@legendapp/state 3.0.0-beta.4 → 3.0.0-beta.40
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/README.md +2 -2
- package/config/enableReactComponents.js +3 -1
- package/config/enableReactComponents.mjs +3 -1
- package/config/enableReactTracking.d.mts +2 -1
- package/config/enableReactTracking.d.ts +2 -1
- package/config/enableReactTracking.js +32 -13
- package/config/enableReactTracking.mjs +32 -13
- package/index.d.mts +46 -8
- package/index.d.ts +46 -8
- package/index.js +267 -75
- package/index.mjs +267 -75
- package/package.json +35 -1
- package/persist-plugins/async-storage.js +17 -9
- package/persist-plugins/async-storage.mjs +17 -9
- package/persist-plugins/expo-sqlite.d.mts +19 -0
- package/persist-plugins/expo-sqlite.d.ts +19 -0
- package/persist-plugins/expo-sqlite.js +72 -0
- package/persist-plugins/expo-sqlite.mjs +69 -0
- package/persist-plugins/indexeddb.js +13 -3
- package/persist-plugins/indexeddb.mjs +13 -3
- package/react-native.d.mts +4 -0
- package/react-native.d.ts +4 -0
- package/react-native.js +53 -0
- package/react-native.mjs +40 -0
- package/react-reactive/Components.d.mts +19 -0
- package/react-reactive/Components.d.ts +19 -0
- package/react-reactive/Components.js +53 -0
- package/react-reactive/Components.mjs +40 -0
- package/react-reactive/enableReactComponents.d.mts +3 -2
- package/react-reactive/enableReactComponents.d.ts +3 -2
- package/react-reactive/enableReactComponents.js +10 -3
- package/react-reactive/enableReactComponents.mjs +10 -3
- package/react-reactive/enableReactNativeComponents.d.mts +3 -20
- package/react-reactive/enableReactNativeComponents.d.ts +3 -20
- package/react-reactive/enableReactNativeComponents.js +8 -3
- package/react-reactive/enableReactNativeComponents.mjs +8 -3
- package/react-reactive/enableReactive.js +10 -3
- package/react-reactive/enableReactive.mjs +10 -3
- package/react-reactive/enableReactive.native.js +8 -3
- package/react-reactive/enableReactive.native.mjs +8 -3
- package/react-reactive/enableReactive.web.js +8 -3
- package/react-reactive/enableReactive.web.mjs +8 -3
- package/react-web.d.mts +7 -0
- package/react-web.d.ts +7 -0
- package/react-web.js +39 -0
- package/react-web.mjs +37 -0
- package/react.d.mts +59 -26
- package/react.d.ts +59 -26
- package/react.js +136 -87
- package/react.mjs +135 -89
- package/sync-plugins/crud.d.mts +24 -9
- package/sync-plugins/crud.d.ts +24 -9
- package/sync-plugins/crud.js +267 -123
- package/sync-plugins/crud.mjs +268 -124
- package/sync-plugins/firebase.d.mts +7 -3
- package/sync-plugins/firebase.d.ts +7 -3
- package/sync-plugins/firebase.js +214 -64
- package/sync-plugins/firebase.mjs +215 -65
- package/sync-plugins/keel.d.mts +12 -13
- package/sync-plugins/keel.d.ts +12 -13
- package/sync-plugins/keel.js +60 -52
- package/sync-plugins/keel.mjs +61 -48
- package/sync-plugins/supabase.d.mts +10 -5
- package/sync-plugins/supabase.d.ts +10 -5
- package/sync-plugins/supabase.js +90 -33
- package/sync-plugins/supabase.mjs +91 -34
- package/sync-plugins/tanstack-query.d.mts +3 -3
- package/sync-plugins/tanstack-query.d.ts +3 -3
- package/sync-plugins/tanstack-query.js +1 -1
- package/sync-plugins/tanstack-query.mjs +1 -1
- package/sync.d.mts +17 -8
- package/sync.d.ts +17 -8
- package/sync.js +448 -307
- package/sync.mjs +446 -307
- package/trace.js +5 -6
- package/trace.mjs +5 -6
- package/types/reactive-native.d.ts +19 -0
- package/types/reactive-web.d.ts +7 -0
|
@@ -21,7 +21,10 @@ var ObservablePersistAsyncStorage = class {
|
|
|
21
21
|
if (preload === true) {
|
|
22
22
|
tables = await AsyncStorage.getAllKeys();
|
|
23
23
|
} else if (state.isArray(preload)) {
|
|
24
|
-
|
|
24
|
+
const metadataTables = preload.map(
|
|
25
|
+
(table) => table.endsWith(MetadataSuffix) ? void 0 : table + MetadataSuffix
|
|
26
|
+
);
|
|
27
|
+
tables = [...preload, ...metadataTables.filter(Boolean)];
|
|
25
28
|
}
|
|
26
29
|
if (tables) {
|
|
27
30
|
const values = await AsyncStorage.multiGet(tables);
|
|
@@ -38,14 +41,19 @@ var ObservablePersistAsyncStorage = class {
|
|
|
38
41
|
}
|
|
39
42
|
loadTable(table) {
|
|
40
43
|
if (this.data[table] === void 0) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
return AsyncStorage.multiGet([table, table + MetadataSuffix]).then((values) => {
|
|
45
|
+
try {
|
|
46
|
+
values.forEach(([table2, value]) => {
|
|
47
|
+
this.data[table2] = value ? safeParse(value) : void 0;
|
|
48
|
+
});
|
|
49
|
+
} catch (err) {
|
|
50
|
+
console.error("[legend-state] ObservablePersistLocalAsyncStorage failed to parse", table, err);
|
|
51
|
+
}
|
|
52
|
+
}).catch((err) => {
|
|
53
|
+
if ((err == null ? void 0 : err.message) !== "window is not defined") {
|
|
54
|
+
console.error("[legend-state] AsyncStorage.multiGet failed", table, err);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
49
57
|
}
|
|
50
58
|
}
|
|
51
59
|
// Gets
|
|
@@ -19,7 +19,10 @@ var ObservablePersistAsyncStorage = class {
|
|
|
19
19
|
if (preload === true) {
|
|
20
20
|
tables = await AsyncStorage.getAllKeys();
|
|
21
21
|
} else if (isArray(preload)) {
|
|
22
|
-
|
|
22
|
+
const metadataTables = preload.map(
|
|
23
|
+
(table) => table.endsWith(MetadataSuffix) ? void 0 : table + MetadataSuffix
|
|
24
|
+
);
|
|
25
|
+
tables = [...preload, ...metadataTables.filter(Boolean)];
|
|
23
26
|
}
|
|
24
27
|
if (tables) {
|
|
25
28
|
const values = await AsyncStorage.multiGet(tables);
|
|
@@ -36,14 +39,19 @@ var ObservablePersistAsyncStorage = class {
|
|
|
36
39
|
}
|
|
37
40
|
loadTable(table) {
|
|
38
41
|
if (this.data[table] === void 0) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
return AsyncStorage.multiGet([table, table + MetadataSuffix]).then((values) => {
|
|
43
|
+
try {
|
|
44
|
+
values.forEach(([table2, value]) => {
|
|
45
|
+
this.data[table2] = value ? safeParse(value) : void 0;
|
|
46
|
+
});
|
|
47
|
+
} catch (err) {
|
|
48
|
+
console.error("[legend-state] ObservablePersistLocalAsyncStorage failed to parse", table, err);
|
|
49
|
+
}
|
|
50
|
+
}).catch((err) => {
|
|
51
|
+
if ((err == null ? void 0 : err.message) !== "window is not defined") {
|
|
52
|
+
console.error("[legend-state] AsyncStorage.multiGet failed", table, err);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
47
55
|
}
|
|
48
56
|
}
|
|
49
57
|
// Gets
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Change } from '@legendapp/state';
|
|
2
|
+
import { ObservablePersistPlugin, PersistMetadata } from '@legendapp/state/sync';
|
|
3
|
+
import { SQLiteStorage } from 'expo-sqlite/kv-store';
|
|
4
|
+
|
|
5
|
+
declare class ObservablePersistSqlite implements ObservablePersistPlugin {
|
|
6
|
+
private data;
|
|
7
|
+
private storage;
|
|
8
|
+
constructor(storage: SQLiteStorage);
|
|
9
|
+
getTable(table: string, init: any): any;
|
|
10
|
+
getMetadata(table: string): PersistMetadata;
|
|
11
|
+
set(table: string, changes: Change[]): void;
|
|
12
|
+
setMetadata(table: string, metadata: PersistMetadata): void;
|
|
13
|
+
deleteTable(table: string): undefined;
|
|
14
|
+
deleteMetadata(table: string): void;
|
|
15
|
+
private save;
|
|
16
|
+
}
|
|
17
|
+
declare function observablePersistSqlite(storage: SQLiteStorage): ObservablePersistSqlite;
|
|
18
|
+
|
|
19
|
+
export { ObservablePersistSqlite, observablePersistSqlite };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Change } from '@legendapp/state';
|
|
2
|
+
import { ObservablePersistPlugin, PersistMetadata } from '@legendapp/state/sync';
|
|
3
|
+
import { SQLiteStorage } from 'expo-sqlite/kv-store';
|
|
4
|
+
|
|
5
|
+
declare class ObservablePersistSqlite implements ObservablePersistPlugin {
|
|
6
|
+
private data;
|
|
7
|
+
private storage;
|
|
8
|
+
constructor(storage: SQLiteStorage);
|
|
9
|
+
getTable(table: string, init: any): any;
|
|
10
|
+
getMetadata(table: string): PersistMetadata;
|
|
11
|
+
set(table: string, changes: Change[]): void;
|
|
12
|
+
setMetadata(table: string, metadata: PersistMetadata): void;
|
|
13
|
+
deleteTable(table: string): undefined;
|
|
14
|
+
deleteMetadata(table: string): void;
|
|
15
|
+
private save;
|
|
16
|
+
}
|
|
17
|
+
declare function observablePersistSqlite(storage: SQLiteStorage): ObservablePersistSqlite;
|
|
18
|
+
|
|
19
|
+
export { ObservablePersistSqlite, observablePersistSqlite };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var state = require('@legendapp/state');
|
|
4
|
+
|
|
5
|
+
// src/persist-plugins/expo-sqlite.ts
|
|
6
|
+
var { safeParse, safeStringify } = state.internal;
|
|
7
|
+
var MetadataSuffix = "__m";
|
|
8
|
+
var ObservablePersistSqlite = class {
|
|
9
|
+
constructor(storage) {
|
|
10
|
+
this.data = {};
|
|
11
|
+
if (!storage) {
|
|
12
|
+
console.error(
|
|
13
|
+
"[legend-state] ObservablePersistSqlite failed to initialize. You need to pass the SQLiteStorage instance."
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
this.storage = storage;
|
|
17
|
+
}
|
|
18
|
+
getTable(table, init) {
|
|
19
|
+
if (!this.storage)
|
|
20
|
+
return void 0;
|
|
21
|
+
if (this.data[table] === void 0) {
|
|
22
|
+
try {
|
|
23
|
+
const value = this.storage.getItemSync(table);
|
|
24
|
+
this.data[table] = value ? safeParse(value) : init;
|
|
25
|
+
} catch (e) {
|
|
26
|
+
console.error("[legend-state] ObservablePersistSqlite failed to parse", table);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return this.data[table];
|
|
30
|
+
}
|
|
31
|
+
getMetadata(table) {
|
|
32
|
+
return this.getTable(table + MetadataSuffix, {});
|
|
33
|
+
}
|
|
34
|
+
set(table, changes) {
|
|
35
|
+
if (!this.data[table]) {
|
|
36
|
+
this.data[table] = {};
|
|
37
|
+
}
|
|
38
|
+
this.data[table] = state.applyChanges(this.data[table], changes);
|
|
39
|
+
this.save(table);
|
|
40
|
+
}
|
|
41
|
+
setMetadata(table, metadata) {
|
|
42
|
+
table = table + MetadataSuffix;
|
|
43
|
+
this.data[table] = metadata;
|
|
44
|
+
this.save(table);
|
|
45
|
+
}
|
|
46
|
+
deleteTable(table) {
|
|
47
|
+
if (!this.storage)
|
|
48
|
+
return void 0;
|
|
49
|
+
delete this.data[table];
|
|
50
|
+
this.storage.removeItemSync(table);
|
|
51
|
+
}
|
|
52
|
+
deleteMetadata(table) {
|
|
53
|
+
this.deleteTable(table + MetadataSuffix);
|
|
54
|
+
}
|
|
55
|
+
// Private
|
|
56
|
+
save(table) {
|
|
57
|
+
if (!this.storage)
|
|
58
|
+
return void 0;
|
|
59
|
+
const v = this.data[table];
|
|
60
|
+
if (v !== void 0 && v !== null) {
|
|
61
|
+
this.storage.setItemSync(table, safeStringify(v));
|
|
62
|
+
} else {
|
|
63
|
+
this.storage.removeItemSync(table);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
function observablePersistSqlite(storage) {
|
|
68
|
+
return new ObservablePersistSqlite(storage);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
exports.ObservablePersistSqlite = ObservablePersistSqlite;
|
|
72
|
+
exports.observablePersistSqlite = observablePersistSqlite;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { applyChanges, internal } from '@legendapp/state';
|
|
2
|
+
|
|
3
|
+
// src/persist-plugins/expo-sqlite.ts
|
|
4
|
+
var { safeParse, safeStringify } = internal;
|
|
5
|
+
var MetadataSuffix = "__m";
|
|
6
|
+
var ObservablePersistSqlite = class {
|
|
7
|
+
constructor(storage) {
|
|
8
|
+
this.data = {};
|
|
9
|
+
if (!storage) {
|
|
10
|
+
console.error(
|
|
11
|
+
"[legend-state] ObservablePersistSqlite failed to initialize. You need to pass the SQLiteStorage instance."
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
this.storage = storage;
|
|
15
|
+
}
|
|
16
|
+
getTable(table, init) {
|
|
17
|
+
if (!this.storage)
|
|
18
|
+
return void 0;
|
|
19
|
+
if (this.data[table] === void 0) {
|
|
20
|
+
try {
|
|
21
|
+
const value = this.storage.getItemSync(table);
|
|
22
|
+
this.data[table] = value ? safeParse(value) : init;
|
|
23
|
+
} catch (e) {
|
|
24
|
+
console.error("[legend-state] ObservablePersistSqlite failed to parse", table);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return this.data[table];
|
|
28
|
+
}
|
|
29
|
+
getMetadata(table) {
|
|
30
|
+
return this.getTable(table + MetadataSuffix, {});
|
|
31
|
+
}
|
|
32
|
+
set(table, changes) {
|
|
33
|
+
if (!this.data[table]) {
|
|
34
|
+
this.data[table] = {};
|
|
35
|
+
}
|
|
36
|
+
this.data[table] = applyChanges(this.data[table], changes);
|
|
37
|
+
this.save(table);
|
|
38
|
+
}
|
|
39
|
+
setMetadata(table, metadata) {
|
|
40
|
+
table = table + MetadataSuffix;
|
|
41
|
+
this.data[table] = metadata;
|
|
42
|
+
this.save(table);
|
|
43
|
+
}
|
|
44
|
+
deleteTable(table) {
|
|
45
|
+
if (!this.storage)
|
|
46
|
+
return void 0;
|
|
47
|
+
delete this.data[table];
|
|
48
|
+
this.storage.removeItemSync(table);
|
|
49
|
+
}
|
|
50
|
+
deleteMetadata(table) {
|
|
51
|
+
this.deleteTable(table + MetadataSuffix);
|
|
52
|
+
}
|
|
53
|
+
// Private
|
|
54
|
+
save(table) {
|
|
55
|
+
if (!this.storage)
|
|
56
|
+
return void 0;
|
|
57
|
+
const v = this.data[table];
|
|
58
|
+
if (v !== void 0 && v !== null) {
|
|
59
|
+
this.storage.setItemSync(table, safeStringify(v));
|
|
60
|
+
} else {
|
|
61
|
+
this.storage.removeItemSync(table);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
function observablePersistSqlite(storage) {
|
|
66
|
+
return new ObservablePersistSqlite(storage);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export { ObservablePersistSqlite, observablePersistSqlite };
|
|
@@ -5,6 +5,12 @@ var state = require('@legendapp/state');
|
|
|
5
5
|
// src/persist-plugins/indexeddb.ts
|
|
6
6
|
var MetadataSuffix = "__legend_metadata";
|
|
7
7
|
var PrimitiveName = "__legend_primitive";
|
|
8
|
+
function getIndexedDB() {
|
|
9
|
+
if (typeof globalThis === "undefined") {
|
|
10
|
+
return void 0;
|
|
11
|
+
}
|
|
12
|
+
return globalThis.indexedDB;
|
|
13
|
+
}
|
|
8
14
|
function requestToPromise(request) {
|
|
9
15
|
return new Promise((resolve) => request.onsuccess = () => resolve());
|
|
10
16
|
}
|
|
@@ -21,8 +27,9 @@ var ObservablePersistIndexedDB = class {
|
|
|
21
27
|
}
|
|
22
28
|
async initialize(configOptions) {
|
|
23
29
|
const config = this.configuration || configOptions.indexedDB;
|
|
24
|
-
if (
|
|
30
|
+
if (!getIndexedDB()) {
|
|
25
31
|
return;
|
|
32
|
+
}
|
|
26
33
|
if (process.env.NODE_ENV === "development" && !config) {
|
|
27
34
|
console.error("[legend-state] Must configure ObservablePersistIndexedDB");
|
|
28
35
|
}
|
|
@@ -69,6 +76,9 @@ var ObservablePersistIndexedDB = class {
|
|
|
69
76
|
loadTable(table, config) {
|
|
70
77
|
var _a;
|
|
71
78
|
if (!this.db) {
|
|
79
|
+
if (!getIndexedDB()) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
72
82
|
throw new Error(
|
|
73
83
|
"[legend-state] ObservablePersistIndexedDB loading without being initialized. This may happen when running outside of a browser."
|
|
74
84
|
);
|
|
@@ -147,7 +157,7 @@ var ObservablePersistIndexedDB = class {
|
|
|
147
157
|
}
|
|
148
158
|
async set(table, changes, config) {
|
|
149
159
|
var _a, _b;
|
|
150
|
-
if (
|
|
160
|
+
if (!getIndexedDB())
|
|
151
161
|
return;
|
|
152
162
|
if (!this.pendingSaves.has(config)) {
|
|
153
163
|
this.pendingSaves.set(config, {});
|
|
@@ -238,7 +248,7 @@ var ObservablePersistIndexedDB = class {
|
|
|
238
248
|
delete this.tableData[tableName];
|
|
239
249
|
delete this.tableData[tableName + "_transformed"];
|
|
240
250
|
}
|
|
241
|
-
if (
|
|
251
|
+
if (!getIndexedDB())
|
|
242
252
|
return;
|
|
243
253
|
this.deleteMetadata(table, config);
|
|
244
254
|
if (data) {
|
|
@@ -3,6 +3,12 @@ import { when, isPromise, observable, setAtPath, isPrimitive } from '@legendapp/
|
|
|
3
3
|
// src/persist-plugins/indexeddb.ts
|
|
4
4
|
var MetadataSuffix = "__legend_metadata";
|
|
5
5
|
var PrimitiveName = "__legend_primitive";
|
|
6
|
+
function getIndexedDB() {
|
|
7
|
+
if (typeof globalThis === "undefined") {
|
|
8
|
+
return void 0;
|
|
9
|
+
}
|
|
10
|
+
return globalThis.indexedDB;
|
|
11
|
+
}
|
|
6
12
|
function requestToPromise(request) {
|
|
7
13
|
return new Promise((resolve) => request.onsuccess = () => resolve());
|
|
8
14
|
}
|
|
@@ -19,8 +25,9 @@ var ObservablePersistIndexedDB = class {
|
|
|
19
25
|
}
|
|
20
26
|
async initialize(configOptions) {
|
|
21
27
|
const config = this.configuration || configOptions.indexedDB;
|
|
22
|
-
if (
|
|
28
|
+
if (!getIndexedDB()) {
|
|
23
29
|
return;
|
|
30
|
+
}
|
|
24
31
|
if (process.env.NODE_ENV === "development" && !config) {
|
|
25
32
|
console.error("[legend-state] Must configure ObservablePersistIndexedDB");
|
|
26
33
|
}
|
|
@@ -67,6 +74,9 @@ var ObservablePersistIndexedDB = class {
|
|
|
67
74
|
loadTable(table, config) {
|
|
68
75
|
var _a;
|
|
69
76
|
if (!this.db) {
|
|
77
|
+
if (!getIndexedDB()) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
70
80
|
throw new Error(
|
|
71
81
|
"[legend-state] ObservablePersistIndexedDB loading without being initialized. This may happen when running outside of a browser."
|
|
72
82
|
);
|
|
@@ -145,7 +155,7 @@ var ObservablePersistIndexedDB = class {
|
|
|
145
155
|
}
|
|
146
156
|
async set(table, changes, config) {
|
|
147
157
|
var _a, _b;
|
|
148
|
-
if (
|
|
158
|
+
if (!getIndexedDB())
|
|
149
159
|
return;
|
|
150
160
|
if (!this.pendingSaves.has(config)) {
|
|
151
161
|
this.pendingSaves.set(config, {});
|
|
@@ -236,7 +246,7 @@ var ObservablePersistIndexedDB = class {
|
|
|
236
246
|
delete this.tableData[tableName];
|
|
237
247
|
delete this.tableData[tableName + "_transformed"];
|
|
238
248
|
}
|
|
239
|
-
if (
|
|
249
|
+
if (!getIndexedDB())
|
|
240
250
|
return;
|
|
241
251
|
this.deleteMetadata(table, config);
|
|
242
252
|
if (data) {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { $ActivityIndicator, $Button, $FlatList, $Image, $Pressable, $ScrollView, $SectionList, $Switch, $Text, $TextInput, $TouchableWithoutFeedback, $View } from './react-reactive/Components.mjs';
|
|
2
|
+
import 'react';
|
|
3
|
+
import '@legendapp/state/react';
|
|
4
|
+
import 'react-native';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { $ActivityIndicator, $Button, $FlatList, $Image, $Pressable, $ScrollView, $SectionList, $Switch, $Text, $TextInput, $TouchableWithoutFeedback, $View } from './react-reactive/Components.js';
|
|
2
|
+
import 'react';
|
|
3
|
+
import '@legendapp/state/react';
|
|
4
|
+
import 'react-native';
|
package/react-native.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('@legendapp/state/react');
|
|
4
|
+
var react$1 = require('react');
|
|
5
|
+
var reactNative = require('react-native');
|
|
6
|
+
|
|
7
|
+
// src/react-reactive/Components.ts
|
|
8
|
+
var $ActivityIndicator = react.reactive(reactNative.ActivityIndicator);
|
|
9
|
+
var $Button = react.reactive(reactNative.Button);
|
|
10
|
+
var $FlatList = react.reactive(reactNative.FlatList, void 0, {
|
|
11
|
+
data: {
|
|
12
|
+
selector: (propsOut, p) => {
|
|
13
|
+
const state = react$1.useRef(0);
|
|
14
|
+
const [renderNum, value] = react.use$(() => [state.current++, p.get(true)]);
|
|
15
|
+
propsOut.extraData = renderNum;
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
var $Image = react.reactive(reactNative.Image);
|
|
21
|
+
var $Pressable = react.reactive(reactNative.Pressable);
|
|
22
|
+
var $ScrollView = react.reactive(reactNative.ScrollView);
|
|
23
|
+
var $SectionList = react.reactive(reactNative.SectionList);
|
|
24
|
+
var $Switch = react.reactive(reactNative.Switch, void 0, {
|
|
25
|
+
value: {
|
|
26
|
+
handler: "onValueChange",
|
|
27
|
+
getValue: (e) => e,
|
|
28
|
+
defaultValue: false
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
var $Text = react.reactive(reactNative.Text);
|
|
32
|
+
var $TextInput = react.reactive(reactNative.TextInput, void 0, {
|
|
33
|
+
value: {
|
|
34
|
+
handler: "onChange",
|
|
35
|
+
getValue: (e) => e.nativeEvent.text,
|
|
36
|
+
defaultValue: ""
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
var $TouchableWithoutFeedback = react.reactive(reactNative.TouchableWithoutFeedback);
|
|
40
|
+
var $View = react.reactive(reactNative.View);
|
|
41
|
+
|
|
42
|
+
exports.$ActivityIndicator = $ActivityIndicator;
|
|
43
|
+
exports.$Button = $Button;
|
|
44
|
+
exports.$FlatList = $FlatList;
|
|
45
|
+
exports.$Image = $Image;
|
|
46
|
+
exports.$Pressable = $Pressable;
|
|
47
|
+
exports.$ScrollView = $ScrollView;
|
|
48
|
+
exports.$SectionList = $SectionList;
|
|
49
|
+
exports.$Switch = $Switch;
|
|
50
|
+
exports.$Text = $Text;
|
|
51
|
+
exports.$TextInput = $TextInput;
|
|
52
|
+
exports.$TouchableWithoutFeedback = $TouchableWithoutFeedback;
|
|
53
|
+
exports.$View = $View;
|
package/react-native.mjs
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { reactive, use$ } from '@legendapp/state/react';
|
|
2
|
+
import { useRef } from 'react';
|
|
3
|
+
import { ActivityIndicator, Button, FlatList, Image, Pressable, ScrollView, SectionList, Switch, Text, TextInput, TouchableWithoutFeedback, View } from 'react-native';
|
|
4
|
+
|
|
5
|
+
// src/react-reactive/Components.ts
|
|
6
|
+
var $ActivityIndicator = reactive(ActivityIndicator);
|
|
7
|
+
var $Button = reactive(Button);
|
|
8
|
+
var $FlatList = reactive(FlatList, void 0, {
|
|
9
|
+
data: {
|
|
10
|
+
selector: (propsOut, p) => {
|
|
11
|
+
const state = useRef(0);
|
|
12
|
+
const [renderNum, value] = use$(() => [state.current++, p.get(true)]);
|
|
13
|
+
propsOut.extraData = renderNum;
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var $Image = reactive(Image);
|
|
19
|
+
var $Pressable = reactive(Pressable);
|
|
20
|
+
var $ScrollView = reactive(ScrollView);
|
|
21
|
+
var $SectionList = reactive(SectionList);
|
|
22
|
+
var $Switch = reactive(Switch, void 0, {
|
|
23
|
+
value: {
|
|
24
|
+
handler: "onValueChange",
|
|
25
|
+
getValue: (e) => e,
|
|
26
|
+
defaultValue: false
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
var $Text = reactive(Text);
|
|
30
|
+
var $TextInput = reactive(TextInput, void 0, {
|
|
31
|
+
value: {
|
|
32
|
+
handler: "onChange",
|
|
33
|
+
getValue: (e) => e.nativeEvent.text,
|
|
34
|
+
defaultValue: ""
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
var $TouchableWithoutFeedback = reactive(TouchableWithoutFeedback);
|
|
38
|
+
var $View = reactive(View);
|
|
39
|
+
|
|
40
|
+
export { $ActivityIndicator, $Button, $FlatList, $Image, $Pressable, $ScrollView, $SectionList, $Switch, $Text, $TextInput, $TouchableWithoutFeedback, $View };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as _legendapp_state_react from '@legendapp/state/react';
|
|
3
|
+
import * as react_native from 'react-native';
|
|
4
|
+
import { View } from 'react-native';
|
|
5
|
+
|
|
6
|
+
declare const $ActivityIndicator: React.ComponentClass<_legendapp_state_react.ShapeWith$<react_native.ActivityIndicatorProps>, any>;
|
|
7
|
+
declare const $Button: React.ComponentClass<_legendapp_state_react.ShapeWith$<react_native.ButtonProps>, any>;
|
|
8
|
+
declare const $FlatList: React.FC<_legendapp_state_react.ShapeWith$<react_native.FlatListProps<unknown>>>;
|
|
9
|
+
declare const $Image: React.ComponentClass<_legendapp_state_react.ShapeWith$<react_native.ImageProps>, any>;
|
|
10
|
+
declare const $Pressable: React.ForwardRefExoticComponent<_legendapp_state_react.ShapeWith$<react_native.PressableProps & React.RefAttributes<View>>>;
|
|
11
|
+
declare const $ScrollView: React.ComponentClass<_legendapp_state_react.ShapeWith$<react_native.ScrollViewProps>, any>;
|
|
12
|
+
declare const $SectionList: React.ComponentClass<_legendapp_state_react.ShapeWith$<react_native.SectionListProps<unknown, unknown>>, any>;
|
|
13
|
+
declare const $Switch: React.FC<_legendapp_state_react.ShapeWith$<react_native.SwitchProps>>;
|
|
14
|
+
declare const $Text: React.ComponentClass<_legendapp_state_react.ShapeWith$<react_native.TextProps>, any>;
|
|
15
|
+
declare const $TextInput: React.FC<_legendapp_state_react.ShapeWith$<react_native.TextInputProps>>;
|
|
16
|
+
declare const $TouchableWithoutFeedback: React.ComponentClass<_legendapp_state_react.ShapeWith$<react_native.TouchableWithoutFeedbackProps>, any>;
|
|
17
|
+
declare const $View: React.ComponentClass<_legendapp_state_react.ShapeWith$<react_native.ViewProps>, any>;
|
|
18
|
+
|
|
19
|
+
export { $ActivityIndicator, $Button, $FlatList, $Image, $Pressable, $ScrollView, $SectionList, $Switch, $Text, $TextInput, $TouchableWithoutFeedback, $View };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as _legendapp_state_react from '@legendapp/state/react';
|
|
3
|
+
import * as react_native from 'react-native';
|
|
4
|
+
import { View } from 'react-native';
|
|
5
|
+
|
|
6
|
+
declare const $ActivityIndicator: React.ComponentClass<_legendapp_state_react.ShapeWith$<react_native.ActivityIndicatorProps>, any>;
|
|
7
|
+
declare const $Button: React.ComponentClass<_legendapp_state_react.ShapeWith$<react_native.ButtonProps>, any>;
|
|
8
|
+
declare const $FlatList: React.FC<_legendapp_state_react.ShapeWith$<react_native.FlatListProps<unknown>>>;
|
|
9
|
+
declare const $Image: React.ComponentClass<_legendapp_state_react.ShapeWith$<react_native.ImageProps>, any>;
|
|
10
|
+
declare const $Pressable: React.ForwardRefExoticComponent<_legendapp_state_react.ShapeWith$<react_native.PressableProps & React.RefAttributes<View>>>;
|
|
11
|
+
declare const $ScrollView: React.ComponentClass<_legendapp_state_react.ShapeWith$<react_native.ScrollViewProps>, any>;
|
|
12
|
+
declare const $SectionList: React.ComponentClass<_legendapp_state_react.ShapeWith$<react_native.SectionListProps<unknown, unknown>>, any>;
|
|
13
|
+
declare const $Switch: React.FC<_legendapp_state_react.ShapeWith$<react_native.SwitchProps>>;
|
|
14
|
+
declare const $Text: React.ComponentClass<_legendapp_state_react.ShapeWith$<react_native.TextProps>, any>;
|
|
15
|
+
declare const $TextInput: React.FC<_legendapp_state_react.ShapeWith$<react_native.TextInputProps>>;
|
|
16
|
+
declare const $TouchableWithoutFeedback: React.ComponentClass<_legendapp_state_react.ShapeWith$<react_native.TouchableWithoutFeedbackProps>, any>;
|
|
17
|
+
declare const $View: React.ComponentClass<_legendapp_state_react.ShapeWith$<react_native.ViewProps>, any>;
|
|
18
|
+
|
|
19
|
+
export { $ActivityIndicator, $Button, $FlatList, $Image, $Pressable, $ScrollView, $SectionList, $Switch, $Text, $TextInput, $TouchableWithoutFeedback, $View };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('@legendapp/state/react');
|
|
4
|
+
var react$1 = require('react');
|
|
5
|
+
var reactNative = require('react-native');
|
|
6
|
+
|
|
7
|
+
// src/react-reactive/Components.ts
|
|
8
|
+
var $ActivityIndicator = react.reactive(reactNative.ActivityIndicator);
|
|
9
|
+
var $Button = react.reactive(reactNative.Button);
|
|
10
|
+
var $FlatList = react.reactive(reactNative.FlatList, void 0, {
|
|
11
|
+
data: {
|
|
12
|
+
selector: (propsOut, p) => {
|
|
13
|
+
const state = react$1.useRef(0);
|
|
14
|
+
const [renderNum, value] = react.use$(() => [state.current++, p.get(true)]);
|
|
15
|
+
propsOut.extraData = renderNum;
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
var $Image = react.reactive(reactNative.Image);
|
|
21
|
+
var $Pressable = react.reactive(reactNative.Pressable);
|
|
22
|
+
var $ScrollView = react.reactive(reactNative.ScrollView);
|
|
23
|
+
var $SectionList = react.reactive(reactNative.SectionList);
|
|
24
|
+
var $Switch = react.reactive(reactNative.Switch, void 0, {
|
|
25
|
+
value: {
|
|
26
|
+
handler: "onValueChange",
|
|
27
|
+
getValue: (e) => e,
|
|
28
|
+
defaultValue: false
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
var $Text = react.reactive(reactNative.Text);
|
|
32
|
+
var $TextInput = react.reactive(reactNative.TextInput, void 0, {
|
|
33
|
+
value: {
|
|
34
|
+
handler: "onChange",
|
|
35
|
+
getValue: (e) => e.nativeEvent.text,
|
|
36
|
+
defaultValue: ""
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
var $TouchableWithoutFeedback = react.reactive(reactNative.TouchableWithoutFeedback);
|
|
40
|
+
var $View = react.reactive(reactNative.View);
|
|
41
|
+
|
|
42
|
+
exports.$ActivityIndicator = $ActivityIndicator;
|
|
43
|
+
exports.$Button = $Button;
|
|
44
|
+
exports.$FlatList = $FlatList;
|
|
45
|
+
exports.$Image = $Image;
|
|
46
|
+
exports.$Pressable = $Pressable;
|
|
47
|
+
exports.$ScrollView = $ScrollView;
|
|
48
|
+
exports.$SectionList = $SectionList;
|
|
49
|
+
exports.$Switch = $Switch;
|
|
50
|
+
exports.$Text = $Text;
|
|
51
|
+
exports.$TextInput = $TextInput;
|
|
52
|
+
exports.$TouchableWithoutFeedback = $TouchableWithoutFeedback;
|
|
53
|
+
exports.$View = $View;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { reactive, use$ } from '@legendapp/state/react';
|
|
2
|
+
import { useRef } from 'react';
|
|
3
|
+
import { ActivityIndicator, Button, FlatList, Image, Pressable, ScrollView, SectionList, Switch, Text, TextInput, TouchableWithoutFeedback, View } from 'react-native';
|
|
4
|
+
|
|
5
|
+
// src/react-reactive/Components.ts
|
|
6
|
+
var $ActivityIndicator = reactive(ActivityIndicator);
|
|
7
|
+
var $Button = reactive(Button);
|
|
8
|
+
var $FlatList = reactive(FlatList, void 0, {
|
|
9
|
+
data: {
|
|
10
|
+
selector: (propsOut, p) => {
|
|
11
|
+
const state = useRef(0);
|
|
12
|
+
const [renderNum, value] = use$(() => [state.current++, p.get(true)]);
|
|
13
|
+
propsOut.extraData = renderNum;
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var $Image = reactive(Image);
|
|
19
|
+
var $Pressable = reactive(Pressable);
|
|
20
|
+
var $ScrollView = reactive(ScrollView);
|
|
21
|
+
var $SectionList = reactive(SectionList);
|
|
22
|
+
var $Switch = reactive(Switch, void 0, {
|
|
23
|
+
value: {
|
|
24
|
+
handler: "onValueChange",
|
|
25
|
+
getValue: (e) => e,
|
|
26
|
+
defaultValue: false
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
var $Text = reactive(Text);
|
|
30
|
+
var $TextInput = reactive(TextInput, void 0, {
|
|
31
|
+
value: {
|
|
32
|
+
handler: "onChange",
|
|
33
|
+
getValue: (e) => e.nativeEvent.text,
|
|
34
|
+
defaultValue: ""
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
var $TouchableWithoutFeedback = reactive(TouchableWithoutFeedback);
|
|
38
|
+
var $View = reactive(View);
|
|
39
|
+
|
|
40
|
+
export { $ActivityIndicator, $Button, $FlatList, $Image, $Pressable, $ScrollView, $SectionList, $Switch, $Text, $TextInput, $TouchableWithoutFeedback, $View };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { FCReactiveObject, configureReactive } from '@legendapp/state/react';
|
|
2
2
|
|
|
3
|
-
declare function
|
|
3
|
+
declare function enableReactComponents_(config: typeof configureReactive): void;
|
|
4
|
+
|
|
4
5
|
declare module '@legendapp/state/react' {
|
|
5
6
|
interface IReactive extends FCReactiveObject<JSX.IntrinsicElements> {
|
|
6
7
|
}
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
export {
|
|
10
|
+
export { enableReactComponents_ };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { FCReactiveObject, configureReactive } from '@legendapp/state/react';
|
|
2
2
|
|
|
3
|
-
declare function
|
|
3
|
+
declare function enableReactComponents_(config: typeof configureReactive): void;
|
|
4
|
+
|
|
4
5
|
declare module '@legendapp/state/react' {
|
|
5
6
|
interface IReactive extends FCReactiveObject<JSX.IntrinsicElements> {
|
|
6
7
|
}
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
export {
|
|
10
|
+
export { enableReactComponents_ };
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
// src/react-reactive/enableReactComponents.ts
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
var isEnabled = false;
|
|
5
|
+
function enableReactComponents_(config) {
|
|
6
|
+
if (isEnabled) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
isEnabled = true;
|
|
10
|
+
const bindInfo = {
|
|
11
|
+
value: { handler: "onChange", getValue: (e) => e.target.value, defaultValue: "" }
|
|
12
|
+
};
|
|
6
13
|
const bindInfoInput = Object.assign(
|
|
7
14
|
{ checked: { handler: "onChange", getValue: (e) => e.target.checked } },
|
|
8
15
|
bindInfo
|
|
@@ -16,4 +23,4 @@ function enableReactComponents(config) {
|
|
|
16
23
|
});
|
|
17
24
|
}
|
|
18
25
|
|
|
19
|
-
exports.
|
|
26
|
+
exports.enableReactComponents_ = enableReactComponents_;
|