@picked/client 0.0.1-dev.1771973228237 → 0.0.1-dev.1772057362040

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