@gomusdev/web-components 1.54.1 → 1.54.2
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.
|
@@ -11327,11 +11327,6 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
11327
11327
|
localStorage.setItem("go-cart", content);
|
|
11328
11328
|
});
|
|
11329
11329
|
});
|
|
11330
|
-
window.addEventListener("storage", (event2) => {
|
|
11331
|
-
if (event2.key !== "go-cart") return;
|
|
11332
|
-
lastWritten = localStorage.getItem("go-cart") ?? "";
|
|
11333
|
-
loadFromLocalStorage$1(cart);
|
|
11334
|
-
});
|
|
11335
11330
|
}
|
|
11336
11331
|
const inTheFuture = (time2) => {
|
|
11337
11332
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -12615,8 +12610,21 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
12615
12610
|
checkout(params) {
|
|
12616
12611
|
return this.apiPost(`/api/v4/orders`, { body: params, requiredFields: ["items", "total"] });
|
|
12617
12612
|
}
|
|
12613
|
+
// Single-slot memo: dedupes identical /api/v4/cart projections across multiple
|
|
12614
|
+
// <go-cart> instances and back-to-back effect runs so the endpoint's rate
|
|
12615
|
+
// limit is not hit by a page that mounts several cart views.
|
|
12616
|
+
#cartProjectionCache = null;
|
|
12618
12617
|
createCart(params) {
|
|
12619
|
-
|
|
12618
|
+
const key = JSON.stringify({ items: params.items ?? [], coupons: params.coupons ?? [] });
|
|
12619
|
+
if (this.#cartProjectionCache?.key === key) {
|
|
12620
|
+
return this.#cartProjectionCache.promise;
|
|
12621
|
+
}
|
|
12622
|
+
const promise = this.apiPost(`/api/v4/cart`, { body: params, requiredFields: ["items"] }).catch((err2) => {
|
|
12623
|
+
if (this.#cartProjectionCache?.key === key) this.#cartProjectionCache = null;
|
|
12624
|
+
throw err2;
|
|
12625
|
+
});
|
|
12626
|
+
this.#cartProjectionCache = { key, promise };
|
|
12627
|
+
return promise;
|
|
12620
12628
|
}
|
|
12621
12629
|
order(token) {
|
|
12622
12630
|
return this.fetchAndCache("/api/v4/orders/{id}", `order-${token}`, "order", { path: { id: token } });
|
|
@@ -16954,7 +16962,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
16954
16962
|
push($$props, true);
|
|
16955
16963
|
let displayItem = prop($$props, "displayItem", 7), displayCart = prop($$props, "displayCart", 7), mainCart = prop($$props, "mainCart", 7), preview = prop($$props, "preview", 7);
|
|
16956
16964
|
let capacity = /* @__PURE__ */ state(void 0);
|
|
16957
|
-
const itemInMaincart = /* @__PURE__ */ user_derived(() => mainCart().items.find((item) => item.uuid === displayItem().display?.reference_uuid));
|
|
16965
|
+
const itemInMaincart = /* @__PURE__ */ user_derived(() => mainCart().items.find((item) => item.uuid === (displayItem().display?.reference_uuid ?? displayItem().uuid)));
|
|
16958
16966
|
const emptyCart = createCart();
|
|
16959
16967
|
user_effect(() => {
|
|
16960
16968
|
mainCart().items.map((i) => i.quantity);
|
|
@@ -17242,8 +17250,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
17242
17250
|
get$2(cart).items.map((i) => i.uuid + ":" + i.quantity + ":" + i.time);
|
|
17243
17251
|
get$2(cart).coupons.join("|");
|
|
17244
17252
|
const currentRequest = ++requestId;
|
|
17245
|
-
if (get$2(cart).items.length === 0) {
|
|
17253
|
+
if (get$2(cart).items.length === 0 || get$2(cart).coupons.length === 0) {
|
|
17246
17254
|
set(displayCart, get$2(cart), true);
|
|
17255
|
+
set(appliedCoupons, /* @__PURE__ */ new Set(), true);
|
|
17247
17256
|
return;
|
|
17248
17257
|
}
|
|
17249
17258
|
void (async () => {
|
|
@@ -11327,11 +11327,6 @@ function syncCartToLocalStorage(cart) {
|
|
|
11327
11327
|
localStorage.setItem("go-cart", content);
|
|
11328
11328
|
});
|
|
11329
11329
|
});
|
|
11330
|
-
window.addEventListener("storage", (event2) => {
|
|
11331
|
-
if (event2.key !== "go-cart") return;
|
|
11332
|
-
lastWritten = localStorage.getItem("go-cart") ?? "";
|
|
11333
|
-
loadFromLocalStorage$1(cart);
|
|
11334
|
-
});
|
|
11335
11330
|
}
|
|
11336
11331
|
const inTheFuture = (time2) => {
|
|
11337
11332
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -12615,8 +12610,21 @@ class Shop {
|
|
|
12615
12610
|
checkout(params) {
|
|
12616
12611
|
return this.apiPost(`/api/v4/orders`, { body: params, requiredFields: ["items", "total"] });
|
|
12617
12612
|
}
|
|
12613
|
+
// Single-slot memo: dedupes identical /api/v4/cart projections across multiple
|
|
12614
|
+
// <go-cart> instances and back-to-back effect runs so the endpoint's rate
|
|
12615
|
+
// limit is not hit by a page that mounts several cart views.
|
|
12616
|
+
#cartProjectionCache = null;
|
|
12618
12617
|
createCart(params) {
|
|
12619
|
-
|
|
12618
|
+
const key = JSON.stringify({ items: params.items ?? [], coupons: params.coupons ?? [] });
|
|
12619
|
+
if (this.#cartProjectionCache?.key === key) {
|
|
12620
|
+
return this.#cartProjectionCache.promise;
|
|
12621
|
+
}
|
|
12622
|
+
const promise = this.apiPost(`/api/v4/cart`, { body: params, requiredFields: ["items"] }).catch((err2) => {
|
|
12623
|
+
if (this.#cartProjectionCache?.key === key) this.#cartProjectionCache = null;
|
|
12624
|
+
throw err2;
|
|
12625
|
+
});
|
|
12626
|
+
this.#cartProjectionCache = { key, promise };
|
|
12627
|
+
return promise;
|
|
12620
12628
|
}
|
|
12621
12629
|
order(token) {
|
|
12622
12630
|
return this.fetchAndCache("/api/v4/orders/{id}", `order-${token}`, "order", { path: { id: token } });
|
|
@@ -16954,7 +16962,7 @@ function Item$1($$anchor, $$props) {
|
|
|
16954
16962
|
push($$props, true);
|
|
16955
16963
|
let displayItem = prop($$props, "displayItem", 7), displayCart = prop($$props, "displayCart", 7), mainCart = prop($$props, "mainCart", 7), preview = prop($$props, "preview", 7);
|
|
16956
16964
|
let capacity = /* @__PURE__ */ state(void 0);
|
|
16957
|
-
const itemInMaincart = /* @__PURE__ */ user_derived(() => mainCart().items.find((item) => item.uuid === displayItem().display?.reference_uuid));
|
|
16965
|
+
const itemInMaincart = /* @__PURE__ */ user_derived(() => mainCart().items.find((item) => item.uuid === (displayItem().display?.reference_uuid ?? displayItem().uuid)));
|
|
16958
16966
|
const emptyCart = createCart();
|
|
16959
16967
|
user_effect(() => {
|
|
16960
16968
|
mainCart().items.map((i) => i.quantity);
|
|
@@ -17242,8 +17250,9 @@ function Cart($$anchor, $$props) {
|
|
|
17242
17250
|
get$2(cart).items.map((i) => i.uuid + ":" + i.quantity + ":" + i.time);
|
|
17243
17251
|
get$2(cart).coupons.join("|");
|
|
17244
17252
|
const currentRequest = ++requestId;
|
|
17245
|
-
if (get$2(cart).items.length === 0) {
|
|
17253
|
+
if (get$2(cart).items.length === 0 || get$2(cart).coupons.length === 0) {
|
|
17246
17254
|
set(displayCart, get$2(cart), true);
|
|
17255
|
+
set(appliedCoupons, /* @__PURE__ */ new Set(), true);
|
|
17247
17256
|
return;
|
|
17248
17257
|
}
|
|
17249
17258
|
void (async () => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|