@picked/client 0.0.1-dev.1778561735098 → 0.0.1-dev.1778730134956

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 (61) hide show
  1. package/dist/{api-Bzb9pR2r.js → api-B-CbCRqb.js} +1 -1
  2. package/dist/{api-XV6bcv_D.cjs → api-CPRRXVw6.cjs} +1 -1
  3. package/dist/cjs/index.js +2 -2
  4. package/dist/cjs/plugins/create-experience/index.js +1 -1
  5. package/dist/cjs/plugins/dom-observer/index.js +1 -0
  6. package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
  7. package/dist/cjs/plugins/experience-browser-storage/index.js +1 -1
  8. package/dist/cjs/plugins/history-browser-storage/index.js +1 -1
  9. package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
  10. package/dist/cjs/server/index.js +1 -1
  11. package/dist/docs/workspaces.mdx +1 -1
  12. package/dist/dom-C3C6Fmwz.cjs +1 -0
  13. package/dist/dom-DGePXPpM.js +84 -0
  14. package/dist/esm/index.js +323 -303
  15. package/dist/esm/plugins/create-experience/index.js +1 -1
  16. package/dist/esm/plugins/dom-observer/index.js +87 -0
  17. package/dist/esm/plugins/dynamic-experiences/index.js +109 -38
  18. package/dist/esm/plugins/experience-browser-storage/index.js +1 -1
  19. package/dist/esm/plugins/history-browser-storage/index.js +14 -53
  20. package/dist/esm/plugins/responses-browser-storage/index.js +1 -1
  21. package/dist/esm/server/index.js +1 -1
  22. package/dist/experience-instance-BOhvCj_F.js +430 -0
  23. package/dist/experience-instance-D8yKenBU.cjs +1 -0
  24. package/dist/types/entities/content/content.d.ts +37 -0
  25. package/dist/types/entities/content/content.d.ts.map +1 -0
  26. package/dist/types/entities/experience/experience.d.ts +22 -2
  27. package/dist/types/entities/experience/experience.d.ts.map +1 -1
  28. package/dist/types/entities/experience-instance/experience-instance.d.ts +12 -0
  29. package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
  30. package/dist/types/entities/history/history.d.ts +19 -28
  31. package/dist/types/entities/history/history.d.ts.map +1 -1
  32. package/dist/types/entities/response/response.d.ts +1 -0
  33. package/dist/types/entities/response/response.d.ts.map +1 -1
  34. package/dist/types/entities/step/step.d.ts +17 -2
  35. package/dist/types/entities/step/step.d.ts.map +1 -1
  36. package/dist/types/index.d.ts +2 -0
  37. package/dist/types/index.d.ts.map +1 -1
  38. package/dist/types/lifecycle/state-snapshot.d.ts.map +1 -1
  39. package/dist/types/picked.d.ts +57 -8
  40. package/dist/types/picked.d.ts.map +1 -1
  41. package/dist/types/plugins/dom-observer/index.d.ts +3 -0
  42. package/dist/types/plugins/dom-observer/index.d.ts.map +1 -0
  43. package/dist/types/plugins/dom-observer/plugin.d.ts +50 -0
  44. package/dist/types/plugins/dom-observer/plugin.d.ts.map +1 -0
  45. package/dist/types/plugins/dynamic-experiences/index.d.ts +2 -1
  46. package/dist/types/plugins/dynamic-experiences/index.d.ts.map +1 -1
  47. package/dist/types/plugins/dynamic-experiences/plugin.d.ts +18 -1
  48. package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
  49. package/dist/types/plugins/dynamic-experiences/types.d.ts +63 -1
  50. package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
  51. package/dist/types/plugins/history-browser-storage/plugin.d.ts +0 -16
  52. package/dist/types/plugins/history-browser-storage/plugin.d.ts.map +1 -1
  53. package/dist/types/utils/dom.d.ts +0 -27
  54. package/dist/types/utils/dom.d.ts.map +1 -1
  55. package/package.json +11 -1
  56. package/dist/experience-instance-B16NqD7y.cjs +0 -1
  57. package/dist/experience-instance-CZC0uPuv.js +0 -513
  58. /package/dist/{id-Bv44ilEo.cjs → id-Cg7fVl1O.cjs} +0 -0
  59. /package/dist/{id-CRqy981z.js → id-n2yrHvNo.js} +0 -0
  60. /package/dist/{storage-B6lQtc4-.cjs → storage-BXSlLTRa.cjs} +0 -0
  61. /package/dist/{storage-6Xk0uAxB.js → storage-hOHCCXvP.js} +0 -0
@@ -1,4 +1,5 @@
1
1
  import { Store } from 'effector';
2
+ import { Content } from '../content/content';
2
3
  export type StepsStore = ReturnType<typeof createStepIndex>;
