@depict-ai/utilishared 0.0.30 → 0.0.32

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 CHANGED
@@ -103,7 +103,7 @@ export function err(exception: Error | any, error_for_stack?: Error): undefined;
103
103
  export function is_available_in(obj: Object, property: PropertyKey, ...sub_objects_to_wait_for: PropertyKey[]): any;
104
104
  export function find_descriptor(obj: Object, prop: PropertyKey): PropertyDescriptor | undefined;
105
105
  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: {
106
+ declare const Sentry: {
107
107
  captureException: (...args: any[]) => void;
108
108
  captureMessage: (...args: any[]) => void;
109
109
  withScope: (...args: any[]) => void;
@@ -112,7 +112,7 @@ export const Sentry: {
112
112
  * Severity level to send to sentry.
113
113
  * We can also send `log`, `info`, `debug`, `critical` and `fatal` but we haven't had a need for it yet.
114
114
  */
115
- export type Severity = "error" | "warning";
115
+ type Severity = "error" | "warning";
116
116
  export function catchify<T extends Function>(fn: T, msg?: string, severity?: Severity): T;
117
117
  /**
118
118
  * Send error message with given severity and extra info to sentry
@@ -200,7 +200,7 @@ export function make_random_classname(): string;
200
200
  export type event_types = "page_view" | "click" | "add_to_cart" | "purchase" | "element_visible";
201
201
  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"];
202
202
  export type depict_body = Partial<{
203
- [K in typeof allowed_keys[number]]: any;
203
+ [K in (typeof allowed_keys)[number]]: any;
204
204
  }>;
205
205
  export type depict_payload = depict_body[];
206
206
  type any_properties = {
@@ -875,7 +875,7 @@ type ExclusiveId = {
875
875
  product_id?: undefined;
876
876
  product_ids?: undefined;
877
877
  };
878
- export type FetchRecsOptions = {
878
+ type FetchRecsOptions = {
879
879
  type: string;
880
880
  } & ExclusiveId;
881
881
  /**
@@ -901,19 +901,11 @@ export function querySelectorAllElements<T extends Element>(elements: Node_Itera
901
901
  export function standard_price_format(price: number, places_after_comma?: number | "auto", decimal_delimiter?: string, thousands_delimiter?: string): string;
902
902
  export function intl_number_format_with_fallback(bcp47_country_code: string, number: number, numberformat_options?: Parameters<typeof Intl.NumberFormat>[1]): string;
903
903
  export function ensure_object_path(obj: object, step1: string, ...path: string[]): any;
904
- export type event_listener_array = [
905
- type: keyof HTMLElementEventMap,
906
- listener: (this: HTMLElement, ev: HTMLElementEventMap[keyof HTMLElementEventMap]) => any,
907
- options?: boolean | AddEventListenerOptions
908
- ][];
909
904
  export function Rec_Renderer(t: Tenant, rendering_options: RR_Options): Promise<RecRendererResult>;
910
905
  export function regex_templating(template: string, display?: Display | {
911
906
  [key: string]: any;
912
907
  }): string;
913
908
  export function clone_deep<T>(obj: T): T;
914
- export function post_process(t: Tenant, rendering_options: RR_Options, displays: Display[], index: number, functions: RR_PostProcessor[], // required, duh
915
- elements: NodeListOf<ChildNode> | Node_Array, event_listeners?: event_listener_array): Promise<NodeListOf<ChildNode> | Node_Array>;
916
- export function pre_processor_pipeline(t: Tenant, rendering_options: RR_Options, displays: Display[]): Promise<Display[]>;
917
909
  export class InfoForProcessing {
918
910
  constructor(t: Tenant, rendering_options: RR_Options, displays: Display[], index?: number, remove_display?: () => void, event_listeners?: [
919
911
  type: keyof HTMLElementEventMap,
@@ -1010,10 +1002,7 @@ export const check_displays: ({ recs, min_recs, market, type, product_id, tenant
1010
1002
  export function require_event_listener(element: Node, event: string, track_id: any, func: EventListenerOrEventListenerObject): void;
1011
1003
  export const default_view_tracking: RR_PostProcessor[];
1012
1004
  export const default_click_tracking: (typeof add_new_tab_listener)[];
1013
- export const tracking_function_map: Map<Function, WeakRef<Function>[]>;
1014
- export const rro_inserted_event_sent: WeakSet<RR_Options>;
1015
1005
  export function recs_inserted_tracking(elements: NodeListOf<ChildNode>, _display: Display, info: InfoForProcessing): NodeListOf<ChildNode>;
1016
- export const gtag_view_sent: WeakSet<Display[]>;
1017
1006
  export function gtag_view_post_processor(elements: NodeListOf<ChildNode>, _display: Display, info: InfoForProcessing): NodeListOf<ChildNode>;
1018
1007
  export function depict_page_view(elements: NodeListOf<ChildNode>, _display: Display, info: InfoForProcessing): NodeListOf<ChildNode>;
1019
1008
  export function gtag_click_post_processor(elements: NodeListOf<ChildNode>, display: Display, info: InfoForProcessing): NodeListOf<ChildNode>;
@@ -1022,17 +1011,12 @@ export function add_to_localstorage(elements: NodeListOf<ChildNode>, display: Di
1022
1011
  export function ga_click(elements: NodeListOf<ChildNode>, display: Display, info: InfoForProcessing): NodeListOf<ChildNode>;
1023
1012
  export const should_colorizeLogics: boolean;
1024
1013
  export function colorize_elements(elements: NodeListOf<ChildNode>, display: Display): NodeListOf<ChildNode>;
1025
- export type RR_Translations = {
1026
- [market: string]: {
1027
- [key: string]: string;
1028
- };
1029
- };
1030
- export type Extended_RR_Options = {
1014
+ type Extended_RR_Options = {
1031
1015
  view_tracking?: RR_PostProcessor[];
1032
1016
  click_tracking?: RR_PostProcessor[];
1033
1017
  } & RR_Options;
1034
1018
  export function default_rr(t: Tenant, rendering_options: Extended_RR_Options): Promise<RecRendererResult>;
1035
- export type GWVM_Options = {
1019
+ type GWVM_Options = {
1036
1020
  container_selector?: string;
1037
1021
  start_rows?: number;
1038
1022
  rows_per_click?: number;
@@ -1045,7 +1029,7 @@ export type GWVM_Options = {
1045
1029
  only_full_rows?: boolean;
1046
1030
  should_preload?: boolean;
1047
1031
  };
1048
- export interface GWVM_InfoForProcessing extends InfoForProcessing {
1032
+ interface GWVM_InfoForProcessing extends InfoForProcessing {
1049
1033
  extras: {
1050
1034
  [key: string]: any;
1051
1035
  load_more_currently_showing: number;
@@ -1056,8 +1040,8 @@ export interface GWVM_InfoForProcessing extends InfoForProcessing {
1056
1040
  };
1057
1041
  };
1058
1042
  }
1059
- export type GWVM_RR_Post_Pro = (elements: NodeListOf<ChildNode> | Node_Array, display: Display, info: GWVM_InfoForProcessing) => Promise<NodeListOf<ChildNode> | Node_Array> | NodeListOf<ChildNode> | Node_Array;
1060
- export type GWVM_RR_Options = Extended_RR_Options & {
1043
+ type GWVM_RR_Post_Pro = (elements: NodeListOf<ChildNode> | Node_Array, display: Display, info: GWVM_InfoForProcessing) => Promise<NodeListOf<ChildNode> | Node_Array> | NodeListOf<ChildNode> | Node_Array;
1044
+ type GWVM_RR_Options = Extended_RR_Options & {
1061
1045
  post_processors?: GWVM_RR_Post_Pro[];
1062
1046
  };
1063
1047
  /**
@@ -1093,7 +1077,7 @@ export function infinite_promise_creator(): {
1093
1077
  internal_resolve: ((value: any) => void) | undefined;
1094
1078
  resolve: (argument?: any) => void;
1095
1079
  };
1096
- export interface trimmed_GWVM_opts extends Omit<GWVM_Options, "start_rows" | "rows_per_click" | "recs_per_row"> {
1080
+ interface trimmed_GWVM_opts extends Omit<GWVM_Options, "start_rows" | "rows_per_click" | "recs_per_row"> {
1097
1081
  }
1098
1082
  /**
1099
1083
  * @deprecated please rewrite this, basing on RecommendationGrid and its `rows.ipns` option, next time you need infinite scroll
@@ -1113,7 +1097,7 @@ export type ArrayElement<ArrayType extends readonly unknown[]> = ArrayType exten
1113
1097
  /**
1114
1098
  * @deprecated please use TwoLetterMarket / readonly arrays/objects instead
1115
1099
  */
1116
- export enum Market {
1100
+ enum Market {
1117
1101
  dk = "dk",
1118
1102
  uk = "uk",
1119
1103
  com = "com",
@@ -1132,7 +1116,7 @@ export enum Market {
1132
1116
  /**
1133
1117
  * @deprecated please use TwoLetterMarket / readonly arrays/objects instead
1134
1118
  */
1135
- export enum Locale {
1119
+ enum Locale {
1136
1120
  sv_SE = "sv-SE",
1137
1121
  no_NO = "no-NO",
1138
1122
  fi_FI = "fi-FI",
@@ -1151,18 +1135,14 @@ type CurrencyInfo = {
1151
1135
  /**
1152
1136
  * @deprecated please use TwoLetterMarket / readonly arrays/objects instead
1153
1137
  */
1154
- export const CURRENCY: Record<string, CurrencyInfo>;
1155
- /**
1156
- * @deprecated please use TwoLetterMarket / readonly arrays/objects instead
1157
- */
1158
- export type MarketDetails = {
1138
+ type MarketDetails = {
1159
1139
  currency: CurrencyInfo;
1160
1140
  locale_bcp47: Locale;
1161
1141
  };
1162
1142
  /**
1163
1143
  * @deprecated please use TwoLetterMarket / readonly arrays/objects instead
1164
1144
  */
1165
- export type MarketConfig = MarketDetails & {
1145
+ type MarketConfig = MarketDetails & {
1166
1146
  analytics_id: string;
1167
1147
  };
1168
1148
  /**
@@ -1204,7 +1184,7 @@ export interface Lazyfier {
1204
1184
  only_load_intersecting: boolean;
1205
1185
  ignore_data_urls?: boolean;
1206
1186
  }
1207
- export interface Lazyfier_Options {
1187
+ interface Lazyfier_Options {
1208
1188
  container?: HTMLElement;
1209
1189
  lazyfinder?: lazyfinder;
1210
1190
  selector?: string;
@@ -1219,13 +1199,12 @@ export class Lazyfier {
1219
1199
  start_observing_for_new_children_(override_container?: HTMLElement): void;
1220
1200
  constructor({ container, lazyfinder, selector, wait_for_dominsertion, only_load_intersecting, ignore_data_urls, verbose, }: Lazyfier_Options);
1221
1201
  }
1222
- export interface lazyfinder {
1202
+ interface lazyfinder {
1223
1203
  elements?: HTMLImageElementWithLoaded[];
1224
1204
  unload?: (element: HTMLImageElementWithLoaded) => void | Promise<void>;
1225
1205
  load?: (element: HTMLImageElementWithLoaded) => void | Promise<void>;
1226
1206
  }
1227
1207
  export function test_array_proxy_support(): boolean;
1228
- export function find_siblings<T extends Element>(element: Element, selector: string): T[];
1229
1208
  export interface Slider_Options {
1230
1209
  /**
1231
1210
  * Controls within what distance to hide the left slider button.
@@ -1298,7 +1277,7 @@ export interface Amazing_Lazy_Slider {
1298
1277
  export class Amazing_Lazy_Slider extends Amazing_Slider {
1299
1278
  constructor(options: Slider_Options, lazyfier_options?: Optional<ConstructorParameters<typeof Lazyfier>[0], "container">);
1300
1279
  }
1301
- export interface Pro_Slider_Options {
1280
+ interface Pro_Slider_Options {
1302
1281
  container?: string | Node_Iterable;
1303
1282
  root_selector?: string;
1304
1283
  override_rec_renderer?: typeof Rec_Renderer;
@@ -1354,9 +1333,9 @@ export const simplified_template_tool: (options: {
1354
1333
  postProcessor?: Function | undefined;
1355
1334
  preProcessor?: Function | undefined;
1356
1335
  }) => Promise<Depict>;
1357
- export interface special_lazyfier_options extends Omit<Lazyfier_Options, "t"> {
1336
+ interface special_lazyfier_options extends Omit<Lazyfier_Options, "t"> {
1358
1337
  }
1359
- export interface Deprecated_Slider_Options {
1338
+ interface Deprecated_Slider_Options {
1360
1339
  dlog?: Function;
1361
1340
  catchify?: Function;
1362
1341
  dist_to_hide_left?: number;
@@ -1371,11 +1350,11 @@ export interface Deprecated_Slider_Options {
1371
1350
  /**
1372
1351
  * @deprecated Please use Pro_Slider instead
1373
1352
  */
1374
- export class Deprecated_Amazing_Slider extends Amazing_Lazy_Slider {
1353
+ declare class Deprecated_Amazing_Slider extends Amazing_Lazy_Slider {
1375
1354
  constructor(static_options: Deprecated_Slider_Options, override_lazyfier_options?: special_lazyfier_options);
1376
1355
  }
1377
1356
  export function insert_styling_into_slider(slider: Deprecated_Amazing_Slider): void;
1378
- export interface RR_Slider_Options {
1357
+ interface RR_Slider_Options {
1379
1358
  container?: string | Node_Iterable;
1380
1359
  root_selector?: string;
1381
1360
  Rec_Renderer?: typeof Rec_Renderer;
@@ -1385,8 +1364,8 @@ export interface RR_Slider_Options {
1385
1364
  * @deprecated please use Pro_Slider instead
1386
1365
  */
1387
1366
  export function RR_Slider(t: Tenant, rendering_options: Extended_RR_Options, options_for_us?: RR_Slider_Options, slider_options?: Deprecated_Slider_Options, override_lazyfier_options?: special_lazyfier_options): ReturnType<typeof Rec_Renderer>;
1388
- export type PreProcessor = (tenant: Tenant, display: any, i?: number, with_loadmore?: boolean, with_slider?: boolean, infinite_scroll?: boolean) => any;
1389
- export type PostProcessor = (tenant: Tenant, items: HTMLCollection, display: any, slider?: Deprecated_Amazing_Slider) => HTMLCollection;
1367
+ type PreProcessor = (tenant: Tenant, display: any, i?: number, with_loadmore?: boolean, with_slider?: boolean, infinite_scroll?: boolean) => any;
1368
+ type PostProcessor = (tenant: Tenant, items: HTMLCollection, display: any, slider?: Deprecated_Amazing_Slider) => HTMLCollection;
1390
1369
  /**
1391
1370
  * @deprecated this uses template-tool-v1 which is long surpassed, please use RecommendationGrid or Pro_Slider (based on Recommendation-Renderer) instead
1392
1371
  */
@@ -1414,18 +1393,15 @@ export const wpff: (dlog: any, error_log?: any[] | undefined) => (url: RequestIn
1414
1393
  export const use_element: <E extends HTMLOrSVGElement = HTMLElement>(callback: (element: E) => void, element: E) => E;
1415
1394
  export const use_listener: <E extends HTMLElement = HTMLElement>(event: string, handler: EventListener, element: E) => E;
1416
1395
  export const classlist: (classes: (string | undefined)[]) => string;
1417
- export type Props = {
1396
+ type Props = {
1418
1397
  children: Elem[] | Elem;
1419
1398
  onClick: (e: MouseEvent) => void;
1420
1399
  [key: string]: any;
1421
1400
  };
1422
- export type Elem = Node | string;
1423
- export type Component = (props: Props, _unknown: unknown) => HTMLElement;
1401
+ type Elem = Node | string;
1402
+ type Component = (props: Props, _unknown: unknown) => HTMLElement;
1424
1403
  export const jsx: (tag: string | Component, { children, ...props }: Props, _unknown: unknown) => JSX.Element;
1425
1404
  export const jsxs: (tag: string | Component, { children, ...props }: Props, _unknown: unknown) => JSX.Element;
1426
- export const Fragment: ({ children }: {
1427
- children: Elem[] | Elem;
1428
- }, _unknown: unknown) => DocumentFragment;
1429
1405
  export const chevronRight: HTMLElement;
1430
1406
  export const chevronLeft: HTMLElement;
1431
1407
  export const expandingContainer: ({ duration }?: {
@@ -1448,9 +1424,9 @@ export function zip_async_iterables<T extends any[]>(iterables: IPNS<T[keyof T]>
1448
1424
  type Override = {
1449
1425
  overrides: Record</* Row: */ number, /* Column: */ number>;
1450
1426
  };
1451
- 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];
1452
- export type ColsAtSize = readonly ColAtSize[];
1453
- export type LayoutOptions = {
1427
+ 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];
1428
+ type ColsAtSize = readonly ColAtSize[];
1429
+ type LayoutOptions = {
1454
1430
  container_element: Element;
1455
1431
  cols_at_size: ColsAtSize;
1456
1432
  grid_spacing: string;
@@ -1465,7 +1441,6 @@ export type LayoutOptions = {
1465
1441
  disable_partial_rows?: boolean;
1466
1442
  override_vertical_spacing?: string;
1467
1443
  };
1468
- export const media_query_header: (min: string, max?: string | undefined) => string;
1469
1444
  /**
1470
1445
  * Grid: Calculates CSS for a grid with a certain spacing and certain number of columns at certain screen sizes, including a view more button.
1471
1446
  * @param rows if set to 'all': Just generate grid styling without any viewing/hiding functionality. If an object: start_rows is the number of rows at the beginning. rows_per_click is the amount of rows to view on each view more buttonn click. button is the view more button to display. ipns is an async iterable infinite promise that you can use to get and set the number of currently viewed rows
@@ -1692,7 +1667,7 @@ export interface ListenableSetEvent<T> extends CustomEvent {
1692
1667
  */
1693
1668
  export class ListenableSet<T> extends Set<T> {
1694
1669
  #private;
1695
- addEventListener(event: "add" | "delete", callback: (ev: ListenableSetEvent<T>) => unknown, options?: Parameters<typeof EventTarget.prototype["addEventListener"]>[2]): void;
1670
+ addEventListener(event: "add" | "delete", callback: (ev: ListenableSetEvent<T>) => unknown, options?: Parameters<(typeof EventTarget.prototype)["addEventListener"]>[2]): void;
1696
1671
  removeEventListener(event: "add" | "delete", callback: (ev: Event) => unknown): void;
1697
1672
  add(property: T): this;
1698
1673
  delete(property: T): any;
@@ -1907,16 +1882,6 @@ export function insert_surfaces({ surfaces: input_surfaces, verb, target, remove
1907
1882
  succeeded: boolean;
1908
1883
  }>[];
1909
1884
  export const revertable_remove: (target: Element | Node_Array | string, should_stay_inserted: Promise<boolean>) => Promise<void>;
1910
- /**
1911
- * restore (if no allSettled and prototype.finally) native Promise and cement Promise - some customers force polyfill promise with flawed implementations of .all and .allSettled that randomly throw (see usage examples)
1912
- * @return void
1913
- */
1914
- export function replace_promise_with_native_if_exists_and_enforce(): void;
1915
- /**
1916
- * Creates a blank iframe inside <head> and returns window.Promise out of it
1917
- * @return a pristine, unpolyfilled window.Promise
1918
- */
1919
- export function get_iframe_promise(): PromiseConstructor;
1920
1885
  type MakePlaceholderRROption = {
1921
1886
  override_rec_renderer?: (t: Tenant, rendering_options: Extended_RR_Options) => Promise<RecRendererResult>;
1922
1887
  image_width?: number;
@@ -1949,6 +1914,16 @@ export function queueMacroTask(callback: VoidFunction): void;
1949
1914
  * @return a WeakSet to add nodes to which you remove and want to ignore removal errors for
1950
1915
  */
1951
1916
  export function removeChild_error_swallowing_factory(): WeakSet<Node>;
1917
+ /**
1918
+ * restore (if no allSettled and prototype.finally) native Promise and cement Promise - some customers force polyfill promise with flawed implementations of .all and .allSettled that randomly throw (see usage examples)
1919
+ * @return void
1920
+ */
1921
+ export function replace_promise_with_native_if_exists_and_enforce(): void;
1922
+ /**
1923
+ * Creates a blank iframe inside <head> and returns window.Promise out of it
1924
+ * @return a pristine, unpolyfilled window.Promise
1925
+ */
1926
+ export function get_iframe_promise(): PromiseConstructor;
1952
1927
  /**
1953
1928
  * Proxies XMLHttpRequest.prototype.open to an open function which also calls the provided `fetch_handler` with useful information as parameter
1954
1929
  * @param fetch_handler A function which is catchified and which's return value is ignored. It gets called every time an XHR request gets opened
@@ -2212,5 +2187,4 @@ export function SearchIcon(props?: JSX.SvgSVGAttributes<SVGSVGElement>): HTMLEle
2212
2187
  export function SortIconAsc(props?: JSX.SvgSVGAttributes<SVGSVGElement>): SVGElement;
2213
2188
  export function SortIconDesc(props?: JSX.SvgSVGAttributes<SVGSVGElement>): HTMLElement;
2214
2189
  export function TickIcon(props?: JSX.SvgSVGAttributes<SVGSVGElement>): HTMLElement;
2215
- export const version = "0.0.30";
2216
- export type { Display as DisplayWithVariants } from "./new_display";
2190
+ export const version = "0.0.32";