zero-query 0.7.5 → 0.8.7

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 (65) hide show
  1. package/README.md +39 -30
  2. package/cli/commands/build.js +110 -1
  3. package/cli/commands/bundle.js +127 -50
  4. package/cli/commands/create.js +1 -1
  5. package/cli/commands/dev/devtools/index.js +56 -0
  6. package/cli/commands/dev/devtools/js/components.js +49 -0
  7. package/cli/commands/dev/devtools/js/core.js +409 -0
  8. package/cli/commands/dev/devtools/js/elements.js +413 -0
  9. package/cli/commands/dev/devtools/js/network.js +166 -0
  10. package/cli/commands/dev/devtools/js/performance.js +73 -0
  11. package/cli/commands/dev/devtools/js/router.js +105 -0
  12. package/cli/commands/dev/devtools/js/source.js +132 -0
  13. package/cli/commands/dev/devtools/js/stats.js +35 -0
  14. package/cli/commands/dev/devtools/js/tabs.js +79 -0
  15. package/cli/commands/dev/devtools/panel.html +95 -0
  16. package/cli/commands/dev/devtools/styles.css +244 -0
  17. package/cli/commands/dev/index.js +28 -3
  18. package/cli/commands/dev/logger.js +6 -1
  19. package/cli/commands/dev/overlay.js +377 -0
  20. package/cli/commands/dev/server.js +8 -0
  21. package/cli/commands/dev/watcher.js +26 -1
  22. package/cli/help.js +8 -5
  23. package/cli/scaffold/{scripts → app}/app.js +1 -1
  24. package/cli/scaffold/{scripts → app}/components/about.js +4 -4
  25. package/cli/scaffold/{scripts → app}/components/api-demo.js +1 -1
  26. package/cli/scaffold/app/components/home.js +137 -0
  27. package/cli/scaffold/{scripts → app}/routes.js +1 -1
  28. package/cli/scaffold/{scripts → app}/store.js +6 -6
  29. package/cli/scaffold/assets/.gitkeep +0 -0
  30. package/cli/scaffold/{styles/styles.css → global.css} +3 -2
  31. package/cli/scaffold/index.html +11 -11
  32. package/dist/zquery.dist.zip +0 -0
  33. package/dist/zquery.js +740 -226
  34. package/dist/zquery.min.js +2 -2
  35. package/index.d.ts +11 -11
  36. package/index.js +15 -10
  37. package/package.json +3 -2
  38. package/src/component.js +154 -139
  39. package/src/core.js +57 -11
  40. package/src/diff.js +256 -58
  41. package/src/expression.js +33 -3
  42. package/src/reactive.js +37 -5
  43. package/src/router.js +196 -7
  44. package/src/ssr.js +1 -1
  45. package/tests/component.test.js +582 -0
  46. package/tests/core.test.js +251 -0
  47. package/tests/diff.test.js +333 -2
  48. package/tests/expression.test.js +148 -0
  49. package/tests/http.test.js +108 -0
  50. package/tests/reactive.test.js +148 -0
  51. package/tests/router.test.js +317 -0
  52. package/tests/store.test.js +126 -0
  53. package/tests/utils.test.js +161 -2
  54. package/types/collection.d.ts +17 -2
  55. package/types/component.d.ts +10 -34
  56. package/types/misc.d.ts +13 -0
  57. package/types/router.d.ts +30 -1
  58. package/cli/commands/dev.old.js +0 -520
  59. package/cli/scaffold/scripts/components/home.js +0 -137
  60. /package/cli/scaffold/{scripts → app}/components/contacts/contacts.css +0 -0
  61. /package/cli/scaffold/{scripts → app}/components/contacts/contacts.html +0 -0
  62. /package/cli/scaffold/{scripts → app}/components/contacts/contacts.js +0 -0
  63. /package/cli/scaffold/{scripts → app}/components/counter.js +0 -0
  64. /package/cli/scaffold/{scripts → app}/components/not-found.js +0 -0
  65. /package/cli/scaffold/{scripts → app}/components/todos.js +0 -0
