proxy.d.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { ImmerBaseState, ImmerState, Drafted, AnyObject, AnyArray, Objectish, ProxyTypeProxyObject, ProxyTypeProxyArray } from "../internal";
  2. interface ProxyBaseState extends ImmerBaseState {
  3. assigned_: {
  4. [property: string]: boolean;
  5. };
  6. parent_?: ImmerState;
  7. revoke_(): void;
  8. }
  9. export interface ProxyObjectState extends ProxyBaseState {
  10. type_: typeof ProxyTypeProxyObject;
  11. base_: any;
  12. copy_: any;
  13. draft_: Drafted<AnyObject, ProxyObjectState>;
  14. }
  15. export interface ProxyArrayState extends ProxyBaseState {
  16. type_: typeof ProxyTypeProxyArray;
  17. base_: AnyArray;
  18. copy_: AnyArray | null;
  19. draft_: Drafted<AnyArray, ProxyArrayState>;
  20. }
  21. declare type ProxyState = ProxyObjectState | ProxyArrayState;
  22. /**
  23. * Returns a new draft of the `base` object.
  24. *
  25. * The second argument is the parent draft-state (used internally).
  26. */
  27. export declare function createProxyProxy<T extends Objectish>(base: T, parent?: ImmerState): Drafted<T, ProxyState>;
  28. /**
  29. * Object drafts
  30. */
  31. export declare const objectTraps: ProxyHandler<ProxyState>;
  32. export declare function markChanged(state: ImmerState): void;
  33. export declare function prepareCopy(state: {
  34. base_: any;
  35. copy_: any;
  36. }): void;
  37. export {};
  38. //# sourceMappingURL=proxy.d.ts.map