@party-stack/expo-runtime 0.7.2 → 1.0.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 CHANGED
@@ -1,6 +1,8 @@
1
1
  # Expo runtime
2
2
 
3
- This runtime targets Expo SDK 57. Install `@party-stack/expo-runtime` and its Expo peer dependencies using SDK 57-compatible versions. Use Expo's installed native fetch; no separate `expo-fetch` package or fetch installer is needed. The runtime includes `expo-blob`.
3
+ This runtime targets Expo SDK 57. Install `@party-stack/expo-runtime` and its Expo peer dependencies using SDK 57-compatible versions. Use Expo's installed native fetch; no separate `expo-fetch` package or fetch installer is needed. Persistent storage uses the Effect React Native SQLite adapter and OP-SQLite. The tested worker configuration uses Effect 4.1.4, `@effect/sql-sqlite-react-native@4.1.4`, and `@op-engineering/op-sqlite@18.2.5`. Install compatible peers and rebuild the app. Replicas reopen in the existing document directory under `SQLite/` with the same partition filenames. The runtime includes `expo-blob`.
4
+
5
+ The adapter imports OP-SQLite as a native peer. Install it directly in the Expo app so autolinking includes it in the binary. Choose a version allowed by the installed adapter and pin `18.2.5` for the worker patch. This repository builds and unit-tests against Effect and adapter `4.0.5` with OP-SQLite `17.1.2`. Adapter `4.0.5` requires OP-SQLite 17.x, while adapter `4.1.4` also accepts 18.x.
4
6
 
5
7
  Import the required polyfill first in your application entry point, before importing application code or creating clients:
6
8
 
@@ -24,6 +26,14 @@ SQLite, creating filesystem directories, or accessing SecureStore. This is usefu
24
26
  `AuthenticationProvider` and a memory UI replica that needs Expo's platform capabilities.
25
27
  Both modes acquire partitions lazily and release their NetInfo listeners with the scope.
26
28
 
