stroid 0.1.4-beta.0 → 0.1.4

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 (106) hide show
  1. package/CHANGELOG.md +313 -288
  2. package/README.md +1017 -117
  3. package/dist/async.js +1 -33
  4. package/dist/chunk-645IESIU.js +2 -0
  5. package/dist/chunk-6ELWGQ4Q.js +2 -0
  6. package/dist/chunk-BW32TJGE.js +13 -0
  7. package/dist/chunk-FOQKGHPS.js +26 -0
  8. package/dist/chunk-KQCSFGHJ.js +2 -0
  9. package/dist/chunk-M2NJVI36.js +2 -0
  10. package/dist/chunk-PVATWAY4.js +2 -0
  11. package/dist/chunk-X3JR32JD.js +2 -0
  12. package/dist/chunk-YU5GMPCC.js +2 -0
  13. package/dist/computed.js +1 -12
  14. package/dist/core.js +1 -22
  15. package/dist/devtools.js +1 -1
  16. package/dist/feature.js +1 -1
  17. package/dist/helpers.js +1 -22
  18. package/dist/index.js +1 -35
  19. package/dist/install.js +1 -1
  20. package/dist/options.d.ts +1 -1
  21. package/dist/persist.js +1 -1
  22. package/dist/psr.d.ts +14 -4
  23. package/dist/psr.js +1 -18
  24. package/dist/react/index.js +5 -36
  25. package/dist/registry.d.ts +1 -0
  26. package/dist/runtime-admin.js +1 -1
  27. package/dist/runtime-tools.js +1 -3
  28. package/dist/selectors.js +1 -1
  29. package/dist/server.d.ts +1 -0
  30. package/dist/server.js +1 -12
  31. package/dist/store-registry.d.ts +2 -0
  32. package/dist/sync.js +1 -1
  33. package/dist/testing.js +1 -22
  34. package/dist/types/adapters/options.d.ts +335 -0
  35. package/dist/types/async/cache.d.ts +40 -0
  36. package/dist/types/async/clone.d.ts +10 -0
  37. package/dist/types/async/errors.d.ts +3 -0
  38. package/dist/types/async/fetch.d.ts +37 -0
  39. package/dist/types/async/inflight.d.ts +30 -0
  40. package/dist/types/async/rate.d.ts +5 -0
  41. package/dist/types/async/registry.d.ts +117 -0
  42. package/dist/types/async/request.d.ts +11 -0
  43. package/dist/types/async/retry.d.ts +10 -0
  44. package/dist/types/async.d.ts +10 -0
  45. package/dist/types/computed/computed-graph.d.ts +33 -0
  46. package/dist/types/computed/index.d.ts +21 -0
  47. package/dist/types/computed/types.d.ts +40 -0
  48. package/dist/types/config.d.ts +10 -0
  49. package/dist/types/core/index.d.ts +11 -0
  50. package/dist/types/core/lifecycle-hooks.d.ts +16 -0
  51. package/dist/types/core/runtime-patch.d.ts +67 -0
  52. package/dist/types/core/store-admin-impl.d.ts +9 -0
  53. package/dist/types/core/store-admin.d.ts +9 -0
  54. package/dist/types/core/store-core.d.ts +13 -0
  55. package/dist/types/core/store-create.d.ts +16 -0
  56. package/dist/types/core/store-hydrate-impl.d.ts +35 -0
  57. package/dist/types/core/store-hydrate.d.ts +9 -0
  58. package/dist/types/core/store-lifecycle/hooks.d.ts +20 -0
  59. package/dist/types/core/store-lifecycle/identity.d.ts +23 -0
  60. package/dist/types/core/store-lifecycle/registry.d.ts +54 -0
  61. package/dist/types/core/store-lifecycle/types.d.ts +67 -0
  62. package/dist/types/core/store-lifecycle/validation.d.ts +53 -0
  63. package/dist/types/core/store-name.d.ts +28 -0
  64. package/dist/types/core/store-notify.d.ts +13 -0
  65. package/dist/types/core/store-read.d.ts +18 -0
  66. package/dist/types/core/store-registry.d.ts +115 -0
  67. package/dist/types/core/store-replace-impl.d.ts +11 -0
  68. package/dist/types/core/store-replace.d.ts +9 -0
  69. package/dist/types/core/store-set-impl.d.ts +13 -0
  70. package/dist/types/core/store-set.d.ts +9 -0
  71. package/dist/types/core/store-shared/core.d.ts +13 -0
  72. package/dist/types/core/store-shared/notify.d.ts +12 -0
  73. package/dist/types/core/store-transaction.d.ts +28 -0
  74. package/dist/types/core/store-write-shared.d.ts +25 -0
  75. package/dist/types/core/store-write.d.ts +13 -0
  76. package/dist/types/features/feature-registry.d.ts +91 -0
  77. package/dist/types/features/lifecycle.d.ts +40 -0
  78. package/dist/types/index.d.ts +17 -0
  79. package/dist/types/integrations/query.d.ts +8 -0
  80. package/dist/types/internals/computed-order.d.ts +3 -0
  81. package/dist/types/internals/config.d.ts +116 -0
  82. package/dist/types/internals/diagnostics.d.ts +21 -0
  83. package/dist/types/internals/reporting.d.ts +9 -0
  84. package/dist/types/internals/store-admin.d.ts +7 -0
  85. package/dist/types/internals/store-ops.d.ts +13 -0
  86. package/dist/types/internals/test-reset.d.ts +2 -0
  87. package/dist/types/internals/write-context.d.ts +20 -0
  88. package/dist/types/notification/delivery.d.ts +3 -0
  89. package/dist/types/notification/index.d.ts +10 -0
  90. package/dist/types/notification/metrics.d.ts +12 -0
  91. package/dist/types/notification/priority.d.ts +9 -0
  92. package/dist/types/notification/scheduler.d.ts +11 -0
  93. package/dist/types/notification/snapshot.d.ts +8 -0
  94. package/dist/types/runtime-admin/index.d.ts +2 -0
  95. package/dist/types/runtime-tools/index.d.ts +63 -0
  96. package/dist/types/store.d.ts +16 -0
  97. package/dist/types/types/utility.d.ts +17 -0
  98. package/dist/types/utils/clone.d.ts +4 -0
  99. package/dist/types/utils/devfreeze.d.ts +2 -0
  100. package/dist/types/utils/hash.d.ts +8 -0
  101. package/dist/types/utils/path.d.ts +5 -0
  102. package/dist/types/utils/validation.d.ts +14 -0
  103. package/dist/types/utils.d.ts +13 -0
  104. package/dist/types.d.ts +1 -1
  105. package/package.json +50 -37
  106. package/dist/tsdoc-metadata.json +0 -11