3
4
  export interface ExperienceStep {
4
5
  id: string;
@@ -6,6 +7,19 @@ export interface ExperienceStep {
6
7
  name: string;
7
8
  fieldKeys: string[];
8
9
  layoutName?: string | null;
10
+ /**
11
+ * Optional reference to a CMS Content record that supplies the step's layout data.
12
+ * The actual content is registered separately via `client.registerContent` and
13
+ * resolved at render time through `layoutContentStore` against the global content registry.
14
+ */
15
+ layoutContentId?: string | null;
16
+ /**
17
+ * Reactive store of the content record this step references. Composed at registration
18
+ * time against `client.contents.getById(layoutContentId)`. `null` when the step has no
19
+ * `layoutContentId`. Reads stay reactive — content registered after the step
20
+ * (or updated mid-session) flows through automatically.
21
+ */
22
+ layoutContentStore?: Store<Content | null> | null;
9
23
  }
10
24
  declare const createStepIndexFactory: () => {
11
25
  register: (step: ExperienceStep) => void;
@@ -19,6 +33,7 @@ declare const createStepIndexFactory: () => {
19
33
  /**
20
34
  * Creates an Effector-based index for registering and retrieving steps.
21
35
  *
36
+ * @returns {ReturnType<typeof createStepIndexFactory>} A step index with register, getById, getByKey, listStore, and indexStore.
22
37
  * @example
23
38
  * ```typescript
24
39
  * const steps = createStepIndex()
@@ -28,8 +43,8 @@ export declare function createStepIndex(): ReturnType<typeof createStepIndexFact
28
43
  /**
29
44
  * Registers a step with the given index via the helper function.
30
45
  *
31
- * @param step - The step definition to register.
32
- * @param index - The step index to register the step with.
46
+ * @param {ExperienceStep} step - The step definition to register.
47
+ * @param {ReturnType<typeof createStepIndex>} index - The step index to register the step with.
33
48
  * @example
34
49
  * ```typescript
35
50
  * setupStep(step, index)
@@ -1 +1 @@
1
- {"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../../../src/entities/step/step.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,OAAO,EAA2B,KAAK,KAAK,EAAE,MAAM,UAAU,CAAA;AAG9D,MAAM,MAAM,UAA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;OAKG;IACH,kBAAkB,CAAC,EAAE,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,IAAI,CAAA;CAClD;AAED,QAAA,MAAM,sBAAsB;qBAuBF,cAAc,KAAG,IAAI;kBAkBxB,cAAc,CAAC,IAAI,CAAC,KAAG,KAAK,CAAC,cAAc,GAAG,IAAI,CAAC;oBAcjD,cAAc,CAAC,KAAK,CAAC,KAAG,KAAK,CAAC,cAAc,GAAG,IAAI,CAAC;;;;;CAa3E,CAAA;AAEF;;;;;;;;GAQG;AACH,wBAAgB,eAAe,IAAI,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAE3E;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,GAAG,IAAI,CAE/F"}
@@ -1,7 +1,9 @@
1
+ /** @file Top-level public entry point — re-exports the client class, public utilities, and entity types. */
1
2
  export * from './exports';
2
3
  export type * from './client';
3
4
  export type * from './entities/action/action';
4
5
  export type * from './entities/condition/condition';
6
+ export type * from './entities/content/content';
5
7
  export type * from './entities/component/component';
6
8
  export type * from './entities/component/lazyComponent';
7
9
  export type * from './entities/experience-instance/experience-instance';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,mBAAmB,UAAU,CAAA;AAC7B,mBAAmB,0BAA0B,CAAA;AAC7C,mBAAmB,gCAAgC,CAAA;AACnD,mBAAmB,gCAAgC,CAAA;AACnD,mBAAmB,oCAAoC,CAAA;AACvD,mBAAmB,oDAAoD,CAAA;AACvE,mBAAmB,kCAAkC,CAAA;AACrD,mBAAmB,sBAAsB,CAAA;AACzC,mBAAmB,4BAA4B,CAAA;AAC/C,mBAAmB,wBAAwB,CAAA;AAC3C,mBAAmB,gCAAgC,CAAA;AACnD,mBAAmB,4BAA4B,CAAA;AAC/C,mBAAmB,0BAA0B,CAAA;AAC7C,mBAAmB,gCAAgC,CAAA;AACnD,mBAAmB,4BAA4B,CAAA;AAC/C,mBAAmB,gBAAgB,CAAA;AACnC,mBAAmB,uBAAuB,CAAA;AAC1C,mBAAmB,8BAA8B,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G,cAAc,WAAW,CAAA;AACzB,mBAAmB,UAAU,CAAA;AAC7B,mBAAmB,0BAA0B,CAAA;AAC7C,mBAAmB,gCAAgC,CAAA;AACnD,mBAAmB,4BAA4B,CAAA;AAC/C,mBAAmB,gCAAgC,CAAA;AACnD,mBAAmB,oCAAoC,CAAA;AACvD,mBAAmB,oDAAoD,CAAA;AACvE,mBAAmB,kCAAkC,CAAA;AACrD,mBAAmB,sBAAsB,CAAA;AACzC,mBAAmB,4BAA4B,CAAA;AAC/C,mBAAmB,wBAAwB,CAAA;AAC3C,mBAAmB,gCAAgC,CAAA;AACnD,mBAAmB,4BAA4B,CAAA;AAC/C,mBAAmB,0BAA0B,CAAA;AAC7C,mBAAmB,gCAAgC,CAAA;AACnD,mBAAmB,4BAA4B,CAAA;AAC/C,mBAAmB,gBAAgB,CAAA;AACnC,mBAAmB,uBAAuB,CAAA;AAC1C,mBAAmB,8BAA8B,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"state-snapshot.d.ts","sourceRoot":"","sources":["../../../src/lifecycle/state-snapshot.ts"],"names":[],"mappings":"AAAA,gIAAgI;AAChI,OAAO,EAAW,KAAK,KAAK,EAAE,MAAM,UAAU,CAAA;AAE9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAEh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GAAG,SAAS,CAAA;KAC9B,EAAE,CAAA;IACH,MAAM,EAAE,KAAK,EAAE,CAAA;CAChB;AA4BD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,KAAK,CAAC,aAAa,CAAC,CAEzF"}
@@ -12,12 +12,42 @@ import { Feature } from './entities/feature/feature';
12
12
  import { EventBusPayload, EventHistoryStore } from './utils/events';
13
13
  import { Field } from './entities/field/field';
14
14
  import { ExperienceStep } from './entities/step/step';
15
+ import { Content } from './entities/content/content';
16
+ import { ContentLoader } from './plugins/dynamic-experiences/types';
15
17
  import { Action } from './entities/action/action';
16
18
  import { Condition } from './entities/condition/condition';
17
19
  import { SessionEntity } from './entities/session/session';
20
+ /**
21
+ * Provenance metadata describing where the Picked client's project config and
22
+ * content came from. Set by `dynamicExperiencesPlugin` when the Vite plugin's
23
+ * virtual data module is available; remains `null` otherwise.
24
+ */
25
+ export interface PickedDataSource {
26
+ /** `'build'` when build-mode prefetch JSON was used, `'dev'` when the dev-mode runtime fetch was used. */
27
+ mode: 'dev' | 'build';
28
+ /** ISO 8601 timestamp from the manifest. `null` in dev mode where no manifest is written. */
29
+ fetchedAt: string | null;
30
+ /** The `versionId` recorded by the source, when known. */
31
+ projectVersionId: string | null;
32
+ /** The `workspaceId` recorded by the source, when known. */
33
+ workspaceId: string | null;
34
+ }
18
35
  export declare class Picked {
19
36
  static readonly logger: (level: "log" | "warn" | "info" | "error", ...args: Parameters<Console["log"]>) => void;
20
37
  private readonly options;
38
+ /**
39
+ * Provenance metadata for the data backing this client. Populated by
40
+ * `dynamicExperiencesPlugin` when the Vite plugin's virtual data module is
41
+ * resolvable; remains `null` when the SDK is using the runtime API path.
42
+ */
43
+ dataSource: PickedDataSource | null;
44
+ /**
45
+ * Content fetcher selected by `dynamicExperiencesPlugin`'s resolution chain. Called
46
+ * by each experience's `prepareExperienceContentFx` (fired in parallel with
47
+ * `initialiseFx` by the per-experience sample graph). `undefined` when no plugin
48
+ * has registered one yet.
49
+ */
50
+ contentLoader?: ContentLoader;
21
51
  private readonly plugins;
22
52
  readonly eventBus: EventCallable<EventBusPayload>;
23
53
  readonly events: EventHistoryStore;
@@ -28,15 +58,24 @@ export declare class Picked {
28
58
  readonly session: SessionEntity;
29
59
  readonly searchParams: import('.').PickedSearchParams;
30
60
  readonly history: {
31
- push: EventCallable<import('.').InstanceNodeIntent>;
32
- replace: EventCallable<import('.').InstanceNodeIntent>;
33
- back: EventCallable<Pick<import('.').InstanceScope, "instanceId">>;
34
- restoreSnapshots: EventCallable<{
35
- snapshots: Record<string, import('.').HistoryEntry[]>;
61
+ push: EventCallable<{
62
+ experienceId: string;
63
+ node: import('.').ExperienceNode;
64
+ }>;
65
+ replace: EventCallable<{
66
+ experienceId: string;
67
+ node: import('.').ExperienceNode;
36
68
  }>;
37
- seedInstanceFromSnapshot: EventCallable<import('.').InstanceScope>;
38
- entriesStore: StoreWritable<import('.').HistoryEntry[]>;
39
- snapshotStore: Store<Record<string, import('.').HistoryEntry[]>>;
69
+ back: EventCallable<{
70
+ experienceId?: string;
71
+ }>;
72
+ restore: EventCallable<{
73
+ entries: import('.').HistoryEntry[];
74
+ }>;
75
+ resetExperience: EventCallable<{
76
+ experienceId: string;
77
+ }>;
78
+ entriesStore: Store<import('.').HistoryEntry[]>;
40
79
  };
41
80
  readonly components: {
42
81
  register: EventCallable<{
@@ -135,6 +174,7 @@ export declare class Picked {
135
174
  };
136
175
  clearAll: EventCallable<void>;
137
176
  clear: EventCallable<string>;
177
+ clearByExperience: (experienceId: string) => void;
138
178
  commit: (responsesToCommit: import('.').CommitResponses) => Promise<{
139
179
  errors: import('.').ValidationError[];
140
180
  }>;
@@ -162,6 +202,14 @@ export declare class Picked {
162
202
  [id: string]: ExperienceStep;
163
203
  }>;
164
204
  };
205
+ readonly contents: {
206
+ register: (content: Content) => void;
207
+ getById: (id: Content["id"]) => Store<Content | null>;
208
+ listStore: Store<Content[]>;
209
+ indexStore: StoreWritable<{
210
+ [id: string]: Content;
211
+ }>;
212
+ };
165
213
  readonly actions: {
166
214
  register: EventCallable<{
167
215
  key: string;
@@ -207,6 +255,7 @@ export declare class Picked {
207
255
  registerCondition: (condition: Condition) => void;
208
256
  registerField: (field: Field) => void;
209
257
  registerStep: (step: ExperienceStep) => void;
258
+ registerContent: (content: Content) => void;
210
259
  registerAction: (key: string, action: Action) => void;
211
260
  registerExperience: (experience: Experience) => void;
212
261
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"picked.d.ts","sourceRoot":"","sources":["../../src/picked.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,OAAO,EAGL,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,KAAK,EACV,KAAK,aAAa,EACnB,MAAM,UAAU,CAAA;AACjB,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,uBAAuB,EAC7B,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,iBAAiB,EAAe,MAAM,0BAA0B,CAAA;AAC3F,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EACL,KAAK,gBAAgB,EAGtB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAEL,KAAK,SAAS,EAEf,MAAM,gCAAgC,CAAA;AAEvC,OAAO,EAA4B,KAAK,aAAa,EAAE,MAAM,4BAA4B,CAAA;AACzF,OAAO,EAA6B,KAAK,uBAAuB,EAAE,MAAM,yBAAyB,CAAA;AACjG,OAAO,EAAmB,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC5E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAA;AAE/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAIzD,OAAO,EAAsB,KAAK,eAAe,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AACjG,OA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,IAAI,CAEnC;IAED,YAAY,GAAI,MAAM,cAAc,KAAG,IAAI,CAE1C;IAED,eAAe,GAAI,SAAS,OAAO,KAAG,IAAI,CAEzC;IAED,cAAc,GAAI,KAAK,MAAM,EAAE,QAAQ,MAAM,KAAG,IAAI,CAEnD;IAED,kBAAkB,GAAI,YAAY,UAAU,KAAG,IAAI,CAMlD;IAED;;;;;;;;;OASG;IAEH,oBAAoB,GAClB,cAAc,MAAM,EACpB,UAAU,uBAAuB,KAChC,OAAO,CAAC,IAAI,CAAC,CAEf;IACD;;;;;;;;;OASG;IAEH,qBAAqB,GACnB,eAAe,MAAM,EACrB,UAAU,uBAAuB,KAChC,OAAO,CAAC,IAAI,CAAC,CAEf;IAED;;;;;;;;OAQG;IAEH,kBAAkB,GAAU,cAAc,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC,CAE/D;IAED;;;;;;;;OAQG;IAEH,mBAAmB,GAAU,eAAe,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC,CAEjE;IAED,OAAO,CAAC,YAAY;IAsBpB,OAAO,CAAC,aAAa;IA8CrB,OAAO,CAAC,eAAe;IAgBvB,OAAO,CAAC,YAAY;IAgBpB,OAAO,CAAC,eAAe;IAWvB,eAAe,GAAI,YAAY,MAAM,KAAG,iBAAiB,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAE1F;CACF"}
@@ -0,0 +1,3 @@
1
+ /** @file Public entrypoint for the dom-observer plugin. */
2
+ export { domObserverPlugin } from './plugin';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dom-observer/index.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA"}
@@ -0,0 +1,50 @@
1
+ import { Plugin } from '../../entities/plugin/plugin';
2
+ /**
3
+ * Watches the document for `childList` mutations and reconciles experiences
4
+ * whose declared target selectors match newly added DOM subtrees. Each
5
+ * matching experience runs through its per-experience `shouldInitialiseFx`,
6
+ * and on `true` is handed to its `initialiseFx(undefined)`.
7
+ *
8
+ * Scope: lazy-mounted target hosts that arrive after the initial bulk init
9
+ * in `picked.ts`. Route-driven re-initialisation (decisionLogic depending
10
+ * on `location.pathname`, lifecycle event re-fires, plugin start hooks)
11
+ * is the responsibility of `singlePageAppPlugin`, which calls
12
+ * `client.start()` on history events. Pair the two plugins to cover both.
13
+ *
14
+ * Pipeline:
15
+ * - Each experience's `configStore.watch()` pushes its trimmed selectors
16
+ * into a reactive `Store<Map<id, string[]>>`. Empty / whitespace-only
17
+ * selectors are filtered out.
18
+ * - A single `MutationObserver` collects `Element` instances from
19
+ * `childList.addedNodes` across one animation frame, then fires a
20
+ * single `mutationObserved` event carrying the collected elements.
21
+ * - `sample` filters registered experiences to those whose selectors
22
+ * match at least one added element via `el.matches` or
23
+ * `el.querySelector`. Malformed selectors are skipped per-experience
24
+ * without poisoning the rest of the batch. The matched array is
25
+ * routed straight into `reconcileMatchedFx` via `sample.target`.
26
+ * - `reconcileMatchedFx` invokes each experience's
27
+ * `shouldInitialiseFx`, and on `true` its `initialiseFx(undefined)`.
28
+ * `initialiseFx` is idempotent: tagged target elements are skipped
29
+ * on subsequent passes.
30
+ *
31
+ * Setup is deferred until `document.body` is parsed, so SDKs loaded from
32
+ * `<head>` without `defer` (the standard Shopify-theme / GTM-template
33
+ * pattern) still install once the body becomes available.
34
+ *
35
+ * No-ops outside browser environments and on partial-DOM runtimes that
36
+ * lack `MutationObserver` or `requestAnimationFrame`. `MutationObserver`
37
+ * does not cross shadow root or iframe boundaries, so experiences whose
38
+ * target lives inside a shadow tree or a cross-origin frame are not
39
+ * reconciled by this plugin.
40
+ *
41
+ * @returns {Plugin} The plugin.
42
+ * @example
43
+ * ```typescript
44
+ * createClient({
45
+ * plugins: [domObserverPlugin()]
46
+ * })
47
+ * ```
48
+ */
49
+ export declare const domObserverPlugin: () => Plugin;
50
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dom-observer/plugin.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AAK1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,eAAO,MAAM,iBAAiB,QAAO,MAiBpC,CAAA"}
@@ -1,4 +1,5 @@
1
- export { dynamicExperiencesPlugin, fetchProject } from './plugin';
1
+ /** @file Public exports for the dynamic-experiences plugin (project config + per-experience content resolution). */
2
+ export { dynamicExperiencesPlugin, fetchExperienceContent, fetchProject } from './plugin';
2
3
  export { createClientHeaders } from '../../utils/client-headers';
3
4
  export type * from './types';
4
5
  //# 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,OAAO,EAAE,wBAAwB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAChE,mBAAmB,SAAS,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;AAChE,mBAAmB,SAAS,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import { Plugin } from '../../entities/plugin/plugin';
2
- import { DynamicExperiencesPluginOptions, FetchProjectOptions, ProjectConfig } from './types';
2
+ import { DynamicExperiencesPluginOptions, ExperienceContentResponse, FetchProjectOptions, ProjectConfig } from './types';
3
3
  /**
4
4
  * Fetches the project configuration from the Picked REST API.
5
5
  *
@@ -16,6 +16,23 @@ import { DynamicExperiencesPluginOptions, FetchProjectOptions, ProjectConfig } f
16
16
  * ```
17
17
  */
18
18
  export declare function fetchProject(apiUrl: string, projectId: string, options?: FetchProjectOptions): Promise<ProjectConfig | null>;
19
+ /**
20
+ * Fetches per-experience content from the Picked API.
21
+ *
22
+ * Returns `null` on network failure, non-OK responses, or invalid JSON shape — preserving
23
+ * the failure-tolerant policy: experiences still render, layouts handle null defensively.
24
+ *
25
+ * @param {string} apiUrl - Base URL for the Picked API.
26
+ * @param {string} projectId - Project ID to fetch content for.
27
+ * @param {string} experienceId - Experience ID whose content to fetch.
28
+ * @param {FetchProjectOptions} [options] - Optional headers and preview token.
29
+ * @returns {Promise<ExperienceContentResponse | null>} Validated content response, or `null` on any failure.
30
+ * @example
31
+ * ```typescript
32
+ * const content = await fetchExperienceContent('https://api.picked.app', 'proj_1', 'exp_1')
33
+ * ```
34
+ */
35
+ export declare function fetchExperienceContent(apiUrl: string, projectId: string, experienceId: string, options?: FetchProjectOptions): Promise<ExperienceContentResponse | null>;
19
36
  /**
20
37
  * Plugin that fetches project configuration from the Picked REST API and registers
21
38
  * features, steps, fields, and experiences with the client.
@@ -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;AAK1D,OAAO,KAAK,EACV,+BAA+B,EAC/B,mBAAmB,EACnB,aAAa,EAGd,MAAM,SAAS,CAAA;AA2VhB;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAmC/B;AAED;;;;;;;;;;;;;;;;;;;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;AAK1D,OAAO,KAAK,EAEV,+BAA+B,EAC/B,yBAAyB,EACzB,mBAAmB,EACnB,aAAa,EAId,MAAM,SAAS,CAAA;AAsThB;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAmC/B;AAoBD;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,yBAAyB,GAAG,IAAI,CAAC,CAsC3C;AAkPD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,CAAC,EAAE,+BAA+B,GAAG,MAAM,CAoC1F"}
@@ -9,8 +9,14 @@ import { LogicRule, LogicValue } from '../../logic-engine';
9
9
  * keys against `ProjectConfig.fields` at registration time.
10
10
  *
11
11
  * `fieldIds` is optional: layout-only steps (driven purely by `layoutName`) omit it.
12
+ *
13
+ * `layoutContentId` is the wire-format reference to a CMS Content record. The actual
14
+ * content blob is delivered by `dynamicExperiencesPlugin`'s content resolution chain
15
+ * (virtual data module, preview-token API fetch, or direct API fetch) and registered
16
+ * via `client.registerContent`. Steps' derived `layoutContentStore` resolves reactively
17
+ * against the registry at render time.
12
18
  */
13
- export type ApiExperienceStep = Omit<ExperienceStep, 'fieldKeys'> & {
19
+ export type ApiExperienceStep = Omit<ExperienceStep, 'fieldKeys' | 'layoutContentStore'> & {
14
20
  fieldIds?: string[];
15
21
  };
16
22
  export interface ProjectConfigFeature {
@@ -66,9 +72,65 @@ export interface ProjectConfig {
66
72
  export interface DynamicExperiencesPluginOptions {
67
73
  apiUrl?: string;
68
74
  projectConfig?: ProjectConfig;
75
+ /**
76
+ * Customer-supplied content fetcher. When provided, supersedes both the virtual
77
+ * data module and the runtime API for per-experience content resolution.
78
+ * Customers using this override are responsible for project ↔ content version
79
+ * consistency. Receives the resolved experience and the current preview token
80
+ * (when present) so the customer can decide preview semantics themselves.
81
+ */
82
+ getContent?: (experience: {
83
+ id: string;
84
+ key: string;
85
+ }, options?: {
86
+ previewToken?: string;
87
+ }) => Promise<ExperienceContentResponse | null>;
69
88
  }
70
89
  export interface FetchProjectOptions {
71
90
  previewToken?: string;
72
91
  headers?: Record<string, string>;
73
92
  }
93
+ /**
94
+ * Wire-format content blob as returned by the Picked API content endpoint.
95
+ */
96
+ export interface ContentBlob {
97
+ id: string;
98
+ data: Record<string, unknown>;
99
+ }
100
+ /**
101
+ * Wire-format response shape for `GET /api/v1/projects/:projectId/experiences/:experienceId/content`.
102
+ * The response is agnostic of step structure — step ↔ content mapping is encoded in the
103
+ * project blob via `Step.layoutContentId`.
104
+ */
105
+ export interface ExperienceContentResponse {
106
+ experienceId: string;
107
+ versionId: string;
108
+ content: ContentBlob[];
109
+ }
110
+ /**
111
+ * Function that resolves an experience's content blobs. Set on the Picked client by
112
+ * `dynamicExperiencesPlugin` (selecting from virtual module, getContent override, or API)
113
+ * and called by each experience's `prepareExperienceContentFx`, which is fired by the
114
+ * per-experience sample graph in parallel with `initialiseFx`.
115
+ */
116
+ export type ContentLoader = (experience: {
117
+ id: string;
118
+ key: string;
119
+ }, options?: {
120
+ previewToken?: string;
121
+ }) => Promise<ExperienceContentResponse | null>;
122
+ /**
123
+ * Optional-fields surface of the virtual data module exposed by `@picked/vite-plugin-picked`.
124
+ * The shape is identical between dev (`vite serve`) and build (`vite build`) modes.
125
+ */
126
+ export interface VirtualPickedData {
127
+ projectConfig: ProjectConfig;
128
+ experienceContent: ContentLoader;
129
+ manifestMetadata: {
130
+ mode: 'dev' | 'build';
131
+ fetchedAt: string | null;
132
+ projectVersionId: string | null;
133
+ workspaceId: string | null;
134
+ };
135
+ }
74
136
  //# sourceMappingURL=types.d.ts.map
@@ -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,SAAS,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAE/D;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,cAAc,EAAE,WAAW,CAAC,GAAG;IAClE,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,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,MAAM,iBAAiB,GAAG,cAAc,CAAA;AAE9C;;;;;;GAMG;AACH,MAAM,WAAW,uBAAuB;IACtC,EAAE,EAAE,MAAM,CAAA;IACV,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,aAAa,EAAE,MAAM,CAAA;IACrB,KAAK,EAAE,iBAAiB,EAAE,CA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C,OAAO,CAAC,EAAE;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,KAChC,OAAO,CAAC,yBAAyB,GAAG,IAAI,CAAC,CAAA;AAE9C;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,aAAa,EAAE,aAAa,CAAA;IAC5B,iBAAiB,EAAE,aAAa,CAAA;IAChC,gBAAgB,EAAE;QAChB,IAAI,EAAE,KAAK,GAAG,OAAO,CAAA;QACrB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;QACxB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;QAC/B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;KAC3B,CAAA;CACF"}
@@ -1,23 +1,7 @@
1
1
  import { Plugin } from '../../entities/plugin/plugin';
2
- export declare const STORAGE_KEY: import('../..').StorageKey;
3
2
  /** @public */
4
3
  export interface HistoryBrowserStoragePlugin {
5
4
  storage?: 'local' | 'session';
6
5
  }
7
- /**
8
- * Picked plugin that persists per-experience history snapshots into
9
- * `localStorage` (default) or `sessionStorage` and restores them on plugin
10
- * setup and again on the client `load` event (restore is idempotent — the
11
- * history entity only fills experiences that have no live entries yet).
12
- *
13
- * Reads the v1 flat-array shape transparently and migrates it in place; the
14
- * next debounced save overwrites the v1 bytes with the v2 record shape.
15
- *
16
- * @param {HistoryBrowserStoragePlugin} [options] - Plugin options.
17
- * @param {'local' | 'session'} [options.storage] - Backing store.
18
- * @returns {Plugin} A Picked client plugin.
19
- * @example
20
- * client.use(historyBrowserStoragePlugin({ storage: 'session' }))
21
- */
22
6
  export declare const historyBrowserStoragePlugin: ({ storage, }?: HistoryBrowserStoragePlugin) => Plugin;
23
7
  //# sourceMappingURL=plugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/history-browser-storage/plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AAK1D,eAAO,MAAM,WAAW,4BAAwC,CAAA;AA2DhE,cAAc;AACd,MAAM,WAAW,2BAA2B;IAC1C,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAC9B;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,2BAA2B,GAAI,eAEzC,2BAAgC,KAAG,MA2ErC,CAAA"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/history-browser-storage/plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AAM1D,cAAc;AACd,MAAM,WAAW,2BAA2B;IAC1C,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAC9B;AAED,eAAO,MAAM,2BAA2B,GAAI,eAEzC,2BAAgC,KAAG,MA8BrC,CAAA"}
@@ -13,33 +13,6 @@ export declare function getTargetElements(targets: {
13
13
  export declare function createAppHosts(targets: (ExperienceTarget & {
14
14
  elements: HTMLElement[];
15
15
  })[], experienceId: string, experienceKey: string): HTMLElement[];
16
- /**
17
- * Finds an existing picked-root host that has already claimed the given selector. Returns
18
- * the claiming experience id, or `undefined` if no host is found.
19
- *
20
- * Used by the per-experience initialise effect to detect target conflicts. The lookup
21
- * intentionally does not filter by placement: only `placement: 'replace'` removes the
22
- * original target elements, so any prior claim that caused a later experience to find
23
- * zero matches must itself have been `replace`. Selector alone is sufficient.
24
- *
25
- * @param {string} selector - The original target selector to look up.
26
- * @returns {string | undefined} The claiming experience id, or `undefined`.
27
- * @example
28
- * const claimer = findClaimingExperienceId('.host-slot')
29
- */
30
- export declare function findClaimingExperienceId(selector: string): string | undefined;
31
- /**
32
- * Finds an existing picked-root host nested inside `element` that was claimed by a different
33
- * experience. Used to detect destructive `placement: 'replace'` collisions where the
34
- * replacing experience would otherwise silently remove another experience's host.
35
- *
36
- * @param {HTMLElement} element - The element that is about to be replaced.
37
- * @param {string} ownExperienceId - The current experience id; matching hosts are ignored.
38
- * @returns {string | undefined} The id of a nested experience's host, if any.
39
- * @example
40
- * findDescendantClaim(parentEl, 'B')
41
- */
42
- export declare function findDescendantClaim(element: HTMLElement, ownExperienceId: string): string | undefined;
43
16
  export declare function tagTargetElement(element: HTMLElement, experienceId: string): void;
44
17
  export declare function isPickedRoot(element: HTMLElement, experienceId?: string): boolean;
45
18
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../../src/utils/dom.ts"],"names":[],"mappings":"AAAA,wGAAwG;AACxG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AAGzE,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,EAAE,CAQ7D;AAID,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,GAAG,UAAU,CAMhE;AAED,wBAAgB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAa9C;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,IAAI,QAS1E;AAED,KAAK,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAA;AAOtE,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,SAAS,CAAA;CAAE,EAAE,EACrD,YAAY,EAAE,MAAM,GACnB,CAAC,gBAAgB,GAAG;IAAE,QAAQ,EAAE,WAAW,EAAE,CAAA;CAAE,CAAC,EAAE,CAqBpD;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,CAAC,gBAAgB,GAAG;IAAE,QAAQ,EAAE,WAAW,EAAE,CAAA;CAAE,CAAC,EAAE,EAC3D,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,iBAOtB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAA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wBAAgB,gBAAgB,CAAC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,QAG1E;AAUD,wBAAgB,YAAY,CAAC,OAAO,EAAE,WAAW,EAAE,YAAY,CAAC,EAAE,MAAM,WAMvE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@picked/client",
3
- "version": "0.0.1-dev.1778561735098",
3
+ "version": "0.0.1-dev.1778730134956",
4
4
  "dependencies": {
5
5
  "@withease/factories": "^1.0.5"
6
6
  },
@@ -89,6 +89,12 @@
89
89
  "require": "./dist/cjs/plugins/dynamic-experiences/index.js",
90
90
  "default": "./dist/esm/plugins/dynamic-experiences/index.js"
91
91
  },
92
+ "./plugins/dom-observer": {
93
+ "types": "./dist/types/plugins/dom-observer/index.d.ts",
94
+ "import": "./dist/esm/plugins/dom-observer/index.js",
95
+ "require": "./dist/cjs/plugins/dom-observer/index.js",
96
+ "default": "./dist/esm/plugins/dom-observer/index.js"
97
+ },
92
98
  "./form": {
93
99
  "types": "./dist/types/form/index.d.ts",
94
100
  "import": "./dist/esm/form/index.js",
@@ -198,6 +204,10 @@
198
204
  "path": "dist/esm/plugins/web-components/index.js",
199
205
  "limit": "10 kB"
200
206
  },
207
+ {
208
+ "path": "dist/esm/plugins/dom-observer/index.js",
209
+ "limit": "5 kB"
210
+ },
201
211
  {
202
212
  "path": "dist/esm/form/index.js",
203
213
  "limit": "5 kB"
@@ -1 +0,0 @@
1
- const e=require(`./rules-logic-H6P8xwHF.cjs`);require(`./logger-fbvQC40v.cjs`);const t=require(`./supports-Dsjg-82e.cjs`),n=require(`./id-Bv44ilEo.cjs`);let r=require(`effector`),i=require(`@withease/factories`);function a(e){return!t.d()||!t.r()?[]:Array.from(window.document.querySelectorAll(e)).filter(e=>e instanceof HTMLElement)}var o=`open`;function s(e){if(!t.l())throw Error(`Shadow DOM is not supported in this environment`);return e.attachShadow({mode:o})}function c(){return new Promise((e,n)=>{if(!t.r()){n();return}document.readyState===`loading`?document.addEventListener(`readystatechange`,()=>e(),{once:!0}):e()})}function l(e,t){let n=new MutationObserver(r=>{document.contains(e)||(n.disconnect(),t())});n.observe(document.body,{childList:!0,subtree:!0})}var u=`picked-root`,d=`picked-target`,f=`picked-root`;function p(e,t){return[...e,{selector:`${f}[experience-id="${t}"]`,placement:`replace`}].flatMap(e=>{let n=a(e.selector).filter(e=>!v(e,t)&&!y(e,t));return{...e,elements:n}})}function m(e,t,n){return e.flatMap(e=>e.elements.map(r=>x(r,e,t,n)))}function h(e){if(!t.r()||typeof CSS>`u`||typeof CSS.escape!=`function`)return;let n=CSS.escape(e),r=document.querySelector(`[data-picked-claimed-selector="${n}"]`);if(r instanceof HTMLElement)return r.dataset.pickedExperienceId}function g(e,n){if(!t.r())return;let r=e.querySelector(`[data-picked-experience-id]`);if(r instanceof HTMLElement){let e=r.dataset.pickedExperienceId;if(e&&e!==n)return e}}function _(e,t){e.classList.add(d),e.classList.add(`${d}-${t}`)}function v(e,t){return t?e.classList.contains(`${d}-${t}`):e.classList.contains(`${d}`)}function y(e,t){return t?e.classList.contains(`${u}-${t}`):e.classList.contains(u)}function b(e,t){let n=document.createElement(`div`);return n.style.display=`block`,n.classList.add(u),n.classList.add(`${u}-${e}`),n.classList.add(`${u}-${t}`),n}function x(e,t,n,r){let i,a=b(n,r);if(a.dataset.pickedExperienceId=n,a.dataset.pickedClaimedSelector=t.selector,e instanceof Document)i=e.body.appendChild(a);else{switch(t.placement){case`replace`:e.replaceWith(a);break;case`before`:e.before(a);break;case`after`:e.after(a);break;case`prepend`:e.prepend(a);break;case`append`:e.append(a);break}i=a}return i}function S(e){return e.type===`condition`}function C(e){return e.type===`step`}function w(e){return e.type===`experience`}function T(e){return e.type===`origin`}function E(e){return e.type===`action`}var D=(e,t,n,r,i=new Set)=>i.has(n.id)?[]:(i.add(n.id),C(n)&&!r?[n]:t.filter(e=>e.sourceNodeId===n.id).flatMap(n=>{let r=e.find(e=>e.id===n.destinationNodeId);return r?D(e,t,r,!1,i):[]})),ee=(e,t,n)=>D(e,t,n,!0,new Set),O=(e,t,n,r,i=new Set)=>{if(i.has(n.id))return[-1,-1];i.add(n.id);let a=t.filter(e=>e.sourceNodeId===n.id);if(a.length===0)return[0,0];let o=1/0,s=-1/0;for(let n of a){let r=e.find(e=>e.id===n.destinationNodeId);if(!r)continue;let[a,c]=O(e,t,r,!1,new Set(i));a!==-1&&(o=Math.min(o,a+1),s=Math.max(s,c+1))}return o===1/0?[-1,-1]:[o,s]},k=(e,t,n)=>O(e,t,n,!0,new Set),A=(e,t,n,r=new Set)=>{if(r.has(n.id))return[-1,-1];if(r.add(n.id),n.type===`origin`)return[0,0];let i=t.filter(e=>e.destinationNodeId===n.id);if(i.length===0)return[-1,-1];let a=1/0,o=-1/0;for(let n of i){let i=e.find(e=>e.id===n.sourceNodeId);if(!i)continue;let[s,c]=A(e,t,i,new Set(r));s!==-1&&(a=Math.min(a,s+1),o=Math.max(o,c+1))}return a===1/0?[-1,-1]:[a,o]},te=(e,t,n)=>A(e,t,n,new Set),j=e=>e.find(e=>e.type===`origin`)||null,M=(e,t,n)=>{if(!e)return j(t);let r=n.find(t=>t.sourceNodeId===e.id);return r&&t.find(e=>e.id===r.destinationNodeId)||null};async function N(e,t,n,r){let i=e?`true`:`false`,a=r.find(e=>e.sourceHandle===i&&e.sourceNodeId===t);return n.find(e=>e.id===a?.destinationNodeId)}function P(e,t,n,r){let i=t.find(t=>t.sourceNodeId===e.id&&t.sourceHandle===r);return i?n.find(e=>e.id===i.destinationNodeId)??null:null}var F=(0,r.createDomain)(`experience-instance`),I=(0,i.createFactory)(({client:t,experience:i,target:a,options:o})=>{let c=n.t(`exp-instance`);t.history.seedInstanceFromSnapshot({instanceId:c,experienceId:i.id});let l=(0,r.createEvent)(),u=(0,r.createEvent)(),d=(0,r.createEvent)(),f=(0,r.createEvent)(),p=(0,r.createEvent)(),m=(0,r.createEvent)(),h=i.componentStore,g=F.store(`transitioning`),_=t.history.entriesStore.map(e=>e.filter(e=>e.instanceId===c)),v=_.map(e=>e.filter(e=>C(e.node))),y=_.map(e=>e.at(-1)?.node||null),b=(0,r.combine)(t.steps.listStore,y,(e,t)=>e.find(e=>t&&C(t)&&e.id===t.stepId)||null),x=(0,r.combine)(t.steps.listStore,v,(e,t)=>{let n=t.at(-2);if(!n||!C(n.node))return null;let r=n.node;return e.find(e=>e.id===r.stepId)||null}),D=(0,r.combine)(i.treeStore,y,({nodes:e,edges:t},n)=>n?ee(e,t,n):[]),O=(0,r.combine)(i.treeStore,y,({nodes:e,edges:t},n)=>n?te(e,t,n):[-1,-1]),A=(0,r.combine)(i.treeStore,y,({nodes:e,edges:t},n)=>n?k(e,t,n):[-1,-1]),I=F.store(!1),L=(0,r.createApi)(I,{open:()=>!0,close:()=>!1,toggle:e=>!e,set:(e,t)=>t}),R=(0,r.createEffect)(()=>{t.history.back({instanceId:c})}),z=(0,r.attach)({source:i.treeStore,effect:(e,n)=>{let r=e.nodes.find(e=>C(e)&&e.stepId===n);r&&t.history.push({instanceId:c,experienceId:i.id,node:r})}}),B=(0,r.attach)({source:y,effect:e=>{}}),V=(0,r.attach)({source:i.treeStore,effect:async({nodes:e})=>j(e)}),H=(0,r.attach)({source:i.treeStore,effect:async({nodes:e,edges:t},n)=>{if(T(n))return M(n,e,t)}}),U=(0,r.attach)({source:i.treeStore,effect:async({nodes:n,edges:r,conditions:i},a)=>{if(!S(a))return;let o=i.find(e=>e.id===a.conditionId)?.logic;return o?N(!!await e.t(t,o),a.id,n,r):void 0}}),W=(0,r.attach)({source:{tree:i.treeStore,actions:t.actions.listStore,snapshot:t.stateSnapshotStore},effect:async({tree:e,actions:t,snapshot:n},r)=>{let{nodes:i,edges:a}=e;if(!E(r))return;let o=r.actionKey;if(!o){`${r.id}`;return}let s=t.find(e=>e.key===o)?.action;if(!s||typeof s!=`function`)return`${o}`,P(r,a,i,`false`);try{`${o}`,await s({...n,args:[]},{experience:Z});let e=P(r,a,i,`true`);return e?(`${o}${e.id}`,e):(`${r.id}`,null)}catch{`${o}`;let e=P(r,a,i,`false`);return e?(`${o}${e.id}`,e):(`${r.id}`,null)}}}),G=(0,r.createEffect)(e=>{w(e)&&t.experiences.launch({key:e.experienceKey})}),K=(0,r.attach)({source:[y,i.treeStore],effect:async([e,{nodes:t,edges:n}])=>M(e,t,n)}),q=(0,r.attach)({source:[y,i.treeStore],effect:async([e,{nodes:t,edges:n}])=>M(e,t,n)}),J=(0,r.createEffect)(e=>{t.history.push({instanceId:c,experienceId:i.id,node:e})}),Y=(0,r.attach)({source:i.configStore,effect:async({initializeOpenLogic:n})=>o?.initialiseOpen===void 0?e.n(n)?!!await e.t(t,n):n??!1:o.initialiseOpen}),X=(0,r.combine)(h,t.frameworks.listStore,(e,t)=>{if(!e)return null;let n=t.find(t=>t.name===e.component.frameworkName);return n?{component:e,framework:n}:null},{skipVoid:!1}),Z,ne=(0,r.attach)({source:X,effect:e=>{if(!e)return;if(!a){`${i.id}`;return}let n=s(a);try{e.framework.render(n,e.component.component,t,Z)}catch{}}});Z=Object.freeze({id:c,experienceKey:i.key,experienceId:i.id,experienceName:i.name,configStore:i.configStore,target:a,componentStore:h,componentAndFrameworkStore:X,stateStore:g,isOpenStore:I,open:L.open,close:L.close,toggleOpen:L.toggle,setOpen:L.set,treeStore:i.treeStore,currentNodeStore:y,currentStepStore:b,previousStepStore:x,nextReachableStepNodesStore:D,stepsToOriginStore:O,stepsToLeafStore:A,goToNextStep:u,goToPreviousStep:d,goToStepById:f,stepsHistoryStore:v,mountFx:ne});let Q=(0,r.createEvent)(),$=(0,r.createEvent)();return(0,r.sample)({clock:y,target:Q}),(0,r.sample)({clock:Q,filter:e=>e===null,target:V}),(0,r.sample)({clock:Q,filter:e=>e!==null,target:$}),(0,r.split)({source:$,match:e=>S(e)?`condition`:C(e)?`step`:w(e)?`launchExperience`:T(e)?`origin`:E(e)?`action`:`other`,cases:{origin:H,condition:U,step:B,launchExperience:G,action:W,__:(0,r.createEvent)()}}),(0,r.sample)({clock:[U.doneData,H.doneData,V.doneData,q.doneData,K.doneData,W.doneData],filter:Boolean,target:J}),(0,r.sample)({clock:u,target:q}),(0,r.sample)({clock:u,source:b,filter:Boolean,target:t.eventBus.prepend(e=>({type:`step_submit`,step:e,experience:Z}))}),(0,r.sample)({clock:q.done,source:b,filter:Boolean,target:t.eventBus.prepend(e=>({type:`step_submit_success`,step:e,experience:Z}))}),(0,r.sample)({clock:q.fail,source:b,filter:Boolean,target:t.eventBus.prepend(e=>({type:`step_submit_error`,step:e,experience:Z}))}),(0,r.sample)({clock:d,target:R}),(0,r.sample)({clock:f,target:z}),(0,r.sample)({source:(0,r.combine)([U.pending,H.pending,V.pending,q.pending]),fn:e=>e.some(Boolean)?`transitioning`:`ready`,target:g}),(0,r.sample)({clock:B.doneData,source:b,filter:Boolean,target:t.eventBus.prepend(e=>({type:`step_enter`,step:e,experience:Z}))}),(0,r.sample)({clock:m,target:Y}),(0,r.sample)({source:Y.doneData,fn:Boolean,target:I}),(0,r.sample)({source:y,clock:l,filter:e=>e?T(e):!0,target:K}),(0,r.sample)({source:I,filter:Boolean,target:l}),(0,r.sample)({source:I,filter:Boolean,target:t.eventBus.prepend(()=>({type:`experience_open`,experience:Z}))}),(0,r.sample)({source:I,filter:e=>!e,target:t.eventBus.prepend(()=>({type:`experience_close`,experience:Z}))}),(0,r.sample)({clock:p,target:[m]}),p(),Z});function L(e){return(0,i.invoke)(I,e)}var R=(0,i.createFactory)(({client:e})=>{let t=F.store({}),n=(0,r.createEvent)(),i=(0,r.createEvent)(),a=(0,r.createEvent)(),o=(0,r.createApi)(t,{register(e,t){let n=[...e[t.experienceId]??[]];return n.push(t),{...e,[t.experienceId]:n}},unregister(e,t){let n=t.experienceId,r=e[n]?.filter(e=>e!==t);return{...e,[n]:r??[]}}}),s=(0,r.createEffect)(({experience:t,target:n,options:r})=>L({client:e,experience:t,target:n,options:r})),c=(0,r.createEffect)(e=>{o.register(e)}),u=(0,r.createEffect)(e=>{e.target&&l(e.target,()=>{a(e)})}),d=(0,r.createEffect)(e=>{o.unregister(e)}),f=(0,r.createEffect)(async e=>{await e.mountFx()});(0,r.sample)({clock:n,target:s}),(0,r.sample)({clock:a,target:d}),(0,r.sample)({clock:s.doneData,target:[c,u,i]}),(0,r.sample)({clock:s.doneData,target:e.eventBus.prepend(e=>({type:`experience_initialize`,experience:e}))}),(0,r.sample)({clock:i,target:f});function p(e,t,r){n({experience:e,target:t,options:r})}let m=t.map(e=>Object.values(e).flat());function h(e){return m.map(t=>t.filter(t=>t.experienceKey===e),{skipVoid:!1})}function g(e){return t.map(t=>t[e]||[],{skipVoid:!1})}return{spawn:p,getByExperienceKey:h,getByExperienceId:g,listStore:m}});function z(e){return(0,i.invoke)(R,e)}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return y}});