@@ -1,137 +0,0 @@
1
- // scripts/components/home.js — dashboard / landing page
2
- //
3
- // Demonstrates: $.component, state, render, mounted lifecycle,
4
- // signal + computed + effect (reactive primitives),
5
- // $.store integration, $.bus, template rendering
6
-
7
- $.component('home-page', {
8
- state: () => ({
9
- greeting: '',
10
- signalDemo: 0,
11
- }),
12
-
13
- mounted() {
14
- // $.signal() — fine-grained reactive primitive
15
- const count = $.signal(0);
16
-
17
- // $.computed() — derived reactive value that auto-updates
18
- const doubled = $.computed(() => count.value * 2);
19
-
20
- // $.effect() — runs whenever its dependencies change
21
- $.effect(() => {
22
- this.state.signalDemo = doubled.value;
23
- });
24
-
25
- // Store the signal setter so the button can use it
26
- this._signalCount = count;
27
-
28
- // Greet based on time of day
29
- const hour = new Date().getHours();
30
- this.state.greeting = hour < 12 ? 'Good morning'
31
- : hour < 18 ? 'Good afternoon'
32
- : 'Good evening';
33
-
34
- // Track page visit via the global store
35
- const store = $.getStore('main');
36
- store.dispatch('incrementVisits');
37
- },
38
-
39
- incrementSignal() {
40
- if (this._signalCount) {
41
- this._signalCount.value++;
42
- }
43
- },
44
-
45
- render() {
46
- const store = $.getStore('main');
47
- return `
48
- <div class="page-header">
49
- <h1>${this.state.greeting} 👋</h1>
50
- <p class="subtitle">Welcome to your new <strong>zQuery</strong> app. Explore the pages to see different features in action.</p>
51
- </div>
52
-
53
- <div class="card-grid">
54
- <div class="card card-accent">
55
- <h3>⚡ Reactive Signals</h3>
56
- <p>Fine-grained reactivity with <code>signal()</code>, <code>computed()</code>, and <code>effect()</code>.</p>
57
- <div class="signal-demo">
58
- <span class="signal-value">Doubled: ${this.state.signalDemo}</span>
59
- <button class="btn btn-sm" @click="incrementSignal">Increment Signal</button>
60
- </div>
61
- </div>
62
-
63
- <div class="card">
64
- <h3>🔢 Counter</h3>
65
- <p><code>computed</code> properties, <code>watch</code> callbacks, and <code>z-for</code> with <code>z-key</code> diffing.</p>
66
- <a z-link="/counter" class="btn btn-outline">Try It →</a>
67
- </div>
68
-
69
- <div class="card">
70
- <h3>✅ Todos</h3>
71
- <p>Global store, <code>z-key</code> keyed lists, DOM diffing. <strong>${store.getters.todoCount}</strong> items, <strong>${store.getters.doneCount}</strong> done.</p>
72
- <a z-link="/todos" class="btn btn-outline">Try It →</a>
73
- </div>
74
-
75
- <div class="card">
76
- <h3>📇 Contacts</h3>
77
- <p>External templates, scoped styles, and <code>z-key</code> keyed lists. <strong>${store.getters.contactCount}</strong> contacts, <strong>${store.getters.favoriteCount}</strong> ★ favorited.</p>
78
- <a z-link="/contacts" class="btn btn-outline">Try It →</a>
79
- </div>
80
-
81
- <div class="card">
82
- <h3>🌐 API Demo</h3>
83
- <p>Fetch data with <code>$.get()</code>, loading states, and <code>$.escapeHtml()</code>.</p>
84
- <a z-link="/api" class="btn btn-outline">Try It →</a>
85
- </div>
86
- </div>
87
-
88
- <div class="card card-muted">
89
- <h3>📊 App Stats</h3>
90
- <div class="stats-grid">
91
- <div class="stat-group">
92
- <span class="stat-group-title">🏠 General</span>
93
- <div class="stat-group-values">
94
- <div class="stat">
95
- <span class="stat-value">${store.state.visits}</span>
96
- <span class="stat-label">Page Views</span>
97
- </div>
98
- </div>
99
- </div>
100
-
101
- <div class="stat-group">
102
- <span class="stat-group-title">✅ Todos</span>
103
- <div class="stat-group-values">
104
- <div class="stat">
105
- <span class="stat-value">${store.getters.todoCount}</span>
106
- <span class="stat-label">Total</span>
107
- </div>
108
- <div class="stat">
109
- <span class="stat-value">${store.getters.pendingCount}</span>
110
- <span class="stat-label">Pending</span>
111
- </div>
112
- <div class="stat">
113
- <span class="stat-value">${store.getters.doneCount}</span>
114
- <span class="stat-label">Done</span>
115
- </div>
116
- </div>
117
- </div>
118
-
119
- <div class="stat-group">
120
- <span class="stat-group-title">📇 Contacts</span>
121
- <div class="stat-group-values">
122
- <div class="stat">
123
- <span class="stat-value">${store.getters.contactCount}</span>
124
- <span class="stat-label">Total</span>
125
- </div>
126
- <div class="stat">
127
- <span class="stat-value">${store.getters.favoriteCount}</span>
128
- <span class="stat-label">★ Favorited</span>
129
- </div>
130
- </div>
131
- </div>
132
- </div>
133
- <small class="muted">Stats powered by <code>$.store()</code> getters — visit count tracked globally.</small>
134
- </div>
135
- `;
136
- }
137
- });