@fidscript/instant-react-native 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +31 -0
- package/dist/EventSourceShim.d.ts.map +1 -0
- package/dist/EventSourceShim.js +228 -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 +31 -0
- package/dist/module/EventSourceShim.d.ts.map +1 -0
- package/dist/module/EventSourceShim.js +226 -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 +49 -0
- package/src/EventSourceImpl.ts +6 -0
- package/src/EventSourceShim.ts +285 -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 +2 -0
- package/tsconfig.json +16 -0
- package/tsconfig.module.json +13 -0
- package/tsconfig.test.json +5 -0
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 '@fidscript/instant-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 '@fidscript/instant-sdk';
|
|
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
|
+
'@fidscript/react-native': 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
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
3
|
+
"include": ["src"],
|
|
4
|
+
"exclude": ["node_modules", "dist", "src/__types__"],
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"outDir": "dist",
|
|
7
|
+
"rootDir": "src",
|
|
8
|
+
"strictNullChecks": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"baseUrl": ".",
|
|
11
|
+
"paths": {
|
|
12
|
+
"@fidscript/instant-sdk": ["../../fidscript-instant-sdk/dist/commonjs"],
|
|
13
|
+
"@fidscript/instant-react-common": ["../../fidscript-instant-react-common/dist/commonjs"]
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"module": "es2015",
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
"outDir": "dist/module",
|
|
7
|
+
"baseUrl": ".",
|
|
8
|
+
"paths": {
|
|
9
|
+
"@fidscript/instant-sdk": ["../../fidscript-instant-sdk/dist/esm"],
|
|
10
|
+
"@fidscript/instant-react-common": ["../../fidscript-instant-react-common/dist/esm"]
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|