29
+ ### Serve a replica from a worker
30
+
31
+ `expoRuntime()` builds storage in the JS runtime that calls it. To move the durable replica off the UI thread, define a worker entry that imports `@party-stack/expo-runtime/worker/bootstrap` and calls `serveOntologyWorker({ owner, runtime, open })` from `@party-stack/expo-runtime/worker`. The runner acquires the SQLite writer lease before invoking the app’s server factory. Opening replica databases and deleting partitions are internal operations.
32
+
33
+ In the UI, pass `workerClient(() => new ExpoWorker(new URL("./issues.worker.ts", import.meta.url)))` and `expoRuntime({ storage: "memory" })` to the provider. For an app-owned session, pass `workerClient(session.port)` and close the session when its callers finish. The [Expo guide](../../apps/website/content/docs/expo.mdx#run-a-dedicated-worker) includes both entries, the server factory, the Android NetInfo configuration and the Metro setup.
34
+
35
+ ### Serve a replica in the app runtime
36
+
27
37
  For a durable parent plus a memory UI replica, build this layer in the application's Effect scope, provide its context while constructing the ontology server, then connect with `localClient(server)` from `@party-stack/ontology/local`. Use `expoRuntime({ storage: "memory" })` for React views that need Expo's native browser authentication without persistent UI storage. The [Expo guide](../../apps/website/content/docs/expo.mdx) shows Connect sign-in, saved Foundry accounts, ontology selection, object browsing, and background checkpoints through one shared device owner. Passing the default persistent runtime directly to `OntologyProvider` or `createLiveOntology` instead creates one persistent UI replica.
28
38
 
29
39
  The polyfill replaces global `Blob` with Expo Blob and global `File` with a compatible class extending Expo Blob. It also supplies secure native randomness when the host lacks it and leaves Expo’s installed fetch unchanged. Import it once at startup; it is a separate entry point so importing the runtime alone does not replace Blob or File. Attachment uploads use Expo’s default fetch; do not opt back into React Native fetch with `EXPO_PUBLIC_USE_RN_FETCH`.
@@ -61,9 +71,9 @@ Add the config plugin when using Expo prebuild/CNG:
61
71
  ```
62
72
 
63
73
  The separate CommonJS entry runs in Expo's build process and does not load React
64
- Native or the runtime. It composes the SDK's SecureStore and SQLite plugins.
74
+ Native or the runtime. It configures SecureStore and foreground Location.
65
75
  SecureStore supplies Android backup exclusions for entries whose device keys
66
- cannot be restored. SQLite's native configuration stays at SDK defaults.
76
+ cannot be restored.
67
77
  No Face ID permission description is added, and an existing application-provided
68
78
  description is preserved. WebBrowser's default plugin adds no configuration, so
69
79
  it is not included; the experimental Android launcher activity stays disabled.
@@ -77,7 +87,7 @@ the iOS "when in use" purpose string (keeping yours, or pass
77
87
  ## Device location
78
88
 
79
89
  `Runtime.geolocation` (and `Runtimes.geolocation`) reads the device location through
80
- expo-location. Permission is requested the first time it is used. Failures are a
90
+ expo-location. The native module loads and requests permission on first use. Failures are a
81
91
  `GeolocationError` whose `reason` is `PermissionDenied`, `PositionUnavailable` or
82
92
  `Timeout`; without a fresh fix it falls back to one at most five minutes old. Pass
83
93
  `geolocation: false` to `expoRuntime` to leave it out. The web runtime provides the
@@ -1 +1 @@
1
- {"version":3,"file":"createExpoGeolocation.d.ts","names":[],"sources":["../src/createExpoGeolocation.ts"],"mappings":";;UAKU;WACG;aACI;aACA;aACA;aACA;aACA;aACA;aACA;;WAEJ;;;iBAII;WACJ,yCAAyC;aAAmB;;WAC5D,0BAA0B;IAAY;QAAwB,QAAQ;WACtE,4BAA4B;IACjC;IACA;QACE,QAAQ;WACL,qBACL;IAAW;KACX,WAAW,UAAU,6BACrB,gBAAgB,4BACf;IAAU;;WACN;aAAqB;aAA2B;;;;wBAuB7C,sBAAsB,WAAU,qBAAoC"}
1
+ {"version":3,"file":"createExpoGeolocation.d.ts","names":[],"sources":["../src/createExpoGeolocation.ts"],"mappings":";;UAIU;WACG;aACI;aACA;aACA;aACA;aACA;aACA;aACA;;WAEJ;;;iBAII;WACJ,yCAAyC;aAAmB;;WAC5D,0BAA0B;IAAY;QAAwB,QAAQ;WACtE,4BAA4B;IACjC;IACA;QACE,QAAQ;WACL,qBACL;IAAW;KACX,WAAW,UAAU,6BACrB,gBAAgB,4BACf;IAAU;;WACN;aAAqB;aAA2B;;;;wBAuB7C,sBAAsB,WAAW,qBAAqB"}
@@ -1,6 +1,5 @@
1
1
  import { GeolocationError } from "@party-stack/runtime";
2
2
  import { Cause, Effect, Option, Queue, Stream } from "effect";
3
- import * as ExpoLocation from "expo-location";
4
3
  //#region src/createExpoGeolocation.ts
5
4
  /** A recent cached fix is better than failing when GPS can't produce a new one. */
6
5
  const lastKnownMaxAgeMs = 3e5;
@@ -23,7 +22,17 @@ const toPosition = ({ coords, timestamp }) => ({
23
22
  timestamp
24
23
  });
25
24
  /** Device location through expo-location, with the web API's options and reasons. */
26
- function createExpoGeolocation(location = ExpoLocation) {
25
+ function createExpoGeolocation(location) {
26
+ if (!location) {
27
+ const native = Effect.tryPromise({
28
+ try: () => import("expo-location"),
29
+ catch: (cause) => fail("PositionUnavailable", "Could not load device location.", cause)
30
+ }).pipe(Effect.map((module) => createExpoGeolocation(module)));
31
+ return {
32
+ getCurrentPosition: (options) => Effect.flatMap(native, (service) => service.getCurrentPosition(options)),
33
+ watchPosition: (options) => Stream.unwrap(Effect.map(native, (service) => service.watchPosition(options)))
34
+ };
35
+ }
27
36
  const permitted = Effect.tryPromise({
28
37
  try: () => location.requestForegroundPermissionsAsync(),
29
38
  catch: (cause) => fail("PermissionDenied", "Location permission could not be requested.", cause)
@@ -1 +1 @@
1
- {"version":3,"file":"createExpoGeolocation.js","names":[],"sources":["../src/createExpoGeolocation.ts"],"sourcesContent":["import { GeolocationError } from \"@party-stack/runtime\";\nimport { Cause, Effect, Option, Queue, Stream } from \"effect\";\nimport * as ExpoLocation from \"expo-location\";\nimport type { Geolocation, GeolocationOptions, GeolocationPosition } from \"@party-stack/runtime\";\n\ninterface ExpoLocationObject {\n readonly coords: {\n readonly latitude: number;\n readonly longitude: number;\n readonly accuracy: number | null;\n readonly altitude: number | null;\n readonly altitudeAccuracy: number | null;\n readonly heading: number | null;\n readonly speed: number | null;\n };\n readonly timestamp: number;\n}\n\n/** The parts of `expo-location` this uses; tests pass a fake. */\nexport interface ExpoLocationModule {\n readonly requestForegroundPermissionsAsync: () => Promise<{ readonly status: string }>;\n readonly getCurrentPositionAsync: (options?: { accuracy?: number }) => Promise<ExpoLocationObject>;\n readonly getLastKnownPositionAsync: (options?: {\n maxAge?: number;\n requiredAccuracy?: number;\n }) => Promise<ExpoLocationObject | null>;\n readonly watchPositionAsync: (\n options: { accuracy?: number },\n callback: (location: ExpoLocationObject) => void,\n errorHandler?: (reason: string) => void\n ) => Promise<{ remove(): void }>;\n readonly Accuracy: { readonly Balanced: number; readonly High: number };\n}\n\n/** A recent cached fix is better than failing when GPS can't produce a new one. */\nconst lastKnownMaxAgeMs = 5 * 60_000;\nconst lastKnownRequiredAccuracyM = 1_000;\n\nconst fail = (reason: GeolocationError[\"reason\"], message: string, cause?: unknown) =>\n new GeolocationError({ reason, message, cause });\nconst toPosition = ({ coords, timestamp }: ExpoLocationObject): GeolocationPosition => ({\n coords: {\n latitude: coords.latitude,\n longitude: coords.longitude,\n accuracy: coords.accuracy ?? 0,\n altitude: coords.altitude,\n altitudeAccuracy: coords.altitudeAccuracy,\n heading: coords.heading,\n speed: coords.speed,\n },\n timestamp,\n});\n\n/** Device location through expo-location, with the web API's options and reasons. */\nexport function createExpoGeolocation(location: ExpoLocationModule = ExpoLocation): Geolocation {\n const permitted = Effect.tryPromise({\n try: () => location.requestForegroundPermissionsAsync(),\n catch: (cause) => fail(\"PermissionDenied\", \"Location permission could not be requested.\", cause),\n }).pipe(\n Effect.flatMap((permission) =>\n permission.status === \"granted\"\n ? Effect.void\n : Effect.fail(fail(\"PermissionDenied\", \"Location permission was denied.\"))\n )\n );\n const accuracy = (options?: GeolocationOptions) =>\n options?.enableHighAccuracy ? location.Accuracy.High : location.Accuracy.Balanced;\n const lastKnown = (options?: GeolocationOptions) =>\n Effect.tryPromise(() =>\n location.getLastKnownPositionAsync({\n maxAge: options?.maximumAge ?? lastKnownMaxAgeMs,\n requiredAccuracy: lastKnownRequiredAccuracyM,\n })\n ).pipe(\n Effect.map((value) => Option.fromNullishOr(value)),\n Effect.orElseSucceed(() => Option.none<ExpoLocationObject>())\n );\n return {\n getCurrentPosition: (options) =>\n Effect.gen(function* () {\n yield* permitted;\n const current = Effect.tryPromise({\n try: () => location.getCurrentPositionAsync({ accuracy: accuracy(options) }),\n catch: (cause) =>\n fail(\"PositionUnavailable\", \"Your location isn't available right now.\", cause),\n });\n const timeout = options?.timeout;\n const result = yield* Effect.result(\n timeout !== undefined && Number.isFinite(timeout)\n ? current.pipe(\n Effect.timeoutOrElse({\n duration: timeout,\n orElse: () =>\n Effect.fail(fail(\"Timeout\", \"Finding your location timed out.\")),\n })\n )\n : current\n );\n if (result._tag === \"Success\") return toPosition(result.success);\n const cached = yield* lastKnown(options);\n if (Option.isSome(cached)) return toPosition(cached.value);\n return yield* result.failure;\n }),\n watchPosition: (options) =>\n Stream.unwrap(\n Effect.as(\n permitted,\n Stream.callback<GeolocationPosition, GeolocationError>((queue) =>\n Effect.acquireRelease(\n Effect.tryPromise({\n try: () =>\n location.watchPositionAsync(\n { accuracy: accuracy(options) },\n (value) => {\n Queue.offerUnsafe(queue, toPosition(value));\n },\n (reason) => {\n Queue.failCauseUnsafe(\n queue,\n Cause.fail(\n fail(\n \"PositionUnavailable\",\n \"Your location isn't available right now.\",\n reason\n )\n )\n );\n }\n ),\n catch: (cause) =>\n fail(\n \"PositionUnavailable\",\n \"Your location isn't available right now.\",\n cause\n ),\n }),\n (subscription) => Effect.sync(() => subscription.remove())\n )\n )\n )\n ),\n };\n}\n"],"mappings":";;;;;AAmCA,MAAM,oBAAoB;AAC1B,MAAM,6BAA6B;AAEnC,MAAM,QAAQ,QAAoC,SAAiB,UAC/D,IAAI,iBAAiB;CAAE;CAAQ;CAAS;AAAM,CAAC;AACnD,MAAM,cAAc,EAAE,QAAQ,iBAA0D;CACpF,QAAQ;EACJ,UAAU,OAAO;EACjB,WAAW,OAAO;EAClB,UAAU,OAAO,YAAY;EAC7B,UAAU,OAAO;EACjB,kBAAkB,OAAO;EACzB,SAAS,OAAO;EAChB,OAAO,OAAO;CAClB;CACA;AACJ;;AAGA,SAAgB,sBAAsB,WAA+B,cAA2B;CAC5F,MAAM,YAAY,OAAO,WAAW;EAChC,WAAW,SAAS,kCAAkC;EACtD,QAAQ,UAAU,KAAK,oBAAoB,+CAA+C,KAAK;CACnG,CAAC,CAAC,CAAC,KACC,OAAO,SAAS,eACZ,WAAW,WAAW,YAChB,OAAO,OACP,OAAO,KAAK,KAAK,oBAAoB,iCAAiC,CAAC,CACjF,CACJ;CACA,MAAM,YA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iBAAiB,OAAO,WAAW,aAAa,OAAO,CAAC,CAC7D,CACJ,CACJ,CACJ;CACR;AACJ"}
1
+ {"version":3,"file":"createExpoGeolocation.js","names":[],"sources":["../src/createExpoGeolocation.ts"],"sourcesContent":["import { GeolocationError } from \"@party-stack/runtime\";\nimport { Cause, Effect, Option, Queue, Stream } from \"effect\";\nimport type { Geolocation, GeolocationOptions, GeolocationPosition } from \"@party-stack/runtime\";\n\ninterface ExpoLocationObject {\n readonly coords: {\n readonly latitude: number;\n readonly longitude: number;\n readonly accuracy: number | null;\n readonly altitude: number | null;\n readonly altitudeAccuracy: number | null;\n readonly heading: number | null;\n readonly speed: number | null;\n };\n readonly timestamp: number;\n}\n\n/** The parts of `expo-location` this uses; tests pass a fake. */\nexport interface ExpoLocationModule {\n readonly requestForegroundPermissionsAsync: () => Promise<{ readonly status: string }>;\n readonly getCurrentPositionAsync: (options?: { accuracy?: number }) => Promise<ExpoLocationObject>;\n readonly getLastKnownPositionAsync: (options?: {\n maxAge?: number;\n requiredAccuracy?: number;\n }) => Promise<ExpoLocationObject | null>;\n readonly watchPositionAsync: (\n options: { accuracy?: number },\n callback: (location: ExpoLocationObject) => void,\n errorHandler?: (reason: string) => void\n ) => Promise<{ remove(): void }>;\n readonly Accuracy: { readonly Balanced: number; readonly High: number };\n}\n\n/** A recent cached fix is better than failing when GPS can't produce a new one. */\nconst lastKnownMaxAgeMs = 5 * 60_000;\nconst lastKnownRequiredAccuracyM = 1_000;\n\nconst fail = (reason: GeolocationError[\"reason\"], message: string, cause?: unknown) =>\n new GeolocationError({ reason, message, cause });\nconst toPosition = ({ coords, timestamp }: ExpoLocationObject): GeolocationPosition => ({\n coords: {\n latitude: coords.latitude,\n longitude: coords.longitude,\n accuracy: coords.accuracy ?? 0,\n altitude: coords.altitude,\n altitudeAccuracy: coords.altitudeAccuracy,\n heading: coords.heading,\n speed: coords.speed,\n },\n timestamp,\n});\n\n/** Device location through expo-location, with the web API's options and reasons. */\nexport function createExpoGeolocation(location?: ExpoLocationModule): Geolocation {\n if (!location) {\n const native = Effect.tryPromise({\n try: () => import(\"expo-location\"),\n catch: (cause) => fail(\"PositionUnavailable\", \"Could not load device location.\", cause),\n }).pipe(Effect.map((module) => createExpoGeolocation(module)));\n return {\n getCurrentPosition: (options) =>\n Effect.flatMap(native, (service) => service.getCurrentPosition(options)),\n watchPosition: (options) =>\n Stream.unwrap(Effect.map(native, (service) => service.watchPosition(options))),\n };\n }\n const permitted = Effect.tryPromise({\n try: () => location.requestForegroundPermissionsAsync(),\n catch: (cause) => fail(\"PermissionDenied\", \"Location permission could not be requested.\", cause),\n }).pipe(\n Effect.flatMap((permission) =>\n permission.status === \"granted\"\n ? Effect.void\n : Effect.fail(fail(\"PermissionDenied\", \"Location permission was denied.\"))\n )\n );\n const accuracy = (options?: GeolocationOptions) =>\n options?.enableHighAccuracy ? location.Accuracy.High : location.Accuracy.Balanced;\n const lastKnown = (options?: GeolocationOptions) =>\n Effect.tryPromise(() =>\n location.getLastKnownPositionAsync({\n maxAge: options?.maximumAge ?? lastKnownMaxAgeMs,\n requiredAccuracy: lastKnownRequiredAccuracyM,\n })\n ).pipe(\n Effect.map((value) => Option.fromNullishOr(value)),\n Effect.orElseSucceed(() => Option.none<ExpoLocationObject>())\n );\n return {\n getCurrentPosition: (options) =>\n Effect.gen(function* () {\n yield* permitted;\n const current = Effect.tryPromise({\n try: () => location.getCurrentPositionAsync({ accuracy: accuracy(options) }),\n catch: (cause) =>\n fail(\"PositionUnavailable\", \"Your location isn't available right now.\", cause),\n });\n const timeout = options?.timeout;\n const result = yield* Effect.result(\n timeout !== undefined && Number.isFinite(timeout)\n ? current.pipe(\n Effect.timeoutOrElse({\n duration: timeout,\n orElse: () =>\n Effect.fail(fail(\"Timeout\", \"Finding your location timed out.\")),\n })\n )\n : current\n );\n if (result._tag === \"Success\") return toPosition(result.success);\n const cached = yield* lastKnown(options);\n if (Option.isSome(cached)) return toPosition(cached.value);\n return yield* result.failure;\n }),\n watchPosition: (options) =>\n Stream.unwrap(\n Effect.as(\n permitted,\n Stream.callback<GeolocationPosition, GeolocationError>((queue) =>\n Effect.acquireRelease(\n Effect.tryPromise({\n try: () =>\n location.watchPositionAsync(\n { accuracy: accuracy(options) },\n (value) => {\n Queue.offerUnsafe(queue, toPosition(value));\n },\n (reason) => {\n Queue.failCauseUnsafe(\n queue,\n Cause.fail(\n fail(\n \"PositionUnavailable\",\n \"Your location isn't available right now.\",\n reason\n )\n )\n );\n }\n ),\n catch: (cause) =>\n fail(\n \"PositionUnavailable\",\n \"Your location isn't available right now.\",\n cause\n ),\n }),\n (subscription) => Effect.sync(() => subscription.remove())\n )\n )\n )\n ),\n };\n}\n"],"mappings":";;;;AAkCA,MAAM,oBAAoB;AAC1B,MAAM,6BAA6B;AAEnC,MAAM,QAAQ,QAAoC,SAAiB,UAC/D,IAAI,iBAAiB;CAAE;CAAQ;CAAS;AAAM,CAAC;AACnD,MAAM,cAAc,EAAE,QAAQ,iBAA0D;CACpF,QAAQ;EACJ,UAAU,OAAO;EACjB,WAAW,OAAO;EAClB,UAAU,OAAO,YAAY;EAC7B,UAAU,OAAO;EACjB,kBAAkB,OAAO;EACzB,SAAS,OAAO;EAChB,OAAO,OAAO;CAClB;CACA;AACJ;;AAGA,SAAgB,sBAAsB,UAA4C;CAC9E,IAAI,CAAC,UAAU;EACX,MAAM,SAAS,OAAO,WAAW;GAC7B,WAAW,OAAO;GAClB,QAAQ,UAAU,KAAK,uBAAuB,mCAAmC,KAAK;EAC1F,CAAC,CAAC,CAAC,KAAK,OAAO,KAAK,WAAW,sBAAsB,MAAM,CAAC,CAAC;EAC7D,OAAO;GACH,qBAAqB,YACjB,OAAO,QAAQ,SAAS,YAAY,QAAQ,mBAAmB,OAAO,CAAC;GAC3E,gBAAgB,YACZ,OAAO,OAAO,OAAO,IAAI,SAAS,YAAY,QAAQ,cAAc,OAAO,CAAC,CAAC;EACrF;CACJ;CACA,MAAM,YAAY,OAAO,WAAW;EAChC,WAAW,SA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UAAU;IACP,MAAM,YAAY,OAAO,WAAW,KAAK,CAAC;GAC9C,IACC,WAAW;IACR,MAAM,gBACF,OACA,MAAM,KACF,KACI,uBACA,4CACA,MACJ,CACJ,CACJ;GACJ,CACJ;GACJ,QAAQ,UACJ,KACI,uBACA,4CACA,KACJ;EACR,CAAC,IACA,iBAAiB,OAAO,WAAW,aAAa,OAAO,CAAC,CAC7D,CACJ,CACJ,CACJ;CACR;AACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"createExpoRuntime.d.ts","names":[],"sources":["../src/createExpoRuntime.ts"],"mappings":";;;iBA2BiB;;WAEJ;;;;WAIA,cAAc;;qBAMd,OAAI,UAAA,mCAAA,OAAA,sCAAA,wDAAA,uBAAA,cAAA,0CAAA;qBA6GJ,QAAK,UAAa,uBAAkB,MAAA,MAAA,iDAAA,uBAAA,cAAA;qBACpC,cAAW,UAAa,uBAAkB,MAAA,MAAA"}
1
+ {"version":3,"file":"createExpoRuntime.d.ts","names":[],"sources":["../src/createExpoRuntime.ts"],"mappings":";;;iBAuBiB;;WAEJ;;;;WAIA,cAAc;;qBAMd,OAAI,UAAA,mCAAA,OAAA,sCAAA,wDAAA,uBAAA,cAAA,0CAAA;qBAuEJ,QAAK,UAAa,uBAAkB,MAAA,MAAA,iDAAA,uBAAA,cAAA;qBACpC,cAAW,UAAa,uBAAkB,MAAA,MAAA"}
@@ -5,18 +5,15 @@ import { makeExpoNetworkLinks } from "./ExpoNetworkConnectivity.js";
5
5
  import { createExpoBrowserAuthentication } from "./createExpoBrowserAuthentication.js";
6
6
  import { createExpoGeolocation } from "./createExpoGeolocation.js";
7
7
  import { nativeKeyCodec } from "./encryptionKeys.js";
8
+ import { deleteSqliteDatabase, openSqliteClient } from "./internal/sqlite.js";
8
9
  import { MemoryBlobBytesStore, Runtime, RuntimeError, RuntimePartition, Runtimes, makeKeyMaterialStoreKeyring } from "@party-stack/runtime";
9
- import { Effect, Layer, Schema } from "effect";
10
+ import { Effect, Layer } from "effect";
10
11
  import { Paths } from "expo-file-system";
11
12
  import { CryptoDigestAlgorithm, digest } from "expo-crypto";
12
13
  import { configureNativeSha256 } from "@party-stack/ontology-storage/blobs";
13
- import { storageError } from "@party-stack/ontology-storage/driver";
14
14
  import * as MemoryTables from "@party-stack/ontology-storage/memory/tables";
15
- import * as SQLite from "@party-stack/sql-ontology-storage/sqlite";
16
15
  import * as SqlTables from "@party-stack/sql-ontology-storage/tables";
17
- import * as Reactivity from "effect/reactivity/Reactivity";
18
16
  import * as SqlClient from "effect/sql/SqlClient";
19
- import { deleteDatabaseAsync, openDatabaseAsync } from "expo-sqlite";
20
17
  //#region src/createExpoRuntime.ts
21
18
  configureNativeSha256((bytes) => digest(CryptoDigestAlgorithm.SHA256, bytes));
22
19
  const geolocationOf = (options) => options.geolocation === false ? void 0 : options.geolocation ?? createExpoGeolocation();
@@ -56,29 +53,7 @@ const make = Effect.fn("ExpoRuntime.make")(function* (options = {}) {
56
53
  })}`;
57
54
  const blobBytes = new ExpoFileSystemBlobBytesStore({ directoryName: `${storageName}-blobs` });
58
55
  const tables = Effect.gen(function* () {
59
- const database = yield* Effect.acquireRelease(Effect.tryPromise({
60
- try: () => openDatabaseAsync(`${storageName}-storage.db`),
61
- catch: (cause) => storageError("sql", "open", cause)
62
- }), (database) => Effect.promise(() => database.closeAsync()));
63
- let active = database;
64
- const sql = yield* SQLite.makeClient({
65
- exec: (query) => active.execSync(query),
66
- prepare: (query) => ({
67
- all: (...values) => active.getAllSync(query, values),
68
- run: (...values) => active.runSync(query, values)
69
- }),
70
- transactionAsync: (body) => {
71
- let value;
72
- return database.withExclusiveTransactionAsync(async (tx) => {
73
- active = tx;
74
- try {
75
- value = await body();
76
- } finally {
77
- active = database;
78
- }
79
- }).then(() => value);
80
- }
81
- }).pipe(Effect.provide(Reactivity.layer), Effect.mapError((cause) => storageError("sql", "open", cause)));
56
+ const sql = yield* openSqliteClient(`${storageName}-storage.db`);
82
57
  return yield* SqlTables.make({ maxParameters: 900 }).pipe(Effect.provideService(SqlClient.SqlClient, sql));
83
58
  });
84
59
  const secrets = makeKeyMaterialStore(`${name}:secrets`);
@@ -105,16 +80,18 @@ const make = Effect.fn("ExpoRuntime.make")(function* (options = {}) {
105
80
  encryptionKeyring,
106
81
  links,
107
82
  tables: ownedTables,
108
- destroy: Effect.tryPromise({
109
- try: async () => {
110
- await Promise.all([deleteDatabaseAsync(`${storageName}-storage.db`).catch((cause) => {
111
- if (!Schema.is(Schema.Struct({ code: Schema.Literal("ERR_DATABASE_NOT_FOUND") }))(cause)) throw cause;
112
- }), Effect.runPromise(blobBytes.clear())]);
113
- },
114
- catch: (cause) => new RuntimeError({
83
+ destroy: Effect.gen(function* () {
84
+ yield* Effect.try({
85
+ try: () => deleteSqliteDatabase(`${storageName}-storage.db`),
86
+ catch: (cause) => new RuntimeError({
87
+ operation: "destroy",
88
+ cause
89
+ })
90
+ });
91
+ yield* blobBytes.clear().pipe(Effect.mapError((cause) => new RuntimeError({
115
92
  operation: "destroy",
116
93
  cause
117
- })
94
+ })));
118
95
  })
119
96
  });
120
97
  });
@@ -1 +1 @@
1
- {"version":3,"file":"createExpoRuntime.js","names":[],"sources":["../src/createExpoRuntime.ts"],"sourcesContent":["import { configureNativeSha256 } from \"@party-stack/ontology-storage/blobs\";\nimport { storageError } from \"@party-stack/ontology-storage/driver\";\nimport * as MemoryTables from \"@party-stack/ontology-storage/memory/tables\";\nimport { Runtime, RuntimeError, RuntimePartition, makeKeyMaterialStoreKeyring } from \"@party-stack/runtime\";\nimport { Runtimes, MemoryBlobBytesStore, type KeyMaterialStore } from \"@party-stack/runtime\";\nimport * as SQLite from \"@party-stack/sql-ontology-storage/sqlite\";\nimport * as SqlTables from \"@party-stack/sql-ontology-storage/tables\";\nimport { Effect, Layer, Schema } from \"effect\";\nimport * as Reactivity from \"effect/reactivity/Reactivity\";\nimport * as SqlClient from \"effect/sql/SqlClient\";\nimport { CryptoDigestAlgorithm, digest } from \"expo-crypto\";\nimport { Paths } from \"expo-file-system\";\nimport { deleteDatabaseAsync, openDatabaseAsync } from \"expo-sqlite\";\nimport { createExpoBrowserAuthentication } from \"./createExpoBrowserAuthentication.js\";\nimport { createExpoGeolocation } from \"./createExpoGeolocation.js\";\nimport { nativeKeyCodec } from \"./encryptionKeys.js\";\nimport { ExpoFileSystemBlobBytesStore } from \"./ExpoFileSystemBlobBytesStore.js\";\nimport { makeKeyMaterialStore } from \"./ExpoKeyMaterialStore.js\";\nimport { makeExpoNetworkLinks } from \"./ExpoNetworkConnectivity.js\";\nimport { hashStorageName } from \"./hashStorageName.js\";\nimport type { Geolocation } from \"@party-stack/runtime\";\nimport type { SQLiteBindValue } from \"expo-sqlite\";\n\n// Content digests use the platform SHA-256; portable JavaScript hashing costs\n// hundreds of milliseconds per MiB on Hermes. Bounded inputs only; see digestBytes.\nconfigureNativeSha256((bytes) => digest(CryptoDigestAlgorithm.SHA256, bytes));\n\nexport interface ExpoRuntimeOptions {\n /** Persistent SQLite/filesystem storage by default; memory keeps native platform capabilities. */\n readonly storage?: \"persistent\" | \"memory\";\n /** Device location through expo-location by default. Permission is requested on\n * first use; add expo-location's config plugin for the platform purpose strings.\n * Pass `false` for none. */\n readonly geolocation?: Geolocation | false;\n}\n\nconst geolocationOf = (options: ExpoRuntimeOptions) =>\n options.geolocation === false ? undefined : (options.geolocation ?? createExpoGeolocation());\n\nexport const make = Effect.fn(\"ExpoRuntime.make\")(function* (options: ExpoRuntimeOptions = {}) {\n const { owner, namespace } = yield* RuntimePartition;\n const links = yield* makeExpoNetworkLinks();\n if (options.storage === \"memory\") {\n const materials = new Map<string, string>();\n const secrets: KeyMaterialStore = {\n get: (id) => Effect.sync(() => materials.get(id)),\n set: (id, value) =>\n Effect.sync(() => {\n materials.set(id, value);\n }),\n delete: (id) =>\n Effect.sync(() => {\n materials.delete(id);\n }),\n };\n return yield* Runtime.make({\n tables: yield* MemoryTables.make(),\n blobBytes: new MemoryBlobBytesStore(),\n encryptionKeyring: yield* makeKeyMaterialStoreKeyring(secrets, nativeKeyCodec),\n browserAuthentication: createExpoBrowserAuthentication(),\n geolocation: geolocationOf(options),\n links,\n capacity: { memory: Effect.succeed(undefined), storage: Effect.succeed(undefined) },\n });\n }\n const name = `party-stack:${owner}:${namespace}`;\n const storageName = `party-stack-${yield* Effect.tryPromise({ try: () => hashStorageName(JSON.stringify([owner, namespace])), catch: (cause) => new RuntimeError({ operation: \"expoRuntime.name\", cause }) })}`;\n const blobBytes = new ExpoFileSystemBlobBytesStore({\n directoryName: `${storageName}-blobs`,\n });\n const tables = Effect.gen(function* () {\n const database = yield* Effect.acquireRelease(\n Effect.tryPromise({\n try: () => openDatabaseAsync(`${storageName}-storage.db`),\n catch: (cause) => storageError(\"sql\", \"open\", cause),\n }),\n (database) => Effect.promise(() => database.closeAsync())\n );\n let active = database;\n const sql = yield* SQLite.makeClient({\n exec: (query) => active.execSync(query),\n prepare: (query) => ({\n all: (...values) => active.getAllSync(query, values as SQLiteBindValue[]),\n run: (...values) => active.runSync(query, values as SQLiteBindValue[]),\n }),\n transactionAsync: <A>(body: () => Promise<A>) => {\n let value: A;\n return database\n .withExclusiveTransactionAsync(async (tx) => {\n active = tx;\n try {\n value = await body();\n } finally {\n active = database;\n }\n })\n .then(() => value);\n },\n }).pipe(\n Effect.provide(Reactivity.layer),\n Effect.mapError((cause) => storageError(\"sql\", \"open\", cause))\n );\n // Each statement is a native call, prepared on its own: let a batch fill one statement.\n // 900 parameters fits any SQLite expo-sqlite ships (999 before SQLite 3.32, 32,766 since).\n return yield* SqlTables.make({ maxParameters: 900 }).pipe(\n Effect.provideService(SqlClient.SqlClient, sql)\n );\n });\n const secrets = makeKeyMaterialStore(`${name}:secrets`);\n const ownedTables = yield* tables;\n const encryptionKeyring = yield* makeKeyMaterialStoreKeyring(secrets, nativeKeyCodec);\n return yield* Runtime.make({\n blobBytes,\n capacity: {\n memory: Effect.succeed(undefined),\n storage: Effect.try({\n try: () => ({\n scope: \"filesystem\" as const,\n limitBytes: Paths.totalDiskSpace,\n availableBytes: Paths.availableDiskSpace,\n }),\n catch: (cause) => new RuntimeError({ operation: \"capacity.storage\", cause }),\n }),\n },\n browserAuthentication: createExpoBrowserAuthentication(),\n geolocation: geolocationOf(options),\n encryptionKeyring,\n links,\n\n tables: ownedTables,\n destroy: Effect.tryPromise({\n try: async () => {\n await Promise.all([\n deleteDatabaseAsync(`${storageName}-storage.db`).catch((cause) => {\n if (\n !Schema.is(Schema.Struct({ code: Schema.Literal(\"ERR_DATABASE_NOT_FOUND\") }))(\n cause\n )\n )\n throw cause;\n }),\n Effect.runPromise(blobBytes.clear()),\n ]);\n },\n catch: (cause) => new RuntimeError({ operation: \"destroy\", cause }),\n }),\n });\n});\nexport const layer = (options: ExpoRuntimeOptions = {}) => Layer.effect(Runtime, make(options));\nexport const expoRuntime = (options: ExpoRuntimeOptions = {}) =>\n Runtimes.layer(layer(options), {\n browserAuthentication: createExpoBrowserAuthentication(),\n geolocation: geolocationOf(options),\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAyBA,uBAAuB,UAAU,OAAO,sBAAsB,QAAQ,KAAK,CAAC;AAW5E,MAAM,iBAAiB,YACnB,QAAQ,gBAAgB,QAAQ,KAAA,IAAa,QAAQ,eAAe,sBAAsB;AAE9F,MAAa,OAAO,OAAO,GAAG,kBAAkB,CAAC,CAAC,WAAW,UAA8B,CAAC,GAAG;CAC3F,MAAM,EAAE,OAAO,cAAc,OAAO;CACpC,MAAM,QAAQ,OAAO,qBAAqB;CAC1C,IAAI,QAAQ,YAAY,UAAU;EAC9B,MAAM,4BAAY,IAAI,IAAoB;EAY1C,OAAO,OAAO,QAAQ,KAAK;GACvB,QAAQ,OAAO,aAAa,KAAK;GACjC,WAAW,IAAI,qBAAqB;GACpC,mBAAmB,OAAO,4BAA4B;IAbtD,MAAM,OAAO,OAAO,WAAW,UAAU,IAAI,EAAE,CAAC;IAChD,MAAM,IAAI,UACN,OAAO,WAAW;KACd,UAAU,IAAI,IAAI,KAAK;IAC3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ExpoRuntime.js","names":[],"sources":["../src/createExpoRuntime.ts"],"sourcesContent":["import { configureNativeSha256 } from \"@party-stack/ontology-storage/blobs\";\nimport * as MemoryTables from \"@party-stack/ontology-storage/memory/tables\";\nimport { Runtime, RuntimeError, RuntimePartition, makeKeyMaterialStoreKeyring } from \"@party-stack/runtime\";\nimport { Runtimes, MemoryBlobBytesStore, type KeyMaterialStore } from \"@party-stack/runtime\";\nimport * as SqlTables from \"@party-stack/sql-ontology-storage/tables\";\nimport { Effect, Layer } from \"effect\";\nimport * as SqlClient from \"effect/sql/SqlClient\";\nimport { CryptoDigestAlgorithm, digest } from \"expo-crypto\";\nimport { Paths } from \"expo-file-system\";\nimport { createExpoBrowserAuthentication } from \"./createExpoBrowserAuthentication.js\";\nimport { createExpoGeolocation } from \"./createExpoGeolocation.js\";\nimport { nativeKeyCodec } from \"./encryptionKeys.js\";\nimport { ExpoFileSystemBlobBytesStore } from \"./ExpoFileSystemBlobBytesStore.js\";\nimport { makeKeyMaterialStore } from \"./ExpoKeyMaterialStore.js\";\nimport { makeExpoNetworkLinks } from \"./ExpoNetworkConnectivity.js\";\nimport { hashStorageName } from \"./hashStorageName.js\";\nimport { openSqliteClient, deleteSqliteDatabase } from \"./internal/sqlite.js\";\nimport type { Geolocation } from \"@party-stack/runtime\";\n\n// Content digests use the platform SHA-256; portable JavaScript hashing costs\n// hundreds of milliseconds per MiB on Hermes. Bounded inputs only; see digestBytes.\nconfigureNativeSha256((bytes) => digest(CryptoDigestAlgorithm.SHA256, bytes));\n\nexport interface ExpoRuntimeOptions {\n /** Persistent SQLite/filesystem storage by default; memory keeps native platform capabilities. */\n readonly storage?: \"persistent\" | \"memory\";\n /** Device location through expo-location by default. Permission is requested on\n * first use; add expo-location's config plugin for the platform purpose strings.\n * Pass `false` for none. */\n readonly geolocation?: Geolocation | false;\n}\n\nconst geolocationOf = (options: ExpoRuntimeOptions) =>\n options.geolocation === false ? undefined : (options.geolocation ?? createExpoGeolocation());\n\nexport const make = Effect.fn(\"ExpoRuntime.make\")(function* (options: ExpoRuntimeOptions = {}) {\n const { owner, namespace } = yield* RuntimePartition;\n const links = yield* makeExpoNetworkLinks();\n if (options.storage === \"memory\") {\n const materials = new Map<string, string>();\n const secrets: KeyMaterialStore = {\n get: (id) => Effect.sync(() => materials.get(id)),\n set: (id, value) =>\n Effect.sync(() => {\n materials.set(id, value);\n }),\n delete: (id) =>\n Effect.sync(() => {\n materials.delete(id);\n }),\n };\n return yield* Runtime.make({\n tables: yield* MemoryTables.make(),\n blobBytes: new MemoryBlobBytesStore(),\n encryptionKeyring: yield* makeKeyMaterialStoreKeyring(secrets, nativeKeyCodec),\n browserAuthentication: createExpoBrowserAuthentication(),\n geolocation: geolocationOf(options),\n links,\n capacity: { memory: Effect.succeed(undefined), storage: Effect.succeed(undefined) },\n });\n }\n const name = `party-stack:${owner}:${namespace}`;\n const storageName = `party-stack-${yield* Effect.tryPromise({ try: () => hashStorageName(JSON.stringify([owner, namespace])), catch: (cause) => new RuntimeError({ operation: \"expoRuntime.name\", cause }) })}`;\n const blobBytes = new ExpoFileSystemBlobBytesStore({\n directoryName: `${storageName}-blobs`,\n });\n const tables = Effect.gen(function* () {\n const sql = yield* openSqliteClient(`${storageName}-storage.db`);\n // Batch native calls while staying within SQLite's legacy parameter limit.\n return yield* SqlTables.make({ maxParameters: 900 }).pipe(\n Effect.provideService(SqlClient.SqlClient, sql)\n );\n });\n const secrets = makeKeyMaterialStore(`${name}:secrets`);\n const ownedTables = yield* tables;\n const encryptionKeyring = yield* makeKeyMaterialStoreKeyring(secrets, nativeKeyCodec);\n return yield* Runtime.make({\n blobBytes,\n capacity: {\n memory: Effect.succeed(undefined),\n storage: Effect.try({\n try: () => ({\n scope: \"filesystem\" as const,\n limitBytes: Paths.totalDiskSpace,\n availableBytes: Paths.availableDiskSpace,\n }),\n catch: (cause) => new RuntimeError({ operation: \"capacity.storage\", cause }),\n }),\n },\n browserAuthentication: createExpoBrowserAuthentication(),\n geolocation: geolocationOf(options),\n encryptionKeyring,\n links,\n\n tables: ownedTables,\n destroy: Effect.gen(function* () {\n yield* Effect.try({\n try: () => deleteSqliteDatabase(`${storageName}-storage.db`),\n catch: (cause) => new RuntimeError({ operation: \"destroy\", cause }),\n });\n yield* blobBytes\n .clear()\n .pipe(Effect.mapError((cause) => new RuntimeError({ operation: \"destroy\", cause })));\n }),\n });\n});\nexport const layer = (options: ExpoRuntimeOptions = {}) => Layer.effect(Runtime, make(options));\nexport const expoRuntime = (options: ExpoRuntimeOptions = {}) =>\n Runtimes.layer(layer(options), {\n browserAuthentication: createExpoBrowserAuthentication(),\n geolocation: geolocationOf(options),\n });\n"],"mappings":";;;;;;;;;;;;;;;;;AAqBA,uBAAuB,UAAU,OAAO,sBAAsB,QAAQ,KAAK,CAAC;AAW5E,MAAM,iBAAiB,YACnB,QAAQ,gBAAgB,QAAQ,KAAA,IAAa,QAAQ,eAAe,sBAAsB;AAE9F,MAAa,OAAO,OAAO,GAAG,kBAAkB,CAAC,CAAC,WAAW,UAA8B,CAAC,GAAG;CAC3F,MAAM,EAAE,OAAO,cAAc,OAAO;CACpC,MAAM,QAAQ,OAAO,qBAAqB;CAC1C,IAAI,QAAQ,YAAY,UAAU;EAC9B,MAAM,4BAAY,IAAI,IAAoB;EAY1C,OAAO,OAAO,QAAQ,KAAK;GACvB,QAAQ,OAAO,aAAa,KAAK;GACjC,WAAW,IAAI,qBAAqB;GACpC,mBAAmB,OAAO,4BAA4B;IAbtD,MAAM,OAAO,OAAO,WAAW,UAAU,IAAI,EAAE,CAAC;IAChD,MAAM,IAAI,UACN,OAAO,WAAW;KACd,UAAU,IAAI,IAAI,KAAK;IAC3B,CAAC;IACL,SAAS,OACL,OAAO,WAAW;KACd,UAAU,OAAO,EAAE;IACvB,CAAC;GAKuD,GAAG,cAAc;GAC7E,uBAAuB,gCAAgC;GACvD,aAAa,cAAc,OAAO;GAClC;GACA,UAAU;IAAE,QAAQ,OAAO,QAAQ,KAAA,CAAS;IAAG,SA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IAAW;GAAM,CAAC,CAAC,CAAC;EAC3F,CAAC;CACL,CAAC;AACL,CAAC;AACD,MAAa,SAAS,UAA8B,CAAC,MAAM,MAAM,OAAO,SAAS,KAAK,OAAO,CAAC;AAC9F,MAAa,eAAe,UAA8B,CAAC,MACvD,SAAS,MAAM,MAAM,OAAO,GAAG;CAC3B,uBAAuB,gCAAgC;CACvD,aAAa,cAAc,OAAO;AACtC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { Effect } from "effect";
2
+ //#region src/internal/sqlite.d.ts
3
+ /** Opens a scoped connection beside the existing Expo replica files. */
4
+ export declare const openSqliteClient: (filename: string) => Effect.Effect<import("@effect/sql-sqlite-react-native/SqliteClient").SqliteClient, import("@party-stack/ontology-storage").OntologyStorageError, import("effect/Scope").Scope>;
5
+ /** The partition owner closes its connection before destroying the database. */
6
+ export declare function deleteSqliteDatabase(filename: string): void;
7
+ //#endregion
8
+ //# sourceMappingURL=sqlite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqlite.d.ts","names":[],"sources":["../../src/internal/sqlite.ts"],"mappings":";;;qBAaa,mBAAgB,qBAAA,OAAA,8DAAA,sDAAA,6CAAA;;wBAqBb,qBAAqB"}
@@ -0,0 +1,48 @@
1
+ import { Effect } from "effect";
2
+ import { Directory, File, Paths } from "expo-file-system";
3
+ import { storageError } from "@party-stack/ontology-storage/driver";
4
+ import * as Reactivity from "effect/reactivity/Reactivity";
5
+ //#region src/internal/sqlite.ts
6
+ function databaseDirectory(filename) {
7
+ if (!/^[a-zA-Z0-9_-][a-zA-Z0-9_.-]*\.db$/.test(filename)) throw new Error("Expected a SQLite .db filename in the replica directory.");
8
+ return new Directory(Paths.document, "SQLite");
9
+ }
10
+ /** Opens a scoped connection beside the existing Expo replica files. */
11
+ const openSqliteClient = Effect.fn("ExpoRuntime.openSqliteClient")(function* (filename) {
12
+ const location = yield* Effect.try({
13
+ try: () => {
14
+ const directory = databaseDirectory(filename);
15
+ directory.create({
16
+ intermediates: true,
17
+ idempotent: true
18
+ });
19
+ if (!directory.uri.startsWith("file:///")) throw new Error("Expected a local SQLite directory.");
20
+ return decodeURIComponent(directory.uri.slice(7));
21
+ },
22
+ catch: (cause) => storageError("sql", "open", cause)
23
+ });
24
+ return yield* (yield* Effect.tryPromise({
25
+ try: () => import("@effect/sql-sqlite-react-native/SqliteClient"),
26
+ catch: (cause) => storageError("sql", "open", cause)
27
+ })).make({
28
+ filename,
29
+ location
30
+ }).pipe(Effect.provide(Reactivity.layer), Effect.catchDefect((cause) => Effect.fail(storageError("sql", "open", cause))));
31
+ });
32
+ /** The partition owner closes its connection before destroying the database. */
33
+ function deleteSqliteDatabase(filename) {
34
+ const directory = databaseDirectory(filename);
35
+ for (const suffix of [
36
+ "",
37
+ "-wal",
38
+ "-shm",
39
+ "-journal"
40
+ ]) {
41
+ const file = new File(directory, filename + suffix);
42
+ if (file.exists) file.delete();
43
+ }
44
+ }
45
+ //#endregion
46
+ export { deleteSqliteDatabase, openSqliteClient };
47
+
48
+ //# sourceMappingURL=sqlite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqlite.js","names":[],"sources":["../../src/internal/sqlite.ts"],"sourcesContent":["import { storageError } from \"@party-stack/ontology-storage/driver\";\nimport { Effect } from \"effect\";\nimport * as Reactivity from \"effect/reactivity/Reactivity\";\nimport { Directory, File, Paths } from \"expo-file-system\";\n\nfunction databaseDirectory(filename: string) {\n if (!/^[a-zA-Z0-9_-][a-zA-Z0-9_.-]*\\.db$/.test(filename)) {\n throw new Error(\"Expected a SQLite .db filename in the replica directory.\");\n }\n return new Directory(Paths.document, \"SQLite\");\n}\n\n/** Opens a scoped connection beside the existing Expo replica files. */\nexport const openSqliteClient = Effect.fn(\"ExpoRuntime.openSqliteClient\")(function* (filename: string) {\n const location = yield* Effect.try({\n try: () => {\n const directory = databaseDirectory(filename);\n directory.create({ intermediates: true, idempotent: true });\n if (!directory.uri.startsWith(\"file:///\")) throw new Error(\"Expected a local SQLite directory.\");\n return decodeURIComponent(directory.uri.slice(\"file://\".length));\n },\n catch: (cause) => storageError(\"sql\", \"open\", cause),\n });\n const driver = yield* Effect.tryPromise({\n try: () => import(\"@effect/sql-sqlite-react-native/SqliteClient\"),\n catch: (cause) => storageError(\"sql\", \"open\", cause),\n });\n return yield* driver.make({ filename, location }).pipe(\n Effect.provide(Reactivity.layer),\n Effect.catchDefect((cause) => Effect.fail(storageError(\"sql\", \"open\", cause)))\n );\n});\n\n/** The partition owner closes its connection before destroying the database. */\nexport function deleteSqliteDatabase(filename: string) {\n const directory = databaseDirectory(filename);\n for (const suffix of [\"\", \"-wal\", \"-shm\", \"-journal\"]) {\n const file = new File(directory, filename + suffix);\n if (file.exists) file.delete();\n }\n}\n"],"mappings":";;;;;AAKA,SAAS,kBAAkB,UAAkB;CACzC,IAAI,CAAC,qCAAqC,KAAK,QAAQ,GACnD,MAAM,IAAI,MAAM,0DAA0D;CAE9E,OAAO,IAAI,UAAU,MAAM,UAAU,QAAQ;AACjD;;AAGA,MAAa,mBAAmB,OAAO,GAAG,8BAA8B,CAAC,CAAC,WAAW,UAAkB;CACnG,MAAM,WAAW,OAAO,OAAO,IAAI;EAC/B,WAAW;GACP,MAAM,YAAY,kBAAkB,QAAQ;GAC5C,UAAU,OAAO;IAAE,eAAe;IAAM,YAAY;GAAK,CAAC;GAC1D,IAAI,CAAC,UAAU,IAAI,WAAW,UAAU,GAAG,MAAM,IAAI,MAAM,oCAAoC;GAC/F,OAAO,mBAAmB,UAAU,IAAI,MAAM,CAAgB,CAAC;EACnE;EACA,QAAQ,UAAU,aAAa,OAAO,QAAQ,KAAK;CACvD,CAAC;CAKD,OAAO,QAAO,OAJQ,OAAO,WAAW;EACpC,WAAW,OAAO;EAClB,QAAQ,UAAU,aAAa,OAAO,QAAQ,KAAK;CACvD,CAAC,EAAA,CACoB,KAAK;EAAE;EAAU;CAAS,CAAC,CAAC,CAAC,KAC9C,OAAO,QAAQ,WAAW,KAAK,GAC/B,OAAO,aAAa,UAAU,OAAO,KAAK,aAAa,OAAO,QAAQ,KAAK,CAAC,CAAC,CACjF;AACJ,CAAC;;AAGD,SAAgB,qBAAqB,UAAkB;CACnD,MAAM,YAAY,kBAAkB,QAAQ;CAC5C,KAAK,MAAM,UAAU;EAAC;EAAI;EAAQ;EAAQ;CAAU,GAAG;EACnD,MAAM,OAAO,IAAI,KAAK,WAAW,WAAW,MAAM;EAClD,IAAI,KAAK,QAAQ,KAAK,OAAO;CACjC;AACJ"}
@@ -0,0 +1,18 @@
1
+ import { ExpoWorkerPort, withWorkerPlatform, workerRunner } from "./platform.js";
2
+ import { runExpoReplicaWorker, serveOntologyWorker } from "./runner.js";
3
+ import { Effect } from "effect";
4
+ //#region src/worker/index.d.ts
5
+ interface WorkerSession {
6
+ readonly port: ExpoWorkerPort;
7
+ readonly ready?: Promise<void>;
8
+ close(): Promise<void>;
9
+ }
10
+ /** A factory gives the view ownership of a dedicated worker. Pass an existing port when its
11
+ * session is already scoped by the application, for example to multiplex another RPC service. */
12
+ export declare const workerClient: (source: ExpoWorkerPort | (() => WorkerSession | Promise<WorkerSession>), options?: {
13
+ readonly connectionTimeoutMs?: number;
14
+ readonly ontology?: string;
15
+ } | undefined) => Effect.Effect<import("@party-stack/ontology-server/rpc").OntologyServerClient, import("@party-stack/ontology-backend").BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, import("effect/Scope").Scope>;
16
+ //#endregion
17
+ export { type ExpoWorkerPort, runExpoReplicaWorker, serveOntologyWorker, withWorkerPlatform, workerRunner };
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/worker/index.ts"],"mappings":";;;;UAQU;WACG,MAAM;WACN,QAAQ;EACjB,SAAS;;;;qBAKA,eAAY,QAAA,wBACW,gBAAgB,QAAQ,iBAAc;;;kBAqBxE,OAAA,kDAAA,8DAAA,wXAAA"}
@@ -0,0 +1,23 @@
1
+ import { withWorkerPlatform, workerRunner } from "./platform.js";
2
+ import { runExpoReplicaWorker, serveOntologyWorker } from "./runner.js";
3
+ import { Effect } from "effect";
4
+ import { classifyBackendFailure } from "@party-stack/ontology-backend";
5
+ import { makeOntologyWorkerClient } from "@party-stack/ontology-server/rpc/worker";
6
+ //#region src/worker/index.ts
7
+ /** A factory gives the view ownership of a dedicated worker. Pass an existing port when its
8
+ * session is already scoped by the application, for example to multiplex another RPC service. */
9
+ const workerClient = Effect.fnUntraced(function* (source, options) {
10
+ const startupError = (cause) => classifyBackendFailure("expo.worker.start", cause);
11
+ const port = typeof source === "function" ? (yield* Effect.acquireRelease(Effect.tryPromise({
12
+ try: async () => source(),
13
+ catch: startupError
14
+ }), (session) => Effect.promise(() => session.close())).pipe(Effect.tap((worker) => worker.ready ? Effect.tryPromise({
15
+ try: () => worker.ready,
16
+ catch: startupError
17
+ }) : Effect.void))).port : source;
18
+ return yield* withWorkerPlatform(makeOntologyWorkerClient(options), port);
19
+ });
20
+ //#endregion
21
+ export { runExpoReplicaWorker, serveOntologyWorker, withWorkerPlatform, workerClient, workerRunner };
22
+
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/worker/index.ts"],"sourcesContent":["import { classifyBackendFailure } from \"@party-stack/ontology-backend\";\nimport { makeOntologyWorkerClient } from \"@party-stack/ontology-server/rpc/worker\";\nimport { Effect } from \"effect\";\nimport { withWorkerPlatform, type ExpoWorkerPort } from \"./platform.js\";\n\nexport { runExpoReplicaWorker, serveOntologyWorker } from \"./runner.js\";\nexport { withWorkerPlatform, workerRunner, type ExpoWorkerPort } from \"./platform.js\";\n\ninterface WorkerSession {\n readonly port: ExpoWorkerPort;\n readonly ready?: Promise<void>;\n close(): Promise<void>;\n}\n\n/** A factory gives the view ownership of a dedicated worker. Pass an existing port when its\n * session is already scoped by the application, for example to multiplex another RPC service. */\nexport const workerClient = Effect.fnUntraced(function* (\n source: ExpoWorkerPort | (() => WorkerSession | Promise<WorkerSession>),\n options?: Parameters<typeof makeOntologyWorkerClient>[0]\n) {\n const startupError = (cause: unknown) => classifyBackendFailure(\"expo.worker.start\", cause);\n const port =\n typeof source === \"function\"\n ? (yield* Effect.acquireRelease(\n Effect.tryPromise({\n try: async () => source(),\n catch: startupError,\n }),\n (session) => Effect.promise(() => session.close())\n ).pipe(\n Effect.tap((worker) =>\n worker.ready\n ? Effect.tryPromise({ try: () => worker.ready!, catch: startupError })\n : Effect.void\n )\n )).port\n : source;\n return yield* withWorkerPlatform(makeOntologyWorkerClient(options), port);\n});\n"],"mappings":";;;;;;;;AAgBA,MAAa,eAAe,OAAO,WAAW,WAC1C,QACA,SACF;CACE,MAAM,gBAAgB,UAAmB,uBAAuB,qBAAqB,KAAK;CAC1F,MAAM,OACF,OAAO,WAAW,cACX,OAAO,OAAO,eACX,OAAO,WAAW;EACd,KAAK,YAAY,OAAO;EACxB,OAAO;CACX,CAAC,IACA,YAAY,OAAO,cAAc,QAAQ,MAAM,CAAC,CACrD,CAAC,CAAC,KACE,OAAO,KAAK,WACR,OAAO,QACD,OAAO,WAAW;EAAE,WAAW,OAAO;EAAQ,OAAO;CAAa,CAAC,IACnE,OAAO,IACjB,CACJ,EAAA,CAAG,OACH;CACV,OAAO,OAAO,mBAAmB,yBAAyB,OAAO,GAAG,IAAI;AAC5E,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { Effect } from "effect";
2
+ import { Worker, WorkerRunner } from "effect/workers";
3
+ import { WorkerPort } from "@party-stack/expo-worker";
4
+ //#region src/worker/platform.d.ts
5
+ export type ExpoWorkerPort = WorkerPort<unknown, unknown>;
6
+ export declare function withWorkerPlatform<A, E, R>(effect: Effect.Effect<A, E, R>, endpoint: ExpoWorkerPort): Effect.Effect<A, E, Exclude<Exclude<R, Worker.WorkerPlatform>, Worker.Spawner>>;
7
+ export declare function workerRunner(endpoint: ExpoWorkerPort): WorkerRunner.WorkerRunnerPlatform["Service"];
8
+ //#endregion
9
+ //# sourceMappingURL=platform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.d.ts","names":[],"sources":["../../src/worker/platform.ts"],"mappings":";;;;YAKY,iBAAiB;wBA0Cb,mBAAmB,GAAG,GAAG,GAAG,QAAQ,OAAO,OAAO,GAAG,GAAG,IAAI,UAAU,iBAAc,OAAA,OAAA,GAAA,GAAA,QAAA,QAAA,GAAA,OAAA,iBAAA,OAAA;wBAOpF,aAAa,UAAU,iBAAiB,aAAa"}
@@ -0,0 +1,62 @@
1
+ import { Deferred, Effect, Exit, FiberSet, Scope } from "effect";
2
+ import { Worker, WorkerRunner } from "effect/workers";
3
+ import { WorkerError, WorkerReceiveError } from "effect/workers/WorkerError";
4
+ //#region src/worker/platform.ts
5
+ function receivedError(cause) {
6
+ return new WorkerError({ reason: new WorkerReceiveError({
7
+ message: "Expo ontology worker connection failed.",
8
+ cause
9
+ }) });
10
+ }
11
+ const platform = Worker.makePlatform()({
12
+ setup: ({ worker, scope }) => Effect.as(Scope.addFinalizer(scope, Effect.try(() => worker.postMessage([1])).pipe(Effect.ignore)), worker),
13
+ listen: ({ port, emit, deferred, scope }) => Effect.acquireRelease(Effect.sync(() => {
14
+ let ready = false;
15
+ const unsubscribe = port.subscribe((message) => {
16
+ if (!Array.isArray(message)) return;
17
+ if (message[0] === 0) {
18
+ if (ready) return;
19
+ ready = true;
20
+ }
21
+ emit(message);
22
+ }, (cause) => Deferred.doneUnsafe(deferred, Exit.fail(receivedError(cause))));
23
+ try {
24
+ port.postMessage(null);
25
+ } catch (cause) {
26
+ Deferred.doneUnsafe(deferred, Exit.fail(receivedError(cause)));
27
+ }
28
+ return unsubscribe;
29
+ }), (unsubscribe) => Effect.sync(unsubscribe)).pipe(Scope.provide(scope), Effect.asVoid)
30
+ });
31
+ function withWorkerPlatform(effect, endpoint) {
32
+ return effect.pipe(Effect.provideService(Worker.WorkerPlatform, platform), Effect.provideService(Worker.Spawner, () => endpoint));
33
+ }
34
+ function workerRunner(endpoint) {
35
+ function startRunner() {
36
+ const sendUnsafe = (_id, message) => endpoint.postMessage([1, message]);
37
+ const run = (handler) => Effect.scoped(Effect.gen(function* () {
38
+ const closed = yield* Deferred.make();
39
+ const fibers = yield* FiberSet.make();
40
+ const start = yield* FiberSet.runtime(fibers)();
41
+ yield* Effect.acquireRelease(Effect.sync(() => endpoint.subscribe((message) => {
42
+ if (message === null) endpoint.postMessage([0]);
43
+ else if (Array.isArray(message) && message[0] === 0) {
44
+ const effect = handler(0, message[1]);
45
+ if (effect) start(effect);
46
+ } else if (Array.isArray(message) && message[0] === 1) Deferred.doneUnsafe(closed, Exit.void);
47
+ }, (cause) => Deferred.doneUnsafe(closed, Exit.fail(receivedError(cause))))), (unsubscribe) => Effect.sync(unsubscribe));
48
+ yield* Effect.sync(() => endpoint.postMessage([0]));
49
+ yield* Effect.raceFirst(Deferred.await(closed), FiberSet.join(fibers).pipe(Effect.mapError(receivedError)));
50
+ }));
51
+ return Effect.succeed({
52
+ run,
53
+ sendUnsafe,
54
+ send: (id, message) => Effect.sync(() => sendUnsafe(id, message))
55
+ });
56
+ }
57
+ return WorkerRunner.WorkerRunnerPlatform.of({ start: startRunner });
58
+ }
59
+ //#endregion
60
+ export { withWorkerPlatform, workerRunner };
61
+
62
+ //# sourceMappingURL=platform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.js","names":[],"sources":["../../src/worker/platform.ts"],"sourcesContent":["import { Deferred, Effect, Exit, FiberSet, Scope } from \"effect\";\nimport { Worker, WorkerRunner } from \"effect/workers\";\nimport { WorkerError, WorkerReceiveError } from \"effect/workers/WorkerError\";\nimport type { WorkerPort } from \"@party-stack/expo-worker\";\n\nexport type ExpoWorkerPort = WorkerPort<unknown, unknown>;\n\nfunction receivedError(cause: unknown) {\n return new WorkerError({\n reason: new WorkerReceiveError({ message: \"Expo ontology worker connection failed.\", cause }),\n });\n}\n\nconst platform = Worker.makePlatform<ExpoWorkerPort>()({\n setup: ({ worker, scope }) =>\n Effect.as(\n Scope.addFinalizer(scope, Effect.try(() => worker.postMessage([1])).pipe(Effect.ignore)),\n worker\n ),\n listen: ({ port, emit, deferred, scope }) =>\n Effect.acquireRelease(\n Effect.sync(() => {\n let ready = false;\n const unsubscribe = port.subscribe(\n (message) => {\n if (!Array.isArray(message)) return;\n if (message[0] === 0) {\n if (ready) return;\n ready = true;\n }\n emit(message);\n },\n (cause) => Deferred.doneUnsafe(deferred, Exit.fail(receivedError(cause)))\n );\n // Either side may finish registering its listener first. Ask the\n // runner to repeat the ready frame if its initial one was missed.\n try {\n port.postMessage(null);\n } catch (cause) {\n Deferred.doneUnsafe(deferred, Exit.fail(receivedError(cause)));\n }\n return unsubscribe;\n }),\n (unsubscribe) => Effect.sync(unsubscribe)\n ).pipe(Scope.provide(scope), Effect.asVoid),\n});\n\nexport function withWorkerPlatform<A, E, R>(effect: Effect.Effect<A, E, R>, endpoint: ExpoWorkerPort) {\n return effect.pipe(\n Effect.provideService(Worker.WorkerPlatform, platform),\n Effect.provideService(Worker.Spawner, () => endpoint)\n );\n}\n\nexport function workerRunner(endpoint: ExpoWorkerPort): WorkerRunner.WorkerRunnerPlatform[\"Service\"] {\n function startRunner<O, I>(): Effect.Effect<WorkerRunner.WorkerRunner<O, I>, WorkerError> {\n const sendUnsafe = (_id: number, message: O) => endpoint.postMessage([1, message]);\n const run: WorkerRunner.WorkerRunner<O, I>[\"run\"] = <A, E, R>(\n handler: (portId: number, message: I) => Effect.Effect<A, E, R> | void\n ) =>\n Effect.scoped(\n Effect.gen(function* () {\n const closed = yield* Deferred.make<void, WorkerError>();\n const fibers = yield* FiberSet.make<A, E>();\n const start = yield* FiberSet.runtime(fibers)<R>();\n yield* Effect.acquireRelease(\n Effect.sync(() =>\n endpoint.subscribe(\n (message) => {\n if (message === null) {\n endpoint.postMessage([0]);\n } else if (Array.isArray(message) && message[0] === 0) {\n const effect = handler(0, message[1] as I);\n if (effect) start(effect);\n } else if (Array.isArray(message) && message[0] === 1) {\n Deferred.doneUnsafe(closed, Exit.void);\n }\n },\n (cause) => Deferred.doneUnsafe(closed, Exit.fail(receivedError(cause)))\n )\n ),\n (unsubscribe) => Effect.sync(unsubscribe)\n );\n yield* Effect.sync(() => endpoint.postMessage([0]));\n yield* Effect.raceFirst(\n Deferred.await(closed),\n FiberSet.join(fibers).pipe(Effect.mapError(receivedError))\n );\n })\n );\n return Effect.succeed({\n run,\n sendUnsafe,\n send: (id, message) => Effect.sync(() => sendUnsafe(id, message)),\n });\n }\n return WorkerRunner.WorkerRunnerPlatform.of({ start: startRunner });\n}\n"],"mappings":";;;;AAOA,SAAS,cAAc,OAAgB;CACnC,OAAO,IAAI,YAAY,EACnB,QAAQ,IAAI,mBAAmB;EAAE,SAAS;EAA2C;CAAM,CAAC,EAChG,CAAC;AACL;AAEA,MAAM,WAAW,OAAO,aAA6B,CAAC,CAAC;CACnD,QAAQ,EAAE,QAAQ,YACd,OAAO,GACH,MAAM,aAAa,OAAO,OAAO,UAAU,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,CAAC,GACvF,MACJ;CACJ,SAAS,EAAE,MAAM,MAAM,UAAU,YAC7B,OAAO,eACH,OAAO,WAAW;EACd,IAAI,QAAQ;EACZ,MAAM,cAAc,KAAK,WACpB,YAAY;GACT,IAAI,CAAC,MAAM,QAAQ,OAAO,GAAG;GAC7B,IAAI,QAAQ,OAAO,GAAG;IAClB,IAAI,OAAO;IACX,QAAQ;GACZ;GACA,KAAK,OAAO;EAChB,IACC,UAAU,SAAS,WAAW,UAAU,KAAK,KAAK,cAAc,KAAK,CAAC,CAAC,CAC5E;EAGA,IAAI;GACA,KAAK,YAAY,IAAI;EACzB,SAAS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AK,OAAO,SAAS,aAAa,CAAC,CAC7D;EACJ,CAAC,CACL;EACJ,OAAO,OAAO,QAAQ;GAClB;GACA;GACA,OAAO,IAAI,YAAY,OAAO,WAAW,WAAW,IAAI,OAAO,CAAC;EACpE,CAAC;CACL;CACA,OAAO,aAAa,qBAAqB,GAAG,EAAE,OAAO,YAAY,CAAC;AACtE"}
@@ -0,0 +1,23 @@
1
+ import { ExpoWorkerPort } from "./platform.js";
2
+ import { Runtimes, RuntimesLayer } from "@party-stack/runtime";
3
+ import { Effect, Scope } from "effect";
4
+ import { OntologyServer } from "@party-stack/ontology-server";
5
+ //#region src/worker/runner.d.ts
6
+ interface ReplicaOwner<C> {
7
+ /** Stable identity of the durable data, shared by all hosts that can open it. */
8
+ readonly owner: (config: C) => string;
9
+ /** Stable application namespace for the ownership lease. */
10
+ readonly namespace?: string;
11
+ }
12
+ /** Advanced entry point for workers serving several protocols from one durable owner. */
13
+ export declare function runExpoReplicaWorker<C>(options: ReplicaOwner<C> & {
14
+ readonly run: (config: C, port: ExpoWorkerPort, ready: () => void) => Effect.Effect<void, unknown, Scope.Scope>;
15
+ }): void;
16
+ /** Install a dedicated worker handler that owns the persistent Expo runtime and ontology RPC server. */
17
+ export declare function serveOntologyWorker<C>(options: ReplicaOwner<C> & {
18
+ readonly open: (config: C) => Effect.Effect<OntologyServer, unknown, Scope.Scope | Runtimes>;
19
+ readonly runtime?: RuntimesLayer;
20
+ }): void;
21
+ //#endregion
22
+ export {};
23
+ //# sourceMappingURL=runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.d.ts","names":[],"sources":["../../src/worker/runner.ts"],"mappings":";;;;;UASU,aAAa;;WAEV,QAAQ,QAAQ;;WAEhB;;;wBAIG,qBAAqB,GACjC,SAAS,aAAa;WACT,MACL,QAAQ,GACR,MAAM,gBACN,sBACC,OAAO,sBAAsB,MAAM;;;wBA0BhC,oBAAoB,GAChC,SAAS,aAAa;WACT,OAAO,QAAQ,MAAM,OAAO,OAAO,yBAAyB,MAAM,QAAQ;WAC1E,UAAU"}
@@ -0,0 +1,33 @@
1
+ import { workerRunner } from "./platform.js";
2
+ import { Effect, Fiber, Layer } from "effect";
3
+ import { serveOntologyWorker as serveOntologyWorker$1 } from "@party-stack/ontology-server/rpc/worker";
4
+ import { WorkerRunner } from "effect/workers";
5
+ import { runExpoWorker } from "@party-stack/expo-worker/runner";
6
+ //#region src/worker/runner.ts
7
+ /** Advanced entry point for workers serving several protocols from one durable owner. */
8
+ function runExpoReplicaWorker(options) {
9
+ runExpoWorker((config, port, signal, ready) => Effect.runPromise(Effect.scoped(Effect.gen(function* () {
10
+ const [{ hashStorageName }, { openSqliteClient }] = yield* Effect.promise(() => Promise.all([import("../hashStorageName.js"), import("../internal/sqlite.js")]));
11
+ const hash = yield* Effect.promise(() => hashStorageName(options.owner(config)));
12
+ const lease = yield* openSqliteClient(`${options.namespace ?? "party-stack"}-worker-owner-${hash}.db`);
13
+ yield* lease`PRAGMA busy_timeout = 0`;
14
+ yield* lease`BEGIN IMMEDIATE`;
15
+ yield* options.run(config, port, ready);
16
+ })), { signal }));
17
+ }
18
+ /** Install a dedicated worker handler that owns the persistent Expo runtime and ontology RPC server. */
19
+ function serveOntologyWorker(options) {
20
+ runExpoReplicaWorker({
21
+ ...options,
22
+ run: (config, port, ready) => Effect.gen(function* () {
23
+ const server = yield* options.open(config);
24
+ const rpc = yield* serveOntologyWorker$1(server).pipe(Effect.provideService(WorkerRunner.WorkerRunnerPlatform, workerRunner(port)));
25
+ ready();
26
+ yield* Fiber.join(rpc);
27
+ }).pipe(Effect.provide(options.runtime ?? Layer.unwrap(Effect.promise(async () => (await import("../createExpoRuntime.js")).expoRuntime({ geolocation: false })))))
28
+ });
29
+ }
30
+ //#endregion
31
+ export { runExpoReplicaWorker, serveOntologyWorker };
32
+
33
+ //# sourceMappingURL=runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.js","names":["serveRpc"],"sources":["../../src/worker/runner.ts"],"sourcesContent":["import { runExpoWorker } from \"@party-stack/expo-worker/runner\";\nimport { serveOntologyWorker as serveRpc } from \"@party-stack/ontology-server/rpc/worker\";\nimport { Effect, Fiber, Layer } from \"effect\";\nimport { WorkerRunner } from \"effect/workers\";\nimport { workerRunner, type ExpoWorkerPort } from \"./platform.js\";\nimport type { OntologyServer } from \"@party-stack/ontology-server\";\nimport type { Runtimes, RuntimesLayer } from \"@party-stack/runtime\";\nimport type { Scope } from \"effect\";\n\ninterface ReplicaOwner<C> {\n /** Stable identity of the durable data, shared by all hosts that can open it. */\n readonly owner: (config: C) => string;\n /** Stable application namespace for the ownership lease. */\n readonly namespace?: string;\n}\n\n/** Advanced entry point for workers serving several protocols from one durable owner. */\nexport function runExpoReplicaWorker<C>(\n options: ReplicaOwner<C> & {\n readonly run: (\n config: C,\n port: ExpoWorkerPort,\n ready: () => void\n ) => Effect.Effect<void, unknown, Scope.Scope>;\n }\n) {\n runExpoWorker<C>((config, port, signal, ready) =>\n Effect.runPromise(\n Effect.scoped(\n Effect.gen(function* () {\n const [{ hashStorageName }, { openSqliteClient }] = yield* Effect.promise(() =>\n Promise.all([import(\"../hashStorageName.js\"), import(\"../internal/sqlite.js\")])\n );\n const hash = yield* Effect.promise(() => hashStorageName(options.owner(config)));\n const lease = yield* openSqliteClient(\n `${options.namespace ?? \"party-stack\"}-worker-owner-${hash}.db`\n );\n yield* lease`PRAGMA busy_timeout = 0`;\n yield* lease`BEGIN IMMEDIATE`;\n // Release the application's server and partitions before closing the lease connection.\n yield* options.run(config, port, ready);\n })\n ),\n { signal }\n )\n );\n}\n\n/** Install a dedicated worker handler that owns the persistent Expo runtime and ontology RPC server. */\nexport function serveOntologyWorker<C>(\n options: ReplicaOwner<C> & {\n readonly open: (config: C) => Effect.Effect<OntologyServer, unknown, Scope.Scope | Runtimes>;\n readonly runtime?: RuntimesLayer;\n }\n) {\n runExpoReplicaWorker<C>({\n ...options,\n run: (config, port, ready) =>\n Effect.gen(function* () {\n const server = yield* options.open(config);\n const rpc = yield* serveRpc(server).pipe(\n Effect.provideService(WorkerRunner.WorkerRunnerPlatform, workerRunner(port))\n );\n ready();\n yield* Fiber.join(rpc);\n }).pipe(\n Effect.provide(\n options.runtime ??\n Layer.unwrap(\n Effect.promise(async () =>\n (await import(\"../createExpoRuntime.js\")).expoRuntime({ geolocation: false })\n )\n )\n )\n ),\n });\n}\n"],"mappings":";;;;;;;AAiBA,SAAgB,qBACZ,SAOF;CACE,eAAkB,QAAQ,MAAM,QAAQ,UACpC,OAAO,WACH,OAAO,OACH,OAAO,IAAI,aAAa;EACpB,MAAM,CAAC,EAAE,mBAAmB,EAAE,sBAAsB,OAAO,OAAO,cAC9D,QAAQ,IAAI,CAAC,OAAO,0BAA0B,OAAO,wBAAwB,CAAC,CAClF;EACA,MAAM,OAAO,OAAO,OAAO,cAAc,gBAAgB,QAAQ,MAAM,MAAM,CAAC,CAAC;EAC/E,MAAM,QAAQ,OAAO,iBACjB,GAAG,QAAQ,aAAa,cAAc,gBAAgB,KAAK,IAC/D;EACA,OAAO,KAAK;EACZ,OAAO,KAAK;EAEZ,OAAO,QAAQ,IAAI,QAAQ,MAAM,KAAK;CAC1C,CAAC,CACL,GACA,EAAE,OAAO,CACb,CACJ;AACJ;;AAGA,SAAgB,oBACZ,SAIF;CACE,qBAAwB;EACpB,GAAG;EACH,MAAM,QAAQ,MAAM,UAChB,OAAO,IAAI,aAAa;GACpB,MAAM,SAAS,OAAO,QAAQ,KAAK,MAAM;GACzC,MAAM,MAAM,OAAOA,sBAAS,MAAM,CAAC,CAAC,KAChC,OAAO,eAAe,aAAa,sBAAsB,aAAa,IAAI,CAAC,CAC/E;GACA,MAAM;GACN,OAAO,MAAM,KAAK,GAAG;EACzB,CAAC,CAAC,CAAC,KACC,OAAO,QACH,QAAQ,WACJ,MAAM,OACF,OAAO,QAAQ,aACV,MAAM,OAAO,2BAAA,CAA4B,YAAY,EAAE,aAAa,MAAM,CAAC,CAChF,CACJ,CACR,CACJ;CACR,CAAC;AACL"}
package/package.json CHANGED
@@ -1,13 +1,15 @@
1
1
  {
2
2
  "name": "@party-stack/expo-runtime",
3
- "version": "0.7.2",
3
+ "version": "1.0.0",
4
4
  "files": [
5
5
  "lib",
6
- "plugin"
6
+ "plugin",
7
+ "worker-bootstrap.cjs"
7
8
  ],
8
9
  "type": "module",
9
10
  "sideEffects": [
10
- "./lib/polyfill.js"
11
+ "./lib/polyfill.js",
12
+ "./worker-bootstrap.cjs"
11
13
  ],
12
14
  "exports": {
13
15
  ".": {
@@ -21,7 +23,16 @@
21
23
  "./plugin": {
22
24
  "types": "./plugin/index.d.cts",
23
25
  "default": "./plugin/index.cjs"
24
- }
26
+ },
27
+ "./worker": {
28
+ "types": "./lib/worker/index.d.ts",
29
+ "default": "./lib/worker/index.js"
30
+ },
31
+ "./worker/runner": {
32
+ "types": "./lib/worker/runner.d.ts",
33
+ "default": "./lib/worker/runner.js"
34
+ },
35
+ "./worker/bootstrap": "./worker-bootstrap.cjs"
25
36
  },
26
37
  "dependencies": {
27
38
  "effect": "^4.0.5",
@@ -31,24 +42,39 @@
31
42
  "expo-secure-store": "^57.0.4",
32
43
  "expo-web-browser": "^57.0.3",
33
44
  "temporal-polyfill": "^0.3.0",
34
- "@party-stack/ontology-storage": "0.4.3",
35
- "@party-stack/runtime": "0.7.2",
36
- "@party-stack/sql-ontology-storage": "0.3.5"
45
+ "@party-stack/ontology-backend": "0.8.3",
46
+ "@party-stack/ontology-server": "0.15.3",
47
+ "@party-stack/ontology-storage": "0.4.4",
48
+ "@party-stack/runtime": "0.7.3",
49
+ "@party-stack/sql-ontology-storage": "0.3.6"
37
50
  },
38
51
  "devDependencies": {
52
+ "@effect/sql-sqlite-react-native": "^4.0.5",
53
+ "@op-engineering/op-sqlite": "^17.1.2",
39
54
  "@react-native-community/netinfo": "^12.0.1",
40
55
  "expo": "^57.0.29",
41
56
  "expo-file-system": "^57.0.7",
42
- "expo-sqlite": "^57.0.4",
43
57
  "typescript": "~7.0.2",
44
58
  "vite": "npm:@voidzero-dev/vite-plus-core@1.2.0",
45
59
  "vite-plus": "1.2.0",
46
- "@party-stack/build-config": "0.2.0"
60
+ "@party-stack/build-config": "0.2.0",
61
+ "@party-stack/expo-worker": "0.1.0"
47
62
  },
48
63
  "peerDependencies": {
64
+ "@effect/sql-sqlite-react-native": "^4.0.5",
65
+ "@op-engineering/op-sqlite": ">=17.1.2 <19",
49
66
  "@react-native-community/netinfo": "^12.0.1",
50
67
  "expo": "^57.0.29",
51
68
  "expo-file-system": "^57.0.7",
52
- "expo-sqlite": "^57.0.4"
69
+ "react-native": "0.86.x",
70
+ "@party-stack/expo-worker": "0.1.0"
71
+ },
72
+ "peerDependenciesMeta": {
73
+ "@party-stack/expo-worker": {
74
+ "optional": true
75
+ },
76
+ "react-native": {
77
+ "optional": true
78
+ }
53
79
  }
54
80
  }
package/plugin/index.cjs CHANGED
@@ -1,6 +1,5 @@
1
1
  const { createRunOncePlugin, withPlugins } = require("expo/config-plugins");
2
2
  const withSecureStore = require("expo-secure-store/app.plugin.js").default;
3
- const withSQLite = require("expo-sqlite/app.plugin.js").default;
4
3
  const withLocation = require("expo-location/app.plugin.js").default;
5
4
  const { name, version } = require("../package.json");
6
5
 
@@ -17,7 +16,6 @@ const withPartyStack = (config, options = {}) =>
17
16
  faceIDPermission: config.ios?.infoPlist?.NSFaceIDUsageDescription ?? false,
18
17
  },
19
18
  ],
