@picked/client 0.0.1-dev.1786001783467 → 0.0.1-dev.1786065500148
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/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/reference/sdk/plugins/dynamic-experiences.md +11 -13
- package/dist/docs/reference/tools/vite-plugin.md +36 -18
- package/dist/esm/index.js +354 -270
- package/dist/esm/plugins/dynamic-experiences/index.js +3 -3
- package/dist/esm/server/index.js +36 -39
- package/dist/plugin-EFn9ALEF.cjs +1 -0
- package/dist/plugin-YytfMG0n.js +153 -0
- package/dist/registry-BYtEBdL1.js +111 -0
- package/dist/registry-DtmKJre-.cjs +1 -0
- package/dist/types/data-source/provider.d.ts +21 -16
- package/dist/types/data-source/provider.d.ts.map +1 -1
- package/dist/types/data-source/registry.d.ts +11 -20
- package/dist/types/data-source/registry.d.ts.map +1 -1
- package/dist/types/data-source/virtual-data.d.ts +19 -0
- package/dist/types/data-source/virtual-data.d.ts.map +1 -0
- package/dist/types/picked.d.ts +50 -1
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/index.d.ts +1 -3
- package/dist/types/plugins/dynamic-experiences/index.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts +8 -7
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts +0 -24
- 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 +7 -25
- package/dist/types/server/serialize.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/api-BivzqML_.cjs +0 -1
- package/dist/api-i7XfDMTd.js +0 -38
- package/dist/plugin-Cbhl3kSg.js +0 -300
- package/dist/plugin-h2BTDtJ0.cjs +0 -1
package/dist/types/picked.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ import { type EventBusPayload, type EventHistoryStore } from './utils/events';
|
|
|
16
16
|
import type { Field } from './entities/field/field';
|
|
17
17
|
import type { ExperienceStep } from './entities/step/step';
|
|
18
18
|
import type { Content, ContentDataPatch } from './entities/content/content';
|
|
19
|
-
import type { ContentLoader } from './plugins/dynamic-experiences/types';
|
|
19
|
+
import type { ContentLoader, ExperienceContentResponse, ProjectConfig } from './plugins/dynamic-experiences/types';
|
|
20
20
|
import type { Action } from './entities/action/action';
|
|
21
21
|
import { type Condition } from './entities/condition/condition';
|
|
22
22
|
import type { SessionEntity } from './entities/session/session';
|
|
@@ -74,6 +74,7 @@ export declare class Picked {
|
|
|
74
74
|
*/
|
|
75
75
|
previewEmbedderOrigins: string[] | null;
|
|
76
76
|
private readonly plugins;
|
|
77
|
+
private readonly dataProviders;
|
|
77
78
|
readonly eventBus: EventCallable<EventBusPayload>;
|
|
78
79
|
readonly events: EventHistoryStore;
|
|
79
80
|
readonly projectId: string;
|
|
@@ -276,6 +277,54 @@ export declare class Picked {
|
|
|
276
277
|
context?: Record<string, unknown>;
|
|
277
278
|
}, string, Error>;
|
|
278
279
|
constructor(options: CreateClientOptions);
|
|
280
|
+
/**
|
|
281
|
+
* Resolves the data provider backing a given preview token, building it once per token.
|
|
282
|
+
*
|
|
283
|
+
* @param {string | undefined} previewToken - Preview token for the caller, when there is one.
|
|
284
|
+
* @returns {PickedDataProvider} The provider for that token.
|
|
285
|
+
* @example
|
|
286
|
+
* const provider = client.dataProviderFor(undefined)
|
|
287
|
+
*/
|
|
288
|
+
private dataProviderFor;
|
|
289
|
+
/**
|
|
290
|
+
* Resolves this project's configuration.
|
|
291
|
+
*
|
|
292
|
+
* Reads the build-time bundle when one registered itself, and the Picked API otherwise. A
|
|
293
|
+
* preview token forces the API, because preview renders unpublished data no bundle can hold.
|
|
294
|
+
* Deduplicated per token, so several callers in one request cost one resolution.
|
|
295
|
+
*
|
|
296
|
+
* @param {object} [options] - Per-call resolution inputs.
|
|
297
|
+
* @param {string} [options.previewToken] - Preview token, forcing a live read.
|
|
298
|
+
* @param {AbortSignal} [options.signal] - Signal applied to an API read.
|
|
299
|
+
* @returns {Promise<ProjectConfig>} The project configuration.
|
|
300
|
+
* @throws {Error} When the configuration cannot be resolved from any source.
|
|
301
|
+
* @example
|
|
302
|
+
* const config = await client.getProjectConfig()
|
|
303
|
+
*/
|
|
304
|
+
getProjectConfig(options?: {
|
|
305
|
+
previewToken?: string;
|
|
306
|
+
signal?: AbortSignal;
|
|
307
|
+
}): Promise<ProjectConfig>;
|
|
308
|
+
/**
|
|
309
|
+
* Resolves one experience's CMS content, from the same source as the configuration.
|
|
310
|
+
*
|
|
311
|
+
* @param {{ id: string; key: string }} experience - The experience to resolve content for.
|
|
312
|
+
* @param {string} experience.id - Experience id, which keys bundled content.
|
|
313
|
+
* @param {string} experience.key - Experience key, for a content loader that prefers it.
|
|
314
|
+
* @param {object} [options] - Per-call resolution inputs.
|
|
315
|
+
* @param {string} [options.previewToken] - Preview token, forcing a live read.
|
|
316
|
+
* @param {AbortSignal} [options.signal] - Deadline for this call's API read, if it makes one.
|
|
317
|
+
* @returns {Promise<ExperienceContentResponse | null>} The content, or `null` when it has none.
|
|
318
|
+
* @example
|
|
319
|
+
* const content = await client.getExperienceContent({ id: 'exp_1', key: 'promo' })
|
|
320
|
+
*/
|
|
321
|
+
getExperienceContent(experience: {
|
|
322
|
+
id: string;
|
|
323
|
+
key: string;
|
|
324
|
+
}, options?: {
|
|
325
|
+
previewToken?: string;
|
|
326
|
+
signal?: AbortSignal;
|
|
327
|
+
}): Promise<ExperienceContentResponse | null>;
|
|
279
328
|
/**
|
|
280
329
|
* Lazily starts the preview channel when this frame is a live-preview session: the outbound
|
|
281
330
|
* bridge, which reports the frame's URL to the dashboard, and the inbound receiver, which applies
|
|
@@ -1 +1 @@
|
|
|
1
|
-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iB,cAAe,SAAS,KAAG,IAAI,CAE/C;IAED,aAAa,UAAW,KAAK,KAAG,IAAI,CAEnC;IAED,YAAY,SAAU,cAAc,KAAG,IAAI,CAE1C;IAED,eAAe,YAAa,OAAO,KAAG,IAAI,CAEzC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,YAAY,OAAQ,MAAM,SAAS,gBAAgB,KAAG,IAAI,CAEzD;IAED,cAAc,QAAS,MAAM,UAAU,MAAM,KAAG,IAAI,CAEnD;IAED,kBAAkB,eAAgB,UAAU,KAAG,IAAI,CAMlD;IAED;;;;;;;;;OASG;IAEH,oBAAoB,iBACJ,MAAM,YACV,uBAAuB,KAChC,OAAO,CAAC,IAAI,CAAC,CAEf;IACD;;;;;;;;;OASG;IAEH,qBAAqB,kBACJ,MAAM,YACX,uBAAuB,KAChC,OAAO,CAAC,IAAI,CAAC,CAEf;IAED;;;;;;;;OAQG;IAEH,kBAAkB,iBAAwB,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC,CAE/D;IAED;;;;;;;;OAQG;IAEH,mBAAmB,kBAAyB,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC,CAEjE;IAED,OAAO,CAAC,YAAY;IAsBpB,OAAO,CAAC,aAAa;IAsCrB,OAAO,CAAC,eAAe;IAgBvB,OAAO,CAAC,YAAY;IAgBpB,OAAO,CAAC,eAAe;IAWvB,eAAe,eAAgB,MAAM,KAAG,iBAAiB,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAE1F;CACF"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/** @file Public exports for the dynamic-experiences plugin (project config + per-experience content resolution). */
|
|
2
2
|
export { dynamicExperiencesPlugin, fetchExperienceContent, fetchProject } from './plugin';
|
|
3
3
|
export { createClientHeaders } from '../../utils/client-headers';
|
|
4
|
-
export {
|
|
5
|
-
export { registerPickedBundle, getRegisteredBundle } from '../../data-source/registry';
|
|
6
|
-
export type { PickedDataMode, PickedDataProvider, PickedDataProviderMeta, PickedDataProviderOptions, } from '../../data-source/provider';
|
|
4
|
+
export { registerPickedBundle } from '../../data-source/registry';
|
|
7
5
|
export type * from './types';
|
|
8
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dynamic-experiences/index.ts"],"names":[],"mappings":"AAAA,oHAAoH;AACpH,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACzF,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dynamic-experiences/index.ts"],"names":[],"mappings":"AAAA,oHAAoH;AACpH,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACzF,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAIhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AACjE,mBAAmB,SAAS,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Plugin } from '../../entities/plugin/plugin';
|
|
2
2
|
import type { Picked } from '../../picked';
|
|
3
|
-
import type {
|
|
3
|
+
import type { ProjectConfig } from './types';
|
|
4
4
|
export { fetchProject, fetchExperienceContent } from '../../data-source/api';
|
|
5
5
|
/**
|
|
6
6
|
* Synchronously registers a complete project config with the client: features, conditions,
|
|
@@ -25,13 +25,14 @@ export declare function registerProjectConfig(client: Picked, config: ProjectCon
|
|
|
25
25
|
sessionId: string;
|
|
26
26
|
}): void;
|
|
27
27
|
/**
|
|
28
|
-
* Plugin that
|
|
29
|
-
*
|
|
28
|
+
* Plugin that resolves project configuration through the client and registers features,
|
|
29
|
+
* steps, fields, and experiences with it.
|
|
30
30
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
31
|
+
* Resolution runs during the `onStart` hook, before experience initialisation, and reads
|
|
32
|
+
* whichever source the client resolves to — the build-time bundle when one registered itself,
|
|
33
|
+
* the Picked API otherwise. Search param feature overrides take precedence over resolved
|
|
34
|
+
* values.
|
|
33
35
|
*
|
|
34
|
-
* @param {DynamicExperiencesPluginOptions} [options] - Optional plugin configuration.
|
|
35
36
|
* @returns {Plugin} A configured Picked plugin.
|
|
36
37
|
* @example
|
|
37
38
|
* ```typescript
|
|
@@ -44,5 +45,5 @@ export declare function registerProjectConfig(client: Picked, config: ProjectCon
|
|
|
44
45
|
* })
|
|
45
46
|
* ```
|
|
46
47
|
*/
|
|
47
|
-
export declare function dynamicExperiencesPlugin(
|
|
48
|
+
export declare function dynamicExperiencesPlugin(): Plugin;
|
|
48
49
|
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dynamic-experiences/plugin.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dynamic-experiences/plugin.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAG1C,OAAO,KAAK,EAGV,aAAa,EAGd,MAAM,SAAS,CAAA;AAEhB,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAyI5E;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACjD,IAAI,CAMN;AAoMD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,CA4DjD"}
|
|
@@ -5,7 +5,6 @@ import type { ExperienceStep } from '../../entities/step/step';
|
|
|
5
5
|
import type { Field } from '../../entities/field/field';
|
|
6
6
|
import type { ExperienceEdge, ExperienceNode, ExperienceTarget } from '../../entities/experience/experience';
|
|
7
7
|
import type { Condition } from '../../entities/condition/condition';
|
|
8
|
-
import type { PickedDataProvider } from '../../data-source/provider';
|
|
9
8
|
import type { LogicRule, LogicValue } from '../../logic-engine';
|
|
10
9
|
/**
|
|
11
10
|
* Wire-format step as returned by the Picked API. Matches {@link ExperienceStep}
|
|
@@ -79,29 +78,6 @@ export interface ProjectConfig {
|
|
|
79
78
|
*/
|
|
80
79
|
previewEmbedderOrigins?: string[];
|
|
81
80
|
}
|
|
82
|
-
export interface DynamicExperiencesPluginOptions {
|
|
83
|
-
apiUrl?: string;
|
|
84
|
-
/**
|
|
85
|
-
* A pre-built data provider, used verbatim. Supply this to share one provider between the
|
|
86
|
-
* browser plugin and a server-side `serialize()` call, or to inject a stub in tests.
|
|
87
|
-
* Supersedes `projectConfig` and `getContent`.
|
|
88
|
-
*/
|
|
89
|
-
dataProvider?: PickedDataProvider;
|
|
90
|
-
projectConfig?: ProjectConfig;
|
|
91
|
-
/**
|
|
92
|
-
* Customer-supplied content fetcher. When provided, supersedes both the virtual
|
|
93
|
-
* data module and the runtime API for per-experience content resolution.
|
|
94
|
-
* Customers using this override are responsible for project ↔ content version
|
|
95
|
-
* consistency. Receives the resolved experience and the current preview token
|
|
96
|
-
* (when present) so the customer can decide preview semantics themselves.
|
|
97
|
-
*/
|
|
98
|
-
getContent?: (experience: {
|
|
99
|
-
id: string;
|
|
100
|
-
key: string;
|
|
101
|
-
}, options?: {
|
|
102
|
-
previewToken?: string;
|
|
103
|
-
}) => Promise<ExperienceContentResponse | null>;
|
|
104
|
-
}
|
|
105
81
|
export interface FetchProjectOptions {
|
|
106
82
|
previewToken?: string;
|
|
107
83
|
headers?: Record<string, string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dynamic-experiences/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAA;AACvD,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,gBAAgB,EACjB,MAAM,sCAAsC,CAAA;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAA;AACnE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dynamic-experiences/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAA;AACvD,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,gBAAgB,EACjB,MAAM,sCAAsC,CAAA;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAA;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAE/D;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,cAAc,EAAE,WAAW,GAAG,oBAAoB,CAAC,GAAG;IACzF,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;CACpB,CAAA;AAED,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,EAA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EAAE,MAAM,CAAC,CAAA;IAChC,sGAAsG;IACtG,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,0FAA0F;IAC1F,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC9B;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,yBAAyB;IACxC,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,OAAO,EAAE,WAAW,EAAE,CAAA;CACvB;AAED;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,CAC1B,UAAU,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EACvC,OAAO,CAAC,EAAE;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,KAChC,OAAO,CAAC,yBAAyB,GAAG,IAAI,CAAC,CAAA;AAE9C;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,6FAA6F;IAC7F,IAAI,EAAE,KAAK,GAAG,OAAO,CAAA;IACrB,8FAA8F;IAC9F,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,+DAA+D;IAC/D,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,iEAAiE;IACjE,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;CAC3B;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,aAAa,EAAE,aAAa,CAAA;IAC5B,iBAAiB,EAAE,aAAa,CAAA;IAChC,gBAAgB,EAAE,sBAAsB,CAAA;CACzC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Picked } from '../picked';
|
|
2
2
|
import type { ExperienceInstance } from '../entities/experience-instance/experience-instance';
|
|
3
3
|
import type { AdaptedComponent } from '../entities/component/component';
|
|
4
|
-
export { serialize, type PickedSnapshot, type SerializeParams, type SerializeAttributes, type SerializeLocation,
|
|
4
|
+
export { serialize, type PickedSnapshot, type SerializeParams, type SerializeAttributes, type SerializeLocation, } from './serialize';
|
|
5
5
|
export { createExperienceInstance } from '../entities/experience-instance/experience-instance';
|
|
6
6
|
export type { ExperienceInstance } from '../entities/experience-instance/experience-instance';
|
|
7
7
|
export { registerProjectConfig } from '../plugins/dynamic-experiences/plugin';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qDAAqD,CAAA;AAE7F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAA;AAEvE,OAAO,EACL,SAAS,EACT,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qDAAqD,CAAA;AAE7F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAA;AAEvE,OAAO,EACL,SAAS,EACT,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,GACvB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,wBAAwB,EAAE,MAAM,qDAAqD,CAAA;AAC9F,YAAY,EAAE,kBAAkB,EAAE,MAAM,qDAAqD,CAAA;AAC7F,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAA;AAC7E,OAAO,EACL,QAAQ,EACR,qBAAqB,EACrB,kBAAkB,EAClB,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,kCAAkC,CAAA;AACzC,YAAY,EACV,WAAW,EACX,aAAa,EACb,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,sCAAsC,CAAA;AA0B7C,MAAM,WAAW,QAAQ,CAAC,CAAC,GAAG,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC;IAC7D,gBAAgB,EAAE,CAAC,SAAS,EAAE,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAA;IAC3E,MAAM,EAAE,CACN,SAAS,EAAE,CAAC,EACZ,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,kBAAkB,KAC3B,OAAO,CAAC;QACX,IAAI,EAAE,MAAM,CAAA;QACZ,IAAI,EAAE,MAAM,CAAA;KACb,CAAC,CAAA;CACH;AAmBD;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAoJ/E"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Picked } from '../picked';
|
|
2
|
-
import type {
|
|
3
|
-
import type { ContentBlob, ExperienceContentResponse, ProjectConfig } from '../plugins/dynamic-experiences/types';
|
|
2
|
+
import type { ContentBlob, ProjectConfig } from '../plugins/dynamic-experiences/types';
|
|
4
3
|
/** Subset of `Location` fields that can be injected into the selection context. */
|
|
5
4
|
export interface SerializeLocation {
|
|
6
5
|
href: string;
|
|
@@ -17,38 +16,21 @@ export interface SerializeLocation {
|
|
|
17
16
|
export interface SerializeAttributes {
|
|
18
17
|
location?: Partial<SerializeLocation>;
|
|
19
18
|
}
|
|
20
|
-
/** Customer-supplied content fetcher used in place of the runtime API during serialization. */
|
|
21
|
-
export type SerializeGetContent = (experience: {
|
|
22
|
-
id: string;
|
|
23
|
-
key: string;
|
|
24
|
-
}, options?: {
|
|
25
|
-
previewToken?: string;
|
|
26
|
-
}) => Promise<ExperienceContentResponse | null>;
|
|
27
19
|
/** Parameters for {@link serialize}. */
|
|
28
20
|
export interface SerializeParams {
|
|
29
|
-
/** The project config to register and select against. */
|
|
30
|
-
projectConfig: ProjectConfig;
|
|
31
21
|
/** URL attributes injected into the selection context. */
|
|
32
22
|
attributes?: SerializeAttributes;
|
|
33
|
-
/** Optional content fetcher; falls back to the runtime API when omitted. */
|
|
34
|
-
getContent?: SerializeGetContent;
|
|
35
23
|
/**
|
|
36
|
-
* Preview token
|
|
37
|
-
* preview
|
|
38
|
-
* so the token cannot be recovered otherwise.
|
|
24
|
+
* Preview token for this request, so preview (unpublished) config and content resolve during
|
|
25
|
+
* preview SSR. The server has no `searchParams`, so the token cannot be recovered otherwise.
|
|
39
26
|
*/
|
|
40
27
|
previewToken?: string;
|
|
41
28
|
/**
|
|
42
|
-
* Per-content-fetch timeout in milliseconds for the
|
|
43
|
-
*
|
|
44
|
-
*
|
|
29
|
+
* Per-content-fetch timeout in milliseconds for the API path, so a slow or hung upstream cannot
|
|
30
|
+
* stall the SSR render indefinitely. On timeout the blob is skipped and the render proceeds.
|
|
31
|
+
* Defaults to {@link DEFAULT_CONTENT_TIMEOUT_MS}.
|
|
45
32
|
*/
|
|
46
33
|
timeoutMs?: number;
|
|
47
|
-
/**
|
|
48
|
-
* Data provider used to resolve content, so the server honours the same `mode` contract as the
|
|
49
|
-
* browser. Omit to fetch from the Picked API with the per-fetch timeout above.
|
|
50
|
-
*/
|
|
51
|
-
dataProvider?: PickedDataProvider;
|
|
52
34
|
}
|
|
53
35
|
/**
|
|
54
36
|
* Plain-JSON SSR snapshot produced by {@link serialize} and consumed by the client provider.
|
|
@@ -86,5 +68,5 @@ export interface PickedSnapshot {
|
|
|
86
68
|
* attributes: { location: { pathname: '/promo' } },
|
|
87
69
|
* })
|
|
88
70
|
*/
|
|
89
|
-
export declare function serialize(client: Picked, params
|
|
71
|
+
export declare function serialize(client: Picked, params?: SerializeParams): Promise<PickedSnapshot>;
|
|
90
72
|
//# sourceMappingURL=serialize.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../../src/server/serialize.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../../src/server/serialize.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAIvC,OAAO,KAAK,EACV,WAAW,EACX,aAAa,EAEd,MAAM,sCAAsC,CAAA;AAE7C,mFAAmF;AACnF,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb;AAED,mFAAmF;AACnF,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAA;CACtC;AAKD,wCAAwC;AACxC,MAAM,WAAW,eAAe;IAC9B,0DAA0D;IAC1D,UAAU,CAAC,EAAE,mBAAmB,CAAA;IAChC;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,qFAAqF;IACrF,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,gFAAgF;IAChF,aAAa,EAAE,aAAa,CAAA;IAC5B,0DAA0D;IAC1D,OAAO,EAAE,WAAW,EAAE,CAAA;IACtB,gEAAgE;IAChE,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC1C;AAoCD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,SAAS,CAC7B,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,eAAoB,GAC3B,OAAO,CAAC,cAAc,CAAC,CA0EzB"}
|
package/package.json
CHANGED
package/dist/api-BivzqML_.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function e(e,t){return{"Picked-Client":e,"Picked-Version":t}}var t=()=>`0.0.1-dev.1786001783467`,n=`v1`;function r(e,t){return new URL(`/api/${n}/${t}`,e).toString()}function i(n){return{...e(`sdk`,t()),...n}}async function a(e,t,n,a){let o=r(e,t);return fetch(o,{headers:i(n),signal:a})}async function o(e,t,n,a){let o=r(e,t);return fetch(o,{method:`POST`,headers:{"Content-Type":`application/json`,...i(a)},body:JSON.stringify(n)})}Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return a}});
|
package/dist/api-i7XfDMTd.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
function e(e, t) {
|
|
2
|
-
return {
|
|
3
|
-
"Picked-Client": e,
|
|
4
|
-
"Picked-Version": t
|
|
5
|
-
};
|
|
6
|
-
}
|
|
7
|
-
//#endregion
|
|
8
|
-
//#region src/utils/version.ts
|
|
9
|
-
var t = () => "0.0.1-dev.1786001783467", n = "v1";
|
|
10
|
-
function r(e, t) {
|
|
11
|
-
return new URL(`/api/${n}/${t}`, e).toString();
|
|
12
|
-
}
|
|
13
|
-
function i(n) {
|
|
14
|
-
return {
|
|
15
|
-
...e("sdk", t()),
|
|
16
|
-
...n
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
async function a(e, t, n, a) {
|
|
20
|
-
let o = r(e, t);
|
|
21
|
-
return fetch(o, {
|
|
22
|
-
headers: i(n),
|
|
23
|
-
signal: a
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
async function o(e, t, n, a) {
|
|
27
|
-
let o = r(e, t);
|
|
28
|
-
return fetch(o, {
|
|
29
|
-
method: "POST",
|
|
30
|
-
headers: {
|
|
31
|
-
"Content-Type": "application/json",
|
|
32
|
-
...i(a)
|
|
33
|
-
},
|
|
34
|
-
body: JSON.stringify(n)
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
//#endregion
|
|
38
|
-
export { e as i, o as n, t as r, a as t };
|
package/dist/plugin-Cbhl3kSg.js
DELETED
|
@@ -1,300 +0,0 @@
|
|
|
1
|
-
import "./logger-DMN6TxJJ.js";
|
|
2
|
-
import { t as e } from "./api-i7XfDMTd.js";
|
|
3
|
-
import { attach as t } from "effector";
|
|
4
|
-
function n(e) {
|
|
5
|
-
return typeof e == "object" && !!e;
|
|
6
|
-
}
|
|
7
|
-
function r(e) {
|
|
8
|
-
return n(e) && "features" in e && Array.isArray(e.features);
|
|
9
|
-
}
|
|
10
|
-
function i(e) {
|
|
11
|
-
return !n(e) || !("experienceId" in e) || !("content" in e) ? !1 : Array.isArray(e.content);
|
|
12
|
-
}
|
|
13
|
-
function a(e) {
|
|
14
|
-
try {
|
|
15
|
-
let t = new URL(e).hostname;
|
|
16
|
-
return t === "localhost" || t === "127.0.0.1" || t === "::1";
|
|
17
|
-
} catch {
|
|
18
|
-
return !1;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
function o(e) {
|
|
22
|
-
if (!n(e) || !("cause" in e)) return !1;
|
|
23
|
-
let { cause: t } = e;
|
|
24
|
-
return !n(t) || !("code" in t) ? !1 : t.code === "ECONNREFUSED";
|
|
25
|
-
}
|
|
26
|
-
async function s(t, n, i) {
|
|
27
|
-
let s = i?.previewToken ? `projects/${n}?preview_token=${encodeURIComponent(i.previewToken)}` : `projects/${n}`, c;
|
|
28
|
-
try {
|
|
29
|
-
c = await e(t, s, i?.headers, i?.signal);
|
|
30
|
-
} catch (e) {
|
|
31
|
-
return a(t) && o(e), null;
|
|
32
|
-
}
|
|
33
|
-
if (!c.ok) return `${c.status.toString()}`, null;
|
|
34
|
-
let l;
|
|
35
|
-
try {
|
|
36
|
-
l = await c.json();
|
|
37
|
-
} catch {
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
return r(l) ? l : null;
|
|
41
|
-
}
|
|
42
|
-
async function c(t, n, r, s) {
|
|
43
|
-
let c = s?.previewToken ? `projects/${n}/experiences/${r}/content?preview_token=${encodeURIComponent(s.previewToken)}` : `projects/${n}/experiences/${r}/content`, l;
|
|
44
|
-
try {
|
|
45
|
-
l = await e(t, c, s?.headers, s?.signal);
|
|
46
|
-
} catch (e) {
|
|
47
|
-
return a(t) && o(e) || `${r}`, null;
|
|
48
|
-
}
|
|
49
|
-
if (!l.ok) return `${r}${l.status.toString()}`, null;
|
|
50
|
-
let u;
|
|
51
|
-
try {
|
|
52
|
-
u = await l.json();
|
|
53
|
-
} catch {
|
|
54
|
-
return `${r}`, null;
|
|
55
|
-
}
|
|
56
|
-
return i(u) ? u : (`${r}`, null);
|
|
57
|
-
}
|
|
58
|
-
//#endregion
|
|
59
|
-
//#region src/data-source/registry.ts
|
|
60
|
-
var l;
|
|
61
|
-
function u(e) {
|
|
62
|
-
l = e;
|
|
63
|
-
}
|
|
64
|
-
function d() {
|
|
65
|
-
return l;
|
|
66
|
-
}
|
|
67
|
-
//#endregion
|
|
68
|
-
//#region src/data-source/provider.ts
|
|
69
|
-
var f = "bundle", p = "api";
|
|
70
|
-
async function m() {
|
|
71
|
-
try {
|
|
72
|
-
let e = await import("virtual:picked/data");
|
|
73
|
-
return h(e) ? e : null;
|
|
74
|
-
} catch {
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
function h(e) {
|
|
79
|
-
if (typeof e != "object" || !e || !("projectConfig" in e) || !("experienceContent" in e) || !("manifestMetadata" in e)) return !1;
|
|
80
|
-
let { experienceContent: t } = e;
|
|
81
|
-
return typeof t == "function";
|
|
82
|
-
}
|
|
83
|
-
function g(e) {
|
|
84
|
-
if (e === void 0 || h(e)) return e;
|
|
85
|
-
}
|
|
86
|
-
function _(e) {
|
|
87
|
-
let { apiUrl: t, projectId: n, previewToken: r, signal: i } = e, a = !!r, o = a ? void 0 : e.projectConfig, l = e.getContent, u = {
|
|
88
|
-
mode: p,
|
|
89
|
-
manifest: null
|
|
90
|
-
}, h, _, v = /* @__PURE__ */ new Map();
|
|
91
|
-
function y() {
|
|
92
|
-
return a ? Promise.resolve(null) : (h ??= b(), h);
|
|
93
|
-
}
|
|
94
|
-
async function b() {
|
|
95
|
-
return g(d()) || m();
|
|
96
|
-
}
|
|
97
|
-
function x(e) {
|
|
98
|
-
u.mode = e ? f : p, u.manifest = e ? e.manifestMetadata : null;
|
|
99
|
-
}
|
|
100
|
-
async function S() {
|
|
101
|
-
if (o) return x(await y()), o;
|
|
102
|
-
let e = await y();
|
|
103
|
-
return x(e), e ? e.projectConfig : s(t, n, {
|
|
104
|
-
...r !== void 0 && { previewToken: r },
|
|
105
|
-
...i !== void 0 && { signal: i }
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
async function C(e) {
|
|
109
|
-
let a = r === void 0 ? void 0 : { previewToken: r };
|
|
110
|
-
if (l) return l(e, a);
|
|
111
|
-
let o = await y();
|
|
112
|
-
if (x(o), o) try {
|
|
113
|
-
return await o.experienceContent(e, a);
|
|
114
|
-
} catch {
|
|
115
|
-
return `${e.id}`, null;
|
|
116
|
-
}
|
|
117
|
-
return c(t, n, e.id, {
|
|
118
|
-
...r !== void 0 && { previewToken: r },
|
|
119
|
-
...i !== void 0 && { signal: i }
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
return {
|
|
123
|
-
meta: u,
|
|
124
|
-
getProjectConfig: () => (_ ??= S(), _),
|
|
125
|
-
getContent: (e) => {
|
|
126
|
-
let t = v.get(e.id);
|
|
127
|
-
if (t) return t;
|
|
128
|
-
let n = C(e).finally(() => {
|
|
129
|
-
v.delete(e.id);
|
|
130
|
-
});
|
|
131
|
-
return v.set(e.id, n), n;
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
//#endregion
|
|
136
|
-
//#region src/plugins/dynamic-experiences/hash.ts
|
|
137
|
-
function v(e) {
|
|
138
|
-
let t = 2166136261;
|
|
139
|
-
for (let n of e) t ^= n.codePointAt(0) ?? 0, t = Math.imul(t, 16777619);
|
|
140
|
-
return t >>> 0;
|
|
141
|
-
}
|
|
142
|
-
function y(e) {
|
|
143
|
-
let t = e;
|
|
144
|
-
return t ^= t >>> 16, t = Math.imul(t, 2246822507), t ^= t >>> 13, t = Math.imul(t, 3266489909), t ^= t >>> 16, t >>> 0;
|
|
145
|
-
}
|
|
146
|
-
function b(e, t) {
|
|
147
|
-
return y(v(`${e}:${t}`)) % 100;
|
|
148
|
-
}
|
|
149
|
-
function x(e, t) {
|
|
150
|
-
return t <= 0 ? !1 : t >= 100 || e < t;
|
|
151
|
-
}
|
|
152
|
-
//#endregion
|
|
153
|
-
//#region src/plugins/dynamic-experiences/plugin.ts
|
|
154
|
-
function S(e, t) {
|
|
155
|
-
if (Array.isArray(t.conditions)) for (let n of t.conditions) e.registerCondition(n);
|
|
156
|
-
}
|
|
157
|
-
function C(e, t) {
|
|
158
|
-
e.registerExperience({
|
|
159
|
-
id: t.id,
|
|
160
|
-
key: t.key,
|
|
161
|
-
name: t.name,
|
|
162
|
-
targets: t.targets,
|
|
163
|
-
nodes: t.nodes,
|
|
164
|
-
edges: t.edges,
|
|
165
|
-
condition: t.condition,
|
|
166
|
-
initializeOpen: t.initializeOpen,
|
|
167
|
-
componentName: t.componentName
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
function w(e, t) {
|
|
171
|
-
if (Array.isArray(t.fields)) for (let n of t.fields) e.registerField(n);
|
|
172
|
-
}
|
|
173
|
-
function T(e, t) {
|
|
174
|
-
if (!Array.isArray(t.steps)) return;
|
|
175
|
-
let n = new Map(t.fields.map((e) => [e.id, e.key]));
|
|
176
|
-
for (let r of t.steps) {
|
|
177
|
-
let t = [];
|
|
178
|
-
for (let e of r.fieldIds ?? []) {
|
|
179
|
-
let i = n.get(e);
|
|
180
|
-
if (i === void 0) {
|
|
181
|
-
`${r.key}${e}`;
|
|
182
|
-
continue;
|
|
183
|
-
}
|
|
184
|
-
t.push(i);
|
|
185
|
-
}
|
|
186
|
-
let i = r.layoutContentId ? e.contents.getById(r.layoutContentId) : null;
|
|
187
|
-
e.registerStep({
|
|
188
|
-
id: r.id,
|
|
189
|
-
key: r.key,
|
|
190
|
-
name: r.name,
|
|
191
|
-
fieldKeys: t,
|
|
192
|
-
layoutName: r.layoutName,
|
|
193
|
-
...r.layoutContentId !== void 0 && {
|
|
194
|
-
layoutContentId: r.layoutContentId,
|
|
195
|
-
layoutContentStore: i
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
function E(e, t) {
|
|
201
|
-
if (Array.isArray(t.experiences)) for (let n of t.experiences) C(e, n);
|
|
202
|
-
}
|
|
203
|
-
function D(e, t, n) {
|
|
204
|
-
A(e, t, n.isPreview, n.sessionId), S(e, t), w(e, t), T(e, t), E(e, t);
|
|
205
|
-
}
|
|
206
|
-
function O(e) {
|
|
207
|
-
let t = e.searchParams["preview-token"];
|
|
208
|
-
if (t && t.length > 0) return t[0];
|
|
209
|
-
}
|
|
210
|
-
function k(e) {
|
|
211
|
-
let t = /* @__PURE__ */ new Set(), n = e.searchParams.feature;
|
|
212
|
-
if (!n) return t;
|
|
213
|
-
for (let e of n) {
|
|
214
|
-
let n = e.indexOf(":");
|
|
215
|
-
n > 0 && t.add(e.substring(0, n));
|
|
216
|
-
}
|
|
217
|
-
return t;
|
|
218
|
-
}
|
|
219
|
-
function A(e, t, n, r) {
|
|
220
|
-
let i = k(e);
|
|
221
|
-
for (let a of t.features) i.has(a.id) || j(e, a, n, r);
|
|
222
|
-
}
|
|
223
|
-
function j(e, t, n, r) {
|
|
224
|
-
let i = b(r, t.id);
|
|
225
|
-
e.registerFeature(t.id, {
|
|
226
|
-
key: `v${t.version}`,
|
|
227
|
-
name: t.name,
|
|
228
|
-
enabled: t.enabled,
|
|
229
|
-
weight: t.weight,
|
|
230
|
-
storage: n ? "session" : "local",
|
|
231
|
-
decide: () => x(i, t.weight)
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
function M(e, t) {
|
|
235
|
-
for (let n of t.content) e.registerContent({
|
|
236
|
-
id: n.id,
|
|
237
|
-
contentModelKey: n.contentModelKey,
|
|
238
|
-
data: n.data
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
function N(e, t) {
|
|
242
|
-
let n = /* @__PURE__ */ new Map();
|
|
243
|
-
return (r, i) => {
|
|
244
|
-
let a = n.get(r.id);
|
|
245
|
-
if (a) return a;
|
|
246
|
-
let o = (async () => {
|
|
247
|
-
try {
|
|
248
|
-
let n = await t(r, i);
|
|
249
|
-
return n && M(e, n), n;
|
|
250
|
-
} finally {
|
|
251
|
-
n.delete(r.id);
|
|
252
|
-
}
|
|
253
|
-
})();
|
|
254
|
-
return n.set(r.id, o), o;
|
|
255
|
-
};
|
|
256
|
-
}
|
|
257
|
-
function P(e, t) {
|
|
258
|
-
let n = new Set(t && Array.isArray(t.experiences) ? t.experiences.map((e) => e.id) : []);
|
|
259
|
-
return (t, r) => n.has(t.id) ? e(t, r) : Promise.resolve(null);
|
|
260
|
-
}
|
|
261
|
-
function F(e, t, n) {
|
|
262
|
-
if (n?.dataProvider) return n.dataProvider;
|
|
263
|
-
let r = O(e);
|
|
264
|
-
return _({
|
|
265
|
-
apiUrl: t,
|
|
266
|
-
projectId: e.projectId,
|
|
267
|
-
...r !== void 0 && { previewToken: r },
|
|
268
|
-
...n?.projectConfig !== void 0 && { projectConfig: n.projectConfig },
|
|
269
|
-
...n?.getContent !== void 0 && { getContent: n.getContent }
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
function I(e) {
|
|
273
|
-
return {
|
|
274
|
-
name: "dynamic-experiences",
|
|
275
|
-
setup: (n) => {
|
|
276
|
-
let r = e?.apiUrl ?? n.apiUrl;
|
|
277
|
-
return { onStart: t({
|
|
278
|
-
source: n.session.store.map((e) => e.id),
|
|
279
|
-
effect: async (t) => {
|
|
280
|
-
let i = F(n, r, e), a = O(n) !== void 0, o = await i.getProjectConfig();
|
|
281
|
-
if (n.contentLoader = N(n, P((e) => i.getContent(e), o)), n.dataSource = i.meta.manifest, !o) return;
|
|
282
|
-
let s = n.seededVersionId;
|
|
283
|
-
if (s !== null && s !== o.versionId) {
|
|
284
|
-
n.versionSkew = {
|
|
285
|
-
seeded: s,
|
|
286
|
-
resolved: o.versionId
|
|
287
|
-
}, `${o.versionId}${s}`;
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
|
-
n.previewEmbedderOrigins = o.previewEmbedderOrigins ?? null, D(n, o, {
|
|
291
|
-
isPreview: a,
|
|
292
|
-
sessionId: t
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
}) };
|
|
296
|
-
}
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
//#endregion
|
|
300
|
-
export { m as a, c, h as i, s as l, D as n, d as o, _ as r, u as s, I as t };
|