stroid 0.1.1 → 0.1.2

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 (180) hide show
  1. package/CHANGELOG.md +210 -119
  2. package/README.md +104 -431
  3. package/dist/async.d.ts +42 -9
  4. package/dist/async.js +26 -26
  5. package/dist/async.js.map +1 -1
  6. package/dist/cache.d.ts +12 -0
  7. package/dist/computed.d.ts +40 -7
  8. package/dist/computed.js +11 -11
  9. package/dist/computed.js.map +1 -1
  10. package/dist/core.d.ts +5 -15
  11. package/dist/core.js +14 -15
  12. package/dist/core.js.map +1 -1
  13. package/dist/devtools.d.ts +30 -5
  14. package/dist/devtools.js +1 -1
  15. package/dist/devtools.js.map +1 -1
  16. package/dist/feature.d.ts +92 -14
  17. package/dist/feature.js +1 -1
  18. package/dist/feature.js.map +1 -1
  19. package/dist/helpers.d.ts +37 -3
  20. package/dist/helpers.js +14 -15
  21. package/dist/helpers.js.map +1 -1
  22. package/dist/index-internal.d.ts +44 -0
  23. package/dist/index.d.cts +169 -33
  24. package/dist/index.d.ts +169 -33
  25. package/dist/index.js +24 -23
  26. package/dist/index.js.map +1 -1
  27. package/dist/install.d.ts +6 -4
  28. package/dist/install.js +1 -1
  29. package/dist/install.js.map +1 -1
  30. package/dist/options.d.ts +295 -0
  31. package/dist/persist.d.ts +1 -1
  32. package/dist/persist.js +1 -1
  33. package/dist/persist.js.map +1 -1
  34. package/dist/react/index.d.ts +70 -0
  35. package/dist/react/index.js +38 -0
  36. package/dist/react/index.js.map +1 -0
  37. package/dist/registry.d.ts +117 -0
  38. package/dist/runtime-admin.d.ts +4 -2
  39. package/dist/runtime-admin.js +1 -1
  40. package/dist/runtime-admin.js.map +1 -1
  41. package/dist/runtime-tools.d.ts +66 -9
  42. package/dist/runtime-tools.js +2 -2
  43. package/dist/runtime-tools.js.map +1 -1
  44. package/dist/selectors.d.ts +4 -2
  45. package/dist/selectors.js +1 -1
  46. package/dist/selectors.js.map +1 -1
  47. package/dist/server.d.ts +30 -2
  48. package/dist/server.js +11 -10
  49. package/dist/server.js.map +1 -1
  50. package/dist/store-registry.d.ts +80 -0
  51. package/dist/sync.d.ts +1 -1
  52. package/dist/sync.js +1 -1
  53. package/dist/sync.js.map +1 -1
  54. package/dist/testing.d.ts +16 -4
  55. package/dist/testing.js +14 -15
  56. package/dist/testing.js.map +1 -1
  57. package/dist/tsdoc-metadata.json +11 -0
  58. package/dist/types/adapters/options.d.ts +335 -0
  59. package/dist/types/async/cache.d.ts +39 -0
  60. package/dist/types/async/clone.d.ts +10 -0
  61. package/dist/types/async/errors.d.ts +3 -0
  62. package/dist/types/async/fetch.d.ts +37 -0
  63. package/dist/types/async/inflight.d.ts +13 -0
  64. package/dist/types/async/rate.d.ts +5 -0
  65. package/dist/types/async/registry.d.ts +116 -0
  66. package/dist/types/async/request.d.ts +11 -0
  67. package/dist/types/async/retry.d.ts +10 -0
  68. package/dist/types/async.d.ts +10 -0
  69. package/dist/types/computed/computed-graph.d.ts +29 -0
  70. package/dist/types/computed/index.d.ts +16 -0
  71. package/dist/types/config.d.ts +10 -0
  72. package/dist/types/core/index.d.ts +11 -0
  73. package/dist/types/core/lifecycle-hooks.d.ts +16 -0
  74. package/dist/types/core/store-admin-impl.d.ts +9 -0
  75. package/dist/types/core/store-admin.d.ts +9 -0
  76. package/dist/types/core/store-core.d.ts +13 -0
  77. package/dist/types/core/store-create.d.ts +16 -0
  78. package/dist/types/core/store-hydrate-impl.d.ts +35 -0
  79. package/dist/types/core/store-hydrate.d.ts +9 -0
  80. package/dist/types/core/store-lifecycle/hooks.d.ts +19 -0
  81. package/dist/types/core/store-lifecycle/identity.d.ts +23 -0
  82. package/dist/types/core/store-lifecycle/registry.d.ts +53 -0
  83. package/dist/types/core/store-lifecycle/types.d.ts +67 -0
  84. package/dist/types/core/store-lifecycle/validation.d.ts +53 -0
  85. package/dist/types/core/store-name.d.ts +28 -0
  86. package/dist/types/core/store-notify.d.ts +12 -0
  87. package/dist/types/core/store-read.d.ts +18 -0
  88. package/dist/types/core/store-registry.d.ts +108 -0
  89. package/dist/types/core/store-replace-impl.d.ts +11 -0
  90. package/dist/types/core/store-replace.d.ts +9 -0
  91. package/dist/types/core/store-set-impl.d.ts +13 -0
  92. package/dist/types/core/store-set.d.ts +9 -0
  93. package/dist/types/core/store-shared/core.d.ts +13 -0
  94. package/dist/types/core/store-shared/notify.d.ts +12 -0
  95. package/dist/types/core/store-transaction.d.ts +26 -0
  96. package/dist/types/core/store-write-shared.d.ts +19 -0
  97. package/dist/types/core/store-write.d.ts +13 -0
  98. package/dist/types/features/feature-registry.d.ts +91 -0
  99. package/dist/types/features/lifecycle.d.ts +40 -0
  100. package/dist/types/index.d.ts +17 -0
  101. package/dist/types/integrations/query.d.ts +8 -0
  102. package/dist/types/internals/computed-order.d.ts +3 -0
  103. package/dist/types/internals/config.d.ts +116 -0
  104. package/dist/types/internals/diagnostics.d.ts +21 -0
  105. package/dist/types/internals/reporting.d.ts +9 -0
  106. package/dist/types/internals/store-admin.d.ts +7 -0
  107. package/dist/types/internals/store-ops.d.ts +13 -0
  108. package/dist/types/internals/test-reset.d.ts +2 -0
  109. package/dist/types/internals/write-context.d.ts +15 -0
  110. package/dist/types/notification/delivery.d.ts +3 -0
  111. package/dist/types/notification/index.d.ts +10 -0
  112. package/dist/types/notification/metrics.d.ts +12 -0
  113. package/dist/types/notification/priority.d.ts +9 -0
  114. package/dist/types/notification/scheduler.d.ts +11 -0
  115. package/dist/types/notification/snapshot.d.ts +8 -0
  116. package/dist/types/runtime-admin/index.d.ts +2 -0
  117. package/dist/types/runtime-tools/index.d.ts +58 -0
  118. package/dist/types/store.d.ts +16 -0
  119. package/dist/types/types/utility.d.ts +17 -0
  120. package/dist/types/utils/clone.d.ts +4 -0
  121. package/dist/types/utils/devfreeze.d.ts +2 -0
  122. package/dist/types/utils/hash.d.ts +8 -0
  123. package/dist/types/utils/path.d.ts +5 -0
  124. package/dist/types/utils/validation.d.ts +14 -0
  125. package/dist/types/utils.d.ts +13 -0
  126. package/dist/types.d.ts +65 -0
  127. package/dist/utility.d.ts +15 -0
  128. package/package.json +26 -11
  129. package/dist/_tsup-dts-rollup.d.cts +0 -2411
  130. package/dist/_tsup-dts-rollup.d.ts +0 -2411
  131. package/dist/async.cjs +0 -34
  132. package/dist/async.cjs.map +0 -1
  133. package/dist/async.d.cts +0 -9
  134. package/dist/computed.cjs +0 -13
  135. package/dist/computed.cjs.map +0 -1
  136. package/dist/computed.d.cts +0 -7
  137. package/dist/core.cjs +0 -24
  138. package/dist/core.cjs.map +0 -1
  139. package/dist/core.d.cts +0 -15
  140. package/dist/devtools.cjs +0 -2
  141. package/dist/devtools.cjs.map +0 -1
  142. package/dist/devtools.d.cts +0 -5
  143. package/dist/feature.cjs +0 -2
  144. package/dist/feature.cjs.map +0 -1
  145. package/dist/feature.d.cts +0 -14
  146. package/dist/helpers.cjs +0 -24
  147. package/dist/helpers.cjs.map +0 -1
  148. package/dist/helpers.d.cts +0 -3
  149. package/dist/index.cjs +0 -35
  150. package/dist/index.cjs.map +0 -1
  151. package/dist/install.cjs +0 -2
  152. package/dist/install.cjs.map +0 -1
  153. package/dist/install.d.cts +0 -4
  154. package/dist/persist.cjs +0 -2
  155. package/dist/persist.cjs.map +0 -1
  156. package/dist/persist.d.cts +0 -1
  157. package/dist/react.cjs +0 -36
  158. package/dist/react.cjs.map +0 -1
  159. package/dist/react.d.cts +0 -7
  160. package/dist/react.d.ts +0 -7
  161. package/dist/react.js +0 -36
  162. package/dist/react.js.map +0 -1
  163. package/dist/runtime-admin.cjs +0 -2
  164. package/dist/runtime-admin.cjs.map +0 -1
  165. package/dist/runtime-admin.d.cts +0 -2
  166. package/dist/runtime-tools.cjs +0 -4
  167. package/dist/runtime-tools.cjs.map +0 -1
  168. package/dist/runtime-tools.d.cts +0 -9
  169. package/dist/selectors.cjs +0 -2
  170. package/dist/selectors.cjs.map +0 -1
  171. package/dist/selectors.d.cts +0 -2
  172. package/dist/server.cjs +0 -12
  173. package/dist/server.cjs.map +0 -1
  174. package/dist/server.d.cts +0 -2
  175. package/dist/sync.cjs +0 -2
  176. package/dist/sync.cjs.map +0 -1
  177. package/dist/sync.d.cts +0 -1
  178. package/dist/testing.cjs +0 -24
  179. package/dist/testing.cjs.map +0 -1
  180. package/dist/testing.d.cts +0 -4
