@picked/client 0.0.1-dev.1786070942751 → 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.
Files changed (43) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/{api-BqZglw7-.js → api-BzK4kXRt.js} +1 -1
  3. package/dist/{api-C5vMi1gb.cjs → api-CgENjKwJ.cjs} +1 -1
  4. package/dist/cjs/index.js +2 -2
  5. package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
  6. package/dist/cjs/server/index.js +1 -1
  7. package/dist/docs/explanation/how-picked-works.md +3 -25
  8. package/dist/docs/reference/sdk/plugins/dynamic-experiences.md +2 -50
  9. package/dist/docs/reference/tools/vite-plugin.md +8 -90
  10. package/dist/esm/index.js +291 -273
  11. package/dist/esm/plugins/dynamic-experiences/index.js +3 -4
  12. package/dist/esm/server/index.js +46 -43
  13. package/dist/plugin-DJjtc5df.js +252 -0
  14. package/dist/plugin-jHxSAqGG.cjs +1 -0
  15. package/dist/types/entities/feature/feature.d.ts +9 -2
  16. package/dist/types/entities/feature/feature.d.ts.map +1 -1
  17. package/dist/types/picked.d.ts +3 -66
  18. package/dist/types/picked.d.ts.map +1 -1
  19. package/dist/types/plugins/dynamic-experiences/index.d.ts +0 -1
  20. package/dist/types/plugins/dynamic-experiences/index.d.ts.map +1 -1
  21. package/dist/types/plugins/dynamic-experiences/plugin.d.ts +40 -9
  22. package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
  23. package/dist/types/plugins/dynamic-experiences/types.d.ts +23 -15
  24. package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
  25. package/dist/types/server/index.d.ts +1 -1
  26. package/dist/types/server/index.d.ts.map +1 -1
  27. package/dist/types/server/serialize.d.ts +19 -7
  28. package/dist/types/server/serialize.d.ts.map +1 -1
  29. package/package.json +3 -3
  30. package/dist/plugin-EFn9ALEF.cjs +0 -1
  31. package/dist/plugin-YytfMG0n.js +0 -153
  32. package/dist/provider-Bng22ugW.cjs +0 -1
  33. package/dist/provider-hAf_rar9.js +0 -68
  34. package/dist/registry-CdPPoopn.js +0 -74
  35. package/dist/registry-DpNNJt2g.cjs +0 -1
  36. package/dist/types/data-source/api.d.ts +0 -60
  37. package/dist/types/data-source/api.d.ts.map +0 -1
  38. package/dist/types/data-source/provider.d.ts +0 -90
  39. package/dist/types/data-source/provider.d.ts.map +0 -1
  40. package/dist/types/data-source/registry.d.ts +0 -26
  41. package/dist/types/data-source/registry.d.ts.map +0 -1
  42. package/dist/types/data-source/virtual-data.d.ts +0 -19
  43. package/dist/types/data-source/virtual-data.d.ts.map +0 -1
