@picked/shopify 0.0.1-dev.1773878362211 → 0.0.1-dev.1774224866171

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.
@@ -0,0 +1 @@
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}});
@@ -0,0 +1,215 @@
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 };
@@ -1 +1 @@
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
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../../ajax-api-BDy6OWHE.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;
package/dist/cjs/index.js CHANGED
@@ -1 +0,0 @@
1
- "use strict";
@@ -1 +1 @@
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
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../../ajax-api-BDy6OWHE.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
- "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`)}async function c(t){return e.get(`apps/picked/api/collections/${t}/metafields`)}exports.getCollectionMetadata=c;exports.getProductMetadata=a;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../../ajax-api-BDy6OWHE.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
- "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
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../../../ajax-api-BDy6OWHE.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
- "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=`
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../../ajax-api-BDy6OWHE.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 {
@@ -7,4 +7,4 @@
7
7
  }
8
8
  }
9
9
  }
10
- `,c={cartId:i,discountCodes:o},r=await e.request(s,{variables:c});if(r.data.cartDiscountCodesUpdate.userErrors.length>0){const a=r.data.cartDiscountCodesUpdate.userErrors.map(d=>d.message).join(", ");throw new Error(`Discount code application failed: ${a}`)}return r}exports.cartDiscountCodesUpdate=C;exports.createStorefrontApiClient=l;exports.getStorefrontApiClient=n;
10
+ `,{variables:i});if(a.data.cartDiscountCodesUpdate.userErrors.length>0){let e=a.data.cartDiscountCodesUpdate.userErrors.map(e=>e.message).join(`, `);throw Error(`Discount code application failed: ${e}`)}return a}exports.cartDiscountCodesUpdate=i,exports.createStorefrontApiClient=n,exports.getStorefrontApiClient=r;
@@ -1 +1 @@
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
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../../ajax-api-BDy6OWHE.cjs`);exports.getRequest=e.u,exports.postRequest=e.d;
@@ -1,45 +1,2 @@
1
- import { p as a, g as e } from "../../request-DHywK46g.js";
2
- function s(t) {
3
- return e(`products/${t}.js`);
4
- }
5
- function u(t, r, n) {
6
- return e(
7
- `recommendations/products.json?product_id=${t}&limit=${r}&intent=${n}`
8
- );
9
- }
10
- function i(t) {
11
- return e(`search/suggest.json?q=${t}`);
12
- }
13
- function d() {
14
- return e("cart.js");
15
- }
16
- function p(t) {
17
- const r = Array.isArray(t) ? { items: t } : { items: [t] };
18
- return a("cart/add.js", r);
19
- }
20
- function g(t) {
21
- return a("cart/update.js", { ...t });
22
- }
23
- function f(t, r, n) {
24
- return a("cart/change.js", { line: t, quantity: r, properties: n });
25
- }
26
- function j() {
27
- return a("cart/clear.js", {});
28
- }
29
- function h(t) {
30
- const r = new URLSearchParams();
31
- return Object.entries(t).forEach(([n, c]) => {
32
- r.append(`shipping_address[${n}]`, c);
33
- }), e(`cart/shipping_rates.json?${r.toString()}`);
34
- }
35
- export {
36
- p as addToCart,
37
- f as changeCart,
38
- j as clearCart,
39
- d as getCart,
40
- i as getPredictiveSearch,
41
- s as getProduct,
42
- u as getProductRecommendations,
43
- h as getShippingRates,
44
- g as updateCart
45
- };
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-Ci7vlv1u.js";
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 };
package/dist/esm/index.js CHANGED
@@ -1 +0,0 @@
1
-
@@ -1,13 +1,12 @@
1
- import { g as c } from "../../request-DHywK46g.js";
2
- async function s(o) {
3
- const { collection: t } = await c(`collections/${o}.json`);
4
- return { collection: t };
1
+ import { u as e } from "../../ajax-api-Ci7vlv1u.js";
2
+ //#region src/json-api/index.ts
3
+ async function t(t) {
4
+ let { collection: n } = await e(`collections/${t}.json`);
5
+ return { collection: n };
5
6
  }
6
- async function e(o, t = 20) {
7
- const { products: n } = await c(`collections/${o}/products.json?limit=${t}`);
8
- return { products: n };
7
+ async function n(t, n = 20) {
8
+ let { products: r } = await e(`collections/${t}/products.json?limit=${n}`);
9
+ return { products: r };
9
10
  }
10
- export {
11
- s as getCollection,
12
- e as getCollectionProducts
13
- };
11
+ //#endregion
12
+ export { t as getCollection, n as getCollectionProducts };
@@ -1,11 +1,10 @@
1
- import { g as e } from "../../request-DHywK46g.js";
2
- async function c(t) {
3
- return e(`apps/picked/api/products/${t}/metafields`);
1
+ import { u as e } from "../../ajax-api-Ci7vlv1u.js";
2
+ //#region src/picked-app/index.ts
3
+ async function t(t) {
4
+ return e(`apps/picked/api/products/${t}/metafields`);
4
5
  }
5
- async function i(t) {
6
- return e(`apps/picked/api/collections/${t}/metafields`);
6
+ async function n(t) {
7
+ return e(`apps/picked/api/collections/${t}/metafields`);
7
8
  }
8
- export {
9
- i as getCollectionMetadata,
10
- c as getProductMetadata
11
- };
9
+ //#endregion
10
+ export { n as getCollectionMetadata, t as getProductMetadata };
@@ -1,132 +1,2 @@
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-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
- function P(e, t) {
8
- let o, r;
9
- return (...g) => (r && r.reject(new Error("Debounced")), new Promise((i, s) => {
10
- r = { resolve: i, reject: s };
11
- const n = async () => {
12
- o = void 0;
13
- try {
14
- const p = await e(...g);
15
- r?.resolve(p);
16
- } catch (p) {
17
- r?.reject(p);
18
- } finally {
19
- r = null;
20
- }
21
- };
22
- clearTimeout(o), o = setTimeout(n, t);
23
- }));
24
- }
25
- const a = {
26
- homepage: /^\/$/,
27
- page: /(?:^|\/)pages\/(?<pageHandle>[^/]+)\/?$/,
28
- blog: /(?:^|\/)blogs\/(?<blogHandle>[^/]+)\/?$/,
29
- article: /^\/blogs\/[^/]+\/(?<article>[^/]+)\/?$/,
30
- cart: /(?:^|\/)cart\/[^/]+$/,
31
- checkout: /^\/checkout\/.+/,
32
- appProxy: /^\/(?:a|apps|community|tools)\/(?<proxyTarget>[^/]+)/,
33
- accountWildcard: /^\/account\/.+/,
34
- accountLogin: /^\/account\/login(?:\/|$)/,
35
- accountRegister: /^\/account\/register(?:\/|$)/
36
- }, c = (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];
41
- }
42
- }, u = (e) => {
43
- switch (e) {
44
- case "product":
45
- return b()?.handle ?? !1;
46
- case "collection":
47
- return m()?.handle ?? !1;
48
- default:
49
- return !1;
50
- }
51
- }, x = {
52
- // Pages
53
- "is-page": ({ location: e }) => c(a.page, e),
54
- "get-page-handle": ({ location: e }) => l(a.page, e),
55
- // Products
56
- "is-product-page": () => !!u("product"),
57
- "get-product-handle": () => u("product"),
58
- // Collections
59
- "is-collection-page": () => !!u("collection"),
60
- "get-collection-handle": () => u("collection"),
61
- // Blogs
62
- "is-blog-page": ({ location: e }) => c(a.blog, e),
63
- "get-blog-handle": ({ location: e }) => l(a.blog, e),
64
- // Blog Articles
65
- "is-article-page": ({ location: e }) => c(a.article, e),
66
- "get-article-handle": ({ location: e }) => l(a.article, e),
67
- // Apps
68
- "is-app-proxy-page": ({ location: e }) => c(a.appProxy, e),
69
- "get-app-proxy-handle": ({ location: e }) => l(a.appProxy, e),
70
- // Account
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),
74
- // Cart
75
- "is-cart-page": ({ location: e }) => c(a.cart, e),
76
- // Checkout
77
- "is-checkout-page": ({ location: e }) => c(a.checkout, e),
78
- // Homepage
79
- "is-homepage": ({ location: e }) => c(a.homepage, e)
80
- }, w = (e) => new Promise((t) => {
81
- setTimeout(t, e);
82
- }), E = () => ({
83
- name: "shopify",
84
- setup: (e) => {
85
- let t = {}, o = 0;
86
- const r = async () => {
87
- if (o >= 3) return;
88
- o++, await y({
89
- attributes: t
90
- }), await w(2e3);
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) {
104
- const n = {
105
- "picked.id": s.id
106
- };
107
- typeof s.isUser < "u" && (n["picked.is_user"] = s.isUser ? "true" : "false"), e.features.listStore.getState().forEach((p) => {
108
- if (p.isResolved) {
109
- const d = p.getBucket();
110
- n[`picked.features.${p.id}`] = `${d.bucket}`;
111
- }
112
- }), t = {
113
- ...t,
114
- ...n
115
- }, g().catch(() => {
116
- });
117
- }
118
- }
119
- });
120
- }
121
- });
122
- export {
123
- j as getPickedConfig,
124
- m as getPickedConfigCollection,
125
- H as getPickedConfigCustomer,
126
- R as getPickedConfigExperiments,
127
- _ as getPickedConfigFeatureExperiments,
128
- b as getPickedConfigProduct,
129
- W as getPickedConfigStorefrontApiToken,
130
- z as getShopify,
131
- E as shopifyPlugin
132
- };
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-Ci7vlv1u.js";
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 };
@@ -1,53 +1,30 @@
1
- import { createStorefrontApiClient as d } from "@shopify/storefront-api-client";
2
- import "@picked/client";
3
- import { g as p } from "../../picked-config-DfUZ8EiJ.js";
4
- import { g as f } from "../../global-obj-Dy9uYgrE.js";
5
- function S(t) {
6
- const r = f(), o = p();
7
- if (!o)
8
- throw new Error(
9
- "Shopify Storefront API token not found. Ensure the Picked Script is enabled on your Shopify storefront"
10
- );
11
- return d({
12
- storeDomain: r.shop,
13
- apiVersion: t.apiVersion,
14
- publicAccessToken: o
15
- });
1
+ import { b as e, p as t } from "../../ajax-api-Ci7vlv1u.js";
2
+ import { createStorefrontApiClient as n } from "@shopify/storefront-api-client";
3
+ //#region src/storefront-api/index.ts
4
+ function r(r) {
5
+ let i = t(), a = e();
6
+ if (!a) throw Error("Shopify Storefront API token not found. Ensure the Picked Script is enabled on your Shopify storefront");
7
+ return n({
8
+ storeDomain: i.shop,
9
+ apiVersion: r.apiVersion,
10
+ publicAccessToken: a
11
+ });
16
12
  }
17
- const u = () => {
18
- if (!client)
19
- throw new Error("Storefront API client not found");
20
- return client;
13
+ var i = () => {
14
+ if (!client) throw Error("Storefront API client not found");
15
+ return client;
21
16
  };
22
- async function g(t, r) {
23
- if (!t)
24
- throw new Error("Cart token is required to apply discount codes");
25
- const o = u(), n = `gid://shopify/Cart/${t}`, i = `
26
- mutation cartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!]) {
27
- cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {
28
- userErrors {
29
- field
30
- message
31
- }
32
- }
33
- }
34
- `, s = {
35
- cartId: n,
36
- discountCodes: r
37
- }, e = await o.request(
38
- i,
39
- {
40
- variables: s
41
- }
42
- );
43
- if (e.data.cartDiscountCodesUpdate.userErrors.length > 0) {
44
- const c = e.data.cartDiscountCodesUpdate.userErrors.map((a) => a.message).join(", ");
45
- throw new Error(`Discount code application failed: ${c}`);
46
- }
47
- return e;
17
+ async function a(e, t) {
18
+ if (!e) throw Error("Cart token is required to apply discount codes");
19
+ let n = i(), r = {
20
+ cartId: `gid://shopify/Cart/${e}`,
21
+ discountCodes: t
22
+ }, a = await n.request("\n mutation cartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!]) {\n cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {\n userErrors {\n field\n message\n }\n }\n }\n ", { variables: r });
23
+ if (a.data.cartDiscountCodesUpdate.userErrors.length > 0) {
24
+ let e = a.data.cartDiscountCodesUpdate.userErrors.map((e) => e.message).join(", ");
25
+ throw Error(`Discount code application failed: ${e}`);
26
+ }
27
+ return a;
48
28
  }
