@deijose/nix-js 1.7.7 → 1.7.9-beta.0
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 +3 -3
- package/dist/lib/nix/async.d.ts +54 -66
- package/dist/lib/nix/template/bindings.d.ts +28 -0
- package/dist/lib/nix/template/dom-write.d.ts +5 -0
- package/dist/lib/nix/template/error-boundary.d.ts +7 -0
- package/dist/lib/nix/template/html.d.ts +8 -0
- package/dist/lib/nix/template/index.d.ts +9 -0
- package/dist/lib/nix/template/keyed.d.ts +13 -0
- package/dist/lib/nix/template/mount-helpers.d.ts +29 -0
- package/dist/lib/nix/template/node-binding.d.ts +6 -0
- package/dist/lib/nix/template/portal.d.ts +19 -0
- package/dist/lib/nix/template/transitions.d.ts +43 -0
- package/dist/lib/nix/template/types.d.ts +48 -0
- package/dist/lib/nix-js.cjs +8 -8
- package/dist/lib/nix-js.js +8 -8
- package/package.json +6 -5
- /package/dist/lib/nix/{template.d.ts → template_old.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/@deijose/nix-js)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
[]()
|
|
6
|
-
[]()
|
|
7
7
|
[]()
|
|
8
|
-
[](https://nix-js
|
|
8
|
+
[](https://nix-js.dev/)
|
|
9
9
|
|
|
10
10
|
A lightweight, fully reactive micro-framework for building modern web UIs — no virtual DOM, no compiler, no build-time magic. Just signals, tagged templates, and pure TypeScript.
|
|
11
11
|
|
|
12
|
-
**[→ Documentation & Live Demo](https://nix-js
|
|
12
|
+
**[→ Documentation & Live Demo](https://nix-js.dev/)**
|
|
13
13
|
|
|
14
14
|
```
|
|
15
15
|
~24 KB minified · ~8 KB gzipped · zero dependencies · TypeScript-first · ES2022
|
package/dist/lib/nix/async.d.ts
CHANGED
|
@@ -2,108 +2,96 @@ import { Signal } from "./reactivity";
|
|
|
2
2
|
import { NixComponent } from "./lifecycle";
|
|
3
3
|
import type { NixTemplate } from "./template";
|
|
4
4
|
export interface SuspenseOptions {
|
|
5
|
-
/** Template shown while the promise is pending. */
|
|
6
5
|
fallback?: NixTemplate;
|
|
7
|
-
/** Factory receiving the error, returns the error template. */
|
|
8
6
|
errorFallback?: (err: unknown) => NixTemplate;
|
|
9
|
-
/** If `true`, shows fallback during re-fetches instead of stale content. */
|
|
10
7
|
resetOnRefresh?: boolean;
|
|
11
|
-
/** Signal that triggers a re-fetch when its value changes. DOM is reused. */
|
|
12
8
|
invalidate?: Signal<unknown>;
|
|
13
|
-
/**
|
|
14
|
-
* Optional cache key. When provided, resolved data is cached globally
|
|
15
|
-
* so that subsequent mounts with the same key render cached data instantly,
|
|
16
|
-
* similar to `createQuery` caching behaviour.
|
|
17
|
-
*/
|
|
18
9
|
cacheKey?: string;
|
|
10
|
+
staleTime?: number;
|
|
11
|
+
}
|
|
12
|
+
export type QueryStatus = "pending" | "success" | "error";
|
|
13
|
+
export interface QueryResult<T> {
|
|
14
|
+
/** Reactive signal with the current fetch status. */
|
|
15
|
+
readonly status: Signal<QueryStatus>;
|
|
16
|
+
/** Reactive signal with the resolved data. `undefined` while pending. */
|
|
17
|
+
readonly data: Signal<T | undefined>;
|
|
18
|
+
/** Reactive signal with the captured error. `undefined` if no error. */
|
|
19
|
+
readonly error: Signal<unknown>;
|
|
20
|
+
/** Clears the cache for this key and re-fetches immediately. */
|
|
21
|
+
refetch(): void;
|
|
22
|
+
}
|
|
23
|
+
export interface QueryOptions {
|
|
19
24
|
/**
|
|
20
|
-
* Time in
|
|
21
|
-
* While fresh,
|
|
22
|
-
*
|
|
23
|
-
* @default 0 (always stale — refetch in background on every mount)
|
|
25
|
+
* Time in ms that cached data is considered fresh.
|
|
26
|
+
* While fresh, mounting will not trigger a background refetch.
|
|
27
|
+
* @default 0
|
|
24
28
|
*/
|
|
25
29
|
staleTime?: number;
|
|
30
|
+
/**
|
|
31
|
+
* - `"always"` — background refetch on every mount (default).
|
|
32
|
+
* - `"stale"` — refetch only when data has exceeded `staleTime`.
|
|
33
|
+
* - `false` — never refetch on mount; only via `refetch()` or `invalidateQueries()`.
|
|
34
|
+
* @default "always"
|
|
35
|
+
*/
|
|
36
|
+
refetchOnMount?: "always" | "stale" | false;
|
|
26
37
|
}
|
|
27
38
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* - Pass a specific `key` to clear only that entry.
|
|
39
|
+
* Clears one or all entries from the global query cache.
|
|
40
|
+
* Passing no argument clears everything.
|
|
31
41
|
*/
|
|
32
42
|
export declare function clearQueryCache(key?: string): void;
|
|
33
43
|
/**
|
|
34
|
-
*
|
|
35
|
-
* @param ms
|
|
44
|
+
* Sets how long cache entries with zero subscribers are kept alive.
|
|
45
|
+
* @param ms Milliseconds. Pass `Infinity` to keep entries forever.
|
|
36
46
|
*/
|
|
37
47
|
export declare function setQueryCacheTime(ms: number): void;
|
|
38
48
|
/**
|
|
39
49
|
* Runs an async function and renders based on its state (pending/resolved/error).
|
|
40
|
-
* Equivalent to the Suspense pattern in other frameworks.
|
|
41
50
|
*
|
|
42
|
-
* Pass `invalidate` to re-fetch without destroying the DOM:
|
|
43
51
|
* ```ts
|
|
44
52
|
* const refresh = signal(0);
|
|
45
53
|
* suspend(() => fetchData(), render, { invalidate: refresh });
|
|
46
|
-
*
|
|
47
|
-
* ```
|
|
48
|
-
*
|
|
49
|
-
* Pass `cacheKey` to enable caching — subsequent mounts render cached data
|
|
50
|
-
* instantly without a loading spinner:
|
|
51
|
-
* ```ts
|
|
52
|
-
* suspend(() => fetchProfile(), render, { cacheKey: "profile" });
|
|
54
|
+
* refresh.update(n => n + 1);
|
|
53
55
|
* ```
|
|
54
56
|
*/
|
|
55
57
|
export declare function suspend<T>(asyncFn: () => Promise<T>, renderFn: (data: T) => NixTemplate | NixComponent, options?: SuspenseOptions): NixComponent;
|
|
56
58
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
+
* Forces all active `createQuery()` instances with the given key to re-fetch.
|
|
60
|
+
* Clears the cached data so subsequent mounts also fetch fresh data.
|
|
61
|
+
* Instances that have been garbage-collected are pruned automatically.
|
|
59
62
|
*/
|
|
60
63
|
export declare function invalidateQueries(key: string): void;
|
|
61
|
-
export interface QueryOptions {
|
|
62
|
-
/** Template shown while the promise is pending. */
|
|
63
|
-
fallback?: NixTemplate;
|
|
64
|
-
/** Factory receiving the error, returns the error template. */
|
|
65
|
-
errorFallback?: (err: unknown) => NixTemplate;
|
|
66
|
-
/** If `true`, shows fallback during re-fetches instead of stale content. */
|
|
67
|
-
resetOnRefresh?: boolean;
|
|
68
|
-
/**
|
|
69
|
-
* Time in ms that cached data is considered fresh.
|
|
70
|
-
* While fresh, mounting the query will **not** refetch — it renders cached
|
|
71
|
-
* data instantly. Set to `Infinity` to never auto-refetch.
|
|
72
|
-
* @default 0 (always stale — background refetch on every mount)
|
|
73
|
-
*/
|
|
74
|
-
staleTime?: number;
|
|
75
|
-
/**
|
|
76
|
-
* Controls whether a background refetch happens when the component mounts.
|
|
77
|
-
* - `"always"` — always refetch on mount (default; stale data shown instantly
|
|
78
|
-
* while the refetch runs in the background).
|
|
79
|
-
* - `"stale"` — refetch only if cached data has exceeded `staleTime`.
|
|
80
|
-
* - `false` — never refetch on mount; only manual `invalidateQueries()` refetches.
|
|
81
|
-
* @default "always"
|
|
82
|
-
*/
|
|
83
|
-
refetchOnMount?: "always" | "stale" | false;
|
|
84
|
-
}
|
|
85
64
|
/**
|
|
86
|
-
* Key-based async data fetching with
|
|
87
|
-
*
|
|
65
|
+
* Key-based async data fetching with global cache and invalidation.
|
|
66
|
+
* Returns reactive signals — render them directly in your component.
|
|
88
67
|
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* 1. If cached data exists, it is rendered **immediately** (no loading spinner).
|
|
92
|
-
* 2. A background refetch runs (unless the data is still "fresh" per `staleTime`).
|
|
93
|
-
* 3. When the refetch resolves, the UI updates seamlessly.
|
|
68
|
+
* Cache persists across route changes. Navigating back renders cached
|
|
69
|
+
* data instantly, then background-refetches if stale.
|
|
94
70
|
*
|
|
95
71
|
* ```ts
|
|
96
|
-
*
|
|
72
|
+
* class PostsPage extends NixComponent {
|
|
73
|
+
* private q = createQuery("posts", () => api.getPosts());
|
|
74
|
+
*
|
|
75
|
+
* render() {
|
|
76
|
+
* return html`
|
|
77
|
+
* ${() => this.q.status.value === "pending" && html`<p>Loading…</p>`}
|
|
78
|
+
* ${() => this.q.status.value === "error" && html`<p>Error</p>`}
|
|
79
|
+
* ${() => this.q.status.value === "success" && html`
|
|
80
|
+
* <ul>${() => repeat(this.q.data.value!, r => r.id,
|
|
81
|
+
* r => html`<li>${() => r.name}</li>`)}</ul>
|
|
82
|
+
* `}
|
|
83
|
+
* `;
|
|
84
|
+
* }
|
|
85
|
+
* }
|
|
97
86
|
*
|
|
98
|
-
* // After a mutation
|
|
99
|
-
* invalidateQueries("
|
|
87
|
+
* // After a mutation:
|
|
88
|
+
* invalidateQueries("posts");
|
|
100
89
|
* ```
|
|
101
90
|
*/
|
|
102
|
-
export declare function createQuery<T>(key: string, asyncFn: () => Promise<T>,
|
|
91
|
+
export declare function createQuery<T>(key: string, asyncFn: () => Promise<T>, options?: QueryOptions): QueryResult<T>;
|
|
103
92
|
/**
|
|
104
93
|
* Wraps a dynamic import for lazy-loading route components.
|
|
105
|
-
* The module is loaded once
|
|
106
|
-
* The imported module must use a default export.
|
|
94
|
+
* The module is loaded once and cached. The imported module must use a default export.
|
|
107
95
|
*/
|
|
108
96
|
export declare function lazy(importFn: () => Promise<{
|
|
109
97
|
default: new () => NixComponent;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** Toggles element visibility via `display: none` without unmounting. */
|
|
2
|
+
export declare function showWhen(el: HTMLElement, condition: boolean): void;
|
|
3
|
+
type BindingContext = {
|
|
4
|
+
type: "node";
|
|
5
|
+
} | {
|
|
6
|
+
type: "event";
|
|
7
|
+
eventName: string;
|
|
8
|
+
modifiers: string[];
|
|
9
|
+
hadOpenQuote: boolean;
|
|
10
|
+
} | {
|
|
11
|
+
type: "attr";
|
|
12
|
+
attrName: string;
|
|
13
|
+
hadOpenQuote: boolean;
|
|
14
|
+
};
|
|
15
|
+
export type { BindingContext };
|
|
16
|
+
/**
|
|
17
|
+
* Determines the binding context (node, event, or attribute) for an interpolated
|
|
18
|
+
* value based on the preceding template string.
|
|
19
|
+
*/
|
|
20
|
+
export declare function detectContext(prevString: string): BindingContext;
|
|
21
|
+
/** Activates all bindings on the cloned fragment. Returns dispose/postMount. */
|
|
22
|
+
export declare function activateBindings(fragment: DocumentFragment, contexts: BindingContext[], values: unknown[], pathMap: Array<{
|
|
23
|
+
nodeIndex: number;
|
|
24
|
+
name?: string;
|
|
25
|
+
} | null>): {
|
|
26
|
+
disposes: Array<() => void>;
|
|
27
|
+
postMountHooks: Array<() => void>;
|
|
28
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { NixComponent } from "../lifecycle";
|
|
2
|
+
import type { NixTemplate, ErrorFallback } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Wraps `content` in an error boundary. If rendering or a reactive update
|
|
5
|
+
* throws, the boundary tears down the broken subtree and renders `fallback`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createErrorBoundary(content: NixTemplate | NixComponent, fallback: ErrorFallback): NixTemplate;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { NixTemplate } from "./types";
|
|
2
|
+
import type { BindingContext } from "./bindings";
|
|
3
|
+
/**
|
|
4
|
+
* Builds the static HTML string, replacing each interpolated value with
|
|
5
|
+
* a comment marker (node), data-nix-e-N (event), or data-nix-a-N (attribute).
|
|
6
|
+
*/
|
|
7
|
+
export declare function buildHTML(strings: readonly string[], contexts: BindingContext[]): string;
|
|
8
|
+
export declare function html(strings: TemplateStringsArray, ...values: unknown[]): NixTemplate;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type { NixTemplate, NixMountHandle, NixRef, KeyedList, PortalOutlet, ErrorFallback, TransitionContent } from "./types";
|
|
2
|
+
export { ref, isNixTemplate, isKeyedList, COMMENT } from "./types";
|
|
3
|
+
export { html, buildHTML } from "./html";
|
|
4
|
+
export { showWhen } from "./bindings";
|
|
5
|
+
export { repeat } from "./keyed";
|
|
6
|
+
export { transition } from "./transitions";
|
|
7
|
+
export type { TransitionOptions } from "./transitions";
|
|
8
|
+
export { portal, portalOutlet, createPortalOutlet, provideOutlet, injectOutlet } from "./portal";
|
|
9
|
+
export { createErrorBoundary } from "./error-boundary";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { NixTemplate, KeyedList, KEntry } from "./types";
|
|
2
|
+
import type { NixComponent } from "../lifecycle";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a keyed list for efficient DOM reconciliation.
|
|
5
|
+
* Use instead of `.map()` when the list changes frequently.
|
|
6
|
+
*/
|
|
7
|
+
export declare function repeat<T>(items: T[], keyFn: (item: T, index: number) => string | number, renderFn: (item: T, index: number) => NixTemplate | NixComponent): KeyedList<T>;
|
|
8
|
+
/**
|
|
9
|
+
* Returns the indices of the Longest Increasing Subsequence.
|
|
10
|
+
* Used to minimize DOM operations during list diffing.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getSequence(arr: Int32Array | number[]): number[];
|
|
13
|
+
export type { KEntry };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { NixComponent } from "../lifecycle";
|
|
2
|
+
import { _captureContextSnapshot } from "../context";
|
|
3
|
+
/**
|
|
4
|
+
* Renders a NixComponent into the DOM and calls onMount immediately.
|
|
5
|
+
* Propagates errors through onError (or re-throws if not present).
|
|
6
|
+
* Returns a full cleanup function (onUnmount + mountCleanup + renderCleanup).
|
|
7
|
+
*/
|
|
8
|
+
export declare function _mountComponent(inst: NixComponent, parent: Node, before: Node | null): () => void;
|
|
9
|
+
/**
|
|
10
|
+
* Same as `_mountComponent` but silently swallows all lifecycle errors.
|
|
11
|
+
* Used for transition content and error boundary fallbacks where errors
|
|
12
|
+
* inside the fallback/transition itself must not propagate.
|
|
13
|
+
*/
|
|
14
|
+
export declare function _mountComponentSilent(inst: NixComponent, parent: Node, before: Node | null): () => void;
|
|
15
|
+
/**
|
|
16
|
+
* Renders a NixComponent using a captured context snapshot.
|
|
17
|
+
* Used for dynamic/keyed rendering inside reactive effects, where the
|
|
18
|
+
* provide/inject context must be inherited from the point of declaration.
|
|
19
|
+
* Calls onMount immediately. Returns a full cleanup function.
|
|
20
|
+
*/
|
|
21
|
+
export declare function _mountComponentWithCtx(inst: NixComponent, parent: Node, before: Node | null, ctxSnapshot: ReturnType<typeof _captureContextSnapshot>): () => void;
|
|
22
|
+
/**
|
|
23
|
+
* Renders a NixComponent with *deferred* onMount — used inside `html` template
|
|
24
|
+
* fragments where the DOM nodes are still in a DocumentFragment and onMount must
|
|
25
|
+
* fire only after the fragment is inserted into the live document.
|
|
26
|
+
*
|
|
27
|
+
* Pushes the full cleanup into `disposes` and the onMount call into `postMountHooks`.
|
|
28
|
+
*/
|
|
29
|
+
export declare function _mountComponentDeferred(inst: NixComponent, parent: Node, before: Node | null, postMountHooks: Array<() => void>, disposes: Array<() => void>): void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Activates a reactive node binding at `anchor`.
|
|
3
|
+
* Handles: text, NixTemplate, NixComponent, KeyedList, Array, and static values.
|
|
4
|
+
* Pushes dispose functions into `disposes`.
|
|
5
|
+
*/
|
|
6
|
+
export declare function activateNodeBinding(anchor: Text, value: unknown, disposes: Array<() => void>, postMountHooks: Array<() => void>): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { NixComponent } from "../lifecycle";
|
|
2
|
+
import type { NixTemplate, NixRef, PortalOutlet } from "./types";
|
|
3
|
+
/** Creates a PortalOutlet token for decoupled portal targeting. */
|
|
4
|
+
export declare function createPortalOutlet(): PortalOutlet;
|
|
5
|
+
/** Declares the DOM anchor for a PortalOutlet inside a template. */
|
|
6
|
+
export declare function portalOutlet(outlet: PortalOutlet): NixTemplate;
|
|
7
|
+
/**
|
|
8
|
+
* Renders `content` into `target` instead of the current tree position.
|
|
9
|
+
* Useful for modals, tooltips, and overlays that must escape overflow clipping.
|
|
10
|
+
* Returns a NixTemplate — works inside reactive conditionals.
|
|
11
|
+
*
|
|
12
|
+
* @param content Template or component to render.
|
|
13
|
+
* @param target CSS selector, Element, PortalOutlet, or NixRef. Defaults to `document.body`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function portal(content: NixTemplate | NixComponent, target?: Element | string | PortalOutlet | NixRef<Element>): NixTemplate;
|
|
16
|
+
/** Provides a PortalOutlet to descendant components via dependency injection. */
|
|
17
|
+
export declare function provideOutlet(outlet: PortalOutlet): void;
|
|
18
|
+
/** Injects the nearest PortalOutlet provided by an ancestor. */
|
|
19
|
+
export declare function injectOutlet(): PortalOutlet | undefined;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { NixTemplate, TransitionContent } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Options for `transition()`. All class-name overrides are optional — by
|
|
4
|
+
* default they are derived from `name` (default `"nix"`).
|
|
5
|
+
*
|
|
6
|
+
* | phase | from class | active class | to class |
|
|
7
|
+
* |--------------|-------------------|---------------------|-----------------|
|
|
8
|
+
* | enter | `{n}-enter-from` | `{n}-enter-active` | `{n}-enter-to` |
|
|
9
|
+
* | leave | `{n}-leave-from` | `{n}-leave-active` | `{n}-leave-to` |
|
|
10
|
+
*/
|
|
11
|
+
export interface TransitionOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Prefix for all generated CSS classes. Default `"nix"`.
|
|
14
|
+
* e.g. `name: "fade"` generates `.fade-enter-from`, `.fade-leave-to`, …
|
|
15
|
+
*/
|
|
16
|
+
name?: string;
|
|
17
|
+
enterFrom?: string;
|
|
18
|
+
enterActive?: string;
|
|
19
|
+
enterTo?: string;
|
|
20
|
+
leaveFrom?: string;
|
|
21
|
+
leaveActive?: string;
|
|
22
|
+
leaveTo?: string;
|
|
23
|
+
/**
|
|
24
|
+
* When `true` the enter transition also plays on the very first render
|
|
25
|
+
* (similar to Vue's `appear`). Default `false`.
|
|
26
|
+
*/
|
|
27
|
+
appear?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Fallback duration in **milliseconds** used when no `transition-duration`
|
|
30
|
+
* or `animation-duration` is found on the element via `getComputedStyle`.
|
|
31
|
+
*/
|
|
32
|
+
duration?: number;
|
|
33
|
+
onBeforeEnter?: (el: Element) => void;
|
|
34
|
+
onAfterEnter?: (el: Element) => void;
|
|
35
|
+
onBeforeLeave?: (el: Element) => void;
|
|
36
|
+
onAfterLeave?: (el: Element) => void;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Wraps content with CSS class-based enter/leave transitions.
|
|
40
|
+
* Static content plays enter on mount (only with `appear: true`).
|
|
41
|
+
* Reactive `() => Template | null` auto-animates enter/leave on toggle.
|
|
42
|
+
*/
|
|
43
|
+
export declare function transition(content: TransitionContent, options?: TransitionOptions): NixTemplate;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export interface NixTemplate {
|
|
2
|
+
readonly __isNixTemplate: true;
|
|
3
|
+
/** Mounts the template into a container element (public / root API). */
|
|
4
|
+
mount(container: Element | string): NixMountHandle;
|
|
5
|
+
/** @internal Renders before `before` node (or appends to `parent`). Returns cleanup. */
|
|
6
|
+
_render(parent: Node, before: Node | null): () => void;
|
|
7
|
+
}
|
|
8
|
+
export interface NixMountHandle {
|
|
9
|
+
unmount(): void;
|
|
10
|
+
}
|
|
11
|
+
/** Direct reference to a DOM element, assigned on mount and cleared on unmount. */
|
|
12
|
+
export interface NixRef<T extends Element = Element> {
|
|
13
|
+
el: T | null;
|
|
14
|
+
}
|
|
15
|
+
/** Creates an empty `NixRef`. Use as `ref` attribute value in templates. */
|
|
16
|
+
export declare function ref<T extends Element = Element>(): NixRef<T>;
|
|
17
|
+
/** Keyed list result for efficient DOM diffing via `repeat()`. */
|
|
18
|
+
export interface KeyedList<T = unknown> {
|
|
19
|
+
readonly __isKeyedList: true;
|
|
20
|
+
readonly items: T[];
|
|
21
|
+
readonly keyFn: (item: T, index: number) => string | number;
|
|
22
|
+
readonly renderFn: (item: T, index: number) => NixTemplate | import("../lifecycle").NixComponent;
|
|
23
|
+
}
|
|
24
|
+
export interface KEntry {
|
|
25
|
+
start: Comment;
|
|
26
|
+
end: Comment;
|
|
27
|
+
cleanup: () => void;
|
|
28
|
+
}
|
|
29
|
+
/** Opaque token for a named portal target. */
|
|
30
|
+
export interface PortalOutlet {
|
|
31
|
+
readonly __isPortalOutlet: true;
|
|
32
|
+
/** @internal */
|
|
33
|
+
_container: Element | null;
|
|
34
|
+
}
|
|
35
|
+
/** Fallback: a static template/component, or a factory receiving the error. */
|
|
36
|
+
export type ErrorFallback = NixTemplate | import("../lifecycle").NixComponent | ((err: unknown) => NixTemplate | import("../lifecycle").NixComponent);
|
|
37
|
+
/** Content that can be wrapped with `transition()`. */
|
|
38
|
+
export type TransitionContent = NixTemplate | import("../lifecycle").NixComponent | (() => NixTemplate | import("../lifecycle").NixComponent | null);
|
|
39
|
+
export declare const COMMENT: {
|
|
40
|
+
readonly SCOPE: "nix-scope";
|
|
41
|
+
readonly ERROR_BOUNDARY: "nix-eb";
|
|
42
|
+
readonly TRANSITION: "nix-t";
|
|
43
|
+
readonly KEYED_START: "nix-ks";
|
|
44
|
+
readonly KEYED_END: "nix-ke";
|
|
45
|
+
readonly KEYED_ZONE: "nix-kz";
|
|
46
|
+
};
|
|
47
|
+
export declare function isNixTemplate(v: unknown): v is NixTemplate;
|
|
48
|
+
export declare function isKeyedList(v: unknown): v is KeyedList;
|
package/dist/lib/nix-js.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=[],t=[],n=null,r=null,i=null,a=[];function o(e){a.push(i),i=e}function s(){i=a.pop()??null}var c=0,l=new Set,u=[],d=100,f=0,p=[],m=0,h=class{_value;_subs=new Set;constructor(e){this._value=e}get value(){return n&&(this._subs.add(n),r?.add(this)),this._value}set value(e){Object.is(this._value,e)||(this._value=e,this._notify())}update(e){this.value=e(this._value)}peek(){return this._value}_removeSub(e){this._subs.delete(e)}_notify(){if(c>0){for(let e of this._subs)l.has(e)||(l.add(e),u.push(e));return}let e=m,t=0;for(let n of this._subs)p[e+t++]=n;m=e+t;try{for(let n=0;n<t;n++){let t=p[e+n];p[e+n]=null,t?.()}}finally{m=e}}dispose(){this._subs.clear()}};function g(e){return new h(e)}function _(l){let o,u=!1,a=new Set,s=new Set,c=i,p=()=>{if(u)return;"function"==typeof o&&o();let i=a;a=s,s=i,s.clear();let h=e.length>0?e.pop():{effect:null,deps:null};if(h.effect=n,h.deps=r,t.push(h),n=p,r=s,++f>d){f=0;let l=t.pop();throw n=l.effect,r=l.deps,l.effect=null,l.deps=null,e.push(l),Error("[Nix] Maximum effect re-execution depth exceeded (possible infinite loop).")}try{o=l()}catch(e){if(!c)throw e;c(e)}finally{f--;let l=t.pop();n=l.effect,r=l.deps,l.effect=null,l.deps=null,e.push(l);for(let e of a)s.has(e)||e._removeSub(p)}};return p(),()=>{u=!0,"function"==typeof o&&o();for(let e of s)e._removeSub(p);s.clear(),a.clear()}}function v(e){let t=new h(void 0),n=_(()=>{t.value=e()}),r=t.dispose;return t.dispose=()=>{n(),r.call(t)},t}function y(e){c++;try{e()}finally{if(0===--c&&u.length>0){let e=u.length;for(let t=0;t<e;t++)u[t]();u.length=0,l.clear()}}}function b(e){let t=n,l=r;n=null,r=null;try{return e()}finally{n=t,r=l}}function x(e,t,n={}){let r,{immediate:l=!1,once:o=!1}=n,i=e instanceof h?()=>e.value:e,u=!0,a=!1,s=_(()=>{let e=i();if(u){if(u=!1,l&&!a){let n=e;b(()=>t(n,void 0)),o&&(a=!0,Promise.resolve().then(s))}r=e}else if(!a){let n=e,l=r;r=e,b(()=>t(n,l)),o&&(a=!0,Promise.resolve().then(s))}});return()=>{a=!0,s()}}function S(e){return e?Promise.resolve().then(e):Promise.resolve()}var C=class{__isNixComponent=!0;children;_slots=new Map;setChildren(e){return this.children=e,this}setSlot(e,t){return this._slots.set(e,t),this}slot(e){return this._slots.get(e)}};function w(e){return"object"==typeof e&&!!e&&!0===e.__isNixComponent}function T(e){return Symbol(e)}var E=[];function ee(){return[...E]}function D(){E.push(new Map)}function O(){E.pop()}function te(e,t){let n=E.splice(0);e.forEach(e=>E.push(e)),E.push(new Map);try{return t()}finally{E.splice(0),n.forEach(e=>E.push(e))}}function k(e,t){let n=E[E.length-1];if(!n)throw Error("[Nix] provide() must be called inside onInit() of a NixComponent.");n.set(e,t)}function A(e){for(let t=E.length-1;t>=0;t--)if(E[t].has(e))return E[t].get(e)}var j={SCOPE:"nix-scope",ERROR_BOUNDARY:"nix-eb",TRANSITION:"nix-t",KEYED_START:"nix-ks",KEYED_END:"nix-ke",KEYED_ZONE:"nix-kz"};function ne(){return{el:null}}function re(e,t){t?"none"===e.style.display&&(e.style.display=""):"none"!==e.style.display&&(e.style.display="none")}function ie(e,t,n){return{__isKeyedList:!0,items:e,keyFn:t,renderFn:n}}function ae(e,t,n){let r,l;D();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}r=e.render()._render(t,n)}finally{O()}try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}r()}}function oe(e,t,n){let r,l;D();try{try{e.onInit?.()}catch{}r=e.render()._render(t,n)}finally{O()}try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch{}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}r()}}function M(e,t,n,r){let l,o;te(r,()=>{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}l=e.render()._render(t,n)});try{let t=e.onMount?.();"function"==typeof t&&(o=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{o?.()}catch{}l()}}function se(e,t,n,r,l){let o,i;D();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}o=e.render()._render(t,n)}finally{O()}r.push(()=>{try{let t=e.onMount?.();"function"==typeof t&&(i=t)}catch(t){if(!e.onError)throw t;e.onError(t)}}),l.push(()=>{try{e.onUnmount?.()}catch{}try{i?.()}catch{}o()})}function ce(){return{__isPortalOutlet:!0,_container:null}}function le(e){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(t,n){let r=document.createElement("div");return r.setAttribute("data-nix-outlet",""),e._container=r,t.insertBefore(r,n),()=>{e._container=null,r.remove()}}}}function ue(e,t=document.body){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let l;return l="string"==typeof t?document.querySelector(t)??document.body:t instanceof Element?t:"__isPortalOutlet"in t?t._container??document.body:t.el??document.body,w(e)?ae(e,l,null):e._render(l,null)}}}var de=T("nix:portal-outlet");function fe(e){k(de,e)}function pe(){return A(de)}function me(e,t){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let l=document.createComment(j.ERROR_BOUNDARY);n.insertBefore(l,r);let i,u=null,a=!1,c=!1,f=!1,d=e=>{let n=l.parentNode,o="function"!=typeof t||w(t)?t:t(e);u=w(o)?oe(o,n,r):o._render(n,r)};o(e=>{a||(a=!0,c?(u?.(),u=null,d(e)):(i=e,f=!0))});try{if(w(e)){D();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}u=e.render()._render(n,r)}finally{O()}if(!a)try{let t=e.onMount?.(),n=u;u=()=>{try{e.onUnmount?.()}catch{}if("function"==typeof t)try{t()}catch{}n?.()}}catch(t){if(!e.onError)throw t;e.onError(t)}}else u=e._render(n,r)}catch(e){a=!0,u?.(),u=null,i=e,f=!0}finally{s(),c=!0}return f&&(u?.(),u=null,d(i)),()=>{u?.(),l.remove()}}}}function he(e){let t=e.name??"nix";return{enterFrom:e.enterFrom??`${t}-enter-from`,enterActive:e.enterActive??`${t}-enter-active`,enterTo:e.enterTo??`${t}-enter-to`,leaveFrom:e.leaveFrom??`${t}-leave-from`,leaveActive:e.leaveActive??`${t}-leave-active`,leaveTo:e.leaveTo??`${t}-leave-to`}}function N(e){return Math.max(0,...e.split(",").map(e=>parseFloat(e.trim())||0))}function P(e,t=0){return new Promise(n=>{let r=getComputedStyle(e),l=1e3*Math.max(N(r.transitionDuration||"0"),N(r.animationDuration||"0")),o=l>0?l+100:t;if(o<=0)return void n();let i,u=t=>{t.target===e&&(clearTimeout(i),e.removeEventListener("transitionend",u),e.removeEventListener("animationend",u),n())};e.addEventListener("transitionend",u),e.addEventListener("animationend",u),i=setTimeout(()=>{e.removeEventListener("transitionend",u),e.removeEventListener("animationend",u),n()},o)})}function ge(e,t={}){let n=he(t);return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(r,l){let o=document.createComment(j.TRANSITION);r.insertBefore(o,l);let i=null,u=null,a=0,s=!0,c=()=>{let e=o.nextSibling;for(;e&&e!==l;){if(e.nodeType===Node.ELEMENT_NODE)return e;e=e.nextSibling}return null};function f(e){return w(e)?oe(e,r,l):e._render(r,l)}let d=(e,r=!1)=>{a++,u&&=(u(),null),i=f(e);let l=c();if(l&&(!s||t.appear)&&!r){let e=a;(async()=>{t.onBeforeEnter?.(l),l.classList.add(n.enterFrom,n.enterActive),l.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),a===e&&(l.classList.remove(n.enterFrom),l.classList.add(n.enterTo),await P(l,t.duration),a===e&&(l.classList.remove(n.enterActive,n.enterTo),t.onAfterEnter?.(l)))})().catch(()=>{})}s=!1},p=()=>{let e=i;i=null;let r=c();if(!r)return void e?.();let l=++a;u=e??null,(async()=>{t.onBeforeLeave?.(r),r.classList.add(n.leaveFrom,n.leaveActive),r.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),a===l&&(r.classList.remove(n.leaveFrom),r.classList.add(n.leaveTo),await P(r,t.duration),a===l&&(r.classList.remove(n.leaveActive,n.leaveTo),t.onAfterLeave?.(r),u?.(),u=null))})().catch(()=>{})},h=null;if("function"!=typeof e||w(e))d(e);else{let t=e,n=null;h=_(()=>{let e=t(),r=null===n,l=null===e;r&&!l?d(e):!r&&l?p():!r&&!l&&(a++,u?.(),u=null,i?.(),i=null,d(e,!0)),n=e}),s=!1}return()=>{a++,h?.(),i?.(),u?.(),i=null,u=null,o.remove()}}}}function _e(e){let t=e.lastIndexOf(">"),n=e.lastIndexOf("<");if(n<=t)return{type:"node"};let r=e.slice(n+1),l=r.lastIndexOf("=");if(-1===l)return{type:"node"};let o=r.endsWith('"')||r.endsWith("'")||'"'===r[r.length-1]||"'"===r[r.length-1],i=l-1;for(;i>=0&&/\S/.test(r[i]);)i--;i++;let u=r.slice(i,l);if("@"===u[0]){let e=u.slice(1).split(".");return{type:"event",eventName:e[0],modifiers:e.slice(1),hadOpenQuote:o}}return{type:"attr",attrName:u,hadOpenQuote:o}}function ve(e,t){let n=new Uint8Array(e.length),r="";for(let l=0;l<e.length;l++){let o=e[l];if(1===n[l]&&('"'===o[0]||"'"===o[0])&&(o=o.slice(1)),l<t.length){let e=t[l];if("node"===e.type)r+=o+`\x3c!--nix-${l}--\x3e`;else if("event"===e.type){let t=`@${e.modifiers.length?`${e.eventName}.${e.modifiers.join(".")}`:e.eventName}=`.length+(e.hadOpenQuote?1:0);r+=o.slice(0,-t)+` data-nix-e-${l}="${e.eventName}"`,e.hadOpenQuote&&(n[l+1]=1)}else{let t=`${e.attrName}=`.length+(e.hadOpenQuote?1:0);r+=o.slice(0,-t)+` data-nix-a-${l}="${e.attrName}"`,e.hadOpenQuote&&(n[l+1]=1)}}else r+=o}return r}function F(e){return"object"==typeof e&&!!e&&!0===e.__isNixTemplate}function ye(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}var be={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"},xe=new Set(["click","dblclick","mousedown","mouseup","keydown","keyup","input","change","submit"]),I=new Set;function Se(e,t,n){let r=e.target,l=e.stopPropagation,o=!1;for(e.stopPropagation=()=>{o=!0,l.call(e)};r&&r!==document;){let l=r[t];if(l){let t=r[n];if(t){if(t.includes("prevent")&&e.preventDefault(),t.includes("stop")&&e.stopPropagation(),t.includes("self")&&e.target!==r){r=r.parentNode;continue}if("key"in e){let n=e,l=!0;for(let e of t){let t=be[e];if(void 0!==t&&n.key!==t){l=!1;break}if(!t&&1===e.length&&n.key.toLowerCase()!==e){l=!1;break}}if(!l){r=r.parentNode;continue}}}if(l(e),o)break}r=r.parentNode}e.stopPropagation=l}var Ce=new Map,L=new Set,R=!1;function z(e){L.add(e),R||(R=!0,queueMicrotask(()=>{for(let e of L)e();L.clear(),R=!1}))}function we(e,t,n,r){let l=[],o=[],i=Array(t.length),u=-1;for(let e=0;e<t.length;e++)r[e]&&r[e].nodeIndex>u&&(u=r[e].nodeIndex);let a=Array(u+1);if(a[0]=e,u>0){let t,n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT),r=1;for(;r<=u&&(t=n.nextNode());)a[r++]=t}for(let e=0;e<t.length;e++){let t=r[e];i[e]=t?a[t.nodeIndex]:null}for(let e=0;e<t.length;e++){let u=t[e],a=n[e],s=r[e];if(!s)continue;let c=i[e];if("event"===u.type){let e=s.name,t=a,n=u.modifiers;if(!xe.has(e)||n.includes("capture")||n.includes("once")){let r={once:n.includes("once"),capture:n.includes("capture"),passive:n.includes("passive")},o=e=>{n.includes("prevent")&&e.preventDefault(),n.includes("stop")&&e.stopPropagation(),(!n.includes("self")||e.target===e.currentTarget)&&t(e)};c.addEventListener(e,o,r),l.push(()=>c.removeEventListener(e,o,r))}else{if(!I.has(e)){let t=`__nix_${e}`,n=`__nix_${e}_mods`,r=e=>Se(e,t,n);Ce.set(e,r),document.addEventListener(e,r),I.add(e)}let r=`__nix_${e}`,o=`__nix_${e}_mods`;c[r]=t,n.length>0&&(c[o]=n),l.push(()=>{c[r]=null,c[o]=null})}continue}if("attr"===u.type){let e=s.name,t=c;if("ref"===e){a.el=t,l.push(()=>{a.el=null});continue}if("show"===e||"hide"===e){let n=t,r=null;if("function"==typeof a){let t=!1,o=!1,i=!0,u=_(()=>{o=!!a();let l=()=>{t=!1;let l="show"===e?o:!o;null===r&&(r=n.style.display||""),n.style.display=l?r:"none"};i?(i=!1,l()):t||(t=!0,z(l))});l.push(u)}else("show"===e?a:!a)||(n.style.display="none");continue}let n=("value"===e||"checked"===e||"selected"===e)&&e in t;if("function"==typeof a){let r,o=!1,i=!0,u=_(()=>{r=a();let l=()=>{o=!1;let l=r;n?t[e]=l??"":null==l||!1===l?t.removeAttribute(e):t.setAttribute(e,String(l))};i?(i=!1,l()):o||(o=!0,z(l))});l.push(u)}else n?t[e]=a??"":null!=a&&!1!==a&&t.setAttribute(e,String(a));continue}let f=c;if(!f)continue;let d=document.createTextNode("");if(f.parentNode.replaceChild(d,f),"function"!=typeof a){if(w(a))se(a,d.parentNode,d,o,l);else if(F(a)){let e=a._render(d.parentNode,d);l.push(e)}else if(Array.isArray(a))for(let e of a)w(e)?se(e,d.parentNode,d,o,l):F(e)?e._render(d.parentNode,d):null!=e&&!1!==e&&d.parentNode.insertBefore(document.createTextNode(String(e)),d);else null!=a&&!1!==a&&d.parentNode.insertBefore(document.createTextNode(String(a)),d);continue}let p=null,h=null,v=null,m=[],g=null,x=ee(),b=!1,E="",N=!0,S=_(()=>{let e=a();if("string"==typeof e||"number"==typeof e){E=String(e);let t=()=>{b=!1,h&&=(h(),null),p?p.nodeValue=E:(p=document.createTextNode(E),d.parentNode.insertBefore(p,d))};return void(N?(N=!1,t()):b||(b=!0,z(t)))}if(b=!1,N=!1,p&&=(p.parentNode?.removeChild(p),null),h&&=(h(),null),null!=e&&!1!==e)if(F(e))h=e._render(d.parentNode,d);else if(w(e))h=M(e,d.parentNode,d,x);else if(ye(e)){v||(v=new Map,g=document.createTextNode(""),d.parentNode.insertBefore(g,d));let t=d.parentNode,n=e.items.map((t,n)=>e.keyFn(t,n)),r=new Set(n),l=!1;if(v.size>0)for(let e of v.keys())if(r.has(e)){l=!0;break}if(!l){if(v.size>0){let e=document.createRange();e.setStartAfter(g),e.setEndBefore(d),e.deleteContents();for(let e of v.values())e.cleanup();v.clear()}if(n.length>0){let r=document.createDocumentFragment();y(()=>{for(let t=0;t<n.length;t++){let l=n[t],o=e.items[t],i=document.createTextNode(""),u=document.createTextNode("");r.appendChild(i),r.appendChild(u);let a=e.renderFn(o,t),s=w(a)?M(a,r,u,x):a._render(r,u);v?.set(l,{start:i,end:u,cleanup:s})}}),t.insertBefore(r,d)}return void(m=n)}let o=new Map;for(let e=0;e<n.length;e++)o.set(n[e],e);let i=new Int32Array(n.length),u=!1,a=0;for(let e=0;e<m.length;e++){let t=m[e],n=o.get(t);if(void 0===n){let e=v.get(t);e.cleanup();let n=e.start;for(;n;){let t=n===e.end?null:n.nextSibling;if(n.parentNode?.removeChild(n),!t)break;n=t}v.delete(t)}else i[n]=e+1,n>=a?a=n:u=!0}let s=u?Te(i):[],c=s.length-1,f=d;for(let r=n.length-1;r>=0;r--){let l=n[r];if(0===i[r]){let n=e.items[r],o=document.createTextNode(""),i=document.createTextNode(""),u=document.createDocumentFragment();u.appendChild(o),u.appendChild(i);let a=e.renderFn(n,r),s=w(a)?M(a,u,i,x):a._render(u,i);v.set(l,{start:o,end:i,cleanup:s}),t.insertBefore(u,f),f=o}else{let e=v.get(l);if(u)if(c<0||r!==s[c]){let n=e.start;for(;n;){let r=n===e.end?null:n.nextSibling;if(t.insertBefore(n,f),!r)break;n=r}}else c--;f=e.start}}m=n}else if(Array.isArray(e)){let t=[];for(let n of e)if(w(n))t.push(ae(n,d.parentNode,d));else if(F(n))t.push(n._render(d.parentNode,d));else if(null!=n&&!1!==n){let e=document.createTextNode(String(n));d.parentNode.insertBefore(e,d),t.push(()=>e.parentNode?.removeChild(e))}h=()=>t.forEach(e=>e())}else p=document.createTextNode(String(e)),d.parentNode.insertBefore(p,d)});l.push(()=>{if(S(),h&&=(h(),null),p&&=(p.parentNode?.removeChild(p),null),v){for(let e of v.values())e.cleanup();v=null,g=null}})}return{disposes:l,postMountHooks:o}}function Te(e){let t,n,r,l,o,i=e.slice(),u=[0],a=e.length;for(t=0;t<a;t++){let a=e[t];if(0!==a){if(n=u[u.length-1],e[n]<a){i[t]=n,u.push(t);continue}for(r=0,l=u.length-1;r<l;)o=r+l>>1,e[u[o]]<a?r=o+1:l=o;a<e[u[r]]&&(r>0&&(i[t]=u[r-1]),u[r]=t)}}for(r=u.length,l=u[r-1];r-- >0;)u[r]=l,l=i[l];return u}var Ee=new WeakMap;function B(e,...t){let n=Ee.get(e);if(!n){let t=[],r="";for(let n=0;n<e.length-1;n++)r+=e[n],t.push(_e(r)),r+="__nix__";let l=document.createElement("template");l.innerHTML=ve(e,t);let o,i=Array(t.length).fill(null),u=l.content,a=document.createTreeWalker(u,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT),s=0;for(;o=a.nextNode();)if(s++,8===o.nodeType){let e=o.nodeValue;if(e&&e.startsWith("nix-")){let t=parseInt(e.slice(4),10);isNaN(t)||(i[t]={nodeIndex:s})}}else if(1===o.nodeType){let e=o,t=Array.from(e.attributes);for(let n=0;n<t.length;n++){let r=t[n],l=r.name;if(l.startsWith("data-nix-e-")){let t=parseInt(l.slice(11),10);isNaN(t)||(i[t]={nodeIndex:s,name:r.value},e.removeAttribute(l));continue}if(l.startsWith("data-nix-a-")){let t=parseInt(l.slice(11),10);isNaN(t)||(i[t]={nodeIndex:s,name:r.value},e.removeAttribute(l))}}}n={contexts:t,tpl:l,pathMap:i},Ee.set(e,n)}let{contexts:r,tpl:l,pathMap:o}=n;function i(e,n){let i=l.content.cloneNode(!0),{disposes:u,postMountHooks:a}=we(i,r,t,o),s=document.createTextNode("");return e.insertBefore(s,n),e.insertBefore(i,n),a.forEach(e=>e()),()=>{for(let e=u.length-1;e>=0;e--)u[e]();let e=s.nextSibling;for(;e&&e!==n;){let t=e.nextSibling;e.parentNode?.removeChild(e),e=t}s.parentNode?.removeChild(s)}}return{__isNixTemplate:!0,_render:i,mount(e){let t="string"==typeof e?document.querySelector(e):e;if(!t)throw Error(`[Nix] mount: contenedor no encontrado: ${e}`);let n=i(t,null);return{unmount(){n()}}}}}function De(e,t){if(w(e)){let n,r,l="string"==typeof t?document.querySelector(t):t;if(!l)throw Error(`[Nix] mount: container not found: ${t}`);D();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(l,null)}finally{O()}try{let t=e.onMount?.();"function"==typeof t&&(r=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return{unmount(){try{e.onUnmount?.()}catch{}try{r?.()}catch{}n()}}}return e.mount(t)}function Oe(e,t){let n={},r=new Set(["$reset","$patch","$state"]);for(let t of Object.keys(e)){if(r.has(t))throw Error(`[Nix] Store key "${t}" is reserved.`);n[t]=g(e[t])}let l=n;let o=Object.assign(Object.create(null),l,{$reset:function(){for(let t of Object.keys(e))n[t].value=e[t]},$patch:function(e){for(let t of Object.keys(e))t in n&&(n[t].value=e[t])}});if(Object.defineProperty(o,"$state",{get(){let e={};for(let t in n)e[t]=n[t].value;return e},enumerable:!0,configurable:!1}),t){let e=t(l);for(let t of Object.keys(e))r.has(t)?console.warn(`[Nix] Store action name "${t}" is reserved and will be ignored.`):o[t]=e[t]}return o}var V=null,H=null;function U(){if(!V)throw Error("[Nix] No active router. Call createRouter() first.");return V}function W(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function ke(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))null!=r&&!1!==r&&t.set(n,String(r));let n=t.toString();return n?"?"+n:""}function Ae(e){return"*"===e?[{kind:"wildcard"}]:e.split("/").filter(Boolean).map(e=>"*"===e?{kind:"wildcard"}:e.startsWith(":")?{kind:"param",name:e.slice(1)}:{kind:"literal",value:e})}function je(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function Me(e,t="",n=[]){let r=[];for(let l of e){let e=je(t,l.path),o=[...n,l.component],i=Ae(e);r.push({fullPath:e,segments:i,chain:o,beforeEnter:l.beforeEnter}),l.children?.length&&r.push(...Me(l.children,e,o))}return r}function Ne(e,t){let n=e.split("/").filter(Boolean),r=t.segments;if(1===r.length&&"wildcard"===r[0].kind)return{};let l=r.length>0&&"wildcard"===r[r.length-1].kind,o=l?r.slice(0,-1):r;if(l){if(n.length<o.length)return null}else if(n.length!==o.length)return null;let i={};for(let e=0;e<o.length;e++){let t=o[e];if("literal"===t.kind){if(n[e]!==t.value)return null}else if("param"===t.kind)try{i[t.name]=decodeURIComponent(n[e]??"")}catch{i[t.name]=n[e]??""}}return i}function Pe(e){return e.segments.reduce((e,t)=>"literal"===t.kind?e+2:"param"===t.kind?e+1:e,0)}function G(e,t){let n,r={},l=-1;for(let o of t){let t=Ne(e,o);if(null===t)continue;let i=Pe(o);i>l&&(n=o,r=t,l=i)}return n?{route:n,params:r}:void 0}function K(e){let t=e.trim();return t&&"/"!==t?(t.startsWith("/")||(t="/"+t),t.endsWith("/")&&(t=t.slice(0,-1)),t):""}function Fe(){if(typeof document>"u")return"";let e=document.querySelector("base");if(!e)return"";let t=e.getAttribute("href")||"";try{return K(new URL(t,window.location.origin).pathname)}catch{return K(t)}}function Ie(e,t){let n=null==t?.base?Fe():K(t.base);function r(){let e=window.location.pathname||"/";if(n&&e.startsWith(n)){let t=e.slice(n.length);return""===t?"/":t}return e}function l(e){return n?n+(e.startsWith("/")?e:"/"+e):e}let o=r(),i=Me(e),u=G(o,i),a=g(o),s=g(u?.params??{}),c=g(W(window.location.search)),f=[],d=[],p=0;function h(e,t,n,r,l){let o=[...f];n&&o.push(n);let i=++p;if(0===o.length)return void r();let u=0;!function n(a){if(i!==p)return;if(!1===a)return void l?.();if("string"==typeof a)return void(a===e?r():_(a));if(u>=o.length)return void r();let s=o[u++](e,t);s instanceof Promise?s.then(n):n(s)}(void 0)}let v=!1;function m(e,t){let n=e.indexOf("?"),r=-1===n?e:e.slice(0,n),l=-1===n?{}:W(e.slice(n)),o=t?{...l,...t}:l,i={};for(let[e,t]of Object.entries(o))null!=t&&!1!==t&&(i[e]=String(t));return{pathname:r,stringQuery:i}}H&&=(H(),null);let y=()=>{let e=r(),t=a.value,n=c.value,o=G(e,i),u=W(window.location.search);h(e,t,o?.route.beforeEnter,()=>{s.value=o?.params??{},c.value=u,a.value=e;for(let n of d)try{n(e,t)}catch{}},()=>{history.pushState(null,"",l(t)+ke(n))})};function x(e,t,n,r,o){s.value=r?.params??{},c.value=t,a.value=e;let i=l(e)+ke(t);o?history.replaceState(null,"",i):history.pushState(null,"",i);for(let t of d)try{t(e,n)}catch{}}function _(e,t){v=!0;let{pathname:n,stringQuery:r}=m(e,t),l=a.value,o=G(n,i);h(n,l,o?.route.beforeEnter,()=>x(n,r,l,o,!1))}window.addEventListener("popstate",y),H=()=>window.removeEventListener("popstate",y);let b={current:a,params:s,query:c,base:n||"/",navigate:_,replace:function(e,t){v=!0;let{pathname:n,stringQuery:r}=m(e,t),l=a.value,o=G(n,i);h(n,l,o?.route.beforeEnter,()=>x(n,r,l,o,!0))},back:function(){history.back()},forward:function(){history.forward()},go:function(e){history.go(e)},isActive:function(e,t=!0){let n=a.value;return t?n===e:n===e||n.startsWith(e.endsWith("/")?e:e+"/")},resolve:function(t){let n=G(t,i);if(!n)return{matched:!1,params:{},route:void 0};let r=n.route.chain[n.route.chain.length-1];return{matched:!0,params:n.params,route:function e(t){for(let n of t){if(n.component===r)return n;if(n.children){let t=e(n.children);if(t)return t}}}(e)}},beforeEach:function(e){return f.push(e),()=>{let t=f.indexOf(e);-1!==t&&f.splice(t,1)}},afterEach:function(e){return d.push(e),()=>{let t=d.indexOf(e);-1!==t&&d.splice(t,1)}},routes:e,_flat:i,_guards:f,_base:n};return V&&console.warn("[Nix] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."),V=b,queueMicrotask(()=>{v||h(o,"",G(o,i)?.route.beforeEnter,()=>{},()=>{history.replaceState(null,"",l("/"));let e=G("/",i);a.value="/",s.value=e?.params??{},c.value={}})}),b}function Le(){return U()}var Re=class extends C{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return B`<div class="router-view">${()=>{let t=U(),n=G(t.current.value,t._flat);return n?e>=n.route.chain.length?B`<span></span>`:n.route.chain[e]():B`<div style="color:#f87171;padding:16px 0">
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=[],t=[],n=null,r=null,i=null,a=[];function o(e){a.push(i),i=e}function s(){i=a.pop()??null}var c=0,l=new Set,u=[],d=100,f=0,p=[],m=0,h=class{_value;_subs=new Set;constructor(e){this._value=e}get value(){return n&&(this._subs.add(n),r?.add(this)),this._value}set value(e){Object.is(this._value,e)||(this._value=e,this._notify())}update(e){this.value=e(this._value)}peek(){return this._value}_removeSub(e){this._subs.delete(e)}_notify(){if(c>0){for(let e of this._subs)l.has(e)||(l.add(e),u.push(e));return}let e=m,t=0;for(let n of this._subs)p[e+t++]=n;m=e+t;try{for(let n=0;n<t;n++){let t=p[e+n];p[e+n]=null,t?.()}}finally{m=e}}dispose(){this._subs.clear()}};function g(e){return new h(e)}function _(l){let o,u=!1,a=new Set,s=new Set,c=i,p=()=>{if(u)return;"function"==typeof o&&o();let i=a;a=s,s=i,s.clear();let h=e.length>0?e.pop():{effect:null,deps:null};if(h.effect=n,h.deps=r,t.push(h),n=p,r=s,++f>d){f=0;let l=t.pop();throw n=l.effect,r=l.deps,l.effect=null,l.deps=null,e.push(l),Error("[Nix] Maximum effect re-execution depth exceeded (possible infinite loop).")}try{o=l()}catch(e){if(!c)throw e;c(e)}finally{f--;let l=t.pop();n=l.effect,r=l.deps,l.effect=null,l.deps=null,e.push(l);for(let e of a)s.has(e)||e._removeSub(p)}};return p(),()=>{u=!0,"function"==typeof o&&o();for(let e of s)e._removeSub(p);s.clear(),a.clear()}}function v(e){let t=new h(void 0),n=_(()=>{t.value=e()}),r=t.dispose;return t.dispose=()=>{n(),r.call(t)},t}function y(e){c++;try{e()}finally{if(0===--c&&u.length>0){let e=u.length;for(let t=0;t<e;t++)u[t]();u.length=0,l.clear()}}}function b(e){let t=n,l=r;n=null,r=null;try{return e()}finally{n=t,r=l}}function x(e,t,n={}){let r,{immediate:l=!1,once:o=!1}=n,i=e instanceof h?()=>e.value:e,u=!0,a=!1,s=_(()=>{let e=i();if(u){if(u=!1,l&&!a){let n=e;b(()=>t(n,void 0)),o&&(a=!0,Promise.resolve().then(s))}r=e}else if(!a){let n=e,l=r;r=e,b(()=>t(n,l)),o&&(a=!0,Promise.resolve().then(s))}});return()=>{a=!0,s()}}function ee(e){return e?Promise.resolve().then(e):Promise.resolve()}function te(){return{el:null}}const S={SCOPE:"nix-scope",ERROR_BOUNDARY:"nix-eb",TRANSITION:"nix-t",KEYED_START:"nix-ks",KEYED_END:"nix-ke",KEYED_ZONE:"nix-kz"};function C(e){return"object"==typeof e&&!!e&&!0===e.__isNixTemplate}function ne(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}var w=class{__isNixComponent=!0;children;_slots=new Map;setChildren(e){return this.children=e,this}setSlot(e,t){return this._slots.set(e,t),this}slot(e){return this._slots.get(e)}};function T(e){return"object"==typeof e&&!!e&&!0===e.__isNixComponent}function E(e){return Symbol(e)}var D=[];function re(){return[...D]}function O(){D.push(new Map)}function k(){D.pop()}function ie(e,t){let n=D.splice(0);e.forEach(e=>D.push(e)),D.push(new Map);try{return t()}finally{D.splice(0),n.forEach(e=>D.push(e))}}function ae(e,t){let n=D[D.length-1];if(!n)throw Error("[Nix] provide() must be called inside onInit() of a NixComponent.");n.set(e,t)}function oe(e){for(let t=D.length-1;t>=0;t--)if(D[t].has(e))return D[t].get(e)}function se(e,t,n){let r,l;O();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}r=e.render()._render(t,n)}finally{k()}try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}r()}}function ce(e,t,n){let r,l;O();try{try{e.onInit?.()}catch{}r=e.render()._render(t,n)}finally{k()}try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch{}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}r()}}function A(e,t,n,r){let l,o;ie(r,()=>{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}l=e.render()._render(t,n)});try{let t=e.onMount?.();"function"==typeof t&&(o=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{o?.()}catch{}l()}}function le(e,t,n,r,l){let o,i;O();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}o=e.render()._render(t,n)}finally{k()}r.push(()=>{try{let t=e.onMount?.();"function"==typeof t&&(i=t)}catch(t){if(!e.onError)throw t;e.onError(t)}}),l.push(()=>{try{e.onUnmount?.()}catch{}try{i?.()}catch{}o()})}function ue(e,t,n){return{__isKeyedList:!0,items:e,keyFn:t,renderFn:n}}function de(e){let t,n,r,l,o,i=e.slice(),u=[0],a=e.length;for(t=0;t<a;t++){let a=e[t];if(0!==a){if(n=u[u.length-1],e[n]<a){i[t]=n,u.push(t);continue}for(r=0,l=u.length-1;r<l;)o=r+l>>1,e[u[o]]<a?r=o+1:l=o;a<e[u[r]]&&(r>0&&(i[t]=u[r-1]),u[r]=t)}}for(r=u.length,l=u[r-1];r-- >0;)u[r]=l,l=i[l];return u}var j=new Set,M=!1;function N(e){j.add(e),M||(M=!0,queueMicrotask(()=>{for(let e of j)e();j.clear(),M=!1}))}function fe(e,t,n,r){if("function"!=typeof t){if(T(t))le(t,e.parentNode,e,r,n);else if(C(t))n.push(t._render(e.parentNode,e));else if(Array.isArray(t))for(let l of t)T(l)?le(l,e.parentNode,e,r,n):C(l)?l._render(e.parentNode,e):null!=l&&!1!==l&&e.parentNode.insertBefore(document.createTextNode(String(l)),e);else null!=t&&!1!==t&&e.parentNode.insertBefore(document.createTextNode(String(t)),e);return}let l=null,o=null,i=null,u=[],a=null,s=re(),c=!1,f="",d=!0,p=_(()=>{let n=t();if("string"==typeof n||"number"==typeof n){f=String(n);let t=()=>{c=!1,o&&=(o(),null),l?l.nodeValue=f:(l=document.createTextNode(f),e.parentNode.insertBefore(l,e))};return void(d?(d=!1,t()):c||(c=!0,N(t)))}if(c=!1,d=!1,l&&=(l.parentNode?.removeChild(l),null),o&&=(o(),null),null!=n&&!1!==n)if(C(n))o=n._render(e.parentNode,e);else if(T(n))o=A(n,e.parentNode,e,s);else if(ne(n)){i||(i=new Map,a=document.createTextNode(""),e.parentNode.insertBefore(a,e));let t=e.parentNode,r=n.items.map((e,t)=>n.keyFn(e,t)),l=new Set(r),o=!1;if(i.size>0)for(let e of i.keys())if(l.has(e)){o=!0;break}if(!o){if(i.size>0){let t=document.createRange();t.setStartAfter(a),t.setEndBefore(e),t.deleteContents();for(let e of i.values())e.cleanup();i.clear()}if(r.length>0){let l=document.createDocumentFragment();y(()=>{for(let e=0;e<r.length;e++){let t=r[e],o=n.items[e],u=document.createTextNode(""),a=document.createTextNode("");l.appendChild(u),l.appendChild(a);let c=n.renderFn(o,e),f=T(c)?A(c,l,a,s):c._render(l,a);i?.set(t,{start:u,end:a,cleanup:f})}}),t.insertBefore(l,e)}return void(u=r)}let c=new Map;for(let e=0;e<r.length;e++)c.set(r[e],e);let f=new Int32Array(r.length),d=!1,p=0;for(let e=0;e<u.length;e++){let t=u[e],n=c.get(t);if(void 0===n){let e=i.get(t);e.cleanup();let n=e.start;for(;n;){let t=n===e.end?null:n.nextSibling;if(n.parentNode?.removeChild(n),!t)break;n=t}i.delete(t)}else f[n]=e+1,n>=p?p=n:d=!0}let h=d?de(f):[],v=h.length-1,m=e;for(let e=r.length-1;e>=0;e--){let l=r[e];if(0===f[e]){let r=n.items[e],o=document.createTextNode(""),u=document.createTextNode(""),a=document.createDocumentFragment();a.appendChild(o),a.appendChild(u);let c=n.renderFn(r,e),f=T(c)?A(c,a,u,s):c._render(a,u);i.set(l,{start:o,end:u,cleanup:f}),t.insertBefore(a,m),m=o}else{let n=i.get(l);if(d)if(v<0||e!==h[v]){let e=n.start;for(;e;){let r=e===n.end?null:e.nextSibling;if(t.insertBefore(e,m),!r)break;e=r}}else v--;m=n.start}}u=r}else if(Array.isArray(n)){let t=[];for(let r of n)if(T(r))t.push(se(r,e.parentNode,e));else if(C(r))t.push(r._render(e.parentNode,e));else if(null!=r&&!1!==r){let n=document.createTextNode(String(r));e.parentNode.insertBefore(n,e),t.push(()=>n.parentNode?.removeChild(n))}o=()=>t.forEach(e=>e())}else l=document.createTextNode(String(n)),e.parentNode.insertBefore(l,e)});n.push(()=>{if(p(),o&&=(o(),null),l&&=(l.parentNode?.removeChild(l),null),i){for(let e of i.values())e.cleanup();i=null,a=null}})}function pe(e,t){t?"none"===e.style.display&&(e.style.display=""):"none"!==e.style.display&&(e.style.display="none")}function me(e){let t=e.lastIndexOf(">"),n=e.lastIndexOf("<");if(n<=t)return{type:"node"};let r=e.slice(n+1),l=r.lastIndexOf("=");if(-1===l)return{type:"node"};let o=r.endsWith('"')||r.endsWith("'")||'"'===r[r.length-1]||"'"===r[r.length-1],i=l-1;for(;i>=0&&/\S/.test(r[i]);)i--;i++;let u=r.slice(i,l);if("@"===u[0]){let e=u.slice(1).split(".");return{type:"event",eventName:e[0],modifiers:e.slice(1),hadOpenQuote:o}}return{type:"attr",attrName:u,hadOpenQuote:o}}var he={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"},ge=new Set(["click","dblclick","mousedown","mouseup","keydown","keyup","input","change","submit"]),P=new Set;function _e(e,t,n){let r=e.target,l=e.stopPropagation,o=!1;for(e.stopPropagation=()=>{o=!0,l.call(e)};r&&r!==document;){let l=r[t];if(l){let t=r[n];if(t){if(t.includes("prevent")&&e.preventDefault(),t.includes("stop")&&e.stopPropagation(),t.includes("self")&&e.target!==r){r=r.parentNode;continue}if("key"in e){let n=e,l=!0;for(let e of t){let t=he[e];if(void 0!==t&&n.key!==t){l=!1;break}if(!t&&1===e.length&&n.key.toLowerCase()!==e){l=!1;break}}if(!l){r=r.parentNode;continue}}}if(l(e),o)break}r=r.parentNode}e.stopPropagation=l}var ve=new Map;function ye(e,t,n,r){let l=[],o=[],i=Array(t.length),u=-1;for(let e=0;e<t.length;e++)r[e]&&r[e].nodeIndex>u&&(u=r[e].nodeIndex);let a=Array(u+1);if(a[0]=e,u>0){let t,n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT),r=1;for(;r<=u&&(t=n.nextNode());)a[r++]=t}for(let e=0;e<t.length;e++){let t=r[e];i[e]=t?a[t.nodeIndex]:null}for(let e=0;e<t.length;e++){let u=t[e],a=n[e],s=r[e];if(!s)continue;let c=i[e];if("event"===u.type){let e=s.name,t=a,n=u.modifiers;if(!ge.has(e)||n.includes("capture")||n.includes("once")){let r={once:n.includes("once"),capture:n.includes("capture"),passive:n.includes("passive")},o=e=>{n.includes("prevent")&&e.preventDefault(),n.includes("stop")&&e.stopPropagation(),(!n.includes("self")||e.target===e.currentTarget)&&t(e)};c.addEventListener(e,o,r),l.push(()=>c.removeEventListener(e,o,r))}else{if(!P.has(e)){let t=`__nix_${e}`,n=`__nix_${e}_mods`,r=e=>_e(e,t,n);ve.set(e,r),document.addEventListener(e,r),P.add(e)}let r=`__nix_${e}`,o=`__nix_${e}_mods`;c[r]=t,n.length>0&&(c[o]=n),l.push(()=>{c[r]=null,c[o]=null})}continue}if("attr"===u.type){let e=s.name,t=c;if("ref"===e){a.el=t,l.push(()=>{a.el=null});continue}if("show"===e||"hide"===e){let n=t,r=null;if("function"==typeof a){let t=!1,o=!1,i=!0,u=_(()=>{o=!!a();let l=()=>{t=!1;let l="show"===e?o:!o;null===r&&(r=n.style.display||""),n.style.display=l?r:"none"};i?(i=!1,l()):t||(t=!0,N(l))});l.push(u)}else("show"===e?a:!a)||(n.style.display="none");continue}let n=("value"===e||"checked"===e||"selected"===e)&&e in t;if("function"==typeof a){let r,o=!1,i=!0,u=_(()=>{r=a();let l=()=>{o=!1;let l=r;n?t[e]=l??"":null==l||!1===l?t.removeAttribute(e):t.setAttribute(e,String(l))};i?(i=!1,l()):o||(o=!0,N(l))});l.push(u)}else n?t[e]=a??"":null!=a&&!1!==a&&t.setAttribute(e,String(a));continue}let f=c;if(!f)continue;let d=document.createTextNode("");f.parentNode.replaceChild(d,f),fe(d,a,l,o)}return{disposes:l,postMountHooks:o}}function be(e,t){let n=new Uint8Array(e.length),r="";for(let l=0;l<e.length;l++){let o=e[l];if(1===n[l]&&('"'===o[0]||"'"===o[0])&&(o=o.slice(1)),l<t.length){let e=t[l];if("node"===e.type)r+=o+`\x3c!--nix-${l}--\x3e`;else if("event"===e.type){let t=`@${e.modifiers.length?`${e.eventName}.${e.modifiers.join(".")}`:e.eventName}=`.length+(e.hadOpenQuote?1:0);r+=o.slice(0,-t)+` data-nix-e-${l}="${e.eventName}"`,e.hadOpenQuote&&(n[l+1]=1)}else{let t=`${e.attrName}=`.length+(e.hadOpenQuote?1:0);r+=o.slice(0,-t)+` data-nix-a-${l}="${e.attrName}"`,e.hadOpenQuote&&(n[l+1]=1)}}else r+=o}return r}var F=new WeakMap;function I(e,...t){let n=F.get(e);if(!n){let t=[],r="";for(let n=0;n<e.length-1;n++)r+=e[n],t.push(me(r)),r+="__nix__";let l=document.createElement("template");l.innerHTML=be(e,t);let o,i=Array(t.length).fill(null),u=l.content,a=document.createTreeWalker(u,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT),s=0;for(;o=a.nextNode();)if(s++,8===o.nodeType){let e=o.nodeValue;if(e&&e.startsWith("nix-")){let t=parseInt(e.slice(4),10);isNaN(t)||(i[t]={nodeIndex:s})}}else if(1===o.nodeType){let e=o,t=Array.from(e.attributes);for(let n=0;n<t.length;n++){let r=t[n],l=r.name;if(l.startsWith("data-nix-e-")){let t=parseInt(l.slice(11),10);isNaN(t)||(i[t]={nodeIndex:s,name:r.value},e.removeAttribute(l));continue}if(l.startsWith("data-nix-a-")){let t=parseInt(l.slice(11),10);isNaN(t)||(i[t]={nodeIndex:s,name:r.value},e.removeAttribute(l))}}}n={contexts:t,tpl:l,pathMap:i},F.set(e,n)}let{contexts:r,tpl:l,pathMap:o}=n;function i(e,n){let i=l.content.cloneNode(!0),{disposes:u,postMountHooks:a}=ye(i,r,t,o),s=document.createTextNode("");return e.insertBefore(s,n),e.insertBefore(i,n),a.forEach(e=>e()),()=>{for(let e=u.length-1;e>=0;e--)u[e]();let e=s.nextSibling;for(;e&&e!==n;){let t=e.nextSibling;e.parentNode?.removeChild(e),e=t}s.parentNode?.removeChild(s)}}return{__isNixTemplate:!0,_render:i,mount(e){let t="string"==typeof e?document.querySelector(e):e;if(!t)throw Error(`[Nix] mount: contenedor no encontrado: ${e}`);let n=i(t,null);return{unmount(){n()}}}}}function xe(e){let t=e.name??"nix";return{enterFrom:e.enterFrom??`${t}-enter-from`,enterActive:e.enterActive??`${t}-enter-active`,enterTo:e.enterTo??`${t}-enter-to`,leaveFrom:e.leaveFrom??`${t}-leave-from`,leaveActive:e.leaveActive??`${t}-leave-active`,leaveTo:e.leaveTo??`${t}-leave-to`}}function L(e){return Math.max(0,...e.split(",").map(e=>parseFloat(e.trim())||0))}function R(e,t=0){return new Promise(n=>{let r=getComputedStyle(e),l=1e3*Math.max(L(r.transitionDuration||"0"),L(r.animationDuration||"0")),o=l>0?l+100:t;if(o<=0)return void n();let i,u=t=>{t.target===e&&(clearTimeout(i),e.removeEventListener("transitionend",u),e.removeEventListener("animationend",u),n())};e.addEventListener("transitionend",u),e.addEventListener("animationend",u),i=setTimeout(()=>{e.removeEventListener("transitionend",u),e.removeEventListener("animationend",u),n()},o)})}function Se(e,t={}){let n=xe(t);return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(r,l){let o=document.createComment(S.TRANSITION);r.insertBefore(o,l);let i=null,u=null,a=0,s=!0,c=()=>{let e=o.nextSibling;for(;e&&e!==l;){if(e.nodeType===Node.ELEMENT_NODE)return e;e=e.nextSibling}return null};function f(e){return T(e)?ce(e,r,l):e._render(r,l)}let d=(e,r=!1)=>{a++,u&&=(u(),null),i=f(e);let l=c();if(l&&(!s||t.appear)&&!r){let e=a;(async()=>{t.onBeforeEnter?.(l),l.classList.add(n.enterFrom,n.enterActive),l.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),a===e&&(l.classList.remove(n.enterFrom),l.classList.add(n.enterTo),await R(l,t.duration),a===e&&(l.classList.remove(n.enterActive,n.enterTo),t.onAfterEnter?.(l)))})().catch(()=>{})}s=!1},p=()=>{let e=i;i=null;let r=c();if(!r)return void e?.();let l=++a;u=e??null,(async()=>{t.onBeforeLeave?.(r),r.classList.add(n.leaveFrom,n.leaveActive),r.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),a===l&&(r.classList.remove(n.leaveFrom),r.classList.add(n.leaveTo),await R(r,t.duration),a===l&&(r.classList.remove(n.leaveActive,n.leaveTo),t.onAfterLeave?.(r),u?.(),u=null))})().catch(()=>{})},h=null;if("function"!=typeof e||T(e))d(e);else{let t=e,n=null;h=_(()=>{let e=t(),r=null===n,l=null===e;r&&!l?d(e):!r&&l?p():!r&&!l&&(a++,u?.(),u=null,i?.(),i=null,d(e,!0)),n=e}),s=!1}return()=>{a++,h?.(),i?.(),u?.(),i=null,u=null,o.remove()}}}}function Ce(){return{__isPortalOutlet:!0,_container:null}}function we(e){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(t,n){let r=document.createElement("div");return r.setAttribute("data-nix-outlet",""),e._container=r,t.insertBefore(r,n),()=>{e._container=null,r.remove()}}}}function Te(e,t=document.body){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let l;return l="string"==typeof t?document.querySelector(t)??document.body:t instanceof Element?t:"__isPortalOutlet"in t?t._container??document.body:t.el??document.body,T(e)?se(e,l,null):e._render(l,null)}}}var z=E("nix:portal-outlet");function Ee(e){ae(z,e)}function De(){return oe(z)}function Oe(e,t){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let l=document.createComment(S.ERROR_BOUNDARY);n.insertBefore(l,r);let i,u=null,a=!1,c=!1,f=!1,d=e=>{let n=l.parentNode,o="function"!=typeof t||T(t)?t:t(e);u=T(o)?ce(o,n,r):o._render(n,r)};o(e=>{a||(a=!0,c?(u?.(),u=null,d(e)):(i=e,f=!0))});try{if(T(e)){O();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}u=e.render()._render(n,r)}finally{k()}if(!a)try{let t=e.onMount?.(),n=u;u=()=>{try{e.onUnmount?.()}catch{}if("function"==typeof t)try{t()}catch{}n?.()}}catch(t){if(!e.onError)throw t;e.onError(t)}}else u=e._render(n,r)}catch(e){a=!0,u?.(),u=null,i=e,f=!0}finally{s(),c=!0}return f&&(u?.(),u=null,d(i)),()=>{u?.(),l.remove()}}}}function ke(e,t){if(T(e)){let n,r,l="string"==typeof t?document.querySelector(t):t;if(!l)throw Error(`[Nix] mount: container not found: ${t}`);O();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(l,null)}finally{k()}try{let t=e.onMount?.();"function"==typeof t&&(r=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return{unmount(){try{e.onUnmount?.()}catch{}try{r?.()}catch{}n()}}}return e.mount(t)}function Ae(e,t){let n={},r=new Set(["$reset","$patch","$state"]);for(let t of Object.keys(e)){if(r.has(t))throw Error(`[Nix] Store key "${t}" is reserved.`);n[t]=g(e[t])}let l=n;let o=Object.assign(Object.create(null),l,{$reset:function(){for(let t of Object.keys(e))n[t].value=e[t]},$patch:function(e){for(let t of Object.keys(e))t in n&&(n[t].value=e[t])}});if(Object.defineProperty(o,"$state",{get(){let e={};for(let t in n)e[t]=n[t].value;return e},enumerable:!0,configurable:!1}),t){let e=t(l);for(let t of Object.keys(e))r.has(t)?console.warn(`[Nix] Store action name "${t}" is reserved and will be ignored.`):o[t]=e[t]}return o}var B=null,V=null;function H(){if(!B)throw Error("[Nix] No active router. Call createRouter() first.");return B}function U(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function je(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))null!=r&&!1!==r&&t.set(n,String(r));let n=t.toString();return n?"?"+n:""}function Me(e){return"*"===e?[{kind:"wildcard"}]:e.split("/").filter(Boolean).map(e=>"*"===e?{kind:"wildcard"}:e.startsWith(":")?{kind:"param",name:e.slice(1)}:{kind:"literal",value:e})}function Ne(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function Pe(e,t="",n=[]){let r=[];for(let l of e){let e=Ne(t,l.path),o=[...n,l.component],i=Me(e);r.push({fullPath:e,segments:i,chain:o,beforeEnter:l.beforeEnter}),l.children?.length&&r.push(...Pe(l.children,e,o))}return r}function Fe(e,t){let n=e.split("/").filter(Boolean),r=t.segments;if(1===r.length&&"wildcard"===r[0].kind)return{};let l=r.length>0&&"wildcard"===r[r.length-1].kind,o=l?r.slice(0,-1):r;if(l){if(n.length<o.length)return null}else if(n.length!==o.length)return null;let i={};for(let e=0;e<o.length;e++){let t=o[e];if("literal"===t.kind){if(n[e]!==t.value)return null}else if("param"===t.kind)try{i[t.name]=decodeURIComponent(n[e]??"")}catch{i[t.name]=n[e]??""}}return i}function Ie(e){return e.segments.reduce((e,t)=>"literal"===t.kind?e+2:"param"===t.kind?e+1:e,0)}function W(e,t){let n,r={},l=-1;for(let o of t){let t=Fe(e,o);if(null===t)continue;let i=Ie(o);i>l&&(n=o,r=t,l=i)}return n?{route:n,params:r}:void 0}function G(e){let t=e.trim();return t&&"/"!==t?(t.startsWith("/")||(t="/"+t),t.endsWith("/")&&(t=t.slice(0,-1)),t):""}function Le(){if(typeof document>"u")return"";let e=document.querySelector("base");if(!e)return"";let t=e.getAttribute("href")||"";try{return G(new URL(t,window.location.origin).pathname)}catch{return G(t)}}function Re(e,t){let n=null==t?.base?Le():G(t.base);function r(){let e=window.location.pathname||"/";if(n&&e.startsWith(n)){let t=e.slice(n.length);return""===t?"/":t}return e}function l(e){return n?n+(e.startsWith("/")?e:"/"+e):e}let o=r(),i=Pe(e),u=W(o,i),a=g(o),s=g(u?.params??{}),c=g(U(window.location.search)),f=[],d=[],p=0;function h(e,t,n,r,l){let o=[...f];n&&o.push(n);let i=++p;if(0===o.length)return void r();let u=0;!function n(a){if(i!==p)return;if(!1===a)return void l?.();if("string"==typeof a)return void(a===e?r():_(a));if(u>=o.length)return void r();let s=o[u++](e,t);s instanceof Promise?s.then(n):n(s)}(void 0)}let v=!1;function m(e,t){let n=e.indexOf("?"),r=-1===n?e:e.slice(0,n),l=-1===n?{}:U(e.slice(n)),o=t?{...l,...t}:l,i={};for(let[e,t]of Object.entries(o))null!=t&&!1!==t&&(i[e]=String(t));return{pathname:r,stringQuery:i}}V&&=(V(),null);let y=()=>{let e=r(),t=a.value,n=c.value,o=W(e,i),u=U(window.location.search);h(e,t,o?.route.beforeEnter,()=>{s.value=o?.params??{},c.value=u,a.value=e;for(let n of d)try{n(e,t)}catch{}},()=>{history.pushState(null,"",l(t)+je(n))})};function x(e,t,n,r,o){s.value=r?.params??{},c.value=t,a.value=e;let i=l(e)+je(t);o?history.replaceState(null,"",i):history.pushState(null,"",i);for(let t of d)try{t(e,n)}catch{}}function _(e,t){v=!0;let{pathname:n,stringQuery:r}=m(e,t),l=a.value,o=W(n,i);h(n,l,o?.route.beforeEnter,()=>x(n,r,l,o,!1))}window.addEventListener("popstate",y),V=()=>window.removeEventListener("popstate",y);let b={current:a,params:s,query:c,base:n||"/",navigate:_,replace:function(e,t){v=!0;let{pathname:n,stringQuery:r}=m(e,t),l=a.value,o=W(n,i);h(n,l,o?.route.beforeEnter,()=>x(n,r,l,o,!0))},back:function(){history.back()},forward:function(){history.forward()},go:function(e){history.go(e)},isActive:function(e,t=!0){let n=a.value;return t?n===e:n===e||n.startsWith(e.endsWith("/")?e:e+"/")},resolve:function(t){let n=W(t,i);if(!n)return{matched:!1,params:{},route:void 0};let r=n.route.chain[n.route.chain.length-1];return{matched:!0,params:n.params,route:function e(t){for(let n of t){if(n.component===r)return n;if(n.children){let t=e(n.children);if(t)return t}}}(e)}},beforeEach:function(e){return f.push(e),()=>{let t=f.indexOf(e);-1!==t&&f.splice(t,1)}},afterEach:function(e){return d.push(e),()=>{let t=d.indexOf(e);-1!==t&&d.splice(t,1)}},routes:e,_flat:i,_guards:f,_base:n};return B&&console.warn("[Nix] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."),B=b,queueMicrotask(()=>{v||h(o,"",W(o,i)?.route.beforeEnter,()=>{},()=>{history.replaceState(null,"",l("/"));let e=W("/",i);a.value="/",s.value=e?.params??{},c.value={}})}),b}function ze(){return H()}var Be=class extends w{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return I`<div class="router-view">${()=>{let t=H(),n=W(t.current.value,t._flat);return n?e>=n.route.chain.length?I`<span></span>`:n.route.chain[e]():I`<div style="color:#f87171;padding:16px 0">
|
|
2
2
|
404 — Route not found: <strong>${t.current.value}</strong>
|
|
3
|
-
</div>`}}</div>`}},
|
|
4
|
-
href=${(
|
|
5
|
-
style=${()=>
|
|
6
|
-
@click=${t=>{t.preventDefault(),
|
|
7
|
-
>${t}</a>`}};function
|
|
3
|
+
</div>`}}</div>`}},Ve=class extends w{_to;_label;constructor(e,t){super(),this._to=e,this._label=t}render(){let e=this._to,t=this._label;return I`<a
|
|
4
|
+
href=${(H()._base||"")+(e.startsWith("/")?e:"/"+e)}
|
|
5
|
+
style=${()=>H().current.value===e?"color:#38bdf8;font-weight:700;text-decoration:none;cursor:pointer;padding:4px 10px;border-radius:4px;background:#0c2a3a":"color:#a3a3a3;text-decoration:none;cursor:pointer;padding:4px 10px;border-radius:4px"}
|
|
6
|
+
@click=${t=>{t.preventDefault(),H().navigate(e)}}
|
|
7
|
+
>${t}</a>`}};function He(){return I`
|
|
8
8
|
<span style="color:#52525b;font-size:13px;display:inline-flex;align-items:center;gap:6px">
|
|
9
9
|
<span class="nix-spinner" style="
|
|
10
10
|
display:inline-block;width:14px;height:14px;border-radius:50%;
|
|
@@ -14,8 +14,8 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=[],t=[]
|
|
|
14
14
|
Loading…
|
|
15
15
|
</span>
|
|
16
16
|
<style>@keyframes nix-spin{to{transform:rotate(360deg)}}</style>
|
|
17
|
-
`}function
|
|
17
|
+
`}function Ue(e){return I`
|
|
18
18
|
<span style="color:#f87171;font-size:13px">
|
|
19
19
|
⚠ ${e instanceof Error?e.message:String(e)}
|
|
20
20
|
</span>
|
|
21
|
-
`}var
|
|
21
|
+
`}var K=new Map,We=3e5,q=null,Ge=We;function Ke(){null===q&&(q=setInterval(()=>{let e=Date.now();for(let[t,n]of K)n.subscribers<=0&&e-n.fetchedAt>Ge&&K.delete(t);0===K.size&&null!==q&&(clearInterval(q),q=null)},6e4))}function J(e){return K.get(e)}function qe(e,t){let n=K.get(e);K.set(e,{data:t,fetchedAt:Date.now(),subscribers:n?.subscribers??0}),Ke()}function Je(e){let t=K.get(e);t&&t.subscribers++}function Ye(e){let t=K.get(e);t&&(t.subscribers=Math.max(0,t.subscribers-1))}function Xe(e,t){let n=K.get(e);return!!n&&Date.now()-n.fetchedAt<t}function Ze(e){void 0===e?K.clear():K.delete(e)}function Qe(e){Ge=e}function $e(e,t,n={}){let{fallback:r,errorFallback:l,resetOnRefresh:o=!1,invalidate:i,cacheKey:u,staleTime:a=0}=n,s=r??He(),c=l??Ue;return new class extends w{_state;_disposeWatcher;constructor(){super();let e=u?J(u):void 0;this._state=g(e?{status:"resolved",data:e.data}:{status:"pending"})}onMount(){u&&Je(u);let e=u?J(u):void 0;if(e&&Xe(u,a)||(e?this._fetch():this._run()),i){let e=!0;this._disposeWatcher=_(()=>{i.value,e?e=!1:(u&&K.delete(u),this._run())})}return()=>{this._disposeWatcher?.(),u&&Ye(u)}}_run(){(o||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){e().then(e=>{u&&qe(u,e),this._state.value={status:"resolved",data:e}},e=>{this._state.value={status:"error",error:e}})}render(){return I`<div class="nix-suspense" style="display:contents">${()=>{let e=this._state.value;return"pending"===e.status?s:"error"===e.status?c(e.error):t(e.data)}}</div>`}}}var Y=new Map,et=new FinalizationRegistry(({key:e,ref:t})=>{let n=Y.get(e);n&&(n.delete(t),0===n.size&&Y.delete(e))});function tt(e){K.delete(e);let t=Y.get(e);if(t){for(let e of t){let n=e.deref();n?n():t.delete(e)}0===t.size&&Y.delete(e)}}function nt(e,t,n={}){let{staleTime:r=0,refetchOnMount:l="always"}=n,o=J(e),i=g(o?"success":"pending"),u=g(o?.data),a=g(void 0),s=()=>{t().then(t=>{qe(e,t),u.value=t,a.value=void 0,i.value="success"},e=>{a.value=e,i.value="error"})},c=()=>{"pending"===i.peek()&&(u.value=void 0,a.value=void 0),s()};Y.has(e)||Y.set(e,new Set);let f=Y.get(e),d=new WeakRef(c);f.add(d),et.register(c,{key:e,ref:d});let p=Xe(e,r);return o?!1===l||"stale"===l&&p||"always"===l&&p&&r>0||s():c(),{status:i,data:u,error:a,refetch:()=>{K.delete(e),c()}}}function rt(e,t){let n=null;return()=>n?new n:$e(async()=>(n=(await e()).default,n),e=>new e,{fallback:t})}function it(e="Required"){return t=>null==t||""===t||Array.isArray(t)&&0===t.length?e:null}function X(e,t){return n=>"string"==typeof n&&n.length<e?t??`Minimum ${e} characters`:null}function at(e,t){return n=>"string"==typeof n&&n.length>e?t??`Maximum ${e} characters`:null}function Z(e,t="Invalid format"){return n=>"string"!=typeof n||e.test(n)?null:t}function ot(e="Invalid email"){return Z(/^[^\s@]+@[^\s@]+\.[^\s@]+$/,e)}function st(e,t){return n=>"number"==typeof n&&n<e?t??`Minimum value is ${e}`:null}function Q(e,t){return n=>"number"==typeof n&&n>e?t??`Maximum value is ${e}`:null}function ct(e){return e}const lt={required:it,minLength:X,maxLength:at,email:ot,pattern:Z,min:st,max:Q};function ut(e,t){return{...e,...t}}function $(e,t=[],n="blur"){let r=g(e),l=g(!1),o=g(!1),i=g(null),u=g(!1),a=v(()=>{if(i.value)return i.value;if(!("input"===n?o.value||l.value:"submit"===n?u.value:l.value))return null;for(let e of t){let t=e(r.value);if(t)return t}return null});function s(t){if(!t||!("value"in t))return e;let n=t;return"boolean"==typeof e?n.checked:"number"==typeof e?Number(n.value):n.value}return{value:r,error:a,touched:l,dirty:o,onInput:e=>{r.value=s(e.target),o.value=!0,i.value=null},onBlur:()=>{l.value=!0},reset:function(){r.value=e,l.value=!1,o.value=!1,i.value=null,u.value=!1},_setExternalError:function(e){i.value=e,e&&(l.value=!0)},_forceVisible:function(){l.value=!0,u.value=!0},_dispose:function(){a.dispose()}}}function dt(e,t={},n="blur"){function r(e){let r={};for(let l in e){let o=t[l]??[];r[l]=$(e[l],o,n)}return r}let l=g(e.map(r)),o=v(()=>l.value.length);return{fields:l,append:function(e){l.value=[...l.value,r(e)]},remove:function(e){let t=l.value;if(!(e<0||e>=t.length)){for(let n in t[e])t[e][n]._dispose();l.value=t.filter((t,n)=>n!==e)}},move:function(e,t){let n=[...l.value];if(e<0||e>=n.length||t<0||t>=n.length||e===t)return;let[r]=n.splice(e,1);n.splice(t,0,r),l.value=n},replace:function(e,t){let n=[...l.value];if(!(e<0||e>=n.length)){for(let t in n[e])n[e][t]._dispose();n[e]=r(t),l.value=n}},length:o,reset:function(){for(let e of l.value)for(let t in e)e[t]._dispose();l.value=e.map(r)},_dispose:function(){for(let e of l.value)for(let t in e)e[t]._dispose();o.dispose()}}}function ft(e,t={}){let n=t.validateOn??"blur",r={};for(let l in e){let o=t.validators?.[l]??[];r[l]=$(e[l],o,n)}let l=g(!1),o=g(0),i=v(()=>{let e={};for(let t in r)e[t]=r[t].value.value;return e}),u=v(()=>{let e={};for(let t in r){let n=r[t].error.value;n&&(e[t]=n)}return e}),a=v(()=>{for(let e in r)if(r[e].error.value)return!1;return!0}),s=v(()=>{for(let e in r)if(r[e].dirty.value)return!0;return!1}),c=v(()=>{for(let e in r)if(r[e].touched.value)return!0;return!1});function f(e){for(let t in e)r[t]?._setExternalError(e[t]??null)}return{fields:r,values:i,errors:u,valid:a,dirty:s,touched:c,isSubmitting:l,submitCount:o,handleSubmit:function(e){return n=>{n.preventDefault(),o.value++;for(let e in r)r[e]._forceVisible();let u=i.value;if(t.validate){let e=t.validate(u);if(e){let t={},n=!1;for(let r in e){let l=e[r],o=Array.isArray(l)?l[0]??null:l??null;o&&(t[r]=o,n=!0)}if(n)return void f(t)}}for(let e in r)if(r[e].error.value)return;let a=e(u);a instanceof Promise&&(l.value=!0,a.finally(()=>{l.value=!1}).catch(()=>{}))}},reset:function(){for(let e in r)r[e].reset();l.value=!1,o.value=0},setErrors:f,dispose:function(){i.dispose(),u.dispose(),a.dispose(),s.dispose(),c.dispose();for(let e in r)r[e]._dispose()}}}exports.Link=Ve,exports.NixComponent=w,exports.RouterView=Be,exports.Signal=h,exports.batch=y,exports.clearQueryCache=Ze,exports.computed=v,exports.createErrorBoundary=Oe,exports.createForm=ft,exports.createInjectionKey=E,exports.createPortalOutlet=Ce,exports.createQuery=nt,exports.createRouter=Re,exports.createStore=Ae,exports.createValidator=ct,exports.effect=_,exports.email=ot,exports.extendValidators=ut,exports.html=I,exports.inject=oe,exports.injectOutlet=De,exports.invalidateQueries=tt,exports.lazy=rt,exports.max=Q,exports.maxLength=at,exports.min=st,exports.minLength=X,exports.mount=ke,exports.nextTick=ee,exports.pattern=Z,exports.portal=Te,exports.portalOutlet=we,exports.provide=ae,exports.provideOutlet=Ee,exports.ref=te,exports.repeat=ue,exports.required=it,exports.setQueryCacheTime=Qe,exports.showWhen=pe,exports.signal=g,exports.suspend=$e,exports.transition=Se,exports.untrack=b,exports.useField=$,exports.useFieldArray=dt,exports.useRouter=ze,exports.validators=lt,exports.watch=x;
|
package/dist/lib/nix-js.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var e=[],t=[],n=null,r=null,i=null,a=[];function o(e){a.push(i),i=e}function s(){i=a.pop()??null}var c=0,l=new Set,u=[],d=100,f=0,p=[],m=0,h=class{_value;_subs=new Set;constructor(e){this._value=e}get value(){return n&&(this._subs.add(n),r?.add(this)),this._value}set value(e){Object.is(this._value,e)||(this._value=e,this._notify())}update(e){this.value=e(this._value)}peek(){return this._value}_removeSub(e){this._subs.delete(e)}_notify(){if(c>0){for(let e of this._subs)l.has(e)||(l.add(e),u.push(e));return}let e=m,t=0;for(let n of this._subs)p[e+t++]=n;m=e+t;try{for(let n=0;n<t;n++){let t=p[e+n];p[e+n]=null,t?.()}}finally{m=e}}dispose(){this._subs.clear()}};function g(e){return new h(e)}function _(l){let o,a=!1,u=new Set,s=new Set,c=i,p=()=>{if(a)return;"function"==typeof o&&o();let i=u;u=s,s=i,s.clear();let h=e.length>0?e.pop():{effect:null,deps:null};if(h.effect=n,h.deps=r,t.push(h),n=p,r=s,++f>d){f=0;let l=t.pop();throw n=l.effect,r=l.deps,l.effect=null,l.deps=null,e.push(l),Error("[Nix] Maximum effect re-execution depth exceeded (possible infinite loop).")}try{o=l()}catch(e){if(!c)throw e;c(e)}finally{f--;let l=t.pop();n=l.effect,r=l.deps,l.effect=null,l.deps=null,e.push(l);for(let e of u)s.has(e)||e._removeSub(p)}};return p(),()=>{a=!0,"function"==typeof o&&o();for(let e of s)e._removeSub(p);s.clear(),u.clear()}}function v(e){let t=new h(void 0),n=_(()=>{t.value=e()}),r=t.dispose;return t.dispose=()=>{n(),r.call(t)},t}function y(e){c++;try{e()}finally{if(0===--c&&u.length>0){let e=u.length;for(let t=0;t<e;t++)u[t]();u.length=0,l.clear()}}}function b(e){let t=n,l=r;n=null,r=null;try{return e()}finally{n=t,r=l}}function x(e,t,n={}){let r,{immediate:l=!1,once:o=!1}=n,i=e instanceof h?()=>e.value:e,a=!0,u=!1,s=_(()=>{let e=i();if(a){if(a=!1,l&&!u){let n=e;b(()=>t(n,void 0)),o&&(u=!0,Promise.resolve().then(s))}r=e}else if(!u){let n=e,l=r;r=e,b(()=>t(n,l)),o&&(u=!0,Promise.resolve().then(s))}});return()=>{u=!0,s()}}function S(e){return e?Promise.resolve().then(e):Promise.resolve()}var C=class{__isNixComponent=!0;children;_slots=new Map;setChildren(e){return this.children=e,this}setSlot(e,t){return this._slots.set(e,t),this}slot(e){return this._slots.get(e)}};function w(e){return"object"==typeof e&&!!e&&!0===e.__isNixComponent}function T(e){return Symbol(e)}var E=[];function ee(){return[...E]}function D(){E.push(new Map)}function O(){E.pop()}function te(e,t){let n=E.splice(0);e.forEach(e=>E.push(e)),E.push(new Map);try{return t()}finally{E.splice(0),n.forEach(e=>E.push(e))}}function k(e,t){let n=E[E.length-1];if(!n)throw Error("[Nix] provide() must be called inside onInit() of a NixComponent.");n.set(e,t)}function A(e){for(let t=E.length-1;t>=0;t--)if(E[t].has(e))return E[t].get(e)}var j={SCOPE:"nix-scope",ERROR_BOUNDARY:"nix-eb",TRANSITION:"nix-t",KEYED_START:"nix-ks",KEYED_END:"nix-ke",KEYED_ZONE:"nix-kz"};function ne(){return{el:null}}function re(e,t){t?"none"===e.style.display&&(e.style.display=""):"none"!==e.style.display&&(e.style.display="none")}function ie(e,t,n){return{__isKeyedList:!0,items:e,keyFn:t,renderFn:n}}function ae(e,t,n){let r,l;D();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}r=e.render()._render(t,n)}finally{O()}try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}r()}}function oe(e,t,n){let r,l;D();try{try{e.onInit?.()}catch{}r=e.render()._render(t,n)}finally{O()}try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch{}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}r()}}function M(e,t,n,r){let l,o;te(r,()=>{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}l=e.render()._render(t,n)});try{let t=e.onMount?.();"function"==typeof t&&(o=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{o?.()}catch{}l()}}function se(e,t,n,r,l){let o,i;D();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}o=e.render()._render(t,n)}finally{O()}r.push(()=>{try{let t=e.onMount?.();"function"==typeof t&&(i=t)}catch(t){if(!e.onError)throw t;e.onError(t)}}),l.push(()=>{try{e.onUnmount?.()}catch{}try{i?.()}catch{}o()})}function ce(){return{__isPortalOutlet:!0,_container:null}}function le(e){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(t,n){let r=document.createElement("div");return r.setAttribute("data-nix-outlet",""),e._container=r,t.insertBefore(r,n),()=>{e._container=null,r.remove()}}}}function ue(e,t=document.body){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let l;return l="string"==typeof t?document.querySelector(t)??document.body:t instanceof Element?t:"__isPortalOutlet"in t?t._container??document.body:t.el??document.body,w(e)?ae(e,l,null):e._render(l,null)}}}var de=T("nix:portal-outlet");function fe(e){k(de,e)}function pe(){return A(de)}function me(e,t){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let l=document.createComment(j.ERROR_BOUNDARY);n.insertBefore(l,r);let i,a=null,u=!1,c=!1,f=!1,d=e=>{let n=l.parentNode,o="function"!=typeof t||w(t)?t:t(e);a=w(o)?oe(o,n,r):o._render(n,r)};o(e=>{u||(u=!0,c?(a?.(),a=null,d(e)):(i=e,f=!0))});try{if(w(e)){D();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}a=e.render()._render(n,r)}finally{O()}if(!u)try{let t=e.onMount?.(),n=a;a=()=>{try{e.onUnmount?.()}catch{}if("function"==typeof t)try{t()}catch{}n?.()}}catch(t){if(!e.onError)throw t;e.onError(t)}}else a=e._render(n,r)}catch(e){u=!0,a?.(),a=null,i=e,f=!0}finally{s(),c=!0}return f&&(a?.(),a=null,d(i)),()=>{a?.(),l.remove()}}}}function he(e){let t=e.name??"nix";return{enterFrom:e.enterFrom??`${t}-enter-from`,enterActive:e.enterActive??`${t}-enter-active`,enterTo:e.enterTo??`${t}-enter-to`,leaveFrom:e.leaveFrom??`${t}-leave-from`,leaveActive:e.leaveActive??`${t}-leave-active`,leaveTo:e.leaveTo??`${t}-leave-to`}}function N(e){return Math.max(0,...e.split(",").map(e=>parseFloat(e.trim())||0))}function P(e,t=0){return new Promise(n=>{let r=getComputedStyle(e),l=1e3*Math.max(N(r.transitionDuration||"0"),N(r.animationDuration||"0")),o=l>0?l+100:t;if(o<=0)return void n();let i,a=t=>{t.target===e&&(clearTimeout(i),e.removeEventListener("transitionend",a),e.removeEventListener("animationend",a),n())};e.addEventListener("transitionend",a),e.addEventListener("animationend",a),i=setTimeout(()=>{e.removeEventListener("transitionend",a),e.removeEventListener("animationend",a),n()},o)})}function ge(e,t={}){let n=he(t);return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(r,l){let o=document.createComment(j.TRANSITION);r.insertBefore(o,l);let i=null,a=null,u=0,s=!0,c=()=>{let e=o.nextSibling;for(;e&&e!==l;){if(e.nodeType===Node.ELEMENT_NODE)return e;e=e.nextSibling}return null};function f(e){return w(e)?oe(e,r,l):e._render(r,l)}let d=(e,r=!1)=>{u++,a&&=(a(),null),i=f(e);let l=c();if(l&&(!s||t.appear)&&!r){let e=u;(async()=>{t.onBeforeEnter?.(l),l.classList.add(n.enterFrom,n.enterActive),l.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),u===e&&(l.classList.remove(n.enterFrom),l.classList.add(n.enterTo),await P(l,t.duration),u===e&&(l.classList.remove(n.enterActive,n.enterTo),t.onAfterEnter?.(l)))})().catch(()=>{})}s=!1},p=()=>{let e=i;i=null;let r=c();if(!r)return void e?.();let l=++u;a=e??null,(async()=>{t.onBeforeLeave?.(r),r.classList.add(n.leaveFrom,n.leaveActive),r.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),u===l&&(r.classList.remove(n.leaveFrom),r.classList.add(n.leaveTo),await P(r,t.duration),u===l&&(r.classList.remove(n.leaveActive,n.leaveTo),t.onAfterLeave?.(r),a?.(),a=null))})().catch(()=>{})},h=null;if("function"!=typeof e||w(e))d(e);else{let t=e,n=null;h=_(()=>{let e=t(),r=null===n,l=null===e;r&&!l?d(e):!r&&l?p():!r&&!l&&(u++,a?.(),a=null,i?.(),i=null,d(e,!0)),n=e}),s=!1}return()=>{u++,h?.(),i?.(),a?.(),i=null,a=null,o.remove()}}}}function _e(e){let t=e.lastIndexOf(">"),n=e.lastIndexOf("<");if(n<=t)return{type:"node"};let r=e.slice(n+1),l=r.lastIndexOf("=");if(-1===l)return{type:"node"};let o=r.endsWith('"')||r.endsWith("'")||'"'===r[r.length-1]||"'"===r[r.length-1],i=l-1;for(;i>=0&&/\S/.test(r[i]);)i--;i++;let a=r.slice(i,l);if("@"===a[0]){let e=a.slice(1).split(".");return{type:"event",eventName:e[0],modifiers:e.slice(1),hadOpenQuote:o}}return{type:"attr",attrName:a,hadOpenQuote:o}}function ve(e,t){let n=new Uint8Array(e.length),r="";for(let l=0;l<e.length;l++){let o=e[l];if(1===n[l]&&('"'===o[0]||"'"===o[0])&&(o=o.slice(1)),l<t.length){let e=t[l];if("node"===e.type)r+=o+`\x3c!--nix-${l}--\x3e`;else if("event"===e.type){let t=`@${e.modifiers.length?`${e.eventName}.${e.modifiers.join(".")}`:e.eventName}=`.length+(e.hadOpenQuote?1:0);r+=o.slice(0,-t)+` data-nix-e-${l}="${e.eventName}"`,e.hadOpenQuote&&(n[l+1]=1)}else{let t=`${e.attrName}=`.length+(e.hadOpenQuote?1:0);r+=o.slice(0,-t)+` data-nix-a-${l}="${e.attrName}"`,e.hadOpenQuote&&(n[l+1]=1)}}else r+=o}return r}function F(e){return"object"==typeof e&&!!e&&!0===e.__isNixTemplate}function ye(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}var be={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"},xe=new Set(["click","dblclick","mousedown","mouseup","keydown","keyup","input","change","submit"]),I=new Set;function Se(e,t,n){let r=e.target,l=e.stopPropagation,o=!1;for(e.stopPropagation=()=>{o=!0,l.call(e)};r&&r!==document;){let l=r[t];if(l){let t=r[n];if(t){if(t.includes("prevent")&&e.preventDefault(),t.includes("stop")&&e.stopPropagation(),t.includes("self")&&e.target!==r){r=r.parentNode;continue}if("key"in e){let n=e,l=!0;for(let e of t){let t=be[e];if(void 0!==t&&n.key!==t){l=!1;break}if(!t&&1===e.length&&n.key.toLowerCase()!==e){l=!1;break}}if(!l){r=r.parentNode;continue}}}if(l(e),o)break}r=r.parentNode}e.stopPropagation=l}var Ce=new Map,L=new Set,R=!1;function z(e){L.add(e),R||(R=!0,queueMicrotask(()=>{for(let e of L)e();L.clear(),R=!1}))}function we(e,t,n,r){let l=[],o=[],i=Array(t.length),a=-1;for(let e=0;e<t.length;e++)r[e]&&r[e].nodeIndex>a&&(a=r[e].nodeIndex);let u=Array(a+1);if(u[0]=e,a>0){let t,n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT),r=1;for(;r<=a&&(t=n.nextNode());)u[r++]=t}for(let e=0;e<t.length;e++){let t=r[e];i[e]=t?u[t.nodeIndex]:null}for(let e=0;e<t.length;e++){let a=t[e],u=n[e],s=r[e];if(!s)continue;let c=i[e];if("event"===a.type){let e=s.name,t=u,n=a.modifiers;if(!xe.has(e)||n.includes("capture")||n.includes("once")){let r={once:n.includes("once"),capture:n.includes("capture"),passive:n.includes("passive")},o=e=>{n.includes("prevent")&&e.preventDefault(),n.includes("stop")&&e.stopPropagation(),(!n.includes("self")||e.target===e.currentTarget)&&t(e)};c.addEventListener(e,o,r),l.push(()=>c.removeEventListener(e,o,r))}else{if(!I.has(e)){let t=`__nix_${e}`,n=`__nix_${e}_mods`,r=e=>Se(e,t,n);Ce.set(e,r),document.addEventListener(e,r),I.add(e)}let r=`__nix_${e}`,o=`__nix_${e}_mods`;c[r]=t,n.length>0&&(c[o]=n),l.push(()=>{c[r]=null,c[o]=null})}continue}if("attr"===a.type){let e=s.name,t=c;if("ref"===e){u.el=t,l.push(()=>{u.el=null});continue}if("show"===e||"hide"===e){let n=t,r=null;if("function"==typeof u){let t=!1,o=!1,i=!0,a=_(()=>{o=!!u();let l=()=>{t=!1;let l="show"===e?o:!o;null===r&&(r=n.style.display||""),n.style.display=l?r:"none"};i?(i=!1,l()):t||(t=!0,z(l))});l.push(a)}else("show"===e?u:!u)||(n.style.display="none");continue}let n=("value"===e||"checked"===e||"selected"===e)&&e in t;if("function"==typeof u){let r,o=!1,i=!0,a=_(()=>{r=u();let l=()=>{o=!1;let l=r;n?t[e]=l??"":null==l||!1===l?t.removeAttribute(e):t.setAttribute(e,String(l))};i?(i=!1,l()):o||(o=!0,z(l))});l.push(a)}else n?t[e]=u??"":null!=u&&!1!==u&&t.setAttribute(e,String(u));continue}let f=c;if(!f)continue;let d=document.createTextNode("");if(f.parentNode.replaceChild(d,f),"function"!=typeof u){if(w(u))se(u,d.parentNode,d,o,l);else if(F(u)){let e=u._render(d.parentNode,d);l.push(e)}else if(Array.isArray(u))for(let e of u)w(e)?se(e,d.parentNode,d,o,l):F(e)?e._render(d.parentNode,d):null!=e&&!1!==e&&d.parentNode.insertBefore(document.createTextNode(String(e)),d);else null!=u&&!1!==u&&d.parentNode.insertBefore(document.createTextNode(String(u)),d);continue}let p=null,h=null,v=null,m=[],g=null,b=ee(),x=!1,E="",N=!0,k=_(()=>{let e=u();if("string"==typeof e||"number"==typeof e){E=String(e);let t=()=>{x=!1,h&&=(h(),null),p?p.nodeValue=E:(p=document.createTextNode(E),d.parentNode.insertBefore(p,d))};return void(N?(N=!1,t()):x||(x=!0,z(t)))}if(x=!1,N=!1,p&&=(p.parentNode?.removeChild(p),null),h&&=(h(),null),null!=e&&!1!==e)if(F(e))h=e._render(d.parentNode,d);else if(w(e))h=M(e,d.parentNode,d,b);else if(ye(e)){v||(v=new Map,g=document.createTextNode(""),d.parentNode.insertBefore(g,d));let t=d.parentNode,n=e.items.map((t,n)=>e.keyFn(t,n)),r=new Set(n),l=!1;if(v.size>0)for(let e of v.keys())if(r.has(e)){l=!0;break}if(!l){if(v.size>0){let e=document.createRange();e.setStartAfter(g),e.setEndBefore(d),e.deleteContents();for(let e of v.values())e.cleanup();v.clear()}if(n.length>0){let r=document.createDocumentFragment();y(()=>{for(let t=0;t<n.length;t++){let l=n[t],o=e.items[t],i=document.createTextNode(""),a=document.createTextNode("");r.appendChild(i),r.appendChild(a);let u=e.renderFn(o,t),s=w(u)?M(u,r,a,b):u._render(r,a);v?.set(l,{start:i,end:a,cleanup:s})}}),t.insertBefore(r,d)}return void(m=n)}let o=new Map;for(let e=0;e<n.length;e++)o.set(n[e],e);let i=new Int32Array(n.length),a=!1,u=0;for(let e=0;e<m.length;e++){let t=m[e],n=o.get(t);if(void 0===n){let e=v.get(t);e.cleanup();let n=e.start;for(;n;){let t=n===e.end?null:n.nextSibling;if(n.parentNode?.removeChild(n),!t)break;n=t}v.delete(t)}else i[n]=e+1,n>=u?u=n:a=!0}let s=a?Te(i):[],c=s.length-1,f=d;for(let r=n.length-1;r>=0;r--){let l=n[r];if(0===i[r]){let n=e.items[r],o=document.createTextNode(""),i=document.createTextNode(""),a=document.createDocumentFragment();a.appendChild(o),a.appendChild(i);let u=e.renderFn(n,r),s=w(u)?M(u,a,i,b):u._render(a,i);v.set(l,{start:o,end:i,cleanup:s}),t.insertBefore(a,f),f=o}else{let e=v.get(l);if(a)if(c<0||r!==s[c]){let n=e.start;for(;n;){let r=n===e.end?null:n.nextSibling;if(t.insertBefore(n,f),!r)break;n=r}}else c--;f=e.start}}m=n}else if(Array.isArray(e)){let t=[];for(let n of e)if(w(n))t.push(ae(n,d.parentNode,d));else if(F(n))t.push(n._render(d.parentNode,d));else if(null!=n&&!1!==n){let e=document.createTextNode(String(n));d.parentNode.insertBefore(e,d),t.push(()=>e.parentNode?.removeChild(e))}h=()=>t.forEach(e=>e())}else p=document.createTextNode(String(e)),d.parentNode.insertBefore(p,d)});l.push(()=>{if(k(),h&&=(h(),null),p&&=(p.parentNode?.removeChild(p),null),v){for(let e of v.values())e.cleanup();v=null,g=null}})}return{disposes:l,postMountHooks:o}}function Te(e){let t,n,r,l,o,i=e.slice(),a=[0],u=e.length;for(t=0;t<u;t++){let u=e[t];if(0!==u){if(n=a[a.length-1],e[n]<u){i[t]=n,a.push(t);continue}for(r=0,l=a.length-1;r<l;)o=r+l>>1,e[a[o]]<u?r=o+1:l=o;u<e[a[r]]&&(r>0&&(i[t]=a[r-1]),a[r]=t)}}for(r=a.length,l=a[r-1];r-- >0;)a[r]=l,l=i[l];return a}var Ee=new WeakMap;function B(e,...t){let n=Ee.get(e);if(!n){let t=[],r="";for(let n=0;n<e.length-1;n++)r+=e[n],t.push(_e(r)),r+="__nix__";let l=document.createElement("template");l.innerHTML=ve(e,t);let o,i=Array(t.length).fill(null),a=l.content,u=document.createTreeWalker(a,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT),s=0;for(;o=u.nextNode();)if(s++,8===o.nodeType){let e=o.nodeValue;if(e&&e.startsWith("nix-")){let t=parseInt(e.slice(4),10);isNaN(t)||(i[t]={nodeIndex:s})}}else if(1===o.nodeType){let e=o,t=Array.from(e.attributes);for(let n=0;n<t.length;n++){let r=t[n],l=r.name;if(l.startsWith("data-nix-e-")){let t=parseInt(l.slice(11),10);isNaN(t)||(i[t]={nodeIndex:s,name:r.value},e.removeAttribute(l));continue}if(l.startsWith("data-nix-a-")){let t=parseInt(l.slice(11),10);isNaN(t)||(i[t]={nodeIndex:s,name:r.value},e.removeAttribute(l))}}}n={contexts:t,tpl:l,pathMap:i},Ee.set(e,n)}let{contexts:r,tpl:l,pathMap:o}=n;function i(e,n){let i=l.content.cloneNode(!0),{disposes:a,postMountHooks:u}=we(i,r,t,o),s=document.createTextNode("");return e.insertBefore(s,n),e.insertBefore(i,n),u.forEach(e=>e()),()=>{for(let e=a.length-1;e>=0;e--)a[e]();let e=s.nextSibling;for(;e&&e!==n;){let t=e.nextSibling;e.parentNode?.removeChild(e),e=t}s.parentNode?.removeChild(s)}}return{__isNixTemplate:!0,_render:i,mount(e){let t="string"==typeof e?document.querySelector(e):e;if(!t)throw Error(`[Nix] mount: contenedor no encontrado: ${e}`);let n=i(t,null);return{unmount(){n()}}}}}function De(e,t){if(w(e)){let n,r,l="string"==typeof t?document.querySelector(t):t;if(!l)throw Error(`[Nix] mount: container not found: ${t}`);D();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(l,null)}finally{O()}try{let t=e.onMount?.();"function"==typeof t&&(r=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return{unmount(){try{e.onUnmount?.()}catch{}try{r?.()}catch{}n()}}}return e.mount(t)}function Oe(e,t){let n={},r=new Set(["$reset","$patch","$state"]);for(let t of Object.keys(e)){if(r.has(t))throw Error(`[Nix] Store key "${t}" is reserved.`);n[t]=g(e[t])}let l=n;let o=Object.assign(Object.create(null),l,{$reset:function(){for(let t of Object.keys(e))n[t].value=e[t]},$patch:function(e){for(let t of Object.keys(e))t in n&&(n[t].value=e[t])}});if(Object.defineProperty(o,"$state",{get(){let e={};for(let t in n)e[t]=n[t].value;return e},enumerable:!0,configurable:!1}),t){let e=t(l);for(let t of Object.keys(e))r.has(t)?console.warn(`[Nix] Store action name "${t}" is reserved and will be ignored.`):o[t]=e[t]}return o}var V=null,H=null;function U(){if(!V)throw Error("[Nix] No active router. Call createRouter() first.");return V}function W(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function ke(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))null!=r&&!1!==r&&t.set(n,String(r));let n=t.toString();return n?"?"+n:""}function Ae(e){return"*"===e?[{kind:"wildcard"}]:e.split("/").filter(Boolean).map(e=>"*"===e?{kind:"wildcard"}:e.startsWith(":")?{kind:"param",name:e.slice(1)}:{kind:"literal",value:e})}function je(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function Me(e,t="",n=[]){let r=[];for(let l of e){let e=je(t,l.path),o=[...n,l.component],i=Ae(e);r.push({fullPath:e,segments:i,chain:o,beforeEnter:l.beforeEnter}),l.children?.length&&r.push(...Me(l.children,e,o))}return r}function Ne(e,t){let n=e.split("/").filter(Boolean),r=t.segments;if(1===r.length&&"wildcard"===r[0].kind)return{};let l=r.length>0&&"wildcard"===r[r.length-1].kind,o=l?r.slice(0,-1):r;if(l){if(n.length<o.length)return null}else if(n.length!==o.length)return null;let i={};for(let e=0;e<o.length;e++){let t=o[e];if("literal"===t.kind){if(n[e]!==t.value)return null}else if("param"===t.kind)try{i[t.name]=decodeURIComponent(n[e]??"")}catch{i[t.name]=n[e]??""}}return i}function Pe(e){return e.segments.reduce((e,t)=>"literal"===t.kind?e+2:"param"===t.kind?e+1:e,0)}function G(e,t){let n,r={},l=-1;for(let o of t){let t=Ne(e,o);if(null===t)continue;let i=Pe(o);i>l&&(n=o,r=t,l=i)}return n?{route:n,params:r}:void 0}function K(e){let t=e.trim();return t&&"/"!==t?(t.startsWith("/")||(t="/"+t),t.endsWith("/")&&(t=t.slice(0,-1)),t):""}function Fe(){if(typeof document>"u")return"";let e=document.querySelector("base");if(!e)return"";let t=e.getAttribute("href")||"";try{return K(new URL(t,window.location.origin).pathname)}catch{return K(t)}}function Ie(e,t){let n=null==t?.base?Fe():K(t.base);function r(){let e=window.location.pathname||"/";if(n&&e.startsWith(n)){let t=e.slice(n.length);return""===t?"/":t}return e}function l(e){return n?n+(e.startsWith("/")?e:"/"+e):e}let o=r(),i=Me(e),a=G(o,i),u=g(o),s=g(a?.params??{}),c=g(W(window.location.search)),f=[],d=[],p=0;function h(e,t,n,r,l){let o=[...f];n&&o.push(n);let i=++p;if(0===o.length)return void r();let a=0;!function n(u){if(i!==p)return;if(!1===u)return void l?.();if("string"==typeof u)return void(u===e?r():b(u));if(a>=o.length)return void r();let s=o[a++](e,t);s instanceof Promise?s.then(n):n(s)}(void 0)}let v=!1;function m(e,t){let n=e.indexOf("?"),r=-1===n?e:e.slice(0,n),l=-1===n?{}:W(e.slice(n)),o=t?{...l,...t}:l,i={};for(let[e,t]of Object.entries(o))null!=t&&!1!==t&&(i[e]=String(t));return{pathname:r,stringQuery:i}}H&&=(H(),null);let y=()=>{let e=r(),t=u.value,n=c.value,o=G(e,i),a=W(window.location.search);h(e,t,o?.route.beforeEnter,()=>{s.value=o?.params??{},c.value=a,u.value=e;for(let n of d)try{n(e,t)}catch{}},()=>{history.pushState(null,"",l(t)+ke(n))})};function _(e,t,n,r,o){s.value=r?.params??{},c.value=t,u.value=e;let i=l(e)+ke(t);o?history.replaceState(null,"",i):history.pushState(null,"",i);for(let t of d)try{t(e,n)}catch{}}function b(e,t){v=!0;let{pathname:n,stringQuery:r}=m(e,t),l=u.value,o=G(n,i);h(n,l,o?.route.beforeEnter,()=>_(n,r,l,o,!1))}window.addEventListener("popstate",y),H=()=>window.removeEventListener("popstate",y);let x={current:u,params:s,query:c,base:n||"/",navigate:b,replace:function(e,t){v=!0;let{pathname:n,stringQuery:r}=m(e,t),l=u.value,o=G(n,i);h(n,l,o?.route.beforeEnter,()=>_(n,r,l,o,!0))},back:function(){history.back()},forward:function(){history.forward()},go:function(e){history.go(e)},isActive:function(e,t=!0){let n=u.value;return t?n===e:n===e||n.startsWith(e.endsWith("/")?e:e+"/")},resolve:function(t){let n=G(t,i);if(!n)return{matched:!1,params:{},route:void 0};let r=n.route.chain[n.route.chain.length-1];return{matched:!0,params:n.params,route:function e(t){for(let n of t){if(n.component===r)return n;if(n.children){let t=e(n.children);if(t)return t}}}(e)}},beforeEach:function(e){return f.push(e),()=>{let t=f.indexOf(e);-1!==t&&f.splice(t,1)}},afterEach:function(e){return d.push(e),()=>{let t=d.indexOf(e);-1!==t&&d.splice(t,1)}},routes:e,_flat:i,_guards:f,_base:n};return V&&console.warn("[Nix] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."),V=x,queueMicrotask(()=>{v||h(o,"",G(o,i)?.route.beforeEnter,()=>{},()=>{history.replaceState(null,"",l("/"));let e=G("/",i);u.value="/",s.value=e?.params??{},c.value={}})}),x}function Le(){return U()}var Re=class extends C{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return B`<div class="router-view">${()=>{let t=U(),n=G(t.current.value,t._flat);return n?e>=n.route.chain.length?B`<span></span>`:n.route.chain[e]():B`<div style="color:#f87171;padding:16px 0">
|
|
1
|
+
var e=[],t=[],n=null,r=null,i=null,a=[];function o(e){a.push(i),i=e}function s(){i=a.pop()??null}var c=0,l=new Set,u=[],d=100,f=0,p=[],m=0,h=class{_value;_subs=new Set;constructor(e){this._value=e}get value(){return n&&(this._subs.add(n),r?.add(this)),this._value}set value(e){Object.is(this._value,e)||(this._value=e,this._notify())}update(e){this.value=e(this._value)}peek(){return this._value}_removeSub(e){this._subs.delete(e)}_notify(){if(c>0){for(let e of this._subs)l.has(e)||(l.add(e),u.push(e));return}let e=m,t=0;for(let n of this._subs)p[e+t++]=n;m=e+t;try{for(let n=0;n<t;n++){let t=p[e+n];p[e+n]=null,t?.()}}finally{m=e}}dispose(){this._subs.clear()}};function g(e){return new h(e)}function _(l){let o,a=!1,u=new Set,s=new Set,c=i,p=()=>{if(a)return;"function"==typeof o&&o();let i=u;u=s,s=i,s.clear();let h=e.length>0?e.pop():{effect:null,deps:null};if(h.effect=n,h.deps=r,t.push(h),n=p,r=s,++f>d){f=0;let l=t.pop();throw n=l.effect,r=l.deps,l.effect=null,l.deps=null,e.push(l),Error("[Nix] Maximum effect re-execution depth exceeded (possible infinite loop).")}try{o=l()}catch(e){if(!c)throw e;c(e)}finally{f--;let l=t.pop();n=l.effect,r=l.deps,l.effect=null,l.deps=null,e.push(l);for(let e of u)s.has(e)||e._removeSub(p)}};return p(),()=>{a=!0,"function"==typeof o&&o();for(let e of s)e._removeSub(p);s.clear(),u.clear()}}function v(e){let t=new h(void 0),n=_(()=>{t.value=e()}),r=t.dispose;return t.dispose=()=>{n(),r.call(t)},t}function y(e){c++;try{e()}finally{if(0===--c&&u.length>0){let e=u.length;for(let t=0;t<e;t++)u[t]();u.length=0,l.clear()}}}function b(e){let t=n,l=r;n=null,r=null;try{return e()}finally{n=t,r=l}}function x(e,t,n={}){let r,{immediate:l=!1,once:o=!1}=n,i=e instanceof h?()=>e.value:e,a=!0,u=!1,s=_(()=>{let e=i();if(a){if(a=!1,l&&!u){let n=e;b(()=>t(n,void 0)),o&&(u=!0,Promise.resolve().then(s))}r=e}else if(!u){let n=e,l=r;r=e,b(()=>t(n,l)),o&&(u=!0,Promise.resolve().then(s))}});return()=>{u=!0,s()}}function ee(e){return e?Promise.resolve().then(e):Promise.resolve()}function te(){return{el:null}}const S={SCOPE:"nix-scope",ERROR_BOUNDARY:"nix-eb",TRANSITION:"nix-t",KEYED_START:"nix-ks",KEYED_END:"nix-ke",KEYED_ZONE:"nix-kz"};function C(e){return"object"==typeof e&&!!e&&!0===e.__isNixTemplate}function ne(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}var w=class{__isNixComponent=!0;children;_slots=new Map;setChildren(e){return this.children=e,this}setSlot(e,t){return this._slots.set(e,t),this}slot(e){return this._slots.get(e)}};function T(e){return"object"==typeof e&&!!e&&!0===e.__isNixComponent}function E(e){return Symbol(e)}var D=[];function re(){return[...D]}function O(){D.push(new Map)}function k(){D.pop()}function ie(e,t){let n=D.splice(0);e.forEach(e=>D.push(e)),D.push(new Map);try{return t()}finally{D.splice(0),n.forEach(e=>D.push(e))}}function ae(e,t){let n=D[D.length-1];if(!n)throw Error("[Nix] provide() must be called inside onInit() of a NixComponent.");n.set(e,t)}function oe(e){for(let t=D.length-1;t>=0;t--)if(D[t].has(e))return D[t].get(e)}function se(e,t,n){let r,l;O();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}r=e.render()._render(t,n)}finally{k()}try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}r()}}function ce(e,t,n){let r,l;O();try{try{e.onInit?.()}catch{}r=e.render()._render(t,n)}finally{k()}try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch{}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}r()}}function A(e,t,n,r){let l,o;ie(r,()=>{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}l=e.render()._render(t,n)});try{let t=e.onMount?.();"function"==typeof t&&(o=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{o?.()}catch{}l()}}function le(e,t,n,r,l){let o,i;O();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}o=e.render()._render(t,n)}finally{k()}r.push(()=>{try{let t=e.onMount?.();"function"==typeof t&&(i=t)}catch(t){if(!e.onError)throw t;e.onError(t)}}),l.push(()=>{try{e.onUnmount?.()}catch{}try{i?.()}catch{}o()})}function ue(e,t,n){return{__isKeyedList:!0,items:e,keyFn:t,renderFn:n}}function de(e){let t,n,r,l,o,i=e.slice(),a=[0],u=e.length;for(t=0;t<u;t++){let u=e[t];if(0!==u){if(n=a[a.length-1],e[n]<u){i[t]=n,a.push(t);continue}for(r=0,l=a.length-1;r<l;)o=r+l>>1,e[a[o]]<u?r=o+1:l=o;u<e[a[r]]&&(r>0&&(i[t]=a[r-1]),a[r]=t)}}for(r=a.length,l=a[r-1];r-- >0;)a[r]=l,l=i[l];return a}var j=new Set,M=!1;function N(e){j.add(e),M||(M=!0,queueMicrotask(()=>{for(let e of j)e();j.clear(),M=!1}))}function fe(e,t,n,r){if("function"!=typeof t){if(T(t))le(t,e.parentNode,e,r,n);else if(C(t))n.push(t._render(e.parentNode,e));else if(Array.isArray(t))for(let l of t)T(l)?le(l,e.parentNode,e,r,n):C(l)?l._render(e.parentNode,e):null!=l&&!1!==l&&e.parentNode.insertBefore(document.createTextNode(String(l)),e);else null!=t&&!1!==t&&e.parentNode.insertBefore(document.createTextNode(String(t)),e);return}let l=null,o=null,i=null,a=[],u=null,s=re(),c=!1,f="",d=!0,p=_(()=>{let n=t();if("string"==typeof n||"number"==typeof n){f=String(n);let t=()=>{c=!1,o&&=(o(),null),l?l.nodeValue=f:(l=document.createTextNode(f),e.parentNode.insertBefore(l,e))};return void(d?(d=!1,t()):c||(c=!0,N(t)))}if(c=!1,d=!1,l&&=(l.parentNode?.removeChild(l),null),o&&=(o(),null),null!=n&&!1!==n)if(C(n))o=n._render(e.parentNode,e);else if(T(n))o=A(n,e.parentNode,e,s);else if(ne(n)){i||(i=new Map,u=document.createTextNode(""),e.parentNode.insertBefore(u,e));let t=e.parentNode,r=n.items.map((e,t)=>n.keyFn(e,t)),l=new Set(r),o=!1;if(i.size>0)for(let e of i.keys())if(l.has(e)){o=!0;break}if(!o){if(i.size>0){let t=document.createRange();t.setStartAfter(u),t.setEndBefore(e),t.deleteContents();for(let e of i.values())e.cleanup();i.clear()}if(r.length>0){let l=document.createDocumentFragment();y(()=>{for(let e=0;e<r.length;e++){let t=r[e],o=n.items[e],a=document.createTextNode(""),u=document.createTextNode("");l.appendChild(a),l.appendChild(u);let c=n.renderFn(o,e),f=T(c)?A(c,l,u,s):c._render(l,u);i?.set(t,{start:a,end:u,cleanup:f})}}),t.insertBefore(l,e)}return void(a=r)}let c=new Map;for(let e=0;e<r.length;e++)c.set(r[e],e);let f=new Int32Array(r.length),d=!1,p=0;for(let e=0;e<a.length;e++){let t=a[e],n=c.get(t);if(void 0===n){let e=i.get(t);e.cleanup();let n=e.start;for(;n;){let t=n===e.end?null:n.nextSibling;if(n.parentNode?.removeChild(n),!t)break;n=t}i.delete(t)}else f[n]=e+1,n>=p?p=n:d=!0}let h=d?de(f):[],v=h.length-1,m=e;for(let e=r.length-1;e>=0;e--){let l=r[e];if(0===f[e]){let r=n.items[e],o=document.createTextNode(""),a=document.createTextNode(""),u=document.createDocumentFragment();u.appendChild(o),u.appendChild(a);let c=n.renderFn(r,e),f=T(c)?A(c,u,a,s):c._render(u,a);i.set(l,{start:o,end:a,cleanup:f}),t.insertBefore(u,m),m=o}else{let n=i.get(l);if(d)if(v<0||e!==h[v]){let e=n.start;for(;e;){let r=e===n.end?null:e.nextSibling;if(t.insertBefore(e,m),!r)break;e=r}}else v--;m=n.start}}a=r}else if(Array.isArray(n)){let t=[];for(let r of n)if(T(r))t.push(se(r,e.parentNode,e));else if(C(r))t.push(r._render(e.parentNode,e));else if(null!=r&&!1!==r){let n=document.createTextNode(String(r));e.parentNode.insertBefore(n,e),t.push(()=>n.parentNode?.removeChild(n))}o=()=>t.forEach(e=>e())}else l=document.createTextNode(String(n)),e.parentNode.insertBefore(l,e)});n.push(()=>{if(p(),o&&=(o(),null),l&&=(l.parentNode?.removeChild(l),null),i){for(let e of i.values())e.cleanup();i=null,u=null}})}function pe(e,t){t?"none"===e.style.display&&(e.style.display=""):"none"!==e.style.display&&(e.style.display="none")}function me(e){let t=e.lastIndexOf(">"),n=e.lastIndexOf("<");if(n<=t)return{type:"node"};let r=e.slice(n+1),l=r.lastIndexOf("=");if(-1===l)return{type:"node"};let o=r.endsWith('"')||r.endsWith("'")||'"'===r[r.length-1]||"'"===r[r.length-1],i=l-1;for(;i>=0&&/\S/.test(r[i]);)i--;i++;let a=r.slice(i,l);if("@"===a[0]){let e=a.slice(1).split(".");return{type:"event",eventName:e[0],modifiers:e.slice(1),hadOpenQuote:o}}return{type:"attr",attrName:a,hadOpenQuote:o}}var he={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"},ge=new Set(["click","dblclick","mousedown","mouseup","keydown","keyup","input","change","submit"]),P=new Set;function _e(e,t,n){let r=e.target,l=e.stopPropagation,o=!1;for(e.stopPropagation=()=>{o=!0,l.call(e)};r&&r!==document;){let l=r[t];if(l){let t=r[n];if(t){if(t.includes("prevent")&&e.preventDefault(),t.includes("stop")&&e.stopPropagation(),t.includes("self")&&e.target!==r){r=r.parentNode;continue}if("key"in e){let n=e,l=!0;for(let e of t){let t=he[e];if(void 0!==t&&n.key!==t){l=!1;break}if(!t&&1===e.length&&n.key.toLowerCase()!==e){l=!1;break}}if(!l){r=r.parentNode;continue}}}if(l(e),o)break}r=r.parentNode}e.stopPropagation=l}var ve=new Map;function ye(e,t,n,r){let l=[],o=[],i=Array(t.length),a=-1;for(let e=0;e<t.length;e++)r[e]&&r[e].nodeIndex>a&&(a=r[e].nodeIndex);let u=Array(a+1);if(u[0]=e,a>0){let t,n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT),r=1;for(;r<=a&&(t=n.nextNode());)u[r++]=t}for(let e=0;e<t.length;e++){let t=r[e];i[e]=t?u[t.nodeIndex]:null}for(let e=0;e<t.length;e++){let a=t[e],u=n[e],s=r[e];if(!s)continue;let c=i[e];if("event"===a.type){let e=s.name,t=u,n=a.modifiers;if(!ge.has(e)||n.includes("capture")||n.includes("once")){let r={once:n.includes("once"),capture:n.includes("capture"),passive:n.includes("passive")},o=e=>{n.includes("prevent")&&e.preventDefault(),n.includes("stop")&&e.stopPropagation(),(!n.includes("self")||e.target===e.currentTarget)&&t(e)};c.addEventListener(e,o,r),l.push(()=>c.removeEventListener(e,o,r))}else{if(!P.has(e)){let t=`__nix_${e}`,n=`__nix_${e}_mods`,r=e=>_e(e,t,n);ve.set(e,r),document.addEventListener(e,r),P.add(e)}let r=`__nix_${e}`,o=`__nix_${e}_mods`;c[r]=t,n.length>0&&(c[o]=n),l.push(()=>{c[r]=null,c[o]=null})}continue}if("attr"===a.type){let e=s.name,t=c;if("ref"===e){u.el=t,l.push(()=>{u.el=null});continue}if("show"===e||"hide"===e){let n=t,r=null;if("function"==typeof u){let t=!1,o=!1,i=!0,a=_(()=>{o=!!u();let l=()=>{t=!1;let l="show"===e?o:!o;null===r&&(r=n.style.display||""),n.style.display=l?r:"none"};i?(i=!1,l()):t||(t=!0,N(l))});l.push(a)}else("show"===e?u:!u)||(n.style.display="none");continue}let n=("value"===e||"checked"===e||"selected"===e)&&e in t;if("function"==typeof u){let r,o=!1,i=!0,a=_(()=>{r=u();let l=()=>{o=!1;let l=r;n?t[e]=l??"":null==l||!1===l?t.removeAttribute(e):t.setAttribute(e,String(l))};i?(i=!1,l()):o||(o=!0,N(l))});l.push(a)}else n?t[e]=u??"":null!=u&&!1!==u&&t.setAttribute(e,String(u));continue}let f=c;if(!f)continue;let d=document.createTextNode("");f.parentNode.replaceChild(d,f),fe(d,u,l,o)}return{disposes:l,postMountHooks:o}}function be(e,t){let n=new Uint8Array(e.length),r="";for(let l=0;l<e.length;l++){let o=e[l];if(1===n[l]&&('"'===o[0]||"'"===o[0])&&(o=o.slice(1)),l<t.length){let e=t[l];if("node"===e.type)r+=o+`\x3c!--nix-${l}--\x3e`;else if("event"===e.type){let t=`@${e.modifiers.length?`${e.eventName}.${e.modifiers.join(".")}`:e.eventName}=`.length+(e.hadOpenQuote?1:0);r+=o.slice(0,-t)+` data-nix-e-${l}="${e.eventName}"`,e.hadOpenQuote&&(n[l+1]=1)}else{let t=`${e.attrName}=`.length+(e.hadOpenQuote?1:0);r+=o.slice(0,-t)+` data-nix-a-${l}="${e.attrName}"`,e.hadOpenQuote&&(n[l+1]=1)}}else r+=o}return r}var F=new WeakMap;function I(e,...t){let n=F.get(e);if(!n){let t=[],r="";for(let n=0;n<e.length-1;n++)r+=e[n],t.push(me(r)),r+="__nix__";let l=document.createElement("template");l.innerHTML=be(e,t);let o,i=Array(t.length).fill(null),a=l.content,u=document.createTreeWalker(a,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT),s=0;for(;o=u.nextNode();)if(s++,8===o.nodeType){let e=o.nodeValue;if(e&&e.startsWith("nix-")){let t=parseInt(e.slice(4),10);isNaN(t)||(i[t]={nodeIndex:s})}}else if(1===o.nodeType){let e=o,t=Array.from(e.attributes);for(let n=0;n<t.length;n++){let r=t[n],l=r.name;if(l.startsWith("data-nix-e-")){let t=parseInt(l.slice(11),10);isNaN(t)||(i[t]={nodeIndex:s,name:r.value},e.removeAttribute(l));continue}if(l.startsWith("data-nix-a-")){let t=parseInt(l.slice(11),10);isNaN(t)||(i[t]={nodeIndex:s,name:r.value},e.removeAttribute(l))}}}n={contexts:t,tpl:l,pathMap:i},F.set(e,n)}let{contexts:r,tpl:l,pathMap:o}=n;function i(e,n){let i=l.content.cloneNode(!0),{disposes:a,postMountHooks:u}=ye(i,r,t,o),s=document.createTextNode("");return e.insertBefore(s,n),e.insertBefore(i,n),u.forEach(e=>e()),()=>{for(let e=a.length-1;e>=0;e--)a[e]();let e=s.nextSibling;for(;e&&e!==n;){let t=e.nextSibling;e.parentNode?.removeChild(e),e=t}s.parentNode?.removeChild(s)}}return{__isNixTemplate:!0,_render:i,mount(e){let t="string"==typeof e?document.querySelector(e):e;if(!t)throw Error(`[Nix] mount: contenedor no encontrado: ${e}`);let n=i(t,null);return{unmount(){n()}}}}}function xe(e){let t=e.name??"nix";return{enterFrom:e.enterFrom??`${t}-enter-from`,enterActive:e.enterActive??`${t}-enter-active`,enterTo:e.enterTo??`${t}-enter-to`,leaveFrom:e.leaveFrom??`${t}-leave-from`,leaveActive:e.leaveActive??`${t}-leave-active`,leaveTo:e.leaveTo??`${t}-leave-to`}}function L(e){return Math.max(0,...e.split(",").map(e=>parseFloat(e.trim())||0))}function R(e,t=0){return new Promise(n=>{let r=getComputedStyle(e),l=1e3*Math.max(L(r.transitionDuration||"0"),L(r.animationDuration||"0")),o=l>0?l+100:t;if(o<=0)return void n();let i,a=t=>{t.target===e&&(clearTimeout(i),e.removeEventListener("transitionend",a),e.removeEventListener("animationend",a),n())};e.addEventListener("transitionend",a),e.addEventListener("animationend",a),i=setTimeout(()=>{e.removeEventListener("transitionend",a),e.removeEventListener("animationend",a),n()},o)})}function Se(e,t={}){let n=xe(t);return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(r,l){let o=document.createComment(S.TRANSITION);r.insertBefore(o,l);let i=null,a=null,u=0,s=!0,c=()=>{let e=o.nextSibling;for(;e&&e!==l;){if(e.nodeType===Node.ELEMENT_NODE)return e;e=e.nextSibling}return null};function f(e){return T(e)?ce(e,r,l):e._render(r,l)}let d=(e,r=!1)=>{u++,a&&=(a(),null),i=f(e);let l=c();if(l&&(!s||t.appear)&&!r){let e=u;(async()=>{t.onBeforeEnter?.(l),l.classList.add(n.enterFrom,n.enterActive),l.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),u===e&&(l.classList.remove(n.enterFrom),l.classList.add(n.enterTo),await R(l,t.duration),u===e&&(l.classList.remove(n.enterActive,n.enterTo),t.onAfterEnter?.(l)))})().catch(()=>{})}s=!1},p=()=>{let e=i;i=null;let r=c();if(!r)return void e?.();let l=++u;a=e??null,(async()=>{t.onBeforeLeave?.(r),r.classList.add(n.leaveFrom,n.leaveActive),r.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),u===l&&(r.classList.remove(n.leaveFrom),r.classList.add(n.leaveTo),await R(r,t.duration),u===l&&(r.classList.remove(n.leaveActive,n.leaveTo),t.onAfterLeave?.(r),a?.(),a=null))})().catch(()=>{})},h=null;if("function"!=typeof e||T(e))d(e);else{let t=e,n=null;h=_(()=>{let e=t(),r=null===n,l=null===e;r&&!l?d(e):!r&&l?p():!r&&!l&&(u++,a?.(),a=null,i?.(),i=null,d(e,!0)),n=e}),s=!1}return()=>{u++,h?.(),i?.(),a?.(),i=null,a=null,o.remove()}}}}function Ce(){return{__isPortalOutlet:!0,_container:null}}function we(e){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(t,n){let r=document.createElement("div");return r.setAttribute("data-nix-outlet",""),e._container=r,t.insertBefore(r,n),()=>{e._container=null,r.remove()}}}}function Te(e,t=document.body){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let l;return l="string"==typeof t?document.querySelector(t)??document.body:t instanceof Element?t:"__isPortalOutlet"in t?t._container??document.body:t.el??document.body,T(e)?se(e,l,null):e._render(l,null)}}}var z=E("nix:portal-outlet");function Ee(e){ae(z,e)}function De(){return oe(z)}function Oe(e,t){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let l=document.createComment(S.ERROR_BOUNDARY);n.insertBefore(l,r);let i,a=null,u=!1,c=!1,f=!1,d=e=>{let n=l.parentNode,o="function"!=typeof t||T(t)?t:t(e);a=T(o)?ce(o,n,r):o._render(n,r)};o(e=>{u||(u=!0,c?(a?.(),a=null,d(e)):(i=e,f=!0))});try{if(T(e)){O();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}a=e.render()._render(n,r)}finally{k()}if(!u)try{let t=e.onMount?.(),n=a;a=()=>{try{e.onUnmount?.()}catch{}if("function"==typeof t)try{t()}catch{}n?.()}}catch(t){if(!e.onError)throw t;e.onError(t)}}else a=e._render(n,r)}catch(e){u=!0,a?.(),a=null,i=e,f=!0}finally{s(),c=!0}return f&&(a?.(),a=null,d(i)),()=>{a?.(),l.remove()}}}}function ke(e,t){if(T(e)){let n,r,l="string"==typeof t?document.querySelector(t):t;if(!l)throw Error(`[Nix] mount: container not found: ${t}`);O();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(l,null)}finally{k()}try{let t=e.onMount?.();"function"==typeof t&&(r=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return{unmount(){try{e.onUnmount?.()}catch{}try{r?.()}catch{}n()}}}return e.mount(t)}function Ae(e,t){let n={},r=new Set(["$reset","$patch","$state"]);for(let t of Object.keys(e)){if(r.has(t))throw Error(`[Nix] Store key "${t}" is reserved.`);n[t]=g(e[t])}let l=n;let o=Object.assign(Object.create(null),l,{$reset:function(){for(let t of Object.keys(e))n[t].value=e[t]},$patch:function(e){for(let t of Object.keys(e))t in n&&(n[t].value=e[t])}});if(Object.defineProperty(o,"$state",{get(){let e={};for(let t in n)e[t]=n[t].value;return e},enumerable:!0,configurable:!1}),t){let e=t(l);for(let t of Object.keys(e))r.has(t)?console.warn(`[Nix] Store action name "${t}" is reserved and will be ignored.`):o[t]=e[t]}return o}var B=null,V=null;function H(){if(!B)throw Error("[Nix] No active router. Call createRouter() first.");return B}function U(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function je(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))null!=r&&!1!==r&&t.set(n,String(r));let n=t.toString();return n?"?"+n:""}function Me(e){return"*"===e?[{kind:"wildcard"}]:e.split("/").filter(Boolean).map(e=>"*"===e?{kind:"wildcard"}:e.startsWith(":")?{kind:"param",name:e.slice(1)}:{kind:"literal",value:e})}function Ne(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function Pe(e,t="",n=[]){let r=[];for(let l of e){let e=Ne(t,l.path),o=[...n,l.component],i=Me(e);r.push({fullPath:e,segments:i,chain:o,beforeEnter:l.beforeEnter}),l.children?.length&&r.push(...Pe(l.children,e,o))}return r}function Fe(e,t){let n=e.split("/").filter(Boolean),r=t.segments;if(1===r.length&&"wildcard"===r[0].kind)return{};let l=r.length>0&&"wildcard"===r[r.length-1].kind,o=l?r.slice(0,-1):r;if(l){if(n.length<o.length)return null}else if(n.length!==o.length)return null;let i={};for(let e=0;e<o.length;e++){let t=o[e];if("literal"===t.kind){if(n[e]!==t.value)return null}else if("param"===t.kind)try{i[t.name]=decodeURIComponent(n[e]??"")}catch{i[t.name]=n[e]??""}}return i}function Ie(e){return e.segments.reduce((e,t)=>"literal"===t.kind?e+2:"param"===t.kind?e+1:e,0)}function W(e,t){let n,r={},l=-1;for(let o of t){let t=Fe(e,o);if(null===t)continue;let i=Ie(o);i>l&&(n=o,r=t,l=i)}return n?{route:n,params:r}:void 0}function G(e){let t=e.trim();return t&&"/"!==t?(t.startsWith("/")||(t="/"+t),t.endsWith("/")&&(t=t.slice(0,-1)),t):""}function Le(){if(typeof document>"u")return"";let e=document.querySelector("base");if(!e)return"";let t=e.getAttribute("href")||"";try{return G(new URL(t,window.location.origin).pathname)}catch{return G(t)}}function Re(e,t){let n=null==t?.base?Le():G(t.base);function r(){let e=window.location.pathname||"/";if(n&&e.startsWith(n)){let t=e.slice(n.length);return""===t?"/":t}return e}function l(e){return n?n+(e.startsWith("/")?e:"/"+e):e}let o=r(),i=Pe(e),a=W(o,i),u=g(o),s=g(a?.params??{}),c=g(U(window.location.search)),f=[],d=[],p=0;function h(e,t,n,r,l){let o=[...f];n&&o.push(n);let i=++p;if(0===o.length)return void r();let a=0;!function n(u){if(i!==p)return;if(!1===u)return void l?.();if("string"==typeof u)return void(u===e?r():b(u));if(a>=o.length)return void r();let s=o[a++](e,t);s instanceof Promise?s.then(n):n(s)}(void 0)}let v=!1;function m(e,t){let n=e.indexOf("?"),r=-1===n?e:e.slice(0,n),l=-1===n?{}:U(e.slice(n)),o=t?{...l,...t}:l,i={};for(let[e,t]of Object.entries(o))null!=t&&!1!==t&&(i[e]=String(t));return{pathname:r,stringQuery:i}}V&&=(V(),null);let y=()=>{let e=r(),t=u.value,n=c.value,o=W(e,i),a=U(window.location.search);h(e,t,o?.route.beforeEnter,()=>{s.value=o?.params??{},c.value=a,u.value=e;for(let n of d)try{n(e,t)}catch{}},()=>{history.pushState(null,"",l(t)+je(n))})};function _(e,t,n,r,o){s.value=r?.params??{},c.value=t,u.value=e;let i=l(e)+je(t);o?history.replaceState(null,"",i):history.pushState(null,"",i);for(let t of d)try{t(e,n)}catch{}}function b(e,t){v=!0;let{pathname:n,stringQuery:r}=m(e,t),l=u.value,o=W(n,i);h(n,l,o?.route.beforeEnter,()=>_(n,r,l,o,!1))}window.addEventListener("popstate",y),V=()=>window.removeEventListener("popstate",y);let x={current:u,params:s,query:c,base:n||"/",navigate:b,replace:function(e,t){v=!0;let{pathname:n,stringQuery:r}=m(e,t),l=u.value,o=W(n,i);h(n,l,o?.route.beforeEnter,()=>_(n,r,l,o,!0))},back:function(){history.back()},forward:function(){history.forward()},go:function(e){history.go(e)},isActive:function(e,t=!0){let n=u.value;return t?n===e:n===e||n.startsWith(e.endsWith("/")?e:e+"/")},resolve:function(t){let n=W(t,i);if(!n)return{matched:!1,params:{},route:void 0};let r=n.route.chain[n.route.chain.length-1];return{matched:!0,params:n.params,route:function e(t){for(let n of t){if(n.component===r)return n;if(n.children){let t=e(n.children);if(t)return t}}}(e)}},beforeEach:function(e){return f.push(e),()=>{let t=f.indexOf(e);-1!==t&&f.splice(t,1)}},afterEach:function(e){return d.push(e),()=>{let t=d.indexOf(e);-1!==t&&d.splice(t,1)}},routes:e,_flat:i,_guards:f,_base:n};return B&&console.warn("[Nix] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."),B=x,queueMicrotask(()=>{v||h(o,"",W(o,i)?.route.beforeEnter,()=>{},()=>{history.replaceState(null,"",l("/"));let e=W("/",i);u.value="/",s.value=e?.params??{},c.value={}})}),x}function ze(){return H()}var Be=class extends w{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return I`<div class="router-view">${()=>{let t=H(),n=W(t.current.value,t._flat);return n?e>=n.route.chain.length?I`<span></span>`:n.route.chain[e]():I`<div style="color:#f87171;padding:16px 0">
|
|
2
2
|
404 — Route not found: <strong>${t.current.value}</strong>
|
|
3
|
-
</div>`}}</div>`}},
|
|
4
|
-
href=${(
|
|
5
|
-
style=${()=>
|
|
6
|
-
@click=${t=>{t.preventDefault(),
|
|
7
|
-
>${t}</a>`}};function
|
|
3
|
+
</div>`}}</div>`}},Ve=class extends w{_to;_label;constructor(e,t){super(),this._to=e,this._label=t}render(){let e=this._to,t=this._label;return I`<a
|
|
4
|
+
href=${(H()._base||"")+(e.startsWith("/")?e:"/"+e)}
|
|
5
|
+
style=${()=>H().current.value===e?"color:#38bdf8;font-weight:700;text-decoration:none;cursor:pointer;padding:4px 10px;border-radius:4px;background:#0c2a3a":"color:#a3a3a3;text-decoration:none;cursor:pointer;padding:4px 10px;border-radius:4px"}
|
|
6
|
+
@click=${t=>{t.preventDefault(),H().navigate(e)}}
|
|
7
|
+
>${t}</a>`}};function He(){return I`
|
|
8
8
|
<span style="color:#52525b;font-size:13px;display:inline-flex;align-items:center;gap:6px">
|
|
9
9
|
<span class="nix-spinner" style="
|
|
10
10
|
display:inline-block;width:14px;height:14px;border-radius:50%;
|
|
@@ -14,8 +14,8 @@ var e=[],t=[],n=null,r=null,i=null,a=[];function o(e){a.push(i),i=e}function s()
|
|
|
14
14
|
Loading…
|
|
15
15
|
</span>
|
|
16
16
|
<style>@keyframes nix-spin{to{transform:rotate(360deg)}}</style>
|
|
17
|
-
`}function
|
|
17
|
+
`}function Ue(e){return I`
|
|
18
18
|
<span style="color:#f87171;font-size:13px">
|
|
19
19
|
⚠ ${e instanceof Error?e.message:String(e)}
|
|
20
20
|
</span>
|
|
21
|
-
`}var
|
|
21
|
+
`}var K=new Map,We=3e5,q=null,Ge=We;function Ke(){null===q&&(q=setInterval(()=>{let e=Date.now();for(let[t,n]of K)n.subscribers<=0&&e-n.fetchedAt>Ge&&K.delete(t);0===K.size&&null!==q&&(clearInterval(q),q=null)},6e4))}function J(e){return K.get(e)}function qe(e,t){let n=K.get(e);K.set(e,{data:t,fetchedAt:Date.now(),subscribers:n?.subscribers??0}),Ke()}function Je(e){let t=K.get(e);t&&t.subscribers++}function Ye(e){let t=K.get(e);t&&(t.subscribers=Math.max(0,t.subscribers-1))}function Xe(e,t){let n=K.get(e);return!!n&&Date.now()-n.fetchedAt<t}function Ze(e){void 0===e?K.clear():K.delete(e)}function Qe(e){Ge=e}function $e(e,t,n={}){let{fallback:r,errorFallback:l,resetOnRefresh:o=!1,invalidate:i,cacheKey:a,staleTime:u=0}=n,s=r??He(),c=l??Ue;return new class extends w{_state;_disposeWatcher;constructor(){super();let e=a?J(a):void 0;this._state=g(e?{status:"resolved",data:e.data}:{status:"pending"})}onMount(){a&&Je(a);let e=a?J(a):void 0;if(e&&Xe(a,u)||(e?this._fetch():this._run()),i){let e=!0;this._disposeWatcher=_(()=>{i.value,e?e=!1:(a&&K.delete(a),this._run())})}return()=>{this._disposeWatcher?.(),a&&Ye(a)}}_run(){(o||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){e().then(e=>{a&&qe(a,e),this._state.value={status:"resolved",data:e}},e=>{this._state.value={status:"error",error:e}})}render(){return I`<div class="nix-suspense" style="display:contents">${()=>{let e=this._state.value;return"pending"===e.status?s:"error"===e.status?c(e.error):t(e.data)}}</div>`}}}var Y=new Map,et=new FinalizationRegistry(({key:e,ref:t})=>{let n=Y.get(e);n&&(n.delete(t),0===n.size&&Y.delete(e))});function tt(e){K.delete(e);let t=Y.get(e);if(t){for(let e of t){let n=e.deref();n?n():t.delete(e)}0===t.size&&Y.delete(e)}}function nt(e,t,n={}){let{staleTime:r=0,refetchOnMount:l="always"}=n,o=J(e),i=g(o?"success":"pending"),a=g(o?.data),u=g(void 0),s=()=>{t().then(t=>{qe(e,t),a.value=t,u.value=void 0,i.value="success"},e=>{u.value=e,i.value="error"})},c=()=>{"pending"===i.peek()&&(a.value=void 0,u.value=void 0),s()};Y.has(e)||Y.set(e,new Set);let f=Y.get(e),d=new WeakRef(c);f.add(d),et.register(c,{key:e,ref:d});let p=Xe(e,r);return o?!1===l||"stale"===l&&p||"always"===l&&p&&r>0||s():c(),{status:i,data:a,error:u,refetch:()=>{K.delete(e),c()}}}function rt(e,t){let n=null;return()=>n?new n:$e(async()=>(n=(await e()).default,n),e=>new e,{fallback:t})}function it(e="Required"){return t=>null==t||""===t||Array.isArray(t)&&0===t.length?e:null}function X(e,t){return n=>"string"==typeof n&&n.length<e?t??`Minimum ${e} characters`:null}function at(e,t){return n=>"string"==typeof n&&n.length>e?t??`Maximum ${e} characters`:null}function Z(e,t="Invalid format"){return n=>"string"!=typeof n||e.test(n)?null:t}function ot(e="Invalid email"){return Z(/^[^\s@]+@[^\s@]+\.[^\s@]+$/,e)}function st(e,t){return n=>"number"==typeof n&&n<e?t??`Minimum value is ${e}`:null}function Q(e,t){return n=>"number"==typeof n&&n>e?t??`Maximum value is ${e}`:null}function ct(e){return e}const lt={required:it,minLength:X,maxLength:at,email:ot,pattern:Z,min:st,max:Q};function ut(e,t){return{...e,...t}}function $(e,t=[],n="blur"){let r=g(e),l=g(!1),o=g(!1),i=g(null),a=g(!1),u=v(()=>{if(i.value)return i.value;if(!("input"===n?o.value||l.value:"submit"===n?a.value:l.value))return null;for(let e of t){let t=e(r.value);if(t)return t}return null});function s(t){if(!t||!("value"in t))return e;let n=t;return"boolean"==typeof e?n.checked:"number"==typeof e?Number(n.value):n.value}return{value:r,error:u,touched:l,dirty:o,onInput:e=>{r.value=s(e.target),o.value=!0,i.value=null},onBlur:()=>{l.value=!0},reset:function(){r.value=e,l.value=!1,o.value=!1,i.value=null,a.value=!1},_setExternalError:function(e){i.value=e,e&&(l.value=!0)},_forceVisible:function(){l.value=!0,a.value=!0},_dispose:function(){u.dispose()}}}function dt(e,t={},n="blur"){function r(e){let r={};for(let l in e){let o=t[l]??[];r[l]=$(e[l],o,n)}return r}let l=g(e.map(r)),o=v(()=>l.value.length);return{fields:l,append:function(e){l.value=[...l.value,r(e)]},remove:function(e){let t=l.value;if(!(e<0||e>=t.length)){for(let n in t[e])t[e][n]._dispose();l.value=t.filter((t,n)=>n!==e)}},move:function(e,t){let n=[...l.value];if(e<0||e>=n.length||t<0||t>=n.length||e===t)return;let[r]=n.splice(e,1);n.splice(t,0,r),l.value=n},replace:function(e,t){let n=[...l.value];if(!(e<0||e>=n.length)){for(let t in n[e])n[e][t]._dispose();n[e]=r(t),l.value=n}},length:o,reset:function(){for(let e of l.value)for(let t in e)e[t]._dispose();l.value=e.map(r)},_dispose:function(){for(let e of l.value)for(let t in e)e[t]._dispose();o.dispose()}}}function ft(e,t={}){let n=t.validateOn??"blur",r={};for(let l in e){let o=t.validators?.[l]??[];r[l]=$(e[l],o,n)}let l=g(!1),o=g(0),i=v(()=>{let e={};for(let t in r)e[t]=r[t].value.value;return e}),a=v(()=>{let e={};for(let t in r){let n=r[t].error.value;n&&(e[t]=n)}return e}),u=v(()=>{for(let e in r)if(r[e].error.value)return!1;return!0}),s=v(()=>{for(let e in r)if(r[e].dirty.value)return!0;return!1}),c=v(()=>{for(let e in r)if(r[e].touched.value)return!0;return!1});function f(e){for(let t in e)r[t]?._setExternalError(e[t]??null)}return{fields:r,values:i,errors:a,valid:u,dirty:s,touched:c,isSubmitting:l,submitCount:o,handleSubmit:function(e){return n=>{n.preventDefault(),o.value++;for(let e in r)r[e]._forceVisible();let a=i.value;if(t.validate){let e=t.validate(a);if(e){let t={},n=!1;for(let r in e){let l=e[r],o=Array.isArray(l)?l[0]??null:l??null;o&&(t[r]=o,n=!0)}if(n)return void f(t)}}for(let e in r)if(r[e].error.value)return;let u=e(a);u instanceof Promise&&(l.value=!0,u.finally(()=>{l.value=!1}).catch(()=>{}))}},reset:function(){for(let e in r)r[e].reset();l.value=!1,o.value=0},setErrors:f,dispose:function(){i.dispose(),a.dispose(),u.dispose(),s.dispose(),c.dispose();for(let e in r)r[e]._dispose()}}}export{Ve as Link,w as NixComponent,Be as RouterView,h as Signal,y as batch,Ze as clearQueryCache,v as computed,Oe as createErrorBoundary,ft as createForm,E as createInjectionKey,Ce as createPortalOutlet,nt as createQuery,Re as createRouter,Ae as createStore,ct as createValidator,_ as effect,ot as email,ut as extendValidators,I as html,oe as inject,De as injectOutlet,tt as invalidateQueries,rt as lazy,Q as max,at as maxLength,st as min,X as minLength,ke as mount,ee as nextTick,Z as pattern,Te as portal,we as portalOutlet,ae as provide,Ee as provideOutlet,te as ref,ue as repeat,it as required,Qe as setQueryCacheTime,pe as showWhen,g as signal,$e as suspend,Se as transition,b as untrack,$ as useField,dt as useFieldArray,ze as useRouter,lt as validators,x as watch};
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deijose/nix-js",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.9-beta.0",
|
|
4
4
|
"description": "A lightweight, fully reactive micro-framework — no virtual DOM, no compiler, just signals and tagged templates.",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"
|
|
6
|
+
"author": "Deiver Vasquez",
|
|
7
|
+
"homepage": "https://nix-js.dev/",
|
|
7
8
|
"repository": {
|
|
8
9
|
"type": "git",
|
|
9
10
|
"url": "https://github.com/DeijoseDevelop/nix-js.git"
|
|
@@ -57,10 +58,10 @@
|
|
|
57
58
|
"happy-dom": "^20.8.3",
|
|
58
59
|
"terser": "^5.46.0",
|
|
59
60
|
"typescript": "~5.9.3",
|
|
60
|
-
"vite": "^8.0.0
|
|
61
|
+
"vite": "^8.0.0",
|
|
61
62
|
"vitest": "^4.0.18"
|
|
62
63
|
},
|
|
63
64
|
"overrides": {
|
|
64
|
-
"vite": "^8.0.0
|
|
65
|
+
"vite": "^8.0.0"
|
|
65
66
|
}
|
|
66
|
-
}
|
|
67
|
+
}
|
|
File without changes
|