@party-stack/expo-runtime 0.4.0 → 0.4.2

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.
Files changed (37) hide show
  1. package/README.md +16 -0
  2. package/lib/ExpoFileSystemBlobBytesStore.d.ts +10 -8
  3. package/lib/ExpoFileSystemBlobBytesStore.d.ts.map +1 -1
  4. package/lib/ExpoFileSystemBlobBytesStore.js +50 -45
  5. package/lib/ExpoFileSystemBlobBytesStore.js.map +1 -1
  6. package/lib/ExpoNetworkConnectivity.d.ts +12 -10
  7. package/lib/ExpoNetworkConnectivity.d.ts.map +1 -1
  8. package/lib/ExpoNetworkConnectivity.js +37 -36
  9. package/lib/ExpoNetworkConnectivity.js.map +1 -1
  10. package/lib/ExpoSecretStore.d.ts +9 -7
  11. package/lib/ExpoSecretStore.d.ts.map +1 -1
  12. package/lib/ExpoSecretStore.js +24 -21
  13. package/lib/ExpoSecretStore.js.map +1 -1
  14. package/lib/createExpoBrowserAuthentication.d.ts +3 -1
  15. package/lib/createExpoBrowserAuthentication.d.ts.map +1 -1
  16. package/lib/createExpoBrowserAuthentication.js +19 -21
  17. package/lib/createExpoBrowserAuthentication.js.map +1 -1
  18. package/lib/createExpoRuntime.d.ts +4 -1
  19. package/lib/createExpoRuntime.d.ts.map +1 -1
  20. package/lib/createExpoRuntime.js +36 -43
  21. package/lib/createExpoRuntime.js.map +1 -1
  22. package/lib/hashStorageName.d.ts +4 -0
  23. package/lib/hashStorageName.d.ts.map +1 -0
  24. package/lib/hashStorageName.js +9 -0
  25. package/lib/hashStorageName.js.map +1 -0
  26. package/lib/index.d.ts +2 -2
  27. package/lib/index.js +0 -1
  28. package/lib/polyfill.d.ts +1 -0
  29. package/lib/polyfill.js +33 -0
  30. package/lib/polyfill.js.map +1 -0
  31. package/package.json +27 -22
  32. package/lib/ExpoSecretStore.test.d.ts +0 -2
  33. package/lib/ExpoSecretStore.test.d.ts.map +0 -1
  34. package/lib/ExpoSecretStore.test.js +0 -40
  35. package/lib/ExpoSecretStore.test.js.map +0 -1
  36. package/lib/index.d.ts.map +0 -1
  37. package/lib/index.js.map +0 -1
