@party-stack/expo-runtime 0.5.0 → 0.6.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 +14 -0
- package/lib/createExpoGeolocation.d.ts +41 -0
- package/lib/createExpoGeolocation.d.ts.map +1 -0
- package/lib/createExpoGeolocation.js +66 -0
- package/lib/createExpoGeolocation.js.map +1 -0
- package/lib/createExpoRuntime.d.ts +5 -1
- package/lib/createExpoRuntime.d.ts.map +1 -1
- package/lib/createExpoRuntime.js +11 -1
- package/lib/createExpoRuntime.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +3 -1
- package/lib/polyfill.js +26 -0
- package/lib/polyfill.js.map +1 -1
- package/lib/timeSlicedImmediate.d.ts +23 -0
- package/lib/timeSlicedImmediate.d.ts.map +1 -0
- package/lib/timeSlicedImmediate.js +52 -0
- package/lib/timeSlicedImmediate.js.map +1 -0
- package/package.json +5 -4
- package/plugin/index.cjs +13 -1
- package/plugin/index.d.cts +4 -0
package/README.md
CHANGED
|
@@ -69,6 +69,20 @@ description is preserved. WebBrowser's default plugin adds no configuration, so
|
|
|
69
69
|
it is not included; the experimental Android launcher activity stays disabled.
|
|
70
70
|
Your application still supplies its OAuth redirect scheme/URL.
|
|
71
71
|
|
|
72
|
+
The plugin also composes expo-location's plugin for foreground location only: it adds
|
|
73
|
+
the iOS "when in use" purpose string (keeping yours, or pass
|
|
74
|
+
`{ "locationPermission": "…" }`) and never requests background location. Pass
|
|
75
|
+
`{ "locationPermission": false }` for an app that never reads location.
|
|
76
|
+
|
|
77
|
+
## Device location
|
|
78
|
+
|
|
79
|
+
`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
|
|
81
|
+
`GeolocationError` whose `reason` is `PermissionDenied`, `PositionUnavailable` or
|
|
82
|
+
`Timeout`; without a fresh fix it falls back to one at most five minutes old. Pass
|
|
83
|
+
`geolocation: false` to `expoRuntime` to leave it out. The web runtime provides the
|
|
84
|
+
same service over `navigator.geolocation`.
|
|
85
|
+
|
|
72
86
|
If you maintain custom Android backup rules, include equivalent SecureStore
|
|
73
87
|
exclusions yourself, then configure:
|
|
74
88
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Geolocation } from "@party-stack/runtime";
|
|
2
|
+
//#region src/createExpoGeolocation.d.ts
|
|
3
|
+
interface ExpoLocationObject {
|
|
4
|
+
readonly coords: {
|
|
5
|
+
readonly latitude: number;
|
|
6
|
+
readonly longitude: number;
|
|
7
|
+
readonly accuracy: number | null;
|
|
8
|
+
readonly altitude: number | null;
|
|
9
|
+
readonly altitudeAccuracy: number | null;
|
|
10
|
+
readonly heading: number | null;
|
|
11
|
+
readonly speed: number | null;
|
|
12
|
+
};
|
|
13
|
+
readonly timestamp: number;
|
|
14
|
+
}
|
|
15
|
+
/** The parts of `expo-location` this uses; tests pass a fake. */
|
|
16
|
+
export interface ExpoLocationModule {
|
|
17
|
+
readonly requestForegroundPermissionsAsync: () => Promise<{
|
|
18
|
+
readonly status: string;
|
|
19
|
+
}>;
|
|
20
|
+
readonly getCurrentPositionAsync: (options?: {
|
|
21
|
+
accuracy?: number;
|
|
22
|
+
}) => Promise<ExpoLocationObject>;
|
|
23
|
+
readonly getLastKnownPositionAsync: (options?: {
|
|
24
|
+
maxAge?: number;
|
|
25
|
+
requiredAccuracy?: number;
|
|
26
|
+
}) => Promise<ExpoLocationObject | null>;
|
|
27
|
+
readonly watchPositionAsync: (options: {
|
|
28
|
+
accuracy?: number;
|
|
29
|
+
}, callback: (location: ExpoLocationObject) => void, errorHandler?: (reason: string) => void) => Promise<{
|
|
30
|
+
remove(): void;
|
|
31
|
+
}>;
|
|
32
|
+
readonly Accuracy: {
|
|
33
|
+
readonly Balanced: number;
|
|
34
|
+
readonly High: number;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/** Device location through expo-location, with the web API's options and reasons. */
|
|
38
|
+
export declare function createExpoGeolocation(location?: ExpoLocationModule): Geolocation;
|
|
39
|
+
//#endregion
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=createExpoGeolocation.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { GeolocationError } from "@party-stack/runtime";
|
|
2
|
+
import { Cause, Effect, Option, Queue, Stream } from "effect";
|
|
3
|
+
import * as ExpoLocation from "expo-location";
|
|
4
|
+
//#region src/createExpoGeolocation.ts
|
|
5
|
+
/** A recent cached fix is better than failing when GPS can't produce a new one. */
|
|
6
|
+
const lastKnownMaxAgeMs = 3e5;
|
|
7
|
+
const lastKnownRequiredAccuracyM = 1e3;
|
|
8
|
+
const fail = (reason, message, cause) => new GeolocationError({
|
|
9
|
+
reason,
|
|
10
|
+
message,
|
|
11
|
+
cause
|
|
12
|
+
});
|
|
13
|
+
const toPosition = ({ coords, timestamp }) => ({
|
|
14
|
+
coords: {
|
|
15
|
+
latitude: coords.latitude,
|
|
16
|
+
longitude: coords.longitude,
|
|
17
|
+
accuracy: coords.accuracy ?? 0,
|
|
18
|
+
altitude: coords.altitude,
|
|
19
|
+
altitudeAccuracy: coords.altitudeAccuracy,
|
|
20
|
+
heading: coords.heading,
|
|
21
|
+
speed: coords.speed
|
|
22
|
+
},
|
|
23
|
+
timestamp
|
|
24
|
+
});
|
|
25
|
+
/** Device location through expo-location, with the web API's options and reasons. */
|
|
26
|
+
function createExpoGeolocation(location = ExpoLocation) {
|
|
27
|
+
const permitted = Effect.tryPromise({
|
|
28
|
+
try: () => location.requestForegroundPermissionsAsync(),
|
|
29
|
+
catch: (cause) => fail("PermissionDenied", "Location permission could not be requested.", cause)
|
|
30
|
+
}).pipe(Effect.flatMap((permission) => permission.status === "granted" ? Effect.void : Effect.fail(fail("PermissionDenied", "Location permission was denied."))));
|
|
31
|
+
const accuracy = (options) => options?.enableHighAccuracy ? location.Accuracy.High : location.Accuracy.Balanced;
|
|
32
|
+
const lastKnown = (options) => Effect.tryPromise(() => location.getLastKnownPositionAsync({
|
|
33
|
+
maxAge: options?.maximumAge ?? lastKnownMaxAgeMs,
|
|
34
|
+
requiredAccuracy: lastKnownRequiredAccuracyM
|
|
35
|
+
})).pipe(Effect.map((value) => Option.fromNullishOr(value)), Effect.orElseSucceed(() => Option.none()));
|
|
36
|
+
return {
|
|
37
|
+
getCurrentPosition: (options) => Effect.gen(function* () {
|
|
38
|
+
yield* permitted;
|
|
39
|
+
const current = Effect.tryPromise({
|
|
40
|
+
try: () => location.getCurrentPositionAsync({ accuracy: accuracy(options) }),
|
|
41
|
+
catch: (cause) => fail("PositionUnavailable", "Your location isn't available right now.", cause)
|
|
42
|
+
});
|
|
43
|
+
const timeout = options?.timeout;
|
|
44
|
+
const result = yield* Effect.result(timeout !== void 0 && Number.isFinite(timeout) ? current.pipe(Effect.timeoutOrElse({
|
|
45
|
+
duration: timeout,
|
|
46
|
+
orElse: () => Effect.fail(fail("Timeout", "Finding your location timed out."))
|
|
47
|
+
})) : current);
|
|
48
|
+
if (result._tag === "Success") return toPosition(result.success);
|
|
49
|
+
const cached = yield* lastKnown(options);
|
|
50
|
+
if (Option.isSome(cached)) return toPosition(cached.value);
|
|
51
|
+
return yield* result.failure;
|
|
52
|
+
}),
|
|
53
|
+
watchPosition: (options) => Stream.unwrap(Effect.as(permitted, Stream.callback((queue) => Effect.acquireRelease(Effect.tryPromise({
|
|
54
|
+
try: () => location.watchPositionAsync({ accuracy: accuracy(options) }, (value) => {
|
|
55
|
+
Queue.offerUnsafe(queue, toPosition(value));
|
|
56
|
+
}, (reason) => {
|
|
57
|
+
Queue.failCauseUnsafe(queue, Cause.fail(fail("PositionUnavailable", "Your location isn't available right now.", reason)));
|
|
58
|
+
}),
|
|
59
|
+
catch: (cause) => fail("PositionUnavailable", "Your location isn't available right now.", cause)
|
|
60
|
+
}), (subscription) => Effect.sync(() => subscription.remove())))))
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
export { createExpoGeolocation };
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=createExpoGeolocation.js.map
|
|
@@ -0,0 +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,YAAY,YACd,SAAS,qBAAqB,SAAS,SAAS,OAAO,SAAS,SAAS;CAC7E,MAAM,aAAa,YACf,OAAO,iBACH,SAAS,0BAA0B;EAC/B,QAAQ,SAAS,cAAc;EAC/B,kBAAkB;CACtB,CAAC,CACL,CAAC,CAAC,KACE,OAAO,KAAK,UAAU,OAAO,cAAc,KAAK,CAAC,GACjD,OAAO,oBAAoB,OAAO,KAAyB,CAAC,CAChE;CACJ,OAAO;EACH,qBAAqB,YACjB,OAAO,IAAI,aAAa;GACpB,OAAO;GACP,MAAM,UAAU,OAAO,WAAW;IAC9B,WAAW,SAAS,wBAAwB,EAAE,UAAU,SAAS,OAAO,EAAE,CAAC;IAC3E,QAAQ,UACJ,KAAK,uBAAuB,4CAA4C,KAAK;GACrF,CAAC;GACD,MAAM,UAAU,SAAS;GACzB,MAAM,SAAS,OAAO,OAAO,OACzB,YAAY,KAAA,KAAa,OAAO,SAAS,OAAO,IAC1C,QAAQ,KACJ,OAAO,cAAc;IACjB,UAAU;IACV,cACI,OAAO,KAAK,KAAK,WAAW,kCAAkC,CAAC;GACvE,CAAC,CACL,IACA,OACV;GACA,IAAI,OAAO,SAAS,WAAW,OAAO,WAAW,OAAO,OAAO;GAC/D,MAAM,SAAS,OAAO,UAAU,OAAO;GACvC,IAAI,OAAO,OAAO,MAAM,GAAG,OAAO,WAAW,OAAO,KAAK;GACzD,OAAO,OAAO,OAAO;EACzB,CAAC;EACL,gBAAgB,YACZ,OAAO,OACH,OAAO,GACH,WACA,OAAO,UAAiD,UACpD,OAAO,eACH,OAAO,WAAW;GACd,WACI,SAAS,mBACL,EAAE,UAAU,SAAS,OAAO,EAAE,IAC7B,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,9 +1,13 @@
|
|
|
1
|
-
import { Runtime, RuntimeError, RuntimePartition, Runtimes } from "@party-stack/runtime";
|
|
1
|
+
import { Geolocation, Runtime, RuntimeError, RuntimePartition, Runtimes } from "@party-stack/runtime";
|
|
2
2
|
import { Effect, Layer } from "effect";
|
|
3
3
|
//#region src/createExpoRuntime.d.ts
|
|
4
4
|
export interface ExpoRuntimeOptions {
|
|
5
5
|
/** Persistent SQLite/filesystem storage by default; memory keeps native platform capabilities. */
|
|
6
6
|
readonly storage?: "persistent" | "memory";
|
|
7
|
+
/** Device location through expo-location by default. Permission is requested on
|
|
8
|
+
* first use; add expo-location's config plugin for the platform purpose strings.
|
|
9
|
+
* Pass `false` for none. */
|
|
10
|
+
readonly geolocation?: Geolocation | false;
|
|
7
11
|
}
|
|
8
12
|
export declare const make: (options?: ExpoRuntimeOptions | undefined) => Effect.Effect<import("@party-stack/runtime").RuntimeService, import("@party-stack/ontology-storage").OntologyStorageError | RuntimeError, RuntimePartition | import("effect/Scope").Scope>;
|
|
9
13
|
export declare const layer: (options?: ExpoRuntimeOptions) => Layer.Layer<Runtime, import("@party-stack/ontology-storage").OntologyStorageError | RuntimeError, RuntimePartition>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createExpoRuntime.d.ts","names":[],"sources":["../src/createExpoRuntime.ts"],"mappings":";;;
|
|
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;qBAyGJ,QAAK,UAAa,uBAAkB,MAAA,MAAA,iDAAA,uBAAA,cAAA;qBACpC,cAAW,UAAa,uBAAkB,MAAA,MAAA"}
|
package/lib/createExpoRuntime.js
CHANGED
|
@@ -3,10 +3,13 @@ import { ExpoFileSystemBlobBytesStore } from "./ExpoFileSystemBlobBytesStore.js"
|
|
|
3
3
|
import { makeKeyMaterialStore } from "./ExpoKeyMaterialStore.js";
|
|
4
4
|
import { makeExpoNetworkConnectivity } from "./ExpoNetworkConnectivity.js";
|
|
5
5
|
import { createExpoBrowserAuthentication } from "./createExpoBrowserAuthentication.js";
|
|
6
|
+
import { createExpoGeolocation } from "./createExpoGeolocation.js";
|
|
6
7
|
import { nativeKeyCodec } from "./encryptionKeys.js";
|
|
7
8
|
import { MemoryBlobBytesStore, Runtime, RuntimeError, RuntimePartition, Runtimes, makeKeyMaterialStoreKeyring } from "@party-stack/runtime";
|
|
8
9
|
import { Effect, Layer, Schema } from "effect";
|
|
9
10
|
import { Paths } from "expo-file-system";
|
|
11
|
+
import { CryptoDigestAlgorithm, digest } from "expo-crypto";
|
|
12
|
+
import { configureNativeSha256 } from "@party-stack/ontology-storage/blobs";
|
|
10
13
|
import { storageError } from "@party-stack/ontology-storage/driver";
|
|
11
14
|
import * as MemoryTables from "@party-stack/ontology-storage/memory/tables";
|
|
12
15
|
import * as SQLite from "@party-stack/sql-ontology-storage/sqlite";
|
|
@@ -15,6 +18,8 @@ import * as Reactivity from "effect/reactivity/Reactivity";
|
|
|
15
18
|
import * as SqlClient from "effect/sql/SqlClient";
|
|
16
19
|
import { deleteDatabaseAsync, openDatabaseAsync } from "expo-sqlite";
|
|
17
20
|
//#region src/createExpoRuntime.ts
|
|
21
|
+
configureNativeSha256((bytes) => digest(CryptoDigestAlgorithm.SHA256, bytes));
|
|
22
|
+
const geolocationOf = (options) => options.geolocation === false ? void 0 : options.geolocation ?? createExpoGeolocation();
|
|
18
23
|
const make = Effect.fn("ExpoRuntime.make")(function* (options = {}) {
|
|
19
24
|
const { owner, namespace } = yield* RuntimePartition;
|
|
20
25
|
const connectivity = yield* makeExpoNetworkConnectivity();
|
|
@@ -33,6 +38,7 @@ const make = Effect.fn("ExpoRuntime.make")(function* (options = {}) {
|
|
|
33
38
|
})
|
|
34
39
|
}, nativeKeyCodec),
|
|
35
40
|
browserAuthentication: createExpoBrowserAuthentication(),
|
|
41
|
+
geolocation: geolocationOf(options),
|
|
36
42
|
connectivity,
|
|
37
43
|
capacity: {
|
|
38
44
|
memory: Effect.succeed(void 0),
|
|
@@ -95,6 +101,7 @@ const make = Effect.fn("ExpoRuntime.make")(function* (options = {}) {
|
|
|
95
101
|
})
|
|
96
102
|
},
|
|
97
103
|
browserAuthentication: createExpoBrowserAuthentication(),
|
|
104
|
+
geolocation: geolocationOf(options),
|
|
98
105
|
encryptionKeyring,
|
|
99
106
|
connectivity,
|
|
100
107
|
tables: ownedTables,
|
|
@@ -112,7 +119,10 @@ const make = Effect.fn("ExpoRuntime.make")(function* (options = {}) {
|
|
|
112
119
|
});
|
|
113
120
|
});
|
|
114
121
|
const layer = (options = {}) => Layer.effect(Runtime, make(options));
|
|
115
|
-
const expoRuntime = (options = {}) => Runtimes.layer(layer(options), {
|
|
122
|
+
const expoRuntime = (options = {}) => Runtimes.layer(layer(options), {
|
|
123
|
+
browserAuthentication: createExpoBrowserAuthentication(),
|
|
124
|
+
geolocation: geolocationOf(options)
|
|
125
|
+
});
|
|
116
126
|
//#endregion
|
|
117
127
|
export { expoRuntime, layer, make };
|
|
118
128
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createExpoRuntime.js","names":[],"sources":["../src/createExpoRuntime.ts"],"sourcesContent":["import { 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 { Paths } from \"expo-file-system\";\nimport { deleteDatabaseAsync, openDatabaseAsync } from \"expo-sqlite\";\nimport { createExpoBrowserAuthentication } from \"./createExpoBrowserAuthentication.js\";\nimport { nativeKeyCodec } from \"./encryptionKeys.js\";\nimport { ExpoFileSystemBlobBytesStore } from \"./ExpoFileSystemBlobBytesStore.js\";\nimport { makeKeyMaterialStore } from \"./ExpoKeyMaterialStore.js\";\nimport { makeExpoNetworkConnectivity } from \"./ExpoNetworkConnectivity.js\";\nimport { hashStorageName } from \"./hashStorageName.js\";\nimport type { SQLiteBindValue } from \"expo-sqlite\";\n\nexport interface ExpoRuntimeOptions {\n /** Persistent SQLite/filesystem storage by default; memory keeps native platform capabilities. */\n readonly storage?: \"persistent\" | \"memory\";\n}\n\nexport const make = Effect.fn(\"ExpoRuntime.make\")(function* (options: ExpoRuntimeOptions = {}) {\n const { owner, namespace } = yield* RuntimePartition;\n const connectivity = yield* makeExpoNetworkConnectivity();\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 connectivity,\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 return yield* SqlTables.make().pipe(Effect.provideService(SqlClient.SqlClient, sql));\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 encryptionKeyring,\n connectivity,\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), { browserAuthentication: createExpoBrowserAuthentication() });\n"],"mappings":"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"}
|
|
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 { makeExpoNetworkConnectivity } 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 connectivity = yield* makeExpoNetworkConnectivity();\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 connectivity,\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 return yield* SqlTables.make().pipe(Effect.provideService(SqlClient.SqlClient, sql));\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 connectivity,\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":"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"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import { ExpoLocationModule, createExpoGeolocation } from "./createExpoGeolocation.js";
|
|
1
2
|
import { ExpoRuntimeOptions, expoRuntime, layer, make } from "./createExpoRuntime.js";
|
|
2
|
-
export { type ExpoRuntimeOptions, expoRuntime, layer, make };
|
|
3
|
+
export { type ExpoLocationModule, type ExpoRuntimeOptions, createExpoGeolocation, expoRuntime, layer, make };
|
package/lib/index.js
CHANGED
package/lib/polyfill.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { makeTimeSlicedImmediate } from "./timeSlicedImmediate.js";
|
|
1
2
|
import { getRandomValues, randomUUID } from "expo-crypto";
|
|
2
3
|
import { Blob } from "expo-blob";
|
|
3
4
|
//#region src/polyfill.ts
|
|
@@ -40,6 +41,31 @@ var ExpoFile = class extends globalThis.Blob {
|
|
|
40
41
|
}
|
|
41
42
|
};
|
|
42
43
|
globalThis.File = ExpoFile;
|
|
44
|
+
if (typeof globalThis.AbortSignal === "function" && typeof globalThis.AbortSignal.prototype.throwIfAborted !== "function") Object.defineProperty(globalThis.AbortSignal.prototype, "throwIfAborted", {
|
|
45
|
+
configurable: true,
|
|
46
|
+
writable: true,
|
|
47
|
+
value: function throwIfAborted() {
|
|
48
|
+
if (!this.aborted) return;
|
|
49
|
+
throw this.reason ?? Object.assign(/* @__PURE__ */ new Error("The operation was aborted."), { name: "AbortError" });
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
if (typeof globalThis.Response === "function" && Reflect.get(globalThis.Response.prototype, Symbol.toStringTag) === void 0) Object.defineProperty(globalThis.Response.prototype, Symbol.toStringTag, {
|
|
53
|
+
value: "Response",
|
|
54
|
+
configurable: true
|
|
55
|
+
});
|
|
56
|
+
if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
|
|
57
|
+
const { setImmediate, clearImmediate } = makeTimeSlicedImmediate();
|
|
58
|
+
Object.defineProperty(globalThis, "setImmediate", {
|
|
59
|
+
value: setImmediate,
|
|
60
|
+
configurable: true,
|
|
61
|
+
writable: true
|
|
62
|
+
});
|
|
63
|
+
Object.defineProperty(globalThis, "clearImmediate", {
|
|
64
|
+
value: clearImmediate,
|
|
65
|
+
configurable: true,
|
|
66
|
+
writable: true
|
|
67
|
+
});
|
|
68
|
+
}
|
|
43
69
|
//#endregion
|
|
44
70
|
export {};
|
|
45
71
|
|
package/lib/polyfill.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polyfill.js","names":[],"sources":["../src/polyfill.ts"],"sourcesContent":["import { Blob } from \"expo-blob\";\nimport { getRandomValues, randomUUID } from \"expo-crypto\";\n\n// Native AES is provided separately; only install the secure randomness used by portable IDs and nonces.\nif (typeof globalThis.crypto === \"undefined\")\n Object.defineProperty(globalThis, \"crypto\", { value: {}, configurable: true });\nif (typeof globalThis.crypto.getRandomValues !== \"function\")\n Object.defineProperty(globalThis.crypto, \"getRandomValues\", {\n value: getRandomValues,\n configurable: true,\n });\nif (typeof globalThis.crypto.randomUUID !== \"function\")\n Object.defineProperty(globalThis.crypto, \"randomUUID\", { value: randomUUID, configurable: true });\n\n// Expo declarations predate the current DOM Blob byte-array generics.\nglobalThis.Blob = Blob as unknown as typeof globalThis.Blob;\n\n// React Native File extends its own Blob class, so replace it alongside Blob.\nclass ExpoFile extends globalThis.Blob implements File {\n readonly #name: string;\n readonly #lastModified: number;\n\n constructor(parts: BlobPart[], name: string, options: FilePropertyBag = {}) {\n super(parts, options);\n this.#name = String(name);\n this.#lastModified = options.lastModified ?? Date.now();\n // Expo FormData checks own descriptors before assigning a blob filename.\n // An inherited getter alone would make that assignment throw.\n Object.defineProperty(this, \"name\", { value: this.#name, enumerable: true });\n }\n\n get name(): string {\n return this.#name;\n }\n\n get lastModified(): number {\n return this.#lastModified;\n }\n\n get webkitRelativePath(): string {\n return \"\";\n }\n\n get [Symbol.toStringTag](): string {\n return \"File\";\n }\n}\n\nglobalThis.File = ExpoFile;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"polyfill.js","names":[],"sources":["../src/polyfill.ts"],"sourcesContent":["import { Blob } from \"expo-blob\";\nimport { getRandomValues, randomUUID } from \"expo-crypto\";\nimport { makeTimeSlicedImmediate } from \"./timeSlicedImmediate.js\";\n\n// Native AES is provided separately; only install the secure randomness used by portable IDs and nonces.\nif (typeof globalThis.crypto === \"undefined\")\n Object.defineProperty(globalThis, \"crypto\", { value: {}, configurable: true });\nif (typeof globalThis.crypto.getRandomValues !== \"function\")\n Object.defineProperty(globalThis.crypto, \"getRandomValues\", {\n value: getRandomValues,\n configurable: true,\n });\nif (typeof globalThis.crypto.randomUUID !== \"function\")\n Object.defineProperty(globalThis.crypto, \"randomUUID\", { value: randomUUID, configurable: true });\n\n// Expo declarations predate the current DOM Blob byte-array generics.\nglobalThis.Blob = Blob as unknown as typeof globalThis.Blob;\n\n// React Native File extends its own Blob class, so replace it alongside Blob.\nclass ExpoFile extends globalThis.Blob implements File {\n readonly #name: string;\n readonly #lastModified: number;\n\n constructor(parts: BlobPart[], name: string, options: FilePropertyBag = {}) {\n super(parts, options);\n this.#name = String(name);\n this.#lastModified = options.lastModified ?? Date.now();\n // Expo FormData checks own descriptors before assigning a blob filename.\n // An inherited getter alone would make that assignment throw.\n Object.defineProperty(this, \"name\", { value: this.#name, enumerable: true });\n }\n\n get name(): string {\n return this.#name;\n }\n\n get lastModified(): number {\n return this.#lastModified;\n }\n\n get webkitRelativePath(): string {\n return \"\";\n }\n\n get [Symbol.toStringTag](): string {\n return \"File\";\n }\n}\n\nglobalThis.File = ExpoFile;\n\n// RN 0.86 signals are usable by Expo fetch but lack this newer standard method;\n// Foundry reads call it before HTTP. Preserve any platform implementation.\nif (\n typeof globalThis.AbortSignal === \"function\" &&\n typeof globalThis.AbortSignal.prototype.throwIfAborted !== \"function\"\n)\n Object.defineProperty(globalThis.AbortSignal.prototype, \"throwIfAborted\", {\n configurable: true,\n writable: true,\n value: function throwIfAborted(this: AbortSignal) {\n if (!this.aborted) return;\n throw (\n this.reason ?? Object.assign(new Error(\"The operation was aborted.\"), { name: \"AbortError\" })\n );\n },\n });\n\n// Expo fetch returns its own standard-tagged Response while React Native keeps a\n// different global Response without Symbol.toStringTag. OAuth libraries accept\n// matching standard tags across implementations; add the missing tag only.\nif (\n typeof globalThis.Response === \"function\" &&\n Reflect.get(globalThis.Response.prototype, Symbol.toStringTag) === undefined\n)\n Object.defineProperty(globalThis.Response.prototype, Symbol.toStringTag, {\n value: \"Response\",\n configurable: true,\n });\n\n// React Native implements setImmediate with microtasks, so Effect fibers that\n// yield through it never return to the event loop. Bound each run of immediates.\nif (typeof navigator !== \"undefined\" && navigator.product === \"ReactNative\") {\n const { setImmediate, clearImmediate } = makeTimeSlicedImmediate();\n Object.defineProperty(globalThis, \"setImmediate\", {\n value: setImmediate,\n configurable: true,\n writable: true,\n });\n Object.defineProperty(globalThis, \"clearImmediate\", {\n value: clearImmediate,\n configurable: true,\n writable: true,\n });\n}\n"],"mappings":";;;;AAKA,IAAI,OAAO,WAAW,WAAW,aAC7B,OAAO,eAAe,YAAY,UAAU;CAAE,OAAO,CAAC;CAAG,cAAc;AAAK,CAAC;AACjF,IAAI,OAAO,WAAW,OAAO,oBAAoB,YAC7C,OAAO,eAAe,WAAW,QAAQ,mBAAmB;CACxD,OAAO;CACP,cAAc;AAClB,CAAC;AACL,IAAI,OAAO,WAAW,OAAO,eAAe,YACxC,OAAO,eAAe,WAAW,QAAQ,cAAc;CAAE,OAAO;CAAY,cAAc;AAAK,CAAC;AAGpG,WAAW,OAAO;AAGlB,IAAM,WAAN,cAAuB,WAAW,KAAqB;CACnD;CACA;CAEA,YAAY,OAAmB,MAAc,UAA2B,CAAC,GAAG;EACxE,MAAM,OAAO,OAAO;EACpB,KAAK,QAAQ,OAAO,IAAI;EACxB,KAAK,gBAAgB,QAAQ,gBAAgB,KAAK,IAAI;EAGtD,OAAO,eAAe,MAAM,QAAQ;GAAE,OAAO,KAAK;GAAO,YAAY;EAAK,CAAC;CAC/E;CAEA,IAAI,OAAe;EACf,OAAO,KAAK;CAChB;CAEA,IAAI,eAAuB;EACvB,OAAO,KAAK;CAChB;CAEA,IAAI,qBAA6B;EAC7B,OAAO;CACX;CAEA,KAAK,OAAO,eAAuB;EAC/B,OAAO;CACX;AACJ;AAEA,WAAW,OAAO;AAIlB,IACI,OAAO,WAAW,gBAAgB,cAClC,OAAO,WAAW,YAAY,UAAU,mBAAmB,YAE3D,OAAO,eAAe,WAAW,YAAY,WAAW,kBAAkB;CACtE,cAAc;CACd,UAAU;CACV,OAAO,SAAS,iBAAkC;EAC9C,IAAI,CAAC,KAAK,SAAS;EACnB,MACI,KAAK,UAAU,OAAO,uBAAO,IAAI,MAAM,4BAA4B,GAAG,EAAE,MAAM,aAAa,CAAC;CAEpG;AACJ,CAAC;AAKL,IACI,OAAO,WAAW,aAAa,cAC/B,QAAQ,IAAI,WAAW,SAAS,WAAW,OAAO,WAAW,MAAM,KAAA,GAEnE,OAAO,eAAe,WAAW,SAAS,WAAW,OAAO,aAAa;CACrE,OAAO;CACP,cAAc;AAClB,CAAC;AAIL,IAAI,OAAO,cAAc,eAAe,UAAU,YAAY,eAAe;CACzE,MAAM,EAAE,cAAc,mBAAmB,wBAAwB;CACjE,OAAO,eAAe,YAAY,gBAAgB;EAC9C,OAAO;EACP,cAAc;EACd,UAAU;CACd,CAAC;CACD,OAAO,eAAe,YAAY,kBAAkB;EAChD,OAAO;EACP,cAAc;EACd,UAAU;CACd,CAAC;AACL"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region src/timeSlicedImmediate.d.ts
|
|
2
|
+
type Task = (...args: unknown[]) => void;
|
|
3
|
+
export interface TimeSlicedImmediateOptions {
|
|
4
|
+
/** Continuous microtask work allowed before deferring to the host event loop. */
|
|
5
|
+
readonly budgetMs?: number;
|
|
6
|
+
readonly now?: () => number;
|
|
7
|
+
readonly queueMicrotask?: (task: () => void) => void;
|
|
8
|
+
readonly setTimeout?: (task: () => void, delay: number) => unknown;
|
|
9
|
+
readonly clearTimeout?: (handle: unknown) => void;
|
|
10
|
+
}
|
|
11
|
+
/** React Native implements `setImmediate` with microtasks. Effect's scheduler
|
|
12
|
+
* yields through `setImmediate`, so long-running Effect work never returns to
|
|
13
|
+
* the event loop: timers, React's scheduler and native events starve for
|
|
14
|
+
* seconds. Run immediates as microtasks within a short slice, then defer the
|
|
15
|
+
* next one to a timer so the host can render and handle input in between.
|
|
16
|
+
*/
|
|
17
|
+
export declare function makeTimeSlicedImmediate(options?: TimeSlicedImmediateOptions): {
|
|
18
|
+
setImmediate: (task: Task, ...args: unknown[]) => number;
|
|
19
|
+
clearImmediate: (id: number | undefined) => void;
|
|
20
|
+
};
|
|
21
|
+
//#endregion
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=timeSlicedImmediate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeSlicedImmediate.d.ts","names":[],"sources":["../src/timeSlicedImmediate.ts"],"mappings":";KAAK,WAAW;iBACC;;WAEJ;WACA;WACA,kBAAkB;WAClB,cAAc,kBAAkB;WAChC,gBAAgB;;;;;;;;wBASb,wBAAwB,UAAS;EASjB,eAAA,MAAA,SAAI;EAuBJ,iBAAA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
//#region src/timeSlicedImmediate.ts
|
|
2
|
+
/** React Native implements `setImmediate` with microtasks. Effect's scheduler
|
|
3
|
+
* yields through `setImmediate`, so long-running Effect work never returns to
|
|
4
|
+
* the event loop: timers, React's scheduler and native events starve for
|
|
5
|
+
* seconds. Run immediates as microtasks within a short slice, then defer the
|
|
6
|
+
* next one to a timer so the host can render and handle input in between.
|
|
7
|
+
*/
|
|
8
|
+
function makeTimeSlicedImmediate(options = {}) {
|
|
9
|
+
const budget = options.budgetMs ?? 8;
|
|
10
|
+
const now = options.now ?? (() => performance.now());
|
|
11
|
+
const microtask = options.queueMicrotask ?? ((task) => globalThis.queueMicrotask(task));
|
|
12
|
+
const timeout = options.setTimeout ?? ((task, delay) => globalThis.setTimeout(task, delay));
|
|
13
|
+
const clear = options.clearTimeout ?? ((handle) => globalThis.clearTimeout(handle));
|
|
14
|
+
let sliceStart;
|
|
15
|
+
let ids = 0;
|
|
16
|
+
const pending = /* @__PURE__ */ new Map();
|
|
17
|
+
const setImmediate = (task, ...args) => {
|
|
18
|
+
const id = ++ids;
|
|
19
|
+
const run = () => {
|
|
20
|
+
if (!pending.delete(id)) return;
|
|
21
|
+
task(...args);
|
|
22
|
+
};
|
|
23
|
+
const current = now();
|
|
24
|
+
if (sliceStart === void 0) {
|
|
25
|
+
sliceStart = current;
|
|
26
|
+
timeout(() => {
|
|
27
|
+
sliceStart = void 0;
|
|
28
|
+
}, 0);
|
|
29
|
+
}
|
|
30
|
+
if (current - sliceStart < budget) {
|
|
31
|
+
pending.set(id, { cancel: () => {} });
|
|
32
|
+
microtask(run);
|
|
33
|
+
} else {
|
|
34
|
+
const handle = timeout(run, 0);
|
|
35
|
+
pending.set(id, { cancel: () => clear(handle) });
|
|
36
|
+
}
|
|
37
|
+
return id;
|
|
38
|
+
};
|
|
39
|
+
const clearImmediate = (id) => {
|
|
40
|
+
if (id === void 0) return;
|
|
41
|
+
pending.get(id)?.cancel();
|
|
42
|
+
pending.delete(id);
|
|
43
|
+
};
|
|
44
|
+
return {
|
|
45
|
+
setImmediate,
|
|
46
|
+
clearImmediate
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { makeTimeSlicedImmediate };
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=timeSlicedImmediate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeSlicedImmediate.js","names":[],"sources":["../src/timeSlicedImmediate.ts"],"sourcesContent":["type Task = (...args: unknown[]) => void;\nexport interface TimeSlicedImmediateOptions {\n /** Continuous microtask work allowed before deferring to the host event loop. */\n readonly budgetMs?: number;\n readonly now?: () => number;\n readonly queueMicrotask?: (task: () => void) => void;\n readonly setTimeout?: (task: () => void, delay: number) => unknown;\n readonly clearTimeout?: (handle: unknown) => void;\n}\n\n/** React Native implements `setImmediate` with microtasks. Effect's scheduler\n * yields through `setImmediate`, so long-running Effect work never returns to\n * the event loop: timers, React's scheduler and native events starve for\n * seconds. Run immediates as microtasks within a short slice, then defer the\n * next one to a timer so the host can render and handle input in between.\n */\nexport function makeTimeSlicedImmediate(options: TimeSlicedImmediateOptions = {}) {\n const budget = options.budgetMs ?? 8;\n const now = options.now ?? (() => performance.now());\n const microtask = options.queueMicrotask ?? ((task) => globalThis.queueMicrotask(task));\n const timeout = options.setTimeout ?? ((task, delay) => globalThis.setTimeout(task, delay));\n const clear = options.clearTimeout ?? ((handle) => globalThis.clearTimeout(handle as number));\n let sliceStart: number | undefined;\n let ids = 0;\n const pending = new Map<number, { cancel: () => void }>();\n const setImmediate = (task: Task, ...args: unknown[]): number => {\n const id = ++ids;\n const run = () => {\n if (!pending.delete(id)) return;\n task(...args);\n };\n const current = now();\n if (sliceStart === undefined) {\n sliceStart = current;\n // Any turn of the event loop ends the slice.\n timeout(() => {\n sliceStart = undefined;\n }, 0);\n }\n if (current - sliceStart < budget) {\n pending.set(id, { cancel: () => {} });\n microtask(run);\n } else {\n const handle = timeout(run, 0);\n pending.set(id, { cancel: () => clear(handle) });\n }\n return id;\n };\n const clearImmediate = (id: number | undefined) => {\n if (id === undefined) return;\n pending.get(id)?.cancel();\n pending.delete(id);\n };\n return { setImmediate, clearImmediate };\n}\n"],"mappings":";;;;;;;AAgBA,SAAgB,wBAAwB,UAAsC,CAAC,GAAG;CAC9E,MAAM,SAAS,QAAQ,YAAY;CACnC,MAAM,MAAM,QAAQ,cAAc,YAAY,IAAI;CAClD,MAAM,YAAY,QAAQ,oBAAoB,SAAS,WAAW,eAAe,IAAI;CACrF,MAAM,UAAU,QAAQ,gBAAgB,MAAM,UAAU,WAAW,WAAW,MAAM,KAAK;CACzF,MAAM,QAAQ,QAAQ,kBAAkB,WAAW,WAAW,aAAa,MAAgB;CAC3F,IAAI;CACJ,IAAI,MAAM;CACV,MAAM,0BAAU,IAAI,IAAoC;CACxD,MAAM,gBAAgB,MAAY,GAAG,SAA4B;EAC7D,MAAM,KAAK,EAAE;EACb,MAAM,YAAY;GACd,IAAI,CAAC,QAAQ,OAAO,EAAE,GAAG;GACzB,KAAK,GAAG,IAAI;EAChB;EACA,MAAM,UAAU,IAAI;EACpB,IAAI,eAAe,KAAA,GAAW;GAC1B,aAAa;GAEb,cAAc;IACV,aAAa,KAAA;GACjB,GAAG,CAAC;EACR;EACA,IAAI,UAAU,aAAa,QAAQ;GAC/B,QAAQ,IAAI,IAAI,EAAE,cAAc,CAAC,EAAE,CAAC;GACpC,UAAU,GAAG;EACjB,OAAO;GACH,MAAM,SAAS,QAAQ,KAAK,CAAC;GAC7B,QAAQ,IAAI,IAAI,EAAE,cAAc,MAAM,MAAM,EAAE,CAAC;EACnD;EACA,OAAO;CACX;CACA,MAAM,kBAAkB,OAA2B;EAC/C,IAAI,OAAO,KAAA,GAAW;EACtB,QAAQ,IAAI,EAAE,CAAC,EAAE,OAAO;EACxB,QAAQ,OAAO,EAAE;CACrB;CACA,OAAO;EAAE;EAAc;CAAe;AAC1C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@party-stack/expo-runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"files": [
|
|
5
5
|
"lib",
|
|
6
6
|
"plugin"
|
|
@@ -27,12 +27,13 @@
|
|
|
27
27
|
"effect": "^4.0.5",
|
|
28
28
|
"expo-blob": "^57.0.2",
|
|
29
29
|
"expo-crypto": "^57.0.4",
|
|
30
|
+
"expo-location": "^57.0.23",
|
|
30
31
|
"expo-secure-store": "^57.0.4",
|
|
31
32
|
"expo-web-browser": "^57.0.3",
|
|
32
33
|
"temporal-polyfill": "^0.3.0",
|
|
33
|
-
"@party-stack/ontology-storage": "0.2.
|
|
34
|
-
"@party-stack/runtime": "0.
|
|
35
|
-
"@party-stack/sql-ontology-storage": "0.2.
|
|
34
|
+
"@party-stack/ontology-storage": "0.2.2",
|
|
35
|
+
"@party-stack/runtime": "0.6.0",
|
|
36
|
+
"@party-stack/sql-ontology-storage": "0.2.2"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
39
|
"@react-native-community/netinfo": "^12.0.1",
|
package/plugin/index.cjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
const { createRunOncePlugin, withPlugins } = require("expo/config-plugins");
|
|
2
2
|
const withSecureStore = require("expo-secure-store/app.plugin.js").default;
|
|
3
3
|
const withSQLite = require("expo-sqlite/app.plugin.js").default;
|
|
4
|
+
const withLocation = require("expo-location/app.plugin.js").default;
|
|
4
5
|
const { name, version } = require("../package.json");
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* @param {Parameters<import("expo/config-plugins.js").ConfigPlugin>[0]} config
|
|
8
|
-
* @param {{ configureAndroidBackup?: boolean }} [options]
|
|
9
|
+
* @param {{ configureAndroidBackup?: boolean; locationPermission?: string | false }} [options]
|
|
9
10
|
*/
|
|
10
11
|
const withPartyStack = (config, options = {}) =>
|
|
11
12
|
withPlugins(config, [
|
|
@@ -17,6 +18,17 @@ const withPartyStack = (config, options = {}) =>
|
|
|
17
18
|
},
|
|
18
19
|
],
|
|
19
20
|
[withSQLite, {}],
|
|
21
|
+
[
|
|
22
|
+
withLocation,
|
|
23
|
+
{
|
|
24
|
+
// Foreground location only. `false` leaves a purpose string out; an
|
|
25
|
+
// undefined one keeps the app's own or uses expo-location's default.
|
|
26
|
+
locationWhenInUsePermission: options.locationPermission,
|
|
27
|
+
locationAlwaysAndWhenInUsePermission: false,
|
|
28
|
+
locationAlwaysPermission: false,
|
|
29
|
+
motionUsagePermission: false,
|
|
30
|
+
},
|
|
31
|
+
],
|
|
20
32
|
]);
|
|
21
33
|
|
|
22
34
|
module.exports = createRunOncePlugin(withPartyStack, name, version);
|
package/plugin/index.d.cts
CHANGED
|
@@ -4,6 +4,10 @@ interface PartyStackPluginOptions {
|
|
|
4
4
|
* Disable only when supplying equivalent custom backup rules.
|
|
5
5
|
*/
|
|
6
6
|
readonly configureAndroidBackup?: boolean;
|
|
7
|
+
/** iOS purpose string for location while the app is in use. Defaults to the app's
|
|
8
|
+
* existing one or expo-location's. `false` leaves it out for apps that never read
|
|
9
|
+
* location. Background location is never requested. */
|
|
10
|
+
readonly locationPermission?: string | false;
|
|
7
11
|
}
|
|
8
12
|
declare const withPartyStack: ConfigPlugin<PartyStackPluginOptions | void>;
|
|
9
13
|
export = withPartyStack;
|