@picked/client 0.0.1-dev.1786004500650 → 0.0.1-dev.1786070942751

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 (34) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/{api-fPB4ZBjC.js → api-BqZglw7-.js} +1 -1
  3. package/dist/{api-BLYaNoaa.cjs → api-C5vMi1gb.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/esm/index.js +20 -1
  8. package/dist/esm/plugins/dynamic-experiences/index.js +4 -3
  9. package/dist/esm/server/index.js +36 -39
  10. package/dist/plugin-EFn9ALEF.cjs +1 -0
  11. package/dist/plugin-YytfMG0n.js +153 -0
  12. package/dist/provider-Bng22ugW.cjs +1 -0
  13. package/dist/provider-hAf_rar9.js +68 -0
  14. package/dist/registry-CdPPoopn.js +74 -0
  15. package/dist/registry-DpNNJt2g.cjs +1 -0
  16. package/dist/types/data-source/provider.d.ts +7 -6
  17. package/dist/types/data-source/provider.d.ts.map +1 -1
  18. package/dist/types/data-source/registry.d.ts +2 -3
  19. package/dist/types/data-source/registry.d.ts.map +1 -1
  20. package/dist/types/picked.d.ts +50 -1
  21. package/dist/types/picked.d.ts.map +1 -1
  22. package/dist/types/plugins/dynamic-experiences/index.d.ts +1 -3
  23. package/dist/types/plugins/dynamic-experiences/index.d.ts.map +1 -1
  24. package/dist/types/plugins/dynamic-experiences/plugin.d.ts +8 -7
  25. package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
  26. package/dist/types/plugins/dynamic-experiences/types.d.ts +0 -24
  27. package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
  28. package/dist/types/server/index.d.ts +1 -1
  29. package/dist/types/server/index.d.ts.map +1 -1
  30. package/dist/types/server/serialize.d.ts +7 -25
  31. package/dist/types/server/serialize.d.ts.map +1 -1
  32. package/package.json +3 -3
  33. package/dist/plugin-Bg-jjHsL.cjs +0 -1
  34. package/dist/plugin-CfO5xaRm.js +0 -302
@@ -1,6 +1,6 @@
1
1
  import type { Plugin } from '../../entities/plugin/plugin';
2
2
  import type { Picked } from '../../picked';
3
- import type { DynamicExperiencesPluginOptions, ProjectConfig } from './types';
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 fetches project configuration from the Picked REST API and registers
29
- * features, steps, fields, and experiences with the client.
28
+ * Plugin that resolves project configuration through the client and registers features,
29
+ * steps, fields, and experiences with it.
30
30
  *
31
- * Features are fetched during the `onStart` hook, before experience initialisation.
32
- * Search param feature overrides take precedence over API-provided values.
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(options?: DynamicExperiencesPluginOptions): Plugin;
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;AAI1C,OAAO,KAAK,EAEV,+BAA+B,EAE/B,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;AAmOD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,CAAC,EAAE,+BAA+B,GAAG,MAAM,CAmD1F"}
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,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,o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stance } 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, type SerializeGetContent, } from './serialize';
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,EACtB,KAAK,mBAAmB,GACzB,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,M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B,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 { PickedDataProvider } from '../data-source/provider';
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 forwarded to the default API content fetch (and to a custom `getContent`), so
37
- * preview (unpublished) content resolves during preview SSR. The server has no `searchParams`,
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 default API path, so a slow or hung upstream
43
- * cannot stall the SSR render indefinitely. On timeout the blob is skipped and the render
44
- * proceeds (matching the existing null-tolerant path). Defaults to {@link DEFAULT_CONTENT_TIMEOUT_MS}.
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: SerializeParams): Promise<PickedSnapshot>;
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;AAEvC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAMjE,OAAO,KAAK,EACV,WAAW,EACX,yBAAyB,EACzB,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,C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,MAAM,GAAE,eAAoB,GAC3B,OAAO,CAAC,cAAc,CAAC,CA0EzB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@picked/client",
3
- "version": "0.0.1-dev.1786004500650",
3
+ "version": "0.0.1-dev.1786070942751",
4
4
  "dependencies": {
5
5
  "@withease/factories": "^1.0.5"
6
6
  },
