storion 0.7.10 → 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.
Files changed (39) hide show
  1. package/CHANGELOG.md +220 -0
  2. package/README.md +1 -0
  3. package/dist/async/index.js +1 -2
  4. package/dist/core/container.d.ts.map +1 -1
  5. package/dist/core/createResolver.d.ts +1 -41
  6. package/dist/core/createResolver.d.ts.map +1 -1
  7. package/dist/core/middleware.d.ts +3 -8
  8. package/dist/core/middleware.d.ts.map +1 -1
  9. package/dist/core/store.d.ts +1 -1
  10. package/dist/core/store.d.ts.map +1 -1
  11. package/dist/devtools/index.js +12 -32
  12. package/dist/devtools/middleware.d.ts.map +1 -1
  13. package/dist/{effect-ByI1oRBq.js → effect-C6h0PDDI.js} +160 -4
  14. package/dist/{emitter-XwTUpyGv.js → emitter-j4rC71vY.js} +1 -159
  15. package/dist/{store-C3dmtJ4u.js → index-OPaTR3zq.js} +549 -17
  16. package/dist/index.d.ts +5 -3
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/isPromiseLike-bFkfHAbm.js +6 -0
  19. package/dist/meta/createMetaQuery.d.ts +10 -0
  20. package/dist/meta/createMetaQuery.d.ts.map +1 -0
  21. package/dist/meta/index.d.ts +4 -0
  22. package/dist/meta/index.d.ts.map +1 -0
  23. package/dist/meta/meta.d.ts +83 -0
  24. package/dist/meta/meta.d.ts.map +1 -0
  25. package/dist/meta/withMeta.d.ts +48 -0
  26. package/dist/meta/withMeta.d.ts.map +1 -0
  27. package/dist/meta-40r-AZfe.js +32 -0
  28. package/dist/persist/index.d.ts +1 -1
  29. package/dist/persist/index.d.ts.map +1 -1
  30. package/dist/persist/index.js +27 -12
  31. package/dist/persist/persist.d.ts +47 -2
  32. package/dist/persist/persist.d.ts.map +1 -1
  33. package/dist/react/context.d.ts.map +1 -1
  34. package/dist/react/index.js +46 -43
  35. package/dist/storion.js +36 -486
  36. package/dist/types.d.ts +149 -34
  37. package/dist/types.d.ts.map +1 -1
  38. package/package.json +3 -2
  39. package/dist/is-KT6PknjJ.js +0 -44
@@ -1,142 +1,3 @@
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
- }
71
- let globalHooks = {
72
- scheduleNotification(notify) {
73
- notify();
74
- },
75
- scheduleEffect(runEffect) {
76
- runEffect();
77
- }
78
- };
79
- function getHooks() {
80
- return globalHooks;
81
- }
82
- function hasReadHook() {
83
- return globalHooks.onRead !== void 0;
84
- }
85
- function hasWriteHook() {
86
- return globalHooks.onWrite !== void 0;
87
- }
88
- function withHooks(hooksOrSetup, fn, onFinish) {
89
- const prev = globalHooks;
90
- if (typeof hooksOrSetup === "function") {
91
- globalHooks = {
92
- ...globalHooks,
93
- ...hooksOrSetup(prev)
94
- };
95
- } else {
96
- globalHooks = { ...prev, ...hooksOrSetup };
97
- }
98
- try {
99
- return fn();
100
- } finally {
101
- globalHooks = prev;
102
- onFinish == null ? void 0 : onFinish();
103
- }
104
- }
105
- function trackRead(storeId, prop, value, subscribe) {
106
- var _a;
107
- const key = `${storeId}.${prop}`;
108
- (_a = globalHooks.onRead) == null ? void 0 : _a.call(globalHooks, { key, value, subscribe });
109
- }
110
- function trackWrite(storeId, prop, next, prev) {
111
- var _a;
112
- const key = `${storeId}.${prop}`;
113
- (_a = globalHooks.onWrite) == null ? void 0 : _a.call(globalHooks, { key, next, prev });
114
- }
115
- function untrack(fn) {
116
- return withHooks({ onRead: void 0, onWrite: void 0 }, fn);
117
- }
118
- function scheduleNotification(notify, key) {
119
- globalHooks.scheduleNotification(notify, key);
120
- }
121
- function batch(fn) {
122
- const pending = /* @__PURE__ */ new Map();
123
- return withHooks(
124
- (current) => ({
125
- ...current,
126
- scheduleNotification: (notify, key) => {
127
- const actualKey = key ?? notify;
128
- pending.set(actualKey, notify);
129
- }
130
- }),
131
- fn,
132
- // Flush on finish
133
- () => {
134
- for (const notify of pending.values()) {
135
- notify();
136
- }
137
- }
138
- );
139
- }
140
1
  function emitter(initialListeners) {
141
2
  const listeners = /* @__PURE__ */ new Set([]);
142
3
  let settledPayload;
@@ -285,24 +146,5 @@ function emitter(initialListeners) {
285
146
  };
286
147
  }
287
148
  export {
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,
296
- batch as b,
297
- LifetimeMismatchError as c,
298
- StoreDisposedError as d,
299
- emitter as e,
300
- hasWriteHook as f,
301
- getHooks as g,
302
- hasReadHook as h,
303
- trackWrite as i,
304
- scheduleNotification as s,
305
- trackRead as t,
306
- untrack as u,
307
- withHooks as w
149
+ emitter as e
308
150
  };