@depict-ai/utilishared 1.0.27 → 1.0.29

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,6 +1,6 @@
1
1
  /// <reference path="../jsx.d.ts" />
2
2
  import { EUnavailabilityType } from "@depict-ai/types/api/TrackV2Request";
3
- export const version = "1.0.27";
3
+ export const version = "1.0.29";
4
4
  export const is_debug: boolean;
5
5
  /**
6
6
  * Sets the prefix of dlog, dwarn, and derror messages in the browser console. Defaults to `[Depict]`.
@@ -13,7 +13,7 @@ export function derror(...args: any[]): void;
13
13
  * Adds things to the object we send to backend in the query params to report the package versions used
14
14
  */
15
15
  export const version_info: {
16
- [key: string]: string;
16
+ [key: string]: string;
17
17
  };
18
18
  export function add_to_version_info(package_name: string, version: string): void;
19
19
  /**
@@ -39,29 +39,29 @@ export function base64_decode_unicode(str: any): string;
39
39
  * subscriber_done decrements the number of subscribers we are waiting for, if this isn't called call_subscribers will get stuck. It also triggers a new call to call_subscribers
40
40
  */
41
41
  export class RawObservableInformation<T> {
42
- subscribers_: ((val: T) => void)[];
43
- waiting_for_update_: number;
44
- queue_: T[];
45
- last_processed_value_: T | undefined;
46
- has_had_value_: boolean;
47
- push_value_: (value: T) => void;
48
- call_subscribers_: () => void;
49
- subscriber_done_: () => void;
42
+ subscribers_: ((val: T) => void)[];
43
+ waiting_for_update_: number;
44
+ queue_: T[];
45
+ last_processed_value_: T | undefined;
46
+ has_had_value_: boolean;
47
+ push_value_: (value: T) => void;
48
+ call_subscribers_: () => void;
49
+ subscriber_done_: () => void;
50
50
  }
51
51
  /**
52
52
  * Makes an asyncIterable function out of a RawObservableInformation instance
53
53
  */
54
54
  export function make_simple_async_iterable<T>(state: RawObservableInformation<T>): ((...values: T[]) => void) & {
55
- [Symbol.asyncIterator](): {
56
- next(): Promise<{
57
- value: T;
58
- done: false;
59
- }>;
60
- return(): Promise<{
61
- value: T;
62
- done: false;
63
- }>;
64
- };
55
+ [Symbol.asyncIterator](): {
56
+ next(): Promise<{
57
+ value: T;
58
+ done: false;
59
+ }>;
60
+ return(): Promise<{
61
+ value: T;
62
+ done: false;
63
+ }>;
64
+ };
65
65
  };
66
66
  /**
67
67
  * You know how you can write `break` inside of a `for await` loop to exit it? Well, this lets you break the loop from outside. Pass any async iterable that never throws and you will get back a function and a specially proxied async iterable. Whenever you call the function all for await loops iterating the returned iterable will break. Note: This will add some extra ticks because awaiting thenable objects takes more ticks than awaiting promises.
@@ -70,9 +70,9 @@ export function make_simple_async_iterable<T>(state: RawObservableInformation<T>
70
70
  */
71
71
  export function make_asyncIterable_exiter<T>(async_iterable: AsyncIterable<T>): [() => void, AsyncIterable<T>];
72
72
  export type IPNS<T> = ((...values: T[]) => void) & AsyncIterable<T> & {
73
- exit: () => void;
74
- state: T | undefined;
75
- latest_call_value: T | undefined;
73
+ exit: () => void;
74
+ state: T | undefined;
75
+ latest_call_value: T | undefined;
76
76
  };
77
77
  /**
78
78
  * Creates an async iterable IPNS with "the old" API (we should maybe create a new one? idk). BUT which is resistant against things taking more than one tick. Meaning you can use `await` in the `for await` body without missing values
@@ -122,9 +122,9 @@ export function is_available_in(obj: Object, property: PropertyKey, ...sub_objec
122
122
  export function find_descriptor(obj: Object, prop: PropertyKey): PropertyDescriptor | undefined;
123
123
  export function variable_setter_to_ipns<T>(obj: Object, variable: PropertyKey, async_iterator_should_return_state_on_first_call?: boolean): IPNS<T>;
124
124
  export const Sentry: Hub | {
125
- captureException: (...args: any[]) => void;
126
- captureMessage: (...args: any[]) => void;
127
- withScope: (...args: any[]) => void;
125
+ captureException: (...args: any[]) => void;
126
+ captureMessage: (...args: any[]) => void;
127
+ withScope: (...args: any[]) => void;
128
128
  };
129
129
  /**
130
130
  * Severity level to send to sentry.
@@ -155,8 +155,8 @@ export function catchify<T extends any[], X>(fn: (...args: T) => X, message?: st
155
155
  * })
156
156
  */
157
157
  export function report(msg: Error | [Error, string], severity: Severity, input_data?: {
158
- [key: string]: any;
159
- stack?: never;
158
+ [key: string]: any;
159
+ stack?: never;
160
160
  }): void;
161
161
  /**
162
162
  * Gives a random number between min and max (potentially including min and max).
@@ -180,41 +180,37 @@ export function deparallelize_no_drop<A extends any[], O>(the_function: AsyncFun
180
180
  * @deprecated use async_iterable_ipns instead. It has a nicer API and more of an ecosystem.
181
181
  */
182
182
  export class infinite_promise_no_skip<T> {
183
- #private;
184
- promise: Promise<T>;
185
- resolve: (value: T) => void;
183
+ #private;
184
+ promise: Promise<T>;
185
+ resolve: (value: T) => void;
186
186
  }
187
187
  type ws_event_callback = typeof WebSocket.prototype.onmessage;
188
188
  export interface AutoReconnectingWS {
189
- onclose: ws_event_callback;
190
- onerrror: ws_event_callback;
191
- onmessage: ws_event_callback;
192
- onopen: ws_event_callback;
189
+ onclose: ws_event_callback;
190
+ onerrror: ws_event_callback;
191
+ onmessage: ws_event_callback;
192
+ onopen: ws_event_callback;
193
193
  }
194
194
  export class AutoReconnectingWS extends EventTarget {
195
- #private;
196
- current_socket: WebSocket;
197
- restart_ws: (arg0?: any) => any;
198
- increase_fails(): void;
199
- send(...args: Parameters<typeof WebSocket.prototype.send>): Promise<void>;
200
- constructor(url: string, protocols?: string | string[], options?: {
201
- max_backoff_ms?: number;
202
- });
195
+ #private;
196
+ current_socket: WebSocket;
197
+ restart_ws: (arg0?: any) => any;
198
+ increase_fails(): void;
199
+ send(...args: Parameters<typeof WebSocket.prototype.send>): Promise<void>;
200
+ constructor(url: string, protocols?: string | string[], options?: {
201
+ max_backoff_ms?: number;
202
+ });
203
203
  }
204
204
  export class DepictAPIWS extends AutoReconnectingWS {
205
- #private;
206
- ensure_sent(payload: {
207
- id: string;
208
- event?: depict_body;
209
- [key: string]: any;
210
- }): Promise<any[]>;
211
- constructor(...params: [
212
- url: ConstructorParameters<typeof AutoReconnectingWS>[0],
213
- protocols?: ConstructorParameters<typeof AutoReconnectingWS>[1],
214
- options?: ConstructorParameters<typeof AutoReconnectingWS>[2] & Partial<{
215
- initial_retry_ms: number;
216
- }>
217
- ]);
205
+ #private;
206
+ ensure_sent(payload: {
207
+ id: string;
208
+ event?: depict_body;
209
+ [key: string]: any;
210
+ }): Promise<any[]>;
211
+ constructor(...params: [url: ConstructorParameters<typeof AutoReconnectingWS>[0], protocols?: ConstructorParameters<typeof AutoReconnectingWS>[1], options?: ConstructorParameters<typeof AutoReconnectingWS>[2] & Partial<{
212
+ initial_retry_ms: number;
213
+ }>]);
218
214
  }
219
215
  /**
220
216
  * Returns a random string
@@ -225,19 +221,17 @@ export function make_random_classname(): string;
225
221
  export const base_url: string;
226
222
  export type event_types = "page_view" | "click" | "add_to_cart" | "purchase" | "element_visible";
227
223
  declare const allowed_keys: readonly ["tenant", "market", "type", "user_id", "session_id", "product_id", "entity_identifiers", "url", "entity_price", "currency", "document_referrer", "document_width", "attribution_id", "recommendation_id", "click_location", "ab_test_group", "variant_ids", "dsid", "transaction_id", "error_type", "detail", "recommendation_type", "search_result_id", "product_listing_result_id"];
228
- export type depict_body = Partial<{
229
- [K in (typeof allowed_keys)[number]]: any;
230
- }>;
224
+ export type depict_body = Partial<{ [K in (typeof allowed_keys)[number]]: any }>;
231
225
  export type depict_payload = depict_body[];
232
226
  type any_properties = {
233
- [key: string]: any;
227
+ [key: string]: any;
234
228
  };
235
229
  export type noisy_depict_payload = (depict_body & any_properties)[];
236
230
  export const filter_depict_payload: (payload: noisy_depict_payload) => depict_payload | undefined;
237
231
  export const send_websocket: (bodies: depict_payload) => Promise<void | undefined>;
238
232
  export const send_depict_unfiltered: (payload: depict_payload, use_ws?: any) => boolean | Promise<void | undefined> | undefined;
239
233
  export const foolproof_send_beacon: (url: string, payload: {
240
- [key: string]: any;
234
+ [key: string]: any;
241
235
  }) => boolean | undefined;
242
236
  export const send_depict: (payload: noisy_depict_payload, use_ws?: boolean | undefined) => boolean | Promise<void | undefined> | undefined;
243
237
  export let get_depict_id: () => string;
@@ -247,106 +241,106 @@ export const set_depict_id_fn: (newfn: () => string) => (() => string) | undefin
247
241
  export const set_user_id_fn: (newfn: () => string) => (() => string) | undefined;
248
242
  export const set_session_id_fn: (newfn: () => string) => (() => string) | undefined;
249
243
  export type TrackingEventContextData = {
250
- user_id: string;
251
- dsid: string;
252
- session_id?: string;
253
- url: string;
254
- document_width: number;
255
- document_referrer: string;
244
+ user_id: string;
245
+ dsid: string;
246
+ session_id?: string;
247
+ url: string;
248
+ document_width: number;
249
+ document_referrer: string;
256
250
  };
257
251
  export const get_tracking_event_context_data: () => TrackingEventContextData;
258
252
  /**
259
253
  * Sends a depict tracking event with prefilled data
260
254
  */
261
255
  export const depict_prefilled: (vars: Partial<{
262
- type: any;
263
- detail: any;
264
- url: any;
265
- currency: any;
266
- tenant: any;
267
- market: any;
268
- user_id: any;
269
- session_id: any;
270
- product_id: any;
271
- entity_identifiers: any;
272
- entity_price: any;
273
- document_referrer: any;
274
- document_width: any;
275
- attribution_id: any;
276
- recommendation_id: any;
277
- click_location: any;
278
- ab_test_group: any;
279
- variant_ids: any;
280
- dsid: any;
281
- transaction_id: any;
282
- error_type: any;
283
- recommendation_type: any;
284
- search_result_id: any;
285
- product_listing_result_id: any;
256
+ type: any;
257
+ detail: any;
258
+ url: any;
259
+ currency: any;
260
+ tenant: any;
261
+ market: any;
262
+ user_id: any;
263
+ session_id: any;
264
+ product_id: any;
265
+ entity_identifiers: any;
266
+ entity_price: any;
267
+ document_referrer: any;
268
+ document_width: any;
269
+ attribution_id: any;
270
+ recommendation_id: any;
271
+ click_location: any;
272
+ ab_test_group: any;
273
+ variant_ids: any;
274
+ dsid: any;
275
+ transaction_id: any;
276
+ error_type: any;
277
+ recommendation_type: any;
278
+ search_result_id: any;
279
+ product_listing_result_id: any;
286
280
  }> & {
287
- [key: string]: any;
281
+ [key: string]: any;
288
282
  }, use_ws?: boolean | undefined) => boolean | Promise<void | undefined> | undefined;
289
283
  export const depict_click: (vars: Partial<{
290
- type: any;
291
- detail: any;
292
- url: any;
293
- currency: any;
294
- tenant: any;
295
- market: any;
296
- user_id: any;
297
- session_id: any;
298
- product_id: any;
299
- entity_identifiers: any;
300
- entity_price: any;
301
- document_referrer: any;
302
- document_width: any;
303
- attribution_id: any;
304
- recommendation_id: any;
305
- click_location: any;
306
- ab_test_group: any;
307
- variant_ids: any;
308
- dsid: any;
309
- transaction_id: any;
310
- error_type: any;
311
- recommendation_type: any;
312
- search_result_id: any;
313
- product_listing_result_id: any;
284
+ type: any;
285
+ detail: any;
286
+ url: any;
287
+ currency: any;
288
+ tenant: any;
289
+ market: any;
290
+ user_id: any;
291
+ session_id: any;
292
+ product_id: any;
293
+ entity_identifiers: any;
294
+ entity_price: any;
295
+ document_referrer: any;
296
+ document_width: any;
297
+ attribution_id: any;
298
+ recommendation_id: any;
299
+ click_location: any;
300
+ ab_test_group: any;
301
+ variant_ids: any;
302
+ dsid: any;
303
+ transaction_id: any;
304
+ error_type: any;
305
+ recommendation_type: any;
306
+ search_result_id: any;
307
+ product_listing_result_id: any;
314
308
  }> & {
315
- [key: string]: any;
309
+ [key: string]: any;
316
310
  }) => boolean | Promise<void | undefined> | undefined;
317
311
  export const depict_add_to_cart: (vars: Partial<{
318
- type: any;
319
- detail: any;
320
- url: any;
321
- currency: any;
322
- tenant: any;
323
- market: any;
324
- user_id: any;
325
- session_id: any;
326
- product_id: any;
327
- entity_identifiers: any;
328
- entity_price: any;
329
- document_referrer: any;
330
- document_width: any;
331
- attribution_id: any;
332
- recommendation_id: any;
333
- click_location: any;
334
- ab_test_group: any;
335
- variant_ids: any;
336
- dsid: any;
337
- transaction_id: any;
338
- error_type: any;
339
- recommendation_type: any;
340
- search_result_id: any;
341
- product_listing_result_id: any;
312
+ type: any;
313
+ detail: any;
314
+ url: any;
315
+ currency: any;
316
+ tenant: any;
317
+ market: any;
318
+ user_id: any;
319
+ session_id: any;
320
+ product_id: any;
321
+ entity_identifiers: any;
322
+ entity_price: any;
323
+ document_referrer: any;
324
+ document_width: any;
325
+ attribution_id: any;
326
+ recommendation_id: any;
327
+ click_location: any;
328
+ ab_test_group: any;
329
+ variant_ids: any;
330
+ dsid: any;
331
+ transaction_id: any;
332
+ error_type: any;
333
+ recommendation_type: any;
334
+ search_result_id: any;
335
+ product_listing_result_id: any;
342
336
  }> & {
343
- [key: string]: any;
337
+ [key: string]: any;
344
338
  }) => boolean | Promise<void | undefined> | undefined;
345
339
  export type ConsentObj = {
346
- marketing: boolean;
347
- necessary: boolean;
348
- preferences: boolean;
349
- statistics: boolean;
340
+ marketing: boolean;
341
+ necessary: boolean;
342
+ preferences: boolean;
343
+ statistics: boolean;
350
344
  };
351
345
  export function get_cookie(cookie_name: string): string | undefined;
352
346
  export function Promise_Any<T>(promises: (T | PromiseLike<T>)[] | Iterable<T | PromiseLike<T>>): Promise<T>;
@@ -377,20 +371,20 @@ export function contextmenu_callback(e: Event, product_id: string): Promise<void
377
371
  */
378
372
  type Optional<T, K extends keyof T> = Omit<T, K> & Partial<T>;
379
373
  export class ElementObserverEvent<ElemType extends CallbackableNode = HTMLElement, SelectorType extends string | CallbackableNode = string | CallbackableNode> {
380
- constructor(opts: {
381
- element_: ElemType;
382
- selector_: SelectorType;
383
- disconnector_: Disconnector;
384
- mutation_record_?: MutationRecord;
385
- event_?: ListenerNames;
386
- });
374
+ constructor(opts: {
375
+ element_: ElemType;
376
+ selector_: SelectorType;
377
+ disconnector_: Disconnector;
378
+ mutation_record_?: MutationRecord;
379
+ event_?: ListenerNames;
380
+ });
387
381
  }
388
382
  export interface ElementObserverEvent<ElemType extends CallbackableNode = HTMLElement, SelectorType extends string | CallbackableNode = string | CallbackableNode> {
389
- element: ElemType;
390
- selector: SelectorType;
391
- disconnector: Disconnector;
392
- mutation_record?: MutationRecord;
393
- event?: ListenerNames;
383
+ element: ElemType;
384
+ selector: SelectorType;
385
+ disconnector: Disconnector;
386
+ mutation_record?: MutationRecord;
387
+ event?: ListenerNames;
394
388
  }
395
389
  /**
396
390
  * Element.querySelectorAll is broken in Chrome 37-latest, use this instead.
@@ -401,56 +395,56 @@ export interface ElementObserverEvent<ElemType extends CallbackableNode = HTMLEl
401
395
  */
402
396
  export function patched_querySelectorAll<T extends Element>(element: Element | Document | DocumentFragment | null, selector: string): NodeListOf<T> | T[] | undefined;
