zero-query 0.9.9 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -33
- package/cli/args.js +1 -1
- package/cli/commands/build.js +2 -2
- package/cli/commands/bundle.js +21 -18
- package/cli/commands/create.js +9 -2
- package/cli/commands/dev/devtools/index.js +1 -1
- package/cli/commands/dev/devtools/js/core.js +14 -14
- package/cli/commands/dev/devtools/js/elements.js +4 -4
- package/cli/commands/dev/devtools/js/stats.js +1 -1
- package/cli/commands/dev/devtools/styles.css +2 -2
- package/cli/commands/dev/index.js +2 -2
- package/cli/commands/dev/logger.js +1 -1
- package/cli/commands/dev/overlay.js +21 -14
- package/cli/commands/dev/server.js +5 -5
- package/cli/commands/dev/validator.js +7 -7
- package/cli/commands/dev/watcher.js +6 -6
- package/cli/help.js +3 -3
- package/cli/index.js +1 -1
- package/cli/scaffold/default/app/app.js +17 -18
- package/cli/scaffold/default/app/components/about.js +9 -9
- package/cli/scaffold/default/app/components/api-demo.js +6 -6
- package/cli/scaffold/default/app/components/contact-card.js +4 -4
- package/cli/scaffold/default/app/components/contacts/contacts.css +2 -2
- package/cli/scaffold/default/app/components/contacts/contacts.html +3 -3
- package/cli/scaffold/default/app/components/contacts/contacts.js +11 -11
- package/cli/scaffold/default/app/components/counter.js +8 -8
- package/cli/scaffold/default/app/components/home.js +13 -13
- package/cli/scaffold/default/app/components/not-found.js +1 -1
- package/cli/scaffold/default/app/components/playground/playground.css +1 -1
- package/cli/scaffold/default/app/components/playground/playground.html +11 -11
- package/cli/scaffold/default/app/components/playground/playground.js +11 -11
- package/cli/scaffold/default/app/components/todos.js +8 -8
- package/cli/scaffold/default/app/components/toolkit/toolkit.css +1 -1
- package/cli/scaffold/default/app/components/toolkit/toolkit.html +4 -4
- package/cli/scaffold/default/app/components/toolkit/toolkit.js +7 -7
- package/cli/scaffold/default/app/routes.js +1 -1
- package/cli/scaffold/default/app/store.js +1 -1
- package/cli/scaffold/default/global.css +2 -2
- package/cli/scaffold/default/index.html +2 -2
- package/cli/scaffold/minimal/app/app.js +6 -7
- package/cli/scaffold/minimal/app/components/about.js +5 -5
- package/cli/scaffold/minimal/app/components/counter.js +6 -6
- package/cli/scaffold/minimal/app/components/home.js +8 -8
- package/cli/scaffold/minimal/app/components/not-found.js +1 -1
- package/cli/scaffold/minimal/app/routes.js +1 -1
- package/cli/scaffold/minimal/app/store.js +1 -1
- package/cli/scaffold/minimal/global.css +2 -2
- package/cli/scaffold/minimal/index.html +1 -1
- package/cli/scaffold/ssr/app/app.js +1 -2
- package/cli/scaffold/ssr/app/components/about.js +5 -5
- package/cli/scaffold/ssr/app/components/home.js +2 -2
- package/cli/scaffold/ssr/app/components/not-found.js +2 -2
- package/cli/scaffold/ssr/app/routes.js +1 -1
- package/cli/scaffold/ssr/global.css +3 -4
- package/cli/scaffold/ssr/index.html +2 -2
- package/cli/scaffold/ssr/server/index.js +26 -25
- package/cli/utils.js +6 -6
- package/dist/zquery.dist.zip +0 -0
- package/dist/zquery.js +508 -227
- package/dist/zquery.min.js +2 -2
- package/index.d.ts +16 -13
- package/index.js +7 -5
- package/package.json +3 -3
- package/src/component.js +64 -63
- package/src/core.js +15 -15
- package/src/diff.js +38 -38
- package/src/errors.js +17 -17
- package/src/expression.js +15 -17
- package/src/http.js +4 -4
- package/src/reactive.js +75 -9
- package/src/router.js +104 -24
- package/src/ssr.js +28 -28
- package/src/store.js +103 -21
- package/src/utils.js +64 -12
- package/tests/audit.test.js +143 -15
- package/tests/cli.test.js +20 -20
- package/tests/component.test.js +121 -121
- package/tests/core.test.js +56 -56
- package/tests/diff.test.js +42 -42
- package/tests/errors.test.js +5 -5
- package/tests/expression.test.js +58 -53
- package/tests/http.test.js +20 -20
- package/tests/reactive.test.js +185 -24
- package/tests/router.test.js +501 -74
- package/tests/ssr.test.js +15 -13
- package/tests/store.test.js +264 -23
- package/tests/test-minifier.js +153 -0
- package/tests/test-ssr.js +27 -0
- package/tests/utils.test.js +163 -26
- package/types/collection.d.ts +2 -2
- package/types/component.d.ts +5 -5
- package/types/errors.d.ts +3 -3
- package/types/http.d.ts +3 -3
- package/types/misc.d.ts +9 -9
- package/types/reactive.d.ts +25 -3
- package/types/router.d.ts +10 -6
- package/types/ssr.d.ts +2 -2
- package/types/store.d.ts +40 -5
- package/types/utils.d.ts +1 -1
package/types/reactive.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Reactive primitives
|
|
2
|
+
* Reactive primitives - deep proxies and signals.
|
|
3
3
|
*
|
|
4
4
|
* @module reactive
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
/** Marker properties added to every reactive proxy. */
|
|
8
8
|
export interface ReactiveProxy<T extends object = object> {
|
|
9
|
-
/** Always `true`
|
|
9
|
+
/** Always `true` - indicates this object is wrapped in a reactive Proxy. */
|
|
10
10
|
readonly __isReactive: true;
|
|
11
11
|
/** The original un-proxied object. */
|
|
12
12
|
readonly __raw: T;
|
|
@@ -65,7 +65,7 @@ export function computed<T>(fn: () => T): Signal<T>;
|
|
|
65
65
|
* Re-runs automatically when any tracked signal changes.
|
|
66
66
|
*
|
|
67
67
|
* @param fn The effect function. Executed immediately on creation, then on signal changes.
|
|
68
|
-
* @returns A dispose function
|
|
68
|
+
* @returns A dispose function - calling it stops tracking and prevents re-runs.
|
|
69
69
|
*
|
|
70
70
|
* @example
|
|
71
71
|
* const count = signal(0);
|
|
@@ -74,3 +74,25 @@ export function computed<T>(fn: () => T): Signal<T>;
|
|
|
74
74
|
* stop(); // effect no longer runs
|
|
75
75
|
*/
|
|
76
76
|
export function effect(fn: () => void): () => void;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Batch multiple signal writes - subscribers and effects fire once at the end.
|
|
80
|
+
* Nested batches are merged into the outermost one.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* const a = signal(0);
|
|
84
|
+
* const b = signal(0);
|
|
85
|
+
* batch(() => {
|
|
86
|
+
* a.value = 1;
|
|
87
|
+
* b.value = 2;
|
|
88
|
+
* }); // effects run once with both values updated
|
|
89
|
+
*/
|
|
90
|
+
export function batch(fn: () => void): void;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Execute a function without tracking signal reads as dependencies.
|
|
94
|
+
* Useful inside effects when you need to read a signal without subscribing.
|
|
95
|
+
*
|
|
96
|
+
* @returns The return value of `fn`.
|
|
97
|
+
*/
|
|
98
|
+
export function untracked<T>(fn: () => T): T;
|
package/types/router.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* SPA Router
|
|
2
|
+
* SPA Router - history and hash-based client-side routing.
|
|
3
3
|
*
|
|
4
4
|
* @module router
|
|
5
5
|
*/
|
|
@@ -39,7 +39,11 @@ export interface NavigationContext {
|
|
|
39
39
|
|
|
40
40
|
/** Router configuration. */
|
|
41
41
|
export interface RouterConfig {
|
|
42
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* Outlet element where route components are rendered.
|
|
44
|
+
* If omitted, the router auto-detects a `<z-outlet>` element in the DOM.
|
|
45
|
+
* Acts as an explicit override of the default `<z-outlet>` lookup.
|
|
46
|
+
*/
|
|
43
47
|
el?: string | Element;
|
|
44
48
|
/** Routing mode (default: `'history'`; `'hash'` for file:// or hash routing). */
|
|
45
49
|
mode?: 'history' | 'hash';
|
|
@@ -86,7 +90,7 @@ export interface RouterInstance {
|
|
|
86
90
|
remove(path: string): RouterInstance;
|
|
87
91
|
|
|
88
92
|
/**
|
|
89
|
-
* Navigation guard
|
|
93
|
+
* Navigation guard - runs before each route change.
|
|
90
94
|
* Return `false` to cancel, or a `string` to redirect.
|
|
91
95
|
*/
|
|
92
96
|
beforeEach(
|
|
@@ -111,10 +115,10 @@ export interface RouterInstance {
|
|
|
111
115
|
|
|
112
116
|
/**
|
|
113
117
|
* Push a lightweight history entry for in-component UI state (modal, tab, panel).
|
|
114
|
-
* The URL does NOT change
|
|
118
|
+
* The URL does NOT change - only a history entry is added so the back button
|
|
115
119
|
* can undo the UI change before navigating away from the route.
|
|
116
|
-
* @param key
|
|
117
|
-
* @param data
|
|
120
|
+
* @param key - identifier for the substate (e.g. 'modal', 'tab')
|
|
121
|
+
* @param data - arbitrary serializable state
|
|
118
122
|
* @example
|
|
119
123
|
* router.pushSubstate('modal', { id: 'confirm-delete' });
|
|
120
124
|
*/
|
package/types/ssr.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Server-Side Rendering
|
|
2
|
+
* Server-Side Rendering - render components to HTML strings.
|
|
3
3
|
*
|
|
4
4
|
* @module ssr
|
|
5
5
|
*/
|
|
@@ -64,6 +64,6 @@ export function createSSRApp(): SSRApp;
|
|
|
64
64
|
export function renderToString(definition: ComponentDefinition, props?: Record<string, any>): string;
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
|
-
* Escape HTML entities
|
|
67
|
+
* Escape HTML entities - exposed for use in SSR templates.
|
|
68
68
|
*/
|
|
69
69
|
export function escapeHtml(str: string): string;
|
package/types/store.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Store
|
|
2
|
+
* Store - reactive global state management.
|
|
3
3
|
*
|
|
4
4
|
* @module store
|
|
5
5
|
*/
|
|
@@ -26,6 +26,9 @@ export interface StoreConfig<
|
|
|
26
26
|
|
|
27
27
|
/** Maximum number of action history entries to keep (default `1000`). */
|
|
28
28
|
maxHistory?: number;
|
|
29
|
+
|
|
30
|
+
/** Maximum number of undo checkpoints to keep (default `50`). */
|
|
31
|
+
maxUndo?: number;
|
|
29
32
|
}
|
|
30
33
|
|
|
31
34
|
/** A store action history entry. */
|
|
@@ -62,10 +65,10 @@ export interface StoreInstance<
|
|
|
62
65
|
|
|
63
66
|
/**
|
|
64
67
|
* Subscribe to changes on a specific state key.
|
|
65
|
-
* Callback receives `(newValue, oldValue
|
|
68
|
+
* Callback receives `(key, newValue, oldValue)`.
|
|
66
69
|
* @returns An unsubscribe function.
|
|
67
70
|
*/
|
|
68
|
-
subscribe(key: string, fn: (
|
|
71
|
+
subscribe(key: string, fn: (key: string, value: any, oldValue: any) => void): () => void;
|
|
69
72
|
|
|
70
73
|
/**
|
|
71
74
|
* Subscribe to all state changes (wildcard).
|
|
@@ -86,8 +89,40 @@ export interface StoreInstance<
|
|
|
86
89
|
*/
|
|
87
90
|
use(fn: (actionName: string, args: any[], state: S) => boolean | void): StoreInstance<S, A, G>;
|
|
88
91
|
|
|
89
|
-
/**
|
|
90
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Replace state and clear action history.
|
|
94
|
+
* If no argument, resets to the original initial state.
|
|
95
|
+
*/
|
|
96
|
+
reset(initialState?: Partial<S>): void;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Batch multiple state changes - subscribers fire once at the end
|
|
100
|
+
* with only the latest value per key.
|
|
101
|
+
*/
|
|
102
|
+
batch(fn: (state: S) => void): void;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Save a state snapshot for undo. Call before making changes you want to be undoable.
|
|
106
|
+
*/
|
|
107
|
+
checkpoint(): void;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Undo to the last checkpoint.
|
|
111
|
+
* @returns `true` if undo was performed, `false` if nothing to undo.
|
|
112
|
+
*/
|
|
113
|
+
undo(): boolean;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Redo the last undone state change.
|
|
117
|
+
* @returns `true` if redo was performed, `false` if nothing to redo.
|
|
118
|
+
*/
|
|
119
|
+
redo(): boolean;
|
|
120
|
+
|
|
121
|
+
/** Whether undo is available. */
|
|
122
|
+
readonly canUndo: boolean;
|
|
123
|
+
|
|
124
|
+
/** Whether redo is available. */
|
|
125
|
+
readonly canRedo: boolean;
|
|
91
126
|
}
|
|
92
127
|
|
|
93
128
|
/** Create a new global reactive store. */
|
package/types/utils.d.ts
CHANGED