@roko-app/instant-react-native 0.0.0-stage → 1.0.67-roko.2
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/LICENSE +202 -0
- package/README.md +59 -2
- package/__tests__/EventSourceShim.test.ts +104 -0
- package/dist/EventSourceImpl.d.ts +10 -0
- package/dist/EventSourceImpl.d.ts.map +1 -0
- package/dist/EventSourceImpl.js +9 -0
- package/dist/EventSourceImpl.js.map +1 -0
- package/dist/EventSourceShim.d.ts +32 -0
- package/dist/EventSourceShim.d.ts.map +1 -0
- package/dist/EventSourceShim.js +249 -0
- package/dist/EventSourceShim.js.map +1 -0
- package/dist/NetworkListener.d.ts +5 -0
- package/dist/NetworkListener.d.ts.map +1 -0
- package/dist/NetworkListener.js +19 -0
- package/dist/NetworkListener.js.map +1 -0
- package/dist/Storage.d.ts +3 -0
- package/dist/Storage.d.ts.map +1 -0
- package/dist/Storage.js +5 -0
- package/dist/Storage.js.map +1 -0
- package/dist/Storage.native.d.ts +22 -0
- package/dist/Storage.native.d.ts.map +1 -0
- package/dist/Storage.native.js +79 -0
- package/dist/Storage.native.js.map +1 -0
- package/dist/Streams.d.ts +15 -0
- package/dist/Streams.d.ts.map +1 -0
- package/dist/Streams.js +9 -0
- package/dist/Streams.js.map +1 -0
- package/dist/Streams.native.d.ts +6 -0
- package/dist/Streams.native.d.ts.map +1 -0
- package/dist/Streams.native.js +9 -0
- package/dist/Streams.native.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +18 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +87 -0
- package/dist/index.js.map +1 -0
- package/dist/module/EventSourceImpl.d.ts +10 -0
- package/dist/module/EventSourceImpl.d.ts.map +1 -0
- package/dist/module/EventSourceImpl.js +4 -0
- package/dist/module/EventSourceImpl.js.map +1 -0
- package/dist/module/EventSourceShim.d.ts +32 -0
- package/dist/module/EventSourceShim.d.ts.map +1 -0
- package/dist/module/EventSourceShim.js +247 -0
- package/dist/module/EventSourceShim.js.map +1 -0
- package/dist/module/NetworkListener.d.ts +5 -0
- package/dist/module/NetworkListener.d.ts.map +1 -0
- package/dist/module/NetworkListener.js +13 -0
- package/dist/module/NetworkListener.js.map +1 -0
- package/dist/module/Storage.d.ts +3 -0
- package/dist/module/Storage.d.ts.map +1 -0
- package/dist/module/Storage.js +3 -0
- package/dist/module/Storage.js.map +1 -0
- package/dist/module/Storage.native.d.ts +22 -0
- package/dist/module/Storage.native.d.ts.map +1 -0
- package/dist/module/Storage.native.js +75 -0
- package/dist/module/Storage.native.js.map +1 -0
- package/dist/module/Streams.d.ts +15 -0
- package/dist/module/Streams.d.ts.map +1 -0
- package/dist/module/Streams.js +6 -0
- package/dist/module/Streams.js.map +1 -0
- package/dist/module/Streams.native.d.ts +6 -0
- package/dist/module/Streams.native.d.ts.map +1 -0
- package/dist/module/Streams.native.js +6 -0
- package/dist/module/Streams.native.js.map +1 -0
- package/dist/module/cli.d.ts +2 -0
- package/dist/module/cli.d.ts.map +1 -0
- package/dist/module/cli.js +2 -0
- package/dist/module/cli.js.map +1 -0
- package/dist/module/index.d.ts +56 -0
- package/dist/module/index.d.ts.map +1 -0
- package/dist/module/index.js +76 -0
- package/dist/module/index.js.map +1 -0
- package/dist/module/version.d.ts +3 -0
- package/dist/module/version.d.ts.map +1 -0
- package/dist/module/version.js +3 -0
- package/dist/module/version.js.map +1 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +5 -0
- package/dist/version.js.map +1 -0
- package/package.json +30 -3
- package/src/EventSourceImpl.ts +6 -0
- package/src/EventSourceShim.ts +312 -0
- package/src/NetworkListener.js +13 -0
- package/src/Storage.js +3 -0
- package/src/Storage.native.ts +91 -0
- package/src/Streams.native.ts +6 -0
- package/src/Streams.ts +5 -0
- package/src/__types__/typeUtils.ts +39 -0
- package/src/__types__/typesTests.ts +86 -0
- package/src/cli.ts +1 -0
- package/src/index.ts +290 -0
- package/src/version.ts +3 -0
- package/tsconfig.json +10 -0
- package/tsconfig.module.json +8 -0
- package/tsconfig.test.json +5 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { StoreInterface, StoreInterfaceStoreName } from '@instantdb/core';
|
|
2
|
+
|
|
3
|
+
const version = 5;
|
|
4
|
+
|
|
5
|
+
// AsyncStorage is an optional peer dependency. The `require` must sit
|
|
6
|
+
// directly inside a `try` block: that's what makes Metro treat it as an
|
|
7
|
+
// optional dependency (`transformer.allowOptionalDependencies`, enabled by
|
|
8
|
+
// default in the Expo and React Native metro configs), so bundling doesn't
|
|
9
|
+
// fail when it isn't installed. When it can't be loaded, `init` surfaces a
|
|
10
|
+
// helpful error unless a custom `Store` is passed.
|
|
11
|
+
let AsyncStorage: any = null;
|
|
12
|
+
let asyncStorageLoadError: unknown = null;
|
|
13
|
+
try {
|
|
14
|
+
AsyncStorage = require('@react-native-async-storage/async-storage').default;
|
|
15
|
+
} catch (e) {
|
|
16
|
+
asyncStorageLoadError = e;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export class AsyncStorageStore extends StoreInterface {
|
|
20
|
+
private appId: string;
|
|
21
|
+
private dbName: StoreInterfaceStoreName;
|
|
22
|
+
constructor(appId: string, dbName: StoreInterfaceStoreName) {
|
|
23
|
+
super(appId, dbName);
|
|
24
|
+
this.appId = appId;
|
|
25
|
+
this.dbName = dbName;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
private makeKey(k: string): string {
|
|
29
|
+
return `instant_${this.appId}_${version}_${this.dbName}_${k}`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async getItem(k) {
|
|
33
|
+
const res = await AsyncStorage.getItem(this.makeKey(k));
|
|
34
|
+
if (res === null) return res;
|
|
35
|
+
return JSON.parse(res);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async setItem(k, v) {
|
|
39
|
+
await AsyncStorage.setItem(this.makeKey(k), JSON.stringify(v));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async removeItem(k: string): Promise<void> {
|
|
43
|
+
await AsyncStorage.removeItem(this.makeKey(k));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async getAllKeys(): Promise<string[]> {
|
|
47
|
+
const allKeys = await AsyncStorage.getAllKeys();
|
|
48
|
+
const keys: string[] = [];
|
|
49
|
+
const keyPrefix = this.makeKey('');
|
|
50
|
+
for (const key of allKeys) {
|
|
51
|
+
if (key.startsWith(keyPrefix)) {
|
|
52
|
+
keys.push(key.substring(keyPrefix.length));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return keys;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async multiSet(keyValuePairs: Array<[string, any]>): Promise<void> {
|
|
59
|
+
await AsyncStorage.multiSet(
|
|
60
|
+
keyValuePairs.map(([k, v]) => [this.makeKey(k), JSON.stringify(v)]),
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
class MissingStore extends StoreInterface {
|
|
66
|
+
constructor(appId: string, dbName: StoreInterfaceStoreName) {
|
|
67
|
+
super(appId, dbName);
|
|
68
|
+
throw new Error(
|
|
69
|
+
'Instant needs a store to persist data on device. ' +
|
|
70
|
+
'Install `@react-native-async-storage/async-storage`, ' +
|
|
71
|
+
'or pass a `Store` to `init` (e.g. from `@instantdb/react-native-mmkv` or `@instantdb/expo-sqlite`).' +
|
|
72
|
+
(asyncStorageLoadError
|
|
73
|
+
? `\n\nLoading async-storage failed with: ${asyncStorageLoadError}`
|
|
74
|
+
: ''),
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async getItem(_k: string): Promise<any> {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async removeItem(_k: string): Promise<void> {}
|
|
83
|
+
|
|
84
|
+
async multiSet(_keyValuePairs: Array<[string, any]>): Promise<void> {}
|
|
85
|
+
|
|
86
|
+
async getAllKeys(): Promise<string[]> {
|
|
87
|
+
return [];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export default AsyncStorage ? AsyncStorageStore : MissingStore;
|
package/src/Streams.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Type testing utils from
|
|
2
|
+
// https://github.com/type-challenges/type-challenges/blob/main/utils/index.d.ts
|
|
3
|
+
|
|
4
|
+
export type Expect<T extends true> = T;
|
|
5
|
+
export type ExpectTrue<T extends true> = T;
|
|
6
|
+
export type ExpectFalse<T extends false> = T;
|
|
7
|
+
export type IsTrue<T extends true> = T;
|
|
8
|
+
export type IsFalse<T extends false> = T;
|
|
9
|
+
|
|
10
|
+
export type Equal<X, Y> =
|
|
11
|
+
(<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2
|
|
12
|
+
? true
|
|
13
|
+
: false;
|
|
14
|
+
export type NotEqual<X, Y> = true extends Equal<X, Y> ? false : true;
|
|
15
|
+
|
|
16
|
+
// https://stackoverflow.com/questions/49927523/disallow-call-with-any/49928360#49928360
|
|
17
|
+
export type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
18
|
+
export type NotAny<T> = true extends IsAny<T> ? false : true;
|
|
19
|
+
|
|
20
|
+
export type Debug<T> = { [K in keyof T]: T[K] };
|
|
21
|
+
export type MergeInsertions<T> = T extends object
|
|
22
|
+
? { [K in keyof T]: MergeInsertions<T[K]> }
|
|
23
|
+
: T;
|
|
24
|
+
|
|
25
|
+
export type Alike<X, Y> = Equal<MergeInsertions<X>, MergeInsertions<Y>>;
|
|
26
|
+
|
|
27
|
+
export type ExpectExtends<VALUE, EXPECTED> = EXPECTED extends VALUE
|
|
28
|
+
? true
|
|
29
|
+
: false;
|
|
30
|
+
export type ExpectValidArgs<
|
|
31
|
+
FUNC extends (...args: any[]) => any,
|
|
32
|
+
ARGS extends any[],
|
|
33
|
+
> = ARGS extends Parameters<FUNC> ? true : false;
|
|
34
|
+
|
|
35
|
+
export type UnionToIntersection<U> = (
|
|
36
|
+
U extends any ? (k: U) => void : never
|
|
37
|
+
) extends (k: infer I) => void
|
|
38
|
+
? I
|
|
39
|
+
: never;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { Equal, Expect, IsAny, NotAny } from './typeUtils';
|
|
2
|
+
import { i, init } from '../index';
|
|
3
|
+
|
|
4
|
+
const schema = i.schema({
|
|
5
|
+
entities: {
|
|
6
|
+
tbl: i.entity({
|
|
7
|
+
d: i.date().indexed(),
|
|
8
|
+
dOptional: i.date().optional(),
|
|
9
|
+
}),
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
function _testUseDatesTest() {
|
|
14
|
+
const db = init({
|
|
15
|
+
schema,
|
|
16
|
+
appId: '123',
|
|
17
|
+
useDateObjects: true,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const { data } = db.useQuery({ tbl: {} });
|
|
21
|
+
const item = data?.tbl[0];
|
|
22
|
+
if (item) {
|
|
23
|
+
type t = typeof item.d;
|
|
24
|
+
type _cases = [Expect<NotAny<t>>, Expect<Equal<t, Date>>];
|
|
25
|
+
|
|
26
|
+
type tOpt = typeof item.dOptional;
|
|
27
|
+
type _cases_2 = [
|
|
28
|
+
Expect<NotAny<tOpt>>,
|
|
29
|
+
Expect<Equal<tOpt, Date | undefined>>,
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function _testUseDatesFalseTest() {
|
|
35
|
+
const db = init({
|
|
36
|
+
schema,
|
|
37
|
+
appId: '123',
|
|
38
|
+
useDateObjects: false,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const { data } = db.useQuery({ tbl: {} });
|
|
42
|
+
const item = data?.tbl[0];
|
|
43
|
+
if (item) {
|
|
44
|
+
type t = typeof item.d;
|
|
45
|
+
type _cases = [Expect<NotAny<t>>, Expect<Equal<t, string | number>>];
|
|
46
|
+
|
|
47
|
+
type tOpt = typeof item.dOptional;
|
|
48
|
+
type _cases_2 = [
|
|
49
|
+
Expect<NotAny<tOpt>>,
|
|
50
|
+
Expect<Equal<tOpt, string | number | undefined>>,
|
|
51
|
+
];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function _testUseDatesUndefinedTest() {
|
|
56
|
+
const db = init({
|
|
57
|
+
schema,
|
|
58
|
+
appId: '123',
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const { data } = db.useQuery({ tbl: {} });
|
|
62
|
+
const item = data?.tbl[0];
|
|
63
|
+
if (item) {
|
|
64
|
+
type t = typeof item.d;
|
|
65
|
+
type _cases = [Expect<NotAny<t>>, Expect<Equal<t, string | number>>];
|
|
66
|
+
|
|
67
|
+
type tOpt = typeof item.dOptional;
|
|
68
|
+
type _cases_2 = [
|
|
69
|
+
Expect<NotAny<tOpt>>,
|
|
70
|
+
Expect<Equal<tOpt, string | number | undefined>>,
|
|
71
|
+
];
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function _testDataNoSchema() {
|
|
76
|
+
const db = init({
|
|
77
|
+
appId: '123',
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const { data } = db.useQuery({ tbl: {} });
|
|
81
|
+
const item = data?.tbl[0];
|
|
82
|
+
if (item) {
|
|
83
|
+
type t = typeof item.d;
|
|
84
|
+
type _cases = [Expect<IsAny<t>>, Expect<Equal<typeof item.id, string>>];
|
|
85
|
+
}
|
|
86
|
+
}
|
package/src/cli.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@instantdb/core';
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import 'react-native-get-random-values';
|
|
2
|
+
|
|
3
|
+
import Store from './Storage';
|
|
4
|
+
import EventSourceImpl from './EventSourceImpl';
|
|
5
|
+
import NetworkListener from './NetworkListener';
|
|
6
|
+
import version from './version';
|
|
7
|
+
import { streamConstructors } from './Streams';
|
|
8
|
+
|
|
9
|
+
import { InstantReactAbstractDatabase } from '@instantdb/react-common';
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
i,
|
|
13
|
+
id,
|
|
14
|
+
tx,
|
|
15
|
+
lookup,
|
|
16
|
+
// error
|
|
17
|
+
InstantAPIError,
|
|
18
|
+
setInstantWarningsEnabled,
|
|
19
|
+
|
|
20
|
+
// sync table enums
|
|
21
|
+
SyncTableCallbackEventType,
|
|
22
|
+
|
|
23
|
+
// types
|
|
24
|
+
createInstantRouteHandler,
|
|
25
|
+
type RoomSchemaShape,
|
|
26
|
+
type InstantQuery,
|
|
27
|
+
type InstantQueryResult,
|
|
28
|
+
type InstantSchema,
|
|
29
|
+
type InstantSchemaDatabase,
|
|
30
|
+
type ConnectionStatus,
|
|
31
|
+
type BackwardsCompatibleSchema,
|
|
32
|
+
type IInstantDatabase,
|
|
33
|
+
type Config,
|
|
34
|
+
type Query,
|
|
35
|
+
type QueryResponse,
|
|
36
|
+
type InstantObject,
|
|
37
|
+
type AuthState,
|
|
38
|
+
type User,
|
|
39
|
+
|
|
40
|
+
// presence types
|
|
41
|
+
type PresencePeer,
|
|
42
|
+
|
|
43
|
+
// schema types
|
|
44
|
+
type AttrsDefs,
|
|
45
|
+
type CardinalityKind,
|
|
46
|
+
type DataAttrDef,
|
|
47
|
+
type EntitiesDef,
|
|
48
|
+
type EntitiesWithLinks,
|
|
49
|
+
type EntityDef,
|
|
50
|
+
type InstantGraph,
|
|
51
|
+
type InstantUnknownSchemaDef,
|
|
52
|
+
type LinkAttrDef,
|
|
53
|
+
type LinkDef,
|
|
54
|
+
type LinksDef,
|
|
55
|
+
type ResolveAttrs,
|
|
56
|
+
type ValueTypes,
|
|
57
|
+
type InstantEntity,
|
|
58
|
+
type ConfigWithSchema,
|
|
59
|
+
type InstaQLEntity,
|
|
60
|
+
type InstaQLResult,
|
|
61
|
+
type InstaQLEntitySubquery,
|
|
62
|
+
type RoomsOf,
|
|
63
|
+
type RoomsDef,
|
|
64
|
+
type PresenceOf,
|
|
65
|
+
type TopicsOf,
|
|
66
|
+
type TopicOf,
|
|
67
|
+
type RoomHandle,
|
|
68
|
+
type CreateParams,
|
|
69
|
+
type InstantConfig,
|
|
70
|
+
type InstantSchemaDef,
|
|
71
|
+
type InstantUnknownSchema,
|
|
72
|
+
type TransactionChunk,
|
|
73
|
+
type InstantRules,
|
|
74
|
+
type UpdateParams,
|
|
75
|
+
type LinkParams,
|
|
76
|
+
type ValidQuery,
|
|
77
|
+
type CheckMagicCodeParams,
|
|
78
|
+
type CheckMagicCodeResponse,
|
|
79
|
+
type ExchangeCodeForTokenParams,
|
|
80
|
+
type SendMagicCodeParams,
|
|
81
|
+
type SendMagicCodeResponse,
|
|
82
|
+
type SignInWithIdTokenParams,
|
|
83
|
+
type VerifyMagicCodeParams,
|
|
84
|
+
type VerifyResponse,
|
|
85
|
+
|
|
86
|
+
// storage types
|
|
87
|
+
type FileOpts,
|
|
88
|
+
type UploadFileResponse,
|
|
89
|
+
type DeleteFileResponse,
|
|
90
|
+
|
|
91
|
+
// sync table types
|
|
92
|
+
type SyncTableCallback,
|
|
93
|
+
type SyncTableCallbackEvent,
|
|
94
|
+
type SyncTableInitialSyncBatch,
|
|
95
|
+
type SyncTableInitialSyncComplete,
|
|
96
|
+
type SyncTableSyncTransaction,
|
|
97
|
+
type SyncTableLoadFromStorage,
|
|
98
|
+
type SyncTableSetupError,
|
|
99
|
+
StoreInterface,
|
|
100
|
+
type StoreInterfaceStoreName,
|
|
101
|
+
CreateReadStreamOpts,
|
|
102
|
+
CreateWriteStreamOpts,
|
|
103
|
+
InstantWritableStream,
|
|
104
|
+
InstantReadableStream,
|
|
105
|
+
type Logger,
|
|
106
|
+
} from '@instantdb/core';
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
*
|
|
110
|
+
* The first step: init your application!
|
|
111
|
+
*
|
|
112
|
+
* Visit https://instantdb.com/dash to get your `appId` :)
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* import { init } from "@instantdb/react-native"
|
|
116
|
+
*
|
|
117
|
+
* const db = init({ appId: "my-app-id" })
|
|
118
|
+
*
|
|
119
|
+
* // You can also provide a schema for type safety and editor autocomplete!
|
|
120
|
+
*
|
|
121
|
+
* import { init } from "@instantdb/react-native"
|
|
122
|
+
* import schema from ""../instant.schema.ts";
|
|
123
|
+
*
|
|
124
|
+
* const db = init({ appId: "my-app-id", schema })
|
|
125
|
+
*
|
|
126
|
+
* // To learn more: https://instantdb.com/docs/modeling-data
|
|
127
|
+
*/
|
|
128
|
+
function init<
|
|
129
|
+
Schema extends InstantSchemaDef<any, any, any> = InstantUnknownSchema,
|
|
130
|
+
UseDates extends boolean = false,
|
|
131
|
+
>(
|
|
132
|
+
// Allows config with missing `useDateObjects`, but keeps `UseDates`
|
|
133
|
+
// as a non-nullable in the InstantConfig type.
|
|
134
|
+
config: Omit<InstantConfig<Schema, UseDates>, 'useDateObjects'> & {
|
|
135
|
+
useDateObjects?: UseDates;
|
|
136
|
+
},
|
|
137
|
+
): InstantReactNativeDatabase<
|
|
138
|
+
Schema,
|
|
139
|
+
UseDates,
|
|
140
|
+
InstantConfig<Schema, UseDates>
|
|
141
|
+
> {
|
|
142
|
+
const configStrict = {
|
|
143
|
+
ReadableStream: streamConstructors.ReadableStream,
|
|
144
|
+
WritableStream: streamConstructors.WritableStream,
|
|
145
|
+
...config,
|
|
146
|
+
useDateObjects: (config.useDateObjects ?? false) as UseDates,
|
|
147
|
+
};
|
|
148
|
+
return new InstantReactNativeDatabase<
|
|
149
|
+
Schema,
|
|
150
|
+
UseDates,
|
|
151
|
+
InstantConfig<Schema, UseDates>
|
|
152
|
+
>(configStrict, {
|
|
153
|
+
'@instantdb/react': version,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* @deprecated
|
|
159
|
+
* `init_experimental` is deprecated. You can replace it with `init`.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
*
|
|
163
|
+
* // Before
|
|
164
|
+
* import { init_experimental } from "@instantdb/react-native"
|
|
165
|
+
* const db = init_experimental({ ... });
|
|
166
|
+
*
|
|
167
|
+
* // After
|
|
168
|
+
* import { init } from "@instantdb/react-native"
|
|
169
|
+
* const db = init({ ... });
|
|
170
|
+
*/
|
|
171
|
+
const init_experimental = init;
|
|
172
|
+
|
|
173
|
+
class InstantReactNativeDatabase<
|
|
174
|
+
Schema extends InstantSchemaDef<any, any, any>,
|
|
175
|
+
UseDates extends boolean,
|
|
176
|
+
Config extends InstantConfig<Schema, UseDates> = InstantConfig<
|
|
177
|
+
Schema,
|
|
178
|
+
UseDates
|
|
179
|
+
>,
|
|
180
|
+
> extends InstantReactAbstractDatabase<Schema, UseDates, Config> {
|
|
181
|
+
static Store = Store;
|
|
182
|
+
static NetworkListener = NetworkListener;
|
|
183
|
+
static EventSourceImpl = EventSourceImpl;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export {
|
|
187
|
+
init,
|
|
188
|
+
init_experimental,
|
|
189
|
+
id,
|
|
190
|
+
tx,
|
|
191
|
+
lookup,
|
|
192
|
+
i,
|
|
193
|
+
createInstantRouteHandler,
|
|
194
|
+
InstantReactNativeDatabase,
|
|
195
|
+
|
|
196
|
+
// error
|
|
197
|
+
InstantAPIError,
|
|
198
|
+
setInstantWarningsEnabled,
|
|
199
|
+
|
|
200
|
+
// sync table enums
|
|
201
|
+
SyncTableCallbackEventType,
|
|
202
|
+
|
|
203
|
+
// types
|
|
204
|
+
type Config,
|
|
205
|
+
type Query,
|
|
206
|
+
type QueryResponse,
|
|
207
|
+
type InstantObject,
|
|
208
|
+
type User,
|
|
209
|
+
type AuthState,
|
|
210
|
+
type ConnectionStatus,
|
|
211
|
+
type InstantQuery,
|
|
212
|
+
type InstantQueryResult,
|
|
213
|
+
type InstantSchema,
|
|
214
|
+
type InstantSchemaDatabase,
|
|
215
|
+
type IInstantDatabase,
|
|
216
|
+
type InstantEntity,
|
|
217
|
+
type RoomSchemaShape,
|
|
218
|
+
|
|
219
|
+
// presence types
|
|
220
|
+
type PresencePeer,
|
|
221
|
+
|
|
222
|
+
// schema types
|
|
223
|
+
type AttrsDefs,
|
|
224
|
+
type CardinalityKind,
|
|
225
|
+
type DataAttrDef,
|
|
226
|
+
type EntitiesDef,
|
|
227
|
+
type EntitiesWithLinks,
|
|
228
|
+
type EntityDef,
|
|
229
|
+
type InstantGraph,
|
|
230
|
+
type CreateParams,
|
|
231
|
+
type LinkAttrDef,
|
|
232
|
+
type InstantConfig,
|
|
233
|
+
type LinkDef,
|
|
234
|
+
type InstantUnknownSchemaDef,
|
|
235
|
+
type LinksDef,
|
|
236
|
+
type RoomsOf,
|
|
237
|
+
type RoomsDef,
|
|
238
|
+
type RoomHandle,
|
|
239
|
+
type PresenceOf,
|
|
240
|
+
type TopicsOf,
|
|
241
|
+
type TopicOf,
|
|
242
|
+
type ResolveAttrs,
|
|
243
|
+
type ValueTypes,
|
|
244
|
+
type InstaQLEntity,
|
|
245
|
+
type InstaQLResult,
|
|
246
|
+
type InstaQLEntitySubquery,
|
|
247
|
+
type InstantSchemaDef,
|
|
248
|
+
type InstantUnknownSchema,
|
|
249
|
+
type BackwardsCompatibleSchema,
|
|
250
|
+
type InstantRules,
|
|
251
|
+
type UpdateParams,
|
|
252
|
+
type LinkParams,
|
|
253
|
+
type ValidQuery,
|
|
254
|
+
type CheckMagicCodeParams,
|
|
255
|
+
type CheckMagicCodeResponse,
|
|
256
|
+
type ExchangeCodeForTokenParams,
|
|
257
|
+
type SendMagicCodeParams,
|
|
258
|
+
type TransactionChunk,
|
|
259
|
+
type SendMagicCodeResponse,
|
|
260
|
+
type SignInWithIdTokenParams,
|
|
261
|
+
type VerifyMagicCodeParams,
|
|
262
|
+
type VerifyResponse,
|
|
263
|
+
|
|
264
|
+
// storage types
|
|
265
|
+
type FileOpts,
|
|
266
|
+
type UploadFileResponse,
|
|
267
|
+
type DeleteFileResponse,
|
|
268
|
+
|
|
269
|
+
// stream types
|
|
270
|
+
type CreateReadStreamOpts,
|
|
271
|
+
type CreateWriteStreamOpts,
|
|
272
|
+
type InstantWritableStream,
|
|
273
|
+
type InstantReadableStream,
|
|
274
|
+
|
|
275
|
+
// custom store
|
|
276
|
+
StoreInterface,
|
|
277
|
+
type StoreInterfaceStoreName,
|
|
278
|
+
|
|
279
|
+
// sync table types
|
|
280
|
+
type SyncTableCallback,
|
|
281
|
+
type SyncTableCallbackEvent,
|
|
282
|
+
type SyncTableInitialSyncBatch,
|
|
283
|
+
type SyncTableInitialSyncComplete,
|
|
284
|
+
type SyncTableSyncTransaction,
|
|
285
|
+
type SyncTableLoadFromStorage,
|
|
286
|
+
type SyncTableSetupError,
|
|
287
|
+
|
|
288
|
+
// logger
|
|
289
|
+
type Logger,
|
|
290
|
+
};
|
package/src/version.ts
ADDED
package/tsconfig.json
ADDED