package/README.md ADDED
@@ -0,0 +1,16 @@
1
+ # Expo runtime
2
+
3
+ This runtime targets Expo SDK 57. Install `@party-stack/expo-runtime` and its Expo peer dependencies using SDK 57-compatible versions. Expo installs `expo/fetch` as the default native fetch starting in SDK 56; no separate `expo-fetch` package or fetch installer is needed. The runtime includes `expo-blob`.
4
+
5
+ Import the required polyfill first in your application entry point, before importing application code or creating clients:
6
+
7
+ ```ts
8
+ import "@party-stack/expo-runtime/polyfill";
9
+ import "expo-router/entry";
10
+ ```
11
+
12
+ Then use `createExpoRuntime` from `@party-stack/expo-runtime` as your installation's runtime provider.
13
+
14
+ The polyfill replaces global `Blob` with Expo Blob and global `File` with a compatible class extending Expo Blob. It 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`.
15
+
16
+ Attachment storage requires blobs with `arrayBuffer()`, as provided by Expo Blob and Expo File. Blobs returned by other native libraries may still use React Native's older Blob implementation; convert those to compatible blobs before passing them to the runtime. Cache reads return `expo-file-system` File objects, which Expo fetch accepts as upload bodies.
@@ -1,13 +1,15 @@
1
- import type { BlobBytesStore } from "@party-stack/runtime";
1
+ import { BlobBytesStore } from "@party-stack/runtime";
2
+ //#region src/ExpoFileSystemBlobBytesStore.d.ts
2
3
  export interface ExpoFileSystemBlobBytesStoreOptions {
3
- directoryName: string;
4
+ directoryName: string;
4
5
  }
5
6
  export declare class ExpoFileSystemBlobBytesStore implements BlobBytesStore {
6
- #private;
7
- constructor(options: ExpoFileSystemBlobBytesStoreOptions);
8
- write(id: string, blob: Blob): Promise<void>;
9
- read(id: string): Promise<Blob>;
10
- delete(id: string): Promise<void>;
11
- clear(): Promise<void>;
7
+ #private;
8
+ constructor(options: ExpoFileSystemBlobBytesStoreOptions);
9
+ write(id: string, blob: Blob): Promise<void>;
10
+ read(id: string): Promise<Blob>;
11
+ delete(id: string): Promise<void>;
12
+ clear(): Promise<void>;
12
13
  }
14
+ //#endregion
13
15
  //# sourceMappingURL=ExpoFileSystemBlobBytesStore.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoFileSystemBlobBytesStore.d.ts","sourceRoot":"","sources":["../src/ExpoFileSystemBlobBytesStore.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,MAAM,WAAW,mCAAmC;IAChD,aAAa,EAAE,MAAM,CAAC;CACzB;AAMD,qBAAa,4BAA6B,YAAW,cAAc;;gBAGnD,OAAO,EAAE,mCAAmC;IAIlD,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAMlD,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU/B,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOjC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAgBzB"}
1
+ {"version":3,"file":"ExpoFileSystemBlobBytesStore.d.ts","names":[],"sources":["../src/ExpoFileSystemBlobBytesStore.ts"],"mappings":";;iBAIiB;EACb;;qBAGS,wCAAwC;;EAGjD,YAAY,SAAS;EAIf,MAAM,YAAY,MAAM,OAAO;EAOrC,KAAK,aAAa,QAAQ;EAU1B,OAAO,aAAa;EAOpB,SAAS"}
@@ -1,47 +1,52 @@
1
+ import { hashStorageName } from "./hashStorageName.js";
1
2
  import { Directory, File, Paths } from "expo-file-system";
2
- function encodeFileName(id) {
3
- return encodeURIComponent(id);
4
- }
5
- export class ExpoFileSystemBlobBytesStore {
6
- #directoryName;
7
- constructor(options) {
8
- this.#directoryName = options.directoryName;
9
- }
10
- async write(id, blob) {
11
- const file = this.#file(id);
12
- file.create({ intermediates: true, overwrite: true });
13
- file.write(new Uint8Array(await blob.arrayBuffer()));
14
- }
15
- read(id) {
16
- return Promise.resolve().then(() => {
17
- const file = this.#file(id);
18
- if (!file.exists) {
19
- throw new Error(`Blob bytes not found for "${id}".`);
20
- }
21
- return file;
22
- });
23
- }
24
- delete(id) {
25
- return Promise.resolve().then(() => {
26
- const file = this.#file(id);
27
- if (file.exists)
28
- file.delete();
29
- });
30
- }
31
- clear() {
32
- return Promise.resolve().then(() => {
33
- const directory = new Directory(Paths.document, this.#directoryName);
34
- if (directory.exists)
35
- directory.delete();
36
- });
37
- }
38
- #directory() {
39
- const directory = new Directory(Paths.document, this.#directoryName);
40
- directory.create({ idempotent: true, intermediates: true });
41
- return directory;
42
- }
43
- #file(id) {
44
- return new File(this.#directory(), encodeFileName(id));
45
- }
46
- }
3
+ //#region src/ExpoFileSystemBlobBytesStore.ts
4
+ var ExpoFileSystemBlobBytesStore = class {
5
+ #directoryName;
6
+ constructor(options) {
7
+ this.#directoryName = options.directoryName;
8
+ }
9
+ async write(id, blob) {
10
+ const file = await this.#file(id);
11
+ const bytes = new Uint8Array(await blob.arrayBuffer());
12
+ file.create({
13
+ intermediates: true,
14
+ overwrite: true
15
+ });
16
+ file.write(bytes);
17
+ }
18
+ read(id) {
19
+ return Promise.resolve().then(async () => {
20
+ const file = await this.#file(id);
21
+ if (!file.exists) throw new Error(`Blob bytes not found for "${id}".`);
22
+ return file;
23
+ });
24
+ }
25
+ delete(id) {
26
+ return Promise.resolve().then(async () => {
27
+ const file = await this.#file(id);
28
+ if (file.exists) file.delete();
29
+ });
30
+ }
31
+ clear() {
32
+ return Promise.resolve().then(() => {
33
+ const directory = new Directory(Paths.document, this.#directoryName);
34
+ if (directory.exists) directory.delete();
35
+ });
36
+ }
37
+ #directory() {
38
+ const directory = new Directory(Paths.document, this.#directoryName);
39
+ directory.create({
40
+ idempotent: true,
41
+ intermediates: true
42
+ });
43
+ return directory;
44
+ }
45
+ #file(id) {
46
+ return hashStorageName(id).then((name) => new File(this.#directory(), name));
47
+ }
48
+ };
49
+ //#endregion
50
+ export { ExpoFileSystemBlobBytesStore };
51
+
47
52
  //# sourceMappingURL=ExpoFileSystemBlobBytesStore.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoFileSystemBlobBytesStore.js","sourceRoot":"","sources":["../src/ExpoFileSystemBlobBytesStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAO1D,SAAS,cAAc,CAAC,EAAU;IAC9B,OAAO,kBAAkB,CAAC,EAAE,CAAC,CAAC;AAClC,CAAC;AAED,MAAM,OAAO,4BAA4B;IACrC,cAAc,CAAS;IAEvB,YAAY,OAA4C;QACpD,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,EAAU,EAAE,IAAU;QAC9B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC5B,IAAI,CAAC,MAAM,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACtD,IAAI,CAAC,KAAK,CAAC,IAAI,UAAU,CAAC,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IACzD,CAAC;IAED,IAAI,CAAC,EAAU;QACX,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;YAC/B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC5B,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACf,MAAM,IAAI,KAAK,CAAC,6BAA6B,EAAE,IAAI,CAAC,CAAC;YACzD,CAAC;YACD,OAAO,IAAI,CAAC;QAChB,CAAC,CAAC,CAAC;IACP,CAAC;IAED,MAAM,CAAC,EAAU;QACb,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;YAC/B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC5B,IAAI,IAAI,CAAC,MAAM;gBAAE,IAAI,CAAC,MAAM,EAAE,CAAC;QACnC,CAAC,CAAC,CAAC;IACP,CAAC;IAED,KAAK;QACD,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;YAC/B,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;YACrE,IAAI,SAAS,CAAC,MAAM;gBAAE,SAAS,CAAC,MAAM,EAAE,CAAC;QAC7C,CAAC,CAAC,CAAC;IACP,CAAC;IAED,UAAU;QACN,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QACrE,SAAS,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5D,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,EAAU;QACZ,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC;IAC3D,CAAC;CACJ"}
1
+ {"version":3,"file":"ExpoFileSystemBlobBytesStore.js","names":[],"sources":["../src/ExpoFileSystemBlobBytesStore.ts"],"sourcesContent":["import { Directory, File, Paths } from \"expo-file-system\";\nimport { hashStorageName } from \"./hashStorageName.js\";\nimport type { BlobBytesStore } from \"@party-stack/runtime\";\n\nexport interface ExpoFileSystemBlobBytesStoreOptions {\n directoryName: string;\n}\n\nexport class ExpoFileSystemBlobBytesStore implements BlobBytesStore {\n #directoryName: string;\n\n constructor(options: ExpoFileSystemBlobBytesStoreOptions) {\n this.#directoryName = options.directoryName;\n }\n\n async write(id: string, blob: Blob): Promise<void> {\n const file = await this.#file(id);\n const bytes = new Uint8Array(await blob.arrayBuffer());\n file.create({ intermediates: true, overwrite: true });\n file.write(bytes);\n }\n\n read(id: string): Promise<Blob> {\n return Promise.resolve().then(async () => {\n const file = await this.#file(id);\n if (!file.exists) {\n throw new Error(`Blob bytes not found for \"${id}\".`);\n }\n return file;\n });\n }\n\n delete(id: string): Promise<void> {\n return Promise.resolve().then(async () => {\n const file = await this.#file(id);\n if (file.exists) file.delete();\n });\n }\n\n clear(): Promise<void> {\n return Promise.resolve().then(() => {\n const directory = new Directory(Paths.document, this.#directoryName);\n if (directory.exists) directory.delete();\n });\n }\n\n #directory(): Directory {\n const directory = new Directory(Paths.document, this.#directoryName);\n directory.create({ idempotent: true, intermediates: true });\n return directory;\n }\n\n #file(id: string): Promise<File> {\n return hashStorageName(id).then((name) => new File(this.#directory(), name));\n }\n}\n"],"mappings":";;;AAQA,IAAa,+BAAb,MAAoE;CAChE;CAEA,YAAY,SAA8C;EACtD,KAAK,iBAAiB,QAAQ;CAClC;CAEA,MAAM,MAAM,IAAY,MAA2B;EAC/C,MAAM,OAAO,MAAM,KAAK,MAAM,EAAE;EAChC,MAAM,QAAQ,IAAI,WAAW,MAAM,KAAK,YAAY,CAAC;EACrD,KAAK,OAAO;GAAE,eAAe;GAAM,WAAW;EAAK,CAAC;EACpD,KAAK,MAAM,KAAK;CACpB;CAEA,KAAK,IAA2B;EAC5B,OAAO,QAAQ,QAAQ,CAAC,CAAC,KAAK,YAAY;GACtC,MAAM,OAAO,MAAM,KAAK,MAAM,EAAE;GAChC,IAAI,CAAC,KAAK,QACN,MAAM,IAAI,MAAM,6BAA6B,GAAG,GAAG;GAEvD,OAAO;EACX,CAAC;CACL;CAEA,OAAO,IAA2B;EAC9B,OAAO,QAAQ,QAAQ,CAAC,CAAC,KAAK,YAAY;GACtC,MAAM,OAAO,MAAM,KAAK,MAAM,EAAE;GAChC,IAAI,KAAK,QAAQ,KAAK,OAAO;EACjC,CAAC;CACL;CAEA,QAAuB;EACnB,OAAO,QAAQ,QAAQ,CAAC,CAAC,WAAW;GAChC,MAAM,YAAY,IAAI,UAAU,MAAM,UAAU,KAAK,cAAc;GACnE,IAAI,UAAU,QAAQ,UAAU,OAAO;EAC3C,CAAC;CACL;CAEA,aAAwB;EACpB,MAAM,YAAY,IAAI,UAAU,MAAM,UAAU,KAAK,cAAc;EACnE,UAAU,OAAO;GAAE,YAAY;GAAM,eAAe;EAAK,CAAC;EAC1D,OAAO;CACX;CAEA,MAAM,IAA2B;EAC7B,OAAO,gBAAgB,EAAE,CAAC,CAAC,MAAM,SAAS,IAAI,KAAK,KAAK,WAAW,GAAG,IAAI,CAAC;CAC/E;AACJ"}
@@ -1,13 +1,15 @@
1
- import type { NetworkConnectivity } from "@party-stack/runtime";
1
+ import { NetworkConnectivity } from "@party-stack/runtime";
2
+ //#region src/ExpoNetworkConnectivity.d.ts
2
3
  export declare class ExpoNetworkConnectivity implements NetworkConnectivity {
3
- private readonly listeners;
4
- private connected;
5
- private readonly unsubscribe;
6
- static create(): Promise<ExpoNetworkConnectivity>;
7
- private constructor();
8
- get isConnected(): boolean;
9
- subscribe(listener: (isConnected: boolean) => void): () => void;
10
- close(): void;
11
- private update;
4
+ private readonly listeners;
5
+ private connected;
6
+ private readonly unsubscribe;
7
+ static create(): Promise<ExpoNetworkConnectivity>;
8
+ private constructor();
9
+ get isConnected(): boolean;
10
+ subscribe(listener: (isConnected: boolean) => void): () => void;
11
+ close(): void;
12
+ private update;
12
13
  }
