@picked/shopify 0.0.35 → 0.0.36-next.1
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/ajax-api/index.js +1 -1
- package/dist/cjs/json-api/index.js +1 -1
- package/dist/cjs/picked-app/index.js +1 -1
- package/dist/cjs/plugins/shopify/index.js +1 -1
- package/dist/cjs/storefront-api/index.js +1 -1
- package/dist/cjs/utils/index.js +1 -1
- package/dist/esm/ajax-api/index.js +1 -1
- package/dist/esm/json-api/index.js +1 -1
- package/dist/esm/picked-app/index.js +1 -1
- package/dist/esm/plugins/shopify/index.js +39 -40
- package/dist/esm/storefront-api/index.js +2 -2
- package/dist/esm/utils/index.js +1 -1
- package/dist/global-obj-DZb8EVvG.cjs +1 -0
- package/dist/global-obj-Dy9uYgrE.js +15 -0
- package/dist/picked-config-C4rg4ENQ.cjs +1 -0
- package/dist/picked-config-DfUZ8EiJ.js +65 -0
- package/dist/{request-CGjDeJdr.cjs → request-BuKr9m4_.cjs} +1 -1
- package/dist/{request-BDRiW21G.js → request-DHywK46g.js} +1 -1
- package/package.json +5 -6
- package/dist/global-obj-DQ6S7d00.js +0 -16
- package/dist/global-obj-OziQiQ8j.cjs +0 -1
- package/dist/picked-config-BmRLdD4G.cjs +0 -1
- package/dist/picked-config-Bx7j5x5b.js +0 -70
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../../request-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../../request-BuKr9m4_.cjs");function c(t){return r.get(`products/${t}.js`)}function o(t,e,n){return r.get(`recommendations/products.json?product_id=${t}&limit=${e}&intent=${n}`)}function s(t){return r.get(`search/suggest.json?q=${t}`)}function u(){return r.get("cart.js")}function i(t){const e=Array.isArray(t)?{items:t}:{items:[t]};return r.post("cart/add.js",e)}function d(t){return r.post("cart/update.js",{...t})}function g(t,e,n){return r.post("cart/change.js",{line:t,quantity:e,properties:n})}function p(){return r.post("cart/clear.js",{})}function h(t){const e=new URLSearchParams;return Object.entries(t).forEach(([n,a])=>{e.append(`shipping_address[${n}]`,a)}),r.get(`cart/shipping_rates.json?${e.toString()}`)}exports.addToCart=i;exports.changeCart=g;exports.clearCart=p;exports.getCart=u;exports.getPredictiveSearch=s;exports.getProduct=c;exports.getProductRecommendations=o;exports.getShippingRates=h;exports.updateCart=d;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../request-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../request-BuKr9m4_.cjs");async function n(t){const{collection:o}=await e.get(`collections/${t}.json`);return{collection:o}}async function l(t,o=20){const{products:c}=await e.get(`collections/${t}/products.json?limit=${o}`);return{products:c}}exports.getCollection=n;exports.getCollectionProducts=l;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../request-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../request-BuKr9m4_.cjs");async function a(t){return e.get(`apps/picked/api/products/${t}/metafields`)}exports.getProductMetadata=a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("@picked/client"),f=require("../../ajax-api/index.js"),
|
|
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-C4rg4ENQ.cjs"),y=require("../../../global-obj-DZb8EVvG.cjs");function P(e,t){let c,r;return(...d)=>(r&&r.reject(new Error("Debounced")),new Promise((o,a)=>{r={resolve:o,reject:a};const g=async()=>{c=void 0;try{const p=await e(...d);r?.resolve(p)}catch(p){r?.reject(p)}finally{r=null}};clearTimeout(c),c=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,l=(e,t)=>{if(t){const c=e.exec(t.pathname);if(c)return c[1]}},u=e=>{switch(e){case"product":return s.getPickedConfigProduct()?.handle??!1;case"collection":return s.getPickedConfigCollection()?.handle??!1;default:return!1}},b={"is-page":({location:e})=>n(i.page,e),"get-page-handle":({location:e})=>l(i.page,e),"is-product-page":()=>!!u("product"),"get-product-handle":()=>u("product"),"is-collection-page":()=>!!u("collection"),"get-collection-handle":()=>u("collection"),"is-blog-page":({location:e})=>n(i.blog,e),"get-blog-handle":({location:e})=>l(i.blog,e),"is-article-page":({location:e})=>n(i.article,e),"get-article-handle":({location:e})=>l(i.article,e),"is-app-proxy-page":({location:e})=>n(i.appProxy,e),"get-app-proxy-handle":({location:e})=>l(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)},m=e=>new Promise(t=>{setTimeout(t,e)}),C=()=>({name:"shopify",setup:e=>{let t={},c=0;const r=async()=>{if(c>=3)return;c++,await f.updateCart({attributes:t}),await m(2e3);const o=await f.getCart();for(const[a,g]of Object.entries(t))if(o.attributes[a]!==g)return r()},d=P(async()=>(c=0,r()),50);Object.entries(b).forEach(([o,a])=>{e.registerPredicate(`shopify-${o}`,a)}),k.supportsWindow()&&e.eventBus.watch(o=>{if(y.supportsShopifyAnalytics()&&(o.type==="session"&&globalThis.window.Shopify.analytics.publish("picked:session",{id:o.id}),o.type==="experience_initialize"||o.type==="feature_decide"||o.type==="initialize"||o.type==="session"||o.type==="user_decide")){const a=e.session;if(a){const g={"picked.id":a.id};typeof a.isUser<"u"&&(g["picked.is_user"]=a.isUser?"true":"false"),e.features.listStore.getState().forEach(p=>{if(p.isResolved){const h=p.getBucket();g[`picked.features.${p.id}`]=`${h.bucket}`}}),t={...t,...g},d().catch(()=>{})}}})}});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,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@shopify/storefront-api-client");require("@picked/client");const p=require("../../picked-config-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@shopify/storefront-api-client");require("@picked/client");const p=require("../../picked-config-C4rg4ENQ.cjs"),f=require("../../global-obj-DZb8EVvG.cjs");function l(t){const o=f.getShopify(),e=p.getPickedConfigStorefrontApiToken();if(!e)throw new Error("Shopify Storefront API token not found. Ensure the Picked Script is enabled on your Shopify storefront");return u.createStorefrontApiClient({storeDomain:o.shop,apiVersion:t.apiVersion,publicAccessToken:e})}const n=()=>{if(!client)throw new Error("Storefront API client not found");return client};async function C(t,o){if(!t)throw new Error("Cart token is required to apply discount codes");const e=n(),i=`gid://shopify/Cart/${t}`,s=`
|
|
2
2
|
mutation cartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!]) {
|
|
3
3
|
cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {
|
|
4
4
|
userErrors {
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../request-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../request-BuKr9m4_.cjs");exports.getRequest=e.get;exports.postRequest=e.post;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { supportsWindow as f } from "@picked/client";
|
|
2
2
|
import { updateCart as y, getCart as h } from "../../ajax-api/index.js";
|
|
3
|
-
import { a as m, b } from "../../../picked-config-
|
|
4
|
-
import { c as j, d as H, e as R, f as _, g as W } from "../../../picked-config-
|
|
5
|
-
import { s as k } from "../../../global-obj-
|
|
6
|
-
import { g as z } from "../../../global-obj-
|
|
3
|
+
import { a as m, b } from "../../../picked-config-DfUZ8EiJ.js";
|
|
4
|
+
import { c as j, d as H, e as R, f as _, g as W } from "../../../picked-config-DfUZ8EiJ.js";
|
|
5
|
+
import { s as k } from "../../../global-obj-Dy9uYgrE.js";
|
|
6
|
+
import { g as z } from "../../../global-obj-Dy9uYgrE.js";
|
|
7
7
|
function P(e, t) {
|
|
8
|
-
let o,
|
|
9
|
-
return (...g) => (
|
|
10
|
-
|
|
8
|
+
let o, r;
|
|
9
|
+
return (...g) => (r && r.reject(new Error("Debounced")), new Promise((i, s) => {
|
|
10
|
+
r = { resolve: i, reject: s };
|
|
11
11
|
const n = async () => {
|
|
12
12
|
o = void 0;
|
|
13
13
|
try {
|
|
14
14
|
const p = await e(...g);
|
|
15
|
-
|
|
15
|
+
r?.resolve(p);
|
|
16
16
|
} catch (p) {
|
|
17
|
-
|
|
17
|
+
r?.reject(p);
|
|
18
18
|
} finally {
|
|
19
|
-
|
|
19
|
+
r = null;
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
clearTimeout(o), o = setTimeout(n, t);
|
|
@@ -33,25 +33,24 @@ const a = {
|
|
|
33
33
|
accountWildcard: /^\/account\/.+/,
|
|
34
34
|
accountLogin: /^\/account\/login(?:\/|$)/,
|
|
35
35
|
accountRegister: /^\/account\/register(?:\/|$)/
|
|
36
|
-
},
|
|
36
|
+
}, c = (e, t) => t ? !!e.exec(t.pathname) : !1, l = (e, t) => {
|
|
37
37
|
if (t) {
|
|
38
38
|
const o = e.exec(t.pathname);
|
|
39
39
|
if (o)
|
|
40
40
|
return o[1];
|
|
41
41
|
}
|
|
42
42
|
}, u = (e) => {
|
|
43
|
-
var t, o;
|
|
44
43
|
switch (e) {
|
|
45
44
|
case "product":
|
|
46
|
-
return
|
|
45
|
+
return b()?.handle ?? !1;
|
|
47
46
|
case "collection":
|
|
48
|
-
return
|
|
47
|
+
return m()?.handle ?? !1;
|
|
49
48
|
default:
|
|
50
49
|
return !1;
|
|
51
50
|
}
|
|
52
51
|
}, x = {
|
|
53
52
|
// Pages
|
|
54
|
-
"is-page": ({ location: e }) =>
|
|
53
|
+
"is-page": ({ location: e }) => c(a.page, e),
|
|
55
54
|
"get-page-handle": ({ location: e }) => l(a.page, e),
|
|
56
55
|
// Products
|
|
57
56
|
"is-product-page": () => !!u("product"),
|
|
@@ -60,52 +59,52 @@ const a = {
|
|
|
60
59
|
"is-collection-page": () => !!u("collection"),
|
|
61
60
|
"get-collection-handle": () => u("collection"),
|
|
62
61
|
// Blogs
|
|
63
|
-
"is-blog-page": ({ location: e }) =>
|
|
62
|
+
"is-blog-page": ({ location: e }) => c(a.blog, e),
|
|
64
63
|
"get-blog-handle": ({ location: e }) => l(a.blog, e),
|
|
65
64
|
// Blog Articles
|
|
66
|
-
"is-article-page": ({ location: e }) =>
|
|
65
|
+
"is-article-page": ({ location: e }) => c(a.article, e),
|
|
67
66
|
"get-article-handle": ({ location: e }) => l(a.article, e),
|
|
68
67
|
// Apps
|
|
69
|
-
"is-app-proxy-page": ({ location: e }) =>
|
|
68
|
+
"is-app-proxy-page": ({ location: e }) => c(a.appProxy, e),
|
|
70
69
|
"get-app-proxy-handle": ({ location: e }) => l(a.appProxy, e),
|
|
71
70
|
// Account
|
|
72
|
-
"is-account-page": ({ location: e }) =>
|
|
73
|
-
"is-login-page": ({ location: e }) =>
|
|
74
|
-
"is-register-page": ({ location: e }) =>
|
|
71
|
+
"is-account-page": ({ location: e }) => c(a.accountWildcard, e),
|
|
72
|
+
"is-login-page": ({ location: e }) => c(a.accountLogin, e),
|
|
73
|
+
"is-register-page": ({ location: e }) => c(a.accountRegister, e),
|
|
75
74
|
// Cart
|
|
76
|
-
"is-cart-page": ({ location: e }) =>
|
|
75
|
+
"is-cart-page": ({ location: e }) => c(a.cart, e),
|
|
77
76
|
// Checkout
|
|
78
|
-
"is-checkout-page": ({ location: e }) =>
|
|
77
|
+
"is-checkout-page": ({ location: e }) => c(a.checkout, e),
|
|
79
78
|
// Homepage
|
|
80
|
-
"is-homepage": ({ location: e }) =>
|
|
79
|
+
"is-homepage": ({ location: e }) => c(a.homepage, e)
|
|
81
80
|
}, w = (e) => new Promise((t) => {
|
|
82
81
|
setTimeout(t, e);
|
|
83
82
|
}), E = () => ({
|
|
84
83
|
name: "shopify",
|
|
85
84
|
setup: (e) => {
|
|
86
85
|
let t = {}, o = 0;
|
|
87
|
-
const
|
|
86
|
+
const r = async () => {
|
|
88
87
|
if (o >= 3) return;
|
|
89
88
|
o++, await y({
|
|
90
89
|
attributes: t
|
|
91
90
|
}), await w(2e3);
|
|
92
|
-
const
|
|
93
|
-
for (const [
|
|
94
|
-
if (
|
|
95
|
-
return
|
|
96
|
-
}, g = P(async () => (o = 0,
|
|
97
|
-
Object.entries(x).forEach(([
|
|
98
|
-
e.registerPredicate(`shopify-${
|
|
99
|
-
}), f() && e.eventBus.watch((
|
|
100
|
-
if (k() && (
|
|
101
|
-
id:
|
|
102
|
-
}),
|
|
103
|
-
const
|
|
104
|
-
if (
|
|
91
|
+
const i = await h();
|
|
92
|
+
for (const [s, n] of Object.entries(t))
|
|
93
|
+
if (i.attributes[s] !== n)
|
|
94
|
+
return r();
|
|
95
|
+
}, g = P(async () => (o = 0, r()), 50);
|
|
96
|
+
Object.entries(x).forEach(([i, s]) => {
|
|
97
|
+
e.registerPredicate(`shopify-${i}`, s);
|
|
98
|
+
}), f() && e.eventBus.watch((i) => {
|
|
99
|
+
if (k() && (i.type === "session" && globalThis.window.Shopify.analytics.publish("picked:session", {
|
|
100
|
+
id: i.id
|
|
101
|
+
}), i.type === "experience_initialize" || i.type === "feature_decide" || i.type === "initialize" || i.type === "session" || i.type === "user_decide")) {
|
|
102
|
+
const s = e.session;
|
|
103
|
+
if (s) {
|
|
105
104
|
const n = {
|
|
106
|
-
"picked.id":
|
|
105
|
+
"picked.id": s.id
|
|
107
106
|
};
|
|
108
|
-
typeof
|
|
107
|
+
typeof s.isUser < "u" && (n["picked.is_user"] = s.isUser ? "true" : "false"), e.features.listStore.getState().forEach((p) => {
|
|
109
108
|
if (p.isResolved) {
|
|
110
109
|
const d = p.getBucket();
|
|
111
110
|
n[`picked.features.${p.id}`] = `${d.bucket}`;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createStorefrontApiClient as d } from "@shopify/storefront-api-client";
|
|
2
2
|
import "@picked/client";
|
|
3
|
-
import { g as p } from "../../picked-config-
|
|
4
|
-
import { g as f } from "../../global-obj-
|
|
3
|
+
import { g as p } from "../../picked-config-DfUZ8EiJ.js";
|
|
4
|
+
import { g as f } from "../../global-obj-Dy9uYgrE.js";
|
|
5
5
|
function S(t) {
|
|
6
6
|
const r = f(), o = p();
|
|
7
7
|
if (!o)
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const i=require("@picked/client");function o(){if(!i.supportsWindow()||!globalThis.window.Shopify)throw new Error("Shopify global object not found. This plugin must be used on a Shopify storefront page.");return globalThis.window.Shopify}function t(n){return typeof o().analytics?.publish=="function"}exports.getShopify=o;exports.supportsShopifyAnalytics=t;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { supportsWindow as o } from "@picked/client";
|
|
2
|
+
function i() {
|
|
3
|
+
if (!o() || !globalThis.window.Shopify)
|
|
4
|
+
throw new Error(
|
|
5
|
+
"Shopify global object not found. This plugin must be used on a Shopify storefront page."
|
|
6
|
+
);
|
|
7
|
+
return globalThis.window.Shopify;
|
|
8
|
+
}
|
|
9
|
+
function p(n) {
|
|
10
|
+
return typeof i().analytics?.publish == "function";
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
i as g,
|
|
14
|
+
p as s
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("@picked/client");function n(){if(e.supportsWindow())return e.getPickedConfig()}function s(){if(e.supportsWindow())return n()?.customer}function f(){if(e.supportsWindow())return n()?.product}function d(){if(e.supportsWindow())return n()?.collection}function u(){if(e.supportsWindow())return n()?.experiments}function g(){if(e.supportsWindow())return n()?.storefront_api?.token}function p(){const r=e.createStorageKey("shopify-roll"),i=e.localStore.get(r);try{const t=i.json();if(typeof t=="number")return t}catch{}const o=Math.random()*100;return i.set(o),o}function k(){const r=u();if(!r)return{};const i=p();try{return r.reduce((o,t)=>{const c=o?{...o}:{};return t.enabled&&(c[t.id]={name:t.name,key:t.version.toString(),decide:()=>i<t.weight}),c},{})}catch{return{}}}exports.getPickedConfig=n;exports.getPickedConfigCollection=d;exports.getPickedConfigCustomer=s;exports.getPickedConfigExperiments=u;exports.getPickedConfigFeatureExperiments=k;exports.getPickedConfigProduct=f;exports.getPickedConfigStorefrontApiToken=g;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { supportsWindow as e, getPickedConfig as u, createStorageKey as f, localStore as s } from "@picked/client";
|
|
2
|
+
function n() {
|
|
3
|
+
if (e())
|
|
4
|
+
return u();
|
|
5
|
+
}
|
|
6
|
+
function l() {
|
|
7
|
+
if (e())
|
|
8
|
+
return n()?.customer;
|
|
9
|
+
}
|
|
10
|
+
function k() {
|
|
11
|
+
if (e())
|
|
12
|
+
return n()?.product;
|
|
13
|
+
}
|
|
14
|
+
function C() {
|
|
15
|
+
if (e())
|
|
16
|
+
return n()?.collection;
|
|
17
|
+
}
|
|
18
|
+
function d() {
|
|
19
|
+
if (e())
|
|
20
|
+
return n()?.experiments;
|
|
21
|
+
}
|
|
22
|
+
function P() {
|
|
23
|
+
if (e())
|
|
24
|
+
return n()?.storefront_api?.token;
|
|
25
|
+
}
|
|
26
|
+
function g() {
|
|
27
|
+
const o = f("shopify-roll"), i = s.get(o);
|
|
28
|
+
try {
|
|
29
|
+
const t = i.json();
|
|
30
|
+
if (typeof t == "number") return t;
|
|
31
|
+
} catch {
|
|
32
|
+
}
|
|
33
|
+
const r = Math.random() * 100;
|
|
34
|
+
return i.set(r), r;
|
|
35
|
+
}
|
|
36
|
+
function p() {
|
|
37
|
+
const o = d();
|
|
38
|
+
if (!o)
|
|
39
|
+
return {};
|
|
40
|
+
const i = g();
|
|
41
|
+
try {
|
|
42
|
+
return o.reduce(
|
|
43
|
+
(r, t) => {
|
|
44
|
+
const c = r ? { ...r } : {};
|
|
45
|
+
return t.enabled && (c[t.id] = {
|
|
46
|
+
name: t.name,
|
|
47
|
+
key: t.version.toString(),
|
|
48
|
+
decide: () => i < t.weight
|
|
49
|
+
}), c;
|
|
50
|
+
},
|
|
51
|
+
{}
|
|
52
|
+
);
|
|
53
|
+
} catch {
|
|
54
|
+
return {};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
C as a,
|
|
59
|
+
k as b,
|
|
60
|
+
n as c,
|
|
61
|
+
l as d,
|
|
62
|
+
d as e,
|
|
63
|
+
p as f,
|
|
64
|
+
P as g
|
|
65
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("@picked/client");const s=require("./global-obj-
|
|
1
|
+
"use strict";require("@picked/client");const s=require("./global-obj-DZb8EVvG.cjs");function r(){const t=s.getShopify();return new URL(`${globalThis.window.location.origin}${t.routes.root}`)}async function i(t){const n=new URL(t,r()),o=await fetch(n.toString());if(!o.ok)throw new Error(o.statusText);return o.json()}async function c(t,n){const o=new URL(t,r()),e=await fetch(o.toString(),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!e.ok)throw new Error(e.statusText);return e.json()}exports.get=i;exports.post=c;
|
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@picked/shopify",
|
|
3
3
|
"description": "Shopify plugin for @picked/client",
|
|
4
|
-
"version": "0.0.
|
|
5
|
-
"dependencies": {},
|
|
4
|
+
"version": "0.0.36-next.1",
|
|
6
5
|
"devDependencies": {
|
|
7
6
|
"@picked/client": "workspace:*",
|
|
8
7
|
"@repo/eslint-config": "workspace:*",
|
|
@@ -11,13 +10,13 @@
|
|
|
11
10
|
"@shopify/storefront-api-client": "^1.0.9",
|
|
12
11
|
"@types/jsdom": "^21.1.7",
|
|
13
12
|
"@types/node": "^22",
|
|
14
|
-
"@vitest/coverage-v8": "^
|
|
13
|
+
"@vitest/coverage-v8": "^4.0.17",
|
|
15
14
|
"effector": "^23.3.0",
|
|
16
15
|
"tsup": "^8.5.0",
|
|
17
16
|
"tsx": "^4.20.3",
|
|
18
|
-
"vite": "^
|
|
17
|
+
"vite": "^7.3.1",
|
|
19
18
|
"vite-plugin-dts": "^4.5.4",
|
|
20
|
-
"vitest": "^
|
|
19
|
+
"vitest": "^4.0.17"
|
|
21
20
|
},
|
|
22
21
|
"exports": {
|
|
23
22
|
".": {
|
|
@@ -69,7 +68,7 @@
|
|
|
69
68
|
"main": "./dist/cjs/index.js",
|
|
70
69
|
"module": "./dist/esm/index.js",
|
|
71
70
|
"peerDependencies": {
|
|
72
|
-
"@picked/client": "0.0.
|
|
71
|
+
"@picked/client": "0.0.36-next.1",
|
|
73
72
|
"@shopify/storefront-api-client": "^1.0.9",
|
|
74
73
|
"effector": "^23.3.0"
|
|
75
74
|
},
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { supportsWindow as i } from "@picked/client";
|
|
2
|
-
function n() {
|
|
3
|
-
if (!i() || !globalThis.window.Shopify)
|
|
4
|
-
throw new Error(
|
|
5
|
-
"Shopify global object not found. This plugin must be used on a Shopify storefront page."
|
|
6
|
-
);
|
|
7
|
-
return globalThis.window.Shopify;
|
|
8
|
-
}
|
|
9
|
-
function s(t) {
|
|
10
|
-
var o;
|
|
11
|
-
return typeof ((o = n().analytics) == null ? void 0 : o.publish) == "function";
|
|
12
|
-
}
|
|
13
|
-
export {
|
|
14
|
-
n as g,
|
|
15
|
-
s
|
|
16
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const t=require("@picked/client");function i(){if(!t.supportsWindow()||!globalThis.window.Shopify)throw new Error("Shopify global object not found. This plugin must be used on a Shopify storefront page.");return globalThis.window.Shopify}function n(s){var o;return typeof((o=i().analytics)==null?void 0:o.publish)=="function"}exports.getShopify=i;exports.supportsShopifyAnalytics=n;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const t=require("@picked/client");function r(){if(t.supportsWindow())return t.getPickedConfig()}function s(){var e;if(t.supportsWindow())return(e=r())==null?void 0:e.customer}function f(){var e;if(t.supportsWindow())return(e=r())==null?void 0:e.product}function d(){var e;if(t.supportsWindow())return(e=r())==null?void 0:e.collection}function u(){var e;if(t.supportsWindow())return(e=r())==null?void 0:e.experiments}function g(){var e,o;if(t.supportsWindow())return(o=(e=r())==null?void 0:e.storefront_api)==null?void 0:o.token}function p(){const e=t.createStorageKey("shopify-roll"),o=t.localStore.get(e);try{const n=o.json();if(typeof n=="number")return n}catch{}const i=Math.random()*100;return o.set(i),i}function k(){const e=u();if(!e)return{};const o=p();try{return e.reduce((i,n)=>{const c=i?{...i}:{};return n.enabled&&(c[n.id]={name:n.name,key:n.version.toString(),decide:()=>o<n.weight}),c},{})}catch{return{}}}exports.getPickedConfig=r;exports.getPickedConfigCollection=d;exports.getPickedConfigCustomer=s;exports.getPickedConfigExperiments=u;exports.getPickedConfigFeatureExperiments=k;exports.getPickedConfigProduct=f;exports.getPickedConfigStorefrontApiToken=g;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { supportsWindow as n, getPickedConfig as u, createStorageKey as f, localStore as s } from "@picked/client";
|
|
2
|
-
function i() {
|
|
3
|
-
if (n())
|
|
4
|
-
return u();
|
|
5
|
-
}
|
|
6
|
-
function l() {
|
|
7
|
-
var t;
|
|
8
|
-
if (n())
|
|
9
|
-
return (t = i()) == null ? void 0 : t.customer;
|
|
10
|
-
}
|
|
11
|
-
function k() {
|
|
12
|
-
var t;
|
|
13
|
-
if (n())
|
|
14
|
-
return (t = i()) == null ? void 0 : t.product;
|
|
15
|
-
}
|
|
16
|
-
function C() {
|
|
17
|
-
var t;
|
|
18
|
-
if (n())
|
|
19
|
-
return (t = i()) == null ? void 0 : t.collection;
|
|
20
|
-
}
|
|
21
|
-
function d() {
|
|
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 g() {
|
|
32
|
-
const t = f("shopify-roll"), r = s.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 p() {
|
|
42
|
-
const t = d();
|
|
43
|
-
if (!t)
|
|
44
|
-
return {};
|
|
45
|
-
const r = g();
|
|
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
|
-
C as a,
|
|
64
|
-
k as b,
|
|
65
|
-
i as c,
|
|
66
|
-
l as d,
|
|
67
|
-
d as e,
|
|
68
|
-
p as f,
|
|
69
|
-
P as g
|
|
70
|
-
};
|