@depict-ai/ui 1.0.15 → 1.0.17
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/client/main.js +8814 -0
- package/dist/client/module.js +8777 -0
- package/dist/index.d.ts +542 -542
- package/dist/main.js +77 -82
- package/dist/module.js +77 -82
- package/dist/server/main.js +7830 -0
- package/dist/server/module.js +7793 -0
- 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/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.17";
|
|
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];
|
|
@@ -995,22 +995,17 @@ function $a73063cc642f3e5f$export$43f0fb951fcb0c54({ displays_by_key_: displays_
|
|
|
995
995
|
];
|
|
996
996
|
},
|
|
997
997
|
children: (product_id, index)=>{
|
|
998
|
-
// We're using `untrack` here since we don't want to react in here to displays_by_key changing
|
|
999
|
-
// As long as our key stays the same we assume that the display hasn't changed, so we don't want to rerender
|
|
1000
|
-
// If the key gets removed, <For> will remove us
|
|
1001
998
|
const owner = (0, $iBTHO$solidjs.getOwner)();
|
|
1002
999
|
const display_accessor = (0, $iBTHO$solidjs.createMemo)(()=>displays_by_key_().get(product_id));
|
|
1003
|
-
const [product_card_resource] = (0, $iBTHO$solidjs.createResource)(
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
]), // re-render when merchant or market changes
|
|
1007
|
-
([merchant, market])=>{
|
|
1000
|
+
const [product_card_resource] = (0, $iBTHO$solidjs.createResource)(display_accessor, // re-render when the reference to the display object changes
|
|
1001
|
+
// this should only be the case when the merchant or market changes and the new request has completed
|
|
1002
|
+
(display)=>{
|
|
1008
1003
|
// get display in the function that re-runs when merchant or market have changed, since the display may have changed but product_id not
|
|
1009
|
-
const display = (0, $iBTHO$solidjs.untrack)(display_accessor);
|
|
1010
1004
|
return product_card_template_(display, {
|
|
1011
1005
|
set_on_index_change: (fn)=>(0, $iBTHO$solidjs.runWithOwner)(owner, ()=>(0, $iBTHO$solidjs.createEffect)(()=>fn(index()))),
|
|
1012
|
-
merchant:
|
|
1013
|
-
market
|
|
1006
|
+
merchant: (0, $iBTHO$solidjs.untrack)(merchant_),
|
|
1007
|
+
// this means that the merchant and market provided to the template is wrong while we do another fetch, but I don't see how anyone would need to know the correct market there
|
|
1008
|
+
market: (0, $iBTHO$solidjs.untrack)(market_)
|
|
1014
1009
|
});
|
|
1015
1010
|
});
|
|
1016
1011
|
const node_accessor = (0, $5f7d55c710fd1bc2$export$2f0cbfbb4354bb52)(product_card_resource);
|
|
@@ -1262,9 +1257,9 @@ function $fe76fb463cc60b89$export$3925f87b1545cfc6({ plp_results_: plp_results_
|
|
|
1262
1257
|
return _el$;
|
|
1263
1258
|
})();
|
|
1264
1259
|
}
|
|
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.
|
|
1260
|
+
/**
|
|
1261
|
+
* Sets styling to styling generated by "Layout" (n_col_styling_with_dist) depending on if filters are open or not
|
|
1262
|
+
* This function is special to the actual PLPResults.
|
|
1268
1263
|
*/ 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
1264
|
(0, $iBTHO$solidjs.createRenderEffect)(()=>{
|
|
1270
1265
|
// Add grid styling that changes when filters get opened/closed
|
|
@@ -3954,9 +3949,9 @@ function $70482f04605572e2$export$b288c38ae3fddb56({ available_filters_: availab
|
|
|
3954
3949
|
last_remote_state = available_filters_();
|
|
3955
3950
|
});
|
|
3956
3951
|
}
|
|
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)
|
|
3952
|
+
/**
|
|
3953
|
+
* 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.
|
|
3954
|
+
* This sets the counts to 0 (if applicable) and removes non-selected options (if applicable)
|
|
3960
3955
|
*/ function $70482f04605572e2$var$modify_only_local_filter(local_filter_object, selected_filter) {
|
|
3961
3956
|
const old_meta = local_filter_object.meta;
|
|
3962
3957
|
const selected_filter_data = selected_filter.data;
|
|
@@ -4396,10 +4391,10 @@ const $1ab22f2cd39b3061$var$range_delimiter = "-";
|
|
|
4396
4391
|
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
4392
|
const $1ab22f2cd39b3061$var$array_item_delimiter = "‣"; // FIXME: decide on a character. Could theoretically be a double string delimiter.
|
|
4398
4393
|
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.
|
|
4394
|
+
/**
|
|
4395
|
+
* 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.
|
|
4396
|
+
* The requirements are either an array of strings, containing no reserved characters, or an array of arrays of strings, containing no reserved characters.
|
|
4397
|
+
* No deep or mixed nesting levels are supported.
|
|
4403
4398
|
*/ function $1ab22f2cd39b3061$var$array_is_serializable(array, is_root = true) {
|
|
4404
4399
|
if (array.every((item)=>Array.isArray(item))) {
|
|
4405
4400
|
if (!is_root) // Deeply nested arrays are not supported, but also don't exist as filters (yet)
|
|
@@ -4411,10 +4406,10 @@ const $1ab22f2cd39b3061$var$empty_item_replacement = "0️⃣";
|
|
|
4411
4406
|
// Encoding reserved characters is not supported
|
|
4412
4407
|
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
4408
|
}
|
|
4414
|
-
/**
|
|
4415
|
-
* Human readable string[] or string[][] serialization for URLs.
|
|
4416
|
-
* @param array
|
|
4417
|
-
* @returns
|
|
4409
|
+
/**
|
|
4410
|
+
* Human readable string[] or string[][] serialization for URLs.
|
|
4411
|
+
* @param array
|
|
4412
|
+
* @returns
|
|
4418
4413
|
*/ function $1ab22f2cd39b3061$var$encode_array(array) {
|
|
4419
4414
|
const is_nested = array.every((item)=>Array.isArray(item));
|
|
4420
4415
|
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 +5504,8 @@ function $c79fd10a3ab7d6e0$export$477caf01aecaeb2a(options) {
|
|
|
5509
5504
|
}
|
|
5510
5505
|
};
|
|
5511
5506
|
}
|
|
5512
|
-
/**
|
|
5513
|
-
* Writes the sorting and filters to the URL query parameters when they change.
|
|
5507
|
+
/**
|
|
5508
|
+
* Writes the sorting and filters to the URL query parameters when they change.
|
|
5514
5509
|
*/ 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
5510
|
(0, $iBTHO$solidjs.createEffect)((0, $iBTHO$solidjs.on)([
|
|
5516
5511
|
get_sorting_,
|
|
@@ -5550,8 +5545,8 @@ function $c79fd10a3ab7d6e0$var$delete_sideways_param_flag(searchParams) {
|
|
|
5550
5545
|
|
|
5551
5546
|
|
|
5552
5547
|
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
|
|
5548
|
+
/**
|
|
5549
|
+
* 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
5550
|
*/ #throwing_on_navigation(...args) {
|
|
5556
5551
|
const { on_navigation_: on_navigation_ } = this;
|
|
5557
5552
|
if (typeof on_navigation_ !== "function") throw new Error("on_navigation_ is not a function");
|
|
@@ -5564,14 +5559,14 @@ class $e96dd13889871fc0$export$7e1297a3a19f10d8 {
|
|
|
5564
5559
|
});
|
|
5565
5560
|
}
|
|
5566
5561
|
}
|
|
5567
|
-
/**
|
|
5568
|
-
* Checks if this tab shouldn't navigate because user wants to open in new tab
|
|
5562
|
+
/**
|
|
5563
|
+
* Checks if this tab shouldn't navigate because user wants to open in new tab
|
|
5569
5564
|
*/ #dont_attempt_navigation(ev) {
|
|
5570
5565
|
return ev?.button || ev?.metaKey || ev?.ctrlKey;
|
|
5571
5566
|
}
|
|
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
|
|
5567
|
+
/**
|
|
5568
|
+
* Vue has async router that needs to be awaited (it navigates after a microtask)
|
|
5569
|
+
* This standardises waiting for all kinds of routers
|
|
5575
5570
|
*/ #get_navigation_happened_promise(is_replace) {
|
|
5576
5571
|
return new Promise((resolve)=>{
|
|
5577
5572
|
const handler = (what_happened)=>{
|
|
@@ -5584,19 +5579,19 @@ class $e96dd13889871fc0$export$7e1297a3a19f10d8 {
|
|
|
5584
5579
|
});
|
|
5585
5580
|
}
|
|
5586
5581
|
navigate_ = {
|
|
5587
|
-
/**
|
|
5588
|
-
* Call this if you *just* want to replace the state object in history.state
|
|
5582
|
+
/**
|
|
5583
|
+
* Call this if you *just* want to replace the state object in history.state
|
|
5589
5584
|
*/ replace_state_: (new_state)=>{
|
|
5590
5585
|
// 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
5586
|
history.replaceState(new_state, "");
|
|
5592
5587
|
},
|
|
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
|
|
5588
|
+
/**
|
|
5589
|
+
* Call this to change the URL
|
|
5590
|
+
* @param new_url_ new URL to go to
|
|
5591
|
+
* @param event_ event if you have this in a click handler, will not do anything on cmd/ctrl or non-left click then
|
|
5592
|
+
* @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
|
|
5593
|
+
* @param is_replace_ if you want to replace the current URL in history instead of pushing a new one
|
|
5594
|
+
* @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
5595
|
*/ 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
5596
|
const new_url_ = raw_new_url instanceof URL ? raw_new_url : new URL(raw_new_url, location.origin);
|
|
5602
5597
|
const wants_hard_navigation = this.on_navigation_ === "hard_navigation";
|
|
@@ -6404,8 +6399,8 @@ async function $f328bd45f8ede33c$export$e16630ecb9644a1c({ on_submit_with_unchan
|
|
|
6404
6399
|
|
|
6405
6400
|
|
|
6406
6401
|
|
|
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.
|
|
6402
|
+
/**
|
|
6403
|
+
* 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
6404
|
*/ const $639c124c22b6cbaa$export$27b710c08412a7ad = (obj)=>{
|
|
6410
6405
|
return Object.fromEntries(Object.keys(obj).map((key)=>[
|
|
6411
6406
|
key,
|
|
@@ -7947,8 +7942,8 @@ function $d8e94ea381ab57fa$export$828dcdd425fd3231(aligner) {
|
|
|
7947
7942
|
|
|
7948
7943
|
|
|
7949
7944
|
const $2c61e4cd8229c49a$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$iBTHO$solidjsweb.template)(`<div class="depict plp search"></div>`, 2);
|
|
7950
|
-
/**
|
|
7951
|
-
* 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.
|
|
7945
|
+
/**
|
|
7946
|
+
* 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.
|
|
7952
7947
|
*/ const $2c61e4cd8229c49a$var$privately_shared_properties = /*@__PURE__*/ new WeakMap();
|
|
7953
7948
|
const $2c61e4cd8229c49a$var$min_products_to_fetch_ = 20;
|
|
7954
7949
|
const $2c61e4cd8229c49a$export$bde3eb976dfded9 = (depict_search)=>$2c61e4cd8229c49a$var$privately_shared_properties.get(depict_search)?.search_query_updating_blocked_;
|
|
@@ -8345,8 +8340,8 @@ const $9c143d25df1fc2a2$export$d86a33413558014e = (openModalParams)=>{
|
|
|
8345
8340
|
}
|
|
8346
8341
|
const { cleanup: cleanup } = (0, $d8e94ea381ab57fa$export$828dcdd425fd3231)(openModalParams.element);
|
|
8347
8342
|
let dispose_aligner;
|
|
8348
|
-
/**
|
|
8349
|
-
* Setting position to fixed is important to make the modal work with align_field.
|
|
8343
|
+
/**
|
|
8344
|
+
* Setting position to fixed is important to make the modal work with align_field.
|
|
8350
8345
|
*/ const style_props_ = (0, $iBTHO$solidjs.createSignal)({
|
|
8351
8346
|
position: "fixed"
|
|
8352
8347
|
});
|
|
@@ -8442,8 +8437,8 @@ class $0a6acf31d1eae57c$export$3ccaa27d81dd8556 extends EventTarget {
|
|
|
8442
8437
|
})();
|
|
8443
8438
|
return new Set();
|
|
8444
8439
|
})();
|
|
8445
|
-
/**
|
|
8446
|
-
* Returns if the "replacement page" is currently open
|
|
8440
|
+
/**
|
|
8441
|
+
* Returns if the "replacement page" is currently open
|
|
8447
8442
|
*/ get open_() {
|
|
8448
8443
|
// make this "readonly" from the outside, the only way to open is by making the url change so that is_page_ returns true
|
|
8449
8444
|
return this.#is_open;
|
|
@@ -8528,26 +8523,26 @@ class $0a6acf31d1eae57c$export$3ccaa27d81dd8556 extends EventTarget {
|
|
|
8528
8523
|
if (what_happened !== "popstate") return;
|
|
8529
8524
|
const cleaned_current_url = $0a6acf31d1eae57c$var$clean_url(location.href);
|
|
8530
8525
|
if (!$0a6acf31d1eae57c$export$3ccaa27d81dd8556.#visited_urls.has(cleaned_current_url)) {
|
|
8531
|
-
/*
|
|
8532
|
-
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).
|
|
8533
|
-
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.
|
|
8534
|
-
The reproduction is this:
|
|
8535
|
-
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.
|
|
8536
|
-
1. Go to a product page like https://ehandel.spendrups.se/Product/1104201
|
|
8537
|
-
2. Make a search
|
|
8538
|
-
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
|
|
8539
|
-
3. Try going back just for fun
|
|
8540
|
-
Everything works as expected
|
|
8541
|
-
4. Go forwards again (just for fun, skip this if you skipped 3)
|
|
8542
|
-
Now the trouble comes when we introduce "hard" navigation.
|
|
8543
|
-
5. Click on a search result. The browser will now "hard" navigate to a new page.
|
|
8544
|
-
6. Click "back"
|
|
8545
|
-
What happens now, is that the browser hard-navigates to /start/search.
|
|
8546
|
-
7. Click "back" again
|
|
8547
|
-
What happens now, is that the browser "soft-navigates" (just changes the URL) to https://ehandel.spendrups.se/Product/1104201
|
|
8548
|
-
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.
|
|
8549
|
-
|
|
8550
|
-
|
|
8526
|
+
/*
|
|
8527
|
+
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).
|
|
8528
|
+
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.
|
|
8529
|
+
The reproduction is this:
|
|
8530
|
+
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.
|
|
8531
|
+
1. Go to a product page like https://ehandel.spendrups.se/Product/1104201
|
|
8532
|
+
2. Make a search
|
|
8533
|
+
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
|
|
8534
|
+
3. Try going back just for fun
|
|
8535
|
+
Everything works as expected
|
|
8536
|
+
4. Go forwards again (just for fun, skip this if you skipped 3)
|
|
8537
|
+
Now the trouble comes when we introduce "hard" navigation.
|
|
8538
|
+
5. Click on a search result. The browser will now "hard" navigate to a new page.
|
|
8539
|
+
6. Click "back"
|
|
8540
|
+
What happens now, is that the browser hard-navigates to /start/search.
|
|
8541
|
+
7. Click "back" again
|
|
8542
|
+
What happens now, is that the browser "soft-navigates" (just changes the URL) to https://ehandel.spendrups.se/Product/1104201
|
|
8543
|
+
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.
|
|
8544
|
+
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.
|
|
8545
|
+
*/ (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");
|
|
8551
8546
|
location.reload();
|
|
8552
8547
|
$0a6acf31d1eae57c$export$3ccaa27d81dd8556.#reverting_permitted = false; // Disallow any reverting since we can't - it would flash a white page until the reload has finished.
|
|
8553
8548
|
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.
|
|
@@ -8556,8 +8551,8 @@ class $0a6acf31d1eae57c$export$3ccaa27d81dd8556 extends EventTarget {
|
|
|
8556
8551
|
(0, $iBTHO$depictaiutilishared.instant_exec_on_suspect_history_change).add(on_maybe_popstate);
|
|
8557
8552
|
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
|
|
8558
8553
|
}
|
|
8559
|
-
/**
|
|
8560
|
-
* Stops listening to URL changes and closes the page (if it is currently open)
|
|
8554
|
+
/**
|
|
8555
|
+
* Stops listening to URL changes and closes the page (if it is currently open)
|
|
8561
8556
|
*/ destroy_() {
|
|
8562
8557
|
this.#unload();
|
|
8563
8558
|
this.#stop_listening?.();
|
|
@@ -8572,8 +8567,8 @@ class $0a6acf31d1eae57c$export$3ccaa27d81dd8556 extends EventTarget {
|
|
|
8572
8567
|
if (!is_spa_) (0, $08e7f10b1831645f$export$689e204eadb33baf)(this); // Make so that clicking on links to the previous page work instantly
|
|
8573
8568
|
}
|
|
8574
8569
|
}
|
|
8575
|
-
/**
|
|
8576
|
-
* Remove hash from URL
|
|
8570
|
+
/**
|
|
8571
|
+
* Remove hash from URL
|
|
8577
8572
|
*/ function $0a6acf31d1eae57c$var$clean_url(url) {
|
|
8578
8573
|
// Would want to have this a static private function on PageReplacer, but that's not supported in MobileSafari yet
|
|
8579
8574
|
// 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.17";
|
|
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];
|
|
@@ -960,22 +960,17 @@ function $29ec7cddbe1d3484$export$43f0fb951fcb0c54({ displays_by_key_: displays_
|
|
|
960
960
|
];
|
|
961
961
|
},
|
|
962
962
|
children: (product_id, index)=>{
|
|
963
|
-
// We're using `untrack` here since we don't want to react in here to displays_by_key changing
|
|
964
|
-
// As long as our key stays the same we assume that the display hasn't changed, so we don't want to rerender
|
|
965
|
-
// If the key gets removed, <For> will remove us
|
|
966
963
|
const owner = (0, $kyEB6$getOwner)();
|
|
967
964
|
const display_accessor = (0, $kyEB6$createMemo)(()=>displays_by_key_().get(product_id));
|
|
968
|
-
const [product_card_resource] = (0, $kyEB6$createResource)(
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
]), // re-render when merchant or market changes
|
|
972
|
-
([merchant, market])=>{
|
|
965
|
+
const [product_card_resource] = (0, $kyEB6$createResource)(display_accessor, // re-render when the reference to the display object changes
|
|
966
|
+
// this should only be the case when the merchant or market changes and the new request has completed
|
|
967
|
+
(display)=>{
|
|
973
968
|
// get display in the function that re-runs when merchant or market have changed, since the display may have changed but product_id not
|
|
974
|
-
const display = (0, $kyEB6$untrack)(display_accessor);
|
|
975
969
|
return product_card_template_(display, {
|
|
976
970
|
set_on_index_change: (fn)=>(0, $kyEB6$runWithOwner)(owner, ()=>(0, $kyEB6$createEffect)(()=>fn(index()))),
|
|
977
|
-
merchant:
|
|
978
|
-
market
|
|
971
|
+
merchant: (0, $kyEB6$untrack)(merchant_),
|
|
972
|
+
// this means that the merchant and market provided to the template is wrong while we do another fetch, but I don't see how anyone would need to know the correct market there
|
|
973
|
+
market: (0, $kyEB6$untrack)(market_)
|
|
979
974
|
});
|
|
980
975
|
});
|
|
981
976
|
const node_accessor = (0, $a52235d12ccf9c88$export$2f0cbfbb4354bb52)(product_card_resource);
|
|
@@ -1227,9 +1222,9 @@ function $2d25e42846eac370$export$3925f87b1545cfc6({ plp_results_: plp_results_
|
|
|
1227
1222
|
return _el$;
|
|
1228
1223
|
})();
|
|
1229
1224
|
}
|
|
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.
|
|
1225
|
+
/**
|
|
1226
|
+
* Sets styling to styling generated by "Layout" (n_col_styling_with_dist) depending on if filters are open or not
|
|
1227
|
+
* This function is special to the actual PLPResults.
|
|
1233
1228
|
*/ 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
1229
|
(0, $kyEB6$createRenderEffect)(()=>{
|
|
1235
1230
|
// Add grid styling that changes when filters get opened/closed
|
|
@@ -3919,9 +3914,9 @@ function $5efb5894079b220e$export$b288c38ae3fddb56({ available_filters_: availab
|
|
|
3919
3914
|
last_remote_state = available_filters_();
|
|
3920
3915
|
});
|
|
3921
3916
|
}
|
|
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)
|
|
3917
|
+
/**
|
|
3918
|
+
* 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.
|
|
3919
|
+
* This sets the counts to 0 (if applicable) and removes non-selected options (if applicable)
|
|
3925
3920
|
*/ function $5efb5894079b220e$var$modify_only_local_filter(local_filter_object, selected_filter) {
|
|
3926
3921
|
const old_meta = local_filter_object.meta;
|
|
3927
3922
|
const selected_filter_data = selected_filter.data;
|
|
@@ -4361,10 +4356,10 @@ const $4147651646da990a$var$range_delimiter = "-";
|
|
|
4361
4356
|
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
4357
|
const $4147651646da990a$var$array_item_delimiter = "‣"; // FIXME: decide on a character. Could theoretically be a double string delimiter.
|
|
4363
4358
|
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.
|
|
4359
|
+
/**
|
|
4360
|
+
* 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.
|
|
4361
|
+
* The requirements are either an array of strings, containing no reserved characters, or an array of arrays of strings, containing no reserved characters.
|
|
4362
|
+
* No deep or mixed nesting levels are supported.
|
|
4368
4363
|
*/ function $4147651646da990a$var$array_is_serializable(array, is_root = true) {
|
|
4369
4364
|
if (array.every((item)=>Array.isArray(item))) {
|
|
4370
4365
|
if (!is_root) // Deeply nested arrays are not supported, but also don't exist as filters (yet)
|
|
@@ -4376,10 +4371,10 @@ const $4147651646da990a$var$empty_item_replacement = "0️⃣";
|
|
|
4376
4371
|
// Encoding reserved characters is not supported
|
|
4377
4372
|
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
4373
|
}
|
|
4379
|
-
/**
|
|
4380
|
-
* Human readable string[] or string[][] serialization for URLs.
|
|
4381
|
-
* @param array
|
|
4382
|
-
* @returns
|
|
4374
|
+
/**
|
|
4375
|
+
* Human readable string[] or string[][] serialization for URLs.
|
|
4376
|
+
* @param array
|
|
4377
|
+
* @returns
|
|
4383
4378
|
*/ function $4147651646da990a$var$encode_array(array) {
|
|
4384
4379
|
const is_nested = array.every((item)=>Array.isArray(item));
|
|
4385
4380
|
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 +5469,8 @@ function $ccd5db07a3a069c5$export$477caf01aecaeb2a(options) {
|
|
|
5474
5469
|
}
|
|
5475
5470
|
};
|
|
5476
5471
|
}
|
|
5477
|
-
/**
|
|
5478
|
-
* Writes the sorting and filters to the URL query parameters when they change.
|
|
5472
|
+
/**
|
|
5473
|
+
* Writes the sorting and filters to the URL query parameters when they change.
|
|
5479
5474
|
*/ 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
5475
|
(0, $kyEB6$createEffect)((0, $kyEB6$on)([
|
|
5481
5476
|
get_sorting_,
|
|
@@ -5515,8 +5510,8 @@ function $ccd5db07a3a069c5$var$delete_sideways_param_flag(searchParams) {
|
|
|
5515
5510
|
|
|
5516
5511
|
|
|
5517
5512
|
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
|
|
5513
|
+
/**
|
|
5514
|
+
* 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
5515
|
*/ #throwing_on_navigation(...args) {
|
|
5521
5516
|
const { on_navigation_: on_navigation_ } = this;
|
|
5522
5517
|
if (typeof on_navigation_ !== "function") throw new Error("on_navigation_ is not a function");
|
|
@@ -5529,14 +5524,14 @@ class $4fd2ba03703a7d92$export$7e1297a3a19f10d8 {
|
|
|
5529
5524
|
});
|
|
5530
5525
|
}
|
|
5531
5526
|
}
|
|
5532
|
-
/**
|
|
5533
|
-
* Checks if this tab shouldn't navigate because user wants to open in new tab
|
|
5527
|
+
/**
|
|
5528
|
+
* Checks if this tab shouldn't navigate because user wants to open in new tab
|
|
5534
5529
|
*/ #dont_attempt_navigation(ev) {
|
|
5535
5530
|
return ev?.button || ev?.metaKey || ev?.ctrlKey;
|
|
5536
5531
|
}
|
|
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
|
|
5532
|
+
/**
|
|
5533
|
+
* Vue has async router that needs to be awaited (it navigates after a microtask)
|
|
5534
|
+
* This standardises waiting for all kinds of routers
|
|
5540
5535
|
*/ #get_navigation_happened_promise(is_replace) {
|
|
5541
5536
|
return new Promise((resolve)=>{
|
|
5542
5537
|
const handler = (what_happened)=>{
|
|
@@ -5549,19 +5544,19 @@ class $4fd2ba03703a7d92$export$7e1297a3a19f10d8 {
|
|
|
5549
5544
|
});
|
|
5550
5545
|
}
|
|
5551
5546
|
navigate_ = {
|
|
5552
|
-
/**
|
|
5553
|
-
* Call this if you *just* want to replace the state object in history.state
|
|
5547
|
+
/**
|
|
5548
|
+
* Call this if you *just* want to replace the state object in history.state
|
|
5554
5549
|
*/ replace_state_: (new_state)=>{
|
|
5555
5550
|
// 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
5551
|
history.replaceState(new_state, "");
|
|
5557
5552
|
},
|
|
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
|
|
5553
|
+
/**
|
|
5554
|
+
* Call this to change the URL
|
|
5555
|
+
* @param new_url_ new URL to go to
|
|
5556
|
+
* @param event_ event if you have this in a click handler, will not do anything on cmd/ctrl or non-left click then
|
|
5557
|
+
* @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
|
|
5558
|
+
* @param is_replace_ if you want to replace the current URL in history instead of pushing a new one
|
|
5559
|
+
* @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
5560
|
*/ 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
5561
|
const new_url_ = raw_new_url instanceof URL ? raw_new_url : new URL(raw_new_url, location.origin);
|
|
5567
5562
|
const wants_hard_navigation = this.on_navigation_ === "hard_navigation";
|
|
@@ -6369,8 +6364,8 @@ async function $bfd908d13d90934c$export$e16630ecb9644a1c({ on_submit_with_unchan
|
|
|
6369
6364
|
|
|
6370
6365
|
|
|
6371
6366
|
|
|
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.
|
|
6367
|
+
/**
|
|
6368
|
+
* 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
6369
|
*/ const $c97b1f0e44afb9d2$export$27b710c08412a7ad = (obj)=>{
|
|
6375
6370
|
return Object.fromEntries(Object.keys(obj).map((key)=>[
|
|
6376
6371
|
key,
|
|
@@ -7912,8 +7907,8 @@ function $4ca91518c9a35379$export$828dcdd425fd3231(aligner) {
|
|
|
7912
7907
|
|
|
7913
7908
|
|
|
7914
7909
|
const $806c97b931758897$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$kyEB6$template)(`<div class="depict plp search"></div>`, 2);
|
|
7915
|
-
/**
|
|
7916
|
-
* 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.
|
|
7910
|
+
/**
|
|
7911
|
+
* 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.
|
|
7917
7912
|
*/ const $806c97b931758897$var$privately_shared_properties = /*@__PURE__*/ new WeakMap();
|
|
7918
7913
|
const $806c97b931758897$var$min_products_to_fetch_ = 20;
|
|
7919
7914
|
const $806c97b931758897$export$bde3eb976dfded9 = (depict_search)=>$806c97b931758897$var$privately_shared_properties.get(depict_search)?.search_query_updating_blocked_;
|
|
@@ -8310,8 +8305,8 @@ const $6891c018a834cfdd$export$d86a33413558014e = (openModalParams)=>{
|
|
|
8310
8305
|
}
|
|
8311
8306
|
const { cleanup: cleanup } = (0, $4ca91518c9a35379$export$828dcdd425fd3231)(openModalParams.element);
|
|
8312
8307
|
let dispose_aligner;
|
|
8313
|
-
/**
|
|
8314
|
-
* Setting position to fixed is important to make the modal work with align_field.
|
|
8308
|
+
/**
|
|
8309
|
+
* Setting position to fixed is important to make the modal work with align_field.
|
|
8315
8310
|
*/ const style_props_ = (0, $kyEB6$createSignal)({
|
|
8316
8311
|
position: "fixed"
|
|
8317
8312
|
});
|
|
@@ -8407,8 +8402,8 @@ class $753e9b2889a47c89$export$3ccaa27d81dd8556 extends EventTarget {
|
|
|
8407
8402
|
})();
|
|
8408
8403
|
return new Set();
|
|
8409
8404
|
})();
|
|
8410
|
-
/**
|
|
8411
|
-
* Returns if the "replacement page" is currently open
|
|
8405
|
+
/**
|
|
8406
|
+
* Returns if the "replacement page" is currently open
|
|
8412
8407
|
*/ get open_() {
|
|
8413
8408
|
// make this "readonly" from the outside, the only way to open is by making the url change so that is_page_ returns true
|
|
8414
8409
|
return this.#is_open;
|
|
@@ -8493,26 +8488,26 @@ class $753e9b2889a47c89$export$3ccaa27d81dd8556 extends EventTarget {
|
|
|
8493
8488
|
if (what_happened !== "popstate") return;
|
|
8494
8489
|
const cleaned_current_url = $753e9b2889a47c89$var$clean_url(location.href);
|
|
8495
8490
|
if (!$753e9b2889a47c89$export$3ccaa27d81dd8556.#visited_urls.has(cleaned_current_url)) {
|
|
8496
|
-
/*
|
|
8497
|
-
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).
|
|
8498
|
-
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.
|
|
8499
|
-
The reproduction is this:
|
|
8500
|
-
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.
|
|
8501
|
-
1. Go to a product page like https://ehandel.spendrups.se/Product/1104201
|
|
8502
|
-
2. Make a search
|
|
8503
|
-
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
|
|
8504
|
-
3. Try going back just for fun
|
|
8505
|
-
Everything works as expected
|
|
8506
|
-
4. Go forwards again (just for fun, skip this if you skipped 3)
|
|
8507
|
-
Now the trouble comes when we introduce "hard" navigation.
|
|
8508
|
-
5. Click on a search result. The browser will now "hard" navigate to a new page.
|
|
8509
|
-
6. Click "back"
|
|
8510
|
-
What happens now, is that the browser hard-navigates to /start/search.
|
|
8511
|
-
7. Click "back" again
|
|
8512
|
-
What happens now, is that the browser "soft-navigates" (just changes the URL) to https://ehandel.spendrups.se/Product/1104201
|
|
8513
|
-
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.
|
|
8514
|
-
|
|
8515
|
-
|
|
8491
|
+
/*
|
|
8492
|
+
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).
|
|
8493
|
+
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.
|
|
8494
|
+
The reproduction is this:
|
|
8495
|
+
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.
|
|
8496
|
+
1. Go to a product page like https://ehandel.spendrups.se/Product/1104201
|
|
8497
|
+
2. Make a search
|
|
8498
|
+
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
|
|
8499
|
+
3. Try going back just for fun
|
|
8500
|
+
Everything works as expected
|
|
8501
|
+
4. Go forwards again (just for fun, skip this if you skipped 3)
|
|
8502
|
+
Now the trouble comes when we introduce "hard" navigation.
|
|
8503
|
+
5. Click on a search result. The browser will now "hard" navigate to a new page.
|
|
8504
|
+
6. Click "back"
|
|
8505
|
+
What happens now, is that the browser hard-navigates to /start/search.
|
|
8506
|
+
7. Click "back" again
|
|
8507
|
+
What happens now, is that the browser "soft-navigates" (just changes the URL) to https://ehandel.spendrups.se/Product/1104201
|
|
8508
|
+
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.
|
|
8509
|
+
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.
|
|
8510
|
+
*/ (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");
|
|
8516
8511
|
location.reload();
|
|
8517
8512
|
$753e9b2889a47c89$export$3ccaa27d81dd8556.#reverting_permitted = false; // Disallow any reverting since we can't - it would flash a white page until the reload has finished.
|
|
8518
8513
|
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.
|
|
@@ -8521,8 +8516,8 @@ class $753e9b2889a47c89$export$3ccaa27d81dd8556 extends EventTarget {
|
|
|
8521
8516
|
(0, $kyEB6$instant_exec_on_suspect_history_change).add(on_maybe_popstate);
|
|
8522
8517
|
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
|
|
8523
8518
|
}
|
|
8524
|
-
/**
|
|
8525
|
-
* Stops listening to URL changes and closes the page (if it is currently open)
|
|
8519
|
+
/**
|
|
8520
|
+
* Stops listening to URL changes and closes the page (if it is currently open)
|
|
8526
8521
|
*/ destroy_() {
|
|
8527
8522
|
this.#unload();
|
|
8528
8523
|
this.#stop_listening?.();
|
|
@@ -8537,8 +8532,8 @@ class $753e9b2889a47c89$export$3ccaa27d81dd8556 extends EventTarget {
|
|
|
8537
8532
|
if (!is_spa_) (0, $6936724b9e0b98d5$export$689e204eadb33baf)(this); // Make so that clicking on links to the previous page work instantly
|
|
8538
8533
|
}
|
|
8539
8534
|
}
|
|
8540
|
-
/**
|
|
8541
|
-
* Remove hash from URL
|
|
8535
|
+
/**
|
|
8536
|
+
* Remove hash from URL
|
|
8542
8537
|
*/ function $753e9b2889a47c89$var$clean_url(url) {
|
|
8543
8538
|
// Would want to have this a static private function on PageReplacer, but that's not supported in MobileSafari yet
|
|
8544
8539
|
// remove hash, all other params *could* trigger a re-request
|