@picked/shopify 0.0.1-dev.1777938796953 → 0.0.1-dev.1778136207545
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/ajax-api-B4PP6DsE.js +237 -0
- package/dist/ajax-api-DqEv8M8X.cjs +1 -0
- 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 +1 -1
- package/dist/esm/storefront-api/index.js +1 -1
- package/dist/esm/utils/index.js +1 -1
- package/dist/types/plugins/shopify/plugin.d.ts +10 -0
- package/dist/types/plugins/shopify/plugin.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/ajax-api-BDy6OWHE.cjs +0 -1
- package/dist/ajax-api-Ci7vlv1u.js +0 -215
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { createStorageKey as e, getPickedConfig as t, localStore as n, supportsWindow as r } from "@picked/client";
|
|
2
|
+
import { attach as i, createEffect as a, sample as o } from "effector";
|
|
3
|
+
//#region src/utils/debounce.ts
|
|
4
|
+
function s(e, t) {
|
|
5
|
+
let n, r;
|
|
6
|
+
return (...i) => (r && r.reject(/* @__PURE__ */ Error("Debounced")), new Promise((a, o) => {
|
|
7
|
+
r = {
|
|
8
|
+
resolve: a,
|
|
9
|
+
reject: o
|
|
10
|
+
}, clearTimeout(n), n = setTimeout(async () => {
|
|
11
|
+
n = void 0;
|
|
12
|
+
try {
|
|
13
|
+
let t = await e(...i);
|
|
14
|
+
r?.resolve(t);
|
|
15
|
+
} catch (e) {
|
|
16
|
+
r?.reject(e);
|
|
17
|
+
} finally {
|
|
18
|
+
r = null;
|
|
19
|
+
}
|
|
20
|
+
}, t);
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/plugins/shopify/picked-config.ts
|
|
25
|
+
function c() {
|
|
26
|
+
if (r()) return t();
|
|
27
|
+
}
|
|
28
|
+
function l() {
|
|
29
|
+
if (r()) return c()?.customer;
|
|
30
|
+
}
|
|
31
|
+
function u() {
|
|
32
|
+
if (r()) return c()?.product;
|
|
33
|
+
}
|
|
34
|
+
function d() {
|
|
35
|
+
if (r()) return c()?.collection;
|
|
36
|
+
}
|
|
37
|
+
function f() {
|
|
38
|
+
if (r()) return c()?.experiments;
|
|
39
|
+
}
|
|
40
|
+
function p() {
|
|
41
|
+
if (r()) return c()?.storefront_api?.token;
|
|
42
|
+
}
|
|
43
|
+
function m() {
|
|
44
|
+
let t = e("shopify-roll"), r = n.get(t);
|
|
45
|
+
try {
|
|
46
|
+
let e = r.json();
|
|
47
|
+
if (typeof e == "number") return e;
|
|
48
|
+
} catch {}
|
|
49
|
+
let i = Math.random() * 100;
|
|
50
|
+
return r.set(i), i;
|
|
51
|
+
}
|
|
52
|
+
function h() {
|
|
53
|
+
let e = f();
|
|
54
|
+
if (!e) return {};
|
|
55
|
+
let t = m();
|
|
56
|
+
try {
|
|
57
|
+
return e.reduce((e, n) => {
|
|
58
|
+
let r = e ? { ...e } : {};
|
|
59
|
+
return n.enabled && (r[n.id] = {
|
|
60
|
+
name: n.name,
|
|
61
|
+
key: n.version.toString(),
|
|
62
|
+
decide: () => t < n.weight
|
|
63
|
+
}), r;
|
|
64
|
+
}, {});
|
|
65
|
+
} catch {
|
|
66
|
+
return {};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/plugins/shopify/predicates.ts
|
|
71
|
+
var g = {
|
|
72
|
+
homepage: /^\/$/,
|
|
73
|
+
productPage: /(?:^|\/)products\/(?<productHandle>[^/]+)\/?$/,
|
|
74
|
+
collection: /^\/collections\/[^/]+\/?$/,
|
|
75
|
+
page: /(?:^|\/)pages\/(?<pageHandle>[^/]+)\/?$/,
|
|
76
|
+
blog: /(?:^|\/)blogs\/(?<blogHandle>[^/]+)\/?$/,
|
|
77
|
+
article: /^\/blogs\/[^/]+\/(?<article>[^/]+)\/?$/,
|
|
78
|
+
cart: /(?:^|\/)cart\/[^/]+$/,
|
|
79
|
+
checkout: /^\/checkout\/.+/,
|
|
80
|
+
appProxy: /^\/(?:a|apps|community|tools)\/(?<proxyTarget>[^/]+)/,
|
|
81
|
+
accountWildcard: /^\/account\/.+/,
|
|
82
|
+
accountLogin: /^\/account\/login(?:\/|$)/,
|
|
83
|
+
accountRegister: /^\/account\/register(?:\/|$)/,
|
|
84
|
+
accountRecover: /^\/account\/login#recover$/
|
|
85
|
+
}, _ = (e, t) => t ? !!e.exec(t.pathname) : !1, v = (e, t) => {
|
|
86
|
+
if (t) {
|
|
87
|
+
let n = e.exec(t.pathname);
|
|
88
|
+
if (n) return n[1];
|
|
89
|
+
}
|
|
90
|
+
}, y = (e) => {
|
|
91
|
+
switch (e) {
|
|
92
|
+
case "product": return u()?.handle ?? !1;
|
|
93
|
+
case "collection": return d()?.handle ?? !1;
|
|
94
|
+
default: return !1;
|
|
95
|
+
}
|
|
96
|
+
}, b = {
|
|
97
|
+
"is-page": ({ location: e }) => _(g.page, e),
|
|
98
|
+
"get-page-handle": ({ location: e }) => v(g.page, e),
|
|
99
|
+
"is-product-page": () => !!y("product"),
|
|
100
|
+
"get-product-handle": () => y("product"),
|
|
101
|
+
"is-collection-page": () => !!y("collection"),
|
|
102
|
+
"get-collection-handle": () => y("collection"),
|
|
103
|
+
"is-blog-page": ({ location: e }) => _(g.blog, e),
|
|
104
|
+
"get-blog-handle": ({ location: e }) => v(g.blog, e),
|
|
105
|
+
"is-article-page": ({ location: e }) => _(g.article, e),
|
|
106
|
+
"get-article-handle": ({ location: e }) => v(g.article, e),
|
|
107
|
+
"is-app-proxy-page": ({ location: e }) => _(g.appProxy, e),
|
|
108
|
+
"get-app-proxy-handle": ({ location: e }) => v(g.appProxy, e),
|
|
109
|
+
"is-account-page": ({ location: e }) => _(g.accountWildcard, e),
|
|
110
|
+
"is-login-page": ({ location: e }) => _(g.accountLogin, e),
|
|
111
|
+
"is-register-page": ({ location: e }) => _(g.accountRegister, e),
|
|
112
|
+
"is-cart-page": ({ location: e }) => _(g.cart, e),
|
|
113
|
+
"is-checkout-page": ({ location: e }) => _(g.checkout, e),
|
|
114
|
+
"is-homepage": ({ location: e }) => _(g.homepage, e)
|
|
115
|
+
};
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region src/plugins/shopify/global-obj.ts
|
|
118
|
+
function x() {
|
|
119
|
+
if (!r() || !globalThis.window.Shopify) throw Error("Shopify global object not found. This plugin must be used on a Shopify storefront page.");
|
|
120
|
+
return globalThis.window.Shopify;
|
|
121
|
+
}
|
|
122
|
+
function S(e) {
|
|
123
|
+
return typeof x().analytics?.publish == "function";
|
|
124
|
+
}
|
|
125
|
+
//#endregion
|
|
126
|
+
//#region src/plugins/shopify/plugin.ts
|
|
127
|
+
var C = (e) => new Promise((t) => {
|
|
128
|
+
setTimeout(t, e);
|
|
129
|
+
}), w = new Set([
|
|
130
|
+
"experience_initialize",
|
|
131
|
+
"feature_decide",
|
|
132
|
+
"initialize",
|
|
133
|
+
"session",
|
|
134
|
+
"user_decide"
|
|
135
|
+
]), T = () => ({
|
|
136
|
+
name: "shopify",
|
|
137
|
+
setup: (e) => {
|
|
138
|
+
let t = {}, n = 0, c = async () => {
|
|
139
|
+
if (n >= 3) return;
|
|
140
|
+
n++, await P({ attributes: t }), await C(2e3);
|
|
141
|
+
let e = await M();
|
|
142
|
+
for (let [n, r] of Object.entries(t)) if (e.attributes[n] !== r) return c();
|
|
143
|
+
}, l = s(async () => (n = 0, c()), 50);
|
|
144
|
+
if (Object.entries(b).forEach(([t, n]) => {
|
|
145
|
+
e.registerPredicate(`shopify-${t}`, n);
|
|
146
|
+
}), !r()) return;
|
|
147
|
+
let u = e.session.store.map((e) => e.id), d = e.session.store.map((e) => e.isUser, { skipVoid: !1 }), f = a((e) => {
|
|
148
|
+
e.type === "session" && S(globalThis.window) && globalThis.window.Shopify.analytics.publish("picked:session", { id: e.id });
|
|
149
|
+
}), p = i({
|
|
150
|
+
source: {
|
|
151
|
+
sessionId: u,
|
|
152
|
+
isUser: d,
|
|
153
|
+
features: e.features.listStore
|
|
154
|
+
},
|
|
155
|
+
effect: ({ sessionId: e, isUser: n, features: r }) => {
|
|
156
|
+
if (!S(globalThis.window) || !e) return;
|
|
157
|
+
let i = { "picked.id": e };
|
|
158
|
+
n !== void 0 && (i["picked.is_user"] = n ? "true" : "false"), r.forEach((e) => {
|
|
159
|
+
if (e.isResolved) {
|
|
160
|
+
let t = e.getBucket();
|
|
161
|
+
i[`picked.features.${e.id}`] = `${t.bucket}`;
|
|
162
|
+
}
|
|
163
|
+
}), t = {
|
|
164
|
+
...t,
|
|
165
|
+
...i
|
|
166
|
+
}, l().catch(() => {});
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
o({
|
|
170
|
+
clock: e.eventBus,
|
|
171
|
+
filter: (e) => e.type === "session",
|
|
172
|
+
target: f
|
|
173
|
+
}), o({
|
|
174
|
+
clock: e.eventBus,
|
|
175
|
+
filter: (e) => w.has(e.type),
|
|
176
|
+
target: p
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
//#endregion
|
|
181
|
+
//#region src/utils/request.ts
|
|
182
|
+
function E() {
|
|
183
|
+
let e = x();
|
|
184
|
+
return new URL(`${globalThis.window.location.origin}${e.routes.root}`);
|
|
185
|
+
}
|
|
186
|
+
async function D(e) {
|
|
187
|
+
let t = new URL(e, E()), n = await fetch(t.toString());
|
|
188
|
+
if (!n.ok) throw Error(n.statusText);
|
|
189
|
+
return n.json();
|
|
190
|
+
}
|
|
191
|
+
async function O(e, t) {
|
|
192
|
+
let n = new URL(e, E()), r = await fetch(n.toString(), {
|
|
193
|
+
method: "POST",
|
|
194
|
+
headers: { "Content-Type": "application/json" },
|
|
195
|
+
body: JSON.stringify(t)
|
|
196
|
+
});
|
|
197
|
+
if (!r.ok) throw Error(r.statusText);
|
|
198
|
+
return r.json();
|
|
199
|
+
}
|
|
200
|
+
//#endregion
|
|
201
|
+
//#region src/ajax-api/index.ts
|
|
202
|
+
function k(e) {
|
|
203
|
+
return D(`products/${e}.js`);
|
|
204
|
+
}
|
|
205
|
+
function A(e, t, n) {
|
|
206
|
+
return D(`recommendations/products.json?product_id=${e}&limit=${t}&intent=${n}`);
|
|
207
|
+
}
|
|
208
|
+
function j(e) {
|
|
209
|
+
return D(`search/suggest.json?q=${e}`);
|
|
210
|
+
}
|
|
211
|
+
function M() {
|
|
212
|
+
return D("cart.js");
|
|
213
|
+
}
|
|
214
|
+
function N(e) {
|
|
215
|
+
return O("cart/add.js", Array.isArray(e) ? { items: e } : { items: [e] });
|
|
216
|
+
}
|
|
217
|
+
function P(e) {
|
|
218
|
+
return O("cart/update.js", { ...e });
|
|
219
|
+
}
|
|
220
|
+
function F(e, t, n) {
|
|
221
|
+
return O("cart/change.js", {
|
|
222
|
+
line: e,
|
|
223
|
+
quantity: t,
|
|
224
|
+
properties: n
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
function I() {
|
|
228
|
+
return O("cart/clear.js", {});
|
|
229
|
+
}
|
|
230
|
+
function L(e) {
|
|
231
|
+
let t = new URLSearchParams();
|
|
232
|
+
return Object.entries(e).forEach(([e, n]) => {
|
|
233
|
+
t.append(`shipping_address[${e}]`, n);
|
|
234
|
+
}), D(`cart/shipping_rates.json?${t.toString()}`);
|
|
235
|
+
}
|
|
236
|
+
//#endregion
|
|
237
|
+
export { f as _, j as a, p as b, L as c, O as d, T as f, l as g, d as h, M as i, P as l, c as m, F as n, k as o, x as p, I as r, A as s, N as t, D as u, h as v, u as y };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
let e=require(`@picked/client`),t=require(`effector`);function n(e,t){let n,r;return(...i)=>(r&&r.reject(Error(`Debounced`)),new Promise((a,o)=>{r={resolve:a,reject:o},clearTimeout(n),n=setTimeout(async()=>{n=void 0;try{let t=await e(...i);r?.resolve(t)}catch(e){r?.reject(e)}finally{r=null}},t)}))}function r(){if((0,e.supportsWindow)())return(0,e.getPickedConfig)()}function i(){if((0,e.supportsWindow)())return r()?.customer}function a(){if((0,e.supportsWindow)())return r()?.product}function o(){if((0,e.supportsWindow)())return r()?.collection}function s(){if((0,e.supportsWindow)())return r()?.experiments}function c(){if((0,e.supportsWindow)())return r()?.storefront_api?.token}function l(){let t=(0,e.createStorageKey)(`shopify-roll`),n=e.localStore.get(t);try{let e=n.json();if(typeof e==`number`)return e}catch{}let r=Math.random()*100;return n.set(r),r}function u(){let e=s();if(!e)return{};let t=l();try{return e.reduce((e,n)=>{let r=e?{...e}:{};return n.enabled&&(r[n.id]={name:n.name,key:n.version.toString(),decide:()=>t<n.weight}),r},{})}catch{return{}}}var d={homepage:/^\/$/,productPage:/(?:^|\/)products\/(?<productHandle>[^/]+)\/?$/,collection:/^\/collections\/[^/]+\/?$/,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(?:\/|$)/,accountRecover:/^\/account\/login#recover$/},f=(e,t)=>t?!!e.exec(t.pathname):!1,p=(e,t)=>{if(t){let n=e.exec(t.pathname);if(n)return n[1]}},m=e=>{switch(e){case`product`:return a()?.handle??!1;case`collection`:return o()?.handle??!1;default:return!1}},h={"is-page":({location:e})=>f(d.page,e),"get-page-handle":({location:e})=>p(d.page,e),"is-product-page":()=>!!m(`product`),"get-product-handle":()=>m(`product`),"is-collection-page":()=>!!m(`collection`),"get-collection-handle":()=>m(`collection`),"is-blog-page":({location:e})=>f(d.blog,e),"get-blog-handle":({location:e})=>p(d.blog,e),"is-article-page":({location:e})=>f(d.article,e),"get-article-handle":({location:e})=>p(d.article,e),"is-app-proxy-page":({location:e})=>f(d.appProxy,e),"get-app-proxy-handle":({location:e})=>p(d.appProxy,e),"is-account-page":({location:e})=>f(d.accountWildcard,e),"is-login-page":({location:e})=>f(d.accountLogin,e),"is-register-page":({location:e})=>f(d.accountRegister,e),"is-cart-page":({location:e})=>f(d.cart,e),"is-checkout-page":({location:e})=>f(d.checkout,e),"is-homepage":({location:e})=>f(d.homepage,e)};function g(){if(!(0,e.supportsWindow)()||!globalThis.window.Shopify)throw Error(`Shopify global object not found. This plugin must be used on a Shopify storefront page.`);return globalThis.window.Shopify}function _(e){return typeof g().analytics?.publish==`function`}var v=e=>new Promise(t=>{setTimeout(t,e)}),y=new Set([`experience_initialize`,`feature_decide`,`initialize`,`session`,`user_decide`]),b=()=>({name:`shopify`,setup:r=>{let i={},a=0,o=async()=>{if(a>=3)return;a++,await k({attributes:i}),await v(2e3);let e=await D();for(let[t,n]of Object.entries(i))if(e.attributes[t]!==n)return o()},s=n(async()=>(a=0,o()),50);if(Object.entries(h).forEach(([e,t])=>{r.registerPredicate(`shopify-${e}`,t)}),!(0,e.supportsWindow)())return;let c=r.session.store.map(e=>e.id),l=r.session.store.map(e=>e.isUser,{skipVoid:!1}),u=(0,t.createEffect)(e=>{e.type===`session`&&_(globalThis.window)&&globalThis.window.Shopify.analytics.publish(`picked:session`,{id:e.id})}),d=(0,t.attach)({source:{sessionId:c,isUser:l,features:r.features.listStore},effect:({sessionId:e,isUser:t,features:n})=>{if(!_(globalThis.window)||!e)return;let r={"picked.id":e};t!==void 0&&(r[`picked.is_user`]=t?`true`:`false`),n.forEach(e=>{if(e.isResolved){let t=e.getBucket();r[`picked.features.${e.id}`]=`${t.bucket}`}}),i={...i,...r},s().catch(()=>{})}});(0,t.sample)({clock:r.eventBus,filter:e=>e.type===`session`,target:u}),(0,t.sample)({clock:r.eventBus,filter:e=>y.has(e.type),target:d})}});function x(){let e=g();return new URL(`${globalThis.window.location.origin}${e.routes.root}`)}async function S(e){let t=new URL(e,x()),n=await fetch(t.toString());if(!n.ok)throw Error(n.statusText);return n.json()}async function C(e,t){let n=new URL(e,x()),r=await fetch(n.toString(),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!r.ok)throw Error(r.statusText);return r.json()}function w(e){return S(`products/${e}.js`)}function T(e,t,n){return S(`recommendations/products.json?product_id=${e}&limit=${t}&intent=${n}`)}function E(e){return S(`search/suggest.json?q=${e}`)}function D(){return S(`cart.js`)}function O(e){return C(`cart/add.js`,Array.isArray(e)?{items:e}:{items:[e]})}function k(e){return C(`cart/update.js`,{...e})}function A(e,t,n){return C(`cart/change.js`,{line:e,quantity:t,properties:n})}function j(){return C(`cart/clear.js`,{})}function M(e){let t=new URLSearchParams;return Object.entries(e).forEach(([e,n])=>{t.append(`shipping_address[${e}]`,n)}),S(`cart/shipping_rates.json?${t.toString()}`)}Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,`b`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`y`,{enumerable:!0,get:function(){return a}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../../ajax-api-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../../ajax-api-DqEv8M8X.cjs`);exports.addToCart=e.t,exports.changeCart=e.n,exports.clearCart=e.r,exports.getCart=e.i,exports.getPredictiveSearch=e.a,exports.getProduct=e.o,exports.getProductRecommendations=e.s,exports.getShippingRates=e.c,exports.updateCart=e.l;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../../ajax-api-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../../ajax-api-DqEv8M8X.cjs`);async function t(t){let{collection:n}=await e.u(`collections/${t}.json`);return{collection:n}}async function n(t,n=20){let{products:r}=await e.u(`collections/${t}/products.json?limit=${n}`);return{products:r}}exports.getCollection=t,exports.getCollectionProducts=n;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../../ajax-api-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../../ajax-api-DqEv8M8X.cjs`);async function t(t){return e.u(`apps/picked/api/products/${t}/metafields`)}async function n(t){return e.u(`apps/picked/api/collections/${t}/metafields`)}exports.getCollectionMetadata=n,exports.getProductMetadata=t;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../../../ajax-api-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../../../ajax-api-DqEv8M8X.cjs`);exports.getPickedConfig=e.m,exports.getPickedConfigCollection=e.h,exports.getPickedConfigCustomer=e.g,exports.getPickedConfigExperiments=e._,exports.getPickedConfigFeatureExperiments=e.v,exports.getPickedConfigProduct=e.y,exports.getPickedConfigStorefrontApiToken=e.b,exports.getShopify=e.p,exports.shopifyPlugin=e.f;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../../ajax-api-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../../ajax-api-DqEv8M8X.cjs`);let t=require(`@shopify/storefront-api-client`);function n(n){let r=e.p(),i=e.b();if(!i)throw Error(`Shopify Storefront API token not found. Ensure the Picked Script is enabled on your Shopify storefront`);return(0,t.createStorefrontApiClient)({storeDomain:r.shop,apiVersion:n.apiVersion,publicAccessToken:i})}var r=()=>{if(!client)throw Error(`Storefront API client not found`);return client};async function i(e,t){if(!e)throw Error(`Cart token is required to apply discount codes`);let n=r(),i={cartId:`gid://shopify/Cart/${e}`,discountCodes:t},a=await n.request(`
|
|
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
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../../ajax-api-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../../ajax-api-DqEv8M8X.cjs`);exports.getRequest=e.u,exports.postRequest=e.d;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s, t as c } from "../../ajax-api-
|
|
1
|
+
import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s, t as c } from "../../ajax-api-B4PP6DsE.js";
|
|
2
2
|
export { c as addToCart, i as changeCart, o as clearCart, n as getCart, e as getPredictiveSearch, a as getProduct, s as getProductRecommendations, t as getShippingRates, r as updateCart };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as e, b as t, f as n, g as r, h as i, m as a, p as o, v as s, y as c } from "../../../ajax-api-
|
|
1
|
+
import { _ as e, b as t, f as n, g as r, h as i, m as a, p as o, v as s, y as c } from "../../../ajax-api-B4PP6DsE.js";
|
|
2
2
|
export { a as getPickedConfig, i as getPickedConfigCollection, r as getPickedConfigCustomer, e as getPickedConfigExperiments, s as getPickedConfigFeatureExperiments, c as getPickedConfigProduct, t as getPickedConfigStorefrontApiToken, o as getShopify, n as shopifyPlugin };
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { d as e, u as t } from "../../ajax-api-
|
|
1
|
+
import { d as e, u as t } from "../../ajax-api-B4PP6DsE.js";
|
|
2
2
|
export { t as getRequest, e as postRequest };
|
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
import { Plugin } from '@picked/client';
|
|
2
|
+
/**
|
|
3
|
+
* Shopify integration plugin — publishes session metadata and feature buckets to Shopify's
|
|
4
|
+
* analytics.web-pixels API and updates cart attributes via the AJAX cart API.
|
|
5
|
+
*
|
|
6
|
+
* @returns {Plugin} The Shopify plugin definition.
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* createClient({ plugins: [shopifyPlugin()] })
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
2
12
|
export declare const shopifyPlugin: () => Plugin;
|
|
3
13
|
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/shopify/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/shopify/plugin.ts"],"names":[],"mappings":"AAAA,8GAA8G;AAC9G,OAAO,KAAK,EAA2B,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAqBrE;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,QAAO,MAkGhC,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.
|
|
4
|
+
"version": "0.0.1-dev.1778136207545",
|
|
5
5
|
"devDependencies": {
|
|
6
6
|
"@picked/client": "workspace:*",
|
|
7
7
|
"@repo/eslint-config": "workspace:*",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"main": "./dist/cjs/index.js",
|
|
79
79
|
"module": "./dist/esm/index.js",
|
|
80
80
|
"peerDependencies": {
|
|
81
|
-
"@picked/client": "0.0.1-dev.
|
|
81
|
+
"@picked/client": "0.0.1-dev.1778136207545",
|
|
82
82
|
"@shopify/storefront-api-client": "^1.0.9",
|
|
83
83
|
"effector": "^23.3.0"
|
|
84
84
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
let e=require(`@picked/client`);function t(e,t){let n,r;return(...i)=>(r&&r.reject(Error(`Debounced`)),new Promise((a,o)=>{r={resolve:a,reject:o},clearTimeout(n),n=setTimeout(async()=>{n=void 0;try{let t=await e(...i);r?.resolve(t)}catch(e){r?.reject(e)}finally{r=null}},t)}))}function n(){if((0,e.supportsWindow)())return(0,e.getPickedConfig)()}function r(){if((0,e.supportsWindow)())return n()?.customer}function i(){if((0,e.supportsWindow)())return n()?.product}function a(){if((0,e.supportsWindow)())return n()?.collection}function o(){if((0,e.supportsWindow)())return n()?.experiments}function s(){if((0,e.supportsWindow)())return n()?.storefront_api?.token}function c(){let t=(0,e.createStorageKey)(`shopify-roll`),n=e.localStore.get(t);try{let e=n.json();if(typeof e==`number`)return e}catch{}let r=Math.random()*100;return n.set(r),r}function l(){let e=o();if(!e)return{};let t=c();try{return e.reduce((e,n)=>{let r=e?{...e}:{};return n.enabled&&(r[n.id]={name:n.name,key:n.version.toString(),decide:()=>t<n.weight}),r},{})}catch{return{}}}var u={homepage:/^\/$/,productPage:/(?:^|\/)products\/(?<productHandle>[^/]+)\/?$/,collection:/^\/collections\/[^/]+\/?$/,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(?:\/|$)/,accountRecover:/^\/account\/login#recover$/},d=(e,t)=>t?!!e.exec(t.pathname):!1,f=(e,t)=>{if(t){let n=e.exec(t.pathname);if(n)return n[1]}},p=e=>{switch(e){case`product`:return i()?.handle??!1;case`collection`:return a()?.handle??!1;default:return!1}},m={"is-page":({location:e})=>d(u.page,e),"get-page-handle":({location:e})=>f(u.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})=>d(u.blog,e),"get-blog-handle":({location:e})=>f(u.blog,e),"is-article-page":({location:e})=>d(u.article,e),"get-article-handle":({location:e})=>f(u.article,e),"is-app-proxy-page":({location:e})=>d(u.appProxy,e),"get-app-proxy-handle":({location:e})=>f(u.appProxy,e),"is-account-page":({location:e})=>d(u.accountWildcard,e),"is-login-page":({location:e})=>d(u.accountLogin,e),"is-register-page":({location:e})=>d(u.accountRegister,e),"is-cart-page":({location:e})=>d(u.cart,e),"is-checkout-page":({location:e})=>d(u.checkout,e),"is-homepage":({location:e})=>d(u.homepage,e)};function h(){if(!(0,e.supportsWindow)()||!globalThis.window.Shopify)throw Error(`Shopify global object not found. This plugin must be used on a Shopify storefront page.`);return globalThis.window.Shopify}function g(e){return typeof h().analytics?.publish==`function`}var _=e=>new Promise(t=>{setTimeout(t,e)}),v=()=>({name:`shopify`,setup:n=>{let r={},i=0,a=async()=>{if(i>=3)return;i++,await D({attributes:r}),await _(2e3);let e=await T();for(let[t,n]of Object.entries(r))if(e.attributes[t]!==n)return a()},o=t(async()=>(i=0,a()),50);Object.entries(m).forEach(([e,t])=>{n.registerPredicate(`shopify-${e}`,t)}),(0,e.supportsWindow)()&&n.eventBus.watch(e=>{if(g(globalThis.window)&&(e.type===`session`&&globalThis.window.Shopify.analytics.publish(`picked:session`,{id:e.id}),e.type===`experience_initialize`||e.type===`feature_decide`||e.type===`initialize`||e.type===`session`||e.type===`user_decide`)){let e=n.session;if(e){let t={"picked.id":e.id};e.isUser!==void 0&&(t[`picked.is_user`]=e.isUser?`true`:`false`),n.features.listStore.getState().forEach(e=>{if(e.isResolved){let n=e.getBucket();t[`picked.features.${e.id}`]=`${n.bucket}`}}),r={...r,...t},o().catch(()=>{})}}})}});function y(){let e=h();return new URL(`${globalThis.window.location.origin}${e.routes.root}`)}async function b(e){let t=new URL(e,y()),n=await fetch(t.toString());if(!n.ok)throw Error(n.statusText);return n.json()}async function x(e,t){let n=new URL(e,y()),r=await fetch(n.toString(),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!r.ok)throw Error(r.statusText);return r.json()}function S(e){return b(`products/${e}.js`)}function C(e,t,n){return b(`recommendations/products.json?product_id=${e}&limit=${t}&intent=${n}`)}function w(e){return b(`search/suggest.json?q=${e}`)}function T(){return b(`cart.js`)}function E(e){return x(`cart/add.js`,Array.isArray(e)?{items:e}:{items:[e]})}function D(e){return x(`cart/update.js`,{...e})}function O(e,t,n){return x(`cart/change.js`,{line:e,quantity:t,properties:n})}function k(){return x(`cart/clear.js`,{})}function A(e){let t=new URLSearchParams;return Object.entries(e).forEach(([e,n])=>{t.append(`shipping_address[${e}]`,n)}),b(`cart/shipping_rates.json?${t.toString()}`)}Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,`b`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`y`,{enumerable:!0,get:function(){return i}});
|
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
import { createStorageKey as e, getPickedConfig as t, localStore as n, supportsWindow as r } from "@picked/client";
|
|
2
|
-
//#region src/utils/debounce.ts
|
|
3
|
-
function i(e, t) {
|
|
4
|
-
let n, r;
|
|
5
|
-
return (...i) => (r && r.reject(/* @__PURE__ */ Error("Debounced")), new Promise((a, o) => {
|
|
6
|
-
r = {
|
|
7
|
-
resolve: a,
|
|
8
|
-
reject: o
|
|
9
|
-
}, clearTimeout(n), n = setTimeout(async () => {
|
|
10
|
-
n = void 0;
|
|
11
|
-
try {
|
|
12
|
-
let t = await e(...i);
|
|
13
|
-
r?.resolve(t);
|
|
14
|
-
} catch (e) {
|
|
15
|
-
r?.reject(e);
|
|
16
|
-
} finally {
|
|
17
|
-
r = null;
|
|
18
|
-
}
|
|
19
|
-
}, t);
|
|
20
|
-
}));
|
|
21
|
-
}
|
|
22
|
-
//#endregion
|
|
23
|
-
//#region src/plugins/shopify/picked-config.ts
|
|
24
|
-
function a() {
|
|
25
|
-
if (r()) return t();
|
|
26
|
-
}
|
|
27
|
-
function o() {
|
|
28
|
-
if (r()) return a()?.customer;
|
|
29
|
-
}
|
|
30
|
-
function s() {
|
|
31
|
-
if (r()) return a()?.product;
|
|
32
|
-
}
|
|
33
|
-
function c() {
|
|
34
|
-
if (r()) return a()?.collection;
|
|
35
|
-
}
|
|
36
|
-
function l() {
|
|
37
|
-
if (r()) return a()?.experiments;
|
|
38
|
-
}
|
|
39
|
-
function u() {
|
|
40
|
-
if (r()) return a()?.storefront_api?.token;
|
|
41
|
-
}
|
|
42
|
-
function d() {
|
|
43
|
-
let t = e("shopify-roll"), r = n.get(t);
|
|
44
|
-
try {
|
|
45
|
-
let e = r.json();
|
|
46
|
-
if (typeof e == "number") return e;
|
|
47
|
-
} catch {}
|
|
48
|
-
let i = Math.random() * 100;
|
|
49
|
-
return r.set(i), i;
|
|
50
|
-
}
|
|
51
|
-
function f() {
|
|
52
|
-
let e = l();
|
|
53
|
-
if (!e) return {};
|
|
54
|
-
let t = d();
|
|
55
|
-
try {
|
|
56
|
-
return e.reduce((e, n) => {
|
|
57
|
-
let r = e ? { ...e } : {};
|
|
58
|
-
return n.enabled && (r[n.id] = {
|
|
59
|
-
name: n.name,
|
|
60
|
-
key: n.version.toString(),
|
|
61
|
-
decide: () => t < n.weight
|
|
62
|
-
}), r;
|
|
63
|
-
}, {});
|
|
64
|
-
} catch {
|
|
65
|
-
return {};
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
//#endregion
|
|
69
|
-
//#region src/plugins/shopify/predicates.ts
|
|
70
|
-
var p = {
|
|
71
|
-
homepage: /^\/$/,
|
|
72
|
-
productPage: /(?:^|\/)products\/(?<productHandle>[^/]+)\/?$/,
|
|
73
|
-
collection: /^\/collections\/[^/]+\/?$/,
|
|
74
|
-
page: /(?:^|\/)pages\/(?<pageHandle>[^/]+)\/?$/,
|
|
75
|
-
blog: /(?:^|\/)blogs\/(?<blogHandle>[^/]+)\/?$/,
|
|
76
|
-
article: /^\/blogs\/[^/]+\/(?<article>[^/]+)\/?$/,
|
|
77
|
-
cart: /(?:^|\/)cart\/[^/]+$/,
|
|
78
|
-
checkout: /^\/checkout\/.+/,
|
|
79
|
-
appProxy: /^\/(?:a|apps|community|tools)\/(?<proxyTarget>[^/]+)/,
|
|
80
|
-
accountWildcard: /^\/account\/.+/,
|
|
81
|
-
accountLogin: /^\/account\/login(?:\/|$)/,
|
|
82
|
-
accountRegister: /^\/account\/register(?:\/|$)/,
|
|
83
|
-
accountRecover: /^\/account\/login#recover$/
|
|
84
|
-
}, m = (e, t) => t ? !!e.exec(t.pathname) : !1, h = (e, t) => {
|
|
85
|
-
if (t) {
|
|
86
|
-
let n = e.exec(t.pathname);
|
|
87
|
-
if (n) return n[1];
|
|
88
|
-
}
|
|
89
|
-
}, g = (e) => {
|
|
90
|
-
switch (e) {
|
|
91
|
-
case "product": return s()?.handle ?? !1;
|
|
92
|
-
case "collection": return c()?.handle ?? !1;
|
|
93
|
-
default: return !1;
|
|
94
|
-
}
|
|
95
|
-
}, _ = {
|
|
96
|
-
"is-page": ({ location: e }) => m(p.page, e),
|
|
97
|
-
"get-page-handle": ({ location: e }) => h(p.page, e),
|
|
98
|
-
"is-product-page": () => !!g("product"),
|
|
99
|
-
"get-product-handle": () => g("product"),
|
|
100
|
-
"is-collection-page": () => !!g("collection"),
|
|
101
|
-
"get-collection-handle": () => g("collection"),
|
|
102
|
-
"is-blog-page": ({ location: e }) => m(p.blog, e),
|
|
103
|
-
"get-blog-handle": ({ location: e }) => h(p.blog, e),
|
|
104
|
-
"is-article-page": ({ location: e }) => m(p.article, e),
|
|
105
|
-
"get-article-handle": ({ location: e }) => h(p.article, e),
|
|
106
|
-
"is-app-proxy-page": ({ location: e }) => m(p.appProxy, e),
|
|
107
|
-
"get-app-proxy-handle": ({ location: e }) => h(p.appProxy, e),
|
|
108
|
-
"is-account-page": ({ location: e }) => m(p.accountWildcard, e),
|
|
109
|
-
"is-login-page": ({ location: e }) => m(p.accountLogin, e),
|
|
110
|
-
"is-register-page": ({ location: e }) => m(p.accountRegister, e),
|
|
111
|
-
"is-cart-page": ({ location: e }) => m(p.cart, e),
|
|
112
|
-
"is-checkout-page": ({ location: e }) => m(p.checkout, e),
|
|
113
|
-
"is-homepage": ({ location: e }) => m(p.homepage, e)
|
|
114
|
-
};
|
|
115
|
-
//#endregion
|
|
116
|
-
//#region src/plugins/shopify/global-obj.ts
|
|
117
|
-
function v() {
|
|
118
|
-
if (!r() || !globalThis.window.Shopify) throw Error("Shopify global object not found. This plugin must be used on a Shopify storefront page.");
|
|
119
|
-
return globalThis.window.Shopify;
|
|
120
|
-
}
|
|
121
|
-
function y(e) {
|
|
122
|
-
return typeof v().analytics?.publish == "function";
|
|
123
|
-
}
|
|
124
|
-
//#endregion
|
|
125
|
-
//#region src/plugins/shopify/plugin.ts
|
|
126
|
-
var b = (e) => new Promise((t) => {
|
|
127
|
-
setTimeout(t, e);
|
|
128
|
-
}), x = () => ({
|
|
129
|
-
name: "shopify",
|
|
130
|
-
setup: (e) => {
|
|
131
|
-
let t = {}, n = 0, a = async () => {
|
|
132
|
-
if (n >= 3) return;
|
|
133
|
-
n++, await A({ attributes: t }), await b(2e3);
|
|
134
|
-
let e = await O();
|
|
135
|
-
for (let [n, r] of Object.entries(t)) if (e.attributes[n] !== r) return a();
|
|
136
|
-
}, o = i(async () => (n = 0, a()), 50);
|
|
137
|
-
Object.entries(_).forEach(([t, n]) => {
|
|
138
|
-
e.registerPredicate(`shopify-${t}`, n);
|
|
139
|
-
}), r() && e.eventBus.watch((n) => {
|
|
140
|
-
if (y(globalThis.window) && (n.type === "session" && globalThis.window.Shopify.analytics.publish("picked:session", { id: n.id }), n.type === "experience_initialize" || n.type === "feature_decide" || n.type === "initialize" || n.type === "session" || n.type === "user_decide")) {
|
|
141
|
-
let n = e.session;
|
|
142
|
-
if (n) {
|
|
143
|
-
let r = { "picked.id": n.id };
|
|
144
|
-
n.isUser !== void 0 && (r["picked.is_user"] = n.isUser ? "true" : "false"), e.features.listStore.getState().forEach((e) => {
|
|
145
|
-
if (e.isResolved) {
|
|
146
|
-
let t = e.getBucket();
|
|
147
|
-
r[`picked.features.${e.id}`] = `${t.bucket}`;
|
|
148
|
-
}
|
|
149
|
-
}), t = {
|
|
150
|
-
...t,
|
|
151
|
-
...r
|
|
152
|
-
}, o().catch(() => {});
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
//#endregion
|
|
159
|
-
//#region src/utils/request.ts
|
|
160
|
-
function S() {
|
|
161
|
-
let e = v();
|
|
162
|
-
return new URL(`${globalThis.window.location.origin}${e.routes.root}`);
|
|
163
|
-
}
|
|
164
|
-
async function C(e) {
|
|
165
|
-
let t = new URL(e, S()), n = await fetch(t.toString());
|
|
166
|
-
if (!n.ok) throw Error(n.statusText);
|
|
167
|
-
return n.json();
|
|
168
|
-
}
|
|
169
|
-
async function w(e, t) {
|
|
170
|
-
let n = new URL(e, S()), r = await fetch(n.toString(), {
|
|
171
|
-
method: "POST",
|
|
172
|
-
headers: { "Content-Type": "application/json" },
|
|
173
|
-
body: JSON.stringify(t)
|
|
174
|
-
});
|
|
175
|
-
if (!r.ok) throw Error(r.statusText);
|
|
176
|
-
return r.json();
|
|
177
|
-
}
|
|
178
|
-
//#endregion
|
|
179
|
-
//#region src/ajax-api/index.ts
|
|
180
|
-
function T(e) {
|
|
181
|
-
return C(`products/${e}.js`);
|
|
182
|
-
}
|
|
183
|
-
function E(e, t, n) {
|
|
184
|
-
return C(`recommendations/products.json?product_id=${e}&limit=${t}&intent=${n}`);
|
|
185
|
-
}
|
|
186
|
-
function D(e) {
|
|
187
|
-
return C(`search/suggest.json?q=${e}`);
|
|
188
|
-
}
|
|
189
|
-
function O() {
|
|
190
|
-
return C("cart.js");
|
|
191
|
-
}
|
|
192
|
-
function k(e) {
|
|
193
|
-
return w("cart/add.js", Array.isArray(e) ? { items: e } : { items: [e] });
|
|
194
|
-
}
|
|
195
|
-
function A(e) {
|
|
196
|
-
return w("cart/update.js", { ...e });
|
|
197
|
-
}
|
|
198
|
-
function j(e, t, n) {
|
|
199
|
-
return w("cart/change.js", {
|
|
200
|
-
line: e,
|
|
201
|
-
quantity: t,
|
|
202
|
-
properties: n
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
function M() {
|
|
206
|
-
return w("cart/clear.js", {});
|
|
207
|
-
}
|
|
208
|
-
function N(e) {
|
|
209
|
-
let t = new URLSearchParams();
|
|
210
|
-
return Object.entries(e).forEach(([e, n]) => {
|
|
211
|
-
t.append(`shipping_address[${e}]`, n);
|
|
212
|
-
}), C(`cart/shipping_rates.json?${t.toString()}`);
|
|
213
|
-
}
|
|
214
|
-
//#endregion
|
|
215
|
-
export { l as _, D as a, u as b, N as c, w as d, x as f, o as g, c as h, O as i, A as l, a as m, j as n, T as o, v as p, M as r, E as s, k as t, C as u, f as v, s as y };
|