@@ -0,0 +1,115 @@
1
+ /**
2
+ * @module store-registry
3
+ *
4
+ * LAYER: Store runtime
5
+ * OWNS: Module-level behavior and exports for store-registry.
6
+ *
7
+ * Consumers: Internal imports and public API.
8
+ */
9
+ import { type FeatureName, type StoreFeatureMeta, type StoreFeatureRuntime } from "../features/feature-registry.js";
10
+ import type { RuntimePatch } from "./runtime-patch.js";
11
+ import type { AsyncRegistry } from "../async/registry.js";
12
+ import type { ComputedClassification } from "../computed/types.js";
13
+ export type RegistryStoreValue = unknown;
14
+ export type RegistrySubscriber = (value: RegistryStoreValue | null) => void;
15
+ export type RegistrySnapshotEntry = {
16
+ version: number;
17
+ snapshot: RegistryStoreValue | null;
18
+ source?: RegistryStoreValue | null;
19
+ mode?: "deep" | "shallow" | "ref";
20
+ };
21
+ export type StoreLifecycleEvent = {
22
+ type: "created";
23
+ name: string;
24
+ isGlobal: boolean;
25
+ isTemp: boolean;
26
+ } | {
27
+ type: "deleted";
28
+ name: string;
29
+ };
30
+ export type StoreLifecycleListener = (event: StoreLifecycleEvent) => void;
31
+ export type TransactionState = {
32
+ depth: number;
33
+ pending: Array<() => void>;
34
+ stagedValues: Map<string, RegistryStoreValue>;
35
+ snapshotCache: Map<string, TransactionSnapshotEntry>;
36
+ runtimePatches: RuntimePatch[];
37
+ failed: boolean;
38
+ error?: Error;
39
+ };
40
+ type TransactionSnapshotMode = "deep" | "shallow" | "ref";
41
+ type TransactionSnapshotEntry = {
42
+ source: RegistryStoreValue | null | undefined;
43
+ snapshot: RegistryStoreValue | null;
44
+ mode: TransactionSnapshotMode;
45
+ };
46
+ export type ComputedEntry = {
47
+ deps: string[];
48
+ compute: (...args: unknown[]) => unknown;
49
+ stale: boolean;
50
+ classification: ComputedClassification;
51
+ hasLastOutput: boolean;
52
+ lastOutput: unknown;
53
+ };
54
+ export type NotifyState = {
55
+ pendingNotifications: Set<string>;
56
+ pendingBuffer: string[];
57
+ orderedNames: string[];
58
+ subscriberBuffer: RegistrySubscriber[];
59
+ notifyScheduled: boolean;
60
+ batchDepth: number;
61
+ flushId: number;
62
+ isFlushing: boolean;
63
+ };
64
+ export type RegistryScope = "default" | "request";
65
+ export type StoreRegistry = {
66
+ scope: RegistryScope;
67
+ stores: Record<string, RegistryStoreValue>;
68
+ subscribers: Record<string, Set<RegistrySubscriber>>;
69
+ initialStates: Record<string, RegistryStoreValue>;
70
+ initialFactories: Record<string, (() => RegistryStoreValue) | undefined>;
71
+ metaEntries: Record<string, StoreFeatureMeta>;
72
+ snapshotCache: Record<string, RegistrySnapshotEntry>;
73
+ featureRuntimes: Map<FeatureName, StoreFeatureRuntime>;
74
+ deletingStores: Set<string>;
75
+ computedEntries: Record<string, ComputedEntry>;
76
+ computedDependents: Record<string, Set<string>>;
77
+ computedCleanups: Map<string, () => void>;
78
+ lastRuntimePatches: RuntimePatch[];
79
+ transaction: TransactionState;
80
+ async: AsyncRegistry;
81
+ notify: NotifyState;
82
+ lifecycleListener: StoreLifecycleListener | null;
83
+ };
84
+ export declare const initializeRegistryFeatureRuntimes: (registry: StoreRegistry) => void;
85
+ export declare const normalizeStoreRegistryScope: (scope: string) => string;
86
+ export declare const defaultRegistryScope: string;
87
+ export declare const getDefaultStoreRegistry: () => StoreRegistry;
88
+ export declare const setRegistryScope: (scope: string) => void;
89
+ export declare const clearRegistryScopeOverrideForTests: () => void;
90
+ export declare const createTransactionState: () => TransactionState;
91
+ export declare const createStoreRegistry: (scope?: RegistryScope) => StoreRegistry;
92
+ export declare const getStoreRegistry: (scope: string) => StoreRegistry;
93
+ export declare const hasStoreEntry: (registry: StoreRegistry, name: string) => boolean;
94
+ export declare const isStoreDeleting: (registry: StoreRegistry, name: string) => boolean;
95
+ export declare const clearStoreRegistries: (registry: StoreRegistry) => void;
96
+ export declare const setLifecycleListener: (registry: StoreRegistry, listener: StoreLifecycleListener | null) => void;
97
+ export declare const emitLifecycleEvent: (registry: StoreRegistry, event: StoreLifecycleEvent) => void;
98
+ export declare const resetAllStoreRegistriesForTests: () => void;
99
+ export type CarrierContext = Record<string, unknown>;
100
+ export interface CarrierRunner {
101
+ run<T>(carrier: CarrierContext, fn: () => T): T;
102
+ get(): CarrierContext | null;
103
+ }
104
+ export declare const injectCarrierRunner: (runner: CarrierRunner) => void;
105
+ export declare const getRequestCarrier: () => CarrierContext | null;
106
+ export interface RegistryRunner {
107
+ run<T>(registry: StoreRegistry, fn: () => T): T;
108
+ get(): StoreRegistry | null;
109
+ enterWith?: (registry: StoreRegistry) => void;
110
+ }
111
+ export declare const injectRegistryRunner: (runner: RegistryRunner) => void;
112
+ export declare const runWithRegistry: <T>(registry: StoreRegistry, fn: () => T) => T;
113
+ export declare const getActiveStoreRegistry: (fallback?: StoreRegistry) => StoreRegistry;
114
+ export declare const enterRegistry: (registry: StoreRegistry) => void;
115
+ export {};
@@ -0,0 +1,11 @@
1
+ import type { StoreDefinition, StoreKey, StoreName, StateFor, WriteResult } from "./store-lifecycle/types.js";
2
+ import type { StoreRegistry } from "./store-registry.js";
3
+ import type { WriteContext } from "../internals/write-context.js";
4
+ import { type CommitAction } from "./store-write-shared.js";
5
+ export declare function replaceStore<Name extends string, State>(name: StoreDefinition<Name, State>, value: State): WriteResult;
6
+ export declare function replaceStore<Name extends string, State>(name: StoreKey<Name, State>, value: State): WriteResult;
7
+ export declare function replaceStore<Name extends StoreName>(name: Name, value: StateFor<Name>): WriteResult;
8
+ export declare const replaceStoreState: (registry: StoreRegistry, name: string, data: unknown, action?: CommitAction, context?: WriteContext | null) => {
9
+ ok: boolean;
10
+ reason?: string;
11
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @module store-replace
3
+ *
4
+ * LAYER: Store runtime
5
+ * OWNS: Public replaceStore exports.
6
+ *
7
+ * Consumers: store-write barrel.
8
+ */
9
+ export { replaceStore } from "./store-replace-impl.js";
@@ -0,0 +1,13 @@
1
+ import type { PartialDeep, Path, PathValue, StoreDefinition, StoreValue, StoreKey, StoreName, StateFor, WriteResult } from "./store-lifecycle/types.js";
2
+ import type { WriteContext } from "../internals/write-context.js";
3
+ type KeyOrData = StoreValue | string | string[] | Record<string, unknown> | ((draft: any) => void);
4
+ type IsStoreNameLoose = string extends StoreName ? true : false;
5
+ type StoreUpdate<State> = State | Partial<State> | PartialDeep<State> | ((draft: State) => void);
6
+ type StoreTarget<Name extends string = string, State = StoreValue> = StoreDefinition<Name, State> | StoreKey<Name, State> | StoreName;
7
+ 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[]));
8
+ 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));
9
+ 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>));
10
+ export declare function setStore<T extends StoreTarget, P extends StorePathForTarget<T>>(name: T, path: P, value: StorePathValueForTarget<T, P>): WriteResult;
11
+ export declare function setStore<T extends StoreTarget>(name: T, update: StoreUpdateForTarget<T>): WriteResult;
12
+ export declare const setStoreWithContext: (name: string | StoreDefinition<string, StoreValue>, keyOrData: KeyOrData, value: unknown, context: WriteContext | null) => WriteResult;
13
+ export {};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @module store-set
3
+ *
4
+ * LAYER: Store runtime
5
+ * OWNS: Public setStore exports.
6
+ *
7
+ * Consumers: store-write barrel.
8
+ */
9
+ export { setStore, setStoreWithContext } from "./store-set-impl.js";
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @module store-shared/core
3
+ *
4
+ * LAYER: Shared types
5
+ * OWNS: Minimal interfaces shared across layers.
6
+ *
7
+ * Consumers: Internal modules (async-cache, adapters).
8
+ */
9
+ export interface IStoreCore<T = any> {
10
+ get(path?: string): T | null;
11
+ set(path: string, value: any): void;
12
+ subscribe(cb: (val: T | null) => void): () => void;
13
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @module store-shared/notify
3
+ *
4
+ * LAYER: Shared types
5
+ * OWNS: Notification handler indirection for layer decoupling.
6
+ *
7
+ * Consumers: store-write, store-create, store-notify.
8
+ */
9
+ type NotifyHandler = (name: string) => void;
10
+ export declare const registerNotifyHandler: (handler: NotifyHandler | null) => (() => void);
11
+ export declare const notifyStore: (name: string) => void;
12
+ export {};
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @module store-transaction
3
+ *
4
+ * LAYER: Store runtime
5
+ * OWNS: Module-level behavior and exports for store-transaction.
6
+ *
7
+ * Consumers: Internal imports and public API.
8
+ */
9
+ import type { StoreValue } from "./store-lifecycle/types.js";
10
+ import type { RuntimePatch } from "./runtime-patch.js";
11
+ import { type StoreRegistry, type TransactionState } from "./store-registry.js";
12
+ export type TransactionRunner = {
13
+ run: <T>(state: TransactionState, fn: () => T) => T;
14
+ get: () => TransactionState | null;
15
+ enterWith?: (state: TransactionState) => void;
16
+ };
17
+ export declare const injectTransactionRunner: (runner: TransactionRunner | null) => void;
18
+ export declare const beginTransaction: (registry?: StoreRegistry) => StoreRegistry;
19
+ export declare const isTransactionActive: () => boolean;
20
+ export declare const markTransactionFailed: (err?: unknown, registry?: StoreRegistry) => void;
21
+ export declare const registerTransactionCommit: (fn: () => void) => void;
22
+ export declare const stageTransactionValue: (name: string, value: StoreValue) => void;
23
+ export declare const stageTransactionPatches: (patches: readonly RuntimePatch[]) => void;
24
+ export declare const getStagedTransactionValue: (name: string) => {
25
+ has: boolean;
26
+ value: StoreValue | undefined;
27
+ };
28
+ export declare const endTransaction: (err?: unknown, registry?: StoreRegistry) => Error | null;
@@ -0,0 +1,25 @@
1
+ import { type WriteContext } from "../internals/write-context.js";
2
+ import type { StoreRegistry } from "./store-registry.js";
3
+ import type { StoreValue } from "./store-lifecycle/types.js";
4
+ import { type RuntimePatch } from "./runtime-patch.js";
5
+ export type CommitAction = "set" | "reset" | "hydrate" | "replace";
6
+ export type CommitHookLabel = "onSet" | "onReset";
7
+ export type CommitMetricsUpdate = {
8
+ resetElapsedMs?: number;
9
+ };
10
+ export type CommitArgs = {
11
+ name: string;
12
+ prev: StoreValue;
13
+ next: StoreValue;
14
+ action: CommitAction;
15
+ hookLabel: CommitHookLabel;
16
+ logMessage: string;
17
+ context?: WriteContext | null;
18
+ runtimePatches?: readonly RuntimePatch[];
19
+ metricsUpdate?: CommitMetricsUpdate;
20
+ };
21
+ export declare const clearSlowMutatorWarnings: () => void;
22
+ export declare const forgetSlowMutatorWarning: (storeName: string) => void;
23
+ export declare const maybeWarnSlowMutator: (storeName: string, elapsedMs: number) => void;
24
+ export declare const resolveWriteContext: (context?: WriteContext | null) => WriteContext | null;
25
+ export declare const stageOrCommitUpdate: (registry: StoreRegistry, args: CommitArgs) => void;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @module store-write
3
+ *
4
+ * LAYER: Store runtime
5
+ * OWNS: Public write API surface (barrel).
6
+ *
7
+ * Consumers: Internal imports and public API.
8
+ */
9
+ import "./store-notify.js";
10
+ export { setStore, setStoreWithContext } from "./store-set.js";
11
+ export { replaceStore } from "./store-replace.js";
12
+ export { hydrateStores } from "./store-hydrate.js";
13
+ export { deleteStore, resetStore, clearAllStores, _hardResetAllStoresForTest, } from "./store-admin.js";
@@ -0,0 +1,91 @@
1
+ /**
2
+ * @module feature-registry
3
+ *
4
+ * LAYER: Module
5
+ * OWNS: Module-level behavior and exports for feature-registry.
6
+ *
7
+ * Consumers: Internal imports and public API.
8
+ */
9
+ import type { NormalizedOptions, StoreValue } from "../adapters/options.js";
10
+ import type { TraceContext } from "../types/utility.js";
11
+ export type BuiltInFeatureName = "persist" | "sync" | "devtools";
12
+ export type FeatureName = BuiltInFeatureName | (string & {});
13
+ export interface FeatureMetrics {
14
+ notifyCount: number;
15
+ totalNotifyMs: number;
16
+ lastNotifyMs: number;
17
+ resetCount: number;
18
+ totalResetMs: number;
19
+ lastResetMs: number;
20
+ }
21
+ export interface StoreFeatureMeta {
22
+ createdAt: string;
23
+ updatedAt: string;
24
+ updatedAtMs: number;
25
+ updateCount: number;
26
+ version: number;
27
+ metrics: FeatureMetrics;
28
+ options: NormalizedOptions;
29
+ readCount: number;
30
+ lastReadAt: string | null;
31
+ lastReadAtMs: number | null;
32
+ lastCorrelationId: string | null;
33
+ lastCorrelationAt: string | null;
34
+ lastCorrelationAtMs: number | null;
35
+ lastTraceContext: TraceContext | null;
36
+ }
37
+ export interface FeatureHookContext {
38
+ name: string;
39
+ options: NormalizedOptions;
40
+ getMeta: () => StoreFeatureMeta | undefined;
41
+ getStoreValue: () => StoreValue;
42
+ getAllStores: () => Record<string, StoreValue>;
43
+ getInitialState: () => StoreValue;
44
+ hasStore: () => boolean;
45
+ setStoreValue: (value: StoreValue) => void;
46
+ applyFeatureState: (value: StoreValue, updatedAtMs?: number) => void;
47
+ notify: () => void;
48
+ reportStoreError: (message: string) => void;
49
+ warn: (message: string) => void;
50
+ warnAlways: (message: string) => void;
51
+ log: (message: string) => void;
52
+ hashState: (value: unknown) => number;
53
+ deepClone: <T>(value: T) => T;
54
+ sanitize: (value: unknown) => unknown;
55
+ validate: (next: StoreValue) => {
56
+ ok: boolean;
57
+ value?: StoreValue;
58
+ };
59
+ isDev: () => boolean;
60
+ }
61
+ /** @deprecated Use FeatureHookContext instead. */
62
+ export type BaseFeatureContext = FeatureHookContext;
63
+ export type FeatureCreateContext<Ext extends object = {}> = FeatureHookContext & Ext;
64
+ export type FeatureWriteContext<Ext extends object = {}> = FeatureHookContext & Ext & {
65
+ action: string;
66
+ prev: StoreValue;
67
+ next: StoreValue;
68
+ };
69
+ export type FeatureDeleteContext<Ext extends object = {}> = FeatureHookContext & Ext & {
70
+ prev: StoreValue;
71
+ };
72
+ export interface DevtoolsFeatureApi {
73
+ getHistory?: (name: string, limit?: number) => unknown[];
74
+ clearHistory?: (name?: string) => void;
75
+ getPersistQueueDepth?: (name: string) => number;
76
+ }
77
+ export interface StoreFeatureRuntime<Ext extends object = {}> {
78
+ onStoreCreate?: (ctx: FeatureCreateContext<Ext>) => void;
79
+ onStoreWrite?: (ctx: FeatureWriteContext<Ext>) => void;
80
+ beforeStoreDelete?: (ctx: FeatureDeleteContext<Ext>) => void;
81
+ afterStoreDelete?: (ctx: FeatureDeleteContext<Ext>) => void;
82
+ resetAll?: () => void;
83
+ api?: DevtoolsFeatureApi;
84
+ }
85
+ export type StoreFeatureFactory<Ext extends object = {}> = () => StoreFeatureRuntime<Ext>;
86
+ export declare const registerStoreFeature: <Ext extends object = {}>(name: FeatureName, factory: StoreFeatureFactory<Ext>) => void;
87
+ export declare const hasRegisteredStoreFeature: (name: FeatureName) => boolean;
88
+ export declare const getStoreFeatureFactory: (name: FeatureName) => StoreFeatureFactory<any> | undefined;
89
+ export declare const getRegisteredFeatureNames: () => FeatureName[];
90
+ export declare const setFeatureRegistrationHook: (hook: ((name: FeatureName, factory: StoreFeatureFactory<any>) => void) | null) => void;
91
+ export declare const resetRegisteredStoreFeaturesForTests: () => void;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @module features/lifecycle
3
+ *
4
+ * LAYER: Feature runtime
5
+ * OWNS: Module-level behavior and exports for features/lifecycle.
6
+ *
7
+ * Consumers: Internal imports and public API.
8
+ */
9
+ import type { StoreValue } from "../adapters/options.js";
10
+ export declare const MIDDLEWARE_ABORT: unique symbol;
11
+ export type LifecycleIssueReporter = (message: string, visibility?: "dev" | "always") => void;
12
+ export declare const runMiddleware: ({ name, payload, middlewares, reportIssue, warn, }: {
13
+ name: string;
14
+ payload: {
15
+ action: string;
16
+ prev: StoreValue;
17
+ next: StoreValue;
18
+ path: unknown;
19
+ correlationId?: string;
20
+ traceContext?: import("../types/utility.js").TraceContext;
21
+ };
22
+ middlewares: Array<(ctx: {
23
+ action: string;
24
+ name: string;
25
+ prev: StoreValue;
26
+ next: StoreValue;
27
+ path: unknown;
28
+ correlationId?: string;
29
+ traceContext?: import("../types/utility.js").TraceContext;
30
+ }) => StoreValue | void>;
31
+ reportIssue: LifecycleIssueReporter;
32
+ warn: (message: string) => void;
33
+ }) => StoreValue | typeof MIDDLEWARE_ABORT;
34
+ export declare const runStoreHook: ({ name, label, fn, args, reportIssue, }: {
35
+ name: string;
36
+ label: "onCreate" | "onSet" | "onReset" | "onDelete";
37
+ fn: ((...args: any[]) => void) | undefined;
38
+ args: any[];
39
+ reportIssue: LifecycleIssueReporter;
40
+ }) => void;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @module index
3
+ *
4
+ * LAYER: Public API
5
+ * OWNS: Module-level behavior and exports for index.
6
+ *
7
+ * Consumers: Internal imports and public API.
8
+ */
9
+ export { createStore, createStoreStrict, setStore, setStoreBatch, getStore, deleteStore, resetStore, hasStore, hydrateStores, } from "./store.js";
10
+ export { getMetrics } from "./core/store-read.js";
11
+ export { getAsyncMetrics } from "./async/fetch.js";
12
+ export { getStoreHealth, findColdStores } from "./runtime-tools/index.js";
13
+ export { createComputed, invalidateComputed, deleteComputed, isComputedStore, } from "./computed/index.js";
14
+ export { namespace, store } from "./store.js";
15
+ export type { Path, PathValue, PartialDeep, HydrateSnapshotFor, HydrationFailure, HydrationResult, StoreDefinition, StoreValue, StoreKey, StoreName, StateFor, StoreStateMap, StrictStoreMap, WriteResult, FeatureOptions, FeatureOptionsMap, PersistOptions, StoreOptions, SyncOptions, } from "./store.js";
16
+ export { configureStroid } from "./config.js";
17
+ export * as queryIntegrations from "./integrations/query.js";
@@ -0,0 +1,8 @@
1
+ import type { FetchInput, FetchOptions } from "../async/cache.js";
2
+ import type { StoreDefinition, StoreKey, StoreName } from "../core/store-lifecycle/types.js";
3
+ type StoreTarget = StoreDefinition<string, unknown> | StoreKey<string, unknown> | StoreName;
4
+ export declare const reactQueryKey: (storeName: StoreTarget, cacheKey?: string | number) => (string | number)[];
5
+ export declare const createReactQueryFetcher: (storeName: StoreTarget, input: FetchInput, options?: FetchOptions) => () => Promise<unknown>;
6
+ export declare const swrKey: (storeName: StoreTarget, cacheKey?: string | number) => (string | number)[];
7
+ export declare const createSwrFetcher: (storeName: StoreTarget, input: FetchInput, options?: FetchOptions) => () => Promise<unknown>;
8
+ export {};
@@ -0,0 +1,3 @@
1
+ export type ComputedOrderResolver = (names: string[]) => string[];
2
+ export declare const setComputedOrderResolver: (next: ComputedOrderResolver | null) => void;
3
+ export declare const getComputedOrder: (names: string[]) => string[];
@@ -0,0 +1,116 @@
1
+ /**
2
+ * @module internals/config
3
+ *
4
+ * LAYER: Internal subsystem
5
+ * OWNS: Module-level behavior and exports for internals/config.
6
+ *
7
+ * Consumers: Internal imports and public API.
8
+ */
9
+ import type { SnapshotMode, MiddlewareCtx, StoreValue } from "../adapters/options.js";
10
+ export type LogSink = {
11
+ log?: (msg: string, meta?: Record<string, unknown>) => void;
12
+ warn?: (msg: string, meta?: Record<string, unknown>) => void;
13
+ critical?: (msg: string, meta?: Record<string, unknown>) => void;
14
+ };
15
+ export type AsyncCloneMode = "none" | "shallow" | "deep";
16
+ export type FlushConfig = {
17
+ chunkSize?: number;
18
+ chunkDelayMs?: number;
19
+ priorityStores?: string[];
20
+ };
21
+ export type RevalidateOnFocusConfig = {
22
+ debounceMs?: number;
23
+ maxConcurrent?: number;
24
+ staggerMs?: number;
25
+ };
26
+ export type StroidConfig = {
27
+ logSink?: LogSink;
28
+ flush?: FlushConfig;
29
+ revalidateOnFocus?: RevalidateOnFocusConfig;
30
+ namespace?: string;
31
+ strictMissingFeatures?: boolean;
32
+ strictFeatures?: boolean;
33
+ assertRuntime?: boolean;
34
+ strictMutatorReturns?: boolean;
35
+ asyncAutoCreate?: boolean;
36
+ asyncCloneResult?: AsyncCloneMode;
37
+ /**
38
+ * Automatically generate correlation IDs for async fetch writes.
39
+ * Default: false.
40
+ */
41
+ autoCorrelationIds?: boolean;
42
+ /**
43
+ * Acknowledge loose store name typing and suppress dev warnings.
44
+ * Useful when you intentionally skip StoreStateMap augmentation.
45
+ */
46
+ acknowledgeLooseTypes?: boolean;
47
+ /**
48
+ * Max number of cached path validation verdicts per store.
49
+ * Default: 500.
50
+ */
51
+ pathCacheSize?: number;
52
+ defaultSnapshotMode?: SnapshotMode;
53
+ /**
54
+ * Alias for defaultSnapshotMode.
55
+ */
56
+ snapshotStrategy?: SnapshotMode;
57
+ /**
58
+ * Throw on async usage errors instead of returning null.
59
+ * Default: false (usage errors return null and call onError).
60
+ */
61
+ strictAsyncUsageErrors?: boolean;
62
+ middleware?: Array<(ctx: MiddlewareCtx) => StoreValue | void>;
63
+ /**
64
+ * Allow hydrateStores to accept trusted snapshots without explicit opt-in.
65
+ * Default: false (hydration requires an explicit trust opt-in).
66
+ */
67
+ allowTrustedHydration?: boolean;
68
+ /**
69
+ * @deprecated Use allowTrustedHydration instead.
70
+ */
71
+ allowUntrustedHydration?: boolean;
72
+ /**
73
+ * Alias for allowTrustedHydration.
74
+ */
75
+ allowHydration?: boolean;
76
+ /**
77
+ * Optional custom mutator engine (e.g. Immer's produce) to enable structural sharing.
78
+ * You can pass the produce function directly or use "immer" after calling registerMutatorProduce().
79
+ */
80
+ mutatorProduce?: (<T>(base: T, recipe: (draft: T) => void) => T) | "immer";
81
+ /**
82
+ * When true, createSelector clones frozen state before proxy tracking.
83
+ * Default: true (safer for mutation-prone selectors in dev).
84
+ */
85
+ selectorCloneFrozen?: boolean;
86
+ };
87
+ type ResolvedConfig = {
88
+ logSink: LogSink;
89
+ flush: Required<FlushConfig>;
90
+ revalidateOnFocus: Required<RevalidateOnFocusConfig>;
91
+ namespace: string;
92
+ strictMissingFeatures: boolean;
93
+ assertRuntime: boolean;
94
+ strictMutatorReturns: boolean;
95
+ asyncAutoCreate: boolean;
96
+ asyncCloneResult: AsyncCloneMode;
97
+ autoCorrelationIds: boolean;
98
+ acknowledgeLooseTypes: boolean;
99
+ pathCacheSize: number;
100
+ defaultSnapshotMode: SnapshotMode;
101
+ strictAsyncUsageErrors: boolean;
102
+ middleware: Array<(ctx: MiddlewareCtx) => StoreValue | void>;
103
+ allowUntrustedHydration: boolean;
104
+ mutatorProduce?: <T>(base: T, recipe: (draft: T) => void) => T;
105
+ selectorCloneFrozen: boolean;
106
+ };
107
+ export declare const getConfig: () => ResolvedConfig;
108
+ export declare const registerMutatorProduce: (produce: (<T>(base: T, recipe: (draft: T) => void) => T), options?: {
109
+ force?: boolean;
110
+ }) => void;
111
+ export declare const configureStroid: (next?: StroidConfig) => void;
112
+ export declare const resetConfig: () => void;
113
+ export declare const _resetConfigForTests: () => void;
114
+ export declare const getNamespace: () => string;
115
+ export declare const setNamespace: (ns: string) => void;
116
+ export {};
@@ -0,0 +1,21 @@
1
+ export declare const __DEV__: boolean;
2
+ export declare const isDev: () => boolean;
3
+ export declare const critical: (msg: string, meta?: Record<string, unknown>) => void;
4
+ export declare const warn: (msg: string, meta?: Record<string, unknown>) => void;
5
+ export declare const warnAlways: (msg: string, meta?: Record<string, unknown>) => void;
6
+ export declare const error: (msg: string, meta?: Record<string, unknown>) => void;
7
+ export declare const log: (msg: string, meta?: Record<string, unknown>) => void;
8
+ export declare const getInvalidFunctionStoreValueMessage: () => string;
9
+ export declare const getMapSetStoreWarningMessage: () => string;
10
+ export declare const getDateStoreWarningMessage: () => string;
11
+ export declare const getSanitizeDateWarningMessage: () => string;
12
+ export declare const getSanitizeMapWarningMessage: () => string;
13
+ export declare const getSanitizeSetWarningMessage: () => string;
14
+ export declare const getPathDepthExceededMessage: (depth: number, maxDepth: number, parts: string[]) => string;
15
+ export declare const getDeepNestingWarningMessage: (depth: number, parts: string[]) => string;
16
+ export declare const getPathReachedNullMessage: (parts: string[], part: string) => string;
17
+ export declare const getPathNotObjectMessage: (part: string) => string;
18
+ export declare const getInvalidStoreNameMessage: (name: string) => string;
19
+ export declare const getStoreNameContainsSpacesMessage: (name: string) => string;
20
+ export declare const getForbiddenStoreNameMessage: (name: string) => string;
21
+ export declare const suggestStoreName: (name: string, existingNames: string[]) => void;
@@ -0,0 +1,9 @@
1
+ export type IssueSeverity = "warn" | "critical";
2
+ export type IssueVisibility = "dev" | "always";
3
+ export type IssueOptions = {
4
+ severity?: IssueSeverity;
5
+ visibility?: IssueVisibility;
6
+ onError?: (message: string) => void;
7
+ };
8
+ export declare const safeInvoke: <T extends unknown[]>(fn: ((...args: T) => void) | undefined, label: string, ...args: T) => void;
9
+ export declare const reportIssue: (message: string, options?: IssueOptions) => void;
@@ -0,0 +1,7 @@
1
+ import { type StoreRegistry } from "../core/store-registry.js";
2
+ export declare const createStoreAdmin: (registry: StoreRegistry) => {
3
+ deleteExistingStore: (name: string) => void;
4
+ clearAllStores: () => string[];
5
+ clearStores: (pattern?: string) => string[];
6
+ reportStoreError: (name: string, message: string) => void;
7
+ };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @module internals/store-ops
3
+ *
4
+ * LAYER: Internal subsystem
5
+ * OWNS: Module-level behavior and exports for internals/store-ops.
6
+ *
7
+ * Consumers: Internal imports and public API.
8
+ */
9
+ export { createStore } from "../core/store-create.js";
10
+ export { replaceStore } from "../core/store-replace.js";
11
+ export { setStore, setStoreWithContext } from "../core/store-set.js";
12
+ export { getStore, hasStore } from "../core/store-read.js";
13
+ export { subscribeStore } from "../core/store-notify.js";
@@ -0,0 +1,2 @@
1
+ export declare const registerTestResetHook: (name: string, fn: () => void, order?: number) => void;
2
+ export declare const runTestResets: () => void;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @module internals/write-context
3
+ *
4
+ * LAYER: Internal subsystem
5
+ * OWNS: Correlation/trace context for write chains.
6
+ *
7
+ * Consumers: store-write.ts, notification/delivery.ts, async-fetch.ts.
8
+ */
9
+ import type { TraceContext } from "../types/utility.js";
10
+ export type WriteContext = {
11
+ correlationId?: string;
12
+ traceContext?: TraceContext;
13
+ };
14
+ export type WriteContextRunner = {
15
+ run: <T>(context: WriteContext, fn: () => T) => T;
16
+ get: () => WriteContext | null;
17
+ };
18
+ export declare const injectWriteContextRunner: (runner: WriteContextRunner | null) => void;
19
+ export declare const getWriteContext: () => WriteContext | null;
20
+ export declare const runWithWriteContext: <T>(context: WriteContext | null | undefined, fn: () => T) => T;
@@ -0,0 +1,3 @@
1
+ import { type StoreRegistry } from "../core/store-registry.js";
2
+ import type { FlushPlan } from "./priority.js";
3
+ export declare const deliverFlush: (registry: StoreRegistry, plan: FlushPlan, flushVersion: number, onComplete: () => void) => void;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @module notification/index
3
+ *
4
+ * LAYER: Notification pipeline
5
+ * OWNS: Orchestrating flush scheduling without owning sub-responsibilities.
6
+ *
7
+ * Consumers: store-notify.ts
8
+ */
9
+ import type { StoreRegistry } from "../core/store-registry.js";
10
+ export declare const scheduleFlush: (registry: StoreRegistry) => void;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @module notification/metrics
3
+ *
4
+ * LAYER: Notification pipeline
5
+ * OWNS: Notify timing and metric aggregation.
6
+ *
7
+ * Consumers: notification/delivery.ts
8
+ */
9
+ import type { FeatureMetrics, StoreFeatureMeta } from "../features/feature-registry.js";
10
+ export declare const createMetrics: (metrics?: FeatureMetrics) => FeatureMetrics;
11
+ export declare const recordMetrics: (metrics: FeatureMetrics, elapsedMs: number) => FeatureMetrics;
12
+ export declare const commitMetrics: (metaEntry: StoreFeatureMeta | undefined, metrics: FeatureMetrics) => void;