@depict-ai/utilishared 0.0.39 → 0.0.41
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/dist/index.d.ts +228 -110
- package/dist/main.js +53 -43
- package/dist/module.js +53 -43
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export const set_browser_prefix: (str: any) => void;
|
|
|
8
8
|
export function dlog(...args: any[]): void;
|
|
9
9
|
export function dwarn(...args: any[]): void;
|
|
10
10
|
export function derror(...args: any[]): void;
|
|
11
|
+
export const version = "0.0.41";
|
|
11
12
|
/**
|
|
12
13
|
* @deprecated this was a stupid idea, it's much easier to read if one just does a quick arrow function that provides the wanted arguments
|
|
13
14
|
*/
|
|
@@ -103,7 +104,7 @@ export function err(exception: Error | any, error_for_stack?: Error): undefined;
|
|
|
103
104
|
export function is_available_in(obj: Object, property: PropertyKey, ...sub_objects_to_wait_for: PropertyKey[]): any;
|
|
104
105
|
export function find_descriptor(obj: Object, prop: PropertyKey): PropertyDescriptor | undefined;
|
|
105
106
|
export function variable_setter_to_ipns<T>(obj: Object, variable: PropertyKey, async_iterator_should_return_state_on_first_call?: boolean): IPNS<T>;
|
|
106
|
-
export const Sentry: {
|
|
107
|
+
export const Sentry: Hub | {
|
|
107
108
|
captureException: (...args: any[]) => void;
|
|
108
109
|
captureMessage: (...args: any[]) => void;
|
|
109
110
|
withScope: (...args: any[]) => void;
|
|
@@ -113,14 +114,22 @@ export const Sentry: {
|
|
|
113
114
|
* We can also send `log`, `info`, `debug`, `critical` and `fatal` but we haven't had a need for it yet.
|
|
114
115
|
*/
|
|
115
116
|
type Severity = "error" | "warning";
|
|
116
|
-
|
|
117
|
+
/**
|
|
118
|
+
* Wraps a function in a try/catch that sends the error to sentry.
|
|
119
|
+
* Also works for functions returning a promise/async functions.
|
|
120
|
+
* If the function threw the wrapped function will return `undefined`
|
|
121
|
+
* @param fn The function to wrap
|
|
122
|
+
* @param message The message of the sentry error
|
|
123
|
+
* @param severity The severity level to send to sentry
|
|
124
|
+
*/
|
|
125
|
+
export function catchify<T extends any[], X>(fn: (...args: T) => X, message?: string, severity?: Severity): (...args: T) => X extends Promise<any> ? Promise<undefined | Awaited<X>> : X | undefined;
|
|
117
126
|
/**
|
|
118
127
|
* Send error message with given severity and extra info to sentry
|
|
119
|
-
* @param msg Error object to send to sentry or an array containing an error and a human
|
|
128
|
+
* @param msg Error object to send to sentry or an array containing an error and a human-readable description for said error
|
|
120
129
|
* @param severity How severe the error is.
|
|
121
130
|
* - `"error"` - Things like not finding the market, unexpected product-id format. Even one of these errors is cause for concern.
|
|
122
131
|
* - `"warning"` - Things that we expect to happen _sometimes_, like network errors. A couple of them is normal,
|
|
123
|
-
* but if we
|
|
132
|
+
* but if we suddenly get 1000s then that's an issue
|
|
124
133
|
* @param input_data An object with extra information to sent to sentry.
|
|
125
134
|
*
|
|
126
135
|
* @example
|
|
@@ -146,11 +155,11 @@ export type AsyncFunction<A extends any[], O> = (...args: A) => Promise<O>;
|
|
|
146
155
|
* @param the_function an async function to wrap
|
|
147
156
|
* @return The same function but wrapped so that it can only run once at once, no matter how often you call it
|
|
148
157
|
*/
|
|
149
|
-
export function deparallelize<A extends any[], O>(the_function: AsyncFunction<A, O>): (...args: A) => Promise<O>;
|
|
158
|
+
export function deparallelize<A extends any[], O>(the_function: AsyncFunction<A, O>): (...args: A) => Promise<Awaited<O> | undefined>;
|
|
150
159
|
/**
|
|
151
160
|
* Like deparallelize but it makes sure that the last call of the function, while it's busy, will be executed after it's no longer busy.
|
|
152
161
|
*/
|
|
153
|
-
export function deparallelize_no_drop<A extends any[], O>(the_function: AsyncFunction<A, O>): (...args: A) => Promise<O>;
|
|
162
|
+
export function deparallelize_no_drop<A extends any[], O>(the_function: AsyncFunction<A, O>): (...args: A) => Promise<Awaited<O> | undefined>;
|
|
154
163
|
/**
|
|
155
164
|
* @deprecated use async_iterable_ipns instead. It has a nicer API and more of an ecosystem.
|
|
156
165
|
*/
|
|
@@ -208,18 +217,18 @@ type any_properties = {
|
|
|
208
217
|
};
|
|
209
218
|
export type noisy_depict_payload = (depict_body & any_properties)[];
|
|
210
219
|
export const filter_depict_payload: (payload: noisy_depict_payload) => depict_payload | undefined;
|
|
211
|
-
export const send_websocket: (bodies: depict_payload) => Promise<void>;
|
|
212
|
-
export const send_depict_unfiltered: (payload: depict_payload, use_ws?:
|
|
220
|
+
export const send_websocket: (bodies: depict_payload) => Promise<void | undefined>;
|
|
221
|
+
export const send_depict_unfiltered: (payload: depict_payload, use_ws?: any) => boolean | Promise<void | undefined> | undefined;
|
|
213
222
|
export const foolproof_send_beacon: (url: string, payload: {
|
|
214
223
|
[key: string]: any;
|
|
215
|
-
}) => boolean;
|
|
216
|
-
export const send_depict: (payload: noisy_depict_payload, use_ws?: boolean | undefined) => boolean | Promise<void> | undefined;
|
|
224
|
+
}) => boolean | undefined;
|
|
225
|
+
export const send_depict: (payload: noisy_depict_payload, use_ws?: boolean | undefined) => boolean | Promise<void | undefined> | undefined;
|
|
217
226
|
export let get_depict_id: () => string;
|
|
218
227
|
export let get_user_id: () => string;
|
|
219
228
|
export let get_session_id: () => string | undefined;
|
|
220
|
-
export const set_depict_id_fn: (newfn: () => string) => () => string;
|
|
221
|
-
export const set_user_id_fn: (newfn: () => string) => () => string;
|
|
222
|
-
export const set_session_id_fn: (newfn: () => string) => () => string;
|
|
229
|
+
export const set_depict_id_fn: (newfn: () => string) => (() => string) | undefined;
|
|
230
|
+
export const set_user_id_fn: (newfn: () => string) => (() => string) | undefined;
|
|
231
|
+
export const set_session_id_fn: (newfn: () => string) => (() => string) | undefined;
|
|
223
232
|
export type TrackingEventContextData = {
|
|
224
233
|
user_id: string;
|
|
225
234
|
dsid: string;
|
|
@@ -232,9 +241,90 @@ export const get_tracking_event_context_data: () => TrackingEventContextData;
|
|
|
232
241
|
/**
|
|
233
242
|
* Sends a depict tracking event with prefilled data
|
|
234
243
|
*/
|
|
235
|
-
export const depict_prefilled: (vars:
|
|
236
|
-
|
|
237
|
-
|
|
244
|
+
export const depict_prefilled: (vars: Partial<{
|
|
245
|
+
type: any;
|
|
246
|
+
detail: any;
|
|
247
|
+
url: any;
|
|
248
|
+
currency: any;
|
|
249
|
+
tenant: any;
|
|
250
|
+
market: any;
|
|
251
|
+
user_id: any;
|
|
252
|
+
session_id: any;
|
|
253
|
+
product_id: any;
|
|
254
|
+
entity_identifiers: any;
|
|
255
|
+
entity_price: any;
|
|
256
|
+
document_referrer: any;
|
|
257
|
+
document_width: any;
|
|
258
|
+
attribution_id: any;
|
|
259
|
+
recommendation_id: any;
|
|
260
|
+
click_location: any;
|
|
261
|
+
ab_test_group: any;
|
|
262
|
+
variant_ids: any;
|
|
263
|
+
dsid: any;
|
|
264
|
+
transaction_id: any;
|
|
265
|
+
error_type: any;
|
|
266
|
+
recommendation_type: any;
|
|
267
|
+
search_result_id: any;
|
|
268
|
+
product_listing_result_id: any;
|
|
269
|
+
}> & {
|
|
270
|
+
[key: string]: any;
|
|
271
|
+
}, use_ws?: boolean | undefined) => boolean | Promise<void | undefined> | undefined;
|
|
272
|
+
export const depict_click: (vars: Partial<{
|
|
273
|
+
type: any;
|
|
274
|
+
detail: any;
|
|
275
|
+
url: any;
|
|
276
|
+
currency: any;
|
|
277
|
+
tenant: any;
|
|
278
|
+
market: any;
|
|
279
|
+
user_id: any;
|
|
280
|
+
session_id: any;
|
|
281
|
+
product_id: any;
|
|
282
|
+
entity_identifiers: any;
|
|
283
|
+
entity_price: any;
|
|
284
|
+
document_referrer: any;
|
|
285
|
+
document_width: any;
|
|
286
|
+
attribution_id: any;
|
|
287
|
+
recommendation_id: any;
|
|
288
|
+
click_location: any;
|
|
289
|
+
ab_test_group: any;
|
|
290
|
+
variant_ids: any;
|
|
291
|
+
dsid: any;
|
|
292
|
+
transaction_id: any;
|
|
293
|
+
error_type: any;
|
|
294
|
+
recommendation_type: any;
|
|
295
|
+
search_result_id: any;
|
|
296
|
+
product_listing_result_id: any;
|
|
297
|
+
}> & {
|
|
298
|
+
[key: string]: any;
|
|
299
|
+
}) => boolean | Promise<void | undefined> | undefined;
|
|
300
|
+
export const depict_add_to_cart: (vars: Partial<{
|
|
301
|
+
type: any;
|
|
302
|
+
detail: any;
|
|
303
|
+
url: any;
|
|
304
|
+
currency: any;
|
|
305
|
+
tenant: any;
|
|
306
|
+
market: any;
|
|
307
|
+
user_id: any;
|
|
308
|
+
session_id: any;
|
|
309
|
+
product_id: any;
|
|
310
|
+
entity_identifiers: any;
|
|
311
|
+
entity_price: any;
|
|
312
|
+
document_referrer: any;
|
|
313
|
+
document_width: any;
|
|
314
|
+
attribution_id: any;
|
|
315
|
+
recommendation_id: any;
|
|
316
|
+
click_location: any;
|
|
317
|
+
ab_test_group: any;
|
|
318
|
+
variant_ids: any;
|
|
319
|
+
dsid: any;
|
|
320
|
+
transaction_id: any;
|
|
321
|
+
error_type: any;
|
|
322
|
+
recommendation_type: any;
|
|
323
|
+
search_result_id: any;
|
|
324
|
+
product_listing_result_id: any;
|
|
325
|
+
}> & {
|
|
326
|
+
[key: string]: any;
|
|
327
|
+
}) => boolean | Promise<void | undefined> | undefined;
|
|
238
328
|
export type ConsentObj = {
|
|
239
329
|
marketing: boolean;
|
|
240
330
|
necessary: boolean;
|
|
@@ -364,7 +454,7 @@ export function buildThresholdList(numSteps: number): number[];
|
|
|
364
454
|
/**
|
|
365
455
|
* A Post processor for Recommendation renderer to add impression tracking to all displays
|
|
366
456
|
*/
|
|
367
|
-
export const impression_tracking_post_processor: RR_PostProcessor
|
|
457
|
+
export const impression_tracking_post_processor: RR_PostProcessor<any>;
|
|
368
458
|
interface ImpressionTrackingOptions {
|
|
369
459
|
/** The element to observe for impressions. */
|
|
370
460
|
element: HTMLElement;
|
|
@@ -503,7 +593,7 @@ export function cookiebot_get_cookie_ipns(): IPNS<ConsentObj>;
|
|
|
503
593
|
*
|
|
504
594
|
* NOTE that this uses {@link set_depict_id_fn} to set {@link get_depict_id} and shouldn't be mixed with other uses of {@link set_depict_id_fn}.
|
|
505
595
|
*/
|
|
506
|
-
export const init_cookiebot_tracking: (anon_id?:
|
|
596
|
+
export const init_cookiebot_tracking: (anon_id?: any) => Promise<void | undefined>;
|
|
507
597
|
declare global {
|
|
508
598
|
interface Window {
|
|
509
599
|
Cookiebot?: {
|
|
@@ -667,21 +757,21 @@ export function optanon_get_cookie_ipns(): IPNS<ConsentObj>;
|
|
|
667
757
|
*
|
|
668
758
|
* NOTE that this uses {@link set_depict_id_fn} to set {@link get_depict_id} and shouldn't be mixed with other uses of {@link set_depict_id_fn}.
|
|
669
759
|
*/
|
|
670
|
-
export const init_optanon_tracking: (anon_id?:
|
|
671
|
-
export const load_gtag: (GA_ID: string, strict?: boolean | undefined) => Promise<void>;
|
|
672
|
-
export const setup_gtag: (GA_ID: string) => void;
|
|
673
|
-
export const gtag_view: (displays:
|
|
760
|
+
export const init_optanon_tracking: (anon_id?: any) => Promise<void | undefined>;
|
|
761
|
+
export const load_gtag: (GA_ID: string, strict?: boolean | undefined) => Promise<void | undefined>;
|
|
762
|
+
export const setup_gtag: (GA_ID: string) => void | undefined;
|
|
763
|
+
export const gtag_view: <T extends Display>(displays: T[], get_product_id: (url?: string | T | undefined) => string | Promise<string>, more?: {
|
|
674
764
|
[key: string]: any;
|
|
675
765
|
list_name?: string | undefined;
|
|
676
|
-
} | ((display:
|
|
766
|
+
} | ((display: T) => {
|
|
677
767
|
[key: string]: any;
|
|
678
|
-
}) | undefined) => Promise<void>;
|
|
768
|
+
}) | undefined) => Promise<void | undefined>;
|
|
679
769
|
export const gtag_click: (product_id: string | number, index: number, more?: object | undefined) => Promise<any>;
|
|
680
770
|
export const send_ga: (action: string) => any;
|
|
681
|
-
export const setup_ga: (GAID: string) => void;
|
|
771
|
+
export const setup_ga: (GAID: string) => void | undefined;
|
|
682
772
|
export const ga_rec_click: () => any;
|
|
683
773
|
export const ga_purchase_click: () => any;
|
|
684
|
-
export const insert_styling: (css: string) => Promise<void>;
|
|
774
|
+
export const insert_styling: (css: string) => Promise<void | undefined>;
|
|
685
775
|
/**
|
|
686
776
|
* A function meant to use to track the main add to cart button on the product page of an integration.
|
|
687
777
|
* * @param tenant instance of `Tenant` class
|
|
@@ -693,9 +783,9 @@ export const track_a2c: (tenant: Tenant, selector: string, validator?: ((e: Even
|
|
|
693
783
|
/**
|
|
694
784
|
* Basically a RecRendererResult with less strict typing
|
|
695
785
|
*/
|
|
696
|
-
export interface Surface {
|
|
786
|
+
export interface Surface<T extends Display> {
|
|
697
787
|
elements?: Node_Array;
|
|
698
|
-
displays?:
|
|
788
|
+
displays?: T[];
|
|
699
789
|
should_stay_inserted?: Promise<boolean>;
|
|
700
790
|
}
|
|
701
791
|
/**
|
|
@@ -711,7 +801,7 @@ export type InsertionVerb = "after" | "before" | "replaceWith" | "append" | "pre
|
|
|
711
801
|
* @param url The url to check, defaults to `window.location`
|
|
712
802
|
* @returns
|
|
713
803
|
*/
|
|
714
|
-
export const normal_get_product_id: (url?: string
|
|
804
|
+
export const normal_get_product_id: (url?: string) => string;
|
|
715
805
|
declare global {
|
|
716
806
|
interface Document {
|
|
717
807
|
depictwashere: boolean;
|
|
@@ -765,7 +855,7 @@ export interface Tenant<ProductId extends IdType> {
|
|
|
765
855
|
debug: boolean;
|
|
766
856
|
dlog: typeof dlog;
|
|
767
857
|
Sentry: typeof Sentry;
|
|
768
|
-
catchify:
|
|
858
|
+
catchify: typeof catchify;
|
|
769
859
|
err: (...errors: any[]) => undefined;
|
|
770
860
|
}
|
|
771
861
|
/**
|
|
@@ -836,9 +926,9 @@ export const AIO: (options: {
|
|
|
836
926
|
list_name?: string | undefined;
|
|
837
927
|
} | undefined) => Promise<{
|
|
838
928
|
add_a2c_element: (element: HTMLElement) => void;
|
|
839
|
-
add_product_element: (element: HTMLElement) => Promise<void>;
|
|
840
|
-
}>;
|
|
841
|
-
export const paint_red: (element: HTMLElement) => void;
|
|
929
|
+
add_product_element: (element: HTMLElement) => Promise<void | undefined>;
|
|
930
|
+
} | undefined>;
|
|
931
|
+
export const paint_red: (element: HTMLElement) => void | undefined;
|
|
842
932
|
/**
|
|
843
933
|
* A function that attempts to "serialize" an object to a text representation that helps with debugging when using sentry
|
|
844
934
|
* @param anything Something to try to serialize - this function is crappy and your mileage may vary
|
|
@@ -886,7 +976,7 @@ type FetchRecsOptions = {
|
|
|
886
976
|
*
|
|
887
977
|
* Formerly called get_displays
|
|
888
978
|
*/
|
|
889
|
-
export function fetch_recs<T = Display>(t: Tenant | {
|
|
979
|
+
export function fetch_recs<T extends Display = Display>(t: Tenant | {
|
|
890
980
|
market: string;
|
|
891
981
|
tenant: string;
|
|
892
982
|
}, options: FetchRecsOptions, headers?: HeadersInit, get_url?: typeof default_get_fetch_url): Promise<T[]>;
|
|
@@ -907,23 +997,23 @@ export function querySelectorAllElements<T extends Element>(elements: Node_Itera
|
|
|
907
997
|
export function standard_price_format(price: number, places_after_comma?: number | "auto", decimal_delimiter?: string, thousands_delimiter?: string): string;
|
|
908
998
|
export function intl_number_format_with_fallback(bcp47_country_code: string, number: number, numberformat_options?: Parameters<typeof Intl.NumberFormat>[1]): string;
|
|
909
999
|
export function ensure_object_path(obj: object, step1: string, ...path: string[]): any;
|
|
910
|
-
export function Rec_Renderer(t: Tenant, rendering_options: RR_Options): Promise<RecRendererResult
|
|
1000
|
+
export function Rec_Renderer<T extends Display>(t: Tenant, rendering_options: RR_Options<T>): Promise<RecRendererResult<T>>;
|
|
911
1001
|
export function regex_templating(template: string, display?: Display | {
|
|
912
1002
|
[key: string]: any;
|
|
913
1003
|
}): string;
|
|
914
1004
|
export function clone_deep<T>(obj: T): T;
|
|
915
|
-
export class InfoForProcessing {
|
|
916
|
-
constructor(t: Tenant, rendering_options: RR_Options
|
|
1005
|
+
export class InfoForProcessing<T extends Display> {
|
|
1006
|
+
constructor(t: Tenant, rendering_options: RR_Options<T>, displays: T[], index?: number, remove_display?: () => void, event_listeners?: [
|
|
917
1007
|
type: keyof HTMLElementEventMap,
|
|
918
1008
|
listener: (this: HTMLElement, ev: HTMLElementEventMap[keyof HTMLElementEventMap]) => any,
|
|
919
1009
|
options?: boolean | AddEventListenerOptions
|
|
920
1010
|
][]);
|
|
921
1011
|
}
|
|
922
1012
|
type RegisterEventListener = (type: keyof HTMLElementEventMap, listener: (this: HTMLElement, ev: HTMLElementEventMap[keyof HTMLElementEventMap]) => any, options?: boolean | AddEventListenerOptions) => void;
|
|
923
|
-
export interface InfoForProcessing {
|
|
1013
|
+
export interface InfoForProcessing<T extends Display> {
|
|
924
1014
|
t: Tenant;
|
|
925
|
-
rendering_options: RR_Options
|
|
926
|
-
displays:
|
|
1015
|
+
rendering_options: RR_Options<T>;
|
|
1016
|
+
displays: T[];
|
|
927
1017
|
index: number;
|
|
928
1018
|
remove_display?: () => void;
|
|
929
1019
|
register_event_listener: RegisterEventListener;
|
|
@@ -936,11 +1026,11 @@ export interface InfoForProcessing {
|
|
|
936
1026
|
[key: string]: any;
|
|
937
1027
|
};
|
|
938
1028
|
}
|
|
939
|
-
export type RR_PreProcessor = (display:
|
|
940
|
-
export type RR_PostProcessor = (elements: NodeListOf<ChildNode> | Node_Array, display:
|
|
941
|
-
export type RR_Options = {
|
|
942
|
-
template: string | ((arg0:
|
|
943
|
-
recs?:
|
|
1029
|
+
export type RR_PreProcessor<T extends Display> = (display: T, info: InfoForProcessing<T>) => Promise<T> | T;
|
|
1030
|
+
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;
|
|
1031
|
+
export type RR_Options<T extends Display> = {
|
|
1032
|
+
template: string | ((arg0: T, info: InfoForProcessing<T>) => Promise<string | Node_Array> | string | Node_Array);
|
|
1033
|
+
recs?: T[] | undefined | Promise<T[] | undefined>;
|
|
944
1034
|
type: string;
|
|
945
1035
|
min_items_to_report?: number;
|
|
946
1036
|
min_items_to_run?: number;
|
|
@@ -948,8 +1038,8 @@ export type RR_Options = {
|
|
|
948
1038
|
extra_api_options?: {
|
|
949
1039
|
[key: string]: any;
|
|
950
1040
|
};
|
|
951
|
-
pre_processors?: RR_PreProcessor[];
|
|
952
|
-
post_processors?: RR_PostProcessor[];
|
|
1041
|
+
pre_processors?: RR_PreProcessor<T>[];
|
|
1042
|
+
post_processors?: RR_PostProcessor<T>[];
|
|
953
1043
|
headers?: HeadersInit;
|
|
954
1044
|
} & FetchRecsOptions;
|
|
955
1045
|
/**
|
|
@@ -959,7 +1049,7 @@ export interface Display {
|
|
|
959
1049
|
/**
|
|
960
1050
|
* The URL of the product page.
|
|
961
1051
|
*/
|
|
962
|
-
page_url:
|
|
1052
|
+
page_url: any;
|
|
963
1053
|
/**
|
|
964
1054
|
* The URL of the product image.
|
|
965
1055
|
*/
|
|
@@ -986,11 +1076,11 @@ export interface Display {
|
|
|
986
1076
|
}
|
|
987
1077
|
export type Node_Iterable = HTMLCollection | NodeListOf<ChildNode> | Node_Array;
|
|
988
1078
|
export type Node_Array = (Element | Text | Comment)[];
|
|
989
|
-
export type RecRendererResult = Record<string, never> | {
|
|
1079
|
+
export type RecRendererResult<T extends Display> = Record<string, never> | {
|
|
990
1080
|
elements: Node_Array;
|
|
991
|
-
displays:
|
|
1081
|
+
displays: T[];
|
|
992
1082
|
};
|
|
993
|
-
export const check_displays: (
|
|
1083
|
+
export const check_displays: (args_0: {
|
|
994
1084
|
recs: Display[] | {
|
|
995
1085
|
displays: Display[];
|
|
996
1086
|
} | Promise<Display[] | {
|
|
@@ -999,29 +1089,29 @@ export const check_displays: ({ recs, min_recs, market, type, product_id, tenant
|
|
|
999
1089
|
min_recs?: number | undefined;
|
|
1000
1090
|
market: string;
|
|
1001
1091
|
type: string;
|
|
1002
|
-
product_id: string | string[] | Promise<string> | Promise<string[]> | ((arg0?: string
|
|
1092
|
+
product_id: string | string[] | Promise<string> | Promise<string[]> | ((arg0?: string) => string | string[] | Promise<string> | Promise<string[]>) | undefined;
|
|
1003
1093
|
tenant: string;
|
|
1004
1094
|
}) => Promise<boolean | undefined>;
|
|
1005
1095
|
/**
|
|
1006
1096
|
* @deprecated You should no longer need to use this. Use observer.onexists to add an event listener to an element once it exists.
|
|
1007
1097
|
*/
|
|
1008
1098
|
export function require_event_listener(element: Node, event: string, track_id: any, func: EventListenerOrEventListenerObject): void;
|
|
1009
|
-
export const default_view_tracking: RR_PostProcessor[];
|
|
1010
|
-
export const default_click_tracking: (typeof add_new_tab_listener)[];
|
|
1011
|
-
export function recs_inserted_tracking(elements: NodeListOf<ChildNode
|
|
1012
|
-
export function gtag_view_post_processor(elements: NodeListOf<ChildNode
|
|
1013
|
-
export function depict_page_view(elements: NodeListOf<ChildNode
|
|
1014
|
-
export function gtag_click_post_processor(elements: NodeListOf<ChildNode
|
|
1015
|
-
export function depict_click_tracking_post_processor(elements: NodeListOf<ChildNode
|
|
1016
|
-
export function add_to_localstorage(elements: NodeListOf<ChildNode
|
|
1017
|
-
export function ga_click(elements: NodeListOf<ChildNode
|
|
1099
|
+
export const default_view_tracking: (RR_PostProcessor<any> | typeof depict_page_view)[];
|
|
1100
|
+
export const default_click_tracking: (typeof depict_click_tracking_post_processor | typeof add_new_tab_listener)[];
|
|
1101
|
+
export function recs_inserted_tracking<T extends Display>(elements: NodeListOf<ChildNode> | Node_Array, _display: Display, info: InfoForProcessing<T>): NodeListOf<ChildNode> | Node_Array;
|
|
1102
|
+
export function gtag_view_post_processor<T extends Display>(elements: NodeListOf<ChildNode> | Node_Array, _display: Display, info: InfoForProcessing<T>): NodeListOf<ChildNode> | Node_Array;
|
|
1103
|
+
export function depict_page_view<T extends Display>(elements: NodeListOf<ChildNode> | Node_Array, _display: Display, info: InfoForProcessing<T>): NodeListOf<ChildNode> | Node_Array;
|
|
1104
|
+
export function gtag_click_post_processor<T extends Display>(elements: NodeListOf<ChildNode> | Node_Array, display: Display, info: InfoForProcessing<T>): NodeListOf<ChildNode> | Node_Array;
|
|
1105
|
+
export function depict_click_tracking_post_processor<T extends Display>(elements: NodeListOf<ChildNode> | Node_Array, display: Display, info: InfoForProcessing<T>): NodeListOf<ChildNode> | Node_Array;
|
|
1106
|
+
export function add_to_localstorage<T extends Display>(elements: NodeListOf<ChildNode> | Node_Array, display: Display, info: InfoForProcessing<T>): NodeListOf<ChildNode> | Node_Array;
|
|
1107
|
+
export function ga_click<T extends Display>(elements: NodeListOf<ChildNode> | Node_Array, display: Display, info: InfoForProcessing<T>): NodeListOf<ChildNode> | Node_Array;
|
|
1018
1108
|
export const should_colorizeLogics: boolean;
|
|
1019
|
-
export function colorize_elements(elements: NodeListOf<ChildNode
|
|
1020
|
-
type Extended_RR_Options = {
|
|
1021
|
-
view_tracking?: RR_PostProcessor[];
|
|
1022
|
-
click_tracking?: RR_PostProcessor[];
|
|
1023
|
-
} & RR_Options
|
|
1024
|
-
export function default_rr(t: Tenant, rendering_options: Extended_RR_Options): Promise<RecRendererResult
|
|
1109
|
+
export function colorize_elements(elements: NodeListOf<ChildNode> | Node_Array, display: Display): NodeListOf<ChildNode> | Node_Array;
|
|
1110
|
+
type Extended_RR_Options<T extends Display> = {
|
|
1111
|
+
view_tracking?: RR_PostProcessor<T>[];
|
|
1112
|
+
click_tracking?: RR_PostProcessor<T>[];
|
|
1113
|
+
} & RR_Options<T>;
|
|
1114
|
+
export function default_rr<T extends Display>(t: Tenant, rendering_options: Extended_RR_Options<T>): Promise<RecRendererResult<T>>;
|
|
1025
1115
|
type GWVM_Options = {
|
|
1026
1116
|
container_selector?: string;
|
|
1027
1117
|
start_rows?: number;
|
|
@@ -1035,7 +1125,7 @@ type GWVM_Options = {
|
|
|
1035
1125
|
only_full_rows?: boolean;
|
|
1036
1126
|
should_preload?: boolean;
|
|
1037
1127
|
};
|
|
1038
|
-
interface GWVM_InfoForProcessing extends InfoForProcessing {
|
|
1128
|
+
interface GWVM_InfoForProcessing<T extends Display> extends InfoForProcessing<T> {
|
|
1039
1129
|
extras: {
|
|
1040
1130
|
[key: string]: any;
|
|
1041
1131
|
load_more_currently_showing: number;
|
|
@@ -1055,7 +1145,7 @@ type GWVM_RR_Options = Extended_RR_Options & {
|
|
|
1055
1145
|
*/
|
|
1056
1146
|
export function GWVM_Renderer(t: Tenant, options: GWVM_RR_Options, GWVM_opts: GWVM_Options): Promise<{
|
|
1057
1147
|
elements?: ChildNode[] | undefined;
|
|
1058
|
-
load_more?: ((num?: number | Event
|
|
1148
|
+
load_more?: ((num?: number | Event) => void) | undefined;
|
|
1059
1149
|
displays?: Display[] | undefined;
|
|
1060
1150
|
}>;
|
|
1061
1151
|
/**
|
|
@@ -1072,7 +1162,7 @@ export function Auto_GWVM(t: Tenant, options: GWVM_RR_Options, GWVM_opts: Omit<G
|
|
|
1072
1162
|
rec_selector?: string;
|
|
1073
1163
|
}): Promise<{
|
|
1074
1164
|
elements?: Node_Array | undefined;
|
|
1075
|
-
load_more?: ((num?: number | Event
|
|
1165
|
+
load_more?: ((num?: number | Event) => void) | undefined;
|
|
1076
1166
|
displays?: Display[] | undefined;
|
|
1077
1167
|
}>;
|
|
1078
1168
|
/**
|
|
@@ -1293,7 +1383,7 @@ interface Pro_Slider_Options {
|
|
|
1293
1383
|
/**
|
|
1294
1384
|
* @deprecated please use RecommendationSlider instead
|
|
1295
1385
|
*/
|
|
1296
|
-
export function Pro_Slider(t: Tenant, rendering_options: Extended_RR_Options
|
|
1386
|
+
export function Pro_Slider<T extends Display>(t: Tenant, rendering_options: Extended_RR_Options<T>, options_for_us?: Pro_Slider_Options, slider_options?: Slider_Options): ReturnType<typeof Rec_Renderer>;
|
|
1297
1387
|
/**
|
|
1298
1388
|
* @deprecated Please use recommendation renderer instead
|
|
1299
1389
|
*/
|
|
@@ -1307,8 +1397,8 @@ export class Depict {
|
|
|
1307
1397
|
loadRecommendations(callback: any): void;
|
|
1308
1398
|
trackGAEvent(action: any, index: any, product_id: any, ga_product_ids?: string[]): void;
|
|
1309
1399
|
trackPageView(): void;
|
|
1310
|
-
trackClick(index: any): boolean | Promise<void> | undefined;
|
|
1311
|
-
trackAddToCart(pId: any): boolean | Promise<void> | undefined;
|
|
1400
|
+
trackClick(index: any): boolean | Promise<void | undefined> | undefined;
|
|
1401
|
+
trackAddToCart(pId: any): boolean | Promise<void | undefined> | undefined;
|
|
1312
1402
|
createContainer(root: any, container: any, prepend?: boolean): void;
|
|
1313
1403
|
renderTemplate({ prep, root, template, itemPreprocessor, itemPostprocessor }?: any): void;
|
|
1314
1404
|
}
|
|
@@ -1331,6 +1421,9 @@ interface TemplateToolOptions {
|
|
|
1331
1421
|
tenant?: string;
|
|
1332
1422
|
market?: string;
|
|
1333
1423
|
}
|
|
1424
|
+
/**
|
|
1425
|
+
* @deprecated Please use RecommendationRenderer instead
|
|
1426
|
+
*/
|
|
1334
1427
|
export const simplified_template_tool: (options: {
|
|
1335
1428
|
options: TemplateToolOptions;
|
|
1336
1429
|
recs?: object[] | undefined;
|
|
@@ -1369,7 +1462,7 @@ interface RR_Slider_Options {
|
|
|
1369
1462
|
/**
|
|
1370
1463
|
* @deprecated please use Pro_Slider instead
|
|
1371
1464
|
*/
|
|
1372
|
-
export function RR_Slider(t: Tenant, rendering_options: Extended_RR_Options
|
|
1465
|
+
export function RR_Slider<T extends Display>(t: Tenant, rendering_options: Extended_RR_Options<T>, options_for_us?: RR_Slider_Options, slider_options?: Deprecated_Slider_Options, override_lazyfier_options?: special_lazyfier_options): ReturnType<typeof Rec_Renderer>;
|
|
1373
1466
|
type PreProcessor = (tenant: Tenant, display: any, i?: number, with_loadmore?: boolean, with_slider?: boolean, infinite_scroll?: boolean) => any;
|
|
1374
1467
|
type PostProcessor = (tenant: Tenant, items: HTMLCollection, display: any, slider?: Deprecated_Amazing_Slider) => HTMLCollection;
|
|
1375
1468
|
/**
|
|
@@ -1395,9 +1488,18 @@ chunk_size_for_load_more, insertion_promise, }: {
|
|
|
1395
1488
|
}): Promise<ChildNode[] | void>;
|
|
1396
1489
|
export function default_pre_processor(_t: any, d: any, i: number, with_loadmore: boolean, with_slider: boolean, infinite_scroll: boolean): any;
|
|
1397
1490
|
export function default_post_processor(_t: any, itms: HTMLCollection, d: any, slider: Deprecated_Amazing_Slider | null): HTMLCollection;
|
|
1398
|
-
|
|
1491
|
+
/**
|
|
1492
|
+
* @deprecated please use `fetch_retry()` instead
|
|
1493
|
+
*
|
|
1494
|
+
* Windows proof fetch factory: windows proof fetch is a utility which retries fetch requests 10 times when they fail. Reason for this is a certain windows 10 build where the network stack randomly breaks 20% of https connections
|
|
1495
|
+
* (Note: this thing really should be rewritten with exponential backoff and a better API)
|
|
1496
|
+
* @param dlog logging function to use
|
|
1497
|
+
* @param error_log an array to which errors will be pushed
|
|
1498
|
+
* @return a windows proof fetch function
|
|
1499
|
+
*/
|
|
1500
|
+
export const wpff: (dlog: any, error_log?: any[]) => (url: RequestInfo, body: BodyInit, headers?: HeadersInit, decode_json?: boolean, fetch_options?: RequestInit, attempt?: number) => any;
|
|
1399
1501
|
export const use_element: <E extends HTMLOrSVGElement = HTMLElement>(callback: (element: E) => void, element: E) => E;
|
|
1400
|
-
export
|
|
1502
|
+
export function use_listener<K extends keyof GlobalEventHandlersEventMap, E extends HTMLElement = HTMLElement>(event: K, handler: (this: GlobalEventHandlers, ev: GlobalEventHandlersEventMap[K]) => any, element: E): E;
|
|
1401
1503
|
export const classlist: (classes: (string | undefined)[]) => string;
|
|
1402
1504
|
type Props = {
|
|
1403
1505
|
children: Elem[] | Elem;
|
|
@@ -1466,10 +1568,10 @@ export function Layout({ rows, container_element, cols_at_size, grid_spacing, la
|
|
|
1466
1568
|
* @return String of generated CSS
|
|
1467
1569
|
*/
|
|
1468
1570
|
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;
|
|
1469
|
-
export interface RecommendationGridOptions extends Omit<LayoutOptions, "container_element" | "layout"> {
|
|
1571
|
+
export interface RecommendationGridOptions<T extends Display> extends Omit<LayoutOptions, "container_element" | "layout"> {
|
|
1470
1572
|
container_elements: Node_Array;
|
|
1471
1573
|
container_selector?: string;
|
|
1472
|
-
override_rec_renderer?: typeof default_rr
|
|
1574
|
+
override_rec_renderer?: typeof default_rr<T>;
|
|
1473
1575
|
lazyfier_options?: Omit<Lazyfier_Options, "t">;
|
|
1474
1576
|
eager_images?: boolean;
|
|
1475
1577
|
}
|
|
@@ -1485,15 +1587,15 @@ export interface RecommendationGridOptions extends Omit<LayoutOptions, "containe
|
|
|
1485
1587
|
* @param ...options_for_grid Options for Grid. See documentation of Grid.
|
|
1486
1588
|
* @constructor
|
|
1487
1589
|
*/
|
|
1488
|
-
export function RecommendationGrid(t: Tenant, recommendation_renderer_options: Extended_RR_Options
|
|
1489
|
-
export interface EasySliderOptions extends Omit<LayoutOptions, "container_element" | "rows" | "layout"> {
|
|
1590
|
+
export function RecommendationGrid<T extends Display>(t: Tenant, recommendation_renderer_options: Extended_RR_Options<T>, { container_elements, container_selector, override_rec_renderer, lazyfier_options, eager_images, ...options_for_grid }: RecommendationGridOptions<T>): Promise<RecRendererResult<T>>;
|
|
1591
|
+
export interface EasySliderOptions<T extends Display> extends Omit<LayoutOptions, "container_element" | "rows" | "layout"> {
|
|
1490
1592
|
rows?: {
|
|
1491
1593
|
start_rows?: number;
|
|
1492
1594
|
ipns?: IPNS<number>;
|
|
1493
1595
|
} | "all";
|
|
1494
1596
|
container_elements: Node_Array;
|
|
1495
1597
|
container_selector?: string;
|
|
1496
|
-
override_rec_renderer?: typeof default_rr
|
|
1598
|
+
override_rec_renderer?: typeof default_rr<T>;
|
|
1497
1599
|
lazyfier_options?: Omit<Lazyfier_Options, "t">;
|
|
1498
1600
|
eager_images?: boolean;
|
|
1499
1601
|
dist_to_hide_left?: number;
|
|
@@ -1512,10 +1614,10 @@ export interface EasySliderOptions extends Omit<LayoutOptions, "container_elemen
|
|
|
1512
1614
|
};
|
|
1513
1615
|
override_vertical_spacing?: string;
|
|
1514
1616
|
}
|
|
1515
|
-
export type RecommendationSliderSurface = Record<string, never> | {
|
|
1617
|
+
export type RecommendationSliderSurface<T extends Display> = Record<string, never> | {
|
|
1516
1618
|
elements: Node_Array;
|
|
1517
1619
|
slider: Amazing_Slider | Amazing_Lazy_Slider;
|
|
1518
|
-
displays:
|
|
1620
|
+
displays: T[];
|
|
1519
1621
|
};
|
|
1520
1622
|
/**
|
|
1521
1623
|
*
|
|
@@ -1525,7 +1627,7 @@ export type RecommendationSliderSurface = Record<string, never> | {
|
|
|
1525
1627
|
* @param RecommendationGrid_options Similar options object to RecommendationGrid except that it also contains options to Amazing_Slider
|
|
1526
1628
|
* @return a Surface (object) that contains displays, elements and the instance of the slider class (as `slider`)
|
|
1527
1629
|
*/
|
|
1528
|
-
export function RecommendationSlider(t: Tenant, recommendation_renderer_options: Extended_RR_Options
|
|
1630
|
+
export function RecommendationSlider<T extends Display>(t: Tenant, recommendation_renderer_options: Extended_RR_Options<T>, { container_elements, container_selector, override_rec_renderer, lazyfier_options, eager_images, grid_spacing, cols_at_size, override_vertical_spacing, rows, ...slider_options }: EasySliderOptions<T>): Promise<RecommendationSliderSurface<T> | RecRendererResult<T> | Surface<T>>;
|
|
1529
1631
|
export function slider_autoscroll_factory(interval?: number): {
|
|
1530
1632
|
constructor_plugin(this: Amazing_Slider): void;
|
|
1531
1633
|
mutation_plugin: (this: Amazing_Slider, _intersections: IntersectionObserverEntry[], intersecting_mutations: Record<number, IntersectionObserverEntry>) => void;
|
|
@@ -1600,15 +1702,15 @@ export function slider_snapping_factory(options?: {
|
|
|
1600
1702
|
stepsize?: number;
|
|
1601
1703
|
threshold?: number;
|
|
1602
1704
|
}): {
|
|
1603
|
-
constructor_plugin: (slider_options: any) => void;
|
|
1604
|
-
mutation_plugin: (intersections: IntersectionObserverEntry[], intersecting_mutations: Record<number, IntersectionObserverEntry>) => void;
|
|
1705
|
+
constructor_plugin: (slider_options: any) => void | undefined;
|
|
1706
|
+
mutation_plugin: (intersections: IntersectionObserverEntry[], intersecting_mutations: Record<number, IntersectionObserverEntry>) => void | undefined;
|
|
1605
1707
|
};
|
|
1606
1708
|
export function slider_wraparound_factory({ clones_per_side }?: {
|
|
1607
1709
|
clones_per_side?: number | undefined;
|
|
1608
1710
|
}): {
|
|
1609
1711
|
constructor_plugin: (this: Amazing_Slider) => void;
|
|
1610
1712
|
mutation_plugin: (this: Amazing_Slider, intersections: IntersectionObserverEntry[], intersecting_mutations: Record<number, IntersectionObserverEntry>) => void;
|
|
1611
|
-
post_processor: (elements: Node_Array
|
|
1713
|
+
post_processor: <T extends Display>(elements: Node_Array | NodeListOf<ChildNode>, _display: Display, info: InfoForProcessing<T>) => Promise<NodeListOf<ChildNode> | Node_Array>;
|
|
1612
1714
|
};
|
|
1613
1715
|
export type ReactiveTemplateValueContents = string | number | Node_Array[number] | undefined | (string | number | Node_Array[number])[];
|
|
1614
1716
|
export function reactive_template(initial_value?: ReactiveTemplateValueContents): readonly [Node_Array, () => ReactiveTemplateValueContents, (arg0: ReactiveTemplateValueContents) => void];
|
|
@@ -1616,8 +1718,8 @@ export function javascript_media_query(// inspired by code in houdinisportswear
|
|
|
1616
1718
|
query: string, handler: (e: MediaQueryListEvent | MediaQueryList) => void, initial_call?: boolean): {
|
|
1617
1719
|
remove(): void;
|
|
1618
1720
|
};
|
|
1619
|
-
type RenderingFunction = (...args: any[]) => Promise<{
|
|
1620
|
-
surface_: Surface | void;
|
|
1721
|
+
type RenderingFunction<T extends Display> = (...args: any[]) => Promise<{
|
|
1722
|
+
surface_: Surface<T> | void;
|
|
1621
1723
|
cache_until_?: Promise<any>;
|
|
1622
1724
|
}>;
|
|
1623
1725
|
/**
|
|
@@ -1626,10 +1728,10 @@ type RenderingFunction = (...args: any[]) => Promise<{
|
|
|
1626
1728
|
* @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_.
|
|
1627
1729
|
* @return a `Surface` object which, utilising a `reactive_template` always represents the currently chosen surface
|
|
1628
1730
|
*/
|
|
1629
|
-
export function surface_mixer({ surface_rendering_functions_, current_surface_, }: {
|
|
1630
|
-
surface_rendering_functions_: RenderingFunction[];
|
|
1731
|
+
export function surface_mixer<T extends Display>({ surface_rendering_functions_, current_surface_, }: {
|
|
1732
|
+
surface_rendering_functions_: RenderingFunction<T>[];
|
|
1631
1733
|
current_surface_: IPNS<number>;
|
|
1632
|
-
}): Promise<Surface
|
|
1734
|
+
}): Promise<Surface<T>>;
|
|
1633
1735
|
/**
|
|
1634
1736
|
* To be used in conjunction with surface_mixer. Makes it possible to switch Surface depending on screen size
|
|
1635
1737
|
* @param surface_per_size An array of arrays which represent which surface to show at which screen width. The arrays in the array can have up to three entries, the first one being: an index in the surface_rendering_functions_ array passed to `surface_mixer`, the second one: min screen width to switch to this surface, the third one: max screen width at which this surface should still be shown.
|
|
@@ -1649,7 +1751,7 @@ export function orderpage_transaction_id_extractor(t: Tenant, selector: string,
|
|
|
1649
1751
|
* @param id_extractor Maps an entry to a transaction ID string, or something falsy if no transaction ID is found.
|
|
1650
1752
|
* For example: entry => entry?.event?.purchase?.orderId
|
|
1651
1753
|
*/
|
|
1652
|
-
export function datalayer_transaction_id_extractor(tenant: Tenant, id_extractor: (layer_entry: any) =>
|
|
1754
|
+
export function datalayer_transaction_id_extractor(tenant: Tenant, id_extractor: (layer_entry: any) => any): void;
|
|
1653
1755
|
/**
|
|
1654
1756
|
* Looks at all URL changes, including the current URL, and attempts to find transaction IDs in them.
|
|
1655
1757
|
* Any transaction IDs found will automatically be sent to Depict's tracking for the given tenant.
|
|
@@ -1688,7 +1790,7 @@ export class ListenableSet<T> extends Set<T> {
|
|
|
1688
1790
|
export function chaotic_closest(element: Element, selector: string, start_right?: boolean): Element | undefined;
|
|
1689
1791
|
type CompareMethod<T> = (i1: T, i2: T) => boolean;
|
|
1690
1792
|
export const deduplicate: <T>(arr1: T[], arr2: T[], compareFunc: CompareMethod<T>) => T[];
|
|
1691
|
-
export const dedup_products: (arr1:
|
|
1793
|
+
export const dedup_products: <T extends Display>(arr1: T[], arr2: T[] | undefined) => T[];
|
|
1692
1794
|
/**
|
|
1693
1795
|
* Attempt to navigate using nextjs's spa router.
|
|
1694
1796
|
* Falls back to default browser navigation.
|
|
@@ -1864,7 +1966,7 @@ export function iterable_to_elems(async_iterable: AsyncIterable<ReactiveTemplate
|
|
|
1864
1966
|
* @param ...args Any arguments that will also be passed on to the wrapped function. If the wrapped function takes an ElementObserverEvent the disconnector on it will also be called if a context should be "stopped";
|
|
1865
1967
|
* @return A wrapped function that now executes in a context
|
|
1866
1968
|
*/
|
|
1867
|
-
export const prevent_infinite_loop: <A, B>(cb: (...args: A
|
|
1969
|
+
export const prevent_infinite_loop: <A extends any[], B>(cb: (...args: A) => void | B) => (...args: A) => void | B;
|
|
1868
1970
|
/**
|
|
1869
1971
|
* Inserts one or multiple surfaces into the DOM.
|
|
1870
1972
|
* Will also revert (if verb is `replaceWith`) or remove the inserted elements again if placeholder rendering fails. This happens by a promise inside of the `Surface`s
|
|
@@ -1876,26 +1978,39 @@ export const prevent_infinite_loop: <A, B>(cb: (...args: A[]) => void | B) => (.
|
|
|
1876
1978
|
* @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
|
|
1877
1979
|
* @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
|
|
1878
1980
|
*/
|
|
1879
|
-
export function insert_surfaces({ surfaces: input_surfaces, verb, target, remove_after_navigation, try_forever, preserve_elements, }: {
|
|
1981
|
+
export function insert_surfaces<T extends Display>({ surfaces: input_surfaces, verb, target, remove_after_navigation, try_forever, preserve_elements, }: {
|
|
1880
1982
|
verb: InsertionVerb;
|
|
1881
1983
|
target: string | HTMLElement;
|
|
1882
1984
|
remove_after_navigation?: boolean;
|
|
1883
1985
|
try_forever?: boolean;
|
|
1884
|
-
surfaces: (Promise<Surface | void> | Surface | void)[];
|
|
1986
|
+
surfaces: (Promise<Surface<T> | void> | Surface<T> | void)[];
|
|
1885
1987
|
preserve_elements?: boolean;
|
|
1886
1988
|
}): Promise<{
|
|
1887
|
-
surface: Surface
|
|
1989
|
+
surface: Surface<T>;
|
|
1888
1990
|
succeeded: boolean;
|
|
1889
1991
|
}>[];
|
|
1890
|
-
export const revertable_remove: (target:
|
|
1891
|
-
type MakePlaceholderRROption = {
|
|
1892
|
-
override_rec_renderer?: (t: Tenant, rendering_options: Extended_RR_Options) => Promise<RecRendererResult
|
|
1992
|
+
export const revertable_remove: (target: string | Element | Node_Array, should_stay_inserted: Promise<boolean>) => Promise<void | undefined>;
|
|
1993
|
+
type MakePlaceholderRROption<T extends Display> = {
|
|
1994
|
+
override_rec_renderer?: (t: Tenant, rendering_options: Extended_RR_Options<T>) => Promise<RecRendererResult<T>>;
|
|
1893
1995
|
image_width?: number;
|
|
1894
1996
|
image_height?: number;
|
|
1895
1997
|
color?: string;
|
|
1896
1998
|
num_items?: number;
|
|
1897
|
-
on_no_rendering_result?: (result?: RecRendererResult) => any;
|
|
1898
|
-
post_rendering?: (surface?: RecRendererResult) => Promise<void> | void;
|
|
1999
|
+
on_no_rendering_result?: (result?: RecRendererResult<T>) => any;
|
|
2000
|
+
post_rendering?: (surface?: RecRendererResult<T>) => Promise<void> | void;
|
|
2001
|
+
};
|
|
2002
|
+
/**
|
|
2003
|
+
* We want to deprecate this
|
|
2004
|
+
*/
|
|
2005
|
+
export type PlaceholderRenderingDisplay = {
|
|
2006
|
+
sale_price: number;
|
|
2007
|
+
page_url: "#" | string;
|
|
2008
|
+
image_url: string;
|
|
2009
|
+
original_price: number;
|
|
2010
|
+
product_id: "placeholder" | string;
|
|
2011
|
+
recommendation_id: "placeholder" | string;
|
|
2012
|
+
title: string;
|
|
2013
|
+
brand: string;
|
|
1899
2014
|
};
|
|
1900
2015
|
export const random_text_placeholder: () => string;
|
|
1901
2016
|
export const placeholder_svg: (image_width: number, image_height: number, color?: string) => string;
|
|
@@ -1905,11 +2020,15 @@ export const placeholder_svg: (image_width: number, image_height: number, color?
|
|
|
1905
2020
|
* @param [image_width=2000] Width of placeholder image svg (use to set aspect ratio)
|
|
1906
2021
|
* @param [image_height=2000] Height of placeholder image svg (use to set aspect ratio)
|
|
1907
2022
|
* @param [num_items=10] Number of placeholders to render
|
|
2023
|
+
* @param [color="#d9d9d9"] Color of placeholder image svg
|
|
1908
2024
|
* @param [on_no_rendering_result] If rendering of actual recommendations fails (doesn't yield any `elements`) this function will be called with the rendering result as first argument
|
|
1909
2025
|
* @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
|
|
1910
2026
|
* @return It returns the same as a normal recommenation renderer would, meaning an object that might contain `displays` and `elements`
|
|
1911
2027
|
*/
|
|
1912
|
-
export function make_placeholder_rr({ override_rec_renderer, image_width, image_height, num_items, color, on_no_rendering_result, post_rendering, }?: MakePlaceholderRROption): Promise<(t: Tenant, rendering_options: Extended_RR_Options) =>
|
|
2028
|
+
export function make_placeholder_rr<T extends Display>({ override_rec_renderer, image_width, image_height, num_items, color, on_no_rendering_result, post_rendering, }?: MakePlaceholderRROption<T>): Promise<(t: Tenant, rendering_options: Extended_RR_Options<T | PlaceholderRenderingDisplay>) => Promise<Record<string, never> | {
|
|
2029
|
+
elements: Node_Array;
|
|
2030
|
+
displays: T[];
|
|
2031
|
+
}>>;
|
|
1913
2032
|
/**
|
|
1914
2033
|
* Queues a task in the event queue without a timeout like setTimeout does, see https://www.youtube.com/watch?v=cCOL7MC4Pl0
|
|
1915
2034
|
* @param callback callback function that gets queued as a task
|
|
@@ -1983,7 +2102,7 @@ export function timeout_promise<T>(promise: Promise<T>, ms: number): Promise<Awa
|
|
|
1983
2102
|
/**
|
|
1984
2103
|
* Uses the default Voyado ID that is used in Voyado email recommendations.
|
|
1985
2104
|
*/
|
|
1986
|
-
export const use_voyado_id: () =>
|
|
2105
|
+
export const use_voyado_id: () => void | undefined;
|
|
1987
2106
|
type ButtonProps = Omit<Partial<JSX.IntrinsicElements["button"]>, "type"> & {
|
|
1988
2107
|
class?: string;
|
|
1989
2108
|
};
|
|
@@ -2029,7 +2148,7 @@ export const Placeholder: ({ width, height, class: extra_classes, style, ...attr
|
|
|
2029
2148
|
* @see {@link Placeholder}
|
|
2030
2149
|
*/
|
|
2031
2150
|
export const ContainedPlaceholderImage: ({ aspect_ratio, ...attributes }: PlaceholderImageProps) => HTMLElement;
|
|
2032
|
-
export const RecommendationContainer: (title?: string | HTMLElement
|
|
2151
|
+
export const RecommendationContainer: (title?: string | HTMLElement, surface_classes?: string[]) => HTMLElement;
|
|
2033
2152
|
export const RightChevron: () => HTMLElement;
|
|
2034
2153
|
export const LeftChevron: () => HTMLElement;
|
|
2035
2154
|
export type ColorObj = {
|
|
@@ -2086,8 +2205,8 @@ export const useExpandingContainer: ({ duration, delay }?: {
|
|
|
2086
2205
|
ExpandingContainer: ({ children }: {
|
|
2087
2206
|
children?: Elem | Elem[] | undefined;
|
|
2088
2207
|
}) => HTMLElement;
|
|
2089
|
-
expand: (expanding_delay?:
|
|
2090
|
-
collapse: (collapsing_delay?:
|
|
2208
|
+
expand: (expanding_delay?: any, time_to_expand?: any) => Promise<Animation | undefined>;
|
|
2209
|
+
collapse: (collapsing_delay?: any, time_to_collapse?: any) => Promise<Animation | undefined>;
|
|
2091
2210
|
};
|
|
2092
2211
|
export const resize_base_url: string;
|
|
2093
2212
|
export const is_safari: boolean;
|
|
@@ -2140,7 +2259,7 @@ export function make_url_with_query_params(base: string, params: {
|
|
|
2140
2259
|
export interface ImageOptions extends Partial<HTMLImageElement> {
|
|
2141
2260
|
aspect_ratio: number;
|
|
2142
2261
|
class?: string;
|
|
2143
|
-
rendering_options?: RR_Options
|
|
2262
|
+
rendering_options?: RR_Options<any>;
|
|
2144
2263
|
srcset_opts?: Parameters<typeof make_sourceset_component>[0];
|
|
2145
2264
|
alt: string;
|
|
2146
2265
|
remove_on_error?: boolean;
|
|
@@ -2193,7 +2312,6 @@ export function SearchIcon(props?: JSX.SvgSVGAttributes<SVGSVGElement>): HTMLEle
|
|
|
2193
2312
|
export function SortIconAsc(props?: JSX.SvgSVGAttributes<SVGSVGElement>): SVGElement;
|
|
2194
2313
|
export function SortIconDesc(props?: JSX.SvgSVGAttributes<SVGSVGElement>): HTMLElement;
|
|
2195
2314
|
export function TickIcon(props?: JSX.SvgSVGAttributes<SVGSVGElement>): HTMLElement;
|
|
2196
|
-
export const version = "0.0.39";
|
|
2197
2315
|
/**
|
|
2198
2316
|
* Shallowly converts all keys in an object from snake_case to camelCase.
|
|
2199
2317
|
* Does not support symbol keys.
|