@absolutejs/absolute 0.20.0-beta.44 → 0.20.0-beta.45

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.
@@ -0,0 +1,104 @@
1
+ // src/mobile/shellExpoSync.ts
2
+ import {
3
+ createExpoSyncBridgeLocalStore,
4
+ createExpoSyncBridgeWebSocket
5
+ } from "@absolutejs/sync-expo/client";
6
+ import { installSyncClientRuntimeTransport } from "@absolutejs/sync/client/runtime";
7
+
8
+ // src/mobile/syncRemediation.ts
9
+ import {
10
+ discardSyncRuntimeDeadLetter,
11
+ inspectSyncRuntime,
12
+ rebaseSyncRuntimeDeadLetter,
13
+ retrySyncRuntimeDeadLetter
14
+ } from "@absolutejs/sync/client/runtime";
15
+ var REMEDIATION_REGISTRY = Symbol.for("@absolutejs/mobile-sync-remediation");
16
+ var isRegistry = (value) => typeof value === "object" && value !== null && Array.isArray(Reflect.get(value, "installations"));
17
+ var resolveRegistry = () => {
18
+ const existing = Reflect.get(globalThis, REMEDIATION_REGISTRY);
19
+ if (isRegistry(existing))
20
+ return existing;
21
+ const created = { installations: [] };
22
+ Object.defineProperty(globalThis, REMEDIATION_REGISTRY, {
23
+ configurable: false,
24
+ enumerable: false,
25
+ value: created,
26
+ writable: false
27
+ });
28
+ return created;
29
+ };
30
+ var registry = resolveRegistry();
31
+ var installAbsoluteMobileSyncRemediation = (bridge = {
32
+ discard: discardSyncRuntimeDeadLetter,
33
+ inspect: inspectSyncRuntime,
34
+ rebase: rebaseSyncRuntimeDeadLetter,
35
+ retry: retrySyncRuntimeDeadLetter
36
+ }) => {
37
+ const installation = { bridge };
38
+ registry.installations.push(installation);
39
+ return () => {
40
+ const index = registry.installations.indexOf(installation);
41
+ if (index >= 0)
42
+ registry.installations.splice(index, 1);
43
+ };
44
+ };
45
+
46
+ // src/mobile/shellExpoSync.ts
47
+ var requireBridge = () => {
48
+ const value = Reflect.get(globalThis, "__absoluteExpoBridge");
49
+ if (typeof value !== "object" || value === null || typeof Reflect.get(value, "request") !== "function" || typeof Reflect.get(value, "on") !== "function")
50
+ throw new TypeError("The Expo Sync bridge is unavailable.");
51
+ return {
52
+ on: (event, listener) => Reflect.apply(Reflect.get(value, "on"), value, [event, listener]),
53
+ request: (method, params) => Promise.resolve(Reflect.apply(Reflect.get(value, "request"), value, [
54
+ method,
55
+ params
56
+ ]))
57
+ };
58
+ };
59
+ var reportShellStatus = (status) => globalThis.dispatchEvent(new CustomEvent("absolute:sync-status", { detail: status }));
60
+ var installAbsoluteExpoShellSync = (auth, config, options = {}) => {
61
+ const provider = options.provider ?? requireBridge();
62
+ const namespace = auth.principal?.namespace;
63
+ const store = namespace && config ? createExpoSyncBridgeLocalStore({
64
+ provider,
65
+ storageSchema: config.storageSchema
66
+ }) : undefined;
67
+ const WebSocketImpl = createExpoSyncBridgeWebSocket(provider);
68
+ const reportStatus = options.reportStatus ?? reportShellStatus;
69
+ const removeTransport = installSyncClientRuntimeTransport({
70
+ ...namespace && store ? { durable: { namespace, store } } : {},
71
+ webSocketImpl: WebSocketImpl,
72
+ registerClient: (client) => {
73
+ const removeStatus = client.subscribeStatus(reportStatus);
74
+ const removeWake = provider.on("sync.wake", () => {
75
+ client.reconnect();
76
+ client.flush({ timeoutMs: 1e4 }).catch(() => {
77
+ return;
78
+ });
79
+ });
80
+ return () => {
81
+ removeStatus();
82
+ removeWake();
83
+ };
84
+ }
85
+ });
86
+ const removeRemediation = installAbsoluteMobileSyncRemediation();
87
+ const reload = options.reload ?? (() => globalThis.location.reload());
88
+ const removePrincipalListener = auth.onPrincipalChange((principal) => {
89
+ if (principal?.namespace !== namespace)
90
+ reload();
91
+ });
92
+ let active = true;
93
+ return () => {
94
+ if (!active)
95
+ return;
96
+ active = false;
97
+ removePrincipalListener();
98
+ removeRemediation();
99
+ removeTransport();
100
+ };
101
+ };
102
+ export {
103
+ installAbsoluteExpoShellSync
104
+ };
@@ -1,3 +1,3 @@
1
1
  import type { MobileConfig } from '../../types/build';
