react-mnemonic 1.2.1-beta1.0 → 1.4.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 +52 -3
- package/dist/bootstrap.cjs +864 -0
- package/dist/bootstrap.cjs.map +1 -0
- package/dist/bootstrap.d.cts +100 -0
- package/dist/bootstrap.d.ts +100 -0
- package/dist/bootstrap.js +857 -0
- package/dist/bootstrap.js.map +1 -0
- package/dist/core.cjs +786 -127
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +3 -2
- package/dist/core.d.ts +3 -2
- package/dist/core.js +787 -128
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +1297 -1004
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1298 -1005
- package/dist/index.js.map +1 -1
- package/dist/key-B0_N_rl6.d.cts +47 -0
- package/dist/key-yGSxLOVj.d.ts +47 -0
- package/dist/optional.cjs +166 -0
- package/dist/optional.cjs.map +1 -0
- package/dist/optional.d.cts +13 -0
- package/dist/optional.d.ts +13 -0
- package/dist/optional.js +162 -0
- package/dist/optional.js.map +1 -0
- package/dist/schema.cjs +1297 -1004
- package/dist/schema.cjs.map +1 -1
- package/dist/schema.d.cts +4 -3
- package/dist/schema.d.ts +4 -3
- package/dist/schema.js +1298 -1005
- package/dist/schema.js.map +1 -1
- package/dist/{key-BvFvcKiR.d.cts → types-RML7bepB.d.cts} +159 -45
- package/dist/{key-BvFvcKiR.d.ts → types-RML7bepB.d.ts} +159 -45
- package/package.json +20 -1
package/README.md
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="./mne_logo-light.png#gh-light-mode-only" alt="react-mnemonic logo" width="220" />
|
|
3
|
+
<img src="./mne_logo.png#gh-dark-mode-only" alt="react-mnemonic logo" width="220" />
|
|
4
|
+
</p>
|
|
5
|
+
|
|
1
6
|
# react-mnemonic
|
|
2
7
|
|
|
3
8
|
AI-friendly, persistent, type-safe state for React.
|
|
@@ -60,9 +65,52 @@ survives a full page reload.
|
|
|
60
65
|
|
|
61
66
|
## Pick the right entrypoint
|
|
62
67
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
68
|
+
| Entrypoint | Approx ESM size | Use when |
|
|
69
|
+
| -------------------------- | --------------- | ----------------------------------------------------------------------------------- |
|
|
70
|
+
| `react-mnemonic/optional` | ~4.9 KB | You want the tiny component-library shim that falls back to local memory |
|
|
71
|
+
| `react-mnemonic/bootstrap` | ~25 KB | You need synchronous first-paint recall before React renders |
|
|
72
|
+
| `react-mnemonic/core` | ~61 KB | A provider is required and you want the lean persisted-state path |
|
|
73
|
+
| `react-mnemonic/schema` | ~80.5 KB | A provider is required and you want schema validation, autoschema, and migrations |
|
|
74
|
+
| `react-mnemonic` | ~80.5 KB | You want the top-level full entrypoint with the same schema-capable runtime surface |
|
|
75
|
+
|
|
76
|
+
These are rough current estimates from the built ESM entry files in `dist/`
|
|
77
|
+
before consumer-side minification and tree-shaking. They are useful for
|
|
78
|
+
relative comparison, not as a hard size guarantee.
|
|
79
|
+
|
|
80
|
+
## Optional persistence for component libraries
|
|
81
|
+
|
|
82
|
+
If your component may render inside or outside a `MnemonicProvider`, import the
|
|
83
|
+
optional hook instead of branching at the call site.
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
import { useMnemonicKeyOptional } from "react-mnemonic/optional";
|
|
87
|
+
|
|
88
|
+
function SearchBox() {
|
|
89
|
+
const { value, set, remove } = useMnemonicKeyOptional("draft", {
|
|
90
|
+
defaultValue: "",
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<div>
|
|
95
|
+
<input value={value} onChange={(event) => set(event.target.value)} />
|
|
96
|
+
<button onClick={remove}>Clear</button>
|
|
97
|
+
</div>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Inside a provider, the draft is persisted. Outside a provider, the same hook
|
|
103
|
+
behaves like local in-memory state without throwing.
|
|
104
|
+
|
|
105
|
+
The lean optional entrypoint exports only:
|
|
106
|
+
|
|
107
|
+
- `useMnemonicKeyOptional(...)`
|
|
108
|
+
- `useMnemonicOptional()`
|
|
109
|
+
- `defineMnemonicKey(...)`
|
|
110
|
+
|
|
111
|
+
Schema metadata such as `schema: { version }` can still be passed through the
|
|
112
|
+
optional hook. Applications pay the schema/runtime cost only when they mount a
|
|
113
|
+
schema-capable `MnemonicProvider`.
|
|
66
114
|
|
|
67
115
|
## AI resources
|
|
68
116
|
|
|
@@ -79,6 +127,7 @@ survives a full page reload.
|
|
|
79
127
|
|
|
80
128
|
- [Documentation home](https://thirtytwobits.github.io/react-mnemonic/)
|
|
81
129
|
- [Quick Start](https://thirtytwobits.github.io/react-mnemonic/docs/getting-started/quick-start)
|
|
130
|
+
- [Optional Persistence](https://thirtytwobits.github.io/react-mnemonic/docs/guides/optional-persistence)
|
|
82
131
|
- [Server Rendering](https://thirtytwobits.github.io/react-mnemonic/docs/guides/server-rendering)
|
|
83
132
|
- [Canonical Key Definitions](https://thirtytwobits.github.io/react-mnemonic/docs/guides/canonical-key-definitions)
|
|
84
133
|
- [Single Source of Truth Schemas](https://thirtytwobits.github.io/react-mnemonic/docs/guides/single-source-of-truth-schemas)
|