@legendapp/state 3.0.0-alpha.1 → 3.0.0-alpha.3
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/CHANGELOG.md +1 -831
- package/LICENSE +1 -21
- package/README.md +1 -141
- package/as/arrayAsRecord.d.mts +5 -0
- package/as/arrayAsRecord.d.ts +5 -0
- package/as/arrayAsRecord.js +28 -0
- package/as/arrayAsRecord.mjs +26 -0
- package/as/arrayAsSet.d.mts +5 -0
- package/as/arrayAsSet.d.ts +5 -0
- package/as/arrayAsSet.js +13 -0
- package/as/arrayAsSet.mjs +11 -0
- package/as/arrayAsString.d.mts +5 -0
- package/as/arrayAsString.d.ts +5 -0
- package/as/arrayAsString.js +13 -0
- package/as/arrayAsString.mjs +11 -0
- package/as/numberAsString.d.mts +5 -0
- package/as/numberAsString.d.ts +5 -0
- package/as/numberAsString.js +13 -0
- package/as/numberAsString.mjs +11 -0
- package/as/recordAsArray.d.mts +5 -0
- package/as/recordAsArray.d.ts +5 -0
- package/as/recordAsArray.js +25 -0
- package/as/recordAsArray.mjs +23 -0
- package/as/recordAsString.d.mts +5 -0
- package/as/recordAsString.d.ts +5 -0
- package/as/recordAsString.js +13 -0
- package/as/recordAsString.mjs +11 -0
- package/as/setAsArray.d.mts +5 -0
- package/as/setAsArray.d.ts +5 -0
- package/as/setAsArray.js +13 -0
- package/as/setAsArray.mjs +11 -0
- package/as/setAsString.d.mts +5 -0
- package/as/setAsString.d.ts +5 -0
- package/as/setAsString.js +13 -0
- package/as/setAsString.mjs +11 -0
- package/as/stringAsArray.d.mts +5 -0
- package/as/stringAsArray.d.ts +5 -0
- package/as/stringAsArray.js +13 -0
- package/as/stringAsArray.mjs +11 -0
- package/as/stringAsNumber.d.mts +5 -0
- package/as/stringAsNumber.d.ts +5 -0
- package/as/stringAsNumber.js +16 -0
- package/as/stringAsNumber.mjs +14 -0
- package/as/stringAsRecord.d.mts +5 -0
- package/as/stringAsRecord.d.ts +5 -0
- package/as/stringAsRecord.js +15 -0
- package/as/stringAsRecord.mjs +13 -0
- package/as/stringAsSet.d.mts +5 -0
- package/as/stringAsSet.d.ts +5 -0
- package/as/stringAsSet.js +13 -0
- package/as/stringAsSet.mjs +11 -0
- package/babel.d.mts +21 -0
- package/babel.d.ts +21 -2
- package/babel.js +57 -53
- package/babel.mjs +65 -0
- package/config/enable$GetSet.js +13 -14
- package/config/enable$GetSet.mjs +13 -14
- package/config/enableReactComponents.d.mts +9 -0
- package/config/enableReactComponents.d.ts +4 -2
- package/config/enableReactComponents.js +13 -10
- package/config/enableReactComponents.mjs +13 -10
- package/config/enableReactNativeComponents.d.mts +22 -0
- package/config/enableReactNativeComponents.d.ts +6 -4
- package/config/enableReactNativeComponents.js +43 -47
- package/config/enableReactNativeComponents.mjs +43 -47
- package/config/enableReactTracking.d.mts +7 -0
- package/config/enableReactTracking.d.ts +3 -2
- package/config/enableReactTracking.js +33 -38
- package/config/enableReactTracking.mjs +33 -38
- package/config/enableReactUse.d.mts +10 -0
- package/config/enableReactUse.d.ts +4 -1
- package/config/enableReactUse.js +15 -14
- package/config/enableReactUse.mjs +15 -14
- package/config/{enable$GetSet.d.ts → enable_GetSet.d.mts} +4 -2
- package/config/enable_GetSet.d.ts +10 -0
- package/config/enable_PeekAssign.d.mts +10 -0
- package/config/enable_PeekAssign.d.ts +4 -2
- package/config/enable_PeekAssign.js +13 -14
- package/config/enable_PeekAssign.mjs +13 -14
- package/helpers/pageHash.d.mts +9 -0
- package/helpers/pageHash.d.ts +2 -0
- package/helpers/pageHash.js +25 -30
- package/helpers/pageHash.mjs +25 -30
- package/helpers/pageHashParams.d.mts +9 -0
- package/helpers/pageHashParams.d.ts +2 -0
- package/helpers/pageHashParams.js +34 -37
- package/helpers/pageHashParams.mjs +34 -37
- package/helpers/time.d.mts +6 -0
- package/helpers/time.d.ts +6 -3
- package/helpers/time.js +17 -17
- package/helpers/time.mjs +17 -17
- package/helpers/trackHistory.d.mts +6 -0
- package/helpers/trackHistory.d.ts +4 -2
- package/helpers/trackHistory.js +13 -16
- package/helpers/trackHistory.mjs +13 -16
- package/helpers/undoRedo.d.mts +37 -0
- package/helpers/undoRedo.d.ts +5 -3
- package/helpers/undoRedo.js +59 -94
- package/helpers/undoRedo.mjs +59 -94
- package/index.d.mts +404 -0
- package/index.d.ts +371 -28
- package/index.js +2015 -2166
- package/index.mjs +2015 -2166
- package/package.json +254 -195
- package/persist-plugins/async-storage.d.mts +18 -0
- package/persist-plugins/async-storage.d.ts +6 -3
- package/persist-plugins/async-storage.js +79 -86
- package/persist-plugins/async-storage.mjs +79 -86
- package/persist-plugins/indexeddb.d.mts +29 -0
- package/persist-plugins/indexeddb.d.ts +6 -3
- package/persist-plugins/indexeddb.js +331 -352
- package/persist-plugins/indexeddb.mjs +331 -352
- package/persist-plugins/local-storage.d.mts +23 -0
- package/persist-plugins/local-storage.d.ts +8 -5
- package/persist-plugins/local-storage.js +74 -76
- package/persist-plugins/local-storage.mjs +74 -76
- package/persist-plugins/mmkv.d.mts +18 -0
- package/persist-plugins/mmkv.d.ts +6 -3
- package/persist-plugins/mmkv.js +82 -86
- package/persist-plugins/mmkv.mjs +82 -86
- package/react-hooks/createObservableHook.d.mts +5 -0
- package/react-hooks/createObservableHook.d.ts +4 -1
- package/react-hooks/createObservableHook.js +29 -30
- package/react-hooks/createObservableHook.mjs +25 -30
- package/react-hooks/useHover.d.mts +5 -0
- package/react-hooks/useHover.d.ts +5 -3
- package/react-hooks/useHover.js +29 -29
- package/react-hooks/useHover.mjs +29 -29
- package/react-hooks/useMeasure.d.mts +9 -0
- package/react-hooks/useMeasure.d.ts +5 -2
- package/react-hooks/useMeasure.js +30 -32
- package/react-hooks/useMeasure.mjs +30 -32
- package/react-hooks/useObservableNextRouter.d.mts +35 -0
- package/react-hooks/useObservableNextRouter.d.ts +9 -7
- package/react-hooks/useObservableNextRouter.js +64 -77
- package/react-hooks/useObservableNextRouter.mjs +60 -77
- package/react.d.mts +157 -0
- package/react.d.ts +157 -21
- package/react.js +458 -749
- package/react.mjs +457 -752
- package/sync-plugins/crud.d.mts +54 -0
- package/sync-plugins/crud.d.ts +12 -10
- package/sync-plugins/crud.js +253 -270
- package/sync-plugins/crud.mjs +253 -270
- package/sync-plugins/fetch.d.mts +21 -0
- package/sync-plugins/fetch.d.ts +7 -4
- package/sync-plugins/fetch.js +50 -37
- package/sync-plugins/fetch.mjs +50 -37
- package/sync-plugins/keel.d.mts +108 -0
- package/sync-plugins/keel.d.ts +17 -15
- package/sync-plugins/keel.js +229 -462
- package/sync-plugins/keel.mjs +227 -464
- package/sync-plugins/supabase.d.mts +39 -0
- package/sync-plugins/supabase.d.ts +16 -14
- package/sync-plugins/supabase.js +128 -128
- package/sync-plugins/supabase.mjs +128 -128
- package/sync-plugins/tanstack-query.d.mts +14 -0
- package/sync-plugins/tanstack-query.d.ts +7 -4
- package/sync-plugins/tanstack-query.js +51 -57
- package/sync-plugins/tanstack-query.mjs +51 -57
- package/sync-plugins/tanstack-react-query.d.mts +8 -0
- package/sync-plugins/tanstack-react-query.d.ts +6 -1
- package/sync-plugins/tanstack-react-query.js +2 -2
- package/sync-plugins/tanstack-react-query.mjs +2 -2
- package/sync.d.mts +351 -0
- package/sync.d.ts +349 -9
- package/sync.js +910 -964
- package/sync.mjs +920 -974
- package/trace.d.mts +9 -0
- package/trace.d.ts +9 -4
- package/trace.js +72 -62
- package/trace.mjs +72 -62
- package/types/babel.d.ts +1 -12
- package/babel.js.map +0 -1
- package/config/enable$GetSet.js.map +0 -1
- package/config/enable$GetSet.mjs.map +0 -1
- package/config/enableReactComponents.js.map +0 -1
- package/config/enableReactComponents.mjs.map +0 -1
- package/config/enableReactNativeComponents.js.map +0 -1
- package/config/enableReactNativeComponents.mjs.map +0 -1
- package/config/enableReactTracking.js.map +0 -1
- package/config/enableReactTracking.mjs.map +0 -1
- package/config/enableReactUse.js.map +0 -1
- package/config/enableReactUse.mjs.map +0 -1
- package/config/enable_PeekAssign.js.map +0 -1
- package/config/enable_PeekAssign.mjs.map +0 -1
- package/helpers/pageHash.js.map +0 -1
- package/helpers/pageHash.mjs.map +0 -1
- package/helpers/pageHashParams.js.map +0 -1
- package/helpers/pageHashParams.mjs.map +0 -1
- package/helpers/time.js.map +0 -1
- package/helpers/time.mjs.map +0 -1
- package/helpers/trackHistory.js.map +0 -1
- package/helpers/trackHistory.mjs.map +0 -1
- package/helpers/undoRedo.js.map +0 -1
- package/helpers/undoRedo.mjs.map +0 -1
- package/history.d.ts +0 -1
- package/history.js +0 -24
- package/history.js.map +0 -1
- package/history.mjs +0 -22
- package/history.mjs.map +0 -1
- package/index.js.map +0 -1
- package/index.mjs.map +0 -1
- package/persist-plugins/async-storage.js.map +0 -1
- package/persist-plugins/async-storage.mjs.map +0 -1
- package/persist-plugins/indexeddb.js.map +0 -1
- package/persist-plugins/indexeddb.mjs.map +0 -1
- package/persist-plugins/local-storage.js.map +0 -1
- package/persist-plugins/local-storage.mjs.map +0 -1
- package/persist-plugins/mmkv.js.map +0 -1
- package/persist-plugins/mmkv.mjs.map +0 -1
- package/react-hooks/createObservableHook.js.map +0 -1
- package/react-hooks/createObservableHook.mjs.map +0 -1
- package/react-hooks/useHover.js.map +0 -1
- package/react-hooks/useHover.mjs.map +0 -1
- package/react-hooks/useMeasure.js.map +0 -1
- package/react-hooks/useMeasure.mjs.map +0 -1
- package/react-hooks/useObservableNextRouter.js.map +0 -1
- package/react-hooks/useObservableNextRouter.mjs.map +0 -1
- package/react.js.map +0 -1
- package/react.mjs.map +0 -1
- package/src/ObservableObject.ts +0 -1350
- package/src/ObservablePrimitive.ts +0 -62
- package/src/babel/index.ts +0 -83
- package/src/batching.ts +0 -357
- package/src/computed.ts +0 -18
- package/src/config/enable$GetSet.ts +0 -30
- package/src/config/enableReactComponents.ts +0 -26
- package/src/config/enableReactNativeComponents.ts +0 -102
- package/src/config/enableReactTracking.ts +0 -62
- package/src/config/enableReactUse.ts +0 -32
- package/src/config/enable_PeekAssign.ts +0 -31
- package/src/config.ts +0 -47
- package/src/createObservable.ts +0 -47
- package/src/event.ts +0 -26
- package/src/globals.ts +0 -235
- package/src/helpers/pageHash.ts +0 -41
- package/src/helpers/pageHashParams.ts +0 -55
- package/src/helpers/time.ts +0 -30
- package/src/helpers/trackHistory.ts +0 -29
- package/src/helpers/undoRedo.ts +0 -111
- package/src/helpers.ts +0 -231
- package/src/is.ts +0 -63
- package/src/linked.ts +0 -17
- package/src/observable.ts +0 -32
- package/src/observableInterfaces.ts +0 -151
- package/src/observableTypes.ts +0 -232
- package/src/observe.ts +0 -89
- package/src/old-plugins/firebase.ts +0 -1053
- package/src/onChange.ts +0 -146
- package/src/persist/configureObservablePersistence.ts +0 -7
- package/src/persist/fieldTransformer.ts +0 -149
- package/src/persist/observablePersistRemoteFunctionsAdapter.ts +0 -39
- package/src/persist/persistObservable.ts +0 -1034
- package/src/persist-plugins/async-storage.ts +0 -99
- package/src/persist-plugins/indexeddb.ts +0 -439
- package/src/persist-plugins/local-storage.ts +0 -86
- package/src/persist-plugins/mmkv.ts +0 -91
- package/src/proxy.ts +0 -28
- package/src/react/Computed.tsx +0 -8
- package/src/react/For.tsx +0 -116
- package/src/react/Memo.tsx +0 -4
- package/src/react/Reactive.tsx +0 -53
- package/src/react/Show.tsx +0 -33
- package/src/react/Switch.tsx +0 -43
- package/src/react/react-globals.ts +0 -3
- package/src/react/reactInterfaces.ts +0 -32
- package/src/react/reactive-observer.tsx +0 -210
- package/src/react/useComputed.ts +0 -36
- package/src/react/useEffectOnce.ts +0 -41
- package/src/react/useIsMounted.ts +0 -16
- package/src/react/useMount.ts +0 -15
- package/src/react/useObservable.ts +0 -24
- package/src/react/useObservableReducer.ts +0 -52
- package/src/react/useObservableState.ts +0 -30
- package/src/react/useObserve.ts +0 -54
- package/src/react/useObserveEffect.ts +0 -40
- package/src/react/usePauseProvider.tsx +0 -16
- package/src/react/useSelector.ts +0 -167
- package/src/react/useUnmount.ts +0 -8
- package/src/react/useWhen.ts +0 -9
- package/src/react-hooks/createObservableHook.ts +0 -53
- package/src/react-hooks/useHover.ts +0 -40
- package/src/react-hooks/useMeasure.ts +0 -48
- package/src/react-hooks/useObservableNextRouter.ts +0 -137
- package/src/retry.ts +0 -71
- package/src/setupTracking.ts +0 -26
- package/src/sync/activateSyncedNode.ts +0 -128
- package/src/sync/configureObservableSync.ts +0 -7
- package/src/sync/persistTypes.ts +0 -216
- package/src/sync/syncHelpers.ts +0 -180
- package/src/sync/syncObservable.ts +0 -1056
- package/src/sync/syncObservableAdapter.ts +0 -31
- package/src/sync/syncTypes.ts +0 -189
- package/src/sync/synced.ts +0 -21
- package/src/sync-plugins/crud.ts +0 -412
- package/src/sync-plugins/fetch.ts +0 -80
- package/src/sync-plugins/keel.ts +0 -495
- package/src/sync-plugins/supabase.ts +0 -249
- package/src/sync-plugins/tanstack-query.ts +0 -113
- package/src/sync-plugins/tanstack-react-query.ts +0 -12
- package/src/trace/traceHelpers.ts +0 -11
- package/src/trace/useTraceListeners.ts +0 -34
- package/src/trace/useTraceUpdates.ts +0 -24
- package/src/trace/useVerifyNotTracking.ts +0 -33
- package/src/trace/useVerifyOneRender.ts +0 -10
- package/src/trackSelector.ts +0 -52
- package/src/tracking.ts +0 -43
- package/src/types/babel.d.ts +0 -12
- package/src/when.ts +0 -75
- package/sync-plugins/crud.js.map +0 -1
- package/sync-plugins/crud.mjs.map +0 -1
- package/sync-plugins/fetch.js.map +0 -1
- package/sync-plugins/fetch.mjs.map +0 -1
- package/sync-plugins/keel.js.map +0 -1
- package/sync-plugins/keel.mjs.map +0 -1
- package/sync-plugins/supabase.js.map +0 -1
- package/sync-plugins/supabase.mjs.map +0 -1
- package/sync-plugins/tanstack-query.js.map +0 -1
- package/sync-plugins/tanstack-query.mjs.map +0 -1
- package/sync-plugins/tanstack-react-query.js.map +0 -1
- package/sync-plugins/tanstack-react-query.mjs.map +0 -1
- package/sync.js.map +0 -1
- package/sync.mjs.map +0 -1
- package/trace.js.map +0 -1
- package/trace.mjs.map +0 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var state = require('@legendapp/state');
|
|
4
|
+
|
|
5
|
+
// src/as/stringAsRecord.ts
|
|
6
|
+
function stringAsRecord(str$) {
|
|
7
|
+
return state.linked({
|
|
8
|
+
get: () => {
|
|
9
|
+
return JSON.parse((str$ == null ? void 0 : str$.get()) || "{}");
|
|
10
|
+
},
|
|
11
|
+
set: ({ value }) => str$ == null ? void 0 : str$.set(JSON.stringify(value))
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
exports.stringAsRecord = stringAsRecord;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { linked } from '@legendapp/state';
|
|
2
|
+
|
|
3
|
+
// src/as/stringAsRecord.ts
|
|
4
|
+
function stringAsRecord(str$) {
|
|
5
|
+
return linked({
|
|
6
|
+
get: () => {
|
|
7
|
+
return JSON.parse((str$ == null ? void 0 : str$.get()) || "{}");
|
|
8
|
+
},
|
|
9
|
+
set: ({ value }) => str$ == null ? void 0 : str$.set(JSON.stringify(value))
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { stringAsRecord };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var state = require('@legendapp/state');
|
|
4
|
+
|
|
5
|
+
// src/as/stringAsSet.ts
|
|
6
|
+
function stringAsSet(str$) {
|
|
7
|
+
return state.linked({
|
|
8
|
+
get: () => new Set(JSON.parse((str$ == null ? void 0 : str$.get()) || "[]")),
|
|
9
|
+
set: ({ value }) => str$ == null ? void 0 : str$.set(JSON.stringify(Array.from(value)))
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
exports.stringAsSet = stringAsSet;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { linked } from '@legendapp/state';
|
|
2
|
+
|
|
3
|
+
// src/as/stringAsSet.ts
|
|
4
|
+
function stringAsSet(str$) {
|
|
5
|
+
return linked({
|
|
6
|
+
get: () => new Set(JSON.parse((str$ == null ? void 0 : str$.get()) || "[]")),
|
|
7
|
+
set: ({ value }) => str$ == null ? void 0 : str$.set(JSON.stringify(Array.from(value)))
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { stringAsSet };
|
package/babel.d.mts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
declare function export_default(): {
|
|
2
|
+
visitor: {
|
|
3
|
+
ImportDeclaration: {
|
|
4
|
+
enter(path: {
|
|
5
|
+
node: any;
|
|
6
|
+
replaceWith: (param: any) => any;
|
|
7
|
+
skip: () => void;
|
|
8
|
+
}): void;
|
|
9
|
+
};
|
|
10
|
+
JSXElement: {
|
|
11
|
+
enter(path: {
|
|
12
|
+
node: any;
|
|
13
|
+
replaceWith: (param: any) => any;
|
|
14
|
+
skip: () => void;
|
|
15
|
+
traverse: (path: any) => any;
|
|
16
|
+
}): void;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { export_default as default };
|
package/babel.d.ts
CHANGED
|
@@ -1,2 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
declare function export_default(): {
|
|
2
|
+
visitor: {
|
|
3
|
+
ImportDeclaration: {
|
|
4
|
+
enter(path: {
|
|
5
|
+
node: any;
|
|
6
|
+
replaceWith: (param: any) => any;
|
|
7
|
+
skip: () => void;
|
|
8
|
+
}): void;
|
|
9
|
+
};
|
|
10
|
+
JSXElement: {
|
|
11
|
+
enter(path: {
|
|
12
|
+
node: any;
|
|
13
|
+
replaceWith: (param: any) => any;
|
|
14
|
+
skip: () => void;
|
|
15
|
+
traverse: (path: any) => any;
|
|
16
|
+
}): void;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { export_default as default };
|
package/babel.js
CHANGED
|
@@ -2,62 +2,66 @@
|
|
|
2
2
|
|
|
3
3
|
var types = require('@babel/types');
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
5
|
+
// src/babel/index.ts
|
|
6
|
+
function babel_default() {
|
|
7
|
+
let hasLegendImport = false;
|
|
8
|
+
return {
|
|
9
|
+
visitor: {
|
|
10
|
+
ImportDeclaration: {
|
|
11
|
+
enter(path) {
|
|
12
|
+
if (path.node.source.value === "@legendapp/state/react") {
|
|
13
|
+
const specifiers = path.node.specifiers;
|
|
14
|
+
for (let i = 0; i < specifiers.length; i++) {
|
|
15
|
+
const s = specifiers[i].imported.name;
|
|
16
|
+
if (!hasLegendImport && (s === "Computed" || s === "Memo" || s === "Show")) {
|
|
17
|
+
hasLegendImport = true;
|
|
18
|
+
path.skip();
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
JSXElement: {
|
|
26
|
+
enter(path) {
|
|
27
|
+
if (!hasLegendImport) {
|
|
28
|
+
path.skip();
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const openingElement = path.node.openingElement;
|
|
32
|
+
const name = openingElement.name.name;
|
|
33
|
+
if (name === "Computed" || name === "Memo" || name === "Show") {
|
|
34
|
+
const children = removeEmptyText(path.node.children);
|
|
35
|
+
if (children.length === 0)
|
|
36
|
+
return;
|
|
37
|
+
if (children[0].type === "JSXElement" || children[0].type === "JSXExpressionContainer" && children[0].expression.type !== "ArrowFunctionExpression" && children[0].expression.type !== "FunctionExpression" && children[0].expression.type !== "MemberExpression" && children[0].expression.type !== "Identifier") {
|
|
38
|
+
const attrs = openingElement.attributes;
|
|
39
|
+
path.replaceWith(
|
|
40
|
+
types.jsxElement(
|
|
41
|
+
types.jsxOpeningElement(types.jsxIdentifier(name), attrs),
|
|
42
|
+
types.jsxClosingElement(types.jsxIdentifier(name)),
|
|
43
|
+
[types.jsxExpressionContainer(types.arrowFunctionExpression([], maybeWrapFragment(children)))]
|
|
44
|
+
)
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
50
52
|
}
|
|
51
53
|
function maybeWrapFragment(children) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
if (children.length === 1 && children[0].type == "JSXElement")
|
|
55
|
+
return children[0];
|
|
56
|
+
if (children.length === 1 && children[0].type == "JSXExpressionContainer")
|
|
57
|
+
return children[0].expression;
|
|
58
|
+
return types.jsxFragment(types.jsxOpeningFragment(), types.jsxClosingFragment(), children);
|
|
57
59
|
}
|
|
58
60
|
function removeEmptyText(nodes) {
|
|
59
|
-
|
|
61
|
+
return nodes.filter((node) => !(node.type === "JSXText" && node.value.trim().length === 0));
|
|
60
62
|
}
|
|
61
63
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
// babel.ts
|
|
65
|
+
var babel_default2 = babel_default;
|
|
66
|
+
|
|
67
|
+
module.exports = babel_default2;
|
package/babel.mjs
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { jsxElement, jsxOpeningElement, jsxIdentifier, jsxClosingElement, jsxExpressionContainer, arrowFunctionExpression, jsxFragment, jsxOpeningFragment, jsxClosingFragment } from '@babel/types';
|
|
2
|
+
|
|
3
|
+
// src/babel/index.ts
|
|
4
|
+
function babel_default() {
|
|
5
|
+
let hasLegendImport = false;
|
|
6
|
+
return {
|
|
7
|
+
visitor: {
|
|
8
|
+
ImportDeclaration: {
|
|
9
|
+
enter(path) {
|
|
10
|
+
if (path.node.source.value === "@legendapp/state/react") {
|
|
11
|
+
const specifiers = path.node.specifiers;
|
|
12
|
+
for (let i = 0; i < specifiers.length; i++) {
|
|
13
|
+
const s = specifiers[i].imported.name;
|
|
14
|
+
if (!hasLegendImport && (s === "Computed" || s === "Memo" || s === "Show")) {
|
|
15
|
+
hasLegendImport = true;
|
|
16
|
+
path.skip();
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
JSXElement: {
|
|
24
|
+
enter(path) {
|
|
25
|
+
if (!hasLegendImport) {
|
|
26
|
+
path.skip();
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const openingElement = path.node.openingElement;
|
|
30
|
+
const name = openingElement.name.name;
|
|
31
|
+
if (name === "Computed" || name === "Memo" || name === "Show") {
|
|
32
|
+
const children = removeEmptyText(path.node.children);
|
|
33
|
+
if (children.length === 0)
|
|
34
|
+
return;
|
|
35
|
+
if (children[0].type === "JSXElement" || children[0].type === "JSXExpressionContainer" && children[0].expression.type !== "ArrowFunctionExpression" && children[0].expression.type !== "FunctionExpression" && children[0].expression.type !== "MemberExpression" && children[0].expression.type !== "Identifier") {
|
|
36
|
+
const attrs = openingElement.attributes;
|
|
37
|
+
path.replaceWith(
|
|
38
|
+
jsxElement(
|
|
39
|
+
jsxOpeningElement(jsxIdentifier(name), attrs),
|
|
40
|
+
jsxClosingElement(jsxIdentifier(name)),
|
|
41
|
+
[jsxExpressionContainer(arrowFunctionExpression([], maybeWrapFragment(children)))]
|
|
42
|
+
)
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function maybeWrapFragment(children) {
|
|
52
|
+
if (children.length === 1 && children[0].type == "JSXElement")
|
|
53
|
+
return children[0];
|
|
54
|
+
if (children.length === 1 && children[0].type == "JSXExpressionContainer")
|
|
55
|
+
return children[0].expression;
|
|
56
|
+
return jsxFragment(jsxOpeningFragment(), jsxClosingFragment(), children);
|
|
57
|
+
}
|
|
58
|
+
function removeEmptyText(nodes) {
|
|
59
|
+
return nodes.filter((node) => !(node.type === "JSXText" && node.value.trim().length === 0));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// babel.ts
|
|
63
|
+
var babel_default2 = babel_default;
|
|
64
|
+
|
|
65
|
+
export { babel_default2 as default };
|
package/config/enable$GetSet.js
CHANGED
|
@@ -2,23 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
var state = require('@legendapp/state');
|
|
4
4
|
|
|
5
|
+
// src/config/enable$GetSet.ts
|
|
5
6
|
function enable$GetSet() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
},
|
|
12
|
-
set(node, value) {
|
|
13
|
-
state.internal.set(node, value);
|
|
14
|
-
},
|
|
15
|
-
},
|
|
7
|
+
state.configureLegendState({
|
|
8
|
+
observableProperties: {
|
|
9
|
+
$: {
|
|
10
|
+
get(node) {
|
|
11
|
+
return state.internal.get(node);
|
|
16
12
|
},
|
|
17
|
-
|
|
13
|
+
set(node, value) {
|
|
14
|
+
state.internal.set(node, value);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
});
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
-
const enableDirectAccess = enable$GetSet;
|
|
20
|
+
var enableDirectAccess = enable$GetSet;
|
|
21
21
|
|
|
22
22
|
exports.enable$GetSet = enable$GetSet;
|
|
23
23
|
exports.enableDirectAccess = enableDirectAccess;
|
|
24
|
-
//# sourceMappingURL=enable$GetSet.js.map
|
package/config/enable$GetSet.mjs
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import { configureLegendState, internal } from '@legendapp/state';
|
|
2
2
|
|
|
3
|
+
// src/config/enable$GetSet.ts
|
|
3
4
|
function enable$GetSet() {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
},
|
|
10
|
-
set(node, value) {
|
|
11
|
-
internal.set(node, value);
|
|
12
|
-
},
|
|
13
|
-
},
|
|
5
|
+
configureLegendState({
|
|
6
|
+
observableProperties: {
|
|
7
|
+
$: {
|
|
8
|
+
get(node) {
|
|
9
|
+
return internal.get(node);
|
|
14
10
|
},
|
|
15
|
-
|
|
11
|
+
set(node, value) {
|
|
12
|
+
internal.set(node, value);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
});
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
-
const enableDirectAccess = enable$GetSet;
|
|
18
|
+
var enableDirectAccess = enable$GetSet;
|
|
19
19
|
|
|
20
20
|
export { enable$GetSet, enableDirectAccess };
|
|
21
|
-
//# sourceMappingURL=enable$GetSet.mjs.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FCReactiveObject } from '@legendapp/state/react';
|
|
2
|
+
|
|
3
|
+
declare function enableReactComponents(): void;
|
|
4
|
+
declare module '@legendapp/state/react' {
|
|
5
|
+
interface IReactive extends FCReactiveObject<JSX.IntrinsicElements> {
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { enableReactComponents };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { FCReactiveObject } from '@legendapp/state/react';
|
|
3
|
-
|
|
2
|
+
|
|
3
|
+
declare function enableReactComponents(): void;
|
|
4
4
|
declare module '@legendapp/state/react' {
|
|
5
5
|
interface IReactive extends FCReactiveObject<JSX.IntrinsicElements> {
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
|
+
|
|
9
|
+
export { enableReactComponents };
|
|
@@ -2,17 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
var react = require('@legendapp/state/react');
|
|
4
4
|
|
|
5
|
+
// src/config/enableReactComponents.ts
|
|
5
6
|
function enableReactComponents() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
const bindInfo = { value: { handler: "onChange", getValue: (e) => e.target.value, defaultValue: "" } };
|
|
8
|
+
const bindInfoInput = Object.assign(
|
|
9
|
+
{ checked: { handler: "onChange", getValue: (e) => e.target.checked } },
|
|
10
|
+
bindInfo
|
|
11
|
+
);
|
|
12
|
+
react.configureReactive({
|
|
13
|
+
binders: {
|
|
14
|
+
input: bindInfoInput,
|
|
15
|
+
textarea: bindInfo,
|
|
16
|
+
select: bindInfo
|
|
17
|
+
}
|
|
18
|
+
});
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
exports.enableReactComponents = enableReactComponents;
|
|
18
|
-
//# sourceMappingURL=enableReactComponents.js.map
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { configureReactive } from '@legendapp/state/react';
|
|
2
2
|
|
|
3
|
+
// src/config/enableReactComponents.ts
|
|
3
4
|
function enableReactComponents() {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
const bindInfo = { value: { handler: "onChange", getValue: (e) => e.target.value, defaultValue: "" } };
|
|
6
|
+
const bindInfoInput = Object.assign(
|
|
7
|
+
{ checked: { handler: "onChange", getValue: (e) => e.target.checked } },
|
|
8
|
+
bindInfo
|
|
9
|
+
);
|
|
10
|
+
configureReactive({
|
|
11
|
+
binders: {
|
|
12
|
+
input: bindInfoInput,
|
|
13
|
+
textarea: bindInfo,
|
|
14
|
+
select: bindInfo
|
|
15
|
+
}
|
|
16
|
+
});
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
export { enableReactComponents };
|
|
16
|
-
//# sourceMappingURL=enableReactComponents.mjs.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { FCReactiveObject, FCReactive } from '@legendapp/state/react';
|
|
2
|
+
import { ActivityIndicator, ActivityIndicatorProps, Button, ButtonProps, FlatList, FlatListProps, Image, ImageProps, Pressable, PressableProps, ScrollView, ScrollViewProps, SectionList, SectionListProps, Switch, SwitchProps, Text, TextProps, TextInput, TextInputProps, TouchableWithoutFeedback, TouchableWithoutFeedbackProps, View, ViewProps } from 'react-native';
|
|
3
|
+
|
|
4
|
+
declare function enableReactNativeComponents(): void;
|
|
5
|
+
declare module '@legendapp/state/react' {
|
|
6
|
+
interface IReactive extends FCReactiveObject<JSX.IntrinsicElements> {
|
|
7
|
+
ActivityIndicator: FCReactive<ActivityIndicator, ActivityIndicatorProps>;
|
|
8
|
+
Button: FCReactive<Button, ButtonProps>;
|
|
9
|
+
FlatList: FCReactive<FlatList, FlatListProps<any>>;
|
|
10
|
+
Image: FCReactive<Image, ImageProps>;
|
|
11
|
+
Pressable: FCReactive<typeof Pressable, PressableProps>;
|
|
12
|
+
ScrollView: FCReactive<ScrollView, ScrollViewProps>;
|
|
13
|
+
SectionList: FCReactive<SectionList, SectionListProps<any>>;
|
|
14
|
+
Switch: FCReactive<Switch, SwitchProps>;
|
|
15
|
+
Text: FCReactive<Text, TextProps>;
|
|
16
|
+
TextInput: FCReactive<TextInput, TextInputProps>;
|
|
17
|
+
TouchableWithoutFeedback: FCReactive<TouchableWithoutFeedback, TouchableWithoutFeedbackProps>;
|
|
18
|
+
View: FCReactive<View, ViewProps>;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { enableReactNativeComponents };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { FCReactiveObject, FCReactive } from '@legendapp/state/react';
|
|
2
|
+
import { ActivityIndicator, ActivityIndicatorProps, Button, ButtonProps, FlatList, FlatListProps, Image, ImageProps, Pressable, PressableProps, ScrollView, ScrollViewProps, SectionList, SectionListProps, Switch, SwitchProps, Text, TextProps, TextInput, TextInputProps, TouchableWithoutFeedback, TouchableWithoutFeedbackProps, View, ViewProps } from 'react-native';
|
|
3
|
+
|
|
4
|
+
declare function enableReactNativeComponents(): void;
|
|
5
5
|
declare module '@legendapp/state/react' {
|
|
6
6
|
interface IReactive extends FCReactiveObject<JSX.IntrinsicElements> {
|
|
7
7
|
ActivityIndicator: FCReactive<ActivityIndicator, ActivityIndicatorProps>;
|
|
@@ -18,3 +18,5 @@ declare module '@legendapp/state/react' {
|
|
|
18
18
|
View: FCReactive<View, ViewProps>;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
+
|
|
22
|
+
export { enableReactNativeComponents };
|
|
@@ -4,54 +4,50 @@ var react$1 = require('react');
|
|
|
4
4
|
var react = require('@legendapp/state/react');
|
|
5
5
|
var reactNative = require('react-native');
|
|
6
6
|
|
|
7
|
+
// src/config/enableReactNativeComponents.ts
|
|
7
8
|
function enableReactNativeComponents() {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
});
|
|
9
|
+
react.configureReactive({
|
|
10
|
+
components: {
|
|
11
|
+
ActivityIndicator: reactNative.ActivityIndicator,
|
|
12
|
+
Button: reactNative.Button,
|
|
13
|
+
FlatList: reactNative.FlatList,
|
|
14
|
+
Image: reactNative.Image,
|
|
15
|
+
Pressable: reactNative.Pressable,
|
|
16
|
+
ScrollView: reactNative.ScrollView,
|
|
17
|
+
SectionList: reactNative.SectionList,
|
|
18
|
+
Switch: reactNative.Switch,
|
|
19
|
+
Text: reactNative.Text,
|
|
20
|
+
TextInput: reactNative.TextInput,
|
|
21
|
+
TouchableWithoutFeedback: reactNative.TouchableWithoutFeedback,
|
|
22
|
+
View: reactNative.View
|
|
23
|
+
},
|
|
24
|
+
binders: {
|
|
25
|
+
TextInput: {
|
|
26
|
+
value: {
|
|
27
|
+
handler: "onChange",
|
|
28
|
+
getValue: (e) => e.nativeEvent.text,
|
|
29
|
+
defaultValue: ""
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
Switch: {
|
|
33
|
+
value: {
|
|
34
|
+
handler: "onValueChange",
|
|
35
|
+
getValue: (e) => e,
|
|
36
|
+
defaultValue: false
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
FlatList: {
|
|
40
|
+
data: {
|
|
41
|
+
selector: (propsOut, p) => {
|
|
42
|
+
const state = react$1.useRef(0);
|
|
43
|
+
const [renderNum, value] = react.useSelector(() => [state.current++, p.get(true)]);
|
|
44
|
+
propsOut.extraData = renderNum;
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
54
51
|
}
|
|
55
52
|
|
|
56
53
|
exports.enableReactNativeComponents = enableReactNativeComponents;
|
|
57
|
-
//# sourceMappingURL=enableReactNativeComponents.js.map
|