storion 0.11.0 → 0.11.2
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/dist/async/async.d.ts +31 -0
- package/dist/async/async.d.ts.map +1 -1
- package/dist/async/index.js +8 -601
- package/dist/async/safe.d.ts +0 -12
- package/dist/async/safe.d.ts.map +1 -1
- package/dist/{effect-1beiYe_c.js → effect-BfoYEdFF.js} +686 -61
- package/dist/isPromiseLike-bFkfHAbm.js +6 -0
- package/dist/persist/index.js +1 -3
- package/dist/react/create.d.ts +5 -4
- package/dist/react/create.d.ts.map +1 -1
- package/dist/react/index.js +14 -14
- package/dist/storion.js +15 -15
- package/package.json +1 -1
package/dist/persist/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { m as meta } from "../meta-40r-AZfe.js";
|
|
2
|
-
|
|
3
|
-
return typeof value === "object" && value !== null && "then" in value && typeof value.then === "function";
|
|
4
|
-
}
|
|
2
|
+
import { i as isPromiseLike } from "../isPromiseLike-bFkfHAbm.js";
|
|
5
3
|
const notPersisted = meta();
|
|
6
4
|
function persist(options) {
|
|
7
5
|
const { filter, fields, handler, onError, force = false } = options;
|
package/dist/react/create.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { StateBase, ActionsBase, StoreOptions, StoreInstance, StableResult, ContainerOptions } from '../types';
|
|
1
|
+
import { StateBase, ActionsBase, StoreOptions, StoreInstance, StableResult, ContainerOptions, SelectorContext } from '../types';
|
|
2
2
|
import { BoundWithStore } from './withStore';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Selector for create() hook.
|
|
6
|
-
* Receives state and actions directly (no get needed).
|
|
6
|
+
* Receives state and actions directly (no get needed), plus SelectorContext for advanced features.
|
|
7
7
|
*/
|
|
8
|
-
export type CreateSelector<TState extends StateBase, TActions extends ActionsBase, T> = (state: Readonly<TState>, actions: TActions) => T;
|
|
8
|
+
export type CreateSelector<TState extends StateBase, TActions extends ActionsBase, T> = (state: Readonly<TState>, actions: TActions, ctx: SelectorContext) => T;
|
|
9
9
|
/**
|
|
10
10
|
* Custom hook returned by create().
|
|
11
11
|
*/
|
|
@@ -49,9 +49,10 @@ export type CreateResult<TState extends StateBase, TActions extends ActionsBase>
|
|
|
49
49
|
*
|
|
50
50
|
* // Use the hook in React components
|
|
51
51
|
* function Counter() {
|
|
52
|
-
* const { count, increment } = useCounter((state, actions) => ({
|
|
52
|
+
* const { count, increment } = useCounter((state, actions, ctx) => ({
|
|
53
53
|
* count: state.count,
|
|
54
54
|
* increment: actions.increment,
|
|
55
|
+
* // ctx provides: mixin, scoped, once, id, container, etc.
|
|
55
56
|
* }));
|
|
56
57
|
*
|
|
57
58
|
* return <button onClick={increment}>{count}</button>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/react/create.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,WAAW,EACX,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,gBAAgB,
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/react/create.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,WAAW,EACX,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,eAAe,EAChB,MAAM,UAAU,CAAC;AAIlB,OAAO,EAEL,KAAK,cAAc,EAEpB,MAAM,aAAa,CAAC;AAErB;;;GAGG;AACH,MAAM,MAAM,cAAc,CACxB,MAAM,SAAS,SAAS,EACxB,QAAQ,SAAS,WAAW,EAC5B,CAAC,IACC,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,eAAe,KAAK,CAAC,CAAC;AAE5E;;GAEG;AACH,MAAM,MAAM,eAAe,CACzB,MAAM,SAAS,SAAS,EACxB,QAAQ,SAAS,WAAW,IAC1B,CAAC,CAAC,SAAS,MAAM,EACnB,QAAQ,EAAE,cAAc,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC,KAC1C,YAAY,CAAC,CAAC,CAAC,CAAC;AAErB;;;GAGG;AACH,MAAM,MAAM,mBAAmB,CAC7B,MAAM,SAAS,SAAS,EACxB,QAAQ,SAAS,WAAW,IAC1B,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAC;AAE1C;;;GAGG;AACH,MAAM,MAAM,gBAAgB,CAC1B,MAAM,SAAS,SAAS,EACxB,QAAQ,SAAS,WAAW,IAC1B,cAAc,CAAC,mBAAmB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;AAE1D;;GAEG;AACH,MAAM,MAAM,YAAY,CACtB,MAAM,SAAS,SAAS,EACxB,QAAQ,SAAS,WAAW,IAC1B,SAAS;IACX,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC/B,eAAe,CAAC,MAAM,EAAE,QAAQ,CAAC;IACjC,gBAAgB,CAAC,MAAM,EAAE,QAAQ,CAAC;CACnC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,wBAAgB,MAAM,CAAC,MAAM,SAAS,SAAS,EAAE,QAAQ,SAAS,WAAW,EAC3E,YAAY,EAAE,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,EAC5C,gBAAgB,CAAC,EAAE,gBAAgB,GAClC,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,CAqChC"}
|
package/dist/react/index.js
CHANGED
|
@@ -4,11 +4,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4
4
|
import { memo, useRef, useMemo, createElement, createContext, useContext, useId, useReducer, useState, useEffect, useLayoutEffect, forwardRef } from "react";
|
|
5
5
|
import { container } from "../storion.js";
|
|
6
6
|
import { append, applyExcept, applyFor, clamp, decrement, disposalGroup, divide, forStores, getNamedGroup, increment, list, map, merge, multiply, prepend, reset, resolver, toggle, trigger, withMeta } from "../storion.js";
|
|
7
|
-
import { P as ProviderMissingError, w as withHooks,
|
|
8
|
-
import { E, H, I, L,
|
|
7
|
+
import { P as ProviderMissingError, w as withHooks, e as AsyncFunctionError, t as tryStabilize, s as strictEqual, S as ScopedOutsideSelectorError, f as storeTuple, g as isSpec, h as STORION_TYPE, j as dev, k as resolveEquality, l as store } from "../effect-BfoYEdFF.js";
|
|
8
|
+
import { E, H, I, L, C, z, B, y, n, x, o, q, m, p, D, v, u } from "../effect-BfoYEdFF.js";
|
|
9
9
|
import { e as emitter } from "../emitter-j4rC71vY.js";
|
|
10
10
|
import { jsx } from "react/jsx-runtime";
|
|
11
|
-
import { m } from "../meta-40r-AZfe.js";
|
|
11
|
+
import { m as m2 } from "../meta-40r-AZfe.js";
|
|
12
12
|
const StoreContext = createContext(null);
|
|
13
13
|
const StoreProvider = memo(
|
|
14
14
|
({ container: value, children }) => {
|
|
@@ -346,9 +346,9 @@ function create(storeOptions, containerOptions) {
|
|
|
346
346
|
const dedicatedContainer = container(containerOptions);
|
|
347
347
|
const instance = dedicatedContainer.get(spec);
|
|
348
348
|
const useCreatedStore = (selector) => {
|
|
349
|
-
return useStoreWithContainer((
|
|
350
|
-
const [state, actions] = get(spec);
|
|
351
|
-
return selector(state, actions);
|
|
349
|
+
return useStoreWithContainer((ctx) => {
|
|
350
|
+
const [state, actions] = ctx.get(spec);
|
|
351
|
+
return selector(state, actions, ctx);
|
|
352
352
|
}, dedicatedContainer);
|
|
353
353
|
};
|
|
354
354
|
const useCreatedStoreContext = (selector) => {
|
|
@@ -409,17 +409,17 @@ export {
|
|
|
409
409
|
H as HooksContextError,
|
|
410
410
|
I as InvalidActionError,
|
|
411
411
|
L as LifetimeMismatchError,
|
|
412
|
-
|
|
412
|
+
C as LocalStoreDependencyError,
|
|
413
413
|
ProviderMissingError,
|
|
414
414
|
STORION_TYPE,
|
|
415
|
-
|
|
416
|
-
|
|
415
|
+
z as SetupPhaseError,
|
|
416
|
+
B as StoreDisposedError,
|
|
417
417
|
StoreProvider,
|
|
418
418
|
y as StorionError,
|
|
419
419
|
append,
|
|
420
420
|
applyExcept,
|
|
421
421
|
applyFor,
|
|
422
|
-
|
|
422
|
+
n as batch,
|
|
423
423
|
clamp,
|
|
424
424
|
container,
|
|
425
425
|
create,
|
|
@@ -427,19 +427,19 @@ export {
|
|
|
427
427
|
x as deepEqual,
|
|
428
428
|
disposalGroup,
|
|
429
429
|
divide,
|
|
430
|
-
|
|
430
|
+
o as effect,
|
|
431
431
|
q as equality,
|
|
432
432
|
forStores,
|
|
433
433
|
getNamedGroup,
|
|
434
434
|
increment,
|
|
435
|
-
|
|
435
|
+
m as is,
|
|
436
436
|
list,
|
|
437
437
|
map,
|
|
438
438
|
merge,
|
|
439
|
-
|
|
439
|
+
m2 as meta,
|
|
440
440
|
multiply,
|
|
441
441
|
p as pick,
|
|
442
|
-
|
|
442
|
+
D as pool,
|
|
443
443
|
prepend,
|
|
444
444
|
reset,
|
|
445
445
|
resolver,
|
package/dist/storion.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { F as tryDispose, g as isSpec, u as untrack, h as STORION_TYPE, n as batch, G as unwrapFn, v as shallowEqual, k as resolveEquality } from "./effect-BfoYEdFF.js";
|
|
2
|
+
import { e, E, H, I, L, C, P, z, B, y, x, o, q, m, p, D, l, s } from "./effect-BfoYEdFF.js";
|
|
3
3
|
import { e as emitter } from "./emitter-j4rC71vY.js";
|
|
4
|
-
import { m } from "./meta-40r-AZfe.js";
|
|
4
|
+
import { m as m2 } from "./meta-40r-AZfe.js";
|
|
5
5
|
function createMetaQuery(entries) {
|
|
6
6
|
const entryArray = Array.isArray(entries) ? entries : entries ? [entries] : [];
|
|
7
7
|
const single = (type) => {
|
|
@@ -557,7 +557,7 @@ function list(options) {
|
|
|
557
557
|
}
|
|
558
558
|
}
|
|
559
559
|
if (removed.length === 0) return 0;
|
|
560
|
-
const sortedIndices = [...indicesToRemove].sort((
|
|
560
|
+
const sortedIndices = [...indicesToRemove].sort((a, b) => b - a);
|
|
561
561
|
batch(() => {
|
|
562
562
|
setter((draft) => {
|
|
563
563
|
const arr = draft ?? [];
|
|
@@ -597,7 +597,7 @@ function list(options) {
|
|
|
597
597
|
}
|
|
598
598
|
}
|
|
599
599
|
if (removed.length === 0) return 0;
|
|
600
|
-
const sortedIndices = [...indicesToRemove].sort((
|
|
600
|
+
const sortedIndices = [...indicesToRemove].sort((a, b) => b - a);
|
|
601
601
|
batch(() => {
|
|
602
602
|
setter((draft) => {
|
|
603
603
|
const arr = draft ?? [];
|
|
@@ -1106,16 +1106,16 @@ function withMeta(factory, meta) {
|
|
|
1106
1106
|
});
|
|
1107
1107
|
}
|
|
1108
1108
|
export {
|
|
1109
|
-
|
|
1109
|
+
e as AsyncFunctionError,
|
|
1110
1110
|
E as EffectRefreshError,
|
|
1111
1111
|
H as HooksContextError,
|
|
1112
1112
|
I as InvalidActionError,
|
|
1113
1113
|
L as LifetimeMismatchError,
|
|
1114
|
-
|
|
1114
|
+
C as LocalStoreDependencyError,
|
|
1115
1115
|
P as ProviderMissingError,
|
|
1116
1116
|
STORION_TYPE,
|
|
1117
|
-
|
|
1118
|
-
|
|
1117
|
+
z as SetupPhaseError,
|
|
1118
|
+
B as StoreDisposedError,
|
|
1119
1119
|
y as StorionError,
|
|
1120
1120
|
append,
|
|
1121
1121
|
applyExcept,
|
|
@@ -1127,25 +1127,25 @@ export {
|
|
|
1127
1127
|
x as deepEqual,
|
|
1128
1128
|
disposalGroup,
|
|
1129
1129
|
divide,
|
|
1130
|
-
|
|
1130
|
+
o as effect,
|
|
1131
1131
|
q as equality,
|
|
1132
1132
|
forStores,
|
|
1133
1133
|
getNamedGroup,
|
|
1134
1134
|
increment,
|
|
1135
|
-
|
|
1135
|
+
m as is,
|
|
1136
1136
|
list,
|
|
1137
1137
|
map,
|
|
1138
1138
|
merge,
|
|
1139
|
-
|
|
1139
|
+
m2 as meta,
|
|
1140
1140
|
multiply,
|
|
1141
1141
|
p as pick,
|
|
1142
|
-
|
|
1142
|
+
D as pool,
|
|
1143
1143
|
prepend,
|
|
1144
1144
|
reset,
|
|
1145
1145
|
createResolver as resolver,
|
|
1146
1146
|
shallowEqual,
|
|
1147
|
-
|
|
1148
|
-
|
|
1147
|
+
l as store,
|
|
1148
|
+
s as strictEqual,
|
|
1149
1149
|
toggle,
|
|
1150
1150
|
trigger,
|
|
1151
1151
|
untrack,
|