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.
- package/README.md +1006 -1128
- 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
|
@@ -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.5",
|
|
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": "git status --porcelain | grep -q . && echo 'Error: uncommitted changes' && exit 1; pnpm version:patch && git add -A && git commit --amend --no-edit &&
|
|
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 &&
|
|
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 &&
|
|
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": [
|