@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/latest/index.cjs CHANGED
@@ -108,7 +108,7 @@ $parcel$export(module.exports, "BreadCrumbs", () => $1f4925833f07df29$export$5b7
108
108
  $parcel$export(module.exports, "QuickLinks", () => $1f4925833f07df29$export$de035477d6fef996);
109
109
  $parcel$export(module.exports, "CategoryPage", () => $14f289047713d67a$export$e2bf8ce7779e827e);
110
110
  /*! Depict.ai search and product listing SDK */
111
- const $b757f75811f3261f$export$83d89fbfd8236492 = "4.8.4";
111
+ const $b757f75811f3261f$export$83d89fbfd8236492 = "4.8.6";
112
112
  function $128302ab61dab8f1$export$54c6d6ff54e72743(whatToWatch) {
113
113
  const [width, setWidth] = $gVhhF$solidjs.createSignal(0);
114
114
  const [height, setHeight] = $gVhhF$solidjs.createSignal(0);
@@ -3088,10 +3088,10 @@ function $0f400c3f7248d5f1$export$92f2da32c6e7e7ee({
3088
3088
  i18n_: i18n_
3089
3089
  }) {
3090
3090
  return $gVhhF$solidjs.createMemo(() => {
3091
- const n_hits = number_();
3092
- if (isNaN(n_hits)) return "";
3091
+ const numberToFormat = number_();
3092
+ if (isNaN(numberToFormat)) return "";
3093
3093
  const price_formatting = i18n_.price_formatting_();
3094
- return $gVhhF$depictaiutilishared.standard_price_format(n_hits, 0,
3094
+ return $gVhhF$depictaiutilishared.standard_price_format(numberToFormat, 0,
3095
3095
  // we never want places after comma here it looks weird as hell
3096
3096
  price_formatting.decimal_places_delimiter_, price_formatting.thousands_delimiter_);
3097
3097
  });
@@ -4128,7 +4128,8 @@ function $66b8b9a9613c141d$export$b94867ecbd698f21({
4128
4128
  });
4129
4129
  }
4130
4130
  }, () => searchFieldEmpty() ? {
4131
- "aria-hidden": "true"
4131
+ "aria-hidden": "true",
4132
+ tabIndex: -1
4132
4133
  } : {
4133
4134
  title: i18n_.clear_filters_query_sorting_after_submit_()
4134
4135
  }), false, true);
