@legendapp/state 3.0.0-alpha.33 → 3.0.0-alpha.35
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/config.d.mts +1 -1
- package/config.d.ts +1 -1
- package/config.js +18 -12
- package/config.mjs +18 -12
- package/index.d.mts +10 -3
- package/index.d.ts +10 -3
- package/index.js +79 -42
- package/index.mjs +76 -42
- package/{observableInterfaces-CZR3_8mM.d.mts → observableInterfaces-CgBddSU6.d.mts} +6 -2
- package/{observableInterfaces-CZR3_8mM.d.ts → observableInterfaces-CgBddSU6.d.ts} +6 -2
- package/package.json +1 -1
- package/persist-plugins/async-storage.d.mts +2 -2
- package/persist-plugins/async-storage.d.ts +2 -2
- package/persist-plugins/async-storage.js +3 -7
- package/persist-plugins/async-storage.mjs +3 -7
- package/persist-plugins/indexeddb.d.mts +2 -2
- package/persist-plugins/indexeddb.d.ts +2 -2
- package/persist-plugins/indexeddb.js +3 -7
- package/persist-plugins/indexeddb.mjs +3 -7
- package/persist-plugins/mmkv.d.mts +2 -2
- package/persist-plugins/mmkv.d.ts +2 -2
- package/persist-plugins/mmkv.js +3 -7
- package/persist-plugins/mmkv.mjs +3 -7
- package/sync-plugins/crud.js +6 -7
- package/sync-plugins/crud.mjs +7 -8
- package/sync-plugins/keel.d.mts +28 -28
- package/sync-plugins/keel.d.ts +28 -28
- package/sync-plugins/keel.js +106 -82
- package/sync-plugins/keel.mjs +108 -82
- package/sync-plugins/supabase.d.mts +2 -2
- package/sync-plugins/supabase.d.ts +2 -2
- package/sync.d.mts +11 -13
- package/sync.d.ts +11 -13
- package/sync.js +149 -130
- package/sync.mjs +150 -131
package/index.mjs
CHANGED
|
@@ -9,6 +9,9 @@ function isString(obj) {
|
|
|
9
9
|
function isObject(obj) {
|
|
10
10
|
return !!obj && typeof obj === "object" && !(obj instanceof Date) && !isArray(obj);
|
|
11
11
|
}
|
|
12
|
+
function isPlainObject(obj) {
|
|
13
|
+
return isObject(obj) && obj.constructor === Object;
|
|
14
|
+
}
|
|
12
15
|
function isFunction(obj) {
|
|
13
16
|
return typeof obj === "function";
|
|
14
17
|
}
|
|
@@ -69,15 +72,19 @@ var symbolIterator = Symbol.iterator;
|
|
|
69
72
|
var symbolGetNode = Symbol("getNode");
|
|
70
73
|
var symbolDelete = /* @__PURE__ */ Symbol("delete");
|
|
71
74
|
var symbolOpaque = Symbol("opaque");
|
|
75
|
+
var symbolPlain = Symbol("plain");
|
|
72
76
|
var optimized = Symbol("optimized");
|
|
73
77
|
var symbolLinked = Symbol("linked");
|
|
74
78
|
var globalState = {
|
|
75
79
|
pendingNodes: /* @__PURE__ */ new Map(),
|
|
76
80
|
dirtyNodes: /* @__PURE__ */ new Set()
|
|
77
81
|
};
|
|
78
|
-
function
|
|
82
|
+
function isHintOpaque(value) {
|
|
79
83
|
return value && (value[symbolOpaque] || value["$$typeof"]);
|
|
80
84
|
}
|
|
85
|
+
function isHintPlain(value) {
|
|
86
|
+
return value && value[symbolPlain];
|
|
87
|
+
}
|
|
81
88
|
function getPathType(value) {
|
|
82
89
|
return isArray(value) ? "array" : isMap(value) ? "map" : value instanceof Set ? "set" : "object";
|
|
83
90
|
}
|
|
@@ -249,6 +256,27 @@ function equals(a, b) {
|
|
|
249
256
|
return a === b || isDate(a) && isDate(b) && +a === +b;
|
|
250
257
|
}
|
|
251
258
|
|
|
259
|
+
// src/ObservableHint.ts
|
|
260
|
+
function addSymbol(value, symbol) {
|
|
261
|
+
if (value) {
|
|
262
|
+
Object.defineProperty(value, symbol, {
|
|
263
|
+
value: true,
|
|
264
|
+
enumerable: false,
|
|
265
|
+
writable: true,
|
|
266
|
+
configurable: true
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
return value;
|
|
270
|
+
}
|
|
271
|
+
var ObservableHint = {
|
|
272
|
+
opaque: function opaqueObject(value) {
|
|
273
|
+
return addSymbol(value, symbolOpaque);
|
|
274
|
+
},
|
|
275
|
+
plain: function plainObject(value) {
|
|
276
|
+
return addSymbol(value, symbolPlain);
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
|
|
252
280
|
// src/helpers.ts
|
|
253
281
|
function computeSelector(selector, e, retainObservable) {
|
|
254
282
|
let c = selector;
|
|
@@ -262,7 +290,10 @@ function getObservableIndex(value$) {
|
|
|
262
290
|
const n = +node.key;
|
|
263
291
|
return isNumber(n) ? n : -1;
|
|
264
292
|
}
|
|
265
|
-
function
|
|
293
|
+
function opaqueObject2(value) {
|
|
294
|
+
if (process.env.NODE_ENV === "development") {
|
|
295
|
+
console.warn("[legend-state]: In version 3.0 opaqueObject is moved to ObservableHint.opaque");
|
|
296
|
+
}
|
|
266
297
|
if (value) {
|
|
267
298
|
value[symbolOpaque] = true;
|
|
268
299
|
}
|
|
@@ -279,16 +310,23 @@ function setAtPath(obj, path, pathTypes, value, mode, fullObj, restore) {
|
|
|
279
310
|
let oFull = fullObj;
|
|
280
311
|
for (let i = 0; i < path.length; i++) {
|
|
281
312
|
p = path[i];
|
|
282
|
-
|
|
313
|
+
const map = isMap(o);
|
|
314
|
+
let child = o ? map ? o.get(p) : o[p] : void 0;
|
|
315
|
+
const fullChild = oFull ? map ? oFull.get(p) : oFull[p] : void 0;
|
|
316
|
+
if (child === symbolDelete) {
|
|
283
317
|
if (oFull) {
|
|
284
|
-
|
|
285
|
-
|
|
318
|
+
if (map) {
|
|
319
|
+
o.set(p, fullChild);
|
|
320
|
+
} else {
|
|
321
|
+
o[p] = fullChild;
|
|
322
|
+
}
|
|
323
|
+
restore == null ? void 0 : restore(path.slice(0, i + 1), fullChild);
|
|
286
324
|
}
|
|
287
325
|
return obj;
|
|
288
|
-
} else if (
|
|
326
|
+
} else if (child === void 0 && value === void 0 && i === path.length - 1) {
|
|
289
327
|
return obj;
|
|
290
|
-
} else if (i < path.length - 1 && (
|
|
291
|
-
|
|
328
|
+
} else if (i < path.length - 1 && (child === void 0 || child === null)) {
|
|
329
|
+
child = initializePathType(pathTypes[i]);
|
|
292
330
|
if (isMap(o)) {
|
|
293
331
|
o.set(p, child);
|
|
294
332
|
} else {
|
|
@@ -296,9 +334,9 @@ function setAtPath(obj, path, pathTypes, value, mode, fullObj, restore) {
|
|
|
296
334
|
}
|
|
297
335
|
}
|
|
298
336
|
if (i < path.length - 1) {
|
|
299
|
-
o =
|
|
337
|
+
o = child;
|
|
300
338
|
if (oFull) {
|
|
301
|
-
oFull =
|
|
339
|
+
oFull = fullChild;
|
|
302
340
|
}
|
|
303
341
|
}
|
|
304
342
|
}
|
|
@@ -328,18 +366,12 @@ function mergeIntoObservable(target, ...sources) {
|
|
|
328
366
|
}
|
|
329
367
|
beginBatch();
|
|
330
368
|
for (let i = 0; i < sources.length; i++) {
|
|
331
|
-
_mergeIntoObservable(
|
|
332
|
-
target,
|
|
333
|
-
sources[i],
|
|
334
|
-
/*assign*/
|
|
335
|
-
i < sources.length - 1,
|
|
336
|
-
0
|
|
337
|
-
);
|
|
369
|
+
_mergeIntoObservable(target, sources[i], 0);
|
|
338
370
|
}
|
|
339
371
|
endBatch();
|
|
340
372
|
return target;
|
|
341
373
|
}
|
|
342
|
-
function _mergeIntoObservable(target, source,
|
|
374
|
+
function _mergeIntoObservable(target, source, levelsDeep) {
|
|
343
375
|
if (isObservable(source)) {
|
|
344
376
|
source = source.peek();
|
|
345
377
|
}
|
|
@@ -365,7 +397,7 @@ function _mergeIntoObservable(target, source, assign2, levelsDeep) {
|
|
|
365
397
|
if (levelsDeep > 0 && isEmpty(sourceValue)) {
|
|
366
398
|
targetChild.set(sourceValue);
|
|
367
399
|
}
|
|
368
|
-
_mergeIntoObservable(targetChild, sourceValue,
|
|
400
|
+
_mergeIntoObservable(targetChild, sourceValue, levelsDeep + 1);
|
|
369
401
|
} else {
|
|
370
402
|
targetChild.set(sourceValue);
|
|
371
403
|
}
|
|
@@ -435,7 +467,7 @@ function deepMerge(target, ...sources) {
|
|
|
435
467
|
let result = isArray(target) ? [...target] : { ...target };
|
|
436
468
|
for (let i = 0; i < sources.length; i++) {
|
|
437
469
|
const obj2 = sources[i];
|
|
438
|
-
if (
|
|
470
|
+
if (isPlainObject(obj2) || isArray(obj2)) {
|
|
439
471
|
const objTarget = obj2;
|
|
440
472
|
for (const key in objTarget) {
|
|
441
473
|
if (hasOwnProperty.call(objTarget, key)) {
|
|
@@ -1151,7 +1183,7 @@ function updateNodes(parent, obj, prevValue) {
|
|
|
1151
1183
|
}
|
|
1152
1184
|
__devUpdateNodes.add(obj);
|
|
1153
1185
|
}
|
|
1154
|
-
if (isObject(obj) &&
|
|
1186
|
+
if (isObject(obj) && isHintOpaque(obj) || isObject(prevValue) && isHintOpaque(prevValue)) {
|
|
1155
1187
|
const isDiff = obj !== prevValue;
|
|
1156
1188
|
if (isDiff) {
|
|
1157
1189
|
if (parent.listeners || parent.listenersImmediate) {
|
|
@@ -1387,7 +1419,7 @@ var proxyHandler = {
|
|
|
1387
1419
|
return property.get(node);
|
|
1388
1420
|
}
|
|
1389
1421
|
let vProp = value == null ? void 0 : value[p];
|
|
1390
|
-
if (isObject(value) &&
|
|
1422
|
+
if (isObject(value) && isHintOpaque(value)) {
|
|
1391
1423
|
return vProp;
|
|
1392
1424
|
}
|
|
1393
1425
|
const fnOrComputed = (_a = node.functions) == null ? void 0 : _a.get(p);
|
|
@@ -2088,14 +2120,14 @@ function setToObservable(node, value) {
|
|
|
2088
2120
|
return value;
|
|
2089
2121
|
}
|
|
2090
2122
|
function recursivelyAutoActivate(obj, node) {
|
|
2091
|
-
if (!node.recursivelyAutoActivated && (isObject(obj) || isArray(obj)) && !
|
|
2123
|
+
if (!node.recursivelyAutoActivated && (isObject(obj) || isArray(obj)) && !isHintOpaque(obj)) {
|
|
2092
2124
|
node.recursivelyAutoActivated = true;
|
|
2093
2125
|
const pathStack = [];
|
|
2094
2126
|
const getNodeAtPath2 = () => {
|
|
2095
2127
|
var _a;
|
|
2096
2128
|
let childNode = node;
|
|
2097
2129
|
for (let i = 0; i < pathStack.length; i++) {
|
|
2098
|
-
const
|
|
2130
|
+
const key = pathStack[i];
|
|
2099
2131
|
const value = (_a = getNodeValue(childNode)) == null ? void 0 : _a[key];
|
|
2100
2132
|
childNode = getChildNode(childNode, key, isFunction(value) ? value : void 0);
|
|
2101
2133
|
peekInternal(childNode);
|
|
@@ -2107,7 +2139,7 @@ function recursivelyAutoActivate(obj, node) {
|
|
|
2107
2139
|
}
|
|
2108
2140
|
function recursivelyAutoActivateInner(obj, pathStack, getNodeAtPath2) {
|
|
2109
2141
|
var _a;
|
|
2110
|
-
if ((isObject(obj) || isArray(obj)) && !
|
|
2142
|
+
if ((isObject(obj) || isArray(obj)) && !isHintOpaque(obj) && !isHintPlain(obj)) {
|
|
2111
2143
|
for (const key in obj) {
|
|
2112
2144
|
if (hasOwnProperty.call(obj, key)) {
|
|
2113
2145
|
const value = obj[key];
|
|
@@ -2126,7 +2158,7 @@ function recursivelyAutoActivateInner(obj, pathStack, getNodeAtPath2) {
|
|
|
2126
2158
|
}
|
|
2127
2159
|
}
|
|
2128
2160
|
if (typeof value === "object") {
|
|
2129
|
-
pathStack.push(
|
|
2161
|
+
pathStack.push(key);
|
|
2130
2162
|
recursivelyAutoActivateInner(value, pathStack, getNodeAtPath2);
|
|
2131
2163
|
pathStack.pop();
|
|
2132
2164
|
}
|
|
@@ -2227,21 +2259,23 @@ function proxy(get2, set2) {
|
|
|
2227
2259
|
function syncState(obs) {
|
|
2228
2260
|
const node = getNode(obs);
|
|
2229
2261
|
if (!node.state) {
|
|
2230
|
-
node.state = observable(
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2262
|
+
node.state = observable(
|
|
2263
|
+
ObservableHint.plain({
|
|
2264
|
+
isPersistLoaded: false,
|
|
2265
|
+
isLoaded: false,
|
|
2266
|
+
isPersistEnabled: true,
|
|
2267
|
+
isSyncEnabled: true,
|
|
2268
|
+
isGetting: false,
|
|
2269
|
+
isSetting: false,
|
|
2270
|
+
numPendingGets: 0,
|
|
2271
|
+
numPendingSets: 0,
|
|
2272
|
+
syncCount: 0,
|
|
2273
|
+
clearPersist: void 0,
|
|
2274
|
+
reset: () => Promise.resolve(),
|
|
2275
|
+
sync: () => Promise.resolve(),
|
|
2276
|
+
getPendingChanges: () => ({})
|
|
2277
|
+
})
|
|
2278
|
+
);
|
|
2245
2279
|
}
|
|
2246
2280
|
return node.state;
|
|
2247
2281
|
}
|
|
@@ -2274,4 +2308,4 @@ var internal = {
|
|
|
2274
2308
|
tracking
|
|
2275
2309
|
};
|
|
2276
2310
|
|
|
2277
|
-
export { ObservablePrimitiveClass, applyChange, applyChanges, batch, beginBatch, beginTracking, computeSelector, computed, constructObjectWithPath, deconstructObjectWithPath, endBatch, endTracking, event, findIDKey, getNode, getNodeValue, 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, optimized, proxy, setAtPath, setSilently, setupTracking, shouldIgnoreUnobserved, symbolDelete, syncState, trackSelector, tracking, updateTracking, when, whenReady };
|
|
2311
|
+
export { ObservableHint, ObservablePrimitiveClass, applyChange, applyChanges, batch, beginBatch, beginTracking, computeSelector, computed, constructObjectWithPath, deconstructObjectWithPath, endBatch, endTracking, event, findIDKey, getNode, getNodeValue, getObservableIndex, hasOwnProperty, internal, isArray, isBoolean, isDate, isEmpty, isFunction, isMap, isNullOrUndefined, isNumber, isObject, isObservable, isObservableValueReady, isObserved, isPlainObject, isPrimitive, isPromise, isSet, isString, isSymbol, linked, mergeIntoObservable, observable, observablePrimitive, observe, opaqueObject2 as opaqueObject, optimized, proxy, setAtPath, setSilently, setupTracking, shouldIgnoreUnobserved, symbolDelete, syncState, trackSelector, tracking, updateTracking, when, whenReady };
|
|
@@ -98,6 +98,7 @@ type ValueOrFunctionKeys<T> = {
|
|
|
98
98
|
type RecursiveValueOrFunction<T> = T extends Function ? T : T extends object ? ((key: string) => any) | Promise<ValueOrFunctionKeys<T>> | ValueOrFunctionKeys<T> | ImmutableObservableBase<T> | (() => T | Promise<T> | ValueOrFunctionKeys<T> | Promise<ValueOrFunctionKeys<T>> | Observable<T>) : ValueOrFunction<T>;
|
|
99
99
|
|
|
100
100
|
declare const symbolOpaque: unique symbol;
|
|
101
|
+
declare const symbolPlain: unique symbol;
|
|
101
102
|
declare function getPathType(value: any): TypeAtPath;
|
|
102
103
|
declare function safeStringify(value: any): any;
|
|
103
104
|
declare function safeParse(value: any): any;
|
|
@@ -119,6 +120,9 @@ interface GetOptions {
|
|
|
119
120
|
type OpaqueObject<T> = T & {
|
|
120
121
|
[symbolOpaque]: true;
|
|
121
122
|
};
|
|
123
|
+
type PlainObject<T> = T & {
|
|
124
|
+
[symbolPlain]: true;
|
|
125
|
+
};
|
|
122
126
|
interface ListenerParams<T = any> {
|
|
123
127
|
value: T;
|
|
124
128
|
getPrevious: () => T;
|
|
@@ -228,7 +232,7 @@ type WaitForSet<T> = ((params: WaitForSetFnParams<T>) => any) | Promise<any> | O
|
|
|
228
232
|
interface LinkedOptions<T = any> {
|
|
229
233
|
get?: () => Promise<T> | T;
|
|
230
234
|
set?: (params: SetParams<T>) => void | Promise<any>;
|
|
231
|
-
waitFor?: Selector<
|
|
235
|
+
waitFor?: Selector<unknown>;
|
|
232
236
|
waitForSet?: WaitForSet<T>;
|
|
233
237
|
initial?: (() => T) | T;
|
|
234
238
|
activate?: 'auto' | 'lazy';
|
|
@@ -280,4 +284,4 @@ interface RetryOptions {
|
|
|
280
284
|
maxDelay?: number;
|
|
281
285
|
}
|
|
282
286
|
|
|
283
|
-
export { type
|
|
287
|
+
export { type RemoveObservables as $, type ArrayValue as A, type ClassConstructor as B, type Change as C, type ObservableListenerDispose as D, type ObservableRoot as E, type Primitive as F, type GetOptions as G, type NotPrimitive as H, type NodeListener as I, type RootNodeInfo as J, type ChildNodeInfo as K, type LinkedOptions as L, type SetParams as M, type NodeInfo as N, type OpaqueObject as O, type PlainObject as P, type WaitForSetFnParams as Q, type RecursiveValueOrFunction as R, type Selector as S, type TrackingType as T, type UpdateFn as U, type GetMode as V, type WaitForSet as W, type UpdateFnParams as X, type ObservableSyncStateBase as Y, type ObservableState as Z, type RetryOptions as _, type Observable as a, type ObservableObjectFns as a0, type ObservableBoolean as a1, type ImmutableObservableBase as a2, type ObservableObject as a3, type ObservableEvent as b, type ObserveEvent as c, type ObservableParam as d, type TypeAtPath as e, type Linked as f, type ObservablePrimitive as g, type ObserveOptions as h, type ObserveEventCallback as i, type ObservableSyncState as j, type ListenerParams as k, type TrackingNode as l, clone as m, ensureNodeValue as n, findIDKey as o, getNode as p, getNodeValue as q, getPathType as r, safeParse as s, safeStringify as t, setNodeValue as u, type TrackingState as v, isObservable as w, type ListenerFn as x, type RecordValue as y, type ObservableValue as z };
|
|
@@ -98,6 +98,7 @@ type ValueOrFunctionKeys<T> = {
|
|
|
98
98
|
type RecursiveValueOrFunction<T> = T extends Function ? T : T extends object ? ((key: string) => any) | Promise<ValueOrFunctionKeys<T>> | ValueOrFunctionKeys<T> | ImmutableObservableBase<T> | (() => T | Promise<T> | ValueOrFunctionKeys<T> | Promise<ValueOrFunctionKeys<T>> | Observable<T>) : ValueOrFunction<T>;
|
|
99
99
|
|
|
100
100
|
declare const symbolOpaque: unique symbol;
|
|
101
|
+
declare const symbolPlain: unique symbol;
|
|
101
102
|
declare function getPathType(value: any): TypeAtPath;
|
|
102
103
|
declare function safeStringify(value: any): any;
|
|
103
104
|
declare function safeParse(value: any): any;
|
|
@@ -119,6 +120,9 @@ interface GetOptions {
|
|
|
119
120
|
type OpaqueObject<T> = T & {
|
|
120
121
|
[symbolOpaque]: true;
|
|
121
122
|
};
|
|
123
|
+
type PlainObject<T> = T & {
|
|
124
|
+
[symbolPlain]: true;
|
|
125
|
+
};
|
|
122
126
|
interface ListenerParams<T = any> {
|
|
123
127
|
value: T;
|
|
124
128
|
getPrevious: () => T;
|
|
@@ -228,7 +232,7 @@ type WaitForSet<T> = ((params: WaitForSetFnParams<T>) => any) | Promise<any> | O
|
|
|
228
232
|
interface LinkedOptions<T = any> {
|
|
229
233
|
get?: () => Promise<T> | T;
|
|
230
234
|
set?: (params: SetParams<T>) => void | Promise<any>;
|
|
231
|
-
waitFor?: Selector<
|
|
235
|
+
waitFor?: Selector<unknown>;
|
|
232
236
|
waitForSet?: WaitForSet<T>;
|
|
233
237
|
initial?: (() => T) | T;
|
|
234
238
|
activate?: 'auto' | 'lazy';
|
|
@@ -280,4 +284,4 @@ interface RetryOptions {
|
|
|
280
284
|
maxDelay?: number;
|
|
281
285
|
}
|
|
282
286
|
|
|
283
|
-
export { type
|
|
287
|
+
export { type RemoveObservables as $, type ArrayValue as A, type ClassConstructor as B, type Change as C, type ObservableListenerDispose as D, type ObservableRoot as E, type Primitive as F, type GetOptions as G, type NotPrimitive as H, type NodeListener as I, type RootNodeInfo as J, type ChildNodeInfo as K, type LinkedOptions as L, type SetParams as M, type NodeInfo as N, type OpaqueObject as O, type PlainObject as P, type WaitForSetFnParams as Q, type RecursiveValueOrFunction as R, type Selector as S, type TrackingType as T, type UpdateFn as U, type GetMode as V, type WaitForSet as W, type UpdateFnParams as X, type ObservableSyncStateBase as Y, type ObservableState as Z, type RetryOptions as _, type Observable as a, type ObservableObjectFns as a0, type ObservableBoolean as a1, type ImmutableObservableBase as a2, type ObservableObject as a3, type ObservableEvent as b, type ObserveEvent as c, type ObservableParam as d, type TypeAtPath as e, type Linked as f, type ObservablePrimitive as g, type ObserveOptions as h, type ObserveEventCallback as i, type ObservableSyncState as j, type ListenerParams as k, type TrackingNode as l, clone as m, ensureNodeValue as n, findIDKey as o, getNode as p, getNodeValue as q, getPathType as r, safeParse as s, safeStringify as t, setNodeValue as u, type TrackingState as v, isObservable as w, type ListenerFn as x, type RecordValue as y, type ObservableValue as z };
|
package/package.json
CHANGED
|
@@ -16,6 +16,6 @@ declare class ObservablePersistAsyncStorage implements ObservablePersistPlugin {
|
|
|
16
16
|
private setValue;
|
|
17
17
|
private save;
|
|
18
18
|
}
|
|
19
|
-
declare function
|
|
19
|
+
declare function observablePersistAsyncStorage(configuration: ObservablePersistAsyncStoragePluginOptions): ObservablePersistAsyncStorage;
|
|
20
20
|
|
|
21
|
-
export { ObservablePersistAsyncStorage,
|
|
21
|
+
export { ObservablePersistAsyncStorage, observablePersistAsyncStorage };
|
|
@@ -16,6 +16,6 @@ declare class ObservablePersistAsyncStorage implements ObservablePersistPlugin {
|
|
|
16
16
|
private setValue;
|
|
17
17
|
private save;
|
|
18
18
|
}
|
|
19
|
-
declare function
|
|
19
|
+
declare function observablePersistAsyncStorage(configuration: ObservablePersistAsyncStoragePluginOptions): ObservablePersistAsyncStorage;
|
|
20
20
|
|
|
21
|
-
export { ObservablePersistAsyncStorage,
|
|
21
|
+
export { ObservablePersistAsyncStorage, observablePersistAsyncStorage };
|
|
@@ -87,13 +87,9 @@ var ObservablePersistAsyncStorage = class {
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
};
|
|
90
|
-
function
|
|
91
|
-
return
|
|
92
|
-
constructor() {
|
|
93
|
-
super(configuration);
|
|
94
|
-
}
|
|
95
|
-
};
|
|
90
|
+
function observablePersistAsyncStorage(configuration) {
|
|
91
|
+
return new ObservablePersistAsyncStorage(configuration);
|
|
96
92
|
}
|
|
97
93
|
|
|
98
94
|
exports.ObservablePersistAsyncStorage = ObservablePersistAsyncStorage;
|
|
99
|
-
exports.
|
|
95
|
+
exports.observablePersistAsyncStorage = observablePersistAsyncStorage;
|
|
@@ -85,12 +85,8 @@ var ObservablePersistAsyncStorage = class {
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
|
-
function
|
|
89
|
-
return
|
|
90
|
-
constructor() {
|
|
91
|
-
super(configuration);
|
|
92
|
-
}
|
|
93
|
-
};
|
|
88
|
+
function observablePersistAsyncStorage(configuration) {
|
|
89
|
+
return new ObservablePersistAsyncStorage(configuration);
|
|
94
90
|
}
|
|
95
91
|
|
|
96
|
-
export { ObservablePersistAsyncStorage,
|
|
92
|
+
export { ObservablePersistAsyncStorage, observablePersistAsyncStorage };
|
|
@@ -26,6 +26,6 @@ declare class ObservablePersistIndexedDB implements ObservablePersistPlugin {
|
|
|
26
26
|
private _setItem;
|
|
27
27
|
private _setTable;
|
|
28
28
|
}
|
|
29
|
-
declare function
|
|
29
|
+
declare function observablePersistIndexedDB(configuration: ObservablePersistIndexedDBPluginOptions): ObservablePersistIndexedDB;
|
|
30
30
|
|
|
31
|
-
export { ObservablePersistIndexedDB,
|
|
31
|
+
export { ObservablePersistIndexedDB, observablePersistIndexedDB };
|
|
@@ -26,6 +26,6 @@ declare class ObservablePersistIndexedDB implements ObservablePersistPlugin {
|
|
|
26
26
|
private _setItem;
|
|
27
27
|
private _setTable;
|
|
28
28
|
}
|
|
29
|
-
declare function
|
|
29
|
+
declare function observablePersistIndexedDB(configuration: ObservablePersistIndexedDBPluginOptions): ObservablePersistIndexedDB;
|
|
30
30
|
|
|
31
|
-
export { ObservablePersistIndexedDB,
|
|
31
|
+
export { ObservablePersistIndexedDB, observablePersistIndexedDB };
|
|
@@ -365,13 +365,9 @@ var ObservablePersistIndexedDB = class {
|
|
|
365
365
|
return lastSet;
|
|
366
366
|
}
|
|
367
367
|
};
|
|
368
|
-
function
|
|
369
|
-
return
|
|
370
|
-
constructor() {
|
|
371
|
-
super(configuration);
|
|
372
|
-
}
|
|
373
|
-
};
|
|
368
|
+
function observablePersistIndexedDB(configuration) {
|
|
369
|
+
return new ObservablePersistIndexedDB(configuration);
|
|
374
370
|
}
|
|
375
371
|
|
|
376
372
|
exports.ObservablePersistIndexedDB = ObservablePersistIndexedDB;
|
|
377
|
-
exports.
|
|
373
|
+
exports.observablePersistIndexedDB = observablePersistIndexedDB;
|
|
@@ -363,12 +363,8 @@ var ObservablePersistIndexedDB = class {
|
|
|
363
363
|
return lastSet;
|
|
364
364
|
}
|
|
365
365
|
};
|
|
366
|
-
function
|
|
367
|
-
return
|
|
368
|
-
constructor() {
|
|
369
|
-
super(configuration);
|
|
370
|
-
}
|
|
371
|
-
};
|
|
366
|
+
function observablePersistIndexedDB(configuration) {
|
|
367
|
+
return new ObservablePersistIndexedDB(configuration);
|
|
372
368
|
}
|
|
373
369
|
|
|
374
|
-
export { ObservablePersistIndexedDB,
|
|
370
|
+
export { ObservablePersistIndexedDB, observablePersistIndexedDB };
|
|
@@ -17,6 +17,6 @@ declare class ObservablePersistMMKV implements ObservablePersistPlugin {
|
|
|
17
17
|
private setValue;
|
|
18
18
|
private save;
|
|
19
19
|
}
|
|
20
|
-
declare function
|
|
20
|
+
declare function observablePersistMMKV(configuration: MMKVConfiguration): ObservablePersistMMKV;
|
|
21
21
|
|
|
22
|
-
export { ObservablePersistMMKV,
|
|
22
|
+
export { ObservablePersistMMKV, observablePersistMMKV };
|
|
@@ -17,6 +17,6 @@ declare class ObservablePersistMMKV implements ObservablePersistPlugin {
|
|
|
17
17
|
private setValue;
|
|
18
18
|
private save;
|
|
19
19
|
}
|
|
20
|
-
declare function
|
|
20
|
+
declare function observablePersistMMKV(configuration: MMKVConfiguration): ObservablePersistMMKV;
|
|
21
21
|
|
|
22
|
-
export { ObservablePersistMMKV,
|
|
22
|
+
export { ObservablePersistMMKV, observablePersistMMKV };
|
package/persist-plugins/mmkv.js
CHANGED
|
@@ -91,13 +91,9 @@ var ObservablePersistMMKV = class {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
|
-
function
|
|
95
|
-
return
|
|
96
|
-
constructor() {
|
|
97
|
-
super(configuration);
|
|
98
|
-
}
|
|
99
|
-
};
|
|
94
|
+
function observablePersistMMKV(configuration) {
|
|
95
|
+
return new ObservablePersistMMKV(configuration);
|
|
100
96
|
}
|
|
101
97
|
|
|
102
98
|
exports.ObservablePersistMMKV = ObservablePersistMMKV;
|
|
103
|
-
exports.
|
|
99
|
+
exports.observablePersistMMKV = observablePersistMMKV;
|
package/persist-plugins/mmkv.mjs
CHANGED
|
@@ -89,12 +89,8 @@ var ObservablePersistMMKV = class {
|
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
};
|
|
92
|
-
function
|
|
93
|
-
return
|
|
94
|
-
constructor() {
|
|
95
|
-
super(configuration);
|
|
96
|
-
}
|
|
97
|
-
};
|
|
92
|
+
function observablePersistMMKV(configuration) {
|
|
93
|
+
return new ObservablePersistMMKV(configuration);
|
|
98
94
|
}
|
|
99
95
|
|
|
100
|
-
export { ObservablePersistMMKV,
|
|
96
|
+
export { ObservablePersistMMKV, observablePersistMMKV };
|
package/sync-plugins/crud.js
CHANGED
|
@@ -62,10 +62,9 @@ function syncedCrud(props) {
|
|
|
62
62
|
const out = asType === "array" ? [] : asMap ? /* @__PURE__ */ new Map() : {};
|
|
63
63
|
for (let i = 0; i < results.length; i++) {
|
|
64
64
|
let result = results[i];
|
|
65
|
-
const
|
|
66
|
-
const value = isObs ? result.peek() : result;
|
|
65
|
+
const value = result;
|
|
67
66
|
if (value) {
|
|
68
|
-
result =
|
|
67
|
+
result = fieldDeleted && result[fieldDeleted] || fieldDeletedList && result[fieldDeletedList] || result[state.symbolDelete] ? state.internal.symbolDelete : result;
|
|
69
68
|
if (asArray) {
|
|
70
69
|
out.push(result);
|
|
71
70
|
} else if (asMap) {
|
|
@@ -169,7 +168,7 @@ function syncedCrud(props) {
|
|
|
169
168
|
if (createFn) {
|
|
170
169
|
creates.set(id, value);
|
|
171
170
|
} else {
|
|
172
|
-
console.
|
|
171
|
+
console.warn("[legend-state] missing create function");
|
|
173
172
|
}
|
|
174
173
|
} else if (path.length === 0) {
|
|
175
174
|
if (valueAtPath) {
|
|
@@ -239,7 +238,7 @@ function syncedCrud(props) {
|
|
|
239
238
|
pendingCreates.add(item.id);
|
|
240
239
|
creates.set(item.id, item);
|
|
241
240
|
} else {
|
|
242
|
-
console.
|
|
241
|
+
console.warn("[legend-state] missing create function");
|
|
243
242
|
}
|
|
244
243
|
} else {
|
|
245
244
|
if (updateFn) {
|
|
@@ -248,7 +247,7 @@ function syncedCrud(props) {
|
|
|
248
247
|
updates.has(item.id) ? Object.assign(updates.get(item.id), item) : item
|
|
249
248
|
);
|
|
250
249
|
} else {
|
|
251
|
-
console.
|
|
250
|
+
console.warn("[legend-state] missing update function");
|
|
252
251
|
}
|
|
253
252
|
}
|
|
254
253
|
});
|
|
@@ -337,7 +336,7 @@ function syncedCrud(props) {
|
|
|
337
336
|
console.error("[legend-state]: deleting item without an id");
|
|
338
337
|
}
|
|
339
338
|
} else {
|
|
340
|
-
console.
|
|
339
|
+
console.warn("[legend-state] missing delete function");
|
|
341
340
|
}
|
|
342
341
|
}
|
|
343
342
|
})
|
package/sync-plugins/crud.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isPromise, applyChanges, isNullOrUndefined, setAtPath, symbolDelete, isArray, internal,
|
|
1
|
+
import { isPromise, applyChanges, isNullOrUndefined, setAtPath, symbolDelete, isArray, internal, getNodeValue } from '@legendapp/state';
|
|
2
2
|
import { synced, deepEqual, internal as internal$1, diffObjects } from '@legendapp/state/sync';
|
|
3
3
|
|
|
4
4
|
// src/sync-plugins/crud.ts
|
|
@@ -60,10 +60,9 @@ function syncedCrud(props) {
|
|
|
60
60
|
const out = asType === "array" ? [] : asMap ? /* @__PURE__ */ new Map() : {};
|
|
61
61
|
for (let i = 0; i < results.length; i++) {
|
|
62
62
|
let result = results[i];
|
|
63
|
-
const
|
|
64
|
-
const value = isObs ? result.peek() : result;
|
|
63
|
+
const value = result;
|
|
65
64
|
if (value) {
|
|
66
|
-
result =
|
|
65
|
+
result = fieldDeleted && result[fieldDeleted] || fieldDeletedList && result[fieldDeletedList] || result[symbolDelete] ? internal.symbolDelete : result;
|
|
67
66
|
if (asArray) {
|
|
68
67
|
out.push(result);
|
|
69
68
|
} else if (asMap) {
|
|
@@ -167,7 +166,7 @@ function syncedCrud(props) {
|
|
|
167
166
|
if (createFn) {
|
|
168
167
|
creates.set(id, value);
|
|
169
168
|
} else {
|
|
170
|
-
console.
|
|
169
|
+
console.warn("[legend-state] missing create function");
|
|
171
170
|
}
|
|
172
171
|
} else if (path.length === 0) {
|
|
173
172
|
if (valueAtPath) {
|
|
@@ -237,7 +236,7 @@ function syncedCrud(props) {
|
|
|
237
236
|
pendingCreates.add(item.id);
|
|
238
237
|
creates.set(item.id, item);
|
|
239
238
|
} else {
|
|
240
|
-
console.
|
|
239
|
+
console.warn("[legend-state] missing create function");
|
|
241
240
|
}
|
|
242
241
|
} else {
|
|
243
242
|
if (updateFn) {
|
|
@@ -246,7 +245,7 @@ function syncedCrud(props) {
|
|
|
246
245
|
updates.has(item.id) ? Object.assign(updates.get(item.id), item) : item
|
|
247
246
|
);
|
|
248
247
|
} else {
|
|
249
|
-
console.
|
|
248
|
+
console.warn("[legend-state] missing update function");
|
|
250
249
|
}
|
|
251
250
|
}
|
|
252
251
|
});
|
|
@@ -335,7 +334,7 @@ function syncedCrud(props) {
|
|
|
335
334
|
console.error("[legend-state]: deleting item without an id");
|
|
336
335
|
}
|
|
337
336
|
} else {
|
|
338
|
-
console.
|
|
337
|
+
console.warn("[legend-state] missing delete function");
|
|
339
338
|
}
|
|
340
339
|
}
|
|
341
340
|
})
|