native-document 1.0.53 → 1.0.54

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.
@@ -4,6 +4,7 @@ export type Unsubscribe = () => void;
4
4
  export interface ObservableItem<T = any> {
5
5
  readonly $currentValue: T;
6
6
  readonly $previousValue: T;
7
+ readonly $initialValue: T | null;
7
8
  readonly $isCleanedUp: boolean;
8
9
 
9
10
  $value: T;
@@ -23,6 +24,10 @@ export interface ObservableItem<T = any> {
23
24
  when(value: T): { $target: T; $observer: ObservableItem<T> };
24
25
 
25
26
  toString(): string;
27
+ equals(value: any): boolean;
28
+ toBool(): boolean;
29
+ toggle(): void;
30
+ reset(): void;
26
31
  }
27
32
 
28
33
  export class ObservableWhen<T = any> {
@@ -81,6 +86,7 @@ export interface ObservableArray<T> extends ObservableItem<T[]> {
81
86
  some(callback: (value: T, index: number, array: T[]) => boolean): boolean;
82
87
  every(callback: (value: T, index: number, array: T[]) => boolean): boolean;
83
88
  find(callback: (value: T, index: number, array: T[]) => boolean): T | undefined;
89
+ at(index: number): T | undefined;
84
90
  findIndex(callback: (value: T, index: number, array: T[]) => boolean): number;
85
91
  concat(...items: (T | T[])[]): T[];
86
92
  }
@@ -88,11 +94,18 @@ export interface ObservableArray<T> extends ObservableItem<T[]> {
88
94
  export type ObservableProxy<T extends Record<string, any>> = {
89
95
  readonly __isProxy__: true;
90
96
  readonly $value: T;
97
+ readonly configs: ObservableConfig | null;
91
98
  $val(): T;
99
+ val(): T;
92
100
  $get(key: string): any;
101
+ get(key: string): any;
93
102
  $clone(): ObservableProxy<T>;
103
+ clone(): ObservableProxy<T>;
94
104
  $updateWith(values: Partial<T>): void;
95
105
  $set(values: Partial<T>): void;
106
+ set(values: Partial<T>): void;
107
+ reset(): void;
108
+ keys(): string[];
96
109
  } & {
97
110
  [K in keyof T]: T[K] extends (infer U)[]
98
111
  ? ObservableArray<U>
@@ -113,13 +126,19 @@ export interface AutoCleanupOptions {
113
126
  threshold?: number;
114
127
  }
115
128
 
129
+ export interface ObservableConfig {
130
+ deep?: boolean;
131
+ reset?: boolean;
132
+ propagation?: boolean;
133
+ }
134
+
116
135
  export interface ObservableStatic {
117
- <T>(value: T): ObservableItem<T>;
118
- array<T>(target: T[]): ObservableArray<T>;
136
+ <T>(value: T, configs?: ObservableConfig | null): ObservableItem<T>;
137
+ array<T>(target: T[], configs?: ObservableConfig | null): ObservableArray<T>;
119
138
 
120
- init<T extends Record<string, any>>(value: T): ObservableProxy<T>;
121
- object<T extends Record<string, any>>(value: T): ObservableProxy<T>;
122
- json<T extends Record<string, any>>(value: T): ObservableProxy<T>;
139
+ init<T extends Record<string, any>>(value: T, configs?: ObservableConfig | null): ObservableProxy<T>;
140
+ object<T extends Record<string, any>>(value: T, configs?: ObservableConfig | null): ObservableProxy<T>;
141
+ json<T extends Record<string, any>>(value: T, configs?: ObservableConfig | null): ObservableProxy<T>;
123
142
 
124
143
  computed<T>(callback: () => T, dependencies?: ValidComputedDependencies | BatchFunction): ObservableItem<T>;
125
144
  computed<T>(callback: () => T, batchFunction?: BatchFunction): ObservableItem<T>;