stroid 0.1.2 → 0.1.3

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 (105) hide show
  1. package/CHANGELOG.md +27 -2
  2. package/dist/async.js +22 -22
  3. package/dist/async.js.map +1 -1
  4. package/dist/computed.d.ts +7 -1
  5. package/dist/computed.js +11 -11
  6. package/dist/computed.js.map +1 -1
  7. package/dist/core.js +14 -14
  8. package/dist/core.js.map +1 -1
  9. package/dist/devtools.js +1 -1
  10. package/dist/devtools.js.map +1 -1
  11. package/dist/feature.js.map +1 -1
  12. package/dist/helpers.js +14 -14
  13. package/dist/helpers.js.map +1 -1
  14. package/dist/index.d.cts +1 -0
  15. package/dist/index.d.ts +1 -0
  16. package/dist/index.js +24 -24
  17. package/dist/index.js.map +1 -1
  18. package/dist/install.js +1 -1
  19. package/dist/install.js.map +1 -1
  20. package/dist/persist.js +1 -1
  21. package/dist/persist.js.map +1 -1
  22. package/dist/react/index.js +25 -25
  23. package/dist/react/index.js.map +1 -1
  24. package/dist/runtime-admin.js +1 -1
  25. package/dist/runtime-admin.js.map +1 -1
  26. package/dist/runtime-tools.js +2 -2
  27. package/dist/runtime-tools.js.map +1 -1
  28. package/dist/selectors.js +1 -1
  29. package/dist/selectors.js.map +1 -1
  30. package/dist/server.js +11 -11
  31. package/dist/server.js.map +1 -1
  32. package/dist/store-registry.d.ts +0 -1
  33. package/dist/sync.js +1 -1
  34. package/dist/sync.js.map +1 -1
  35. package/dist/testing.js +14 -14
  36. package/dist/testing.js.map +1 -1
  37. package/package.json +4 -1
  38. package/dist/types/adapters/options.d.ts +0 -335
  39. package/dist/types/async/cache.d.ts +0 -39
  40. package/dist/types/async/clone.d.ts +0 -10
  41. package/dist/types/async/errors.d.ts +0 -3
  42. package/dist/types/async/fetch.d.ts +0 -37
  43. package/dist/types/async/inflight.d.ts +0 -13
  44. package/dist/types/async/rate.d.ts +0 -5
  45. package/dist/types/async/registry.d.ts +0 -116
  46. package/dist/types/async/request.d.ts +0 -11
  47. package/dist/types/async/retry.d.ts +0 -10
  48. package/dist/types/async.d.ts +0 -10
  49. package/dist/types/computed/computed-graph.d.ts +0 -29
  50. package/dist/types/computed/index.d.ts +0 -16
  51. package/dist/types/config.d.ts +0 -10
  52. package/dist/types/core/index.d.ts +0 -11
  53. package/dist/types/core/lifecycle-hooks.d.ts +0 -16
  54. package/dist/types/core/store-admin-impl.d.ts +0 -9
  55. package/dist/types/core/store-admin.d.ts +0 -9
  56. package/dist/types/core/store-core.d.ts +0 -13
  57. package/dist/types/core/store-create.d.ts +0 -16
  58. package/dist/types/core/store-hydrate-impl.d.ts +0 -35
  59. package/dist/types/core/store-hydrate.d.ts +0 -9
  60. package/dist/types/core/store-lifecycle/hooks.d.ts +0 -19
  61. package/dist/types/core/store-lifecycle/identity.d.ts +0 -23
  62. package/dist/types/core/store-lifecycle/registry.d.ts +0 -53
  63. package/dist/types/core/store-lifecycle/types.d.ts +0 -67
  64. package/dist/types/core/store-lifecycle/validation.d.ts +0 -53
  65. package/dist/types/core/store-name.d.ts +0 -28
  66. package/dist/types/core/store-notify.d.ts +0 -12
  67. package/dist/types/core/store-read.d.ts +0 -18
  68. package/dist/types/core/store-registry.d.ts +0 -108
  69. package/dist/types/core/store-replace-impl.d.ts +0 -11
  70. package/dist/types/core/store-replace.d.ts +0 -9
  71. package/dist/types/core/store-set-impl.d.ts +0 -13
  72. package/dist/types/core/store-set.d.ts +0 -9
  73. package/dist/types/core/store-shared/core.d.ts +0 -13
  74. package/dist/types/core/store-shared/notify.d.ts +0 -12
  75. package/dist/types/core/store-transaction.d.ts +0 -26
  76. package/dist/types/core/store-write-shared.d.ts +0 -19
  77. package/dist/types/core/store-write.d.ts +0 -13
  78. package/dist/types/features/feature-registry.d.ts +0 -91
  79. package/dist/types/features/lifecycle.d.ts +0 -40
  80. package/dist/types/index.d.ts +0 -17
  81. package/dist/types/integrations/query.d.ts +0 -8
  82. package/dist/types/internals/computed-order.d.ts +0 -3
  83. package/dist/types/internals/config.d.ts +0 -116
  84. package/dist/types/internals/diagnostics.d.ts +0 -21
  85. package/dist/types/internals/reporting.d.ts +0 -9
  86. package/dist/types/internals/store-admin.d.ts +0 -7
  87. package/dist/types/internals/store-ops.d.ts +0 -13
  88. package/dist/types/internals/test-reset.d.ts +0 -2
  89. package/dist/types/internals/write-context.d.ts +0 -15
  90. package/dist/types/notification/delivery.d.ts +0 -3
  91. package/dist/types/notification/index.d.ts +0 -10
  92. package/dist/types/notification/metrics.d.ts +0 -12
  93. package/dist/types/notification/priority.d.ts +0 -9
  94. package/dist/types/notification/scheduler.d.ts +0 -11
  95. package/dist/types/notification/snapshot.d.ts +0 -8
  96. package/dist/types/runtime-admin/index.d.ts +0 -2
  97. package/dist/types/runtime-tools/index.d.ts +0 -58
  98. package/dist/types/store.d.ts +0 -16
  99. package/dist/types/types/utility.d.ts +0 -17
  100. package/dist/types/utils/clone.d.ts +0 -4
  101. package/dist/types/utils/devfreeze.d.ts +0 -2
  102. package/dist/types/utils/hash.d.ts +0 -8
  103. package/dist/types/utils/path.d.ts +0 -5
  104. package/dist/types/utils/validation.d.ts +0 -14
  105. package/dist/types/utils.d.ts +0 -13
