@depict-ai/ui 1.0.8 → 1.0.9
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/README.md +3 -3
- package/dist/index.d.ts +542 -542
- package/dist/main.js +73 -73
- package/dist/module.js +73 -73
- package/locales/index.d.ts +89 -89
- package/locales/index.js +2 -2
- package/locales/require.js +2 -2
- package/package.json +4 -4
- package/styles.scss +1 -1
- package/dist/typescript_schema/BaseSearchRequest.d.ts +0 -197
- package/dist/typescript_schema/ProductListingQueriesRequest.d.ts +0 -14
- package/dist/typescript_schema/ProductListingQueriesResponse.d.ts +0 -10
- package/dist/typescript_schema/ProductListingRequest.d.ts +0 -221
- package/dist/typescript_schema/ProductListingResponse.d.ts +0 -232
- package/dist/typescript_schema/RecommendResponse.d.ts +0 -15
- package/dist/typescript_schema/SearchRequest.d.ts +0 -213
- package/dist/typescript_schema/SearchResponse.d.ts +0 -192
- package/dist/typescript_schema/SearchSuggestionsRequest.d.ts +0 -18
- package/dist/typescript_schema/SearchSuggestionsResponse.d.ts +0 -182
- package/dist/typescript_schema/TrackV2Request.d.ts +0 -115
package/dist/main.js
CHANGED
|
@@ -37,7 +37,7 @@ $parcel$export(module.exports, "defaultGridSpacing", () => $a3280f0aad997933$exp
|
|
|
37
37
|
$parcel$export(module.exports, "defaultColsAtSize", () => $a3280f0aad997933$export$c3834fa86c616831);
|
|
38
38
|
$parcel$export(module.exports, "defaultCategoryTitlePlugin", () => $a3280f0aad997933$export$7bf543b9d9be2c22);
|
|
39
39
|
$parcel$export(module.exports, "version", () => $b757f75811f3261f$export$83d89fbfd8236492);
|
|
40
|
-
/*! Depict.ai search and product listing SDK */ const $b757f75811f3261f$export$83d89fbfd8236492 = "1.0.
|
|
40
|
+
/*! Depict.ai search and product listing SDK */ const $b757f75811f3261f$export$83d89fbfd8236492 = "1.0.9";
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
|
|
@@ -821,8 +821,8 @@ function $0caf87eaa19079da$export$f33414a4df0afd3f({ product_card_template_: pro
|
|
|
821
821
|
});
|
|
822
822
|
return get_elements; // https://github.com/solidjs/solid/releases/tag/v1.7.0
|
|
823
823
|
}
|
|
824
|
-
/**
|
|
825
|
-
* Get one placeholder element. It will be cloned for each placeholder for ultimate performance even when solid-js isn't rendering the placeholders.
|
|
824
|
+
/**
|
|
825
|
+
* Get one placeholder element. It will be cloned for each placeholder for ultimate performance even when solid-js isn't rendering the placeholders.
|
|
826
826
|
*/ function $0caf87eaa19079da$var$Placeholder({ product_card_template_: product_card_template_ }) {
|
|
827
827
|
const get_cloned_placeholders = (element_to_clone = $0caf87eaa19079da$var$cached_placeholder_element)=>Array.isArray(element_to_clone) ? element_to_clone.map((el)=>el instanceof Node ? el.cloneNode(true) : el) : element_to_clone;
|
|
828
828
|
if ($0caf87eaa19079da$var$cached_placeholder_element) return get_cloned_placeholders();
|
|
@@ -867,8 +867,8 @@ function $0caf87eaa19079da$export$f33414a4df0afd3f({ product_card_template_: pro
|
|
|
867
867
|
}
|
|
868
868
|
|
|
869
869
|
|
|
870
|
-
/*
|
|
871
|
-
* Usually product templates are somewhat height-elastic depending on the content, i.e. if the title is longer we might up to two extra rows for this. That means that the placeholders almost never will reflect the size of the actual content when we do scroll restoration. This magic number specifies how many extra placeholders we should render everytime to compensate for this, since if the placeholders are in total shorter than the old scroll location the scroll restoration won't work.
|
|
870
|
+
/*
|
|
871
|
+
* Usually product templates are somewhat height-elastic depending on the content, i.e. if the title is longer we might up to two extra rows for this. That means that the placeholders almost never will reflect the size of the actual content when we do scroll restoration. This magic number specifies how many extra placeholders we should render everytime to compensate for this, since if the placeholders are in total shorter than the old scroll location the scroll restoration won't work.
|
|
872
872
|
*/ const $aec24316ed262dc0$export$6c9030e511152266 = 30;
|
|
873
873
|
|
|
874
874
|
|
|
@@ -960,8 +960,8 @@ function $4117463e2939f5f4$export$63dd0350f8559dda({ displays_by_key_: displays_
|
|
|
960
960
|
|
|
961
961
|
|
|
962
962
|
|
|
963
|
-
/**
|
|
964
|
-
* Gets product_id (the thing we key the rendering on) from a display
|
|
963
|
+
/**
|
|
964
|
+
* Gets product_id (the thing we key the rendering on) from a display
|
|
965
965
|
*/ function $a5871dacf261adf8$export$548d053aba053d79(display) {
|
|
966
966
|
if ("variant_index" in display) {
|
|
967
967
|
const actual_display = display.variant_displays[display.variant_index];
|
|
@@ -1262,9 +1262,9 @@ function $fe76fb463cc60b89$export$3925f87b1545cfc6({ plp_results_: plp_results_
|
|
|
1262
1262
|
return _el$;
|
|
1263
1263
|
})();
|
|
1264
1264
|
}
|
|
1265
|
-
/**
|
|
1266
|
-
* Sets styling to styling generated by "Layout" (n_col_styling_with_dist) depending on if filters are open or not
|
|
1267
|
-
* This function is special to the actual PLPResults.
|
|
1265
|
+
/**
|
|
1266
|
+
* Sets styling to styling generated by "Layout" (n_col_styling_with_dist) depending on if filters are open or not
|
|
1267
|
+
* This function is special to the actual PLPResults.
|
|
1268
1268
|
*/ function $fe76fb463cc60b89$var$results_grid_styling_generator({ layout_options_: layout_options_ , sort_or_filter_open_: sort_or_filter_open_ , set_styling_: set_styling_ , selector_beginning_: selector_beginning_ }) {
|
|
1269
1269
|
(0, $iBTHO$solidjs.createRenderEffect)(()=>{
|
|
1270
1270
|
// Add grid styling that changes when filters get opened/closed
|
|
@@ -3954,9 +3954,9 @@ function $70482f04605572e2$export$b288c38ae3fddb56({ available_filters_: availab
|
|
|
3954
3954
|
last_remote_state = available_filters_();
|
|
3955
3955
|
});
|
|
3956
3956
|
}
|
|
3957
|
-
/**
|
|
3958
|
-
* When a filter is only available locally due to being selected in a previous navigation, we want to make that clear and prevent further "invalid" choices.
|
|
3959
|
-
* This sets the counts to 0 (if applicable) and removes non-selected options (if applicable)
|
|
3957
|
+
/**
|
|
3958
|
+
* When a filter is only available locally due to being selected in a previous navigation, we want to make that clear and prevent further "invalid" choices.
|
|
3959
|
+
* This sets the counts to 0 (if applicable) and removes non-selected options (if applicable)
|
|
3960
3960
|
*/ function $70482f04605572e2$var$modify_only_local_filter(local_filter_object, selected_filter) {
|
|
3961
3961
|
const old_meta = local_filter_object.meta;
|
|
3962
3962
|
const selected_filter_data = selected_filter.data;
|
|
@@ -4396,10 +4396,10 @@ const $1ab22f2cd39b3061$var$range_delimiter = "-";
|
|
|
4396
4396
|
const $1ab22f2cd39b3061$var$string_item_delimiter = "‚"; // This is not a comma but a comma-like character that browsers will render in the URL bar.
|
|
4397
4397
|
const $1ab22f2cd39b3061$var$array_item_delimiter = "‣"; // FIXME: decide on a character. Could theoretically be a double string delimiter.
|
|
4398
4398
|
const $1ab22f2cd39b3061$var$empty_item_replacement = "0️⃣";
|
|
4399
|
-
/**
|
|
4400
|
-
* Checks if a given array of filter data can be neatly serialized into an URL query parameter, or if it should fall back to JSON+base64.
|
|
4401
|
-
* The requirements are either an array of strings, containing no reserved characters, or an array of arrays of strings, containing no reserved characters.
|
|
4402
|
-
* No deep or mixed nesting levels are supported.
|
|
4399
|
+
/**
|
|
4400
|
+
* Checks if a given array of filter data can be neatly serialized into an URL query parameter, or if it should fall back to JSON+base64.
|
|
4401
|
+
* The requirements are either an array of strings, containing no reserved characters, or an array of arrays of strings, containing no reserved characters.
|
|
4402
|
+
* No deep or mixed nesting levels are supported.
|
|
4403
4403
|
*/ function $1ab22f2cd39b3061$var$array_is_serializable(array, is_root = true) {
|
|
4404
4404
|
if (array.every((item)=>Array.isArray(item))) {
|
|
4405
4405
|
if (!is_root) // Deeply nested arrays are not supported, but also don't exist as filters (yet)
|
|
@@ -4411,10 +4411,10 @@ const $1ab22f2cd39b3061$var$empty_item_replacement = "0️⃣";
|
|
|
4411
4411
|
// Encoding reserved characters is not supported
|
|
4412
4412
|
return !array.some((item)=>item.includes($1ab22f2cd39b3061$var$array_item_delimiter) || item.includes($1ab22f2cd39b3061$var$string_item_delimiter) || item === $1ab22f2cd39b3061$var$empty_item_replacement);
|
|
4413
4413
|
}
|
|
4414
|
-
/**
|
|
4415
|
-
* Human readable string[] or string[][] serialization for URLs.
|
|
4416
|
-
* @param array
|
|
4417
|
-
* @returns
|
|
4414
|
+
/**
|
|
4415
|
+
* Human readable string[] or string[][] serialization for URLs.
|
|
4416
|
+
* @param array
|
|
4417
|
+
* @returns
|
|
4418
4418
|
*/ function $1ab22f2cd39b3061$var$encode_array(array) {
|
|
4419
4419
|
const is_nested = array.every((item)=>Array.isArray(item));
|
|
4420
4420
|
if (is_nested) return array.map($1ab22f2cd39b3061$var$encode_array).join($1ab22f2cd39b3061$var$array_item_delimiter) + $1ab22f2cd39b3061$var$array_item_delimiter; // Nested arrays require a suffix to close nesting levels
|
|
@@ -5509,8 +5509,8 @@ function $c79fd10a3ab7d6e0$export$477caf01aecaeb2a(options) {
|
|
|
5509
5509
|
}
|
|
5510
5510
|
};
|
|
5511
5511
|
}
|
|
5512
|
-
/**
|
|
5513
|
-
* Writes the sorting and filters to the URL query parameters when they change.
|
|
5512
|
+
/**
|
|
5513
|
+
* Writes the sorting and filters to the URL query parameters when they change.
|
|
5514
5514
|
*/ function $c79fd10a3ab7d6e0$var$start_href_writer({ get_sorting_: get_sorting_ , get_selected_filters_: get_selected_filters_ , router_: router_ , get_has_sideways_filter_clearing_flag_: get_has_sideways_filter_clearing_flag_ }) {
|
|
5515
5515
|
(0, $iBTHO$solidjs.createEffect)((0, $iBTHO$solidjs.on)([
|
|
5516
5516
|
get_sorting_,
|
|
@@ -5550,8 +5550,8 @@ function $c79fd10a3ab7d6e0$var$delete_sideways_param_flag(searchParams) {
|
|
|
5550
5550
|
|
|
5551
5551
|
|
|
5552
5552
|
class $e96dd13889871fc0$export$7e1297a3a19f10d8 {
|
|
5553
|
-
/**
|
|
5554
|
-
* Function that will be called when we want to navigate, or a string saying it's not an SPA. You can change this OTG
|
|
5553
|
+
/**
|
|
5554
|
+
* Function that will be called when we want to navigate, or a string saying it's not an SPA. You can change this OTG
|
|
5555
5555
|
*/ #throwing_on_navigation(...args) {
|
|
5556
5556
|
const { on_navigation_: on_navigation_ } = this;
|
|
5557
5557
|
if (typeof on_navigation_ !== "function") throw new Error("on_navigation_ is not a function");
|
|
@@ -5564,14 +5564,14 @@ class $e96dd13889871fc0$export$7e1297a3a19f10d8 {
|
|
|
5564
5564
|
});
|
|
5565
5565
|
}
|
|
5566
5566
|
}
|
|
5567
|
-
/**
|
|
5568
|
-
* Checks if this tab shouldn't navigate because user wants to open in new tab
|
|
5567
|
+
/**
|
|
5568
|
+
* Checks if this tab shouldn't navigate because user wants to open in new tab
|
|
5569
5569
|
*/ #dont_attempt_navigation(ev) {
|
|
5570
5570
|
return ev?.button || ev?.metaKey || ev?.ctrlKey;
|
|
5571
5571
|
}
|
|
5572
|
-
/**
|
|
5573
|
-
* Vue has async router that needs to be awaited (it navigates after a microtask)
|
|
5574
|
-
* This standardises waiting for all kinds of routers
|
|
5572
|
+
/**
|
|
5573
|
+
* Vue has async router that needs to be awaited (it navigates after a microtask)
|
|
5574
|
+
* This standardises waiting for all kinds of routers
|
|
5575
5575
|
*/ #get_navigation_happened_promise(is_replace) {
|
|
5576
5576
|
return new Promise((resolve)=>{
|
|
5577
5577
|
const handler = (what_happened)=>{
|
|
@@ -5584,19 +5584,19 @@ class $e96dd13889871fc0$export$7e1297a3a19f10d8 {
|
|
|
5584
5584
|
});
|
|
5585
5585
|
}
|
|
5586
5586
|
navigate_ = {
|
|
5587
|
-
/**
|
|
5588
|
-
* Call this if you *just* want to replace the state object in history.state
|
|
5587
|
+
/**
|
|
5588
|
+
* Call this if you *just* want to replace the state object in history.state
|
|
5589
5589
|
*/ replace_state_: (new_state)=>{
|
|
5590
5590
|
// This doesn't break any router, so we just do this directly for now, since many don't expose an interface for changing the state
|
|
5591
5591
|
history.replaceState(new_state, "");
|
|
5592
5592
|
},
|
|
5593
|
-
/**
|
|
5594
|
-
* Call this to change the URL
|
|
5595
|
-
* @param new_url_ new URL to go to
|
|
5596
|
-
* @param event_ event if you have this in a click handler, will not do anything on cmd/ctrl or non-left click then
|
|
5597
|
-
* @param force_spa_navigation_ if you want to force SPA navigation even if on_navigation_ is set to "hard_navigation". You should only set this to true for inter-SDK-page navigations
|
|
5598
|
-
* @param is_replace_ if you want to replace the current URL in history instead of pushing a new one
|
|
5599
|
-
* @param category_query_id_ If you are navigating to a category and know the query_id of, please provide it. This is for making a better devEx in js-ui
|
|
5593
|
+
/**
|
|
5594
|
+
* Call this to change the URL
|
|
5595
|
+
* @param new_url_ new URL to go to
|
|
5596
|
+
* @param event_ event if you have this in a click handler, will not do anything on cmd/ctrl or non-left click then
|
|
5597
|
+
* @param force_spa_navigation_ if you want to force SPA navigation even if on_navigation_ is set to "hard_navigation". You should only set this to true for inter-SDK-page navigations
|
|
5598
|
+
* @param is_replace_ if you want to replace the current URL in history instead of pushing a new one
|
|
5599
|
+
* @param category_query_id_ If you are navigating to a category and know the query_id of, please provide it. This is for making a better devEx in js-ui
|
|
5600
5600
|
*/ go_to_: (0, $iBTHO$depictaiutilishared.catchify)(async ({ new_url_: raw_new_url , event_: event_ , force_spa_navigation_: force_spa_navigation_ , is_replace_: is_replace_ , category_query_id_: category_query_id_ })=>{
|
|
5601
5601
|
const new_url_ = raw_new_url instanceof URL ? raw_new_url : new URL(raw_new_url, location.origin);
|
|
5602
5602
|
const wants_hard_navigation = this.on_navigation_ === "hard_navigation";
|
|
@@ -6404,8 +6404,8 @@ async function $f328bd45f8ede33c$export$e16630ecb9644a1c({ on_submit_with_unchan
|
|
|
6404
6404
|
|
|
6405
6405
|
|
|
6406
6406
|
|
|
6407
|
-
/**
|
|
6408
|
-
* Expand an object where every value in the top-level is an accessor into a normal object. Used for converting solid_i18n objects into external i18n typed objects.
|
|
6407
|
+
/**
|
|
6408
|
+
* Expand an object where every value in the top-level is an accessor into a normal object. Used for converting solid_i18n objects into external i18n typed objects.
|
|
6409
6409
|
*/ const $639c124c22b6cbaa$export$27b710c08412a7ad = (obj)=>{
|
|
6410
6410
|
return Object.fromEntries(Object.keys(obj).map((key)=>[
|
|
6411
6411
|
key,
|
|
@@ -7946,8 +7946,8 @@ function $d8e94ea381ab57fa$export$828dcdd425fd3231(aligner) {
|
|
|
7946
7946
|
|
|
7947
7947
|
|
|
7948
7948
|
const $2c61e4cd8229c49a$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$iBTHO$solidjsweb.template)(`<div class="depict plp search"></div>`, 2);
|
|
7949
|
-
/**
|
|
7950
|
-
* Type for the private properties that are shared between the different exported search SDK wrapper functions. SDK users are not allowed to change/access these, they're an internal implementation detail.
|
|
7949
|
+
/**
|
|
7950
|
+
* Type for the private properties that are shared between the different exported search SDK wrapper functions. SDK users are not allowed to change/access these, they're an internal implementation detail.
|
|
7951
7951
|
*/ const $2c61e4cd8229c49a$var$privately_shared_properties = /*@__PURE__*/ new WeakMap();
|
|
7952
7952
|
const $2c61e4cd8229c49a$var$min_products_to_fetch_ = 20;
|
|
7953
7953
|
const $2c61e4cd8229c49a$export$bde3eb976dfded9 = (depict_search)=>$2c61e4cd8229c49a$var$privately_shared_properties.get(depict_search)?.search_query_updating_blocked_;
|
|
@@ -8148,14 +8148,14 @@ class $2c61e4cd8229c49a$export$ac6237957a15b3f0 {
|
|
|
8148
8148
|
set market(market) {
|
|
8149
8149
|
this.#market_signal[1](market);
|
|
8150
8150
|
}
|
|
8151
|
-
async fetchSearchResults(query, filters,
|
|
8151
|
+
async fetchSearchResults(query, filters, maxResults = 50) {
|
|
8152
8152
|
const { depict_api_: depict_api_ } = $2c61e4cd8229c49a$var$privately_shared_properties.get(this);
|
|
8153
8153
|
const result = await depict_api_.query({
|
|
8154
8154
|
tenant: this.merchant,
|
|
8155
8155
|
market: this.market,
|
|
8156
8156
|
query: query,
|
|
8157
8157
|
filters: filters,
|
|
8158
|
-
limit:
|
|
8158
|
+
limit: maxResults
|
|
8159
8159
|
});
|
|
8160
8160
|
if (result.failed) throw new Error("Failed to fetch search results");
|
|
8161
8161
|
return result.displays;
|
|
@@ -8344,8 +8344,8 @@ const $9c143d25df1fc2a2$export$d86a33413558014e = (openModalParams)=>{
|
|
|
8344
8344
|
}
|
|
8345
8345
|
const { cleanup: cleanup } = (0, $d8e94ea381ab57fa$export$828dcdd425fd3231)(openModalParams.element);
|
|
8346
8346
|
let dispose_aligner;
|
|
8347
|
-
/**
|
|
8348
|
-
* Setting position to fixed is important to make the modal work with align_field.
|
|
8347
|
+
/**
|
|
8348
|
+
* Setting position to fixed is important to make the modal work with align_field.
|
|
8349
8349
|
*/ const style_props_ = (0, $iBTHO$solidjs.createSignal)({
|
|
8350
8350
|
position: "fixed"
|
|
8351
8351
|
});
|
|
@@ -8441,8 +8441,8 @@ class $0a6acf31d1eae57c$export$3ccaa27d81dd8556 extends EventTarget {
|
|
|
8441
8441
|
})();
|
|
8442
8442
|
return new Set();
|
|
8443
8443
|
})();
|
|
8444
|
-
/**
|
|
8445
|
-
* Returns if the "replacement page" is currently open
|
|
8444
|
+
/**
|
|
8445
|
+
* Returns if the "replacement page" is currently open
|
|
8446
8446
|
*/ get open_() {
|
|
8447
8447
|
// make this "readonly" from the outside, the only way to open is by making the url change so that is_page_ returns true
|
|
8448
8448
|
return this.#is_open;
|
|
@@ -8527,26 +8527,26 @@ class $0a6acf31d1eae57c$export$3ccaa27d81dd8556 extends EventTarget {
|
|
|
8527
8527
|
if (what_happened !== "popstate") return;
|
|
8528
8528
|
const cleaned_current_url = $0a6acf31d1eae57c$var$clean_url(location.href);
|
|
8529
8529
|
if (!$0a6acf31d1eae57c$export$3ccaa27d81dd8556.#visited_urls.has(cleaned_current_url)) {
|
|
8530
|
-
/*
|
|
8531
|
-
What does this check do? Well, there's a bug without it where people end up on a page that they shouldn't see (i.e. a somewhat blank page).
|
|
8532
|
-
The culprit of that bug is: the browser remembers where to make "hard"-navigations (i.e. a full document rebuild with a new `document` and `window` object) when going back and forwards in the history and where to just change the url. What it doesn't always correctly remember (observed in at least chrome and firefox), is *what document to hard-navigate to*. Therefore, we have to jump in and take care of that.
|
|
8533
|
-
The reproduction is this:
|
|
8534
|
-
Spendrups has set up a search page for us under /start/search. We don't want to hard-reload the page though to get there.
|
|
8535
|
-
1. Go to a product page like https://ehandel.spendrups.se/Product/1104201
|
|
8536
|
-
2. Make a search
|
|
8537
|
-
We use PageReplacer to just replace the current page (and the url in the address bar) with the search page. The thing is though, that when going back now the URL just updates but the browser doesn't actually navigate - that's fine, PageReplacer will just restore the old page contents
|
|
8538
|
-
3. Try going back just for fun
|
|
8539
|
-
Everything works as expected
|
|
8540
|
-
4. Go forwards again (just for fun, skip this if you skipped 3)
|
|
8541
|
-
Now the trouble comes when we introduce "hard" navigation.
|
|
8542
|
-
5. Click on a search result. The browser will now "hard" navigate to a new page.
|
|
8543
|
-
6. Click "back"
|
|
8544
|
-
What happens now, is that the browser hard-navigates to /start/search.
|
|
8545
|
-
7. Click "back" again
|
|
8546
|
-
What happens now, is that the browser "soft-navigates" (just changes the URL) to https://ehandel.spendrups.se/Product/1104201
|
|
8547
|
-
PageReplacer unload itself and reveals the original document - it is expected to be the one under https://ehandel.spendrups.se/Product/1104201, but actually it is the one under /start/search - a white page.
|
|
8548
|
-
|
|
8549
|
-
|
|
8530
|
+
/*
|
|
8531
|
+
What does this check do? Well, there's a bug without it where people end up on a page that they shouldn't see (i.e. a somewhat blank page).
|
|
8532
|
+
The culprit of that bug is: the browser remembers where to make "hard"-navigations (i.e. a full document rebuild with a new `document` and `window` object) when going back and forwards in the history and where to just change the url. What it doesn't always correctly remember (observed in at least chrome and firefox), is *what document to hard-navigate to*. Therefore, we have to jump in and take care of that.
|
|
8533
|
+
The reproduction is this:
|
|
8534
|
+
Spendrups has set up a search page for us under /start/search. We don't want to hard-reload the page though to get there.
|
|
8535
|
+
1. Go to a product page like https://ehandel.spendrups.se/Product/1104201
|
|
8536
|
+
2. Make a search
|
|
8537
|
+
We use PageReplacer to just replace the current page (and the url in the address bar) with the search page. The thing is though, that when going back now the URL just updates but the browser doesn't actually navigate - that's fine, PageReplacer will just restore the old page contents
|
|
8538
|
+
3. Try going back just for fun
|
|
8539
|
+
Everything works as expected
|
|
8540
|
+
4. Go forwards again (just for fun, skip this if you skipped 3)
|
|
8541
|
+
Now the trouble comes when we introduce "hard" navigation.
|
|
8542
|
+
5. Click on a search result. The browser will now "hard" navigate to a new page.
|
|
8543
|
+
6. Click "back"
|
|
8544
|
+
What happens now, is that the browser hard-navigates to /start/search.
|
|
8545
|
+
7. Click "back" again
|
|
8546
|
+
What happens now, is that the browser "soft-navigates" (just changes the URL) to https://ehandel.spendrups.se/Product/1104201
|
|
8547
|
+
PageReplacer unload itself and reveals the original document - it is expected to be the one under https://ehandel.spendrups.se/Product/1104201, but actually it is the one under /start/search - a white page.
|
|
8548
|
+
The fix: is to remember all pages that we have visited since the creation of `window` (we do that by having a static property on PageReplacer since we assume the PageReplacer source code will only exist once on the page and will be loaded at page load, the latter assumption might be wrong, but I hope not). If we get a "popstate" event (meaning back or forwards button, not new page being pushed) to an unknown page we reload.
|
|
8549
|
+
*/ (0, $iBTHO$depictaiutilishared.dlog)("PageReplacer: ", cleaned_current_url, " hasn't been visited since document was created, reloading since we won't be able to show this page otherwise");
|
|
8550
8550
|
location.reload();
|
|
8551
8551
|
$0a6acf31d1eae57c$export$3ccaa27d81dd8556.#reverting_permitted = false; // Disallow any reverting since we can't - it would flash a white page until the reload has finished.
|
|
8552
8552
|
this.#unload(); // Call unload to "kill" the solid-js stuff quicker so that it stops updating - the user is expecting the next thing that happens to be a navigation to the actual page the URL says they're on.
|
|
@@ -8555,8 +8555,8 @@ class $0a6acf31d1eae57c$export$3ccaa27d81dd8556 extends EventTarget {
|
|
|
8555
8555
|
(0, $iBTHO$depictaiutilishared.instant_exec_on_suspect_history_change).add(on_maybe_popstate);
|
|
8556
8556
|
this.#revert_fns.push(()=>(0, $iBTHO$depictaiutilishared.instant_exec_on_suspect_history_change).delete(on_maybe_popstate)); // Don't run the bugfixer if there isn't a PageReplacer page open since I assume the bug only happens when going back from a PageReplace'd page
|
|
8557
8557
|
}
|
|
8558
|
-
/**
|
|
8559
|
-
* Stops listening to URL changes and closes the page (if it is currently open)
|
|
8558
|
+
/**
|
|
8559
|
+
* Stops listening to URL changes and closes the page (if it is currently open)
|
|
8560
8560
|
*/ destroy_() {
|
|
8561
8561
|
this.#unload();
|
|
8562
8562
|
this.#stop_listening?.();
|
|
@@ -8571,8 +8571,8 @@ class $0a6acf31d1eae57c$export$3ccaa27d81dd8556 extends EventTarget {
|
|
|
8571
8571
|
if (!is_spa_) (0, $08e7f10b1831645f$export$689e204eadb33baf)(this); // Make so that clicking on links to the previous page work instantly
|
|
8572
8572
|
}
|
|
8573
8573
|
}
|
|
8574
|
-
/**
|
|
8575
|
-
* Remove hash from URL
|
|
8574
|
+
/**
|
|
8575
|
+
* Remove hash from URL
|
|
8576
8576
|
*/ function $0a6acf31d1eae57c$var$clean_url(url) {
|
|
8577
8577
|
// Would want to have this a static private function on PageReplacer, but that's not supported in MobileSafari yet
|
|
8578
8578
|
// remove hash, all other params *could* trigger a re-request
|
package/dist/module.js
CHANGED
|
@@ -2,7 +2,7 @@ import {add_to_version_info as $kyEB6$add_to_version_info, fetch_recs as $kyEB6$
|
|
|
2
2
|
import {template as $kyEB6$template, insert as $kyEB6$insert, effect as $kyEB6$effect, setAttribute as $kyEB6$setAttribute, createComponent as $kyEB6$createComponent, use as $kyEB6$use, memo as $kyEB6$memo, addEventListener as $kyEB6$addEventListener, delegateEvents as $kyEB6$delegateEvents, spread as $kyEB6$spread, classList as $kyEB6$classList, style as $kyEB6$style, Dynamic as $kyEB6$Dynamic, mergeProps as $kyEB6$mergeProps, className as $kyEB6$className} from "solid-js/web";
|
|
3
3
|
import {createSignal as $kyEB6$createSignal, getOwner as $kyEB6$getOwner, createRoot as $kyEB6$createRoot, runWithOwner as $kyEB6$runWithOwner, onCleanup as $kyEB6$onCleanup, createComputed as $kyEB6$createComputed, createRenderEffect as $kyEB6$createRenderEffect, createEffect as $kyEB6$createEffect, untrack as $kyEB6$untrack, batch as $kyEB6$batch, createResource as $kyEB6$createResource, createMemo as $kyEB6$createMemo, Show as $kyEB6$Show, createReaction as $kyEB6$createReaction, Suspense as $kyEB6$Suspense, on as $kyEB6$on, ErrorBoundary as $kyEB6$ErrorBoundary, For as $kyEB6$For, Index as $kyEB6$Index} from "solid-js";
|
|
4
4
|
|
|
5
|
-
/*! Depict.ai search and product listing SDK */ const $ec291e0010116877$export$83d89fbfd8236492 = "1.0.
|
|
5
|
+
/*! Depict.ai search and product listing SDK */ const $ec291e0010116877$export$83d89fbfd8236492 = "1.0.9";
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
@@ -786,8 +786,8 @@ function $6e41f1fde994db72$export$f33414a4df0afd3f({ product_card_template_: pro
|
|
|
786
786
|
});
|
|
787
787
|
return get_elements; // https://github.com/solidjs/solid/releases/tag/v1.7.0
|
|
788
788
|
}
|
|
789
|
-
/**
|
|
790
|
-
* Get one placeholder element. It will be cloned for each placeholder for ultimate performance even when solid-js isn't rendering the placeholders.
|
|
789
|
+
/**
|
|
790
|
+
* Get one placeholder element. It will be cloned for each placeholder for ultimate performance even when solid-js isn't rendering the placeholders.
|
|
791
791
|
*/ function $6e41f1fde994db72$var$Placeholder({ product_card_template_: product_card_template_ }) {
|
|
792
792
|
const get_cloned_placeholders = (element_to_clone = $6e41f1fde994db72$var$cached_placeholder_element)=>Array.isArray(element_to_clone) ? element_to_clone.map((el)=>el instanceof Node ? el.cloneNode(true) : el) : element_to_clone;
|
|
793
793
|
if ($6e41f1fde994db72$var$cached_placeholder_element) return get_cloned_placeholders();
|
|
@@ -832,8 +832,8 @@ function $6e41f1fde994db72$export$f33414a4df0afd3f({ product_card_template_: pro
|
|
|
832
832
|
}
|
|
833
833
|
|
|
834
834
|
|
|
835
|
-
/*
|
|
836
|
-
* Usually product templates are somewhat height-elastic depending on the content, i.e. if the title is longer we might up to two extra rows for this. That means that the placeholders almost never will reflect the size of the actual content when we do scroll restoration. This magic number specifies how many extra placeholders we should render everytime to compensate for this, since if the placeholders are in total shorter than the old scroll location the scroll restoration won't work.
|
|
835
|
+
/*
|
|
836
|
+
* Usually product templates are somewhat height-elastic depending on the content, i.e. if the title is longer we might up to two extra rows for this. That means that the placeholders almost never will reflect the size of the actual content when we do scroll restoration. This magic number specifies how many extra placeholders we should render everytime to compensate for this, since if the placeholders are in total shorter than the old scroll location the scroll restoration won't work.
|
|
837
837
|
*/ const $7747fe1a8c5652e3$export$6c9030e511152266 = 30;
|
|
838
838
|
|
|
839
839
|
|
|
@@ -925,8 +925,8 @@ function $0e0b96a8dc1ad492$export$63dd0350f8559dda({ displays_by_key_: displays_
|
|
|
925
925
|
|
|
926
926
|
|
|
927
927
|
|
|
928
|
-
/**
|
|
929
|
-
* Gets product_id (the thing we key the rendering on) from a display
|
|
928
|
+
/**
|
|
929
|
+
* Gets product_id (the thing we key the rendering on) from a display
|
|
930
930
|
*/ function $16351e4c87b90b3d$export$548d053aba053d79(display) {
|
|
931
931
|
if ("variant_index" in display) {
|
|
932
932
|
const actual_display = display.variant_displays[display.variant_index];
|
|
@@ -1227,9 +1227,9 @@ function $2d25e42846eac370$export$3925f87b1545cfc6({ plp_results_: plp_results_
|
|
|
1227
1227
|
return _el$;
|
|
1228
1228
|
})();
|
|
1229
1229
|
}
|
|
1230
|
-
/**
|
|
1231
|
-
* Sets styling to styling generated by "Layout" (n_col_styling_with_dist) depending on if filters are open or not
|
|
1232
|
-
* This function is special to the actual PLPResults.
|
|
1230
|
+
/**
|
|
1231
|
+
* Sets styling to styling generated by "Layout" (n_col_styling_with_dist) depending on if filters are open or not
|
|
1232
|
+
* This function is special to the actual PLPResults.
|
|
1233
1233
|
*/ function $2d25e42846eac370$var$results_grid_styling_generator({ layout_options_: layout_options_ , sort_or_filter_open_: sort_or_filter_open_ , set_styling_: set_styling_ , selector_beginning_: selector_beginning_ }) {
|
|
1234
1234
|
(0, $kyEB6$createRenderEffect)(()=>{
|
|
1235
1235
|
// Add grid styling that changes when filters get opened/closed
|
|
@@ -3919,9 +3919,9 @@ function $5efb5894079b220e$export$b288c38ae3fddb56({ available_filters_: availab
|
|
|
3919
3919
|
last_remote_state = available_filters_();
|
|
3920
3920
|
});
|
|
3921
3921
|
}
|
|
3922
|
-
/**
|
|
3923
|
-
* When a filter is only available locally due to being selected in a previous navigation, we want to make that clear and prevent further "invalid" choices.
|
|
3924
|
-
* This sets the counts to 0 (if applicable) and removes non-selected options (if applicable)
|
|
3922
|
+
/**
|
|
3923
|
+
* When a filter is only available locally due to being selected in a previous navigation, we want to make that clear and prevent further "invalid" choices.
|
|
3924
|
+
* This sets the counts to 0 (if applicable) and removes non-selected options (if applicable)
|
|
3925
3925
|
*/ function $5efb5894079b220e$var$modify_only_local_filter(local_filter_object, selected_filter) {
|
|
3926
3926
|
const old_meta = local_filter_object.meta;
|
|
3927
3927
|
const selected_filter_data = selected_filter.data;
|
|
@@ -4361,10 +4361,10 @@ const $4147651646da990a$var$range_delimiter = "-";
|
|
|
4361
4361
|
const $4147651646da990a$var$string_item_delimiter = "‚"; // This is not a comma but a comma-like character that browsers will render in the URL bar.
|
|
4362
4362
|
const $4147651646da990a$var$array_item_delimiter = "‣"; // FIXME: decide on a character. Could theoretically be a double string delimiter.
|
|
4363
4363
|
const $4147651646da990a$var$empty_item_replacement = "0️⃣";
|
|
4364
|
-
/**
|
|
4365
|
-
* Checks if a given array of filter data can be neatly serialized into an URL query parameter, or if it should fall back to JSON+base64.
|
|
4366
|
-
* The requirements are either an array of strings, containing no reserved characters, or an array of arrays of strings, containing no reserved characters.
|
|
4367
|
-
* No deep or mixed nesting levels are supported.
|
|
4364
|
+
/**
|
|
4365
|
+
* Checks if a given array of filter data can be neatly serialized into an URL query parameter, or if it should fall back to JSON+base64.
|
|
4366
|
+
* The requirements are either an array of strings, containing no reserved characters, or an array of arrays of strings, containing no reserved characters.
|
|
4367
|
+
* No deep or mixed nesting levels are supported.
|
|
4368
4368
|
*/ function $4147651646da990a$var$array_is_serializable(array, is_root = true) {
|
|
4369
4369
|
if (array.every((item)=>Array.isArray(item))) {
|
|
4370
4370
|
if (!is_root) // Deeply nested arrays are not supported, but also don't exist as filters (yet)
|
|
@@ -4376,10 +4376,10 @@ const $4147651646da990a$var$empty_item_replacement = "0️⃣";
|
|
|
4376
4376
|
// Encoding reserved characters is not supported
|
|
4377
4377
|
return !array.some((item)=>item.includes($4147651646da990a$var$array_item_delimiter) || item.includes($4147651646da990a$var$string_item_delimiter) || item === $4147651646da990a$var$empty_item_replacement);
|
|
4378
4378
|
}
|
|
4379
|
-
/**
|
|
4380
|
-
* Human readable string[] or string[][] serialization for URLs.
|
|
4381
|
-
* @param array
|
|
4382
|
-
* @returns
|
|
4379
|
+
/**
|
|
4380
|
+
* Human readable string[] or string[][] serialization for URLs.
|
|
4381
|
+
* @param array
|
|
4382
|
+
* @returns
|
|
4383
4383
|
*/ function $4147651646da990a$var$encode_array(array) {
|
|
4384
4384
|
const is_nested = array.every((item)=>Array.isArray(item));
|
|
4385
4385
|
if (is_nested) return array.map($4147651646da990a$var$encode_array).join($4147651646da990a$var$array_item_delimiter) + $4147651646da990a$var$array_item_delimiter; // Nested arrays require a suffix to close nesting levels
|
|
@@ -5474,8 +5474,8 @@ function $ccd5db07a3a069c5$export$477caf01aecaeb2a(options) {
|
|
|
5474
5474
|
}
|
|
5475
5475
|
};
|
|
5476
5476
|
}
|
|
5477
|
-
/**
|
|
5478
|
-
* Writes the sorting and filters to the URL query parameters when they change.
|
|
5477
|
+
/**
|
|
5478
|
+
* Writes the sorting and filters to the URL query parameters when they change.
|
|
5479
5479
|
*/ function $ccd5db07a3a069c5$var$start_href_writer({ get_sorting_: get_sorting_ , get_selected_filters_: get_selected_filters_ , router_: router_ , get_has_sideways_filter_clearing_flag_: get_has_sideways_filter_clearing_flag_ }) {
|
|
5480
5480
|
(0, $kyEB6$createEffect)((0, $kyEB6$on)([
|
|
5481
5481
|
get_sorting_,
|
|
@@ -5515,8 +5515,8 @@ function $ccd5db07a3a069c5$var$delete_sideways_param_flag(searchParams) {
|
|
|
5515
5515
|
|
|
5516
5516
|
|
|
5517
5517
|
class $4fd2ba03703a7d92$export$7e1297a3a19f10d8 {
|
|
5518
|
-
/**
|
|
5519
|
-
* Function that will be called when we want to navigate, or a string saying it's not an SPA. You can change this OTG
|
|
5518
|
+
/**
|
|
5519
|
+
* Function that will be called when we want to navigate, or a string saying it's not an SPA. You can change this OTG
|
|
5520
5520
|
*/ #throwing_on_navigation(...args) {
|
|
5521
5521
|
const { on_navigation_: on_navigation_ } = this;
|
|
5522
5522
|
if (typeof on_navigation_ !== "function") throw new Error("on_navigation_ is not a function");
|
|
@@ -5529,14 +5529,14 @@ class $4fd2ba03703a7d92$export$7e1297a3a19f10d8 {
|
|
|
5529
5529
|
});
|
|
5530
5530
|
}
|
|
5531
5531
|
}
|
|
5532
|
-
/**
|
|
5533
|
-
* Checks if this tab shouldn't navigate because user wants to open in new tab
|
|
5532
|
+
/**
|
|
5533
|
+
* Checks if this tab shouldn't navigate because user wants to open in new tab
|
|
5534
5534
|
*/ #dont_attempt_navigation(ev) {
|
|
5535
5535
|
return ev?.button || ev?.metaKey || ev?.ctrlKey;
|
|
5536
5536
|
}
|
|
5537
|
-
/**
|
|
5538
|
-
* Vue has async router that needs to be awaited (it navigates after a microtask)
|
|
5539
|
-
* This standardises waiting for all kinds of routers
|
|
5537
|
+
/**
|
|
5538
|
+
* Vue has async router that needs to be awaited (it navigates after a microtask)
|
|
5539
|
+
* This standardises waiting for all kinds of routers
|
|
5540
5540
|
*/ #get_navigation_happened_promise(is_replace) {
|
|
5541
5541
|
return new Promise((resolve)=>{
|
|
5542
5542
|
const handler = (what_happened)=>{
|
|
@@ -5549,19 +5549,19 @@ class $4fd2ba03703a7d92$export$7e1297a3a19f10d8 {
|
|
|
5549
5549
|
});
|
|
5550
5550
|
}
|
|
5551
5551
|
navigate_ = {
|
|
5552
|
-
/**
|
|
5553
|
-
* Call this if you *just* want to replace the state object in history.state
|
|
5552
|
+
/**
|
|
5553
|
+
* Call this if you *just* want to replace the state object in history.state
|
|
5554
5554
|
*/ replace_state_: (new_state)=>{
|
|
5555
5555
|
// This doesn't break any router, so we just do this directly for now, since many don't expose an interface for changing the state
|
|
5556
5556
|
history.replaceState(new_state, "");
|
|
5557
5557
|
},
|
|
5558
|
-
/**
|
|
5559
|
-
* Call this to change the URL
|
|
5560
|
-
* @param new_url_ new URL to go to
|
|
5561
|
-
* @param event_ event if you have this in a click handler, will not do anything on cmd/ctrl or non-left click then
|
|
5562
|
-
* @param force_spa_navigation_ if you want to force SPA navigation even if on_navigation_ is set to "hard_navigation". You should only set this to true for inter-SDK-page navigations
|
|
5563
|
-
* @param is_replace_ if you want to replace the current URL in history instead of pushing a new one
|
|
5564
|
-
* @param category_query_id_ If you are navigating to a category and know the query_id of, please provide it. This is for making a better devEx in js-ui
|
|
5558
|
+
/**
|
|
5559
|
+
* Call this to change the URL
|
|
5560
|
+
* @param new_url_ new URL to go to
|
|
5561
|
+
* @param event_ event if you have this in a click handler, will not do anything on cmd/ctrl or non-left click then
|
|
5562
|
+
* @param force_spa_navigation_ if you want to force SPA navigation even if on_navigation_ is set to "hard_navigation". You should only set this to true for inter-SDK-page navigations
|
|
5563
|
+
* @param is_replace_ if you want to replace the current URL in history instead of pushing a new one
|
|
5564
|
+
* @param category_query_id_ If you are navigating to a category and know the query_id of, please provide it. This is for making a better devEx in js-ui
|
|
5565
5565
|
*/ go_to_: (0, $kyEB6$catchify)(async ({ new_url_: raw_new_url , event_: event_ , force_spa_navigation_: force_spa_navigation_ , is_replace_: is_replace_ , category_query_id_: category_query_id_ })=>{
|
|
5566
5566
|
const new_url_ = raw_new_url instanceof URL ? raw_new_url : new URL(raw_new_url, location.origin);
|
|
5567
5567
|
const wants_hard_navigation = this.on_navigation_ === "hard_navigation";
|
|
@@ -6369,8 +6369,8 @@ async function $bfd908d13d90934c$export$e16630ecb9644a1c({ on_submit_with_unchan
|
|
|
6369
6369
|
|
|
6370
6370
|
|
|
6371
6371
|
|
|
6372
|
-
/**
|
|
6373
|
-
* Expand an object where every value in the top-level is an accessor into a normal object. Used for converting solid_i18n objects into external i18n typed objects.
|
|
6372
|
+
/**
|
|
6373
|
+
* Expand an object where every value in the top-level is an accessor into a normal object. Used for converting solid_i18n objects into external i18n typed objects.
|
|
6374
6374
|
*/ const $c97b1f0e44afb9d2$export$27b710c08412a7ad = (obj)=>{
|
|
6375
6375
|
return Object.fromEntries(Object.keys(obj).map((key)=>[
|
|
6376
6376
|
key,
|
|
@@ -7911,8 +7911,8 @@ function $4ca91518c9a35379$export$828dcdd425fd3231(aligner) {
|
|
|
7911
7911
|
|
|
7912
7912
|
|
|
7913
7913
|
const $806c97b931758897$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$kyEB6$template)(`<div class="depict plp search"></div>`, 2);
|
|
7914
|
-
/**
|
|
7915
|
-
* Type for the private properties that are shared between the different exported search SDK wrapper functions. SDK users are not allowed to change/access these, they're an internal implementation detail.
|
|
7914
|
+
/**
|
|
7915
|
+
* Type for the private properties that are shared between the different exported search SDK wrapper functions. SDK users are not allowed to change/access these, they're an internal implementation detail.
|
|
7916
7916
|
*/ const $806c97b931758897$var$privately_shared_properties = /*@__PURE__*/ new WeakMap();
|
|
7917
7917
|
const $806c97b931758897$var$min_products_to_fetch_ = 20;
|
|
7918
7918
|
const $806c97b931758897$export$bde3eb976dfded9 = (depict_search)=>$806c97b931758897$var$privately_shared_properties.get(depict_search)?.search_query_updating_blocked_;
|
|
@@ -8113,14 +8113,14 @@ class $806c97b931758897$export$ac6237957a15b3f0 {
|
|
|
8113
8113
|
set market(market) {
|
|
8114
8114
|
this.#market_signal[1](market);
|
|
8115
8115
|
}
|
|
8116
|
-
async fetchSearchResults(query, filters,
|
|
8116
|
+
async fetchSearchResults(query, filters, maxResults = 50) {
|
|
8117
8117
|
const { depict_api_: depict_api_ } = $806c97b931758897$var$privately_shared_properties.get(this);
|
|
8118
8118
|
const result = await depict_api_.query({
|
|
8119
8119
|
tenant: this.merchant,
|
|
8120
8120
|
market: this.market,
|
|
8121
8121
|
query: query,
|
|
8122
8122
|
filters: filters,
|
|
8123
|
-
limit:
|
|
8123
|
+
limit: maxResults
|
|
8124
8124
|
});
|
|
8125
8125
|
if (result.failed) throw new Error("Failed to fetch search results");
|
|
8126
8126
|
return result.displays;
|
|
@@ -8309,8 +8309,8 @@ const $6891c018a834cfdd$export$d86a33413558014e = (openModalParams)=>{
|
|
|
8309
8309
|
}
|
|
8310
8310
|
const { cleanup: cleanup } = (0, $4ca91518c9a35379$export$828dcdd425fd3231)(openModalParams.element);
|
|
8311
8311
|
let dispose_aligner;
|
|
8312
|
-
/**
|
|
8313
|
-
* Setting position to fixed is important to make the modal work with align_field.
|
|
8312
|
+
/**
|
|
8313
|
+
* Setting position to fixed is important to make the modal work with align_field.
|
|
8314
8314
|
*/ const style_props_ = (0, $kyEB6$createSignal)({
|
|
8315
8315
|
position: "fixed"
|
|
8316
8316
|
});
|
|
@@ -8406,8 +8406,8 @@ class $753e9b2889a47c89$export$3ccaa27d81dd8556 extends EventTarget {
|
|
|
8406
8406
|
})();
|
|
8407
8407
|
return new Set();
|
|
8408
8408
|
})();
|
|
8409
|
-
/**
|
|
8410
|
-
* Returns if the "replacement page" is currently open
|
|
8409
|
+
/**
|
|
8410
|
+
* Returns if the "replacement page" is currently open
|
|
8411
8411
|
*/ get open_() {
|
|
8412
8412
|
// make this "readonly" from the outside, the only way to open is by making the url change so that is_page_ returns true
|
|
8413
8413
|
return this.#is_open;
|
|
@@ -8492,26 +8492,26 @@ class $753e9b2889a47c89$export$3ccaa27d81dd8556 extends EventTarget {
|
|
|
8492
8492
|
if (what_happened !== "popstate") return;
|
|
8493
8493
|
const cleaned_current_url = $753e9b2889a47c89$var$clean_url(location.href);
|
|
8494
8494
|
if (!$753e9b2889a47c89$export$3ccaa27d81dd8556.#visited_urls.has(cleaned_current_url)) {
|
|
8495
|
-
/*
|
|
8496
|
-
What does this check do? Well, there's a bug without it where people end up on a page that they shouldn't see (i.e. a somewhat blank page).
|
|
8497
|
-
The culprit of that bug is: the browser remembers where to make "hard"-navigations (i.e. a full document rebuild with a new `document` and `window` object) when going back and forwards in the history and where to just change the url. What it doesn't always correctly remember (observed in at least chrome and firefox), is *what document to hard-navigate to*. Therefore, we have to jump in and take care of that.
|
|
8498
|
-
The reproduction is this:
|
|
8499
|
-
Spendrups has set up a search page for us under /start/search. We don't want to hard-reload the page though to get there.
|
|
8500
|
-
1. Go to a product page like https://ehandel.spendrups.se/Product/1104201
|
|
8501
|
-
2. Make a search
|
|
8502
|
-
We use PageReplacer to just replace the current page (and the url in the address bar) with the search page. The thing is though, that when going back now the URL just updates but the browser doesn't actually navigate - that's fine, PageReplacer will just restore the old page contents
|
|
8503
|
-
3. Try going back just for fun
|
|
8504
|
-
Everything works as expected
|
|
8505
|
-
4. Go forwards again (just for fun, skip this if you skipped 3)
|
|
8506
|
-
Now the trouble comes when we introduce "hard" navigation.
|
|
8507
|
-
5. Click on a search result. The browser will now "hard" navigate to a new page.
|
|
8508
|
-
6. Click "back"
|
|
8509
|
-
What happens now, is that the browser hard-navigates to /start/search.
|
|
8510
|
-
7. Click "back" again
|
|
8511
|
-
What happens now, is that the browser "soft-navigates" (just changes the URL) to https://ehandel.spendrups.se/Product/1104201
|
|
8512
|
-
PageReplacer unload itself and reveals the original document - it is expected to be the one under https://ehandel.spendrups.se/Product/1104201, but actually it is the one under /start/search - a white page.
|
|
8513
|
-
|
|
8514
|
-
|
|
8495
|
+
/*
|
|
8496
|
+
What does this check do? Well, there's a bug without it where people end up on a page that they shouldn't see (i.e. a somewhat blank page).
|
|
8497
|
+
The culprit of that bug is: the browser remembers where to make "hard"-navigations (i.e. a full document rebuild with a new `document` and `window` object) when going back and forwards in the history and where to just change the url. What it doesn't always correctly remember (observed in at least chrome and firefox), is *what document to hard-navigate to*. Therefore, we have to jump in and take care of that.
|
|
8498
|
+
The reproduction is this:
|
|
8499
|
+
Spendrups has set up a search page for us under /start/search. We don't want to hard-reload the page though to get there.
|
|
8500
|
+
1. Go to a product page like https://ehandel.spendrups.se/Product/1104201
|
|
8501
|
+
2. Make a search
|
|
8502
|
+
We use PageReplacer to just replace the current page (and the url in the address bar) with the search page. The thing is though, that when going back now the URL just updates but the browser doesn't actually navigate - that's fine, PageReplacer will just restore the old page contents
|
|
8503
|
+
3. Try going back just for fun
|
|
8504
|
+
Everything works as expected
|
|
8505
|
+
4. Go forwards again (just for fun, skip this if you skipped 3)
|
|
8506
|
+
Now the trouble comes when we introduce "hard" navigation.
|
|
8507
|
+
5. Click on a search result. The browser will now "hard" navigate to a new page.
|
|
8508
|
+
6. Click "back"
|
|
8509
|
+
What happens now, is that the browser hard-navigates to /start/search.
|
|
8510
|
+
7. Click "back" again
|
|
8511
|
+
What happens now, is that the browser "soft-navigates" (just changes the URL) to https://ehandel.spendrups.se/Product/1104201
|
|
8512
|
+
PageReplacer unload itself and reveals the original document - it is expected to be the one under https://ehandel.spendrups.se/Product/1104201, but actually it is the one under /start/search - a white page.
|
|
8513
|
+
The fix: is to remember all pages that we have visited since the creation of `window` (we do that by having a static property on PageReplacer since we assume the PageReplacer source code will only exist once on the page and will be loaded at page load, the latter assumption might be wrong, but I hope not). If we get a "popstate" event (meaning back or forwards button, not new page being pushed) to an unknown page we reload.
|
|
8514
|
+
*/ (0, $kyEB6$dlog)("PageReplacer: ", cleaned_current_url, " hasn't been visited since document was created, reloading since we won't be able to show this page otherwise");
|
|
8515
8515
|
location.reload();
|
|
8516
8516
|
$753e9b2889a47c89$export$3ccaa27d81dd8556.#reverting_permitted = false; // Disallow any reverting since we can't - it would flash a white page until the reload has finished.
|
|
8517
8517
|
this.#unload(); // Call unload to "kill" the solid-js stuff quicker so that it stops updating - the user is expecting the next thing that happens to be a navigation to the actual page the URL says they're on.
|
|
@@ -8520,8 +8520,8 @@ class $753e9b2889a47c89$export$3ccaa27d81dd8556 extends EventTarget {
|
|
|
8520
8520
|
(0, $kyEB6$instant_exec_on_suspect_history_change).add(on_maybe_popstate);
|
|
8521
8521
|
this.#revert_fns.push(()=>(0, $kyEB6$instant_exec_on_suspect_history_change).delete(on_maybe_popstate)); // Don't run the bugfixer if there isn't a PageReplacer page open since I assume the bug only happens when going back from a PageReplace'd page
|
|
8522
8522
|
}
|
|
8523
|
-
/**
|
|
8524
|
-
* Stops listening to URL changes and closes the page (if it is currently open)
|
|
8523
|
+
/**
|
|
8524
|
+
* Stops listening to URL changes and closes the page (if it is currently open)
|
|
8525
8525
|
*/ destroy_() {
|
|
8526
8526
|
this.#unload();
|
|
8527
8527
|
this.#stop_listening?.();
|
|
@@ -8536,8 +8536,8 @@ class $753e9b2889a47c89$export$3ccaa27d81dd8556 extends EventTarget {
|
|
|
8536
8536
|
if (!is_spa_) (0, $6936724b9e0b98d5$export$689e204eadb33baf)(this); // Make so that clicking on links to the previous page work instantly
|
|
8537
8537
|
}
|
|
8538
8538
|
}
|
|
8539
|
-
/**
|
|
8540
|
-
* Remove hash from URL
|
|
8539
|
+
/**
|
|
8540
|
+
* Remove hash from URL
|
|
8541
8541
|
*/ function $753e9b2889a47c89$var$clean_url(url) {
|
|
8542
8542
|
// Would want to have this a static private function on PageReplacer, but that's not supported in MobileSafari yet
|
|
8543
8543
|
// remove hash, all other params *could* trigger a re-request
|