@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.
- package/ES10/index.cjs +8967 -0
- package/{dist → ES10}/index.d.ts +1212 -1115
- package/ES10/index.js +8708 -0
- package/latest/index.cjs +8336 -0
- package/latest/index.d.ts +2534 -0
- package/latest/index.js +8077 -0
- package/multi_import_deduplicator.cjs +31 -0
- package/multi_import_deduplicator.mjs +31 -0
- package/package.json +50 -14
- package/dist/main.cjs +0 -8931
- package/dist/module.js +0 -8666
package/{dist → ES10}/index.d.ts
RENAMED
|
@@ -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.
|
|
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
|
-
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
-
|
|
159
|
-
|
|
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
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
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
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
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
|
-
|
|
281
|
+
[key: string]: any;
|
|
288
282
|
}, use_ws?: boolean | undefined) => boolean | Promise<void | undefined> | undefined;
|
|
289
283
|
export const depict_click: (vars: Partial<{
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
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
|
-
|
|
309
|
+
[key: string]: any;
|
|
316
310
|
}) => boolean | Promise<void | undefined> | undefined;
|
|
317
311
|
export const depict_add_to_cart: (vars: Partial<{
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
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
|
-
|
|
337
|
+
[key: string]: any;
|
|
344
338
|
}) => boolean | Promise<void | undefined> | undefined;
|
|
345
339
|
export type ConsentObj = {
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
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
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
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
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
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
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
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
|
-
|
|
451
|
-
|
|
452
|
-
|
|
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
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
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: ({
|
|
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
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
499
|
+
recommendation_type?: string;
|
|
500
|
+
entity_price?: number;
|
|
501
|
+
market?: string;
|
|
502
|
+
tenant?: string;
|
|
503
|
+
product_id?: string;
|
|
506
504
|
} & ({
|
|
507
|
-
|
|
505
|
+
recommendation_id: string;
|
|
508
506
|
} | {
|
|
509
|
-
|
|
507
|
+
search_result_id: string;
|
|
510
508
|
} | {
|
|
511
|
-
|
|
509
|
+
product_listing_result_id: string;
|
|
512
510
|
} | {
|
|
513
|
-
|
|
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
|
-
|
|
518
|
-
|
|
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
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
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
|
-
|
|
574
|
-
|
|
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
|
-
|
|
578
|
-
|
|
579
|
-
|
|
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
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
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
|
-
|
|
709
|
+
domains: Domain[];
|
|
712
710
|
}
|
|
713
711
|
export interface Domain {
|
|
714
|
-
|
|
715
|
-
|
|
712
|
+
d: string;
|
|
713
|
+
c: number[];
|
|
716
714
|
}
|
|
717
715
|
export interface Configuration {
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
716
|
+
loaded: boolean;
|
|
717
|
+
loadRetry: number;
|
|
718
|
+
tags: any[];
|
|
719
|
+
trackingDomains: any[];
|
|
722
720
|
}
|
|
723
721
|
export interface Consent {
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
722
|
+
stamp: string;
|
|
723
|
+
necessary: boolean;
|
|
724
|
+
preferences: boolean;
|
|
725
|
+
statistics: boolean;
|
|
726
|
+
marketing: boolean;
|
|
729
727
|
}
|
|
730
728
|
export interface CookieList {
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
729
|
+
cookieTablePreference: any[];
|
|
730
|
+
cookieTableStatistics: any[];
|
|
731
|
+
cookieTableAdvertising: any[];
|
|
732
|
+
cookieTableUnclassified: any[];
|
|
735
733
|
}
|
|
736
734
|
export interface Iframe {
|
|
737
|
-
|
|
738
|
-
|
|
735
|
+
cookieconsentDataStyleDisplay: string;
|
|
736
|
+
mtjQuery171028673205955022363: number;
|
|
739
737
|
}
|
|
740
738
|
export interface RegulationRegions {
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
739
|
+
gdpr: string[];
|
|
740
|
+
ccpa: string[];
|
|
741
|
+
lgpd: string[];
|
|
744
742
|
}
|
|
745
743
|
export interface Regulations {
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
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
|
-
|
|
754
|
-
|
|
755
|
-
|
|
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
|
-
|
|
787
|
-
|
|
783
|
+
[key: string]: any;
|
|
784
|
+
list_name?: string | undefined;
|
|
788
785
|
} | ((display: T) => {
|
|
789
|
-
|
|
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
|
-
|
|
810
|
-
|
|
811
|
-
|
|
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
|
-
|
|
829
|
-
|
|
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
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
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
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
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
|
-
|
|
904
|
-
|
|
900
|
+
t?: Tenant;
|
|
901
|
+
impression_tracking?: false;
|
|
905
902
|
} | {
|
|
906
|
-
|
|
907
|
-
|
|
903
|
+
impression_tracking: true;
|
|
904
|
+
t: Tenant;
|
|
908
905
|
};
|
|
909
906
|
type TenantSpecificationOptions = {
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
907
|
+
t?: Tenant;
|
|
908
|
+
tenant: string;
|
|
909
|
+
market: string;
|
|
910
|
+
get_product_id: (url?: string) => string | Promise<string>;
|
|
914
911
|
} | {
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
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
|
-
|
|
922
|
-
|
|
918
|
+
product_selector: string;
|
|
919
|
+
product_elements?: null | void | undefined;
|
|
923
920
|
} | {
|
|
924
|
-
|
|
925
|
-
|
|
921
|
+
product_selector?: null | void | undefined;
|
|
922
|
+
product_elements: HTMLElement[];
|
|
926
923
|
};
|
|
927
924
|
type A2CButtonDiscoveryOptions = {
|
|
928
|
-
|
|
929
|
-
|
|
925
|
+
a2c_selector: string;
|
|
926
|
+
a2c_elements?: null | void | undefined;
|
|
930
927
|
} | {
|
|
931
|
-
|
|
932
|
-
|
|
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
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
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
|
-
|
|
952
|
-
|
|
948
|
+
[key: string]: any;
|
|
949
|
+
list_name?: string | undefined;
|
|
953
950
|
} | undefined) => Promise<{
|
|
954
|
-
|
|
955
|
-
|
|
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
|
-
|
|
979
|
-
|
|
980
|
-
|
|
975
|
+
category_id: string;
|
|
976
|
+
product_id?: undefined;
|
|
977
|
+
product_ids?: undefined;
|
|
981
978
|
} | {
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
979
|
+
category_id?: undefined;
|
|
980
|
+
product_id: string;
|
|
981
|
+
product_ids?: undefined;
|
|
985
982
|
} | {
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
983
|
+
category_id?: undefined;
|
|
984
|
+
product_id?: undefined;
|
|
985
|
+
product_ids: string[];
|
|
989
986
|
} | {
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
987
|
+
category_id?: undefined;
|
|
988
|
+
product_id?: undefined;
|
|
989
|
+
product_ids?: undefined;
|
|
993
990
|
};
|
|
994
991
|
type FetchRecsOptions = {
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
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
|
-
|
|
1009
|
-
|
|
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
|
-
|
|
1009
|
+
displays: any[];
|
|
1013
1010
|
}>(t: Tenant | {
|
|
1014
|
-
|
|
1015
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
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
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
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
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
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
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
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
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
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
|
-
|
|
1146
|
-
|
|
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
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
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
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
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
|
-
|
|
1196
|
-
|
|
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
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
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
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
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">, {
|
|
1246
|
-
|
|
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
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
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
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
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, {
|
|
1266
|
-
|
|
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
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
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
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
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
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
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
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
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
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
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
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
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
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
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
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
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
|
-
|
|
1398
|
+
lazyfier: Lazyfier;
|
|
1456
1399
|
}
|
|
1457
1400
|
export class Amazing_Lazy_Slider extends Amazing_Slider {
|
|
1458
|
-
|
|
1401
|
+
constructor(options: Slider_Options, lazyfier_options?: Optional<ConstructorParameters<typeof Lazyfier>[0], "container">);
|
|
1459
1402
|
}
|
|
1460
1403
|
interface Pro_Slider_Options {
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
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
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
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
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1439
|
+
interface Document {
|
|
1440
|
+
_depict_modify: boolean | undefined;
|
|
1441
|
+
}
|
|
1493
1442
|
}
|
|
1494
1443
|
interface TemplateToolOptions {
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
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
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
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
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
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({
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
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
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
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, {
|
|
1596
|
-
|
|
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: ({
|
|
1600
|
-
|
|
1568
|
+
export const expandingContainer: ({
|
|
1569
|
+
duration
|
|
1570
|
+
}?: {
|
|
1571
|
+
duration?: number;
|
|
1601
1572
|
}) => {
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
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
|
-
|
|
1588
|
+
overrides: Record< /* Row: */number, /* Column: */number>;
|
|
1618
1589
|
};
|
|
1619
|
-
export type ColAtSize = /** [ <number of columns>, <min-width>, <max-width>, <spacing> ] */
|
|
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
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
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({
|
|
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
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
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>, {
|
|
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
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
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
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
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>, {
|
|
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
|
-
|
|
1728
|
-
|
|
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
|
-
|
|
1732
|
-
|
|
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
|
-
|
|
1740
|
-
|
|
1736
|
+
left: HTMLImageElement[];
|
|
1737
|
+
right: HTMLImageElement[];
|
|
1741
1738
|
};
|
|
1742
|
-
export function slider_dots_factory({
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
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
|
-
|
|
1750
|
-
|
|
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
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
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({
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1772
|
-
|
|
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
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1791
|
+
add_position_styling: boolean;
|
|
1792
|
+
scroll_bar_classes?: string[];
|
|
1793
|
+
scroll_container_classes?: string[];
|
|
1784
1794
|
}): {
|
|
1785
|
-
|
|
1786
|
-
|
|
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, {
|
|
1789
|
-
|
|
1790
|
-
|
|
1798
|
+
export function slider_snap_css(_t?: any, {
|
|
1799
|
+
snapEvery,
|
|
1800
|
+
align
|
|
1801
|
+
}?: {
|
|
1802
|
+
snapEvery?: number;
|
|
1803
|
+
align?: "center" | "start" | "end";
|
|
1791
1804
|
}): {
|
|
1792
|
-
|
|
1793
|
-
|
|
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
|
-
|
|
1798
|
-
|
|
1810
|
+
stepsize?: number;
|
|
1811
|
+
threshold?: number;
|
|
1799
1812
|
}): {
|
|
1800
|
-
|
|
1801
|
-
|
|
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({
|
|
1804
|
-
|
|
1816
|
+
export function slider_wraparound_factory({
|
|
1817
|
+
clones_per_side
|
|
1818
|
+
}?: {
|
|
1819
|
+
clones_per_side?: number | undefined;
|
|
1805
1820
|
}): {
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
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(
|
|
1834
|
+
export function javascript_media_query(
|
|
1835
|
+
// inspired by code in houdinisportswear modify script
|
|
1820
1836
|
query: string, handler: (e: MediaQueryListEvent | MediaQueryList | {
|
|
1821
|
-
|
|
1837
|
+
matches: false;
|
|
1822
1838
|
}) => void, initial_call?: boolean): {
|
|
1823
|
-
|
|
1839
|
+
remove(): void;
|
|
1824
1840
|
};
|
|
1825
1841
|
type RenderingFunction<T extends Display> = (...args: any[]) => Promise<{
|
|
1826
|
-
|
|
1827
|
-
|
|
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>({
|
|
1836
|
-
|
|
1837
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
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
|
-
|
|
1946
|
+
constructor(response_string: string, url: string, headers?: HeadersInit, override_options?: ResponseInit);
|
|
1928
1947
|
}
|
|
1929
1948
|
export type ShopifyItem = {
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1949
|
+
id: number;
|
|
1950
|
+
handle: string;
|
|
1951
|
+
quantity: number;
|
|
1952
|
+
url: string;
|
|
1934
1953
|
};
|
|
1935
1954
|
export type ShopifyError = {
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
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
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1965
|
+
type: "get_items";
|
|
1966
|
+
response: Promise<ShopifyItem[] | ShopifyError>;
|
|
1967
|
+
body?: object;
|
|
1949
1968
|
} | {
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1969
|
+
type: "add_items";
|
|
1970
|
+
response: Promise<ShopifyItem[] | ShopifyError>;
|
|
1971
|
+
body?: object;
|
|
1953
1972
|
} | {
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1973
|
+
type: "update_items";
|
|
1974
|
+
response: Promise<ShopifyItem[] | ShopifyError>;
|
|
1975
|
+
body?: object;
|
|
1957
1976
|
} | {
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1977
|
+
type: "change_items";
|
|
1978
|
+
response: Promise<ShopifyItem[] | ShopifyError>;
|
|
1979
|
+
body?: object;
|
|
1961
1980
|
} | {
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
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
|
-
|
|
2029
|
-
|
|
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({
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
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>({
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
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
|
-
|
|
2094
|
-
|
|
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
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
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
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
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>({
|
|
2133
|
-
|
|
2134
|
-
|
|
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
|
-
|
|
2244
|
+
class?: string;
|
|
2207
2245
|
};
|
|
2208
|
-
export function DefaultViewMoreButton({
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
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
|
-
|
|
2215
|
-
|
|
2259
|
+
close_: VoidFunction;
|
|
2260
|
+
on_close_: (fn: VoidFunction) => number;
|
|
2216
2261
|
}>;
|
|
2217
|
-
export function GeneralSizeSelector({
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
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
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
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
|
-
|
|
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: ({
|
|
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: ({
|
|
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
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
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
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
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({
|
|
2293
|
-
|
|
2294
|
-
|
|
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: ({
|
|
2302
|
-
|
|
2303
|
-
|
|
2368
|
+
export const useExpandingContainer: ({
|
|
2369
|
+
duration,
|
|
2370
|
+
delay
|
|
2371
|
+
}?: {
|
|
2372
|
+
duration?: number;
|
|
2373
|
+
delay?: number;
|
|
2304
2374
|
}) => {
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
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({
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2438
|
+
[key: string]: any;
|
|
2358
2439
|
}): string;
|
|
2359
2440
|
export interface ImageOptions extends Partial<HTMLImageElement> {
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
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: ({
|
|
2469
|
+
export const ContainedImage: ({
|
|
2470
|
+
init_with_placeholder,
|
|
2471
|
+
...options
|
|
2472
|
+
}: ImageOptions) => HTMLElement;
|
|
2389
2473
|
type HoverImageOptions = ImageOptions & {
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
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: ({
|
|
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
|
-
|
|
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
|
-
|
|
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;
|