403
397
  export interface ElementObserver {
404
- /**
405
- * Immediately calls the callback with an ElementObserverEvent for nodes existing in the DOM that match the provided selector OR are the selector,
406
- * also calls the callback with an ElementObserverEvent whenever ANYTHING in the DOM occurs that makes an element match the provided selector.
407
- * @param selector Selector string or element to listen for
408
- * @param callback Function that will be called with the ElementObserverEvent. Exceptions and promise rejections of the callback will be caught and sent to sentry.
409
- */
410
- onexists: EO_listener_also_taking_els;
411
- /**
412
- * Dispatches an ElementObserverEvent whenever a node is added to the DOM that matches the specified selector OR is the selector.
413
- * @param selector CSS selector or element to observe
414
- * @param callback Function that will be called with the ElementObserverEvent. Exceptions and promise rejections of the callback will be caught and sent to sentry.
415
- **/
416
- oncreation: EO_listener_also_taking_els;
417
- /**
418
- * Dispatches an ElementObserverEvent whenever a node is removed from the DOM that matches the specified selector OR is the selector.
419
- * @param selector CSS selector or element to observe
420
- * @param callback Function that will be called with the ElementObserverEvent. Exceptions and promise rejections of the callback will be caught and sent to sentry.
421
- */
422
- onremoved: EO_listener_also_taking_els;
423
- /**
424
- * Dispatches an ElementObserverEvent whenever a node that matches the specified selector or its children change in the DOM.
425
- * @param selector CSS selector or element to observe
426
- * @param callback Function that will be called with the ElementObserverEvent. Exceptions and promise rejections of the callback will be caught and sent to sentry.
427
- */
428
- onchange: EO_listener;
429
- /**
430
- * Immediately calls the callback with an ElementObserverEvent on nodes that match the provided selector OR are the selector.
431
- * @param selector Selector string or element to look for in the DOM
432
- * @param callback Function that will be called with the ElementObserverEvent. Exceptions and promise rejections of the callback will be caught and sent to sentry.
433
- */
434
- ifexists: EO_listener_also_taking_els;
435
- /**
436
- * See docs for observer.onexists. Will return a Promise that resolves to the element out of the first call of an observer.onexists callback.
437
- * @param selector Selector string or element to wait for
438
- * @param timeout timeout to stop listening and resolve the Promise with `undefined`
439
- */
440
- wait_for_element: <ElemType extends HTMLElement = HTMLElement>(selector: string | ElemType, timeout?: number) => Promise<ElemType>;
441
- /**
442
- * See docs for observer.on<listener>. Will return a Promise that resolves to the first element that matches the given listener and selector. I.e. `wait_for_listener("removed", ".old-recs");` will resolve to the first element matching `.old-recs` that is removed from the DOM
443
- * @param listener one of the possible functions on ElementObserver that start with "on", without the "on". So "creation", "change", "exists" or "removed"
444
- * @param selector String containing CSS selector
445
- * @param timeout timeout to stop listening and resolve the Promise with `undefined`
446
- */
447
- wait_for_listener: <ElemType extends HTMLElement = HTMLElement, SelectorType = string | CallbackableNode>(listener: SelectorType extends CallbackableNode ? "creation" | "removed" : "exists" | "creation" | "removed" | "change", selector: SelectorType, timeout?: number) => Promise<ElemType>;
398
+ /**
399
+ * Immediately calls the callback with an ElementObserverEvent for nodes existing in the DOM that match the provided selector OR are the selector,
400
+ * also calls the callback with an ElementObserverEvent whenever ANYTHING in the DOM occurs that makes an element match the provided selector.
401
+ * @param selector Selector string or element to listen for
402
+ * @param callback Function that will be called with the ElementObserverEvent. Exceptions and promise rejections of the callback will be caught and sent to sentry.
403
+ */
404
+ onexists: EO_listener_also_taking_els;
405
+ /**
406
+ * Dispatches an ElementObserverEvent whenever a node is added to the DOM that matches the specified selector OR is the selector.
407
+ * @param selector CSS selector or element to observe
408
+ * @param callback Function that will be called with the ElementObserverEvent. Exceptions and promise rejections of the callback will be caught and sent to sentry.
409
+ **/
410
+ oncreation: EO_listener_also_taking_els;
411
+ /**
412
+ * Dispatches an ElementObserverEvent whenever a node is removed from the DOM that matches the specified selector OR is the selector.
413
+ * @param selector CSS selector or element to observe
414
+ * @param callback Function that will be called with the ElementObserverEvent. Exceptions and promise rejections of the callback will be caught and sent to sentry.
415
+ */
416
+ onremoved: EO_listener_also_taking_els;
417
+ /**
418
+ * Dispatches an ElementObserverEvent whenever a node that matches the specified selector or its children change in the DOM.
419
+ * @param selector CSS selector or element to observe
420
+ * @param callback Function that will be called with the ElementObserverEvent. Exceptions and promise rejections of the callback will be caught and sent to sentry.
421
+ */
422
+ onchange: EO_listener;
423
+ /**
424
+ * Immediately calls the callback with an ElementObserverEvent on nodes that match the provided selector OR are the selector.
425
+ * @param selector Selector string or element to look for in the DOM
426
+ * @param callback Function that will be called with the ElementObserverEvent. Exceptions and promise rejections of the callback will be caught and sent to sentry.
427
+ */
428
+ ifexists: EO_listener_also_taking_els;
429
+ /**
430
+ * See docs for observer.onexists. Will return a Promise that resolves to the element out of the first call of an observer.onexists callback.
431
+ * @param selector Selector string or element to wait for
432
+ * @param timeout timeout to stop listening and resolve the Promise with `undefined`
433
+ */
434
+ wait_for_element: <ElemType extends HTMLElement = HTMLElement>(selector: string | ElemType, timeout?: number) => Promise<ElemType>;
435
+ /**
436
+ * See docs for observer.on<listener>. Will return a Promise that resolves to the first element that matches the given listener and selector. I.e. `wait_for_listener("removed", ".old-recs");` will resolve to the first element matching `.old-recs` that is removed from the DOM
437
+ * @param listener one of the possible functions on ElementObserver that start with "on", without the "on". So "creation", "change", "exists" or "removed"
438
+ * @param selector String containing CSS selector
439
+ * @param timeout timeout to stop listening and resolve the Promise with `undefined`
440
+ */
441
+ wait_for_listener: <ElemType extends HTMLElement = HTMLElement, SelectorType = string | CallbackableNode>(listener: SelectorType extends CallbackableNode ? "creation" | "removed" : "exists" | "creation" | "removed" | "change", selector: SelectorType, timeout?: number) => Promise<ElemType>;
448
442
  }
449
443
  export class ElementObserver {
450
- #private;
451
- constructor(options?: {
452
- territory?: HTMLElement | Document | DocumentFragment;
453
- });
444
+ #private;
445
+ constructor(options?: {
446
+ territory?: HTMLElement | Document | DocumentFragment;
447
+ });
454
448
  }
455
449
  type EO_listener = <ElemType extends HTMLElement = HTMLElement>(selector: string, callback: ObserverCallbackFunction<ElemType>) => Disconnector;
456
450
  type EO_listener_also_taking_els = <ElemType extends CallbackableNode = HTMLElement, SelectorType extends string | CallbackableNode = string | CallbackableNode>(selector: SelectorType, callback: ObserverCallbackFunction<ElemType, SelectorType>) => Disconnector;
@@ -473,15 +467,15 @@ export function buildThresholdList(numSteps: number): number[];
473
467
  */
474
468
  export const impression_tracking_post_processor: RR_PostProcessor<any>;
475
469
  interface ImpressionTrackingOptions {
476
- /** The element to observe for impressions. */
477
- element: HTMLElement;
478
- /** The impression data to send to the api (this is combined with context data) */
479
- data: ExplicitImpressionEventData;
480
- /** When true the element will be observed by the IntersectionObserver only after it's inserted into the DOM.
481
- * Sometimes with a pollyfilled IntersectionObserver it ignores elements that are not in the DOM yet.
482
- * Defaults to true.
483
- * */
484
- wait_for_dom_insertion?: boolean;
470
+ /** The element to observe for impressions. */
471
+ element: HTMLElement;
472
+ /** The impression data to send to the api (this is combined with context data) */
473
+ data: ExplicitImpressionEventData;
474
+ /** When true the element will be observed by the IntersectionObserver only after it's inserted into the DOM.
475
+ * Sometimes with a pollyfilled IntersectionObserver it ignores elements that are not in the DOM yet.
476
+ * Defaults to true.
477
+ * */
478
+ wait_for_dom_insertion?: boolean;
485
479
  }
486
480
  /**
487
481
  * Registers the passed element for impression tracking.
@@ -490,7 +484,11 @@ interface ImpressionTrackingOptions {
490
484
  *
491
485
  * @return A function to stop observing the element for impressions
492
486
  */
493
- export const impression_track_element: ({ element, data, wait_for_dom_insertion, }: ImpressionTrackingOptions) => () => void;
487
+ export const impression_track_element: ({
488
+ element,
489
+ data,
490
+ wait_for_dom_insertion
491
+ }: ImpressionTrackingOptions) => () => void;
494
492
  /** The start and end visibility threshold for an intersection to count as an impression */
495
493
  export let impression_threshold: number[];
496
494
  export const set_impression_threshold: (start: number, end: number) => number[];
@@ -498,24 +496,24 @@ export const set_impression_threshold: (start: number, end: number) => number[];
498
496
  export const has_to_be_intersecting_for = 500;
499
497
  /** What explicit information is needed to form an ImpressionEvent */
500
498
  export type ExplicitImpressionEventData = {
501
- recommendation_type?: string;
502
- entity_price?: number;
503
- market?: string;
504
- tenant?: string;
505
- product_id?: string;
499
+ recommendation_type?: string;
500
+ entity_price?: number;
501
+ market?: string;
502
+ tenant?: string;
503
+ product_id?: string;
506
504
  } & ({
507
- recommendation_id: string;
505
+ recommendation_id: string;
508
506
  } | {
509
- search_result_id: string;
507
+ search_result_id: string;
510
508
  } | {
511
- product_listing_result_id: string;
509
+ product_listing_result_id: string;
512
510
  } | {
513
- suggestions_result_id: string;
511
+ suggestions_result_id: string;
514
512
  });
515
513
  /** What an impression event looks like when sent to the api */
516
514
  export type ImpressionEvent = {
517
- /** The type for impression events should be element_visible */
518
- type: "element_visible";
515
+ /** The type for impression events should be element_visible */
516
+ type: "element_visible";
519
517
  } & (ExplicitImpressionEventData | TrackingEventContextData);
520
518
  /**
521
519
  * Sends an impression event to the api.
@@ -564,19 +562,19 @@ export function on_next_navigation(callback: (new_href: string) => void): Promis
564
562
  */
565
563
  export function history_replacer(after_navigation: after_navig_fn, replace_replaceState?: boolean): Promise<void>;
566
564
  interface TrackingData {
567
- /** The active market, if any */
568
- market?: string;
569
- /** The merchant id */
570
- tenant: string;
565
+ /** The active market, if any */
566
+ market?: string;
567
+ /** The merchant id */
568
+ tenant: string;
571
569
  }
572
570
  export interface PageViewEventData extends TrackingData {
573
- /** If the page is a pdp, include the product_id */
574
- product_id?: string;
571
+ /** If the page is a pdp, include the product_id */
572
+ product_id?: string;
575
573
  }
576
574
  export interface PageViewTrackingData extends TrackingData {
577
- /** A function that returns the product_id of the product being displayed on href,
578
- * if the href points to a PDP */
579
- get_product_id: (href: string) => string | undefined | Promise<string | undefined>;
575
+ /** A function that returns the product_id of the product being displayed on href,
576
+ * if the href points to a PDP */
577
+ get_product_id: (href: string) => string | undefined | Promise<string | undefined>;
580
578
  }
581
579
  /**
582
580
  * Sends a page_view event to Depict tracking if it hasn't been sent yet for the current page url
@@ -617,142 +615,141 @@ export function cookiebot_get_cookie_ipns(): IPNS<ConsentObj>;
617
615
  */
618
616
  export const init_cookiebot_tracking: (anon_id?: any) => Promise<void | undefined>;
619
617
  declare global {
620
- interface Window {
621
- Cookiebot?: {
622
- name: string;
623
- consented: boolean;
624
- declined: boolean;
625
- changed: boolean;
626
- hasResponse: boolean;
627
- consentID: string;
628
- consent: Consent;
629
- isOutsideEU: boolean;
630
- isOutOfRegion: boolean;
631
- host: string;
632
- domain: string;
633
- currentPath: string;
634
- doNotTrack: boolean;
635
- consentLevel: string;
636
- isRenewal: boolean;
637
- forceShow: boolean;
638
- dialog: null;
639
- responseMode: string;
640
- serial: string;
641
- scriptId: string;
642
- scriptElement: ScriptElement;
643
- whitelist: any[];
644
- cookieList: CookieList;
645
- pathlist: any[];
646
- userIsInPath: boolean;
647
- cookieEnabled: boolean;
648
- versionChecked: boolean;
649
- versionRequested: boolean;
650
- version: number;
651
- latestVersion: number;
652
- isNewVersion: boolean;
653
- CDN: string;
654
- source: string;
655
- retryCounter: number;
656
- frameRetryCounter: number;
657
- bulkConsentFrameRetryCounter: number;
658
- setOnloadFrameRetryCounter: number;
659
- optOutLifetime: number;
660
- consentLifetime: null;
661
- framework: string;
662
- hasFramework: boolean;
663
- frameworkBlocked: boolean;
664
- frameworkLoaded: boolean;
665
- iframeReady: boolean;
666
- iframe: Iframe;
667
- bulkconsent: null;
668
- bulkresetdomains: any[];
669
- bulkconsentsubmitted: boolean;
670
- isbulkrenewal: boolean;
671
- wipe: Wipe;
672
- consentUTC: Date;
673
- IABConsentString: string;
674
- GACMConsentString: string;
675
- dataLayerName: string;
676
- loaded: boolean;
677
- autoblock: boolean;
678
- mutationObserver: null;
679
- mutationCounter: number;
680
- mutationFallback: boolean;
681
- mutationFallbackDocAttributes: any[];
682
- mutationHandlerFallbackCharsetLoaded: boolean;
683
- mutationAppName: string;
684
- mutationEventListeners: any[];
685
- mutationOnloadEventListeners: any[];
686
- mutateEventListeners: boolean;
687
- mutationHandlerFirstScript: null;
688
- postPonedMutations: any[];
689
- nonAsyncMutations: any[];
690
- deferMutations: any[];
691
- geoRegions: any[];
692
- userCountry: string;
693
- userCulture: string;
694
- windowOnloadTriggered: boolean;
695
- botDetectionDisabled: boolean;
696
- regulations: Regulations;
697
- regulationRegions: RegulationRegions;
698
- commonTrackers: CommonTrackers;
699
- configuration: Configuration;
700
- inlineConfiguration: null;
701
- processLinkClickCounter: number;
702
- performanceEntriesCounter: number;
703
- OverrideEventListenersOnloadFired: any[];
704
- OverrideEventListenersOnloadToFire: any[];
705
- fallbackScriptNodes: any[];
706
- fallbackDeferNodes: any[];
707
- };
708
- }
618
+ interface Window {
619
+ Cookiebot?: {
620
+ name: string;
621
+ consented: boolean;
622
+ declined: boolean;
623
+ changed: boolean;
624
+ hasResponse: boolean;
625
+ consentID: string;
626
+ consent: Consent;
627
+ isOutsideEU: boolean;
628
+ isOutOfRegion: boolean;
629
+ host: string;
630
+ domain: string;
631
+ currentPath: string;
632
+ doNotTrack: boolean;
633
+ consentLevel: string;
634
+ isRenewal: boolean;
635
+ forceShow: boolean;
636
+ dialog: null;
637
+ responseMode: string;
638
+ serial: string;
639
+ scriptId: string;
640
+ scriptElement: ScriptElement;
641
+ whitelist: any[];
642
+ cookieList: CookieList;
643
+ pathlist: any[];
644
+ userIsInPath: boolean;
645
+ cookieEnabled: boolean;
646
+ versionChecked: boolean;
647
+ versionRequested: boolean;
648
+ version: number;
649
+ latestVersion: number;
650
+ isNewVersion: boolean;
651
+ CDN: string;
652
+ source: string;
653
+ retryCounter: number;
654
+ frameRetryCounter: number;
655
+ bulkConsentFrameRetryCounter: number;
656
+ setOnloadFrameRetryCounter: number;
657
+ optOutLifetime: number;
658
+ consentLifetime: null;
659
+ framework: string;
660
+ hasFramework: boolean;
661
+ frameworkBlocked: boolean;
662
+ frameworkLoaded: boolean;
663
+ iframeReady: boolean;
664
+ iframe: Iframe;
665
+ bulkconsent: null;
666
+ bulkresetdomains: any[];
667
+ bulkconsentsubmitted: boolean;
668
+ isbulkrenewal: boolean;
669
+ wipe: Wipe;
670
+ consentUTC: Date;
671
+ IABConsentString: string;
672
+ GACMConsentString: string;
673
+ dataLayerName: string;
674
+ loaded: boolean;
675
+ autoblock: boolean;
676
+ mutationObserver: null;
677
+ mutationCounter: number;
678
+ mutationFallback: boolean;
679
+ mutationFallbackDocAttributes: any[];
680
+ mutationHandlerFallbackCharsetLoaded: boolean;
681
+ mutationAppName: string;
682
+ mutationEventListeners: any[];
683
+ mutationOnloadEventListeners: any[];
684
+ mutateEventListeners: boolean;
685
+ mutationHandlerFirstScript: null;
686
+ postPonedMutations: any[];
687
+ nonAsyncMutations: any[];
688
+ deferMutations: any[];
689
+ geoRegions: any[];
690
+ userCountry: string;
691
+ userCulture: string;
692
+ windowOnloadTriggered: boolean;
693
+ botDetectionDisabled: boolean;
694
+ regulations: Regulations;
695
+ regulationRegions: RegulationRegions;
696
+ commonTrackers: CommonTrackers;
697
+ configuration: Configuration;
698
+ inlineConfiguration: null;
699
+ processLinkClickCounter: number;
700
+ performanceEntriesCounter: number;
701
+ OverrideEventListenersOnloadFired: any[];
702
+ OverrideEventListenersOnloadToFire: any[];
703
+ fallbackScriptNodes: any[];
704
+ fallbackDeferNodes: any[];
705
+ };
706
+ }
709
707
  }
710
708
  export interface CommonTrackers {
711
- domains: Domain[];
709
+ domains: Domain[];
712
710
  }
713
711
  export interface Domain {
714
- d: string;
715
- c: number[];
712
+ d: string;
713
+ c: number[];
716
714
  }
717
715
  export interface Configuration {
718
- loaded: boolean;
719
- loadRetry: number;
720
- tags: any[];
721
- trackingDomains: any[];
716
+ loaded: boolean;
717
+ loadRetry: number;
718
+ tags: any[];
719
+ trackingDomains: any[];
722
720
  }
723
721
  export interface Consent {
724
- stamp: string;
725
- necessary: boolean;
726
- preferences: boolean;
727
- statistics: boolean;
728
- marketing: boolean;
722
+ stamp: string;
723
+ necessary: boolean;
724
+ preferences: boolean;
725
+ statistics: boolean;
726
+ marketing: boolean;
729
727
  }
730
728
  export interface CookieList {
731
- cookieTablePreference: any[];
732
- cookieTableStatistics: any[];
733
- cookieTableAdvertising: any[];
734
- cookieTableUnclassified: any[];
729
+ cookieTablePreference: any[];
730
+ cookieTableStatistics: any[];
731
+ cookieTableAdvertising: any[];
732
+ cookieTableUnclassified: any[];
735
733
  }
