@picked/shopify 0.0.23-next.1 → 0.0.23-next.3

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 u=require("@picked/client"),f=require("../../ajax-api/index.js"),a=require("../../../picked-config-DfcDhMyM.cjs"),l=require("../../../global-obj-OziQiQ8j.cjs");function h(e,i){let t;return(...n)=>{const s=()=>{t=void 0,e(...n)};clearTimeout(t),t=setTimeout(s,i)}}const o={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(?:\/|$)/},c=(e,i)=>i?!!e.exec(i.pathname):!1,r=(e,i)=>{if(i){const t=e.exec(i.pathname);if(t)return t[1]}},g=e=>{var i,t;switch(e){case"product":return((i=a.getPickedConfigProduct())==null?void 0:i.handle)??!1;case"collection":return((t=a.getPickedConfigCollection())==null?void 0:t.handle)??!1;default:return!1}},k={"is-page":({location:e})=>c(o.page,e),"get-page-handle":({location:e})=>r(o.page,e),"is-product-page":()=>!!g("product"),"get-product-handle":()=>g("product"),"is-collection-page":()=>!!g("collection"),"get-collection-handle":()=>g("collection"),"is-blog-page":({location:e})=>c(o.blog,e),"get-blog-handle":({location:e})=>r(o.blog,e),"is-article-page":({location:e})=>c(o.article,e),"get-article-handle":({location:e})=>r(o.article,e),"is-app-proxy-page":({location:e})=>c(o.appProxy,e),"get-app-proxy-handle":({location:e})=>r(o.appProxy,e),"is-account-page":({location:e})=>c(o.accountWildcard,e),"is-login-page":({location:e})=>c(o.accountLogin,e),"is-register-page":({location:e})=>c(o.accountRegister,e),"is-cart-page":({location:e})=>c(o.cart,e),"is-checkout-page":({location:e})=>c(o.checkout,e),"is-homepage":({location:e})=>c(o.homepage,e)},P=()=>({name:"shopify",setup:e=>{if(Object.entries(k).forEach(([i,t])=>{e.registerPredicate(`shopify-${i}`,t)}),u.supportsWindow()){const i=h(f.updateCart,50);e.eventBus.watch(t=>{if(l.supportsShopifyAnalytics()&&(t.type==="session"&&globalThis.window.Shopify.analytics.publish("picked:session",{id:t.id}),t.type==="feature_decide"||t.type==="session")){const n=e.session;if(n){const s={"picked.id":n.id};typeof n.isUser<"u"&&(s["picked.is_user"]=n.isUser?"true":"false"),e.features.listStore.getState().forEach(p=>{if(p.isResolved){const d=p.getBucket();s[`picked.features.${p.id}`]=`${d.bucket}`}}),i({attributes:s})}}})}}});exports.getPickedConfig=a.getPickedConfig;exports.getPickedConfigCollection=a.getPickedConfigCollection;exports.getPickedConfigCustomer=a.getPickedConfigCustomer;exports.getPickedConfigExperiments=a.getPickedConfigExperiments;exports.getPickedConfigFeatureExperiments=a.getPickedConfigFeatureExperiments;exports.getPickedConfigProduct=a.getPickedConfigProduct;exports.getPickedConfigStorefrontApiToken=a.getPickedConfigStorefrontApiToken;exports.getShopify=l.getShopify;exports.shopifyPlugin=P;
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,17 +1,26 @@
1
- import { supportsWindow as l } from "@picked/client";
2
- import { updateCart as u } from "../../ajax-api/index.js";
3
- import { a as d, b as f } from "../../../picked-config-B69J6txs.js";
4
- import { c as E, d as S, e as T, f as w, g as H } from "../../../picked-config-B69J6txs.js";
5
- import { s as h } from "../../../global-obj-DQ6S7d00.js";
6
- import { g as v } from "../../../global-obj-DQ6S7d00.js";
7
- function m(e, o) {
8
- let t;
9
- return (...c) => {
10
- const s = () => {
11
- t = void 0, e(...c);
1
+ import { supportsWindow as f } from "@picked/client";
2
+ import { updateCart as y, getCart as h } from "../../ajax-api/index.js";
3
+ import { a as m, b } 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
+ import { s as k } from "../../../global-obj-DQ6S7d00.js";
6
+ import { g as z } from "../../../global-obj-DQ6S7d00.js";
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 };
11
+ const n = async () => {
12
+ o = 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
+ }
12
21
  };
13
- clearTimeout(t), t = setTimeout(s, o);
14
- };
22
+ clearTimeout(o), o = setTimeout(n, t);
23
+ }));
15
24
  }
