Skip to content
Myr

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 file

Take it

The walk stopped after 200 commits: lines older than fe8f589 point at it.

chore(comments): update comments (#727)郗银before adoptionfe8f589

lines 1–7why, one step back
1import {
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 back
8 ArchType,

chore(comments): update comments (#727)郗银before adoptionfe8f589

lines 9–21why, one step back
9 die
10} 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 back
22 base: any,

chore(comments): update comments (#727)郗银before adoptionfe8f589

lines 23–26why, one step back
23 replacement: any,
24 patches: Patch[],25 inversePatches: Patch[]26 ): void

fix: Make `applyPatches` to accept `readonly Patch[]` (#1094)Mateusz Burzyńskibefore adoption4da2e0d

line 27why, one step back
27 applyPatches_<T>(draft: T, patches: readonly Patch[]): T

chore(comments): update comments (#727)郗银before adoptionfe8f589

lines 28–41why, one step back
28 }
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 back
42 die(0, pluginKey)

chore(comments): update comments (#727)郗银before adoptionfe8f589

lines 43–56why, one step back
43 }
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 back
57 type_: ArchType.Map

chore(comments): update comments (#727)郗银before adoptionfe8f589

lines 58–65why, one step back
58 copy_: AnyMap | undefined
59 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 back
66 type_: ArchType.Set

chore(comments): update comments (#727)郗银before adoptionfe8f589

lines 67–76why, one step back
67 copy_: AnySet | undefined
68 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)[]