@evolu/react-native 15.0.0-next.2 → 15.0.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.
@@ -56,6 +56,7 @@ const abortReasonBySignal = new WeakMap();
56
56
  const anyControllersBySignal = new WeakMap();
57
57
  const installAbortControllerPolyfills = () => {
58
58
  installAbortReasonPolyfill(globalThis.AbortController, globalThis.AbortSignal);
59
+ installAbortSignalThrowIfAbortedPolyfill(globalThis.AbortSignal);
59
60
  installAbortSignalStaticMethods(globalThis.AbortController, globalThis.AbortSignal);
60
61
  };
61
62
  const installAbortReasonPolyfill = (abortController, abortSignal) => {
@@ -84,6 +85,19 @@ const installAbortReasonPolyfill = (abortController, abortSignal) => {
84
85
  writable: false,
85
86
  });
86
87
  };
88
+ const installAbortSignalThrowIfAbortedPolyfill = (abortSignal) => {
89
+ if (typeof abortSignal.prototype.throwIfAborted === "function")
90
+ return;
91
+ Object.defineProperty(abortSignal.prototype, "throwIfAborted", {
92
+ configurable: true,
93
+ enumerable: false,
94
+ writable: true,
95
+ value() {
96
+ if (this.aborted)
97
+ throw this.reason;
98
+ },
99
+ });
100
+ };
87
101
  const installAbortSignalStaticMethods = (abortController, abortSignal) => {
88
102
  if (typeof abortSignal.abort !== "function") {
89
103
  Object.defineProperty(abortSignal, "abort", {
@@ -3,12 +3,13 @@
3
3
  *
4
4
  * @module
5
5
  */
6
- import { type CreateRun, type RunDefaultDeps } from "@evolu/common";
6
+ import { type DisposableRun, type RunCustomDeps } from "@evolu/common";
7
7
  /**
8
- * Creates {@link Run} for React Native with global error handling.
8
+ * Creates a root {@link Run} for React Native.
9
9
  *
10
- * Registers `ErrorUtils.setGlobalHandler` for uncaught JavaScript errors. The
11
- * handler is restored to the previous one when the Run is disposed.
10
+ * Defects are reported with React Native's global `ErrorUtils.reportError`. A
11
+ * custom `reportDefect` dependency overrides the React Native default. The
12
+ * platform-independent microtask reporter is used when `ErrorUtils` is absent.
12
13
  *
13
14
  * ### Example
14
15
  *
@@ -19,13 +20,10 @@ import { type CreateRun, type RunDefaultDeps } from "@evolu/common";
19
20
  * }),
20
21
  * });
21
22
  *
22
- * await using run = createRun({ console });
23
- * await using disposer = new AsyncDisposableStack();
24
- *
25
- * disposer.use(await run.orThrow(startApp()));
23
+ * const run = createRun({ console });
24
+ * const appPromise = run.ok(startApp());
26
25
  * ```
27
- *
28
- * @group React Native Run
29
26
  */
30
- export declare const createRun: CreateRun<RunDefaultDeps>;
27
+ export declare function createRun(): DisposableRun;
28
+ export declare function createRun<D extends object>(deps: RunCustomDeps<D>): DisposableRun<D>;
31
29
  //# sourceMappingURL=Task.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Task.d.ts","sourceRoot":"","sources":["../../src/Task.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAGL,KAAK,SAAS,EAEd,KAAK,cAAc,EACpB,MAAM,eAAe,CAAC;AAEvB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,SAAS,EAAE,SAAS,CAAC,cAAc,CA4B/C,CAAC"}
1
+ {"version":3,"file":"Task.d.ts","sourceRoot":"","sources":["../../src/Task.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAGL,KAAK,aAAa,EAElB,KAAK,aAAa,EACnB,MAAM,eAAe,CAAC;AAEvB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,SAAS,IAAI,aAAa,CAAC;AAC3C,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EACxC,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,GACrB,aAAa,CAAC,CAAC,CAAC,CAAC"}
package/dist/src/Task.js CHANGED
@@ -3,44 +3,15 @@
3
3
  *
4
4
  * @module
5
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 disposer = new AsyncDisposableStack();
24
- *
25
- * disposer.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);
6
+ import { createRun as createCommonRun, reportDefectAfterMicrotask, } from "@evolu/common";
7
+ export function createRun(deps) {
8
+ const reportDefect = (reported) => {
9
+ if (globalThis.ErrorUtils)
10
+ globalThis.ErrorUtils.reportError(reported);
11
+ else
12
+ reportDefectAfterMicrotask(reported);
38
13
  };
39
- globalThis.ErrorUtils?.setGlobalHandler(handleError);
40
- run.onAbort(() => {
41
- if (previousHandler) {
42
- globalThis.ErrorUtils?.setGlobalHandler(previousHandler);
43
- }
44
- });
45
- return run;
46
- };
14
+ return deps === undefined
15
+ ? createCommonRun({ reportDefect })
16
+ : createCommonRun({ reportDefect, ...deps });
17
+ }
@@ -16,7 +16,7 @@
16
16
  // import * as Expo from "expo";
17
17
  // import * as SecureStore from "expo-secure-store";
18
18
  // import KVStore from "expo-sqlite/kv-store";
19
- // import { createSharedEvoluDeps, createSharedLocalAuth } from "./shared.js";
19
+ // import { createSharedEvoluDeps, createSharedLocalAuth } from "./shared.ts";
20
20
  // const reloadApp: ReloadApp = () => {
21
21
  // void Expo.reloadAppAsync();
22
22
  // };
@@ -10,8 +10,8 @@
10
10
  // import { type ReloadApp } from "@evolu/common";
11
11
  // import { DevSettings } from "react-native";
12
12
  // import { SensitiveInfo } from "react-native-sensitive-info";
13
- // import { createSharedEvoluDeps, createSharedLocalAuth } from "../shared.js";
14
- // import { createOpSqliteDriver } from "../sqlite-drivers/createOpSqliteDriver.js";
13
+ // import { createSharedEvoluDeps, createSharedLocalAuth } from "../shared.ts";
14
+ // import { createOpSqliteDriver } from "../sqlite-drivers/createOpSqliteDriver.ts";
15
15
  //
16
16
  // const reloadApp: ReloadApp = () => {
17
17
  // if (process.env.NODE_ENV === "development") {
@@ -7,8 +7,8 @@
7
7
  // * performance.
8
8
  // */
9
9
  //
10
- // import { createExpoDeps } from "../createExpoDeps.js";
11
- // import { createOpSqliteDriver } from "../sqlite-drivers/createOpSqliteDriver.js";
10
+ // import { createExpoDeps } from "../createExpoDeps.ts";
11
+ // import { createOpSqliteDriver } from "../sqlite-drivers/createOpSqliteDriver.ts";
12
12
  //
13
13
  // // eslint-disable-next-line evolu/require-pure-annotation
14
14
  // export const { evoluReactNativeDeps, localAuth } = createExpoDeps({
@@ -1 +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"}
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,UAAU,OAAO,CAAC,UAAU,CAAC,KAAQ,SAO7D,CAAC"}
@@ -15,8 +15,8 @@ export const createEvoluDeps = (deps = {}) => createSharedEvoluDeps({
15
15
  void Expo.reloadAppAsync();
16
16
  },
17
17
  });
18
- // import { createExpoDeps } from "../createExpoDeps.js";
19
- // import { createExpoSqliteDriver } from "../sqlite-drivers/createExpoSqliteDriver.js";
18
+ // import { createExpoDeps } from "../createExpoDeps.ts";
19
+ // import { createExpoSqliteDriver } from "../sqlite-drivers/createExpoSqliteDriver.ts";
20
20
  //
21
21
  // // eslint-disable-next-line evolu/require-pure-annotation
22
22
  // export const { evoluReactNativeDeps, localAuth } = createExpoDeps({
@@ -1,4 +1,4 @@
1
- export * from "./components/EvoluIdenticon.js";
2
- export * from "./LockManager.js";
3
- export * from "./Task.js";
1
+ export * from "./components/EvoluIdenticon.tsx";
2
+ export * from "./LockManager.ts";
3
+ export * from "./Task.ts";
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAWL,KAAK,UAAU,EACf,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EAClB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAIV,SAAS,EAGV,MAAM,2BAA2B,CAAC;AAQnC,mDAAmD;AACnD,eAAO,MAAM,eAAe,GAC1B,MAAM,YAAY,GAAG,qBAAqB,GAAG,OAAO,CAAC,UAAU,CAAC,KAC/D,SA8CF,CAAC"}
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAYL,KAAK,UAAU,EACf,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EAClB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAIV,SAAS,EAGV,MAAM,2BAA2B,CAAC;AAQnC,mDAAmD;AACnD,eAAO,MAAM,eAAe,SACpB,YAAY,GAAG,qBAAqB,GAAG,OAAO,CAAC,UAAU,CAAC,KAC/D,SAiDF,CAAC"}
@@ -1,4 +1,56 @@
1
- import { createConsole, createConsoleStoreOutput, createBroadcastChannel, createMessageChannel, createMessagePort, createRandomBytes, createRun, createSharedWorker, createWebSocket, createWorker, } from "@evolu/common";
1
+ var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
2
+ if (value !== null && value !== void 0) {
3
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
4
+ var dispose, inner;
5
+ if (async) {
6
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
7
+ dispose = value[Symbol.asyncDispose];
8
+ }
9
+ if (dispose === void 0) {
10
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
11
+ dispose = value[Symbol.dispose];
12
+ if (async) inner = dispose;
13
+ }
14
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
15
+ if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
16
+ env.stack.push({ value: value, dispose: dispose, async: async });
17
+ }
18
+ else if (async) {
19
+ env.stack.push({ async: true });
20
+ }
21
+ return value;
22
+ };
23
+ var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
24
+ return function (env) {
25
+ function fail(e) {
26
+ env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
27
+ env.hasError = true;
28
+ }
29
+ var r, s = 0;
30
+ function next() {
31
+ while (r = env.stack.pop()) {
32
+ try {
33
+ if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
34
+ if (r.dispose) {
35
+ var result = r.dispose.call(r.value);
36
+ if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
37
+ }
38
+ else s |= 1;
39
+ }
40
+ catch (e) {
41
+ fail(e);
42
+ }
43
+ }
44
+ if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
45
+ if (env.hasError) throw env.error;
46
+ }
47
+ return next();
48
+ };
49
+ })(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
50
+ var e = new Error(message);
51
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
52
+ });
53
+ import { createConsole, createConsoleStoreOutput, createBroadcastChannel, createMessageChannel, createMessagePort, createRandomBytes, createRun, createSharedWorker, createWebSocket, createWorker, waitForAbort, } from "@evolu/common";
2
54
  import { createEvoluDeps as createCommonEvoluDeps, initSharedWorker, startDbWorker, } from "@evolu/common/local-first";