14
+ //#endregion
13
15
  //# sourceMappingURL=ExpoNetworkConnectivity.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoNetworkConnectivity.d.ts","sourceRoot":"","sources":["../src/ExpoNetworkConnectivity.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,qBAAa,uBACT,YAAW,mBAAmB;IAE9B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAEtB;IACJ,OAAO,CAAC,SAAS,CAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAa;WAE5B,MAAM,IAAI,OAAO,CAAC,uBAAuB,CAAC;IAOvD,OAAO;IAOP,IAAI,WAAW,IAAI,OAAO,CAEzB;IAED,SAAS,CACL,QAAQ,EAAE,CAAC,WAAW,EAAE,OAAO,KAAK,IAAI,GACzC,MAAM,IAAI;IAOb,KAAK,IAAI,IAAI;IAKb,OAAO,CAAC,MAAM;CAOjB"}
1
+ {"version":3,"file":"ExpoNetworkConnectivity.d.ts","names":[],"sources":["../src/ExpoNetworkConnectivity.ts"],"mappings":";;qBAGa,mCAAmC;mBAC3B;UACT;mBACS;SAEJ,UAAU,QAAQ;UAKxB;MAOH;EAIJ,UAAU,WAAW;EAOrB;UAKQ"}
@@ -1,38 +1,39 @@
1
1
  import NetInfo from "@react-native-community/netinfo";
2
- export class ExpoNetworkConnectivity {
3
- listeners = new Set();
4
- connected;
5
- unsubscribe;
6
- static async create() {
7
- const initialState = await NetInfo.fetch();
8
- return new ExpoNetworkConnectivity(initialState.isConnected === true);
9
- }
10
- constructor(initialIsConnected) {
11
- this.connected = initialIsConnected;
12
- this.unsubscribe = NetInfo.addEventListener((state) => {
13
- this.update(state.isConnected === true);
14
- });
15
- }
16
- get isConnected() {
17
- return this.connected;
18
- }
19
- subscribe(listener) {
20
- this.listeners.add(listener);
21
- return () => {
22
- this.listeners.delete(listener);
23
- };
24
- }
25
- close() {
26
- this.unsubscribe();
27
- this.listeners.clear();
28
- }
29
- update(isConnected) {
30
- if (isConnected === this.connected)
31
- return;
32
- this.connected = isConnected;
33
- for (const listener of this.listeners) {
34
- listener(isConnected);
35
- }
36
- }
37
- }
2
+ //#region src/ExpoNetworkConnectivity.ts
3
+ var ExpoNetworkConnectivity = class ExpoNetworkConnectivity {
4
+ listeners = /* @__PURE__ */ new Set();
5
+ connected;
6
+ unsubscribe;
7
+ static async create() {
8
+ const initialState = await NetInfo.fetch();
9
+ return new ExpoNetworkConnectivity(initialState.isConnected === true);
10
+ }
11
+ constructor(initialIsConnected) {
12
+ this.connected = initialIsConnected;
13
+ this.unsubscribe = NetInfo.addEventListener((state) => {
14
+ this.update(state.isConnected === true);
15
+ });
16
+ }
17
+ get isConnected() {
18
+ return this.connected;
19
+ }
20
+ subscribe(listener) {
21
+ this.listeners.add(listener);
22
+ return () => {
23
+ this.listeners.delete(listener);
24
+ };
25
+ }
26
+ close() {
27
+ this.unsubscribe();
28
+ this.listeners.clear();
29
+ }
30
+ update(isConnected) {
31
+ if (isConnected === this.connected) return;
32
+ this.connected = isConnected;
33
+ for (const listener of this.listeners) listener(isConnected);
34
+ }
35
+ };
36
+ //#endregion
37
+ export { ExpoNetworkConnectivity };
38
+
38
39
  //# sourceMappingURL=ExpoNetworkConnectivity.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoNetworkConnectivity.js","sourceRoot":"","sources":["../src/ExpoNetworkConnectivity.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,iCAAiC,CAAC;AAGtD,MAAM,OAAO,uBAAuB;IAGf,SAAS,GAAG,IAAI,GAAG,EAEjC,CAAC;IACI,SAAS,CAAU;IACV,WAAW,CAAa;IAEzC,MAAM,CAAC,KAAK,CAAC,MAAM;QACf,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;QAC3C,OAAO,IAAI,uBAAuB,CAC9B,YAAY,CAAC,WAAW,KAAK,IAAI,CACpC,CAAC;IACN,CAAC;IAED,YAAoB,kBAA2B;QAC3C,IAAI,CAAC,SAAS,GAAG,kBAAkB,CAAC;QACpC,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,KAAK,EAAE,EAAE;YAClD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,KAAK,IAAI,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;IACP,CAAC;IAED,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,SAAS,CACL,QAAwC;QAExC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC7B,OAAO,GAAG,EAAE;YACR,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACpC,CAAC,CAAC;IACN,CAAC;IAED,KAAK;QACD,IAAI,CAAC,WAAW,EAAE,CAAC;QACnB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;IAEO,MAAM,CAAC,WAAoB;QAC/B,IAAI,WAAW,KAAK,IAAI,CAAC,SAAS;YAAE,OAAO;QAC3C,IAAI,CAAC,SAAS,GAAG,WAAW,CAAC;QAC7B,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACpC,QAAQ,CAAC,WAAW,CAAC,CAAC;QAC1B,CAAC;IACL,CAAC;CACJ"}
