@absolutejs/absolute 0.20.0-beta.6 → 0.20.0-beta.61
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 +205 -0
- package/dist/angular/browser.js +392 -405
- package/dist/angular/browser.js.map +3 -3
- package/dist/angular/components/core/streamingSlotRegistrar.js +7 -7
- package/dist/angular/components/core/streamingSlotRegistry.js +4 -4
- package/dist/angular/index.js +379 -321
- package/dist/angular/index.js.map +8 -7
- package/dist/angular/server.js +133 -61
- package/dist/angular/server.js.map +8 -7
- package/dist/build.js +2336 -1347
- package/dist/build.js.map +22 -17
- package/dist/cli/config/client.js +12 -12
- package/dist/cli/config/server.js +1140 -1091
- package/dist/cli/index.js +10107 -2126
- package/dist/client/chunks/angularPatch-arh4sr68.js +157 -0
- package/dist/client/chunks/angularPatch-arh4sr68.js.map +10 -0
- package/dist/client/chunks/index-5py90ctf.js +87 -0
- package/dist/client/chunks/index-5py90ctf.js.map +10 -0
- package/dist/client/chunks/index-m35nbkdp.js +374 -0
- package/dist/client/chunks/index-m35nbkdp.js.map +12 -0
- package/dist/client/chunks/index-qxjc7kc5.js +12 -0
- package/dist/client/chunks/index-qxjc7kc5.js.map +9 -0
- package/dist/client/chunks/islands-xj2n8nwf.js +281 -0
- package/dist/client/chunks/islands-xj2n8nwf.js.map +14 -0
- package/dist/client/chunks/react-pdg4325x.js +65 -0
- package/dist/client/chunks/react-pdg4325x.js.map +10 -0
- package/dist/client/chunks/svelte-s0c964kb.js +19 -0
- package/dist/client/chunks/svelte-s0c964kb.js.map +10 -0
- package/dist/client/chunks/vue-rdskrnyg.js +24 -0
- package/dist/client/chunks/vue-rdskrnyg.js.map +10 -0
- package/dist/client/index.js +73 -841
- package/dist/client/index.js.map +7 -20
- package/dist/core/streamingSlotRegistrar.js +15 -13
- package/dist/core/streamingSlotRegistrar.js.map +2 -2
- package/dist/core/streamingSlotRegistry.js +11 -9
- package/dist/core/streamingSlotRegistry.js.map +2 -2
- package/dist/dev/client/hmrClient.ts +35 -3
- package/dist/dev/client/hmrTiming.ts +6 -0
- package/dist/dev/client/syncDevtools.ts +237 -0
- package/dist/dev/serverBootstrap.js +28 -0
- package/dist/image-client/imageClient.js +7 -7
- package/dist/index.js +3756 -2361
- package/dist/index.js.map +38 -30
- package/dist/islands/browser.js +11 -25
- package/dist/islands/browser.js.map +2 -2
- package/dist/islands/index.js +55 -52
- package/dist/islands/index.js.map +5 -4
- package/dist/mobile/browser.js +429 -20
- package/dist/mobile/browser.js.map +8 -5
- package/dist/mobile/index.js +11287 -3348
- package/dist/mobile/index.js.map +47 -18
- package/dist/mobile/remoteMacAgentEntry.js +1374 -14
- package/dist/mobile/shellAuth.js +36 -0
- package/dist/mobile/shellBootstrap.js +1800 -0
- package/dist/mobile/shellExpoAuth.js +163 -0
- package/dist/mobile/shellExpoDevices.js +77 -0
- package/dist/mobile/shellExpoSync.js +104 -0
- package/dist/mobile/shellSync.js +184 -0
- package/dist/mobile/shellUpdate.js +532 -0
- package/dist/mobile/uiPrimitives.js +264 -0
- package/dist/react/browser.js +17 -59
- package/dist/react/browser.js.map +2 -2
- package/dist/react/components/browser/index.js +107 -107
- package/dist/react/components/index.js +118 -116
- package/dist/react/components/index.js.map +2 -2
- package/dist/react/hooks/index.js +11 -25
- package/dist/react/hooks/index.js.map +2 -2
- package/dist/react/index.js +110 -67
- package/dist/react/index.js.map +8 -7
- package/dist/react/jsxDevRuntimeCompat.js +11 -9
- package/dist/react/jsxDevRuntimeCompat.js.map +2 -2
- package/dist/react/jsxRuntimeCompat.js +11 -9
- package/dist/react/jsxRuntimeCompat.js.map +2 -2
- package/dist/react/router/browser.js +9 -7
- package/dist/react/router/browser.js.map +2 -2
- package/dist/react/router/index.js +9 -7
- package/dist/react/router/index.js.map +2 -2
- package/dist/react/server.js +67 -11
- package/dist/react/server.js.map +7 -6
- package/dist/src/build/pwa.d.ts +16 -0
- package/dist/src/cli/config/server.d.ts +1 -1
- package/dist/src/cli/instanceStatus.d.ts +1 -0
- package/dist/src/cli/scripts/dev.d.ts +2 -0
- package/dist/src/client/browserTranslation.d.ts +19 -0
- package/dist/src/client/index.d.ts +1 -0
- package/dist/src/core/browserTranslation.d.ts +6 -0
- package/dist/src/core/devBuild.d.ts +1 -0
- package/dist/src/core/prepare.d.ts +376 -0
- package/dist/src/dev/clientManager.d.ts +1 -0
- package/dist/src/dev/devCert.d.ts +6 -4
- package/dist/src/dev/serverEntryCopies.d.ts +3 -0
- package/dist/src/ember/browser.d.ts +0 -16
- package/dist/src/mobile/adaptiveShell.d.ts +27 -0
- package/dist/src/mobile/androidEmulatorController.d.ts +8 -1
- package/dist/src/mobile/androidRelease.d.ts +9 -2
- package/dist/src/mobile/androidTestReport.d.ts +14 -0
- package/dist/src/mobile/androidUpgradeConformance.d.ts +47 -0
- package/dist/src/mobile/androidWebView.d.ts +1 -0
- package/dist/src/mobile/browser.d.ts +2 -0
- package/dist/src/mobile/capacitorBundle.d.ts +19 -0
- package/dist/src/mobile/ciWorkflow.d.ts +26 -0
- package/dist/src/mobile/config.d.ts +10 -1
- package/dist/src/mobile/devDeviceAdapter.d.ts +3 -0
- package/dist/src/mobile/deviceCapabilities.d.ts +49 -0
- package/dist/src/mobile/expoBridge.d.ts +91 -0
- package/dist/src/mobile/expoDevController.d.ts +56 -0
- package/dist/src/mobile/expoProject.d.ts +16 -0
- package/dist/src/mobile/index.d.ts +23 -0
- package/dist/src/mobile/iosDeviceAcceptance.d.ts +32 -0
- package/dist/src/mobile/iosPhysicalDeviceTransport.d.ts +16 -0
- package/dist/src/mobile/iosRelease.d.ts +63 -3
- package/dist/src/mobile/iosSimulatorController.d.ts +20 -2
- package/dist/src/mobile/iosTestReport.d.ts +24 -0
- package/dist/src/mobile/mobileBundleInspection.d.ts +63 -0
- package/dist/src/mobile/mobileInspect.d.ts +142 -0
- package/dist/src/mobile/mobilePreview.d.ts +174 -0
- package/dist/src/mobile/mobilePreviewClient.d.ts +1 -0
- package/dist/src/mobile/nativeAuth.d.ts +6 -0
- package/dist/src/mobile/nativeBackgroundSync.d.ts +4 -0
- package/dist/src/mobile/nativeDeviceCapabilities.d.ts +6 -0
- package/dist/src/mobile/nativeRoute.d.ts +13 -0
- package/dist/src/mobile/nativeTestReport.d.ts +91 -0
- package/dist/src/mobile/nativeUpdates.d.ts +4 -0
- package/dist/src/mobile/navigationLifecycle.d.ts +36 -0
- package/dist/src/mobile/navigationState.d.ts +53 -0
- package/dist/src/mobile/pageProtocol.d.ts +2 -0
- package/dist/src/mobile/releaseDoctor.d.ts +23 -1
- package/dist/src/mobile/remoteMacProtocol.d.ts +134 -1
- package/dist/src/mobile/remoteMacWire.d.ts +1 -1
- package/dist/src/mobile/shellAuth.d.ts +8 -1
- package/dist/src/mobile/shellBootstrap.d.ts +15 -2
- package/dist/src/mobile/shellExpoAuth.d.ts +12 -0
- package/dist/src/mobile/shellExpoDevices.d.ts +3 -0
- package/dist/src/mobile/shellExpoSync.d.ts +18 -0
- package/dist/src/mobile/shellHttp.d.ts +2 -0
- package/dist/src/mobile/shellPush.d.ts +11 -0
- package/dist/src/mobile/shellSync.d.ts +46 -1
- package/dist/src/mobile/shellUpdate.d.ts +2 -0
- package/dist/src/mobile/syncRemediation.d.ts +10 -0
- package/dist/src/mobile/syncSchema.d.ts +9 -0
- package/dist/src/mobile/transport.d.ts +15 -0
- package/dist/src/mobile/uiPrimitives.d.ts +37 -0
- package/dist/src/mobile/updateClient.d.ts +44 -0
- package/dist/src/mobile/updateProtocol.d.ts +51 -0
- package/dist/src/mobile/updatePublisher.d.ts +66 -0
- package/dist/src/mobile/updateRollout.d.ts +16 -0
- package/dist/src/mobile/updateRuntime.d.ts +27 -0
- package/dist/src/mobile/updateSigning.d.ts +20 -0
- package/dist/src/plugins/hmr.d.ts +3 -0
- package/dist/src/plugins/imageOptimizer.d.ts +1 -1
- package/dist/src/react/hooks/useMediaQuery.d.ts +1 -1
- package/dist/src/utils/imageProcessing.d.ts +3 -0
- package/dist/src/utils/loadConfig.d.ts +1 -0
- package/dist/src/utils/logger.d.ts +1 -0
- package/dist/src/utils/startupBanner.d.ts +1 -0
- package/dist/src/utils/userAgentFunctions.d.ts +1 -1
- package/dist/src/vue/browser.d.ts +1 -0
- package/dist/src/vue/browserTranslation.d.ts +5 -0
- package/dist/src/vue/index.d.ts +1 -0
- package/dist/svelte/browser.js +12 -26
- package/dist/svelte/browser.js.map +2 -2
- package/dist/svelte/index.js +104 -61
- package/dist/svelte/index.js.map +8 -7
- package/dist/svelte/server.js +84 -28
- package/dist/svelte/server.js.map +7 -6
- package/dist/types/build.d.ts +64 -3
- package/dist/types/cli.d.ts +1 -0
- package/dist/types/messages.d.ts +1 -1
- package/dist/vue/browser.js +116 -56
- package/dist/vue/browser.js.map +5 -3
- package/dist/vue/components/Image.js +9 -7
- package/dist/vue/components/Image.js.map +2 -2
- package/dist/vue/components/index.js +11 -9
- package/dist/vue/components/index.js.map +2 -2
- package/dist/vue/index.js +211 -94
- package/dist/vue/index.js.map +10 -7
- package/dist/vue/server.js +69 -13
- package/dist/vue/server.js.map +7 -6
- package/package.json +40 -14
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
// src/mobile/shellExpoDevices.ts
|
|
2
|
+
import { installExpoWebViewDeviceAdapter } from "@absolutejs/devices-expo/bridge";
|
|
3
|
+
var bridge = () => {
|
|
4
|
+
const value = Reflect.get(globalThis, "__absoluteExpoBridge");
|
|
5
|
+
if (typeof value !== "object" || value === null || typeof Reflect.get(value, "request") !== "function") {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
return {
|
|
9
|
+
on: (event, listener) => {
|
|
10
|
+
const eventRegistrar = Reflect.get(value, "on");
|
|
11
|
+
if (typeof eventRegistrar !== "function")
|
|
12
|
+
return () => {
|
|
13
|
+
return;
|
|
14
|
+
};
|
|
15
|
+
const subscription = Reflect.apply(eventRegistrar, value, [
|
|
16
|
+
event,
|
|
17
|
+
listener
|
|
18
|
+
]);
|
|
19
|
+
if (typeof subscription !== "function")
|
|
20
|
+
return () => {
|
|
21
|
+
return;
|
|
22
|
+
};
|
|
23
|
+
return async () => {
|
|
24
|
+
await Reflect.apply(subscription, undefined, []);
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
request: (method, params) => Promise.resolve(Reflect.apply(Reflect.get(value, "request"), value, [
|
|
28
|
+
method,
|
|
29
|
+
params
|
|
30
|
+
]))
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
var parseFetchResult = (value) => {
|
|
34
|
+
if (!value || typeof value !== "object")
|
|
35
|
+
throw new TypeError("The Expo HTTP bridge returned an invalid response.");
|
|
36
|
+
const body = Reflect.get(value, "body");
|
|
37
|
+
const headers = Reflect.get(value, "headers");
|
|
38
|
+
const status = Reflect.get(value, "status");
|
|
39
|
+
if (typeof body !== "string" || typeof status !== "number" || !Number.isInteger(status) || !headers || typeof headers !== "object") {
|
|
40
|
+
throw new TypeError("The Expo HTTP bridge returned an invalid response.");
|
|
41
|
+
}
|
|
42
|
+
const entries = Object.entries(headers);
|
|
43
|
+
if (!entries.every(([, header]) => typeof header === "string")) {
|
|
44
|
+
throw new TypeError("The Expo HTTP bridge returned invalid headers.");
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
body,
|
|
48
|
+
headers: Object.fromEntries(entries.map(([name, header]) => [name, String(header)])),
|
|
49
|
+
status
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
var requireBridge = () => {
|
|
53
|
+
const provider = bridge();
|
|
54
|
+
if (!provider)
|
|
55
|
+
throw new TypeError("The Expo WebView bridge is unavailable.");
|
|
56
|
+
return provider;
|
|
57
|
+
};
|
|
58
|
+
var createAbsoluteExpoBridgeFetch = () => async (input, init) => {
|
|
59
|
+
const request = new Request(input, init);
|
|
60
|
+
const body = request.method === "GET" || request.method === "DELETE" ? undefined : await request.text();
|
|
61
|
+
const headers = Object.fromEntries(request.headers);
|
|
62
|
+
const result = parseFetchResult(await requireBridge().request("http.fetch", {
|
|
63
|
+
...body === undefined ? {} : { body },
|
|
64
|
+
headers,
|
|
65
|
+
method: request.method,
|
|
66
|
+
url: request.url
|
|
67
|
+
}));
|
|
68
|
+
return new Response(result.body, {
|
|
69
|
+
headers: result.headers,
|
|
70
|
+
status: result.status
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
var installAbsoluteExpoWebDeviceAdapter = (capabilities = []) => installExpoWebViewDeviceAdapter(requireBridge(), capabilities);
|
|
74
|
+
|
|
75
|
+
// src/mobile/shellExpoAuth.ts
|
|
76
|
+
import {
|
|
77
|
+
installAuthClientRuntimeTransport
|
|
78
|
+
} from "@absolutejs/auth/client/mobile";
|
|
79
|
+
var requireBridge2 = () => {
|
|
80
|
+
const value = Reflect.get(globalThis, "__absoluteExpoBridge");
|
|
81
|
+
if (typeof value !== "object" || value === null || typeof Reflect.get(value, "request") !== "function") {
|
|
82
|
+
throw new TypeError("The Expo Auth bridge is unavailable.");
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
on: typeof Reflect.get(value, "on") === "function" ? (event, listener) => Reflect.apply(Reflect.get(value, "on"), value, [
|
|
86
|
+
event,
|
|
87
|
+
listener
|
|
88
|
+
]) : undefined,
|
|
89
|
+
request: (method, params) => Promise.resolve(Reflect.apply(Reflect.get(value, "request"), value, [
|
|
90
|
+
method,
|
|
91
|
+
params
|
|
92
|
+
]))
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
var parseStatus = (value) => {
|
|
96
|
+
if (typeof value !== "object" || value === null)
|
|
97
|
+
throw new TypeError("The Expo Auth bridge returned an invalid status.");
|
|
98
|
+
const principal = Reflect.get(value, "principal");
|
|
99
|
+
if (principal !== null && (typeof principal !== "object" || principal === null || typeof Reflect.get(principal, "namespace") !== "string")) {
|
|
100
|
+
throw new TypeError("The Expo Auth bridge returned an invalid principal.");
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
principal: principal === null ? null : { namespace: String(Reflect.get(principal, "namespace")) },
|
|
104
|
+
user: Reflect.get(value, "user") ?? null
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
var createAbsoluteExpoShellAuth = async (config) => {
|
|
108
|
+
const provider = requireBridge2();
|
|
109
|
+
const fetch = createAbsoluteExpoBridgeFetch();
|
|
110
|
+
const authFetch = (input, init) => {
|
|
111
|
+
const resolved = typeof input === "string" || input instanceof URL ? new URL(String(input), config.issuer) : input;
|
|
112
|
+
return fetch(resolved, init);
|
|
113
|
+
};
|
|
114
|
+
let status = { principal: null, user: null };
|
|
115
|
+
const listeners = new Set;
|
|
116
|
+
provider.on?.("auth.principal", (payload) => {
|
|
117
|
+
status = parseStatus({
|
|
118
|
+
principal: payload.principal,
|
|
119
|
+
user: status.user
|
|
120
|
+
});
|
|
121
|
+
for (const listener of listeners)
|
|
122
|
+
listener(status.principal);
|
|
123
|
+
});
|
|
124
|
+
installAuthClientRuntimeTransport({
|
|
125
|
+
fetch: authFetch,
|
|
126
|
+
signInEmail: async ({ email }) => {
|
|
127
|
+
status = parseStatus(await provider.request("auth.signIn", { email, signup: false }));
|
|
128
|
+
return { status: "authenticated" };
|
|
129
|
+
},
|
|
130
|
+
signOut: async () => {
|
|
131
|
+
await provider.request("auth.signOut", {});
|
|
132
|
+
status = { principal: null, user: null };
|
|
133
|
+
return null;
|
|
134
|
+
},
|
|
135
|
+
signUpEmail: async ({ email }) => {
|
|
136
|
+
status = parseStatus(await provider.request("auth.signIn", { email, signup: true }));
|
|
137
|
+
return { status: "authenticated" };
|
|
138
|
+
},
|
|
139
|
+
status: async () => {
|
|
140
|
+
status = parseStatus(await provider.request("auth.status", {}));
|
|
141
|
+
return { user: status.user };
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
status = parseStatus(await provider.request("auth.status", {}));
|
|
145
|
+
return {
|
|
146
|
+
clientId: config.clientId,
|
|
147
|
+
fetch,
|
|
148
|
+
issuer: config.issuer,
|
|
149
|
+
principal: status.principal,
|
|
150
|
+
redirectUri: config.redirectUri,
|
|
151
|
+
onPrincipalChange: (listener) => {
|
|
152
|
+
listeners.add(listener);
|
|
153
|
+
listener(status.principal);
|
|
154
|
+
return () => listeners.delete(listener);
|
|
155
|
+
},
|
|
156
|
+
socketTicket: async () => {
|
|
157
|
+
throw new TypeError("Expo socket tickets remain native-only until @absolutejs/sync-expo is installed.");
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
export {
|
|
162
|
+
createAbsoluteExpoShellAuth
|
|
163
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// src/mobile/shellExpoDevices.ts
|
|
2
|
+
import { installExpoWebViewDeviceAdapter } from "@absolutejs/devices-expo/bridge";
|
|
3
|
+
var bridge = () => {
|
|
4
|
+
const value = Reflect.get(globalThis, "__absoluteExpoBridge");
|
|
5
|
+
if (typeof value !== "object" || value === null || typeof Reflect.get(value, "request") !== "function") {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
return {
|
|
9
|
+
on: (event, listener) => {
|
|
10
|
+
const eventRegistrar = Reflect.get(value, "on");
|
|
11
|
+
if (typeof eventRegistrar !== "function")
|
|
12
|
+
return () => {
|
|
13
|
+
return;
|
|
14
|
+
};
|
|
15
|
+
const subscription = Reflect.apply(eventRegistrar, value, [
|
|
16
|
+
event,
|
|
17
|
+
listener
|
|
18
|
+
]);
|
|
19
|
+
if (typeof subscription !== "function")
|
|
20
|
+
return () => {
|
|
21
|
+
return;
|
|
22
|
+
};
|
|
23
|
+
return async () => {
|
|
24
|
+
await Reflect.apply(subscription, undefined, []);
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
request: (method, params) => Promise.resolve(Reflect.apply(Reflect.get(value, "request"), value, [
|
|
28
|
+
method,
|
|
29
|
+
params
|
|
30
|
+
]))
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
var parseFetchResult = (value) => {
|
|
34
|
+
if (!value || typeof value !== "object")
|
|
35
|
+
throw new TypeError("The Expo HTTP bridge returned an invalid response.");
|
|
36
|
+
const body = Reflect.get(value, "body");
|
|
37
|
+
const headers = Reflect.get(value, "headers");
|
|
38
|
+
const status = Reflect.get(value, "status");
|
|
39
|
+
if (typeof body !== "string" || typeof status !== "number" || !Number.isInteger(status) || !headers || typeof headers !== "object") {
|
|
40
|
+
throw new TypeError("The Expo HTTP bridge returned an invalid response.");
|
|
41
|
+
}
|
|
42
|
+
const entries = Object.entries(headers);
|
|
43
|
+
if (!entries.every(([, header]) => typeof header === "string")) {
|
|
44
|
+
throw new TypeError("The Expo HTTP bridge returned invalid headers.");
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
body,
|
|
48
|
+
headers: Object.fromEntries(entries.map(([name, header]) => [name, String(header)])),
|
|
49
|
+
status
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
var requireBridge = () => {
|
|
53
|
+
const provider = bridge();
|
|
54
|
+
if (!provider)
|
|
55
|
+
throw new TypeError("The Expo WebView bridge is unavailable.");
|
|
56
|
+
return provider;
|
|
57
|
+
};
|
|
58
|
+
var createAbsoluteExpoBridgeFetch = () => async (input, init) => {
|
|
59
|
+
const request = new Request(input, init);
|
|
60
|
+
const body = request.method === "GET" || request.method === "DELETE" ? undefined : await request.text();
|
|
61
|
+
const headers = Object.fromEntries(request.headers);
|
|
62
|
+
const result = parseFetchResult(await requireBridge().request("http.fetch", {
|
|
63
|
+
...body === undefined ? {} : { body },
|
|
64
|
+
headers,
|
|
65
|
+
method: request.method,
|
|
66
|
+
url: request.url
|
|
67
|
+
}));
|
|
68
|
+
return new Response(result.body, {
|
|
69
|
+
headers: result.headers,
|
|
70
|
+
status: result.status
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
var installAbsoluteExpoWebDeviceAdapter = (capabilities = []) => installExpoWebViewDeviceAdapter(requireBridge(), capabilities);
|
|
74
|
+
export {
|
|
75
|
+
createAbsoluteExpoBridgeFetch,
|
|
76
|
+
installAbsoluteExpoWebDeviceAdapter
|
|
77
|
+
};
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
// src/mobile/shellSync.ts
|
|
2
|
+
import { lifecycle, network } from "@absolutejs/devices";
|
|
3
|
+
import {
|
|
4
|
+
createCapacitorSyncLocalStore,
|
|
5
|
+
createCapacitorSyncProtection,
|
|
6
|
+
AbsoluteBackgroundSync,
|
|
7
|
+
configureCapacitorBackgroundSync,
|
|
8
|
+
installCapacitorSyncLifecycle
|
|
9
|
+
} from "@absolutejs/sync-capacitor";
|
|
10
|
+
import { installSyncClientRuntimeTransport } from "@absolutejs/sync/client/runtime";
|
|
11
|
+
|
|
12
|
+
// src/mobile/syncRemediation.ts
|
|
13
|
+
import {
|
|
14
|
+
discardSyncRuntimeDeadLetter,
|
|
15
|
+
inspectSyncRuntime,
|
|
16
|
+
rebaseSyncRuntimeDeadLetter,
|
|
17
|
+
retrySyncRuntimeDeadLetter
|
|
18
|
+
} from "@absolutejs/sync/client/runtime";
|
|
19
|
+
var REMEDIATION_REGISTRY = Symbol.for("@absolutejs/mobile-sync-remediation");
|
|
20
|
+
var isRegistry = (value) => typeof value === "object" && value !== null && Array.isArray(Reflect.get(value, "installations"));
|
|
21
|
+
var resolveRegistry = () => {
|
|
22
|
+
const existing = Reflect.get(globalThis, REMEDIATION_REGISTRY);
|
|
23
|
+
if (isRegistry(existing))
|
|
24
|
+
return existing;
|
|
25
|
+
const created = { installations: [] };
|
|
26
|
+
Object.defineProperty(globalThis, REMEDIATION_REGISTRY, {
|
|
27
|
+
configurable: false,
|
|
28
|
+
enumerable: false,
|
|
29
|
+
value: created,
|
|
30
|
+
writable: false
|
|
31
|
+
});
|
|
32
|
+
return created;
|
|
33
|
+
};
|
|
34
|
+
var registry = resolveRegistry();
|
|
35
|
+
var installAbsoluteMobileSyncRemediation = (bridge = {
|
|
36
|
+
discard: discardSyncRuntimeDeadLetter,
|
|
37
|
+
inspect: inspectSyncRuntime,
|
|
38
|
+
rebase: rebaseSyncRuntimeDeadLetter,
|
|
39
|
+
retry: retrySyncRuntimeDeadLetter
|
|
40
|
+
}) => {
|
|
41
|
+
const installation = { bridge };
|
|
42
|
+
registry.installations.push(installation);
|
|
43
|
+
return () => {
|
|
44
|
+
const index = registry.installations.indexOf(installation);
|
|
45
|
+
if (index >= 0)
|
|
46
|
+
registry.installations.splice(index, 1);
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// src/mobile/shellSync.ts
|
|
51
|
+
var reloadShell = () => globalThis.location.reload();
|
|
52
|
+
var ABSOLUTE_MOBILE_SYNC_SCHEMA_EVENT = "absolute:sync-schema";
|
|
53
|
+
var ABSOLUTE_MOBILE_SYNC_SCHEMA_STATE_KEY = "absolutejs.mobile.sync.schema-state";
|
|
54
|
+
var ABSOLUTE_MOBILE_SYNC_STATUS_EVENT = "absolute:sync-status";
|
|
55
|
+
var schemaStateSymbol = () => Symbol.for(ABSOLUTE_MOBILE_SYNC_SCHEMA_STATE_KEY);
|
|
56
|
+
var readAbsoluteMobileSyncSchemaState = () => {
|
|
57
|
+
const value = Reflect.get(globalThis, schemaStateSymbol());
|
|
58
|
+
if (typeof value !== "object" || value === null)
|
|
59
|
+
return;
|
|
60
|
+
const state = Reflect.get(value, "state");
|
|
61
|
+
if (state === "preparing")
|
|
62
|
+
return { state };
|
|
63
|
+
if (state === "failed")
|
|
64
|
+
return schemaFailureState(value);
|
|
65
|
+
const minimumCompatibleVersion = Reflect.get(value, "minimumCompatibleVersion");
|
|
66
|
+
const storedVersion = Reflect.get(value, "storedVersion");
|
|
67
|
+
const targetVersion = Reflect.get(value, "targetVersion");
|
|
68
|
+
if (state !== "ready" || typeof minimumCompatibleVersion !== "number" || typeof storedVersion !== "number" || typeof targetVersion !== "number")
|
|
69
|
+
return;
|
|
70
|
+
return {
|
|
71
|
+
minimumCompatibleVersion,
|
|
72
|
+
state,
|
|
73
|
+
storedVersion,
|
|
74
|
+
targetVersion
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
var reportShellSchemaState = (state) => {
|
|
78
|
+
Reflect.set(globalThis, schemaStateSymbol(), state);
|
|
79
|
+
globalThis.dispatchEvent(new CustomEvent(ABSOLUTE_MOBILE_SYNC_SCHEMA_EVENT, { detail: state }));
|
|
80
|
+
};
|
|
81
|
+
var schemaFailureState = (error) => {
|
|
82
|
+
if (typeof error !== "object" || error === null)
|
|
83
|
+
return { code: "UNKNOWN", state: "failed" };
|
|
84
|
+
const rawCode = Reflect.get(error, "code");
|
|
85
|
+
const code = rawCode === "INVALID_PLAN" || rawCode === "MIGRATION_MISSING" || rawCode === "SCHEMA_TOO_NEW" || rawCode === "SCHEMA_TOO_OLD" ? rawCode : "UNKNOWN";
|
|
86
|
+
const storedVersion = Reflect.get(error, "storedVersion");
|
|
87
|
+
const targetVersion = Reflect.get(error, "targetVersion");
|
|
88
|
+
return {
|
|
89
|
+
code,
|
|
90
|
+
state: "failed",
|
|
91
|
+
...typeof storedVersion === "number" ? { storedVersion } : {},
|
|
92
|
+
...typeof targetVersion === "number" ? { targetVersion } : {}
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
var reportShellStatus = (status) => globalThis.dispatchEvent(new CustomEvent(ABSOLUTE_MOBILE_SYNC_STATUS_EVENT, { detail: status }));
|
|
96
|
+
var installAbsoluteMobileShellSync = (auth, config, options = {}) => {
|
|
97
|
+
const namespace = auth.principal?.namespace;
|
|
98
|
+
const store = namespace ? options.createStore?.({
|
|
99
|
+
protection: createCapacitorSyncProtection(),
|
|
100
|
+
storageSchema: config?.storageSchema
|
|
101
|
+
}) ?? createCapacitorSyncLocalStore({
|
|
102
|
+
protection: createCapacitorSyncProtection(),
|
|
103
|
+
storageSchema: config?.storageSchema
|
|
104
|
+
}) : undefined;
|
|
105
|
+
const installLifecycle = options.installLifecycle ?? installCapacitorSyncLifecycle;
|
|
106
|
+
const reportStatus = options.reportStatus ?? reportShellStatus;
|
|
107
|
+
const reportSchemaState = options.reportSchemaState ?? reportShellSchemaState;
|
|
108
|
+
const configureBackground = options.configureBackground ?? configureCapacitorBackgroundSync;
|
|
109
|
+
const clearBackground = options.clearBackground ?? (() => AbsoluteBackgroundSync.clear());
|
|
110
|
+
let schemaReady = Promise.resolve(true);
|
|
111
|
+
if (store?.getSchemaStatus) {
|
|
112
|
+
reportSchemaState({ state: "preparing" });
|
|
113
|
+
schemaReady = store.getSchemaStatus().then((state) => {
|
|
114
|
+
reportSchemaState(state);
|
|
115
|
+
return true;
|
|
116
|
+
}).catch((error) => {
|
|
117
|
+
reportSchemaState(schemaFailureState(error));
|
|
118
|
+
return false;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
if (namespace && config) {
|
|
122
|
+
schemaReady.then((ready) => {
|
|
123
|
+
if (!ready)
|
|
124
|
+
return;
|
|
125
|
+
return configureBackground({
|
|
126
|
+
clientId: auth.clientId,
|
|
127
|
+
endpoint: config.background.endpoint,
|
|
128
|
+
intervalMinutes: config.background.intervalMinutes,
|
|
129
|
+
issuer: auth.issuer,
|
|
130
|
+
namespace
|
|
131
|
+
});
|
|
132
|
+
}).catch((error) => console.error("[Absolute Mobile] Background Sync configuration failed:", error));
|
|
133
|
+
} else {
|
|
134
|
+
clearBackground().catch(() => {
|
|
135
|
+
return;
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
const removeTransport = installSyncClientRuntimeTransport({
|
|
139
|
+
...namespace && store ? { durable: { namespace, store } } : {},
|
|
140
|
+
socketTicket: auth.socketTicket,
|
|
141
|
+
registerClient: (client) => {
|
|
142
|
+
let active2 = true;
|
|
143
|
+
const removeStatus = client.subscribeStatus(reportStatus);
|
|
144
|
+
const reportLifecycleFailure = (error) => console.error("[Absolute Mobile] Sync lifecycle installation failed:", error);
|
|
145
|
+
const removal = installLifecycle({
|
|
146
|
+
client,
|
|
147
|
+
lifecycle,
|
|
148
|
+
network
|
|
149
|
+
}).catch((error) => {
|
|
150
|
+
reportLifecycleFailure(error);
|
|
151
|
+
return;
|
|
152
|
+
});
|
|
153
|
+
return () => {
|
|
154
|
+
if (!active2)
|
|
155
|
+
return;
|
|
156
|
+
active2 = false;
|
|
157
|
+
removeStatus();
|
|
158
|
+
removal.then((remove) => remove?.());
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
const removeRemediation = installAbsoluteMobileSyncRemediation();
|
|
163
|
+
const reload = options.reload ?? reloadShell;
|
|
164
|
+
const removePrincipalListener = auth.onPrincipalChange((principal) => {
|
|
165
|
+
if (principal?.namespace !== namespace)
|
|
166
|
+
reload();
|
|
167
|
+
});
|
|
168
|
+
let active = true;
|
|
169
|
+
return () => {
|
|
170
|
+
if (!active)
|
|
171
|
+
return;
|
|
172
|
+
active = false;
|
|
173
|
+
removePrincipalListener();
|
|
174
|
+
removeRemediation();
|
|
175
|
+
removeTransport();
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
export {
|
|
179
|
+
ABSOLUTE_MOBILE_SYNC_SCHEMA_EVENT,
|
|
180
|
+
ABSOLUTE_MOBILE_SYNC_SCHEMA_STATE_KEY,
|
|
181
|
+
ABSOLUTE_MOBILE_SYNC_STATUS_EVENT,
|
|
182
|
+
installAbsoluteMobileShellSync,
|
|
183
|
+
readAbsoluteMobileSyncSchemaState
|
|
184
|
+
};
|