@roko-app/instant-react-native 0.0.0-stage → 1.0.67-roko.1
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,249 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// Modified version of https://github.com/binaryminds/react-native-sse/blob/master/src/EventSource.js
|
|
4
|
+
// that conforms to our `EventSourceType` subset of the browser-native `EventSource`.
|
|
5
|
+
const XMLReadyStateMap = [
|
|
6
|
+
'UNSENT',
|
|
7
|
+
'OPENED',
|
|
8
|
+
'HEADERS_RECEIVED',
|
|
9
|
+
'LOADING',
|
|
10
|
+
'DONE',
|
|
11
|
+
];
|
|
12
|
+
class EventSource {
|
|
13
|
+
ERROR = -1;
|
|
14
|
+
static CONNECTING = 0;
|
|
15
|
+
static OPEN = 1;
|
|
16
|
+
static CLOSED = 2;
|
|
17
|
+
// [roko-db] RN's XHR accumulates the whole streamed body in one string and
|
|
18
|
+
// this shim never recycled the connection, so a long-lived SSE session (e.g.
|
|
19
|
+
// Mac Catalyst, where the WebSocket fallback pins Instant to SSE) grew it
|
|
20
|
+
// until Hermes threw a fatal "RangeError: String length exceeds limit".
|
|
21
|
+
// Past this many processed characters we abort and surface an SSE error;
|
|
22
|
+
// the consumer reconnects with a fresh instance (same path as a normal
|
|
23
|
+
// DONE), which resets the accumulator.
|
|
24
|
+
static MAX_ACCUMULATED_LENGTH = 8 * 1024 * 1024;
|
|
25
|
+
CRLF = '\r\n';
|
|
26
|
+
LF = '\n';
|
|
27
|
+
CR = '\r';
|
|
28
|
+
url;
|
|
29
|
+
onopen;
|
|
30
|
+
onerror;
|
|
31
|
+
onmessage;
|
|
32
|
+
debug;
|
|
33
|
+
status;
|
|
34
|
+
headers = {
|
|
35
|
+
Accept: 'text/event-stream',
|
|
36
|
+
'Cache-Control': 'no-cache',
|
|
37
|
+
'X-Requested-With': 'XMLHttpRequest',
|
|
38
|
+
};
|
|
39
|
+
_xhr;
|
|
40
|
+
lineEndingCharacter;
|
|
41
|
+
_lastIndexProcessed;
|
|
42
|
+
constructor(url) {
|
|
43
|
+
this.status = EventSource.CONNECTING;
|
|
44
|
+
this.lineEndingCharacter = null;
|
|
45
|
+
this._xhr = null;
|
|
46
|
+
this._lastIndexProcessed = 0;
|
|
47
|
+
this.debug = false;
|
|
48
|
+
if (!url || typeof url !== 'string') {
|
|
49
|
+
throw new SyntaxError('[EventSource] Invalid URL argument.');
|
|
50
|
+
}
|
|
51
|
+
this.url = url;
|
|
52
|
+
this.open();
|
|
53
|
+
}
|
|
54
|
+
get readyState() {
|
|
55
|
+
if (this.status === this.ERROR) {
|
|
56
|
+
return EventSource.CLOSED;
|
|
57
|
+
}
|
|
58
|
+
return this.status;
|
|
59
|
+
}
|
|
60
|
+
open() {
|
|
61
|
+
try {
|
|
62
|
+
this.status = EventSource.CONNECTING;
|
|
63
|
+
this._lastIndexProcessed = 0;
|
|
64
|
+
this._xhr = new XMLHttpRequest();
|
|
65
|
+
this._xhr.open('GET', this.url, true);
|
|
66
|
+
for (const [key, value] of Object.entries(this.headers)) {
|
|
67
|
+
if (value !== undefined && value !== null) {
|
|
68
|
+
this._xhr.setRequestHeader(key, value);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
this._xhr.onreadystatechange = () => {
|
|
72
|
+
if (this.status === EventSource.CLOSED) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const xhr = this._xhr;
|
|
76
|
+
this._logDebug(`[EventSource][onreadystatechange] ReadyState: ${XMLReadyStateMap[xhr.readyState] || 'Unknown'}(${xhr.readyState}), status: ${xhr.status}`);
|
|
77
|
+
if (xhr.readyState !== XMLHttpRequest.DONE &&
|
|
78
|
+
xhr.readyState !== XMLHttpRequest.LOADING) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (xhr.status >= 200 && xhr.status < 400) {
|
|
82
|
+
if (this.status === EventSource.CONNECTING) {
|
|
83
|
+
this.status = EventSource.OPEN;
|
|
84
|
+
this.dispatch('open', { type: 'open' });
|
|
85
|
+
this._logDebug('[EventSource][onreadystatechange][OPEN] Connection opened.');
|
|
86
|
+
}
|
|
87
|
+
this._handleEvent(xhr.responseText || '');
|
|
88
|
+
// [roko-db] Recycle before the accumulated responseText can exceed
|
|
89
|
+
// Hermes' string cap (see MAX_ACCUMULATED_LENGTH).
|
|
90
|
+
if (xhr.readyState === XMLHttpRequest.LOADING &&
|
|
91
|
+
this._lastIndexProcessed > EventSource.MAX_ACCUMULATED_LENGTH) {
|
|
92
|
+
this._logDebug('[EventSource][onreadystatechange] Accumulated response cap reached — recycling connection.');
|
|
93
|
+
this.status = this.ERROR;
|
|
94
|
+
this.dispatch('error', {
|
|
95
|
+
type: 'error',
|
|
96
|
+
message: 'recycled: accumulated response cap reached',
|
|
97
|
+
});
|
|
98
|
+
xhr.abort();
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (xhr.readyState === XMLHttpRequest.DONE) {
|
|
102
|
+
this._logDebug('[EventSource][onreadystatechange][DONE] Operation done.');
|
|
103
|
+
this.dispatch('error', { type: 'error' });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else if (xhr.status !== 0) {
|
|
107
|
+
this.status = this.ERROR;
|
|
108
|
+
this.dispatch('error', {
|
|
109
|
+
type: 'error',
|
|
110
|
+
message: xhr.responseText,
|
|
111
|
+
xhrStatus: xhr.status,
|
|
112
|
+
xhrState: xhr.readyState,
|
|
113
|
+
});
|
|
114
|
+
if (xhr.readyState === XMLHttpRequest.DONE) {
|
|
115
|
+
this._logDebug('[EventSource][onreadystatechange][ERROR] Response status error.');
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
this._xhr.onerror = () => {
|
|
120
|
+
if (this.status === EventSource.CLOSED) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
this.status = this.ERROR;
|
|
124
|
+
this.dispatch('error', {
|
|
125
|
+
type: 'error',
|
|
126
|
+
message: this._xhr.responseText,
|
|
127
|
+
xhrStatus: this._xhr.status,
|
|
128
|
+
xhrState: this._xhr.readyState,
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
this._xhr.send();
|
|
132
|
+
}
|
|
133
|
+
catch (e) {
|
|
134
|
+
this.status = this.ERROR;
|
|
135
|
+
this.dispatch('error', {
|
|
136
|
+
type: 'exception',
|
|
137
|
+
message: e.message,
|
|
138
|
+
error: e,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
_logDebug(...msg) {
|
|
143
|
+
if (this.debug) {
|
|
144
|
+
console.debug(...msg);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
_handleEvent(response) {
|
|
148
|
+
if (this.lineEndingCharacter === null) {
|
|
149
|
+
const detectedNewlineChar = this._detectNewlineChar(response);
|
|
150
|
+
if (detectedNewlineChar !== null) {
|
|
151
|
+
this._logDebug(`[EventSource] Automatically detected lineEndingCharacter: ${JSON.stringify(detectedNewlineChar).slice(1, -1)}`);
|
|
152
|
+
this.lineEndingCharacter = detectedNewlineChar;
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
console.warn("[EventSource] Unable to identify the line ending character. Ensure your server delivers a standard line ending character: \\r\\n, \\n, \\r, or specify your custom character using the 'lineEndingCharacter' option.");
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
const indexOfDoubleNewline = this._getLastDoubleNewlineIndex(response);
|
|
160
|
+
if (indexOfDoubleNewline <= this._lastIndexProcessed) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const parts = response
|
|
164
|
+
.substring(this._lastIndexProcessed, indexOfDoubleNewline)
|
|
165
|
+
.split(this.lineEndingCharacter);
|
|
166
|
+
this._lastIndexProcessed = indexOfDoubleNewline;
|
|
167
|
+
let type = undefined;
|
|
168
|
+
let data = [];
|
|
169
|
+
let line = '';
|
|
170
|
+
for (let i = 0; i < parts.length; i++) {
|
|
171
|
+
line = parts[i].trim();
|
|
172
|
+
if (line.startsWith('event')) {
|
|
173
|
+
type = line.replace(/event:?\s*/, '');
|
|
174
|
+
}
|
|
175
|
+
else if (line.startsWith('retry')) {
|
|
176
|
+
// Ignore for our use case, we'll reconnect with a new
|
|
177
|
+
// instance on error
|
|
178
|
+
}
|
|
179
|
+
else if (line.startsWith('data')) {
|
|
180
|
+
data.push(line.replace(/data:?\s*/, ''));
|
|
181
|
+
}
|
|
182
|
+
else if (line.startsWith('id')) {
|
|
183
|
+
// Ignore this, not used for our use case
|
|
184
|
+
}
|
|
185
|
+
else if (line === '') {
|
|
186
|
+
if (data.length > 0) {
|
|
187
|
+
const eventType = type || 'message';
|
|
188
|
+
const event = {
|
|
189
|
+
type: eventType,
|
|
190
|
+
data: data.join('\n'),
|
|
191
|
+
url: this.url,
|
|
192
|
+
};
|
|
193
|
+
this.dispatch(eventType, event);
|
|
194
|
+
data = [];
|
|
195
|
+
type = undefined;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
_detectNewlineChar(response) {
|
|
201
|
+
const supportedLineEndings = [this.CRLF, this.LF, this.CR];
|
|
202
|
+
for (const char of supportedLineEndings) {
|
|
203
|
+
if (response.includes(char)) {
|
|
204
|
+
return char;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
_getLastDoubleNewlineIndex(response) {
|
|
210
|
+
const doubleLineEndingCharacter = this.lineEndingCharacter + this.lineEndingCharacter;
|
|
211
|
+
const lastIndex = response.lastIndexOf(doubleLineEndingCharacter);
|
|
212
|
+
if (lastIndex === -1) {
|
|
213
|
+
return -1;
|
|
214
|
+
}
|
|
215
|
+
return lastIndex + doubleLineEndingCharacter.length;
|
|
216
|
+
}
|
|
217
|
+
dispatch(type, data) {
|
|
218
|
+
switch (type) {
|
|
219
|
+
case 'open': {
|
|
220
|
+
if (this.onopen) {
|
|
221
|
+
this.onopen(data);
|
|
222
|
+
}
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
case 'error': {
|
|
226
|
+
if (this.onerror) {
|
|
227
|
+
this.onerror(data);
|
|
228
|
+
}
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
case 'message': {
|
|
232
|
+
if (this.onmessage) {
|
|
233
|
+
this.onmessage(data);
|
|
234
|
+
}
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
close() {
|
|
240
|
+
if (this.status !== EventSource.CLOSED) {
|
|
241
|
+
this.status = EventSource.CLOSED;
|
|
242
|
+
}
|
|
243
|
+
if (this._xhr) {
|
|
244
|
+
this._xhr.abort();
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
exports.default = EventSource;
|
|
249
|
+
//# sourceMappingURL=EventSourceShim.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventSourceShim.js","sourceRoot":"","sources":["../src/EventSourceShim.ts"],"names":[],"mappings":";;AAEA,qGAAqG;AACrG,qFAAqF;AAErF,MAAM,gBAAgB,GAAG;IACvB,QAAQ;IACR,QAAQ;IACR,kBAAkB;IAClB,SAAS;IACT,MAAM;CACP,CAAC;AAEF,MAAM,WAAW;IACP,KAAK,GAAG,CAAC,CAAC,CAAC;IACnB,MAAM,CAAC,UAAU,GAAG,CAAC,CAAC;IACtB,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC;IAChB,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IAElB,2EAA2E;IAC3E,6EAA6E;IAC7E,0EAA0E;IAC1E,wEAAwE;IACxE,yEAAyE;IACzE,uEAAuE;IACvE,uCAAuC;IACvC,MAAM,CAAC,sBAAsB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;IAExC,I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b,KAAK,MAAM,CAAC,CAAC,CAAC;gBACZ,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;oBAChB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBACpB,CAAC;gBACD,MAAM;YACR,CAAC;YACD,KAAK,OAAO,CAAC,CAAC,CAAC;gBACb,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;oBACjB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBACrB,CAAC;gBACD,MAAM;YACR,CAAC;YACD,KAAK,SAAS,CAAC,CAAC,CAAC;gBACf,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;oBACnB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;gBACvB,CAAC;gBACD,MAAM;YACR,CAAC;QACH,CAAC;IACH,CAAC;IAED,KAAK;QACH,IAAI,IAAI,CAAC,MAAM,KAAK,WAAW,CAAC,MAAM,EAAE,CAAC;YACvC,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;QACnC,CAAC;QAED,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACd,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QACpB,CAAC;IACH,CAAC;;AAGH,kBAAe,WAAW,CAAC","sourcesContent":["import { type EventSourceType } from '@instantdb/core';\n\n// Modified version of https://github.com/binaryminds/react-native-sse/blob/master/src/EventSource.js\n// that conforms to our `EventSourceType` subset of the browser-native `EventSource`.\n\nconst XMLReadyStateMap = [\n 'UNSENT',\n 'OPENED',\n 'HEADERS_RECEIVED',\n 'LOADING',\n 'DONE',\n];\n\nclass EventSource implements EventSourceType {\n private ERROR = -1;\n static CONNECTING = 0;\n static OPEN = 1;\n static CLOSED = 2;\n\n // [roko-db] RN's XHR accumulates the whole streamed body in one string and\n // this shim never recycled the connection, so a long-lived SSE session (e.g.\n // Mac Catalyst, where the WebSocket fallback pins Instant to SSE) grew it\n // until Hermes threw a fatal \"RangeError: String length exceeds limit\".\n // Past this many processed characters we abort and surface an SSE error;\n // the consumer reconnects with a fresh instance (same path as a normal\n // DONE), which resets the accumulator.\n static MAX_ACCUMULATED_LENGTH = 8 * 1024 * 1024;\n\n private CRLF = '\\r\\n';\n private LF = '\\n';\n private CR = '\\r';\n\n readonly url: string;\n\n onopen;\n onerror;\n onmessage;\n\n debug: boolean;\n\n private status: number;\n\n private headers = {\n Accept: 'text/event-stream',\n 'Cache-Control': 'no-cache',\n 'X-Requested-With': 'XMLHttpRequest',\n };\n\n private _xhr: XMLHttpRequest | null;\n private lineEndingCharacter: string | null;\n private _lastIndexProcessed: number;\n\n constructor(url) {\n this.status = EventSource.CONNECTING;\n\n this.lineEndingCharacter = null;\n this._xhr = null;\n this._lastIndexProcessed = 0;\n this.debug = false;\n\n if (!url || typeof url !== 'string') {\n throw new SyntaxError('[EventSource] Invalid URL argument.');\n }\n\n this.url = url;\n\n this.open();\n }\n\n public get readyState() {\n if (this.status === this.ERROR) {\n return EventSource.CLOSED;\n }\n return this.status;\n }\n\n open() {\n try {\n this.status = EventSource.CONNECTING;\n\n this._lastIndexProcessed = 0;\n\n this._xhr = new XMLHttpRequest();\n this._xhr.open('GET', this.url, true);\n\n for (const [key, value] of Object.entries(this.headers)) {\n if (value !== undefined && value !== null) {\n this._xhr.setRequestHeader(key, value);\n }\n }\n\n this._xhr.onreadystatechange = () => {\n if (this.status === EventSource.CLOSED) {\n return;\n }\n\n const xhr = this._xhr!;\n\n this._logDebug(\n `[EventSource][onreadystatechange] ReadyState: ${XMLReadyStateMap[xhr.readyState] || 'Unknown'}(${\n xhr.readyState\n }), status: ${xhr.status}`,\n );\n\n if (\n xhr.readyState !== XMLHttpRequest.DONE &&\n xhr.readyState !== XMLHttpRequest.LOADING\n ) {\n return;\n }\n\n if (xhr.status >= 200 && xhr.status < 400) {\n if (this.status === EventSource.CONNECTING) {\n this.status = EventSource.OPEN;\n this.dispatch('open', { type: 'open' });\n this._logDebug(\n '[EventSource][onreadystatechange][OPEN] Connection opened.',\n );\n }\n\n this._handleEvent(xhr.responseText || '');\n\n // [roko-db] Recycle before the accumulated responseText can exceed\n // Hermes' string cap (see MAX_ACCUMULATED_LENGTH).\n if (\n xhr.readyState === XMLHttpRequest.LOADING &&\n this._lastIndexProcessed > EventSource.MAX_ACCUMULATED_LENGTH\n ) {\n this._logDebug(\n '[EventSource][onreadystatechange] Accumulated response cap reached — recycling connection.',\n );\n this.status = this.ERROR;\n this.dispatch('error', {\n type: 'error',\n message: 'recycled: accumulated response cap reached',\n });\n xhr.abort();\n return;\n }\n\n if (xhr.readyState === XMLHttpRequest.DONE) {\n this._logDebug(\n '[EventSource][onreadystatechange][DONE] Operation done.',\n );\n this.dispatch('error', { type: 'error' });\n }\n } else if (xhr.status !== 0) {\n this.status = this.ERROR;\n this.dispatch('error', {\n type: 'error',\n message: xhr.responseText,\n xhrStatus: xhr.status,\n xhrState: xhr.readyState,\n });\n\n if (xhr.readyState === XMLHttpRequest.DONE) {\n this._logDebug(\n '[EventSource][onreadystatechange][ERROR] Response status error.',\n );\n }\n }\n };\n\n this._xhr.onerror = () => {\n if (this.status === EventSource.CLOSED) {\n return;\n }\n\n this.status = this.ERROR;\n this.dispatch('error', {\n type: 'error',\n message: this._xhr!.responseText,\n xhrStatus: this._xhr!.status,\n xhrState: this._xhr!.readyState,\n });\n };\n\n this._xhr.send();\n } catch (e) {\n this.status = this.ERROR;\n this.dispatch('error', {\n type: 'exception',\n message: e.message,\n error: e,\n });\n }\n }\n\n _logDebug(...msg) {\n if (this.debug) {\n console.debug(...msg);\n }\n }\n\n _handleEvent(response) {\n if (this.lineEndingCharacter === null) {\n const detectedNewlineChar = this._detectNewlineChar(response);\n if (detectedNewlineChar !== null) {\n this._logDebug(\n `[EventSource] Automatically detected lineEndingCharacter: ${JSON.stringify(\n detectedNewlineChar,\n ).slice(1, -1)}`,\n );\n this.lineEndingCharacter = detectedNewlineChar;\n } else {\n console.warn(\n \"[EventSource] Unable to identify the line ending character. Ensure your server delivers a standard line ending character: \\\\r\\\\n, \\\\n, \\\\r, or specify your custom character using the 'lineEndingCharacter' option.\",\n );\n return;\n }\n }\n\n const indexOfDoubleNewline = this._getLastDoubleNewlineIndex(response);\n if (indexOfDoubleNewline <= this._lastIndexProcessed) {\n return;\n }\n\n const parts = response\n .substring(this._lastIndexProcessed, indexOfDoubleNewline)\n .split(this.lineEndingCharacter);\n\n this._lastIndexProcessed = indexOfDoubleNewline;\n\n let type: string | undefined = undefined;\n let data: string[] = [];\n let line = '';\n\n for (let i = 0; i < parts.length; i++) {\n line = parts[i].trim();\n if (line.startsWith('event')) {\n type = line.replace(/event:?\\s*/, '');\n } else if (line.startsWith('retry')) {\n // Ignore for our use case, we'll reconnect with a new\n // instance on error\n } else if (line.startsWith('data')) {\n data.push(line.replace(/data:?\\s*/, ''));\n } else if (line.startsWith('id')) {\n // Ignore this, not used for our use case\n } else if (line === '') {\n if (data.length > 0) {\n const eventType = type || 'message';\n const event = {\n type: eventType,\n data: data.join('\\n'),\n url: this.url,\n };\n\n this.dispatch(eventType, event);\n\n data = [];\n type = undefined;\n }\n }\n }\n }\n\n _detectNewlineChar(response) {\n const supportedLineEndings = [this.CRLF, this.LF, this.CR];\n for (const char of supportedLineEndings) {\n if (response.includes(char)) {\n return char;\n }\n }\n return null;\n }\n\n _getLastDoubleNewlineIndex(response) {\n const doubleLineEndingCharacter =\n this.lineEndingCharacter! + this.lineEndingCharacter!;\n const lastIndex = response.lastIndexOf(doubleLineEndingCharacter);\n if (lastIndex === -1) {\n return -1;\n }\n\n return lastIndex + doubleLineEndingCharacter.length;\n }\n\n dispatch(type, data) {\n switch (type) {\n case 'open': {\n if (this.onopen) {\n this.onopen(data);\n }\n break;\n }\n case 'error': {\n if (this.onerror) {\n this.onerror(data);\n }\n break;\n }\n case 'message': {\n if (this.onmessage) {\n this.onmessage(data);\n }\n break;\n }\n }\n }\n\n close() {\n if (this.status !== EventSource.CLOSED) {\n this.status = EventSource.CLOSED;\n }\n\n if (this._xhr) {\n this._xhr.abort();\n }\n }\n}\n\nexport default EventSource;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NetworkListener.d.ts","sourceRoot":"","sources":["../src/NetworkListener.js"],"names":[],"mappings":"AAEA;IACE,8CAGC;IACD,qFAIC;CACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const netinfo_1 = __importDefault(require("@react-native-community/netinfo"));
|
|
7
|
+
class NetworkListener {
|
|
8
|
+
static async getIsOnline() {
|
|
9
|
+
const network = await netinfo_1.default.fetch();
|
|
10
|
+
return network.isConnected;
|
|
11
|
+
}
|
|
12
|
+
static listen(f) {
|
|
13
|
+
return netinfo_1.default.addEventListener((state) => {
|
|
14
|
+
f(state.isConnected);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.default = NetworkListener;
|
|
19
|
+
//# sourceMappingURL=NetworkListener.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NetworkListener.js","sourceRoot":"","sources":["../src/NetworkListener.js"],"names":[],"mappings":";;;;;AAAA,8EAAsD;AAEtD,MAAqB,eAAe;IAClC,MAAM,CAAC,KAAK,CAAC,WAAW;QACtB,MAAM,OAAO,GAAG,MAAM,iBAAO,CAAC,KAAK,EAAE,CAAC;QACtC,OAAO,OAAO,CAAC,WAAW,CAAC;IAC7B,CAAC;IACD,MAAM,CAAC,MAAM,CAAC,CAAC;QACb,OAAO,iBAAO,CAAC,gBAAgB,CAAC,CAAC,KAAK,EAAE,EAAE;YACxC,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAVD,kCAUC","sourcesContent":["import NetInfo from '@react-native-community/netinfo';\n\nexport default class NetworkListener {\n static async getIsOnline() {\n const network = await NetInfo.fetch();\n return network.isConnected;\n }\n static listen(f) {\n return NetInfo.addEventListener((state) => {\n f(state.isConnected);\n });\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Storage.d.ts","sourceRoot":"","sources":["../src/Storage.js"],"names":[],"mappings":";iCAAiC,iBAAiB"}
|
package/dist/Storage.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Storage.js","sourceRoot":"","sources":["../src/Storage.js"],"names":[],"mappings":";;AAAA,0CAAmD;AAEnD,kBAAe,uBAAgB,CAAC","sourcesContent":["import { IndexedDBStorage } from '@instantdb/core';\n\nexport default IndexedDBStorage;\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { StoreInterface, StoreInterfaceStoreName } from '@instantdb/core';
|
|
2
|
+
export declare class AsyncStorageStore extends StoreInterface {
|
|
3
|
+
private appId;
|
|
4
|
+
private dbName;
|
|
5
|
+
constructor(appId: string, dbName: StoreInterfaceStoreName);
|
|
6
|
+
private makeKey;
|
|
7
|
+
getItem(k: any): Promise<any>;
|
|
8
|
+
setItem(k: any, v: any): Promise<void>;
|
|
9
|
+
removeItem(k: string): Promise<void>;
|
|
10
|
+
getAllKeys(): Promise<string[]>;
|
|
11
|
+
multiSet(keyValuePairs: Array<[string, any]>): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
declare class MissingStore extends StoreInterface {
|
|
14
|
+
constructor(appId: string, dbName: StoreInterfaceStoreName);
|
|
15
|
+
getItem(_k: string): Promise<any>;
|
|
16
|
+
removeItem(_k: string): Promise<void>;
|
|
17
|
+
multiSet(_keyValuePairs: Array<[string, any]>): Promise<void>;
|
|
18
|
+
getAllKeys(): Promise<string[]>;
|
|
19
|
+
}
|
|
20
|
+
declare const _default: typeof MissingStore;
|
|
21
|
+
export default _default;
|
|
22
|
+
//# sourceMappingURL=Storage.native.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Storage.native.d.ts","sourceRoot":"","sources":["../src/Storage.native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAkB1E,qBAAa,iBAAkB,SAAQ,cAAc;IACnD,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,MAAM,CAA0B;gBAC5B,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,uBAAuB;IAM1D,OAAO,CAAC,OAAO;IAIT,OAAO,CAAC,CAAC,KAAA;IAMT,OAAO,CAAC,CAAC,KAAA,EAAE,CAAC,KAAA;IAIZ,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpC,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAY/B,QAAQ,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAKnE;AAED,cAAM,YAAa,SAAQ,cAAc;gBAC3B,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,uBAAuB;IAYpD,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAIjC,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAErC,QAAQ,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAE7D,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CAGtC;;AAED,wBAA+D"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AsyncStorageStore = void 0;
|
|
4
|
+
const core_1 = require("@instantdb/core");
|
|
5
|
+
const version = 5;
|
|
6
|
+
// AsyncStorage is an optional peer dependency. The `require` must sit
|
|
7
|
+
// directly inside a `try` block: that's what makes Metro treat it as an
|
|
8
|
+
// optional dependency (`transformer.allowOptionalDependencies`, enabled by
|
|
9
|
+
// default in the Expo and React Native metro configs), so bundling doesn't
|
|
10
|
+
// fail when it isn't installed. When it can't be loaded, `init` surfaces a
|
|
11
|
+
// helpful error unless a custom `Store` is passed.
|
|
12
|
+
let AsyncStorage = null;
|
|
13
|
+
let asyncStorageLoadError = null;
|
|
14
|
+
try {
|
|
15
|
+
AsyncStorage = require('@react-native-async-storage/async-storage').default;
|
|
16
|
+
}
|
|
17
|
+
catch (e) {
|
|
18
|
+
asyncStorageLoadError = e;
|
|
19
|
+
}
|
|
20
|
+
class AsyncStorageStore extends core_1.StoreInterface {
|
|
21
|
+
appId;
|
|
22
|
+
dbName;
|
|
23
|
+
constructor(appId, dbName) {
|
|
24
|
+
super(appId, dbName);
|
|
25
|
+
this.appId = appId;
|
|
26
|
+
this.dbName = dbName;
|
|
27
|
+
}
|
|
28
|
+
makeKey(k) {
|
|
29
|
+
return `instant_${this.appId}_${version}_${this.dbName}_${k}`;
|
|
30
|
+
}
|
|
31
|
+
async getItem(k) {
|
|
32
|
+
const res = await AsyncStorage.getItem(this.makeKey(k));
|
|
33
|
+
if (res === null)
|
|
34
|
+
return res;
|
|
35
|
+
return JSON.parse(res);
|
|
36
|
+
}
|
|
37
|
+
async setItem(k, v) {
|
|
38
|
+
await AsyncStorage.setItem(this.makeKey(k), JSON.stringify(v));
|
|
39
|
+
}
|
|
40
|
+
async removeItem(k) {
|
|
41
|
+
await AsyncStorage.removeItem(this.makeKey(k));
|
|
42
|
+
}
|
|
43
|
+
async getAllKeys() {
|
|
44
|
+
const allKeys = await AsyncStorage.getAllKeys();
|
|
45
|
+
const keys = [];
|
|
46
|
+
const keyPrefix = this.makeKey('');
|
|
47
|
+
for (const key of allKeys) {
|
|
48
|
+
if (key.startsWith(keyPrefix)) {
|
|
49
|
+
keys.push(key.substring(keyPrefix.length));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return keys;
|
|
53
|
+
}
|
|
54
|
+
async multiSet(keyValuePairs) {
|
|
55
|
+
await AsyncStorage.multiSet(keyValuePairs.map(([k, v]) => [this.makeKey(k), JSON.stringify(v)]));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.AsyncStorageStore = AsyncStorageStore;
|
|
59
|
+
class MissingStore extends core_1.StoreInterface {
|
|
60
|
+
constructor(appId, dbName) {
|
|
61
|
+
super(appId, dbName);
|
|
62
|
+
throw new Error('Instant needs a store to persist data on device. ' +
|
|
63
|
+
'Install `@react-native-async-storage/async-storage`, ' +
|
|
64
|
+
'or pass a `Store` to `init` (e.g. from `@instantdb/react-native-mmkv` or `@instantdb/expo-sqlite`).' +
|
|
65
|
+
(asyncStorageLoadError
|
|
66
|
+
? `\n\nLoading async-storage failed with: ${asyncStorageLoadError}`
|
|
67
|
+
: ''));
|
|
68
|
+
}
|
|
69
|
+
async getItem(_k) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
async removeItem(_k) { }
|
|
73
|
+
async multiSet(_keyValuePairs) { }
|
|
74
|
+
async getAllKeys() {
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.default = AsyncStorage ? AsyncStorageStore : MissingStore;
|
|
79
|
+
//# sourceMappingURL=Storage.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Storage.native.js","sourceRoot":"","sources":["../src/Storage.native.ts"],"names":[],"mappings":";;;AAAA,0CAA0E;AAE1E,MAAM,OAAO,GAAG,CAAC,CAAC;AAElB,sEAAsE;AACtE,wEAAwE;AACxE,2EAA2E;AAC3E,2EAA2E;AAC3E,2EAA2E;AAC3E,mDAAmD;AACnD,IAAI,YAAY,GAAQ,IAAI,CAAC;AAC7B,IAAI,qBAAqB,GAAY,IAA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Y,CAAC","sourcesContent":["import { StoreInterface, StoreInterfaceStoreName } from '@instantdb/core';\n\nconst version = 5;\n\n// AsyncStorage is an optional peer dependency. The `require` must sit\n// directly inside a `try` block: that's what makes Metro treat it as an\n// optional dependency (`transformer.allowOptionalDependencies`, enabled by\n// default in the Expo and React Native metro configs), so bundling doesn't\n// fail when it isn't installed. When it can't be loaded, `init` surfaces a\n// helpful error unless a custom `Store` is passed.\nlet AsyncStorage: any = null;\nlet asyncStorageLoadError: unknown = null;\ntry {\n AsyncStorage = require('@react-native-async-storage/async-storage').default;\n} catch (e) {\n asyncStorageLoadError = e;\n}\n\nexport class AsyncStorageStore extends StoreInterface {\n private appId: string;\n private dbName: StoreInterfaceStoreName;\n constructor(appId: string, dbName: StoreInterfaceStoreName) {\n super(appId, dbName);\n this.appId = appId;\n this.dbName = dbName;\n }\n\n private makeKey(k: string): string {\n return `instant_${this.appId}_${version}_${this.dbName}_${k}`;\n }\n\n async getItem(k) {\n const res = await AsyncStorage.getItem(this.makeKey(k));\n if (res === null) return res;\n return JSON.parse(res);\n }\n\n async setItem(k, v) {\n await AsyncStorage.setItem(this.makeKey(k), JSON.stringify(v));\n }\n\n async removeItem(k: string): Promise<void> {\n await AsyncStorage.removeItem(this.makeKey(k));\n }\n\n async getAllKeys(): Promise<string[]> {\n const allKeys = await AsyncStorage.getAllKeys();\n const keys: string[] = [];\n const keyPrefix = this.makeKey('');\n for (const key of allKeys) {\n if (key.startsWith(keyPrefix)) {\n keys.push(key.substring(keyPrefix.length));\n }\n }\n return keys;\n }\n\n async multiSet(keyValuePairs: Array<[string, any]>): Promise<void> {\n await AsyncStorage.multiSet(\n keyValuePairs.map(([k, v]) => [this.makeKey(k), JSON.stringify(v)]),\n );\n }\n}\n\nclass MissingStore extends StoreInterface {\n constructor(appId: string, dbName: StoreInterfaceStoreName) {\n super(appId, dbName);\n throw new Error(\n 'Instant needs a store to persist data on device. ' +\n 'Install `@react-native-async-storage/async-storage`, ' +\n 'or pass a `Store` to `init` (e.g. from `@instantdb/react-native-mmkv` or `@instantdb/expo-sqlite`).' +\n (asyncStorageLoadError\n ? `\\n\\nLoading async-storage failed with: ${asyncStorageLoadError}`\n : ''),\n );\n }\n\n async getItem(_k: string): Promise<any> {\n return null;\n }\n\n async removeItem(_k: string): Promise<void> {}\n\n async multiSet(_keyValuePairs: Array<[string, any]>): Promise<void> {}\n\n async getAllKeys(): Promise<string[]> {\n return [];\n }\n}\n\nexport default AsyncStorage ? AsyncStorageStore : MissingStore;\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const streamConstructors: {
|
|
2
|
+
ReadableStream: {
|
|
3
|
+
new (underlyingSource: UnderlyingByteSource, strategy?: {
|
|
4
|
+
highWaterMark?: number;
|
|
5
|
+
}): ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
6
|
+
new <R = any>(underlyingSource: UnderlyingDefaultSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>;
|
|
7
|
+
new <R = any>(underlyingSource?: UnderlyingSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>;
|
|
8
|
+
prototype: ReadableStream;
|
|
9
|
+
};
|
|
10
|
+
WritableStream: {
|
|
11
|
+
new <W = any>(underlyingSink?: UnderlyingSink<W>, strategy?: QueuingStrategy<W>): WritableStream<W>;
|
|
12
|
+
prototype: WritableStream;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=Streams.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Streams.d.ts","sourceRoot":"","sources":["../src/Streams.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,kBAAkB;;;yBAIgn5oC,CAAC;;;;;;;;;;CAD/o5oC,CAAC"}
|
package/dist/Streams.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.streamConstructors = void 0;
|
|
4
|
+
// RN may need a polyfill for streams, so we put those in Streams.native.ts
|
|
5
|
+
exports.streamConstructors = {
|
|
6
|
+
ReadableStream: ReadableStream,
|
|
7
|
+
WritableStream: WritableStream,
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=Streams.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Streams.js","sourceRoot":"","sources":["../src/Streams.ts"],"names":[],"mappings":";;;AAAA,2EAA2E;AAC9D,QAAA,kBAAkB,GAAG;IAChC,cAAc,EAAE,cAAc;IAC9B,cAAc,EAAE,cAAc;CAC/B,CAAC","sourcesContent":["// RN may need a polyfill for streams, so we put those in Streams.native.ts\nexport const streamConstructors = {\n ReadableStream: ReadableStream,\n WritableStream: WritableStream,\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Streams.native.d.ts","sourceRoot":"","sources":["../src/Streams.native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtE,eAAO,MAAM,kBAAkB;;;CAG9B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.streamConstructors = void 0;
|
|
4
|
+
const web_streams_polyfill_1 = require("web-streams-polyfill");
|
|
5
|
+
exports.streamConstructors = {
|
|
6
|
+
ReadableStream: web_streams_polyfill_1.ReadableStream,
|
|
7
|
+
WritableStream: web_streams_polyfill_1.WritableStream,
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=Streams.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Streams.native.js","sourceRoot":"","sources":["../src/Streams.native.ts"],"names":[],"mappings":";;;AAAA,+DAAsE;AAEzD,QAAA,kBAAkB,GAAG;IAChC,cAAc,EAAE,qCAAc;IAC9B,cAAc,EAAE,qCAAc;CAC/B,CAAC","sourcesContent":["import { ReadableStream, WritableStream } from 'web-streams-polyfill';\n\nexport const streamConstructors = {\n ReadableStream: ReadableStream,\n WritableStream: WritableStream,\n};\n"]}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("@instantdb/core"), exports);
|
|
18
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC","sourcesContent":["export * from '@instantdb/core';\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import 'react-native-get-random-values';
|
|
2
|
+
import Store from './Storage';
|
|
3
|
+
import NetworkListener from './NetworkListener';
|
|
4
|
+
import { InstantReactAbstractDatabase } from '@instantdb/react-common';
|
|
5
|
+
import { i, id, tx, lookup, InstantAPIError, setInstantWarningsEnabled, SyncTableCallbackEventType, createInstantRouteHandler, type RoomSchemaShape, type InstantQuery, type InstantQueryResult, type InstantSchema, type InstantSchemaDatabase, type ConnectionStatus, type BackwardsCompatibleSchema, type IInstantDatabase, type Config, type Query, type QueryResponse, type InstantObject, type AuthState, type User, type PresencePeer, type AttrsDefs, type CardinalityKind, type DataAttrDef, type EntitiesDef, type EntitiesWithLinks, type EntityDef, type InstantGraph, type InstantUnknownSchemaDef, type LinkAttrDef, type LinkDef, type LinksDef, type ResolveAttrs, type ValueTypes, type InstantEntity, type InstaQLEntity, type InstaQLResult, type InstaQLEntitySubquery, type RoomsOf, type RoomsDef, type PresenceOf, type TopicsOf, type TopicOf, type RoomHandle, type CreateParams, type InstantConfig, type InstantSchemaDef, type InstantUnknownSchema, type TransactionChunk, type InstantRules, type UpdateParams, type LinkParams, type ValidQuery, type CheckMagicCodeParams, type CheckMagicCodeResponse, type ExchangeCodeForTokenParams, type SendMagicCodeParams, type SendMagicCodeResponse, type SignInWithIdTokenParams, type VerifyMagicCodeParams, type VerifyResponse, type FileOpts, type UploadFileResponse, type DeleteFileResponse, type SyncTableCallback, type SyncTableCallbackEvent, type SyncTableInitialSyncBatch, type SyncTableInitialSyncComplete, type SyncTableSyncTransaction, type SyncTableLoadFromStorage, type SyncTableSetupError, StoreInterface, type StoreInterfaceStoreName, CreateReadStreamOpts, CreateWriteStreamOpts, InstantWritableStream, InstantReadableStream, type Logger } from '@instantdb/core';
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* The first step: init your application!
|
|
9
|
+
*
|
|
10
|
+
* Visit https://instantdb.com/dash to get your `appId` :)
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* import { init } from "@instantdb/react-native"
|
|
14
|
+
*
|
|
15
|
+
* const db = init({ appId: "my-app-id" })
|
|
16
|
+
*
|
|
17
|
+
* // You can also provide a schema for type safety and editor autocomplete!
|
|
18
|
+
*
|
|
19
|
+
* import { init } from "@instantdb/react-native"
|
|
20
|
+
* import schema from ""../instant.schema.ts";
|
|
21
|
+
*
|
|
22
|
+
* const db = init({ appId: "my-app-id", schema })
|
|
23
|
+
*
|
|
24
|
+
* // To learn more: https://instantdb.com/docs/modeling-data
|
|
25
|
+
*/
|
|
26
|
+
declare function init<Schema extends InstantSchemaDef<any, any, any> = InstantUnknownSchema, UseDates extends boolean = false>(config: Omit<InstantConfig<Schema, UseDates>, 'useDateObjects'> & {
|
|
27
|
+
useDateObjects?: UseDates;
|
|
28
|
+
}): InstantReactNativeDatabase<Schema, UseDates, InstantConfig<Schema, UseDates>>;
|
|
29
|
+
/**
|
|
30
|
+
* @deprecated
|
|
31
|
+
* `init_experimental` is deprecated. You can replace it with `init`.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
*
|
|
35
|
+
* // Before
|
|
36
|
+
* import { init_experimental } from "@instantdb/react-native"
|
|
37
|
+
* const db = init_experimental({ ... });
|
|
38
|
+
*
|
|
39
|
+
* // After
|
|
40
|
+
* import { init } from "@instantdb/react-native"
|
|
41
|
+
* const db = init({ ... });
|
|
42
|
+
*/
|
|
43
|
+
declare const init_experimental: typeof init;
|
|
44
|
+
declare class InstantReactNativeDatabase<Schema extends InstantSchemaDef<any, any, any>, UseDates extends boolean, Config extends InstantConfig<Schema, UseDates> = InstantConfig<Schema, UseDates>> extends InstantReactAbstractDatabase<Schema, UseDates, Config> {
|
|
45
|
+
static Store: typeof Store;
|
|
46
|
+
static NetworkListener: typeof NetworkListener;
|
|
47
|
+
static EventSourceImpl: {
|
|
48
|
+
new (url: string | URL, eventSourceInitDict?: EventSourceInit): EventSource;
|
|
49
|
+
prototype: EventSource;
|
|
50
|
+
readonly CONNECTING: 0;
|
|
51
|
+
readonly OPEN: 1;
|
|
52
|
+
readonly CLOSED: 2;
|
|
53
|
+
} | typeof import("./EventSourceShim").default;
|
|
54
|
+
}
|
|
55
|
+
export { init, init_experimental, id, tx, lookup, i, createInstantRouteHandler, InstantReactNativeDatabase, InstantAPIError, setInstantWarningsEnabled, SyncTableCallbackEventType, type Config, type Query, type QueryResponse, type InstantObject, type User, type AuthState, type ConnectionStatus, type InstantQuery, type InstantQueryResult, type InstantSchema, type InstantSchemaDatabase, type IInstantDatabase, type InstantEntity, type RoomSchemaShape, type PresencePeer, type AttrsDefs, type CardinalityKind, type DataAttrDef, type EntitiesDef, type EntitiesWithLinks, type EntityDef, type InstantGraph, type CreateParams, type LinkAttrDef, type InstantConfig, type LinkDef, type InstantUnknownSchemaDef, type LinksDef, type RoomsOf, type RoomsDef, type RoomHandle, type PresenceOf, type TopicsOf, type TopicOf, type ResolveAttrs, type ValueTypes, type InstaQLEntity, type InstaQLResult, type InstaQLEntitySubquery, type InstantSchemaDef, type InstantUnknownSchema, type BackwardsCompatibleSchema, type InstantRules, type UpdateParams, type LinkParams, type ValidQuery, type CheckMagicCodeParams, type CheckMagicCodeResponse, type ExchangeCodeForTokenParams, type SendMagicCodeParams, type TransactionChunk, type SendMagicCodeResponse, type SignInWithIdTokenParams, type VerifyMagicCodeParams, type VerifyResponse, type FileOpts, type UploadFileResponse, type DeleteFileResponse, type CreateReadStreamOpts, type CreateWriteStreamOpts, type InstantWritableStream, type InstantReadableStream, StoreInterface, type StoreInterfaceStoreName, type SyncTableCallback, type SyncTableCallbackEvent, type SyncTableInitialSyncBatch, type SyncTableInitialSyncComplete, type SyncTableSyncTransaction, type SyncTableLoadFromStorage, type SyncTableSetupError, type Logger, };
|
|
56
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAC;AAExC,OAAO,KAAK,MAAM,WAAW,CAAC;AAE9B,OAAO,eAA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