1
+ {"version":3,"file":"ExpoNetworkConnectivity.js","names":[],"sources":["../src/ExpoNetworkConnectivity.ts"],"sourcesContent":["import NetInfo from \"@react-native-community/netinfo\";\nimport type { NetworkConnectivity } from \"@party-stack/runtime\";\n\nexport class ExpoNetworkConnectivity implements NetworkConnectivity {\n private readonly listeners = new Set<(isConnected: boolean) => void>();\n private connected: boolean;\n private readonly unsubscribe: () => void;\n\n static async create(): Promise<ExpoNetworkConnectivity> {\n const initialState = await NetInfo.fetch();\n return new ExpoNetworkConnectivity(initialState.isConnected === true);\n }\n\n private constructor(initialIsConnected: boolean) {\n this.connected = initialIsConnected;\n this.unsubscribe = NetInfo.addEventListener((state) => {\n this.update(state.isConnected === true);\n });\n }\n\n get isConnected(): boolean {\n return this.connected;\n }\n\n subscribe(listener: (isConnected: boolean) => void): () => void {\n this.listeners.add(listener);\n return () => {\n this.listeners.delete(listener);\n };\n }\n\n close(): void {\n this.unsubscribe();\n this.listeners.clear();\n }\n\n private update(isConnected: boolean): void {\n if (isConnected === this.connected) return;\n this.connected = isConnected;\n for (const listener of this.listeners) {\n listener(isConnected);\n }\n }\n}\n"],"mappings":";;AAGA,IAAa,0BAAb,MAAa,wBAAuD;CAChE,4BAA6B,IAAI,IAAoC;CACrE;CACA;CAEA,aAAa,SAA2C;EACpD,MAAM,eAAe,MAAM,QAAQ,MAAM;EACzC,OAAO,IAAI,wBAAwB,aAAa,gBAAgB,IAAI;CACxE;CAEA,YAAoB,oBAA6B;EAC7C,KAAK,YAAY;EACjB,KAAK,cAAc,QAAQ,kBAAkB,UAAU;GACnD,KAAK,OAAO,MAAM,gBAAgB,IAAI;EAC1C,CAAC;CACL;CAEA,IAAI,cAAuB;EACvB,OAAO,KAAK;CAChB;CAEA,UAAU,UAAsD;EAC5D,KAAK,UAAU,IAAI,QAAQ;EAC3B,aAAa;GACT,KAAK,UAAU,OAAO,QAAQ;EAClC;CACJ;CAEA,QAAc;EACV,KAAK,YAAY;EACjB,KAAK,UAAU,MAAM;CACzB;CAEA,OAAe,aAA4B;EACvC,IAAI,gBAAgB,KAAK,WAAW;EACpC,KAAK,YAAY;EACjB,KAAK,MAAM,YAAY,KAAK,WACxB,SAAS,WAAW;CAE5B;AACJ"}
@@ -1,10 +1,12 @@
1
- import type { SecretStore } from "@party-stack/runtime";
1
+ import { SecretStore } from "@party-stack/runtime";
2
+ //#region src/ExpoSecretStore.d.ts
2
3
  export declare class ExpoSecretStore implements SecretStore {
3
- private readonly prefix;
4
- constructor(prefix: string);
5
- get(key: string): Promise<string | undefined>;
6
- set(key: string, value: string): Promise<void>;
7
- delete(key: string): Promise<void>;
8
- private key;
4
+ private readonly prefix;
5
+ constructor(prefix: string);
6
+ get(key: string): Promise<string | undefined>;
7
+ set(key: string, value: string): Promise<void>;
8
+ delete(key: string): Promise<void>;
9
+ private key;
9
10
  }
11
+ //#endregion
10
12
  //# sourceMappingURL=ExpoSecretStore.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoSecretStore.d.ts","sourceRoot":"","sources":["../src/ExpoSecretStore.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAQxD,qBAAa,eAAgB,YAAW,WAAW;IACnC,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAE3C,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAI7C,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9C,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlC,OAAO,CAAC,GAAG;CAGd"}
1
+ {"version":3,"file":"ExpoSecretStore.d.ts","names":[],"sources":["../src/ExpoSecretStore.ts"],"mappings":";;qBASa,2BAA2B;mBACP;EAA7B,YAA6B;EAE7B,IAAI,cAAc;EAIlB,IAAI,aAAa,gBAAgB;EAIjC,OAAO,cAAc;UAIb"}
@@ -1,25 +1,28 @@
1
1
  import { deleteItemAsync, getItemAsync, setItemAsync } from "expo-secure-store";
2
- // https://docs.expo.dev/versions/latest/sdk/securestore#securestoresetitemkey-value-options
2
+ //#region src/ExpoSecretStore.ts
3
3
  function encodeKey(value) {
4
- const bytes = new TextEncoder().encode(value);
5
- return `party-stack.${Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("")}`;
6
- }
7
- export class ExpoSecretStore {
8
- prefix;
9
- constructor(prefix) {
10
- this.prefix = prefix;
11
- }
12
- get(key) {
13
- return getItemAsync(this.key(key)).then((value) => value ?? undefined);
14
- }
15
- set(key, value) {
16
- return setItemAsync(this.key(key), value);
17
- }
18
- delete(key) {
19
- return deleteItemAsync(this.key(key));
20
- }
21
- key(key) {
22
- return encodeKey(JSON.stringify([this.prefix, key]));
23
- }
4
+ const bytes = new TextEncoder().encode(value);
5
+ return `party-stack.${Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("")}`;
24
6
  }
7
+ var ExpoSecretStore = class {
8
+ prefix;
9
+ constructor(prefix) {
10
+ this.prefix = prefix;
11
+ }
12
+ get(key) {
13
+ return getItemAsync(this.key(key)).then((value) => value ?? void 0);
14
+ }
15
+ set(key, value) {
16
+ return setItemAsync(this.key(key), value);
17
+ }
18
+ delete(key) {
19
+ return deleteItemAsync(this.key(key));
20
+ }
21
+ key(key) {
22
+ return encodeKey(JSON.stringify([this.prefix, key]));
23
+ }
24
+ };
25
+ //#endregion
26
+ export { ExpoSecretStore };
27
+
25
28
  //# sourceMappingURL=ExpoSecretStore.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoSecretStore.js","sourceRoot":"","sources":["../src/ExpoSecretStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGhF,4FAA4F;AAC5F,SAAS,SAAS,CAAC,KAAa;IAC5B,MAAM,KAAK,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9C,OAAO,eAAe,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;AACrG,CAAC;AAED,MAAM,OAAO,eAAe;IACK;IAA7B,YAA6B,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC;IAE/C,GAAG,CAAC,GAAW;QACX,OAAO,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,IAAI,SAAS,CAAC,CAAC;IAC3E,CAAC;IAED,GAAG,CAAC,GAAW,EAAE,KAAa;QAC1B,OAAO,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;IAC9C,CAAC;IAED,MAAM,CAAC,GAAW;QACd,OAAO,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1C,CAAC;IAEO,GAAG,CAAC,GAAW;QACnB,OAAO,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IACzD,CAAC;CACJ"}