@@ -5518,7 +5519,8 @@ function $11597ae03e703a47$var$RawSearchModalV2({
5518
5519
  // total number of results = content results + product results + category suggestions
5519
5520
  const totalNumberResults = $gVhhF$solidjs.createMemo(() => {
5520
5521
  const results = get_modal_search_results_()?.();
5521
- const hits = results?.n_hits;
5522
+ // Show actual number of result (more accurate) if there's no cursor (backend doesn't have more products)
5523
+ const hits = results?.cursor ? results?.n_hits : results?.displays?.length;
5522
5524
  const content_results = content_search_enabled_() && results?.content_search_links?.length || 0;
5523
5525
  const category_results = listing_suggestions_()?.length || 0;
5524
5526
  return (hits ?? 0) + content_results + category_results;
@@ -6044,6 +6046,7 @@ async function $9abb0a35d4b60ed3$export$79b1565500412d9b(search_modal, modal_fn_
6044
6046
  close_modal_: close_modal_
6045
6047
  };
6046
6048
  }
6049
+ let $6e22b5314fb52f4c$export$68620bd6d5c6bb86;
6047
6050
  function $6e22b5314fb52f4c$export$e183a13865960371(params_to_default_value, router_) {
6048
6051
  const signals = {};
6049
6052
  const entries = Object.entries(params_to_default_value);
@@ -6075,6 +6078,10 @@ function $6e22b5314fb52f4c$export$e183a13865960371(params_to_default_value, rout
6075
6078
  }
6076
6079
  }
6077
6080
  if (signal_changed) router_.navigate_.replace_state_(state);
6081
+ $gVhhF$solidjs.onCleanup(() => $6e22b5314fb52f4c$export$68620bd6d5c6bb86 = {
6082
+ time: new Date().toISOString(),
6083
+ stack: new Error().stack
6084
+ });
6078
6085
  });
6079
6086
  // 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
6080
6087
  (0, $gVhhF$depictaiutilishared.instant_exec_on_suspect_history_change).add(event_handler);
@@ -9589,7 +9596,15 @@ function $70482f04605572e2$export$b288c38ae3fddb56({
9589
9596
  selected_filters_: [read_selected_filters]
9590
9597
  }) {
9591
9598
  let last_remote_state;
9599
+ let executions = 0;
9600
+ let oneSecondInfiniteLoopPreventionTimeout;
9592
9601
  $gVhhF$solidjs.createComputed(() => {
9602
+ // 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
9603
+ // I spent a 1h17min debug session with MadePeople in a tab where they could reproduce
9604
+ // 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
9605
+ // 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.
9606
+ // 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)
9607
+ // As a value first workaround, we just recognise when the computation has been executed "too often" and just start not doing anything after that
9593
9608
  const remote_filters = Object.fromEntries(available_filters_()?.map(filter => [JSON.stringify([filter.field, filter.op, filter?.meta?.type]), filter]) || []);
9594
9609
  const local_filters = Object.fromEntries(read_local_cache().map(filter => [JSON.stringify([filter.field, filter.op, filter?.meta?.type]), filter]));
9595
9610
  const selected_filters = Object.fromEntries(read_selected_filters().map(filter_obj => [JSON.stringify([filter_obj.field, filter_obj.op]), filter_obj]));
@@ -9672,9 +9687,34 @@ function $70482f04605572e2$export$b288c38ae3fddb56({
9672
9687
  }
9673
9688
  if (last_remote_state !== available_filters_() ||
9674
9689
  // 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
9675
- JSON.stringify(new_local_filter_state) !== JSON.stringify(read_local_cache()))
9676
- // Sorry……… They're not that big
9690
+ // Sorry……… They're not that big
9691
+ JSON.stringify(new_local_filter_state) !== JSON.stringify(read_local_cache())) {
9692
+ const owner = $gVhhF$solidjs.getOwner();
9693
+ const signal = owner?.sources?.find?.(source => source.value === read_local_cache());
9694
+ if (executions > 30) {
9695
+ // We're probably in an infinite loop, let's just stop
9696
+ $gVhhF$depictaiutilishared.report(new Error("Infinite loop detected in create_modified_filters"), "error", {
9697
+ executions: executions,
9698
+ new_local_filter_state: new_local_filter_state,
9699
+ available_filters: available_filters_(),
9700
+ last_remote_state: last_remote_state,
9701
+ history_length: history.length,
9702
+ location: location.href,
9703
+ foundSignal: !!signal,
9704
+ observerSlots: signal?.observerSlots,
9705
+ observers: signal?.observers?.map?.(o => o?.fn + ""),
9706
+ lastHistoryDotStateToStateCleanupInfo: $6e22b5314fb52f4c$export$68620bd6d5c6bb86
9707
+ });
9708
+ return;
9709
+ }
9677
9710
  write_local_cache(new_local_filter_state);
9711
+ // Keep track how many times we wrote this signal
9712
+ executions++;
9713
+ oneSecondInfiniteLoopPreventionTimeout ||= setTimeout($gVhhF$depictaiutilishared.catchify(() => {
9714
+ executions = 0;
9715
+ oneSecondInfiniteLoopPreventionTimeout = undefined;
9716
+ }), 1000);
9717
+ }
9678
9718
  last_remote_state = available_filters_();
9679
9719
  });
9680
9720
  }
@@ -11323,7 +11363,8 @@ function $ac167f6af6a48fc3$export$a1fd619a4743ca08({
11323
11363
  query_base_: query_base_,
11324
11364
  depict_api_: depict_api_,
11325
11365
  is_loading_: is_loading_,
11326
- content_blocks_: content_blocks_
11366
+ content_blocks_: content_blocks_,
11367
+ setCurrentlyLoadedDisplays_: setCurrentlyLoadedDisplays_
11327
11368
  }) {
11328
11369
  // Although typing doesn't reflect it, plp_results is guaranteed to contain an array of at least one display at this point
11329
11370
  const [get_extra_displays, set_extra_displays_] = $gVhhF$solidjs.createSignal([], {
@@ -11347,6 +11388,7 @@ function $ac167f6af6a48fc3$export$a1fd619a4743ca08({
11347
11388
  is_loading_: is_loading_,
11348
11389
  get_extra_displays: get_extra_displays
11349
11390
  });
11391
+ $gVhhF$solidjs.createComputed(() => setCurrentlyLoadedDisplays_(displays_by_key_().size));
11350
11392
  $3f08fe2992a2a8ca$export$5e4aed86c12acdd9({
11351
11393
  percentage_in_view_: percentage_in_view_,
11352
11394
  set_extra_displays_: set_extra_displays_,
@@ -11402,7 +11444,8 @@ function $fe76fb463cc60b89$export$3925f87b1545cfc6({
11402
11444
  layout_options_: layout_options_,
11403
11445
  id_currently_querying_for_: id_currently_querying_for_,
11404
11446
  content_blocks_by_row_: content_blocks_by_row_,
11405
- ConfiguredScrollStatus_: ConfiguredScrollStatus_
11447
+ ConfiguredScrollStatus_: ConfiguredScrollStatus_,
11448
+ setCurrentlyLoadedDisplays_: setCurrentlyLoadedDisplays_
11406
11449
  }) {
11407
11450
  // 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
11408
11451
  const is_loading_ = $gVhhF$solidjs.createMemo(() => plp_results_.loading || query_base_.loading);
@@ -11533,7 +11576,8 @@ function $fe76fb463cc60b89$export$3925f87b1545cfc6({
11533
11576
  query_base_: query_base_,
11534
11577
  depict_api_: depict_api_,
11535
11578
  is_loading_: is_loading_,
11536
- content_blocks_: content_blocks_
11579
+ content_blocks_: content_blocks_,
11580
+ setCurrentlyLoadedDisplays_: setCurrentlyLoadedDisplays_
11537
11581
  });
11538
11582
  $gVhhF$solidjs.onCleanup(() => suspense_contents = undefined);
11539
11583
  return suspense_contents;
@@ -13300,6 +13344,15 @@ function $5cbaffcb5602e671$export$44f738469d5570cf({
13300
13344
  };
13301
13345
  });
13302
13346
  }
13347
+ function $13796d59ea8af231$export$a86bc18439445599(plp_products_, [allProductsLoaded], currentlyLoadedDisplays) {
13348
+ return $gVhhF$solidjs.createMemo(() => {
13349
+ const backendSays = plp_products_()?.n_hits;
13350
+ const loadedAll = allProductsLoaded();
13351
+ if (!backendSays || !loadedAll) return backendSays;
13352
+ // 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.
13353
+ return currentlyLoadedDisplays();
13354
+ });
13355
+ }
13303
13356
  var $f1d7cb69f839a526$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=filter-results-for-one-row><!$><!/><!$><!/>`),
13304
13357
  $f1d7cb69f839a526$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div><div class=listing-page><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/></div><!$><!/><!$><!/>`);
13305
13358
  function $f1d7cb69f839a526$export$a54ec244c8863715({
@@ -13340,6 +13393,7 @@ function $f1d7cb69f839a526$export$a54ec244c8863715({
13340
13393
  }) {
13341
13394
  const [get_sorting] = current_sorting_;
13342
13395
  const all_products_loaded_ = $gVhhF$solidjs.createSignal(false);
13396
+ const [currentlyLoadedDisplays, setCurrentlyLoadedDisplays_] = $gVhhF$solidjs.createSignal(0);
13343
13397
  const [get_all_products_loaded, set_all_products_loaded] = all_products_loaded_;
13344
13398
  const number_of_rendered_selected_filters_items_ = $gVhhF$solidjs.createSignal(0);
13345
13399
  const first_result_in_viewport_ = $gVhhF$solidjs.createSignal();
@@ -13409,9 +13463,9 @@ function $f1d7cb69f839a526$export$a54ec244c8863715({
13409
13463
  const SafeSearchField = $gVhhF$depictaiutilishared.catchify((0, $66b8b9a9613c141d$export$b94867ecbd698f21));
13410
13464
  const [sort_or_filter_open_, set_sort_or_filter_open_] = $gVhhF$solidjs.createSignal(false);
13411
13465
  const [desktop_filter_elements_, set_desktop_filter_elements] = $gVhhF$solidjs.createSignal();
13412
- const n_hits = $gVhhF$solidjs.createMemo(() => search_results_()?.n_hits);
13466
+ const countOfProductsForUI = $13796d59ea8af231$export$a86bc18439445599(search_results_, all_products_loaded_, currentlyLoadedDisplays);
13413
13467
  const formatted_number_of_results_ = $0f400c3f7248d5f1$export$92f2da32c6e7e7ee({
13414
- number_: n_hits,
13468
+ number_: countOfProductsForUI,
13415
13469
  i18n_: i18n_
13416
13470
  });
13417
13471
  const [sort_and_filter_element_, set_sort_and_filter_element_] = $gVhhF$solidjs.createSignal();
@@ -13420,7 +13474,7 @@ function $f1d7cb69f839a526$export$a54ec244c8863715({
13420
13474
  get type() {
13421
13475
  return (0, $65a0c4b1c2eb5d0b$export$2452208c79fe93ea).products;
13422
13476
  },
13423
- number_of_results_: n_hits
13477
+ number_of_results_: countOfProductsForUI
13424
13478
  }, {
13425
13479
  get_search_query_: get_search_query_,
13426
13480
  i18n_: i18n_,
@@ -13674,6 +13728,7 @@ function $f1d7cb69f839a526$export$a54ec244c8863715({
13674
13728
  sort_or_filter_open_: sort_or_filter_open_,
13675
13729
  id_currently_querying_for_: get_search_query_,
13676
13730
  content_blocks_by_row_: content_blocks_by_row_,
13731
+ setCurrentlyLoadedDisplays_: setCurrentlyLoadedDisplays_,
13677
13732
  no_results_options_: {
13678
13733
  selected_filters_: selected_filters_,
13679
13734
  expanded_hierarchical_filters_: expanded_hierarchical_filters_,
@@ -13716,7 +13771,7 @@ function $f1d7cb69f839a526$export$a54ec244c8863715({
13716
13771
  last_result_in_viewport_: last_result_in_viewport_,
13717
13772
  formatted_number_of_results_: formatted_number_of_results_,
13718
13773
  i18n_: i18n_,
13719
- number_of_results_: $gVhhF$solidjs.createMemo(() => search_results_()?.n_hits)
13774
+ number_of_results_: countOfProductsForUI
13720
13775
  });
13721
13776
  }
13722
13777
  }), _el$23, _co$10);
@@ -15118,6 +15173,8 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
15118
15173
  const number_of_rendered_selected_filters_items_ = $gVhhF$solidjs.createSignal(0);
15119
15174
  const first_result_in_viewport_ = $gVhhF$solidjs.createSignal();
15120
15175
  const last_result_in_viewport_ = $gVhhF$solidjs.createSignal();
15176
+ const all_products_loaded_ = $gVhhF$solidjs.createSignal(false);
15177
+ const [currentlyLoadedDisplays, setCurrentlyLoadedDisplays_] = $gVhhF$solidjs.createSignal(0);
15121
15178
  const [can_write_scroll_restoration_, set_can_write_scroll_restoration] = $gVhhF$solidjs.createSignal(false);
15122
15179
  const products_query_base_ = $8cd545330f2674dc$export$210f130a61ac1e8d(() => {
15123
15180
  const sort_obj = get_sorting() && {
@@ -15164,6 +15221,7 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
15164
15221
  // Make "Get Listing" request to get quicklinks, breadcrumbs, title, etc
15165
15222
  const [plp_meta] = $gVhhF$solidjs.createResource(meta_query_base, $gVhhF$depictaiutilisharedlatest.catchify(query => depict_api_.get_listing(query)));
15166
15223
  const contentBlocksByRow = $0a80939bf0a1e9cc$export$7a92d995f1bf3592(history_content_blocks_, plp_meta, content_blocks_by_row_, router_);
15224
+ const countOfProductsForUI = $13796d59ea8af231$export$a86bc18439445599(plp_products_, all_products_loaded_, currentlyLoadedDisplays);
15167
15225
  const available_sortings_ = $gVhhF$solidjs.createMemo(() => plp_products_()?.sorts?.map(sort => ({
15168
15226
  ...sort,
15169
15227
  order: sort.order ?? "desc"
@@ -15175,7 +15233,7 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
15175
15233
  const [sort_or_filter_open_, set_sort_or_filter_open_] = $gVhhF$solidjs.createSignal(false);
15176
15234
  const [desktop_filter_elements_, set_desktop_filter_elements] = $gVhhF$solidjs.createSignal();
15177
15235
  const formatted_number_of_results_ = $0f400c3f7248d5f1$export$92f2da32c6e7e7ee({
15178
- number_: $gVhhF$solidjs.createMemo(() => plp_products_()?.n_hits),
15236
+ number_: countOfProductsForUI,
15179
15237
  i18n_: i18n_
15180
15238
  });
15181
15239
  const [sort_and_filter_element_, set_sort_and_filter_element_] = $gVhhF$solidjs.createSignal();
@@ -15196,7 +15254,7 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
15196
15254
  last_result_in_viewport_: last_result_in_viewport_,
15197
15255
  formatted_number_of_results_: formatted_number_of_results_,
15198
15256
  i18n_: i18n_,
15199
- number_of_results_: $gVhhF$solidjs.createMemo(() => plp_products_()?.n_hits),
15257
+ number_of_results_: countOfProductsForUI,
15200
15258
  ...extraProps
15201
15259
  });
15202
15260
  }
@@ -15222,7 +15280,7 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
15222
15280
  }), _el$4, _co$);
15223
15281
  $gVhhF$solidjsweb.insert(_el$, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
15224
15282
  get when() {
15225
- return plp_products_()?.n_hits === 1;
15283
+ return countOfProductsForUI() === 1;
15226
15284
  },
15227
15285
  get fallback() {
15228
15286
  return i18n_.products_();
@@ -15427,6 +15485,8 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
15427
15485
  content_blocks_by_row_: contentBlocksByRow,
15428
15486
  ConfiguredScrollStatus_: ConfiguredScrollStatus_,
15429
15487
  id_currently_querying_for_: id_to_query_for_,
15488
+ setCurrentlyLoadedDisplays_: setCurrentlyLoadedDisplays_,
15489
+ all_products_loaded_: all_products_loaded_,
15430
15490
  no_results_options_: {
15431
15491
  selected_filters_: selected_filters_,
15432
15492
  expanded_hierarchical_filters_: expanded_hierarchical_filters_,
package/latest/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/latest/index.js CHANGED
@@ -7,7 +7,7 @@ import { dlog as $9HbP8$dlog, catchify as $9HbP8$catchify1, ListenableSet as $9H
7
7
  /*! Depict.ai search and product listing SDK */
8
8
  import { register_es_version } from "../multi_import_deduplicator.mjs";
9
9
  register_es_version("ui", "latest");
10
- const $ec291e0010116877$export$83d89fbfd8236492 = "4.8.4";
10
+ const $ec291e0010116877$export$83d89fbfd8236492 = "4.8.6";
11
11
  function $a444a52bafa0dacc$export$54c6d6ff54e72743(whatToWatch) {
12
12
  const [width, setWidth] = $9HbP8$createSignal(0);
13
13
  const [height, setHeight] = $9HbP8$createSignal(0);
@@ -2987,10 +2987,10 @@ function $511cc0abd9a64ce8$export$92f2da32c6e7e7ee({
2987
2987
  i18n_: i18n_
2988
2988
  }) {
2989
2989
  return $9HbP8$createMemo(() => {
2990
- const n_hits = number_();
2991
- if (isNaN(n_hits)) return "";
2990
+ const numberToFormat = number_();
2991
+ if (isNaN(numberToFormat)) return "";
2992
2992
  const price_formatting = i18n_.price_formatting_();
2993
- return $9HbP8$standard_price_format(n_hits, 0,
2993
+ return $9HbP8$standard_price_format(numberToFormat, 0,
2994
2994
  // we never want places after comma here it looks weird as hell
2995
2995
  price_formatting.decimal_places_delimiter_, price_formatting.thousands_delimiter_);
2996
2996
  });
@@ -4027,7 +4027,8 @@ function $5285d2814d0fac0c$export$b94867ecbd698f21({
4027
4027
  });
4028
4028
  }
4029
4029
  }, () => searchFieldEmpty() ? {
4030
- "aria-hidden": "true"
4030
+ "aria-hidden": "true",
4031
+ tabIndex: -1
4031
4032
  } : {
4032
4033
  title: i18n_.clear_filters_query_sorting_after_submit_()
4033
4034
  }), false, true);
@@ -5417,7 +5418,8 @@ function $500a16dd18ee5a71$var$RawSearchModalV2({
5417
5418
  // total number of results = content results + product results + category suggestions
5418
5419
  const totalNumberResults = $9HbP8$createMemo(() => {
5419
5420
  const results = get_modal_search_results_()?.();
5420
- const hits = results?.n_hits;
5421
+ // Show actual number of result (more accurate) if there's no cursor (backend doesn't have more products)
5422
+ const hits = results?.cursor ? results?.n_hits : results?.displays?.length;
5421
5423
  const content_results = content_search_enabled_() && results?.content_search_links?.length || 0;
5422
5424
  const category_results = listing_suggestions_()?.length || 0;
5423
5425
  return (hits ?? 0) + content_results + category_results;
@@ -5943,6 +5945,7 @@ async function $194bd6b8e4c59830$export$79b1565500412d9b(search_modal, modal_fn_
5943
5945
  close_modal_: close_modal_
5944
5946
  };
5945
5947
  }
5948
+ let $ca6f574bd8772184$export$68620bd6d5c6bb86;
5946
5949
  function $ca6f574bd8772184$export$e183a13865960371(params_to_default_value, router_) {
5947
5950
  const signals = {};
5948
5951
  const entries = Object.entries(params_to_default_value);
@@ -5974,6 +5977,10 @@ function $ca6f574bd8772184$export$e183a13865960371(params_to_default_value, rout
5974
5977
  }
5975
5978
  }
5976
5979
  if (signal_changed) router_.navigate_.replace_state_(state);
5980
+ $9HbP8$onCleanup(() => $ca6f574bd8772184$export$68620bd6d5c6bb86 = {
5981
+ time: new Date().toISOString(),
5982
+ stack: new Error().stack
5983
+ });
5977
5984
  });
5978
5985
  // 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
5979
5986
  (0, $9HbP8$instant_exec_on_suspect_history_change).add(event_handler);
@@ -9488,7 +9495,15 @@ function $5efb5894079b220e$export$b288c38ae3fddb56({
9488
9495
  selected_filters_: [read_selected_filters]
9489
9496
  }) {
9490
9497
  let last_remote_state;
9498
+ let executions = 0;
9499
+ let oneSecondInfiniteLoopPreventionTimeout;
9491
9500
  $9HbP8$createComputed(() => {
9501
+ // 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
9502
+ // I spent a 1h17min debug session with MadePeople in a tab where they could reproduce
9503
+ // 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
9504
+ // 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.
9505
+ // 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)
9506
+ // As a value first workaround, we just recognise when the computation has been executed "too often" and just start not doing anything after that
9492
9507
  const remote_filters = Object.fromEntries(available_filters_()?.map(filter => [JSON.stringify([filter.field, filter.op, filter?.meta?.type]), filter]) || []);
9493
9508
  const local_filters = Object.fromEntries(read_local_cache().map(filter => [JSON.stringify([filter.field, filter.op, filter?.meta?.type]), filter]));
9494
9509
  const selected_filters = Object.fromEntries(read_selected_filters().map(filter_obj => [JSON.stringify([filter_obj.field, filter_obj.op]), filter_obj]));
@@ -9571,9 +9586,34 @@ function $5efb5894079b220e$export$b288c38ae3fddb56({
9571
9586
  }
9572
9587
  if (last_remote_state !== available_filters_() ||
9573
9588
  // 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
9574
- JSON.stringify(new_local_filter_state) !== JSON.stringify(read_local_cache()))
9575
- // Sorry……… They're not that big
9589
+ // Sorry……… They're not that big
9590
+ JSON.stringify(new_local_filter_state) !== JSON.stringify(read_local_cache())) {
9591
+ const owner = $9HbP8$getOwner();
9592
+ const signal = owner?.sources?.find?.(source => source.value === read_local_cache());
9593
+ if (executions > 30) {
9594
+ // We're probably in an infinite loop, let's just stop
9595
+ $9HbP8$report(new Error("Infinite loop detected in create_modified_filters"), "error", {
9596
+ executions: executions,
9597
+ new_local_filter_state: new_local_filter_state,
9598
+ available_filters: available_filters_(),
9599
+ last_remote_state: last_remote_state,
9600
+ history_length: history.length,
9601
+ location: location.href,
9602
+ foundSignal: !!signal,
9603
+ observerSlots: signal?.observerSlots,
9604
+ observers: signal?.observers?.map?.(o => o?.fn + ""),
9605
+ lastHistoryDotStateToStateCleanupInfo: $ca6f574bd8772184$export$68620bd6d5c6bb86
9606
+ });
9607
+ return;
9608
+ }
9576
9609
  write_local_cache(new_local_filter_state);
9610
+ // Keep track how many times we wrote this signal
9611
+ executions++;
9612
+ oneSecondInfiniteLoopPreventionTimeout ||= setTimeout($9HbP8$catchify(() => {
9613
+ executions = 0;
9614
+ oneSecondInfiniteLoopPreventionTimeout = undefined;
9615
+ }), 1000);
9616
+ }
9577
9617
  last_remote_state = available_filters_();
9578
9618
  });
9579
9619
  }
@@ -11222,7 +11262,8 @@ function $0449e7d49398c077$export$a1fd619a4743ca08({
11222
11262
  query_base_: query_base_,
11223
11263
  depict_api_: depict_api_,
11224
11264
  is_loading_: is_loading_,
11225
- content_blocks_: content_blocks_
11265
+ content_blocks_: content_blocks_,
11266
+ setCurrentlyLoadedDisplays_: setCurrentlyLoadedDisplays_
11226
11267
  }) {
11227
11268
  // Although typing doesn't reflect it, plp_results is guaranteed to contain an array of at least one display at this point
11228
11269
  const [get_extra_displays, set_extra_displays_] = $9HbP8$createSignal([], {
@@ -11246,6 +11287,7 @@ function $0449e7d49398c077$export$a1fd619a4743ca08({
11246
11287
  is_loading_: is_loading_,
11247
11288
  get_extra_displays: get_extra_displays
11248
11289
  });
11290
+ $9HbP8$createComputed(() => setCurrentlyLoadedDisplays_(displays_by_key_().size));
11249
11291
  $056f6ac0a6caa919$export$5e4aed86c12acdd9({
11250
11292
  percentage_in_view_: percentage_in_view_,
11251
11293
  set_extra_displays_: set_extra_displays_,
@@ -11301,7 +11343,8 @@ function $2d25e42846eac370$export$3925f87b1545cfc6({
11301
11343
  layout_options_: layout_options_,
11302
11344
  id_currently_querying_for_: id_currently_querying_for_,
11303
11345
  content_blocks_by_row_: content_blocks_by_row_,
11304
- ConfiguredScrollStatus_: ConfiguredScrollStatus_
11346
+ ConfiguredScrollStatus_: ConfiguredScrollStatus_,
11347
+ setCurrentlyLoadedDisplays_: setCurrentlyLoadedDisplays_
11305
11348
  }) {
11306
11349
  // 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
11307
11350
  const is_loading_ = $9HbP8$createMemo(() => plp_results_.loading || query_base_.loading);
@@ -11432,7 +11475,8 @@ function $2d25e42846eac370$export$3925f87b1545cfc6({
11432
11475
  query_base_: query_base_,
11433
11476
  depict_api_: depict_api_,
11434
11477
  is_loading_: is_loading_,
11435
- content_blocks_: content_blocks_
11478
+ content_blocks_: content_blocks_,
11479
+ setCurrentlyLoadedDisplays_: setCurrentlyLoadedDisplays_
11436
11480
  });
11437
11481
  $9HbP8$onCleanup(() => suspense_contents = undefined);
11438
11482
  return suspense_contents;
@@ -13199,6 +13243,15 @@ function $0e562a5b247b1fc2$export$44f738469d5570cf({
13199
13243
  };
13200
13244
  });
13201
13245
  }
13246
+ function $3ef0154d1cf118ed$export$a86bc18439445599(plp_products_, [allProductsLoaded], currentlyLoadedDisplays) {
13247
+ return $9HbP8$createMemo(() => {
13248
+ const backendSays = plp_products_()?.n_hits;
13249
+ const loadedAll = allProductsLoaded();
13250
+ if (!backendSays || !loadedAll) return backendSays;
13251
+ // 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.
13252
+ return currentlyLoadedDisplays();
13253
+ });
13254
+ }
13202
13255
  var $7097477c78a89208$var$_tmpl$ = /*#__PURE__*/$9HbP8$template(`<div class=filter-results-for-one-row><!$><!/><!$><!/>`),
13203
13256
  $7097477c78a89208$var$_tmpl$2 = /*#__PURE__*/$9HbP8$template(`<div><div class=listing-page><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/></div><!$><!/><!$><!/>`);
13204
13257
  function $7097477c78a89208$export$a54ec244c8863715({
@@ -13239,6 +13292,7 @@ function $7097477c78a89208$export$a54ec244c8863715({
13239
13292
  }) {
13240
13293
  const [get_sorting] = current_sorting_;
13241
13294
  const all_products_loaded_ = $9HbP8$createSignal(false);
13295
+ const [currentlyLoadedDisplays, setCurrentlyLoadedDisplays_] = $9HbP8$createSignal(0);
13242
13296
  const [get_all_products_loaded, set_all_products_loaded] = all_products_loaded_;
13243
13297
  const number_of_rendered_selected_filters_items_ = $9HbP8$createSignal(0);
13244
13298
  const first_result_in_viewport_ = $9HbP8$createSignal();
@@ -13308,9 +13362,9 @@ function $7097477c78a89208$export$a54ec244c8863715({
13308
13362
  const SafeSearchField = $9HbP8$catchify((0, $5285d2814d0fac0c$export$b94867ecbd698f21));
13309
13363
  const [sort_or_filter_open_, set_sort_or_filter_open_] = $9HbP8$createSignal(false);
13310
13364
  const [desktop_filter_elements_, set_desktop_filter_elements] = $9HbP8$createSignal();
13311
- const n_hits = $9HbP8$createMemo(() => search_results_()?.n_hits);
13365
+ const countOfProductsForUI = $3ef0154d1cf118ed$export$a86bc18439445599(search_results_, all_products_loaded_, currentlyLoadedDisplays);
13312
13366
  const formatted_number_of_results_ = $511cc0abd9a64ce8$export$92f2da32c6e7e7ee({
13313
- number_: n_hits,
13367
+ number_: countOfProductsForUI,
13314
13368
  i18n_: i18n_
13315
13369
  });
13316
13370
  const [sort_and_filter_element_, set_sort_and_filter_element_] = $9HbP8$createSignal();
@@ -13319,7 +13373,7 @@ function $7097477c78a89208$export$a54ec244c8863715({
13319
13373
  get type() {
13320
13374
  return (0, $f8c929beb82c512b$export$2452208c79fe93ea).products;
13321
13375
  },
13322
- number_of_results_: n_hits
13376
+ number_of_results_: countOfProductsForUI
13323
13377
  }, {
13324
13378
  get_search_query_: get_search_query_,
13325
13379
  i18n_: i18n_,
@@ -13573,6 +13627,7 @@ function $7097477c78a89208$export$a54ec244c8863715({
13573
13627
  sort_or_filter_open_: sort_or_filter_open_,
13574
13628
  id_currently_querying_for_: get_search_query_,
13575
13629
  content_blocks_by_row_: content_blocks_by_row_,
13630
+ setCurrentlyLoadedDisplays_: setCurrentlyLoadedDisplays_,
13576
13631
  no_results_options_: {
13577
13632
  selected_filters_: selected_filters_,
13578
13633
  expanded_hierarchical_filters_: expanded_hierarchical_filters_,
@@ -13615,7 +13670,7 @@ function $7097477c78a89208$export$a54ec244c8863715({
13615
13670
  last_result_in_viewport_: last_result_in_viewport_,
13616
13671
  formatted_number_of_results_: formatted_number_of_results_,
13617
13672
  i18n_: i18n_,
13618
- number_of_results_: $9HbP8$createMemo(() => search_results_()?.n_hits)
13673
+ number_of_results_: countOfProductsForUI
13619
13674
  });
13620
13675
  }
13621
13676
  }), _el$23, _co$10);
@@ -15017,6 +15072,8 @@ function $df5d81d0fe61ff21$export$f7d2f673fc2f091d({
15017
15072
  const number_of_rendered_selected_filters_items_ = $9HbP8$createSignal(0);
15018
15073
  const first_result_in_viewport_ = $9HbP8$createSignal();
15019
15074
  const last_result_in_viewport_ = $9HbP8$createSignal();
15075
+ const all_products_loaded_ = $9HbP8$createSignal(false);
15076
+ const [currentlyLoadedDisplays, setCurrentlyLoadedDisplays_] = $9HbP8$createSignal(0);
15020
15077
  const [can_write_scroll_restoration_, set_can_write_scroll_restoration] = $9HbP8$createSignal(false);
15021
15078
  const products_query_base_ = $587cd61972788655$export$210f130a61ac1e8d(() => {
15022
15079
  const sort_obj = get_sorting() && {
@@ -15063,6 +15120,7 @@ function $df5d81d0fe61ff21$export$f7d2f673fc2f091d({
15063
15120
  // Make "Get Listing" request to get quicklinks, breadcrumbs, title, etc
15064
15121
  const [plp_meta] = $9HbP8$createResource(meta_query_base, $9HbP8$catchify1(query => depict_api_.get_listing(query)));
15065
15122
  const contentBlocksByRow = $486360b09f0d5729$export$7a92d995f1bf3592(history_content_blocks_, plp_meta, content_blocks_by_row_, router_);
15123
+ const countOfProductsForUI = $3ef0154d1cf118ed$export$a86bc18439445599(plp_products_, all_products_loaded_, currentlyLoadedDisplays);
15066
15124
  const available_sortings_ = $9HbP8$createMemo(() => plp_products_()?.sorts?.map(sort => ({
15067
15125
  ...sort,
15068
15126
  order: sort.order ?? "desc"
@@ -15074,7 +15132,7 @@ function $df5d81d0fe61ff21$export$f7d2f673fc2f091d({
15074
15132
  const [sort_or_filter_open_, set_sort_or_filter_open_] = $9HbP8$createSignal(false);
15075
15133
  const [desktop_filter_elements_, set_desktop_filter_elements] = $9HbP8$createSignal();
15076
15134
  const formatted_number_of_results_ = $511cc0abd9a64ce8$export$92f2da32c6e7e7ee({
15077
- number_: $9HbP8$createMemo(() => plp_products_()?.n_hits),
15135
+ number_: countOfProductsForUI,
15078
15136
  i18n_: i18n_
15079
15137
  });
15080
15138
  const [sort_and_filter_element_, set_sort_and_filter_element_] = $9HbP8$createSignal();
@@ -15095,7 +15153,7 @@ function $df5d81d0fe61ff21$export$f7d2f673fc2f091d({
15095
15153
  last_result_in_viewport_: last_result_in_viewport_,
15096
15154
  formatted_number_of_results_: formatted_number_of_results_,
15097
15155
  i18n_: i18n_,
15098
- number_of_results_: $9HbP8$createMemo(() => plp_products_()?.n_hits),
15156
+ number_of_results_: countOfProductsForUI,
15099
15157
  ...extraProps
15100
15158
  });
15101
15159
  }
@@ -15121,7 +15179,7 @@ function $df5d81d0fe61ff21$export$f7d2f673fc2f091d({
15121
15179
  }), _el$4, _co$);
15122
15180
  $9HbP8$insert(_el$, $9HbP8$createComponent((0, $9HbP8$Show), {
15123
15181
  get when() {
15124
- return plp_products_()?.n_hits === 1;
15182
+ return countOfProductsForUI() === 1;
15125
15183
  },
15126
15184
  get fallback() {
15127
15185
  return i18n_.products_();
@@ -15326,6 +15384,8 @@ function $df5d81d0fe61ff21$export$f7d2f673fc2f091d({
15326
15384
  content_blocks_by_row_: contentBlocksByRow,
15327
15385
  ConfiguredScrollStatus_: ConfiguredScrollStatus_,
15328
15386
  id_currently_querying_for_: id_to_query_for_,
15387
+ setCurrentlyLoadedDisplays_: setCurrentlyLoadedDisplays_,
15388
+ all_products_loaded_: all_products_loaded_,
15329
15389
  no_results_options_: {
15330
15390
  selected_filters_: selected_filters_,
15331
15391
  expanded_hierarchical_filters_: expanded_hierarchical_filters_,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@depict-ai/ui",
3
- "version": "4.8.4",
3
+ "version": "4.8.6",
4
4
  "description": "Base package containing the actual UI of Depict UI along with translations, with a not-simplified API. We recommend using @depict-ai/js-ui or @depict-ai/react-ui instead.",
5
5
  "packageManager": "yarn@3.2.2",
6
6
  "sass": "styles.scss",