@@ -171,8 +171,8 @@
171
171
  "size-limit": [
172
172
  {
173
173
  "path": "dist/esm/index.js",
174
- "limit": "16 kB",
175
- "name": "index (incl. lazily-loaded preview channel; see AGENTS.md)"
174
+ "limit": "18 kB",
175
+ "name": "index (incl. lazily-loaded preview channel and data provider; see AGENTS.md)"
176
176
  },
177
177
  {
178
178
  "path": "dist/esm/server/index.js",
@@ -1 +0,0 @@
1
- require("./logger-CSTvAyyB.cjs");const e=require("./api-BLYaNoaa.cjs");let t=require("effector");function n(e){return typeof e==`object`&&!!e}function r(e){return n(e)&&`features`in e&&Array.isArray(e.features)}function i(e){return!n(e)||!(`experienceId`in e)||!(`content`in e)?!1:Array.isArray(e.content)}function a(e){try{let t=new URL(e).hostname;return t===`localhost`||t===`127.0.0.1`||t===`::1`}catch{return!1}}function o(e){if(!n(e)||!(`cause`in e))return!1;let{cause:t}=e;return!n(t)||!(`code`in t)?!1:t.code===`ECONNREFUSED`}async function s(t,n,i){let s=i?.previewToken?`projects/${n}?preview_token=${encodeURIComponent(i.previewToken)}`:`projects/${n}`,c;try{c=await e.t(t,s,i?.headers,i?.signal)}catch(e){return a(t)&&o(e),null}if(!c.ok)return`${c.status.toString()}`,null;let l;try{l=await c.json()}catch{return null}return r(l)?l:null}async function c(t,n,r,s){let c=s?.previewToken?`projects/${n}/experiences/${r}/content?preview_token=${encodeURIComponent(s.previewToken)}`:`projects/${n}/experiences/${r}/content`,l;try{l=await e.t(t,c,s?.headers,s?.signal)}catch(e){return a(t)&&o(e)||`${r}`,null}if(!l.ok)return`${r}${l.status.toString()}`,null;let u;try{u=await l.json()}catch{return`${r}`,null}return i(u)?u:(`${r}`,null)}function l(e){if(typeof e!=`object`||!e||!(`projectConfig`in e)||!(`experienceContent`in e)||!(`manifestMetadata`in e))return!1;let{experienceContent:t}=e;return typeof t==`function`}var u=null;function d(e){l(e)&&(u=e)}function f(){return u}var p=`bundle`,m=`api`;async function h(){try{let e=await import(`virtual:picked/data`);return l(e)?e:null}catch{return null}}function g(e){if(e===void 0||l(e))return e}function _(e){let{apiUrl:t,projectId:n,previewToken:r,signal:i}=e,a=!!r,o=a?m:e.mode,l=g(a?void 0:e.bundle),u=a?void 0:e.projectConfig,d=e.getContent,_={mode:o??m,manifest:null},v,y,b=new Map;function x(){if(o===m)return Promise.resolve(null);if(l)return Promise.resolve(l);let e=f();return e?Promise.resolve(e):(v??=h(),v)}function S(e){_.mode=e?p:m,_.manifest=e?e.manifestMetadata:null}async function C(){if(u)return S(await x()),u;let e=await x();return S(e),e?e.projectConfig:o===p?null:s(t,n,{...r!==void 0&&{previewToken:r},...i!==void 0&&{signal:i}})}async function w(e){let a=r===void 0?void 0:{previewToken:r};if(d)return d(e,a);let s=await x();if(S(s),s)try{return await s.experienceContent(e,a)}catch{return`${e.id}`,null}return o===p?null:c(t,n,e.id,{...r!==void 0&&{previewToken:r},...i!==void 0&&{signal:i}})}return{meta:_,getProjectConfig:()=>(y??=C(),y),getContent:e=>{let t=b.get(e.id);if(t)return t;let n=w(e).finally(()=>{b.delete(e.id)});return b.set(e.id,n),n}}}function v(e){let t=2166136261;for(let n of e)t^=n.codePointAt(0)??0,t=Math.imul(t,16777619);return t>>>0}function y(e){let t=e;return t^=t>>>16,t=Math.imul(t,2246822507),t^=t>>>13,t=Math.imul(t,3266489909),t^=t>>>16,t>>>0}function b(e,t){return y(v(`${e}:${t}`))%100}function x(e,t){return t<=0?!1:t>=100||e<t}function S(e,t){if(Array.isArray(t.conditions))for(let n of t.conditions)e.registerCondition(n)}function C(e,t){e.registerExperience({id:t.id,key:t.key,name:t.name,targets:t.targets,nodes:t.nodes,edges:t.edges,condition:t.condition,initializeOpen:t.initializeOpen,componentName:t.componentName})}function w(e,t){if(Array.isArray(t.fields))for(let n of t.fields)e.registerField(n)}function T(e,t){if(!Array.isArray(t.steps))return;let n=new Map(t.fields.map(e=>[e.id,e.key]));for(let r of t.steps){let t=[];for(let e of r.fieldIds??[]){let i=n.get(e);if(i===void 0){`${r.key}${e}`;continue}t.push(i)}let i=r.layoutContentId?e.contents.getById(r.layoutContentId):null;e.registerStep({id:r.id,key:r.key,name:r.name,fieldKeys:t,layoutName:r.layoutName,...r.layoutContentId!==void 0&&{layoutContentId:r.layoutContentId,layoutContentStore:i}})}}function E(e,t){if(Array.isArray(t.experiences))for(let n of t.experiences)C(e,n)}function D(e,t,n){A(e,t,n.isPreview,n.sessionId),S(e,t),w(e,t),T(e,t),E(e,t)}function O(e){let t=e.searchParams[`preview-token`];if(t&&t.length>0)return t[0]}function k(e){let t=new Set,n=e.searchParams.feature;if(!n)return t;for(let e of n){let n=e.indexOf(`:`);n>0&&t.add(e.substring(0,n))}return t}function A(e,t,n,r){let i=k(e);for(let a of t.features)i.has(a.id)||j(e,a,n,r)}function j(e,t,n,r){let i=b(r,t.id);e.registerFeature(t.id,{key:`v${t.version}`,name:t.name,enabled:t.enabled,weight:t.weight,storage:n?`session`:`local`,decide:()=>x(i,t.weight)})}function M(e,t){for(let n of t.content)e.registerContent({id:n.id,contentModelKey:n.contentModelKey,data:n.data})}function N(e,t){let n=new Map;return(r,i)=>{let a=n.get(r.id);if(a)return a;let o=(async()=>{try{let n=await t(r,i);return n&&M(e,n),n}finally{n.delete(r.id)}})();return n.set(r.id,o),o}}function P(e,t){let n=new Set(t&&Array.isArray(t.experiences)?t.experiences.map(e=>e.id):[]);return(t,r)=>n.has(t.id)?e(t,r):Promise.resolve(null)}function F(e,t,n){if(n?.dataProvider)return n.dataProvider;let r=O(e);return _({apiUrl:t,projectId:e.projectId,...r!==void 0&&{previewToken:r},...n?.projectConfig!==void 0&&{projectConfig:n.projectConfig},...n?.getContent!==void 0&&{getContent:n.getContent}})}function I(e){return{name:`dynamic-experiences`,setup:n=>{let r=e?.apiUrl??n.apiUrl;return{onStart:(0,t.attach)({source:n.session.store.map(e=>e.id),effect:async t=>{let i=F(n,r,e),a=O(n)!==void 0,o=await i.getProjectConfig();if(n.contentLoader=N(n,P(e=>i.getContent(e),o)),n.dataSource=i.meta.manifest,!o)return;let s=n.seededVersionId;if(s!==null&&s!==o.versionId){n.versionSkew={seeded:s,resolved:o.versionId},`${o.versionId}${s}`;return}n.previewEmbedderOrigins=o.previewEmbedderOrigins??null,D(n,o,{isPreview:a,sessionId:t})}})}}}}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return I}});
@@ -1,302 +0,0 @@
1
- import "./logger-DMN6TxJJ.js";
2
- import { t as e } from "./api-fPB4ZBjC.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/virtual-data.ts
60
- function l(e) {
61
- if (typeof e != "object" || !e || !("projectConfig" in e) || !("experienceContent" in e) || !("manifestMetadata" in e)) return !1;
62
- let { experienceContent: t } = e;
63
- return typeof t == "function";
64
- }
65
- //#endregion
66
- //#region src/data-source/registry.ts
67
- var u = null;
68
- function d(e) {
69
- l(e) && (u = e);
70
- }
71
- function f() {
72
- return u;
73
- }
74
- //#endregion
75
- //#region src/data-source/provider.ts
76
- var p = "bundle", m = "api";
77
- async function h() {
78
- try {
79
- let e = await import("virtual:picked/data");
80
- return l(e) ? e : null;
81
- } catch {
82
- return null;
83
- }
84
- }
85
- function g(e) {
86
- if (e === void 0 || l(e)) return e;
87
- }
88
- function _(e) {
89
- let { apiUrl: t, projectId: n, previewToken: r, signal: i } = e, a = !!r, o = a ? m : e.mode, l = g(a ? void 0 : e.bundle), u = a ? void 0 : e.projectConfig, d = e.getContent, _ = {
90
- mode: o ?? m,
91
- manifest: null
92
- }, v, y, b = /* @__PURE__ */ new Map();
93
- function x() {
94
- if (o === m) return Promise.resolve(null);
95
- if (l) return Promise.resolve(l);
96
- let e = f();
97
- return e ? Promise.resolve(e) : (v ??= h(), v);
98
- }
99
- function S(e) {
100
- _.mode = e ? p : m, _.manifest = e ? e.manifestMetadata : null;
101
- }
102
- async function C() {
103
- if (u) return S(await x()), u;
104
- let e = await x();
105
- return S(e), e ? e.projectConfig : o === p ? null : s(t, n, {
106
- ...r !== void 0 && { previewToken: r },
107
- ...i !== void 0 && { signal: i }
108
- });
109
- }
110
- async function w(e) {
111
- let a = r === void 0 ? void 0 : { previewToken: r };
112
- if (d) return d(e, a);
113
- let s = await x();
114
- if (S(s), s) try {
115
- return await s.experienceContent(e, a);
116
- } catch {
117
- return `${e.id}`, null;
118
- }
119
- return o === p ? null : c(t, n, e.id, {
120
- ...r !== void 0 && { previewToken: r },
121
- ...i !== void 0 && { signal: i }
122
- });
123
- }
124
- return {
125
- meta: _,
126
- getProjectConfig: () => (y ??= C(), y),
127
- getContent: (e) => {
128
- let t = b.get(e.id);
129
- if (t) return t;
130
- let n = w(e).finally(() => {
131
- b.delete(e.id);
132
- });
133
- return b.set(e.id, n), n;
134
- }
135
- };
136
- }
137
- //#endregion
138
- //#region src/plugins/dynamic-experiences/hash.ts
139
- function v(e) {
140
- let t = 2166136261;
141
- for (let n of e) t ^= n.codePointAt(0) ?? 0, t = Math.imul(t, 16777619);
142
- return t >>> 0;
143
- }
144
- function y(e) {
145
- let t = e;
146
- return t ^= t >>> 16, t = Math.imul(t, 2246822507), t ^= t >>> 13, t = Math.imul(t, 3266489909), t ^= t >>> 16, t >>> 0;
147
- }
148
- function b(e, t) {
149
- return y(v(`${e}:${t}`)) % 100;
150
- }
151
- function x(e, t) {
152
- return t <= 0 ? !1 : t >= 100 || e < t;
153
- }
154
- //#endregion
155
- //#region src/plugins/dynamic-experiences/plugin.ts
156
- function S(e, t) {
157
- if (Array.isArray(t.conditions)) for (let n of t.conditions) e.registerCondition(n);
158
- }
159
- function C(e, t) {
160
- e.registerExperience({
161
- id: t.id,
162
- key: t.key,
163
- name: t.name,
164
- targets: t.targets,
165
- nodes: t.nodes,
166
- edges: t.edges,
167
- condition: t.condition,
168
- initializeOpen: t.initializeOpen,
169
- componentName: t.componentName
170
- });
171
- }
172
- function w(e, t) {
173
- if (Array.isArray(t.fields)) for (let n of t.fields) e.registerField(n);
174
- }
175
- function T(e, t) {
176
- if (!Array.isArray(t.steps)) return;
177
- let n = new Map(t.fields.map((e) => [e.id, e.key]));
178
- for (let r of t.steps) {
179
- let t = [];
180
- for (let e of r.fieldIds ?? []) {
181
- let i = n.get(e);
182
- if (i === void 0) {
183
- `${r.key}${e}`;
184
- continue;
185
- }
186
- t.push(i);
187
- }
188
- let i = r.layoutContentId ? e.contents.getById(r.layoutContentId) : null;
189
- e.registerStep({
190
- id: r.id,
191
- key: r.key,
192
- name: r.name,
193
- fieldKeys: t,
194
- layoutName: r.layoutName,
195
- ...r.layoutContentId !== void 0 && {
196
- layoutContentId: r.layoutContentId,
197
- layoutContentStore: i
198
- }
199
- });
200
- }
201
- }
202
- function E(e, t) {
203
- if (Array.isArray(t.experiences)) for (let n of t.experiences) C(e, n);
204
- }
205
- function D(e, t, n) {
206
- A(e, t, n.isPreview, n.sessionId), S(e, t), w(e, t), T(e, t), E(e, t);
207
- }
208
- function O(e) {
209
- let t = e.searchParams["preview-token"];
210
- if (t && t.length > 0) return t[0];
211
- }
212
- function k(e) {
213
- let t = /* @__PURE__ */ new Set(), n = e.searchParams.feature;
214
- if (!n) return t;
215
- for (let e of n) {
216
- let n = e.indexOf(":");
217
- n > 0 && t.add(e.substring(0, n));
218
- }
219
- return t;
220
- }
221
- function A(e, t, n, r) {
222
- let i = k(e);
223
- for (let a of t.features) i.has(a.id) || j(e, a, n, r);
224
- }
225
- function j(e, t, n, r) {
226
- let i = b(r, t.id);
227
- e.registerFeature(t.id, {
228
- key: `v${t.version}`,
229
- name: t.name,
230
- enabled: t.enabled,
231
- weight: t.weight,
232
- storage: n ? "session" : "local",
233
- decide: () => x(i, t.weight)
234
- });
235
- }
236
- function M(e, t) {
237
- for (let n of t.content) e.registerContent({
238
- id: n.id,
239
- contentModelKey: n.contentModelKey,
240
- data: n.data
241
- });
242
- }
243
- function N(e, t) {
244
- let n = /* @__PURE__ */ new Map();
245
- return (r, i) => {
246
- let a = n.get(r.id);
247
- if (a) return a;
248
- let o = (async () => {
249
- try {
250
- let n = await t(r, i);
251
- return n && M(e, n), n;
252
- } finally {
253
- n.delete(r.id);
254
- }
255
- })();
256
- return n.set(r.id, o), o;
257
- };
258
- }
259
- function P(e, t) {
260
- let n = new Set(t && Array.isArray(t.experiences) ? t.experiences.map((e) => e.id) : []);
261
- return (t, r) => n.has(t.id) ? e(t, r) : Promise.resolve(null);
262
- }
263
- function F(e, t, n) {
264
- if (n?.dataProvider) return n.dataProvider;
265
- let r = O(e);
266
- return _({
267
- apiUrl: t,
268
- projectId: e.projectId,
269
- ...r !== void 0 && { previewToken: r },
270
- ...n?.projectConfig !== void 0 && { projectConfig: n.projectConfig },
271
- ...n?.getContent !== void 0 && { getContent: n.getContent }
272
- });
273
- }
274
- function I(e) {
275
- return {
276
- name: "dynamic-experiences",
277
- setup: (n) => {
278
- let r = e?.apiUrl ?? n.apiUrl;
279
- return { onStart: t({
280
- source: n.session.store.map((e) => e.id),
281
- effect: async (t) => {
282
- let i = F(n, r, e), a = O(n) !== void 0, o = await i.getProjectConfig();
283
- if (n.contentLoader = N(n, P((e) => i.getContent(e), o)), n.dataSource = i.meta.manifest, !o) return;
284
- let s = n.seededVersionId;
285
- if (s !== null && s !== o.versionId) {
286
- n.versionSkew = {
287
- seeded: s,
288
- resolved: o.versionId
289
- }, `${o.versionId}${s}`;
290
- return;
291
- }
292
- n.previewEmbedderOrigins = o.previewEmbedderOrigins ?? null, D(n, o, {
293
- isPreview: a,
294
- sessionId: t
295
- });
296
- }
297
- }) };
298
- }
299
- };
300
- }
301
- //#endregion
302
- export { f as a, c, h as i, s as l, D as n, d as o, _ as r, l as s, I as t };