@gomusdev/web-components 1.54.0 → 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.
@@ -1,153 +1 @@
1
- export declare function createMockUITicket(): {
2
- uid: number;
3
- selectedTime: string;
4
- product_type: import('../../../lib/models/cart/types').ProductType;
5
- type: import('../../../lib/models/ticket/UITicket.svelte').UITicketType;
6
- shop_order: number;
7
- id: number;
8
- title: string;
9
- ticket_type: "time_slot" | "annual" | "normal";
10
- bookable: boolean;
11
- museum_ids: number[];
12
- exhibition_ids: number[];
13
- price_cents: number;
14
- discount: number;
15
- vat_pct: number;
16
- tax_included: boolean;
17
- entry_duration: number | null;
18
- min_persons: number;
19
- max_persons: number;
20
- quota_ids: number[];
21
- first_entry: number;
22
- last_entry: number;
23
- personalizeable: boolean;
24
- attendees: boolean | string;
25
- identification: boolean | string;
26
- free_timing: boolean;
27
- is_collective: boolean;
28
- is_upgrade: boolean;
29
- is_mantle: boolean;
30
- description: string | null;
31
- sub_ticket_ids: number[];
32
- sub_tickets: {
33
- [key: string]: {
34
- title?: string;
35
- min_persons?: number;
36
- max_persons?: number;
37
- description?: string | null;
38
- };
39
- } | null;
40
- is_sub_ticket: boolean;
41
- created_at: string;
42
- updated_at: string;
43
- shipped_with_merchandise_id: number | null;
44
- restricted_shop_account: boolean;
45
- cash_point_order: number;
46
- capacities: {
47
- [key: string]: number;
48
- };
49
- total_capacities: {
50
- [key: string]: number;
51
- };
52
- max_capacity: number;
53
- max_total_capacity: number;
54
- dynamic_prices: {
55
- [key: string]: number;
56
- } | null;
57
- } | {
58
- uid: number;
59
- selectedTime: string;
60
- product_type: import('../../../lib/models/cart/types').ProductType;
61
- type: import('../../../lib/models/ticket/UITicket.svelte').UITicketType;
62
- shop_order: number;
63
- id: number;
64
- title: string;
65
- ticket_type: "time_slot" | "annual" | "normal";
66
- bookable: boolean;
67
- museum_ids: number[];
68
- exhibition_ids: number[];
69
- price_cents: number;
70
- discount: number;
71
- vat_pct: number;
72
- tax_included: boolean;
73
- entry_duration: number | null;
74
- min_persons: number;
75
- max_persons: number;
76
- quota_ids: number[];
77
- first_entry: number;
78
- last_entry: number;
79
- personalizeable: boolean;
80
- attendees: boolean | string;
81
- identification: boolean | string;
82
- free_timing: boolean;
83
- is_collective: boolean;
84
- is_upgrade: boolean;
85
- is_mantle: boolean;
86
- description: string | null;
87
- sub_ticket_ids: number[];
88
- sub_tickets: {
89
- [key: string]: {
90
- title?: string;
91
- min_persons?: number;
92
- max_persons?: number;
93
- description?: string | null;
94
- };
95
- } | null;
96
- is_sub_ticket: boolean;
97
- created_at: string;
98
- updated_at: string;
99
- shipped_with_merchandise_id: number | null;
100
- restricted_shop_account: boolean;
101
- cash_point_order: number;
102
- dynamic_prices: {
103
- [key: string]: number;
104
- } | null;
105
- } | {
106
- uid: number;
107
- selectedTime: string;
108
- product_type: import('../../../lib/models/cart/types').ProductType;
109
- type: import('../../../lib/models/ticket/UITicket.svelte').UITicketType;
110
- shop_order: number;
111
- id: number;
112
- title: string;
113
- ticket_type: "time_slot" | "annual" | "normal";
114
- bookable: boolean;
115
- museum_ids: number[];
116
- exhibition_ids: number[];
117
- price_cents: number;
118
- discount: number;
119
- vat_pct: number;
120
- tax_included: boolean;
121
- entry_duration: number | null;
122
- quota_ids: number[];
123
- first_entry: number;
124
- last_entry: number;
125
- personalizeable: boolean;
126
- attendees: boolean | string;
127
- identification: boolean | string;
128
- free_timing: boolean;
129
- is_collective: boolean;
130
- is_upgrade: boolean;
131
- is_mantle: boolean;
132
- description: string | null;
133
- sub_ticket_ids: number[];
134
- sub_tickets: {
135
- [key: string]: {
136
- title?: string;
137
- min_persons?: number;
138
- max_persons?: number;
139
- description?: string | null;
140
- };
141
- } | null;
142
- is_sub_ticket: boolean;
143
- created_at: string;
144
- updated_at: string;
145
- cash_point_order: number;
146
- shipped_with_merchandise_id: number | null;
147
- restricted_shop_account: boolean;
148
- min_persons: number;
149
- max_persons: number;
150
- dynamic_prices?: {
151
- [key: string]: number;
152
- } | null;
153
- };
1
+ export declare function createMockUITicket(): any;
@@ -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
- return this.apiPost(`/api/v4/cart`, { body: params, requiredFields: ["items"] });
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);
@@ -17169,18 +17177,33 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17169
17177
  }
