Skip to content

Commit 8b31ae6

Browse files
committed
ClubsFunctionConfigFetcher supports encoded value
1 parent 6d9a020 commit 8b31ae6

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/getClubsConfig.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { decode } from './decode'
2+
import { encode } from './encode'
23
import type { ClubsConfiguration, ClubsFunctionConfigFetcher } from './types'
34

45
export const getClubsConfig: (
56
fetcher: ClubsFunctionConfigFetcher
67
) => Promise<readonly [ClubsConfiguration, string]> = async (fetcher) => {
78
const config = await fetcher()
8-
const decoded = decode(config)
9-
return [decoded, config]
9+
const encoded = typeof config === 'string' ? config : encode(config)
10+
const decoded = typeof config === 'string' ? decode(config) : config
11+
return [decoded, encoded]
1012
}

src/types.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,11 @@ export type ClubsFunctionPlugin =
402402
| ClubsFunctionStandardPlugin
403403
| ClubsFunctionThemePlugin
404404

405-
export type ClubsFunctionConfigFetcher = () => string | Promise<string>
405+
export type ClubsFunctionConfigFetcher = () =>
406+
| string
407+
| ClubsConfiguration
408+
| Promise<string>
409+
| Promise<ClubsConfiguration>
406410

407411
export type ClubsFunctionPluginOptionSetter = <T extends ClubsPluginOptions>(
408412
nextOptions: T

0 commit comments

Comments
 (0)