@legendapp/state 3.0.0-alpha.28 → 3.0.0-alpha.29

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.
package/index.d.mts CHANGED
@@ -103,14 +103,14 @@ declare function safeStringify(value: any): any;
103
103
  declare function safeParse(value: any): any;
104
104
  declare function clone<T>(value: T): any;
105
105
  declare function isObservable(value$: any): value$ is Observable;
106
- declare function getNode(value$: ObservableParam): NodeValue;
107
- declare function setNodeValue(node: NodeValue, newValue: any): {
106
+ declare function getNode(value$: ObservableParam): NodeInfo;
107
+ declare function setNodeValue(node: NodeInfo, newValue: any): {
108
108
  prevValue: any;
109
109
  newValue: any;
110
110
  };
111
- declare function getNodeValue(node: NodeValue): any;
112
- declare function ensureNodeValue(node: NodeValue): any;
113
- declare function findIDKey(obj: unknown | undefined, node: NodeValue): string | ((value: any) => string) | undefined;
111
+ declare function getNodeValue(node: NodeInfo): any;
112
+ declare function ensureNodeValue(node: NodeInfo): any;
113
+ declare function findIDKey(obj: unknown | undefined, node: NodeInfo): string | ((value: any) => string) | undefined;
114
114
 
115
115
  type TrackingType = undefined | true | symbol;
116
116
  interface GetOptions {
@@ -151,31 +151,31 @@ interface ObservableRoot {
151
151
  }
152
152
  type Primitive = boolean | string | number | Date;
153
153
  type NotPrimitive<T> = T extends Primitive ? never : T;
154
- interface NodeValueListener {
154
+ interface NodeListener {
155
155
  track: TrackingType;
156
156
  noArgs?: boolean;
157
157
  listener: ListenerFn;
158
158
  }
159
159
  interface TrackingState {
160
- nodes?: Map<NodeValue, TrackingNode>;
161
- traceListeners?: (nodes: Map<NodeValue, TrackingNode>) => void;
160
+ nodes?: Map<NodeInfo, TrackingNode>;
161
+ traceListeners?: (nodes: Map<NodeInfo, TrackingNode>) => void;
162
162
  traceUpdates?: (fn: Function) => Function;
163
163
  }
164
- interface BaseNodeValue {
165
- children?: Map<string, ChildNodeValue>;
164
+ interface BaseNodeInfo {
165
+ children?: Map<string, ChildNodeInfo>;
166
166
  proxy?: object;
167
167
  root: ObservableRoot;
168
- listeners?: Set<NodeValueListener>;
169
- listenersImmediate?: Set<NodeValueListener>;
168
+ listeners?: Set<NodeListener>;
169
+ listenersImmediate?: Set<NodeListener>;
170
170
  isEvent?: boolean;
171
- linkedToNode?: NodeValue;
171
+ linkedToNode?: NodeInfo;
172
172
  linkedToNodeDispose?: () => void;
173
173
  activatedObserveDispose?: () => void;
174
- linkedFromNodes?: Set<NodeValue>;
174
+ linkedFromNodes?: Set<NodeInfo>;
175
175
  isSetting?: number;
176
176
  isAssigning?: number;
177
177
  isComputing?: boolean;
178
- parentOther?: NodeValue;
178
+ parentOther?: NodeInfo;
179
179
  functions?: Map<string, Function | Observable<any>>;
180
180
  lazy?: boolean;
181
181
  lazyFn?: Function;
@@ -189,21 +189,21 @@ interface BaseNodeValue {
189
189
  onChange: (params: UpdateFnParams) => void | Promise<void>;
190
190
  };
191
191
  dirtyFn?: () => void;
192
- dirtyChildren?: Set<NodeValue>;
192
+ dirtyChildren?: Set<NodeInfo>;
193
193
  numGets?: number;
194
194
  getNumResolved?: number;
195
195
  }
196
- interface RootNodeValue extends BaseNodeValue {
196
+ interface RootNodeInfo extends BaseNodeInfo {
197
197
  parent?: undefined;
198
198
  key?: undefined;
199
199
  }
200
- interface ChildNodeValue extends BaseNodeValue {
201
- parent: NodeValue;
200
+ interface ChildNodeInfo extends BaseNodeInfo {
201
+ parent: NodeInfo;
202
202
  key: string;
203
203
  }
204
- type NodeValue = RootNodeValue | ChildNodeValue;
204
+ type NodeInfo = RootNodeInfo | ChildNodeInfo;
205
205
  interface TrackingNode {
206
- node: NodeValue;
206
+ node: NodeInfo;
207
207
  track: TrackingType;
208
208
  num: number;
209
209
  }
@@ -218,7 +218,7 @@ interface ObserveEventCallback<T> {
218
218
  previous?: T | undefined;
219
219
  value?: T;
220
220
  cancel: boolean;
221
- nodes: Map<NodeValue, TrackingNode> | undefined;
221
+ nodes: Map<NodeInfo, TrackingNode> | undefined;
222
222
  refresh: () => void;
223
223
  onCleanup?: () => void;
224
224
  onCleanupReaction?: () => void;
@@ -278,12 +278,12 @@ interface RetryOptions {
278
278
  maxDelay?: number;
279
279
  }
280
280
 
281
- declare function getProxy(node: NodeValue, p?: string, asFunction?: Function): Observable;
282
- declare function set(node: NodeValue, newValue?: any): void;
283
- declare function get(node: NodeValue, options?: TrackingType | GetOptions): any;
284
- declare function peek(node: NodeValue): any;
285
- declare function isObserved(node: NodeValue): boolean;
286
- declare function shouldIgnoreUnobserved(node: NodeValue, refreshFn: () => void): true | undefined;
281
+ declare function getProxy(node: NodeInfo, p?: string, asFunction?: Function): Observable;
282
+ declare function set(node: NodeInfo, newValue?: any): void;
283
+ declare function get(node: NodeInfo, options?: TrackingType | GetOptions): any;
284
+ declare function peek(node: NodeInfo): any;
285
+ declare function isObserved(node: NodeInfo): boolean;
286
+ declare function shouldIgnoreUnobserved(node: NodeInfo, refreshFn: () => void): true | undefined;
287
287
 
288
288
  declare function createPreviousHandler(value: any, changes: Change[]): () => any;
289
289
  declare function batch(fn: () => void): void;
@@ -294,10 +294,10 @@ declare function computed<T>(get: () => RecursiveValueOrFunction<T>): Observable
294
294
  declare function computed<T, T2 = T>(get: (() => RecursiveValueOrFunction<T>) | RecursiveValueOrFunction<T>, set: (value: T2) => void): Observable<T>;
295
295
 
296
296
  declare function configureLegendState({ observableFunctions, observableProperties, jsonReplacer, jsonReviver, }: {
297
- observableFunctions?: Record<string, (node: NodeValue, ...args: any[]) => any>;
297
+ observableFunctions?: Record<string, (node: NodeInfo, ...args: any[]) => any>;
298
298
  observableProperties?: Record<string, {
299
- get: (node: NodeValue) => any;
300
- set: (node: NodeValue, value: any) => any;
299
+ get: (node: NodeInfo) => any;
300
+ set: (node: NodeInfo, value: any) => any;
301
301
  }>;
302
302
  jsonReplacer?: (this: any, key: string, value: any) => any;
303
303
  jsonReviver?: (this: any, key: string, value: any) => any;
@@ -355,7 +355,7 @@ declare function proxy<T>(get: (key: string) => T): Observable<Record<string, T>
355
355
  declare function syncState(obs: ObservableParam): Observable<ObservableSyncState>;
356
356
 
357
357
  declare function trackSelector<T>(selector: Selector<T>, update: (params: ListenerParams) => void, observeEvent?: ObserveEvent<T>, observeOptions?: ObserveOptions, createResubscribe?: boolean): {
358
- nodes: Map<NodeValue, TrackingNode> | undefined;
358
+ nodes: Map<NodeInfo, TrackingNode> | undefined;
359
359
  value: T;
360
360
  dispose: (() => void) | undefined;
361
361
  resubscribe: (() => () => void) | undefined;
@@ -391,17 +391,17 @@ declare const internal: {
391
391
  globalState: {
392
392
  isLoadingLocal: boolean;
393
393
  isLoadingRemote: boolean;
394
- activateSyncedNode: (node: NodeValue, newValue: any) => {
394
+ activateSyncedNode: (node: NodeInfo, newValue: any) => {
395
395
  update: UpdateFn;
396
396
  value: any;
397
397
  };
398
- pendingNodes: Map<NodeValue, () => void>;
399
- dirtyNodes: Set<NodeValue>;
398
+ pendingNodes: Map<NodeInfo, () => void>;
399
+ dirtyNodes: Set<NodeInfo>;
400
400
  replacer: undefined | ((this: any, key: string, value: any) => any);
401
401
  reviver: undefined | ((this: any, key: string, value: any) => any);
402
402
  };
403
403
  initializePathType: typeof initializePathType;
404
- observableFns: Map<string, (node: NodeValue, ...args: any[]) => any>;
404
+ observableFns: Map<string, (node: NodeInfo, ...args: any[]) => any>;
405
405
  optimized: symbol;
406
406
  peek: typeof peek;
407
407
  runWithRetry: typeof runWithRetry;
@@ -417,4 +417,4 @@ declare const internal: {
417
417
  };
418
418
  };
419
419
 
420
- export { type ArrayValue, type Change, type ChildNodeValue, type ClassConstructor, type GetMode, type GetOptions, type ImmutableObservableBase, type Linked, type LinkedOptions, type ListenerFn, type ListenerParams, type NodeValue, type NodeValueListener, type NotPrimitive, type Observable, type ObservableBoolean, type ObservableEvent, type ObservableListenerDispose, type ObservableObject, type ObservableObjectFns, type ObservableParam, type ObservablePrimitive, type ObservableRoot, type ObservableState, type ObservableSyncState, type ObservableSyncStateBase, type ObservableValue, type ObserveEvent, type ObserveEventCallback, type ObserveOptions, type OpaqueObject, type Primitive, type RecordValue, type RecursiveValueOrFunction, type RemoveObservables, type RetryOptions, type RootNodeValue, type Selector, type SetParams, type TrackingNode, type TrackingState, type TrackingType, type TypeAtPath, type UpdateFn, type UpdateFnParams, type WaitForSetFnParams, applyChange, applyChanges, batch, beginBatch, computeSelector, computed, configureLegendState, constructObjectWithPath, deconstructObjectWithPath, endBatch, event, getObservableIndex, hasOwnProperty, internal, isArray, isBoolean, isDate, isEmpty, isFunction, isMap, isNullOrUndefined, isNumber, isObject, isObservable, isObservableValueReady, isObserved, isPrimitive, isPromise, isString, isSymbol, linked, mergeIntoObservable, observable, observablePrimitive, observe, opaqueObject, proxy, setAtPath, setInObservableAtPath, setSilently, shouldIgnoreUnobserved, syncState, trackSelector, when, whenReady };
420
+ export { type ArrayValue, type Change, type ChildNodeInfo, type ClassConstructor, type GetMode, type GetOptions, type ImmutableObservableBase, type Linked, type LinkedOptions, type ListenerFn, type ListenerParams, type NodeInfo, type NodeListener, type NotPrimitive, type Observable, type ObservableBoolean, type ObservableEvent, type ObservableListenerDispose, type ObservableObject, type ObservableObjectFns, type ObservableParam, type ObservablePrimitive, type ObservableRoot, type ObservableState, type ObservableSyncState, type ObservableSyncStateBase, type ObservableValue, type ObserveEvent, type ObserveEventCallback, type ObserveOptions, type OpaqueObject, type Primitive, type RecordValue, type RecursiveValueOrFunction, type RemoveObservables, type RetryOptions, type RootNodeInfo, type Selector, type SetParams, type TrackingNode, type TrackingState, type TrackingType, type TypeAtPath, type UpdateFn, type UpdateFnParams, type WaitForSetFnParams, applyChange, applyChanges, batch, beginBatch, computeSelector, computed, configureLegendState, constructObjectWithPath, deconstructObjectWithPath, endBatch, event, getObservableIndex, hasOwnProperty, internal, isArray, isBoolean, isDate, isEmpty, isFunction, isMap, isNullOrUndefined, isNumber, isObject, isObservable, isObservableValueReady, isObserved, isPrimitive, isPromise, isString, isSymbol, linked, mergeIntoObservable, observable, observablePrimitive, observe, opaqueObject, proxy, setAtPath, setInObservableAtPath, setSilently, shouldIgnoreUnobserved, syncState, trackSelector, when, whenReady };
package/index.d.ts CHANGED
@@ -103,14 +103,14 @@ declare function safeStringify(value: any): any;
103
103
  declare function safeParse(value: any): any;
104
104
  declare function clone<T>(value: T): any;
105
105
  declare function isObservable(value$: any): value$ is Observable;
106
- declare function getNode(value$: ObservableParam): NodeValue;
107
- declare function setNodeValue(node: NodeValue, newValue: any): {
106
+ declare function getNode(value$: ObservableParam): NodeInfo;
107
+ declare function setNodeValue(node: NodeInfo, newValue: any): {
108
108
  prevValue: any;
109
109
  newValue: any;
110
110
  };
111
- declare function getNodeValue(node: NodeValue): any;
112
- declare function ensureNodeValue(node: NodeValue): any;
113
- declare function findIDKey(obj: unknown | undefined, node: NodeValue): string | ((value: any) => string) | undefined;
111
+ declare function getNodeValue(node: NodeInfo): any;
112
+ declare function ensureNodeValue(node: NodeInfo): any;
113
+ declare function findIDKey(obj: unknown | undefined, node: NodeInfo): string | ((value: any) => string) | undefined;
114
114
 
115
115
  type TrackingType = undefined | true | symbol;
116
116
  interface GetOptions {
@@ -151,31 +151,31 @@ interface ObservableRoot {
151
151
  }
152
152
  type Primitive = boolean | string | number | Date;
153
153
  type NotPrimitive<T> = T extends Primitive ? never : T;
154
- interface NodeValueListener {
154
+ interface NodeListener {
155
155
  track: TrackingType;
156
156
  noArgs?: boolean;
157
157
  listener: ListenerFn;
158
158
  }
159
159
  interface TrackingState {
160
- nodes?: Map<NodeValue, TrackingNode>;
161
- traceListeners?: (nodes: Map<NodeValue, TrackingNode>) => void;
160
+ nodes?: Map<NodeInfo, TrackingNode>;
161
+ traceListeners?: (nodes: Map<NodeInfo, TrackingNode>) => void;
162
162
  traceUpdates?: (fn: Function) => Function;
163
163
  }
164
- interface BaseNodeValue {
165
- children?: Map<string, ChildNodeValue>;
164
+ interface BaseNodeInfo {
165
+ children?: Map<string, ChildNodeInfo>;
166
166
  proxy?: object;
167
167
  root: ObservableRoot;
168
- listeners?: Set<NodeValueListener>;
169
- listenersImmediate?: Set<NodeValueListener>;
168
+ listeners?: Set<NodeListener>;
169
+ listenersImmediate?: Set<NodeListener>;
170
170
  isEvent?: boolean;
171
- linkedToNode?: NodeValue;
171
+ linkedToNode?: NodeInfo;
172
172
  linkedToNodeDispose?: () => void;
173
173
  activatedObserveDispose?: () => void;
174
- linkedFromNodes?: Set<NodeValue>;
174
+ linkedFromNodes?: Set<NodeInfo>;
175
175
  isSetting?: number;
176
176
  isAssigning?: number;
177
177
  isComputing?: boolean;
178
- parentOther?: NodeValue;
178
+ parentOther?: NodeInfo;
179
179
  functions?: Map<string, Function | Observable<any>>;
180
180
  lazy?: boolean;
181
181
  lazyFn?: Function;
@@ -189,21 +189,21 @@ interface BaseNodeValue {
189
189
  onChange: (params: UpdateFnParams) => void | Promise<void>;
190
190
  };
191
191
  dirtyFn?: () => void;
192
- dirtyChildren?: Set<NodeValue>;
192
+ dirtyChildren?: Set<NodeInfo>;
193
193
  numGets?: number;
194
194
  getNumResolved?: number;
195
195
  }
196
- interface RootNodeValue extends BaseNodeValue {
196
+ interface RootNodeInfo extends BaseNodeInfo {
197
197
  parent?: undefined;
198
198
  key?: undefined;
199
199
  }
200
- interface ChildNodeValue extends BaseNodeValue {
201
- parent: NodeValue;
200
+ interface ChildNodeInfo extends BaseNodeInfo {
201
+ parent: NodeInfo;
202
202
  key: string;
203
203
  }
204
- type NodeValue = RootNodeValue | ChildNodeValue;
204
+ type NodeInfo = RootNodeInfo | ChildNodeInfo;
205
205
  interface TrackingNode {
206
- node: NodeValue;
206
+ node: NodeInfo;
207
207
  track: TrackingType;
208
208
  num: number;
209
209
  }
@@ -218,7 +218,7 @@ interface ObserveEventCallback<T> {
218
218
  previous?: T | undefined;
219
219
  value?: T;
220
220
  cancel: boolean;
221
- nodes: Map<NodeValue, TrackingNode> | undefined;
221
+ nodes: Map<NodeInfo, TrackingNode> | undefined;
222
222
  refresh: () => void;
223
223
  onCleanup?: () => void;
224
224
  onCleanupReaction?: () => void;
@@ -278,12 +278,12 @@ interface RetryOptions {
278
278
  maxDelay?: number;
279
279
  }
280
280
 
281
- declare function getProxy(node: NodeValue, p?: string, asFunction?: Function): Observable;
282
- declare function set(node: NodeValue, newValue?: any): void;
283
- declare function get(node: NodeValue, options?: TrackingType | GetOptions): any;
284
- declare function peek(node: NodeValue): any;
285
- declare function isObserved(node: NodeValue): boolean;
286
- declare function shouldIgnoreUnobserved(node: NodeValue, refreshFn: () => void): true | undefined;
281
+ declare function getProxy(node: NodeInfo, p?: string, asFunction?: Function): Observable;
282
+ declare function set(node: NodeInfo, newValue?: any): void;
283
+ declare function get(node: NodeInfo, options?: TrackingType | GetOptions): any;
284
+ declare function peek(node: NodeInfo): any;
285
+ declare function isObserved(node: NodeInfo): boolean;
286
+ declare function shouldIgnoreUnobserved(node: NodeInfo, refreshFn: () => void): true | undefined;
287
287
 
288
288
  declare function createPreviousHandler(value: any, changes: Change[]): () => any;
289
289
  declare function batch(fn: () => void): void;
@@ -294,10 +294,10 @@ declare function computed<T>(get: () => RecursiveValueOrFunction<T>): Observable
294
294
  declare function computed<T, T2 = T>(get: (() => RecursiveValueOrFunction<T>) | RecursiveValueOrFunction<T>, set: (value: T2) => void): Observable<T>;
295
295
 
296
296
  declare function configureLegendState({ observableFunctions, observableProperties, jsonReplacer, jsonReviver, }: {
297
- observableFunctions?: Record<string, (node: NodeValue, ...args: any[]) => any>;
297
+ observableFunctions?: Record<string, (node: NodeInfo, ...args: any[]) => any>;
298
298
  observableProperties?: Record<string, {
299
- get: (node: NodeValue) => any;
300
- set: (node: NodeValue, value: any) => any;
299
+ get: (node: NodeInfo) => any;
300
+ set: (node: NodeInfo, value: any) => any;
301
301
  }>;
302
302
  jsonReplacer?: (this: any, key: string, value: any) => any;
303
303
  jsonReviver?: (this: any, key: string, value: any) => any;
@@ -355,7 +355,7 @@ declare function proxy<T>(get: (key: string) => T): Observable<Record<string, T>
355
355
  declare function syncState(obs: ObservableParam): Observable<ObservableSyncState>;
356
356
 
357
357
  declare function trackSelector<T>(selector: Selector<T>, update: (params: ListenerParams) => void, observeEvent?: ObserveEvent<T>, observeOptions?: ObserveOptions, createResubscribe?: boolean): {
358
- nodes: Map<NodeValue, TrackingNode> | undefined;
358
+ nodes: Map<NodeInfo, TrackingNode> | undefined;
359
359
  value: T;
360
360
  dispose: (() => void) | undefined;
361
361
  resubscribe: (() => () => void) | undefined;
@@ -391,17 +391,17 @@ declare const internal: {
391
391
  globalState: {
392
392
  isLoadingLocal: boolean;
393
393
  isLoadingRemote: boolean;
394
- activateSyncedNode: (node: NodeValue, newValue: any) => {
394
+ activateSyncedNode: (node: NodeInfo, newValue: any) => {
395
395
  update: UpdateFn;
396
396
  value: any;
397
397
  };
398
- pendingNodes: Map<NodeValue, () => void>;
399
- dirtyNodes: Set<NodeValue>;
398
+ pendingNodes: Map<NodeInfo, () => void>;
399
+ dirtyNodes: Set<NodeInfo>;
400
400
  replacer: undefined | ((this: any, key: string, value: any) => any);
401
401
  reviver: undefined | ((this: any, key: string, value: any) => any);
402
402
  };
403
403
  initializePathType: typeof initializePathType;
404
- observableFns: Map<string, (node: NodeValue, ...args: any[]) => any>;
404
+ observableFns: Map<string, (node: NodeInfo, ...args: any[]) => any>;
405
405
  optimized: symbol;
406
406
  peek: typeof peek;
407
407
  runWithRetry: typeof runWithRetry;
@@ -417,4 +417,4 @@ declare const internal: {
417
417
  };
418
418
  };
419
419
 
420
- export { type ArrayValue, type Change, type ChildNodeValue, type ClassConstructor, type GetMode, type GetOptions, type ImmutableObservableBase, type Linked, type LinkedOptions, type ListenerFn, type ListenerParams, type NodeValue, type NodeValueListener, type NotPrimitive, type Observable, type ObservableBoolean, type ObservableEvent, type ObservableListenerDispose, type ObservableObject, type ObservableObjectFns, type ObservableParam, type ObservablePrimitive, type ObservableRoot, type ObservableState, type ObservableSyncState, type ObservableSyncStateBase, type ObservableValue, type ObserveEvent, type ObserveEventCallback, type ObserveOptions, type OpaqueObject, type Primitive, type RecordValue, type RecursiveValueOrFunction, type RemoveObservables, type RetryOptions, type RootNodeValue, type Selector, type SetParams, type TrackingNode, type TrackingState, type TrackingType, type TypeAtPath, type UpdateFn, type UpdateFnParams, type WaitForSetFnParams, applyChange, applyChanges, batch, beginBatch, computeSelector, computed, configureLegendState, constructObjectWithPath, deconstructObjectWithPath, endBatch, event, getObservableIndex, hasOwnProperty, internal, isArray, isBoolean, isDate, isEmpty, isFunction, isMap, isNullOrUndefined, isNumber, isObject, isObservable, isObservableValueReady, isObserved, isPrimitive, isPromise, isString, isSymbol, linked, mergeIntoObservable, observable, observablePrimitive, observe, opaqueObject, proxy, setAtPath, setInObservableAtPath, setSilently, shouldIgnoreUnobserved, syncState, trackSelector, when, whenReady };
420
+ export { type ArrayValue, type Change, type ChildNodeInfo, type ClassConstructor, type GetMode, type GetOptions, type ImmutableObservableBase, type Linked, type LinkedOptions, type ListenerFn, type ListenerParams, type NodeInfo, type NodeListener, type NotPrimitive, type Observable, type ObservableBoolean, type ObservableEvent, type ObservableListenerDispose, type ObservableObject, type ObservableObjectFns, type ObservableParam, type ObservablePrimitive, type ObservableRoot, type ObservableState, type ObservableSyncState, type ObservableSyncStateBase, type ObservableValue, type ObserveEvent, type ObserveEventCallback, type ObserveOptions, type OpaqueObject, type Primitive, type RecordValue, type RecursiveValueOrFunction, type RemoveObservables, type RetryOptions, type RootNodeInfo, type Selector, type SetParams, type TrackingNode, type TrackingState, type TrackingType, type TypeAtPath, type UpdateFn, type UpdateFnParams, type WaitForSetFnParams, applyChange, applyChanges, batch, beginBatch, computeSelector, computed, configureLegendState, constructObjectWithPath, deconstructObjectWithPath, endBatch, event, getObservableIndex, hasOwnProperty, internal, isArray, isBoolean, isDate, isEmpty, isFunction, isMap, isNullOrUndefined, isNumber, isObject, isObservable, isObservableValueReady, isObserved, isPrimitive, isPromise, isString, isSymbol, linked, mergeIntoObservable, observable, observablePrimitive, observe, opaqueObject, proxy, setAtPath, setInObservableAtPath, setSilently, shouldIgnoreUnobserved, syncState, trackSelector, when, whenReady };
package/index.js CHANGED
@@ -61,7 +61,7 @@ var setPrimitives = /* @__PURE__ */ new Set(["boolean", "string", "number"]);
61
61
  function isActualPrimitive(arg) {
62
62
  return setPrimitives.has(typeof arg);
63
63
  }
64
- function isChildNodeValue(node) {
64
+ function isChildNode(node) {
65
65
  return !!node.parent;
66
66
  }
67
67
 
@@ -185,7 +185,7 @@ var arrNodeKeys = [];
185
185
  function getNodeValue(node) {
186
186
  let count = 0;
187
187
  let n = node;
188
- while (isChildNodeValue(n)) {
188
+ while (isChildNode(n)) {
189
189
  arrNodeKeys[count++] = n.key;
190
190
  n = n.parent;
191
191
  }
@@ -225,7 +225,7 @@ function getChildNode(node, key, asFunction) {
225
225
  function ensureNodeValue(node) {
226
226
  let value = getNodeValue(node);
227
227
  if (!value || isFunction(value)) {
228
- if (isChildNodeValue(node)) {
228
+ if (isChildNode(node)) {
229
229
  const parent = ensureNodeValue(node.parent);
230
230
  value = parent[node.key] = {};
231
231
  } else {
@@ -1115,6 +1115,7 @@ var ArrayLoopers = /* @__PURE__ */ new Set([
1115
1115
  "filter",
1116
1116
  "find",
1117
1117
  "findIndex",
1118
+ "flatMap",
1118
1119
  "forEach",
1119
1120
  "join",
1120
1121
  "map",
@@ -1144,7 +1145,7 @@ function collectionSetter(node, target, prop, ...args) {
1144
1145
  const prevValue = target.slice();
1145
1146
  const ret = target[prop].apply(target, args);
1146
1147
  if (node) {
1147
- const hasParent = isChildNodeValue(node);
1148
+ const hasParent = isChildNode(node);
1148
1149
  const key = hasParent ? node.key : "_";
1149
1150
  const parentValue = hasParent ? getNodeValue(node.parent) : node.root;
1150
1151
  parentValue[key] = prevValue;
@@ -1610,7 +1611,7 @@ function assign(node, value) {
1610
1611
  return proxy2;
1611
1612
  }
1612
1613
  function deleteFn(node, key) {
1613
- if (key === void 0 && isChildNodeValue(node)) {
1614
+ if (key === void 0 && isChildNode(node)) {
1614
1615
  key = node.key;
1615
1616
  node = node.parent;
1616
1617
  }
package/index.mjs CHANGED
@@ -59,7 +59,7 @@ var setPrimitives = /* @__PURE__ */ new Set(["boolean", "string", "number"]);
59
59
  function isActualPrimitive(arg) {
60
60
  return setPrimitives.has(typeof arg);
61
61
  }
62
- function isChildNodeValue(node) {
62
+ function isChildNode(node) {
63
63
  return !!node.parent;
64
64
  }
65
65
 
@@ -183,7 +183,7 @@ var arrNodeKeys = [];
183
183
  function getNodeValue(node) {
184
184
  let count = 0;
185
185
  let n = node;
186
- while (isChildNodeValue(n)) {
186
+ while (isChildNode(n)) {
187
187
  arrNodeKeys[count++] = n.key;
188
188
  n = n.parent;
189
189
  }
@@ -223,7 +223,7 @@ function getChildNode(node, key, asFunction) {
223
223
  function ensureNodeValue(node) {
224
224
  let value = getNodeValue(node);
225
225
  if (!value || isFunction(value)) {
226
- if (isChildNodeValue(node)) {
226
+ if (isChildNode(node)) {
227
227
  const parent = ensureNodeValue(node.parent);
228
228
  value = parent[node.key] = {};
229
229
  } else {
@@ -1113,6 +1113,7 @@ var ArrayLoopers = /* @__PURE__ */ new Set([
1113
1113
  "filter",
1114
1114
  "find",
1115
1115
  "findIndex",
1116
+ "flatMap",
1116
1117
  "forEach",
1117
1118
  "join",
1118
1119
  "map",
@@ -1142,7 +1143,7 @@ function collectionSetter(node, target, prop, ...args) {
1142
1143
  const prevValue = target.slice();
1143
1144
  const ret = target[prop].apply(target, args);
1144
1145
  if (node) {
1145
- const hasParent = isChildNodeValue(node);
1146
+ const hasParent = isChildNode(node);
1146
1147
  const key = hasParent ? node.key : "_";
1147
1148
  const parentValue = hasParent ? getNodeValue(node.parent) : node.root;
1148
1149
  parentValue[key] = prevValue;
@@ -1608,7 +1609,7 @@ function assign(node, value) {
1608
1609
  return proxy2;
1609
1610
  }
1610
1611
  function deleteFn(node, key) {
1611
- if (key === void 0 && isChildNodeValue(node)) {
1612
+ if (key === void 0 && isChildNode(node)) {
1612
1613
  key = node.key;
1613
1614
  node = node.parent;
1614
1615
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/state",
3
- "version": "3.0.0-alpha.28",
3
+ "version": "3.0.0-alpha.29",
4
4
  "description": "legend-state",
5
5
  "sideEffects": false,
6
6
  "private": false,
@@ -62,6 +62,7 @@ interface SyncedKeelConfiguration extends Omit<SyncedCrudPropsBase<any>, keyof S
62
62
  action: string;
63
63
  error: APIResult<any>['error'];
64
64
  }) => void;
65
+ refreshAuth?: () => void | Promise<void>;
65
66
  }
66
67
  interface SyncedKeelPropsManyBase<TRemote extends {
67
68
  id: string;
@@ -62,6 +62,7 @@ interface SyncedKeelConfiguration extends Omit<SyncedCrudPropsBase<any>, keyof S
62
62
  action: string;
63
63
  error: APIResult<any>['error'];
64
64
  }) => void;
65
+ refreshAuth?: () => void | Promise<void>;
65
66
  }
66
67
  interface SyncedKeelPropsManyBase<TRemote extends {
67
68
  id: string;
@@ -20,6 +20,9 @@ var modifiedClients = /* @__PURE__ */ new WeakSet();
20
20
  var isEnabled$ = state.observable(true);
21
21
  async function ensureAuthToken() {
22
22
  await state.when(isEnabled$.get());
23
+ if (keelConfig.refreshAuth) {
24
+ await keelConfig.refreshAuth();
25
+ }
23
26
  let isAuthed = await keelConfig.client.auth.isAuthenticated();
24
27
  if (!isAuthed) {
25
28
  isAuthed = await keelConfig.client.auth.refresh();
@@ -14,6 +14,9 @@ var modifiedClients = /* @__PURE__ */ new WeakSet();
14
14
  var isEnabled$ = observable(true);
15
15
  async function ensureAuthToken() {
16
16
  await when(isEnabled$.get());
17
+ if (keelConfig.refreshAuth) {
18
+ await keelConfig.refreshAuth();
19
+ }
17
20
  let isAuthed = await keelConfig.client.auth.isAuthenticated();
18
21
  if (!isAuthed) {
19
22
  isAuthed = await keelConfig.client.auth.refresh();
package/sync.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { MMKVConfiguration } from 'react-native-mmkv';
2
2
  import { AsyncStorageStatic } from '@react-native-async-storage/async-storage';
3
- import { ClassConstructor, NodeValue, ObservableParam, GetMode, SetParams, UpdateFn, LinkedOptions, RetryOptions, Change, Observable, ObservableSyncState, TypeAtPath, RecordValue, ArrayValue } from '@legendapp/state';
3
+ import { ClassConstructor, NodeInfo, ObservableParam, GetMode, SetParams, UpdateFn, LinkedOptions, RetryOptions, Change, Observable, ObservableSyncState, TypeAtPath, RecordValue, ArrayValue } from '@legendapp/state';
4
4
  import { SyncedOptionsGlobal as SyncedOptionsGlobal$1 } from '@legendapp/state/sync';
5
5
 
6
6
  interface PersistOptions<T = any> {
@@ -17,7 +17,7 @@ interface PersistOptions<T = any> {
17
17
  options?: any;
18
18
  }
19
19
  interface SyncedGetSetSubscribeBaseParams<T = any> {
20
- node: NodeValue;
20
+ node: NodeInfo;
21
21
  value$: ObservableParam<T>;
22
22
  refresh: () => void;
23
23
  }
@@ -117,7 +117,7 @@ interface ObservableSyncFunctions<T = any> {
117
117
  }>;
118
118
  }
119
119
  interface SubscribeOptions {
120
- node: NodeValue;
120
+ node: NodeInfo;
121
121
  update: UpdateFn;
122
122
  refresh: () => void;
123
123
  }
package/sync.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { MMKVConfiguration } from 'react-native-mmkv';
2
2
  import { AsyncStorageStatic } from '@react-native-async-storage/async-storage';
3
- import { ClassConstructor, NodeValue, ObservableParam, GetMode, SetParams, UpdateFn, LinkedOptions, RetryOptions, Change, Observable, ObservableSyncState, TypeAtPath, RecordValue, ArrayValue } from '@legendapp/state';
3
+ import { ClassConstructor, NodeInfo, ObservableParam, GetMode, SetParams, UpdateFn, LinkedOptions, RetryOptions, Change, Observable, ObservableSyncState, TypeAtPath, RecordValue, ArrayValue } from '@legendapp/state';
4
4
  import { SyncedOptionsGlobal as SyncedOptionsGlobal$1 } from '@legendapp/state/sync';
5
5
 
6
6
  interface PersistOptions<T = any> {
@@ -17,7 +17,7 @@ interface PersistOptions<T = any> {
17
17
  options?: any;
18
18
  }
19
19
  interface SyncedGetSetSubscribeBaseParams<T = any> {
20
- node: NodeValue;
20
+ node: NodeInfo;
21
21
  value$: ObservableParam<T>;
22
22
  refresh: () => void;
23
23
  }
@@ -117,7 +117,7 @@ interface ObservableSyncFunctions<T = any> {
117
117
  }>;
118
118
  }
119
119
  interface SubscribeOptions {
120
- node: NodeValue;
120
+ node: NodeInfo;
121
121
  update: UpdateFn;
122
122
  refresh: () => void;
123
123
  }