@kodaris/krubble-app-components 1.0.153 → 1.0.155
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/dist/krubble-app.bundled.js +40 -0
- package/dist/krubble-app.bundled.js.map +1 -1
- package/dist/krubble-app.bundled.min.js +1 -1
- package/dist/krubble-app.bundled.min.js.map +1 -1
- package/dist/krubble-app.umd.js +40 -0
- package/dist/krubble-app.umd.js.map +1 -1
- package/dist/krubble-app.umd.min.js +1 -1
- package/dist/krubble-app.umd.min.js.map +1 -1
- package/dist/router.d.ts +13 -0
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +40 -0
- package/dist/router.js.map +1 -1
- package/package.json +1 -1
|
@@ -12541,6 +12541,46 @@ class KRRouter {
|
|
|
12541
12541
|
window.history.pushState({}, '', fullPath);
|
|
12542
12542
|
window.dispatchEvent(new PopStateEvent('popstate'));
|
|
12543
12543
|
}
|
|
12544
|
+
/**
|
|
12545
|
+
* Rewrite the current url in place, keeping the mounted screen as it is — no popstate is dispatched,
|
|
12546
|
+
* so nothing in flight (a streaming response, an open editor) is torn down. For when a screen's url
|
|
12547
|
+
* becomes more specific after a server round-trip: a new chat's first message resolves a conversation
|
|
12548
|
+
* id, a new record's save yields its key.
|
|
12549
|
+
*
|
|
12550
|
+
* Use this instead of a bare history.replaceState. The cache files each screen under its url, so a raw
|
|
12551
|
+
* rewrite would leave the screen keyed by the OLD url: navigating back to that url would be a cache hit
|
|
12552
|
+
* handing back this same screen with all its state — a chat rewritten from `new` to `all/123` would
|
|
12553
|
+
* reopen conversation 123 on the next New Chat click instead of starting fresh. So the deepest level's
|
|
12554
|
+
* cache entry is re-filed under the new url, and its outlet context follows.
|
|
12555
|
+
*/
|
|
12556
|
+
static replace(path) {
|
|
12557
|
+
const before = KRRouter.matchRoutes();
|
|
12558
|
+
let fullPath = path;
|
|
12559
|
+
if (!path.startsWith('/')) {
|
|
12560
|
+
fullPath = KRRouter.base + '/' + path;
|
|
12561
|
+
}
|
|
12562
|
+
window.history.replaceState({}, '', fullPath);
|
|
12563
|
+
const after = KRRouter.matchRoutes();
|
|
12564
|
+
if (!before.routes.length || !after.routes.length) {
|
|
12565
|
+
return;
|
|
12566
|
+
}
|
|
12567
|
+
// The caller is the deepest matched screen rewriting its own url; shallower levels keep theirs.
|
|
12568
|
+
const level = before.routes.length - 1;
|
|
12569
|
+
const oldUrl = before.routes[level].url;
|
|
12570
|
+
const newUrl = after.routes[after.routes.length - 1].url;
|
|
12571
|
+
if (oldUrl === newUrl) {
|
|
12572
|
+
return;
|
|
12573
|
+
}
|
|
12574
|
+
const entry = KRRouter.routeCache.get(oldUrl);
|
|
12575
|
+
if (entry) {
|
|
12576
|
+
KRRouter.routeCache.delete(oldUrl);
|
|
12577
|
+
KRRouter.routeCache.set(newUrl, entry);
|
|
12578
|
+
}
|
|
12579
|
+
const context = KRRouter.outletContexts.get(level);
|
|
12580
|
+
if (context && context.url === oldUrl) {
|
|
12581
|
+
context.url = newUrl;
|
|
12582
|
+
}
|
|
12583
|
+
}
|
|
12544
12584
|
static getParams() {
|
|
12545
12585
|
const matched = KRRouter.matchRoutes();
|
|
12546
12586
|
const params = {};
|