@evolu/react-native 14.2.0 → 15.0.0-next.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/README.md +3 -3
- package/dist/src/Polyfills.d.ts +3 -0
- package/dist/src/Polyfills.d.ts.map +1 -0
- package/dist/src/Polyfills.js +209 -0
- package/dist/src/Task.d.ts +31 -0
- package/dist/src/Task.d.ts.map +1 -0
- package/dist/src/Task.js +46 -0
- package/dist/src/Worker.d.ts +30 -0
- package/dist/src/Worker.d.ts.map +1 -0
- package/dist/src/Worker.js +29 -0
- package/dist/src/components/EvoluIdenticon.d.ts +9 -0
- package/dist/src/components/EvoluIdenticon.d.ts.map +1 -0
- package/dist/{components → src/components}/EvoluIdenticon.js +1 -1
- package/dist/src/createExpoDeps.d.ts +1 -0
- package/dist/src/createExpoDeps.d.ts.map +1 -0
- package/dist/src/createExpoDeps.js +163 -0
- package/dist/src/exports/bare-op-sqlite.d.ts +1 -0
- package/dist/src/exports/bare-op-sqlite.d.ts.map +1 -0
- package/dist/src/exports/bare-op-sqlite.js +31 -0
- package/dist/src/exports/expo-op-sqlite.d.ts +1 -0
- package/dist/src/exports/expo-op-sqlite.d.ts.map +1 -0
- package/dist/src/exports/expo-op-sqlite.js +16 -0
- package/dist/src/exports/expo-sqlite.d.ts +11 -0
- package/dist/src/exports/expo-sqlite.d.ts.map +1 -0
- package/dist/src/exports/expo-sqlite.js +24 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +3 -0
- package/dist/src/shared.d.ts +5 -0
- package/dist/src/shared.d.ts.map +1 -0
- package/dist/src/shared.js +87 -0
- package/dist/src/sqlite-drivers/createExpoSqliteDriver.d.ts +3 -0
- package/dist/src/sqlite-drivers/createExpoSqliteDriver.d.ts.map +1 -0
- package/dist/src/sqlite-drivers/createExpoSqliteDriver.js +51 -0
- package/dist/src/sqlite-drivers/createOpSqliteDriver.d.ts +3 -0
- package/dist/src/sqlite-drivers/createOpSqliteDriver.d.ts.map +1 -0
- package/dist/src/sqlite-drivers/createOpSqliteDriver.js +37 -0
- package/dist/src/web.d.ts.map +1 -0
- package/package.json +73 -52
- package/src/ErrorUtils.d.ts +19 -0
- package/src/Polyfills.ts +305 -0
- package/src/Task.ts +66 -0
- package/src/Worker.ts +54 -0
- package/src/components/EvoluIdenticon.tsx +2 -2
- package/src/createExpoDeps.ts +162 -160
- package/src/exports/bare-op-sqlite.ts +30 -28
- package/src/exports/expo-op-sqlite.ts +15 -14
- package/src/exports/expo-sqlite.ts +21 -4
- package/src/index.ts +2 -0
- package/src/shared.ts +113 -52
- package/src/sqlite-drivers/createExpoSqliteDriver.ts +59 -51
- package/src/sqlite-drivers/createOpSqliteDriver.ts +51 -61
- package/LICENSE +0 -21
- package/dist/components/EvoluIdenticon.d.ts +0 -9
- package/dist/components/EvoluIdenticon.d.ts.map +0 -1
- package/dist/createExpoDeps.d.ts +0 -7
- package/dist/createExpoDeps.d.ts.map +0 -1
- package/dist/createExpoDeps.js +0 -123
- package/dist/exports/bare-op-sqlite.d.ts +0 -10
- package/dist/exports/bare-op-sqlite.d.ts.map +0 -1
- package/dist/exports/bare-op-sqlite.js +0 -24
- package/dist/exports/expo-op-sqlite.d.ts +0 -9
- package/dist/exports/expo-op-sqlite.d.ts.map +0 -1
- package/dist/exports/expo-op-sqlite.js +0 -12
- package/dist/exports/expo-sqlite.d.ts +0 -8
- package/dist/exports/expo-sqlite.d.ts.map +0 -1
- package/dist/exports/expo-sqlite.js +0 -11
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -1
- package/dist/shared.d.ts +0 -5
- package/dist/shared.d.ts.map +0 -1
- package/dist/shared.js +0 -39
- package/dist/sqlite-drivers/createExpoSqliteDriver.d.ts +0 -3
- package/dist/sqlite-drivers/createExpoSqliteDriver.d.ts.map +0 -1
- package/dist/sqlite-drivers/createExpoSqliteDriver.js +0 -46
- package/dist/sqlite-drivers/createOpSqliteDriver.d.ts +0 -3
- package/dist/sqlite-drivers/createOpSqliteDriver.d.ts.map +0 -1
- package/dist/sqlite-drivers/createOpSqliteDriver.js +0 -54
- package/dist/web.d.ts.map +0 -1
- /package/dist/{web.d.ts → src/web.d.ts} +0 -0
- /package/dist/{web.js → src/web.js} +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# Evolu for React Native
|
|
1
|
+
# Evolu for React Native
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This package provides Evolu for [React Native](https://reactnative.dev) and [Expo](https://expo.dev).
|
|
4
4
|
|
|
5
5
|
## Documentation
|
|
6
6
|
|
|
@@ -12,4 +12,4 @@ The Evolu community is on [GitHub Discussions](https://github.com/evoluhq/evolu/
|
|
|
12
12
|
|
|
13
13
|
To chat with other community members, you can join the [Evolu Discord](https://discord.gg/2J8yyyyxtZ).
|
|
14
14
|
|
|
15
|
-
[](https://x.com/evoluhq)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Polyfills.d.ts","sourceRoot":"","sources":["../../src/Polyfills.ts"],"names":[],"mappings":"AAmCA,qEAAqE;AACrE,eAAO,MAAM,gBAAgB,QAAO,IAKnC,CAAC"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
3
|
+
import { installPolyfills as installCommonPolyfills } from "@evolu/common/polyfills";
|
|
4
|
+
// @ts-expect-error Runtime polyfill package has no TypeScript declarations.
|
|
5
|
+
import fromAsync from "array-from-async";
|
|
6
|
+
// @ts-expect-error Runtime polyfill package has no TypeScript declarations.
|
|
7
|
+
import withResolvers from "promise.withresolvers";
|
|
8
|
+
// @ts-expect-error Runtime polyfill package has no TypeScript declarations.
|
|
9
|
+
import promiseTry from "promise.try";
|
|
10
|
+
// @ts-expect-error Runtime polyfill package has no TypeScript declarations.
|
|
11
|
+
import toSorted from "array.prototype.tosorted";
|
|
12
|
+
// @ts-expect-error Runtime polyfill package has no TypeScript declarations.
|
|
13
|
+
import difference from "set.prototype.difference";
|
|
14
|
+
// @ts-expect-error Runtime polyfill package has no TypeScript declarations.
|
|
15
|
+
import intersection from "set.prototype.intersection";
|
|
16
|
+
// @ts-expect-error Runtime polyfill package has no TypeScript declarations.
|
|
17
|
+
import isDisjointFrom from "set.prototype.isdisjointfrom";
|
|
18
|
+
// @ts-expect-error Runtime polyfill package has no TypeScript declarations.
|
|
19
|
+
import isSubsetOf from "set.prototype.issubsetof";
|
|
20
|
+
// @ts-expect-error Runtime polyfill package has no TypeScript declarations.
|
|
21
|
+
import isSupersetOf from "set.prototype.issupersetof";
|
|
22
|
+
// @ts-expect-error Runtime polyfill package has no TypeScript declarations.
|
|
23
|
+
import symmetricDifference from "set.prototype.symmetricdifference";
|
|
24
|
+
// @ts-expect-error Runtime polyfill package has no TypeScript declarations.
|
|
25
|
+
import union from "set.prototype.union";
|
|
26
|
+
difference.shim();
|
|
27
|
+
intersection.shim();
|
|
28
|
+
isDisjointFrom.shim();
|
|
29
|
+
isSubsetOf.shim();
|
|
30
|
+
isSupersetOf.shim();
|
|
31
|
+
symmetricDifference.shim();
|
|
32
|
+
union.shim();
|
|
33
|
+
/** Installs polyfills required by Evolu in React Native runtimes. */
|
|
34
|
+
export const installPolyfills = () => {
|
|
35
|
+
installCommonPolyfills();
|
|
36
|
+
installArrayPolyfills();
|
|
37
|
+
installPromisePolyfills();
|
|
38
|
+
installAbortControllerPolyfills();
|
|
39
|
+
};
|
|
40
|
+
const installArrayPolyfills = () => {
|
|
41
|
+
if (typeof Array.fromAsync !== "function") {
|
|
42
|
+
Object.defineProperty(Array, "fromAsync", {
|
|
43
|
+
configurable: true,
|
|
44
|
+
enumerable: false,
|
|
45
|
+
writable: true,
|
|
46
|
+
value: fromAsync,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
toSorted.shim();
|
|
50
|
+
};
|
|
51
|
+
const installPromisePolyfills = () => {
|
|
52
|
+
withResolvers.shim();
|
|
53
|
+
promiseTry.shim();
|
|
54
|
+
};
|
|
55
|
+
const abortReasonBySignal = new WeakMap();
|
|
56
|
+
const anyControllersBySignal = new WeakMap();
|
|
57
|
+
const installAbortControllerPolyfills = () => {
|
|
58
|
+
installAbortReasonPolyfill(globalThis.AbortController, globalThis.AbortSignal);
|
|
59
|
+
installAbortSignalStaticMethods(globalThis.AbortController, globalThis.AbortSignal);
|
|
60
|
+
};
|
|
61
|
+
const installAbortReasonPolyfill = (abortController, abortSignal) => {
|
|
62
|
+
if (!("reason" in abortSignal.prototype)) {
|
|
63
|
+
Object.defineProperty(abortSignal.prototype, "reason", {
|
|
64
|
+
configurable: true,
|
|
65
|
+
enumerable: false,
|
|
66
|
+
get() {
|
|
67
|
+
return abortReasonBySignal.get(this);
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
const prototype = abortController.prototype;
|
|
72
|
+
if (prototype.__evoluAbortReasonPatched)
|
|
73
|
+
return;
|
|
74
|
+
const nativeAbort = prototype.abort;
|
|
75
|
+
prototype.abort = function (reason) {
|
|
76
|
+
const normalizedReason = reason === undefined ? createAbortError() : reason;
|
|
77
|
+
abortReasonBySignal.set(this.signal, normalizedReason);
|
|
78
|
+
nativeAbort.call(this, normalizedReason);
|
|
79
|
+
};
|
|
80
|
+
Object.defineProperty(prototype, "__evoluAbortReasonPatched", {
|
|
81
|
+
value: true,
|
|
82
|
+
configurable: true,
|
|
83
|
+
enumerable: false,
|
|
84
|
+
writable: false,
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
const installAbortSignalStaticMethods = (abortController, abortSignal) => {
|
|
88
|
+
if (typeof abortSignal.abort !== "function") {
|
|
89
|
+
Object.defineProperty(abortSignal, "abort", {
|
|
90
|
+
configurable: true,
|
|
91
|
+
enumerable: false,
|
|
92
|
+
writable: true,
|
|
93
|
+
value: (reason) => {
|
|
94
|
+
const controller = new abortController();
|
|
95
|
+
controller.abort(reason);
|
|
96
|
+
return controller.signal;
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
if (typeof abortSignal.timeout !== "function") {
|
|
101
|
+
Object.defineProperty(abortSignal, "timeout", {
|
|
102
|
+
configurable: true,
|
|
103
|
+
enumerable: false,
|
|
104
|
+
writable: true,
|
|
105
|
+
value: (milliseconds) => {
|
|
106
|
+
const controller = new abortController();
|
|
107
|
+
const timeoutId = globalThis.setTimeout(() => {
|
|
108
|
+
controller.abort(createTimeoutError(milliseconds));
|
|
109
|
+
}, milliseconds);
|
|
110
|
+
controller.signal.addEventListener("abort", () => {
|
|
111
|
+
globalThis.clearTimeout(timeoutId);
|
|
112
|
+
}, { once: true });
|
|
113
|
+
return controller.signal;
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
if (typeof abortSignal.any !== "function") {
|
|
118
|
+
Object.defineProperty(abortSignal, "any", {
|
|
119
|
+
configurable: true,
|
|
120
|
+
enumerable: false,
|
|
121
|
+
writable: true,
|
|
122
|
+
value: (signals) => createAbortSignalAny(abortController, signals),
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
const createAbortSignalAny = (abortController, signals) => {
|
|
127
|
+
const controller = new abortController();
|
|
128
|
+
if (signals.length === 0)
|
|
129
|
+
return controller.signal;
|
|
130
|
+
for (const signal of signals) {
|
|
131
|
+
if (signal.aborted) {
|
|
132
|
+
controller.abort(readSignalReason(signal));
|
|
133
|
+
return controller.signal;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const sources = Array.from(new Set(signals));
|
|
137
|
+
for (const signal of sources) {
|
|
138
|
+
const registry = anyControllersBySignal.get(signal) ??
|
|
139
|
+
createAnyControllersRegistry(signal);
|
|
140
|
+
anyControllersBySignal.set(signal, registry);
|
|
141
|
+
registry.add(controller);
|
|
142
|
+
}
|
|
143
|
+
controller.signal.addEventListener("abort", () => {
|
|
144
|
+
for (const signal of sources) {
|
|
145
|
+
anyControllersBySignal.get(signal)?.remove(controller);
|
|
146
|
+
}
|
|
147
|
+
}, { once: true });
|
|
148
|
+
return controller.signal;
|
|
149
|
+
};
|
|
150
|
+
const createAnyControllersRegistry = (sourceSignal) => {
|
|
151
|
+
let refs = [];
|
|
152
|
+
const cleanup = () => {
|
|
153
|
+
refs = refs.filter((ref) => {
|
|
154
|
+
const controller = ref.deref();
|
|
155
|
+
return controller != null && !controller.signal.aborted;
|
|
156
|
+
});
|
|
157
|
+
if (refs.length === 0) {
|
|
158
|
+
sourceSignal.removeEventListener("abort", onAbort);
|
|
159
|
+
anyControllersBySignal.delete(sourceSignal);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
const onAbort = () => {
|
|
163
|
+
const reason = readSignalReason(sourceSignal);
|
|
164
|
+
for (const ref of refs) {
|
|
165
|
+
const controller = ref.deref();
|
|
166
|
+
if (!controller || controller.signal.aborted)
|
|
167
|
+
continue;
|
|
168
|
+
controller.abort(reason);
|
|
169
|
+
}
|
|
170
|
+
refs = [];
|
|
171
|
+
sourceSignal.removeEventListener("abort", onAbort);
|
|
172
|
+
anyControllersBySignal.delete(sourceSignal);
|
|
173
|
+
};
|
|
174
|
+
sourceSignal.addEventListener("abort", onAbort, { once: true });
|
|
175
|
+
return {
|
|
176
|
+
add: (controller) => {
|
|
177
|
+
refs.push(new globalThis.WeakRef(controller));
|
|
178
|
+
cleanup();
|
|
179
|
+
},
|
|
180
|
+
remove: (controller) => {
|
|
181
|
+
refs = refs.filter((ref) => {
|
|
182
|
+
const candidate = ref.deref();
|
|
183
|
+
return candidate != null && candidate !== controller;
|
|
184
|
+
});
|
|
185
|
+
cleanup();
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
const readSignalReason = (signal) => {
|
|
190
|
+
if ("reason" in signal) {
|
|
191
|
+
return signal.reason;
|
|
192
|
+
}
|
|
193
|
+
return createAbortError();
|
|
194
|
+
};
|
|
195
|
+
const createTimeoutError = (milliseconds) => createNamedError("TimeoutError", `signal timed out after ${milliseconds} ms`);
|
|
196
|
+
const createAbortError = () => createNamedError("AbortError", "This operation was aborted");
|
|
197
|
+
const createNamedError = (name, message) => {
|
|
198
|
+
if (typeof globalThis.DOMException === "function") {
|
|
199
|
+
try {
|
|
200
|
+
return new globalThis.DOMException(message, name);
|
|
201
|
+
}
|
|
202
|
+
catch {
|
|
203
|
+
// Some runtimes expose DOMException but cannot construct it reliably.
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
const error = new Error(message);
|
|
207
|
+
error.name = name;
|
|
208
|
+
return error;
|
|
209
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React Native-specific Task utilities.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { type CreateRun, type RunDeps } from "@evolu/common";
|
|
7
|
+
/**
|
|
8
|
+
* Creates {@link Run} for React Native with global error handling.
|
|
9
|
+
*
|
|
10
|
+
* Registers `ErrorUtils.setGlobalHandler` for uncaught JavaScript errors. The
|
|
11
|
+
* handler is restored to the previous one when the Run is disposed.
|
|
12
|
+
*
|
|
13
|
+
* ### Example
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* const console = createConsole({
|
|
17
|
+
* formatter: createConsoleFormatter()({
|
|
18
|
+
* timestampFormat: "relative",
|
|
19
|
+
* }),
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* await using run = createRun({ console });
|
|
23
|
+
* await using stack = new AsyncDisposableStack();
|
|
24
|
+
*
|
|
25
|
+
* stack.use(await run.orThrow(startApp()));
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @group React Native Run
|
|
29
|
+
*/
|
|
30
|
+
export declare const createRun: CreateRun<RunDeps>;
|
|
31
|
+
//# sourceMappingURL=Task.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Task.d.ts","sourceRoot":"","sources":["../../src/Task.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAGL,KAAK,SAAS,EAEd,KAAK,OAAO,EACb,MAAM,eAAe,CAAC;AAEvB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,SAAS,EAAE,SAAS,CAAC,OAAO,CA4BxC,CAAC"}
|
package/dist/src/Task.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React Native-specific Task utilities.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { createRun as createCommonRun, createUnknownError, } from "@evolu/common";
|
|
7
|
+
/**
|
|
8
|
+
* Creates {@link Run} for React Native with global error handling.
|
|
9
|
+
*
|
|
10
|
+
* Registers `ErrorUtils.setGlobalHandler` for uncaught JavaScript errors. The
|
|
11
|
+
* handler is restored to the previous one when the Run is disposed.
|
|
12
|
+
*
|
|
13
|
+
* ### Example
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* const console = createConsole({
|
|
17
|
+
* formatter: createConsoleFormatter()({
|
|
18
|
+
* timestampFormat: "relative",
|
|
19
|
+
* }),
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* await using run = createRun({ console });
|
|
23
|
+
* await using stack = new AsyncDisposableStack();
|
|
24
|
+
*
|
|
25
|
+
* stack.use(await run.orThrow(startApp()));
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @group React Native Run
|
|
29
|
+
*/
|
|
30
|
+
export const createRun = (deps) => {
|
|
31
|
+
const run = createCommonRun(deps);
|
|
32
|
+
const console = run.deps.console.child("global");
|
|
33
|
+
const previousHandler = globalThis.ErrorUtils?.getGlobalHandler();
|
|
34
|
+
const handleError = (error, isFatal) => {
|
|
35
|
+
console.error(isFatal ? "fatalError" : "uncaughtError", createUnknownError(error));
|
|
36
|
+
// Call the previous handler if it exists
|
|
37
|
+
previousHandler?.(error, isFatal);
|
|
38
|
+
};
|
|
39
|
+
globalThis.ErrorUtils?.setGlobalHandler(handleError);
|
|
40
|
+
run.onAbort(() => {
|
|
41
|
+
if (previousHandler) {
|
|
42
|
+
globalThis.ErrorUtils?.setGlobalHandler(previousHandler);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
return run;
|
|
46
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type MessageChannel, type MessagePort, type NativeMessagePort, type SharedWorker, type SharedWorkerSelf, type Worker, type WorkerSelf } from "@evolu/common";
|
|
2
|
+
/**
|
|
3
|
+
* Creates an in-memory {@link Worker} for React Native.
|
|
4
|
+
*
|
|
5
|
+
* Since React Native doesn't support Web Workers yet, this runs in the main
|
|
6
|
+
* thread. Messages are queued until `onMessage` is assigned.
|
|
7
|
+
*/
|
|
8
|
+
export declare const createWorker: <Input, Output>(initWorker: (self: WorkerSelf<Input, Output>) => void) => Worker<Input, Output>;
|
|
9
|
+
/**
|
|
10
|
+
* Creates an in-memory {@link SharedWorker} for React Native.
|
|
11
|
+
*
|
|
12
|
+
* Since React Native doesn't support SharedWorkers, this runs in the main
|
|
13
|
+
* thread. Messages are queued until `onMessage` is assigned.
|
|
14
|
+
*/
|
|
15
|
+
export declare const createSharedWorker: <Input, Output>(initWorker: (self: SharedWorkerSelf<Input, Output>) => void) => SharedWorker<Input, Output>;
|
|
16
|
+
/**
|
|
17
|
+
* Creates an in-memory {@link MessageChannel} for React Native.
|
|
18
|
+
*
|
|
19
|
+
* Since React Native doesn't support MessageChannel yet, this creates two
|
|
20
|
+
* connected ports running in-process. Messages are queued until `onMessage` is
|
|
21
|
+
* assigned.
|
|
22
|
+
*/
|
|
23
|
+
export declare const createMessageChannel: <Input, Output = never>() => MessageChannel<Input, Output>;
|
|
24
|
+
/**
|
|
25
|
+
* Creates an Evolu {@link MessagePort} from a "native" port.
|
|
26
|
+
*
|
|
27
|
+
* Uses the shared in-memory native-port registry from `@evolu/common`.
|
|
28
|
+
*/
|
|
29
|
+
export declare const createMessagePort: <Input, Output = never>(nativePort: NativeMessagePort<Input, Output>) => MessagePort<Input, Output>;
|
|
30
|
+
//# sourceMappingURL=Worker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Worker.d.ts","sourceRoot":"","sources":["../../src/Worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,MAAM,EACX,KAAK,UAAU,EAChB,MAAM,eAAe,CAAC;AAEvB;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,KAAK,EAAE,MAAM,EACxC,YAAY,CAAC,IAAI,EAAE,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,KACpD,MAAM,CAAC,KAAK,EAAE,MAAM,CAAmC,CAAC;AAE3D;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,KAAK,EAAE,MAAM,EAC9C,YAAY,CAAC,IAAI,EAAE,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,KAC1D,YAAY,CAAC,KAAK,EAAE,MAAM,CAAyC,CAAC;AAEvE;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAAI,KAAK,EAAE,MAAM,GAAG,KAAK,OAAK,cAAc,CAC3E,KAAK,EACL,MAAM,CACwC,CAAC;AAEjD;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,KAAK,EAAE,MAAM,GAAG,KAAK,EACrD,YAAY,iBAAiB,CAAC,KAAK,EAAE,MAAM,CAAC,KAC3C,WAAW,CAAC,KAAK,EAAE,MAAM,CAAwC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createMessageChannel as createCommonMessageChannel, createMessagePort as createCommonMessagePort, createSharedWorker as createCommonSharedWorker, createWorker as createCommonWorker, } from "@evolu/common";
|
|
2
|
+
/**
|
|
3
|
+
* Creates an in-memory {@link Worker} for React Native.
|
|
4
|
+
*
|
|
5
|
+
* Since React Native doesn't support Web Workers yet, this runs in the main
|
|
6
|
+
* thread. Messages are queued until `onMessage` is assigned.
|
|
7
|
+
*/
|
|
8
|
+
export const createWorker = (initWorker) => createCommonWorker(initWorker);
|
|
9
|
+
/**
|
|
10
|
+
* Creates an in-memory {@link SharedWorker} for React Native.
|
|
11
|
+
*
|
|
12
|
+
* Since React Native doesn't support SharedWorkers, this runs in the main
|
|
13
|
+
* thread. Messages are queued until `onMessage` is assigned.
|
|
14
|
+
*/
|
|
15
|
+
export const createSharedWorker = (initWorker) => createCommonSharedWorker(initWorker);
|
|
16
|
+
/**
|
|
17
|
+
* Creates an in-memory {@link MessageChannel} for React Native.
|
|
18
|
+
*
|
|
19
|
+
* Since React Native doesn't support MessageChannel yet, this creates two
|
|
20
|
+
* connected ports running in-process. Messages are queued until `onMessage` is
|
|
21
|
+
* assigned.
|
|
22
|
+
*/
|
|
23
|
+
export const createMessageChannel = () => createCommonMessageChannel();
|
|
24
|
+
/**
|
|
25
|
+
* Creates an Evolu {@link MessagePort} from a "native" port.
|
|
26
|
+
*
|
|
27
|
+
* Uses the shared in-memory native-port registry from `@evolu/common`.
|
|
28
|
+
*/
|
|
29
|
+
export const createMessagePort = (nativePort) => createCommonMessagePort(nativePort);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type IdenticonStyle, OwnerId } from "@evolu/common";
|
|
2
|
+
import { type FC } from "react";
|
|
3
|
+
export declare const EvoluIdenticon: FC<{
|
|
4
|
+
id: OwnerId;
|
|
5
|
+
size?: number;
|
|
6
|
+
borderRadius?: number;
|
|
7
|
+
style?: IdenticonStyle;
|
|
8
|
+
}>;
|
|
9
|
+
//# sourceMappingURL=EvoluIdenticon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EvoluIdenticon.d.ts","sourceRoot":"","sources":["../../../src/components/EvoluIdenticon.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,cAAc,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC9E,OAAO,EAAE,KAAK,EAAE,EAAW,MAAM,OAAO,CAAC;AAIzC,eAAO,MAAM,cAAc,EAAE,EAAE,CAAC;IAC9B,EAAE,EAAE,OAAO,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,cAAc,CAAC;CACxB,CAcA,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createIdenticon } from "@evolu/common";
|
|
2
|
+
import { createIdenticon, OwnerId } from "@evolu/common";
|
|
3
3
|
import { useMemo } from "react";
|
|
4
4
|
import { View } from "react-native";
|
|
5
5
|
import { SvgXml } from "react-native-svg";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=createExpoDeps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createExpoDeps.d.ts","sourceRoot":"","sources":["../../src/createExpoDeps.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// import type {
|
|
3
|
+
// AccessControl,
|
|
4
|
+
// LocalAuthOptions,
|
|
5
|
+
// SecureStorage,
|
|
6
|
+
// SensitiveInfoItem,
|
|
7
|
+
// StorageMetadata,
|
|
8
|
+
// } from "@evolu/common";
|
|
9
|
+
// import {
|
|
10
|
+
// type CreateSqliteDriverDep,
|
|
11
|
+
// type LocalAuth,
|
|
12
|
+
// localAuthDefaultOptions,
|
|
13
|
+
// type ReloadApp,
|
|
14
|
+
// } from "@evolu/common";
|
|
15
|
+
// import type { EvoluDeps } from "@evolu/common/local-first";
|
|
16
|
+
// import * as Expo from "expo";
|
|
17
|
+
// import * as SecureStore from "expo-secure-store";
|
|
18
|
+
// import KVStore from "expo-sqlite/kv-store";
|
|
19
|
+
// import { createSharedEvoluDeps, createSharedLocalAuth } from "./shared.js";
|
|
20
|
+
// const reloadApp: ReloadApp = () => {
|
|
21
|
+
// void Expo.reloadAppAsync();
|
|
22
|
+
// };
|
|
23
|
+
//
|
|
24
|
+
// const createSecureStore = (): SecureStorage => {
|
|
25
|
+
// const store: SecureStorage = {
|
|
26
|
+
// setItem: async (key, value, options) => {
|
|
27
|
+
// const rnsiOpts = convertOptions(options);
|
|
28
|
+
// const service = options?.service ?? "default";
|
|
29
|
+
// const metadata = createMetadata(options?.accessControl === "none");
|
|
30
|
+
// await KVStore.setItem(`${service}-${key}`, "1");
|
|
31
|
+
// await SecureStore.setItemAsync(
|
|
32
|
+
// key,
|
|
33
|
+
// JSON.stringify({ value, metadata }),
|
|
34
|
+
// rnsiOpts,
|
|
35
|
+
// );
|
|
36
|
+
// return { metadata };
|
|
37
|
+
// },
|
|
38
|
+
//
|
|
39
|
+
// getItem: async (key, options) => {
|
|
40
|
+
// const rnsiOpts = convertOptions(options);
|
|
41
|
+
// const service = options?.service ?? "default";
|
|
42
|
+
// let data: { value: string; metadata: StorageMetadata };
|
|
43
|
+
// try {
|
|
44
|
+
// const result = await SecureStore.getItemAsync(key, rnsiOpts);
|
|
45
|
+
// if (!result) return null;
|
|
46
|
+
// data = JSON.parse(result) as {
|
|
47
|
+
// value: string;
|
|
48
|
+
// metadata: StorageMetadata;
|
|
49
|
+
// };
|
|
50
|
+
// } catch (_error) {
|
|
51
|
+
// return null;
|
|
52
|
+
// }
|
|
53
|
+
// return { key, service, ...data };
|
|
54
|
+
// },
|
|
55
|
+
//
|
|
56
|
+
// deleteItem: async (key, options) => {
|
|
57
|
+
// const rnsiOpts = convertOptions(options);
|
|
58
|
+
// const service = options?.service ?? "default";
|
|
59
|
+
// await Promise.all([
|
|
60
|
+
// KVStore.removeItemAsync(`${service}-${key}`),
|
|
61
|
+
// SecureStore.deleteItemAsync(key, rnsiOpts),
|
|
62
|
+
// ]);
|
|
63
|
+
// return true;
|
|
64
|
+
// },
|
|
65
|
+
//
|
|
66
|
+
// getAllItems: async (options) => {
|
|
67
|
+
// const keys = await KVStore.getAllKeysAsync();
|
|
68
|
+
// const service = options?.service ?? "default";
|
|
69
|
+
// const metadata = createMetadata(options?.accessControl === "none");
|
|
70
|
+
// return keys
|
|
71
|
+
// .filter((key) => key.startsWith(`${service}-`))
|
|
72
|
+
// .map((key) => ({
|
|
73
|
+
// key: key.slice(service.length + 1),
|
|
74
|
+
// service,
|
|
75
|
+
// metadata,
|
|
76
|
+
// }));
|
|
77
|
+
// },
|
|
78
|
+
//
|
|
79
|
+
// clearService: async (options) => {
|
|
80
|
+
// const rnsiOpts = convertOptions(options);
|
|
81
|
+
// const service = options?.service ?? "default";
|
|
82
|
+
// const items = await store.getAllItems(options);
|
|
83
|
+
// await KVStore.multiRemove(items.map((item) => `${service}-${item.key}`));
|
|
84
|
+
// await Promise.all(
|
|
85
|
+
// items.map(async (item) => {
|
|
86
|
+
// await SecureStore.deleteItemAsync(item.key, rnsiOpts);
|
|
87
|
+
// }),
|
|
88
|
+
// );
|
|
89
|
+
// },
|
|
90
|
+
// };
|
|
91
|
+
//
|
|
92
|
+
// return store;
|
|
93
|
+
// };
|
|
94
|
+
// /**
|
|
95
|
+
// * Create default metadata for backwards compatibility with items that don't
|
|
96
|
+
// * have stored metadata.
|
|
97
|
+
// */
|
|
98
|
+
// const createMetadata = (isSecure = true): SensitiveInfoItem["metadata"] => ({
|
|
99
|
+
// backend: "keychain",
|
|
100
|
+
// accessControl: isSecure ? "biometryCurrentSet" : "none",
|
|
101
|
+
// securityLevel: isSecure ? "biometry" : "software",
|
|
102
|
+
// timestamp: Date.now(),
|
|
103
|
+
// });
|
|
104
|
+
//
|
|
105
|
+
// const convertOptions = (
|
|
106
|
+
// options?: LocalAuthOptions,
|
|
107
|
+
// ): SecureStore.SecureStoreOptions => {
|
|
108
|
+
// const accessGroup =
|
|
109
|
+
// options?.keychainGroup ?? localAuthDefaultOptions.keychainGroup ?? "";
|
|
110
|
+
// const keychainService =
|
|
111
|
+
// options?.service ?? localAuthDefaultOptions.service ?? "";
|
|
112
|
+
// const keychainAccessible = convertKeychainAccessible(
|
|
113
|
+
// options?.accessControl ??
|
|
114
|
+
// localAuthDefaultOptions.accessControl ??
|
|
115
|
+
// "biometryCurrentSet",
|
|
116
|
+
// );
|
|
117
|
+
// const authenticationPrompt =
|
|
118
|
+
// options?.authenticationPrompt?.title ??
|
|
119
|
+
// localAuthDefaultOptions.authenticationPrompt?.title ??
|
|
120
|
+
// "";
|
|
121
|
+
// return {
|
|
122
|
+
// accessGroup,
|
|
123
|
+
// keychainService,
|
|
124
|
+
// keychainAccessible,
|
|
125
|
+
// authenticationPrompt,
|
|
126
|
+
// requireAuthentication: options?.accessControl !== "none",
|
|
127
|
+
// };
|
|
128
|
+
// };
|
|
129
|
+
//
|
|
130
|
+
// const convertKeychainAccessible = (
|
|
131
|
+
// accessControl: AccessControl,
|
|
132
|
+
// ): SecureStore.KeychainAccessibilityConstant => {
|
|
133
|
+
// switch (accessControl) {
|
|
134
|
+
// case "none":
|
|
135
|
+
// // eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
136
|
+
// return SecureStore.ALWAYS;
|
|
137
|
+
// case "biometryCurrentSet":
|
|
138
|
+
// return SecureStore.AFTER_FIRST_UNLOCK;
|
|
139
|
+
// case "biometryAny":
|
|
140
|
+
// return SecureStore.AFTER_FIRST_UNLOCK;
|
|
141
|
+
// case "devicePasscode":
|
|
142
|
+
// return SecureStore.AFTER_FIRST_UNLOCK;
|
|
143
|
+
// case "secureEnclaveBiometry":
|
|
144
|
+
// return SecureStore.AFTER_FIRST_UNLOCK;
|
|
145
|
+
// // Exhaustive check
|
|
146
|
+
// default:
|
|
147
|
+
// accessControl satisfies never;
|
|
148
|
+
// // Default (for typescript, should never hit)
|
|
149
|
+
// return SecureStore.AFTER_FIRST_UNLOCK;
|
|
150
|
+
// }
|
|
151
|
+
// };
|
|
152
|
+
//
|
|
153
|
+
// const localAuth = createSharedLocalAuth(createSecureStore());
|
|
154
|
+
//
|
|
155
|
+
// export const createExpoDeps = (
|
|
156
|
+
// deps: CreateSqliteDriverDep,
|
|
157
|
+
// ): { evoluReactNativeDeps: EvoluDeps; localAuth: LocalAuth } => ({
|
|
158
|
+
// evoluReactNativeDeps: createSharedEvoluDeps({
|
|
159
|
+
// ...deps,
|
|
160
|
+
// reloadApp,
|
|
161
|
+
// }),
|
|
162
|
+
// localAuth,
|
|
163
|
+
// });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=bare-op-sqlite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bare-op-sqlite.d.ts","sourceRoot":"","sources":["../../../src/exports/bare-op-sqlite.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// /**
|
|
3
|
+
// * Public entry point for bare React Native with OP-SQLite. Exported as
|
|
4
|
+
// * "@evolu/react-native/bare-op-sqlite" in package.json.
|
|
5
|
+
// *
|
|
6
|
+
// * Use this with bare React Native projects (not Expo) that use
|
|
7
|
+
// * `@op-engineering/op-sqlite`.
|
|
8
|
+
// */
|
|
9
|
+
//
|
|
10
|
+
// import { type ReloadApp } from "@evolu/common";
|
|
11
|
+
// import { DevSettings } from "react-native";
|
|
12
|
+
// import { SensitiveInfo } from "react-native-sensitive-info";
|
|
13
|
+
// import { createSharedEvoluDeps, createSharedLocalAuth } from "../shared.js";
|
|
14
|
+
// import { createOpSqliteDriver } from "../sqlite-drivers/createOpSqliteDriver.js";
|
|
15
|
+
//
|
|
16
|
+
// const reloadApp: ReloadApp = () => {
|
|
17
|
+
// if (process.env.NODE_ENV === "development") {
|
|
18
|
+
// DevSettings.reload();
|
|
19
|
+
// } else {
|
|
20
|
+
// // TODO: reload not implemented for bare rn
|
|
21
|
+
// }
|
|
22
|
+
// };
|
|
23
|
+
//
|
|
24
|
+
// // eslint-disable-next-line evolu/require-pure-annotation
|
|
25
|
+
// export const evoluReactNativeDeps = createSharedEvoluDeps({
|
|
26
|
+
// createSqliteDriver: createOpSqliteDriver,
|
|
27
|
+
// reloadApp,
|
|
28
|
+
// });
|
|
29
|
+
//
|
|
30
|
+
// // eslint-disable-next-line evolu/require-pure-annotation
|
|
31
|
+
// export const localAuth = createSharedLocalAuth(SensitiveInfo);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=expo-op-sqlite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expo-op-sqlite.d.ts","sourceRoot":"","sources":["../../../src/exports/expo-op-sqlite.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// /**
|
|
3
|
+
// * Public entry point for Expo with OP-SQLite. Exported as
|
|
4
|
+
// * "@evolu/react-native/expo-op-sqlite" in package.json.
|
|
5
|
+
// *
|
|
6
|
+
// * Use this with Expo projects that use `@op-engineering/op-sqlite` for better
|
|
7
|
+
// * performance.
|
|
8
|
+
// */
|
|
9
|
+
//
|
|
10
|
+
// import { createExpoDeps } from "../createExpoDeps.js";
|
|
11
|
+
// import { createOpSqliteDriver } from "../sqlite-drivers/createOpSqliteDriver.js";
|
|
12
|
+
//
|
|
13
|
+
// // eslint-disable-next-line evolu/require-pure-annotation
|
|
14
|
+
// export const { evoluReactNativeDeps, localAuth } = createExpoDeps({
|
|
15
|
+
// createSqliteDriver: createOpSqliteDriver,
|
|
16
|
+
// });
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public entry point for Expo SQLite. Exported as
|
|
3
|
+
* "@evolu/react-native/expo-sqlite" in package.json.
|
|
4
|
+
*
|
|
5
|
+
* Use this with Expo projects that use expo-sqlite.
|
|
6
|
+
*/
|
|
7
|
+
import type { ConsoleDep } from "@evolu/common";
|
|
8
|
+
import type { EvoluDeps } from "@evolu/common/local-first";
|
|
9
|
+
/** Creates Evolu dependencies for Expo. */
|
|
10
|
+
export declare const createEvoluDeps: (deps?: Partial<ConsoleDep>) => EvoluDeps;
|
|
11
|
+
//# sourceMappingURL=expo-sqlite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expo-sqlite.d.ts","sourceRoot":"","sources":["../../../src/exports/expo-sqlite.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAK3D,2CAA2C;AAC3C,eAAO,MAAM,eAAe,GAAI,OAAM,OAAO,CAAC,UAAU,CAAM,KAAG,SAO7D,CAAC"}
|