storion 0.7.0 → 0.7.4
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 +21 -0
- package/dist/async/async.d.ts.map +1 -1
- package/dist/async/index.d.ts +1 -1
- package/dist/async/index.d.ts.map +1 -1
- package/dist/async/index.js +42 -25
- package/dist/core/effect.d.ts.map +1 -1
- package/dist/core/pick.d.ts.map +1 -1
- package/dist/core/store.d.ts.map +1 -1
- package/dist/core/storeContext.d.ts.map +1 -1
- package/dist/devtools/index.js +2 -2
- package/dist/{effect-DPAYSuW3.js → effect-ByI1oRBq.js} +6 -10
- package/dist/{emitter-BA44OHdL.js → emitter-XwTUpyGv.js} +82 -2
- package/dist/errors.d.ts +68 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/react/context.d.ts.map +1 -1
- package/dist/react/index.js +28 -16
- package/dist/react/useLocalStore.d.ts.map +1 -1
- package/dist/react/useStore.d.ts.map +1 -1
- package/dist/{store-BroaE7p4.js → store-CwgUVEWv.js} +15 -20
- package/dist/storion.js +16 -8
- package/package.json +4 -4
package/dist/async/async.d.ts
CHANGED
|
@@ -42,6 +42,27 @@ export declare function asyncState<T>(mode: "stale", status: "idle", data: T): A
|
|
|
42
42
|
export declare function asyncState<T>(mode: "stale", status: "pending", data: T, extra?: AsyncStateExtra<T>): AsyncState<T, "stale">;
|
|
43
43
|
export declare function asyncState<T>(mode: "stale", status: "success", data: T): AsyncState<T, "stale">;
|
|
44
44
|
export declare function asyncState<T>(mode: "stale", status: "error", data: T, error: Error, extra?: AsyncStateExtra<T>): AsyncState<T, "stale">;
|
|
45
|
+
export declare namespace asyncState {
|
|
46
|
+
var from: typeof asyncStateFrom;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Create a new AsyncState based on a previous state, preserving mode and stale data.
|
|
50
|
+
* Useful for deriving new states while maintaining the mode semantics.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* // From success to pending (preserves mode and stale data)
|
|
54
|
+
* const next = asyncState.from(prev, "pending");
|
|
55
|
+
*
|
|
56
|
+
* // From pending to success
|
|
57
|
+
* const next = asyncState.from(prev, "success", newData);
|
|
58
|
+
*
|
|
59
|
+
* // From any to error
|
|
60
|
+
* const next = asyncState.from(prev, "error", new Error("failed"));
|
|
61
|
+
*/
|
|
62
|
+
export declare function asyncStateFrom<T, M extends AsyncMode>(prev: AsyncState<T, M>, status: "idle"): AsyncState<T, M>;
|
|
63
|
+
export declare function asyncStateFrom<T, M extends AsyncMode>(prev: AsyncState<T, M>, status: "pending"): AsyncState<T, M>;
|
|
64
|
+
export declare function asyncStateFrom<T, M extends AsyncMode>(prev: AsyncState<T, M>, status: "success", data: T): AsyncState<T, M>;
|
|
65
|
+
export declare function asyncStateFrom<T, M extends AsyncMode>(prev: AsyncState<T, M>, status: "error", error: Error): AsyncState<T, M>;
|
|
45
66
|
export declare namespace async {
|
|
46
67
|
/**
|
|
47
68
|
* Create a fresh mode async state (data undefined during loading/error).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../../src/async/async.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EAET,YAAY,EACZ,YAAY,EACZ,YAAY,EAEZ,kBAAkB,EAElB,cAAc,EAEd,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACV,QAAQ,EACR,cAAc,EAEf,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../../src/async/async.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EAET,YAAY,EACZ,YAAY,EACZ,YAAY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IACH,SAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,SAAS,SAAS,EAC5C,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,GACtB,KAAK,IAAI,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,KAAK,CAAA;KAAE,CAE/D;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+CG;IACH,SAAgB,MAAM,CAAC,CAAC,EAAE,CAAC,SAAS,SAAS,GAAG,OAAO,EACrD,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAC9B,SAAS,EAAE,MAAM,CAAC,GACjB,YAAY,CAoDd;CACF"}
|
package/dist/async/index.d.ts
CHANGED
|
@@ -8,6 +8,6 @@
|
|
|
8
8
|
* - fresh: data is undefined during loading/error (only show fresh data)
|
|
9
9
|
* - stale: data is preserved during loading/error (stale-while-revalidate)
|
|
10
10
|
*/
|
|
11
|
-
export { async, asyncState, getPendingPromise } from './async';
|
|
11
|
+
export { async, asyncState, asyncStateFrom, getPendingPromise } from './async';
|
|
12
12
|
export { AsyncNotReadyError, AsyncAggregateError, type AsyncMode, type AsyncState, type AsyncIdleState, type AsyncIdleStateFresh, type AsyncIdleStateStale, type AsyncPendingState, type AsyncPendingStateFresh, type AsyncPendingStateStale, type AsyncSuccessState, type AsyncErrorState, type AsyncErrorStateFresh, type AsyncErrorStateStale, type AsyncStatus, type AsyncContext, type AsyncHandler, type AsyncOptions, type AsyncRetryOptions, type AsyncActions, type AsyncLastInvocation, type CancellablePromise, type InferAsyncData, type InferAsyncMode, type SettledResult, type MapAsyncData, type MapSettledResult, type RaceResult, type AsyncKey, type SerializedAsyncState, } from './types';
|
|
13
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/async/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC/
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/async/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC/E,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,oBAAoB,GAC1B,MAAM,SAAS,CAAC"}
|
package/dist/async/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { e as effect } from "../effect-
|
|
2
|
-
import { u as untrack } from "../emitter-
|
|
1
|
+
import { e as effect } from "../effect-ByI1oRBq.js";
|
|
2
|
+
import { u as untrack, A as AsyncFunctionError } from "../emitter-XwTUpyGv.js";
|
|
3
3
|
class AsyncNotReadyError extends Error {
|
|
4
4
|
constructor(message, status) {
|
|
5
5
|
super(message);
|
|
@@ -358,6 +358,39 @@ function asyncState(mode, status, dataOrError, errorOrExtra, extra) {
|
|
|
358
358
|
}
|
|
359
359
|
return Object.freeze(state);
|
|
360
360
|
}
|
|
361
|
+
function asyncStateFrom(prev, status, dataOrError) {
|
|
362
|
+
const mode = prev.mode;
|
|
363
|
+
const staleData = mode === "stale" ? prev.data : void 0;
|
|
364
|
+
if (mode === "stale") {
|
|
365
|
+
switch (status) {
|
|
366
|
+
case "idle":
|
|
367
|
+
return asyncState("stale", "idle", staleData);
|
|
368
|
+
case "pending":
|
|
369
|
+
return asyncState("stale", "pending", staleData);
|
|
370
|
+
case "success":
|
|
371
|
+
return asyncState("stale", "success", dataOrError);
|
|
372
|
+
case "error":
|
|
373
|
+
return asyncState(
|
|
374
|
+
"stale",
|
|
375
|
+
"error",
|
|
376
|
+
staleData,
|
|
377
|
+
dataOrError
|
|
378
|
+
);
|
|
379
|
+
}
|
|
380
|
+
} else {
|
|
381
|
+
switch (status) {
|
|
382
|
+
case "idle":
|
|
383
|
+
return asyncState("fresh", "idle");
|
|
384
|
+
case "pending":
|
|
385
|
+
return asyncState("fresh", "pending");
|
|
386
|
+
case "success":
|
|
387
|
+
return asyncState("fresh", "success", dataOrError);
|
|
388
|
+
case "error":
|
|
389
|
+
return asyncState("fresh", "error", dataOrError);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
asyncState.from = asyncStateFrom;
|
|
361
394
|
((async2) => {
|
|
362
395
|
function fresh() {
|
|
363
396
|
return asyncState("fresh", "idle");
|
|
@@ -530,44 +563,27 @@ function asyncState(mode, status, dataOrError, errorOrExtra, extra) {
|
|
|
530
563
|
let hasSetPending = false;
|
|
531
564
|
return effect((ctx) => {
|
|
532
565
|
const currentState = untrack(getState);
|
|
533
|
-
const mode = currentState.mode;
|
|
534
|
-
const staleData = mode === "stale" ? currentState.data : currentState.status === "success" ? currentState.data : void 0;
|
|
535
566
|
try {
|
|
536
567
|
const result = computeFn();
|
|
537
568
|
if (result !== null && result !== void 0 && typeof result.then === "function") {
|
|
538
|
-
throw new
|
|
539
|
-
"async.derive
|
|
569
|
+
throw new AsyncFunctionError(
|
|
570
|
+
"async.derive computeFn",
|
|
571
|
+
"Use async.wait() for async values, not async/await or returning promises."
|
|
540
572
|
);
|
|
541
573
|
}
|
|
542
574
|
hasSetPending = false;
|
|
543
|
-
|
|
544
|
-
setState(asyncState("stale", "success", result));
|
|
545
|
-
} else {
|
|
546
|
-
setState(asyncState("fresh", "success", result));
|
|
547
|
-
}
|
|
575
|
+
setState(asyncState.from(currentState, "success", result));
|
|
548
576
|
} catch (ex) {
|
|
549
577
|
if (ex !== null && ex !== void 0 && typeof ex.then === "function") {
|
|
550
578
|
if (!hasSetPending) {
|
|
551
579
|
hasSetPending = true;
|
|
552
|
-
|
|
553
|
-
setState(
|
|
554
|
-
asyncState("stale", "pending", staleData)
|
|
555
|
-
);
|
|
556
|
-
} else {
|
|
557
|
-
setState(asyncState("fresh", "pending"));
|
|
558
|
-
}
|
|
580
|
+
setState(asyncState.from(currentState, "pending"));
|
|
559
581
|
}
|
|
560
582
|
ctx.safe(ex).then(ctx.refresh, ctx.refresh);
|
|
561
583
|
} else {
|
|
562
584
|
hasSetPending = false;
|
|
563
585
|
const error = ex instanceof Error ? ex : new Error(String(ex));
|
|
564
|
-
|
|
565
|
-
setState(
|
|
566
|
-
asyncState("stale", "error", staleData, error)
|
|
567
|
-
);
|
|
568
|
-
} else {
|
|
569
|
-
setState(asyncState("fresh", "error", error));
|
|
570
|
-
}
|
|
586
|
+
setState(asyncState.from(currentState, "error", error));
|
|
571
587
|
}
|
|
572
588
|
}
|
|
573
589
|
});
|
|
@@ -579,5 +595,6 @@ export {
|
|
|
579
595
|
AsyncNotReadyError,
|
|
580
596
|
async,
|
|
581
597
|
asyncState,
|
|
598
|
+
asyncStateFrom,
|
|
582
599
|
getPendingPromise
|
|
583
600
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effect.d.ts","sourceRoot":"","sources":["../../src/core/effect.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"effect.d.ts","sourceRoot":"","sources":["../../src/core/effect.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAiBH;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,uCAAuC;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,mEAAmE;IACnE,KAAK,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC;CAChD;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,gCAAgC;IAChC,KAAK,EAAE,OAAO,CAAC;IACf,2CAA2C;IAC3C,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,4DAA4D;IAC5D,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAC3B,UAAU,GACV,WAAW,GACX,iBAAiB,GACjB,CAAC,CAAC,OAAO,EAAE,kBAAkB,KAAK,IAAI,CAAC,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,8BAA8B;IAC9B,OAAO,CAAC,EAAE,mBAAmB,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,oEAAoE;IACpE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACpC;AAMD;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB;;;;;;;;OAQG;IACH,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAE7B;;;;;;;;;;;;;OAaG;IACH,SAAS,CAAC,QAAQ,EAAE,YAAY,GAAG,YAAY,CAAC;IAEhD;;;;;;;;;;;OAWG;IACH,IAAI,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAEzC;;;;;;;;;;;;;OAaG;IACH,IAAI,CAAC,KAAK,SAAS,OAAO,EAAE,EAAE,OAAO,EACnC,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,GACpC,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,GAAG,SAAS,CAAC;IAE3C;;;;;;;;;;;;;;;;;;OAkBG;IACH,OAAO,IAAI,IAAI,CAAC;CACjB;AA4GD;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,GAAG,EAAE,aAAa,KAAK,IAAI,CAAC;AAsBpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,wBAAgB,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,YAAY,CAyS1E"}
|
package/dist/core/pick.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pick.d.ts","sourceRoot":"","sources":["../../src/core/pick.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"pick.d.ts","sourceRoot":"","sources":["../../src/core/pick.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAQ7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,QAAQ,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAsGxE"}
|
package/dist/core/store.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/core/store.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,QAAQ,EAKb,KAAK,kBAAkB,EACxB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/core/store.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,QAAQ,EAKb,KAAK,kBAAkB,EACxB,MAAM,UAAU,CAAC;AA0BlB;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CAAC,MAAM,SAAS,SAAS,EAAE,QAAQ,SAAS,WAAW,EAC1E,OAAO,EAAE,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,GACtC,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CAqB7B;AAYD,0CAA0C;AAC1C,MAAM,WAAW,0BAA0B;IACzC,WAAW,CAAC,EAAE,kBAAkB,CAAC;CAClC;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,SAAS,SAAS,EACxB,QAAQ,SAAS,WAAW,EAE5B,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,EACjC,QAAQ,EAAE,QAAQ,EAClB,eAAe,GAAE,0BAA+B,GAC/C,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,CAsrBjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storeContext.d.ts","sourceRoot":"","sources":["../../src/core/storeContext.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,QAAQ,EACb,KAAK,YAAY,EAGjB,KAAK,KAAK,EACV,K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,MAAM,IAAI,CAAC;IAClB,wDAAwD;IACxD,WAAW,EAAE,MAAM,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,IAAI,CAAC;IAC1D,2CAA2C;IAC3C,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IAC3D,4DAA4D;IAC5D,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;IAC3C,8BAA8B;IAC9B,YAAY,EAAE,MAAM,OAAO,CAAC;CAC7B;AAkBD;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,MAAM,SAAS,SAAS,EAAE,MAAM,EAC1D,QAAQ,EAAE,YAAY,CAAC,MAAM,CAAC,EAC9B,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,GAC7B,KAAK,CAAC,MAAM,CAAC,CAsHf;AA2CD;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,SAAS,SAAS,EACxB,QAAQ,SAAS,WAAW,EAC5B,OAAO,EAAE,yBAAyB,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,YAAY,CAAC,MAAM,CAAC,CAwJ5E"}
|
package/dist/devtools/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as createStoreInstance, S as STORION_TYPE } from "../store-
|
|
2
|
-
import { e as emitter } from "../emitter-
|
|
1
|
+
import { c as createStoreInstance, S as STORION_TYPE } from "../store-CwgUVEWv.js";
|
|
2
|
+
import { e as emitter } from "../emitter-XwTUpyGv.js";
|
|
3
3
|
let snapshotIdCounter = 0;
|
|
4
4
|
let eventIdCounter = 0;
|
|
5
5
|
const DEFAULT_MAX_EVENTS = 200;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as getHooks, w as withHooks, s as scheduleNotification, e as emitter } from "./emitter-
|
|
1
|
+
import { g as getHooks, E as EffectRefreshError, w as withHooks, A as AsyncFunctionError, s as scheduleNotification, e as emitter } from "./emitter-XwTUpyGv.js";
|
|
2
2
|
function isPromiseLike(value) {
|
|
3
3
|
return typeof value === "object" && value !== null && "then" in value && typeof value.then === "function";
|
|
4
4
|
}
|
|
@@ -72,11 +72,6 @@ function createEffectContext(nth, onRefresh) {
|
|
|
72
72
|
};
|
|
73
73
|
return Object.assign(context, { _runCleanups: runCleanups });
|
|
74
74
|
}
|
|
75
|
-
class CannotRefreshError extends Error {
|
|
76
|
-
constructor() {
|
|
77
|
-
super("Effect is already running, cannot refresh");
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
75
|
function resolveErrorStrategy(effectOptions) {
|
|
81
76
|
return (effectOptions == null ? void 0 : effectOptions.onError) ?? "keepAlive";
|
|
82
77
|
}
|
|
@@ -217,7 +212,7 @@ function effect(fn, options) {
|
|
|
217
212
|
if (fn.length) {
|
|
218
213
|
lazyContext = createEffectContext(currentGeneration, () => {
|
|
219
214
|
if (isRunning) {
|
|
220
|
-
throw new
|
|
215
|
+
throw new EffectRefreshError();
|
|
221
216
|
}
|
|
222
217
|
execute();
|
|
223
218
|
});
|
|
@@ -225,8 +220,9 @@ function effect(fn, options) {
|
|
|
225
220
|
withHooks(getTrackingHooks, () => {
|
|
226
221
|
const result = fn(lazyContext);
|
|
227
222
|
if (result !== null && result !== void 0 && typeof result.then === "function") {
|
|
228
|
-
throw new
|
|
229
|
-
"Effect function
|
|
223
|
+
throw new AsyncFunctionError(
|
|
224
|
+
"Effect function",
|
|
225
|
+
"Use ctx.safe(promise) for async operations instead of returning a Promise."
|
|
230
226
|
);
|
|
231
227
|
}
|
|
232
228
|
if (lazyContext && lazyContext.refresh === result) {
|
|
@@ -250,7 +246,7 @@ function effect(fn, options) {
|
|
|
250
246
|
prevTrackedDeps.clear();
|
|
251
247
|
prevSubscriptionEmitter = null;
|
|
252
248
|
} catch (error) {
|
|
253
|
-
if (error instanceof
|
|
249
|
+
if (error instanceof EffectRefreshError) {
|
|
254
250
|
throw error;
|
|
255
251
|
}
|
|
256
252
|
handleError(error);
|
|
@@ -1,3 +1,73 @@
|
|
|
1
|
+
class StorionError extends Error {
|
|
2
|
+
constructor(message) {
|
|
3
|
+
super(message);
|
|
4
|
+
this.name = "StorionError";
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
class SetupPhaseError extends StorionError {
|
|
8
|
+
constructor(method, hint) {
|
|
9
|
+
super(
|
|
10
|
+
`${method}() can only be called during setup phase. Do not call ${method}() inside actions or async callbacks.` + (hint ? ` ${hint}` : "")
|
|
11
|
+
);
|
|
12
|
+
this.name = "SetupPhaseError";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
class LifetimeMismatchError extends StorionError {
|
|
16
|
+
constructor(parentName, childName, operation) {
|
|
17
|
+
super(
|
|
18
|
+
`Lifetime mismatch: Store "${parentName}" (keepAlive) cannot ${operation} store "${childName}" (autoDispose). A long-lived store cannot ${operation} a store that may be disposed. Either change "${parentName}" to autoDispose, or change "${childName}" to keepAlive.`
|
|
19
|
+
);
|
|
20
|
+
this.name = "LifetimeMismatchError";
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
class AsyncFunctionError extends StorionError {
|
|
24
|
+
constructor(context, hint) {
|
|
25
|
+
super(`${context} must be synchronous. ${hint}`);
|
|
26
|
+
this.name = "AsyncFunctionError";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
class StoreDisposedError extends StorionError {
|
|
30
|
+
constructor(storeId) {
|
|
31
|
+
super(`Cannot call action on disposed store: ${storeId}`);
|
|
32
|
+
this.name = "StoreDisposedError";
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
class InvalidActionError extends StorionError {
|
|
36
|
+
constructor(actionName, actualType) {
|
|
37
|
+
super(
|
|
38
|
+
`Action "${actionName}" must be a function, got ${actualType}. If using focus(), destructure it and return the getter/setter separately: const [get, set] = focus("path"); return { get, set };`
|
|
39
|
+
);
|
|
40
|
+
this.name = "InvalidActionError";
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
class HooksContextError extends StorionError {
|
|
44
|
+
constructor(method, requiredContext) {
|
|
45
|
+
super(
|
|
46
|
+
`${method}() must be called inside ${requiredContext}. It requires an active tracking context.`
|
|
47
|
+
);
|
|
48
|
+
this.name = "HooksContextError";
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
class ProviderMissingError extends StorionError {
|
|
52
|
+
constructor(hook, provider) {
|
|
53
|
+
super(`${hook} must be used within a ${provider}`);
|
|
54
|
+
this.name = "ProviderMissingError";
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
class LocalStoreDependencyError extends StorionError {
|
|
58
|
+
constructor(storeName, dependencyCount) {
|
|
59
|
+
super(
|
|
60
|
+
`Local store must not have dependencies, but "${storeName}" has ${dependencyCount} dependencies. Use useStore() with a global container for stores with dependencies.`
|
|
61
|
+
);
|
|
62
|
+
this.name = "LocalStoreDependencyError";
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
class EffectRefreshError extends StorionError {
|
|
66
|
+
constructor() {
|
|
67
|
+
super("Effect is already running, cannot refresh");
|
|
68
|
+
this.name = "EffectRefreshError";
|
|
69
|
+
}
|
|
70
|
+
}
|
|
1
71
|
let globalHooks = {
|
|
2
72
|
scheduleNotification(notify) {
|
|
3
73
|
notify();
|
|
@@ -215,12 +285,22 @@ function emitter(initialListeners) {
|
|
|
215
285
|
};
|
|
216
286
|
}
|
|
217
287
|
export {
|
|
218
|
-
|
|
288
|
+
AsyncFunctionError as A,
|
|
289
|
+
EffectRefreshError as E,
|
|
290
|
+
HooksContextError as H,
|
|
291
|
+
InvalidActionError as I,
|
|
292
|
+
LocalStoreDependencyError as L,
|
|
293
|
+
ProviderMissingError as P,
|
|
294
|
+
StorionError as S,
|
|
295
|
+
SetupPhaseError as a,
|
|
219
296
|
batch as b,
|
|
220
|
-
|
|
297
|
+
LifetimeMismatchError as c,
|
|
298
|
+
StoreDisposedError as d,
|
|
221
299
|
emitter as e,
|
|
300
|
+
hasWriteHook as f,
|
|
222
301
|
getHooks as g,
|
|
223
302
|
hasReadHook as h,
|
|
303
|
+
trackWrite as i,
|
|
224
304
|
scheduleNotification as s,
|
|
225
305
|
trackRead as t,
|
|
226
306
|
untrack as u,
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom error classes for Storion.
|
|
3
|
+
* Using named error classes helps with error identification and handling.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Base class for all Storion errors.
|
|
7
|
+
*/
|
|
8
|
+
export declare class StorionError extends Error {
|
|
9
|
+
constructor(message: string);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Thrown when a method that should only be called during setup phase
|
|
13
|
+
* is called outside of it (e.g., inside actions or async callbacks).
|
|
14
|
+
*/
|
|
15
|
+
export declare class SetupPhaseError extends StorionError {
|
|
16
|
+
constructor(method: string, hint?: string);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Thrown when a store with keepAlive lifetime tries to depend on
|
|
20
|
+
* or create a store with autoDispose lifetime.
|
|
21
|
+
*/
|
|
22
|
+
export declare class LifetimeMismatchError extends StorionError {
|
|
23
|
+
constructor(parentName: string, childName: string, operation: "depend on" | "create");
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Thrown when an async function (returning Promise) is used where
|
|
27
|
+
* a synchronous function is required.
|
|
28
|
+
*/
|
|
29
|
+
export declare class AsyncFunctionError extends StorionError {
|
|
30
|
+
constructor(context: string, hint: string);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Thrown when attempting to call an action on a disposed store.
|
|
34
|
+
*/
|
|
35
|
+
export declare class StoreDisposedError extends StorionError {
|
|
36
|
+
constructor(storeId: string);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Thrown when an action definition is not a function.
|
|
40
|
+
*/
|
|
41
|
+
export declare class InvalidActionError extends StorionError {
|
|
42
|
+
constructor(actionName: string, actualType: string);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Thrown when pick() is called outside of an effect or useStore selector.
|
|
46
|
+
*/
|
|
47
|
+
export declare class HooksContextError extends StorionError {
|
|
48
|
+
constructor(method: string, requiredContext: string);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Thrown when useContainer is called outside of StoreProvider.
|
|
52
|
+
*/
|
|
53
|
+
export declare class ProviderMissingError extends StorionError {
|
|
54
|
+
constructor(hook: string, provider: string);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Thrown when a local store (useLocalStore) has dependencies.
|
|
58
|
+
*/
|
|
59
|
+
export declare class LocalStoreDependencyError extends StorionError {
|
|
60
|
+
constructor(storeName: string, dependencyCount: number);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Thrown when refresh() is called while the effect is still running.
|
|
64
|
+
*/
|
|
65
|
+
export declare class EffectRefreshError extends StorionError {
|
|
66
|
+
constructor();
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,qBAAa,YAAa,SAAQ,KAAK;gBACzB,OAAO,EAAE,MAAM;CAI5B;AAMD;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,YAAY;gBAE7C,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,MAAM;CAShB;AAMD;;;GAGG;AACH,qBAAa,qBAAsB,SAAQ,YAAY;gBAEnD,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,WAAW,GAAG,QAAQ;CAUpC;AAMD;;;GAGG;AACH,qBAAa,kBAAmB,SAAQ,YAAY;gBACtC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;CAI1C;AAMD;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,YAAY;gBACtC,OAAO,EAAE,MAAM;CAI5B;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,YAAY;gBACtC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;CAQnD;AAMD;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,YAAY;gBACrC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM;CAOpD;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,YAAY;gBACxC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAI3C;AAMD;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,YAAY;gBAC7C,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM;CAOvD;AAMD;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,YAAY;;CAKnD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -15,4 +15,5 @@ export { applyFor, applyExcept, compose, forStores, type SpecPattern, } from './
|
|
|
15
15
|
export { equality, shallowEqual, deepEqual, strictEqual, } from './core/equality';
|
|
16
16
|
export { trigger, type TriggerOptions } from './trigger';
|
|
17
17
|
export { wrapFn as wrapFn, unwrapFn, isWrappedFn } from './core/fnWrapper';
|
|
18
|
+
export { StorionError, SetupPhaseError, LifetimeMismatchError, AsyncFunctionError, StoreDisposedError, InvalidActionError, HooksContextError, ProviderMissingError, LocalStoreDependencyError, EffectRefreshError, } from './errors';
|
|
18
19
|
//# sourceMappingURL=index.d.ts.map
|
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,WAA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CAAC;AAEf,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/react/context.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,EAAE,EAGR,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAU/C;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CAShD,CAAC;AAEF;;GAEG;AACH,wBAAgB,YAAY,IAAI,cAAc,CAO7C"}
|
package/dist/react/index.js
CHANGED
|
@@ -4,12 +4,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4
4
|
import { memo, useMemo, createElement, createContext, useContext, useReducer, useRef, useEffect, useLayoutEffect, useState, forwardRef } from "react";
|
|
5
5
|
import { container } from "../storion.js";
|
|
6
6
|
import { applyExcept, applyFor, compose, createLoggingMiddleware, createResolver, createValidationMiddleware, forStores, pick, trigger, when } from "../storion.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { b as b2, u as u2 } from "../
|
|
7
|
+
import { P as ProviderMissingError, L as LocalStoreDependencyError, w as withHooks, A as AsyncFunctionError } from "../emitter-XwTUpyGv.js";
|
|
8
|
+
import { E, H, I, c, a, d, S, b, u } from "../emitter-XwTUpyGv.js";
|
|
9
|
+
import { i as isSpec, S as STORION_TYPE, r as resolveEquality, s as store } from "../store-CwgUVEWv.js";
|
|
10
|
+
import { n, l, g, a as a2, h, d as d2, f, k, e, j, b as b2, p, m, o, u as u2, w } from "../store-CwgUVEWv.js";
|
|
11
11
|
import { jsx } from "react/jsx-runtime";
|
|
12
|
-
import { e as e2 } from "../effect-
|
|
12
|
+
import { e as e2 } from "../effect-ByI1oRBq.js";
|
|
13
13
|
const StoreContext = createContext(null);
|
|
14
14
|
const StoreProvider = memo(
|
|
15
15
|
({ container: value, children }) => {
|
|
@@ -24,7 +24,7 @@ const StoreProvider = memo(
|
|
|
24
24
|
function useContainer() {
|
|
25
25
|
const ctx = useContext(StoreContext);
|
|
26
26
|
if (!ctx) {
|
|
27
|
-
throw new
|
|
27
|
+
throw new ProviderMissingError("useContainer", "StoreProvider");
|
|
28
28
|
}
|
|
29
29
|
return ctx;
|
|
30
30
|
}
|
|
@@ -163,8 +163,9 @@ class LocalStoreController {
|
|
|
163
163
|
const depsCount = ((_b = (_a = this._store) == null ? void 0 : _a.deps) == null ? void 0 : _b.length) ?? 0;
|
|
164
164
|
if (depsCount > 0) {
|
|
165
165
|
this.dispose();
|
|
166
|
-
throw new
|
|
167
|
-
|
|
166
|
+
throw new LocalStoreDependencyError(
|
|
167
|
+
this.spec.displayName,
|
|
168
|
+
depsCount
|
|
168
169
|
);
|
|
169
170
|
}
|
|
170
171
|
if (shouldScheduleDispose) {
|
|
@@ -245,8 +246,9 @@ function useStoreWithContainer(selector, container2) {
|
|
|
245
246
|
refs.onceRan = true;
|
|
246
247
|
}
|
|
247
248
|
if (result && typeof result.then === "function") {
|
|
248
|
-
throw new
|
|
249
|
-
"useStore selector
|
|
249
|
+
throw new AsyncFunctionError(
|
|
250
|
+
"useStore selector",
|
|
251
|
+
"Do not return a Promise from the selector function."
|
|
250
252
|
);
|
|
251
253
|
}
|
|
252
254
|
refs.fresh = result;
|
|
@@ -385,11 +387,21 @@ function create(options) {
|
|
|
385
387
|
return [instance, useCreatedStore];
|
|
386
388
|
}
|
|
387
389
|
export {
|
|
390
|
+
AsyncFunctionError,
|
|
391
|
+
E as EffectRefreshError,
|
|
392
|
+
H as HooksContextError,
|
|
393
|
+
I as InvalidActionError,
|
|
394
|
+
c as LifetimeMismatchError,
|
|
395
|
+
LocalStoreDependencyError,
|
|
396
|
+
ProviderMissingError,
|
|
388
397
|
STORION_TYPE,
|
|
398
|
+
a as SetupPhaseError,
|
|
399
|
+
d as StoreDisposedError,
|
|
389
400
|
StoreProvider,
|
|
401
|
+
S as StorionError,
|
|
390
402
|
applyExcept,
|
|
391
403
|
applyFor,
|
|
392
|
-
|
|
404
|
+
b as batch,
|
|
393
405
|
compose,
|
|
394
406
|
container,
|
|
395
407
|
create,
|
|
@@ -401,23 +413,23 @@ export {
|
|
|
401
413
|
l as equality,
|
|
402
414
|
forStores,
|
|
403
415
|
g as getKind,
|
|
404
|
-
|
|
416
|
+
a2 as is,
|
|
405
417
|
h as isAction,
|
|
406
|
-
|
|
418
|
+
d2 as isContainer,
|
|
407
419
|
f as isFocus,
|
|
408
420
|
k as isSelectorContext,
|
|
409
421
|
isSpec,
|
|
410
422
|
e as isStore,
|
|
411
423
|
j as isStoreContext,
|
|
412
|
-
|
|
424
|
+
b2 as isStorion,
|
|
413
425
|
p as isWrappedFn,
|
|
414
426
|
pick,
|
|
415
427
|
m as shallowEqual,
|
|
416
428
|
store,
|
|
417
429
|
o as strictEqual,
|
|
418
430
|
trigger,
|
|
419
|
-
|
|
420
|
-
|
|
431
|
+
u as untrack,
|
|
432
|
+
u2 as unwrapFn,
|
|
421
433
|
useContainer,
|
|
422
434
|
useStore,
|
|
423
435
|
when,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocalStore.d.ts","sourceRoot":"","sources":["../../src/react/useLocalStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EACL,WAAW,EACX,SAAS,EAET,aAAa,EACb,SAAS,EACV,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"useLocalStore.d.ts","sourceRoot":"","sources":["../../src/react/useLocalStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EACL,WAAW,EACX,SAAS,EAET,aAAa,EACb,SAAS,EACV,MAAM,UAAU,CAAC;AAIlB;;;GAGG;AACH,MAAM,MAAM,gBAAgB,CAC1B,MAAM,SAAS,SAAS,EACxB,QAAQ,SAAS,WAAW,IAC1B,SAAS;IACX,QAAQ,CAAC,MAAM,CAAC;IAChB,QAAQ;IACR,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;CACzD,CAAC;AASF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,aAAa,CAC3B,MAAM,SAAS,SAAS,EACxB,QAAQ,SAAS,WAAW,EAC5B,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,gBAAgB,CAAC,MAAM,EAAE,QAAQ,CAAC,CA8CvE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStore.d.ts","sourceRoot":"","sources":["../../src/react/useStore.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,cAAc,EAEnB,KAAK,QAAQ,EACb,KAAK,YAAY,EAClB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"useStore.d.ts","sourceRoot":"","sources":["../../src/react/useStore.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,cAAc,EAEnB,KAAK,QAAQ,EACb,KAAK,YAAY,EAClB,MAAM,UAAU,CAAC;AAIlB,OAAO,EAAiB,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAuBvE;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,MAAM,EACpD,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EACrB,SAAS,EAAE,cAAc,GACxB,YAAY,CAAC,CAAC,CAAC,CAmJjB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,EACvC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GACpB,YAAY,CAAC,CAAC,CAAC,CAAC;AACnB,wBAAgB,QAAQ,CACtB,MAAM,SAAS,SAAS,EACxB,QAAQ,SAAS,WAAW,EAC5B,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,gBAAgB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { e as emitter, w as withHooks, h as hasReadHook, t as trackRead,
|
|
1
|
+
import { a as SetupPhaseError, c as LifetimeMismatchError, e as emitter, w as withHooks, I as InvalidActionError, h as hasReadHook, t as trackRead, f as hasWriteHook, i as trackWrite, d as StoreDisposedError, s as scheduleNotification, b as batch } from "./emitter-XwTUpyGv.js";
|
|
2
2
|
const STORION_TYPE = Symbol("STORION");
|
|
3
3
|
function is$1(value, kind) {
|
|
4
4
|
return value !== null && (typeof value === "object" || typeof value === "function") && STORION_TYPE in value && value[STORION_TYPE] === kind;
|
|
@@ -1863,8 +1863,9 @@ function createStoreContext(options) {
|
|
|
1863
1863
|
// Implementation handles both StoreSpec and Factory overloads
|
|
1864
1864
|
get(specOrFactory) {
|
|
1865
1865
|
if (!isSetupPhase()) {
|
|
1866
|
-
throw new
|
|
1867
|
-
|
|
1866
|
+
throw new SetupPhaseError(
|
|
1867
|
+
"get",
|
|
1868
|
+
"Declare all dependencies at the top of your setup function."
|
|
1868
1869
|
);
|
|
1869
1870
|
}
|
|
1870
1871
|
if (!isSpec(specOrFactory)) {
|
|
@@ -1875,9 +1876,7 @@ function createStoreContext(options) {
|
|
|
1875
1876
|
if (currentLifetime === "keepAlive" && depLifetime === "autoDispose") {
|
|
1876
1877
|
const currentName = spec.options.name ?? "unknown";
|
|
1877
1878
|
const depName = depSpec.name ?? "unknown";
|
|
1878
|
-
throw new
|
|
1879
|
-
`Lifetime mismatch: Store "${currentName}" (keepAlive) cannot depend on store "${depName}" (autoDispose). A long-lived store cannot depend on a store that may be disposed. Either change "${currentName}" to autoDispose, or change "${depName}" to keepAlive.`
|
|
1880
|
-
);
|
|
1879
|
+
throw new LifetimeMismatchError(currentName, depName, "depend on");
|
|
1881
1880
|
}
|
|
1882
1881
|
const instance = resolver.get(depSpec);
|
|
1883
1882
|
onDependency == null ? void 0 : onDependency(instance);
|
|
@@ -1890,8 +1889,9 @@ function createStoreContext(options) {
|
|
|
1890
1889
|
// Implementation handles StoreSpec, Factory, and parameterized Factory overloads
|
|
1891
1890
|
create(specOrFactory, ...args) {
|
|
1892
1891
|
if (!isSetupPhase()) {
|
|
1893
|
-
throw new
|
|
1894
|
-
|
|
1892
|
+
throw new SetupPhaseError(
|
|
1893
|
+
"create",
|
|
1894
|
+
"Declare all child stores at the top of your setup function."
|
|
1895
1895
|
);
|
|
1896
1896
|
}
|
|
1897
1897
|
if (!isSpec(specOrFactory)) {
|
|
@@ -1904,9 +1904,7 @@ function createStoreContext(options) {
|
|
|
1904
1904
|
if (currentLifetime === "keepAlive" && childLifetime === "autoDispose") {
|
|
1905
1905
|
const currentName = spec.options.name ?? "unknown";
|
|
1906
1906
|
const childName = childSpec.name ?? "unknown";
|
|
1907
|
-
throw new
|
|
1908
|
-
`Lifetime mismatch: Store "${currentName}" (keepAlive) cannot create child store "${childName}" (autoDispose). A long-lived store cannot create a store that may be disposed before it. Either change "${currentName}" to autoDispose, or change "${childName}" to keepAlive.`
|
|
1909
|
-
);
|
|
1907
|
+
throw new LifetimeMismatchError(currentName, childName, "create");
|
|
1910
1908
|
}
|
|
1911
1909
|
const instance = resolver.create(childSpec);
|
|
1912
1910
|
onDispose == null ? void 0 : onDispose(willDispose(instance));
|
|
@@ -1924,16 +1922,15 @@ function createStoreContext(options) {
|
|
|
1924
1922
|
},
|
|
1925
1923
|
mixin(mixin, ...args) {
|
|
1926
1924
|
if (!isSetupPhase()) {
|
|
1927
|
-
throw new
|
|
1928
|
-
`mixin() can only be called during setup phase. Do not call mixin() inside actions or async callbacks.`
|
|
1929
|
-
);
|
|
1925
|
+
throw new SetupPhaseError("mixin");
|
|
1930
1926
|
}
|
|
1931
1927
|
return mixin(ctx, ...args);
|
|
1932
1928
|
},
|
|
1933
1929
|
focus(path, options2) {
|
|
1934
1930
|
if (!isSetupPhase()) {
|
|
1935
|
-
throw new
|
|
1936
|
-
|
|
1931
|
+
throw new SetupPhaseError(
|
|
1932
|
+
"focus",
|
|
1933
|
+
"Use the .to() method on an existing focus for dynamic sub-paths."
|
|
1937
1934
|
);
|
|
1938
1935
|
}
|
|
1939
1936
|
const focusCtx = {
|
|
@@ -2383,14 +2380,12 @@ function createStoreInstance(spec, resolver, instanceOptions = {}) {
|
|
|
2383
2380
|
const wrappedActions = {};
|
|
2384
2381
|
for (const [name, action] of Object.entries(actions)) {
|
|
2385
2382
|
if (typeof action !== "function") {
|
|
2386
|
-
throw new
|
|
2387
|
-
`Action "${name}" must be a function, got ${typeof action}. If using focus(), destructure it and return the getter/setter separately: const [get, set] = focus("path"); return { get, set };`
|
|
2388
|
-
);
|
|
2383
|
+
throw new InvalidActionError(name, typeof action);
|
|
2389
2384
|
}
|
|
2390
2385
|
const wrappedAction = wrapFn(action, (originalAction) => {
|
|
2391
2386
|
const wrapper = (...args) => {
|
|
2392
2387
|
if (disposed) {
|
|
2393
|
-
throw new
|
|
2388
|
+
throw new StoreDisposedError(storeId);
|
|
2394
2389
|
}
|
|
2395
2390
|
const actionNameKey = name;
|
|
2396
2391
|
const nthKey = name;
|
package/dist/storion.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as tryDispose, i as isSpec, S as STORION_TYPE, r as resolveEquality, u as unwrapFn, m as shallowEqual } from "./store-
|
|
2
|
-
import { n, l, g, a, h, d, f, k, e, j, b, p, s, o, w } from "./store-
|
|
3
|
-
import { e as emitter, u as untrack, g as getHooks, w as withHooks } from "./emitter-
|
|
4
|
-
import { b as b2 } from "./emitter-
|
|
5
|
-
import { e as e2 } from "./effect-
|
|
1
|
+
import { t as tryDispose, i as isSpec, S as STORION_TYPE, r as resolveEquality, u as unwrapFn, m as shallowEqual } from "./store-CwgUVEWv.js";
|
|
2
|
+
import { n, l, g, a, h, d, f, k, e, j, b, p, s, o, w } from "./store-CwgUVEWv.js";
|
|
3
|
+
import { e as emitter, u as untrack, g as getHooks, H as HooksContextError, w as withHooks } from "./emitter-XwTUpyGv.js";
|
|
4
|
+
import { A, E, I, c, L, P, a as a2, d as d2, S, b as b2 } from "./emitter-XwTUpyGv.js";
|
|
5
|
+
import { e as e2 } from "./effect-ByI1oRBq.js";
|
|
6
6
|
function extractDisplayName(factory) {
|
|
7
7
|
if (isSpec(factory)) {
|
|
8
8
|
return factory.displayName;
|
|
@@ -268,9 +268,7 @@ function pick(selector, equality) {
|
|
|
268
268
|
var _a;
|
|
269
269
|
const parentHooks = getHooks();
|
|
270
270
|
if (!parentHooks.onRead) {
|
|
271
|
-
throw new
|
|
272
|
-
"pick() must be called inside an effect or useStore selector. It requires an active hooks.onRead context."
|
|
273
|
-
);
|
|
271
|
+
throw new HooksContextError("pick", "an effect or useStore selector");
|
|
274
272
|
}
|
|
275
273
|
const equalityFn = resolveEquality(equality);
|
|
276
274
|
const currentReads = [];
|
|
@@ -450,7 +448,17 @@ trigger.clearAll = () => {
|
|
|
450
448
|
cache.clear();
|
|
451
449
|
};
|
|
452
450
|
export {
|
|
451
|
+
A as AsyncFunctionError,
|
|
452
|
+
E as EffectRefreshError,
|
|
453
|
+
HooksContextError,
|
|
454
|
+
I as InvalidActionError,
|
|
455
|
+
c as LifetimeMismatchError,
|
|
456
|
+
L as LocalStoreDependencyError,
|
|
457
|
+
P as ProviderMissingError,
|
|
453
458
|
STORION_TYPE,
|
|
459
|
+
a2 as SetupPhaseError,
|
|
460
|
+
d2 as StoreDisposedError,
|
|
461
|
+
S as StorionError,
|
|
454
462
|
applyExcept,
|
|
455
463
|
applyFor,
|
|
456
464
|
b2 as batch,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "storion",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4",
|
|
4
4
|
"description": "Reactive stores for modern apps. Type-safe. Auto-tracked. Effortlessly composable",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/storion.js",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"version:minor": "npm version minor -m \"chore: bump version to %s\"",
|
|
47
47
|
"version:major": "npm version major -m \"chore: bump version to %s\"",
|
|
48
48
|
"prepublishOnly": "pnpm run build",
|
|
49
|
-
"release:patch": "pnpm version:patch && git add -A && git commit --amend --no-edit &&
|
|
50
|
-
"release:minor": "pnpm version:minor && git add -A && git commit --amend --no-edit &&
|
|
51
|
-
"release:major": "pnpm version:major && git add -A && git commit --amend --no-edit &&
|
|
49
|
+
"release:patch": "git status --porcelain | grep -q . && echo 'Error: uncommitted changes' && exit 1; pnpm version:patch && git add -A && git commit --amend --no-edit && npm publish",
|
|
50
|
+
"release:minor": "git status --porcelain | grep -q . && echo 'Error: uncommitted changes' && exit 1; pnpm version:minor && git add -A && git commit --amend --no-edit && npm publish",
|
|
51
|
+
"release:major": "git status --porcelain | grep -q . && echo 'Error: uncommitted changes' && exit 1; pnpm version:major && git add -A && git commit --amend --no-edit && npm publish",
|
|
52
52
|
"publish:dry": "npm publish --dry-run"
|
|
53
53
|
},
|
|
54
54
|
"keywords": [
|