zero-query 0.9.8 → 1.0.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 +55 -31
- package/cli/args.js +1 -1
- package/cli/commands/build.js +2 -2
- package/cli/commands/bundle.js +15 -15
- package/cli/commands/create.js +41 -7
- 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 +4 -2
- package/cli/index.js +2 -2
- 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 +29 -0
- package/cli/scaffold/ssr/app/components/about.js +28 -0
- package/cli/scaffold/ssr/app/components/home.js +37 -0
- package/cli/scaffold/ssr/app/components/not-found.js +15 -0
- package/cli/scaffold/ssr/app/routes.js +6 -0
- package/cli/scaffold/ssr/global.css +113 -0
- package/cli/scaffold/ssr/index.html +31 -0
- package/cli/scaffold/ssr/package.json +8 -0
- package/cli/scaffold/ssr/server/index.js +118 -0
- package/cli/utils.js +6 -6
- package/dist/zquery.dist.zip +0 -0
- package/dist/zquery.js +565 -228
- package/dist/zquery.min.js +2 -2
- package/index.d.ts +25 -12
- package/index.js +11 -7
- package/package.json +9 -3
- package/src/component.js +64 -63
- package/src/core.js +15 -15
- package/src/diff.js +38 -38
- package/src/errors.js +72 -18
- package/src/expression.js +15 -17
- package/src/http.js +4 -4
- package/src/package.json +1 -0
- package/src/reactive.js +75 -9
- package/src/router.js +104 -24
- package/src/ssr.js +133 -39
- 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 +425 -147
- 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 +444 -10
- package/tests/store.test.js +264 -23
- 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 +36 -4
- 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 +22 -2
- package/types/store.d.ts +40 -5
- package/types/utils.d.ts +1 -1
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
|
*/
|
|
@@ -11,6 +11,9 @@ export interface SSRApp {
|
|
|
11
11
|
/** Register a component for SSR. */
|
|
12
12
|
component(name: string, definition: ComponentDefinition): SSRApp;
|
|
13
13
|
|
|
14
|
+
/** Check whether a component is registered. */
|
|
15
|
+
has(name: string): boolean;
|
|
16
|
+
|
|
14
17
|
/**
|
|
15
18
|
* Render a component to an HTML string.
|
|
16
19
|
* @param componentName Registered component name.
|
|
@@ -20,9 +23,16 @@ export interface SSRApp {
|
|
|
20
23
|
renderToString(
|
|
21
24
|
componentName: string,
|
|
22
25
|
props?: Record<string, any>,
|
|
23
|
-
options?: { hydrate?: boolean },
|
|
26
|
+
options?: { hydrate?: boolean; mode?: 'html' | 'fragment' },
|
|
24
27
|
): Promise<string>;
|
|
25
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Render multiple components as a batch.
|
|
31
|
+
*/
|
|
32
|
+
renderBatch(
|
|
33
|
+
entries: Array<{ name: string; props?: Record<string, any>; options?: { hydrate?: boolean; mode?: 'html' | 'fragment' } }>,
|
|
34
|
+
): Promise<string[]>;
|
|
35
|
+
|
|
26
36
|
/**
|
|
27
37
|
* Render a full HTML page with a component mounted in a shell.
|
|
28
38
|
*/
|
|
@@ -30,11 +40,16 @@ export interface SSRApp {
|
|
|
30
40
|
component?: string;
|
|
31
41
|
props?: Record<string, any>;
|
|
32
42
|
title?: string;
|
|
43
|
+
description?: string;
|
|
33
44
|
styles?: string[];
|
|
34
45
|
scripts?: string[];
|
|
35
46
|
lang?: string;
|
|
36
47
|
meta?: string;
|
|
37
48
|
bodyAttrs?: string;
|
|
49
|
+
head?: {
|
|
50
|
+
canonical?: string;
|
|
51
|
+
og?: Record<string, string>;
|
|
52
|
+
};
|
|
38
53
|
}): Promise<string>;
|
|
39
54
|
}
|
|
40
55
|
|
|
@@ -47,3 +62,8 @@ export function createSSRApp(): SSRApp;
|
|
|
47
62
|
* @param props Props to pass.
|
|
48
63
|
*/
|
|
49
64
|
export function renderToString(definition: ComponentDefinition, props?: Record<string, any>): string;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Escape HTML entities - exposed for use in SSR templates.
|
|
68
|
+
*/
|
|
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