navgo 4.0.2 → 5.0.0
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/index.js +5 -5
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -254,8 +254,8 @@ export default class Navgo {
|
|
|
254
254
|
return true
|
|
255
255
|
}
|
|
256
256
|
|
|
257
|
-
async #run_loader(route, params) {
|
|
258
|
-
const ret_val = route[1].loader?.(params)
|
|
257
|
+
async #run_loader(route, url, params) {
|
|
258
|
+
const ret_val = route[1].loader?.({ route_entry: route, url, params })
|
|
259
259
|
return Array.isArray(ret_val) ? Promise.all(ret_val) : ret_val
|
|
260
260
|
}
|
|
261
261
|
|
|
@@ -355,7 +355,7 @@ export default class Navgo {
|
|
|
355
355
|
const pre = this.#preloads.get(path)
|
|
356
356
|
data =
|
|
357
357
|
pre?.data ??
|
|
358
|
-
(await (pre?.promise || this.#run_loader(hit.route, hit.params)).catch(e => ({
|
|
358
|
+
(await (pre?.promise || this.#run_loader(hit.route, url, hit.params)).catch(e => ({
|
|
359
359
|
__error: e,
|
|
360
360
|
})))
|
|
361
361
|
this.#preloads.delete(path)
|
|
@@ -482,7 +482,7 @@ export default class Navgo {
|
|
|
482
482
|
*/
|
|
483
483
|
/** @param {string} url_raw @returns {Promise<unknown|void>} */
|
|
484
484
|
async preload(url_raw) {
|
|
485
|
-
const { path } = this.#resolve_url_and_path(url_raw) || {}
|
|
485
|
+
const { path, url } = this.#resolve_url_and_path(url_raw) || {}
|
|
486
486
|
if (!path) {
|
|
487
487
|
ℹ('[🧭 preload]', 'invalid url', { url: url_raw })
|
|
488
488
|
return Promise.resolve()
|
|
@@ -505,7 +505,7 @@ export default class Navgo {
|
|
|
505
505
|
}
|
|
506
506
|
|
|
507
507
|
const entry = {}
|
|
508
|
-
entry.promise = this.#run_loader(hit.route, hit.params).then(data => {
|
|
508
|
+
entry.promise = this.#run_loader(hit.route, url, hit.params).then(data => {
|
|
509
509
|
entry.data = data
|
|
510
510
|
delete entry.promise
|
|
511
511
|
ℹ('[🧭 preload]', 'done', { path })
|