stroid 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/README.md +375 -468
- package/dist/_tsup-dts-rollup.d.cts +2411 -0
- package/dist/_tsup-dts-rollup.d.ts +2411 -0
- package/dist/async.cjs +29 -24
- package/dist/async.cjs.map +1 -0
- package/dist/async.d.cts +9 -40
- package/dist/async.d.ts +9 -40
- package/dist/async.js +29 -24
- package/dist/async.js.map +1 -0
- package/dist/computed.cjs +12 -10
- package/dist/computed.cjs.map +1 -0
- package/dist/computed.d.cts +7 -29
- package/dist/computed.d.ts +7 -29
- package/dist/computed.js +12 -10
- package/dist/computed.js.map +1 -0
- package/dist/core.cjs +17 -23
- package/dist/core.cjs.map +1 -0
- package/dist/core.d.cts +15 -5
- package/dist/core.d.ts +15 -5
- package/dist/core.js +17 -23
- package/dist/core.js.map +1 -0
- package/dist/devtools.cjs +2 -1
- package/dist/devtools.cjs.map +1 -0
- package/dist/devtools.d.cts +5 -19
- package/dist/devtools.d.ts +5 -19
- package/dist/devtools.js +2 -1
- package/dist/devtools.js.map +1 -0
- package/dist/feature.cjs +2 -0
- package/dist/feature.cjs.map +1 -0
- package/dist/feature.d.cts +14 -0
- package/dist/feature.d.ts +14 -0
- package/dist/feature.js +2 -0
- package/dist/feature.js.map +1 -0
- package/dist/helpers.cjs +17 -13
- package/dist/helpers.cjs.map +1 -0
- package/dist/helpers.d.cts +3 -29
- package/dist/helpers.d.ts +3 -29
- package/dist/helpers.js +17 -13
- package/dist/helpers.js.map +1 -0
- package/dist/index.cjs +26 -21
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +33 -130
- package/dist/index.d.ts +33 -130
- package/dist/index.js +26 -21
- package/dist/index.js.map +1 -0
- package/dist/install.cjs +2 -0
- package/dist/install.cjs.map +1 -0
- package/dist/install.d.cts +4 -0
- package/dist/install.d.ts +4 -0
- package/dist/install.js +2 -0
- package/dist/install.js.map +1 -0
- package/dist/persist.cjs +2 -1
- package/dist/persist.cjs.map +1 -0
- package/dist/persist.d.cts +1 -2
- package/dist/persist.d.ts +1 -2
- package/dist/persist.js +2 -1
- package/dist/persist.js.map +1 -0
- package/dist/react.cjs +27 -22
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +7 -52
- package/dist/react.d.ts +7 -52
- package/dist/react.js +27 -22
- package/dist/react.js.map +1 -0
- package/dist/runtime-admin.cjs +2 -1
- package/dist/runtime-admin.cjs.map +1 -0
- package/dist/runtime-admin.d.cts +2 -4
- package/dist/runtime-admin.d.ts +2 -4
- package/dist/runtime-admin.js +2 -1
- package/dist/runtime-admin.js.map +1 -0
- package/dist/runtime-tools.cjs +3 -2
- package/dist/runtime-tools.cjs.map +1 -0
- package/dist/runtime-tools.d.cts +9 -39
- package/dist/runtime-tools.d.ts +9 -39
- package/dist/runtime-tools.js +3 -2
- package/dist/runtime-tools.js.map +1 -0
- package/dist/selectors.cjs +2 -1
- package/dist/selectors.cjs.map +1 -0
- package/dist/selectors.d.cts +2 -4
- package/dist/selectors.d.ts +2 -4
- package/dist/selectors.js +2 -1
- package/dist/selectors.js.map +1 -0
- package/dist/server.cjs +11 -9
- package/dist/server.cjs.map +1 -0
- package/dist/server.d.cts +2 -14
- package/dist/server.d.ts +2 -14
- package/dist/server.js +11 -9
- package/dist/server.js.map +1 -0
- package/dist/sync.cjs +2 -1
- package/dist/sync.cjs.map +1 -0
- package/dist/sync.d.cts +1 -2
- package/dist/sync.d.ts +1 -2
- package/dist/sync.js +2 -1
- package/dist/sync.js.map +1 -0
- package/dist/testing.cjs +17 -13
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +4 -16
- package/dist/testing.d.ts +4 -16
- package/dist/testing.js +17 -13
- package/dist/testing.js.map +1 -0
- package/package.json +12 -3
- package/dist/async-cache-DFHwcBQL.d.cts +0 -52
- package/dist/async-cache-DFHwcBQL.d.ts +0 -52
- package/dist/computed-BbAZm1Dq.d.cts +0 -17
- package/dist/computed-CccdgY5j.d.ts +0 -17
- package/dist/options-CB35e3Xo.d.cts +0 -245
- package/dist/options-CB35e3Xo.d.ts +0 -245
- package/dist/types/adapters/options.d.ts +0 -247
- package/dist/types/async/clone.d.ts +0 -2
- package/dist/types/async/errors.d.ts +0 -3
- package/dist/types/async/inflight.d.ts +0 -13
- package/dist/types/async/rate.d.ts +0 -5
- package/dist/types/async/request.d.ts +0 -3
- package/dist/types/async-cache.d.ts +0 -57
- package/dist/types/async-fetch.d.ts +0 -37
- package/dist/types/async-registry.d.ts +0 -96
- package/dist/types/async-retry.d.ts +0 -10
- package/dist/types/async.d.ts +0 -2
- package/dist/types/computed-graph.d.ts +0 -31
- package/dist/types/computed.d.ts +0 -15
- package/dist/types/config.d.ts +0 -2
- package/dist/types/core.d.ts +0 -1
- package/dist/types/devfreeze.d.ts +0 -1
- package/dist/types/feature-registry.d.ts +0 -69
- package/dist/types/features/lifecycle.d.ts +0 -28
- package/dist/types/index.d.ts +0 -6
- package/dist/types/integrations/query.d.ts +0 -8
- package/dist/types/internals/config.d.ts +0 -62
- package/dist/types/internals/diagnostics.d.ts +0 -21
- package/dist/types/internals/hooks-warnings.d.ts +0 -6
- package/dist/types/internals/reporting.d.ts +0 -8
- package/dist/types/internals/store-admin.d.ts +0 -7
- package/dist/types/internals/store-ops.d.ts +0 -3
- package/dist/types/runtime-admin.d.ts +0 -2
- package/dist/types/store-lifecycle/bind.d.ts +0 -3
- package/dist/types/store-lifecycle/hooks.d.ts +0 -44
- package/dist/types/store-lifecycle/identity.d.ts +0 -23
- package/dist/types/store-lifecycle/registry.d.ts +0 -39
- package/dist/types/store-lifecycle/types.d.ts +0 -39
- package/dist/types/store-lifecycle/validation.d.ts +0 -45
- package/dist/types/store-lifecycle.d.ts +0 -20
- package/dist/types/store-name.d.ts +0 -19
- package/dist/types/store-notify.d.ts +0 -12
- package/dist/types/store-read.d.ts +0 -12
- package/dist/types/store-registry.d.ts +0 -74
- package/dist/types/store-transaction.d.ts +0 -12
- package/dist/types/store-write.d.ts +0 -45
- package/dist/types/store.d.ts +0 -7
- package/dist/types/utils/clone.d.ts +0 -4
- package/dist/types/utils/hash.d.ts +0 -8
- package/dist/types/utils/path.d.ts +0 -5
- package/dist/types/utils/validation.d.ts +0 -14
- package/dist/types/utils.d.ts +0 -5
- package/dist/types-grvlY4BX.d.cts +0 -37
- package/dist/types-grvlY4BX.d.ts +0 -37
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
export type StoreValue = unknown;
|
|
2
|
-
export interface PersistDriver {
|
|
3
|
-
getItem?: (k: string) => string | null | Promise<string | null>;
|
|
4
|
-
setItem?: (k: string, v: string) => void | Promise<void>;
|
|
5
|
-
removeItem?: (k: string) => void | Promise<void>;
|
|
6
|
-
[key: string]: unknown;
|
|
7
|
-
}
|
|
8
|
-
export type StoreScope = "request" | "global" | "temp";
|
|
9
|
-
export type SnapshotMode = "deep" | "shallow" | "ref";
|
|
10
|
-
export type ValidateFn<State = StoreValue> = (next: State) => boolean | State;
|
|
11
|
-
export type SchemaValidateOption = {
|
|
12
|
-
safeParse: (value: unknown) => {
|
|
13
|
-
success: true;
|
|
14
|
-
data: unknown;
|
|
15
|
-
} | {
|
|
16
|
-
success: false;
|
|
17
|
-
error?: unknown;
|
|
18
|
-
};
|
|
19
|
-
} | {
|
|
20
|
-
parse: (value: unknown) => unknown;
|
|
21
|
-
} | {
|
|
22
|
-
validateSync: (value: unknown) => unknown;
|
|
23
|
-
} | {
|
|
24
|
-
isValidSync: (value: unknown) => boolean;
|
|
25
|
-
} | {
|
|
26
|
-
validate: (value: unknown) => unknown;
|
|
27
|
-
};
|
|
28
|
-
export type ValidateOption<State = StoreValue> = ValidateFn<State> | SchemaValidateOption;
|
|
29
|
-
export interface PersistOptions<State = StoreValue> {
|
|
30
|
-
driver?: PersistDriver;
|
|
31
|
-
storage?: PersistDriver;
|
|
32
|
-
key?: string;
|
|
33
|
-
serialize?: (v: unknown) => string;
|
|
34
|
-
deserialize?: (v: string) => unknown;
|
|
35
|
-
/**
|
|
36
|
-
* Optional encryption hook for persisted payloads.
|
|
37
|
-
*
|
|
38
|
-
* Default is identity (no encryption). Data is stored in plaintext.
|
|
39
|
-
*/
|
|
40
|
-
encrypt?: (v: string) => string;
|
|
41
|
-
/**
|
|
42
|
-
* Optional async encryption hook for persisted payloads.
|
|
43
|
-
*
|
|
44
|
-
* When provided, persistence will encrypt in the background and hydrate asynchronously.
|
|
45
|
-
*/
|
|
46
|
-
encryptAsync?: (v: string) => Promise<string>;
|
|
47
|
-
/**
|
|
48
|
-
* Optional decryption hook for persisted payloads.
|
|
49
|
-
*
|
|
50
|
-
* Default is identity (no encryption). Data is stored in plaintext.
|
|
51
|
-
*/
|
|
52
|
-
decrypt?: (v: string) => string;
|
|
53
|
-
/**
|
|
54
|
-
* Optional async decryption hook for persisted payloads.
|
|
55
|
-
*
|
|
56
|
-
* When provided, persistence will hydrate asynchronously after store creation.
|
|
57
|
-
*/
|
|
58
|
-
decryptAsync?: (v: string) => Promise<string>;
|
|
59
|
-
/**
|
|
60
|
-
* Explicitly allow plaintext persistence when encrypt/decrypt are identity.
|
|
61
|
-
*
|
|
62
|
-
* In production builds, plaintext persistence is blocked unless this is true.
|
|
63
|
-
*/
|
|
64
|
-
allowPlaintext?: boolean;
|
|
65
|
-
/**
|
|
66
|
-
* Marks this store's persisted data as sensitive (secrets/PII).
|
|
67
|
-
*
|
|
68
|
-
* When `true`, stroid throws at store creation time unless a non-identity
|
|
69
|
-
* `encrypt` hook is provided.
|
|
70
|
-
*/
|
|
71
|
-
sensitiveData?: boolean;
|
|
72
|
-
/**
|
|
73
|
-
* Integrity check mode for persisted payloads.
|
|
74
|
-
* - "hash" (default): store and validate a checksum.
|
|
75
|
-
* - "none": skip checksum generation/validation.
|
|
76
|
-
* - "sha256": store a SHA-256 hash for stronger tamper detection (may be async in browsers).
|
|
77
|
-
*/
|
|
78
|
-
checksum?: "hash" | "none" | "sha256";
|
|
79
|
-
version?: number;
|
|
80
|
-
migrations?: Record<number, (state: State) => State>;
|
|
81
|
-
onMigrationFail?: "reset" | "keep" | ((state: unknown) => unknown);
|
|
82
|
-
onStorageCleared?: (info: {
|
|
83
|
-
name: string;
|
|
84
|
-
key: string;
|
|
85
|
-
reason: "clear" | "remove" | "missing";
|
|
86
|
-
}) => void;
|
|
87
|
-
}
|
|
88
|
-
export interface PersistConfig {
|
|
89
|
-
driver: PersistDriver;
|
|
90
|
-
key: string;
|
|
91
|
-
serialize: (v: unknown) => string;
|
|
92
|
-
deserialize: (v: string) => unknown;
|
|
93
|
-
encrypt: (v: string) => string;
|
|
94
|
-
decrypt: (v: string) => string;
|
|
95
|
-
encryptAsync?: (v: string) => Promise<string>;
|
|
96
|
-
decryptAsync?: (v: string) => Promise<string>;
|
|
97
|
-
allowPlaintext?: boolean;
|
|
98
|
-
sensitiveData?: boolean;
|
|
99
|
-
checksum: "hash" | "none" | "sha256";
|
|
100
|
-
onMigrationFail?: "reset" | "keep" | ((state: unknown) => unknown);
|
|
101
|
-
onStorageCleared?: (info: {
|
|
102
|
-
name: string;
|
|
103
|
-
key: string;
|
|
104
|
-
reason: "clear" | "remove" | "missing";
|
|
105
|
-
}) => void;
|
|
106
|
-
}
|
|
107
|
-
export interface MiddlewareCtx {
|
|
108
|
-
action: string;
|
|
109
|
-
name: string;
|
|
110
|
-
prev: StoreValue;
|
|
111
|
-
next: StoreValue;
|
|
112
|
-
path: unknown;
|
|
113
|
-
}
|
|
114
|
-
export interface SyncOptions {
|
|
115
|
-
channel?: string;
|
|
116
|
-
maxPayloadBytes?: number;
|
|
117
|
-
/**
|
|
118
|
-
* Optional shared token for lightweight cross-tab authentication.
|
|
119
|
-
* When set, incoming sync messages without a matching token are rejected.
|
|
120
|
-
*/
|
|
121
|
-
authToken?: string;
|
|
122
|
-
conflictResolver?: (args: {
|
|
123
|
-
local: StoreValue;
|
|
124
|
-
incoming: StoreValue;
|
|
125
|
-
localUpdated: number;
|
|
126
|
-
incomingUpdated: number;
|
|
127
|
-
}) => StoreValue | void;
|
|
128
|
-
/**
|
|
129
|
-
* Optional checksum mode for sync payloads.
|
|
130
|
-
* - "hash" (default): include a checksum of the payload.
|
|
131
|
-
* - "none": skip checksum generation.
|
|
132
|
-
*/
|
|
133
|
-
checksum?: "hash" | "none";
|
|
134
|
-
/**
|
|
135
|
-
* Optional signer for sync payloads. The returned value is attached to the message as `auth`.
|
|
136
|
-
*/
|
|
137
|
-
sign?: (payload: SyncMessage) => unknown;
|
|
138
|
-
/**
|
|
139
|
-
* Optional verifier for incoming sync payloads.
|
|
140
|
-
* Return true to accept the message, false to reject it.
|
|
141
|
-
*/
|
|
142
|
-
verify?: (payload: SyncMessage) => boolean;
|
|
143
|
-
/**
|
|
144
|
-
* Optional resolver for updatedAt timestamps when conflicts are resolved.
|
|
145
|
-
*/
|
|
146
|
-
resolveUpdatedAt?: (args: {
|
|
147
|
-
localUpdated: number;
|
|
148
|
-
incomingUpdated: number | undefined;
|
|
149
|
-
now: number;
|
|
150
|
-
}) => number;
|
|
151
|
-
}
|
|
152
|
-
export type SyncMessage = {
|
|
153
|
-
v: number;
|
|
154
|
-
protocol: number;
|
|
155
|
-
type: "sync-request" | "sync-state";
|
|
156
|
-
name: string;
|
|
157
|
-
clock: number;
|
|
158
|
-
source: string;
|
|
159
|
-
updatedAt?: number;
|
|
160
|
-
data?: StoreValue;
|
|
161
|
-
checksum?: number | null;
|
|
162
|
-
auth?: unknown;
|
|
163
|
-
token?: string;
|
|
164
|
-
requestedAt?: number;
|
|
165
|
-
};
|
|
166
|
-
export interface DevtoolsOptions<State = StoreValue> {
|
|
167
|
-
enabled?: boolean;
|
|
168
|
-
historyLimit?: number;
|
|
169
|
-
redactor?: (state: State) => State;
|
|
170
|
-
}
|
|
171
|
-
export interface LifecycleOptions<State = StoreValue> {
|
|
172
|
-
middleware?: Array<(ctx: MiddlewareCtx) => StoreValue | void>;
|
|
173
|
-
onSet?: (prev: State, next: State) => void;
|
|
174
|
-
onReset?: (prev: State, next: State) => void;
|
|
175
|
-
onDelete?: (prev: State) => void;
|
|
176
|
-
onCreate?: (initial: State) => void;
|
|
177
|
-
}
|
|
178
|
-
export interface StoreOptions<State = StoreValue> {
|
|
179
|
-
scope?: StoreScope;
|
|
180
|
-
lazy?: boolean;
|
|
181
|
-
/**
|
|
182
|
-
* Allow `setStore(name, path, value)` to create missing **leaf** keys on object nodes.
|
|
183
|
-
*
|
|
184
|
-
* Default: `false` (strict path writes).
|
|
185
|
-
*
|
|
186
|
-
* Notes:
|
|
187
|
-
* - Does not expand arrays (out-of-bounds indices are still rejected).
|
|
188
|
-
* - Does not create missing intermediate objects for deep paths; define the shape up-front.
|
|
189
|
-
*/
|
|
190
|
-
pathCreate?: boolean;
|
|
191
|
-
validate?: ValidateOption<State>;
|
|
192
|
-
persist?: boolean | string | PersistOptions<State>;
|
|
193
|
-
devtools?: boolean | DevtoolsOptions<State>;
|
|
194
|
-
lifecycle?: LifecycleOptions<State>;
|
|
195
|
-
middleware?: Array<(ctx: MiddlewareCtx) => StoreValue | void>;
|
|
196
|
-
onSet?: (prev: State, next: State) => void;
|
|
197
|
-
onReset?: (prev: State, next: State) => void;
|
|
198
|
-
onDelete?: (prev: State) => void;
|
|
199
|
-
onCreate?: (initial: State) => void;
|
|
200
|
-
onError?: (err: string) => void;
|
|
201
|
-
/** @deprecated use validate instead */
|
|
202
|
-
validator?: (next: State) => boolean;
|
|
203
|
-
/** @deprecated use validate instead */
|
|
204
|
-
schema?: unknown;
|
|
205
|
-
migrations?: Record<number, (state: State) => State>;
|
|
206
|
-
version?: number;
|
|
207
|
-
redactor?: (state: State) => State;
|
|
208
|
-
historyLimit?: number;
|
|
209
|
-
allowSSRGlobalStore?: boolean;
|
|
210
|
-
sync?: boolean | SyncOptions;
|
|
211
|
-
/**
|
|
212
|
-
* Snapshot cloning strategy used by subscriptions and selector snapshots.
|
|
213
|
-
*
|
|
214
|
-
* - "deep" (default): deep clone and dev-freeze snapshot values.
|
|
215
|
-
* - "shallow": shallow clone (top-level) only; nested references are shared.
|
|
216
|
-
* - "ref": return the live store reference (no cloning).
|
|
217
|
-
*/
|
|
218
|
-
snapshot?: SnapshotMode;
|
|
219
|
-
}
|
|
220
|
-
export interface NormalizedOptions {
|
|
221
|
-
scope: StoreScope;
|
|
222
|
-
lazy: boolean;
|
|
223
|
-
pathCreate: boolean;
|
|
224
|
-
persist: PersistConfig | null;
|
|
225
|
-
devtools: boolean;
|
|
226
|
-
middleware: Array<(ctx: MiddlewareCtx) => StoreValue | void>;
|
|
227
|
-
onSet?: (prev: StoreValue, next: StoreValue) => void;
|
|
228
|
-
onReset?: (prev: StoreValue, next: StoreValue) => void;
|
|
229
|
-
onDelete?: (prev: StoreValue) => void;
|
|
230
|
-
onCreate?: (initial: StoreValue) => void;
|
|
231
|
-
onError?: (err: string) => void;
|
|
232
|
-
validate?: ValidateOption;
|
|
233
|
-
migrations: Record<number, (state: any) => any>;
|
|
234
|
-
version: number;
|
|
235
|
-
redactor?: (state: StoreValue) => StoreValue;
|
|
236
|
-
historyLimit: number;
|
|
237
|
-
allowSSRGlobalStore?: boolean;
|
|
238
|
-
sync?: boolean | SyncOptions;
|
|
239
|
-
snapshot: SnapshotMode;
|
|
240
|
-
explicitPersist: boolean;
|
|
241
|
-
explicitSync: boolean;
|
|
242
|
-
explicitDevtools: boolean;
|
|
243
|
-
}
|
|
244
|
-
export declare const resetLegacyOptionDeprecationWarningsForTests: () => void;
|
|
245
|
-
export declare const normalizePersistOptions: <State>(persist: StoreOptions<State>["persist"], name: string) => PersistConfig | null;
|
|
246
|
-
export declare const collectLegacyOptionDeprecationWarnings: <State>(option: StoreOptions<State>) => string[];
|
|
247
|
-
export declare const normalizeStoreOptions: <State>(option: StoreOptions<State> | undefined, name: string) => NormalizedOptions;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export declare const runAsyncHook: (name: string, label: "onSuccess" | "onError", fn: ((value: any) => void) | undefined, value: unknown) => void;
|
|
2
|
-
export declare const reportAsyncUsageError: (name: string, message: string, onError?: (message: string) => void) => null;
|
|
3
|
-
export declare const throwAsyncUsageError: (name: string, message: string, onError?: (message: string) => void) => never;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { FetchOptions } from "../async-cache.js";
|
|
2
|
-
export type InflightEntry = {
|
|
3
|
-
promise: Promise<unknown>;
|
|
4
|
-
raw: Promise<unknown>;
|
|
5
|
-
transform?: FetchOptions["transform"];
|
|
6
|
-
};
|
|
7
|
-
export declare const isCurrentRequest: (cacheSlot: string, version: number) => boolean;
|
|
8
|
-
export declare const reserveRequestVersion: (cacheSlot: string) => number;
|
|
9
|
-
export declare const clearRequestVersion: (cacheSlot: string, version: number) => void;
|
|
10
|
-
export declare const setInflightEntry: (cacheSlot: string, entry: InflightEntry) => void;
|
|
11
|
-
export declare const clearInflightEntry: (cacheSlot: string) => void;
|
|
12
|
-
export declare const hasInflightEntry: (cacheSlot: string) => boolean;
|
|
13
|
-
export declare const tryDedupeRequest: (name: string, cacheSlot: string, transform: FetchOptions["transform"] | undefined, onError?: (message: string) => void) => Promise<unknown> | null | undefined;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export declare const RATE_WINDOW_MS = 1000;
|
|
2
|
-
export declare const RATE_MAX = 100;
|
|
3
|
-
export declare const pruneRateCounters: (nowTs: number) => void;
|
|
4
|
-
export declare const scheduleRatePrune: (delayMs?: number) => void;
|
|
5
|
-
export declare const registerRateHit: (cacheSlot: string, nowTs: number) => boolean;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import type { FetchOptions } from "./async-registry.js";
|
|
2
|
-
export type { FetchOptions, AsyncStateSnapshot, AsyncStateAdapter } from "./async-registry.js";
|
|
3
|
-
export type FetchInput = string | Promise<unknown> | (() => string | Promise<unknown>);
|
|
4
|
-
export declare const MAX_CACHE_SLOTS_PER_STORE = 100;
|
|
5
|
-
export declare const MAX_INFLIGHT_SLOTS_PER_STORE = 100;
|
|
6
|
-
export declare const MAX_WARNED_ENTRIES = 1000;
|
|
7
|
-
export declare const getActiveAsyncRegistry: () => import("./async-registry.js").AsyncRegistry;
|
|
8
|
-
export declare const fetchRegistry: Record<string, {
|
|
9
|
-
kind: "url";
|
|
10
|
-
url: string;
|
|
11
|
-
options: FetchOptions;
|
|
12
|
-
} | {
|
|
13
|
-
kind: "factory";
|
|
14
|
-
factory: () => string | Promise<unknown>;
|
|
15
|
-
options: FetchOptions;
|
|
16
|
-
}>;
|
|
17
|
-
export declare const inflight: Partial<Record<string, {
|
|
18
|
-
promise: Promise<unknown>;
|
|
19
|
-
raw: Promise<unknown>;
|
|
20
|
-
transform?: FetchOptions["transform"];
|
|
21
|
-
}>>;
|
|
22
|
-
export declare const requestVersion: Record<string, number>;
|
|
23
|
-
export declare const cacheMeta: Record<string, {
|
|
24
|
-
timestamp: number;
|
|
25
|
-
expiresAt: number | null;
|
|
26
|
-
data: unknown;
|
|
27
|
-
}>;
|
|
28
|
-
export declare const rateWindowStart: Record<string, number>;
|
|
29
|
-
export declare const rateCount: Record<string, number>;
|
|
30
|
-
export declare const ratePruneState: {
|
|
31
|
-
lastAt: number;
|
|
32
|
-
};
|
|
33
|
-
export declare const cleanupSubs: Record<string, () => void>;
|
|
34
|
-
export declare const storeCleanupFns: Record<string, Set<() => void>>;
|
|
35
|
-
export declare const revalidateHandlers: Record<string, () => void>;
|
|
36
|
-
export declare const noSignalWarned: Set<string>;
|
|
37
|
-
export declare const shapeWarned: Set<string>;
|
|
38
|
-
export declare const autoCreateWarned: Set<string>;
|
|
39
|
-
export declare const revalidateKeys: Set<string>;
|
|
40
|
-
export declare const asyncMetrics: {
|
|
41
|
-
cacheHits: number;
|
|
42
|
-
cacheMisses: number;
|
|
43
|
-
dedupes: number;
|
|
44
|
-
requests: number;
|
|
45
|
-
failures: number;
|
|
46
|
-
avgMs: number;
|
|
47
|
-
lastMs: number;
|
|
48
|
-
};
|
|
49
|
-
export declare const markWarned: (set: Set<string>, key: string) => void;
|
|
50
|
-
export declare const resetAsyncState: () => void;
|
|
51
|
-
export declare const shouldUseCache: (cacheSlot: string, ttl?: number) => boolean;
|
|
52
|
-
export declare const clearAsyncMeta: (name: string) => void;
|
|
53
|
-
export declare const pruneAsyncCache: (name: string) => void;
|
|
54
|
-
export declare const countInflightSlots: (name: string) => number;
|
|
55
|
-
export declare const registerStoreCleanup: (name: string, fn: () => void) => void;
|
|
56
|
-
export declare const unregisterStoreCleanup: (name: string, fn: () => void) => void;
|
|
57
|
-
export declare const ensureCleanupSubscription: (name: string) => void;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { type StoreDefinition, type StoreKey, type StoreName } from "./store-lifecycle.js";
|
|
2
|
-
import { type FetchInput, type FetchOptions } from "./async-cache.js";
|
|
3
|
-
export declare function fetchStore<Name extends string, State>(name: StoreDefinition<Name, State>, urlOrRequest: FetchInput, options?: FetchOptions): Promise<unknown>;
|
|
4
|
-
export declare function fetchStore<Name extends string, State>(name: StoreKey<Name, State>, urlOrRequest: FetchInput, options?: FetchOptions): Promise<unknown>;
|
|
5
|
-
export declare function fetchStore<Name extends StoreName>(name: Name, urlOrRequest: FetchInput, options?: FetchOptions): Promise<unknown>;
|
|
6
|
-
export declare function refetchStore<Name extends string, State>(name: StoreDefinition<Name, State>): Promise<unknown>;
|
|
7
|
-
export declare function refetchStore<Name extends string, State>(name: StoreKey<Name, State>): Promise<unknown>;
|
|
8
|
-
export declare function refetchStore<Name extends StoreName>(name: Name): Promise<unknown>;
|
|
9
|
-
export declare function enableRevalidateOnFocus<Name extends string, State>(name: StoreDefinition<Name, State>, overrides?: Partial<FetchOptions> & {
|
|
10
|
-
debounceMs?: number;
|
|
11
|
-
maxConcurrent?: number;
|
|
12
|
-
staggerMs?: number;
|
|
13
|
-
priority?: "high" | "normal";
|
|
14
|
-
}): (() => void);
|
|
15
|
-
export declare function enableRevalidateOnFocus<Name extends string, State>(name: StoreKey<Name, State>, overrides?: Partial<FetchOptions> & {
|
|
16
|
-
debounceMs?: number;
|
|
17
|
-
maxConcurrent?: number;
|
|
18
|
-
staggerMs?: number;
|
|
19
|
-
priority?: "high" | "normal";
|
|
20
|
-
}): (() => void);
|
|
21
|
-
export declare function enableRevalidateOnFocus<Name extends StoreName>(name?: Name | "*", overrides?: Partial<FetchOptions> & {
|
|
22
|
-
debounceMs?: number;
|
|
23
|
-
maxConcurrent?: number;
|
|
24
|
-
staggerMs?: number;
|
|
25
|
-
priority?: "high" | "normal";
|
|
26
|
-
}): (() => void);
|
|
27
|
-
export declare const getAsyncMetrics: () => {
|
|
28
|
-
cacheHits: number;
|
|
29
|
-
cacheMisses: number;
|
|
30
|
-
dedupes: number;
|
|
31
|
-
requests: number;
|
|
32
|
-
failures: number;
|
|
33
|
-
avgMs: number;
|
|
34
|
-
lastMs: number;
|
|
35
|
-
};
|
|
36
|
-
export declare const _resetAsyncStateForTests: () => void;
|
|
37
|
-
export declare const cleanupAllRevalidateHandlers: () => void;
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
export type AsyncStateSnapshot = {
|
|
2
|
-
data?: unknown;
|
|
3
|
-
loading: boolean;
|
|
4
|
-
error: string | null;
|
|
5
|
-
status: "idle" | "loading" | "success" | "error" | "aborted";
|
|
6
|
-
cached?: boolean;
|
|
7
|
-
revalidating?: boolean;
|
|
8
|
-
};
|
|
9
|
-
export type AsyncStateAdapter = (ctx: {
|
|
10
|
-
name: string;
|
|
11
|
-
prev: unknown;
|
|
12
|
-
next: AsyncStateSnapshot;
|
|
13
|
-
set: (value: unknown | ((draft: any) => void)) => void;
|
|
14
|
-
}) => void;
|
|
15
|
-
export interface FetchOptions {
|
|
16
|
-
transform?: (result: unknown) => unknown;
|
|
17
|
-
onSuccess?: (data: unknown) => void;
|
|
18
|
-
onError?: (message: string) => void;
|
|
19
|
-
/**
|
|
20
|
-
* Optional adapter to write async state into a custom store shape.
|
|
21
|
-
* When provided, default AsyncState writes are skipped.
|
|
22
|
-
*/
|
|
23
|
-
stateAdapter?: AsyncStateAdapter;
|
|
24
|
-
method?: string;
|
|
25
|
-
headers?: Record<string, string>;
|
|
26
|
-
body?: unknown;
|
|
27
|
-
ttl?: number;
|
|
28
|
-
staleWhileRevalidate?: boolean;
|
|
29
|
-
dedupe?: boolean;
|
|
30
|
-
retry?: number;
|
|
31
|
-
retryDelay?: number;
|
|
32
|
-
retryBackoff?: number;
|
|
33
|
-
signal?: AbortSignal;
|
|
34
|
-
cacheKey?: string;
|
|
35
|
-
responseType?: "auto" | "json" | "text" | "arrayBuffer" | "blob" | "formData";
|
|
36
|
-
/**
|
|
37
|
-
* Auto-create the backing store if missing.
|
|
38
|
-
* Defaults to the global config setting (true by default).
|
|
39
|
-
*/
|
|
40
|
-
autoCreate?: boolean;
|
|
41
|
-
/**
|
|
42
|
-
* Clone strategy for transformed results.
|
|
43
|
-
* - "none" (default): store by reference.
|
|
44
|
-
* - "shallow": shallow clone objects/arrays.
|
|
45
|
-
* - "deep": deep clone objects/arrays.
|
|
46
|
-
*/
|
|
47
|
-
cloneResult?: "none" | "shallow" | "deep";
|
|
48
|
-
}
|
|
49
|
-
type InflightEntry = {
|
|
50
|
-
promise: Promise<unknown>;
|
|
51
|
-
raw: Promise<unknown>;
|
|
52
|
-
transform?: FetchOptions["transform"];
|
|
53
|
-
};
|
|
54
|
-
export type AsyncRegistry = {
|
|
55
|
-
fetchRegistry: Record<string, {
|
|
56
|
-
kind: "url";
|
|
57
|
-
url: string;
|
|
58
|
-
options: FetchOptions;
|
|
59
|
-
} | {
|
|
60
|
-
kind: "factory";
|
|
61
|
-
factory: () => string | Promise<unknown>;
|
|
62
|
-
options: FetchOptions;
|
|
63
|
-
}>;
|
|
64
|
-
inflight: Partial<Record<string, InflightEntry>>;
|
|
65
|
-
requestVersion: Record<string, number>;
|
|
66
|
-
cacheMeta: Record<string, {
|
|
67
|
-
timestamp: number;
|
|
68
|
-
expiresAt: number | null;
|
|
69
|
-
data: unknown;
|
|
70
|
-
}>;
|
|
71
|
-
rateWindowStart: Record<string, number>;
|
|
72
|
-
rateCount: Record<string, number>;
|
|
73
|
-
ratePruneState: {
|
|
74
|
-
lastAt: number;
|
|
75
|
-
};
|
|
76
|
-
ratePruneTimer: ReturnType<typeof setTimeout> | null;
|
|
77
|
-
noSignalWarned: Set<string>;
|
|
78
|
-
shapeWarned: Set<string>;
|
|
79
|
-
autoCreateWarned: Set<string>;
|
|
80
|
-
cleanupSubs: Record<string, () => void>;
|
|
81
|
-
storeCleanupFns: Record<string, Set<() => void>>;
|
|
82
|
-
revalidateKeys: Set<string>;
|
|
83
|
-
revalidateHandlers: Record<string, () => void>;
|
|
84
|
-
asyncMetrics: {
|
|
85
|
-
cacheHits: number;
|
|
86
|
-
cacheMisses: number;
|
|
87
|
-
dedupes: number;
|
|
88
|
-
requests: number;
|
|
89
|
-
failures: number;
|
|
90
|
-
avgMs: number;
|
|
91
|
-
lastMs: number;
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
export declare const createAsyncRegistry: () => AsyncRegistry;
|
|
95
|
-
export declare const resetAsyncRegistry: (registry: AsyncRegistry) => void;
|
|
96
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare const MAX_RETRY_ATTEMPTS = 10;
|
|
2
|
-
export declare const MIN_RETRY_DELAY_MS = 10;
|
|
3
|
-
export declare const MAX_RETRY_DELAY_MS = 30000;
|
|
4
|
-
export declare const MAX_RETRY_BACKOFF = 8;
|
|
5
|
-
export declare const delay: (ms: number, signal?: AbortSignal) => Promise<void>;
|
|
6
|
-
export declare const normalizeRetryOptions: (name: string, retry: number, retryDelay: number, retryBackoff: number) => {
|
|
7
|
-
retry: number;
|
|
8
|
-
retryDelay: number;
|
|
9
|
-
retryBackoff: number;
|
|
10
|
-
};
|
package/dist/types/async.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module computed-graph
|
|
3
|
-
*
|
|
4
|
-
* LAYER: Internal graph engine
|
|
5
|
-
* OWNS: Dependency tracking, cycle detection, topological ordering,
|
|
6
|
-
* computed entry CRUD. Zero React. Zero async.
|
|
7
|
-
*
|
|
8
|
-
* Consumers: computed.ts (public API), store-notify.ts (flush ordering),
|
|
9
|
-
* store-admin.ts (cleanup on delete), runtime-tools.ts (diagnostics)
|
|
10
|
-
*/
|
|
11
|
-
import { type ComputedEntry } from "./store-registry.js";
|
|
12
|
-
export declare const detectCycle: (name: string, deps: string[]) => string | null;
|
|
13
|
-
export declare const registerComputed: (name: string, deps: string[], compute: (...args: unknown[]) => unknown) => boolean;
|
|
14
|
-
export declare const unregisterComputed: (name: string) => void;
|
|
15
|
-
export declare const markStale: (name: string) => void;
|
|
16
|
-
export declare const isComputed: (name: string) => boolean;
|
|
17
|
-
export declare const getComputedEntry: (name: string) => ComputedEntry | undefined;
|
|
18
|
-
export declare const getTopoOrderedComputeds: (changedSources: string[]) => string[];
|
|
19
|
-
export declare const getFullComputedGraph: () => {
|
|
20
|
-
nodes: string[];
|
|
21
|
-
edges: Array<{
|
|
22
|
-
from: string;
|
|
23
|
-
to: string;
|
|
24
|
-
}>;
|
|
25
|
-
dependencies: Record<string, string[]>;
|
|
26
|
-
dependents: Record<string, string[]>;
|
|
27
|
-
};
|
|
28
|
-
export declare const getComputedDepsFor: (name: string) => {
|
|
29
|
-
deps: string[];
|
|
30
|
-
dependents: string[];
|
|
31
|
-
} | null;
|
package/dist/types/computed.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { StoreDefinition, StoreKey, StoreName, StateFor, StoreValue } from "./store-lifecycle.js";
|
|
2
|
-
export type ComputedOptions = {
|
|
3
|
-
autoDispose?: boolean;
|
|
4
|
-
onError?: (err: unknown) => void;
|
|
5
|
-
};
|
|
6
|
-
type DepHandle = StoreDefinition<string, StoreValue> | StoreKey<string, StoreValue>;
|
|
7
|
-
type DepValue<T> = T extends StoreDefinition<string, infer S> ? Readonly<S> | null : T extends StoreKey<string, infer S> ? Readonly<S> | null : T extends StoreName ? Readonly<StateFor<T>> | null : StoreValue | null;
|
|
8
|
-
export declare function createComputed<TResult, Deps extends readonly (StoreName | DepHandle)[]>(name: string, deps: Deps, compute: (...args: {
|
|
9
|
-
[K in keyof Deps]: DepValue<Deps[K]>;
|
|
10
|
-
}) => TResult, options?: ComputedOptions): StoreDefinition<string, TResult> | undefined;
|
|
11
|
-
export declare const invalidateComputed: (name: string) => void;
|
|
12
|
-
export declare const deleteComputed: (name: string) => void;
|
|
13
|
-
export declare const isComputedStore: (name: string) => boolean;
|
|
14
|
-
export declare const _resetComputedForTests: () => void;
|
|
15
|
-
export {};
|
package/dist/types/config.d.ts
DELETED
package/dist/types/core.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./index.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const devDeepFreeze: <T>(value: T) => T;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import type { NormalizedOptions, StoreValue } from "./adapters/options.js";
|
|
2
|
-
export type FeatureName = "persist" | "sync" | "devtools";
|
|
3
|
-
export interface FeatureMetrics {
|
|
4
|
-
notifyCount: number;
|
|
5
|
-
totalNotifyMs: number;
|
|
6
|
-
lastNotifyMs: number;
|
|
7
|
-
}
|
|
8
|
-
export interface StoreFeatureMeta {
|
|
9
|
-
createdAt: string;
|
|
10
|
-
updatedAt: string;
|
|
11
|
-
updatedAtMs: number;
|
|
12
|
-
updateCount: number;
|
|
13
|
-
version: number;
|
|
14
|
-
metrics: FeatureMetrics;
|
|
15
|
-
options: NormalizedOptions;
|
|
16
|
-
}
|
|
17
|
-
export interface BaseFeatureContext {
|
|
18
|
-
name: string;
|
|
19
|
-
options: NormalizedOptions;
|
|
20
|
-
getMeta: () => StoreFeatureMeta | undefined;
|
|
21
|
-
getStoreValue: () => StoreValue;
|
|
22
|
-
getAllStores: () => Record<string, StoreValue>;
|
|
23
|
-
getInitialState: () => StoreValue;
|
|
24
|
-
hasStore: () => boolean;
|
|
25
|
-
setStoreValue: (value: StoreValue) => void;
|
|
26
|
-
applyFeatureState: (value: StoreValue, updatedAtMs?: number) => void;
|
|
27
|
-
notify: () => void;
|
|
28
|
-
reportStoreError: (message: string) => void;
|
|
29
|
-
warn: (message: string) => void;
|
|
30
|
-
log: (message: string) => void;
|
|
31
|
-
hashState: (value: unknown) => number;
|
|
32
|
-
deepClone: <T>(value: T) => T;
|
|
33
|
-
sanitize: (value: unknown) => unknown;
|
|
34
|
-
validate: (next: StoreValue) => {
|
|
35
|
-
ok: boolean;
|
|
36
|
-
value?: StoreValue;
|
|
37
|
-
};
|
|
38
|
-
isDev: () => boolean;
|
|
39
|
-
}
|
|
40
|
-
export interface FeatureCreateContext extends BaseFeatureContext {
|
|
41
|
-
}
|
|
42
|
-
export interface FeatureWriteContext extends BaseFeatureContext {
|
|
43
|
-
action: string;
|
|
44
|
-
prev: StoreValue;
|
|
45
|
-
next: StoreValue;
|
|
46
|
-
}
|
|
47
|
-
export interface FeatureDeleteContext extends BaseFeatureContext {
|
|
48
|
-
prev: StoreValue;
|
|
49
|
-
}
|
|
50
|
-
export interface DevtoolsFeatureApi {
|
|
51
|
-
getHistory?: (name: string, limit?: number) => unknown[];
|
|
52
|
-
clearHistory?: (name?: string) => void;
|
|
53
|
-
getPersistQueueDepth?: (name: string) => number;
|
|
54
|
-
}
|
|
55
|
-
export interface StoreFeatureRuntime {
|
|
56
|
-
onStoreCreate?: (ctx: FeatureCreateContext) => void;
|
|
57
|
-
onStoreWrite?: (ctx: FeatureWriteContext) => void;
|
|
58
|
-
beforeStoreDelete?: (ctx: FeatureDeleteContext) => void;
|
|
59
|
-
afterStoreDelete?: (ctx: FeatureDeleteContext) => void;
|
|
60
|
-
resetAll?: () => void;
|
|
61
|
-
api?: DevtoolsFeatureApi;
|
|
62
|
-
}
|
|
63
|
-
export type StoreFeatureFactory = () => StoreFeatureRuntime;
|
|
64
|
-
export declare const registerStoreFeature: (name: FeatureName, factory: StoreFeatureFactory) => void;
|
|
65
|
-
export declare const hasRegisteredStoreFeature: (name: FeatureName) => boolean;
|
|
66
|
-
export declare const getStoreFeatureFactory: (name: FeatureName) => StoreFeatureFactory | undefined;
|
|
67
|
-
export declare const getRegisteredFeatureNames: () => FeatureName[];
|
|
68
|
-
export declare const setFeatureRegistrationHook: (hook: ((name: FeatureName, factory: StoreFeatureFactory) => void) | null) => void;
|
|
69
|
-
export declare const resetRegisteredStoreFeaturesForTests: () => void;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { StoreValue } from "../adapters/options.js";
|
|
2
|
-
export declare const MIDDLEWARE_ABORT: unique symbol;
|
|
3
|
-
export type LifecycleIssueReporter = (message: string, visibility?: "dev" | "always") => void;
|
|
4
|
-
export declare const runMiddleware: ({ name, payload, middlewares, reportIssue, warn, }: {
|
|
5
|
-
name: string;
|
|
6
|
-
payload: {
|
|
7
|
-
action: string;
|
|
8
|
-
prev: StoreValue;
|
|
9
|
-
next: StoreValue;
|
|
10
|
-
path: unknown;
|
|
11
|
-
};
|
|
12
|
-
middlewares: Array<(ctx: {
|
|
13
|
-
action: string;
|
|
14
|
-
name: string;
|
|
15
|
-
prev: StoreValue;
|
|
16
|
-
next: StoreValue;
|
|
17
|
-
path: unknown;
|
|
18
|
-
}) => StoreValue | void>;
|
|
19
|
-
reportIssue: LifecycleIssueReporter;
|
|
20
|
-
warn: (message: string) => void;
|
|
21
|
-
}) => StoreValue | typeof MIDDLEWARE_ABORT;
|
|
22
|
-
export declare const runStoreHook: ({ name, label, fn, args, reportIssue, }: {
|
|
23
|
-
name: string;
|
|
24
|
-
label: "onCreate" | "onSet" | "onReset" | "onDelete";
|
|
25
|
-
fn: ((...args: any[]) => void) | undefined;
|
|
26
|
-
args: any[];
|
|
27
|
-
reportIssue: LifecycleIssueReporter;
|
|
28
|
-
}) => void;
|
package/dist/types/index.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { createStore, createStoreStrict, setStore, setStoreBatch, getStore, deleteStore, resetStore, hasStore, hydrateStores, } from "./store.js";
|
|
2
|
-
export { createComputed, invalidateComputed, deleteComputed, isComputedStore, } from "./computed.js";
|
|
3
|
-
export { namespace, store } from "./store.js";
|
|
4
|
-
export type { Path, PathValue, PartialDeep, StoreDefinition, StoreValue, StoreKey, StoreName, StateFor, StoreStateMap, StrictStoreMap, WriteResult, PersistOptions, StoreOptions, SyncOptions, } from "./store.js";
|
|
5
|
-
export { configureStroid } from "./config.js";
|
|
6
|
-
export * as queryIntegrations from "./integrations/query.js";
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { FetchInput, FetchOptions } from "../async-cache.js";
|
|
2
|
-
import type { StoreDefinition, StoreKey, StoreName } from "../store-lifecycle.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 {};
|