2
- export declare const absoluteNativeDevAdapterSource: (projectRoot: string, mobile: MobileConfig, resolveModule?: (specifier: string) => string, expoAdapterModule?: string, expoAuthModule?: string) => string;
2
+ export declare const absoluteNativeDevAdapterSource: (projectRoot: string, mobile: MobileConfig, resolveModule?: (specifier: string) => string, expoAdapterModule?: string, expoAuthModule?: string, expoSyncModule?: string) => string;
3
3
  export declare const buildAbsoluteNativeDevAdapter: (projectRoot: string, mobile: MobileConfig) => Promise<string>;
@@ -1,6 +1,6 @@
1
- export declare const ABSOLUTE_EXPO_BRIDGE_FORMAT: 2;
1
+ export declare const ABSOLUTE_EXPO_BRIDGE_FORMAT: 3;
2
2
  export declare const ABSOLUTE_EXPO_BRIDGE_MAX_BYTES: number;
3
- export declare const ABSOLUTE_EXPO_BRIDGE_METHODS: readonly ["devices.haptics.impact", "http.fetch", "auth.signIn", "auth.signOut", "auth.status"];
3
+ export declare const ABSOLUTE_EXPO_BRIDGE_METHODS: readonly ["devices.haptics.impact", "http.fetch", "auth.signIn", "auth.signOut", "auth.status", "sync.store.begin", "sync.store.deleteNamespace", "sync.store.end", "sync.store.schema", "sync.tx.deleteCollection", "sync.tx.deleteMutation", "sync.tx.getCollection", "sync.tx.getInstallationId", "sync.tx.getMutation", "sync.tx.listCollections", "sync.tx.listMutations", "sync.tx.putCollection", "sync.tx.putMutation", "sync.tx.setInstallationId", "sync.socket.close", "sync.socket.open", "sync.socket.sendChunk"];
4
4
  export type AbsoluteExpoBridgeMethod = (typeof ABSOLUTE_EXPO_BRIDGE_METHODS)[number];