736
734
  export interface Iframe {
737
- cookieconsentDataStyleDisplay: string;
738
- mtjQuery171028673205955022363: number;
735
+ cookieconsentDataStyleDisplay: string;
736
+ mtjQuery171028673205955022363: number;
739
737
  }
740
738
  export interface RegulationRegions {
741
- gdpr: string[];
742
- ccpa: string[];
743
- lgpd: string[];
739
+ gdpr: string[];
740
+ ccpa: string[];
741
+ lgpd: string[];
744
742
  }
745
743
  export interface Regulations {
746
- gdprApplies: boolean;
747
- ccpaApplies: boolean;
748
- lgpdApplies: boolean;
749
- }
750
- export interface ScriptElement {
744
+ gdprApplies: boolean;
745
+ ccpaApplies: boolean;
746
+ lgpdApplies: boolean;
751
747
  }
748
+ export interface ScriptElement {}
752
749
  export interface Wipe {
753
- preferences: boolean;
754
- statistics: boolean;
755
- marketing: boolean;
750
+ preferences: boolean;
751
+ statistics: boolean;
752
+ marketing: boolean;
756
753
  }
757
754
  /**
758
755
  * Returns current consent status synchronously, meaning the user might not have seen the dialog yet (in which case this will return false)
@@ -783,10 +780,10 @@ export const init_optanon_tracking: (anon_id?: any) => Promise<void | undefined>
783
780
  export const load_gtag: (GA_ID: string, strict?: boolean | undefined) => Promise<void | undefined>;
784
781
  export const setup_gtag: (GA_ID: string) => void | undefined;
785
782
  export const gtag_view: <T extends Display>(raw_displays: T[], get_product_id: (url?: string | T | undefined) => string | Promise<string>, more?: {
786
- [key: string]: any;
787
- list_name?: string | undefined;
783
+ [key: string]: any;
784
+ list_name?: string | undefined;
788
785
  } | ((display: T) => {
789
- [key: string]: any;
786
+ [key: string]: any;
790
787
  }) | undefined) => Promise<void | undefined>;
791
788
  export const gtag_click: (product_id: string | number, index: number, more?: object | undefined) => Promise<any>;
792
789
  export const send_ga: (action: string) => any;
@@ -806,9 +803,9 @@ export const track_a2c: (tenant: Tenant, selector: string, validator?: ((e: Even
806
803
  * Basically a RecRendererResult with less strict typing
807
804
  */
808
805
  export interface Surface<T extends Display> {
809
- elements?: Node_Array;
810
- displays?: T[];
811
- should_stay_inserted?: Promise<boolean>;
806
+ elements?: Node_Array;
807
+ displays?: T[];
808
+ should_stay_inserted?: Promise<boolean>;
812
809
  }
813
810
  /**
814
811
  * Functions existing on ChildNode that are commonly used to insert recommendations into the DOM
@@ -825,9 +822,9 @@ export type InsertionVerb = "after" | "before" | "replaceWith" | "append" | "pre
825
822
  */
826
823
  export const normal_get_product_id: (url?: string) => string;
827
824
  declare global {
828
- interface Document {
829
- depictwashere: boolean;
830
- }
825
+ interface Document {
826
+ depictwashere: boolean;
827
+ }
831
828
  }
832
829
  /**
833
830
  * If you need custom market logic that {@link depict_init_with_market_logic} doesn't support then use this function.
@@ -861,98 +858,98 @@ export const depict_init: (callback: () => Promise<void>) => void;
861
858
  export function depict_init_with_market_logic<T extends readonly string[]>(callback: (market: T[number]) => Promise<void>, get_market: () => Promise<string | undefined> | string | undefined, supported_markets: T, unsupported_markets: string[], preferred_demo_market?: string): void;
862
859
  type IdType = string | undefined | Promise<string | undefined>;
863
860
  export interface Tenant<ProductId extends IdType> {
864
- TENANT: string;
865
- tenant: string;
866
- MARKET: TwoLetterMarket;
867
- market: TwoLetterMarket;
868
- TYPE: string;
869
- type: string;
870
- GA_ID: string;
871
- gaid: string;
872
- get_product_id: (url?: string) => ProductId extends string | undefined ? string : Promise<string>;
873
- product_id: (url?: string) => string | Promise<string>;
874
- dataset: DOMStringMap;
875
- modify: boolean;
876
- is_debug: boolean;
877
- debug: boolean;
878
- dlog: typeof dlog;
879
- Sentry: typeof Sentry;
880
- catchify: typeof catchify;
881
- err: (...errors: any[]) => undefined;
861
+ TENANT: string;
862
+ tenant: string;
863
+ MARKET: TwoLetterMarket;
864
+ market: TwoLetterMarket;
865
+ TYPE: string;
866
+ type: string;
867
+ GA_ID: string;
868
+ gaid: string;
869
+ get_product_id: (url?: string) => ProductId extends string | undefined ? string : Promise<string>;
870
+ product_id: (url?: string) => string | Promise<string>;
871
+ dataset: DOMStringMap;
872
+ modify: boolean;
873
+ is_debug: boolean;
874
+ debug: boolean;
875
+ dlog: typeof dlog;
876
+ Sentry: typeof Sentry;
877
+ catchify: typeof catchify;
878
+ err: (...errors: any[]) => undefined;
882
879
  }
883
880
  /**
884
881
  * Tenant class. This describes which site/customer one is on, in which market, and some more information. It also sends the page_view event if not already done and highlights elements with a `.depict` class if `localStorage['highlight-depict']` is `"true"`
885
882
  * @param options A object with constructor options
886
883
  */
887
884
  export class Tenant<ProductId extends IdType = IdType> {
888
- constructor(options: {
889
- TENANT?: string;
890
- TYPE?: string;
891
- MARKET: TwoLetterMarket;
892
- GA_ID: string;
893
- get_product_id: (url?: string) => ProductId;
894
- current_script_override?: HTMLScriptElement;
895
- pageview_tracking?: boolean;
896
- });
885
+ constructor(options: {
886
+ TENANT?: string;
887
+ TYPE?: string;
888
+ MARKET: TwoLetterMarket;
889
+ GA_ID: string;
890
+ get_product_id: (url?: string) => ProductId;
891
+ current_script_override?: HTMLScriptElement;
892
+ pageview_tracking?: boolean;
893
+ });
897
894
  }
898
895
  /**
899
896
  * This is a list of alpha-2 country codes plus some two letter combinations commonly used to describe markets
900
897
  */
901
898
  export type TwoLetterMarket = "af" | "al" | "dz" | "as" | "ad" | "ao" | "ai" | "aq" | "ag" | "ar" | "am" | "aw" | "au" | "at" | "az" | "bs" | "bh" | "bd" | "bb" | "by" | "be" | "bz" | "bj" | "bm" | "bt" | "bo" | "bq" | "ba" | "bw" | "bv" | "br" | "io" | "bn" | "bg" | "bf" | "bi" | "cv" | "kh" | "cm" | "ca" | "ky" | "cf" | "td" | "cl" | "cn" | "cx" | "cc" | "co" | "km" | "cd" | "cg" | "ck" | "cr" | "hr" | "cu" | "cw" | "cy" | "cz" | "ci" | "dk" | "dj" | "dm" | "do" | "ec" | "eg" | "sv" | "gq" | "er" | "ee" | "sz" | "et" | "fk" | "fo" | "fj" | "fi" | "fr" | "gf" | "pf" | "tf" | "ga" | "gm" | "ge" | "de" | "gh" | "gi" | "gr" | "gl" | "gd" | "gp" | "gu" | "gt" | "gg" | "gn" | "gw" | "gy" | "ht" | "hm" | "va" | "hn" | "hk" | "hu" | "is" | "in" | "id" | "ir" | "iq" | "ie" | "im" | "il" | "it" | "jm" | "jp" | "je" | "jo" | "kz" | "ke" | "ki" | "kp" | "kr" | "kw" | "kg" | "la" | "lv" | "lb" | "ls" | "lr" | "ly" | "li" | "lt" | "lu" | "mo" | "mg" | "mw" | "my" | "mv" | "ml" | "mt" | "mh" | "mq" | "mr" | "mu" | "yt" | "mx" | "fm" | "md" | "mc" | "mn" | "me" | "ms" | "ma" | "mz" | "mm" | "na" | "nr" | "np" | "nl" | "nc" | "nz" | "ni" | "ne" | "ng" | "nu" | "nf" | "mp" | "no" | "om" | "pk" | "pw" | "ps" | "pa" | "pg" | "py" | "pe" | "ph" | "pn" | "pl" | "pt" | "pr" | "qa" | "mk" | "ro" | "ru" | "rw" | "re" | "bl" | "sh" | "kn" | "lc" | "mf" | "pm" | "vc" | "ws" | "sm" | "st" | "sa" | "sn" | "rs" | "sc" | "sl" | "sg" | "sx" | "sk" | "si" | "sb" | "so" | "za" | "gs" | "ss" | "es" | "lk" | "sd" | "sr" | "sj" | "se" | "ch" | "sy" | "tw" | "tj" | "tz" | "th" | "tl" | "tg" | "tk" | "to" | "tt" | "tn" | "tr" | "tm" | "tc" | "tv" | "ug" | "ua" | "ae" | "gb" | "um" | "us" | "uy" | "uz" | "vu" | "ve" | "vn" | "vg" | "vi" | "wf" | "eh" | "ye" | "zm" | "zw" | "ax" | "uk" | "en" | "da" | "eu" | "sv" | "oc" | "nb" | "sq";
902
899
  type ImpressionTrackOptions = {
903
- t?: Tenant;
904
- impression_tracking?: false;
900
+ t?: Tenant;
901
+ impression_tracking?: false;
905
902
  } | {
906
- impression_tracking: true;
907
- t: Tenant;
903
+ impression_tracking: true;
904
+ t: Tenant;
908
905
  };
909
906
  type TenantSpecificationOptions = {
910
- t?: Tenant;
911
- tenant: string;
912
- market: string;
913
- get_product_id: (url?: string) => string | Promise<string>;
907
+ t?: Tenant;
908
+ tenant: string;
909
+ market: string;
910
+ get_product_id: (url?: string) => string | Promise<string>;
914
911
  } | {
915
- t: Tenant;
916
- tenant?: string;
917
- market?: string;
918
- get_product_id?: (url?: string) => string | Promise<string>;
912
+ t: Tenant;
913
+ tenant?: string;
914
+ market?: string;
915
+ get_product_id?: (url?: string) => string | Promise<string>;
919
916
  };
920
917
  type ElementDiscoveryOptions = {
921
- product_selector: string;
922
- product_elements?: null | void | undefined;
918
+ product_selector: string;
919
+ product_elements?: null | void | undefined;
923
920
  } | {
924
- product_selector?: null | void | undefined;
925
- product_elements: HTMLElement[];
921
+ product_selector?: null | void | undefined;
922
+ product_elements: HTMLElement[];
926
923
  };
927
924
  type A2CButtonDiscoveryOptions = {
928
- a2c_selector: string;
929
- a2c_elements?: null | void | undefined;
925
+ a2c_selector: string;
926
+ a2c_elements?: null | void | undefined;
930
927
  } | {
931
- a2c_selector?: null | void | undefined;
932
- a2c_elements: HTMLElement[];
928
+ a2c_selector?: null | void | undefined;
929
+ a2c_elements: HTMLElement[];
933
930
  };
934
931
  /**
935
932
  * @deprecated Please use DPC instead.
936
933
  * Does not support ModernDisplays.
937
934
  */
938
935
  export const AIO: (options: {
939
- attempt_gtag_view_tracking?: boolean | undefined;
940
- no_gtag?: boolean | undefined;
941
- shade?: boolean | undefined;
942
- always_track_a2c?: boolean | undefined;
943
- get_rec_id?: ((elem: HTMLElement) => string | undefined) | undefined;
944
- get_prod_id?: ((elem: HTMLElement) => (string | undefined) | Promise<string | undefined>) | undefined;
945
- get_ga_prod_id?: ((elem: HTMLElement) => string | undefined | Promise<string | undefined>) | undefined;
946
- click_location_prefix?: ((elem: HTMLElement) => string | undefined) | undefined;
947
- rec_a2c_selector?: string | undefined;
948
- rec_a2c_unbubbled?: boolean | undefined;
949
- get_display?: ((elem: HTMLElement) => Partial<LegacyDisplay> | undefined) | undefined;
936
+ attempt_gtag_view_tracking?: boolean | undefined;
937
+ no_gtag?: boolean | undefined;
938
+ shade?: boolean | undefined;
939
+ always_track_a2c?: boolean | undefined;
940
+ get_rec_id?: ((elem: HTMLElement) => string | undefined) | undefined;
941
+ get_prod_id?: ((elem: HTMLElement) => (string | undefined) | Promise<string | undefined>) | undefined;
942
+ get_ga_prod_id?: ((elem: HTMLElement) => string | undefined | Promise<string | undefined>) | undefined;
943
+ click_location_prefix?: ((elem: HTMLElement) => string | undefined) | undefined;
944
+ rec_a2c_selector?: string | undefined;
945
+ rec_a2c_unbubbled?: boolean | undefined;
946
+ get_display?: ((elem: HTMLElement) => Partial<LegacyDisplay> | undefined) | undefined;
950
947
  } & ImpressionTrackOptions & TenantSpecificationOptions & ElementDiscoveryOptions & A2CButtonDiscoveryOptions, gtag_options?: {
951
- [key: string]: any;
952
- list_name?: string | undefined;
948
+ [key: string]: any;
949
+ list_name?: string | undefined;
953
950
  } | undefined) => Promise<{
954
- add_a2c_element: (element: HTMLElement) => void;
955
- add_product_element: (element: HTMLElement) => Promise<void | undefined>;
951
+ add_a2c_element: (element: HTMLElement) => void;
952
+ add_product_element: (element: HTMLElement) => Promise<void | undefined>;
956
953
  } | undefined>;
957
954
  export const paint_red: (element: HTMLElement) => void | undefined;
958
955
  /**
@@ -975,26 +972,26 @@ export const wait: (delay: number) => Promise<unknown>;
975
972
  export function fetch_retry(url: RequestInfo, options?: RequestInit, max_retries?: number): Promise<false | Response>;
976
973
  type PossibleEndpoint = "general" | "product" | "products" | "category";
977
974
  type ExclusiveId = {
978
- category_id: string;
979
- product_id?: undefined;
980
- product_ids?: undefined;
975
+ category_id: string;
976
+ product_id?: undefined;
977
+ product_ids?: undefined;
981
978
  } | {
982
- category_id?: undefined;
983
- product_id: string;
984
- product_ids?: undefined;
979
+ category_id?: undefined;
980
+ product_id: string;
981
+ product_ids?: undefined;
985
982
  } | {
986
- category_id?: undefined;
987
- product_id?: undefined;
988
- product_ids: string[];
983
+ category_id?: undefined;
984
+ product_id?: undefined;
985
+ product_ids: string[];
989
986
  } | {
990
- category_id?: undefined;
991
- product_id?: undefined;
992
- product_ids?: undefined;
987
+ category_id?: undefined;
988
+ product_id?: undefined;
989
+ product_ids?: undefined;
993
990
  };
994
991
  type FetchRecsOptions = {
995
- type: string;
996
- user_id?: string;
997
- session_id?: string;
992
+ type: string;
993
+ user_id?: string;
994
+ session_id?: string;
998
995
  } & ExclusiveId;
999
996
  /**
1000
997
  * Fetches recommendations from the depict v2 recommendation api.
@@ -1005,14 +1002,14 @@ type FetchRecsOptions = {
1005
1002
  * Formerly called get_displays
1006
1003
  */
1007
1004
  export function fetch_recs<T extends Display = Display>(t: Tenant | {
1008
- market: string;
1009
- tenant: string;
1005
+ market: string;
1006
+ tenant: string;
1010
1007
  }, options: FetchRecsOptions, headers?: HeadersInit, get_url?: typeof default_get_fetch_url): Promise<T[]>;
1011
1008
  export function fetch_recs_whole_response<R extends {
1012
- displays: any[];
1009
+ displays: any[];
1013
1010
  }>(t: Tenant | {
1014
- market: string;
1015
- tenant: string;
1011
+ market: string;
1012
+ tenant: string;
1016
1013
  }, options: FetchRecsOptions, headers?: HeadersInit, get_url?: typeof default_get_fetch_url): Promise<R>;
1017
1014
  declare function default_get_fetch_url(type: PossibleEndpoint): string;
1018
1015
  export function ensure_parameter_in_url(url: any, param: any, value: any): string;
