@wizzard-packages/core 0.5.0-canary-20260908083257 → 0.5.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.
Files changed (2) hide show
  1. package/README.md +82 -40
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -4,64 +4,106 @@
4
4
  ![downloads](https://img.shields.io/npm/dm/@wizzard-packages/core)
5
5
  ![license](https://img.shields.io/npm/l/@wizzard-packages/core)
6
6
 
7
- Framework-agnostic wizard engine: state, actions, and types. Use this package to build your own UI layer or plug it into another framework.
8
-
9
- ## Why core
10
-
11
- - Headless state store and typed actions
12
- - Works in any UI (React, Vue, custom, CLI)
13
- - Small surface area with predictable behavior
7
+ The engine. A flow is a plain JSON object — no functions, no classes, no `Set`s — and this
8
+ package is what walks it: expressions, guards, validation, navigation and the state that
9
+ comes out. It has no framework in it, so React and Vue are thin bindings over one engine
10
+ rather than two implementations of the same rules.
14
11
 
15
12
  ## Install
16
13
 
17
14
  ```bash
18
- pnpm add @wizzard-packages/core
15
+ pnpm add @wizzard-packages/core@canary
19
16
  ```
20
17
 
21
- ## Quickstart
18
+ ## A flow
19
+
20
+ `defineFlow` and `step` are the typed way to write that JSON. They add no runtime behaviour —
21
+ `defineFlow` returns its argument — but they carry the shape of each step's data into
22
+ `wizard.get` and `wizard.set`.
22
23
 
24
+ <!-- example:quickstart-flow -->
25
+
26
+ <!-- prettier-ignore -->
23
27
  ```ts
24
- import { WizardStore, type IWizardConfig } from '@wizzard-packages/core';
28
+ import { defineFlow, step } from '@wizzard-packages/core/v1';
29
+
30
+ /**
31
+ * The smallest flow that is still a wizard: two steps, one field, and a value
32
+ * that has to survive going back.
33
+ *
34
+ * A flow is data. This object is JSON — no functions, no classes — so the same
35
+ * definition can come from a file, from a backend, or from a generator, and one
36
+ * engine runs all three.
37
+ */
38
+ export const signup = defineFlow({
39
+ id: 'signup',
40
+ order: ['name', 'review'],
41
+ steps: {
42
+ name: step<{ full: string }>({ label: 'Your name' }),
43
+ review: step({ label: 'Review' }),
44
+ },
45
+ });
46
+ ```
47
+
48
+ <!-- /example -->
25
49
 
26
- type Data = { name: string };
50
+ ## Running it
27
51
 
28
- type StepId = 'name' | 'review';
52
+ ```ts
53
+ import { createWizard } from '@wizzard-packages/core/v1';
29
54
 
30
- const config: IWizardConfig<Data, StepId> = {
31
- steps: [
32
- { id: 'name', label: 'Name', component: null },
33
- { id: 'review', label: 'Review', component: null },
34
- ],
35
- };
55
+ import { signup } from './flow';
36
56
 
37
- const store = new WizardStore<Data, StepId>({ name: '' });
57
+ const wizard = createWizard({ flow: signup });
38
58
 
39
- store.dispatch({
40
- type: 'INIT',
41
- payload: { data: { name: '' }, config },
42
- });
59
+ await wizard.start(); // enters the first reachable step
60
+ wizard.set('name.full', 'Ada');
61
+ const result = await wizard.next();
62
+ // { ok: true } — or { ok: false, reason: 'blocked', by: 'age-check' }
43
63
  ```
44
64
 
45
- ## Utilities
65
+ Navigation returns a result, never a bare boolean, because "it did not move" and "why it did
66
+ not move" are different questions and the second one is what you render. `subscribe`,
67
+ `select` and `watch` are the three ways to hear about a change: everything, one derived
68
+ value, or one data path.
46
69
 
47
- ```ts
48
- import { getByPath, setByPath } from '@wizzard-packages/core';
70
+ Anything a flow cannot serialize — a validator, a predicate, an async guard — is a **named**
71
+ entry in `registry`, so `JSON.stringify(flow)` always round-trips.
49
72
 
50
- const data = { user: { name: 'Ada' } };
51
- const name = getByPath(data, 'user.name');
52
- const next = setByPath(data, 'user.name', 'Grace');
53
- ```
73
+ ## Entries
74
+
75
+ Separate entry points because they are separate budgets. A wizard that never draws itself
76
+ does not carry the code that would.
77
+
78
+ | Entry | What it is |
79
+ | ---------------- | -------------------------------------------------------------- |
80
+ | `/v1` | the engine: types, expressions, navigation, selectors |
81
+ | `/graph` | a flow as `{ nodes, edges }`, for drawing it |
82
+ | `/groups` | traversal for repeated sub-flows |
83
+ | `/session` | a recorded run, and the check that a replay matches it |
84
+ | `/snapshot` | serialize a run, and refuse stored JSON that cannot be trusted |
85
+ | `/expr` | a builder for expressions, if you dislike writing JSON |
86
+ | `/validate-flow` | checks a flow definition, for tooling and tests |
87
+
88
+ `.size-limit.js` holds the budget for each, with the measurement that set it.
89
+
90
+ ## Documentation
91
+
92
+ The guides live on the site: [Getting started](https://zizzx.github.io/wizzard-packages/docs/start/),
93
+ [The flow](https://zizzx.github.io/wizzard-packages/docs/flow/),
94
+ [Expressions](https://zizzx.github.io/wizzard-packages/docs/expressions/),
95
+ [Navigation](https://zizzx.github.io/wizzard-packages/docs/navigation/).
96
+
97
+ Bindings: [`@wizzard-packages/react`](https://www.npmjs.com/package/@wizzard-packages/react),
98
+ [`@wizzard-packages/vue`](https://www.npmjs.com/package/@wizzard-packages/vue). Validation:
99
+ [`@wizzard-packages/validate`](https://www.npmjs.com/package/@wizzard-packages/validate).
54
100
 
55
- ## Related packages
101
+ ## Upgrading from 0.x
56
102
 
57
- - @wizzard-packages/react - React provider + hooks on top of core
58
- - @wizzard-packages/persistence - save/load wizard state
59
- - @wizzard-packages/middleware - logger and devtools middleware
60
- - @wizzard-packages/adapter-zod - validation with Zod
61
- - @wizzard-packages/adapter-yup - validation with Yup
62
- - @wizzard-packages/devtools - DevTools UI (React)
103
+ 0.x was a different library with the same name: `new WizardStore(...)`, a config of steps, and
104
+ the branching in your components. v1 is on the `canary` tag while the launch lands. The
105
+ 0.x line on `latest` is being retired.
63
106
 
64
- ## Links
107
+ ## License
65
108
 
66
- - Repo: https://github.com/ZizzX/wizzard-packages
67
- - Docs UI: https://zizzx.github.io/wizzard-packages/
109
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wizzard-packages/core",
3
- "version": "0.5.0-canary-20260908083257",
3
+ "version": "0.5.0",
4
4
  "description": "Core logic for Wizzard Stepper - framework agnostic store and utilities.",
5
5
  "keywords": [
6
6
  "wizard",