@picked/client 0.0.1-dev.1786065500148 → 0.0.1-dev.1786072899095
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/api-BzK4kXRt.js +38 -0
- package/dist/api-CgENjKwJ.cjs +1 -0
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/docs/explanation/how-picked-works.md +3 -25
- package/dist/docs/reference/sdk/plugins/dynamic-experiences.md +2 -50
- package/dist/docs/reference/tools/vite-plugin.md +8 -90
- package/dist/esm/index.js +452 -499
- package/dist/esm/plugins/dynamic-experiences/index.js +3 -3
- package/dist/esm/server/index.js +46 -43
- package/dist/plugin-DJjtc5df.js +252 -0
- package/dist/plugin-jHxSAqGG.cjs +1 -0
- package/dist/types/entities/feature/feature.d.ts +9 -2
- package/dist/types/entities/feature/feature.d.ts.map +1 -1
- package/dist/types/picked.d.ts +3 -66
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/index.d.ts +0 -1
- package/dist/types/plugins/dynamic-experiences/index.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts +40 -9
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts +23 -15
- package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
- package/dist/types/server/index.d.ts +1 -1
- package/dist/types/server/index.d.ts.map +1 -1
- package/dist/types/server/serialize.d.ts +19 -7
- package/dist/types/server/serialize.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/plugin-EFn9ALEF.cjs +0 -1
- package/dist/plugin-YytfMG0n.js +0 -153
- package/dist/registry-BYtEBdL1.js +0 -111
- package/dist/registry-DtmKJre-.cjs +0 -1
- package/dist/types/data-source/api.d.ts +0 -60
- package/dist/types/data-source/api.d.ts.map +0 -1
- package/dist/types/data-source/provider.d.ts +0 -91
- package/dist/types/data-source/provider.d.ts.map +0 -1
- package/dist/types/data-source/registry.d.ts +0 -27
- package/dist/types/data-source/registry.d.ts.map +0 -1
- package/dist/types/data-source/virtual-data.d.ts +0 -19
- package/dist/types/data-source/virtual-data.d.ts.map +0 -1
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import type { ContentLoader, ExperienceContentResponse, PickedManifestMetadata, ProjectConfig, VirtualPickedData } from '../plugins/dynamic-experiences/types';
|
|
2
|
-
import { isVirtualPickedData } from './virtual-data';
|
|
3
|
-
/** Where a data provider reads project config and CMS content from. */
|
|
4
|
-
export type PickedDataMode = 'bundle' | 'api';
|
|
5
|
-
/** Options for {@link createPickedDataProvider}. */
|
|
6
|
-
export interface PickedDataProviderOptions {
|
|
7
|
-
/** Base URL for the Picked API. Used by `'api'` mode and by every preview session. */
|
|
8
|
-
apiUrl: string;
|
|
9
|
-
/** Project ID to resolve data for. */
|
|
10
|
-
projectId: string;
|
|
11
|
-
/**
|
|
12
|
-
* Which source to read from. Omit to keep the legacy behaviour: `'bundle'` when
|
|
13
|
-
* `virtual:picked/data` resolves, `'api'` otherwise.
|
|
14
|
-
*/
|
|
15
|
-
mode?: PickedDataMode;
|
|
16
|
-
/**
|
|
17
|
-
* Preview token from the current session. A present token forces `'api'` for both config
|
|
18
|
-
* and content and overrides `bundle` and `projectConfig`, because preview renders
|
|
19
|
-
* unpublished data that no bundled snapshot can contain.
|
|
20
|
-
*/
|
|
21
|
-
previewToken?: string;
|
|
22
|
-
/**
|
|
23
|
-
* The `virtual:picked/data` module. Supply it to skip the dynamic import — which is also
|
|
24
|
-
* how a consumer places the module in a chosen chunk, since a module that is both
|
|
25
|
-
* statically and dynamically imported is placed in the static chunk. A value that does not
|
|
26
|
-
* match the module's shape is ignored with a warning, the same as an unresolvable import.
|
|
27
|
-
*/
|
|
28
|
-
bundle?: VirtualPickedData;
|
|
29
|
-
/** Explicit project config. Supersedes both sources, except under a preview token. */
|
|
30
|
-
projectConfig?: ProjectConfig;
|
|
31
|
-
/** Explicit content loader. Supersedes both sources, except under a preview token. */
|
|
32
|
-
getContent?: ContentLoader;
|
|
33
|
-
/** Abort signal applied to API fetches, such as an `AbortSignal.timeout` deadline. */
|
|
34
|
-
signal?: AbortSignal;
|
|
35
|
-
}
|
|
36
|
-
/** Read-only description of what a provider resolved to. */
|
|
37
|
-
export interface PickedDataProviderMeta {
|
|
38
|
-
/** The mode in force, after preview-token resolution. */
|
|
39
|
-
mode: PickedDataMode;
|
|
40
|
-
/** The bundle's manifest metadata, or `null` when not reading from a bundle. */
|
|
41
|
-
manifest: PickedManifestMetadata | null;
|
|
42
|
-
}
|
|
43
|
-
/** Resolves this session's project config and per-experience CMS content. */
|
|
44
|
-
export interface PickedDataProvider {
|
|
45
|
-
/** What this provider resolved to. `manifest` populates once a bundle has been read. */
|
|
46
|
-
readonly meta: PickedDataProviderMeta;
|
|
47
|
-
/** Resolves the project config, or `null` when unavailable. Deduplicated across callers. */
|
|
48
|
-
getProjectConfig: () => Promise<ProjectConfig | null>;
|
|
49
|
-
/** Resolves an experience's content, or `null` when unavailable. Deduplicated per experience id. */
|
|
50
|
-
getContent: (experience: {
|
|
51
|
-
id: string;
|
|
52
|
-
key: string;
|
|
53
|
-
}, options?: {
|
|
54
|
-
signal?: AbortSignal;
|
|
55
|
-
}) => Promise<ExperienceContentResponse | null>;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Attempts to resolve `virtual:picked/data` provided by `@picked/vite-plugin-picked`.
|
|
59
|
-
*
|
|
60
|
-
* The dynamic import uses a literal string specifier (intentionally — using a variable plus
|
|
61
|
-
* `@vite-ignore` defeats Vite's import-analysis, so the plugin's `resolveId` is never called
|
|
62
|
-
* at build time and the bundle ends up with a runtime fetch to a `virtual:` URL that the
|
|
63
|
-
* browser cannot resolve). The SDK's own build marks `virtual:picked/data` as external so
|
|
64
|
-
* this literal import is preserved into the published dist, then downstream Vite builds with
|
|
65
|
-
* `@picked/vite-plugin-picked` resolve it through the plugin pipeline.
|
|
66
|
-
*
|
|
67
|
-
* Returns `null` when the virtual module is unresolvable (the consumer is not using the Vite
|
|
68
|
-
* plugin, or its build did not generate the module). Errors are swallowed: the caller falls
|
|
69
|
-
* back to the API path.
|
|
70
|
-
*
|
|
71
|
-
* @returns {Promise<VirtualPickedData | null>} The virtual module exports, or `null`.
|
|
72
|
-
* @example
|
|
73
|
-
* ```typescript
|
|
74
|
-
* const bundle = await resolveVirtualDataModule()
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
|
-
export declare function resolveVirtualDataModule(): Promise<VirtualPickedData | null>;
|
|
78
|
-
export { isVirtualPickedData };
|
|
79
|
-
/**
|
|
80
|
-
* Creates the data provider for a session.
|
|
81
|
-
*
|
|
82
|
-
* @param {PickedDataProviderOptions} options - Provider configuration.
|
|
83
|
-
* @returns {PickedDataProvider} A provider resolving config and content from one source.
|
|
84
|
-
* @example
|
|
85
|
-
* ```typescript
|
|
86
|
-
* const provider = createPickedDataProvider({ mode: 'api', apiUrl, projectId })
|
|
87
|
-
* const config = await provider.getProjectConfig()
|
|
88
|
-
* ```
|
|
89
|
-
*/
|
|
90
|
-
export declare function createPickedDataProvider(options: PickedDataProviderOptions): PickedDataProvider;
|
|
91
|
-
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/data-source/provider.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,aAAa,EACb,yBAAyB,EACzB,sBAAsB,EACtB,aAAa,EACb,iBAAiB,EAClB,MAAM,sCAAsC,CAAA;AAG7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAEpD,uEAAuE;AACvE,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,KAAK,CAAA;AAQ7C,oDAAoD;AACpD,MAAM,WAAW,yBAAyB;IACxC,sF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,0 @@
|
|
|
1
|
-
import type { VirtualPickedData } from '../plugins/dynamic-experiences/types';
|
|
2
|
-
/**
|
|
3
|
-
* Records the bundle the build generated, for this session's data provider to read.
|
|
4
|
-
*
|
|
5
|
-
* A value that does not match the module shape is refused rather than stored, so a malformed
|
|
6
|
-
* registration lands on the already-defined "no bundle" path instead of an undefined read at
|
|
7
|
-
* the first content resolution. Any usable bundle registered earlier is kept.
|
|
8
|
-
*
|
|
9
|
-
* @param {unknown} bundle - The generated module's exports.
|
|
10
|
-
* @returns {void} Nothing.
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* registerPickedBundle({ projectConfig, experienceContent, manifestMetadata })
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
16
|
-
export declare function registerPickedBundle(bundle: unknown): void;
|
|
17
|
-
/**
|
|
18
|
-
* Reads the registered bundle.
|
|
19
|
-
*
|
|
20
|
-
* @returns {VirtualPickedData | null} The bundle, or `null` when nothing has registered one.
|
|
21
|
-
* @example
|
|
22
|
-
* ```typescript
|
|
23
|
-
* const bundle = readRegisteredBundle()
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
export declare function readRegisteredBundle(): VirtualPickedData | null;
|
|
27
|
-
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/data-source/registry.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AAK7E;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAQ1D;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,IAAI,iBAAiB,GAAG,IAAI,CAE/D"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file The shape guard for the generated `virtual:picked/data` module.
|
|
3
|
-
*
|
|
4
|
-
* Lives apart from the provider and the registry because both validate against it, and a guard
|
|
5
|
-
* shared by two modules that also reference each other would otherwise close an import cycle.
|
|
6
|
-
*/
|
|
7
|
-
import type { VirtualPickedData } from '../plugins/dynamic-experiences/types';
|
|
8
|
-
/**
|
|
9
|
-
* Runtime type guard that validates the shape of a `virtual:picked/data` module.
|
|
10
|
-
*
|
|
11
|
-
* @param {unknown} value - Candidate module exports.
|
|
12
|
-
* @returns {boolean} Whether `value` matches the {@link VirtualPickedData} shape.
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* if (isVirtualPickedData(mod)) { useVirtualModule(mod) }
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export declare function isVirtualPickedData(value: unknown): value is VirtualPickedData;
|
|
19
|
-
//# sourceMappingURL=virtual-data.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-data.d.ts","sourceRoot":"","sources":["../../../src/data-source/virtual-data.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AAE7E;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,iBAAiB,CAU9E"}
|