@depict-ai/ui 4.8.4 → 4.8.6

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 CHANGED
@@ -114,7 +114,7 @@ $parcel$export(module.exports, "BreadCrumbs", () => $335c02c1241a9ca8$export$5b7
114
114
  $parcel$export(module.exports, "QuickLinks", () => $335c02c1241a9ca8$export$de035477d6fef996);
115
115
  $parcel$export(module.exports, "CategoryPage", () => $c10e33c4681f8c9b$export$e2bf8ce7779e827e);
116
116
  /*! Depict.ai search and product listing SDK */
117
- const $aa1938dec50d6c12$export$83d89fbfd8236492 = "4.8.4";
117
+ const $aa1938dec50d6c12$export$83d89fbfd8236492 = "4.8.6";
118
118
  function $054b1113e4897051$export$54c6d6ff54e72743(whatToWatch) {
119
119
  const [width, setWidth] = $52FdA$solidjs.createSignal(0);
120
120
  const [height, setHeight] = $52FdA$solidjs.createSignal(0);
@@ -3257,10 +3257,10 @@ function $068bde7fa83ac02c$export$92f2da32c6e7e7ee(_ref) {
3257
3257
  i18n_: i18n_
3258
3258
  } = _ref;
3259
3259
  return $52FdA$solidjs.createMemo(() => {
3260
- const n_hits = number_();
3261
- if (isNaN(n_hits)) return "";
3260
+ const numberToFormat = number_();
3261
+ if (isNaN(numberToFormat)) return "";
3262
3262
  const price_formatting = i18n_.price_formatting_();
3263
- return $52FdA$depictaiutilishared.standard_price_format(n_hits, 0,
3263
+ return $52FdA$depictaiutilishared.standard_price_format(numberToFormat, 0,
3264
3264
  // we never want places after comma here it looks weird as hell
3265
3265
  price_formatting.decimal_places_delimiter_, price_formatting.thousands_delimiter_);
3266
3266
  });
@@ -4350,7 +4350,8 @@ function $29e5dbeb69da7a36$export$b94867ecbd698f21(_ref) {
4350
4350
  });
4351
4351
  }
4352
4352
  }, () => searchFieldEmpty() ? {
4353
- "aria-hidden": "true"
4353
+ "aria-hidden": "true",
4354
+ tabIndex: -1
4354
4355
  } : {
4355
4356
  title: i18n_.clear_filters_query_sorting_after_submit_()
4356
4357
  }), false, true);
@@ -5789,9 +5790,10 @@ function $43600b30502feeda$var$RawSearchModalV2(_ref) {
5789
5790
  });
5790
5791
  // total number of results = content results + product results + category suggestions
5791
5792
  const totalNumberResults = $52FdA$solidjs.createMemo(() => {
5792
- var _get_modal_search_res4, _results$content_sear, _listing_suggestions_;
5793
+ var _get_modal_search_res4, _results$displays, _results$content_sear, _listing_suggestions_;
5793
5794
  const results = (_get_modal_search_res4 = get_modal_search_results_()) === null || _get_modal_search_res4 === void 0 ? void 0 : _get_modal_search_res4();
5794
- const hits = results === null || results === void 0 ? void 0 : results.n_hits;
5795
+ // Show actual number of result (more accurate) if there's no cursor (backend doesn't have more products)
5796
+ const hits = results !== null && results !== void 0 && results.cursor ? results === null || results === void 0 ? void 0 : results.n_hits : results === null || results === void 0 ? void 0 : (_results$displays = results.displays) === null || _results$displays === void 0 ? void 0 : _results$displays.length;
5795
5797
  const content_results = content_search_enabled_() && (results === null || results === void 0 ? void 0 : (_results$content_sear = results.content_search_links) === null || _results$content_sear === void 0 ? void 0 : _results$content_sear.length) || 0;
5796
5798
  const category_results = ((_listing_suggestions_ = listing_suggestions_()) === null || _listing_suggestions_ === void 0 ? void 0 : _listing_suggestions_.length) || 0;
5797
5799
  return (hits !== null && hits !== void 0 ? hits : 0) + content_results + category_results;
@@ -6334,6 +6336,7 @@ async function $4cf7d9829d60d844$export$79b1565500412d9b(search_modal, modal_fn_
6334
6336
  close_modal_: close_modal_
6335
6337
  };
6336
6338
  }
6339
+ let $367b536a2a94d24e$export$68620bd6d5c6bb86;
6337
6340
  function $367b536a2a94d24e$export$e183a13865960371(params_to_default_value, router_) {
6338
6341
  const signals = {};
6339
6342
  const entries = Object.entries(params_to_default_value);
@@ -6366,6 +6369,10 @@ function $367b536a2a94d24e$export$e183a13865960371(params_to_default_value, rout
6366
6369
  }
6367
6370
  }
6368
6371
  if (signal_changed) router_.navigate_.replace_state_(state);
6372
+ $52FdA$solidjs.onCleanup(() => $367b536a2a94d24e$export$68620bd6d5c6bb86 = {
6373
+ time: new Date().toISOString(),
6374
+ stack: new Error().stack
6375
+ });
6369
6376
  });
6370
6377
  // history_dot_state_to_state needs to update after its signals after url_state does BUT in the same task (might even have to be in the same tick in the microtask queue). If we'd use window.addEventListener("popstate") it would be guaranteed to be too late since each event listener has its own task
6371
6378
  (0, $52FdA$depictaiutilishared.instant_exec_on_suspect_history_change).add(event_handler);
@@ -10089,8 +10096,16 @@ function $a162c9a08dc208c2$export$b288c38ae3fddb56(_ref) {
10089
10096
  selected_filters_: [read_selected_filters]
10090
10097
  } = _ref;
10091
10098
  let last_remote_state;