5
5
  export type AbsoluteExpoBridgeRequest = {
6
6
  format: typeof ABSOLUTE_EXPO_BRIDGE_FORMAT;
@@ -23,7 +23,7 @@ export type AbsoluteExpoBridgeResponse = {
23
23
  export type AbsoluteExpoBridgeEvent = {
24
24
  format: typeof ABSOLUTE_EXPO_BRIDGE_FORMAT;
25
25
  kind: 'event';
26
- event: 'ready' | 'navigation' | 'auth.principal';
26
+ event: 'ready' | 'navigation' | 'auth.principal' | 'sync.socket' | 'sync.wake';
27
27
  path: string;
28
28
  payload?: Record<string, unknown>;
29
29
  };
@@ -33,12 +33,12 @@ export declare const createAbsoluteExpoBridgeError: (id: string, code: string, m
33
33
  code: string;
34
34
  message: string;
35
35
  };
36
- format: 2;
36
+ format: 3;
37
37
  id: string;
38
38
  kind: "response";
39
39
  result?: undefined;
40
40
  } | {
41
- format: 2;
41
+ format: 3;
42
42
  id: string;
43
43
  kind: "response";
44
44
  result: unknown;
@@ -49,22 +49,22 @@ export declare const createAbsoluteExpoBridgeResponse: (id: string, result: unkn
49
49
  code: string;
50
50
  message: string;
51
51
  };
52
- format: 2;
52
+ format: 3;
53
53
  id: string;
54
54
  kind: "response";
55
55
  result?: undefined;
56
56
  } | {
57
- format: 2;
57
+ format: 3;
58
58
  id: string;
59
59
  kind: "response";
60
60
  result: unknown;
61
61
  error?: undefined;
62
62
  };
63
63
  export declare const parseAbsoluteExpoBridgeMessage: (source: string) => {
64
- format: 2;
64
+ format: 3;
65
65
  id: string;
66
66
  kind: "request";
67
- method: "devices.haptics.impact" | "http.fetch" | "auth.signIn" | "auth.signOut" | "auth.status";
67
+ method: "devices.haptics.impact" | "http.fetch" | "auth.signIn" | "auth.signOut" | "auth.status" | "sync.store.begin" | "sync.store.deleteNamespace" | "sync.store.end" | "sync.store.schema" | "sync.tx.deleteCollection" | "sync.tx.deleteMutation" | "sync.tx.getCollection" | "sync.tx.getInstallationId" | "sync.tx.getMutation" | "sync.tx.listCollections" | "sync.tx.listMutations" | "sync.tx.putCollection" | "sync.tx.putMutation" | "sync.tx.setInstallationId" | "sync.socket.close" | "sync.socket.open" | "sync.socket.sendChunk";
68
68
  params: Record<string, unknown>;
69
69
  path: string;
70
70
  } | {
@@ -72,12 +72,12 @@ export declare const parseAbsoluteExpoBridgeMessage: (source: string) => {
72
72
  code: string;
73
73
  message: string;
74
74
  };
75
- format: 2;
75
+ format: 3;
76
76
  id: string;
77
77
  kind: "response";
78
78
  result?: undefined;
79
79
  } | {
80
- format: 2;
80
+ format: 3;
81
81
  id: string;
82
82
  kind: "response";
83
83
  result: unknown;
@@ -85,7 +85,7 @@ export declare const parseAbsoluteExpoBridgeMessage: (source: string) => {
85
85
  } | {
86
86
  payload?: Record<string, unknown> | undefined;
87
87
  event: string;
88
- format: 2;
88
+ format: 3;
89
89
  kind: "event";
90
90
  path: string;
91
91
  };
@@ -3,6 +3,9 @@ export declare const ABSOLUTE_AUTH_PACKAGE: "@absolutejs/auth";
3
3
  export declare const ABSOLUTE_EXPO_AUTH_CORE_VERSION: "0.75.6";
4
4
  export declare const ABSOLUTE_EXPO_AUTH_PACKAGE: "@absolutejs/auth-expo";
5
5
  export declare const ABSOLUTE_EXPO_AUTH_VERSION: "0.0.2";
6
+ export declare const ABSOLUTE_EXPO_SYNC_CORE_VERSION: "2.31.0";
7
+ export declare const ABSOLUTE_EXPO_SYNC_PACKAGE: "@absolutejs/sync-expo";
8
+ export declare const ABSOLUTE_EXPO_SYNC_VERSION: "0.0.2";
6
9
  export declare const ABSOLUTE_NATIVE_AUTH_CLIENTS_ENV: "ABSOLUTE_AUTH_NATIVE_CLIENTS";
7
10
  export declare const ABSOLUTE_NATIVE_AUTH_SCOPES: readonly ["openid", "profile"];
8
11
  export declare const ABSOLUTE_SYNC_PACKAGE: "@absolutejs/sync";
@@ -0,0 +1,18 @@
1
+ import { type AbsoluteExpoSyncBridgeProvider } from '@absolutejs/sync-expo/client';
2
+ import type { SyncClientStatus } from '@absolutejs/sync/client';
3
+ import type { AbsoluteMobileShellAuthRuntime } from './shellBootstrap';
4
+ import type { AbsoluteMobileClientManifest } from './transport';
5
+ type ExpoBridge = AbsoluteExpoSyncBridgeProvider & {
6
+ on(event: 'sync.socket' | 'sync.wake', listener: (payload: Record<string, unknown>) => void): () => void;
7
+ };
8
+ export type AbsoluteExpoShellSyncOptions = {
9
+ provider?: ExpoBridge;
10
+ reload?: () => void;
11
+ reportStatus?: (status: SyncClientStatus) => void;
12
+ };
13
+ /**
14
+ * Gives unchanged WebView page clients native-owned SQLite and sockets. Auth
15
+ * namespaces and socket tickets never cross into page-controlled JavaScript.
16
+ */
17
+ export declare const installAbsoluteExpoShellSync: (auth: AbsoluteMobileShellAuthRuntime, config?: NonNullable<AbsoluteMobileClientManifest["sync"]>, options?: AbsoluteExpoShellSyncOptions) => () => void;
18
+ export {};
package/package.json CHANGED
@@ -29,8 +29,9 @@
29
29
  "@absolutejs/dispatch": "0.9.0",
30
30
  "@absolutejs/manifest": "0.9.0",
31
31
  "@absolutejs/scoped-state": "0.2.2",
32
- "@absolutejs/sync": "2.29.0",
32
+ "@absolutejs/sync": "2.31.0",
33
33
  "@absolutejs/sync-capacitor": "0.9.2",
34
+ "@absolutejs/sync-expo": "0.0.2",
34
35
  "@angular/animations": "21.2.6",
35
36
  "@angular/cdk": "21.2.6",
36
37
  "@angular/common": "21.2.6",
@@ -506,7 +507,7 @@
506
507
  ]
507
508
  }
508
509
  },
509
- "version": "0.20.0-beta.44",
510
+ "version": "0.20.0-beta.45",
510
511
  "workspaces": [
511
512
  "tests/fixtures/*",
512
513
  "tests/fixtures/_packages/*"