@legendapp/state 3.0.0-alpha.36 → 3.0.0-alpha.37
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/configureReactive-BAV1PS2I.d.mts +32 -0
- package/configureReactive-BAV1PS2I.d.ts +32 -0
- package/package.json +26 -1
- 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 +7 -0
- package/react-reactive/enableReactive.d.ts +7 -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 +4 -29
- package/react.d.ts +4 -29
- package/react.js +21 -15
- package/react.mjs +21 -15
- package/sync-plugins/supabase.d.mts +1 -1
- package/sync-plugins/supabase.d.ts +1 -1
- package/sync-plugins/supabase.js +2 -1
- package/sync-plugins/supabase.mjs +2 -1
package/.DS_Store
ADDED
|
Binary file
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ReactNode, FC, LegacyRef, ComponentClass } from 'react';
|
|
2
|
+
import { Selector, Observable } from '@legendapp/state';
|
|
3
|
+
|
|
4
|
+
type ShapeWithNew$<T> = Partial<Omit<T, 'children'>> & {
|
|
5
|
+
[K in keyof T as K extends `$${string & K}` ? K : `$${string & K}`]?: Selector<T[K]>;
|
|
6
|
+
} & {
|
|
7
|
+
children?: Selector<ReactNode>;
|
|
8
|
+
};
|
|
9
|
+
interface BindKey<P> {
|
|
10
|
+
handler?: keyof P;
|
|
11
|
+
getValue?: (e: any) => any;
|
|
12
|
+
defaultValue?: any;
|
|
13
|
+
selector?: (propsOut: Record<string, any>, p: Observable<any>) => any;
|
|
14
|
+
}
|
|
15
|
+
type BindKeys<P = any> = Record<keyof P, BindKey<P>>;
|
|
16
|
+
type FCReactiveObject<T> = {
|
|
17
|
+
[K in keyof T]: FC<ShapeWithNew$<T[K]>>;
|
|
18
|
+
};
|
|
19
|
+
type FCReactive<P, P2> = P & FC<ShapeWithNew$<P2> & {
|
|
20
|
+
ref?: LegacyRef<P> | undefined;
|
|
21
|
+
}>;
|
|
22
|
+
interface UseSelectorOptions {
|
|
23
|
+
suspense?: boolean;
|
|
24
|
+
skipCheck?: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
declare function configureReactive({ components, binders, }: {
|
|
28
|
+
components?: Record<string, FC | ComponentClass<any>>;
|
|
29
|
+
binders?: Record<string, BindKeys>;
|
|
30
|
+
}): void;
|
|
31
|
+
|
|
32
|
+
export { type BindKeys as B, type FCReactiveObject as F, type ShapeWithNew$ as S, type UseSelectorOptions as U, type BindKey as a, type FCReactive as b, configureReactive as c };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ReactNode, FC, LegacyRef, ComponentClass } from 'react';
|
|
2
|
+
import { Selector, Observable } from '@legendapp/state';
|
|
3
|
+
|
|
4
|
+
type ShapeWithNew$<T> = Partial<Omit<T, 'children'>> & {
|
|
5
|
+
[K in keyof T as K extends `$${string & K}` ? K : `$${string & K}`]?: Selector<T[K]>;
|
|
6
|
+
} & {
|
|
7
|
+
children?: Selector<ReactNode>;
|
|
8
|
+
};
|
|
9
|
+
interface BindKey<P> {
|
|
10
|
+
handler?: keyof P;
|
|
11
|
+
getValue?: (e: any) => any;
|
|
12
|
+
defaultValue?: any;
|
|
13
|
+
selector?: (propsOut: Record<string, any>, p: Observable<any>) => any;
|
|
14
|
+
}
|
|
15
|
+
type BindKeys<P = any> = Record<keyof P, BindKey<P>>;
|
|
16
|
+
type FCReactiveObject<T> = {
|
|
17
|
+
[K in keyof T]: FC<ShapeWithNew$<T[K]>>;
|
|
18
|
+
};
|
|
19
|
+
type FCReactive<P, P2> = P & FC<ShapeWithNew$<P2> & {
|
|
20
|
+
ref?: LegacyRef<P> | undefined;
|
|
21
|
+
}>;
|
|
22
|
+
interface UseSelectorOptions {
|
|
23
|
+
suspense?: boolean;
|
|
24
|
+
skipCheck?: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
declare function configureReactive({ components, binders, }: {
|
|
28
|
+
components?: Record<string, FC | ComponentClass<any>>;
|
|
29
|
+
binders?: Record<string, BindKeys>;
|
|
30
|
+
}): void;
|
|
31
|
+
|
|
32
|
+
export { type BindKeys as B, type FCReactiveObject as F, type ShapeWithNew$ as S, type UseSelectorOptions as U, type BindKey as a, type FCReactive as b, configureReactive as c };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legendapp/state",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.37",
|
|
4
4
|
"description": "legend-state",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"private": false,
|
|
@@ -73,6 +73,31 @@
|
|
|
73
73
|
"require": "./trace.js",
|
|
74
74
|
"types": "./trace.d.ts"
|
|
75
75
|
},
|
|
76
|
+
"./react-reactive/enableReactive": {
|
|
77
|
+
"import": "./react-reactive/enableReactive.mjs",
|
|
78
|
+
"require": "./react-reactive/enableReactive.js",
|
|
79
|
+
"types": "./react-reactive/enableReactive.d.ts"
|
|
80
|
+
},
|
|
81
|
+
"./react-reactive/enableReactComponents": {
|
|
82
|
+
"import": "./react-reactive/enableReactComponents.mjs",
|
|
83
|
+
"require": "./react-reactive/enableReactComponents.js",
|
|
84
|
+
"types": "./react-reactive/enableReactComponents.d.ts"
|
|
85
|
+
},
|
|
86
|
+
"./react-reactive/enableReactNativeComponents": {
|
|
87
|
+
"import": "./react-reactive/enableReactNativeComponents.mjs",
|
|
88
|
+
"require": "./react-reactive/enableReactNativeComponents.js",
|
|
89
|
+
"types": "./react-reactive/enableReactNativeComponents.d.ts"
|
|
90
|
+
},
|
|
91
|
+
"./react-reactive/enableReactive.native": {
|
|
92
|
+
"import": "./react-reactive/enableReactive.native.mjs",
|
|
93
|
+
"require": "./react-reactive/enableReactive.native.js",
|
|
94
|
+
"types": "./react-reactive/enableReactive.native.d.ts"
|
|
95
|
+
},
|
|
96
|
+
"./react-reactive/enableReactive.web": {
|
|
97
|
+
"import": "./react-reactive/enableReactive.web.mjs",
|
|
98
|
+
"require": "./react-reactive/enableReactive.web.js",
|
|
99
|
+
"types": "./react-reactive/enableReactive.web.d.ts"
|
|
100
|
+
},
|
|
76
101
|
"./as/stringAsSet": {
|
|
77
102
|
"import": "./as/stringAsSet.mjs",
|
|
78
103
|
"require": "./as/stringAsSet.js",
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FCReactiveObject, configureReactive } from '@legendapp/state/react';
|
|
2
|
+
|
|
3
|
+
declare function enableReactComponents(config: typeof configureReactive): void;
|
|
4
|
+
declare module '@legendapp/state/react' {
|
|
5
|
+
interface IReactive extends FCReactiveObject<JSX.IntrinsicElements> {
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { enableReactComponents };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FCReactiveObject, configureReactive } from '@legendapp/state/react';
|
|
2
|
+
|
|
3
|
+
declare function enableReactComponents(config: typeof configureReactive): void;
|
|
4
|
+
declare module '@legendapp/state/react' {
|
|
5
|
+
interface IReactive extends FCReactiveObject<JSX.IntrinsicElements> {
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { enableReactComponents };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/react-reactive/enableReactComponents.ts
|
|
4
|
+
function enableReactComponents(config) {
|
|
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
|
+
config({
|
|
11
|
+
binders: {
|
|
12
|
+
input: bindInfoInput,
|
|
13
|
+
textarea: bindInfo,
|
|
14
|
+
select: bindInfo
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
exports.enableReactComponents = enableReactComponents;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/react-reactive/enableReactComponents.ts
|
|
2
|
+
function enableReactComponents(config) {
|
|
3
|
+
const bindInfo = { value: { handler: "onChange", getValue: (e) => e.target.value, defaultValue: "" } };
|
|
4
|
+
const bindInfoInput = Object.assign(
|
|
5
|
+
{ checked: { handler: "onChange", getValue: (e) => e.target.checked } },
|
|
6
|
+
bindInfo
|
|
7
|
+
);
|
|
8
|
+
config({
|
|
9
|
+
binders: {
|
|
10
|
+
input: bindInfoInput,
|
|
11
|
+
textarea: bindInfo,
|
|
12
|
+
select: bindInfo
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { enableReactComponents };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { FCReactiveObject, FCReactive, configureReactive } 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(configure: typeof configureReactive): 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 };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { FCReactiveObject, FCReactive, configureReactive } 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(configure: typeof configureReactive): 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 };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
var react$1 = require('@legendapp/state/react');
|
|
5
|
+
var reactNative = require('react-native');
|
|
6
|
+
|
|
7
|
+
// src/react-reactive/enableReactNativeComponents.ts
|
|
8
|
+
function enableReactNativeComponents(configure) {
|
|
9
|
+
configure({
|
|
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.useRef(0);
|
|
43
|
+
const [renderNum, value] = react$1.useSelector(() => [state.current++, p.get(true)]);
|
|
44
|
+
propsOut.extraData = renderNum;
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
exports.enableReactNativeComponents = enableReactNativeComponents;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
import { useSelector } from '@legendapp/state/react';
|
|
3
|
+
import { ActivityIndicator, Button, FlatList, Image, Pressable, ScrollView, SectionList, Switch, Text, TextInput, TouchableWithoutFeedback, View } from 'react-native';
|
|
4
|
+
|
|
5
|
+
// src/react-reactive/enableReactNativeComponents.ts
|
|
6
|
+
function enableReactNativeComponents(configure) {
|
|
7
|
+
configure({
|
|
8
|
+
components: {
|
|
9
|
+
ActivityIndicator,
|
|
10
|
+
Button,
|
|
11
|
+
FlatList,
|
|
12
|
+
Image,
|
|
13
|
+
Pressable,
|
|
14
|
+
ScrollView,
|
|
15
|
+
SectionList,
|
|
16
|
+
Switch,
|
|
17
|
+
Text,
|
|
18
|
+
TextInput,
|
|
19
|
+
TouchableWithoutFeedback,
|
|
20
|
+
View
|
|
21
|
+
},
|
|
22
|
+
binders: {
|
|
23
|
+
TextInput: {
|
|
24
|
+
value: {
|
|
25
|
+
handler: "onChange",
|
|
26
|
+
getValue: (e) => e.nativeEvent.text,
|
|
27
|
+
defaultValue: ""
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
Switch: {
|
|
31
|
+
value: {
|
|
32
|
+
handler: "onValueChange",
|
|
33
|
+
getValue: (e) => e,
|
|
34
|
+
defaultValue: false
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
FlatList: {
|
|
38
|
+
data: {
|
|
39
|
+
selector: (propsOut, p) => {
|
|
40
|
+
const state = useRef(0);
|
|
41
|
+
const [renderNum, value] = useSelector(() => [state.current++, p.get(true)]);
|
|
42
|
+
propsOut.extraData = renderNum;
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { enableReactNativeComponents };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/react-reactive/enableReactComponents.ts
|
|
4
|
+
function enableReactComponents(config) {
|
|
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
|
+
config({
|
|
11
|
+
binders: {
|
|
12
|
+
input: bindInfoInput,
|
|
13
|
+
textarea: bindInfo,
|
|
14
|
+
select: bindInfo
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// src/react-reactive/enableReactive.ts
|
|
20
|
+
function enableReactive(config) {
|
|
21
|
+
enableReactComponents(config);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
exports.enableReactive = enableReactive;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// src/react-reactive/enableReactComponents.ts
|
|
2
|
+
function enableReactComponents(config) {
|
|
3
|
+
const bindInfo = { value: { handler: "onChange", getValue: (e) => e.target.value, defaultValue: "" } };
|
|
4
|
+
const bindInfoInput = Object.assign(
|
|
5
|
+
{ checked: { handler: "onChange", getValue: (e) => e.target.checked } },
|
|
6
|
+
bindInfo
|
|
7
|
+
);
|
|
8
|
+
config({
|
|
9
|
+
binders: {
|
|
10
|
+
input: bindInfoInput,
|
|
11
|
+
textarea: bindInfo,
|
|
12
|
+
select: bindInfo
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// src/react-reactive/enableReactive.ts
|
|
18
|
+
function enableReactive(config) {
|
|
19
|
+
enableReactComponents(config);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { enableReactive };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
var react$1 = require('@legendapp/state/react');
|
|
5
|
+
var reactNative = require('react-native');
|
|
6
|
+
|
|
7
|
+
// src/react-reactive/enableReactNativeComponents.ts
|
|
8
|
+
function enableReactNativeComponents(configure) {
|
|
9
|
+
configure({
|
|
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.useRef(0);
|
|
43
|
+
const [renderNum, value] = react$1.useSelector(() => [state.current++, p.get(true)]);
|
|
44
|
+
propsOut.extraData = renderNum;
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// src/react-reactive/enableReactive.native.ts
|
|
54
|
+
function enableReactive(configure) {
|
|
55
|
+
enableReactNativeComponents(configure);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
exports.enableReactive = enableReactive;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
import { useSelector } from '@legendapp/state/react';
|
|
3
|
+
import { ActivityIndicator, Button, FlatList, Image, Pressable, ScrollView, SectionList, Switch, Text, TextInput, TouchableWithoutFeedback, View } from 'react-native';
|
|
4
|
+
|
|
5
|
+
// src/react-reactive/enableReactNativeComponents.ts
|
|
6
|
+
function enableReactNativeComponents(configure) {
|
|
7
|
+
configure({
|
|
8
|
+
components: {
|
|
9
|
+
ActivityIndicator,
|
|
10
|
+
Button,
|
|
11
|
+
FlatList,
|
|
12
|
+
Image,
|
|
13
|
+
Pressable,
|
|
14
|
+
ScrollView,
|
|
15
|
+
SectionList,
|
|
16
|
+
Switch,
|
|
17
|
+
Text,
|
|
18
|
+
TextInput,
|
|
19
|
+
TouchableWithoutFeedback,
|
|
20
|
+
View
|
|
21
|
+
},
|
|
22
|
+
binders: {
|
|
23
|
+
TextInput: {
|
|
24
|
+
value: {
|
|
25
|
+
handler: "onChange",
|
|
26
|
+
getValue: (e) => e.nativeEvent.text,
|
|
27
|
+
defaultValue: ""
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
Switch: {
|
|
31
|
+
value: {
|
|
32
|
+
handler: "onValueChange",
|
|
33
|
+
getValue: (e) => e,
|
|
34
|
+
defaultValue: false
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
FlatList: {
|
|
38
|
+
data: {
|
|
39
|
+
selector: (propsOut, p) => {
|
|
40
|
+
const state = useRef(0);
|
|
41
|
+
const [renderNum, value] = useSelector(() => [state.current++, p.get(true)]);
|
|
42
|
+
propsOut.extraData = renderNum;
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// src/react-reactive/enableReactive.native.ts
|
|
52
|
+
function enableReactive(configure) {
|
|
53
|
+
enableReactNativeComponents(configure);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { enableReactive };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
var react$1 = require('@legendapp/state/react');
|
|
5
|
+
var reactNative = require('react-native');
|
|
6
|
+
|
|
7
|
+
// src/react-reactive/enableReactNativeComponents.ts
|
|
8
|
+
function enableReactNativeComponents(configure) {
|
|
9
|
+
configure({
|
|
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.useRef(0);
|
|
43
|
+
const [renderNum, value] = react$1.useSelector(() => [state.current++, p.get(true)]);
|
|
44
|
+
propsOut.extraData = renderNum;
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// src/react-reactive/enableReactive.web.ts
|
|
54
|
+
function enableReactive(configure) {
|
|
55
|
+
enableReactNativeComponents(configure);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
exports.enableReactive = enableReactive;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
import { useSelector } from '@legendapp/state/react';
|
|
3
|
+
import { ActivityIndicator, Button, FlatList, Image, Pressable, ScrollView, SectionList, Switch, Text, TextInput, TouchableWithoutFeedback, View } from 'react-native';
|
|
4
|
+
|
|
5
|
+
// src/react-reactive/enableReactNativeComponents.ts
|
|
6
|
+
function enableReactNativeComponents(configure) {
|
|
7
|
+
configure({
|
|
8
|
+
components: {
|
|
9
|
+
ActivityIndicator,
|
|
10
|
+
Button,
|
|
11
|
+
FlatList,
|
|
12
|
+
Image,
|
|
13
|
+
Pressable,
|
|
14
|
+
ScrollView,
|
|
15
|
+
SectionList,
|
|
16
|
+
Switch,
|
|
17
|
+
Text,
|
|
18
|
+
TextInput,
|
|
19
|
+
TouchableWithoutFeedback,
|
|
20
|
+
View
|
|
21
|
+
},
|
|
22
|
+
binders: {
|
|
23
|
+
TextInput: {
|
|
24
|
+
value: {
|
|
25
|
+
handler: "onChange",
|
|
26
|
+
getValue: (e) => e.nativeEvent.text,
|
|
27
|
+
defaultValue: ""
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
Switch: {
|
|
31
|
+
value: {
|
|
32
|
+
handler: "onValueChange",
|
|
33
|
+
getValue: (e) => e,
|
|
34
|
+
defaultValue: false
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
FlatList: {
|
|
38
|
+
data: {
|
|
39
|
+
selector: (propsOut, p) => {
|
|
40
|
+
const state = useRef(0);
|
|
41
|
+
const [renderNum, value] = useSelector(() => [state.current++, p.get(true)]);
|
|
42
|
+
propsOut.extraData = renderNum;
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// src/react-reactive/enableReactive.web.ts
|
|
52
|
+
function enableReactive(configure) {
|
|
53
|
+
enableReactNativeComponents(configure);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { enableReactive };
|
package/react.d.mts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ReactNode, ReactElement, FC,
|
|
2
|
+
import { ReactNode, ReactElement, FC, DependencyList, ReducerWithoutAction, ReducerStateWithoutAction, DispatchWithoutAction, Reducer, ReducerState, Dispatch, ReducerAction } from 'react';
|
|
3
3
|
import { ObservableParam, Observable, ObservableBoolean, Selector, RecursiveValueOrFunction, ObserveOptions, ObserveEvent, ObserveEventCallback } from '@legendapp/state';
|
|
4
|
+
import { B as BindKeys, U as UseSelectorOptions } from './configureReactive-BAV1PS2I.mjs';
|
|
5
|
+
export { a as BindKey, b as FCReactive, F as FCReactiveObject, S as ShapeWithNew$, c as configureReactive } from './configureReactive-BAV1PS2I.mjs';
|
|
4
6
|
|
|
5
7
|
declare function Computed({ children }: {
|
|
6
8
|
children: ObservableParam | (() => ReactNode);
|
|
@@ -28,36 +30,9 @@ declare function usePauseProvider(): {
|
|
|
28
30
|
|
|
29
31
|
declare const Memo: react.MemoExoticComponent<typeof Computed>;
|
|
30
32
|
|
|
31
|
-
type ShapeWithNew$<T> = Partial<Omit<T, 'children'>> & {
|
|
32
|
-
[K in keyof T as K extends `$${string & K}` ? K : `$${string & K}`]?: Selector<T[K]>;
|
|
33
|
-
} & {
|
|
34
|
-
children?: Selector<ReactNode>;
|
|
35
|
-
};
|
|
36
|
-
interface BindKey<P> {
|
|
37
|
-
handler?: keyof P;
|
|
38
|
-
getValue?: (e: any) => any;
|
|
39
|
-
defaultValue?: any;
|
|
40
|
-
selector?: (propsOut: Record<string, any>, p: Observable<any>) => any;
|
|
41
|
-
}
|
|
42
|
-
type BindKeys<P = any> = Record<keyof P, BindKey<P>>;
|
|
43
|
-
type FCReactiveObject<T> = {
|
|
44
|
-
[K in keyof T]: FC<ShapeWithNew$<T[K]>>;
|
|
45
|
-
};
|
|
46
|
-
type FCReactive<P, P2> = P & FC<ShapeWithNew$<P2> & {
|
|
47
|
-
ref?: LegacyRef<P> | undefined;
|
|
48
|
-
}>;
|
|
49
|
-
interface UseSelectorOptions {
|
|
50
|
-
suspense?: boolean;
|
|
51
|
-
skipCheck?: boolean;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
33
|
interface IReactive {
|
|
55
34
|
}
|
|
56
35
|
declare const Reactive: IReactive;
|
|
57
|
-
declare function configureReactive({ components, binders, }: {
|
|
58
|
-
components?: Record<string, FC | ComponentClass<any>>;
|
|
59
|
-
binders?: Record<string, BindKeys>;
|
|
60
|
-
}): void;
|
|
61
36
|
|
|
62
37
|
interface PropsIf<T> {
|
|
63
38
|
if: Selector<T>;
|
|
@@ -158,4 +133,4 @@ declare const useUnmountOnce: typeof useUnmount;
|
|
|
158
133
|
declare function useWhen<T>(predicate: Selector<T>, effect: (value: T) => any | (() => any)): Promise<any>;
|
|
159
134
|
declare function useWhenReady<T>(predicate: Selector<T>, effect: (value: T) => any | (() => any)): Promise<any>;
|
|
160
135
|
|
|
161
|
-
export {
|
|
136
|
+
export { BindKeys, Computed, type ExtractFCPropsType, For, type IReactive, Memo, type ObjectShapeWith$, Reactive, type ShapeWith$, type ShapeWithPick$, Show, Switch, type UseObserveOptions, UseSelectorOptions, hasSymbol, observer, reactive, reactiveComponents, reactiveObserver, useComputed, useEffectOnce, useIsMounted, useMount, useMountOnce, useObservable, useObservableReducer, useObserve, useObserveEffect, usePauseProvider, useSelector, useUnmount, useUnmountOnce, useWhen, useWhenReady };
|
package/react.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ReactNode, ReactElement, FC,
|
|
2
|
+
import { ReactNode, ReactElement, FC, DependencyList, ReducerWithoutAction, ReducerStateWithoutAction, DispatchWithoutAction, Reducer, ReducerState, Dispatch, ReducerAction } from 'react';
|
|
3
3
|
import { ObservableParam, Observable, ObservableBoolean, Selector, RecursiveValueOrFunction, ObserveOptions, ObserveEvent, ObserveEventCallback } from '@legendapp/state';
|
|
4
|
+
import { B as BindKeys, U as UseSelectorOptions } from './configureReactive-BAV1PS2I.js';
|
|
5
|
+
export { a as BindKey, b as FCReactive, F as FCReactiveObject, S as ShapeWithNew$, c as configureReactive } from './configureReactive-BAV1PS2I.js';
|
|
4
6
|
|
|
5
7
|
declare function Computed({ children }: {
|
|
6
8
|
children: ObservableParam | (() => ReactNode);
|
|
@@ -28,36 +30,9 @@ declare function usePauseProvider(): {
|
|
|
28
30
|
|
|
29
31
|
declare const Memo: react.MemoExoticComponent<typeof Computed>;
|
|
30
32
|
|
|
31
|
-
type ShapeWithNew$<T> = Partial<Omit<T, 'children'>> & {
|
|
32
|
-
[K in keyof T as K extends `$${string & K}` ? K : `$${string & K}`]?: Selector<T[K]>;
|
|
33
|
-
} & {
|
|
34
|
-
children?: Selector<ReactNode>;
|
|
35
|
-
};
|
|
36
|
-
interface BindKey<P> {
|
|
37
|
-
handler?: keyof P;
|
|
38
|
-
getValue?: (e: any) => any;
|
|
39
|
-
defaultValue?: any;
|
|
40
|
-
selector?: (propsOut: Record<string, any>, p: Observable<any>) => any;
|
|
41
|
-
}
|
|
42
|
-
type BindKeys<P = any> = Record<keyof P, BindKey<P>>;
|
|
43
|
-
type FCReactiveObject<T> = {
|
|
44
|
-
[K in keyof T]: FC<ShapeWithNew$<T[K]>>;
|
|
45
|
-
};
|
|
46
|
-
type FCReactive<P, P2> = P & FC<ShapeWithNew$<P2> & {
|
|
47
|
-
ref?: LegacyRef<P> | undefined;
|
|
48
|
-
}>;
|
|
49
|
-
interface UseSelectorOptions {
|
|
50
|
-
suspense?: boolean;
|
|
51
|
-
skipCheck?: boolean;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
33
|
interface IReactive {
|
|
55
34
|
}
|
|
56
35
|
declare const Reactive: IReactive;
|
|
57
|
-
declare function configureReactive({ components, binders, }: {
|
|
58
|
-
components?: Record<string, FC | ComponentClass<any>>;
|
|
59
|
-
binders?: Record<string, BindKeys>;
|
|
60
|
-
}): void;
|
|
61
36
|
|
|
62
37
|
interface PropsIf<T> {
|
|
63
38
|
if: Selector<T>;
|
|
@@ -158,4 +133,4 @@ declare const useUnmountOnce: typeof useUnmount;
|
|
|
158
133
|
declare function useWhen<T>(predicate: Selector<T>, effect: (value: T) => any | (() => any)): Promise<any>;
|
|
159
134
|
declare function useWhenReady<T>(predicate: Selector<T>, effect: (value: T) => any | (() => any)): Promise<any>;
|
|
160
135
|
|
|
161
|
-
export {
|
|
136
|
+
export { BindKeys, Computed, type ExtractFCPropsType, For, type IReactive, Memo, type ObjectShapeWith$, Reactive, type ShapeWith$, type ShapeWithPick$, Show, Switch, type UseObserveOptions, UseSelectorOptions, hasSymbol, observer, reactive, reactiveComponents, reactiveObserver, useComputed, useEffectOnce, useIsMounted, useMount, useMountOnce, useObservable, useObservableReducer, useObserve, useObserveEffect, usePauseProvider, useSelector, useUnmount, useUnmountOnce, useWhen, useWhenReady };
|
package/react.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var state = require('@legendapp/state');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var index_js = require('use-sync-external-store/shim/index.js');
|
|
6
|
+
var enableReactive = require('@legendapp/state/react-reactive/enableReactive');
|
|
6
7
|
|
|
7
8
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
9
|
|
|
@@ -336,8 +337,27 @@ function For({
|
|
|
336
337
|
return out;
|
|
337
338
|
}
|
|
338
339
|
var Memo = React.memo(Computed, () => true);
|
|
340
|
+
|
|
341
|
+
// src/react/configureReactive.ts
|
|
339
342
|
var ReactiveFns = /* @__PURE__ */ new Map();
|
|
340
343
|
var ReactiveFnBinders = /* @__PURE__ */ new Map();
|
|
344
|
+
function configureReactive({
|
|
345
|
+
components,
|
|
346
|
+
binders
|
|
347
|
+
}) {
|
|
348
|
+
if (components) {
|
|
349
|
+
for (const key in components) {
|
|
350
|
+
ReactiveFns.set(key, components[key]);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
if (binders) {
|
|
354
|
+
for (const key in binders) {
|
|
355
|
+
ReactiveFnBinders.set(key, binders[key]);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// src/react/Reactive.tsx
|
|
341
361
|
var Reactive = new Proxy(
|
|
342
362
|
{},
|
|
343
363
|
{
|
|
@@ -357,21 +377,7 @@ var Reactive = new Proxy(
|
|
|
357
377
|
}
|
|
358
378
|
}
|
|
359
379
|
);
|
|
360
|
-
|
|
361
|
-
components,
|
|
362
|
-
binders
|
|
363
|
-
}) {
|
|
364
|
-
if (components) {
|
|
365
|
-
for (const key in components) {
|
|
366
|
-
ReactiveFns.set(key, components[key]);
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
if (binders) {
|
|
370
|
-
for (const key in binders) {
|
|
371
|
-
ReactiveFnBinders.set(key, binders[key]);
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
}
|
|
380
|
+
enableReactive.enableReactive(configureReactive);
|
|
375
381
|
function Show({ if: if_, ifReady, else: else_, $value, wrap, children }) {
|
|
376
382
|
const value = useSelector(if_ != null ? if_ : ifReady);
|
|
377
383
|
const show = ifReady !== void 0 ? state.isObservableValueReady(value) : value;
|
package/react.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isFunction, isEmpty, observable, isPromise, isObservable, when, computeSelector, isArray, isMap, isObservableValueReady, linked, observe, whenReady, internal, trackSelector, isPrimitive } from '@legendapp/state';
|
|
2
2
|
import React, { memo, forwardRef, createElement, useState, useContext, useMemo, useRef, useEffect, createContext, useCallback } from 'react';
|
|
3
3
|
import { useSyncExternalStore } from 'use-sync-external-store/shim/index.js';
|
|
4
|
+
import { enableReactive } from '@legendapp/state/react-reactive/enableReactive';
|
|
4
5
|
|
|
5
6
|
// src/react/Computed.tsx
|
|
6
7
|
|
|
@@ -330,8 +331,27 @@ function For({
|
|
|
330
331
|
return out;
|
|
331
332
|
}
|
|
332
333
|
var Memo = memo(Computed, () => true);
|
|
334
|
+
|
|
335
|
+
// src/react/configureReactive.ts
|
|
333
336
|
var ReactiveFns = /* @__PURE__ */ new Map();
|
|
334
337
|
var ReactiveFnBinders = /* @__PURE__ */ new Map();
|
|
338
|
+
function configureReactive({
|
|
339
|
+
components,
|
|
340
|
+
binders
|
|
341
|
+
}) {
|
|
342
|
+
if (components) {
|
|
343
|
+
for (const key in components) {
|
|
344
|
+
ReactiveFns.set(key, components[key]);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
if (binders) {
|
|
348
|
+
for (const key in binders) {
|
|
349
|
+
ReactiveFnBinders.set(key, binders[key]);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// src/react/Reactive.tsx
|
|
335
355
|
var Reactive = new Proxy(
|
|
336
356
|
{},
|
|
337
357
|
{
|
|
@@ -351,21 +371,7 @@ var Reactive = new Proxy(
|
|
|
351
371
|
}
|
|
352
372
|
}
|
|
353
373
|
);
|
|
354
|
-
|
|
355
|
-
components,
|
|
356
|
-
binders
|
|
357
|
-
}) {
|
|
358
|
-
if (components) {
|
|
359
|
-
for (const key in components) {
|
|
360
|
-
ReactiveFns.set(key, components[key]);
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
if (binders) {
|
|
364
|
-
for (const key in binders) {
|
|
365
|
-
ReactiveFnBinders.set(key, binders[key]);
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
}
|
|
374
|
+
enableReactive(configureReactive);
|
|
369
375
|
function Show({ if: if_, ifReady, else: else_, $value, wrap, children }) {
|
|
370
376
|
const value = useSelector(if_ != null ? if_ : ifReady);
|
|
371
377
|
const show = ifReady !== void 0 ? isObservableValueReady(value) : value;
|
|
@@ -26,7 +26,7 @@ interface SyncedSupabaseConfiguration extends Omit<SyncedSupabaseConfig<{
|
|
|
26
26
|
as?: Exclude<CrudAsOption, 'value'>;
|
|
27
27
|
}
|
|
28
28
|
interface SyncedSupabaseProps<Client extends SupabaseClient<any, any>, Collection extends SupabaseCollectionOf<Client, SchemaName>, SchemaName extends SchemaNameOf<Client> = 'public', TOption extends CrudAsOption = 'object', TRemote extends SupabaseRowOf<Client, Collection, SchemaName> = SupabaseRowOf<Client, Collection, SchemaName>, TLocal = TRemote> extends SyncedSupabaseConfig<TRemote, TLocal>, Omit<SyncedCrudPropsMany<TRemote, TRemote, TOption>, 'list'> {
|
|
29
|
-
supabase
|
|
29
|
+
supabase?: Client;
|
|
30
30
|
collection: Collection;
|
|
31
31
|
schema?: SchemaName;
|
|
32
32
|
select?: (query: PostgrestQueryBuilder<SupabaseSchemaOf<Client>, SupabaseTableOf<Client, SchemaName>[Collection], Collection>) => PostgrestFilterBuilder<SupabaseSchemaOf<Client>, TRemote, TRemote[], Collection, []>;
|
|
@@ -26,7 +26,7 @@ interface SyncedSupabaseConfiguration extends Omit<SyncedSupabaseConfig<{
|
|
|
26
26
|
as?: Exclude<CrudAsOption, 'value'>;
|
|
27
27
|
}
|
|
28
28
|
interface SyncedSupabaseProps<Client extends SupabaseClient<any, any>, Collection extends SupabaseCollectionOf<Client, SchemaName>, SchemaName extends SchemaNameOf<Client> = 'public', TOption extends CrudAsOption = 'object', TRemote extends SupabaseRowOf<Client, Collection, SchemaName> = SupabaseRowOf<Client, Collection, SchemaName>, TLocal = TRemote> extends SyncedSupabaseConfig<TRemote, TLocal>, Omit<SyncedCrudPropsMany<TRemote, TRemote, TOption>, 'list'> {
|
|
29
|
-
supabase
|
|
29
|
+
supabase?: Client;
|
|
30
30
|
collection: Collection;
|
|
31
31
|
schema?: SchemaName;
|
|
32
32
|
select?: (query: PostgrestQueryBuilder<SupabaseSchemaOf<Client>, SupabaseTableOf<Client, SchemaName>[Collection], Collection>) => PostgrestFilterBuilder<SupabaseSchemaOf<Client>, TRemote, TRemote[], Collection, []>;
|
package/sync-plugins/supabase.js
CHANGED
|
@@ -30,7 +30,7 @@ function wrapSupabaseFn(fn) {
|
|
|
30
30
|
function syncedSupabase(props) {
|
|
31
31
|
props = { ...supabaseConfig, ...props };
|
|
32
32
|
const {
|
|
33
|
-
supabase
|
|
33
|
+
supabase,
|
|
34
34
|
collection,
|
|
35
35
|
select: selectFn,
|
|
36
36
|
schema,
|
|
@@ -53,6 +53,7 @@ function syncedSupabase(props) {
|
|
|
53
53
|
delete: deleteParam,
|
|
54
54
|
...rest
|
|
55
55
|
} = props;
|
|
56
|
+
const client = supabase;
|
|
56
57
|
const fieldCreatedAt = fieldCreatedAtParam || (changesSince === "last-sync" ? "created_at" : void 0);
|
|
57
58
|
const fieldUpdatedAt = fieldUpdatedAtParam || (changesSince === "last-sync" ? "updated_at" : void 0);
|
|
58
59
|
const fieldDeleted = fieldDeletedParam || (changesSince === "last-sync" ? "deleted" : void 0);
|
|
@@ -28,7 +28,7 @@ function wrapSupabaseFn(fn) {
|
|
|
28
28
|
function syncedSupabase(props) {
|
|
29
29
|
props = { ...supabaseConfig, ...props };
|
|
30
30
|
const {
|
|
31
|
-
supabase
|
|
31
|
+
supabase,
|
|
32
32
|
collection,
|
|
33
33
|
select: selectFn,
|
|
34
34
|
schema,
|
|
@@ -51,6 +51,7 @@ function syncedSupabase(props) {
|
|
|
51
51
|
delete: deleteParam,
|
|
52
52
|
...rest
|
|
53
53
|
} = props;
|
|
54
|
+
const client = supabase;
|
|
54
55
|
const fieldCreatedAt = fieldCreatedAtParam || (changesSince === "last-sync" ? "created_at" : void 0);
|
|
55
56
|
const fieldUpdatedAt = fieldUpdatedAtParam || (changesSince === "last-sync" ? "updated_at" : void 0);
|
|
56
57
|
const fieldDeleted = fieldDeletedParam || (changesSince === "last-sync" ? "deleted" : void 0);
|