@@ -1027,123 +1024,115 @@ export function intl_number_format_with_fallback(bcp47_country_code: string, num
1027
1024
  export function ensure_object_path(obj: object, step1: string, ...path: string[]): any;
1028
1025
  export function Rec_Renderer<T extends Display>(t: Tenant | null, rendering_options: RR_Options<T>): Promise<RecRendererResult<T>>;
1029
1026
  export function regex_templating(template: string, display?: Display | {
1030
- [key: string]: any;
1027
+ [key: string]: any;
1031
1028
  }): string;
1032
1029
  export function clone_deep<T>(obj: T): T;
1033
1030
  export class InfoForProcessing<T extends Display> {
1034
- constructor(t: Tenant | null, rendering_options: RR_Options<T>, displays: T[], index?: number, remove_display?: () => void, event_listeners?: [
1035
- type: keyof HTMLElementEventMap,
1036
- listener: (this: HTMLElement, ev: HTMLElementEventMap[keyof HTMLElementEventMap]) => any,
1037
- options?: boolean | AddEventListenerOptions
1038
- ][]);
1031
+ constructor(t: Tenant | null, rendering_options: RR_Options<T>, displays: T[], index?: number, remove_display?: () => void, event_listeners?: [type: keyof HTMLElementEventMap, listener: (this: HTMLElement, ev: HTMLElementEventMap[keyof HTMLElementEventMap]) => any, options?: boolean | AddEventListenerOptions][]);
1039
1032
  }
1040
1033
  type RegisterEventListener = (type: keyof HTMLElementEventMap, listener: (this: HTMLElement, ev: HTMLElementEventMap[keyof HTMLElementEventMap]) => any, options?: boolean | AddEventListenerOptions) => void;
1041
1034
  export interface InfoForProcessing<T extends Display> {
1042
- t: Tenant;
1043
- rendering_options: RR_Options<T>;
1044
- displays: T[];
1045
- index: number;
1046
- remove_display?: () => void;
1047
- register_event_listener: RegisterEventListener;
1048
- event_listeners?: [
1049
- type: keyof HTMLElementEventMap,
1050
- listener: (this: HTMLElement, ev: HTMLElementEventMap[keyof HTMLElementEventMap]) => any,
1051
- options?: boolean | AddEventListenerOptions
1052
- ][];
1053
- extras?: {
1054
- [key: string]: any;
1055
- };
1035
+ t: Tenant;
1036
+ rendering_options: RR_Options<T>;
1037
+ displays: T[];
1038
+ index: number;
1039
+ remove_display?: () => void;
1040
+ register_event_listener: RegisterEventListener;
1041
+ event_listeners?: [type: keyof HTMLElementEventMap, listener: (this: HTMLElement, ev: HTMLElementEventMap[keyof HTMLElementEventMap]) => any, options?: boolean | AddEventListenerOptions][];
1042
+ extras?: {
1043
+ [key: string]: any;
1044
+ };
1056
1045
  }
1057
1046
  export type RR_PreProcessor<T extends Display> = (display: T, info: InfoForProcessing<T>) => Promise<T> | T;
1058
1047
  export type RR_PostProcessor<T extends Display> = (elements: NodeListOf<ChildNode> | Node_Array, display: T, info: InfoForProcessing<T>) => Promise<NodeListOf<ChildNode> | Node_Array> | NodeListOf<ChildNode> | Node_Array;
1059
1048
  export type RR_Options<T extends Display> = {
1060
- template: string | ((arg0: T, info: InfoForProcessing<T>) => Promise<string | Node_Array> | string | Node_Array);
1061
- recs?: T[] | undefined | Promise<T[] | undefined>;
1062
- type: string;
1063
- min_items_to_report?: number;
1064
- min_items_to_run?: number;
1065
- max_items?: number;
1066
- extra_api_options?: {
1067
- [key: string]: any;
1068
- };
1069
- pre_processors?: RR_PreProcessor<T>[];
1070
- post_processors?: RR_PostProcessor<T>[];
1071
- headers?: HeadersInit;
1049
+ template: string | ((arg0: T, info: InfoForProcessing<T>) => Promise<string | Node_Array> | string | Node_Array);
1050
+ recs?: T[] | undefined | Promise<T[] | undefined>;
1051
+ type: string;
1052
+ min_items_to_report?: number;
1053
+ min_items_to_run?: number;
1054
+ max_items?: number;
1055
+ extra_api_options?: {
1056
+ [key: string]: any;
1057
+ };
1058
+ pre_processors?: RR_PreProcessor<T>[];
1059
+ post_processors?: RR_PostProcessor<T>[];
1060
+ headers?: HeadersInit;
1072
1061
  } & FetchRecsOptions;
1073
1062
  /**
1074
1063
  * Product properties that are used to render the product cards. Used until early 2023
1075
1064
  */
1076
1065
  export interface LegacyDisplay {
1077
- /**
1078
- * The URL of the product page.
1079
- */
1080
- page_url: any;
1081
- /**
1082
- * The URL of the product image.
1083
- */
1084
- image_url: string;
1085
- /** The price of the product. */
1086
- sale_price: number;
1087
- /** The original price of the product. */
1088
- original_price: number;
1089
- /** The product ID of the product. */
1090
- product_id: string;
1091
- /** The Google Analytics product ID */
1092
- ga_product_id?: string;
1093
- /** The Google Analytics product IDs */
1094
- ga_product_ids?: string[];
1095
- /** The variation IDs */
1096
- variant_ids?: string[];
1097
- /** The title */
1098
- title: string;
1099
- /** Unique recommendation result ID used by Depict */
1100
- recommendation_id?: string;
1101
- /** Unique search result ID used by Depict */
1102
- search_result_id?: string;
1103
- /** Unique product listing result ID used by Depict */
1104
- product_listing_result_id?: string;
1105
- [key: string]: any;
1066
+ /**
1067
+ * The URL of the product page.
1068
+ */
1069
+ page_url: any;
1070
+ /**
1071
+ * The URL of the product image.
1072
+ */
1073
+ image_url: string;
1074
+ /** The price of the product. */
1075
+ sale_price: number;
1076
+ /** The original price of the product. */
1077
+ original_price: number;
1078
+ /** The product ID of the product. */
1079
+ product_id: string;
1080
+ /** The Google Analytics product ID */
1081
+ ga_product_id?: string;
1082
+ /** The Google Analytics product IDs */
1083
+ ga_product_ids?: string[];
1084
+ /** The variation IDs */
1085
+ variant_ids?: string[];
1086
+ /** The title */
1087
+ title: string;
1088
+ /** Unique recommendation result ID used by Depict */
1089
+ recommendation_id?: string;
1090
+ /** Unique search result ID used by Depict */
1091
+ search_result_id?: string;
1092
+ /** Unique product listing result ID used by Depict */
1093
+ product_listing_result_id?: string;
1094
+ [key: string]: any;
1106
1095
  }
1107
1096
  interface ModernDisplay {
1108
- /**
1109
- * The index of the variant to be displayed.
1110
- */
1111
- variant_index: number;
1112
- /**
1113
- * All variant displays (eg. different colors, sizes) of the product.
1114
- */
1115
- variant_displays: any[];
1116
- /** SKUs of the different variants */
1117
- variant_skus: string[];
1118
- /** Product of the different variants */
1119
- variant_product_ids: string[];
1120
- /** Unique recommendation result ID used by Depict */
1121
- recommendation_id?: string;
1122
- /** Unique search result ID used by Depict */
1123
- search_result_id?: string;
1124
- /** Unique product listing result ID used by Depict */
1125
- product_listing_result_id?: string;
1126
- /** Recommendation type logic used by Depict */
1127
- logic?: string;
1097
+ /**
1098
+ * The index of the variant to be displayed.
1099
+ */
1100
+ variant_index: number;
1101
+ /**
1102
+ * All variant displays (eg. different colors, sizes) of the product.
1103
+ */
1104
+ variant_displays: any[];
1105
+ /** SKUs of the different variants */
1106
+ variant_skus: string[];
1107
+ /** Product of the different variants */
1108
+ variant_product_ids: string[];
1109
+ /** Unique recommendation result ID used by Depict */
1110
+ recommendation_id?: string;
1111
+ /** Unique search result ID used by Depict */
1112
+ search_result_id?: string;
1113
+ /** Unique product listing result ID used by Depict */
1114
+ product_listing_result_id?: string;
1115
+ /** Recommendation type logic used by Depict */
1116
+ logic?: string;
1128
1117
  }
1129
1118
  interface BasicDisplay {
1130
- product_id: string;
1131
- /** Unique recommendation result ID used by Depict */
1132
- recommendation_id?: string;
1133
- /** Unique search result ID used by Depict */
1134
- search_result_id?: string;
1135
- /** Unique product listing result ID used by Depict */
1136
- product_listing_result_id?: string;
1137
- /** Recommendation type logic used by Depict */
1138
- logic?: string;
1139
- [key: string]: any;
1119
+ product_id: string;
1120
+ /** Unique recommendation result ID used by Depict */
1121
+ recommendation_id?: string;
1122
+ /** Unique search result ID used by Depict */
1123
+ search_result_id?: string;
1124
+ /** Unique product listing result ID used by Depict */
1125
+ product_listing_result_id?: string;
1126
+ /** Recommendation type logic used by Depict */
1127
+ logic?: string;
1128
+ [key: string]: any;
1140
1129
  }
1141
1130
  export type Display = LegacyDisplay | ModernDisplay | BasicDisplay;
1142
1131
  export type Node_Iterable = HTMLCollection | NodeListOf<ChildNode> | Node_Array;
1143
1132
  export type Node_Array = (Element | Text | Comment)[];
1144
1133
  export type RecRendererResult<T extends Display> = Record<string, never> | {
1145
- elements: Node_Array;
1146
- displays: T[];
1134
+ elements: Node_Array;
1135
+ displays: T[];
1147
1136
  };
1148
1137
  /**
1149
1138
  * Queues a task in the event queue without a timeout like setTimeout does, see https://www.youtube.com/watch?v=cCOL7MC4Pl0
@@ -1151,9 +1140,9 @@ export type RecRendererResult<T extends Display> = Record<string, never> | {
1151
1140
  */
1152
1141
  export function queueMacroTask(callback: VoidFunction): void;
1153
1142
  interface SDKRenderingInfo {
1154
- set_on_index_change: (fn: (index: number) => void) => void;
1155
- merchant: string;
1156
- market: string;
1143
+ set_on_index_change: (fn: (index: number) => void) => void;
1144
+ merchant: string;
1145
+ market: string;
1157
1146
  }
1158
1147
  /**
1159
1148
  * Creates a handler for sending the "recommendations_inserted" event on new results.
@@ -1165,16 +1154,16 @@ export function make_plp_recommendations_inserted_handler(tenant: string, market
1165
1154
  */
1166
1155
  export function cache_args(fn: any, ...args: any[]): (...unimportant_args: any[]) => any;
1167
1156
  export const check_displays: (args_0: {
1168
- recs: Display[] | {
1169
- displays: Display[];
1170
- } | Promise<Display[] | {
1171
- displays: Display[];
1172
- }>;
1173
- min_recs?: number | undefined;
1174
- market: string;
1175
- type: string;
1176
- product_id: string | string[] | Promise<string> | Promise<string[]> | ((arg0?: string) => string | string[] | Promise<string> | Promise<string[]>) | undefined;
1177
- tenant: string;
1157
+ recs: Display[] | {
1158
+ displays: Display[];
1159
+ } | Promise<Display[] | {
1160
+ displays: Display[];
1161
+ }>;
1162
+ min_recs?: number | undefined;
1163
+ market: string;
1164
+ type: string;
1165
+ product_id: string | string[] | Promise<string> | Promise<string[]> | ((arg0?: string) => string | string[] | Promise<string> | Promise<string[]>) | undefined;
1166
+ tenant: string;
1178
1167
  }) => Promise<boolean | undefined>;
1179
1168
  /**
1180
1169
  * @deprecated You should no longer need to use this. Use observer.onexists to add an event listener to an element once it exists.
@@ -1192,45 +1181,45 @@ export function ga_click<T extends Display>(elements: NodeListOf<ChildNode> | No
1192
1181
  export const should_colorizeLogics: boolean;
1193
1182
  export function colorize_elements(elements: NodeListOf<ChildNode> | Node_Array, display: Display): NodeListOf<ChildNode> | Node_Array;
1194
1183
  type Extended_RR_Options<T extends Display> = {
1195
- view_tracking?: RR_PostProcessor<T>[];
1196
- click_tracking?: RR_PostProcessor<T>[];
1184
+ view_tracking?: RR_PostProcessor<T>[];
1185
+ click_tracking?: RR_PostProcessor<T>[];
1197
1186
  } & RR_Options<T>;
1198
1187
  export function default_rr<T extends Display>(t: Tenant | null, rendering_options: Extended_RR_Options<T>): Promise<RecRendererResult<T>>;
1199
1188
  type GWVM_Options = {
1200
- container_selector?: string;
1201
- start_rows?: number;
1202
- rows_per_click?: number;
1203
- recs_per_row?: number | ((showing: number) => number);
1204
- button?: string | HTMLElement;
1205
- override_rec_renderer?: typeof Rec_Renderer;
1206
- title_selector?: string;
1207
- title?: string | HTMLElement;
1208
- container_template: string | Node_Array;
1209
- only_full_rows?: boolean;
1210
- should_preload?: boolean;
1189
+ container_selector?: string;
1190
+ start_rows?: number;
1191
+ rows_per_click?: number;
1192
+ recs_per_row?: number | ((showing: number) => number);
1193
+ button?: string | HTMLElement;
1194
+ override_rec_renderer?: typeof Rec_Renderer;
1195
+ title_selector?: string;
1196
+ title?: string | HTMLElement;
1197
+ container_template: string | Node_Array;
1198
+ only_full_rows?: boolean;
1199
+ should_preload?: boolean;
1211
1200
  };
1212
1201
  interface GWVM_InfoForProcessing<T extends Display> extends InfoForProcessing<T> {
1213
- extras: {
1214
- [key: string]: any;
1215
- load_more_currently_showing: number;
1216
- load_more: (num?: number | Event) => void;
1217
- load_more_ipo: {
1218
- promise: Promise<number>;
1219
- resolve: (argument?: number) => void;
1220
- };
1202
+ extras: {
1203
+ [key: string]: any;
1204
+ load_more_currently_showing: number;
1205
+ load_more: (num?: number | Event) => void;
1206
+ load_more_ipo: {
1207
+ promise: Promise<number>;
1208
+ resolve: (argument?: number) => void;
1221
1209
  };
1210
+ };
1222
1211
  }
1223
1212
  type GWVM_RR_Post_Pro = (elements: NodeListOf<ChildNode> | Node_Array, display: Display, info: GWVM_InfoForProcessing) => Promise<NodeListOf<ChildNode> | Node_Array> | NodeListOf<ChildNode> | Node_Array;
1224
1213
  type GWVM_RR_Options = Extended_RR_Options & {
1225
- post_processors?: GWVM_RR_Post_Pro[];
1214
+ post_processors?: GWVM_RR_Post_Pro[];
1226
1215
  };
1227
1216
  /**
1228
1217
  * @deprecated please use RecommendationGrid instead
1229
1218
  */
1230
1219
  export function GWVM_Renderer(t: Tenant, options: GWVM_RR_Options, GWVM_opts: GWVM_Options): Promise<{
1231
- elements?: ChildNode[] | undefined;
1232
- load_more?: ((num?: number | Event) => void) | undefined;
1233
- displays?: Display[] | undefined;
1220
+ elements?: ChildNode[] | undefined;
1221
+ load_more?: ((num?: number | Event) => void) | undefined;
1222
+ displays?: Display[] | undefined;
1234
1223
  }>;
1235
1224
  /**
1236
1225
  * Used auto generate recommendations with view more button.
@@ -1242,105 +1231,40 @@ export function GWVM_Renderer(t: Tenant, options: GWVM_RR_Options, GWVM_opts: GW
1242
1231
  * for which the first options object was used) for the width calculation. Default: ".rec_outer".
1243
1232
  * @deprecated please use RecommendationGrid instead
1244
1233
  */
1245
- export function Auto_GWVM(t: Tenant, options: GWVM_RR_Options, GWVM_opts: Omit<GWVM_Options, "recs_per_row">, { rec_selector }?: {
1246
- rec_selector?: string;
1234
+ export function Auto_GWVM(t: Tenant, options: GWVM_RR_Options, GWVM_opts: Omit<GWVM_Options, "recs_per_row">, {
1235
+ rec_selector
1236
+ }?: {
1237
+ rec_selector?: string;
1247
1238
  }): Promise<{
1248
- elements?: Node_Array | undefined;
1249
- load_more?: ((num?: number | Event) => void) | undefined;
1250
- displays?: Display[] | undefined;
1239
+ elements?: Node_Array | undefined;
1240
+ load_more?: ((num?: number | Event) => void) | undefined;
1241
+ displays?: Display[] | undefined;
1251
1242
  }>;
1252
1243
  /**
1253
1244
  * @deprecated use async_iterable_ipns instead. This can skip values which yields unexpected results.
1254
1245
  */
1255
1246
  export function infinite_promise_creator(): {
1256
- promise: Promise<unknown>;
1257
- internal_resolve: ((value: any) => void) | undefined;
1258
- resolve: (argument?: any) => void;
1247
+ promise: Promise<unknown>;
1248
+ internal_resolve: ((value: any) => void) | undefined;
1249
+ resolve: (argument?: any) => void;
1259
1250
  };
1260
- interface trimmed_GWVM_opts extends Omit<GWVM_Options, "start_rows" | "rows_per_click" | "recs_per_row"> {
1261
- }
1251
+ interface trimmed_GWVM_opts extends Omit<GWVM_Options, "start_rows" | "rows_per_click" | "recs_per_row"> {}
1262
1252
  /**
1263
1253
  * @deprecated please rewrite this, basing on RecommendationGrid and its `rows.ipns` option, next time you need infinite scroll
1264
1254
  */
1265
- export function infinite_renderer(t: Tenant, options: GWVM_RR_Options, GWVM_opts: trimmed_GWVM_opts, { rec_selector }?: {
1266
- rec_selector?: string;
1255
+ export function infinite_renderer(t: Tenant, options: GWVM_RR_Options, GWVM_opts: trimmed_GWVM_opts, {
1256
+ rec_selector
1257
+ }?: {
1258
+ rec_selector?: string;
1267
1259
  }): Promise<{
1268
- elements?: Node_Array | undefined;
1269
- load_more?: ((num?: number | Event | undefined) => void) | undefined;
1270
- displays?: Display[] | undefined;
1260
+ elements?: Node_Array | undefined;
1261
+ load_more?: ((num?: number | Event | undefined) => void) | undefined;
1262
+ displays?: Display[] | undefined;
1271
1263
  }>;
1272
1264
  /**
1273
1265
  * @deprecated Emil's utility in integration.ts is better because it doesn't cause multiply <style> tags and doesn't require a tenant class
1274
1266
  */
1275
1267
  export function deprecated_insert_styling(t: Tenant, css: string, extra_html?: string): Promise<void>;
1276
- export type ArrayElement<ArrayType extends readonly unknown[]> = ArrayType extends readonly (infer ElementType)[] ? ElementType : never;
1277
- /**
1278
- * @deprecated please use TwoLetterMarket / readonly arrays/objects instead
1279
- */
1280
- enum Market {
1281
- dk = "dk",
1282
- uk = "uk",
1283
- com = "com",
1284
- fi = "fi",
1285
- no = "no",
1286
- de = "de",
1287
- nl = "nl",
1288
- fr = "fr",
1289
- se = "se",
1290
- ch = "ch",
1291
- za = "za",
1292
- us = "us",
1293
- ee = "ee",
1294
- default = "default"
1295
- }
1296
- /**
1297
- * @deprecated please use TwoLetterMarket / readonly arrays/objects instead
1298
- */
1299
- enum Locale {
1300
- sv_SE = "sv-SE",
1301
- no_NO = "no-NO",
1302
- fi_FI = "fi-FI",
1303
- da_DK = "da-DK",
1304
- en_UK = "en-UK",
1305
- de_DE = "de-DE",
1306
- nl_NL = "nl-NL",
1307
- fr_FR = "fr-FR",
1308
- de_CH = "de-CH"
1309
- }
1310
- type CurrencyInfo = {
1311
- name: string;
1312
- pre: string;
1313
- post: string;
1314
- };
1315
- /**
1316
- * @deprecated please use TwoLetterMarket / readonly arrays/objects instead
1317
- */
1318
- type MarketDetails = {
1319
- currency: CurrencyInfo;
1320
- locale_bcp47: Locale;
1321
- };
1322
- /**
1323
- * @deprecated please use TwoLetterMarket / readonly arrays/objects instead
1324
- */
1325
- type MarketConfig = MarketDetails & {
1326
- analytics_id: string;
1327
- };
1328
- /**
1329
- * @deprecated please use TwoLetterMarket / readonly arrays/objects instead
1330
- */
1331
- export const MARKET_MAP: Record<Market, MarketDetails>;
1332
- /**
1333
- * @deprecated please use TwoLetterMarket / readonly arrays/objects instead
1334
- */
1335
- export function get_market_locale(market: Market): Locale;
1336
- /**
1337
- * @deprecated please use TwoLetterMarket / readonly arrays/objects instead
1338
- */
1339
- export function get_market_currency(market: Market): CurrencyInfo;
1340
- /**
1341
- * @deprecated please use TwoLetterMarket / readonly arrays/objects instead
1342
- */
1343
- export type TenantMarketConfig<M extends Market> = Record<M, MarketConfig>;
1344
1268
  /**
1345
1269
  * @deprecated This is a predecessor to reactive_template which is much more limited (can only have two states) plus it's much more cumbersome to use, which is why I'm deprecating it.
1346
1270
  */
@@ -1349,120 +1273,139 @@ type accepted_element_types = Node_Array[0] | Node_Array;
1349
1273
  type accepted_input_that_resolves_to_elements = accepted_element_types | Promise<accepted_element_types> | (() => accepted_element_types) | (() => Promise<accepted_element_types>);
1350
1274
  declare function placeholder_worker(placeholder_elements: accepted_input_that_resolves_to_elements, final_elements: accepted_input_that_resolves_to_elements, switching_trigger?: infinite_promise_no_skip<boolean> | Promise<boolean>): Promise<void>;
1351
1275
  declare global {
1352
- interface HTMLImageElementWithLoaded extends HTMLImageElement {
1353
- loaded?: boolean;
1354
- }
1355
- interface HTMLSourceElementWithLoaded extends HTMLSourceElement {
1356
- loaded?: boolean;
1357
- }
1276
+ interface HTMLImageElementWithLoaded extends HTMLImageElement {
1277
+ loaded?: boolean;
1278
+ }
1279
+ interface HTMLSourceElementWithLoaded extends HTMLSourceElement {
1280
+ loaded?: boolean;
1281
+ }
1358
1282
  }
1359
1283
  export interface Lazyfier {
1360
- t: Tenant;
1361
- container: HTMLElement;
1362
- selector: string;
1363
- lazyfinder: lazyfinder;
1364
- only_load_intersecting: boolean;
1365
- ignore_data_urls?: boolean;
1284
+ t: Tenant;
1285
+ container: HTMLElement;
1286
+ selector: string;
1287
+ lazyfinder: lazyfinder;
1288
+ only_load_intersecting: boolean;
1289
+ ignore_data_urls?: boolean;
1366
1290
  }
1367
1291
  interface Lazyfier_Options {
1368
- container?: HTMLElement;
1369
- lazyfinder?: lazyfinder;
1370
- selector?: string;
1371
- wait_for_dominsertion?: boolean | Promise<any>;
1372
- only_load_intersecting?: boolean;
1373
- verbose?: boolean;
1374
- ignore_data_urls?: boolean;
1292
+ container?: HTMLElement;
1293
+ lazyfinder?: lazyfinder;
1294
+ selector?: string;
1295
+ wait_for_dominsertion?: boolean | Promise<any>;
1296
+ only_load_intersecting?: boolean;
1297
+ verbose?: boolean;
1298
+ ignore_data_urls?: boolean;
1375
1299
  }
1376
1300
  export class Lazyfier {
1377
- #private;
1378
- intersection_observer: IntersectionObserver;
1379
- start_observing_for_new_children_(override_container?: HTMLElement): void;
1380
- constructor({ container, lazyfinder, selector, wait_for_dominsertion, only_load_intersecting, ignore_data_urls, verbose, }: Lazyfier_Options);
1301
+ #private;
1302
+ intersection_observer: IntersectionObserver;
1303
+ start_observing_for_new_children_(override_container?: HTMLElement): void;
1304
+ constructor({
1305
+ container,
1306
+ lazyfinder,
1307
+ selector,
1308
+ wait_for_dominsertion,
1309
+ only_load_intersecting,
1310
+ ignore_data_urls,
1311
+ verbose
1312
+ }: Lazyfier_Options);
1381
1313
  }
1382
1314
  interface lazyfinder {
1383
- elements?: HTMLImageElementWithLoaded[];
1384
- unload?: (element: HTMLImageElementWithLoaded) => void | Promise<void>;
1385
- load?: (element: HTMLImageElementWithLoaded) => void | Promise<void>;
1315
+ elements?: HTMLImageElementWithLoaded[];
1316
+ unload?: (element: HTMLImageElementWithLoaded) => void | Promise<void>;
1317
+ load?: (element: HTMLImageElementWithLoaded) => void | Promise<void>;
1386
1318
  }
1387
1319
  export function test_array_proxy_support(): boolean;
1388
1320
  export interface Slider_Options {
1389
- /**
1390
- * Controls within what distance to hide the left slider button.
1391
- * The distance is in pixels to the leftmost part of the slider container from the first element in the slider
1392
- *
1393
- * Defaults to `10`
1394
- */
1395
- dist_to_hide_left?: number;
1396
- /**
1397
- * Controls within what distance to hide the right slider button.
1398
- * The distance is in pixels to the rightmost part of the slider container from the last element in the slider
1399
- *
1400
- * Defaults to `10`
1401
- */
1402
- dist_to_hide_right?: number;
1403
- stepstoslide?: number;
1404
- center_target?: boolean;
1405
- constructor_plugins?: ((arg0: Slider_Options) => any)[];
1406
- mutation_plugins?: ((mutations: IntersectionObserverEntry[], intersecting_items: Record<number, IntersectionObserverEntry>) => any)[];
1407
- correct_bs_targets?: boolean;
1408
- button_contents?: {
1409
- right: Node_Iterable;
1410
- left: Node_Iterable;
1411
- };
1412
- button_elems?: {
1413
- right: HTMLElement;
1414
- left: HTMLElement;
1415
- };
1416
- autoinvalidate_cache?: boolean;
1321
+ /**
1322
+ * Controls within what distance to hide the left slider button.
1323
+ * The distance is in pixels to the leftmost part of the slider container from the first element in the slider
1324
+ *
1325
+ * Defaults to `10`
1326
+ */
1327
+ dist_to_hide_left?: number;
1328
+ /**
1329
+ * Controls within what distance to hide the right slider button.
1330
+ * The distance is in pixels to the rightmost part of the slider container from the last element in the slider
1331
+ *
1332
+ * Defaults to `10`
1333
+ */
1334
+ dist_to_hide_right?: number;
1335
+ stepstoslide?: number;
1336
+ center_target?: boolean;
1337
+ constructor_plugins?: ((arg0: Slider_Options) => any)[];
1338
+ mutation_plugins?: ((mutations: IntersectionObserverEntry[], intersecting_items: Record<number, IntersectionObserverEntry>) => any)[];
1339
+ correct_bs_targets?: boolean;
1340
+ button_contents?: {
1341
+ right: Node_Iterable;
1342
+ left: Node_Iterable;
1343
+ };
1344
+ button_elems?: {
1345
+ right: HTMLElement;
1346
+ left: HTMLElement;
1347
+ };
1348
+ autoinvalidate_cache?: boolean;
1417
1349
  }
1418
1350
  export class Amazing_Slider {
1419
- #private;
1420
- container: HTMLElement;
1421
- insert_here: HTMLElement;
1422
- intersecting_items_object: {
1423
- [key: string]: IntersectionObserverEntry;
1424
- [key: number]: IntersectionObserverEntry;
1425
- };
1426
- stepstoslide: number;
1427
- dist_to_hide_left: number;
1428
- dist_to_hide_right: number;
1429
- center_target: boolean;
1430
- correct_bs_targets: boolean;
1431
- snap_style?: HTMLStyleElement;
1432
- on_elements_changed: ((records: MutationRecord[]) => any)[];
1433
- observer: IntersectionObserver;
1434
- observe: any;
1435
- get_index_of_element(target: Element | HTMLElement): number | undefined;
1436
- first_intersecting_index(min_ratio?: number): number;
1437
- get first_intersecting(): IntersectionObserverEntry;
1438
- get index_of_last_element(): number;
1439
- get currently_selected(): number | undefined;
1440
- get visible_sizes(): Map<Element, {
1441
- total_visible: number;
1442
- ratio_visible: number;
1443
- margin_left: number;
1444
- margin_right: number;
1445
- rect: DOMRect;
1446
- }>;
1447
- get cards_fitting_in_viewport(): number;
1448
- element_by_index(index: number): Element;
1449
- invalidate_cache(): void;
1450
- scroll_to_rel(offset: number, harsh?: boolean): void;
1451
- scroll_to_abs(offset: number, harsh?: boolean): void;
1452
- constructor({ dist_to_hide_left, dist_to_hide_right, stepstoslide, center_target, mutation_plugins, constructor_plugins, correct_bs_targets, button_contents, button_elems, autoinvalidate_cache, }: Slider_Options);
1351
+ #private;
1352
+ container: HTMLElement;
1353
+ insert_here: HTMLElement;
1354
+ intersecting_items_object: {
1355
+ [key: string]: IntersectionObserverEntry;
1356
+ [key: number]: IntersectionObserverEntry;
1357
+ };
1358
+ stepstoslide: number;
1359
+ dist_to_hide_left: number;
1360
+ dist_to_hide_right: number;
1361
+ center_target: boolean;
1362
+ correct_bs_targets: boolean;
1363
+ snap_style?: HTMLStyleElement;
1364
+ on_elements_changed: ((records: MutationRecord[]) => any)[];
1365
+ observer: IntersectionObserver;
1366
+ observe: any;
1367
+ get_index_of_element(target: Element | HTMLElement): number | undefined;
1368
+ first_intersecting_index(min_ratio?: number): number;
1369
+ get first_intersecting(): IntersectionObserverEntry;
1370
+ get index_of_last_element(): number;
1371
+ get currently_selected(): number | undefined;
1372
+ get visible_sizes(): Map<Element, {
1373
+ total_visible: number;
1374
+ ratio_visible: number;
1375
+ margin_left: number;
1376
+ margin_right: number;
1377
+ rect: DOMRect;
1378
+ }>;
1379
+ get cards_fitting_in_viewport(): number;
1380
+ element_by_index(index: number): Element;
1381
+ invalidate_cache(): void;
1382
+ scroll_to_rel(offset: number, harsh?: boolean): void;
1383
+ scroll_to_abs(offset: number, harsh?: boolean): void;
1384
+ constructor({
1385
+ dist_to_hide_left,
1386
+ dist_to_hide_right,
1387
+ stepstoslide,
1388
+ center_target,
1389
+ mutation_plugins,
1390
+ constructor_plugins,
1391
+ correct_bs_targets,
1392
+ button_contents,
1393
+ button_elems,
1394
+ autoinvalidate_cache
1395
+ }: Slider_Options);
1453
1396
  }
1454
1397
  export interface Amazing_Lazy_Slider {
1455
- lazyfier: Lazyfier;
1398
+ lazyfier: Lazyfier;
1456
1399
  }
1457
1400
  export class Amazing_Lazy_Slider extends Amazing_Slider {
1458
- constructor(options: Slider_Options, lazyfier_options?: Optional<ConstructorParameters<typeof Lazyfier>[0], "container">);
1401
+ constructor(options: Slider_Options, lazyfier_options?: Optional<ConstructorParameters<typeof Lazyfier>[0], "container">);
1459
1402
  }
1460
1403
  interface Pro_Slider_Options {
1461
- container?: string | Node_Iterable;
1462
- root_selector?: string;
1463
- override_rec_renderer?: typeof Rec_Renderer;
1464
- insertion_verb?: "append" | "prepend" | "before" | "after" | "replaceWith";
1465
- lazyfier_options?: ConstructorParameters<typeof Amazing_Lazy_Slider>[1];
1404
+ container?: string | Node_Iterable;
1405
+ root_selector?: string;
1406
+ override_rec_renderer?: typeof Rec_Renderer;
1407
+ insertion_verb?: "append" | "prepend" | "before" | "after" | "replaceWith";
1408
+ lazyfier_options?: ConstructorParameters<typeof Amazing_Lazy_Slider>[1];
1466
1409
  }
1467
1410
  /**
1468
1411
  * @deprecated please use RecommendationSlider instead
@@ -1472,76 +1415,81 @@ export function Pro_Slider<T extends Display>(t: Tenant, rendering_options: Exte
1472
1415
  * @deprecated Please use recommendation renderer instead
1473
1416
  */
1474
1417
  export class Depict {
1475
- #private;
1476
- settings: any;
1477
- data: any;
1478
- tracker: void;
1479
- constructor(settings: any);
1480
- init(callback: Function, existingDisplays?: object[]): void;
1481
- loadRecommendations(callback: any): void;
1482
- trackGAEvent(action: any, index: any, product_id: any, ga_product_ids?: string[]): void;
1483
- trackPageView(): void;
1484
- trackClick(index: any): boolean | Promise<void | undefined> | undefined;
1485
- trackAddToCart(pId: any): boolean | Promise<void | undefined> | undefined;
1486
- createContainer(root: any, container: any, prepend?: boolean): void;
1487
- renderTemplate({ prep, root, template, itemPreprocessor, itemPostprocessor }?: any): void;
1418
+ #private;
1419
+ settings: any;
1420
+ data: any;
1421
+ tracker: void;
1422
+ constructor(settings: any);
1423
+ init(callback: Function, existingDisplays?: object[]): void;
1424
+ loadRecommendations(callback: any): void;
1425
+ trackGAEvent(action: any, index: any, product_id: any, ga_product_ids?: string[]): void;
1426
+ trackPageView(): void;
1427
+ trackClick(index: any): boolean | Promise<void | undefined> | undefined;
1428
+ trackAddToCart(pId: any): boolean | Promise<void | undefined> | undefined;
1429
+ createContainer(root: any, container: any, prepend?: boolean): void;
1430
+ renderTemplate({
1431
+ prep,
1432
+ root,
1433
+ template,
1434
+ itemPreprocessor,
1435
+ itemPostprocessor
1436
+ }?: any): void;
1488
1437
  }
1489
1438
  declare global {
1490
- interface Document {
1491
- _depict_modify: boolean | undefined;
1492
- }
1439
+ interface Document {
1440
+ _depict_modify: boolean | undefined;
1441
+ }
1493
1442
  }
1494
1443
  interface TemplateToolOptions {
1495
- max_items?: number;
1496
- min_items?: number;
1497
- DNT?: boolean;
1498
- debug?: boolean;
1499
- type?: string;
1500
- product_id?: Function | ((url?: string) => string);
1501
- sendGa?: boolean;
1502
- loadHack?: boolean;
1503
- shade?: boolean;
1504
- gaid?: string;
1505
- tenant?: string;
1506
- market?: string;
1444
+ max_items?: number;
1445
+ min_items?: number;
1446
+ DNT?: boolean;
1447
+ debug?: boolean;
1448
+ type?: string;
1449
+ product_id?: Function | ((url?: string) => string);
1450
+ sendGa?: boolean;
1451
+ loadHack?: boolean;
1452
+ shade?: boolean;
1453
+ gaid?: string;
1454
+ tenant?: string;
1455
+ market?: string;
1507
1456
  }
1508
1457
  /**
1509
1458
  * @deprecated Please use RecommendationRenderer instead
1510
1459
  */
1511
1460
  export const simplified_template_tool: (options: {
1512
- options: TemplateToolOptions;
1513
- recs?: object[] | undefined;
1514
- root: Element;
1515
- template: string;
1516
- postProcessor?: Function | undefined;
1517
- preProcessor?: Function | undefined;
1461
+ options: TemplateToolOptions;
1462
+ recs?: object[] | undefined;
1463
+ root: Element;
1464
+ template: string;
1465
+ postProcessor?: Function | undefined;
1466
+ preProcessor?: Function | undefined;
1518
1467
  }) => Promise<Depict>;
1519
- interface special_lazyfier_options extends Omit<Lazyfier_Options, "t"> {
1520
- }
1468
+ interface special_lazyfier_options extends Omit<Lazyfier_Options, "t"> {}
1521
1469
  interface Deprecated_Slider_Options {
1522
- dlog?: Function;
1523
- catchify?: Function;
1524
- dist_to_hide_left?: number;
1525
- dist_to_hide_right?: number;
1526
- stepstoslide?: number;
1527
- arrow_image?: string;
1528
- center_target?: boolean;
1529
- constructor_plugins?: ((arg0: Deprecated_Slider_Options) => any)[];
1530
- mutation_plugins?: ((mutations: IntersectionObserverEntry[], intersecting_items: Record<number, IntersectionObserverEntry>) => any)[];
1531
- correct_bs_targets?: boolean;
1470
+ dlog?: Function;
1471
+ catchify?: Function;
1472
+ dist_to_hide_left?: number;
1473
+ dist_to_hide_right?: number;
1474
+ stepstoslide?: number;
1475
+ arrow_image?: string;
1476
+ center_target?: boolean;
1477
+ constructor_plugins?: ((arg0: Deprecated_Slider_Options) => any)[];
1478
+ mutation_plugins?: ((mutations: IntersectionObserverEntry[], intersecting_items: Record<number, IntersectionObserverEntry>) => any)[];
1479
+ correct_bs_targets?: boolean;
1532
1480
  }
1533
1481
  /**
1534
1482
  * @deprecated Please use Pro_Slider instead
1535
1483
  */
1536
1484
  declare class Deprecated_Amazing_Slider extends Amazing_Lazy_Slider {
1537
- constructor(static_options: Deprecated_Slider_Options, override_lazyfier_options?: special_lazyfier_options);
1485
+ constructor(static_options: Deprecated_Slider_Options, override_lazyfier_options?: special_lazyfier_options);
1538
1486
  }
1539
1487
  export function insert_styling_into_slider(slider: Deprecated_Amazing_Slider): void;
1540
1488
  interface RR_Slider_Options {
1541
- container?: string | Node_Iterable;
1542
- root_selector?: string;
1543
- Rec_Renderer?: typeof Rec_Renderer;
1544
- insertion_verb?: "append" | "prepend" | "before" | "after" | "replaceWith";
1489
+ container?: string | Node_Iterable;
1490
+ root_selector?: string;
1491
+ Rec_Renderer?: typeof Rec_Renderer;
1492
+ insertion_verb?: "append" | "prepend" | "before" | "after" | "replaceWith";
1545
1493
  }
1546
1494
  /**
1547
1495
  * @deprecated please use Pro_Slider instead
@@ -1552,23 +1500,38 @@ type PostProcessor = (tenant: Tenant, items: HTMLCollection, display: any, slide
1552
1500
  /**
1553
1501
  * @deprecated this uses template-tool-v1 which is long surpassed, please use RecommendationGrid or Pro_Slider (based on Recommendation-Renderer) instead
1554
1502
  */
1555
- export function get_recs_with_template({ t, recs, title, infinite_scroll, with_slider, with_loadmore, template_tool_options, slider_options, pre_processors, post_processors, container_template, // container template
1556
- template, // recommendation template
1557
- chunk_size_for_load_more, insertion_promise, }: {
1558
- t: Tenant;
1559
- recs?: any[];
1560
- with_loadmore?: boolean;
1561
- title?: string | Node[] | NodeList;
1562
- infinite_scroll?: boolean;
1563
- template_tool_options?: TemplateToolOptions;
1564
- with_slider?: boolean;
1565
- slider_options?: Deprecated_Slider_Options;
1566
- pre_processors?: PreProcessor[];
1567
- post_processors?: PostProcessor[];
1568
- container_template: string;
1569
- template: string;
1570
- chunk_size_for_load_more?: number;
1571
- insertion_promise?: Promise<void | unknown>;
1503
+ export function get_recs_with_template({
1504
+ t,
1505
+ recs,
1506
+ title,
1507
+ infinite_scroll,
1508
+ with_slider,
1509
+ with_loadmore,
1510
+ template_tool_options,
1511
+ slider_options,
1512
+ pre_processors,
1513
+ post_processors,
1514
+ container_template,
1515
+ // container template
1516
+ template,
1517
+ // recommendation template
1518
+ chunk_size_for_load_more,
1519
+ insertion_promise
1520
+ }: {
1521
+ t: Tenant;
1522
+ recs?: any[];
1523
+ with_loadmore?: boolean;
1524
+ title?: string | Node[] | NodeList;
1525
+ infinite_scroll?: boolean;
1526
+ template_tool_options?: TemplateToolOptions;
1527
+ with_slider?: boolean;
1528
+ slider_options?: Deprecated_Slider_Options;
1529
+ pre_processors?: PreProcessor[];
1530
+ post_processors?: PostProcessor[];
1531
+ container_template: string;
1532
+ template: string;
1533
+ chunk_size_for_load_more?: number;
1534
+ insertion_promise?: Promise<void | unknown>;
1572
1535
  }): Promise<ChildNode[] | void>;
1573
1536
  export function default_pre_processor(_t: any, d: any, i: number, with_loadmore: boolean, with_slider: boolean, infinite_scroll: boolean): any;
1574
1537
  export function default_post_processor(_t: any, itms: HTMLCollection, d: any, slider: Deprecated_Amazing_Slider | null): HTMLCollection;
@@ -1586,22 +1549,30 @@ export const use_element: <E extends HTMLOrSVGElement = HTMLElement>(callback: (
1586
1549
  export function use_listener<K extends keyof GlobalEventHandlersEventMap, E extends HTMLElement = HTMLElement>(event: K, handler: (this: GlobalEventHandlers, ev: GlobalEventHandlersEventMap[K]) => any, element: E): E;
1587
1550
  export const classlist: (classes: (string | undefined)[]) => string;
1588
1551
  type Props = {
1589
- children?: Elem[] | Elem;
1590
- onClick?: (e: MouseEvent) => void;
1591
- [key: string]: any;
1552
+ children?: Elem[] | Elem;
1553
+ onClick?: (e: MouseEvent) => void;
1554
+ [key: string]: any;
1592
1555
  };
1593
1556
  type Elem = Node | string;
1594
1557
  type Component = (props: Props, _unknown?: unknown) => HTMLElement;
1595
- export const jsx: (tag: string | Component, { children, ...props }: Props, _unknown?: unknown) => JSX.Element;
1596
- export const jsxs: (tag: string | Component, { children, ...props }: Props, _unknown?: unknown) => JSX.Element;
1558
+ export const jsx: (tag: string | Component, {
1559
+ children,
1560
+ ...props
1561
+ }: Props, _unknown?: unknown) => JSX.Element;
1562
+ export const jsxs: (tag: string | Component, {
1563
+ children,
1564
+ ...props
1565
+ }: Props, _unknown?: unknown) => JSX.Element;
1597
1566
  export const chevronRight: HTMLElement;
1598
1567
  export const chevronLeft: HTMLElement;
1599
- export const expandingContainer: ({ duration }?: {
1600
- duration?: number;
1568
+ export const expandingContainer: ({
1569
+ duration
1570
+ }?: {
1571
+ duration?: number;
1601
1572
  }) => {
1602
- expand: () => void;
1603
- content: HTMLDivElement;
1604
- container: HTMLDivElement;
1573
+ expand: () => void;
1574
+ content: HTMLDivElement;
1575
+ container: HTMLDivElement;
1605
1576
  };
1606
1577
  /**
1607
1578
  * Like Promise.any but for async iterable infinite promises (object that have `.state` and a [Symbol.asyncIterator]). Returns an array of all current values when one value udpates.
@@ -1614,24 +1585,24 @@ export function zip_async_iterables<T extends any[]>(iterables: IPNS<T[keyof T]>
1614
1585
  * @param value The amount of columns that your selected row should have
1615
1586
  */
1616
1587
  type Override = {
1617
- overrides: Record</* Row: */ number, /* Column: */ number>;
1588
+ overrides: Record< /* Row: */number, /* Column: */number>;
1618
1589
  };
1619
- export type ColAtSize = /** [ <number of columns>, <min-width>, <max-width>, <spacing> ] */ readonly [number, null, string, string | null] | readonly [number, string, string, null, Override] | readonly [number, string, null, string | null] | readonly [number, string, string, string | null] | readonly [number, string, null] | readonly [number, string, string] | readonly [number, null, string] | readonly [number, string];
1590
+ export type ColAtSize = /** [ <number of columns>, <min-width>, <max-width>, <spacing> ] */readonly [number, null, string, string | null] | readonly [number, string, string, null, Override] | readonly [number, string, null, string | null] | readonly [number, string, string, string | null] | readonly [number, string, null] | readonly [number, string, string] | readonly [number, null, string] | readonly [number, string];
1620
1591
  export type ColsAtSize = readonly ColAtSize[];
1621
1592
  export type LayoutOptions = {
1622
- container_element: Element;
1623
- cols_at_size: ColsAtSize;
1624
- grid_spacing: string;
1625
- rows: {
1626
- start_rows?: number;
1627
- rows_per_click?: number;
1628
- ipns?: IPNS<number>;
1629
- max_rows?: number;
1630
- button?: HTMLElement;
1631
- } | "all";
1632
- layout: "slider" | "grid";
1633
- disable_partial_rows?: boolean;
1634
- override_vertical_spacing?: string;
1593
+ container_element: Element;
1594
+ cols_at_size: ColsAtSize;
1595
+ grid_spacing: string;
1596
+ rows: {
1597
+ start_rows?: number;
1598
+ rows_per_click?: number;
1599
+ ipns?: IPNS<number>;
1600
+ max_rows?: number;
1601
+ button?: HTMLElement;
1602
+ } | "all";
1603
+ layout: "slider" | "grid";
1604
+ disable_partial_rows?: boolean;
1605
+ override_vertical_spacing?: string;
1635
1606
  };
1636
1607
  export const layout_media_query_header: (min: string, max?: string) => string;
1637
1608
  /**
@@ -1643,7 +1614,15 @@ export const layout_media_query_header: (min: string, max?: string) => string;
1643
1614
  * @param disable_partial_rows If set to `true`, will not let user press "show more" if next row is a partial row. Example of partial row: `cols_at_size` says we should have 4 recs in the next row but we only have 2 left, so the row just gets 2 instead of 4, meaning it doesn't "fill out".
1644
1615
  * @param override_vertical_spacing by default, the grid_spacing is used both horizontally and vertically, with this you can specify a separate spacing
1645
1616
  */
1646
- export function Layout({ rows, container_element, cols_at_size, grid_spacing, layout, disable_partial_rows, override_vertical_spacing, }: LayoutOptions): Promise<void>;
1617
+ export function Layout({
1618
+ rows,
1619
+ container_element,
1620
+ cols_at_size,
1621
+ grid_spacing,
1622
+ layout,
1623
+ disable_partial_rows,
1624
+ override_vertical_spacing
1625
+ }: LayoutOptions): Promise<void>;
1647
1626
  /** Getting how many recs should be displayed for a certain row (while taking override rules into account)
1648
1627
  * This returns number of recs for this row and all the previous ones
1649
1628
  * @param row The "index" of the row (counting from the top). Starts at 1.
@@ -1664,11 +1643,11 @@ export function layout_get_visible_recs_without_partial_rows(rows: number, max_r
1664
1643
  */
1665
1644
  export function n_col_styling_with_dist(selector_beginning: string, default_grid_spacing_text: string, cols_at_size: ColsAtSize, layout: "slider" | "grid", override_vertical_spacing?: string): string;
1666
1645
  export interface RecommendationGridOptions<T extends Display> extends Omit<LayoutOptions, "container_element" | "layout"> {
1667
- container_elements: Node_Array;
1668
- container_selector?: string;
1669
- override_rec_renderer?: typeof default_rr<T>;
1670
- lazyfier_options?: Omit<Lazyfier_Options, "t">;
1671
- eager_images?: boolean;
1646
+ container_elements: Node_Array;
1647
+ container_selector?: string;
1648
+ override_rec_renderer?: typeof default_rr<T>;
1649
+ lazyfier_options?: Omit<Lazyfier_Options, "t">;
1650
+ eager_images?: boolean;
1672
1651
  }
1673
1652
  /**
1674
1653
  * RecommendationGrid: Searches your container_elements for ".grid" or `container_selector`, runs default_rr or `override_rec_renderer` and puts the recs into the found element. Then runs `Grid` on it.
@@ -1682,37 +1661,44 @@ export interface RecommendationGridOptions<T extends Display> extends Omit<Layou
1682
1661
  * @param ...options_for_grid Options for Grid. See documentation of Grid.
1683
1662
  * @constructor
1684
1663
  */
1685
- export function RecommendationGrid<T extends Display>(t: Tenant | null, recommendation_renderer_options: Extended_RR_Options<T>, { container_elements, container_selector, override_rec_renderer, lazyfier_options, eager_images, ...options_for_grid }: RecommendationGridOptions<T>): Promise<RecRendererResult<T>>;
1664
+ export function RecommendationGrid<T extends Display>(t: Tenant | null, recommendation_renderer_options: Extended_RR_Options<T>, {
1665
+ container_elements,
1666
+ container_selector,
1667
+ override_rec_renderer,
1668
+ lazyfier_options,
1669
+ eager_images,
1670
+ ...options_for_grid
1671
+ }: RecommendationGridOptions<T>): Promise<RecRendererResult<T>>;
1686
1672
  export interface EasySliderOptions<T extends Display> extends Omit<LayoutOptions, "container_element" | "rows" | "layout"> {
1687
- rows?: {
1688
- start_rows?: number;
1689
- ipns?: IPNS<number>;
1690
- } | "all";
1691
- container_elements: Node_Array;
1692
- container_selector?: string;
1693
- override_rec_renderer?: typeof default_rr<T>;
1694
- lazyfier_options?: Omit<Lazyfier_Options, "t">;
1695
- eager_images?: boolean;
1696
- dist_to_hide_left?: number;
1697
- dist_to_hide_right?: number;
1698
- stepstoslide?: number;
1699
- center_target?: boolean;
1700
- constructor_plugins?: ((arg0: Slider_Options) => any)[];
1701
- mutation_plugins?: ((mutations: IntersectionObserverEntry[], intersecting_items: Record<number, IntersectionObserverEntry>) => any)[];
1702
- button_contents?: {
1703
- right: Node_Iterable;
1704
- left: Node_Iterable;
1705
- };
1706
- button_elems?: {
1707
- right: HTMLElement;
1708
- left: HTMLElement;
1709
- };
1710
- override_vertical_spacing?: string;
1673
+ rows?: {
1674
+ start_rows?: number;
1675
+ ipns?: IPNS<number>;
1676
+ } | "all";
1677
+ container_elements: Node_Array;
1678
+ container_selector?: string;
1679
+ override_rec_renderer?: typeof default_rr<T>;
1680
+ lazyfier_options?: Omit<Lazyfier_Options, "t">;
1681
+ eager_images?: boolean;
1682
+ dist_to_hide_left?: number;
1683
+ dist_to_hide_right?: number;
1684
+ stepstoslide?: number;
1685
+ center_target?: boolean;
1686
+ constructor_plugins?: ((arg0: Slider_Options) => any)[];
1687
+ mutation_plugins?: ((mutations: IntersectionObserverEntry[], intersecting_items: Record<number, IntersectionObserverEntry>) => any)[];
1688
+ button_contents?: {
1689
+ right: Node_Iterable;
1690
+ left: Node_Iterable;
1691
+ };
1692
+ button_elems?: {
1693
+ right: HTMLElement;
1694
+ left: HTMLElement;
1695
+ };
1696
+ override_vertical_spacing?: string;
1711
1697
  }
1712
1698
  export type RecommendationSliderSurface<T extends Display> = Record<string, never> | {
1713
- elements: Node_Array;
1714
- slider: Amazing_Slider | Amazing_Lazy_Slider;
1715
- displays: T[];
1699
+ elements: Node_Array;
1700
+ slider: Amazing_Slider | Amazing_Lazy_Slider;
1701
+ displays: T[];
1716
1702
  };
1717
1703
  /**
1718
1704
  *
@@ -1722,54 +1708,78 @@ export type RecommendationSliderSurface<T extends Display> = Record<string, neve
1722
1708
  * @param RecommendationGrid_options Similar options object to RecommendationGrid except that it also contains options to Amazing_Slider
1723
1709
  * @return a Surface (object) that contains displays, elements and the instance of the slider class (as `slider`)
1724
1710
  */
1725
- export function RecommendationSlider<T extends Display>(t: Tenant | null, recommendation_renderer_options: Extended_RR_Options<T>, { container_elements, container_selector, override_rec_renderer, lazyfier_options, eager_images, grid_spacing, cols_at_size, override_vertical_spacing, rows, ...slider_options }: EasySliderOptions<T>): Promise<RecommendationSliderSurface<T> | RecRendererResult<T> | Surface<T>>;
1711
+ export function RecommendationSlider<T extends Display>(t: Tenant | null, recommendation_renderer_options: Extended_RR_Options<T>, {
1712
+ container_elements,
1713
+ container_selector,
1714
+ override_rec_renderer,
1715
+ lazyfier_options,
1716
+ eager_images,
1717
+ grid_spacing,
1718
+ cols_at_size,
1719
+ override_vertical_spacing,
1720
+ rows,
1721
+ ...slider_options
1722
+ }: EasySliderOptions<T>): Promise<RecommendationSliderSurface<T> | RecRendererResult<T> | Surface<T>>;
1726
1723
  export function slider_autoscroll_factory(interval?: number): {
1727
- constructor_plugin(this: Amazing_Slider): void;
1728
- mutation_plugin: (this: Amazing_Slider, _intersections: IntersectionObserverEntry[], intersecting_mutations: Record<number, IntersectionObserverEntry>) => void;
1724
+ constructor_plugin(this: Amazing_Slider): void;
1725
+ mutation_plugin: (this: Amazing_Slider, _intersections: IntersectionObserverEntry[], intersecting_mutations: Record<number, IntersectionObserverEntry>) => void;
1729
1726
  };
1730
1727
  export function make_button1(): {
1731
- left: [HTMLImageElement];
1732
- right: [HTMLImageElement];
1728
+ left: [HTMLImageElement];
1729
+ right: [HTMLImageElement];
1733
1730
  };
1734
1731
  /**
1735
1732
  * Returns an object to put into `button_contents` for `Pro_Slider` containing the icon arrow images
1736
1733
  * @return An object with left and right being an array containing one image
1737
1734
  */
1738
1735
  export function make_button2(): {
1739
- left: HTMLImageElement[];
1740
- right: HTMLImageElement[];
1736
+ left: HTMLImageElement[];
1737
+ right: HTMLImageElement[];
1741
1738
  };
1742
- export function slider_dots_factory({ t, navcont_insertion_fn, navdot, dontshowonedot, bitesize, }: {
1743
- t: Tenant;
1744
- navcont_insertion_fn?: (slider: Amazing_Slider, navcont: HTMLDivElement) => any;
1745
- navdot: (unique_name: number, index: number) => Element;
1746
- dontshowonedot?: boolean;
1747
- bitesize?: number;
1739
+ export function slider_dots_factory({
1740
+ t,
1741
+ navcont_insertion_fn,
1742
+ navdot,
1743
+ dontshowonedot,
1744
+ bitesize
1745
+ }: {
1746
+ t: Tenant;
1747
+ navcont_insertion_fn?: (slider: Amazing_Slider, navcont: HTMLDivElement) => any;
1748
+ navdot: (unique_name: number, index: number) => Element;
1749
+ dontshowonedot?: boolean;
1750
+ bitesize?: number;
1748
1751
  }): {
1749
- constructor_plugin: () => void;
1750
- mutation_plugin: (intersections: IntersectionObserverEntry[], intersecting_mutations: Record<number, IntersectionObserverEntry>) => void;
1752
+ constructor_plugin: () => void;
1753
+ mutation_plugin: (intersections: IntersectionObserverEntry[], intersecting_mutations: Record<number, IntersectionObserverEntry>) => void;
1751
1754
  };
1752
1755
  export function navdot(unique_name: string | number): HTMLElement;
1753
1756
  export function slider_draggable_factory(t: Tenant): {
1754
- constructor_plugin: (slider_options: any) => void;
1755
- mutation_plugin: (intersections: IntersectionObserverEntry[], intersecting_mutations: Record<number, IntersectionObserverEntry>) => void;
1756
- post_pro_plugin: {
1757
- instant: (items: HTMLCollection) => void;
1758
- };
1757
+ constructor_plugin: (slider_options: any) => void;
1758
+ mutation_plugin: (intersections: IntersectionObserverEntry[], intersecting_mutations: Record<number, IntersectionObserverEntry>) => void;
1759
+ post_pro_plugin: {
1760
+ instant: (items: HTMLCollection) => void;
1761
+ };
1759
1762
  };
1760
- export function slider_fading_factory({ fade_in_duration_, fade_out_duration_, visible_opacity_, faded_opacity_, easing_, threshold_, }?: {
1761
- fade_in_duration_?: number;
1762
- fade_out_duration_?: number;
1763
- visible_opacity_?: number;
1764
- faded_opacity_?: number;
1765
- easing_?: string;
1766
- threshold_?: number;
1763
+ export function slider_fading_factory({
1764
+ fade_in_duration_,
1765
+ fade_out_duration_,
1766
+ visible_opacity_,
1767
+ faded_opacity_,
1768
+ easing_,
1769
+ threshold_
1770
+ }?: {
1771
+ fade_in_duration_?: number;
1772
+ fade_out_duration_?: number;
1773
+ visible_opacity_?: number;
1774
+ faded_opacity_?: number;
1775
+ easing_?: string;
1776
+ threshold_?: number;
1767
1777
  }): {
1768
- readonly mutation_plugin_: (this: Amazing_Slider, entries: IntersectionObserverEntry[], _intersecting_mutations: Record<number, IntersectionObserverEntry>) => void;
1778
+ readonly mutation_plugin_: (this: Amazing_Slider, entries: IntersectionObserverEntry[], _intersecting_mutations: Record<number, IntersectionObserverEntry>) => void;
1769
1779
  };
1770
1780
  export function slider_fractional_factory(_t?: any, fraction?: number, max_steps?: number, dont_enable_correct_bs_targets?: boolean, min_steps?: number): {
1771
- constructor_plugin: (slider_options: Slider_Options) => void;
1772
- mutation_plugin: (intersections: IntersectionObserverEntry[], intersecting_mutations: Record<number, IntersectionObserverEntry>) => void;
1781
+ constructor_plugin: (slider_options: Slider_Options) => void;
1782
+ mutation_plugin: (intersections: IntersectionObserverEntry[], intersecting_mutations: Record<number, IntersectionObserverEntry>) => void;
1773
1783
  };
1774
1784
  /**
1775
1785
  * * Plugin for rendering a scrollbar below the slider that follow the slider position.
@@ -1778,34 +1788,39 @@ export function slider_fractional_factory(_t?: any, fraction?: number, max_steps
1778
1788
  * @param options Options for the scrollbar. Add position styling and additional classes.
1779
1789
  */
1780
1790
  export function slider_show_scroll(options: {
1781
- add_position_styling: boolean;
1782
- scroll_bar_classes?: string[];
1783
- scroll_container_classes?: string[];
1791
+ add_position_styling: boolean;
1792
+ scroll_bar_classes?: string[];
1793
+ scroll_container_classes?: string[];
1784
1794
  }): {
1785
- constructor_plugin: (_slider_options: Slider_Options) => void;
1786
- mutation_plugin: (_intersections: IntersectionObserverEntry[], _intersecting_mutations: Record<number, IntersectionObserverEntry>) => void;
1795
+ constructor_plugin: (_slider_options: Slider_Options) => void;
1796
+ mutation_plugin: (_intersections: IntersectionObserverEntry[], _intersecting_mutations: Record<number, IntersectionObserverEntry>) => void;
1787
1797
  };
1788
- export function slider_snap_css(_t?: any, { snapEvery, align }?: {
1789
- snapEvery?: number;
1790
- align?: "center" | "start" | "end";
1798
+ export function slider_snap_css(_t?: any, {
1799
+ snapEvery,
1800
+ align
1801
+ }?: {
1802
+ snapEvery?: number;
1803
+ align?: "center" | "start" | "end";
1791
1804
  }): {
1792
- constructor_plugin: (_slider_options: Slider_Options) => void;
1793
- mutation_plugin: (_intersections: IntersectionObserverEntry[], intersecting_mutations: Record<number, IntersectionObserverEntry>) => void;
1805
+ constructor_plugin: (_slider_options: Slider_Options) => void;
1806
+ mutation_plugin: (_intersections: IntersectionObserverEntry[], intersecting_mutations: Record<number, IntersectionObserverEntry>) => void;
1794
1807
  };
1795
1808
  export function can_use_snapping_and_still_scroll(): Promise<boolean>;
1796
1809
  export function slider_snapping_factory(options?: {
1797
- stepsize?: number;
1798
- threshold?: number;
1810
+ stepsize?: number;
1811
+ threshold?: number;
1799
1812
  }): {
1800
- constructor_plugin: (slider_options: any) => void | undefined;
1801
- mutation_plugin: (intersections: IntersectionObserverEntry[], intersecting_mutations: Record<number, IntersectionObserverEntry>) => void | undefined;
1813
+ constructor_plugin: (slider_options: any) => void | undefined;
1814
+ mutation_plugin: (intersections: IntersectionObserverEntry[], intersecting_mutations: Record<number, IntersectionObserverEntry>) => void | undefined;
1802
1815
  };
1803
- export function slider_wraparound_factory({ clones_per_side }?: {
1804
- clones_per_side?: number | undefined;
1816
+ export function slider_wraparound_factory({
1817
+ clones_per_side
1818
+ }?: {
1819
+ clones_per_side?: number | undefined;
1805
1820
  }): {
1806
- constructor_plugin: (this: Amazing_Slider) => void;
1807
- mutation_plugin: (this: Amazing_Slider, intersections: IntersectionObserverEntry[], intersecting_mutations: Record<number, IntersectionObserverEntry>) => void;
1808
- post_processor: <T extends Display>(elements: Node_Array | NodeListOf<ChildNode>, _display: Display, info: InfoForProcessing<T>) => Promise<NodeListOf<ChildNode> | Node_Array>;
1821
+ constructor_plugin: (this: Amazing_Slider) => void;
1822
+ mutation_plugin: (this: Amazing_Slider, intersections: IntersectionObserverEntry[], intersecting_mutations: Record<number, IntersectionObserverEntry>) => void;
1823
+ post_processor: <T extends Display>(elements: Node_Array | NodeListOf<ChildNode>, _display: Display, info: InfoForProcessing<T>) => Promise<NodeListOf<ChildNode> | Node_Array>;
1809
1824
  };
1810
1825
  export type ReactiveTemplateValueContents = string | number | Node_Array[number] | undefined | (string | number | Node_Array[number])[];
1811
1826
  export function reactive_template(initial_value?: ReactiveTemplateValueContents): readonly [Node_Array, () => ReactiveTemplateValueContents, (arg0: ReactiveTemplateValueContents) => void];
@@ -1816,15 +1831,16 @@ export function reactive_template(initial_value?: ReactiveTemplateValueContents)
1816
1831
  * @param initial_call If the handler should be called instantly with the current state of the media query
1817
1832
  * @return An object containing `remove`, a function which removes the event listener again
1818
1833
  */
1819
- export function javascript_media_query(// inspired by code in houdinisportswear modify script
1834
+ export function javascript_media_query(
1835
+ // inspired by code in houdinisportswear modify script
1820
1836
  query: string, handler: (e: MediaQueryListEvent | MediaQueryList | {
1821
- matches: false;
1837
+ matches: false;
1822
1838
  }) => void, initial_call?: boolean): {
1823
- remove(): void;
1839
+ remove(): void;
1824
1840
  };
1825
1841
  type RenderingFunction<T extends Display> = (...args: any[]) => Promise<{
1826
- surface_: Surface<T> | void;
1827
- cache_until_?: Promise<any>;
1842
+ surface_: Surface<T> | void;
1843
+ cache_until_?: Promise<any>;
1828
1844
  }>;
1829
1845
  /**
1830
1846
  * Makes it possible to have "multiple surfaces" in one surface. So you provide multiple functions that return a `Surface` and get one `Surface` which will switch between the `Surface`s returned by the different functions depending on which one is selected by an IPNS.
@@ -1832,9 +1848,12 @@ type RenderingFunction<T extends Display> = (...args: any[]) => Promise<{
1832
1848
  * @param current_surface_ An IPNS representing which Surface should currently be chosen. It has to resolve with a number corresponding with the index of a function in surface_rendering_functions_.
1833
1849
  * @return a `Surface` object which, utilising a `reactive_template` always represents the currently chosen surface
1834
1850
  */
1835
- export function surface_mixer<T extends Display>({ surface_rendering_functions_, current_surface_, }: {
1836
- surface_rendering_functions_: RenderingFunction<T>[];
1837
- current_surface_: IPNS<number>;
1851
+ export function surface_mixer<T extends Display>({
1852
+ surface_rendering_functions_,
1853
+ current_surface_
1854
+ }: {
1855
+ surface_rendering_functions_: RenderingFunction<T>[];
1856
+ current_surface_: IPNS<number>;
1838
1857
  }): Promise<Surface<T>>;
1839
1858
  /**
1840
1859
  * To be used in conjunction with surface_mixer. Makes it possible to switch Surface depending on screen size
@@ -1871,18 +1890,18 @@ export function send_transaction_id_to_depict(t: Tenant, input_id: string, dsid?
1871
1890
  export function ga_to_transaction_api(t: Tenant, filter?: (text: string) => string | undefined): void;
1872
1891
  export function send_product_unavailable_to_depict(t: Tenant, unavailability_type: EUnavailabilityType): Promise<void>;
1873
1892
  export interface ListenableSetEvent<T> extends CustomEvent {
1874
- detail: T;
1893
+ detail: T;
1875
1894
  }
1876
1895
  /**
1877
1896
  * Set but you can listen for values being added or removed
1878
1897
  * i.e. my_set.addEventListener("add", ({detail}) => console.log(detail, "was added to", my_set));
1879
1898
  */
1880
1899
  export class ListenableSet<T> extends Set<T> {
1881
- #private;
1882
- addEventListener(event: "add" | "delete", callback: (ev: ListenableSetEvent<T>) => unknown, options?: Parameters<(typeof EventTarget.prototype)["addEventListener"]>[2]): void;
1883
- removeEventListener(event: "add" | "delete", callback: (ev: Event) => unknown): void;
1884
- add(property: T): this;
1885
- delete(property: T): any;
1900
+ #private;
1901
+ addEventListener(event: "add" | "delete", callback: (ev: ListenableSetEvent<T>) => unknown, options?: Parameters<(typeof EventTarget.prototype)["addEventListener"]>[2]): void;
1902
+ removeEventListener(event: "add" | "delete", callback: (ev: Event) => unknown): void;
1903
+ add(property: T): this;
1904
+ delete(property: T): any;
1886
1905
  }
1887
1906
  /**
1888
1907
  * This does what you'd think Element.closest does. It finds the closest node in the DOM tree matching a selector. So it starts out with the siblings and then goes upwards in the DOM and checks the siblings and their children of the parent until there's no parent anymore.
@@ -1924,18 +1943,18 @@ export function fetch_replacer(fetch_proxy_handler: (target: typeof window.fetch
1924
1943
  * @param override_options More options to pass to the `Response` constructor
1925
1944
  */
1926
1945
  export class FakeResponse extends Response {
1927
- constructor(response_string: string, url: string, headers?: HeadersInit, override_options?: ResponseInit);
1946
+ constructor(response_string: string, url: string, headers?: HeadersInit, override_options?: ResponseInit);
1928
1947
  }
1929
1948
  export type ShopifyItem = {
1930
- id: number;
1931
- handle: string;
1932
- quantity: number;
1933
- url: string;
1949
+ id: number;
1950
+ handle: string;
1951
+ quantity: number;
1952
+ url: string;
1934
1953
  };
1935
1954
  export type ShopifyError = {
1936
- status: number;
1937
- message: string;
1938
- description: string;
1955
+ status: number;
1956
+ message: string;
1957
+ description: string;
1939
1958
  };
1940
1959
  /**
1941
1960
  * Represents a Shopify cart "event", i.e. Whenever a Shopify API request is sucessfull.
@@ -1943,25 +1962,25 @@ export type ShopifyError = {
1943
1962
  * - `response` resolves to a shopify response
1944
1963
  */
1945
1964
  export type ShopifyEvent = {
1946
- type: "get_items";
1947
- response: Promise<ShopifyItem[] | ShopifyError>;
1948
- body?: object;
1965
+ type: "get_items";
1966
+ response: Promise<ShopifyItem[] | ShopifyError>;
1967
+ body?: object;
1949
1968
  } | {
1950
- type: "add_items";
1951
- response: Promise<ShopifyItem[] | ShopifyError>;
1952
- body?: object;
1969
+ type: "add_items";
1970
+ response: Promise<ShopifyItem[] | ShopifyError>;
1971
+ body?: object;
1953
1972
  } | {
1954
- type: "update_items";
1955
- response: Promise<ShopifyItem[] | ShopifyError>;
1956
- body?: object;
1973
+ type: "update_items";
1974
+ response: Promise<ShopifyItem[] | ShopifyError>;
1975
+ body?: object;
1957
1976
  } | {
1958
- type: "change_items";
1959
- response: Promise<ShopifyItem[] | ShopifyError>;
1960
- body?: object;
1977
+ type: "change_items";
1978
+ response: Promise<ShopifyItem[] | ShopifyError>;
1979
+ body?: object;
1961
1980
  } | {
1962
- type: "clear_items";
1963
- response: Promise<[] | ShopifyError>;
1964
- body?: object;
1981
+ type: "clear_items";
1982
+ response: Promise<[] | ShopifyError>;
1983
+ body?: object;
1965
1984
  };
1966
1985
  /**
1967
1986
  * Whenever any request to the shopify cart endpoint (this includes requests made by merchant code) is made {@link on_response} is called.
@@ -1987,7 +2006,7 @@ export type ShopifyEvent = {
1987
2006
  */
1988
2007
  export function intercept(on_request: (event: ShopifyEvent) => any): void;
1989
2008
  export type AddToCartOptions = {
1990
- quantity?: number;
2009
+ quantity?: number;
1991
2010
  };
1992
2011
  /**
1993
2012
  * Add an item to the Shopify cart.
@@ -2015,21 +2034,21 @@ export function add_item(shopify_id: string, options?: AddToCartOptions): Promis
2015
2034
  */
2016
2035
  export function get_items_in_cart(): Promise<ShopifyItem[] | ShopifyError>;
2017
2036
  declare global {
2018
- interface Window {
2019
- ShopifyAnalytics: {
2020
- meta?: {
2021
- product?: ShopifyMetaProduct;
2022
- };
2023
- };
2024
- }
2037
+ interface Window {
2038
+ ShopifyAnalytics: {
2039
+ meta?: {
2040
+ product?: ShopifyMetaProduct;
2041
+ };
2042
+ };
2043
+ }
2025
2044
  }
2026
2045
  interface ShopifyMetaProduct {
2046
+ id?: string;
2047
+ vendor?: string;
2048
+ variants?: {
2027
2049
  id?: string;
2028
- vendor?: string;
2029
- variants?: {
2030
- id?: string;
2031
- sku?: string;
2032
- }[];
2050
+ sku?: string;
2051
+ }[];
2033
2052
  }
2034
2053
  /** Shopify sites often has an interesting meta object defined on window.ShopifyAnalytics.meta
2035
2054
  * The SKU that backend requires might only be found in the meta object.
@@ -2044,10 +2063,14 @@ export const get_shopify_analytics_meta_product: () => Promise<ShopifyMetaProduc
2044
2063
  * @param functions_to_variants [description]
2045
2064
  * @return The return value of the called function
2046
2065
  */
2047
- export function get_optimize_variant({ t, experiment_id, functions_to_variants, }: {
2048
- t: Tenant;
2049
- experiment_id: string;
2050
- functions_to_variants: Function[];
2066
+ export function get_optimize_variant({
2067
+ t,
2068
+ experiment_id,
2069
+ functions_to_variants
2070
+ }: {
2071
+ t: Tenant;
2072
+ experiment_id: string;
2073
+ functions_to_variants: Function[];
2051
2074
  }): Promise<any>;
2052
2075
  /**
2053
2076
  * Ensures that the attribute value of an element is what an AsyncIterable resolves with
@@ -2082,39 +2105,46 @@ export const prevent_infinite_loop: <A extends any[], B>(cb: (...args: A) => voi
2082
2105
  * @param preserve_elements Whether to reinsert elements into it's container if they are removed, useful for sites using VDOM diffing such as react where nodes that aren't in the VDOM are removed when rerendering
2083
2106
  * @return An array of promises, corresponding to the provided surfaces, where each promise will resolve with an object containing the surface and whether it failed or succeded
2084
2107
  */
2085
- export function insert_surfaces<T extends Display>({ surfaces: input_surfaces, verb, target, remove_after_navigation, try_forever, preserve_elements, }: {
2086
- verb: InsertionVerb;
2087
- target: string | HTMLElement;
2088
- remove_after_navigation?: boolean;
2089
- try_forever?: boolean;
2090
- surfaces: (Promise<Surface<T> | void> | Surface<T> | void)[];
2091
- preserve_elements?: boolean;
2108
+ export function insert_surfaces<T extends Display>({
2109
+ surfaces: input_surfaces,
2110
+ verb,
2111
+ target,
2112
+ remove_after_navigation,
2113
+ try_forever,
2114
+ preserve_elements
2115
+ }: {
2116
+ verb: InsertionVerb;
2117
+ target: string | HTMLElement;
2118
+ remove_after_navigation?: boolean;
2119
+ try_forever?: boolean;
2120
+ surfaces: (Promise<Surface<T> | void> | Surface<T> | void)[];
2121
+ preserve_elements?: boolean;
2092
2122
  }): Promise<{
2093
- surface: Surface<T>;
2094
- succeeded: boolean;
2123
+ surface: Surface<T>;
2124
+ succeeded: boolean;
2095
2125
  }>[];
2096
2126
  export const revertable_remove: (target: string | Element | Node_Array, should_stay_inserted: Promise<boolean>) => Promise<void | undefined>;
2097
2127
  type MakePlaceholderRROption<T extends Display> = {
2098
- override_rec_renderer?: (t: Tenant | null, rendering_options: Extended_RR_Options<T>) => Promise<RecRendererResult<T>>;
2099
- image_width?: number;
2100
- image_height?: number;
2101
- color?: string;
2102
- num_items?: number;
2103
- on_no_rendering_result?: (result?: RecRendererResult<T>) => any;
2104
- post_rendering?: (surface?: RecRendererResult<T>) => Promise<void> | void;
2128
+ override_rec_renderer?: (t: Tenant | null, rendering_options: Extended_RR_Options<T>) => Promise<RecRendererResult<T>>;
2129
+ image_width?: number;
2130
+ image_height?: number;
2131
+ color?: string;
2132
+ num_items?: number;
2133
+ on_no_rendering_result?: (result?: RecRendererResult<T>) => any;
2134
+ post_rendering?: (surface?: RecRendererResult<T>) => Promise<void> | void;
2105
2135
  };
2106
2136
  /**
2107
2137
  * We want to deprecate this
2108
2138
  */
2109
2139
  export type PlaceholderRenderingDisplay = {
2110
- sale_price: number;
2111
- page_url: "#" | string;
2112
- image_url: string;
2113
- original_price: number;
2114
- product_id: "placeholder" | string;
2115
- recommendation_id: "placeholder" | string;
2116
- title: string;
2117
- brand: string;
2140
+ sale_price: number;
2141
+ page_url: "#" | string;
2142
+ image_url: string;
2143
+ original_price: number;
2144
+ product_id: "placeholder" | string;
2145
+ recommendation_id: "placeholder" | string;
2146
+ title: string;
2147
+ brand: string;
2118
2148
  };
2119
2149
  export const random_text_placeholder: () => string;
2120
2150
  export const placeholder_svg: (image_width: number, image_height: number, color?: string) => string;
@@ -2129,9 +2159,17 @@ export const placeholder_svg: (image_width: number, image_height: number, color?
2129
2159
  * @param [post_rendering] Will be called and awaited after rendering of actual recommendations, has a chance to change them before they get inserted into the DOM
2130
2160
  * @return It returns the same as a normal recommenation renderer would, meaning an object that might contain `displays` and `elements`
2131
2161
  */
2132
- export function make_placeholder_rr<T extends Display>({ override_rec_renderer, image_width, image_height, num_items, color, on_no_rendering_result, post_rendering, }?: MakePlaceholderRROption<T>): Promise<(t: Tenant | null, rendering_options: Extended_RR_Options<T | PlaceholderRenderingDisplay>) => Promise<Record<string, never> | {
2133
- elements: Node_Array;
2134
- displays: T[];
2162
+ export function make_placeholder_rr<T extends Display>({
2163
+ override_rec_renderer,
2164
+ image_width,
2165
+ image_height,
2166
+ num_items,
2167
+ color,
2168
+ on_no_rendering_result,
2169
+ post_rendering
2170
+ }?: MakePlaceholderRROption<T>): Promise<(t: Tenant | null, rendering_options: Extended_RR_Options<T | PlaceholderRenderingDisplay>) => Promise<Record<string, never> | {
2171
+ elements: Node_Array;
2172
+ displays: T[];
2135
2173
  }>>;
2136
2174
  /**
2137
2175
  * Makes Node.prototype.removeChild not throw and emulate correct removal when a node is being removed by React's VDOM diffing that we have already removed before
@@ -2203,110 +2241,144 @@ export function timeout_promise<T>(promise: Promise<T>, ms: number): Promise<Awa
2203
2241
  */
2204
2242
  export const use_voyado_id: () => void | undefined;
2205
2243
  type ButtonProps = Omit<Partial<JSX.IntrinsicElements["button"]>, "type"> & {
2206
- class?: string;
2244
+ class?: string;
2207
2245
  };
2208
- export function DefaultViewMoreButton({ children, ...attributes }: ButtonProps): HTMLButtonElement;
2209
- export function GeneralSideSlidein({ title_, children, CloseIcon, }: {
2210
- title_: IPNS<string>;
2211
- children: HTMLElement | HTMLElement[];
2212
- CloseIcon: () => HTMLElement | SVGElement;
2246
+ export function DefaultViewMoreButton({
2247
+ children,
2248
+ ...attributes
2249
+ }: ButtonProps): HTMLButtonElement;
2250
+ export function GeneralSideSlidein({
2251
+ title_,
2252
+ children,
2253
+ CloseIcon
2254
+ }: {
2255
+ title_: IPNS<string>;
2256
+ children: HTMLElement | HTMLElement[];
2257
+ CloseIcon: () => HTMLElement | SVGElement;
2213
2258
  }): Promise<{
2214
- close_: VoidFunction;
2215
- on_close_: (fn: VoidFunction) => number;
2259
+ close_: VoidFunction;
2260
+ on_close_: (fn: VoidFunction) => number;
2216
2261
  }>;
2217
- export function GeneralSizeSelector({ title_, items_, out_of_stock_text_, CloseIcon, }: {
2218
- title_: IPNS<string>;
2219
- out_of_stock_text_: IPNS<string>;
2220
- items_: {
2221
- id_: string;
2222
- size_name_: string;
2223
- is_available_: boolean;
2224
- }[];
2225
- CloseIcon: () => HTMLElement | SVGElement;
2262
+ export function GeneralSizeSelector({
2263
+ title_,
2264
+ items_,
2265
+ out_of_stock_text_,
2266
+ CloseIcon
2267
+ }: {
2268
+ title_: IPNS<string>;
2269
+ out_of_stock_text_: IPNS<string>;
2270
+ items_: {
2271
+ id_: string;
2272
+ size_name_: string;
2273
+ is_available_: boolean;
2274
+ }[];
2275
+ CloseIcon: () => HTMLElement | SVGElement;
2226
2276
  }): Promise<string | void>;
2227
2277
  type PlaceholderProps = Omit<Partial<JSX.IntrinsicElements["div"]>, "style"> & {
2228
- /** Any extra classes togheter with the default `depict-placeholder` class */
2229
- class?: string;
2230
- /** Convinence prop for setting element width */
2231
- width?: string;
2232
- /** Convinence prop for setting element height */
2233
- height?: string;
2234
- /** Will override the usage of width & height */
2235
- style?: string;
2278
+ /** Any extra classes togheter with the default `depict-placeholder` class */
2279
+ class?: string;
2280
+ /** Convinence prop for setting element width */
2281
+ width?: string;
2282
+ /** Convinence prop for setting element height */
2283
+ height?: string;
2284
+ /** Will override the usage of width & height */
2285
+ style?: string;
2236
2286
  };
2237
2287
  type PlaceholderImageProps = Omit<PlaceholderProps, "width" | "height" | "style"> & {
2238
- aspect_ratio: number;
2288
+ aspect_ratio: number;
2239
2289
  };
2240
2290
  /**
2241
2291
  * A Placeholder with shimmering animation.
2242
2292
  * For text you can use `height="1em"`.
2243
2293
  * For specific number of characters use `ch`, ex: `width="7ch"`
2244
2294
  */
2245
- export const Placeholder: ({ width, height, class: extra_classes, style, ...attributes }: PlaceholderProps) => HTMLElement;
2295
+ export const Placeholder: ({
2296
+ width,
2297
+ height,
2298
+ class: extra_classes,
2299
+ style,
2300
+ ...attributes
2301
+ }: PlaceholderProps) => HTMLElement;
2246
2302
  /**
2247
2303
  * A wrapper of Placeholder with full width and maintained aspect ratio.
2248
2304
  * @see {@link Placeholder}
2249
2305
  */
2250
- export const ContainedPlaceholderImage: ({ aspect_ratio, ...attributes }: PlaceholderImageProps) => HTMLElement;
2306
+ export const ContainedPlaceholderImage: ({
2307
+ aspect_ratio,
2308
+ ...attributes
2309
+ }: PlaceholderImageProps) => HTMLElement;
2251
2310
  export const RecommendationContainer: (title?: string | HTMLElement, surface_classes?: string[]) => HTMLElement;
2252
2311
  export const RightChevron: () => HTMLElement;
2253
2312
  export const LeftChevron: () => HTMLElement;
2254
2313
  export type ColorObj = {
2255
- /** the value passed as a css color */
2256
- value: string;
2257
- /** if specified, it's used as a title on hover */
2258
- label?: string;
2259
- /** Allow for arbitrary data to be passed */
2260
- [key: string]: any;
2314
+ /** the value passed as a css color */
2315
+ value: string;
2316
+ /** if specified, it's used as a title on hover */
2317
+ label?: string;
2318
+ /** Allow for arbitrary data to be passed */
2319
+ [key: string]: any;
2261
2320
  };
2262
2321
  interface ColorPickerProps {
2263
- /** An array of colors that can be selected */
2264
- colors: ColorObj[];
2265
- onSelect: (color: ColorObj) => unknown;
2266
- /**
2267
- * Called everytime a color is hovered
2268
- */
2269
- onHoverUpdate?: (color: ColorObj, hovering: boolean) => unknown;
2270
- /**
2271
- * The color value to be initially selected. Can be omitted for no color to be selected.
2272
- * If multiple colors use the same hex value, the label can also be specified (using a ColorObj)
2273
- */
2274
- initialColor?: string | ColorObj;
2275
- /**
2276
- * Enabled hovering preview. When true `onSelect` will be called with a new color when it's hovered,
2277
- * then reverts back to the last clicked color when hovering is stopped
2278
- * */
2279
- selectOnHover?: boolean;
2280
- /**
2281
- * If set to true only `onSelect` will be called when an item is clicked
2282
- */
2283
- dontSetActiveOnClick?: boolean;
2284
- /**
2285
- * If only circles should be returned and not the container element
2286
- */
2287
- onlyCircles?: boolean;
2322
+ /** An array of colors that can be selected */
2323
+ colors: ColorObj[];
2324
+ onSelect: (color: ColorObj) => unknown;
2325
+ /**
2326
+ * Called everytime a color is hovered
2327
+ */
2328
+ onHoverUpdate?: (color: ColorObj, hovering: boolean) => unknown;
2329
+ /**
2330
+ * The color value to be initially selected. Can be omitted for no color to be selected.
2331
+ * If multiple colors use the same hex value, the label can also be specified (using a ColorObj)
2332
+ */
2333
+ initialColor?: string | ColorObj;
2334
+ /**
2335
+ * Enabled hovering preview. When true `onSelect` will be called with a new color when it's hovered,
2336
+ * then reverts back to the last clicked color when hovering is stopped
2337
+ * */
2338
+ selectOnHover?: boolean;
2339
+ /**
2340
+ * If set to true only `onSelect` will be called when an item is clicked
2341
+ */
2342
+ dontSetActiveOnClick?: boolean;
2343
+ /**
2344
+ * If only circles should be returned and not the container element
2345
+ */
2346
+ onlyCircles?: boolean;
2288
2347
  }
2289
2348
  /**
2290
2349
  * A color selector, that calls onSelect when a color is clicked and optionally on hover as well.
2291
2350
  */
2292
- export function createColorPicker({ colors, initialColor, onSelect, selectOnHover, onHoverUpdate, dontSetActiveOnClick, onlyCircles, }: ColorPickerProps): {
2293
- setActiveIndex: (index: number) => void | undefined;
2294
- ColorPicker(): HTMLElement;
2351
+ export function createColorPicker({
2352
+ colors,
2353
+ initialColor,
2354
+ onSelect,
2355
+ selectOnHover,
2356
+ onHoverUpdate,
2357
+ dontSetActiveOnClick,
2358
+ onlyCircles
2359
+ }: ColorPickerProps): {
2360
+ setActiveIndex: (index: number) => void | undefined;
2361
+ ColorPicker(): HTMLElement;
2295
2362
  };
2296
2363
  /**
2297
2364
  * For example how to use, check /src/glitter/main.tsx
2298
2365
  * Warning: Don't use margins for the element you want to expand, since the animation will look janky
2299
2366
  * EDIT: above no longer applies if you only have one element that you want to expand
2300
2367
  */
2301
- export const useExpandingContainer: ({ duration, delay }?: {
2302
- duration?: number;
2303
- delay?: number;
2368
+ export const useExpandingContainer: ({
2369
+ duration,
2370
+ delay
2371
+ }?: {
2372
+ duration?: number;
2373
+ delay?: number;
2304
2374
  }) => {
2305
- ExpandingContainer: ({ children }: {
2306
- children?: Elem | Elem[] | undefined;
2307
- }) => HTMLElement;
2308
- expand: (expanding_delay?: any, time_to_expand?: any) => Promise<Animation | undefined>;
2309
- collapse: (collapsing_delay?: any, time_to_collapse?: any) => Promise<Animation | undefined>;
2375
+ ExpandingContainer: ({
2376
+ children
2377
+ }: {
2378
+ children?: Elem | Elem[] | undefined;
2379
+ }) => HTMLElement;
2380
+ expand: (expanding_delay?: any, time_to_expand?: any) => Promise<Animation | undefined>;
2381
+ collapse: (collapsing_delay?: any, time_to_collapse?: any) => Promise<Animation | undefined>;
2310
2382
  };
2311
2383
  export const resize_base_url: string;
2312
2384
  export const is_safari: boolean;
@@ -2334,17 +2406,26 @@ export function make_sizes_setter(what_to_watch: HTMLElement, sizes_communicator
2334
2406
  * `const SourcesetComponent = make_sourceset_component(first_canvas, true, ["webp", "png", "tiff"]);`
2335
2407
  * and then instead of your <img> tags: `<SourcesetComponent data-src={d.image_url} class="image" />`
2336
2408
  */
2337
- export function make_sourceset_component({ what_to_watch, set_dataset, formats, resolutions, sizes_communicator, resolution_factor, market_, sizes_setter_, }?: {
2338
- what_to_watch?: HTMLElement;
2339
- set_dataset?: boolean;
2340
- formats?: string[];
2341
- resolutions?: number[];
2342
- sizes_communicator?: IPNS<number>;
2343
- resolution_factor?: number;
2344
- market_?: string;
2345
- sizes_setter_?: ReturnType<typeof make_sizes_setter>;
2409
+ export function make_sourceset_component({
2410
+ what_to_watch,
2411
+ set_dataset,
2412
+ formats,
2413
+ resolutions,
2414
+ sizes_communicator,
2415
+ resolution_factor,
2416
+ market_,
2417
+ sizes_setter_
2418
+ }?: {
2419
+ what_to_watch?: HTMLElement;
2420
+ set_dataset?: boolean;
2421
+ formats?: string[];
2422
+ resolutions?: number[];
2423
+ sizes_communicator?: IPNS<number>;
2424
+ resolution_factor?: number;
2425
+ market_?: string;
2426
+ sizes_setter_?: ReturnType<typeof make_sizes_setter>;
2346
2427
  }): (image_options: Partial<JSX.IntrinsicElements["img"]> & {
2347
- class?: string;
2428
+ class?: string;
2348
2429
  }) => HTMLElement;
2349
2430
  /**
2350
2431
  * Adds query parameters from the `params` parameter to the `base` url.
@@ -2354,19 +2435,19 @@ export function make_sourceset_component({ what_to_watch, set_dataset, formats,
2354
2435
  * @return an absolute URL with the added query parameters
2355
2436
  */
2356
2437
  export function make_url_with_query_params(base: string, params: {
2357
- [key: string]: any;
2438
+ [key: string]: any;
2358
2439
  }): string;
2359
2440
  export interface ImageOptions extends Partial<HTMLImageElement> {
2360
- aspect_ratio: number;
2361
- class?: string;
2362
- rendering_options?: RR_Options<any>;
2363
- srcset_opts?: Parameters<typeof make_sourceset_component>[0];
2364
- alt: string;
2365
- remove_on_error?: boolean;
2366
- /**
2367
- * If true, inserts grey placeholder svg's before the image lazyloader and the sourceset component add the real source
2368
- */
2369
- init_with_placeholder?: boolean;
2441
+ aspect_ratio: number;
2442
+ class?: string;
2443
+ rendering_options?: RR_Options<any>;
2444
+ srcset_opts?: Parameters<typeof make_sourceset_component>[0];
2445
+ alt: string;
2446
+ remove_on_error?: boolean;
2447
+ /**
2448
+ * If true, inserts grey placeholder svg's before the image lazyloader and the sourceset component add the real source
2449
+ */
2450
+ init_with_placeholder?: boolean;
2370
2451
  }
2371
2452
  /**
2372
2453
  * Contained image gives an image (a container with) intrinsic size of the given aspect ratio, filling out available space.
@@ -2385,19 +2466,30 @@ export interface ImageOptions extends Partial<HTMLImageElement> {
2385
2466
  * @param Everything else: attributes on the <img> tag
2386
2467
  * @returns It depends on options and build target. But it's always one HTMLElement.
2387
2468
  */
2388
- export const ContainedImage: ({ init_with_placeholder, ...options }: ImageOptions) => HTMLElement;
2469
+ export const ContainedImage: ({
2470
+ init_with_placeholder,
2471
+ ...options
2472
+ }: ImageOptions) => HTMLElement;
2389
2473
  type HoverImageOptions = ImageOptions & {
2390
- mobile_touch_hover?: boolean;
2391
- extra_container_class?: string;
2392
- main_extra_classes?: string;
2393
- second_src?: string;
2394
- second_srcset?: string;
2395
- second_srcset_opts?: Parameters<typeof make_sourceset_component>[0];
2396
- fade_length_seconds?: number;
2397
- /** The minimum amount of time for a touch to be considered a link click */
2398
- navigation_minimum_ms?: number;
2474
+ mobile_touch_hover?: boolean;
2475
+ extra_container_class?: string;
2476
+ main_extra_classes?: string;
2477
+ second_src?: string;
2478
+ second_srcset?: string;
2479
+ second_srcset_opts?: Parameters<typeof make_sourceset_component>[0];
2480
+ fade_length_seconds?: number;
2481
+ /** The minimum amount of time for a touch to be considered a link click */
2482
+ navigation_minimum_ms?: number;
2399
2483
  };
2400
- export const ContainedHoverImage: ({ second_src, second_srcset, second_srcset_opts, fade_length_seconds, mobile_touch_hover, navigation_minimum_ms, ...options }: HoverImageOptions) => HTMLElement;
2484
+ export const ContainedHoverImage: ({
2485
+ second_src,
2486
+ second_srcset,
2487
+ second_srcset_opts,
2488
+ fade_length_seconds,
2489
+ mobile_touch_hover,
2490
+ navigation_minimum_ms,
2491
+ ...options
2492
+ }: HoverImageOptions) => HTMLElement;
2401
2493
  /**
2402
2494
  * Shallowly converts all keys in an object from snake_case to camelCase.
2403
2495
  * Does not support symbol keys.
@@ -2405,7 +2497,7 @@ export const ContainedHoverImage: ({ second_src, second_srcset, second_srcset_op
2405
2497
  * @param obj the object. It will be cloned and not modified in-place.
2406
2498
  */
2407
2499
  export function camelCasifyObject<T extends {
2408
- [key: string]: any;
2500
+ [key: string]: any;
2409
2501
  }, X extends T = T>(obj: T): X;
2410
2502
  /**
2411
2503
  * Shallowly converts all keys in an object from camelCase to snake_case.
@@ -2413,7 +2505,7 @@ export function camelCasifyObject<T extends {
2413
2505
  * @param obj the object. It will be cloned and not modified in-place.
2414
2506
  */
2415
2507
  export function snakeCasifyObject<T extends {
2416
- [key: string]: any;
2508
+ [key: string]: any;
2417
2509
  }, X extends T = T>(obj: T): X;
2418
2510
  /**
2419
2511
  * Converts RGB to HSL
@@ -2435,3 +2527,8 @@ export function hsb_to_rgb(h: number, s: number, b: number): readonly [number, n
2435
2527
  * Source: https://gist.github.com/jfsiii/5641126
2436
2528
  */
2437
2529
  export function relative_luminance_from_rgb(R8bit: number, G8bit: number, B8bit: number): number;
2530
+ /**
2531
+ * Converts a hex string to an RGB array
2532
+ * Source: https://stackoverflow.com/a/39077686
2533
+ */
2534
+ export function hex_to_rgb(hex: string): [number, number, number] | null;