ranui 0.2.0-alpha.7 → 0.2.1-alpha.1
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/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/dist/arrow-down-Bi5kqUrX.js +12 -0
- package/dist/builder.d.ts +2 -2
- package/dist/builder.js +32 -28
- package/dist/builtin-D9djWkCE.js +409 -0
- package/dist/{button-Be_uHDZG.js → button-BfYw0fes.js} +1 -1
- package/dist/button.js +1 -1
- package/dist/{card-BVvXX6KM.js → card-CqJa4Q_v.js} +1 -1
- package/dist/card.js +1 -1
- package/dist/{checkbox-BtoX9X2Z.js → checkbox-CThC9-vy.js} +1 -1
- package/dist/checkbox.js +1 -1
- package/dist/{colorpicker-Dukms7ET.js → colorpicker-XNxDRcQ-.js} +5 -6
- package/dist/colorpicker.js +1 -1
- package/dist/components/colorpicker/index.d.ts +3 -3
- package/dist/components/icon/builtin.d.ts +9 -0
- package/dist/components/icon/index.d.ts +8 -0
- package/dist/components/route/index.d.ts +10 -4
- package/dist/components/router/index.d.ts +3 -0
- package/dist/{dropdown-BYS1Trdu.js → dropdown-CCvsambb.js} +1 -1
- package/dist/dropdown.js +1 -1
- package/dist/factory-DCrO37si.js +334 -0
- package/dist/{form-BsB5JhS4.js → form-Ceq3uJzz.js} +1 -1
- package/dist/form.js +1 -1
- package/dist/{icon-pfolda2m.js → icon-C_ENrJ3F.js} +50 -13
- package/dist/icon.js +4 -3
- package/dist/icons.js +5 -0
- package/dist/iife/button.iife.js +1 -1
- package/dist/iife/card.iife.js +1 -1
- package/dist/iife/checkbox.iife.js +1 -1
- package/dist/iife/colorpicker.iife.js +2 -2
- package/dist/iife/dropdown.iife.js +1 -1
- package/dist/iife/form.iife.js +1 -1
- package/dist/iife/icon.iife.js +1 -1
- package/dist/iife/image.iife.js +1 -1
- package/dist/iife/input.iife.js +1 -1
- package/dist/iife/loading.iife.js +1 -1
- package/dist/iife/math.iife.js +14 -14
- package/dist/iife/message.iife.js +1 -1
- package/dist/iife/modal.iife.js +1 -1
- package/dist/iife/player.iife.js +8 -8
- package/dist/iife/popover.iife.js +1 -1
- package/dist/iife/progress.iife.js +1 -1
- package/dist/iife/radar.iife.js +1 -1
- package/dist/iife/route.iife.js +1 -1
- package/dist/iife/router.iife.js +1 -1
- package/dist/iife/scratch.iife.js +1 -1
- package/dist/iife/section.iife.js +1 -1
- package/dist/iife/select.iife.js +2 -2
- package/dist/iife/skeleton.iife.js +1 -1
- package/dist/iife/tab.iife.js +1 -1
- package/dist/iife/tabpane.iife.js +1 -1
- package/dist/{image-BXpKQ9sU.js → image-B7MBI5n_.js} +1 -1
- package/dist/image.js +1 -1
- package/dist/index.cjs +256 -23
- package/dist/index.d.ts +3 -1
- package/dist/index.iife.js +266 -33
- package/dist/index.js +69 -65
- package/dist/{input-BMMM60e6.js → input-RNqdEHPf.js} +2 -2
- package/dist/input.js +1 -1
- package/dist/{loading-BScjyeVm.js → loading-B9MFI03l.js} +1 -1
- package/dist/loading.js +1 -1
- package/dist/{math-IjzOAwnA.js → math-CudIwEXZ.js} +1 -1
- package/dist/math.js +1 -1
- package/dist/{message-CLpuP8HY.js → message-DW7qWpEm.js} +34 -49
- package/dist/message.js +1 -1
- package/dist/{modal-DOTpABRe.js → modal-CrvGKL2B.js} +1 -1
- package/dist/modal.js +1 -1
- package/dist/{player-5olrw-qB.js → player-BKQaaT7o.js} +2 -2
- package/dist/player.js +1 -1
- package/dist/{popover-DRUQjdPs.js → popover-CvYIVgUS.js} +2 -2
- package/dist/popover.js +1 -1
- package/dist/{progress-BIEXYYd2.js → progress-C6jctsFH.js} +1 -1
- package/dist/progress.js +1 -1
- package/dist/{radar-DAF95_Mj.js → radar-BUb4EzmG.js} +1 -1
- package/dist/radar.js +1 -1
- package/dist/route-Djrf9UR_.js +116 -0
- package/dist/route.js +1 -1
- package/dist/{router-B9rCrWXm.js → router-BU2KhtxV.js} +22 -17
- package/dist/router.js +1 -1
- package/dist/{scratch-QlPyy1f4.js → scratch-CO4I2dIa.js} +1 -1
- package/dist/scratch.js +1 -1
- package/dist/{section-D0qMm9KM.js → section-CsUkp8bv.js} +1 -1
- package/dist/section.js +1 -1
- package/dist/{select-aAaWoveE.js → select-Dn26ajJZ.js} +8 -15
- package/dist/select.js +1 -1
- package/dist/{skeleton-CFqQmKyt.js → skeleton-BuMLhvzQ.js} +1 -1
- package/dist/skeleton.js +1 -1
- package/dist/{tab-CiF2YPck.js → tab-40fDkuox.js} +1 -1
- package/dist/tab.js +1 -1
- package/dist/{tabpane-B-m3xwqu.js → tabpane-F4Pd7JtC.js} +1 -1
- package/dist/tabpane.js +1 -1
- package/dist/test/unit/icon.builtin.test.d.ts +1 -0
- package/dist/test/unit/utils.colorpicker.reconnect.test.d.ts +1 -0
- package/dist/test/unit/utils.route.lazy.test.d.ts +1 -0
- package/dist/test/unit/utils.router.match.test.d.ts +1 -0
- package/dist/test/unit/utils.signal.owner.test.d.ts +1 -0
- package/dist/utils/builder/core.d.ts +20 -13
- package/dist/utils/builder/factory.d.ts +1 -1
- package/dist/utils/builder/index.d.ts +2 -2
- package/dist/utils/builder/signal.d.ts +93 -64
- package/dist/utils/router/index.d.ts +13 -3
- package/dist/utils/router.js +95 -54
- package/dist/utils/theme.d.ts +1 -1
- package/dist/warning-circle-fill-Cz0qu7AH.js +23 -0
- package/docs/BUILDER.md +230 -0
- package/docs/COMPONENTS.md +21 -3
- package/package.json +25 -3
- package/dist/factory-BdsO0dEW.js +0 -165
- package/dist/route-MQZpn2BP.js +0 -88
- package/dist/signal-CSSZxlK5.js +0 -57
|
@@ -1,87 +1,116 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Reactive primitives — signal /
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* computed
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
2
|
+
* Reactive primitives — signal / computed / createEffect / batch, plus an
|
|
3
|
+
* ownership layer (createRoot / onCleanup / getOwner / runWithOwner) and untrack.
|
|
4
|
+
*
|
|
5
|
+
* Design reference: SwiftUI @Observable + Solid.js fine-grained reactivity.
|
|
6
|
+
*
|
|
7
|
+
* View = f(State)
|
|
8
|
+
* signal — reactive source (@State)
|
|
9
|
+
* computed — derived, LAZY + memoized (SwiftUI computed property / Solid memo)
|
|
10
|
+
* createEffect— side effect that re-runs when its reads change (≈ body)
|
|
11
|
+
* ownership — effects/memos form an owner tree; disposing a scope disposes
|
|
12
|
+
* everything created under it (critical for MPA: tear down a page
|
|
13
|
+
* and every effect it spawned is cleaned up in one call).
|
|
14
|
+
*
|
|
15
|
+
* Model (push-pull scheduling + lazy memos):
|
|
16
|
+
* - Reading a source inside a computation links them both ways.
|
|
17
|
+
* - Writing a signal marks direct observers DIRTY and their transitive memo
|
|
18
|
+
* observers CHECK ("maybe dirty"), scheduling any dependent effects. Effects
|
|
19
|
+
* flush once (deduped — diamond dependencies run an effect a single time).
|
|
20
|
+
* - Memos recompute lazily on read, and only re-notify their observers when
|
|
21
|
+
* their derived value actually changes (via `equals`). A CHECK computation
|
|
22
|
+
* first pulls its sources up to date; if none changed value, it is skipped —
|
|
23
|
+
* so a memo whose output is stable never wakes the effects behind it.
|
|
24
|
+
* - Every computation is owned; re-running or disposing it first disposes its
|
|
25
|
+
* owned children and runs its cleanups (no leaked nested effects).
|
|
23
26
|
*/
|
|
24
27
|
export type Getter<T> = () => T;
|
|
25
28
|
export type Setter<T> = (value: T | ((prev: T) => T)) => void;
|
|
26
29
|
export interface SignalOptions<T> {
|
|
27
|
-
/** Custom equality
|
|
30
|
+
/** Custom equality. Defaults to Object.is. Return true to skip the update. */
|
|
28
31
|
equals?: (prev: T, next: T) => boolean;
|
|
29
32
|
}
|
|
33
|
+
/** Anything a computation can subscribe to (a signal, or a memo). */
|
|
34
|
+
interface SourceLike {
|
|
35
|
+
observers: Set<Computation>;
|
|
36
|
+
}
|
|
37
|
+
/** Staleness of a computation. CLEAN → up to date; CHECK → a memo source may
|
|
38
|
+
* have changed (verify before recomputing); DIRTY → definitely recompute. */
|
|
39
|
+
declare const CLEAN = 0;
|
|
40
|
+
declare const CHECK = 1;
|
|
41
|
+
declare const DIRTY = 2;
|
|
42
|
+
type State = typeof CLEAN | typeof CHECK | typeof DIRTY;
|
|
43
|
+
/** An effect or a memo — a node that runs a function and tracks its reads. */
|
|
44
|
+
interface Computation extends Owner {
|
|
45
|
+
fn: () => unknown;
|
|
46
|
+
/** Sources (signals / memos) read during the last run. */
|
|
47
|
+
sources: Set<SourceLike>;
|
|
48
|
+
isEffect: boolean;
|
|
49
|
+
running: boolean;
|
|
50
|
+
disposed: boolean;
|
|
51
|
+
state: State;
|
|
52
|
+
observers: Set<Computation>;
|
|
53
|
+
value: unknown;
|
|
54
|
+
equals: (a: unknown, b: unknown) => boolean;
|
|
55
|
+
}
|
|
56
|
+
/** A node that can own child computations + cleanups (effect, memo, or root). */
|
|
57
|
+
export interface Owner {
|
|
58
|
+
owned: Computation[];
|
|
59
|
+
cleanups: Array<() => void>;
|
|
60
|
+
owner: Owner | null;
|
|
61
|
+
}
|
|
30
62
|
/**
|
|
31
|
-
* Create a reactive value. Returns a [getter, setter] tuple.
|
|
63
|
+
* Create a reactive value. Returns a `[getter, setter]` tuple.
|
|
32
64
|
*
|
|
33
65
|
* const [count, setCount] = signal(0);
|
|
34
|
-
* count()
|
|
35
|
-
* setCount(1)
|
|
36
|
-
* setCount(n => n + 1) // updater
|
|
66
|
+
* count(); // read — auto-tracked inside computed / createEffect
|
|
67
|
+
* setCount(1); // write — notifies dependents; skipped if unchanged
|
|
68
|
+
* setCount((n) => n + 1) // updater form
|
|
37
69
|
*/
|
|
38
70
|
export declare function signal<T>(initial: T, options?: SignalOptions<T>): [Getter<T>, Setter<T>];
|
|
39
71
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
72
|
+
* Derived, read-only, LAZY + memoized value. Recomputes only when read after a
|
|
73
|
+
* dependency changed; unread memos never recompute. When a recompute produces an
|
|
74
|
+
* equal value (default `Object.is`, override via `options.equals`) the memo does
|
|
75
|
+
* NOT notify its observers — so effects behind a value-stable memo stay asleep.
|
|
76
|
+
* Owned by the current scope, so it is disposed when that scope is.
|
|
77
|
+
*
|
|
78
|
+
* const fullName = computed(() => `${first()} ${last()}`);
|
|
79
|
+
* fullName(); // computes on first read, caches until a dep's value changes
|
|
80
|
+
*/
|
|
81
|
+
export declare function computed<T>(fn: () => T, options?: SignalOptions<T>): Getter<T>;
|
|
82
|
+
/**
|
|
83
|
+
* Run `fn` immediately, then re-run it whenever a signal/memo it read changes.
|
|
84
|
+
* Owned by the current scope. `fn` may return a cleanup, called before each
|
|
85
|
+
* re-run and on dispose. Returns a dispose function.
|
|
48
86
|
*
|
|
49
87
|
* const dispose = createEffect(() => {
|
|
50
|
-
*
|
|
51
|
-
* return () => {
|
|
88
|
+
* el.textContent = `Count: ${count()}`;
|
|
89
|
+
* return () => {}; // optional cleanup
|
|
52
90
|
* });
|
|
53
|
-
*
|
|
54
|
-
* dispose(); // stop tracking, remove from all signals
|
|
55
91
|
*/
|
|
56
92
|
export declare function createEffect(fn: () => void | (() => void)): () => void;
|
|
57
93
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* const [firstName, setFirstName] = signal('Jane');
|
|
61
|
-
* const [lastName, setLastName] = signal('Doe');
|
|
62
|
-
* const fullName = computed(() => `${firstName()} ${lastName()}`);
|
|
63
|
-
*
|
|
64
|
-
* fullName() // 'Jane Doe'
|
|
65
|
-
* setFirstName('John');
|
|
66
|
-
* fullName() // 'John Doe'
|
|
94
|
+
* Coalesce multiple writes into one flush. Effects run once after `fn` returns,
|
|
95
|
+
* deduplicated. Nested batches are absorbed by the outermost one.
|
|
67
96
|
*/
|
|
68
|
-
export declare function
|
|
97
|
+
export declare function batch(fn: () => void): void;
|
|
98
|
+
/** Read signals without subscribing the current computation to them. */
|
|
99
|
+
export declare function untrack<T>(fn: () => T): T;
|
|
69
100
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
101
|
+
* Create a disposable reactive scope. Effects/memos created inside are owned by
|
|
102
|
+
* it; calling the passed `dispose` tears them all down. Use one per page/route
|
|
103
|
+
* in an MPA/SPA so navigating away cleans up every effect that page spawned.
|
|
72
104
|
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* setFirstName('John');
|
|
77
|
-
* setLastName('Smith');
|
|
78
|
-
*
|
|
79
|
-
* // With batch: one flush after both writes (1 run)
|
|
80
|
-
* batch(() => {
|
|
81
|
-
* setFirstName('John');
|
|
82
|
-
* setLastName('Smith');
|
|
83
|
-
* });
|
|
84
|
-
*
|
|
85
|
-
* Nested batch() calls are safe — inner calls are absorbed by the outer batch.
|
|
105
|
+
* const dispose = createRoot((dispose) => { renderPage(); return dispose; });
|
|
106
|
+
* // ...later, on navigation:
|
|
107
|
+
* dispose();
|
|
86
108
|
*/
|
|
87
|
-
export declare function
|
|
109
|
+
export declare function createRoot<T>(fn: (dispose: () => void) => T): T;
|
|
110
|
+
/** Register a cleanup on the current scope, run when it re-runs or is disposed. */
|
|
111
|
+
export declare function onCleanup(fn: () => void): void;
|
|
112
|
+
/** The current owner scope (for advanced integrations, e.g. a router). */
|
|
113
|
+
export declare function getOwner(): Owner | null;
|
|
114
|
+
/** Run `fn` under a specific owner scope (pairs with getOwner). */
|
|
115
|
+
export declare function runWithOwner<T>(owner: Owner | null, fn: () => T): T;
|
|
116
|
+
export {};
|
|
@@ -55,10 +55,19 @@ export interface RouterComponentElement extends HTMLElement {
|
|
|
55
55
|
export declare function getSSGPath(): string | null;
|
|
56
56
|
export declare function setSSGPath(path: string): void;
|
|
57
57
|
export declare function clearSSGPath(): void;
|
|
58
|
+
/**
|
|
59
|
+
* Match a route pattern (with `:param` and `*` segments) against a path.
|
|
60
|
+
* Single source of truth shared by RouterCore and the `<r-route>` element.
|
|
61
|
+
*/
|
|
62
|
+
export declare function matchPath(routePath: string, exact: boolean, path: string): {
|
|
63
|
+
matched: boolean;
|
|
64
|
+
params: Record<string, string>;
|
|
65
|
+
};
|
|
58
66
|
export declare class RouterCore {
|
|
59
67
|
private readonly _mode;
|
|
60
68
|
private readonly _base;
|
|
61
69
|
private readonly _routes;
|
|
70
|
+
private readonly _flatRoutes;
|
|
62
71
|
private readonly _vtMode;
|
|
63
72
|
private readonly _beforeGuards;
|
|
64
73
|
private readonly _afterGuards;
|
|
@@ -73,10 +82,11 @@ export declare class RouterCore {
|
|
|
73
82
|
get base(): string;
|
|
74
83
|
get routes(): RouteConfig[];
|
|
75
84
|
get currentRoute(): RouteLocation | null;
|
|
76
|
-
|
|
77
|
-
/** Return the first RouteConfig whose path matches the given URL path, or null. */
|
|
85
|
+
/** Return the first matching route (absolute path, nested-aware), or null. */
|
|
78
86
|
matchRoute(path: string): RouteConfig | null;
|
|
79
|
-
/**
|
|
87
|
+
/** Extract `:param` values for the first matching route ({} if none). */
|
|
88
|
+
matchParams(path: string): Record<string, string>;
|
|
89
|
+
/** All declared route paths (nested flattened) — used to enumerate SSG pages. */
|
|
80
90
|
getStaticPaths(): string[];
|
|
81
91
|
private _enableMpa;
|
|
82
92
|
private _disableMpa;
|
package/dist/utils/router.js
CHANGED
|
@@ -1,41 +1,71 @@
|
|
|
1
|
-
var
|
|
2
|
-
function
|
|
3
|
-
return
|
|
1
|
+
var c = null, r = null, h = null;
|
|
2
|
+
function P() {
|
|
3
|
+
return h;
|
|
4
4
|
}
|
|
5
|
-
function
|
|
6
|
-
|
|
5
|
+
function x(e) {
|
|
6
|
+
h = e;
|
|
7
7
|
}
|
|
8
|
-
function
|
|
9
|
-
|
|
8
|
+
function E() {
|
|
9
|
+
h = null;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function m(e) {
|
|
12
12
|
const t = {};
|
|
13
|
-
return e && new URLSearchParams(e.startsWith("?") ? e.slice(1) : e).forEach((
|
|
14
|
-
t[
|
|
13
|
+
return e && new URLSearchParams(e.startsWith("?") ? e.slice(1) : e).forEach((n, a) => {
|
|
14
|
+
t[a] = n;
|
|
15
15
|
}), t;
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function f(e, t, n) {
|
|
18
|
+
const a = [], s = e.split("/").map((i) => i.startsWith(":") ? (a.push(i.slice(1)), "([^/]+)") : i === "*" ? "(.*)" : i.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("/"), o = t ? new RegExp(`^${s}$`) : new RegExp(`^${s}(?:/.*)?$`), u = n.match(o);
|
|
19
|
+
if (!u) return {
|
|
20
|
+
matched: !1,
|
|
21
|
+
params: {}
|
|
22
|
+
};
|
|
23
|
+
const d = {};
|
|
24
|
+
return a.forEach((i, w) => {
|
|
25
|
+
d[i] = decodeURIComponent(u[w + 1] ?? "");
|
|
26
|
+
}), {
|
|
27
|
+
matched: !0,
|
|
28
|
+
params: d
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function g(e, t) {
|
|
32
|
+
return e ? `${e.replace(/\/$/, "")}/${t.replace(/^\//, "")}` : t;
|
|
33
|
+
}
|
|
34
|
+
function l(e, t = "") {
|
|
35
|
+
const n = [];
|
|
36
|
+
for (const a of e) {
|
|
37
|
+
const s = g(t, a.path);
|
|
38
|
+
n.push({
|
|
39
|
+
path: s,
|
|
40
|
+
exact: a.exact ?? !1,
|
|
41
|
+
meta: a.meta
|
|
42
|
+
}), a.children?.length && n.push(...l(a.children, s));
|
|
43
|
+
}
|
|
44
|
+
return n;
|
|
45
|
+
}
|
|
46
|
+
function v() {
|
|
18
47
|
return typeof document < "u" && "startViewTransition" in document;
|
|
19
48
|
}
|
|
20
|
-
function
|
|
21
|
-
|
|
49
|
+
function b(e) {
|
|
50
|
+
v() ? document.startViewTransition(e) : e();
|
|
22
51
|
}
|
|
23
|
-
function
|
|
52
|
+
function p() {
|
|
24
53
|
typeof document > "u" || r && document.head.contains(r) || (r = document.createElement("style"), r.textContent = "@view-transition { navigation: auto; }", document.head.appendChild(r));
|
|
25
54
|
}
|
|
26
|
-
function
|
|
55
|
+
function _() {
|
|
27
56
|
r?.remove(), r = null;
|
|
28
57
|
}
|
|
29
|
-
function
|
|
58
|
+
function y(e) {
|
|
30
59
|
return e === !0 || e === "spa" || e === "both";
|
|
31
60
|
}
|
|
32
|
-
function
|
|
61
|
+
function S(e) {
|
|
33
62
|
return e === "mpa" || e === "both";
|
|
34
63
|
}
|
|
35
|
-
var
|
|
64
|
+
var R = class {
|
|
36
65
|
_mode;
|
|
37
66
|
_base;
|
|
38
67
|
_routes;
|
|
68
|
+
_flatRoutes;
|
|
39
69
|
_vtMode;
|
|
40
70
|
_beforeGuards = [];
|
|
41
71
|
_afterGuards = [];
|
|
@@ -46,7 +76,7 @@ var g = class {
|
|
|
46
76
|
_current = null;
|
|
47
77
|
_mpaActive = !1;
|
|
48
78
|
constructor(e = {}) {
|
|
49
|
-
this._mode = e.mode ?? "history", this._base = e.base ?? "", this._routes = e.routes ?? [], this._vtMode = e.viewTransition,
|
|
79
|
+
this._mode = e.mode ?? "history", this._base = e.base ?? "", this._routes = e.routes ?? [], this._flatRoutes = l(this._routes), this._vtMode = e.viewTransition, S(this._vtMode) && this._enableMpa();
|
|
50
80
|
}
|
|
51
81
|
get mode() {
|
|
52
82
|
return this._mode;
|
|
@@ -60,21 +90,29 @@ var g = class {
|
|
|
60
90
|
get currentRoute() {
|
|
61
91
|
return this._current;
|
|
62
92
|
}
|
|
63
|
-
_matchConfigPath(e, t) {
|
|
64
|
-
const i = [], n = t.path.split("/").map((s) => s.startsWith(":") ? (i.push(s.slice(1)), "([^/]+)") : s === "*" ? "(.*)" : s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("/");
|
|
65
|
-
return (t.exact ? new RegExp(`^${n}$`) : new RegExp(`^${n}(?:/.*)?$`)).test(e);
|
|
66
|
-
}
|
|
67
93
|
matchRoute(e) {
|
|
68
|
-
|
|
94
|
+
const t = this._flatRoutes.find((n) => f(n.path, n.exact, e).matched);
|
|
95
|
+
return t ? {
|
|
96
|
+
path: t.path,
|
|
97
|
+
exact: t.exact,
|
|
98
|
+
meta: t.meta
|
|
99
|
+
} : null;
|
|
100
|
+
}
|
|
101
|
+
matchParams(e) {
|
|
102
|
+
for (const t of this._flatRoutes) {
|
|
103
|
+
const n = f(t.path, t.exact, e);
|
|
104
|
+
if (n.matched) return n.params;
|
|
105
|
+
}
|
|
106
|
+
return {};
|
|
69
107
|
}
|
|
70
108
|
getStaticPaths() {
|
|
71
|
-
return this.
|
|
109
|
+
return this._flatRoutes.map((e) => e.path);
|
|
72
110
|
}
|
|
73
111
|
_enableMpa() {
|
|
74
|
-
this._mpaActive || (this._mpaActive = !0,
|
|
112
|
+
this._mpaActive || (this._mpaActive = !0, p(), typeof window < "u" && (window.addEventListener("pageswap", this._onPageSwap), window.addEventListener("pagereveal", this._onPageReveal)));
|
|
75
113
|
}
|
|
76
114
|
_disableMpa() {
|
|
77
|
-
this._mpaActive && (this._mpaActive = !1,
|
|
115
|
+
this._mpaActive && (this._mpaActive = !1, _(), typeof window < "u" && (window.removeEventListener("pageswap", this._onPageSwap), window.removeEventListener("pagereveal", this._onPageReveal)));
|
|
78
116
|
}
|
|
79
117
|
_onPageSwap = (e) => {
|
|
80
118
|
this._pageSwapHandlers.forEach((t) => t(e));
|
|
@@ -89,11 +127,11 @@ var g = class {
|
|
|
89
127
|
this._components.delete(e);
|
|
90
128
|
}
|
|
91
129
|
_buildLocation(e) {
|
|
92
|
-
const t = e.indexOf("?"),
|
|
130
|
+
const t = e.indexOf("?"), n = t === -1 ? e : e.slice(0, t), a = t === -1 ? "" : e.slice(t + 1);
|
|
93
131
|
return {
|
|
94
|
-
path:
|
|
132
|
+
path: n || "/",
|
|
95
133
|
params: {},
|
|
96
|
-
query:
|
|
134
|
+
query: m(a),
|
|
97
135
|
fullPath: e || "/"
|
|
98
136
|
};
|
|
99
137
|
}
|
|
@@ -104,21 +142,23 @@ var g = class {
|
|
|
104
142
|
return (t && e.startsWith(t) ? e.slice(t.length) || "/" : e) + (window.location.search || "");
|
|
105
143
|
}
|
|
106
144
|
_notify() {
|
|
107
|
-
const e = this._buildLocation(this._getCurrentPath())
|
|
145
|
+
const e = this._buildLocation(this._getCurrentPath());
|
|
146
|
+
e.params = this.matchParams(e.path);
|
|
147
|
+
const t = this._current;
|
|
108
148
|
this._current = e;
|
|
109
|
-
const
|
|
110
|
-
this._components.forEach((
|
|
149
|
+
const n = () => {
|
|
150
|
+
this._components.forEach((a) => a._syncRoutes());
|
|
111
151
|
};
|
|
112
|
-
|
|
152
|
+
y(this._vtMode) ? b(n) : n(), this._afterGuards.forEach((a) => a(e, t)), this._changeHandlers.forEach((a) => a(e, t));
|
|
113
153
|
}
|
|
114
154
|
async _navigate(e, t) {
|
|
115
|
-
const
|
|
155
|
+
const n = this._buildLocation(e), a = this._current;
|
|
116
156
|
for (const s of this._beforeGuards) {
|
|
117
|
-
const
|
|
118
|
-
s(
|
|
157
|
+
const o = await new Promise((u) => {
|
|
158
|
+
s(n, a, u);
|
|
119
159
|
});
|
|
120
|
-
if (
|
|
121
|
-
if (typeof
|
|
160
|
+
if (o === !1) return;
|
|
161
|
+
if (typeof o == "string") return this._navigate(o, t);
|
|
122
162
|
}
|
|
123
163
|
if (typeof window < "u") {
|
|
124
164
|
const s = this._mode === "hash" ? `#${e}` : this._base + e;
|
|
@@ -175,23 +215,24 @@ var g = class {
|
|
|
175
215
|
};
|
|
176
216
|
}
|
|
177
217
|
};
|
|
178
|
-
function
|
|
179
|
-
|
|
180
|
-
const t = new
|
|
181
|
-
return
|
|
218
|
+
function H(e) {
|
|
219
|
+
c?.destroy();
|
|
220
|
+
const t = new R(e);
|
|
221
|
+
return c = t, t;
|
|
182
222
|
}
|
|
183
|
-
function
|
|
184
|
-
return
|
|
223
|
+
function M() {
|
|
224
|
+
return c;
|
|
185
225
|
}
|
|
186
|
-
function
|
|
187
|
-
return
|
|
226
|
+
function G() {
|
|
227
|
+
return p(), () => _();
|
|
188
228
|
}
|
|
189
229
|
export {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
230
|
+
R as RouterCore,
|
|
231
|
+
E as clearSSGPath,
|
|
232
|
+
H as createRouter,
|
|
233
|
+
G as enableMpaViewTransitions,
|
|
234
|
+
P as getSSGPath,
|
|
235
|
+
f as matchPath,
|
|
236
|
+
x as setSSGPath,
|
|
237
|
+
M as useRouter
|
|
197
238
|
};
|
package/dist/utils/theme.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export type RanThemeName = 'light' | 'dark' | 'system';
|
|
|
2
2
|
export type ThemeTarget = HTMLElement | Document;
|
|
3
3
|
export type ThemeTokenMap = Record<string, string | number | null | undefined>;
|
|
4
4
|
export declare const setTheme: (name: RanThemeName, target?: ThemeTarget) => void;
|
|
5
|
-
export declare const getTheme: (target?: ThemeTarget) => RanThemeName |
|
|
5
|
+
export declare const getTheme: (target?: ThemeTarget) => RanThemeName | '';
|
|
6
6
|
export declare const setThemeToken: (name: string, value: string | number, target?: HTMLElement) => void;
|
|
7
7
|
export declare const clearThemeToken: (name: string, target?: HTMLElement) => void;
|
|
8
8
|
export declare const setThemeTokens: (tokens: ThemeTokenMap, target?: HTMLElement) => void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var i = {
|
|
2
|
+
success: !0,
|
|
3
|
+
_identification: !0,
|
|
4
|
+
data: '<svg t="1667965185400" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8572" width="200" height="200"><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64z m193.5 301.7l-210.6 292c-12.7 17.7-39 17.7-51.7 0L318.5 484.9c-3.8-5.3 0-12.7 6.5-12.7h46.9c10.2 0 19.9 4.9 25.9 13.3l71.2 98.8 157.2-218c6-8.3 15.6-13.3 25.9-13.3H699c6.5 0 10.3 7.4 6.5 12.7z" p-id="8573"></path></svg>'
|
|
5
|
+
}, t = {
|
|
6
|
+
success: !0,
|
|
7
|
+
_identification: !0,
|
|
8
|
+
data: '<svg t="1667965220951" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8711" width="200" height="200"><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64z m165.4 618.2l-66-0.3L512 563.4l-99.3 118.4-66.1 0.3c-4.4 0-8-3.5-8-8 0-1.9 0.7-3.7 1.9-5.2l130.1-155L340.5 359c-1.2-1.5-1.9-3.3-1.9-5.2 0-4.4 3.6-8 8-8l66.1 0.3L512 464.6l99.3-118.4 66-0.3c4.4 0 8 3.5 8 8 0 1.9-0.7 3.7-1.9 5.2L553.5 514l130 155c1.2 1.5 1.9 3.3 1.9 5.2 0 4.4-3.6 8-8 8z" p-id="8712"></path></svg>'
|
|
9
|
+
}, s = {
|
|
10
|
+
success: !0,
|
|
11
|
+
_identification: !0,
|
|
12
|
+
data: '<svg t="1667965239916" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8850" width="200" height="200"><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64z m32 664c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V456c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272z m-32-344c-26.5 0-48-21.5-48-48s21.5-48 48-48 48 21.5 48 48-21.5 48-48 48z" p-id="8851"></path></svg>'
|
|
13
|
+
}, c = {
|
|
14
|
+
success: !0,
|
|
15
|
+
_identification: !0,
|
|
16
|
+
data: '<svg t="1667965273540" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8989" width="200" height="200"><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64z m-32 232c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V296z m32 440c-26.5 0-48-21.5-48-48s21.5-48 48-48 48 21.5 48 48-21.5 48-48 48z" p-id="8990"></path></svg>'
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
i,
|
|
20
|
+
s as n,
|
|
21
|
+
t as r,
|
|
22
|
+
c as t
|
|
23
|
+
};
|