storion 0.7.1 → 0.7.5

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.
@@ -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,EAC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U,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"}
@@ -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/D,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"}
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"}
@@ -1,5 +1,5 @@
1
- import { e as effect } from "../effect-DPAYSuW3.js";
2
- import { u as untrack } from "../emitter-BA44OHdL.js";
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 Error(
539
- "async.derive: computeFn must be synchronous. Use async.wait() for async values, not async/await or returning promises."
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
- if (mode === "stale") {
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
- if (mode === "stale") {
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
- if (mode === "stale") {
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;AAgBH;;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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ACH,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"}
@@ -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;AAO7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,QAAQ,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAyGxE"}
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"}
@@ -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;AAyBlB;;;;;;;;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,CA0rBjC"}
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;;;;;;;;GAQ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IAC7B,KAAK,EAAE,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"}
@@ -1,5 +1,5 @@
1
- import { c as createStoreInstance, S as STORION_TYPE } from "../store-BroaE7p4.js";
2
- import { e as emitter } from "../emitter-BA44OHdL.js";
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-BA44OHdL.js";
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 CannotRefreshError();
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 Error(
229
- "Effect function must be synchronous. Use ctx.safe(promise) for async operations instead of returning a Promise."
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 Error && error instanceof CannotRefreshError) {
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
- hasWriteHook as a,
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
- trackWrite as c,
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,
@@ -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
@@ -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,EACnB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,QAAQ,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,MAAM,aAAa,CAAC;AAEnC,OAAO,EACL,MAAM,EACN,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,GACvB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,QAAQ,EACR,WAAW,EACX,OAAO,EACP,SAAS,EACT,KAAK,WAAW,GACjB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,SAAS,EACT,WAAW,GACZ,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,OAAO,EAAE,KAAK,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"}
@@ -1 +1 @@
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;AAS/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"}
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"}
@@ -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 { i as isSpec, S as STORION_TYPE, r as resolveEquality, s as store } from "../store-BroaE7p4.js";
8
- import { n, l, g, a, h, d, f, k, e, j, b, p, m, o, u, w } from "../store-BroaE7p4.js";
9
- import { w as withHooks } from "../emitter-BA44OHdL.js";
10
- import { b as b2, u as u2 } from "../emitter-BA44OHdL.js";
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-DPAYSuW3.js";
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 Error("useContainer must be used within a StoreProvider");
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 Error(
167
- `Local store must not have dependencies, but "${this.spec.displayName}" has ${depsCount} dependencies. Use useStore() with a global container for stores with dependencies.`
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 Error(
249
- "useStore selector must be synchronous. Do not return a Promise from the selector function."
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
- b2 as batch,
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
- a as is,
416
+ a2 as is,
405
417
  h as isAction,
406
- d as isContainer,
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
- b as isStorion,
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
- u2 as untrack,
420
- u as unwrapFn,
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;AAGlB;;;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
+ {"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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