@picked/client 0.0.62-next.1 → 0.0.62-next.11
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/README.md +0 -8
- package/dist/{api-Dfrznen2.js → api-C6HQ65g9.js} +1 -1
- package/dist/api-v323-Asd.cjs +1 -0
- package/dist/cjs/form/index.js +1 -1
- package/dist/cjs/index.js +4 -4
- package/dist/cjs/plugins/create-experience/index.js +1 -1
- package/dist/cjs/plugins/dom-observer/index.js +1 -0
- package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
- package/dist/cjs/plugins/experience-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/history-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/single-page-app/index.js +1 -1
- package/dist/cjs/plugins/web-components/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/docs/actions.mdx +0 -1
- package/dist/docs/api/authentication.md +376 -0
- package/dist/docs/api/authorization-and-scopes.md +262 -0
- package/dist/docs/api/error-handling.md +211 -0
- package/dist/docs/api/index.md +172 -11
- package/dist/docs/api/pagination.md +176 -0
- package/dist/docs/image-optimisation-service.md +72 -0
- package/dist/docs/index.md +0 -2
- package/dist/docs/pickedql/data-sources.md +2 -2
- package/dist/docs/pickedql/dimensions.md +2 -0
- package/dist/docs/pickedql/schema.md +2 -2
- package/dist/docs/pickedql/virtual-functions.md +27 -0
- package/dist/docs/sdk/actions.md +0 -1
- package/dist/docs/sdk/content-security-policy.md +8 -7
- package/dist/docs/sdk/features.md +0 -1
- package/dist/docs/sdk/fields.md +2 -2
- package/dist/docs/sdk/index.md +0 -1
- package/dist/docs/sdk/plugins/create-experience.md +0 -1
- package/dist/docs/sdk/plugins/dynamic-experiences.md +2 -3
- package/dist/docs/sdk/plugins/window-object.md +0 -1
- package/dist/docs/sdk/predicates.md +0 -1
- package/dist/docs/workspaces.mdx +60 -1
- package/dist/dom-C3C6Fmwz.cjs +1 -0
- package/dist/dom-DGePXPpM.js +84 -0
- package/dist/esm/form/index.js +1 -1
- package/dist/esm/index.js +1020 -494
- package/dist/esm/plugins/create-experience/index.js +1 -1
- package/dist/esm/plugins/dom-observer/index.js +87 -0
- package/dist/esm/plugins/dynamic-experiences/index.js +133 -60
- package/dist/esm/plugins/experience-browser-storage/index.js +9 -6
- package/dist/esm/plugins/history-browser-storage/index.js +1 -1
- package/dist/esm/plugins/responses-browser-storage/index.js +1 -1
- package/dist/esm/plugins/single-page-app/index.js +1 -1
- package/dist/esm/plugins/web-components/index.js +1 -1
- package/dist/esm/server/index.js +23 -13
- package/dist/experience-instance-DImym3m_.js +419 -0
- package/dist/experience-instance-DygAdzbn.cjs +1 -0
- package/dist/rules-logic-D_CVBuv7.js +13 -0
- package/dist/rules-logic-H6P8xwHF.cjs +1 -0
- package/dist/types/client.d.ts +2 -2
- package/dist/types/entities/action/action.d.ts +6 -3
- package/dist/types/entities/action/action.d.ts.map +1 -1
- package/dist/types/entities/component/component.d.ts +39 -2
- package/dist/types/entities/component/component.d.ts.map +1 -1
- package/dist/types/entities/content/content.d.ts +37 -0
- package/dist/types/entities/content/content.d.ts.map +1 -0
- package/dist/types/entities/experience/experience.d.ts +69 -113
- package/dist/types/entities/experience/experience.d.ts.map +1 -1
- package/dist/types/entities/experience-instance/experience-instance.d.ts +17 -2
- package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
- package/dist/types/entities/feature/feature.d.ts +26 -2
- package/dist/types/entities/feature/feature.d.ts.map +1 -1
- package/dist/types/entities/field/field.d.ts.map +1 -1
- package/dist/types/entities/framework/framework.d.ts +24 -3
- package/dist/types/entities/framework/framework.d.ts.map +1 -1
- package/dist/types/entities/plugin/plugin.d.ts +32 -1
- package/dist/types/entities/plugin/plugin.d.ts.map +1 -1
- package/dist/types/entities/predicate/predicate.d.ts +24 -3
- package/dist/types/entities/predicate/predicate.d.ts.map +1 -1
- package/dist/types/entities/session/session.d.ts +45 -0
- package/dist/types/entities/session/session.d.ts.map +1 -0
- package/dist/types/entities/step/step.d.ts +17 -2
- package/dist/types/entities/step/step.d.ts.map +1 -1
- package/dist/types/exports.d.ts +9 -3
- package/dist/types/exports.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lifecycle/lifecycle.d.ts +47 -0
- package/dist/types/lifecycle/lifecycle.d.ts.map +1 -0
- package/dist/types/lifecycle/rules-logic.d.ts +24 -0
- package/dist/types/lifecycle/rules-logic.d.ts.map +1 -0
- package/dist/types/lifecycle/state-snapshot.d.ts +37 -0
- package/dist/types/lifecycle/state-snapshot.d.ts.map +1 -0
- package/dist/types/logic-engine.d.ts +1 -1
- package/dist/types/logic-engine.d.ts.map +1 -1
- package/dist/types/picked.d.ts +141 -187
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/dom-observer/index.d.ts +3 -0
- package/dist/types/plugins/dom-observer/index.d.ts.map +1 -0
- package/dist/types/plugins/dom-observer/plugin.d.ts +50 -0
- package/dist/types/plugins/dom-observer/plugin.d.ts.map +1 -0
- 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 +18 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts +63 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
- package/dist/types/plugins/experience-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/plugins/web-components/plugin.d.ts.map +1 -1
- package/dist/types/server/index.d.ts +7 -0
- package/dist/types/server/index.d.ts.map +1 -1
- package/dist/types/utils/events.d.ts +1 -1
- package/dist/types/utils/events.d.ts.map +1 -1
- package/dist/types/utils/picked-config.d.ts +12 -4
- package/dist/types/utils/picked-config.d.ts.map +1 -1
- package/dist/types/utils/rules-logic.d.ts +4 -9
- package/dist/types/utils/rules-logic.d.ts.map +1 -1
- package/package.json +12 -2
- package/dist/api-NpGrXHyM.cjs +0 -1
- package/dist/docs/reference/index.md +0 -11
- package/dist/docs/tooling/index.md +0 -19
- package/dist/experience-instance-DC2gKwA6.cjs +0 -1
- package/dist/experience-instance-DJaNc5Ob.js +0 -486
- package/dist/rules-logic-BTIxfrJJ.js +0 -240
- package/dist/rules-logic-DNLOv90w.cjs +0 -1
- package/dist/types/utils/state-snaphot.d.ts +0 -26
- package/dist/types/utils/state-snaphot.d.ts.map +0 -1
- package/dist/types/utils/user-session.d.ts +0 -12
- package/dist/types/utils/user-session.d.ts.map +0 -1
- /package/dist/docs/{tooling/chrome-extension.md → chrome-extension.md} +0 -0
- /package/dist/docs/{tooling/gtm-template.md → gtm-template.md} +0 -0
- /package/dist/docs/{tooling/mcp.md → mcp.md} +0 -0
- /package/dist/docs/{tooling/vite-plugin.md → vite-plugin.md} +0 -0
- /package/dist/{id-Bv44ilEo.cjs → id-Cg7fVl1O.cjs} +0 -0
- /package/dist/{id-CRqy981z.js → id-n2yrHvNo.js} +0 -0
- /package/dist/{object-C82v79xc.js → object-DvUDOytC.js} +0 -0
- /package/dist/{object-CUJOjanb.cjs → object-ThO1DEyl.cjs} +0 -0
- /package/dist/{storage-B6lQtc4-.cjs → storage-BXSlLTRa.cjs} +0 -0
- /package/dist/{storage-6Xk0uAxB.js → storage-hOHCCXvP.js} +0 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import "../../../logger-6z_gb4rA.js";
|
|
2
|
+
import { d as e, r as t } from "../../../supports-0XIfd4-R.js";
|
|
3
|
+
import { r as n } from "../../../dom-DGePXPpM.js";
|
|
4
|
+
import { createEffect as r, createEvent as i, createStore as a, sample as o } from "effector";
|
|
5
|
+
//#region src/plugins/dom-observer/plugin.ts
|
|
6
|
+
var s = /* @__PURE__ */ new WeakSet(), c = () => ({
|
|
7
|
+
name: "dom-observer",
|
|
8
|
+
setup: (e) => {
|
|
9
|
+
l() && (s.has(e) || (s.add(e), u(e)));
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
function l() {
|
|
13
|
+
return !(!e() || !t() || typeof MutationObserver != "function" || typeof requestAnimationFrame != "function");
|
|
14
|
+
}
|
|
15
|
+
function u(e) {
|
|
16
|
+
n().then(() => {
|
|
17
|
+
document.body && d(e);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function d(e) {
|
|
21
|
+
let t = i(), n = a(/* @__PURE__ */ new Map()).on(t, (e, { id: t, selectors: n }) => {
|
|
22
|
+
let r = new Map(e);
|
|
23
|
+
return n.length > 0 ? r.set(t, n) : r.delete(t), r;
|
|
24
|
+
}), s = /* @__PURE__ */ new Map();
|
|
25
|
+
e.experiences.listStore.watch((e) => {
|
|
26
|
+
for (let n of e) {
|
|
27
|
+
if (s.has(n.id)) continue;
|
|
28
|
+
let e = n.configStore.watch((e) => {
|
|
29
|
+
t({
|
|
30
|
+
id: n.id,
|
|
31
|
+
selectors: f(e.targetSelectors)
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
s.set(n.id, e);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
let c = r(async (e) => {
|
|
38
|
+
await Promise.all(e.map(async (e) => {
|
|
39
|
+
await e.shouldInitialiseFx() && await e.initialiseFx(void 0);
|
|
40
|
+
}));
|
|
41
|
+
});
|
|
42
|
+
c.fail.watch(({ error: e }) => {});
|
|
43
|
+
let l = i();
|
|
44
|
+
o({
|
|
45
|
+
clock: l,
|
|
46
|
+
source: {
|
|
47
|
+
selectorsById: n,
|
|
48
|
+
experiences: e.experiences.listStore
|
|
49
|
+
},
|
|
50
|
+
fn: ({ selectorsById: e, experiences: t }, n) => t.filter((t) => {
|
|
51
|
+
let r = e.get(t.id);
|
|
52
|
+
return r ? r.some((e) => p(n, e)) : !1;
|
|
53
|
+
}),
|
|
54
|
+
target: c
|
|
55
|
+
});
|
|
56
|
+
let u = [], d, m = () => {
|
|
57
|
+
d = void 0;
|
|
58
|
+
let e = u;
|
|
59
|
+
u = [], l(e);
|
|
60
|
+
};
|
|
61
|
+
new MutationObserver((e) => {
|
|
62
|
+
let t = !1;
|
|
63
|
+
for (let n of e) if (n.type === "childList") for (let e of n.addedNodes) e instanceof Element && (u.push(e), t = !0);
|
|
64
|
+
t && (d ??= requestAnimationFrame(m));
|
|
65
|
+
}).observe(document.body, {
|
|
66
|
+
childList: !0,
|
|
67
|
+
subtree: !0
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
function f(e) {
|
|
71
|
+
let t = [];
|
|
72
|
+
for (let n of e) {
|
|
73
|
+
let e = n.selector.trim();
|
|
74
|
+
e.length > 0 && t.push(e);
|
|
75
|
+
}
|
|
76
|
+
return t;
|
|
77
|
+
}
|
|
78
|
+
function p(e, t) {
|
|
79
|
+
for (let n of e) try {
|
|
80
|
+
if (n.matches(t) || n.querySelector(t) !== null) return !0;
|
|
81
|
+
} catch {
|
|
82
|
+
return !1;
|
|
83
|
+
}
|
|
84
|
+
return !1;
|
|
85
|
+
}
|
|
86
|
+
//#endregion
|
|
87
|
+
export { c as domObserverPlugin };
|
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
import "../../../logger-6z_gb4rA.js";
|
|
2
|
-
import { i as e, t } from "../../../api-
|
|
2
|
+
import { i as e, t } from "../../../api-C6HQ65g9.js";
|
|
3
|
+
import { attach as n } from "effector";
|
|
3
4
|
//#region src/plugins/dynamic-experiences/hash.ts
|
|
4
|
-
function
|
|
5
|
+
function r(e) {
|
|
5
6
|
let t = 2166136261;
|
|
6
7
|
for (let n = 0; n < e.length; n++) t ^= e.charCodeAt(n), t = Math.imul(t, 16777619);
|
|
7
8
|
return t >>> 0;
|
|
8
9
|
}
|
|
9
|
-
function
|
|
10
|
-
return
|
|
10
|
+
function i(e) {
|
|
11
|
+
return r(e) % 100;
|
|
11
12
|
}
|
|
12
|
-
function
|
|
13
|
+
function a(e, t) {
|
|
13
14
|
return t <= 0 ? !1 : t >= 100 ? !0 : e < t;
|
|
14
15
|
}
|
|
15
16
|
//#endregion
|
|
16
17
|
//#region src/plugins/dynamic-experiences/plugin.ts
|
|
17
|
-
function
|
|
18
|
+
function o(e) {
|
|
18
19
|
return typeof e == "object" && !!e && "features" in e && Array.isArray(e.features);
|
|
19
20
|
}
|
|
20
|
-
function
|
|
21
|
+
function s(e, t) {
|
|
21
22
|
if (Array.isArray(t.conditions)) for (let n of t.conditions) e.registerCondition(n);
|
|
22
23
|
}
|
|
23
|
-
function
|
|
24
|
+
function c(e, t) {
|
|
24
25
|
e.registerExperience({
|
|
25
26
|
id: t.id,
|
|
26
27
|
key: t.key,
|
|
@@ -33,10 +34,10 @@ function s(e, t) {
|
|
|
33
34
|
componentName: t.componentName
|
|
34
35
|
});
|
|
35
36
|
}
|
|
36
|
-
function
|
|
37
|
+
function l(e, t) {
|
|
37
38
|
if (Array.isArray(t.fields)) for (let n of t.fields) e.registerField(n);
|
|
38
39
|
}
|
|
39
|
-
function
|
|
40
|
+
function u(e, t) {
|
|
40
41
|
if (!Array.isArray(t.steps)) return;
|
|
41
42
|
let n = new Map(t.fields.map((e) => [e.id, e.key]));
|
|
42
43
|
for (let r of t.steps) {
|
|
@@ -49,23 +50,28 @@ function l(e, t) {
|
|
|
49
50
|
}
|
|
50
51
|
t.push(i);
|
|
51
52
|
}
|
|
53
|
+
let i = r.layoutContentId ? e.contents.getById(r.layoutContentId) : null;
|
|
52
54
|
e.registerStep({
|
|
53
55
|
id: r.id,
|
|
54
56
|
key: r.key,
|
|
55
57
|
name: r.name,
|
|
56
58
|
fieldKeys: t,
|
|
57
|
-
layoutName: r.layoutName
|
|
59
|
+
layoutName: r.layoutName,
|
|
60
|
+
...r.layoutContentId !== void 0 && {
|
|
61
|
+
layoutContentId: r.layoutContentId,
|
|
62
|
+
layoutContentStore: i
|
|
63
|
+
}
|
|
58
64
|
});
|
|
59
65
|
}
|
|
60
66
|
}
|
|
61
|
-
function
|
|
62
|
-
if (Array.isArray(t.experiences)) for (let n of t.experiences)
|
|
67
|
+
function d(e, t) {
|
|
68
|
+
if (Array.isArray(t.experiences)) for (let n of t.experiences) c(e, n);
|
|
63
69
|
}
|
|
64
|
-
function
|
|
70
|
+
function f(e) {
|
|
65
71
|
let t = e.searchParams["preview-token"];
|
|
66
72
|
if (t && t.length > 0) return t[0];
|
|
67
73
|
}
|
|
68
|
-
function
|
|
74
|
+
function p(e) {
|
|
69
75
|
let t = /* @__PURE__ */ new Set(), n = e.searchParams.feature;
|
|
70
76
|
if (!n) return t;
|
|
71
77
|
for (let e of n) {
|
|
@@ -74,37 +80,18 @@ function f(e) {
|
|
|
74
80
|
}
|
|
75
81
|
return t;
|
|
76
82
|
}
|
|
77
|
-
function p(e, t, n) {
|
|
78
|
-
let i = f(e), a = e.session?.id;
|
|
79
|
-
if (!a) throw Error("Session ID is required for feature registration");
|
|
80
|
-
let o = r(a);
|
|
81
|
-
for (let r of t.features) i.has(r.id) || m(e, r, n, o);
|
|
82
|
-
}
|
|
83
83
|
function m(e, t, n, r) {
|
|
84
|
+
let a = p(e), o = i(r);
|
|
85
|
+
for (let r of t.features) a.has(r.id) || h(e, r, n, o);
|
|
86
|
+
}
|
|
87
|
+
function h(e, t, n, r) {
|
|
84
88
|
e.registerFeature(t.id, {
|
|
85
89
|
key: `v${t.version}`,
|
|
86
90
|
name: t.name,
|
|
87
91
|
storage: n ? "session" : "local",
|
|
88
|
-
decide: () => t.enabled ?
|
|
92
|
+
decide: () => t.enabled ? a(r, t.weight) : !1
|
|
89
93
|
});
|
|
90
94
|
}
|
|
91
|
-
function h() {
|
|
92
|
-
let e;
|
|
93
|
-
try {
|
|
94
|
-
e = __PICKED_PROJECT_CONFIG__;
|
|
95
|
-
} catch {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
if (e === void 0) return;
|
|
99
|
-
let t;
|
|
100
|
-
if (typeof e == "string") try {
|
|
101
|
-
t = JSON.parse(e);
|
|
102
|
-
} catch {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
else t = e;
|
|
106
|
-
if (a(t)) return t;
|
|
107
|
-
}
|
|
108
95
|
function g(e) {
|
|
109
96
|
try {
|
|
110
97
|
let t = new URL(e).hostname;
|
|
@@ -119,43 +106,129 @@ function _(e) {
|
|
|
119
106
|
return typeof t != "object" || !t || !("code" in t) ? !1 : t.code === "ECONNREFUSED";
|
|
120
107
|
}
|
|
121
108
|
async function v(e, n, r) {
|
|
122
|
-
let i = r?.previewToken ? `projects/${n}?preview_token=${encodeURIComponent(r.previewToken)}` : `projects/${n}`,
|
|
109
|
+
let i = r?.previewToken ? `projects/${n}?preview_token=${encodeURIComponent(r.previewToken)}` : `projects/${n}`, a;
|
|
123
110
|
try {
|
|
124
|
-
|
|
111
|
+
a = await t(e, i, r?.headers);
|
|
125
112
|
} catch (t) {
|
|
126
113
|
return g(e) && _(t), null;
|
|
127
114
|
}
|
|
128
|
-
if (!
|
|
115
|
+
if (!a.ok) return `${a.status.toString()}`, null;
|
|
129
116
|
let s;
|
|
130
117
|
try {
|
|
131
|
-
s = await
|
|
118
|
+
s = await a.json();
|
|
132
119
|
} catch {
|
|
133
120
|
return null;
|
|
134
121
|
}
|
|
135
|
-
return
|
|
122
|
+
return o(s) ? s : null;
|
|
136
123
|
}
|
|
137
124
|
function y(e) {
|
|
125
|
+
return typeof e != "object" || !e || !("experienceId" in e) || !("content" in e) ? !1 : Array.isArray(e.content);
|
|
126
|
+
}
|
|
127
|
+
async function b(e, n, r, i) {
|
|
128
|
+
let a = i?.previewToken ? `projects/${n}/experiences/${r}/content?preview_token=${encodeURIComponent(i.previewToken)}` : `projects/${n}/experiences/${r}/content`, o;
|
|
129
|
+
try {
|
|
130
|
+
o = await t(e, a, i?.headers);
|
|
131
|
+
} catch (t) {
|
|
132
|
+
return g(e) && _(t) || `${r}`, null;
|
|
133
|
+
}
|
|
134
|
+
if (!o.ok) return `${r}${o.status.toString()}`, null;
|
|
135
|
+
let s;
|
|
136
|
+
try {
|
|
137
|
+
s = await o.json();
|
|
138
|
+
} catch {
|
|
139
|
+
return `${r}`, null;
|
|
140
|
+
}
|
|
141
|
+
return y(s) ? s : (`${r}`, null);
|
|
142
|
+
}
|
|
143
|
+
function x(e, t) {
|
|
144
|
+
for (let n of t.content) e.registerContent({
|
|
145
|
+
id: n.id,
|
|
146
|
+
data: n.data
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
function S(e) {
|
|
150
|
+
if (typeof e != "object" || !e || !("projectConfig" in e) || !("experienceContent" in e) || !("manifestMetadata" in e)) return !1;
|
|
151
|
+
let { experienceContent: t } = e;
|
|
152
|
+
return typeof t == "function";
|
|
153
|
+
}
|
|
154
|
+
async function C() {
|
|
155
|
+
try {
|
|
156
|
+
let e = await import("virtual:picked/data");
|
|
157
|
+
return S(e) ? e : null;
|
|
158
|
+
} catch {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
function w(e, t, n) {
|
|
163
|
+
return (r) => b(e, t, r.id, n ? { previewToken: n } : void 0);
|
|
164
|
+
}
|
|
165
|
+
function T(e, t) {
|
|
166
|
+
return (n) => e(n, t ? { previewToken: t } : void 0);
|
|
167
|
+
}
|
|
168
|
+
function E(e) {
|
|
169
|
+
return (t, n) => e.experienceContent(t, n);
|
|
170
|
+
}
|
|
171
|
+
function D(e, t) {
|
|
172
|
+
let n = /* @__PURE__ */ new Map();
|
|
173
|
+
return (r, i) => {
|
|
174
|
+
let a = n.get(r.id);
|
|
175
|
+
if (a) return a;
|
|
176
|
+
let o = (async () => {
|
|
177
|
+
try {
|
|
178
|
+
let n = await t(r, i);
|
|
179
|
+
return n && x(e, n), n;
|
|
180
|
+
} finally {
|
|
181
|
+
n.delete(r.id);
|
|
182
|
+
}
|
|
183
|
+
})();
|
|
184
|
+
return n.set(r.id, o), o;
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
async function O(e) {
|
|
188
|
+
let { client: t, apiUrl: n, options: r } = e, i = f(t), a = !!i, o = r?.projectConfig ?? null, s = r?.getContent ? T(r.getContent, i) : null, c = null;
|
|
189
|
+
if (i) return o ??= await v(n, t.projectId, { previewToken: i }), s ??= w(n, t.projectId, i), {
|
|
190
|
+
config: o,
|
|
191
|
+
contentLoader: s,
|
|
192
|
+
dataSource: c,
|
|
193
|
+
isPreview: a
|
|
194
|
+
};
|
|
195
|
+
if (o && s) return {
|
|
196
|
+
config: o,
|
|
197
|
+
contentLoader: s,
|
|
198
|
+
dataSource: c,
|
|
199
|
+
isPreview: a
|
|
200
|
+
};
|
|
201
|
+
let l = await C();
|
|
202
|
+
return l ? (o ??= l.projectConfig, s ??= E(l), c = l.manifestMetadata, {
|
|
203
|
+
config: o,
|
|
204
|
+
contentLoader: s,
|
|
205
|
+
dataSource: c,
|
|
206
|
+
isPreview: a
|
|
207
|
+
}) : (o ??= await v(n, t.projectId), s ??= w(n, t.projectId), {
|
|
208
|
+
config: o,
|
|
209
|
+
contentLoader: s,
|
|
210
|
+
dataSource: c,
|
|
211
|
+
isPreview: a
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
function k(e) {
|
|
138
215
|
return {
|
|
139
216
|
name: "dynamic-experiences",
|
|
140
217
|
setup: (t) => {
|
|
141
|
-
let
|
|
142
|
-
return { onStart:
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
let
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
p(t, i, !1), o(t, i), c(t, i), l(t, i), u(t, i);
|
|
152
|
-
return;
|
|
218
|
+
let r = e?.apiUrl ?? t.apiUrl;
|
|
219
|
+
return { onStart: n({
|
|
220
|
+
source: t.session.store.map((e) => e.id),
|
|
221
|
+
effect: async (n) => {
|
|
222
|
+
let { config: i, contentLoader: a, dataSource: o, isPreview: c } = await O({
|
|
223
|
+
client: t,
|
|
224
|
+
apiUrl: r,
|
|
225
|
+
options: e
|
|
226
|
+
});
|
|
227
|
+
a && (t.contentLoader = D(t, a)), t.dataSource = o, i && (m(t, i, c, n), s(t, i), l(t, i), u(t, i), d(t, i));
|
|
153
228
|
}
|
|
154
|
-
|
|
155
|
-
a && (p(t, a, !1), o(t, a), c(t, a), l(t, a), u(t, a));
|
|
156
|
-
} };
|
|
229
|
+
}) };
|
|
157
230
|
}
|
|
158
231
|
};
|
|
159
232
|
}
|
|
160
233
|
//#endregion
|
|
161
|
-
export { e as createClientHeaders,
|
|
234
|
+
export { e as createClientHeaders, k as dynamicExperiencesPlugin, b as fetchExperienceContent, v as fetchProject };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "../../../logger-6z_gb4rA.js";
|
|
2
2
|
import { d as e } from "../../../supports-0XIfd4-R.js";
|
|
3
|
-
import { n as t, r as n, t as r } from "../../../storage-
|
|
3
|
+
import { n as t, r as n, t as r } from "../../../storage-hOHCCXvP.js";
|
|
4
4
|
import { createEffect as i, sample as a } from "effector";
|
|
5
5
|
//#region src/plugins/experience-browser-storage/plugin.ts
|
|
6
6
|
var o = ({ storage: o = "local" } = {}) => ({
|
|
@@ -10,7 +10,7 @@ var o = ({ storage: o = "local" } = {}) => ({
|
|
|
10
10
|
let c = o === "local" ? t : n, l = i(async (e) => {
|
|
11
11
|
if (!e) return;
|
|
12
12
|
let t = r("open-close", "experience", e), n = c.get(t).boolean();
|
|
13
|
-
|
|
13
|
+
n !== null && e.setOpen(n);
|
|
14
14
|
});
|
|
15
15
|
a({
|
|
16
16
|
source: s.eventBus,
|
|
@@ -18,12 +18,15 @@ var o = ({ storage: o = "local" } = {}) => ({
|
|
|
18
18
|
fn: (e) => e.experience,
|
|
19
19
|
target: l
|
|
20
20
|
});
|
|
21
|
-
let u = i(async (e) => {
|
|
22
|
-
let
|
|
23
|
-
c.set(
|
|
21
|
+
let u = i(async ({ experience: e, isOpen: t }) => {
|
|
22
|
+
let n = r("open-close", "experience", e);
|
|
23
|
+
c.set(n, t);
|
|
24
24
|
}), d = (e) => a({
|
|
25
25
|
source: e.isOpenStore,
|
|
26
|
-
fn: () =>
|
|
26
|
+
fn: (t) => ({
|
|
27
|
+
experience: e,
|
|
28
|
+
isOpen: t
|
|
29
|
+
}),
|
|
27
30
|
target: u
|
|
28
31
|
});
|
|
29
32
|
s.experienceInstances.listStore.watch((e) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { d as e } from "../../../supports-0XIfd4-R.js";
|
|
2
|
-
import { n as t, r as n, t as r } from "../../../storage-
|
|
2
|
+
import { n as t, r as n, t as r } from "../../../storage-hOHCCXvP.js";
|
|
3
3
|
import { createEffect as i, sample as a } from "effector";
|
|
4
4
|
//#region src/plugins/history-browser-storage/plugin.ts
|
|
5
5
|
var o = r("history", "global"), s = ({ storage: r = "local" } = {}) => ({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { d as e } from "../../../supports-0XIfd4-R.js";
|
|
2
|
-
import { n as t, r as n, t as r } from "../../../storage-
|
|
2
|
+
import { n as t, r as n, t as r } from "../../../storage-hOHCCXvP.js";
|
|
3
3
|
import { attach as i, createEffect as a, sample as o } from "effector";
|
|
4
4
|
//#region src/plugins/responses-browser-storage/plugin.ts
|
|
5
5
|
var s = r("responses", "global");
|
|
@@ -9,7 +9,7 @@ var n = () => ({
|
|
|
9
9
|
class i extends HTMLElement {
|
|
10
10
|
connectedCallback() {
|
|
11
11
|
let e = this.getAttribute("experience-id");
|
|
12
|
-
n.
|
|
12
|
+
n.readyStore.getState() && e && n.experiences.launch({ id: e });
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
window.customElements.define(r, i);
|
package/dist/esm/server/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as e } from "../../experience-instance-
|
|
1
|
+
import { t as e } from "../../experience-instance-DImym3m_.js";
|
|
2
2
|
import { attach as t, createEffect as n, createEvent as r, createStore as i, sample as a } from "effector";
|
|
3
3
|
//#region src/server/index.ts
|
|
4
4
|
function o() {
|
|
@@ -19,17 +19,27 @@ function s(s, c) {
|
|
|
19
19
|
currentExperienceIndex: 0,
|
|
20
20
|
renderedExperiences: [],
|
|
21
21
|
isComplete: !1
|
|
22
|
-
}), v = n(async (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
}), v = n(async (e) => {
|
|
23
|
+
let n = t({
|
|
24
|
+
source: e.experience.componentStore,
|
|
25
|
+
effect: async (t, n) => {
|
|
26
|
+
let r = e.availableRenderers[n];
|
|
27
|
+
return t && r?.isValidComponent(t.component) ? {
|
|
28
|
+
rendered: await r.render(t.component, s, e.experience),
|
|
29
|
+
rendererIndex: n
|
|
30
|
+
} : null;
|
|
31
|
+
}
|
|
32
|
+
}), r = e.startRendererIndex ?? 0;
|
|
33
|
+
for (let t = r; t < e.availableRenderers.length; t++) {
|
|
34
|
+
let e = await n(t);
|
|
35
|
+
if (e) return e;
|
|
30
36
|
}
|
|
31
37
|
return null;
|
|
32
|
-
})
|
|
38
|
+
}), y = n(async ({ experience: e, availableRenderers: t, startRendererIndex: n = 0 }) => e ? v({
|
|
39
|
+
experience: e,
|
|
40
|
+
availableRenderers: t,
|
|
41
|
+
startRendererIndex: n
|
|
42
|
+
}) : null);
|
|
33
43
|
return _.on(p, (e, t) => ({
|
|
34
44
|
...e,
|
|
35
45
|
renderedExperiences: [...e.renderedExperiences, t],
|
|
@@ -55,9 +65,9 @@ function s(s, c) {
|
|
|
55
65
|
availableRenderers: c,
|
|
56
66
|
startRendererIndex: 0
|
|
57
67
|
}),
|
|
58
|
-
target:
|
|
68
|
+
target: y
|
|
59
69
|
}), a({
|
|
60
|
-
clock:
|
|
70
|
+
clock: y.doneData,
|
|
61
71
|
filter: (e) => e !== null,
|
|
62
72
|
fn: (e) => e.rendered.body,
|
|
63
73
|
target: p
|
|
@@ -65,7 +75,7 @@ function s(s, c) {
|
|
|
65
75
|
clock: p,
|
|
66
76
|
target: f
|
|
67
77
|
}), a({
|
|
68
|
-
clock:
|
|
78
|
+
clock: y.doneData,
|
|
69
79
|
filter: (e) => e === null,
|
|
70
80
|
target: h
|
|
71
81
|
}), a({
|