49
- export {
50
- g as cartDiscountCodesUpdate,
51
- S as createStorefrontApiClient,
52
- u as getStorefrontApiClient
53
- };
29
+ //#endregion
30
+ export { a as cartDiscountCodesUpdate, r as createStorefrontApiClient, i as getStorefrontApiClient };
@@ -1,5 +1,2 @@
1
- import { g as t, p as o } from "../../request-DHywK46g.js";
2
- export {
3
- t as getRequest,
4
- o as postRequest
5
- };
1
+ import { d as e, u as t } from "../../ajax-api-Ci7vlv1u.js";
2
+ export { t as getRequest, e as postRequest };
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.1773878362211",
4
+ "version": "0.0.1-dev.1774224866171",
5
5
  "devDependencies": {
6
6
  "@picked/client": "workspace:*",
7
7
  "@repo/eslint-config": "workspace:*",
@@ -11,14 +11,14 @@
11
11
  "@size-limit/preset-small-lib": "^12.0.0",
12
12
  "@types/jsdom": "^21.1.7",
13
13
  "@types/node": "^22",
14
- "@vitest/coverage-v8": "^4.0.17",
14
+ "@vitest/coverage-v8": "^4.1.0",
15
15
  "effector": "^23.3.0",
16
16
  "size-limit": "^12.0.0",
17
17
  "tsup": "^8.5.0",
18
18
  "tsx": "^4.20.3",
19
- "vite": "^7.3.1",
19
+ "vite": "^8.0.1",
20
20
  "vite-plugin-dts": "^4.5.4",
21
- "vitest": "^4.0.17"
21
+ "vitest": "^4.1.0"
22
22
  },