17170
17178
  return fallback;
17171
17179
  }
17180
+ function resolveQuantitySource(attrs) {
17181
+ return "quantity" in attrs && attrs.quantity !== void 0 ? attrs.quantity : attrs.quantities;
17182
+ }
17183
+ function resolveApiQuantity(attrs) {
17184
+ return getQuantity(resolveQuantitySource(attrs), 0);
17185
+ }
17186
+ function getScalePriceId(attrs) {
17187
+ const source2 = resolveQuantitySource(attrs);
17188
+ if (source2 && typeof source2 === "object") {
17189
+ const keys = Object.keys(source2);
17190
+ if (keys.length > 0) return Number(keys[0]);
17191
+ }
17192
+ return void 0;
17193
+ }
17172
17194
  function createDisplayCart(baseCart, apiItems) {
17173
17195
  const displayCart = createCart();
17174
17196
  const appliedCoupons = /* @__PURE__ */ new Set();
17175
17197
  baseCart.coupons.forEach((coupon) => displayCart.addCoupon(coupon));
17176
17198
  apiItems.forEach((apiItem) => {
17177
17199
  const attrs = apiItem.attributes;
17200
+ const scalePriceId = getScalePriceId(attrs);
17178
17201
  const itemInBaseCart = baseCart.items.find(
17179
- (i) => i.type.toLowerCase() === apiItem.type.toLowerCase() && i.product.id === attrs.id && (!attrs.time || i.time === attrs.time)
17202
+ (i) => i.type.toLowerCase() === apiItem.type.toLowerCase() && i.product.id === attrs.id && (!attrs.time || i.time === attrs.time) && (scalePriceId === void 0 || isUIScaledPricesTicket(i.product) && i.product.scale_price_id === scalePriceId)
17180
17203
  );
17181
17204
  if (!itemInBaseCart) {
17182
17205
  console.error("(go-cart) Ignoring unmatched cart line", { type: apiItem.type, attrs });
17183
- return [];
17206
+ return;
17184
17207
  }
17185
17208
  if (attrs.coupon) {
17186
17209
  displayCart.addCoupon(attrs.coupon);
@@ -17190,10 +17213,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17190
17213
  });
17191
17214
  return { cart: displayCart, appliedCoupons };
17192
17215
  }
17193
- function resolveApiQuantity(attrs) {
17194
- const source2 = "quantity" in attrs && attrs.quantity !== void 0 ? attrs.quantity : attrs.quantities;
17195
- return getQuantity(source2, 0);
17196
- }
17197
17216
  function createDisplayCartItem(cartItem, attrs) {
17198
17217
  const quantity = resolveApiQuantity(attrs);
17199
17218
  const displayPrice = attrs.price_cents ?? cartItem.product.price_cents;
@@ -17231,11 +17250,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17231
17250
  get$2(cart).items.map((i) => i.uuid + ":" + i.quantity + ":" + i.time);
17232
17251
  get$2(cart).coupons.join("|");
17233
17252
  const currentRequest = ++requestId;
17234
- if (get$2(cart).items.length === 0) {
17253
+ if (get$2(cart).items.length === 0 || get$2(cart).coupons.length === 0) {
17235
17254
  set(displayCart, get$2(cart), true);
17255
+ set(appliedCoupons, /* @__PURE__ */ new Set(), true);
17236
17256
  return;
17237
17257
  }
17238
- (async () => {
17258
+ void (async () => {
17239
17259
  try {
17240
17260
  const { items, coupons } = get$2(cart).orderData();
17241
17261
  const response = await shop.createCart({ items, coupons });
@@ -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
- return this.apiPost(`/api/v4/cart`, { body: params, requiredFields: ["items"] });
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);
@@ -17169,18 +17177,33 @@ function getQuantity(value, fallback) {
17169
17177
  }
17170
17178
  return fallback;
17171
17179
  }
17180
+ function resolveQuantitySource(attrs) {
17181
+ return "quantity" in attrs && attrs.quantity !== void 0 ? attrs.quantity : attrs.quantities;
17182
+ }
17183
+ function resolveApiQuantity(attrs) {
17184
+ return getQuantity(resolveQuantitySource(attrs), 0);
17185
+ }
17186
+ function getScalePriceId(attrs) {
17187
+ const source2 = resolveQuantitySource(attrs);
17188
+ if (source2 && typeof source2 === "object") {
17189
+ const keys = Object.keys(source2);
17190
+ if (keys.length > 0) return Number(keys[0]);
17191
+ }
17192
+ return void 0;
17193
+ }
17172
17194
  function createDisplayCart(baseCart, apiItems) {
17173
17195
  const displayCart = createCart();
17174
17196
  const appliedCoupons = /* @__PURE__ */ new Set();
17175
17197
  baseCart.coupons.forEach((coupon) => displayCart.addCoupon(coupon));
17176
17198
  apiItems.forEach((apiItem) => {
17177
17199
  const attrs = apiItem.attributes;
17200
+ const scalePriceId = getScalePriceId(attrs);
17178
17201
  const itemInBaseCart = baseCart.items.find(
17179
- (i) => i.type.toLowerCase() === apiItem.type.toLowerCase() && i.product.id === attrs.id && (!attrs.time || i.time === attrs.time)
17202
+ (i) => i.type.toLowerCase() === apiItem.type.toLowerCase() && i.product.id === attrs.id && (!attrs.time || i.time === attrs.time) && (scalePriceId === void 0 || isUIScaledPricesTicket(i.product) && i.product.scale_price_id === scalePriceId)
17180
17203
  );
17181
17204
  if (!itemInBaseCart) {
17182
17205
  console.error("(go-cart) Ignoring unmatched cart line", { type: apiItem.type, attrs });
17183
- return [];
17206
+ return;
17184
17207
  }
17185
17208
  if (attrs.coupon) {
17186
17209
  displayCart.addCoupon(attrs.coupon);
@@ -17190,10 +17213,6 @@ function createDisplayCart(baseCart, apiItems) {
17190
17213
  });
17191
17214
  return { cart: displayCart, appliedCoupons };
17192
17215
  }
17193
- function resolveApiQuantity(attrs) {
17194
- const source2 = "quantity" in attrs && attrs.quantity !== void 0 ? attrs.quantity : attrs.quantities;
17195
- return getQuantity(source2, 0);
17196
- }
17197
17216
  function createDisplayCartItem(cartItem, attrs) {
17198
17217
  const quantity = resolveApiQuantity(attrs);
17199
17218
  const displayPrice = attrs.price_cents ?? cartItem.product.price_cents;
@@ -17231,11 +17250,12 @@ function Cart($$anchor, $$props) {
17231
17250
  get$2(cart).items.map((i) => i.uuid + ":" + i.quantity + ":" + i.time);
17232
17251
  get$2(cart).coupons.join("|");
17233
17252
  const currentRequest = ++requestId;
17234
- if (get$2(cart).items.length === 0) {
17253
+ if (get$2(cart).items.length === 0 || get$2(cart).coupons.length === 0) {
17235
17254
  set(displayCart, get$2(cart), true);
17255
+ set(appliedCoupons, /* @__PURE__ */ new Set(), true);
17236
17256
  return;
17237
17257
  }
17238
- (async () => {
17258
+ void (async () => {
17239
17259
  try {
17240
17260
  const { items, coupons } = get$2(cart).orderData();
17241
17261
  const response = await shop.createCart({ items, coupons });
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "name": "Giantmonkey GmbH"
5
5
  },
6
6
  "license": "MIT",
7
- "version": "1.54.0",
7
+ "version": "1.54.2",
8
8
  "type": "module",
9
9
  "main": "./dist-js/gomus-webcomponents.iife.js",
10
10
  "module": "./dist-js/gomus-webcomponents.iife.js",
@@ -1,3 +0,0 @@
1
- import { CalendarDate } from '@internationalized/date';
2
- import { Writable } from 'svelte/store';
3
- export declare const selectedDate: Writable<CalendarDate>;
@@ -1 +0,0 @@
1
- export declare const browser: import('svelte/store').Readable<boolean>;
@@ -1,23 +0,0 @@
1
- export declare const applyAction: (result: any) => void;
2
- export declare function deserialize(result: any): any;
3
- export declare function enhance(form_element: any, submit?: () => {
4
- new (executor: (resolve: (value: void | PromiseLike<void>) => void, reject: (reason?: any) => void) => void): Promise<void>;
5
- all<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>[]>;
6
- all<T extends readonly unknown[] | []>(values: T): Promise<{ -readonly [P in keyof T]: Awaited<T[P]>; }>;
7
- race<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>>;
8
- race<T extends readonly unknown[] | []>(values: T): Promise<Awaited<T[number]>>;
9
- readonly prototype: Promise<any>;
10
- reject<T = never>(reason?: any): Promise<T>;
11
- resolve(): Promise<void>;
12
- resolve<T>(value: T): Promise<Awaited<T>>;
13
- resolve<T>(value: T | PromiseLike<T>): Promise<Awaited<T>>;
14
- allSettled<T extends readonly unknown[] | []>(values: T): Promise<{ -readonly [P in keyof T]: PromiseSettledResult<Awaited<T[P]>>; }>;
15
- allSettled<T>(values: Iterable<T | PromiseLike<T>>): Promise<PromiseSettledResult<Awaited<T>>[]>;
16
- any<T extends readonly unknown[] | []>(values: T): Promise<Awaited<T[number]>>;
17
- any<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>>;
18
- withResolvers<T>(): PromiseWithResolvers<T>;
19
- try<T, U extends unknown[]>(callbackFn: (...args: U) => T | PromiseLike<T>, ...args: U): Promise<Awaited<T>>;
20
- readonly [Symbol.species]: PromiseConstructor;
21
- }): {
22
- destroy(): void;
23
- };
@@ -1,4 +0,0 @@
1
- export declare const beforeCallbacks: never[];
2
- export declare const beforeNavigate: () => void;
3
- export declare const goto: () => void;
4
- export declare const invalidateAll: () => void;
@@ -1,2 +0,0 @@
1
- export declare const navigating: import('svelte/store').Readable<boolean>;
2
- export declare const page: import('svelte/store').Writable<Page>;