@adukiorg/anza 0.2.0 → 0.2.3

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 (83) hide show
  1. package/CHANGELOG.md +90 -4
  2. package/README.md +97 -133
  3. package/bin/anza/anza-linux-arm64 +0 -0
  4. package/bin/anza/anza-linux-x64 +0 -0
  5. package/bin/anza/anza-macos-arm64 +0 -0
  6. package/bin/anza/anza-macos-x64 +0 -0
  7. package/bin/anza/anza-windows-x64.exe +0 -0
  8. package/bin/anza/find.js +35 -0
  9. package/bin/anza/index.js +34 -0
  10. package/bin/anza/launch.js +19 -0
  11. package/bin/common/index.js +7 -0
  12. package/bin/common/logs.js +62 -0
  13. package/bin/create/copy.js +18 -0
  14. package/bin/create/index.js +45 -0
  15. package/bin/create/run.js +210 -0
  16. package/bin/create/write.js +19 -0
  17. package/importmap.json +4 -0
  18. package/package.json +16 -10
  19. package/src/core/offline/{usage.md → notes/usage.md} +11 -1
  20. package/src/core/router/boot.js +82 -0
  21. package/src/core/router/cascade.js +76 -0
  22. package/src/core/router/container.js +63 -72
  23. package/src/core/router/graph.js +144 -0
  24. package/src/core/router/index.js +12 -2
  25. package/src/core/router/intercept.js +26 -7
  26. package/src/core/router/lca.js +58 -0
  27. package/src/core/router/match.js +49 -36
  28. package/src/core/router/notes/audit-old.md +887 -0
  29. package/src/core/router/notes/audti.md +773 -0
  30. package/src/core/router/notes/tasks.md +473 -0
  31. package/src/core/router/{usage.md → notes/usage.md} +57 -35
  32. package/src/core/router/sync/tab.js +6 -4
  33. package/src/core/router/transitions.js +35 -8
  34. package/src/core/router/trie.js +130 -0
  35. package/src/core/security/{usage.md → notes/usage.md} +1 -2
  36. package/src/core/storage/{usage.md → notes/usage.md} +6 -6
  37. package/src/core/theme/index.js +78 -0
  38. package/src/core/ui/define/index.js +2 -1
  39. package/src/core/ui/define/orchestrator.js +10 -4
  40. package/src/core/ui/defs/dock.js +134 -0
  41. package/src/core/ui/defs/index.js +20 -0
  42. package/src/core/ui/defs/page.js +89 -0
  43. package/src/core/ui/defs/part.js +28 -0
  44. package/src/core/ui/defs/spec.js +96 -0
  45. package/src/core/ui/defs/view.js +23 -0
  46. package/src/core/ui/index.js +16 -3
  47. package/src/core/ui/notes/definations.md +979 -0
  48. package/src/tokens/index.css +1 -0
  49. package/src/tokens/semantic/contrast.css +18 -0
  50. package/src/tokens/semantic/transitions.css +32 -0
  51. package/types/core/platform/index.d.ts +39 -10
  52. package/types/core/router/index.d.ts +9 -0
  53. package/types/core/theme/index.d.ts +18 -0
  54. package/types/core/ui/index.d.ts +11 -0
  55. package/types/index.d.ts +1 -0
  56. package/bin/anza.js +0 -63
  57. package/bin/create.js +0 -150
  58. package/src/core/api/plan.md +0 -209
  59. package/src/core/events/missing.md +0 -103
  60. package/src/core/events/plan.md +0 -177
  61. package/src/core/offline/missing.md +0 -89
  62. package/src/core/offline/plan.md +0 -143
  63. package/src/core/platform/missing.md +0 -119
  64. package/src/core/platform/platform.d.ts +0 -88
  65. package/src/core/router/missing.md +0 -716
  66. package/src/core/router/outlet.js +0 -139
  67. package/src/core/router/plan.md +0 -370
  68. package/src/core/security/missing.md +0 -97
  69. package/src/core/state/missing.md +0 -165
  70. package/src/core/storage/missing.md +0 -165
  71. package/src/core/storage/plan.md +0 -69
  72. package/src/core/ui/implementation.md +0 -170
  73. package/src/core/ui/plan.md +0 -510
  74. package/src/core/ui/ui.types.md +0 -890
  75. /package/src/core/animations/{usage.md → notes/usage.md} +0 -0
  76. /package/src/core/api/{usage.md → notes/usage.md} +0 -0
  77. /package/src/core/events/{usage.md → notes/usage.md} +0 -0
  78. /package/src/core/platform/{usage.md → notes/usage.md} +0 -0
  79. /package/src/core/state/{usage.md → notes/usage.md} +0 -0
  80. /package/src/core/ui/{usage.md → notes/usage.md} +0 -0
  81. /package/src/core/ui/{watch.md → notes/watch.md} +0 -0
  82. /package/src/core/workers/{plan.md → notes/plan.md} +0 -0
  83. /package/src/core/workers/{usage.md → notes/usage.md} +0 -0
