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
@@ -0,0 +1,83 @@
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()` or `myMeta(value)` - applies to the entire store
8
+ * - Field level: `myMeta.for("fieldName")` or `myMeta.for("fieldName", value)` - applies to specific field
9
+ *
10
+ * ## Overloads
11
+ *
12
+ * ### 1. `meta()` - Boolean flag meta
13
+ * Creates a meta type where calling `myMeta()` returns `MetaEntry<any, true>`
14
+ * ```ts
15
+ * const persist = meta();
16
+ * persist() // MetaEntry with value: true
17
+ * persist.for("field") // MetaEntry with value: true for field
18
+ * ```
19
+ *
20
+ * ### 2. `meta<TValue>()` - Typed value meta (requires value argument)
21
+ * Creates a meta type where calling `myMeta(value)` returns `MetaEntry<any, TValue>`
22
+ * ```ts
23
+ * const priority = meta<number>();
24
+ * priority(1) // MetaEntry with value: 1
25
+ * priority.for("field", 5) // MetaEntry with value: 5 for field
26
+ * ```
27
+ *
28
+ * ### 3. `meta(builder)` - Custom builder meta
29
+ * Creates a meta type with custom value transformation
30
+ * ```ts
31
+ * const config = meta((name: string, value: number) => ({ name, value }));
32
+ * config("timeout", 5000) // MetaEntry with value: { name: "timeout", value: 5000 }
33
+ * ```
34
+ *
35
+ * @example Boolean flag meta
36
+ * ```ts
37
+ * const persist = meta();
38
+ *
39
+ * const userStore = store({
40
+ * state: { name: "" },
41
+ * meta: [persist()],
42
+ * });
43
+ *
44
+ * ctx.meta(persist).store; // true
45
+ * ```
46
+ *
47
+ * @example Typed value meta
48
+ * ```ts
49
+ * const priority = meta<number>();
50
+ *
51
+ * const criticalStore = store({
52
+ * state: { data: null },
53
+ * meta: [priority(1)],
54
+ * });
55
+ *
56
+ * ctx.meta(priority).store; // 1
57
+ * ```
58
+ *
59
+ * @example Field-level meta
60
+ * ```ts
61
+ * const validate = meta<string>();
62
+ *
63
+ * const formStore = store({
64
+ * state: { email: "", age: 0 },
65
+ * meta: [
66
+ * validate.for("email", "email-format"),
67
+ * validate.for("age", "positive-number"),
68
+ * ],
69
+ * });
70
+ *
71
+ * formStore.meta(validate).fields.email; // "email-format"
72
+ * formStore.meta(validate).fields.age; // "positive-number"
73
+ * ```
74
+ *
75
+ * @param builder - Optional function to transform arguments into meta value.
76
+ * If omitted with no type param, meta value is `true`.
77
+ * If omitted with type param, first argument is returned as value.
78
+ * @returns A MetaType that creates MetaEntry objects
79
+ */
80
+ export declare function meta(): MetaType<any, [], true>;
81
+ export declare function meta<TValue>(): MetaType<any, [value: TValue], TValue>;
82
+ export declare function meta<TValue, TArgs extends any[]>(builder: (...args: TArgs) => TValue): MetaType<any, TArgs, TValue>;
83
+ //# 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,EAAsB,MAAM,UAAU,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4EG;AACH,wBAAgB,IAAI,IAAI,QAAQ,CAAC,GAAG,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;AAChD,wBAAgB,IAAI,CAAC,MAAM,KAAK,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC;AACvE,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,32 @@
1
+ function meta(builder) {
2
+ if (!builder) {
3
+ builder = (...args) => args.length ? args[0] : true;
4
+ }
5
+ const metaType = Object.assign(
6
+ // Store-level meta: myMeta(...args)
7
+ (...args) => {
8
+ return {
9
+ fields: void 0,
10
+ value: (builder == null ? void 0 : builder(...args)) ?? true,
11
+ type: metaType
12
+ // reference the MetaType itself
13
+ };
14
+ },
15
+ {
16
+ // Field-level meta: myMeta.for("fieldName", ...args) or myMeta.for(["f1", "f2"], ...args)
17
+ for(fieldOrFields, ...args) {
18
+ const fields = Array.isArray(fieldOrFields) ? fieldOrFields : [fieldOrFields];
19
+ return {
20
+ fields,
21
+ value: (builder == null ? void 0 : builder(...args)) ?? true,
22
+ type: metaType
23
+ // reference the MetaType itself
24
+ };
25
+ }
26
+ }
27
+ );
28
+ return metaType;
29
+ }
30
+ export {
31
+ meta as m
32
+ };
@@ -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-40r-AZfe.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-OPaTR3zq.js";
6
+ import { n, m, l, u, q, o, g, a, h, d, f, k, e, j, b, z, p, t, v, w, y, A, x } from "../index-OPaTR3zq.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-40r-AZfe.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,43 @@ 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
+ n as applyExcept,
420
+ m as applyFor,
421
+ b2 as batch,
418
422
  container,
419
423
  create,
420
- createLoggingMiddleware,
421
- createResolver,
422
- createValidationMiddleware,
424
+ l as createResolver,
423
425
  createWithStore,
424
- d3 as deepEqual,
425
- e3 as effect,
426
- e2 as equality,
427
- forStores,
426
+ u as deepEqual,
427
+ e2 as effect,
428
+ q as equality,
429
+ o as forStores,
428
430
  g as getKind,
429
- b2 as is,
430
- f as isAction,
431
- d2 as isContainer,
432
- e as isFocus,
433
- j as isSelectorContext,
431
+ a as is,
432
+ h as isAction,
433
+ d as isContainer,
434
+ f as isFocus,
435
+ k as isSelectorContext,
434
436
  isSpec,
435
- i as isStore,
436
- h as isStoreContext,
437
- c2 as isStorion,
438
- i2 as isWrappedFn,
439
- pick,
440
- a2 as shallowEqual,
437
+ e as isStore,
438
+ j as isStoreContext,
439
+ b as isStorion,
440
+ z as isWrappedFn,
441
+ m2 as meta,
442
+ p as pick,
443
+ t as shallowEqual,
441
444
  store,
442
- b3 as strictEqual,
443
- trigger,
444
- u as untrack,
445
- u2 as unwrapFn,
445
+ v as strictEqual,
446
+ w as trigger,
447
+ u2 as untrack,
448
+ y as unwrapFn,
446
449
  useContainer,
447
450
  useStore,
448
- when,
451
+ A as withMeta,
449
452
  withStore,
450
- w as wrapFn
453
+ x as wrapFn
451
454
  };