@@ -1,90 +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 resolve `'bundle'` when a bundle is available and
13
- * `'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, supplied directly to skip both the registry and the
24
- * dynamic import. A value that fails the shape guard is ignored with a warning, the same as
25
- * an unresolvable import.
26
- */
27
- bundle?: VirtualPickedData;
28
- /** Explicit project config. Supersedes both sources, except under a preview token. */
29
- projectConfig?: ProjectConfig;
30
- /** Explicit content loader. Supersedes both sources, except under a preview token. */
31
- getContent?: ContentLoader;
32
- /** Abort signal applied to API fetches, such as an `AbortSignal.timeout` deadline. */
33
- signal?: AbortSignal;
34
- }
35
- /** Read-only description of what a provider resolved to. */
36
- export interface PickedDataProviderMeta {
37
- /** The mode in force, after preview-token resolution. */
38
- mode: PickedDataMode;
39
- /** The bundle's manifest metadata, or `null` when not reading from a bundle. */
40
- manifest: PickedManifestMetadata | null;
41
- }
42
- /** Resolves this session's project config and per-experience CMS content. */
43
- export interface PickedDataProvider {
44
- /** What this provider resolved to. `manifest` populates once a bundle has been read. */
45
- readonly meta: PickedDataProviderMeta;
46
- /** Resolves the project config, or `null` when unavailable. Deduplicated across callers. */
47
- getProjectConfig: () => Promise<ProjectConfig | null>;
48
- /** Resolves an experience's content, or `null` when unavailable. Deduplicated per experience id. */
49
- getContent: (experience: {
50
- id: string;
51
- key: string;
52
- }, options?: {
53
- signal?: AbortSignal;
54
- }) => Promise<ExperienceContentResponse | null>;
55
- }
56
- /**
57
- * Attempts to resolve `virtual:picked/data` provided by `@picked/vite-plugin-picked`.
58
- *
59
- * The dynamic import uses a literal string specifier (intentionally — using a variable plus
60
- * `@vite-ignore` defeats Vite's import-analysis, so the plugin's `resolveId` is never called
61
- * at build time and the bundle ends up with a runtime fetch to a `virtual:` URL that the
62
- * browser cannot resolve). The SDK's own build marks `virtual:picked/data` as external so
63
- * this literal import is preserved into the published dist, then downstream Vite builds with
64
- * `@picked/vite-plugin-picked` resolve it through the plugin pipeline.
65
- *
66
- * Returns `null` when the virtual module is unresolvable (the consumer is not using the Vite
67
- * plugin, or its build did not generate the module). Errors are swallowed: the caller falls
68
- * back to the API path.
69
- *
70
- * @returns {Promise<VirtualPickedData | null>} The virtual module exports, or `null`.
71
- * @example
72
- * ```typescript
73
- * const bundle = await resolveVirtualDataModule()
74
- * ```
75
- */
76
- export declare function resolveVirtualDataModule(): Promise<VirtualPickedData | null>;
77
- export { isVirtualPickedData };
78
- /**
79
- * Creates the data provider for a session.
80
- *
81
- * @param {PickedDataProviderOptions} options - Provider configuration.
82
- * @returns {PickedDataProvider} A provider resolving config and content from one source.
83
- * @example
84
- * ```typescript
85
- * const provider = createPickedDataProvider({ mode: 'api', apiUrl, projectId })
86
- * const config = await provider.getProjectConfig()
87
- * ```
88
- */
89
- export declare function createPickedDataProvider(options: PickedDataProviderOptions): PickedDataProvider;
90
- //# sourceMappingURL=provider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/data-source/provider.ts"],"names":[],"mappings":"AAUA,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,sFAAsF;IACtF,MAAM,EAAE,MAAM,CAAA;IACd,sCAAsC;IACtC,SAAS,EAAE,MAAM,CAAA;IACjB;;;OAGG;IACH,IAAI,CAAC,EAAE,cAAc,CAAA;IACrB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;;OAIG;IACH,MAAM,CAAC,EAAE,iBAAiB,CAAA;IAC1B,sFAAsF;IACtF,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B,sFAAsF;IACtF,UAAU,CAAC,EAAE,aAAa,CAAA;IAC1B,sFAAsF;IACtF,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB;AAED,4DAA4D;AAC5D,MAAM,WAAW,sBAAsB;IACrC,yDAAyD;IACzD,IAAI,EAAE,cAAc,CAAA;IACpB,gFAAgF;IAChF,QAAQ,EAAE,sBAAsB,GAAG,IAAI,CAAA;CACxC;AAED,6EAA6E;AAC7E,MAAM,WAAW,kBAAkB;IACjC,wFAAwF;IACxF,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAA;IACrC,4FAA4F;IAC5F,gBAAgB,EAAE,MAAM,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAAA;IACrD,oGAAoG;IACpG,UAAU,EAAE,CACV,UAAU,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,EACvC,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,KAC/B,OAAO,CAAC,yBAAyB,GAAG,IAAI,CAAC,CAAA;CAC/C;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAYlF;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAA;AAyB9B;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,kBAAkB,CAuK/F"}
@@ -1,26 +0,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 fails the shape guard is refused, so a malformed registration lands on the
6
- * "no bundle" path. Any usable bundle registered earlier is kept.
7
- *
8
- * @param {unknown} bundle - The generated module's exports.
9
- * @returns {void} Nothing.
10
- * @example
11
- * ```typescript
12
- * registerPickedBundle({ projectConfig, experienceContent, manifestMetadata })
13
- * ```
14
- */
15
- export declare function registerPickedBundle(bundle: unknown): void;
16
- /**
17
- * Reads the registered bundle.
18
- *
19
- * @returns {VirtualPickedData | null} The bundle, or `null` when nothing has registered one.
20
- * @example
21
- * ```typescript
22
- * const bundle = readRegisteredBundle()
23
- * ```
24
- */
25
- export declare function readRegisteredBundle(): VirtualPickedData | null;
26
- //# sourceMappingURL=registry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/data-source/registry.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AAK7E;;;;;;;;;;;;GAYG;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"}