applying transfer to react app

This commit is contained in:
Tyler Koenig
2021-09-20 16:54:47 -04:00
parent 8819f31dd0
commit c612b7d702
37373 changed files with 3775588 additions and 2871 deletions
+3
View File
@@ -0,0 +1,3 @@
/** Takes a snapshot of the current state of a draft and finalizes it (but without freezing). This is a great utility to print the current state during debugging (no Proxies in the way). The output of current can also be safely leaked outside the producer. */
export declare function current<T>(value: T): T;
//# sourceMappingURL=current.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"current.d.ts","sourceRoot":"","sources":["../src/core/current.ts"],"names":[],"mappings":"AAgBA,mQAAmQ;AACnQ,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAAA"}
+3
View File
@@ -0,0 +1,3 @@
import { ImmerScope } from "../internal";
export declare function processResult(result: any, scope: ImmerScope): any;
//# sourceMappingURL=finalize.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"finalize.d.ts","sourceRoot":"","sources":["../src/core/finalize.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,UAAU,EAoBV,MAAM,aAAa,CAAA;AAEpB,wBAAgB,aAAa,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,UAAU,OAiC3D"}
+53
View File
@@ -0,0 +1,53 @@
import { IProduceWithPatches, IProduce, ImmerState, Drafted, Patch, Objectish, Draft, PatchListener } from "../internal";
interface ProducersFns {
produce: IProduce;
produceWithPatches: IProduceWithPatches;
}
export declare class Immer implements ProducersFns {
useProxies_: boolean;
autoFreeze_: boolean;
constructor(config?: {
useProxies?: boolean;
autoFreeze?: boolean;
});
/**
* The `produce` function takes a value and a "recipe function" (whose
* return value often depends on the base state). The recipe function is
* free to mutate its first argument however it wants. All mutations are
* only ever applied to a __copy__ of the base state.
*
* Pass only a function to create a "curried producer" which relieves you
* from passing the recipe function every time.
*
* Only plain objects and arrays are made mutable. All other objects are
* considered uncopyable.
*
* Note: This function is __bound__ to its `Immer` instance.
*
* @param {any} base - the initial state
* @param {Function} producer - function that receives a proxy of the base state as first argument and which can be freely modified
* @param {Function} patchListener - optional function that will be called with all the patches produced here
* @returns {any} a new state, or the initial state if nothing was modified
*/
produce(base: any, recipe?: any, patchListener?: any): any;
produceWithPatches(arg1: any, arg2?: any, arg3?: any): any;
createDraft<T extends Objectish>(base: T): Draft<T>;
finishDraft<D extends Draft<any>>(draft: D, patchListener?: PatchListener): D extends Draft<infer T> ? T : never;
/**
* Pass true to automatically freeze all copies created by Immer.
*
* By default, auto-freezing is enabled.
*/
setAutoFreeze(value: boolean): void;
/**
* Pass true to use the ES2015 `Proxy` class when creating drafts, which is
* always faster than using ES5 proxies.
*
* By default, feature detection is used, so calling this is rarely necessary.
*/
setUseProxies(value: boolean): void;
applyPatches(base: Objectish, patches: Patch[]): any;
}
export declare function createProxy<T extends Objectish>(immer: Immer, value: T, parent?: ImmerState): Drafted<T, ImmerState>;
export {};
//# sourceMappingURL=immerClass.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"immerClass.d.ts","sourceRoot":"","sources":["../src/core/immerClass.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,mBAAmB,EACnB,QAAQ,EACR,UAAU,EACV,OAAO,EAGP,KAAK,EACL,SAAS,EAET,KAAK,EACL,aAAa,EAgBb,MAAM,aAAa,CAAA;AAEpB,UAAU,YAAY;IACrB,OAAO,EAAE,QAAQ,CAAA;IACjB,kBAAkB,EAAE,mBAAmB,CAAA;CACvC;AAED,qBAAa,KAAM,YAAW,YAAY;IACzC,WAAW,EAAE,OAAO,CAAa;IAEjC,WAAW,EAAE,OAAO,CAAO;gBAEf,MAAM,CAAC,EAAE;QAAC,UAAU,CAAC,EAAE,OAAO,CAAC;QAAC,UAAU,CAAC,EAAE,OAAO,CAAA;KAAC;IASjE;;;;;;;;;;;;;;;;;;OAkBG;IACH,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,aAAa,CAAC,EAAE,GAAG;IA0DpD,kBAAkB,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,GAAG;IAc1D,WAAW,CAAC,CAAC,SAAS,SAAS,EAAE,IAAI,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;IAUnD,WAAW,CAAC,CAAC,SAAS,KAAK,CAAC,GAAG,CAAC,EAC/B,KAAK,EAAE,CAAC,EACR,aAAa,CAAC,EAAE,aAAa,GAC3B,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK;IAWvC;;;;OAIG;IACH,aAAa,CAAC,KAAK,EAAE,OAAO;IAI5B;;;;;OAKG;IACH,aAAa,CAAC,KAAK,EAAE,OAAO;IAO5B,YAAY,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE;CAsB9C;AAED,wBAAgB,WAAW,CAAC,CAAC,SAAS,SAAS,EAC9C,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,CAAC,EACR,MAAM,CAAC,EAAE,UAAU,GACjB,OAAO,CAAC,CAAC,EAAE,UAAU,CAAC,CAaxB"}
+38
View File
@@ -0,0 +1,38 @@
import { ImmerBaseState, ImmerState, Drafted, AnyObject, AnyArray, Objectish, ProxyTypeProxyObject, ProxyTypeProxyArray } from "../internal";
interface ProxyBaseState extends ImmerBaseState {
assigned_: {
[property: string]: boolean;
};
parent_?: ImmerState;
revoke_(): void;
}
export interface ProxyObjectState extends ProxyBaseState {
type_: typeof ProxyTypeProxyObject;
base_: any;
copy_: any;
draft_: Drafted<AnyObject, ProxyObjectState>;
}
export interface ProxyArrayState extends ProxyBaseState {
type_: typeof ProxyTypeProxyArray;
base_: AnyArray;
copy_: AnyArray | null;
draft_: Drafted<AnyArray, ProxyArrayState>;
}
declare type ProxyState = ProxyObjectState | ProxyArrayState;
/**
* Returns a new draft of the `base` object.
*
* The second argument is the parent draft-state (used internally).
*/
export declare function createProxyProxy<T extends Objectish>(base: T, parent?: ImmerState): Drafted<T, ProxyState>;
/**
* Object drafts
*/
export declare const objectTraps: ProxyHandler<ProxyState>;
export declare function markChanged(state: ImmerState): void;
export declare function prepareCopy(state: {
base_: any;
copy_: any;
}): void;
export {};
//# sourceMappingURL=proxy.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../src/core/proxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAON,cAAc,EACd,UAAU,EACV,OAAO,EACP,SAAS,EACT,QAAQ,EACR,SAAS,EAKT,oBAAoB,EACpB,mBAAmB,EACnB,MAAM,aAAa,CAAA;AAEpB,UAAU,cAAe,SAAQ,cAAc;IAC9C,SAAS,EAAE;QACV,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAA;KAC3B,CAAA;IACD,OAAO,CAAC,EAAE,UAAU,CAAA;IACpB,OAAO,IAAI,IAAI,CAAA;CACf;AAED,MAAM,WAAW,gBAAiB,SAAQ,cAAc;IACvD,KAAK,EAAE,OAAO,oBAAoB,CAAA;IAClC,KAAK,EAAE,GAAG,CAAA;IACV,KAAK,EAAE,GAAG,CAAA;IACV,MAAM,EAAE,OAAO,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAA;CAC5C;AAED,MAAM,WAAW,eAAgB,SAAQ,cAAc;IACtD,KAAK,EAAE,OAAO,mBAAmB,CAAA;IACjC,KAAK,EAAE,QAAQ,CAAA;IACf,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAA;IACtB,MAAM,EAAE,OAAO,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAA;CAC1C;AAED,aAAK,UAAU,GAAG,gBAAgB,GAAG,eAAe,CAAA;AAEpD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,SAAS,EACnD,IAAI,EAAE,CAAC,EACP,MAAM,CAAC,EAAE,UAAU,GACjB,OAAO,CAAC,CAAC,EAAE,UAAU,CAAC,CA0CxB;AAED;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,YAAY,CAAC,UAAU,CAoGhD,CAAA;AAwDD,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,QAO5C;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE;IAAC,KAAK,EAAE,GAAG,CAAC;IAAC,KAAK,EAAE,GAAG,CAAA;CAAC,QAI1D"}
+18
View File
@@ -0,0 +1,18 @@
import { Patch, PatchListener, Immer } from "../internal";
/** Each scope represents a `produce` call. */
export interface ImmerScope {
patches_?: Patch[];
inversePatches_?: Patch[];
canAutoFreeze_: boolean;
drafts_: any[];
parent_?: ImmerScope;
patchListener_?: PatchListener;
immer_: Immer;
unfinalizedDrafts_: number;
}
export declare function getCurrentScope(): ImmerScope;
export declare function usePatchesInScope(scope: ImmerScope, patchListener?: PatchListener): void;
export declare function revokeScope(scope: ImmerScope): void;
export declare function leaveScope(scope: ImmerScope): void;
export declare function enterScope(immer: Immer): ImmerScope;
//# sourceMappingURL=scope.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../src/core/scope.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,EACL,aAAa,EAEb,KAAK,EAML,MAAM,aAAa,CAAA;AAGpB,8CAA8C;AAE9C,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,EAAE,KAAK,EAAE,CAAA;IAClB,eAAe,CAAC,EAAE,KAAK,EAAE,CAAA;IACzB,cAAc,EAAE,OAAO,CAAA;IACvB,OAAO,EAAE,GAAG,EAAE,CAAA;IACd,OAAO,CAAC,EAAE,UAAU,CAAA;IACpB,cAAc,CAAC,EAAE,aAAa,CAAA;IAC9B,MAAM,EAAE,KAAK,CAAA;IACb,kBAAkB,EAAE,MAAM,CAAA;CAC1B;AAID,wBAAgB,eAAe,eAG9B;AAiBD,wBAAgB,iBAAiB,CAChC,KAAK,EAAE,UAAU,EACjB,aAAa,CAAC,EAAE,aAAa,QAQ7B;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,QAK5C;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,QAI3C;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,cAEtC"}
+1934
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+80
View File
@@ -0,0 +1,80 @@
import { IProduce, IProduceWithPatches, Immer, Draft, Immutable } from "./internal";
export { Draft, Immutable, Patch, PatchListener, original, current, isDraft, isDraftable, NOTHING as nothing, DRAFTABLE as immerable, freeze } from "./internal";
/**
* The `produce` function takes a value and a "recipe function" (whose
* return value often depends on the base state). The recipe function is
* free to mutate its first argument however it wants. All mutations are
* only ever applied to a __copy__ of the base state.
*
* Pass only a function to create a "curried producer" which relieves you
* from passing the recipe function every time.
*
* Only plain objects and arrays are made mutable. All other objects are
* considered uncopyable.
*
* Note: This function is __bound__ to its `Immer` instance.
*
* @param {any} base - the initial state
* @param {Function} producer - function that receives a proxy of the base state as first argument and which can be freely modified
* @param {Function} patchListener - optional function that will be called with all the patches produced here
* @returns {any} a new state, or the initial state if nothing was modified
*/
export declare const produce: IProduce;
export default produce;
/**
* Like `produce`, but `produceWithPatches` always returns a tuple
* [nextState, patches, inversePatches] (instead of just the next state)
*/
export declare const produceWithPatches: IProduceWithPatches;
/**
* Pass true to automatically freeze all copies created by Immer.
*
* Always freeze by default, even in production mode
*/
export declare const setAutoFreeze: (value: boolean) => void;
/**
* Pass true to use the ES2015 `Proxy` class when creating drafts, which is
* always faster than using ES5 proxies.
*
* By default, feature detection is used, so calling this is rarely necessary.
*/
export declare const setUseProxies: (value: boolean) => void;
/**
* Apply an array of Immer patches to the first argument.
*
* This function is a producer, which means copy-on-write is in effect.
*/
export declare const applyPatches: (base: import("./internal").Objectish, patches: import("./internal").Patch[]) => any;
/**
* Create an Immer draft from the given base state, which may be a draft itself.
* The draft can be modified until you finalize it with the `finishDraft` function.
*/
export declare const createDraft: <T extends import("./internal").Objectish>(base: T) => Draft<T>;
/**
* Finalize an Immer draft from a `createDraft` call, returning the base state
* (if no changes were made) or a modified copy. The draft must *not* be
* mutated afterwards.
*
* Pass a function as the 2nd argument to generate Immer patches based on the
* changes that were made.
*/
export declare const finishDraft: <D extends any>(draft: D, patchListener?: import("./internal").PatchListener | undefined) => D extends Draft<infer T> ? T : never;
/**
* This function is actually a no-op, but can be used to cast an immutable type
* to an draft type and make TypeScript happy
*
* @param value
*/
export declare function castDraft<T>(value: T): Draft<T>;
/**
* This function is actually a no-op, but can be used to cast a mutable type
* to an immutable type and make TypeScript happy
* @param value
*/
export declare function castImmutable<T>(value: T): Immutable<T>;
export { Immer };
export { enableES5 } from "./plugins/es5";
export { enablePatches } from "./plugins/patches";
export { enableMapSet } from "./plugins/mapset";
export { enableAllPlugins } from "./plugins/all";
//# sourceMappingURL=immer.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"immer.d.ts","sourceRoot":"","sources":["src/immer.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,QAAQ,EACR,mBAAmB,EACnB,KAAK,EACL,KAAK,EACL,SAAS,EACT,MAAM,YAAY,CAAA;AAEnB,OAAO,EACN,KAAK,EACL,SAAS,EACT,KAAK,EACL,aAAa,EACb,QAAQ,EACR,OAAO,EACP,OAAO,EACP,WAAW,EACX,OAAO,IAAI,OAAO,EAClB,SAAS,IAAI,SAAS,EACtB,MAAM,EACN,MAAM,YAAY,CAAA;AAInB;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,OAAO,EAAE,QAAwB,CAAA;AAC9C,eAAe,OAAO,CAAA;AAEtB;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,mBAEhC,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa,0BAAkC,CAAA;AAE5D;;;;;GAKG;AACH,eAAO,MAAM,aAAa,0BAAkC,CAAA;AAE5D;;;;GAIG;AACH,eAAO,MAAM,YAAY,sFAAiC,CAAA;AAE1D;;;GAGG;AACH,eAAO,MAAM,WAAW,iEAAgC,CAAA;AAExD;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,mIAAgC,CAAA;AAExD;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAE/C;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAEvD;AAED,OAAO,EAAC,KAAK,EAAC,CAAA;AAEd,OAAO,EAAC,SAAS,EAAC,MAAM,eAAe,CAAA;AACvC,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAC,gBAAgB,EAAC,MAAM,eAAe,CAAA"}
+2
View File
File diff suppressed because one or more lines are too long
+1
View File
File diff suppressed because one or more lines are too long
+1940
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+8
View File
@@ -0,0 +1,8 @@
'use strict'
if (process.env.NODE_ENV === 'production') {
module.exports = require('./immer.cjs.production.min.js')
} else {
module.exports = require('./immer.cjs.development.js')
}
+113
View File
@@ -0,0 +1,113 @@
// @flow
export interface Patch {
op: "replace" | "remove" | "add";
path: (string | number)[];
value?: any;
}
export type PatchListener = (patches: Patch[], inversePatches: Patch[]) => void
type Base = {...} | Array<any>
interface IProduce {
/**
* Immer takes a state, and runs a function against it.
* That function can freely mutate the state, as it will create copies-on-write.
* This means that the original state will stay unchanged, and once the function finishes, the modified state is returned.
*
* If the first argument is a function, this is interpreted as the recipe, and will create a curried function that will execute the recipe
* any time it is called with the current state.
*
* @param currentState - the state to start with
* @param recipe - function that receives a proxy of the current state as first argument and which can be freely modified
* @param initialState - if a curried function is created and this argument was given, it will be used as fallback if the curried function is called with a state of undefined
* @returns The next state: a new state, or the current state if nothing was modified
*/
<S: Base>(
currentState: S,
recipe: (draftState: S) => S | void,
patchListener?: PatchListener
): S;
// curried invocations with inital state
<S: Base, A = void, B = void, C = void>(
recipe: (draftState: S, a: A, b: B, c: C, ...extraArgs: any[]) => S | void,
initialState: S
): (currentState: S | void, a: A, b: B, c: C, ...extraArgs: any[]) => S;
// curried invocations without inital state
<S: Base, A = void, B = void, C = void>(
recipe: (draftState: S, a: A, b: B, c: C, ...extraArgs: any[]) => S | void
): (currentState: S, a: A, b: B, c: C, ...extraArgs: any[]) => S;
}
interface IProduceWithPatches {
/**
* Like `produce`, but instead of just returning the new state,
* a tuple is returned with [nextState, patches, inversePatches]
*
* Like produce, this function supports currying
*/
<S: Base>(
currentState: S,
recipe: (draftState: S) => S | void
): [S, Patch[], Patch[]];
// curried invocations with inital state
<S: Base, A = void, B = void, C = void>(
recipe: (draftState: S, a: A, b: B, c: C, ...extraArgs: any[]) => S | void,
initialState: S
): (currentState: S | void, a: A, b: B, c: C, ...extraArgs: any[]) => [S, Patch[], Patch[]];
// curried invocations without inital state
<S: Base, A = void, B = void, C = void>(
recipe: (draftState: S, a: A, b: B, c: C, ...extraArgs: any[]) => S | void
): (currentState: S, a: A, b: B, c: C, ...extraArgs: any[]) => [S, Patch[], Patch[]];
}
declare export var produce: IProduce
declare export default IProduce
declare export var produceWithPatches: IProduceWithPatches
declare export var nothing: typeof undefined
declare export var immerable: Symbol
/**
* Automatically freezes any state trees generated by immer.
* This protects against accidental modifications of the state tree outside of an immer function.
* This comes with a performance impact, so it is recommended to disable this option in production.
* By default it is turned on during local development, and turned off in production.
*/
declare export function setAutoFreeze(autoFreeze: boolean): void
/**
* Manually override whether proxies should be used.
* By default done by using feature detection
*/
declare export function setUseProxies(useProxies: boolean): void
declare export function applyPatches<S>(state: S, patches: Patch[]): S
declare export function original<S>(value: S): S
declare export function current<S>(value: S): S
declare export function isDraft(value: any): boolean
/**
* Creates a mutable draft from an (immutable) object / array.
* The draft can be modified until `finishDraft` is called
*/
declare export function createDraft<T>(base: T): T
/**
* Given a draft that was created using `createDraft`,
* finalizes the draft into a new immutable object.
* Optionally a patch-listener can be provided to gather the patches that are needed to construct the object.
*/
declare export function finishDraft<T>(base: T, listener?: PatchListener): T
declare export function enableES5(): void
declare export function enableMapSet(): void
declare export function enablePatches(): void
declare export function enableAllPlugins(): void
declare export function freeze<T>(obj: T, freeze?: boolean): T
+12
View File
@@ -0,0 +1,12 @@
export * from "./utils/env";
export * from "./utils/errors";
export * from "./types/types-external";
export * from "./types/types-internal";
export * from "./utils/common";
export * from "./utils/plugins";
export * from "./core/scope";
export * from "./core/finalize";
export * from "./core/proxy";
export * from "./core/immerClass";
export * from "./core/current";
//# sourceMappingURL=internal.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["src/internal.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,wBAAwB,CAAA;AACtC,cAAc,wBAAwB,CAAA;AACtC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA"}
+2
View File
@@ -0,0 +1,2 @@
export declare function enableAllPlugins(): void;
//# sourceMappingURL=all.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"all.d.ts","sourceRoot":"","sources":["../src/plugins/all.ts"],"names":[],"mappings":"AAIA,wBAAgB,gBAAgB,SAI/B"}
+2
View File
@@ -0,0 +1,2 @@
export declare function enableES5(): void;
//# sourceMappingURL=es5.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"es5.d.ts","sourceRoot":"","sources":["../src/plugins/es5.ts"],"names":[],"mappings":"AAyBA,wBAAgB,SAAS,SAoPxB"}
+2
View File
@@ -0,0 +1,2 @@
export declare function enableMapSet(): void;
//# sourceMappingURL=mapset.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"mapset.d.ts","sourceRoot":"","sources":["../src/plugins/mapset.ts"],"names":[],"mappings":"AAqBA,wBAAgB,YAAY,SAmU3B"}
+2
View File
@@ -0,0 +1,2 @@
export declare function enablePatches(): void;
//# sourceMappingURL=patches.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"patches.d.ts","sourceRoot":"","sources":["../src/plugins/patches.ts"],"names":[],"mappings":"AAgCA,wBAAgB,aAAa,SA+Q5B"}
+79
View File
@@ -0,0 +1,79 @@
import { Nothing } from "../internal";
declare type Tail<T extends any[]> = ((...t: T) => any) extends (_: any, ...tail: infer TT) => any ? TT : [];
/** Object types that should never be mapped */
declare type AtomicObject = Function | Promise<any> | Date | RegExp | Boolean | Number | String;
/**
* If the lib "ES2105.collections" is not included in tsconfig.json,
* types like ReadonlyArray, WeakMap etc. fall back to `any` (specified nowhere)
* or `{}` (from the node types), in both cases entering an infite recursion in
* pattern matching type mappings
* This type can be used to cast these types to `void` in these cases.
*/
export declare type IfAvailable<T, Fallback = void> = true | false extends (T extends never ? true : false) ? Fallback : keyof T extends never ? Fallback : T;
/**
* These should also never be mapped but must be tested after regular Map and
* Set
*/
declare type WeakReferences = IfAvailable<WeakMap<any, any>> | IfAvailable<WeakSet<any>>;
export declare type WritableDraft<T> = {
-readonly [K in keyof T]: Draft<T[K]>;
};
export declare type Draft<T> = T extends AtomicObject ? T : T extends IfAvailable<ReadonlyMap<infer K, infer V>> ? Map<Draft<K>, Draft<V>> : T extends IfAvailable<ReadonlySet<infer V>> ? Set<Draft<V>> : T extends WeakReferences ? T : T extends object ? WritableDraft<T> : T;
/** Convert a mutable type into a readonly type */
export declare type Immutable<T> = T extends AtomicObject ? T : T extends IfAvailable<ReadonlyMap<infer K, infer V>> ? ReadonlyMap<Immutable<K>, Immutable<V>> : T extends IfAvailable<ReadonlySet<infer V>> ? ReadonlySet<Immutable<V>> : T extends WeakReferences ? T : T extends object ? {
readonly [K in keyof T]: Immutable<T[K]>;
} : T;
export interface Patch {
op: "replace" | "remove" | "add";
path: (string | number)[];
value?: any;
}
export declare type PatchListener = (patches: Patch[], inversePatches: Patch[]) => void;
/** Converts `nothing` into `undefined` */
declare type FromNothing<T> = T extends Nothing ? undefined : T;
/** The inferred return type of `produce` */
export declare type Produced<Base, Return> = Return extends void ? Base : Return extends Promise<infer Result> ? Promise<Result extends void ? Base : FromNothing<Result>> : FromNothing<Return>;
/**
* The `produce` function takes a value and a "recipe function" (whose
* return value often depends on the base state). The recipe function is
* free to mutate its first argument however it wants. All mutations are
* only ever applied to a __copy__ of the base state.
*
* Pass only a function to create a "curried producer" which relieves you
* from passing the recipe function every time.
*
* Only plain objects and arrays are made mutable. All other objects are
* considered uncopyable.
*
* Note: This function is __bound__ to its `Immer` instance.
*
* @param {any} base - the initial state
* @param {Function} producer - function that receives a proxy of the base state as first argument and which can be freely modified
* @param {Function} patchListener - optional function that will be called with all the patches produced here
* @returns {any} a new state, or the initial state if nothing was modified
*/
export interface IProduce {
/** Curried producer */
<Recipe extends (...args: any[]) => any, Params extends any[] = Parameters<Recipe>, T = Params[0]>(recipe: Recipe): <Base extends Immutable<T>>(base: Base, ...rest: Tail<Params>) => Produced<Base, ReturnType<Recipe>>;
/** Curried producer with initial state */
<Recipe extends (...args: any[]) => any, Params extends any[] = Parameters<Recipe>, T = Params[0]>(recipe: Recipe, initialState: Immutable<T>): <Base extends Immutable<T>>(base?: Base, ...rest: Tail<Params>) => Produced<Base, ReturnType<Recipe>>;
/** Normal producer */
<Base, D = Draft<Base>, Return = void>(base: Base, recipe: (draft: D) => Return, listener?: PatchListener): Produced<Base, Return>;
}
/**
* Like `produce`, but instead of just returning the new state,
* a tuple is returned with [nextState, patches, inversePatches]
*
* Like produce, this function supports currying
*/
export interface IProduceWithPatches {
/** Curried producer */
<Recipe extends (...args: any[]) => any, Params extends any[] = Parameters<Recipe>, T = Params[0]>(recipe: Recipe): <Base extends Immutable<T>>(base: Base, ...rest: Tail<Params>) => [Produced<Base, ReturnType<Recipe>>, Patch[], Patch[]];
/** Curried producer with initial state */
<Recipe extends (...args: any[]) => any, Params extends any[] = Parameters<Recipe>, T = Params[0]>(recipe: Recipe, initialState: Immutable<T>): <Base extends Immutable<T>>(base?: Base, ...rest: Tail<Params>) => [Produced<Base, ReturnType<Recipe>>, Patch[], Patch[]];
/** Normal producer */
<Base, D = Draft<Base>, Return = void>(base: Base, recipe: (draft: D) => Return): [Produced<Base, Return>, Patch[], Patch[]];
}
export declare function never_used(): void;
export {};
//# sourceMappingURL=types-external.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"types-external.d.ts","sourceRoot":"","sources":["../src/types/types-external.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,aAAa,CAAA;AAEnC,aAAK,IAAI,CAAC,CAAC,SAAS,GAAG,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,GAAG,CAAC,SAAS,CACvD,CAAC,EAAE,GAAG,EACN,GAAG,IAAI,EAAE,MAAM,EAAE,KACb,GAAG,GACL,EAAE,GACF,EAAE,CAAA;AAEL,+CAA+C;AAC/C,aAAK,YAAY,GACd,QAAQ,GACR,OAAO,CAAC,GAAG,CAAC,GACZ,IAAI,GACJ,MAAM,GACN,OAAO,GACP,MAAM,GACN,MAAM,CAAA;AAET;;;;;;GAMG;AACH,oBAAY,WAAW,CAAC,CAAC,EAAE,QAAQ,GAAG,IAAI,IAEzC,IAAI,GAAG,KAAK,SAAS,CAAC,CAAC,SAAS,KAAK,GACnC,IAAI,GACJ,KAAK,CAAC,GACL,QAAQ,GACR,MAAM,CAAC,SAAS,KAAK,GACrB,QAAQ,GACR,CAAC,CAAA;AAEL;;;GAGG;AACH,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,UAAU,CAAC,MAAM,CAAC,EACzC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,EAEb,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,SAAS,CAAC,CAAC,CAAC,GACxB,CAAC,IAAI,SAAS,SAAS,CAAC,CAAC,CAAC,EAC5B,IAAI,CAAC,EAAE,IAAI,EACX,GAAG,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,KACjB,CAAC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;IAE3D,sBAAsB;IACtB,CAAC,IAAI,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,EACpC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,GAC1B,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;CAC7C;AAID,wBAAgB,UAAU,SAAK"}
+31
View File
@@ -0,0 +1,31 @@
import { SetState, ImmerScope, ProxyObjectState, ProxyArrayState, ES5ObjectState, ES5ArrayState, MapState, DRAFT_STATE } from "../internal";
export declare type Objectish = AnyObject | AnyArray | AnyMap | AnySet;
export declare type ObjectishNoSet = AnyObject | AnyArray | AnyMap;
export declare type AnyObject = {
[key: string]: any;
};
export declare type AnyArray = Array<any>;
export declare type AnySet = Set<any>;
export declare type AnyMap = Map<any, any>;
export declare const ArchtypeObject = 0;
export declare const ArchtypeArray = 1;
export declare const ArchtypeMap = 2;
export declare const ArchtypeSet = 3;
export declare const ProxyTypeProxyObject = 0;
export declare const ProxyTypeProxyArray = 1;
export declare const ProxyTypeES5Object = 4;
export declare const ProxyTypeES5Array = 5;
export declare const ProxyTypeMap = 2;
export declare const ProxyTypeSet = 3;
export interface ImmerBaseState {
parent_?: ImmerState;
scope_: ImmerScope;
modified_: boolean;
finalized_: boolean;
isManual_: boolean;
}
export declare type ImmerState = ProxyObjectState | ProxyArrayState | ES5ObjectState | ES5ArrayState | MapState | SetState;
export declare type Drafted<Base = any, T extends ImmerState = ImmerState> = {
[DRAFT_STATE]: T;
} & Base;
//# sourceMappingURL=types-internal.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"types-internal.d.ts","sourceRoot":"","sources":["../src/types/types-internal.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,aAAa,EACb,QAAQ,EACR,WAAW,EACX,MAAM,aAAa,CAAA;AAEpB,oBAAY,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAA;AAC9D,oBAAY,cAAc,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAA;AAE1D,oBAAY,SAAS,GAAG;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAC,CAAA;AAC5C,oBAAY,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,CAAA;AACjC,oBAAY,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,CAAA;AAC7B,oBAAY,MAAM,GAAG,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;AAElC,eAAO,MAAM,cAAc,IAAI,CAAA;AAC/B,eAAO,MAAM,aAAa,IAAI,CAAA;AAC9B,eAAO,MAAM,WAAW,IAAI,CAAA;AAC5B,eAAO,MAAM,WAAW,IAAI,CAAA;AAE5B,eAAO,MAAM,oBAAoB,IAAI,CAAA;AACrC,eAAO,MAAM,mBAAmB,IAAI,CAAA;AACpC,eAAO,MAAM,kBAAkB,IAAI,CAAA;AACnC,eAAO,MAAM,iBAAiB,IAAI,CAAA;AAClC,eAAO,MAAM,YAAY,IAAI,CAAA;AAC7B,eAAO,MAAM,YAAY,IAAI,CAAA;AAE7B,MAAM,WAAW,cAAc;IAC9B,OAAO,CAAC,EAAE,UAAU,CAAA;IACpB,MAAM,EAAE,UAAU,CAAA;IAClB,SAAS,EAAE,OAAO,CAAA;IAClB,UAAU,EAAE,OAAO,CAAA;IACnB,SAAS,EAAE,OAAO,CAAA;CAClB;AAED,oBAAY,UAAU,GACnB,gBAAgB,GAChB,eAAe,GACf,cAAc,GACd,aAAa,GACb,QAAQ,GACR,QAAQ,CAAA;AAGX,oBAAY,OAAO,CAAC,IAAI,GAAG,GAAG,EAAE,CAAC,SAAS,UAAU,GAAG,UAAU,IAAI;IACpE,CAAC,WAAW,CAAC,EAAE,CAAC,CAAA;CAChB,GAAG,IAAI,CAAA"}
+32
View File
@@ -0,0 +1,32 @@
import { Objectish, AnyObject, AnyMap, AnySet, ImmerState } from "../internal";
/** Returns true if the given value is an Immer draft */
export declare function isDraft(value: any): boolean;
/** Returns true if the given value can be drafted by Immer */
export declare function isDraftable(value: any): boolean;
export declare function isPlainObject(value: any): boolean;
/** Get the underlying object that is represented by the given draft */
export declare function original<T>(value: T): T | undefined;
export declare const ownKeys: (target: AnyObject) => PropertyKey[];
export declare const getOwnPropertyDescriptors: <T>(o: T) => { [P in keyof T]: TypedPropertyDescriptor<T[P]>; } & {
[x: string]: PropertyDescriptor;
};
export declare function each<T extends Objectish>(obj: T, iter: (key: string | number, value: any, source: T) => void, enumerableOnly?: boolean): void;
export declare function getArchtype(thing: any): 0 | 1 | 2 | 3;
export declare function has(thing: any, prop: PropertyKey): boolean;
export declare function get(thing: AnyMap | AnyObject, prop: PropertyKey): any;
export declare function set(thing: any, propOrOldValue: PropertyKey, value: any): void;
export declare function is(x: any, y: any): boolean;
export declare function isMap(target: any): target is AnyMap;
export declare function isSet(target: any): target is AnySet;
export declare function latest(state: ImmerState): any;
export declare function shallowCopy(base: any): any;
/**
* Freezes draftable objects. Returns the original object.
* By default freezes shallowly, but if the second argument is `true` it will freeze recursively.
*
* @param obj
* @param deep
*/
export declare function freeze<T>(obj: T, deep?: boolean): T;
export declare function isFrozen(obj: any): boolean;
//# sourceMappingURL=common.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/utils/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,SAAS,EAET,SAAS,EACT,MAAM,EACN,MAAM,EACN,UAAU,EAOV,MAAM,aAAa,CAAA;AAEpB,wDAAwD;AAExD,wBAAgB,OAAO,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAE3C;AAED,8DAA8D;AAE9D,wBAAgB,WAAW,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAU/C;AAGD,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAIjD;AAED,uEAAuE;AAEvE,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS,CAAA;AAOpD,eAAO,MAAM,OAAO,EAAE,CAAC,MAAM,EAAE,SAAS,KAAK,WAAW,EAQC,CAAA;AAEzD,eAAO,MAAM,yBAAyB;;CASpC,CAAA;AAEF,wBAAgB,IAAI,CAAC,CAAC,SAAS,SAAS,EACvC,GAAG,EAAE,CAAC,EACN,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,KAAK,IAAI,EAC3D,cAAc,CAAC,EAAE,OAAO,GACtB,IAAI,CAAA;AAYP,wBAAgB,WAAW,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAcrD;AAGD,wBAAgB,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAI1D;AAGD,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,WAAW,GAAG,GAAG,CAGrE;AAGD,wBAAgB,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,cAAc,EAAE,WAAW,EAAE,KAAK,EAAE,GAAG,QAOtE;AAGD,wBAAgB,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,OAAO,CAO1C;AAGD,wBAAgB,KAAK,CAAC,MAAM,EAAE,GAAG,GAAG,MAAM,IAAI,MAAM,CAEnD;AAGD,wBAAgB,KAAK,CAAC,MAAM,EAAE,GAAG,GAAG,MAAM,IAAI,MAAM,CAEnD;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,GAAG,CAE7C;AAGD,wBAAgB,WAAW,CAAC,IAAI,EAAE,GAAG,OAwBpC;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,CAAC,CAAA;AAepD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAI1C"}
+23
View File
@@ -0,0 +1,23 @@
export declare const hasMap: boolean;
export declare const hasSet: boolean;
export declare const hasProxies: boolean;
/**
* The sentinel value returned by producers to replace the draft with undefined.
*/
export declare const NOTHING: Nothing;
/**
* To let Immer treat your class instances as plain immutable objects
* (albeit with a custom prototype), you must define either an instance property
* or a static property on each of your custom classes.
*
* Otherwise, your class instance will never be drafted, which means it won't be
* safe to mutate in a produce callback.
*/
export declare const DRAFTABLE: unique symbol;
export declare const DRAFT_STATE: unique symbol;
export declare const iteratorSymbol: typeof Symbol.iterator;
/** Use a class type for `nothing` so its type is unique */
export declare class Nothing {
private _;
}
//# sourceMappingURL=env.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/utils/env.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,MAAM,SAA6B,CAAA;AAChD,eAAO,MAAM,MAAM,SAA6B,CAAA;AAChD,eAAO,MAAM,UAAU,SAGQ,CAAA;AAE/B;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,OAEe,CAAA;AAErC;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,EAAE,OAAO,MAEC,CAAA;AAEhC,eAAO,MAAM,WAAW,EAAE,OAAO,MAEL,CAAA;AAG5B,eAAO,MAAM,cAAc,EAAE,OAAO,MAAM,CAAC,QACgC,CAAA;AAE3E,2DAA2D;AAC3D,qBAAa,OAAO;IAGnB,OAAO,CAAC,CAAC,CAAgB;CACzB"}
+29
View File
@@ -0,0 +1,29 @@
declare const errors: {
readonly 0: "Illegal state";
readonly 1: "Immer drafts cannot have computed properties";
readonly 2: "This object has been frozen and should not be mutated";
readonly 3: (data: any) => string;
readonly 4: "An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.";
readonly 5: "Immer forbids circular references";
readonly 6: "The first or second argument to `produce` must be a function";
readonly 7: "The third argument to `produce` must be a function or undefined";
readonly 8: "First argument to `createDraft` must be a plain object, an array, or an immerable object";
readonly 9: "First argument to `finishDraft` must be a draft returned by `createDraft`";
readonly 10: "The given draft is already finalized";
readonly 11: "Object.defineProperty() cannot be used on an Immer draft";
readonly 12: "Object.setPrototypeOf() cannot be used on an Immer draft";
readonly 13: "Immer only supports deleting array indices";
readonly 14: "Immer only supports setting array indices and the 'length' property";
readonly 15: (path: string) => string;
readonly 16: "Sets cannot have \"replace\" patches.";
readonly 17: (op: string) => string;
readonly 18: (plugin: string) => string;
readonly 20: "Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available";
readonly 21: (thing: string) => string;
readonly 22: (thing: string) => string;
readonly 23: (thing: string) => string;
readonly 24: "Patching reserved attributes like __proto__, prototype and constructor is not allowed";
};
export declare function die(error: keyof typeof errors, ...args: any[]): never;
export {};
//# sourceMappingURL=errors.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/utils/errors.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;CA0CF,CAAA;AAEV,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,OAAO,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,KAAK,CAerE"}
+62
View File
@@ -0,0 +1,62 @@
import { ImmerState, Patch, ImmerScope, Drafted, AnyObject, ImmerBaseState, AnyMap, AnySet, ProxyTypeES5Array, ProxyTypeES5Object, ProxyTypeMap, ProxyTypeSet } from "../internal";
/** Plugin utilities */
declare const plugins: {
Patches?: {
generatePatches_(state: ImmerState, basePath: PatchPath, patches: Patch[], inversePatches: Patch[]): void;
generateReplacementPatches_(rootState: ImmerState, replacement: any, patches: Patch[], inversePatches: Patch[]): void;
applyPatches_<T>(draft: T, patches: Patch[]): T;
};
ES5?: {
willFinalizeES5_(scope: ImmerScope, result: any, isReplaced: boolean): void;
createES5Proxy_<T>(base: T, parent?: ImmerState): Drafted<T, ES5ObjectState | ES5ArrayState>;
hasChanges_(state: ES5ArrayState | ES5ObjectState): boolean;
};
MapSet?: {
proxyMap_<T extends AnyMap>(target: T, parent?: ImmerState): T;
proxySet_<T extends AnySet>(target: T, parent?: ImmerState): T;
};
};
declare type Plugins = typeof plugins;
export declare function getPlugin<K extends keyof Plugins>(pluginKey: K): Exclude<Plugins[K], undefined>;
export declare function loadPlugin<K extends keyof Plugins>(pluginKey: K, implementation: Plugins[K]): void;
/** ES5 Plugin */
interface ES5BaseState extends ImmerBaseState {
assigned_: {
[key: string]: any;
};
parent_?: ImmerState;
revoked_: boolean;
}
export interface ES5ObjectState extends ES5BaseState {
type_: typeof ProxyTypeES5Object;
draft_: Drafted<AnyObject, ES5ObjectState>;
base_: AnyObject;
copy_: AnyObject | null;
}
export interface ES5ArrayState extends ES5BaseState {
type_: typeof ProxyTypeES5Array;
draft_: Drafted<AnyObject, ES5ArrayState>;
base_: any;
copy_: any;
}
/** Map / Set plugin */
export interface MapState extends ImmerBaseState {
type_: typeof ProxyTypeMap;
copy_: AnyMap | undefined;
assigned_: Map<any, boolean> | undefined;
base_: AnyMap;
revoked_: boolean;
draft_: Drafted<AnyMap, MapState>;
}
export interface SetState extends ImmerBaseState {
type_: typeof ProxyTypeSet;
copy_: AnySet | undefined;
base_: AnySet;
drafts_: Map<any, Drafted>;
revoked_: boolean;
draft_: Drafted<AnySet, SetState>;
}
/** Patches plugin */
export declare type PatchPath = (string | number)[];
export {};
//# sourceMappingURL=plugins.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../src/utils/plugins.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,UAAU,EACV,KAAK,EACL,UAAU,EACV,OAAO,EACP,SAAS,EACT,cAAc,EACd,MAAM,EACN,MAAM,EACN,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,YAAY,EAEZ,MAAM,aAAa,CAAA;AAEpB,uBAAuB;AACvB,QAAA,MAAM,OAAO,EAAE;IACd,OAAO,CAAC,EAAE;QACT,gBAAgB,CACf,KAAK,EAAE,UAAU,EACjB,QAAQ,EAAE,SAAS,EACnB,OAAO,EAAE,KAAK,EAAE,EAChB,cAAc,EAAE,KAAK,EAAE,GACrB,IAAI,CAAA;QACP,2BAA2B,CAC1B,SAAS,EAAE,UAAU,EACrB,WAAW,EAAE,GAAG,EAChB,OAAO,EAAE,KAAK,EAAE,EAChB,cAAc,EAAE,KAAK,EAAE,GACrB,IAAI,CAAA;QACP,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC,CAAA;KAC/C,CAAA;IACD,GAAG,CAAC,EAAE;QACL,gBAAgB,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,GAAG,IAAI,CAAA;QAC3E,eAAe,CAAC,CAAC,EAChB,IAAI,EAAE,CAAC,EACP,MAAM,CAAC,EAAE,UAAU,GACjB,OAAO,CAAC,CAAC,EAAE,cAAc,GAAG,aAAa,CAAC,CA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