@iyulab/router 0.9.0 → 0.9.2

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.9.2] - 2026-04-13
4
+
5
+ ### Fixed
6
+ - Nested route rendering now waits for child outlet readiness after parent render, preventing children from being rendered into the previous outlet when the next `<u-outlet>` is created inside a component shadow root
7
+ - `Router.go()` now awaits `UOutlet.render()` before resolving the next outlet in the matched route chain
8
+ - `waitOutlet()` now prefers component lifecycle-aware readiness checks (`customElements.whenDefined`, `updateComplete`, next animation frame) during outlet discovery
9
+
10
+ ## [0.9.1] - 2026-04-08
11
+
12
+ ### Fixed
13
+ - Redirect cycle detection no longer triggers false positives on initial navigation — `visit()` check is now skipped for the first `go()` call and only applied within redirect chains (`isRedirect: true`)
14
+
3
15
  ## [0.9.0] - 2026-04-08
4
16
 
5
17
  ### Added
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-CUGwxZKa.js";
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-CEEpCf48.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
@@ -240,11 +240,13 @@ function findOutlet(element, skip = false) {
240
240
  * `u-outlet` 엘리먼트를 찾아 반환합니다. 없으면 에러를 던집니다.
241
241
  *
242
242
  * @param element 검색을 시작할 HTMLElement
243
+ * @param skip element 자신을 검사에서 제외할지 여부 (기본값: false)
244
+ *
243
245
  * @returns 찾은 UOutlet 엘리먼트
244
246
  * @throws OutletMissingError `u-outlet` 엘리먼트를 찾지 못한 경우
245
247
  */
246
- function findOutletOrThrow(element) {
247
- const outlet = findOutlet(element);
248
+ function findOutletOrThrow(element, skip = false) {
249
+ const outlet = findOutlet(element, skip);
248
250
  if (!outlet) throw new OutletMissingError();
249
251
  return outlet;
250
252
  }
@@ -253,14 +255,18 @@ function findOutletOrThrow(element) {
253
255
  *
254
256
  * @param element 대기할 엘리먼트
255
257
  * @param timeout 타임아웃 시간(밀리초, 기본값: 10_000ms)
258
+ * @param skip element 자신을 검사에서 제외할지 여부 (기본값: false)
259
+ *
256
260
  * @returns 준비된 `u-outlet` 엘리먼트
257
261
  */
258
- async function waitOutlet(element, timeout = 1e4) {
262
+ async function waitOutlet(element, timeout = 1e4, skip = false) {
259
263
  const start = performance.now();
260
264
  while (performance.now() - start < timeout) {
261
- const outlet = findOutlet(element);
265
+ const outlet = findOutlet(element, skip);
262
266
  if (outlet) return outlet;
263
- await new Promise((r) => setTimeout(r, 50));
267
+ if (element.localName.includes("-")) await customElements.whenDefined(element.localName);
268
+ if ("updateComplete" in element) await element.updateComplete;
269
+ await new Promise((resolve) => requestAnimationFrame(() => resolve()));
264
270
  }
265
271
  throw new Error(`Timed out waiting for <u-outlet> inside <${element.tagName.toLowerCase()}>. Ensure that the router root element contains a <u-outlet> child.`);
266
272
  }
@@ -441,7 +447,7 @@ var Router = class {
441
447
  const requestID = getRandomID();
442
448
  this._requestID = requestID;
443
449
  const context = parseUrl(href, this._basepath);
444
- if (this._tracker.visit(context.href)) return;
450
+ if (options?.isRedirect && this._tracker.visit(context.href)) return;
445
451
  const useReplace = options?.isRedirect || options?.replace || context.href === window.location.href;
446
452
  const historyState = {
447
453
  basepath: context.basepath,
@@ -491,14 +497,15 @@ var Router = class {
491
497
  throw new ContentLoadError(e);
492
498
  }
493
499
  try {
494
- outlet.render(content, {
500
+ await outlet.render(content, {
495
501
  id: route.id,
496
502
  force: route.force
497
503
  });
498
504
  } catch (e) {
499
505
  throw new ContentRenderError(e);
500
506
  }
501
- outlet = findOutlet(outlet, true) || outlet;
507
+ if ("children" in route && route.children && route.children.length > 0) outlet = await waitOutlet(outlet, 2e3, true);
508
+ else outlet = findOutlet(outlet, true) || outlet;
502
509
  title = route.title || title;
503
510
  }
504
511
  window.dispatchEvent(new RouteDoneEvent(context));
package/dist/react.js CHANGED
@@ -1,4 +1,4 @@
1
- import { s as UOutlet$1, t as ULink$1 } from "./share-CUGwxZKa.js";
1
+ import { s as UOutlet$1, t as ULink$1 } from "./share-CEEpCf48.js";
2
2
  import React from "react";
3
3
  import { createComponent } from "@lit/react";
4
4
  //#region src/react.ts
@@ -126,12 +126,12 @@ function catchBasepath(basepath) {
126
126
  return basepath;
127
127
  }
128
128
  //#endregion
129
- //#region \0@oxc-project+runtime@0.123.0/helpers/decorateMetadata.js
129
+ //#region \0@oxc-project+runtime@0.124.0/helpers/decorateMetadata.js
130
130
  function __decorateMetadata(k, v) {
131
131
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
132
132
  }
133
133
  //#endregion
134
- //#region \0@oxc-project+runtime@0.123.0/helpers/decorate.js
134
+ //#region \0@oxc-project+runtime@0.124.0/helpers/decorate.js
135
135
  function __decorate(decorators, target, key, desc) {
136
136
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
137
137
  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.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "A modern client-side router for web applications with support for Lit and React components",
5
5
  "keywords": [
6
6
  "lit",
@@ -5,7 +5,7 @@ license: MIT
5
5
  compatibility: Browser environments only (requires URLPattern and History API)
6
6
  metadata:
7
7
  author: iyulab
8
- version: "0.9.0"
8
+ version: "0.9.2"
9
9
  ---
10
10
 
11
11
  # @iyulab/router