@picked/shopify 0.0.1-dev.1764911630251 → 0.0.1-dev.1764916608146

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 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
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("@picked/client"),f=require("../../ajax-api/index.js"),n=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 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()}}})}});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,15 +1,15 @@
1
1
  import { supportsWindow as f } from "@picked/client";
2
- import { updateCart as h, getCart as y } from "../../ajax-api/index.js";
2
+ import { updateCart as y, getCart as h } from "../../ajax-api/index.js";
3
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";
4
+ import { c as j, d as H, e as R, f as _, g as v } from "../../../picked-config-B69J6txs.js";
5
5
  import { s as k } from "../../../global-obj-DQ6S7d00.js";
6
- import { g as L } from "../../../global-obj-DQ6S7d00.js";
6
+ import { g as z } from "../../../global-obj-DQ6S7d00.js";
7
7
  function P(e, t) {
8
- let a, i;
8
+ let o, i;
9
9
  return (...g) => (i && i.reject(new Error("Debounced")), new Promise((s, c) => {
10
10
  i = { resolve: s, reject: c };
11
11
  const n = async () => {
12
- a = void 0;
12
+ o = void 0;
13
13
  try {
14
14
  const p = await e(...g);
15
15
  i == null || i.resolve(p);
@@ -19,10 +19,10 @@ function P(e, t) {
19
19
  i = null;
20
20
  }
21
21
  };
22
- clearTimeout(a), a = setTimeout(n, t);
22
+ clearTimeout(o), o = setTimeout(n, t);
23
23
  }));
24
24
  }
25
- const o = {
25
+ const a = {
26
26
  homepage: /^\/$/,
27
27
  page: /(?:^|\/)pages\/(?<pageHandle>[^/]+)\/?$/,
28
28
  blog: /(?:^|\/)blogs\/(?<blogHandle>[^/]+)\/?$/,
@@ -35,24 +35,24 @@ const o = {
35
35
  accountRegister: /^\/account\/register(?:\/|$)/
36
36
  }, r = (e, t) => t ? !!e.exec(t.pathname) : !1, l = (e, t) => {
37
37
  if (t) {
38
- const a = e.exec(t.pathname);
39
- if (a)
40
- return a[1];
38
+ const o = e.exec(t.pathname);
39
+ if (o)
40
+ return o[1];
41
41
  }
42
42
  }, u = (e) => {
43
- var t, a;
43
+ var t, o;
44
44
  switch (e) {
45
45
  case "product":
46
46
  return ((t = b()) == null ? void 0 : t.handle) ?? !1;
47
47
  case "collection":
48
- return ((a = m()) == null ? void 0 : a.handle) ?? !1;
48
+ return ((o = m()) == null ? void 0 : o.handle) ?? !1;
49
49
  default:
50
50
  return !1;
51
51
  }
52
52
  }, x = {
53
53
  // Pages
54
- "is-page": ({ location: e }) => r(o.page, e),
55
- "get-page-handle": ({ location: e }) => l(o.page, e),
54
+ "is-page": ({ location: e }) => r(a.page, e),
55
+ "get-page-handle": ({ location: e }) => l(a.page, e),
56
56
  // Products
57
57
  "is-product-page": () => !!u("product"),
58
58
  "get-product-handle": () => u("product"),
@@ -60,44 +60,46 @@ const o = {
60
60
  "is-collection-page": () => !!u("collection"),
61
61
  "get-collection-handle": () => u("collection"),
62
62
  // Blogs
63
- "is-blog-page": ({ location: e }) => r(o.blog, e),
64
- "get-blog-handle": ({ location: e }) => l(o.blog, e),
63
+ "is-blog-page": ({ location: e }) => r(a.blog, e),
64
+ "get-blog-handle": ({ location: e }) => l(a.blog, e),
65
65
  // Blog Articles
66
- "is-article-page": ({ location: e }) => r(o.article, e),
67
- "get-article-handle": ({ location: e }) => l(o.article, e),
66
+ "is-article-page": ({ location: e }) => r(a.article, e),
67
+ "get-article-handle": ({ location: e }) => l(a.article, e),
68
68
  // Apps
69
- "is-app-proxy-page": ({ location: e }) => r(o.appProxy, e),
70
- "get-app-proxy-handle": ({ location: e }) => l(o.appProxy, e),
69
+ "is-app-proxy-page": ({ location: e }) => r(a.appProxy, e),
70
+ "get-app-proxy-handle": ({ location: e }) => l(a.appProxy, e),
71
71
  // Account
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),
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),
75
75
  // Cart
76
- "is-cart-page": ({ location: e }) => r(o.cart, e),
76
+ "is-cart-page": ({ location: e }) => r(a.cart, e),
77
77
  // Checkout
78
- "is-checkout-page": ({ location: e }) => r(o.checkout, e),
78
+ "is-checkout-page": ({ location: e }) => r(a.checkout, e),
79
79
  // Homepage
80
- "is-homepage": ({ location: e }) => r(o.homepage, e)
81
- }, B = () => ({
80
+ "is-homepage": ({ location: e }) => r(a.homepage, e)
81
+ }, w = (e) => new Promise((t) => {
82
+ setTimeout(t, e);
83
+ }), E = () => ({
82
84
  name: "shopify",
83
85
  setup: (e) => {
84
- let t = {}, a = 0;
86
+ let t = {}, o = 0;
85
87
  const i = async () => {
86
- if (a >= 3) return;
87
- a++, await h({
88
+ if (o >= 3) return;
89
+ o++, await y({
88
90
  attributes: t
89
- });
90
- const s = await y();
91
+ }), await w(2e3);
92
+ const s = await h();
91
93
  for (const [c, n] of Object.entries(t))
92
94
  if (s.attributes[c] !== n)
93
95
  return i();
94
- }, g = P(async () => (a = 0, i()), 50);
96
+ }, g = P(async () => (o = 0, i()), 50);
95
97
  Object.entries(x).forEach(([s, c]) => {
96
98
  e.registerPredicate(`shopify-${s}`, c);
97
99
  }), f() && e.eventBus.watch((s) => {
98
100
  if (k() && (s.type === "session" && globalThis.window.Shopify.analytics.publish("picked:session", {
99
101
  id: s.id
100
- }), s.type === "feature_decide" || s.type === "session")) {
102
+ }), s.type === "experience_initialize" || s.type === "feature_decide" || s.type === "initialize" || s.type === "session" || s.type === "user_decide")) {
101
103
  const c = e.session;
102
104
  if (c) {
103
105
  const n = {
@@ -118,13 +120,13 @@ const o = {
118
120
  }
119
121
  });
120
122
  export {
121
- S as getPickedConfig,
123
+ j as getPickedConfig,
122
124
  m as getPickedConfigCollection,
123
- T as getPickedConfigCustomer,
124
- j as getPickedConfigExperiments,
125
- H as getPickedConfigFeatureExperiments,
125
+ H as getPickedConfigCustomer,
126
+ R as getPickedConfigExperiments,
127
+ _ as getPickedConfigFeatureExperiments,
126
128
  b as getPickedConfigProduct,
127
- R as getPickedConfigStorefrontApiToken,
128
- L as getShopify,
129
- B as shopifyPlugin
129
+ v as getPickedConfigStorefrontApiToken,
130
+ z as getShopify,
131
+ E as shopifyPlugin
130
132
  };
@@ -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;AAOpD,eAAO,MAAM,aAAa,QAAO,MA8EhC,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;AAYpD,eAAO,MAAM,aAAa,QAAO,MAuFhC,CAAA"}
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.1764911630251",
4
+ "version": "0.0.1-dev.1764916608146",
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.1764911630251",
66
+ "@picked/client": "0.0.1-dev.1764916608146",
67
67
  "@shopify/storefront-api-client": "^1.0.9",
68
68
  "effector": "^23.3.0"
69
69
  },