@picked/client 0.0.1-dev.1762985685249 → 0.0.1-dev.1763077817547
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/cjs/index.js +1 -1
- package/dist/cjs/plugins/shopify/index.js +1 -1
- package/dist/esm/index.js +150 -754
- package/dist/esm/plugins/shopify/index.js +89 -36
- package/dist/esm/plugins/single-page-app/index.js +3 -3
- package/dist/esm/plugins/web-components/index.js +1 -1
- package/dist/esm/plugins/window-object/index.js +1 -1
- package/dist/esm/server/index.js +7 -7
- package/dist/{experience-instance-QtGs0N3g.js → experience-instance-CeuHLrdL.js} +7 -7
- package/dist/{supports-BjhuLJ8z.js → supports-DBMT17KZ.js} +10 -10
- package/dist/types/entities/feature/feature.d.ts.map +1 -1
- package/dist/types/plugins/shopify/global-obj.d.ts +49 -0
- package/dist/types/plugins/shopify/global-obj.d.ts.map +1 -0
- package/dist/types/plugins/shopify/index.d.ts +4 -0
- package/dist/types/plugins/shopify/index.d.ts.map +1 -1
- package/dist/types/plugins/shopify/picked-config.d.ts +103 -0
- package/dist/types/plugins/shopify/picked-config.d.ts.map +1 -0
- package/dist/types/plugins/shopify/{shopify.d.ts → predicates.d.ts} +20 -6
- package/dist/types/plugins/shopify/predicates.d.ts.map +1 -0
- package/dist/user-session-Bny5aSWK.cjs +1 -0
- package/dist/user-session-sUXlj29_.js +637 -0
- package/package.json +1 -1
- package/dist/types/plugins/shopify/shopify.d.ts.map +0 -1
- package/dist/types/plugins/shopify/utils.d.ts +0 -21
- package/dist/types/plugins/shopify/utils.d.ts.map +0 -1
|
@@ -1,8 +1,37 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
|
|
1
|
+
import { a as r } from "../../../supports-DBMT17KZ.js";
|
|
2
|
+
import "../../../user-session-sUXlj29_.js";
|
|
3
|
+
import "../../../experience-instance-CeuHLrdL.js";
|
|
4
|
+
import "effector";
|
|
5
|
+
function c() {
|
|
6
|
+
if (!r() || !window.pickedConfig)
|
|
7
|
+
throw new Error(
|
|
8
|
+
"Picked config not found. Ensure the Picked Script is enabled on your Shopify storefront"
|
|
9
|
+
);
|
|
10
|
+
return window.pickedConfig;
|
|
11
|
+
}
|
|
12
|
+
function w() {
|
|
13
|
+
if (r())
|
|
14
|
+
return c().customer;
|
|
15
|
+
}
|
|
16
|
+
function s() {
|
|
17
|
+
if (r())
|
|
18
|
+
return c().product;
|
|
19
|
+
}
|
|
20
|
+
function u() {
|
|
21
|
+
if (r())
|
|
22
|
+
return c().collection;
|
|
23
|
+
}
|
|
24
|
+
function k() {
|
|
25
|
+
if (r())
|
|
26
|
+
return c().experiments;
|
|
27
|
+
}
|
|
28
|
+
function P() {
|
|
29
|
+
var e;
|
|
30
|
+
if (r())
|
|
31
|
+
return (e = c().storefront_api) == null ? void 0 : e.token;
|
|
32
|
+
}
|
|
33
|
+
const t = {
|
|
3
34
|
homepage: /^\/$/,
|
|
4
|
-
productPage: /(?:^|\/)products\/(?<productHandle>[^/]+)\/?$/,
|
|
5
|
-
collection: /^\/collections\/[^/]+\/?$/,
|
|
6
35
|
page: /(?:^|\/)pages\/[^/]+$/,
|
|
7
36
|
blog: /(?:^|\/)blogs\/(?<blogHandle>[^/]+)\/?$/,
|
|
8
37
|
article: /^\/blogs\/[^/]+\/(?<article>[^/]+)\/?$/,
|
|
@@ -12,58 +41,82 @@ const a = {
|
|
|
12
41
|
accountWildcard: /^\/account\/.+/,
|
|
13
42
|
accountLogin: /^\/account\/login(?:\/|$)/,
|
|
14
43
|
accountRegister: /^\/account\/register(?:\/|$)/
|
|
15
|
-
}, n =
|
|
44
|
+
}, n = (e, o) => o ? !!e.exec(o.pathname) : !1, a = (e, o) => {
|
|
16
45
|
if (o) {
|
|
17
|
-
const
|
|
18
|
-
if (
|
|
19
|
-
return
|
|
46
|
+
const i = e.exec(o.pathname);
|
|
47
|
+
if (i)
|
|
48
|
+
return i[1];
|
|
20
49
|
}
|
|
21
|
-
},
|
|
50
|
+
}, p = (e) => {
|
|
51
|
+
var o, i;
|
|
52
|
+
switch (e) {
|
|
53
|
+
case "product":
|
|
54
|
+
return ((o = s()) == null ? void 0 : o.handle) ?? !1;
|
|
55
|
+
case "collection":
|
|
56
|
+
return ((i = u()) == null ? void 0 : i.handle) ?? !1;
|
|
57
|
+
default:
|
|
58
|
+
return !1;
|
|
59
|
+
}
|
|
60
|
+
}, g = {
|
|
22
61
|
// Pages
|
|
23
|
-
"is-page": ({ location: e }) => t
|
|
24
|
-
"get-page-handle": ({ location: e }) =>
|
|
62
|
+
"is-page": ({ location: e }) => n(t.page, e),
|
|
63
|
+
"get-page-handle": ({ location: e }) => a(t.page, e),
|
|
25
64
|
// Products
|
|
26
|
-
"is-product-page": (
|
|
27
|
-
"get-product-handle": (
|
|
65
|
+
"is-product-page": () => !!p("product"),
|
|
66
|
+
"get-product-handle": () => p("product"),
|
|
28
67
|
// Collections
|
|
29
|
-
"is-collection-page": (
|
|
30
|
-
"get-collection-handle": (
|
|
68
|
+
"is-collection-page": () => !!p("collection"),
|
|
69
|
+
"get-collection-handle": () => p("collection"),
|
|
31
70
|
// Blogs
|
|
32
|
-
"is-blog-page": ({ location: e }) => t
|
|
33
|
-
"get-blog-handle": ({ location: e }) =>
|
|
71
|
+
"is-blog-page": ({ location: e }) => n(t.blog, e),
|
|
72
|
+
"get-blog-handle": ({ location: e }) => a(t.blog, e),
|
|
34
73
|
// Blog Articles
|
|
35
|
-
"is-article-page": ({ location: e }) => t
|
|
36
|
-
"get-article-handle": ({ location: e }) =>
|
|
74
|
+
"is-article-page": ({ location: e }) => n(t.article, e),
|
|
75
|
+
"get-article-handle": ({ location: e }) => a(t.article, e),
|
|
37
76
|
// Apps
|
|
38
|
-
"is-app-proxy-page": ({ location: e }) => t
|
|
39
|
-
"get-app-proxy-handle": ({ location: e }) =>
|
|
77
|
+
"is-app-proxy-page": ({ location: e }) => n(t.appProxy, e),
|
|
78
|
+
"get-app-proxy-handle": ({ location: e }) => a(t.appProxy, e),
|
|
40
79
|
// Account
|
|
41
|
-
"is-account-page": ({ location: e }) => t
|
|
42
|
-
"is-login-page": ({ location: e }) => t
|
|
43
|
-
"is-register-page": ({ location: e }) => t
|
|
80
|
+
"is-account-page": ({ location: e }) => n(t.accountWildcard, e),
|
|
81
|
+
"is-login-page": ({ location: e }) => n(t.accountLogin, e),
|
|
82
|
+
"is-register-page": ({ location: e }) => n(t.accountRegister, e),
|
|
44
83
|
// Cart
|
|
45
|
-
"is-cart-page": ({ location: e }) => t
|
|
84
|
+
"is-cart-page": ({ location: e }) => n(t.cart, e),
|
|
46
85
|
// Checkout
|
|
47
|
-
"is-checkout-page": ({ location: e }) => t
|
|
86
|
+
"is-checkout-page": ({ location: e }) => n(t.checkout, e),
|
|
48
87
|
// Homepage
|
|
49
|
-
"is-homepage": ({ location: e }) => t
|
|
88
|
+
"is-homepage": ({ location: e }) => n(t.homepage, e)
|
|
50
89
|
};
|
|
51
|
-
function
|
|
52
|
-
|
|
53
|
-
|
|
90
|
+
function l() {
|
|
91
|
+
if (!r() || !window.Shopify)
|
|
92
|
+
throw new Error(
|
|
93
|
+
"Shopify global object not found. This plugin must be used on a Shopify storefront page."
|
|
94
|
+
);
|
|
95
|
+
return window.Shopify;
|
|
96
|
+
}
|
|
97
|
+
function f(e) {
|
|
98
|
+
var o, i;
|
|
99
|
+
return typeof ((i = (o = l()) == null ? void 0 : o.analytics) == null ? void 0 : i.publish) == "function";
|
|
54
100
|
}
|
|
55
|
-
const
|
|
101
|
+
const b = () => ({
|
|
56
102
|
name: "shopify",
|
|
57
103
|
setup: (e) => {
|
|
58
|
-
Object.entries(
|
|
59
|
-
e.registerPredicate(`shopify-${o}`,
|
|
60
|
-
}),
|
|
61
|
-
|
|
104
|
+
Object.entries(g).forEach(([o, i]) => {
|
|
105
|
+
e.registerPredicate(`shopify-${o}`, i);
|
|
106
|
+
}), r() && e.eventBus.watch((o) => {
|
|
107
|
+
f() && o.type === "session" && window.Shopify.analytics.publish("picked:session", {
|
|
62
108
|
id: o.id
|
|
63
109
|
});
|
|
64
110
|
});
|
|
65
111
|
}
|
|
66
112
|
});
|
|
67
113
|
export {
|
|
68
|
-
|
|
114
|
+
c as getPickedConfig,
|
|
115
|
+
u as getPickedConfigCollection,
|
|
116
|
+
w as getPickedConfigCustomer,
|
|
117
|
+
k as getPickedConfigExperiments,
|
|
118
|
+
s as getPickedConfigProduct,
|
|
119
|
+
P as getPickedConfigStorefrontApiToken,
|
|
120
|
+
l as getShopify,
|
|
121
|
+
b as shopifyPlugin
|
|
69
122
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as f, G as c,
|
|
1
|
+
import { a as f, G as c, d as m } from "../../../supports-DBMT17KZ.js";
|
|
2
2
|
import { p as a } from "../../../object-JwZ58NOH.js";
|
|
3
3
|
const o = c;
|
|
4
4
|
let s;
|
|
5
|
-
const
|
|
5
|
+
const y = (r) => ({
|
|
6
6
|
name: "single-page-app",
|
|
7
7
|
setup: (n) => {
|
|
8
8
|
r.instrumentHistory && f() && h(() => {
|
|
@@ -33,5 +33,5 @@ function h(r) {
|
|
|
33
33
|
a(o.history, "pushState", n), a(o.history, "replaceState", n);
|
|
34
34
|
}
|
|
35
35
|
export {
|
|
36
|
-
|
|
36
|
+
y as singlePageAppPlugin
|
|
37
37
|
};
|
package/dist/esm/server/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createEvent as i, createStore as
|
|
2
|
-
import {
|
|
1
|
+
import { createEvent as i, createStore as C, createEffect as S, sample as n, attach as h } from "effector";
|
|
2
|
+
import { a as F } from "../../experience-instance-CeuHLrdL.js";
|
|
3
3
|
function R() {
|
|
4
4
|
let c, p;
|
|
5
5
|
return {
|
|
@@ -11,19 +11,19 @@ function R() {
|
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
function w(c, p) {
|
|
14
|
-
const { promise: g, resolve: t } = R(), o = i(), s = i(), l = i(), m = i(), d = i(), I = c.experiences.listStore.map((e) => e.map((r) => F({ client: c, experience: r }))), x =
|
|
14
|
+
const { promise: g, resolve: t } = R(), o = i(), s = i(), l = i(), m = i(), d = i(), I = c.experiences.listStore.map((e) => e.map((r) => F({ client: c, experience: r }))), x = C({
|
|
15
15
|
currentExperienceIndex: 0,
|
|
16
16
|
renderedExperiences: [],
|
|
17
17
|
isComplete: !1
|
|
18
|
-
}), f =
|
|
18
|
+
}), f = S(
|
|
19
19
|
async ({
|
|
20
20
|
experience: e,
|
|
21
21
|
availableRenderers: r,
|
|
22
|
-
startRendererIndex:
|
|
22
|
+
startRendererIndex: v = 0
|
|
23
23
|
}) => {
|
|
24
24
|
if (!e)
|
|
25
25
|
return null;
|
|
26
|
-
for (let a =
|
|
26
|
+
for (let a = v; a < r.length; a++) {
|
|
27
27
|
const u = r[a], E = e.componentStore.getState();
|
|
28
28
|
if (E && (u != null && u.isValidComponent(E.component)))
|
|
29
29
|
return { rendered: await u.render(E.component, c, e), rendererIndex: a };
|
|
@@ -75,7 +75,7 @@ function w(c, p) {
|
|
|
75
75
|
filter: ({ experiences: e, state: r }) => r.currentExperienceIndex >= e.length,
|
|
76
76
|
target: m
|
|
77
77
|
});
|
|
78
|
-
const k =
|
|
78
|
+
const k = h({
|
|
79
79
|
source: x,
|
|
80
80
|
effect: (e) => {
|
|
81
81
|
e.isComplete && t(e.renderedExperiences);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createDomain as ht, createEvent as B, combine as C, createApi as ot, createEffect as M, attach as F, split as yt, sample as m } from "effector";
|
|
2
2
|
import { createFactory as it, invoke as st } from "@withease/factories";
|
|
3
|
-
import {
|
|
3
|
+
import { h as wt, s as at, a as Nt } from "./supports-DBMT17KZ.js";
|
|
4
4
|
import { l as I } from "./logger-C9a75KZn.js";
|
|
5
5
|
import { i as It } from "./object-JwZ58NOH.js";
|
|
6
6
|
function xt(t) {
|
|
@@ -768,14 +768,14 @@ function Yt(t) {
|
|
|
768
768
|
return st(Gt, t);
|
|
769
769
|
}
|
|
770
770
|
export {
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
771
|
+
jt as a,
|
|
772
|
+
Jt as b,
|
|
773
|
+
Yt as c,
|
|
774
774
|
Xt as d,
|
|
775
775
|
et as e,
|
|
776
|
-
|
|
776
|
+
At as f,
|
|
777
777
|
zt as g,
|
|
778
|
-
|
|
779
|
-
|
|
778
|
+
j as h,
|
|
779
|
+
Ot as i,
|
|
780
780
|
Qt as t
|
|
781
781
|
};
|
|
@@ -81,15 +81,15 @@ function h() {
|
|
|
81
81
|
export {
|
|
82
82
|
t as G,
|
|
83
83
|
l as a,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
e,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
i,
|
|
92
|
-
|
|
93
|
-
|
|
84
|
+
r as b,
|
|
85
|
+
e as c,
|
|
86
|
+
s as d,
|
|
87
|
+
a as e,
|
|
88
|
+
c as f,
|
|
89
|
+
u as g,
|
|
90
|
+
i as h,
|
|
91
|
+
f as i,
|
|
92
|
+
y as j,
|
|
93
|
+
h as k,
|
|
94
94
|
p as s
|
|
95
95
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature.d.ts","sourceRoot":"","sources":["../../../../src/entities/feature/feature.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAI1C,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IACnE,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAC9B;AAED,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAEjE,MAAM,WAAW,gBAAgB;IAC/B,EAAE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AAC,SAAS,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC,CAAC,CAAC,EAC1F,MAAM,EAAE,CAAC,GACR,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAE9C;AAED,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,EAAE,SAAS,OAAO,EAAE,UAAU,aAAa,SAEnF,CAAA"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
interface EventPayload {
|
|
2
|
+
[key: string]: string | number | boolean | null | undefined | EventPayload | Array<string | number | boolean | null | undefined | EventPayload>;
|
|
3
|
+
}
|
|
4
|
+
export interface Shopify {
|
|
5
|
+
shop: string;
|
|
6
|
+
locale: string;
|
|
7
|
+
currency: {
|
|
8
|
+
active: string;
|
|
9
|
+
rate: string;
|
|
10
|
+
};
|
|
11
|
+
country: string;
|
|
12
|
+
theme: {
|
|
13
|
+
name: string;
|
|
14
|
+
id: number;
|
|
15
|
+
schema_name: string;
|
|
16
|
+
schema_version: string;
|
|
17
|
+
theme_store_id: number | null;
|
|
18
|
+
role: string;
|
|
19
|
+
handle: string;
|
|
20
|
+
style: {
|
|
21
|
+
id: number | null;
|
|
22
|
+
handle: string | null;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
routes: {
|
|
26
|
+
root: string;
|
|
27
|
+
};
|
|
28
|
+
PaymentButton: {
|
|
29
|
+
isStorefrontPortableWallets: boolean;
|
|
30
|
+
};
|
|
31
|
+
analytics?: {
|
|
32
|
+
publish?: (event: string, payload: EventPayload) => void;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
declare global {
|
|
36
|
+
interface Window {
|
|
37
|
+
Shopify?: Shopify;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export declare function getShopify(): Shopify;
|
|
41
|
+
export declare function supportsShopifyAnalytics(w: Window): w is Window & {
|
|
42
|
+
Shopify: {
|
|
43
|
+
analytics: {
|
|
44
|
+
publish: (event: string, payload: EventPayload) => void;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export {};
|
|
49
|
+
//# sourceMappingURL=global-obj.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global-obj.d.ts","sourceRoot":"","sources":["../../../../src/plugins/shopify/global-obj.ts"],"names":[],"mappings":"AAEA,UAAU,YAAY;IACpB,CAAC,GAAG,EAAE,MAAM,GACR,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,GACT,YAAY,GACZ,KAAK,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,YAAY,CAAC,CAAA;CACvE;AAED,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE;QACR,MAAM,EAAE,MAAM,CAAA;QACd,IAAI,EAAE,MAAM,CAAA;KACb,CAAA;IACD,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAA;QACZ,EAAE,EAAE,MAAM,CAAA;QACV,WAAW,EAAE,MAAM,CAAA;QACnB,cAAc,EAAE,MAAM,CAAA;QACtB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;QAC7B,IAAI,EAAE,MAAM,CAAA;QACZ,MAAM,EAAE,MAAM,CAAA;QACd,KAAK,EAAE;YACL,EAAE,EAAE,MAAM,GAAG,IAAI,CAAA;YACjB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;SACtB,CAAA;KACF,CAAA;IACD,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAA;KACb,CAAA;IACD,aAAa,EAAE;QACb,2BAA2B,EAAE,OAAO,CAAA;KACrC,CAAA;IACD,SAAS,CAAC,EAAE;QACV,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,KAAK,IAAI,CAAA;KACzD,CAAA;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,OAAO,CAAC,EAAE,OAAO,CAAA;KAClB;CACF;AAED,wBAAgB,UAAU,YAQzB;AAED,wBAAgB,wBAAwB,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,IAAI,MAAM,GAAG;IACjE,OAAO,EAAE;QAAE,SAAS,EAAE;YAAE,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,KAAK,IAAI,CAAA;SAAE,CAAA;KAAE,CAAA;CACpF,CAEA"}
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
export { shopifyPlugin } from './plugin';
|
|
2
|
+
export { getPickedConfig, getPickedConfigCollection, getPickedConfigCustomer, getPickedConfigExperiments, getPickedConfigProduct, getPickedConfigStorefrontApiToken, } from './picked-config';
|
|
3
|
+
export type * from './picked-config';
|
|
4
|
+
export { getShopify } from './global-obj';
|
|
5
|
+
export type * from './global-obj';
|
|
2
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/shopify/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/shopify/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAGxC,OAAO,EACL,eAAe,EACf,yBAAyB,EACzB,uBAAuB,EACvB,0BAA0B,EAC1B,sBAAsB,EACtB,iCAAiC,GAClC,MAAM,iBAAiB,CAAA;AACxB,mBAAmB,iBAAiB,CAAA;AAGpC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,mBAAmB,cAAc,CAAA"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { CreateClientOptions } from '../../index';
|
|
2
|
+
export interface PickedConfigExperiment {
|
|
3
|
+
enabled: boolean;
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
version: number;
|
|
7
|
+
weight: number;
|
|
8
|
+
}
|
|
9
|
+
export type PickedConfigCollection = Partial<{
|
|
10
|
+
title: string;
|
|
11
|
+
id: number;
|
|
12
|
+
handle: string;
|
|
13
|
+
}>;
|
|
14
|
+
export type PickedConfigProductVariant = Partial<{
|
|
15
|
+
available: boolean;
|
|
16
|
+
title: string;
|
|
17
|
+
id: number;
|
|
18
|
+
price: number;
|
|
19
|
+
inventory_quantity: number;
|
|
20
|
+
option1: string;
|
|
21
|
+
}>;
|
|
22
|
+
export type PickedConfigProductCollection = Partial<{
|
|
23
|
+
id: number;
|
|
24
|
+
}>;
|
|
25
|
+
export type MetafieldValue = string | number | boolean | null | undefined;
|
|
26
|
+
export interface MetafieldObject {
|
|
27
|
+
[key: string]: MetafieldValue | MetafieldObject | MetafieldValue[] | MetafieldObject[];
|
|
28
|
+
}
|
|
29
|
+
export type PickedConfigProduct = Partial<{
|
|
30
|
+
available: boolean;
|
|
31
|
+
collections: PickedConfigProductCollection[];
|
|
32
|
+
featured_image: string;
|
|
33
|
+
handle: string;
|
|
34
|
+
id: number;
|
|
35
|
+
metafields: MetafieldObject;
|
|
36
|
+
price: number;
|
|
37
|
+
tags: string[];
|
|
38
|
+
title: string;
|
|
39
|
+
type: string;
|
|
40
|
+
url: string;
|
|
41
|
+
variants: PickedConfigProductVariant[];
|
|
42
|
+
vendor: string;
|
|
43
|
+
}>;
|
|
44
|
+
export type PickedConfigCustomer = Partial<{
|
|
45
|
+
accepts_marketing: boolean;
|
|
46
|
+
email: string;
|
|
47
|
+
first_name: string | null;
|
|
48
|
+
has_account: boolean;
|
|
49
|
+
id: number;
|
|
50
|
+
last_name: string | null;
|
|
51
|
+
orders_count: number;
|
|
52
|
+
phone: string | null;
|
|
53
|
+
tax_exempt: boolean;
|
|
54
|
+
}>;
|
|
55
|
+
export interface ShopifyPickedConfig {
|
|
56
|
+
customer?: PickedConfigCustomer;
|
|
57
|
+
product?: PickedConfigProduct;
|
|
58
|
+
collection?: PickedConfigCollection;
|
|
59
|
+
experiments?: PickedConfigExperiment[];
|
|
60
|
+
storefront_api?: {
|
|
61
|
+
token?: string;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
declare global {
|
|
65
|
+
interface Window {
|
|
66
|
+
pickedConfig?: Readonly<Partial<CreateClientOptions> & ShopifyPickedConfig>;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
export declare function getPickedConfig(): Readonly<Partial<CreateClientOptions> & ShopifyPickedConfig>;
|
|
70
|
+
export declare function getPickedConfigCustomer(): Partial<{
|
|
71
|
+
accepts_marketing: boolean;
|
|
72
|
+
email: string;
|
|
73
|
+
first_name: string | null;
|
|
74
|
+
has_account: boolean;
|
|
75
|
+
id: number;
|
|
76
|
+
last_name: string | null;
|
|
77
|
+
orders_count: number;
|
|
78
|
+
phone: string | null;
|
|
79
|
+
tax_exempt: boolean;
|
|
80
|
+
}> | undefined;
|
|
81
|
+
export declare function getPickedConfigProduct(): Partial<{
|
|
82
|
+
available: boolean;
|
|
83
|
+
collections: PickedConfigProductCollection[];
|
|
84
|
+
featured_image: string;
|
|
85
|
+
handle: string;
|
|
86
|
+
id: number;
|
|
87
|
+
metafields: MetafieldObject;
|
|
88
|
+
price: number;
|
|
89
|
+
tags: string[];
|
|
90
|
+
title: string;
|
|
91
|
+
type: string;
|
|
92
|
+
url: string;
|
|
93
|
+
variants: PickedConfigProductVariant[];
|
|
94
|
+
vendor: string;
|
|
95
|
+
}> | undefined;
|
|
96
|
+
export declare function getPickedConfigCollection(): Partial<{
|
|
97
|
+
title: string;
|
|
98
|
+
id: number;
|
|
99
|
+
handle: string;
|
|
100
|
+
}> | undefined;
|
|
101
|
+
export declare function getPickedConfigExperiments(): PickedConfigExperiment[] | undefined;
|
|
102
|
+
export declare function getPickedConfigStorefrontApiToken(): string | undefined;
|
|
103
|
+
//# sourceMappingURL=picked-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"picked-config.d.ts","sourceRoot":"","sources":["../../../../src/plugins/shopify/picked-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAGtD,MAAM,WAAW,sBAAsB;IAErC,OAAO,EAAE,OAAO,CAAA;IAGhB,EAAE,EAAE,MAAM,CAAA;IAGV,IAAI,EAAE,MAAM,CAAA;IAGZ,OAAO,EAAE,MAAM,CAAA;IAGf,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,MAAM,sBAAsB,GAAG,OAAO,CAAC;IAC3C,KAAK,EAAE,MAAM,CAAA;IACb,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,MAAM,CAAA;CACf,CAAC,CAAA;AAEF,MAAM,MAAM,0BAA0B,GAAG,OAAO,CAAC;IAC/C,SAAS,EAAE,OAAO,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;IACb,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,kBAAkB,EAAE,MAAM,CAAA;IAC1B,OAAO,EAAE,MAAM,CAAA;CAChB,CAAC,CAAA;AAEF,MAAM,MAAM,6BAA6B,GAAG,OAAO,CAAC;IAClD,EAAE,EAAE,MAAM,CAAA;CACX,CAAC,CAAA;AAEF,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAA;AAEzE,MAAM,WAAW,eAAe;IAC9B,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,GAAG,eAAe,GAAG,cAAc,EAAE,GAAG,eAAe,EAAE,CAAA;CACvF;AAED,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC;IACxC,SAAS,EAAE,OAAO,CAAA;IAClB,WAAW,EAAE,6BAA6B,EAAE,CAAA;IAC5C,cAAc,EAAE,MAAM,CAAA;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M;eACC,MAAM,GAAG,IAAI;kBACV,MAAM;WACb,MAAM,GAAG,IAAI;gBACR,OAAO;eAmCpB;AAED,wBAAgB,sBAAsB;eA7DzB,OAAO;iBACL,6BAA6B,EAAE;oBAC5B,MAAM;YACd,MAAM;QACV,MAAM;gBACE,eAAe;WACpB,MAAM;UACP,MAAM,EAAE;WACP,MAAM;UACP,MAAM;SACP,MAAM;cACD,0BAA0B,EAAE;YAC9B,MAAM;eAuDf;AAED,wBAAgB,yBAAyB;WA9FhC,MAAM;QACT,MAAM;YACF,MAAM;eAkGf;AAED,wBAAgB,0BAA0B,yCAMzC;AAED,wBAAgB,iCAAiC,uBAMhD"}
|
|
@@ -1,16 +1,30 @@
|
|
|
1
1
|
import { StateSnapshot } from '../../utils/state-snaphot';
|
|
2
2
|
export declare const evaluatePathname: (regexPattern: RegExp, location?: StateSnapshot["location"]) => boolean;
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Evaluate handle from path using regex pattern
|
|
5
|
+
*
|
|
6
|
+
* @param regexPattern Regex pattern to extract handle
|
|
7
|
+
* @param location Location object containing pathname
|
|
8
|
+
* @returns handle string or undefined
|
|
9
|
+
*/
|
|
10
|
+
export declare const evaluateHandleByPath: (regexPattern: RegExp, location?: StateSnapshot["location"]) => string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Evaluate handle from pickedConfig based on type
|
|
13
|
+
*
|
|
14
|
+
* @param type page type: 'product' | 'collection'
|
|
15
|
+
* @returns handle string or undefined
|
|
16
|
+
*/
|
|
17
|
+
export declare const evaluateHandleByType: (type: "product" | "collection") => string | false;
|
|
4
18
|
interface PredicateArgs {
|
|
5
19
|
location?: StateSnapshot['location'];
|
|
6
20
|
}
|
|
7
21
|
export declare const shopifyPredicates: {
|
|
8
22
|
'is-page': ({ location }: PredicateArgs) => boolean;
|
|
9
23
|
'get-page-handle': ({ location }: PredicateArgs) => string | undefined;
|
|
10
|
-
'is-product-page': (
|
|
11
|
-
'get-product-handle': (
|
|
12
|
-
'is-collection-page': (
|
|
13
|
-
'get-collection-handle': (
|
|
24
|
+
'is-product-page': () => boolean;
|
|
25
|
+
'get-product-handle': () => string | false;
|
|
26
|
+
'is-collection-page': () => boolean;
|
|
27
|
+
'get-collection-handle': () => string | false;
|
|
14
28
|
'is-blog-page': ({ location }: PredicateArgs) => boolean;
|
|
15
29
|
'get-blog-handle': ({ location }: PredicateArgs) => string | undefined;
|
|
16
30
|
'is-article-page': ({ location }: PredicateArgs) => boolean;
|
|
@@ -25,4 +39,4 @@ export declare const shopifyPredicates: {
|
|
|
25
39
|
'is-homepage': ({ location }: PredicateArgs) => boolean;
|
|
26
40
|
};
|
|
27
41
|
export {};
|
|
28
|
-
//# sourceMappingURL=
|
|
42
|
+
//# sourceMappingURL=predicates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"predicates.d.ts","sourceRoot":"","sources":["../../../../src/plugins/shopify/predicates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAmB9D,eAAO,MAAM,gBAAgB,GAC3B,cAAc,MAAM,EACpB,WAAW,aAAa,CAAC,UAAU,CAAC,KACnC,OAMF,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAC/B,cAAc,MAAM,EACpB,WAAW,aAAa,CAAC,UAAU,CAAC,uBAQrC,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,MAAM,SAAS,GAAG,YAAY,mBASlE,CAAA;AAED,UAAU,aAAa;IACrB,QAAQ,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC,CAAA;CACrC;AAED,eAAO,MAAM,iBAAiB;8BAEF,aAAa;sCACL,aAAa;;;;;mCAQhB,aAAa;sCACV,aAAa;sCAEb,aAAa;yCACV,aAAa;wCAGd,aAAa;2CACV,aAAa;sCAGlB,aAAa;oCAEf,aAAa;uCACV,aAAa;mCAGjB,aAAa;uCAET,aAAa;kCAElB,aAAa;CAC5C,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const p=require("effector"),y=require("@withease/factories"),w=require("./experience-instance-B2l_MG7I.cjs"),b=require("./logger-BsmHUUw1.cjs"),x=require("./storage-DuRlyFaY.cjs"),P=require("./id-BKIWbSTy.cjs"),M=require("./object-BbFTsGh3.cjs"),B=require("./supports-YvpQZxbh.cjs"),j=p.createDomain("experience"),T=y.createFactory(({client:t,experience:e})=>{const i=j.store(e),g=p.createApi(i,{merge(u,S){return{...u,...S.experience}}}),f=i.map(u=>({name:u.name,decisionLogic:u.decide,targetSelectors:u.targets,initializeOpenLogic:e.initializeOpen})),d=t.components.listStore.map(u=>u.find(S=>S.name===`experience:${e.id}`)||u.find(S=>S.name==="experience"),{skipVoid:!1}),r=i.map(u=>({steps:u.steps,nodes:u.nodes,edges:u.edges,conditionals:u.conditionals})),n=e.actions??[];return{id:e.id,configStore:f,treeStore:r,componentStore:d,actions:n,merge:g.merge}});function V(t){return y.invoke(T,t)}const N=y.createFactory(({client:t})=>{const e=j.store({}),i=p.createApi(e,{register(r,n){return{...r,[n.id]:n}}});function g(r){const n=e.getState()[r.id];if(n){n.merge({experience:r,strategy:"override"});return}const u=V({client:t,experience:r});i.register(u)}const f=e.map(r=>Object.values(r));function d(r){return e.map(n=>n[r],{skipVoid:!1})}return{register:g,getById:d,listStore:f}});function C(t){return y.invoke(N,t)}const L=(t,e)=>{e.register(t)},O=(t,e)=>{const{targetSelectors:i}=e.configStore.getState(),g=w.getTargetElements(i,e.id);g.forEach(({elements:d})=>d.forEach(r=>w.tagTargetElement(r,e.id))),w.createAppHosts(g,e.id).forEach(d=>{t.experienceInstances.spawn(e,d)})},q=async t=>{await Promise.all(t.experiences.listStore.getState().map(async e=>{await _(t,e)&&O(t,e)}))},_=async(t,e)=>{const{decisionLogic:i,targetSelectors:g}=e.configStore.getState();return w.getTargetElements(g,e.id).length<1||g.length===0?!1:i&&w.isRulesLogic(i)?await w.evaluateRuleLogic(t,i)===!0:!0},U=p.createDomain("component"),H=y.createFactory(({client:t,component:e,name:i})=>{const g=t.frameworks.getByName(e.frameworkName);return{name:i,component:e,frameworkStore:g}});function K(t){return y.invoke(H,t)}const z=y.createFactory(({client:t})=>{const e=U.store({}),i=p.createApi(e,{register(r,n){return{...r,[n.name]:n}}});function g(r,n){e.getState()[r]&&b.logger("warn",`Component '${r}' already registered. Registering again will override the previous registration.`);const S=K({client:t,name:r,component:n});i.register(S)}const f=e.map(r=>Object.values(r));function d(r){return e.map(n=>n[r],{skipVoid:!1})}return{register:g,getByName:d,listStore:f}});function G(t){return y.invoke(z,t)}const Y=(t,e,i)=>{i.register(t,e)},J=p.createDomain("framework"),Q=y.createFactory(({client:t})=>{const e=J.store({}),i=p.createApi(e,{register(r,n){return{...r,[n.name]:n.framework}}});function g(r,n){e.getState()[r]&&b.logger("warn",`Framework '${r}' already registered. Registering again will override the previous registration.`),i.register({name:r,framework:n})}const f=e.map(r=>Object.values(r));function d(r){return e.map(n=>n[r],{skipVoid:!1})}return{register:g,getByName:d,listStore:f}});function W(t){return y.invoke(Q,t)}const X=(t,e)=>{e.register(t.name,t)},Z=6e3,D=x.createStorageKey("last_ping","global"),ee=t=>`${t}/api/v1/ping`,te=async t=>{try{const e=Date.now(),i=localStorage.getItem(D);if(i&&e-parseInt(i)<Z)return!0;const g=ee(t.apiUrl),f={projectId:t.projectId,path:window.location.pathname},d=JSON.stringify(f),r={"Content-Type":"application/json"},n=document.getElementById("picked_script"),u=n==null?void 0:n.dataset.verceltoken;u&&(r["x-vercel-protection-bypass"]=u);const k=(await fetch(g,{method:"POST",headers:r,body:d})).ok;return k&&localStorage.setItem(D,e.toString()),k}catch(e){return b.logger("error",e),!1}},re=p.createDomain("predicate"),ne=y.createFactory(({client:t})=>{const e=re.store({}),i=p.createApi(e,{register(r,n){return{...r,[n.name]:{name:n.name,predicate:n.predicate}}}});function g(r,n){e.getState()[r]&&b.logger("warn",`Predicate '${r}' already registered. Registering again will override the previous registration.`),i.register(Object.freeze({name:r,predicate:n}))}const f=e.map(r=>Object.values(r));function d(r){return e.map(n=>n[r],{skipVoid:!1})}return{register:g,getByName:d,listStore:f}});function se(t){return y.invoke(ne,t)}const oe=(t,e,i)=>{i.register(t,e)},$=p.createDomain("feature"),ie=y.createFactory(({client:t})=>{const e=$.store({}),i=$.store([]),g=p.createApi(e,{register(a,o){return{...a,[o.id]:o.feature}}});function f(a,o){e.getState()[a]&&b.logger("warn",`Feature '${a}' already registered. Registering again will override the previous registration.`);const c={id:a,feature:{...o,id:a}};g.register(Object.freeze({id:a,feature:c}))}const d=p.createEffect(async({id:a,key:o,storage:s="local"})=>{const c=x.createStorageKey(`feature:${a}:${o}`,"global"),l=(s==="session"?x.sessionStore:x.localStore).get(c).boolean();return l===null?null:{id:a,key:o,bucket:l,storage:s}}),r=p.createEffect(a=>{if(!a)return null;const o=x.createStorageKey(`feature:${a.id}:${a.key}`,"global");(a.storage==="session"?x.sessionStore:x.localStore).set(o,a.bucket)}),n=new Map,u=p.attach({source:{allFeaturesStore:e,resolvedFeaturesStore:i},effect:async({allFeaturesStore:a,resolvedFeaturesStore:o},{id:s,decide:c,key:m})=>{const l=o.find(A=>A.id===s);if(l)return l;const v=a[s];if(!v)throw new Error(`Feature with id '${s}' not found`);const F=n.get(`${s}:${m}`);if(F!==void 0){const A=await F;return{id:v.id,bucket:A,key:m,storage:v.feature.storage}}const E=c();n.set(`${s}:${m}`,E);const I=await E;return{id:v.id,bucket:I,key:m,storage:v.feature.storage}}});p.sample({clock:g.register,source:e,filter:(a,o)=>{const s=a[o.id];return s?s.feature.key!==o.feature.feature.key||s.feature.storage!==o.feature.feature.storage:!0},fn:(a,o)=>{const{id:s,feature:c}=o;return{id:s,key:c.feature.key,storage:c.feature.storage}},target:d}),p.sample({source:e,clock:u.doneData,fn:(a,o)=>{var v;const{id:s,bucket:c,storage:m}=o,l=(v=a[s])==null?void 0:v.feature.key;return l?{key:l,id:s,bucket:c,storage:m}:null},target:r});const S=p.combine({allFeaturesStore:e,resolvedFeaturesStore:i}).map(({allFeaturesStore:a,resolvedFeaturesStore:o})=>Object.values(a).map(s=>{const c=o.find(m=>m.id===s.id);return c?{id:s.id,name:s.feature.name,key:s.feature.key,getBucket:()=>({id:s.id,bucket:c.bucket}),isResolved:!0}:{id:s.id,name:s.feature.name,key:s.feature.key,getBucket:async()=>await u(s.feature),isResolved:!1}}));p.sample({clock:u.doneData,source:{resolvedFeatures:i},filter:({resolvedFeatures:a},{id:o})=>!a.some(s=>s.id===o),fn:(a,o)=>o,target:t.eventBus.prepend(a=>({type:"feature_decide",feature:a}))}),p.sample({clock:[d.doneData,u.doneData],source:i,fn:(a,o)=>!o||a.some(s=>s.id===o.id)?a:[...a,o],target:i});function k(a){return e.map(o=>o[a],{skipVoid:!1})}return{register:f,getByName:k,listStore:S}});function ae(t){return y.invoke(ie,t)}const ce=(t,e,i)=>{i.register(t,e)},h=p.createDomain("history");function R(t,e){return{id:P.generateId(`history-entry-${Date.now()}-${Math.random()}}`),node:e,at:Date.now(),experienceId:t}}const ue=y.createFactory(()=>{const t=h.store({entries:[]}),e=h.event(),i=h.event(),g=h.event(),f=h.event();t.on(e,(r,n)=>({entries:[...r.entries,R(n.experienceId,n.node)]})),t.on(i,(r,n)=>({entries:[...r.entries.slice(0,-1),R(n.experienceId,n.node)]})),t.on(f,(r,n)=>n);function d(r,n){const u={lastStepIndex:-1,secondLastStepIndex:-1};for(let S=r.length-1;S>=0;S--){const k=r[S],a=k==null?void 0:k.node;if(!(!a||!w.isStepNode(a))&&!(n&&(k==null?void 0:k.experienceId)!==n))if(u.lastStepIndex===-1)u.lastStepIndex=S;else{u.secondLastStepIndex=S;break}}return u}return t.on(g,(r,n)=>{const{secondLastStepIndex:u}=d(r.entries,n.experienceId),S=u!==-1?r.entries.slice(0,u+1):r.entries;return{...r,entries:S}}),{push:e,replace:i,back:g,restore:f,entriesStore:t.map(r=>r.entries)}});function le(){return y.invoke(ue)}const ge=p.createDomain("field"),de=y.createFactory(()=>{const t=ge.store({}),e=p.createApi(t,{register(r,n){return{...r,[n.field.id]:n.field}}});function i(r){e.register({field:r})}const g=t.map(r=>Object.values(r));function f(r){return t.map(n=>n[r]||null)}function d(r){return t.map(n=>Object.values(n).find(u=>u.name===r)||null)}return{register:i,getById:f,listStore:g,getByName:d}});function pe(){return y.invoke(de)}const fe=(t,e)=>{e.register(t)},me=p.createDomain("action"),ye=y.createFactory(()=>{const t=me.store({}),e=p.createApi(t,{register(d,r){return{...d,[r.name]:{name:r.name,action:r.action}}}});function i(d,r){e.register({name:d,action:r})}const g=t.map(d=>Object.values(d));function f(d){return t.map(r=>r[d],{skipVoid:!1})}return{register:i,getByName:f,listStore:g}});function Se(){return y.invoke(ye)}const ve=(t,e,i)=>{i.register(t,e)},ke=p.createDomain("response"),Fe=y.createFactory(({client:t})=>{const e=ke.store({}),i=p.createEvent(),g=p.createEvent(),f=p.createApi(e,{register(o,s){return{...o,[s.fieldId]:s.response}},registerBatch(o,s){return{...o,...s}},clear(o,s){const{[s]:c,...m}=o;return m},clearAll(){return{}}});function d(o,s){f.register({fieldId:o,response:s})}async function r(o){const s=[];return await Promise.allSettled(Object.entries(o).map(async([c,m])=>{let l=m;const v=t.fields.getById(c).getState();if(!v){s.push({fieldId:c,userMessage:`Field '${c}' not found`,systemMessage:`No field with ID '${c}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,value:l});return}if(v.multiple&&(typeof l=="string"||typeof l=="number"||typeof l=="boolean")&&(l=[l]),v.validation&&!M.isEmpty(v.validation)){const F=await w.evaluateRuleLogic(t,v.validation,{$input:l});if(typeof F=="string"){s.push({fieldId:c,userMessage:F,systemMessage:`Field validation resulted in an error: ${F}.`,value:l});return}if(F===!1){s.push({fieldId:c,userMessage:"This field is invalid",systemMessage:"Field validation resulted in an unspecified error.",value:l});return}}if(v.required&&(typeof l>"u"||l===null||l===""||Array.isArray(l)&&!l.length)){s.push({fieldId:c,userMessage:"This field is required",systemMessage:"Field is required.",value:l});return}if(!v.multiple&&Array.isArray(l)&&l.length>1){s.push({fieldId:c,userMessage:"This field expects a single response",systemMessage:"Field expects a single response.",value:l});return}if(v.options){const F=v.options.map(I=>I.value),E=Array.isArray(l)?l:[l];Array.isArray(l)&&(E.every(I=>F.includes(I))||s.push({fieldId:c,userMessage:"This field expects a valid option",systemMessage:`Field expects a valid option. Valid options are: ${F.join(", ")}`,value:l}))}})),{responsesToCommit:o,validationErrors:s}}async function n(o){const{responsesToCommit:s,validationErrors:c}=await r(o);return c.length?{errors:c}:(f.registerBatch(s),{errors:[]})}const u=e.map(o=>o),S=e.map(o=>Object.keys(o).map(c=>({fieldId:c,value:o[c]})));function k(o){const s=t.fields.getById(o),c=e.map(m=>m[o]||null);return p.combine({f:s,r:c},({f:m,r:l})=>l||(m!=null&&m.defaultValue?m.defaultValue:null))}function a(o){const s=t.fields.getByName(o);return p.combine({f:s,s:e},({f:c,s:m})=>{const l=c&&m[c.id]||null;return l||(c!=null&&c.defaultValue?c.defaultValue:null)})}return p.sample({clock:i,target:f.clearAll}),p.sample({clock:g,target:f.clear}),{register:d,clearAll:i,clear:g,commit:n,getResponsesToCommit:r,listStore:S,getAllStore:u,getByFieldId:k,getByFieldName:a}});function xe(t){return y.invoke(Fe,t)}function we(){if(B.supportsCryptoRandomUUID())return crypto.randomUUID();const t=Date.now().toString(36),e=Math.random().toString(36).substring(2,15),i=Math.random().toString(36).substring(2,15),g=Math.random().toString(36).substring(2,15);return`${t}-${e}-${i}-${g}`}const Ie=()=>({id:we()}),he=x.createStorageKey("session","global"),be=()=>{if(!B.supportsLocalStorage())return null;const t=x.localStore.get(he);let e=t.isSet()?t.json():null;return e||(e=Ie(),t.set(e)),e},Ee=()=>be();exports.createActionIndex=Se;exports.createComponentIndex=G;exports.createExperienceIndex=C;exports.createFeatureIndex=ae;exports.createFieldIndex=pe;exports.createFrameworkIndex=W;exports.createHistory=le;exports.createPredicateIndex=se;exports.createResponseIndex=xe;exports.initialiseExperience=O;exports.initialiseExperiences=q;exports.initialiseSession=Ee;exports.ping=te;exports.setupAction=ve;exports.setupComponent=Y;exports.setupExperience=L;exports.setupFeature=ce;exports.setupField=fe;exports.setupFramework=X;exports.setupPredicate=oe;
|