storion 0.8.0 → 0.8.1
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/CHANGELOG.md +220 -0
- package/README.md +1 -0
- package/dist/core/createResolver.d.ts +1 -41
- package/dist/core/createResolver.d.ts.map +1 -1
- package/dist/{index-CIFKRy71.js → index-OPaTR3zq.js} +13 -42
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/meta/meta.d.ts +36 -24
- package/dist/meta/meta.d.ts.map +1 -1
- package/dist/{meta-u3yOx5Kh.js → meta-40r-AZfe.js} +3 -0
- package/dist/persist/index.js +1 -1
- package/dist/react/index.js +15 -18
- package/dist/storion.js +14 -17
- package/package.json +3 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- `MetaEntry.fields` now supports arrays for applying meta to multiple fields at once
|
|
12
|
+
```ts
|
|
13
|
+
meta: [notPersisted.for(["password", "token"])]
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## [0.8.0] - 2024-12-21
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
- **Persist Module** (`storion/persist`)
|
|
22
|
+
- `persistMiddleware(options)` for automatic state persistence
|
|
23
|
+
- `notPersisted` meta for excluding stores or fields from persistence
|
|
24
|
+
- Supports sync and async `load`/`save` handlers
|
|
25
|
+
- `force` option to override dirty state during hydration
|
|
26
|
+
- **Meta System**
|
|
27
|
+
- `meta()` function for creating typed metadata builders
|
|
28
|
+
- `MetaType.for(field)` and `MetaType.for([fields])` for field-level meta
|
|
29
|
+
- `MetaQuery` with `.all()` and `.any()` query methods
|
|
30
|
+
- `withMeta(factory, entries)` for attaching meta to factories
|
|
31
|
+
- Meta available in middleware via `ctx.meta(type)`
|
|
32
|
+
- **Middleware Utilities**
|
|
33
|
+
- `forStores(middleware)` helper for store-only middleware
|
|
34
|
+
- `applyFor(patterns, middleware)` for conditional middleware
|
|
35
|
+
- `applyExcept(patterns, middleware)` for exclusion patterns
|
|
36
|
+
- `store.hydrate(state, { force })` - force option to override dirty properties
|
|
37
|
+
|
|
38
|
+
### Changed
|
|
39
|
+
- `StoreMiddlewareContext` now includes `meta` property for querying store metadata
|
|
40
|
+
- `FactoryMiddlewareContext` now includes `meta` property for querying factory metadata
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## [0.7.0] - 2024-12-15
|
|
45
|
+
|
|
46
|
+
### Added
|
|
47
|
+
- **DevTools Module** (`storion/devtools`)
|
|
48
|
+
- `devtoolsMiddleware()` for state inspection
|
|
49
|
+
- `__revertState` and `__takeSnapshot` injected actions
|
|
50
|
+
- State history tracking with configurable `maxHistory`
|
|
51
|
+
- DevTools panel (`storion/devtools-panel`)
|
|
52
|
+
- **withStore HOC** for React
|
|
53
|
+
- Separates data selection from rendering
|
|
54
|
+
- Automatic memoization
|
|
55
|
+
- Direct mode and HOC mode
|
|
56
|
+
- `createWithStore(useContextHook)` factory for custom `withStore` implementations
|
|
57
|
+
- `create()` shorthand for single-store apps returning `[instance, useHook, withStore]`
|
|
58
|
+
|
|
59
|
+
### Changed
|
|
60
|
+
- Improved TypeScript inference for store actions
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## [0.6.0] - 2024-12-01
|
|
65
|
+
|
|
66
|
+
### Added
|
|
67
|
+
- **Async Module** (`storion/async`)
|
|
68
|
+
- `async.fresh<T>()` - throws during loading (Suspense-compatible)
|
|
69
|
+
- `async.stale<T>(initialData)` - returns stale data during loading
|
|
70
|
+
- `async.wait(state)` - extracts data or throws
|
|
71
|
+
- Automatic request cancellation via `ctx.signal`
|
|
72
|
+
- `ctx.safe(promise)` for effect-safe async operations
|
|
73
|
+
- `trigger(action, deps, ...args)` for declarative data fetching in components
|
|
74
|
+
|
|
75
|
+
### Changed
|
|
76
|
+
- Effects now require synchronous functions (use `ctx.safe()` for async)
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## [0.5.0] - 2024-11-15
|
|
81
|
+
|
|
82
|
+
### Added
|
|
83
|
+
- **Focus (Lens-like Access)**
|
|
84
|
+
- `focus(path)` for nested state access
|
|
85
|
+
- Returns `[getter, setter]` tuple
|
|
86
|
+
- Type-safe path inference
|
|
87
|
+
- **Reactive Effects**
|
|
88
|
+
- `effect(fn, options)` with automatic dependency tracking
|
|
89
|
+
- `ctx.cleanup()` for teardown logic
|
|
90
|
+
- `ctx.refresh()` for manual re-execution
|
|
91
|
+
- Error handling strategies: `"throw"`, `"ignore"`, `"retry"`
|
|
92
|
+
- `batch(fn)` for batching multiple state updates
|
|
93
|
+
- `untrack(fn)` for reading state without tracking
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## [0.4.0] - 2024-11-01
|
|
98
|
+
|
|
99
|
+
### Added
|
|
100
|
+
- **Middleware System**
|
|
101
|
+
- `container({ middleware: [...] })` for middleware injection
|
|
102
|
+
- Middleware receives `MiddlewareContext` with `type`, `next`, `resolver`
|
|
103
|
+
- Discriminated union: `StoreMiddlewareContext` vs `FactoryMiddlewareContext`
|
|
104
|
+
- `createLoggingMiddleware()` built-in middleware
|
|
105
|
+
- `createValidationMiddleware()` built-in middleware
|
|
106
|
+
|
|
107
|
+
### Changed
|
|
108
|
+
- Container now uses middleware chain pattern
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## [0.3.0] - 2024-10-15
|
|
113
|
+
|
|
114
|
+
### Added
|
|
115
|
+
- **Store Lifecycle**
|
|
116
|
+
- `lifetime: "keepAlive"` (default) - persists until container disposal
|
|
117
|
+
- `lifetime: "autoDispose"` - disposes when no subscribers
|
|
118
|
+
- `store.dispose()` method
|
|
119
|
+
- `store.subscribe(listener)` for change notifications
|
|
120
|
+
- `store.dehydrate()` for serializing state
|
|
121
|
+
- `store.hydrate(state)` for restoring state
|
|
122
|
+
- `store.dirty` property tracking modified fields
|
|
123
|
+
- `store.reset()` to restore initial state
|
|
124
|
+
|
|
125
|
+
### Changed
|
|
126
|
+
- Stores now track dirty state automatically
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## [0.2.0] - 2024-10-01
|
|
131
|
+
|
|
132
|
+
### Added
|
|
133
|
+
- **Dependency Injection**
|
|
134
|
+
- `container()` for managing store instances
|
|
135
|
+
- `get(factory)` for resolving dependencies
|
|
136
|
+
- Services (plain factories) support
|
|
137
|
+
- `mixin(factory)` for setup-time composition
|
|
138
|
+
- `StoreProvider` React component
|
|
139
|
+
- `useContainer()` hook
|
|
140
|
+
|
|
141
|
+
### Changed
|
|
142
|
+
- Stores are now lazily instantiated via container
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## [0.1.0] - 2024-09-15
|
|
147
|
+
|
|
148
|
+
### Added
|
|
149
|
+
- **Core Store**
|
|
150
|
+
- `store(options)` factory function
|
|
151
|
+
- `state` - reactive state object
|
|
152
|
+
- `actions` - returned from `setup()` function
|
|
153
|
+
- `update(producer)` for Immer-style nested updates
|
|
154
|
+
- **React Integration**
|
|
155
|
+
- `useStore(selector)` hook with auto-tracking
|
|
156
|
+
- `useLocalStore(spec)` for component-scoped stores
|
|
157
|
+
- **Reactivity**
|
|
158
|
+
- Proxy-based dependency tracking
|
|
159
|
+
- Fine-grained updates (only re-render on accessed properties)
|
|
160
|
+
- `pick(state, equality)` for custom comparison
|
|
161
|
+
- **Type Safety**
|
|
162
|
+
- Full TypeScript support
|
|
163
|
+
- Inferred state and action types
|
|
164
|
+
- **Equality Utilities**
|
|
165
|
+
- `strictEqual` (default)
|
|
166
|
+
- `shallowEqual`
|
|
167
|
+
- `deepEqual`
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## Migration Guides
|
|
172
|
+
|
|
173
|
+
### Migrating to 0.8.0
|
|
174
|
+
|
|
175
|
+
#### Meta System Changes
|
|
176
|
+
If you were using internal meta APIs, update to the new public API:
|
|
177
|
+
|
|
178
|
+
```ts
|
|
179
|
+
// Before (internal)
|
|
180
|
+
spec.meta // was MetaEntry[]
|
|
181
|
+
|
|
182
|
+
// After (0.8.0)
|
|
183
|
+
ctx.meta(persistMeta).store // query store-level
|
|
184
|
+
ctx.meta(persistMeta).fields // query field-level
|
|
185
|
+
ctx.meta.all(type) // get all values
|
|
186
|
+
ctx.meta.any(type1, type2) // check existence
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Migrating to 0.6.0
|
|
190
|
+
|
|
191
|
+
#### Async Effects
|
|
192
|
+
Effects must now be synchronous:
|
|
193
|
+
|
|
194
|
+
```ts
|
|
195
|
+
// Before (broken in 0.6.0)
|
|
196
|
+
effect(async (ctx) => {
|
|
197
|
+
const data = await fetchData();
|
|
198
|
+
state.data = data;
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
// After
|
|
202
|
+
effect((ctx) => {
|
|
203
|
+
ctx.safe(fetchData()).then((data) => {
|
|
204
|
+
state.data = data;
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
[Unreleased]: https://github.com/linq2js/storion/compare/v0.8.0...HEAD
|
|
212
|
+
[0.8.0]: https://github.com/linq2js/storion/compare/v0.7.0...v0.8.0
|
|
213
|
+
[0.7.0]: https://github.com/linq2js/storion/compare/v0.6.0...v0.7.0
|
|
214
|
+
[0.6.0]: https://github.com/linq2js/storion/compare/v0.5.0...v0.6.0
|
|
215
|
+
[0.5.0]: https://github.com/linq2js/storion/compare/v0.4.0...v0.5.0
|
|
216
|
+
[0.4.0]: https://github.com/linq2js/storion/compare/v0.3.0...v0.4.0
|
|
217
|
+
[0.3.0]: https://github.com/linq2js/storion/compare/v0.2.0...v0.3.0
|
|
218
|
+
[0.2.0]: https://github.com/linq2js/storion/compare/v0.1.0...v0.2.0
|
|
219
|
+
[0.1.0]: https://github.com/linq2js/storion/releases/tag/v0.1.0
|
|
220
|
+
|
package/README.md
CHANGED
|
@@ -1,47 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Resolver, ResolverOptions } from '../types';
|
|
2
2
|
|
|
3
|
-
export type { Factory, Middleware, MiddlewareContext, Resolver, ResolverOptions, } from '../types';
|
|
4
3
|
/**
|
|
5
4
|
* Create a new resolver with optional middleware and parent.
|
|
6
5
|
*/
|
|
7
6
|
export declare function createResolver(options?: ResolverOptions): Resolver;
|
|
8
|
-
/**
|
|
9
|
-
* Create a middleware that only applies to factories matching a predicate.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```ts
|
|
13
|
-
* const storeOnlyMiddleware = when(
|
|
14
|
-
* (factory) => is(factory, "store.spec"),
|
|
15
|
-
* (ctx) => {
|
|
16
|
-
* console.log("Creating store:", ctx.factory.name);
|
|
17
|
-
* return ctx.next();
|
|
18
|
-
* }
|
|
19
|
-
* );
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
export declare function when(predicate: (factory: Factory) => boolean, middleware: Middleware): Middleware;
|
|
23
|
-
/**
|
|
24
|
-
* Create a logging middleware for debugging.
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ```ts
|
|
28
|
-
* const app = createResolver({
|
|
29
|
-
* middleware: [createLoggingMiddleware("App")],
|
|
30
|
-
* });
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
export declare function createLoggingMiddleware(prefix?: string): Middleware;
|
|
34
|
-
/**
|
|
35
|
-
* Create a middleware that validates factory results.
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```ts
|
|
39
|
-
* const validateMiddleware = createValidationMiddleware((result) => {
|
|
40
|
-
* if (result === null || result === undefined) {
|
|
41
|
-
* throw new Error("Factory returned null/undefined");
|
|
42
|
-
* }
|
|
43
|
-
* });
|
|
44
|
-
* ```
|
|
45
|
-
*/
|
|
46
|
-
export declare function createValidationMiddleware(validate: (result: unknown, factory: Factory) => void): Middleware;
|
|
47
7
|
//# sourceMappingURL=createResolver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createResolver.d.ts","sourceRoot":"","sources":["../../src/core/createResolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"createResolver.d.ts","sourceRoot":"","sources":["../../src/core/createResolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAGV,QAAQ,EACR,eAAe,EAIhB,MAAM,UAAU,CAAC;AAsClB;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,GAAE,eAAoB,GAAG,QAAQ,CAiKtE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as SetupPhaseError, c as LifetimeMismatchError, w as withHooks, I as InvalidActionError, h as hasReadHook, t as trackRead, f as hasWriteHook, g as trackWrite, d as StoreDisposedError, s as scheduleNotification, b as batch, u as untrack, i as getHooks, H as HooksContextError } from "./effect-C6h0PDDI.js";
|
|
2
2
|
import { e as emitter } from "./emitter-j4rC71vY.js";
|
|
3
|
-
import "./meta-
|
|
3
|
+
import "./meta-40r-AZfe.js";
|
|
4
4
|
const STORION_TYPE = Symbol("STORION");
|
|
5
5
|
function is$1(value, kind) {
|
|
6
6
|
return value !== null && (typeof value === "object" || typeof value === "function") && STORION_TYPE in value && value[STORION_TYPE] === kind;
|
|
@@ -2621,32 +2621,6 @@ function createResolver(options = {}) {
|
|
|
2621
2621
|
};
|
|
2622
2622
|
return resolver;
|
|
2623
2623
|
}
|
|
2624
|
-
function when(predicate, middleware) {
|
|
2625
|
-
return (ctx) => {
|
|
2626
|
-
if (predicate(ctx.factory)) {
|
|
2627
|
-
return middleware(ctx);
|
|
2628
|
-
}
|
|
2629
|
-
return ctx.next();
|
|
2630
|
-
};
|
|
2631
|
-
}
|
|
2632
|
-
function createLoggingMiddleware(prefix = "Resolver") {
|
|
2633
|
-
return (ctx) => {
|
|
2634
|
-
const name = ctx.factory.name || "anonymous";
|
|
2635
|
-
console.log(`[${prefix}] Creating: ${name}`);
|
|
2636
|
-
const start = performance.now();
|
|
2637
|
-
const result = ctx.next();
|
|
2638
|
-
const duration = (performance.now() - start).toFixed(2);
|
|
2639
|
-
console.log(`[${prefix}] Created: ${name} (${duration}ms)`);
|
|
2640
|
-
return result;
|
|
2641
|
-
};
|
|
2642
|
-
}
|
|
2643
|
-
function createValidationMiddleware(validate) {
|
|
2644
|
-
return (ctx) => {
|
|
2645
|
-
const result = ctx.next();
|
|
2646
|
-
validate(result, ctx.factory);
|
|
2647
|
-
return result;
|
|
2648
|
-
};
|
|
2649
|
-
}
|
|
2650
2624
|
let defaultMiddlewareConfig = {};
|
|
2651
2625
|
const container = function(options = {}) {
|
|
2652
2626
|
const middleware = [
|
|
@@ -2957,10 +2931,7 @@ function withMeta(factory, meta) {
|
|
|
2957
2931
|
});
|
|
2958
2932
|
}
|
|
2959
2933
|
export {
|
|
2960
|
-
|
|
2961
|
-
unwrapFn as B,
|
|
2962
|
-
isWrappedFn as C,
|
|
2963
|
-
withMeta as D,
|
|
2934
|
+
withMeta as A,
|
|
2964
2935
|
STORION_TYPE as S,
|
|
2965
2936
|
is$1 as a,
|
|
2966
2937
|
isStorion as b,
|
|
@@ -2974,18 +2945,18 @@ export {
|
|
|
2974
2945
|
isStoreContext as j,
|
|
2975
2946
|
isSelectorContext as k,
|
|
2976
2947
|
createResolver as l,
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2948
|
+
applyFor as m,
|
|
2949
|
+
applyExcept as n,
|
|
2950
|
+
forStores as o,
|
|
2980
2951
|
pick as p,
|
|
2981
|
-
|
|
2952
|
+
equality as q,
|
|
2982
2953
|
resolveEquality as r,
|
|
2983
2954
|
store as s,
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2955
|
+
shallowEqual as t,
|
|
2956
|
+
deepEqual as u,
|
|
2957
|
+
strictEqual as v,
|
|
2958
|
+
trigger as w,
|
|
2959
|
+
wrapFn as x,
|
|
2960
|
+
unwrapFn as y,
|
|
2961
|
+
isWrappedFn as z
|
|
2991
2962
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export { is, isStorion, getKind, isSpec, isContainer, isStore, isFocus, isAction
|
|
|
8
8
|
export { store } from './core/store';
|
|
9
9
|
export { container } from './core/container';
|
|
10
10
|
export { batch, untrack } from './core/tracking';
|
|
11
|
-
export { createResolver
|
|
11
|
+
export { createResolver } from './core/createResolver';
|
|
12
12
|
export { pick } from './core/pick';
|
|
13
13
|
export { effect, type EffectFn, type EffectContext, type EffectOptions, type EffectErrorStrategy, type EffectErrorContext, type EffectRetryConfig, } from './core/effect';
|
|
14
14
|
export { applyFor, applyExcept, forStores, type SpecPattern, } from './core/middleware';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,YAAY,EACZ,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,cAAc,EAC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,cAAc,EAAE,MAAM,WAAW,CAAC;AAGzD,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG3E,OAAO,EACL,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,yBAAyB,EACzB,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/meta/meta.d.ts
CHANGED
|
@@ -4,13 +4,35 @@ import { MetaType } from '../types';
|
|
|
4
4
|
* Create a metadata builder for decorating stores with custom metadata.
|
|
5
5
|
*
|
|
6
6
|
* Meta allows libraries and users to attach arbitrary typed metadata to:
|
|
7
|
-
* - Store level: `myMeta(value)` - applies to the entire store
|
|
8
|
-
* - Field level: `myMeta.for("fieldName", value)` - applies to specific
|
|
7
|
+
* - Store level: `myMeta()` or `myMeta(value)` - applies to the entire store
|
|
8
|
+
* - Field level: `myMeta.for("fieldName")` or `myMeta.for("fieldName", value)` - applies to specific field
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
* or use `ctx.meta.all(type)` for all values.
|
|
10
|
+
* ## Overloads
|
|
12
11
|
*
|
|
13
|
-
*
|
|
12
|
+
* ### 1. `meta()` - Boolean flag meta
|
|
13
|
+
* Creates a meta type where calling `myMeta()` returns `MetaEntry<any, true>`
|
|
14
|
+
* ```ts
|
|
15
|
+
* const persist = meta();
|
|
16
|
+
* persist() // MetaEntry with value: true
|
|
17
|
+
* persist.for("field") // MetaEntry with value: true for field
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* ### 2. `meta<TValue>()` - Typed value meta (requires value argument)
|
|
21
|
+
* Creates a meta type where calling `myMeta(value)` returns `MetaEntry<any, TValue>`
|
|
22
|
+
* ```ts
|
|
23
|
+
* const priority = meta<number>();
|
|
24
|
+
* priority(1) // MetaEntry with value: 1
|
|
25
|
+
* priority.for("field", 5) // MetaEntry with value: 5 for field
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* ### 3. `meta(builder)` - Custom builder meta
|
|
29
|
+
* Creates a meta type with custom value transformation
|
|
30
|
+
* ```ts
|
|
31
|
+
* const config = meta((name: string, value: number) => ({ name, value }));
|
|
32
|
+
* config("timeout", 5000) // MetaEntry with value: { name: "timeout", value: 5000 }
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @example Boolean flag meta
|
|
14
36
|
* ```ts
|
|
15
37
|
* const persist = meta();
|
|
16
38
|
*
|
|
@@ -19,26 +41,24 @@ import { MetaType } from '../types';
|
|
|
19
41
|
* meta: [persist()],
|
|
20
42
|
* });
|
|
21
43
|
*
|
|
22
|
-
* ctx.meta(persist).store;
|
|
23
|
-
* ctx.meta.all(persist).store; // [true] (all values)
|
|
44
|
+
* ctx.meta(persist).store; // true
|
|
24
45
|
* ```
|
|
25
46
|
*
|
|
26
|
-
* @example
|
|
47
|
+
* @example Typed value meta
|
|
27
48
|
* ```ts
|
|
28
|
-
* const priority = meta(
|
|
49
|
+
* const priority = meta<number>();
|
|
29
50
|
*
|
|
30
51
|
* const criticalStore = store({
|
|
31
52
|
* state: { data: null },
|
|
32
|
-
* meta: [priority(1)
|
|
53
|
+
* meta: [priority(1)],
|
|
33
54
|
* });
|
|
34
55
|
*
|
|
35
|
-
* ctx.meta(priority).store;
|
|
36
|
-
* ctx.meta.all(priority).store; // [1, 2] (all)
|
|
56
|
+
* ctx.meta(priority).store; // 1
|
|
37
57
|
* ```
|
|
38
58
|
*
|
|
39
59
|
* @example Field-level meta
|
|
40
60
|
* ```ts
|
|
41
|
-
* const validate = meta(
|
|
61
|
+
* const validate = meta<string>();
|
|
42
62
|
*
|
|
43
63
|
* const formStore = store({
|
|
44
64
|
* state: { email: "", age: 0 },
|
|
@@ -52,20 +72,12 @@ import { MetaType } from '../types';
|
|
|
52
72
|
* formStore.meta(validate).fields.age; // "positive-number"
|
|
53
73
|
* ```
|
|
54
74
|
*
|
|
55
|
-
* @example Check meta existence
|
|
56
|
-
* ```ts
|
|
57
|
-
* const persist = meta();
|
|
58
|
-
* const sync = meta();
|
|
59
|
-
*
|
|
60
|
-
* userStore.meta.any(persist); // true
|
|
61
|
-
* userStore.meta.any(sync); // false
|
|
62
|
-
* userStore.meta.any(persist, sync); // true (has at least one)
|
|
63
|
-
* ```
|
|
64
|
-
*
|
|
65
75
|
* @param builder - Optional function to transform arguments into meta value.
|
|
66
|
-
* If omitted, meta value
|
|
76
|
+
* If omitted with no type param, meta value is `true`.
|
|
77
|
+
* If omitted with type param, first argument is returned as value.
|
|
67
78
|
* @returns A MetaType that creates MetaEntry objects
|
|
68
79
|
*/
|
|
69
80
|
export declare function meta(): MetaType<any, [], true>;
|
|
81
|
+
export declare function meta<TValue>(): MetaType<any, [value: TValue], TValue>;
|
|
70
82
|
export declare function meta<TValue, TArgs extends any[]>(builder: (...args: TArgs) => TValue): MetaType<any, TArgs, TValue>;
|
|
71
83
|
//# sourceMappingURL=meta.d.ts.map
|
package/dist/meta/meta.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../src/meta/meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../src/meta/meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAsB,MAAM,UAAU,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4EG;AACH,wBAAgB,IAAI,IAAI,QAAQ,CAAC,GAAG,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;AAChD,wBAAgB,IAAI,CAAC,MAAM,KAAK,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC;AACvE,wBAAgB,IAAI,CAAC,MAAM,EAAE,KAAK,SAAS,GAAG,EAAE,EAC9C,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,MAAM,GAClC,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC"}
|
package/dist/persist/index.js
CHANGED
package/dist/react/index.js
CHANGED
|
@@ -2,12 +2,12 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
import { memo, useRef, useMemo, createElement, createContext, useContext, useReducer, useEffect, useLayoutEffect, useState, forwardRef } from "react";
|
|
5
|
-
import { c as container, i as isSpec, S as STORION_TYPE, r as resolveEquality, s as store } from "../index-
|
|
6
|
-
import {
|
|
5
|
+
import { c as container, i as isSpec, S as STORION_TYPE, r as resolveEquality, s as store } from "../index-OPaTR3zq.js";
|
|
6
|
+
import { n, m, l, u, q, o, g, a, h, d, f, k, e, j, b, z, p, t, v, w, y, A, x } from "../index-OPaTR3zq.js";
|
|
7
7
|
import { P as ProviderMissingError, L as LocalStoreDependencyError, w as withHooks, A as AsyncFunctionError } from "../effect-C6h0PDDI.js";
|
|
8
8
|
import { E, H, I, c, a as a2, d as d2, S, b as b2, e as e2, u as u2 } from "../effect-C6h0PDDI.js";
|
|
9
9
|
import { jsx } from "react/jsx-runtime";
|
|
10
|
-
import { m as m2 } from "../meta-
|
|
10
|
+
import { m as m2 } from "../meta-40r-AZfe.js";
|
|
11
11
|
const StoreContext = createContext(null);
|
|
12
12
|
const StoreProvider = memo(
|
|
13
13
|
({ container: value, children }) => {
|
|
@@ -416,19 +416,17 @@ export {
|
|
|
416
416
|
d2 as StoreDisposedError,
|
|
417
417
|
StoreProvider,
|
|
418
418
|
S as StorionError,
|
|
419
|
-
|
|
420
|
-
|
|
419
|
+
n as applyExcept,
|
|
420
|
+
m as applyFor,
|
|
421
421
|
b2 as batch,
|
|
422
422
|
container,
|
|
423
423
|
create,
|
|
424
|
-
m as createLoggingMiddleware,
|
|
425
424
|
l as createResolver,
|
|
426
|
-
n as createValidationMiddleware,
|
|
427
425
|
createWithStore,
|
|
428
|
-
|
|
426
|
+
u as deepEqual,
|
|
429
427
|
e2 as effect,
|
|
430
|
-
|
|
431
|
-
|
|
428
|
+
q as equality,
|
|
429
|
+
o as forStores,
|
|
432
430
|
g as getKind,
|
|
433
431
|
a as is,
|
|
434
432
|
h as isAction,
|
|
@@ -439,19 +437,18 @@ export {
|
|
|
439
437
|
e as isStore,
|
|
440
438
|
j as isStoreContext,
|
|
441
439
|
b as isStorion,
|
|
442
|
-
|
|
440
|
+
z as isWrappedFn,
|
|
443
441
|
m2 as meta,
|
|
444
442
|
p as pick,
|
|
445
|
-
|
|
443
|
+
t as shallowEqual,
|
|
446
444
|
store,
|
|
447
|
-
|
|
448
|
-
|
|
445
|
+
v as strictEqual,
|
|
446
|
+
w as trigger,
|
|
449
447
|
u2 as untrack,
|
|
450
|
-
|
|
448
|
+
y as unwrapFn,
|
|
451
449
|
useContainer,
|
|
452
450
|
useStore,
|
|
453
|
-
|
|
454
|
-
D as withMeta,
|
|
451
|
+
A as withMeta,
|
|
455
452
|
withStore,
|
|
456
|
-
|
|
453
|
+
x as wrapFn
|
|
457
454
|
};
|
package/dist/storion.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S,
|
|
1
|
+
import { S, n, m, c, l, u, q, o, g, a, h, d, f, k, i, e, j, b, z, p, t, s, v, w, y, A, x } from "./index-OPaTR3zq.js";
|
|
2
2
|
import { A as A2, E, H, I, c as c2, L, P, a as a2, d as d2, S as S2, b as b2, e as e2, u as u2 } from "./effect-C6h0PDDI.js";
|
|
3
|
-
import { m as m2 } from "./meta-
|
|
3
|
+
import { m as m2 } from "./meta-40r-AZfe.js";
|
|
4
4
|
export {
|
|
5
5
|
A2 as AsyncFunctionError,
|
|
6
6
|
E as EffectRefreshError,
|
|
@@ -13,17 +13,15 @@ export {
|
|
|
13
13
|
a2 as SetupPhaseError,
|
|
14
14
|
d2 as StoreDisposedError,
|
|
15
15
|
S2 as StorionError,
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
n as applyExcept,
|
|
17
|
+
m as applyFor,
|
|
18
18
|
b2 as batch,
|
|
19
19
|
c as container,
|
|
20
|
-
m as createLoggingMiddleware,
|
|
21
20
|
l as createResolver,
|
|
22
|
-
|
|
23
|
-
x as deepEqual,
|
|
21
|
+
u as deepEqual,
|
|
24
22
|
e2 as effect,
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
q as equality,
|
|
24
|
+
o as forStores,
|
|
27
25
|
g as getKind,
|
|
28
26
|
a as is,
|
|
29
27
|
h as isAction,
|
|
@@ -34,16 +32,15 @@ export {
|
|
|
34
32
|
e as isStore,
|
|
35
33
|
j as isStoreContext,
|
|
36
34
|
b as isStorion,
|
|
37
|
-
|
|
35
|
+
z as isWrappedFn,
|
|
38
36
|
m2 as meta,
|
|
39
37
|
p as pick,
|
|
40
|
-
|
|
38
|
+
t as shallowEqual,
|
|
41
39
|
s as store,
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
v as strictEqual,
|
|
41
|
+
w as trigger,
|
|
44
42
|
u2 as untrack,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
A as wrapFn
|
|
43
|
+
y as unwrapFn,
|
|
44
|
+
A as withMeta,
|
|
45
|
+
x as wrapFn
|
|
49
46
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "storion",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "Reactive stores for modern apps. Type-safe. Auto-tracked. Effortlessly composable",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/storion.js",
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"files": [
|
|
36
|
-
"dist"
|
|
36
|
+
"dist",
|
|
37
|
+
"CHANGELOG.md"
|
|
37
38
|
],
|
|
38
39
|
"scripts": {
|
|
39
40
|
"dev": "vite build --watch",
|