1
+ {"version":3,"file":"ExpoSecretStore.js","names":[],"sources":["../src/ExpoSecretStore.ts"],"sourcesContent":["import { deleteItemAsync, getItemAsync, setItemAsync } from \"expo-secure-store\";\nimport type { SecretStore } from \"@party-stack/runtime\";\n\n// https://docs.expo.dev/versions/latest/sdk/securestore#securestoresetitemkey-value-options\nfunction encodeKey(value: string): string {\n const bytes = new TextEncoder().encode(value);\n return `party-stack.${Array.from(bytes, (byte) => byte.toString(16).padStart(2, \"0\")).join(\"\")}`;\n}\n\nexport class ExpoSecretStore implements SecretStore {\n constructor(private readonly prefix: string) {}\n\n get(key: string): Promise<string | undefined> {\n return getItemAsync(this.key(key)).then((value) => value ?? undefined);\n }\n\n set(key: string, value: string): Promise<void> {\n return setItemAsync(this.key(key), value);\n }\n\n delete(key: string): Promise<void> {\n return deleteItemAsync(this.key(key));\n }\n\n private key(key: string): string {\n return encodeKey(JSON.stringify([this.prefix, key]));\n }\n}\n"],"mappings":";;AAIA,SAAS,UAAU,OAAuB;CACtC,MAAM,QAAQ,IAAI,YAAY,CAAC,CAAC,OAAO,KAAK;CAC5C,OAAO,eAAe,MAAM,KAAK,QAAQ,SAAS,KAAK,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE;AACjG;AAEA,IAAa,kBAAb,MAAoD;CACnB;CAA7B,YAAY,QAAiC;EAAhB,KAAA,SAAA;CAAiB;CAE9C,IAAI,KAA0C;EAC1C,OAAO,aAAa,KAAK,IAAI,GAAG,CAAC,CAAC,CAAC,MAAM,UAAU,SAAS,KAAA,CAAS;CACzE;CAEA,IAAI,KAAa,OAA8B;EAC3C,OAAO,aAAa,KAAK,IAAI,GAAG,GAAG,KAAK;CAC5C;CAEA,OAAO,KAA4B;EAC/B,OAAO,gBAAgB,KAAK,IAAI,GAAG,CAAC;CACxC;CAEA,IAAY,KAAqB;EAC7B,OAAO,UAAU,KAAK,UAAU,CAAC,KAAK,QAAQ,GAAG,CAAC,CAAC;CACvD;AACJ"}
@@ -1,3 +1,5 @@
1
- import { type BrowserAuthentication } from "@party-stack/runtime";
1
+ import { BrowserAuthentication } from "@party-stack/runtime";
2
+ //#region src/createExpoBrowserAuthentication.d.ts
2
3
  export declare function createExpoBrowserAuthentication(): BrowserAuthentication;
4
+ //#endregion
3
5
  //# sourceMappingURL=createExpoBrowserAuthentication.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createExpoBrowserAuthentication.d.ts","sourceRoot":"","sources":["../src/createExpoBrowserAuthentication.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,KAAK,qBAAqB,EAC7B,MAAM,sBAAsB,CAAC;AAM9B,wBAAgB,+BAA+B,IAAI,qBAAqB,CAuBvE"}
