@iyulab/router 0.11.2 → 0.11.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/CHANGELOG.md +27 -0
- package/dist/index.js +10 -6
- package/dist/react.js +1 -1
- package/dist/{share-Ds0NYHr-.js → share-BOhUKwJL.js} +6 -3
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.11.4] - 2026-09-01
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **Three error messages gave no way to act on the failure.** `UOutlet.render()`
|
|
8
|
+
threw a generic "not supported content type" without saying what type it
|
|
9
|
+
actually received or what's supported; `getRoutes()` threw a garbled,
|
|
10
|
+
comma-spliced message that leaked an internal function name
|
|
11
|
+
(`setRoutes`) instead of the actual `path` value; and a route whose
|
|
12
|
+
`render()` returned a non-renderable value threw "Failed to load content
|
|
13
|
+
for the route." with no route path or id to identify which route failed.
|
|
14
|
+
All three now interpolate the actual value/route and name the expected
|
|
15
|
+
shape.
|
|
16
|
+
|
|
17
|
+
## [0.11.3] - 2026-08-31
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
|
|
21
|
+
- **`waitOutlet()` could hang forever in a backgrounded tab.** The wait loop
|
|
22
|
+
only re-checked for the outlet after each `requestAnimationFrame`
|
|
23
|
+
resolved, and a fully suspended tab can stop firing `rAF` entirely (not
|
|
24
|
+
just throttle it), so the loop never exited. It now races each `rAF`
|
|
25
|
+
wait against a `setTimeout` for the remaining budget, and does one more
|
|
26
|
+
outlet check immediately before throwing — the deadline can pass in the
|
|
27
|
+
exact frame the outlet became ready, and without that final check that
|
|
28
|
+
read as a false timeout.
|
|
29
|
+
|
|
3
30
|
## [0.11.2] - 2026-08-25
|
|
4
31
|
|
|
5
32
|
### Fixed
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as isExternalUrl, i as absolutePath, n as __decorate, o as parseUrl, r as __decorateMetadata, s as UOutlet, t as ULink } from "./share-
|
|
1
|
+
import { a as isExternalUrl, i as absolutePath, n as __decorate, o as parseUrl, r as __decorateMetadata, s as UOutlet, t as ULink } from "./share-BOhUKwJL.js";
|
|
2
2
|
import { LitElement, css, html } from "lit";
|
|
3
3
|
import { customElement, property } from "lit/decorators.js";
|
|
4
4
|
//#region src/types/RouteError.ts
|
|
@@ -260,14 +260,18 @@ function findOutletOrThrow(element, skip = false) {
|
|
|
260
260
|
* @returns 준비된 `u-outlet` 엘리먼트
|
|
261
261
|
*/
|
|
262
262
|
async function waitOutlet(element, timeout = 1e4, skip = false) {
|
|
263
|
-
const
|
|
264
|
-
while (performance.now()
|
|
263
|
+
const deadline = performance.now() + timeout;
|
|
264
|
+
while (performance.now() < deadline) {
|
|
265
265
|
const outlet = findOutlet(element, skip);
|
|
266
266
|
if (outlet) return outlet;
|
|
267
267
|
if (element.localName.includes("-")) await customElements.whenDefined(element.localName);
|
|
268
268
|
if ("updateComplete" in element) await element.updateComplete;
|
|
269
|
-
|
|
269
|
+
const remaining = deadline - performance.now();
|
|
270
|
+
if (remaining <= 0) break;
|
|
271
|
+
await Promise.race([new Promise((resolve) => requestAnimationFrame(() => resolve())), new Promise((resolve) => setTimeout(resolve, remaining))]);
|
|
270
272
|
}
|
|
273
|
+
const outlet = findOutlet(element, skip);
|
|
274
|
+
if (outlet) return outlet;
|
|
271
275
|
throw new Error(`Timed out waiting for <u-outlet> inside <${element.tagName.toLowerCase()}>. Ensure that the router root element contains a <u-outlet> child.`);
|
|
272
276
|
}
|
|
273
277
|
/**
|
|
@@ -339,7 +343,7 @@ function getRoutes(routes, pathname) {
|
|
|
339
343
|
}
|
|
340
344
|
if (route.path instanceof URLPattern) {
|
|
341
345
|
if (route.path.test({ pathname })) return [route];
|
|
342
|
-
} else throw new Error(
|
|
346
|
+
} else throw new Error(`Route "path" must be a URLPattern, but got ${JSON.stringify(route.path)}. Routes passed to the Router must go through its normal config flow (new Router({ routes: [...] })), which normalizes string paths into URLPattern before matching — a route object was matched before that step ran.`);
|
|
343
347
|
}
|
|
344
348
|
return [];
|
|
345
349
|
}
|
|
@@ -506,7 +510,7 @@ var Router = class {
|
|
|
506
510
|
let content;
|
|
507
511
|
try {
|
|
508
512
|
content = await route.render(context);
|
|
509
|
-
if (content === false || content === void 0 || content === null) throw new Error(
|
|
513
|
+
if (content === false || content === void 0 || content === null) throw new Error(`Route render() returned ${content === false ? "false" : String(content)} for "${context.pathname}"${route.id ? ` (route id: "${route.id}")` : ""} — a route's render() must return an HTMLElement, a Lit TemplateResult, or a React element.`);
|
|
510
514
|
} catch (e) {
|
|
511
515
|
throw new ContentLoadError(e);
|
|
512
516
|
}
|
package/dist/react.js
CHANGED
|
@@ -23,7 +23,10 @@ var UOutlet = class extends HTMLElement {
|
|
|
23
23
|
const { createRoot } = await import("react-dom/client");
|
|
24
24
|
this.root = createRoot(this);
|
|
25
25
|
this.root.render(value);
|
|
26
|
-
} else
|
|
26
|
+
} else {
|
|
27
|
+
const receivedType = value?.constructor?.name ?? typeof value;
|
|
28
|
+
throw new Error(`Unsupported content type for Outlet rendering: received ${receivedType}. Expected an HTMLElement, a Lit TemplateResult, or a React element.`);
|
|
29
|
+
}
|
|
27
30
|
}
|
|
28
31
|
/**
|
|
29
32
|
* 기존 DOM을 삭제하여, 초기 상태로 되돌립니다.
|
|
@@ -1023,12 +1026,12 @@ function catchBasepath(basepath) {
|
|
|
1023
1026
|
return basepath;
|
|
1024
1027
|
}
|
|
1025
1028
|
//#endregion
|
|
1026
|
-
//#region \0@oxc-project+runtime@0.
|
|
1029
|
+
//#region \0@oxc-project+runtime@0.148.0/helpers/esm/decorateMetadata.js
|
|
1027
1030
|
function __decorateMetadata(k, v) {
|
|
1028
1031
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1029
1032
|
}
|
|
1030
1033
|
//#endregion
|
|
1031
|
-
//#region \0@oxc-project+runtime@0.
|
|
1034
|
+
//#region \0@oxc-project+runtime@0.148.0/helpers/esm/decorate.js
|
|
1032
1035
|
function __decorate(decorators, target, key, desc) {
|
|
1033
1036
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1034
1037
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iyulab/router",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.4",
|
|
4
4
|
"description": "A modern client-side router for web applications with support for Lit and React components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lit",
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
|
+
"preversion": "node -e \"if(require('fs').existsSync('../../scripts/preversion-check.mjs'))require('child_process').execFileSync('node',['../../scripts/preversion-check.mjs'],{stdio:'inherit'})\"",
|
|
50
51
|
"test": "vitest run",
|
|
51
52
|
"build": "npm run typecheck && vite build",
|
|
52
53
|
"test:watch": "vitest",
|