storion 0.7.10 → 0.8.0

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 (36) hide show
  1. package/dist/async/index.js +1 -2
  2. package/dist/core/container.d.ts.map +1 -1
  3. package/dist/core/createResolver.d.ts.map +1 -1
  4. package/dist/core/middleware.d.ts +3 -8
  5. package/dist/core/middleware.d.ts.map +1 -1
  6. package/dist/core/store.d.ts +1 -1
  7. package/dist/core/store.d.ts.map +1 -1
  8. package/dist/devtools/index.js +12 -32
  9. package/dist/devtools/middleware.d.ts.map +1 -1
  10. package/dist/{effect-ByI1oRBq.js → effect-C6h0PDDI.js} +160 -4
  11. package/dist/{emitter-XwTUpyGv.js → emitter-j4rC71vY.js} +1 -159
  12. package/dist/{store-C3dmtJ4u.js → index-CIFKRy71.js} +578 -17
  13. package/dist/index.d.ts +4 -2
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/isPromiseLike-bFkfHAbm.js +6 -0
  16. package/dist/meta/createMetaQuery.d.ts +10 -0
  17. package/dist/meta/createMetaQuery.d.ts.map +1 -0
  18. package/dist/meta/index.d.ts +4 -0
  19. package/dist/meta/index.d.ts.map +1 -0
  20. package/dist/meta/meta.d.ts +71 -0
  21. package/dist/meta/meta.d.ts.map +1 -0
  22. package/dist/meta/withMeta.d.ts +48 -0
  23. package/dist/meta/withMeta.d.ts.map +1 -0
  24. package/dist/meta-u3yOx5Kh.js +29 -0
  25. package/dist/persist/index.d.ts +1 -1
  26. package/dist/persist/index.d.ts.map +1 -1
  27. package/dist/persist/index.js +27 -12
  28. package/dist/persist/persist.d.ts +47 -2
  29. package/dist/persist/persist.d.ts.map +1 -1
  30. package/dist/react/context.d.ts.map +1 -1
  31. package/dist/react/index.js +49 -43
  32. package/dist/storion.js +39 -486
  33. package/dist/types.d.ts +149 -34
  34. package/dist/types.d.ts.map +1 -1
  35. package/package.json +1 -1
  36. package/dist/is-KT6PknjJ.js +0 -44
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/meta/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,71 @@
1
+ import { MetaType } from '../types';
2
+
3
+ /**
4
+ * Create a metadata builder for decorating stores with custom metadata.
5
+ *
6
+ * Meta allows libraries and users to attach arbitrary typed metadata to:
7
+ * - Store level: `myMeta(value)` - applies to the entire store
8
+ * - Field level: `myMeta.for("fieldName", value)` - applies to specific state field
9
+ *
10
+ * Retrieve meta via `ctx.meta(type)` which returns first value (default),
11
+ * or use `ctx.meta.all(type)` for all values.
12
+ *
13
+ * @example Store-level meta (boolean flag)
14
+ * ```ts
15
+ * const persist = meta();
16
+ *
17
+ * const userStore = store({
18
+ * state: { name: "" },
19
+ * meta: [persist()],
20
+ * });
21
+ *
22
+ * ctx.meta(persist).store; // true (first value)
23
+ * ctx.meta.all(persist).store; // [true] (all values)
24
+ * ```
25
+ *
26
+ * @example Store-level meta (with value)
27
+ * ```ts
28
+ * const priority = meta((level: number) => level);
29
+ *
30
+ * const criticalStore = store({
31
+ * state: { data: null },
32
+ * meta: [priority(1), priority(2)],
33
+ * });
34
+ *
35
+ * ctx.meta(priority).store; // 1 (first)
36
+ * ctx.meta.all(priority).store; // [1, 2] (all)
37
+ * ```
38
+ *
39
+ * @example Field-level meta
40
+ * ```ts
41
+ * const validate = meta((rule: string) => rule);
42
+ *
43
+ * const formStore = store({
44
+ * state: { email: "", age: 0 },
45
+ * meta: [
46
+ * validate.for("email", "email-format"),
47
+ * validate.for("age", "positive-number"),
48
+ * ],
49
+ * });
50
+ *
51
+ * formStore.meta(validate).fields.email; // "email-format"
52
+ * formStore.meta(validate).fields.age; // "positive-number"
53
+ * ```
54
+ *
55
+ * @example Check meta existence
56
+ * ```ts
57
+ * const persist = meta();
58
+ * const sync = meta();
59
+ *
60
+ * userStore.meta.any(persist); // true
61
+ * userStore.meta.any(sync); // false
62
+ * userStore.meta.any(persist, sync); // true (has at least one)
63
+ * ```
64
+ *
65
+ * @param builder - Optional function to transform arguments into meta value.
66
+ * If omitted, meta value defaults to `true`.
67
+ * @returns A MetaType that creates MetaEntry objects
68
+ */
69
+ export declare function meta(): MetaType<any, [], true>;
70
+ export declare function meta<TValue, TArgs extends any[]>(builder: (...args: TArgs) => TValue): MetaType<any, TArgs, TValue>;
71
+ //# sourceMappingURL=meta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../src/meta/meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAa,MAAM,UAAU,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AACH,wBAAgB,IAAI,IAAI,QAAQ,CAAC,GAAG,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;AAChD,wBAAgB,IAAI,CAAC,MAAM,EAAE,KAAK,SAAS,GAAG,EAAE,EAC9C,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,MAAM,GAClC,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC"}
@@ -0,0 +1,48 @@
1
+ import { Factory, MetaEntry } from '../types';
2
+
3
+ /**
4
+ * Attach metadata to a service or factory function.
5
+ *
6
+ * This allows middleware to access meta information for any factory,
7
+ * not just stores. Meta is queried via `ctx.meta` in middleware context.
8
+ *
9
+ * @example Basic usage
10
+ * ```ts
11
+ * const persist = meta();
12
+ * const priority = meta((level: number) => level);
13
+ *
14
+ * // Attach meta to a service factory
15
+ * const apiService = withMeta(
16
+ * (resolver) => ({ fetch: () => {} }),
17
+ * [persist(), priority(1)]
18
+ * );
19
+ *
20
+ * // In middleware, query via ctx.meta
21
+ * const middleware: Middleware = (ctx) => {
22
+ * if (ctx.meta.any(persist)) {
23
+ * console.log("This factory should be persisted");
24
+ * }
25
+ * return ctx.next();
26
+ * };
27
+ * ```
28
+ *
29
+ * @example Combined with store meta
30
+ * ```ts
31
+ * // Factory meta and store spec meta are merged in ctx.meta
32
+ * const userStore = store({
33
+ * name: "user",
34
+ * state: { name: "" },
35
+ * meta: [persist()], // spec meta
36
+ * });
37
+ *
38
+ * // In middleware, ctx.meta includes both factory.meta and spec.meta
39
+ * ```
40
+ *
41
+ * @param factory - The factory function to attach meta to
42
+ * @param meta - Single MetaEntry or array of MetaEntry
43
+ * @returns The same factory function with `.meta` property attached
44
+ */
45
+ export declare function withMeta<TFactory extends Factory, TField extends ReturnType<TFactory> extends object ? keyof ReturnType<TFactory> : any>(factory: TFactory, meta: MetaEntry<TField, any> | MetaEntry<TField, any>[]): TFactory & {
46
+ meta: MetaEntry<TField, any>[];
47
+ };
48
+ //# sourceMappingURL=withMeta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withMeta.d.ts","sourceRoot":"","sources":["../../src/meta/withMeta.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,QAAQ,CACtB,QAAQ,SAAS,OAAO,EACxB,MAAM,SAAS,UAAU,CAAC,QAAQ,CAAC,SAAS,MAAM,GAC9C,MAAM,UAAU,CAAC,QAAQ,CAAC,GAC1B,GAAG,EAEP,OAAO,EAAE,QAAQ,EACjB,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GACtD,QAAQ,GAAG;IACZ,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;CAChC,CAIA"}
@@ -0,0 +1,29 @@
1
+ function meta(builder) {
2
+ const metaType = Object.assign(
3
+ // Store-level meta: myMeta(...args)
4
+ (...args) => {
5
+ return {
6
+ fields: void 0,
7
+ value: (builder == null ? void 0 : builder(...args)) ?? true,
8
+ type: metaType
9
+ // reference the MetaType itself
10
+ };
11
+ },
12
+ {
13
+ // Field-level meta: myMeta.for("fieldName", ...args) or myMeta.for(["f1", "f2"], ...args)
14
+ for(fieldOrFields, ...args) {
15
+ const fields = Array.isArray(fieldOrFields) ? fieldOrFields : [fieldOrFields];
16
+ return {
17
+ fields,
18
+ value: (builder == null ? void 0 : builder(...args)) ?? true,
19
+ type: metaType
20
+ // reference the MetaType itself
21
+ };
22
+ }
23
+ }
24
+ );
25
+ return metaType;
26
+ }
27
+ export {
28
+ meta as m
29
+ };
@@ -5,5 +5,5 @@
5
5
  *