1
+ {"version":3,"file":"createExpoBrowserAuthentication.d.ts","names":[],"sources":["../src/createExpoBrowserAuthentication.ts"],"mappings":";;wBAGgB,mCAAmC"}
@@ -1,23 +1,21 @@
1
- import { BrowserAuthenticationCancelledError, } from "@party-stack/runtime";
2
- import { dismissAuthSession, openAuthSessionAsync, } from "expo-web-browser";
3
- export function createExpoBrowserAuthentication() {
4
- return {
5
- start({ redirectUrl }) {
6
- return {
7
- async open(authorizationUrl) {
8
- const result = await openAuthSessionAsync(authorizationUrl, redirectUrl);
9
- if (result.type === "success") {
10
- return {
11
- callbackUrl: result.url,
12
- };
13
- }
14
- throw new BrowserAuthenticationCancelledError();
15
- },
16
- close() {
17
- dismissAuthSession();
18
- },
19
- };
20
- },
21
- };
1
+ import { BrowserAuthenticationCancelledError } from "@party-stack/runtime";
2
+ import { dismissAuthSession, openAuthSessionAsync } from "expo-web-browser";
3
+ //#region src/createExpoBrowserAuthentication.ts
4
+ function createExpoBrowserAuthentication() {
5
+ return { start({ redirectUrl }) {
6
+ return {
7
+ async open(authorizationUrl) {
8
+ const result = await openAuthSessionAsync(authorizationUrl, redirectUrl);
9
+ if (result.type === "success") return { callbackUrl: result.url };
10
+ throw new BrowserAuthenticationCancelledError();
11
+ },
12
+ close() {
13
+ dismissAuthSession();
14
+ }
15
+ };
16
+ } };
22
17
  }
18
+ //#endregion
19
+ export { createExpoBrowserAuthentication };
20
+
23
21
  //# sourceMappingURL=createExpoBrowserAuthentication.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createExpoBrowserAuthentication.js","sourceRoot":"","sources":["../src/createExpoBrowserAuthentication.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,mCAAmC,GAEtC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACH,kBAAkB,EAClB,oBAAoB,GACvB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,UAAU,+BAA+B;IAC3C,OAAO;QACH,KAAK,CAAC,EAAE,WAAW,EAAE;YACjB,OAAO;gBACH,KAAK,CAAC,IAAI,CAAC,gBAAgB;oBACvB,MAAM,MAAM,GACR,MAAM,oBAAoB,CACtB,gBAAgB,EAChB,WAAW,CACd,CAAC;oBACN,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;wBAC5B,OAAO;4BACH,WAAW,EAAE,MAAM,CAAC,GAAG;yBAC1B,CAAC;oBACN,CAAC;oBACD,MAAM,IAAI,mCAAmC,EAAE,CAAC;gBACpD,CAAC;gBACD,KAAK;oBACD,kBAAkB,EAAE,CAAC;gBACzB,CAAC;aACJ,CAAC;QACN,CAAC;KACJ,CAAC;AACN,CAAC"}
1
+ {"version":3,"file":"createExpoBrowserAuthentication.js","names":[],"sources":["../src/createExpoBrowserAuthentication.ts"],"sourcesContent":["import { BrowserAuthenticationCancelledError, type BrowserAuthentication } from \"@party-stack/runtime\";\nimport { dismissAuthSession, openAuthSessionAsync } from \"expo-web-browser\";\n\nexport function createExpoBrowserAuthentication(): BrowserAuthentication {\n return {\n start({ redirectUrl }) {\n return {\n async open(authorizationUrl) {\n const result = await openAuthSessionAsync(authorizationUrl, redirectUrl);\n if (result.type === \"success\") {\n return {\n callbackUrl: result.url,\n };\n }\n throw new BrowserAuthenticationCancelledError();\n },\n close() {\n dismissAuthSession();\n },\n };\n },\n };\n}\n"],"mappings":";;;AAGA,SAAgB,kCAAyD;CACrE,OAAO,EACH,MAAM,EAAE,eAAe;EACnB,OAAO;GACH,MAAM,KAAK,kBAAkB;IACzB,MAAM,SAAS,MAAM,qBAAqB,kBAAkB,WAAW;IACvE,IAAI,OAAO,SAAS,WAChB,OAAO,EACH,aAAa,OAAO,IACxB;IAEJ,MAAM,IAAI,oCAAoC;GAClD;GACA,QAAQ;IACJ,mBAAmB;GACvB;EACJ;CACJ,EACJ;AACJ"}
@@ -1,3 +1,6 @@
1
+ import { RuntimeAdapter } from "@party-stack/runtime";
1
2
  import "temporal-polyfill/global";
2
- export declare const createExpoRuntime: (owner: string, namespace: string) => Promise<import("@party-stack/runtime").RuntimeAdapter>;
3
+ //#region src/createExpoRuntime.d.ts
4
+ export declare const createExpoRuntime: (owner: string, namespace: string) => Promise<RuntimeAdapter>;
5
+ //#endregion
3
6
  //# sourceMappingURL=createExpoRuntime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createExpoRuntime.d.ts","sourceRoot":"","sources":["../src/createExpoRuntime.ts"],"names":[],"mappings":"AACA,OAAO,0BAA0B,CAAC;AAalC,eAAO,MAAM,iBAAiB,8FAyC5B,CAAC"}
1
+ {"version":3,"file":"createExpoRuntime.d.ts","names":[],"sources":["../src/createExpoRuntime.ts"],"mappings":";;;qBAaa,oBAAoB,eAAe,sBAAsB,QAAQ"}
@@ -1,48 +1,41 @@
1
- // SQLite persistence revives Temporal values through the registered global constructors.
2
- import "temporal-polyfill/global";
3
- import { SingleProcessCoordination } from "@party-stack/coordination";
4
- import { defineRuntime } from "@party-stack/runtime";
5
- import { createExpoSQLitePersistence, } from "@tanstack/expo-db-sqlite-persistence";
6
- import { deleteDatabaseAsync, openDatabaseAsync } from "expo-sqlite";
7
- import { createExpoBrowserAuthentication } from "./createExpoBrowserAuthentication.js";
1
+ import { hashStorageName } from "./hashStorageName.js";
8
2
  import { ExpoFileSystemBlobBytesStore } from "./ExpoFileSystemBlobBytesStore.js";
9
3
  import { ExpoNetworkConnectivity } from "./ExpoNetworkConnectivity.js";
10
4
  import { ExpoSecretStore } from "./ExpoSecretStore.js";
11
- export const createExpoRuntime = defineRuntime(async (owner, namespace) => {
12
- const name = `party-stack:${owner}:${namespace}`;
13
- const [database, connectivity] = await Promise.all([
14
- openDatabaseAsync(`${name}.db`),
15
- ExpoNetworkConnectivity.create(),
16
- ]);
17
- const persistence = createExpoSQLitePersistence({
18
- database: database,
19
- });
20
- const coordination = new SingleProcessCoordination({
21
- scope: name,
22
- });
23
- const blobBytes = new ExpoFileSystemBlobBytesStore({
24
- directoryName: `${name}:blobs`,
25
- });
26
- return {
27
- owner,
28
- namespace,
29
- blobBytes,
30
- browserAuthentication: createExpoBrowserAuthentication(),
31
- secrets: new ExpoSecretStore(`${name}:secrets`),
32
- connectivity,
33
- coordination,
34
- persistence,
35
- destroy: async () => {
36
- await Promise.all([
37
- deleteDatabaseAsync(`${name}.db`),
38
- blobBytes.clear(),
39
- ]);
40
- },
41
- cleanup: async () => {
42
- await coordination.close();
43
- connectivity.close();
44
- await database.closeAsync();
45
- },
46
- };
5
+ import { createExpoBrowserAuthentication } from "./createExpoBrowserAuthentication.js";
6
+ import { defineRuntime } from "@party-stack/runtime";
7
+ import "temporal-polyfill/global";
8
+ import { SingleProcessCoordination } from "@party-stack/coordination";
9
+ import { createExpoSQLitePersistence } from "@tanstack/expo-db-sqlite-persistence";
10
+ import { deleteDatabaseAsync, openDatabaseAsync } from "expo-sqlite";
11
+ //#region src/createExpoRuntime.ts
12
+ const createExpoRuntime = defineRuntime(async (owner, namespace) => {
13
+ const name = `party-stack:${owner}:${namespace}`;
14
+ const storageName = `party-stack-${await hashStorageName(JSON.stringify([owner, namespace]))}`;
15
+ const [database, connectivity] = await Promise.all([openDatabaseAsync(`${storageName}.db`), ExpoNetworkConnectivity.create()]);
16
+ const persistence = createExpoSQLitePersistence({ database });
17
+ const coordination = new SingleProcessCoordination({ scope: name });
18
+ const blobBytes = new ExpoFileSystemBlobBytesStore({ directoryName: `${storageName}-blobs` });
19
+ return {
20
+ owner,
21
+ namespace,
22
+ blobBytes,
23
+ browserAuthentication: createExpoBrowserAuthentication(),
24
+ secrets: new ExpoSecretStore(`${name}:secrets`),
25
+ connectivity,
26
+ coordination,
27
+ persistence,
28
+ destroy: async () => {
29
+ await Promise.all([deleteDatabaseAsync(`${storageName}.db`), blobBytes.clear()]);
30
+ },
31
+ cleanup: async () => {
32
+ await coordination.close();
33
+ connectivity.close();
34
+ await database.closeAsync();
35
+ }
36
+ };
47
37
  });
38
+ //#endregion
39
+ export { createExpoRuntime };
40
+
48
41
  //# sourceMappingURL=createExpoRuntime.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createExpoRuntime.js","sourceRoot":"","sources":["../src/createExpoRuntime.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,OAAO,0BAA0B,CAAC;AAClC,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EACH,2BAA2B,GAE9B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AACvF,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AACjF,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAC,KAAK,EAChD,KAAK,EACL,SAAS,EACX,EAAE;IACA,MAAM,IAAI,GAAG,eAAe,KAAK,IAAI,SAAS,EAAE,CAAC;IACjD,MAAM,CAAC,QAAQ,EAAE,YAAY,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAC/C,iBAAiB,CAAC,GAAG,IAAI,KAAK,CAAC;QAC/B,uBAAuB,CAAC,MAAM,EAAE;KACnC,CAAC,CAAC;IACH,MAAM,WAAW,GAAG,2BAA2B,CAAC;QAC5C,QAAQ,EAAE,QAA6C;KAC1D,CAAC,CAAC;IACH,MAAM,YAAY,GACd,IAAI,yBAAyB,CAAC;QAC1B,KAAK,EAAE,IAAI;KACd,CAAC,CAAC;IACP,MAAM,SAAS,GAAG,IAAI,4BAA4B,CAAC;QAC/C,aAAa,EAAE,GAAG,IAAI,QAAQ;KACjC,CAAC,CAAC;IACH,OAAO;QACH,KAAK;QACL,SAAS;QACT,SAAS;QACT,qBAAqB,EACjB,+BAA+B,EAAE;QACrC,OAAO,EAAE,IAAI,eAAe,CAAC,GAAG,IAAI,UAAU,CAAC;QAC/C,YAAY;QACZ,YAAY;QACZ,WAAW;QACX,OAAO,EAAE,KAAK,IAAI,EAAE;YAChB,MAAM,OAAO,CAAC,GAAG,CAAC;gBACd,mBAAmB,CAAC,GAAG,IAAI,KAAK,CAAC;gBACjC,SAAS,CAAC,KAAK,EAAE;aACpB,CAAC,CAAC;QACP,CAAC;QACD,OAAO,EAAE,KAAK,IAAI,EAAE;YAChB,MAAM,YAAY,CAAC,KAAK,EAAE,CAAC;YAC3B,YAAY,CAAC,KAAK,EAAE,CAAC;YACrB,MAAM,QAAQ,CAAC,UAAU,EAAE,CAAC;QAChC,CAAC;KACJ,CAAC;AACN,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"createExpoRuntime.js","names":[],"sources":["../src/createExpoRuntime.ts"],"sourcesContent":["// SQLite persistence revives Temporal values through the registered global constructors.\nimport \"temporal-polyfill/global\";\nimport { SingleProcessCoordination } from \"@party-stack/coordination\";\nimport { defineRuntime } from \"@party-stack/runtime\";\nimport { createExpoSQLitePersistence } from \"@tanstack/expo-db-sqlite-persistence\";\nimport { deleteDatabaseAsync, openDatabaseAsync } from \"expo-sqlite\";\nimport { createExpoBrowserAuthentication } from \"./createExpoBrowserAuthentication.js\";\nimport { ExpoFileSystemBlobBytesStore } from \"./ExpoFileSystemBlobBytesStore.js\";\nimport { ExpoNetworkConnectivity } from \"./ExpoNetworkConnectivity.js\";\nimport { ExpoSecretStore } from \"./ExpoSecretStore.js\";\nimport { hashStorageName } from \"./hashStorageName.js\";\nimport type { RuntimeAdapter } from \"@party-stack/runtime\";\n\nexport const createExpoRuntime: (owner: string, namespace: string) => Promise<RuntimeAdapter> = defineRuntime(\n async (owner, namespace) => {\n const name = `party-stack:${owner}:${namespace}`;\n const storageName = `party-stack-${await hashStorageName(JSON.stringify([owner, namespace]))}`;\n const [database, connectivity] = await Promise.all([\n openDatabaseAsync(`${storageName}.db`),\n ExpoNetworkConnectivity.create(),\n ]);\n const persistence = createExpoSQLitePersistence({\n database: database,\n });\n const coordination = new SingleProcessCoordination({\n scope: name,\n });\n const blobBytes = new ExpoFileSystemBlobBytesStore({\n directoryName: `${storageName}-blobs`,\n });\n return {\n owner,\n namespace,\n blobBytes,\n browserAuthentication: createExpoBrowserAuthentication(),\n secrets: new ExpoSecretStore(`${name}:secrets`),\n connectivity,\n coordination,\n persistence,\n destroy: async () => {\n await Promise.all([deleteDatabaseAsync(`${storageName}.db`), blobBytes.clear()]);\n },\n cleanup: async () => {\n await coordination.close();\n connectivity.close();\n await database.closeAsync();\n },\n };\n }\n);\n"],"mappings":";;;;;;;;;;;AAaA,MAAa,oBAAmF,cAC5F,OAAO,OAAO,cAAc;CACxB,MAAM,OAAO,eAAe,MAAM,GAAG;CACrC,MAAM,cAAc,eAAe,MAAM,gBAAgB,KAAK,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC;CAC3F,MAAM,CAAC,UAAU,gBAAgB,MAAM,QAAQ,IAAI,CAC/C,kBAAkB,GAAG,YAAY,IAAI,GACrC,wBAAwB,OAAO,CACnC,CAAC;CACD,MAAM,cAAc,4BAA4B,EAClC,SACd,CAAC;CACD,MAAM,eAAe,IAAI,0BAA0B,EAC/C,OAAO,KACX,CAAC;CACD,MAAM,YAAY,IAAI,6BAA6B,EAC/C,eAAe,GAAG,YAAY,QAClC,CAAC;CACD,OAAO;EACH;EACA;EACA;EACA,uBAAuB,gCAAgC;EACvD,SAAS,IAAI,gBAAgB,GAAG,KAAK,SAAS;EAC9C;EACA;EACA;EACA,SAAS,YAAY;GACjB,MAAM,QAAQ,IAAI,CAAC,oBAAoB,GAAG,YAAY,IAAI,GAAG,UAAU,MAAM,CAAC,CAAC;EACnF;EACA,SAAS,YAAY;GACjB,MAAM,aAAa,MAAM;GACzB,aAAa,MAAM;GACnB,MAAM,SAAS,WAAW;EAC9B;CACJ;AACJ,CACJ"}
@@ -0,0 +1,4 @@
1
+ //#region src/hashStorageName.d.ts
2
+ export declare function hashStorageName(value: string): Promise<string>;
3
+ //#endregion
4
+ //# sourceMappingURL=hashStorageName.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hashStorageName.d.ts","names":[],"sources":["../src/hashStorageName.ts"],"mappings":";wBAEgB,gBAAgB,gBAAgB"}
@@ -0,0 +1,9 @@
1
+ import { CryptoDigestAlgorithm, digestStringAsync } from "expo-crypto";
2
+ //#region src/hashStorageName.ts
3
+ function hashStorageName(value) {
4
+ return digestStringAsync(CryptoDigestAlgorithm.SHA256, value);
5
+ }
6
+ //#endregion
7
+ export { hashStorageName };
8
+
9
+ //# sourceMappingURL=hashStorageName.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hashStorageName.js","names":[],"sources":["../src/hashStorageName.ts"],"sourcesContent":["import { CryptoDigestAlgorithm, digestStringAsync } from \"expo-crypto\";\n\nexport function hashStorageName(value: string): Promise<string> {\n return digestStringAsync(CryptoDigestAlgorithm.SHA256, value);\n}\n"],"mappings":";;AAEA,SAAgB,gBAAgB,OAAgC;CAC5D,OAAO,kBAAkB,sBAAsB,QAAQ,KAAK;AAChE"}
package/lib/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { createExpoRuntime } from "./createExpoRuntime.js";
2
- //# sourceMappingURL=index.d.ts.map
1
+ import { createExpoRuntime } from "./createExpoRuntime.js";
2
+ export { createExpoRuntime };
package/lib/index.js CHANGED
@@ -1,2 +1 @@
1
1
  export { createExpoRuntime } from "./createExpoRuntime.js";
2
- //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ export {}
@@ -0,0 +1,33 @@
1
+ import { Blob } from "expo-blob";
2
+ //#region src/polyfill.ts
3
+ globalThis.Blob = Blob;
4
+ var ExpoFile = class extends globalThis.Blob {
5
+ #name;
6
+ #lastModified;
7
+ constructor(parts, name, options = {}) {
8
+ super(parts, options);
9
+ this.#name = String(name);
10
+ this.#lastModified = options.lastModified ?? Date.now();
11
+ Object.defineProperty(this, "name", {
12
+ value: this.#name,
13
+ enumerable: true
14
+ });
15
+ }
16
+ get name() {
17
+ return this.#name;
18
+ }
19
+ get lastModified() {
20
+ return this.#lastModified;
21
+ }
22
+ get webkitRelativePath() {
23
+ return "";
24
+ }
25
+ get [Symbol.toStringTag]() {
26
+ return "File";
27
+ }
28
+ };
29
+ globalThis.File = ExpoFile;
30
+ //#endregion
31
+ export {};
32
+
33
+ //# sourceMappingURL=polyfill.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"polyfill.js","names":[],"sources":["../src/polyfill.ts"],"sourcesContent":["import { Blob } from \"expo-blob\";\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":";;AAGA,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"}
package/package.json CHANGED
@@ -1,41 +1,46 @@
1
1
  {
2
2
  "name": "@party-stack/expo-runtime",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
+ "files": [
5
+ "lib"
6
+ ],
4
7
  "type": "module",
8
+ "sideEffects": [
9
+ "./lib/polyfill.js"
10
+ ],
5
11
  "exports": {
6
12
  ".": {
7
13
  "types": "./lib/index.d.ts",
8
14
  "default": "./lib/index.js"
15
+ },
16
+ "./polyfill": {
17
+ "types": "./lib/polyfill.d.ts",
18
+ "default": "./lib/polyfill.js"
9
19
  }
10
20
  },
11
- "files": [
12
- "lib"
13
- ],
14
21
  "dependencies": {
15
- "@tanstack/expo-db-sqlite-persistence": "0.2.30",
16
- "expo-secure-store": "^57.0.1",
17
- "expo-web-browser": "^57.0.2",
22
+ "@tanstack/expo-db-sqlite-persistence": "0.2.34",
23
+ "expo-blob": "^57.0.2",
24
+ "expo-crypto": "^57.0.4",
25
+ "expo-secure-store": "^57.0.4",
26
+ "expo-web-browser": "^57.0.3",
18
27
  "temporal-polyfill": "^0.3.0",
19
- "@party-stack/coordination": "0.3.0",
20
- "@party-stack/runtime": "0.4.0"
28
+ "@party-stack/coordination": "0.3.1",
29
+ "@party-stack/runtime": "0.4.2"
21
30
  },
22
31
  "devDependencies": {
23
- "@bobbyfidz/universal-build-config": "^0.1.1",
24
32
  "@react-native-community/netinfo": "^12.0.1",
25
- "eslint": "^9.25.0",
26
- "expo-file-system": "^55.0.19",
27
- "expo-sqlite": "^55.0.15",
28
- "typescript": "~5.8.3",
29
- "vitest": "^3.1.1"
33
+ "expo": "^57.0.29",
34
+ "expo-file-system": "^57.0.7",
35
+ "expo-sqlite": "^57.0.4",
36
+ "typescript": "~7.0.2",
37
+ "vite-plus": "1.2.0",
38
+ "@party-stack/build-config": "0.1.3"
30
39
  },
31
40
  "peerDependencies": {
32
41
  "@react-native-community/netinfo": "^12.0.1",
33
- "expo-file-system": "^55.0.19",
34
- "expo-sqlite": "^55.0.15"
35
- },
36
- "scripts": {
37
- "build": "tsc",
38
- "lint": "eslint",
39
- "test": "vitest run --pass-with-no-tests"
42
+ "expo": "^57.0.29",
43
+ "expo-file-system": "^57.0.7",
44
+ "expo-sqlite": "^57.0.4"
40
45
  }
41
46
  }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=ExpoSecretStore.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExpoSecretStore.test.d.ts","sourceRoot":"","sources":["../src/ExpoSecretStore.test.ts"],"names":[],"mappings":""}
@@ -1,40 +0,0 @@
1
- import { beforeEach, describe, expect, it, vi, } from "vitest";
2
- import { ExpoSecretStore } from "./ExpoSecretStore.js";
3
- const secureStore = vi.hoisted(() => ({
4
- deleteItemAsync: vi.fn((key) => {
5
- void key;
6
- return Promise.resolve();
7
- }),
8
- getItemAsync: vi.fn((key) => {
9
- void key;
10
- return Promise.resolve(null);
11
- }),
12
- setItemAsync: vi.fn((key, value) => {
13
- void key;
14
- void value;
15
- return Promise.resolve();
16
- }),
17
- }));
18
- vi.mock("expo-secure-store", () => secureStore);
19
- describe("ExpoSecretStore", () => {
20
- beforeEach(() => {
21
- vi.clearAllMocks();
22
- });
23
- it("encodes namespaced keys using only SecureStore-safe characters", async () => {
24
- const store = new ExpoSecretStore("party-stack:user@example.com:oauth");
25
- await store.set("tokens/client:id", "secret");
26
- const key = secureStore.setItemAsync
27
- .mock.calls[0]?.[0];
28
- expect(key).toMatch(/^[A-Za-z0-9._-]+$/);
29
- expect(key).not.toContain("user@example.com");
30
- expect(secureStore.setItemAsync).toHaveBeenCalledWith(key, "secret");
31
- });
32
- it("separates prefix and key without collisions", async () => {
33
- await new ExpoSecretStore("a").set("b:c", "one");
34
- await new ExpoSecretStore("a:b").set("c", "two");
35
- expect(secureStore.setItemAsync
36
- .mock.calls[0]?.[0]).not.toBe(secureStore.setItemAsync
37
- .mock.calls[1]?.[0]);
38
- });
39
- });
40
- //# sourceMappingURL=ExpoSecretStore.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExpoSecretStore.test.js","sourceRoot":"","sources":["../src/ExpoSecretStore.test.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,UAAU,EACV,QAAQ,EACR,MAAM,EACN,EAAE,EACF,EAAE,GACL,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,WAAW,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAClC,eAAe,EAAE,EAAE,CAAC,EAAE,CAClB,CAAC,GAAW,EAAE,EAAE;QACZ,KAAK,GAAG,CAAC;QACT,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC,CACJ;IACD,YAAY,EAAE,EAAE,CAAC,EAAE,CACf,CAAC,GAAW,EAAE,EAAE;QACZ,KAAK,GAAG,CAAC;QACT,OAAO,OAAO,CAAC,OAAO,CAClB,IAAI,CACP,CAAC;IACN,CAAC,CACJ;IACD,YAAY,EAAE,EAAE,CAAC,EAAE,CACf,CACI,GAAW,EACX,KAAa,EACf,EAAE;QACA,KAAK,GAAG,CAAC;QACT,KAAK,KAAK,CAAC;QACX,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC,CACJ;CACJ,CAAC,CAAC,CAAC;AAEJ,EAAE,CAAC,IAAI,CAAC,mBAAmB,EAAE,GAAG,EAAE,CAC9B,WAAW,CACd,CAAC;AAEF,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC7B,UAAU,CAAC,GAAG,EAAE;QACZ,EAAE,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gEAAgE,EAAE,KAAK,IAAI,EAAE;QAC5E,MAAM,KAAK,GACP,IAAI,eAAe,CACf,oCAAoC,CACvC,CAAC;QAEN,MAAM,KAAK,CAAC,GAAG,CACX,kBAAkB,EAClB,QAAQ,CACX,CAAC;QAEF,MAAM,GAAG,GACL,WAAW,CAAC,YAAY;aACnB,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC5B,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CACf,mBAAmB,CACtB,CAAC;QACF,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,SAAS,CACrB,kBAAkB,CACrB,CAAC;QACF,MAAM,CACF,WAAW,CAAC,YAAY,CAC3B,CAAC,oBAAoB,CAClB,GAAG,EACH,QAAQ,CACX,CAAC;IACN,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6CAA6C,EAAE,KAAK,IAAI,EAAE;QACzD,MAAM,IAAI,eAAe,CACrB,GAAG,CACN,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACpB,MAAM,IAAI,eAAe,CACrB,KAAK,CACR,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAElB,MAAM,CACF,WAAW,CAAC,YAAY;aACnB,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAC1B,CAAC,GAAG,CAAC,IAAI,CACN,WAAW,CAAC,YAAY;aACnB,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAC1B,CAAC;IACN,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC"}
package/lib/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC"}