3
55
  import { lockManager } from "./LockManager.js";
4
56
  /** Creates Evolu dependencies for React Native. */
@@ -25,11 +77,26 @@ export const createEvoluDeps = (deps) => {
25
77
  };
26
78
  const createDbWorker = () => createWorker((self) => {
27
79
  const dbWorkerRun = createWorkerRun();
28
- dbWorkerRun(startDbWorker(self));
80
+ void dbWorkerRun(startDbWorker(self));
29
81
  });
30
82
  const sharedWorker = createSharedWorker((self) => {
31
83
  const sharedWorkerRun = createWorkerRun();
32
- sharedWorkerRun(initSharedWorker(self));
84
+ void sharedWorkerRun(async (run) => {
85
+ const env_1 = { stack: [], error: void 0, hasError: false };
86
+ try {
87
+ const _ = __addDisposableResource(env_1, await run.ok(initSharedWorker(self)), true);
88
+ return await run(waitForAbort);
89
+ }
90
+ catch (e_1) {
91
+ env_1.error = e_1;
92
+ env_1.hasError = true;
93
+ }
94
+ finally {
95
+ const result_1 = __disposeResources(env_1);
96
+ if (result_1)
97
+ await result_1;
98
+ }
99
+ });
33
100
  });
34
101
  return createCommonEvoluDeps({
35
102
  ...deps,
@@ -1 +1 @@
1
- {"version":3,"file":"createOpSqliteDriver.d.ts","sourceRoot":"","sources":["../../../src/sqlite-drivers/createOpSqliteDriver.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,kBAAkB,EAIxB,MAAM,eAAe,CAAC;AAGvB,eAAO,MAAM,oBAAoB,EAAE,kBAiEhC,CAAC"}
1
+ {"version":3,"file":"createOpSqliteDriver.d.ts","sourceRoot":"","sources":["../../../src/sqlite-drivers/createOpSqliteDriver.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,kBAAkB,EAGxB,MAAM,eAAe,CAAC;AAGvB,eAAO,MAAM,oBAAoB,EAAE,kBAiEhC,CAAC"}
@@ -50,7 +50,7 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
50
50
  var e = new Error(message);
51
51
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
52
52
  });
53
- import { bytesToHex, createPreparedStatementsCache, lazyVoid, ok, } from "@evolu/common";
53
+ import { constVoid, bytesToHex, createPreparedStatementsCache, ok, } from "@evolu/common";
54
54
  import { open } from "@op-engineering/op-sqlite";
55
55
  export const createOpSqliteDriver = (name, options) => () => {
56
56
  const env_1 = { stack: [], error: void 0, hasError: false };
@@ -69,7 +69,7 @@ export const createOpSqliteDriver = (name, options) => () => {
69
69
  });
70
70
  const cache = disposer.use(createPreparedStatementsCache((sql) => db.prepareStatement(sql),
71
71
  // op-sqlite doesn't have API for that
72
- lazyVoid));
72
+ constVoid));
73
73
  const disposables = disposer.move();
