@picked/shopify 0.0.1-dev.1769474304876 → 0.0.1-dev.1769554766412

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../../request-CGjDeJdr.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
+ "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-CGjDeJdr.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
+ "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-CGjDeJdr.cjs");async function a(t){return e.get(`apps/picked/api/products/${t}/metafields`)}exports.getProductMetadata=a;
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"),n=require("../../../picked-config-BmRLdD4G.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 l=async()=>{o=void 0;try{const g=await e(...d);c==null||c.resolve(g)}catch(g){c==null||c.reject(g)}finally{c=null}};clearTimeout(o),o=setTimeout(l,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(?:\/|$)/},s=(e,t)=>t?!!e.exec(t.pathname):!1,p=(e,t)=>{if(t){const o=e.exec(t.pathname);if(o)return o[1]}},u=e=>{var t,o;switch(e){case"product":return((t=n.getPickedConfigProduct())==null?void 0:t.handle)??!1;case"collection":return((o=n.getPickedConfigCollection())==null?void 0:o.handle)??!1;default:return!1}},b={"is-page":({location:e})=>s(i.page,e),"get-page-handle":({location:e})=>p(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})=>s(i.blog,e),"get-blog-handle":({location:e})=>p(i.blog,e),"is-article-page":({location:e})=>s(i.article,e),"get-article-handle":({location:e})=>p(i.article,e),"is-app-proxy-page":({location:e})=>s(i.appProxy,e),"get-app-proxy-handle":({location:e})=>p(i.appProxy,e),"is-account-page":({location:e})=>s(i.accountWildcard,e),"is-login-page":({location:e})=>s(i.accountLogin,e),"is-register-page":({location:e})=>s(i.accountRegister,e),"is-cart-page":({location:e})=>s(i.cart,e),"is-checkout-page":({location:e})=>s(i.checkout,e),"is-homepage":({location:e})=>s(i.homepage,e)},m=e=>new Promise(t=>{setTimeout(t,e)}),C=()=>({name:"shopify",setup:e=>{let t={},o=0;const c=async()=>{if(o>=3)return;o++,await f.updateCart({attributes:t}),await m(2e3);const a=await f.getCart();for(const[r,l]of Object.entries(t))if(a.attributes[r]!==l)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==="experience_initialize"||a.type==="feature_decide"||a.type==="initialize"||a.type==="session"||a.type==="user_decide")){const r=e.session;if(r){const l={"picked.id":r.id};typeof r.isUser<"u"&&(l["picked.is_user"]=r.isUser?"true":"false"),e.features.listStore.getState().forEach(g=>{if(g.isResolved){const h=g.getBucket();l[`picked.features.${g.id}`]=`${h.bucket}`}}),t={...t,...l},d().catch(()=>{})}}})}});exports.getPickedConfig=n.getPickedConfig;exports.getPickedConfigCollection=n.getPickedConfigCollection;exports.getPickedConfigCustomer=n.getPickedConfigCustomer;exports.getPickedConfigExperiments=n.getPickedConfigExperiments;exports.getPickedConfigFeatureExperiments=n.getPickedConfigFeatureExperiments;exports.getPickedConfigProduct=n.getPickedConfigProduct;exports.getPickedConfigStorefrontApiToken=n.getPickedConfigStorefrontApiToken;exports.getShopify=y.getShopify;exports.shopifyPlugin=C;
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-BmRLdD4G.cjs"),f=require("../../global-obj-OziQiQ8j.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=`
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 {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../request-CGjDeJdr.cjs");exports.getRequest=e.get;exports.postRequest=e.post;
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,4 +1,4 @@
1
- import { g as e, p as a } from "../../request-BDRiW21G.js";
1
+ import { g as e, p as a } from "../../request-DHywK46g.js";
2
2
  function s(t) {
3
3
  return e(`products/${t}.js`);
4
4
  }
@@ -1,4 +1,4 @@
1
- import { g as c } from "../../request-BDRiW21G.js";
1
+ import { g as c } from "../../request-DHywK46g.js";
2
2
  async function s(o) {
3
3
  const { collection: t } = await c(`collections/${o}.json`);
4
4
  return { collection: t };
@@ -1,4 +1,4 @@
1
- import { g as a } from "../../request-BDRiW21G.js";
1
+ import { g as a } from "../../request-DHywK46g.js";
2
2
  async function p(t) {
3
3
  return a(`apps/picked/api/products/${t}/metafields`);
4
4
  }
@@ -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-Bx7j5x5b.js";
4
- import { c as j, d as H, e as R, f as _, g as W } from "../../../picked-config-Bx7j5x5b.js";
5
- import { s as k } from "../../../global-obj-DQ6S7d00.js";
6
- import { g as z } from "../../../global-obj-DQ6S7d00.js";
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, i;
9
- return (...g) => (i && i.reject(new Error("Debounced")), new Promise((s, c) => {
10
- i = { resolve: s, reject: c };
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
- i == null || i.resolve(p);
15
+ r?.resolve(p);
16
16
  } catch (p) {
17
- i == null || i.reject(p);
17
+ r?.reject(p);
18
18
  } finally {
19
- i = null;
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
- }, r = (e, t) => t ? !!e.exec(t.pathname) : !1, l = (e, t) => {
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 ((t = b()) == null ? void 0 : t.handle) ?? !1;
45
+ return b()?.handle ?? !1;
47
46
  case "collection":
48
- return ((o = m()) == null ? void 0 : o.handle) ?? !1;
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 }) => r(a.page, 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 }) => r(a.blog, 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 }) => r(a.article, 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 }) => r(a.appProxy, 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 }) => r(a.accountWildcard, e),
73
- "is-login-page": ({ location: e }) => r(a.accountLogin, e),
74
- "is-register-page": ({ location: e }) => r(a.accountRegister, 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 }) => r(a.cart, e),
75
+ "is-cart-page": ({ location: e }) => c(a.cart, e),
77
76
  // Checkout
78
- "is-checkout-page": ({ location: e }) => r(a.checkout, e),
77
+ "is-checkout-page": ({ location: e }) => c(a.checkout, e),
79
78
  // Homepage
80
- "is-homepage": ({ location: e }) => r(a.homepage, 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 i = async () => {
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 s = await h();
93
- for (const [c, n] of Object.entries(t))
94
- if (s.attributes[c] !== n)
95
- return i();
96
- }, g = P(async () => (o = 0, i()), 50);
97
- Object.entries(x).forEach(([s, c]) => {
98
- e.registerPredicate(`shopify-${s}`, c);
99
- }), f() && e.eventBus.watch((s) => {
100
- if (k() && (s.type === "session" && globalThis.window.Shopify.analytics.publish("picked:session", {
101
- id: s.id
102
- }), s.type === "experience_initialize" || s.type === "feature_decide" || s.type === "initialize" || s.type === "session" || s.type === "user_decide")) {
103
- const c = e.session;
104
- if (c) {
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": c.id
105
+ "picked.id": s.id
107
106
  };
108
- typeof c.isUser < "u" && (n["picked.is_user"] = c.isUser ? "true" : "false"), e.features.listStore.getState().forEach((p) => {
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-Bx7j5x5b.js";
4
- import { g as f } from "../../global-obj-DQ6S7d00.js";
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)
@@ -1,4 +1,4 @@
1
- import { g as t, p as o } from "../../request-BDRiW21G.js";
1
+ import { g as t, p as o } from "../../request-DHywK46g.js";
2
2
  export {
3
3
  t as getRequest,
4
4
  o as postRequest
@@ -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-OziQiQ8j.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;
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;
@@ -1,5 +1,5 @@
1
1
  import "@picked/client";
2
- import { g as e } from "./global-obj-DQ6S7d00.js";
2
+ import { g as e } from "./global-obj-Dy9uYgrE.js";
3
3
  function s() {
4
4
  const t = e();
5
5
  return new URL(`${globalThis.window.location.origin}${t.routes.root}`);
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.1-dev.1769474304876",
5
- "dependencies": {},
4
+ "version": "0.0.1-dev.1769554766412",
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": "^3.2.4",
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": "^6.4.1",
17
+ "vite": "^7.3.1",
19
18
  "vite-plugin-dts": "^4.5.4",
20
- "vitest": "^3.2.4"
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.1-dev.1769474304876",
71
+ "@picked/client": "0.0.1-dev.1769554766412",
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
- };