coaction 2.1.0 → 3.1.0

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/dist/index.d.mts CHANGED
@@ -2,6 +2,12 @@ import { Transport } from "data-transport";
2
2
  import { Draft, Patches } from "mutative";
3
3
  import { computed, effect, effectScope, endBatch, isComputed, isEffect, isEffectScope, isSignal, signal, startBatch, trigger } from "alien-signals";
4
4
 
5
+ //#region packages/core/src/jsonTypes.d.ts
6
+ type JsonPrimitive = null | boolean | number | string;
7
+ type JsonValue = JsonPrimitive | JsonValue[] | {
8
+ [key: string]: JsonValue;
9
+ };
10
+ //#endregion
5
11
  //#region packages/core/src/interface.d.ts
6
12
  /**
7
13
  * Generic object shape used by stores and slices.
@@ -156,6 +162,22 @@ interface Store<T extends ISlices = ISlices> {
156
162
  * `MiddlewareStore` instead of relying on deprecated `patch` or `trace` hooks.
157
163
  */
158
164
  interface MiddlewareStore<T extends ISlices = ISlices> extends Store<T> {}
165
+ type TransportPolicyRequest = {
166
+ action: readonly string[];
167
+ args: readonly JsonValue[];
168
+ type: 'execute';
169
+ } | {
170
+ type: 'fullSync';
171
+ };
172
+ type TransportPolicy = {
173
+ /** Further restrict action paths declared by the authoritative store. */allowedActions?: readonly (readonly string[])[]; /** Authorize a decoded JSON request before serving it. */
174
+ authorize?: (request: TransportPolicyRequest) => boolean | Promise<boolean>;
175
+ /**
176
+ * Map a caught execute error to an explicitly client-visible message.
177
+ * Returning `undefined` keeps the generic redacted message.
178
+ */
179
+ mapError?: (error: unknown, request: TransportPolicyRequest) => string | undefined | Promise<string | undefined>;
180
+ };
159
181
  /**
160
182
  * Helper passed into {@link Slice} and {@link Slices} factories.
161
183
  *
@@ -243,7 +265,8 @@ type StoreOptions<T extends CreateState> = {
243
265
  /**
244
266
  * Inject a pre-built transport for advanced shared-store setups.
245
267
  */
246
- transport?: Transport;
268
+ transport?: Transport; /** Restrict requests accepted by a shared-main store. */
269
+ transportPolicy?: TransportPolicy;
247
270
  /**
248
271
  * Middleware chain applied before the initial state is finalized.
249
272
  */