@@ -1,165 +0,0 @@
1
- # State Missing Support
2
-
3
- This document tracks remaining support, runtime bugs, type mismatches, and performance optimization work for `src/core/state`. Implemented behavior belongs in `usage.md` (or core documentation); unsupported, untyped, or under-tested behavior belongs here until it is built and verified.
4
-
5
- ---
6
-
7
- ## 0. Toolchain and Naming Rules
8
-
9
- Heavy validation, static analysis, and code generation belong in `tools/`, not in browser runtime modules.
10
-
11
- Current toolchain state support requirements:
12
- - Analyze `state` initialization and usage patterns statically.
13
- - Detect mutations violating the immutability discipline.
14
- - Generate unified type definitions for state domains.
15
-
16
- Naming rules for state support:
17
- - Prefer one-word files: `store.js`, `derived.js`, `persist.js`, `sync.js`, `index.js`.
18
- - Plural folders: `tests/`, `types/`.
19
- - Single-word methods: `get`, `set`, `batch`, `sync`, `derived`, `clear`, `reset`, `estimate`, `persist`.
20
- - Single-word events: `change`, `hydrate`, `quota`, `error`.
21
- - Avoid compound names where single words carry full meaning in context.
22
-
23
- ---
24
-
25
- ## 1. Critical Runtime and Type Gaps
26
-
27
- ### 1.1. Storage Type Mismatches
28
- - **Status**: Critical mismatch.
29
- - **Files**:
30
- - `types/core/state/index.d.ts`
31
- - `src/core/state/persist.js`
32
- - **Problem**:
33
- The type declaration file defines `storage` with `persist(store, options)` and `hydrate(store, name)`. The actual runtime `storage` export is an instance of `PlatformStorage` exposing CRUD and system queries: `get(store, key)`, `set(store, key, val)`, `delete(store, key)`, `query(store, filter)`, `estimate()`, `persist()`, and `isPersisted()`.
34
- - **Expected Support**:
35
- - Align `types/core/state/index.d.ts` to expose the true `PlatformStorage` interface.
36
- - Implement helper hooks in the store or `persist.js` to simplify store-wide persistence if required, but maintain structural parity.
37
-
38
- ### 1.2. Writable Store Event and Helper Omissions
39
- - **Status**: Runtime gap.
40
- - **Files**:
41
- - `src/core/state/store.js`
42
- - `src/core/state/index.js`
43
- - **Problem**:
44
- The State Management specification (§15) defines `store.broadcast(channelName)` as a method directly on the store instance for cross-tab replication. Currently, this functionality is decoupled into a standalone `sync(store, keys, channelName)` function. Similarly, `store.derived(keys, compute)` is specified but not present on the store instance class.
45
- - **Expected Support**:
46
- - Add a delegate helper `broadcast(channelName, keys?)` to `ReactiveStore` mapping directly to the `sync` utility.
47
- - Add a delegate helper `derived(keys, compute)` to `ReactiveStore` mapping to `derived(compute)` with key-bound invalidation if preferred, or clean up the API specification.
48
-
49
- ---
50
-
51
- ## 2. Persistence Gaps (Storage Quota and Eviction)
52
-
53
- ### 2.1. Proactive Eviction and Quota Warnings
54
- - **Status**: Planned but missing.
55
- - **File**:
56
- - `src/core/state/persist.js`
57
- - **Problem**:
58
- The storage engine does not monitor available quota or execute proactive eviction. Large applications risk throwing unhandled `QuotaExceededError` exceptions when writing data.
59
- - **Expected Support**:
60
- - Implement a quota check wrapper on `set()`.
61
- - Establish a warning threshold (80% of estimated quota).
62
- - Add proactive eviction stages:
63
- 1. Prune expired cache records based on TTL metadata.
64
- 2. Evict low-recency records (LRU) using a `lastAccessed` timestamp.
65
- - Dispatch a global `quota` warning event if space remains critical.
66
-
67
- ### 2.2. Write-Through and Write-Ahead Transaction Queues
68
- - **Status**: Missing support.
69
- - **File**:
70
- - `src/core/state/persist.js`
71
- - **Problem**:
72
- Mutating state is not atomic. A crash between memory writing and database writing leaves inconsistent schemas.
73
- - **Expected Support**:
74
- - Add a transaction-safe queue to handle write-ahead serialization (log first, modify memory on confirmation).
75
- - Implement retry logic in the write queue on transient storage lockups or quota exceptions.
76
-
77
- ---
78
-
79
- ## 3. Reactivity Performance and Deep Store Support
80
-
81
- ### 3.1. Deep Reactive Stores
82
- - **Status**: Enhancement.
83
- - **File**:
84
- - `src/core/state/store.js`
85
- - **Problem**:
86
- `ReactiveStore` only intercepts top-level properties (shallow). Mutating nested objects (e.g., `store.get('user').name = 'alice'`) bypasses reactive traps. Manual structural sharing (e.g., `store.set('user', { ...user, name: 'alice' })`) is error-prone.
87
- - **Expected Support**:
88
- - Add opt-in deep reactivity configuration on store instantiation.
89
- - Recursively wrap accessed nested object fields in reactive `Proxy` instances, returning mapped pathways.
90
- - Validate that circular references do not crash proxy wrappers.
91
-
92
- ### 3.2. Optimized Snapshots
93
- - **Status**: Performance enhancement.
94
- - **File**:
95
- - `src/core/state/store.js`
96
- - **Problem**:
97
- `store.snapshot()` falls back to `JSON.parse(JSON.stringify(...))` when `structuredClone` is missing or if non-serializable objects (like `Map` or `Set`) are stored. This degrades speed in performance-sensitive contexts.
98
- - **Expected Support**:
99
- - Use custom fast-cloning paths for pure data objects.
100
- - Delegate serialization for custom collection types within the store configuration.
101
-
102
- ---
103
-
104
- ## 4. Build-Time Static Analysis
105
-
106
- ### 4.1. Immutability Violation Scan
107
- - **Status**: Planned.
108
- - **Files**:
109
- - `tools/src/extract/runner.rs`
110
- - **Problem**:
111
- In-place mutations of objects retrieved from reactive stores (e.g. `store.get('user').name = 'bob'`) bypasses the `Object.is` check and stops reactive updates. This is hard to debug at runtime.
112
- - **Expected Support**:
113
- - Implement a AST-based checker in `anza` to scan JavaScript sources for store retrieval variables followed by mutation assignments.
114
- - Log lint warnings during `scan` and `dev` runs.
115
-
116
- ### 4.2. Schema Type Generation
117
- - **Status**: Enhancement.
118
- - **Files**:
119
- - `tools/src/extract/runner.rs`
120
- - **Expected Support**:
121
- - Statically analyze store initializations to output a typed state manifest schema (`state.d.ts`).
122
-
123
- ---
124
-
125
- ## 5. Test Coverage Gaps
126
-
127
- ### 5.1. No Persistence Tests
128
- - **Status**: Missing coverage.
129
- - **File**:
130
- - `tests/core/state/persist.test.js`
131
- - **Needed Coverage**:
132
- - Database instantiation and migrations.
133
- - CRUD operations (`get`, `set`, `delete`, `query`).
134
- - Quota estimate mock and persistence hooks.
135
- - Eviction stages validation.
136
-
137
- ### 5.2. Tab Sync Robustness
138
- - **Status**: Weak coverage.
139
- - **File**:
140
- - `tests/core/state/sync.test.js`
141
- - **Needed Coverage**:
142
- - Re-entrancy and circular echo avoidance.
143
- - Proper disposal of broadcast channels.
144
-
145
- ---
146
-
147
- ## 6. Suggested Implementation Order
148
-
149
- 1. Align `types/core/state/index.d.ts` with runtime `PlatformStorage`.
150
- 2. Add `tests/core/state/persist.test.js` to cover basic IndexedDB CRUD operations.
151
- 3. Expose `store.broadcast()` and `store.derived()` delegate methods.
152
- 4. Implement recursive deep proxy wrapper options in `ReactiveStore`.
153
- 5. Implement quota warning thresholds and basic recency-based eviction.
154
- 6. Add build-time immutability violation scanner to `anza`.
155
-
156
- ---
157
-
158
- ## 7. Done Criteria
159
-
160
- This missing-support list is complete when:
161
- - Type declarations for `storage` match runtime methods.
162
- - Persistent local store has comprehensive tests covering IndexedDB operations.
163
- - Deep reactive stores are optionally configurable and verified.
164
- - Static scanning tools warn developers of inline store mutations.
165
- - Eviction and warning systems prevent silent quota failures.
@@ -1,165 +0,0 @@
1
- # Storage Missing Support
2
-
3
- This document tracks remaining support, runtime gaps, concurrency constraints, serialization enhancements, and performance optimization work for `src/core/storage`. Implemented behavior belongs in `usage.md` (or core documentation); unsupported, under-tested, or performance-gated behavior belongs here until it is built and verified.
4
-
5
- ---
6
-
7
- ## 0. Toolchain and Naming Rules
8
-
9
- Heavy compilation, static analysis, and code generation belong in `tools/`, not in browser runtime modules.
10
-
11
- Current toolchain storage support requirements:
12
-
13
- - Analyze storage tier utilization and statically compile Dedicated Web Worker scripts to avoid runtime ObjectURL blobs.
14
- - Detect synchronous storage access patterns (like `localStorage` or `sessionStorage` usage) outside designated bootstrap paths.
15
- - Statically validate migration schema progression profiles.
16
-
17
- Naming rules for storage support:
18
-
19
- - Prefer one-word files: `idb.js`, `lru.js`, `opfs.js`, `quota.js`, `cache.js`, `index.js`.
20
- - Plural folders: `tests/`, `migrations/`.
21
- - Single-word methods: `get`, `set`, `delete`, `query`, `list`, `clear`, `estimate`, `persist`, `persisted`, `transaction`.
22
- - Single-word events: `warning`, `quota`, `blocked`.
23
- - Avoid compound names where single words carry full meaning in context.
24
-
25
- ---
26
-
27
- ## 1. Critical Runtime and Type Gaps
28
-
29
- ### 1.1. Missing Unified Gateway Methods
30
-
31
- - **Status**: Runtime gap.
32
- - **Files**:
33
- - `src/core/storage/index.js`
34
- - **Problem**:
35
- The Storage Architecture specification (§15) defines `storage.transaction(stores, mode, fn)`, `storage.persisted()`, and `storage.onQuotaWarning(handler)` as part of the Unified Storage Gateway interface. Currently, these methods are not implemented on the exported `storage` facade.
36
- - **Expected Support**:
37
- - Implement `storage.transaction(stores, mode, fn)` to execute multi-store operations inside a single transactional block.
38
- - Implement `storage.persisted()` wrapping `navigator.storage.persisted()`.
39
- - Implement `storage.onQuotaWarning(handler)` to subscribe to quota limit checks.
40
-
41
- ### 1.2. Storage Type Mismatches
42
-
43
- - **Status**: Type mismatch.
44
- - **Files**:
45
- - `types/core/storage/index.d.ts`
46
- - **Problem**:
47
- The type declaration file does not align with the public specifications. It is missing declarations for `persisted()`, `transaction()`, and the proper returned structure from `estimate()` (including the `persisted` flag).
48
- - **Expected Support**:
49
- - Align `types/core/storage/index.d.ts` to expose the true interface.
50
-
51
- ---
52
-
53
- ## 2. Concurrency & Durability Gaps
54
-
55
- ### 2.1. Web Locks Coordination for OPFS
56
-
57
- - **Status**: Critical concurrency gap.
58
- - **Files**:
59
- - `src/core/storage/opfs.js`
60
- - **Problem**:
61
- The OPFS manager does not coordinate file access across different tabs. Concurrent reads and writes to the same virtual file will throw errors or lead to raw binary data corruption.
62
- - **Expected Support**:
63
- - Wrap OPFS operations (`get`, `set`, `delete`) in an exclusive Web Lock (`workers.lock` or `navigator.locks.request`) scoped to the filename to serialize cross-tab operations.
64
-
65
- ### 2.2. IndexedDB Upgrade Blocking Coordination
66
-
67
- - **Status**: Runtime gap.
68
- - **Files**:
69
- - `src/core/storage/idb.js`
70
- - **Problem**:
71
- If a user has multiple tabs open, an IndexedDB database schema upgrade (triggered by opening with a higher version) is blocked indefinitely because the old tabs hold active connections. Currently, the database class does not listen to `onblocked` or `onversionchange` events.
72
- - **Expected Support**:
73
- - Handle the `blocked` event on the database open request, dispatching an event to warn the system of connection locks.
74
- - Listen to the `versionchange` event on the active database connection. If triggered, gracefully close the database immediately so that other tabs can proceed with schema upgrades.
75
-
76
- ### 2.3. Write Journal for Durability
77
-
78
- - **Status**: Planned but missing.
79
- - **Files**:
80
- - `src/core/storage/index.js`
81
- - **Problem**:
82
- Transactions can fail to write to disk due to abrupt tab crashes or sudden power losses, leaving memory and disk states inconsistent.
83
- - **Expected Support**:
84
- - Introduce a write journal using crash-durable `localStorage` to buffer pending keys before committing them to IndexedDB.
85
- - Verify and replay uncommitted journal operations automatically during client boot.
86
-
87
- ---
88
-
89
- ## 3. Serialization & Performance Gaps
90
-
91
- ### 3.1. Transparent Compression for Large Records
92
-
93
- - **Status**: Performance enhancement.
94
- - **Files**:
95
- - `src/core/storage/index.js`
96
- - **Problem**:
97
- Writing large objects (>64KB) directly to IndexedDB consumes excess quota, increases serialization/deserialization delay, and degrades storage bandwidth.
98
- - **Expected Support**:
99
- - Implement transparent compression using the browser's native Compression Streams API (`new CompressionStream('gzip')`) when writing values exceeding 64KB.
100
- - Inject a metadata envelope (`{ value, compressed: true }`) to identify compressed payloads and decompress them automatically on read.
101
-
102
- ### 3.2. Worker Script Optimization
103
-
104
- - **Status**: Optimization.
105
- - **Files**:
106
- - `src/core/storage/opfs.js`
107
- - **Problem**:
108
- The OPFS manager instantiates its Dedicated Worker using a Blob URL wrapper on an inline string (`URL.createObjectURL(new Blob(...))`). This slows down initial load, blocks minification, and triggers Content Security Policy (CSP) security warnings.
109
- - **Expected Support**:
110
- - Offload worker script extraction to the build-time compiler (`tools/`) to generate a static asset or optimize string injection.
111
-
112
- ---
113
-
114
- ## 4. Test Coverage Gaps
115
-
116
- ### 4.1. OPFS Integration Tests
117
-
118
- - **Status**: Missing coverage.
119
- - **Files**:
120
- - `tests/core/storage/opfs.test.js` [NEW]
121
- - **Needed Coverage**:
122
- - Dedicated Worker execution offloading.
123
- - Parallel reads/writes and verification of data persistence.
124
- - Cross-tab change invalidation alerts over BroadcastChannel.
125
-
126
- ### 4.2. Cache API and TTL Verification
127
-
128
- - **Status**: Missing coverage.
129
- - **Files**:
130
- - `tests/core/storage/cache.test.js` [NEW]
131
- - **Needed Coverage**:
132
- - Cache matches and correct header insertion for `x-expires-at`.
133
- - Automatic eviction of expired items.
134
-
135
- ### 4.3. Quota Warning and Eviction Tests
136
-
137
- - **Status**: Missing coverage.
138
- - **Files**:
139
- - `tests/core/storage/quota.test.js` [NEW]
140
- - **Needed Coverage**:
141
- - Mocking quota estimate queries.
142
- - Verification that warnings fire when threshold usage exceeds 80%.
143
-
144
- ---
145
-
146
- ## 5. Suggested Implementation Order
147
-
148
- 1. Align `types/core/storage/index.d.ts` with the full unified storage API.
149
- 2. Add comprehensive tests for `opfs.js`, `cache.js`, and `quota.js`.
150
- 3. Implement Web Locks for OPFS file synchronization.
151
- 4. Implement database blocking and connection version upgrade handlers.
152
- 5. Implement transparent Compression Streams for large values (>64KB).
153
- 6. Implement write journaling for transactional durability.
154
-
155
- ---
156
-
157
- ## 6. Done Criteria
158
-
159
- This missing-support list is complete when:
160
-
161
- - TypeScript declarations map the complete unified storage API.
162
- - OPFS, Cache TTL, and Quota warning components have complete integration tests.
163
- - Web Locks synchronize multi-tab file writes.
164
- - DB upgrades are not blocked by connections in sibling tabs.
165
- - Large records (>64KB) are compressed transparently using native streams.
@@ -1,69 +0,0 @@
1
- # Storage Engine Architecture Plan
2
-
3
- This document outlines the blueprint for the local-first Multi-Tier Storage Gateway within `core.storage`, mapping memory LRU, IndexedDB, Cache API, and Origin Private File System (OPFS) under a unified tiered facade.
4
-
5
- ---
6
-
7
- ## 1. Architectural Architecture & Requirements
8
-
9
- We will structure `core.storage` to provide:
10
- 1. **Tiered Storage Architecture:** Clean separation of data structures into Memory LRU (transient, near-instant), IndexedDB (default transactional storage), Cache API (Request/Response persistence), and OPFS (high-performance synchronous file systems).
11
- 2. **Synchronous Storage Ban:** Prevent performance-degrading synchronous operations (like blocking localStorage reads) in user interaction loops to keep the Interaction to Next Paint (INP) score pristine.
12
- 3. **Dedicated Web Worker Offloading:** Route heavy OPFS synchronous file operations (using `FileSystemSyncAccessHandle`) to a background Dedicated Web Worker to eliminate main thread contention.
13
- 4. **Cross-Tab Invalidation:** Broadcast storage mutations across tabs in real-time utilizing a native `BroadcastChannel` named `core:opfs-invalidation` or namespace channels.
14
- 5. **Quota Governance & Self-Healing:** Integrate the browser's native `StorageManager` to monitor space estimates, query persistence, request persistent storage (`navigator.storage.persist()`), and fire events on 80% quota usage limits.
15
-
16
- ---
17
-
18
- ## 2. Directory Layout & Core Components
19
-
20
- Following `RULE[user_global]`, the storage components are flat and named using lowercase:
21
-
22
- ```
23
- src/core/storage/
24
- ├── index.js # Unified Storage Gateway Entry (core.storage)
25
- ├── idb.js # Promise-wrapped transactional IndexedDB client
26
- ├── lru.js # Least-Recently-Used & WeakRef memory caching stores
27
- ├── opfs.js # Dedicated Web Worker coordinator for OPFS access
28
- ├── quota.js # StorageManager quota checks and persistence control
29
- └── plan.md # This planning blueprint
30
- ```
31
-
32
- ---
33
-
34
- ## 3. Technical Blueprint & Multi-Tier Mapping
35
-
36
- ### Tier Performance Matrix
37
-
38
- | Tier | API Backend | Performance | Thread Scoped | Use Case |
39
- |---|---|---|---|---|
40
- | `memory` | Map / WeakRef | Sub-microsecond | Main / Worker | Ephemeral/transient cache |
41
- | `idb` | IndexedDB | 1ms – 5ms | Main / Worker | Structured user/document databases |
42
- | `cache` | Cache API | 2ms – 10ms | Main / Worker | Offline Request/Response caching |
43
- | `opfs` | OPFS Access Handle | Sub-millisecond | Dedicated Worker | Large sequential writes, SQLite storage |
44
-
45
- ### Unified Storage Gateway Contracts
46
-
47
- ```javascript
48
- // src/core/storage/index.js
49
- export const storage = {
50
- async get(key, tier = 'idb') { ... },
51
- async set(key, value, tier = 'idb', ttl = null) { ... },
52
- async delete(key, tier = 'idb') { ... },
53
- async list(tier = 'idb') { ... },
54
- async clear(tier = 'all') { ... }
55
- };
56
- ```
57
-
58
- ---
59
-
60
- ## 4. Verification Plan
61
-
62
- ### Automated Verification
63
- - Verify database migrations run sequentially on database opening without skipping steps.
64
- - Validate that WeakRef memory cache recovers objects when available and handles garbage collection gracefully under memory pressure.
65
- - Confirm background Dedicated Worker file operations complete correctly without stalling the main thread.
66
- - Assert that cross-tab signals are successfully broadcasted and received during file operations.
67
-
68
- ### Quota Checks
69
- - Validate that the quota manager detects when usage climbs past 80% and fires an eviction warning event.
@@ -1,170 +0,0 @@
1
- # Native UI Implementation Checklist
2
-
3
- This checklist is the execution companion to `plan.md`, `watch.md`, and `usage.md`.
4
-
5
- Status: **Fully Implemented and Verified**
6
-
7
- - All phases (Phase 1 through Phase 7) are completed, optimized, and verified.
8
- - The runtime helpers, event delegation, mutation watcher, lifecycle injection, Rust scanner, and comprehensive test suite are fully operational and integrated.
9
-
10
- ## Phase 1: Runtime Helpers
11
-
12
- Files:
13
-
14
- - `src/core/ui/define/proxy.js`
15
- - `src/core/ui/define/element.js`
16
- - optional new `src/core/ui/define/context.js`
17
-
18
- Tasks:
19
-
20
- - Split `TagsCache` into separate `one` and `all` caches.
21
- - Add `TagsCache.has(selector)` if desired.
22
- - Add descriptor-free `refs` fallback scanning.
23
- - Add duplicate-ref development warnings.
24
- - Add context builder for `{ el, ctrl, tags, on, refs, watch, internals }`.
25
- - Install cache invalidation for `replaceChildren` and `innerHTML`.
26
- - Return stable context objects for mount/update.
27
-
28
- Acceptance:
29
-
30
- - `tags.one('button')` and `tags.all('button')` can be called in any order.
31
- - `refs` works with and without `.tags.json`.
32
- - Existing `ui.element` components continue to mount.
33
-
34
- ## Phase 2: Event Delegation
35
-
36
- File:
37
-
38
- - `src/core/ui/define/proxy.js`
39
-
40
- Tasks:
41
-
42
- - Replace per-binding root listeners with one root listener per event type.
43
- - Store event registrations in sets keyed by event type.
44
- - Support `on.click(selector, handler)`.
45
- - Support `on.click(selector, handler, signal)`.
46
- - Support `on.click(selector, handler, options)`.
47
- - Support `on.click.once(selector, handler)`.
48
- - Return disposer functions.
49
- - Remove bindings on custom signal abort.
50
- - Remove all bindings on component signal abort.
51
-
52
- Acceptance:
53
-
54
- - Dynamically added matching elements work without rebinding.
55
- - Multiple click handlers do not create multiple native click listeners on the shadow root.
56
- - `.once` fires once and removes only itself.
57
-
58
- ## Phase 3: `watch`
59
-
60
- File:
61
-
62
- - `src/core/ui/define/proxy.js` or new `src/core/ui/define/watch.js`
63
-
64
- Tasks:
65
-
66
- - Implement `createMutationWatcher(shadowRoot, defaultSignal)`.
67
- - Support `watch.attr`, `watch.kids`, `watch.text`, `watch.tree`.
68
- - Support `.once` on each method.
69
- - Accept selector strings and direct element references.
70
- - Accept custom `AbortSignal` or options object.
71
- - Return disposer functions.
72
- - Recompute observer options from active registrations.
73
- - Dispatch reshaped handler arguments.
74
- - Guard callbacks after lifecycle abort.
75
-
76
- Acceptance:
77
-
78
- - One `MutationObserver` exists per component instance.
79
- - Attribute, child, text, and tree handlers receive documented arguments.
80
- - Component disconnect clears all registrations.
81
-
82
- ## Phase 4: Lifecycle Injection
83
-
84
- File:
85
-
86
- - `src/core/ui/define/element.js`
87
-
88
- Tasks:
89
-
90
- - Use the context builder after template/style hydration.
91
- - Pass `watch` to `spec.mount`.
92
- - Pass `watch` and `prev` to `spec.update`.
93
- - Preserve `internals` behavior for form-associated elements.
94
- - Keep `spec.unmount` shape stable.
95
-
96
- Acceptance:
97
-
98
- - Existing components using `{ tags, on, refs }` still work.
99
- - New components can destructure `{ watch }`.
100
- - Updates receive `prev` consistently.
101
-
102
- ## Phase 5: Rust Scanner
103
-
104
- Files:
105
-
106
- - `tools/src/extract/html.rs`
107
- - `tools/src/extract/runner.rs`
108
- - `tools/src/watcher/runner.rs`
109
- - `tools/src/main.rs`
110
-
111
- Tasks:
112
-
113
- - Refactor scanner into `parse_html`, `parse_file`, `emit_descriptor`, and `parse_and_emit`.
114
- - Return `Result` instead of silently swallowing errors.
115
- - Add descriptor `version`.
116
- - Add duplicate-ref diagnostics.
117
- - Keep sorted deterministic output.
118
- - Consider `attrs` and `refTypes` fields.
119
- - Add subcommands or document current flags until subcommands land.
120
- - Regenerate descriptors on HTML watcher events.
121
- - Remove stale descriptors when source HTML is deleted.
122
-
123
- Acceptance:
124
-
125
- - Build mode emits descriptors for all HTML templates.
126
- - Dev watcher regenerates a changed template descriptor.
127
- - Malformed HTML fragments do not panic.
128
-
129
- ## Phase 6: Tests
130
-
131
- JavaScript tests:
132
-
133
- - `tags` cache shapes and invalidation.
134
- - `refs` descriptor and fallback behavior.
135
- - `on` delegation, custom events, once, signal cleanup.
136
- - `watch` attr/kids/text/tree, once, direct refs, selector misses, lifecycle abort.
137
-
138
- Rust tests:
139
-
140
- - Descriptor parsing.
141
- - Stable JSON ordering.
142
- - Duplicate refs.
143
- - Watcher-triggered regeneration.
144
-
145
- ## Phase 7: Documentation
146
-
147
- Files:
148
-
149
- - `src/core/ui/plan.md`
150
- - `src/core/ui/watch.md`
151
- - `src/core/ui/usage.md`
152
- - `src/core/ui/implementation.md`
153
-
154
- Tasks:
155
-
156
- - Keep `plan.md` as the architectural implementation plan.
157
- - Keep `watch.md` as the `watch` API and internals spec.
158
- - Keep `usage.md` as the public usage guide.
159
- - Keep this file as the execution checklist.
160
-
161
- ## Done Definition
162
-
163
- The work is complete when:
164
-
165
- - Runtime injects `refs`, `tags`, `on`, and `watch`.
166
- - All helpers clean up from `ctrl.signal`.
167
- - Rust emits descriptors deterministically.
168
- - Dev watcher keeps descriptors current.
169
- - Usage docs cover every public call shape.
170
- - Tests prove lifecycle cleanup and cache correctness.