@picked/client 0.0.1-dev.1772073931707 → 0.0.1-dev.1772085077346
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/api-CbXfbi_s.js +19 -0
- package/dist/api-DzSCgBQ2.cjs +1 -0
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/create-experience/index.js +1 -1
- package/dist/cjs/plugins/dynamic-experiences/index.js +1 -0
- package/dist/cjs/server/index.js +1 -1
- package/dist/esm/index.js +552 -630
- package/dist/esm/plugins/create-experience/index.js +228 -194
- package/dist/esm/plugins/dynamic-experiences/index.js +115 -0
- package/dist/esm/server/index.js +1 -1
- package/dist/experience-instance-CU_pYPyd.js +820 -0
- package/dist/experience-instance-D_Mwuzb4.cjs +1 -0
- package/dist/types/client.d.ts +10 -12
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/entities/action/action.d.ts +2 -5
- package/dist/types/entities/action/action.d.ts.map +1 -1
- package/dist/types/entities/component/component.d.ts +2 -1
- package/dist/types/entities/component/component.d.ts.map +1 -1
- package/dist/types/entities/component/lazyComponent.d.ts +11 -0
- package/dist/types/entities/component/lazyComponent.d.ts.map +1 -0
- package/dist/types/entities/experience/experience.d.ts +6 -6
- package/dist/types/entities/experience/experience.d.ts.map +1 -1
- package/dist/types/entities/experience-instance/experience-instance.d.ts +4 -3
- package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
- package/dist/types/entities/field/field.d.ts +14 -51
- package/dist/types/entities/field/field.d.ts.map +1 -1
- package/dist/types/entities/plugin/plugin.d.ts +4 -1
- package/dist/types/entities/plugin/plugin.d.ts.map +1 -1
- 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/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/picked.d.ts +17 -17
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/ping.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/create-experience.d.ts +23 -26
- package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/hash.d.ts +18 -0
- package/dist/types/plugins/dynamic-experiences/hash.d.ts.map +1 -0
- package/dist/types/plugins/dynamic-experiences/index.d.ts +3 -0
- package/dist/types/plugins/dynamic-experiences/index.d.ts.map +1 -0
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts +23 -0
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -0
- package/dist/types/plugins/dynamic-experiences/types.d.ts +15 -0
- package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -0
- package/dist/types/utils/api.d.ts +3 -0
- package/dist/types/utils/api.d.ts.map +1 -0
- package/dist/types/utils/get-step-fields.d.ts +1 -2
- package/dist/types/utils/get-step-fields.d.ts.map +1 -1
- package/dist/types/utils/rules-logic.d.ts.map +1 -1
- package/package.json +7 -1
- package/dist/experience-instance-5rr_D--s.cjs +0 -1
- package/dist/experience-instance-CLR80xop.js +0 -819
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { g as l } from "../../../api-CbXfbi_s.js";
|
|
2
|
+
import { l as a } from "../../../logger-C9a75KZn.js";
|
|
3
|
+
function d(e) {
|
|
4
|
+
let r = 2166136261;
|
|
5
|
+
for (let n = 0; n < e.length; n++)
|
|
6
|
+
r ^= e.charCodeAt(n), r = Math.imul(r, 16777619);
|
|
7
|
+
return r >>> 0;
|
|
8
|
+
}
|
|
9
|
+
function p(e) {
|
|
10
|
+
return d(e) % 100;
|
|
11
|
+
}
|
|
12
|
+
function g(e, r) {
|
|
13
|
+
return r <= 0 ? !1 : r >= 100 ? !0 : e < r;
|
|
14
|
+
}
|
|
15
|
+
function m(e) {
|
|
16
|
+
return typeof e != "object" || e === null || !("id" in e && "name" in e && "enabled" in e && "weight" in e && "version" in e) ? !1 : typeof e.id == "string" && typeof e.name == "string" && typeof e.enabled == "boolean" && typeof e.weight == "number" && typeof e.version == "number";
|
|
17
|
+
}
|
|
18
|
+
function c(e) {
|
|
19
|
+
return typeof e != "object" || e === null || !("features" in e) || !Array.isArray(e.features) ? !1 : e.features.every(m);
|
|
20
|
+
}
|
|
21
|
+
function _(e) {
|
|
22
|
+
const r = e.searchParams["preview-token"];
|
|
23
|
+
if (r && r.length > 0)
|
|
24
|
+
return r[0];
|
|
25
|
+
}
|
|
26
|
+
function h(e) {
|
|
27
|
+
const r = /* @__PURE__ */ new Set(), n = e.searchParams.feature;
|
|
28
|
+
if (!n)
|
|
29
|
+
return r;
|
|
30
|
+
for (const i of n) {
|
|
31
|
+
const t = i.indexOf(":");
|
|
32
|
+
t > 0 && r.add(i.substring(0, t));
|
|
33
|
+
}
|
|
34
|
+
return r;
|
|
35
|
+
}
|
|
36
|
+
function u(e, r, n) {
|
|
37
|
+
const i = h(e), t = e.session?.id;
|
|
38
|
+
if (!t)
|
|
39
|
+
throw new Error("Session ID is required for feature registration");
|
|
40
|
+
const o = p(t);
|
|
41
|
+
for (const s of r.features)
|
|
42
|
+
i.has(s.id) || y(e, s, n, o);
|
|
43
|
+
}
|
|
44
|
+
function y(e, r, n, i) {
|
|
45
|
+
e.registerFeature(r.id, {
|
|
46
|
+
key: `v${r.version}`,
|
|
47
|
+
name: r.name,
|
|
48
|
+
storage: n ? "session" : "local",
|
|
49
|
+
decide: () => r.enabled ? g(i, r.weight) : !1
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function C() {
|
|
53
|
+
if (typeof __PICKED_PROJECT_CONFIG__ > "u")
|
|
54
|
+
return;
|
|
55
|
+
let e;
|
|
56
|
+
if (typeof __PICKED_PROJECT_CONFIG__ == "string")
|
|
57
|
+
try {
|
|
58
|
+
e = JSON.parse(__PICKED_PROJECT_CONFIG__);
|
|
59
|
+
} catch {
|
|
60
|
+
a("warn", "Build-time project config is not valid JSON");
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
else
|
|
64
|
+
e = __PICKED_PROJECT_CONFIG__;
|
|
65
|
+
if (c(e))
|
|
66
|
+
return e;
|
|
67
|
+
a("warn", "Build-time project config has invalid shape, falling back to runtime fetch");
|
|
68
|
+
}
|
|
69
|
+
async function f(e, r, n) {
|
|
70
|
+
const i = n ? `projects/${r}?preview_token=${encodeURIComponent(n)}` : `projects/${r}`;
|
|
71
|
+
let t;
|
|
72
|
+
try {
|
|
73
|
+
t = await l(e, i);
|
|
74
|
+
} catch (s) {
|
|
75
|
+
return a("warn", "Failed to fetch project config", s), null;
|
|
76
|
+
}
|
|
77
|
+
if (!t.ok)
|
|
78
|
+
return a("warn", `Project config request failed with status ${t.status.toString()}`), null;
|
|
79
|
+
let o;
|
|
80
|
+
try {
|
|
81
|
+
o = await t.json();
|
|
82
|
+
} catch {
|
|
83
|
+
return a("warn", "Failed to parse project config response"), null;
|
|
84
|
+
}
|
|
85
|
+
return c(o) ? o : (a("warn", "Invalid project config response shape"), null);
|
|
86
|
+
}
|
|
87
|
+
function v(e) {
|
|
88
|
+
return {
|
|
89
|
+
name: "dynamic-experiences",
|
|
90
|
+
setup: (r) => {
|
|
91
|
+
const n = e?.apiUrl ?? r.apiUrl;
|
|
92
|
+
return {
|
|
93
|
+
onStart: async () => {
|
|
94
|
+
const i = _(r);
|
|
95
|
+
if (i) {
|
|
96
|
+
const s = await f(n, r.projectId, i);
|
|
97
|
+
s && u(r, s, !0);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const t = e?.projectConfig ?? C();
|
|
101
|
+
if (t) {
|
|
102
|
+
u(r, t, !1);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const o = await f(n, r.projectId);
|
|
106
|
+
o && u(r, o, !1);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
export {
|
|
113
|
+
v as dynamicExperiencesPlugin,
|
|
114
|
+
f as fetchProject
|
|
115
|
+
};
|
package/dist/esm/server/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createEvent as i, createStore as v, createEffect as C, sample as n, attach as S } from "effector";
|
|
2
|
-
import { h as F } from "../../experience-instance-
|
|
2
|
+
import { h as F } from "../../experience-instance-CU_pYPyd.js";
|
|
3
3
|
function R() {
|
|
4
4
|
let c, p;
|
|
5
5
|
return {
|