74
74
  return ok({
75
75
  exec: (query) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evolu/react-native",
3
- "version": "15.0.0-next.2",
3
+ "version": "15.0.1",
4
4
  "description": "Evolu for React Native and Expo",
5
5
  "keywords": [
6
6
  "evolu",
@@ -89,24 +89,29 @@
89
89
  "set.prototype.union": "^1.1.3"
90
90
  },
91
91
  "devDependencies": {
92
- "@op-engineering/op-sqlite": "^15.2.2",
93
- "@types/react": "^19.2.14",
94
- "expo": "^55.0.4",
95
- "expo-secure-store": "~55.0.8",
96
- "expo-sqlite": "~55.0.10",
97
- "react": "^19.2.4",
98
- "react-native": "0.83.6",
99
- "react-native-nitro-modules": "0.34.1",
100
- "react-native-sensitive-info": "6.0.0-rc.11",
101
- "react-native-svg": "15.15.3",
102
- "typescript": "^6",
103
- "@evolu/common": "8.0.0-next.5",
104
- "@evolu/react": "11.0.0-next.0",
92
+ "@expo/dom-webview": "~57.0.0",
93
+ "@op-engineering/op-sqlite": "^17.1.3",
94
+ "@react-native/metro-config": "0.86.2",
95
+ "@types/react": "^19.2.18",
96
+ "@typescript/native": "npm:typescript@^7.0.2",
97
+ "expo": "~57.0.9",
98
+ "expo-secure-store": "~57.0.0",
99
+ "expo-sqlite": "~57.0.0",
100
+ "react": "19.2.3",
101
+ "react-native": "0.86.2",
102
+ "react-native-nitro-modules": "0.36.5",
103
+ "react-native-reanimated": "4.5.1",
104
+ "react-native-sensitive-info": "6.1.5",
105
+ "react-native-svg": "15.15.4",
106
+ "react-native-worklets": "0.10.1",
107
+ "typescript": "npm:@typescript/typescript6@^6.0.2",
108
+ "@evolu/common": "8.1.0",
109
+ "@evolu/react": "11.0.1",
105
110
  "@evolu/typescript-config": "0.0.2"
106
111
  },
107
112
  "peerDependencies": {
108
- "@evolu/common": "^8.0.0-next.0",
109
- "@evolu/react": "^11.0.0-next.0",
113
+ "@evolu/common": "^8.0.0",
114
+ "@evolu/react": "^11.0.0",
110
115
  "@op-engineering/op-sqlite": ">=12",
111
116
  "expo": ">=55",
112
117
  "expo-secure-store": ">=55",
@@ -6,6 +6,7 @@
6
6
  */
7
7
  interface ErrorUtils {
8
8
  getGlobalHandler: () => ((error: unknown, isFatal?: boolean) => void) | null;
9
+ reportError: (error: unknown) => void;
9
10
  setGlobalHandler: (
10
11
  handler: (error: unknown, isFatal?: boolean) => void,
11
12
  ) => void;
package/src/Polyfills.ts CHANGED
@@ -98,6 +98,7 @@ const installAbortControllerPolyfills = (): void => {
98
98
  globalThis.AbortController,
99
99
  globalThis.AbortSignal,
100
100
  );
101
+ installAbortSignalThrowIfAbortedPolyfill(globalThis.AbortSignal);
101
102
  installAbortSignalStaticMethods(
102
103
  globalThis.AbortController,
103
104
  globalThis.AbortSignal,
@@ -136,6 +137,21 @@ const installAbortReasonPolyfill = (
136
137
  });
137
138
  };
138
139
 
140
+ const installAbortSignalThrowIfAbortedPolyfill = (
141
+ abortSignal: AbortSignalConstructor,
142
+ ): void => {
143
+ if (typeof abortSignal.prototype.throwIfAborted === "function") return;
144
+
145
+ Object.defineProperty(abortSignal.prototype, "throwIfAborted", {
146
+ configurable: true,
147
+ enumerable: false,
148
+ writable: true,
149
+ value(this: AbortSignal): void {
150
+ if (this.aborted) throw this.reason;
151
+ },
152
+ });
153
+ };
154
+
139
155
  const installAbortSignalStaticMethods = (
140
156
  abortController: AbortControllerConstructor,
141
157
  abortSignal: AbortSignalConstructor,
package/src/Task.ts CHANGED
@@ -6,17 +6,18 @@
6
6
 
7
7
  import {
8
8
  createRun as createCommonRun,
9
- createUnknownError,
10
- type CreateRun,
9
+ reportDefectAfterMicrotask,
10
+ type DisposableRun,
11
11
  type Run,
12
- type RunDefaultDeps,
12
+ type RunCustomDeps,
13
13
  } from "@evolu/common";
14
14
 
15
15
  /**
16
- * Creates {@link Run} for React Native with global error handling.
16
+ * Creates a root {@link Run} for React Native.
17
17
  *
18
- * Registers `ErrorUtils.setGlobalHandler` for uncaught JavaScript errors. The
19
- * handler is restored to the previous one when the Run is disposed.
18
+ * Defects are reported with React Native's global `ErrorUtils.reportError`. A
19
+ * custom `reportDefect` dependency overrides the React Native default. The
20
+ * platform-independent microtask reporter is used when `ErrorUtils` is absent.
20
21
  *
21
22
  * ### Example
22
23
  *
@@ -27,40 +28,23 @@ import {
27
28
  * }),
28
29
  * });
29
30
  *
30
- * await using run = createRun({ console });
31
- * await using disposer = new AsyncDisposableStack();
32
- *
33
- * disposer.use(await run.orThrow(startApp()));
31
+ * const run = createRun({ console });
32
+ * const appPromise = run.ok(startApp());
34
33
  * ```
35
- *
36
- * @group React Native Run
37
34
  */
38
- export const createRun: CreateRun<RunDefaultDeps> = <D>(
39
- deps?: D,
40
- ): Run<RunDefaultDeps & D> => {
41
- const run = createCommonRun(deps);
42
-
43
- const console = run.deps.console.child("global");
44
-
45
- const previousHandler = globalThis.ErrorUtils?.getGlobalHandler();
46
-
47
- const handleError = (error: unknown, isFatal?: boolean) => {
48
- console.error(
49
- isFatal ? "fatalError" : "uncaughtError",
50
- createUnknownError(error),
51
- );
52
-
53
- // Call the previous handler if it exists
54
- previousHandler?.(error, isFatal);
35
+ export function createRun(): DisposableRun;
36
+ export function createRun<D extends object>(
37
+ deps: RunCustomDeps<D>,
38
+ ): DisposableRun<D>;
39
+ export function createRun<D extends object>(
40
+ deps?: RunCustomDeps<D>,
41
+ ): DisposableRun | DisposableRun<D> {
42
+ const reportDefect = (reported: unknown): void => {
43
+ if (globalThis.ErrorUtils) globalThis.ErrorUtils.reportError(reported);
44
+ else reportDefectAfterMicrotask(reported);
55
45
  };
56
46
 
57
- globalThis.ErrorUtils?.setGlobalHandler(handleError);
58
-
59
- run.onAbort(() => {
60
- if (previousHandler) {
61
- globalThis.ErrorUtils?.setGlobalHandler(previousHandler);
62
- }
63
- });
64
-
65
- return run;
66
- };
47
+ return deps === undefined
48
+ ? createCommonRun({ reportDefect })
49
+ : createCommonRun<D>({ reportDefect, ...deps });
50
+ }
@@ -15,7 +15,7 @@
15
15
  // import * as Expo from "expo";
16
16
  // import * as SecureStore from "expo-secure-store";
17
17
  // import KVStore from "expo-sqlite/kv-store";
18
- // import { createSharedEvoluDeps, createSharedLocalAuth } from "./shared.js";
18
+ // import { createSharedEvoluDeps, createSharedLocalAuth } from "./shared.ts";
19
19
 
20
20
  // const reloadApp: ReloadApp = () => {
21
21
  // void Expo.reloadAppAsync();
@@ -9,8 +9,8 @@
9
9
  // import { type ReloadApp } from "@evolu/common";
10
10
  // import { DevSettings } from "react-native";
11
11
  // import { SensitiveInfo } from "react-native-sensitive-info";
12
- // import { createSharedEvoluDeps, createSharedLocalAuth } from "../shared.js";
13
- // import { createOpSqliteDriver } from "../sqlite-drivers/createOpSqliteDriver.js";
12
+ // import { createSharedEvoluDeps, createSharedLocalAuth } from "../shared.ts";
13
+ // import { createOpSqliteDriver } from "../sqlite-drivers/createOpSqliteDriver.ts";
14
14
  //
15
15
  // const reloadApp: ReloadApp = () => {
16
16
  // if (process.env.NODE_ENV === "development") {
@@ -6,8 +6,8 @@
6
6
  // * performance.
7
7
  // */
8
8
  //
9
- // import { createExpoDeps } from "../createExpoDeps.js";
10
- // import { createOpSqliteDriver } from "../sqlite-drivers/createOpSqliteDriver.js";
9
+ // import { createExpoDeps } from "../createExpoDeps.ts";
10
+ // import { createOpSqliteDriver } from "../sqlite-drivers/createOpSqliteDriver.ts";
11
11
  //
12
12
  // // eslint-disable-next-line evolu/require-pure-annotation
13
13
  // export const { evoluReactNativeDeps, localAuth } = createExpoDeps({
@@ -8,8 +8,8 @@
8
8
  import type { ConsoleDep } from "@evolu/common";
9
9
  import type { EvoluDeps } from "@evolu/common/local-first";
10
10
  import * as Expo from "expo";
11
- import { createEvoluDeps as createSharedEvoluDeps } from "../shared.js";
12
- import { createExpoSqliteDriver } from "../sqlite-drivers/createExpoSqliteDriver.js";
11
+ import { createEvoluDeps as createSharedEvoluDeps } from "../shared.ts";
12
+ import { createExpoSqliteDriver } from "../sqlite-drivers/createExpoSqliteDriver.ts";
13
13
 
14
14
  /** Creates Evolu dependencies for Expo. */
15
15
  export const createEvoluDeps = (deps: Partial<ConsoleDep> = {}): EvoluDeps =>
@@ -21,8 +21,8 @@ export const createEvoluDeps = (deps: Partial<ConsoleDep> = {}): EvoluDeps =>
21
21
  },
22
22
  });
23
23
 
24
- // import { createExpoDeps } from "../createExpoDeps.js";
25
- // import { createExpoSqliteDriver } from "../sqlite-drivers/createExpoSqliteDriver.js";
24
+ // import { createExpoDeps } from "../createExpoDeps.ts";
25
+ // import { createExpoSqliteDriver } from "../sqlite-drivers/createExpoSqliteDriver.ts";
26
26
  //
27
27
  // // eslint-disable-next-line evolu/require-pure-annotation
28
28
  // export const { evoluReactNativeDeps, localAuth } = createExpoDeps({
package/src/index.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from "./components/EvoluIdenticon.js";
2
- export * from "./LockManager.js";
3
- export * from "./Task.js";
1
+ export * from "./components/EvoluIdenticon.tsx";
2
+ export * from "./LockManager.ts";
3
+ export * from "./Task.ts";
package/src/shared.ts CHANGED
@@ -9,6 +9,7 @@ import {
9
9
  createSharedWorker,
10
10
  createWebSocket,
11
11
  createWorker,
12
+ waitForAbort,
12
13
  type ConsoleDep,
13
14
  type CreateSqliteDriverDep,
14
15
  type ReloadAppDep,
@@ -26,7 +27,7 @@ import {
26
27
  initSharedWorker,
27
28
  startDbWorker,
28
29
  } from "@evolu/common/local-first";
29
- import { lockManager } from "./LockManager.js";
30
+ import { lockManager } from "./LockManager.ts";
30
31
 
31
32
  /** Creates Evolu dependencies for React Native. */
32
33
  export const createEvoluDeps = (
@@ -57,7 +58,7 @@ export const createEvoluDeps = (
57
58
  const createDbWorker: CreateDbWorker = (): DbWorker =>
58
59
  createWorker<DbWorkerInit, never>((self) => {
59
60
  const dbWorkerRun = createWorkerRun();
60
- dbWorkerRun(startDbWorker(self));
61
+ void dbWorkerRun(startDbWorker(self));
61
62
  });
62
63
 
63
64
  const sharedWorker = createSharedWorker<
@@ -65,7 +66,10 @@ export const createEvoluDeps = (
65
66
  SharedWorkerOutput
66
67
  >((self) => {
67
68
  const sharedWorkerRun = createWorkerRun();
68
- sharedWorkerRun(initSharedWorker(self));
69
+ void sharedWorkerRun(async (run) => {
70
+ await using _ = await run.ok(initSharedWorker(self));
71
+ return await run(waitForAbort);
72
+ });
69
73
  });
70
74
 
71
75
  return createCommonEvoluDeps({
@@ -1,8 +1,8 @@
1
1
  import {
2
+ constVoid,
2
3
  bytesToHex,
3
4
  createPreparedStatementsCache,
4
5
  type CreateSqliteDriver,
5
- lazyVoid,
6
6
  ok,
7
7
  type SqliteRow,
8
8
  } from "@evolu/common";
@@ -32,7 +32,7 @@ export const createOpSqliteDriver: CreateSqliteDriver =
32
32
  createPreparedStatementsCache<PreparedStatement>(
33
33
  (sql) => db.prepareStatement(sql),
34
34
  // op-sqlite doesn't have API for that
35
- lazyVoid,
35
+ constVoid,
36
36
  ),
37
37
  );
38
38