@legendapp/state 3.0.0-alpha.8 → 3.0.0-beta.0
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/.DS_Store +0 -0
- package/config/configureLegendState.d.mts +13 -0
- package/config/configureLegendState.d.ts +13 -0
- package/config/configureLegendState.js +45 -0
- package/config/configureLegendState.mjs +43 -0
- package/config/enable$GetSet.js +2 -1
- package/config/enable$GetSet.mjs +2 -1
- package/config/enableReactTracking.js +2 -1
- package/config/enableReactTracking.mjs +2 -1
- package/config/enableReactUse.js +2 -1
- package/config/enableReactUse.mjs +2 -1
- package/config/enable_PeekAssign.js +2 -1
- package/config/enable_PeekAssign.mjs +2 -1
- package/helpers/trackHistory.js +2 -2
- package/helpers/trackHistory.mjs +2 -2
- package/index.d.mts +104 -80
- package/index.d.ts +104 -80
- package/index.js +328 -318
- package/index.mjs +325 -316
- package/package.json +36 -1
- package/persist-plugins/async-storage.d.mts +6 -3
- package/persist-plugins/async-storage.d.ts +6 -3
- package/persist-plugins/async-storage.js +8 -4
- package/persist-plugins/async-storage.mjs +8 -5
- package/persist-plugins/indexeddb.d.mts +6 -4
- package/persist-plugins/indexeddb.d.ts +6 -4
- package/persist-plugins/indexeddb.js +35 -15
- package/persist-plugins/indexeddb.mjs +35 -16
- package/persist-plugins/mmkv.d.mts +5 -1
- package/persist-plugins/mmkv.d.ts +5 -1
- package/persist-plugins/mmkv.js +10 -5
- package/persist-plugins/mmkv.mjs +10 -6
- package/react-reactive/enableReactComponents.d.mts +9 -0
- package/react-reactive/enableReactComponents.d.ts +9 -0
- package/react-reactive/enableReactComponents.js +19 -0
- package/react-reactive/enableReactComponents.mjs +17 -0
- package/react-reactive/enableReactNativeComponents.d.mts +22 -0
- package/react-reactive/enableReactNativeComponents.d.ts +22 -0
- package/react-reactive/enableReactNativeComponents.js +53 -0
- package/react-reactive/enableReactNativeComponents.mjs +51 -0
- package/react-reactive/enableReactive.d.mts +5 -0
- package/react-reactive/enableReactive.d.ts +5 -0
- package/react-reactive/enableReactive.js +24 -0
- package/react-reactive/enableReactive.mjs +22 -0
- package/react-reactive/enableReactive.native.d.mts +5 -0
- package/react-reactive/enableReactive.native.d.ts +5 -0
- package/react-reactive/enableReactive.native.js +58 -0
- package/react-reactive/enableReactive.native.mjs +56 -0
- package/react-reactive/enableReactive.web.d.mts +5 -0
- package/react-reactive/enableReactive.web.d.ts +5 -0
- package/react-reactive/enableReactive.web.js +58 -0
- package/react-reactive/enableReactive.web.mjs +56 -0
- package/react.d.mts +39 -34
- package/react.d.ts +39 -34
- package/react.js +39 -17
- package/react.mjs +39 -17
- package/sync-plugins/crud.d.mts +21 -24
- package/sync-plugins/crud.d.ts +21 -24
- package/sync-plugins/crud.js +241 -140
- package/sync-plugins/crud.mjs +243 -142
- package/sync-plugins/fetch.js +12 -8
- package/sync-plugins/fetch.mjs +13 -9
- package/sync-plugins/firebase.d.mts +27 -0
- package/sync-plugins/firebase.d.ts +27 -0
- package/sync-plugins/firebase.js +373 -0
- package/sync-plugins/firebase.mjs +368 -0
- package/sync-plugins/keel.d.mts +43 -26
- package/sync-plugins/keel.d.ts +43 -26
- package/sync-plugins/keel.js +145 -100
- package/sync-plugins/keel.mjs +147 -100
- package/sync-plugins/supabase.d.mts +19 -9
- package/sync-plugins/supabase.d.ts +19 -9
- package/sync-plugins/supabase.js +52 -22
- package/sync-plugins/supabase.mjs +53 -23
- package/sync-plugins/tanstack-query.d.mts +2 -2
- package/sync-plugins/tanstack-query.d.ts +2 -2
- package/sync-plugins/tanstack-query.js +22 -5
- package/sync-plugins/tanstack-query.mjs +22 -5
- package/sync-plugins/tanstack-react-query.d.mts +1 -1
- package/sync-plugins/tanstack-react-query.d.ts +1 -1
- package/sync-plugins/tanstack-react-query.js +8 -1
- package/sync-plugins/tanstack-react-query.mjs +8 -1
- package/sync.d.mts +74 -200
- package/sync.d.ts +74 -200
- package/sync.js +492 -293
- package/sync.mjs +498 -299
package/.DS_Store
CHANGED
|
Binary file
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { NodeInfo } from '@legendapp/state';
|
|
2
|
+
|
|
3
|
+
declare function configureLegendState({ observableFunctions, observableProperties, jsonReplacer, jsonReviver, }: {
|
|
4
|
+
observableFunctions?: Record<string, (node: NodeInfo, ...args: any[]) => any>;
|
|
5
|
+
observableProperties?: Record<string, {
|
|
6
|
+
get: (node: NodeInfo) => any;
|
|
7
|
+
set: (node: NodeInfo, value: any) => any;
|
|
8
|
+
}>;
|
|
9
|
+
jsonReplacer?: (this: any, key: string, value: any) => any;
|
|
10
|
+
jsonReviver?: (this: any, key: string, value: any) => any;
|
|
11
|
+
}): void;
|
|
12
|
+
|
|
13
|
+
export { configureLegendState };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { NodeInfo } from '@legendapp/state';
|
|
2
|
+
|
|
3
|
+
declare function configureLegendState({ observableFunctions, observableProperties, jsonReplacer, jsonReviver, }: {
|
|
4
|
+
observableFunctions?: Record<string, (node: NodeInfo, ...args: any[]) => any>;
|
|
5
|
+
observableProperties?: Record<string, {
|
|
6
|
+
get: (node: NodeInfo) => any;
|
|
7
|
+
set: (node: NodeInfo, value: any) => any;
|
|
8
|
+
}>;
|
|
9
|
+
jsonReplacer?: (this: any, key: string, value: any) => any;
|
|
10
|
+
jsonReviver?: (this: any, key: string, value: any) => any;
|
|
11
|
+
}): void;
|
|
12
|
+
|
|
13
|
+
export { configureLegendState };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var state = require('@legendapp/state');
|
|
4
|
+
|
|
5
|
+
// src/config/configureLegendState.ts
|
|
6
|
+
var { globalState, observableProperties: _observableProperties, observableFns, ObservablePrimitiveClass } = state.internal;
|
|
7
|
+
function configureLegendState({
|
|
8
|
+
observableFunctions,
|
|
9
|
+
observableProperties,
|
|
10
|
+
jsonReplacer,
|
|
11
|
+
jsonReviver
|
|
12
|
+
}) {
|
|
13
|
+
if (observableFunctions) {
|
|
14
|
+
for (const key in observableFunctions) {
|
|
15
|
+
const fn = observableFunctions[key];
|
|
16
|
+
observableFns.set(key, fn);
|
|
17
|
+
ObservablePrimitiveClass.prototype[key] = function(...args) {
|
|
18
|
+
return fn.call(this, this._node, ...args);
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (observableProperties) {
|
|
23
|
+
for (const key in observableProperties) {
|
|
24
|
+
const fns = observableProperties[key];
|
|
25
|
+
_observableProperties.set(key, fns);
|
|
26
|
+
Object.defineProperty(ObservablePrimitiveClass.prototype, key, {
|
|
27
|
+
configurable: true,
|
|
28
|
+
get() {
|
|
29
|
+
return fns.get.call(this, this._node);
|
|
30
|
+
},
|
|
31
|
+
set(value) {
|
|
32
|
+
return fns.set.call(this, this._node, value);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (jsonReplacer) {
|
|
38
|
+
globalState.replacer = jsonReplacer;
|
|
39
|
+
}
|
|
40
|
+
if (jsonReviver) {
|
|
41
|
+
globalState.reviver = jsonReviver;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
exports.configureLegendState = configureLegendState;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { internal } from '@legendapp/state';
|
|
2
|
+
|
|
3
|
+
// src/config/configureLegendState.ts
|
|
4
|
+
var { globalState, observableProperties: _observableProperties, observableFns, ObservablePrimitiveClass } = internal;
|
|
5
|
+
function configureLegendState({
|
|
6
|
+
observableFunctions,
|
|
7
|
+
observableProperties,
|
|
8
|
+
jsonReplacer,
|
|
9
|
+
jsonReviver
|
|
10
|
+
}) {
|
|
11
|
+
if (observableFunctions) {
|
|
12
|
+
for (const key in observableFunctions) {
|
|
13
|
+
const fn = observableFunctions[key];
|
|
14
|
+
observableFns.set(key, fn);
|
|
15
|
+
ObservablePrimitiveClass.prototype[key] = function(...args) {
|
|
16
|
+
return fn.call(this, this._node, ...args);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (observableProperties) {
|
|
21
|
+
for (const key in observableProperties) {
|
|
22
|
+
const fns = observableProperties[key];
|
|
23
|
+
_observableProperties.set(key, fns);
|
|
24
|
+
Object.defineProperty(ObservablePrimitiveClass.prototype, key, {
|
|
25
|
+
configurable: true,
|
|
26
|
+
get() {
|
|
27
|
+
return fns.get.call(this, this._node);
|
|
28
|
+
},
|
|
29
|
+
set(value) {
|
|
30
|
+
return fns.set.call(this, this._node, value);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (jsonReplacer) {
|
|
36
|
+
globalState.replacer = jsonReplacer;
|
|
37
|
+
}
|
|
38
|
+
if (jsonReviver) {
|
|
39
|
+
globalState.reviver = jsonReviver;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { configureLegendState };
|
package/config/enable$GetSet.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var state = require('@legendapp/state');
|
|
4
|
+
var configureLegendState = require('@legendapp/state/config/configureLegendState');
|
|
4
5
|
|
|
5
6
|
// src/config/enable$GetSet.ts
|
|
6
7
|
function enable$GetSet() {
|
|
7
|
-
|
|
8
|
+
configureLegendState.configureLegendState({
|
|
8
9
|
observableProperties: {
|
|
9
10
|
$: {
|
|
10
11
|
get(node) {
|
package/config/enable$GetSet.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var state = require('@legendapp/state');
|
|
4
|
+
var configureLegendState = require('@legendapp/state/config/configureLegendState');
|
|
4
5
|
var react$1 = require('@legendapp/state/react');
|
|
5
6
|
var react = require('react');
|
|
6
7
|
|
|
@@ -22,7 +23,7 @@ function enableReactTracking({ auto, warnUnobserved }) {
|
|
|
22
23
|
}
|
|
23
24
|
return false;
|
|
24
25
|
};
|
|
25
|
-
|
|
26
|
+
configureLegendState.configureLegendState({
|
|
26
27
|
observableFunctions: {
|
|
27
28
|
get: (node, options) => {
|
|
28
29
|
if (needsSelector()) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isObject, internal, tracking } from '@legendapp/state';
|
|
2
|
+
import { configureLegendState } from '@legendapp/state/config/configureLegendState';
|
|
2
3
|
import { useSelector } from '@legendapp/state/react';
|
|
3
4
|
import { createContext, __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, useContext } from 'react';
|
|
4
5
|
|
package/config/enableReactUse.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var state = require('@legendapp/state');
|
|
4
|
+
var configureLegendState = require('@legendapp/state/config/configureLegendState');
|
|
4
5
|
var react = require('@legendapp/state/react');
|
|
5
6
|
|
|
6
7
|
// src/config/enableReactUse.ts
|
|
7
8
|
var didWarn = false;
|
|
8
9
|
function enableReactUse() {
|
|
9
|
-
|
|
10
|
+
configureLegendState.configureLegendState({
|
|
10
11
|
observableFunctions: {
|
|
11
12
|
use: (node, options) => {
|
|
12
13
|
if (process.env.NODE_ENV === "development" && !didWarn) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { internal } from '@legendapp/state';
|
|
2
|
+
import { configureLegendState } from '@legendapp/state/config/configureLegendState';
|
|
2
3
|
import { useSelector } from '@legendapp/state/react';
|
|
3
4
|
|
|
4
5
|
// src/config/enableReactUse.ts
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var state = require('@legendapp/state');
|
|
4
|
+
var configureLegendState = require('@legendapp/state/config/configureLegendState');
|
|
4
5
|
|
|
5
6
|
// src/config/enable_PeekAssign.ts
|
|
6
7
|
function enable_PeekAssign() {
|
|
7
|
-
|
|
8
|
+
configureLegendState.configureLegendState({
|
|
8
9
|
observableProperties: {
|
|
9
10
|
_: {
|
|
10
11
|
get(node) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { internal } from '@legendapp/state';
|
|
2
|
+
import { configureLegendState } from '@legendapp/state/config/configureLegendState';
|
|
2
3
|
|
|
3
4
|
// src/config/enable_PeekAssign.ts
|
|
4
5
|
function enable_PeekAssign() {
|
package/helpers/trackHistory.js
CHANGED
|
@@ -5,8 +5,8 @@ var state = require('@legendapp/state');
|
|
|
5
5
|
// src/helpers/trackHistory.ts
|
|
6
6
|
function trackHistory(value$, targetObservable) {
|
|
7
7
|
const history = targetObservable != null ? targetObservable : state.observable();
|
|
8
|
-
value$.onChange(({
|
|
9
|
-
if (!
|
|
8
|
+
value$.onChange(({ isFromPersist, isFromSync, changes }) => {
|
|
9
|
+
if (!isFromPersist && !isFromSync) {
|
|
10
10
|
const time = Date.now().toString();
|
|
11
11
|
for (let i = 0; i < changes.length; i++) {
|
|
12
12
|
const { path, prevAtPath, pathTypes } = changes[i];
|
package/helpers/trackHistory.mjs
CHANGED
|
@@ -3,8 +3,8 @@ import { observable, constructObjectWithPath, mergeIntoObservable } from '@legen
|
|
|
3
3
|
// src/helpers/trackHistory.ts
|
|
4
4
|
function trackHistory(value$, targetObservable) {
|
|
5
5
|
const history = targetObservable != null ? targetObservable : observable();
|
|
6
|
-
value$.onChange(({
|
|
7
|
-
if (!
|
|
6
|
+
value$.onChange(({ isFromPersist, isFromSync, changes }) => {
|
|
7
|
+
if (!isFromPersist && !isFromSync) {
|
|
8
8
|
const time = Date.now().toString();
|
|
9
9
|
for (let i = 0; i < changes.length; i++) {
|
|
10
10
|
const { path, prevAtPath, pathTypes } = changes[i];
|