@ilha/router 0.10.3 → 0.10.4
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/index.js +1 -1
- package/dist/{plugin-DBbbaeFm.js → plugin-BQil-7B_.js} +1 -1
- package/dist/rsbuild.js +1 -1
- package/dist/server-island.js +40 -2
- package/dist/{src-B5dHU24f.js → src-PCXNZfql.js} +8 -8
- package/dist/{ssr-CTd2quoA.js → ssr-BTmqfAp9.js} +1 -1
- package/dist/ssr.js +1 -1
- package/dist/vite.js +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as wrapLayout, C as routePath, D as useContext, E as src_default, F as getHistoryMode, I as setHistoryMode, O as useRoute, P as httpResponse, S as routeParams, T as router, _ as prefetch, a as RouterView, b as resolveRedirectTarget, c as composeLoaders, d as error, f as invalidate, g as navigating, h as navigate, i as RouterLink, k as wrapError, l as defineLayout, m as loader, n as LoaderError, o as afterNavigate, p as isActive, r as Redirect, s as beforeNavigate, t as LOADER_ENDPOINT, u as enableLinkInterception, v as prime, w as routeSearch, x as routeHash, y as redirect } from "./src-
|
|
1
|
+
import { A as wrapLayout, C as routePath, D as useContext, E as src_default, F as getHistoryMode, I as setHistoryMode, O as useRoute, P as httpResponse, S as routeParams, T as router, _ as prefetch, a as RouterView, b as resolveRedirectTarget, c as composeLoaders, d as error, f as invalidate, g as navigating, h as navigate, i as RouterLink, k as wrapError, l as defineLayout, m as loader, n as LoaderError, o as afterNavigate, p as isActive, r as Redirect, s as beforeNavigate, t as LOADER_ENDPOINT, u as enableLinkInterception, v as prime, w as routeSearch, x as routeHash, y as redirect } from "./src-PCXNZfql.js";
|
|
2
2
|
import { o as head, s as serializeHead } from "./snapshot-CsEaY6h_.js";
|
|
3
3
|
|
|
4
4
|
export { LOADER_ENDPOINT, LoaderError, Redirect, RouterLink, RouterView, afterNavigate, beforeNavigate, composeLoaders, src_default as default, defineLayout, enableLinkInterception, error, getHistoryMode, head, httpResponse, invalidate, isActive, loader, navigate, navigating, prefetch, prime, redirect, resolveRedirectTarget, routeHash, routeParams, routePath, routeSearch, router, serializeHead, setHistoryMode, useContext, useRoute, wrapError, wrapLayout };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as runWithIslandRequest, S as setFrameGuard, _ as parseFrameProps, b as renderServerIsland, c as frameEnvelope, m as isSafeFramePath, n as FrameError, o as authorizeFrameRequest, u as getFrameGuard, w as setLoaderGuard, x as setFrameAuth } from "./ssr-
|
|
1
|
+
import { E as runWithIslandRequest, S as setFrameGuard, _ as parseFrameProps, b as renderServerIsland, c as frameEnvelope, m as isSafeFramePath, n as FrameError, o as authorizeFrameRequest, u as getFrameGuard, w as setLoaderGuard, x as setFrameAuth } from "./ssr-BTmqfAp9.js";
|
|
2
2
|
import { existsSync, readFileSync, statSync, watch } from "node:fs";
|
|
3
3
|
import { basename, dirname, extname, join, relative, resolve, sep } from "node:path";
|
|
4
4
|
import { createUnplugin } from "unplugin";
|
package/dist/rsbuild.js
CHANGED
package/dist/server-island.js
CHANGED
|
@@ -48,6 +48,42 @@ function belongsToHost(host, candidate) {
|
|
|
48
48
|
}
|
|
49
49
|
return el === host;
|
|
50
50
|
}
|
|
51
|
+
/** Dev cold-start can race a warming `virtual:oxide/actions` graph — retry briefly. */
|
|
52
|
+
async function startServerStream(fn, signal) {
|
|
53
|
+
let last;
|
|
54
|
+
for (let attempt = 0; attempt < 4; attempt++) {
|
|
55
|
+
if (signal.aborted) throw last ?? new DOMException("The operation was aborted.", "AbortError");
|
|
56
|
+
let gen;
|
|
57
|
+
try {
|
|
58
|
+
gen = await fn(signal);
|
|
59
|
+
const first = await gen.next();
|
|
60
|
+
return {
|
|
61
|
+
gen,
|
|
62
|
+
first
|
|
63
|
+
};
|
|
64
|
+
} catch (err) {
|
|
65
|
+
last = err;
|
|
66
|
+
if (gen) Promise.resolve(gen.return?.(void 0)).catch(() => {});
|
|
67
|
+
if (signal.aborted) throw err;
|
|
68
|
+
const msg = String(err);
|
|
69
|
+
if (!msg.includes("404") && !msg.includes("503")) throw err;
|
|
70
|
+
if (attempt === 3) throw err;
|
|
71
|
+
await new Promise((resolve, reject) => {
|
|
72
|
+
const timer = setTimeout(() => {
|
|
73
|
+
signal.removeEventListener("abort", onAbort);
|
|
74
|
+
resolve();
|
|
75
|
+
}, 50 * (attempt + 1));
|
|
76
|
+
const onAbort = () => {
|
|
77
|
+
clearTimeout(timer);
|
|
78
|
+
reject(err);
|
|
79
|
+
};
|
|
80
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
81
|
+
if (signal.aborted) onAbort();
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
throw last;
|
|
86
|
+
}
|
|
51
87
|
function hydrateServerIsland(host, id, wiring, props) {
|
|
52
88
|
const controller = new AbortController();
|
|
53
89
|
const cleanups = [];
|
|
@@ -159,13 +195,15 @@ function hydrateServerIsland(host, id, wiring, props) {
|
|
|
159
195
|
syncChildren();
|
|
160
196
|
for (const [key, fn] of Object.entries(wiring.streams ?? {})) (async () => {
|
|
161
197
|
try {
|
|
162
|
-
const gen = await fn
|
|
198
|
+
const { gen, first } = await startServerStream(fn, controller.signal);
|
|
163
199
|
try {
|
|
200
|
+
let step = first;
|
|
164
201
|
for (;;) {
|
|
165
|
-
const { done, value } =
|
|
202
|
+
const { done, value } = step;
|
|
166
203
|
if (controller.signal.aborted || done) break;
|
|
167
204
|
state[key] = value;
|
|
168
205
|
scheduleRepaint();
|
|
206
|
+
step = await gen.next();
|
|
169
207
|
}
|
|
170
208
|
} catch (err) {
|
|
171
209
|
if (!controller.signal.aborted && err?.name !== "AbortError") console.error(`[ilha-router] stream "${key}" failed:`, err);
|
|
@@ -1017,7 +1017,7 @@ function routePath(value) {
|
|
|
1017
1017
|
const store = activeRouteStore();
|
|
1018
1018
|
if (arguments.length > 0) {
|
|
1019
1019
|
if (store) return store.path = value;
|
|
1020
|
-
return _routePathSig(value), value;
|
|
1020
|
+
return _routePathSig.set(value), value;
|
|
1021
1021
|
}
|
|
1022
1022
|
return store ? store.path : _routePathSig();
|
|
1023
1023
|
}
|
|
@@ -1026,7 +1026,7 @@ function routeParams(value) {
|
|
|
1026
1026
|
const store = activeRouteStore();
|
|
1027
1027
|
if (arguments.length > 0) {
|
|
1028
1028
|
if (store) return store.params = value;
|
|
1029
|
-
return _routeParamsSig(value), value;
|
|
1029
|
+
return _routeParamsSig.set(value), value;
|
|
1030
1030
|
}
|
|
1031
1031
|
return store ? store.params : _routeParamsSig();
|
|
1032
1032
|
}
|
|
@@ -1035,7 +1035,7 @@ function routeSearch(value) {
|
|
|
1035
1035
|
const store = activeRouteStore();
|
|
1036
1036
|
if (arguments.length > 0) {
|
|
1037
1037
|
if (store) return store.search = value;
|
|
1038
|
-
return _routeSearchSig(value), value;
|
|
1038
|
+
return _routeSearchSig.set(value), value;
|
|
1039
1039
|
}
|
|
1040
1040
|
return store ? store.search : _routeSearchSig();
|
|
1041
1041
|
}
|
|
@@ -1044,7 +1044,7 @@ function routeHash(value) {
|
|
|
1044
1044
|
const store = activeRouteStore();
|
|
1045
1045
|
if (arguments.length > 0) {
|
|
1046
1046
|
if (store) return store.hash = value;
|
|
1047
|
-
return _routeHashSig(value), value;
|
|
1047
|
+
return _routeHashSig.set(value), value;
|
|
1048
1048
|
}
|
|
1049
1049
|
return store ? store.hash : _routeHashSig();
|
|
1050
1050
|
}
|
|
@@ -1066,13 +1066,13 @@ function invalidate() {
|
|
|
1066
1066
|
/** Mark a navigation as started; returns an idempotent settle callback. */
|
|
1067
1067
|
function beginNavigation() {
|
|
1068
1068
|
if (!isBrowser) return () => {};
|
|
1069
|
-
_navigatingSig(_navigatingSig() + 1);
|
|
1069
|
+
_navigatingSig.set(_navigatingSig() + 1);
|
|
1070
1070
|
document.documentElement.setAttribute("data-router-pending", "");
|
|
1071
1071
|
let done = false;
|
|
1072
1072
|
return () => {
|
|
1073
1073
|
if (done) return;
|
|
1074
1074
|
done = true;
|
|
1075
|
-
_navigatingSig(Math.max(0, _navigatingSig() - 1));
|
|
1075
|
+
_navigatingSig.set(Math.max(0, _navigatingSig() - 1));
|
|
1076
1076
|
if (_navigatingSig() === 0) document.documentElement.removeAttribute("data-router-pending");
|
|
1077
1077
|
};
|
|
1078
1078
|
}
|
|
@@ -1103,8 +1103,8 @@ function activeIsland(value) {
|
|
|
1103
1103
|
if (arguments.length > 0) {
|
|
1104
1104
|
const next = value ?? null;
|
|
1105
1105
|
if (store) return store.island = next;
|
|
1106
|
-
if (next === null) _activeIslandSig(null);
|
|
1107
|
-
else _activeIslandSig(
|
|
1106
|
+
if (next === null) _activeIslandSig.set(null);
|
|
1107
|
+
else _activeIslandSig.set(next);
|
|
1108
1108
|
return next;
|
|
1109
1109
|
}
|
|
1110
1110
|
return store ? store.island : _activeIslandSig();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as parsePattern, N as safeDecode, b as resolveRedirectTarget, j as matchSegments } from "./src-
|
|
1
|
+
import { M as parsePattern, N as safeDecode, b as resolveRedirectTarget, j as matchSegments } from "./src-PCXNZfql.js";
|
|
2
2
|
import "ilha";
|
|
3
3
|
import { bindServerAction, setServerManifestSerializer } from "ilha/internal";
|
|
4
4
|
import { AsyncLocalStorage } from "node:async_hooks";
|
package/dist/ssr.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { C as setFrameLoaderRunner, S as setFrameGuard, T as ssr, _ as parseFrameProps, a as __ilhaServerAction, b as renderServerIsland, c as frameEnvelope, d as getFrameLoaderRunner, f as getLoaderGuard, g as json, h as isTrustedOrigin, i as MAX_BODY, l as getFrameAuth, m as isSafeFramePath, n as FrameError, o as authorizeFrameRequest, p as getServerIslandEntry, r as LOADER_ENDPOINT, s as forwardIdentityHeaders, t as FRAME_ENDPOINT, u as getFrameGuard, v as readBodyBounded, w as setLoaderGuard, x as setFrameAuth, y as registerServerIsland } from "./ssr-
|
|
1
|
+
import { C as setFrameLoaderRunner, S as setFrameGuard, T as ssr, _ as parseFrameProps, a as __ilhaServerAction, b as renderServerIsland, c as frameEnvelope, d as getFrameLoaderRunner, f as getLoaderGuard, g as json, h as isTrustedOrigin, i as MAX_BODY, l as getFrameAuth, m as isSafeFramePath, n as FrameError, o as authorizeFrameRequest, p as getServerIslandEntry, r as LOADER_ENDPOINT, s as forwardIdentityHeaders, t as FRAME_ENDPOINT, u as getFrameGuard, v as readBodyBounded, w as setLoaderGuard, x as setFrameAuth, y as registerServerIsland } from "./ssr-BTmqfAp9.js";
|
|
2
2
|
|
|
3
3
|
export { FRAME_ENDPOINT, FrameError, LOADER_ENDPOINT, MAX_BODY, __ilhaServerAction, authorizeFrameRequest, ssr as default, forwardIdentityHeaders, frameEnvelope, getFrameAuth, getFrameGuard, getFrameLoaderRunner, getLoaderGuard, getServerIslandEntry, isSafeFramePath, isTrustedOrigin, json, parseFrameProps, readBodyBounded, registerServerIsland, renderServerIsland, setFrameAuth, setFrameGuard, setFrameLoaderRunner, setLoaderGuard };
|
package/dist/vite.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ilha/router",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.4",
|
|
4
4
|
"description": "A tiny SPA router for Ilha",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"frontend",
|
|
@@ -75,10 +75,10 @@
|
|
|
75
75
|
"unplugin": "3.3.0"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
|
-
"ilha": "0.
|
|
78
|
+
"ilha": "0.13.0",
|
|
79
79
|
"vite": "^8.2.2"
|
|
80
80
|
},
|
|
81
81
|
"peerDependencies": {
|
|
82
|
-
"ilha": ">=0.
|
|
82
|
+
"ilha": ">=0.13.0"
|
|
83
83
|
}
|
|
84
84
|
}
|