@picked/shopify 0.0.1-dev.1764898426031 → 0.0.1-dev.1764911630251
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/plugins/shopify/index.js +1 -1
- package/dist/cjs/storefront-api/index.js +1 -1
- package/dist/esm/plugins/shopify/index.js +94 -61
- package/dist/esm/storefront-api/index.js +1 -1
- package/dist/picked-config-B69J6txs.js +70 -0
- package/dist/picked-config-DfcDhMyM.cjs +1 -0
- package/dist/types/plugins/shopify/plugin.d.ts.map +1 -1
- package/dist/types/utils/debounce.d.ts +2 -1
- package/dist/types/utils/debounce.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/picked-config-BEFhVeAZ.cjs +0 -1
- package/dist/picked-config-DfW6lJWR.js +0 -70
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("@picked/client"),f=require("../../ajax-api/index.js"),s=require("../../../picked-config-DfcDhMyM.cjs"),y=require("../../../global-obj-OziQiQ8j.cjs");function P(e,t){let o,c;return(...d)=>(c&&c.reject(new Error("Debounced")),new Promise((a,r)=>{c={resolve:a,reject:r};const g=async()=>{o=void 0;try{const l=await e(...d);c==null||c.resolve(l)}catch(l){c==null||c.reject(l)}finally{c=null}};clearTimeout(o),o=setTimeout(g,t)}))}const i={homepage:/^\/$/,page:/(?:^|\/)pages\/(?<pageHandle>[^/]+)\/?$/,blog:/(?:^|\/)blogs\/(?<blogHandle>[^/]+)\/?$/,article:/^\/blogs\/[^/]+\/(?<article>[^/]+)\/?$/,cart:/(?:^|\/)cart\/[^/]+$/,checkout:/^\/checkout\/.+/,appProxy:/^\/(?:a|apps|community|tools)\/(?<proxyTarget>[^/]+)/,accountWildcard:/^\/account\/.+/,accountLogin:/^\/account\/login(?:\/|$)/,accountRegister:/^\/account\/register(?:\/|$)/},n=(e,t)=>t?!!e.exec(t.pathname):!1,u=(e,t)=>{if(t){const o=e.exec(t.pathname);if(o)return o[1]}},p=e=>{var t,o;switch(e){case"product":return((t=s.getPickedConfigProduct())==null?void 0:t.handle)??!1;case"collection":return((o=s.getPickedConfigCollection())==null?void 0:o.handle)??!1;default:return!1}},b={"is-page":({location:e})=>n(i.page,e),"get-page-handle":({location:e})=>u(i.page,e),"is-product-page":()=>!!p("product"),"get-product-handle":()=>p("product"),"is-collection-page":()=>!!p("collection"),"get-collection-handle":()=>p("collection"),"is-blog-page":({location:e})=>n(i.blog,e),"get-blog-handle":({location:e})=>u(i.blog,e),"is-article-page":({location:e})=>n(i.article,e),"get-article-handle":({location:e})=>u(i.article,e),"is-app-proxy-page":({location:e})=>n(i.appProxy,e),"get-app-proxy-handle":({location:e})=>u(i.appProxy,e),"is-account-page":({location:e})=>n(i.accountWildcard,e),"is-login-page":({location:e})=>n(i.accountLogin,e),"is-register-page":({location:e})=>n(i.accountRegister,e),"is-cart-page":({location:e})=>n(i.cart,e),"is-checkout-page":({location:e})=>n(i.checkout,e),"is-homepage":({location:e})=>n(i.homepage,e)},C=()=>({name:"shopify",setup:e=>{let t={},o=0;const c=async()=>{if(o>=3)return;o++,await f.updateCart({attributes:t});const a=await f.getCart();for(const[r,g]of Object.entries(t))if(a.attributes[r]!==g)return c()},d=P(async()=>(o=0,c()),50);Object.entries(b).forEach(([a,r])=>{e.registerPredicate(`shopify-${a}`,r)}),k.supportsWindow()&&e.eventBus.watch(a=>{if(y.supportsShopifyAnalytics()&&(a.type==="session"&&globalThis.window.Shopify.analytics.publish("picked:session",{id:a.id}),a.type==="feature_decide"||a.type==="session")){const r=e.session;if(r){const g={"picked.id":r.id};typeof r.isUser<"u"&&(g["picked.is_user"]=r.isUser?"true":"false"),e.features.listStore.getState().forEach(l=>{if(l.isResolved){const h=l.getBucket();g[`picked.features.${l.id}`]=`${h.bucket}`}}),t={...t,...g},d()}}})}});exports.getPickedConfig=s.getPickedConfig;exports.getPickedConfigCollection=s.getPickedConfigCollection;exports.getPickedConfigCustomer=s.getPickedConfigCustomer;exports.getPickedConfigExperiments=s.getPickedConfigExperiments;exports.getPickedConfigFeatureExperiments=s.getPickedConfigFeatureExperiments;exports.getPickedConfigProduct=s.getPickedConfigProduct;exports.getPickedConfigStorefrontApiToken=s.getPickedConfigStorefrontApiToken;exports.getShopify=y.getShopify;exports.shopifyPlugin=C;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@shopify/storefront-api-client");require("@picked/client");const n=require("../../picked-config-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@shopify/storefront-api-client");require("@picked/client");const n=require("../../picked-config-DfcDhMyM.cjs"),i=require("../../global-obj-OziQiQ8j.cjs");function f(t){const o=i.getShopify(),e=n.getPickedConfigStorefrontApiToken();if(!e)throw new Error("Shopify Storefront API token not found. Ensure the Picked Script is enabled on your Shopify storefront");return r.createStorefrontApiClient({storeDomain:o.shop,apiVersion:t.apiVersion,publicAccessToken:e})}const c=()=>{if(!client)throw new Error("Storefront API client not found");return client};exports.createStorefrontApiClient=f;exports.getStorefrontApiClient=c;
|
|
@@ -1,10 +1,28 @@
|
|
|
1
|
-
import { supportsWindow as
|
|
2
|
-
import { updateCart as
|
|
3
|
-
import { a as
|
|
4
|
-
import { c as
|
|
5
|
-
import { s as
|
|
6
|
-
import { g as
|
|
7
|
-
|
|
1
|
+
import { supportsWindow as f } from "@picked/client";
|
|
2
|
+
import { updateCart as h, getCart as y } from "../../ajax-api/index.js";
|
|
3
|
+
import { a as m, b } from "../../../picked-config-B69J6txs.js";
|
|
4
|
+
import { c as S, d as T, e as j, f as H, g as R } from "../../../picked-config-B69J6txs.js";
|
|
5
|
+
import { s as k } from "../../../global-obj-DQ6S7d00.js";
|
|
6
|
+
import { g as L } from "../../../global-obj-DQ6S7d00.js";
|
|
7
|
+
function P(e, t) {
|
|
8
|
+
let a, i;
|
|
9
|
+
return (...g) => (i && i.reject(new Error("Debounced")), new Promise((s, c) => {
|
|
10
|
+
i = { resolve: s, reject: c };
|
|
11
|
+
const n = async () => {
|
|
12
|
+
a = void 0;
|
|
13
|
+
try {
|
|
14
|
+
const p = await e(...g);
|
|
15
|
+
i == null || i.resolve(p);
|
|
16
|
+
} catch (p) {
|
|
17
|
+
i == null || i.reject(p);
|
|
18
|
+
} finally {
|
|
19
|
+
i = null;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
clearTimeout(a), a = setTimeout(n, t);
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
const o = {
|
|
8
26
|
homepage: /^\/$/,
|
|
9
27
|
page: /(?:^|\/)pages\/(?<pageHandle>[^/]+)\/?$/,
|
|
10
28
|
blog: /(?:^|\/)blogs\/(?<blogHandle>[^/]+)\/?$/,
|
|
@@ -15,83 +33,98 @@ const a = {
|
|
|
15
33
|
accountWildcard: /^\/account\/.+/,
|
|
16
34
|
accountLogin: /^\/account\/login(?:\/|$)/,
|
|
17
35
|
accountRegister: /^\/account\/register(?:\/|$)/
|
|
18
|
-
},
|
|
36
|
+
}, r = (e, t) => t ? !!e.exec(t.pathname) : !1, l = (e, t) => {
|
|
19
37
|
if (t) {
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
22
|
-
return
|
|
38
|
+
const a = e.exec(t.pathname);
|
|
39
|
+
if (a)
|
|
40
|
+
return a[1];
|
|
23
41
|
}
|
|
24
|
-
},
|
|
25
|
-
var t,
|
|
42
|
+
}, u = (e) => {
|
|
43
|
+
var t, a;
|
|
26
44
|
switch (e) {
|
|
27
45
|
case "product":
|
|
28
|
-
return ((t =
|
|
46
|
+
return ((t = b()) == null ? void 0 : t.handle) ?? !1;
|
|
29
47
|
case "collection":
|
|
30
|
-
return ((
|
|
48
|
+
return ((a = m()) == null ? void 0 : a.handle) ?? !1;
|
|
31
49
|
default:
|
|
32
50
|
return !1;
|
|
33
51
|
}
|
|
34
|
-
},
|
|
52
|
+
}, x = {
|
|
35
53
|
// Pages
|
|
36
|
-
"is-page": ({ location: e }) => o
|
|
37
|
-
"get-page-handle": ({ location: e }) =>
|
|
54
|
+
"is-page": ({ location: e }) => r(o.page, e),
|
|
55
|
+
"get-page-handle": ({ location: e }) => l(o.page, e),
|
|
38
56
|
// Products
|
|
39
|
-
"is-product-page": () => !!
|
|
40
|
-
"get-product-handle": () =>
|
|
57
|
+
"is-product-page": () => !!u("product"),
|
|
58
|
+
"get-product-handle": () => u("product"),
|
|
41
59
|
// Collections
|
|
42
|
-
"is-collection-page": () => !!
|
|
43
|
-
"get-collection-handle": () =>
|
|
60
|
+
"is-collection-page": () => !!u("collection"),
|
|
61
|
+
"get-collection-handle": () => u("collection"),
|
|
44
62
|
// Blogs
|
|
45
|
-
"is-blog-page": ({ location: e }) => o
|
|
46
|
-
"get-blog-handle": ({ location: e }) =>
|
|
63
|
+
"is-blog-page": ({ location: e }) => r(o.blog, e),
|
|
64
|
+
"get-blog-handle": ({ location: e }) => l(o.blog, e),
|
|
47
65
|
// Blog Articles
|
|
48
|
-
"is-article-page": ({ location: e }) => o
|
|
49
|
-
"get-article-handle": ({ location: e }) =>
|
|
66
|
+
"is-article-page": ({ location: e }) => r(o.article, e),
|
|
67
|
+
"get-article-handle": ({ location: e }) => l(o.article, e),
|
|
50
68
|
// Apps
|
|
51
|
-
"is-app-proxy-page": ({ location: e }) => o
|
|
52
|
-
"get-app-proxy-handle": ({ location: e }) =>
|
|
69
|
+
"is-app-proxy-page": ({ location: e }) => r(o.appProxy, e),
|
|
70
|
+
"get-app-proxy-handle": ({ location: e }) => l(o.appProxy, e),
|
|
53
71
|
// Account
|
|
54
|
-
"is-account-page": ({ location: e }) => o
|
|
55
|
-
"is-login-page": ({ location: e }) => o
|
|
56
|
-
"is-register-page": ({ location: e }) => o
|
|
72
|
+
"is-account-page": ({ location: e }) => r(o.accountWildcard, e),
|
|
73
|
+
"is-login-page": ({ location: e }) => r(o.accountLogin, e),
|
|
74
|
+
"is-register-page": ({ location: e }) => r(o.accountRegister, e),
|
|
57
75
|
// Cart
|
|
58
|
-
"is-cart-page": ({ location: e }) => o
|
|
76
|
+
"is-cart-page": ({ location: e }) => r(o.cart, e),
|
|
59
77
|
// Checkout
|
|
60
|
-
"is-checkout-page": ({ location: e }) => o
|
|
78
|
+
"is-checkout-page": ({ location: e }) => r(o.checkout, e),
|
|
61
79
|
// Homepage
|
|
62
|
-
"is-homepage": ({ location: e }) => o
|
|
63
|
-
},
|
|
80
|
+
"is-homepage": ({ location: e }) => r(o.homepage, e)
|
|
81
|
+
}, B = () => ({
|
|
64
82
|
name: "shopify",
|
|
65
83
|
setup: (e) => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
|
|
84
|
+
let t = {}, a = 0;
|
|
85
|
+
const i = async () => {
|
|
86
|
+
if (a >= 3) return;
|
|
87
|
+
a++, await h({
|
|
88
|
+
attributes: t
|
|
89
|
+
});
|
|
90
|
+
const s = await y();
|
|
91
|
+
for (const [c, n] of Object.entries(t))
|
|
92
|
+
if (s.attributes[c] !== n)
|
|
93
|
+
return i();
|
|
94
|
+
}, g = P(async () => (a = 0, i()), 50);
|
|
95
|
+
Object.entries(x).forEach(([s, c]) => {
|
|
96
|
+
e.registerPredicate(`shopify-${s}`, c);
|
|
97
|
+
}), f() && e.eventBus.watch((s) => {
|
|
98
|
+
if (k() && (s.type === "session" && globalThis.window.Shopify.analytics.publish("picked:session", {
|
|
99
|
+
id: s.id
|
|
100
|
+
}), s.type === "feature_decide" || s.type === "session")) {
|
|
101
|
+
const c = e.session;
|
|
102
|
+
if (c) {
|
|
103
|
+
const n = {
|
|
104
|
+
"picked.id": c.id
|
|
105
|
+
};
|
|
106
|
+
typeof c.isUser < "u" && (n["picked.is_user"] = c.isUser ? "true" : "false"), e.features.listStore.getState().forEach((p) => {
|
|
107
|
+
if (p.isResolved) {
|
|
108
|
+
const d = p.getBucket();
|
|
109
|
+
n[`picked.features.${p.id}`] = `${d.bucket}`;
|
|
110
|
+
}
|
|
111
|
+
}), t = {
|
|
112
|
+
...t,
|
|
113
|
+
...n
|
|
114
|
+
}, g();
|
|
74
115
|
}
|
|
75
|
-
}
|
|
76
|
-
attributes: {
|
|
77
|
-
[`picked.features.${t.feature.id}`]: `${t.feature.bucket}`
|
|
78
|
-
}
|
|
79
|
-
}), t.type === "user_decide" && s({
|
|
80
|
-
attributes: {
|
|
81
|
-
"picked.is_user": t.value ? "true" : "false"
|
|
82
|
-
}
|
|
83
|
-
}));
|
|
116
|
+
}
|
|
84
117
|
});
|
|
85
118
|
}
|
|
86
119
|
});
|
|
87
120
|
export {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
121
|
+
S as getPickedConfig,
|
|
122
|
+
m as getPickedConfigCollection,
|
|
123
|
+
T as getPickedConfigCustomer,
|
|
124
|
+
j as getPickedConfigExperiments,
|
|
125
|
+
H as getPickedConfigFeatureExperiments,
|
|
126
|
+
b as getPickedConfigProduct,
|
|
127
|
+
R as getPickedConfigStorefrontApiToken,
|
|
128
|
+
L as getShopify,
|
|
129
|
+
B as shopifyPlugin
|
|
97
130
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createStorefrontApiClient as e } from "@shopify/storefront-api-client";
|
|
2
2
|
import "@picked/client";
|
|
3
|
-
import { g as n } from "../../picked-config-
|
|
3
|
+
import { g as n } from "../../picked-config-B69J6txs.js";
|
|
4
4
|
import { g as i } from "../../global-obj-DQ6S7d00.js";
|
|
5
5
|
function S(t) {
|
|
6
6
|
const r = i(), o = n();
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { supportsWindow as n, createStorageKey as u, localStore as f } from "@picked/client";
|
|
2
|
+
function i() {
|
|
3
|
+
if (n())
|
|
4
|
+
return globalThis.window.pickedConfig;
|
|
5
|
+
}
|
|
6
|
+
function a() {
|
|
7
|
+
var t;
|
|
8
|
+
if (n())
|
|
9
|
+
return (t = i()) == null ? void 0 : t.customer;
|
|
10
|
+
}
|
|
11
|
+
function l() {
|
|
12
|
+
var t;
|
|
13
|
+
if (n())
|
|
14
|
+
return (t = i()) == null ? void 0 : t.product;
|
|
15
|
+
}
|
|
16
|
+
function k() {
|
|
17
|
+
var t;
|
|
18
|
+
if (n())
|
|
19
|
+
return (t = i()) == null ? void 0 : t.collection;
|
|
20
|
+
}
|
|
21
|
+
function s() {
|
|
22
|
+
var t;
|
|
23
|
+
if (n())
|
|
24
|
+
return (t = i()) == null ? void 0 : t.experiments;
|
|
25
|
+
}
|
|
26
|
+
function p() {
|
|
27
|
+
var t, r;
|
|
28
|
+
if (n())
|
|
29
|
+
return (r = (t = i()) == null ? void 0 : t.storefront_api) == null ? void 0 : r.token;
|
|
30
|
+
}
|
|
31
|
+
function d() {
|
|
32
|
+
const t = u("shopify-roll"), r = f.get(t);
|
|
33
|
+
try {
|
|
34
|
+
const e = r.json();
|
|
35
|
+
if (typeof e == "number") return e;
|
|
36
|
+
} catch {
|
|
37
|
+
}
|
|
38
|
+
const o = Math.random() * 100;
|
|
39
|
+
return r.set(o), o;
|
|
40
|
+
}
|
|
41
|
+
function C() {
|
|
42
|
+
const t = s();
|
|
43
|
+
if (!t)
|
|
44
|
+
return {};
|
|
45
|
+
const r = d();
|
|
46
|
+
try {
|
|
47
|
+
return t.reduce(
|
|
48
|
+
(o, e) => {
|
|
49
|
+
const c = o ? { ...o } : {};
|
|
50
|
+
return e.enabled && (c[e.id] = {
|
|
51
|
+
name: e.name,
|
|
52
|
+
key: e.version.toString(),
|
|
53
|
+
decide: () => r < e.weight
|
|
54
|
+
}), c;
|
|
55
|
+
},
|
|
56
|
+
{}
|
|
57
|
+
);
|
|
58
|
+
} catch {
|
|
59
|
+
return {};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
export {
|
|
63
|
+
k as a,
|
|
64
|
+
l as b,
|
|
65
|
+
i as c,
|
|
66
|
+
a as d,
|
|
67
|
+
s as e,
|
|
68
|
+
C as f,
|
|
69
|
+
p as g
|
|
70
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const o=require("@picked/client");function i(){if(o.supportsWindow())return globalThis.window.pickedConfig}function s(){var e;if(o.supportsWindow())return(e=i())==null?void 0:e.customer}function d(){var e;if(o.supportsWindow())return(e=i())==null?void 0:e.product}function f(){var e;if(o.supportsWindow())return(e=i())==null?void 0:e.collection}function u(){var e;if(o.supportsWindow())return(e=i())==null?void 0:e.experiments}function g(){var e,n;if(o.supportsWindow())return(n=(e=i())==null?void 0:e.storefront_api)==null?void 0:n.token}function p(){const e=o.createStorageKey("shopify-roll"),n=o.localStore.get(e);try{const t=n.json();if(typeof t=="number")return t}catch{}const r=Math.random()*100;return n.set(r),r}function l(){const e=u();if(!e)return{};const n=p();try{return e.reduce((r,t)=>{const c=r?{...r}:{};return t.enabled&&(c[t.id]={name:t.name,key:t.version.toString(),decide:()=>n<t.weight}),c},{})}catch{return{}}}exports.getPickedConfig=i;exports.getPickedConfigCollection=f;exports.getPickedConfigCustomer=s;exports.getPickedConfigExperiments=u;exports.getPickedConfigFeatureExperiments=l;exports.getPickedConfigProduct=d;exports.getPickedConfigStorefrontApiToken=g;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/shopify/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,MAAM,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/shopify/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAOpD,eAAO,MAAM,aAAa,QAAO,MA8EhC,CAAA"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare function debounce<T extends (...args: any[]) => void>(func: T, wait: number): (...args: Parameters<T>) => void;
|
|
2
|
+
export declare function debounceAsync<T extends (...args: any[]) => any>(func: T, wait: number): (...args: Parameters<T>) => Promise<ReturnType<T>>;
|
|
2
3
|
//# sourceMappingURL=debounce.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debounce.d.ts","sourceRoot":"","sources":["../../../src/utils/debounce.ts"],"names":[],"mappings":"AACA,
|
|
1
|
+
{"version":3,"file":"debounce.d.ts","sourceRoot":"","sources":["../../../src/utils/debounce.ts"],"names":[],"mappings":"AACA,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,IAGxE,GAAG,MAAM,UAAU,CAAC,CAAC,CAAC,KAAG,IAAI,CAStC;AAGD,wBAAgB,aAAa,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,IAI5E,GAAG,MAAM,UAAU,CAAC,CAAC,CAAC,KAAG,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAsBxD"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@picked/shopify",
|
|
3
3
|
"description": "Shopify plugin for @picked/client",
|
|
4
|
-
"version": "0.0.1-dev.
|
|
4
|
+
"version": "0.0.1-dev.1764911630251",
|
|
5
5
|
"dependencies": {},
|
|
6
6
|
"devDependencies": {
|
|
7
7
|
"@picked/client": "workspace:*",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"main": "./dist/cjs/index.js",
|
|
64
64
|
"module": "./dist/esm/index.js",
|
|
65
65
|
"peerDependencies": {
|
|
66
|
-
"@picked/client": "0.0.1-dev.
|
|
66
|
+
"@picked/client": "0.0.1-dev.1764911630251",
|
|
67
67
|
"@shopify/storefront-api-client": "^1.0.9",
|
|
68
68
|
"effector": "^23.3.0"
|
|
69
69
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const n=require("@picked/client");function i(){if(n.supportsWindow())return globalThis.window.pickedConfig}function s(){var e;if(n.supportsWindow())return(e=i())==null?void 0:e.customer}function d(){var e;if(n.supportsWindow())return(e=i())==null?void 0:e.product}function f(){var e;if(n.supportsWindow())return(e=i())==null?void 0:e.collection}function u(){var e;if(n.supportsWindow())return(e=i())==null?void 0:e.experiments}function g(){var e,o;if(n.supportsWindow())return(o=(e=i())==null?void 0:e.storefront_api)==null?void 0:o.token}function p(){const e=n.createStorageKey("shopify-plugin-experiment-roll"),o=n.localStore.get(e);try{const t=o.json();if(typeof t=="number")return t}catch{}const r=Math.random()*100;return o.set(r),r}function l(){const e=u();if(!e)return{};const o=p();try{return e.reduce((r,t)=>{const c=r?{...r}:{};return t.enabled&&(c[t.id]={name:t.name,key:t.version.toString(),decide:()=>o<t.weight}),c},{})}catch{return{}}}exports.getPickedConfig=i;exports.getPickedConfigCollection=f;exports.getPickedConfigCustomer=s;exports.getPickedConfigExperiments=u;exports.getPickedConfigFeatureExperiments=l;exports.getPickedConfigProduct=d;exports.getPickedConfigStorefrontApiToken=g;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { supportsWindow as r, createStorageKey as u, localStore as f } from "@picked/client";
|
|
2
|
-
function i() {
|
|
3
|
-
if (r())
|
|
4
|
-
return globalThis.window.pickedConfig;
|
|
5
|
-
}
|
|
6
|
-
function a() {
|
|
7
|
-
var e;
|
|
8
|
-
if (r())
|
|
9
|
-
return (e = i()) == null ? void 0 : e.customer;
|
|
10
|
-
}
|
|
11
|
-
function l() {
|
|
12
|
-
var e;
|
|
13
|
-
if (r())
|
|
14
|
-
return (e = i()) == null ? void 0 : e.product;
|
|
15
|
-
}
|
|
16
|
-
function p() {
|
|
17
|
-
var e;
|
|
18
|
-
if (r())
|
|
19
|
-
return (e = i()) == null ? void 0 : e.collection;
|
|
20
|
-
}
|
|
21
|
-
function s() {
|
|
22
|
-
var e;
|
|
23
|
-
if (r())
|
|
24
|
-
return (e = i()) == null ? void 0 : e.experiments;
|
|
25
|
-
}
|
|
26
|
-
function k() {
|
|
27
|
-
var e, n;
|
|
28
|
-
if (r())
|
|
29
|
-
return (n = (e = i()) == null ? void 0 : e.storefront_api) == null ? void 0 : n.token;
|
|
30
|
-
}
|
|
31
|
-
function d() {
|
|
32
|
-
const e = u("shopify-plugin-experiment-roll"), n = f.get(e);
|
|
33
|
-
try {
|
|
34
|
-
const t = n.json();
|
|
35
|
-
if (typeof t == "number") return t;
|
|
36
|
-
} catch {
|
|
37
|
-
}
|
|
38
|
-
const o = Math.random() * 100;
|
|
39
|
-
return n.set(o), o;
|
|
40
|
-
}
|
|
41
|
-
function C() {
|
|
42
|
-
const e = s();
|
|
43
|
-
if (!e)
|
|
44
|
-
return {};
|
|
45
|
-
const n = d();
|
|
46
|
-
try {
|
|
47
|
-
return e.reduce(
|
|
48
|
-
(o, t) => {
|
|
49
|
-
const c = o ? { ...o } : {};
|
|
50
|
-
return t.enabled && (c[t.id] = {
|
|
51
|
-
name: t.name,
|
|
52
|
-
key: t.version.toString(),
|
|
53
|
-
decide: () => n < t.weight
|
|
54
|
-
}), c;
|
|
55
|
-
},
|
|
56
|
-
{}
|
|
57
|
-
);
|
|
58
|
-
} catch {
|
|
59
|
-
return {};
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
export {
|
|
63
|
-
p as a,
|
|
64
|
-
l as b,
|
|
65
|
-
i as c,
|
|
66
|
-
a as d,
|
|
67
|
-
s as e,
|
|
68
|
-
C as f,
|
|
69
|
-
k as g
|
|
70
|
-
};
|