@picked/shopify 0.0.1-dev.1764090824933 → 0.0.1-dev.1764096269522
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/plugins/shopify/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/plugins/shopify/index.js +66 -45
- package/dist/esm/utils/index.js +1 -1
- package/dist/request-3iRvPhXG.cjs +1 -0
- package/dist/request-CgVZHVbc.js +28 -0
- package/dist/types/plugins/shopify/plugin.d.ts.map +1 -1
- package/dist/types/utils/debounce.d.ts +2 -0
- package/dist/types/utils/debounce.d.ts.map +1 -0
- package/package.json +2 -2
- package/dist/request-CdrE2oln.js +0 -28
- package/dist/request-TZ1Wihiu.cjs +0 -1
|
@@ -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-3iRvPhXG.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-3iRvPhXG.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
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@picked/client"),u=require("../../ajax-api/index.js"),a=require("../../../picked-config-OpJ03CX7.cjs"),p=require("../../../global-obj-Cvtghh3D.cjs"),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(?:\/|$)/},c=(e,o)=>o?!!e.exec(o.pathname):!1,r=(e,o)=>{if(o){const t=e.exec(o.pathname);if(t)return t[1]}},g=e=>{var o,t;switch(e){case"product":return((o=a.getPickedConfigProduct())==null?void 0:o.handle)??!1;case"collection":return((t=a.getPickedConfigCollection())==null?void 0:t.handle)??!1;default:return!1}},d={"is-page":({location:e})=>c(i.page,e),"get-page-handle":({location:e})=>r(i.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(i.blog,e),"get-blog-handle":({location:e})=>r(i.blog,e),"is-article-page":({location:e})=>c(i.article,e),"get-article-handle":({location:e})=>r(i.article,e),"is-app-proxy-page":({location:e})=>c(i.appProxy,e),"get-app-proxy-handle":({location:e})=>r(i.appProxy,e),"is-account-page":({location:e})=>c(i.accountWildcard,e),"is-login-page":({location:e})=>c(i.accountLogin,e),"is-register-page":({location:e})=>c(i.accountRegister,e),"is-cart-page":({location:e})=>c(i.cart,e),"is-checkout-page":({location:e})=>c(i.checkout,e),"is-homepage":({location:e})=>c(i.homepage,e)};function f(e,o){let t;return(...n)=>{const s=()=>{t=void 0,e(...n)};clearTimeout(t),t=setTimeout(s,o)}}const h=()=>({name:"shopify",setup:e=>{if(Object.entries(d).forEach(([o,t])=>{e.registerPredicate(`shopify-${o}`,t)}),l.supportsWindow()){const o=f(u.updateCart,500);let t={};e.eventBus.watch(n=>{if(p.supportsShopifyAnalytics()){if(n.type==="session"&&(globalThis.window.Shopify.analytics.publish("picked:session",{id:n.id}),t["picked.id"]=n.id),n.type==="feature_decide"){const s=`picked.feature:${n.feature.id}`;t[s]=n.feature.bucket?"true":"false"}o({attributes:t})}})}}});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=p.getShopify;exports.shopifyPlugin=h;
|
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-3iRvPhXG.cjs");exports.getRequest=e.get;exports.postRequest=e.post;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { supportsWindow as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
1
|
+
import { supportsWindow as p } from "@picked/client";
|
|
2
|
+
import { updateCart as g } from "../../ajax-api/index.js";
|
|
3
|
+
import { a as l, b as u } from "../../../picked-config-DcKNgPpy.js";
|
|
4
|
+
import { c as $, d as B, e as T, f as w, g as E } from "../../../picked-config-DcKNgPpy.js";
|
|
5
|
+
import { s as d } from "../../../global-obj-Qsw8OZYk.js";
|
|
6
|
+
import { g as S } from "../../../global-obj-Qsw8OZYk.js";
|
|
7
|
+
const o = {
|
|
7
8
|
homepage: /^\/$/,
|
|
8
9
|
page: /(?:^|\/)pages\/(?<pageHandle>[^/]+)\/?$/,
|
|
9
10
|
blog: /(?:^|\/)blogs\/(?<blogHandle>[^/]+)\/?$/,
|
|
@@ -14,26 +15,26 @@ const a = {
|
|
|
14
15
|
accountWildcard: /^\/account\/.+/,
|
|
15
16
|
accountLogin: /^\/account\/login(?:\/|$)/,
|
|
16
17
|
accountRegister: /^\/account\/register(?:\/|$)/
|
|
17
|
-
},
|
|
18
|
-
if (
|
|
19
|
-
const
|
|
20
|
-
if (
|
|
21
|
-
return
|
|
18
|
+
}, i = (e, a) => a ? !!e.exec(a.pathname) : !1, r = (e, a) => {
|
|
19
|
+
if (a) {
|
|
20
|
+
const t = e.exec(a.pathname);
|
|
21
|
+
if (t)
|
|
22
|
+
return t[1];
|
|
22
23
|
}
|
|
23
24
|
}, s = (e) => {
|
|
24
|
-
var
|
|
25
|
+
var a, t;
|
|
25
26
|
switch (e) {
|
|
26
27
|
case "product":
|
|
27
|
-
return ((
|
|
28
|
+
return ((a = u()) == null ? void 0 : a.handle) ?? !1;
|
|
28
29
|
case "collection":
|
|
29
|
-
return ((
|
|
30
|
+
return ((t = l()) == null ? void 0 : t.handle) ?? !1;
|
|
30
31
|
default:
|
|
31
32
|
return !1;
|
|
32
33
|
}
|
|
33
|
-
},
|
|
34
|
+
}, f = {
|
|
34
35
|
// Pages
|
|
35
|
-
"is-page": ({ location: e }) =>
|
|
36
|
-
"get-page-handle": ({ location: e }) =>
|
|
36
|
+
"is-page": ({ location: e }) => i(o.page, e),
|
|
37
|
+
"get-page-handle": ({ location: e }) => r(o.page, e),
|
|
37
38
|
// Products
|
|
38
39
|
"is-product-page": () => !!s("product"),
|
|
39
40
|
"get-product-handle": () => s("product"),
|
|
@@ -41,44 +42,64 @@ const a = {
|
|
|
41
42
|
"is-collection-page": () => !!s("collection"),
|
|
42
43
|
"get-collection-handle": () => s("collection"),
|
|
43
44
|
// Blogs
|
|
44
|
-
"is-blog-page": ({ location: e }) =>
|
|
45
|
-
"get-blog-handle": ({ location: e }) =>
|
|
45
|
+
"is-blog-page": ({ location: e }) => i(o.blog, e),
|
|
46
|
+
"get-blog-handle": ({ location: e }) => r(o.blog, e),
|
|
46
47
|
// Blog Articles
|
|
47
|
-
"is-article-page": ({ location: e }) =>
|
|
48
|
-
"get-article-handle": ({ location: e }) =>
|
|
48
|
+
"is-article-page": ({ location: e }) => i(o.article, e),
|
|
49
|
+
"get-article-handle": ({ location: e }) => r(o.article, e),
|
|
49
50
|
// Apps
|
|
50
|
-
"is-app-proxy-page": ({ location: e }) =>
|
|
51
|
-
"get-app-proxy-handle": ({ location: e }) =>
|
|
51
|
+
"is-app-proxy-page": ({ location: e }) => i(o.appProxy, e),
|
|
52
|
+
"get-app-proxy-handle": ({ location: e }) => r(o.appProxy, e),
|
|
52
53
|
// Account
|
|
53
|
-
"is-account-page": ({ location: e }) =>
|
|
54
|
-
"is-login-page": ({ location: e }) =>
|
|
55
|
-
"is-register-page": ({ location: e }) =>
|
|
54
|
+
"is-account-page": ({ location: e }) => i(o.accountWildcard, e),
|
|
55
|
+
"is-login-page": ({ location: e }) => i(o.accountLogin, e),
|
|
56
|
+
"is-register-page": ({ location: e }) => i(o.accountRegister, e),
|
|
56
57
|
// Cart
|
|
57
|
-
"is-cart-page": ({ location: e }) =>
|
|
58
|
+
"is-cart-page": ({ location: e }) => i(o.cart, e),
|
|
58
59
|
// Checkout
|
|
59
|
-
"is-checkout-page": ({ location: e }) =>
|
|
60
|
+
"is-checkout-page": ({ location: e }) => i(o.checkout, e),
|
|
60
61
|
// Homepage
|
|
61
|
-
"is-homepage": ({ location: e }) =>
|
|
62
|
-
}
|
|
62
|
+
"is-homepage": ({ location: e }) => i(o.homepage, e)
|
|
63
|
+
};
|
|
64
|
+
function h(e, a) {
|
|
65
|
+
let t;
|
|
66
|
+
return (...c) => {
|
|
67
|
+
const n = () => {
|
|
68
|
+
t = void 0, e(...c);
|
|
69
|
+
};
|
|
70
|
+
clearTimeout(t), t = setTimeout(n, a);
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
const P = () => ({
|
|
63
74
|
name: "shopify",
|
|
64
75
|
setup: (e) => {
|
|
65
|
-
Object.entries(
|
|
66
|
-
e.registerPredicate(`shopify-${
|
|
67
|
-
}),
|
|
68
|
-
|
|
69
|
-
|
|
76
|
+
if (Object.entries(f).forEach(([a, t]) => {
|
|
77
|
+
e.registerPredicate(`shopify-${a}`, t);
|
|
78
|
+
}), p()) {
|
|
79
|
+
const a = h(g, 500);
|
|
80
|
+
let t = {};
|
|
81
|
+
e.eventBus.watch((c) => {
|
|
82
|
+
if (d()) {
|
|
83
|
+
if (c.type === "session" && (globalThis.window.Shopify.analytics.publish("picked:session", {
|
|
84
|
+
id: c.id
|
|
85
|
+
}), t["picked.id"] = c.id), c.type === "feature_decide") {
|
|
86
|
+
const n = `picked.feature:${c.feature.id}`;
|
|
87
|
+
t[n] = c.feature.bucket ? "true" : "false";
|
|
88
|
+
}
|
|
89
|
+
a({ attributes: t });
|
|
90
|
+
}
|
|
70
91
|
});
|
|
71
|
-
}
|
|
92
|
+
}
|
|
72
93
|
}
|
|
73
94
|
});
|
|
74
95
|
export {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
96
|
+
$ as getPickedConfig,
|
|
97
|
+
l as getPickedConfigCollection,
|
|
98
|
+
B as getPickedConfigCustomer,
|
|
99
|
+
T as getPickedConfigExperiments,
|
|
100
|
+
w as getPickedConfigFeatureExperiments,
|
|
101
|
+
u as getPickedConfigProduct,
|
|
102
|
+
E as getPickedConfigStorefrontApiToken,
|
|
103
|
+
S as getShopify,
|
|
104
|
+
P as shopifyPlugin
|
|
84
105
|
};
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";require("@picked/client");const s=require("./global-obj-Cvtghh3D.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;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import "@picked/client";
|
|
2
|
+
import { g as e } from "./global-obj-Qsw8OZYk.js";
|
|
3
|
+
function s() {
|
|
4
|
+
const t = e();
|
|
5
|
+
return new URL(`${globalThis.window.location.origin}${t.routes.root}`);
|
|
6
|
+
}
|
|
7
|
+
async function c(t) {
|
|
8
|
+
const n = new URL(t, s()), o = await fetch(n.toString());
|
|
9
|
+
if (!o.ok)
|
|
10
|
+
throw new Error(o.statusText);
|
|
11
|
+
return o.json();
|
|
12
|
+
}
|
|
13
|
+
async function p(t, n) {
|
|
14
|
+
const o = new URL(t, s()), r = await fetch(o.toString(), {
|
|
15
|
+
method: "POST",
|
|
16
|
+
headers: {
|
|
17
|
+
"Content-Type": "application/json"
|
|
18
|
+
},
|
|
19
|
+
body: JSON.stringify(n)
|
|
20
|
+
});
|
|
21
|
+
if (!r.ok)
|
|
22
|
+
throw new Error(r.statusText);
|
|
23
|
+
return r.json();
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
c as g,
|
|
27
|
+
p
|
|
28
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/shopify/plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAU,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/shopify/plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAU,MAAM,gBAAgB,CAAA;AAMpD,eAAO,MAAM,aAAa,QAAO,MAyChC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debounce.d.ts","sourceRoot":"","sources":["../../../src/utils/debounce.ts"],"names":[],"mappings":"AAAA,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"}
|
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.1764096269522",
|
|
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.1764096269522",
|
|
67
67
|
"@shopify/storefront-api-client": "^1.0.9",
|
|
68
68
|
"effector": "^23.3.0"
|
|
69
69
|
},
|
package/dist/request-CdrE2oln.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import "@picked/client";
|
|
2
|
-
import { g as e } from "./global-obj-Qsw8OZYk.js";
|
|
3
|
-
function r() {
|
|
4
|
-
const t = e();
|
|
5
|
-
return new URL(`https://${t.shop}${t.routes.root}`);
|
|
6
|
-
}
|
|
7
|
-
async function p(t) {
|
|
8
|
-
const n = new URL(t, r()), o = await fetch(n.toString());
|
|
9
|
-
if (!o.ok)
|
|
10
|
-
throw new Error(o.statusText);
|
|
11
|
-
return o.json();
|
|
12
|
-
}
|
|
13
|
-
async function c(t, n) {
|
|
14
|
-
const o = new URL(t, r()), s = await fetch(o.toString(), {
|
|
15
|
-
method: "POST",
|
|
16
|
-
headers: {
|
|
17
|
-
"Content-Type": "application/json"
|
|
18
|
-
},
|
|
19
|
-
body: JSON.stringify(n)
|
|
20
|
-
});
|
|
21
|
-
if (!s.ok)
|
|
22
|
-
throw new Error(s.statusText);
|
|
23
|
-
return s.json();
|
|
24
|
-
}
|
|
25
|
-
export {
|
|
26
|
-
p as g,
|
|
27
|
-
c as p
|
|
28
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";require("@picked/client");const r=require("./global-obj-Cvtghh3D.cjs");function s(){const t=r.getShopify();return new URL(`https://${t.shop}${t.routes.root}`)}async function i(t){const n=new URL(t,s()),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,s()),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;
|