@@ -379,204 +402,26 @@ type Creator = {
379
402
  * a shared store.
380
403
  *
381
404
  * @remarks
382
- * - Pass a {@link Slice} function for a single store.
383
- * - Pass an object of slice factories for a slices store.
384
- * - When an object input only contains functions, prefer explicit `sliceMode`
385
- * to avoid ambiguous inference.
386
- * - When `clientTransport` or `worker` is provided, returned store methods
387
- * become promise-returning methods because execution happens on the main
388
- * shared store.
389
- * - New semantics should prefer explicit helpers or variants over adding more
390
- * ambiguous `create()` input forms.
405
+ * Prefer the static `coaction/local` entry when transport support is not
406
+ * required. It excludes the JSON protocol and reconnect runtime from the
407
+ * consumer dependency graph.
391
408
  */
392
409
  declare const create: Creator;
393
410
  //#endregion
394
- //#region packages/core/src/internal.d.ts
395
- type MutationOperation = 'setState' | 'apply';
396
- type StoreOperation = MutationOperation | 'subscribe' | `action ${string}`;
397
- type SignalSlot = {
398
- refresh: () => void;
399
- };
400
- type StateSchema = {
401
- rootKeys: Set<PropertyKey>;
402
- sliceKeys?: Map<PropertyKey, Set<PropertyKey>>;
403
- };
404
- interface Internal<T extends CreateState = CreateState> {
405
- /**
406
- * The store module.
407
- */
408
- module: T;
409
- /**
410
- * The root state.
411
- */
412
- rootState: T | Draft<T>;
413
- /**
414
- * The backup state.
415
- */
416
- backupState: T | Draft<T>;
417
- /**
418
- * Finalize the draft.
419
- */
420
- finalizeDraft: () => [T, Patches, Patches];
421
- /**
422
- * The mutable instance.
423
- */
424
- mutableInstance: any;
425
- /**
426
- * The sequence number.
427
- */
428
- sequence: number;
429
- /**
430
- * Whether the batch is running.
431
- */
432
- isBatching: boolean;
433
- /**
434
- * The listeners.
435
- */
436
- listeners: Set<Listener>;
437
- /**
438
- * Publish an externally-owned immutable state change to signal slots and
439
- * store subscribers.
440
- */
441
- notifyStateChange: () => void;
442
- /**
443
- * Reactive state slots used by computed getters/selectors.
444
- */
445
- signalSlots?: Set<SignalSlot>;
446
- /**
447
- * State keys that are allowed after initialization.
448
- */
449
- stateSchema?: StateSchema;
450
- /**
451
- * The act is used to run the function in the action for mutable state.
452
- */
453
- actMutable?: <T extends () => any>(fn: T) => ReturnType<T>;
454
- /**
455
- * Get the mutable raw instance via the initial state.
456
- */
457
- toMutableRaw?: (key: any) => any;
458
- /**
459
- * The update immutable function.
460
- */
461
- updateImmutable?: (state: T) => void;
462
- /**
463
- * Adapter-level authority check for low-level mutations.
464
- */
465
- assertMutationAllowed?: (operation: MutationOperation) => void;
466
- /**
467
- * Store lifecycle guard.
468
- */
469
- assertAlive?: (operation: StoreOperation) => void;
470
- /**
471
- * Authorized client-mirror state application used by transports.
472
- */
473
- applyClientState?: (state?: T, patches?: Patches) => void;
474
- }
475
- //#endregion
476
- //#region packages/core/src/binder.d.ts
477
- type ExternalStoreAdapterOptions<F = (...args: any[]) => any> = {
478
- /**
479
- * Normalize a third-party store instance into a raw state object plus the
480
- * binding hook used during initialization.
481
- */
482
- handleState: <T extends object = object>(state: T) => {
483
- /**
484
- * Copy of the incoming state object that Coaction should consume.
485
- */
486
- copyState: T;
487
- /**
488
- * Optional nested key when the adapter exposes a single child object from
489
- * the third-party store.
490
- */
491
- key?: keyof T;
492
- /**
493
- * Convert the external state object into the raw state shape used by
494
- * Coaction.
495
- */
496
- bind: (state: T) => T;
497
- };
498
- /**
499
- * Wire Coaction's store lifecycle to the external store implementation.
500
- */
501
- handleStore: (
502
- /**
503
- * Coaction store wrapper.
504
- */
505
-
506
- store: Store<object>,
507
- /**
508
- * Raw state object returned from `bind`.
509
- */
510
-
511
- rawState: object,
512
- /**
513
- * Original external store state object.
514
- */
515
-
516
- state: object,
517
- /**
518
- * Low-level Coaction adapter hooks used by official bindings.
519
- */
520
-
521
- internal: Internal<object>,
522
- /**
523
- * Optional nested key returned by `handleState`.
524
- */
525
-
526
- key?: PropertyKey) => void;
527
- };
411
+ //#region packages/core/src/getRawStateClientAction.d.ts
528
412
  /**
529
- * Build an adapter helper for bridging an external store implementation into
530
- * Coaction.
531
- *
532
- * @remarks
533
- * Official bindings use this to integrate stores such as Redux, Jotai, Pinia,
534
- * Zustand, MobX, and Valtio. Binder-backed integrations are whole-store
535
- * adapters; they are not compatible with Coaction slices mode.
536
- */
537
- declare function createBinder<F = (...args: any[]) => any>({
538
- handleState,
539
- handleStore
540
- }: ExternalStoreAdapterOptions<F>): F;
541
- /**
542
- * Define a whole-store adapter for integrating an external state runtime with
543
- * Coaction.
544
- *
545
- * @remarks
546
- * This is the stable 2.x name for adapter authors. `createBinder()` remains as
547
- * a compatibility alias for existing official and community integrations.
413
+ * The authority changed while a remote action was in flight, so its side-effect
414
+ * outcome cannot be determined safely from the current client mirror.
548
415
  */
549
- declare function defineExternalStoreAdapter<F = (...args: any[]) => any>(options: ExternalStoreAdapterOptions<F>): F;
416
+ declare class ActionAuthorityChangedError extends Error {
417
+ readonly code = "COACTION_ACTION_AUTHORITY_CHANGED";
418
+ readonly outcome = "unknown";
419
+ constructor(action: string);
420
+ }
550
421
  //#endregion
551
422
  //#region packages/core/src/lifecycle.d.ts
552
423
  declare const onStoreReady: <T extends CreateState>(store: Store<T>, callback: () => void) => () => void;
553
424
  //#endregion
554
- //#region packages/core/src/reactiveTracker.d.ts
555
- type ReactiveTracker = {
556
- getSnapshot: () => number;
557
- subscribe: (listener: () => void) => () => void;
558
- track: <T>(fn: () => T) => T;
559
- dispose: () => void;
560
- };
561
- declare const createReactiveTracker: () => ReactiveTracker;
562
- //#endregion
563
- //#region packages/core/src/replaceExternalStoreState.d.ts
564
- type ReplaceExternalStoreStateOptions = {
565
- syncImmutable?: boolean;
566
- };
567
- declare const replaceExternalStoreState: <T extends CreateState>(store: MiddlewareStore<T>, internal: Internal<T>, source: Record<PropertyKey, unknown>, {
568
- syncImmutable
569
- }?: ReplaceExternalStoreStateOptions) => void;
570
- //#endregion
571
- //#region packages/core/src/externalMutableAdapterUtils.d.ts
572
- declare const getMutableAdapterOwnEnumerableKeys: (value: object) => (string | symbol)[];
573
- declare const isMutableAdapterUnsafeKey: (key: PropertyKey) => key is "__proto__" | "prototype" | "constructor";
574
- declare const replaceMutableAdapterState: (rawState: Record<PropertyKey, unknown>, mutableState: Record<PropertyKey, unknown>, publicState: Record<PropertyKey, unknown>, source: Record<PropertyKey, unknown>) => void;
575
- declare const applyMutableAdapterPatches: (baseState: unknown, patches: Patches, rawState: Record<PropertyKey, unknown>, mutableState: Record<PropertyKey, unknown>, publicState: Record<PropertyKey, unknown>) => void;
576
- declare const toMutableAdapterSnapshot: (value: unknown, visited?: WeakMap<object, unknown>) => unknown;
577
- declare const snapshotMutableAdapterPureState: (store: Store<object>) => Record<PropertyKey, unknown>;
578
- declare const isEqualMutableAdapterSnapshot: (left: unknown, right: unknown, visited?: WeakMap<object, WeakSet<object>>) => boolean;
579
- //#endregion
580
425
  //#region packages/core/src/utils.d.ts
581
426
  declare class UnsafePatchPathError extends Error {
582
427
  name: string;
@@ -595,32 +440,7 @@ declare const sanitizePatches: <T extends {
595
440
  source?: string;
596
441
  warnOnDropped?: boolean;
597
442
  }) => T[] | undefined;
598
- type RootReplacementPatch = {
599
- op: 'add' | 'remove' | 'replace';
600
- path: PropertyKey[];
601
- value?: unknown;
602
- };
603
- declare const createRootReplacementPatches: (currentState: Record<PropertyKey, unknown>, nextState: Record<PropertyKey, unknown>) => {
604
- patches: RootReplacementPatch[];
605
- inversePatches: RootReplacementPatch[];
606
- };
607
- declare const applyRootReplacementWithPatches: <T extends object>(store: MiddlewareStore<T>, nextState: Record<PropertyKey, unknown>, options?: {
608
- applyExactReplacement?: (state: T) => void;
609
- }) => [T, Patches, Patches];
610
- declare const replaceOwnEnumerable: (target: Record<PropertyKey, unknown>, source: Record<PropertyKey, unknown>) => void;
611
443
  declare const sanitizeReplacementState: <T>(source: T, seen?: WeakMap<object, unknown>) => T;
612
444
  declare const sanitizeInitialStateValue: <T>(source: T, seen?: WeakMap<object, unknown>) => T;
613
445
  //#endregion
614
- //#region packages/core/src/wrapStore.d.ts
615
- /**
616
- * Convert a store object into Coaction's callable store shape.
617
- *
618
- * @remarks
619
- * Framework bindings use this to attach selector-aware readers while
620
- * preserving the underlying store API on the returned function object. Most
621
- * applications should call {@link create} instead of using `wrapStore()`
622
- * directly.
623
- */
624
- declare const wrapStore: <T extends object>(store: Store<T>, getState?: (...args: unknown[]) => T) => StoreReturn<T>;
625
- //#endregion
626
- export { type StoreWithAsyncFunction as AsyncStore, type Asyncify, type ClientStoreOptions, type ExternalStoreAdapterOptions, type ISlices, type Middleware, type MiddlewareStore, type PatchTransform, type ReactiveTracker, type Slice, type SliceState, type Slices, StateSchemaError, type Store, type StoreOptions, type StoreTraceEvent, UnsafePatchPathError, applyMutableAdapterPatches, applyRootReplacementWithPatches, assertSafePatches, computed, create, createBinder, createReactiveTracker, createRootReplacementPatches, defineExternalStoreAdapter, effect, effectScope, endBatch, getMutableAdapterOwnEnumerableKeys, isComputed, isEffect, isEffectScope, isEqualMutableAdapterSnapshot, isMutableAdapterUnsafeKey, isSignal, isStateSchemaError, onStoreReady, replaceExternalStoreState, replaceMutableAdapterState, replaceOwnEnumerable, sanitizeInitialStateValue, sanitizePatches, sanitizeReplacementState, signal, snapshotMutableAdapterPureState, startBatch, toMutableAdapterSnapshot, trigger, wrapStore };
446
+ export { ActionAuthorityChangedError, type StoreWithAsyncFunction as AsyncStore, type Asyncify, type ClientStoreOptions, type ISlices, type JsonPrimitive, type JsonValue, type Middleware, type MiddlewareStore, type PatchTransform, type Slice, type SliceState, type Slices, StateSchemaError, type Store, type StoreOptions, type StoreTraceEvent, type TransportPolicy, type TransportPolicyRequest, UnsafePatchPathError, assertSafePatches, computed, create, effect, effectScope, endBatch, isComputed, isEffect, isEffectScope, isSignal, isStateSchemaError, onStoreReady, sanitizeInitialStateValue, sanitizePatches, sanitizeReplacementState, signal, startBatch, trigger };
package/dist/index.d.ts CHANGED
@@ -2,6 +2,12 @@ import { Transport } from "data-transport";
2
2
  import { Draft, Patches } from "mutative";
3
3
  import { computed, effect, effectScope, endBatch, isComputed, isEffect, isEffectScope, isSignal, signal, startBatch, trigger } from "alien-signals";
4
4
 
5
+ //#region packages/core/src/jsonTypes.d.ts
6
+ type JsonPrimitive = null | boolean | number | string;
7
+ type JsonValue = JsonPrimitive | JsonValue[] | {
8
+ [key: string]: JsonValue;
9
+ };
10
+ //#endregion
5
11
  //#region packages/core/src/interface.d.ts
6
12
  /**
7
13
  * Generic object shape used by stores and slices.
@@ -156,6 +162,22 @@ interface Store<T extends ISlices = ISlices> {
156
162
  * `MiddlewareStore` instead of relying on deprecated `patch` or `trace` hooks.
157
163
  */
158
164
  interface MiddlewareStore<T extends ISlices = ISlices> extends Store<T> {}
165
+ type TransportPolicyRequest = {
166
+ action: readonly string[];
167
+ args: readonly JsonValue[];
168
+ type: 'execute';
169
+ } | {
170
+ type: 'fullSync';
171
+ };
172
+ type TransportPolicy = {
173
+ /** Further restrict action paths declared by the authoritative store. */allowedActions?: readonly (readonly string[])[]; /** Authorize a decoded JSON request before serving it. */
174
+ authorize?: (request: TransportPolicyRequest) => boolean | Promise<boolean>;
175
+ /**
176
+ * Map a caught execute error to an explicitly client-visible message.
177
+ * Returning `undefined` keeps the generic redacted message.
178
+ */
179
+ mapError?: (error: unknown, request: TransportPolicyRequest) => string | undefined | Promise<string | undefined>;
180
+ };
159
181
  /**
160
182
  * Helper passed into {@link Slice} and {@link Slices} factories.
161
183
  *
@@ -243,7 +265,8 @@ type StoreOptions<T extends CreateState> = {
243
265
  /**
244
266
  * Inject a pre-built transport for advanced shared-store setups.
245
267
  */
246
- transport?: Transport;
268
+ transport?: Transport; /** Restrict requests accepted by a shared-main store. */
269
+ transportPolicy?: TransportPolicy;
247
270
  /**
248
271
  * Middleware chain applied before the initial state is finalized.
249
272
  */
@@ -379,204 +402,26 @@ type Creator = {
379
402
  * a shared store.
380
403
  *
381
404
  * @remarks
382
- * - Pass a {@link Slice} function for a single store.
383
- * - Pass an object of slice factories for a slices store.
384
- * - When an object input only contains functions, prefer explicit `sliceMode`
385
- * to avoid ambiguous inference.
386
- * - When `clientTransport` or `worker` is provided, returned store methods
387
- * become promise-returning methods because execution happens on the main
388
- * shared store.
389
- * - New semantics should prefer explicit helpers or variants over adding more
390
- * ambiguous `create()` input forms.
405
+ * Prefer the static `coaction/local` entry when transport support is not
406
+ * required. It excludes the JSON protocol and reconnect runtime from the
407
+ * consumer dependency graph.
391
408
  */
392
409
  declare const create: Creator;
393
410
  //#endregion
394
- //#region packages/core/src/internal.d.ts
395
- type MutationOperation = 'setState' | 'apply';
396
- type StoreOperation = MutationOperation | 'subscribe' | `action ${string}`;
397
- type SignalSlot = {
398
- refresh: () => void;
399
- };
400
- type StateSchema = {
401
- rootKeys: Set<PropertyKey>;
402
- sliceKeys?: Map<PropertyKey, Set<PropertyKey>>;
403
- };
404
- interface Internal<T extends CreateState = CreateState> {
405
- /**
406
- * The store module.
407
- */
408
- module: T;
409
- /**
410
- * The root state.
411
- */
412
- rootState: T | Draft<T>;
413
- /**
414
- * The backup state.
415
- */
416
- backupState: T | Draft<T>;
417
- /**
418
- * Finalize the draft.
419
- */
420
- finalizeDraft: () => [T, Patches, Patches];
421
- /**
422
- * The mutable instance.
423
- */
424
- mutableInstance: any;
425
- /**
426
- * The sequence number.
427
- */
428
- sequence: number;
429
- /**
430
- * Whether the batch is running.
431
- */
432
- isBatching: boolean;
433
- /**
434
- * The listeners.
435
- */
436
- listeners: Set<Listener>;
437
- /**
438
- * Publish an externally-owned immutable state change to signal slots and
439
- * store subscribers.
440
- */
441
- notifyStateChange: () => void;
442
- /**
443
- * Reactive state slots used by computed getters/selectors.
444
- */
445
- signalSlots?: Set<SignalSlot>;
446
- /**
447
- * State keys that are allowed after initialization.
448
- */
449
- stateSchema?: StateSchema;
450
- /**
451
- * The act is used to run the function in the action for mutable state.
452
- */
453
- actMutable?: <T extends () => any>(fn: T) => ReturnType<T>;
454
- /**
455
- * Get the mutable raw instance via the initial state.
456
- */
457
- toMutableRaw?: (key: any) => any;
458
- /**
459
- * The update immutable function.
460
- */
461
- updateImmutable?: (state: T) => void;
462
- /**
463
- * Adapter-level authority check for low-level mutations.
464
- */
465
- assertMutationAllowed?: (operation: MutationOperation) => void;
466
- /**
467
- * Store lifecycle guard.
468
- */
469
- assertAlive?: (operation: StoreOperation) => void;
470
- /**
471
- * Authorized client-mirror state application used by transports.
472
- */
473
- applyClientState?: (state?: T, patches?: Patches) => void;
474
- }
475
- //#endregion
476
- //#region packages/core/src/binder.d.ts
477
- type ExternalStoreAdapterOptions<F = (...args: any[]) => any> = {
478
- /**
479
- * Normalize a third-party store instance into a raw state object plus the
480
- * binding hook used during initialization.
481
- */
482
- handleState: <T extends object = object>(state: T) => {
483
- /**
484
- * Copy of the incoming state object that Coaction should consume.
485
- */
486
- copyState: T;
487
- /**
488
- * Optional nested key when the adapter exposes a single child object from
489
- * the third-party store.
490
- */
491
- key?: keyof T;
492
- /**
493
- * Convert the external state object into the raw state shape used by
494
- * Coaction.
495
- */
496
- bind: (state: T) => T;
497
- };
498
- /**
499
- * Wire Coaction's store lifecycle to the external store implementation.
500
- */
501
- handleStore: (
502
- /**
503
- * Coaction store wrapper.
504
- */
505
-
506
- store: Store<object>,
507
- /**
508
- * Raw state object returned from `bind`.
509
- */
510
-
511
- rawState: object,
512
- /**
513
- * Original external store state object.
514
- */
515
-
516
- state: object,
517
- /**
518
- * Low-level Coaction adapter hooks used by official bindings.
519
- */
520
-
521
- internal: Internal<object>,
522
- /**
523
- * Optional nested key returned by `handleState`.
524
- */
525
-
526
- key?: PropertyKey) => void;
527
- };
411
+ //#region packages/core/src/getRawStateClientAction.d.ts
528
412
  /**
529
- * Build an adapter helper for bridging an external store implementation into
530
- * Coaction.
531
- *
532
- * @remarks
533
- * Official bindings use this to integrate stores such as Redux, Jotai, Pinia,
534
- * Zustand, MobX, and Valtio. Binder-backed integrations are whole-store
535
- * adapters; they are not compatible with Coaction slices mode.
536
- */
537
- declare function createBinder<F = (...args: any[]) => any>({
538
- handleState,
539
- handleStore
540
- }: ExternalStoreAdapterOptions<F>): F;
541
- /**
542
- * Define a whole-store adapter for integrating an external state runtime with
543
- * Coaction.
544
- *
545
- * @remarks
546
- * This is the stable 2.x name for adapter authors. `createBinder()` remains as
547
- * a compatibility alias for existing official and community integrations.
413
+ * The authority changed while a remote action was in flight, so its side-effect
414
+ * outcome cannot be determined safely from the current client mirror.
548
415
  */
549
- declare function defineExternalStoreAdapter<F = (...args: any[]) => any>(options: ExternalStoreAdapterOptions<F>): F;
416
+ declare class ActionAuthorityChangedError extends Error {
417
+ readonly code = "COACTION_ACTION_AUTHORITY_CHANGED";
418
+ readonly outcome = "unknown";
419
+ constructor(action: string);
420
+ }
550
421
  //#endregion
551
422
  //#region packages/core/src/lifecycle.d.ts
552
423
  declare const onStoreReady: <T extends CreateState>(store: Store<T>, callback: () => void) => () => void;
553
424
  //#endregion
554
- //#region packages/core/src/reactiveTracker.d.ts
555
- type ReactiveTracker = {
556
- getSnapshot: () => number;
557
- subscribe: (listener: () => void) => () => void;
558
- track: <T>(fn: () => T) => T;
559
- dispose: () => void;
560
- };
561
- declare const createReactiveTracker: () => ReactiveTracker;
562
- //#endregion
563
- //#region packages/core/src/replaceExternalStoreState.d.ts
564
- type ReplaceExternalStoreStateOptions = {
565
- syncImmutable?: boolean;
566
- };
567
- declare const replaceExternalStoreState: <T extends CreateState>(store: MiddlewareStore<T>, internal: Internal<T>, source: Record<PropertyKey, unknown>, {
568
- syncImmutable
569
- }?: ReplaceExternalStoreStateOptions) => void;
570
- //#endregion
571
- //#region packages/core/src/externalMutableAdapterUtils.d.ts
572
- declare const getMutableAdapterOwnEnumerableKeys: (value: object) => (string | symbol)[];
573
- declare const isMutableAdapterUnsafeKey: (key: PropertyKey) => key is "__proto__" | "prototype" | "constructor";
574
- declare const replaceMutableAdapterState: (rawState: Record<PropertyKey, unknown>, mutableState: Record<PropertyKey, unknown>, publicState: Record<PropertyKey, unknown>, source: Record<PropertyKey, unknown>) => void;
575
- declare const applyMutableAdapterPatches: (baseState: unknown, patches: Patches, rawState: Record<PropertyKey, unknown>, mutableState: Record<PropertyKey, unknown>, publicState: Record<PropertyKey, unknown>) => void;
576
- declare const toMutableAdapterSnapshot: (value: unknown, visited?: WeakMap<object, unknown>) => unknown;
577
- declare const snapshotMutableAdapterPureState: (store: Store<object>) => Record<PropertyKey, unknown>;
578
- declare const isEqualMutableAdapterSnapshot: (left: unknown, right: unknown, visited?: WeakMap<object, WeakSet<object>>) => boolean;
579
- //#endregion
580
425
  //#region packages/core/src/utils.d.ts
581
426
  declare class UnsafePatchPathError extends Error {
582
427
  name: string;
@@ -595,32 +440,7 @@ declare const sanitizePatches: <T extends {
595
440
  source?: string;
596
441
  warnOnDropped?: boolean;
597
442
  }) => T[] | undefined;
598
- type RootReplacementPatch = {
599
- op: 'add' | 'remove' | 'replace';
600
- path: PropertyKey[];
601
- value?: unknown;
602
- };
603
- declare const createRootReplacementPatches: (currentState: Record<PropertyKey, unknown>, nextState: Record<PropertyKey, unknown>) => {
604
- patches: RootReplacementPatch[];
605
- inversePatches: RootReplacementPatch[];
606
- };
607
- declare const applyRootReplacementWithPatches: <T extends object>(store: MiddlewareStore<T>, nextState: Record<PropertyKey, unknown>, options?: {
608
- applyExactReplacement?: (state: T) => void;
609
- }) => [T, Patches, Patches];
610
- declare const replaceOwnEnumerable: (target: Record<PropertyKey, unknown>, source: Record<PropertyKey, unknown>) => void;
611
443
  declare const sanitizeReplacementState: <T>(source: T, seen?: WeakMap<object, unknown>) => T;
612
444
  declare const sanitizeInitialStateValue: <T>(source: T, seen?: WeakMap<object, unknown>) => T;
613
445
  //#endregion
614
- //#region packages/core/src/wrapStore.d.ts
615
- /**
616
- * Convert a store object into Coaction's callable store shape.
617
- *
618
- * @remarks
619
- * Framework bindings use this to attach selector-aware readers while
620
- * preserving the underlying store API on the returned function object. Most
621
- * applications should call {@link create} instead of using `wrapStore()`
622
- * directly.
623
- */
624
- declare const wrapStore: <T extends object>(store: Store<T>, getState?: (...args: unknown[]) => T) => StoreReturn<T>;
625
- //#endregion
626
- export { type StoreWithAsyncFunction as AsyncStore, type Asyncify, type ClientStoreOptions, type ExternalStoreAdapterOptions, type ISlices, type Middleware, type MiddlewareStore, type PatchTransform, type ReactiveTracker, type Slice, type SliceState, type Slices, StateSchemaError, type Store, type StoreOptions, type StoreTraceEvent, UnsafePatchPathError, applyMutableAdapterPatches, applyRootReplacementWithPatches, assertSafePatches, computed, create, createBinder, createReactiveTracker, createRootReplacementPatches, defineExternalStoreAdapter, effect, effectScope, endBatch, getMutableAdapterOwnEnumerableKeys, isComputed, isEffect, isEffectScope, isEqualMutableAdapterSnapshot, isMutableAdapterUnsafeKey, isSignal, isStateSchemaError, onStoreReady, replaceExternalStoreState, replaceMutableAdapterState, replaceOwnEnumerable, sanitizeInitialStateValue, sanitizePatches, sanitizeReplacementState, signal, snapshotMutableAdapterPureState, startBatch, toMutableAdapterSnapshot, trigger, wrapStore };
446
+ export { ActionAuthorityChangedError, type StoreWithAsyncFunction as AsyncStore, type Asyncify, type ClientStoreOptions, type ISlices, type JsonPrimitive, type JsonValue, type Middleware, type MiddlewareStore, type PatchTransform, type Slice, type SliceState, type Slices, StateSchemaError, type Store, type StoreOptions, type StoreTraceEvent, type TransportPolicy, type TransportPolicyRequest, UnsafePatchPathError, assertSafePatches, computed, create, effect, effectScope, endBatch, isComputed, isEffect, isEffectScope, isSignal, isStateSchemaError, onStoreReady, sanitizeInitialStateValue, sanitizePatches, sanitizeReplacementState, signal, startBatch, trigger };