plugins.ts
This file
Path
src/utils/plugins.ts
76 lines · 1.6 KiB · TypeScript
Last changed by
fix: Make `applyPatches` to accept `readonly Patch[]` (#1094)Mateusz Burzyńskibefore adoption4da2e0d
History of this fileTake it
The walk stopped after 200 commits: lines older than 6555173 point at it.
fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173
lines 1–7why, one step back1import {2 ImmerState,3 Patch,4 Drafted,5 ImmerBaseState,6 AnyMap,7 AnySet,Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42
line 8why, one step back8 ArchType,fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173
lines 9–21why, one step back9 die10} from "../internal"1112/** Plugin utilities */13const plugins: {14 Patches?: {15 generatePatches_(16 state: ImmerState,17 basePath: PatchPath,18 patches: Patch[],19 inversePatches: Patch[]20 ): void21 generateReplacementPatches_(fix: No patches being generated for root primitive replacements. Fixes #888Michel Weststratebefore adoption0f96270
line 22why, one step back22 base: any,fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173
lines 23–26why, one step back23 replacement: any,24 patches: Patch[],25 inversePatches: Patch[]26 ): voidfix: Make `applyPatches` to accept `readonly Patch[]` (#1094)Mateusz Burzyńskibefore adoption4da2e0d
line 27why, one step back27 applyPatches_<T>(draft: T, patches: readonly Patch[]): Tfix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173
lines 28–41why, one step back28 }29 MapSet?: {30 proxyMap_<T extends AnyMap>(target: T, parent?: ImmerState): T31 proxySet_<T extends AnySet>(target: T, parent?: ImmerState): T32 }33} = {}3435type Plugins = typeof plugins3637export function getPlugin<K extends keyof Plugins>(38 pluginKey: K39): Exclude<Plugins[K], undefined> {40 const plugin = plugins[pluginKey]41 if (!plugin) {Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42
line 42why, one step back42 die(0, pluginKey)fix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173
lines 43–56why, one step back43 }44 // @ts-ignore45 return plugin46}4748export function loadPlugin<K extends keyof Plugins>(49 pluginKey: K,50 implementation: Plugins[K]51): void {52 if (!plugins[pluginKey]) plugins[pluginKey] = implementation53}54/** Map / Set plugin */5556export interface MapState extends ImmerBaseState {Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42
line 57why, one step back57 type_: ArchType.Mapfix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173
lines 58–65why, one step back58 copy_: AnyMap | undefined59 assigned_: Map<any, boolean> | undefined60 base_: AnyMap61 revoked_: boolean62 draft_: Drafted<AnyMap, MapState>63}6465export interface SetState extends ImmerBaseState {Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42
line 66why, one step back66 type_: ArchType.Setfix: #785 fix type inference for produce incorrectly inferring promise (#786)hardfistbefore adoption6555173
lines 67–76why, one step back67 copy_: AnySet | undefined68 base_: AnySet69 drafts_: Map<any, Drafted> // maps the original value to the draft value in the new set70 revoked_: boolean71 draft_: Drafted<AnySet, SetState>72}7374/** Patches plugin */7576export type PatchPath = (string | number)[]