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.
Files changed (99) hide show
  1. package/README.md +34 -33
  2. package/cli/args.js +1 -1
  3. package/cli/commands/build.js +2 -2
  4. package/cli/commands/bundle.js +21 -18
  5. package/cli/commands/create.js +9 -2
  6. package/cli/commands/dev/devtools/index.js +1 -1
  7. package/cli/commands/dev/devtools/js/core.js +14 -14
  8. package/cli/commands/dev/devtools/js/elements.js +4 -4
  9. package/cli/commands/dev/devtools/js/stats.js +1 -1
  10. package/cli/commands/dev/devtools/styles.css +2 -2
  11. package/cli/commands/dev/index.js +2 -2
  12. package/cli/commands/dev/logger.js +1 -1
  13. package/cli/commands/dev/overlay.js +21 -14
  14. package/cli/commands/dev/server.js +5 -5
  15. package/cli/commands/dev/validator.js +7 -7
  16. package/cli/commands/dev/watcher.js +6 -6
  17. package/cli/help.js +3 -3
  18. package/cli/index.js +1 -1
  19. package/cli/scaffold/default/app/app.js +17 -18
  20. package/cli/scaffold/default/app/components/about.js +9 -9
  21. package/cli/scaffold/default/app/components/api-demo.js +6 -6
  22. package/cli/scaffold/default/app/components/contact-card.js +4 -4
  23. package/cli/scaffold/default/app/components/contacts/contacts.css +2 -2
  24. package/cli/scaffold/default/app/components/contacts/contacts.html +3 -3
  25. package/cli/scaffold/default/app/components/contacts/contacts.js +11 -11
  26. package/cli/scaffold/default/app/components/counter.js +8 -8
  27. package/cli/scaffold/default/app/components/home.js +13 -13
  28. package/cli/scaffold/default/app/components/not-found.js +1 -1
  29. package/cli/scaffold/default/app/components/playground/playground.css +1 -1
  30. package/cli/scaffold/default/app/components/playground/playground.html +11 -11
  31. package/cli/scaffold/default/app/components/playground/playground.js +11 -11
  32. package/cli/scaffold/default/app/components/todos.js +8 -8
  33. package/cli/scaffold/default/app/components/toolkit/toolkit.css +1 -1
  34. package/cli/scaffold/default/app/components/toolkit/toolkit.html +4 -4
  35. package/cli/scaffold/default/app/components/toolkit/toolkit.js +7 -7
  36. package/cli/scaffold/default/app/routes.js +1 -1
  37. package/cli/scaffold/default/app/store.js +1 -1
  38. package/cli/scaffold/default/global.css +2 -2
  39. package/cli/scaffold/default/index.html +2 -2
  40. package/cli/scaffold/minimal/app/app.js +6 -7
  41. package/cli/scaffold/minimal/app/components/about.js +5 -5
  42. package/cli/scaffold/minimal/app/components/counter.js +6 -6
  43. package/cli/scaffold/minimal/app/components/home.js +8 -8
  44. package/cli/scaffold/minimal/app/components/not-found.js +1 -1
  45. package/cli/scaffold/minimal/app/routes.js +1 -1
  46. package/cli/scaffold/minimal/app/store.js +1 -1
  47. package/cli/scaffold/minimal/global.css +2 -2
  48. package/cli/scaffold/minimal/index.html +1 -1
  49. package/cli/scaffold/ssr/app/app.js +1 -2
  50. package/cli/scaffold/ssr/app/components/about.js +5 -5
  51. package/cli/scaffold/ssr/app/components/home.js +2 -2
  52. package/cli/scaffold/ssr/app/components/not-found.js +2 -2
  53. package/cli/scaffold/ssr/app/routes.js +1 -1
  54. package/cli/scaffold/ssr/global.css +3 -4
  55. package/cli/scaffold/ssr/index.html +2 -2
  56. package/cli/scaffold/ssr/server/index.js +26 -25
  57. package/cli/utils.js +6 -6
  58. package/dist/zquery.dist.zip +0 -0
  59. package/dist/zquery.js +508 -227
  60. package/dist/zquery.min.js +2 -2
  61. package/index.d.ts +16 -13
  62. package/index.js +7 -5
  63. package/package.json +3 -3
  64. package/src/component.js +64 -63
  65. package/src/core.js +15 -15
  66. package/src/diff.js +38 -38
  67. package/src/errors.js +17 -17
  68. package/src/expression.js +15 -17
  69. package/src/http.js +4 -4
  70. package/src/reactive.js +75 -9
  71. package/src/router.js +104 -24
  72. package/src/ssr.js +28 -28
  73. package/src/store.js +103 -21
  74. package/src/utils.js +64 -12
  75. package/tests/audit.test.js +143 -15
  76. package/tests/cli.test.js +20 -20
  77. package/tests/component.test.js +121 -121
  78. package/tests/core.test.js +56 -56
  79. package/tests/diff.test.js +42 -42
  80. package/tests/errors.test.js +5 -5
  81. package/tests/expression.test.js +58 -53
  82. package/tests/http.test.js +20 -20
  83. package/tests/reactive.test.js +185 -24
  84. package/tests/router.test.js +501 -74
  85. package/tests/ssr.test.js +15 -13
  86. package/tests/store.test.js +264 -23
  87. package/tests/test-minifier.js +153 -0
  88. package/tests/test-ssr.js +27 -0
  89. package/tests/utils.test.js +163 -26
  90. package/types/collection.d.ts +2 -2
  91. package/types/component.d.ts +5 -5
  92. package/types/errors.d.ts +3 -3
  93. package/types/http.d.ts +3 -3
  94. package/types/misc.d.ts +9 -9
  95. package/types/reactive.d.ts +25 -3
  96. package/types/router.d.ts +10 -6
  97. package/types/ssr.d.ts +2 -2
  98. package/types/store.d.ts +40 -5
  99. package/types/utils.d.ts +1 -1
@@ -1,12 +1,12 @@
1
1
  /**
2
- * Reactive primitives deep proxies and signals.
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` indicates this object is wrapped in a reactive Proxy. */
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 calling it stops tracking and prevents re-runs.
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 history and hash-based client-side routing.
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
- /** Outlet element where route components are rendered. */
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 runs before each route change.
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 only a history entry is added so the back button
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 identifier for the substate (e.g. 'modal', 'tab')
117
- * @param data arbitrary serializable state
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 render components to HTML strings.
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 exposed for use in SSR templates.
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 reactive global state management.
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, key)`.
68
+ * Callback receives `(key, newValue, oldValue)`.
66
69
  * @returns An unsubscribe function.
67
70
  */
68
- subscribe(key: string, fn: (value: any, oldValue: any, key: string) => void): () => void;
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
- /** Replace state and clear action history. */
90
- reset(initialState: Partial<S>): void;
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
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Utility functions debounce, throttle, strings, objects, URL, storage, event bus.
2
+ * Utility functions - debounce, throttle, strings, objects, URL, storage, event bus.
3
3
  *
4
4
  * @module utils
5
5
  */