6
6
  * @packageDocumentation
7
7
  */
8
- export { persistMiddleware, type PersistOptions, type PersistLoadResult, } from './persist';
8
+ export { persistMiddleware, notPersisted, type PersistOptions, type PersistLoadResult, } from './persist';
9
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/persist/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,iBAAiB,EACjB,KAAK,cAAc,EACnB,KAAK,iBAAiB,GACvB,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/persist/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,KAAK,cAAc,EACnB,KAAK,iBAAiB,GACvB,MAAM,WAAW,CAAC"}
@@ -1,22 +1,36 @@
1
- import { i as isStore } from "../is-KT6PknjJ.js";
2
- function isPromiseLike(value) {
3
- return value !== null && typeof value === "object" && "then" in value && typeof value.then === "function";
4
- }
1
+ import { m as meta } from "../meta-u3yOx5Kh.js";
2
+ import { i as isPromiseLike } from "../isPromiseLike-bFkfHAbm.js";
3
+ const notPersisted = meta();
5
4
  function persistMiddleware(options) {
6
- const { filter, load, save, onError } = options;
7
- return (ctx) => {
8
- const instance = ctx.next();
9
- if (!isStore(instance)) {
5
+ const { filter, load, save, onError, force = false } = options;
6
+ return ({ spec, next, meta: meta2 }) => {
7
+ const instance = next();
8
+ if (filter && !filter(spec)) {
10
9
  return instance;
11
10
  }
12
- const spec = instance.spec;
13
- if (filter && !filter(spec)) {
11
+ const notPersistedInfo = meta2(notPersisted);
12
+ if (notPersistedInfo.store === true) {
14
13
  return instance;
15
14
  }
15
+ const excludedFields = new Set(
16
+ Object.keys(notPersistedInfo.fields).filter(
17
+ (field) => notPersistedInfo.fields[field] === true
18
+ )
19
+ );
20
+ const filterState = (state) => {
21
+ if (excludedFields.size === 0) return state;
22
+ const filtered = {};
23
+ for (const key in state) {
24
+ if (!excludedFields.has(key)) {
25
+ filtered[key] = state[key];
26
+ }
27
+ }
28
+ return filtered;
29
+ };
16
30
  const hydrateWithState = (state) => {
17
31
  if (state != null) {
18
32
  try {
19
- instance.hydrate(state);
33
+ instance.hydrate(filterState(state), { force });
20
34
  } catch (error) {
21
35
  onError == null ? void 0 : onError(spec, error, "load");
22
36
  }
@@ -41,7 +55,7 @@ function persistMiddleware(options) {
41
55
  instance.subscribe(() => {
42
56
  try {
43
57
  const state = instance.dehydrate();
44
- save(spec, state);
58
+ save(spec, filterState(state));
45
59
  } catch (error) {
46
60
  onError == null ? void 0 : onError(spec, error, "save");
47
61
  }
@@ -51,5 +65,6 @@ function persistMiddleware(options) {
51
65
  };
52
66
  }
53
67
  export {
68
+ notPersisted,
54
69
  persistMiddleware
55
70
  };
@@ -1,5 +1,39 @@
1
- import { StoreSpec, Middleware } from '../types';
1
+ import { StoreSpec, StoreMiddleware } from '../types';
2
2
 
3
+ /**
4
+ * Mark stores or fields as not persisted.
5
+ *
6
+ * When called without arguments, marks the entire store as not persisted.
7
+ * When called with a field name, marks that specific field as not persisted.
8
+ *
9
+ * @example Store-level exclusion
10
+ * ```ts
11
+ * import { notPersisted } from 'storion/persist';
12
+ *
13
+ * const tempStore = store({
14
+ * name: 'temp',
15
+ * state: { sessionData: {} },
16
+ * setup: () => ({}),
17
+ * meta: [notPersisted()], // entire store skipped
18
+ * });
19
+ * ```
20
+ *
21
+ * @example Field-level exclusion
22
+ * ```ts
23
+ * import { notPersisted } from 'storion/persist';
24
+ *
25
+ * const userStore = store({
26
+ * name: 'user',
27
+ * state: { name: '', password: '', token: '' },
28
+ * setup: () => ({}),
29
+ * meta: [
30
+ * notPersisted('password'),
31
+ * notPersisted('token'),
32
+ * ],
33
+ * });
34
+ * ```
35
+ */
36
+ export declare const notPersisted: import('..').MetaType<any, [], true>;
3
37
  /**
4
38
  * Result from load function - can be sync or async
5
39
  */
@@ -39,6 +73,17 @@ export interface PersistOptions {
39
73
  * @param operation - Whether the error occurred during 'load' or 'save'
40
74
  */
41
75
  onError?: (spec: StoreSpec, error: unknown, operation: "load" | "save") => void;
76
+ /**
77
+ * Force hydration to overwrite dirty (modified) state properties.
78
+ *
79
+ * By default (false), hydrate() skips properties that have been modified
80
+ * since initialization to avoid overwriting fresh data with stale persisted data.
81
+ *
82
+ * Set to true to always apply persisted data regardless of dirty state.
83
+ *
84
+ * @default false
85
+ */
86
+ force?: boolean;
42
87
  }
43
88
  /**
44
89
  * Creates a persist middleware that automatically saves and restores store state.
@@ -79,5 +124,5 @@ export interface PersistOptions {
79
124
  * });
80
125
  * ```
81
126
  */
82
- export declare function persistMiddleware(options: PersistOptions): Middleware;
127
+ export declare function persistMiddleware(options: PersistOptions): StoreMiddleware;
83
128
  //# sourceMappingURL=persist.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"persist.d.ts","sourceRoot":"","sources":["../../src/persist/persist.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtD;;GAEG;AACH,MAAM,MAAM,iBAAiB,GACzB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACvB,IAAI,GACJ,SAAS,GACT,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,OAAO,CAAC;IAEtC;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,iBAAiB,CAAC;IAE9C;;;;;OAKG;IACH,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IAEjE;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,CACR,IAAI,EAAE,SAAS,EACf,KAAK,EAAE,OAAO,EACd,SAAS,EAAE,MAAM,GAAG,MAAM,KACvB,IAAI,CAAC;CACX;AAcD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,cAAc,GAAG,UAAU,CAkErE"}
1
+ {"version":3,"file":"persist.d.ts","sourceRoot":"","sources":["../../src/persist/persist.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAI3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,YAAY,sCAAS,CAAC;AAEnC;;GAEG;AACH,MAAM,MAAM,iBAAiB,GACzB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACvB,IAAI,GACJ,SAAS,GACT,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,OAAO,CAAC;IAEtC;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,iBAAiB,CAAC;IAE9C;;;;;OAKG;IACH,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IAEjE;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,CACR,IAAI,EAAE,SAAS,EACf,KAAK,EAAE,OAAO,EACd,SAAS,EAAE,MAAM,GAAG,MAAM,KACvB,IAAI,CAAC;IAEV;;;;;;;;;OASG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,cAAc,GAAG,eAAe,CAmG1E"}
@@ -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;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"}
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,EAIR,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,CAoBhD,CAAC;AAEF;;GAEG;AACH,wBAAgB,YAAY,IAAI,cAAc,CAO7C"}
@@ -1,21 +1,26 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { memo, useMemo, createElement, createContext, useContext, useReducer, useRef, useEffect, useLayoutEffect, useState, forwardRef } from "react";
5
- import { container } from "../storion.js";
6
- import { applyExcept, applyFor, compose, createLoggingMiddleware, createResolver, createValidationMiddleware, forStores, pick, trigger, when } from "../storion.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 { a as isSpec, S as STORION_TYPE } from "../is-KT6PknjJ.js";
10
- import { g, b as b2, f, d as d2, e, j, i, h, c as c2 } from "../is-KT6PknjJ.js";
4
+ import { memo, useRef, useMemo, createElement, createContext, useContext, useReducer, useEffect, useLayoutEffect, useState, forwardRef } from "react";
5
+ import { c as container, i as isSpec, S as STORION_TYPE, r as resolveEquality, s as store } from "../index-CIFKRy71.js";
6
+ import { q, o, m, l, n, x, u, t, g, a, h, d, f, k, e, j, b, C, p, v, y, z, B, w, D, A } from "../index-CIFKRy71.js";
7
+ import { P as ProviderMissingError, L as LocalStoreDependencyError, w as withHooks, A as AsyncFunctionError } from "../effect-C6h0PDDI.js";
8
+ import { E, H, I, c, a as a2, d as d2, S, b as b2, e as e2, u as u2 } from "../effect-C6h0PDDI.js";
11
9
  import { jsx } from "react/jsx-runtime";
12
- import { r as resolveEquality, s as store } from "../store-C3dmtJ4u.js";
13
- import { d as d3, e as e2, i as i2, a as a2, b as b3, u as u2, w } from "../store-C3dmtJ4u.js";
14
- import { e as e3 } from "../effect-ByI1oRBq.js";
10
+ import { m as m2 } from "../meta-u3yOx5Kh.js";
15
11
  const StoreContext = createContext(null);
16
12
  const StoreProvider = memo(
17
13
  ({ container: value, children }) => {
18
- const valueOrDefault = useMemo(() => value ?? container(), [value]);
14
+ const defaultContainerRef = useRef();
15
+ const valueOrDefault = useMemo(() => {
16
+ if (value) {
17
+ return value;
18
+ }
19
+ if (!defaultContainerRef.current) {
20
+ defaultContainerRef.current = container();
21
+ }
22
+ return defaultContainerRef.current;
23
+ }, [value]);
19
24
  return createElement(
20
25
  StoreContext.Provider,
21
26
  { value: valueOrDefault },
@@ -83,7 +88,7 @@ const useIsomorphicLayoutEffect = isServer ? useEffect : useLayoutEffect;
83
88
  const shouldScheduleDispose = !isServer && typeof useLayoutEffect === "function" && dev();
84
89
  function useLocalStore(spec) {
85
90
  var _a;
86
- const [, forceUpdate] = useReducer((x) => x + 1, 0);
91
+ const [, forceUpdate] = useReducer((x2) => x2 + 1, 0);
87
92
  const prevControllerRef = useRef(null);
88
93
  const controller = useMemo(() => new LocalStoreController(spec), [spec]);
89
94
  if (prevControllerRef.current !== controller) {
@@ -194,7 +199,7 @@ class LocalStoreController {
194
199
  }
195
200
  }
196
201
  function useStoreWithContainer(selector, container2) {
197
- const [, forceUpdate] = useReducer((x) => x + 1, 0);
202
+ const [, forceUpdate] = useReducer((x2) => x2 + 1, 0);
198
203
  const [refs] = useState(() => ({
199
204
  fresh: void 0,
200
205
  stableFns: /* @__PURE__ */ new Map(),
@@ -407,45 +412,46 @@ export {
407
412
  LocalStoreDependencyError,
408
413
  ProviderMissingError,
409
414
  STORION_TYPE,
410
- a as SetupPhaseError,
411
- d as StoreDisposedError,
415
+ a2 as SetupPhaseError,
416
+ d2 as StoreDisposedError,
412
417
  StoreProvider,
413
418
  S as StorionError,
414
- applyExcept,
415
- applyFor,
416
- b as batch,
417
- compose,
419
+ q as applyExcept,
420
+ o as applyFor,
421
+ b2 as batch,
418
422
  container,
419
423
  create,
420
- createLoggingMiddleware,
421
- createResolver,
422
- createValidationMiddleware,
424
+ m as createLoggingMiddleware,
425
+ l as createResolver,
426
+ n as createValidationMiddleware,
423
427
  createWithStore,
424
- d3 as deepEqual,
425
- e3 as effect,
426
- e2 as equality,
427
- forStores,
428
+ x as deepEqual,
429
+ e2 as effect,
430
+ u as equality,
431
+ t as forStores,
428
432
  g as getKind,
429
- b2 as is,
430
- f as isAction,
431
- d2 as isContainer,
432
- e as isFocus,
433
- j as isSelectorContext,
433
+ a as is,
434
+ h as isAction,
435
+ d as isContainer,
436
+ f as isFocus,
437
+ k as isSelectorContext,
434
438
  isSpec,
435
- i as isStore,
436
- h as isStoreContext,
437
- c2 as isStorion,
438
- i2 as isWrappedFn,
439
- pick,
440
- a2 as shallowEqual,
439
+ e as isStore,
440
+ j as isStoreContext,
441
+ b as isStorion,
442
+ C as isWrappedFn,
443
+ m2 as meta,
444
+ p as pick,
445
+ v as shallowEqual,
441
446
  store,
442
- b3 as strictEqual,
443
- trigger,
444
- u as untrack,
445
- u2 as unwrapFn,
447
+ y as strictEqual,
448
+ z as trigger,
449
+ u2 as untrack,
450
+ B as unwrapFn,
446
451
  useContainer,
447
452
  useStore,
448
- when,
453
+ w as when,
454
+ D as withMeta,
449
455
  withStore,
450
- w as wrapFn
456
+ A as wrapFn
451
457
  };