@@ -1,10 +0,0 @@
1
- /**
2
- * @module config
3
- *
4
- * LAYER: Public API
5
- * OWNS: Module-level behavior and exports for config.
6
- *
7
- * Consumers: Internal imports and public API.
8
- */
9
- export { configureStroid, resetConfig, registerMutatorProduce } from "./internals/config.js";
10
- export type { LogSink, StroidConfig, FlushConfig, RevalidateOnFocusConfig, } from "./internals/config.js";
@@ -1,11 +0,0 @@
1
- /**
2
- * @module core
3
- *
4
- * LAYER: Public API (minimal runtime)
5
- * OWNS: Core store primitives only.
6
- *
7
- * Consumers: Bundle-size-sensitive consumers and explicit core usage.
8
- */
9
- export { createStore } from "./store-create.js";
10
- export { setStore, resetStore, deleteStore } from "./store-write.js";
11
- export { getStore, hasStore } from "./store-read.js";
@@ -1,16 +0,0 @@
1
- /**
2
- * @module core/lifecycle-hooks
3
- *
4
- * LAYER: Core utilities
5
- * OWNS: Cross-cutting lifecycle hooks without dependencies on other modules.
6
- *
7
- * Consumers: notification/*, async-cache.ts, internals/store-admin.ts
8
- */
9
- export type LifecycleHookEvent = {
10
- type: string;
11
- [key: string]: unknown;
12
- };
13
- export type LifecycleHook = (storeId: string, event: LifecycleHookEvent) => void;
14
- export declare const registerHook: (name: string, fn: LifecycleHook) => (() => void);
15
- export declare const hasHook: (name: string) => boolean;
16
- export declare const fireHook: (name: string, storeId: string, event: LifecycleHookEvent) => void;
@@ -1,9 +0,0 @@
1
- import type { StoreDefinition, StoreKey, StoreName, WriteResult } from "./store-lifecycle/types.js";
2
- export declare function deleteStore<Name extends string, State>(name: StoreDefinition<Name, State>): void;
3
- export declare function deleteStore<Name extends string, State>(name: StoreKey<Name, State>): void;
4
- export declare function deleteStore<Name extends StoreName>(name: Name): void;
5
- export declare function resetStore<Name extends string, State>(name: StoreDefinition<Name, State>): WriteResult;
6
- export declare function resetStore<Name extends string, State>(name: StoreKey<Name, State>): WriteResult;
7
- export declare function resetStore<Name extends StoreName>(name: Name): WriteResult;
8
- export declare const clearAllStores: () => void;
9
- export declare const _hardResetAllStoresForTest: () => void;
@@ -1,9 +0,0 @@
1
- /**
2
- * @module store-admin
3
- *
4
- * LAYER: Store runtime
5
- * OWNS: Public delete/reset/clear exports.
6
- *
7
- * Consumers: store-write barrel.
8
- */
9
- export { deleteStore, resetStore, clearAllStores, _hardResetAllStoresForTest, } from "./store-admin-impl.js";
@@ -1,13 +0,0 @@
1
- /**
2
- * @module store-core
3
- *
4
- * LAYER: Store core
5
- * OWNS: Minimal core adapters and registry accessors.
6
- *
7
- * Consumers: Internal async modules.
8
- */
9
- import type { StoreRegistry } from "./store-registry.js";
10
- import type { IStoreCore } from "./store-shared/core.js";
11
- export declare const getActiveRegistry: () => StoreRegistry;
12
- export declare const getActiveAsyncRegistry: () => StoreRegistry["async"];
13
- export declare const createStoreCore: <T = any>(name: string) => IStoreCore<T>;
@@ -1,16 +0,0 @@
1
- import { type StoreOptions } from "../adapters/options.js";
2
- import type { NonFunction } from "../types/utility.js";
3
- import type { StoreDefinition } from "./store-lifecycle/types.js";
4
- type LazyDisallow<T> = T extends {
5
- lazy: true;
6
- } ? never : T;
7
- export declare const clearSsrGlobalAllowWarned: (name?: string) => void;
8
- export declare function createStore<Name extends string, State>(name: Name, initialData: () => State, option: StoreOptions<State> & {
9
- lazy: true;
10
- }): StoreDefinition<Name, State> | undefined;
11
- export declare function createStore<Name extends string, State, Opt extends StoreOptions<State>>(name: Name, initialData: NonFunction<State>, option?: LazyDisallow<Opt>): StoreDefinition<Name, State> | undefined;
12
- export declare function createStoreStrict<Name extends string, State>(name: Name, initialData: () => State, option: StoreOptions<State> & {
13
- lazy: true;
14
- }): StoreDefinition<Name, State>;
15
- export declare function createStoreStrict<Name extends string, State, Opt extends StoreOptions<State>>(name: Name, initialData: NonFunction<State>, option?: LazyDisallow<Opt>): StoreDefinition<Name, State>;
16
- export {};
@@ -1,35 +0,0 @@
1
- import { type StoreOptions } from "../adapters/options.js";
2
- import type { StoreStateMap, StrictStoreMap, HydrateSnapshotFor, HydrationResult } from "./store-lifecycle/types.js";
3
- type HydrateSnapshot = HydrateSnapshotFor<StoreStateMap & StrictStoreMap>;
4
- type HydrateOptions<Snapshot extends object> = Partial<{
5
- [K in keyof Snapshot]: StoreOptions<Snapshot[K]>;
6
- }> & {
7
- default?: StoreOptions;
8
- };
9
- type HydrationTrustBase<Snapshot extends object> = {
10
- /**
11
- * Explicitly trust this snapshot and allow hydration.
12
- */
13
- allowTrusted?: boolean;
14
- /**
15
- * Alias for allowTrusted.
16
- */
17
- allowHydration?: boolean;
18
- /**
19
- * @deprecated Use allowTrusted instead.
20
- */
21
- allowUntrusted?: boolean;
22
- validate?: (snapshot: Snapshot) => boolean;
23
- onValidationError?: (error: unknown, snapshot: Snapshot) => boolean;
24
- };
25
- type HydrationTrust<Snapshot extends object> = (HydrationTrustBase<Snapshot> & {
26
- allowTrusted: true;
27
- }) | (HydrationTrustBase<Snapshot> & {
28
- allowHydration: true;
29
- }) | (HydrationTrustBase<Snapshot> & {
30
- allowUntrusted: true;
31
- }) | (HydrationTrustBase<Snapshot> & {
32
- validate: (snapshot: Snapshot) => boolean;
33
- });
34
- export declare const hydrateStores: <Snapshot extends object = HydrateSnapshot>(snapshot: Snapshot, options: HydrateOptions<Snapshot> | undefined, trust: HydrationTrust<Snapshot>) => HydrationResult;
35
- export {};
@@ -1,9 +0,0 @@
1
- /**
2
- * @module store-hydrate
3
- *
4
- * LAYER: Store runtime
5
- * OWNS: Public hydrateStores export.
6
- *
7
- * Consumers: store-write barrel.
8
- */
9
- export { hydrateStores } from "./store-hydrate-impl.js";
@@ -1,19 +0,0 @@
1
- import { MIDDLEWARE_ABORT } from "../../features/lifecycle.js";
2
- import { type FeatureHookContext } from "../../features/feature-registry.js";
3
- import type { NormalizedOptions } from "../../adapters/options.js";
4
- import type { StoreValue } from "./types.js";
5
- export declare const clearFeatureContexts: () => void;
6
- export declare const createBaseFeatureContext: (name: string) => FeatureHookContext | null;
7
- export declare const runFeatureCreateHooks: (name: string, notify: (name: string) => void) => void;
8
- export declare const runFeatureWriteHooks: (name: string, action: string, prev: StoreValue, next: StoreValue, notify: (name: string) => void) => void;
9
- export declare const runFeatureDeleteHooks: (name: string, prev: StoreValue, notify: (name: string) => void) => void;
10
- export declare const runMiddlewareForStore: (name: string, payload: {
11
- action: string;
12
- prev: StoreValue;
13
- next: StoreValue;
14
- path: unknown;
15
- correlationId?: string;
16
- traceContext?: import("../../types/utility.js").TraceContext;
17
- }) => StoreValue | typeof MIDDLEWARE_ABORT;
18
- export declare const runStoreHookSafe: (name: string, label: "onCreate" | "onSet" | "onReset" | "onDelete", fn: ((...args: any[]) => void) | undefined, args: any[]) => void;
19
- export declare const resolveFeatureAvailability: (name: string, options: NormalizedOptions) => NormalizedOptions;
@@ -1,23 +0,0 @@
1
- import { type IssueSeverity, type IssueVisibility } from "../../internals/reporting.js";
2
- import type { FeatureName } from "../../features/feature-registry.js";
3
- import type { StoreDefinition } from "./types.js";
4
- export declare const getSsrWarningIssued: (name?: string) => boolean;
5
- export declare const markSsrWarningIssued: (name: string) => void;
6
- export declare const resetSsrWarningFlag: () => void;
7
- export declare const qualifyName: (raw: string) => string;
8
- export declare const nameOf: (name: string | StoreDefinition<string, unknown>) => string;
9
- export declare const exists: (name: string) => boolean;
10
- export declare const reportStoreIssue: (name: string, message: string, options?: {
11
- severity?: IssueSeverity;
12
- visibility?: IssueVisibility;
13
- }) => void;
14
- export declare const reportStoreCreationIssue: (message: string, onError?: (message: string) => void, options?: {
15
- severity?: IssueSeverity;
16
- visibility?: IssueVisibility;
17
- }) => void;
18
- export declare const reportStoreWarning: (name: string, message: string, visibility?: IssueVisibility) => void;
19
- export declare const reportStoreCreationWarning: (message: string, onError?: (message: string) => void, visibility?: IssueVisibility) => void;
20
- export declare const reportStoreError: (name: string, message: string) => void;
21
- export declare const reportStoreCreationError: (message: string, onError?: (message: string) => void) => void;
22
- export declare const warnMissingFeature: (storeName: string, featureName: FeatureName, onError?: (message: string) => void) => void;
23
- export declare const getFeatureApi: (name: FeatureName) => import("../../features/feature-registry.js").DevtoolsFeatureApi | undefined;
@@ -1,53 +0,0 @@
1
- /**
2
- * @module store-lifecycle/registry
3
- *
4
- * LAYER: Store lifecycle
5
- * OWNS: Module-level behavior and exports for store-lifecycle/registry.
6
- *
7
- * Consumers: Internal imports and public API.
8
- */
9
- import { getStoreRegistry, type StoreRegistry, type StoreLifecycleEvent, type StoreLifecycleListener } from "../store-registry.js";
10
- import { type FeatureName, type StoreFeatureRuntime, type StoreFeatureMeta } from "../../features/feature-registry.js";
11
- import { createStoreAdmin } from "../../internals/store-admin.js";
12
- import type { StoreValue, Subscriber } from "./types.js";
13
- export { defaultRegistryScope } from "../store-registry.js";
14
- export type { StoreLifecycleEvent } from "../store-registry.js";
15
- export declare const setRegistryContext: (scope: string, registry: StoreRegistry) => void;
16
- export declare const getRegistry: () => StoreRegistry;
17
- export declare const onStoreLifecycle: (fn: StoreLifecycleListener | null) => (() => void);
18
- export declare const emitStoreLifecycle: (registry: StoreRegistry, event: StoreLifecycleEvent) => void;
19
- export declare function setPathCacheInvalidator(fn: (name: string) => void): void;
20
- export declare const stores: Record<string, unknown>;
21
- export declare const subscribers: Record<string, Set<Subscriber>>;
22
- export declare const initialStates: Record<string, unknown>;
23
- export declare const initialFactories: Record<string, (() => StoreValue) | undefined>;
24
- export declare const meta: Record<string, StoreFeatureMeta>;
25
- export declare const snapshotCache: Record<string, {
26
- version: number;
27
- snapshot: StoreValue | null;
28
- source?: StoreValue | null;
29
- mode?: "deep" | "shallow" | "ref";
30
- }>;
31
- export declare const featureRuntimes: Map<FeatureName, StoreFeatureRuntime<{}>>;
32
- export declare const storeAdmin: {
33
- deleteExistingStore: (name: string) => void;
34
- clearAllStores: () => string[];
35
- clearStores: (pattern?: string) => string[];
36
- reportStoreError: (name: string, message: string) => void;
37
- };
38
- export declare const getStoreAdmin: () => ReturnType<typeof createStoreAdmin>;
39
- export declare const getFeatureRuntime: (name: FeatureName) => StoreFeatureRuntime | undefined;
40
- export declare const initializeRegisteredFeatureRuntimes: () => void;
41
- export declare const hasStoreEntryInternal: (name: string, registry?: StoreRegistry) => boolean;
42
- export declare const getStoreValueRef: (name: string, registry?: StoreRegistry) => StoreValue | undefined;
43
- export declare const setStoreValueInternal: (name: string, value: StoreValue, registry?: StoreRegistry) => void;
44
- export declare const applyFeatureState: (name: string, value: StoreValue, updatedAtMs?: number) => void;
45
- export declare const recordStoreRead: (name: string, registry?: StoreRegistry) => void;
46
- export declare const clearAllRegistries: () => void;
47
- export declare const resetFeaturesForTests: () => void;
48
- export declare const getMetaEntry: (name: string) => StoreFeatureMeta | undefined;
49
- export declare const isDeleting: (name: string) => boolean;
50
- export declare const resolveScope: (scopeOrRegistry?: string | ReturnType<typeof getStoreRegistry>) => {
51
- scope: string;
52
- registry: StoreRegistry;
53
- };
@@ -1,67 +0,0 @@
1
- /**
2
- * @module store-lifecycle/types
3
- *
4
- * LAYER: Store lifecycle
5
- * OWNS: Module-level behavior and exports for store-lifecycle/types.
6
- *
7
- * Consumers: Internal imports and public API.
8
- */
9
- type Primitive = string | number | boolean | bigint | symbol | null | undefined;
10
- type PrevDepth = [never, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
11
- type PathInternal<T, Depth extends number> = Depth extends 0 ? never : T extends Primitive ? never : {
12
- [K in keyof T & (string | number)]: T[K] extends Primitive | Array<unknown> ? `${K}` : `${K}` | `${K}.${PathInternal<T[K], PrevDepth[Depth]>}`;
13
- }[keyof T & (string | number)];
14
- export type PathDepth<T, Depth extends number> = PathInternal<T, Depth>;
15
- export type Path<T, Depth extends number = 10> = PathInternal<T, Depth>;
16
- export type PathValue<T, P extends Path<T>> = P extends `${infer K}.${infer Rest}` ? K extends keyof T ? Rest extends Path<T[K]> ? PathValue<T[K], Rest> : never : never : P extends keyof T ? T[P] : never;
17
- export type PartialDeep<T> = T extends Primitive ? T : unknown extends T ? T : {
18
- [K in keyof T]?: PartialDeep<T[K]>;
19
- };
20
- export type StoreValue = unknown;
21
- export type HydrateSnapshotFor<Map extends object> = Partial<{
22
- [K in keyof Map & string]: Map[K];
23
- }>;
24
- export type HydrationFailureReason = "invalid-name" | "create-failed" | "merge-failed";
25
- export type HydrationFailure = {
26
- name: string;
27
- reason: HydrationFailureReason;
28
- cause?: unknown;
29
- received?: unknown;
30
- };
31
- export type HydrationBlockReason = "transaction" | "untrusted" | "validation-error" | "validation-failed";
32
- export type HydrationResult = {
33
- hydrated: string[];
34
- created: string[];
35
- failed: HydrationFailure[];
36
- blocked?: {
37
- reason: HydrationBlockReason;
38
- cause?: unknown;
39
- };
40
- };
41
- export interface StoreStateMap {
42
- }
43
- export interface StrictStoreMap {
44
- }
45
- type RegisteredStoreMap = StoreStateMap & StrictStoreMap;
46
- declare const storeNameBrand: unique symbol;
47
- type BrandedStoreName = string & {
48
- readonly [storeNameBrand]: true;
49
- };
50
- export type StoreName = (keyof RegisteredStoreMap & string) | BrandedStoreName;
51
- export type StateFor<Name extends string> = Name extends keyof RegisteredStoreMap ? RegisteredStoreMap[Name] : StoreValue;
52
- export type UnregisteredStoreName<Name extends string> = never;
53
- export type StoreKey<Name extends string = string, State = StoreValue> = StoreDefinition<Name, State> & {
54
- __store?: true;
55
- };
56
- export interface StoreDefinition<Name extends string = string, State = StoreValue> {
57
- name: Name;
58
- state?: State;
59
- }
60
- export type WriteResult = {
61
- ok: true;
62
- } | {
63
- ok: false;
64
- reason: "not-found" | "validate" | "path" | "middleware" | "ssr" | "invalid-args" | "lazy-uninitialized";
65
- };
66
- export type Subscriber = (value: StoreValue | null) => void;
67
- export {};
@@ -1,53 +0,0 @@
1
- /**
2
- * @module store-lifecycle/validation
3
- *
4
- * LAYER: Store lifecycle
5
- * OWNS: Module-level behavior and exports for store-lifecycle/validation.
6
- *
7
- * Consumers: Internal imports and public API.
8
- */
9
- import { type SupportedType, PathInput } from "../../utils.js";
10
- import { type ValidateOption } from "../../adapters/options.js";
11
- import type { StoreValue } from "./types.js";
12
- type PathSafetyVerdict = {
13
- ok: true;
14
- } | {
15
- ok: false;
16
- reason: string;
17
- };
18
- type PathValidationCacheNode = {
19
- children: Map<string, PathValidationCacheNode>;
20
- verdicts?: Map<SupportedType, PathSafetyVerdict>;
21
- };
22
- export declare const pathValidationCache: Map<string, PathValidationCacheNode>;
23
- export declare const resetPathValidationCache: (registry: object) => void;
24
- export declare const validatePathSafety: (storeName: string, base: StoreValue, path: PathInput, nextValue: unknown) => {
25
- ok: boolean;
26
- reason?: string;
27
- };
28
- export declare const sanitizeValue: (name: string, value: unknown, onError?: (message: string) => void, options?: {
29
- reuseInput?: boolean;
30
- }) => {
31
- ok: true;
32
- value: StoreValue;
33
- } | {
34
- ok: false;
35
- };
36
- export declare const runValidation: (name: string, value: StoreValue, validate: ValidateOption | undefined, onError?: (message: string) => void) => {
37
- ok: true;
38
- value: StoreValue;
39
- } | {
40
- ok: false;
41
- };
42
- export declare const normalizeCommittedState: (name: string, value: unknown, validate: ValidateOption | undefined, onError?: (message: string) => void, options?: {
43
- reuseInput?: boolean;
44
- }) => {
45
- ok: true;
46
- value: StoreValue;
47
- } | {
48
- ok: false;
49
- };
50
- export declare const invalidatePathCache: (name: string) => void;
51
- export declare const clearPathValidationCache: () => void;
52
- export declare const materializeInitial: (name: string, registry?: import("../store-registry.js").StoreRegistry) => boolean;
53
- export {};
@@ -1,28 +0,0 @@
1
- /**
2
- * @module store-name
3
- *
4
- * LAYER: Store runtime
5
- * OWNS: Module-level behavior and exports for store-name.
6
- *
7
- * Consumers: Internal imports and public API.
8
- */
9
- import type { StoreKey, StoreValue } from "./store-lifecycle/types.js";
10
- import type { StoreOptions } from "../adapters/options.js";
11
- import type { NonFunction } from "../types/utility.js";
12
- /**
13
- * Helper to get an auto-completable, literal-typed store handle without creating it.
14
- *
15
- * Example:
16
- * const user = store("user");
17
- * setStore(user, "name", "Alex");
18
- */
19
- export declare const store: <Name extends string, State = StoreValue>(name: Name) => StoreKey<Name, State>;
20
- export declare const namespace: (ns: string) => {
21
- store: <Name extends string, State = unknown>(name: Name) => StoreKey<Name, State>;
22
- create: <Name extends string, State>(name: Name, data: NonFunction<State>, options?: StoreOptions<State>) => import("./store-lifecycle/types.js").StoreDefinition<string, State> | undefined;
23
- createStrict: <Name extends string, State>(name: Name, data: NonFunction<State>, options?: StoreOptions<State>) => import("./store-lifecycle/types.js").StoreDefinition<string, State>;
24
- set: (name: any, ...rest: any[]) => any;
25
- get: (name: any, ...rest: any[]) => any;
26
- delete: (name: string) => void;
27
- reset: (name: string) => import("./store-lifecycle/types.js").WriteResult;
28
- };
@@ -1,12 +0,0 @@
1
- import type { StoreValue, Subscriber } from "./store-lifecycle/types.js";
2
- export declare const notify: (name: string) => void;
3
- export declare const setStoreBatch: (fn: () => unknown) => void;
4
- export declare const subscribeStore: (name: string, fn: Subscriber) => (() => void);
5
- /** @deprecated Use subscribeStore instead. */
6
- export declare const subscribeInternal: (name: string, fn: Subscriber) => (() => void);
7
- /** @deprecated Use subscribeStore instead. */
8
- export declare const subscribe: (name: string, fn: Subscriber) => (() => void);
9
- export declare const getStoreSnapshot: (name: string) => StoreValue | null;
10
- /** @deprecated Use getStoreSnapshot instead. */
11
- export declare const getSnapshot: (name: string) => StoreValue | null;
12
- export declare const resetNotifyStateForTests: () => void;
@@ -1,18 +0,0 @@
1
- import { hasStoreEntryInternal, getStoreValueRef } from "./store-lifecycle/registry.js";
2
- import { getFeatureApi } from "./store-lifecycle/identity.js";
3
- import type { Path, PathValue, StoreDefinition, StoreValue, StoreKey, StoreName, StateFor } from "./store-lifecycle/types.js";
4
- import type { FeatureMetrics } from "../features/feature-registry.js";
5
- type StoreSnapshot<T> = T extends object ? Readonly<T> : T;
6
- export declare function getStore<Name extends string, State, P extends Path<State>>(name: StoreDefinition<Name, State>, path: P): StoreSnapshot<PathValue<State, P>> | null;
7
- export declare function getStore<Name extends string, State>(name: StoreDefinition<Name, State>, path?: undefined): StoreSnapshot<State> | null;
8
- export declare function getStore<Name extends string, State, P extends Path<State>>(name: StoreKey<Name, State>, path: P): StoreSnapshot<PathValue<State, P>> | null;
9
- export declare function getStore<Name extends string, State>(name: StoreKey<Name, State>, path?: undefined): StoreSnapshot<State> | null;
10
- export declare function getStore<Name extends StoreName, P extends Path<StateFor<Name>>>(name: Name, path: P): StoreSnapshot<PathValue<StateFor<Name>, P>> | null;
11
- export declare function getStore<Name extends StoreName>(name: Name, path?: undefined): StoreSnapshot<StateFor<Name>> | null;
12
- export declare const hasStore: (name: string) => boolean;
13
- export declare const isLazyStore: (name: string) => boolean;
14
- export declare const isStoreMaterialized: (name: string) => boolean;
15
- export declare const isLazyPending: (name: string) => boolean;
16
- export { hasStoreEntryInternal as _hasStoreEntryInternal, getStoreValueRef as _getStoreValueRef, getFeatureApi as _getFeatureApi };
17
- export declare const getInitialState: () => Record<string, StoreValue>;
18
- export declare const getMetrics: (name: string) => FeatureMetrics | null;
@@ -1,108 +0,0 @@
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 { AsyncRegistry } from "../async/registry.js";
11
- export type RegistryStoreValue = unknown;
12
- export type RegistrySubscriber = (value: RegistryStoreValue | null) => void;
13
- export type RegistrySnapshotEntry = {
14
- version: number;
15
- snapshot: RegistryStoreValue | null;
16
- source?: RegistryStoreValue | null;
17
- mode?: "deep" | "shallow" | "ref";
18
- };
19
- export type StoreLifecycleEvent = {
20
- type: "created";
21
- name: string;
22
- isGlobal: boolean;
23
- isTemp: boolean;
24
- } | {
25
- type: "deleted";
26
- name: string;
27
- };
28
- export type StoreLifecycleListener = (event: StoreLifecycleEvent) => void;
29
- export type TransactionState = {
30
- depth: number;
31
- pending: Array<() => void>;
32
- stagedValues: Map<string, RegistryStoreValue>;
33
- snapshotCache: Map<string, TransactionSnapshotEntry>;
34
- failed: boolean;
35
- error?: Error;
36
- };
37
- type TransactionSnapshotMode = "deep" | "shallow" | "ref";
38
- type TransactionSnapshotEntry = {
39
- source: RegistryStoreValue | null | undefined;
40
- snapshot: RegistryStoreValue | null;
41
- mode: TransactionSnapshotMode;
42
- };
43
- export type ComputedEntry = {
44
- deps: string[];
45
- compute: (...args: unknown[]) => unknown;
46
- stale: boolean;
47
- };
48
- export type NotifyState = {
49
- pendingNotifications: Set<string>;
50
- pendingBuffer: string[];
51
- orderedNames: string[];
52
- subscriberBuffer: RegistrySubscriber[];
53
- notifyScheduled: boolean;
54
- batchDepth: number;
55
- flushId: number;
56
- isFlushing: boolean;
57
- };
58
- export type RegistryScope = "default" | "request";
59
- export type StoreRegistry = {
60
- scope: RegistryScope;
61
- stores: Record<string, RegistryStoreValue>;
62
- subscribers: Record<string, Set<RegistrySubscriber>>;
63
- initialStates: Record<string, RegistryStoreValue>;
64
- initialFactories: Record<string, (() => RegistryStoreValue) | undefined>;
65
- metaEntries: Record<string, StoreFeatureMeta>;
66
- snapshotCache: Record<string, RegistrySnapshotEntry>;
67
- featureRuntimes: Map<FeatureName, StoreFeatureRuntime>;
68
- deletingStores: Set<string>;
69
- computedEntries: Record<string, ComputedEntry>;
70
- computedDependents: Record<string, Set<string>>;
71
- computedCleanups: Map<string, () => void>;
72
- transaction: TransactionState;
73
- async: AsyncRegistry;
74
- notify: NotifyState;
75
- lifecycleListener: StoreLifecycleListener | null;
76
- };
77
- export declare const initializeRegistryFeatureRuntimes: (registry: StoreRegistry) => void;
78
- export declare const normalizeStoreRegistryScope: (scope: string) => string;
79
- export declare const defaultRegistryScope: string;
80
- export declare const getDefaultStoreRegistry: () => StoreRegistry;
81
- export declare const setRegistryScope: (scope: string) => void;
82
- export declare const clearRegistryScopeOverrideForTests: () => void;
83
- export declare const createTransactionState: () => TransactionState;
84
- export declare const createStoreRegistry: (scope?: RegistryScope) => StoreRegistry;
85
- export declare const getStoreRegistry: (scope: string) => StoreRegistry;
86
- export declare const hasStoreEntry: (registry: StoreRegistry, name: string) => boolean;
87
- export declare const isStoreDeleting: (registry: StoreRegistry, name: string) => boolean;
88
- export declare const clearStoreRegistries: (registry: StoreRegistry) => void;
89
- export declare const setLifecycleListener: (registry: StoreRegistry, listener: StoreLifecycleListener | null) => void;
90
- export declare const emitLifecycleEvent: (registry: StoreRegistry, event: StoreLifecycleEvent) => void;
91
- export declare const resetAllStoreRegistriesForTests: () => void;
92
- export type CarrierContext = Record<string, unknown>;
93
- export interface CarrierRunner {
94
- run<T>(carrier: CarrierContext, fn: () => T): T;
95
- get(): CarrierContext | null;
96
- }
97
- export declare const injectCarrierRunner: (runner: CarrierRunner) => void;
98
- export declare const getRequestCarrier: () => CarrierContext | null;
99
- export interface RegistryRunner {
100
- run<T>(registry: StoreRegistry, fn: () => T): T;
101
- get(): StoreRegistry | null;
102
- enterWith?: (registry: StoreRegistry) => void;
103
- }
104
- export declare const injectRegistryRunner: (runner: RegistryRunner) => void;
105
- export declare const runWithRegistry: <T>(registry: StoreRegistry, fn: () => T) => T;
106
- export declare const getActiveStoreRegistry: (fallback?: StoreRegistry) => StoreRegistry;
107
- export declare const enterRegistry: (registry: StoreRegistry) => void;
108
- export {};
@@ -1,11 +0,0 @@
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
- };
@@ -1,9 +0,0 @@
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";
@@ -1,13 +0,0 @@
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 {};
@@ -1,9 +0,0 @@
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";
@@ -1,13 +0,0 @@
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
- }
@@ -1,12 +0,0 @@
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 {};
@@ -1,26 +0,0 @@
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 StoreRegistry, type TransactionState } from "./store-registry.js";
11
- export type TransactionRunner = {
12
- run: <T>(state: TransactionState, fn: () => T) => T;
13
- get: () => TransactionState | null;
14
- enterWith?: (state: TransactionState) => void;
15
- };
16
- export declare const injectTransactionRunner: (runner: TransactionRunner | null) => void;
17
- export declare const beginTransaction: (registry?: StoreRegistry) => StoreRegistry;
18
- export declare const isTransactionActive: () => boolean;
19
- export declare const markTransactionFailed: (err?: unknown, registry?: StoreRegistry) => void;
20
- export declare const registerTransactionCommit: (fn: () => void) => void;
21
- export declare const stageTransactionValue: (name: string, value: StoreValue) => void;
22
- export declare const getStagedTransactionValue: (name: string) => {
23
- has: boolean;
24
- value: StoreValue | undefined;
25
- };
26
- export declare const endTransaction: (err?: unknown, registry?: StoreRegistry) => Error | null;