@sladg/apex-state 3.11.2 → 4.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 +21 -35
- package/dist/index.d.ts +530 -291
- package/dist/index.js +1511 -1619
- package/dist/index.js.map +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +456 -651
- package/dist/testing/index.js.map +1 -1
- package/package.json +9 -4
package/README.md
CHANGED
|
@@ -48,7 +48,7 @@ const UserForm = () => {
|
|
|
48
48
|
onChange={(e) => setValue(e.target.value)}
|
|
49
49
|
className={validationState?.isError ? 'error' : ''}
|
|
50
50
|
/>
|
|
51
|
-
{validationState?.isError && <span>{validationState.errors[0]}</span>}
|
|
51
|
+
{validationState?.isError && <span>{validationState.errors[0]?.message}</span>}
|
|
52
52
|
</div>
|
|
53
53
|
)
|
|
54
54
|
}
|
|
@@ -203,7 +203,7 @@ const ProfileForm = () => {
|
|
|
203
203
|
<div>
|
|
204
204
|
<input value={email.value} onChange={(e) => email.setValue(e.target.value)} />
|
|
205
205
|
{email.validationState?.isError && (
|
|
206
|
-
<ul>{email.validationState.errors.map((err, i) => <li key={i}>{err}</li>)}</ul>
|
|
206
|
+
<ul>{email.validationState.errors.map((err, i) => <li key={i}>{err.message}</li>)}</ul>
|
|
207
207
|
)}
|
|
208
208
|
</div>
|
|
209
209
|
<div>
|
|
@@ -212,7 +212,7 @@ const ProfileForm = () => {
|
|
|
212
212
|
value={age.value}
|
|
213
213
|
onChange={(e) => age.setValue(Number(e.target.value))}
|
|
214
214
|
/>
|
|
215
|
-
{age.validationState?.isError && <span>{age.validationState.errors[0]}</span>}
|
|
215
|
+
{age.validationState?.isError && <span>{age.validationState.errors[0]?.message}</span>}
|
|
216
216
|
</div>
|
|
217
217
|
</form>
|
|
218
218
|
)
|
|
@@ -330,7 +330,7 @@ store.useConcerns('dynamic-text', {
|
|
|
330
330
|
},
|
|
331
331
|
})
|
|
332
332
|
|
|
333
|
-
const { dynamicTooltip, dynamicLabel } = store.
|
|
333
|
+
const { dynamicTooltip, dynamicLabel } = store.useFieldStore('legs.0.strike')
|
|
334
334
|
// dynamicTooltip -> "Current strike: 105"
|
|
335
335
|
// dynamicLabel -> "Strike for AAPL"
|
|
336
336
|
```
|
|
@@ -510,30 +510,18 @@ it('tracks concern and side effect registrations', () => {
|
|
|
510
510
|
})
|
|
511
511
|
```
|
|
512
512
|
|
|
513
|
-
##
|
|
514
|
-
|
|
515
|
-
WASM is the default. Pass `{ useLegacyImplementation: true }` for pure JS:
|
|
516
|
-
|
|
517
|
-
```tsx
|
|
518
|
-
// WASM (default) — Rust-powered pipeline, faster for complex state
|
|
519
|
-
const wasmStore = createGenericStore<MyState>()
|
|
520
|
-
|
|
521
|
-
// Legacy JS — pure JavaScript, no WASM binary needed
|
|
522
|
-
const legacyStore = createGenericStore<MyState>({ useLegacyImplementation: true })
|
|
523
|
-
```
|
|
524
|
-
|
|
525
|
-
### Performance
|
|
513
|
+
## Performance
|
|
526
514
|
|
|
527
515
|
Benchmarked with 60 variants across 3 Record layers, 75 syncs, 40 flips, 100 BoolLogic conditions, 85 listeners:
|
|
528
516
|
|
|
529
|
-
| Operation |
|
|
530
|
-
|
|
531
|
-
| Single field edit |
|
|
532
|
-
| 7 changes + cascading listeners |
|
|
533
|
-
| 60 bulk price changes |
|
|
534
|
-
| 135 changes (full catalog refresh) |
|
|
517
|
+
| Operation | Duration |
|
|
518
|
+
|---|---|
|
|
519
|
+
| Single field edit | 1.4µs |
|
|
520
|
+
| 7 changes + cascading listeners | 0.11ms |
|
|
521
|
+
| 60 bulk price changes | 2.9ms |
|
|
522
|
+
| 135 changes (full catalog refresh) | 2.99ms |
|
|
535
523
|
|
|
536
|
-
|
|
524
|
+
See [Benchmark Comparison](docs/BENCHMARK_COMPARISON.md) for the full analysis.
|
|
537
525
|
|
|
538
526
|
## API Overview
|
|
539
527
|
|
|
@@ -549,8 +537,8 @@ Both modes produce **identical state** — verified across all 16 benchmark scen
|
|
|
549
537
|
| `useJitStore()` | `{ proxyValue, setChanges, getState }` | Bulk updates, non-reactive reads |
|
|
550
538
|
| `useConcerns(id, config)` | `void` | Register validation/BoolLogic/dynamic text |
|
|
551
539
|
| `useSideEffects(id, config)` | `void` | Register sync/flip/aggregation/listeners |
|
|
552
|
-
| `useFieldConcerns(path)` | `EvaluatedConcerns` | Read concern results for a path |
|
|
553
540
|
| `withConcerns(selection)` | `{ useFieldStore }` | Scoped field store with selected concerns |
|
|
541
|
+
| `withMeta(presetMeta)` | `{ useFieldStore }` | Field store with preset META values |
|
|
554
542
|
|
|
555
543
|
### Built-in Concerns
|
|
556
544
|
|
|
@@ -573,15 +561,14 @@ Both modes produce **identical state** — verified across all 16 benchmark scen
|
|
|
573
561
|
```
|
|
574
562
|
setValue("email", "alice@example.com")
|
|
575
563
|
|
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
| v
|
|
579
|
-
| execute listeners + Zod validators (JS)
|
|
580
|
-
| |
|
|
581
|
-
| v
|
|
582
|
-
| pipelineFinalize -> diff -> final changes (Rust)
|
|
564
|
+
v
|
|
565
|
+
[WASM/Rust] shadow state + sync + flip + BoolLogic evaluation
|
|
583
566
|
|
|
|
584
|
-
|
|
567
|
+
v
|
|
568
|
+
[JS] execute listeners + Zod validators
|
|
569
|
+
|
|
|
570
|
+
v
|
|
571
|
+
[WASM/Rust] diff -> compute final changes
|
|
585
572
|
|
|
|
586
573
|
v
|
|
587
574
|
valtio proxy -> React re-render
|
|
@@ -618,11 +605,10 @@ cargo install wasm-pack
|
|
|
618
605
|
| [Concerns Guide](docs/guides/CONCERNS_GUIDE.md) | Concern lifecycle, built-ins, custom concerns |
|
|
619
606
|
| [Side Effects Guide](docs/SIDE_EFFECTS_GUIDE.md) | Sync, flip, aggregation, listener API |
|
|
620
607
|
| [WASM Architecture](docs/WASM_ARCHITECTURE.md) | JS/WASM boundary, data flow, ownership model |
|
|
621
|
-
| [Benchmark Comparison](docs/BENCHMARK_COMPARISON.md) |
|
|
608
|
+
| [Benchmark Comparison](docs/BENCHMARK_COMPARISON.md) | Detailed benchmark analysis across 16 scenarios |
|
|
622
609
|
| [Wildcard Paths](docs/WILD_FUNCTION_GUIDE.md) | `_()` hash key utility for Record types |
|
|
623
610
|
| [String Interpolation](docs/INTERPOLATION.md) | Template helpers for dynamic text concerns |
|
|
624
611
|
| [Testing Mock](docs/TESTING_MOCK.md) | Mock module for consumer tests (`vi.mock`) |
|
|
625
|
-
| [Record Migration](docs/RECORD_MIGRATION.md) | Migration patterns for dynamic Record types |
|
|
626
612
|
| [Debug Timing](docs/DEBUG_TIMING.md) | Performance debugging utilities |
|
|
627
613
|
| [Full Index](docs/README.md) | Complete documentation index |
|
|
628
614
|
|