16
25
  const a = {
17
26
  homepage: /^\/$/,
@@ -24,89 +33,100 @@ const a = {
24
33
  accountWildcard: /^\/account\/.+/,
25
34
  accountLogin: /^\/account\/login(?:\/|$)/,
26
35
  accountRegister: /^\/account\/register(?:\/|$)/
27
- }, i = (e, o) => o ? !!e.exec(o.pathname) : !1, r = (e, o) => {
28
- if (o) {
29
- const t = e.exec(o.pathname);
30
- if (t)
31
- return t[1];
36
+ }, r = (e, t) => t ? !!e.exec(t.pathname) : !1, l = (e, t) => {
37
+ if (t) {
38
+ const o = e.exec(t.pathname);
39
+ if (o)
40
+ return o[1];
32
41
  }
33
- }, n = (e) => {
34
- var o, t;
42
+ }, u = (e) => {
43
+ var t, o;
35
44
  switch (e) {
36
45
  case "product":
37
- return ((o = f()) == null ? void 0 : o.handle) ?? !1;
46
+ return ((t = b()) == null ? void 0 : t.handle) ?? !1;
38
47
  case "collection":
39
- return ((t = d()) == null ? void 0 : t.handle) ?? !1;
48
+ return ((o = m()) == null ? void 0 : o.handle) ?? !1;
40
49
  default:
41
50
  return !1;
42
51
  }
43
- }, y = {
52
+ }, x = {
44
53
  // Pages
45
- "is-page": ({ location: e }) => i(a.page, e),
46
- "get-page-handle": ({ location: e }) => r(a.page, e),
54
+ "is-page": ({ location: e }) => r(a.page, e),
55
+ "get-page-handle": ({ location: e }) => l(a.page, e),
47
56
  // Products
48
- "is-product-page": () => !!n("product"),
49
- "get-product-handle": () => n("product"),
57
+ "is-product-page": () => !!u("product"),
58
+ "get-product-handle": () => u("product"),
50
59
  // Collections
51
- "is-collection-page": () => !!n("collection"),
52
- "get-collection-handle": () => n("collection"),
60
+ "is-collection-page": () => !!u("collection"),
61
+ "get-collection-handle": () => u("collection"),
53
62
  // Blogs
54
- "is-blog-page": ({ location: e }) => i(a.blog, e),
55
- "get-blog-handle": ({ location: e }) => r(a.blog, e),
63
+ "is-blog-page": ({ location: e }) => r(a.blog, e),
64
+ "get-blog-handle": ({ location: e }) => l(a.blog, e),
56
65
  // Blog Articles
57
- "is-article-page": ({ location: e }) => i(a.article, e),
58
- "get-article-handle": ({ location: e }) => r(a.article, e),
66
+ "is-article-page": ({ location: e }) => r(a.article, e),
67
+ "get-article-handle": ({ location: e }) => l(a.article, e),
59
68
  // Apps
60
- "is-app-proxy-page": ({ location: e }) => i(a.appProxy, e),
61
- "get-app-proxy-handle": ({ location: e }) => r(a.appProxy, e),
69
+ "is-app-proxy-page": ({ location: e }) => r(a.appProxy, e),
70
+ "get-app-proxy-handle": ({ location: e }) => l(a.appProxy, e),
62
71
  // Account
63
- "is-account-page": ({ location: e }) => i(a.accountWildcard, e),
64
- "is-login-page": ({ location: e }) => i(a.accountLogin, e),
65
- "is-register-page": ({ location: e }) => i(a.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),
66
75
  // Cart
67
- "is-cart-page": ({ location: e }) => i(a.cart, e),
76
+ "is-cart-page": ({ location: e }) => r(a.cart, e),
68
77
  // Checkout
69
- "is-checkout-page": ({ location: e }) => i(a.checkout, e),
78
+ "is-checkout-page": ({ location: e }) => r(a.checkout, e),
70
79
  // Homepage
71
- "is-homepage": ({ location: e }) => i(a.homepage, e)
72
- }, C = () => ({
80
+ "is-homepage": ({ location: e }) => r(a.homepage, e)
81
+ }, w = (e) => new Promise((t) => {
82
+ setTimeout(t, e);
83
+ }), E = () => ({
73
84
  name: "shopify",
74
85
  setup: (e) => {
75
- if (Object.entries(y).forEach(([o, t]) => {
76
- e.registerPredicate(`shopify-${o}`, t);
77
- }), l()) {
78
- const o = m(u, 50);
79
- e.eventBus.watch((t) => {
80
- if (h() && (t.type === "session" && globalThis.window.Shopify.analytics.publish("picked:session", {
81
- id: t.id
82
- }), t.type === "feature_decide" || t.type === "session")) {
83
- const c = e.session;
84
- if (c) {
85
- const s = {
86
- "picked.id": c.id
87
- };
88
- typeof c.isUser < "u" && (s["picked.is_user"] = c.isUser ? "true" : "false"), e.features.listStore.getState().forEach((p) => {
89
- if (p.isResolved) {
90
- const g = p.getBucket();
91
- s[`picked.features.${p.id}`] = `${g.bucket}`;
92
- }
93
- }), o({
94
- attributes: s
95
- });
96
- }
86
+ let t = {}, o = 0;
87
+ const i = async () => {
88
+ if (o >= 3) return;
89
+ o++, await y({
90
+ attributes: t
91
+ }), 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) {
105
+ const n = {
106
+ "picked.id": c.id
107
+ };
108
+ typeof c.isUser < "u" && (n["picked.is_user"] = c.isUser ? "true" : "false"), e.features.listStore.getState().forEach((p) => {
109
+ if (p.isResolved) {
110
+ const d = p.getBucket();
111
+ n[`picked.features.${p.id}`] = `${d.bucket}`;
112
+ }
113
+ }), t = {
114
+ ...t,
115
+ ...n
116
+ }, g();
97
117
  }
98
- });
99
- }
118
+ }
119
+ });
100
120
  }
101
121
  });
102
122
  export {
103
- E as getPickedConfig,
104
- d as getPickedConfigCollection,
105
- S as getPickedConfigCustomer,
106
- T as getPickedConfigExperiments,
107
- w as getPickedConfigFeatureExperiments,
108
- f as getPickedConfigProduct,
109
- H as getPickedConfigStorefrontApiToken,
110
- v as getShopify,
111
- C as shopifyPlugin
123
+ j as getPickedConfig,
124
+ m as getPickedConfigCollection,
125
+ H as getPickedConfigCustomer,
126
+ R as getPickedConfigExperiments,
127
+ _ as getPickedConfigFeatureExperiments,
128
+ b as getPickedConfigProduct,
129
+ v as getPickedConfigStorefrontApiToken,
130
+ z as getShopify,
131
+ E as shopifyPlugin
112
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,MAuDhC,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"}
@@ -1,2 +1,3 @@
1
- export default function debounce<T extends (...args: any[]) => void>(func: T, wait: number): (...args: Parameters<T>) => void;
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,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,IAGhF,GAAG,MAAM,UAAU,CAAC,CAAC,CAAC,KAAG,IAAI,CAStC"}
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.23-next.1",
4
+ "version": "0.0.23-next.3",
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.23-next.1",
66
+ "@picked/client": "0.0.23-next.3",
67
67
  "@shopify/storefront-api-client": "^1.0.9",
68
68
  "effector": "^23.3.0"
69
69
  },