@picked/client 0.0.1-dev.1786072899095 → 0.0.1-dev.1786601464574
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/api-C8B96Kwv.js +22 -0
- package/dist/api-DS7fA9kj.cjs +1 -0
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/docs/explanation/content-references.md +99 -0
- package/dist/docs/explanation/how-picked-works.md +25 -3
- package/dist/docs/explanation/the-content-model.md +38 -28
- package/dist/docs/how-to/authenticate-the-cli.md +95 -0
- package/dist/docs/how-to/create-a-content-entry.md +48 -0
- package/dist/docs/how-to/define-a-page-layout.md +12 -5
- package/dist/docs/how-to/install-the-sdk.md +7 -0
- package/dist/docs/how-to/point-one-entry-at-another.md +61 -0
- package/dist/docs/how-to/read-a-referenced-entry.md +111 -0
- package/dist/docs/how-to/reuse-a-section.md +26 -10
- package/dist/docs/how-to/switch-workspaces.md +123 -0
- package/dist/docs/index.md +1 -1
- package/dist/docs/reference/dashboard/content/blocks.mdx +57 -0
- package/dist/docs/reference/dashboard/content/content-entries.mdx +61 -10
- package/dist/docs/reference/dashboard/content/models.mdx +108 -0
- package/dist/docs/reference/dashboard/content/pages.mdx +4 -3
- package/dist/docs/reference/dashboard/fields.mdx +1 -1
- package/dist/docs/reference/dashboard/steps.mdx +2 -2
- package/dist/docs/reference/delivery-api/experience-content.md +68 -13
- package/dist/docs/reference/delivery-api/workspace-schema.md +74 -0
- package/dist/docs/reference/glossary.md +13 -5
- package/dist/docs/reference/management-api/error-handling.md +2 -2
- package/dist/docs/reference/sdk/content.md +216 -0
- package/dist/docs/reference/sdk/plugins/dynamic-experiences.md +51 -3
- package/dist/docs/reference/sdk/ssr/serialize.md +6 -3
- package/dist/docs/reference/sdk/type-generation.md +130 -0
- package/dist/docs/reference/tools/cli.md +141 -0
- package/dist/docs/reference/tools/vite-plugin.md +90 -8
- package/dist/docs/tutorials/first-api-call.md +1 -1
- package/dist/docs/tutorials/first-server-rendered-page.mdx +1 -1
- package/dist/esm/index.js +496 -432
- package/dist/esm/plugins/dynamic-experiences/index.js +5 -3
- package/dist/esm/server/index.js +43 -46
- package/dist/plugin-C8hWW3ed.js +157 -0
- package/dist/plugin-Dtg2sOad.cjs +1 -0
- package/dist/provider-BEpRDCyr.js +69 -0
- package/dist/provider-ixdOyYTA.cjs +1 -0
- package/dist/registry-C1t8l3t9.cjs +1 -0
- package/dist/registry-CXZv0uLg.js +18 -0
- package/dist/types/data-source/api.d.ts +60 -0
- package/dist/types/data-source/api.d.ts.map +1 -0
- package/dist/types/data-source/provider.d.ts +90 -0
- package/dist/types/data-source/provider.d.ts.map +1 -0
- package/dist/types/data-source/registry.d.ts +26 -0
- package/dist/types/data-source/registry.d.ts.map +1 -0
- 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/entities/content/reference.d.ts +101 -0
- package/dist/types/entities/content/reference.d.ts.map +1 -0
- package/dist/types/entities/response/response.d.ts +22 -6
- package/dist/types/entities/response/response.d.ts.map +1 -1
- package/dist/types/exports.d.ts +2 -0
- package/dist/types/exports.d.ts.map +1 -1
- package/dist/types/form/create-submit-pipeline.d.ts +32 -3
- package/dist/types/form/create-submit-pipeline.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/picked.d.ts +68 -4
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/ping.d.ts +4 -3
- package/dist/types/ping.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/index.d.ts +2 -1
- package/dist/types/plugins/dynamic-experiences/index.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts +9 -40
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts +22 -129
- package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
- package/dist/types/schema-registry.d.ts +190 -0
- package/dist/types/schema-registry.d.ts.map +1 -0
- package/dist/types/server/index.d.ts +2 -2
- package/dist/types/server/index.d.ts.map +1 -1
- package/dist/types/server/serialize.d.ts +37 -34
- package/dist/types/server/serialize.d.ts.map +1 -1
- package/dist/types/typed-content.d.ts +17 -0
- package/dist/types/typed-content.d.ts.map +1 -0
- package/dist/types/utils/picked-config.d.ts +19 -1
- package/dist/types/utils/picked-config.d.ts.map +1 -1
- package/dist/version-BLzNWQ-j.cjs +1 -0
- package/dist/version-IAAIvoH9.js +4 -0
- package/package.json +5 -3
- package/dist/api-BzK4kXRt.js +0 -38
- package/dist/api-CgENjKwJ.cjs +0 -1
- package/dist/docs/reference/dashboard/content/layouts.mdx +0 -62
- package/dist/docs/reference/dashboard/content/sections.mdx +0 -28
- package/dist/plugin-DJjtc5df.js +0 -252
- package/dist/plugin-jHxSAqGG.cjs +0 -1
- package/dist/types/utils/api.d.ts +0 -25
- package/dist/types/utils/api.d.ts.map +0 -1
- package/dist/types/utils/client-headers.d.ts +0 -2
- package/dist/types/utils/client-headers.d.ts.map +0 -1
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as t,
|
|
3
|
-
|
|
1
|
+
import { t as e } from "../../../plugin-C8hWW3ed.js";
|
|
2
|
+
import { n as t, t as n } from "../../../api-C8B96Kwv.js";
|
|
3
|
+
import { n as r } from "../../../registry-CXZv0uLg.js";
|
|
4
|
+
import { createClientHeaders as i, fetchSchema as a } from "@picked/delivery-api-client";
|
|
5
|
+
export { i as createClientHeaders, e as dynamicExperiencesPlugin, n as fetchExperienceContent, t as fetchProject, a as fetchSchema, r as registerPickedBundle };
|
package/dist/esm/server/index.js
CHANGED
|
@@ -1,44 +1,41 @@
|
|
|
1
1
|
import { a as e, c as t, i as n, o as r, s as i, t as a, u as o } from "../../experience-instance-DGk11d8a.js";
|
|
2
|
-
import {
|
|
3
|
-
import { attach as
|
|
2
|
+
import { n as s } from "../../plugin-C8hWW3ed.js";
|
|
3
|
+
import { attach as c, createEffect as l, createEvent as u, createStore as d, sample as f } from "effector";
|
|
4
4
|
//#region src/server/serialize.ts
|
|
5
|
-
var
|
|
6
|
-
function
|
|
5
|
+
var p = 1e4;
|
|
6
|
+
function m(e) {
|
|
7
7
|
if (e?.location !== void 0) return { location: e.location };
|
|
8
8
|
}
|
|
9
|
-
function
|
|
9
|
+
function h(e, t) {
|
|
10
10
|
return e.nodes.filter(o).some((e) => t.get(e.stepId) === !0);
|
|
11
11
|
}
|
|
12
|
-
async function
|
|
13
|
-
let {
|
|
14
|
-
e.conditionResults.reset(), s(e,
|
|
12
|
+
async function g(e, n = {}) {
|
|
13
|
+
let i = n.previewToken === void 0 ? void 0 : { previewToken: n.previewToken }, a = await e.getProjectConfig(i), o = e.session.store.getState().id;
|
|
14
|
+
e.conditionResults.reset(), s(e, a, {
|
|
15
15
|
isPreview: !1,
|
|
16
|
-
sessionId:
|
|
16
|
+
sessionId: o
|
|
17
17
|
});
|
|
18
|
-
let
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
});
|
|
30
|
-
if (r) for (let e of r.content) d.set(e.id, e);
|
|
31
|
-
}
|
|
18
|
+
let c = m(n.attributes), l = n.timeoutMs ?? p, u = new Map(a.steps.map((e) => [e.id, e.layoutContentId !== void 0 && e.layoutContentId !== null])), d = Object.fromEntries(a.conditions.map((e) => [e.key, e])), f = a.experiences.filter((e) => !t(e.condition, d)), g = (await Promise.all(f.map(async (t) => ({
|
|
19
|
+
experience: t,
|
|
20
|
+
active: await r(e, { condition: t.condition }, { context: c })
|
|
21
|
+
})))).filter((e) => e.active).map((e) => e.experience), _ = await Promise.all(g.filter((e) => h(e, u)).map((t) => e.getExperienceContent({
|
|
22
|
+
id: t.id,
|
|
23
|
+
key: t.key
|
|
24
|
+
}, {
|
|
25
|
+
...i,
|
|
26
|
+
signal: AbortSignal.timeout(l)
|
|
27
|
+
}))), v = /* @__PURE__ */ new Map();
|
|
28
|
+
for (let e of _) if (e) for (let t of [...e.references ?? [], ...e.content]) v.set(t.id, t);
|
|
32
29
|
return {
|
|
33
|
-
versionId:
|
|
34
|
-
projectConfig:
|
|
35
|
-
content: Array.from(
|
|
30
|
+
versionId: a.versionId,
|
|
31
|
+
projectConfig: a,
|
|
32
|
+
content: Array.from(v.values()),
|
|
36
33
|
conditionResults: e.conditionResults.store.getState()
|
|
37
34
|
};
|
|
38
35
|
}
|
|
39
36
|
//#endregion
|
|
40
37
|
//#region src/server/index.ts
|
|
41
|
-
function
|
|
38
|
+
function _() {
|
|
42
39
|
let e, t;
|
|
43
40
|
return {
|
|
44
41
|
promise: new Promise((n, r) => {
|
|
@@ -48,16 +45,16 @@ function v() {
|
|
|
48
45
|
reject: (e) => t(e)
|
|
49
46
|
};
|
|
50
47
|
}
|
|
51
|
-
function
|
|
52
|
-
let { promise: n, resolve: r } =
|
|
48
|
+
function v(e, t) {
|
|
49
|
+
let { promise: n, resolve: r } = _(), i = u(), o = u(), s = u(), p = u(), m = u(), h = e.experiences.listStore.map((t) => t.map((t) => a({
|
|
53
50
|
client: e,
|
|
54
51
|
experience: t
|
|
55
|
-
}))), g =
|
|
52
|
+
}))), g = d({
|
|
56
53
|
currentExperienceIndex: 0,
|
|
57
54
|
renderedExperiences: [],
|
|
58
55
|
isComplete: !1
|
|
59
|
-
}),
|
|
60
|
-
let n =
|
|
56
|
+
}), v = l(async (t) => {
|
|
57
|
+
let n = c({
|
|
61
58
|
source: t.experience.componentStore,
|
|
62
59
|
effect: async (n, r) => {
|
|
63
60
|
let i = t.availableRenderers[r];
|
|
@@ -72,7 +69,7 @@ function y(e, t) {
|
|
|
72
69
|
if (t) return t;
|
|
73
70
|
}
|
|
74
71
|
return null;
|
|
75
|
-
}), y =
|
|
72
|
+
}), y = l(async ({ experience: e, availableRenderers: t, startRendererIndex: n = 0 }) => e ? v({
|
|
76
73
|
experience: e,
|
|
77
74
|
availableRenderers: t,
|
|
78
75
|
startRendererIndex: n
|
|
@@ -84,13 +81,13 @@ function y(e, t) {
|
|
|
84
81
|
})).on(m, (e) => ({
|
|
85
82
|
...e,
|
|
86
83
|
currentExperienceIndex: e.currentExperienceIndex + 1
|
|
87
|
-
})).on(
|
|
84
|
+
})).on(p, (e) => ({
|
|
88
85
|
...e,
|
|
89
86
|
isComplete: !0
|
|
90
|
-
})).reset(i),
|
|
87
|
+
})).reset(i), f({
|
|
91
88
|
clock: i,
|
|
92
89
|
target: o
|
|
93
|
-
}),
|
|
90
|
+
}), f({
|
|
94
91
|
clock: o,
|
|
95
92
|
source: {
|
|
96
93
|
experiences: h,
|
|
@@ -103,22 +100,22 @@ function y(e, t) {
|
|
|
103
100
|
startRendererIndex: 0
|
|
104
101
|
}),
|
|
105
102
|
target: y
|
|
106
|
-
}),
|
|
103
|
+
}), f({
|
|
107
104
|
clock: y.doneData,
|
|
108
105
|
filter: (e) => e !== null,
|
|
109
106
|
fn: (e) => e.rendered.body,
|
|
110
107
|
target: s
|
|
111
|
-
}),
|
|
108
|
+
}), f({
|
|
112
109
|
clock: s,
|
|
113
110
|
target: o
|
|
114
|
-
}),
|
|
111
|
+
}), f({
|
|
115
112
|
clock: y.doneData,
|
|
116
113
|
filter: (e) => e === null,
|
|
117
114
|
target: m
|
|
118
|
-
}),
|
|
115
|
+
}), f({
|
|
119
116
|
clock: m,
|
|
120
117
|
target: o
|
|
121
|
-
}),
|
|
118
|
+
}), f({
|
|
122
119
|
clock: [
|
|
123
120
|
o,
|
|
124
121
|
m,
|
|
@@ -129,18 +126,18 @@ function y(e, t) {
|
|
|
129
126
|
state: g
|
|
130
127
|
},
|
|
131
128
|
filter: ({ experiences: e, state: t }) => t.currentExperienceIndex >= e.length,
|
|
132
|
-
target:
|
|
129
|
+
target: p
|
|
133
130
|
});
|
|
134
|
-
let b =
|
|
131
|
+
let b = c({
|
|
135
132
|
source: g,
|
|
136
133
|
effect: (e) => {
|
|
137
134
|
e.isComplete && r(e.renderedExperiences);
|
|
138
135
|
}
|
|
139
136
|
});
|
|
140
|
-
return
|
|
141
|
-
clock:
|
|
137
|
+
return f({
|
|
138
|
+
clock: p,
|
|
142
139
|
target: b
|
|
143
140
|
}), i(), n;
|
|
144
141
|
}
|
|
145
142
|
//#endregion
|
|
146
|
-
export { a as createExperienceInstance, n as evaluateConditionMemo, e as hashRule, r as isExperienceActive, s as registerProjectConfig,
|
|
143
|
+
export { a as createExperienceInstance, n as evaluateConditionMemo, e as hashRule, r as isExperienceActive, s as registerProjectConfig, v as render, i as ruleReferencesAction, t as ruleReferencesActionDeep, g as serialize };
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import "./logger-DMN6TxJJ.js";
|
|
2
|
+
import "./api-C8B96Kwv.js";
|
|
3
|
+
import { attach as e } from "effector";
|
|
4
|
+
//#region src/plugins/dynamic-experiences/hash.ts
|
|
5
|
+
function t(e) {
|
|
6
|
+
let t = 2166136261;
|
|
7
|
+
for (let n of e) t ^= n.codePointAt(0) ?? 0, t = Math.imul(t, 16777619);
|
|
8
|
+
return t >>> 0;
|
|
9
|
+
}
|
|
10
|
+
function n(e) {
|
|
11
|
+
let t = e;
|
|
12
|
+
return t ^= t >>> 16, t = Math.imul(t, 2246822507), t ^= t >>> 13, t = Math.imul(t, 3266489909), t ^= t >>> 16, t >>> 0;
|
|
13
|
+
}
|
|
14
|
+
function r(e, r) {
|
|
15
|
+
return n(t(`${e}:${r}`)) % 100;
|
|
16
|
+
}
|
|
17
|
+
function i(e, t) {
|
|
18
|
+
return t <= 0 ? !1 : t >= 100 || e < t;
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/plugins/dynamic-experiences/plugin.ts
|
|
22
|
+
function a(e, t) {
|
|
23
|
+
if (Array.isArray(t.conditions)) for (let n of t.conditions) e.registerCondition(n);
|
|
24
|
+
}
|
|
25
|
+
function o(e, t) {
|
|
26
|
+
e.registerExperience({
|
|
27
|
+
id: t.id,
|
|
28
|
+
key: t.key,
|
|
29
|
+
name: t.name,
|
|
30
|
+
targets: t.targets,
|
|
31
|
+
nodes: t.nodes,
|
|
32
|
+
edges: t.edges,
|
|
33
|
+
condition: t.condition,
|
|
34
|
+
initializeOpen: t.initializeOpen,
|
|
35
|
+
componentName: t.componentName
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function s(e) {
|
|
39
|
+
return typeof e != "object" || !e ? !1 : "id" in e && "key" in e && "type" in e && "name" in e;
|
|
40
|
+
}
|
|
41
|
+
function c(e, t) {
|
|
42
|
+
if (Array.isArray(t.fields)) for (let n of t.fields) s(n) && e.registerField(n);
|
|
43
|
+
}
|
|
44
|
+
function l(e, t) {
|
|
45
|
+
if (!Array.isArray(t.steps)) return;
|
|
46
|
+
let n = new Map(t.fields.map((e) => [e.id, e.key]));
|
|
47
|
+
for (let r of t.steps) {
|
|
48
|
+
let t = [];
|
|
49
|
+
for (let e of r.fieldIds ?? []) {
|
|
50
|
+
let i = n.get(e);
|
|
51
|
+
if (i === void 0) {
|
|
52
|
+
`${r.key}${e}`;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
t.push(i);
|
|
56
|
+
}
|
|
57
|
+
let i = r.layoutContentId ? e.contents.getById(r.layoutContentId) : null;
|
|
58
|
+
e.registerStep({
|
|
59
|
+
id: r.id,
|
|
60
|
+
key: r.key,
|
|
61
|
+
name: r.name,
|
|
62
|
+
fieldKeys: t,
|
|
63
|
+
layoutName: r.layoutName,
|
|
64
|
+
...r.layoutContentId !== void 0 && {
|
|
65
|
+
layoutContentId: r.layoutContentId,
|
|
66
|
+
layoutContentStore: i
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function u(e, t) {
|
|
72
|
+
if (Array.isArray(t.experiences)) for (let n of t.experiences) o(e, n);
|
|
73
|
+
}
|
|
74
|
+
function d(e, t, n) {
|
|
75
|
+
m(e, t, n.isPreview, n.sessionId), a(e, t), c(e, t), l(e, t), u(e, t);
|
|
76
|
+
}
|
|
77
|
+
function f(e) {
|
|
78
|
+
let t = e.searchParams["preview-token"];
|
|
79
|
+
if (t && t.length > 0) return t[0];
|
|
80
|
+
}
|
|
81
|
+
function p(e) {
|
|
82
|
+
let t = /* @__PURE__ */ new Set(), n = e.searchParams.feature;
|
|
83
|
+
if (!n) return t;
|
|
84
|
+
for (let e of n) {
|
|
85
|
+
let n = e.indexOf(":");
|
|
86
|
+
n > 0 && t.add(e.substring(0, n));
|
|
87
|
+
}
|
|
88
|
+
return t;
|
|
89
|
+
}
|
|
90
|
+
function m(e, t, n, r) {
|
|
91
|
+
let i = p(e);
|
|
92
|
+
for (let a of t.features) i.has(a.id) || h(e, a, n, r);
|
|
93
|
+
}
|
|
94
|
+
function h(e, t, n, a) {
|
|
95
|
+
let o = r(a, t.id);
|
|
96
|
+
e.registerFeature(t.id, {
|
|
97
|
+
key: `v${t.version}`,
|
|
98
|
+
name: t.name,
|
|
99
|
+
enabled: t.enabled,
|
|
100
|
+
weight: t.weight,
|
|
101
|
+
storage: n ? "session" : "local",
|
|
102
|
+
decide: () => i(o, t.weight)
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function g(e, t) {
|
|
106
|
+
for (let n of [...t.references ?? [], ...t.content]) e.registerContent({
|
|
107
|
+
id: n.id,
|
|
108
|
+
contentModelKey: n.contentModelKey,
|
|
109
|
+
data: n.data
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
function _(e, t) {
|
|
113
|
+
let n = /* @__PURE__ */ new Map();
|
|
114
|
+
return (r, i) => {
|
|
115
|
+
let a = n.get(r.id);
|
|
116
|
+
if (a) return a;
|
|
117
|
+
let o = (async () => {
|
|
118
|
+
try {
|
|
119
|
+
let n = await t(r, i);
|
|
120
|
+
return n && g(e, n), n;
|
|
121
|
+
} finally {
|
|
122
|
+
n.delete(r.id);
|
|
123
|
+
}
|
|
124
|
+
})();
|
|
125
|
+
return n.set(r.id, o), o;
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function v(e, t) {
|
|
129
|
+
let n = new Set(t && Array.isArray(t.experiences) ? t.experiences.map((e) => e.id) : []);
|
|
130
|
+
return (t, r) => n.has(t.id) ? e(t, r) : Promise.resolve(null);
|
|
131
|
+
}
|
|
132
|
+
function y() {
|
|
133
|
+
return {
|
|
134
|
+
name: "dynamic-experiences",
|
|
135
|
+
setup: (t) => ({ onStart: e({
|
|
136
|
+
source: t.session.store.map((e) => e.id),
|
|
137
|
+
effect: async (e) => {
|
|
138
|
+
let n = f(t), r = n !== void 0, i = n === void 0 ? void 0 : { previewToken: n }, a = await t.getProjectConfig(n === void 0 ? void 0 : { previewToken: n }).catch((e) => null);
|
|
139
|
+
if (t.contentLoader = _(t, v((e) => t.getExperienceContent(e, i), a)), !a) return;
|
|
140
|
+
let o = t.seededVersionId;
|
|
141
|
+
if (o !== null && o !== a.versionId) {
|
|
142
|
+
t.versionSkew = {
|
|
143
|
+
seeded: o,
|
|
144
|
+
resolved: a.versionId
|
|
145
|
+
}, `${a.versionId}${o}`;
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
t.previewEmbedderOrigins = a.previewEmbedderOrigins ?? null, d(t, a, {
|
|
149
|
+
isPreview: r,
|
|
150
|
+
sessionId: e
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}) })
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
//#endregion
|
|
157
|
+
export { d as n, y as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require("./logger-CSTvAyyB.cjs"),require("./api-DS7fA9kj.cjs");let e=require("effector");function t(e){let t=2166136261;for(let n of e)t^=n.codePointAt(0)??0,t=Math.imul(t,16777619);return t>>>0}function n(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 r(e,r){return n(t(`${e}:${r}`))%100}function i(e,t){return t<=0?!1:t>=100||e<t}function a(e,t){if(Array.isArray(t.conditions))for(let n of t.conditions)e.registerCondition(n)}function o(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 s(e){return typeof e!=`object`||!e?!1:`id`in e&&`key`in e&&`type`in e&&`name`in e}function c(e,t){if(Array.isArray(t.fields))for(let n of t.fields)s(n)&&e.registerField(n)}function l(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 u(e,t){if(Array.isArray(t.experiences))for(let n of t.experiences)o(e,n)}function d(e,t,n){m(e,t,n.isPreview,n.sessionId),a(e,t),c(e,t),l(e,t),u(e,t)}function f(e){let t=e.searchParams[`preview-token`];if(t&&t.length>0)return t[0]}function p(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 m(e,t,n,r){let i=p(e);for(let a of t.features)i.has(a.id)||h(e,a,n,r)}function h(e,t,n,a){let o=r(a,t.id);e.registerFeature(t.id,{key:`v${t.version}`,name:t.name,enabled:t.enabled,weight:t.weight,storage:n?`session`:`local`,decide:()=>i(o,t.weight)})}function g(e,t){for(let n of[...t.references??[],...t.content])e.registerContent({id:n.id,contentModelKey:n.contentModelKey,data:n.data})}function _(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&&g(e,n),n}finally{n.delete(r.id)}})();return n.set(r.id,o),o}}function v(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 y(){return{name:`dynamic-experiences`,setup:t=>({onStart:(0,e.attach)({source:t.session.store.map(e=>e.id),effect:async e=>{let n=f(t),r=n!==void 0,i=n===void 0?void 0:{previewToken:n},a=await t.getProjectConfig(n===void 0?void 0:{previewToken:n}).catch(e=>null);if(t.contentLoader=_(t,v(e=>t.getExperienceContent(e,i),a)),!a)return;let o=t.seededVersionId;if(o!==null&&o!==a.versionId){t.versionSkew={seeded:o,resolved:a.versionId},`${a.versionId}${o}`;return}t.previewEmbedderOrigins=a.previewEmbedderOrigins??null,d(t,a,{isPreview:r,sessionId:e})}})})}}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return y}});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import "./logger-DMN6TxJJ.js";
|
|
2
|
+
import { n as e, t } from "./api-C8B96Kwv.js";
|
|
3
|
+
import { r as n, t as r } from "./registry-CXZv0uLg.js";
|
|
4
|
+
//#region src/data-source/provider.ts
|
|
5
|
+
var i = "bundle", a = "api";
|
|
6
|
+
async function o() {
|
|
7
|
+
try {
|
|
8
|
+
let e = await import("virtual:picked/data");
|
|
9
|
+
return n(e) ? e : null;
|
|
10
|
+
} catch {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function s(e) {
|
|
15
|
+
if (e === void 0 || n(e)) return e;
|
|
16
|
+
}
|
|
17
|
+
function c(n) {
|
|
18
|
+
let { apiUrl: c, projectId: l, previewToken: u, signal: d } = n, f = !!u, p = f ? a : n.mode, m = s(f ? void 0 : n.bundle), h = f ? void 0 : n.projectConfig, g = n.getContent, _ = {
|
|
19
|
+
mode: p ?? a,
|
|
20
|
+
manifest: null
|
|
21
|
+
}, v, y, b = /* @__PURE__ */ new Map();
|
|
22
|
+
function x() {
|
|
23
|
+
if (p === a) return Promise.resolve(null);
|
|
24
|
+
if (m) return Promise.resolve(m);
|
|
25
|
+
let e = r();
|
|
26
|
+
return e ? Promise.resolve(e) : (v ??= o(), v);
|
|
27
|
+
}
|
|
28
|
+
function S(e) {
|
|
29
|
+
_.mode = e ? i : a, _.manifest = e ? e.manifestMetadata : null;
|
|
30
|
+
}
|
|
31
|
+
async function C() {
|
|
32
|
+
if (h) return S(await x()), h;
|
|
33
|
+
let t = await x();
|
|
34
|
+
return S(t), t ? t.projectConfig : p === i ? null : e(c, l, {
|
|
35
|
+
...u !== void 0 && { previewToken: u },
|
|
36
|
+
...d !== void 0 && { signal: d }
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
async function w(e, n) {
|
|
40
|
+
let r = u === void 0 ? void 0 : { previewToken: u };
|
|
41
|
+
if (g) return g(e, r);
|
|
42
|
+
let a = await x();
|
|
43
|
+
if (S(a), a) try {
|
|
44
|
+
return await a.experienceContent(e, r);
|
|
45
|
+
} catch {
|
|
46
|
+
return `${e.id}`, null;
|
|
47
|
+
}
|
|
48
|
+
if (p === i) return null;
|
|
49
|
+
let o = n ?? d;
|
|
50
|
+
return t(c, l, e.id, {
|
|
51
|
+
...u !== void 0 && { previewToken: u },
|
|
52
|
+
...o !== void 0 && { signal: o }
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
meta: _,
|
|
57
|
+
getProjectConfig: () => (y ??= C(), y),
|
|
58
|
+
getContent: (e, t) => {
|
|
59
|
+
let n = b.get(e.id);
|
|
60
|
+
if (n) return n;
|
|
61
|
+
let r = w(e, t?.signal).finally(() => {
|
|
62
|
+
b.delete(e.id);
|
|
63
|
+
});
|
|
64
|
+
return b.set(e.id, r), r;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
export { c as createPickedDataProvider };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require("./logger-CSTvAyyB.cjs");const e=require("./api-DS7fA9kj.cjs"),t=require("./registry-C1t8l3t9.cjs");var n=`bundle`,r=`api`;async function i(){try{let e=await import(`virtual:picked/data`);return t.r(e)?e:null}catch{return null}}function a(e){if(e===void 0||t.r(e))return e}function o(o){let{apiUrl:s,projectId:c,previewToken:l,signal:u}=o,d=!!l,f=d?r:o.mode,p=a(d?void 0:o.bundle),m=d?void 0:o.projectConfig,h=o.getContent,g={mode:f??r,manifest:null},_,v,y=new Map;function b(){if(f===r)return Promise.resolve(null);if(p)return Promise.resolve(p);let e=t.t();return e?Promise.resolve(e):(_??=i(),_)}function x(e){g.mode=e?n:r,g.manifest=e?e.manifestMetadata:null}async function S(){if(m)return x(await b()),m;let t=await b();return x(t),t?t.projectConfig:f===n?null:e.n(s,c,{...l!==void 0&&{previewToken:l},...u!==void 0&&{signal:u}})}async function C(t,r){let i=l===void 0?void 0:{previewToken:l};if(h)return h(t,i);let a=await b();if(x(a),a)try{return await a.experienceContent(t,i)}catch{return`${t.id}`,null}if(f===n)return null;let o=r??u;return e.t(s,c,t.id,{...l!==void 0&&{previewToken:l},...o!==void 0&&{signal:o}})}return{meta:g,getProjectConfig:()=>(v??=S(),v),getContent:(e,t)=>{let n=y.get(e.id);if(n)return n;let r=C(e,t?.signal).finally(()=>{y.delete(e.id)});return y.set(e.id,r),r}}}exports.createPickedDataProvider=o;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require("./logger-CSTvAyyB.cjs");function e(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 t=null;function n(n){e(n)&&(t=n)}function r(){return t}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return r}});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import "./logger-DMN6TxJJ.js";
|
|
2
|
+
//#region src/data-source/virtual-data.ts
|
|
3
|
+
function e(e) {
|
|
4
|
+
if (typeof e != "object" || !e || !("projectConfig" in e) || !("experienceContent" in e) || !("manifestMetadata" in e)) return !1;
|
|
5
|
+
let { experienceContent: t } = e;
|
|
6
|
+
return typeof t == "function";
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/data-source/registry.ts
|
|
10
|
+
var t = null;
|
|
11
|
+
function n(n) {
|
|
12
|
+
e(n) && (t = n);
|
|
13
|
+
}
|
|
14
|
+
function r() {
|
|
15
|
+
return t;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { n, e as r, r as t };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { ExperienceContentResponse, FetchProjectOptions, ProjectConfig } from '@picked/delivery-api-client';
|
|
2
|
+
/**
|
|
3
|
+
* Minimal shape check: verifies that `data` is an object with a `features` array.
|
|
4
|
+
*
|
|
5
|
+
* This is the minimum invariant required to prevent runtime crashes when iterating
|
|
6
|
+
* `config.features`. Individual feature and experience shapes are trusted from the API.
|
|
7
|
+
*
|
|
8
|
+
* @param {unknown} data - Unknown API response to validate.
|
|
9
|
+
* @returns {boolean} Whether `data` has the minimum required shape.
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* if (isProjectConfig(json)) { json.features }
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare function isProjectConfig(data: unknown): data is ProjectConfig;
|
|
16
|
+
/**
|
|
17
|
+
* Minimal shape check for a successful experience-content response.
|
|
18
|
+
*
|
|
19
|
+
* @param {unknown} data - Unknown API response to validate.
|
|
20
|
+
* @returns {boolean} Whether `data` has the minimum required shape.
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* if (isExperienceContentResponse(json)) { useResponse(json) }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function isExperienceContentResponse(data: unknown): data is ExperienceContentResponse;
|
|
27
|
+
/**
|
|
28
|
+
* Fetches the project configuration from the Picked REST API.
|
|
29
|
+
*
|
|
30
|
+
* Returns `null` on network failure, non-OK responses, or invalid JSON shape.
|
|
31
|
+
* Connection-refused errors from local URLs are suppressed silently.
|
|
32
|
+
*
|
|
33
|
+
* @param {string} apiUrl - Base URL for the Picked API.
|
|
34
|
+
* @param {string} projectId - Project ID to fetch config for.
|
|
35
|
+
* @param {FetchProjectOptions} [options] - Optional headers, preview token, and abort signal.
|
|
36
|
+
* @returns {Promise<ProjectConfig | null>} Validated project config, or `null` on any failure.
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const config = await fetchProject('https://api.picked.app', 'proj_123')
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function fetchProject(apiUrl: string, projectId: string, options?: FetchProjectOptions): Promise<ProjectConfig | null>;
|
|
43
|
+
/**
|
|
44
|
+
* Fetches per-experience content from the Picked API.
|
|
45
|
+
*
|
|
46
|
+
* Returns `null` on network failure, non-OK responses, or invalid JSON shape — preserving
|
|
47
|
+
* the failure-tolerant policy: experiences still render, layouts handle null defensively.
|
|
48
|
+
*
|
|
49
|
+
* @param {string} apiUrl - Base URL for the Picked API.
|
|
50
|
+
* @param {string} projectId - Project ID to fetch content for.
|
|
51
|
+
* @param {string} experienceId - Experience ID whose content to fetch.
|
|
52
|
+
* @param {FetchProjectOptions} [options] - Optional headers, preview token, and abort signal.
|
|
53
|
+
* @returns {Promise<ExperienceContentResponse | null>} Validated content response, or `null` on any failure.
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* const content = await fetchExperienceContent('https://api.picked.app', 'proj_1', 'exp_1')
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare function fetchExperienceContent(apiUrl: string, projectId: string, experienceId: string, options?: FetchProjectOptions): Promise<ExperienceContentResponse | null>;
|
|
60
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/data-source/api.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EACV,yBAAyB,EACzB,mBAAmB,EACnB,aAAa,EACd,MAAM,6BAA6B,CAAA;AA6CpC;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,aAAa,CAEpE;AAED;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,yBAAyB,CAM5F;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAE/B;AAED;;;;;;;;;;;;;;;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,CAE3C"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { ContentLoader, ExperienceContentResponse, PickedManifestMetadata, ProjectConfig, VirtualPickedData } from '../plugins/dynamic-experiences/types';
|
|
2
|
+
import { isVirtualPickedData } from './virtual-data';
|
|
3
|
+
/** Where a data provider reads project config and CMS content from. */
|
|
4
|
+
export type PickedDataMode = 'bundle' | 'api';
|
|
5
|
+
/** Options for {@link createPickedDataProvider}. */
|
|
6
|
+
export interface PickedDataProviderOptions {
|
|
7
|
+
/** Base URL for the Picked API. Used by `'api'` mode and by every preview session. */
|
|
8
|
+
apiUrl: string;
|
|
9
|
+
/** Project ID to resolve data for. */
|
|
10
|
+
projectId: string;
|
|
11
|
+
/**
|
|
12
|
+
* Which source to read from. Omit to resolve `'bundle'` when a bundle is available and
|
|
13
|
+
* `'api'` otherwise.
|
|
14
|
+
*/
|
|
15
|
+
mode?: PickedDataMode;
|
|
16
|
+
/**
|
|
17
|
+
* Preview token from the current session. A present token forces `'api'` for both config
|
|
18
|
+
* and content and overrides `bundle` and `projectConfig`, because preview renders
|
|
19
|
+
* unpublished data that no bundled snapshot can contain.
|
|
20
|
+
*/
|
|
21
|
+
previewToken?: string;
|
|
22
|
+
/**
|
|
23
|
+
* The `virtual:picked/data` module, supplied directly to skip both the registry and the
|
|
24
|
+
* dynamic import. A value that fails the shape guard is ignored with a warning, the same as
|
|
25
|
+
* an unresolvable import.
|
|
26
|
+
*/
|
|
27
|
+
bundle?: VirtualPickedData;
|
|
28
|
+
/** Explicit project config. Supersedes both sources, except under a preview token. */
|
|
29
|
+
projectConfig?: ProjectConfig;
|
|
30
|
+
/** Explicit content loader. Supersedes both sources, except under a preview token. */
|
|
31
|
+
getContent?: ContentLoader;
|
|
32
|
+
/** Abort signal applied to API fetches, such as an `AbortSignal.timeout` deadline. */
|
|
33
|
+
signal?: AbortSignal;
|
|
34
|
+
}
|
|
35
|
+
/** Read-only description of what a provider resolved to. */
|
|
36
|
+
export interface PickedDataProviderMeta {
|
|
37
|
+
/** The mode in force, after preview-token resolution. */
|
|
38
|
+
mode: PickedDataMode;
|
|
39
|
+
/** The bundle's manifest metadata, or `null` when not reading from a bundle. */
|
|
40
|
+
manifest: PickedManifestMetadata | null;
|
|
41
|
+
}
|
|
42
|
+
/** Resolves this session's project config and per-experience CMS content. */
|
|
43
|
+
export interface PickedDataProvider {
|
|
44
|
+
/** What this provider resolved to. `manifest` populates once a bundle has been read. */
|
|
45
|
+
readonly meta: PickedDataProviderMeta;
|
|
46
|
+
/** Resolves the project config, or `null` when unavailable. Deduplicated across callers. */
|
|
47
|
+
getProjectConfig: () => Promise<ProjectConfig | null>;
|
|
48
|
+
/** Resolves an experience's content, or `null` when unavailable. Deduplicated per experience id. */
|
|
49
|
+
getContent: (experience: {
|
|
50
|
+
id: string;
|
|
51
|
+
key: string;
|
|
52
|
+
}, options?: {
|
|
53
|
+
signal?: AbortSignal;
|
|
54
|
+
}) => Promise<ExperienceContentResponse | null>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Attempts to resolve `virtual:picked/data` provided by `@picked/vite-plugin-picked`.
|
|
58
|
+
*
|
|
59
|
+
* The dynamic import uses a literal string specifier (intentionally — using a variable plus
|
|
60
|
+
* `@vite-ignore` defeats Vite's import-analysis, so the plugin's `resolveId` is never called
|
|
61
|
+
* at build time and the bundle ends up with a runtime fetch to a `virtual:` URL that the
|
|
62
|
+
* browser cannot resolve). The SDK's own build marks `virtual:picked/data` as external so
|
|
63
|
+
* this literal import is preserved into the published dist, then downstream Vite builds with
|
|
64
|
+
* `@picked/vite-plugin-picked` resolve it through the plugin pipeline.
|
|
65
|
+
*
|
|
66
|
+
* Returns `null` when the virtual module is unresolvable (the consumer is not using the Vite
|
|
67
|
+
* plugin, or its build did not generate the module). Errors are swallowed: the caller falls
|
|
68
|
+
* back to the API path.
|
|
69
|
+
*
|
|
70
|
+
* @returns {Promise<VirtualPickedData | null>} The virtual module exports, or `null`.
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* const bundle = await resolveVirtualDataModule()
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare function resolveVirtualDataModule(): Promise<VirtualPickedData | null>;
|
|
77
|
+
export { isVirtualPickedData };
|
|
78
|
+
/**
|
|
79
|
+
* Creates the data provider for a session.
|
|
80
|
+
*
|
|
81
|
+
* @param {PickedDataProviderOptions} options - Provider configuration.
|
|
82
|
+
* @returns {PickedDataProvider} A provider resolving config and content from one source.
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* const provider = createPickedDataProvider({ mode: 'api', apiUrl, projectId })
|
|
86
|
+
* const config = await provider.getProjectConfig()
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
export declare function createPickedDataProvider(options: PickedDataProviderOptions): PickedDataProvider;
|
|
90
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/data-source/provider.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,aAAa,EACb,yBAAyB,EACzB,sBAAsB,EACtB,aAAa,EACb,iBAAiB,EAClB,MAAM,sCAAsC,CAAA;AAG7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAEpD,uEAAuE;AACvE,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,KAAK,CAAA;AAQ7C,oDAAoD;AACpD,MAAM,WAAW,yBAAyB;IACxC,sFAAsF;IACtF,MAAM,EAAE,MAAM,CAAA;IACd,sCAAsC;IACtC,SAAS,EAAE,MAAM,CAAA;IACjB;;;OAGG;IACH,IAAI,CAAC,EAAE,cAAc,CAAA;IACrB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;;OAIG;IACH,MAAM,CAAC,EAAE,iBAAiB,CAAA;IAC1B,sFAAsF;IACtF,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B,sFAAsF;IACtF,UAAU,CAAC,EAAE,aAAa,CAAA;IAC1B,sFAAsF;IACtF,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB;AAED,4DAA4D;AAC5D,MAAM,WAAW,sBAAsB;IACrC,yDAAyD;IACzD,IAAI,EAAE,cAAc,CAAA;IACpB,gFAAgF;IAChF,QAAQ,EAAE,sBAAsB,GAAG,IAAI,CAAA;CACxC;AAED,6EAA6E;AAC7E,MAAM,WAAW,kBAAkB;IACjC,wFAAwF;IACxF,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAA;IACrC,4FAA4F;IAC5F,gBAAgB,EAAE,MAAM,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAAA;IACrD,oGAAoG;IACpG,UAAU,EAAE,CACV,UAAU,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,EACvC,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,KAC/B,OAAO,CAAC,yBAAyB,GAAG,IAAI,CAAC,CAAA;CAC/C;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAYlF;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAA;AAyB9B;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,kBAAkB,CAuK/F"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { VirtualPickedData } from '../plugins/dynamic-experiences/types';
|
|
2
|
+
/**
|
|
3
|
+
* Records the bundle the build generated, for this session's data provider to read.
|
|
4
|
+
*
|
|
5
|
+
* A value that fails the shape guard is refused, so a malformed registration lands on the
|
|
6
|
+
* "no bundle" path. Any usable bundle registered earlier is kept.
|
|
7
|
+
*
|
|
8
|
+
* @param {unknown} bundle - The generated module's exports.
|
|
9
|
+
* @returns {void} Nothing.
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* registerPickedBundle({ projectConfig, experienceContent, manifestMetadata })
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare function registerPickedBundle(bundle: unknown): void;
|
|
16
|
+
/**
|
|
17
|
+
* Reads the registered bundle.
|
|
18
|
+
*
|
|
19
|
+
* @returns {VirtualPickedData | null} The bundle, or `null` when nothing has registered one.
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const bundle = readRegisteredBundle()
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function readRegisteredBundle(): VirtualPickedData | null;
|
|
26
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/data-source/registry.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AAK7E;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAQ1D;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,IAAI,iBAAiB,GAAG,IAAI,CAE/D"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The shape guard for the generated `virtual:picked/data` module.
|
|
3
|
+
*
|
|
4
|
+
* Lives apart from the provider and the registry because both validate against it, and a guard
|
|
5
|
+
* shared by two modules that also reference each other would otherwise close an import cycle.
|
|
6
|
+
*/
|
|
7
|
+
import type { VirtualPickedData } from '../plugins/dynamic-experiences/types';
|
|
8
|
+
/**
|
|
9
|
+
* Runtime type guard that validates the shape of a `virtual:picked/data` module.
|
|
10
|
+
*
|
|
11
|
+
* @param {unknown} value - Candidate module exports.
|
|
12
|
+
* @returns {boolean} Whether `value` matches the {@link VirtualPickedData} shape.
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* if (isVirtualPickedData(mod)) { useVirtualModule(mod) }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function isVirtualPickedData(value: unknown): value is VirtualPickedData;
|
|
19
|
+
//# sourceMappingURL=virtual-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"virtual-data.d.ts","sourceRoot":"","sources":["../../../src/data-source/virtual-data.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AAE7E;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,iBAAiB,CAU9E"}
|