20
- [withSQLite, {}],
21
19
  [
22
20
  withLocation,
23
21
  {
@@ -0,0 +1,29 @@
1
+ // Install native Expo modules before evaluating packages that read them at import time.
2
+ const { installExpoWorkerModules } = require("@party-stack/expo-worker/bootstrap");
3
+ installExpoWorkerModules([
4
+ "AesCryptoModule",
5
+ "AssetModule",
6
+ "ExpoBlob",
7
+ "BlobModule",
8
+ "ConstantsModule",
9
+ "CryptoModule",
10
+ "ExpoFetchModule",
11
+ "FileSystemModule",
12
+ "FileSystemLegacyModule",
13
+ "SecureStoreModule",
14
+ "WebBrowserModule",
15
+ ]);
16
+ globalThis.Event ??= require("react-native/src/private/webapis/dom/events/Event").default;
17
+ globalThis.EventTarget ??= require("react-native/src/private/webapis/dom/events/EventTarget").default;
18
+ globalThis.CustomEvent ??= require("react-native/src/private/webapis/dom/events/CustomEvent").default;
19
+ require("react-native/Libraries/Core/setUpXHR");
20
+ globalThis.TextDecoder ??= require("expo/src/winter/TextDecoder").TextDecoder;
21
+ const expoUrl = require("expo/src/winter/url");
22
+ globalThis.URL = expoUrl.URL;
23
+ globalThis.URLSearchParams = expoUrl.URLSearchParams;
24
+ globalThis.DOMException ??= require("expo/src/winter/DOMException").DOMException;
25
+ require("expo/src/winter/AbortSignal").installAbortSignalPatch(AbortSignal);
26
+ // Resolving Headers installs RN's Request and Response before switching to Expo fetch.
27
+ if (!globalThis.Headers) throw new Error("Expo worker fetch requires Headers");
28
+ globalThis.fetch = require("expo/fetch").fetch;
29
+ require("./lib/polyfill.js");