23
23
  "exports": {
24
24
  ".": {
@@ -72,13 +72,13 @@
72
72
  "knip",
73
73
  "jscpd",
74
74
  "eslint",
75
- "tsc"
75
+ "tsgo"
76
76
  ]
77
77
  },
78
78
  "main": "./dist/cjs/index.js",
79
79
  "module": "./dist/esm/index.js",
80
80
  "peerDependencies": {
81
- "@picked/client": "0.0.1-dev.1773878362211",
81
+ "@picked/client": "0.0.1-dev.1774224866171",
82
82
  "@shopify/storefront-api-client": "^1.0.9",
83
83
  "effector": "^23.3.0"
84
84
  },
@@ -98,7 +98,7 @@
98
98
  "test:coverage": "vitest run --coverage",
99
99
  "test:packaged-types": "attw --pack",
100
100
  "test:watch": "vitest",
101
- "type-check": "tsc -p . --noEmit"
101
+ "type-check": "tsgo -p . --noEmit"
102
102
  },
103
103
  "size-limit": [
104
104
  {
@@ -1 +0,0 @@
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;
@@ -1,15 +0,0 @@
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
- };
@@ -1 +0,0 @@
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;
@@ -1,65 +0,0 @@
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 +0,0 @@
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,28 +0,0 @@
1
- import "@picked/client";
2
- import { g as e } from "./global-obj-Dy9uYgrE.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
- };