10099
+ let executions = 0;
10100
+ let oneSecondInfiniteLoopPreventionTimeout;
10092
10101
  $52FdA$solidjs.createComputed(() => {
10093
10102
  var _available_filters_;
10103
+ // Sometimes (24 events in sentry, https://depictai-0o.sentry.io/issues/?project=5476183&query=is%3Aunresolved+filters+failed&referrer=issue-list&statsPeriod=14d), for some inexplicable reason, this computation infinite loops
10104
+ // I spent a 1h17min debug session with MadePeople in a tab where they could reproduce
10105
+ // Observations were that of the signal read_local_cache the observers at some point randomly started having this computation first instead of the effect that writes the value to the history
10106
+ // It's VERY HARD to get a tab in a state where it can be reproduced, like with the exact same circumstances it happens "once a day" for them and there's no noticable pattern. But when a tab is found, it can be reliably reproduced by going backwards/forwards.
10107
+ // Also we reliably clean up and dispose of the search page and the effect of history_dot_state_to_state stays in the signals' observers, but for some reason it disappears when the bug happens (onCleanup doesn't get called then either, if I debugged that correctly)
10108
+ // As a value first workaround, we just recognise when the computation has been executed "too often" and just start not doing anything after that
10094
10109
  const remote_filters = Object.fromEntries(((_available_filters_ = available_filters_()) === null || _available_filters_ === void 0 ? void 0 : _available_filters_.map(filter => {
10095
10110
  var _filter$meta;
10096
10111
  return [JSON.stringify([filter.field, filter.op, filter === null || filter === void 0 ? void 0 : (_filter$meta = filter.meta) === null || _filter$meta === void 0 ? void 0 : _filter$meta.type]), filter];
@@ -10197,9 +10212,36 @@ function $a162c9a08dc208c2$export$b288c38ae3fddb56(_ref) {
10197
10212
  }
10198
10213
  if (last_remote_state !== available_filters_() ||
10199
10214
  // we HAVE to update the local filter state (it can contain same info but needs to be different object reference) every time the API state changes, otherwise the CheckboxHierarchicalFilter component doesn't update
10200
- JSON.stringify(new_local_filter_state) !== JSON.stringify(read_local_cache()))
10201
- // Sorry……… They're not that big
10215
+ // Sorry……… They're not that big
10216
+ JSON.stringify(new_local_filter_state) !== JSON.stringify(read_local_cache())) {
10217
+ var _sources, _sources$find;
10218
+ const owner = $52FdA$solidjs.getOwner();
10219
+ const signal = owner === null || owner === void 0 ? void 0 : (_sources = owner.sources) === null || _sources === void 0 ? void 0 : (_sources$find = _sources.find) === null || _sources$find === void 0 ? void 0 : _sources$find.call(_sources, source => source.value === read_local_cache());
10220
+ if (executions > 30) {
10221
+ var _signal$observers, _signal$observers$map;
10222
+ // We're probably in an infinite loop, let's just stop
10223
+ $52FdA$depictaiutilishared.report(new Error("Infinite loop detected in create_modified_filters"), "error", {
10224
+ executions: executions,
10225
+ new_local_filter_state: new_local_filter_state,
10226
+ available_filters: available_filters_(),
10227
+ last_remote_state: last_remote_state,
10228
+ history_length: history.length,
10229
+ location: location.href,
10230
+ foundSignal: !!signal,
10231
+ observerSlots: signal === null || signal === void 0 ? void 0 : signal.observerSlots,
10232
+ observers: signal === null || signal === void 0 ? void 0 : (_signal$observers = signal.observers) === null || _signal$observers === void 0 ? void 0 : (_signal$observers$map = _signal$observers.map) === null || _signal$observers$map === void 0 ? void 0 : _signal$observers$map.call(_signal$observers, o => (o === null || o === void 0 ? void 0 : o.fn) + ""),
10233
+ lastHistoryDotStateToStateCleanupInfo: $367b536a2a94d24e$export$68620bd6d5c6bb86
10234
+ });
10235
+ return;
10236
+ }
10202
10237
  write_local_cache(new_local_filter_state);
10238
+ // Keep track how many times we wrote this signal
10239
+ executions++;
10240
+ oneSecondInfiniteLoopPreventionTimeout || (oneSecondInfiniteLoopPreventionTimeout = setTimeout($52FdA$depictaiutilishared.catchify(() => {
10241
+ executions = 0;
10242
+ oneSecondInfiniteLoopPreventionTimeout = undefined;
10243
+ }), 1000));
10244
+ }
10203
10245
  last_remote_state = available_filters_();
10204
10246
  });
10205
10247
  }
@@ -12027,7 +12069,8 @@ function $0d3ee7000f047e67$export$a1fd619a4743ca08(_ref) {
12027
12069
  query_base_: query_base_,
12028
12070
  depict_api_: depict_api_,
12029
12071
  is_loading_: is_loading_,
12030
- content_blocks_: content_blocks_
12072
+ content_blocks_: content_blocks_,
12073
+ setCurrentlyLoadedDisplays_: setCurrentlyLoadedDisplays_
12031
12074
  } = _ref;
12032
12075
  // Although typing doesn't reflect it, plp_results is guaranteed to contain an array of at least one display at this point
12033
12076
  const [get_extra_displays, set_extra_displays_] = $52FdA$solidjs.createSignal([], {
@@ -12054,6 +12097,7 @@ function $0d3ee7000f047e67$export$a1fd619a4743ca08(_ref) {
12054
12097
  is_loading_: is_loading_,
12055
12098
  get_extra_displays: get_extra_displays
12056
12099
  });
12100
+ $52FdA$solidjs.createComputed(() => setCurrentlyLoadedDisplays_(displays_by_key_().size));
12057
12101
  $19438fea513c9d01$export$5e4aed86c12acdd9({
12058
12102
  percentage_in_view_: percentage_in_view_,
12059
12103
  set_extra_displays_: set_extra_displays_,
@@ -12114,7 +12158,8 @@ function $484eec37514a982e$export$3925f87b1545cfc6(_ref) {
12114
12158
  layout_options_: layout_options_,
12115
12159
  id_currently_querying_for_: id_currently_querying_for_,
12116
12160
  content_blocks_by_row_: content_blocks_by_row_,
12117
- ConfiguredScrollStatus_: ConfiguredScrollStatus_
12161
+ ConfiguredScrollStatus_: ConfiguredScrollStatus_,
12162
+ setCurrentlyLoadedDisplays_: setCurrentlyLoadedDisplays_
12118
12163
  } = _ref;
12119
12164
  // The plp_results_ resource will be delayed because we're using createBatchedMemo to not make triplicate API requests, but we need to show the placeholders before already to match Chrome and Firefox's "content has to be there, ready for scroll restoration, before all popstate tasks have been completed"-requirement
12120
12165
  const is_loading_ = $52FdA$solidjs.createMemo(() => plp_results_.loading || query_base_.loading);
@@ -12251,7 +12296,8 @@ function $484eec37514a982e$export$3925f87b1545cfc6(_ref) {
12251
12296
  query_base_: query_base_,
12252
12297
  depict_api_: depict_api_,
12253
12298
  is_loading_: is_loading_,
12254
- content_blocks_: content_blocks_
12299
+ content_blocks_: content_blocks_,
12300
+ setCurrentlyLoadedDisplays_: setCurrentlyLoadedDisplays_
12255
12301
  });
12256
12302
  $52FdA$solidjs.onCleanup(() => suspense_contents = undefined);
12257
12303
  return suspense_contents;
@@ -14113,6 +14159,17 @@ function $a60bc7692ce52705$export$44f738469d5570cf(_ref) {
14113
14159
  };
14114
14160
  });
14115
14161
  }
14162
+ function $e335e2ff536c1a0b$export$a86bc18439445599(plp_products_, _ref, currentlyLoadedDisplays) {
14163
+ let [allProductsLoaded] = _ref;
14164
+ return $52FdA$solidjs.createMemo(() => {
14165
+ var _plp_products_;
14166
+ const backendSays = (_plp_products_ = plp_products_()) === null || _plp_products_ === void 0 ? void 0 : _plp_products_.n_hits;
14167
+ const loadedAll = allProductsLoaded();
14168
+ if (!backendSays || !loadedAll) return backendSays;
14169
+ // People can remove displays in the displayTransformers, for example houdini do it (https://depictaiworkspace.slack.com/archives/C061H2TF7K4/p1713261063439089). Correct the n_hits as well as possible in that case.
14170
+ return currentlyLoadedDisplays();
14171
+ });
14172
+ }
14116
14173
  var $739c927cbecd26b0$var$_tmpl$ = /*#__PURE__*/$52FdA$solidjsweb.template(`<div class=filter-results-for-one-row><!$><!/><!$><!/>`),
14117
14174
  $739c927cbecd26b0$var$_tmpl$2 = /*#__PURE__*/$52FdA$solidjsweb.template(`<div><div class=listing-page><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/></div><!$><!/><!$><!/>`);
14118
14175
  function $739c927cbecd26b0$export$a54ec244c8863715(_ref) {
@@ -14154,6 +14211,7 @@ function $739c927cbecd26b0$export$a54ec244c8863715(_ref) {
14154
14211
  } = _ref;
14155
14212
  const [get_sorting] = current_sorting_;
14156
14213
  const all_products_loaded_ = $52FdA$solidjs.createSignal(false);
14214
+ const [currentlyLoadedDisplays, setCurrentlyLoadedDisplays_] = $52FdA$solidjs.createSignal(0);
14157
14215
  const [get_all_products_loaded, set_all_products_loaded] = all_products_loaded_;
14158
14216
  const number_of_rendered_selected_filters_items_ = $52FdA$solidjs.createSignal(0);
14159
14217
  const first_result_in_viewport_ = $52FdA$solidjs.createSignal();
@@ -14232,24 +14290,21 @@ function $739c927cbecd26b0$export$a54ec244c8863715(_ref) {
14232
14290
  const SafeSearchField = $52FdA$depictaiutilishared.catchify((0, $29e5dbeb69da7a36$export$b94867ecbd698f21));
14233
14291
  const [sort_or_filter_open_, set_sort_or_filter_open_] = $52FdA$solidjs.createSignal(false);
14234
14292
  const [desktop_filter_elements_, set_desktop_filter_elements] = $52FdA$solidjs.createSignal();
14235
- const n_hits = $52FdA$solidjs.createMemo(() => {
14236
- var _search_results_3;
14237
- return (_search_results_3 = search_results_()) === null || _search_results_3 === void 0 ? void 0 : _search_results_3.n_hits;
14238
- });
14293
+ const countOfProductsForUI = $e335e2ff536c1a0b$export$a86bc18439445599(search_results_, all_products_loaded_, currentlyLoadedDisplays);
14239
14294
  const formatted_number_of_results_ = $068bde7fa83ac02c$export$92f2da32c6e7e7ee({
14240
- number_: n_hits,
14295
+ number_: countOfProductsForUI,
14241
14296
  i18n_: i18n_
14242
14297
  });
14243
14298
  const [sort_and_filter_element_, set_sort_and_filter_element_] = $52FdA$solidjs.createSignal();
14244
14299
  const no_results_text_ = $52FdA$solidjs.createMemo(() => {
14245
- var _search_results_4, _search_results_4$con;
14246
- return ((_search_results_4 = search_results_()) !== null && _search_results_4 !== void 0 && (_search_results_4$con = _search_results_4.content_search_links) !== null && _search_results_4$con !== void 0 && _search_results_4$con.length ? i18n_.no_products_ : i18n_.no_results_text_)();
14300
+ var _search_results_3, _search_results_3$con;
14301
+ return ((_search_results_3 = search_results_()) !== null && _search_results_3 !== void 0 && (_search_results_3$con = _search_results_3.content_search_links) !== null && _search_results_3$con !== void 0 && _search_results_3$con.length ? i18n_.no_products_ : i18n_.no_results_text_)();
14247
14302
  });
14248
14303
  const results_for = $52FdA$solidjsweb.createComponent((0, $9870a8a48ee126af$export$9dd50d35b9d94fdf), $52FdA$solidjsweb.mergeProps({
14249
14304
  get type() {
14250
14305
  return (0, $9870a8a48ee126af$export$2452208c79fe93ea).products;
14251
14306
  },
14252
- number_of_results_: n_hits
14307
+ number_of_results_: countOfProductsForUI
14253
14308
  }, {
14254
14309
  get_search_query_: get_search_query_,
14255
14310
  i18n_: i18n_,
@@ -14510,6 +14565,7 @@ function $739c927cbecd26b0$export$a54ec244c8863715(_ref) {
14510
14565
  sort_or_filter_open_: sort_or_filter_open_,
14511
14566
  id_currently_querying_for_: get_search_query_,
14512
14567
  content_blocks_by_row_: content_blocks_by_row_,
14568
+ setCurrentlyLoadedDisplays_: setCurrentlyLoadedDisplays_,
14513
14569
  no_results_options_: {
14514
14570
  selected_filters_: selected_filters_,
14515
14571
  expanded_hierarchical_filters_: expanded_hierarchical_filters_,
@@ -14552,10 +14608,7 @@ function $739c927cbecd26b0$export$a54ec244c8863715(_ref) {
14552
14608
  last_result_in_viewport_: last_result_in_viewport_,
14553
14609
  formatted_number_of_results_: formatted_number_of_results_,
14554
14610
  i18n_: i18n_,
14555
- number_of_results_: $52FdA$solidjs.createMemo(() => {
14556
- var _search_results_5;
14557
- return (_search_results_5 = search_results_()) === null || _search_results_5 === void 0 ? void 0 : _search_results_5.n_hits;
14558
- })
14611
+ number_of_results_: countOfProductsForUI
14559
14612
  });
14560
14613
  }
14561
14614
  }), _el$23, _co$10);
@@ -16175,6 +16228,8 @@ function $ede6c70ecdca46fe$export$f7d2f673fc2f091d(_ref) {
16175
16228
  const number_of_rendered_selected_filters_items_ = $52FdA$solidjs.createSignal(0);
16176
16229
  const first_result_in_viewport_ = $52FdA$solidjs.createSignal();
16177
16230
  const last_result_in_viewport_ = $52FdA$solidjs.createSignal();
16231
+ const all_products_loaded_ = $52FdA$solidjs.createSignal(false);
16232
+ const [currentlyLoadedDisplays, setCurrentlyLoadedDisplays_] = $52FdA$solidjs.createSignal(0);
16178
16233
  const [can_write_scroll_restoration_, set_can_write_scroll_restoration] = $52FdA$solidjs.createSignal(false);
16179
16234
  const products_query_base_ = $e4bc31358c414b18$export$210f130a61ac1e8d(() => {
16180
16235
  const sort_obj = get_sorting() && {
@@ -16221,6 +16276,7 @@ function $ede6c70ecdca46fe$export$f7d2f673fc2f091d(_ref) {
16221
16276
  // Make "Get Listing" request to get quicklinks, breadcrumbs, title, etc
16222
16277
  const [plp_meta] = $52FdA$solidjs.createResource(meta_query_base, $52FdA$depictaiutilisharedlatest.catchify(query => depict_api_.get_listing(query)));
16223
16278
  const contentBlocksByRow = $0c035bbe7e30b438$export$7a92d995f1bf3592(history_content_blocks_, plp_meta, content_blocks_by_row_, router_);
16279
+ const countOfProductsForUI = $e335e2ff536c1a0b$export$a86bc18439445599(plp_products_, all_products_loaded_, currentlyLoadedDisplays);
16224
16280
  const available_sortings_ = $52FdA$solidjs.createMemo(() => {
16225
16281
  var _plp_products_, _plp_products_$sorts;
16226
16282
  return (_plp_products_ = plp_products_()) === null || _plp_products_ === void 0 ? void 0 : (_plp_products_$sorts = _plp_products_.sorts) === null || _plp_products_$sorts === void 0 ? void 0 : _plp_products_$sorts.map(sort => {
@@ -16247,10 +16303,7 @@ function $ede6c70ecdca46fe$export$f7d2f673fc2f091d(_ref) {
16247
16303
  const [sort_or_filter_open_, set_sort_or_filter_open_] = $52FdA$solidjs.createSignal(false);
16248
16304
  const [desktop_filter_elements_, set_desktop_filter_elements] = $52FdA$solidjs.createSignal();
16249
16305
  const formatted_number_of_results_ = $068bde7fa83ac02c$export$92f2da32c6e7e7ee({
16250
- number_: $52FdA$solidjs.createMemo(() => {
16251
- var _plp_products_3;
16252
- return (_plp_products_3 = plp_products_()) === null || _plp_products_3 === void 0 ? void 0 : _plp_products_3.n_hits;
16253
- }),
16306
+ number_: countOfProductsForUI,
16254
16307
  i18n_: i18n_
16255
16308
  });
16256
16309
  const [sort_and_filter_element_, set_sort_and_filter_element_] = $52FdA$solidjs.createSignal();
@@ -16273,10 +16326,7 @@ function $ede6c70ecdca46fe$export$f7d2f673fc2f091d(_ref) {
16273
16326
  last_result_in_viewport_: last_result_in_viewport_,
16274
16327
  formatted_number_of_results_: formatted_number_of_results_,
16275
16328
  i18n_: i18n_,
16276
- number_of_results_: $52FdA$solidjs.createMemo(() => {
16277
- var _plp_products_4;
16278
- return (_plp_products_4 = plp_products_()) === null || _plp_products_4 === void 0 ? void 0 : _plp_products_4.n_hits;
16279
- }),
16329
+ number_of_results_: countOfProductsForUI,
16280
16330
  ...extraProps
16281
16331
  });
16282
16332
  }
@@ -16303,8 +16353,7 @@ function $ede6c70ecdca46fe$export$f7d2f673fc2f091d(_ref) {
16303
16353
  }), _el$4, _co$);
16304
16354
  $52FdA$solidjsweb.insert(_el$, $52FdA$solidjsweb.createComponent((0, $52FdA$solidjs.Show), {
16305
16355
  get when() {
16306
- var _plp_products_5;
16307
- return ((_plp_products_5 = plp_products_()) === null || _plp_products_5 === void 0 ? void 0 : _plp_products_5.n_hits) === 1;
16356
+ return countOfProductsForUI() === 1;
16308
16357
  },
16309
16358
  get fallback() {
16310
16359
  return i18n_.products_();
@@ -16512,6 +16561,8 @@ function $ede6c70ecdca46fe$export$f7d2f673fc2f091d(_ref) {
16512
16561
  content_blocks_by_row_: contentBlocksByRow,
16513
16562
  ConfiguredScrollStatus_: ConfiguredScrollStatus_,
16514
16563
  id_currently_querying_for_: id_to_query_for_,
16564
+ setCurrentlyLoadedDisplays_: setCurrentlyLoadedDisplays_,
16565
+ all_products_loaded_: all_products_loaded_,
16515
16566
  no_results_options_: {
16516
16567
  selected_filters_: selected_filters_,
16517
16568
  expanded_hierarchical_filters_: expanded_hierarchical_filters_,
package/ES10/index.d.ts CHANGED
@@ -11,7 +11,7 @@ import { GetListingRequest } from "@depict-ai/types/api/GetListingRequest";
11
11
  import { BaseSearchRequestV3 } from "@depict-ai/types/api/BaseSearchRequestV3";
12
12
  import { FeaturedInDisplay } from "@depict-ai/types/api/FeaturedInResponseV3";
13
13
  import { SearchFilter as _SearchFilter3 } from "@depict-ai/types/api/SearchRequestV2";
14
- export const version = "4.8.4";
14
+ export const version = "4.8.6";
15
15
  /**
16
16
  * Returns two accessors (one width and one height) that will update when the size of the provided element changes, to be used with ResponsiveImg
17
17
  */
package/ES10/index.js CHANGED
@@ -10,7 +10,7 @@ import $8tj43$babelruntimehelpersclassPrivateFieldGet from "@babel/runtime/helpe
10
10
  /*! Depict.ai search and product listing SDK */
11
11
  import { register_es_version } from "../multi_import_deduplicator.mjs";
12
12
  register_es_version("ui", "ES10");
13
- const $8db9a15135765c11$export$83d89fbfd8236492 = "4.8.4";
13
+ const $8db9a15135765c11$export$83d89fbfd8236492 = "4.8.6";
14
14
  function $4be619ec2cd7bba3$export$54c6d6ff54e72743(whatToWatch) {
15
15
  const [width, setWidth] = $8tj43$createSignal(0);
16
16
  const [height, setHeight] = $8tj43$createSignal(0);
@@ -3153,10 +3153,10 @@ function $43fbdca0f726a34b$export$92f2da32c6e7e7ee(_ref) {
3153
3153
  i18n_: i18n_
3154
3154
  } = _ref;
3155
3155
  return $8tj43$createMemo(() => {
3156
- const n_hits = number_();
3157
- if (isNaN(n_hits)) return "";
3156
+ const numberToFormat = number_();
3157
+ if (isNaN(numberToFormat)) return "";
3158
3158
  const price_formatting = i18n_.price_formatting_();
3159
- return $8tj43$standard_price_format(n_hits, 0,
3159
+ return $8tj43$standard_price_format(numberToFormat, 0,
3160
3160
  // we never want places after comma here it looks weird as hell
3161
3161
  price_formatting.decimal_places_delimiter_, price_formatting.thousands_delimiter_);
3162
3162
  });
@@ -4246,7 +4246,8 @@ function $584c06c09cf4609d$export$b94867ecbd698f21(_ref) {
4246
4246
  });
4247
4247
  }
4248
4248
  }, () => searchFieldEmpty() ? {
4249
- "aria-hidden": "true"
4249
+ "aria-hidden": "true",
4250
+ tabIndex: -1
4250
4251
  } : {
4251
4252
  title: i18n_.clear_filters_query_sorting_after_submit_()
4252
4253
  }), false, true);
@@ -5685,9 +5686,10 @@ function $06fcd2a345efd24d$var$RawSearchModalV2(_ref) {
5685
5686
  });
5686
5687
  // total number of results = content results + product results + category suggestions
5687
5688
  const totalNumberResults = $8tj43$createMemo(() => {
5688
- var _get_modal_search_res4, _results$content_sear, _listing_suggestions_;
5689
+ var _get_modal_search_res4, _results$displays, _results$content_sear, _listing_suggestions_;
5689
5690
  const results = (_get_modal_search_res4 = get_modal_search_results_()) === null || _get_modal_search_res4 === void 0 ? void 0 : _get_modal_search_res4();
5690
- const hits = results === null || results === void 0 ? void 0 : results.n_hits;
5691
+ // Show actual number of result (more accurate) if there's no cursor (backend doesn't have more products)
5692
+ const hits = results !== null && results !== void 0 && results.cursor ? results === null || results === void 0 ? void 0 : results.n_hits : results === null || results === void 0 ? void 0 : (_results$displays = results.displays) === null || _results$displays === void 0 ? void 0 : _results$displays.length;
5691
5693
  const content_results = content_search_enabled_() && (results === null || results === void 0 ? void 0 : (_results$content_sear = results.content_search_links) === null || _results$content_sear === void 0 ? void 0 : _results$content_sear.length) || 0;
5692
5694
  const category_results = ((_listing_suggestions_ = listing_suggestions_()) === null || _listing_suggestions_ === void 0 ? void 0 : _listing_suggestions_.length) || 0;
5693
5695
  return (hits !== null && hits !== void 0 ? hits : 0) + content_results + category_results;
@@ -6230,6 +6232,7 @@ async function $d5f1e6a0f9117286$export$79b1565500412d9b(search_modal, modal_fn_
6230
6232
  close_modal_: close_modal_
6231
6233
  };
6232
6234
  }
6235
+ let $972f6bce0f9d61be$export$68620bd6d5c6bb86;
6233
6236
  function $972f6bce0f9d61be$export$e183a13865960371(params_to_default_value, router_) {
6234
6237
  const signals = {};
6235
6238
  const entries = Object.entries(params_to_default_value);
@@ -6262,6 +6265,10 @@ function $972f6bce0f9d61be$export$e183a13865960371(params_to_default_value, rout
6262
6265
  }
6263
6266
  }
6264
6267
  if (signal_changed) router_.navigate_.replace_state_(state);
6268
+ $8tj43$onCleanup(() => $972f6bce0f9d61be$export$68620bd6d5c6bb86 = {
6269
+ time: new Date().toISOString(),
6270
+ stack: new Error().stack
6271
+ });
6265
6272
  });
6266
6273
  // history_dot_state_to_state needs to update after its signals after url_state does BUT in the same task (might even have to be in the same tick in the microtask queue). If we'd use window.addEventListener("popstate") it would be guaranteed to be too late since each event listener has its own task
6267
6274
  (0, $8tj43$instant_exec_on_suspect_history_change).add(event_handler);
@@ -9985,8 +9992,16 @@ function $44aa24b1bb793549$export$b288c38ae3fddb56(_ref) {
9985
9992
  selected_filters_: [read_selected_filters]
9986
9993
  } = _ref;
9987
9994
  let last_remote_state;
9995
+ let executions = 0;
9996
+ let oneSecondInfiniteLoopPreventionTimeout;
9988
9997
  $8tj43$createComputed(() => {
9989
9998
  var _available_filters_;
9999
+ // Sometimes (24 events in sentry, https://depictai-0o.sentry.io/issues/?project=5476183&query=is%3Aunresolved+filters+failed&referrer=issue-list&statsPeriod=14d), for some inexplicable reason, this computation infinite loops
10000
+ // I spent a 1h17min debug session with MadePeople in a tab where they could reproduce
10001
+ // Observations were that of the signal read_local_cache the observers at some point randomly started having this computation first instead of the effect that writes the value to the history
10002
+ // It's VERY HARD to get a tab in a state where it can be reproduced, like with the exact same circumstances it happens "once a day" for them and there's no noticable pattern. But when a tab is found, it can be reliably reproduced by going backwards/forwards.
10003
+ // Also we reliably clean up and dispose of the search page and the effect of history_dot_state_to_state stays in the signals' observers, but for some reason it disappears when the bug happens (onCleanup doesn't get called then either, if I debugged that correctly)
10004
+ // As a value first workaround, we just recognise when the computation has been executed "too often" and just start not doing anything after that
9990
10005
  const remote_filters = Object.fromEntries(((_available_filters_ = available_filters_()) === null || _available_filters_ === void 0 ? void 0 : _available_filters_.map(filter => {
9991
10006
  var _filter$meta;
9992
10007
  return [JSON.stringify([filter.field, filter.op, filter === null || filter === void 0 ? void 0 : (_filter$meta = filter.meta) === null || _filter$meta === void 0 ? void 0 : _filter$meta.type]), filter];
@@ -10093,9 +10108,36 @@ function $44aa24b1bb793549$export$b288c38ae3fddb56(_ref) {
10093
10108
  }
10094
10109
  if (last_remote_state !== available_filters_() ||
10095
10110
  // we HAVE to update the local filter state (it can contain same info but needs to be different object reference) every time the API state changes, otherwise the CheckboxHierarchicalFilter component doesn't update
10096
- JSON.stringify(new_local_filter_state) !== JSON.stringify(read_local_cache()))
10097
- // Sorry……… They're not that big
10111
+ // Sorry……… They're not that big
10112
+ JSON.stringify(new_local_filter_state) !== JSON.stringify(read_local_cache())) {
10113
+ var _sources, _sources$find;
10114
+ const owner = $8tj43$getOwner();
10115
+ const signal = owner === null || owner === void 0 ? void 0 : (_sources = owner.sources) === null || _sources === void 0 ? void 0 : (_sources$find = _sources.find) === null || _sources$find === void 0 ? void 0 : _sources$find.call(_sources, source => source.value === read_local_cache());
10116
+ if (executions > 30) {
10117
+ var _signal$observers, _signal$observers$map;
10118
+ // We're probably in an infinite loop, let's just stop
10119
+ $8tj43$report(new Error("Infinite loop detected in create_modified_filters"), "error", {
10120
+ executions: executions,
10121
+ new_local_filter_state: new_local_filter_state,
10122
+ available_filters: available_filters_(),
10123
+ last_remote_state: last_remote_state,
10124
+ history_length: history.length,
10125
+ location: location.href,
10126
+ foundSignal: !!signal,
10127
+ observerSlots: signal === null || signal === void 0 ? void 0 : signal.observerSlots,
10128
+ observers: signal === null || signal === void 0 ? void 0 : (_signal$observers = signal.observers) === null || _signal$observers === void 0 ? void 0 : (_signal$observers$map = _signal$observers.map) === null || _signal$observers$map === void 0 ? void 0 : _signal$observers$map.call(_signal$observers, o => (o === null || o === void 0 ? void 0 : o.fn) + ""),
10129
+ lastHistoryDotStateToStateCleanupInfo: $972f6bce0f9d61be$export$68620bd6d5c6bb86
10130
+ });
10131
+ return;
10132
+ }
10098
10133
  write_local_cache(new_local_filter_state);
10134
+ // Keep track how many times we wrote this signal
10135
+ executions++;
10136
+ oneSecondInfiniteLoopPreventionTimeout || (oneSecondInfiniteLoopPreventionTimeout = setTimeout($8tj43$catchify(() => {
10137
+ executions = 0;
10138
+ oneSecondInfiniteLoopPreventionTimeout = undefined;
10139
+ }), 1000));
10140
+ }
10099
10141
  last_remote_state = available_filters_();
10100
10142
  });
10101
10143
  }
@@ -11923,7 +11965,8 @@ function $45a8953d760b5e58$export$a1fd619a4743ca08(_ref) {
11923
11965
  query_base_: query_base_,
11924
11966
  depict_api_: depict_api_,
11925
11967
  is_loading_: is_loading_,
11926
- content_blocks_: content_blocks_
11968
+ content_blocks_: content_blocks_,
11969
+ setCurrentlyLoadedDisplays_: setCurrentlyLoadedDisplays_
11927
11970
  } = _ref;
11928
11971
  // Although typing doesn't reflect it, plp_results is guaranteed to contain an array of at least one display at this point
11929
11972
  const [get_extra_displays, set_extra_displays_] = $8tj43$createSignal([], {
@@ -11950,6 +11993,7 @@ function $45a8953d760b5e58$export$a1fd619a4743ca08(_ref) {
11950
11993
  is_loading_: is_loading_,
11951
11994
  get_extra_displays: get_extra_displays
11952
11995
  });
11996
+ $8tj43$createComputed(() => setCurrentlyLoadedDisplays_(displays_by_key_().size));
11953
11997
  $6d2962bc9370f884$export$5e4aed86c12acdd9({
11954
11998
  percentage_in_view_: percentage_in_view_,
11955
11999
  set_extra_displays_: set_extra_displays_,
@@ -12010,7 +12054,8 @@ function $7faea0096f14b59b$export$3925f87b1545cfc6(_ref) {
12010
12054
  layout_options_: layout_options_,
12011
12055
  id_currently_querying_for_: id_currently_querying_for_,
12012
12056
  content_blocks_by_row_: content_blocks_by_row_,
12013
- ConfiguredScrollStatus_: ConfiguredScrollStatus_
12057
+ ConfiguredScrollStatus_: ConfiguredScrollStatus_,
12058
+ setCurrentlyLoadedDisplays_: setCurrentlyLoadedDisplays_
12014
12059
  } = _ref;
12015
12060
  // The plp_results_ resource will be delayed because we're using createBatchedMemo to not make triplicate API requests, but we need to show the placeholders before already to match Chrome and Firefox's "content has to be there, ready for scroll restoration, before all popstate tasks have been completed"-requirement
12016
12061
  const is_loading_ = $8tj43$createMemo(() => plp_results_.loading || query_base_.loading);
@@ -12147,7 +12192,8 @@ function $7faea0096f14b59b$export$3925f87b1545cfc6(_ref) {
12147
12192
  query_base_: query_base_,
12148
12193
  depict_api_: depict_api_,
12149
12194
  is_loading_: is_loading_,
12150
- content_blocks_: content_blocks_
12195
+ content_blocks_: content_blocks_,
12196
+ setCurrentlyLoadedDisplays_: setCurrentlyLoadedDisplays_
12151
12197
  });
12152
12198
  $8tj43$onCleanup(() => suspense_contents = undefined);
12153
12199
  return suspense_contents;
@@ -14009,6 +14055,17 @@ function $937791b86d3d1509$export$44f738469d5570cf(_ref) {
14009
14055
  };
14010
14056
  });
14011
14057
  }
14058
+ function $0728458b46ee9d32$export$a86bc18439445599(plp_products_, _ref, currentlyLoadedDisplays) {
14059
+ let [allProductsLoaded] = _ref;
14060
+ return $8tj43$createMemo(() => {
14061
+ var _plp_products_;
14062
+ const backendSays = (_plp_products_ = plp_products_()) === null || _plp_products_ === void 0 ? void 0 : _plp_products_.n_hits;
14063
+ const loadedAll = allProductsLoaded();
14064
+ if (!backendSays || !loadedAll) return backendSays;
14065
+ // People can remove displays in the displayTransformers, for example houdini do it (https://depictaiworkspace.slack.com/archives/C061H2TF7K4/p1713261063439089). Correct the n_hits as well as possible in that case.
14066
+ return currentlyLoadedDisplays();
14067
+ });
14068
+ }
14012
14069
  var $da279c5a540c6846$var$_tmpl$ = /*#__PURE__*/$8tj43$template(`<div class=filter-results-for-one-row><!$><!/><!$><!/>`),
14013
14070
  $da279c5a540c6846$var$_tmpl$2 = /*#__PURE__*/$8tj43$template(`<div><div class=listing-page><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/></div><!$><!/><!$><!/>`);
14014
14071
  function $da279c5a540c6846$export$a54ec244c8863715(_ref) {
@@ -14050,6 +14107,7 @@ function $da279c5a540c6846$export$a54ec244c8863715(_ref) {
14050
14107
  } = _ref;
14051
14108
  const [get_sorting] = current_sorting_;
14052
14109
  const all_products_loaded_ = $8tj43$createSignal(false);
14110
+ const [currentlyLoadedDisplays, setCurrentlyLoadedDisplays_] = $8tj43$createSignal(0);
14053
14111
  const [get_all_products_loaded, set_all_products_loaded] = all_products_loaded_;
14054
14112
  const number_of_rendered_selected_filters_items_ = $8tj43$createSignal(0);
14055
14113
  const first_result_in_viewport_ = $8tj43$createSignal();
@@ -14128,24 +14186,21 @@ function $da279c5a540c6846$export$a54ec244c8863715(_ref) {
14128
14186
  const SafeSearchField = $8tj43$catchify((0, $584c06c09cf4609d$export$b94867ecbd698f21));
14129
14187
  const [sort_or_filter_open_, set_sort_or_filter_open_] = $8tj43$createSignal(false);
14130
14188
  const [desktop_filter_elements_, set_desktop_filter_elements] = $8tj43$createSignal();
14131
- const n_hits = $8tj43$createMemo(() => {
14132
- var _search_results_3;
14133
- return (_search_results_3 = search_results_()) === null || _search_results_3 === void 0 ? void 0 : _search_results_3.n_hits;
14134
- });
14189
+ const countOfProductsForUI = $0728458b46ee9d32$export$a86bc18439445599(search_results_, all_products_loaded_, currentlyLoadedDisplays);
14135
14190
  const formatted_number_of_results_ = $43fbdca0f726a34b$export$92f2da32c6e7e7ee({
14136
- number_: n_hits,
14191
+ number_: countOfProductsForUI,
14137
14192
  i18n_: i18n_
14138
14193
  });
14139
14194
  const [sort_and_filter_element_, set_sort_and_filter_element_] = $8tj43$createSignal();
14140
14195
  const no_results_text_ = $8tj43$createMemo(() => {
14141
- var _search_results_4, _search_results_4$con;
14142
- return ((_search_results_4 = search_results_()) !== null && _search_results_4 !== void 0 && (_search_results_4$con = _search_results_4.content_search_links) !== null && _search_results_4$con !== void 0 && _search_results_4$con.length ? i18n_.no_products_ : i18n_.no_results_text_)();
14196
+ var _search_results_3, _search_results_3$con;
14197
+ return ((_search_results_3 = search_results_()) !== null && _search_results_3 !== void 0 && (_search_results_3$con = _search_results_3.content_search_links) !== null && _search_results_3$con !== void 0 && _search_results_3$con.length ? i18n_.no_products_ : i18n_.no_results_text_)();
14143
14198
  });
14144
14199
  const results_for = $8tj43$createComponent((0, $69602b3d8fd54c38$export$9dd50d35b9d94fdf), $8tj43$mergeProps({
14145
14200
  get type() {
14146
14201
  return (0, $69602b3d8fd54c38$export$2452208c79fe93ea).products;
14147
14202
  },
14148
- number_of_results_: n_hits
14203
+ number_of_results_: countOfProductsForUI
14149
14204
  }, {
14150
14205
  get_search_query_: get_search_query_,
14151
14206
  i18n_: i18n_,
@@ -14406,6 +14461,7 @@ function $da279c5a540c6846$export$a54ec244c8863715(_ref) {
14406
14461
  sort_or_filter_open_: sort_or_filter_open_,
14407
14462
  id_currently_querying_for_: get_search_query_,
14408
14463
  content_blocks_by_row_: content_blocks_by_row_,
14464
+ setCurrentlyLoadedDisplays_: setCurrentlyLoadedDisplays_,
14409
14465
  no_results_options_: {
14410
14466
  selected_filters_: selected_filters_,
14411
14467
  expanded_hierarchical_filters_: expanded_hierarchical_filters_,
@@ -14448,10 +14504,7 @@ function $da279c5a540c6846$export$a54ec244c8863715(_ref) {
14448
14504
  last_result_in_viewport_: last_result_in_viewport_,
14449
14505
  formatted_number_of_results_: formatted_number_of_results_,
14450
14506
  i18n_: i18n_,
14451
- number_of_results_: $8tj43$createMemo(() => {
14452
- var _search_results_5;
14453
- return (_search_results_5 = search_results_()) === null || _search_results_5 === void 0 ? void 0 : _search_results_5.n_hits;
14454
- })
14507
+ number_of_results_: countOfProductsForUI
14455
14508
  });
14456
14509
  }
14457
14510
  }), _el$23, _co$10);
@@ -16071,6 +16124,8 @@ function $4b4b262708b516ee$export$f7d2f673fc2f091d(_ref) {
16071
16124
  const number_of_rendered_selected_filters_items_ = $8tj43$createSignal(0);
16072
16125
  const first_result_in_viewport_ = $8tj43$createSignal();
16073
16126
  const last_result_in_viewport_ = $8tj43$createSignal();
16127
+ const all_products_loaded_ = $8tj43$createSignal(false);
16128
+ const [currentlyLoadedDisplays, setCurrentlyLoadedDisplays_] = $8tj43$createSignal(0);
16074
16129
  const [can_write_scroll_restoration_, set_can_write_scroll_restoration] = $8tj43$createSignal(false);
16075
16130
  const products_query_base_ = $ec225bf1f1627ea8$export$210f130a61ac1e8d(() => {
16076
16131
  const sort_obj = get_sorting() && {
@@ -16117,6 +16172,7 @@ function $4b4b262708b516ee$export$f7d2f673fc2f091d(_ref) {
16117
16172
  // Make "Get Listing" request to get quicklinks, breadcrumbs, title, etc
16118
16173
  const [plp_meta] = $8tj43$createResource(meta_query_base, $8tj43$catchify1(query => depict_api_.get_listing(query)));
16119
16174
  const contentBlocksByRow = $12ff24fdc4b26d88$export$7a92d995f1bf3592(history_content_blocks_, plp_meta, content_blocks_by_row_, router_);
16175
+ const countOfProductsForUI = $0728458b46ee9d32$export$a86bc18439445599(plp_products_, all_products_loaded_, currentlyLoadedDisplays);
16120
16176
  const available_sortings_ = $8tj43$createMemo(() => {
16121
16177
  var _plp_products_, _plp_products_$sorts;
16122
16178
  return (_plp_products_ = plp_products_()) === null || _plp_products_ === void 0 ? void 0 : (_plp_products_$sorts = _plp_products_.sorts) === null || _plp_products_$sorts === void 0 ? void 0 : _plp_products_$sorts.map(sort => {
@@ -16143,10 +16199,7 @@ function $4b4b262708b516ee$export$f7d2f673fc2f091d(_ref) {
16143
16199
  const [sort_or_filter_open_, set_sort_or_filter_open_] = $8tj43$createSignal(false);
16144
16200
  const [desktop_filter_elements_, set_desktop_filter_elements] = $8tj43$createSignal();
16145
16201
  const formatted_number_of_results_ = $43fbdca0f726a34b$export$92f2da32c6e7e7ee({
16146
- number_: $8tj43$createMemo(() => {
16147
- var _plp_products_3;
16148
- return (_plp_products_3 = plp_products_()) === null || _plp_products_3 === void 0 ? void 0 : _plp_products_3.n_hits;
16149
- }),
16202
+ number_: countOfProductsForUI,
16150
16203
  i18n_: i18n_
16151
16204
  });
16152
16205
  const [sort_and_filter_element_, set_sort_and_filter_element_] = $8tj43$createSignal();
@@ -16169,10 +16222,7 @@ function $4b4b262708b516ee$export$f7d2f673fc2f091d(_ref) {
16169
16222
  last_result_in_viewport_: last_result_in_viewport_,
16170
16223
  formatted_number_of_results_: formatted_number_of_results_,
16171
16224
  i18n_: i18n_,
16172
- number_of_results_: $8tj43$createMemo(() => {
16173
- var _plp_products_4;
16174
- return (_plp_products_4 = plp_products_()) === null || _plp_products_4 === void 0 ? void 0 : _plp_products_4.n_hits;
16175
- }),
16225
+ number_of_results_: countOfProductsForUI,
16176
16226
  ...extraProps
16177
16227
  });
16178
16228
  }
@@ -16199,8 +16249,7 @@ function $4b4b262708b516ee$export$f7d2f673fc2f091d(_ref) {
16199
16249
  }), _el$4, _co$);
16200
16250
  $8tj43$insert(_el$, $8tj43$createComponent((0, $8tj43$Show), {
16201
16251
  get when() {
16202
- var _plp_products_5;
16203
- return ((_plp_products_5 = plp_products_()) === null || _plp_products_5 === void 0 ? void 0 : _plp_products_5.n_hits) === 1;
16252
+ return countOfProductsForUI() === 1;
16204
16253
  },
16205
16254
  get fallback() {
16206
16255
  return i18n_.products_();
@@ -16408,6 +16457,8 @@ function $4b4b262708b516ee$export$f7d2f673fc2f091d(_ref) {
16408
16457
  content_blocks_by_row_: contentBlocksByRow,
16409
16458
  ConfiguredScrollStatus_: ConfiguredScrollStatus_,
16410
16459
  id_currently_querying_for_: id_to_query_for_,
16460
+ setCurrentlyLoadedDisplays_: setCurrentlyLoadedDisplays_,
16461
+ all_products_loaded_: all_products_loaded_,
16411
16462
  no_results_options_: {
16412
16463
  selected_filters_: selected_filters_,
16413
16464
  expanded_hierarchical_filters_: expanded_hierarchical_filters_,