@@ -0,0 +1,44 @@
1
+ import { S as StoreOptions } from './options.js';
2
+ import { N as NonFunction } from './utility.js';
3
+ import { d as StoreValue, a as StoreDefinition, b as StoreKey, c as StoreName, i as Path, e as StateFor, j as PathValue, W as WriteResult, P as PartialDeep } from './types.js';
4
+ import { FeatureMetrics } from './feature.js';
5
+
6
+ type IsStoreNameLoose = string extends StoreName ? true : false;
7
+ type StoreUpdate<State> = State | Partial<State> | PartialDeep<State> | ((draft: State) => void);
8
+ type StoreTarget<Name extends string = string, State = StoreValue> = StoreDefinition<Name, State> | StoreKey<Name, State> | StoreName;
9
+ type StorePathForTarget<T> = T extends StoreDefinition<any, infer S> ? Path<S> : T extends StoreKey<any, infer S> ? Path<S> : (IsStoreNameLoose extends true ? string | string[] : (T extends StoreName ? Path<StateFor<T>> : string | string[]));
10
+ type StorePathValueForTarget<T, P> = T extends StoreDefinition<any, infer S> ? (P extends Path<S> ? PathValue<S, P> : never) : T extends StoreKey<any, infer S> ? (P extends Path<S> ? PathValue<S, P> : never) : (IsStoreNameLoose extends true ? unknown : (T extends StoreName ? (P extends Path<StateFor<T>> ? PathValue<StateFor<T>, P> : never) : unknown));
11
+ type StoreUpdateForTarget<T> = T extends StoreDefinition<any, infer S> ? StoreUpdate<S> : T extends StoreKey<any, infer S> ? StoreUpdate<S> : (IsStoreNameLoose extends true ? StoreUpdate<StoreValue> : (T extends StoreName ? StoreUpdate<StateFor<T>> : StoreUpdate<StoreValue>));
12
+ declare function setStore<T extends StoreTarget, P extends StorePathForTarget<T>>(name: T, path: P, value: StorePathValueForTarget<T, P>): WriteResult;
13
+ declare function setStore<T extends StoreTarget>(name: T, update: StoreUpdateForTarget<T>): WriteResult;
14
+
15
+ declare function deleteStore<Name extends string, State>(name: StoreDefinition<Name, State>): void;
16
+ declare function deleteStore<Name extends string, State>(name: StoreKey<Name, State>): void;
17
+ declare function deleteStore<Name extends StoreName>(name: Name): void;
18
+ declare function resetStore<Name extends string, State>(name: StoreDefinition<Name, State>): WriteResult;
19
+ declare function resetStore<Name extends string, State>(name: StoreKey<Name, State>): WriteResult;
20
+ declare function resetStore<Name extends StoreName>(name: Name): WriteResult;
21
+
22
+ type LazyDisallow<T> = T extends {
23
+ lazy: true;
24
+ } ? never : T;
25
+ declare function createStore<Name extends string, State>(name: Name, initialData: () => State, option: StoreOptions<State> & {
26
+ lazy: true;
27
+ }): StoreDefinition<Name, State> | undefined;
28
+ declare function createStore<Name extends string, State, Opt extends StoreOptions<State>>(name: Name, initialData: NonFunction<State>, option?: LazyDisallow<Opt>): StoreDefinition<Name, State> | undefined;
29
+ declare function createStoreStrict<Name extends string, State>(name: Name, initialData: () => State, option: StoreOptions<State> & {
30
+ lazy: true;
31
+ }): StoreDefinition<Name, State>;
32
+ declare function createStoreStrict<Name extends string, State, Opt extends StoreOptions<State>>(name: Name, initialData: NonFunction<State>, option?: LazyDisallow<Opt>): StoreDefinition<Name, State>;
33
+
34
+ type StoreSnapshot<T> = T extends object ? Readonly<T> : T;
35
+ declare function getStore<Name extends string, State, P extends Path<State>>(name: StoreDefinition<Name, State>, path: P): StoreSnapshot<PathValue<State, P>> | null;
36
+ declare function getStore<Name extends string, State>(name: StoreDefinition<Name, State>, path?: undefined): StoreSnapshot<State> | null;
37
+ declare function getStore<Name extends string, State, P extends Path<State>>(name: StoreKey<Name, State>, path: P): StoreSnapshot<PathValue<State, P>> | null;
38
+ declare function getStore<Name extends string, State>(name: StoreKey<Name, State>, path?: undefined): StoreSnapshot<State> | null;
39
+ declare function getStore<Name extends StoreName, P extends Path<StateFor<Name>>>(name: Name, path: P): StoreSnapshot<PathValue<StateFor<Name>, P>> | null;
40
+ declare function getStore<Name extends StoreName>(name: Name, path?: undefined): StoreSnapshot<StateFor<Name>> | null;
41
+ declare const hasStore: (name: string) => boolean;
42
+ declare const getMetrics: (name: string) => FeatureMetrics | null;
43
+
44
+ export { createStoreStrict as a, getStore as b, createStore as c, deleteStore as d, getMetrics as g, hasStore as h, resetStore as r, setStore as s };
package/dist/index.d.cts CHANGED
@@ -1,33 +1,169 @@
1
- export { createStore_alias_1 as createStore } from './_tsup-dts-rollup.cjs';
2
- export { createStoreStrict } from './_tsup-dts-rollup.cjs';
3
- export { setStore_alias_1 as setStore } from './_tsup-dts-rollup.cjs';
4
- export { setStoreBatch } from './_tsup-dts-rollup.cjs';
5
- export { getStore_alias_1 as getStore } from './_tsup-dts-rollup.cjs';
6
- export { deleteStore_alias_1 as deleteStore } from './_tsup-dts-rollup.cjs';
7
- export { resetStore } from './_tsup-dts-rollup.cjs';
8
- export { hasStore } from './_tsup-dts-rollup.cjs';
9
- export { hydrateStores } from './_tsup-dts-rollup.cjs';
10
- export { createComputed_alias_2 as createComputed } from './_tsup-dts-rollup.cjs';
11
- export { invalidateComputed_alias_2 as invalidateComputed } from './_tsup-dts-rollup.cjs';
12
- export { deleteComputed_alias_2 as deleteComputed } from './_tsup-dts-rollup.cjs';
13
- export { isComputedStore_alias_2 as isComputedStore } from './_tsup-dts-rollup.cjs';
14
- export { namespace } from './_tsup-dts-rollup.cjs';
15
- export { store } from './_tsup-dts-rollup.cjs';
16
- export { Path_alias_1 as Path } from './_tsup-dts-rollup.cjs';
17
- export { PathValue_alias_1 as PathValue } from './_tsup-dts-rollup.cjs';
18
- export { PartialDeep_alias_1 as PartialDeep } from './_tsup-dts-rollup.cjs';
19
- export { StoreDefinition_alias_1 as StoreDefinition } from './_tsup-dts-rollup.cjs';
20
- export { StoreValue_alias_1 as StoreValue } from './_tsup-dts-rollup.cjs';
21
- export { StoreKey_alias_1 as StoreKey } from './_tsup-dts-rollup.cjs';
22
- export { StoreName_alias_1 as StoreName } from './_tsup-dts-rollup.cjs';
23
- export { StateFor_alias_1 as StateFor } from './_tsup-dts-rollup.cjs';
24
- export { StoreStateMap_alias_1 as StoreStateMap } from './_tsup-dts-rollup.cjs';
25
- export { StrictStoreMap_alias_1 as StrictStoreMap } from './_tsup-dts-rollup.cjs';
26
- export { WriteResult_alias_1 as WriteResult } from './_tsup-dts-rollup.cjs';
27
- export { FeatureOptions } from './_tsup-dts-rollup.cjs';
28
- export { FeatureOptionsMap } from './_tsup-dts-rollup.cjs';
29
- export { PersistOptions } from './_tsup-dts-rollup.cjs';
30
- export { StoreOptions } from './_tsup-dts-rollup.cjs';
31
- export { SyncOptions } from './_tsup-dts-rollup.cjs';
32
- export { configureStroid_alias_1 as configureStroid } from './_tsup-dts-rollup.cjs';
33
- export { queryIntegrations } from './_tsup-dts-rollup.cjs';
1
+ import { H as HydrateSnapshotFor, S as StoreStateMap, f as StrictStoreMap, g as HydrationResult, b as StoreKey, a as StoreDefinition, W as WriteResult, d as StoreValue, c as StoreName } from './types.js';
2
+ export { h as HydrationFailure, P as PartialDeep, i as Path, j as PathValue, e as StateFor } from './types.js';
3
+ import { S as StoreOptions, b as SnapshotMode, M as MiddlewareCtx, a as StoreValue$1 } from './options.js';
4
+ export { F as FeatureOptions, c as FeatureOptionsMap, P as PersistOptions, d as SyncOptions } from './options.js';
5
+ export { c as createStore, a as createStoreStrict, d as deleteStore, g as getMetrics, b as getStore, h as hasStore, r as resetStore, s as setStore } from './index-internal.js';
6
+ import { N as NonFunction } from './utility.js';
7
+ export { getAsyncMetrics } from './async.js';
8
+ export { findColdStores, getStoreHealth } from './runtime-tools.js';
9
+ export { createComputed, deleteComputed, invalidateComputed, isComputedStore } from './computed.js';
10
+ import { F as FetchInput } from './cache.js';
11
+ import { F as FetchOptions } from './registry.js';
12
+ import './feature.js';
13
+
14
+ declare const setStoreBatch: (fn: () => unknown) => void;
15
+
16
+ type HydrateSnapshot = HydrateSnapshotFor<StoreStateMap & StrictStoreMap>;
17
+ type HydrateOptions<Snapshot extends object> = Partial<{
18
+ [K in keyof Snapshot]: StoreOptions<Snapshot[K]>;
19
+ }> & {
20
+ default?: StoreOptions;
21
+ };
22
+ type HydrationTrustBase<Snapshot extends object> = {
23
+ /**
24
+ * Explicitly trust this snapshot and allow hydration.
25
+ */
26
+ allowTrusted?: boolean;
27
+ /**
28
+ * Alias for allowTrusted.
29
+ */
30
+ allowHydration?: boolean;
31
+ /**
32
+ * @deprecated Use allowTrusted instead.
33
+ */
34
+ allowUntrusted?: boolean;
35
+ validate?: (snapshot: Snapshot) => boolean;
36
+ onValidationError?: (error: unknown, snapshot: Snapshot) => boolean;
37
+ };
38
+ type HydrationTrust<Snapshot extends object> = (HydrationTrustBase<Snapshot> & {
39
+ allowTrusted: true;
40
+ }) | (HydrationTrustBase<Snapshot> & {
41
+ allowHydration: true;
42
+ }) | (HydrationTrustBase<Snapshot> & {
43
+ allowUntrusted: true;
44
+ }) | (HydrationTrustBase<Snapshot> & {
45
+ validate: (snapshot: Snapshot) => boolean;
46
+ });
47
+ declare const hydrateStores: <Snapshot extends object = HydrateSnapshot>(snapshot: Snapshot, options: HydrateOptions<Snapshot> | undefined, trust: HydrationTrust<Snapshot>) => HydrationResult;
48
+
49
+ /**
50
+ * Helper to get an auto-completable, literal-typed store handle without creating it.
51
+ *
52
+ * Example:
53
+ * const user = store("user");
54
+ * setStore(user, "name", "Alex");
55
+ */
56
+ declare const store: <Name extends string, State = StoreValue>(name: Name) => StoreKey<Name, State>;
57
+ declare const namespace: (ns: string) => {
58
+ store: <Name extends string, State = unknown>(name: Name) => StoreKey<Name, State>;
59
+ create: <Name extends string, State>(name: Name, data: NonFunction<State>, options?: StoreOptions<State>) => StoreDefinition<string, State> | undefined;
60
+ createStrict: <Name extends string, State>(name: Name, data: NonFunction<State>, options?: StoreOptions<State>) => StoreDefinition<string, State>;
61
+ set: (name: any, ...rest: any[]) => any;
62
+ get: (name: any, ...rest: any[]) => any;
63
+ delete: (name: string) => void;
64
+ reset: (name: string) => WriteResult;
65
+ };
66
+
67
+ /**
68
+ * @module internals/config
69
+ *
70
+ * LAYER: Internal subsystem
71
+ * OWNS: Module-level behavior and exports for internals/config.
72
+ *
73
+ * Consumers: Internal imports and public API.
74
+ */
75
+
76
+ type LogSink = {
77
+ log?: (msg: string, meta?: Record<string, unknown>) => void;
78
+ warn?: (msg: string, meta?: Record<string, unknown>) => void;
79
+ critical?: (msg: string, meta?: Record<string, unknown>) => void;
80
+ };
81
+ type AsyncCloneMode = "none" | "shallow" | "deep";
82
+ type FlushConfig = {
83
+ chunkSize?: number;
84
+ chunkDelayMs?: number;
85
+ priorityStores?: string[];
86
+ };
87
+ type RevalidateOnFocusConfig = {
88
+ debounceMs?: number;
89
+ maxConcurrent?: number;
90
+ staggerMs?: number;
91
+ };
92
+ type StroidConfig = {
93
+ logSink?: LogSink;
94
+ flush?: FlushConfig;
95
+ revalidateOnFocus?: RevalidateOnFocusConfig;
96
+ namespace?: string;
97
+ strictMissingFeatures?: boolean;
98
+ strictFeatures?: boolean;
99
+ assertRuntime?: boolean;
100
+ strictMutatorReturns?: boolean;
101
+ asyncAutoCreate?: boolean;
102
+ asyncCloneResult?: AsyncCloneMode;
103
+ /**
104
+ * Automatically generate correlation IDs for async fetch writes.
105
+ * Default: false.
106
+ */
107
+ autoCorrelationIds?: boolean;
108
+ /**
109
+ * Acknowledge loose store name typing and suppress dev warnings.
110
+ * Useful when you intentionally skip StoreStateMap augmentation.
111
+ */
112
+ acknowledgeLooseTypes?: boolean;
113
+ /**
114
+ * Max number of cached path validation verdicts per store.
115
+ * Default: 500.
116
+ */
117
+ pathCacheSize?: number;
118
+ defaultSnapshotMode?: SnapshotMode;
119
+ /**
120
+ * Alias for defaultSnapshotMode.
121
+ */
122
+ snapshotStrategy?: SnapshotMode;
123
+ /**
124
+ * Throw on async usage errors instead of returning null.
125
+ * Default: false (usage errors return null and call onError).
126
+ */
127
+ strictAsyncUsageErrors?: boolean;
128
+ middleware?: Array<(ctx: MiddlewareCtx) => StoreValue$1 | void>;
129
+ /**
130
+ * Allow hydrateStores to accept trusted snapshots without explicit opt-in.
131
+ * Default: false (hydration requires an explicit trust opt-in).
132
+ */
133
+ allowTrustedHydration?: boolean;
134
+ /**
135
+ * @deprecated Use allowTrustedHydration instead.
136
+ */
137
+ allowUntrustedHydration?: boolean;
138
+ /**
139
+ * Alias for allowTrustedHydration.
140
+ */
141
+ allowHydration?: boolean;
142
+ /**
143
+ * Optional custom mutator engine (e.g. Immer's produce) to enable structural sharing.
144
+ * You can pass the produce function directly or use "immer" after calling registerMutatorProduce().
145
+ */
146
+ mutatorProduce?: (<T>(base: T, recipe: (draft: T) => void) => T) | "immer";
147
+ /**
148
+ * When true, createSelector clones frozen state before proxy tracking.
149
+ * Default: true (safer for mutation-prone selectors in dev).
150
+ */
151
+ selectorCloneFrozen?: boolean;
152
+ };
153
+ declare const configureStroid: (next?: StroidConfig) => void;
154
+
155
+ type StoreTarget = StoreDefinition<string, unknown> | StoreKey<string, unknown> | StoreName;
156
+ declare const reactQueryKey: (storeName: StoreTarget, cacheKey?: string | number) => (string | number)[];
157
+ declare const createReactQueryFetcher: (storeName: StoreTarget, input: FetchInput, options?: FetchOptions) => () => Promise<unknown>;
158
+ declare const swrKey: (storeName: StoreTarget, cacheKey?: string | number) => (string | number)[];
159
+ declare const createSwrFetcher: (storeName: StoreTarget, input: FetchInput, options?: FetchOptions) => () => Promise<unknown>;
160
+
161
+ declare const query_createReactQueryFetcher: typeof createReactQueryFetcher;
162
+ declare const query_createSwrFetcher: typeof createSwrFetcher;
163
+ declare const query_reactQueryKey: typeof reactQueryKey;
164
+ declare const query_swrKey: typeof swrKey;
165
+ declare namespace query {
166
+ export { query_createReactQueryFetcher as createReactQueryFetcher, query_createSwrFetcher as createSwrFetcher, query_reactQueryKey as reactQueryKey, query_swrKey as swrKey };
167
+ }
168
+
169
+ export { HydrateSnapshotFor, HydrationResult, StoreDefinition, StoreKey, StoreName, StoreOptions, StoreStateMap, StoreValue, StrictStoreMap, WriteResult, configureStroid, hydrateStores, namespace, query as queryIntegrations, setStoreBatch, store };
package/dist/index.d.ts CHANGED
@@ -1,33 +1,169 @@
1
- export { createStore_alias_1 as createStore } from './_tsup-dts-rollup.js';
2
- export { createStoreStrict } from './_tsup-dts-rollup.js';
3
- export { setStore_alias_1 as setStore } from './_tsup-dts-rollup.js';
4
- export { setStoreBatch } from './_tsup-dts-rollup.js';
5
- export { getStore_alias_1 as getStore } from './_tsup-dts-rollup.js';
6
- export { deleteStore_alias_1 as deleteStore } from './_tsup-dts-rollup.js';
7
- export { resetStore } from './_tsup-dts-rollup.js';
8
- export { hasStore } from './_tsup-dts-rollup.js';
9
- export { hydrateStores } from './_tsup-dts-rollup.js';
10
- export { createComputed_alias_2 as createComputed } from './_tsup-dts-rollup.js';
11
- export { invalidateComputed_alias_2 as invalidateComputed } from './_tsup-dts-rollup.js';
12
- export { deleteComputed_alias_2 as deleteComputed } from './_tsup-dts-rollup.js';
13
- export { isComputedStore_alias_2 as isComputedStore } from './_tsup-dts-rollup.js';
14
- export { namespace } from './_tsup-dts-rollup.js';
15
- export { store } from './_tsup-dts-rollup.js';
16
- export { Path_alias_1 as Path } from './_tsup-dts-rollup.js';
17
- export { PathValue_alias_1 as PathValue } from './_tsup-dts-rollup.js';
18
- export { PartialDeep_alias_1 as PartialDeep } from './_tsup-dts-rollup.js';
19
- export { StoreDefinition_alias_1 as StoreDefinition } from './_tsup-dts-rollup.js';
20
- export { StoreValue_alias_1 as StoreValue } from './_tsup-dts-rollup.js';
21
- export { StoreKey_alias_1 as StoreKey } from './_tsup-dts-rollup.js';
22
- export { StoreName_alias_1 as StoreName } from './_tsup-dts-rollup.js';
23
- export { StateFor_alias_1 as StateFor } from './_tsup-dts-rollup.js';
24
- export { StoreStateMap_alias_1 as StoreStateMap } from './_tsup-dts-rollup.js';
25
- export { StrictStoreMap_alias_1 as StrictStoreMap } from './_tsup-dts-rollup.js';
26
- export { WriteResult_alias_1 as WriteResult } from './_tsup-dts-rollup.js';
27
- export { FeatureOptions } from './_tsup-dts-rollup.js';
28
- export { FeatureOptionsMap } from './_tsup-dts-rollup.js';
29
- export { PersistOptions } from './_tsup-dts-rollup.js';
30
- export { StoreOptions } from './_tsup-dts-rollup.js';
31
- export { SyncOptions } from './_tsup-dts-rollup.js';
32
- export { configureStroid_alias_1 as configureStroid } from './_tsup-dts-rollup.js';
33
- export { queryIntegrations } from './_tsup-dts-rollup.js';
1
+ import { H as HydrateSnapshotFor, S as StoreStateMap, f as StrictStoreMap, g as HydrationResult, b as StoreKey, a as StoreDefinition, W as WriteResult, d as StoreValue, c as StoreName } from './types.js';
2
+ export { h as HydrationFailure, P as PartialDeep, i as Path, j as PathValue, e as StateFor } from './types.js';
3
+ import { S as StoreOptions, b as SnapshotMode, M as MiddlewareCtx, a as StoreValue$1 } from './options.js';
4
+ export { F as FeatureOptions, c as FeatureOptionsMap, P as PersistOptions, d as SyncOptions } from './options.js';
5
+ export { c as createStore, a as createStoreStrict, d as deleteStore, g as getMetrics, b as getStore, h as hasStore, r as resetStore, s as setStore } from './index-internal.js';
6
+ import { N as NonFunction } from './utility.js';
7
+ export { getAsyncMetrics } from './async.js';
8
+ export { findColdStores, getStoreHealth } from './runtime-tools.js';
9
+ export { createComputed, deleteComputed, invalidateComputed, isComputedStore } from './computed.js';
10
+ import { F as FetchInput } from './cache.js';
11
+ import { F as FetchOptions } from './registry.js';
12
+ import './feature.js';
13
+
14
+ declare const setStoreBatch: (fn: () => unknown) => void;
15
+
16
+ type HydrateSnapshot = HydrateSnapshotFor<StoreStateMap & StrictStoreMap>;
17
+ type HydrateOptions<Snapshot extends object> = Partial<{
18
+ [K in keyof Snapshot]: StoreOptions<Snapshot[K]>;
19
+ }> & {
20
+ default?: StoreOptions;
21
+ };
22
+ type HydrationTrustBase<Snapshot extends object> = {
23
+ /**
24
+ * Explicitly trust this snapshot and allow hydration.
25
+ */
26
+ allowTrusted?: boolean;
27
+ /**
28
+ * Alias for allowTrusted.
29
+ */
30
+ allowHydration?: boolean;
31
+ /**
32
+ * @deprecated Use allowTrusted instead.
33
+ */
34
+ allowUntrusted?: boolean;
35
+ validate?: (snapshot: Snapshot) => boolean;
36
+ onValidationError?: (error: unknown, snapshot: Snapshot) => boolean;
37
+ };
38
+ type HydrationTrust<Snapshot extends object> = (HydrationTrustBase<Snapshot> & {
39
+ allowTrusted: true;
40
+ }) | (HydrationTrustBase<Snapshot> & {
41
+ allowHydration: true;
42
+ }) | (HydrationTrustBase<Snapshot> & {
43
+ allowUntrusted: true;
44
+ }) | (HydrationTrustBase<Snapshot> & {
45
+ validate: (snapshot: Snapshot) => boolean;
46
+ });
47
+ declare const hydrateStores: <Snapshot extends object = HydrateSnapshot>(snapshot: Snapshot, options: HydrateOptions<Snapshot> | undefined, trust: HydrationTrust<Snapshot>) => HydrationResult;
48
+
49
+ /**
50
+ * Helper to get an auto-completable, literal-typed store handle without creating it.
51
+ *
52
+ * Example:
53
+ * const user = store("user");
54
+ * setStore(user, "name", "Alex");
55
+ */
56
+ declare const store: <Name extends string, State = StoreValue>(name: Name) => StoreKey<Name, State>;
57
+ declare const namespace: (ns: string) => {
58
+ store: <Name extends string, State = unknown>(name: Name) => StoreKey<Name, State>;
59
+ create: <Name extends string, State>(name: Name, data: NonFunction<State>, options?: StoreOptions<State>) => StoreDefinition<string, State> | undefined;
60
+ createStrict: <Name extends string, State>(name: Name, data: NonFunction<State>, options?: StoreOptions<State>) => StoreDefinition<string, State>;
61
+ set: (name: any, ...rest: any[]) => any;
62
+ get: (name: any, ...rest: any[]) => any;
63
+ delete: (name: string) => void;
64
+ reset: (name: string) => WriteResult;
65
+ };
66
+
67
+ /**
68
+ * @module internals/config
69
+ *
70
+ * LAYER: Internal subsystem
71
+ * OWNS: Module-level behavior and exports for internals/config.
72
+ *
73
+ * Consumers: Internal imports and public API.
74
+ */
75
+
76
+ type LogSink = {
77
+ log?: (msg: string, meta?: Record<string, unknown>) => void;
78
+ warn?: (msg: string, meta?: Record<string, unknown>) => void;
79
+ critical?: (msg: string, meta?: Record<string, unknown>) => void;
80
+ };
81
+ type AsyncCloneMode = "none" | "shallow" | "deep";
82
+ type FlushConfig = {
83
+ chunkSize?: number;
84
+ chunkDelayMs?: number;
85
+ priorityStores?: string[];
86
+ };
87
+ type RevalidateOnFocusConfig = {
88
+ debounceMs?: number;
89
+ maxConcurrent?: number;
90
+ staggerMs?: number;
91
+ };
92
+ type StroidConfig = {
93
+ logSink?: LogSink;
94
+ flush?: FlushConfig;
95
+ revalidateOnFocus?: RevalidateOnFocusConfig;
96
+ namespace?: string;
97
+ strictMissingFeatures?: boolean;
98
+ strictFeatures?: boolean;
99
+ assertRuntime?: boolean;
100
+ strictMutatorReturns?: boolean;
101
+ asyncAutoCreate?: boolean;
102
+ asyncCloneResult?: AsyncCloneMode;
103
+ /**
104
+ * Automatically generate correlation IDs for async fetch writes.
105
+ * Default: false.
106
+ */
107
+ autoCorrelationIds?: boolean;
108
+ /**
109
+ * Acknowledge loose store name typing and suppress dev warnings.
110
+ * Useful when you intentionally skip StoreStateMap augmentation.
111
+ */
112
+ acknowledgeLooseTypes?: boolean;
113
+ /**
114
+ * Max number of cached path validation verdicts per store.
115
+ * Default: 500.
116
+ */
117
+ pathCacheSize?: number;
118
+ defaultSnapshotMode?: SnapshotMode;
119
+ /**
120
+ * Alias for defaultSnapshotMode.
121
+ */
122
+ snapshotStrategy?: SnapshotMode;
123
+ /**
124
+ * Throw on async usage errors instead of returning null.
125
+ * Default: false (usage errors return null and call onError).
126
+ */
127
+ strictAsyncUsageErrors?: boolean;
128
+ middleware?: Array<(ctx: MiddlewareCtx) => StoreValue$1 | void>;
129
+ /**
130
+ * Allow hydrateStores to accept trusted snapshots without explicit opt-in.
131
+ * Default: false (hydration requires an explicit trust opt-in).
132
+ */
133
+ allowTrustedHydration?: boolean;
134
+ /**
135
+ * @deprecated Use allowTrustedHydration instead.
136
+ */
137
+ allowUntrustedHydration?: boolean;
138
+ /**
139
+ * Alias for allowTrustedHydration.
140
+ */
141
+ allowHydration?: boolean;
142
+ /**
143
+ * Optional custom mutator engine (e.g. Immer's produce) to enable structural sharing.
144
+ * You can pass the produce function directly or use "immer" after calling registerMutatorProduce().
145
+ */
146
+ mutatorProduce?: (<T>(base: T, recipe: (draft: T) => void) => T) | "immer";
147
+ /**
148
+ * When true, createSelector clones frozen state before proxy tracking.
149
+ * Default: true (safer for mutation-prone selectors in dev).
150
+ */
151
+ selectorCloneFrozen?: boolean;
152
+ };
153
+ declare const configureStroid: (next?: StroidConfig) => void;
154
+
155
+ type StoreTarget = StoreDefinition<string, unknown> | StoreKey<string, unknown> | StoreName;
156
+ declare const reactQueryKey: (storeName: StoreTarget, cacheKey?: string | number) => (string | number)[];
157
+ declare const createReactQueryFetcher: (storeName: StoreTarget, input: FetchInput, options?: FetchOptions) => () => Promise<unknown>;
158
+ declare const swrKey: (storeName: StoreTarget, cacheKey?: string | number) => (string | number)[];
159
+ declare const createSwrFetcher: (storeName: StoreTarget, input: FetchInput, options?: FetchOptions) => () => Promise<unknown>;
160
+
161
+ declare const query_createReactQueryFetcher: typeof createReactQueryFetcher;
162
+ declare const query_createSwrFetcher: typeof createSwrFetcher;
163
+ declare const query_reactQueryKey: typeof reactQueryKey;
164
+ declare const query_swrKey: typeof swrKey;
165
+ declare namespace query {
166
+ export { query_createReactQueryFetcher as createReactQueryFetcher, query_createSwrFetcher as createSwrFetcher, query_reactQueryKey as reactQueryKey, query_swrKey as swrKey };
167
+ }
168
+
169
+ export { HydrateSnapshotFor, HydrationResult, StoreDefinition, StoreKey, StoreName, StoreOptions, StoreStateMap, StoreValue, StrictStoreMap, WriteResult, configureStroid, hydrateStores, namespace, query as queryIntegrations, setStoreBatch, store };