@absolutejs/absolute 0.20.0-beta.5 → 0.20.0-beta.50
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 -361
- 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 +355 -302
- package/dist/angular/index.js.map +5 -5
- package/dist/angular/server.js +109 -58
- package/dist/angular/server.js.map +5 -5
- package/dist/build.js +2261 -1335
- package/dist/build.js.map +16 -12
- package/dist/cli/config/client.js +12 -12
- package/dist/cli/config/server.js +1136 -1090
- package/dist/cli/index.js +8247 -1898
- package/dist/client/index.js +29 -25
- package/dist/client/index.js.map +2 -2
- 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 +3400 -2126
- package/dist/index.js.map +30 -23
- package/dist/islands/browser.js +11 -9
- package/dist/islands/browser.js.map +2 -2
- package/dist/islands/index.js +39 -35
- package/dist/islands/index.js.map +2 -2
- package/dist/mobile/browser.js +167 -20
- package/dist/mobile/browser.js.map +7 -5
- package/dist/mobile/index.js +7840 -2983
- package/dist/mobile/index.js.map +37 -18
- package/dist/mobile/remoteMacAgentEntry.js +1184 -14
- package/dist/mobile/shellAuth.js +36 -0
- package/dist/mobile/shellBootstrap.js +836 -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 +173 -0
- package/dist/react/browser.js +17 -15
- 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 -9
- package/dist/react/hooks/index.js.map +2 -2
- package/dist/react/index.js +92 -49
- package/dist/react/index.js.map +4 -4
- 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 +51 -10
- package/dist/react/server.js.map +4 -4
- 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/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/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 +1 -0
- package/dist/src/mobile/capacitorBundle.d.ts +11 -0
- package/dist/src/mobile/ciWorkflow.d.ts +26 -0
- package/dist/src/mobile/config.d.ts +4 -1
- package/dist/src/mobile/devDeviceAdapter.d.ts +3 -0
- package/dist/src/mobile/deviceCapabilities.d.ts +48 -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 +14 -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 +16 -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 +55 -0
- package/dist/src/mobile/mobileInspect.d.ts +136 -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/pageProtocol.d.ts +2 -0
- package/dist/src/mobile/releaseDoctor.d.ts +23 -1
- package/dist/src/mobile/remoteMacProtocol.d.ts +38 -0
- 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 +14 -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/syncRemediation.d.ts +10 -0
- package/dist/src/mobile/syncSchema.d.ts +9 -0
- package/dist/src/mobile/transport.d.ts +7 -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/svelte/browser.js +12 -10
- package/dist/svelte/browser.js.map +2 -2
- package/dist/svelte/index.js +86 -43
- package/dist/svelte/index.js.map +4 -4
- package/dist/svelte/server.js +68 -27
- package/dist/svelte/server.js.map +4 -4
- package/dist/types/build.d.ts +53 -3
- package/dist/types/cli.d.ts +1 -0
- package/dist/types/messages.d.ts +1 -1
- package/dist/vue/browser.js +14 -12
- package/dist/vue/browser.js.map +2 -2
- 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 +91 -48
- package/dist/vue/index.js.map +4 -4
- package/dist/vue/server.js +53 -12
- package/dist/vue/server.js.map +4 -4
- package/package.json +35 -15
package/dist/mobile/index.js.map
CHANGED
|
@@ -1,44 +1,63 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/constants.ts", "../src/utils/getDurationString.ts", "../src/utils/startupBanner.ts", "../src/utils/stringModifiers.ts", "../src/mobile/artifactStore.ts", "../src/mobile/releaseArtifact.ts", "../src/mobile/androidRelease.ts", "../src/mobile/emulatorDoctor.ts", "../src/cli/utils.ts", "../src/mobile/androidEmulatorController.ts", "../src/mobile/capacitorProject.ts", "../src/mobile/iosRelease.ts", "../src/mobile/iosConformance.ts", "../src/mobile/iosSimulatorController.ts", "../src/mobile/iosNativeWatcher.ts", "../src/mobile/remoteMacProtocol.ts", "../src/mobile/remoteMacWire.ts", "../src/mobile/
|
|
3
|
+
"sources": ["../src/constants.ts", "../src/utils/getDurationString.ts", "../src/utils/startupBanner.ts", "../src/mobile/config.ts", "../src/utils/stringModifiers.ts", "../src/mobile/nativeAuth.ts", "../node_modules/@absolutejs/sync/dist/client/index.js", "../src/mobile/syncSchema.ts", "../src/mobile/deviceCapabilities.ts", "../src/cli/scripts/telemetry.ts", "../src/cli/telemetryEvent.ts", "../src/mobile/artifactStore.ts", "../src/mobile/releaseArtifact.ts", "../src/mobile/androidRelease.ts", "../src/mobile/emulatorDoctor.ts", "../src/cli/utils.ts", "../src/mobile/androidEmulatorController.ts", "../src/mobile/capacitorProject.ts", "../src/mobile/androidUpgradeConformance.ts", "../src/mobile/iosRelease.ts", "../src/mobile/iosConformance.ts", "../src/mobile/iosSimulatorController.ts", "../src/mobile/iosPhysicalDeviceTransport.ts", "../src/mobile/iosNativeWatcher.ts", "../src/mobile/remoteMacProtocol.ts", "../src/mobile/remoteMacWire.ts", "../src/mobile/iosDeviceAcceptance.ts", "../src/mobile/associationFiles.ts", "../src/mobile/buildMetadata.ts", "../src/mobile/buildPipeline.ts", "../src/mobile/buildRelease.ts", "../src/mobile/capacitorBundle.ts", "../src/mobile/routeMatcher.ts", "../src/mobile/producerContextState.ts", "../src/mobile/pageProtocol.ts", "../src/mobile/client.ts", "../src/mobile/transport.ts", "../src/mobile/materializedBundle.ts", "../src/mobile/expoProject.ts", "../src/mobile/index.ts", "../node_modules/@absolutejs/sync/dist/client/runtimeTransport.js", "../src/mobile/syncRemediation.ts", "../src/mobile/expoBridge.ts", "../src/mobile/expoDevController.ts", "../src/mobile/ciWorkflow.ts", "../src/mobile/compatibilityDispatcher.ts", "../src/mobile/producerContext.ts", "../src/mobile/mobilePreview.ts", "../src/mobile/nativeDeepLinks.ts", "../src/mobile/nativeDeviceCapabilities.ts", "../src/mobile/releasePublisher.ts", "../src/mobile/routeMetadataTransform.ts", "../node_modules/@absolutejs/http/dist/index.js", "../src/mobile/shellHttp.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"export const ANGULAR_INIT_TIMEOUT_MS = 500;\nexport const ANSI_ESCAPE_CODE = 27;\nexport const ANSI_ESCAPE_LENGTH = 3;\nexport const ASCII_SPACE = 32;\nexport const BASE_36_RADIX = 36;\nexport const BUN_BUILD_WARNING_SUPPRESSION =\n\t'wildcard sideEffects are not supported yet';\n/* Tailwind v4 at-rules that Bun's native CSS parser doesn't recognize.\n When a user imports their Tailwind entry CSS from a TS/TSX file, Bun's\n bundler walks it and warns about each unknown at-rule even though the\n actual Tailwind output is produced via the separate tailwindcss compile()\n pipeline (see compileTailwind.ts). The warnings are noise — suppress them. */\nexport const TAILWIND_BUN_CSS_WARNING_PATTERN =\n\t/invalid @ rule encountered: '@(theme|tailwind|source|utility|variant|custom-variant|apply|reference|plugin|config)'/;\nexport const BODY_SLICE_LENGTH = 2000;\nexport const BYTES_PER_KILOBYTE = 1024;\nexport const CLI_ARGS_OFFSET = 3;\nexport const CSS_ERROR_RESOLVE_DELAY_MS = 50;\nexport const CSS_MAX_CHECK_ATTEMPTS = 10;\nexport const CSS_MAX_PARSE_TIMEOUT_MS = 500;\nexport const CSS_SHEET_READY_TIMEOUT_MS = 100;\nexport const DEFAULT_CHUNK_SIZE = 16_384;\nexport const DEFAULT_DEBOUNCE_MS = 15;\nexport const DEFAULT_PORT = 3000;\nexport const DEV_SERVER_RESTART_DEBOUNCE_MS = 100;\nexport const DOM_UPDATE_DELAY_MS = 50;\nexport const FILE_PROTOCOL_PREFIX_LENGTH = 7;\nexport const FOCUS_ID_PREFIX_LENGTH = 3;\nexport const FOCUS_IDX_PREFIX_LENGTH = 4;\nexport const FOCUS_NAME_PREFIX_LENGTH = 5;\nexport const ESLINT_STUDIO_DEFAULT_HOST = 'eslint.absolute.localhost';\nexport const ESLINT_STUDIO_DEFAULT_PORT = 4099;\nexport const CONFIG_DEFAULT_HOST = 'config.absolute.localhost';\nexport const CONFIG_DEFAULT_PORT = 4099;\nexport const HMR_UPDATE_TIMEOUT_MS = 2000;\nexport const HOOK_SIGNATURE_LENGTH = 12;\nexport const EXCLUDE_LAST_OFFSET = -1;\nexport const HTTP_STATUS_OK = 200;\nexport const HTTP_STATUS_BAD_REQUEST = 400;\nexport const HTTP_STATUS_NOT_FOUND = 404;\nexport const HOURS_IN_DAY = 24;\nexport const HOURS_IN_HALF_DAY = 12;\nexport const IMAGE_DEFAULT_DEVICE_SIZES = [\n\t640, 750, 828, 1080, 1200, 1920, 2048, 3840\n];\nexport const IMAGE_DEFAULT_IMAGE_SIZES = [16, 32, 48, 64, 96, 128, 256, 384];\nexport const IMAGE_DEFAULT_QUALITY = 75;\nexport const IMAGE_GLOB_SUFFIX_LENGTH = 2;\nexport const INSTANCE_PROBE_TIMEOUT_MS = 250;\nexport const MAX_ERROR_LENGTH = 200;\nexport const MAX_RECONNECT_ATTEMPTS = 60;\nexport const MILLISECONDS_IN_A_SECOND = 1000;\nexport const MINUTES_IN_AN_HOUR = 60;\nexport const SECONDS_IN_A_MINUTE = 60;\nexport const MILLISECONDS_IN_A_MINUTE =\n\tMILLISECONDS_IN_A_SECOND * SECONDS_IN_A_MINUTE;\nexport const MILLISECONDS_IN_A_DAY =\n\tMILLISECONDS_IN_A_SECOND *\n\tSECONDS_IN_A_MINUTE *\n\tMINUTES_IN_AN_HOUR *\n\tHOURS_IN_DAY;\nexport const OVERLAY_FADE_DURATION_MS = 150;\nexport const PING_INTERVAL_MS = 30_000;\nexport const LIST_LOG_TAIL_MAX_BYTES = 65_536;\nexport const LIST_TUI_COLUMN_GAP = 2;\nexport const LIST_TUI_DEFAULT_HEIGHT = 28;\nexport const LIST_TUI_DEFAULT_WIDTH = 100;\nexport const LIST_TUI_ESCAPE_SEQUENCE_TIMEOUT_MS = 30;\nexport const LIST_TUI_FOOTER_LINE_COUNT = 2;\nexport const LIST_TUI_MARKER_WIDTH = 2;\nexport const LIST_TUI_MIN_LOG_HEIGHT = 3;\nexport const LIST_TUI_MIN_URL_WIDTH = 16;\nexport const LIST_TUI_RENDER_DEBOUNCE_MS = 16;\nexport const LIST_TUI_STATUS_MESSAGE_TIMEOUT_MS = 4000;\nexport const LIST_WATCH_REFRESH_MS = 1000;\nexport const RAF_BATCH_COUNT = 3;\nexport const RANDOM_ID_END_INDEX = 11;\nexport const REBUILD_BATCH_DELAY_MS = 10;\nexport const REBUILD_RELOAD_DELAY_MS = 200;\nexport const RECONNECT_INITIAL_DELAY_MS = 500;\nexport const RECONNECT_POLL_INTERVAL_MS = 300;\nexport const REACT_STREAM_SLOT_FAST_DELAY_MS = 5;\nexport const REACT_STREAM_SLOT_SLOW_DELAY_MS = 20;\nexport const SIGINT_EXIT_CODE = 130;\nexport const SIGTERM_EXIT_CODE = 143;\nexport const SVELTE_CSS_LOAD_TIMEOUT_MS = 500;\nexport const TIME_PRECISION = 2;\nexport const TWO_THIRDS = 2 / 3;\nexport const UNFOUND_INDEX = -1;\nexport const WEBSOCKET_NORMAL_CLOSURE = 1000;\n// Default Bun WebSocket idleTimeout (seconds) applied to every absolute server.\n// Long-lived sockets (voice intake, referee, realtime sync) sit idle during\n// greeting playback or while a user listens silently — no client→server frames.\n// Without an explicit value the WS idleTimeout falls back to Elysia's small\n// top-level serve default (~30s, closing at ~60s), which kills these sessions\n// mid-call with INACTIVE_CLIENT. 240s outlasts any greeting or think-pause and\n// gives a briefly-suspended tab time to wake and reconnect. Paired with Bun's\n// `sendPings` (protocol-level keepalive the browser answers without JS, so a\n// throttled background tab still responds). Bun's hard ceiling is 960s.\nexport const DEFAULT_WEBSOCKET_IDLE_TIMEOUT_SECONDS = 240;\n// HTTP idleTimeout for Bun.serve. Bun's DEFAULT is a hostile 10s for a\n// framework meant to host streaming/AI workloads: a long-lived SSE response\n// (or any long poll) that stays silent past 10s — e.g. an agentic AI turn\n// waiting on the model's first token after a large tool result inflates the\n// prompt — gets its socket reaped with no error, and the client hangs. 240s\n// mirrors the WS default and outlasts realistic model think-pauses; Bun's\n// hard ceiling for HTTP idleTimeout is 255s. Override per-app with the\n// ABSOLUTE_IDLE_TIMEOUT env var (seconds; 0 disables the timeout entirely).\nexport const DEFAULT_HTTP_IDLE_TIMEOUT_SECONDS = 240;\nexport const MAX_HTTP_IDLE_TIMEOUT_SECONDS = 255;\nexport const WORKSPACE_COMMAND_ARGS_OFFSET = 3;\nexport const WORKSPACE_FAILURE_LOG_PRINT_LIMIT = 30;\nexport const WORKSPACE_FAILURE_RECENT_LOG_LIMIT = 60;\nexport const WORKSPACE_READY_ATTEMPT_TIMEOUT_MS = 5_000;\nexport const WORKSPACE_READY_PROBE_INTERVAL_MS = 250;\nexport const WORKSPACE_READY_TIMEOUT_MS = 30_000;\nexport const WORKSPACE_SHUTDOWN_TIMEOUT_MS = 10_000;\nexport const WORKSPACE_TUI_DEFAULT_HEIGHT = 28;\nexport const WORKSPACE_TUI_DEFAULT_WIDTH = 100;\nexport const WORKSPACE_TUI_ESCAPE_SEQUENCE_TIMEOUT_MS = 30;\nexport const WORKSPACE_TUI_FOOTER_LINE_COUNT = 3;\nexport const WORKSPACE_TUI_MIN_LOG_HEIGHT = 3;\nexport const WORKSPACE_TUI_MIN_SERVICE_NAME_WIDTH = 7;\nexport const WORKSPACE_TUI_MIN_TARGET_WIDTH = 8;\nexport const WORKSPACE_TUI_MIN_WRAP_WIDTH = 12;\nexport const WORKSPACE_TUI_PROMPT_CURSOR_OFFSET = 3;\nexport const WORKSPACE_TUI_RECENT_LOG_LIMIT = 40;\nexport const WORKSPACE_TUI_RENDER_DEBOUNCE_MS = 16;\nexport const WORKSPACE_TUI_STATUS_WIDTH = 10;\nexport const WORKSPACE_TUI_TARGET_PADDING_WIDTH = 6;\nexport const WORKSPACE_TUI_VISIBILITY_WIDTH = 8;\n",
|
|
6
6
|
"import {\n\tMILLISECONDS_IN_A_SECOND,\n\tTIME_PRECISION,\n\tMILLISECONDS_IN_A_MINUTE\n} from '../constants';\n\nexport const getDurationString = (duration: number) => {\n\tlet durationString;\n\n\tif (duration < MILLISECONDS_IN_A_SECOND) {\n\t\tdurationString = `${duration.toFixed(TIME_PRECISION)}ms`;\n\t} else if (duration < MILLISECONDS_IN_A_MINUTE) {\n\t\tdurationString = `${(duration / MILLISECONDS_IN_A_SECOND).toFixed(TIME_PRECISION)}s`;\n\t} else {\n\t\tconst totalSeconds = Math.round(duration / MILLISECONDS_IN_A_SECOND);\n\t\tconst minutes = Math.floor(totalSeconds / 60);\n\t\tconst seconds = totalSeconds % 60;\n\t\tdurationString =\n\t\t\tseconds === 0 ? `${minutes}m` : `${minutes}m ${seconds}s`;\n\t}\n\n\treturn durationString;\n};\n",
|
|
7
|
-
"import { HOURS_IN_HALF_DAY } from '../constants';\nimport { getDurationString } from './getDurationString';\n\nconst colors = {\n\tbold: '\\x1b[1m',\n\tcyan: '\\x1b[36m',\n\tdim: '\\x1b[2m',\n\tgreen: '\\x1b[32m',\n\treset: '\\x1b[0m'\n} as const;\n\nconst MONTHS = [\n\t'Jan',\n\t'Feb',\n\t'Mar',\n\t'Apr',\n\t'May',\n\t'Jun',\n\t'Jul',\n\t'Aug',\n\t'Sep',\n\t'Oct',\n\t'Nov',\n\t'Dec'\n] as const;\n\nexport const formatTimestamp = () => {\n\tconst now = new Date();\n\tconst month = MONTHS[now.getMonth()];\n\tconst day = now.getDate().toString().padStart(2, '0');\n\tlet hours = now.getHours();\n\tconst minutes = now.getMinutes().toString().padStart(2, '0');\n\tconst seconds = now.getSeconds().toString().padStart(2, '0');\n\tconst ampm = hours >= HOURS_IN_HALF_DAY ? 'PM' : 'AM';\n\thours = hours % HOURS_IN_HALF_DAY || HOURS_IN_HALF_DAY;\n\n\treturn `${month} ${day} ${hours}:${minutes}:${seconds} ${ampm}`;\n};\n\nexport const startupBanner = (options: {\n\tversion: string;\n\treadyDuration: number;\n\tbuildDuration?: number;\n\tport: string | number;\n\thost: string;\n\tnetworkUrl?: string;\n\tprotocol?: string;\n}) => {\n\tconst {\n\t\tversion,\n\t\treadyDuration,\n\t\tbuildDuration,\n\t\tport,\n\t\thost,\n\t\tnetworkUrl,\n\t\tprotocol = 'http'\n\t} = options;\n\tconst name = `${colors.cyan}${colors.bold}ABSOLUTEJS${colors.reset}`;\n\tconst ver = `${colors.dim}v${version}${colors.reset}`;\n\tconst time = `${colors.dim}ready in${colors.reset} ${colors.bold}${getDurationString(readyDuration)}${colors.reset}`;\n\tconst build =\n\t\ttypeof buildDuration === 'number' && Number.isFinite(buildDuration)\n\t\t\t? ` ${colors.dim}(build ${getDurationString(buildDuration)})${colors.reset}`\n\t\t\t: '';\n\tconsole.log('');\n\tconsole.log(` ${name} ${ver} ${time}${build}`);\n\tconsole.log('');\n\tconsole.log(\n\t\t` ${colors.green}➜${colors.reset} ${colors.bold}Local:${colors.reset} ${protocol}://${host === '0.0.0.0' ? 'localhost' : host}:${port}/`\n\t);\n\tif (networkUrl) {\n\t\tconsole.log(\n\t\t\t` ${colors.green}➜${colors.reset} ${colors.bold}Network:${colors.reset} ${networkUrl}`\n\t\t);\n\t}\n\tconsole.log('');\n};\n",
|
|
7
|
+
"import { HOURS_IN_HALF_DAY } from '../constants';\nimport { getDurationString } from './getDurationString';\n\nconst colors = {\n\tbold: '\\x1b[1m',\n\tcyan: '\\x1b[36m',\n\tdim: '\\x1b[2m',\n\tgreen: '\\x1b[32m',\n\treset: '\\x1b[0m'\n} as const;\n\nconst MONTHS = [\n\t'Jan',\n\t'Feb',\n\t'Mar',\n\t'Apr',\n\t'May',\n\t'Jun',\n\t'Jul',\n\t'Aug',\n\t'Sep',\n\t'Oct',\n\t'Nov',\n\t'Dec'\n] as const;\n\nexport const formatTimestamp = () => {\n\tconst now = new Date();\n\tconst month = MONTHS[now.getMonth()];\n\tconst day = now.getDate().toString().padStart(2, '0');\n\tlet hours = now.getHours();\n\tconst minutes = now.getMinutes().toString().padStart(2, '0');\n\tconst seconds = now.getSeconds().toString().padStart(2, '0');\n\tconst ampm = hours >= HOURS_IN_HALF_DAY ? 'PM' : 'AM';\n\thours = hours % HOURS_IN_HALF_DAY || HOURS_IN_HALF_DAY;\n\n\treturn `${month} ${day} ${hours}:${minutes}:${seconds} ${ampm}`;\n};\n\nexport const startupBanner = (options: {\n\tversion: string;\n\treadyDuration: number;\n\tbuildDuration?: number;\n\tport: string | number;\n\thost: string;\n\tnetworkUrl?: string;\n\tmobilePreviewUrl?: string;\n\tprotocol?: string;\n}) => {\n\tconst {\n\t\tversion,\n\t\treadyDuration,\n\t\tbuildDuration,\n\t\tport,\n\t\thost,\n\t\tnetworkUrl,\n\t\tmobilePreviewUrl,\n\t\tprotocol = 'http'\n\t} = options;\n\tconst name = `${colors.cyan}${colors.bold}ABSOLUTEJS${colors.reset}`;\n\tconst ver = `${colors.dim}v${version}${colors.reset}`;\n\tconst time = `${colors.dim}ready in${colors.reset} ${colors.bold}${getDurationString(readyDuration)}${colors.reset}`;\n\tconst build =\n\t\ttypeof buildDuration === 'number' && Number.isFinite(buildDuration)\n\t\t\t? ` ${colors.dim}(build ${getDurationString(buildDuration)})${colors.reset}`\n\t\t\t: '';\n\tconsole.log('');\n\tconsole.log(` ${name} ${ver} ${time}${build}`);\n\tconsole.log('');\n\tconsole.log(\n\t\t` ${colors.green}➜${colors.reset} ${colors.bold}Local:${colors.reset} ${protocol}://${host === '0.0.0.0' ? 'localhost' : host}:${port}/`\n\t);\n\tif (networkUrl) {\n\t\tconsole.log(\n\t\t\t` ${colors.green}➜${colors.reset} ${colors.bold}Network:${colors.reset} ${networkUrl}`\n\t\t);\n\t}\n\tif (mobilePreviewUrl) {\n\t\tconsole.log(\n\t\t\t` ${colors.green}➜${colors.reset} ${colors.bold}Mobile:${colors.reset} ${mobilePreviewUrl}`\n\t\t);\n\t}\n\tconsole.log('');\n};\n",
|
|
8
|
+
"import { resolve } from 'node:path';\nimport type { MobileConfig, MobilePlatform } from '../../types/build';\n\nexport type NormalizedAbsoluteMobileConfig = {\n\tappId: string;\n\tappName: string;\n\tandroidCertificateFingerprints: string[];\n\tappleAppIdPrefix?: string;\n\tbundleDirectory: string;\n\tdeepLinkHosts: string[];\n\tdeepLinkScheme?: string;\n\tengine: 'capacitor' | 'expo';\n\tentry: string;\n\texpoNativeRoutes: Record<string, string>;\n\texpoSdkVersion?: 57;\n\tiosVersion?: string;\n\tnativeProjectDirectory: string;\n\tplatforms: MobilePlatform[];\n\tproductionOrigin: string;\n\tpushAndroidGoogleServicesFile: string;\n};\n\nconst APP_ID_PATTERN = /^[A-Za-z][\\w]*(?:\\.[A-Za-z][\\w]*)+$/;\nconst SCHEME_PATTERN = /^[a-z][a-z0-9+.-]*$/;\nconst APPLE_APP_ID_PREFIX_PATTERN = /^[A-Z0-9]{10}$/;\nconst CERTIFICATE_FINGERPRINT_PATTERN = /^[0-9A-F]{64}$/;\nconst HOSTNAME_PATTERN =\n\t/^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)(?:\\.(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?))*$/;\nconst EXPO_RESERVED_ROUTE_PREFIXES = new Set([\n\t'_expo',\n\t'_flight',\n\t'_sitemap',\n\t'assets',\n\t'expo-dev-plugins',\n\t'inspector',\n\t'manifest',\n\t'public'\n]);\n\nconst resolveProjectPath = (\n\tprojectRoot: string,\n\tvalue: string,\n\tfield: string\n) => {\n\tconst root = resolve(projectRoot);\n\tconst path = resolve(root, value);\n\tif (path !== root && !path.startsWith(`${root}/`)) {\n\t\tthrow new TypeError(`${field} must remain inside the project root.`);\n\t}\n\n\treturn path;\n};\n\nconst requireText = (value: string, field: string) => {\n\tconst normalized = value.trim();\n\tif (!normalized) throw new TypeError(`${field} must not be empty.`);\n\n\treturn normalized;\n};\n\nconst normalizeEntry = (entry: string | undefined) => {\n\tconst normalized = requireText(entry ?? '/', 'mobile.entry');\n\tif (!normalized.startsWith('/') || normalized.startsWith('//')) {\n\t\tthrow new TypeError(\n\t\t\t'mobile.entry must be an absolute application path.'\n\t\t);\n\t}\n\n\treturn normalized;\n};\n\nconst normalizeProductionOrigin = (value: string) => {\n\tconst parsed = new URL(\n\t\trequireText(value, 'mobile.server.productionOrigin')\n\t);\n\tconst isLoopbackHttp =\n\t\tparsed.protocol === 'http:' &&\n\t\t(parsed.hostname === 'localhost' ||\n\t\t\tparsed.hostname === '127.0.0.1' ||\n\t\t\tparsed.hostname === '[::1]');\n\tif (parsed.protocol !== 'https:' && !isLoopbackHttp) {\n\t\tthrow new TypeError(\n\t\t\t'mobile.server.productionOrigin must use HTTPS, except for a loopback development origin.'\n\t\t);\n\t}\n\tif (\n\t\tparsed.username ||\n\t\tparsed.password ||\n\t\tparsed.pathname !== '/' ||\n\t\tparsed.search ||\n\t\tparsed.hash\n\t) {\n\t\tthrow new TypeError(\n\t\t\t'mobile.server.productionOrigin must be an origin without credentials, path, query, or hash.'\n\t\t);\n\t}\n\n\treturn parsed.origin;\n};\n\nconst normalizePlatforms = (\n\tplatforms: readonly MobilePlatform[] | undefined\n) => {\n\tconst normalized: MobilePlatform[] = [\n\t\t...new Set<MobilePlatform>(platforms ?? ['ios', 'android'])\n\t];\n\tif (normalized.length === 0) {\n\t\tthrow new TypeError(\n\t\t\t'mobile.platforms must contain at least one platform.'\n\t\t);\n\t}\n\n\treturn normalized;\n};\n\nconst normalizeHosts = (\n\thosts: readonly string[] | undefined,\n\tproductionOrigin: string\n) => {\n\tconst normalizeHostname = (host: string) => {\n\t\tconst value = requireText(host, 'mobile.deepLinks.hosts').toLowerCase();\n\t\tif (!HOSTNAME_PATTERN.test(value)) {\n\t\t\tthrow new TypeError(\n\t\t\t\t'mobile.deepLinks.hosts entries must be valid hostnames without ports, wildcards, or paths.'\n\t\t\t);\n\t\t}\n\n\t\treturn value;\n\t};\n\tconst productionHostname = new URL(productionOrigin).hostname;\n\t// IPv6 loopback is valid for a local backend preview but cannot be an\n\t// Android App Link or Apple Universal Link hostname.\n\tconst normalized = new Set<string>(\n\t\tproductionHostname === '[::1]'\n\t\t\t? []\n\t\t\t: [normalizeHostname(productionHostname)]\n\t);\n\tfor (const host of hosts ?? []) {\n\t\tnormalized.add(normalizeHostname(host));\n\t}\n\n\treturn [...normalized].sort();\n};\n\nconst normalizeAppleAppIdPrefix = (value: string | undefined) => {\n\tif (value === undefined) return undefined;\n\tconst normalized = requireText(\n\t\tvalue,\n\t\t'mobile.deepLinks.apple.appIdPrefix'\n\t).toUpperCase();\n\tif (!APPLE_APP_ID_PREFIX_PATTERN.test(normalized)) {\n\t\tthrow new TypeError(\n\t\t\t'mobile.deepLinks.apple.appIdPrefix must contain ten letters or digits.'\n\t\t);\n\t}\n\n\treturn normalized;\n};\n\nconst normalizeIosVersion = (value: string | undefined) => {\n\tif (value === undefined) return undefined;\n\tconst normalized = requireText(value, 'mobile.ios.version');\n\tif (!/^\\d+(?:\\.\\d+){0,2}$/u.test(normalized)) {\n\t\tthrow new TypeError(\n\t\t\t'mobile.ios.version must contain one to three dot-separated integer components, for example 1.4.0.'\n\t\t);\n\t}\n\n\treturn normalized;\n};\n\nconst normalizeCertificateFingerprints = (\n\tvalues: readonly string[] | undefined\n) =>\n\t[\n\t\t...new Set(\n\t\t\t(values ?? [])\n\t\t\t\t.map((value) =>\n\t\t\t\t\trequireText(\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t'mobile.deepLinks.android.sha256CertificateFingerprints'\n\t\t\t\t\t)\n\t\t\t\t\t\t.replaceAll(':', '')\n\t\t\t\t\t\t.toUpperCase()\n\t\t\t\t)\n\t\t\t\t.map((value) => {\n\t\t\t\t\tif (!CERTIFICATE_FINGERPRINT_PATTERN.test(value)) {\n\t\t\t\t\t\tthrow new TypeError(\n\t\t\t\t\t\t\t'mobile.deepLinks.android.sha256CertificateFingerprints entries must be SHA-256 certificate fingerprints.'\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn value.match(/.{2}/g)?.join(':') ?? value;\n\t\t\t\t})\n\t\t)\n\t].sort();\n\nconst validateExpoNativeRouteSegment = (\n\tpath: string,\n\tsegment: string,\n\tindex: number,\n\tcount: number,\n\tparameters: Set<string>\n) => {\n\tif (segment === '*' && (index !== count - 1 || count === 1)) {\n\t\tthrow new TypeError(\n\t\t\t`mobile.routes.native route ${path} must use * once, as the final segment after a static or parameterized prefix.`\n\t\t);\n\t}\n\tif (segment === '*') return;\n\tif (\n\t\t!segment.startsWith(':') &&\n\t\t(segment.includes('*') || segment.includes(':'))\n\t) {\n\t\tthrow new TypeError(\n\t\t\t`mobile.routes.native route ${path} contains invalid segment ${segment}.`\n\t\t);\n\t}\n\tif (!segment.startsWith(':')) return;\n\tconst name = segment.slice(1);\n\tif (!/^[A-Za-z][A-Za-z0-9_]*$/u.test(name)) {\n\t\tthrow new TypeError(\n\t\t\t`mobile.routes.native route ${path} has invalid parameter ${segment}.`\n\t\t);\n\t}\n\tif (parameters.has(name)) {\n\t\tthrow new TypeError(\n\t\t\t`mobile.routes.native route ${path} repeats parameter ${segment}.`\n\t\t);\n\t}\n\tparameters.add(name);\n};\n\nconst normalizeExpoNativeRoutes = (\n\tconfig: MobileConfig,\n\tprojectRoot: string\n) => {\n\tif (config.engine !== 'expo') return {};\n\tconst routes = config.routes?.native ?? {};\n\tconst normalized: Record<string, string> = {};\n\tconst ownership = new Map<string, string>();\n\tfor (const [route, module] of Object.entries(routes)) {\n\t\tconst path = normalizeEntry(route);\n\t\tif (\n\t\t\tpath.includes('?') ||\n\t\t\tpath.includes('#') ||\n\t\t\t(path !== '/' && path.endsWith('/'))\n\t\t) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`mobile.routes.native route ${path} must be a canonical path without a query, fragment, or trailing slash.`\n\t\t\t);\n\t\t}\n\t\tif (path === '/__absolute/native') {\n\t\t\tthrow new TypeError(\n\t\t\t\t'mobile.routes.native reserves /__absolute/native for the Expo diagnostic screen.'\n\t\t\t);\n\t\t}\n\t\tconst segments = path.split('/').filter(Boolean);\n\t\tif (segments[0] && EXPO_RESERVED_ROUTE_PREFIXES.has(segments[0])) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`mobile.routes.native route ${path} conflicts with an Expo Router or Metro reserved path.`\n\t\t\t);\n\t\t}\n\t\tconst parameters = new Set<string>();\n\t\tsegments.forEach((segment, index) =>\n\t\t\tvalidateExpoNativeRouteSegment(\n\t\t\t\tpath,\n\t\t\t\tsegment,\n\t\t\t\tindex,\n\t\t\t\tsegments.length,\n\t\t\t\tparameters\n\t\t\t)\n\t\t);\n\t\tconst signature = segments\n\t\t\t.map((segment) => (segment.startsWith(':') ? ':' : segment))\n\t\t\t.join('/');\n\t\tconst existing = ownership.get(signature);\n\t\tif (existing) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`mobile.routes.native routes ${existing} and ${path} claim the same Expo route pattern.`\n\t\t\t);\n\t\t}\n\t\townership.set(signature, path);\n\t\tnormalized[path] = resolveProjectPath(\n\t\t\tprojectRoot,\n\t\t\trequireText(module, `mobile.routes.native[${path}]`),\n\t\t\t`mobile.routes.native[${path}]`\n\t\t);\n\t}\n\n\treturn Object.fromEntries(\n\t\tObject.entries(normalized).sort(([left], [right]) =>\n\t\t\tleft.localeCompare(right)\n\t\t)\n\t);\n};\n\nexport const normalizeAbsoluteMobileConfig = (\n\tconfig: MobileConfig,\n\tprojectRoot: string\n): NormalizedAbsoluteMobileConfig => {\n\tconst appId = requireText(config.appId, 'mobile.appId');\n\tif (!APP_ID_PATTERN.test(appId)) {\n\t\tthrow new TypeError(\n\t\t\t'mobile.appId must use reverse-domain notation, for example com.example.app.'\n\t\t);\n\t}\n\tconst productionOrigin = normalizeProductionOrigin(\n\t\tconfig.server.productionOrigin\n\t);\n\tconst deepLinkScheme = (config.deepLinks?.scheme ?? appId)\n\t\t.trim()\n\t\t.toLowerCase();\n\tif (deepLinkScheme && !SCHEME_PATTERN.test(deepLinkScheme)) {\n\t\tthrow new TypeError(\n\t\t\t'mobile.deepLinks.scheme is not a valid URL scheme.'\n\t\t);\n\t}\n\n\treturn {\n\t\tandroidCertificateFingerprints: normalizeCertificateFingerprints(\n\t\t\tconfig.deepLinks?.android?.sha256CertificateFingerprints\n\t\t),\n\t\tappId,\n\t\tappleAppIdPrefix: normalizeAppleAppIdPrefix(\n\t\t\tconfig.deepLinks?.apple?.appIdPrefix\n\t\t),\n\t\tappName: requireText(config.appName, 'mobile.appName'),\n\t\tbundleDirectory: resolveProjectPath(\n\t\t\tprojectRoot,\n\t\t\tconfig.bundleDirectory ?? '.absolutejs/mobile/web',\n\t\t\t'mobile.bundleDirectory'\n\t\t),\n\t\tdeepLinkHosts: normalizeHosts(\n\t\t\tconfig.deepLinks?.hosts,\n\t\t\tproductionOrigin\n\t\t),\n\t\tdeepLinkScheme,\n\t\tengine: config.engine ?? 'capacitor',\n\t\tentry: normalizeEntry(config.entry),\n\t\texpoNativeRoutes: normalizeExpoNativeRoutes(config, projectRoot),\n\t\t...(config.engine === 'expo'\n\t\t\t? { expoSdkVersion: config.expo?.sdkVersion ?? 57 }\n\t\t\t: {}),\n\t\tiosVersion: normalizeIosVersion(config.ios?.version),\n\t\tnativeProjectDirectory: resolveProjectPath(\n\t\t\tprojectRoot,\n\t\t\tconfig.nativeProject?.directory ??\n\t\t\t\t(config.engine === 'expo'\n\t\t\t\t\t? '.absolutejs/mobile/expo'\n\t\t\t\t\t: 'mobile'),\n\t\t\t'mobile.nativeProject.directory'\n\t\t),\n\t\tplatforms: normalizePlatforms(config.platforms),\n\t\tproductionOrigin,\n\t\tpushAndroidGoogleServicesFile: resolveProjectPath(\n\t\t\tprojectRoot,\n\t\t\tconfig.pushNotifications?.android?.googleServicesFile ??\n\t\t\t\t'google-services.json',\n\t\t\t'mobile.pushNotifications.android.googleServicesFile'\n\t\t)\n\t};\n};\n",
|
|
8
9
|
"const normalizeSlug = (str: string) =>\n\tstr\n\t\t.trim()\n\t\t.replace(/\\s+/g, '-')\n\t\t.replace(/[^A-Za-z0-9\\-_]+/g, '')\n\t\t.replace(/[-_]{2,}/g, '-');\n\nexport const toKebab = (str: string) =>\n\tnormalizeSlug(str)\n\t\t.replace(/([a-z0-9])([A-Z])/g, '$1-$2')\n\t\t.toLowerCase();\nexport const toPascal = (str: string) => {\n\tif (!str.includes('-') && !str.includes('_')) {\n\t\treturn str.charAt(0).toUpperCase() + str.slice(1);\n\t}\n\n\treturn normalizeSlug(str)\n\t\t.split(/[-_]/)\n\t\t.filter(Boolean)\n\t\t.map(\n\t\t\t(segment) =>\n\t\t\t\tsegment.charAt(0).toUpperCase() + segment.slice(1).toLowerCase()\n\t\t)\n\t\t.join('');\n};\nexport const toScreamingSnake = (str: string) =>\n\tstr.replace(/([a-z0-9])([A-Z])/g, '$1_$2').toUpperCase();\n",
|
|
10
|
+
"import { readFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport type { NormalizedAbsoluteMobileConfig } from './config';\n\nexport const ABSOLUTE_AUTH_PACKAGE = '@absolutejs/auth' as const;\nexport const ABSOLUTE_EXPO_AUTH_CORE_VERSION = '0.75.6' as const;\nexport const ABSOLUTE_EXPO_AUTH_PACKAGE = '@absolutejs/auth-expo' as const;\nexport const ABSOLUTE_EXPO_AUTH_VERSION = '0.0.2' as const;\nexport const ABSOLUTE_EXPO_SYNC_CORE_VERSION = '2.31.0' as const;\nexport const ABSOLUTE_EXPO_SYNC_PACKAGE = '@absolutejs/sync-expo' as const;\nexport const ABSOLUTE_EXPO_SYNC_VERSION = '0.0.2' as const;\nexport const ABSOLUTE_NATIVE_AUTH_CLIENTS_ENV =\n\t'ABSOLUTE_AUTH_NATIVE_CLIENTS' as const;\nexport const ABSOLUTE_NATIVE_AUTH_SCOPES = ['openid', 'profile'] as const;\nexport const ABSOLUTE_SYNC_PACKAGE = '@absolutejs/sync' as const;\n\nexport type AbsoluteMobileAuthManifest = {\n\tclientId: string;\n\tissuer: string;\n\tredirectUri: string;\n\tscopes: string[];\n};\n\nconst readPackageManifest = (projectRoot: string) => {\n\ttry {\n\t\treturn JSON.parse(\n\t\t\treadFileSync(join(projectRoot, 'package.json'), 'utf8')\n\t\t);\n\t} catch {\n\t\treturn undefined;\n\t}\n};\n\nconst packageManifestHas = (manifest: unknown, packageName: string) => {\n\tif (typeof manifest !== 'object' || manifest === null) return false;\n\n\treturn [\n\t\tReflect.get(manifest, 'dependencies'),\n\t\tReflect.get(manifest, 'devDependencies'),\n\t\tReflect.get(manifest, 'optionalDependencies'),\n\t\tReflect.get(manifest, 'peerDependencies')\n\t].some(\n\t\t(dependencies) =>\n\t\t\ttypeof dependencies === 'object' &&\n\t\t\tdependencies !== null &&\n\t\t\tObject.hasOwn(dependencies, packageName)\n\t);\n};\n\nexport const createAbsoluteMobileAuthManifest = (\n\tconfig: NormalizedAbsoluteMobileConfig\n): AbsoluteMobileAuthManifest => {\n\tconst scheme = config.deepLinkScheme ?? config.appId.toLowerCase();\n\n\treturn {\n\t\tclientId: `absolutejs-native:${config.appId}`,\n\t\tissuer: config.productionOrigin,\n\t\tredirectUri: `${scheme}://auth/callback`,\n\t\tscopes: [...ABSOLUTE_NATIVE_AUTH_SCOPES]\n\t};\n};\n\nexport const installAbsoluteMobileAuthEnvironment = (\n\tprojectRoot: string,\n\tconfig: NormalizedAbsoluteMobileConfig\n) => {\n\tconst auth = resolveAbsoluteMobileAuthManifest(projectRoot, config);\n\tconst serialized = serializeAbsoluteMobileAuthEnvironment(config, auth);\n\tif (serialized === undefined)\n\t\tdelete process.env[ABSOLUTE_NATIVE_AUTH_CLIENTS_ENV];\n\telse process.env[ABSOLUTE_NATIVE_AUTH_CLIENTS_ENV] = serialized;\n\n\treturn auth;\n};\n\nexport const projectUsesAbsoluteAuth = (projectRoot: string) =>\n\tpackageManifestHas(readPackageManifest(projectRoot), ABSOLUTE_AUTH_PACKAGE);\n\nexport const projectUsesAbsoluteSync = (projectRoot: string) =>\n\tpackageManifestHas(readPackageManifest(projectRoot), ABSOLUTE_SYNC_PACKAGE);\n\nexport const resolveAbsoluteMobileAuthManifest = (\n\tprojectRoot: string,\n\tconfig: NormalizedAbsoluteMobileConfig\n) =>\n\tprojectUsesAbsoluteAuth(projectRoot)\n\t\t? createAbsoluteMobileAuthManifest(config)\n\t\t: undefined;\n\nexport const serializeAbsoluteMobileAuthEnvironment = (\n\tconfig: NormalizedAbsoluteMobileConfig,\n\tauth: AbsoluteMobileAuthManifest | undefined\n) =>\n\tauth === undefined\n\t\t? undefined\n\t\t: JSON.stringify([\n\t\t\t\t{\n\t\t\t\t\t...auth,\n\t\t\t\t\tname: `${config.appName} native app`\n\t\t\t\t}\n\t\t\t]);\n",
|
|
11
|
+
"var __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __name = (target, name) => {\n Object.defineProperty(target, \"name\", {\n value: name,\n enumerable: false,\n configurable: true\n });\n return target;\n};\nvar __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for(\"Symbol.\" + name);\nvar __typeError = (msg) => {\n throw TypeError(msg);\n};\nvar __defNormalProp = (obj, key, value) => (key in obj) ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;\nvar __accessCheck = (obj, member, msg) => member.has(obj) || __typeError(\"Cannot \" + msg);\nvar __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use the \"in\" operator on this value') : member.has(obj);\nvar __privateGet = (obj, member, getter) => (__accessCheck(obj, member, \"read from private field\"), getter ? getter.call(obj) : member.get(obj));\nvar __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, \"write to private field\"), setter ? setter.call(obj, value) : member.set(obj, value), value);\nvar __privateMethod = (obj, member, method) => (__accessCheck(obj, member, \"access private method\"), method);\nvar __decoratorStart = (base) => [, , , __create(base?.[__knownSymbol(\"metadata\")] ?? null)];\nvar __decoratorStrings = [\"class\", \"method\", \"getter\", \"setter\", \"accessor\", \"field\", \"value\", \"get\", \"set\"];\nvar __expectFn = (fn) => fn !== undefined && typeof fn !== \"function\" ? __typeError(\"Function expected\") : fn;\nvar __decoratorContext = (kind, name, done, metadata, fns) => ({\n kind: __decoratorStrings[kind],\n name,\n metadata,\n addInitializer: (fn) => done._ ? __typeError(\"Already initialized\") : fns.push(__expectFn(fn || null))\n});\nvar __decoratorMetadata = (array, target) => __defNormalProp(target, __knownSymbol(\"metadata\"), array[3]);\nvar __runInitializers = (array, flags, self, value) => {\n for (var i = 0, fns = array[flags >> 1], n = fns && fns.length;i < n; i++)\n flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value);\n return value;\n};\nvar __decorateElement = (array, flags, name, decorators, target, extra) => {\n var fn, it, done, ctx, access, k = flags & 7, s = !!(flags & 8), p = !!(flags & 16);\n var j = k > 3 ? array.length + 1 : k ? s ? 1 : 2 : 0, key = __decoratorStrings[k + 5];\n var initializers = k > 3 && (array[j - 1] = []), extraInitializers = array[j] || (array[j] = []);\n var desc = k && (!p && !s && (target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc(k < 4 ? target : {\n get [name]() {\n return __privateGet(this, extra);\n },\n set [name](x) {\n __privateSet(this, extra, x);\n }\n }, name));\n k ? p && k < 4 && __name(extra, (k > 2 ? \"set \" : k > 1 ? \"get \" : \"\") + name) : __name(target, name);\n for (var i = decorators.length - 1;i >= 0; i--) {\n ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);\n if (k) {\n ctx.static = s, ctx.private = p, access = ctx.access = { has: p ? (x) => __privateIn(target, x) : (x) => (name in x) };\n if (k ^ 3)\n access.get = p ? (x) => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name];\n if (k > 2)\n access.set = p ? (x, y) => __privateSet(x, target, y, k ^ 4 ? extra : desc.set) : (x, y) => x[name] = y;\n }\n it = (0, decorators[i])(k ? k < 4 ? p ? extra : desc[key] : k > 4 ? undefined : { get: desc.get, set: desc.set } : target, ctx);\n done._ = 1;\n if (k ^ 4 || it === undefined)\n __expectFn(it) && (k > 4 ? initializers.unshift(it) : k ? p ? extra = it : desc[key] = it : target = it);\n else if (typeof it !== \"object\" || it === null)\n __typeError(\"Object expected\");\n else\n __expectFn(fn = it.get) && (desc.get = fn), __expectFn(fn = it.set) && (desc.set = fn), __expectFn(fn = it.init) && initializers.unshift(fn);\n }\n return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;\n};\n\n// src/crdt/orSet.ts\nvar newTag = () => globalThis.crypto.randomUUID();\nvar defaultEquals = (a, b) => Object.is(a, b);\nvar orSet = {\n create: () => ({ adds: [], removed: [] }),\n add: (state, value, tag = newTag()) => ({\n adds: [...state.adds, { value, tag }],\n removed: state.removed\n }),\n remove: (state, value, equals = defaultEquals) => {\n const tags = state.adds.filter((entry) => equals(entry.value, value)).map((entry) => entry.tag);\n return {\n adds: state.adds,\n removed: [...new Set([...state.removed, ...tags])]\n };\n },\n has: (state, value, equals = defaultEquals) => {\n const removed = new Set(state.removed);\n return state.adds.some((entry) => equals(entry.value, value) && !removed.has(entry.tag));\n },\n values: (state, equals = defaultEquals) => {\n const removed = new Set(state.removed);\n const out = [];\n for (const entry of state.adds) {\n if (!removed.has(entry.tag) && !out.some((value) => equals(value, entry.value))) {\n out.push(entry.value);\n }\n }\n return out;\n },\n merge: (a, b) => {\n const byTag = new Map;\n for (const entry of [...a.adds, ...b.adds]) {\n byTag.set(entry.tag, entry);\n }\n return {\n adds: [...byTag.values()],\n removed: [...new Set([...a.removed, ...b.removed])]\n };\n }\n};\n// src/crdt/lwwMap.ts\nvar pick = (a, b) => {\n if (b.timestamp > a.timestamp) {\n return b;\n }\n if (b.timestamp < a.timestamp) {\n return a;\n }\n return b.replica > a.replica ? b : a;\n};\nvar lwwMap = {\n create: () => ({}),\n set: (state, key, value, replica, timestamp = Date.now()) => ({\n ...state,\n [key]: { value, deleted: false, timestamp, replica }\n }),\n delete: (state, key, replica, timestamp = Date.now()) => ({\n ...state,\n [key]: { value: state[key]?.value, deleted: true, timestamp, replica }\n }),\n get: (state, key) => {\n const entry = state[key];\n return entry !== undefined && !entry.deleted ? entry.value : undefined;\n },\n has: (state, key) => {\n const entry = state[key];\n return entry !== undefined && !entry.deleted;\n },\n keys: (state) => Object.keys(state).filter((key) => !state[key]?.deleted),\n entries: (state) => {\n const out = [];\n for (const [key, entry] of Object.entries(state)) {\n if (!entry.deleted && entry.value !== undefined) {\n out.push([key, entry.value]);\n }\n }\n return out;\n },\n merge: (a, b) => {\n const out = { ...a };\n for (const [key, entry] of Object.entries(b)) {\n const existing = out[key];\n out[key] = existing === undefined ? entry : pick(existing, entry);\n }\n return out;\n }\n};\n// src/crdt/list.ts\nvar order = (a, b) => {\n if (a.clock !== b.clock) {\n return b.clock - a.clock;\n }\n if (a.replica === b.replica) {\n return 0;\n }\n return a.replica > b.replica ? -1 : 1;\n};\nvar linearize = (elements) => {\n const present = new Set(elements.map((element) => element.id));\n const children = new Map;\n for (const element of elements) {\n const anchor = element.after !== null && !present.has(element.after) ? null : element.after;\n const list = children.get(anchor);\n if (list === undefined) {\n children.set(anchor, [element]);\n } else {\n list.push(element);\n }\n }\n for (const list of children.values()) {\n list.sort(order);\n }\n const ordered = [];\n const stack = [...children.get(null) ?? []].reverse();\n while (stack.length > 0) {\n const element = stack.pop();\n ordered.push(element);\n const kids = children.get(element.id);\n if (kids !== undefined) {\n for (let index = kids.length - 1;index >= 0; index -= 1) {\n stack.push(kids[index]);\n }\n }\n }\n return ordered;\n};\nvar listOf = (state) => linearize(state.elements).filter((element) => !element.deleted).map((element) => element.value);\nvar mergeListState = (a, b) => {\n const byId = new Map;\n for (const element of [...a.elements, ...b.elements]) {\n const existing = byId.get(element.id);\n byId.set(element.id, existing === undefined ? element : { ...existing, deleted: existing.deleted || element.deleted });\n }\n return { elements: [...byId.values()] };\n};\nvar createList = (replica, initial) => {\n const elements = new Map;\n const pending = new Map;\n let clock = 0;\n if (initial !== undefined) {\n for (const element of initial.elements) {\n elements.set(element.id, element);\n clock = Math.max(clock, element.clock);\n }\n }\n const visible = () => linearize([...elements.values()]).filter((element) => !element.deleted);\n return {\n list: () => listOf({ elements: [...elements.values()] }),\n insert: (index, items) => {\n const seen = visible();\n let after = index <= 0 ? null : seen[index - 1]?.id ?? null;\n for (const value of items) {\n clock += 1;\n const element = {\n id: `${replica}:${clock}`,\n replica,\n clock,\n after,\n value,\n deleted: false\n };\n elements.set(element.id, element);\n pending.set(element.id, element);\n after = element.id;\n }\n },\n delete: (index, count) => {\n const seen = visible();\n for (let offset = 0;offset < count; offset += 1) {\n const target = seen[index + offset];\n if (target !== undefined) {\n const tombstoned = { ...target, deleted: true };\n elements.set(target.id, tombstoned);\n pending.set(target.id, tombstoned);\n }\n }\n },\n merge: (state) => {\n for (const element of state.elements) {\n const existing = elements.get(element.id);\n elements.set(element.id, existing === undefined ? element : {\n ...existing,\n deleted: existing.deleted || element.deleted\n });\n clock = Math.max(clock, element.clock);\n }\n },\n state: () => ({ elements: [...elements.values()] }),\n takeDelta: () => {\n const delta = { elements: [...pending.values()] };\n pending.clear();\n return delta;\n }\n };\n};\n\n// src/crdt/index.ts\nvar sumValues = (counts) => Object.values(counts).reduce((total, value) => total + value, 0);\nvar mergeMax = (a, b) => {\n const merged = { ...a };\n for (const [replica, value] of Object.entries(b)) {\n merged[replica] = Math.max(merged[replica] ?? 0, value);\n }\n return merged;\n};\nvar counter = {\n create: () => ({ increments: {}, decrements: {} }),\n value: (state) => sumValues(state.increments) - sumValues(state.decrements),\n increment: (state, replica, by = 1) => ({\n increments: {\n ...state.increments,\n [replica]: (state.increments[replica] ?? 0) + by\n },\n decrements: state.decrements\n }),\n decrement: (state, replica, by = 1) => ({\n increments: state.increments,\n decrements: {\n ...state.decrements,\n [replica]: (state.decrements[replica] ?? 0) + by\n }\n }),\n merge: (a, b) => ({\n increments: mergeMax(a.increments, b.increments),\n decrements: mergeMax(a.decrements, b.decrements)\n })\n};\nvar lww = {\n create: (value, replica, timestamp = Date.now()) => ({ value, timestamp, replica }),\n set: (value, replica, timestamp = Date.now()) => ({\n value,\n timestamp,\n replica\n }),\n merge: (a, b) => {\n if (b.timestamp > a.timestamp) {\n return b;\n }\n if (b.timestamp < a.timestamp) {\n return a;\n }\n return b.replica > a.replica ? b : a;\n }\n};\nvar compare = (a, b) => {\n if (a.clock !== b.clock) {\n return b.clock - a.clock;\n }\n if (a.replica === b.replica) {\n return 0;\n }\n return a.replica > b.replica ? -1 : 1;\n};\nvar linearize2 = (elements) => {\n const present = new Set(elements.map((element) => element.id));\n const children = new Map;\n for (const element of elements) {\n const anchor = element.after !== null && !present.has(element.after) ? null : element.after;\n const list = children.get(anchor);\n if (list === undefined) {\n children.set(anchor, [element]);\n } else {\n list.push(element);\n }\n }\n for (const list of children.values()) {\n list.sort(compare);\n }\n const ordered = [];\n const stack = [...children.get(null) ?? []].reverse();\n while (stack.length > 0) {\n const element = stack.pop();\n ordered.push(element);\n const kids = children.get(element.id);\n if (kids !== undefined) {\n for (let index = kids.length - 1;index >= 0; index -= 1) {\n stack.push(kids[index]);\n }\n }\n }\n return ordered;\n};\nvar textOf = (state) => linearize2(state.elements).filter((element) => !element.deleted).map((element) => element.value).join(\"\");\nvar mergeTextState = (a, b) => {\n const byId = new Map;\n for (const element of [...a.elements, ...b.elements]) {\n const existing = byId.get(element.id);\n byId.set(element.id, existing === undefined ? element : { ...existing, deleted: existing.deleted || element.deleted });\n }\n return { elements: [...byId.values()] };\n};\nvar tombstoneCount = (state) => state.elements.reduce((total, element) => element.deleted ? total + 1 : total, 0);\nvar compact = (state) => {\n const byId = new Map(state.elements.map((element) => [element.id, element]));\n const keep = new Set;\n for (const element of state.elements) {\n if (element.deleted) {\n continue;\n }\n let anchor = element.after;\n while (anchor !== null && !keep.has(anchor)) {\n const target = byId.get(anchor);\n if (target === undefined || !target.deleted) {\n break;\n }\n keep.add(anchor);\n anchor = target.after;\n }\n }\n return {\n elements: state.elements.filter((element) => !element.deleted || keep.has(element.id))\n };\n};\nvar createTextCrdt = (replica, initial) => {\n const elements = new Map;\n const pending = new Map;\n let clock = 0;\n if (initial !== undefined) {\n for (const element of initial.elements) {\n elements.set(element.id, element);\n clock = Math.max(clock, element.clock);\n }\n }\n const visible = () => linearize2([...elements.values()]).filter((element) => !element.deleted);\n const insert = (index, value) => {\n const seen = visible();\n let after = index <= 0 ? null : seen[index - 1]?.id ?? null;\n for (const char of [...value]) {\n clock += 1;\n const element = {\n id: `${replica}:${clock}`,\n replica,\n clock,\n after,\n value: char,\n deleted: false\n };\n elements.set(element.id, element);\n pending.set(element.id, element);\n after = element.id;\n }\n };\n const remove = (index, count) => {\n const seen = visible();\n for (let offset = 0;offset < count; offset += 1) {\n const target = seen[index + offset];\n if (target !== undefined) {\n const tombstoned = { ...target, deleted: true };\n elements.set(target.id, tombstoned);\n pending.set(target.id, tombstoned);\n }\n }\n };\n return {\n text: () => textOf({ elements: [...elements.values()] }),\n insert,\n delete: remove,\n merge: (state) => {\n for (const element of state.elements) {\n const existing = elements.get(element.id);\n elements.set(element.id, existing === undefined ? element : {\n ...existing,\n deleted: existing.deleted || element.deleted\n });\n clock = Math.max(clock, element.clock);\n }\n },\n setText: (next) => {\n const current = textOf({ elements: [...elements.values()] });\n if (current === next) {\n return;\n }\n let prefix = 0;\n const maxPrefix = Math.min(current.length, next.length);\n while (prefix < maxPrefix && current[prefix] === next[prefix]) {\n prefix += 1;\n }\n let suffix = 0;\n while (suffix < maxPrefix - prefix && current[current.length - 1 - suffix] === next[next.length - 1 - suffix]) {\n suffix += 1;\n }\n const removed = current.length - prefix - suffix;\n if (removed > 0) {\n remove(prefix, removed);\n }\n const inserted = next.slice(prefix, next.length - suffix);\n if (inserted.length > 0) {\n insert(prefix, inserted);\n }\n },\n state: () => ({ elements: [...elements.values()] }),\n takeDelta: () => {\n const delta = { elements: [...pending.values()] };\n pending.clear();\n return delta;\n },\n anchorAt: (index) => {\n if (index <= 0) {\n return null;\n }\n const seen = visible();\n return seen[Math.min(index, seen.length) - 1]?.id ?? null;\n },\n indexOfAnchor: (anchor) => {\n if (anchor === null) {\n return 0;\n }\n let visibleCount = 0;\n for (const element of linearize2([...elements.values()])) {\n if (!element.deleted) {\n visibleCount += 1;\n }\n if (element.id === anchor) {\n return visibleCount;\n }\n }\n return visibleCount;\n }\n };\n};\nvar rgaText = {\n compact,\n create: createTextCrdt,\n empty: () => ({ elements: [] }),\n merge: mergeTextState,\n textOf\n};\n\n// src/client/runtimeTransport.ts\nvar RUNTIME_TRANSPORT = Symbol.for(\"@absolutejs/sync/client-runtime-transport\");\nvar host = globalThis;\nvar isRegistry = (value) => typeof value === \"object\" && value !== null && Array.isArray(Reflect.get(value, \"installations\")) && Array.isArray(Reflect.get(value, \"clients\"));\nvar registry = (() => {\n const existing = host[RUNTIME_TRANSPORT];\n if (isRegistry(existing))\n return existing;\n if (typeof existing === \"object\" && existing !== null && Array.isArray(Reflect.get(existing, \"installations\"))) {\n Reflect.set(existing, \"clients\", []);\n return existing;\n }\n const created = { clients: [], installations: [] };\n Object.defineProperty(host, RUNTIME_TRANSPORT, {\n configurable: false,\n enumerable: false,\n value: created,\n writable: false\n });\n return created;\n})();\nvar getSyncClientRuntimeTransport = () => registry.installations.at(-1)?.transport;\nvar installSyncClientRuntimeTransport = (transport) => {\n const installation = { transport };\n registry.installations.push(installation);\n return () => {\n const index = registry.installations.indexOf(installation);\n if (index >= 0)\n registry.installations.splice(index, 1);\n };\n};\nvar registerSyncRuntimeClient = (client) => {\n registry.clients.push(client);\n return () => {\n const index = registry.clients.indexOf(client);\n if (index >= 0)\n registry.clients.splice(index, 1);\n };\n};\nvar maximum = (values) => {\n const present = values.filter((value) => value !== undefined);\n return present.length === 0 ? undefined : Math.max(...present);\n};\nvar minimum = (values) => {\n const present = values.filter((value) => value !== undefined);\n return present.length === 0 ? undefined : Math.min(...present);\n};\nvar inspectSyncRuntime = async () => {\n const clients = [...registry.clients];\n const statuses = clients.map((client) => client.status());\n const deadLetters = (await Promise.all(clients.map((client) => client.listDeadLetters()))).flat().map((record) => ({\n attempts: record.attempts,\n ...record.rejection?.code ? { code: record.rejection.code } : {},\n createdAt: record.createdAt,\n ...record.deadLetteredAt === undefined ? {} : { deadLetteredAt: record.deadLetteredAt },\n ...record.rejection?.kind ? { kind: record.rejection.kind } : {},\n ...record.rejection?.message ? { message: record.rejection.message } : {},\n name: record.name,\n operationId: record.operationId\n })).sort((left, right) => (left.deadLetteredAt ?? left.createdAt) - (right.deadLetteredAt ?? right.createdAt) || left.operationId.localeCompare(right.operationId));\n const lastError = statuses.findLast((status) => status.lastError)?.lastError;\n return {\n automaticResolutions: statuses.reduce((total, status) => total + status.automaticResolutions, 0),\n clients: clients.length,\n conflicts: deadLetters.filter((record) => record.kind === \"conflict\").length,\n deadLetters,\n ...lastError ? { lastError } : {},\n ...maximum(statuses.map((status) => status.lastSuccessfulPullAt)) === undefined ? {} : {\n lastSuccessfulPullAt: maximum(statuses.map((status) => status.lastSuccessfulPullAt))\n },\n ...maximum(statuses.map((status) => status.lastSuccessfulPushAt)) === undefined ? {} : {\n lastSuccessfulPushAt: maximum(statuses.map((status) => status.lastSuccessfulPushAt))\n },\n ...minimum(statuses.map((status) => status.oldestDeadLetterAt)) === undefined ? {} : {\n oldestDeadLetterAt: minimum(statuses.map((status) => status.oldestDeadLetterAt))\n },\n ...minimum(statuses.map((status) => status.oldestPendingAt)) === undefined ? {} : {\n oldestPendingAt: minimum(statuses.map((status) => status.oldestPendingAt))\n },\n pending: statuses.reduce((total, status) => total + status.pending, 0)\n };\n};\nvar clientWithDeadLetter = async (operationId) => {\n for (const client of registry.clients)\n if ((await client.listDeadLetters()).some((record) => record.operationId === operationId))\n return client;\n throw new Error(`Unknown Sync dead letter \"${operationId}\"`);\n};\nvar retrySyncRuntimeDeadLetter = async (operationId) => (await clientWithDeadLetter(operationId)).retryDeadLetter(operationId);\nvar discardSyncRuntimeDeadLetter = async (operationId) => (await clientWithDeadLetter(operationId)).discardDeadLetter(operationId);\nvar rebaseSyncRuntimeDeadLetter = async (operationId, args) => (await clientWithDeadLetter(operationId)).rebaseDeadLetter(operationId, args);\n\n// src/client/headlessSync.ts\nvar defaultKey = (row) => {\n if (typeof row !== \"object\" || row === null)\n throw new TypeError(\"Headless Sync rows require an object key.\");\n const key = Reflect.get(row, \"id\");\n if (typeof key !== \"string\" && typeof key !== \"number\")\n throw new TypeError(\"Headless Sync rows require an id key or an explicit key function.\");\n return key;\n};\nvar requireInteger = (value, fallback) => {\n const result = value ?? fallback;\n if (!Number.isSafeInteger(result) || result < 0)\n throw new TypeError(\"Headless Sync limits must be non-negative integers.\");\n return result;\n};\nvar retryDelay = (attempt) => Math.min(30000, 500 * 2 ** Math.max(0, attempt - 1));\nvar parseResponse = (value) => {\n if (typeof value !== \"object\" || value === null || Reflect.get(value, \"version\") !== 1 || !Array.isArray(Reflect.get(value, \"mutations\")) || !Array.isArray(Reflect.get(value, \"pulls\")))\n throw new Error(\"The Headless Sync response is malformed.\");\n return value;\n};\nvar sameBaseline = (current, baseline) => current?.cursor === baseline?.cursor && (current?.version ?? 0) === (baseline?.version ?? 0);\nvar applyPull = (current, pull, collection, key) => {\n const descriptor = {\n ...current,\n collection: collection.collection,\n params: collection.params\n };\n if (collection.key === undefined)\n descriptor.headlessKey = \"id\";\n else\n delete descriptor.headlessKey;\n if (pull.type === \"snapshot\")\n return {\n ...descriptor,\n rows: pull.rows,\n version: pull.version,\n cursor: pull.cursor\n };\n const rows = new Map;\n for (const row of current?.rows ?? [])\n rows.set(key(row), row);\n for (const row of pull.removed)\n rows.delete(key(row));\n for (const row of pull.changed)\n rows.set(key(row), row);\n for (const row of pull.added)\n rows.set(key(row), row);\n return {\n ...descriptor,\n rows: [...rows.values()],\n version: pull.version,\n cursor: pull.cursor\n };\n};\nvar runHeadlessSync = async ({\n endpoint,\n store,\n namespace,\n collections,\n maxMutations: configuredMaxMutations,\n maxPulls: configuredMaxPulls,\n maxAttempts: configuredMaxAttempts,\n retryBackoff = retryDelay,\n headers,\n fetch: fetchOverride,\n now = Date.now\n}) => {\n if (endpoint.length === 0 || namespace.length === 0)\n throw new TypeError(\"Headless Sync endpoint and namespace are required.\");\n const maxMutations = requireInteger(configuredMaxMutations, 50);\n const maxPulls = requireInteger(configuredMaxPulls, 50);\n const maxAttempts = requireInteger(configuredMaxAttempts, 5);\n const startedAt = now();\n const snapshot = await store.transaction(namespace, \"readwrite\", async (tx) => {\n const due = (await tx.listMutations()).filter((record) => record.state !== \"dead-letter\" && (record.nextAttemptAt ?? 0) <= startedAt).slice(0, maxMutations);\n const mutations = [];\n for (const record of due) {\n const next = { ...record, attempts: record.attempts + 1 };\n delete next.nextAttemptAt;\n await tx.putMutation(next);\n mutations.push(next);\n }\n const discoveredCollections = collections ?? (await tx.listCollections()).filter(({ record }) => record.headlessKey === \"id\" && typeof record.collection === \"string\" && record.collection.length > 0).map(({ key, record }) => ({\n collection: record.collection,\n localKey: key,\n params: record.params\n }));\n const pulls = await Promise.all(discoveredCollections.slice(0, maxPulls).map(async (collection) => ({\n collection,\n record: await tx.getCollection(collection.localKey)\n })));\n return { mutations, pulls };\n });\n const request = {\n version: 1,\n mutations: snapshot.mutations.map(({ operationId, name, args }) => ({\n operationId,\n name,\n args\n })),\n pulls: snapshot.pulls.map(({ collection, record }, index) => ({\n id: String(index),\n collection: collection.collection,\n params: collection.params,\n ...record?.cursor !== undefined ? { since: record.cursor } : (record?.version ?? 0) > 0 ? { since: record.version } : {}\n }))\n };\n const fetchImpl = fetchOverride ?? ((url, init) => globalThis.fetch(url, init));\n let response;\n try {\n const fetched = await fetchImpl(endpoint, {\n body: JSON.stringify(request),\n credentials: \"include\",\n headers: {\n accept: \"application/json\",\n \"content-type\": \"application/json\",\n ...await headers?.()\n },\n method: \"POST\",\n redirect: \"error\"\n });\n if (!fetched.ok)\n throw new Error(`Headless Sync failed with HTTP ${fetched.status}.`);\n response = parseResponse(await fetched.json());\n } catch (error) {\n await store.transaction(namespace, \"readwrite\", async (tx) => {\n for (const sent of snapshot.mutations) {\n const current = await tx.getMutation(sent.operationId);\n if (current?.attempts !== sent.attempts)\n continue;\n await tx.putMutation({\n ...current,\n lastError: error instanceof Error ? error.message : String(error),\n nextAttemptAt: now() + Math.max(0, retryBackoff(current.attempts))\n });\n }\n });\n throw error;\n }\n const mutationResults = new Map(response.mutations.map((result2) => [result2.operationId, result2]));\n const pullResults = new Map(response.pulls.map((result2) => [result2.id, result2]));\n const result = {\n acknowledged: 0,\n conflictsDiscarded: 0,\n conflictsRetried: 0,\n deadLettered: 0,\n pulled: 0,\n retryScheduled: 0\n };\n await store.transaction(namespace, \"readwrite\", async (tx) => {\n for (const sent of snapshot.mutations) {\n const current = await tx.getMutation(sent.operationId);\n if (current?.attempts !== sent.attempts)\n continue;\n const outcome = mutationResults.get(sent.operationId);\n if (outcome?.status === \"ack\") {\n await tx.deleteMutation(sent.operationId);\n result.acknowledged += 1;\n continue;\n }\n const rejection = outcome?.status === \"reject\" ? outcome.rejection : {\n kind: \"retryable\",\n message: \"Missing mutation response.\"\n };\n if (rejection.kind === \"conflict\" && current.conflictPolicy?.strategy === \"server-wins\") {\n await tx.deleteMutation(sent.operationId);\n result.conflictsDiscarded += 1;\n continue;\n }\n if (rejection.kind === \"conflict\" && current.conflictPolicy?.strategy === \"client-wins\" && (current.conflictAttempts ?? 0) < (current.conflictPolicy.maxAttempts ?? 1)) {\n const retry = {\n ...current,\n conflictAttempts: (current.conflictAttempts ?? 0) + 1,\n lastError: rejection.message,\n rejection,\n state: \"pending\"\n };\n delete retry.nextAttemptAt;\n await tx.putMutation(retry);\n result.conflictsRetried += 1;\n continue;\n }\n if (rejection.kind !== \"retryable\" || current.attempts >= maxAttempts) {\n const deadLetter = {\n ...current,\n deadLetteredAt: now(),\n lastError: rejection.message,\n rejection,\n state: \"dead-letter\"\n };\n delete deadLetter.nextAttemptAt;\n await tx.putMutation(deadLetter);\n result.deadLettered += 1;\n } else {\n await tx.putMutation({\n ...current,\n lastError: rejection.message,\n nextAttemptAt: now() + Math.max(0, rejection.retryAfterMs ?? retryBackoff(current.attempts)),\n rejection,\n state: \"pending\"\n });\n result.retryScheduled += 1;\n }\n }\n for (let index = 0;index < snapshot.pulls.length; index += 1) {\n const baseline = snapshot.pulls[index];\n const pull = pullResults.get(String(index));\n if (pull === undefined || pull.type === \"error\")\n continue;\n const current = await tx.getCollection(baseline.collection.localKey);\n if (!sameBaseline(current, baseline.record))\n continue;\n await tx.putCollection(baseline.collection.localKey, applyPull(current, pull, baseline.collection, baseline.collection.key ?? defaultKey));\n result.pulled += 1;\n }\n });\n return result;\n};\n\n// src/reactiveHub.ts\nvar SYNC_OPEN_TOPIC = \"@absolutejs/sync:open\";\n\n// src/client/sharedSubscriber.ts\nvar pools = new Map;\nvar topicMatches = (pattern, topic) => pattern.endsWith(\"*\") ? topic.startsWith(pattern.slice(0, -1)) : topic === pattern;\nvar unionTopics = (pool) => {\n const topics = new Set;\n for (const member of pool.members) {\n for (const topic of member.topics) {\n topics.add(topic);\n }\n }\n return [...topics].sort();\n};\nvar deliverOpen = (pool, event, toAll) => {\n for (const member of pool.members) {\n if (!toAll && member.opened) {\n continue;\n }\n member.opened = true;\n member.onOpen?.();\n member.onEvent(event);\n }\n};\nvar connect = (pool, topics) => {\n pool.source?.close();\n const params = new URLSearchParams({ topics: topics.join(\",\") });\n const separator = pool.url.includes(\"?\") ? \"&\" : \"?\";\n const source = new pool.Impl(`${pool.url}${separator}${params.toString()}`, {\n withCredentials: pool.withCredentials\n });\n pool.source = source;\n pool.connectedTopics = topics.join(\",\");\n pool.sourceOpened = false;\n source.onmessage = (message) => {\n let event;\n try {\n event = JSON.parse(message.data);\n } catch {\n return;\n }\n if (pool.source !== source) {\n return;\n }\n if (event.topic === SYNC_OPEN_TOPIC) {\n deliverOpen(pool, event, pool.sourceOpened);\n pool.sourceOpened = true;\n return;\n }\n for (const member of pool.members) {\n if (member.topics.some((pattern) => topicMatches(pattern, event.topic))) {\n member.onEvent(event);\n }\n }\n };\n source.onerror = (event) => {\n if (pool.source !== source) {\n return;\n }\n for (const member of pool.members) {\n member.onError?.(event);\n }\n };\n};\nvar reconcile = (pool) => {\n pool.reconcileTimer = undefined;\n if (pool.members.size === 0) {\n pool.source?.close();\n pool.source = null;\n pool.connectedTopics = \"\";\n pools.delete(poolKey(pool.url, pool.withCredentials));\n return;\n }\n const topics = unionTopics(pool);\n if (pool.source && topics.join(\",\") === pool.connectedTopics) {\n return;\n }\n connect(pool, topics);\n};\nvar scheduleReconcile = (pool) => {\n if (pool.reconcileTimer !== undefined) {\n return;\n }\n pool.reconcileTimer = setTimeout(() => reconcile(pool), 0);\n};\nvar poolKey = (url, withCredentials) => `${url}|${withCredentials ? 1 : 0}`;\nvar createSharedSyncSubscriber = ({\n topics,\n onEvent,\n url = \"/sync\",\n onOpen,\n onError,\n withCredentials,\n eventSourceImpl\n}) => {\n const Impl = eventSourceImpl ?? globalThis.EventSource;\n if (!Impl) {\n throw new Error(\"createSharedSyncSubscriber requires EventSource. Run in a browser or pass eventSourceImpl.\");\n }\n const key = poolKey(url, withCredentials ?? false);\n let pool = pools.get(key);\n if (!pool || pool.Impl !== Impl) {\n pool = {\n Impl,\n url,\n withCredentials: withCredentials ?? false,\n members: new Set,\n source: null,\n connectedTopics: \"\",\n sourceOpened: false,\n reconcileTimer: undefined\n };\n pools.set(key, pool);\n }\n const member = {\n topics: [...topics],\n onEvent,\n onOpen,\n onError,\n opened: false\n };\n pool.members.add(member);\n scheduleReconcile(pool);\n const owner = pool;\n return {\n close: () => {\n owner.members.delete(member);\n scheduleReconcile(owner);\n },\n get source() {\n return owner.source;\n }\n };\n};\n\n// src/client/subscriber.ts\nvar createSyncSubscriber = (options) => {\n if (options.shared) {\n return createSharedSyncSubscriber(options);\n }\n const {\n topics,\n onEvent,\n url = \"/sync\",\n onOpen,\n onError,\n withCredentials,\n eventSourceImpl\n } = options;\n const Impl = eventSourceImpl ?? globalThis.EventSource;\n if (!Impl) {\n throw new Error(\"createSyncSubscriber requires EventSource. Run in a browser or pass eventSourceImpl.\");\n }\n const params = new URLSearchParams({ topics: topics.join(\",\") });\n const separator = url.includes(\"?\") ? \"&\" : \"?\";\n const source = new Impl(`${url}${separator}${params.toString()}`, {\n withCredentials: withCredentials ?? false\n });\n source.onmessage = (event) => {\n try {\n onEvent(JSON.parse(event.data));\n } catch {}\n };\n if (onOpen) {\n source.onopen = () => onOpen();\n }\n if (onError) {\n source.onerror = (event) => onError(event);\n }\n return {\n close: () => source.close(),\n source\n };\n};\n// src/client/liveQuery.ts\nvar createLiveQuery = (options) => {\n const hasSeed = options.initialData !== undefined;\n let state = {\n data: options.initialData,\n error: undefined,\n loading: !options.manual && !hasSeed,\n fetching: false\n };\n const listeners = new Set;\n const setState = (patch) => {\n state = { ...state, ...patch };\n for (const listener of listeners) {\n listener(state);\n }\n };\n let requestSeq = 0;\n let inFlight;\n let closed = false;\n const refetch = async () => {\n if (closed) {\n return;\n }\n const seq = requestSeq += 1;\n inFlight?.abort();\n const controller = new AbortController;\n inFlight = controller;\n setState({ fetching: true });\n try {\n const data = await options.fetcher(controller.signal);\n if (seq !== requestSeq) {\n return;\n }\n setState({\n data,\n error: undefined,\n loading: false,\n fetching: false\n });\n } catch (error) {\n if (controller.signal.aborted || seq !== requestSeq) {\n return;\n }\n setState({ error, loading: false, fetching: false });\n options.onError?.(error);\n } finally {\n if (inFlight === controller) {\n inFlight = undefined;\n }\n }\n };\n let debounceTimer;\n const scheduleRefetch = () => {\n if (closed) {\n return;\n }\n if (!options.debounceMs) {\n refetch();\n return;\n }\n if (debounceTimer !== undefined) {\n return;\n }\n debounceTimer = setTimeout(() => {\n debounceTimer = undefined;\n refetch();\n }, options.debounceMs);\n };\n let opened = false;\n const onEvent = (event) => {\n if (event.topic === SYNC_OPEN_TOPIC) {\n if (opened) {\n scheduleRefetch();\n }\n opened = true;\n return;\n }\n scheduleRefetch();\n };\n const subscriber = createSyncSubscriber({\n topics: options.topics,\n onEvent,\n url: options.url,\n withCredentials: options.withCredentials,\n eventSourceImpl: options.eventSourceImpl,\n shared: options.shared\n });\n if (!options.manual && !hasSeed) {\n refetch();\n }\n const close = () => {\n if (closed) {\n return;\n }\n closed = true;\n subscriber.close();\n inFlight?.abort();\n if (debounceTimer !== undefined) {\n clearTimeout(debounceTimer);\n debounceTimer = undefined;\n }\n listeners.clear();\n };\n return {\n get: () => state,\n subscribe: (listener) => {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n refetch,\n close\n };\n};\nvar jsonFetcher = (url, init) => async (signal) => {\n const response = await fetch(url, { ...init, signal });\n if (!response.ok) {\n throw new Error(`${response.status} ${response.statusText}`);\n }\n return await response.json();\n};\n// src/serializer.ts\nvar jsonSerializer = {\n decode: (raw) => {\n if (typeof raw === \"string\") {\n try {\n return JSON.parse(raw);\n } catch {\n return null;\n }\n }\n if (raw instanceof Uint8Array) {\n try {\n return JSON.parse(new TextDecoder().decode(raw));\n } catch {\n return null;\n }\n }\n if (raw instanceof ArrayBuffer) {\n try {\n return JSON.parse(new TextDecoder().decode(new Uint8Array(raw)));\n } catch {\n return null;\n }\n }\n return raw;\n },\n encodeClient: (frame) => JSON.stringify(frame),\n encodeServer: (frame) => JSON.stringify(frame)\n};\n\n// src/client/reconnectBackoff.ts\nvar createReconnectBackoff = (initialMs, maximumMs) => {\n let attempt = 0;\n return {\n markHealthy() {\n attempt = 0;\n },\n nextDelay() {\n const delay = Math.min(initialMs * 2 ** attempt, maximumMs);\n attempt += 1;\n return delay;\n }\n };\n};\nvar hasReconnectHealthyFrameType = (frame, types) => typeof frame === \"object\" && frame !== null && (\"type\" in frame) && typeof frame.type === \"string\" && types.includes(frame.type);\n\n// src/client/syncCollection.ts\nvar serverFrameTypes = [\n \"snapshot\",\n \"diff\",\n \"error\",\n \"ack\",\n \"reject\"\n];\nvar localStorageMutationStorage = (key) => ({\n load: () => {\n const raw = globalThis.localStorage?.getItem(key);\n return raw ? JSON.parse(raw) : [];\n },\n save: (records) => {\n globalThis.localStorage?.setItem(key, JSON.stringify(records));\n }\n});\nvar localStorageCollectionCache = (key) => ({\n load: () => {\n const raw = globalThis.localStorage?.getItem(key);\n return raw ? JSON.parse(raw) : undefined;\n },\n save: (snapshot) => {\n globalThis.localStorage?.setItem(key, JSON.stringify(snapshot));\n },\n clear: () => {\n globalThis.localStorage?.removeItem(key);\n }\n});\nvar openIndexedDb = (databaseName, storeName) => new Promise((resolve, reject) => {\n const request = globalThis.indexedDB.open(databaseName, 1);\n request.onupgradeneeded = () => {\n request.result.createObjectStore(storeName);\n };\n request.onsuccess = () => resolve(request.result);\n request.onerror = () => reject(request.error);\n});\nvar indexedDbCollectionCache = ({\n key,\n databaseName = \"absolutejs-sync\",\n storeName = \"collections\"\n}) => {\n let handle;\n const database = () => {\n handle ??= openIndexedDb(databaseName, storeName);\n return handle;\n };\n const withStore = async (mode, run) => {\n if (globalThis.indexedDB === undefined) {\n return;\n }\n const db = await database();\n return new Promise((resolve, reject) => {\n const request = run(db.transaction(storeName, mode).objectStore(storeName));\n request.onsuccess = () => resolve(request.result);\n request.onerror = () => reject(request.error);\n });\n };\n return {\n load: () => withStore(\"readonly\", (store) => store.get(key)),\n save: async (snapshot) => {\n await withStore(\"readwrite\", (store) => store.put(snapshot, key));\n },\n clear: async () => {\n await withStore(\"readwrite\", (store) => store.delete(key));\n }\n };\n};\nvar SUBSCRIPTION_ID = \"s\";\nvar createSyncCollection = (options) => {\n const key = options.key ?? ((row) => row.id);\n const reconnectMs = options.reconnectMs ?? 500;\n const maxReconnectMs = options.maxReconnectMs ?? 1e4;\n const serializer = options.serializer ?? jsonSerializer;\n const Impl = options.webSocketImpl ?? globalThis.WebSocket;\n if (!Impl) {\n throw new Error(\"createSyncCollection requires WebSocket. Run in a browser or pass webSocketImpl.\");\n }\n const confirmed = new Map;\n const pending = [];\n let mutationSeq = 0;\n let state = {\n data: [],\n status: \"connecting\",\n error: undefined\n };\n const listeners = new Set;\n const setState = (patch) => {\n state = { ...state, ...patch };\n for (const listener of listeners) {\n listener(state);\n }\n };\n const recompute = (patch = {}) => {\n const working = new Map(confirmed);\n const draft = {\n set: (row) => working.set(key(row), row),\n delete: (rowKey) => working.delete(rowKey)\n };\n for (const mutation of pending) {\n mutation.optimistic?.(draft);\n }\n setState({ ...patch, data: [...working.values()] });\n };\n let socket;\n let connected = false;\n let closed = false;\n const reconnectBackoff = createReconnectBackoff(reconnectMs, maxReconnectMs);\n let reconnectTimer;\n let appliedVersion = 0;\n let appliedCursor;\n const persist = () => {\n options.storage?.save(pending.map((mutation) => ({\n mutationId: mutation.mutationId,\n name: mutation.name,\n args: mutation.args\n })));\n };\n let cacheScheduled = false;\n const persistCache = () => {\n if (options.cache === undefined || cacheScheduled) {\n return;\n }\n cacheScheduled = true;\n queueMicrotask(() => {\n cacheScheduled = false;\n options.cache?.save({\n rows: [...confirmed.values()],\n version: appliedVersion\n });\n });\n };\n const settlePending = (mutationId) => {\n const index = pending.findIndex((mutation2) => mutation2.mutationId === mutationId);\n if (index === -1) {\n return;\n }\n const [mutation] = pending.splice(index, 1);\n persist();\n return mutation;\n };\n const applyFrame = (frame) => {\n if (frame.type === \"snapshot\") {\n confirmed.clear();\n for (const row of frame.rows) {\n confirmed.set(key(row), row);\n }\n if (frame.version !== undefined) {\n appliedVersion = frame.version;\n }\n if (frame.cursor !== undefined) {\n appliedCursor = frame.cursor;\n }\n persistCache();\n recompute({ status: \"ready\", error: undefined });\n } else if (frame.type === \"diff\") {\n for (const row of frame.removed) {\n confirmed.delete(key(row));\n }\n for (const row of frame.added) {\n confirmed.set(key(row), row);\n }\n for (const row of frame.changed) {\n confirmed.set(key(row), row);\n }\n if (frame.cursor !== undefined) {\n appliedCursor = frame.cursor;\n }\n if (frame.version !== undefined) {\n appliedVersion = Math.max(appliedVersion, frame.version);\n }\n persistCache();\n recompute({ status: \"ready\", error: undefined });\n } else if (frame.type === \"error\") {\n setState({ error: frame.message });\n options.onError?.(frame.message);\n } else if (frame.type === \"ack\") {\n const mutation = settlePending(frame.mutationId);\n if (mutation !== undefined) {\n recompute();\n mutation.resolve(frame.result);\n }\n } else if (frame.type === \"reject\") {\n const mutation = settlePending(frame.mutationId);\n if (mutation !== undefined) {\n recompute();\n mutation.reject(new Error(String(frame.message)));\n }\n }\n };\n const wsSend = (payload) => {\n socket?.send(payload);\n };\n const sendMutate = (mutation) => {\n if (connected) {\n wsSend(serializer.encodeClient({\n type: \"mutate\",\n mutationId: mutation.mutationId,\n name: mutation.name,\n args: mutation.args\n }));\n }\n };\n const connect2 = () => {\n if (closed) {\n return;\n }\n setState({ status: \"connecting\" });\n const ws = new Impl(options.url);\n socket = ws;\n ws.onopen = () => {\n connected = true;\n ws.send(serializer.encodeClient({\n type: \"subscribe\",\n id: SUBSCRIPTION_ID,\n collection: options.collection,\n params: options.params,\n since: appliedCursor ?? (appliedVersion > 0 ? appliedVersion : undefined)\n }));\n for (const mutation of pending) {\n sendMutate(mutation);\n }\n };\n ws.onmessage = (event) => {\n try {\n const decoded = serializer.decode(event.data);\n if (decoded !== null && typeof decoded === \"object\") {\n applyFrame(decoded);\n if (hasReconnectHealthyFrameType(decoded, serverFrameTypes)) {\n reconnectBackoff.markHealthy();\n }\n }\n } catch {}\n };\n ws.onclose = () => {\n connected = false;\n if (closed || reconnectMs <= 0) {\n return;\n }\n const delay = reconnectBackoff.nextDelay();\n reconnectTimer = setTimeout(connect2, delay);\n };\n };\n const hydratePersisted = async () => {\n if (options.storage === undefined) {\n return;\n }\n const records = await options.storage.load();\n for (const record of records) {\n if (pending.some((m) => m.mutationId === record.mutationId)) {\n continue;\n }\n pending.push({\n mutationId: record.mutationId,\n name: record.name,\n args: record.args,\n resolve: () => {},\n reject: () => {}\n });\n mutationSeq = Math.max(mutationSeq, record.mutationId);\n }\n if (connected) {\n for (const mutation of pending) {\n sendMutate(mutation);\n }\n }\n };\n const hydrateCache = async () => {\n if (options.cache === undefined) {\n return;\n }\n let snapshot;\n try {\n snapshot = await options.cache.load();\n } catch {\n return;\n }\n if (snapshot === undefined || appliedVersion > 0) {\n return;\n }\n for (const row of snapshot.rows) {\n confirmed.set(key(row), row);\n }\n appliedVersion = snapshot.version;\n recompute();\n };\n if (options.cache === undefined) {\n connect2();\n hydratePersisted();\n } else {\n (async () => {\n await hydrateCache();\n await hydratePersisted();\n connect2();\n })();\n }\n return {\n get: () => state,\n subscribe: (listener) => {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n mutate: (mutateOptions) => new Promise((resolve, reject) => {\n const mutation = {\n mutationId: mutationSeq += 1,\n name: mutateOptions.name,\n args: mutateOptions.args,\n optimistic: mutateOptions.optimistic,\n resolve: (result) => resolve(result),\n reject\n };\n pending.push(mutation);\n persist();\n recompute();\n sendMutate(mutation);\n }),\n disconnect: () => {\n if (closed || socket === undefined) {\n return;\n }\n try {\n socket.close();\n } catch {}\n },\n close: () => {\n if (closed) {\n return;\n }\n closed = true;\n connected = false;\n if (reconnectTimer !== undefined) {\n clearTimeout(reconnectTimer);\n }\n try {\n wsSend(serializer.encodeClient({\n type: \"unsubscribe\",\n id: SUBSCRIPTION_ID\n }));\n socket?.close();\n } catch {}\n for (const mutation of pending.splice(0)) {\n mutation.reject(new Error(\"sync collection closed\"));\n }\n persist();\n setState({ status: \"closed\" });\n listeners.clear();\n }\n };\n};\n// src/client/collaborativeText.ts\nvar createCollaborativeText = (options) => {\n const keyField = options.keyField ?? \"id\";\n const mutation = options.mutation ?? `${options.collection}:merge`;\n const replica = options.replica ?? globalThis.crypto.randomUUID();\n const make = options.create ?? ((id) => createTextCrdt(id));\n const crdt = make(replica);\n let current = {\n ready: false,\n status: \"connecting\",\n text: \"\"\n };\n let pendingText = null;\n const subscribers = new Set;\n const emit = () => {\n for (const run of subscribers) {\n run(current);\n }\n };\n const collection = createSyncCollection({\n collection: options.collection,\n key: (row) => row[keyField],\n params: options.params,\n url: options.url\n });\n const broadcast = (next) => {\n crdt.setText(next);\n current = { ...current, text: next };\n emit();\n const payload = crdt.takeDelta ? crdt.takeDelta() : crdt.state();\n collection.mutate({\n args: { [keyField]: options.id, [options.field]: payload },\n name: mutation\n });\n };\n const apply = (state) => {\n let { text } = current;\n const row = state.data.find((candidate) => candidate[keyField] === options.id);\n const fieldState = row?.[options.field];\n if (fieldState !== undefined) {\n crdt.merge(fieldState);\n text = crdt.text();\n }\n const ready = current.ready || fieldState !== undefined;\n current = { ready, status: state.status, text };\n emit();\n if (ready && pendingText !== null) {\n const buffered = pendingText;\n pendingText = null;\n broadcast(buffered);\n }\n };\n apply(collection.get());\n const unsubscribe = collection.subscribe(apply);\n return {\n get: () => current,\n subscribe(run) {\n subscribers.add(run);\n run(current);\n return () => {\n subscribers.delete(run);\n };\n },\n setText(next) {\n if (!current.ready) {\n pendingText = next;\n current = { ...current, text: next };\n emit();\n return;\n }\n broadcast(next);\n },\n anchorAt: (index) => crdt.anchorAt?.(index) ?? null,\n indexOfAnchor: (anchor) => crdt.indexOfAnchor?.(anchor) ?? 0,\n close() {\n unsubscribe();\n collection.close();\n subscribers.clear();\n }\n };\n};\n// src/client/presence.ts\nvar createPresence = (options) => {\n const reconnectMs = options.reconnectMs ?? 500;\n const maxReconnectMs = options.maxReconnectMs ?? 1e4;\n const serializer = options.serializer ?? jsonSerializer;\n const Impl = options.webSocketImpl ?? globalThis.WebSocket;\n if (!Impl) {\n throw new Error(\"createPresence requires WebSocket. Run in a browser or pass webSocketImpl.\");\n }\n const id = options.memberId ?? globalThis.crypto?.randomUUID?.() ?? `m${Math.random()}`;\n const members = new Map;\n let state = options.state;\n let snapshot = [];\n const listeners = new Set;\n const emit = () => {\n snapshot = [...members].map(([memberId, memberState]) => ({\n id: memberId,\n state: memberState\n }));\n for (const listener of listeners) {\n listener(snapshot);\n }\n };\n let socket;\n let connected = false;\n let closed = false;\n const reconnectBackoff = createReconnectBackoff(reconnectMs, maxReconnectMs);\n let reconnectTimer;\n const send = (frame) => {\n if (connected) {\n socket?.send(serializer.encodeClient(frame));\n }\n };\n const connect2 = () => {\n if (closed) {\n return;\n }\n const ws = new Impl(options.url);\n socket = ws;\n ws.onopen = () => {\n connected = true;\n ws.send(serializer.encodeClient({\n type: \"presence-join\",\n room: options.room,\n memberId: id,\n state\n }));\n };\n ws.onmessage = (event) => {\n let frame;\n const decoded = serializer.decode(event.data);\n if (decoded === null || typeof decoded !== \"object\") {\n return;\n }\n frame = decoded;\n if (frame.type !== \"presence\" || frame.room !== options.room) {\n return;\n }\n reconnectBackoff.markHealthy();\n for (const member of frame.joined ?? []) {\n members.set(member.id, member.state);\n }\n for (const member of frame.updated ?? []) {\n members.set(member.id, member.state);\n }\n for (const memberId of frame.left ?? []) {\n members.delete(memberId);\n }\n emit();\n };\n ws.onclose = () => {\n connected = false;\n if (closed || reconnectMs <= 0) {\n return;\n }\n const delay = reconnectBackoff.nextDelay();\n reconnectTimer = setTimeout(connect2, delay);\n };\n };\n connect2();\n return {\n id,\n get: () => snapshot,\n subscribe: (listener) => {\n listeners.add(listener);\n listener(snapshot);\n return () => {\n listeners.delete(listener);\n };\n },\n set: (next) => {\n state = next;\n send({ type: \"presence-set\", room: options.room, state: next });\n },\n close: () => {\n closed = true;\n if (reconnectTimer !== undefined) {\n clearTimeout(reconnectTimer);\n }\n send({ type: \"presence-leave\", room: options.room });\n socket?.close();\n members.clear();\n }\n };\n};\n// src/client/localStore.ts\nclass SyncLocalDataPolicyError extends Error {\n code;\n constructor(code, message) {\n super(message);\n this.name = \"SyncLocalDataPolicyError\";\n this.code = code;\n }\n}\n\nclass SyncLocalStoreSchemaError extends Error {\n code;\n storedVersion;\n targetVersion;\n constructor(code, message, versions = {}) {\n super(message);\n this.name = \"SyncLocalStoreSchemaError\";\n this.code = code;\n this.storedVersion = versions.storedVersion;\n this.targetVersion = versions.targetVersion;\n }\n}\nvar positiveVersion = (value, label) => {\n if (!Number.isSafeInteger(value) || value < 1)\n throw new SyncLocalStoreSchemaError(\"INVALID_PLAN\", `${label} must be a positive safe integer`);\n return value;\n};\nvar isSchemaBundle = (schema) => (\"components\" in schema);\nvar validatePolicyMatch = (match, label) => {\n if (match.length === 0 || match.trim() !== match || /^\\*+$/.test(match) || match.includes(\"**\"))\n throw new SyncLocalDataPolicyError(\"INVALID_POLICY\", `${label}.match must be an exact name or a non-empty glob without adjacent wildcards.`);\n};\nvar validateSyncLocalDataPolicy = (policy, label = \"localData\") => {\n if (policy.maxBytesPerNamespace !== undefined && (!Number.isSafeInteger(policy.maxBytesPerNamespace) || policy.maxBytesPerNamespace < 1))\n throw new SyncLocalDataPolicyError(\"INVALID_POLICY\", `${label}.maxBytesPerNamespace must be a positive safe integer.`);\n for (const [index, rule] of (policy.collections ?? []).entries()) {\n validatePolicyMatch(rule.match, `${label}.collections[${index}]`);\n if (rule.maxAgeMs !== undefined && (!Number.isSafeInteger(rule.maxAgeMs) || rule.maxAgeMs < 1))\n throw new SyncLocalDataPolicyError(\"INVALID_POLICY\", `${label}.collections[${index}].maxAgeMs must be a positive safe integer.`);\n if (rule.persistence === \"memory-only\" && rule.protection === \"required\")\n throw new SyncLocalDataPolicyError(\"INVALID_POLICY\", `${label}.collections[${index}] cannot require at-rest protection when it is memory-only.`);\n if (rule.sensitivity !== undefined && rule.sensitivity !== \"public\" && rule.protection !== \"required\" && rule.persistence !== \"memory-only\")\n throw new SyncLocalDataPolicyError(\"INVALID_POLICY\", `${label}.collections[${index}] declares ${rule.sensitivity} data without required protection or memory-only persistence.`);\n }\n for (const [index, rule] of (policy.mutations ?? []).entries()) {\n validatePolicyMatch(rule.match, `${label}.mutations[${index}]`);\n if (rule.conflict !== undefined && rule.conflict.strategy !== \"client-wins\" && rule.conflict.strategy !== \"manual\" && rule.conflict.strategy !== \"server-wins\")\n throw new SyncLocalDataPolicyError(\"INVALID_POLICY\", `${label}.mutations[${index}].conflict.strategy is invalid.`);\n if (rule.conflict?.maxAttempts !== undefined && (!Number.isSafeInteger(rule.conflict.maxAttempts) || rule.conflict.maxAttempts < 1))\n throw new SyncLocalDataPolicyError(\"INVALID_POLICY\", `${label}.mutations[${index}].conflict.maxAttempts must be a positive safe integer.`);\n if (rule.conflict?.maxAttempts !== undefined && rule.conflict.strategy !== \"client-wins\")\n throw new SyncLocalDataPolicyError(\"INVALID_POLICY\", `${label}.mutations[${index}].conflict.maxAttempts is only valid for client-wins.`);\n if (rule.persistence === \"memory-only\" && rule.protection === \"required\")\n throw new SyncLocalDataPolicyError(\"INVALID_POLICY\", `${label}.mutations[${index}] cannot require at-rest protection when it is memory-only.`);\n if (rule.sensitivity !== undefined && rule.sensitivity !== \"public\" && rule.protection !== \"required\" && rule.persistence !== \"memory-only\")\n throw new SyncLocalDataPolicyError(\"INVALID_POLICY\", `${label}.mutations[${index}] declares ${rule.sensitivity} arguments without required protection.`);\n }\n return policy;\n};\nvar resolveSyncLocalDataPolicy = (schema = { version: 1 }) => {\n const policies = normalizeSyncLocalSchemaComponents(schema).map((component) => component.localData ? validateSyncLocalDataPolicy(component.localData, `${component.id}.localData`) : undefined).filter((policy) => policy !== undefined);\n const quotas = policies.map((policy) => policy.maxBytesPerNamespace).filter((value) => value !== undefined);\n return {\n ...quotas.length > 0 ? { maxBytesPerNamespace: Math.min(...quotas) } : {},\n collections: policies.flatMap((policy) => policy.collections ?? []),\n mutations: policies.flatMap((policy) => policy.mutations ?? [])\n };\n};\nvar policyMatches = (pattern, name) => pattern === name || (() => {\n const pieces = pattern.split(\"*\");\n if (pieces.length === 1)\n return false;\n let offset = 0;\n for (const [index, piece] of pieces.entries()) {\n if (piece.length === 0)\n continue;\n const found = name.indexOf(piece, offset);\n if (found < 0 || index === 0 && found !== 0)\n return false;\n offset = found + piece.length;\n }\n const last = pieces.at(-1);\n return last.length === 0 || name.endsWith(last);\n})();\nvar matchingPolicy = (rules, name) => {\n const matches = rules.filter((rule) => policyMatches(rule.match, name));\n if (matches.length === 0)\n return;\n const specificity = (rule) => rule.match.replaceAll(\"*\", \"\").length;\n matches.sort((left, right) => specificity(right) - specificity(left));\n if (matches[1] !== undefined && specificity(matches[0]) === specificity(matches[1]))\n throw new SyncLocalDataPolicyError(\"INVALID_POLICY\", `Local-data policy has equally specific rules for \"${name}\".`);\n return matches[0];\n};\nvar resolveSyncLocalCollectionPolicy = (policy, name) => matchingPolicy(policy.collections, name) ?? { match: name };\nvar resolveSyncLocalMutationPolicy = (policy, name) => matchingPolicy(policy.mutations, name) ?? { match: name };\nvar normalizeSyncLocalSchemaComponents = (schema = { version: 1 }) => {\n const components = isSchemaBundle(schema) ? [...schema.components] : [{ ...schema, id: \"@absolutejs/app\" }];\n const ids = new Set;\n for (const component of components) {\n if (typeof component.id !== \"string\" || component.id.trim() !== component.id || component.id.length === 0)\n throw new SyncLocalStoreSchemaError(\"INVALID_PLAN\", \"Sync schema component id must be non-empty and trimmed\");\n if (ids.has(component.id))\n throw new SyncLocalStoreSchemaError(\"INVALID_PLAN\", `Sync schema component \"${component.id}\" is declared more than once`);\n ids.add(component.id);\n if (component.localData)\n validateSyncLocalDataPolicy(component.localData, `${component.id}.localData`);\n }\n return components.sort((a, b) => a.id.localeCompare(b.id));\n};\nvar createSyncLocalSchemaStatus = (components, orphanedComponents = [], includeComponents = true) => {\n const app = components.find((component) => component.id === \"@absolutejs/app\");\n return {\n ...includeComponents ? {\n components: components.map((component) => ({\n id: component.id,\n minimumCompatibleVersion: component.minimumCompatibleVersion,\n storedVersion: component.targetVersion,\n targetVersion: component.targetVersion\n }))\n } : {},\n minimumCompatibleVersion: app?.minimumCompatibleVersion ?? 1,\n ...orphanedComponents.length > 0 ? { orphanedComponents: [...orphanedComponents] } : {},\n state: \"ready\",\n storedVersion: app?.targetVersion ?? 1,\n targetVersion: app?.targetVersion ?? 1\n };\n};\nvar resolveSyncLocalSchemaComponents = (storedVersions, schema = { version: 1 }) => {\n const components = normalizeSyncLocalSchemaComponents(schema).map((component) => {\n const current = resolveSyncLocalMigrations(component.version, component);\n return {\n id: component.id,\n ...resolveSyncLocalMigrations(storedVersions[component.id] ?? current.minimumCompatibleVersion, component)\n };\n });\n const active = new Set(components.map((component) => component.id));\n const orphanedComponents = Object.keys(storedVersions).filter((id) => !active.has(id)).sort();\n return { components, orphanedComponents };\n};\nvar migrationCollectionName = (record, context) => record.collection ?? context.key;\nvar migrateRow = (row, operation) => {\n if (typeof row !== \"object\" || row === null || Array.isArray(row))\n throw new SyncLocalStoreSchemaError(\"INVALID_PLAN\", `Sync ${operation.type} requires object rows`);\n const next = { ...row };\n if (operation.type === \"set-default\") {\n if (!Object.hasOwn(next, operation.field))\n next[operation.field] = structuredClone(operation.value);\n } else if (operation.type === \"remove-field\") {\n delete next[operation.field];\n } else if (Object.hasOwn(next, operation.from)) {\n if (Object.hasOwn(next, operation.to))\n throw new SyncLocalStoreSchemaError(\"INVALID_PLAN\", `Sync rename-field cannot overwrite existing field \"${operation.to}\"`);\n next[operation.to] = next[operation.from];\n delete next[operation.from];\n }\n return next;\n};\nvar applyDeclarativeCollectionOperations = (record, context, operations) => {\n let current = structuredClone(record);\n for (const operation of operations) {\n if (operation.collection !== migrationCollectionName(current, context))\n continue;\n if (operation.type === \"delete-collection\")\n return null;\n current = {\n ...current,\n rows: current.rows.map((row) => migrateRow(row, operation))\n };\n }\n return current;\n};\nvar resolveSyncLocalMigrations = (storedVersion, schema = { version: 1 }) => {\n positiveVersion(storedVersion, \"Stored Sync schema version\");\n const targetVersion = positiveVersion(schema.version, \"Target Sync schema version\");\n const migrations = [...schema.migrations ?? []].sort((a, b) => a.toVersion - b.toVersion);\n const versions = new Set;\n for (const migration of migrations) {\n positiveVersion(migration.toVersion, \"Sync migration toVersion\");\n if (versions.has(migration.toVersion))\n throw new SyncLocalStoreSchemaError(\"INVALID_PLAN\", `Sync migration ${migration.toVersion} is declared more than once`);\n versions.add(migration.toVersion);\n }\n const inferredMinimum = migrations[0] ? migrations[0].toVersion - 1 : targetVersion;\n const minimumCompatibleVersion = positiveVersion(schema.minimumCompatibleVersion ?? inferredMinimum, \"Minimum compatible Sync schema version\");\n if (minimumCompatibleVersion > targetVersion)\n throw new SyncLocalStoreSchemaError(\"INVALID_PLAN\", \"Minimum compatible Sync schema version cannot exceed its target\");\n if (storedVersion > targetVersion)\n throw new SyncLocalStoreSchemaError(\"SCHEMA_TOO_NEW\", `Stored Sync schema ${storedVersion} is newer than this runtime's schema ${targetVersion}`, { storedVersion, targetVersion });\n if (storedVersion < minimumCompatibleVersion)\n throw new SyncLocalStoreSchemaError(\"SCHEMA_TOO_OLD\", `Stored Sync schema ${storedVersion} is older than the minimum compatible schema ${minimumCompatibleVersion}`, { storedVersion, targetVersion });\n const steps = [];\n for (let version = storedVersion + 1;version <= targetVersion; version++) {\n const migration = migrations.find((candidate) => candidate.toVersion === version);\n if (migration === undefined)\n throw new SyncLocalStoreSchemaError(\"MIGRATION_MISSING\", `Sync migration ${version - 1} -> ${version} is missing`, { storedVersion, targetVersion });\n steps.push(migration);\n }\n return { minimumCompatibleVersion, steps, targetVersion };\n};\nvar migrateSyncLocalCollectionRecord = (record, context, steps) => {\n let current = structuredClone(record);\n for (const step of steps) {\n if (current === null)\n break;\n current = applyDeclarativeCollectionOperations(current, context, step.operations ?? []);\n if (current === null)\n break;\n const next = step.migrateCollection?.(structuredClone(current), context);\n if (next === null)\n current = null;\n else if (next !== undefined)\n current = structuredClone(next);\n }\n return current;\n};\nvar migrateSyncLocalMutationRecord = (record, context, steps) => {\n let current = structuredClone(record);\n for (const step of steps) {\n if (current === null)\n break;\n const next = step.migrateMutation?.(structuredClone(current), context);\n if (next === null)\n current = null;\n else if (next !== undefined) {\n if (next.operationId !== context.key)\n throw new SyncLocalStoreSchemaError(\"INVALID_PLAN\", \"Sync migrations cannot change a mutation operationId\");\n current = structuredClone(next);\n }\n }\n return current;\n};\nvar jsonBytes = (value) => new TextEncoder().encode(JSON.stringify(value)).byteLength;\nvar evictionRank = {\n disposable: 0,\n normal: 1,\n critical: 2\n};\nvar runSyncLocalPolicyTransaction = async (options) => {\n const { mode, now, policy, raw } = options;\n const requireProtection = (kind, name) => {\n if (!options.protected)\n throw new SyncLocalDataPolicyError(\"PROTECTION_REQUIRED\", `Sync ${kind} \"${name}\" requires encrypted persistence, but this runtime has no audited protection provider.`);\n };\n const collectionPolicy = (record, key) => resolveSyncLocalCollectionPolicy(policy, record.collection ?? key);\n const unavailableMemoryOnly = (rule) => rule.protection === \"required\" && !options.protected && rule.onProtectionUnavailable === \"memory-only\";\n const expired = (record, key) => {\n const rule = collectionPolicy(record, key);\n return rule.maxAgeMs !== undefined && record.storedAt !== undefined && now - record.storedAt >= rule.maxAgeMs;\n };\n const tx = {\n ...raw,\n resolveMutationPolicy: (name) => resolveSyncLocalMutationPolicy(policy, name),\n getCollection: async (key) => {\n const record = await raw.getCollection(key);\n if (record === undefined)\n return;\n const rule = collectionPolicy(record, key);\n if (rule.persistence === \"memory-only\" || unavailableMemoryOnly(rule) || expired(record, key)) {\n if (mode === \"readwrite\")\n await raw.deleteCollection(key);\n return;\n }\n if (rule.protection === \"required\")\n requireProtection(\"collection\", record.collection ?? key);\n return record;\n },\n listCollections: async () => {\n const kept = [];\n for (const entry of await raw.listCollections()) {\n const rule = collectionPolicy(entry.record, entry.key);\n if (rule.persistence === \"memory-only\" || unavailableMemoryOnly(rule) || expired(entry.record, entry.key)) {\n if (mode === \"readwrite\")\n await raw.deleteCollection(entry.key);\n continue;\n }\n if (rule.protection === \"required\")\n requireProtection(\"collection\", entry.record.collection ?? entry.key);\n kept.push(entry);\n }\n return kept;\n },\n putCollection: async (key, record) => {\n const rule = collectionPolicy(record, key);\n if (rule.persistence === \"memory-only\" || unavailableMemoryOnly(rule)) {\n await raw.deleteCollection(key);\n return;\n }\n if (rule.protection === \"required\")\n requireProtection(\"collection\", record.collection ?? key);\n await raw.putCollection(key, rule.maxAgeMs !== undefined || policy.maxBytesPerNamespace !== undefined ? { ...record, storedAt: now } : record);\n },\n getMutation: async (operationId) => {\n const record = await raw.getMutation(operationId);\n if (!record)\n return;\n const rule = resolveSyncLocalMutationPolicy(policy, record.name);\n if (rule.persistence === \"memory-only\" || unavailableMemoryOnly(rule)) {\n if (mode === \"readwrite\")\n await raw.deleteMutation(operationId);\n return;\n }\n if (rule.protection === \"required\")\n requireProtection(\"mutation\", record.name);\n return rule.conflict && record.conflictPolicy === undefined ? { ...record, conflictPolicy: structuredClone(rule.conflict) } : record;\n },\n listMutations: async () => {\n const records = [];\n for (const record of await raw.listMutations()) {\n const rule = resolveSyncLocalMutationPolicy(policy, record.name);\n if (rule.persistence === \"memory-only\" || unavailableMemoryOnly(rule)) {\n if (mode === \"readwrite\")\n await raw.deleteMutation(record.operationId);\n continue;\n }\n if (rule.protection === \"required\")\n requireProtection(\"mutation\", record.name);\n records.push(rule.conflict && record.conflictPolicy === undefined ? {\n ...record,\n conflictPolicy: structuredClone(rule.conflict)\n } : record);\n }\n return records;\n },\n putMutation: async (record) => {\n const rule = resolveSyncLocalMutationPolicy(policy, record.name);\n if (rule.persistence === \"memory-only\" || unavailableMemoryOnly(rule)) {\n await raw.deleteMutation(record.operationId);\n return;\n }\n if (rule.protection === \"required\")\n requireProtection(\"mutation\", record.name);\n await raw.putMutation(rule.conflict && record.conflictPolicy === undefined ? {\n ...record,\n conflictPolicy: structuredClone(rule.conflict)\n } : record);\n }\n };\n const result = await options.run(tx);\n if (mode === \"readwrite\" && policy.maxBytesPerNamespace !== undefined) {\n const mutations = await raw.listMutations();\n let collections = await raw.listCollections();\n let bytes = mutations.reduce((total, value) => total + jsonBytes(value), 0) + collections.reduce((total, entry) => total + jsonBytes(entry.record), 0);\n const candidates = [...collections].sort((left, right) => {\n const leftRule = collectionPolicy(left.record, left.key);\n const rightRule = collectionPolicy(right.record, right.key);\n return evictionRank[leftRule.evictionPriority ?? \"normal\"] - evictionRank[rightRule.evictionPriority ?? \"normal\"] || (left.record.storedAt ?? 0) - (right.record.storedAt ?? 0) || left.key.localeCompare(right.key);\n });\n for (const candidate of candidates) {\n if (bytes <= policy.maxBytesPerNamespace)\n break;\n await raw.deleteCollection(candidate.key);\n bytes -= jsonBytes(candidate.record);\n }\n if (bytes > policy.maxBytesPerNamespace)\n throw new SyncLocalDataPolicyError(\"QUOTA_EXCEEDED\", `Sync pending operations require ${bytes} logical bytes, exceeding the protected ${policy.maxBytesPerNamespace}-byte namespace quota; pending mutations were retained.`);\n }\n return result;\n};\nvar clone = (value) => structuredClone(value);\nvar emptyNamespace = () => ({\n collections: new Map,\n mutations: new Map\n});\nvar cloneNamespace = (source) => ({\n installationId: source.installationId,\n collections: new Map([...source.collections].map(([key, value]) => [key, clone(value)])),\n mutations: new Map([...source.mutations].map(([key, value]) => [key, clone(value)]))\n});\nvar createMemorySyncLocalStore = ({\n storageSchema = { version: 1 },\n protection,\n now = Date.now\n} = {}) => {\n const localData = resolveSyncLocalDataPolicy(storageSchema);\n let protectorPromise;\n const prepareProtector = () => protectorPromise ??= protection?.prepare();\n const targetComponents = normalizeSyncLocalSchemaComponents(storageSchema);\n const resolvedSchema = resolveSyncLocalSchemaComponents(Object.fromEntries(targetComponents.map((component) => [\n component.id,\n component.version\n ])), storageSchema);\n const schemaStatus = createSyncLocalSchemaStatus(resolvedSchema.components, [], isSchemaBundle(storageSchema));\n const namespaces = new Map;\n let tail = Promise.resolve();\n const withLock = async (run) => {\n let release;\n const previous = tail;\n tail = new Promise((resolve) => {\n release = resolve;\n });\n await previous;\n try {\n return await run();\n } finally {\n release();\n }\n };\n const transaction = async (namespace, mode, run) => {\n if (namespace.length === 0) {\n throw new Error(\"Sync local-store namespace must not be empty\");\n }\n const protector = await prepareProtector();\n return withLock(async () => {\n const current = namespaces.get(namespace) ?? emptyNamespace();\n const working = cloneNamespace(current);\n const writable = () => {\n if (mode !== \"readwrite\") {\n throw new Error(\"Cannot write in a readonly Sync local transaction\");\n }\n };\n const tx = {\n getInstallationId: async () => working.installationId,\n setInstallationId: async (installationId) => {\n writable();\n if (installationId.length === 0) {\n throw new Error(\"Sync installation id must not be empty\");\n }\n working.installationId = installationId;\n },\n getCollection: async (key) => {\n const record = working.collections.get(key);\n return record === undefined ? undefined : clone(record);\n },\n listCollections: async () => [...working.collections.entries()].map(([key, record]) => ({\n key,\n record: clone(record)\n })),\n putCollection: async (key, record) => {\n writable();\n working.collections.set(key, clone(record));\n },\n deleteCollection: async (key) => {\n writable();\n working.collections.delete(key);\n },\n listMutations: async () => [...working.mutations.values()].sort((a, b) => a.createdAt - b.createdAt).map(clone),\n getMutation: async (operationId) => {\n const record = working.mutations.get(operationId);\n return record === undefined ? undefined : clone(record);\n },\n putMutation: async (record) => {\n writable();\n working.mutations.set(record.operationId, clone(record));\n },\n deleteMutation: async (operationId) => {\n writable();\n working.mutations.delete(operationId);\n }\n };\n const result = await runSyncLocalPolicyTransaction({\n mode,\n now: now(),\n policy: localData,\n protected: protector !== undefined,\n raw: tx,\n run\n });\n if (mode === \"readwrite\")\n namespaces.set(namespace, working);\n return result;\n });\n };\n return {\n transaction,\n getSchemaStatus: async () => ({ ...schemaStatus }),\n deleteNamespace: async (namespace) => {\n await withLock(async () => {\n namespaces.delete(namespace);\n return;\n });\n }\n };\n};\nvar openProtectedRecord = (value, protector, context) => {\n if (protector === undefined || protector.id !== value.protector)\n throw new SyncLocalDataPolicyError(\"PROTECTION_REQUIRED\", `Sync data is protected by \"${value.protector}\", which is unavailable in this runtime.`);\n return JSON.parse(protector.open(value.value, { ...context, name: value.name }));\n};\nvar requestResult = (request) => new Promise((resolve, reject) => {\n request.onsuccess = () => resolve(request.result);\n request.onerror = () => reject(request.error);\n});\nvar transactionComplete = (transaction) => new Promise((resolve, reject) => {\n transaction.oncomplete = () => resolve();\n transaction.onabort = () => reject(transaction.error ?? new Error(\"IndexedDB transaction aborted\"));\n transaction.onerror = () => reject(transaction.error ?? new Error(\"IndexedDB transaction failed\"));\n});\nvar deleteIndexRows = (index, namespace) => new Promise((resolve, reject) => {\n const request = index.openCursor(namespace);\n request.onerror = () => reject(request.error);\n request.onsuccess = () => {\n const cursor = request.result;\n if (cursor === null) {\n resolve();\n return;\n }\n cursor.delete();\n cursor.continue();\n };\n});\nvar migrateIndexedRows = (request, migrate) => new Promise((resolve, reject) => {\n request.onerror = () => reject(request.error);\n request.onsuccess = () => {\n const cursor = request.result;\n if (cursor === null) {\n resolve();\n return;\n }\n let next;\n try {\n next = migrate(cursor.value);\n } catch (error) {\n reject(error);\n return;\n }\n const write = next === null ? cursor.delete() : cursor.update(next);\n write.onerror = () => reject(write.error);\n write.onsuccess = () => cursor.continue();\n };\n});\nvar createIndexedDbSyncLocalStore = ({\n databaseName = \"absolutejs-sync-local-v1\",\n indexedDB: factory = globalThis.indexedDB,\n storageSchema = { version: 1 },\n protection,\n now = Date.now\n} = {}) => {\n const localData = resolveSyncLocalDataPolicy(storageSchema);\n let protectorPromise;\n const prepareProtector = () => protectorPromise ??= protection?.prepare();\n if (factory === undefined) {\n throw new Error(\"createIndexedDbSyncLocalStore requires IndexedDB in this runtime\");\n }\n let databasePromise;\n const database = () => {\n databasePromise ??= new Promise((resolve, reject) => {\n const request = factory.open(databaseName, 2);\n request.onupgradeneeded = () => {\n const db = request.result;\n if (!db.objectStoreNames.contains(\"metadata\"))\n db.createObjectStore(\"metadata\");\n if (!db.objectStoreNames.contains(\"collections\")) {\n const collections = db.createObjectStore(\"collections\", {\n keyPath: [\"namespace\", \"key\"]\n });\n collections.createIndex(\"namespace\", \"namespace\");\n }\n if (!db.objectStoreNames.contains(\"mutations\")) {\n const mutations = db.createObjectStore(\"mutations\", {\n keyPath: [\"namespace\", \"operationId\"]\n });\n mutations.createIndex(\"namespace\", \"namespace\");\n }\n if (!db.objectStoreNames.contains(\"schema\"))\n db.createObjectStore(\"schema\");\n };\n request.onsuccess = () => {\n request.result.onversionchange = () => request.result.close();\n resolve(request.result);\n };\n request.onerror = () => reject(request.error);\n request.onblocked = () => reject(new Error(`IndexedDB upgrade blocked for \"${databaseName}\"`));\n });\n return databasePromise;\n };\n let schemaPromise;\n const prepareSchema = () => {\n schemaPromise ??= Promise.all([database(), prepareProtector()]).then(async ([db, preparedProtector]) => {\n const native = db.transaction([\"schema\", \"collections\", \"mutations\"], \"readwrite\");\n const completed = transactionComplete(native);\n try {\n const schemaStore = native.objectStore(\"schema\");\n const savedVersion = await requestResult(schemaStore.get(\"logicalVersion\"));\n const savedComponents = await requestResult(schemaStore.get(\"componentVersions\"));\n const storedVersions = {};\n if (typeof savedComponents === \"object\" && savedComponents !== null && !Array.isArray(savedComponents))\n for (const [id, version] of Object.entries(savedComponents)) {\n if (!Number.isSafeInteger(version) || version < 1)\n throw new SyncLocalStoreSchemaError(\"INVALID_PLAN\", `Stored Sync component \"${id}\" has an invalid version`);\n storedVersions[id] = version;\n }\n if (storedVersions[\"@absolutejs/app\"] === undefined && typeof savedVersion === \"number\")\n storedVersions[\"@absolutejs/app\"] = savedVersion;\n const resolved = resolveSyncLocalSchemaComponents(storedVersions, storageSchema);\n const steps = resolved.components.flatMap((component) => component.steps);\n if (steps.length > 0) {\n await migrateIndexedRows(native.objectStore(\"collections\").openCursor(), (row) => {\n const {\n namespace,\n key,\n protectedRecord,\n ...plain\n } = row;\n const record = protectedRecord ? openProtectedRecord(protectedRecord, preparedProtector, { kind: \"collection\", namespace }) : plain;\n const migrated = migrateSyncLocalCollectionRecord(record, { key, namespace }, steps);\n if (migrated === null)\n return null;\n return protectedRecord && preparedProtector ? {\n key,\n namespace,\n protectedRecord: {\n ...protectedRecord,\n value: preparedProtector.seal(JSON.stringify(migrated), {\n kind: \"collection\",\n name: migrated.collection ?? key,\n namespace\n })\n }\n } : { ...migrated, key, namespace };\n });\n await migrateIndexedRows(native.objectStore(\"mutations\").openCursor(), (row) => {\n const { namespace, protectedRecord, ...plain } = row;\n const record = protectedRecord ? openProtectedRecord(protectedRecord, preparedProtector, { kind: \"mutation\", namespace }) : plain;\n const migrated = migrateSyncLocalMutationRecord(record, { key: record.operationId, namespace }, steps);\n if (migrated === null)\n return null;\n return protectedRecord && preparedProtector ? {\n createdAt: migrated.createdAt,\n namespace,\n operationId: migrated.operationId,\n protectedRecord: {\n ...protectedRecord,\n value: preparedProtector.seal(JSON.stringify(migrated), {\n kind: \"mutation\",\n name: migrated.name,\n namespace\n })\n }\n } : { ...migrated, namespace };\n });\n }\n const nextVersions = { ...storedVersions };\n for (const component of resolved.components)\n nextVersions[component.id] = component.targetVersion;\n await requestResult(schemaStore.put(nextVersions, \"componentVersions\"));\n const app = resolved.components.find((component) => component.id === \"@absolutejs/app\");\n if (app)\n await requestResult(schemaStore.put(app.targetVersion, \"logicalVersion\"));\n await completed;\n return createSyncLocalSchemaStatus(resolved.components, resolved.orphanedComponents, isSchemaBundle(storageSchema));\n } catch (error) {\n try {\n native.abort();\n } catch {}\n await completed.catch(() => {});\n throw error;\n }\n });\n return schemaPromise;\n };\n const transaction = async (namespace, mode, run) => {\n if (namespace.length === 0) {\n throw new Error(\"Sync local-store namespace must not be empty\");\n }\n await prepareSchema();\n const protector = await prepareProtector();\n const db = await database();\n const native = db.transaction([\"metadata\", \"collections\", \"mutations\"], mode);\n const completed = transactionComplete(native);\n const writable = () => {\n if (mode !== \"readwrite\") {\n throw new Error(\"Cannot write in a readonly Sync local transaction\");\n }\n };\n const metadata = native.objectStore(\"metadata\");\n const collections = native.objectStore(\"collections\");\n const mutations = native.objectStore(\"mutations\");\n const tx = {\n getInstallationId: () => requestResult(metadata.get(namespace)),\n setInstallationId: async (installationId) => {\n writable();\n if (installationId.length === 0) {\n throw new Error(\"Sync installation id must not be empty\");\n }\n await requestResult(metadata.put(installationId, namespace));\n },\n getCollection: async (key) => {\n const row = await requestResult(collections.get([namespace, key]));\n if (row === undefined)\n return;\n if (row.protectedRecord)\n return openProtectedRecord(row.protectedRecord, protector, { kind: \"collection\", namespace });\n const {\n namespace: _namespace,\n key: _key,\n protectedRecord: _protected,\n ...record\n } = row;\n return record;\n },\n listCollections: async () => {\n const rows = await requestResult(collections.index(\"namespace\").getAll(namespace));\n return rows.map((row) => ({\n key: row.key,\n record: row.protectedRecord ? openProtectedRecord(row.protectedRecord, protector, { kind: \"collection\", namespace }) : (({\n namespace: _namespace,\n key: _key,\n protectedRecord: _protected,\n ...record\n }) => record)(row)\n }));\n },\n putCollection: async (key, record) => {\n writable();\n await requestResult(collections.put(protector ? {\n key,\n namespace,\n protectedRecord: {\n name: record.collection ?? key,\n protector: protector.id,\n value: protector.seal(JSON.stringify(record), {\n kind: \"collection\",\n name: record.collection ?? key,\n namespace\n })\n }\n } : { ...record, key, namespace }));\n },\n deleteCollection: async (key) => {\n writable();\n await requestResult(collections.delete([namespace, key]));\n },\n listMutations: async () => {\n const rows = await requestResult(mutations.index(\"namespace\").getAll(namespace));\n return rows.map((row) => row.protectedRecord ? openProtectedRecord(row.protectedRecord, protector, { kind: \"mutation\", namespace }) : (({\n namespace: _namespace,\n protectedRecord: _protected,\n ...record\n }) => record)(row)).sort((a, b) => a.createdAt - b.createdAt);\n },\n getMutation: async (operationId) => {\n const row = await requestResult(mutations.get([namespace, operationId]));\n if (row === undefined)\n return;\n if (row.protectedRecord)\n return openProtectedRecord(row.protectedRecord, protector, { kind: \"mutation\", namespace });\n const {\n namespace: _namespace,\n protectedRecord: _protected,\n ...record\n } = row;\n return record;\n },\n putMutation: async (record) => {\n writable();\n await requestResult(mutations.put(protector ? {\n createdAt: record.createdAt,\n namespace,\n operationId: record.operationId,\n protectedRecord: {\n name: record.name,\n protector: protector.id,\n value: protector.seal(JSON.stringify(record), {\n kind: \"mutation\",\n name: record.name,\n namespace\n })\n }\n } : { ...record, namespace }));\n },\n deleteMutation: async (operationId) => {\n writable();\n await requestResult(mutations.delete([namespace, operationId]));\n }\n };\n try {\n const result = await runSyncLocalPolicyTransaction({\n mode,\n now: now(),\n policy: localData,\n protected: protector !== undefined,\n raw: tx,\n run\n });\n await completed;\n return result;\n } catch (error) {\n try {\n native.abort();\n } catch {}\n await completed.catch(() => {});\n throw error;\n }\n };\n return {\n transaction,\n getSchemaStatus: async () => ({ ...await prepareSchema() }),\n deleteNamespace: async (namespace) => {\n await prepareSchema();\n const db = await database();\n const native = db.transaction([\"metadata\", \"collections\", \"mutations\"], \"readwrite\");\n const completed = transactionComplete(native);\n await requestResult(native.objectStore(\"metadata\").delete(namespace));\n await deleteIndexRows(native.objectStore(\"collections\").index(\"namespace\"), namespace);\n await deleteIndexRows(native.objectStore(\"mutations\").index(\"namespace\"), namespace);\n await completed;\n }\n };\n};\nvar randomId = () => {\n const id = globalThis.crypto?.randomUUID?.();\n if (id === undefined) {\n throw new Error(\"Sync operation ids require crypto.randomUUID or a createId callback\");\n }\n return id;\n};\nvar ensureSyncInstallationId = (store, namespace, createId = randomId) => store.transaction(namespace, \"readwrite\", async (tx) => {\n const existing = await tx.getInstallationId();\n if (existing !== undefined)\n return existing;\n const installationId = createId();\n await tx.setInstallationId(installationId);\n return installationId;\n});\nvar createSyncOperationId = (installationId, createId = randomId) => `${installationId}:${createId()}`;\n\n// src/reconciliation.ts\nclass SyncMutationRejectedError extends Error {\n operationId;\n rejection;\n constructor(rejection, operationId) {\n super(rejection.message);\n this.name = \"SyncMutationRejectedError\";\n this.operationId = operationId;\n this.rejection = rejection;\n }\n}\n\n// src/client/syncClient.ts\nvar serverFrameTypes2 = [\n \"snapshot\",\n \"diff\",\n \"frame\",\n \"error\",\n \"ack\",\n \"reject\"\n];\nvar canonicalJson = (value) => {\n const seen = new Set;\n const normalize = (input) => {\n if (input === undefined)\n return null;\n if (input === null || typeof input === \"string\" || typeof input === \"boolean\") {\n return input;\n }\n if (typeof input === \"number\") {\n if (!Number.isFinite(input)) {\n throw new Error(\"Sync collection params must contain finite numbers; provide an explicit localKey\");\n }\n return input;\n }\n if (typeof input !== \"object\") {\n throw new Error(\"Sync collection params must be JSON-serializable; provide an explicit localKey\");\n }\n if (seen.has(input)) {\n throw new Error(\"Sync collection params contain a cycle; provide an explicit localKey\");\n }\n seen.add(input);\n try {\n if (Array.isArray(input))\n return input.map(normalize);\n const prototype = Object.getPrototypeOf(input);\n if (prototype !== Object.prototype && prototype !== null) {\n throw new Error(\"Sync collection params must use plain objects; provide an explicit localKey\");\n }\n return Object.fromEntries(Object.entries(input).sort(([a], [b]) => a.localeCompare(b)).map(([key, item]) => [key, normalize(item)]));\n } finally {\n seen.delete(input);\n }\n };\n return JSON.stringify(normalize(value));\n};\nvar defaultLocalKey = (collection, params) => params === undefined ? collection : `${collection}:${canonicalJson(params)}`;\nvar ticketAuthenticatedSocketUrl = (url) => {\n if (/(?:\\?|&)__absolute_auth=/u.test(url))\n return url;\n const hashAt = url.indexOf(\"#\");\n const beforeHash = hashAt === -1 ? url : url.slice(0, hashAt);\n const hash = hashAt === -1 ? \"\" : url.slice(hashAt);\n const separator = beforeHash.includes(\"?\") ? \"&\" : \"?\";\n return `${beforeHash}${separator}__absolute_auth=ticket${hash}`;\n};\nvar createSyncClient = (options) => {\n const runtime = getSyncClientRuntimeTransport();\n const socketTicket = options.socketTicket ?? runtime?.socketTicket;\n const durable = options.durable ?? runtime?.durable;\n const reconnectMs = options.reconnectMs ?? 500;\n const maxReconnectMs = options.maxReconnectMs ?? 1e4;\n const maxAttempts = durable?.maxAttempts ?? 5;\n if (!Number.isInteger(maxAttempts) || maxAttempts < 1) {\n throw new TypeError(\"durable.maxAttempts must be a positive integer\");\n }\n const retryBackoff = durable?.retryBackoff ?? ((attempt) => Math.min(30000, 500 * 2 ** (attempt - 1)));\n const serializer = options.serializer ?? jsonSerializer;\n const Impl = options.webSocketImpl ?? runtime?.webSocketImpl ?? globalThis.WebSocket;\n if (!Impl) {\n throw new Error(\"createSyncClient requires WebSocket. Run in a browser or pass webSocketImpl.\");\n }\n const entries = new Map;\n const pending = [];\n const mutationOwner = new Map;\n const deadLetters = new Map;\n const retryTimers = new Map;\n const statusListeners = new Set;\n let nextEntryId = 0;\n let mutationSeq = 0;\n let installationId;\n let socket;\n let connected = false;\n let closed = false;\n const reconnectBackoff = createReconnectBackoff(reconnectMs, maxReconnectMs);\n let reconnectTimer;\n let immediateReconnect = false;\n let clientStatus = {\n automaticResolutions: 0,\n connection: \"connecting\",\n conflicts: 0,\n deadLetters: 0,\n pending: 0\n };\n const snapshotStatus = () => ({ ...clientStatus });\n const updateStatus = (patch = {}) => {\n const oldestPendingAt = pending.reduce((oldest, mutation) => oldest === undefined ? mutation.createdAt : Math.min(oldest, mutation.createdAt), undefined);\n const retained = [...deadLetters.values()];\n const oldestDeadLetterAt = retained.reduce((oldest, record) => {\n const at = record.deadLetteredAt ?? record.createdAt;\n return oldest === undefined ? at : Math.min(oldest, at);\n }, undefined);\n clientStatus = {\n ...clientStatus,\n ...patch,\n pending: pending.length,\n deadLetters: deadLetters.size,\n conflicts: retained.filter((record) => record.rejection?.kind === \"conflict\").length,\n ...oldestDeadLetterAt === undefined ? {} : { oldestDeadLetterAt },\n ...oldestPendingAt === undefined ? {} : { oldestPendingAt }\n };\n if (oldestPendingAt === undefined)\n delete clientStatus.oldestPendingAt;\n if (oldestDeadLetterAt === undefined)\n delete clientStatus.oldestDeadLetterAt;\n for (const listener of statusListeners)\n listener(snapshotStatus());\n };\n const notify = (entry) => {\n for (const listener of entry.listeners) {\n listener(entry.state);\n }\n };\n const rebuild = (entry, patch = {}) => {\n const working = new Map(entry.confirmed);\n const draft = {\n set: (row) => working.set(entry.key(row), row),\n delete: (rowKey) => working.delete(rowKey)\n };\n for (const mutation of pending) {\n if (mutation.ownerKey === entry.localKey) {\n mutation.optimistic?.(draft);\n }\n for (const operation of mutation.optimisticOperations) {\n if (operation.collection !== entry.localKey)\n continue;\n if (operation.type === \"delete\")\n draft.delete(operation.key);\n else\n draft.set(operation.row);\n }\n }\n entry.state = {\n ...entry.state,\n ...patch,\n data: [...working.values()]\n };\n };\n const recompute = (entry, patch = {}) => {\n rebuild(entry, patch);\n notify(entry);\n };\n const applyDiffToConfirmed = (entry, diff) => {\n for (const row of diff.removed) {\n entry.confirmed.delete(entry.key(row));\n }\n for (const row of diff.added) {\n entry.confirmed.set(entry.key(row), row);\n }\n for (const row of diff.changed) {\n entry.confirmed.set(entry.key(row), row);\n }\n };\n const settlePending = (mutationId) => {\n const mutation = mutationOwner.get(mutationId);\n mutationOwner.delete(mutationId);\n if (mutation === undefined) {\n return;\n }\n const index = pending.findIndex((item) => item === mutation);\n if (index === -1) {\n return;\n }\n pending.splice(index, 1);\n if (mutation.operationId !== undefined) {\n const timer = retryTimers.get(mutation.operationId);\n if (timer !== undefined)\n clearTimeout(timer);\n retryTimers.delete(mutation.operationId);\n }\n updateStatus();\n return mutation;\n };\n const reportStorageError = (error) => {\n durable?.onError?.(error);\n options.onError?.(error);\n };\n let localWriteTail = Promise.resolve();\n const queueLocalWrite = (run) => {\n const next = localWriteTail.then(run);\n localWriteTail = next.then(() => {\n return;\n }, (error) => reportStorageError(error));\n return next;\n };\n const persistEntries = (affected) => {\n if (durable === undefined)\n return;\n const snapshots = new Map;\n for (const entry of affected) {\n snapshots.set(entry.localKey, {\n rows: [...entry.confirmed.values()],\n version: entry.appliedVersion,\n cursor: entry.cursor,\n collection: entry.collection,\n params: entry.params,\n ...entry.headlessKey ? { headlessKey: entry.headlessKey } : {}\n });\n }\n queueLocalWrite(() => durable.store.transaction(durable.namespace, \"readwrite\", async (tx) => {\n for (const [key, record] of snapshots) {\n await tx.putCollection(key, record);\n }\n })).catch(() => {});\n };\n const recomputeMutationEntries = (mutation) => {\n const keys = new Set([\n mutation.ownerKey,\n ...mutation.optimisticOperations.map((operation) => operation.collection)\n ]);\n for (const entry of entries.values()) {\n if (keys.has(entry.localKey))\n recompute(entry);\n }\n };\n let sendMutate;\n const finishPending = (mutationId, result, error) => {\n const mutation = settlePending(mutationId);\n if (mutation === undefined)\n return;\n recomputeMutationEntries(mutation);\n if (error === undefined)\n mutation.resolve?.(result);\n else\n mutation.reject?.(error);\n };\n const finishDurablePending = (mutationId, echoedOperationId, result, error) => {\n const mutation = mutationOwner.get(mutationId);\n if (mutation?.operationId === undefined || durable === undefined) {\n finishPending(mutationId, result, error);\n return;\n }\n if (echoedOperationId !== mutation.operationId) {\n reportStorageError(new Error(`Durable mutation acknowledgment identity mismatch for ${mutation.operationId}`));\n return;\n }\n queueLocalWrite(() => durable.store.transaction(durable.namespace, \"readwrite\", (tx) => tx.deleteMutation(mutation.operationId))).then(() => finishPending(mutationId, result, error)).catch(() => {});\n };\n const deadLetterPending = (mutationId, rejection) => {\n const mutation = mutationOwner.get(mutationId);\n if (mutation?.operationId === undefined || durable === undefined) {\n finishPending(mutationId, undefined, new SyncMutationRejectedError(rejection, mutation?.operationId));\n return;\n }\n const deadLetteredAt = Date.now();\n queueLocalWrite(() => durable.store.transaction(durable.namespace, \"readwrite\", async (tx) => {\n const current = await tx.getMutation(mutation.operationId);\n if (current === undefined)\n return;\n const record = {\n ...current,\n attempts: mutation.attempts,\n deadLetteredAt,\n lastError: rejection.message,\n rejection,\n state: \"dead-letter\"\n };\n delete record.nextAttemptAt;\n await tx.putMutation(record);\n deadLetters.set(record.operationId, record);\n })).then(() => {\n updateStatus({ lastError: rejection.message });\n finishPending(mutationId, undefined, new SyncMutationRejectedError(rejection, mutation.operationId));\n }).catch(() => {});\n };\n const retryRejectedPending = (mutation, rejection) => {\n if (mutation.operationId === undefined || durable === undefined) {\n deadLetterPending(mutation.mutationId, rejection);\n return;\n }\n if (mutation.attempts >= maxAttempts) {\n deadLetterPending(mutation.mutationId, rejection);\n return;\n }\n const delay = Math.max(0, rejection.retryAfterMs ?? retryBackoff(mutation.attempts));\n mutation.nextAttemptAt = Date.now() + delay;\n queueLocalWrite(() => durable.store.transaction(durable.namespace, \"readwrite\", async (tx) => {\n const record = await tx.getMutation(mutation.operationId);\n if (record === undefined)\n return;\n await tx.putMutation({\n ...record,\n attempts: mutation.attempts,\n lastError: rejection.message,\n nextAttemptAt: mutation.nextAttemptAt,\n rejection,\n state: \"pending\"\n });\n })).then(() => {\n updateStatus({ lastError: rejection.message });\n sendMutate(mutation);\n }).catch(() => {});\n };\n const resolveConflictedPending = (mutation, rejection) => {\n const policy = mutation.conflictPolicy;\n if (!policy || policy.strategy === \"manual\")\n return false;\n const lastConflictAt = Date.now();\n if (policy.strategy === \"server-wins\") {\n queueLocalWrite(() => durable === undefined || mutation.operationId === undefined ? Promise.resolve() : durable.store.transaction(durable.namespace, \"readwrite\", (tx) => tx.deleteMutation(mutation.operationId))).then(() => {\n updateStatus({\n automaticResolutions: clientStatus.automaticResolutions + 1,\n lastConflictAt,\n lastError: rejection.message\n });\n finishPending(mutation.mutationId, undefined, new SyncMutationRejectedError(rejection, mutation.operationId));\n }).catch(() => {});\n return true;\n }\n const conflictAttempts = mutation.conflictAttempts ?? 0;\n if (conflictAttempts >= (policy.maxAttempts ?? 1))\n return false;\n mutation.conflictAttempts = conflictAttempts + 1;\n mutation.nextAttemptAt = undefined;\n queueLocalWrite(() => durable === undefined || mutation.operationId === undefined ? Promise.resolve() : durable.store.transaction(durable.namespace, \"readwrite\", async (tx) => {\n const record = await tx.getMutation(mutation.operationId);\n if (record === undefined)\n return;\n await tx.putMutation({\n ...record,\n attempts: mutation.attempts,\n conflictAttempts: mutation.conflictAttempts,\n lastError: rejection.message,\n rejection,\n state: \"pending\"\n });\n })).then(() => {\n updateStatus({\n automaticResolutions: clientStatus.automaticResolutions + 1,\n lastConflictAt,\n lastError: rejection.message\n });\n sendMutate(mutation);\n }).catch(() => {});\n return true;\n };\n const applyFrame = (frame) => {\n updateStatus({ connection: \"online\" });\n if (frame.type === \"snapshot\") {\n const entry = entries.get(frame.id);\n if (entry === undefined) {\n return;\n }\n entry.confirmed.clear();\n for (const row of frame.rows) {\n entry.confirmed.set(entry.key(row), row);\n }\n if (frame.version !== undefined) {\n entry.appliedVersion = frame.version;\n }\n if (frame.cursor !== undefined) {\n entry.cursor = frame.cursor;\n }\n persistEntries([entry]);\n recompute(entry, { status: \"ready\", error: undefined });\n updateStatus({ lastSuccessfulPullAt: Date.now() });\n } else if (frame.type === \"diff\") {\n const entry = entries.get(frame.id);\n if (entry === undefined) {\n return;\n }\n applyDiffToConfirmed(entry, frame);\n if (frame.version !== undefined) {\n entry.appliedVersion = Math.max(entry.appliedVersion, frame.version);\n }\n if (frame.cursor !== undefined) {\n entry.cursor = frame.cursor;\n }\n persistEntries([entry]);\n recompute(entry);\n updateStatus({ lastSuccessfulPullAt: Date.now() });\n } else if (frame.type === \"frame\") {\n const affected = new Set;\n for (const diff of frame.diffs) {\n const entry = entries.get(diff.id);\n if (entry === undefined) {\n continue;\n }\n applyDiffToConfirmed(entry, diff);\n if (frame.version !== undefined) {\n entry.appliedVersion = Math.max(entry.appliedVersion, frame.version);\n }\n if (frame.cursor !== undefined) {\n entry.cursor = frame.cursor;\n }\n rebuild(entry);\n affected.add(entry);\n }\n persistEntries(affected);\n for (const entry of affected) {\n notify(entry);\n }\n updateStatus({ lastSuccessfulPullAt: Date.now() });\n } else if (frame.type === \"error\") {\n if (frame.id !== undefined) {\n const entry = entries.get(frame.id);\n if (entry !== undefined) {\n recompute(entry, { error: frame.message });\n }\n }\n options.onError?.(frame.message);\n updateStatus({ lastError: String(frame.message) });\n } else if (frame.type === \"ack\") {\n updateStatus({ lastSuccessfulPushAt: Date.now() });\n finishDurablePending(frame.mutationId, frame.operationId, frame.result);\n } else if (frame.type === \"reject\") {\n const mutation = mutationOwner.get(frame.mutationId);\n if (mutation?.operationId !== undefined && frame.operationId !== mutation.operationId) {\n reportStorageError(new Error(`Durable mutation rejection identity mismatch for ${mutation.operationId}`));\n return;\n }\n const rejection = frame.rejection ?? {\n kind: \"permanent\",\n message: String(frame.message)\n };\n if (rejection.kind === \"conflict\" && mutation !== undefined && resolveConflictedPending(mutation, rejection)) {\n return;\n }\n if (rejection.kind === \"retryable\" && mutation !== undefined) {\n retryRejectedPending(mutation, rejection);\n } else {\n deadLetterPending(frame.mutationId, rejection);\n }\n }\n };\n const wsSend = (payload) => {\n socket?.send(payload);\n };\n const sendSubscribe = (entry) => {\n const since = entry.cursor ?? (entry.appliedVersion > 0 ? entry.appliedVersion : undefined);\n wsSend(serializer.encodeClient({\n type: \"subscribe\",\n id: entry.id,\n collection: entry.collection,\n params: entry.params,\n since\n }));\n };\n sendMutate = (mutation) => {\n if (mutation.nextAttemptAt !== undefined) {\n const delay = mutation.nextAttemptAt - Date.now();\n if (delay > 0 && mutation.operationId !== undefined) {\n if (!retryTimers.has(mutation.operationId)) {\n const timer = setTimeout(() => {\n retryTimers.delete(mutation.operationId);\n mutation.nextAttemptAt = undefined;\n sendMutate(mutation);\n }, delay);\n retryTimers.set(mutation.operationId, timer);\n }\n return;\n }\n mutation.nextAttemptAt = undefined;\n }\n if (!connected)\n return;\n const payload = serializer.encodeClient({\n type: \"mutate\",\n mutationId: mutation.mutationId,\n operationId: mutation.operationId,\n name: mutation.name,\n args: mutation.args\n });\n if (durable === undefined || mutation.operationId === undefined) {\n wsSend(payload);\n return;\n }\n if (mutation.sending)\n return;\n mutation.sending = true;\n mutation.attempts += 1;\n const targetSocket = socket;\n queueLocalWrite(() => durable.store.transaction(durable.namespace, \"readwrite\", async (tx) => {\n const record = await tx.getMutation(mutation.operationId);\n if (record !== undefined) {\n await tx.putMutation({\n ...record,\n attempts: mutation.attempts,\n state: \"pending\",\n nextAttemptAt: undefined\n });\n }\n })).catch(() => {}).finally(() => {\n mutation.sending = false;\n if (connected && socket === targetSocket && pending.includes(mutation)) {\n targetSocket?.send(payload);\n }\n });\n };\n const initializeDurable = async () => {\n if (durable === undefined)\n return;\n installationId = await ensureSyncInstallationId(durable.store, durable.namespace, durable.createId);\n const records = await durable.store.transaction(durable.namespace, \"readonly\", (tx) => tx.listMutations());\n for (const record of records) {\n if (record.state === \"dead-letter\") {\n deadLetters.set(record.operationId, record);\n continue;\n }\n mutationSeq += 1;\n const mutation = {\n mutationId: mutationSeq,\n operationId: record.operationId,\n ownerKey: record.owner ?? record.optimistic[0]?.collection ?? \"\",\n name: record.name,\n args: record.args,\n optimisticOperations: record.optimistic,\n inverse: record.inverse,\n attempts: record.attempts,\n createdAt: record.createdAt,\n conflictAttempts: record.conflictAttempts,\n conflictPolicy: record.conflictPolicy,\n nextAttemptAt: record.nextAttemptAt,\n supersedesOperationId: record.supersedesOperationId\n };\n pending.push(mutation);\n mutationOwner.set(mutation.mutationId, mutation);\n }\n updateStatus();\n };\n const durableReady = durable === undefined ? Promise.resolve() : initializeDurable().catch((error) => {\n reportStorageError(error);\n throw error;\n });\n const hydrateEntry = async (entry) => {\n if (durable === undefined)\n return;\n await durableReady;\n const record = await durable.store.transaction(durable.namespace, \"readonly\", (tx) => tx.getCollection(entry.localKey));\n if (entry.closed || record === undefined) {\n if (!entry.closed)\n recompute(entry);\n return;\n }\n entry.confirmed.clear();\n for (const row of record.rows) {\n entry.confirmed.set(entry.key(row), row);\n }\n entry.appliedVersion = record.version;\n entry.cursor = record.cursor;\n recompute(entry);\n };\n const connect2 = () => {\n if (closed) {\n return;\n }\n reconnectTimer = undefined;\n updateStatus({ connection: \"connecting\" });\n const ws = new Impl(socketTicket ? ticketAuthenticatedSocketUrl(options.url) : options.url);\n socket = ws;\n const sendInitialFrames = () => {\n if (socket !== ws || closed)\n return;\n if (socketTicket) {\n socketTicket().then((ticket) => {\n if (socket !== ws || closed)\n return;\n wsSend(serializer.encodeClient({\n type: \"authenticate\",\n ticket\n }));\n connected = true;\n for (const entry of entries.values())\n sendSubscribe(entry);\n for (const mutation of pending)\n sendMutate(mutation);\n }).catch((error) => {\n options.onError?.(error);\n updateStatus({ lastError: String(error) });\n ws.close();\n });\n return;\n }\n connected = true;\n for (const entry of entries.values()) {\n sendSubscribe(entry);\n }\n for (const mutation of pending)\n sendMutate(mutation);\n };\n ws.onopen = () => {\n if (durable === undefined) {\n sendInitialFrames();\n return;\n }\n Promise.all([...entries.values()].map((entry) => entry.hydrated)).then(sendInitialFrames).catch((error) => {\n reportStorageError(error);\n ws.close();\n });\n };\n ws.onmessage = (event) => {\n try {\n const decoded = serializer.decode(event.data);\n if (decoded !== null && typeof decoded === \"object\") {\n applyFrame(decoded);\n if (hasReconnectHealthyFrameType(decoded, serverFrameTypes2)) {\n reconnectBackoff.markHealthy();\n }\n }\n } catch {}\n };\n ws.onclose = () => {\n if (socket === ws)\n socket = undefined;\n connected = false;\n if (closed) {\n return;\n }\n updateStatus({ connection: \"offline\" });\n if (immediateReconnect) {\n immediateReconnect = false;\n connect2();\n return;\n }\n if (reconnectMs <= 0)\n return;\n const delay = reconnectBackoff.nextDelay();\n reconnectTimer = setTimeout(connect2, delay);\n };\n };\n if (durable === undefined)\n connect2();\n else\n durableReady.then(connect2).catch(() => {});\n const normalizeOptimisticOperations = (ownerKey, operations) => (operations ?? []).map((operation) => operation.type === \"delete\" ? {\n type: \"delete\",\n collection: operation.collection ?? ownerKey,\n key: operation.key\n } : {\n type: operation.type,\n collection: operation.collection ?? ownerKey,\n row: operation.row\n });\n const captureInverse = (operations) => {\n const working = new Map;\n const entryFor = (localKey) => {\n const entry = [...entries.values()].find((item) => item.localKey === localKey);\n if (entry === undefined) {\n throw new Error(`Durable optimistic operation targets unopened collection \"${localKey}\"`);\n }\n let rows = working.get(localKey);\n if (rows === undefined) {\n rows = new Map(entry.state.data.map((row) => [entry.key(row), row]));\n working.set(localKey, rows);\n }\n return { entry, rows };\n };\n const inverse = [];\n for (const operation of operations) {\n const { entry, rows } = entryFor(operation.collection);\n if (operation.type === \"delete\") {\n const existing2 = rows.get(operation.key);\n if (existing2 !== undefined) {\n inverse.unshift({\n type: \"insert\",\n collection: operation.collection,\n row: existing2\n });\n }\n rows.delete(operation.key);\n continue;\n }\n const rowKey = entry.key(operation.row);\n const existing = rows.get(rowKey);\n inverse.unshift(existing === undefined ? {\n type: \"delete\",\n collection: operation.collection,\n key: rowKey\n } : {\n type: \"update\",\n collection: operation.collection,\n row: existing\n });\n rows.set(rowKey, operation.row);\n }\n return inverse;\n };\n const collection = (handleOptions) => {\n const entryId = `c${nextEntryId}`;\n nextEntryId += 1;\n const localKey = handleOptions.localKey ?? defaultLocalKey(handleOptions.collection, handleOptions.params);\n if (localKey.length === 0) {\n throw new Error(\"Sync collection localKey must not be empty\");\n }\n const entry = {\n id: entryId,\n localKey,\n collection: handleOptions.collection,\n params: handleOptions.params,\n key: handleOptions.key ?? ((row) => row.id),\n headlessKey: handleOptions.key === undefined ? \"id\" : undefined,\n confirmed: new Map,\n state: { data: [], status: \"connecting\", error: undefined },\n listeners: new Set,\n appliedVersion: 0,\n cursor: undefined,\n closed: false,\n hydrated: Promise.resolve()\n };\n entries.set(entryId, entry);\n entry.hydrated = hydrateEntry(entry);\n if (connected)\n entry.hydrated.then(() => sendSubscribe(entry)).catch(reportStorageError);\n return {\n get: () => entry.state,\n subscribe: (listener) => {\n const typed = listener;\n entry.listeners.add(typed);\n listener(entry.state);\n return () => {\n entry.listeners.delete(typed);\n };\n },\n mutate: (mutateOptions) => new Promise((resolve, reject) => {\n const addPending = (operationId, optimisticOperations, inverse, createdAt = Date.now(), conflictPolicy) => {\n mutationSeq += 1;\n const mutation = {\n mutationId: mutationSeq,\n operationId,\n ownerKey: entry.localKey,\n name: mutateOptions.name,\n args: mutateOptions.args,\n optimistic: mutateOptions.optimistic,\n optimisticOperations,\n inverse,\n attempts: 0,\n createdAt,\n conflictPolicy,\n resolve: (result) => resolve(result),\n reject\n };\n pending.push(mutation);\n mutationOwner.set(mutation.mutationId, mutation);\n updateStatus();\n recomputeMutationEntries(mutation);\n sendMutate(mutation);\n };\n if (durable === undefined) {\n const optimisticOperations = normalizeOptimisticOperations(entry.localKey, mutateOptions.optimisticOperations);\n const inverse = captureInverse(optimisticOperations);\n addPending(undefined, optimisticOperations, inverse);\n return;\n }\n (async () => {\n await entry.hydrated;\n const optimisticOperations = normalizeOptimisticOperations(entry.localKey, mutateOptions.optimisticOperations);\n const inverse = captureInverse(optimisticOperations);\n await durableReady;\n const operationId = createSyncOperationId(installationId, durable.createId);\n const createdAt = Date.now();\n const stored = await queueLocalWrite(() => durable.store.transaction(durable.namespace, \"readwrite\", async (tx) => {\n const conflictPolicy = tx.resolveMutationPolicy?.(mutateOptions.name)?.conflict;\n const record = {\n operationId,\n owner: entry.localKey,\n name: mutateOptions.name,\n args: mutateOptions.args,\n optimistic: optimisticOperations,\n inverse,\n createdAt,\n attempts: 0,\n state: \"pending\",\n ...conflictPolicy ? { conflictPolicy } : {}\n };\n await tx.putMutation(record);\n return record;\n }));\n addPending(operationId, optimisticOperations, inverse, createdAt, stored.conflictPolicy);\n })().catch(reject);\n }),\n close: () => {\n if (entry.closed) {\n return;\n }\n entry.closed = true;\n entries.delete(entryId);\n if (connected) {\n wsSend(serializer.encodeClient({\n type: \"unsubscribe\",\n id: entryId\n }));\n }\n }\n };\n };\n const listDeadLetters = async () => {\n if (durable === undefined)\n return [];\n await durableReady;\n return [...deadLetters.values()].sort((a, b) => a.createdAt - b.createdAt).map((record) => structuredClone(record));\n };\n const retryDeadLetter = async (operationId) => {\n if (durable === undefined) {\n throw new Error(\"Dead-letter retry requires a durable Sync client\");\n }\n await durableReady;\n if (closed)\n throw new Error(\"Cannot retry a dead letter on a closed client\");\n const record = await queueLocalWrite(() => durable.store.transaction(durable.namespace, \"readwrite\", async (tx) => {\n const current = await tx.getMutation(operationId);\n if (current?.state !== \"dead-letter\") {\n throw new Error(`Unknown Sync dead letter \"${operationId}\"`);\n }\n const next = {\n ...current,\n attempts: 0,\n state: \"pending\"\n };\n delete next.deadLetteredAt;\n delete next.lastError;\n delete next.nextAttemptAt;\n delete next.rejection;\n await tx.putMutation(next);\n return next;\n }));\n deadLetters.delete(operationId);\n mutationSeq += 1;\n const mutation = {\n args: record.args,\n attempts: 0,\n createdAt: record.createdAt,\n conflictAttempts: record.conflictAttempts,\n conflictPolicy: record.conflictPolicy,\n inverse: record.inverse,\n mutationId: mutationSeq,\n name: record.name,\n operationId: record.operationId,\n optimisticOperations: record.optimistic,\n ownerKey: record.owner ?? record.optimistic[0]?.collection ?? \"\"\n };\n pending.push(mutation);\n mutationOwner.set(mutation.mutationId, mutation);\n recomputeMutationEntries(mutation);\n updateStatus();\n sendMutate(mutation);\n };\n const rebaseDeadLetter = async (operationId, args) => {\n if (durable === undefined)\n throw new Error(\"Dead-letter rebase requires a durable Sync client\");\n await durableReady;\n if (closed)\n throw new Error(\"Cannot rebase a dead letter on a closed client\");\n const nextOperationId = createSyncOperationId(installationId, durable.createId);\n const record = await queueLocalWrite(() => durable.store.transaction(durable.namespace, \"readwrite\", async (tx) => {\n const current = await tx.getMutation(operationId);\n if (current?.state !== \"dead-letter\")\n throw new Error(`Unknown Sync dead letter \"${operationId}\"`);\n const next = {\n ...current,\n args,\n attempts: 0,\n conflictAttempts: 0,\n createdAt: Date.now(),\n operationId: nextOperationId,\n state: \"pending\",\n supersedesOperationId: operationId\n };\n delete next.deadLetteredAt;\n delete next.lastError;\n delete next.nextAttemptAt;\n delete next.rejection;\n await tx.deleteMutation(operationId);\n await tx.putMutation(next);\n return next;\n }));\n deadLetters.delete(operationId);\n mutationSeq += 1;\n const mutation = {\n args: record.args,\n attempts: 0,\n conflictAttempts: 0,\n conflictPolicy: record.conflictPolicy,\n createdAt: record.createdAt,\n inverse: record.inverse,\n mutationId: mutationSeq,\n name: record.name,\n operationId: record.operationId,\n optimisticOperations: record.optimistic,\n ownerKey: record.owner ?? record.optimistic[0]?.collection ?? \"\",\n supersedesOperationId: operationId\n };\n pending.push(mutation);\n mutationOwner.set(mutation.mutationId, mutation);\n recomputeMutationEntries(mutation);\n updateStatus();\n sendMutate(mutation);\n return nextOperationId;\n };\n const discardDeadLetter = async (operationId) => {\n if (durable === undefined) {\n throw new Error(\"Dead-letter discard requires a durable Sync client\");\n }\n await durableReady;\n if (!deadLetters.has(operationId)) {\n throw new Error(`Unknown Sync dead letter \"${operationId}\"`);\n }\n await queueLocalWrite(() => durable.store.transaction(durable.namespace, \"readwrite\", (tx) => tx.deleteMutation(operationId)));\n deadLetters.delete(operationId);\n updateStatus();\n };\n const subscribeStatus = (listener) => {\n statusListeners.add(listener);\n listener(snapshotStatus());\n return () => {\n statusListeners.delete(listener);\n };\n };\n const flush = async ({ timeoutMs = 1e4 } = {}) => {\n if (!Number.isFinite(timeoutMs) || timeoutMs < 0) {\n throw new TypeError(\"Sync flush timeoutMs must be a non-negative number\");\n }\n await durableReady;\n if (pending.length === 0) {\n return {\n deadLetters: deadLetters.size,\n pending: 0,\n timedOut: false\n };\n }\n if (!connected)\n reconnect();\n const timedOut = await new Promise((resolve) => {\n let settled = false;\n let remove = () => {\n return;\n };\n const timer = setTimeout(() => {\n if (settled)\n return;\n settled = true;\n remove();\n resolve(true);\n }, timeoutMs);\n remove = subscribeStatus((current) => {\n if (settled || current.pending > 0)\n return;\n settled = true;\n clearTimeout(timer);\n remove();\n resolve(false);\n });\n });\n return {\n deadLetters: deadLetters.size,\n pending: pending.length,\n timedOut\n };\n };\n let removeRuntimeClient;\n let removeInspectionClient;\n const close = () => {\n if (closed)\n return;\n closed = true;\n if (reconnectTimer !== undefined) {\n clearTimeout(reconnectTimer);\n }\n socket?.close();\n for (const timer of retryTimers.values())\n clearTimeout(timer);\n retryTimers.clear();\n entries.clear();\n mutationOwner.clear();\n pending.length = 0;\n updateStatus({ connection: \"closed\" });\n statusListeners.clear();\n removeRuntimeClient?.();\n removeRuntimeClient = undefined;\n removeInspectionClient?.();\n removeInspectionClient = undefined;\n };\n const disconnect = () => {\n if (closed || socket === undefined) {\n return;\n }\n socket.close();\n };\n const reconnect = () => {\n if (closed)\n return;\n if (reconnectTimer !== undefined) {\n clearTimeout(reconnectTimer);\n reconnectTimer = undefined;\n }\n const current = socket;\n if (current && current.readyState !== current.CLOSED) {\n immediateReconnect = true;\n current.close();\n return;\n }\n socket = undefined;\n connect2();\n };\n const client = {\n close,\n collection,\n discardDeadLetter,\n disconnect,\n flush,\n listDeadLetters,\n rebaseDeadLetter,\n reconnect,\n retryDeadLetter,\n status: snapshotStatus,\n subscribeStatus\n };\n removeRuntimeClient = runtime?.registerClient?.(client) ?? undefined;\n removeInspectionClient = registerSyncRuntimeClient(client);\n return client;\n};\n// src/client/syncStore.ts\nvar serverFrameTypes3 = [\"snapshot\", \"diff\", \"error\"];\nvar SUBSCRIPTION_ID2 = \"s\";\nvar syncStore = (options) => {\n const key = options.key ?? ((row) => row.id);\n const reconnectMs = options.reconnectMs ?? 500;\n const maxReconnectMs = options.maxReconnectMs ?? 1e4;\n const reconcileGraceMs = options.reconcileGraceMs ?? 3000;\n const mutations = options.mutations ?? {};\n const serializer = options.serializer ?? jsonSerializer;\n const Impl = options.webSocketImpl ?? globalThis.WebSocket;\n if (!Impl) {\n throw new Error(\"syncStore requires WebSocket. Run in a browser or pass webSocketImpl.\");\n }\n const confirmed = new Map;\n const pending = [];\n let mutationSeq = 0;\n let state = {\n data: options.initialData ? [...options.initialData] : [],\n status: \"connecting\",\n error: undefined\n };\n if (options.initialData) {\n for (const row of options.initialData) {\n confirmed.set(key(row), row);\n }\n }\n const listeners = new Set;\n const setState = (patch) => {\n state = { ...state, ...patch };\n for (const listener of listeners) {\n listener(state);\n }\n };\n const recompute = (patch = {}) => {\n const working = new Map(confirmed);\n const draft = {\n set: (row) => working.set(key(row), row),\n delete: (rowKey) => working.delete(rowKey)\n };\n for (const mutation of pending) {\n mutation.optimistic?.(draft);\n }\n setState({ ...patch, data: [...working.values()] });\n };\n const persist = () => {\n options.storage?.save(pending.map((mutation) => ({\n mutationId: mutation.id,\n name: mutation.name,\n args: mutation.args\n })));\n };\n const dropPending = (mutation) => {\n const index = pending.indexOf(mutation);\n if (index !== -1) {\n pending.splice(index, 1);\n }\n if (mutation.graceTimer !== undefined) {\n clearTimeout(mutation.graceTimer);\n }\n };\n const reconcileSettled = () => {\n let changed = false;\n for (const mutation of [...pending]) {\n if (!mutation.settled) {\n continue;\n }\n let reflected = true;\n for (const [rowKey, kind] of mutation.touched) {\n const present = confirmed.has(rowKey);\n if (kind === \"set\" ? !present : present) {\n reflected = false;\n break;\n }\n }\n if (reflected) {\n dropPending(mutation);\n changed = true;\n }\n }\n if (changed) {\n recompute();\n }\n };\n let socket;\n let connected = false;\n let closed = false;\n const reconnectBackoff = createReconnectBackoff(reconnectMs, maxReconnectMs);\n let reconnectTimer;\n let appliedVersion = 0;\n let appliedCursor;\n const applyFrame = (frame) => {\n if (frame.type === \"snapshot\") {\n confirmed.clear();\n for (const row of frame.rows) {\n confirmed.set(key(row), row);\n }\n if (frame.version !== undefined) {\n appliedVersion = frame.version;\n }\n if (frame.cursor !== undefined) {\n appliedCursor = frame.cursor;\n }\n recompute({ status: \"ready\", error: undefined });\n reconcileSettled();\n } else if (frame.type === \"diff\") {\n for (const row of frame.removed) {\n confirmed.delete(key(row));\n }\n for (const row of frame.added) {\n confirmed.set(key(row), row);\n }\n for (const row of frame.changed) {\n confirmed.set(key(row), row);\n }\n if (frame.version !== undefined) {\n appliedVersion = Math.max(appliedVersion, frame.version);\n }\n if (frame.cursor !== undefined) {\n appliedCursor = frame.cursor;\n }\n recompute();\n reconcileSettled();\n } else if (frame.type === \"error\") {\n setState({ error: frame.message });\n options.onError?.(frame.message);\n }\n };\n const runMutation = async (mutation) => {\n if (mutation.inFlight || mutation.settled) {\n return;\n }\n const run = mutations[mutation.name];\n if (run === undefined) {\n dropPending(mutation);\n recompute();\n mutation.reject(new Error(`Unknown mutation \"${mutation.name}\"`));\n return;\n }\n mutation.inFlight = true;\n try {\n const result = await run(mutation.args);\n mutation.inFlight = false;\n mutation.settled = true;\n mutation.resolve(result);\n persist();\n reconcileSettled();\n if (pending.includes(mutation)) {\n mutation.graceTimer = setTimeout(() => {\n dropPending(mutation);\n recompute();\n }, reconcileGraceMs);\n }\n } catch (error) {\n mutation.inFlight = false;\n if (connected) {\n dropPending(mutation);\n recompute();\n persist();\n mutation.reject(error);\n } else {\n options.onError?.(error);\n }\n }\n };\n const connect2 = () => {\n if (closed) {\n return;\n }\n setState({ status: \"connecting\" });\n const ws = new Impl(options.url);\n socket = ws;\n ws.onopen = () => {\n connected = true;\n ws.send(serializer.encodeClient({\n type: \"subscribe\",\n id: SUBSCRIPTION_ID2,\n collection: options.collection,\n params: options.params,\n since: appliedCursor ?? (appliedVersion > 0 ? appliedVersion : undefined)\n }));\n for (const mutation of pending) {\n if (!mutation.settled && !mutation.inFlight) {\n runMutation(mutation);\n }\n }\n };\n ws.onmessage = (event) => {\n try {\n const decoded = serializer.decode(event.data);\n if (decoded !== null && typeof decoded === \"object\") {\n applyFrame(decoded);\n if (hasReconnectHealthyFrameType(decoded, serverFrameTypes3)) {\n reconnectBackoff.markHealthy();\n }\n }\n } catch {}\n };\n ws.onclose = () => {\n connected = false;\n if (closed || reconnectMs <= 0) {\n return;\n }\n const delay = reconnectBackoff.nextDelay();\n reconnectTimer = setTimeout(connect2, delay);\n };\n };\n const eagerHydrate = async () => {\n if (options.hydrate === undefined || options.initialData !== undefined) {\n return;\n }\n try {\n const rows = await options.hydrate();\n if (state.status !== \"ready\") {\n confirmed.clear();\n for (const row of rows) {\n confirmed.set(key(row), row);\n }\n recompute({ status: \"ready\" });\n }\n } catch (error) {\n options.onError?.(error);\n }\n };\n const hydratePersisted = async () => {\n if (options.storage === undefined) {\n return;\n }\n const records = await options.storage.load();\n for (const record of records) {\n if (pending.some((m) => m.id === record.mutationId)) {\n continue;\n }\n pending.push({\n id: record.mutationId,\n name: record.name,\n args: record.args,\n touched: new Map,\n settled: false,\n inFlight: false,\n resolve: () => {},\n reject: () => {}\n });\n mutationSeq = Math.max(mutationSeq, record.mutationId);\n }\n if (connected) {\n for (const mutation of pending) {\n runMutation(mutation);\n }\n }\n };\n connect2();\n eagerHydrate();\n hydratePersisted();\n const collectTouched = (optimistic) => {\n const touched = new Map;\n optimistic?.({\n set: (row) => touched.set(key(row), \"set\"),\n delete: (rowKey) => touched.set(rowKey, \"delete\")\n });\n return touched;\n };\n return {\n get: () => state,\n subscribe: (listener) => {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n mutate: (name, args, mutateOptions) => new Promise((resolve, reject) => {\n const mutation = {\n id: mutationSeq += 1,\n name,\n args,\n touched: collectTouched(mutateOptions?.optimistic),\n optimistic: mutateOptions?.optimistic,\n settled: false,\n inFlight: false,\n resolve,\n reject\n };\n pending.push(mutation);\n persist();\n recompute();\n runMutation(mutation);\n }),\n refetch: async () => {\n if (options.hydrate === undefined) {\n return;\n }\n const rows = await options.hydrate();\n confirmed.clear();\n for (const row of rows) {\n confirmed.set(key(row), row);\n }\n recompute({ status: \"ready\" });\n },\n close: () => {\n if (closed) {\n return;\n }\n closed = true;\n connected = false;\n if (reconnectTimer !== undefined) {\n clearTimeout(reconnectTimer);\n }\n try {\n socket?.send(serializer.encodeClient({\n type: \"unsubscribe\",\n id: SUBSCRIPTION_ID2\n }));\n socket?.close();\n } catch {}\n for (const mutation of pending.splice(0)) {\n if (mutation.graceTimer !== undefined) {\n clearTimeout(mutation.graceTimer);\n }\n mutation.reject(new Error(\"sync store closed\"));\n }\n persist();\n setState({ status: \"closed\" });\n listeners.clear();\n }\n };\n};\nvar unwrapEden = async (response) => {\n const { data, error } = await response;\n if (error !== null && error !== undefined) {\n throw error;\n }\n return data;\n};\nexport {\n SyncLocalDataPolicyError,\n SyncLocalStoreSchemaError,\n SyncMutationRejectedError,\n createCollaborativeText,\n createIndexedDbSyncLocalStore,\n createLiveQuery,\n createMemorySyncLocalStore,\n createPresence,\n createSharedSyncSubscriber,\n createSyncClient,\n createSyncCollection,\n createSyncLocalSchemaStatus,\n createSyncOperationId,\n createSyncSubscriber,\n discardSyncRuntimeDeadLetter,\n ensureSyncInstallationId,\n getSyncClientRuntimeTransport,\n indexedDbCollectionCache,\n inspectSyncRuntime,\n installSyncClientRuntimeTransport,\n jsonFetcher,\n localStorageCollectionCache,\n localStorageMutationStorage,\n migrateSyncLocalCollectionRecord,\n migrateSyncLocalMutationRecord,\n normalizeSyncLocalSchemaComponents,\n rebaseSyncRuntimeDeadLetter,\n registerSyncRuntimeClient,\n resolveSyncLocalCollectionPolicy,\n resolveSyncLocalDataPolicy,\n resolveSyncLocalMigrations,\n resolveSyncLocalMutationPolicy,\n resolveSyncLocalSchemaComponents,\n retrySyncRuntimeDeadLetter,\n runHeadlessSync,\n runSyncLocalPolicyTransaction,\n syncStore,\n unwrapEden,\n validateSyncLocalDataPolicy\n};\n\n//# debugId=117FAC16CDE3C9F364756E2164756E21\n//# sourceMappingURL=index.js.map\n",
|
|
12
|
+
"import { readFileSync } from 'node:fs';\nimport { dirname, join, resolve } from 'node:path';\nimport {\n\tresolveSyncLocalSchemaComponents,\n\ttype SyncLocalCollectionMigrationOperation,\n\ttype SyncLocalCollectionPolicy,\n\ttype SyncLocalConflictPolicy,\n\ttype SyncLocalDataPolicy,\n\ttype SyncLocalJsonValue,\n\ttype SyncLocalMutationPolicy,\n\ttype SyncLocalStoreMigration,\n\ttype SyncLocalStoreSchemaBundle,\n\ttype SyncLocalStoreSchemaComponent\n} from '@absolutejs/sync/client';\n\nexport type AbsoluteSyncSchemaDiscovery = {\n\tcomponents: SyncLocalStoreSchemaBundle['components'];\n\tsources: { id: string; manifestPath: string }[];\n};\n\n// A predicate annotation is required so parsed package JSON remains `unknown`\n// until every object boundary has been checked.\nconst object = (value: unknown): value is Record<string, unknown> =>\n\ttypeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst manifestAt = (path: string) => {\n\ttry {\n\t\tconst value: unknown = JSON.parse(readFileSync(path, 'utf8'));\n\n\t\treturn object(value) ? value : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n};\n\nconst localSchemaMetadata = (manifest: object) => {\n\tconst absolutejs = Reflect.get(manifest, 'absolutejs');\n\tif (!object(absolutejs)) return undefined;\n\tconst sync = Reflect.get(absolutejs, 'sync');\n\tif (!object(sync)) return undefined;\n\n\treturn Reflect.get(sync, 'localSchema');\n};\n\nconst packageManifestPath = (projectRoot: string, packageName: string) => {\n\tlet directory = resolve(projectRoot);\n\twhile (true) {\n\t\tconst candidate = join(\n\t\t\tdirectory,\n\t\t\t'node_modules',\n\t\t\tpackageName,\n\t\t\t'package.json'\n\t\t);\n\t\tconst manifest = manifestAt(candidate);\n\t\tif (manifest && Reflect.get(manifest, 'name') === packageName)\n\t\t\treturn candidate;\n\t\tconst parent = dirname(directory);\n\t\tif (parent === directory) return undefined;\n\t\tdirectory = parent;\n\t}\n};\n\nconst metadataError = (id: string, detail: string) =>\n\tnew TypeError(\n\t\t`Invalid AbsoluteJS Sync schema metadata for ${id}: ${detail}`\n\t);\n\nconst positiveVersion = (value: unknown, id: string, field: string) => {\n\tif (typeof value !== 'number' || !Number.isSafeInteger(value) || value < 1)\n\t\tthrow metadataError(id, `${field} must be a positive safe integer.`);\n\n\treturn value;\n};\n\nconst nonEmpty = (value: unknown, id: string, field: string) => {\n\tif (\n\t\ttypeof value !== 'string' ||\n\t\tvalue.trim() !== value ||\n\t\tvalue.length === 0\n\t)\n\t\tthrow metadataError(id, `${field} must be a non-empty trimmed string.`);\n\n\treturn value;\n};\n\nconst requireObject = (value: unknown, id: string, detail: string) => {\n\tif (!object(value)) throw metadataError(id, detail);\n\n\treturn value;\n};\n\nconst unknownField = (record: Record<string, unknown>, key: string) =>\n\trecord[key];\n\nconst normalizeJsonValue: (\n\tvalue: unknown,\n\tid: string,\n\tfield: string\n) => SyncLocalJsonValue = (value, id, field) => {\n\tif (\n\t\tvalue === null ||\n\t\ttypeof value === 'string' ||\n\t\ttypeof value === 'boolean'\n\t)\n\t\treturn value;\n\tif (typeof value === 'number' && Number.isFinite(value)) return value;\n\tif (Array.isArray(value))\n\t\treturn value.map((entry) => normalizeJsonValue(entry, id, field));\n\tif (object(value))\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries(value).map(([key, entry]) => [\n\t\t\t\tkey,\n\t\t\t\tnormalizeJsonValue(entry, id, field)\n\t\t\t])\n\t\t);\n\n\tthrow metadataError(id, `${field} must be JSON-safe.`);\n};\n\nconst operation: (\n\tvalue: unknown,\n\tid: string,\n\tindex: number\n) => SyncLocalCollectionMigrationOperation = (value, id, index) => {\n\tconst record = requireObject(\n\t\tvalue,\n\t\tid,\n\t\t`migration operation ${index} must be an object.`\n\t);\n\tconst type = Reflect.get(record, 'type');\n\tconst collection = nonEmpty(\n\t\tReflect.get(record, 'collection'),\n\t\tid,\n\t\t`operation ${index}.collection`\n\t);\n\tif (type === 'delete-collection') return { collection, type };\n\tif (type === 'rename-field')\n\t\treturn {\n\t\t\tcollection,\n\t\t\tfrom: nonEmpty(\n\t\t\t\tReflect.get(record, 'from'),\n\t\t\t\tid,\n\t\t\t\t`operation ${index}.from`\n\t\t\t),\n\t\t\tto: nonEmpty(\n\t\t\t\tReflect.get(record, 'to'),\n\t\t\t\tid,\n\t\t\t\t`operation ${index}.to`\n\t\t\t),\n\t\t\ttype\n\t\t};\n\tconst field = nonEmpty(\n\t\tReflect.get(record, 'field'),\n\t\tid,\n\t\t`operation ${index}.field`\n\t);\n\tif (type === 'remove-field') return { collection, field, type };\n\tif (type === 'set-default')\n\t\treturn {\n\t\t\tcollection,\n\t\t\tfield,\n\t\t\ttype,\n\t\t\tvalue: normalizeJsonValue(\n\t\t\t\tReflect.get(record, 'value'),\n\t\t\t\tid,\n\t\t\t\t`operation ${index}.value`\n\t\t\t)\n\t\t};\n\n\tthrow metadataError(id, `operation ${index}.type is not supported.`);\n};\n\nconst migration: (\n\tvalue: unknown,\n\tid: string,\n\tindex: number\n) => SyncLocalStoreMigration = (value, id, index) => {\n\tconst record = requireObject(\n\t\tvalue,\n\t\tid,\n\t\t`migration ${index} must be an object.`\n\t);\n\tconst allowed = new Set(['operations', 'toVersion']);\n\tconst unsupported = Object.keys(record).find((key) => !allowed.has(key));\n\tif (unsupported)\n\t\tthrow metadataError(\n\t\t\tid,\n\t\t\t`migration ${index}.${unsupported} is not declarative metadata.`\n\t\t);\n\tconst declaredOperations = Reflect.get(record, 'operations');\n\tif (declaredOperations !== undefined && !Array.isArray(declaredOperations))\n\t\tthrow metadataError(\n\t\t\tid,\n\t\t\t`migration ${index}.operations must be an array.`\n\t\t);\n\tconst operations = Array.isArray(declaredOperations)\n\t\t? declaredOperations\n\t\t: [];\n\n\treturn {\n\t\toperations: operations.map((entry, operationIndex) =>\n\t\t\toperation(entry, id, operationIndex)\n\t\t),\n\t\ttoVersion: positiveVersion(\n\t\t\tReflect.get(record, 'toVersion'),\n\t\t\tid,\n\t\t\t`migration ${index}.toVersion`\n\t\t)\n\t};\n};\n\nconst localDataPolicy = (value: unknown, id: string): SyncLocalDataPolicy => {\n\tconst record = requireObject(value, id, 'localData must be an object.');\n\tconst allowed = new Set([\n\t\t'collections',\n\t\t'maxBytesPerNamespace',\n\t\t'mutations'\n\t]);\n\tconst unsupported = Object.keys(record).find((key) => !allowed.has(key));\n\tif (unsupported)\n\t\tthrow metadataError(id, `localData.${unsupported} is not supported.`);\n\tconst collectionRules = Reflect.get(record, 'collections');\n\tconst mutationRules = Reflect.get(record, 'mutations');\n\tif (collectionRules !== undefined && !Array.isArray(collectionRules))\n\t\tthrow metadataError(id, 'localData.collections must be an array.');\n\tif (mutationRules !== undefined && !Array.isArray(mutationRules))\n\t\tthrow metadataError(id, 'localData.mutations must be an array.');\n\tconst collections: SyncLocalCollectionPolicy[] | undefined = Array.isArray(\n\t\tcollectionRules\n\t)\n\t\t? collectionRules.map((entry, index) => {\n\t\t\t\tconst rule = requireObject(\n\t\t\t\t\tentry,\n\t\t\t\t\tid,\n\t\t\t\t\t`localData.collections[${index}] must be an object.`\n\t\t\t\t);\n\t\t\t\tconst allowedRuleKeys = new Set([\n\t\t\t\t\t'evictionPriority',\n\t\t\t\t\t'match',\n\t\t\t\t\t'maxAgeMs',\n\t\t\t\t\t'onProtectionUnavailable',\n\t\t\t\t\t'persistence',\n\t\t\t\t\t'protection',\n\t\t\t\t\t'sensitivity'\n\t\t\t\t]);\n\t\t\t\tconst unsupportedRuleKey = Object.keys(rule).find(\n\t\t\t\t\t(key) => !allowedRuleKeys.has(key)\n\t\t\t\t);\n\t\t\t\tif (unsupportedRuleKey)\n\t\t\t\t\tthrow metadataError(\n\t\t\t\t\t\tid,\n\t\t\t\t\t\t`localData.collections[${index}].${unsupportedRuleKey} is not supported.`\n\t\t\t\t\t);\n\t\t\t\tconst match = nonEmpty(\n\t\t\t\t\tReflect.get(rule, 'match'),\n\t\t\t\t\tid,\n\t\t\t\t\t`localData.collections[${index}].match`\n\t\t\t\t);\n\t\t\t\tconst persistence = unknownField(rule, 'persistence');\n\t\t\t\tconst sensitivity = unknownField(rule, 'sensitivity');\n\t\t\t\tconst protection = unknownField(rule, 'protection');\n\t\t\t\tconst onProtectionUnavailable = unknownField(\n\t\t\t\t\trule,\n\t\t\t\t\t'onProtectionUnavailable'\n\t\t\t\t);\n\t\t\t\tconst evictionPriority = unknownField(rule, 'evictionPriority');\n\t\t\t\tconst maxAge = unknownField(rule, 'maxAgeMs');\n\t\t\t\tif (\n\t\t\t\t\tpersistence !== undefined &&\n\t\t\t\t\tpersistence !== 'durable' &&\n\t\t\t\t\tpersistence !== 'memory-only'\n\t\t\t\t)\n\t\t\t\t\tthrow metadataError(\n\t\t\t\t\t\tid,\n\t\t\t\t\t\t`localData.collections[${index}].persistence is invalid.`\n\t\t\t\t\t);\n\t\t\t\tif (\n\t\t\t\t\tsensitivity !== undefined &&\n\t\t\t\t\tsensitivity !== 'public' &&\n\t\t\t\t\tsensitivity !== 'private' &&\n\t\t\t\t\tsensitivity !== 'secret'\n\t\t\t\t)\n\t\t\t\t\tthrow metadataError(\n\t\t\t\t\t\tid,\n\t\t\t\t\t\t`localData.collections[${index}].sensitivity is invalid.`\n\t\t\t\t\t);\n\t\t\t\tif (\n\t\t\t\t\tprotection !== undefined &&\n\t\t\t\t\tprotection !== 'none' &&\n\t\t\t\t\tprotection !== 'required'\n\t\t\t\t)\n\t\t\t\t\tthrow metadataError(\n\t\t\t\t\t\tid,\n\t\t\t\t\t\t`localData.collections[${index}].protection is invalid.`\n\t\t\t\t\t);\n\t\t\t\tif (\n\t\t\t\t\tonProtectionUnavailable !== undefined &&\n\t\t\t\t\tonProtectionUnavailable !== 'error' &&\n\t\t\t\t\tonProtectionUnavailable !== 'memory-only'\n\t\t\t\t)\n\t\t\t\t\tthrow metadataError(\n\t\t\t\t\t\tid,\n\t\t\t\t\t\t`localData.collections[${index}].onProtectionUnavailable is invalid.`\n\t\t\t\t\t);\n\t\t\t\tif (\n\t\t\t\t\tevictionPriority !== undefined &&\n\t\t\t\t\tevictionPriority !== 'critical' &&\n\t\t\t\t\tevictionPriority !== 'normal' &&\n\t\t\t\t\tevictionPriority !== 'disposable'\n\t\t\t\t)\n\t\t\t\t\tthrow metadataError(\n\t\t\t\t\t\tid,\n\t\t\t\t\t\t`localData.collections[${index}].evictionPriority is invalid.`\n\t\t\t\t\t);\n\n\t\t\t\treturn {\n\t\t\t\t\tmatch,\n\t\t\t\t\t...(sensitivity ? { sensitivity } : {}),\n\t\t\t\t\t...(persistence ? { persistence } : {}),\n\t\t\t\t\t...(protection ? { protection } : {}),\n\t\t\t\t\t...(onProtectionUnavailable\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tonProtectionUnavailable: onProtectionUnavailable\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: {}),\n\t\t\t\t\t...(evictionPriority ? { evictionPriority } : {}),\n\t\t\t\t\t...(maxAge === undefined\n\t\t\t\t\t\t? {}\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tmaxAgeMs: positiveVersion(\n\t\t\t\t\t\t\t\t\tmaxAge,\n\t\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t\t\t`localData.collections[${index}].maxAgeMs`\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t})\n\t\t\t\t};\n\t\t\t})\n\t\t: undefined;\n\tconst mutations: SyncLocalMutationPolicy[] | undefined = Array.isArray(\n\t\tmutationRules\n\t)\n\t\t? mutationRules.map((entry, index) => {\n\t\t\t\tconst rule = requireObject(\n\t\t\t\t\tentry,\n\t\t\t\t\tid,\n\t\t\t\t\t`localData.mutations[${index}] must be an object.`\n\t\t\t\t);\n\t\t\t\tconst allowedRuleKeys = new Set([\n\t\t\t\t\t'conflict',\n\t\t\t\t\t'match',\n\t\t\t\t\t'onProtectionUnavailable',\n\t\t\t\t\t'persistence',\n\t\t\t\t\t'protection',\n\t\t\t\t\t'sensitivity'\n\t\t\t\t]);\n\t\t\t\tconst unsupportedRuleKey = Object.keys(rule).find(\n\t\t\t\t\t(key) => !allowedRuleKeys.has(key)\n\t\t\t\t);\n\t\t\t\tif (unsupportedRuleKey)\n\t\t\t\t\tthrow metadataError(\n\t\t\t\t\t\tid,\n\t\t\t\t\t\t`localData.mutations[${index}].${unsupportedRuleKey} is not supported.`\n\t\t\t\t\t);\n\t\t\t\tconst protection = unknownField(rule, 'protection');\n\t\t\t\tconst sensitivity = unknownField(rule, 'sensitivity');\n\t\t\t\tconst persistence = unknownField(rule, 'persistence');\n\t\t\t\tconst onProtectionUnavailable = unknownField(\n\t\t\t\t\trule,\n\t\t\t\t\t'onProtectionUnavailable'\n\t\t\t\t);\n\t\t\t\tconst declaredConflict = unknownField(rule, 'conflict');\n\t\t\t\tlet conflict: SyncLocalConflictPolicy | undefined;\n\t\t\t\tif (declaredConflict !== undefined) {\n\t\t\t\t\tconst conflictRecord = requireObject(\n\t\t\t\t\t\tdeclaredConflict,\n\t\t\t\t\t\tid,\n\t\t\t\t\t\t`localData.mutations[${index}].conflict must be an object.`\n\t\t\t\t\t);\n\t\t\t\t\tconst unsupportedConflictKey = Object.keys(\n\t\t\t\t\t\tconflictRecord\n\t\t\t\t\t).find(\n\t\t\t\t\t\t(key) => key !== 'maxAttempts' && key !== 'strategy'\n\t\t\t\t\t);\n\t\t\t\t\tif (unsupportedConflictKey)\n\t\t\t\t\t\tthrow metadataError(\n\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t`localData.mutations[${index}].conflict.${unsupportedConflictKey} is not supported.`\n\t\t\t\t\t\t);\n\t\t\t\t\tconst strategy = unknownField(conflictRecord, 'strategy');\n\t\t\t\t\tif (\n\t\t\t\t\t\tstrategy !== 'client-wins' &&\n\t\t\t\t\t\tstrategy !== 'manual' &&\n\t\t\t\t\t\tstrategy !== 'server-wins'\n\t\t\t\t\t)\n\t\t\t\t\t\tthrow metadataError(\n\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t`localData.mutations[${index}].conflict.strategy is invalid.`\n\t\t\t\t\t\t);\n\t\t\t\t\tconst maxAttempts = unknownField(\n\t\t\t\t\t\tconflictRecord,\n\t\t\t\t\t\t'maxAttempts'\n\t\t\t\t\t);\n\t\t\t\t\tif (maxAttempts !== undefined && strategy !== 'client-wins')\n\t\t\t\t\t\tthrow metadataError(\n\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t`localData.mutations[${index}].conflict.maxAttempts requires client-wins.`\n\t\t\t\t\t\t);\n\t\t\t\t\tconflict = {\n\t\t\t\t\t\tstrategy,\n\t\t\t\t\t\t...(maxAttempts === undefined\n\t\t\t\t\t\t\t? {}\n\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\tmaxAttempts: positiveVersion(\n\t\t\t\t\t\t\t\t\t\tmaxAttempts,\n\t\t\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t\t\t\t`localData.mutations[${index}].conflict.maxAttempts`\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\tprotection !== undefined &&\n\t\t\t\t\tprotection !== 'none' &&\n\t\t\t\t\tprotection !== 'required'\n\t\t\t\t)\n\t\t\t\t\tthrow metadataError(\n\t\t\t\t\t\tid,\n\t\t\t\t\t\t`localData.mutations[${index}].protection is invalid.`\n\t\t\t\t\t);\n\t\t\t\tif (\n\t\t\t\t\tsensitivity !== undefined &&\n\t\t\t\t\tsensitivity !== 'public' &&\n\t\t\t\t\tsensitivity !== 'private' &&\n\t\t\t\t\tsensitivity !== 'secret'\n\t\t\t\t)\n\t\t\t\t\tthrow metadataError(\n\t\t\t\t\t\tid,\n\t\t\t\t\t\t`localData.mutations[${index}].sensitivity is invalid.`\n\t\t\t\t\t);\n\t\t\t\tif (\n\t\t\t\t\tonProtectionUnavailable !== undefined &&\n\t\t\t\t\tonProtectionUnavailable !== 'error' &&\n\t\t\t\t\tonProtectionUnavailable !== 'memory-only'\n\t\t\t\t)\n\t\t\t\t\tthrow metadataError(\n\t\t\t\t\t\tid,\n\t\t\t\t\t\t`localData.mutations[${index}].onProtectionUnavailable is invalid.`\n\t\t\t\t\t);\n\t\t\t\tif (\n\t\t\t\t\tpersistence !== undefined &&\n\t\t\t\t\tpersistence !== 'durable' &&\n\t\t\t\t\tpersistence !== 'memory-only'\n\t\t\t\t)\n\t\t\t\t\tthrow metadataError(\n\t\t\t\t\t\tid,\n\t\t\t\t\t\t`localData.mutations[${index}].persistence is invalid.`\n\t\t\t\t\t);\n\n\t\t\t\treturn {\n\t\t\t\t\tmatch: nonEmpty(\n\t\t\t\t\t\tReflect.get(rule, 'match'),\n\t\t\t\t\t\tid,\n\t\t\t\t\t\t`localData.mutations[${index}].match`\n\t\t\t\t\t),\n\t\t\t\t\t...(conflict ? { conflict } : {}),\n\t\t\t\t\t...(sensitivity ? { sensitivity } : {}),\n\t\t\t\t\t...(onProtectionUnavailable\n\t\t\t\t\t\t? { onProtectionUnavailable }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\t...(persistence\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tpersistence: persistence\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: {}),\n\t\t\t\t\t...(protection ? { protection: protection } : {})\n\t\t\t\t};\n\t\t\t})\n\t\t: undefined;\n\tconst quota = Reflect.get(record, 'maxBytesPerNamespace');\n\n\treturn {\n\t\t...(collections ? { collections } : {}),\n\t\t...(mutations ? { mutations } : {}),\n\t\t...(quota === undefined\n\t\t\t? {}\n\t\t\t: {\n\t\t\t\t\tmaxBytesPerNamespace: positiveVersion(\n\t\t\t\t\t\tquota,\n\t\t\t\t\t\tid,\n\t\t\t\t\t\t'localData.maxBytesPerNamespace'\n\t\t\t\t\t)\n\t\t\t\t})\n\t};\n};\n\nconst component: (\n\tid: string,\n\tvalue: unknown\n) => SyncLocalStoreSchemaComponent = (id, value) => {\n\tconst record = requireObject(value, id, 'localSchema must be an object.');\n\tconst allowed = new Set([\n\t\t'localData',\n\t\t'migrations',\n\t\t'minimumCompatibleVersion',\n\t\t'version'\n\t]);\n\tconst unsupported = Object.keys(record).find((key) => !allowed.has(key));\n\tif (unsupported)\n\t\tthrow metadataError(id, `${unsupported} is not supported.`);\n\tconst version = positiveVersion(\n\t\tReflect.get(record, 'version'),\n\t\tid,\n\t\t'version'\n\t);\n\tconst declaredMinimum = Reflect.get(record, 'minimumCompatibleVersion');\n\tconst minimumCompatibleVersion =\n\t\tdeclaredMinimum === undefined\n\t\t\t? Math.max(1, version - 2)\n\t\t\t: positiveVersion(declaredMinimum, id, 'minimumCompatibleVersion');\n\tconst declaredMigrations = Reflect.get(record, 'migrations');\n\tconst declaredLocalData = Reflect.get(record, 'localData');\n\tif (declaredMigrations !== undefined && !Array.isArray(declaredMigrations))\n\t\tthrow metadataError(id, 'migrations must be an array.');\n\tconst migrations = Array.isArray(declaredMigrations)\n\t\t? declaredMigrations\n\t\t: undefined;\n\n\treturn {\n\t\tid,\n\t\t...(declaredLocalData === undefined\n\t\t\t? {}\n\t\t\t: { localData: localDataPolicy(declaredLocalData, id) }),\n\t\tminimumCompatibleVersion,\n\t\t...(Array.isArray(migrations)\n\t\t\t? {\n\t\t\t\t\tmigrations: migrations.map((entry, index) =>\n\t\t\t\t\t\tmigration(entry, id, index)\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t: {}),\n\t\tversion\n\t};\n};\n\nconst dependencyNames = (manifest: object) =>\n\t[\n\t\tReflect.get(manifest, 'dependencies'),\n\t\tReflect.get(manifest, 'optionalDependencies'),\n\t\tReflect.get(manifest, 'devDependencies'),\n\t\tReflect.get(manifest, 'peerDependencies')\n\t]\n\t\t.flatMap((dependencies) =>\n\t\t\tobject(dependencies) ? Object.keys(dependencies) : []\n\t\t)\n\t\t.filter((name, index, names) => names.indexOf(name) === index)\n\t\t.sort();\n\nexport const discoverAbsoluteSyncSchema = (\n\tprojectRoot: string\n): AbsoluteSyncSchemaDiscovery => {\n\tconst appManifestPath = join(resolve(projectRoot), 'package.json');\n\tconst appManifest = manifestAt(appManifestPath);\n\tif (!appManifest)\n\t\treturn {\n\t\t\tcomponents: [\n\t\t\t\t{\n\t\t\t\t\tid: '@absolutejs/app',\n\t\t\t\t\tminimumCompatibleVersion: 1,\n\t\t\t\t\tversion: 1\n\t\t\t\t}\n\t\t\t],\n\t\t\tsources: []\n\t\t};\n\tconst appMetadata = localSchemaMetadata(appManifest);\n\tconst components: SyncLocalStoreSchemaComponent[] = [\n\t\tappMetadata === undefined\n\t\t\t? { id: '@absolutejs/app', minimumCompatibleVersion: 1, version: 1 }\n\t\t\t: component('@absolutejs/app', appMetadata)\n\t];\n\tconst sources: AbsoluteSyncSchemaDiscovery['sources'] = [\n\t\t{ id: '@absolutejs/app', manifestPath: appManifestPath }\n\t];\n\tfor (const name of dependencyNames(appManifest)) {\n\t\tconst manifestPath = packageManifestPath(projectRoot, name);\n\t\tif (!manifestPath) continue;\n\t\tconst manifest = manifestAt(manifestPath);\n\t\tif (!manifest) continue;\n\t\tconst metadata = localSchemaMetadata(manifest);\n\t\tif (metadata === undefined) continue;\n\t\tcomponents.push(component(name, metadata));\n\t\tsources.push({ id: name, manifestPath });\n\t}\n\tcomponents.sort((left, right) => left.id.localeCompare(right.id));\n\tsources.sort((left, right) => left.id.localeCompare(right.id));\n\tresolveSyncLocalSchemaComponents({}, { components });\n\n\treturn { components, sources };\n};\n",
|
|
13
|
+
"import { existsSync, readFileSync } from 'node:fs';\nimport { extname, join, relative, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport ts from 'typescript';\n\nexport type AbsoluteDeviceCapabilityProvider = {\n\tfactory: string;\n\tmodule: string;\n\tplugins?: string[];\n\tnative?: {\n\t\tandroid?: { permissions: string[] };\n\t\tios?: {\n\t\t\tprivacyAccessedApis?: Partial<\n\t\t\t\tRecord<AbsoluteIosPrivacyAccessedApi, string[]>\n\t\t\t>;\n\t\t\tpushNotifications?: true;\n\t\t\tsystemBars?: true;\n\t\t\tusageDescriptions?: AbsoluteIosUsageDescription[];\n\t\t};\n\t};\n\tpackages: string[];\n};\n\nexport type AbsoluteIosUsageDescription =\n\t| 'camera'\n\t| 'location-always'\n\t| 'location-when-in-use'\n\t| 'photo-library'\n\t| 'photo-library-add';\n\nexport type AbsoluteIosPrivacyAccessedApi =\n\t'NSPrivacyAccessedAPICategoryFileTimestamp';\n\nexport type AbsoluteDeviceCapabilityPlan = {\n\tcapabilities: string[];\n\tproviders: Record<string, AbsoluteDeviceCapabilityProvider>;\n\trequiredPackages: string[];\n};\n\nconst DEVICES_PACKAGE = '@absolutejs/devices';\nexport type AbsoluteDeviceProvider = 'capacitor' | 'expo';\nconst ADAPTERS: Record<AbsoluteDeviceProvider, string> = {\n\tcapacitor: '@absolutejs/devices-capacitor',\n\texpo: '@absolutejs/devices-expo'\n};\nconst SOURCE_GLOB = new Bun.Glob('**/*.{js,jsx,ts,tsx,svelte,vue}');\nconst IGNORED_DIRECTORIES = new Set([\n\t'.absolutejs',\n\t'.git',\n\t'.test-builds',\n\t'.test-shards',\n\t'build',\n\t'dist',\n\t'node_modules',\n\t'test',\n\t'tests'\n]);\nconst IDENTIFIER_PATTERN = /^[A-Za-z_$][\\w$]*$/u;\nconst providerModulePattern = (provider: AbsoluteDeviceProvider) =>\n\tnew RegExp(`^@absolutejs/devices-${provider}/[a-z][a-z0-9-]*$`, 'u');\nconst providerPackagePattern = (provider: AbsoluteDeviceProvider) =>\n\tprovider === 'capacitor'\n\t\t? /^@capacitor\\/[a-z][a-z0-9-]*@\\d+\\.\\d+\\.\\d+$/u\n\t\t: /^(?:expo-[a-z][a-z0-9-]*|@react-native-[a-z0-9-]+\\/[a-z][a-z0-9-]*)@\\d+\\.\\d+\\.\\d+$/u;\nconst providerLabel = (provider: AbsoluteDeviceProvider) =>\n\tprovider === 'capacitor' ? 'Capacitor' : 'Expo';\nconst ANDROID_PERMISSION_PATTERN = /^android\\.permission\\.[A-Z][A-Z0-9_]*$/u;\nconst IOS_USAGE_DESCRIPTIONS: ReadonlySet<string> = new Set([\n\t'camera',\n\t'location-always',\n\t'location-when-in-use',\n\t'photo-library',\n\t'photo-library-add'\n]);\nconst IOS_PRIVACY_ACCESSED_API_REASONS: Readonly<\n\tRecord<AbsoluteIosPrivacyAccessedApi, ReadonlySet<string>>\n> = {\n\tNSPrivacyAccessedAPICategoryFileTimestamp: new Set(['C617.1'])\n};\nconst IOS_PRIVACY_ACCESSED_APIS: readonly AbsoluteIosPrivacyAccessedApi[] = [\n\t'NSPrivacyAccessedAPICategoryFileTimestamp'\n];\n\nconst object = (value: unknown): value is Record<string, unknown> =>\n\ttypeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst readJson = (path: string) => {\n\tconst value: unknown = JSON.parse(readFileSync(path, 'utf8'));\n\tif (!object(value)) throw new TypeError(`${path} must contain an object.`);\n\n\treturn value;\n};\n\nconst text = (value: unknown, field: string) => {\n\tif (typeof value !== 'string' || value.length === 0)\n\t\tthrow new TypeError(`${field} must be a non-empty string.`);\n\n\treturn value;\n};\n\nconst androidPermissions = (value: unknown, field: string) => {\n\tif (value === undefined) return undefined;\n\tif (!object(value)) throw new TypeError(`${field} must be an object.`);\n\tconst { permissions } = value;\n\tif (\n\t\t!Array.isArray(permissions) ||\n\t\t!permissions.every(\n\t\t\t(permission): permission is string =>\n\t\t\t\ttypeof permission === 'string' &&\n\t\t\t\tANDROID_PERMISSION_PATTERN.test(permission)\n\t\t)\n\t)\n\t\tthrow new TypeError(\n\t\t\t`${field}.permissions must contain Android permission names.`\n\t\t);\n\n\treturn [...permissions];\n};\n\nconst iosPrivacyAccessedApis = (value: unknown, field: string) => {\n\tif (value === undefined) return undefined;\n\tif (!object(value)) throw new TypeError(`${field} must be an object.`);\n\tconst privacy: Partial<Record<AbsoluteIosPrivacyAccessedApi, string[]>> =\n\t\t{};\n\tfor (const api of IOS_PRIVACY_ACCESSED_APIS) {\n\t\tconst reasons = value[api];\n\t\tif (reasons === undefined) continue;\n\t\tconst supported = IOS_PRIVACY_ACCESSED_API_REASONS[api];\n\t\tif (\n\t\t\t!Array.isArray(reasons) ||\n\t\t\treasons.length === 0 ||\n\t\t\t!reasons.every(\n\t\t\t\t(reason): reason is string =>\n\t\t\t\t\ttypeof reason === 'string' && supported.has(reason)\n\t\t\t)\n\t\t)\n\t\t\tthrow new TypeError(\n\t\t\t\t`${field} contains an unsupported API or reason.`\n\t\t\t);\n\t\tprivacy[api] = [...reasons];\n\t}\n\tif (\n\t\tObject.keys(value).some(\n\t\t\t(api) => !IOS_PRIVACY_ACCESSED_APIS.some((known) => known === api)\n\t\t)\n\t)\n\t\tthrow new TypeError(`${field} contains an unsupported API or reason.`);\n\n\treturn privacy;\n};\n\nconst iosNativeRequirements = (value: unknown, field: string) => {\n\tif (value === undefined) return undefined;\n\tif (!object(value)) throw new TypeError(`${field} must be an object.`);\n\tconst {\n\t\tprivacyAccessedApis,\n\t\tpushNotifications,\n\t\tsystemBars,\n\t\tusageDescriptions\n\t} = value;\n\tif (pushNotifications !== undefined && pushNotifications !== true)\n\t\tthrow new TypeError(`${field}.pushNotifications must be true.`);\n\tif (systemBars !== undefined && systemBars !== true)\n\t\tthrow new TypeError(`${field}.systemBars must be true.`);\n\tif (\n\t\tusageDescriptions !== undefined &&\n\t\t(!Array.isArray(usageDescriptions) ||\n\t\t\t!usageDescriptions.every(\n\t\t\t\t(purpose): purpose is AbsoluteIosUsageDescription =>\n\t\t\t\t\ttypeof purpose === 'string' &&\n\t\t\t\t\tIOS_USAGE_DESCRIPTIONS.has(purpose)\n\t\t\t))\n\t)\n\t\tthrow new TypeError(\n\t\t\t`${field}.usageDescriptions contains an unsupported purpose.`\n\t\t);\n\tconst privacy = iosPrivacyAccessedApis(\n\t\tprivacyAccessedApis,\n\t\t`${field}.privacyAccessedApis`\n\t);\n\n\treturn {\n\t\t...(privacy === undefined ? {} : { privacyAccessedApis: privacy }),\n\t\t...(pushNotifications === true\n\t\t\t? { pushNotifications: true as const }\n\t\t\t: {}),\n\t\t...(systemBars === true ? { systemBars: true as const } : {}),\n\t\t...(usageDescriptions === undefined\n\t\t\t? {}\n\t\t\t: { usageDescriptions: [...usageDescriptions] })\n\t};\n};\n\nconst parseProvider = (\n\tname: string,\n\tvalue: unknown,\n\tproviderName: AbsoluteDeviceProvider\n): AbsoluteDeviceCapabilityProvider => {\n\tif (!IDENTIFIER_PATTERN.test(name))\n\t\tthrow new TypeError('Device capability names must be identifiers.');\n\tif (!object(value))\n\t\tthrow new TypeError(`Device capability ${name} must be an object.`);\n\tconst factory = text(value.factory, `${name}.factory`);\n\tconst module = text(value.module, `${name}.module`);\n\tif (!IDENTIFIER_PATTERN.test(factory))\n\t\tthrow new TypeError(`${name}.factory must be a JavaScript identifier.`);\n\tif (!providerModulePattern(providerName).test(module))\n\t\tthrow new TypeError(\n\t\t\t`${name}.module must be an official devices-${providerName} subpath.`\n\t\t);\n\tif (\n\t\t!Array.isArray(value.packages) ||\n\t\t!value.packages.every(\n\t\t\t(spec): spec is string =>\n\t\t\t\ttypeof spec === 'string' &&\n\t\t\t\tproviderPackagePattern(providerName).test(spec)\n\t\t)\n\t)\n\t\tthrow new TypeError(\n\t\t\t`${name}.packages must contain exact official ${providerLabel(providerName)} package versions.`\n\t\t);\n\tconst { plugins } = value;\n\tif (\n\t\tplugins !== undefined &&\n\t\t(!Array.isArray(plugins) ||\n\t\t\t!plugins.every(\n\t\t\t\t(plugin): plugin is string =>\n\t\t\t\t\ttypeof plugin === 'string' &&\n\t\t\t\t\t/^expo-[a-z][a-z0-9-]*$/u.test(plugin)\n\t\t\t))\n\t)\n\t\tthrow new TypeError(\n\t\t\t`${name}.plugins must contain Expo config plugin names.`\n\t\t);\n\tlet native: AbsoluteDeviceCapabilityProvider['native'];\n\tconst { native: nativeMetadata } = value;\n\tif (nativeMetadata !== undefined) {\n\t\tif (!object(nativeMetadata))\n\t\t\tthrow new TypeError(`${name}.native must be an object.`);\n\t\tconst { android, ios } = nativeMetadata;\n\t\tconst permissions = androidPermissions(\n\t\t\tandroid,\n\t\t\t`${name}.native.android`\n\t\t);\n\t\tconst iosRequirements = iosNativeRequirements(\n\t\t\tios,\n\t\t\t`${name}.native.ios`\n\t\t);\n\t\tnative = {\n\t\t\t...(permissions === undefined ? {} : { android: { permissions } }),\n\t\t\t...(iosRequirements === undefined ? {} : { ios: iosRequirements })\n\t\t};\n\t}\n\n\treturn {\n\t\tfactory,\n\t\tmodule,\n\t\t...(native === undefined ? {} : { native }),\n\t\t...(plugins === undefined ? {} : { plugins: [...plugins] }),\n\t\tpackages: [...value.packages]\n\t};\n};\n\nexport const absoluteDeviceNativeRequirements = (\n\tplan: AbsoluteDeviceCapabilityPlan\n) => {\n\tconst privacy = plan.capabilities.reduce<\n\t\tPartial<Record<AbsoluteIosPrivacyAccessedApi, Set<string>>>\n\t>((requirements, name) => {\n\t\tfor (const api of IOS_PRIVACY_ACCESSED_APIS) {\n\t\t\tconst reasons =\n\t\t\t\tplan.providers[name]?.native?.ios?.privacyAccessedApis?.[api] ??\n\t\t\t\t[];\n\t\t\tif (reasons.length === 0) continue;\n\t\t\tconst current = requirements[api] ?? new Set<string>();\n\t\t\tfor (const reason of reasons) current.add(reason);\n\t\t\trequirements[api] = current;\n\t\t}\n\n\t\treturn requirements;\n\t}, {});\n\n\treturn {\n\t\tandroidPermissions: [\n\t\t\t...new Set(\n\t\t\t\tplan.capabilities.flatMap(\n\t\t\t\t\t(name) =>\n\t\t\t\t\t\tplan.providers[name]?.native?.android?.permissions ?? []\n\t\t\t\t)\n\t\t\t)\n\t\t].sort(),\n\t\tiosPrivacyAccessedApis: IOS_PRIVACY_ACCESSED_APIS.flatMap((api) => {\n\t\t\tconst reasons = privacy[api];\n\n\t\t\treturn reasons ? [{ api, reasons: [...reasons].sort() }] : [];\n\t\t}),\n\t\tiosPushNotifications: plan.capabilities.some(\n\t\t\t(name) =>\n\t\t\t\tplan.providers[name]?.native?.ios?.pushNotifications === true\n\t\t),\n\t\tiosSystemBars: plan.capabilities.some(\n\t\t\t(name) => plan.providers[name]?.native?.ios?.systemBars === true\n\t\t),\n\t\tiosUsageDescriptions: [\n\t\t\t...new Set(\n\t\t\t\tplan.capabilities.flatMap(\n\t\t\t\t\t(name) =>\n\t\t\t\t\t\tplan.providers[name]?.native?.ios?.usageDescriptions ??\n\t\t\t\t\t\t[]\n\t\t\t\t)\n\t\t\t)\n\t\t].sort()\n\t};\n};\n\nexport const loadAbsoluteDeviceCapabilityProviders = (\n\tprojectRoot: string,\n\tprovider: AbsoluteDeviceProvider = 'capacitor'\n) => {\n\tconst adapter = ADAPTERS[provider];\n\tlet path = join(\n\t\tresolve(projectRoot),\n\t\t'node_modules',\n\t\tadapter,\n\t\t'package.json'\n\t);\n\ttry {\n\t\treadFileSync(path, 'utf8');\n\t} catch {\n\t\tpath = fileURLToPath(import.meta.resolve(`${adapter}/package.json`));\n\t}\n\tconst manifest = readJson(path);\n\tconst { absolutejs } = manifest;\n\tconst devices = object(absolutejs) ? absolutejs.devices : undefined;\n\tif (\n\t\t!object(devices) ||\n\t\tdevices.format !== 1 ||\n\t\tdevices.provider !== provider ||\n\t\t!object(devices.capabilities)\n\t)\n\t\tthrow new TypeError(\n\t\t\t`${adapter} does not publish supported capability metadata.`\n\t\t);\n\n\tconst entries = Object.entries(devices.capabilities).map(\n\t\t([name, capability]) => ({\n\t\t\tname,\n\t\t\tprovider: parseProvider(name, capability, provider)\n\t\t})\n\t);\n\n\treturn Object.fromEntries(\n\t\tentries\n\t\t\t.sort((left, right) => left.name.localeCompare(right.name))\n\t\t\t.map(({ name, provider: capabilityProvider }) => [\n\t\t\t\tname,\n\t\t\t\tcapabilityProvider\n\t\t\t])\n\t);\n};\n\nconst isIgnored = (path: string) =>\n\tpath.split('/').some((segment) => IGNORED_DIRECTORIES.has(segment));\n\nconst importedCapabilities = (source: string, file: string) => {\n\tconst names = new Set<string>();\n\tconst namespaces = new Set<string>();\n\tconst visit = (node: ts.Node) => {\n\t\tif (\n\t\t\tts.isImportDeclaration(node) &&\n\t\t\tts.isStringLiteral(node.moduleSpecifier) &&\n\t\t\tnode.moduleSpecifier.text === DEVICES_PACKAGE &&\n\t\t\t!node.importClause?.isTypeOnly\n\t\t) {\n\t\t\tconst bindings = node.importClause?.namedBindings;\n\t\t\tif (bindings && ts.isNamedImports(bindings))\n\t\t\t\tfor (const element of bindings.elements)\n\t\t\t\t\tif (!element.isTypeOnly)\n\t\t\t\t\t\tnames.add((element.propertyName ?? element.name).text);\n\t\t\tif (bindings && ts.isNamespaceImport(bindings))\n\t\t\t\tnamespaces.add(bindings.name.text);\n\t\t}\n\t\tif (\n\t\t\tts.isExportDeclaration(node) &&\n\t\t\t!node.isTypeOnly &&\n\t\t\tnode.moduleSpecifier !== undefined &&\n\t\t\tts.isStringLiteral(node.moduleSpecifier) &&\n\t\t\tnode.moduleSpecifier.text === DEVICES_PACKAGE &&\n\t\t\tnode.exportClause &&\n\t\t\tts.isNamedExports(node.exportClause)\n\t\t)\n\t\t\tfor (const element of node.exportClause.elements)\n\t\t\t\tif (!element.isTypeOnly)\n\t\t\t\t\tnames.add((element.propertyName ?? element.name).text);\n\t\tif (\n\t\t\tts.isPropertyAccessExpression(node) &&\n\t\t\tts.isIdentifier(node.expression) &&\n\t\t\tnamespaces.has(node.expression.text)\n\t\t)\n\t\t\tnames.add(node.name.text);\n\t\tts.forEachChild(node, visit);\n\t};\n\tconst extension = extname(file).toLowerCase();\n\tconst sources =\n\t\textension === '.svelte' || extension === '.vue'\n\t\t\t? [...source.matchAll(/<script\\b[^>]*>([\\s\\S]*?)<\\/script\\s*>/giu)]\n\t\t\t\t\t.map((match) => match[1])\n\t\t\t\t\t.filter((value): value is string => value !== undefined)\n\t\t\t: [source];\n\tfor (const [index, script] of sources.entries())\n\t\tvisit(\n\t\t\tts.createSourceFile(\n\t\t\t\t`${file}#script-${index}`,\n\t\t\t\tscript,\n\t\t\t\tts.ScriptTarget.Latest,\n\t\t\t\ttrue,\n\t\t\t\tts.ScriptKind.TSX\n\t\t\t)\n\t\t);\n\n\treturn names;\n};\n\nexport const assertAbsoluteDeviceCapabilityPackages = (\n\tprojectRoot: string,\n\tplan: AbsoluteDeviceCapabilityPlan\n) => {\n\tconst missing = missingAbsoluteDeviceCapabilityPackages(\n\t\tplan,\n\t\tdirectAbsoluteProjectPackages(projectRoot)\n\t);\n\tconst mismatched = plan.requiredPackages.filter((spec) => {\n\t\tconst separator = spec.lastIndexOf('@');\n\t\tconst packageName = spec.slice(0, separator);\n\t\tif (missing.includes(spec)) return false;\n\t\ttry {\n\t\t\treturn (\n\t\t\t\treadJson(\n\t\t\t\t\tjoin(\n\t\t\t\t\t\tresolve(projectRoot),\n\t\t\t\t\t\t'node_modules',\n\t\t\t\t\t\tpackageName,\n\t\t\t\t\t\t'package.json'\n\t\t\t\t\t)\n\t\t\t\t).version !== spec.slice(separator + 1)\n\t\t\t);\n\t\t} catch {\n\t\t\treturn true;\n\t\t}\n\t});\n\tconst unmet = [...missing, ...mismatched];\n\tif (unmet.length > 0)\n\t\tthrow new TypeError(\n\t\t\t`Device capabilities ${plan.capabilities.join(', ')} require ${unmet.join(', ')}. Run absolute mobile sync and approve the detected capability plugins.`\n\t\t);\n};\n\nexport const directAbsoluteProjectPackages = (projectRoot: string) => {\n\tconst manifest = readJson(join(resolve(projectRoot), 'package.json'));\n\tconst packages = new Set<string>();\n\tfor (const field of ['dependencies', 'devDependencies']) {\n\t\tconst dependencies = manifest[field];\n\t\tif (object(dependencies))\n\t\t\tfor (const name of Object.keys(dependencies)) packages.add(name);\n\t}\n\n\treturn packages;\n};\n\nexport const discoverAbsoluteDeviceCapabilities = (\n\tprojectRoot: string,\n\tproviders = loadAbsoluteDeviceCapabilityProviders(projectRoot)\n) => {\n\tconst root = resolve(projectRoot);\n\tif (!existsSync(root)) return [];\n\tconst known = new Set(Object.keys(providers));\n\tconst capabilities = new Set<string>();\n\tfor (const path of SOURCE_GLOB.scanSync({ cwd: root })) {\n\t\tconst portable = relative(root, resolve(root, path)).replaceAll(\n\t\t\t'\\\\',\n\t\t\t'/'\n\t\t);\n\t\tif (isIgnored(portable)) continue;\n\t\tconst source = readFileSync(resolve(root, portable), 'utf8');\n\t\tfor (const name of importedCapabilities(source, portable))\n\t\t\tif (known.has(name)) capabilities.add(name);\n\t}\n\n\treturn [...capabilities].sort();\n};\n\nexport const missingAbsoluteDeviceCapabilityPackages = (\n\tplan: AbsoluteDeviceCapabilityPlan,\n\tdirectPackages: ReadonlySet<string>\n) =>\n\tplan.requiredPackages.filter((spec) => {\n\t\tconst packageName = spec.slice(0, spec.lastIndexOf('@'));\n\n\t\treturn !directPackages.has(packageName);\n\t});\n\n/** Framework-agnostic capability discovery used by web/PWA builds. This does\n * not load a native provider manifest, so Web Push never requires Capacitor. */\nexport const projectImportsAbsoluteDeviceCapability = (\n\tprojectRoot: string,\n\tcapability: string\n) => {\n\tconst root = resolve(projectRoot);\n\tfor (const path of SOURCE_GLOB.scanSync({ cwd: root })) {\n\t\tconst portable = relative(root, resolve(root, path)).replaceAll(\n\t\t\t'\\\\',\n\t\t\t'/'\n\t\t);\n\t\tif (isIgnored(portable)) continue;\n\t\tconst source = readFileSync(resolve(root, portable), 'utf8');\n\t\tif (importedCapabilities(source, portable).has(capability)) return true;\n\t}\n\n\treturn false;\n};\n\nexport const resolveAbsoluteDeviceCapabilityPlan = (\n\tprojectRoot: string,\n\tprovider: AbsoluteDeviceProvider = 'capacitor'\n): AbsoluteDeviceCapabilityPlan => {\n\tconst allProviders = loadAbsoluteDeviceCapabilityProviders(\n\t\tprojectRoot,\n\t\tprovider\n\t);\n\tconst capabilities = discoverAbsoluteDeviceCapabilities(\n\t\tprojectRoot,\n\t\tallProviders\n\t);\n\tconst providers: Record<string, AbsoluteDeviceCapabilityProvider> = {};\n\tfor (const name of capabilities) {\n\t\tconst capabilityProvider = allProviders[name];\n\t\tif (capabilityProvider) providers[name] = capabilityProvider;\n\t}\n\n\treturn {\n\t\tcapabilities,\n\t\tproviders,\n\t\trequiredPackages: [\n\t\t\t...new Set(\n\t\t\t\tcapabilities.flatMap((name) => providers[name]?.packages ?? [])\n\t\t\t)\n\t\t].sort()\n\t};\n};\n",
|
|
14
|
+
"import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { homedir } from 'node:os';\nimport { join } from 'node:path';\nimport type { TelemetryConfig } from '../../../types/telemetry';\n\nconst configDir = join(homedir(), '.absolutejs');\nconst configPath = join(configDir, 'telemetry.json');\n\nexport const getTelemetryConfig = () => {\n\ttry {\n\t\tif (!existsSync(configPath)) return null;\n\t\tconst raw = readFileSync(configPath, 'utf-8');\n\n\t\tconst config: TelemetryConfig = JSON.parse(raw);\n\n\t\treturn config;\n\t} catch {\n\t\treturn null;\n\t}\n};\n\nexport const isTelemetryEnabled = () => {\n\tconst config = getTelemetryConfig();\n\n\treturn config?.enabled === true;\n};\n\nexport const saveTelemetryConfig = (config: TelemetryConfig) => {\n\tmkdirSync(configDir, { recursive: true });\n\twriteFileSync(configPath, `${JSON.stringify(config, null, '\\t')}\\n`);\n};\n\nconst enable = () => {\n\tconst existing = getTelemetryConfig();\n\tconst config: TelemetryConfig = {\n\t\tanonymousId: existing?.anonymousId ?? crypto.randomUUID(),\n\t\tcreatedAt: existing?.createdAt ?? new Date().toISOString(),\n\t\tenabled: true\n\t};\n\tsaveTelemetryConfig(config);\n\tconsole.log('Telemetry enabled.');\n\tconsole.log(`Anonymous ID: ${config.anonymousId}`);\n};\n\nconst disable = () => {\n\tconst existing = getTelemetryConfig();\n\tif (existing) {\n\t\tsaveTelemetryConfig({ ...existing, enabled: false });\n\t}\n\tconsole.log('Telemetry disabled.');\n};\n\nconst status = () => {\n\tconst config = getTelemetryConfig();\n\tif (!config || !config.enabled) {\n\t\tconsole.log('Telemetry is disabled.');\n\t} else {\n\t\tconsole.log('Telemetry is enabled.');\n\t\tconsole.log(`Anonymous ID: ${config.anonymousId}`);\n\t}\n};\n\nexport const telemetry = (args: string[]) => {\n\tconst [subcommand] = args;\n\n\tif (subcommand === 'enable') {\n\t\tenable();\n\n\t\treturn;\n\t}\n\tif (subcommand === 'disable') {\n\t\tdisable();\n\n\t\treturn;\n\t}\n\tif (subcommand === 'status') {\n\t\tstatus();\n\n\t\treturn;\n\t}\n\tif (!subcommand) {\n\t\tstatus();\n\t\tconsole.log('');\n\t\tconsole.log('Usage: absolute telemetry <command>');\n\t\tconsole.log('Commands:');\n\t\tconsole.log(' enable Enable anonymous telemetry');\n\t\tconsole.log(' disable Disable telemetry');\n\t\tconsole.log(' status Show current telemetry status');\n\n\t\treturn;\n\t}\n\tconsole.error(`Unknown telemetry command: ${subcommand}`);\n\tconsole.error('Usage: absolute telemetry <enable|disable|status>');\n\tprocess.exit(1);\n};\n",
|
|
15
|
+
"import { existsSync, readFileSync } from 'node:fs';\nimport { arch, platform } from 'node:os';\nimport { dirname, join, parse } from 'node:path';\nimport type { TelemetryEvent } from '../../types/telemetry';\nimport { getTelemetryConfig } from './scripts/telemetry';\n\nconst checkCandidate = (candidate: string) => {\n\tif (!existsSync(candidate)) {\n\t\treturn null;\n\t}\n\tconst pkg = JSON.parse(readFileSync(candidate, 'utf-8'));\n\n\tif (pkg.name === '@absolutejs/absolute') {\n\t\tconst ver: string = pkg.version;\n\n\t\treturn ver;\n\t}\n\n\treturn null;\n};\n\nconst getVersion = () => {\n\ttry {\n\t\treturn findPackageVersion();\n\t} catch {\n\t\treturn 'unknown';\n\t}\n};\n\nconst findPackageVersion = () => {\n\tlet { dir } = import.meta;\n\n\twhile (dir !== parse(dir).root) {\n\t\tconst candidate = join(dir, 'package.json');\n\t\tconst version = checkCandidate(candidate);\n\t\tif (version) {\n\t\t\treturn version;\n\t\t}\n\t\tdir = dirname(dir);\n\t}\n\n\treturn 'unknown';\n};\n\nexport const sendTelemetryEvent = (\n\tevent: string,\n\tpayload: Record<string, unknown>\n) => {\n\ttry {\n\t\tif (process.env.TELEMETRY_OFF === '1') return;\n\t\tconst config = getTelemetryConfig();\n\t\tif (!config?.enabled) return;\n\n\t\tconst body: TelemetryEvent = {\n\t\t\tanonymousId: config.anonymousId,\n\t\t\tarch: arch(),\n\t\t\tbunVersion: Bun.version,\n\t\t\tevent,\n\t\t\tos: platform(),\n\t\t\tpayload,\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t\tversion: getVersion()\n\t\t};\n\n\t\tfetch('https://absolutejs.com/api/telemetry', {\n\t\t\tbody: JSON.stringify(body),\n\t\t\theaders: { 'Content-Type': 'application/json' },\n\t\t\tmethod: 'POST'\n\t\t}).catch(() => undefined);\n\t} catch {\n\t\t/* silently ignore */\n\t}\n};\n",
|
|
9
16
|
"import { createHash } from 'node:crypto';\nimport {\n\tmkdir,\n\tmkdtemp,\n\treadFile,\n\treaddir,\n\trename,\n\trm,\n\twriteFile\n} from 'node:fs/promises';\nimport { join, resolve as resolvePath } from 'node:path';\nimport {\n\tparseAbsoluteMobileCompatibilityArtifact,\n\tretainAbsoluteMobileCompatibilityArtifacts,\n\ttype AbsoluteMobileCompatibilityArtifact\n} from './releaseArtifact';\n\nexport type AbsoluteMobileStoredCompatibilityRelease = {\n\tartifact: AbsoluteMobileCompatibilityArtifact;\n\tproducer: Blob;\n};\n\nexport type AbsoluteMobileCompatibilityArtifactStore = {\n\tdelete: (appId: string, releaseId: string) => Promise<void>;\n\tlist: (appId: string) => Promise<AbsoluteMobileCompatibilityArtifact[]>;\n\tread: (\n\t\tappId: string,\n\t\treleaseId: string\n\t) => Promise<AbsoluteMobileStoredCompatibilityRelease | null>;\n\twrite: (release: AbsoluteMobileStoredCompatibilityRelease) => Promise<void>;\n};\n\nexport type AbsoluteMobileFileArtifactStoreOptions = {\n\tmaxProducerBytes?: number;\n\troot: string;\n};\n\nexport type AbsoluteMobileBlobStore = {\n\tdelete: (key: string) => Promise<void>;\n\tget: (key: string) => Promise<Uint8Array | null>;\n\tlist: (options: { cursor?: string; prefix: string }) => Promise<{\n\t\tcursor?: string;\n\t\tobjects: Array<{ key: string }>;\n\t\ttruncated: boolean;\n\t}>;\n\tput: (\n\t\tkey: string,\n\t\tbody: ReadableStream<Uint8Array> | Uint8Array | string,\n\t\toptions?: {\n\t\t\tcontentType?: string;\n\t\t\tmaxBytes?: number;\n\t\t\tmetadata?: Record<string, string>;\n\t\t}\n\t) => Promise<unknown>;\n};\n\nexport type AbsoluteMobileBlobArtifactStoreOptions = {\n\tmaxProducerBytes?: number;\n\tprefix?: string;\n\tstore: AbsoluteMobileBlobStore;\n};\n\nexport type AbsoluteMobileCarryForwardInput = {\n\tcurrent: AbsoluteMobileStoredCompatibilityRelease;\n\tstore: AbsoluteMobileCompatibilityArtifactStore;\n};\n\nconst DEFAULT_MAX_PRODUCER_BYTES = 134_217_728;\nconst SHA_256 = 'sha256';\nconst ARTIFACT_FILE = 'artifact.json';\nconst RELEASE_ID_PATTERN = /^amc_[a-f0-9]{64}$/;\nconst DEFAULT_BLOB_PREFIX = 'absolutejs/mobile-compatibility';\n\nconst hashBlob = async (blob: Blob) => {\n\tconst bytes = new Uint8Array(await blob.arrayBuffer());\n\n\treturn createHash(SHA_256).update(bytes).digest('hex');\n};\n\nconst blobFromBytes = (bytes: Uint8Array) => {\n\tconst buffer = new ArrayBuffer(bytes.byteLength);\n\tnew Uint8Array(buffer).set(bytes);\n\n\treturn new Blob([buffer]);\n};\n\nconst errorHasCode = (error: unknown, code: string) =>\n\ttypeof error === 'object' &&\n\terror !== null &&\n\tReflect.get(error, 'code') === code;\n\nconst appDirectoryName = (appId: string) =>\n\tcreateHash(SHA_256).update(appId).digest('hex');\n\nconst requireReleaseId = (releaseId: string) => {\n\tif (!RELEASE_ID_PATTERN.test(releaseId)) {\n\t\tthrow new TypeError('Invalid mobile compatibility release id.');\n\t}\n\n\treturn releaseId;\n};\n\nconst readStoredArtifact = async (releaseDirectory: string) => {\n\tconst serialized = await readFile(\n\t\tjoin(releaseDirectory, ARTIFACT_FILE),\n\t\t'utf8'\n\t);\n\tconst parsed: unknown = JSON.parse(serialized);\n\n\treturn parseAbsoluteMobileCompatibilityArtifact(parsed);\n};\n\nconst validateStoredIdentity = (\n\tartifact: AbsoluteMobileCompatibilityArtifact,\n\tappId: string,\n\treleaseId: string\n) => {\n\tif (artifact.appId !== appId || artifact.releaseId !== releaseId) {\n\t\tthrow new TypeError(\n\t\t\t'Stored mobile compatibility identity does not match.'\n\t\t);\n\t}\n\n\treturn artifact;\n};\n\ntype BlobKeyLister = (\n\tstore: AbsoluteMobileBlobStore,\n\tprefix: string,\n\tcursor?: string,\n\tkeys?: string[]\n) => Promise<string[]>;\n\nconst listBlobKeys: BlobKeyLister = async (\n\tstore,\n\tprefix,\n\tcursor,\n\tkeys = []\n) => {\n\tconst result = await store.list({ cursor, prefix });\n\tconst collected = [...keys, ...result.objects.map(({ key }) => key)];\n\tif (!result.truncated) return collected;\n\tif (!result.cursor) {\n\t\tthrow new TypeError('Truncated blob listing did not provide a cursor.');\n\t}\n\n\treturn listBlobKeys(store, prefix, result.cursor, collected);\n};\n\nconst normalizeBlobPrefix = (prefix: string) => {\n\tconst normalized = prefix.replace(/^\\/+|\\/+$/g, '');\n\tif (!normalized || normalized.split('/').includes('..')) {\n\t\tthrow new TypeError('Mobile compatibility blob prefix is invalid.');\n\t}\n\n\treturn normalized;\n};\nexport const carryForwardAbsoluteMobileCompatibilityReleases = async (\n\tinput: AbsoluteMobileCarryForwardInput\n) => {\n\tawait verifyAbsoluteMobileCompatibilityProducer(input.current);\n\tawait input.store.write(input.current);\n\tconst available = await input.store.list(input.current.artifact.appId);\n\tconst retained = retainAbsoluteMobileCompatibilityArtifacts(available);\n\tif (retained[0]?.releaseId !== input.current.artifact.releaseId) {\n\t\tthrow new TypeError(\n\t\t\t'Current mobile release generation must be newer than stored history.'\n\t\t);\n\t}\n\tconst releases = await Promise.all(\n\t\tretained.map(({ releaseId }) =>\n\t\t\tinput.store.read(input.current.artifact.appId, releaseId)\n\t\t)\n\t);\n\n\treturn Promise.all(\n\t\treleases.map((release) => {\n\t\t\tif (!release) {\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t'Compatibility store listed a release it could not read.'\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn verifyAbsoluteMobileCompatibilityProducer(release);\n\t\t})\n\t);\n};\n\nexport const createAbsoluteMobileBlobArtifactStore = (\n\toptions: AbsoluteMobileBlobArtifactStoreOptions\n): AbsoluteMobileCompatibilityArtifactStore => {\n\tconst prefix = normalizeBlobPrefix(options.prefix ?? DEFAULT_BLOB_PREFIX);\n\tconst maxProducerBytes =\n\t\toptions.maxProducerBytes ?? DEFAULT_MAX_PRODUCER_BYTES;\n\tconst appPrefix = (appId: string) =>\n\t\t`${prefix}/${appDirectoryName(appId)}/releases`;\n\tconst releasePrefix = (appId: string, releaseId: string) =>\n\t\t`${appPrefix(appId)}/${requireReleaseId(releaseId)}`;\n\tconst artifactKey = (appId: string, releaseId: string) =>\n\t\t`${releasePrefix(appId, releaseId)}/${ARTIFACT_FILE}`;\n\tconst producerKey = (artifact: AbsoluteMobileCompatibilityArtifact) =>\n\t\t`${releasePrefix(artifact.appId, artifact.releaseId)}/${artifact.producer.module}`;\n\tconst readArtifact = async (appId: string, releaseId: string) => {\n\t\tconst bytes = await options.store.get(artifactKey(appId, releaseId));\n\t\tif (!bytes) return null;\n\t\tconst parsed: unknown = JSON.parse(new TextDecoder().decode(bytes));\n\n\t\treturn validateStoredIdentity(\n\t\t\tparseAbsoluteMobileCompatibilityArtifact(parsed),\n\t\t\tappId,\n\t\t\treleaseId\n\t\t);\n\t};\n\n\treturn {\n\t\tdelete: async (appId, releaseId) => {\n\t\t\tconst artifact = await readArtifact(appId, releaseId);\n\t\t\tif (artifact) await options.store.delete(producerKey(artifact));\n\t\t\tawait options.store.delete(artifactKey(appId, releaseId));\n\t\t},\n\t\tlist: async (appId) => {\n\t\t\tconst releaseRoot = `${appPrefix(appId)}/`;\n\t\t\tconst keys = await listBlobKeys(options.store, releaseRoot);\n\t\t\tconst releaseIds = keys\n\t\t\t\t.filter((key) => key.endsWith(`/${ARTIFACT_FILE}`))\n\t\t\t\t.map((key) => key.slice(releaseRoot.length).split('/')[0])\n\t\t\t\t.filter(\n\t\t\t\t\t(releaseId): releaseId is string =>\n\t\t\t\t\t\ttypeof releaseId === 'string' &&\n\t\t\t\t\t\tRELEASE_ID_PATTERN.test(releaseId)\n\t\t\t\t);\n\t\t\tconst artifacts = await Promise.all(\n\t\t\t\t[...new Set(releaseIds)].map((releaseId) =>\n\t\t\t\t\treadArtifact(appId, releaseId)\n\t\t\t\t)\n\t\t\t);\n\n\t\t\treturn artifacts\n\t\t\t\t.filter(\n\t\t\t\t\t(\n\t\t\t\t\t\tartifact\n\t\t\t\t\t): artifact is AbsoluteMobileCompatibilityArtifact =>\n\t\t\t\t\t\tartifact !== null\n\t\t\t\t)\n\t\t\t\t.sort((left, right) => right.generation - left.generation);\n\t\t},\n\t\tread: async (appId, releaseId) => {\n\t\t\tconst artifact = await readArtifact(appId, releaseId);\n\t\t\tif (!artifact) return null;\n\t\t\tconst bytes = await options.store.get(producerKey(artifact));\n\t\t\tif (!bytes) {\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t'Mobile compatibility artifact is missing its producer.'\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn { artifact, producer: blobFromBytes(bytes) };\n\t\t},\n\t\twrite: async (release) => {\n\t\t\tconst artifact = parseAbsoluteMobileCompatibilityArtifact(\n\t\t\t\trelease.artifact\n\t\t\t);\n\t\t\tconst validated = await verifyAbsoluteMobileCompatibilityProducer(\n\t\t\t\t{ artifact, producer: release.producer },\n\t\t\t\tmaxProducerBytes\n\t\t\t);\n\t\t\tawait options.store.put(\n\t\t\t\tproducerKey(validated.artifact),\n\t\t\t\tvalidated.producer.stream(),\n\t\t\t\t{\n\t\t\t\t\tcontentType: 'text/javascript; charset=utf-8',\n\t\t\t\t\tmaxBytes: maxProducerBytes,\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\tappId: validated.artifact.appId,\n\t\t\t\t\t\treleaseId: validated.artifact.releaseId,\n\t\t\t\t\t\tsha256: validated.artifact.producer.bundleHash\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\t\t\tawait options.store.put(\n\t\t\t\tartifactKey(\n\t\t\t\t\tvalidated.artifact.appId,\n\t\t\t\t\tvalidated.artifact.releaseId\n\t\t\t\t),\n\t\t\t\t`${JSON.stringify(validated.artifact, null, '\\t')}\\n`,\n\t\t\t\t{ contentType: 'application/json' }\n\t\t\t);\n\t\t}\n\t};\n};\n\nexport const createAbsoluteMobileFileArtifactStore = (\n\toptions: AbsoluteMobileFileArtifactStoreOptions\n): AbsoluteMobileCompatibilityArtifactStore => {\n\tconst root = resolvePath(options.root);\n\tconst maxProducerBytes =\n\t\toptions.maxProducerBytes ?? DEFAULT_MAX_PRODUCER_BYTES;\n\tconst appDirectory = (appId: string) => join(root, appDirectoryName(appId));\n\tconst releaseDirectory = (appId: string, releaseId: string) =>\n\t\tjoin(appDirectory(appId), requireReleaseId(releaseId));\n\tconst acceptExistingRelease = async (\n\t\terror: unknown,\n\t\tartifact: AbsoluteMobileCompatibilityArtifact\n\t) => {\n\t\tif (\n\t\t\t!errorHasCode(error, 'EEXIST') &&\n\t\t\t!errorHasCode(error, 'ENOTEMPTY')\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\tconst existing = await readStoredArtifact(\n\t\t\treleaseDirectory(artifact.appId, artifact.releaseId)\n\t\t);\n\n\t\treturn existing.releaseId === artifact.releaseId;\n\t};\n\n\treturn {\n\t\tdelete: async (appId, releaseId) => {\n\t\t\tawait rm(releaseDirectory(appId, releaseId), {\n\t\t\t\tforce: true,\n\t\t\t\trecursive: true\n\t\t\t});\n\t\t},\n\t\tlist: async (appId) => {\n\t\t\tlet entries;\n\t\t\ttry {\n\t\t\t\tentries = await readdir(appDirectory(appId), {\n\t\t\t\t\twithFileTypes: true\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tif (errorHasCode(error, 'ENOENT')) return [];\n\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tconst artifacts = await Promise.all(\n\t\t\t\tentries\n\t\t\t\t\t.filter(\n\t\t\t\t\t\t(entry) =>\n\t\t\t\t\t\t\tentry.isDirectory() &&\n\t\t\t\t\t\t\tRELEASE_ID_PATTERN.test(entry.name)\n\t\t\t\t\t)\n\t\t\t\t\t.map(async ({ name }) =>\n\t\t\t\t\t\tvalidateStoredIdentity(\n\t\t\t\t\t\t\tawait readStoredArtifact(\n\t\t\t\t\t\t\t\treleaseDirectory(appId, name)\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tappId,\n\t\t\t\t\t\t\tname\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t);\n\n\t\t\treturn artifacts.sort(\n\t\t\t\t(left, right) => right.generation - left.generation\n\t\t\t);\n\t\t},\n\t\tread: async (appId, releaseId) => {\n\t\t\tconst directory = releaseDirectory(appId, releaseId);\n\t\t\tlet artifact;\n\t\t\ttry {\n\t\t\t\tartifact = validateStoredIdentity(\n\t\t\t\t\tawait readStoredArtifact(directory),\n\t\t\t\t\tappId,\n\t\t\t\t\treleaseId\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\tif (errorHasCode(error, 'ENOENT')) return null;\n\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tartifact,\n\t\t\t\tproducer: Bun.file(join(directory, artifact.producer.module))\n\t\t\t};\n\t\t},\n\t\twrite: async (release) => {\n\t\t\tconst validatedArtifact = parseAbsoluteMobileCompatibilityArtifact(\n\t\t\t\trelease.artifact\n\t\t\t);\n\t\t\tconst validated = await verifyAbsoluteMobileCompatibilityProducer(\n\t\t\t\t{ artifact: validatedArtifact, producer: release.producer },\n\t\t\t\tmaxProducerBytes\n\t\t\t);\n\t\t\tconst parent = appDirectory(validated.artifact.appId);\n\t\t\tawait mkdir(parent, { recursive: true });\n\t\t\tconst staging = await mkdtemp(join(parent, '.stage-'));\n\t\t\tconst producerPath = join(\n\t\t\t\tstaging,\n\t\t\t\tvalidated.artifact.producer.module\n\t\t\t);\n\t\t\ttry {\n\t\t\t\tawait mkdir(resolvePath(producerPath, '..'), {\n\t\t\t\t\trecursive: true\n\t\t\t\t});\n\t\t\t\tawait Promise.all([\n\t\t\t\t\twriteFile(\n\t\t\t\t\t\tjoin(staging, ARTIFACT_FILE),\n\t\t\t\t\t\t`${JSON.stringify(validated.artifact, null, '\\t')}\\n`\n\t\t\t\t\t),\n\t\t\t\t\twriteFile(\n\t\t\t\t\t\tproducerPath,\n\t\t\t\t\t\tnew Uint8Array(await validated.producer.arrayBuffer())\n\t\t\t\t\t)\n\t\t\t\t]);\n\t\t\t\tawait rename(\n\t\t\t\t\tstaging,\n\t\t\t\t\treleaseDirectory(\n\t\t\t\t\t\tvalidated.artifact.appId,\n\t\t\t\t\t\tvalidated.artifact.releaseId\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\tawait rm(staging, { force: true, recursive: true });\n\t\t\t\tif (await acceptExistingRelease(error, validated.artifact))\n\t\t\t\t\treturn;\n\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t};\n};\n\nexport const verifyAbsoluteMobileCompatibilityProducer = async (\n\trelease: AbsoluteMobileStoredCompatibilityRelease,\n\tmaxProducerBytes = DEFAULT_MAX_PRODUCER_BYTES\n) => {\n\tconst { artifact, producer } = release;\n\tif (\n\t\tproducer.size !== artifact.producer.bytes ||\n\t\tproducer.size > maxProducerBytes\n\t) {\n\t\tthrow new TypeError(\n\t\t\t'Mobile compatibility producer size does not match its artifact.'\n\t\t);\n\t}\n\tif ((await hashBlob(producer)) !== artifact.producer.bundleHash) {\n\t\tthrow new TypeError(\n\t\t\t'Mobile compatibility producer hash does not match its artifact.'\n\t\t);\n\t}\n\n\treturn release;\n};\n",
|
|
10
17
|
"import { createHash } from 'node:crypto';\nimport type {\n\tAbsoluteMobilePageClient,\n\tAbsoluteMobilePageFramework,\n\tAbsoluteMobileUpgradeRequiredResult\n} from './pageProtocol';\n\nexport const ABSOLUTE_MOBILE_COMPATIBILITY_FORMAT = 1 as const;\nexport const ABSOLUTE_MOBILE_RETAINED_GENERATIONS = 3;\n\nexport type AbsoluteMobileCompatibilityPage = {\n\tbundleHash: string;\n\tbundlePath: string;\n\tcontract: string;\n\tframework: AbsoluteMobilePageFramework;\n\tpageId: string;\n\tpropsSchemaHash: string;\n\tstyleBundleHash?: string;\n\tstyleBundlePath?: string;\n};\n\nexport type AbsoluteMobileCompatibilityRoute = {\n\tmethod: 'GET' | 'HEAD';\n\tpageId: string;\n\tpattern: string;\n};\n\nexport type AbsoluteMobileCompatibilityProducer = {\n\tbundleHash: string;\n\tbytes: number;\n\texportName: string;\n\tmodule: string;\n};\n\nexport type AbsoluteMobileCompatibilityArtifactInput = {\n\tappBuild: string;\n\tappId: string;\n\tgeneration: number;\n\tpages: readonly AbsoluteMobileCompatibilityPage[];\n\tproducer: AbsoluteMobileCompatibilityProducer;\n\troutes: readonly AbsoluteMobileCompatibilityRoute[];\n\truntime: string;\n};\n\nexport type AbsoluteMobileCompatibilityArtifact = {\n\tappBuild: string;\n\tappId: string;\n\tformat: typeof ABSOLUTE_MOBILE_COMPATIBILITY_FORMAT;\n\tgeneration: number;\n\tpages: AbsoluteMobileCompatibilityPage[];\n\tproducer: AbsoluteMobileCompatibilityProducer;\n\treleaseId: string;\n\troutes: AbsoluteMobileCompatibilityRoute[];\n\truntime: string;\n};\n\nexport type AbsoluteMobileResolvedRelease =\n\t| {\n\t\t\tartifact: AbsoluteMobileCompatibilityArtifact;\n\t\t\tkind: 'retained';\n\t\t\tpage: AbsoluteMobileCompatibilityPage;\n\t }\n\t| {\n\t\t\tkind: 'upgrade-required';\n\t\t\tresult: AbsoluteMobileUpgradeRequiredResult;\n\t };\n\ntype CanonicalRecord = Record<string, unknown>;\ntype CanonicalValueNormalizer = (\n\tvalue: unknown,\n\tancestors: Set<object>\n) => unknown;\ntype CompatibilityArtifactContent = Omit<\n\tAbsoluteMobileCompatibilityArtifact,\n\t'releaseId'\n>;\n\nconst SHA_256 = 'sha256';\nconst RELEASE_ID_PREFIX = 'amc_';\nconst MODULE_SEGMENT_PARENT = '..';\nconst EXPORT_NAME_PATTERN = /^[A-Z_a-z]\\w*$/;\nconst frameworks = new Set<string>([\n\t'angular',\n\t'ember',\n\t'html',\n\t'htmx',\n\t'react',\n\t'svelte',\n\t'vue'\n]);\n\nconst isCanonicalRecord = (value: unknown): value is CanonicalRecord => {\n\tif (typeof value !== 'object' || value === null || Array.isArray(value)) {\n\t\treturn false;\n\t}\n\n\tconst prototype: unknown = Object.getPrototypeOf(value);\n\n\treturn prototype === Object.prototype || prototype === null;\n};\n\nconst enterCanonicalValue = (value: object, ancestors: Set<object>) => {\n\tif (ancestors.has(value)) {\n\t\tthrow new TypeError('Compatibility metadata cannot contain cycles.');\n\t}\n\tancestors.add(value);\n};\n\nconst normalizeCanonicalArray = (value: unknown[], ancestors: Set<object>) => {\n\tenterCanonicalValue(value, ancestors);\n\tconst normalized = value.map((item) =>\n\t\tnormalizeCanonicalValue(item, ancestors)\n\t);\n\tancestors.delete(value);\n\n\treturn normalized;\n};\n\nconst normalizeCanonicalRecord = (\n\tvalue: CanonicalRecord,\n\tancestors: Set<object>\n) => {\n\tenterCanonicalValue(value, ancestors);\n\tconst normalized = Object.fromEntries(\n\t\tObject.entries(value)\n\t\t\t.sort(([left], [right]) => left.localeCompare(right))\n\t\t\t.map(([key, item]) => [\n\t\t\t\tkey,\n\t\t\t\tnormalizeCanonicalValue(item, ancestors)\n\t\t\t])\n\t);\n\tancestors.delete(value);\n\n\treturn normalized;\n};\n\nconst normalizeCanonicalValue: CanonicalValueNormalizer = (\n\tvalue,\n\tancestors\n) => {\n\tif (\n\t\tvalue === null ||\n\t\ttypeof value === 'string' ||\n\t\ttypeof value === 'boolean'\n\t) {\n\t\treturn value;\n\t}\n\tif (typeof value === 'number' && Number.isFinite(value)) return value;\n\tif (Array.isArray(value)) return normalizeCanonicalArray(value, ancestors);\n\tif (isCanonicalRecord(value)) {\n\t\treturn normalizeCanonicalRecord(value, ancestors);\n\t}\n\n\tthrow new TypeError(\n\t\t'Compatibility metadata must contain only finite JSON values.'\n\t);\n};\n\nconst canonicalJson = (value: unknown) =>\n\tJSON.stringify(normalizeCanonicalValue(value, new Set<object>()));\n\nconst hashCanonicalValue = (value: unknown) =>\n\tcreateHash(SHA_256).update(canonicalJson(value)).digest('hex');\n\nconst requireNonEmpty = (value: string, field: string) => {\n\tif (!value.trim()) {\n\t\tthrow new TypeError(`${field} must not be empty.`);\n\t}\n\n\treturn value;\n};\n\nconst isPageFramework = (\n\tvalue: unknown\n): value is AbsoluteMobilePageFramework =>\n\ttypeof value === 'string' && frameworks.has(value);\n\nconst readString = (value: unknown, field: string) => {\n\tif (typeof value !== 'string') {\n\t\tthrow new TypeError(`${field} must be a string.`);\n\t}\n\n\treturn value;\n};\n\nconst parseCompatibilityPage = (value: unknown) => {\n\tif (!isCanonicalRecord(value) || !isPageFramework(value.framework)) {\n\t\tthrow new TypeError('Compatibility artifact contains an invalid page.');\n\t}\n\n\tconst styleBundleHash =\n\t\ttypeof value.styleBundleHash === 'string'\n\t\t\t? value.styleBundleHash\n\t\t\t: undefined;\n\tconst styleBundlePath =\n\t\ttypeof value.styleBundlePath === 'string'\n\t\t\t? value.styleBundlePath\n\t\t\t: undefined;\n\tif (Boolean(styleBundleHash) !== Boolean(styleBundlePath)) {\n\t\tthrow new TypeError(\n\t\t\t'Compatibility page style hash and path must be provided together.'\n\t\t);\n\t}\n\n\treturn {\n\t\tbundleHash: readString(value.bundleHash, 'page.bundleHash'),\n\t\tbundlePath: readString(value.bundlePath, 'page.bundlePath'),\n\t\tcontract: readString(value.contract, 'page.contract'),\n\t\tframework: value.framework,\n\t\tpageId: readString(value.pageId, 'page.pageId'),\n\t\tpropsSchemaHash: readString(\n\t\t\tvalue.propsSchemaHash,\n\t\t\t'page.propsSchemaHash'\n\t\t),\n\t\t...(styleBundleHash && styleBundlePath\n\t\t\t? { styleBundleHash, styleBundlePath }\n\t\t\t: {})\n\t} satisfies AbsoluteMobileCompatibilityPage;\n};\n\nconst parseCompatibilityRoute = (value: unknown) => {\n\tif (\n\t\t!isCanonicalRecord(value) ||\n\t\t(value.method !== 'GET' && value.method !== 'HEAD')\n\t) {\n\t\tthrow new TypeError(\n\t\t\t'Compatibility artifact contains an invalid route.'\n\t\t);\n\t}\n\n\treturn {\n\t\tmethod: value.method,\n\t\tpageId: readString(value.pageId, 'route.pageId'),\n\t\tpattern: readString(value.pattern, 'route.pattern')\n\t} satisfies AbsoluteMobileCompatibilityRoute;\n};\n\nconst parseCompatibilityProducer = (value: unknown) => {\n\tif (!isCanonicalRecord(value) || typeof value.bytes !== 'number') {\n\t\tthrow new TypeError(\n\t\t\t'Compatibility artifact contains an invalid producer.'\n\t\t);\n\t}\n\n\treturn {\n\t\tbundleHash: readString(value.bundleHash, 'producer.bundleHash'),\n\t\tbytes: value.bytes,\n\t\texportName: readString(value.exportName, 'producer.exportName'),\n\t\tmodule: readString(value.module, 'producer.module')\n\t} satisfies AbsoluteMobileCompatibilityProducer;\n};\n\nconst validateProducerModule = (module: string) => {\n\trequireNonEmpty(module, 'producer.module');\n\tconst segments = module.split('/');\n\tif (\n\t\tmodule.startsWith('/') ||\n\t\tmodule.includes('\\\\') ||\n\t\tsegments.includes(MODULE_SEGMENT_PARENT)\n\t) {\n\t\tthrow new TypeError('producer.module must be a safe relative path.');\n\t}\n\n\treturn module;\n};\n\nconst normalizePage = (\n\tpage: AbsoluteMobileCompatibilityPage\n): AbsoluteMobileCompatibilityPage => {\n\tif (Boolean(page.styleBundleHash) !== Boolean(page.styleBundlePath)) {\n\t\tthrow new TypeError(\n\t\t\t'Compatibility page style hash and path must be provided together.'\n\t\t);\n\t}\n\n\treturn {\n\t\tbundleHash: requireNonEmpty(page.bundleHash, 'page.bundleHash'),\n\t\tbundlePath: requireNonEmpty(page.bundlePath, 'page.bundlePath'),\n\t\tcontract: requireNonEmpty(page.contract, 'page.contract'),\n\t\tframework: page.framework,\n\t\tpageId: requireNonEmpty(page.pageId, 'page.pageId'),\n\t\tpropsSchemaHash: requireNonEmpty(\n\t\t\tpage.propsSchemaHash,\n\t\t\t'page.propsSchemaHash'\n\t\t),\n\t\t...(page.styleBundleHash && page.styleBundlePath\n\t\t\t? {\n\t\t\t\t\tstyleBundleHash: requireNonEmpty(\n\t\t\t\t\t\tpage.styleBundleHash,\n\t\t\t\t\t\t'page.styleBundleHash'\n\t\t\t\t\t),\n\t\t\t\t\tstyleBundlePath: requireNonEmpty(\n\t\t\t\t\t\tpage.styleBundlePath,\n\t\t\t\t\t\t'page.styleBundlePath'\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t: {})\n\t};\n};\n\nconst normalizeRoute = (\n\troute: AbsoluteMobileCompatibilityRoute\n): AbsoluteMobileCompatibilityRoute => {\n\tif (!route.pattern.startsWith('/')) {\n\t\tthrow new TypeError('route.pattern must start with /.');\n\t}\n\n\treturn {\n\t\tmethod: route.method,\n\t\tpageId: requireNonEmpty(route.pageId, 'route.pageId'),\n\t\tpattern: route.pattern\n\t};\n};\n\nconst assertUnique = (values: string[], field: string) => {\n\tif (new Set(values).size !== values.length) {\n\t\tthrow new TypeError(`${field} values must be unique.`);\n\t}\n};\n\nconst normalizeArtifactContent = (\n\tinput: AbsoluteMobileCompatibilityArtifactInput\n): CompatibilityArtifactContent => {\n\tif (!Number.isSafeInteger(input.generation) || input.generation < 1) {\n\t\tthrow new TypeError('generation must be a positive safe integer.');\n\t}\n\tif (\n\t\t!Number.isSafeInteger(input.producer.bytes) ||\n\t\tinput.producer.bytes < 1\n\t) {\n\t\tthrow new TypeError('producer.bytes must be a positive safe integer.');\n\t}\n\n\tconst pages = input.pages\n\t\t.map(normalizePage)\n\t\t.sort((left, right) => left.pageId.localeCompare(right.pageId));\n\tconst routes = input.routes\n\t\t.map(normalizeRoute)\n\t\t.sort((left, right) =>\n\t\t\t`${left.pattern}:${left.method}`.localeCompare(\n\t\t\t\t`${right.pattern}:${right.method}`\n\t\t\t)\n\t\t);\n\tassertUnique(\n\t\tpages.map(({ pageId }) => pageId),\n\t\t'page.pageId'\n\t);\n\tassertUnique(\n\t\troutes.map(({ method, pattern }) => `${method}:${pattern}`),\n\t\t'route method and pattern'\n\t);\n\tconst pageIds = new Set(pages.map(({ pageId }) => pageId));\n\tconst missingPage = routes.find(({ pageId }) => !pageIds.has(pageId));\n\tif (missingPage) {\n\t\tthrow new TypeError(\n\t\t\t`Route ${missingPage.pattern} references unknown page ${missingPage.pageId}.`\n\t\t);\n\t}\n\tif (!EXPORT_NAME_PATTERN.test(input.producer.exportName)) {\n\t\tthrow new TypeError(\n\t\t\t'producer.exportName must be a JavaScript identifier.'\n\t\t);\n\t}\n\n\treturn {\n\t\tappBuild: requireNonEmpty(input.appBuild, 'appBuild'),\n\t\tappId: requireNonEmpty(input.appId, 'appId'),\n\t\tformat: ABSOLUTE_MOBILE_COMPATIBILITY_FORMAT,\n\t\tgeneration: input.generation,\n\t\tpages,\n\t\tproducer: {\n\t\t\tbundleHash: requireNonEmpty(\n\t\t\t\tinput.producer.bundleHash,\n\t\t\t\t'producer.bundleHash'\n\t\t\t),\n\t\t\tbytes: input.producer.bytes,\n\t\t\texportName: input.producer.exportName,\n\t\t\tmodule: validateProducerModule(input.producer.module)\n\t\t},\n\t\troutes,\n\t\truntime: requireNonEmpty(input.runtime, 'runtime')\n\t};\n};\n\nexport const createAbsoluteMobileCompatibilityArtifact = (\n\tinput: AbsoluteMobileCompatibilityArtifactInput\n) => {\n\tconst content = normalizeArtifactContent(input);\n\n\treturn {\n\t\t...content,\n\t\treleaseId: `${RELEASE_ID_PREFIX}${hashCanonicalValue(content)}`\n\t} satisfies AbsoluteMobileCompatibilityArtifact;\n};\n\nexport const hashAbsoluteMobilePropsSchema = (schema: unknown) =>\n\thashCanonicalValue(schema);\n\nexport const parseAbsoluteMobileCompatibilityArtifact = (value: unknown) => {\n\tif (\n\t\t!isCanonicalRecord(value) ||\n\t\tvalue.format !== ABSOLUTE_MOBILE_COMPATIBILITY_FORMAT ||\n\t\ttypeof value.generation !== 'number' ||\n\t\t!Array.isArray(value.pages) ||\n\t\t!Array.isArray(value.routes)\n\t) {\n\t\tthrow new TypeError('Invalid mobile compatibility artifact.');\n\t}\n\n\tconst releaseId = readString(value.releaseId, 'releaseId');\n\tconst artifact = createAbsoluteMobileCompatibilityArtifact({\n\t\tappBuild: readString(value.appBuild, 'appBuild'),\n\t\tappId: readString(value.appId, 'appId'),\n\t\tgeneration: value.generation,\n\t\tpages: value.pages.map(parseCompatibilityPage),\n\t\tproducer: parseCompatibilityProducer(value.producer),\n\t\troutes: value.routes.map(parseCompatibilityRoute),\n\t\truntime: readString(value.runtime, 'runtime')\n\t});\n\tif (artifact.releaseId !== releaseId) {\n\t\tthrow new TypeError('Mobile compatibility artifact integrity failed.');\n\t}\n\n\treturn artifact;\n};\n\nexport const resolveAbsoluteMobileCompatibilityRelease = (\n\tclient: AbsoluteMobilePageClient,\n\tartifacts: readonly AbsoluteMobileCompatibilityArtifact[]\n): AbsoluteMobileResolvedRelease => {\n\tconst artifact = artifacts.find(\n\t\t(candidate) =>\n\t\t\tcandidate.appBuild === client.appBuild &&\n\t\t\tcandidate.runtime === client.runtime\n\t);\n\tif (!artifact) {\n\t\treturn {\n\t\t\tkind: 'upgrade-required',\n\t\t\tresult: {\n\t\t\t\tkind: 'upgrade-required',\n\t\t\t\tpageId: client.pageId,\n\t\t\t\treason: 'app-release'\n\t\t\t}\n\t\t};\n\t}\n\n\tconst page = artifact.pages.find(\n\t\t(candidate) =>\n\t\t\tcandidate.pageId === client.pageId &&\n\t\t\tcandidate.bundleHash === client.pageBundle &&\n\t\t\tclient.pageContracts.includes(candidate.contract)\n\t);\n\tif (!page) {\n\t\treturn {\n\t\t\tkind: 'upgrade-required',\n\t\t\tresult: {\n\t\t\t\tkind: 'upgrade-required',\n\t\t\t\tpageId: client.pageId,\n\t\t\t\treason: 'page-contract',\n\t\t\t\tsupportedContracts: artifact.pages\n\t\t\t\t\t.filter(({ pageId }) => pageId === client.pageId)\n\t\t\t\t\t.map(({ contract }) => contract)\n\t\t\t}\n\t\t};\n\t}\n\n\treturn { artifact, kind: 'retained', page };\n};\n\nexport const retainAbsoluteMobileCompatibilityArtifacts = (\n\tartifacts: readonly AbsoluteMobileCompatibilityArtifact[]\n) => {\n\tconst appIds = new Set(artifacts.map(({ appId }) => appId));\n\tif (appIds.size > 1) {\n\t\tthrow new TypeError(\n\t\t\t'Cannot retain compatibility artifacts for multiple apps.'\n\t\t);\n\t}\n\tassertUnique(\n\t\tartifacts.map(({ appBuild }) => appBuild),\n\t\t'appBuild'\n\t);\n\tassertUnique(\n\t\tartifacts.map(({ generation }) => String(generation)),\n\t\t'generation'\n\t);\n\n\treturn [...artifacts]\n\t\t.sort((left, right) => right.generation - left.generation)\n\t\t.slice(0, ABSOLUTE_MOBILE_RETAINED_GENERATIONS);\n};\n",
|
|
11
|
-
"import { createHash } from 'node:crypto';\nimport {\n\taccess,\n\tcopyFile,\n\tmkdir,\n\tmkdtemp,\n\treadFile,\n\trename,\n\trm,\n\tstat,\n\twriteFile\n} from 'node:fs/promises';\nimport { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';\nimport {\n\tabsoluteManagedAndroidSdkRoot,\n\tdetectAbsoluteMobileHost,\n\ttype AbsoluteMobileHost\n} from './emulatorDoctor';\nimport {\n\tbuildAbsoluteAndroidGradleArtifact,\n\tfingerprintAbsoluteAndroidNativeProject,\n\ttype AbsoluteAndroidCommandOptions,\n\ttype AbsoluteAndroidCommandResult\n} from './androidEmulatorController';\nimport type { NormalizedAbsoluteMobileConfig } from './config';\n\nexport const ABSOLUTE_ANDROID_RELEASE_FORMAT = 1 as const;\n\nexport type AbsoluteAndroidReleaseMetadata = {\n\tappBuild: string;\n\tappId: string;\n\tartifact: string;\n\tbytes: number;\n\tengine: 'capacitor';\n\tformat: typeof ABSOLUTE_ANDROID_RELEASE_FORMAT;\n\tplatform: 'android';\n\treleaseId: string;\n\truntime: string;\n\tsha256: string;\n\tsigned: boolean;\n\ttype: 'aab';\n\tversionCode?: number;\n};\n\ntype MobileClientManifest = {\n\tappBuild: string;\n\tappId: string;\n\truntime: string;\n};\n\nexport type BuildAbsoluteAndroidReleaseOptions = {\n\tallowUnsigned?: boolean;\n\tandroidRoot?: string;\n\tcapture?: (\n\t\tcommand: string[],\n\t\toptions?: AbsoluteAndroidCommandOptions\n\t) => AbsoluteAndroidCommandResult;\n\tconfig: NormalizedAbsoluteMobileConfig;\n\thost?: AbsoluteMobileHost;\n\tjarsigner?: string | null;\n\toutputDirectory?: string;\n\tprojectRoot: string;\n\trun?: (\n\t\tcommand: string[],\n\t\toptions?: AbsoluteAndroidCommandOptions\n\t) => Promise<number>;\n\tprepareVersionCode?: (buildIdentity: string) => Promise<number>;\n\tversionCode?: number;\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n\ttypeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst requireManifest = (value: unknown): MobileClientManifest => {\n\tif (\n\t\t!isRecord(value) ||\n\t\ttypeof value.appBuild !== 'string' ||\n\t\ttypeof value.appId !== 'string' ||\n\t\ttypeof value.runtime !== 'string'\n\t) {\n\t\tthrow new TypeError('Invalid embedded AbsoluteJS mobile manifest.');\n\t}\n\n\treturn {\n\t\tappBuild: value.appBuild,\n\t\tappId: value.appId,\n\t\truntime: value.runtime\n\t};\n};\n\nconst pathExists = async (path: string) => {\n\ttry {\n\t\tawait access(path);\n\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n};\n\nconst defaultCapture = (\n\tcommand: string[],\n\toptions: AbsoluteAndroidCommandOptions = {}\n) => {\n\ttry {\n\t\tconst result = Bun.spawnSync(command, {\n\t\t\tcwd: options.cwd,\n\t\t\tenv: options.env,\n\t\t\tstderr: 'pipe',\n\t\t\tstdin: 'ignore',\n\t\t\tstdout: 'pipe'\n\t\t});\n\n\t\treturn {\n\t\t\texitCode: result.exitCode,\n\t\t\tstderr: result.stderr.toString(),\n\t\t\tstdout: result.stdout.toString()\n\t\t};\n\t} catch (error) {\n\t\treturn {\n\t\t\texitCode: 1,\n\t\t\tstderr: error instanceof Error ? error.message : String(error),\n\t\t\tstdout: ''\n\t\t};\n\t}\n};\n\nconst verifyAabSignature = (\n\tartifactPath: string,\n\tcapture: NonNullable<BuildAbsoluteAndroidReleaseOptions['capture']>,\n\tjarsigner: string | null | undefined\n) => {\n\tconst executable =\n\t\tjarsigner === undefined ? Bun.which('jarsigner') : jarsigner;\n\tif (!executable) return null;\n\tconst result = capture([\n\t\texecutable,\n\t\t'-J-Duser.language=en',\n\t\t'-J-Duser.country=US',\n\t\t'-verify',\n\t\tartifactPath\n\t]);\n\n\treturn result.exitCode === 0 && /jar verified/iu.test(result.stdout);\n};\n\nconst sha256File = async (path: string) =>\n\tcreateHash('sha256')\n\t\t.update(await readFile(path))\n\t\t.digest('hex');\n\nconst safeOutputDirectory = (projectRoot: string, requested?: string) => {\n\tconst root = resolve(projectRoot);\n\tconst output = resolve(\n\t\troot,\n\t\trequested ?? '.absolutejs/mobile/releases/android'\n\t);\n\tconst projectRelative = relative(root, output);\n\tif (\n\t\tprojectRelative === '..' ||\n\t\tprojectRelative.startsWith(`..${sep}`) ||\n\t\tisAbsolute(projectRelative)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t'mobile build --outdir must remain inside the project.'\n\t\t);\n\t}\n\n\treturn output;\n};\n\nconst installRelease = async (\n\tartifactPath: string,\n\tmetadata: Omit<AbsoluteAndroidReleaseMetadata, 'artifact'>,\n\toutputRoot: string\n) => {\n\tconst releaseRoot = join(outputRoot, metadata.releaseId);\n\tconst artifactName = 'app-release.aab';\n\tconst destination = join(releaseRoot, artifactName);\n\tif (await pathExists(releaseRoot)) {\n\t\tconst existing = requireManifestIdentity(\n\t\t\tJSON.parse(\n\t\t\t\tawait readFile(join(releaseRoot, 'release.json'), 'utf8')\n\t\t\t),\n\t\t\tmetadata\n\t\t);\n\t\tconst [installedBytes, installedSha256] = await Promise.all([\n\t\t\tstat(destination).then(({ size }) => size),\n\t\t\tsha256File(destination)\n\t\t]);\n\t\tif (\n\t\t\tinstalledBytes !== metadata.bytes ||\n\t\t\tinstalledSha256 !== metadata.sha256\n\t\t) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`Immutable Android release ${metadata.releaseId} artifact is missing or modified.`\n\t\t\t);\n\t\t}\n\n\t\treturn { artifactPath: destination, metadata: existing, releaseRoot };\n\t}\n\tawait mkdir(dirname(releaseRoot), { recursive: true });\n\tconst staging = await mkdtemp(\n\t\tjoin(dirname(releaseRoot), '.android-stage-')\n\t);\n\ttry {\n\t\tawait copyFile(artifactPath, join(staging, artifactName));\n\t\tconst complete = {\n\t\t\t...metadata,\n\t\t\tartifact: artifactName\n\t\t} satisfies AbsoluteAndroidReleaseMetadata;\n\t\tawait writeFile(\n\t\t\tjoin(staging, 'release.json'),\n\t\t\t`${JSON.stringify(complete, null, '\\t')}\\n`,\n\t\t\t{ flag: 'wx' }\n\t\t);\n\t\tawait rename(staging, releaseRoot);\n\n\t\treturn { artifactPath: destination, metadata: complete, releaseRoot };\n\t} finally {\n\t\tawait rm(staging, { force: true, recursive: true }).catch(\n\t\t\t() => undefined\n\t\t);\n\t}\n};\n\nconst requireManifestIdentity = (\n\tvalue: unknown,\n\texpected: Omit<AbsoluteAndroidReleaseMetadata, 'artifact'>\n) => {\n\tif (!isRecord(value)) {\n\t\tthrow new TypeError('Existing Android release metadata is invalid.');\n\t}\n\tconst { artifact } = value;\n\tif (\n\t\tartifact !== 'app-release.aab' ||\n\t\tObject.entries(expected).some(\n\t\t\t([key, expectedValue]) => Reflect.get(value, key) !== expectedValue\n\t\t)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t`Immutable Android release ${expected.releaseId} does not match its content.`\n\t\t);\n\t}\n\n\treturn { ...expected, artifact } satisfies AbsoluteAndroidReleaseMetadata;\n};\n\nexport const buildAbsoluteAndroidRelease = async (\n\toptions: BuildAbsoluteAndroidReleaseOptions\n) => {\n\tif (options.versionCode !== undefined && options.prepareVersionCode) {\n\t\tthrow new TypeError(\n\t\t\t'Android release versionCode and prepareVersionCode cannot be combined.'\n\t\t);\n\t}\n\tif (\n\t\toptions.versionCode !== undefined &&\n\t\t(!Number.isSafeInteger(options.versionCode) ||\n\t\t\toptions.versionCode < 1 ||\n\t\t\toptions.versionCode > 2_100_000_000)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t'Android versionCode must be an integer from 1 through 2100000000.'\n\t\t);\n\t}\n\tconst projectRoot = resolve(options.projectRoot);\n\tconst host = options.host ?? detectAbsoluteMobileHost();\n\tconst androidRoot =\n\t\toptions.androidRoot ??\n\t\tprocess.env.ANDROID_HOME ??\n\t\tprocess.env.ANDROID_SDK_ROOT ??\n\t\tabsoluteManagedAndroidSdkRoot(host);\n\tconst nativeDirectory = join(\n\t\toptions.config.nativeProjectDirectory,\n\t\t'android'\n\t);\n\tconst manifest = requireManifest(\n\t\tJSON.parse(\n\t\t\tawait readFile(\n\t\t\t\tjoin(\n\t\t\t\t\toptions.config.bundleDirectory,\n\t\t\t\t\t'absolute-mobile-manifest.json'\n\t\t\t\t),\n\t\t\t\t'utf8'\n\t\t\t)\n\t\t)\n\t);\n\tif (manifest.appId !== options.config.appId) {\n\t\tthrow new TypeError(\n\t\t\t'Embedded mobile manifest appId does not match mobile.appId.'\n\t\t);\n\t}\n\tlet { versionCode } = options;\n\tif (options.prepareVersionCode) {\n\t\tconst nativeFingerprint = await fingerprintAbsoluteAndroidNativeProject(\n\t\t\t{ nativeDirectory }\n\t\t);\n\t\tconst buildIdentity = createHash('sha256')\n\t\t\t.update(`${manifest.appBuild}\\0${nativeFingerprint}`)\n\t\t\t.digest('hex');\n\t\tversionCode = await options.prepareVersionCode(buildIdentity);\n\t}\n\tif (\n\t\tversionCode !== undefined &&\n\t\t(!Number.isSafeInteger(versionCode) ||\n\t\t\tversionCode < 1 ||\n\t\t\tversionCode > 2_100_000_000)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t'Android versionCode must be an integer from 1 through 2100000000.'\n\t\t);\n\t}\n\tconst { artifactPath } = await buildAbsoluteAndroidGradleArtifact({\n\t\tcapture: options.capture,\n\t\tgradleArguments:\n\t\t\tversionCode === undefined\n\t\t\t\t? []\n\t\t\t\t: [`-Pandroid.injected.version.code=${versionCode}`],\n\t\tproject: {\n\t\t\tandroidRoot,\n\t\t\tconfig: options.config,\n\t\t\thost,\n\t\t\tnativeDirectory,\n\t\t\tprojectRoot\n\t\t},\n\t\trun: options.run,\n\t\ttask: 'bundleRelease'\n\t});\n\tif (!(await pathExists(artifactPath))) {\n\t\tthrow new TypeError(\n\t\t\t`Android Gradle did not produce the expected App Bundle: ${artifactPath}`\n\t\t);\n\t}\n\tconst capture = options.capture ?? defaultCapture;\n\tconst signed = verifyAabSignature(artifactPath, capture, options.jarsigner);\n\tif (signed === null && !options.allowUnsigned) {\n\t\tthrow new TypeError(\n\t\t\t'Could not verify the Android App Bundle signature because jarsigner is unavailable. Install a JDK, or use --unsigned only for a non-publishable build.'\n\t\t);\n\t}\n\tif (!signed && !options.allowUnsigned) {\n\t\tthrow new TypeError(\n\t\t\t'Android Gradle produced an unsigned App Bundle. Configure the release signingConfig in the source-owned Android project (prefer external Gradle properties), or pass --unsigned only for a non-publishable build.'\n\t\t);\n\t}\n\tconst [bytes, sha256] = await Promise.all([\n\t\tstat(artifactPath).then(({ size }) => size),\n\t\tsha256File(artifactPath)\n\t]);\n\tconst releaseId = `amobile_android_${sha256}`;\n\tconst metadata = {\n\t\tappBuild: manifest.appBuild,\n\t\tappId: manifest.appId,\n\t\tbytes,\n\t\tengine: 'capacitor',\n\t\tformat: ABSOLUTE_ANDROID_RELEASE_FORMAT,\n\t\tplatform: 'android',\n\t\treleaseId,\n\t\truntime: manifest.runtime,\n\t\tsha256,\n\t\tsigned: signed === true,\n\t\ttype: 'aab',\n\t\t...(versionCode === undefined ? {} : { versionCode })\n\t} satisfies Omit<AbsoluteAndroidReleaseMetadata, 'artifact'>;\n\n\treturn installRelease(\n\t\tartifactPath,\n\t\tmetadata,\n\t\tsafeOutputDirectory(projectRoot, options.outputDirectory)\n\t);\n};\n",
|
|
18
|
+
"import { createHash } from 'node:crypto';\nimport {\n\taccess,\n\tcopyFile,\n\tmkdir,\n\tmkdtemp,\n\treadFile,\n\trealpath,\n\trename,\n\trm,\n\tstat,\n\twriteFile\n} from 'node:fs/promises';\nimport { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';\nimport {\n\tabsoluteManagedAndroidSdkRoot,\n\tdetectAbsoluteMobileHost,\n\ttype AbsoluteMobileHost\n} from './emulatorDoctor';\nimport {\n\tbuildAbsoluteAndroidGradleArtifact,\n\tfingerprintAbsoluteAndroidNativeProject,\n\ttype AbsoluteAndroidCommandOptions,\n\ttype AbsoluteAndroidCommandResult\n} from './androidEmulatorController';\nimport type { NormalizedAbsoluteMobileConfig } from './config';\n\nexport const ABSOLUTE_ANDROID_RELEASE_FORMAT = 1 as const;\n\nexport type AbsoluteAndroidReleaseMetadata = {\n\tappBuild: string;\n\tappId: string;\n\tartifact: string;\n\tbytes: number;\n\tengine: 'capacitor' | 'expo';\n\tformat: typeof ABSOLUTE_ANDROID_RELEASE_FORMAT;\n\tplatform: 'android';\n\treleaseId: string;\n\truntime: string;\n\tsha256: string;\n\tsigned: boolean;\n\ttype: 'aab';\n\tversionCode?: number;\n};\n\ntype MobileClientManifest = {\n\tappBuild: string;\n\tappId: string;\n\truntime: string;\n};\n\nexport type BuildAbsoluteAndroidReleaseOptions = {\n\tallowUnsigned?: boolean;\n\tandroidRoot?: string;\n\tcapture?: (\n\t\tcommand: string[],\n\t\toptions?: AbsoluteAndroidCommandOptions\n\t) => AbsoluteAndroidCommandResult;\n\tconfig: NormalizedAbsoluteMobileConfig;\n\tenv?: Record<string, string | undefined>;\n\thost?: AbsoluteMobileHost;\n\tjarsigner?: string | null;\n\toutputDirectory?: string;\n\tprojectRoot: string;\n\trun?: (\n\t\tcommand: string[],\n\t\toptions?: AbsoluteAndroidCommandOptions\n\t) => Promise<number>;\n\tprepareVersionCode?: (buildIdentity: string) => Promise<number>;\n\tsigning?: {\n\t\tkeyAlias: string;\n\t\tkeyPasswordEnvironment: string;\n\t\tkeystorePath: string;\n\t\tstorePasswordEnvironment: string;\n\t};\n\tversionCode?: number;\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n\ttypeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst requireManifest = (value: unknown): MobileClientManifest => {\n\tif (\n\t\t!isRecord(value) ||\n\t\ttypeof value.appBuild !== 'string' ||\n\t\ttypeof value.appId !== 'string' ||\n\t\ttypeof value.runtime !== 'string'\n\t) {\n\t\tthrow new TypeError('Invalid embedded AbsoluteJS mobile manifest.');\n\t}\n\n\treturn {\n\t\tappBuild: value.appBuild,\n\t\tappId: value.appId,\n\t\truntime: value.runtime\n\t};\n};\n\nconst pathExists = async (path: string) => {\n\ttry {\n\t\tawait access(path);\n\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n};\n\nconst defaultCapture = (\n\tcommand: string[],\n\toptions: AbsoluteAndroidCommandOptions = {}\n) => {\n\ttry {\n\t\tconst result = Bun.spawnSync(command, {\n\t\t\tcwd: options.cwd,\n\t\t\tenv: options.env,\n\t\t\tstderr: 'pipe',\n\t\t\tstdin: 'ignore',\n\t\t\tstdout: 'pipe'\n\t\t});\n\n\t\treturn {\n\t\t\texitCode: result.exitCode,\n\t\t\tstderr: result.stderr.toString(),\n\t\t\tstdout: result.stdout.toString()\n\t\t};\n\t} catch (error) {\n\t\treturn {\n\t\t\texitCode: 1,\n\t\t\tstderr: error instanceof Error ? error.message : String(error),\n\t\t\tstdout: ''\n\t\t};\n\t}\n};\n\nconst verifyAabSignature = (\n\tartifactPath: string,\n\tcapture: NonNullable<BuildAbsoluteAndroidReleaseOptions['capture']>,\n\tjarsigner: string | null | undefined\n) => {\n\tconst executable =\n\t\tjarsigner === undefined ? Bun.which('jarsigner') : jarsigner;\n\tif (!executable) return null;\n\tconst result = capture([\n\t\texecutable,\n\t\t'-J-Duser.language=en',\n\t\t'-J-Duser.country=US',\n\t\t'-verify',\n\t\tartifactPath\n\t]);\n\n\treturn result.exitCode === 0 && /jar verified/iu.test(result.stdout);\n};\n\nconst signAab = (\n\tartifactPath: string,\n\tcapture: NonNullable<BuildAbsoluteAndroidReleaseOptions['capture']>,\n\tjarsigner: string,\n\tsigning: NonNullable<BuildAbsoluteAndroidReleaseOptions['signing']>\n) => {\n\tconst result = capture([\n\t\tjarsigner,\n\t\t'-keystore',\n\t\tsigning.keystorePath,\n\t\t'-storepass:env',\n\t\tsigning.storePasswordEnvironment,\n\t\t'-keypass:env',\n\t\tsigning.keyPasswordEnvironment,\n\t\tartifactPath,\n\t\tsigning.keyAlias\n\t]);\n\tif (result.exitCode !== 0)\n\t\tthrow new TypeError(\n\t\t\t'jarsigner could not sign the Android App Bundle with the configured CI identity.'\n\t\t);\n};\n\nconst sha256File = async (path: string) =>\n\tcreateHash('sha256')\n\t\t.update(await readFile(path))\n\t\t.digest('hex');\n\nconst fingerprintExpoAndroidProject = async (nativeDirectory: string) => {\n\tconst root = await realpath(nativeDirectory);\n\tconst files = await Array.fromAsync(\n\t\tnew Bun.Glob('**/*').scan({ cwd: root, onlyFiles: true })\n\t);\n\tconst records = await Promise.all(\n\t\tfiles\n\t\t\t.filter((path) => {\n\t\t\t\tconst parts = path.replaceAll('\\\\', '/').split('/');\n\n\t\t\t\treturn !parts.includes('.gradle') && !parts.includes('build');\n\t\t\t})\n\t\t\t.sort()\n\t\t\t.map(async (path) => {\n\t\t\t\tconst contents = await readFile(join(root, path));\n\n\t\t\t\treturn `${path.replaceAll('\\\\', '/')}\\0${createHash('sha256').update(contents).digest('hex')}\\0`;\n\t\t\t})\n\t);\n\n\treturn createHash('sha256').update(records.join('')).digest('hex');\n};\n\nconst safeOutputDirectory = (projectRoot: string, requested?: string) => {\n\tconst root = resolve(projectRoot);\n\tconst output = resolve(\n\t\troot,\n\t\trequested ?? '.absolutejs/mobile/releases/android'\n\t);\n\tconst projectRelative = relative(root, output);\n\tif (\n\t\tprojectRelative === '..' ||\n\t\tprojectRelative.startsWith(`..${sep}`) ||\n\t\tisAbsolute(projectRelative)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t'mobile build --outdir must remain inside the project.'\n\t\t);\n\t}\n\n\treturn output;\n};\n\nconst installRelease = async (\n\tartifactPath: string,\n\tmetadata: Omit<AbsoluteAndroidReleaseMetadata, 'artifact'>,\n\toutputRoot: string\n) => {\n\tconst releaseRoot = join(outputRoot, metadata.releaseId);\n\tconst artifactName = 'app-release.aab';\n\tconst destination = join(releaseRoot, artifactName);\n\tif (await pathExists(releaseRoot)) {\n\t\tconst existing = requireManifestIdentity(\n\t\t\tJSON.parse(\n\t\t\t\tawait readFile(join(releaseRoot, 'release.json'), 'utf8')\n\t\t\t),\n\t\t\tmetadata\n\t\t);\n\t\tconst [installedBytes, installedSha256] = await Promise.all([\n\t\t\tstat(destination).then(({ size }) => size),\n\t\t\tsha256File(destination)\n\t\t]);\n\t\tif (\n\t\t\tinstalledBytes !== metadata.bytes ||\n\t\t\tinstalledSha256 !== metadata.sha256\n\t\t) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`Immutable Android release ${metadata.releaseId} artifact is missing or modified.`\n\t\t\t);\n\t\t}\n\n\t\treturn { artifactPath: destination, metadata: existing, releaseRoot };\n\t}\n\tawait mkdir(dirname(releaseRoot), { recursive: true });\n\tconst staging = await mkdtemp(\n\t\tjoin(dirname(releaseRoot), '.android-stage-')\n\t);\n\ttry {\n\t\tawait copyFile(artifactPath, join(staging, artifactName));\n\t\tconst complete = {\n\t\t\t...metadata,\n\t\t\tartifact: artifactName\n\t\t} satisfies AbsoluteAndroidReleaseMetadata;\n\t\tawait writeFile(\n\t\t\tjoin(staging, 'release.json'),\n\t\t\t`${JSON.stringify(complete, null, '\\t')}\\n`,\n\t\t\t{ flag: 'wx' }\n\t\t);\n\t\tawait rename(staging, releaseRoot);\n\n\t\treturn { artifactPath: destination, metadata: complete, releaseRoot };\n\t} finally {\n\t\tawait rm(staging, { force: true, recursive: true }).catch(\n\t\t\t() => undefined\n\t\t);\n\t}\n};\n\nconst requireManifestIdentity = (\n\tvalue: unknown,\n\texpected: Omit<AbsoluteAndroidReleaseMetadata, 'artifact'>\n) => {\n\tif (!isRecord(value)) {\n\t\tthrow new TypeError('Existing Android release metadata is invalid.');\n\t}\n\tconst { artifact } = value;\n\tif (\n\t\tartifact !== 'app-release.aab' ||\n\t\tObject.entries(expected).some(\n\t\t\t([key, expectedValue]) => Reflect.get(value, key) !== expectedValue\n\t\t)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t`Immutable Android release ${expected.releaseId} does not match its content.`\n\t\t);\n\t}\n\n\treturn { ...expected, artifact } satisfies AbsoluteAndroidReleaseMetadata;\n};\n\nexport const buildAbsoluteAndroidRelease = async (\n\toptions: BuildAbsoluteAndroidReleaseOptions\n) => {\n\tif (options.versionCode !== undefined && options.prepareVersionCode) {\n\t\tthrow new TypeError(\n\t\t\t'Android release versionCode and prepareVersionCode cannot be combined.'\n\t\t);\n\t}\n\tif (\n\t\toptions.versionCode !== undefined &&\n\t\t(!Number.isSafeInteger(options.versionCode) ||\n\t\t\toptions.versionCode < 1 ||\n\t\t\toptions.versionCode > 2_100_000_000)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t'Android versionCode must be an integer from 1 through 2100000000.'\n\t\t);\n\t}\n\tconst projectRoot = resolve(options.projectRoot);\n\tconst host = options.host ?? detectAbsoluteMobileHost();\n\tif (options.config.engine === 'expo' && host === 'wsl') {\n\t\tthrow new TypeError(\n\t\t\t'Expo Android production builds from WSL are not available yet. Run the generated CI workflow on Linux or build from native Windows while the WSL projection is completed.'\n\t\t);\n\t}\n\tconst androidRoot =\n\t\toptions.androidRoot ??\n\t\tprocess.env.ANDROID_HOME ??\n\t\tprocess.env.ANDROID_SDK_ROOT ??\n\t\tabsoluteManagedAndroidSdkRoot(host);\n\tconst nativeDirectory = join(\n\t\toptions.config.nativeProjectDirectory,\n\t\t'android'\n\t);\n\tconst manifest = requireManifest(\n\t\tJSON.parse(\n\t\t\tawait readFile(\n\t\t\t\tjoin(\n\t\t\t\t\toptions.config.bundleDirectory,\n\t\t\t\t\t'absolute-mobile-manifest.json'\n\t\t\t\t),\n\t\t\t\t'utf8'\n\t\t\t)\n\t\t)\n\t);\n\tif (manifest.appId !== options.config.appId) {\n\t\tthrow new TypeError(\n\t\t\t'Embedded mobile manifest appId does not match mobile.appId.'\n\t\t);\n\t}\n\tlet { versionCode } = options;\n\tif (options.prepareVersionCode) {\n\t\tconst nativeFingerprint =\n\t\t\toptions.config.engine === 'expo'\n\t\t\t\t? await fingerprintExpoAndroidProject(nativeDirectory)\n\t\t\t\t: await fingerprintAbsoluteAndroidNativeProject({\n\t\t\t\t\t\tnativeDirectory\n\t\t\t\t\t});\n\t\tconst buildIdentity = createHash('sha256')\n\t\t\t.update(`${manifest.appBuild}\\0${nativeFingerprint}`)\n\t\t\t.digest('hex');\n\t\tversionCode = await options.prepareVersionCode(buildIdentity);\n\t}\n\tif (\n\t\tversionCode !== undefined &&\n\t\t(!Number.isSafeInteger(versionCode) ||\n\t\t\tversionCode < 1 ||\n\t\t\tversionCode > 2_100_000_000)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t'Android versionCode must be an integer from 1 through 2100000000.'\n\t\t);\n\t}\n\tconst { artifactPath } = await buildAbsoluteAndroidGradleArtifact({\n\t\tcapture: options.capture,\n\t\tenv: options.env,\n\t\tgradleArguments:\n\t\t\tversionCode === undefined\n\t\t\t\t? []\n\t\t\t\t: [`-Pandroid.injected.version.code=${versionCode}`],\n\t\tproject: {\n\t\t\tandroidRoot,\n\t\t\tconfig: options.config,\n\t\t\thost,\n\t\t\tnativeDirectory,\n\t\t\tprojectRoot\n\t\t},\n\t\trun: options.run,\n\t\ttask: 'bundleRelease'\n\t});\n\tif (!(await pathExists(artifactPath))) {\n\t\tthrow new TypeError(\n\t\t\t`Android Gradle did not produce the expected App Bundle: ${artifactPath}`\n\t\t);\n\t}\n\tconst capture = options.capture ?? defaultCapture;\n\tconst jarsigner =\n\t\toptions.jarsigner === undefined\n\t\t\t? Bun.which('jarsigner')\n\t\t\t: options.jarsigner;\n\tlet signed = verifyAabSignature(artifactPath, capture, jarsigner);\n\tif (signed === false && options.signing) {\n\t\tif (!jarsigner)\n\t\t\tthrow new TypeError(\n\t\t\t\t'Could not sign the Android App Bundle because jarsigner is unavailable.'\n\t\t\t);\n\t\tsignAab(artifactPath, capture, jarsigner, options.signing);\n\t\tsigned = verifyAabSignature(artifactPath, capture, jarsigner);\n\t\tif (!signed)\n\t\t\tthrow new TypeError(\n\t\t\t\t'Android App Bundle signature verification failed after CI signing.'\n\t\t\t);\n\t}\n\tif (signed === null && !options.allowUnsigned) {\n\t\tthrow new TypeError(\n\t\t\t'Could not verify the Android App Bundle signature because jarsigner is unavailable. Install a JDK, or use --unsigned only for a non-publishable build.'\n\t\t);\n\t}\n\tif (!signed && !options.allowUnsigned) {\n\t\tthrow new TypeError(\n\t\t\t'Android Gradle produced an unsigned App Bundle. Configure the release signingConfig in the source-owned Android project (prefer external Gradle properties), or pass --unsigned only for a non-publishable build.'\n\t\t);\n\t}\n\tconst [bytes, sha256] = await Promise.all([\n\t\tstat(artifactPath).then(({ size }) => size),\n\t\tsha256File(artifactPath)\n\t]);\n\tconst releaseId = `amobile_android_${sha256}`;\n\tconst metadata = {\n\t\tappBuild: manifest.appBuild,\n\t\tappId: manifest.appId,\n\t\tbytes,\n\t\tengine: options.config.engine,\n\t\tformat: ABSOLUTE_ANDROID_RELEASE_FORMAT,\n\t\tplatform: 'android',\n\t\treleaseId,\n\t\truntime: manifest.runtime,\n\t\tsha256,\n\t\tsigned: signed === true,\n\t\ttype: 'aab',\n\t\t...(versionCode === undefined ? {} : { versionCode })\n\t} satisfies Omit<AbsoluteAndroidReleaseMetadata, 'artifact'>;\n\n\treturn installRelease(\n\t\tartifactPath,\n\t\tmetadata,\n\t\tsafeOutputDirectory(projectRoot, options.outputDirectory)\n\t);\n};\n",
|
|
12
19
|
"import { access } from 'node:fs/promises';\nimport { homedir } from 'node:os';\nimport { join } from 'node:path';\nimport { isWSLEnvironment } from '../cli/utils';\n\nexport type AbsoluteMobileHost = 'macos' | 'windows' | 'linux' | 'wsl';\nexport type AbsoluteMobileDoctorStatus = 'pass' | 'warn' | 'fail' | 'skip';\nexport const ABSOLUTE_ANDROID_AVD_NAME = 'AbsoluteJS_API_36';\n\nexport type AbsoluteMobileDoctorCheck = {\n\tid: string;\n\tlabel: string;\n\tpath?: string;\n\tplatform: 'host' | 'android' | 'ios';\n\tremediation?: string;\n\tstatus: AbsoluteMobileDoctorStatus;\n};\n\nexport type InspectAbsoluteMobileToolchainOptions = {\n\tandroidRoot?: string | null;\n\tcapture?: (command: string[]) => { exitCode: number; stdout: string };\n\tenv?: Record<string, string | undefined>;\n\texists?: (path: string) => Promise<boolean>;\n\thost?: AbsoluteMobileHost;\n\twhich?: (command: string) => string | null;\n};\n\nconst captureCommand = (command: string[]) => {\n\ttry {\n\t\tconst result = Bun.spawnSync(command, {\n\t\t\tstderr: 'ignore',\n\t\t\tstdout: 'pipe'\n\t\t});\n\n\t\treturn {\n\t\t\texitCode: result.exitCode,\n\t\t\tstdout: result.stdout.toString()\n\t\t};\n\t} catch {\n\t\treturn { exitCode: 1, stdout: '' };\n\t}\n};\n\nconst hasAvailableIosRuntime = (output: string) => {\n\ttry {\n\t\tconst parsed: unknown = JSON.parse(output);\n\t\tif (typeof parsed !== 'object' || parsed === null) return false;\n\t\tconst runtimes = Reflect.get(parsed, 'runtimes');\n\t\tif (!Array.isArray(runtimes)) return false;\n\n\t\treturn runtimes.some(\n\t\t\t(runtime) =>\n\t\t\t\ttypeof runtime === 'object' &&\n\t\t\t\truntime !== null &&\n\t\t\t\tReflect.get(runtime, 'isAvailable') === true &&\n\t\t\t\ttypeof Reflect.get(runtime, 'identifier') === 'string' &&\n\t\t\t\tString(Reflect.get(runtime, 'identifier')).includes('iOS')\n\t\t);\n\t} catch {\n\t\treturn false;\n\t}\n};\n\nconst windowsPathToWsl = (path: string) => {\n\tconst match = /^([a-z]):[\\\\/](.*)$/i.exec(path.trim());\n\tif (!match) return path.trim().replaceAll('\\\\', '/');\n\n\treturn `/mnt/${match[1]?.toLowerCase()}/${match[2]?.replaceAll('\\\\', '/')}`;\n};\n\nconst windowsLocalAppDataFromWsl = () => {\n\ttry {\n\t\tconst result = Bun.spawnSync(\n\t\t\t['cmd.exe', '/d', '/c', 'echo', '%LOCALAPPDATA%'],\n\t\t\t{ stderr: 'ignore', stdout: 'pipe' }\n\t\t);\n\t\tif (result.exitCode !== 0) return undefined;\n\t\tconst output = result.stdout.toString().trim();\n\t\tif (!output || output === '%LOCALAPPDATA%') return undefined;\n\n\t\treturn windowsPathToWsl(output);\n\t} catch {\n\t\treturn undefined;\n\t}\n};\n\nexport const absoluteManagedAndroidSdkRoot = (\n\thost: AbsoluteMobileHost,\n\tenv: Record<string, string | undefined> = process.env\n) => {\n\tif (host === 'windows') {\n\t\treturn join(\n\t\t\tenv.LOCALAPPDATA ?? join(homedir(), 'AppData', 'Local'),\n\t\t\t'AbsoluteJS',\n\t\t\t'Android',\n\t\t\t'Sdk'\n\t\t);\n\t}\n\tif (host === 'wsl') {\n\t\tconst localAppData = windowsLocalAppDataFromWsl();\n\t\tif (localAppData) {\n\t\t\treturn join(localAppData, 'AbsoluteJS', 'Android', 'Sdk');\n\t\t}\n\t}\n\n\treturn join(homedir(), '.absolutejs', 'android-sdk');\n};\n\nconst pathExists = async (path: string) => {\n\ttry {\n\t\tawait access(path);\n\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n};\n\nexport const detectAbsoluteMobileHost = (\n\tplatform = process.platform,\n\twsl = isWSLEnvironment()\n) => {\n\tif (platform === 'darwin') return 'macos';\n\tif (platform === 'win32') return 'windows';\n\tif (platform === 'linux' && wsl) return 'wsl';\n\n\treturn 'linux';\n};\n\nconst executableNames = (host: AbsoluteMobileHost, name: string) => {\n\tif (host === 'wsl') return [`${name}.exe`, `${name}.bat`, name];\n\tif (host === 'windows') return [name, `${name}.exe`, `${name}.bat`];\n\n\treturn [name];\n};\n\nconst findExecutable = async (\n\tname: string,\n\tpaths: string[],\n\toptions: Required<\n\t\tPick<InspectAbsoluteMobileToolchainOptions, 'exists' | 'which'>\n\t>,\n\thost: AbsoluteMobileHost\n) => {\n\tconst existing = await Promise.all(\n\t\tpaths.map(async (path) =>\n\t\t\t(await options.exists(path)) ? path : undefined\n\t\t)\n\t);\n\tconst configured = existing.find((path) => path !== undefined);\n\tif (configured) return configured;\n\tfor (const candidate of executableNames(host, name)) {\n\t\tconst path = options.which(candidate);\n\t\tif (path) return path;\n\t}\n\n\treturn undefined;\n};\n\nconst toolCheck = (\n\tid: string,\n\tlabel: string,\n\tplatform: 'android' | 'ios',\n\tpath: string | undefined,\n\tremediation: string\n) =>\n\tpath\n\t\t? ({\n\t\t\t\tid,\n\t\t\t\tlabel,\n\t\t\t\tpath,\n\t\t\t\tplatform,\n\t\t\t\tstatus: 'pass'\n\t\t\t} satisfies AbsoluteMobileDoctorCheck)\n\t\t: ({\n\t\t\t\tid,\n\t\t\t\tlabel,\n\t\t\t\tplatform,\n\t\t\t\tremediation,\n\t\t\t\tstatus: 'fail'\n\t\t\t} satisfies AbsoluteMobileDoctorCheck);\n\nexport const inspectAbsoluteMobileToolchain = async (\n\tinput: InspectAbsoluteMobileToolchainOptions = {}\n) => {\n\tconst env = input.env ?? process.env;\n\tconst host = input.host ?? detectAbsoluteMobileHost();\n\tconst exists = input.exists ?? pathExists;\n\tconst which = input.which ?? ((command: string) => Bun.which(command));\n\tconst capture = input.capture ?? captureCommand;\n\tconst androidRoot =\n\t\tinput.androidRoot === null\n\t\t\t? undefined\n\t\t\t: (input.androidRoot ??\n\t\t\t\tenv.ANDROID_HOME ??\n\t\t\t\tenv.ANDROID_SDK_ROOT ??\n\t\t\t\tabsoluteManagedAndroidSdkRoot(host, env));\n\tconst windowsAndroidTools = host === 'windows' || host === 'wsl';\n\tconst android = (segments: string[]) =>\n\t\tandroidRoot ? join(androidRoot, ...segments) : undefined;\n\tconst paths = (values: Array<string | undefined>) =>\n\t\tvalues.filter((value): value is string => Boolean(value));\n\tconst adb = await findExecutable(\n\t\t'adb',\n\t\tpaths([\n\t\t\tandroid(['platform-tools', windowsAndroidTools ? 'adb.exe' : 'adb'])\n\t\t]),\n\t\t{ exists, which },\n\t\thost\n\t);\n\tconst emulator = await findExecutable(\n\t\t'emulator',\n\t\tpaths([\n\t\t\tandroid([\n\t\t\t\t'emulator',\n\t\t\t\twindowsAndroidTools ? 'emulator.exe' : 'emulator'\n\t\t\t])\n\t\t]),\n\t\t{ exists, which },\n\t\thost\n\t);\n\tconst sdkmanager = await findExecutable(\n\t\t'sdkmanager',\n\t\tpaths([\n\t\t\tandroid([\n\t\t\t\t'cmdline-tools',\n\t\t\t\t'latest',\n\t\t\t\t'bin',\n\t\t\t\twindowsAndroidTools ? 'sdkmanager.bat' : 'sdkmanager'\n\t\t\t])\n\t\t]),\n\t\t{ exists, which },\n\t\thost\n\t);\n\tconst avdmanager = await findExecutable(\n\t\t'avdmanager',\n\t\tpaths([\n\t\t\tandroid([\n\t\t\t\t'cmdline-tools',\n\t\t\t\t'latest',\n\t\t\t\t'bin',\n\t\t\t\twindowsAndroidTools ? 'avdmanager.bat' : 'avdmanager'\n\t\t\t])\n\t\t]),\n\t\t{ exists, which },\n\t\thost\n\t);\n\tconst java = await findExecutable('java', [], { exists, which }, host);\n\tconst checks: AbsoluteMobileDoctorCheck[] = [\n\t\t{\n\t\t\tid: 'host',\n\t\t\tlabel: `Development host: ${host}`,\n\t\t\tplatform: 'host',\n\t\t\tstatus: 'pass'\n\t\t},\n\t\ttoolCheck(\n\t\t\t'android.adb',\n\t\t\t'Android Debug Bridge',\n\t\t\t'android',\n\t\t\tadb,\n\t\t\t'Install Android SDK Platform Tools or expose adb on PATH.'\n\t\t),\n\t\ttoolCheck(\n\t\t\t'android.emulator',\n\t\t\t'Android Emulator',\n\t\t\t'android',\n\t\t\temulator,\n\t\t\t'Install the Android Emulator from Android Studio SDK Manager.'\n\t\t),\n\t\ttoolCheck(\n\t\t\t'android.sdkmanager',\n\t\t\t'Android SDK Manager',\n\t\t\t'android',\n\t\t\tsdkmanager,\n\t\t\t'Install Android SDK Command-line Tools (latest).'\n\t\t),\n\t\ttoolCheck(\n\t\t\t'android.avdmanager',\n\t\t\t'Android Virtual Device Manager',\n\t\t\t'android',\n\t\t\tavdmanager,\n\t\t\t'Install Android SDK Command-line Tools (latest).'\n\t\t),\n\t\ttoolCheck(\n\t\t\t'android.java',\n\t\t\t'Java runtime',\n\t\t\t'android',\n\t\t\tjava,\n\t\t\t'Install the JDK required by the configured Android Gradle plugin.'\n\t\t)\n\t];\n\tif (emulator) {\n\t\tconst avds = capture([emulator, '-list-avds']);\n\t\tconst hasManagedAvd =\n\t\t\tavds.exitCode === 0 &&\n\t\t\tavds.stdout.split(/\\r?\\n/).includes(ABSOLUTE_ANDROID_AVD_NAME);\n\t\tchecks.push({\n\t\t\tid: 'android.avd',\n\t\t\tlabel: `AbsoluteJS Android emulator (${ABSOLUTE_ANDROID_AVD_NAME})`,\n\t\t\tplatform: 'android',\n\t\t\tremediation: hasManagedAvd\n\t\t\t\t? undefined\n\t\t\t\t: 'Run absolute mobile doctor android --fix to provision the managed emulator.',\n\t\t\tstatus: hasManagedAvd ? 'pass' : 'fail'\n\t\t});\n\t}\n\n\tif (host === 'wsl') {\n\t\tchecks.push({\n\t\t\tid: 'android.virtualization',\n\t\t\tlabel: adb?.endsWith('.exe')\n\t\t\t\t? 'Windows-host Android bridge available to WSL'\n\t\t\t\t: 'WSL requires a Windows-host emulator bridge or Linux KVM',\n\t\t\tplatform: 'android',\n\t\t\tremediation: adb?.endsWith('.exe')\n\t\t\t\t? undefined\n\t\t\t\t: 'Expose the Windows Android SDK adb.exe to WSL, or enable /dev/kvm for a Linux SDK.',\n\t\t\tstatus: adb?.endsWith('.exe') ? 'pass' : 'warn'\n\t\t});\n\t} else if (host === 'linux') {\n\t\tconst hasKvm = await exists('/dev/kvm');\n\t\tchecks.push({\n\t\t\tid: 'android.virtualization',\n\t\t\tlabel: 'Linux KVM acceleration',\n\t\t\tplatform: 'android',\n\t\t\tremediation: hasKvm\n\t\t\t\t? undefined\n\t\t\t\t: 'Enable KVM and grant the current user access to /dev/kvm.',\n\t\t\tstatus: hasKvm ? 'pass' : 'warn'\n\t\t});\n\t}\n\n\tif (host !== 'macos') {\n\t\tchecks.push({\n\t\t\tid: 'ios.simulator',\n\t\t\tlabel: 'iOS Simulator requires macOS and Xcode',\n\t\t\tplatform: 'ios',\n\t\t\tstatus: 'skip'\n\t\t});\n\n\t\treturn checks;\n\t}\n\n\tconst xcrun = await findExecutable('xcrun', [], { exists, which }, host);\n\tconst xcodebuild = await findExecutable(\n\t\t'xcodebuild',\n\t\t[],\n\t\t{ exists, which },\n\t\thost\n\t);\n\tchecks.push(\n\t\ttoolCheck(\n\t\t\t'ios.xcrun',\n\t\t\t'Xcode command runner',\n\t\t\t'ios',\n\t\t\txcrun,\n\t\t\t'Install Xcode and select it with xcode-select.'\n\t\t),\n\t\ttoolCheck(\n\t\t\t'ios.xcodebuild',\n\t\t\t'Xcode build system',\n\t\t\t'ios',\n\t\t\txcodebuild,\n\t\t\t'Install Xcode and select it with xcode-select.'\n\t\t)\n\t);\n\tif (xcrun) {\n\t\tconst runtimes = capture([\n\t\t\txcrun,\n\t\t\t'simctl',\n\t\t\t'list',\n\t\t\t'runtimes',\n\t\t\t'--json'\n\t\t]);\n\t\tconst hasRuntime =\n\t\t\truntimes.exitCode === 0 && hasAvailableIosRuntime(runtimes.stdout);\n\t\tchecks.push({\n\t\t\tid: 'ios.runtime',\n\t\t\tlabel: 'iOS Simulator runtime',\n\t\t\tplatform: 'ios',\n\t\t\tremediation: hasRuntime\n\t\t\t\t? undefined\n\t\t\t\t: 'Run absolute mobile doctor ios --fix to download an iOS Simulator runtime.',\n\t\t\tstatus: hasRuntime ? 'pass' : 'fail'\n\t\t});\n\t}\n\n\treturn checks;\n};\n",
|
|
13
20
|
"import { $ } from 'bun';\nimport { execSync } from 'node:child_process';\nimport { existsSync, readFileSync } from 'node:fs';\nimport { createServer } from 'node:net';\nimport { resolve } from 'node:path';\nimport type { DbScripts } from '../../types/cli';\nimport { MILLISECONDS_IN_A_SECOND } from '../constants';\nimport { formatTimestamp } from '../utils/startupBanner';\n\nexport const COMPOSE_PATH = 'db/docker-compose.db.yml';\nexport const DEFAULT_SERVER_ENTRY = 'src/backend/server.ts';\nexport const isWSLEnvironment = () => {\n\ttry {\n\t\tconst release = readFileSync('/proc/version', 'utf-8');\n\n\t\treturn /microsoft|wsl/i.test(release);\n\t} catch {\n\t\treturn false;\n\t}\n};\nconst safeKill = (pid: number) => {\n\ttry {\n\t\tprocess.kill(pid, 'SIGTERM');\n\t} catch {\n\t\t/* already exited */\n\t}\n};\n\n// Ask the OS for an unused TCP port (bind :0, read the assigned port, release it).\n// Used to pick a collision-proof port for the compile pre-render server: the old\n// `DEFAULT_PORT + 1` is frequently occupied on CI runners, and the `lsof`-based\n// stale-process cleanup is a no-op on minimal images where `lsof` isn't installed —\n// together those produced an EADDRINUSE that failed every runner compile.\nexport const findFreePort = () =>\n\tnew Promise<number>((_resolve, reject) => {\n\t\tconst server = createServer();\n\t\tserver.unref();\n\t\tserver.once('error', reject);\n\t\tserver.listen(0, '127.0.0.1', () => {\n\t\t\tconst address = server.address();\n\t\t\tif (!address || typeof address === 'string') {\n\t\t\t\tserver.close();\n\t\t\t\treject(new Error('Failed to allocate a free port'));\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tserver.close((error) => {\n\t\t\t\tif (error) {\n\t\t\t\t\treject(error);\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t_resolve(address.port);\n\t\t\t});\n\t\t});\n\t});\n\nexport const killStaleProcesses = (\n\tport: number,\n\tlogMessage?: (message: string) => void\n) => {\n\tlet output: string;\n\ttry {\n\t\toutput = execSync(`lsof -ti tcp:${port} -sTCP:LISTEN 2>/dev/null`, {\n\t\t\tencoding: 'utf-8'\n\t\t}).trim();\n\t} catch {\n\t\treturn;\n\t}\n\tif (!output) {\n\t\treturn;\n\t}\n\n\tconst pids = output\n\t\t.split('\\n')\n\t\t.map(Number)\n\t\t.filter((pid) => pid !== process.pid && pid > 0);\n\tif (pids.length === 0) {\n\t\treturn;\n\t}\n\n\tpids.forEach(safeKill);\n\tconst message = `Killed ${pids.length} stale ${pids.length === 1 ? 'process' : 'processes'} on port ${port}.`;\n\tif (logMessage) {\n\t\tlogMessage(message);\n\n\t\treturn;\n\t}\n\tconsole.log(\n\t\t`\\x1b[2m${formatTimestamp()}\\x1b[0m \\x1b[33m[cli]\\x1b[0m \\x1b[33m${message}\\x1b[0m`\n\t);\n};\nexport const openUrlInBrowser = (\n\turl: string,\n\tonError?: (message: string) => void\n) => {\n\tif (process.env.ABSOLUTE_NO_OPEN) return false;\n\n\tconst { platform } = process;\n\tconst isWSL = platform === 'linux' && isWSLEnvironment();\n\tlet command: string;\n\tif (isWSL) {\n\t\tcommand = 'cmd.exe';\n\t} else if (platform === 'darwin') {\n\t\tcommand = 'open';\n\t} else if (platform === 'win32') {\n\t\tcommand = 'start';\n\t} else {\n\t\tcommand = 'xdg-open';\n\t}\n\tconst commandArgs = isWSL ? ['/c', 'start', url] : [url];\n\ttry {\n\t\tBun.spawn([command, ...commandArgs], {\n\t\t\tstderr: 'ignore',\n\t\t\tstdout: 'ignore'\n\t\t});\n\n\t\treturn true;\n\t} catch {\n\t\tonError?.(`Could not open browser automatically. Visit ${url}`);\n\n\t\treturn false;\n\t}\n};\n\nexport const printHelp = (subject = 'server', mobile = false) => {\n\tconst title = subject === 'workspace' ? 'workspace' : subject;\n\tconsole.log('');\n\tconsole.log('\\x1b[1mShortcuts:\\x1b[0m');\n\tconsole.log(` \\x1b[36mr\\x1b[0m / restart — Restart ${title}`);\n\tconsole.log(` \\x1b[36mp\\x1b[0m / pause — Pause/resume ${title}`);\n\tconsole.log(' \\x1b[36mo\\x1b[0m / open — Open in browser');\n\tconsole.log(' \\x1b[36mc\\x1b[0m / clear — Clear terminal');\n\tconsole.log(' \\x1b[36mm\\x1b[0m / heap — Write a heap snapshot');\n\tif (mobile) {\n\t\tconsole.log(\n\t\t\t' \\x1b[36md\\x1b[0m / device — Show mobile target status'\n\t\t);\n\t\tconsole.log(' relaunch — Relaunch the mobile app');\n\t}\n\tconsole.log(' \\x1b[36mq\\x1b[0m / quit — Graceful shutdown');\n\tconsole.log(' \\x1b[36mh\\x1b[0m / help — Show this help');\n\tconsole.log(' \\x1b[36m$\\x1b[0m — Run a shell command');\n\tconsole.log(\n\t\t' \\x1b[36m↑\\x1b[0m / \\x1b[36m↓\\x1b[0m — Command history'\n\t);\n\tconsole.log('');\n};\nexport const printHint = () => {\n\tconsole.log('\\x1b[90mpress h + enter to show shortcuts\\x1b[0m');\n};\nexport const readDbScripts = async () => {\n\tconst pkgPath = resolve('package.json');\n\tif (!existsSync(pkgPath)) return null;\n\n\tconst pkg = await Bun.file(pkgPath).json();\n\tconst upCommand: string | undefined = pkg.scripts?.['db:up'];\n\tconst downCommand: string | undefined = pkg.scripts?.['db:down'];\n\n\tif (!upCommand || !downCommand) return null;\n\n\treturn { downCommand, upCommand };\n};\nexport const startDatabase = async (scripts: DbScripts) => {\n\tawait timed('Starting database container...', async () => {\n\t\tconst { exitCode } = await $`${{ raw: scripts.upCommand }}`\n\t\t\t.quiet()\n\t\t\t.nothrow();\n\t\tif (exitCode !== 0) process.exit(exitCode);\n\t});\n};\nexport const stopDatabase = async (scripts: DbScripts) => {\n\tconsole.log('\\nStopping database container...');\n\tawait $`${{ raw: scripts.downCommand }}`.quiet().nothrow();\n};\nexport const timed = async (label: string, task: () => Promise<void>) => {\n\tprocess.stdout.write(label);\n\tconst start = performance.now();\n\tawait task();\n\tconst duration = (\n\t\t(performance.now() - start) /\n\t\tMILLISECONDS_IN_A_SECOND\n\t).toFixed(2);\n\tprocess.stdout.write(` \\x1b[90m${duration}s\\x1b[0m\\n`);\n};\n",
|
|
14
|
-
"import {\n\taccess,\n\tcopyFile,\n\tlstat,\n\tmkdir,\n\treadFile,\n\treaddir,\n\treadlink,\n\trealpath,\n\trename,\n\trm,\n\twriteFile\n} from 'node:fs/promises';\nimport { createHash, randomUUID } from 'node:crypto';\nimport {\n\tdirname,\n\tisAbsolute,\n\tjoin,\n\trelative,\n\tresolve,\n\tsep,\n\twin32\n} from 'node:path';\nimport {\n\tABSOLUTE_ANDROID_AVD_NAME,\n\tabsoluteManagedAndroidSdkRoot,\n\tdetectAbsoluteMobileHost,\n\tinspectAbsoluteMobileToolchain,\n\ttype AbsoluteMobileHost\n} from './emulatorDoctor';\nimport type { NormalizedAbsoluteMobileConfig } from './config';\nimport { writeAbsoluteCapacitorConfig } from './capacitorProject';\nimport { getDurationString } from '../utils/getDurationString';\n\nconst ANDROID_BOOT_TIMEOUT_MS = 180_000;\nconst ANDROID_BOOT_POLL_MS = 1_000;\nconst DEV_JOURNAL_FORMAT = 1;\nconst NATIVE_CACHE_FORMAT = 1;\nconst HASH_RADIX = 16;\nconst EXECUTABLE_MODE_MASK = 0o111;\nconst NATIVE_PUBLIC_PATH_SEGMENTS = 5;\nconst CAPACITOR_PROJECT_DIRECTORY_PATTERN =\n\t/project\\(['\"](:[^'\"]+)['\"]\\)\\.projectDir\\s*=\\s*new File\\(['\"]([^'\"]+)['\"]\\)/gu;\n\nexport type AbsoluteAndroidCommandOptions = {\n\tcwd?: string;\n\tenv?: Record<string, string | undefined>;\n\tsignal?: AbortSignal;\n};\n\nexport type AbsoluteAndroidCommandResult = {\n\texitCode: number;\n\tstderr: string;\n\tstdout: string;\n};\n\nexport type AbsoluteAndroidDevState =\n\t| 'booting'\n\t| 'building'\n\t| 'closed'\n\t| 'closing'\n\t| 'configuring'\n\t| 'connecting'\n\t| 'failed'\n\t| 'forwarding'\n\t| 'installing'\n\t| 'checking-native'\n\t| 'launching'\n\t| 'ready'\n\t| 'streaming-logs'\n\t| 'syncing';\n\nexport type AbsoluteAndroidNativeLogEntry = {\n\tlevel: 'debug' | 'error' | 'fatal' | 'info' | 'verbose' | 'warn';\n\tmessage: string;\n\ttag: string;\n};\n\ntype AbsoluteAndroidLogStream = {\n\tclose: () => Promise<void>;\n};\n\ntype AndroidDevJournal = {\n\tbackupPath: string;\n\tformat: number;\n\tmanifestBackupPath?: string;\n\tnativeConfigPath: string;\n\tnativeManifestPath?: string;\n};\n\ntype AndroidNativeCache = {\n\tappId: string;\n\tfingerprint: string;\n\tformat: number;\n\tinstallations: Record<string, string>;\n};\n\ntype AndroidInstalledPackage = {\n\tidentity: string;\n\tuid?: string;\n};\n\nexport type AbsoluteAndroidDevProject = {\n\tadb: string;\n\tandroidRoot: string;\n\tcap: string;\n\tconfig: NormalizedAbsoluteMobileConfig;\n\temulator: string;\n\thost: AbsoluteMobileHost;\n\tnativeDirectory: string;\n\tprojectRoot: string;\n};\n\nexport type AbsoluteAndroidDevSession = {\n\tclose: () => Promise<void>;\n\tnativeCacheHit: boolean;\n\trebuild: () => Promise<AbsoluteAndroidDevSession>;\n\trelaunch: () => Promise<void>;\n\tserial: string;\n\tstate: AbsoluteAndroidDevState;\n\tstartedEmulator: boolean;\n\ttimings: Record<string, number>;\n};\n\nexport type AbsoluteAndroidDevPhaseTiming = {\n\tdurationMs: number;\n\tphase: AbsoluteAndroidDevState;\n\ttotalMs: number;\n};\n\nconst ANDROID_TIMING_PHASES: Array<[string, string]> = [\n\t['syncing', 'Capacitor sync'],\n\t['configuring', 'dev config'],\n\t['fingerprinting', 'fingerprint'],\n\t['booting', 'emulator'],\n\t['connecting', 'device ready'],\n\t['forwarding', 'ADB reverse'],\n\t['checking-native', 'package check'],\n\t['building', 'Gradle'],\n\t['installing', 'install'],\n\t['launching', 'launch'],\n\t['streaming-logs', 'logs']\n];\n\nconst androidTimingSummary = (timings: Record<string, number>) =>\n\tANDROID_TIMING_PHASES.map(([phase, label]) => {\n\t\tconst duration = timings[phase];\n\t\tif (duration === undefined || label === undefined) return null;\n\n\t\treturn `${label} ${getDurationString(duration)}`;\n\t})\n\t\t.filter((value): value is string => value !== null)\n\t\t.join(', ');\n\nexport type PrepareAbsoluteAndroidDevOptions = {\n\tcreateNativeProject: boolean;\n\tprojectRoot: string;\n\trun?: (\n\t\tcommand: string[],\n\t\toptions?: AbsoluteAndroidCommandOptions\n\t) => Promise<number>;\n};\n\nexport type StartAbsoluteAndroidDevOptions = {\n\tcapture?: (\n\t\tcommand: string[],\n\t\toptions?: AbsoluteAndroidCommandOptions\n\t) => AbsoluteAndroidCommandResult;\n\tlog?: (message: string) => void;\n\tnativeLog?: (entry: AbsoluteAndroidNativeLogEntry) => void;\n\tonPhaseTiming?: (timing: AbsoluteAndroidDevPhaseTiming) => void;\n\tonStateChange?: (state: AbsoluteAndroidDevState) => void;\n\thttps?: boolean;\n\t/** Launch the locally embedded production web bundle while forwarding\n\t * `port` only for its configured backend. No dev-server URL is written. */\n\tembeddedBundle?: boolean;\n\tport: number;\n\tproject: AbsoluteAndroidDevProject;\n\trun?: (\n\t\tcommand: string[],\n\t\toptions?: AbsoluteAndroidCommandOptions\n\t) => Promise<number>;\n\tsignal?: AbortSignal;\n\tsleep?: (milliseconds: number) => Promise<void>;\n\tspawn?: (\n\t\tcommand: string[],\n\t\toptions?: AbsoluteAndroidCommandOptions\n\t) => void;\n\tstartNativeLogs?: (\n\t\tcommand: string[],\n\t\toptions: AbsoluteAndroidCommandOptions,\n\t\tonLine: (line: string) => void\n\t) => AbsoluteAndroidLogStream;\n};\n\nconst pathExists = async (path: string) => {\n\ttry {\n\t\tawait access(path);\n\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n};\n\nconst forwardCommandOutput = (\n\tstream: ReadableStream<Uint8Array>,\n\tdestination: NodeJS.WriteStream\n) =>\n\tstream.pipeTo(\n\t\tnew WritableStream({\n\t\t\twrite: (chunk) => {\n\t\t\t\tdestination.write(chunk);\n\t\t\t}\n\t\t})\n\t);\n\nconst runCommand = async (\n\tcommand: string[],\n\toptions: AbsoluteAndroidCommandOptions = {}\n) => {\n\tconst subprocess = Bun.spawn(command, {\n\t\tcwd: options.cwd,\n\t\tenv: options.env,\n\t\tsignal: options.signal,\n\t\tstderr: 'pipe',\n\t\tstdin: 'ignore',\n\t\tstdout: 'pipe'\n\t});\n\tconst [exitCode] = await Promise.all([\n\t\tsubprocess.exited,\n\t\tforwardCommandOutput(subprocess.stdout, process.stdout),\n\t\tforwardCommandOutput(subprocess.stderr, process.stderr)\n\t]);\n\n\treturn exitCode;\n};\n\nconst captureCommand = (\n\tcommand: string[],\n\toptions: AbsoluteAndroidCommandOptions = {}\n) => {\n\ttry {\n\t\tconst result = Bun.spawnSync(command, {\n\t\t\tcwd: options.cwd,\n\t\t\tenv: options.env,\n\t\t\tstderr: 'pipe',\n\t\t\tstdout: 'pipe'\n\t\t});\n\n\t\treturn {\n\t\t\texitCode: result.exitCode,\n\t\t\tstderr: result.stderr.toString(),\n\t\t\tstdout: result.stdout.toString()\n\t\t};\n\t} catch (error) {\n\t\treturn {\n\t\t\texitCode: 1,\n\t\t\tstderr: error instanceof Error ? error.message : String(error),\n\t\t\tstdout: ''\n\t\t};\n\t}\n};\n\nconst spawnCommand = (\n\tcommand: string[],\n\toptions: AbsoluteAndroidCommandOptions = {}\n) => {\n\tBun.spawn(command, {\n\t\tcwd: options.cwd,\n\t\tenv: options.env,\n\t\tstderr: 'ignore',\n\t\tstdin: 'ignore',\n\t\tstdout: 'ignore'\n\t});\n};\n\nconst LOGCAT_LINE_PATTERN =\n\t/^\\d{2}-\\d{2}\\s+\\d{2}:\\d{2}:\\d{2}\\.\\d+\\s+\\d+\\s+\\d+\\s+([VDIWEF])\\s+([^:]+):\\s?(.*)$/u;\nconst ASCII_CONTROL_END = 31;\nconst ASCII_DELETE = 127;\nconst ASCII_ESCAPE = 27;\nconst ASCII_HORIZONTAL_TAB = 9;\nconst LOGCAT_MESSAGE_CAPTURE = 3;\nconst UNFOUND_INDEX = -1;\nconst ANSI_SEQUENCE_PATTERN = new RegExp(\n\t`${String.fromCharCode(ASCII_ESCAPE)}(?:\\\\[[0-?]*[ -/]*[@-~]|[@-_])`,\n\t'gu'\n);\nconst AUTHORIZATION_SECRET_PATTERN =\n\t/([\"']?(?:authorization|proxy-authorization)[\"']?\\s*[:=]\\s*)(?:Bearer|Basic)\\s+[^\\s,;]+/giu;\nconst BEARER_SECRET_PATTERN = /\\b(Bearer)\\s+[^\\s,;]+/giu;\nconst COOKIE_SECRET_PATTERN =\n\t/([\"']?(?:cookie|set-cookie)[\"']?\\s*[:=]\\s*).*/giu;\nconst NAMED_SECRET_PATTERN =\n\t/([\"']?(?:access_token|refresh_token|id_token|client_secret|password|code|token)[\"']?\\s*[:=]\\s*)(\"[^\"]*\"|'[^']*'|[^\\s&,;]+)/giu;\nconst QUERY_SECRET_PATTERN = /([?&](?:code|token)=)[^&\\s]+/giu;\n\nexport const redactAbsoluteAndroidLog = (value: string) =>\n\tvalue\n\t\t.replace(ANSI_SEQUENCE_PATTERN, '')\n\t\t.split('')\n\t\t.filter((character) => {\n\t\t\tconst code = character.charCodeAt(0);\n\n\t\t\treturn (\n\t\t\t\tcode === ASCII_HORIZONTAL_TAB ||\n\t\t\t\t(code > ASCII_CONTROL_END && code !== ASCII_DELETE)\n\t\t\t);\n\t\t})\n\t\t.join('')\n\t\t.replace(AUTHORIZATION_SECRET_PATTERN, '$1[REDACTED]')\n\t\t.replace(BEARER_SECRET_PATTERN, '$1 [REDACTED]')\n\t\t.replace(COOKIE_SECRET_PATTERN, '$1[REDACTED]')\n\t\t.replace(NAMED_SECRET_PATTERN, '$1[REDACTED]')\n\t\t.replace(QUERY_SECRET_PATTERN, '$1[REDACTED]');\n\nconst androidLogLevel = (level: string) => {\n\tif (level === 'V') return 'verbose';\n\tif (level === 'D') return 'debug';\n\tif (level === 'W') return 'warn';\n\tif (level === 'E') return 'error';\n\tif (level === 'F') return 'fatal';\n\n\treturn 'info';\n};\n\nconst emitCompleteLogLines = (\n\tvalue: string,\n\tonLine: (line: string) => void\n) => {\n\tlet buffered = value;\n\tlet newlineIndex = buffered.indexOf('\\n');\n\twhile (newlineIndex !== UNFOUND_INDEX) {\n\t\tonLine(buffered.slice(0, newlineIndex).replace(/\\r$/u, ''));\n\t\tbuffered = buffered.slice(newlineIndex + 1);\n\t\tnewlineIndex = buffered.indexOf('\\n');\n\t}\n\n\treturn buffered;\n};\n\nconst decodeLogStream = () => {\n\tconst decoder = new TextDecoder();\n\n\treturn new TransformStream<Uint8Array, string>({\n\t\tflush: (controller) => {\n\t\t\tconst remaining = decoder.decode();\n\t\t\tif (remaining) controller.enqueue(remaining);\n\t\t},\n\t\ttransform: (chunk, controller) => {\n\t\t\tconst decoded = decoder.decode(chunk, { stream: true });\n\t\t\tif (decoded) controller.enqueue(decoded);\n\t\t}\n\t});\n};\n\nexport const isIgnorableAbsoluteAndroidLog = (\n\tentry: AbsoluteAndroidNativeLogEntry\n) =>\n\tentry.tag === 'Capacitor/Console' &&\n\tentry.message.includes('Error injecting safe area CSS:') &&\n\tentry.message.includes(\"Cannot read properties of null (reading 'style')\");\nexport const parseAbsoluteAndroidLogLine = (\n\tline: string\n): AbsoluteAndroidNativeLogEntry | null => {\n\tconst sanitized = redactAbsoluteAndroidLog(line).trim();\n\tif (!sanitized) return null;\n\tconst match = LOGCAT_LINE_PATTERN.exec(sanitized);\n\tif (!match) {\n\t\treturn { level: 'info', message: sanitized, tag: 'logcat' };\n\t}\n\n\treturn {\n\t\tlevel: androidLogLevel(match[1] ?? 'I'),\n\t\tmessage: match[LOGCAT_MESSAGE_CAPTURE] ?? '',\n\t\ttag: match[2]?.trim() || 'android'\n\t};\n};\n\nconst consumeLogLines = async (\n\tstream: ReadableStream<Uint8Array>,\n\tonLine: (line: string) => void\n) => {\n\tlet buffered = '';\n\tawait stream.pipeThrough(decodeLogStream()).pipeTo(\n\t\tnew WritableStream({\n\t\t\twrite: (chunk) => {\n\t\t\t\tbuffered = emitCompleteLogLines(buffered + chunk, onLine);\n\t\t\t}\n\t\t})\n\t);\n\tif (buffered) {\n\t\tonLine(buffered.replace(/\\r$/u, ''));\n\t}\n};\n\nconst startNativeLogStream = (\n\tcommand: string[],\n\toptions: AbsoluteAndroidCommandOptions,\n\tonLine: (line: string) => void\n): AbsoluteAndroidLogStream => {\n\tconst subprocess = Bun.spawn(command, {\n\t\tenv: options.env,\n\t\tstderr: 'pipe',\n\t\tstdin: 'ignore',\n\t\tstdout: 'pipe'\n\t});\n\tconst output = Promise.all([\n\t\tconsumeLogLines(subprocess.stdout, onLine),\n\t\tconsumeLogLines(subprocess.stderr, onLine)\n\t]);\n\tvoid output.catch(() => undefined);\n\n\treturn {\n\t\tclose: async () => {\n\t\t\ttry {\n\t\t\t\tsubprocess.kill();\n\t\t\t} catch {\n\t\t\t\t/* logcat already exited */\n\t\t\t}\n\t\t\tawait Promise.all([\n\t\t\t\tsubprocess.exited.catch(() => undefined),\n\t\t\t\toutput.catch(() => undefined)\n\t\t\t]);\n\t\t}\n\t};\n};\n\nconst requireSuccess = async (\n\tcommand: string[],\n\tlabel: string,\n\trun: NonNullable<StartAbsoluteAndroidDevOptions['run']>,\n\toptions?: AbsoluteAndroidCommandOptions\n) => {\n\tconst exitCode = await run(command, options);\n\tthrowIfAborted(options?.signal);\n\tif (exitCode !== 0) throw new Error(`${label} failed (exit ${exitCode}).`);\n};\n\nconst throwIfAborted = (signal?: AbortSignal) => {\n\tif (!signal?.aborted) return;\n\tthrow new DOMException(\n\t\t'Android development startup was cancelled.',\n\t\t'AbortError'\n\t);\n};\n\nconst journalPaths = (projectRoot: string) => {\n\tconst root = join(projectRoot, '.absolutejs', 'mobile', 'dev-session');\n\n\treturn {\n\t\tbackup: join(root, 'capacitor.config.backup.json'),\n\t\tjournal: join(root, 'journal.json'),\n\t\tmanifestBackup: join(root, 'AndroidManifest.backup.xml'),\n\t\troot\n\t};\n};\n\nconst isInside = (root: string, path: string) => {\n\tconst resolvedRoot = resolve(root);\n\tconst resolvedPath = resolve(path);\n\tconst relativePath = relative(resolvedRoot, resolvedPath);\n\n\treturn (\n\t\trelativePath === '' ||\n\t\t(relativePath !== '..' &&\n\t\t\t!relativePath.startsWith(`..${sep}`) &&\n\t\t\t!isAbsolute(relativePath))\n\t);\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n\ttypeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst nativeCachePath = (projectRoot: string) =>\n\tjoin(projectRoot, '.absolutejs', 'mobile', 'cache', 'android-debug.json');\n\nconst parseNativeCache = (value: unknown): AndroidNativeCache | null => {\n\tif (!isRecord(value)) return null;\n\tconst { appId, fingerprint, format, installations } = value;\n\tif (\n\t\tformat !== NATIVE_CACHE_FORMAT ||\n\t\ttypeof appId !== 'string' ||\n\t\ttypeof fingerprint !== 'string' ||\n\t\t!isRecord(installations) ||\n\t\t!Object.values(installations).every(\n\t\t\t(identity) => typeof identity === 'string'\n\t\t)\n\t) {\n\t\treturn null;\n\t}\n\n\treturn {\n\t\tappId,\n\t\tfingerprint,\n\t\tformat,\n\t\tinstallations: Object.fromEntries(\n\t\t\tObject.entries(installations).map(([serial, identity]) => [\n\t\t\t\tserial,\n\t\t\t\tString(identity)\n\t\t\t])\n\t\t)\n\t};\n};\n\nconst readNativeCache = async (projectRoot: string) =>\n\treadFile(nativeCachePath(projectRoot), 'utf8')\n\t\t.then((source) => parseNativeCache(JSON.parse(source)))\n\t\t.catch(() => null);\n\nconst writeNativeCache = async (\n\tprojectRoot: string,\n\tcache: AndroidNativeCache\n) => {\n\tconst destination = nativeCachePath(projectRoot);\n\tconst temporary = `${destination}.${process.pid}.${randomUUID()}.tmp`;\n\tawait mkdir(dirname(destination), { recursive: true });\n\ttry {\n\t\tawait writeFile(temporary, `${JSON.stringify(cache, null, '\\t')}\\n`, {\n\t\t\tflag: 'wx'\n\t\t});\n\t\tawait rename(temporary, destination);\n\t} finally {\n\t\tawait rm(temporary, { force: true }).catch(() => undefined);\n\t}\n};\n\nconst nativeDependencySources = async (nativeDirectory: string) => {\n\tconst settings = await readFile(\n\t\tjoin(nativeDirectory, 'capacitor.settings.gradle'),\n\t\t'utf8'\n\t);\n\tconst pattern = new RegExp(\n\t\tCAPACITOR_PROJECT_DIRECTORY_PATTERN.source,\n\t\tCAPACITOR_PROJECT_DIRECTORY_PATTERN.flags\n\t);\n\tconst dependencies = [...settings.matchAll(pattern)].map((match) => ({\n\t\tname: (match[1] ?? '').slice(1).replaceAll(/[^a-zA-Z0-9_.-]/gu, '_'),\n\t\tsource: resolve(nativeDirectory, match[2] ?? '')\n\t}));\n\tif (dependencies.length === 0) {\n\t\tthrow new Error(\n\t\t\t'Capacitor Android settings did not declare any native dependencies.'\n\t\t);\n\t}\n\n\treturn { dependencies, settings };\n};\n\nconst shouldIgnoreNativePath = (\n\trelativePath: string,\n\tignorePublicBundle: boolean\n) => {\n\tconst parts = relativePath.split(sep);\n\tif (\n\t\tparts.includes('.gradle') ||\n\t\tparts.includes('build') ||\n\t\tparts.includes('.absolutejs-dependencies')\n\t) {\n\t\treturn true;\n\t}\n\n\treturn (\n\t\tignorePublicBundle &&\n\t\tparts.slice(0, NATIVE_PUBLIC_PATH_SEGMENTS).join('/') ===\n\t\t\t'app/src/main/assets/public'\n\t);\n};\n\ntype NativeDirectoryCollector = (\n\troot: string,\n\tlabel: string,\n\tdirectory: string,\n\tignorePublicBundle: boolean\n) => Promise<string[]>;\n\nconst collectNativePath = async (\n\troot: string,\n\tlabel: string,\n\tpath: string,\n\tisDirectory: boolean,\n\tisFile: boolean,\n\tisSymbolicLink: boolean,\n\tignorePublicBundle: boolean\n) => {\n\tconst relativePath = relative(root, path);\n\tif (shouldIgnoreNativePath(relativePath, ignorePublicBundle)) return [];\n\tconst identity = `${label}:${relativePath.split(sep).join('/')}\\0`;\n\tif (isDirectory) {\n\t\treturn collectNativeDirectory(root, label, path, ignorePublicBundle);\n\t}\n\tif (isSymbolicLink) {\n\t\treturn [`link\\0${identity}${await readlink(path)}\\0`];\n\t}\n\tif (!isFile) return [];\n\tconst [metadata, contents] = await Promise.all([\n\t\tlstat(path),\n\t\treadFile(path)\n\t]);\n\tconst contentDigest = createHash('sha256').update(contents).digest('hex');\n\n\treturn [\n\t\t`file\\0${identity}${metadata.mode & EXECUTABLE_MODE_MASK}\\0${contentDigest}\\0`\n\t];\n};\n\nconst collectNativeDirectory: NativeDirectoryCollector = async (\n\troot,\n\tlabel,\n\tdirectory,\n\tignorePublicBundle\n) => {\n\tconst entries = await readdir(directory, { withFileTypes: true });\n\tentries.sort((left, right) => left.name.localeCompare(right.name));\n\tconst records = await Promise.all(\n\t\tentries.map((entry) =>\n\t\t\tcollectNativePath(\n\t\t\t\troot,\n\t\t\t\tlabel,\n\t\t\t\tjoin(directory, entry.name),\n\t\t\t\tentry.isDirectory(),\n\t\t\t\tentry.isFile(),\n\t\t\t\tentry.isSymbolicLink(),\n\t\t\t\tignorePublicBundle\n\t\t\t)\n\t\t)\n\t);\n\n\treturn records.flat();\n};\n\nconst hashNativeTree = async (\n\troot: string,\n\tlabel: string,\n\tignorePublicBundle: boolean\n) => {\n\tconst resolvedRoot = await realpath(root);\n\tconst records = await collectNativeDirectory(\n\t\tresolvedRoot,\n\t\tlabel,\n\t\tresolvedRoot,\n\t\tignorePublicBundle\n\t);\n\n\treturn createHash('sha256').update(records.join('')).digest('hex');\n};\n\ntype NativeFingerprintRoot = {\n\tignorePublicBundle: boolean;\n\tlabel: string;\n\tsource: string;\n};\n\nexport const fingerprintAbsoluteAndroidNativeProject = async (\n\tproject: Pick<AbsoluteAndroidDevProject, 'nativeDirectory'>,\n\toptions: { includePublicBundle?: boolean } = {}\n) => {\n\tconst { dependencies } = await nativeDependencySources(\n\t\tproject.nativeDirectory\n\t);\n\tconst roots: NativeFingerprintRoot[] = [\n\t\t{\n\t\t\tignorePublicBundle: options.includePublicBundle !== true,\n\t\t\tlabel: 'android',\n\t\t\tsource: project.nativeDirectory\n\t\t},\n\t\t...dependencies\n\t\t\t.sort((left, right) => left.name.localeCompare(right.name))\n\t\t\t.map((dependency) => ({\n\t\t\t\tignorePublicBundle: false,\n\t\t\t\tlabel: `dependency:${dependency.name}`,\n\t\t\t\tsource: dependency.source\n\t\t\t}))\n\t];\n\tconst treeDigests = await Promise.all(\n\t\troots.map((root) =>\n\t\t\thashNativeTree(root.source, root.label, root.ignorePublicBundle)\n\t\t)\n\t);\n\n\treturn createHash('sha256').update(treeDigests.join('\\0')).digest('hex');\n};\n\nconst parseJournal = (value: unknown): AndroidDevJournal | null => {\n\tif (typeof value !== 'object' || value === null) return null;\n\tconst backupPath = Reflect.get(value, 'backupPath');\n\tconst format = Reflect.get(value, 'format');\n\tconst manifestBackupPath = Reflect.get(value, 'manifestBackupPath');\n\tconst nativeConfigPath = Reflect.get(value, 'nativeConfigPath');\n\tconst nativeManifestPath = Reflect.get(value, 'nativeManifestPath');\n\tif (\n\t\ttypeof backupPath !== 'string' ||\n\t\tformat !== DEV_JOURNAL_FORMAT ||\n\t\ttypeof nativeConfigPath !== 'string'\n\t) {\n\t\treturn null;\n\t}\n\tif (\n\t\t(manifestBackupPath !== undefined ||\n\t\t\tnativeManifestPath !== undefined) &&\n\t\t(typeof manifestBackupPath !== 'string' ||\n\t\t\ttypeof nativeManifestPath !== 'string')\n\t) {\n\t\treturn null;\n\t}\n\n\treturn {\n\t\tbackupPath,\n\t\tformat,\n\t\tmanifestBackupPath,\n\t\tnativeConfigPath,\n\t\tnativeManifestPath\n\t};\n};\n\nexport const repairAbsoluteAndroidDevSession = async (projectRoot: string) => {\n\tconst paths = journalPaths(projectRoot);\n\tif (!(await pathExists(paths.journal))) {\n\t\tawait rm(paths.root, { force: true, recursive: true });\n\n\t\treturn false;\n\t}\n\tconst journal = await readFile(paths.journal, 'utf8')\n\t\t.then((source) => parseJournal(JSON.parse(source)))\n\t\t.catch(() => null);\n\tif (\n\t\t!journal ||\n\t\t!isInside(projectRoot, journal.nativeConfigPath) ||\n\t\t!isInside(paths.root, journal.backupPath) ||\n\t\t(journal.nativeManifestPath !== undefined &&\n\t\t\t!isInside(projectRoot, journal.nativeManifestPath)) ||\n\t\t(journal.manifestBackupPath !== undefined &&\n\t\t\t!isInside(paths.root, journal.manifestBackupPath))\n\t) {\n\t\tthrow new Error(\n\t\t\t`Refusing unsafe or invalid mobile dev journal at ${paths.journal}.`\n\t\t);\n\t}\n\tif (await pathExists(journal.backupPath)) {\n\t\tawait mkdir(dirname(journal.nativeConfigPath), { recursive: true });\n\t\tawait copyFile(journal.backupPath, journal.nativeConfigPath);\n\t}\n\tif (\n\t\tjournal.manifestBackupPath &&\n\t\tjournal.nativeManifestPath &&\n\t\t(await pathExists(journal.manifestBackupPath))\n\t) {\n\t\tawait mkdir(dirname(journal.nativeManifestPath), { recursive: true });\n\t\tawait copyFile(journal.manifestBackupPath, journal.nativeManifestPath);\n\t}\n\tawait rm(paths.root, { force: true, recursive: true });\n\n\treturn true;\n};\n\nconst androidDevelopmentManifest = (source: string, cleartext: boolean) => {\n\tif (!cleartext) return source;\n\tif (/android:usesCleartextTraffic=[\"'][^\"']*[\"']/u.test(source)) {\n\t\treturn source.replace(\n\t\t\t/android:usesCleartextTraffic=[\"'][^\"']*[\"']/u,\n\t\t\t'android:usesCleartextTraffic=\"true\"'\n\t\t);\n\t}\n\n\treturn source.replace(\n\t\t'<application',\n\t\t'<application\\n android:usesCleartextTraffic=\"true\"'\n\t);\n};\n\nconst writeDevConfig = async (\n\tprojectRoot: string,\n\tnativeConfigPath: string,\n\tnativeManifestPath: string,\n\tport: number,\n\thttps: boolean,\n\tentry: string,\n\tembeddedBundle: boolean\n) => {\n\tconst paths = journalPaths(projectRoot);\n\tawait repairAbsoluteAndroidDevSession(projectRoot);\n\tconst source = await readFile(nativeConfigPath, 'utf8');\n\tconst manifestSource = await readFile(nativeManifestPath, 'utf8');\n\tconst parsed: unknown = JSON.parse(source);\n\tif (!isRecord(parsed)) {\n\t\tthrow new Error(\n\t\t\t`Invalid Capacitor native config at ${nativeConfigPath}.`\n\t\t);\n\t}\n\tawait mkdir(paths.root, { recursive: true });\n\tawait writeFile(paths.backup, source, { flag: 'wx' });\n\tawait writeFile(paths.manifestBackup, manifestSource, { flag: 'wx' });\n\tconst journal: AndroidDevJournal = {\n\t\tbackupPath: paths.backup,\n\t\tformat: DEV_JOURNAL_FORMAT,\n\t\tmanifestBackupPath: paths.manifestBackup,\n\t\tnativeConfigPath,\n\t\tnativeManifestPath\n\t};\n\tawait writeFile(paths.journal, `${JSON.stringify(journal, null, '\\t')}\\n`, {\n\t\tflag: 'wx'\n\t});\n\tif (!embeddedBundle) {\n\t\tconst currentServer = parsed.server;\n\t\tconst developmentUrl = new URL(\n\t\t\t`${https ? 'https' : 'http'}://localhost:${port}${entry}`\n\t\t);\n\t\tdevelopmentUrl.searchParams.set(\n\t\t\t'__absolute_target',\n\t\t\t'capacitor-android'\n\t\t);\n\t\tparsed.server = {\n\t\t\t...(typeof currentServer === 'object' && currentServer !== null\n\t\t\t\t? currentServer\n\t\t\t\t: {}),\n\t\t\tcleartext: !https,\n\t\t\turl: developmentUrl.href\n\t\t};\n\t}\n\tawait writeFile(\n\t\tnativeConfigPath,\n\t\t`${JSON.stringify(parsed, null, '\\t')}\\n`\n\t);\n\tawait writeFile(\n\t\tnativeManifestPath,\n\t\tandroidDevelopmentManifest(manifestSource, !https)\n\t);\n};\n\nexport const parseAdbDevices = (output: string) =>\n\toutput\n\t\t.split(/\\r?\\n/)\n\t\t.slice(1)\n\t\t.map((line) => line.trim().split(/\\s+/, 2))\n\t\t.filter(\n\t\t\t(parts): parts is [string, string] =>\n\t\t\t\tparts.length === 2 && parts[1] === 'device'\n\t\t)\n\t\t.map(([serial]) => serial);\n\nconst isManagedEmulatorSerial = (\n\tserial: string,\n\tadb: string,\n\tcapture: NonNullable<StartAbsoluteAndroidDevOptions['capture']>,\n\tenv: Record<string, string | undefined>\n) => {\n\tif (!serial.startsWith('emulator-')) return false;\n\tconst avd = capture([adb, '-s', serial, 'emu', 'avd', 'name'], { env });\n\n\treturn (\n\t\tavd.exitCode === 0 &&\n\t\tavd.stdout\n\t\t\t.split(/\\r?\\n/)\n\t\t\t.map((value) => value.trim())\n\t\t\t.includes(ABSOLUTE_ANDROID_AVD_NAME)\n\t);\n};\n\nconst managedEmulatorSerial = (\n\tadb: string,\n\tcapture: NonNullable<StartAbsoluteAndroidDevOptions['capture']>,\n\tenv: Record<string, string | undefined>\n) => {\n\tconst devices = capture([adb, 'devices'], { env });\n\tif (devices.exitCode !== 0) return undefined;\n\n\treturn parseAdbDevices(devices.stdout).find((serial) =>\n\t\tisManagedEmulatorSerial(serial, adb, capture, env)\n\t);\n};\n\nconst completedBootSerial = (\n\tproject: AbsoluteAndroidDevProject,\n\tcapture: NonNullable<StartAbsoluteAndroidDevOptions['capture']>,\n\tenv: Record<string, string | undefined>\n) => {\n\tconst serial = managedEmulatorSerial(project.adb, capture, env);\n\tif (!serial) return undefined;\n\tconst booted = capture(\n\t\t[project.adb, '-s', serial, 'shell', 'getprop', 'sys.boot_completed'],\n\t\t{ env }\n\t);\n\n\treturn booted.exitCode === 0 && booted.stdout.trim() === '1'\n\t\t? serial\n\t\t: undefined;\n};\n\nconst preferredCompletedBootSerial = (\n\tproject: AbsoluteAndroidDevProject,\n\tserial: string,\n\tcapture: NonNullable<StartAbsoluteAndroidDevOptions['capture']>,\n\tenv: Record<string, string | undefined>\n) => {\n\tconst booted = capture(\n\t\t[project.adb, '-s', serial, 'shell', 'getprop', 'sys.boot_completed'],\n\t\t{ env }\n\t);\n\n\treturn booted.exitCode === 0 && booted.stdout.trim() === '1'\n\t\t? serial\n\t\t: undefined;\n};\n\nconst waitForManagedEmulator = async (\n\tproject: AbsoluteAndroidDevProject,\n\tcapture: NonNullable<StartAbsoluteAndroidDevOptions['capture']>,\n\tsleep: NonNullable<StartAbsoluteAndroidDevOptions['sleep']>,\n\tenv: Record<string, string | undefined>,\n\tsignal?: AbortSignal,\n\tpreferredSerial?: string\n) => {\n\tconst deadline = Date.now() + ANDROID_BOOT_TIMEOUT_MS;\n\tlet firstSerial = preferredSerial;\n\tconst poll = async () => {\n\t\tthrowIfAborted(signal);\n\t\tconst serial = firstSerial\n\t\t\t? preferredCompletedBootSerial(project, firstSerial, capture, env)\n\t\t\t: completedBootSerial(project, capture, env);\n\t\tfirstSerial = undefined;\n\t\tif (serial) return serial;\n\t\tif (Date.now() >= deadline) {\n\t\t\tthrow new Error(\n\t\t\t\t`Android emulator ${ABSOLUTE_ANDROID_AVD_NAME} did not finish booting within ${ANDROID_BOOT_TIMEOUT_MS / ANDROID_BOOT_POLL_MS}s.`\n\t\t\t);\n\t\t}\n\t\tawait sleep(ANDROID_BOOT_POLL_MS);\n\n\t\treturn poll();\n\t};\n\n\treturn poll();\n};\n\nconst windowsPathFromWsl = (\n\tpath: string,\n\tcapture: NonNullable<StartAbsoluteAndroidDevOptions['capture']>\n) => {\n\tconst result = capture(['wslpath', '-w', path]);\n\tif (result.exitCode !== 0 || !result.stdout.trim()) {\n\t\tthrow new Error(`Could not translate WSL path for Windows: ${path}`);\n\t}\n\n\treturn result.stdout.trim();\n};\n\ntype WindowsGradleDependency = {\n\tname: string;\n\twindowsSource: string;\n};\n\nconst mirroredCapacitorDependencies = async (\n\tproject: Pick<AbsoluteAndroidDevProject, 'nativeDirectory'>,\n\tcapture: NonNullable<StartAbsoluteAndroidDevOptions['capture']>\n) => {\n\tconst settingsPath = join(\n\t\tproject.nativeDirectory,\n\t\t'capacitor.settings.gradle'\n\t);\n\tconst settings = await readFile(settingsPath, 'utf8');\n\tconst dependencies: WindowsGradleDependency[] = [];\n\tconst rewrittenSettings = settings.replace(\n\t\tCAPACITOR_PROJECT_DIRECTORY_PATTERN,\n\t\t(_statement, projectName: string, sourcePath: string) => {\n\t\t\tconst name = projectName\n\t\t\t\t.slice(1)\n\t\t\t\t.replaceAll(/[^a-zA-Z0-9_.-]/gu, '_');\n\t\t\tconst source = resolve(project.nativeDirectory, sourcePath);\n\t\t\tdependencies.push({\n\t\t\t\tname,\n\t\t\t\twindowsSource: windowsPathFromWsl(source, capture)\n\t\t\t});\n\n\t\t\treturn `project('${projectName}').projectDir = new File('./.absolutejs-dependencies/${name}')`;\n\t\t}\n\t);\n\tif (dependencies.length === 0) {\n\t\tthrow new Error(\n\t\t\t'Capacitor Android settings did not declare any native dependencies.'\n\t\t);\n\t}\n\n\treturn { dependencies, rewrittenSettings };\n};\n\nconst encodedWindowsGradleCommand = (\n\twindowsSource: string,\n\twindowsDirectory: string,\n\twindowsAndroidRoot: string,\n\tdependencies: WindowsGradleDependency[],\n\trewrittenSettings: string,\n\ttask: AbsoluteAndroidGradleTask,\n\tgradleArguments: readonly string[]\n) => {\n\tconst sourceDirectory = Buffer.from(windowsSource, 'utf8').toString(\n\t\t'base64'\n\t);\n\tconst buildDirectory = Buffer.from(windowsDirectory, 'utf8').toString(\n\t\t'base64'\n\t);\n\tconst androidRoot = Buffer.from(windowsAndroidRoot, 'utf8').toString(\n\t\t'base64'\n\t);\n\tconst dependencyData = Buffer.from(\n\t\tJSON.stringify(dependencies),\n\t\t'utf8'\n\t).toString('base64');\n\tconst settingsData = Buffer.from(rewrittenSettings, 'utf8').toString(\n\t\t'base64'\n\t);\n\tconst argumentsData = Buffer.from(\n\t\tJSON.stringify(gradleArguments),\n\t\t'utf8'\n\t).toString('base64');\n\tconst source = [\n\t\t\"$ErrorActionPreference = 'Stop'\",\n\t\t`$source = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('${sourceDirectory}'))`,\n\t\t`$directory = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('${buildDirectory}'))`,\n\t\t`$androidHome = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('${androidRoot}'))`,\n\t\t`$dependencies = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('${dependencyData}')) | ConvertFrom-Json`,\n\t\t`$settings = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('${settingsData}'))`,\n\t\t`$gradleArguments = @([Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('${argumentsData}')) | ConvertFrom-Json)`,\n\t\t'$env:ANDROID_HOME = $androidHome',\n\t\t'$env:ANDROID_SDK_ROOT = $androidHome',\n\t\t'New-Item -ItemType Directory -Force -Path $directory | Out-Null',\n\t\t'& robocopy.exe $source $directory /MIR /XD .gradle build .absolutejs-dependencies /NFL /NDL /NJH /NJS /NP',\n\t\t'$copyExit = $LASTEXITCODE',\n\t\t'if ($copyExit -ge 8) { exit $copyExit }',\n\t\t\"foreach ($dependency in @($dependencies)) { $target = Join-Path $directory ('.absolutejs-dependencies\\\\' + $dependency.name); New-Item -ItemType Directory -Force -Path $target | Out-Null; & robocopy.exe $dependency.windowsSource $target /MIR /XD .gradle build /NFL /NDL /NJH /NJS /NP; if ($LASTEXITCODE -ge 8) { exit $LASTEXITCODE } }\",\n\t\t\"[IO.File]::WriteAllText((Join-Path $directory 'capacitor.settings.gradle'), $settings)\",\n\t\t\"$wrapper = Join-Path $directory 'gradlew.bat'\",\n\t\t`& $wrapper --no-daemon --console=plain -p $directory @gradleArguments ${task}`,\n\t\t'if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }',\n\t\t'exit 0'\n\t].join('; ');\n\n\treturn Buffer.from(source, 'utf16le').toString('base64');\n};\n\nexport type AbsoluteAndroidGradleTask =\n\t| 'assembleDebug'\n\t| 'assembleRelease'\n\t| 'bundleRelease';\n\nexport type BuildAbsoluteAndroidGradleOptions = {\n\tcapture?: NonNullable<StartAbsoluteAndroidDevOptions['capture']>;\n\tenv?: Record<string, string | undefined>;\n\tgradleArguments?: readonly string[];\n\tproject: Pick<\n\t\tAbsoluteAndroidDevProject,\n\t\t'androidRoot' | 'config' | 'host' | 'nativeDirectory' | 'projectRoot'\n\t>;\n\trun?: NonNullable<StartAbsoluteAndroidDevOptions['run']>;\n\tsignal?: AbortSignal;\n\ttask: AbsoluteAndroidGradleTask;\n};\n\nconst gradleArtifactPath = (\n\tnativeDirectory: string,\n\ttask: AbsoluteAndroidGradleTask,\n\twindows = false\n) => {\n\tconst pathJoin = windows ? win32.join : join;\n\tif (task === 'assembleDebug') {\n\t\treturn pathJoin(\n\t\t\tnativeDirectory,\n\t\t\t'app',\n\t\t\t'build',\n\t\t\t'outputs',\n\t\t\t'apk',\n\t\t\t'debug',\n\t\t\t'app-debug.apk'\n\t\t);\n\t}\n\tif (task === 'assembleRelease') {\n\t\treturn pathJoin(\n\t\t\tnativeDirectory,\n\t\t\t'app',\n\t\t\t'build',\n\t\t\t'outputs',\n\t\t\t'apk',\n\t\t\t'release',\n\t\t\t'app-release.apk'\n\t\t);\n\t}\n\n\treturn pathJoin(\n\t\tnativeDirectory,\n\t\t'app',\n\t\t'build',\n\t\t'outputs',\n\t\t'bundle',\n\t\t'release',\n\t\t'app-release.aab'\n\t);\n};\n\nconst resolveGradleArtifactPath = async (\n\tnativeDirectory: string,\n\ttask: AbsoluteAndroidGradleTask\n) => {\n\tconst primary = gradleArtifactPath(nativeDirectory, task);\n\tif (task !== 'assembleRelease' || (await pathExists(primary))) {\n\t\treturn primary;\n\t}\n\n\treturn join(\n\t\tnativeDirectory,\n\t\t'app',\n\t\t'build',\n\t\t'outputs',\n\t\t'apk',\n\t\t'release',\n\t\t'app-release-unsigned.apk'\n\t);\n};\n\nexport const buildAbsoluteAndroidGradleArtifact = async (\n\toptions: BuildAbsoluteAndroidGradleOptions\n) => {\n\tconst { project, task } = options;\n\tconst capture = options.capture ?? captureCommand;\n\tconst run = options.run ?? runCommand;\n\tconst env = options.env ?? process.env;\n\tconst gradleArguments = options.gradleArguments ?? [];\n\tif (project.host === 'wsl') {\n\t\tconst windowsSource = windowsPathFromWsl(\n\t\t\tproject.nativeDirectory,\n\t\t\tcapture\n\t\t);\n\t\tconst buildId = Bun.hash(project.projectRoot).toString(HASH_RADIX);\n\t\tconst managedBuildDirectory = resolve(\n\t\t\tproject.androidRoot,\n\t\t\t'..',\n\t\t\t'..',\n\t\t\t'Builds',\n\t\t\t`${project.config.appId}-${buildId}`\n\t\t);\n\t\tconst windowsDirectory = windowsPathFromWsl(\n\t\t\tmanagedBuildDirectory,\n\t\t\tcapture\n\t\t);\n\t\tconst windowsAndroidRoot = windowsPathFromWsl(\n\t\t\tproject.androidRoot,\n\t\t\tcapture\n\t\t);\n\t\tconst { dependencies, rewrittenSettings } =\n\t\t\tawait mirroredCapacitorDependencies(project, capture);\n\t\tawait requireSuccess(\n\t\t\t[\n\t\t\t\t'powershell.exe',\n\t\t\t\t'-NoProfile',\n\t\t\t\t'-EncodedCommand',\n\t\t\t\tencodedWindowsGradleCommand(\n\t\t\t\t\twindowsSource,\n\t\t\t\t\twindowsDirectory,\n\t\t\t\t\twindowsAndroidRoot,\n\t\t\t\t\tdependencies,\n\t\t\t\t\trewrittenSettings,\n\t\t\t\t\ttask,\n\t\t\t\t\tgradleArguments\n\t\t\t\t)\n\t\t\t],\n\t\t\t'Android Gradle build',\n\t\t\trun,\n\t\t\t{ env, signal: options.signal }\n\t\t);\n\n\t\tconst artifactPath = await resolveGradleArtifactPath(\n\t\t\tmanagedBuildDirectory,\n\t\t\ttask\n\t\t);\n\t\tconst unsigned = artifactPath.endsWith('-unsigned.apk');\n\n\t\treturn {\n\t\t\tartifactPath,\n\t\t\tinstallPath: unsigned\n\t\t\t\t? win32.join(\n\t\t\t\t\t\twindowsDirectory,\n\t\t\t\t\t\t'app',\n\t\t\t\t\t\t'build',\n\t\t\t\t\t\t'outputs',\n\t\t\t\t\t\t'apk',\n\t\t\t\t\t\t'release',\n\t\t\t\t\t\t'app-release-unsigned.apk'\n\t\t\t\t\t)\n\t\t\t\t: gradleArtifactPath(windowsDirectory, task, true)\n\t\t};\n\t}\n\tconst wrapper = project.host === 'windows' ? 'gradlew.bat' : './gradlew';\n\tawait requireSuccess(\n\t\t[wrapper, '--no-daemon', '--console=plain', ...gradleArguments, task],\n\t\t'Android Gradle build',\n\t\trun,\n\t\t{ cwd: project.nativeDirectory, env, signal: options.signal }\n\t);\n\n\tconst artifactPath = await resolveGradleArtifactPath(\n\t\tproject.nativeDirectory,\n\t\ttask\n\t);\n\n\treturn { artifactPath, installPath: artifactPath };\n};\n\nconst buildAndroidDebugApp = async (\n\tproject: AbsoluteAndroidDevProject,\n\tcapture: NonNullable<StartAbsoluteAndroidDevOptions['capture']>,\n\trun: NonNullable<StartAbsoluteAndroidDevOptions['run']>,\n\tenv: Record<string, string | undefined>,\n\tsignal?: AbortSignal\n) =>\n\t(\n\t\tawait buildAbsoluteAndroidGradleArtifact({\n\t\t\tcapture,\n\t\t\tenv,\n\t\t\tproject,\n\t\t\trun,\n\t\t\tsignal,\n\t\t\ttask: 'assembleDebug'\n\t\t})\n\t).installPath;\n\ntype EnsureAndroidDebugAppOptions = {\n\tcache: AndroidNativeCache | null;\n\tcapture: NonNullable<StartAbsoluteAndroidDevOptions['capture']>;\n\tenv: Record<string, string | undefined>;\n\tfingerprint: string;\n\tlog: NonNullable<StartAbsoluteAndroidDevOptions['log']>;\n\tproject: AbsoluteAndroidDevProject;\n\trun: NonNullable<StartAbsoluteAndroidDevOptions['run']>;\n\tserial: string;\n\tsignal?: AbortSignal;\n\ttransition: (state: AbsoluteAndroidDevState) => void;\n};\n\nconst persistInstalledAndroidNativeCache = async (\n\toptions: EnsureAndroidDebugAppOptions,\n\tinstalled: AndroidInstalledPackage | undefined\n) => {\n\tif (!installed) {\n\t\toptions.log(\n\t\t\t'Android package identity was unavailable; the next session will rebuild safely.'\n\t\t);\n\n\t\treturn;\n\t}\n\tconst installations =\n\t\toptions.cache?.appId === options.project.config.appId &&\n\t\toptions.cache.fingerprint === options.fingerprint\n\t\t\t? { ...options.cache.installations }\n\t\t\t: {};\n\tinstallations[options.serial] = installed.identity;\n\tawait writeNativeCache(options.project.projectRoot, {\n\t\tappId: options.project.config.appId,\n\t\tfingerprint: options.fingerprint,\n\t\tformat: NATIVE_CACHE_FORMAT,\n\t\tinstallations\n\t}).catch((error) => {\n\t\toptions.log(\n\t\t\t`Android native cache could not be saved: ${error instanceof Error ? error.message : String(error)}`\n\t\t);\n\t});\n};\n\nconst ensureAndroidDebugApp = async (options: EnsureAndroidDebugAppOptions) => {\n\tconst installed = androidInstalledPackageIdentity(\n\t\toptions.project,\n\t\toptions.serial,\n\t\toptions.capture,\n\t\toptions.env\n\t);\n\tconst cacheHit =\n\t\toptions.cache?.appId === options.project.config.appId &&\n\t\toptions.cache.fingerprint === options.fingerprint &&\n\t\tinstalled !== undefined &&\n\t\toptions.cache.installations[options.serial] === installed.identity;\n\tif (cacheHit) {\n\t\toptions.log(\n\t\t\t`Android native app is unchanged on ${options.serial}; skipped Gradle build and APK install.`\n\t\t);\n\n\t\treturn { nativeCacheHit: true, uid: installed.uid };\n\t}\n\toptions.log(\n\t\t'Android native inputs changed or the installed app is stale; rebuilding.'\n\t);\n\toptions.transition('building');\n\tconst installPath = await buildAndroidDebugApp(\n\t\toptions.project,\n\t\toptions.capture,\n\t\toptions.run,\n\t\toptions.env,\n\t\toptions.signal\n\t);\n\tthrowIfAborted(options.signal);\n\toptions.transition('installing');\n\tawait requireSuccess(\n\t\t[\n\t\t\toptions.project.adb,\n\t\t\t'-s',\n\t\t\toptions.serial,\n\t\t\t'install',\n\t\t\t'-r',\n\t\t\tinstallPath\n\t\t],\n\t\t'Android app installation',\n\t\toptions.run,\n\t\t{ env: options.env, signal: options.signal }\n\t);\n\tconst updated = androidInstalledPackageIdentity(\n\t\toptions.project,\n\t\toptions.serial,\n\t\toptions.capture,\n\t\toptions.env\n\t);\n\tawait persistInstalledAndroidNativeCache(options, updated);\n\n\treturn { nativeCacheHit: false, uid: updated?.uid };\n};\n\nconst startManagedEmulatorIfNeeded = (\n\tproject: AbsoluteAndroidDevProject,\n\tcapture: NonNullable<StartAbsoluteAndroidDevOptions['capture']>,\n\tspawn: NonNullable<StartAbsoluteAndroidDevOptions['spawn']>,\n\tlog: NonNullable<StartAbsoluteAndroidDevOptions['log']>,\n\tenv: Record<string, string | undefined>\n) => {\n\tconst serial = managedEmulatorSerial(project.adb, capture, env);\n\tif (serial) return { serial, started: false };\n\tlog(`Starting Android emulator ${ABSOLUTE_ANDROID_AVD_NAME}...`);\n\tspawn(\n\t\t[\n\t\t\tproject.emulator,\n\t\t\t'-avd',\n\t\t\tABSOLUTE_ANDROID_AVD_NAME,\n\t\t\t'-netdelay',\n\t\t\t'none',\n\t\t\t'-netspeed',\n\t\t\t'full'\n\t\t],\n\t\t{ env }\n\t);\n\n\treturn { serial: undefined, started: true };\n};\n\nconst logHttpsCertificateRequirement = (\n\thttps: boolean | undefined,\n\tlog: NonNullable<StartAbsoluteAndroidDevOptions['log']>\n) => {\n\tif (https !== true) return;\n\tlog(\n\t\t'Android HMR is using HTTPS; the emulator must trust the local development certificate authority.'\n\t);\n};\n\nconst removeAdbReverse = async (\n\tproject: AbsoluteAndroidDevProject,\n\tserial: string | undefined,\n\tport: number,\n\trun: NonNullable<StartAbsoluteAndroidDevOptions['run']>,\n\tenv: Record<string, string | undefined>\n) => {\n\tif (!serial) return;\n\tawait run(\n\t\t[project.adb, '-s', serial, 'reverse', '--remove', `tcp:${port}`],\n\t\t{ env }\n\t).catch(() => undefined);\n};\n\nconst androidLaunchCommand = (\n\tproject: AbsoluteAndroidDevProject,\n\tserial: string\n) => [\n\tproject.adb,\n\t'-s',\n\tserial,\n\t'shell',\n\t'monkey',\n\t'-p',\n\tproject.config.appId,\n\t'-c',\n\t'android.intent.category.LAUNCHER',\n\t'1'\n];\n\nconst stopAndroidAppCommand = (\n\tproject: AbsoluteAndroidDevProject,\n\tserial: string\n) => [\n\tproject.adb,\n\t'-s',\n\tserial,\n\t'shell',\n\t'am',\n\t'force-stop',\n\tproject.config.appId\n];\n\nconst launchAndroidApp = async (\n\tproject: AbsoluteAndroidDevProject,\n\tserial: string,\n\tdescription: string,\n\trun: NonNullable<StartAbsoluteAndroidDevOptions['run']>,\n\toptions: {\n\t\tenv: Record<string, string | undefined>;\n\t\tsignal?: AbortSignal;\n\t}\n) => {\n\tawait requireSuccess(\n\t\tstopAndroidAppCommand(project, serial),\n\t\t`${description} reset`,\n\t\trun,\n\t\toptions\n\t);\n\tawait requireSuccess(\n\t\tandroidLaunchCommand(project, serial),\n\t\tdescription,\n\t\trun,\n\t\toptions\n\t);\n};\n\nconst androidPackageUid = (\n\tproject: AbsoluteAndroidDevProject,\n\tserial: string,\n\tcapture: NonNullable<StartAbsoluteAndroidDevOptions['capture']>,\n\tenv: Record<string, string | undefined>\n) => {\n\tconst result = capture(\n\t\t[\n\t\t\tproject.adb,\n\t\t\t'-s',\n\t\t\tserial,\n\t\t\t'shell',\n\t\t\t'cmd',\n\t\t\t'package',\n\t\t\t'list',\n\t\t\t'packages',\n\t\t\t'-U',\n\t\t\tproject.config.appId\n\t\t],\n\t\t{ env }\n\t);\n\tif (result.exitCode !== 0) return undefined;\n\tconst escapedAppId = project.config.appId.replace(\n\t\t/[.*+?^${}()|[\\]\\\\]/gu,\n\t\t'\\\\$&'\n\t);\n\tconst match = new RegExp(`package:${escapedAppId}\\\\s+uid:(\\\\d+)`, 'u').exec(\n\t\tresult.stdout\n\t);\n\n\treturn match?.[1];\n};\n\nconst androidInstalledPackageIdentity = (\n\tproject: AbsoluteAndroidDevProject,\n\tserial: string,\n\tcapture: NonNullable<StartAbsoluteAndroidDevOptions['capture']>,\n\tenv: Record<string, string | undefined>\n) => {\n\tconst result = capture(\n\t\t[\n\t\t\tproject.adb,\n\t\t\t'-s',\n\t\t\tserial,\n\t\t\t'shell',\n\t\t\t'dumpsys',\n\t\t\t'package',\n\t\t\tproject.config.appId\n\t\t],\n\t\t{ env }\n\t);\n\tif (result.exitCode !== 0) return undefined;\n\tconst codePath = /^\\s*codePath=(.+)$/mu.exec(result.stdout)?.[1]?.trim();\n\tconst lastUpdateTime = /^\\s*lastUpdateTime=(.+)$/mu\n\t\t.exec(result.stdout)?.[1]\n\t\t?.trim();\n\tif (!codePath || !lastUpdateTime) return undefined;\n\tconst uid = /^\\s*appId=(\\d+)$/mu.exec(result.stdout)?.[1];\n\n\treturn { identity: `${codePath}\\0${lastUpdateTime}`, uid };\n};\n\nconst attachAndroidNativeLogs = (\n\tproject: AbsoluteAndroidDevProject,\n\tserial: string,\n\tcapture: NonNullable<StartAbsoluteAndroidDevOptions['capture']>,\n\tenv: Record<string, string | undefined>,\n\toptions: StartAbsoluteAndroidDevOptions,\n\tknownUid?: string\n) => {\n\tif (!options.nativeLog) return null;\n\tconst uid = knownUid ?? androidPackageUid(project, serial, capture, env);\n\tif (!uid) {\n\t\toptions.log?.(\n\t\t\t`Android app logs unavailable: could not resolve the package UID for ${project.config.appId}.`\n\t\t);\n\n\t\treturn null;\n\t}\n\tconst onLine = (line: string) => {\n\t\tconst entry = parseAbsoluteAndroidLogLine(line);\n\t\t// Capacitor 8 SystemBars can run before documentElement exists. A later\n\t\t// inset pass applies the values; keep the plugin enabled because disabling\n\t\t// it breaks edge-to-edge layout on Android 16. Remove this narrow filter\n\t\t// when https://github.com/ionic-team/capacitor/issues/8530 is fixed.\n\t\tif (entry && !isIgnorableAbsoluteAndroidLog(entry)) {\n\t\t\toptions.nativeLog?.(entry);\n\t\t}\n\t};\n\n\treturn (options.startNativeLogs ?? startNativeLogStream)(\n\t\t[\n\t\t\tproject.adb,\n\t\t\t'-s',\n\t\t\tserial,\n\t\t\t'logcat',\n\t\t\t`--uid=${uid}`,\n\t\t\t'-v',\n\t\t\t'threadtime',\n\t\t\t'-T',\n\t\t\t'1',\n\t\t\t'*:W',\n\t\t\t'Capacitor:V',\n\t\t\t'Capacitor/Console:V',\n\t\t\t'chromium:I'\n\t\t],\n\t\t{ env },\n\t\tonLine\n\t);\n};\n\nexport const prepareAbsoluteAndroidDevProject = async (\n\tconfig: NormalizedAbsoluteMobileConfig,\n\toptions: PrepareAbsoluteAndroidDevOptions\n): Promise<AbsoluteAndroidDevProject> => {\n\tconst projectRoot = resolve(options.projectRoot);\n\tconst host = detectAbsoluteMobileHost();\n\tconst androidRoot =\n\t\tprocess.env.ANDROID_HOME ??\n\t\tprocess.env.ANDROID_SDK_ROOT ??\n\t\tabsoluteManagedAndroidSdkRoot(host);\n\tconst checks = await inspectAbsoluteMobileToolchain({ androidRoot, host });\n\tconst failed = checks.filter(\n\t\t(check) =>\n\t\t\tcheck.platform === 'android' &&\n\t\t\t(check.status === 'fail' || check.status === 'warn')\n\t);\n\tif (failed.length > 0) {\n\t\tthrow new Error(\n\t\t\t`Android emulation is not ready: ${failed.map(({ label }) => label).join(', ')}.`\n\t\t);\n\t}\n\tconst adb = checks.find((check) => check.id === 'android.adb')?.path;\n\tconst emulator = checks.find(\n\t\t(check) => check.id === 'android.emulator'\n\t)?.path;\n\tif (!adb || !emulator) {\n\t\tthrow new Error(\n\t\t\t'Android SDK tools disappeared after readiness checks.'\n\t\t);\n\t}\n\tconst cap = join(\n\t\tprojectRoot,\n\t\t'node_modules',\n\t\t'.bin',\n\t\thost === 'windows' ? 'cap.cmd' : 'cap'\n\t);\n\tif (!(await pathExists(cap))) {\n\t\tthrow new Error(\n\t\t\t'Capacitor CLI is not installed. Run absolute mobile init first.'\n\t\t);\n\t}\n\tawait writeAbsoluteCapacitorConfig(config, { projectRoot });\n\tawait mkdir(config.bundleDirectory, { recursive: true });\n\tconst placeholder = join(config.bundleDirectory, 'index.html');\n\tif (!(await pathExists(placeholder))) {\n\t\tawait writeFile(\n\t\t\tplaceholder,\n\t\t\t'<!doctype html><title>AbsoluteJS mobile development</title>\\n'\n\t\t);\n\t}\n\tconst nativeDirectory = join(config.nativeProjectDirectory, 'android');\n\tif (!(await pathExists(nativeDirectory))) {\n\t\tif (!options.createNativeProject) {\n\t\t\tthrow new Error('Android native project has not been created.');\n\t\t}\n\t\tconst run = options.run ?? runCommand;\n\t\tif (\n\t\t\t(await run([cap, 'add', 'android'], {\n\t\t\t\tcwd: projectRoot\n\t\t\t})) !== 0\n\t\t) {\n\t\t\tthrow new Error('Capacitor Android project creation failed.');\n\t\t}\n\t}\n\n\treturn {\n\t\tadb,\n\t\tandroidRoot,\n\t\tcap,\n\t\tconfig,\n\t\temulator,\n\t\thost,\n\t\tnativeDirectory,\n\t\tprojectRoot\n\t};\n};\n\nexport const startAbsoluteAndroidDevSession = async (\n\toptions: StartAbsoluteAndroidDevOptions\n) => {\n\tconst { project } = options;\n\tconst startupStartedAt = performance.now();\n\tlet phaseStartedAt = performance.now();\n\tconst phaseDurations: Record<string, number> = {};\n\tlet state: AbsoluteAndroidDevState = 'syncing';\n\tconst transition = (next: AbsoluteAndroidDevState) => {\n\t\tif (next === state) {\n\t\t\toptions.onStateChange?.(next);\n\n\t\t\treturn;\n\t\t}\n\t\tconst now = performance.now();\n\t\tconst durationMs = now - phaseStartedAt;\n\t\tphaseDurations[state] = (phaseDurations[state] ?? 0) + durationMs;\n\t\toptions.onPhaseTiming?.({\n\t\t\tdurationMs,\n\t\t\tphase: state,\n\t\t\ttotalMs: now - startupStartedAt\n\t\t});\n\t\tstate = next;\n\t\tphaseStartedAt = now;\n\t\toptions.onStateChange?.(next);\n\t};\n\tconst capture = options.capture ?? captureCommand;\n\tconst run = options.run ?? runCommand;\n\tconst sleep = options.sleep ?? Bun.sleep;\n\tconst spawn = options.spawn ?? spawnCommand;\n\tconst log = options.log ?? console.log;\n\tconst androidHome =\n\t\tproject.host === 'wsl'\n\t\t\t? windowsPathFromWsl(project.androidRoot, capture)\n\t\t\t: project.androidRoot;\n\tconst env: Record<string, string | undefined> = {\n\t\t...process.env,\n\t\tANDROID_HOME: androidHome\n\t};\n\ttransition('syncing');\n\tawait repairAbsoluteAndroidDevSession(project.projectRoot);\n\tthrowIfAborted(options.signal);\n\tawait requireSuccess(\n\t\t[project.cap, 'sync', 'android'],\n\t\t'Capacitor Android synchronization',\n\t\trun,\n\t\t{ cwd: project.projectRoot, env, signal: options.signal }\n\t);\n\tthrowIfAborted(options.signal);\n\ttransition('configuring');\n\tconst nativeConfigPath = join(\n\t\tproject.nativeDirectory,\n\t\t'app',\n\t\t'src',\n\t\t'main',\n\t\t'assets',\n\t\t'capacitor.config.json'\n\t);\n\tconst nativeManifestPath = join(\n\t\tproject.nativeDirectory,\n\t\t'app',\n\t\t'src',\n\t\t'main',\n\t\t'AndroidManifest.xml'\n\t);\n\tlet connectedSerial: string | undefined;\n\tlet nativeLogs: AbsoluteAndroidLogStream | null = null;\n\tconst closeNativeLogs = async () => {\n\t\tconst stream = nativeLogs;\n\t\tnativeLogs = null;\n\t\tawait stream?.close().catch(() => undefined);\n\t};\n\ttry {\n\t\tawait writeDevConfig(\n\t\t\tproject.projectRoot,\n\t\t\tnativeConfigPath,\n\t\t\tnativeManifestPath,\n\t\t\toptions.port,\n\t\t\toptions.https === true,\n\t\t\tproject.config.entry,\n\t\t\toptions.embeddedBundle === true\n\t\t);\n\t\tthrowIfAborted(options.signal);\n\t\tlogHttpsCertificateRequirement(options.https, log);\n\t\tconst fingerprintStartedAt = performance.now();\n\t\tconst nativeFingerprintPromise =\n\t\t\tfingerprintAbsoluteAndroidNativeProject(project, {\n\t\t\t\tincludePublicBundle: options.embeddedBundle === true\n\t\t\t}).then((fingerprint) => {\n\t\t\t\tphaseDurations.fingerprinting =\n\t\t\t\t\tperformance.now() - fingerprintStartedAt;\n\n\t\t\t\treturn fingerprint;\n\t\t\t});\n\t\ttransition('booting');\n\t\tconst emulator = startManagedEmulatorIfNeeded(\n\t\t\tproject,\n\t\t\tcapture,\n\t\t\tspawn,\n\t\t\tlog,\n\t\t\tenv\n\t\t);\n\t\tconst { started: startedEmulator } = emulator;\n\t\ttransition('connecting');\n\t\tconst serial = await waitForManagedEmulator(\n\t\t\tproject,\n\t\t\tcapture,\n\t\t\tsleep,\n\t\t\tenv,\n\t\t\toptions.signal,\n\t\t\temulator.serial\n\t\t);\n\t\tconnectedSerial = serial;\n\t\ttransition('forwarding');\n\t\tawait requireSuccess(\n\t\t\t[\n\t\t\t\tproject.adb,\n\t\t\t\t'-s',\n\t\t\t\tserial,\n\t\t\t\t'reverse',\n\t\t\t\t`tcp:${options.port}`,\n\t\t\t\t`tcp:${options.port}`\n\t\t\t],\n\t\t\t'ADB reverse port forwarding',\n\t\t\trun,\n\t\t\t{ env, signal: options.signal }\n\t\t);\n\t\tthrowIfAborted(options.signal);\n\t\tconst nativeFingerprint = await nativeFingerprintPromise;\n\t\tthrowIfAborted(options.signal);\n\t\ttransition('checking-native');\n\t\tconst cache = await readNativeCache(project.projectRoot);\n\t\tconst installedApp = await ensureAndroidDebugApp({\n\t\t\tcache,\n\t\t\tcapture,\n\t\t\tenv,\n\t\t\tfingerprint: nativeFingerprint,\n\t\t\tlog,\n\t\t\tproject,\n\t\t\trun,\n\t\t\tserial,\n\t\t\tsignal: options.signal,\n\t\t\ttransition\n\t\t});\n\t\tconst { nativeCacheHit, uid } = installedApp;\n\t\tthrowIfAborted(options.signal);\n\t\ttransition('launching');\n\t\tawait launchAndroidApp(project, serial, 'Android app launch', run, {\n\t\t\tenv,\n\t\t\tsignal: options.signal\n\t\t});\n\t\tthrowIfAborted(options.signal);\n\t\tif (options.nativeLog) transition('streaming-logs');\n\t\tnativeLogs = attachAndroidNativeLogs(\n\t\t\tproject,\n\t\t\tserial,\n\t\t\tcapture,\n\t\t\tenv,\n\t\t\toptions,\n\t\t\tuid\n\t\t);\n\t\ttransition('ready');\n\t\tphaseDurations.total = performance.now() - startupStartedAt;\n\t\tlog(\n\t\t\toptions.embeddedBundle === true\n\t\t\t\t? `Android emulator connected (${serial}) with the embedded bundle and backend on port ${options.port} in ${getDurationString(phaseDurations.total)} (${nativeCacheHit ? 'native cache hit' : 'native build installed'}).`\n\t\t\t\t: `Android emulator connected (${serial}) with HMR on port ${options.port} in ${getDurationString(phaseDurations.total)} (${nativeCacheHit ? 'native cache hit' : 'native build installed'}).`\n\t\t);\n\t\tlog(`Android startup: ${androidTimingSummary(phaseDurations)}.`);\n\t\tlet closed = false;\n\t\tconst close = async () => {\n\t\t\tif (closed) return;\n\t\t\tclosed = true;\n\t\t\ttransition('closing');\n\t\t\tawait closeNativeLogs();\n\t\t\tawait removeAdbReverse(project, serial, options.port, run, env);\n\t\t\tawait repairAbsoluteAndroidDevSession(project.projectRoot);\n\t\t\ttransition('closed');\n\t\t};\n\n\t\treturn {\n\t\t\tclose,\n\t\t\tnativeCacheHit,\n\t\t\tserial,\n\t\t\tstartedEmulator,\n\t\t\ttimings: { ...phaseDurations },\n\t\t\trebuild: async () => {\n\t\t\t\tif (closed) {\n\t\t\t\t\tthrow new Error('Android development session is closed.');\n\t\t\t\t}\n\t\t\t\tlog(\n\t\t\t\t\t'Android native inputs changed; rebuilding without restarting the dev server.'\n\t\t\t\t);\n\t\t\t\tawait close();\n\n\t\t\t\treturn startAbsoluteAndroidDevSession(options);\n\t\t\t},\n\t\t\trelaunch: async () => {\n\t\t\t\tif (closed) {\n\t\t\t\t\tthrow new Error('Android development session is closed.');\n\t\t\t\t}\n\t\t\t\ttransition('launching');\n\t\t\t\ttry {\n\t\t\t\t\tawait launchAndroidApp(\n\t\t\t\t\t\tproject,\n\t\t\t\t\t\tserial,\n\t\t\t\t\t\t'Android app relaunch',\n\t\t\t\t\t\trun,\n\t\t\t\t\t\t{ env, signal: options.signal }\n\t\t\t\t\t);\n\t\t\t\t\ttransition('ready');\n\t\t\t\t\tlog(`Android app relaunched on ${serial}.`);\n\t\t\t\t} catch (error) {\n\t\t\t\t\ttransition('failed');\n\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t},\n\t\t\tget state() {\n\t\t\t\treturn state;\n\t\t\t}\n\t\t};\n\t} catch (error) {\n\t\ttransition('failed');\n\t\tawait closeNativeLogs();\n\t\tawait removeAdbReverse(\n\t\t\tproject,\n\t\t\tconnectedSerial,\n\t\t\toptions.port,\n\t\t\trun,\n\t\t\tenv\n\t\t);\n\t\tawait repairAbsoluteAndroidDevSession(project.projectRoot);\n\n\t\tthrow error;\n\t}\n};\n",
|
|
21
|
+
"import {\n\taccess,\n\tcopyFile,\n\tlstat,\n\tmkdir,\n\treadFile,\n\treaddir,\n\treadlink,\n\trealpath,\n\trename,\n\trm,\n\twriteFile\n} from 'node:fs/promises';\nimport { createHash, randomUUID } from 'node:crypto';\nimport {\n\tdirname,\n\tisAbsolute,\n\tjoin,\n\trelative,\n\tresolve,\n\tsep,\n\twin32\n} from 'node:path';\nimport {\n\tABSOLUTE_ANDROID_AVD_NAME,\n\tabsoluteManagedAndroidSdkRoot,\n\tdetectAbsoluteMobileHost,\n\tinspectAbsoluteMobileToolchain,\n\ttype AbsoluteMobileHost\n} from './emulatorDoctor';\nimport type { NormalizedAbsoluteMobileConfig } from './config';\nimport { writeAbsoluteCapacitorConfig } from './capacitorProject';\nimport { getDurationString } from '../utils/getDurationString';\n\nconst ANDROID_BOOT_TIMEOUT_MS = 180_000;\nconst ANDROID_BOOT_POLL_MS = 1_000;\nconst DEV_JOURNAL_FORMAT = 1;\nconst NATIVE_CACHE_FORMAT = 1;\nconst HASH_RADIX = 16;\nconst EXECUTABLE_MODE_MASK = 0o111;\nconst NATIVE_PUBLIC_PATH_SEGMENTS = 5;\nconst CAPACITOR_PROJECT_DIRECTORY_PATTERN =\n\t/project\\(['\"](:[^'\"]+)['\"]\\)\\.projectDir\\s*=\\s*new File\\(['\"]([^'\"]+)['\"]\\)/gu;\n\nexport type AbsoluteAndroidCommandOptions = {\n\tcwd?: string;\n\tenv?: Record<string, string | undefined>;\n\tsignal?: AbortSignal;\n};\n\nexport type AbsoluteAndroidCommandResult = {\n\texitCode: number;\n\tstderr: string;\n\tstdout: string;\n};\n\nexport type AbsoluteAndroidDevState =\n\t| 'booting'\n\t| 'building'\n\t| 'closed'\n\t| 'closing'\n\t| 'configuring'\n\t| 'connecting'\n\t| 'failed'\n\t| 'forwarding'\n\t| 'installing'\n\t| 'checking-native'\n\t| 'launching'\n\t| 'ready'\n\t| 'streaming-logs'\n\t| 'syncing';\n\nexport type AbsoluteAndroidNativeLogEntry = {\n\tlevel: 'debug' | 'error' | 'fatal' | 'info' | 'verbose' | 'warn';\n\tmessage: string;\n\ttag: string;\n};\n\ntype AbsoluteAndroidLogStream = {\n\tclose: () => Promise<void>;\n};\n\ntype AndroidDevJournal = {\n\tbackupPath: string;\n\tformat: number;\n\tmanifestBackupPath?: string;\n\tnativeConfigPath: string;\n\tnativeManifestPath?: string;\n\tprojectedFiles?: Array<{\n\t\tbackupPath?: string;\n\t\tpath: string;\n\t}>;\n};\n\ntype AndroidNativeCache = {\n\tappId: string;\n\tfingerprint: string;\n\tformat: number;\n\tinstallations: Record<string, string>;\n};\n\ntype AndroidInstalledPackage = {\n\tidentity: string;\n\tuid?: string;\n};\n\nexport type AbsoluteAndroidDevProject = {\n\tadb: string;\n\tandroidRoot: string;\n\tcap: string;\n\tconfig: NormalizedAbsoluteMobileConfig;\n\temulator?: string;\n\thost: AbsoluteMobileHost;\n\tnativeDirectory: string;\n\tprojectRoot: string;\n};\n\nexport type AbsoluteAndroidDevSession = {\n\tclose: () => Promise<void>;\n\tnativeCacheHit: boolean;\n\trebuild: () => Promise<AbsoluteAndroidDevSession>;\n\trelaunch: () => Promise<void>;\n\tserial: string;\n\tstate: AbsoluteAndroidDevState;\n\tstartedEmulator: boolean;\n\ttimings: Record<string, number>;\n};\n\nexport type AbsoluteAndroidDevPhaseTiming = {\n\tdurationMs: number;\n\tphase: AbsoluteAndroidDevState;\n\ttotalMs: number;\n};\n\nconst ANDROID_TIMING_PHASES: Array<[string, string]> = [\n\t['syncing', 'Capacitor sync'],\n\t['configuring', 'dev config'],\n\t['fingerprinting', 'fingerprint'],\n\t['booting', 'emulator'],\n\t['connecting', 'device ready'],\n\t['forwarding', 'ADB reverse'],\n\t['checking-native', 'package check'],\n\t['building', 'Gradle'],\n\t['installing', 'install'],\n\t['launching', 'launch'],\n\t['streaming-logs', 'logs']\n];\n\nconst androidTimingSummary = (\n\ttimings: Record<string, number>,\n\tphysicalDevice = false\n) =>\n\tANDROID_TIMING_PHASES.map(([phase, label]) => {\n\t\tconst duration = timings[phase];\n\t\tif (duration === undefined || label === undefined) return null;\n\t\tlet phaseLabel = label;\n\t\tif (physicalDevice && phase === 'booting')\n\t\t\tphaseLabel = 'device selection';\n\t\tif (physicalDevice && phase === 'forwarding')\n\t\t\tphaseLabel = 'LAN transport';\n\n\t\treturn `${phaseLabel} ${getDurationString(duration)}`;\n\t})\n\t\t.filter((value): value is string => value !== null)\n\t\t.join(', ');\n\nexport type PrepareAbsoluteAndroidDevOptions = {\n\tcreateNativeProject: boolean;\n\tprojectRoot: string;\n\ttarget?: 'device' | 'emulator';\n\trun?: (\n\t\tcommand: string[],\n\t\toptions?: AbsoluteAndroidCommandOptions\n\t) => Promise<number>;\n};\n\nexport type StartAbsoluteAndroidDevOptions = {\n\tcapture?: (\n\t\tcommand: string[],\n\t\toptions?: AbsoluteAndroidCommandOptions\n\t) => AbsoluteAndroidCommandResult;\n\tlog?: (message: string) => void;\n\tnativeLog?: (entry: AbsoluteAndroidNativeLogEntry) => void;\n\tonPhaseTiming?: (timing: AbsoluteAndroidDevPhaseTiming) => void;\n\tonStateChange?: (state: AbsoluteAndroidDevState) => void;\n\thttps?: boolean;\n\t/** Launch the locally embedded production web bundle while forwarding\n\t * `port` only for its configured backend. No dev-server URL is written. */\n\tembeddedBundle?: boolean;\n\t/** A connected physical device selected explicitly by ADB serial. */\n\tdeviceSerial?: string;\n\t/** CA certificate temporarily trusted only by this development app. */\n\tcertificateAuthorityPath?: string;\n\tport: number;\n\tproject: AbsoluteAndroidDevProject;\n\t/** Hostname or LAN address loaded by the physical device. */\n\tserverHost?: string;\n\trun?: (\n\t\tcommand: string[],\n\t\toptions?: AbsoluteAndroidCommandOptions\n\t) => Promise<number>;\n\tsignal?: AbortSignal;\n\tsleep?: (milliseconds: number) => Promise<void>;\n\tspawn?: (\n\t\tcommand: string[],\n\t\toptions?: AbsoluteAndroidCommandOptions\n\t) => void;\n\tstartNativeLogs?: (\n\t\tcommand: string[],\n\t\toptions: AbsoluteAndroidCommandOptions,\n\t\tonLine: (line: string) => void\n\t) => AbsoluteAndroidLogStream;\n};\n\nconst pathExists = async (path: string) => {\n\ttry {\n\t\tawait access(path);\n\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n};\n\nconst forwardCommandOutput = (\n\tstream: ReadableStream<Uint8Array>,\n\tdestination: NodeJS.WriteStream\n) =>\n\tstream.pipeTo(\n\t\tnew WritableStream({\n\t\t\twrite: (chunk) => {\n\t\t\t\tdestination.write(chunk);\n\t\t\t}\n\t\t})\n\t);\n\nconst runCommand = async (\n\tcommand: string[],\n\toptions: AbsoluteAndroidCommandOptions = {}\n) => {\n\tconst subprocess = Bun.spawn(command, {\n\t\tcwd: options.cwd,\n\t\tenv: options.env,\n\t\tsignal: options.signal,\n\t\tstderr: 'pipe',\n\t\tstdin: 'ignore',\n\t\tstdout: 'pipe'\n\t});\n\tconst [exitCode] = await Promise.all([\n\t\tsubprocess.exited,\n\t\tforwardCommandOutput(subprocess.stdout, process.stdout),\n\t\tforwardCommandOutput(subprocess.stderr, process.stderr)\n\t]);\n\n\treturn exitCode;\n};\n\nconst captureCommand = (\n\tcommand: string[],\n\toptions: AbsoluteAndroidCommandOptions = {}\n) => {\n\ttry {\n\t\tconst result = Bun.spawnSync(command, {\n\t\t\tcwd: options.cwd,\n\t\t\tenv: options.env,\n\t\t\tstderr: 'pipe',\n\t\t\tstdout: 'pipe'\n\t\t});\n\n\t\treturn {\n\t\t\texitCode: result.exitCode,\n\t\t\tstderr: result.stderr.toString(),\n\t\t\tstdout: result.stdout.toString()\n\t\t};\n\t} catch (error) {\n\t\treturn {\n\t\t\texitCode: 1,\n\t\t\tstderr: error instanceof Error ? error.message : String(error),\n\t\t\tstdout: ''\n\t\t};\n\t}\n};\n\nconst spawnCommand = (\n\tcommand: string[],\n\toptions: AbsoluteAndroidCommandOptions = {}\n) => {\n\tBun.spawn(command, {\n\t\tcwd: options.cwd,\n\t\tenv: options.env,\n\t\tstderr: 'ignore',\n\t\tstdin: 'ignore',\n\t\tstdout: 'ignore'\n\t});\n};\n\nconst LOGCAT_LINE_PATTERN =\n\t/^\\d{2}-\\d{2}\\s+\\d{2}:\\d{2}:\\d{2}\\.\\d+\\s+\\d+\\s+\\d+\\s+([VDIWEF])\\s+([^:]+):\\s?(.*)$/u;\nconst ASCII_CONTROL_END = 31;\nconst ASCII_DELETE = 127;\nconst ASCII_ESCAPE = 27;\nconst ASCII_HORIZONTAL_TAB = 9;\nconst LOGCAT_MESSAGE_CAPTURE = 3;\nconst UNFOUND_INDEX = -1;\nconst ANSI_SEQUENCE_PATTERN = new RegExp(\n\t`${String.fromCharCode(ASCII_ESCAPE)}(?:\\\\[[0-?]*[ -/]*[@-~]|[@-_])`,\n\t'gu'\n);\nconst AUTHORIZATION_SECRET_PATTERN =\n\t/([\"']?(?:authorization|proxy-authorization)[\"']?\\s*[:=]\\s*)(?:Bearer|Basic)\\s+[^\\s,;]+/giu;\nconst BEARER_SECRET_PATTERN = /\\b(Bearer)\\s+[^\\s,;]+/giu;\nconst COOKIE_SECRET_PATTERN =\n\t/([\"']?(?:cookie|set-cookie)[\"']?\\s*[:=]\\s*).*/giu;\nconst NAMED_SECRET_PATTERN =\n\t/([\"']?(?:access_token|refresh_token|id_token|client_secret|password|code|token)[\"']?\\s*[:=]\\s*)(\"[^\"]*\"|'[^']*'|[^\\s&,;]+)/giu;\nconst QUERY_SECRET_PATTERN = /([?&](?:code|token)=)[^&\\s]+/giu;\n\nexport const redactAbsoluteAndroidLog = (value: string) =>\n\tvalue\n\t\t.replace(ANSI_SEQUENCE_PATTERN, '')\n\t\t.split('')\n\t\t.filter((character) => {\n\t\t\tconst code = character.charCodeAt(0);\n\n\t\t\treturn (\n\t\t\t\tcode === ASCII_HORIZONTAL_TAB ||\n\t\t\t\t(code > ASCII_CONTROL_END && code !== ASCII_DELETE)\n\t\t\t);\n\t\t})\n\t\t.join('')\n\t\t.replace(AUTHORIZATION_SECRET_PATTERN, '$1[REDACTED]')\n\t\t.replace(BEARER_SECRET_PATTERN, '$1 [REDACTED]')\n\t\t.replace(COOKIE_SECRET_PATTERN, '$1[REDACTED]')\n\t\t.replace(NAMED_SECRET_PATTERN, '$1[REDACTED]')\n\t\t.replace(QUERY_SECRET_PATTERN, '$1[REDACTED]');\n\nconst androidLogLevel = (level: string) => {\n\tif (level === 'V') return 'verbose';\n\tif (level === 'D') return 'debug';\n\tif (level === 'W') return 'warn';\n\tif (level === 'E') return 'error';\n\tif (level === 'F') return 'fatal';\n\n\treturn 'info';\n};\n\nconst emitCompleteLogLines = (\n\tvalue: string,\n\tonLine: (line: string) => void\n) => {\n\tlet buffered = value;\n\tlet newlineIndex = buffered.indexOf('\\n');\n\twhile (newlineIndex !== UNFOUND_INDEX) {\n\t\tonLine(buffered.slice(0, newlineIndex).replace(/\\r$/u, ''));\n\t\tbuffered = buffered.slice(newlineIndex + 1);\n\t\tnewlineIndex = buffered.indexOf('\\n');\n\t}\n\n\treturn buffered;\n};\n\nconst decodeLogStream = () => {\n\tconst decoder = new TextDecoder();\n\n\treturn new TransformStream<Uint8Array, string>({\n\t\tflush: (controller) => {\n\t\t\tconst remaining = decoder.decode();\n\t\t\tif (remaining) controller.enqueue(remaining);\n\t\t},\n\t\ttransform: (chunk, controller) => {\n\t\t\tconst decoded = decoder.decode(chunk, { stream: true });\n\t\t\tif (decoded) controller.enqueue(decoded);\n\t\t}\n\t});\n};\n\nexport const isIgnorableAbsoluteAndroidLog = (\n\tentry: AbsoluteAndroidNativeLogEntry\n) =>\n\tentry.tag === 'Capacitor/Console' &&\n\tentry.message.includes('Error injecting safe area CSS:') &&\n\tentry.message.includes(\"Cannot read properties of null (reading 'style')\");\nexport const parseAbsoluteAndroidLogLine = (\n\tline: string\n): AbsoluteAndroidNativeLogEntry | null => {\n\tconst sanitized = redactAbsoluteAndroidLog(line).trim();\n\tif (!sanitized) return null;\n\tconst match = LOGCAT_LINE_PATTERN.exec(sanitized);\n\tif (!match) {\n\t\treturn { level: 'info', message: sanitized, tag: 'logcat' };\n\t}\n\n\treturn {\n\t\tlevel: androidLogLevel(match[1] ?? 'I'),\n\t\tmessage: match[LOGCAT_MESSAGE_CAPTURE] ?? '',\n\t\ttag: match[2]?.trim() || 'android'\n\t};\n};\n\nconst consumeLogLines = async (\n\tstream: ReadableStream<Uint8Array>,\n\tonLine: (line: string) => void\n) => {\n\tlet buffered = '';\n\tawait stream.pipeThrough(decodeLogStream()).pipeTo(\n\t\tnew WritableStream({\n\t\t\twrite: (chunk) => {\n\t\t\t\tbuffered = emitCompleteLogLines(buffered + chunk, onLine);\n\t\t\t}\n\t\t})\n\t);\n\tif (buffered) {\n\t\tonLine(buffered.replace(/\\r$/u, ''));\n\t}\n};\n\nconst startNativeLogStream = (\n\tcommand: string[],\n\toptions: AbsoluteAndroidCommandOptions,\n\tonLine: (line: string) => void\n): AbsoluteAndroidLogStream => {\n\tconst subprocess = Bun.spawn(command, {\n\t\tenv: options.env,\n\t\tstderr: 'pipe',\n\t\tstdin: 'ignore',\n\t\tstdout: 'pipe'\n\t});\n\tconst output = Promise.all([\n\t\tconsumeLogLines(subprocess.stdout, onLine),\n\t\tconsumeLogLines(subprocess.stderr, onLine)\n\t]);\n\tvoid output.catch(() => undefined);\n\n\treturn {\n\t\tclose: async () => {\n\t\t\ttry {\n\t\t\t\tsubprocess.kill();\n\t\t\t} catch {\n\t\t\t\t/* logcat already exited */\n\t\t\t}\n\t\t\tawait Promise.all([\n\t\t\t\tsubprocess.exited.catch(() => undefined),\n\t\t\t\toutput.catch(() => undefined)\n\t\t\t]);\n\t\t}\n\t};\n};\n\nconst requireSuccess = async (\n\tcommand: string[],\n\tlabel: string,\n\trun: NonNullable<StartAbsoluteAndroidDevOptions['run']>,\n\toptions?: AbsoluteAndroidCommandOptions\n) => {\n\tconst exitCode = await run(command, options);\n\tthrowIfAborted(options?.signal);\n\tif (exitCode !== 0) throw new Error(`${label} failed (exit ${exitCode}).`);\n};\n\nconst throwIfAborted = (signal?: AbortSignal) => {\n\tif (!signal?.aborted) return;\n\tthrow new DOMException(\n\t\t'Android development startup was cancelled.',\n\t\t'AbortError'\n\t);\n};\n\nconst journalPaths = (projectRoot: string) => {\n\tconst root = join(projectRoot, '.absolutejs', 'mobile', 'dev-session');\n\n\treturn {\n\t\tbackup: join(root, 'capacitor.config.backup.json'),\n\t\tcaBackup: join(root, 'absolutejs_dev_ca.backup.pem'),\n\t\tjournal: join(root, 'journal.json'),\n\t\tmanifestBackup: join(root, 'AndroidManifest.backup.xml'),\n\t\tnetworkConfigBackup: join(\n\t\t\troot,\n\t\t\t'absolutejs_dev_network_security.backup.xml'\n\t\t),\n\t\troot\n\t};\n};\n\nconst isInside = (root: string, path: string) => {\n\tconst resolvedRoot = resolve(root);\n\tconst resolvedPath = resolve(path);\n\tconst relativePath = relative(resolvedRoot, resolvedPath);\n\n\treturn (\n\t\trelativePath === '' ||\n\t\t(relativePath !== '..' &&\n\t\t\t!relativePath.startsWith(`..${sep}`) &&\n\t\t\t!isAbsolute(relativePath))\n\t);\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n\ttypeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst nativeCachePath = (projectRoot: string) =>\n\tjoin(projectRoot, '.absolutejs', 'mobile', 'cache', 'android-debug.json');\n\nconst parseNativeCache = (value: unknown): AndroidNativeCache | null => {\n\tif (!isRecord(value)) return null;\n\tconst { appId, fingerprint, format, installations } = value;\n\tif (\n\t\tformat !== NATIVE_CACHE_FORMAT ||\n\t\ttypeof appId !== 'string' ||\n\t\ttypeof fingerprint !== 'string' ||\n\t\t!isRecord(installations) ||\n\t\t!Object.values(installations).every(\n\t\t\t(identity) => typeof identity === 'string'\n\t\t)\n\t) {\n\t\treturn null;\n\t}\n\n\treturn {\n\t\tappId,\n\t\tfingerprint,\n\t\tformat,\n\t\tinstallations: Object.fromEntries(\n\t\t\tObject.entries(installations).map(([serial, identity]) => [\n\t\t\t\tserial,\n\t\t\t\tString(identity)\n\t\t\t])\n\t\t)\n\t};\n};\n\nconst readNativeCache = async (projectRoot: string) =>\n\treadFile(nativeCachePath(projectRoot), 'utf8')\n\t\t.then((source) => parseNativeCache(JSON.parse(source)))\n\t\t.catch(() => null);\n\nconst writeNativeCache = async (\n\tprojectRoot: string,\n\tcache: AndroidNativeCache\n) => {\n\tconst destination = nativeCachePath(projectRoot);\n\tconst temporary = `${destination}.${process.pid}.${randomUUID()}.tmp`;\n\tawait mkdir(dirname(destination), { recursive: true });\n\ttry {\n\t\tawait writeFile(temporary, `${JSON.stringify(cache, null, '\\t')}\\n`, {\n\t\t\tflag: 'wx'\n\t\t});\n\t\tawait rename(temporary, destination);\n\t} finally {\n\t\tawait rm(temporary, { force: true }).catch(() => undefined);\n\t}\n};\n\nconst nativeDependencySources = async (nativeDirectory: string) => {\n\tconst settings = await readFile(\n\t\tjoin(nativeDirectory, 'capacitor.settings.gradle'),\n\t\t'utf8'\n\t);\n\tconst pattern = new RegExp(\n\t\tCAPACITOR_PROJECT_DIRECTORY_PATTERN.source,\n\t\tCAPACITOR_PROJECT_DIRECTORY_PATTERN.flags\n\t);\n\tconst dependencies = [...settings.matchAll(pattern)].map((match) => ({\n\t\tname: (match[1] ?? '').slice(1).replaceAll(/[^a-zA-Z0-9_.-]/gu, '_'),\n\t\tsource: resolve(nativeDirectory, match[2] ?? '')\n\t}));\n\tif (dependencies.length === 0) {\n\t\tthrow new Error(\n\t\t\t'Capacitor Android settings did not declare any native dependencies.'\n\t\t);\n\t}\n\n\treturn { dependencies, settings };\n};\n\nconst shouldIgnoreNativePath = (\n\trelativePath: string,\n\tignorePublicBundle: boolean\n) => {\n\tconst parts = relativePath.split(sep);\n\tif (\n\t\tparts.includes('.gradle') ||\n\t\tparts.includes('build') ||\n\t\tparts.includes('.absolutejs-dependencies')\n\t) {\n\t\treturn true;\n\t}\n\n\treturn (\n\t\tignorePublicBundle &&\n\t\tparts.slice(0, NATIVE_PUBLIC_PATH_SEGMENTS).join('/') ===\n\t\t\t'app/src/main/assets/public'\n\t);\n};\n\ntype NativeDirectoryCollector = (\n\troot: string,\n\tlabel: string,\n\tdirectory: string,\n\tignorePublicBundle: boolean\n) => Promise<string[]>;\n\nconst collectNativePath = async (\n\troot: string,\n\tlabel: string,\n\tpath: string,\n\tisDirectory: boolean,\n\tisFile: boolean,\n\tisSymbolicLink: boolean,\n\tignorePublicBundle: boolean\n) => {\n\tconst relativePath = relative(root, path);\n\tif (shouldIgnoreNativePath(relativePath, ignorePublicBundle)) return [];\n\tconst identity = `${label}:${relativePath.split(sep).join('/')}\\0`;\n\tif (isDirectory) {\n\t\treturn collectNativeDirectory(root, label, path, ignorePublicBundle);\n\t}\n\tif (isSymbolicLink) {\n\t\treturn [`link\\0${identity}${await readlink(path)}\\0`];\n\t}\n\tif (!isFile) return [];\n\tconst [metadata, contents] = await Promise.all([\n\t\tlstat(path),\n\t\treadFile(path)\n\t]);\n\tconst contentDigest = createHash('sha256').update(contents).digest('hex');\n\n\treturn [\n\t\t`file\\0${identity}${metadata.mode & EXECUTABLE_MODE_MASK}\\0${contentDigest}\\0`\n\t];\n};\n\nconst collectNativeDirectory: NativeDirectoryCollector = async (\n\troot,\n\tlabel,\n\tdirectory,\n\tignorePublicBundle\n) => {\n\tconst entries = await readdir(directory, { withFileTypes: true });\n\tentries.sort((left, right) => left.name.localeCompare(right.name));\n\tconst records = await Promise.all(\n\t\tentries.map((entry) =>\n\t\t\tcollectNativePath(\n\t\t\t\troot,\n\t\t\t\tlabel,\n\t\t\t\tjoin(directory, entry.name),\n\t\t\t\tentry.isDirectory(),\n\t\t\t\tentry.isFile(),\n\t\t\t\tentry.isSymbolicLink(),\n\t\t\t\tignorePublicBundle\n\t\t\t)\n\t\t)\n\t);\n\n\treturn records.flat();\n};\n\nconst hashNativeTree = async (\n\troot: string,\n\tlabel: string,\n\tignorePublicBundle: boolean\n) => {\n\tconst resolvedRoot = await realpath(root);\n\tconst records = await collectNativeDirectory(\n\t\tresolvedRoot,\n\t\tlabel,\n\t\tresolvedRoot,\n\t\tignorePublicBundle\n\t);\n\n\treturn createHash('sha256').update(records.join('')).digest('hex');\n};\n\ntype NativeFingerprintRoot = {\n\tignorePublicBundle: boolean;\n\tlabel: string;\n\tsource: string;\n};\n\nexport const fingerprintAbsoluteAndroidNativeProject = async (\n\tproject: Pick<AbsoluteAndroidDevProject, 'nativeDirectory'>,\n\toptions: { includePublicBundle?: boolean } = {}\n) => {\n\tconst { dependencies } = await nativeDependencySources(\n\t\tproject.nativeDirectory\n\t);\n\tconst roots: NativeFingerprintRoot[] = [\n\t\t{\n\t\t\tignorePublicBundle: options.includePublicBundle !== true,\n\t\t\tlabel: 'android',\n\t\t\tsource: project.nativeDirectory\n\t\t},\n\t\t...dependencies\n\t\t\t.sort((left, right) => left.name.localeCompare(right.name))\n\t\t\t.map((dependency) => ({\n\t\t\t\tignorePublicBundle: false,\n\t\t\t\tlabel: `dependency:${dependency.name}`,\n\t\t\t\tsource: dependency.source\n\t\t\t}))\n\t];\n\tconst treeDigests = await Promise.all(\n\t\troots.map((root) =>\n\t\t\thashNativeTree(root.source, root.label, root.ignorePublicBundle)\n\t\t)\n\t);\n\n\treturn createHash('sha256').update(treeDigests.join('\\0')).digest('hex');\n};\n\nconst parseJournal = (value: unknown): AndroidDevJournal | null => {\n\tif (typeof value !== 'object' || value === null) return null;\n\tconst backupPath = Reflect.get(value, 'backupPath');\n\tconst format = Reflect.get(value, 'format');\n\tconst manifestBackupPath = Reflect.get(value, 'manifestBackupPath');\n\tconst nativeConfigPath = Reflect.get(value, 'nativeConfigPath');\n\tconst nativeManifestPath = Reflect.get(value, 'nativeManifestPath');\n\tconst projectedFiles = Reflect.get(value, 'projectedFiles');\n\tif (\n\t\ttypeof backupPath !== 'string' ||\n\t\tformat !== DEV_JOURNAL_FORMAT ||\n\t\ttypeof nativeConfigPath !== 'string'\n\t) {\n\t\treturn null;\n\t}\n\tif (\n\t\t(manifestBackupPath !== undefined ||\n\t\t\tnativeManifestPath !== undefined) &&\n\t\t(typeof manifestBackupPath !== 'string' ||\n\t\t\ttypeof nativeManifestPath !== 'string')\n\t) {\n\t\treturn null;\n\t}\n\tif (\n\t\tprojectedFiles !== undefined &&\n\t\t(!Array.isArray(projectedFiles) ||\n\t\t\t!projectedFiles.every(\n\t\t\t\t(file) =>\n\t\t\t\t\tisRecord(file) &&\n\t\t\t\t\ttypeof file.path === 'string' &&\n\t\t\t\t\t(file.backupPath === undefined ||\n\t\t\t\t\t\ttypeof file.backupPath === 'string')\n\t\t\t))\n\t) {\n\t\treturn null;\n\t}\n\n\treturn {\n\t\tbackupPath,\n\t\tformat,\n\t\tmanifestBackupPath,\n\t\tnativeConfigPath,\n\t\tnativeManifestPath,\n\t\tprojectedFiles\n\t};\n};\n\nconst restoreAndroidProjectedFile = async (\n\tfile: NonNullable<AndroidDevJournal['projectedFiles']>[number]\n) => {\n\tif (!file.backupPath || !(await pathExists(file.backupPath))) {\n\t\tawait rm(file.path, { force: true });\n\n\t\treturn;\n\t}\n\tawait mkdir(dirname(file.path), { recursive: true });\n\tawait copyFile(file.backupPath, file.path);\n};\n\nexport const repairAbsoluteAndroidDevSession = async (projectRoot: string) => {\n\tconst paths = journalPaths(projectRoot);\n\tif (!(await pathExists(paths.journal))) {\n\t\tawait rm(paths.root, { force: true, recursive: true });\n\n\t\treturn false;\n\t}\n\tconst journal = await readFile(paths.journal, 'utf8')\n\t\t.then((source) => parseJournal(JSON.parse(source)))\n\t\t.catch(() => null);\n\tif (\n\t\t!journal ||\n\t\t!isInside(projectRoot, journal.nativeConfigPath) ||\n\t\t!isInside(paths.root, journal.backupPath) ||\n\t\t(journal.nativeManifestPath !== undefined &&\n\t\t\t!isInside(projectRoot, journal.nativeManifestPath)) ||\n\t\t(journal.manifestBackupPath !== undefined &&\n\t\t\t!isInside(paths.root, journal.manifestBackupPath)) ||\n\t\tjournal.projectedFiles?.some(\n\t\t\t(file) =>\n\t\t\t\t!isInside(projectRoot, file.path) ||\n\t\t\t\t(file.backupPath !== undefined &&\n\t\t\t\t\t!isInside(paths.root, file.backupPath))\n\t\t)\n\t) {\n\t\tthrow new Error(\n\t\t\t`Refusing unsafe or invalid mobile dev journal at ${paths.journal}.`\n\t\t);\n\t}\n\tif (await pathExists(journal.backupPath)) {\n\t\tawait mkdir(dirname(journal.nativeConfigPath), { recursive: true });\n\t\tawait copyFile(journal.backupPath, journal.nativeConfigPath);\n\t}\n\tif (\n\t\tjournal.manifestBackupPath &&\n\t\tjournal.nativeManifestPath &&\n\t\t(await pathExists(journal.manifestBackupPath))\n\t) {\n\t\tawait mkdir(dirname(journal.nativeManifestPath), { recursive: true });\n\t\tawait copyFile(journal.manifestBackupPath, journal.nativeManifestPath);\n\t}\n\tawait Promise.all(\n\t\t(journal.projectedFiles ?? []).map(restoreAndroidProjectedFile)\n\t);\n\tawait rm(paths.root, { force: true, recursive: true });\n\n\treturn true;\n};\n\nconst setAndroidApplicationAttribute = (\n\tsource: string,\n\tattribute: string,\n\tvalue: string\n) => {\n\tconst pattern = new RegExp(`android:${attribute}=[\"'][^\"']*[\"']`, 'u');\n\tif (pattern.test(source))\n\t\treturn source.replace(pattern, `android:${attribute}=\"${value}\"`);\n\n\treturn source.replace(\n\t\t'<application',\n\t\t`<application\\n android:${attribute}=\"${value}\"`\n\t);\n};\n\nconst androidDevelopmentManifest = (\n\tsource: string,\n\tcleartext: boolean,\n\tdevelopmentNetworkConfig?: string\n) => {\n\tlet projected = source;\n\tif (developmentNetworkConfig) {\n\t\tprojected = setAndroidApplicationAttribute(\n\t\t\tprojected,\n\t\t\t'networkSecurityConfig',\n\t\t\t`@xml/${developmentNetworkConfig}`\n\t\t);\n\t}\n\tif (!cleartext) return projected;\n\tif (/android:usesCleartextTraffic=[\"'][^\"']*[\"']/u.test(source)) {\n\t\treturn projected.replace(\n\t\t\t/android:usesCleartextTraffic=[\"'][^\"']*[\"']/u,\n\t\t\t'android:usesCleartextTraffic=\"true\"'\n\t\t);\n\t}\n\n\treturn setAndroidApplicationAttribute(\n\t\tprojected,\n\t\t'usesCleartextTraffic',\n\t\t'true'\n\t);\n};\n\nconst withAndroidDebugCertificateAuthority = (source: string) => {\n\tif (source.includes('@raw/absolutejs_dev_ca')) return source;\n\tconst debugOverrides =\n\t\t/<debug-overrides(?:\\s[^>]*)?>([\\s\\S]*?)<\\/debug-overrides>/u;\n\tconst match = source.match(debugOverrides);\n\tif (match) {\n\t\tconst [block] = match;\n\t\tconst trustAnchors = /<trust-anchors(?:\\s[^>]*)?>/u;\n\t\tconst projectedBlock = trustAnchors.test(block)\n\t\t\t? block.replace(\n\t\t\t\t\ttrustAnchors,\n\t\t\t\t\t'$&\\n\\t\\t\\t<certificates src=\"@raw/absolutejs_dev_ca\" />'\n\t\t\t\t)\n\t\t\t: block.replace(\n\t\t\t\t\t'</debug-overrides>',\n\t\t\t\t\t'\\t<trust-anchors>\\n\\t\\t\\t<certificates src=\"@raw/absolutejs_dev_ca\" />\\n\\t\\t</trust-anchors>\\n\\t</debug-overrides>'\n\t\t\t\t);\n\n\t\treturn source.replace(block, projectedBlock);\n\t}\n\tif (!source.includes('</network-security-config>')) {\n\t\tthrow new Error('Android Network Security Configuration is invalid.');\n\t}\n\n\treturn source.replace(\n\t\t'</network-security-config>',\n\t\t'\\t<debug-overrides>\\n\\t\\t<trust-anchors>\\n\\t\\t\\t<certificates src=\"@raw/absolutejs_dev_ca\" />\\n\\t\\t</trust-anchors>\\n\\t</debug-overrides>\\n</network-security-config>'\n\t);\n};\n\nconst writeDevConfig = async (\n\tprojectRoot: string,\n\tnativeConfigPath: string,\n\tnativeManifestPath: string,\n\tport: number,\n\thttps: boolean,\n\tentry: string,\n\tembeddedBundle: boolean,\n\tserverHost: string,\n\tcertificateAuthorityPath?: string\n) => {\n\tconst paths = journalPaths(projectRoot);\n\tawait repairAbsoluteAndroidDevSession(projectRoot);\n\tconst source = await readFile(nativeConfigPath, 'utf8');\n\tconst manifestSource = await readFile(nativeManifestPath, 'utf8');\n\tconst parsed: unknown = JSON.parse(source);\n\tif (!isRecord(parsed)) {\n\t\tthrow new Error(\n\t\t\t`Invalid Capacitor native config at ${nativeConfigPath}.`\n\t\t);\n\t}\n\tawait mkdir(paths.root, { recursive: true });\n\tawait writeFile(paths.backup, source, { flag: 'wx' });\n\tawait writeFile(paths.manifestBackup, manifestSource, { flag: 'wx' });\n\tconst resourceRoot = join(dirname(nativeManifestPath), 'res');\n\tconst caPath = join(resourceRoot, 'raw', 'absolutejs_dev_ca.pem');\n\tconst existingNetworkConfig = manifestSource.match(\n\t\t/android:networkSecurityConfig=[\"']@xml\\/([a-z0-9_]+)[\"']/u\n\t)?.[1];\n\tconst networkConfigName =\n\t\texistingNetworkConfig ?? 'absolutejs_dev_network_security';\n\tconst networkConfigPath = join(\n\t\tresourceRoot,\n\t\t'xml',\n\t\t`${networkConfigName}.xml`\n\t);\n\tconst backupProjectedFile = async ([path, backupPath]: readonly [\n\t\tstring,\n\t\tstring\n\t]) => {\n\t\tif (!(await pathExists(path))) return { path };\n\t\tawait copyFile(path, backupPath);\n\n\t\treturn { backupPath, path };\n\t};\n\tconst projectedFiles: AndroidDevJournal['projectedFiles'] =\n\t\thttps && certificateAuthorityPath\n\t\t\t? await Promise.all(\n\t\t\t\t\t(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t[caPath, paths.caBackup],\n\t\t\t\t\t\t\t[networkConfigPath, paths.networkConfigBackup]\n\t\t\t\t\t\t] as const\n\t\t\t\t\t).map(backupProjectedFile)\n\t\t\t\t)\n\t\t\t: [];\n\tconst journal: AndroidDevJournal = {\n\t\tbackupPath: paths.backup,\n\t\tformat: DEV_JOURNAL_FORMAT,\n\t\tmanifestBackupPath: paths.manifestBackup,\n\t\tnativeConfigPath,\n\t\tnativeManifestPath,\n\t\tprojectedFiles\n\t};\n\tawait writeFile(paths.journal, `${JSON.stringify(journal, null, '\\t')}\\n`, {\n\t\tflag: 'wx'\n\t});\n\tif (!embeddedBundle) {\n\t\tconst currentServer = parsed.server;\n\t\tconst developmentUrl = new URL(\n\t\t\t`${https ? 'https' : 'http'}://${serverHost}:${port}${entry}`\n\t\t);\n\t\tdevelopmentUrl.searchParams.set(\n\t\t\t'__absolute_target',\n\t\t\t'capacitor-android'\n\t\t);\n\t\tparsed.server = {\n\t\t\t...(typeof currentServer === 'object' && currentServer !== null\n\t\t\t\t? currentServer\n\t\t\t\t: {}),\n\t\t\tcleartext: !https,\n\t\t\turl: developmentUrl.href\n\t\t};\n\t}\n\tawait writeFile(\n\t\tnativeConfigPath,\n\t\t`${JSON.stringify(parsed, null, '\\t')}\\n`\n\t);\n\tif (https && certificateAuthorityPath) {\n\t\tawait Promise.all([\n\t\t\tmkdir(dirname(caPath), { recursive: true }),\n\t\t\tmkdir(dirname(networkConfigPath), { recursive: true })\n\t\t]);\n\t\tawait copyFile(certificateAuthorityPath, caPath);\n\t\tconst existingNetworkConfigSource = existingNetworkConfig\n\t\t\t? await readFile(networkConfigPath, 'utf8')\n\t\t\t: '<?xml version=\"1.0\" encoding=\"utf-8\"?>\\n<network-security-config>\\n</network-security-config>\\n';\n\t\tawait writeFile(\n\t\t\tnetworkConfigPath,\n\t\t\twithAndroidDebugCertificateAuthority(existingNetworkConfigSource)\n\t\t);\n\t}\n\tawait writeFile(\n\t\tnativeManifestPath,\n\t\tandroidDevelopmentManifest(\n\t\t\tmanifestSource,\n\t\t\t!https,\n\t\t\thttps && certificateAuthorityPath !== undefined\n\t\t\t\t? networkConfigName\n\t\t\t\t: undefined\n\t\t)\n\t);\n};\n\nexport const parseAdbDevices = (output: string) =>\n\toutput\n\t\t.split(/\\r?\\n/)\n\t\t.slice(1)\n\t\t.map((line) => line.trim().split(/\\s+/, 2))\n\t\t.filter(\n\t\t\t(parts): parts is [string, string] =>\n\t\t\t\tparts.length === 2 && parts[1] === 'device'\n\t\t)\n\t\t.map(([serial]) => serial);\n\nconst isManagedEmulatorSerial = (\n\tserial: string,\n\tadb: string,\n\tcapture: NonNullable<StartAbsoluteAndroidDevOptions['capture']>,\n\tenv: Record<string, string | undefined>\n) => {\n\tif (!serial.startsWith('emulator-')) return false;\n\tconst avd = capture([adb, '-s', serial, 'emu', 'avd', 'name'], { env });\n\n\treturn (\n\t\tavd.exitCode === 0 &&\n\t\tavd.stdout\n\t\t\t.split(/\\r?\\n/)\n\t\t\t.map((value) => value.trim())\n\t\t\t.includes(ABSOLUTE_ANDROID_AVD_NAME)\n\t);\n};\n\nconst managedEmulatorSerial = (\n\tadb: string,\n\tcapture: NonNullable<StartAbsoluteAndroidDevOptions['capture']>,\n\tenv: Record<string, string | undefined>\n) => {\n\tconst devices = capture([adb, 'devices'], { env });\n\tif (devices.exitCode !== 0) return undefined;\n\n\treturn parseAdbDevices(devices.stdout).find((serial) =>\n\t\tisManagedEmulatorSerial(serial, adb, capture, env)\n\t);\n};\n\nconst requireConnectedAndroidDevice = (\n\tadb: string,\n\tserial: string,\n\tcapture: NonNullable<StartAbsoluteAndroidDevOptions['capture']>,\n\tenv: Record<string, string | undefined>\n) => {\n\tconst devices = capture([adb, 'devices'], { env });\n\tif (\n\t\tdevices.exitCode !== 0 ||\n\t\t!parseAdbDevices(devices.stdout).includes(serial)\n\t) {\n\t\tthrow new Error(\n\t\t\t`Android device ${serial} is not connected and authorized. Confirm the USB debugging prompt, then retry.`\n\t\t);\n\t}\n};\n\nconst completedBootSerial = (\n\tproject: AbsoluteAndroidDevProject,\n\tcapture: NonNullable<StartAbsoluteAndroidDevOptions['capture']>,\n\tenv: Record<string, string | undefined>\n) => {\n\tconst serial = managedEmulatorSerial(project.adb, capture, env);\n\tif (!serial) return undefined;\n\tconst booted = capture(\n\t\t[project.adb, '-s', serial, 'shell', 'getprop', 'sys.boot_completed'],\n\t\t{ env }\n\t);\n\n\treturn booted.exitCode === 0 && booted.stdout.trim() === '1'\n\t\t? serial\n\t\t: undefined;\n};\n\nconst preferredCompletedBootSerial = (\n\tproject: AbsoluteAndroidDevProject,\n\tserial: string,\n\tcapture: NonNullable<StartAbsoluteAndroidDevOptions['capture']>,\n\tenv: Record<string, string | undefined>\n) => {\n\tconst booted = capture(\n\t\t[project.adb, '-s', serial, 'shell', 'getprop', 'sys.boot_completed'],\n\t\t{ env }\n\t);\n\n\treturn booted.exitCode === 0 && booted.stdout.trim() === '1'\n\t\t? serial\n\t\t: undefined;\n};\n\nconst waitForManagedEmulator = async (\n\tproject: AbsoluteAndroidDevProject,\n\tcapture: NonNullable<StartAbsoluteAndroidDevOptions['capture']>,\n\tsleep: NonNullable<StartAbsoluteAndroidDevOptions['sleep']>,\n\tenv: Record<string, string | undefined>,\n\tsignal?: AbortSignal,\n\tpreferredSerial?: string\n) => {\n\tconst deadline = Date.now() + ANDROID_BOOT_TIMEOUT_MS;\n\tconst poll = async () => {\n\t\tthrowIfAborted(signal);\n\t\tconst serial = preferredSerial\n\t\t\t? preferredCompletedBootSerial(\n\t\t\t\t\tproject,\n\t\t\t\t\tpreferredSerial,\n\t\t\t\t\tcapture,\n\t\t\t\t\tenv\n\t\t\t\t)\n\t\t\t: completedBootSerial(project, capture, env);\n\t\tif (serial) return serial;\n\t\tif (Date.now() >= deadline) {\n\t\t\tthrow new Error(\n\t\t\t\t`Android ${preferredSerial ? `target ${preferredSerial}` : `emulator ${ABSOLUTE_ANDROID_AVD_NAME}`} did not finish booting within ${ANDROID_BOOT_TIMEOUT_MS / ANDROID_BOOT_POLL_MS}s.`\n\t\t\t);\n\t\t}\n\t\tawait sleep(ANDROID_BOOT_POLL_MS);\n\n\t\treturn poll();\n\t};\n\n\treturn poll();\n};\n\nconst windowsPathFromWsl = (\n\tpath: string,\n\tcapture: NonNullable<StartAbsoluteAndroidDevOptions['capture']>\n) => {\n\tconst result = capture(['wslpath', '-w', path]);\n\tif (result.exitCode !== 0 || !result.stdout.trim()) {\n\t\tthrow new Error(`Could not translate WSL path for Windows: ${path}`);\n\t}\n\n\treturn result.stdout.trim();\n};\n\ntype WindowsGradleDependency = {\n\tname: string;\n\twindowsSource: string;\n};\n\nconst mirroredCapacitorDependencies = async (\n\tproject: Pick<AbsoluteAndroidDevProject, 'nativeDirectory'>,\n\tcapture: NonNullable<StartAbsoluteAndroidDevOptions['capture']>\n) => {\n\tconst settingsPath = join(\n\t\tproject.nativeDirectory,\n\t\t'capacitor.settings.gradle'\n\t);\n\tconst settings = await readFile(settingsPath, 'utf8');\n\tconst dependencies: WindowsGradleDependency[] = [];\n\tconst rewrittenSettings = settings.replace(\n\t\tCAPACITOR_PROJECT_DIRECTORY_PATTERN,\n\t\t(_statement, projectName: string, sourcePath: string) => {\n\t\t\tconst name = projectName\n\t\t\t\t.slice(1)\n\t\t\t\t.replaceAll(/[^a-zA-Z0-9_.-]/gu, '_');\n\t\t\tconst source = resolve(project.nativeDirectory, sourcePath);\n\t\t\tdependencies.push({\n\t\t\t\tname,\n\t\t\t\twindowsSource: windowsPathFromWsl(source, capture)\n\t\t\t});\n\n\t\t\treturn `project('${projectName}').projectDir = new File('./.absolutejs-dependencies/${name}')`;\n\t\t}\n\t);\n\tif (dependencies.length === 0) {\n\t\tthrow new Error(\n\t\t\t'Capacitor Android settings did not declare any native dependencies.'\n\t\t);\n\t}\n\n\treturn { dependencies, rewrittenSettings };\n};\n\nconst encodedWindowsGradleCommand = (\n\twindowsSource: string,\n\twindowsDirectory: string,\n\twindowsAndroidRoot: string,\n\tdependencies: WindowsGradleDependency[],\n\trewrittenSettings: string,\n\ttask: AbsoluteAndroidGradleTask,\n\tgradleArguments: readonly string[]\n) => {\n\tconst sourceDirectory = Buffer.from(windowsSource, 'utf8').toString(\n\t\t'base64'\n\t);\n\tconst buildDirectory = Buffer.from(windowsDirectory, 'utf8').toString(\n\t\t'base64'\n\t);\n\tconst androidRoot = Buffer.from(windowsAndroidRoot, 'utf8').toString(\n\t\t'base64'\n\t);\n\tconst dependencyData = Buffer.from(\n\t\tJSON.stringify(dependencies),\n\t\t'utf8'\n\t).toString('base64');\n\tconst settingsData = Buffer.from(rewrittenSettings, 'utf8').toString(\n\t\t'base64'\n\t);\n\tconst argumentsData = Buffer.from(\n\t\tJSON.stringify(gradleArguments),\n\t\t'utf8'\n\t).toString('base64');\n\tconst source = [\n\t\t\"$ErrorActionPreference = 'Stop'\",\n\t\t`$source = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('${sourceDirectory}'))`,\n\t\t`$directory = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('${buildDirectory}'))`,\n\t\t`$androidHome = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('${androidRoot}'))`,\n\t\t`$dependencies = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('${dependencyData}')) | ConvertFrom-Json`,\n\t\t`$settings = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('${settingsData}'))`,\n\t\t`$gradleArguments = @([Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('${argumentsData}')) | ConvertFrom-Json)`,\n\t\t'$env:ANDROID_HOME = $androidHome',\n\t\t'$env:ANDROID_SDK_ROOT = $androidHome',\n\t\t'New-Item -ItemType Directory -Force -Path $directory | Out-Null',\n\t\t'& robocopy.exe $source $directory /MIR /XD .gradle build .absolutejs-dependencies /NFL /NDL /NJH /NJS /NP',\n\t\t'$copyExit = $LASTEXITCODE',\n\t\t'if ($copyExit -ge 8) { exit $copyExit }',\n\t\t\"foreach ($dependency in @($dependencies)) { $target = Join-Path $directory ('.absolutejs-dependencies\\\\' + $dependency.name); New-Item -ItemType Directory -Force -Path $target | Out-Null; & robocopy.exe $dependency.windowsSource $target /MIR /XD .gradle build /NFL /NDL /NJH /NJS /NP; if ($LASTEXITCODE -ge 8) { exit $LASTEXITCODE } }\",\n\t\t\"[IO.File]::WriteAllText((Join-Path $directory 'capacitor.settings.gradle'), $settings)\",\n\t\t\"$wrapper = Join-Path $directory 'gradlew.bat'\",\n\t\t`& $wrapper --no-daemon --console=plain -p $directory @gradleArguments ${task}`,\n\t\t'if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }',\n\t\t'exit 0'\n\t].join('; ');\n\n\treturn Buffer.from(source, 'utf16le').toString('base64');\n};\n\nexport type AbsoluteAndroidGradleTask =\n\t| 'assembleDebug'\n\t| 'assembleRelease'\n\t| 'bundleRelease';\n\nexport type BuildAbsoluteAndroidGradleOptions = {\n\tcapture?: NonNullable<StartAbsoluteAndroidDevOptions['capture']>;\n\tenv?: Record<string, string | undefined>;\n\tgradleArguments?: readonly string[];\n\tproject: Pick<\n\t\tAbsoluteAndroidDevProject,\n\t\t'androidRoot' | 'config' | 'host' | 'nativeDirectory' | 'projectRoot'\n\t>;\n\trun?: NonNullable<StartAbsoluteAndroidDevOptions['run']>;\n\tsignal?: AbortSignal;\n\ttask: AbsoluteAndroidGradleTask;\n};\n\nconst gradleArtifactPath = (\n\tnativeDirectory: string,\n\ttask: AbsoluteAndroidGradleTask,\n\twindows = false\n) => {\n\tconst pathJoin = windows ? win32.join : join;\n\tif (task === 'assembleDebug') {\n\t\treturn pathJoin(\n\t\t\tnativeDirectory,\n\t\t\t'app',\n\t\t\t'build',\n\t\t\t'outputs',\n\t\t\t'apk',\n\t\t\t'debug',\n\t\t\t'app-debug.apk'\n\t\t);\n\t}\n\tif (task === 'assembleRelease') {\n\t\treturn pathJoin(\n\t\t\tnativeDirectory,\n\t\t\t'app',\n\t\t\t'build',\n\t\t\t'outputs',\n\t\t\t'apk',\n\t\t\t'release',\n\t\t\t'app-release.apk'\n\t\t);\n\t}\n\n\treturn pathJoin(\n\t\tnativeDirectory,\n\t\t'app',\n\t\t'build',\n\t\t'outputs',\n\t\t'bundle',\n\t\t'release',\n\t\t'app-release.aab'\n\t);\n};\n\nconst resolveGradleArtifactPath = async (\n\tnativeDirectory: string,\n\ttask: AbsoluteAndroidGradleTask\n) => {\n\tconst primary = gradleArtifactPath(nativeDirectory, task);\n\tif (task !== 'assembleRelease' || (await pathExists(primary))) {\n\t\treturn primary;\n\t}\n\n\treturn join(\n\t\tnativeDirectory,\n\t\t'app',\n\t\t'build',\n\t\t'outputs',\n\t\t'apk',\n\t\t'release',\n\t\t'app-release-unsigned.apk'\n\t);\n};\n\nexport const buildAbsoluteAndroidGradleArtifact = async (\n\toptions: BuildAbsoluteAndroidGradleOptions\n) => {\n\tconst { project, task } = options;\n\tconst capture = options.capture ?? captureCommand;\n\tconst run = options.run ?? runCommand;\n\tconst env = options.env ?? process.env;\n\tconst gradleArguments = options.gradleArguments ?? [];\n\tif (project.host === 'wsl') {\n\t\tconst windowsSource = windowsPathFromWsl(\n\t\t\tproject.nativeDirectory,\n\t\t\tcapture\n\t\t);\n\t\tconst buildId = Bun.hash(project.projectRoot).toString(HASH_RADIX);\n\t\tconst managedBuildDirectory = resolve(\n\t\t\tproject.androidRoot,\n\t\t\t'..',\n\t\t\t'..',\n\t\t\t'Builds',\n\t\t\t`${project.config.appId}-${buildId}`\n\t\t);\n\t\tconst windowsDirectory = windowsPathFromWsl(\n\t\t\tmanagedBuildDirectory,\n\t\t\tcapture\n\t\t);\n\t\tconst windowsAndroidRoot = windowsPathFromWsl(\n\t\t\tproject.androidRoot,\n\t\t\tcapture\n\t\t);\n\t\tconst { dependencies, rewrittenSettings } =\n\t\t\tawait mirroredCapacitorDependencies(project, capture);\n\t\tawait requireSuccess(\n\t\t\t[\n\t\t\t\t'powershell.exe',\n\t\t\t\t'-NoProfile',\n\t\t\t\t'-EncodedCommand',\n\t\t\t\tencodedWindowsGradleCommand(\n\t\t\t\t\twindowsSource,\n\t\t\t\t\twindowsDirectory,\n\t\t\t\t\twindowsAndroidRoot,\n\t\t\t\t\tdependencies,\n\t\t\t\t\trewrittenSettings,\n\t\t\t\t\ttask,\n\t\t\t\t\tgradleArguments\n\t\t\t\t)\n\t\t\t],\n\t\t\t'Android Gradle build',\n\t\t\trun,\n\t\t\t{ env, signal: options.signal }\n\t\t);\n\n\t\tconst artifactPath = await resolveGradleArtifactPath(\n\t\t\tmanagedBuildDirectory,\n\t\t\ttask\n\t\t);\n\t\tconst unsigned = artifactPath.endsWith('-unsigned.apk');\n\n\t\treturn {\n\t\t\tartifactPath,\n\t\t\tinstallPath: unsigned\n\t\t\t\t? win32.join(\n\t\t\t\t\t\twindowsDirectory,\n\t\t\t\t\t\t'app',\n\t\t\t\t\t\t'build',\n\t\t\t\t\t\t'outputs',\n\t\t\t\t\t\t'apk',\n\t\t\t\t\t\t'release',\n\t\t\t\t\t\t'app-release-unsigned.apk'\n\t\t\t\t\t)\n\t\t\t\t: gradleArtifactPath(windowsDirectory, task, true)\n\t\t};\n\t}\n\tconst wrapper = project.host === 'windows' ? 'gradlew.bat' : './gradlew';\n\tawait requireSuccess(\n\t\t[wrapper, '--no-daemon', '--console=plain', ...gradleArguments, task],\n\t\t'Android Gradle build',\n\t\trun,\n\t\t{ cwd: project.nativeDirectory, env, signal: options.signal }\n\t);\n\n\tconst artifactPath = await resolveGradleArtifactPath(\n\t\tproject.nativeDirectory,\n\t\ttask\n\t);\n\n\treturn { artifactPath, installPath: artifactPath };\n};\n\nconst buildAndroidDebugApp = async (\n\tproject: AbsoluteAndroidDevProject,\n\tcapture: NonNullable<StartAbsoluteAndroidDevOptions['capture']>,\n\trun: NonNullable<StartAbsoluteAndroidDevOptions['run']>,\n\tenv: Record<string, string | undefined>,\n\tsignal?: AbortSignal\n) =>\n\t(\n\t\tawait buildAbsoluteAndroidGradleArtifact({\n\t\t\tcapture,\n\t\t\tenv,\n\t\t\tproject,\n\t\t\trun,\n\t\t\tsignal,\n\t\t\ttask: 'assembleDebug'\n\t\t})\n\t).installPath;\n\ntype EnsureAndroidDebugAppOptions = {\n\tcache: AndroidNativeCache | null;\n\tcapture: NonNullable<StartAbsoluteAndroidDevOptions['capture']>;\n\tenv: Record<string, string | undefined>;\n\tfingerprint: string;\n\tlog: NonNullable<StartAbsoluteAndroidDevOptions['log']>;\n\tproject: AbsoluteAndroidDevProject;\n\trun: NonNullable<StartAbsoluteAndroidDevOptions['run']>;\n\tserial: string;\n\tsignal?: AbortSignal;\n\ttransition: (state: AbsoluteAndroidDevState) => void;\n};\n\nconst persistInstalledAndroidNativeCache = async (\n\toptions: EnsureAndroidDebugAppOptions,\n\tinstalled: AndroidInstalledPackage | undefined\n) => {\n\tif (!installed) {\n\t\toptions.log(\n\t\t\t'Android package identity was unavailable; the next session will rebuild safely.'\n\t\t);\n\n\t\treturn;\n\t}\n\tconst installations =\n\t\toptions.cache?.appId === options.project.config.appId &&\n\t\toptions.cache.fingerprint === options.fingerprint\n\t\t\t? { ...options.cache.installations }\n\t\t\t: {};\n\tinstallations[options.serial] = installed.identity;\n\tawait writeNativeCache(options.project.projectRoot, {\n\t\tappId: options.project.config.appId,\n\t\tfingerprint: options.fingerprint,\n\t\tformat: NATIVE_CACHE_FORMAT,\n\t\tinstallations\n\t}).catch((error) => {\n\t\toptions.log(\n\t\t\t`Android native cache could not be saved: ${error instanceof Error ? error.message : String(error)}`\n\t\t);\n\t});\n};\n\nconst ensureAndroidDebugApp = async (options: EnsureAndroidDebugAppOptions) => {\n\tconst installed = androidInstalledPackageIdentity(\n\t\toptions.project,\n\t\toptions.serial,\n\t\toptions.capture,\n\t\toptions.env\n\t);\n\tconst cacheHit =\n\t\toptions.cache?.appId === options.project.config.appId &&\n\t\toptions.cache.fingerprint === options.fingerprint &&\n\t\tinstalled !== undefined &&\n\t\toptions.cache.installations[options.serial] === installed.identity;\n\tif (cacheHit) {\n\t\toptions.log(\n\t\t\t`Android native app is unchanged on ${options.serial}; skipped Gradle build and APK install.`\n\t\t);\n\n\t\treturn { nativeCacheHit: true, uid: installed.uid };\n\t}\n\toptions.log(\n\t\t'Android native inputs changed or the installed app is stale; rebuilding.'\n\t);\n\toptions.transition('building');\n\tconst installPath = await buildAndroidDebugApp(\n\t\toptions.project,\n\t\toptions.capture,\n\t\toptions.run,\n\t\toptions.env,\n\t\toptions.signal\n\t);\n\tthrowIfAborted(options.signal);\n\toptions.transition('installing');\n\tawait requireSuccess(\n\t\t[\n\t\t\toptions.project.adb,\n\t\t\t'-s',\n\t\t\toptions.serial,\n\t\t\t'install',\n\t\t\t'-r',\n\t\t\t'-d',\n\t\t\tinstallPath\n\t\t],\n\t\t'Android app installation',\n\t\toptions.run,\n\t\t{ env: options.env, signal: options.signal }\n\t);\n\tconst updated = androidInstalledPackageIdentity(\n\t\toptions.project,\n\t\toptions.serial,\n\t\toptions.capture,\n\t\toptions.env\n\t);\n\tawait persistInstalledAndroidNativeCache(options, updated);\n\n\treturn { nativeCacheHit: false, uid: updated?.uid };\n};\n\nconst startManagedEmulatorIfNeeded = (\n\tproject: AbsoluteAndroidDevProject,\n\tcapture: NonNullable<StartAbsoluteAndroidDevOptions['capture']>,\n\tspawn: NonNullable<StartAbsoluteAndroidDevOptions['spawn']>,\n\tlog: NonNullable<StartAbsoluteAndroidDevOptions['log']>,\n\tenv: Record<string, string | undefined>\n) => {\n\tif (!project.emulator) {\n\t\tthrow new Error(\n\t\t\t'Android Emulator is unavailable. Select a physical device or run `absolute mobile doctor android --fix`.'\n\t\t);\n\t}\n\tconst serial = managedEmulatorSerial(project.adb, capture, env);\n\tif (serial) return { serial, started: false };\n\tlog(`Starting Android emulator ${ABSOLUTE_ANDROID_AVD_NAME}...`);\n\tspawn(\n\t\t[\n\t\t\tproject.emulator,\n\t\t\t'-avd',\n\t\t\tABSOLUTE_ANDROID_AVD_NAME,\n\t\t\t'-netdelay',\n\t\t\t'none',\n\t\t\t'-netspeed',\n\t\t\t'full'\n\t\t],\n\t\t{ env }\n\t);\n\n\treturn { serial: undefined, started: true };\n};\n\nconst logHttpsCertificateRequirement = (\n\thttps: boolean | undefined,\n\tlog: NonNullable<StartAbsoluteAndroidDevOptions['log']>\n) => {\n\tif (https !== true) return;\n\tlog(\n\t\t'Android HMR is using HTTPS; AbsoluteJS is projecting the local development CA into this debug app only.'\n\t);\n};\n\nconst removeAdbReverse = async (\n\tproject: AbsoluteAndroidDevProject,\n\tserial: string | undefined,\n\tport: number,\n\trun: NonNullable<StartAbsoluteAndroidDevOptions['run']>,\n\tenv: Record<string, string | undefined>\n) => {\n\tif (!serial) return;\n\tawait run(\n\t\t[project.adb, '-s', serial, 'reverse', '--remove', `tcp:${port}`],\n\t\t{ env }\n\t).catch(() => undefined);\n};\n\nconst androidLaunchCommand = (\n\tproject: AbsoluteAndroidDevProject,\n\tserial: string\n) => [\n\tproject.adb,\n\t'-s',\n\tserial,\n\t'shell',\n\t'monkey',\n\t'-p',\n\tproject.config.appId,\n\t'-c',\n\t'android.intent.category.LAUNCHER',\n\t'1'\n];\n\nconst stopAndroidAppCommand = (\n\tproject: AbsoluteAndroidDevProject,\n\tserial: string\n) => [\n\tproject.adb,\n\t'-s',\n\tserial,\n\t'shell',\n\t'am',\n\t'force-stop',\n\tproject.config.appId\n];\n\nconst launchAndroidApp = async (\n\tproject: AbsoluteAndroidDevProject,\n\tserial: string,\n\tdescription: string,\n\trun: NonNullable<StartAbsoluteAndroidDevOptions['run']>,\n\toptions: {\n\t\tenv: Record<string, string | undefined>;\n\t\tsignal?: AbortSignal;\n\t}\n) => {\n\tawait requireSuccess(\n\t\tstopAndroidAppCommand(project, serial),\n\t\t`${description} reset`,\n\t\trun,\n\t\toptions\n\t);\n\tawait requireSuccess(\n\t\tandroidLaunchCommand(project, serial),\n\t\tdescription,\n\t\trun,\n\t\toptions\n\t);\n};\n\nconst androidPackageUid = (\n\tproject: AbsoluteAndroidDevProject,\n\tserial: string,\n\tcapture: NonNullable<StartAbsoluteAndroidDevOptions['capture']>,\n\tenv: Record<string, string | undefined>\n) => {\n\tconst result = capture(\n\t\t[\n\t\t\tproject.adb,\n\t\t\t'-s',\n\t\t\tserial,\n\t\t\t'shell',\n\t\t\t'cmd',\n\t\t\t'package',\n\t\t\t'list',\n\t\t\t'packages',\n\t\t\t'-U',\n\t\t\tproject.config.appId\n\t\t],\n\t\t{ env }\n\t);\n\tif (result.exitCode !== 0) return undefined;\n\tconst escapedAppId = project.config.appId.replace(\n\t\t/[.*+?^${}()|[\\]\\\\]/gu,\n\t\t'\\\\$&'\n\t);\n\tconst match = new RegExp(`package:${escapedAppId}\\\\s+uid:(\\\\d+)`, 'u').exec(\n\t\tresult.stdout\n\t);\n\n\treturn match?.[1];\n};\n\nconst androidInstalledPackageIdentity = (\n\tproject: AbsoluteAndroidDevProject,\n\tserial: string,\n\tcapture: NonNullable<StartAbsoluteAndroidDevOptions['capture']>,\n\tenv: Record<string, string | undefined>\n) => {\n\tconst result = capture(\n\t\t[\n\t\t\tproject.adb,\n\t\t\t'-s',\n\t\t\tserial,\n\t\t\t'shell',\n\t\t\t'dumpsys',\n\t\t\t'package',\n\t\t\tproject.config.appId\n\t\t],\n\t\t{ env }\n\t);\n\tif (result.exitCode !== 0) return undefined;\n\tconst codePath = /^\\s*codePath=(.+)$/mu.exec(result.stdout)?.[1]?.trim();\n\tconst lastUpdateTime = /^\\s*lastUpdateTime=(.+)$/mu\n\t\t.exec(result.stdout)?.[1]\n\t\t?.trim();\n\tif (!codePath || !lastUpdateTime) return undefined;\n\tconst uid = /^\\s*appId=(\\d+)$/mu.exec(result.stdout)?.[1];\n\n\treturn { identity: `${codePath}\\0${lastUpdateTime}`, uid };\n};\n\nconst attachAndroidNativeLogs = (\n\tproject: AbsoluteAndroidDevProject,\n\tserial: string,\n\tcapture: NonNullable<StartAbsoluteAndroidDevOptions['capture']>,\n\tenv: Record<string, string | undefined>,\n\toptions: StartAbsoluteAndroidDevOptions,\n\tknownUid?: string\n) => {\n\tif (!options.nativeLog) return null;\n\tconst uid = knownUid ?? androidPackageUid(project, serial, capture, env);\n\tif (!uid) {\n\t\toptions.log?.(\n\t\t\t`Android app logs unavailable: could not resolve the package UID for ${project.config.appId}.`\n\t\t);\n\n\t\treturn null;\n\t}\n\tconst onLine = (line: string) => {\n\t\tconst entry = parseAbsoluteAndroidLogLine(line);\n\t\t// Capacitor 8 SystemBars can run before documentElement exists. A later\n\t\t// inset pass applies the values; keep the plugin enabled because disabling\n\t\t// it breaks edge-to-edge layout on Android 16. Remove this narrow filter\n\t\t// when https://github.com/ionic-team/capacitor/issues/8530 is fixed.\n\t\tif (entry && !isIgnorableAbsoluteAndroidLog(entry)) {\n\t\t\toptions.nativeLog?.(entry);\n\t\t}\n\t};\n\n\treturn (options.startNativeLogs ?? startNativeLogStream)(\n\t\t[\n\t\t\tproject.adb,\n\t\t\t'-s',\n\t\t\tserial,\n\t\t\t'logcat',\n\t\t\t`--uid=${uid}`,\n\t\t\t'-v',\n\t\t\t'threadtime',\n\t\t\t'-T',\n\t\t\t'1',\n\t\t\t'*:W',\n\t\t\t'Capacitor:V',\n\t\t\t'Capacitor/Console:V',\n\t\t\t'chromium:I'\n\t\t],\n\t\t{ env },\n\t\tonLine\n\t);\n};\n\nexport const prepareAbsoluteAndroidDevProject = async (\n\tconfig: NormalizedAbsoluteMobileConfig,\n\toptions: PrepareAbsoluteAndroidDevOptions\n): Promise<AbsoluteAndroidDevProject> => {\n\tconst projectRoot = resolve(options.projectRoot);\n\tconst host = detectAbsoluteMobileHost();\n\tconst androidRoot =\n\t\tprocess.env.ANDROID_HOME ??\n\t\tprocess.env.ANDROID_SDK_ROOT ??\n\t\tabsoluteManagedAndroidSdkRoot(host);\n\tconst checks = await inspectAbsoluteMobileToolchain({ androidRoot, host });\n\tconst deviceOnlyChecks = new Set([\n\t\t'android.avd',\n\t\t'android.avdmanager',\n\t\t'android.emulator',\n\t\t'android.virtualization'\n\t]);\n\tconst failed = checks.filter(\n\t\t(check) =>\n\t\t\tcheck.platform === 'android' &&\n\t\t\t(check.status === 'fail' || check.status === 'warn') &&\n\t\t\t(options.target !== 'device' || !deviceOnlyChecks.has(check.id))\n\t);\n\tif (failed.length > 0) {\n\t\tthrow new Error(\n\t\t\t`Android ${options.target === 'device' ? 'device development' : 'emulation'} is not ready: ${failed.map(({ label }) => label).join(', ')}.`\n\t\t);\n\t}\n\tconst adb = checks.find((check) => check.id === 'android.adb')?.path;\n\tconst emulator = checks.find(\n\t\t(check) => check.id === 'android.emulator'\n\t)?.path;\n\tif (!adb || (options.target !== 'device' && !emulator)) {\n\t\tthrow new Error(\n\t\t\t'Android SDK tools disappeared after readiness checks.'\n\t\t);\n\t}\n\tconst cap = join(\n\t\tprojectRoot,\n\t\t'node_modules',\n\t\t'.bin',\n\t\thost === 'windows' ? 'cap.cmd' : 'cap'\n\t);\n\tif (!(await pathExists(cap))) {\n\t\tthrow new Error(\n\t\t\t'Capacitor CLI is not installed. Run absolute mobile init first.'\n\t\t);\n\t}\n\tawait writeAbsoluteCapacitorConfig(config, { projectRoot });\n\tawait mkdir(config.bundleDirectory, { recursive: true });\n\tconst placeholder = join(config.bundleDirectory, 'index.html');\n\tif (!(await pathExists(placeholder))) {\n\t\tawait writeFile(\n\t\t\tplaceholder,\n\t\t\t'<!doctype html><title>AbsoluteJS mobile development</title>\\n'\n\t\t);\n\t}\n\tconst nativeDirectory = join(config.nativeProjectDirectory, 'android');\n\tif (!(await pathExists(nativeDirectory))) {\n\t\tif (!options.createNativeProject) {\n\t\t\tthrow new Error('Android native project has not been created.');\n\t\t}\n\t\tconst run = options.run ?? runCommand;\n\t\tif (\n\t\t\t(await run([cap, 'add', 'android'], {\n\t\t\t\tcwd: projectRoot\n\t\t\t})) !== 0\n\t\t) {\n\t\t\tthrow new Error('Capacitor Android project creation failed.');\n\t\t}\n\t}\n\n\treturn {\n\t\tadb,\n\t\tandroidRoot,\n\t\tcap,\n\t\tconfig,\n\t\t...(emulator ? { emulator } : {}),\n\t\thost,\n\t\tnativeDirectory,\n\t\tprojectRoot\n\t};\n};\n\nexport const startAbsoluteAndroidDevSession = async (\n\toptions: StartAbsoluteAndroidDevOptions\n) => {\n\tconst { project } = options;\n\tconst startupStartedAt = performance.now();\n\tlet phaseStartedAt = performance.now();\n\tconst phaseDurations: Record<string, number> = {};\n\tlet state: AbsoluteAndroidDevState = 'syncing';\n\tconst transition = (next: AbsoluteAndroidDevState) => {\n\t\tif (next === state) {\n\t\t\toptions.onStateChange?.(next);\n\n\t\t\treturn;\n\t\t}\n\t\tconst now = performance.now();\n\t\tconst durationMs = now - phaseStartedAt;\n\t\tphaseDurations[state] = (phaseDurations[state] ?? 0) + durationMs;\n\t\toptions.onPhaseTiming?.({\n\t\t\tdurationMs,\n\t\t\tphase: state,\n\t\t\ttotalMs: now - startupStartedAt\n\t\t});\n\t\tstate = next;\n\t\tphaseStartedAt = now;\n\t\toptions.onStateChange?.(next);\n\t};\n\tconst capture = options.capture ?? captureCommand;\n\tconst run = options.run ?? runCommand;\n\tconst sleep = options.sleep ?? Bun.sleep;\n\tconst spawn = options.spawn ?? spawnCommand;\n\tconst log = options.log ?? console.log;\n\tconst androidHome =\n\t\tproject.host === 'wsl'\n\t\t\t? windowsPathFromWsl(project.androidRoot, capture)\n\t\t\t: project.androidRoot;\n\tconst env: Record<string, string | undefined> = {\n\t\t...process.env,\n\t\tANDROID_HOME: androidHome\n\t};\n\ttransition('syncing');\n\tawait repairAbsoluteAndroidDevSession(project.projectRoot);\n\tthrowIfAborted(options.signal);\n\tawait requireSuccess(\n\t\t[project.cap, 'sync', 'android'],\n\t\t'Capacitor Android synchronization',\n\t\trun,\n\t\t{ cwd: project.projectRoot, env, signal: options.signal }\n\t);\n\tthrowIfAborted(options.signal);\n\ttransition('configuring');\n\tconst nativeConfigPath = join(\n\t\tproject.nativeDirectory,\n\t\t'app',\n\t\t'src',\n\t\t'main',\n\t\t'assets',\n\t\t'capacitor.config.json'\n\t);\n\tconst nativeManifestPath = join(\n\t\tproject.nativeDirectory,\n\t\t'app',\n\t\t'src',\n\t\t'main',\n\t\t'AndroidManifest.xml'\n\t);\n\tlet connectedSerial: string | undefined;\n\tlet nativeLogs: AbsoluteAndroidLogStream | null = null;\n\tconst closeNativeLogs = async () => {\n\t\tconst stream = nativeLogs;\n\t\tnativeLogs = null;\n\t\tawait stream?.close().catch(() => undefined);\n\t};\n\ttry {\n\t\tconst physicalDevice = options.deviceSerial !== undefined;\n\t\tif (options.https && !options.certificateAuthorityPath) {\n\t\t\tthrow new Error(\n\t\t\t\t'Android HTTPS development requires the AbsoluteJS development CA certificate.'\n\t\t\t);\n\t\t}\n\t\tawait writeDevConfig(\n\t\t\tproject.projectRoot,\n\t\t\tnativeConfigPath,\n\t\t\tnativeManifestPath,\n\t\t\toptions.port,\n\t\t\toptions.https === true,\n\t\t\tproject.config.entry,\n\t\t\toptions.embeddedBundle === true,\n\t\t\toptions.serverHost ?? 'localhost',\n\t\t\toptions.certificateAuthorityPath\n\t\t);\n\t\tthrowIfAborted(options.signal);\n\t\tlogHttpsCertificateRequirement(options.https, log);\n\t\tconst fingerprintStartedAt = performance.now();\n\t\tconst nativeFingerprintPromise =\n\t\t\tfingerprintAbsoluteAndroidNativeProject(project, {\n\t\t\t\tincludePublicBundle: options.embeddedBundle === true\n\t\t\t}).then((fingerprint) => {\n\t\t\t\tphaseDurations.fingerprinting =\n\t\t\t\t\tperformance.now() - fingerprintStartedAt;\n\n\t\t\t\treturn fingerprint;\n\t\t\t});\n\t\ttransition('booting');\n\t\tif (options.deviceSerial)\n\t\t\trequireConnectedAndroidDevice(\n\t\t\t\tproject.adb,\n\t\t\t\toptions.deviceSerial,\n\t\t\t\tcapture,\n\t\t\t\tenv\n\t\t\t);\n\t\tconst emulator = options.deviceSerial\n\t\t\t? { serial: options.deviceSerial, started: false }\n\t\t\t: startManagedEmulatorIfNeeded(project, capture, spawn, log, env);\n\t\tconst { started: startedEmulator } = emulator;\n\t\ttransition('connecting');\n\t\tconst serial = await waitForManagedEmulator(\n\t\t\tproject,\n\t\t\tcapture,\n\t\t\tsleep,\n\t\t\tenv,\n\t\t\toptions.signal,\n\t\t\temulator.serial\n\t\t);\n\t\tconnectedSerial = serial;\n\t\ttransition('forwarding');\n\t\tif (!physicalDevice)\n\t\t\tawait requireSuccess(\n\t\t\t\t[\n\t\t\t\t\tproject.adb,\n\t\t\t\t\t'-s',\n\t\t\t\t\tserial,\n\t\t\t\t\t'reverse',\n\t\t\t\t\t`tcp:${options.port}`,\n\t\t\t\t\t`tcp:${options.port}`\n\t\t\t\t],\n\t\t\t\t'ADB reverse port forwarding',\n\t\t\t\trun,\n\t\t\t\t{ env, signal: options.signal }\n\t\t\t);\n\t\tthrowIfAborted(options.signal);\n\t\tconst nativeFingerprint = await nativeFingerprintPromise;\n\t\tthrowIfAborted(options.signal);\n\t\ttransition('checking-native');\n\t\tconst cache = await readNativeCache(project.projectRoot);\n\t\tconst installedApp = await ensureAndroidDebugApp({\n\t\t\tcache,\n\t\t\tcapture,\n\t\t\tenv,\n\t\t\tfingerprint: nativeFingerprint,\n\t\t\tlog,\n\t\t\tproject,\n\t\t\trun,\n\t\t\tserial,\n\t\t\tsignal: options.signal,\n\t\t\ttransition\n\t\t});\n\t\tconst { nativeCacheHit, uid } = installedApp;\n\t\tthrowIfAborted(options.signal);\n\t\ttransition('launching');\n\t\tawait launchAndroidApp(project, serial, 'Android app launch', run, {\n\t\t\tenv,\n\t\t\tsignal: options.signal\n\t\t});\n\t\tthrowIfAborted(options.signal);\n\t\tif (options.nativeLog) transition('streaming-logs');\n\t\tnativeLogs = attachAndroidNativeLogs(\n\t\t\tproject,\n\t\t\tserial,\n\t\t\tcapture,\n\t\t\tenv,\n\t\t\toptions,\n\t\t\tuid\n\t\t);\n\t\ttransition('ready');\n\t\tphaseDurations.total = performance.now() - startupStartedAt;\n\t\tlog(\n\t\t\toptions.embeddedBundle === true\n\t\t\t\t? `Android ${physicalDevice ? 'device' : 'emulator'} connected (${serial}) with the embedded bundle and backend on port ${options.port} in ${getDurationString(phaseDurations.total)} (${nativeCacheHit ? 'native cache hit' : 'native build installed'}).`\n\t\t\t\t: `Android ${physicalDevice ? 'device' : 'emulator'} connected (${serial}) with HMR on port ${options.port} in ${getDurationString(phaseDurations.total)} (${nativeCacheHit ? 'native cache hit' : 'native build installed'}).`\n\t\t);\n\t\tlog(\n\t\t\t`Android startup: ${androidTimingSummary(phaseDurations, physicalDevice)}.`\n\t\t);\n\t\tlet closed = false;\n\t\tconst close = async () => {\n\t\t\tif (closed) return;\n\t\t\tclosed = true;\n\t\t\ttransition('closing');\n\t\t\tawait closeNativeLogs();\n\t\t\tif (!physicalDevice)\n\t\t\t\tawait removeAdbReverse(project, serial, options.port, run, env);\n\t\t\tawait repairAbsoluteAndroidDevSession(project.projectRoot);\n\t\t\ttransition('closed');\n\t\t};\n\n\t\treturn {\n\t\t\tclose,\n\t\t\tnativeCacheHit,\n\t\t\tserial,\n\t\t\tstartedEmulator,\n\t\t\ttimings: { ...phaseDurations },\n\t\t\trebuild: async () => {\n\t\t\t\tif (closed) {\n\t\t\t\t\tthrow new Error('Android development session is closed.');\n\t\t\t\t}\n\t\t\t\tlog(\n\t\t\t\t\t'Android native inputs changed; rebuilding without restarting the dev server.'\n\t\t\t\t);\n\t\t\t\tawait close();\n\n\t\t\t\treturn startAbsoluteAndroidDevSession(options);\n\t\t\t},\n\t\t\trelaunch: async () => {\n\t\t\t\tif (closed) {\n\t\t\t\t\tthrow new Error('Android development session is closed.');\n\t\t\t\t}\n\t\t\t\ttransition('launching');\n\t\t\t\ttry {\n\t\t\t\t\tawait launchAndroidApp(\n\t\t\t\t\t\tproject,\n\t\t\t\t\t\tserial,\n\t\t\t\t\t\t'Android app relaunch',\n\t\t\t\t\t\trun,\n\t\t\t\t\t\t{ env, signal: options.signal }\n\t\t\t\t\t);\n\t\t\t\t\ttransition('ready');\n\t\t\t\t\tlog(`Android app relaunched on ${serial}.`);\n\t\t\t\t} catch (error) {\n\t\t\t\t\ttransition('failed');\n\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t},\n\t\t\tget state() {\n\t\t\t\treturn state;\n\t\t\t}\n\t\t};\n\t} catch (error) {\n\t\ttransition('failed');\n\t\tawait closeNativeLogs();\n\t\tif (!options.deviceSerial)\n\t\t\tawait removeAdbReverse(\n\t\t\t\tproject,\n\t\t\t\tconnectedSerial,\n\t\t\t\toptions.port,\n\t\t\t\trun,\n\t\t\t\tenv\n\t\t\t);\n\t\tawait repairAbsoluteAndroidDevSession(project.projectRoot);\n\n\t\tthrow error;\n\t}\n};\n",
|
|
15
22
|
"import { access, readFile, rename, writeFile } from 'node:fs/promises';\nimport { relative, resolve } from 'node:path';\nimport type { NormalizedAbsoluteMobileConfig } from './config';\n\nexport type WriteAbsoluteCapacitorConfigOptions = {\n\tforce?: boolean;\n\tprojectRoot: string;\n};\n\nconst CONFIG_FILE = 'capacitor.config.ts';\n\nconst portableRelative = (root: string, path: string) =>\n\trelative(root, path).replaceAll('\\\\', '/');\n\nconst capacitorConfigSource = (\n\tconfig: NormalizedAbsoluteMobileConfig,\n\tprojectRoot: string\n) => `import type { CapacitorConfig } from '@capacitor/cli';\n\nconst config: CapacitorConfig = {\n\tappId: ${JSON.stringify(config.appId)},\n\tappName: ${JSON.stringify(config.appName)},\n\twebDir: ${JSON.stringify(portableRelative(projectRoot, config.bundleDirectory))},\n\tandroid: {\n\t\tpath: ${JSON.stringify(portableRelative(projectRoot, `${config.nativeProjectDirectory}/android`))}\n\t},\n\tios: {\n\t\tpath: ${JSON.stringify(portableRelative(projectRoot, `${config.nativeProjectDirectory}/ios`))}\n\t}\n};\n\nexport default config;\n`;\n\nconst exists = async (path: string) => {\n\ttry {\n\t\tawait access(path);\n\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n};\n\nexport const writeAbsoluteCapacitorConfig = async (\n\tconfig: NormalizedAbsoluteMobileConfig,\n\toptions: WriteAbsoluteCapacitorConfigOptions\n) => {\n\tconst projectRoot = resolve(options.projectRoot);\n\tconst destination = resolve(projectRoot, CONFIG_FILE);\n\tconst source = capacitorConfigSource(config, projectRoot);\n\tif (await exists(destination)) {\n\t\tconst current = await readFile(destination, 'utf8');\n\t\tif (current === source) return { changed: false, path: destination };\n\t\tif (!options.force) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`${CONFIG_FILE} already exists and differs; rerun with --force only after reviewing it.`\n\t\t\t);\n\t\t}\n\t}\n\tconst temporary = `${destination}.${crypto.randomUUID()}.tmp`;\n\tawait writeFile(temporary, source, { flag: 'wx' });\n\tawait rename(temporary, destination);\n\n\treturn { changed: true, path: destination };\n};\n",
|
|
16
|
-
"import { createHash } from 'node:crypto';\nimport {\n\taccess,\n\tcopyFile,\n\tmkdir,\n\tmkdtemp,\n\treaddir,\n\treadFile,\n\trename,\n\trm,\n\tstat,\n\twriteFile\n} from 'node:fs/promises';\nimport { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';\nimport type { NormalizedAbsoluteMobileConfig } from './config';\nimport {\n\tdetectAbsoluteMobileHost,\n\ttype AbsoluteMobileHost\n} from './emulatorDoctor';\n\nexport const ABSOLUTE_IOS_RELEASE_FORMAT = 1 as const;\n\nexport type AbsoluteIosReleaseMetadata = {\n\tappBuild: string;\n\tappId: string;\n\tartifact: 'App.ipa';\n\tbuildNumber?: number;\n\tbytes: number;\n\tengine: 'capacitor';\n\tformat: typeof ABSOLUTE_IOS_RELEASE_FORMAT;\n\tmarketingVersion: string;\n\tplatform: 'ios';\n\treleaseId: string;\n\truntime: string;\n\tsha256: string;\n\tsigned: boolean;\n\ttype: 'ipa';\n};\n\ntype MobileClientManifest = {\n\tappBuild: string;\n\tappId: string;\n\truntime: string;\n};\ntype CommandOptions = {\n\tcwd?: string;\n\tenv?: Record<string, string | undefined>;\n};\ntype CommandResult = { exitCode: number; stderr: string; stdout: string };\n\nexport type BuildAbsoluteIosReleaseOptions = {\n\tallowUnsigned?: boolean;\n\tcapture?: (command: string[], options?: CommandOptions) => CommandResult;\n\tconfig: NormalizedAbsoluteMobileConfig;\n\thost?: AbsoluteMobileHost;\n\toutputDirectory?: string;\n\tprepareBuildNumber?: (buildIdentity: string) => Promise<number>;\n\tprojectRoot: string;\n\trun?: (command: string[], options?: CommandOptions) => Promise<number>;\n\tbuildNumber?: number;\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n\ttypeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst requireManifest = (value: unknown): MobileClientManifest => {\n\tif (\n\t\t!isRecord(value) ||\n\t\ttypeof value.appBuild !== 'string' ||\n\t\ttypeof value.appId !== 'string' ||\n\t\ttypeof value.runtime !== 'string'\n\t) {\n\t\tthrow new TypeError('Invalid embedded AbsoluteJS mobile manifest.');\n\t}\n\n\treturn {\n\t\tappBuild: value.appBuild,\n\t\tappId: value.appId,\n\t\truntime: value.runtime\n\t};\n};\n\nconst pathExists = async (path: string) => {\n\ttry {\n\t\tawait access(path);\n\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n};\n\nconst defaultRun = async (command: string[], options: CommandOptions = {}) => {\n\tconst process = Bun.spawn(command, {\n\t\tcwd: options.cwd,\n\t\tenv: options.env,\n\t\tstderr: 'inherit',\n\t\tstdin: 'inherit',\n\t\tstdout: 'inherit'\n\t});\n\n\treturn process.exited;\n};\n\nconst defaultCapture = (command: string[], options: CommandOptions = {}) => {\n\ttry {\n\t\tconst result = Bun.spawnSync(command, {\n\t\t\tcwd: options.cwd,\n\t\t\tenv: options.env,\n\t\t\tstderr: 'pipe',\n\t\t\tstdin: 'ignore',\n\t\t\tstdout: 'pipe'\n\t\t});\n\n\t\treturn {\n\t\t\texitCode: result.exitCode,\n\t\t\tstderr: result.stderr.toString(),\n\t\t\tstdout: result.stdout.toString()\n\t\t};\n\t} catch (error) {\n\t\treturn {\n\t\t\texitCode: 1,\n\t\t\tstderr: error instanceof Error ? error.message : String(error),\n\t\t\tstdout: ''\n\t\t};\n\t}\n};\n\nconst ignoredFingerprintDirectories = new Set([\n\t'Pods',\n\t'DerivedData',\n\t'build',\n\t'xcuserdata'\n]);\n\nconst fingerprintFiles = async (\n\troot: string,\n\tcurrent = root\n): Promise<string[]> => {\n\tconst entries = await readdir(current, { withFileTypes: true });\n\tconst nested = await Promise.all(\n\t\tentries\n\t\t\t.sort((left, right) => left.name.localeCompare(right.name))\n\t\t\t.map(async (entry) => {\n\t\t\t\tconst path = join(current, entry.name);\n\t\t\t\tconst projectRelative = relative(root, path).replaceAll(\n\t\t\t\t\t'\\\\',\n\t\t\t\t\t'/'\n\t\t\t\t);\n\t\t\t\tconst ignored =\n\t\t\t\t\tentry.isDirectory() &&\n\t\t\t\t\t(ignoredFingerprintDirectories.has(entry.name) ||\n\t\t\t\t\t\tprojectRelative === 'App/App/public');\n\t\t\t\tif (ignored) return [];\n\t\t\t\tif (entry.isDirectory()) return fingerprintFiles(root, path);\n\n\t\t\t\treturn entry.isFile() ? [path] : [];\n\t\t\t})\n\t);\n\n\treturn nested.flat();\n};\n\nexport const fingerprintAbsoluteIosNativeProject = async (\n\tnativeDirectory: string\n) => {\n\tconst hasher = createHash('sha256');\n\tconst files = await fingerprintFiles(nativeDirectory);\n\tconst contents = await Promise.all(files.map((file) => readFile(file)));\n\tfiles.forEach((file, index) => {\n\t\thasher.update(relative(nativeDirectory, file).replaceAll('\\\\', '/'));\n\t\thasher.update('\\0');\n\t\thasher.update(contents[index] ?? new Uint8Array());\n\t\thasher.update('\\0');\n\t});\n\n\treturn hasher.digest('hex');\n};\n\nconst safeOutputDirectory = (projectRoot: string, requested?: string) => {\n\tconst root = resolve(projectRoot);\n\tconst output = resolve(\n\t\troot,\n\t\trequested ?? '.absolutejs/mobile/releases/ios'\n\t);\n\tconst projectRelative = relative(root, output);\n\tif (\n\t\tprojectRelative === '..' ||\n\t\tprojectRelative.startsWith(`..${sep}`) ||\n\t\tisAbsolute(projectRelative)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t'mobile build --outdir must remain inside the project.'\n\t\t);\n\t}\n\n\treturn output;\n};\n\nconst sha256File = async (path: string) =>\n\tcreateHash('sha256')\n\t\t.update(await readFile(path))\n\t\t.digest('hex');\n\nconst findByExtension = async (\n\troot: string,\n\textension: string\n): Promise<string | undefined> => {\n\tif (!(await pathExists(root))) return undefined;\n\tconst entries = await readdir(root, { withFileTypes: true });\n\tconst matches = await Promise.all(\n\t\tentries.map(async (entry) => {\n\t\t\tconst path = join(root, entry.name);\n\t\t\tif (entry.isDirectory() && entry.name.endsWith(extension))\n\t\t\t\treturn path;\n\t\t\tif (entry.isFile() && entry.name.endsWith(extension)) return path;\n\n\t\t\treturn entry.isDirectory()\n\t\t\t\t? findByExtension(path, extension)\n\t\t\t\t: undefined;\n\t\t})\n\t);\n\n\treturn matches.find((match) => match !== undefined);\n};\n\nconst exportOptions = () => `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\"><dict>\n\t<key>destination</key><string>export</string>\n\t<key>manageAppVersionAndBuildNumber</key><false/>\n\t<key>method</key><string>app-store-connect</string>\n\t<key>signingStyle</key><string>automatic</string>\n\t<key>stripSwiftSymbols</key><true/>\n\t<key>uploadSymbols</key><true/>\n</dict></plist>\n`;\n\nconst requireBuildNumber = (value: number | undefined) => {\n\tif (value !== undefined && (!Number.isSafeInteger(value) || value < 1))\n\t\tthrow new TypeError('iOS build number must be a positive integer.');\n\n\treturn value;\n};\n\nconst installRelease = async (\n\tartifactPath: string,\n\tmetadata: Omit<AbsoluteIosReleaseMetadata, 'artifact'>,\n\toutputRoot: string\n) => {\n\tconst releaseRoot = join(outputRoot, metadata.releaseId);\n\tconst destination = join(releaseRoot, 'App.ipa');\n\tif (await pathExists(releaseRoot)) {\n\t\tconst value: unknown = JSON.parse(\n\t\t\tawait readFile(join(releaseRoot, 'release.json'), 'utf8')\n\t\t);\n\t\tif (\n\t\t\t!isRecord(value) ||\n\t\t\tvalue.artifact !== 'App.ipa' ||\n\t\t\tObject.entries(metadata).some(\n\t\t\t\t([key, expected]) => Reflect.get(value, key) !== expected\n\t\t\t)\n\t\t) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`Immutable iOS release ${metadata.releaseId} does not match its content.`\n\t\t\t);\n\t\t}\n\t\tconst [bytes, sha256] = await Promise.all([\n\t\t\tstat(destination).then(({ size }) => size),\n\t\t\tsha256File(destination)\n\t\t]);\n\t\tif (bytes !== metadata.bytes || sha256 !== metadata.sha256)\n\t\t\tthrow new TypeError(\n\t\t\t\t`Immutable iOS release ${metadata.releaseId} artifact is missing or modified.`\n\t\t\t);\n\n\t\treturn {\n\t\t\tartifactPath: destination,\n\t\t\tmetadata: {\n\t\t\t\t...metadata,\n\t\t\t\tartifact: 'App.ipa'\n\t\t\t} satisfies AbsoluteIosReleaseMetadata,\n\t\t\treleaseRoot\n\t\t};\n\t}\n\tawait mkdir(dirname(releaseRoot), { recursive: true });\n\tconst staging = await mkdtemp(join(dirname(releaseRoot), '.ios-stage-'));\n\ttry {\n\t\tawait copyFile(artifactPath, join(staging, 'App.ipa'));\n\t\tconst complete = {\n\t\t\t...metadata,\n\t\t\tartifact: 'App.ipa'\n\t\t} satisfies AbsoluteIosReleaseMetadata;\n\t\tawait writeFile(\n\t\t\tjoin(staging, 'release.json'),\n\t\t\t`${JSON.stringify(complete, null, '\\t')}\\n`,\n\t\t\t{ flag: 'wx' }\n\t\t);\n\t\tawait rename(staging, releaseRoot);\n\n\t\treturn { artifactPath: destination, metadata: complete, releaseRoot };\n\t} finally {\n\t\tawait rm(staging, { force: true, recursive: true }).catch(\n\t\t\t() => undefined\n\t\t);\n\t}\n};\n\nexport const buildAbsoluteIosRelease = async (\n\toptions: BuildAbsoluteIosReleaseOptions\n) => {\n\tif (options.buildNumber !== undefined && options.prepareBuildNumber)\n\t\tthrow new TypeError(\n\t\t\t'iOS release buildNumber and prepareBuildNumber cannot be combined.'\n\t\t);\n\tif ((options.host ?? detectAbsoluteMobileHost()) !== 'macos')\n\t\tthrow new TypeError('iOS release builds require macOS and Xcode.');\n\tconst marketingVersion = options.config.iosVersion;\n\tif (!marketingVersion)\n\t\tthrow new TypeError(\n\t\t\t'iOS release builds require mobile.ios.version in absolutejs.config.ts.'\n\t\t);\n\tconst manifest = requireManifest(\n\t\tJSON.parse(\n\t\t\tawait readFile(\n\t\t\t\tjoin(\n\t\t\t\t\toptions.config.bundleDirectory,\n\t\t\t\t\t'absolute-mobile-manifest.json'\n\t\t\t\t),\n\t\t\t\t'utf8'\n\t\t\t)\n\t\t)\n\t);\n\tif (manifest.appId !== options.config.appId)\n\t\tthrow new TypeError(\n\t\t\t'Embedded mobile manifest appId does not match mobile.appId.'\n\t\t);\n\tconst nativeDirectory = join(options.config.nativeProjectDirectory, 'ios');\n\tlet buildNumber = requireBuildNumber(options.buildNumber);\n\tif (options.prepareBuildNumber) {\n\t\tconst nativeFingerprint =\n\t\t\tawait fingerprintAbsoluteIosNativeProject(nativeDirectory);\n\t\tconst buildIdentity = createHash('sha256')\n\t\t\t.update(\n\t\t\t\t`${manifest.appBuild}\\0${nativeFingerprint}\\0${marketingVersion}`\n\t\t\t)\n\t\t\t.digest('hex');\n\t\tbuildNumber = requireBuildNumber(\n\t\t\tawait options.prepareBuildNumber(buildIdentity)\n\t\t);\n\t}\n\tconst stagingParent = resolve(options.projectRoot, '.absolutejs/mobile');\n\tawait mkdir(stagingParent, { recursive: true });\n\tconst staging = await mkdtemp(join(stagingParent, '.ios-build-'));\n\tconst archivePath = join(staging, 'App.xcarchive');\n\tconst exportPath = join(staging, 'export');\n\tconst exportPlist = join(staging, 'ExportOptions.plist');\n\tawait mkdir(exportPath, { recursive: true });\n\tawait writeFile(exportPlist, exportOptions());\n\tconst run = options.run ?? defaultRun;\n\ttry {\n\t\tconst versionArguments = [\n\t\t\t`MARKETING_VERSION=${marketingVersion}`,\n\t\t\t...(buildNumber === undefined\n\t\t\t\t? []\n\t\t\t\t: [`CURRENT_PROJECT_VERSION=${buildNumber}`])\n\t\t];\n\t\tconst archiveExit = await run(\n\t\t\t[\n\t\t\t\t'xcodebuild',\n\t\t\t\t'-workspace',\n\t\t\t\tjoin(nativeDirectory, 'App', 'App.xcworkspace'),\n\t\t\t\t'-scheme',\n\t\t\t\t'App',\n\t\t\t\t'-configuration',\n\t\t\t\t'Release',\n\t\t\t\t'-destination',\n\t\t\t\t'generic/platform=iOS',\n\t\t\t\t'-archivePath',\n\t\t\t\tarchivePath,\n\t\t\t\t...versionArguments,\n\t\t\t\t'archive'\n\t\t\t],\n\t\t\t{ cwd: nativeDirectory }\n\t\t);\n\t\tif (archiveExit !== 0)\n\t\t\tthrow new TypeError('Xcode failed to archive the iOS app.');\n\t\tconst archivedApp = await findByExtension(\n\t\t\tjoin(archivePath, 'Products', 'Applications'),\n\t\t\t'.app'\n\t\t);\n\t\tconst capture = options.capture ?? defaultCapture;\n\t\tconst signed = archivedApp\n\t\t\t? capture([\n\t\t\t\t\t'codesign',\n\t\t\t\t\t'--verify',\n\t\t\t\t\t'--deep',\n\t\t\t\t\t'--strict',\n\t\t\t\t\tarchivedApp\n\t\t\t\t]).exitCode === 0\n\t\t\t: false;\n\t\tif (!signed && !options.allowUnsigned)\n\t\t\tthrow new TypeError(\n\t\t\t\t'Xcode produced an unsigned iOS archive. Configure signing in the source-owned Xcode project, or pass --unsigned only for a non-publishable build.'\n\t\t\t);\n\t\tconst exportExit = await run(\n\t\t\t[\n\t\t\t\t'xcodebuild',\n\t\t\t\t'-exportArchive',\n\t\t\t\t'-archivePath',\n\t\t\t\tarchivePath,\n\t\t\t\t'-exportPath',\n\t\t\t\texportPath,\n\t\t\t\t'-exportOptionsPlist',\n\t\t\t\texportPlist\n\t\t\t],\n\t\t\t{ cwd: nativeDirectory }\n\t\t);\n\t\tif (exportExit !== 0)\n\t\t\tthrow new TypeError('Xcode failed to export the App Store IPA.');\n\t\tconst artifactPath = await findByExtension(exportPath, '.ipa');\n\t\tif (!artifactPath)\n\t\t\tthrow new TypeError('Xcode did not produce an exported IPA.');\n\t\tconst [bytes, sha256] = await Promise.all([\n\t\t\tstat(artifactPath).then(({ size }) => size),\n\t\t\tsha256File(artifactPath)\n\t\t]);\n\t\tconst releaseId = `amobile_ios_${sha256}`;\n\n\t\treturn await installRelease(\n\t\t\tartifactPath,\n\t\t\t{\n\t\t\t\tappBuild: manifest.appBuild,\n\t\t\t\tappId: manifest.appId,\n\t\t\t\t...(buildNumber === undefined ? {} : { buildNumber }),\n\t\t\t\tbytes,\n\t\t\t\tengine: 'capacitor',\n\t\t\t\tformat: 1,\n\t\t\t\tmarketingVersion,\n\t\t\t\tplatform: 'ios',\n\t\t\t\treleaseId,\n\t\t\t\truntime: manifest.runtime,\n\t\t\t\tsha256,\n\t\t\t\tsigned,\n\t\t\t\ttype: 'ipa'\n\t\t\t},\n\t\t\tsafeOutputDirectory(options.projectRoot, options.outputDirectory)\n\t\t);\n\t} finally {\n\t\tawait rm(staging, { force: true, recursive: true }).catch(\n\t\t\t() => undefined\n\t\t);\n\t}\n};\n",
|
|
23
|
+
"import { performance } from 'node:perf_hooks';\n\nexport type AbsoluteAndroidInstalledApp = {\n\tappId: string;\n\tdataDirectory?: string;\n\tfirstInstallTime?: string;\n\tlastUpdateTime?: string;\n\tuid?: string;\n\tversionCode?: number;\n\tversionName?: string;\n};\n\nexport type AbsoluteAndroidUpgradeState = {\n\tauthCredential: boolean;\n\tpendingOperations: boolean;\n\tsyncDatabase: boolean;\n};\n\nexport type AbsoluteAndroidCompatibilityMatrix = {\n\tnPlusOne: 'compatible' | 'upgrade-required';\n\tnPlusTwo: 'compatible' | 'upgrade-required';\n\tnPlusThree: 'compatible' | 'upgrade-required';\n\trollback: 'compatible' | 'failed';\n};\n\nexport type AbsoluteAndroidUpgradeConformanceResult = {\n\tafter: AbsoluteAndroidInstalledApp;\n\tbefore: AbsoluteAndroidInstalledApp;\n\tcompatibility?: AbsoluteAndroidCompatibilityMatrix;\n\tdurationMs: number;\n\tinstallMs: number;\n\toutcome: 'fail' | 'pass';\n\tstate: AbsoluteAndroidUpgradeState;\n};\n\nexport type AbsoluteAndroidUpgradeCommandResult = {\n\texitCode: number;\n\tstderr: string;\n\tstdout: string;\n};\n\nexport type RunAbsoluteAndroidUpgradeConformanceOptions = {\n\tadb: string;\n\tafterInstall?: (installed: AbsoluteAndroidInstalledApp) => Promise<void>;\n\tapkPath: string;\n\tappId: string;\n\tcompatibility?: AbsoluteAndroidCompatibilityMatrix;\n\trun?: (command: string[]) => Promise<AbsoluteAndroidUpgradeCommandResult>;\n\tserial: string;\n\tverifyState: () => Promise<AbsoluteAndroidUpgradeState>;\n};\n\nconst captureCommand = async (command: string[]) => {\n\tconst process = Bun.spawn(command, { stderr: 'pipe', stdout: 'pipe' });\n\tconst [exitCode, stderr, stdout] = await Promise.all([\n\t\tprocess.exited,\n\t\tnew Response(process.stderr).text(),\n\t\tnew Response(process.stdout).text()\n\t]);\n\n\treturn { exitCode, stderr, stdout };\n};\n\nconst field = (output: string, name: string) =>\n\tnew RegExp(`^\\\\s*${name}=([^\\\\r\\\\n]+)$`, 'mu').exec(output)?.[1]?.trim();\n\nexport const inspectAbsoluteAndroidInstalledApp = async (\n\tadb: string,\n\tserial: string,\n\tappId: string,\n\trun: (\n\t\tcommand: string[]\n\t) => Promise<AbsoluteAndroidUpgradeCommandResult> = captureCommand\n) => {\n\tconst result = await run([\n\t\tadb,\n\t\t'-s',\n\t\tserial,\n\t\t'shell',\n\t\t'dumpsys',\n\t\t'package',\n\t\tappId\n\t]);\n\tif (result.exitCode !== 0)\n\t\tthrow new Error(\n\t\t\t`Could not inspect installed Android app ${appId}: ${result.stderr.trim() || result.stdout.trim()}`\n\t\t);\n\tconst installed = parseAbsoluteAndroidInstalledApp(appId, result.stdout);\n\tif (!installed)\n\t\tthrow new Error(`Android app ${appId} is not installed on ${serial}.`);\n\n\treturn installed;\n};\nexport const parseAbsoluteAndroidInstalledApp = (\n\tappId: string,\n\toutput: string\n): AbsoluteAndroidInstalledApp | null => {\n\tconst packageName = /^\\s*Package \\[([^\\]]+)\\]/mu.exec(output)?.[1];\n\tif (packageName !== appId && !output.includes(`package:${appId}`))\n\t\treturn null;\n\tconst versionCodeText = /^\\s*versionCode=(\\d+)/mu.exec(output)?.[1];\n\n\treturn {\n\t\tappId,\n\t\t...(field(output, 'dataDir')\n\t\t\t? { dataDirectory: field(output, 'dataDir') }\n\t\t\t: {}),\n\t\t...(field(output, 'firstInstallTime')\n\t\t\t? { firstInstallTime: field(output, 'firstInstallTime') }\n\t\t\t: {}),\n\t\t...(field(output, 'lastUpdateTime')\n\t\t\t? { lastUpdateTime: field(output, 'lastUpdateTime') }\n\t\t\t: {}),\n\t\t...(field(output, 'userId') || field(output, 'appId')\n\t\t\t? { uid: field(output, 'userId') ?? field(output, 'appId') }\n\t\t\t: {}),\n\t\t...(versionCodeText ? { versionCode: Number(versionCodeText) } : {}),\n\t\t...(field(output, 'versionName')\n\t\t\t? { versionName: field(output, 'versionName') }\n\t\t\t: {})\n\t};\n};\n\nconst unchanged = (\n\tname: string,\n\tbefore: string | undefined,\n\tafter: string | undefined\n) => {\n\tif (!before || !after)\n\t\tthrow new Error(\n\t\t\t`Android did not report ${name} for the upgrade proof.`\n\t\t);\n\tif (before !== after)\n\t\tthrow new Error(`Android ${name} changed during the in-place upgrade.`);\n};\n\nexport const runAbsoluteAndroidUpgradeConformance = async (\n\toptions: RunAbsoluteAndroidUpgradeConformanceOptions\n): Promise<AbsoluteAndroidUpgradeConformanceResult> => {\n\tconst run = options.run ?? captureCommand;\n\tconst startedAt = performance.now();\n\tconst before = await inspectAbsoluteAndroidInstalledApp(\n\t\toptions.adb,\n\t\toptions.serial,\n\t\toptions.appId,\n\t\trun\n\t);\n\tconst installStartedAt = performance.now();\n\tconst installed = await run([\n\t\toptions.adb,\n\t\t'-s',\n\t\toptions.serial,\n\t\t'install',\n\t\t'-r',\n\t\toptions.apkPath\n\t]);\n\tconst installMs = Math.round(performance.now() - installStartedAt);\n\tif (installed.exitCode !== 0 || !installed.stdout.includes('Success'))\n\t\tthrow new Error(\n\t\t\t`Android in-place upgrade failed: ${installed.stderr.trim() || installed.stdout.trim()}`\n\t\t);\n\tconst after = await inspectAbsoluteAndroidInstalledApp(\n\t\toptions.adb,\n\t\toptions.serial,\n\t\toptions.appId,\n\t\trun\n\t);\n\tunchanged('application UID', before.uid, after.uid);\n\tunchanged('data directory', before.dataDirectory, after.dataDirectory);\n\tunchanged(\n\t\t'first install timestamp',\n\t\tbefore.firstInstallTime,\n\t\tafter.firstInstallTime\n\t);\n\tif (\n\t\tbefore.versionCode !== undefined &&\n\t\tafter.versionCode !== undefined &&\n\t\tafter.versionCode <= before.versionCode\n\t)\n\t\tthrow new Error(\n\t\t\t`Android versionCode did not increase (${before.versionCode} -> ${after.versionCode}).`\n\t\t);\n\tawait options.afterInstall?.(after);\n\tconst state = await options.verifyState();\n\tconst compatibilityPass =\n\t\t!options.compatibility ||\n\t\t(options.compatibility.nPlusOne === 'compatible' &&\n\t\t\toptions.compatibility.nPlusTwo === 'compatible' &&\n\t\t\toptions.compatibility.nPlusThree === 'upgrade-required' &&\n\t\t\toptions.compatibility.rollback === 'compatible');\n\tconst outcome =\n\t\tObject.values(state).every(Boolean) && compatibilityPass\n\t\t\t? 'pass'\n\t\t\t: 'fail';\n\n\treturn {\n\t\tafter,\n\t\tbefore,\n\t\t...(options.compatibility\n\t\t\t? { compatibility: options.compatibility }\n\t\t\t: {}),\n\t\tdurationMs: Math.round(performance.now() - startedAt),\n\t\tinstallMs,\n\t\toutcome,\n\t\tstate\n\t};\n};\n",
|
|
24
|
+
"import { createHash } from 'node:crypto';\nimport {\n\taccess,\n\tcopyFile,\n\tmkdir,\n\tmkdtemp,\n\treaddir,\n\treadFile,\n\trename,\n\trm,\n\tstat,\n\twriteFile\n} from 'node:fs/promises';\nimport { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';\nimport type { NormalizedAbsoluteMobileConfig } from './config';\nimport {\n\tdetectAbsoluteMobileHost,\n\ttype AbsoluteMobileHost\n} from './emulatorDoctor';\n\nexport const ABSOLUTE_IOS_RELEASE_FORMAT = 1 as const;\n\nexport type AbsoluteIosReleaseMetadata = {\n\tappBuild: string;\n\tappId: string;\n\tartifact: 'App.ipa';\n\tbuildNumber?: number;\n\tbytes: number;\n\tengine: 'capacitor' | 'expo';\n\tformat: typeof ABSOLUTE_IOS_RELEASE_FORMAT;\n\tmarketingVersion: string;\n\tplatform: 'ios';\n\treleaseId: string;\n\truntime: string;\n\tsha256: string;\n\tsigned: boolean;\n\ttype: 'ipa';\n};\n\ntype MobileClientManifest = {\n\tappBuild: string;\n\tappId: string;\n\truntime: string;\n};\ntype CommandOptions = {\n\tcwd?: string;\n\tenv?: Record<string, string | undefined>;\n};\ntype CommandResult = { exitCode: number; stderr: string; stdout: string };\n\nexport type BuildAbsoluteIosReleaseOptions = {\n\tallowUnsigned?: boolean;\n\tcapture?: (command: string[], options?: CommandOptions) => CommandResult;\n\tconfig: NormalizedAbsoluteMobileConfig;\n\tdevelopmentTeam?: string;\n\tenv?: Record<string, string | undefined>;\n\thost?: AbsoluteMobileHost;\n\toutputDirectory?: string;\n\tprepareBuildNumber?: (buildIdentity: string) => Promise<number>;\n\tprojectRoot: string;\n\trun?: (command: string[], options?: CommandOptions) => Promise<number>;\n\tbuildNumber?: number;\n\tscheme?: string;\n\tworkspacePath?: string;\n};\n\nconst developmentTeamArgument = (value: string | undefined) => {\n\tif (value === undefined) return undefined;\n\tconst team = value.trim().toUpperCase();\n\tif (!/^[A-Z0-9]{10}$/u.test(team))\n\t\tthrow new TypeError(\n\t\t\t'iOS development team must contain ten letters or digits.'\n\t\t);\n\n\treturn `DEVELOPMENT_TEAM=${team}`;\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n\ttypeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst requireManifest = (value: unknown): MobileClientManifest => {\n\tif (\n\t\t!isRecord(value) ||\n\t\ttypeof value.appBuild !== 'string' ||\n\t\ttypeof value.appId !== 'string' ||\n\t\ttypeof value.runtime !== 'string'\n\t) {\n\t\tthrow new TypeError('Invalid embedded AbsoluteJS mobile manifest.');\n\t}\n\n\treturn {\n\t\tappBuild: value.appBuild,\n\t\tappId: value.appId,\n\t\truntime: value.runtime\n\t};\n};\n\nconst pathExists = async (path: string) => {\n\ttry {\n\t\tawait access(path);\n\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n};\n\nconst defaultRun = async (command: string[], options: CommandOptions = {}) => {\n\tconst process = Bun.spawn(command, {\n\t\tcwd: options.cwd,\n\t\tenv: options.env,\n\t\tstderr: 'inherit',\n\t\tstdin: 'inherit',\n\t\tstdout: 'inherit'\n\t});\n\n\treturn process.exited;\n};\n\nconst defaultCapture = (command: string[], options: CommandOptions = {}) => {\n\ttry {\n\t\tconst result = Bun.spawnSync(command, {\n\t\t\tcwd: options.cwd,\n\t\t\tenv: options.env,\n\t\t\tstderr: 'pipe',\n\t\t\tstdin: 'ignore',\n\t\t\tstdout: 'pipe'\n\t\t});\n\n\t\treturn {\n\t\t\texitCode: result.exitCode,\n\t\t\tstderr: result.stderr.toString(),\n\t\t\tstdout: result.stdout.toString()\n\t\t};\n\t} catch (error) {\n\t\treturn {\n\t\t\texitCode: 1,\n\t\t\tstderr: error instanceof Error ? error.message : String(error),\n\t\t\tstdout: ''\n\t\t};\n\t}\n};\n\nconst ignoredFingerprintDirectories = new Set([\n\t'Pods',\n\t'DerivedData',\n\t'build',\n\t'xcuserdata'\n]);\n\nconst fingerprintFiles = async (\n\troot: string,\n\tcurrent = root,\n\toptions: { includePublicBundle?: boolean } = {}\n): Promise<string[]> => {\n\tconst entries = await readdir(current, { withFileTypes: true });\n\tconst nested = await Promise.all(\n\t\tentries\n\t\t\t.sort((left, right) => left.name.localeCompare(right.name))\n\t\t\t.map(async (entry) => {\n\t\t\t\tconst path = join(current, entry.name);\n\t\t\t\tconst projectRelative = relative(root, path).replaceAll(\n\t\t\t\t\t'\\\\',\n\t\t\t\t\t'/'\n\t\t\t\t);\n\t\t\t\tconst ignored =\n\t\t\t\t\tentry.isDirectory() &&\n\t\t\t\t\t(ignoredFingerprintDirectories.has(entry.name) ||\n\t\t\t\t\t\t(projectRelative === 'App/App/public' &&\n\t\t\t\t\t\t\toptions.includePublicBundle !== true));\n\t\t\t\tif (ignored) return [];\n\t\t\t\tif (entry.isDirectory())\n\t\t\t\t\treturn fingerprintFiles(root, path, options);\n\n\t\t\t\treturn entry.isFile() ? [path] : [];\n\t\t\t})\n\t);\n\n\treturn nested.flat();\n};\n\nexport const fingerprintAbsoluteIosNativeProject = async (\n\tnativeDirectory: string,\n\toptions: { includePublicBundle?: boolean } = {}\n) => {\n\tconst hasher = createHash('sha256');\n\tconst files = await fingerprintFiles(\n\t\tnativeDirectory,\n\t\tnativeDirectory,\n\t\toptions\n\t);\n\tconst contents = await Promise.all(files.map((file) => readFile(file)));\n\tfiles.forEach((file, index) => {\n\t\thasher.update(relative(nativeDirectory, file).replaceAll('\\\\', '/'));\n\t\thasher.update('\\0');\n\t\thasher.update(contents[index] ?? new Uint8Array());\n\t\thasher.update('\\0');\n\t});\n\n\treturn hasher.digest('hex');\n};\n\nconst safeOutputDirectory = (projectRoot: string, requested?: string) => {\n\tconst root = resolve(projectRoot);\n\tconst output = resolve(\n\t\troot,\n\t\trequested ?? '.absolutejs/mobile/releases/ios'\n\t);\n\tconst projectRelative = relative(root, output);\n\tif (\n\t\tprojectRelative === '..' ||\n\t\tprojectRelative.startsWith(`..${sep}`) ||\n\t\tisAbsolute(projectRelative)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t'mobile build --outdir must remain inside the project.'\n\t\t);\n\t}\n\n\treturn output;\n};\n\nconst sha256File = async (path: string) =>\n\tcreateHash('sha256')\n\t\t.update(await readFile(path))\n\t\t.digest('hex');\n\nconst findByExtension = async (\n\troot: string,\n\textension: string\n): Promise<string | undefined> => {\n\tif (!(await pathExists(root))) return undefined;\n\tconst entries = await readdir(root, { withFileTypes: true });\n\tconst matches = await Promise.all(\n\t\tentries.map(async (entry) => {\n\t\t\tconst path = join(root, entry.name);\n\t\t\tif (entry.isDirectory() && entry.name.endsWith(extension))\n\t\t\t\treturn path;\n\t\t\tif (entry.isFile() && entry.name.endsWith(extension)) return path;\n\n\t\t\treturn entry.isDirectory()\n\t\t\t\t? findByExtension(path, extension)\n\t\t\t\t: undefined;\n\t\t})\n\t);\n\n\treturn matches.find((match) => match !== undefined);\n};\n\nconst findAllByExtension = async (\n\troot: string,\n\textension: string,\n\toptions: { excludedDirectories?: ReadonlySet<string> } = {}\n): Promise<string[]> => {\n\tif (!(await pathExists(root))) return [];\n\tconst entries = await readdir(root, { withFileTypes: true });\n\tconst matches = await Promise.all(\n\t\tentries.map(async (entry) => {\n\t\t\tconst path = join(root, entry.name);\n\t\t\tif (entry.name.endsWith(extension)) return [path];\n\t\t\tif (\n\t\t\t\t!entry.isDirectory() ||\n\t\t\t\toptions.excludedDirectories?.has(entry.name)\n\t\t\t)\n\t\t\t\treturn [];\n\n\t\t\treturn findAllByExtension(path, extension, options);\n\t\t})\n\t);\n\n\treturn matches.flat().sort();\n};\n\nexport const resolveAbsoluteIosXcodeProject = async (\n\tnativeDirectory: string,\n\toptions: { scheme?: string; workspacePath?: string } = {}\n) => {\n\tconst requestedWorkspace = options.workspacePath\n\t\t? resolve(nativeDirectory, options.workspacePath)\n\t\t: undefined;\n\tif (requestedWorkspace) {\n\t\tconst requestedRelative = relative(nativeDirectory, requestedWorkspace);\n\t\tif (\n\t\t\trequestedRelative === '..' ||\n\t\t\trequestedRelative.startsWith(`..${sep}`) ||\n\t\t\tisAbsolute(requestedRelative)\n\t\t)\n\t\t\tthrow new TypeError(\n\t\t\t\t'iOS release workspacePath must remain inside the native iOS project.'\n\t\t\t);\n\t}\n\tconst workspaces = requestedWorkspace\n\t\t? [requestedWorkspace]\n\t\t: await findAllByExtension(nativeDirectory, '.xcworkspace', {\n\t\t\t\texcludedDirectories: new Set(['Pods', 'DerivedData', 'build'])\n\t\t\t});\n\tif (workspaces.length !== 1)\n\t\tthrow new TypeError(\n\t\t\tworkspaces.length > 1\n\t\t\t\t? `iOS release found multiple Xcode workspaces: ${workspaces.map((path) => relative(nativeDirectory, path)).join(', ')}. Pass an explicit workspacePath.`\n\t\t\t\t: 'iOS release could not find an Xcode workspace.'\n\t\t);\n\tconst [workspacePath] = workspaces;\n\tif (!workspacePath || !(await pathExists(workspacePath)))\n\t\tthrow new TypeError('iOS release could not find an Xcode workspace.');\n\tif (options.scheme) return { scheme: options.scheme, workspacePath };\n\tconst schemeFiles = await findAllByExtension(nativeDirectory, '.xcscheme', {\n\t\texcludedDirectories: new Set(['Pods', 'DerivedData', 'build'])\n\t});\n\tconst schemes = [\n\t\t...new Set(\n\t\t\tschemeFiles.map((path) =>\n\t\t\t\tpath.slice(path.lastIndexOf(sep) + 1, -'.xcscheme'.length)\n\t\t\t)\n\t\t)\n\t];\n\tif (schemes.length !== 1 || !schemes[0])\n\t\tthrow new TypeError(\n\t\t\tschemes.length > 1\n\t\t\t\t? `iOS release found multiple shared Xcode schemes: ${schemes.join(', ')}. Pass an explicit scheme.`\n\t\t\t\t: 'iOS release could not find a shared Xcode scheme.'\n\t\t);\n\n\treturn { scheme: schemes[0], workspacePath };\n};\n\nconst exportOptions = () => `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\"><dict>\n\t<key>destination</key><string>export</string>\n\t<key>manageAppVersionAndBuildNumber</key><false/>\n\t<key>method</key><string>app-store-connect</string>\n\t<key>signingStyle</key><string>automatic</string>\n\t<key>stripSwiftSymbols</key><true/>\n\t<key>uploadSymbols</key><true/>\n</dict></plist>\n`;\n\nconst requireBuildNumber = (value: number | undefined) => {\n\tif (value !== undefined && (!Number.isSafeInteger(value) || value < 1))\n\t\tthrow new TypeError('iOS build number must be a positive integer.');\n\n\treturn value;\n};\n\nconst installRelease = async (\n\tartifactPath: string,\n\tmetadata: Omit<AbsoluteIosReleaseMetadata, 'artifact'>,\n\toutputRoot: string\n) => {\n\tconst releaseRoot = join(outputRoot, metadata.releaseId);\n\tconst destination = join(releaseRoot, 'App.ipa');\n\tif (await pathExists(releaseRoot)) {\n\t\tconst value: unknown = JSON.parse(\n\t\t\tawait readFile(join(releaseRoot, 'release.json'), 'utf8')\n\t\t);\n\t\tif (\n\t\t\t!isRecord(value) ||\n\t\t\tvalue.artifact !== 'App.ipa' ||\n\t\t\tObject.entries(metadata).some(\n\t\t\t\t([key, expected]) => Reflect.get(value, key) !== expected\n\t\t\t)\n\t\t) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`Immutable iOS release ${metadata.releaseId} does not match its content.`\n\t\t\t);\n\t\t}\n\t\tconst [bytes, sha256] = await Promise.all([\n\t\t\tstat(destination).then(({ size }) => size),\n\t\t\tsha256File(destination)\n\t\t]);\n\t\tif (bytes !== metadata.bytes || sha256 !== metadata.sha256)\n\t\t\tthrow new TypeError(\n\t\t\t\t`Immutable iOS release ${metadata.releaseId} artifact is missing or modified.`\n\t\t\t);\n\n\t\treturn {\n\t\t\tartifactPath: destination,\n\t\t\tmetadata: {\n\t\t\t\t...metadata,\n\t\t\t\tartifact: 'App.ipa'\n\t\t\t} satisfies AbsoluteIosReleaseMetadata,\n\t\t\treleaseRoot\n\t\t};\n\t}\n\tawait mkdir(dirname(releaseRoot), { recursive: true });\n\tconst staging = await mkdtemp(join(dirname(releaseRoot), '.ios-stage-'));\n\ttry {\n\t\tawait copyFile(artifactPath, join(staging, 'App.ipa'));\n\t\tconst complete = {\n\t\t\t...metadata,\n\t\t\tartifact: 'App.ipa'\n\t\t} satisfies AbsoluteIosReleaseMetadata;\n\t\tawait writeFile(\n\t\t\tjoin(staging, 'release.json'),\n\t\t\t`${JSON.stringify(complete, null, '\\t')}\\n`,\n\t\t\t{ flag: 'wx' }\n\t\t);\n\t\tawait rename(staging, releaseRoot);\n\n\t\treturn { artifactPath: destination, metadata: complete, releaseRoot };\n\t} finally {\n\t\tawait rm(staging, { force: true, recursive: true }).catch(\n\t\t\t() => undefined\n\t\t);\n\t}\n};\n\nexport const buildAbsoluteIosRelease = async (\n\toptions: BuildAbsoluteIosReleaseOptions\n) => {\n\tif (options.buildNumber !== undefined && options.prepareBuildNumber)\n\t\tthrow new TypeError(\n\t\t\t'iOS release buildNumber and prepareBuildNumber cannot be combined.'\n\t\t);\n\tif ((options.host ?? detectAbsoluteMobileHost()) !== 'macos')\n\t\tthrow new TypeError('iOS release builds require macOS and Xcode.');\n\tconst marketingVersion = options.config.iosVersion;\n\tif (!marketingVersion)\n\t\tthrow new TypeError(\n\t\t\t'iOS release builds require mobile.ios.version in absolutejs.config.ts.'\n\t\t);\n\tconst manifest = requireManifest(\n\t\tJSON.parse(\n\t\t\tawait readFile(\n\t\t\t\tjoin(\n\t\t\t\t\toptions.config.bundleDirectory,\n\t\t\t\t\t'absolute-mobile-manifest.json'\n\t\t\t\t),\n\t\t\t\t'utf8'\n\t\t\t)\n\t\t)\n\t);\n\tif (manifest.appId !== options.config.appId)\n\t\tthrow new TypeError(\n\t\t\t'Embedded mobile manifest appId does not match mobile.appId.'\n\t\t);\n\tconst nativeDirectory = join(options.config.nativeProjectDirectory, 'ios');\n\tconst xcode = await resolveAbsoluteIosXcodeProject(nativeDirectory, {\n\t\tscheme: options.scheme,\n\t\tworkspacePath: options.workspacePath\n\t});\n\tlet buildNumber = requireBuildNumber(options.buildNumber);\n\tif (options.prepareBuildNumber) {\n\t\tconst nativeFingerprint =\n\t\t\tawait fingerprintAbsoluteIosNativeProject(nativeDirectory);\n\t\tconst buildIdentity = createHash('sha256')\n\t\t\t.update(\n\t\t\t\t`${manifest.appBuild}\\0${nativeFingerprint}\\0${marketingVersion}`\n\t\t\t)\n\t\t\t.digest('hex');\n\t\tbuildNumber = requireBuildNumber(\n\t\t\tawait options.prepareBuildNumber(buildIdentity)\n\t\t);\n\t}\n\tconst stagingParent = resolve(options.projectRoot, '.absolutejs/mobile');\n\tawait mkdir(stagingParent, { recursive: true });\n\tconst staging = await mkdtemp(join(stagingParent, '.ios-build-'));\n\tconst archivePath = join(staging, 'App.xcarchive');\n\tconst exportPath = join(staging, 'export');\n\tconst exportPlist = join(staging, 'ExportOptions.plist');\n\tawait mkdir(exportPath, { recursive: true });\n\tawait writeFile(exportPlist, exportOptions());\n\tconst run = options.run ?? defaultRun;\n\ttry {\n\t\tconst developmentTeam = developmentTeamArgument(\n\t\t\toptions.developmentTeam\n\t\t);\n\t\tconst versionArguments = [\n\t\t\t`MARKETING_VERSION=${marketingVersion}`,\n\t\t\t...(developmentTeam ? [developmentTeam] : []),\n\t\t\t...(buildNumber === undefined\n\t\t\t\t? []\n\t\t\t\t: [`CURRENT_PROJECT_VERSION=${buildNumber}`])\n\t\t];\n\t\tconst archiveExit = await run(\n\t\t\t[\n\t\t\t\t'xcodebuild',\n\t\t\t\t'-workspace',\n\t\t\t\txcode.workspacePath,\n\t\t\t\t'-scheme',\n\t\t\t\txcode.scheme,\n\t\t\t\t'-configuration',\n\t\t\t\t'Release',\n\t\t\t\t'-destination',\n\t\t\t\t'generic/platform=iOS',\n\t\t\t\t'-archivePath',\n\t\t\t\tarchivePath,\n\t\t\t\t...versionArguments,\n\t\t\t\t'archive'\n\t\t\t],\n\t\t\t{ cwd: nativeDirectory, env: options.env }\n\t\t);\n\t\tif (archiveExit !== 0)\n\t\t\tthrow new TypeError('Xcode failed to archive the iOS app.');\n\t\tconst archivedApp = await findByExtension(\n\t\t\tjoin(archivePath, 'Products', 'Applications'),\n\t\t\t'.app'\n\t\t);\n\t\tconst capture = options.capture ?? defaultCapture;\n\t\tconst signed = archivedApp\n\t\t\t? capture([\n\t\t\t\t\t'codesign',\n\t\t\t\t\t'--verify',\n\t\t\t\t\t'--deep',\n\t\t\t\t\t'--strict',\n\t\t\t\t\tarchivedApp\n\t\t\t\t]).exitCode === 0\n\t\t\t: false;\n\t\tif (!signed && !options.allowUnsigned)\n\t\t\tthrow new TypeError(\n\t\t\t\t'Xcode produced an unsigned iOS archive. Configure signing in the source-owned Xcode project, or pass --unsigned only for a non-publishable build.'\n\t\t\t);\n\t\tconst exportExit = await run(\n\t\t\t[\n\t\t\t\t'xcodebuild',\n\t\t\t\t'-exportArchive',\n\t\t\t\t'-archivePath',\n\t\t\t\tarchivePath,\n\t\t\t\t'-exportPath',\n\t\t\t\texportPath,\n\t\t\t\t'-exportOptionsPlist',\n\t\t\t\texportPlist\n\t\t\t],\n\t\t\t{ cwd: nativeDirectory, env: options.env }\n\t\t);\n\t\tif (exportExit !== 0)\n\t\t\tthrow new TypeError('Xcode failed to export the App Store IPA.');\n\t\tconst artifactPath = await findByExtension(exportPath, '.ipa');\n\t\tif (!artifactPath)\n\t\t\tthrow new TypeError('Xcode did not produce an exported IPA.');\n\t\tconst [bytes, sha256] = await Promise.all([\n\t\t\tstat(artifactPath).then(({ size }) => size),\n\t\t\tsha256File(artifactPath)\n\t\t]);\n\t\tconst releaseId = `amobile_ios_${sha256}`;\n\n\t\treturn await installRelease(\n\t\t\tartifactPath,\n\t\t\t{\n\t\t\t\tappBuild: manifest.appBuild,\n\t\t\t\tappId: manifest.appId,\n\t\t\t\t...(buildNumber === undefined ? {} : { buildNumber }),\n\t\t\t\tbytes,\n\t\t\t\tengine: options.config.engine,\n\t\t\t\tformat: 1,\n\t\t\t\tmarketingVersion,\n\t\t\t\tplatform: 'ios',\n\t\t\t\treleaseId,\n\t\t\t\truntime: manifest.runtime,\n\t\t\t\tsha256,\n\t\t\t\tsigned,\n\t\t\t\ttype: 'ipa'\n\t\t\t},\n\t\t\tsafeOutputDirectory(options.projectRoot, options.outputDirectory)\n\t\t);\n\t} finally {\n\t\tawait rm(staging, { force: true, recursive: true }).catch(\n\t\t\t() => undefined\n\t\t);\n\t}\n};\n",
|
|
17
25
|
"import { readFile, stat } from 'node:fs/promises';\n\nconst HMR_LINE = new RegExp(\n\tString.raw`\\[hmr:ios\\]\\s+([^\\n]*?)\\s+(applied in|falling back to reload after|failed after)\\s+(\\d+)ms(?:; server\\s+(\\d+)ms, client\\s+(\\d+)ms)?`,\n\t'u'\n);\n\nexport type AbsoluteIosHmrApply = {\n\tclientMs?: number;\n\tduration: number;\n\tline: string;\n\toutcome: 'applied' | 'failed' | 'reloaded';\n\tserverMs?: number;\n};\n\nexport const parseAbsoluteIosHmrLog = (\n\tline: string\n): AbsoluteIosHmrApply | null => {\n\tconst match = HMR_LINE.exec(line);\n\tif (!match) return null;\n\tconst [, , action, durationValue, serverValue, clientValue] = match;\n\tlet outcome: AbsoluteIosHmrApply['outcome'] = 'reloaded';\n\tif (action === 'applied in') outcome = 'applied';\n\tif (action === 'failed after') outcome = 'failed';\n\tconst serverMs =\n\t\tserverValue === undefined ? undefined : Number(serverValue);\n\tconst clientMs =\n\t\tclientValue === undefined ? undefined : Number(clientValue);\n\n\treturn {\n\t\t...(clientMs === undefined ? {} : { clientMs }),\n\t\tduration: Number(durationValue),\n\t\tline: match[0],\n\t\toutcome,\n\t\t...(serverMs === undefined ? {} : { serverMs })\n\t};\n};\n\nconst findHmrApply = (lines: string[]) => {\n\tconst apply = lines\n\t\t.map((line) => parseAbsoluteIosHmrLog(line))\n\t\t.find((candidate) => candidate !== null);\n\tif (apply?.outcome === 'failed')\n\t\tthrow new Error(\n\t\t\t`iOS HMR client reported a failed apply: ${apply.line}`\n\t\t);\n\n\treturn apply;\n};\n\nexport const waitForAbsoluteIosHmrLog = async (options: {\n\tlogPath: string;\n\tsignal?: AbortSignal;\n\tsleep?: (milliseconds: number) => Promise<void>;\n\tstartOffset?: number;\n\ttimeoutMs?: number;\n}) => {\n\tconst sleep = options.sleep ?? Bun.sleep;\n\tconst timeoutMs = options.timeoutMs ?? 30_000;\n\tconst deadline = Date.now() + timeoutMs;\n\tlet offset =\n\t\toptions.startOffset ??\n\t\t(await stat(options.logPath)\n\t\t\t.then(({ size }) => size)\n\t\t\t.catch(() => 0));\n\tlet buffered = '';\n\tconst poll = async (): Promise<AbsoluteIosHmrApply> => {\n\t\tif (Date.now() > deadline)\n\t\t\tthrow new Error(\n\t\t\t\t`No iOS native HMR acknowledgement was observed within ${timeoutMs}ms.`\n\t\t\t);\n\t\toptions.signal?.throwIfAborted();\n\t\tconst contents = await readFile(options.logPath).catch(() =>\n\t\t\tBuffer.alloc(0)\n\t\t);\n\t\tif (contents.byteLength < offset) {\n\t\t\toffset = 0;\n\t\t\tbuffered = '';\n\t\t}\n\t\tif (contents.byteLength > offset) {\n\t\t\tbuffered += contents.subarray(offset).toString('utf8');\n\t\t\toffset = contents.byteLength;\n\t\t\tconst lines = buffered.split(/\\r?\\n/u);\n\t\t\tbuffered = lines.pop() ?? '';\n\t\t\tconst apply = findHmrApply(lines);\n\t\t\tif (apply) return apply;\n\t\t}\n\t\tawait sleep(100);\n\n\t\treturn poll();\n\t};\n\n\treturn poll();\n};\n",
|
|
18
|
-
"import { createHash, randomUUID } from 'node:crypto';\nimport {\n\taccess,\n\tcopyFile,\n\tmkdir,\n\treadFile,\n\trename,\n\trm,\n\twriteFile\n} from 'node:fs/promises';\nimport { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';\nimport type { NormalizedAbsoluteMobileConfig } from './config';\nimport {\n\tdetectAbsoluteMobileHost,\n\tinspectAbsoluteMobileToolchain\n} from './emulatorDoctor';\nimport { writeAbsoluteCapacitorConfig } from './capacitorProject';\nimport { fingerprintAbsoluteIosNativeProject } from './iosRelease';\nimport { getDurationString } from '../utils/getDurationString';\n\nexport const ABSOLUTE_IOS_SIMULATOR_NAME = 'AbsoluteJS iPhone';\n\nconst BOOT_TIMEOUT_MS = 180_000;\nconst BOOT_POLL_MS = 1_000;\nconst DEV_JOURNAL_FORMAT = 1;\nconst NATIVE_CACHE_FORMAT = 1;\n\nexport type AbsoluteIosCommandOptions = {\n\tcwd?: string;\n\tenv?: Record<string, string | undefined>;\n\tsignal?: AbortSignal;\n};\n\nexport type AbsoluteIosCommandResult = {\n\texitCode: number;\n\tstderr: string;\n\tstdout: string;\n};\n\nexport type AbsoluteIosDevState =\n\t| 'booting'\n\t| 'building'\n\t| 'checking-native'\n\t| 'closed'\n\t| 'closing'\n\t| 'configuring'\n\t| 'connecting'\n\t| 'failed'\n\t| 'installing'\n\t| 'launching'\n\t| 'ready'\n\t| 'streaming-logs'\n\t| 'syncing';\n\nexport type AbsoluteIosNativeLogEntry = {\n\tlevel: 'debug' | 'error' | 'fault' | 'info' | 'notice';\n\tmessage: string;\n\ttag: string;\n};\n\ntype AbsoluteIosLogStream = { close: () => Promise<void> };\n\nexport type AbsoluteIosDevProject = {\n\tcap: string;\n\tconfig: NormalizedAbsoluteMobileConfig;\n\tnativeDirectory: string;\n\tprojectRoot: string;\n\txcodebuild: string;\n\txcrun: string;\n};\n\nexport type AbsoluteIosDevSession = {\n\tclose: () => Promise<void>;\n\tnativeCacheHit: boolean;\n\trebuild: () => Promise<AbsoluteIosDevSession>;\n\trelaunch: () => Promise<void>;\n\tscreenshot: (destination: string) => Promise<string>;\n\tstartedSimulator: boolean;\n\tstate: AbsoluteIosDevState;\n\ttimings: Record<string, number>;\n\tudid: string;\n};\n\nexport type AbsoluteIosDevPhaseTiming = {\n\tdurationMs: number;\n\tphase: AbsoluteIosDevState;\n\ttotalMs: number;\n};\n\nexport type PrepareAbsoluteIosDevOptions = {\n\tcreateNativeProject: boolean;\n\tprojectRoot: string;\n\trun?: (\n\t\tcommand: string[],\n\t\toptions?: AbsoluteIosCommandOptions\n\t) => Promise<number>;\n};\n\nexport type StartAbsoluteIosDevOptions = {\n\tcapture?: (\n\t\tcommand: string[],\n\t\toptions?: AbsoluteIosCommandOptions\n\t) => AbsoluteIosCommandResult;\n\thttps?: boolean;\n\tlog?: (message: string) => void;\n\tnativeLog?: (entry: AbsoluteIosNativeLogEntry) => void;\n\tonPhaseTiming?: (timing: AbsoluteIosDevPhaseTiming) => void;\n\tonStateChange?: (state: AbsoluteIosDevState) => void;\n\tport: number;\n\tproject: AbsoluteIosDevProject;\n\trun?: (\n\t\tcommand: string[],\n\t\toptions?: AbsoluteIosCommandOptions\n\t) => Promise<number>;\n\tsignal?: AbortSignal;\n\tsleep?: (milliseconds: number) => Promise<void>;\n\tspawn?: (command: string[], options?: AbsoluteIosCommandOptions) => void;\n\tstartNativeLogs?: (\n\t\tcommand: string[],\n\t\toptions: AbsoluteIosCommandOptions,\n\t\tonLine: (line: string) => void\n\t) => AbsoluteIosLogStream;\n};\n\ntype IosRuntime = {\n\tidentifier: string;\n\tisAvailable: boolean;\n\tname: string;\n\tversion: string;\n};\n\ntype IosDeviceType = { identifier: string; name: string };\n\ntype IosDevJournal = {\n\tconfigBackupPath: string;\n\tformat: number;\n\tinfoBackupPath: string;\n\tinfoPath: string;\n\tnativeConfigPath: string;\n};\n\ntype IosNativeCache = {\n\tappId: string;\n\tfingerprint: string;\n\tformat: number;\n\tinstallations: Record<string, string>;\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n\ttypeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst pathExists = async (path: string) => {\n\ttry {\n\t\tawait access(path);\n\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n};\n\nconst throwIfAborted = (signal?: AbortSignal) => signal?.throwIfAborted();\n\nconst defaultCapture = (\n\tcommand: string[],\n\toptions: AbsoluteIosCommandOptions = {}\n) => {\n\ttry {\n\t\tconst result = Bun.spawnSync(command, {\n\t\t\tcwd: options.cwd,\n\t\t\tenv: options.env,\n\t\t\tstderr: 'pipe',\n\t\t\tstdin: 'ignore',\n\t\t\tstdout: 'pipe'\n\t\t});\n\n\t\treturn {\n\t\t\texitCode: result.exitCode,\n\t\t\tstderr: result.stderr.toString(),\n\t\t\tstdout: result.stdout.toString()\n\t\t};\n\t} catch (error) {\n\t\treturn {\n\t\t\texitCode: 1,\n\t\t\tstderr: error instanceof Error ? error.message : String(error),\n\t\t\tstdout: ''\n\t\t};\n\t}\n};\n\nconst defaultRun = async (\n\tcommand: string[],\n\toptions: AbsoluteIosCommandOptions = {}\n) => {\n\tconst process = Bun.spawn(command, {\n\t\tcwd: options.cwd,\n\t\tenv: options.env,\n\t\tsignal: options.signal,\n\t\tstderr: 'inherit',\n\t\tstdin: 'inherit',\n\t\tstdout: 'inherit'\n\t});\n\n\treturn process.exited;\n};\n\nconst defaultSpawn = (\n\tcommand: string[],\n\toptions: AbsoluteIosCommandOptions = {}\n) => {\n\tBun.spawn(command, {\n\t\tcwd: options.cwd,\n\t\tenv: options.env,\n\t\tsignal: options.signal,\n\t\tstderr: 'ignore',\n\t\tstdin: 'ignore',\n\t\tstdout: 'ignore'\n\t});\n};\n\nconst consumeLines = async (\n\tstream: ReadableStream<Uint8Array>,\n\tonLine: (line: string) => void\n) => {\n\tconst reader = stream.getReader();\n\tconst decoder = new TextDecoder();\n\tlet buffered = '';\n\tconst pump = async (): Promise<void> => {\n\t\tconst { done, value } = await reader.read();\n\t\tif (done) return;\n\t\tbuffered += decoder.decode(value, { stream: true });\n\t\tconst lines = buffered.split(/\\r?\\n/u);\n\t\tbuffered = lines.pop() ?? '';\n\t\tlines.forEach(onLine);\n\n\t\tawait pump();\n\t};\n\ttry {\n\t\tawait pump();\n\t\tbuffered += decoder.decode();\n\t\tif (buffered) onLine(buffered);\n\t} finally {\n\t\treader.releaseLock();\n\t}\n};\n\nconst defaultStartNativeLogs = (\n\tcommand: string[],\n\toptions: AbsoluteIosCommandOptions,\n\tonLine: (line: string) => void\n): AbsoluteIosLogStream => {\n\tconst process = Bun.spawn(command, {\n\t\tcwd: options.cwd,\n\t\tenv: options.env,\n\t\tsignal: options.signal,\n\t\tstderr: 'pipe',\n\t\tstdin: 'ignore',\n\t\tstdout: 'pipe'\n\t});\n\tvoid consumeLines(process.stdout, onLine);\n\tvoid consumeLines(process.stderr, onLine);\n\n\treturn {\n\t\tclose: async () => {\n\t\t\ttry {\n\t\t\t\tprocess.kill();\n\t\t\t} catch {\n\t\t\t\t/* already closed */\n\t\t\t}\n\t\t\tawait process.exited.catch(() => undefined);\n\t\t}\n\t};\n};\n\nconst requireSuccess = async (\n\tcommand: string[],\n\tlabel: string,\n\trun: NonNullable<StartAbsoluteIosDevOptions['run']>,\n\toptions?: AbsoluteIosCommandOptions\n) => {\n\tconst exitCode = await run(command, options);\n\tif (exitCode !== 0)\n\t\tthrow new Error(`${label} failed with status ${exitCode}.`);\n};\n\nconst requireCapturedSuccess = (\n\tresult: AbsoluteIosCommandResult,\n\tlabel: string\n) => {\n\tif (result.exitCode !== 0) {\n\t\tthrow new Error(\n\t\t\t`${label} failed: ${result.stderr.trim() || result.stdout.trim() || `status ${result.exitCode}`}`\n\t\t);\n\t}\n\n\treturn result.stdout.trim();\n};\n\nconst parseJson = (source: string, label: string) => {\n\ttry {\n\t\tconst parsed: unknown = JSON.parse(source);\n\t\tif (isRecord(parsed)) return parsed;\n\t} catch {\n\t\t/* normalized below */\n\t}\n\tthrow new Error(`Invalid ${label} JSON from simctl.`);\n};\n\nexport const parseIosDeviceTypes = (source: string) => {\n\tconst parsed = parseJson(source, 'device type');\n\tconst types = parsed.devicetypes;\n\tif (!Array.isArray(types)) return [];\n\n\treturn types.flatMap((type) => {\n\t\tif (!isRecord(type)) return [];\n\t\tconst { identifier } = type;\n\t\tconst { name } = type;\n\n\t\treturn typeof identifier === 'string' && typeof name === 'string'\n\t\t\t? [{ identifier, name }]\n\t\t\t: [];\n\t});\n};\nexport const parseIosRuntimes = (source: string) => {\n\tconst parsed = parseJson(source, 'runtime');\n\tconst { runtimes } = parsed;\n\tif (!Array.isArray(runtimes)) return [];\n\n\treturn runtimes.flatMap((runtime) => {\n\t\tif (!isRecord(runtime)) return [];\n\t\tconst { identifier } = runtime;\n\t\tconst { name } = runtime;\n\t\tconst { version } = runtime;\n\t\tif (\n\t\t\ttypeof identifier !== 'string' ||\n\t\t\ttypeof name !== 'string' ||\n\t\t\ttypeof version !== 'string'\n\t\t)\n\t\t\treturn [];\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tidentifier,\n\t\t\t\tisAvailable: runtime.isAvailable !== false,\n\t\t\t\tname,\n\t\t\t\tversion\n\t\t\t}\n\t\t];\n\t});\n};\nexport const parseIosSimulators = (source: string) => {\n\tconst parsed = parseJson(source, 'device');\n\tconst { devices } = parsed;\n\tif (!isRecord(devices)) return [];\n\n\treturn Object.entries(devices).flatMap(([runtime, values]) => {\n\t\tif (!Array.isArray(values)) return [];\n\n\t\treturn values.flatMap((device) => {\n\t\t\tif (!isRecord(device)) return [];\n\t\t\tconst { name } = device;\n\t\t\tconst { state } = device;\n\t\t\tconst { udid } = device;\n\t\t\tif (\n\t\t\t\ttypeof name !== 'string' ||\n\t\t\t\ttypeof state !== 'string' ||\n\t\t\t\ttypeof udid !== 'string'\n\t\t\t)\n\t\t\t\treturn [];\n\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tisAvailable: device.isAvailable !== false,\n\t\t\t\t\tname,\n\t\t\t\t\truntime,\n\t\t\t\t\tstate,\n\t\t\t\t\tudid\n\t\t\t\t}\n\t\t\t];\n\t\t});\n\t});\n};\n\nconst versionParts = (version: string) =>\n\tversion.split('.').map((part) => Number(part));\n\nconst compareVersions = (left: string, right: string) => {\n\tconst leftParts = versionParts(left);\n\tconst rightParts = versionParts(right);\n\tconst length = Math.max(leftParts.length, rightParts.length);\n\tfor (let index = 0; index < length; index++) {\n\t\tconst difference = (leftParts[index] ?? 0) - (rightParts[index] ?? 0);\n\t\tif (difference !== 0) return difference;\n\t}\n\n\treturn 0;\n};\n\nconst latestIosRuntime = (runtimes: IosRuntime[]) =>\n\truntimes\n\t\t.filter(\n\t\t\t(runtime) =>\n\t\t\t\truntime.isAvailable &&\n\t\t\t\truntime.identifier.includes('SimRuntime.iOS-')\n\t\t)\n\t\t.sort((left, right) => compareVersions(right.version, left.version))[0];\n\nconst iphoneGeneration = (name: string) =>\n\tNumber(/iPhone\\s+(\\d+)/u.exec(name)?.[1] ?? 0);\n\nconst preferredIphoneType = (types: IosDeviceType[]) =>\n\ttypes\n\t\t.filter((type) => type.name.startsWith('iPhone'))\n\t\t.sort((left, right) => {\n\t\t\tconst generation =\n\t\t\t\tiphoneGeneration(right.name) - iphoneGeneration(left.name);\n\t\t\tif (generation !== 0) return generation;\n\t\t\tconst rightPro = right.name.includes('Pro') ? 1 : 0;\n\t\t\tconst leftPro = left.name.includes('Pro') ? 1 : 0;\n\n\t\t\treturn rightPro - leftPro;\n\t\t})[0];\n\nconst journalPaths = (projectRoot: string) => {\n\tconst root = join(projectRoot, '.absolutejs', 'mobile', 'ios-dev-session');\n\n\treturn {\n\t\tconfigBackup: join(root, 'capacitor-config.backup'),\n\t\tinfoBackup: join(root, 'Info.plist.backup'),\n\t\tjournal: join(root, 'journal.json'),\n\t\troot\n\t};\n};\n\nconst nativeCachePath = (projectRoot: string) =>\n\tjoin(projectRoot, '.absolutejs', 'mobile', 'ios-native-cache.json');\n\nconst isInside = (root: string, path: string) => {\n\tconst value = relative(resolve(root), resolve(path));\n\n\treturn (\n\t\tvalue === '' ||\n\t\t(!value.startsWith(`..${sep}`) && value !== '..' && !isAbsolute(value))\n\t);\n};\n\nconst parseJournal = (value: unknown): IosDevJournal | null => {\n\tif (!isRecord(value) || value.format !== DEV_JOURNAL_FORMAT) return null;\n\tconst { configBackupPath } = value;\n\tconst { infoBackupPath } = value;\n\tconst { infoPath } = value;\n\tconst { nativeConfigPath } = value;\n\tif (\n\t\ttypeof configBackupPath !== 'string' ||\n\t\ttypeof infoBackupPath !== 'string' ||\n\t\ttypeof infoPath !== 'string' ||\n\t\ttypeof nativeConfigPath !== 'string'\n\t)\n\t\treturn null;\n\n\treturn {\n\t\tconfigBackupPath,\n\t\tformat: DEV_JOURNAL_FORMAT,\n\t\tinfoBackupPath,\n\t\tinfoPath,\n\t\tnativeConfigPath\n\t};\n};\n\nexport const repairAbsoluteIosDevSession = async (projectRoot: string) => {\n\tconst paths = journalPaths(projectRoot);\n\tif (!(await pathExists(paths.journal))) {\n\t\tawait rm(paths.root, { force: true, recursive: true });\n\n\t\treturn false;\n\t}\n\tconst journal = await readFile(paths.journal, 'utf8')\n\t\t.then((source) => parseJournal(JSON.parse(source)))\n\t\t.catch(() => null);\n\tif (\n\t\t!journal ||\n\t\t!isInside(projectRoot, journal.nativeConfigPath) ||\n\t\t!isInside(projectRoot, journal.infoPath) ||\n\t\t!isInside(paths.root, journal.configBackupPath) ||\n\t\t!isInside(paths.root, journal.infoBackupPath)\n\t) {\n\t\tthrow new Error(\n\t\t\t`Refusing unsafe or invalid iOS dev journal at ${paths.journal}.`\n\t\t);\n\t}\n\tif (await pathExists(journal.configBackupPath))\n\t\tawait copyFile(journal.configBackupPath, journal.nativeConfigPath);\n\tif (await pathExists(journal.infoBackupPath))\n\t\tawait copyFile(journal.infoBackupPath, journal.infoPath);\n\tawait rm(paths.root, { force: true, recursive: true });\n\n\treturn true;\n};\n\nconst iosDevelopmentInfoPlist = (source: string, cleartext: boolean) => {\n\tif (!cleartext) return source;\n\tconst arbitraryLoads =\n\t\t/(<key>NSAllowsArbitraryLoads<\\/key>\\s*)<false\\s*\\/>/u;\n\tif (arbitraryLoads.test(source))\n\t\treturn source.replace(arbitraryLoads, '$1<true/>');\n\tif (/<key>NSAllowsArbitraryLoads<\\/key>\\s*<true\\s*\\/>/u.test(source))\n\t\treturn source;\n\tconst transport = /(<key>NSAppTransportSecurity<\\/key>\\s*<dict>)/u;\n\tif (transport.test(source))\n\t\treturn source.replace(\n\t\t\ttransport,\n\t\t\t'$1\\n\\t\\t<key>NSAllowsArbitraryLoads</key>\\n\\t\\t<true/>'\n\t\t);\n\n\treturn source.replace(\n\t\t/<dict>/u,\n\t\t'<dict>\\n\\t<key>NSAppTransportSecurity</key>\\n\\t<dict>\\n\\t\\t<key>NSAllowsArbitraryLoads</key>\\n\\t\\t<true/>\\n\\t</dict>'\n\t);\n};\n\nconst writeDevProjection = async (\n\tproject: AbsoluteIosDevProject,\n\tport: number,\n\thttps: boolean\n) => {\n\tconst paths = journalPaths(project.projectRoot);\n\tawait repairAbsoluteIosDevSession(project.projectRoot);\n\tconst nativeConfigPath = join(\n\t\tproject.nativeDirectory,\n\t\t'App',\n\t\t'App',\n\t\t'capacitor.config.json'\n\t);\n\tconst infoPath = join(project.nativeDirectory, 'App', 'App', 'Info.plist');\n\tconst [configSource, infoSource] = await Promise.all([\n\t\treadFile(nativeConfigPath, 'utf8'),\n\t\treadFile(infoPath, 'utf8')\n\t]);\n\tconst parsed: unknown = JSON.parse(configSource);\n\tif (!isRecord(parsed))\n\t\tthrow new Error(\n\t\t\t`Invalid Capacitor native config at ${nativeConfigPath}.`\n\t\t);\n\tawait mkdir(paths.root, { recursive: true });\n\tawait Promise.all([\n\t\twriteFile(paths.configBackup, configSource, { flag: 'wx' }),\n\t\twriteFile(paths.infoBackup, infoSource, { flag: 'wx' })\n\t]);\n\tconst journal: IosDevJournal = {\n\t\tconfigBackupPath: paths.configBackup,\n\t\tformat: DEV_JOURNAL_FORMAT,\n\t\tinfoBackupPath: paths.infoBackup,\n\t\tinfoPath,\n\t\tnativeConfigPath\n\t};\n\tawait writeFile(paths.journal, `${JSON.stringify(journal, null, '\\t')}\\n`, {\n\t\tflag: 'wx'\n\t});\n\tconst developmentUrl = new URL(\n\t\t`${https ? 'https' : 'http'}://localhost:${port}${project.config.entry}`\n\t);\n\tdevelopmentUrl.searchParams.set('__absolute_target', 'capacitor-ios');\n\tconst existingServer = parsed.server;\n\tparsed.server = {\n\t\t...(isRecord(existingServer) ? existingServer : {}),\n\t\tcleartext: !https,\n\t\turl: developmentUrl.href\n\t};\n\tawait Promise.all([\n\t\twriteFile(nativeConfigPath, `${JSON.stringify(parsed, null, '\\t')}\\n`),\n\t\twriteFile(infoPath, iosDevelopmentInfoPlist(infoSource, !https))\n\t]);\n};\n\nconst parseNativeCache = (value: unknown): IosNativeCache | null => {\n\tif (!isRecord(value)) return null;\n\tconst { appId, fingerprint, format, installations } = value;\n\tif (\n\t\tformat !== NATIVE_CACHE_FORMAT ||\n\t\ttypeof appId !== 'string' ||\n\t\ttypeof fingerprint !== 'string' ||\n\t\t!isRecord(installations) ||\n\t\t!Object.values(installations).every(\n\t\t\t(identity) => typeof identity === 'string'\n\t\t)\n\t)\n\t\treturn null;\n\n\treturn {\n\t\tappId,\n\t\tfingerprint,\n\t\tformat,\n\t\tinstallations: Object.fromEntries(\n\t\t\tObject.entries(installations).map(([udid, identity]) => [\n\t\t\t\tudid,\n\t\t\t\tString(identity)\n\t\t\t])\n\t\t)\n\t};\n};\n\nconst readNativeCache = (projectRoot: string) =>\n\treadFile(nativeCachePath(projectRoot), 'utf8')\n\t\t.then((source) => parseNativeCache(JSON.parse(source)))\n\t\t.catch(() => null);\n\nconst writeNativeCache = async (projectRoot: string, cache: IosNativeCache) => {\n\tconst destination = nativeCachePath(projectRoot);\n\tconst temporary = `${destination}.${process.pid}.${randomUUID()}.tmp`;\n\tawait mkdir(dirname(destination), { recursive: true });\n\ttry {\n\t\tawait writeFile(temporary, `${JSON.stringify(cache, null, '\\t')}\\n`, {\n\t\t\tflag: 'wx'\n\t\t});\n\t\tawait rename(temporary, destination);\n\t} finally {\n\t\tawait rm(temporary, { force: true }).catch(() => undefined);\n\t}\n};\n\nexport const fingerprintAbsoluteIosDevProject = async (\n\tproject: Pick<AbsoluteIosDevProject, 'nativeDirectory'>\n) => fingerprintAbsoluteIosNativeProject(project.nativeDirectory);\n\nconst simulatorInventory = (\n\txcrun: string,\n\tcapture: NonNullable<StartAbsoluteIosDevOptions['capture']>\n) => {\n\tconst result = capture([\n\t\txcrun,\n\t\t'simctl',\n\t\t'list',\n\t\t'devices',\n\t\t'available',\n\t\t'-j'\n\t]);\n\n\treturn parseIosSimulators(\n\t\trequireCapturedSuccess(result, 'iOS simulator discovery')\n\t);\n};\n\nconst ensureManagedSimulator = async (\n\tproject: AbsoluteIosDevProject,\n\tcapture: NonNullable<StartAbsoluteIosDevOptions['capture']>\n) => {\n\tconst runtimes = parseIosRuntimes(\n\t\trequireCapturedSuccess(\n\t\t\tcapture([project.xcrun, 'simctl', 'list', 'runtimes', '-j']),\n\t\t\t'iOS runtime discovery'\n\t\t)\n\t);\n\tconst runtime = latestIosRuntime(runtimes);\n\tif (!runtime)\n\t\tthrow new Error(\n\t\t\t'No available iOS Simulator runtime. Run absolute mobile doctor ios --fix.'\n\t\t);\n\tconst [existing] = simulatorInventory(project.xcrun, capture)\n\t\t.filter(\n\t\t\t(device) =>\n\t\t\t\tdevice.isAvailable &&\n\t\t\t\tdevice.name === ABSOLUTE_IOS_SIMULATOR_NAME &&\n\t\t\t\tdevice.runtime === runtime.identifier\n\t\t)\n\t\t.sort(\n\t\t\t(left, right) =>\n\t\t\t\tNumber(right.state === 'Booted') -\n\t\t\t\tNumber(left.state === 'Booted')\n\t\t);\n\tif (existing) return { created: false, device: existing };\n\tconst types = parseIosDeviceTypes(\n\t\trequireCapturedSuccess(\n\t\t\tcapture([project.xcrun, 'simctl', 'list', 'devicetypes', '-j']),\n\t\t\t'iOS device-type discovery'\n\t\t)\n\t);\n\tconst type = preferredIphoneType(types);\n\tif (!type)\n\t\tthrow new Error('Xcode did not report an iPhone simulator type.');\n\tconst [udid] = requireCapturedSuccess(\n\t\tcapture([\n\t\t\tproject.xcrun,\n\t\t\t'simctl',\n\t\t\t'create',\n\t\t\tABSOLUTE_IOS_SIMULATOR_NAME,\n\t\t\ttype.identifier,\n\t\t\truntime.identifier\n\t\t]),\n\t\t'iOS simulator creation'\n\t).split(/\\s/u);\n\tif (!udid)\n\t\tthrow new Error('simctl did not return the created simulator UDID.');\n\n\treturn {\n\t\tcreated: true,\n\t\tdevice: {\n\t\t\tisAvailable: true,\n\t\t\tname: ABSOLUTE_IOS_SIMULATOR_NAME,\n\t\t\truntime: runtime.identifier,\n\t\t\tstate: 'Shutdown',\n\t\t\tudid\n\t\t}\n\t};\n};\n\nconst waitForBootedSimulator = async (\n\tproject: AbsoluteIosDevProject,\n\tudid: string,\n\tcapture: NonNullable<StartAbsoluteIosDevOptions['capture']>,\n\tsleep: NonNullable<StartAbsoluteIosDevOptions['sleep']>,\n\tsignal?: AbortSignal\n) => {\n\tconst deadline = Date.now() + BOOT_TIMEOUT_MS;\n\tconst poll = async (): Promise<void> => {\n\t\tthrowIfAborted(signal);\n\t\tconst device = simulatorInventory(project.xcrun, capture).find(\n\t\t\t(candidate) => candidate.udid === udid\n\t\t);\n\t\tif (device?.state === 'Booted') return;\n\t\tif (Date.now() > deadline)\n\t\t\tthrow new Error(\n\t\t\t\t`iOS simulator ${udid} did not finish booting within ${BOOT_TIMEOUT_MS / 1_000}s.`\n\t\t\t);\n\t\tawait sleep(BOOT_POLL_MS);\n\n\t\tawait poll();\n\t};\n\n\treturn poll();\n};\n\nconst bootSimulator = (\n\tproject: AbsoluteIosDevProject,\n\tdevice: ReturnType<typeof parseIosSimulators>[number],\n\tcapture: NonNullable<StartAbsoluteIosDevOptions['capture']>\n) => {\n\tif (device.state === 'Booted') return;\n\trequireCapturedSuccess(\n\t\tcapture([project.xcrun, 'simctl', 'boot', device.udid]),\n\t\t'iOS simulator boot'\n\t);\n};\n\nconst installedAppIdentity = (\n\tproject: AbsoluteIosDevProject,\n\tudid: string,\n\tcapture: NonNullable<StartAbsoluteIosDevOptions['capture']>\n) => {\n\tconst result = capture([\n\t\tproject.xcrun,\n\t\t'simctl',\n\t\t'get_app_container',\n\t\tudid,\n\t\tproject.config.appId,\n\t\t'app'\n\t]);\n\n\treturn result.exitCode === 0 && result.stdout.trim()\n\t\t? result.stdout.trim()\n\t\t: undefined;\n};\n\nconst buildIosDebugApp = async (\n\tproject: AbsoluteIosDevProject,\n\tudid: string,\n\tfingerprint: string,\n\trun: NonNullable<StartAbsoluteIosDevOptions['run']>,\n\tsignal?: AbortSignal\n) => {\n\tconst derivedDataPath = join(\n\t\tproject.projectRoot,\n\t\t'.absolutejs',\n\t\t'mobile',\n\t\t'ios-derived-data',\n\t\tcreateHash('sha256')\n\t\t\t.update(project.config.appId)\n\t\t\t.digest('hex')\n\t\t\t.slice(0, 16)\n\t);\n\tawait mkdir(derivedDataPath, { recursive: true });\n\tawait requireSuccess(\n\t\t[\n\t\t\tproject.xcodebuild,\n\t\t\t'-workspace',\n\t\t\tjoin(project.nativeDirectory, 'App', 'App.xcworkspace'),\n\t\t\t'-scheme',\n\t\t\t'App',\n\t\t\t'-configuration',\n\t\t\t'Debug',\n\t\t\t'-destination',\n\t\t\t`platform=iOS Simulator,id=${udid}`,\n\t\t\t'-derivedDataPath',\n\t\t\tderivedDataPath,\n\t\t\t'build'\n\t\t],\n\t\t'iOS simulator build',\n\t\trun,\n\t\t{ cwd: project.nativeDirectory, signal }\n\t);\n\tconst appPath = join(\n\t\tderivedDataPath,\n\t\t'Build',\n\t\t'Products',\n\t\t'Debug-iphonesimulator',\n\t\t'App.app'\n\t);\n\tif (!(await pathExists(appPath)))\n\t\tthrow new Error(\n\t\t\t`Xcode did not produce the simulator app at ${appPath}.`\n\t\t);\n\n\treturn appPath;\n};\n\nconst ensureIosDebugApp = async (options: {\n\tcache: IosNativeCache | null;\n\tcapture: NonNullable<StartAbsoluteIosDevOptions['capture']>;\n\tfingerprint: string;\n\tlog: NonNullable<StartAbsoluteIosDevOptions['log']>;\n\tproject: AbsoluteIosDevProject;\n\trun: NonNullable<StartAbsoluteIosDevOptions['run']>;\n\tsignal?: AbortSignal;\n\ttransition: (state: AbsoluteIosDevState) => void;\n\tudid: string;\n}) => {\n\tconst installed = installedAppIdentity(\n\t\toptions.project,\n\t\toptions.udid,\n\t\toptions.capture\n\t);\n\tconst cacheHit =\n\t\toptions.cache?.appId === options.project.config.appId &&\n\t\toptions.cache.fingerprint === options.fingerprint &&\n\t\tinstalled !== undefined &&\n\t\toptions.cache.installations[options.udid] === installed;\n\tif (cacheHit) {\n\t\toptions.log(\n\t\t\t`iOS native app is unchanged on ${options.udid}; skipped Xcode build and install.`\n\t\t);\n\n\t\treturn true;\n\t}\n\toptions.log(\n\t\t'iOS native inputs changed or the installed app is stale; rebuilding.'\n\t);\n\toptions.transition('building');\n\tconst appPath = await buildIosDebugApp(\n\t\toptions.project,\n\t\toptions.udid,\n\t\toptions.fingerprint,\n\t\toptions.run,\n\t\toptions.signal\n\t);\n\tthrowIfAborted(options.signal);\n\toptions.transition('installing');\n\tawait requireSuccess(\n\t\t[options.project.xcrun, 'simctl', 'install', options.udid, appPath],\n\t\t'iOS simulator app installation',\n\t\toptions.run,\n\t\t{ signal: options.signal }\n\t);\n\tconst updated = installedAppIdentity(\n\t\toptions.project,\n\t\toptions.udid,\n\t\toptions.capture\n\t);\n\tif (updated) {\n\t\tawait writeNativeCache(options.project.projectRoot, {\n\t\t\tappId: options.project.config.appId,\n\t\t\tfingerprint: options.fingerprint,\n\t\t\tformat: NATIVE_CACHE_FORMAT,\n\t\t\tinstallations: { [options.udid]: updated }\n\t\t}).catch((error) =>\n\t\t\toptions.log(\n\t\t\t\t`iOS native cache could not be saved: ${error instanceof Error ? error.message : String(error)}`\n\t\t\t)\n\t\t);\n\t}\n\n\treturn false;\n};\n\nconst SECRET_VALUE =\n\t/((?:authorization|cookie|password|secret|token|oauth[_-]?code)\\s*[:=]\\s*)([^\\s,;]+)/giu;\nconst BEARER_VALUE = new RegExp(\n\tString.raw`\\bBearer\\s+[A-Za-z0-9._~+/-]+=*`,\n\t'giu'\n);\nconst JWT_VALUE = /\\beyJ[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\b/gu;\nconst IOS_LOG_PATTERN = new RegExp(\n\tString.raw`\\s(Debug|Info|Notice|Error|Fault)\\s+.*?\\[[^\\]]+\\]\\s+\\[([^\\]]+)\\]\\s*(.*)$`,\n\t'iu'\n);\n\nexport const parseAbsoluteIosLogLine = (\n\tline: string\n): AbsoluteIosNativeLogEntry | null => {\n\tconst sanitized = redactAbsoluteIosLog(line).trim();\n\tif (!sanitized) return null;\n\tconst match = IOS_LOG_PATTERN.exec(sanitized);\n\tconst candidate = match?.[1]?.toLowerCase();\n\tconst level =\n\t\tcandidate === 'debug' ||\n\t\tcandidate === 'error' ||\n\t\tcandidate === 'fault' ||\n\t\tcandidate === 'notice'\n\t\t\t? candidate\n\t\t\t: 'info';\n\n\treturn {\n\t\tlevel,\n\t\tmessage: match?.[3]?.trim() || sanitized,\n\t\ttag: match?.[2]?.trim() || 'App'\n\t};\n};\nexport const redactAbsoluteIosLog = (value: string) =>\n\tvalue\n\t\t.replaceAll(BEARER_VALUE, 'Bearer [REDACTED]')\n\t\t.replaceAll(JWT_VALUE, '[REDACTED_JWT]')\n\t\t.replaceAll(SECRET_VALUE, '$1[REDACTED]')\n\t\t.replaceAll(/\\p{C}/gu, '');\n\nconst attachNativeLogs = (\n\tproject: AbsoluteIosDevProject,\n\tudid: string,\n\toptions: StartAbsoluteIosDevOptions\n) => {\n\tif (!options.nativeLog) return null;\n\tconst start = options.startNativeLogs ?? defaultStartNativeLogs;\n\n\treturn start(\n\t\t[\n\t\t\tproject.xcrun,\n\t\t\t'simctl',\n\t\t\t'spawn',\n\t\t\tudid,\n\t\t\t'log',\n\t\t\t'stream',\n\t\t\t'--style',\n\t\t\t'compact',\n\t\t\t'--level',\n\t\t\t'debug',\n\t\t\t'--predicate',\n\t\t\t'process == \"App\"'\n\t\t],\n\t\t{ signal: options.signal },\n\t\t(line) => {\n\t\t\tconst entry = parseAbsoluteIosLogLine(line);\n\t\t\tif (entry) options.nativeLog?.(entry);\n\t\t}\n\t);\n};\n\nconst IOS_TIMING_PHASES: Array<[string, string]> = [\n\t['syncing', 'Capacitor sync'],\n\t['configuring', 'dev config'],\n\t['fingerprinting', 'fingerprint'],\n\t['booting', 'simulator'],\n\t['connecting', 'device ready'],\n\t['checking-native', 'app check'],\n\t['building', 'Xcode'],\n\t['installing', 'install'],\n\t['launching', 'launch'],\n\t['streaming-logs', 'logs']\n];\n\nconst timingSummary = (timings: Record<string, number>) =>\n\tIOS_TIMING_PHASES.map(([phase, label]) => {\n\t\tconst duration = timings[phase];\n\n\t\treturn duration === undefined\n\t\t\t? null\n\t\t\t: `${label} ${getDurationString(duration)}`;\n\t})\n\t\t.filter((value): value is string => value !== null)\n\t\t.join(', ');\n\nexport const prepareAbsoluteIosDevProject = async (\n\tconfig: NormalizedAbsoluteMobileConfig,\n\toptions: PrepareAbsoluteIosDevOptions\n): Promise<AbsoluteIosDevProject> => {\n\tif (detectAbsoluteMobileHost() !== 'macos')\n\t\tthrow new Error('iOS simulation requires macOS and Xcode.');\n\tconst projectRoot = resolve(options.projectRoot);\n\tconst checks = await inspectAbsoluteMobileToolchain({ host: 'macos' });\n\tconst failed = checks.filter(\n\t\t(check) =>\n\t\t\tcheck.platform === 'ios' &&\n\t\t\t(check.status === 'fail' || check.status === 'warn')\n\t);\n\tif (failed.length > 0)\n\t\tthrow new Error(\n\t\t\t`iOS simulation is not ready: ${failed.map(({ label }) => label).join(', ')}.`\n\t\t);\n\tconst xcrun = checks.find((check) => check.id === 'ios.xcrun')?.path;\n\tconst xcodebuild = checks.find(\n\t\t(check) => check.id === 'ios.xcodebuild'\n\t)?.path;\n\tif (!xcrun || !xcodebuild)\n\t\tthrow new Error('Xcode tools disappeared after readiness checks.');\n\tconst cap = join(projectRoot, 'node_modules', '.bin', 'cap');\n\tif (!(await pathExists(cap)))\n\t\tthrow new Error(\n\t\t\t'Capacitor CLI is not installed. Run absolute mobile init first.'\n\t\t);\n\tawait writeAbsoluteCapacitorConfig(config, { projectRoot });\n\tawait mkdir(config.bundleDirectory, { recursive: true });\n\tconst placeholder = join(config.bundleDirectory, 'index.html');\n\tif (!(await pathExists(placeholder)))\n\t\tawait writeFile(\n\t\t\tplaceholder,\n\t\t\t'<!doctype html><title>AbsoluteJS mobile development</title>\\n'\n\t\t);\n\tconst nativeDirectory = join(config.nativeProjectDirectory, 'ios');\n\tif (!(await pathExists(nativeDirectory))) {\n\t\tif (!options.createNativeProject)\n\t\t\tthrow new Error('iOS native project has not been created.');\n\t\tconst run = options.run ?? defaultRun;\n\t\tif ((await run([cap, 'add', 'ios'], { cwd: projectRoot })) !== 0)\n\t\t\tthrow new Error('Capacitor iOS project creation failed.');\n\t}\n\n\treturn {\n\t\tcap,\n\t\tconfig,\n\t\tnativeDirectory,\n\t\tprojectRoot,\n\t\txcodebuild,\n\t\txcrun\n\t};\n};\n\nexport const startAbsoluteIosDevSession = async (\n\toptions: StartAbsoluteIosDevOptions\n): Promise<AbsoluteIosDevSession> => {\n\tconst { project } = options;\n\tconst capture = options.capture ?? defaultCapture;\n\tconst run = options.run ?? defaultRun;\n\tconst sleep = options.sleep ?? Bun.sleep;\n\tconst spawn = options.spawn ?? defaultSpawn;\n\tconst log = options.log ?? console.log;\n\tconst startedAt = performance.now();\n\tlet phaseStartedAt = performance.now();\n\tconst timings: Record<string, number> = {};\n\tlet state: AbsoluteIosDevState = 'syncing';\n\tconst transition = (next: AbsoluteIosDevState) => {\n\t\tif (next === state) {\n\t\t\toptions.onStateChange?.(next);\n\n\t\t\treturn;\n\t\t}\n\t\tconst now = performance.now();\n\t\tconst durationMs = now - phaseStartedAt;\n\t\ttimings[state] = (timings[state] ?? 0) + durationMs;\n\t\toptions.onPhaseTiming?.({\n\t\t\tdurationMs,\n\t\t\tphase: state,\n\t\t\ttotalMs: now - startedAt\n\t\t});\n\t\tstate = next;\n\t\tphaseStartedAt = now;\n\t\toptions.onStateChange?.(next);\n\t};\n\tlet nativeLogs: AbsoluteIosLogStream | null = null;\n\tconst closeLogs = async () => {\n\t\tconst stream = nativeLogs;\n\t\tnativeLogs = null;\n\t\tawait stream?.close().catch(() => undefined);\n\t};\n\ttry {\n\t\tawait repairAbsoluteIosDevSession(project.projectRoot);\n\t\tthrowIfAborted(options.signal);\n\t\ttransition('syncing');\n\t\tawait requireSuccess(\n\t\t\t[project.cap, 'sync', 'ios'],\n\t\t\t'Capacitor iOS synchronization',\n\t\t\trun,\n\t\t\t{ cwd: project.projectRoot, signal: options.signal }\n\t\t);\n\t\ttransition('configuring');\n\t\tawait writeDevProjection(project, options.port, options.https === true);\n\t\tthrowIfAborted(options.signal);\n\t\tconst fingerprintStartedAt = performance.now();\n\t\tconst fingerprintPromise = fingerprintAbsoluteIosDevProject(\n\t\t\tproject\n\t\t).then((fingerprint) => {\n\t\t\ttimings.fingerprinting = performance.now() - fingerprintStartedAt;\n\n\t\t\treturn fingerprint;\n\t\t});\n\t\ttransition('booting');\n\t\tconst { created, device } = await ensureManagedSimulator(\n\t\t\tproject,\n\t\t\tcapture\n\t\t);\n\t\tconst startedSimulator = created || device.state !== 'Booted';\n\t\tbootSimulator(project, device, capture);\n\t\tspawn([\n\t\t\t'open',\n\t\t\t'-a',\n\t\t\t'Simulator',\n\t\t\t'--args',\n\t\t\t'-CurrentDeviceUDID',\n\t\t\tdevice.udid\n\t\t]);\n\t\ttransition('connecting');\n\t\tawait waitForBootedSimulator(\n\t\t\tproject,\n\t\t\tdevice.udid,\n\t\t\tcapture,\n\t\t\tsleep,\n\t\t\toptions.signal\n\t\t);\n\t\tawait requireSuccess(\n\t\t\t[project.xcrun, 'simctl', 'bootstatus', device.udid, '-b'],\n\t\t\t'iOS simulator boot readiness',\n\t\t\trun,\n\t\t\t{ signal: options.signal }\n\t\t);\n\t\tconst fingerprint = await fingerprintPromise;\n\t\ttransition('checking-native');\n\t\tconst nativeCacheHit = await ensureIosDebugApp({\n\t\t\tcache: await readNativeCache(project.projectRoot),\n\t\t\tcapture,\n\t\t\tfingerprint,\n\t\t\tlog,\n\t\t\tproject,\n\t\t\trun,\n\t\t\tsignal: options.signal,\n\t\t\ttransition,\n\t\t\tudid: device.udid\n\t\t});\n\t\tthrowIfAborted(options.signal);\n\t\tif (options.nativeLog) transition('streaming-logs');\n\t\tnativeLogs = attachNativeLogs(project, device.udid, options);\n\t\ttransition('launching');\n\t\tawait requireSuccess(\n\t\t\t[\n\t\t\t\tproject.xcrun,\n\t\t\t\t'simctl',\n\t\t\t\t'launch',\n\t\t\t\t'--terminate-running-process',\n\t\t\t\tdevice.udid,\n\t\t\t\tproject.config.appId\n\t\t\t],\n\t\t\t'iOS app launch',\n\t\t\trun,\n\t\t\t{ signal: options.signal }\n\t\t);\n\t\ttransition('ready');\n\t\ttimings.total = performance.now() - startedAt;\n\t\tlog(\n\t\t\t`iOS simulator connected (${device.udid}) with HMR on port ${options.port} in ${getDurationString(timings.total)} (${nativeCacheHit ? 'native cache hit' : 'native build installed'}).`\n\t\t);\n\t\tlog(`iOS startup: ${timingSummary(timings)}.`);\n\t\tlet closed = false;\n\t\tconst close = async () => {\n\t\t\tif (closed) return;\n\t\t\tclosed = true;\n\t\t\ttransition('closing');\n\t\t\tawait closeLogs();\n\t\t\tawait repairAbsoluteIosDevSession(project.projectRoot);\n\t\t\ttransition('closed');\n\t\t};\n\n\t\treturn {\n\t\t\tclose,\n\t\t\tnativeCacheHit,\n\t\t\tstartedSimulator,\n\t\t\ttimings: { ...timings },\n\t\t\tudid: device.udid,\n\t\t\trebuild: async () => {\n\t\t\t\tif (closed)\n\t\t\t\t\tthrow new Error('iOS development session is closed.');\n\t\t\t\tlog(\n\t\t\t\t\t'iOS native inputs changed; rebuilding without restarting the dev server.'\n\t\t\t\t);\n\t\t\t\tawait close();\n\n\t\t\t\treturn startAbsoluteIosDevSession(options);\n\t\t\t},\n\t\t\trelaunch: async () => {\n\t\t\t\tif (closed)\n\t\t\t\t\tthrow new Error('iOS development session is closed.');\n\t\t\t\ttransition('launching');\n\t\t\t\ttry {\n\t\t\t\t\tawait requireSuccess(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\tproject.xcrun,\n\t\t\t\t\t\t\t'simctl',\n\t\t\t\t\t\t\t'launch',\n\t\t\t\t\t\t\t'--terminate-running-process',\n\t\t\t\t\t\t\tdevice.udid,\n\t\t\t\t\t\t\tproject.config.appId\n\t\t\t\t\t\t],\n\t\t\t\t\t\t'iOS app relaunch',\n\t\t\t\t\t\trun,\n\t\t\t\t\t\t{ signal: options.signal }\n\t\t\t\t\t);\n\t\t\t\t\ttransition('ready');\n\t\t\t\t\tlog(`iOS app relaunched on ${device.udid}.`);\n\t\t\t\t} catch (error) {\n\t\t\t\t\ttransition('failed');\n\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t},\n\t\t\tscreenshot: async (destination) => {\n\t\t\t\tconst resolved = resolve(project.projectRoot, destination);\n\t\t\t\tif (!isInside(project.projectRoot, resolved))\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t'iOS screenshot destination must remain inside the project.'\n\t\t\t\t\t);\n\t\t\t\tawait mkdir(dirname(resolved), { recursive: true });\n\t\t\t\tawait requireSuccess(\n\t\t\t\t\t[\n\t\t\t\t\t\tproject.xcrun,\n\t\t\t\t\t\t'simctl',\n\t\t\t\t\t\t'io',\n\t\t\t\t\t\tdevice.udid,\n\t\t\t\t\t\t'screenshot',\n\t\t\t\t\t\tresolved\n\t\t\t\t\t],\n\t\t\t\t\t'iOS simulator screenshot',\n\t\t\t\t\trun,\n\t\t\t\t\t{ signal: options.signal }\n\t\t\t\t);\n\n\t\t\t\treturn resolved;\n\t\t\t},\n\t\t\tget state() {\n\t\t\t\treturn state;\n\t\t\t}\n\t\t};\n\t} catch (error) {\n\t\ttransition('failed');\n\t\tawait closeLogs();\n\t\tawait repairAbsoluteIosDevSession(project.projectRoot);\n\n\t\tthrow error;\n\t}\n};\n",
|
|
26
|
+
"import { createHash, randomUUID } from 'node:crypto';\nimport {\n\taccess,\n\tcopyFile,\n\tmkdir,\n\treadFile,\n\trename,\n\trm,\n\twriteFile\n} from 'node:fs/promises';\nimport { isIP } from 'node:net';\nimport { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';\nimport type { NormalizedAbsoluteMobileConfig } from './config';\nimport {\n\tdetectAbsoluteMobileHost,\n\tinspectAbsoluteMobileToolchain\n} from './emulatorDoctor';\nimport { writeAbsoluteCapacitorConfig } from './capacitorProject';\nimport { fingerprintAbsoluteIosNativeProject } from './iosRelease';\nimport {\n\tnormalizeAbsoluteIosDeviceHost,\n\tnormalizeAbsoluteIosDeviceIdentifier,\n\tstartAbsoluteIosCaEnrollmentServer,\n\ttype AbsoluteIosCaEnrollmentServer\n} from './iosPhysicalDeviceTransport';\nimport { getDurationString } from '../utils/getDurationString';\n\nexport const ABSOLUTE_IOS_SIMULATOR_NAME = 'AbsoluteJS iPhone';\n\nconst BOOT_TIMEOUT_MS = 180_000;\nconst BOOT_POLL_MS = 1_000;\nconst DEV_JOURNAL_FORMAT = 1;\nconst NATIVE_CACHE_FORMAT = 1;\n\nexport type AbsoluteIosCommandOptions = {\n\tcwd?: string;\n\tenv?: Record<string, string | undefined>;\n\tsignal?: AbortSignal;\n};\n\nexport type AbsoluteIosCommandResult = {\n\texitCode: number;\n\tstderr: string;\n\tstdout: string;\n};\n\nexport type AbsoluteIosDevState =\n\t| 'booting'\n\t| 'building'\n\t| 'checking-native'\n\t| 'closed'\n\t| 'closing'\n\t| 'configuring'\n\t| 'connecting'\n\t| 'enrolling-trust'\n\t| 'failed'\n\t| 'installing'\n\t| 'launching'\n\t| 'ready'\n\t| 'streaming-logs'\n\t| 'syncing';\n\nexport type AbsoluteIosNativeLogEntry = {\n\tlevel: 'debug' | 'error' | 'fault' | 'info' | 'notice';\n\tmessage: string;\n\ttag: string;\n};\n\ntype AbsoluteIosLogStream = { close: () => Promise<void> };\n\nexport type AbsoluteIosDevProject = {\n\tcap: string;\n\tconfig: NormalizedAbsoluteMobileConfig;\n\tnativeDirectory: string;\n\tprojectRoot: string;\n\txcodebuild: string;\n\txcrun: string;\n};\n\nexport type AbsoluteIosDevSession = {\n\tclose: () => Promise<void>;\n\tnativeCacheHit: boolean;\n\trebuild: () => Promise<AbsoluteIosDevSession>;\n\trelaunch: () => Promise<void>;\n\tscreenshot: (destination: string) => Promise<string>;\n\tstartedSimulator: boolean;\n\tstate: AbsoluteIosDevState;\n\ttargetKind: 'device' | 'simulator';\n\ttimings: Record<string, number>;\n\tudid: string;\n};\n\nexport type AbsoluteIosDevPhaseTiming = {\n\tdurationMs: number;\n\tphase: AbsoluteIosDevState;\n\ttotalMs: number;\n};\n\nexport type PrepareAbsoluteIosDevOptions = {\n\tcreateNativeProject: boolean;\n\tprojectRoot: string;\n\trun?: (\n\t\tcommand: string[],\n\t\toptions?: AbsoluteIosCommandOptions\n\t) => Promise<number>;\n\ttarget?: 'device' | 'simulator';\n};\n\nexport type StartAbsoluteIosDevOptions = {\n\t/** CA certificate installed into this simulator's trusted root store. */\n\tcertificateAuthorityPath?: string;\n\tcapture?: (\n\t\tcommand: string[],\n\t\toptions?: AbsoluteIosCommandOptions\n\t) => AbsoluteIosCommandResult;\n\t/** Xcode device identifier or name. Omit to use the managed Simulator. */\n\tdeviceIdentifier?: string;\n\t/** Launch the locally embedded production web bundle. `port` remains the\n\t * configured backend port and no temporary development URL is projected. */\n\tembeddedBundle?: boolean;\n\thttps?: boolean;\n\tlog?: (message: string) => void;\n\tnativeLog?: (entry: AbsoluteIosNativeLogEntry) => void;\n\tonPhaseTiming?: (timing: AbsoluteIosDevPhaseTiming) => void;\n\tonStateChange?: (state: AbsoluteIosDevState) => void;\n\tport: number;\n\tproject: AbsoluteIosDevProject;\n\trun?: (\n\t\tcommand: string[],\n\t\toptions?: AbsoluteIosCommandOptions\n\t) => Promise<number>;\n\t/** Hostname or LAN address embedded into a physical-device dev URL. */\n\tserverHost?: string;\n\tsignal?: AbortSignal;\n\tsleep?: (milliseconds: number) => Promise<void>;\n\tspawn?: (command: string[], options?: AbsoluteIosCommandOptions) => void;\n\tstartNativeLogs?: (\n\t\tcommand: string[],\n\t\toptions: AbsoluteIosCommandOptions,\n\t\tonLine: (line: string) => void\n\t) => AbsoluteIosLogStream;\n\tstartCaEnrollmentServer?: (options: {\n\t\tcertificateAuthorityPath: string;\n\t\tdisplayHost: string;\n\t}) => Promise<AbsoluteIosCaEnrollmentServer>;\n};\n\ntype IosRuntime = {\n\tidentifier: string;\n\tisAvailable: boolean;\n\tname: string;\n\tversion: string;\n};\n\ntype IosDeviceType = { identifier: string; name: string };\n\ntype IosDevJournal = {\n\tconfigBackupPath: string;\n\tformat: number;\n\tinfoBackupPath: string;\n\tinfoPath: string;\n\tnativeConfigPath: string;\n};\n\ntype IosNativeCache = {\n\tappId: string;\n\tfingerprint: string;\n\tformat: number;\n\tinstallations: Record<string, string>;\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n\ttypeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst pathExists = async (path: string) => {\n\ttry {\n\t\tawait access(path);\n\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n};\n\nconst throwIfAborted = (signal?: AbortSignal) => signal?.throwIfAborted();\n\nconst defaultCapture = (\n\tcommand: string[],\n\toptions: AbsoluteIosCommandOptions = {}\n) => {\n\ttry {\n\t\tconst result = Bun.spawnSync(command, {\n\t\t\tcwd: options.cwd,\n\t\t\tenv: options.env,\n\t\t\tstderr: 'pipe',\n\t\t\tstdin: 'ignore',\n\t\t\tstdout: 'pipe'\n\t\t});\n\n\t\treturn {\n\t\t\texitCode: result.exitCode,\n\t\t\tstderr: result.stderr.toString(),\n\t\t\tstdout: result.stdout.toString()\n\t\t};\n\t} catch (error) {\n\t\treturn {\n\t\t\texitCode: 1,\n\t\t\tstderr: error instanceof Error ? error.message : String(error),\n\t\t\tstdout: ''\n\t\t};\n\t}\n};\n\nconst defaultRun = async (\n\tcommand: string[],\n\toptions: AbsoluteIosCommandOptions = {}\n) => {\n\tconst process = Bun.spawn(command, {\n\t\tcwd: options.cwd,\n\t\tenv: options.env,\n\t\tsignal: options.signal,\n\t\tstderr: 'inherit',\n\t\tstdin: 'inherit',\n\t\tstdout: 'inherit'\n\t});\n\n\treturn process.exited;\n};\n\nconst defaultSpawn = (\n\tcommand: string[],\n\toptions: AbsoluteIosCommandOptions = {}\n) => {\n\tBun.spawn(command, {\n\t\tcwd: options.cwd,\n\t\tenv: options.env,\n\t\tsignal: options.signal,\n\t\tstderr: 'ignore',\n\t\tstdin: 'ignore',\n\t\tstdout: 'ignore'\n\t});\n};\n\nconst consumeLines = async (\n\tstream: ReadableStream<Uint8Array>,\n\tonLine: (line: string) => void\n) => {\n\tconst reader = stream.getReader();\n\tconst decoder = new TextDecoder();\n\tlet buffered = '';\n\tconst pump = async (): Promise<void> => {\n\t\tconst { done, value } = await reader.read();\n\t\tif (done) return;\n\t\tbuffered += decoder.decode(value, { stream: true });\n\t\tconst lines = buffered.split(/\\r?\\n/u);\n\t\tbuffered = lines.pop() ?? '';\n\t\tlines.forEach(onLine);\n\n\t\tawait pump();\n\t};\n\ttry {\n\t\tawait pump();\n\t\tbuffered += decoder.decode();\n\t\tif (buffered) onLine(buffered);\n\t} finally {\n\t\treader.releaseLock();\n\t}\n};\n\nconst defaultStartNativeLogs = (\n\tcommand: string[],\n\toptions: AbsoluteIosCommandOptions,\n\tonLine: (line: string) => void\n): AbsoluteIosLogStream => {\n\tconst process = Bun.spawn(command, {\n\t\tcwd: options.cwd,\n\t\tenv: options.env,\n\t\tsignal: options.signal,\n\t\tstderr: 'pipe',\n\t\tstdin: 'ignore',\n\t\tstdout: 'pipe'\n\t});\n\tvoid consumeLines(process.stdout, onLine);\n\tvoid consumeLines(process.stderr, onLine);\n\n\treturn {\n\t\tclose: async () => {\n\t\t\ttry {\n\t\t\t\tprocess.kill();\n\t\t\t} catch {\n\t\t\t\t/* already closed */\n\t\t\t}\n\t\t\tawait process.exited.catch(() => undefined);\n\t\t}\n\t};\n};\n\nconst requireSuccess = async (\n\tcommand: string[],\n\tlabel: string,\n\trun: NonNullable<StartAbsoluteIosDevOptions['run']>,\n\toptions?: AbsoluteIosCommandOptions\n) => {\n\tconst exitCode = await run(command, options);\n\tif (exitCode !== 0)\n\t\tthrow new Error(`${label} failed with status ${exitCode}.`);\n};\n\nconst trustIosSimulatorDevelopmentCa = async (\n\toptions: StartAbsoluteIosDevOptions,\n\tudid: string,\n\trun: NonNullable<StartAbsoluteIosDevOptions['run']>,\n\tlog: NonNullable<StartAbsoluteIosDevOptions['log']>\n) => {\n\tif (!options.https) return;\n\tif (!options.certificateAuthorityPath) {\n\t\tthrow new Error(\n\t\t\t'iOS Simulator HTTPS requires the AbsoluteJS development CA certificate.'\n\t\t);\n\t}\n\tawait requireSuccess(\n\t\t[\n\t\t\toptions.project.xcrun,\n\t\t\t'simctl',\n\t\t\t'keychain',\n\t\t\tudid,\n\t\t\t'add-root-cert',\n\t\t\toptions.certificateAuthorityPath\n\t\t],\n\t\t'iOS Simulator development CA trust',\n\t\trun,\n\t\t{ signal: options.signal }\n\t);\n\tlog(\n\t\t'Installed the AbsoluteJS development CA into this iOS Simulator trust store.'\n\t);\n};\n\nconst iosLaunchCommand = (\n\tproject: AbsoluteIosDevProject,\n\tudid: string,\n\tphysical: boolean\n) =>\n\tphysical\n\t\t? [\n\t\t\t\tproject.xcrun,\n\t\t\t\t'devicectl',\n\t\t\t\t'device',\n\t\t\t\t'process',\n\t\t\t\t'launch',\n\t\t\t\t'--terminate-existing',\n\t\t\t\t'--device',\n\t\t\t\tudid,\n\t\t\t\tproject.config.appId\n\t\t\t]\n\t\t: [\n\t\t\t\tproject.xcrun,\n\t\t\t\t'simctl',\n\t\t\t\t'launch',\n\t\t\t\t'--terminate-running-process',\n\t\t\t\tudid,\n\t\t\t\tproject.config.appId\n\t\t\t];\n\nconst requireCapturedSuccess = (\n\tresult: AbsoluteIosCommandResult,\n\tlabel: string\n) => {\n\tif (result.exitCode !== 0) {\n\t\tthrow new Error(\n\t\t\t`${label} failed: ${result.stderr.trim() || result.stdout.trim() || `status ${result.exitCode}`}`\n\t\t);\n\t}\n\n\treturn result.stdout.trim();\n};\n\nconst parseJson = (source: string, label: string) => {\n\ttry {\n\t\tconst parsed: unknown = JSON.parse(source);\n\t\tif (isRecord(parsed)) return parsed;\n\t} catch {\n\t\t/* normalized below */\n\t}\n\tthrow new Error(`Invalid ${label} JSON from simctl.`);\n};\n\nexport const parseIosDeviceTypes = (source: string) => {\n\tconst parsed = parseJson(source, 'device type');\n\tconst types = parsed.devicetypes;\n\tif (!Array.isArray(types)) return [];\n\n\treturn types.flatMap((type) => {\n\t\tif (!isRecord(type)) return [];\n\t\tconst { identifier } = type;\n\t\tconst { name } = type;\n\n\t\treturn typeof identifier === 'string' && typeof name === 'string'\n\t\t\t? [{ identifier, name }]\n\t\t\t: [];\n\t});\n};\nexport const parseIosRuntimes = (source: string) => {\n\tconst parsed = parseJson(source, 'runtime');\n\tconst { runtimes } = parsed;\n\tif (!Array.isArray(runtimes)) return [];\n\n\treturn runtimes.flatMap((runtime) => {\n\t\tif (!isRecord(runtime)) return [];\n\t\tconst { identifier } = runtime;\n\t\tconst { name } = runtime;\n\t\tconst { version } = runtime;\n\t\tif (\n\t\t\ttypeof identifier !== 'string' ||\n\t\t\ttypeof name !== 'string' ||\n\t\t\ttypeof version !== 'string'\n\t\t)\n\t\t\treturn [];\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tidentifier,\n\t\t\t\tisAvailable: runtime.isAvailable !== false,\n\t\t\t\tname,\n\t\t\t\tversion\n\t\t\t}\n\t\t];\n\t});\n};\nexport const parseIosSimulators = (source: string) => {\n\tconst parsed = parseJson(source, 'device');\n\tconst { devices } = parsed;\n\tif (!isRecord(devices)) return [];\n\n\treturn Object.entries(devices).flatMap(([runtime, values]) => {\n\t\tif (!Array.isArray(values)) return [];\n\n\t\treturn values.flatMap((device) => {\n\t\t\tif (!isRecord(device)) return [];\n\t\t\tconst { name } = device;\n\t\t\tconst { state } = device;\n\t\t\tconst { udid } = device;\n\t\t\tif (\n\t\t\t\ttypeof name !== 'string' ||\n\t\t\t\ttypeof state !== 'string' ||\n\t\t\t\ttypeof udid !== 'string'\n\t\t\t)\n\t\t\t\treturn [];\n\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tisAvailable: device.isAvailable !== false,\n\t\t\t\t\tname,\n\t\t\t\t\truntime,\n\t\t\t\t\tstate,\n\t\t\t\t\tudid\n\t\t\t\t}\n\t\t\t];\n\t\t});\n\t});\n};\n\nconst versionParts = (version: string) =>\n\tversion.split('.').map((part) => Number(part));\n\nconst compareVersions = (left: string, right: string) => {\n\tconst leftParts = versionParts(left);\n\tconst rightParts = versionParts(right);\n\tconst length = Math.max(leftParts.length, rightParts.length);\n\tfor (let index = 0; index < length; index++) {\n\t\tconst difference = (leftParts[index] ?? 0) - (rightParts[index] ?? 0);\n\t\tif (difference !== 0) return difference;\n\t}\n\n\treturn 0;\n};\n\nconst latestIosRuntime = (runtimes: IosRuntime[]) =>\n\truntimes\n\t\t.filter(\n\t\t\t(runtime) =>\n\t\t\t\truntime.isAvailable &&\n\t\t\t\truntime.identifier.includes('SimRuntime.iOS-')\n\t\t)\n\t\t.sort((left, right) => compareVersions(right.version, left.version))[0];\n\nconst iphoneGeneration = (name: string) =>\n\tNumber(/iPhone\\s+(\\d+)/u.exec(name)?.[1] ?? 0);\n\nconst preferredIphoneType = (types: IosDeviceType[]) =>\n\ttypes\n\t\t.filter((type) => type.name.startsWith('iPhone'))\n\t\t.sort((left, right) => {\n\t\t\tconst generation =\n\t\t\t\tiphoneGeneration(right.name) - iphoneGeneration(left.name);\n\t\t\tif (generation !== 0) return generation;\n\t\t\tconst rightPro = right.name.includes('Pro') ? 1 : 0;\n\t\t\tconst leftPro = left.name.includes('Pro') ? 1 : 0;\n\n\t\t\treturn rightPro - leftPro;\n\t\t})[0];\n\nconst journalPaths = (projectRoot: string) => {\n\tconst root = join(projectRoot, '.absolutejs', 'mobile', 'ios-dev-session');\n\n\treturn {\n\t\tconfigBackup: join(root, 'capacitor-config.backup'),\n\t\tinfoBackup: join(root, 'Info.plist.backup'),\n\t\tjournal: join(root, 'journal.json'),\n\t\troot\n\t};\n};\n\nconst nativeCachePath = (projectRoot: string) =>\n\tjoin(projectRoot, '.absolutejs', 'mobile', 'ios-native-cache.json');\n\nconst isInside = (root: string, path: string) => {\n\tconst value = relative(resolve(root), resolve(path));\n\n\treturn (\n\t\tvalue === '' ||\n\t\t(!value.startsWith(`..${sep}`) && value !== '..' && !isAbsolute(value))\n\t);\n};\n\nconst parseJournal = (value: unknown): IosDevJournal | null => {\n\tif (!isRecord(value) || value.format !== DEV_JOURNAL_FORMAT) return null;\n\tconst { configBackupPath } = value;\n\tconst { infoBackupPath } = value;\n\tconst { infoPath } = value;\n\tconst { nativeConfigPath } = value;\n\tif (\n\t\ttypeof configBackupPath !== 'string' ||\n\t\ttypeof infoBackupPath !== 'string' ||\n\t\ttypeof infoPath !== 'string' ||\n\t\ttypeof nativeConfigPath !== 'string'\n\t)\n\t\treturn null;\n\n\treturn {\n\t\tconfigBackupPath,\n\t\tformat: DEV_JOURNAL_FORMAT,\n\t\tinfoBackupPath,\n\t\tinfoPath,\n\t\tnativeConfigPath\n\t};\n};\n\nexport const repairAbsoluteIosDevSession = async (projectRoot: string) => {\n\tconst paths = journalPaths(projectRoot);\n\tif (!(await pathExists(paths.journal))) {\n\t\tawait rm(paths.root, { force: true, recursive: true });\n\n\t\treturn false;\n\t}\n\tconst journal = await readFile(paths.journal, 'utf8')\n\t\t.then((source) => parseJournal(JSON.parse(source)))\n\t\t.catch(() => null);\n\tif (\n\t\t!journal ||\n\t\t!isInside(projectRoot, journal.nativeConfigPath) ||\n\t\t!isInside(projectRoot, journal.infoPath) ||\n\t\t!isInside(paths.root, journal.configBackupPath) ||\n\t\t!isInside(paths.root, journal.infoBackupPath)\n\t) {\n\t\tthrow new Error(\n\t\t\t`Refusing unsafe or invalid iOS dev journal at ${paths.journal}.`\n\t\t);\n\t}\n\tif (await pathExists(journal.configBackupPath))\n\t\tawait copyFile(journal.configBackupPath, journal.nativeConfigPath);\n\tif (await pathExists(journal.infoBackupPath))\n\t\tawait copyFile(journal.infoBackupPath, journal.infoPath);\n\tawait rm(paths.root, { force: true, recursive: true });\n\n\treturn true;\n};\n\nconst iosDevelopmentInfoPlist = (source: string, cleartext: boolean) => {\n\tif (!cleartext) return source;\n\tconst arbitraryLoads =\n\t\t/(<key>NSAllowsArbitraryLoads<\\/key>\\s*)<false\\s*\\/>/u;\n\tif (arbitraryLoads.test(source))\n\t\treturn source.replace(arbitraryLoads, '$1<true/>');\n\tif (/<key>NSAllowsArbitraryLoads<\\/key>\\s*<true\\s*\\/>/u.test(source))\n\t\treturn source;\n\tconst transport = /(<key>NSAppTransportSecurity<\\/key>\\s*<dict>)/u;\n\tif (transport.test(source))\n\t\treturn source.replace(\n\t\t\ttransport,\n\t\t\t'$1\\n\\t\\t<key>NSAllowsArbitraryLoads</key>\\n\\t\\t<true/>'\n\t\t);\n\n\treturn source.replace(\n\t\t/<dict>/u,\n\t\t'<dict>\\n\\t<key>NSAppTransportSecurity</key>\\n\\t<dict>\\n\\t\\t<key>NSAllowsArbitraryLoads</key>\\n\\t\\t<true/>\\n\\t</dict>'\n\t);\n};\n\nconst writeDevProjection = async (\n\tproject: AbsoluteIosDevProject,\n\tport: number,\n\thttps: boolean,\n\tserverHost = 'localhost'\n) => {\n\tconst paths = journalPaths(project.projectRoot);\n\tawait repairAbsoluteIosDevSession(project.projectRoot);\n\tconst nativeConfigPath = join(\n\t\tproject.nativeDirectory,\n\t\t'App',\n\t\t'App',\n\t\t'capacitor.config.json'\n\t);\n\tconst infoPath = join(project.nativeDirectory, 'App', 'App', 'Info.plist');\n\tconst [configSource, infoSource] = await Promise.all([\n\t\treadFile(nativeConfigPath, 'utf8'),\n\t\treadFile(infoPath, 'utf8')\n\t]);\n\tconst parsed: unknown = JSON.parse(configSource);\n\tif (!isRecord(parsed))\n\t\tthrow new Error(\n\t\t\t`Invalid Capacitor native config at ${nativeConfigPath}.`\n\t\t);\n\tawait mkdir(paths.root, { recursive: true });\n\tawait Promise.all([\n\t\twriteFile(paths.configBackup, configSource, { flag: 'wx' }),\n\t\twriteFile(paths.infoBackup, infoSource, { flag: 'wx' })\n\t]);\n\tconst journal: IosDevJournal = {\n\t\tconfigBackupPath: paths.configBackup,\n\t\tformat: DEV_JOURNAL_FORMAT,\n\t\tinfoBackupPath: paths.infoBackup,\n\t\tinfoPath,\n\t\tnativeConfigPath\n\t};\n\tawait writeFile(paths.journal, `${JSON.stringify(journal, null, '\\t')}\\n`, {\n\t\tflag: 'wx'\n\t});\n\tconst developmentUrl = new URL(\n\t\t`${https ? 'https' : 'http'}://localhost:${port}${project.config.entry}`\n\t);\n\tdevelopmentUrl.hostname =\n\t\tisIP(serverHost) === 6 ? `[${serverHost}]` : serverHost;\n\tdevelopmentUrl.searchParams.set('__absolute_target', 'capacitor-ios');\n\tconst existingServer = parsed.server;\n\tparsed.server = {\n\t\t...(isRecord(existingServer) ? existingServer : {}),\n\t\tcleartext: !https,\n\t\turl: developmentUrl.href\n\t};\n\tawait Promise.all([\n\t\twriteFile(nativeConfigPath, `${JSON.stringify(parsed, null, '\\t')}\\n`),\n\t\twriteFile(infoPath, iosDevelopmentInfoPlist(infoSource, !https))\n\t]);\n};\n\nconst parseNativeCache = (value: unknown): IosNativeCache | null => {\n\tif (!isRecord(value)) return null;\n\tconst { appId, fingerprint, format, installations } = value;\n\tif (\n\t\tformat !== NATIVE_CACHE_FORMAT ||\n\t\ttypeof appId !== 'string' ||\n\t\ttypeof fingerprint !== 'string' ||\n\t\t!isRecord(installations) ||\n\t\t!Object.values(installations).every(\n\t\t\t(identity) => typeof identity === 'string'\n\t\t)\n\t)\n\t\treturn null;\n\n\treturn {\n\t\tappId,\n\t\tfingerprint,\n\t\tformat,\n\t\tinstallations: Object.fromEntries(\n\t\t\tObject.entries(installations).map(([udid, identity]) => [\n\t\t\t\tudid,\n\t\t\t\tString(identity)\n\t\t\t])\n\t\t)\n\t};\n};\n\nconst readNativeCache = (projectRoot: string) =>\n\treadFile(nativeCachePath(projectRoot), 'utf8')\n\t\t.then((source) => parseNativeCache(JSON.parse(source)))\n\t\t.catch(() => null);\n\nconst writeNativeCache = async (projectRoot: string, cache: IosNativeCache) => {\n\tconst destination = nativeCachePath(projectRoot);\n\tconst temporary = `${destination}.${process.pid}.${randomUUID()}.tmp`;\n\tawait mkdir(dirname(destination), { recursive: true });\n\ttry {\n\t\tawait writeFile(temporary, `${JSON.stringify(cache, null, '\\t')}\\n`, {\n\t\t\tflag: 'wx'\n\t\t});\n\t\tawait rename(temporary, destination);\n\t} finally {\n\t\tawait rm(temporary, { force: true }).catch(() => undefined);\n\t}\n};\n\nexport const fingerprintAbsoluteIosDevProject = async (\n\tproject: Pick<AbsoluteIosDevProject, 'nativeDirectory'>,\n\toptions: { includePublicBundle?: boolean } = {}\n) => fingerprintAbsoluteIosNativeProject(project.nativeDirectory, options);\n\nconst simulatorInventory = (\n\txcrun: string,\n\tcapture: NonNullable<StartAbsoluteIosDevOptions['capture']>\n) => {\n\tconst result = capture([\n\t\txcrun,\n\t\t'simctl',\n\t\t'list',\n\t\t'devices',\n\t\t'available',\n\t\t'-j'\n\t]);\n\n\treturn parseIosSimulators(\n\t\trequireCapturedSuccess(result, 'iOS simulator discovery')\n\t);\n};\n\nconst ensureManagedSimulator = async (\n\tproject: AbsoluteIosDevProject,\n\tcapture: NonNullable<StartAbsoluteIosDevOptions['capture']>\n) => {\n\tconst runtimes = parseIosRuntimes(\n\t\trequireCapturedSuccess(\n\t\t\tcapture([project.xcrun, 'simctl', 'list', 'runtimes', '-j']),\n\t\t\t'iOS runtime discovery'\n\t\t)\n\t);\n\tconst runtime = latestIosRuntime(runtimes);\n\tif (!runtime)\n\t\tthrow new Error(\n\t\t\t'No available iOS Simulator runtime. Run absolute mobile doctor ios --fix.'\n\t\t);\n\tconst [existing] = simulatorInventory(project.xcrun, capture)\n\t\t.filter(\n\t\t\t(device) =>\n\t\t\t\tdevice.isAvailable &&\n\t\t\t\tdevice.name === ABSOLUTE_IOS_SIMULATOR_NAME &&\n\t\t\t\tdevice.runtime === runtime.identifier\n\t\t)\n\t\t.sort(\n\t\t\t(left, right) =>\n\t\t\t\tNumber(right.state === 'Booted') -\n\t\t\t\tNumber(left.state === 'Booted')\n\t\t);\n\tif (existing) return { created: false, device: existing };\n\tconst types = parseIosDeviceTypes(\n\t\trequireCapturedSuccess(\n\t\t\tcapture([project.xcrun, 'simctl', 'list', 'devicetypes', '-j']),\n\t\t\t'iOS device-type discovery'\n\t\t)\n\t);\n\tconst type = preferredIphoneType(types);\n\tif (!type)\n\t\tthrow new Error('Xcode did not report an iPhone simulator type.');\n\tconst [udid] = requireCapturedSuccess(\n\t\tcapture([\n\t\t\tproject.xcrun,\n\t\t\t'simctl',\n\t\t\t'create',\n\t\t\tABSOLUTE_IOS_SIMULATOR_NAME,\n\t\t\ttype.identifier,\n\t\t\truntime.identifier\n\t\t]),\n\t\t'iOS simulator creation'\n\t).split(/\\s/u);\n\tif (!udid)\n\t\tthrow new Error('simctl did not return the created simulator UDID.');\n\n\treturn {\n\t\tcreated: true,\n\t\tdevice: {\n\t\t\tisAvailable: true,\n\t\t\tname: ABSOLUTE_IOS_SIMULATOR_NAME,\n\t\t\truntime: runtime.identifier,\n\t\t\tstate: 'Shutdown',\n\t\t\tudid\n\t\t}\n\t};\n};\n\nconst waitForBootedSimulator = async (\n\tproject: AbsoluteIosDevProject,\n\tudid: string,\n\tcapture: NonNullable<StartAbsoluteIosDevOptions['capture']>,\n\tsleep: NonNullable<StartAbsoluteIosDevOptions['sleep']>,\n\tsignal?: AbortSignal\n) => {\n\tconst deadline = Date.now() + BOOT_TIMEOUT_MS;\n\tconst poll = async (): Promise<void> => {\n\t\tthrowIfAborted(signal);\n\t\tconst device = simulatorInventory(project.xcrun, capture).find(\n\t\t\t(candidate) => candidate.udid === udid\n\t\t);\n\t\tif (device?.state === 'Booted') return;\n\t\tif (Date.now() > deadline)\n\t\t\tthrow new Error(\n\t\t\t\t`iOS simulator ${udid} did not finish booting within ${BOOT_TIMEOUT_MS / 1_000}s.`\n\t\t\t);\n\t\tawait sleep(BOOT_POLL_MS);\n\n\t\tawait poll();\n\t};\n\n\treturn poll();\n};\n\nconst bootSimulator = (\n\tproject: AbsoluteIosDevProject,\n\tdevice: ReturnType<typeof parseIosSimulators>[number],\n\tcapture: NonNullable<StartAbsoluteIosDevOptions['capture']>\n) => {\n\tif (device.state === 'Booted') return;\n\trequireCapturedSuccess(\n\t\tcapture([project.xcrun, 'simctl', 'boot', device.udid]),\n\t\t'iOS simulator boot'\n\t);\n};\n\nconst installedAppIdentity = (\n\tproject: AbsoluteIosDevProject,\n\tudid: string,\n\tcapture: NonNullable<StartAbsoluteIosDevOptions['capture']>\n) => {\n\tconst result = capture([\n\t\tproject.xcrun,\n\t\t'simctl',\n\t\t'get_app_container',\n\t\tudid,\n\t\tproject.config.appId,\n\t\t'app'\n\t]);\n\n\treturn result.exitCode === 0 && result.stdout.trim()\n\t\t? result.stdout.trim()\n\t\t: undefined;\n};\n\nconst validatePhysicalIosDevice = (\n\tproject: AbsoluteIosDevProject,\n\tidentifier: string,\n\tcapture: NonNullable<StartAbsoluteIosDevOptions['capture']>\n) => {\n\tconst result = capture([\n\t\tproject.xcrun,\n\t\t'devicectl',\n\t\t'device',\n\t\t'info',\n\t\t'details',\n\t\t'--device',\n\t\tidentifier\n\t]);\n\tif (result.exitCode !== 0)\n\t\tthrow new Error(\n\t\t\t`Physical iOS device ${JSON.stringify(identifier)} is unavailable: ${result.stderr.trim() || result.stdout.trim() || 'pair it in Xcode Device Hub, trust this Mac, unlock it, and enable Developer Mode.'}`\n\t\t);\n};\n\nconst physicalIosAppIsInstalled = (\n\tproject: AbsoluteIosDevProject,\n\tidentifier: string,\n\tcapture: NonNullable<StartAbsoluteIosDevOptions['capture']>\n) => {\n\tconst result = capture([\n\t\tproject.xcrun,\n\t\t'devicectl',\n\t\t'device',\n\t\t'info',\n\t\t'apps',\n\t\t'--device',\n\t\tidentifier\n\t]);\n\n\treturn (\n\t\tresult.exitCode === 0 && result.stdout.includes(project.config.appId)\n\t);\n};\n\nconst buildIosDebugApp = async (\n\tproject: AbsoluteIosDevProject,\n\tudid: string,\n\tfingerprint: string,\n\trun: NonNullable<StartAbsoluteIosDevOptions['run']>,\n\tsignal?: AbortSignal\n) => {\n\tconst derivedDataPath = join(\n\t\tproject.projectRoot,\n\t\t'.absolutejs',\n\t\t'mobile',\n\t\t'ios-derived-data',\n\t\tcreateHash('sha256')\n\t\t\t.update(project.config.appId)\n\t\t\t.digest('hex')\n\t\t\t.slice(0, 16)\n\t);\n\tawait mkdir(derivedDataPath, { recursive: true });\n\tawait requireSuccess(\n\t\t[\n\t\t\tproject.xcodebuild,\n\t\t\t'-workspace',\n\t\t\tjoin(project.nativeDirectory, 'App', 'App.xcworkspace'),\n\t\t\t'-scheme',\n\t\t\t'App',\n\t\t\t'-configuration',\n\t\t\t'Debug',\n\t\t\t'-destination',\n\t\t\t`platform=iOS Simulator,id=${udid}`,\n\t\t\t'-derivedDataPath',\n\t\t\tderivedDataPath,\n\t\t\t'build'\n\t\t],\n\t\t'iOS simulator build',\n\t\trun,\n\t\t{ cwd: project.nativeDirectory, signal }\n\t);\n\tconst appPath = join(\n\t\tderivedDataPath,\n\t\t'Build',\n\t\t'Products',\n\t\t'Debug-iphonesimulator',\n\t\t'App.app'\n\t);\n\tif (!(await pathExists(appPath)))\n\t\tthrow new Error(\n\t\t\t`Xcode did not produce the simulator app at ${appPath}.`\n\t\t);\n\n\treturn appPath;\n};\n\nconst buildPhysicalIosDebugApp = async (\n\tproject: AbsoluteIosDevProject,\n\tidentifier: string,\n\trun: NonNullable<StartAbsoluteIosDevOptions['run']>,\n\tsignal?: AbortSignal\n) => {\n\tconst derivedDataPath = join(\n\t\tproject.projectRoot,\n\t\t'.absolutejs',\n\t\t'mobile',\n\t\t'ios-derived-data',\n\t\tcreateHash('sha256')\n\t\t\t.update(project.config.appId)\n\t\t\t.digest('hex')\n\t\t\t.slice(0, 16)\n\t);\n\tawait mkdir(derivedDataPath, { recursive: true });\n\tawait requireSuccess(\n\t\t[\n\t\t\tproject.xcodebuild,\n\t\t\t'-workspace',\n\t\t\tjoin(project.nativeDirectory, 'App', 'App.xcworkspace'),\n\t\t\t'-scheme',\n\t\t\t'App',\n\t\t\t'-configuration',\n\t\t\t'Debug',\n\t\t\t'-destination',\n\t\t\t`platform=iOS,id=${identifier}`,\n\t\t\t'-derivedDataPath',\n\t\t\tderivedDataPath,\n\t\t\t'-allowProvisioningUpdates',\n\t\t\t'build'\n\t\t],\n\t\t'iOS physical-device build (configure automatic signing and a Development Team in Xcode if this is the first run)',\n\t\trun,\n\t\t{ cwd: project.nativeDirectory, signal }\n\t);\n\tconst appPath = join(\n\t\tderivedDataPath,\n\t\t'Build',\n\t\t'Products',\n\t\t'Debug-iphoneos',\n\t\t'App.app'\n\t);\n\tif (!(await pathExists(appPath)))\n\t\tthrow new Error(\n\t\t\t`Xcode did not produce the physical-device app at ${appPath}.`\n\t\t);\n\n\treturn appPath;\n};\n\nconst ensurePhysicalIosDebugApp = async (options: {\n\tcache: IosNativeCache | null;\n\tcapture: NonNullable<StartAbsoluteIosDevOptions['capture']>;\n\tfingerprint: string;\n\tidentifier: string;\n\tlog: NonNullable<StartAbsoluteIosDevOptions['log']>;\n\tproject: AbsoluteIosDevProject;\n\trun: NonNullable<StartAbsoluteIosDevOptions['run']>;\n\tsignal?: AbortSignal;\n\ttransition: (state: AbsoluteIosDevState) => void;\n}) => {\n\tconst cacheHit =\n\t\toptions.cache?.appId === options.project.config.appId &&\n\t\toptions.cache.fingerprint === options.fingerprint &&\n\t\toptions.cache.installations[options.identifier] ===\n\t\t\toptions.fingerprint &&\n\t\tphysicalIosAppIsInstalled(\n\t\t\toptions.project,\n\t\t\toptions.identifier,\n\t\t\toptions.capture\n\t\t);\n\tif (cacheHit) {\n\t\toptions.log(\n\t\t\t`iOS native app is unchanged on the selected physical device; skipped Xcode build and install.`\n\t\t);\n\n\t\treturn true;\n\t}\n\toptions.log(\n\t\t'iOS native inputs changed or the physical-device install is stale; rebuilding.'\n\t);\n\toptions.transition('building');\n\tconst appPath = await buildPhysicalIosDebugApp(\n\t\toptions.project,\n\t\toptions.identifier,\n\t\toptions.run,\n\t\toptions.signal\n\t);\n\tthrowIfAborted(options.signal);\n\toptions.transition('installing');\n\tawait requireSuccess(\n\t\t[\n\t\t\toptions.project.xcrun,\n\t\t\t'devicectl',\n\t\t\t'device',\n\t\t\t'install',\n\t\t\t'app',\n\t\t\t'--device',\n\t\t\toptions.identifier,\n\t\t\tappPath\n\t\t],\n\t\t'iOS physical-device app installation',\n\t\toptions.run,\n\t\t{ signal: options.signal }\n\t);\n\tawait writeNativeCache(options.project.projectRoot, {\n\t\tappId: options.project.config.appId,\n\t\tfingerprint: options.fingerprint,\n\t\tformat: NATIVE_CACHE_FORMAT,\n\t\tinstallations: {\n\t\t\t...(options.cache?.appId === options.project.config.appId\n\t\t\t\t? options.cache.installations\n\t\t\t\t: {}),\n\t\t\t[options.identifier]: options.fingerprint\n\t\t}\n\t}).catch((error) =>\n\t\toptions.log(\n\t\t\t`iOS native cache could not be saved: ${error instanceof Error ? error.message : String(error)}`\n\t\t)\n\t);\n\n\treturn false;\n};\n\nconst ensureIosDebugApp = async (options: {\n\tcache: IosNativeCache | null;\n\tcapture: NonNullable<StartAbsoluteIosDevOptions['capture']>;\n\tfingerprint: string;\n\tlog: NonNullable<StartAbsoluteIosDevOptions['log']>;\n\tproject: AbsoluteIosDevProject;\n\trun: NonNullable<StartAbsoluteIosDevOptions['run']>;\n\tsignal?: AbortSignal;\n\ttransition: (state: AbsoluteIosDevState) => void;\n\tudid: string;\n}) => {\n\tconst installed = installedAppIdentity(\n\t\toptions.project,\n\t\toptions.udid,\n\t\toptions.capture\n\t);\n\tconst cacheHit =\n\t\toptions.cache?.appId === options.project.config.appId &&\n\t\toptions.cache.fingerprint === options.fingerprint &&\n\t\tinstalled !== undefined &&\n\t\toptions.cache.installations[options.udid] === installed;\n\tif (cacheHit) {\n\t\toptions.log(\n\t\t\t`iOS native app is unchanged on ${options.udid}; skipped Xcode build and install.`\n\t\t);\n\n\t\treturn true;\n\t}\n\toptions.log(\n\t\t'iOS native inputs changed or the installed app is stale; rebuilding.'\n\t);\n\toptions.transition('building');\n\tconst appPath = await buildIosDebugApp(\n\t\toptions.project,\n\t\toptions.udid,\n\t\toptions.fingerprint,\n\t\toptions.run,\n\t\toptions.signal\n\t);\n\tthrowIfAborted(options.signal);\n\toptions.transition('installing');\n\tawait requireSuccess(\n\t\t[options.project.xcrun, 'simctl', 'install', options.udid, appPath],\n\t\t'iOS simulator app installation',\n\t\toptions.run,\n\t\t{ signal: options.signal }\n\t);\n\tconst updated = installedAppIdentity(\n\t\toptions.project,\n\t\toptions.udid,\n\t\toptions.capture\n\t);\n\tif (updated) {\n\t\tawait writeNativeCache(options.project.projectRoot, {\n\t\t\tappId: options.project.config.appId,\n\t\t\tfingerprint: options.fingerprint,\n\t\t\tformat: NATIVE_CACHE_FORMAT,\n\t\t\tinstallations: { [options.udid]: updated }\n\t\t}).catch((error) =>\n\t\t\toptions.log(\n\t\t\t\t`iOS native cache could not be saved: ${error instanceof Error ? error.message : String(error)}`\n\t\t\t)\n\t\t);\n\t}\n\n\treturn false;\n};\n\nconst SECRET_VALUE =\n\t/((?:authorization|cookie|password|secret|token|oauth[_-]?code)\\s*[:=]\\s*)([^\\s,;]+)/giu;\nconst BEARER_VALUE = new RegExp(\n\tString.raw`\\bBearer\\s+[A-Za-z0-9._~+/-]+=*`,\n\t'giu'\n);\nconst JWT_VALUE = /\\beyJ[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\b/gu;\nconst IOS_LOG_PATTERN = new RegExp(\n\tString.raw`\\s(Debug|Info|Notice|Error|Fault)\\s+.*?\\[[^\\]]+\\]\\s+\\[([^\\]]+)\\]\\s*(.*)$`,\n\t'iu'\n);\n\nexport const parseAbsoluteIosLogLine = (\n\tline: string\n): AbsoluteIosNativeLogEntry | null => {\n\tconst sanitized = redactAbsoluteIosLog(line).trim();\n\tif (!sanitized) return null;\n\tconst match = IOS_LOG_PATTERN.exec(sanitized);\n\tconst candidate = match?.[1]?.toLowerCase();\n\tconst level =\n\t\tcandidate === 'debug' ||\n\t\tcandidate === 'error' ||\n\t\tcandidate === 'fault' ||\n\t\tcandidate === 'notice'\n\t\t\t? candidate\n\t\t\t: 'info';\n\n\treturn {\n\t\tlevel,\n\t\tmessage: match?.[3]?.trim() || sanitized,\n\t\ttag: match?.[2]?.trim() || 'App'\n\t};\n};\nexport const redactAbsoluteIosLog = (value: string) =>\n\tvalue\n\t\t.replaceAll(BEARER_VALUE, 'Bearer [REDACTED]')\n\t\t.replaceAll(JWT_VALUE, '[REDACTED_JWT]')\n\t\t.replaceAll(SECRET_VALUE, '$1[REDACTED]')\n\t\t.replaceAll(/\\p{C}/gu, '');\n\nconst attachNativeLogs = (\n\tproject: AbsoluteIosDevProject,\n\tudid: string,\n\toptions: StartAbsoluteIosDevOptions\n) => {\n\tif (!options.nativeLog) return null;\n\tconst start = options.startNativeLogs ?? defaultStartNativeLogs;\n\tconst command = options.deviceIdentifier\n\t\t? [\n\t\t\t\tproject.xcrun,\n\t\t\t\t'devicectl',\n\t\t\t\t'device',\n\t\t\t\t'process',\n\t\t\t\t'launch',\n\t\t\t\t'--console',\n\t\t\t\t'--terminate-existing',\n\t\t\t\t'--device',\n\t\t\t\tudid,\n\t\t\t\tproject.config.appId\n\t\t\t]\n\t\t: [\n\t\t\t\tproject.xcrun,\n\t\t\t\t'simctl',\n\t\t\t\t'spawn',\n\t\t\t\tudid,\n\t\t\t\t'log',\n\t\t\t\t'stream',\n\t\t\t\t'--style',\n\t\t\t\t'compact',\n\t\t\t\t'--level',\n\t\t\t\t'debug',\n\t\t\t\t'--predicate',\n\t\t\t\t'process == \"App\"'\n\t\t\t];\n\n\treturn start(command, { signal: options.signal }, (line) => {\n\t\tconst entry = parseAbsoluteIosLogLine(line);\n\t\tif (entry) options.nativeLog?.(entry);\n\t});\n};\n\nconst IOS_TIMING_PHASES: Array<[string, string]> = [\n\t['syncing', 'Capacitor sync'],\n\t['configuring', 'dev config'],\n\t['fingerprinting', 'fingerprint'],\n\t['booting', 'simulator'],\n\t['connecting', 'device ready'],\n\t['enrolling-trust', 'HTTPS trust'],\n\t['checking-native', 'app check'],\n\t['building', 'Xcode'],\n\t['installing', 'install'],\n\t['launching', 'launch'],\n\t['streaming-logs', 'logs']\n];\n\nconst timingSummary = (timings: Record<string, number>) =>\n\tIOS_TIMING_PHASES.map(([phase, label]) => {\n\t\tconst duration = timings[phase];\n\n\t\treturn duration === undefined\n\t\t\t? null\n\t\t\t: `${label} ${getDurationString(duration)}`;\n\t})\n\t\t.filter((value): value is string => value !== null)\n\t\t.join(', ');\n\nexport const prepareAbsoluteIosDevProject = async (\n\tconfig: NormalizedAbsoluteMobileConfig,\n\toptions: PrepareAbsoluteIosDevOptions\n): Promise<AbsoluteIosDevProject> => {\n\tif (detectAbsoluteMobileHost() !== 'macos')\n\t\tthrow new Error('iOS development requires macOS and Xcode.');\n\tconst target = options.target ?? 'simulator';\n\tconst projectRoot = resolve(options.projectRoot);\n\tconst checks = await inspectAbsoluteMobileToolchain({ host: 'macos' });\n\tconst failed = checks.filter(\n\t\t(check) =>\n\t\t\tcheck.platform === 'ios' &&\n\t\t\t!(target === 'device' && check.id === 'ios.runtime') &&\n\t\t\t(check.status === 'fail' || check.status === 'warn')\n\t);\n\tif (failed.length > 0)\n\t\tthrow new Error(\n\t\t\t`iOS ${target} development is not ready: ${failed.map(({ label }) => label).join(', ')}.`\n\t\t);\n\tconst xcrun = checks.find((check) => check.id === 'ios.xcrun')?.path;\n\tconst xcodebuild = checks.find(\n\t\t(check) => check.id === 'ios.xcodebuild'\n\t)?.path;\n\tif (!xcrun || !xcodebuild)\n\t\tthrow new Error('Xcode tools disappeared after readiness checks.');\n\tconst cap = join(projectRoot, 'node_modules', '.bin', 'cap');\n\tif (!(await pathExists(cap)))\n\t\tthrow new Error(\n\t\t\t'Capacitor CLI is not installed. Run absolute mobile init first.'\n\t\t);\n\tawait writeAbsoluteCapacitorConfig(config, { projectRoot });\n\tawait mkdir(config.bundleDirectory, { recursive: true });\n\tconst placeholder = join(config.bundleDirectory, 'index.html');\n\tif (!(await pathExists(placeholder)))\n\t\tawait writeFile(\n\t\t\tplaceholder,\n\t\t\t'<!doctype html><title>AbsoluteJS mobile development</title>\\n'\n\t\t);\n\tconst nativeDirectory = join(config.nativeProjectDirectory, 'ios');\n\tif (!(await pathExists(nativeDirectory))) {\n\t\tif (!options.createNativeProject)\n\t\t\tthrow new Error('iOS native project has not been created.');\n\t\tconst run = options.run ?? defaultRun;\n\t\tif ((await run([cap, 'add', 'ios'], { cwd: projectRoot })) !== 0)\n\t\t\tthrow new Error('Capacitor iOS project creation failed.');\n\t}\n\n\treturn {\n\t\tcap,\n\t\tconfig,\n\t\tnativeDirectory,\n\t\tprojectRoot,\n\t\txcodebuild,\n\t\txcrun\n\t};\n};\n\nconst preparePhysicalIosTarget = async (options: {\n\tcapture: NonNullable<StartAbsoluteIosDevOptions['capture']>;\n\tdeviceIdentifier: string;\n\tlog: NonNullable<StartAbsoluteIosDevOptions['log']>;\n\tproject: AbsoluteIosDevProject;\n\tserverHost: string;\n\tstartOptions: StartAbsoluteIosDevOptions;\n\ttransition: (state: AbsoluteIosDevState) => void;\n}) => {\n\toptions.transition('connecting');\n\tvalidatePhysicalIosDevice(\n\t\toptions.project,\n\t\toptions.deviceIdentifier,\n\t\toptions.capture\n\t);\n\tif (!options.startOptions.https)\n\t\treturn {\n\t\t\tcaEnrollmentServer: null,\n\t\t\tstartedSimulator: false,\n\t\t\tudid: options.deviceIdentifier\n\t\t};\n\tif (!options.startOptions.certificateAuthorityPath)\n\t\tthrow new Error(\n\t\t\t'Physical iOS HTTPS development requires the AbsoluteJS development CA certificate.'\n\t\t);\n\toptions.transition('enrolling-trust');\n\tconst startEnrollment =\n\t\toptions.startOptions.startCaEnrollmentServer ??\n\t\tstartAbsoluteIosCaEnrollmentServer;\n\tconst caEnrollmentServer = await startEnrollment({\n\t\tcertificateAuthorityPath: options.startOptions.certificateAuthorityPath,\n\t\tdisplayHost: options.serverHost\n\t});\n\toptions.log(\n\t\t`On the iOS device, open ${caEnrollmentServer.url}, install the AbsoluteJS development CA profile, then enable it under Settings > General > About > Certificate Trust Settings. This public CA endpoint exists only for this dev session.`\n\t);\n\n\treturn {\n\t\tcaEnrollmentServer,\n\t\tstartedSimulator: false,\n\t\tudid: options.deviceIdentifier\n\t};\n};\n\nconst prepareIosSimulatorTarget = async (options: {\n\tcapture: NonNullable<StartAbsoluteIosDevOptions['capture']>;\n\tlog: NonNullable<StartAbsoluteIosDevOptions['log']>;\n\tproject: AbsoluteIosDevProject;\n\trun: NonNullable<StartAbsoluteIosDevOptions['run']>;\n\tsleep: NonNullable<StartAbsoluteIosDevOptions['sleep']>;\n\tspawn: NonNullable<StartAbsoluteIosDevOptions['spawn']>;\n\tstartOptions: StartAbsoluteIosDevOptions;\n\ttransition: (state: AbsoluteIosDevState) => void;\n}) => {\n\toptions.transition('booting');\n\tconst managed = await ensureManagedSimulator(\n\t\toptions.project,\n\t\toptions.capture\n\t);\n\tconst { device } = managed;\n\tconst startedSimulator = managed.created || device.state !== 'Booted';\n\tbootSimulator(options.project, device, options.capture);\n\toptions.spawn([\n\t\t'open',\n\t\t'-a',\n\t\t'Simulator',\n\t\t'--args',\n\t\t'-CurrentDeviceUDID',\n\t\tdevice.udid\n\t]);\n\toptions.transition('connecting');\n\tawait waitForBootedSimulator(\n\t\toptions.project,\n\t\tdevice.udid,\n\t\toptions.capture,\n\t\toptions.sleep,\n\t\toptions.startOptions.signal\n\t);\n\tawait requireSuccess(\n\t\t[options.project.xcrun, 'simctl', 'bootstatus', device.udid, '-b'],\n\t\t'iOS simulator boot readiness',\n\t\toptions.run,\n\t\t{ signal: options.startOptions.signal }\n\t);\n\tawait trustIosSimulatorDevelopmentCa(\n\t\toptions.startOptions,\n\t\tdevice.udid,\n\t\toptions.run,\n\t\toptions.log\n\t);\n\n\treturn { caEnrollmentServer: null, startedSimulator, udid: device.udid };\n};\n\nexport const startAbsoluteIosDevSession = async (\n\toptions: StartAbsoluteIosDevOptions\n): Promise<AbsoluteIosDevSession> => {\n\tconst { project } = options;\n\tconst deviceIdentifier = options.deviceIdentifier\n\t\t? normalizeAbsoluteIosDeviceIdentifier(options.deviceIdentifier)\n\t\t: undefined;\n\tconst targetKind = deviceIdentifier ? 'device' : 'simulator';\n\tconst serverHost = deviceIdentifier\n\t\t? normalizeAbsoluteIosDeviceHost(options.serverHost ?? '')\n\t\t: 'localhost';\n\tconst capture = options.capture ?? defaultCapture;\n\tconst run = options.run ?? defaultRun;\n\tconst sleep = options.sleep ?? Bun.sleep;\n\tconst spawn = options.spawn ?? defaultSpawn;\n\tconst log = options.log ?? console.log;\n\tconst startedAt = performance.now();\n\tlet phaseStartedAt = performance.now();\n\tconst timings: Record<string, number> = {};\n\tlet state: AbsoluteIosDevState = 'syncing';\n\tconst transition = (next: AbsoluteIosDevState) => {\n\t\tif (next === state) {\n\t\t\toptions.onStateChange?.(next);\n\n\t\t\treturn;\n\t\t}\n\t\tconst now = performance.now();\n\t\tconst durationMs = now - phaseStartedAt;\n\t\ttimings[state] = (timings[state] ?? 0) + durationMs;\n\t\toptions.onPhaseTiming?.({\n\t\t\tdurationMs,\n\t\t\tphase: state,\n\t\t\ttotalMs: now - startedAt\n\t\t});\n\t\tstate = next;\n\t\tphaseStartedAt = now;\n\t\toptions.onStateChange?.(next);\n\t};\n\tlet nativeLogs: AbsoluteIosLogStream | null = null;\n\tlet caEnrollmentServer: AbsoluteIosCaEnrollmentServer | null = null;\n\tconst closeLogs = async () => {\n\t\tconst stream = nativeLogs;\n\t\tnativeLogs = null;\n\t\tawait stream?.close().catch(() => undefined);\n\t};\n\tconst relaunchTarget = async (udid: string) => {\n\t\tif (deviceIdentifier && options.nativeLog) {\n\t\t\tawait closeLogs();\n\t\t\tnativeLogs = attachNativeLogs(project, udid, options);\n\n\t\t\treturn;\n\t\t}\n\t\tawait requireSuccess(\n\t\t\tiosLaunchCommand(project, udid, deviceIdentifier !== undefined),\n\t\t\t'iOS app relaunch',\n\t\t\trun,\n\t\t\t{ signal: options.signal }\n\t\t);\n\t};\n\ttry {\n\t\tawait repairAbsoluteIosDevSession(project.projectRoot);\n\t\tthrowIfAborted(options.signal);\n\t\ttransition('syncing');\n\t\tawait requireSuccess(\n\t\t\t[project.cap, 'sync', 'ios'],\n\t\t\t'Capacitor iOS synchronization',\n\t\t\trun,\n\t\t\t{ cwd: project.projectRoot, signal: options.signal }\n\t\t);\n\t\ttransition('configuring');\n\t\tif (options.embeddedBundle !== true)\n\t\t\tawait writeDevProjection(\n\t\t\t\tproject,\n\t\t\t\toptions.port,\n\t\t\t\toptions.https === true,\n\t\t\t\tserverHost\n\t\t\t);\n\t\tthrowIfAborted(options.signal);\n\t\tconst fingerprintStartedAt = performance.now();\n\t\tconst fingerprintPromise = fingerprintAbsoluteIosDevProject(project, {\n\t\t\tincludePublicBundle: options.embeddedBundle === true\n\t\t}).then((fingerprint) => {\n\t\t\ttimings.fingerprinting = performance.now() - fingerprintStartedAt;\n\n\t\t\treturn fingerprint;\n\t\t});\n\t\tconst target = deviceIdentifier\n\t\t\t? await preparePhysicalIosTarget({\n\t\t\t\t\tcapture,\n\t\t\t\t\tdeviceIdentifier,\n\t\t\t\t\tlog,\n\t\t\t\t\tproject,\n\t\t\t\t\tserverHost,\n\t\t\t\t\tstartOptions: options,\n\t\t\t\t\ttransition\n\t\t\t\t})\n\t\t\t: await prepareIosSimulatorTarget({\n\t\t\t\t\tcapture,\n\t\t\t\t\tlog,\n\t\t\t\t\tproject,\n\t\t\t\t\trun,\n\t\t\t\t\tsleep,\n\t\t\t\t\tspawn,\n\t\t\t\t\tstartOptions: options,\n\t\t\t\t\ttransition\n\t\t\t\t});\n\t\tconst {\n\t\t\tcaEnrollmentServer: targetCaEnrollmentServer,\n\t\t\tstartedSimulator,\n\t\t\tudid\n\t\t} = target;\n\t\tcaEnrollmentServer = targetCaEnrollmentServer;\n\t\tconst fingerprint = await fingerprintPromise;\n\t\ttransition('checking-native');\n\t\tconst cache = await readNativeCache(project.projectRoot);\n\t\tconst nativeCacheHit = deviceIdentifier\n\t\t\t? await ensurePhysicalIosDebugApp({\n\t\t\t\t\tcache,\n\t\t\t\t\tcapture,\n\t\t\t\t\tfingerprint,\n\t\t\t\t\tidentifier: deviceIdentifier,\n\t\t\t\t\tlog,\n\t\t\t\t\tproject,\n\t\t\t\t\trun,\n\t\t\t\t\tsignal: options.signal,\n\t\t\t\t\ttransition\n\t\t\t\t})\n\t\t\t: await ensureIosDebugApp({\n\t\t\t\t\tcache,\n\t\t\t\t\tcapture,\n\t\t\t\t\tfingerprint,\n\t\t\t\t\tlog,\n\t\t\t\t\tproject,\n\t\t\t\t\trun,\n\t\t\t\t\tsignal: options.signal,\n\t\t\t\t\ttransition,\n\t\t\t\t\tudid\n\t\t\t\t});\n\t\tthrowIfAborted(options.signal);\n\t\tif (options.nativeLog) transition('streaming-logs');\n\t\tnativeLogs = attachNativeLogs(project, udid, options);\n\t\ttransition('launching');\n\t\tif (!deviceIdentifier || !nativeLogs)\n\t\t\tawait requireSuccess(\n\t\t\t\tiosLaunchCommand(project, udid, deviceIdentifier !== undefined),\n\t\t\t\t'iOS app launch',\n\t\t\t\trun,\n\t\t\t\t{ signal: options.signal }\n\t\t\t);\n\t\ttransition('ready');\n\t\ttimings.total = performance.now() - startedAt;\n\t\tlog(\n\t\t\toptions.embeddedBundle === true\n\t\t\t\t? `iOS ${targetKind} connected with the embedded bundle and backend on port ${options.port} in ${getDurationString(timings.total)} (${nativeCacheHit ? 'native cache hit' : 'native build installed'}).`\n\t\t\t\t: `iOS ${targetKind} connected with HMR on port ${options.port} in ${getDurationString(timings.total)} (${nativeCacheHit ? 'native cache hit' : 'native build installed'}).`\n\t\t);\n\t\tlog(`iOS startup: ${timingSummary(timings)}.`);\n\t\tlet closed = false;\n\t\tconst close = async () => {\n\t\t\tif (closed) return;\n\t\t\tclosed = true;\n\t\t\ttransition('closing');\n\t\t\tawait closeLogs();\n\t\t\tawait caEnrollmentServer?.close().catch(() => undefined);\n\t\t\tcaEnrollmentServer = null;\n\t\t\tawait repairAbsoluteIosDevSession(project.projectRoot);\n\t\t\ttransition('closed');\n\t\t};\n\n\t\treturn {\n\t\t\tclose,\n\t\t\tnativeCacheHit,\n\t\t\tstartedSimulator,\n\t\t\ttargetKind,\n\t\t\ttimings: { ...timings },\n\t\t\tudid,\n\t\t\trebuild: async () => {\n\t\t\t\tif (closed)\n\t\t\t\t\tthrow new Error('iOS development session is closed.');\n\t\t\t\tlog(\n\t\t\t\t\t'iOS native inputs changed; rebuilding without restarting the dev server.'\n\t\t\t\t);\n\t\t\t\tawait close();\n\n\t\t\t\treturn startAbsoluteIosDevSession(options);\n\t\t\t},\n\t\t\trelaunch: async () => {\n\t\t\t\tif (closed)\n\t\t\t\t\tthrow new Error('iOS development session is closed.');\n\t\t\t\ttransition('launching');\n\t\t\t\ttry {\n\t\t\t\t\tawait relaunchTarget(udid);\n\t\t\t\t\ttransition('ready');\n\t\t\t\t\tlog(`iOS app relaunched on the selected ${targetKind}.`);\n\t\t\t\t} catch (error) {\n\t\t\t\t\ttransition('failed');\n\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t},\n\t\t\tscreenshot: async (destination) => {\n\t\t\t\tif (deviceIdentifier)\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t'Physical iOS screenshots are captured in Xcode Device Hub; the CLI never records a device screen automatically.'\n\t\t\t\t\t);\n\t\t\t\tconst resolved = resolve(project.projectRoot, destination);\n\t\t\t\tif (!isInside(project.projectRoot, resolved))\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t'iOS screenshot destination must remain inside the project.'\n\t\t\t\t\t);\n\t\t\t\tawait mkdir(dirname(resolved), { recursive: true });\n\t\t\t\tawait requireSuccess(\n\t\t\t\t\t[\n\t\t\t\t\t\tproject.xcrun,\n\t\t\t\t\t\t'simctl',\n\t\t\t\t\t\t'io',\n\t\t\t\t\t\tudid,\n\t\t\t\t\t\t'screenshot',\n\t\t\t\t\t\tresolved\n\t\t\t\t\t],\n\t\t\t\t\t'iOS simulator screenshot',\n\t\t\t\t\trun,\n\t\t\t\t\t{ signal: options.signal }\n\t\t\t\t);\n\n\t\t\t\treturn resolved;\n\t\t\t},\n\t\t\tget state() {\n\t\t\t\treturn state;\n\t\t\t}\n\t\t};\n\t} catch (error) {\n\t\ttransition('failed');\n\t\tawait closeLogs();\n\t\tawait caEnrollmentServer?.close().catch(() => undefined);\n\t\tawait repairAbsoluteIosDevSession(project.projectRoot);\n\n\t\tthrow error;\n\t}\n};\n",
|
|
27
|
+
"import { randomUUID, X509Certificate } from 'node:crypto';\nimport { createServer, type Server as HttpServer } from 'node:http';\nimport {\n\tconnect as connectTcp,\n\tcreateServer as createTcpServer,\n\tisIP,\n\ttype Server as TcpServer\n} from 'node:net';\nimport { readFile } from 'node:fs/promises';\n\nexport type AbsoluteIosCloseableServer = {\n\tclose: () => Promise<void>;\n};\n\nexport type AbsoluteIosCaEnrollmentServer = AbsoluteIosCloseableServer & {\n\turl: string;\n};\n\nconst closeServer = (server: HttpServer | TcpServer) =>\n\tnew Promise<void>((resolve, reject) => {\n\t\tserver.close((error) => {\n\t\t\tif (error) reject(error);\n\t\t\telse resolve();\n\t\t});\n\t});\n\nconst listen = (server: HttpServer | TcpServer, port: number) =>\n\tnew Promise<number>((resolve, reject) => {\n\t\tserver.once('error', reject);\n\t\tserver.listen(port, '0.0.0.0', () => {\n\t\t\tserver.off('error', reject);\n\t\t\tconst address = server.address();\n\t\t\tif (!address || typeof address === 'string') {\n\t\t\t\treject(\n\t\t\t\t\tnew Error('Could not determine the iOS device helper port.')\n\t\t\t\t);\n\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tresolve(address.port);\n\t\t});\n\t});\n\nconst findEphemeralPort = async () => {\n\tconst probe = createTcpServer();\n\tconst port = await new Promise<number>((resolve, reject) => {\n\t\tprobe.once('error', reject);\n\t\tprobe.listen(0, '127.0.0.1', () => {\n\t\t\tconst address = probe.address();\n\t\t\tif (!address || typeof address === 'string') {\n\t\t\t\treject(\n\t\t\t\t\tnew Error('Could not allocate the iOS CA enrollment port.')\n\t\t\t\t);\n\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tresolve(address.port);\n\t\t});\n\t});\n\tawait closeServer(probe);\n\n\treturn port;\n};\n\nexport const normalizeAbsoluteIosDeviceHost = (value: string) => {\n\tconst normalized = value.trim();\n\tif (!normalized || normalized.length > 253 || /[\\0\\s/?#]/u.test(normalized))\n\t\tthrow new TypeError(\n\t\t\t'Physical iOS development requires a valid LAN host.'\n\t\t);\n\n\treturn normalized;\n};\nexport const normalizeAbsoluteIosDeviceIdentifier = (value: string) => {\n\tconst normalized = value.trim();\n\tif (!normalized || normalized.length > 256 || /[\\0\\r\\n]/u.test(normalized))\n\t\tthrow new TypeError(\n\t\t\t'--ios-device requires a valid Xcode device identifier or name.'\n\t\t);\n\n\treturn normalized;\n};\n\nconst urlForHost = (protocol: 'http' | 'https', host: string, port: number) => {\n\tconst url = new URL(`${protocol}://localhost:${port}`);\n\tconst normalizedHost = normalizeAbsoluteIosDeviceHost(host);\n\turl.hostname =\n\t\tisIP(normalizedHost) === 6 ? `[${normalizedHost}]` : normalizedHost;\n\n\treturn url;\n};\n\nexport const startAbsoluteIosCaEnrollmentServer = async (options: {\n\tcertificateAuthorityPath: string;\n\tdisplayHost: string;\n}): Promise<AbsoluteIosCaEnrollmentServer> => {\n\tconst certificate = new X509Certificate(\n\t\tawait readFile(options.certificateAuthorityPath)\n\t);\n\tconst certificateBytes = certificate.raw;\n\tconst token = randomUUID().replaceAll('-', '');\n\tconst certificatePath = `/${token}/absolutejs-development-ca.cer`;\n\tconst server = createServer((request, response) => {\n\t\tif (request.method !== 'GET' || request.url !== certificatePath) {\n\t\t\tresponse.writeHead(404, {\n\t\t\t\t'Cache-Control': 'no-store',\n\t\t\t\t'Content-Type': 'text/plain; charset=utf-8'\n\t\t\t});\n\t\t\tresponse.end('Not found.');\n\n\t\t\treturn;\n\t\t}\n\t\tresponse.writeHead(200, {\n\t\t\t'Cache-Control': 'no-store',\n\t\t\t'Content-Disposition':\n\t\t\t\t'attachment; filename=\"absolutejs-development-ca.cer\"',\n\t\t\t'Content-Length': String(certificateBytes.byteLength),\n\t\t\t'Content-Type': 'application/x-x509-ca-cert',\n\t\t\t'X-Content-Type-Options': 'nosniff'\n\t\t});\n\t\tresponse.end(certificateBytes);\n\t});\n\tconst port = await findEphemeralPort();\n\tawait listen(server, port);\n\tconst url = urlForHost('http', options.displayHost, port);\n\turl.pathname = certificatePath;\n\n\treturn {\n\t\turl: url.href,\n\t\tclose: () => closeServer(server)\n\t};\n};\n\nexport const startAbsoluteIosTcpRelay = async (options: {\n\tlistenPort: number;\n\ttargetPort: number;\n}): Promise<AbsoluteIosCloseableServer> => {\n\tconst server = createTcpServer((downstream) => {\n\t\tconst upstream = connectTcp({\n\t\t\thost: '127.0.0.1',\n\t\t\tport: options.targetPort\n\t\t});\n\t\tdownstream.pipe(upstream);\n\t\tupstream.pipe(downstream);\n\t\tconst closePeer = () => {\n\t\t\tdownstream.destroy();\n\t\t\tupstream.destroy();\n\t\t};\n\t\tdownstream.once('error', closePeer);\n\t\tupstream.once('error', closePeer);\n\t});\n\tawait listen(server, options.listenPort);\n\n\treturn { close: () => closeServer(server) };\n};\n",
|
|
19
28
|
"import { watch, type FSWatcher } from 'node:fs';\nimport { basename } from 'node:path';\nimport {\n\tfingerprintAbsoluteIosDevProject,\n\ttype AbsoluteIosDevProject\n} from './iosSimulatorController';\n\nconst NATIVE_CHANGE_DEBOUNCE_MS = 500;\nconst ROOT_NATIVE_INPUTS = new Set([\n\t'absolute.config.js',\n\t'absolute.config.mjs',\n\t'absolute.config.ts',\n\t'absolutejs.config.js',\n\t'absolutejs.config.mjs',\n\t'absolutejs.config.ts',\n\t'bun.lock',\n\t'bun.lockb',\n\t'capacitor.config.js',\n\t'capacitor.config.ts',\n\t'package.json'\n]);\n\nexport type AbsoluteIosNativeChange = {\n\tafterFingerprint: string;\n\tbeforeFingerprint: string;\n\tpaths: string[];\n\trootInputChanged: boolean;\n};\n\nexport type AbsoluteIosNativeWatcher = { close: () => void };\n\nexport type AbsoluteIosNativeWatcherOptions = {\n\tdebounceMs?: number;\n\tonChange: (change: AbsoluteIosNativeChange) => Promise<void>;\n\tonError?: (error: unknown) => void;\n\tproject: AbsoluteIosDevProject;\n\tsignal?: AbortSignal;\n};\n\nexport const createAbsoluteIosNativeWatcher = async (\n\toptions: AbsoluteIosNativeWatcherOptions\n): Promise<AbsoluteIosNativeWatcher> => {\n\tlet fingerprint = await fingerprintAbsoluteIosDevProject(options.project);\n\tlet closed = false;\n\tlet running = false;\n\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\tlet rootInputChanged = false;\n\tconst changedPaths = new Set<string>();\n\tconst watchers: FSWatcher[] = [];\n\tconst debounceMs = options.debounceMs ?? NATIVE_CHANGE_DEBOUNCE_MS;\n\n\tconst close = () => {\n\t\tif (closed) return;\n\t\tclosed = true;\n\t\tif (timer) clearTimeout(timer);\n\t\twatchers.forEach((watcher) => watcher.close());\n\t\toptions.signal?.removeEventListener('abort', close);\n\t};\n\tconst schedule = () => {\n\t\tif (closed || running) return;\n\t\tif (timer) clearTimeout(timer);\n\t\ttimer = setTimeout(() => void flush(), debounceMs);\n\t};\n\tconst flush = async () => {\n\t\ttimer = undefined;\n\t\tif (closed || running || changedPaths.size === 0) return;\n\t\trunning = true;\n\t\tconst paths = [...changedPaths].sort();\n\t\tconst forced = rootInputChanged;\n\t\tchangedPaths.clear();\n\t\trootInputChanged = false;\n\t\ttry {\n\t\t\tconst next = await fingerprintAbsoluteIosDevProject(\n\t\t\t\toptions.project\n\t\t\t);\n\t\t\tif (!forced && next === fingerprint) return;\n\t\t\tawait options.onChange({\n\t\t\t\tafterFingerprint: next,\n\t\t\t\tbeforeFingerprint: fingerprint,\n\t\t\t\tpaths,\n\t\t\t\trootInputChanged: forced\n\t\t\t});\n\t\t\tfingerprint = await fingerprintAbsoluteIosDevProject(\n\t\t\t\toptions.project\n\t\t\t);\n\t\t} catch (error) {\n\t\t\toptions.onError?.(error);\n\t\t} finally {\n\t\t\trunning = false;\n\t\t\tif (changedPaths.size > 0) schedule();\n\t\t}\n\t};\n\tconst record = (path: string, force: boolean) => {\n\t\tif (closed) return;\n\t\tchangedPaths.add(path);\n\t\trootInputChanged ||= force;\n\t\tschedule();\n\t};\n\n\twatchers.push(\n\t\twatch(\n\t\t\toptions.project.nativeDirectory,\n\t\t\t{ recursive: true },\n\t\t\t(_event, filename) => {\n\t\t\t\tif (filename) record(String(filename), false);\n\t\t\t}\n\t\t)\n\t);\n\twatchers.push(\n\t\twatch(options.project.projectRoot, (_event, filename) => {\n\t\t\tif (!filename) return;\n\t\t\tconst path = String(filename);\n\t\t\tif (isAbsoluteIosNativeRootInput(path)) record(path, true);\n\t\t})\n\t);\n\twatchers.forEach((watcher) =>\n\t\twatcher.on('error', (error) => options.onError?.(error))\n\t);\n\toptions.signal?.addEventListener('abort', close, { once: true });\n\n\treturn { close };\n};\nexport const isAbsoluteIosNativeRootInput = (path: string) =>\n\tROOT_NATIVE_INPUTS.has(basename(path));\n",
|
|
20
|
-
"/* eslint-disable @typescript-eslint/consistent-type-assertions, absolute/max-depth-extended, no-await-in-loop -- This module validates persisted/remote input and consumes protocol streams sequentially. */\nimport { createHash, randomUUID } from 'node:crypto';\nimport { chmod, mkdir, readFile, rename, writeFile } from 'node:fs/promises';\nimport { homedir } from 'node:os';\nimport {\n\tdirname,\n\tisAbsolute,\n\tjoin,\n\tposix,\n\trelative,\n\tresolve as resolvePath,\n\tsep\n} from 'node:path';\nimport type { MobileConfig } from '../../types/build';\nimport type { FileSink } from 'bun';\nimport type { NormalizedAbsoluteMobileConfig } from './config';\nimport type {\n\tAbsoluteIosDevPhaseTiming,\n\tAbsoluteIosDevSession,\n\tAbsoluteIosDevState,\n\tAbsoluteIosNativeLogEntry\n} from './iosSimulatorController';\nimport {\n\tABSOLUTE_REMOTE_MAC_EVENT_PREFIX,\n\tABSOLUTE_REMOTE_MAC_PROTOCOL_VERSION\n} from './remoteMacWire';\nexport {\n\tABSOLUTE_REMOTE_MAC_EVENT_PREFIX,\n\tABSOLUTE_REMOTE_MAC_PROTOCOL_VERSION\n} from './remoteMacWire';\n\nconst PROFILE_FORMAT = 1;\nconst PROFILE_NAME = /^[a-z0-9](?:[a-z0-9._-]{0,62}[a-z0-9])?$/u;\nconst SSH_DESTINATION = /^(?:[A-Za-z0-9._-]+@)?[A-Za-z0-9._:-]+$/u;\n\nexport type AbsoluteRemoteMacProfile = {\n\tbunPath: string;\n\tcreatedAt: string;\n\tdestination: string;\n\tname: string;\n\tport?: number;\n\tworkspaceRoot: string;\n\txcodeVersion: string;\n};\n\ntype ProfileStore = {\n\tdefaultProfile?: string;\n\tformat: number;\n\tprofiles: Record<string, AbsoluteRemoteMacProfile>;\n};\n\nexport type AbsoluteRemoteMacInspection = {\n\tbunPath: string;\n\thome: string;\n\tos: string;\n\txcodeVersion: string;\n};\n\nexport type AbsoluteRemoteIosDevProject = {\n\tcap: string;\n\tconfig: NormalizedAbsoluteMobileConfig;\n\tnativeDirectory: string;\n\tprojectRoot: string;\n\tprofile: AbsoluteRemoteMacProfile;\n\tremoteProjectRoot: string;\n\tremote: true;\n\txcodebuild: string;\n\txcrun: string;\n};\n\nexport type AbsoluteIosDevelopmentProject =\n\t| AbsoluteRemoteIosDevProject\n\t| (import('./iosSimulatorController').AbsoluteIosDevProject & {\n\t\t\tremote?: false;\n\t });\n\nexport type AbsoluteRemoteMacCommandResult = {\n\texitCode: number;\n\tstderr: string;\n\tstdout: string;\n};\n\nexport type AbsoluteRemoteMacTransport = {\n\tcapture: (command: string[]) => Promise<AbsoluteRemoteMacCommandResult>;\n\tspawn: (\n\t\tcommand: string[],\n\t\toptions: { signal?: AbortSignal }\n\t) => {\n\t\texited: Promise<number>;\n\t\tkill: () => void;\n\t\tstderr: ReadableStream<Uint8Array>;\n\t\tstdin: FileSink;\n\t\tstdout: ReadableStream<Uint8Array>;\n\t};\n};\n\nexport type AbsoluteRemoteIosOptions = {\n\thttps?: boolean;\n\tlog?: (message: string) => void;\n\tnativeLog?: (entry: AbsoluteIosNativeLogEntry) => void;\n\tonPhaseTiming?: (timing: AbsoluteIosDevPhaseTiming) => void;\n\tonStateChange?: (state: AbsoluteIosDevState) => void;\n\tport: number;\n\tproject: AbsoluteRemoteIosDevProject;\n\tsignal?: AbortSignal;\n\tinstallAgent?: (\n\t\tproject: AbsoluteRemoteIosDevProject\n\t) => Promise<{ remotePath: string; uploaded?: boolean }>;\n\tsyncProject?: (project: AbsoluteRemoteIosDevProject) => Promise<void>;\n\ttransport?: AbsoluteRemoteMacTransport;\n};\n\ntype RemoteEvent =\n\t| { entry: AbsoluteIosNativeLogEntry; type: 'native-log'; v: 1 }\n\t| { error: string; type: 'fatal'; v: 1 }\n\t| { message: string; type: 'log'; v: 1 }\n\t| { state: AbsoluteIosDevState; type: 'state'; v: 1 }\n\t| ({ type: 'timing'; v: 1 } & AbsoluteIosDevPhaseTiming)\n\t| {\n\t\t\tid: string;\n\t\t\tok: boolean;\n\t\t\tresult?: unknown;\n\t\t\terror?: string;\n\t\t\ttype: 'response';\n\t\t\tv: 1;\n\t }\n\t| {\n\t\t\tnativeCacheHit: boolean;\n\t\t\tstartedSimulator: boolean;\n\t\t\ttimings: Record<string, number>;\n\t\t\ttype: 'ready';\n\t\t\tudid: string;\n\t\t\tv: 1;\n\t };\n\nconst defaultProfilePath = () =>\n\tjoin(homedir(), '.absolutejs', 'mobile', 'remote-macs.json');\n\nconst emptyStore = (): ProfileStore => ({\n\tformat: PROFILE_FORMAT,\n\tprofiles: {}\n});\n\nconst loadStore = async (path = defaultProfilePath()) => {\n\ttry {\n\t\tconst parsed = JSON.parse(await readFile(path, 'utf8')) as ProfileStore;\n\t\tif (\n\t\t\tparsed.format !== PROFILE_FORMAT ||\n\t\t\ttypeof parsed.profiles !== 'object' ||\n\t\t\tparsed.profiles === null ||\n\t\t\tArray.isArray(parsed.profiles)\n\t\t)\n\t\t\tthrow new Error('Unsupported remote Mac profile format.');\n\t\tfor (const [key, profile] of Object.entries(parsed.profiles)) {\n\t\t\tif (\n\t\t\t\ttypeof profile !== 'object' ||\n\t\t\t\tprofile === null ||\n\t\t\t\tvalidateAbsoluteRemoteMacProfileName(key) !== key ||\n\t\t\t\tprofile.name !== key ||\n\t\t\t\tvalidateAbsoluteSshDestination(profile.destination) !==\n\t\t\t\t\tprofile.destination ||\n\t\t\t\tvalidatePort(profile.port) !== profile.port ||\n\t\t\t\ttypeof profile.createdAt !== 'string' ||\n\t\t\t\t!profile.createdAt ||\n\t\t\t\ttypeof profile.bunPath !== 'string' ||\n\t\t\t\t!profile.bunPath.startsWith('/') ||\n\t\t\t\t/[\\r\\n\\0]/u.test(profile.bunPath) ||\n\t\t\t\ttypeof profile.workspaceRoot !== 'string' ||\n\t\t\t\t!profile.workspaceRoot.startsWith('/') ||\n\t\t\t\tprofile.workspaceRoot === '/' ||\n\t\t\t\t/[\\r\\n\\0]/u.test(profile.workspaceRoot) ||\n\t\t\t\ttypeof profile.xcodeVersion !== 'string' ||\n\t\t\t\t!profile.xcodeVersion.startsWith('Xcode ')\n\t\t\t)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Remote Mac profile ${JSON.stringify(key)} is invalid.`\n\t\t\t\t);\n\t\t}\n\t\tif (\n\t\t\tparsed.defaultProfile !== undefined &&\n\t\t\t!parsed.profiles[parsed.defaultProfile]\n\t\t)\n\t\t\tthrow new Error('The default remote Mac profile does not exist.');\n\n\t\treturn parsed;\n\t} catch (error) {\n\t\tif ((error as NodeJS.ErrnoException).code === 'ENOENT')\n\t\t\treturn emptyStore();\n\t\tthrow error;\n\t}\n};\n\nconst saveStore = async (store: ProfileStore, path = defaultProfilePath()) => {\n\tawait mkdir(dirname(path), { recursive: true });\n\tconst temporary = `${path}.${randomUUID()}.tmp`;\n\tawait writeFile(temporary, `${JSON.stringify(store, null, 2)}\\n`, {\n\t\tmode: 0o600\n\t});\n\tawait rename(temporary, path);\n\tawait chmod(path, 0o600);\n};\n\nexport const validateAbsoluteRemoteMacProfileName = (name: string) => {\n\tconst normalized = name.trim().toLowerCase();\n\tif (!PROFILE_NAME.test(normalized))\n\t\tthrow new TypeError(\n\t\t\t'Remote Mac profile names must use 1-64 lowercase letters, digits, dots, dashes, or underscores.'\n\t\t);\n\n\treturn normalized;\n};\n\nexport const validateAbsoluteSshDestination = (destination: string) => {\n\tconst normalized = destination.trim();\n\tif (!SSH_DESTINATION.test(normalized) || normalized.startsWith('-'))\n\t\tthrow new TypeError(\n\t\t\t'Remote Mac SSH destination must be a host, SSH alias, or user@host without command-line options.'\n\t\t);\n\n\treturn normalized;\n};\n\nconst validatePort = (port: number | undefined) => {\n\tif (\n\t\tport !== undefined &&\n\t\t(!Number.isInteger(port) || port < 1 || port > 65_535)\n\t)\n\t\tthrow new TypeError('Remote Mac SSH port must be between 1 and 65535.');\n\n\treturn port;\n};\n\nconst shellQuote = (value: string) => `'${value.replaceAll(\"'\", \"'\\\\''\")}'`;\n\nexport const absoluteRemoteMacSshBase = (\n\tprofile: Pick<AbsoluteRemoteMacProfile, 'destination' | 'port'>,\n\toptions: { acceptNew?: boolean } = {}\n) => [\n\t'ssh',\n\t'-o',\n\t'BatchMode=yes',\n\t'-o',\n\t'ConnectTimeout=10',\n\t'-o',\n\t'ServerAliveInterval=15',\n\t'-o',\n\t'ServerAliveCountMax=3',\n\t'-o',\n\t`StrictHostKeyChecking=${options.acceptNew ? 'accept-new' : 'yes'}`,\n\t...(profile.port ? ['-p', String(profile.port)] : []),\n\tprofile.destination\n];\n\nconst localCapture = async (command: string[]) => {\n\tconst process = Bun.spawn(command, {\n\t\tstderr: 'pipe',\n\t\tstdin: 'ignore',\n\t\tstdout: 'pipe'\n\t});\n\tconst [exitCode, stdout, stderr] = await Promise.all([\n\t\tprocess.exited,\n\t\tnew Response(process.stdout).text(),\n\t\tnew Response(process.stderr).text()\n\t]);\n\n\treturn { exitCode, stderr, stdout };\n};\n\nconst defaultTransport: AbsoluteRemoteMacTransport = {\n\tcapture: localCapture,\n\tspawn: (command, options) =>\n\t\tBun.spawn(command, {\n\t\t\tsignal: options.signal,\n\t\t\tstderr: 'pipe',\n\t\t\tstdin: 'pipe',\n\t\t\tstdout: 'pipe'\n\t\t}) as ReturnType<AbsoluteRemoteMacTransport['spawn']>\n};\n\nconst requireRemoteSuccess = (\n\tresult: AbsoluteRemoteMacCommandResult,\n\tlabel: string\n) => {\n\tif (result.exitCode !== 0)\n\t\tthrow new Error(\n\t\t\t`${label} failed: ${(result.stderr || result.stdout).trim() || `status ${result.exitCode}`}`\n\t\t);\n\n\treturn result.stdout.trim();\n};\n\nexport const getAbsoluteRemoteMacProfile = async (\n\tname?: string,\n\tprofilePath?: string\n) => {\n\tconst store = await loadStore(profilePath);\n\tconst selected =\n\t\tname ?? process.env.ABSOLUTE_IOS_REMOTE ?? store.defaultProfile;\n\tif (!selected) return undefined;\n\tconst profile = store.profiles[selected];\n\tif (!profile)\n\t\tthrow new Error(\n\t\t\t`Remote Mac profile ${JSON.stringify(selected)} was not found.`\n\t\t);\n\n\treturn profile;\n};\nexport const inspectAbsoluteRemoteMac = async (\n\tdestination: string,\n\toptions: {\n\t\tacceptNew?: boolean;\n\t\tport?: number;\n\t\ttransport?: Pick<AbsoluteRemoteMacTransport, 'capture'>;\n\t} = {}\n) => {\n\tconst profile: Pick<AbsoluteRemoteMacProfile, 'destination' | 'port'> = {\n\t\tdestination: validateAbsoluteSshDestination(destination),\n\t\tport: validatePort(options.port)\n\t};\n\tconst capture = options.transport?.capture ?? defaultTransport.capture;\n\tconst command = [\n\t\t...absoluteRemoteMacSshBase(profile, {\n\t\t\tacceptNew: options.acceptNew === true\n\t\t}),\n\t\t'/bin/sh -lc',\n\t\tshellQuote(\n\t\t\t`bun_path=\"$(command -v bun || true)\"; if [ -z \"$bun_path\" ] && [ -x \"$HOME/.bun/bin/bun\" ]; then bun_path=\"$HOME/.bun/bin/bun\"; fi; printf '%s\\\\n' \"$(uname -s)\" \"$HOME\" \"$bun_path\" \"$(/usr/bin/xcodebuild -version 2>/dev/null | tr '\\\\n' ' ' || true)\"`\n\t\t)\n\t];\n\tconst lines = requireRemoteSuccess(\n\t\tawait capture(command),\n\t\t'Remote Mac handshake'\n\t).split(/\\r?\\n/u);\n\tconst [operatingSystem, home, bunPath, xcodeVersion] = lines;\n\tif (operatingSystem !== 'Darwin')\n\t\tthrow new Error('The SSH target is not a Mac.');\n\tif (!home?.startsWith('/') || !bunPath?.startsWith('/'))\n\t\tthrow new Error(\n\t\t\t'The remote Mac must have Bun installed and available to SSH.'\n\t\t);\n\tif (!xcodeVersion?.startsWith('Xcode '))\n\t\tthrow new Error(\n\t\t\t'The remote Mac must have full Xcode installed and selected.'\n\t\t);\n\n\treturn { bunPath, home, os: operatingSystem, xcodeVersion };\n};\nexport const listAbsoluteRemoteMacProfiles = async (profilePath?: string) => {\n\tconst store = await loadStore(profilePath);\n\n\treturn {\n\t\tdefaultProfile: store.defaultProfile,\n\t\tprofiles: Object.values(store.profiles).sort((left, right) =>\n\t\t\tleft.name.localeCompare(right.name)\n\t\t)\n\t};\n};\nexport const pairAbsoluteRemoteMac = async (options: {\n\tdestination: string;\n\tname: string;\n\tport?: number;\n\tprofilePath?: string;\n\ttransport?: Pick<AbsoluteRemoteMacTransport, 'capture'>;\n\tworkspaceRoot?: string;\n}) => {\n\tconst name = validateAbsoluteRemoteMacProfileName(options.name);\n\tconst destination = validateAbsoluteSshDestination(options.destination);\n\tconst port = validatePort(options.port);\n\tconst inspection = await inspectAbsoluteRemoteMac(destination, {\n\t\tacceptNew: true,\n\t\tport,\n\t\ttransport: options.transport\n\t});\n\tconst workspaceRoot = options.workspaceRoot\n\t\t? options.workspaceRoot.trim()\n\t\t: posix.join(inspection.home, '.absolutejs', 'remote-ios');\n\tif (\n\t\t!workspaceRoot.startsWith('/') ||\n\t\tworkspaceRoot === '/' ||\n\t\t/[\\r\\n\\0]/u.test(workspaceRoot)\n\t)\n\t\tthrow new TypeError(\n\t\t\t'Remote Mac workspace must be an absolute macOS path.'\n\t\t);\n\tconst profile: AbsoluteRemoteMacProfile = {\n\t\tbunPath: inspection.bunPath,\n\t\tcreatedAt: new Date().toISOString(),\n\t\tdestination,\n\t\tname,\n\t\t...(port ? { port } : {}),\n\t\tworkspaceRoot,\n\t\txcodeVersion: inspection.xcodeVersion\n\t};\n\tconst store = await loadStore(options.profilePath);\n\tstore.profiles[name] = profile;\n\tstore.defaultProfile = name;\n\tawait saveStore(store, options.profilePath);\n\n\treturn profile;\n};\nexport const removeAbsoluteRemoteMacProfile = async (\n\tname: string,\n\tprofilePath?: string\n) => {\n\tconst normalized = validateAbsoluteRemoteMacProfileName(name);\n\tconst store = await loadStore(profilePath);\n\tif (!store.profiles[normalized]) return false;\n\tdelete store.profiles[normalized];\n\tif (store.defaultProfile === normalized) {\n\t\tconst [nextDefault] = Object.keys(store.profiles).sort();\n\t\tstore.defaultProfile = nextDefault;\n\t}\n\tawait saveStore(store, profilePath);\n\n\treturn true;\n};\n\nconst projectIdentity = (projectRoot: string, appId: string) =>\n\tcreateHash('sha256')\n\t\t.update(`${resolvePath(projectRoot)}\\0${appId}`)\n\t\t.digest('hex')\n\t\t.slice(0, 20);\n\nexport const createAbsoluteRemoteIosDevProject = (\n\tconfig: NormalizedAbsoluteMobileConfig,\n\tprojectRoot: string,\n\tprofile: AbsoluteRemoteMacProfile\n): AbsoluteRemoteIosDevProject => ({\n\tcap: join(resolvePath(projectRoot), 'node_modules', '.bin', 'cap'),\n\tconfig,\n\tnativeDirectory: join(config.nativeProjectDirectory, 'ios'),\n\tprofile,\n\tprojectRoot: resolvePath(projectRoot),\n\tremote: true,\n\tremoteProjectRoot: posix.join(\n\t\tprofile.workspaceRoot,\n\t\t'projects',\n\t\tprojectIdentity(projectRoot, config.appId),\n\t\t'current'\n\t),\n\txcodebuild: 'remote:xcodebuild',\n\txcrun: 'remote:xcrun'\n});\nexport const installAbsoluteRemoteMacAgent = async (\n\tproject: AbsoluteRemoteIosDevProject\n) => {\n\tconst artifact = await materializeAbsoluteRemoteMacAgent(\n\t\tproject.projectRoot\n\t);\n\tconst directory = posix.join(\n\t\tproject.profile.workspaceRoot,\n\t\t'agents',\n\t\t`protocol-${ABSOLUTE_REMOTE_MAC_PROTOCOL_VERSION}`,\n\t\tartifact.sha256\n\t);\n\tconst remotePath = posix.join(directory, 'agent.js');\n\tconst verifyScript =\n\t\t`test -f ${shellQuote(remotePath)} && ` +\n\t\t`test \"$(shasum -a 256 ${shellQuote(remotePath)} | awk '{print $1}')\" = ${shellQuote(artifact.sha256)}`;\n\tconst verified = await defaultTransport.capture([\n\t\t...absoluteRemoteMacSshBase(project.profile),\n\t\t'/bin/sh -lc',\n\t\tshellQuote(verifyScript)\n\t]);\n\tif (verified.exitCode === 0)\n\t\treturn { ...artifact, remotePath, uploaded: false };\n\tconst temporary = posix.join(directory, `.agent-${randomUUID()}.tmp`);\n\tconst installScript = [\n\t\t'set -eu',\n\t\t'umask 077',\n\t\t`mkdir -p ${shellQuote(directory)}`,\n\t\t`cat > ${shellQuote(temporary)}`,\n\t\t`test \"$(shasum -a 256 ${shellQuote(temporary)} | awk '{print $1}')\" = ${shellQuote(artifact.sha256)}`,\n\t\t`chmod 600 ${shellQuote(temporary)}`,\n\t\t`mv ${shellQuote(temporary)} ${shellQuote(remotePath)}`\n\t].join('; ');\n\tconst upload = Bun.spawn(\n\t\t[\n\t\t\t...absoluteRemoteMacSshBase(project.profile),\n\t\t\t'/bin/sh -lc',\n\t\t\tshellQuote(installScript)\n\t\t],\n\t\t{\n\t\t\tstderr: 'pipe',\n\t\t\tstdin: Bun.file(artifact.path),\n\t\t\tstdout: 'pipe'\n\t\t}\n\t);\n\tconst [exitCode, stderr] = await Promise.all([\n\t\tupload.exited,\n\t\tnew Response(upload.stderr).text()\n\t]);\n\tif (exitCode !== 0)\n\t\tthrow new Error(\n\t\t\t`Remote Mac agent installation failed: ${stderr.trim() || `status ${exitCode}`}`\n\t\t);\n\n\treturn { ...artifact, remotePath, uploaded: true };\n};\nexport const materializeAbsoluteRemoteMacAgent = async (\n\tprojectRoot: string\n) => {\n\tconst shippedCandidates = [\n\t\tjoin(import.meta.dir, 'remoteMacAgentEntry.js'),\n\t\tjoin(import.meta.dir, '..', 'mobile', 'remoteMacAgentEntry.js')\n\t];\n\tlet path: string | undefined;\n\tfor (const candidate of shippedCandidates) {\n\t\tif (await Bun.file(candidate).exists()) {\n\t\t\tpath = candidate;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (!path) {\n\t\tconst sourceCandidates = [\n\t\t\tjoin(import.meta.dir, 'remoteMacAgentEntry.ts'),\n\t\t\tjoin(\n\t\t\t\timport.meta.dir,\n\t\t\t\t'..',\n\t\t\t\t'..',\n\t\t\t\t'src',\n\t\t\t\t'mobile',\n\t\t\t\t'remoteMacAgentEntry.ts'\n\t\t\t)\n\t\t];\n\t\tconst source = await sourceCandidates.reduce<\n\t\t\tPromise<string | undefined>\n\t\t>(\n\t\t\tasync (found, candidate) =>\n\t\t\t\t(await found) ??\n\t\t\t\t((await Bun.file(candidate).exists()) ? candidate : undefined),\n\t\t\tPromise.resolve(undefined)\n\t\t);\n\t\tif (!source)\n\t\t\tthrow new Error(\n\t\t\t\t'The AbsoluteJS installation does not contain its remote Mac agent artifact.'\n\t\t\t);\n\t\tconst outdir = join(\n\t\t\tresolvePath(projectRoot),\n\t\t\t'.absolutejs',\n\t\t\t'mobile',\n\t\t\t'remote-agent'\n\t\t);\n\t\tawait mkdir(outdir, { recursive: true });\n\t\tconst result = await Bun.build({\n\t\t\tentrypoints: [source],\n\t\t\tminify: true,\n\t\t\toutdir,\n\t\t\ttarget: 'bun'\n\t\t});\n\t\tif (!result.success)\n\t\t\tthrow new AggregateError(\n\t\t\t\tresult.logs,\n\t\t\t\t'Failed to build the AbsoluteJS remote Mac agent.'\n\t\t\t);\n\t\tpath = join(outdir, 'remoteMacAgentEntry.js');\n\t}\n\tconst bytes = await Bun.file(path).arrayBuffer();\n\tconst sha256 = createHash('sha256')\n\t\t.update(new Uint8Array(bytes))\n\t\t.digest('hex');\n\n\treturn { bytes: bytes.byteLength, path, sha256 };\n};\n\nconst portableRelativePath = (root: string, path: string) =>\n\trelative(root, path).split(sep).join(posix.sep);\n\nconst portableMobileConfig = (\n\tproject: AbsoluteRemoteIosDevProject\n): MobileConfig => ({\n\tappId: project.config.appId,\n\tappName: project.config.appName,\n\tbundleDirectory: portableRelativePath(\n\t\tproject.projectRoot,\n\t\tproject.config.bundleDirectory\n\t),\n\t...(project.config.deepLinkScheme ||\n\tproject.config.deepLinkHosts.length > 1 ||\n\tproject.config.appleAppIdPrefix\n\t\t? {\n\t\t\t\tdeepLinks: {\n\t\t\t\t\t...(project.config.deepLinkScheme\n\t\t\t\t\t\t? { scheme: project.config.deepLinkScheme }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\thosts: project.config.deepLinkHosts,\n\t\t\t\t\t...(project.config.appleAppIdPrefix\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tapple: {\n\t\t\t\t\t\t\t\t\tappIdPrefix: project.config.appleAppIdPrefix\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: {})\n\t\t\t\t}\n\t\t\t}\n\t\t: {}),\n\tentry: project.config.entry,\n\t...(project.config.iosVersion\n\t\t? { ios: { version: project.config.iosVersion } }\n\t\t: {}),\n\tnativeProject: {\n\t\tdirectory: portableRelativePath(\n\t\t\tproject.projectRoot,\n\t\t\tproject.config.nativeProjectDirectory\n\t\t),\n\t\tmode: 'source'\n\t},\n\tplatforms: ['ios'],\n\tserver: { productionOrigin: project.config.productionOrigin }\n});\n\nexport const absoluteRemoteProjectSyncCommands = (\n\tproject: AbsoluteRemoteIosDevProject\n) => {\n\tconst current = project.remoteProjectRoot;\n\tconst parent = posix.dirname(current);\n\tconst staging = posix.join(parent, `.incoming-${randomUUID()}`);\n\tconst previous = posix.join(parent, '.previous');\n\tconst script = [\n\t\t'set -eu',\n\t\t`mkdir -p ${shellQuote(staging)}`,\n\t\t`tar -xf - -C ${shellQuote(staging)}`,\n\t\t`if [ -d ${shellQuote(posix.join(current, 'node_modules'))} ]; then mv ${shellQuote(posix.join(current, 'node_modules'))} ${shellQuote(posix.join(staging, 'node_modules'))}; fi`,\n\t\t`if [ -d ${shellQuote(posix.join(current, '.absolutejs'))} ]; then mv ${shellQuote(posix.join(current, '.absolutejs'))} ${shellQuote(posix.join(staging, '.absolutejs'))}; fi`,\n\t\t`rm -rf ${shellQuote(previous)}`,\n\t\t`if [ -d ${shellQuote(current)} ]; then mv ${shellQuote(current)} ${shellQuote(previous)}; fi`,\n\t\t`mv ${shellQuote(staging)} ${shellQuote(current)}`,\n\t\t`rm -rf ${shellQuote(previous)}`\n\t].join('; ');\n\n\treturn {\n\t\tremote: [\n\t\t\t...absoluteRemoteMacSshBase(project.profile),\n\t\t\t'/bin/sh -lc',\n\t\t\tshellQuote(script)\n\t\t],\n\t\ttar: [\n\t\t\t'tar',\n\t\t\t'--exclude=.git',\n\t\t\t'--exclude=node_modules',\n\t\t\t'--exclude=build',\n\t\t\t'--exclude=.absolutejs',\n\t\t\t'-cf',\n\t\t\t'-',\n\t\t\t'-C',\n\t\t\tproject.projectRoot,\n\t\t\t'.'\n\t\t]\n\t};\n};\n\nexport const syncAbsoluteRemoteMacProject = async (\n\tproject: AbsoluteRemoteIosDevProject\n) => {\n\tconst commands = absoluteRemoteProjectSyncCommands(project);\n\tconst archive = Bun.spawn(commands.tar, {\n\t\tstderr: 'pipe',\n\t\tstdout: 'pipe'\n\t});\n\tconst upload = Bun.spawn(commands.remote, {\n\t\tstderr: 'pipe',\n\t\tstdin: archive.stdout,\n\t\tstdout: 'pipe'\n\t});\n\tconst [archiveExit, uploadExit, archiveError, uploadError] =\n\t\tawait Promise.all([\n\t\t\tarchive.exited,\n\t\t\tupload.exited,\n\t\t\tnew Response(archive.stderr).text(),\n\t\t\tnew Response(upload.stderr).text()\n\t\t]);\n\tif (archiveExit !== 0 || uploadExit !== 0)\n\t\tthrow new Error(\n\t\t\t`Remote Mac project synchronization failed: ${(archiveError || uploadError).trim()}`\n\t\t);\n\tconst install = await defaultTransport.capture([\n\t\t...absoluteRemoteMacSshBase(project.profile),\n\t\t'/bin/sh -lc',\n\t\tshellQuote(\n\t\t\t`cd ${shellQuote(project.remoteProjectRoot)} && ${shellQuote(project.profile.bunPath)} install --frozen-lockfile`\n\t\t)\n\t]);\n\trequireRemoteSuccess(install, 'Remote Mac dependency installation');\n};\n\nconst consumeLines = async (\n\tstream: ReadableStream<Uint8Array>,\n\tonLine: (line: string) => void\n) => {\n\tconst reader = stream.getReader();\n\tconst decoder = new TextDecoder();\n\tlet buffered = '';\n\ttry {\n\t\twhile (true) {\n\t\t\tconst { done, value } = await reader.read();\n\t\t\tif (done) break;\n\t\t\tbuffered += decoder.decode(value, { stream: true });\n\t\t\tconst lines = buffered.split(/\\r?\\n/u);\n\t\t\tbuffered = lines.pop() ?? '';\n\t\t\tlines.forEach(onLine);\n\t\t}\n\t\tbuffered += decoder.decode();\n\t\tif (buffered) onLine(buffered);\n\t} finally {\n\t\treader.releaseLock();\n\t}\n};\n\nexport const startAbsoluteRemoteIosDevSession = async (\n\toptions: AbsoluteRemoteIosOptions\n) => {\n\tconst startedAt = performance.now();\n\tconst transport = options.transport ?? defaultTransport;\n\tconst installAgent = options.installAgent ?? installAbsoluteRemoteMacAgent;\n\tconst syncProject = options.syncProject ?? syncAbsoluteRemoteMacProject;\n\tconst agentStartedAt = performance.now();\n\tconst agent = await installAgent(options.project);\n\tconst agentDuration = performance.now() - agentStartedAt;\n\tconst syncStartedAt = performance.now();\n\tawait syncProject(options.project);\n\tconst syncDuration = performance.now() - syncStartedAt;\n\tconst encodedConfig = Buffer.from(\n\t\tJSON.stringify(portableMobileConfig(options.project))\n\t).toString('base64url');\n\tconst remoteCommand = [\n\t\t`cd ${shellQuote(options.project.remoteProjectRoot)}`,\n\t\t'&&',\n\t\t'exec',\n\t\tshellQuote(options.project.profile.bunPath),\n\t\tshellQuote(agent.remotePath),\n\t\t'--port',\n\t\tString(options.port),\n\t\t'--mobile-config',\n\t\tshellQuote(encodedConfig),\n\t\t...(options.https ? ['--https'] : [])\n\t].join(' ');\n\tconst command = [\n\t\t...absoluteRemoteMacSshBase(options.project.profile),\n\t\t'-o',\n\t\t'ExitOnForwardFailure=yes',\n\t\t'-R',\n\t\t`${options.port}:127.0.0.1:${options.port}`,\n\t\t'/bin/sh -lc',\n\t\tshellQuote(remoteCommand)\n\t];\n\tconst connectStartedAt = performance.now();\n\tconst process = transport.spawn(command, { signal: options.signal });\n\tlet state: AbsoluteIosDevState = 'syncing';\n\tlet ready: Extract<RemoteEvent, { type: 'ready' }> | undefined;\n\tlet fatal: Error | undefined;\n\tconst pending = new Map<\n\t\tstring,\n\t\t{ reject: (error: Error) => void; resolve: (value: unknown) => void }\n\t>();\n\tlet resolveReady!: () => void;\n\tlet rejectReady!: (error: Error) => void;\n\tconst readyPromise = new Promise<void>((resolve, reject) => {\n\t\tresolveReady = resolve;\n\t\trejectReady = reject;\n\t});\n\tconst handleEvent = (event: RemoteEvent) => {\n\t\tif (event.v !== ABSOLUTE_REMOTE_MAC_PROTOCOL_VERSION) {\n\t\t\trejectReady(new Error('Remote Mac protocol version mismatch.'));\n\n\t\t\treturn;\n\t\t}\n\t\tif (event.type === 'log') options.log?.(event.message);\n\t\tif (event.type === 'native-log') options.nativeLog?.(event.entry);\n\t\tif (event.type === 'state') {\n\t\t\t({ state } = event);\n\t\t\toptions.onStateChange?.(state);\n\t\t}\n\t\tif (event.type === 'timing') options.onPhaseTiming?.(event);\n\t\tif (event.type === 'ready') {\n\t\t\tready = event;\n\t\t\tresolveReady();\n\t\t}\n\t\tif (event.type === 'fatal') {\n\t\t\tfatal = new Error(event.error);\n\t\t\trejectReady(fatal);\n\t\t}\n\t\tif (event.type === 'response') {\n\t\t\tconst request = pending.get(event.id);\n\t\t\tif (!request) return;\n\t\t\tpending.delete(event.id);\n\t\t\tif (event.ok) request.resolve(event.result);\n\t\t\telse\n\t\t\t\trequest.reject(\n\t\t\t\t\tnew Error(event.error ?? 'Remote command failed.')\n\t\t\t\t);\n\t\t}\n\t};\n\tconst stdoutDone = consumeLines(process.stdout, (line) => {\n\t\tif (!line.startsWith(ABSOLUTE_REMOTE_MAC_EVENT_PREFIX)) return;\n\t\ttry {\n\t\t\thandleEvent(\n\t\t\t\tJSON.parse(\n\t\t\t\t\tline.slice(ABSOLUTE_REMOTE_MAC_EVENT_PREFIX.length)\n\t\t\t\t) as RemoteEvent\n\t\t\t);\n\t\t} catch {\n\t\t\toptions.log?.(`Remote Mac emitted an invalid protocol event.`);\n\t\t}\n\t}).catch((error: unknown) => {\n\t\tfatal =\n\t\t\terror instanceof Error\n\t\t\t\t? error\n\t\t\t\t: new Error('Failed to read the remote Mac protocol stream.');\n\t\trejectReady(fatal);\n\t});\n\tconst stderrDone = consumeLines(process.stderr, (line) =>\n\t\toptions.log?.(`[remote] ${line}`)\n\t).catch((error: unknown) =>\n\t\toptions.log?.(\n\t\t\t`[remote] ${error instanceof Error ? error.message : 'Failed to read SSH stderr.'}`\n\t\t)\n\t);\n\tvoid process.exited.then(async (exitCode) => {\n\t\tawait Promise.all([stdoutDone, stderrDone]);\n\t\tconst error =\n\t\t\tfatal ??\n\t\t\tnew Error(`Remote Mac connection closed with status ${exitCode}.`);\n\t\tif (!ready) rejectReady(error);\n\t\tpending.forEach(({ reject }) => reject(error));\n\t\tpending.clear();\n\n\t\treturn undefined;\n\t});\n\tawait readyPromise;\n\tif (!ready) throw fatal ?? new Error('Remote Mac did not become ready.');\n\tconst totalDuration = performance.now() - startedAt;\n\tlet currentReady: Extract<RemoteEvent, { type: 'ready' }> = {\n\t\t...ready,\n\t\ttimings: {\n\t\t\t...ready.timings,\n\t\t\t'remote-agent': agentDuration,\n\t\t\t'remote-connect': performance.now() - connectStartedAt,\n\t\t\t'remote-sync': syncDuration,\n\t\t\ttotal: totalDuration\n\t\t}\n\t};\n\toptions.log?.(\n\t\t`Remote Mac connected (${options.project.profile.name}); agent ${agent.uploaded ? 'uploaded' : 'cache hit'}, project synced, and iOS ready in ${totalDuration.toFixed(2)}ms.`\n\t);\n\n\tconst request = (\n\t\tcommandName: 'close' | 'rebuild' | 'relaunch' | 'screenshot'\n\t) => {\n\t\tconst id = randomUUID();\n\t\tconst response = new Promise<unknown>((resolve, reject) =>\n\t\t\tpending.set(id, { reject, resolve })\n\t\t);\n\t\tprocess.stdin.write(\n\t\t\t`${JSON.stringify({ command: commandName, id, v: 1 })}\\n`\n\t\t);\n\t\tprocess.stdin.flush();\n\n\t\treturn response;\n\t};\n\tlet closed = false;\n\tconst close = async () => {\n\t\tif (closed) return;\n\t\tclosed = true;\n\t\tawait request('close').catch(() => undefined);\n\t\tprocess.stdin.end();\n\t\tawait process.exited.catch(() => undefined);\n\t};\n\tconst makeSession = (): AbsoluteIosDevSession => ({\n\t\tclose,\n\t\tnativeCacheHit: currentReady.nativeCacheHit,\n\t\tstartedSimulator: currentReady.startedSimulator,\n\t\ttimings: currentReady.timings,\n\t\tudid: currentReady.udid,\n\t\trebuild: async () => {\n\t\t\tconst rebuildStartedAt = performance.now();\n\t\t\tconst rebuildSyncStartedAt = performance.now();\n\t\t\tawait syncProject(options.project);\n\t\t\tconst rebuildSyncDuration =\n\t\t\t\tperformance.now() - rebuildSyncStartedAt;\n\t\t\tconst result = (await request('rebuild')) as Extract<\n\t\t\t\tRemoteEvent,\n\t\t\t\t{ type: 'ready' }\n\t\t\t>;\n\t\t\tcurrentReady = {\n\t\t\t\t...result,\n\t\t\t\ttimings: {\n\t\t\t\t\t...result.timings,\n\t\t\t\t\t'remote-sync': rebuildSyncDuration,\n\t\t\t\t\ttotal: performance.now() - rebuildStartedAt\n\t\t\t\t}\n\t\t\t};\n\n\t\t\treturn makeSession();\n\t\t},\n\t\trelaunch: async () => {\n\t\t\tawait request('relaunch');\n\t\t},\n\t\tscreenshot: async (destination) => {\n\t\t\tconst result = (await request('screenshot')) as { data: string };\n\t\t\tconst target = resolvePath(\n\t\t\t\toptions.project.projectRoot,\n\t\t\t\tdestination\n\t\t\t);\n\t\t\tconst targetRelative = relative(\n\t\t\t\toptions.project.projectRoot,\n\t\t\t\ttarget\n\t\t\t);\n\t\t\tif (targetRelative.startsWith('..') || isAbsolute(targetRelative))\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'iOS screenshot must remain inside the project.'\n\t\t\t\t);\n\t\t\tawait mkdir(dirname(target), { recursive: true });\n\t\t\tawait writeFile(target, Buffer.from(result.data, 'base64'));\n\n\t\t\treturn target;\n\t\t},\n\t\tget state() {\n\t\t\treturn state;\n\t\t}\n\t});\n\n\treturn makeSession();\n};\n",
|
|
21
|
-
"export const ABSOLUTE_REMOTE_MAC_EVENT_PREFIX = 'ABSOLUTE_REMOTE_MAC\\t';\nexport const ABSOLUTE_REMOTE_MAC_PROTOCOL_VERSION =
|
|
29
|
+
"/* eslint-disable @typescript-eslint/consistent-type-assertions, absolute/max-depth-extended, no-await-in-loop -- This module validates persisted/remote input and consumes protocol streams sequentially. */\nimport { createHash, randomUUID } from 'node:crypto';\nimport { chmod, mkdir, readFile, rename, writeFile } from 'node:fs/promises';\nimport { homedir } from 'node:os';\nimport { isIP } from 'node:net';\nimport {\n\tdirname,\n\tisAbsolute,\n\tjoin,\n\tposix,\n\trelative,\n\tresolve as resolvePath,\n\tsep\n} from 'node:path';\nimport type { MobileConfig } from '../../types/build';\nimport type { FileSink } from 'bun';\nimport type { NormalizedAbsoluteMobileConfig } from './config';\nimport type {\n\tAbsoluteIosDevPhaseTiming,\n\tAbsoluteIosDevSession,\n\tAbsoluteIosDevState,\n\tAbsoluteIosNativeLogEntry\n} from './iosSimulatorController';\nimport type {\n\tAbsoluteExpoDevPhaseTiming,\n\tAbsoluteExpoDevSession,\n\tAbsoluteExpoDevState\n} from './expoDevController';\nimport {\n\tABSOLUTE_REMOTE_MAC_EVENT_PREFIX,\n\tABSOLUTE_REMOTE_MAC_PROTOCOL_VERSION\n} from './remoteMacWire';\nexport {\n\tABSOLUTE_REMOTE_MAC_EVENT_PREFIX,\n\tABSOLUTE_REMOTE_MAC_PROTOCOL_VERSION\n} from './remoteMacWire';\n\nconst PROFILE_FORMAT = 1;\nconst REMOTE_STDIN_FLUSH_ATTEMPTS = 3;\nconst REMOTE_SESSION_CLOSE_TIMEOUT_MS = 2_000;\nconst PROFILE_NAME = /^[a-z0-9](?:[a-z0-9._-]{0,62}[a-z0-9])?$/u;\nconst SSH_DESTINATION = /^(?:[A-Za-z0-9._-]+@)?[A-Za-z0-9._:-]+$/u;\n\nexport type AbsoluteRemoteMacProfile = {\n\tbunPath: string;\n\tcreatedAt: string;\n\tdestination: string;\n\tname: string;\n\tport?: number;\n\tworkspaceRoot: string;\n\txcodeVersion: string;\n};\n\ntype ProfileStore = {\n\tdefaultProfile?: string;\n\tformat: number;\n\tprofiles: Record<string, AbsoluteRemoteMacProfile>;\n};\n\nexport type AbsoluteRemoteMacInspection = {\n\tbunPath: string;\n\thome: string;\n\tos: string;\n\txcodeVersion: string;\n};\n\nexport type AbsoluteRemoteIosDevProject = {\n\tcap: string;\n\tconfig: NormalizedAbsoluteMobileConfig;\n\tnativeDirectory: string;\n\tprojectRoot: string;\n\tprofile: AbsoluteRemoteMacProfile;\n\tremoteProjectRoot: string;\n\tremote: true;\n\txcodebuild: string;\n\txcrun: string;\n};\n\nexport type AbsoluteRemoteExpoIosDevProject = AbsoluteRemoteIosDevProject & {\n\tconfig: NormalizedAbsoluteMobileConfig & { engine: 'expo' };\n};\n\nexport type AbsoluteIosDevelopmentProject =\n\t| AbsoluteRemoteIosDevProject\n\t| (import('./iosSimulatorController').AbsoluteIosDevProject & {\n\t\t\tremote?: false;\n\t });\n\nexport type AbsoluteRemoteMacCommandResult = {\n\texitCode: number;\n\tstderr: string;\n\tstdout: string;\n};\n\nexport type AbsoluteRemoteMacTransport = {\n\tcapture: (command: string[]) => Promise<AbsoluteRemoteMacCommandResult>;\n\tspawn: (\n\t\tcommand: string[],\n\t\toptions: { signal?: AbortSignal }\n\t) => {\n\t\texited: Promise<number>;\n\t\tkill: () => void;\n\t\tstderr: ReadableStream<Uint8Array>;\n\t\tstdin: FileSink;\n\t\tstdout: ReadableStream<Uint8Array>;\n\t};\n};\n\nexport type AbsoluteRemoteIosOptions = {\n\tcertificateAuthorityPath?: string;\n\thttps?: boolean;\n\tdeviceIdentifier?: string;\n\tlog?: (message: string) => void;\n\tnativeLog?: (entry: AbsoluteIosNativeLogEntry) => void;\n\tonPhaseTiming?: (timing: AbsoluteIosDevPhaseTiming) => void;\n\tonStateChange?: (state: AbsoluteIosDevState) => void;\n\tport: number;\n\tproject: AbsoluteRemoteIosDevProject;\n\tsignal?: AbortSignal;\n\tserverHost?: string;\n\tinstallAgent?: (\n\t\tproject: AbsoluteRemoteIosDevProject\n\t) => Promise<{ remotePath: string; uploaded?: boolean }>;\n\tsyncProject?: (project: AbsoluteRemoteIosDevProject) => Promise<void>;\n\ttransport?: AbsoluteRemoteMacTransport;\n};\n\ntype AbsoluteRemoteDevOptions = AbsoluteRemoteIosOptions & {\n\tmetroPort?: number;\n\tonExpoPhaseTiming?: (timing: AbsoluteExpoDevPhaseTiming) => void;\n\tonExpoStateChange?: (state: AbsoluteExpoDevState) => void;\n};\n\nexport type AbsoluteRemoteExpoIosOptions = {\n\tcertificateAuthorityPath?: string;\n\tdeviceIdentifier?: string;\n\thttps?: boolean;\n\tlog?: (message: string) => void;\n\tmetroPort: number;\n\tonPhaseTiming?: (timing: AbsoluteExpoDevPhaseTiming) => void;\n\tonStateChange?: (state: AbsoluteExpoDevState) => void;\n\tport: number;\n\tproject: AbsoluteRemoteExpoIosDevProject;\n\tserverHost?: string;\n\tsignal?: AbortSignal;\n\tinstallAgent?: (\n\t\tproject: AbsoluteRemoteIosDevProject\n\t) => Promise<{ remotePath: string; uploaded?: boolean }>;\n\tsyncProject?: (project: AbsoluteRemoteIosDevProject) => Promise<void>;\n\ttransport?: AbsoluteRemoteMacTransport;\n};\n\ntype RemoteEvent =\n\t| { entry: AbsoluteIosNativeLogEntry; type: 'native-log'; v: number }\n\t| { error: string; type: 'fatal'; v: number }\n\t| { message: string; type: 'log'; v: number }\n\t| {\n\t\t\tstate: AbsoluteIosDevState | AbsoluteExpoDevState;\n\t\t\ttype: 'state';\n\t\t\tv: number;\n\t }\n\t| ({ type: 'timing'; v: number } & (\n\t\t\t| AbsoluteIosDevPhaseTiming\n\t\t\t| AbsoluteExpoDevPhaseTiming\n\t ))\n\t| {\n\t\t\tid: string;\n\t\t\tok: boolean;\n\t\t\tresult?: unknown;\n\t\t\terror?: string;\n\t\t\ttype: 'response';\n\t\t\tv: number;\n\t }\n\t| {\n\t\t\tengine: 'capacitor' | 'expo';\n\t\t\tnativeCacheHit: boolean;\n\t\t\tstartedSimulator: boolean;\n\t\t\ttargetKind: 'device' | 'simulator';\n\t\t\ttimings: Record<string, number>;\n\t\t\ttype: 'ready';\n\t\t\tudid: string;\n\t\t\tv: number;\n\t };\n\nconst defaultProfilePath = () =>\n\tjoin(homedir(), '.absolutejs', 'mobile', 'remote-macs.json');\n\nconst emptyStore = (): ProfileStore => ({\n\tformat: PROFILE_FORMAT,\n\tprofiles: {}\n});\n\nconst loadStore = async (path = defaultProfilePath()) => {\n\ttry {\n\t\tconst parsed = JSON.parse(await readFile(path, 'utf8')) as ProfileStore;\n\t\tif (\n\t\t\tparsed.format !== PROFILE_FORMAT ||\n\t\t\ttypeof parsed.profiles !== 'object' ||\n\t\t\tparsed.profiles === null ||\n\t\t\tArray.isArray(parsed.profiles)\n\t\t)\n\t\t\tthrow new Error('Unsupported remote Mac profile format.');\n\t\tfor (const [key, profile] of Object.entries(parsed.profiles)) {\n\t\t\tif (\n\t\t\t\ttypeof profile !== 'object' ||\n\t\t\t\tprofile === null ||\n\t\t\t\tvalidateAbsoluteRemoteMacProfileName(key) !== key ||\n\t\t\t\tprofile.name !== key ||\n\t\t\t\tvalidateAbsoluteSshDestination(profile.destination) !==\n\t\t\t\t\tprofile.destination ||\n\t\t\t\tvalidatePort(profile.port) !== profile.port ||\n\t\t\t\ttypeof profile.createdAt !== 'string' ||\n\t\t\t\t!profile.createdAt ||\n\t\t\t\ttypeof profile.bunPath !== 'string' ||\n\t\t\t\t!profile.bunPath.startsWith('/') ||\n\t\t\t\t/[\\r\\n\\0]/u.test(profile.bunPath) ||\n\t\t\t\ttypeof profile.workspaceRoot !== 'string' ||\n\t\t\t\t!profile.workspaceRoot.startsWith('/') ||\n\t\t\t\tprofile.workspaceRoot === '/' ||\n\t\t\t\t/[\\r\\n\\0]/u.test(profile.workspaceRoot) ||\n\t\t\t\ttypeof profile.xcodeVersion !== 'string' ||\n\t\t\t\t!profile.xcodeVersion.startsWith('Xcode ')\n\t\t\t)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Remote Mac profile ${JSON.stringify(key)} is invalid.`\n\t\t\t\t);\n\t\t}\n\t\tif (\n\t\t\tparsed.defaultProfile !== undefined &&\n\t\t\t!parsed.profiles[parsed.defaultProfile]\n\t\t)\n\t\t\tthrow new Error('The default remote Mac profile does not exist.');\n\n\t\treturn parsed;\n\t} catch (error) {\n\t\tif ((error as NodeJS.ErrnoException).code === 'ENOENT')\n\t\t\treturn emptyStore();\n\t\tthrow error;\n\t}\n};\n\nconst saveStore = async (store: ProfileStore, path = defaultProfilePath()) => {\n\tawait mkdir(dirname(path), { recursive: true });\n\tconst temporary = `${path}.${randomUUID()}.tmp`;\n\tawait writeFile(temporary, `${JSON.stringify(store, null, 2)}\\n`, {\n\t\tmode: 0o600\n\t});\n\tawait rename(temporary, path);\n\tawait chmod(path, 0o600);\n};\n\nexport const validateAbsoluteRemoteMacProfileName = (name: string) => {\n\tconst normalized = name.trim().toLowerCase();\n\tif (!PROFILE_NAME.test(normalized))\n\t\tthrow new TypeError(\n\t\t\t'Remote Mac profile names must use 1-64 lowercase letters, digits, dots, dashes, or underscores.'\n\t\t);\n\n\treturn normalized;\n};\n\nexport const validateAbsoluteSshDestination = (destination: string) => {\n\tconst normalized = destination.trim();\n\tif (!SSH_DESTINATION.test(normalized) || normalized.startsWith('-'))\n\t\tthrow new TypeError(\n\t\t\t'Remote Mac SSH destination must be a host, SSH alias, or user@host without command-line options.'\n\t\t);\n\n\treturn normalized;\n};\n\nconst validatePort = (port: number | undefined) => {\n\tif (\n\t\tport !== undefined &&\n\t\t(!Number.isInteger(port) || port < 1 || port > 65_535)\n\t)\n\t\tthrow new TypeError('Remote Mac SSH port must be between 1 and 65535.');\n\n\treturn port;\n};\n\nconst shellQuote = (value: string) => `'${value.replaceAll(\"'\", \"'\\\\''\")}'`;\n\nexport const absoluteRemoteMacSshBase = (\n\tprofile: Pick<AbsoluteRemoteMacProfile, 'destination' | 'port'>,\n\toptions: { acceptNew?: boolean } = {}\n) => [\n\t'ssh',\n\t'-o',\n\t'BatchMode=yes',\n\t'-o',\n\t'ConnectTimeout=10',\n\t'-o',\n\t'ServerAliveInterval=15',\n\t'-o',\n\t'ServerAliveCountMax=3',\n\t'-o',\n\t`StrictHostKeyChecking=${options.acceptNew ? 'accept-new' : 'yes'}`,\n\t...(profile.port ? ['-p', String(profile.port)] : []),\n\tprofile.destination\n];\n\nconst localCapture = async (command: string[]) => {\n\tconst process = Bun.spawn(command, {\n\t\tstderr: 'pipe',\n\t\tstdin: 'ignore',\n\t\tstdout: 'pipe'\n\t});\n\tconst [exitCode, stdout, stderr] = await Promise.all([\n\t\tprocess.exited,\n\t\tnew Response(process.stdout).text(),\n\t\tnew Response(process.stderr).text()\n\t]);\n\n\treturn { exitCode, stderr, stdout };\n};\n\nconst defaultTransport: AbsoluteRemoteMacTransport = {\n\tcapture: localCapture,\n\tspawn: (command, options) =>\n\t\tBun.spawn(command, {\n\t\t\tsignal: options.signal,\n\t\t\tstderr: 'pipe',\n\t\t\tstdin: 'pipe',\n\t\t\tstdout: 'pipe'\n\t\t}) as ReturnType<AbsoluteRemoteMacTransport['spawn']>\n};\n\nconst requireRemoteSuccess = (\n\tresult: AbsoluteRemoteMacCommandResult,\n\tlabel: string\n) => {\n\tif (result.exitCode !== 0)\n\t\tthrow new Error(\n\t\t\t`${label} failed: ${(result.stderr || result.stdout).trim() || `status ${result.exitCode}`}`\n\t\t);\n\n\treturn result.stdout.trim();\n};\n\n/** Run a non-interactive command on an already paired Mac.\n *\n * Arguments are quoted independently before crossing SSH. This is intended for\n * small, read-only inspections and lifecycle commands that do not need the\n * long-running remote development agent.\n */\nexport const captureAbsoluteRemoteMacCommand = async (\n\tprofile: AbsoluteRemoteMacProfile,\n\tcommand: string[],\n\ttransport?: Pick<AbsoluteRemoteMacTransport, 'capture'>\n) => {\n\tif (command.length === 0)\n\t\tthrow new TypeError('A Remote Mac command cannot be empty.');\n\tif (command.some((argument) => /[\\r\\n\\0]/u.test(argument)))\n\t\tthrow new TypeError(\n\t\t\t'Remote Mac command arguments cannot contain controls.'\n\t\t);\n\tconst capture = transport?.capture ?? defaultTransport.capture;\n\n\treturn capture([\n\t\t...absoluteRemoteMacSshBase(profile),\n\t\t'/bin/sh -lc',\n\t\tshellQuote(command.map((argument) => shellQuote(argument)).join(' '))\n\t]);\n};\n\nexport const getAbsoluteRemoteMacProfile = async (\n\tname?: string,\n\tprofilePath?: string\n) => {\n\tconst store = await loadStore(profilePath);\n\tconst selected =\n\t\tname ?? process.env.ABSOLUTE_IOS_REMOTE ?? store.defaultProfile;\n\tif (!selected) return undefined;\n\tconst profile = store.profiles[selected];\n\tif (!profile)\n\t\tthrow new Error(\n\t\t\t`Remote Mac profile ${JSON.stringify(selected)} was not found.`\n\t\t);\n\n\treturn profile;\n};\nexport const inspectAbsoluteRemoteMac = async (\n\tdestination: string,\n\toptions: {\n\t\tacceptNew?: boolean;\n\t\tport?: number;\n\t\ttransport?: Pick<AbsoluteRemoteMacTransport, 'capture'>;\n\t} = {}\n) => {\n\tconst profile: Pick<AbsoluteRemoteMacProfile, 'destination' | 'port'> = {\n\t\tdestination: validateAbsoluteSshDestination(destination),\n\t\tport: validatePort(options.port)\n\t};\n\tconst capture = options.transport?.capture ?? defaultTransport.capture;\n\tconst command = [\n\t\t...absoluteRemoteMacSshBase(profile, {\n\t\t\tacceptNew: options.acceptNew === true\n\t\t}),\n\t\t'/bin/sh -lc',\n\t\tshellQuote(\n\t\t\t`bun_path=\"$(command -v bun || true)\"; if [ -z \"$bun_path\" ] && [ -x \"$HOME/.bun/bin/bun\" ]; then bun_path=\"$HOME/.bun/bin/bun\"; fi; printf '%s\\\\n' \"$(uname -s)\" \"$HOME\" \"$bun_path\" \"$(/usr/bin/xcodebuild -version 2>/dev/null | tr '\\\\n' ' ' || true)\"`\n\t\t)\n\t];\n\tconst lines = requireRemoteSuccess(\n\t\tawait capture(command),\n\t\t'Remote Mac handshake'\n\t).split(/\\r?\\n/u);\n\tconst [operatingSystem, home, bunPath, xcodeVersion] = lines;\n\tif (operatingSystem !== 'Darwin')\n\t\tthrow new Error('The SSH target is not a Mac.');\n\tif (!home?.startsWith('/') || !bunPath?.startsWith('/'))\n\t\tthrow new Error(\n\t\t\t'The remote Mac must have Bun installed and available to SSH.'\n\t\t);\n\tif (!xcodeVersion?.startsWith('Xcode '))\n\t\tthrow new Error(\n\t\t\t'The remote Mac must have full Xcode installed and selected.'\n\t\t);\n\n\treturn { bunPath, home, os: operatingSystem, xcodeVersion };\n};\n\nexport const inspectAbsoluteRemoteMacLanHost = async (\n\tprofile: AbsoluteRemoteMacProfile,\n\ttransport?: Pick<AbsoluteRemoteMacTransport, 'capture'>\n) => {\n\tconst capture = transport?.capture ?? defaultTransport.capture;\n\tconst script =\n\t\t'default_interface=\"$(/sbin/route -n get default 2>/dev/null | /usr/bin/awk \\'/interface:/{print $2; exit}\\')\"; for interface in \"$default_interface\" en0 en1; do [ -n \"$interface\" ] || continue; address=\"$(/usr/sbin/ipconfig getifaddr \"$interface\" 2>/dev/null || true)\"; if [ -n \"$address\" ]; then printf \\'%s\\\\n\\' \"$address\"; exit 0; fi; done; exit 1';\n\tconst result = await capture([\n\t\t...absoluteRemoteMacSshBase(profile),\n\t\t'/bin/sh -lc',\n\t\tshellQuote(script)\n\t]);\n\tconst host = requireRemoteSuccess(\n\t\tresult,\n\t\t'Remote Mac LAN address discovery'\n\t).trim();\n\tif (isIP(host) === 0)\n\t\tthrow new Error(\n\t\t\t'The Remote Mac did not report a device-reachable LAN address.'\n\t\t);\n\n\treturn host;\n};\n\nexport const listAbsoluteRemoteMacProfiles = async (profilePath?: string) => {\n\tconst store = await loadStore(profilePath);\n\n\treturn {\n\t\tdefaultProfile: store.defaultProfile,\n\t\tprofiles: Object.values(store.profiles).sort((left, right) =>\n\t\t\tleft.name.localeCompare(right.name)\n\t\t)\n\t};\n};\nexport const pairAbsoluteRemoteMac = async (options: {\n\tdestination: string;\n\tname: string;\n\tport?: number;\n\tprofilePath?: string;\n\ttransport?: Pick<AbsoluteRemoteMacTransport, 'capture'>;\n\tworkspaceRoot?: string;\n}) => {\n\tconst name = validateAbsoluteRemoteMacProfileName(options.name);\n\tconst destination = validateAbsoluteSshDestination(options.destination);\n\tconst port = validatePort(options.port);\n\tconst inspection = await inspectAbsoluteRemoteMac(destination, {\n\t\tacceptNew: true,\n\t\tport,\n\t\ttransport: options.transport\n\t});\n\tconst workspaceRoot = options.workspaceRoot\n\t\t? options.workspaceRoot.trim()\n\t\t: posix.join(inspection.home, '.absolutejs', 'remote-ios');\n\tif (\n\t\t!workspaceRoot.startsWith('/') ||\n\t\tworkspaceRoot === '/' ||\n\t\t/[\\r\\n\\0]/u.test(workspaceRoot)\n\t)\n\t\tthrow new TypeError(\n\t\t\t'Remote Mac workspace must be an absolute macOS path.'\n\t\t);\n\tconst profile: AbsoluteRemoteMacProfile = {\n\t\tbunPath: inspection.bunPath,\n\t\tcreatedAt: new Date().toISOString(),\n\t\tdestination,\n\t\tname,\n\t\t...(port ? { port } : {}),\n\t\tworkspaceRoot,\n\t\txcodeVersion: inspection.xcodeVersion\n\t};\n\tconst store = await loadStore(options.profilePath);\n\tstore.profiles[name] = profile;\n\tstore.defaultProfile = name;\n\tawait saveStore(store, options.profilePath);\n\n\treturn profile;\n};\nexport const removeAbsoluteRemoteMacProfile = async (\n\tname: string,\n\tprofilePath?: string\n) => {\n\tconst normalized = validateAbsoluteRemoteMacProfileName(name);\n\tconst store = await loadStore(profilePath);\n\tif (!store.profiles[normalized]) return false;\n\tdelete store.profiles[normalized];\n\tif (store.defaultProfile === normalized) {\n\t\tconst [nextDefault] = Object.keys(store.profiles).sort();\n\t\tstore.defaultProfile = nextDefault;\n\t}\n\tawait saveStore(store, profilePath);\n\n\treturn true;\n};\n\nconst projectIdentity = (projectRoot: string, appId: string) =>\n\tcreateHash('sha256')\n\t\t.update(`${resolvePath(projectRoot)}\\0${appId}`)\n\t\t.digest('hex')\n\t\t.slice(0, 20);\n\nexport const createAbsoluteRemoteExpoIosDevProject = (\n\tconfig: NormalizedAbsoluteMobileConfig,\n\tprojectRoot: string,\n\tprofile: AbsoluteRemoteMacProfile\n) => {\n\tif (config.engine !== 'expo')\n\t\tthrow new TypeError(\n\t\t\t'Remote Expo execution requires mobile.engine: expo.'\n\t\t);\n\n\treturn createAbsoluteRemoteIosDevProject(\n\t\tconfig,\n\t\tprojectRoot,\n\t\tprofile\n\t) as AbsoluteRemoteExpoIosDevProject;\n};\nexport const createAbsoluteRemoteIosDevProject = (\n\tconfig: NormalizedAbsoluteMobileConfig,\n\tprojectRoot: string,\n\tprofile: AbsoluteRemoteMacProfile\n): AbsoluteRemoteIosDevProject => ({\n\tcap: join(resolvePath(projectRoot), 'node_modules', '.bin', 'cap'),\n\tconfig,\n\tnativeDirectory: join(config.nativeProjectDirectory, 'ios'),\n\tprofile,\n\tprojectRoot: resolvePath(projectRoot),\n\tremote: true,\n\tremoteProjectRoot: posix.join(\n\t\tprofile.workspaceRoot,\n\t\t'projects',\n\t\tprojectIdentity(projectRoot, config.appId),\n\t\t'current'\n\t),\n\txcodebuild: 'remote:xcodebuild',\n\txcrun: 'remote:xcrun'\n});\nexport const installAbsoluteRemoteMacAgent = async (\n\tproject: AbsoluteRemoteIosDevProject\n) => {\n\tconst artifact = await materializeAbsoluteRemoteMacAgent(\n\t\tproject.projectRoot\n\t);\n\tconst directory = posix.join(\n\t\tproject.profile.workspaceRoot,\n\t\t'agents',\n\t\t`protocol-${ABSOLUTE_REMOTE_MAC_PROTOCOL_VERSION}`,\n\t\tartifact.sha256\n\t);\n\tconst remotePath = posix.join(directory, 'agent.js');\n\tconst verifyScript =\n\t\t`test -f ${shellQuote(remotePath)} && ` +\n\t\t`test \"$(shasum -a 256 ${shellQuote(remotePath)} | awk '{print $1}')\" = ${shellQuote(artifact.sha256)}`;\n\tconst verified = await defaultTransport.capture([\n\t\t...absoluteRemoteMacSshBase(project.profile),\n\t\t'/bin/sh -lc',\n\t\tshellQuote(verifyScript)\n\t]);\n\tif (verified.exitCode === 0)\n\t\treturn { ...artifact, remotePath, uploaded: false };\n\tconst temporary = posix.join(directory, `.agent-${randomUUID()}.tmp`);\n\tconst installScript = [\n\t\t'set -eu',\n\t\t'umask 077',\n\t\t`mkdir -p ${shellQuote(directory)}`,\n\t\t`cat > ${shellQuote(temporary)}`,\n\t\t`test \"$(shasum -a 256 ${shellQuote(temporary)} | awk '{print $1}')\" = ${shellQuote(artifact.sha256)}`,\n\t\t`chmod 600 ${shellQuote(temporary)}`,\n\t\t`mv ${shellQuote(temporary)} ${shellQuote(remotePath)}`\n\t].join('; ');\n\tconst upload = Bun.spawn(\n\t\t[\n\t\t\t...absoluteRemoteMacSshBase(project.profile),\n\t\t\t'/bin/sh -lc',\n\t\t\tshellQuote(installScript)\n\t\t],\n\t\t{\n\t\t\tstderr: 'pipe',\n\t\t\tstdin: Bun.file(artifact.path),\n\t\t\tstdout: 'pipe'\n\t\t}\n\t);\n\tconst [exitCode, stderr] = await Promise.all([\n\t\tupload.exited,\n\t\tnew Response(upload.stderr).text()\n\t]);\n\tif (exitCode !== 0)\n\t\tthrow new Error(\n\t\t\t`Remote Mac agent installation failed: ${stderr.trim() || `status ${exitCode}`}`\n\t\t);\n\n\treturn { ...artifact, remotePath, uploaded: true };\n};\nexport const materializeAbsoluteRemoteMacAgent = async (\n\tprojectRoot: string\n) => {\n\tconst shippedCandidates = [\n\t\tjoin(import.meta.dir, 'remoteMacAgentEntry.js'),\n\t\tjoin(import.meta.dir, '..', 'mobile', 'remoteMacAgentEntry.js')\n\t];\n\tlet path: string | undefined;\n\tfor (const candidate of shippedCandidates) {\n\t\tif (await Bun.file(candidate).exists()) {\n\t\t\tpath = candidate;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (!path) {\n\t\tconst sourceCandidates = [\n\t\t\tjoin(import.meta.dir, 'remoteMacAgentEntry.ts'),\n\t\t\tjoin(\n\t\t\t\timport.meta.dir,\n\t\t\t\t'..',\n\t\t\t\t'..',\n\t\t\t\t'src',\n\t\t\t\t'mobile',\n\t\t\t\t'remoteMacAgentEntry.ts'\n\t\t\t)\n\t\t];\n\t\tconst source = await sourceCandidates.reduce<\n\t\t\tPromise<string | undefined>\n\t\t>(\n\t\t\tasync (found, candidate) =>\n\t\t\t\t(await found) ??\n\t\t\t\t((await Bun.file(candidate).exists()) ? candidate : undefined),\n\t\t\tPromise.resolve(undefined)\n\t\t);\n\t\tif (!source)\n\t\t\tthrow new Error(\n\t\t\t\t'The AbsoluteJS installation does not contain its remote Mac agent artifact.'\n\t\t\t);\n\t\tconst outdir = join(\n\t\t\tresolvePath(projectRoot),\n\t\t\t'.absolutejs',\n\t\t\t'mobile',\n\t\t\t'remote-agent'\n\t\t);\n\t\tawait mkdir(outdir, { recursive: true });\n\t\tconst result = await Bun.build({\n\t\t\tentrypoints: [source],\n\t\t\tminify: true,\n\t\t\toutdir,\n\t\t\ttarget: 'bun'\n\t\t});\n\t\tif (!result.success)\n\t\t\tthrow new AggregateError(\n\t\t\t\tresult.logs,\n\t\t\t\t'Failed to build the AbsoluteJS remote Mac agent.'\n\t\t\t);\n\t\tpath = join(outdir, 'remoteMacAgentEntry.js');\n\t}\n\tconst bytes = await Bun.file(path).arrayBuffer();\n\tconst sha256 = createHash('sha256')\n\t\t.update(new Uint8Array(bytes))\n\t\t.digest('hex');\n\n\treturn { bytes: bytes.byteLength, path, sha256 };\n};\n\nconst portableRelativePath = (root: string, path: string) =>\n\trelative(root, path).split(sep).join(posix.sep);\n\nconst portableMobileConfig = (\n\tproject: AbsoluteRemoteIosDevProject\n): MobileConfig => ({\n\tappId: project.config.appId,\n\tappName: project.config.appName,\n\tbundleDirectory: portableRelativePath(\n\t\tproject.projectRoot,\n\t\tproject.config.bundleDirectory\n\t),\n\tengine: project.config.engine,\n\t...(project.config.deepLinkScheme ||\n\tproject.config.deepLinkHosts.length > 1 ||\n\tproject.config.appleAppIdPrefix\n\t\t? {\n\t\t\t\tdeepLinks: {\n\t\t\t\t\t...(project.config.deepLinkScheme\n\t\t\t\t\t\t? { scheme: project.config.deepLinkScheme }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\thosts: project.config.deepLinkHosts,\n\t\t\t\t\t...(project.config.appleAppIdPrefix\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tapple: {\n\t\t\t\t\t\t\t\t\tappIdPrefix: project.config.appleAppIdPrefix\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: {})\n\t\t\t\t}\n\t\t\t}\n\t\t: {}),\n\tentry: project.config.entry,\n\t...(project.config.engine === 'expo'\n\t\t? {\n\t\t\t\texpo: { sdkVersion: project.config.expoSdkVersion ?? 57 },\n\t\t\t\troutes: {\n\t\t\t\t\tdefault: 'web' as const,\n\t\t\t\t\tnative: Object.fromEntries(\n\t\t\t\t\t\tObject.entries(project.config.expoNativeRoutes).map(\n\t\t\t\t\t\t\t([route, module]) => [\n\t\t\t\t\t\t\t\troute,\n\t\t\t\t\t\t\t\tportableRelativePath(\n\t\t\t\t\t\t\t\t\tproject.projectRoot,\n\t\t\t\t\t\t\t\t\tmodule\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t: {}),\n\t...(project.config.iosVersion\n\t\t? { ios: { version: project.config.iosVersion } }\n\t\t: {}),\n\tnativeProject: {\n\t\tdirectory: portableRelativePath(\n\t\t\tproject.projectRoot,\n\t\t\tproject.config.nativeProjectDirectory\n\t\t),\n\t\tmode: 'source'\n\t},\n\tplatforms: ['ios'],\n\tserver: { productionOrigin: project.config.productionOrigin }\n});\n\nexport const absoluteRemoteProjectSyncCommands = (\n\tproject: AbsoluteRemoteIosDevProject\n) => {\n\tconst current = project.remoteProjectRoot;\n\tconst parent = posix.dirname(current);\n\tconst staging = posix.join(parent, `.incoming-${randomUUID()}`);\n\tconst previous = posix.join(parent, '.previous');\n\tconst script = [\n\t\t'set -eu',\n\t\t`mkdir -p ${shellQuote(staging)}`,\n\t\t`tar -xf - -C ${shellQuote(staging)}`,\n\t\t`if [ -d ${shellQuote(posix.join(current, 'node_modules'))} ]; then mv ${shellQuote(posix.join(current, 'node_modules'))} ${shellQuote(posix.join(staging, 'node_modules'))}; fi`,\n\t\t`if [ -d ${shellQuote(posix.join(current, '.absolutejs'))} ]; then mv ${shellQuote(posix.join(current, '.absolutejs'))} ${shellQuote(posix.join(staging, '.absolutejs'))}; fi`,\n\t\t`rm -rf ${shellQuote(previous)}`,\n\t\t`if [ -d ${shellQuote(current)} ]; then mv ${shellQuote(current)} ${shellQuote(previous)}; fi`,\n\t\t`mv ${shellQuote(staging)} ${shellQuote(current)}`,\n\t\t`rm -rf ${shellQuote(previous)}`\n\t].join('; ');\n\n\treturn {\n\t\tremote: [\n\t\t\t...absoluteRemoteMacSshBase(project.profile),\n\t\t\t'/bin/sh -lc',\n\t\t\tshellQuote(script)\n\t\t],\n\t\ttar: [\n\t\t\t'tar',\n\t\t\t'--exclude=.git',\n\t\t\t'--exclude=node_modules',\n\t\t\t'--exclude=build',\n\t\t\t'--exclude=.absolutejs',\n\t\t\t'-cf',\n\t\t\t'-',\n\t\t\t'-C',\n\t\t\tproject.projectRoot,\n\t\t\t'.'\n\t\t]\n\t};\n};\n\nexport const syncAbsoluteRemoteMacProject = async (\n\tproject: AbsoluteRemoteIosDevProject\n) => {\n\tconst commands = absoluteRemoteProjectSyncCommands(project);\n\tconst archive = Bun.spawn(commands.tar, {\n\t\tstderr: 'pipe',\n\t\tstdout: 'pipe'\n\t});\n\tconst upload = Bun.spawn(commands.remote, {\n\t\tstderr: 'pipe',\n\t\tstdin: archive.stdout,\n\t\tstdout: 'pipe'\n\t});\n\tconst [archiveExit, uploadExit, archiveError, uploadError] =\n\t\tawait Promise.all([\n\t\t\tarchive.exited,\n\t\t\tupload.exited,\n\t\t\tnew Response(archive.stderr).text(),\n\t\t\tnew Response(upload.stderr).text()\n\t\t]);\n\tif (archiveExit !== 0 || uploadExit !== 0)\n\t\tthrow new Error(\n\t\t\t`Remote Mac project synchronization failed: ${(archiveError || uploadError).trim()}`\n\t\t);\n\tconst install = await defaultTransport.capture([\n\t\t...absoluteRemoteMacSshBase(project.profile),\n\t\t'/bin/sh -lc',\n\t\tshellQuote(\n\t\t\t`cd ${shellQuote(project.remoteProjectRoot)} && ${shellQuote(project.profile.bunPath)} install --frozen-lockfile`\n\t\t)\n\t]);\n\trequireRemoteSuccess(install, 'Remote Mac dependency installation');\n};\n\nconst consumeLines = async (\n\tstream: ReadableStream<Uint8Array>,\n\tonLine: (line: string) => void\n) => {\n\tconst reader = stream.getReader();\n\tconst decoder = new TextDecoder();\n\tlet buffered = '';\n\ttry {\n\t\twhile (true) {\n\t\t\tconst { done, value } = await reader.read();\n\t\t\tif (done) break;\n\t\t\tbuffered += decoder.decode(value, { stream: true });\n\t\t\tconst lines = buffered.split(/\\r?\\n/u);\n\t\t\tbuffered = lines.pop() ?? '';\n\t\t\tlines.forEach(onLine);\n\t\t}\n\t\tbuffered += decoder.decode();\n\t\tif (buffered) onLine(buffered);\n\t} finally {\n\t\treader.releaseLock();\n\t}\n};\n\nexport const startAbsoluteRemoteExpoIosDevSession = async (\n\toptions: AbsoluteRemoteExpoIosOptions\n): Promise<AbsoluteExpoDevSession> => {\n\tconst session = await startAbsoluteRemoteDevSession({\n\t\tcertificateAuthorityPath: options.certificateAuthorityPath,\n\t\tdeviceIdentifier: options.deviceIdentifier,\n\t\thttps: options.https,\n\t\tinstallAgent: options.installAgent,\n\t\tlog: options.log,\n\t\tmetroPort: options.metroPort,\n\t\tonExpoPhaseTiming: options.onPhaseTiming,\n\t\tonExpoStateChange: options.onStateChange,\n\t\tport: options.port,\n\t\tproject: options.project,\n\t\tserverHost: options.serverHost,\n\t\tsignal: options.signal,\n\t\tsyncProject: options.syncProject,\n\t\ttransport: options.transport\n\t});\n\n\treturn {\n\t\tclose: session.close,\n\t\tmetroPort: options.metroPort,\n\t\tplatforms: ['ios'],\n\t\ttimings: session.timings\n\t};\n};\nexport const startAbsoluteRemoteIosDevSession = (\n\toptions: AbsoluteRemoteIosOptions\n) => startAbsoluteRemoteDevSession(options);\nconst startAbsoluteRemoteDevSession = async (\n\toptions: AbsoluteRemoteDevOptions\n) => {\n\tconst startedAt = performance.now();\n\tconst transport = options.transport ?? defaultTransport;\n\tconst installAgent = options.installAgent ?? installAbsoluteRemoteMacAgent;\n\tconst syncProject = options.syncProject ?? syncAbsoluteRemoteMacProject;\n\tconst agentStartedAt = performance.now();\n\tconst agent = await installAgent(options.project);\n\tconst agentDuration = performance.now() - agentStartedAt;\n\tconst syncStartedAt = performance.now();\n\tawait syncProject(options.project);\n\tconst syncDuration = performance.now() - syncStartedAt;\n\tconst encodedConfig = Buffer.from(\n\t\tJSON.stringify(portableMobileConfig(options.project))\n\t).toString('base64url');\n\tconst encodedCertificateAuthority = options.certificateAuthorityPath\n\t\t? (await readFile(options.certificateAuthorityPath)).toString(\n\t\t\t\t'base64url'\n\t\t\t)\n\t\t: undefined;\n\tconst physicalDevice = options.deviceIdentifier !== undefined;\n\tconst expo = options.project.config.engine === 'expo';\n\tif (expo && options.metroPort === undefined)\n\t\tthrow new TypeError('Remote Expo execution requires a Metro port.');\n\tif (options.metroPort === options.port)\n\t\tthrow new TypeError(\n\t\t\t'Expo Metro and AbsoluteJS must use different ports.'\n\t\t);\n\tconst translatedRelayPort = (sourcePort: number) =>\n\t\tsourcePort <= 49_151 ? sourcePort + 16_384 : sourcePort - 16_384;\n\tconst occupiedRemotePorts = new Set(\n\t\t[options.port, options.metroPort].filter(\n\t\t\t(value): value is number => value !== undefined\n\t\t)\n\t);\n\tconst reserveRelayPort = (sourcePort: number) => {\n\t\tlet candidate = translatedRelayPort(sourcePort);\n\t\twhile (occupiedRemotePorts.has(candidate))\n\t\t\tcandidate = candidate === 65_535 ? 1_024 : candidate + 1;\n\t\toccupiedRemotePorts.add(candidate);\n\n\t\treturn candidate;\n\t};\n\tconst relayPort = physicalDevice\n\t\t? reserveRelayPort(options.port)\n\t\t: undefined;\n\tconst metroRelayPort =\n\t\tphysicalDevice && options.metroPort !== undefined\n\t\t\t? reserveRelayPort(options.metroPort)\n\t\t\t: undefined;\n\tif (physicalDevice && !options.serverHost)\n\t\tthrow new Error(\n\t\t\t'Remote physical iOS development requires the Remote Mac LAN host.'\n\t\t);\n\tconst remoteCommand = [\n\t\t`cd ${shellQuote(options.project.remoteProjectRoot)}`,\n\t\t'&&',\n\t\t'exec',\n\t\tshellQuote(options.project.profile.bunPath),\n\t\tshellQuote(agent.remotePath),\n\t\t'--port',\n\t\tString(options.port),\n\t\t'--mobile-config',\n\t\tshellQuote(encodedConfig),\n\t\t...(expo && options.metroPort !== undefined\n\t\t\t? ['--metro-port', String(options.metroPort)]\n\t\t\t: []),\n\t\t...(encodedCertificateAuthority\n\t\t\t? [\n\t\t\t\t\t'--certificate-authority',\n\t\t\t\t\tshellQuote(encodedCertificateAuthority)\n\t\t\t\t]\n\t\t\t: []),\n\t\t...(options.https ? ['--https'] : []),\n\t\t...(options.deviceIdentifier\n\t\t\t? [\n\t\t\t\t\t'--ios-device',\n\t\t\t\t\tshellQuote(options.deviceIdentifier),\n\t\t\t\t\t'--server-host',\n\t\t\t\t\tshellQuote(options.serverHost ?? ''),\n\t\t\t\t\t'--relay-port',\n\t\t\t\t\tString(relayPort),\n\t\t\t\t\t...(expo && metroRelayPort !== undefined\n\t\t\t\t\t\t? ['--metro-relay-port', String(metroRelayPort)]\n\t\t\t\t\t\t: [])\n\t\t\t\t]\n\t\t\t: [])\n\t].join(' ');\n\tconst command = [\n\t\t...absoluteRemoteMacSshBase(options.project.profile),\n\t\t'-o',\n\t\t'ExitOnForwardFailure=yes',\n\t\t'-R',\n\t\tphysicalDevice\n\t\t\t? `127.0.0.1:${relayPort}:127.0.0.1:${options.port}`\n\t\t\t: `${options.port}:127.0.0.1:${options.port}`,\n\t\t...(expo && options.metroPort !== undefined\n\t\t\t? [\n\t\t\t\t\t'-R',\n\t\t\t\t\tphysicalDevice\n\t\t\t\t\t\t? `127.0.0.1:${metroRelayPort}:127.0.0.1:${options.metroPort}`\n\t\t\t\t\t\t: `${options.metroPort}:127.0.0.1:${options.metroPort}`\n\t\t\t\t]\n\t\t\t: []),\n\t\t'/bin/sh -lc',\n\t\tshellQuote(remoteCommand)\n\t];\n\tconst connectStartedAt = performance.now();\n\tconst process = transport.spawn(command, { signal: options.signal });\n\tlet state: AbsoluteIosDevState = 'syncing';\n\tlet ready: Extract<RemoteEvent, { type: 'ready' }> | undefined;\n\tlet fatal: Error | undefined;\n\tconst pending = new Map<\n\t\tstring,\n\t\t{ reject: (error: Error) => void; resolve: (value: unknown) => void }\n\t>();\n\tlet resolveReady!: () => void;\n\tlet rejectReady!: (error: Error) => void;\n\tconst readyPromise = new Promise<void>((resolve, reject) => {\n\t\tresolveReady = resolve;\n\t\trejectReady = reject;\n\t});\n\tconst handleEvent = (event: RemoteEvent) => {\n\t\tif (event.v !== ABSOLUTE_REMOTE_MAC_PROTOCOL_VERSION) {\n\t\t\trejectReady(new Error('Remote Mac protocol version mismatch.'));\n\n\t\t\treturn;\n\t\t}\n\t\tif (event.type === 'log') options.log?.(event.message);\n\t\tif (event.type === 'native-log') options.nativeLog?.(event.entry);\n\t\tif (event.type === 'state') {\n\t\t\tif (expo)\n\t\t\t\toptions.onExpoStateChange?.(\n\t\t\t\t\tevent.state as AbsoluteExpoDevState\n\t\t\t\t);\n\t\t\telse {\n\t\t\t\tstate = event.state as AbsoluteIosDevState;\n\t\t\t\toptions.onStateChange?.(state);\n\t\t\t}\n\t\t}\n\t\tif (event.type === 'timing') {\n\t\t\tif (expo)\n\t\t\t\toptions.onExpoPhaseTiming?.(\n\t\t\t\t\tevent as AbsoluteExpoDevPhaseTiming\n\t\t\t\t);\n\t\t\telse options.onPhaseTiming?.(event as AbsoluteIosDevPhaseTiming);\n\t\t}\n\t\tif (event.type === 'ready') {\n\t\t\tready = event;\n\t\t\tresolveReady();\n\t\t}\n\t\tif (event.type === 'fatal') {\n\t\t\tfatal = new Error(event.error);\n\t\t\trejectReady(fatal);\n\t\t}\n\t\tif (event.type === 'response') {\n\t\t\tconst request = pending.get(event.id);\n\t\t\tif (!request) return;\n\t\t\tpending.delete(event.id);\n\t\t\tif (event.ok) request.resolve(event.result);\n\t\t\telse\n\t\t\t\trequest.reject(\n\t\t\t\t\tnew Error(event.error ?? 'Remote command failed.')\n\t\t\t\t);\n\t\t}\n\t};\n\tconst stdoutDone = consumeLines(process.stdout, (line) => {\n\t\tif (!line.startsWith(ABSOLUTE_REMOTE_MAC_EVENT_PREFIX)) return;\n\t\ttry {\n\t\t\thandleEvent(\n\t\t\t\tJSON.parse(\n\t\t\t\t\tline.slice(ABSOLUTE_REMOTE_MAC_EVENT_PREFIX.length)\n\t\t\t\t) as RemoteEvent\n\t\t\t);\n\t\t} catch {\n\t\t\toptions.log?.(`Remote Mac emitted an invalid protocol event.`);\n\t\t}\n\t}).catch((error: unknown) => {\n\t\tfatal =\n\t\t\terror instanceof Error\n\t\t\t\t? error\n\t\t\t\t: new Error('Failed to read the remote Mac protocol stream.');\n\t\trejectReady(fatal);\n\t});\n\tconst stderrDone = consumeLines(process.stderr, (line) =>\n\t\toptions.log?.(`[remote] ${line}`)\n\t).catch((error: unknown) =>\n\t\toptions.log?.(\n\t\t\t`[remote] ${error instanceof Error ? error.message : 'Failed to read SSH stderr.'}`\n\t\t)\n\t);\n\tvoid process.exited.then(async (exitCode) => {\n\t\tawait Promise.all([stdoutDone, stderrDone]);\n\t\tconst error =\n\t\t\tfatal ??\n\t\t\tnew Error(`Remote Mac connection closed with status ${exitCode}.`);\n\t\tif (!ready) rejectReady(error);\n\t\tpending.forEach(({ reject }) => reject(error));\n\t\tpending.clear();\n\n\t\treturn undefined;\n\t});\n\ttry {\n\t\tawait readyPromise;\n\t} catch (error) {\n\t\tprocess.stdin.end();\n\t\tprocess.kill();\n\t\tawait process.exited.catch(() => undefined);\n\n\t\tthrow error;\n\t}\n\tif (!ready) throw fatal ?? new Error('Remote Mac did not become ready.');\n\tif (ready.engine !== options.project.config.engine) {\n\t\tprocess.stdin.end();\n\t\tprocess.kill();\n\t\tawait process.exited.catch(() => undefined);\n\t\tthrow new Error(\n\t\t\t'Remote Mac executor returned the wrong mobile engine.'\n\t\t);\n\t}\n\tconst totalDuration = performance.now() - startedAt;\n\tlet currentReady: Extract<RemoteEvent, { type: 'ready' }> = {\n\t\t...ready,\n\t\ttimings: {\n\t\t\t...ready.timings,\n\t\t\t'remote-agent': agentDuration,\n\t\t\t'remote-connect': performance.now() - connectStartedAt,\n\t\t\t'remote-sync': syncDuration,\n\t\t\ttotal: totalDuration\n\t\t}\n\t};\n\toptions.log?.(\n\t\t`Remote Mac connected (${options.project.profile.name}); agent ${agent.uploaded ? 'uploaded' : 'cache hit'}, project synced, and ${expo ? 'Expo ' : ''}iOS ready in ${totalDuration.toFixed(2)}ms.`\n\t);\n\n\tconst request = (\n\t\tcommandName: 'close' | 'rebuild' | 'relaunch' | 'screenshot'\n\t) => {\n\t\tconst id = randomUUID();\n\t\tconst response = new Promise<unknown>((resolve, reject) =>\n\t\t\tpending.set(id, { reject, resolve })\n\t\t);\n\t\tprocess.stdin.write(\n\t\t\t`${JSON.stringify({ command: commandName, id, v: ABSOLUTE_REMOTE_MAC_PROTOCOL_VERSION })}\\n`\n\t\t);\n\t\tconst flush = async () => {\n\t\t\tfor (\n\t\t\t\tlet attempt = 0;\n\t\t\t\tattempt < REMOTE_STDIN_FLUSH_ATTEMPTS;\n\t\t\t\tattempt++\n\t\t\t) {\n\t\t\t\ttry {\n\t\t\t\t\tawait process.stdin.flush();\n\n\t\t\t\t\treturn;\n\t\t\t\t} catch {\n\t\t\t\t\t// Bun can transiently report EPERM for a subprocess pipe. Retrying\n\t\t\t\t\t// the same sink flush cannot duplicate the already queued frame.\n\t\t\t\t\tawait Promise.resolve();\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\treturn flush().then(() => response);\n\t};\n\tlet closed = false;\n\tconst close = async () => {\n\t\tif (closed) return;\n\t\tclosed = true;\n\t\tconst timeout = () =>\n\t\t\tnew Promise<'timeout'>((resolve) =>\n\t\t\t\tsetTimeout(\n\t\t\t\t\t() => resolve('timeout'),\n\t\t\t\t\tREMOTE_SESSION_CLOSE_TIMEOUT_MS\n\t\t\t\t)\n\t\t\t);\n\t\tawait Promise.race([\n\t\t\trequest('close').catch(() => undefined),\n\t\t\ttimeout()\n\t\t]);\n\t\tprocess.stdin.end();\n\t\tconst exit = await Promise.race([\n\t\t\tprocess.exited\n\t\t\t\t.then(() => 'exited' as const)\n\t\t\t\t.catch(() => 'exited' as const),\n\t\t\ttimeout()\n\t\t]);\n\t\tif (exit === 'timeout') {\n\t\t\tprocess.kill();\n\t\t\tawait process.exited.catch(() => undefined);\n\t\t}\n\t};\n\tconst makeSession = (): AbsoluteIosDevSession => ({\n\t\tclose,\n\t\tnativeCacheHit: currentReady.nativeCacheHit,\n\t\tstartedSimulator: currentReady.startedSimulator,\n\t\ttargetKind: currentReady.targetKind,\n\t\ttimings: currentReady.timings,\n\t\tudid: currentReady.udid,\n\t\trebuild: async () => {\n\t\t\tconst rebuildStartedAt = performance.now();\n\t\t\tconst rebuildSyncStartedAt = performance.now();\n\t\t\tawait syncProject(options.project);\n\t\t\tconst rebuildSyncDuration =\n\t\t\t\tperformance.now() - rebuildSyncStartedAt;\n\t\t\tconst result = (await request('rebuild')) as Extract<\n\t\t\t\tRemoteEvent,\n\t\t\t\t{ type: 'ready' }\n\t\t\t>;\n\t\t\tcurrentReady = {\n\t\t\t\t...result,\n\t\t\t\ttimings: {\n\t\t\t\t\t...result.timings,\n\t\t\t\t\t'remote-sync': rebuildSyncDuration,\n\t\t\t\t\ttotal: performance.now() - rebuildStartedAt\n\t\t\t\t}\n\t\t\t};\n\n\t\t\treturn makeSession();\n\t\t},\n\t\trelaunch: async () => {\n\t\t\tawait request('relaunch');\n\t\t},\n\t\tscreenshot: async (destination) => {\n\t\t\tconst result = (await request('screenshot')) as { data: string };\n\t\t\tconst target = resolvePath(\n\t\t\t\toptions.project.projectRoot,\n\t\t\t\tdestination\n\t\t\t);\n\t\t\tconst targetRelative = relative(\n\t\t\t\toptions.project.projectRoot,\n\t\t\t\ttarget\n\t\t\t);\n\t\t\tif (targetRelative.startsWith('..') || isAbsolute(targetRelative))\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'iOS screenshot must remain inside the project.'\n\t\t\t\t);\n\t\t\tawait mkdir(dirname(target), { recursive: true });\n\t\t\tawait writeFile(target, Buffer.from(result.data, 'base64'));\n\n\t\t\treturn target;\n\t\t},\n\t\tget state() {\n\t\t\treturn state;\n\t\t}\n\t});\n\n\treturn makeSession();\n};\n",
|
|
30
|
+
"export const ABSOLUTE_REMOTE_MAC_EVENT_PREFIX = 'ABSOLUTE_REMOTE_MAC\\t';\nexport const ABSOLUTE_REMOTE_MAC_PROTOCOL_VERSION = 2;\n",
|
|
31
|
+
"export type AbsoluteIosDeviceAcceptanceResult = {\n\thmrConnected: true;\n\tinstalled: true;\n\trelaunchMs: number;\n};\n\ntype CommandResult = { exitCode: number; stderr: string; stdout: string };\n\nexport const absoluteIosDeviceAcceptanceCommands = (options: {\n\tappId: string;\n\tdevice: string;\n\txcrun?: string;\n}) => {\n\tconst xcrun = options.xcrun ?? '/usr/bin/xcrun';\n\tconst prefix = [xcrun, 'devicectl', 'device'];\n\n\treturn {\n\t\tapps: [...prefix, 'info', 'apps', '--device', options.device],\n\t\tdetails: [...prefix, 'info', 'details', '--device', options.device],\n\t\tlaunch: [\n\t\t\t...prefix,\n\t\t\t'process',\n\t\t\t'launch',\n\t\t\t'--terminate-existing',\n\t\t\t'--device',\n\t\t\toptions.device,\n\t\t\toptions.appId\n\t\t]\n\t};\n};\n\nconst requireSuccess = (result: CommandResult, message: string) => {\n\tif (result.exitCode !== 0) throw new Error(message);\n\n\treturn result;\n};\n\n/**\n * Validate and relaunch a physical iOS app without retaining device inventory,\n * signing output, or console output in the acceptance result.\n */\nexport const testAbsoluteIosPhysicalDevice = async (options: {\n\tappId: string;\n\tcapture: (command: string[]) => Promise<CommandResult>;\n\tdevice: string;\n\tnow?: () => number;\n\twaitForHmr: () => Promise<void>;\n\txcrun?: string;\n}): Promise<AbsoluteIosDeviceAcceptanceResult> => {\n\tconst commands = absoluteIosDeviceAcceptanceCommands(options);\n\trequireSuccess(\n\t\tawait options.capture(commands.details),\n\t\t'The selected physical iOS device is unavailable. Pair it in Xcode Device Hub, trust this Mac, unlock it, and enable Developer Mode.'\n\t);\n\tconst apps = requireSuccess(\n\t\tawait options.capture(commands.apps),\n\t\t'AbsoluteJS could not inspect installed apps on the physical iOS device.'\n\t);\n\tif (!apps.stdout.includes(options.appId))\n\t\tthrow new Error(\n\t\t\t'The AbsoluteJS app is not installed on the selected physical iOS device. Start bun dev with the same --ios-device value first.'\n\t\t);\n\tconst now = options.now ?? performance.now.bind(performance);\n\tconst startedAt = now();\n\trequireSuccess(\n\t\tawait options.capture(commands.launch),\n\t\t'AbsoluteJS could not relaunch the app on the physical iOS device.'\n\t);\n\tawait options.waitForHmr();\n\n\treturn {\n\t\thmrConnected: true,\n\t\tinstalled: true,\n\t\trelaunchMs: Math.round(now() - startedAt)\n\t};\n};\n",
|
|
22
32
|
"import {\n\taccess,\n\tmkdir,\n\treadFile,\n\trename,\n\trm,\n\twriteFile\n} from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { Elysia } from 'elysia';\nimport type { MobileConfig } from '../../types/build';\nimport {\n\tnormalizeAbsoluteMobileConfig,\n\ttype NormalizedAbsoluteMobileConfig\n} from './config';\n\nconst JSON_HEADERS: Record<string, string> = {\n\t'cache-control': 'public, max-age=300, must-revalidate',\n\t'content-type': 'application/json; charset=utf-8'\n};\nconst OWNERSHIP_FILE = '.absolutejs-mobile-associations.json';\nconst HTTP_OK = 200;\nconst VERIFY_TIMEOUT_MS = 10_000;\n\ntype AssociationEndpoint = {\n\tdocument: unknown;\n\thost: string;\n\tpath: string;\n\tplatform: string;\n};\n\nexport type AbsoluteAssociationRequest = (\n\tinput: string | URL | Request,\n\tinit?: RequestInit\n) => Promise<Response>;\n\nexport const ANDROID_ASSOCIATION_PATH = '/.well-known/assetlinks.json';\nexport const APPLE_ASSOCIATION_PATH = '/.well-known/apple-app-site-association';\n\nexport type AbsoluteMobileAssociationDocuments = {\n\tandroid?: readonly [\n\t\t{\n\t\t\trelation: readonly ['delegate_permission/common.handle_all_urls'];\n\t\t\ttarget: {\n\t\t\t\tnamespace: 'android_app';\n\t\t\t\tpackage_name: string;\n\t\t\t\tsha256_cert_fingerprints: string[];\n\t\t\t};\n\t\t}\n\t];\n\tapple?: {\n\t\tapplinks: {\n\t\t\tdetails: readonly [\n\t\t\t\t{\n\t\t\t\t\tappIDs: readonly [string];\n\t\t\t\t\tcomponents: readonly [{ '/': '/*' }];\n\t\t\t\t}\n\t\t\t];\n\t\t};\n\t};\n};\n\nconst missingIdentity = (field: string, platform: string) =>\n\tnew TypeError(\n\t\t`${field} is required to publish ${platform} deep-link association files.`\n\t);\n\nconst createAppleDocument = (\n\tconfig: NormalizedAbsoluteMobileConfig,\n\trequireAll: boolean\n) => {\n\tif (!config.platforms.includes('ios')) return undefined;\n\tif (!config.appleAppIdPrefix && requireAll) {\n\t\tthrow missingIdentity('mobile.deepLinks.apple.appIdPrefix', 'iOS');\n\t}\n\tif (!config.appleAppIdPrefix) return undefined;\n\n\treturn {\n\t\tapplinks: {\n\t\t\tdetails: [\n\t\t\t\t{\n\t\t\t\t\tappIDs: [\n\t\t\t\t\t\t`${config.appleAppIdPrefix}.${config.appId}`\n\t\t\t\t\t] as const,\n\t\t\t\t\tcomponents: [{ '/': '/*' as const }]\n\t\t\t\t}\n\t\t\t] as const\n\t\t}\n\t};\n};\n\nconst createAndroidDocument = (\n\tconfig: NormalizedAbsoluteMobileConfig,\n\trequireAll: boolean\n) => {\n\tif (!config.platforms.includes('android')) return undefined;\n\tif (config.androidCertificateFingerprints.length === 0 && requireAll) {\n\t\tthrow missingIdentity(\n\t\t\t'mobile.deepLinks.android.sha256CertificateFingerprints',\n\t\t\t'Android'\n\t\t);\n\t}\n\tif (config.androidCertificateFingerprints.length === 0) return undefined;\n\n\treturn [\n\t\t{\n\t\t\trelation: ['delegate_permission/common.handle_all_urls'] as const,\n\t\t\ttarget: {\n\t\t\t\tnamespace: 'android_app' as const,\n\t\t\t\tpackage_name: config.appId,\n\t\t\t\tsha256_cert_fingerprints: config.androidCertificateFingerprints\n\t\t\t}\n\t\t}\n\t] as const;\n};\n\nexport const createAbsoluteMobileAssociationDocuments = (\n\tconfig: NormalizedAbsoluteMobileConfig,\n\toptions: { requireAll?: boolean } = {}\n) => {\n\tconst documents: AbsoluteMobileAssociationDocuments = {};\n\tconst requireAll = options.requireAll === true;\n\tconst android = createAndroidDocument(config, requireAll);\n\tconst apple = createAppleDocument(config, requireAll);\n\tif (android) documents.android = android;\n\tif (apple) documents.apple = apple;\n\n\treturn documents;\n};\n\nconst jsonResponse = (value: unknown) =>\n\tnew Response(`${JSON.stringify(value)}\\n`, { headers: JSON_HEADERS });\n\nexport const createAbsoluteMobileAssociationPlugin = (\n\tmobile: MobileConfig | undefined,\n\tprojectRoot: string,\n\toptions: { requireAll?: boolean } = {}\n) => {\n\tconst plugin = new Elysia({ name: 'absolutejs-mobile-associations' });\n\tif (!mobile) return plugin;\n\tconst config = normalizeAbsoluteMobileConfig(mobile, projectRoot);\n\tconst documents = createAbsoluteMobileAssociationDocuments(config, options);\n\tif (documents.apple) {\n\t\tplugin.get(APPLE_ASSOCIATION_PATH, () => jsonResponse(documents.apple));\n\t}\n\tif (documents.android) {\n\t\tplugin.get(ANDROID_ASSOCIATION_PATH, () =>\n\t\t\tjsonResponse(documents.android)\n\t\t);\n\t}\n\n\treturn plugin;\n};\n\nconst writeAtomic = async (path: string, source: string) => {\n\tlet current: string | undefined;\n\ttry {\n\t\tcurrent = await readFile(path, 'utf8');\n\t} catch (error) {\n\t\tif (\n\t\t\t!(error instanceof Error) ||\n\t\t\t!('code' in error) ||\n\t\t\terror.code !== 'ENOENT'\n\t\t) {\n\t\t\tthrow error;\n\t\t}\n\t}\n\tif (current === source) return false;\n\tconst temporary = `${path}.${crypto.randomUUID()}.tmp`;\n\tawait writeFile(temporary, source, { flag: 'wx' });\n\tawait rename(temporary, path);\n\n\treturn true;\n};\n\nconst exists = async (path: string) => {\n\ttry {\n\t\tawait access(path);\n\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n};\n\nconst assertOwnedOutput = async (root: string) => {\n\tconst path = resolve(root, OWNERSHIP_FILE);\n\tlet ownership: unknown;\n\ttry {\n\t\townership = JSON.parse(await readFile(path, 'utf8'));\n\t} catch {\n\t\tthrow new TypeError(\n\t\t\t`Association output ${root} already exists and is not owned by AbsoluteJS.`\n\t\t);\n\t}\n\tif (\n\t\ttypeof ownership !== 'object' ||\n\t\townership === null ||\n\t\tReflect.get(ownership, 'format') !== 1\n\t) {\n\t\tthrow new TypeError(\n\t\t\t`Association output ${root} has an unsupported ownership manifest.`\n\t\t);\n\t}\n};\n\nconst publishGeneratedDirectory = async (temporary: string, root: string) => {\n\tconst hasCurrent = await exists(root);\n\tif (hasCurrent) await assertOwnedOutput(root);\n\tconst backup = `${root}.${crypto.randomUUID()}.previous`;\n\tif (hasCurrent) await rename(root, backup);\n\ttry {\n\t\tawait rename(temporary, root);\n\t} catch (error) {\n\t\tif (hasCurrent) await rename(backup, root);\n\t\tthrow error;\n\t}\n\tif (hasCurrent) await rm(backup, { force: true, recursive: true });\n};\n\nconst materializeHost = async (\n\troot: string,\n\thost: string,\n\tfiles: Array<[string, unknown]>\n) => {\n\tconst directory = resolve(root, host, '.well-known');\n\tawait mkdir(directory, { recursive: true });\n\n\treturn Promise.all(\n\t\tfiles.map(async ([name, document]) => {\n\t\t\tconst path = resolve(directory, name);\n\t\t\tawait writeAtomic(path, `${JSON.stringify(document, null, 2)}\\n`);\n\n\t\t\treturn path;\n\t\t})\n\t);\n};\n\nconst associationEndpoints = (\n\tconfig: NormalizedAbsoluteMobileConfig,\n\tdocuments: AbsoluteMobileAssociationDocuments\n) =>\n\tconfig.deepLinkHosts.flatMap((host) => {\n\t\tconst endpoints: AssociationEndpoint[] = [];\n\t\tif (documents.android)\n\t\t\tendpoints.push({\n\t\t\t\tdocument: documents.android,\n\t\t\t\thost,\n\t\t\t\tpath: ANDROID_ASSOCIATION_PATH,\n\t\t\t\tplatform: 'Android'\n\t\t\t});\n\t\tif (documents.apple)\n\t\t\tendpoints.push({\n\t\t\t\tdocument: documents.apple,\n\t\t\t\thost,\n\t\t\t\tpath: APPLE_ASSOCIATION_PATH,\n\t\t\t\tplatform: 'Apple'\n\t\t\t});\n\n\t\treturn endpoints;\n\t});\n\nexport const materializeAbsoluteMobileAssociationFiles = async (\n\tconfig: NormalizedAbsoluteMobileConfig,\n\toutputDirectory: string\n) => {\n\tconst root = resolve(outputDirectory);\n\tconst temporary = `${root}.${crypto.randomUUID()}.tmp`;\n\tconst documents = createAbsoluteMobileAssociationDocuments(config, {\n\t\trequireAll: true\n\t});\n\tconst files: Array<[string, unknown]> = [];\n\tif (documents.android) files.push(['assetlinks.json', documents.android]);\n\tif (documents.apple) {\n\t\tfiles.push(['apple-app-site-association', documents.apple]);\n\t}\n\tawait mkdir(temporary, { recursive: true });\n\ttry {\n\t\tconst temporaryPaths = (\n\t\t\tawait Promise.all(\n\t\t\t\tconfig.deepLinkHosts.map((host) =>\n\t\t\t\t\tmaterializeHost(temporary, host, files)\n\t\t\t\t)\n\t\t\t)\n\t\t).flat();\n\t\tawait writeAtomic(\n\t\t\tresolve(temporary, OWNERSHIP_FILE),\n\t\t\t`${JSON.stringify({ format: 1, hosts: config.deepLinkHosts }, null, 2)}\\n`\n\t\t);\n\t\tawait publishGeneratedDirectory(temporary, root);\n\t\tconst written = temporaryPaths.map((path) =>\n\t\t\tresolve(root, path.slice(temporary.length + 1))\n\t\t);\n\n\t\treturn { root, written };\n\t} catch (error) {\n\t\tawait rm(temporary, { force: true, recursive: true });\n\t\tthrow error;\n\t}\n};\n\nexport const verifyAbsoluteMobileAssociationFiles = async (\n\tconfig: NormalizedAbsoluteMobileConfig,\n\trequest: AbsoluteAssociationRequest = globalThis.fetch\n) => {\n\tconst documents = createAbsoluteMobileAssociationDocuments(config, {\n\t\trequireAll: true\n\t});\n\tconst results = await Promise.all(\n\t\tassociationEndpoints(config, documents).map(async (endpoint) => {\n\t\t\tconst url = `https://${endpoint.host}${endpoint.path}`;\n\t\t\tconst response = await request(url, {\n\t\t\t\tredirect: 'manual',\n\t\t\t\tsignal: AbortSignal.timeout(VERIFY_TIMEOUT_MS)\n\t\t\t});\n\t\t\tif (response.status !== HTTP_OK) {\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t`${endpoint.platform} association verification failed for ${url}: HTTP ${response.status}; redirects are not allowed.`\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst contentType = response.headers.get('content-type') ?? '';\n\t\t\tif (!contentType.toLowerCase().startsWith('application/json')) {\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t`${endpoint.platform} association verification failed for ${url}: expected application/json.`\n\t\t\t\t);\n\t\t\t}\n\t\t\tlet document: unknown;\n\t\t\ttry {\n\t\t\t\tdocument = await response.json();\n\t\t\t} catch {\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t`${endpoint.platform} association verification failed for ${url}: invalid JSON.`\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (\n\t\t\t\tJSON.stringify(document) !== JSON.stringify(endpoint.document)\n\t\t\t) {\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t`${endpoint.platform} association verification failed for ${url}: the hosted identity does not match mobile config.`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn { platform: endpoint.platform, url };\n\t\t})\n\t);\n\n\treturn { results };\n};\n",
|
|
23
|
-
"import { resolve } from 'node:path';\nimport type { MobileConfig, MobilePlatform } from '../../types/build';\n\nexport type NormalizedAbsoluteMobileConfig = {\n\tappId: string;\n\tappName: string;\n\tandroidCertificateFingerprints: string[];\n\tappleAppIdPrefix?: string;\n\tbundleDirectory: string;\n\tdeepLinkHosts: string[];\n\tdeepLinkScheme?: string;\n\tengine: 'capacitor';\n\tentry: string;\n\tiosVersion?: string;\n\tnativeProjectDirectory: string;\n\tplatforms: MobilePlatform[];\n\tproductionOrigin: string;\n};\n\nconst APP_ID_PATTERN = /^[A-Za-z][\\w]*(?:\\.[A-Za-z][\\w]*)+$/;\nconst SCHEME_PATTERN = /^[a-z][a-z0-9+.-]*$/;\nconst APPLE_APP_ID_PREFIX_PATTERN = /^[A-Z0-9]{10}$/;\nconst CERTIFICATE_FINGERPRINT_PATTERN = /^[0-9A-F]{64}$/;\nconst HOSTNAME_PATTERN =\n\t/^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)(?:\\.(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?))*$/;\n\nconst resolveProjectPath = (\n\tprojectRoot: string,\n\tvalue: string,\n\tfield: string\n) => {\n\tconst root = resolve(projectRoot);\n\tconst path = resolve(root, value);\n\tif (path !== root && !path.startsWith(`${root}/`)) {\n\t\tthrow new TypeError(`${field} must remain inside the project root.`);\n\t}\n\n\treturn path;\n};\n\nconst requireText = (value: string, field: string) => {\n\tconst normalized = value.trim();\n\tif (!normalized) throw new TypeError(`${field} must not be empty.`);\n\n\treturn normalized;\n};\n\nconst normalizeEntry = (entry: string | undefined) => {\n\tconst normalized = requireText(entry ?? '/', 'mobile.entry');\n\tif (!normalized.startsWith('/') || normalized.startsWith('//')) {\n\t\tthrow new TypeError(\n\t\t\t'mobile.entry must be an absolute application path.'\n\t\t);\n\t}\n\n\treturn normalized;\n};\n\nconst normalizeProductionOrigin = (value: string) => {\n\tconst parsed = new URL(\n\t\trequireText(value, 'mobile.server.productionOrigin')\n\t);\n\tconst isLoopbackHttp =\n\t\tparsed.protocol === 'http:' &&\n\t\t(parsed.hostname === 'localhost' ||\n\t\t\tparsed.hostname === '127.0.0.1' ||\n\t\t\tparsed.hostname === '[::1]');\n\tif (parsed.protocol !== 'https:' && !isLoopbackHttp) {\n\t\tthrow new TypeError(\n\t\t\t'mobile.server.productionOrigin must use HTTPS, except for a loopback development origin.'\n\t\t);\n\t}\n\tif (\n\t\tparsed.username ||\n\t\tparsed.password ||\n\t\tparsed.pathname !== '/' ||\n\t\tparsed.search ||\n\t\tparsed.hash\n\t) {\n\t\tthrow new TypeError(\n\t\t\t'mobile.server.productionOrigin must be an origin without credentials, path, query, or hash.'\n\t\t);\n\t}\n\n\treturn parsed.origin;\n};\n\nconst normalizePlatforms = (\n\tplatforms: readonly MobilePlatform[] | undefined\n) => {\n\tconst normalized: MobilePlatform[] = [\n\t\t...new Set<MobilePlatform>(platforms ?? ['ios', 'android'])\n\t];\n\tif (normalized.length === 0) {\n\t\tthrow new TypeError(\n\t\t\t'mobile.platforms must contain at least one platform.'\n\t\t);\n\t}\n\n\treturn normalized;\n};\n\nconst normalizeHosts = (\n\thosts: readonly string[] | undefined,\n\tproductionOrigin: string\n) => {\n\tconst normalizeHostname = (host: string) => {\n\t\tconst value = requireText(host, 'mobile.deepLinks.hosts').toLowerCase();\n\t\tif (!HOSTNAME_PATTERN.test(value)) {\n\t\t\tthrow new TypeError(\n\t\t\t\t'mobile.deepLinks.hosts entries must be valid hostnames without ports, wildcards, or paths.'\n\t\t\t);\n\t\t}\n\n\t\treturn value;\n\t};\n\tconst productionHostname = new URL(productionOrigin).hostname;\n\t// IPv6 loopback is valid for a local backend preview but cannot be an\n\t// Android App Link or Apple Universal Link hostname.\n\tconst normalized = new Set<string>(\n\t\tproductionHostname === '[::1]'\n\t\t\t? []\n\t\t\t: [normalizeHostname(productionHostname)]\n\t);\n\tfor (const host of hosts ?? []) {\n\t\tnormalized.add(normalizeHostname(host));\n\t}\n\n\treturn [...normalized].sort();\n};\n\nconst normalizeAppleAppIdPrefix = (value: string | undefined) => {\n\tif (value === undefined) return undefined;\n\tconst normalized = requireText(\n\t\tvalue,\n\t\t'mobile.deepLinks.apple.appIdPrefix'\n\t).toUpperCase();\n\tif (!APPLE_APP_ID_PREFIX_PATTERN.test(normalized)) {\n\t\tthrow new TypeError(\n\t\t\t'mobile.deepLinks.apple.appIdPrefix must contain ten letters or digits.'\n\t\t);\n\t}\n\n\treturn normalized;\n};\n\nconst normalizeIosVersion = (value: string | undefined) => {\n\tif (value === undefined) return undefined;\n\tconst normalized = requireText(value, 'mobile.ios.version');\n\tif (!/^\\d+(?:\\.\\d+){0,2}$/u.test(normalized)) {\n\t\tthrow new TypeError(\n\t\t\t'mobile.ios.version must contain one to three dot-separated integer components, for example 1.4.0.'\n\t\t);\n\t}\n\n\treturn normalized;\n};\n\nconst normalizeCertificateFingerprints = (\n\tvalues: readonly string[] | undefined\n) =>\n\t[\n\t\t...new Set(\n\t\t\t(values ?? [])\n\t\t\t\t.map((value) =>\n\t\t\t\t\trequireText(\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t'mobile.deepLinks.android.sha256CertificateFingerprints'\n\t\t\t\t\t)\n\t\t\t\t\t\t.replaceAll(':', '')\n\t\t\t\t\t\t.toUpperCase()\n\t\t\t\t)\n\t\t\t\t.map((value) => {\n\t\t\t\t\tif (!CERTIFICATE_FINGERPRINT_PATTERN.test(value)) {\n\t\t\t\t\t\tthrow new TypeError(\n\t\t\t\t\t\t\t'mobile.deepLinks.android.sha256CertificateFingerprints entries must be SHA-256 certificate fingerprints.'\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn value.match(/.{2}/g)?.join(':') ?? value;\n\t\t\t\t})\n\t\t)\n\t].sort();\n\nexport const normalizeAbsoluteMobileConfig = (\n\tconfig: MobileConfig,\n\tprojectRoot: string\n): NormalizedAbsoluteMobileConfig => {\n\tconst appId = requireText(config.appId, 'mobile.appId');\n\tif (!APP_ID_PATTERN.test(appId)) {\n\t\tthrow new TypeError(\n\t\t\t'mobile.appId must use reverse-domain notation, for example com.example.app.'\n\t\t);\n\t}\n\tconst productionOrigin = normalizeProductionOrigin(\n\t\tconfig.server.productionOrigin\n\t);\n\tconst deepLinkScheme = (config.deepLinks?.scheme ?? appId)\n\t\t.trim()\n\t\t.toLowerCase();\n\tif (deepLinkScheme && !SCHEME_PATTERN.test(deepLinkScheme)) {\n\t\tthrow new TypeError(\n\t\t\t'mobile.deepLinks.scheme is not a valid URL scheme.'\n\t\t);\n\t}\n\n\treturn {\n\t\tandroidCertificateFingerprints: normalizeCertificateFingerprints(\n\t\t\tconfig.deepLinks?.android?.sha256CertificateFingerprints\n\t\t),\n\t\tappId,\n\t\tappleAppIdPrefix: normalizeAppleAppIdPrefix(\n\t\t\tconfig.deepLinks?.apple?.appIdPrefix\n\t\t),\n\t\tappName: requireText(config.appName, 'mobile.appName'),\n\t\tbundleDirectory: resolveProjectPath(\n\t\t\tprojectRoot,\n\t\t\tconfig.bundleDirectory ?? '.absolutejs/mobile/web',\n\t\t\t'mobile.bundleDirectory'\n\t\t),\n\t\tdeepLinkHosts: normalizeHosts(\n\t\t\tconfig.deepLinks?.hosts,\n\t\t\tproductionOrigin\n\t\t),\n\t\tdeepLinkScheme,\n\t\tengine: 'capacitor',\n\t\tentry: normalizeEntry(config.entry),\n\t\tiosVersion: normalizeIosVersion(config.ios?.version),\n\t\tnativeProjectDirectory: resolveProjectPath(\n\t\t\tprojectRoot,\n\t\t\tconfig.nativeProject?.directory ?? 'mobile',\n\t\t\t'mobile.nativeProject.directory'\n\t\t),\n\t\tplatforms: normalizePlatforms(config.platforms),\n\t\tproductionOrigin\n\t};\n};\n",
|
|
24
33
|
"import type { AbsoluteMobilePageFramework } from './pageProtocol';\n\nexport const ABSOLUTE_MOBILE_ROUTE_DETAIL = 'x-absolute-mobile' as const;\n\nexport type AbsoluteMobileBuildPageMetadata = {\n\tbundleKey: string;\n\tcontract: string;\n\tframework: AbsoluteMobilePageFramework;\n\tpageId: string;\n\tpropsSchemaHash: string;\n};\n\nconst frameworks = new Set<string>([\n\t'angular',\n\t'ember',\n\t'html',\n\t'htmx',\n\t'react',\n\t'svelte',\n\t'vue'\n]);\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n\ttypeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst isPageFramework = (\n\tvalue: unknown\n): value is AbsoluteMobilePageFramework =>\n\ttypeof value === 'string' && frameworks.has(value);\n\nexport const parseAbsoluteMobileBuildPageMetadata = (\n\tvalue: unknown\n): AbsoluteMobileBuildPageMetadata | undefined => {\n\tif (!isRecord(value)) return undefined;\n\tif (\n\t\ttypeof value.bundleKey !== 'string' ||\n\t\ttypeof value.contract !== 'string' ||\n\t\t!isPageFramework(value.framework) ||\n\t\ttypeof value.pageId !== 'string' ||\n\t\ttypeof value.propsSchemaHash !== 'string'\n\t) {\n\t\treturn undefined;\n\t}\n\n\treturn {\n\t\tbundleKey: value.bundleKey,\n\t\tcontract: value.contract,\n\t\tframework: value.framework,\n\t\tpageId: value.pageId,\n\t\tpropsSchemaHash: value.propsSchemaHash\n\t};\n};\n",
|
|
25
|
-
"import { readFile } from 'node:fs/promises';\nimport { join, resolve } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport type { Elysia } from 'elysia';\nimport type { MobileConfig } from '../../types/build';\nimport { buildAbsoluteMobileCompatibilityRelease } from './buildRelease';\nimport { materializeAbsoluteCapacitorWebBundle } from './capacitorBundle';\nimport { normalizeAbsoluteMobileConfig } from './config';\nimport {\n\tmaterializeAbsoluteMobileCompatibilityBundle,\n\treadAbsoluteMobileMaterializedReleases\n} from './materializedBundle';\nimport { ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION } from './pageProtocol';\nimport { retainAbsoluteMobileCompatibilityArtifacts } from './releaseArtifact';\nimport {\n\tprojectUsesAbsoluteSync,\n\tresolveAbsoluteMobileAuthManifest\n} from './nativeAuth';\n\nexport type FinalizeAbsoluteMobileBuildOptions = {\n\tbuildDirectory: string;\n\tconfigPath?: string;\n\tmobile: MobileConfig;\n\tproducerPath: string;\n\tprojectRoot: string;\n};\n\ntype ServerModule = {\n\tapp?: unknown;\n\tdefault?: unknown;\n\tserver?: unknown;\n};\n\ntype StringRecord = Record<string, string>;\n\nconst isElysiaApp = (\n\tvalue: unknown\n): value is Pick<Elysia, 'compile' | 'modules' | 'routes'> =>\n\ttypeof value === 'object' &&\n\tvalue !== null &&\n\ttypeof Reflect.get(value, 'compile') === 'function' &&\n\tArray.isArray(Reflect.get(value, 'routes'));\n\nconst isStringRecord = (value: unknown): value is StringRecord =>\n\ttypeof value === 'object' &&\n\tvalue !== null &&\n\t!Array.isArray(value) &&\n\tObject.values(value).every((entry) => typeof entry === 'string');\n\nconst serverExportName = (loaded: ServerModule, app: unknown) => {\n\tif (loaded.server === app) return 'server';\n\tif (loaded.app === app) return 'app';\n\n\treturn 'default';\n};\n\nconst restoreEnvironmentVariable = (\n\tname:\n\t\t| 'ABSOLUTE_BUILD_DIR'\n\t\t| 'ABSOLUTE_COMPILED_RUNTIME'\n\t\t| 'ABSOLUTE_CONFIG',\n\tprevious: string | undefined\n) => {\n\tif (previous !== undefined) process.env[name] = previous;\n\telse delete process.env[name];\n};\n\nconst requireRelease = <T>(releases: Map<string, T>, releaseId: string) => {\n\tconst release = releases.get(releaseId);\n\tif (!release) {\n\t\tthrow new TypeError(`Missing retained mobile release ${releaseId}.`);\n\t}\n\n\treturn release;\n};\n\nconst loadServerApp = async (producerPath: string) => {\n\tconst loaded: ServerModule = await import(\n\t\t`${pathToFileURL(producerPath).href}?absolute-mobile-capture=${crypto.randomUUID()}`\n\t);\n\tconst candidates = [loaded.server, loaded.app, loaded.default];\n\tconst app = candidates.find(isElysiaApp);\n\tif (!app) {\n\t\tthrow new TypeError(\n\t\t\t'Mobile builds require the server entry to export its Elysia app as server, app, or default.'\n\t\t);\n\t}\n\tconst exportName = serverExportName(loaded, app);\n\n\treturn { app, exportName };\n};\n\nexport const finalizeAbsoluteMobileCompatibilityBuild = async (\n\toptions: FinalizeAbsoluteMobileBuildOptions\n) => {\n\tconst buildDirectory = resolve(options.buildDirectory);\n\tconst mobile = normalizeAbsoluteMobileConfig(\n\t\toptions.mobile,\n\t\toptions.projectRoot\n\t);\n\tconst root = join(buildDirectory, '.absolutejs', 'mobile-compatibility');\n\tconst [manifestSource, previous] = await Promise.all([\n\t\treadFile(join(buildDirectory, 'manifest.json'), 'utf8'),\n\t\treadAbsoluteMobileMaterializedReleases(root)\n\t]);\n\tconst manifest: unknown = JSON.parse(manifestSource);\n\tif (!isStringRecord(manifest)) {\n\t\tthrow new TypeError(\n\t\t\t'Invalid AbsoluteJS build manifest for mobile capture.'\n\t\t);\n\t}\n\tconst previousBuildDirectory = process.env.ABSOLUTE_BUILD_DIR;\n\tconst previousCompiledRuntime = process.env.ABSOLUTE_COMPILED_RUNTIME;\n\tconst previousConfigPath = process.env.ABSOLUTE_CONFIG;\n\tprocess.env.ABSOLUTE_BUILD_DIR = buildDirectory;\n\tprocess.env.ABSOLUTE_COMPILED_RUNTIME = '1';\n\tif (options.configPath) {\n\t\tprocess.env.ABSOLUTE_CONFIG = resolve(\n\t\t\toptions.projectRoot,\n\t\t\toptions.configPath\n\t\t);\n\t}\n\tlet loaded: Awaited<ReturnType<typeof loadServerApp>>;\n\ttry {\n\t\tloaded = await loadServerApp(resolve(options.producerPath));\n\t} finally {\n\t\trestoreEnvironmentVariable(\n\t\t\t'ABSOLUTE_BUILD_DIR',\n\t\t\tpreviousBuildDirectory\n\t\t);\n\t\trestoreEnvironmentVariable(\n\t\t\t'ABSOLUTE_COMPILED_RUNTIME',\n\t\t\tpreviousCompiledRuntime\n\t\t);\n\t\trestoreEnvironmentVariable('ABSOLUTE_CONFIG', previousConfigPath);\n\t}\n\tconst current = await buildAbsoluteMobileCompatibilityRelease({\n\t\tapp: loaded.app,\n\t\tappId: mobile.appId,\n\t\tbuildDirectory,\n\t\tmanifest,\n\t\tpreviousArtifacts: previous.map(({ artifact }) => artifact),\n\t\tproducerExport: loaded.exportName,\n\t\tproducerPath: resolve(options.producerPath),\n\t\truntime: String(ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION)\n\t});\n\tconst auth = resolveAbsoluteMobileAuthManifest(options.projectRoot, mobile);\n\tconst sync =\n\t\tauth !== undefined && projectUsesAbsoluteSync(options.projectRoot);\n\tif (\n\t\tauth &&\n\t\t!loaded.app.routes.some(\n\t\t\t(route) => route.path === '/.well-known/openid-configuration'\n\t\t)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t'@absolutejs/auth is installed, but its OIDC provider is not mounted. Native authentication requires the auth oidc configuration so AbsoluteJS can provision a public PKCE client.'\n\t\t);\n\t}\n\tconst releasesById = new Map(\n\t\t[current, ...previous].map((release) => [\n\t\t\trelease.artifact.releaseId,\n\t\t\trelease\n\t\t])\n\t);\n\tconst retained = retainAbsoluteMobileCompatibilityArtifacts(\n\t\t[...releasesById.values()].map(({ artifact }) => artifact)\n\t);\n\tawait materializeAbsoluteMobileCompatibilityBundle({\n\t\tcurrentReleaseId: current.artifact.releaseId,\n\t\treleases: retained.map((artifact) =>\n\t\t\trequireRelease(releasesById, artifact.releaseId)\n\t\t),\n\t\troot\n\t});\n\tawait materializeAbsoluteCapacitorWebBundle({\n\t\tartifact: current.artifact,\n\t\t...(auth ? { auth } : {}),\n\t\tbuildDirectory,\n\t\tconfig: mobile,\n\t\t...(sync ? { sync: true } : {})\n\t});\n\n\treturn current.artifact;\n};\n",
|
|
34
|
+
"import { readFile } from 'node:fs/promises';\nimport { join, resolve } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport type { Elysia } from 'elysia';\nimport type { MobileConfig } from '../../types/build';\nimport { buildAbsoluteMobileCompatibilityRelease } from './buildRelease';\nimport { materializeAbsoluteCapacitorWebBundle } from './capacitorBundle';\nimport { normalizeAbsoluteMobileConfig } from './config';\nimport {\n\tmaterializeAbsoluteMobileCompatibilityBundle,\n\treadAbsoluteMobileMaterializedReleases\n} from './materializedBundle';\nimport { ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION } from './pageProtocol';\nimport { retainAbsoluteMobileCompatibilityArtifacts } from './releaseArtifact';\nimport {\n\tprojectUsesAbsoluteSync,\n\tresolveAbsoluteMobileAuthManifest\n} from './nativeAuth';\nimport { discoverAbsoluteSyncSchema } from './syncSchema';\nimport {\n\tassertAbsoluteDeviceCapabilityPackages,\n\tresolveAbsoluteDeviceCapabilityPlan\n} from './deviceCapabilities';\nimport {\n\tsyncAbsoluteExpoWebAssets,\n\twriteAbsoluteExpoProject\n} from './expoProject';\n\nexport type FinalizeAbsoluteMobileBuildOptions = {\n\tbuildDirectory: string;\n\tconfigPath?: string;\n\tmobile: MobileConfig;\n\tproducerPath: string;\n\tprojectRoot: string;\n};\n\ntype ServerModule = {\n\tapp?: unknown;\n\tdefault?: unknown;\n\tserver?: unknown;\n};\n\ntype StringRecord = Record<string, string>;\n\nconst isElysiaApp = (\n\tvalue: unknown\n): value is Pick<Elysia, 'compile' | 'modules' | 'routes'> =>\n\ttypeof value === 'object' &&\n\tvalue !== null &&\n\ttypeof Reflect.get(value, 'compile') === 'function' &&\n\tArray.isArray(Reflect.get(value, 'routes'));\n\nconst isStringRecord = (value: unknown): value is StringRecord =>\n\ttypeof value === 'object' &&\n\tvalue !== null &&\n\t!Array.isArray(value) &&\n\tObject.values(value).every((entry) => typeof entry === 'string');\n\nconst serverExportName = (loaded: ServerModule, app: unknown) => {\n\tif (loaded.server === app) return 'server';\n\tif (loaded.app === app) return 'app';\n\n\treturn 'default';\n};\n\nconst restoreEnvironmentVariable = (\n\tname:\n\t\t| 'ABSOLUTE_BUILD_DIR'\n\t\t| 'ABSOLUTE_COMPILED_RUNTIME'\n\t\t| 'ABSOLUTE_CONFIG',\n\tprevious: string | undefined\n) => {\n\tif (previous !== undefined) process.env[name] = previous;\n\telse delete process.env[name];\n};\n\nconst requireRelease = <T>(releases: Map<string, T>, releaseId: string) => {\n\tconst release = releases.get(releaseId);\n\tif (!release) {\n\t\tthrow new TypeError(`Missing retained mobile release ${releaseId}.`);\n\t}\n\n\treturn release;\n};\n\nconst loadServerApp = async (producerPath: string) => {\n\tconst loaded: ServerModule = await import(\n\t\t`${pathToFileURL(producerPath).href}?absolute-mobile-capture=${crypto.randomUUID()}`\n\t);\n\tconst candidates = [loaded.server, loaded.app, loaded.default];\n\tconst app = candidates.find(isElysiaApp);\n\tif (!app) {\n\t\tthrow new TypeError(\n\t\t\t'Mobile builds require the server entry to export its Elysia app as server, app, or default.'\n\t\t);\n\t}\n\tconst exportName = serverExportName(loaded, app);\n\n\treturn { app, exportName };\n};\n\nexport const finalizeAbsoluteMobileCompatibilityBuild = async (\n\toptions: FinalizeAbsoluteMobileBuildOptions\n) => {\n\tconst buildDirectory = resolve(options.buildDirectory);\n\tconst mobile = normalizeAbsoluteMobileConfig(\n\t\toptions.mobile,\n\t\toptions.projectRoot\n\t);\n\tconst root = join(buildDirectory, '.absolutejs', 'mobile-compatibility');\n\tconst [manifestSource, previous] = await Promise.all([\n\t\treadFile(join(buildDirectory, 'manifest.json'), 'utf8'),\n\t\treadAbsoluteMobileMaterializedReleases(root)\n\t]);\n\tconst manifest: unknown = JSON.parse(manifestSource);\n\tif (!isStringRecord(manifest)) {\n\t\tthrow new TypeError(\n\t\t\t'Invalid AbsoluteJS build manifest for mobile capture.'\n\t\t);\n\t}\n\tconst previousBuildDirectory = process.env.ABSOLUTE_BUILD_DIR;\n\tconst previousCompiledRuntime = process.env.ABSOLUTE_COMPILED_RUNTIME;\n\tconst previousConfigPath = process.env.ABSOLUTE_CONFIG;\n\tprocess.env.ABSOLUTE_BUILD_DIR = buildDirectory;\n\tprocess.env.ABSOLUTE_COMPILED_RUNTIME = '1';\n\tif (options.configPath) {\n\t\tprocess.env.ABSOLUTE_CONFIG = resolve(\n\t\t\toptions.projectRoot,\n\t\t\toptions.configPath\n\t\t);\n\t}\n\tlet loaded: Awaited<ReturnType<typeof loadServerApp>>;\n\ttry {\n\t\tloaded = await loadServerApp(resolve(options.producerPath));\n\t} finally {\n\t\trestoreEnvironmentVariable(\n\t\t\t'ABSOLUTE_BUILD_DIR',\n\t\t\tpreviousBuildDirectory\n\t\t);\n\t\trestoreEnvironmentVariable(\n\t\t\t'ABSOLUTE_COMPILED_RUNTIME',\n\t\t\tpreviousCompiledRuntime\n\t\t);\n\t\trestoreEnvironmentVariable('ABSOLUTE_CONFIG', previousConfigPath);\n\t}\n\tconst current = await buildAbsoluteMobileCompatibilityRelease({\n\t\tapp: loaded.app,\n\t\tappId: mobile.appId,\n\t\tbuildDirectory,\n\t\tmanifest,\n\t\tpreviousArtifacts: previous.map(({ artifact }) => artifact),\n\t\tproducerExport: loaded.exportName,\n\t\tproducerPath: resolve(options.producerPath),\n\t\truntime: String(ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION)\n\t});\n\tconst auth = resolveAbsoluteMobileAuthManifest(options.projectRoot, mobile);\n\tconst sync =\n\t\tauth !== undefined && projectUsesAbsoluteSync(options.projectRoot);\n\tconst syncSchema = sync\n\t\t? discoverAbsoluteSyncSchema(options.projectRoot)\n\t\t: undefined;\n\tconst deviceCapabilities = resolveAbsoluteDeviceCapabilityPlan(\n\t\toptions.projectRoot,\n\t\tmobile.engine\n\t);\n\tconst usesPush =\n\t\tdeviceCapabilities.capabilities.includes('pushNotifications');\n\tif (usesPush && !auth)\n\t\tthrow new TypeError(\n\t\t\t'Portable push notifications require @absolutejs/auth so provider tokens can be registered without exposing identity controls to page code.'\n\t\t);\n\tif (\n\t\tusesPush &&\n\t\t!loaded.app.routes.some(\n\t\t\t(route) =>\n\t\t\t\troute.path === '/auth/push' ||\n\t\t\t\troute.path === '/auth/mobile/push'\n\t\t)\n\t)\n\t\tthrow new TypeError(\n\t\t\t'@absolutejs/devices pushNotifications is used, but Auth push is not configured. Pass a trusted server-side registrar to auth({ push: ... }).'\n\t\t);\n\tif (mobile.engine === 'capacitor') {\n\t\tassertAbsoluteDeviceCapabilityPackages(\n\t\t\toptions.projectRoot,\n\t\t\tdeviceCapabilities\n\t\t);\n\t}\n\tif (\n\t\tauth &&\n\t\t!loaded.app.routes.some(\n\t\t\t(route) => route.path === '/.well-known/openid-configuration'\n\t\t)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t'@absolutejs/auth is installed, but its OIDC provider is not mounted. Native authentication requires the auth oidc configuration so AbsoluteJS can provision a public PKCE client.'\n\t\t);\n\t}\n\tconst releasesById = new Map(\n\t\t[current, ...previous].map((release) => [\n\t\t\trelease.artifact.releaseId,\n\t\t\trelease\n\t\t])\n\t);\n\tconst retained = retainAbsoluteMobileCompatibilityArtifacts(\n\t\t[...releasesById.values()].map(({ artifact }) => artifact)\n\t);\n\tawait materializeAbsoluteMobileCompatibilityBundle({\n\t\tcurrentReleaseId: current.artifact.releaseId,\n\t\treleases: retained.map((artifact) =>\n\t\t\trequireRelease(releasesById, artifact.releaseId)\n\t\t),\n\t\troot\n\t});\n\tawait materializeAbsoluteCapacitorWebBundle({\n\t\tartifact: current.artifact,\n\t\t...(auth ? { auth } : {}),\n\t\tbuildDirectory,\n\t\tconfig: mobile,\n\t\tdeviceCapabilities,\n\t\tprojectRoot: options.projectRoot,\n\t\t...(sync ? { sync: true } : {}),\n\t\t...(syncSchema\n\t\t\t? { syncSchema: { components: syncSchema.components } }\n\t\t\t: {})\n\t});\n\tif (mobile.engine === 'expo') {\n\t\tawait writeAbsoluteExpoProject(mobile, {\n\t\t\tprojectRoot: options.projectRoot\n\t\t});\n\t\tawait syncAbsoluteExpoWebAssets(mobile);\n\t}\n\n\treturn current.artifact;\n};\n",
|
|
26
35
|
"import { createHash } from 'node:crypto';\nimport { mkdir, readFile, writeFile } from 'node:fs/promises';\nimport { basename, dirname, extname, join, relative, resolve } from 'node:path';\nimport type { Elysia } from 'elysia';\nimport {\n\tABSOLUTE_MOBILE_ROUTE_DETAIL,\n\tparseAbsoluteMobileBuildPageMetadata,\n\ttype AbsoluteMobileBuildPageMetadata\n} from './buildMetadata';\nimport {\n\tcreateAbsoluteMobileCompatibilityArtifact,\n\ttype AbsoluteMobileCompatibilityArtifact,\n\ttype AbsoluteMobileCompatibilityPage,\n\ttype AbsoluteMobileCompatibilityRoute\n} from './releaseArtifact';\nimport type { AbsoluteMobileStoredCompatibilityRelease } from './artifactStore';\nimport { toPascal } from '../utils/stringModifiers';\n\nexport type AbsoluteMobileBuildReleaseOptions = {\n\tapp: Pick<Elysia, 'compile' | 'modules' | 'routes'>;\n\tappId: string;\n\tbuildDirectory: string;\n\tmanifest: Record<string, string>;\n\tpreviousArtifacts?: readonly AbsoluteMobileCompatibilityArtifact[];\n\tproducerExport?: string;\n\tproducerModule?: string;\n\tproducerPath: string;\n\truntime: string;\n};\n\nconst sha256 = (bytes: Uint8Array) =>\n\tcreateHash('sha256').update(bytes).digest('hex');\n\nconst STATIC_SCRIPT_PATTERN =\n\t/(<script\\b[^>]*?\\bsrc\\s*=\\s*[\"'])(\\/[^\"']+\\.(?:js|ts))([\"'][^>]*>)/giu;\n\nconst rewriteStaticScriptPaths = (\n\tsource: string,\n\tmanifest: Record<string, string>\n) =>\n\tsource.replace(\n\t\tSTATIC_SCRIPT_PATTERN,\n\t\t(match, prefix: string, path: string, suffix: string) => {\n\t\t\tif (path.endsWith('/htmx.min.js')) return match;\n\t\t\tconst key = toPascal(basename(path, extname(path)));\n\t\t\tconst builtPath = manifest[key];\n\n\t\t\treturn builtPath ? `${prefix}${builtPath}${suffix}` : match;\n\t\t}\n\t);\n\nconst readPageMetadata = (route: {\n\thooks?: { detail?: Record<string, unknown> };\n}) =>\n\tparseAbsoluteMobileBuildPageMetadata(\n\t\troute.hooks?.detail?.[ABSOLUTE_MOBILE_ROUTE_DETAIL]\n\t);\n\nconst resolveAssetPath = (buildDirectory: string, assetPath: string) => {\n\tconst resolvedBuildDirectory = resolve(buildDirectory);\n\tconst resolvedAsset = resolve(assetPath);\n\tif (resolvedAsset.startsWith(`${resolvedBuildDirectory}/`)) {\n\t\treturn resolvedAsset;\n\t}\n\n\treturn join(buildDirectory, assetPath.replace(/^\\/+/, ''));\n};\n\nconst pageFor = async (\n\tmetadata: AbsoluteMobileBuildPageMetadata,\n\tmanifest: Record<string, string>,\n\tbuildDirectory: string\n) => {\n\tconst assetPath = manifest[metadata.bundleKey];\n\tif (!assetPath) {\n\t\tthrow new TypeError(\n\t\t\t`Mobile page ${metadata.pageId} references missing manifest asset ${metadata.bundleKey}.`\n\t\t);\n\t}\n\tlet resolvedAssetPath = resolveAssetPath(buildDirectory, assetPath);\n\tif (metadata.framework === 'html' || metadata.framework === 'htmx') {\n\t\tconst source = await readFile(resolvedAssetPath, 'utf8');\n\t\tconst rewritten = rewriteStaticScriptPaths(source, manifest);\n\t\tconst documentHash = sha256(new TextEncoder().encode(rewritten));\n\t\tresolvedAssetPath = join(\n\t\t\tbuildDirectory,\n\t\t\t'.absolutejs',\n\t\t\t'mobile-pages',\n\t\t\t`${documentHash}.html`\n\t\t);\n\t\tawait mkdir(dirname(resolvedAssetPath), { recursive: true });\n\t\tawait writeFile(resolvedAssetPath, rewritten);\n\t}\n\tconst pageAssetKey = metadata.bundleKey.replace(/Index$/u, '');\n\tconst styleAssetPath = [\n\t\t`${pageAssetKey}BundledCSS`,\n\t\t`${pageAssetKey}CompiledCSS`\n\t]\n\t\t.map((key) => manifest[key])\n\t\t.find((path): path is string => typeof path === 'string');\n\tconst resolvedStylePath = styleAssetPath\n\t\t? resolveAssetPath(buildDirectory, styleAssetPath)\n\t\t: undefined;\n\tconst [bytes, styleBytes] = await Promise.all([\n\t\treadFile(resolvedAssetPath),\n\t\tresolvedStylePath ? readFile(resolvedStylePath) : undefined\n\t]);\n\tconst bundlePath = `/${relative(resolve(buildDirectory), resolvedAssetPath).replaceAll('\\\\', '/')}`;\n\tconst styleBundlePath = resolvedStylePath\n\t\t? `/${relative(resolve(buildDirectory), resolvedStylePath).replaceAll('\\\\', '/')}`\n\t\t: undefined;\n\n\treturn {\n\t\tbundleHash: sha256(bytes),\n\t\tbundlePath,\n\t\tcontract: metadata.contract,\n\t\tframework: metadata.framework,\n\t\tpageId: metadata.pageId,\n\t\tpropsSchemaHash: metadata.propsSchemaHash,\n\t\t...(styleBytes && styleBundlePath\n\t\t\t? {\n\t\t\t\t\tstyleBundleHash: sha256(styleBytes),\n\t\t\t\t\tstyleBundlePath\n\t\t\t\t}\n\t\t\t: {})\n\t} satisfies AbsoluteMobileCompatibilityPage;\n};\n\nexport const buildAbsoluteMobileCompatibilityRelease = async (\n\toptions: AbsoluteMobileBuildReleaseOptions\n): Promise<AbsoluteMobileStoredCompatibilityRelease> => {\n\tconst [captured, producerBytes] = await Promise.all([\n\t\tcaptureAbsoluteMobileRouteGraph(options.app),\n\t\treadFile(options.producerPath)\n\t]);\n\tif (captured.length === 0) {\n\t\tthrow new TypeError(\n\t\t\t'No instrumented AbsoluteJS mobile page routes were found in the finalized Elysia route graph.'\n\t\t);\n\t}\n\tconst metadataByPage = new Map<string, AbsoluteMobileBuildPageMetadata>();\n\tfor (const { metadata } of captured) {\n\t\tconst prior = metadataByPage.get(metadata.pageId);\n\t\tif (prior && JSON.stringify(prior) !== JSON.stringify(metadata)) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`Mobile page ${metadata.pageId} has inconsistent generated contracts.`\n\t\t\t);\n\t\t}\n\t\tmetadataByPage.set(metadata.pageId, metadata);\n\t}\n\tconst pages = await Promise.all(\n\t\t[...metadataByPage.values()].map((metadata) =>\n\t\t\tpageFor(metadata, options.manifest, options.buildDirectory)\n\t\t)\n\t);\n\tconst producerHash = sha256(producerBytes);\n\tconst appBuild = `ambuild_${sha256(\n\t\tnew TextEncoder().encode(\n\t\t\tJSON.stringify({\n\t\t\t\tpages: pages.map(\n\t\t\t\t\t({\n\t\t\t\t\t\tbundleHash,\n\t\t\t\t\t\tbundlePath,\n\t\t\t\t\t\tcontract,\n\t\t\t\t\t\tpageId,\n\t\t\t\t\t\tstyleBundleHash,\n\t\t\t\t\t\tstyleBundlePath\n\t\t\t\t\t}) => ({\n\t\t\t\t\t\tbundleHash,\n\t\t\t\t\t\tbundlePath,\n\t\t\t\t\t\tcontract,\n\t\t\t\t\t\tpageId,\n\t\t\t\t\t\t...(styleBundleHash && styleBundlePath\n\t\t\t\t\t\t\t? { styleBundleHash, styleBundlePath }\n\t\t\t\t\t\t\t: {})\n\t\t\t\t\t})\n\t\t\t\t),\n\t\t\t\tproducerHash,\n\t\t\t\truntime: options.runtime\n\t\t\t})\n\t\t)\n\t)}`;\n\tconst priorAppIds = new Set(\n\t\t(options.previousArtifacts ?? []).map(({ appId }) => appId)\n\t);\n\tif (\n\t\tpriorAppIds.size > 1 ||\n\t\t(priorAppIds.size === 1 && !priorAppIds.has(options.appId))\n\t) {\n\t\tthrow new TypeError(\n\t\t\t'Previous mobile compatibility artifacts belong to another app.'\n\t\t);\n\t}\n\tconst unchanged = options.previousArtifacts?.find(\n\t\t(artifact) =>\n\t\t\tartifact.appBuild === appBuild &&\n\t\t\tartifact.runtime === options.runtime\n\t);\n\tconst generation =\n\t\tunchanged?.generation ??\n\t\tMath.max(\n\t\t\t0,\n\t\t\t...(options.previousArtifacts ?? []).map(\n\t\t\t\t(artifact) => artifact.generation\n\t\t\t)\n\t\t) + 1;\n\tconst artifact = createAbsoluteMobileCompatibilityArtifact({\n\t\tappBuild,\n\t\tappId: options.appId,\n\t\tgeneration,\n\t\tpages,\n\t\tproducer: {\n\t\t\tbundleHash: producerHash,\n\t\t\tbytes: producerBytes.byteLength,\n\t\t\texportName: options.producerExport ?? 'server',\n\t\t\tmodule: options.producerModule ?? 'producer.js'\n\t\t},\n\t\troutes: captured.map(({ route }) => route),\n\t\truntime: options.runtime\n\t});\n\n\treturn { artifact, producer: new Blob([producerBytes]) };\n};\nexport const captureAbsoluteMobileRouteGraph = async (\n\tapp: Pick<Elysia, 'compile' | 'modules' | 'routes'>\n) => {\n\tif (app.modules) await app.modules;\n\tapp.compile();\n\tconst captured = app.routes.flatMap((route) => {\n\t\tconst metadata = readPageMetadata(route);\n\t\tif (!metadata || (route.method !== 'GET' && route.method !== 'HEAD')) {\n\t\t\treturn [];\n\t\t}\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tmetadata,\n\t\t\t\troute: {\n\t\t\t\t\tmethod: route.method === 'GET' ? 'GET' : 'HEAD',\n\t\t\t\t\tpageId: metadata.pageId,\n\t\t\t\t\tpattern: route.path\n\t\t\t\t} satisfies AbsoluteMobileCompatibilityRoute\n\t\t\t}\n\t\t];\n\t});\n\tconst identities = new Map<string, string>();\n\tfor (const { metadata, route } of captured) {\n\t\tconst prior = identities.get(`${route.method}:${route.pattern}`);\n\t\tif (prior && prior !== metadata.pageId) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`Mobile route ${route.method} ${route.pattern} resolves to multiple pages.`\n\t\t\t);\n\t\t}\n\t\tidentities.set(`${route.method}:${route.pattern}`, metadata.pageId);\n\t}\n\n\treturn captured;\n};\n",
|
|
27
|
-
"import {\n\tcp,\n\tcopyFile,\n\tmkdir,\n\tmkdtemp,\n\treadFile,\n\trename,\n\trm,\n\twriteFile\n} from 'node:fs/promises';\nimport { existsSync } from 'node:fs';\nimport { basename, dirname, extname, join, relative, resolve } from 'node:path';\nimport type { NormalizedAbsoluteMobileConfig } from './config';\nimport type {\n\tAbsoluteMobileCompatibilityArtifact,\n\tAbsoluteMobileCompatibilityPage\n} from './releaseArtifact';\nimport { resolveAbsoluteMobileRoute } from './routeMatcher';\nimport {\n\tABSOLUTE_MOBILE_CLIENT_MANIFEST_FORMAT,\n\ttype AbsoluteMobileClientManifest\n} from './transport';\nimport type { AbsoluteMobileAuthManifest } from './nativeAuth';\n\nexport type AbsoluteCapacitorBundleOptions = {\n\tartifact: AbsoluteMobileCompatibilityArtifact;\n\tauth?: AbsoluteMobileAuthManifest;\n\tbuildDirectory: string;\n\tconfig: NormalizedAbsoluteMobileConfig;\n\tsync?: boolean;\n};\n\nconst MANIFEST_FILE = 'absolute-mobile-manifest.json';\nconst BOOTSTRAP_FILE = 'absolute-mobile-bootstrap.js';\nconst INDEX_FILE = 'index.html';\nconst CLIENT_CSS_DEPENDENCY_PATTERN =\n\t/(?:@import\\s+(?:url\\(\\s*)?|url\\(\\s*)[\"']?((?:\\/|\\.\\.\\/|\\.\\/)[^\"')\\s]+)[\"']?\\s*\\)?/gu;\nconst CLIENT_MARKUP_DEPENDENCY_PATTERN =\n\t/<(?:script\\b[^>]*\\bsrc|link\\b[^>]*\\bhref|img\\b[^>]*\\bsrc|source\\b[^>]*\\bsrcset)\\s*=\\s*[\"']((?:\\/|\\.\\.\\/|\\.\\/)[^\"',\\s]+)/giu;\nconst CAPACITOR_CLIENT_FRAMEWORKS = new Set([\n\t'angular',\n\t'html',\n\t'htmx',\n\t'react',\n\t'svelte',\n\t'vue'\n]);\nconst CLIENT_ASSET_DIRECTORIES = ['assets', 'html', 'htmx', 'indexes'] as const;\n\nconst errorHasCode = (error: unknown, code: string) =>\n\ttypeof error === 'object' &&\n\terror !== null &&\n\tReflect.get(error, 'code') === code;\n\nconst shellBootstrapModule = () => {\n\tconst candidate = ['js', 'ts']\n\t\t.map((extension) =>\n\t\t\tjoin(import.meta.dir, `shellBootstrap.${extension}`)\n\t\t)\n\t\t.find(existsSync);\n\tif (candidate) return candidate;\n\n\tthrow new TypeError('AbsoluteJS mobile shell bootstrap module is missing.');\n};\n\nconst shellAuthModule = () => {\n\tconst candidate = ['js', 'ts']\n\t\t.map((extension) => join(import.meta.dir, `shellAuth.${extension}`))\n\t\t.find(existsSync);\n\tif (candidate) return candidate;\n\n\tthrow new TypeError('AbsoluteJS mobile auth shell module is missing.');\n};\n\nconst shellSyncModule = () => {\n\tconst candidate = ['js', 'ts']\n\t\t.map((extension) => join(import.meta.dir, `shellSync.${extension}`))\n\t\t.find(existsSync);\n\tif (candidate) return candidate;\n\n\tthrow new TypeError('AbsoluteJS mobile Sync shell module is missing.');\n};\n\nconst escapeHtml = (value: string) =>\n\tvalue\n\t\t.replaceAll('&', '&')\n\t\t.replaceAll('<', '<')\n\t\t.replaceAll('>', '>')\n\t\t.replaceAll('\"', '"');\n\nconst indexHtml = (appName: string) => `<!doctype html>\n<html>\n\t<head>\n\t\t<meta charset=\"utf-8\">\n\t\t<meta name=\"viewport\" content=\"width=device-width,initial-scale=1,viewport-fit=cover\">\n\t\t<meta name=\"color-scheme\" content=\"light dark\">\n\t\t<title>${escapeHtml(appName)}</title>\n\t</head>\n\t<body>\n\t\t<main id=\"absolute-mobile-status\" role=\"status\">Starting…</main>\n\t\t<script type=\"module\" src=\"./${BOOTSTRAP_FILE}\"></script>\n\t</body>\n</html>\n`;\n\nconst sourceAssetPath = (buildDirectory: string, bundlePath: string) => {\n\tconst root = resolve(buildDirectory);\n\tconst asset = resolve(root, bundlePath.replace(/^\\/+/, ''));\n\tif (!asset.startsWith(`${root}/`)) {\n\t\tthrow new TypeError('Mobile page bundle escaped the build directory.');\n\t}\n\n\treturn asset;\n};\n\nconst buildShellBootstrap = async (\n\tstaging: string,\n\tauth: boolean,\n\tsync: boolean\n) => {\n\tconst modulePath = shellBootstrapModule();\n\tconst authImport = auth\n\t\t? `import { createAbsoluteMobileShellAuth } from ${JSON.stringify(shellAuthModule())};\\n`\n\t\t: '';\n\tconst options = auth\n\t\t? `{ createAuth: createAbsoluteMobileShellAuth${sync ? ', installSync: installAbsoluteMobileShellSync' : ''} }`\n\t\t: '';\n\tconst syncImport = sync\n\t\t? `import { installAbsoluteMobileShellSync } from ${JSON.stringify(shellSyncModule())};\\n`\n\t\t: '';\n\tconst entryPath = join(staging, '.absolute-mobile-entry.ts');\n\tawait writeFile(\n\t\tentryPath,\n\t\t`import { startAbsoluteMobileShell } from ${JSON.stringify(modulePath)};\\n${authImport}${syncImport}void startAbsoluteMobileShell(${options});\\n`\n\t);\n\tconst build = await Bun.build({\n\t\tentrypoints: [entryPath],\n\t\tminify: true,\n\t\toutdir: staging,\n\t\ttarget: 'browser'\n\t});\n\tif (!build.success || build.outputs.length !== 1) {\n\t\tthrow new AggregateError(\n\t\t\tbuild.logs,\n\t\t\t'Failed to build the AbsoluteJS Capacitor shell.'\n\t\t);\n\t}\n\tawait rename(build.outputs[0]?.path ?? '', join(staging, BOOTSTRAP_FILE));\n\tawait rm(entryPath, { force: true });\n};\n\nconst removePreviousBundle = async (backup: string, moved: boolean) => {\n\tif (!moved) return;\n\tawait rm(backup, { force: true, recursive: true });\n};\n\nconst restorePreviousBundle = async (\n\tbackup: string,\n\tdestination: string,\n\tmoved: boolean\n) => {\n\tif (!moved) return;\n\tawait rename(backup, destination);\n};\n\nconst installBundle = async (staging: string, destination: string) => {\n\tconst backup = `${destination}.previous-${crypto.randomUUID()}`;\n\tlet movedPrevious = false;\n\ttry {\n\t\tawait rename(destination, backup);\n\t\tmovedPrevious = true;\n\t} catch (error) {\n\t\tif (!errorHasCode(error, 'ENOENT')) throw error;\n\t}\n\ttry {\n\t\tawait rename(staging, destination);\n\t\tawait removePreviousBundle(backup, movedPrevious);\n\t} catch (error) {\n\t\tawait restorePreviousBundle(backup, destination, movedPrevious);\n\n\t\tthrow error;\n\t}\n};\n\nconst copyClientPage = async (\n\tpage: AbsoluteMobileCompatibilityPage,\n\tbuildDirectory: string,\n\tstaging: string,\n\tcopiedDependencies: Set<string>\n) => {\n\tif (!CAPACITOR_CLIENT_FRAMEWORKS.has(page.framework)) {\n\t\tthrow new TypeError(\n\t\t\t`Capacitor client rendering does not yet support ${page.framework} page ${page.pageId}.`\n\t\t);\n\t}\n\tconst extension = extname(page.bundlePath) || '.js';\n\tconst localBundlePath = `./pages/${page.bundleHash}${extension}`;\n\tconst source = sourceAssetPath(buildDirectory, page.bundlePath);\n\tawait copyFile(source, join(staging, localBundlePath));\n\tawait copyAbsoluteClientDependencies(\n\t\tsource,\n\t\tbuildDirectory,\n\t\tstaging,\n\t\tcopiedDependencies\n\t);\n\n\tlet localStylePath: string | undefined;\n\tif (page.styleBundlePath && page.styleBundleHash) {\n\t\tconst styleExtension = extname(page.styleBundlePath) || '.css';\n\t\tlocalStylePath = `./styles/${page.styleBundleHash}${styleExtension}`;\n\t\tconst styleSource = sourceAssetPath(\n\t\t\tbuildDirectory,\n\t\t\tpage.styleBundlePath\n\t\t);\n\t\tawait mkdir(dirname(join(staging, localStylePath)), {\n\t\t\trecursive: true\n\t\t});\n\t\tawait copyFile(styleSource, join(staging, localStylePath));\n\t\tawait copyAbsoluteClientDependencies(\n\t\t\tstyleSource,\n\t\t\tbuildDirectory,\n\t\t\tstaging,\n\t\t\tcopiedDependencies\n\t\t);\n\t}\n\n\treturn {\n\t\t...page,\n\t\tlocalBundlePath,\n\t\t...(localStylePath ? { localStylePath } : {})\n\t};\n};\n\nconst absoluteClientImports = async (\n\tsourcePath: string,\n\tbuildDirectory: string\n) => {\n\tconst source = await readFile(sourcePath, 'utf8');\n\tconst extension = extname(sourcePath).toLowerCase();\n\tlet scriptLoader: 'js' | 'jsx' | 'ts' | 'tsx' | undefined;\n\tif (extension === '.tsx') scriptLoader = 'tsx';\n\telse if (extension === '.ts') scriptLoader = 'ts';\n\telse if (extension === '.jsx') scriptLoader = 'jsx';\n\telse if (['.js', '.mjs', '.cjs'].includes(extension)) scriptLoader = 'js';\n\tconst scriptImports = scriptLoader\n\t\t? new Bun.Transpiler({ loader: scriptLoader })\n\t\t\t\t.scanImports(source)\n\t\t\t\t.map(({ path }) => path)\n\t\t: [];\n\tconst cssImports =\n\t\textension === '.css'\n\t\t\t? [...source.matchAll(CLIENT_CSS_DEPENDENCY_PATTERN)].flatMap(\n\t\t\t\t\t(match) => match[1] ?? []\n\t\t\t\t)\n\t\t\t: [];\n\tconst markupImports =\n\t\textension === '.html'\n\t\t\t? [...source.matchAll(CLIENT_MARKUP_DEPENDENCY_PATTERN)].flatMap(\n\t\t\t\t\t(match) => match[1] ?? []\n\t\t\t\t)\n\t\t\t: [];\n\n\treturn [...scriptImports, ...cssImports, ...markupImports].flatMap(\n\t\t(specifier) => {\n\t\t\tif (!specifier) return [];\n\t\t\tif (\n\t\t\t\t!specifier.startsWith('/') &&\n\t\t\t\t!specifier.startsWith('./') &&\n\t\t\t\t!specifier.startsWith('../')\n\t\t\t) {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\tconst clean = specifier.split(/[?#]/u, 1)[0] ?? specifier;\n\t\t\tif (clean.startsWith('/')) return [clean];\n\t\t\tconst resolved = resolve(dirname(sourcePath), clean);\n\t\t\tconst root = resolve(buildDirectory);\n\t\t\tconst relativePath = relative(root, resolved).replaceAll('\\\\', '/');\n\t\t\tif (relativePath === '..' || relativePath.startsWith('../')) {\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t`Mobile client dependency escaped the build directory: ${specifier}`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn [`/${relativePath}`];\n\t\t}\n\t);\n};\n\nconst copyAbsoluteClientDependency = async (\n\tspecifier: string,\n\tbuildDirectory: string,\n\tstaging: string,\n\tcopied: Set<string>\n) => {\n\tif (copied.has(specifier)) return;\n\tcopied.add(specifier);\n\tconst source = sourceAssetPath(buildDirectory, specifier);\n\tconst destination = join(staging, specifier.replace(/^\\/+/, ''));\n\tawait mkdir(dirname(destination), { recursive: true });\n\tawait copyFile(source, destination);\n\tawait copyAbsoluteClientDependencies(\n\t\tsource,\n\t\tbuildDirectory,\n\t\tstaging,\n\t\tcopied\n\t);\n};\n\nconst copyAbsoluteClientDependencies = async (\n\tsourcePath: string,\n\tbuildDirectory: string,\n\tstaging: string,\n\tcopied: Set<string>\n) => {\n\tconst dependencies = await absoluteClientImports(\n\t\tsourcePath,\n\t\tbuildDirectory\n\t);\n\tawait Promise.all(\n\t\tdependencies.map((specifier) =>\n\t\t\tcopyAbsoluteClientDependency(\n\t\t\t\tspecifier,\n\t\t\t\tbuildDirectory,\n\t\t\t\tstaging,\n\t\t\t\tcopied\n\t\t\t)\n\t\t)\n\t);\n};\n\nexport const materializeAbsoluteCapacitorWebBundle = async (\n\toptions: AbsoluteCapacitorBundleOptions\n) => {\n\tif (\n\t\t!resolveAbsoluteMobileRoute(\n\t\t\toptions.artifact.routes,\n\t\t\tnew URL(options.config.entry, 'https://absolute.invalid').pathname\n\t\t)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t`mobile.entry ${options.config.entry} is not a captured mobile page route.`\n\t\t);\n\t}\n\tconst destination = options.config.bundleDirectory;\n\tawait mkdir(dirname(destination), { recursive: true });\n\tconst staging = await mkdtemp(\n\t\tjoin(dirname(destination), `.${basename(destination)}.stage-`)\n\t);\n\ttry {\n\t\tconst pageDirectory = join(staging, 'pages');\n\t\tawait mkdir(pageDirectory, { recursive: true });\n\t\tawait Promise.all(\n\t\t\tCLIENT_ASSET_DIRECTORIES.map((directory) => ({\n\t\t\t\tdestination: join(staging, directory),\n\t\t\t\tsource: join(options.buildDirectory, directory)\n\t\t\t}))\n\t\t\t\t.filter(({ source }) => existsSync(source))\n\t\t\t\t.map(({ destination: assetDestination, source }) =>\n\t\t\t\t\tcp(source, assetDestination, { recursive: true })\n\t\t\t\t)\n\t\t);\n\t\tconst copiedDependencies = new Set<string>();\n\t\tconst pages = await Promise.all(\n\t\t\toptions.artifact.pages.map((page) =>\n\t\t\t\tcopyClientPage(\n\t\t\t\t\tpage,\n\t\t\t\t\toptions.buildDirectory,\n\t\t\t\t\tstaging,\n\t\t\t\t\tcopiedDependencies\n\t\t\t\t)\n\t\t\t)\n\t\t);\n\t\tconst manifest = {\n\t\t\tappBuild: options.artifact.appBuild,\n\t\t\t...(options.auth ? { auth: options.auth } : {}),\n\t\t\tappId: options.config.appId,\n\t\t\tappName: options.config.appName,\n\t\t\tdeepLinkHosts: options.config.deepLinkHosts,\n\t\t\tdeepLinkScheme: options.config.deepLinkScheme,\n\t\t\tentry: options.config.entry,\n\t\t\tformat: ABSOLUTE_MOBILE_CLIENT_MANIFEST_FORMAT,\n\t\t\tpages,\n\t\t\tproductionOrigin: options.config.productionOrigin,\n\t\t\troutes: options.artifact.routes,\n\t\t\truntime: options.artifact.runtime,\n\t\t\t...(options.sync ? { sync: { socketTickets: true as const } } : {})\n\t\t} satisfies AbsoluteMobileClientManifest;\n\t\tawait Promise.all([\n\t\t\twriteFile(\n\t\t\t\tjoin(staging, MANIFEST_FILE),\n\t\t\t\t`${JSON.stringify(manifest, null, '\\t')}\\n`\n\t\t\t),\n\t\t\twriteFile(\n\t\t\t\tjoin(staging, INDEX_FILE),\n\t\t\t\tindexHtml(options.config.appName)\n\t\t\t),\n\t\t\tbuildShellBootstrap(\n\t\t\t\tstaging,\n\t\t\t\toptions.auth !== undefined,\n\t\t\t\toptions.auth !== undefined && options.sync === true\n\t\t\t)\n\t\t]);\n\t\tawait installBundle(staging, destination);\n\n\t\treturn manifest;\n\t} catch (error) {\n\t\tawait rm(staging, { force: true, recursive: true });\n\n\t\tthrow error;\n\t}\n};\n",
|
|
36
|
+
"import {\n\tcp,\n\tcopyFile,\n\tmkdir,\n\tmkdtemp,\n\treadFile,\n\trename,\n\trm,\n\twriteFile\n} from 'node:fs/promises';\nimport { existsSync } from 'node:fs';\nimport { basename, dirname, extname, join, relative, resolve } from 'node:path';\nimport type { NormalizedAbsoluteMobileConfig } from './config';\nimport type {\n\tAbsoluteMobileCompatibilityArtifact,\n\tAbsoluteMobileCompatibilityPage\n} from './releaseArtifact';\nimport { resolveAbsoluteMobileRoute } from './routeMatcher';\nimport {\n\tABSOLUTE_MOBILE_CLIENT_MANIFEST_FORMAT,\n\ttype AbsoluteMobileClientManifest\n} from './transport';\nimport type { AbsoluteMobileAuthManifest } from './nativeAuth';\nimport type { SyncLocalStoreSchemaBundle } from '@absolutejs/sync/client';\nimport type { AbsoluteDeviceCapabilityPlan } from './deviceCapabilities';\n\nexport type AbsoluteCapacitorBundleOptions = {\n\tartifact: AbsoluteMobileCompatibilityArtifact;\n\tauth?: AbsoluteMobileAuthManifest;\n\tbuildDirectory: string;\n\tconfig: NormalizedAbsoluteMobileConfig;\n\tdeviceCapabilities: AbsoluteDeviceCapabilityPlan;\n\tprojectRoot: string;\n\tsync?: boolean;\n\tsyncSchema?: SyncLocalStoreSchemaBundle;\n};\n\nconst MANIFEST_FILE = 'absolute-mobile-manifest.json';\nconst BOOTSTRAP_FILE = 'absolute-mobile-bootstrap.js';\nconst INDEX_FILE = 'index.html';\nconst CLIENT_CSS_DEPENDENCY_PATTERN =\n\t/(?:@import\\s+(?:url\\(\\s*)?|url\\(\\s*)[\"']?((?:\\/|\\.\\.\\/|\\.\\/)[^\"')\\s]+)[\"']?\\s*\\)?/gu;\nconst CLIENT_MARKUP_DEPENDENCY_PATTERN =\n\t/<(?:script\\b[^>]*\\bsrc|link\\b[^>]*\\bhref|img\\b[^>]*\\bsrc|source\\b[^>]*\\bsrcset)\\s*=\\s*[\"']((?:\\/|\\.\\.\\/|\\.\\/)[^\"',\\s]+)/giu;\nconst CAPACITOR_CLIENT_FRAMEWORKS = new Set([\n\t'angular',\n\t'html',\n\t'htmx',\n\t'react',\n\t'svelte',\n\t'vue'\n]);\nconst CLIENT_ASSET_DIRECTORIES = ['assets', 'html', 'htmx', 'indexes'] as const;\n\nconst errorHasCode = (error: unknown, code: string) =>\n\ttypeof error === 'object' &&\n\terror !== null &&\n\tReflect.get(error, 'code') === code;\n\nconst shellBootstrapModule = () => {\n\tconst candidate = ['js', 'ts']\n\t\t.map((extension) =>\n\t\t\tjoin(import.meta.dir, `shellBootstrap.${extension}`)\n\t\t)\n\t\t.find(existsSync);\n\tif (candidate) return candidate;\n\n\tthrow new TypeError('AbsoluteJS mobile shell bootstrap module is missing.');\n};\n\nconst shellAuthModule = () => {\n\tconst candidate = ['js', 'ts']\n\t\t.map((extension) => join(import.meta.dir, `shellAuth.${extension}`))\n\t\t.find(existsSync);\n\tif (candidate) return candidate;\n\n\tthrow new TypeError('AbsoluteJS mobile auth shell module is missing.');\n};\n\nconst shellExpoAuthModule = () => {\n\tconst candidate = ['js', 'ts']\n\t\t.map((extension) => join(import.meta.dir, `shellExpoAuth.${extension}`))\n\t\t.find(existsSync);\n\tif (candidate) return candidate;\n\n\tthrow new TypeError('AbsoluteJS Expo auth bridge module is missing.');\n};\n\nconst shellSyncModule = () => {\n\tconst candidate = ['js', 'ts']\n\t\t.map((extension) => join(import.meta.dir, `shellSync.${extension}`))\n\t\t.find(existsSync);\n\tif (candidate) return candidate;\n\n\tthrow new TypeError('AbsoluteJS mobile Sync shell module is missing.');\n};\n\nconst shellExpoSyncModule = () => {\n\tconst candidate = ['js', 'ts']\n\t\t.map((extension) => join(import.meta.dir, `shellExpoSync.${extension}`))\n\t\t.find(existsSync);\n\tif (candidate) return candidate;\n\n\tthrow new TypeError('AbsoluteJS Expo Sync bridge module is missing.');\n};\n\nconst shellPushModule = () => {\n\tconst candidate = ['js', 'ts']\n\t\t.map((extension) => join(import.meta.dir, `shellPush.${extension}`))\n\t\t.find(existsSync);\n\tif (candidate) return candidate;\n\n\tthrow new TypeError('AbsoluteJS mobile push shell module is missing.');\n};\n\nconst shellExpoDevicesModule = () => {\n\tconst candidate = ['js', 'ts']\n\t\t.map((extension) =>\n\t\t\tjoin(import.meta.dir, `shellExpoDevices.${extension}`)\n\t\t)\n\t\t.find(existsSync);\n\tif (candidate) return candidate;\n\n\tthrow new TypeError('AbsoluteJS Expo device bridge module is missing.');\n};\n\nconst escapeHtml = (value: string) =>\n\tvalue\n\t\t.replaceAll('&', '&')\n\t\t.replaceAll('<', '<')\n\t\t.replaceAll('>', '>')\n\t\t.replaceAll('\"', '"');\n\nconst contentSecurityPolicy = (productionOrigin: string) => {\n\tconst backend = new URL(productionOrigin);\n\tconst socketOrigin = `${backend.protocol === 'https:' ? 'wss:' : 'ws:'}//${backend.host}`;\n\n\treturn [\n\t\t\"default-src 'self' data: blob: https:\",\n\t\t\"base-uri 'none'\",\n\t\t\"object-src 'none'\",\n\t\t\"script-src 'self'\",\n\t\t\"style-src 'self' 'unsafe-inline'\",\n\t\t`connect-src 'self' ${backend.origin} ${socketOrigin}`,\n\t\t\"form-action 'none'\"\n\t].join('; ');\n};\n\nconst indexHtml = (\n\tappName: string,\n\tproductionOrigin: string\n) => `<!doctype html>\n<html>\n\t<head>\n\t\t<meta charset=\"utf-8\">\n\t\t<meta name=\"viewport\" content=\"width=device-width,initial-scale=1,viewport-fit=cover\">\n\t\t<meta name=\"color-scheme\" content=\"light dark\">\n\t\t<meta http-equiv=\"Content-Security-Policy\" content=\"${escapeHtml(contentSecurityPolicy(productionOrigin))}\">\n\t\t<title>${escapeHtml(appName)}</title>\n\t</head>\n\t<body>\n\t\t<main id=\"absolute-mobile-status\" role=\"status\">Starting…</main>\n\t\t<script type=\"module\" src=\"./${BOOTSTRAP_FILE}\"></script>\n\t</body>\n</html>\n`;\n\nconst sourceAssetPath = (buildDirectory: string, bundlePath: string) => {\n\tconst root = resolve(buildDirectory);\n\tconst asset = resolve(root, bundlePath.replace(/^\\/+/, ''));\n\tif (!asset.startsWith(`${root}/`)) {\n\t\tthrow new TypeError('Mobile page bundle escaped the build directory.');\n\t}\n\n\treturn asset;\n};\n\nconst importEntryTarget = (entry: unknown) => {\n\tif (typeof entry === 'string') return entry;\n\tif (typeof entry === 'object' && entry !== null)\n\t\treturn Reflect.get(entry, 'import');\n\n\treturn undefined;\n};\n\nconst resolveProjectImport = async (projectRoot: string, specifier: string) => {\n\tconst segments = specifier.split('/');\n\tconst packageName = specifier.startsWith('@')\n\t\t? segments.slice(0, 2).join('/')\n\t\t: (segments[0] ?? '');\n\tconst subpath = specifier.slice(packageName.length);\n\tconst packageDirectory = join(\n\t\tresolve(projectRoot),\n\t\t'node_modules',\n\t\tpackageName\n\t);\n\tconst manifest: unknown = JSON.parse(\n\t\tawait readFile(join(packageDirectory, 'package.json'), 'utf8')\n\t);\n\tconst exports =\n\t\ttypeof manifest === 'object' && manifest !== null\n\t\t\t? Reflect.get(manifest, 'exports')\n\t\t\t: undefined;\n\tconst entry =\n\t\ttypeof exports === 'object' && exports !== null\n\t\t\t? Reflect.get(exports, subpath ? `.${subpath}` : '.')\n\t\t\t: undefined;\n\tconst target = importEntryTarget(entry);\n\tif (typeof target !== 'string' || !target.startsWith('./'))\n\t\tthrow new TypeError(`${specifier} does not publish an import entry.`);\n\tconst resolved = resolve(packageDirectory, target);\n\tif (!resolved.startsWith(`${resolve(packageDirectory)}/`))\n\t\tthrow new TypeError(`${specifier} has an unsafe import entry.`);\n\n\treturn resolved;\n};\n\nconst buildShellBootstrap = async (\n\tstaging: string,\n\tauth: boolean,\n\tsync: boolean,\n\tstoragePrefix: string,\n\tengine: 'capacitor' | 'expo',\n\tdeviceCapabilities: AbsoluteDeviceCapabilityPlan,\n\tprojectRoot: string\n) => {\n\tconst capacitor = engine !== 'expo';\n\tconst shellCapabilities = capacitor ? deviceCapabilities.capabilities : [];\n\tconst modulePath = shellBootstrapModule();\n\tconst authFactory = capacitor\n\t\t? 'createAbsoluteMobileShellAuth'\n\t\t: 'createAbsoluteExpoShellAuth';\n\tconst syncFactory = capacitor\n\t\t? 'installAbsoluteMobileShellSync'\n\t\t: 'installAbsoluteExpoShellSync';\n\tconst authImport = auth\n\t\t? `import { ${authFactory} } from ${JSON.stringify(capacitor ? shellAuthModule() : shellExpoAuthModule())};\\n`\n\t\t: '';\n\tconst options = auth\n\t\t? `{ createAuth: ${authFactory}${sync ? `, installSync: ${syncFactory}` : ''} }`\n\t\t: '';\n\tconst syncImport = sync\n\t\t? `import { ${syncFactory} } from ${JSON.stringify(capacitor ? shellSyncModule() : shellExpoSyncModule())};\\n`\n\t\t: '';\n\tconst pushIndex = shellCapabilities.indexOf('pushNotifications');\n\tconst push = pushIndex !== -1;\n\tconst pushImport = push\n\t\t? `import { createAbsoluteMobileShellPush } from ${JSON.stringify(shellPushModule())};\\n`\n\t\t: '';\n\tconst capabilityImports = (\n\t\tawait Promise.all(\n\t\t\tshellCapabilities.map(async (name, index) => {\n\t\t\t\tconst provider = deviceCapabilities.providers[name];\n\t\t\t\tif (!provider)\n\t\t\t\t\tthrow new TypeError(\n\t\t\t\t\t\t`Missing device capability provider ${name}.`\n\t\t\t\t\t);\n\n\t\t\t\treturn `import { ${provider.factory} as absoluteDeviceCapability${index} } from ${JSON.stringify(await resolveProjectImport(projectRoot, provider.module))};`;\n\t\t\t})\n\t\t)\n\t).join('\\n');\n\tconst pushSetup = push\n\t\t? `const absoluteMobilePush = createAbsoluteMobileShellPush();\\nconst absoluteMobilePushCapability = absoluteDeviceCapability${pushIndex}(absoluteMobilePush.capabilityOptions);\\n`\n\t\t: '';\n\tconst capabilityOptions = shellCapabilities\n\t\t.map(\n\t\t\t(name, index) =>\n\t\t\t\t`${JSON.stringify(name)}: ${name === 'pushNotifications' ? 'absoluteMobilePushCapability' : `absoluteDeviceCapability${index}()`}`\n\t\t)\n\t\t.join(', ');\n\tconst entryPath = join(staging, '.absolute-mobile-entry.ts');\n\tconst baseAdapterModule = capacitor\n\t\t? await resolveProjectImport(\n\t\t\t\tprojectRoot,\n\t\t\t\t'@absolutejs/devices-capacitor'\n\t\t\t)\n\t\t: shellExpoDevicesModule();\n\tconst adapterImport = capacitor\n\t\t? `import { installCapacitorDeviceAdapterIfNative } from ${JSON.stringify(baseAdapterModule)};`\n\t\t: `import { createAbsoluteExpoBridgeFetch, installAbsoluteExpoWebDeviceAdapter } from ${JSON.stringify(baseAdapterModule)};`;\n\tconst adapterInstall = capacitor\n\t\t? `installCapacitorDeviceAdapterIfNative({ storagePrefix: ${JSON.stringify(storagePrefix)}${capabilityOptions ? `, ${capabilityOptions}` : ''} });`\n\t\t: `installAbsoluteExpoWebDeviceAdapter(${JSON.stringify(deviceCapabilities.capabilities)});`;\n\tlet shellOptions = auth\n\t\t? options\n\t\t: '{ createFetch: createAbsoluteExpoBridgeFetch }';\n\tif (capacitor) shellOptions = options;\n\tif (push) {\n\t\tshellOptions = `{ createAuth: (config, options) => createAbsoluteMobileShellAuth(config, options), beforeSignOut: absoluteMobilePush.beforeSignOut, connectPush: (auth) => absoluteMobilePush.connect(auth, absoluteMobilePushCapability)${sync ? `, installSync: ${syncFactory}` : ''} }`;\n\t}\n\tawait writeFile(\n\t\tentryPath,\n\t\t`import { startAbsoluteMobileShell } from ${JSON.stringify(modulePath)};\\n${adapterImport}\\n${authImport}${syncImport}${pushImport}${capabilityImports}\\n${pushSetup}${adapterInstall}\\nvoid startAbsoluteMobileShell(${shellOptions});\\n`\n\t);\n\tconst build = await Bun.build({\n\t\tentrypoints: [entryPath],\n\t\tminify: true,\n\t\toutdir: staging,\n\t\ttarget: 'browser'\n\t});\n\tif (!build.success || build.outputs.length !== 1) {\n\t\tthrow new AggregateError(\n\t\t\tbuild.logs,\n\t\t\t'Failed to build the AbsoluteJS Capacitor shell.'\n\t\t);\n\t}\n\tawait rename(build.outputs[0]?.path ?? '', join(staging, BOOTSTRAP_FILE));\n\tawait rm(entryPath, { force: true });\n};\n\nconst removePreviousBundle = async (backup: string, moved: boolean) => {\n\tif (!moved) return;\n\tawait rm(backup, { force: true, recursive: true });\n};\n\nconst restorePreviousBundle = async (\n\tbackup: string,\n\tdestination: string,\n\tmoved: boolean\n) => {\n\tif (!moved) return;\n\tawait rename(backup, destination);\n};\n\nconst installBundle = async (staging: string, destination: string) => {\n\tconst backup = `${destination}.previous-${crypto.randomUUID()}`;\n\tlet movedPrevious = false;\n\ttry {\n\t\tawait rename(destination, backup);\n\t\tmovedPrevious = true;\n\t} catch (error) {\n\t\tif (!errorHasCode(error, 'ENOENT')) throw error;\n\t}\n\ttry {\n\t\tawait rename(staging, destination);\n\t\tawait removePreviousBundle(backup, movedPrevious);\n\t} catch (error) {\n\t\tawait restorePreviousBundle(backup, destination, movedPrevious);\n\n\t\tthrow error;\n\t}\n};\n\nconst copyClientPage = async (\n\tpage: AbsoluteMobileCompatibilityPage,\n\tbuildDirectory: string,\n\tstaging: string,\n\tcopiedDependencies: Set<string>\n) => {\n\tif (!CAPACITOR_CLIENT_FRAMEWORKS.has(page.framework)) {\n\t\tthrow new TypeError(\n\t\t\t`Capacitor client rendering does not yet support ${page.framework} page ${page.pageId}.`\n\t\t);\n\t}\n\tconst extension = extname(page.bundlePath) || '.js';\n\tconst localBundlePath = `./pages/${page.bundleHash}${extension}`;\n\tconst source = sourceAssetPath(buildDirectory, page.bundlePath);\n\tawait copyFile(source, join(staging, localBundlePath));\n\tawait copyAbsoluteClientDependencies(\n\t\tsource,\n\t\tbuildDirectory,\n\t\tstaging,\n\t\tcopiedDependencies\n\t);\n\n\tlet localStylePath: string | undefined;\n\tif (page.styleBundlePath && page.styleBundleHash) {\n\t\tconst styleExtension = extname(page.styleBundlePath) || '.css';\n\t\tlocalStylePath = `./styles/${page.styleBundleHash}${styleExtension}`;\n\t\tconst styleSource = sourceAssetPath(\n\t\t\tbuildDirectory,\n\t\t\tpage.styleBundlePath\n\t\t);\n\t\tawait mkdir(dirname(join(staging, localStylePath)), {\n\t\t\trecursive: true\n\t\t});\n\t\tawait copyFile(styleSource, join(staging, localStylePath));\n\t\tawait copyAbsoluteClientDependencies(\n\t\t\tstyleSource,\n\t\t\tbuildDirectory,\n\t\t\tstaging,\n\t\t\tcopiedDependencies\n\t\t);\n\t}\n\n\treturn {\n\t\t...page,\n\t\tlocalBundlePath,\n\t\t...(localStylePath ? { localStylePath } : {})\n\t};\n};\n\nconst absoluteClientImports = async (\n\tsourcePath: string,\n\tbuildDirectory: string\n) => {\n\tconst source = await readFile(sourcePath, 'utf8');\n\tconst extension = extname(sourcePath).toLowerCase();\n\tlet scriptLoader: 'js' | 'jsx' | 'ts' | 'tsx' | undefined;\n\tif (extension === '.tsx') scriptLoader = 'tsx';\n\telse if (extension === '.ts') scriptLoader = 'ts';\n\telse if (extension === '.jsx') scriptLoader = 'jsx';\n\telse if (['.js', '.mjs', '.cjs'].includes(extension)) scriptLoader = 'js';\n\tconst scriptImports = scriptLoader\n\t\t? new Bun.Transpiler({ loader: scriptLoader })\n\t\t\t\t.scanImports(source)\n\t\t\t\t.map(({ path }) => path)\n\t\t: [];\n\tconst cssImports =\n\t\textension === '.css'\n\t\t\t? [...source.matchAll(CLIENT_CSS_DEPENDENCY_PATTERN)].flatMap(\n\t\t\t\t\t(match) => match[1] ?? []\n\t\t\t\t)\n\t\t\t: [];\n\tconst markupImports =\n\t\textension === '.html'\n\t\t\t? [...source.matchAll(CLIENT_MARKUP_DEPENDENCY_PATTERN)].flatMap(\n\t\t\t\t\t(match) => match[1] ?? []\n\t\t\t\t)\n\t\t\t: [];\n\n\treturn [...scriptImports, ...cssImports, ...markupImports].flatMap(\n\t\t(specifier) => {\n\t\t\tif (!specifier) return [];\n\t\t\tif (\n\t\t\t\t!specifier.startsWith('/') &&\n\t\t\t\t!specifier.startsWith('./') &&\n\t\t\t\t!specifier.startsWith('../')\n\t\t\t) {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\tconst clean = specifier.split(/[?#]/u, 1)[0] ?? specifier;\n\t\t\tif (clean.startsWith('/')) return [clean];\n\t\t\tconst resolved = resolve(dirname(sourcePath), clean);\n\t\t\tconst root = resolve(buildDirectory);\n\t\t\tconst relativePath = relative(root, resolved).replaceAll('\\\\', '/');\n\t\t\tif (relativePath === '..' || relativePath.startsWith('../')) {\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t`Mobile client dependency escaped the build directory: ${specifier}`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn [`/${relativePath}`];\n\t\t}\n\t);\n};\n\nconst copyAbsoluteClientDependency = async (\n\tspecifier: string,\n\tbuildDirectory: string,\n\tstaging: string,\n\tcopied: Set<string>\n) => {\n\tif (copied.has(specifier)) return;\n\tcopied.add(specifier);\n\tconst source = sourceAssetPath(buildDirectory, specifier);\n\tconst destination = join(staging, specifier.replace(/^\\/+/, ''));\n\tawait mkdir(dirname(destination), { recursive: true });\n\tawait copyFile(source, destination);\n\tawait copyAbsoluteClientDependencies(\n\t\tsource,\n\t\tbuildDirectory,\n\t\tstaging,\n\t\tcopied\n\t);\n};\n\nconst copyAbsoluteClientDependencies = async (\n\tsourcePath: string,\n\tbuildDirectory: string,\n\tstaging: string,\n\tcopied: Set<string>\n) => {\n\tconst dependencies = await absoluteClientImports(\n\t\tsourcePath,\n\t\tbuildDirectory\n\t);\n\tawait Promise.all(\n\t\tdependencies.map((specifier) =>\n\t\t\tcopyAbsoluteClientDependency(\n\t\t\t\tspecifier,\n\t\t\t\tbuildDirectory,\n\t\t\t\tstaging,\n\t\t\t\tcopied\n\t\t\t)\n\t\t)\n\t);\n};\n\nexport const materializeAbsoluteCapacitorWebBundle = async (\n\toptions: AbsoluteCapacitorBundleOptions\n) => {\n\tif (\n\t\t!resolveAbsoluteMobileRoute(\n\t\t\toptions.artifact.routes,\n\t\t\tnew URL(options.config.entry, 'https://absolute.invalid').pathname\n\t\t)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t`mobile.entry ${options.config.entry} is not a captured mobile page route.`\n\t\t);\n\t}\n\tconst destination = options.config.bundleDirectory;\n\tawait mkdir(dirname(destination), { recursive: true });\n\tconst staging = await mkdtemp(\n\t\tjoin(dirname(destination), `.${basename(destination)}.stage-`)\n\t);\n\ttry {\n\t\tconst pageDirectory = join(staging, 'pages');\n\t\tawait mkdir(pageDirectory, { recursive: true });\n\t\tawait Promise.all(\n\t\t\tCLIENT_ASSET_DIRECTORIES.map((directory) => ({\n\t\t\t\tdestination: join(staging, directory),\n\t\t\t\tsource: join(options.buildDirectory, directory)\n\t\t\t}))\n\t\t\t\t.filter(({ source }) => existsSync(source))\n\t\t\t\t.map(({ destination: assetDestination, source }) =>\n\t\t\t\t\tcp(source, assetDestination, { recursive: true })\n\t\t\t\t)\n\t\t);\n\t\tconst copiedDependencies = new Set<string>();\n\t\tconst pages = await Promise.all(\n\t\t\toptions.artifact.pages.map((page) =>\n\t\t\t\tcopyClientPage(\n\t\t\t\t\tpage,\n\t\t\t\t\toptions.buildDirectory,\n\t\t\t\t\tstaging,\n\t\t\t\t\tcopiedDependencies\n\t\t\t\t)\n\t\t\t)\n\t\t);\n\t\tconst manifest = {\n\t\t\tappBuild: options.artifact.appBuild,\n\t\t\t...(options.auth ? { auth: options.auth } : {}),\n\t\t\tappId: options.config.appId,\n\t\t\tappName: options.config.appName,\n\t\t\tdeepLinkHosts: options.config.deepLinkHosts,\n\t\t\tdeepLinkScheme: options.config.deepLinkScheme,\n\t\t\tdeviceCapabilities: options.deviceCapabilities.capabilities,\n\t\t\tentry: options.config.entry,\n\t\t\tformat: ABSOLUTE_MOBILE_CLIENT_MANIFEST_FORMAT,\n\t\t\tpages,\n\t\t\tproductionOrigin: options.config.productionOrigin,\n\t\t\troutes: options.artifact.routes,\n\t\t\truntime: options.artifact.runtime,\n\t\t\t...(options.sync\n\t\t\t\t? {\n\t\t\t\t\t\tsync: {\n\t\t\t\t\t\t\tbackground: {\n\t\t\t\t\t\t\t\tendpoint: new URL(\n\t\t\t\t\t\t\t\t\t'/__absolute/sync/background',\n\t\t\t\t\t\t\t\t\toptions.config.productionOrigin\n\t\t\t\t\t\t\t\t).href,\n\t\t\t\t\t\t\t\tintervalMinutes: 15\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tsocketTickets: true as const,\n\t\t\t\t\t\t\tstorageSchema: options.syncSchema ?? {\n\t\t\t\t\t\t\t\tcomponents: [\n\t\t\t\t\t\t\t\t\t{ id: '@absolutejs/app', version: 1 }\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t: {})\n\t\t} satisfies AbsoluteMobileClientManifest;\n\t\tawait Promise.all([\n\t\t\twriteFile(\n\t\t\t\tjoin(staging, MANIFEST_FILE),\n\t\t\t\t`${JSON.stringify(manifest, null, '\\t')}\\n`\n\t\t\t),\n\t\t\twriteFile(\n\t\t\t\tjoin(staging, INDEX_FILE),\n\t\t\t\tindexHtml(\n\t\t\t\t\toptions.config.appName,\n\t\t\t\t\toptions.config.productionOrigin\n\t\t\t\t)\n\t\t\t),\n\t\t\tbuildShellBootstrap(\n\t\t\t\tstaging,\n\t\t\t\toptions.auth !== undefined,\n\t\t\t\toptions.auth !== undefined && options.sync === true,\n\t\t\t\t`absolutejs.${options.auth?.clientId ?? options.config.appId}.`,\n\t\t\t\toptions.config.engine,\n\t\t\t\toptions.deviceCapabilities,\n\t\t\t\toptions.projectRoot\n\t\t\t)\n\t\t]);\n\t\tawait installBundle(staging, destination);\n\n\t\treturn manifest;\n\t} catch (error) {\n\t\tawait rm(staging, { force: true, recursive: true });\n\n\t\tthrow error;\n\t}\n};\n",
|
|
28
37
|
"import type { AbsoluteMobileCompatibilityRoute } from './releaseArtifact';\n\nconst REGEXP_SPECIAL_CHARACTERS = /[.*+?^${}()|[\\]\\\\]/g;\n\nconst routeSegmentPattern = (segment: string) => {\n\tif (segment === '*') return '.*';\n\tif (segment.startsWith(':') && segment.endsWith('?')) return '[^/]*';\n\tif (segment.startsWith(':')) return '[^/]+';\n\n\treturn segment.replace(REGEXP_SPECIAL_CHARACTERS, '\\\\$&');\n};\n\nexport const matchesAbsoluteMobileRoutePattern = (\n\tpattern: string,\n\tpathname: string\n) => {\n\tconst expression = pattern.split('/').map(routeSegmentPattern).join('/');\n\n\treturn new RegExp(`^${expression}/?$`).test(pathname);\n};\n\nexport const resolveAbsoluteMobileRoute = (\n\troutes: readonly AbsoluteMobileCompatibilityRoute[],\n\tpathname: string,\n\tmethod: 'GET' | 'HEAD' = 'GET'\n) =>\n\troutes.find(\n\t\t(route) =>\n\t\t\troute.method === method &&\n\t\t\tmatchesAbsoluteMobileRoutePattern(route.pattern, pathname)\n\t);\n",
|
|
29
38
|
"import type { AbsoluteMobileCompatibilityPage } from './releaseArtifact';\n\nexport type AbsoluteMobileProducerContext = {\n\tpage: AbsoluteMobileCompatibilityPage;\n\treleaseId: string;\n};\n\nexport const ABSOLUTE_MOBILE_PRODUCER_STORAGE_KEY = Symbol.for(\n\t'absolutejs.mobileProducerAsyncLocalStorage'\n);\n\nconst frameworks = new Set<string>([\n\t'angular',\n\t'ember',\n\t'html',\n\t'htmx',\n\t'react',\n\t'svelte',\n\t'vue'\n]);\n\nconst isCompatibilityPage = (\n\tvalue: unknown\n): value is AbsoluteMobileCompatibilityPage =>\n\ttypeof value === 'object' &&\n\tvalue !== null &&\n\t'bundleHash' in value &&\n\ttypeof value.bundleHash === 'string' &&\n\t'contract' in value &&\n\ttypeof value.contract === 'string' &&\n\t'framework' in value &&\n\ttypeof value.framework === 'string' &&\n\tframeworks.has(value.framework) &&\n\t'pageId' in value &&\n\ttypeof value.pageId === 'string' &&\n\t'propsSchemaHash' in value &&\n\ttypeof value.propsSchemaHash === 'string';\n\nexport const getCurrentAbsoluteMobileProducerContext = () => {\n\tconst value: unknown = Reflect.get(\n\t\tglobalThis,\n\t\tABSOLUTE_MOBILE_PRODUCER_STORAGE_KEY\n\t);\n\tif (\n\t\ttypeof value !== 'object' ||\n\t\tvalue === null ||\n\t\t!('getStore' in value) ||\n\t\ttypeof value.getStore !== 'function'\n\t) {\n\t\treturn undefined;\n\t}\n\tconst context: unknown = value.getStore();\n\tif (\n\t\ttypeof context !== 'object' ||\n\t\tcontext === null ||\n\t\t!('page' in context) ||\n\t\t!isCompatibilityPage(context.page) ||\n\t\t!('releaseId' in context) ||\n\t\ttypeof context.releaseId !== 'string'\n\t) {\n\t\treturn undefined;\n\t}\n\n\treturn { page: context.page, releaseId: context.releaseId };\n};\n",
|
|
30
|
-
"import {\n\tgetCurrentAbsoluteMobileProducerContext,\n\ttype AbsoluteMobileProducerContext\n} from './producerContextState';\n\nexport const ABSOLUTE_MOBILE_PAGE_MEDIA_TYPE =\n\t'application/vnd.absolute.page+json';\nexport const ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION = 1 as const;\nconst BAD_REQUEST_STATUS = 400;\nconst OK_STATUS = 200;\nconst SERVER_ERROR_STATUS = 500;\nconst UPGRADE_REQUIRED_STATUS = 426;\n\nexport const MOBILE_PAGE_REQUEST_HEADERS = {\n\tappBuild: 'x-absolute-mobile-app-build',\n\tpageBundle: 'x-absolute-mobile-page-bundle',\n\tpageContracts: 'x-absolute-mobile-page-contracts',\n\tpageId: 'x-absolute-mobile-page-id',\n\tprotocol: 'x-absolute-mobile-protocol',\n\truntime: 'x-absolute-mobile-runtime'\n} as const;\n\nexport type AbsoluteMobilePageFramework =\n\t| 'angular'\n\t| 'ember'\n\t| 'html'\n\t| 'htmx'\n\t| 'react'\n\t| 'svelte'\n\t| 'vue';\n\nexport type AbsoluteMobilePageClient = {\n\tappBuild: string;\n\tpageBundle: string;\n\tpageContracts: string[];\n\tpageId: string;\n\tprotocol: number;\n\truntime: string;\n};\n\nexport type AbsoluteMobilePageRepresentation<Props> = {\n\t/** Stable data contract understood by an embedded page bundle. */\n\tcontract: string;\n\t/**\n\t * Adapts the current route props to an older compatible contract. The\n\t * current representation normally uses the identity function.\n\t */\n\tmapProps: (props: Props) => Record<string, unknown>;\n};\n\nexport type AbsoluteMobilePageCompatibility<Props> = {\n\tframework: AbsoluteMobilePageFramework;\n\tpageId: string;\n\t/** Newest representation first, followed by retained compatibility forms. */\n\trepresentations: readonly AbsoluteMobilePageRepresentation<Props>[];\n\t/** Current runtime plus every retained compatible runtime generation. */\n\truntimes: readonly string[];\n};\n\nexport type AbsoluteMobilePageResult = {\n\tkind: 'page';\n\tcontract: string;\n\tframework: AbsoluteMobilePageFramework;\n\tpageId: string;\n\tprops: Record<string, unknown>;\n\tstatus: number;\n};\n\nexport type AbsoluteMobileUpgradeReason =\n\t| 'app-release'\n\t| 'page-contract'\n\t| 'protocol'\n\t| 'runtime';\n\nexport type AbsoluteMobileUpgradeRequiredResult = {\n\tkind: 'upgrade-required';\n\treason: AbsoluteMobileUpgradeReason;\n\tpageId: string;\n\tsupportedContracts?: string[];\n\tsupportedRuntimes?: string[];\n};\n\nexport type AbsoluteMobileInvalidRequestResult = {\n\tkind: 'invalid-request';\n\tmessage: string;\n};\n\nexport type AbsoluteMobilePageErrorResult = {\n\tcode: 'representation-failed';\n\tkind: 'error';\n\tpageId: string;\n\tstatus: typeof SERVER_ERROR_STATUS;\n};\n\nexport type AbsoluteMobilePageEnvelope = {\n\tprotocol: typeof ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION;\n\tresponse:\n\t\t| AbsoluteMobilePageErrorResult\n\t\t| AbsoluteMobileInvalidRequestResult\n\t\t| AbsoluteMobilePageResult\n\t\t| AbsoluteMobileUpgradeRequiredResult;\n};\n\ntype ParsedMobilePageRequest =\n\t| { kind: 'not-mobile' }\n\t| { kind: 'invalid'; message: string }\n\t| { kind: 'mobile'; client: AbsoluteMobilePageClient };\n\ntype FinalizeAbsoluteMobilePageInput<Props> = {\n\tcompatibility: AbsoluteMobilePageCompatibility<Props>;\n\tprops: Props;\n\trequest: Request | undefined;\n\tstatus?: number;\n};\n\nconst parseMediaType = (value: string) =>\n\tvalue.split(';', 1)[0]?.trim().toLowerCase();\n\nexport const acceptsAbsoluteMobilePage = (request: Request | undefined) => {\n\tif (!request) return false;\n\n\treturn (request.headers.get('accept') ?? '')\n\t\t.split(',')\n\t\t.some(\n\t\t\t(value) => parseMediaType(value) === ABSOLUTE_MOBILE_PAGE_MEDIA_TYPE\n\t\t);\n};\n\nconst readRequiredHeader = (request: Request, name: string) => {\n\tconst value = request.headers.get(name)?.trim();\n\n\treturn value ? value : undefined;\n};\n\nexport const parseAbsoluteMobilePageRequest = (\n\trequest: Request | undefined\n): ParsedMobilePageRequest => {\n\tif (!request || !acceptsAbsoluteMobilePage(request)) {\n\t\treturn { kind: 'not-mobile' };\n\t}\n\n\tconst protocolValue = readRequiredHeader(\n\t\trequest,\n\t\tMOBILE_PAGE_REQUEST_HEADERS.protocol\n\t);\n\tconst runtime = readRequiredHeader(\n\t\trequest,\n\t\tMOBILE_PAGE_REQUEST_HEADERS.runtime\n\t);\n\tconst appBuild = readRequiredHeader(\n\t\trequest,\n\t\tMOBILE_PAGE_REQUEST_HEADERS.appBuild\n\t);\n\tconst pageBundle = readRequiredHeader(\n\t\trequest,\n\t\tMOBILE_PAGE_REQUEST_HEADERS.pageBundle\n\t);\n\tconst pageContractsValue = readRequiredHeader(\n\t\trequest,\n\t\tMOBILE_PAGE_REQUEST_HEADERS.pageContracts\n\t);\n\tconst pageId = readRequiredHeader(\n\t\trequest,\n\t\tMOBILE_PAGE_REQUEST_HEADERS.pageId\n\t);\n\n\tif (!protocolValue || !/^\\d+$/.test(protocolValue)) {\n\t\treturn {\n\t\t\tkind: 'invalid',\n\t\t\tmessage: `Missing or invalid ${MOBILE_PAGE_REQUEST_HEADERS.protocol} header.`\n\t\t};\n\t}\n\tif (!runtime) {\n\t\treturn {\n\t\t\tkind: 'invalid',\n\t\t\tmessage: `Missing ${MOBILE_PAGE_REQUEST_HEADERS.runtime} header.`\n\t\t};\n\t}\n\tif (!appBuild) {\n\t\treturn {\n\t\t\tkind: 'invalid',\n\t\t\tmessage: `Missing ${MOBILE_PAGE_REQUEST_HEADERS.appBuild} header.`\n\t\t};\n\t}\n\tif (!pageBundle) {\n\t\treturn {\n\t\t\tkind: 'invalid',\n\t\t\tmessage: `Missing ${MOBILE_PAGE_REQUEST_HEADERS.pageBundle} header.`\n\t\t};\n\t}\n\tif (!pageContractsValue) {\n\t\treturn {\n\t\t\tkind: 'invalid',\n\t\t\tmessage: `Missing ${MOBILE_PAGE_REQUEST_HEADERS.pageContracts} header.`\n\t\t};\n\t}\n\tif (!pageId) {\n\t\treturn {\n\t\t\tkind: 'invalid',\n\t\t\tmessage: `Missing ${MOBILE_PAGE_REQUEST_HEADERS.pageId} header.`\n\t\t};\n\t}\n\n\tconst pageContracts = [\n\t\t...new Set(\n\t\t\tpageContractsValue\n\t\t\t\t.split(',')\n\t\t\t\t.map((value) => value.trim())\n\t\t\t\t.filter(Boolean)\n\t\t)\n\t];\n\tif (pageContracts.length === 0) {\n\t\treturn {\n\t\t\tkind: 'invalid',\n\t\t\tmessage: `${MOBILE_PAGE_REQUEST_HEADERS.pageContracts} must contain at least one contract.`\n\t\t};\n\t}\n\n\treturn {\n\t\tclient: {\n\t\t\tappBuild,\n\t\t\tpageBundle,\n\t\t\tpageContracts,\n\t\t\tpageId,\n\t\t\tprotocol: Number(protocolValue),\n\t\t\truntime\n\t\t},\n\t\tkind: 'mobile'\n\t};\n};\n\nconst responseHeaders = () => {\n\tconst headers = new Headers({\n\t\t'cache-control': 'no-store',\n\t\t'content-type': `${ABSOLUTE_MOBILE_PAGE_MEDIA_TYPE}; version=${ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION}`\n\t});\n\theaderVaryValues.forEach((value) => headers.append('vary', value));\n\n\treturn headers;\n};\n\nconst headerVaryValues = [\n\t'Accept',\n\tMOBILE_PAGE_REQUEST_HEADERS.protocol,\n\tMOBILE_PAGE_REQUEST_HEADERS.runtime,\n\tMOBILE_PAGE_REQUEST_HEADERS.appBuild,\n\tMOBILE_PAGE_REQUEST_HEADERS.pageBundle,\n\tMOBILE_PAGE_REQUEST_HEADERS.pageContracts,\n\tMOBILE_PAGE_REQUEST_HEADERS.pageId\n];\n\nconst envelopeResponse = (\n\tresponse: AbsoluteMobilePageEnvelope['response'],\n\tstatus: number\n) =>\n\tnew Response(\n\t\tJSON.stringify({\n\t\t\tprotocol: ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION,\n\t\t\tresponse\n\t\t} satisfies AbsoluteMobilePageEnvelope),\n\t\t{ headers: responseHeaders(), status }\n\t);\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n\ttypeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst normalizeJsonValue = (value: Record<string, unknown>) => {\n\tconst serialized = JSON.stringify(value);\n\tif (serialized === undefined) {\n\t\tthrow new TypeError('Mobile page props must be JSON-serializable.');\n\t}\n\n\tconst parsed: unknown = JSON.parse(serialized);\n\tif (!isRecord(parsed)) {\n\t\tthrow new TypeError('Mobile page props must serialize to an object.');\n\t}\n\n\treturn parsed;\n};\n\nconst finalizeArchivedMobilePage = <Props>(\n\tcontext: AbsoluteMobileProducerContext,\n\tinput: FinalizeAbsoluteMobilePageInput<Props>\n) => {\n\tconst { page } = context;\n\tif (\n\t\tpage.pageId !== input.compatibility.pageId ||\n\t\tpage.framework !== input.compatibility.framework\n\t) {\n\t\treturn envelopeResponse(\n\t\t\t{\n\t\t\t\tkind: 'invalid-request',\n\t\t\t\tmessage:\n\t\t\t\t\t'Archived producer page identity does not match its release artifact.'\n\t\t\t},\n\t\t\tBAD_REQUEST_STATUS\n\t\t);\n\t}\n\n\ttry {\n\t\tconst [currentRepresentation] = input.compatibility.representations;\n\t\tif (!currentRepresentation) {\n\t\t\tthrow new TypeError('Mobile page has no current representation.');\n\t\t}\n\n\t\treturn envelopeResponse(\n\t\t\t{\n\t\t\t\tcontract: page.contract,\n\t\t\t\tframework: page.framework,\n\t\t\t\tkind: 'page',\n\t\t\t\tpageId: page.pageId,\n\t\t\t\tprops: normalizeJsonValue(\n\t\t\t\t\tcurrentRepresentation.mapProps(input.props)\n\t\t\t\t),\n\t\t\t\tstatus: input.status ?? OK_STATUS\n\t\t\t},\n\t\t\tinput.status ?? OK_STATUS\n\t\t);\n\t} catch (error) {\n\t\tconsole.error(\n\t\t\t`[Mobile] Archived producer ${context.releaseId} failed for ${page.pageId}:`,\n\t\t\terror\n\t\t);\n\n\t\treturn createAbsoluteMobilePageErrorResponse(page.pageId);\n\t}\n};\n\nexport const createAbsoluteMobileInvalidRequestResponse = (message: string) =>\n\tenvelopeResponse({ kind: 'invalid-request', message }, BAD_REQUEST_STATUS);\n\nexport const createAbsoluteMobilePageErrorResponse = (pageId: string) =>\n\tenvelopeResponse(\n\t\t{\n\t\t\tcode: 'representation-failed',\n\t\t\tkind: 'error',\n\t\t\tpageId,\n\t\t\tstatus: SERVER_ERROR_STATUS\n\t\t},\n\t\tSERVER_ERROR_STATUS\n\t);\n\nexport const createAbsoluteMobileUpgradeResponse = (\n\tresult: AbsoluteMobileUpgradeRequiredResult\n) => envelopeResponse(result, UPGRADE_REQUIRED_STATUS);\n\nexport const finalizeAbsoluteMobilePage = <Props>(\n\tinput: FinalizeAbsoluteMobilePageInput<Props>\n) => {\n\tconst parsed = parseAbsoluteMobilePageRequest(input.request);\n\tif (parsed.kind === 'not-mobile') return undefined;\n\tif (parsed.kind === 'invalid') {\n\t\treturn envelopeResponse(\n\t\t\t{ kind: 'invalid-request', message: parsed.message },\n\t\t\tBAD_REQUEST_STATUS\n\t\t);\n\t}\n\n\tconst { client } = parsed;\n\tif (client.pageId !== input.compatibility.pageId) {\n\t\treturn envelopeResponse(\n\t\t\t{\n\t\t\t\tkind: 'invalid-request',\n\t\t\t\tmessage: `Requested mobile page ${client.pageId} does not match ${input.compatibility.pageId}.`\n\t\t\t},\n\t\t\tBAD_REQUEST_STATUS\n\t\t);\n\t}\n\tconst producerContext = getCurrentAbsoluteMobileProducerContext();\n\tif (producerContext)\n\t\treturn finalizeArchivedMobilePage(producerContext, input);\n\tif (client.protocol !== ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION) {\n\t\treturn envelopeResponse(\n\t\t\t{\n\t\t\t\tkind: 'upgrade-required',\n\t\t\t\tpageId: input.compatibility.pageId,\n\t\t\t\treason: 'protocol'\n\t\t\t},\n\t\t\tUPGRADE_REQUIRED_STATUS\n\t\t);\n\t}\n\tif (!input.compatibility.runtimes.includes(client.runtime)) {\n\t\treturn envelopeResponse(\n\t\t\t{\n\t\t\t\tkind: 'upgrade-required',\n\t\t\t\tpageId: input.compatibility.pageId,\n\t\t\t\treason: 'runtime',\n\t\t\t\tsupportedRuntimes: [...input.compatibility.runtimes]\n\t\t\t},\n\t\t\tUPGRADE_REQUIRED_STATUS\n\t\t);\n\t}\n\n\tconst clientContracts = new Set(client.pageContracts);\n\tconst representation = input.compatibility.representations.find(\n\t\t({ contract }) => clientContracts.has(contract)\n\t);\n\tif (!representation) {\n\t\treturn envelopeResponse(\n\t\t\t{\n\t\t\t\tkind: 'upgrade-required',\n\t\t\t\tpageId: input.compatibility.pageId,\n\t\t\t\treason: 'page-contract',\n\t\t\t\tsupportedContracts: input.compatibility.representations.map(\n\t\t\t\t\t({ contract }) => contract\n\t\t\t\t)\n\t\t\t},\n\t\t\tUPGRADE_REQUIRED_STATUS\n\t\t);\n\t}\n\n\ttry {\n\t\treturn envelopeResponse(\n\t\t\t{\n\t\t\t\tcontract: representation.contract,\n\t\t\t\tframework: input.compatibility.framework,\n\t\t\t\tkind: 'page',\n\t\t\t\tpageId: input.compatibility.pageId,\n\t\t\t\tprops: normalizeJsonValue(representation.mapProps(input.props)),\n\t\t\t\tstatus: input.status ?? OK_STATUS\n\t\t\t},\n\t\t\tinput.status ?? OK_STATUS\n\t\t);\n\t} catch (error) {\n\t\tconsole.error(\n\t\t\t`[Mobile] Failed to produce ${input.compatibility.pageId} representation ${representation.contract}:`,\n\t\t\terror\n\t\t);\n\n\t\treturn envelopeResponse(\n\t\t\t{\n\t\t\t\tcode: 'representation-failed',\n\t\t\t\tkind: 'error',\n\t\t\t\tpageId: input.compatibility.pageId,\n\t\t\t\tstatus: SERVER_ERROR_STATUS\n\t\t\t},\n\t\t\tSERVER_ERROR_STATUS\n\t\t);\n\t}\n};\n",
|
|
39
|
+
"import {\n\tgetCurrentAbsoluteMobileProducerContext,\n\ttype AbsoluteMobileProducerContext\n} from './producerContextState';\n\nexport const ABSOLUTE_MOBILE_PAGE_MEDIA_TYPE =\n\t'application/vnd.absolute.page+json';\nexport const ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION = 1 as const;\nexport const ABSOLUTE_NATIVE_ROUTE_DATA_MEDIA_TYPE =\n\t'application/vnd.absolute.native-route+json';\nconst BAD_REQUEST_STATUS = 400;\nconst OK_STATUS = 200;\nconst SERVER_ERROR_STATUS = 500;\nconst UPGRADE_REQUIRED_STATUS = 426;\n\nexport const MOBILE_PAGE_REQUEST_HEADERS = {\n\tappBuild: 'x-absolute-mobile-app-build',\n\tpageBundle: 'x-absolute-mobile-page-bundle',\n\tpageContracts: 'x-absolute-mobile-page-contracts',\n\tpageId: 'x-absolute-mobile-page-id',\n\tprotocol: 'x-absolute-mobile-protocol',\n\truntime: 'x-absolute-mobile-runtime'\n} as const;\n\nexport type AbsoluteMobilePageFramework =\n\t| 'angular'\n\t| 'ember'\n\t| 'html'\n\t| 'htmx'\n\t| 'react'\n\t| 'svelte'\n\t| 'vue';\n\nexport type AbsoluteMobilePageClient = {\n\tappBuild: string;\n\tpageBundle: string;\n\tpageContracts: string[];\n\tpageId: string;\n\tprotocol: number;\n\truntime: string;\n};\n\nexport type AbsoluteMobilePageRepresentation<Props> = {\n\t/** Stable data contract understood by an embedded page bundle. */\n\tcontract: string;\n\t/**\n\t * Adapts the current route props to an older compatible contract. The\n\t * current representation normally uses the identity function.\n\t */\n\tmapProps: (props: Props) => Record<string, unknown>;\n};\n\nexport type AbsoluteMobilePageCompatibility<Props> = {\n\tframework: AbsoluteMobilePageFramework;\n\tpageId: string;\n\t/** Newest representation first, followed by retained compatibility forms. */\n\trepresentations: readonly AbsoluteMobilePageRepresentation<Props>[];\n\t/** Current runtime plus every retained compatible runtime generation. */\n\truntimes: readonly string[];\n};\n\nexport type AbsoluteMobilePageResult = {\n\tkind: 'page';\n\tcontract: string;\n\tframework: AbsoluteMobilePageFramework;\n\tpageId: string;\n\tprops: Record<string, unknown>;\n\tstatus: number;\n};\n\nexport type AbsoluteMobileUpgradeReason =\n\t| 'app-release'\n\t| 'page-contract'\n\t| 'protocol'\n\t| 'runtime';\n\nexport type AbsoluteMobileUpgradeRequiredResult = {\n\tkind: 'upgrade-required';\n\treason: AbsoluteMobileUpgradeReason;\n\tpageId: string;\n\tsupportedContracts?: string[];\n\tsupportedRuntimes?: string[];\n};\n\nexport type AbsoluteMobileInvalidRequestResult = {\n\tkind: 'invalid-request';\n\tmessage: string;\n};\n\nexport type AbsoluteMobilePageErrorResult = {\n\tcode: 'representation-failed';\n\tkind: 'error';\n\tpageId: string;\n\tstatus: typeof SERVER_ERROR_STATUS;\n};\n\nexport type AbsoluteMobilePageEnvelope = {\n\tprotocol: typeof ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION;\n\tresponse:\n\t\t| AbsoluteMobilePageErrorResult\n\t\t| AbsoluteMobileInvalidRequestResult\n\t\t| AbsoluteMobilePageResult\n\t\t| AbsoluteMobileUpgradeRequiredResult;\n};\n\ntype ParsedMobilePageRequest =\n\t| { kind: 'not-mobile' }\n\t| { kind: 'invalid'; message: string }\n\t| { kind: 'mobile'; client: AbsoluteMobilePageClient };\n\ntype FinalizeAbsoluteMobilePageInput<Props> = {\n\tcompatibility: AbsoluteMobilePageCompatibility<Props>;\n\tprops: Props;\n\trequest: Request | undefined;\n\tstatus?: number;\n};\n\nconst parseMediaType = (value: string) =>\n\tvalue.split(';', 1)[0]?.trim().toLowerCase();\n\nexport const acceptsAbsoluteMobilePage = (request: Request | undefined) => {\n\tif (!request) return false;\n\n\treturn (request.headers.get('accept') ?? '')\n\t\t.split(',')\n\t\t.some(\n\t\t\t(value) => parseMediaType(value) === ABSOLUTE_MOBILE_PAGE_MEDIA_TYPE\n\t\t);\n};\n\nexport const acceptsAbsoluteNativeRouteData = (\n\trequest: Request | undefined\n) => {\n\tif (!request) return false;\n\n\treturn (request.headers.get('accept') ?? '')\n\t\t.split(',')\n\t\t.some(\n\t\t\t(value) =>\n\t\t\t\tparseMediaType(value) === ABSOLUTE_NATIVE_ROUTE_DATA_MEDIA_TYPE\n\t\t);\n};\n\nconst readRequiredHeader = (request: Request, name: string) => {\n\tconst value = request.headers.get(name)?.trim();\n\n\treturn value ? value : undefined;\n};\n\nexport const parseAbsoluteMobilePageRequest = (\n\trequest: Request | undefined\n): ParsedMobilePageRequest => {\n\tif (!request || !acceptsAbsoluteMobilePage(request)) {\n\t\treturn { kind: 'not-mobile' };\n\t}\n\n\tconst protocolValue = readRequiredHeader(\n\t\trequest,\n\t\tMOBILE_PAGE_REQUEST_HEADERS.protocol\n\t);\n\tconst runtime = readRequiredHeader(\n\t\trequest,\n\t\tMOBILE_PAGE_REQUEST_HEADERS.runtime\n\t);\n\tconst appBuild = readRequiredHeader(\n\t\trequest,\n\t\tMOBILE_PAGE_REQUEST_HEADERS.appBuild\n\t);\n\tconst pageBundle = readRequiredHeader(\n\t\trequest,\n\t\tMOBILE_PAGE_REQUEST_HEADERS.pageBundle\n\t);\n\tconst pageContractsValue = readRequiredHeader(\n\t\trequest,\n\t\tMOBILE_PAGE_REQUEST_HEADERS.pageContracts\n\t);\n\tconst pageId = readRequiredHeader(\n\t\trequest,\n\t\tMOBILE_PAGE_REQUEST_HEADERS.pageId\n\t);\n\n\tif (!protocolValue || !/^\\d+$/.test(protocolValue)) {\n\t\treturn {\n\t\t\tkind: 'invalid',\n\t\t\tmessage: `Missing or invalid ${MOBILE_PAGE_REQUEST_HEADERS.protocol} header.`\n\t\t};\n\t}\n\tif (!runtime) {\n\t\treturn {\n\t\t\tkind: 'invalid',\n\t\t\tmessage: `Missing ${MOBILE_PAGE_REQUEST_HEADERS.runtime} header.`\n\t\t};\n\t}\n\tif (!appBuild) {\n\t\treturn {\n\t\t\tkind: 'invalid',\n\t\t\tmessage: `Missing ${MOBILE_PAGE_REQUEST_HEADERS.appBuild} header.`\n\t\t};\n\t}\n\tif (!pageBundle) {\n\t\treturn {\n\t\t\tkind: 'invalid',\n\t\t\tmessage: `Missing ${MOBILE_PAGE_REQUEST_HEADERS.pageBundle} header.`\n\t\t};\n\t}\n\tif (!pageContractsValue) {\n\t\treturn {\n\t\t\tkind: 'invalid',\n\t\t\tmessage: `Missing ${MOBILE_PAGE_REQUEST_HEADERS.pageContracts} header.`\n\t\t};\n\t}\n\tif (!pageId) {\n\t\treturn {\n\t\t\tkind: 'invalid',\n\t\t\tmessage: `Missing ${MOBILE_PAGE_REQUEST_HEADERS.pageId} header.`\n\t\t};\n\t}\n\n\tconst pageContracts = [\n\t\t...new Set(\n\t\t\tpageContractsValue\n\t\t\t\t.split(',')\n\t\t\t\t.map((value) => value.trim())\n\t\t\t\t.filter(Boolean)\n\t\t)\n\t];\n\tif (pageContracts.length === 0) {\n\t\treturn {\n\t\t\tkind: 'invalid',\n\t\t\tmessage: `${MOBILE_PAGE_REQUEST_HEADERS.pageContracts} must contain at least one contract.`\n\t\t};\n\t}\n\n\treturn {\n\t\tclient: {\n\t\t\tappBuild,\n\t\t\tpageBundle,\n\t\t\tpageContracts,\n\t\t\tpageId,\n\t\t\tprotocol: Number(protocolValue),\n\t\t\truntime\n\t\t},\n\t\tkind: 'mobile'\n\t};\n};\n\nconst responseHeaders = () => {\n\tconst headers = new Headers({\n\t\t'cache-control': 'no-store',\n\t\t'content-type': `${ABSOLUTE_MOBILE_PAGE_MEDIA_TYPE}; version=${ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION}`\n\t});\n\theaderVaryValues.forEach((value) => headers.append('vary', value));\n\n\treturn headers;\n};\n\nconst headerVaryValues = [\n\t'Accept',\n\tMOBILE_PAGE_REQUEST_HEADERS.protocol,\n\tMOBILE_PAGE_REQUEST_HEADERS.runtime,\n\tMOBILE_PAGE_REQUEST_HEADERS.appBuild,\n\tMOBILE_PAGE_REQUEST_HEADERS.pageBundle,\n\tMOBILE_PAGE_REQUEST_HEADERS.pageContracts,\n\tMOBILE_PAGE_REQUEST_HEADERS.pageId\n];\n\nconst envelopeResponse = (\n\tresponse: AbsoluteMobilePageEnvelope['response'],\n\tstatus: number\n) =>\n\tnew Response(\n\t\tJSON.stringify({\n\t\t\tprotocol: ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION,\n\t\t\tresponse\n\t\t} satisfies AbsoluteMobilePageEnvelope),\n\t\t{ headers: responseHeaders(), status }\n\t);\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n\ttypeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst normalizeJsonValue = (value: Record<string, unknown>) => {\n\tconst serialized = JSON.stringify(value);\n\tif (serialized === undefined) {\n\t\tthrow new TypeError('Mobile page props must be JSON-serializable.');\n\t}\n\n\tconst parsed: unknown = JSON.parse(serialized);\n\tif (!isRecord(parsed)) {\n\t\tthrow new TypeError('Mobile page props must serialize to an object.');\n\t}\n\n\treturn parsed;\n};\n\nconst finalizeArchivedMobilePage = <Props>(\n\tcontext: AbsoluteMobileProducerContext,\n\tinput: FinalizeAbsoluteMobilePageInput<Props>\n) => {\n\tconst { page } = context;\n\tif (\n\t\tpage.pageId !== input.compatibility.pageId ||\n\t\tpage.framework !== input.compatibility.framework\n\t) {\n\t\treturn envelopeResponse(\n\t\t\t{\n\t\t\t\tkind: 'invalid-request',\n\t\t\t\tmessage:\n\t\t\t\t\t'Archived producer page identity does not match its release artifact.'\n\t\t\t},\n\t\t\tBAD_REQUEST_STATUS\n\t\t);\n\t}\n\n\ttry {\n\t\tconst [currentRepresentation] = input.compatibility.representations;\n\t\tif (!currentRepresentation) {\n\t\t\tthrow new TypeError('Mobile page has no current representation.');\n\t\t}\n\n\t\treturn envelopeResponse(\n\t\t\t{\n\t\t\t\tcontract: page.contract,\n\t\t\t\tframework: page.framework,\n\t\t\t\tkind: 'page',\n\t\t\t\tpageId: page.pageId,\n\t\t\t\tprops: normalizeJsonValue(\n\t\t\t\t\tcurrentRepresentation.mapProps(input.props)\n\t\t\t\t),\n\t\t\t\tstatus: input.status ?? OK_STATUS\n\t\t\t},\n\t\t\tinput.status ?? OK_STATUS\n\t\t);\n\t} catch (error) {\n\t\tconsole.error(\n\t\t\t`[Mobile] Archived producer ${context.releaseId} failed for ${page.pageId}:`,\n\t\t\terror\n\t\t);\n\n\t\treturn createAbsoluteMobilePageErrorResponse(page.pageId);\n\t}\n};\n\nconst finalizeAbsoluteNativeRouteDevelopmentPage = <Props>(\n\tinput: FinalizeAbsoluteMobilePageInput<Props>\n) => {\n\tif (process.env.NODE_ENV !== 'development') {\n\t\treturn createAbsoluteMobileInvalidRequestResponse(\n\t\t\t'The native-route development representation is disabled outside development.'\n\t\t);\n\t}\n\tif (input.request?.method !== 'GET') {\n\t\treturn createAbsoluteMobileInvalidRequestResponse(\n\t\t\t'Native-route data requests must use GET.'\n\t\t);\n\t}\n\tif (\n\t\tinput.request.headers.get(MOBILE_PAGE_REQUEST_HEADERS.protocol) !==\n\t\tString(ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION)\n\t) {\n\t\treturn createAbsoluteMobileInvalidRequestResponse(\n\t\t\t`Native-route data requires protocol ${ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION}.`\n\t\t);\n\t}\n\tconst [representation] = input.compatibility.representations;\n\tif (!representation) {\n\t\treturn createAbsoluteMobilePageErrorResponse(\n\t\t\tinput.compatibility.pageId\n\t\t);\n\t}\n\n\ttry {\n\t\treturn envelopeResponse(\n\t\t\t{\n\t\t\t\tcontract: representation.contract,\n\t\t\t\tframework: input.compatibility.framework,\n\t\t\t\tkind: 'page',\n\t\t\t\tpageId: input.compatibility.pageId,\n\t\t\t\tprops: normalizeJsonValue(representation.mapProps(input.props)),\n\t\t\t\tstatus: input.status ?? OK_STATUS\n\t\t\t},\n\t\t\tinput.status ?? OK_STATUS\n\t\t);\n\t} catch (error) {\n\t\tconsole.error(\n\t\t\t`[Mobile] Failed to produce development native route ${input.compatibility.pageId}:`,\n\t\t\terror\n\t\t);\n\n\t\treturn createAbsoluteMobilePageErrorResponse(\n\t\t\tinput.compatibility.pageId\n\t\t);\n\t}\n};\n\nexport const createAbsoluteMobileInvalidRequestResponse = (message: string) =>\n\tenvelopeResponse({ kind: 'invalid-request', message }, BAD_REQUEST_STATUS);\n\nexport const createAbsoluteMobilePageErrorResponse = (pageId: string) =>\n\tenvelopeResponse(\n\t\t{\n\t\t\tcode: 'representation-failed',\n\t\t\tkind: 'error',\n\t\t\tpageId,\n\t\t\tstatus: SERVER_ERROR_STATUS\n\t\t},\n\t\tSERVER_ERROR_STATUS\n\t);\n\nexport const createAbsoluteMobileUpgradeResponse = (\n\tresult: AbsoluteMobileUpgradeRequiredResult\n) => envelopeResponse(result, UPGRADE_REQUIRED_STATUS);\n\nexport const finalizeAbsoluteMobilePage = <Props>(\n\tinput: FinalizeAbsoluteMobilePageInput<Props>\n) => {\n\tif (acceptsAbsoluteNativeRouteData(input.request)) {\n\t\treturn finalizeAbsoluteNativeRouteDevelopmentPage(input);\n\t}\n\tconst parsed = parseAbsoluteMobilePageRequest(input.request);\n\tif (parsed.kind === 'not-mobile') return undefined;\n\tif (parsed.kind === 'invalid') {\n\t\treturn envelopeResponse(\n\t\t\t{ kind: 'invalid-request', message: parsed.message },\n\t\t\tBAD_REQUEST_STATUS\n\t\t);\n\t}\n\n\tconst { client } = parsed;\n\tif (client.pageId !== input.compatibility.pageId) {\n\t\treturn envelopeResponse(\n\t\t\t{\n\t\t\t\tkind: 'invalid-request',\n\t\t\t\tmessage: `Requested mobile page ${client.pageId} does not match ${input.compatibility.pageId}.`\n\t\t\t},\n\t\t\tBAD_REQUEST_STATUS\n\t\t);\n\t}\n\tconst producerContext = getCurrentAbsoluteMobileProducerContext();\n\tif (producerContext)\n\t\treturn finalizeArchivedMobilePage(producerContext, input);\n\tif (client.protocol !== ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION) {\n\t\treturn envelopeResponse(\n\t\t\t{\n\t\t\t\tkind: 'upgrade-required',\n\t\t\t\tpageId: input.compatibility.pageId,\n\t\t\t\treason: 'protocol'\n\t\t\t},\n\t\t\tUPGRADE_REQUIRED_STATUS\n\t\t);\n\t}\n\tif (!input.compatibility.runtimes.includes(client.runtime)) {\n\t\treturn envelopeResponse(\n\t\t\t{\n\t\t\t\tkind: 'upgrade-required',\n\t\t\t\tpageId: input.compatibility.pageId,\n\t\t\t\treason: 'runtime',\n\t\t\t\tsupportedRuntimes: [...input.compatibility.runtimes]\n\t\t\t},\n\t\t\tUPGRADE_REQUIRED_STATUS\n\t\t);\n\t}\n\n\tconst clientContracts = new Set(client.pageContracts);\n\tconst representation = input.compatibility.representations.find(\n\t\t({ contract }) => clientContracts.has(contract)\n\t);\n\tif (!representation) {\n\t\treturn envelopeResponse(\n\t\t\t{\n\t\t\t\tkind: 'upgrade-required',\n\t\t\t\tpageId: input.compatibility.pageId,\n\t\t\t\treason: 'page-contract',\n\t\t\t\tsupportedContracts: input.compatibility.representations.map(\n\t\t\t\t\t({ contract }) => contract\n\t\t\t\t)\n\t\t\t},\n\t\t\tUPGRADE_REQUIRED_STATUS\n\t\t);\n\t}\n\n\ttry {\n\t\treturn envelopeResponse(\n\t\t\t{\n\t\t\t\tcontract: representation.contract,\n\t\t\t\tframework: input.compatibility.framework,\n\t\t\t\tkind: 'page',\n\t\t\t\tpageId: input.compatibility.pageId,\n\t\t\t\tprops: normalizeJsonValue(representation.mapProps(input.props)),\n\t\t\t\tstatus: input.status ?? OK_STATUS\n\t\t\t},\n\t\t\tinput.status ?? OK_STATUS\n\t\t);\n\t} catch (error) {\n\t\tconsole.error(\n\t\t\t`[Mobile] Failed to produce ${input.compatibility.pageId} representation ${representation.contract}:`,\n\t\t\terror\n\t\t);\n\n\t\treturn envelopeResponse(\n\t\t\t{\n\t\t\t\tcode: 'representation-failed',\n\t\t\t\tkind: 'error',\n\t\t\t\tpageId: input.compatibility.pageId,\n\t\t\t\tstatus: SERVER_ERROR_STATUS\n\t\t\t},\n\t\t\tSERVER_ERROR_STATUS\n\t\t);\n\t}\n};\n",
|
|
31
40
|
"import {\n\tABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION,\n\ttype AbsoluteMobilePageEnvelope,\n\ttype AbsoluteMobilePageFramework,\n\ttype AbsoluteMobilePageResult,\n\ttype AbsoluteMobileUpgradeReason,\n\ttype AbsoluteMobileUpgradeRequiredResult\n} from './pageProtocol';\n\ntype AbsoluteMobileClientTarget = {\n\t__ABSOLUTE_PAGE_DISPOSE__?: () => Promise<void> | void;\n\t__ABSOLUTE_PAGE_READY__?: Promise<unknown>;\n\t__ABSOLUTE_PAGE_RENDER_MODE__?: 'client' | 'hydrate';\n\t__ABS_ANGULAR_REQUEST_CONTEXT__?: Record<string, unknown>;\n\t__INITIAL_PROPS__?: Record<string, unknown>;\n};\n\nexport type AbsoluteMobilePageLoader = (input: {\n\tcontract: string;\n\tpageId: string;\n}) => Promise<unknown>;\n\nexport type AbsoluteMobilePageActivation =\n\t| {\n\t\t\tkind: 'rendered';\n\t\t\tcontract: string;\n\t\t\tpageId: string;\n\t }\n\t| AbsoluteMobileUpgradeRequiredResult;\n\nexport type AbsoluteMobilePageActivationOptions = {\n\tloadPage: AbsoluteMobilePageLoader;\n\ttarget?: AbsoluteMobileClientTarget;\n};\n\nexport class AbsoluteMobilePageProtocolError extends Error {\n\treadonly code:\n\t\t| 'invalid-envelope'\n\t\t| 'invalid-props'\n\t\t| 'server-error'\n\t\t| 'server-rejected-request';\n\n\tconstructor(\n\t\tcode: AbsoluteMobilePageProtocolError['code'],\n\t\tmessage: string\n\t) {\n\t\tsuper(message);\n\t\tthis.name = 'AbsoluteMobilePageProtocolError';\n\t\tthis.code = code;\n\t}\n}\n\nexport const disposeAbsoluteMobilePage = async (\n\ttarget: AbsoluteMobileClientTarget = window\n) => {\n\tconst dispose = target.__ABSOLUTE_PAGE_DISPOSE__;\n\ttarget.__ABSOLUTE_PAGE_DISPOSE__ = undefined;\n\ttarget.__ABSOLUTE_PAGE_READY__ = undefined;\n\tif (dispose) await dispose();\n};\n\nconst frameworks = new Set<string>([\n\t'angular',\n\t'ember',\n\t'html',\n\t'htmx',\n\t'react',\n\t'svelte',\n\t'vue'\n]);\nconst upgradeReasons = new Set<string>([\n\t'app-release',\n\t'page-contract',\n\t'protocol',\n\t'runtime'\n]);\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n\ttypeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst isFramework = (value: unknown): value is AbsoluteMobilePageFramework =>\n\ttypeof value === 'string' && frameworks.has(value);\n\nconst isUpgradeReason = (\n\tvalue: unknown\n): value is AbsoluteMobileUpgradeReason =>\n\ttypeof value === 'string' && upgradeReasons.has(value);\n\nconst parsePageResult = (\n\tvalue: Record<string, unknown>\n): AbsoluteMobilePageResult => {\n\tif (\n\t\ttypeof value.contract !== 'string' ||\n\t\t!isFramework(value.framework) ||\n\t\ttypeof value.pageId !== 'string' ||\n\t\ttypeof value.status !== 'number'\n\t) {\n\t\tthrow new AbsoluteMobilePageProtocolError(\n\t\t\t'invalid-envelope',\n\t\t\t'The mobile page response is missing required page metadata.'\n\t\t);\n\t}\n\tif (!isRecord(value.props)) {\n\t\tthrow new AbsoluteMobilePageProtocolError(\n\t\t\t'invalid-props',\n\t\t\t'The mobile page response must contain an object props value.'\n\t\t);\n\t}\n\n\treturn {\n\t\tcontract: value.contract,\n\t\tframework: value.framework,\n\t\tkind: 'page',\n\t\tpageId: value.pageId,\n\t\tprops: value.props,\n\t\tstatus: value.status\n\t};\n};\n\nconst parseUpgradeResult = (\n\tvalue: Record<string, unknown>\n): AbsoluteMobileUpgradeRequiredResult => {\n\tif (typeof value.pageId !== 'string' || !isUpgradeReason(value.reason)) {\n\t\tthrow new AbsoluteMobilePageProtocolError(\n\t\t\t'invalid-envelope',\n\t\t\t'The update response is missing its page or reason.'\n\t\t);\n\t}\n\n\treturn {\n\t\tkind: 'upgrade-required',\n\t\tpageId: value.pageId,\n\t\treason: value.reason,\n\t\tsupportedContracts: Array.isArray(value.supportedContracts)\n\t\t\t? value.supportedContracts.filter(\n\t\t\t\t\t(contract): contract is string =>\n\t\t\t\t\t\ttypeof contract === 'string'\n\t\t\t\t)\n\t\t\t: undefined,\n\t\tsupportedRuntimes: Array.isArray(value.supportedRuntimes)\n\t\t\t? value.supportedRuntimes.filter(\n\t\t\t\t\t(runtime): runtime is string => typeof runtime === 'string'\n\t\t\t\t)\n\t\t\t: undefined\n\t};\n};\n\nexport const activateAbsoluteMobilePage = async (\n\tvalue: unknown,\n\toptions: AbsoluteMobilePageActivationOptions\n) => {\n\tconst envelope = parseAbsoluteMobilePageEnvelope(value);\n\tif (envelope.response.kind === 'upgrade-required') {\n\t\treturn envelope.response;\n\t}\n\tif (envelope.response.kind !== 'page') {\n\t\tthrow new AbsoluteMobilePageProtocolError(\n\t\t\t'invalid-envelope',\n\t\t\t'Expected a renderable mobile page response.'\n\t\t);\n\t}\n\n\tconst target: AbsoluteMobileClientTarget = options.target ?? window;\n\tawait disposeAbsoluteMobilePage(target);\n\ttarget.__INITIAL_PROPS__ = envelope.response.props;\n\ttarget.__ABS_ANGULAR_REQUEST_CONTEXT__ = envelope.response.props;\n\ttarget.__ABSOLUTE_PAGE_RENDER_MODE__ = 'client';\n\tawait options.loadPage({\n\t\tcontract: envelope.response.contract,\n\t\tpageId: envelope.response.pageId\n\t});\n\tif (target.__ABSOLUTE_PAGE_READY__) {\n\t\tawait target.__ABSOLUTE_PAGE_READY__;\n\t}\n\n\treturn {\n\t\tcontract: envelope.response.contract,\n\t\tkind: 'rendered',\n\t\tpageId: envelope.response.pageId\n\t} satisfies AbsoluteMobilePageActivation;\n};\n\nexport const parseAbsoluteMobilePageEnvelope = (value: unknown) => {\n\tif (!isRecord(value) || !isRecord(value.response)) {\n\t\tthrow new AbsoluteMobilePageProtocolError(\n\t\t\t'invalid-envelope',\n\t\t\t'The server did not return an AbsoluteJS mobile page envelope.'\n\t\t);\n\t}\n\tif (value.protocol !== ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION) {\n\t\tthrow new AbsoluteMobilePageProtocolError(\n\t\t\t'invalid-envelope',\n\t\t\t`Unsupported mobile page protocol ${String(value.protocol)}.`\n\t\t);\n\t}\n\n\tconst { kind } = value.response;\n\tif (kind === 'page') {\n\t\treturn {\n\t\t\tprotocol: ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION,\n\t\t\tresponse: parsePageResult(value.response)\n\t\t} satisfies AbsoluteMobilePageEnvelope;\n\t}\n\tif (kind === 'upgrade-required') {\n\t\treturn {\n\t\t\tprotocol: ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION,\n\t\t\tresponse: parseUpgradeResult(value.response)\n\t\t} satisfies AbsoluteMobilePageEnvelope;\n\t}\n\tif (kind === 'invalid-request') {\n\t\tthrow new AbsoluteMobilePageProtocolError(\n\t\t\t'server-rejected-request',\n\t\t\ttypeof value.response.message === 'string'\n\t\t\t\t? value.response.message\n\t\t\t\t: 'The server rejected the mobile page request.'\n\t\t);\n\t}\n\tif (kind === 'error') {\n\t\tthrow new AbsoluteMobilePageProtocolError(\n\t\t\t'server-error',\n\t\t\t'The server could not create a compatible mobile page representation.'\n\t\t);\n\t}\n\n\tthrow new AbsoluteMobilePageProtocolError(\n\t\t'invalid-envelope',\n\t\t`Unknown mobile page response kind ${String(kind)}.`\n\t);\n};\n",
|
|
32
|
-
"import {\n\tactivateAbsoluteMobilePage,\n\ttype AbsoluteMobilePageActivationOptions\n} from './client';\nimport {\n\tABSOLUTE_MOBILE_PAGE_MEDIA_TYPE,\n\tABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION,\n\tMOBILE_PAGE_REQUEST_HEADERS\n} from './pageProtocol';\nimport type {\n\tAbsoluteMobileCompatibilityPage,\n\tAbsoluteMobileCompatibilityRoute\n} from './releaseArtifact';\nimport { resolveAbsoluteMobileRoute } from './routeMatcher';\nimport type { AbsoluteMobileAuthManifest } from './nativeAuth';\n\nexport const ABSOLUTE_MOBILE_CLIENT_MANIFEST_FORMAT = 1 as const;\n\nexport type AbsoluteMobileFetch = (\n\tinput: RequestInfo | URL,\n\tinit?: RequestInit\n) => Promise<Response>;\n\nexport type AbsoluteMobileClientPage = AbsoluteMobileCompatibilityPage & {\n\tlocalBundlePath: string;\n\tlocalStylePath?: string;\n};\n\nexport type AbsoluteMobileClientManifest = {\n\tauth?: AbsoluteMobileAuthManifest;\n\tappBuild: string;\n\tappId: string;\n\tappName: string;\n\tdeepLinkHosts: string[];\n\tdeepLinkScheme?: string;\n\tentry: string;\n\tformat: typeof ABSOLUTE_MOBILE_CLIENT_MANIFEST_FORMAT;\n\tpages: AbsoluteMobileClientPage[];\n\tproductionOrigin: string;\n\troutes: AbsoluteMobileCompatibilityRoute[];\n\truntime: string;\n\tsync?: {
|
|
41
|
+
"import {\n\tactivateAbsoluteMobilePage,\n\ttype AbsoluteMobilePageActivationOptions\n} from './client';\nimport {\n\tABSOLUTE_MOBILE_PAGE_MEDIA_TYPE,\n\tABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION,\n\tMOBILE_PAGE_REQUEST_HEADERS\n} from './pageProtocol';\nimport type {\n\tAbsoluteMobileCompatibilityPage,\n\tAbsoluteMobileCompatibilityRoute\n} from './releaseArtifact';\nimport { resolveAbsoluteMobileRoute } from './routeMatcher';\nimport type { AbsoluteMobileAuthManifest } from './nativeAuth';\nimport type { SyncLocalStoreSchemaBundle } from '@absolutejs/sync/client';\n\nexport const ABSOLUTE_MOBILE_CLIENT_MANIFEST_FORMAT = 1 as const;\n\nexport type AbsoluteMobileFetch = (\n\tinput: RequestInfo | URL,\n\tinit?: RequestInit\n) => Promise<Response>;\n\nexport type AbsoluteMobileClientPage = AbsoluteMobileCompatibilityPage & {\n\tlocalBundlePath: string;\n\tlocalStylePath?: string;\n};\n\nexport type AbsoluteMobileClientManifest = {\n\tauth?: AbsoluteMobileAuthManifest;\n\tappBuild: string;\n\tappId: string;\n\tappName: string;\n\tdeepLinkHosts: string[];\n\tdeepLinkScheme?: string;\n\tdeviceCapabilities: string[];\n\tentry: string;\n\tformat: typeof ABSOLUTE_MOBILE_CLIENT_MANIFEST_FORMAT;\n\tpages: AbsoluteMobileClientPage[];\n\tproductionOrigin: string;\n\troutes: AbsoluteMobileCompatibilityRoute[];\n\truntime: string;\n\tsync?: {\n\t\tsocketTickets: true;\n\t\tbackground: { endpoint: string; intervalMinutes: number };\n\t\tstorageSchema: SyncLocalStoreSchemaBundle;\n\t};\n};\n\nexport type AbsoluteMobileTransportOptions = {\n\tfetch?: AbsoluteMobileFetch;\n\theaders?: HeadersInit;\n};\n\nconst pageForPathname = (\n\tmanifest: AbsoluteMobileClientManifest,\n\tpathname: string\n) => {\n\tconst route = resolveAbsoluteMobileRoute(manifest.routes, pathname);\n\tif (!route) {\n\t\tthrow new TypeError(`No embedded mobile page owns ${pathname}.`);\n\t}\n\tconst page = manifest.pages.find(\n\t\t(candidate) => candidate.pageId === route.pageId\n\t);\n\tif (!page) {\n\t\tthrow new TypeError(\n\t\t\t`Mobile route ${route.pattern} references missing page ${route.pageId}.`\n\t\t);\n\t}\n\n\treturn page;\n};\n\nconst canonicalBackendUrl = (\n\tmanifest: AbsoluteMobileClientManifest,\n\tpath: string\n) => {\n\tconst origin = new URL(manifest.productionOrigin);\n\tconst url = new URL(path, `${origin.origin}/`);\n\tif (url.origin !== origin.origin) {\n\t\tthrow new TypeError('Mobile transport cannot leave productionOrigin.');\n\t}\n\turl.hash = '';\n\n\treturn url;\n};\n\nexport const createAbsoluteMobilePageRequest = (\n\tmanifest: AbsoluteMobileClientManifest,\n\tpath: string,\n\toptions: AbsoluteMobileTransportOptions = {}\n) => {\n\tconst url = canonicalBackendUrl(manifest, path);\n\tconst page = pageForPathname(manifest, url.pathname);\n\tconst headers = new Headers(options.headers);\n\theaders.set('accept', ABSOLUTE_MOBILE_PAGE_MEDIA_TYPE);\n\theaders.set(MOBILE_PAGE_REQUEST_HEADERS.appBuild, manifest.appBuild);\n\theaders.set(MOBILE_PAGE_REQUEST_HEADERS.pageBundle, page.bundleHash);\n\theaders.set(MOBILE_PAGE_REQUEST_HEADERS.pageContracts, page.contract);\n\theaders.set(MOBILE_PAGE_REQUEST_HEADERS.pageId, page.pageId);\n\theaders.set(\n\t\tMOBILE_PAGE_REQUEST_HEADERS.protocol,\n\t\tString(ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION)\n\t);\n\theaders.set(MOBILE_PAGE_REQUEST_HEADERS.runtime, manifest.runtime);\n\n\treturn new Request(url, { headers, method: 'GET' });\n};\n\nexport const fetchAbsoluteMobilePage = async (\n\tmanifest: AbsoluteMobileClientManifest,\n\tpath: string,\n\toptions: AbsoluteMobileTransportOptions = {}\n) => {\n\tconst request = createAbsoluteMobilePageRequest(manifest, path, options);\n\tconst response = await (options.fetch ?? globalThis.fetch)(request);\n\tconst value: unknown = await response.json();\n\n\treturn value;\n};\n\nexport const navigateAbsoluteMobilePage = async (\n\tmanifest: AbsoluteMobileClientManifest,\n\tpath: string,\n\toptions: AbsoluteMobileTransportOptions &\n\t\tAbsoluteMobilePageActivationOptions\n) => {\n\tconst envelope = await fetchAbsoluteMobilePage(manifest, path, options);\n\n\treturn activateAbsoluteMobilePage(envelope, options);\n};\n\nexport const resolveAbsoluteMobileDeepLink = (\n\tmanifest: AbsoluteMobileClientManifest,\n\tvalue: string\n) => {\n\tconst url = new URL(value);\n\tif (url.username || url.password) {\n\t\tthrow new TypeError('Mobile deep links cannot contain credentials.');\n\t}\n\tconst isHttpsHost =\n\t\turl.protocol === 'https:' &&\n\t\tmanifest.deepLinkHosts.includes(url.hostname.toLowerCase());\n\tconst isCustomScheme =\n\t\tmanifest.deepLinkScheme !== undefined &&\n\t\turl.protocol === `${manifest.deepLinkScheme}:`;\n\tif (!isHttpsHost && !isCustomScheme) {\n\t\tthrow new TypeError(\n\t\t\t'Mobile deep link is outside the configured app URLs.'\n\t\t);\n\t}\n\n\treturn `${url.pathname || '/'}${url.search}${url.hash}`;\n};\n\nexport const resolveAbsoluteMobileNavigation = (\n\tmanifest: AbsoluteMobileClientManifest,\n\tvalue: string,\n\tlocalOrigin: string\n) => {\n\tconst url = new URL(value, `${localOrigin}/`);\n\tconst local = new URL(localOrigin);\n\tconst production = new URL(manifest.productionOrigin);\n\tconst matches = (candidate: URL, allowed: URL) =>\n\t\tcandidate.protocol === allowed.protocol &&\n\t\tcandidate.host === allowed.host;\n\tif (!matches(url, local) && !matches(url, production)) {\n\t\treturn undefined;\n\t}\n\n\treturn `${url.pathname}${url.search}${url.hash}`;\n};\n",
|
|
33
42
|
"import { createHash } from 'node:crypto';\nimport {\n\taccess,\n\tmkdir,\n\tmkdtemp,\n\treadFile,\n\trename,\n\trm,\n\twriteFile\n} from 'node:fs/promises';\nimport { dirname, join, resolve as resolvePath } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport {\n\tverifyAbsoluteMobileCompatibilityProducer,\n\ttype AbsoluteMobileStoredCompatibilityRelease\n} from './artifactStore';\nimport type {\n\tAbsoluteMobileCompatibilityDispatcherOptions,\n\tAbsoluteMobileCompatibilityProducerHandler\n} from './compatibilityDispatcher';\nimport {\n\tparseAbsoluteMobileCompatibilityArtifact,\n\tretainAbsoluteMobileCompatibilityArtifacts,\n\ttype AbsoluteMobileCompatibilityArtifact\n} from './releaseArtifact';\n\nexport const ABSOLUTE_MOBILE_MATERIALIZED_BUNDLE_FORMAT = 1 as const;\n\nexport type AbsoluteMobileMaterializedBundleInput = {\n\tcurrentReleaseId: string;\n\treleases: readonly AbsoluteMobileStoredCompatibilityRelease[];\n\troot: string;\n};\n\nexport type AbsoluteMobileMaterializedBundleIndex = {\n\tbundleId: string;\n\tcurrentReleaseId: string;\n\tformat: typeof ABSOLUTE_MOBILE_MATERIALIZED_BUNDLE_FORMAT;\n\treleases: AbsoluteMobileCompatibilityArtifact[];\n};\n\ntype CompatibilityModule = Record<string, unknown>;\ntype CompatibilityModuleLoader = (\n\tmodulePath: string\n) => Promise<CompatibilityModule>;\n\nconst CURRENT_BUNDLE_FILE = 'current.json';\nconst BUNDLES_DIRECTORY = 'bundles';\nconst ARTIFACT_FILE = 'artifact.json';\nconst BUNDLE_ID_PATTERN = /^amb_[a-f0-9]{64}$/;\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n\ttypeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst errorHasCode = (error: unknown, code: string) =>\n\ttypeof error === 'object' &&\n\terror !== null &&\n\tReflect.get(error, 'code') === code;\n\nconst bundleIdFor = (\n\tcurrentReleaseId: string,\n\treleases: readonly AbsoluteMobileCompatibilityArtifact[]\n) => {\n\tconst identity = JSON.stringify({\n\t\tcurrentReleaseId,\n\t\treleases: releases.map(({ releaseId }) => releaseId)\n\t});\n\n\treturn `amb_${createHash('sha256').update(identity).digest('hex')}`;\n};\n\nconst parseBundleIndex = (value: unknown) => {\n\tif (\n\t\t!isRecord(value) ||\n\t\tvalue.format !== ABSOLUTE_MOBILE_MATERIALIZED_BUNDLE_FORMAT ||\n\t\ttypeof value.bundleId !== 'string' ||\n\t\t!BUNDLE_ID_PATTERN.test(value.bundleId) ||\n\t\ttypeof value.currentReleaseId !== 'string' ||\n\t\t!Array.isArray(value.releases)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t'Invalid materialized mobile compatibility bundle.'\n\t\t);\n\t}\n\tconst releases = value.releases.map(\n\t\tparseAbsoluteMobileCompatibilityArtifact\n\t);\n\tconst retained = retainAbsoluteMobileCompatibilityArtifacts(releases);\n\tif (\n\t\tretained.length !== releases.length ||\n\t\tretained.some(\n\t\t\t({ releaseId }, index) => releaseId !== releases[index]?.releaseId\n\t\t)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t'Materialized mobile bundle releases are not a retained generation window.'\n\t\t);\n\t}\n\tconst expectedBundleId = bundleIdFor(value.currentReleaseId, releases);\n\tif (value.bundleId !== expectedBundleId) {\n\t\tthrow new TypeError('Materialized mobile bundle integrity failed.');\n\t}\n\tif (releases[0]?.releaseId !== value.currentReleaseId) {\n\t\tthrow new TypeError(\n\t\t\t'Materialized mobile bundle current release is not its newest generation.'\n\t\t);\n\t}\n\n\treturn {\n\t\tbundleId: value.bundleId,\n\t\tcurrentReleaseId: value.currentReleaseId,\n\t\tformat: ABSOLUTE_MOBILE_MATERIALIZED_BUNDLE_FORMAT,\n\t\treleases\n\t} satisfies AbsoluteMobileMaterializedBundleIndex;\n};\n\nconst writeRelease = async (\n\troot: string,\n\trelease: AbsoluteMobileStoredCompatibilityRelease\n) => {\n\tconst directory = join(root, release.artifact.releaseId);\n\tconst producerPath = join(directory, release.artifact.producer.module);\n\tawait mkdir(dirname(producerPath), { recursive: true });\n\tawait Promise.all([\n\t\twriteFile(\n\t\t\tjoin(directory, ARTIFACT_FILE),\n\t\t\t`${JSON.stringify(release.artifact, null, '\\t')}\\n`\n\t\t),\n\t\twriteFile(\n\t\t\tproducerPath,\n\t\t\tnew Uint8Array(await release.producer.arrayBuffer())\n\t\t)\n\t]);\n};\n\nconst installImmutableBundle = async (\n\tbundlesRoot: string,\n\tbundleId: string,\n\treleases: readonly AbsoluteMobileStoredCompatibilityRelease[]\n) => {\n\tconst destination = join(bundlesRoot, bundleId);\n\ttry {\n\t\tawait access(destination);\n\n\t\treturn destination;\n\t} catch (error) {\n\t\tif (!errorHasCode(error, 'ENOENT')) throw error;\n\t}\n\n\tconst staging = await mkdtemp(join(bundlesRoot, '.stage-'));\n\ttry {\n\t\tawait Promise.all(\n\t\t\treleases.map((release) => writeRelease(staging, release))\n\t\t);\n\t\tawait rename(staging, destination);\n\t} catch (error) {\n\t\tawait rm(staging, { force: true, recursive: true });\n\t\tif (errorHasCode(error, 'EEXIST') || errorHasCode(error, 'ENOTEMPTY')) {\n\t\t\treturn destination;\n\t\t}\n\n\t\tthrow error;\n\t}\n\n\treturn destination;\n};\n\nconst readCompatibilityModule: CompatibilityModuleLoader = (modulePath) =>\n\timport(pathToFileURL(modulePath).href);\n\nconst resolveProducerHandler = (\n\tloaded: CompatibilityModule,\n\texportName: string\n) => {\n\tconst value = loaded[exportName];\n\tif (!isRecord(value) || typeof value.handle !== 'function') {\n\t\tthrow new TypeError(\n\t\t\t`Compatibility producer export ${exportName} must expose handle(request).`\n\t\t);\n\t}\n\n\tconst { handle } = value;\n\n\treturn {\n\t\thandle: async (request) => {\n\t\t\tconst response: unknown = await Reflect.apply(handle, value, [\n\t\t\t\trequest\n\t\t\t]);\n\t\t\tif (!(response instanceof Response)) {\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t`Compatibility producer ${exportName} returned a non-Response value.`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn response;\n\t\t}\n\t} satisfies AbsoluteMobileCompatibilityProducerHandler;\n};\n\nexport const loadAbsoluteMobileMaterializedBundle = async (\n\troot: string\n): Promise<AbsoluteMobileCompatibilityDispatcherOptions> => {\n\tconst resolvedRoot = resolvePath(root);\n\tconst serialized = await readFile(\n\t\tjoin(resolvedRoot, CURRENT_BUNDLE_FILE),\n\t\t'utf8'\n\t);\n\tconst parsed: unknown = JSON.parse(serialized);\n\tconst index = parseBundleIndex(parsed);\n\tconst bundleRoot = join(resolvedRoot, BUNDLES_DIRECTORY, index.bundleId);\n\n\treturn {\n\t\tartifacts: index.releases,\n\t\tcurrentReleaseId: index.currentReleaseId,\n\t\tloadProducer: async (artifact) => {\n\t\t\tconst modulePath = join(\n\t\t\t\tbundleRoot,\n\t\t\t\tartifact.releaseId,\n\t\t\t\tartifact.producer.module\n\t\t\t);\n\t\t\tawait verifyAbsoluteMobileCompatibilityProducer({\n\t\t\t\tartifact,\n\t\t\t\tproducer: Bun.file(modulePath)\n\t\t\t});\n\t\t\tconst loaded = await readCompatibilityModule(modulePath);\n\n\t\t\treturn resolveProducerHandler(loaded, artifact.producer.exportName);\n\t\t}\n\t};\n};\n\nexport const materializeAbsoluteMobileCompatibilityBundle = async (\n\tinput: AbsoluteMobileMaterializedBundleInput\n) => {\n\tconst releases = await Promise.all(\n\t\tinput.releases.map((release) =>\n\t\t\tverifyAbsoluteMobileCompatibilityProducer(release)\n\t\t)\n\t);\n\tconst artifacts = retainAbsoluteMobileCompatibilityArtifacts(\n\t\treleases.map(({ artifact }) => artifact)\n\t);\n\tif (artifacts.length !== releases.length) {\n\t\tthrow new TypeError(\n\t\t\t'Materialization input must already contain only retained releases.'\n\t\t);\n\t}\n\tif (artifacts[0]?.releaseId !== input.currentReleaseId) {\n\t\tthrow new TypeError(\n\t\t\t'Materialization current release must be the newest generation.'\n\t\t);\n\t}\n\tconst orderedReleases = artifacts.map((artifact) => {\n\t\tconst release = releases.find(\n\t\t\t(candidate) => candidate.artifact.releaseId === artifact.releaseId\n\t\t);\n\t\tif (!release) {\n\t\t\tthrow new TypeError('Materialization input is missing a producer.');\n\t\t}\n\n\t\treturn release;\n\t});\n\tconst root = resolvePath(input.root);\n\tconst bundlesRoot = join(root, BUNDLES_DIRECTORY);\n\tawait mkdir(bundlesRoot, { recursive: true });\n\tconst bundleId = bundleIdFor(input.currentReleaseId, artifacts);\n\tawait installImmutableBundle(bundlesRoot, bundleId, orderedReleases);\n\tconst index = {\n\t\tbundleId,\n\t\tcurrentReleaseId: input.currentReleaseId,\n\t\tformat: ABSOLUTE_MOBILE_MATERIALIZED_BUNDLE_FORMAT,\n\t\treleases: artifacts\n\t} satisfies AbsoluteMobileMaterializedBundleIndex;\n\tconst pointerPath = join(root, CURRENT_BUNDLE_FILE);\n\tconst temporaryPointerPath = join(\n\t\troot,\n\t\t`.current-${crypto.randomUUID()}.json`\n\t);\n\tawait writeFile(\n\t\ttemporaryPointerPath,\n\t\t`${JSON.stringify(index, null, '\\t')}\\n`,\n\t\t{ flag: 'wx' }\n\t);\n\tawait rename(temporaryPointerPath, pointerPath);\n\n\treturn index;\n};\n\nexport const readAbsoluteMobileMaterializedReleases = async (root: string) => {\n\tconst resolvedRoot = resolvePath(root);\n\ttry {\n\t\tconst serialized = await readFile(\n\t\t\tjoin(resolvedRoot, CURRENT_BUNDLE_FILE),\n\t\t\t'utf8'\n\t\t);\n\t\tconst parsed: unknown = JSON.parse(serialized);\n\t\tconst index = parseBundleIndex(parsed);\n\t\tconst bundleRoot = join(\n\t\t\tresolvedRoot,\n\t\t\tBUNDLES_DIRECTORY,\n\t\t\tindex.bundleId\n\t\t);\n\n\t\treturn Promise.all(\n\t\t\tindex.releases.map(async (artifact) => {\n\t\t\t\tconst producer = Bun.file(\n\t\t\t\t\tjoin(\n\t\t\t\t\t\tbundleRoot,\n\t\t\t\t\t\tartifact.releaseId,\n\t\t\t\t\t\tartifact.producer.module\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\tawait verifyAbsoluteMobileCompatibilityProducer({\n\t\t\t\t\tartifact,\n\t\t\t\t\tproducer\n\t\t\t\t});\n\n\t\t\t\treturn { artifact, producer };\n\t\t\t})\n\t\t);\n\t} catch (error) {\n\t\tif (errorHasCode(error, 'ENOENT')) return [];\n\n\t\tthrow error;\n\t}\n};\n",
|
|
34
|
-
"import { readFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport type { NormalizedAbsoluteMobileConfig } from './config';\n\nexport const ABSOLUTE_AUTH_PACKAGE = '@absolutejs/auth' as const;\nexport const ABSOLUTE_NATIVE_AUTH_CLIENTS_ENV =\n\t'ABSOLUTE_AUTH_NATIVE_CLIENTS' as const;\nexport const ABSOLUTE_NATIVE_AUTH_SCOPES = ['openid', 'profile'] as const;\nexport const ABSOLUTE_SYNC_PACKAGE = '@absolutejs/sync' as const;\n\nexport type AbsoluteMobileAuthManifest = {\n\tclientId: string;\n\tissuer: string;\n\tredirectUri: string;\n\tscopes: string[];\n};\n\nconst readPackageManifest = (projectRoot: string) => {\n\ttry {\n\t\treturn JSON.parse(\n\t\t\treadFileSync(join(projectRoot, 'package.json'), 'utf8')\n\t\t);\n\t} catch {\n\t\treturn undefined;\n\t}\n};\n\nconst packageManifestHas = (manifest: unknown, packageName: string) => {\n\tif (typeof manifest !== 'object' || manifest === null) return false;\n\n\treturn [\n\t\tReflect.get(manifest, 'dependencies'),\n\t\tReflect.get(manifest, 'devDependencies'),\n\t\tReflect.get(manifest, 'optionalDependencies'),\n\t\tReflect.get(manifest, 'peerDependencies')\n\t].some(\n\t\t(dependencies) =>\n\t\t\ttypeof dependencies === 'object' &&\n\t\t\tdependencies !== null &&\n\t\t\tObject.hasOwn(dependencies, packageName)\n\t);\n};\n\nexport const createAbsoluteMobileAuthManifest = (\n\tconfig: NormalizedAbsoluteMobileConfig\n): AbsoluteMobileAuthManifest => {\n\tconst scheme = config.deepLinkScheme ?? config.appId.toLowerCase();\n\n\treturn {\n\t\tclientId: `absolutejs-native:${config.appId}`,\n\t\tissuer: config.productionOrigin,\n\t\tredirectUri: `${scheme}://auth/callback`,\n\t\tscopes: [...ABSOLUTE_NATIVE_AUTH_SCOPES]\n\t};\n};\n\nexport const installAbsoluteMobileAuthEnvironment = (\n\tprojectRoot: string,\n\tconfig: NormalizedAbsoluteMobileConfig\n) => {\n\tconst auth = resolveAbsoluteMobileAuthManifest(projectRoot, config);\n\tconst serialized = serializeAbsoluteMobileAuthEnvironment(config, auth);\n\tif (serialized === undefined)\n\t\tdelete process.env[ABSOLUTE_NATIVE_AUTH_CLIENTS_ENV];\n\telse process.env[ABSOLUTE_NATIVE_AUTH_CLIENTS_ENV] = serialized;\n\n\treturn auth;\n};\n\nexport const projectUsesAbsoluteAuth = (projectRoot: string) =>\n\tpackageManifestHas(readPackageManifest(projectRoot), ABSOLUTE_AUTH_PACKAGE);\n\nexport const projectUsesAbsoluteSync = (projectRoot: string) =>\n\tpackageManifestHas(readPackageManifest(projectRoot), ABSOLUTE_SYNC_PACKAGE);\n\nexport const resolveAbsoluteMobileAuthManifest = (\n\tprojectRoot: string,\n\tconfig: NormalizedAbsoluteMobileConfig\n) =>\n\tprojectUsesAbsoluteAuth(projectRoot)\n\t\t? createAbsoluteMobileAuthManifest(config)\n\t\t: undefined;\n\nexport const serializeAbsoluteMobileAuthEnvironment = (\n\tconfig: NormalizedAbsoluteMobileConfig,\n\tauth: AbsoluteMobileAuthManifest | undefined\n) =>\n\tauth === undefined\n\t\t? undefined\n\t\t: JSON.stringify([\n\t\t\t\t{\n\t\t\t\t\t...auth,\n\t\t\t\t\tname: `${config.appName} native app`\n\t\t\t\t}\n\t\t\t]);\n",
|
|
35
|
-
"
|
|
43
|
+
"import {\n\taccess,\n\tcp,\n\tmkdir,\n\tmkdtemp,\n\treaddir,\n\treadFile,\n\trename,\n\trm,\n\twriteFile\n} from 'node:fs/promises';\nimport { createHash } from 'node:crypto';\nimport { basename, dirname, join, relative, resolve, sep } from 'node:path';\nimport type { NormalizedAbsoluteMobileConfig } from './config';\nimport {\n\tABSOLUTE_EXPO_AUTH_PACKAGE,\n\tABSOLUTE_EXPO_AUTH_CORE_VERSION,\n\tABSOLUTE_EXPO_AUTH_VERSION,\n\tABSOLUTE_EXPO_SYNC_CORE_VERSION,\n\tABSOLUTE_EXPO_SYNC_PACKAGE,\n\tABSOLUTE_EXPO_SYNC_VERSION,\n\tprojectUsesAbsoluteSync,\n\tresolveAbsoluteMobileAuthManifest,\n\ttype AbsoluteMobileAuthManifest\n} from './nativeAuth';\nimport { discoverAbsoluteSyncSchema } from './syncSchema';\nimport type { SyncLocalStoreSchemaBundle } from '@absolutejs/sync/client';\nimport {\n\tabsoluteDeviceNativeRequirements,\n\tresolveAbsoluteDeviceCapabilityPlan,\n\ttype AbsoluteDeviceCapabilityPlan\n} from './deviceCapabilities';\n\nconst EXPO_GENERATED_HEADER =\n\t'// Generated by AbsoluteJS. Edit absolute.config.ts, then run absolute mobile sync.\\n';\nconst EXPO_ASSET_EXTENSION = '.absasset';\nconst EXPO_PROJECT_MARKER = '.absolutejs-expo-project';\n\ntype AbsoluteExpoNativeDataManifest = {\n\tappBuild: string;\n\tpages: {\n\t\tbundleHash: string;\n\t\tcontract: string;\n\t\tpageId: string;\n\t}[];\n\tproductionOrigin: string;\n\troutes: { method: 'GET'; pageId: string; pattern: string }[];\n\truntime: string;\n};\n\ntype AbsoluteExpoAssetEntry = { asset: string; path: string };\n\nexport type WriteAbsoluteExpoProjectOptions = {\n\tforce?: boolean;\n\tprojectRoot: string;\n};\n\nconst exists = async (path: string) => {\n\ttry {\n\t\tawait access(path);\n\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n\ttypeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst requireManifestString = (value: unknown, field: string) => {\n\tif (typeof value !== 'string' || !value) {\n\t\tthrow new TypeError(`AbsoluteJS mobile manifest ${field} is invalid.`);\n\t}\n\n\treturn value;\n};\n\nconst expoNativeDataManifest = (\n\tvalue: unknown\n): AbsoluteExpoNativeDataManifest => {\n\tif (\n\t\t!isRecord(value) ||\n\t\t!Array.isArray(value.pages) ||\n\t\t!Array.isArray(value.routes)\n\t) {\n\t\tthrow new TypeError('AbsoluteJS mobile manifest is invalid.');\n\t}\n\tconst pages = value.pages.map((page) => {\n\t\tif (!isRecord(page))\n\t\t\tthrow new TypeError('AbsoluteJS mobile manifest page is invalid.');\n\n\t\treturn {\n\t\t\tbundleHash: requireManifestString(\n\t\t\t\tpage.bundleHash,\n\t\t\t\t'page.bundleHash'\n\t\t\t),\n\t\t\tcontract: requireManifestString(page.contract, 'page.contract'),\n\t\t\tpageId: requireManifestString(page.pageId, 'page.pageId')\n\t\t};\n\t});\n\tconst routes = value.routes.flatMap((route) => {\n\t\tif (!isRecord(route) || typeof route.method !== 'string') {\n\t\t\tthrow new TypeError('AbsoluteJS mobile manifest route is invalid.');\n\t\t}\n\t\tif (route.method !== 'GET') return [];\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tmethod: 'GET' as const,\n\t\t\t\tpageId: requireManifestString(route.pageId, 'route.pageId'),\n\t\t\t\tpattern: requireManifestString(route.pattern, 'route.pattern')\n\t\t\t}\n\t\t];\n\t});\n\n\treturn {\n\t\tappBuild: requireManifestString(value.appBuild, 'appBuild'),\n\t\tpages,\n\t\tproductionOrigin: requireManifestString(\n\t\t\tvalue.productionOrigin,\n\t\t\t'productionOrigin'\n\t\t),\n\t\troutes,\n\t\truntime: requireManifestString(value.runtime, 'runtime')\n\t};\n};\n\nconst portableRelative = (from: string, destination: string) => {\n\tconst value = relative(from, destination).replaceAll('\\\\', '/');\n\n\treturn value.startsWith('.') ? value : `./${value}`;\n};\n\nconst routeSegments = (route: string) => {\n\tconst segments = route.split('/').filter(Boolean);\n\n\treturn segments.map((segment, index) => {\n\t\tif (segment.startsWith(':')) return `[${segment.slice(1)}]`;\n\t\tif (segment === '*' && index === segments.length - 1)\n\t\t\treturn '[...absoluteWildcard]';\n\t\tif (\n\t\t\tsegment === '.' ||\n\t\t\tsegment === '..' ||\n\t\t\t!/^[A-Za-z0-9._~-]+$/u.test(segment)\n\t\t) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`Expo native route ${route} contains an unsupported segment ${segment}.`\n\t\t\t);\n\t\t}\n\n\t\treturn segment;\n\t});\n};\n\nconst routeFile = (project: string, route: string) =>\n\tjoin(project, 'app', ...routeSegments(route), 'index.tsx');\n\nconst packageDependencies = (plan: AbsoluteDeviceCapabilityPlan) =>\n\tObject.fromEntries(\n\t\tplan.requiredPackages.map((spec) => {\n\t\t\tconst separator = spec.lastIndexOf('@');\n\n\t\t\treturn [spec.slice(0, separator), spec.slice(separator + 1)];\n\t\t})\n\t);\n\nconst expoPackage = (\n\tauth: boolean,\n\tsync: boolean,\n\tdevices: AbsoluteDeviceCapabilityPlan\n) => ({\n\tdependencies: {\n\t\t'@absolutejs/devices': '0.7.0',\n\t\t'@absolutejs/devices-expo': '0.0.2',\n\t\t...(auth\n\t\t\t? {\n\t\t\t\t\t'@absolutejs/auth': ABSOLUTE_EXPO_AUTH_CORE_VERSION,\n\t\t\t\t\t[ABSOLUTE_EXPO_AUTH_PACKAGE]: ABSOLUTE_EXPO_AUTH_VERSION\n\t\t\t\t}\n\t\t\t: {}),\n\t\t...(sync\n\t\t\t? {\n\t\t\t\t\t'@absolutejs/sync': ABSOLUTE_EXPO_SYNC_CORE_VERSION,\n\t\t\t\t\t[ABSOLUTE_EXPO_SYNC_PACKAGE]: ABSOLUTE_EXPO_SYNC_VERSION\n\t\t\t\t}\n\t\t\t: {}),\n\t\texpo: '~57.0.9',\n\t\t'expo-asset': '~57.0.15',\n\t\t'expo-constants': '~57.0.16',\n\t\t'expo-dev-client': '~57.0.16',\n\t\t'expo-file-system': '~57.0.6',\n\t\t'expo-haptics': '~57.0.2',\n\t\t'expo-linking': '~57.0.8',\n\t\t...(sync\n\t\t\t? {\n\t\t\t\t\t'expo-background-task': '~57.0.14',\n\t\t\t\t\t'expo-network': '~57.0.1',\n\t\t\t\t\t'expo-sqlite': '~57.0.2',\n\t\t\t\t\t'expo-task-manager': '~57.0.14',\n\t\t\t\t\t'expo-updates': '~57.0.19'\n\t\t\t\t}\n\t\t\t: {}),\n\t\t'expo-router': '~57.0.17',\n\t\t...(auth\n\t\t\t? {\n\t\t\t\t\t'expo-secure-store': '~57.0.2',\n\t\t\t\t\t'expo-web-browser': '~57.0.2'\n\t\t\t\t}\n\t\t\t: {}),\n\t\treact: '19.2.3',\n\t\t'react-native': '0.86.3',\n\t\t'react-native-safe-area-context': '~5.7.0',\n\t\t'react-native-screens': '4.26.0',\n\t\t'react-native-webview': '13.16.1',\n\t\t...packageDependencies(devices)\n\t},\n\tdevDependencies: {\n\t\t'@types/react': '~19.2.2',\n\t\ttypescript: '~6.0.3'\n\t},\n\tmain: 'expo-router/entry',\n\tname: 'absolutejs-expo-shell',\n\tprivate: true,\n\tscripts: {\n\t\tandroid: 'expo run:android',\n\t\tios: 'expo run:ios',\n\t\tstart: 'expo start --dev-client'\n\t},\n\tversion: '0.0.0'\n});\n\nconst expoAppConfig = (\n\tconfig: NormalizedAbsoluteMobileConfig,\n\tauth: boolean,\n\tsync: boolean,\n\tdevices: AbsoluteDeviceCapabilityPlan\n) => {\n\tconst requirements = absoluteDeviceNativeRequirements(devices);\n\tconst usageKey = (purpose: string) => {\n\t\tif (purpose === 'camera') return 'NSCameraUsageDescription';\n\t\tif (purpose === 'photo-library')\n\t\t\treturn 'NSPhotoLibraryUsageDescription';\n\t\tif (purpose === 'photo-library-add')\n\t\t\treturn 'NSPhotoLibraryAddUsageDescription';\n\t\tif (purpose === 'location-always')\n\t\t\treturn 'NSLocationAlwaysAndWhenInUseUsageDescription';\n\n\t\treturn 'NSLocationWhenInUseUsageDescription';\n\t};\n\tconst usageDescription = (purpose: string) => {\n\t\tif (purpose === 'camera')\n\t\t\treturn `${config.appName} uses your camera when you choose to take a photo.`;\n\t\tif (purpose === 'photo-library')\n\t\t\treturn `${config.appName} accesses your photo library only for photo actions you choose.`;\n\t\tif (purpose.startsWith('location-'))\n\t\t\treturn `${config.appName} uses your location only while you use the app and request a location-based action.`;\n\n\t\treturn `${config.appName} adds to your photo library only for photo actions you choose.`;\n\t};\n\tconst descriptions = Object.fromEntries(\n\t\trequirements.iosUsageDescriptions.map((purpose) => [\n\t\t\tusageKey(purpose),\n\t\t\tusageDescription(purpose)\n\t\t])\n\t);\n\tconst devicePlugins = [\n\t\t...new Set(\n\t\t\tdevices.capabilities.flatMap(\n\t\t\t\t(name) => devices.providers[name]?.plugins ?? []\n\t\t\t)\n\t\t)\n\t];\n\tconst configuredPlugins = devicePlugins.map((plugin) => {\n\t\tif (plugin === 'expo-image-picker')\n\t\t\treturn [\n\t\t\t\tplugin,\n\t\t\t\t{\n\t\t\t\t\tcameraPermission: descriptions.NSCameraUsageDescription,\n\t\t\t\t\tmicrophonePermission: false,\n\t\t\t\t\tphotosPermission:\n\t\t\t\t\t\tdescriptions.NSPhotoLibraryUsageDescription\n\t\t\t\t}\n\t\t\t];\n\t\tif (plugin === 'expo-location')\n\t\t\treturn [\n\t\t\t\tplugin,\n\t\t\t\t{\n\t\t\t\t\tlocationWhenInUsePermission:\n\t\t\t\t\t\tdescriptions.NSLocationWhenInUseUsageDescription\n\t\t\t\t}\n\t\t\t];\n\n\t\treturn plugin;\n\t});\n\n\treturn {\n\t\texpo: {\n\t\t\tandroid: {\n\t\t\t\t...(devicePlugins.includes('expo-image-picker')\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tblockedPermissions: [\n\t\t\t\t\t\t\t\t'android.permission.READ_EXTERNAL_STORAGE',\n\t\t\t\t\t\t\t\t'android.permission.RECORD_AUDIO',\n\t\t\t\t\t\t\t\t'android.permission.WRITE_EXTERNAL_STORAGE'\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t\tintentFilters: config.deepLinkHosts.map((host) => ({\n\t\t\t\t\taction: 'VIEW',\n\t\t\t\t\tautoVerify: true,\n\t\t\t\t\tcategory: ['BROWSABLE', 'DEFAULT'],\n\t\t\t\t\tdata: [{ host, pathPrefix: '/', scheme: 'https' }]\n\t\t\t\t})),\n\t\t\t\tpackage: config.appId,\n\t\t\t\tpermissions: requirements.androidPermissions\n\t\t\t},\n\t\t\texperiments: { typedRoutes: true },\n\t\t\tios: {\n\t\t\t\tassociatedDomains: config.deepLinkHosts.map(\n\t\t\t\t\t(host) => `applinks:${host}`\n\t\t\t\t),\n\t\t\t\tbundleIdentifier: config.appId,\n\t\t\t\tinfoPlist: descriptions,\n\t\t\t\t...(requirements.iosPrivacyAccessedApis.length > 0\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tprivacyManifests: {\n\t\t\t\t\t\t\t\tNSPrivacyAccessedAPITypes:\n\t\t\t\t\t\t\t\t\trequirements.iosPrivacyAccessedApis.map(\n\t\t\t\t\t\t\t\t\t\t({ api, reasons }) => ({\n\t\t\t\t\t\t\t\t\t\t\tNSPrivacyAccessedAPIType: api,\n\t\t\t\t\t\t\t\t\t\t\tNSPrivacyAccessedAPITypeReasons:\n\t\t\t\t\t\t\t\t\t\t\t\treasons\n\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t\t...(config.iosVersion ? { buildNumber: config.iosVersion } : {})\n\t\t\t},\n\t\t\tname: config.appName,\n\t\t\tplugins: [\n\t\t\t\t'expo-router',\n\t\t\t\t['expo-dev-client', { launchMode: 'most-recent' }],\n\t\t\t\t...(auth ? ['expo-secure-store'] : []),\n\t\t\t\t...(sync\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t'expo-sqlite',\n\t\t\t\t\t\t\t'expo-background-task',\n\t\t\t\t\t\t\t'expo-task-manager'\n\t\t\t\t\t\t]\n\t\t\t\t\t: []),\n\t\t\t\t...configuredPlugins\n\t\t\t],\n\t\t\truntimeVersion: { policy: 'appVersion' },\n\t\t\tscheme: config.deepLinkScheme,\n\t\t\tslug: config.appId.toLowerCase().replaceAll('.', '-'),\n\t\t\tversion: config.iosVersion ?? '0.1.0'\n\t\t}\n\t};\n};\n\nconst expoDynamicAppConfig = `${EXPO_GENERATED_HEADER}const config = require('./app.json');\n\nif (process.env.ABSOLUTE_EXPO_DEVELOPMENT === '1' && process.env.ABSOLUTE_EXPO_DEVELOPMENT_CA_PATH) {\n\tconfig.expo.plugins = [\n\t\t...config.expo.plugins,\n\t\t'./plugins/withAbsoluteDevelopmentCa'\n\t];\n}\n\nmodule.exports = config;\n`;\n\nconst expoDevelopmentCaPlugin = `${EXPO_GENERATED_HEADER}const { AndroidConfig, withAndroidManifest, withDangerousMod } = require('expo/config-plugins');\nconst { copyFile, mkdir } = require('node:fs/promises');\nconst path = require('node:path');\n\nconst NETWORK_CONFIG = [\n\t'<?xml version=\"1.0\" encoding=\"utf-8\"?>',\n\t'<network-security-config>',\n\t'\\t<debug-overrides>',\n\t'\\t\\t<trust-anchors>',\n\t'\\t\\t\\t<certificates src=\"@raw/absolutejs_dev_ca\" />',\n\t'\\t\\t</trust-anchors>',\n\t'\\t</debug-overrides>',\n\t'</network-security-config>',\n\t''\n].join('\\\\n');\n\nconst withAbsoluteDevelopmentCa = config => {\n\tconfig = withAndroidManifest(config, value => {\n\t\tconst application = AndroidConfig.Manifest.getMainApplicationOrThrow(value.modResults);\n\t\tapplication.$['android:networkSecurityConfig'] = '@xml/absolutejs_dev_network_security';\n\t\treturn value;\n\t});\n\treturn withDangerousMod(config, ['android', async value => {\n\t\tconst certificate = process.env.ABSOLUTE_EXPO_DEVELOPMENT_CA_PATH;\n\t\tif (!certificate) throw new Error('AbsoluteJS Expo HTTPS development requires its development CA path.');\n\t\tconst resources = path.join(value.modRequest.platformProjectRoot, 'app', 'src', 'main', 'res');\n\t\tawait Promise.all([\n\t\t\tmkdir(path.join(resources, 'raw'), { recursive: true }),\n\t\t\tmkdir(path.join(resources, 'xml'), { recursive: true })\n\t\t]);\n\t\tawait Promise.all([\n\t\t\tcopyFile(certificate, path.join(resources, 'raw', 'absolutejs_dev_ca.pem')),\n\t\t\trequire('node:fs/promises').writeFile(path.join(resources, 'xml', 'absolutejs_dev_network_security.xml'), NETWORK_CONFIG)\n\t\t]);\n\t\treturn value;\n\t}]);\n};\n\nmodule.exports = withAbsoluteDevelopmentCa;\n`;\n\nconst metroConfig = (projectRoot: string) =>\n\t`${EXPO_GENERATED_HEADER}const { getDefaultConfig } = require('expo/metro-config');\nconst path = require('node:path');\n\nconst projectRoot = __dirname;\nconst appRoot = ${JSON.stringify(projectRoot)};\nconst config = getDefaultConfig(projectRoot);\nconfig.resolver.assetExts.push('absasset');\nconfig.resolver.nodeModulesPaths = [\n\tpath.join(projectRoot, 'node_modules'),\n\tpath.join(appRoot, 'node_modules')\n];\nconfig.watchFolders = [appRoot];\n\nmodule.exports = config;\n`;\n\nconst layoutSource = (auth: boolean, sync: boolean) =>\n\t`${EXPO_GENERATED_HEADER}import { Stack } from 'expo-router';\nimport '../src/generated/AbsoluteDevices';\n${auth ? \"import { useEffect, useState } from 'react';\\nimport { startAbsoluteExpoAuth } from '../src/generated/AbsoluteAuth';\" : ''}\n${sync ? \"import { startAbsoluteExpoSync } from '../src/generated/AbsoluteSync';\" : ''}\n\nexport default function AbsoluteLayout() {\n\t${\n\t\tauth\n\t\t\t? `const [ready, setReady] = useState(false);\n\tuseEffect(() => {\n\t\tlet active = true;\n\t\tvoid ${sync ? 'startAbsoluteExpoSync' : 'startAbsoluteExpoAuth'}().then(() => { if (active) setReady(true); });\n\t\treturn () => { active = false; };\n\t}, []);\n\tif (!ready) return null;`\n\t\t\t: ''\n\t}\n\treturn <Stack screenOptions={{ headerShown: false }} />;\n}\n`;\n\nconst nativeDiagnosticSource = `${EXPO_GENERATED_HEADER}import * as Haptics from 'expo-haptics';\nimport { Link } from 'expo-router';\nimport { Pressable, SafeAreaView, StyleSheet, Text, View } from 'react-native';\n\nexport default function AbsoluteNativeDiagnostic() {\n\treturn (\n\t\t<SafeAreaView style={styles.page}>\n\t\t\t<View style={styles.card}>\n\t\t\t\t<Text style={styles.eyebrow}>ABSOLUTEJS · EXPO EXPERIMENT</Text>\n\t\t\t\t<Text style={styles.title}>This screen is native React UI.</Text>\n\t\t\t\t<Text style={styles.body}>Ordinary AbsoluteJS routes remain embedded web routes. Only explicitly owned routes use React Native.</Text>\n\t\t\t\t<Pressable style={styles.button} onPress={() => Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Medium)}>\n\t\t\t\t\t<Text style={styles.buttonText}>Test native haptics</Text>\n\t\t\t\t</Pressable>\n\t\t\t\t<Link href=\"/\" style={styles.link}>Open the AbsoluteJS app</Link>\n\t\t\t</View>\n\t\t</SafeAreaView>\n\t);\n}\n\nconst styles = StyleSheet.create({\n\tbody: { color: '#cbd5e1', fontSize: 16, lineHeight: 24 },\n\tbutton: { backgroundColor: '#f8fafc', borderRadius: 12, padding: 14 },\n\tbuttonText: { color: '#020617', fontSize: 16, fontWeight: '700', textAlign: 'center' },\n\tcard: { backgroundColor: '#0f172a', borderRadius: 24, gap: 20, maxWidth: 560, padding: 28, width: '100%' },\n\teyebrow: { color: '#38bdf8', fontSize: 12, fontWeight: '800', letterSpacing: 1.5 },\n\tlink: { color: '#7dd3fc', fontSize: 16, textAlign: 'center' },\n\tpage: { alignItems: 'center', backgroundColor: '#020617', flex: 1, justifyContent: 'center', padding: 20 },\n\ttitle: { color: '#f8fafc', fontSize: 32, fontWeight: '800' }\n});\n`;\n\nconst devicesRuntimeSource = (\n\tconfig: NormalizedAbsoluteMobileConfig,\n\tplan: AbsoluteDeviceCapabilityPlan,\n\tauth: boolean\n) => {\n\tconst imports = plan.capabilities.map((name, index) => {\n\t\tconst provider = plan.providers[name];\n\t\tif (!provider)\n\t\t\tthrow new TypeError(\n\t\t\t\t`Missing Expo device capability provider ${name}.`\n\t\t\t);\n\n\t\treturn `import { ${provider.factory} as absoluteExpoCapability${index} } from ${JSON.stringify(provider.module)};`;\n\t});\n\tconst pushIndex = plan.capabilities.indexOf('pushNotifications');\n\tconst push = pushIndex !== -1;\n\tif (push && !auth)\n\t\tthrow new TypeError(\n\t\t\t'Expo push notifications require the provisioned AbsoluteJS Auth runtime.'\n\t\t);\n\tconst entries = plan.capabilities\n\t\t.map(\n\t\t\t(name, index) =>\n\t\t\t\t`${JSON.stringify(name)}: absoluteExpoCapability${index}(${name === 'pushNotifications' ? 'absoluteExpoPushOptions' : ''})`\n\t\t)\n\t\t.join(',\\n\\t');\n\tconst pushSource = push\n\t\t? `const INSTALLATION_KEY = 'absolutejs.push.installation-id';\nconst requirePushResponse = async (response: Response, operation: string) => {\n\tif (!response.ok) throw new Error(\\`AbsoluteJS native push \\${operation} failed with HTTP \\${response.status}.\\`);\n\treturn response.json() as Promise<Record<string, unknown>>;\n};\nconst absoluteExpoPushOptions = {\n\tonRegistration: async (registration: { platform: 'apns' | 'fcm'; token: string }) => {\n\t\tconst known = await absoluteExpoDevices.storage.get(INSTALLATION_KEY);\n\t\tconst register = (installationId?: string | null) => absoluteExpoAuth.fetch('/auth/push', {\n\t\t\tbody: JSON.stringify({ ...(installationId ? { installationId } : {}), platform: registration.platform, token: registration.token }),\n\t\t\theaders: { 'content-type': 'application/json' },\n\t\t\tmethod: 'POST'\n\t\t});\n\t\tlet response = await register(known);\n\t\tconst conflict = response.status === 409 && await response.clone().json().then(value => typeof value === 'object' && value !== null && Reflect.get(value, 'code') === 'installation-ownership').catch(() => false);\n\t\tif (known && conflict) {\n\t\t\tawait absoluteExpoDevices.storage.remove(INSTALLATION_KEY);\n\t\t\tresponse = await register();\n\t\t}\n\t\tconst result = await requirePushResponse(response, 'registration');\n\t\tif (typeof result.installationId !== 'string' || !result.installationId || result.installationId.length > 128) throw new Error('AbsoluteJS native push returned an invalid installation identity.');\n\t\tawait absoluteExpoDevices.storage.set(INSTALLATION_KEY, result.installationId);\n\t},\n\tonUnregistration: async () => {\n\t\tconst installationId = await absoluteExpoDevices.storage.get(INSTALLATION_KEY);\n\t\tif (!installationId) return;\n\t\tawait requirePushResponse(await absoluteExpoAuth.fetch('/auth/push', {\n\t\t\tbody: JSON.stringify({ installationId }),\n\t\t\theaders: { 'content-type': 'application/json' },\n\t\t\tmethod: 'DELETE'\n\t\t}), 'removal');\n\t\tawait absoluteExpoDevices.storage.remove(INSTALLATION_KEY);\n\t}\n};`\n\t\t: '';\n\n\treturn `${EXPO_GENERATED_HEADER}import { installDeviceAdapter } from '@absolutejs/devices/runtime';\nimport { createExpoDeviceAdapter } from '@absolutejs/devices-expo';\n${push ? \"import { absoluteExpoAuth } from './AbsoluteAuth';\" : ''}\n${imports.join('\\n')}\n\n${pushSource}\n\nexport const absoluteExpoDeviceCapabilities = ${JSON.stringify(plan.capabilities)} as const;\nexport const absoluteExpoDevices = createExpoDeviceAdapter({\n\tstoragePrefix: ${JSON.stringify(`absolutejs.${config.appId}.`)},\n\t${entries}\n});\ninstallDeviceAdapter(absoluteExpoDevices);\nexport const beforeAbsoluteExpoDeviceSignOut = async () => {\n\t${push ? 'await absoluteExpoDevices.pushNotifications?.disable();' : ''}\n};\n${\n\tpush\n\t\t? `absoluteExpoAuth.onPrincipalChange(principal => {\n\tif (!principal) return;\n\tvoid absoluteExpoDevices.pushNotifications?.queryPermission().then(permission => permission.state === 'granted' ? absoluteExpoDevices.pushNotifications?.enable() : undefined).catch(() => undefined);\n});`\n\t\t: ''\n}\n`;\n};\n\nconst authRuntimeSource = (auth: AbsoluteMobileAuthManifest, appId: string) => {\n\tconst storageIdentity = createHash('sha256')\n\t\t.update(appId)\n\t\t.digest('hex')\n\t\t.slice(0, 24);\n\n\treturn `${EXPO_GENERATED_HEADER}import { createAbsoluteExpoAuthClient } from '@absolutejs/auth-expo';\nimport { createMobileAuthTransport, installAuthClientRuntimeTransport } from '@absolutejs/auth/client/mobile';\n\nexport const absoluteExpoAuth = createAbsoluteExpoAuthClient({\n\tallowedOrigins: [${JSON.stringify(auth.issuer)}],\n\tclientId: ${JSON.stringify(auth.clientId)},\n\tissuer: ${JSON.stringify(auth.issuer)},\n\tredirectUri: ${JSON.stringify(auth.redirectUri)},\n\tresource: ${JSON.stringify(auth.issuer)},\n\tscopes: ${JSON.stringify(auth.scopes)},\n\tstoragePrefix: ${JSON.stringify(`absolutejs.auth.${storageIdentity}`)}\n});\ninstallAuthClientRuntimeTransport(createMobileAuthTransport(absoluteExpoAuth, { baseUrl: ${JSON.stringify(auth.issuer)} }));\n\nlet currentPrincipal: Awaited<ReturnType<typeof absoluteExpoAuth.principal>> = null;\nabsoluteExpoAuth.onPrincipalChange(principal => {\n\tcurrentPrincipal = principal;\n});\nexport const getAbsoluteExpoAuthPrincipal = () => currentPrincipal;\n\nlet startPromise: Promise<void> | undefined;\nexport const startAbsoluteExpoAuth = () => {\n\tstartPromise ??= absoluteExpoAuth.start().then(async () => {\n\t\tcurrentPrincipal = await absoluteExpoAuth.principal();\n\t});\n\n\treturn startPromise;\n};\n`;\n};\n\nconst syncRuntimeSource = (\n\tconfig: NormalizedAbsoluteMobileConfig,\n\tschema: SyncLocalStoreSchemaBundle\n) => {\n\tconst storageIdentity = createHash('sha256')\n\t\t.update(config.appId)\n\t\t.digest('hex')\n\t\t.slice(0, 24);\n\tconst backgroundEndpoint = new URL(\n\t\t'/__absolute/sync/background',\n\t\tconfig.productionOrigin\n\t).href;\n\tconst backgroundTask = `${config.appId}.absolutejs.sync`;\n\n\treturn `${EXPO_GENERATED_HEADER}import { runHeadlessSync } from '@absolutejs/sync/client/headless';\nimport type { SyncLocalStoreSchemaBundle } from '@absolutejs/sync/client';\nimport { installSyncClientRuntimeTransport } from '@absolutejs/sync/client/runtime';\nimport {\n\tcreateExpoSyncBridgeHost,\n\tcreateExpoSyncLocalStore,\n\tcreateExpoSyncProtection,\n\tcreateExpoSyncSocketBridgeHost,\n\tdefineExpoSyncBackgroundTask,\n\tinstallExpoSyncLifecycle,\n\tregisterExpoSyncBackgroundTask\n} from '@absolutejs/sync-expo';\nimport * as Updates from 'expo-updates';\nimport { absoluteExpoAuth, startAbsoluteExpoAuth } from './AbsoluteAuth';\n\nconst BACKGROUND_TASK = ${JSON.stringify(backgroundTask)};\nconst BACKGROUND_ENDPOINT = ${JSON.stringify(backgroundEndpoint)};\nconst PRODUCTION_ORIGIN = ${JSON.stringify(config.productionOrigin)};\nconst STORAGE_SCHEMA: SyncLocalStoreSchemaBundle = ${JSON.stringify(schema)};\nconst store = createExpoSyncLocalStore({\n\tdatabaseName: ${JSON.stringify(`absolutejs-sync-${storageIdentity}.db`)},\n\tprotection: createExpoSyncProtection({ storagePrefix: ${JSON.stringify(`absolutejs.sync.${storageIdentity}`)} }),\n\tstorageSchema: STORAGE_SCHEMA\n});\n\nconst runBackgroundSync = async () => {\n\tawait startAbsoluteExpoAuth();\n\tconst principal = await absoluteExpoAuth.principal();\n\tif (!principal) return;\n\tawait runHeadlessSync({\n\t\tendpoint: BACKGROUND_ENDPOINT,\n\t\tfetch: (url, init) => absoluteExpoAuth.fetch(url, init),\n\t\tnamespace: principal.namespace,\n\t\tstore\n\t});\n};\ndefineExpoSyncBackgroundTask(BACKGROUND_TASK, runBackgroundSync);\n\nlet activeNamespace: string | undefined;\nlet started = false;\nlet startPromise: Promise<void> | undefined;\nexport const startAbsoluteExpoSync = () => {\n\tstartPromise ??= (async () => {\n\t\tawait startAbsoluteExpoAuth();\n\t\tconst principal = await absoluteExpoAuth.principal();\n\t\tactiveNamespace = principal?.namespace;\n\t\tinstallSyncClientRuntimeTransport({\n\t\t\t...(principal ? { durable: { namespace: principal.namespace, store }, socketTicket: () => absoluteExpoAuth.socketTicket() } : {}),\n\t\t\tregisterClient: client => installExpoSyncLifecycle({ client })\n\t\t});\n\t\tawait registerExpoSyncBackgroundTask(BACKGROUND_TASK, { minimumInterval: 15 });\n\t\tstarted = true;\n\t})();\n\n\treturn startPromise;\n};\n\nabsoluteExpoAuth.onPrincipalChange(principal => {\n\tif (!started || principal?.namespace === activeNamespace) return;\n\tvoid Updates.reloadAsync();\n});\n\nexport const createAbsoluteExpoSyncBridge = async (\n\temit: (event: 'sync.socket' | 'sync.wake', payload: Record<string, unknown>) => void\n) => {\n\tawait startAbsoluteExpoSync();\n\tconst principal = await absoluteExpoAuth.principal();\n\tif (!principal) return {\n\t\tclose: () => undefined,\n\t\trequest: async () => { throw new Error('Expo Sync requires an authenticated principal.'); }\n\t};\n\tconst transactions = createExpoSyncBridgeHost({ namespace: principal.namespace, store });\n\tconst sockets = createExpoSyncSocketBridgeHost({\n\t\tallowedOrigin: PRODUCTION_ORIGIN,\n\t\temit: payload => emit('sync.socket', payload),\n\t\tsocketTicket: audience => absoluteExpoAuth.socketTicket(audience)\n\t});\n\tconst removeLifecycle = installExpoSyncLifecycle({\n\t\tclient: { reconnect: () => emit('sync.wake', {}) }\n\t});\n\n\treturn {\n\t\tclose: async () => {\n\t\t\tremoveLifecycle();\n\t\t\tawait Promise.all([transactions.close(), sockets.close()]);\n\t\t},\n\t\trequest: (method: string, params: Record<string, unknown>) =>\n\t\t\tmethod.startsWith('sync.socket.')\n\t\t\t\t? sockets.request(method, params)\n\t\t\t\t: transactions.request(method, params)\n\t};\n};\n`;\n};\n\nconst webHostSource = (\n\tconfig: NormalizedAbsoluteMobileConfig,\n\tauth: AbsoluteMobileAuthManifest | undefined,\n\tsync: boolean\n) => {\n\tconst nativeRoutes = [\n\t\t'/__absolute/native',\n\t\t...Object.keys(config.expoNativeRoutes)\n\t];\n\tconst nativeRoutePatterns = nativeRoutes.map((route) =>\n\t\troute.split('/').filter(Boolean)\n\t);\n\n\treturn `${EXPO_GENERATED_HEADER}import * as Linking from 'expo-linking';\nimport { router, usePathname } from 'expo-router';\nimport { useEffect, useRef, useState } from 'react';\nimport { ActivityIndicator, BackHandler, Platform, StyleSheet, View } from 'react-native';\nimport { WebView, type WebViewMessageEvent } from 'react-native-webview';\nimport { materializeAbsoluteWebBundle } from './webAssets';\nimport { createExpoDevicesBridgeHost } from '@absolutejs/devices-expo/bridge';\nimport { absoluteExpoDevices, beforeAbsoluteExpoDeviceSignOut } from './AbsoluteDevices';\n${auth ? \"import { absoluteExpoAuth, getAbsoluteExpoAuthPrincipal, startAbsoluteExpoAuth } from './AbsoluteAuth';\" : ''}\n${sync ? \"import { createAbsoluteExpoSyncBridge, startAbsoluteExpoSync } from './AbsoluteSync';\" : ''}\n\nconst BRIDGE_FORMAT = 3;\nconst MAX_MESSAGE_BYTES = 64 * 1024;\nconst MAX_HTTP_BODY_BYTES = 48 * 1024;\nconst NATIVE_ROUTE_PATTERNS = ${JSON.stringify(nativeRoutePatterns)};\nconst PRODUCTION_ORIGIN = ${JSON.stringify(config.productionOrigin)};\nconst DEV_ORIGIN = Platform.OS === 'android'\n\t? process.env.EXPO_PUBLIC_ABSOLUTE_DEV_ANDROID_ORIGIN\n\t: process.env.EXPO_PUBLIC_ABSOLUTE_DEV_IOS_ORIGIN;\nconst HMR_TARGET = Platform.OS === 'android' ? 'expo-android' : 'expo-ios';\nconst AUTH_ENABLED = ${auth ? 'true' : 'false'};\nconst SYNC_ENABLED = ${sync ? 'true' : 'false'};\n\nconst isNativeRoute = (pathname: string) => {\n\tconst segments = pathname.split('/').filter(Boolean);\n\treturn NATIVE_ROUTE_PATTERNS.some(pattern => {\n\t\tfor (let index = 0; index < pattern.length; index += 1) {\n\t\t\tconst expected = pattern[index]!;\n\t\t\tif (expected === '*') return segments.length > index;\n\t\t\tif (segments[index] === undefined) return false;\n\t\t\tif (!expected.startsWith(':') && expected !== segments[index]) return false;\n\t\t}\n\t\treturn segments.length === pattern.length;\n\t});\n};\n\nconst bridgeBootstrap = (path: string) => {\n\tconst initialPath = DEV_ORIGIN\n\t\t? 'location.pathname + location.search + location.hash'\n\t\t: JSON.stringify(path);\n\treturn \\`(() => {\n\tconst pending = new Map();\n\tconst listeners = new Map();\n\tlet sequence = 0;\n\tlet currentPath = \\${initialPath};\n\tconst send = value => {\n\t\tconst source = JSON.stringify(value);\n\t\tif (new TextEncoder().encode(source).byteLength > 65536) throw new Error('Expo bridge message exceeds 64 KiB.');\n\t\twindow.ReactNativeWebView.postMessage(source);\n\t};\n\tglobalThis.__absoluteExpoReceive = source => {\n\t\tconst message = JSON.parse(source);\n\t\tif (message.kind === 'event') {\n\t\t\tfor (const listener of listeners.get(message.event) || []) listener(message.payload || {});\n\t\t\treturn;\n\t\t}\n\t\tconst operation = pending.get(message.id);\n\t\tif (!operation) return;\n\t\tpending.delete(message.id);\n\t\tclearTimeout(operation.timer);\n\t\tmessage.error ? operation.reject(new Error(message.error.message)) : operation.resolve(message.result);\n\t};\n\tglobalThis.__absoluteExpoBridge = {\n\t\ton(event, listener) {\n\t\t\tconst values = listeners.get(event) || new Set();\n\t\t\tvalues.add(listener);\n\t\t\tlisteners.set(event, values);\n\t\t\treturn () => {\n\t\t\t\tvalues.delete(listener);\n\t\t\t\tif (values.size === 0) listeners.delete(event);\n\t\t\t};\n\t\t},\n\t\trequest(method, params) {\n\t\t\tconst id = 'web_' + Date.now().toString(36) + '_' + (++sequence).toString(36);\n\t\t\tsend({ format: 3, id, kind: 'request', method, params, path: currentPath });\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tconst interactive = method.startsWith('devices.camera.') || method.startsWith('devices.photos.') || method.startsWith('devices.documents.') || method.endsWith('.requestPermission');\n\t\t\t\tconst timer = setTimeout(() => {\n\t\t\t\t\tpending.delete(id);\n\t\t\t\t\treject(new Error('Expo bridge request timed out.'));\n\t\t\t\t}, interactive ? 5 * 60 * 1000 : 30 * 1000);\n\t\t\t\tpending.set(id, { reject, resolve, timer });\n\t\t\t});\n\t\t},\n\t\tsetPath(path) {\n\t\t\tcurrentPath = path;\n\t\t\tsend({ format: 3, kind: 'event', event: 'navigation', path });\n\t\t}\n\t};\n\tif (\\${DEV_ORIGIN ? 'true' : 'false'}) {\n\t\tconst publishPath = () => {\n\t\t\tconst path = location.pathname + location.search + location.hash;\n\t\t\tif (path === currentPath) return;\n\t\t\tcurrentPath = path;\n\t\t\tsend({ format: 3, kind: 'event', event: 'navigation', path });\n\t\t};\n\t\tfor (const method of ['pushState', 'replaceState']) {\n\t\t\tconst original = history[method];\n\t\t\thistory[method] = function(...args) {\n\t\t\t\tconst result = original.apply(this, args);\n\t\t\t\tpublishPath();\n\t\t\t\treturn result;\n\t\t\t};\n\t\t}\n\t\taddEventListener('popstate', publishPath);\n\t\taddEventListener('hashchange', publishPath);\n\t}\n\tdocument.addEventListener('click', event => {\n\t\tconst anchor = event.target instanceof Element ? event.target.closest('a[href]') : null;\n\t\tif (!anchor) return;\n\t\tconst url = new URL(anchor.href, location.href);\n\t\tif (!isNativeRoute(url.pathname)) return;\n\t\tevent.preventDefault();\n\t\tsend({ format: 3, kind: 'event', event: 'navigation', path: url.pathname + url.search + url.hash });\n\t}, true);\n\tsend({ format: 3, kind: 'event', event: 'ready', path: currentPath });\n})(); true;\\`;\n};\n\nconst bridgeFetch = async (params: Record<string, unknown>) => {\n\tif (typeof params.method !== 'string' || !['DELETE', 'GET', 'PATCH', 'POST', 'PUT'].includes(params.method) || typeof params.url !== 'string' || typeof params.headers !== 'object' || params.headers === null || Array.isArray(params.headers) || params.body !== undefined && typeof params.body !== 'string') throw new Error('Expo bridge HTTP request is invalid.');\n\tconst url = new URL(params.url);\n\tif (url.origin !== PRODUCTION_ORIGIN || url.username || url.password) throw new Error('Expo bridge HTTP request left productionOrigin.');\n\tconst headers = new Headers();\n\tfor (const [name, value] of Object.entries(params.headers as Record<string, unknown>)) {\n\t\tconst normalized = name.toLowerCase();\n\t\tif (typeof value !== 'string' || (normalized !== 'accept' && normalized !== 'content-type' && !normalized.startsWith('x-absolute-mobile-'))) throw new Error('Expo bridge HTTP header is not allowed.');\n\t\theaders.set(normalized, value);\n\t}\n\tconst response = await ${auth ? 'absoluteExpoAuth.fetchOptional' : 'fetch'}(url, { ...(typeof params.body === 'string' ? { body: params.body } : {}), headers, method: params.method, redirect: 'manual' });\n\tif (new URL(response.url || url.href).origin !== PRODUCTION_ORIGIN || response.status >= 300 && response.status < 400) throw new Error('Expo bridge HTTP redirects are not allowed.');\n\tconst body = await response.text();\n\tif (new TextEncoder().encode(body).byteLength > MAX_HTTP_BODY_BYTES) throw new Error('Expo bridge HTTP response exceeds 48 KiB.');\n\tconst responseHeaders: Record<string, string> = {};\n\tfor (const name of ['cache-control', 'content-type']) {\n\t\tconst value = response.headers.get(name);\n\t\tif (value) responseHeaders[name] = value;\n\t}\n\treturn { body, headers: responseHeaders, status: response.status };\n};\n\nconst authStatus = async () => {\n\t${\n\t\tauth\n\t\t\t? `const user = await absoluteExpoAuth.status();\n\tconst principal = getAbsoluteExpoAuthPrincipal();\n\treturn { principal: principal ? { namespace: principal.namespace } : null, user };`\n\t\t\t: \"throw new Error('Expo Auth is not configured.');\"\n\t}\n};\n\nexport function AbsoluteWebHost() {\n\tconst pathname = usePathname() || '/';\n\tconst webView = useRef<WebView>(null);\n\tconst devicesBridge = useRef<{ close(): void | Promise<void>; request(method: string, params: Record<string, unknown>): Promise<unknown> } | undefined>(undefined);\n\tconst syncBridge = useRef<{ close(): void | Promise<void>; request(method: string, params: Record<string, unknown>): Promise<unknown> } | undefined>(undefined);\n\tconst [indexUri, setIndexUri] = useState<string>();\n\tconst [canGoBack, setCanGoBack] = useState(false);\n\tconst [runtimeReady, setRuntimeReady] = useState(!AUTH_ENABLED && !SYNC_ENABLED);\n\tconst [devicesReady, setDevicesReady] = useState(false);\n\tconst activeWebPath = useRef(pathname);\n\n\tuseEffect(() => {\n\t\tif (!AUTH_ENABLED && !SYNC_ENABLED) return;\n\t\tlet active = true;\n\t\t${\n\t\t\tauth\n\t\t\t\t? `const stop = absoluteExpoAuth.onPrincipalChange(principal => {\n\t\t\tif (!active) return;\n\t\t\tconst source = JSON.stringify({ event: 'auth.principal', format: BRIDGE_FORMAT, kind: 'event', path: activeWebPath.current, payload: { principal: principal ? { namespace: principal.namespace } : null } });\n\t\t\twebView.current?.injectJavaScript(\\`globalThis.__absoluteExpoReceive(\\${JSON.stringify(source)}); true;\\`);\n\t\t});\n\t\tvoid ${sync ? 'startAbsoluteExpoSync' : 'startAbsoluteExpoAuth'}().then(async () => {\n\t\t\t${\n\t\t\t\tsync\n\t\t\t\t\t? `syncBridge.current = await createAbsoluteExpoSyncBridge((event, payload) => {\n\t\t\t\tconst source = JSON.stringify({ event, format: BRIDGE_FORMAT, kind: 'event', path: activeWebPath.current, payload });\n\t\t\t\twebView.current?.injectJavaScript(\\`globalThis.__absoluteExpoReceive(\\${JSON.stringify(source)}); true;\\`);\n\t\t\t});`\n\t\t\t\t\t: ''\n\t\t\t}\n\t\t\tif (active) setRuntimeReady(true);\n\t\t});\n\t\treturn () => {\n\t\t\tactive = false;\n\t\t\tstop();\n\t\t\tconst bridge = syncBridge.current;\n\t\t\tsyncBridge.current = undefined;\n\t\t\tvoid bridge?.close();\n\t\t};`\n\t\t\t\t: ''\n\t\t}\n\t}, []);\n\n\tuseEffect(() => {\n\t\tif (DEV_ORIGIN) {\n\t\t\tconst target = new URL(pathname, DEV_ORIGIN);\n\t\t\ttarget.searchParams.set('__absolute_target', HMR_TARGET);\n\t\t\tsetIndexUri(target.href);\n\t\t\treturn;\n\t\t}\n\t\tvoid materializeAbsoluteWebBundle().then(uri => setIndexUri(uri + '?absolutePath=' + encodeURIComponent(pathname)));\n\t}, [pathname]);\n\tuseEffect(() => {\n\t\tconst subscription = BackHandler.addEventListener('hardwareBackPress', () => {\n\t\t\tif (!canGoBack) return false;\n\t\t\twebView.current?.goBack();\n\t\t\treturn true;\n\t\t});\n\t\treturn () => subscription.remove();\n\t}, [canGoBack]);\n\n\tconst respond = (message: Record<string, unknown>) => {\n\t\tconst source = JSON.stringify(message).replaceAll('\\\\u2028', '\\\\\\\\u2028').replaceAll('\\\\u2029', '\\\\\\\\u2029');\n\t\tif (new TextEncoder().encode(source).byteLength > MAX_MESSAGE_BYTES) throw new Error('Expo bridge response exceeds 64 KiB.');\n\t\twebView.current?.injectJavaScript(\\`globalThis.__absoluteExpoReceive(\\${JSON.stringify(source)}); true;\\`);\n\t};\n\tuseEffect(() => {\n\t\tlet active = true;\n\t\tvoid createExpoDevicesBridgeHost(absoluteExpoDevices, (event, payload) => {\n\t\t\tif (!active) return;\n\t\t\trespond({ event, format: BRIDGE_FORMAT, kind: 'event', path: activeWebPath.current, payload });\n\t\t}).then(host => {\n\t\t\tif (!active) return void host.close();\n\t\t\tdevicesBridge.current = host;\n\t\t\tsetDevicesReady(true);\n\t\t});\n\t\treturn () => {\n\t\t\tactive = false;\n\t\t\tconst host = devicesBridge.current;\n\t\t\tdevicesBridge.current = undefined;\n\t\t\tvoid host?.close();\n\t\t};\n\t}, []);\n\tconst hasOrigin = (source: string, origin: string) => {\n\t\ttry { return new URL(source).origin === origin; } catch { return false; }\n\t};\n\tconst onMessage = async (event: WebViewMessageEvent) => {\n\t\tconst source = event.nativeEvent.data;\n\t\tif (new TextEncoder().encode(source).byteLength > MAX_MESSAGE_BYTES) return;\n\t\tlet message: Record<string, unknown>;\n\t\ttry { message = JSON.parse(source); } catch { return; }\n\t\tif (message.format !== BRIDGE_FORMAT || typeof message.path !== 'string' || !message.path.startsWith('/') || message.path.startsWith('//')) return;\n\t\tif (message.kind === 'event' && (message.event === 'navigation' || message.event === 'ready')) {\n\t\t\tconst target = new URL(message.path, PRODUCTION_ORIGIN);\n\t\t\tif (target.origin !== PRODUCTION_ORIGIN) return;\n\t\t\tif (isNativeRoute(target.pathname)) router.push(message.path as never);\n\t\t\telse activeWebPath.current = message.path;\n\t\t\treturn;\n\t\t}\n\t\tif (message.kind !== 'request' || typeof message.id !== 'string' || message.path !== activeWebPath.current) return;\n\t\ttry {\n\t\t\tif (typeof message.params !== 'object' || message.params === null || Array.isArray(message.params)) throw new Error('Expo bridge method params are invalid.');\n\t\t\tif (typeof message.method === 'string' && message.method.startsWith('devices.')) {\n\t\t\t\tif (!devicesBridge.current) throw new Error('Expo devices bridge is unavailable.');\n\t\t\t\trespond({ format: BRIDGE_FORMAT, id: message.id, kind: 'response', result: await devicesBridge.current.request(message.method, message.params as Record<string, unknown>) });\n\t\t\t} else if (message.method === 'http.fetch') {\n\t\t\t\trespond({ format: BRIDGE_FORMAT, id: message.id, kind: 'response', result: await bridgeFetch(message.params as Record<string, unknown>) });\n\t\t\t} else if (message.method === 'auth.signIn') {\n\t\t\t\t${\n\t\t\t\t\tauth\n\t\t\t\t\t\t? `const params = message.params as Record<string, unknown>;\n\t\t\t\tif (typeof params.email !== 'string' || typeof params.signup !== 'boolean') throw new Error('Expo Auth sign-in params are invalid.');\n\t\t\t\tawait absoluteExpoAuth.signIn({ authorizationParameters: { login_hint: params.email, ...(params.signup ? { screen_hint: 'signup' } : {}) } });\n\t\t\t\trespond({ format: BRIDGE_FORMAT, id: message.id, kind: 'response', result: await authStatus() });`\n\t\t\t\t\t\t: \"throw new Error('Expo Auth is not configured.');\"\n\t\t\t\t}\n\t\t\t} else if (message.method === 'auth.signOut') {\n\t\t\t\t${\n\t\t\t\t\tauth\n\t\t\t\t\t\t? `await beforeAbsoluteExpoDeviceSignOut();\n\t\t\t\tawait absoluteExpoAuth.signOut();\n\t\t\t\trespond({ format: BRIDGE_FORMAT, id: message.id, kind: 'response', result: null });`\n\t\t\t\t\t\t: \"throw new Error('Expo Auth is not configured.');\"\n\t\t\t\t}\n\t\t\t} else if (message.method === 'auth.status') {\n\t\t\t\trespond({ format: BRIDGE_FORMAT, id: message.id, kind: 'response', result: await authStatus() });\n\t\t\t} else if (typeof message.method === 'string' && message.method.startsWith('sync.')) {\n\t\t\t\tif (!syncBridge.current) throw new Error('Expo Sync bridge is unavailable.');\n\t\t\t\trespond({ format: BRIDGE_FORMAT, id: message.id, kind: 'response', result: await syncBridge.current.request(message.method, message.params as Record<string, unknown>) });\n\t\t\t} else {\n\t\t\t\tthrow new Error('Expo bridge method is not allowed.');\n\t\t\t}\n\t\t} catch (error) {\n\t\t\trespond({ error: { code: 'failed', message: error instanceof Error ? error.message : 'Native operation failed.' }, format: BRIDGE_FORMAT, id: message.id, kind: 'response' });\n\t\t}\n\t};\n\n\tif (!indexUri || !runtimeReady || !devicesReady) return <View style={styles.loading}><ActivityIndicator /></View>;\n\treturn <WebView\n\t\tallowFileAccess\n\t\tallowFileAccessFromFileURLs\n\t\tallowUniversalAccessFromFileURLs={false}\n\t\tallowingReadAccessToURL={indexUri.slice(0, indexUri.lastIndexOf('/') + 1)}\n\t\tinjectedJavaScriptBeforeContentLoaded={bridgeBootstrap(pathname)}\n\t\tonMessage={onMessage}\n\t\tonNavigationStateChange={state => setCanGoBack(state.canGoBack)}\n\t\tonShouldStartLoadWithRequest={request => {\n\t\t\tif (request.url.startsWith('file:') || hasOrigin(request.url, PRODUCTION_ORIGIN) || DEV_ORIGIN && hasOrigin(request.url, DEV_ORIGIN)) return true;\n\t\t\tvoid Linking.openURL(request.url);\n\t\t\treturn false;\n\t\t}}\n\t\tref={webView}\n\t\tsource={{ uri: indexUri }}\n\t\tstyle={styles.web}\n\t/>;\n}\n\nconst styles = StyleSheet.create({ loading: { alignItems: 'center', flex: 1, justifyContent: 'center' }, web: { flex: 1 } });\n`;\n};\n\nconst webRouteSource = `${EXPO_GENERATED_HEADER}import { AbsoluteWebHost } from '../src/generated/AbsoluteWebHost';\n\nexport default AbsoluteWebHost;\n`;\n\nconst catchAllRouteSource = `${EXPO_GENERATED_HEADER}import { AbsoluteWebHost } from '../src/generated/AbsoluteWebHost';\n\nexport default AbsoluteWebHost;\n`;\n\nconst nativeRouteRuntimeSource = (auth: boolean) =>\n\t`${EXPO_GENERATED_HEADER}import { useLocalSearchParams, usePathname } from 'expo-router';\nimport { type ComponentType, useEffect, useMemo, useState } from 'react';\nimport { ActivityIndicator, Platform, Pressable, StyleSheet, Text, View } from 'react-native';\nimport { ABSOLUTE_MOBILE_MANIFEST } from './webAssets';\n${auth ? \"import { absoluteExpoAuth } from './AbsoluteAuth';\" : ''}\n\nconst PAGE_MEDIA_TYPE = 'application/vnd.absolute.page+json';\nconst NATIVE_DATA_MEDIA_TYPE = 'application/vnd.absolute.native-route+json';\nconst PROTOCOL = 1;\nconst MAX_DATA_BYTES = 1024 * 1024;\nconst DEV_ORIGIN = Platform.OS === 'android'\n\t? process.env.EXPO_PUBLIC_ABSOLUTE_DEV_ANDROID_ORIGIN\n\t: process.env.EXPO_PUBLIC_ABSOLUTE_DEV_IOS_ORIGIN;\n\ntype RouteParams = Record<string, string | string[] | undefined>;\ntype NativeRouteProps<PageProps extends object, Params extends object> = {\n\tpageProps: Readonly<PageProps>;\n\tparams: Readonly<Params>;\n\treload: () => void;\n};\ntype NativeRouteState<PageProps> =\n\t| { kind: 'loading' }\n\t| { kind: 'ready'; pageProps: PageProps }\n\t| { kind: 'error' };\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n\ttypeof value === 'object' && value !== null && !Array.isArray(value);\nconst routeSegmentPattern = (segment: string) => {\n\tif (segment === '*') return '.*';\n\tif (segment.startsWith(':') && segment.endsWith('?')) return '[^/]*';\n\tif (segment.startsWith(':')) return '[^/]+';\n\treturn segment.replace(/[.*+?^\\${}()|[\\\\]\\\\\\\\]/g, '\\\\\\\\$&');\n};\nconst matchesRoute = (pattern: string, pathname: string) =>\n\tnew RegExp('^' + pattern.split('/').map(routeSegmentPattern).join('/') + '/?$').test(pathname);\nconst requestPathFor = (pathname: string, params: RouteParams, pattern: string) => {\n\tconst pathNames = new Set(pattern.split('/').filter(segment => segment.startsWith(':')).map(segment => segment.replace(/^:/, '').replace(/\\\\?$/, '')));\n\tif (pattern.endsWith('/*')) pathNames.add('absoluteWildcard');\n\tconst query = new URLSearchParams();\n\tfor (const [name, value] of Object.entries(params).sort(([left], [right]) => left.localeCompare(right))) {\n\t\tif (pathNames.has(name) || name === '#' || value === undefined) continue;\n\t\tfor (const item of Array.isArray(value) ? value : [value]) query.append(name, item);\n\t}\n\tconst search = query.toString();\n\treturn pathname + (search ? '?' + search : '');\n};\nconst productionPage = (pathname: string) => {\n\tif (!ABSOLUTE_MOBILE_MANIFEST) throw new Error('AbsoluteJS native route data is not prepared for production.');\n\tconst route = ABSOLUTE_MOBILE_MANIFEST.routes.find(candidate => candidate.method === 'GET' && matchesRoute(candidate.pattern, pathname));\n\tif (!route) throw new Error('No trusted AbsoluteJS page route owns this native URL.');\n\tconst page = ABSOLUTE_MOBILE_MANIFEST.pages.find(candidate => candidate.pageId === route.pageId);\n\tif (!page) throw new Error('The embedded AbsoluteJS page contract is incomplete.');\n\treturn page;\n};\nconst createDataRequest = (path: string) => {\n\tconst development = typeof DEV_ORIGIN === 'string' && DEV_ORIGIN.length > 0;\n\tconst origin = development ? DEV_ORIGIN : ABSOLUTE_MOBILE_MANIFEST?.productionOrigin;\n\tif (!origin) throw new Error('AbsoluteJS native route data has no trusted server origin.');\n\tconst url = new URL(path, origin);\n\tif (url.origin !== new URL(origin).origin) throw new Error('AbsoluteJS native route data left its trusted origin.');\n\tconst headers = new Headers();\n\theaders.set('accept', development ? NATIVE_DATA_MEDIA_TYPE : PAGE_MEDIA_TYPE);\n\theaders.set('x-absolute-mobile-protocol', String(PROTOCOL));\n\tlet page: ReturnType<typeof productionPage> | undefined;\n\tif (!development) {\n\t\tpage = productionPage(url.pathname);\n\t\theaders.set('x-absolute-mobile-app-build', ABSOLUTE_MOBILE_MANIFEST!.appBuild);\n\t\theaders.set('x-absolute-mobile-page-bundle', page.bundleHash);\n\t\theaders.set('x-absolute-mobile-page-contracts', page.contract);\n\t\theaders.set('x-absolute-mobile-page-id', page.pageId);\n\t\theaders.set('x-absolute-mobile-runtime', ABSOLUTE_MOBILE_MANIFEST!.runtime);\n\t}\n\treturn { page, request: new Request(url, { headers, method: 'GET' }) };\n};\nconst requestData = async <PageProps extends object>(path: string, signal: AbortSignal) => {\n\tconst { page, request } = createDataRequest(path);\n\tconst response = await ${auth ? 'absoluteExpoAuth.fetchOptional' : 'fetch'}(request, { redirect: 'manual', signal });\n\tif (new URL(response.url || request.url).origin !== new URL(request.url).origin || response.status >= 300 && response.status < 400) throw new Error('AbsoluteJS native route data redirected outside its contract.');\n\tconst source = await response.text();\n\tif (new TextEncoder().encode(source).byteLength > MAX_DATA_BYTES) throw new Error('AbsoluteJS native route data exceeded 1 MiB.');\n\tlet envelope: unknown;\n\ttry { envelope = JSON.parse(source); } catch { throw new Error('The server did not return an AbsoluteJS page envelope.'); }\n\tif (!isRecord(envelope) || envelope.protocol !== PROTOCOL || !isRecord(envelope.response)) throw new Error('The server returned an invalid AbsoluteJS page envelope.');\n\tconst result = envelope.response;\n\tif (result.kind === 'upgrade-required') throw new Error('This app version must be updated before opening this screen.');\n\tif (result.kind !== 'page' || !isRecord(result.props) || typeof result.pageId !== 'string' || typeof result.contract !== 'string') throw new Error('The server did not produce native route page props.');\n\tif (page && (result.pageId !== page.pageId || result.contract !== page.contract)) throw new Error('The server returned a different page contract than this app contains.');\n\treturn result.props as PageProps;\n};\n\nexport const createAbsoluteNativeRoute = <\n\tPageProps extends object,\n\tParams extends object = RouteParams\n>(Component: ComponentType<NativeRouteProps<PageProps, Params>>, pattern: string) => {\n\tfunction AbsoluteNativeRouteScreen() {\n\t\tconst pathname = usePathname() || '/';\n\t\tconst params = useLocalSearchParams() as RouteParams;\n\t\tconst parameterKey = JSON.stringify(params);\n\t\tconst requestPath = useMemo(() => requestPathFor(pathname, params, pattern), [parameterKey, pathname]);\n\t\tconst [revision, setRevision] = useState(0);\n\t\tconst [state, setState] = useState<NativeRouteState<PageProps>>({ kind: 'loading' });\n\t\tuseEffect(() => {\n\t\t\tconst controller = new AbortController();\n\t\t\tsetState({ kind: 'loading' });\n\t\t\tvoid requestData<PageProps>(requestPath, controller.signal).then(\n\t\t\t\tpageProps => { if (!controller.signal.aborted) setState({ kind: 'ready', pageProps }); },\n\t\t\t\t() => { if (!controller.signal.aborted) setState({ kind: 'error' }); }\n\t\t\t);\n\t\t\treturn () => controller.abort();\n\t\t}, [requestPath, revision]);\n\t\tconst reload = () => setRevision(value => value + 1);\n\t\tif (state.kind === 'loading') return <View style={styles.center}><ActivityIndicator accessibilityLabel=\"Loading screen\" /></View>;\n\t\tif (state.kind === 'error') return <View style={styles.center}><Text accessibilityRole=\"alert\" style={styles.error}>This screen could not load.</Text><Pressable accessibilityRole=\"button\" onPress={reload} style={styles.button}><Text>Try again</Text></Pressable></View>;\n\t\treturn <Component pageProps={state.pageProps} params={params as Params} reload={reload} />;\n\t}\n\treturn AbsoluteNativeRouteScreen;\n};\n\nconst styles = StyleSheet.create({\n\tbutton: { backgroundColor: '#e2e8f0', borderRadius: 10, paddingHorizontal: 16, paddingVertical: 12 },\n\tcenter: { alignItems: 'center', flex: 1, gap: 16, justifyContent: 'center', padding: 24 },\n\terror: { color: '#b91c1c', fontSize: 16, textAlign: 'center' }\n});\n`;\n\nconst nativeWrapperSource = (\n\twrapper: string,\n\tmodule: string,\n\truntime: string,\n\troute: string\n) =>\n\t`${EXPO_GENERATED_HEADER}import ApplicationNativeRoute from ${JSON.stringify(portableRelative(dirname(wrapper), module).replace(/\\.(?:[cm]?[jt]sx?)$/u, ''))};\nimport { createAbsoluteNativeRoute } from ${JSON.stringify(portableRelative(dirname(wrapper), runtime).replace(/\\.(?:[cm]?[jt]sx?)$/u, ''))};\n\nexport default createAbsoluteNativeRoute(ApplicationNativeRoute, ${JSON.stringify(route)});\n`;\n\nconst expoTsConfig = (\n\tprojectRoot: string,\n\tproject: string,\n\tauth: boolean,\n\tsync: boolean\n) => ({\n\tcompilerOptions: {\n\t\tpaths: {\n\t\t\t...(auth\n\t\t\t\t? {\n\t\t\t\t\t\t'@absolutejs/auth': [\n\t\t\t\t\t\t\t'./node_modules/@absolutejs/auth/dist/index.d.ts'\n\t\t\t\t\t\t],\n\t\t\t\t\t\t'@absolutejs/auth/*': [\n\t\t\t\t\t\t\t'./node_modules/@absolutejs/auth/dist/*'\n\t\t\t\t\t\t]\n\t\t\t\t\t}\n\t\t\t\t: {}),\n\t\t\t...(sync\n\t\t\t\t? {\n\t\t\t\t\t\t'@absolutejs/sync': [\n\t\t\t\t\t\t\t'./node_modules/@absolutejs/sync/dist/index.d.ts'\n\t\t\t\t\t\t],\n\t\t\t\t\t\t'@absolutejs/sync-expo': [\n\t\t\t\t\t\t\t'./node_modules/@absolutejs/sync-expo/dist/index.d.ts'\n\t\t\t\t\t\t],\n\t\t\t\t\t\t'@absolutejs/sync-expo/*': [\n\t\t\t\t\t\t\t'./node_modules/@absolutejs/sync-expo/dist/*'\n\t\t\t\t\t\t],\n\t\t\t\t\t\t'@absolutejs/sync/*': [\n\t\t\t\t\t\t\t'./node_modules/@absolutejs/sync/dist/*'\n\t\t\t\t\t\t]\n\t\t\t\t\t}\n\t\t\t\t: {}),\n\t\t\t'*': [\n\t\t\t\t'./node_modules/*',\n\t\t\t\t`${portableRelative(project, projectRoot)}/node_modules/*`\n\t\t\t],\n\t\t\treact: ['./node_modules/@types/react/index.d.ts'],\n\t\t\t'react/*': ['./node_modules/@types/react/*']\n\t\t},\n\t\tstrict: true\n\t},\n\textends: 'expo/tsconfig.base'\n});\n\nconst writeManagedFile = async (\n\tpath: string,\n\tsource: string,\n\tforce: boolean\n) => {\n\tawait mkdir(dirname(path), { recursive: true });\n\tif (await exists(path)) {\n\t\tconst current = await readFile(path, 'utf8');\n\t\tif (current === source) return false;\n\t\tif (!force && !current.startsWith(EXPO_GENERATED_HEADER)) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`Expo project file ${path} is not AbsoluteJS-managed; rerun with --force only after reviewing it.`\n\t\t\t);\n\t\t}\n\t}\n\tconst temporary = `${path}.${crypto.randomUUID()}.tmp`;\n\tawait writeFile(temporary, source, { flag: 'wx' });\n\tawait rename(temporary, path);\n\n\treturn true;\n};\n\nconst pruneStaleManagedExpoRoutes = async (\n\tproject: string,\n\texpected: ReadonlySet<string>\n) => {\n\tconst appDirectory = join(project, 'app');\n\tif (!(await exists(appDirectory))) return 0;\n\tconst files = await walkFiles(appDirectory);\n\tconst stale = (\n\t\tawait Promise.all(\n\t\t\tfiles.map(async (path) => ({\n\t\t\t\tmanaged:\n\t\t\t\t\tpath.endsWith('.tsx') &&\n\t\t\t\t\t(await readFile(path, 'utf8')).startsWith(\n\t\t\t\t\t\tEXPO_GENERATED_HEADER\n\t\t\t\t\t),\n\t\t\t\tpath\n\t\t\t}))\n\t\t)\n\t).filter(({ managed, path }) => managed && !expected.has(path));\n\tawait Promise.all(stale.map(({ path }) => rm(path, { force: true })));\n\n\treturn stale.length;\n};\n\nconst jsonSource = (value: unknown) => `${JSON.stringify(value, null, '\\t')}\\n`;\n\nconst nativeDataManifestTypeSource = `type AbsoluteMobileManifest = {\n\tappBuild: string;\n\tpages: readonly { bundleHash: string; contract: string; pageId: string }[];\n\tproductionOrigin: string;\n\troutes: readonly { method: 'GET'; pageId: string; pattern: string }[];\n\truntime: string;\n};\n`;\n\nconst emptyWebAssetsSource = `${EXPO_GENERATED_HEADER}${nativeDataManifestTypeSource}\nexport const materializeAbsoluteWebBundle = async () => {\n\tthrow new Error('The embedded AbsoluteJS bundle is unavailable. Run absolute prepare before a production Expo build.');\n};\nexport const ABSOLUTE_MOBILE_MANIFEST: AbsoluteMobileManifest | undefined = undefined;\n`;\n\nexport const writeAbsoluteExpoProject = async (\n\tconfig: NormalizedAbsoluteMobileConfig,\n\toptions: WriteAbsoluteExpoProjectOptions\n) => {\n\tif (config.engine !== 'expo')\n\t\tthrow new TypeError(\n\t\t\t'Expo project generation requires mobile.engine: expo.'\n\t\t);\n\tconst projectRoot = resolve(options.projectRoot);\n\tconst project = config.nativeProjectDirectory;\n\tconst auth = resolveAbsoluteMobileAuthManifest(projectRoot, config);\n\tconst devices = resolveAbsoluteDeviceCapabilityPlan(projectRoot, 'expo');\n\tconst syncEnabled = Boolean(auth && projectUsesAbsoluteSync(projectRoot));\n\tconst syncSchema = syncEnabled\n\t\t? { components: discoverAbsoluteSyncSchema(projectRoot).components }\n\t\t: undefined;\n\tconst routeModules = Object.entries(config.expoNativeRoutes);\n\tconst moduleChecks = await Promise.all(\n\t\trouteModules.map(async ([route, module]) => ({\n\t\t\texists: await exists(module),\n\t\t\tmodule,\n\t\t\troute\n\t\t}))\n\t);\n\tconst missing = moduleChecks.find((entry) => !entry.exists);\n\tif (missing) {\n\t\tthrow new TypeError(\n\t\t\t`Expo native route ${missing.route} references missing module ${missing.module}.`\n\t\t);\n\t}\n\tconst marker = join(project, EXPO_PROJECT_MARKER);\n\tif ((await exists(project)) && !(await exists(marker))) {\n\t\tconst entries = await readdir(project);\n\t\tif (entries.length > 0 && !options.force) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`Expo project directory ${project} is not AbsoluteJS-managed; rerun with --force only after reviewing it.`\n\t\t\t);\n\t\t}\n\t}\n\tawait mkdir(project, { recursive: true });\n\tawait writeFile(marker, 'format=1\\n');\n\tconst authEnabled = Boolean(auth);\n\tconst files = new Map<string, string>([\n\t\t[\n\t\t\tjoin(project, '.gitignore'),\n\t\t\t'.expo/\\nandroid/\\nios/\\nnode_modules/\\n'\n\t\t],\n\t\t[\n\t\t\tjoin(project, 'app.json'),\n\t\t\tjsonSource(expoAppConfig(config, authEnabled, syncEnabled, devices))\n\t\t],\n\t\t[join(project, 'app.config.js'), expoDynamicAppConfig],\n\t\t[\n\t\t\tjoin(project, 'package.json'),\n\t\t\tjsonSource(expoPackage(authEnabled, syncEnabled, devices))\n\t\t],\n\t\t[join(project, 'metro.config.js'), metroConfig(projectRoot)],\n\t\t[\n\t\t\tjoin(project, 'plugins', 'withAbsoluteDevelopmentCa.js'),\n\t\t\texpoDevelopmentCaPlugin\n\t\t],\n\t\t[\n\t\t\tjoin(project, 'tsconfig.json'),\n\t\t\tjsonSource(\n\t\t\t\texpoTsConfig(projectRoot, project, authEnabled, syncEnabled)\n\t\t\t)\n\t\t],\n\t\t[\n\t\t\tjoin(project, 'app', '_layout.tsx'),\n\t\t\tlayoutSource(authEnabled, syncEnabled)\n\t\t],\n\t\t[\n\t\t\tjoin(project, 'app', '__absolute', 'native', 'index.tsx'),\n\t\t\tnativeDiagnosticSource\n\t\t],\n\t\t[\n\t\t\tjoin(project, 'src', 'generated', 'AbsoluteDevices.ts'),\n\t\t\tdevicesRuntimeSource(config, devices, authEnabled)\n\t\t],\n\t\t[\n\t\t\tjoin(project, 'src', 'generated', 'AbsoluteNativeRoute.tsx'),\n\t\t\tnativeRouteRuntimeSource(authEnabled)\n\t\t],\n\t\t[\n\t\t\tjoin(project, 'src', 'generated', 'AbsoluteWebHost.tsx'),\n\t\t\twebHostSource(config, auth, syncEnabled)\n\t\t]\n\t]);\n\tif (auth) {\n\t\tfiles.set(\n\t\t\tjoin(project, 'src', 'generated', 'AbsoluteAuth.ts'),\n\t\t\tauthRuntimeSource(auth, config.appId)\n\t\t);\n\t}\n\tif (syncSchema) {\n\t\tfiles.set(\n\t\t\tjoin(project, 'src', 'generated', 'AbsoluteSync.ts'),\n\t\t\tsyncRuntimeSource(config, syncSchema)\n\t\t);\n\t}\n\tconst webAssetsPath = join(project, 'src', 'generated', 'webAssets.ts');\n\tif (!(await exists(webAssetsPath))) {\n\t\tfiles.set(webAssetsPath, emptyWebAssetsSource);\n\t}\n\tif (!config.expoNativeRoutes['/']) {\n\t\tfiles.set(join(project, 'app', 'index.tsx'), webRouteSource);\n\t}\n\tfiles.set(join(project, 'app', '[...absolute].tsx'), catchAllRouteSource);\n\tconst nativeRouteRuntime = join(\n\t\tproject,\n\t\t'src',\n\t\t'generated',\n\t\t'AbsoluteNativeRoute.tsx'\n\t);\n\tfor (const [route, module] of routeModules) {\n\t\tconst wrapper =\n\t\t\troute === '/'\n\t\t\t\t? join(project, 'app', 'index.tsx')\n\t\t\t\t: routeFile(project, route);\n\t\tfiles.set(\n\t\t\twrapper,\n\t\t\tnativeWrapperSource(wrapper, module, nativeRouteRuntime, route)\n\t\t);\n\t}\n\tconst removed = await pruneStaleManagedExpoRoutes(\n\t\tproject,\n\t\tnew Set(\n\t\t\t[...files.keys()].filter((path) =>\n\t\t\t\tpath.startsWith(`${join(project, 'app')}${sep}`)\n\t\t\t)\n\t\t)\n\t);\n\tconst changes = await Promise.all(\n\t\t[...files].map(([path, source]) => writeManagedFile(path, source, true))\n\t);\n\tconst changed = removed + changes.filter(Boolean).length;\n\n\treturn { changed, path: project, written: [...files.keys()] };\n};\n\nconst walkFiles = async (root: string, directory = root): Promise<string[]> => {\n\tconst entries = await readdir(directory, { withFileTypes: true });\n\tconst nested = await Promise.all(\n\t\tentries.map((entry) => {\n\t\t\tconst path = join(directory, entry.name);\n\t\t\tif (entry.isDirectory()) return walkFiles(root, path);\n\t\t\tif (entry.isFile()) return [path];\n\t\t\tthrow new TypeError(\n\t\t\t\t`Expo embedded bundle cannot contain a symbolic link or special file: ${path}.`\n\t\t\t);\n\t\t})\n\t);\n\n\treturn nested.flat().sort();\n};\n\nconst renameIfPresent = async (source: string, destination: string) => {\n\ttry {\n\t\tawait rename(source, destination);\n\n\t\treturn true;\n\t} catch (error) {\n\t\tif (\n\t\t\ttypeof error === 'object' &&\n\t\t\terror !== null &&\n\t\t\tReflect.get(error, 'code') === 'ENOENT'\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\tthrow error;\n\t}\n};\n\nconst installStagedDirectory = async (staging: string, destination: string) => {\n\tconst backup = `${destination}.previous-${crypto.randomUUID()}`;\n\tconst moved = await renameIfPresent(destination, backup);\n\ttry {\n\t\tawait rename(staging, destination);\n\t\tif (moved) await rm(backup, { force: true, recursive: true });\n\t} catch (error) {\n\t\tif (moved) await rename(backup, destination);\n\t\tthrow error;\n\t}\n};\n\nconst assetModuleSource = (\n\tassets: AbsoluteExpoAssetEntry[],\n\tbundleId: string,\n\tmanifest: AbsoluteExpoNativeDataManifest\n) => `${EXPO_GENERATED_HEADER}import { Asset } from 'expo-asset';\nimport { Directory, File, Paths } from 'expo-file-system';\n\n${nativeDataManifestTypeSource}\ndeclare const require: (path: string) => number;\nconst BUNDLE_ID = ${JSON.stringify(bundleId)};\nexport const ABSOLUTE_MOBILE_MANIFEST: AbsoluteMobileManifest = ${JSON.stringify(manifest)};\nconst ASSETS = [\n${assets.map(({ asset, path }) => `\\t{ module: require(${JSON.stringify(asset)}), path: ${JSON.stringify(path)} }`).join(',\\n')}\n] as const;\n\nexport const materializeAbsoluteWebBundle = async () => {\n\tconst root = new Directory(Paths.document, 'absolutejs-web', BUNDLE_ID);\n\troot.create({ idempotent: true, intermediates: true });\n\tfor (const entry of ASSETS) {\n\t\tconst parts = entry.path.split('/');\n\t\tconst name = parts.pop();\n\t\tif (!name) throw new Error('AbsoluteJS embedded asset path is invalid.');\n\t\tconst directory = new Directory(root, ...parts);\n\t\tdirectory.create({ idempotent: true, intermediates: true });\n\t\tconst destination = new File(directory, name);\n\t\tif (destination.exists) continue;\n\t\tconst asset = await Asset.fromModule(entry.module).downloadAsync();\n\t\tif (!asset.localUri) throw new Error('Expo did not materialize an embedded AbsoluteJS asset.');\n\t\tnew File(asset.localUri).copy(destination);\n\t}\n\n\treturn new File(root, 'index.html').uri;\n};\n`;\n\nexport const syncAbsoluteExpoWebAssets = async (\n\tconfig: NormalizedAbsoluteMobileConfig\n) => {\n\tif (config.engine !== 'expo')\n\t\tthrow new TypeError('Expo asset sync requires mobile.engine: expo.');\n\tconst marker = join(config.nativeProjectDirectory, EXPO_PROJECT_MARKER);\n\tif (!(await exists(marker))) {\n\t\tthrow new TypeError(\n\t\t\t'Expo asset sync requires an AbsoluteJS-managed Expo project. Run mobile init first.'\n\t\t);\n\t}\n\tconst manifestPath = join(\n\t\tconfig.bundleDirectory,\n\t\t'absolute-mobile-manifest.json'\n\t);\n\tconst manifest: unknown = JSON.parse(await readFile(manifestPath, 'utf8'));\n\tconst nativeDataManifest = expoNativeDataManifest(manifest);\n\tconst { appBuild } = nativeDataManifest;\n\tconst files = await walkFiles(config.bundleDirectory);\n\tconst bundleHash = createHash('sha256');\n\tconst filesWithContents = await Promise.all(\n\t\tfiles.map(async (file) => ({ contents: await readFile(file), file }))\n\t);\n\tfilesWithContents.forEach(({ contents, file }) => {\n\t\tbundleHash.update(\n\t\t\trelative(config.bundleDirectory, file).replaceAll('\\\\', '/')\n\t\t);\n\t\tbundleHash.update('\\0');\n\t\tbundleHash.update(contents);\n\t\tbundleHash.update('\\0');\n\t});\n\tconst bundleId = `amexpo_${bundleHash.digest('hex')}`;\n\tconst destination = join(\n\t\tconfig.nativeProjectDirectory,\n\t\t'assets',\n\t\t'absolute'\n\t);\n\tawait mkdir(dirname(destination), { recursive: true });\n\tconst staging = await mkdtemp(\n\t\tjoin(dirname(destination), `.${basename(destination)}.stage-`)\n\t);\n\tlet assets: AbsoluteExpoAssetEntry[];\n\ttry {\n\t\tassets = await Promise.all(\n\t\t\tfiles.map(async (source, index) => {\n\t\t\t\tconst name = `${String(index).padStart(6, '0')}${EXPO_ASSET_EXTENSION}`;\n\t\t\t\tawait cp(source, join(staging, name));\n\n\t\t\t\treturn {\n\t\t\t\t\tasset: portableRelative(\n\t\t\t\t\t\tjoin(config.nativeProjectDirectory, 'src', 'generated'),\n\t\t\t\t\t\tjoin(destination, name)\n\t\t\t\t\t),\n\t\t\t\t\tpath: relative(config.bundleDirectory, source).replaceAll(\n\t\t\t\t\t\t'\\\\',\n\t\t\t\t\t\t'/'\n\t\t\t\t\t)\n\t\t\t\t};\n\t\t\t})\n\t\t);\n\t\tawait installStagedDirectory(staging, destination);\n\t} catch (error) {\n\t\tawait rm(staging, { force: true, recursive: true });\n\t\tthrow error;\n\t}\n\tconst generated = join(\n\t\tconfig.nativeProjectDirectory,\n\t\t'src',\n\t\t'generated',\n\t\t'webAssets.ts'\n\t);\n\tawait writeManagedFile(\n\t\tgenerated,\n\t\tassetModuleSource(assets, bundleId, nativeDataManifest),\n\t\ttrue\n\t);\n\n\treturn { appBuild, assets: assets.length, bundleId, path: destination };\n};\n",
|
|
44
|
+
"export * from './artifactStore';\nexport * from './androidRelease';\nexport * from './androidUpgradeConformance';\nexport * from './iosRelease';\nexport * from './iosConformance';\nexport * from './iosSimulatorController';\nexport * from './iosPhysicalDeviceTransport';\nexport * from './iosNativeWatcher';\nexport * from './remoteMacProtocol';\nexport * from './iosDeviceAcceptance';\nexport * from './associationFiles';\nexport * from './buildMetadata';\nexport * from './buildPipeline';\nexport * from './buildRelease';\nexport * from './capacitorBundle';\nexport * from './syncSchema';\nexport * from './syncRemediation';\nexport * from './deviceCapabilities';\nexport * from './expoBridge';\nexport * from './expoDevController';\nexport * from './expoProject';\nexport * from './capacitorProject';\nexport * from './config';\nexport * from './client';\nexport * from './ciWorkflow';\nexport * from './compatibilityDispatcher';\nexport * from './materializedBundle';\nexport * from './mobilePreview';\nexport * from './nativeDeepLinks';\nexport * from './nativeDeviceCapabilities';\nexport * from './nativeAuth';\nexport * from './nativeRoute';\nexport * from './pageProtocol';\nexport * from './producerContext';\nexport * from './releaseArtifact';\nexport * from './releasePublisher';\nexport * from './routeMetadataTransform';\nexport * from './routeMatcher';\nexport * from './shellHttp';\nexport * from './transport';\n",
|
|
45
|
+
"var __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __name = (target, name) => {\n Object.defineProperty(target, \"name\", {\n value: name,\n enumerable: false,\n configurable: true\n });\n return target;\n};\nvar __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for(\"Symbol.\" + name);\nvar __typeError = (msg) => {\n throw TypeError(msg);\n};\nvar __defNormalProp = (obj, key, value) => (key in obj) ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;\nvar __accessCheck = (obj, member, msg) => member.has(obj) || __typeError(\"Cannot \" + msg);\nvar __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use the \"in\" operator on this value') : member.has(obj);\nvar __privateGet = (obj, member, getter) => (__accessCheck(obj, member, \"read from private field\"), getter ? getter.call(obj) : member.get(obj));\nvar __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, \"write to private field\"), setter ? setter.call(obj, value) : member.set(obj, value), value);\nvar __privateMethod = (obj, member, method) => (__accessCheck(obj, member, \"access private method\"), method);\nvar __decoratorStart = (base) => [, , , __create(base?.[__knownSymbol(\"metadata\")] ?? null)];\nvar __decoratorStrings = [\"class\", \"method\", \"getter\", \"setter\", \"accessor\", \"field\", \"value\", \"get\", \"set\"];\nvar __expectFn = (fn) => fn !== undefined && typeof fn !== \"function\" ? __typeError(\"Function expected\") : fn;\nvar __decoratorContext = (kind, name, done, metadata, fns) => ({\n kind: __decoratorStrings[kind],\n name,\n metadata,\n addInitializer: (fn) => done._ ? __typeError(\"Already initialized\") : fns.push(__expectFn(fn || null))\n});\nvar __decoratorMetadata = (array, target) => __defNormalProp(target, __knownSymbol(\"metadata\"), array[3]);\nvar __runInitializers = (array, flags, self, value) => {\n for (var i = 0, fns = array[flags >> 1], n = fns && fns.length;i < n; i++)\n flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value);\n return value;\n};\nvar __decorateElement = (array, flags, name, decorators, target, extra) => {\n var fn, it, done, ctx, access, k = flags & 7, s = !!(flags & 8), p = !!(flags & 16);\n var j = k > 3 ? array.length + 1 : k ? s ? 1 : 2 : 0, key = __decoratorStrings[k + 5];\n var initializers = k > 3 && (array[j - 1] = []), extraInitializers = array[j] || (array[j] = []);\n var desc = k && (!p && !s && (target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc(k < 4 ? target : {\n get [name]() {\n return __privateGet(this, extra);\n },\n set [name](x) {\n __privateSet(this, extra, x);\n }\n }, name));\n k ? p && k < 4 && __name(extra, (k > 2 ? \"set \" : k > 1 ? \"get \" : \"\") + name) : __name(target, name);\n for (var i = decorators.length - 1;i >= 0; i--) {\n ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);\n if (k) {\n ctx.static = s, ctx.private = p, access = ctx.access = { has: p ? (x) => __privateIn(target, x) : (x) => (name in x) };\n if (k ^ 3)\n access.get = p ? (x) => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name];\n if (k > 2)\n access.set = p ? (x, y) => __privateSet(x, target, y, k ^ 4 ? extra : desc.set) : (x, y) => x[name] = y;\n }\n it = (0, decorators[i])(k ? k < 4 ? p ? extra : desc[key] : k > 4 ? undefined : { get: desc.get, set: desc.set } : target, ctx);\n done._ = 1;\n if (k ^ 4 || it === undefined)\n __expectFn(it) && (k > 4 ? initializers.unshift(it) : k ? p ? extra = it : desc[key] = it : target = it);\n else if (typeof it !== \"object\" || it === null)\n __typeError(\"Object expected\");\n else\n __expectFn(fn = it.get) && (desc.get = fn), __expectFn(fn = it.set) && (desc.set = fn), __expectFn(fn = it.init) && initializers.unshift(fn);\n }\n return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;\n};\n\n// src/client/runtimeTransport.ts\nvar RUNTIME_TRANSPORT = Symbol.for(\"@absolutejs/sync/client-runtime-transport\");\nvar host = globalThis;\nvar isRegistry = (value) => typeof value === \"object\" && value !== null && Array.isArray(Reflect.get(value, \"installations\")) && Array.isArray(Reflect.get(value, \"clients\"));\nvar registry = (() => {\n const existing = host[RUNTIME_TRANSPORT];\n if (isRegistry(existing))\n return existing;\n if (typeof existing === \"object\" && existing !== null && Array.isArray(Reflect.get(existing, \"installations\"))) {\n Reflect.set(existing, \"clients\", []);\n return existing;\n }\n const created = { clients: [], installations: [] };\n Object.defineProperty(host, RUNTIME_TRANSPORT, {\n configurable: false,\n enumerable: false,\n value: created,\n writable: false\n });\n return created;\n})();\nvar getSyncClientRuntimeTransport = () => registry.installations.at(-1)?.transport;\nvar installSyncClientRuntimeTransport = (transport) => {\n const installation = { transport };\n registry.installations.push(installation);\n return () => {\n const index = registry.installations.indexOf(installation);\n if (index >= 0)\n registry.installations.splice(index, 1);\n };\n};\nvar registerSyncRuntimeClient = (client) => {\n registry.clients.push(client);\n return () => {\n const index = registry.clients.indexOf(client);\n if (index >= 0)\n registry.clients.splice(index, 1);\n };\n};\nvar maximum = (values) => {\n const present = values.filter((value) => value !== undefined);\n return present.length === 0 ? undefined : Math.max(...present);\n};\nvar minimum = (values) => {\n const present = values.filter((value) => value !== undefined);\n return present.length === 0 ? undefined : Math.min(...present);\n};\nvar inspectSyncRuntime = async () => {\n const clients = [...registry.clients];\n const statuses = clients.map((client) => client.status());\n const deadLetters = (await Promise.all(clients.map((client) => client.listDeadLetters()))).flat().map((record) => ({\n attempts: record.attempts,\n ...record.rejection?.code ? { code: record.rejection.code } : {},\n createdAt: record.createdAt,\n ...record.deadLetteredAt === undefined ? {} : { deadLetteredAt: record.deadLetteredAt },\n ...record.rejection?.kind ? { kind: record.rejection.kind } : {},\n ...record.rejection?.message ? { message: record.rejection.message } : {},\n name: record.name,\n operationId: record.operationId\n })).sort((left, right) => (left.deadLetteredAt ?? left.createdAt) - (right.deadLetteredAt ?? right.createdAt) || left.operationId.localeCompare(right.operationId));\n const lastError = statuses.findLast((status) => status.lastError)?.lastError;\n return {\n automaticResolutions: statuses.reduce((total, status) => total + status.automaticResolutions, 0),\n clients: clients.length,\n conflicts: deadLetters.filter((record) => record.kind === \"conflict\").length,\n deadLetters,\n ...lastError ? { lastError } : {},\n ...maximum(statuses.map((status) => status.lastSuccessfulPullAt)) === undefined ? {} : {\n lastSuccessfulPullAt: maximum(statuses.map((status) => status.lastSuccessfulPullAt))\n },\n ...maximum(statuses.map((status) => status.lastSuccessfulPushAt)) === undefined ? {} : {\n lastSuccessfulPushAt: maximum(statuses.map((status) => status.lastSuccessfulPushAt))\n },\n ...minimum(statuses.map((status) => status.oldestDeadLetterAt)) === undefined ? {} : {\n oldestDeadLetterAt: minimum(statuses.map((status) => status.oldestDeadLetterAt))\n },\n ...minimum(statuses.map((status) => status.oldestPendingAt)) === undefined ? {} : {\n oldestPendingAt: minimum(statuses.map((status) => status.oldestPendingAt))\n },\n pending: statuses.reduce((total, status) => total + status.pending, 0)\n };\n};\nvar clientWithDeadLetter = async (operationId) => {\n for (const client of registry.clients)\n if ((await client.listDeadLetters()).some((record) => record.operationId === operationId))\n return client;\n throw new Error(`Unknown Sync dead letter \"${operationId}\"`);\n};\nvar retrySyncRuntimeDeadLetter = async (operationId) => (await clientWithDeadLetter(operationId)).retryDeadLetter(operationId);\nvar discardSyncRuntimeDeadLetter = async (operationId) => (await clientWithDeadLetter(operationId)).discardDeadLetter(operationId);\nvar rebaseSyncRuntimeDeadLetter = async (operationId, args) => (await clientWithDeadLetter(operationId)).rebaseDeadLetter(operationId, args);\nexport {\n discardSyncRuntimeDeadLetter,\n getSyncClientRuntimeTransport,\n inspectSyncRuntime,\n installSyncClientRuntimeTransport,\n rebaseSyncRuntimeDeadLetter,\n registerSyncRuntimeClient,\n retrySyncRuntimeDeadLetter\n};\n\n//# debugId=74366468048A0B9164756E2164756E21\n//# sourceMappingURL=runtimeTransport.js.map\n",
|
|
46
|
+
"import {\n\tdiscardSyncRuntimeDeadLetter,\n\tinspectSyncRuntime,\n\trebaseSyncRuntimeDeadLetter,\n\tretrySyncRuntimeDeadLetter,\n\ttype SyncRuntimeInspection\n} from '@absolutejs/sync/client/runtime';\n\nexport type AbsoluteMobileSyncRemediation = {\n\tdiscard: (operationId: string) => Promise<void>;\n\tinspect: () => Promise<SyncRuntimeInspection>;\n\trebase: (operationId: string, args: unknown) => Promise<string>;\n\tretry: (operationId: string) => Promise<void>;\n};\n\ntype Installation = { bridge: AbsoluteMobileSyncRemediation };\ntype Registry = { installations: Installation[] };\nconst REMEDIATION_REGISTRY = Symbol.for('@absolutejs/mobile-sync-remediation');\nconst LAST_INSTALLATION_OFFSET = -1;\nconst isRegistry = (value: unknown): value is Registry =>\n\ttypeof value === 'object' &&\n\tvalue !== null &&\n\tArray.isArray(Reflect.get(value, 'installations'));\nconst resolveRegistry = () => {\n\tconst existing: unknown = Reflect.get(globalThis, REMEDIATION_REGISTRY);\n\tif (isRegistry(existing)) return existing;\n\tconst created: Registry = { installations: [] };\n\tObject.defineProperty(globalThis, REMEDIATION_REGISTRY, {\n\t\tconfigurable: false,\n\t\tenumerable: false,\n\t\tvalue: created,\n\t\twritable: false\n\t});\n\n\treturn created;\n};\nconst registry = resolveRegistry();\n\n/** Install the native shell's framework-neutral, redacted remediation bridge. */\nexport const getAbsoluteMobileSyncRemediation = () =>\n\tregistry.installations.at(LAST_INSTALLATION_OFFSET)?.bridge;\nexport const installAbsoluteMobileSyncRemediation = (\n\tbridge: AbsoluteMobileSyncRemediation = {\n\t\tdiscard: discardSyncRuntimeDeadLetter,\n\t\tinspect: inspectSyncRuntime,\n\t\trebase: rebaseSyncRuntimeDeadLetter,\n\t\tretry: retrySyncRuntimeDeadLetter\n\t}\n) => {\n\tconst installation: Installation = { bridge };\n\tregistry.installations.push(installation);\n\n\treturn () => {\n\t\tconst index = registry.installations.indexOf(installation);\n\t\tif (index >= 0) registry.installations.splice(index, 1);\n\t};\n};\n",
|
|
47
|
+
"export const ABSOLUTE_EXPO_BRIDGE_FORMAT = 3 as const;\nexport const ABSOLUTE_EXPO_BRIDGE_MAX_BYTES = 64 * 1024;\n\nexport const ABSOLUTE_EXPO_BRIDGE_METHODS = [\n\t'devices.platform.getInfo',\n\t'devices.lifecycle.getState',\n\t'devices.links.getLaunchUrl',\n\t'devices.links.openExternal',\n\t'devices.network.getStatus',\n\t'devices.storage.clear',\n\t'devices.storage.get',\n\t'devices.storage.keys',\n\t'devices.storage.remove',\n\t'devices.storage.set',\n\t'devices.back.capability',\n\t'devices.clipboard.capability',\n\t'devices.clipboard.readText',\n\t'devices.clipboard.writeText',\n\t'devices.share.capability',\n\t'devices.share.share',\n\t'devices.haptics.capability',\n\t'devices.haptics.impact',\n\t'devices.haptics.notification',\n\t'devices.haptics.selectionChanged',\n\t'devices.haptics.vibrate',\n\t'devices.keyboard.capability',\n\t'devices.keyboard.dismiss',\n\t'devices.keyboard.getState',\n\t'devices.systemBars.capability',\n\t'devices.systemBars.setAppearance',\n\t'devices.systemBars.setVisible',\n\t'devices.camera.capability',\n\t'devices.camera.queryPermission',\n\t'devices.camera.requestPermission',\n\t'devices.camera.takePhoto',\n\t'devices.photos.capability',\n\t'devices.photos.pick',\n\t'devices.location.capability',\n\t'devices.location.current',\n\t'devices.location.queryPermission',\n\t'devices.location.requestPermission',\n\t'devices.location.watch.start',\n\t'devices.location.watch.stop',\n\t'devices.localNotifications.capability',\n\t'devices.localNotifications.queryPermission',\n\t'devices.localNotifications.requestPermission',\n\t'devices.localNotifications.schedule',\n\t'devices.localNotifications.pending',\n\t'devices.localNotifications.cancel',\n\t'devices.pushNotifications.capability',\n\t'devices.pushNotifications.queryPermission',\n\t'devices.pushNotifications.requestPermission',\n\t'devices.pushNotifications.enable',\n\t'devices.pushNotifications.disable',\n\t'devices.documents.capability',\n\t'devices.documents.pick',\n\t'devices.transfer.read',\n\t'devices.transfer.close',\n\t'devices.upload.begin',\n\t'devices.upload.write',\n\t'devices.documents.export',\n\t'devices.documents.open',\n\t'http.fetch',\n\t'auth.signIn',\n\t'auth.signOut',\n\t'auth.status',\n\t'sync.store.begin',\n\t'sync.store.deleteNamespace',\n\t'sync.store.end',\n\t'sync.store.schema',\n\t'sync.tx.deleteCollection',\n\t'sync.tx.deleteMutation',\n\t'sync.tx.getCollection',\n\t'sync.tx.getInstallationId',\n\t'sync.tx.getMutation',\n\t'sync.tx.listCollections',\n\t'sync.tx.listMutations',\n\t'sync.tx.putCollection',\n\t'sync.tx.putMutation',\n\t'sync.tx.setInstallationId',\n\t'sync.socket.close',\n\t'sync.socket.open',\n\t'sync.socket.sendChunk'\n] as const;\n\nexport type AbsoluteExpoBridgeMethod =\n\t(typeof ABSOLUTE_EXPO_BRIDGE_METHODS)[number];\n\nexport type AbsoluteExpoBridgeRequest = {\n\tformat: typeof ABSOLUTE_EXPO_BRIDGE_FORMAT;\n\tid: string;\n\tkind: 'request';\n\tmethod: AbsoluteExpoBridgeMethod;\n\tparams: Record<string, unknown>;\n\tpath: string;\n};\n\nexport type AbsoluteExpoBridgeResponse = {\n\tformat: typeof ABSOLUTE_EXPO_BRIDGE_FORMAT;\n\tid: string;\n\tkind: 'response';\n\tresult?: unknown;\n\terror?: { code: string; message: string };\n};\n\nexport type AbsoluteExpoBridgeEvent = {\n\tformat: typeof ABSOLUTE_EXPO_BRIDGE_FORMAT;\n\tkind: 'event';\n\tevent:\n\t\t| 'ready'\n\t\t| 'navigation'\n\t\t| 'auth.principal'\n\t\t| 'sync.socket'\n\t\t| 'sync.wake';\n\tpath: string;\n\tpayload?: Record<string, unknown>;\n};\n\nexport type AbsoluteExpoBridgeMessage =\n\t| AbsoluteExpoBridgeEvent\n\t| AbsoluteExpoBridgeRequest\n\t| AbsoluteExpoBridgeResponse;\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n\ttypeof value === 'object' &&\n\tvalue !== null &&\n\t!Array.isArray(value) &&\n\t(Object.getPrototypeOf(value) === Object.prototype ||\n\t\tObject.getPrototypeOf(value) === null);\n\nconst validId = (value: unknown) =>\n\ttypeof value === 'string' && /^[A-Za-z0-9_-]{1,80}$/u.test(value);\n\nconst validPath = (value: unknown) =>\n\ttypeof value === 'string' &&\n\tvalue.startsWith('/') &&\n\t!value.startsWith('//') &&\n\tvalue.length <= 4096;\n\nconst parseRequest = (value: Record<string, unknown>) => {\n\tif (typeof value.id !== 'string' || !validId(value.id))\n\t\tthrow new TypeError('Expo bridge request id is invalid.');\n\tconst method = ABSOLUTE_EXPO_BRIDGE_METHODS.find(\n\t\t(candidate) => candidate === value.method\n\t);\n\tif (!method) {\n\t\tthrow new TypeError('Expo bridge method is not allowed.');\n\t}\n\tif (!isRecord(value.params))\n\t\tthrow new TypeError('Expo bridge request params must be an object.');\n\tif (typeof value.path !== 'string' || !validPath(value.path))\n\t\tthrow new TypeError('Expo bridge request path is invalid.');\n\tif (method === 'devices.haptics.impact') {\n\t\tconst styles = new Set([\n\t\t\t'error',\n\t\t\t'heavy',\n\t\t\t'light',\n\t\t\t'medium',\n\t\t\t'selection',\n\t\t\t'success',\n\t\t\t'vibrate',\n\t\t\t'warning'\n\t\t]);\n\t\tif (\n\t\t\ttypeof value.params.style !== 'string' ||\n\t\t\t!styles.has(value.params.style)\n\t\t)\n\t\t\tthrow new TypeError('Expo bridge haptics style is invalid.');\n\t\tif (\n\t\t\tvalue.params.durationMs !== undefined &&\n\t\t\t(typeof value.params.durationMs !== 'number' ||\n\t\t\t\t!Number.isFinite(value.params.durationMs) ||\n\t\t\t\tvalue.params.durationMs < 0 ||\n\t\t\t\tvalue.params.durationMs > 10_000)\n\t\t) {\n\t\t\tthrow new TypeError('Expo bridge haptics duration is invalid.');\n\t\t}\n\t}\n\tif (method === 'http.fetch') {\n\t\tif (typeof value.params.url !== 'string')\n\t\t\tthrow new TypeError('Expo bridge HTTP URL is invalid.');\n\t\tconst url = new URL(value.params.url);\n\t\tconst loopbackHttp =\n\t\t\turl.protocol === 'http:' &&\n\t\t\t(url.hostname === 'localhost' ||\n\t\t\t\turl.hostname === '127.0.0.1' ||\n\t\t\t\turl.hostname === '[::1]');\n\t\tif (url.protocol !== 'https:' && !loopbackHttp)\n\t\t\tthrow new TypeError('Expo bridge HTTP URL must use HTTPS.');\n\t\tif (\n\t\t\ttypeof value.params.method !== 'string' ||\n\t\t\t!['DELETE', 'GET', 'PATCH', 'POST', 'PUT'].includes(\n\t\t\t\tvalue.params.method\n\t\t\t)\n\t\t)\n\t\t\tthrow new TypeError('Expo bridge HTTP method is not allowed.');\n\t\tif (\n\t\t\tvalue.params.body !== undefined &&\n\t\t\ttypeof value.params.body !== 'string'\n\t\t)\n\t\t\tthrow new TypeError('Expo bridge HTTP body is invalid.');\n\t\tif (\n\t\t\ttypeof value.params.body === 'string' &&\n\t\t\tnew TextEncoder().encode(value.params.body).byteLength > 48 * 1024\n\t\t)\n\t\t\tthrow new TypeError('Expo bridge HTTP body exceeds 48 KiB.');\n\t\tif (\n\t\t\t(value.params.method === 'GET' ||\n\t\t\t\tvalue.params.method === 'DELETE') &&\n\t\t\tvalue.params.body !== undefined\n\t\t)\n\t\t\tthrow new TypeError(\n\t\t\t\t'Expo bridge HTTP method cannot contain a body.'\n\t\t\t);\n\t\tif (!isRecord(value.params.headers))\n\t\t\tthrow new TypeError('Expo bridge HTTP headers must be an object.');\n\t\tconst headersAllowed = Object.entries(value.params.headers).every(\n\t\t\t([name, header]) =>\n\t\t\t\ttypeof header === 'string' &&\n\t\t\t\t(name.toLowerCase() === 'accept' ||\n\t\t\t\t\tname.toLowerCase() === 'content-type' ||\n\t\t\t\t\tname.toLowerCase().startsWith('x-absolute-mobile-'))\n\t\t);\n\t\tif (!headersAllowed) {\n\t\t\tthrow new TypeError('Expo bridge HTTP header is not allowed.');\n\t\t}\n\t}\n\tif (method === 'auth.signIn') {\n\t\tif (\n\t\t\ttypeof value.params.email !== 'string' ||\n\t\t\tvalue.params.email.length > 320 ||\n\t\t\ttypeof value.params.signup !== 'boolean'\n\t\t)\n\t\t\tthrow new TypeError('Expo bridge Auth sign-in params are invalid.');\n\t}\n\tif (\n\t\t(method === 'auth.signOut' || method === 'auth.status') &&\n\t\tObject.keys(value.params).length !== 0\n\t)\n\t\tthrow new TypeError('Expo bridge Auth params must be empty.');\n\n\treturn {\n\t\tformat: ABSOLUTE_EXPO_BRIDGE_FORMAT,\n\t\tid: value.id,\n\t\tkind: 'request' as const,\n\t\tmethod,\n\t\tparams: value.params,\n\t\tpath: value.path\n\t};\n};\n\nconst parseResponse = (value: Record<string, unknown>) => {\n\tif (typeof value.id !== 'string' || !validId(value.id))\n\t\tthrow new TypeError('Expo bridge response id is invalid.');\n\tif (value.error !== undefined) {\n\t\tif (\n\t\t\t!isRecord(value.error) ||\n\t\t\ttypeof value.error.code !== 'string' ||\n\t\t\ttypeof value.error.message !== 'string'\n\t\t) {\n\t\t\tthrow new TypeError('Expo bridge response error is invalid.');\n\t\t}\n\t\tif (value.result !== undefined)\n\t\t\tthrow new TypeError(\n\t\t\t\t'Expo bridge response cannot contain result and error.'\n\t\t\t);\n\t}\n\n\tif (isRecord(value.error)) {\n\t\treturn {\n\t\t\terror: {\n\t\t\t\tcode: String(value.error.code),\n\t\t\t\tmessage: String(value.error.message)\n\t\t\t},\n\t\t\tformat: ABSOLUTE_EXPO_BRIDGE_FORMAT,\n\t\t\tid: value.id,\n\t\t\tkind: 'response' as const\n\t\t};\n\t}\n\n\treturn {\n\t\tformat: ABSOLUTE_EXPO_BRIDGE_FORMAT,\n\t\tid: value.id,\n\t\tkind: 'response' as const,\n\t\tresult: value.result\n\t};\n};\n\nconst parseEvent = (value: Record<string, unknown>) => {\n\tif (\n\t\tvalue.event !== 'ready' &&\n\t\tvalue.event !== 'navigation' &&\n\t\tvalue.event !== 'auth.principal' &&\n\t\tvalue.event !== 'sync.socket' &&\n\t\tvalue.event !== 'sync.wake'\n\t) {\n\t\tthrow new TypeError('Expo bridge event is not allowed.');\n\t}\n\tif (typeof value.path !== 'string' || !validPath(value.path))\n\t\tthrow new TypeError('Expo bridge event path is invalid.');\n\tif (value.payload !== undefined && !isRecord(value.payload)) {\n\t\tthrow new TypeError('Expo bridge event payload must be an object.');\n\t}\n\n\treturn {\n\t\tevent: value.event,\n\t\tformat: ABSOLUTE_EXPO_BRIDGE_FORMAT,\n\t\tkind: 'event' as const,\n\t\tpath: value.path,\n\t\t...(value.payload ? { payload: value.payload } : {})\n\t};\n};\n\nexport const createAbsoluteExpoBridgeError = (\n\tid: string,\n\tcode: string,\n\tmessage: string\n) =>\n\tparseResponse({\n\t\terror: { code, message },\n\t\tformat: ABSOLUTE_EXPO_BRIDGE_FORMAT,\n\t\tid,\n\t\tkind: 'response'\n\t});\nexport const createAbsoluteExpoBridgeResponse = (id: string, result: unknown) =>\n\tparseResponse({\n\t\tformat: ABSOLUTE_EXPO_BRIDGE_FORMAT,\n\t\tid,\n\t\tkind: 'response',\n\t\tresult\n\t});\nexport const parseAbsoluteExpoBridgeMessage = (source: string) => {\n\tif (\n\t\tnew TextEncoder().encode(source).byteLength >\n\t\tABSOLUTE_EXPO_BRIDGE_MAX_BYTES\n\t)\n\t\tthrow new TypeError('Expo bridge message exceeds 64 KiB.');\n\tlet parsed: unknown;\n\ttry {\n\t\tparsed = JSON.parse(source);\n\t} catch (cause) {\n\t\tthrow new TypeError('Expo bridge message is not valid JSON.', {\n\t\t\tcause\n\t\t});\n\t}\n\tif (!isRecord(parsed) || parsed.format !== ABSOLUTE_EXPO_BRIDGE_FORMAT) {\n\t\tthrow new TypeError('Expo bridge message format is unsupported.');\n\t}\n\tif (parsed.kind === 'request') return parseRequest(parsed);\n\tif (parsed.kind === 'response') return parseResponse(parsed);\n\tif (parsed.kind === 'event') return parseEvent(parsed);\n\n\tthrow new TypeError('Expo bridge message kind is unsupported.');\n};\n",
|
|
48
|
+
"import { spawn, type ChildProcess } from 'node:child_process';\nimport { access } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport type { NormalizedAbsoluteMobileConfig } from './config';\nimport {\n\tstartAbsoluteIosCaEnrollmentServer,\n\ttype AbsoluteIosCaEnrollmentServer\n} from './iosPhysicalDeviceTransport';\n\nexport type AbsoluteExpoDevPlatform = 'android' | 'ios';\nexport type AbsoluteExpoDevState =\n\t| 'building-android'\n\t| 'building-ios'\n\t| 'closed'\n\t| 'enrolling-trust'\n\t| 'failed'\n\t| 'preparing-native'\n\t| 'ready'\n\t| 'starting-metro';\n\nexport type AbsoluteExpoDevCommand = {\n\targs: string[];\n\tenv: Record<string, string>;\n\tplatform?: AbsoluteExpoDevPlatform;\n\trole: 'metro' | 'native-build' | 'native-prepare';\n};\n\nexport type AbsoluteExpoDevPlan = {\n\tcommands: AbsoluteExpoDevCommand[];\n\tmetroPort: number;\n\tproject: string;\n};\n\nexport type PlanAbsoluteExpoDevOptions = {\n\tandroidDevice?: string;\n\tandroidOrigin?: string;\n\tcertificateAuthorityPath?: string;\n\tiosDevice?: string;\n\tiosOrigin?: string;\n\tmetroHost?: string;\n\tmetroPort: number;\n\t/** The caller owns Metro, for example through a Remote Mac tunnel. */\n\tmetro?: 'external' | 'managed';\n\tplatforms: AbsoluteExpoDevPlatform[];\n};\n\nexport type AbsoluteExpoDevPhaseTiming = {\n\tdurationMs: number;\n\tphase: AbsoluteExpoDevState;\n};\n\nexport type StartAbsoluteExpoDevOptions = PlanAbsoluteExpoDevOptions & {\n\tconfig: NormalizedAbsoluteMobileConfig;\n\texecutable?: string;\n\tlog?: (message: string) => void;\n\tonPhaseTiming?: (timing: AbsoluteExpoDevPhaseTiming) => void;\n\tonStateChange?: (state: AbsoluteExpoDevState) => void;\n\tsignal?: AbortSignal;\n\tspawnProcess?: typeof spawn;\n\tstartCaEnrollmentServer?: typeof startAbsoluteIosCaEnrollmentServer;\n};\n\nexport type AbsoluteExpoDevSession = {\n\tclose: () => Promise<void>;\n\tmetroPort: number;\n\tplatforms: AbsoluteExpoDevPlatform[];\n\ttimings: Partial<Record<AbsoluteExpoDevState, number>>;\n};\n\nconst METRO_READY_TIMEOUT_MS = 60_000;\nconst PROCESS_CLOSE_TIMEOUT_MS = 2_000;\n\nconst commandEnvironment = (options: PlanAbsoluteExpoDevOptions) => ({\n\tABSOLUTE_EXPO_DEVELOPMENT: '1',\n\t...(options.certificateAuthorityPath\n\t\t? {\n\t\t\t\tABSOLUTE_EXPO_DEVELOPMENT_CA_PATH:\n\t\t\t\t\toptions.certificateAuthorityPath\n\t\t\t}\n\t\t: {}),\n\t...(options.androidOrigin\n\t\t? { EXPO_PUBLIC_ABSOLUTE_DEV_ANDROID_ORIGIN: options.androidOrigin }\n\t\t: {}),\n\t...(options.iosOrigin\n\t\t? { EXPO_PUBLIC_ABSOLUTE_DEV_IOS_ORIGIN: options.iosOrigin }\n\t\t: {}),\n\t...(options.metroHost\n\t\t? { REACT_NATIVE_PACKAGER_HOSTNAME: options.metroHost }\n\t\t: {})\n});\n\nexport const absoluteExpoExecutable = async (project: string) => {\n\tconst executable = join(project, 'node_modules', '.bin', 'expo');\n\ttry {\n\t\tawait access(executable);\n\n\t\treturn executable;\n\t} catch {\n\t\tthrow new TypeError(\n\t\t\t'Expo dependencies are not installed in the generated shell. Run `absolute mobile init --yes`.'\n\t\t);\n\t}\n};\n\nexport const planAbsoluteExpoDevSession = (\n\tconfig: NormalizedAbsoluteMobileConfig,\n\toptions: PlanAbsoluteExpoDevOptions\n): AbsoluteExpoDevPlan => {\n\tif (config.engine !== 'expo')\n\t\tthrow new TypeError('The Expo development controller requires Expo.');\n\tif (options.platforms.length === 0 && options.metro === 'external')\n\t\tthrow new TypeError(\n\t\t\t'External Expo execution requires a target platform.'\n\t\t);\n\tconst secureOrigin = [options.androidOrigin, options.iosOrigin].some(\n\t\t(origin) => origin && new URL(origin).protocol === 'https:'\n\t);\n\tif (secureOrigin && !options.certificateAuthorityPath)\n\t\tthrow new TypeError(\n\t\t\t'Expo HTTPS development requires the AbsoluteJS development CA certificate.'\n\t\t);\n\tconst env = commandEnvironment(options);\n\tconst metro: AbsoluteExpoDevCommand = {\n\t\targs: [\n\t\t\t'start',\n\t\t\t'--dev-client',\n\t\t\t'--host',\n\t\t\t'localhost',\n\t\t\t'--port',\n\t\t\tString(options.metroPort)\n\t\t],\n\t\tenv,\n\t\trole: 'metro'\n\t};\n\tconst prepare: AbsoluteExpoDevCommand | undefined =\n\t\toptions.platforms.length === 0\n\t\t\t? undefined\n\t\t\t: {\n\t\t\t\t\targs: [\n\t\t\t\t\t\t'prebuild',\n\t\t\t\t\t\t'--clean',\n\t\t\t\t\t\t'--no-install',\n\t\t\t\t\t\t'--platform',\n\t\t\t\t\t\toptions.platforms.length === 2\n\t\t\t\t\t\t\t? 'all'\n\t\t\t\t\t\t\t: (options.platforms[0] ?? 'all')\n\t\t\t\t\t],\n\t\t\t\t\tenv,\n\t\t\t\t\trole: 'native-prepare'\n\t\t\t\t};\n\tconst native = options.platforms.map((platform) => {\n\t\tconst device =\n\t\t\tplatform === 'android' ? options.androidDevice : options.iosDevice;\n\t\tconst command: AbsoluteExpoDevCommand = {\n\t\t\targs: [\n\t\t\t\t`run:${platform}`,\n\t\t\t\t'--no-bundler',\n\t\t\t\t'--port',\n\t\t\t\tString(options.metroPort),\n\t\t\t\t...(device ? ['--device', device] : [])\n\t\t\t],\n\t\t\tenv,\n\t\t\tplatform,\n\t\t\trole: 'native-build'\n\t\t};\n\n\t\treturn command;\n\t});\n\n\treturn {\n\t\tcommands: [\n\t\t\t...(prepare ? [prepare] : []),\n\t\t\t...(options.metro === 'external' ? [] : [metro]),\n\t\t\t...native\n\t\t],\n\t\tmetroPort: options.metroPort,\n\t\tproject: config.nativeProjectDirectory\n\t};\n};\n\nconst abortError = () =>\n\tnew DOMException('Expo development aborted.', 'AbortError');\n\nconst forwardLines = (\n\tprocess: ChildProcess,\n\tonLine: (line: string) => void\n) => {\n\tconst attach = (stream: NodeJS.ReadableStream | null) => {\n\t\tif (!stream) return;\n\t\tlet buffered = '';\n\t\tstream.on('data', (chunk: Buffer) => {\n\t\t\tbuffered += chunk.toString('utf8');\n\t\t\tlet newline = buffered.indexOf('\\n');\n\t\t\twhile (newline >= 0) {\n\t\t\t\tonLine(buffered.slice(0, newline).replace(/\\r$/u, ''));\n\t\t\t\tbuffered = buffered.slice(newline + 1);\n\t\t\t\tnewline = buffered.indexOf('\\n');\n\t\t\t}\n\t\t});\n\t\tstream.on('end', () => {\n\t\t\tif (buffered) onLine(buffered);\n\t\t});\n\t};\n\tattach(process.stdout);\n\tattach(process.stderr);\n};\n\nconst stopProcess = async (process: ChildProcess) => {\n\tif (process.exitCode !== null || process.killed) return;\n\tprocess.kill('SIGTERM');\n\tawait Promise.race([\n\t\tnew Promise<void>((resolve) => process.once('exit', () => resolve())),\n\t\tnew Promise<void>((resolve) =>\n\t\t\tsetTimeout(resolve, PROCESS_CLOSE_TIMEOUT_MS)\n\t\t)\n\t]);\n\tif (process.exitCode === null) process.kill('SIGKILL');\n};\n\nconst waitForExit = (process: ChildProcess) =>\n\tnew Promise<number>((resolve) => {\n\t\tif (process.exitCode !== null) {\n\t\t\tresolve(process.exitCode);\n\n\t\t\treturn;\n\t\t}\n\t\tprocess.once('exit', (code) => resolve(code ?? 1));\n\t});\n\ntype ExpoUtilityCommandOptions = {\n\tcwd: string;\n\tsignal?: AbortSignal;\n\tlog: (message: string) => void;\n};\n\nconst runUtilityCommand = async (\n\trun: typeof spawn,\n\tcommand: string,\n\targs: string[],\n\toptions: ExpoUtilityCommandOptions\n) => {\n\tconst child = run(command, args, {\n\t\tcwd: options.cwd,\n\t\tenv: process.env,\n\t\tstdio: ['ignore', 'pipe', 'pipe']\n\t});\n\tforwardLines(child, options.log);\n\tconst abort = () => void stopProcess(child);\n\toptions.signal?.addEventListener('abort', abort, { once: true });\n\tconst exitCode = await waitForExit(child);\n\toptions.signal?.removeEventListener('abort', abort);\n\tif (options.signal?.aborted) throw abortError();\n\n\treturn exitCode;\n};\n\nexport const startAbsoluteExpoDevSession = async (\n\toptions: StartAbsoluteExpoDevOptions\n) => {\n\tconst plan = planAbsoluteExpoDevSession(options.config, options);\n\tconst executable =\n\t\toptions.executable ?? (await absoluteExpoExecutable(plan.project));\n\tconst run = options.spawnProcess ?? spawn;\n\tconst log = options.log ?? (() => undefined);\n\tconst timings: Partial<Record<AbsoluteExpoDevState, number>> = {};\n\tlet caEnrollmentServer: AbsoluteIosCaEnrollmentServer | null = null;\n\tconst closeEnrollmentServer = async () => {\n\t\tconst server = caEnrollmentServer;\n\t\tcaEnrollmentServer = null;\n\t\tawait server?.close();\n\t};\n\tconst publishTiming = (phase: AbsoluteExpoDevState, durationMs: number) => {\n\t\ttimings[phase] = (timings[phase] ?? 0) + durationMs;\n\t\toptions.onPhaseTiming?.({ durationMs, phase });\n\t};\n\tconst setState = (state: AbsoluteExpoDevState) => {\n\t\toptions.onStateChange?.(state);\n\t};\n\tif (options.signal?.aborted) throw abortError();\n\tconst prepareCommand = plan.commands.find(\n\t\t(command) => command.role === 'native-prepare'\n\t);\n\tconst metroCommand = plan.commands.find(\n\t\t(command) => command.role === 'metro'\n\t);\n\tconst nativeCommands = plan.commands.filter(\n\t\t(command) => command.role === 'native-build'\n\t);\n\tconst runPrepareCommand = async (command: AbsoluteExpoDevCommand) => {\n\t\tsetState('preparing-native');\n\t\tconst prepareStarted = performance.now();\n\t\tconst prepareProcess = run(executable, command.args, {\n\t\t\tcwd: plan.project,\n\t\t\tenv: { ...process.env, ...command.env },\n\t\t\tstdio: ['ignore', 'pipe', 'pipe']\n\t\t});\n\t\tforwardLines(prepareProcess, (line) => {\n\t\t\tif (line) log(`[prebuild] ${line}`);\n\t\t});\n\t\tconst abortPrepare = () => void stopProcess(prepareProcess);\n\t\toptions.signal?.addEventListener('abort', abortPrepare, { once: true });\n\t\tconst prepareExit = await waitForExit(prepareProcess);\n\t\toptions.signal?.removeEventListener('abort', abortPrepare);\n\t\tif (options.signal?.aborted) throw abortError();\n\t\tif (prepareExit !== 0) {\n\t\t\tsetState('failed');\n\t\t\tthrow new Error(\n\t\t\t\t`Expo native preparation exited with status ${prepareExit}.`\n\t\t\t);\n\t\t}\n\t\tpublishTiming('preparing-native', performance.now() - prepareStarted);\n\t};\n\tif (prepareCommand) await runPrepareCommand(prepareCommand);\n\tconst managedMetro = metroCommand !== undefined;\n\tif (managedMetro) setState('starting-metro');\n\tconst metroStarted = performance.now();\n\tconst metro = metroCommand\n\t\t? run(executable, metroCommand.args, {\n\t\t\t\tcwd: plan.project,\n\t\t\t\tenv: { ...process.env, ...metroCommand.env },\n\t\t\t\tstdio: ['ignore', 'pipe', 'pipe']\n\t\t\t})\n\t\t: undefined;\n\tlet metroReady = false;\n\tlet resolveMetro: (() => void) | undefined;\n\tconst metroPromise = new Promise<void>((resolve, reject) => {\n\t\tif (!metro) {\n\t\t\tresolve();\n\n\t\t\treturn;\n\t\t}\n\t\tconst timeout = setTimeout(() => {\n\t\t\treject(\n\t\t\t\tnew Error('Expo Metro did not become ready within 60 seconds.')\n\t\t\t);\n\t\t}, METRO_READY_TIMEOUT_MS);\n\t\tresolveMetro = () => {\n\t\t\tclearTimeout(timeout);\n\t\t\tresolve();\n\t\t};\n\t\tmetro.once('exit', (code) => {\n\t\t\tif (!metroReady) {\n\t\t\t\tclearTimeout(timeout);\n\t\t\t\treject(\n\t\t\t\t\tnew Error(`Expo Metro exited with status ${code ?? 1}.`)\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\t});\n\tif (metro)\n\t\tforwardLines(metro, (line) => {\n\t\t\tif (line) log(`[metro] ${line}`);\n\t\t\tif (\n\t\t\t\t!metroReady &&\n\t\t\t\t/(?:Waiting on|Metro waiting on|Dev server ready)/iu.test(line)\n\t\t\t) {\n\t\t\t\tmetroReady = true;\n\t\t\t\tresolveMetro?.();\n\t\t\t}\n\t\t});\n\tconst abort = () => {\n\t\tif (metro) void stopProcess(metro);\n\t};\n\toptions.signal?.addEventListener('abort', abort, { once: true });\n\tconst runNativeCommand = async (command: AbsoluteExpoDevCommand) => {\n\t\tif (options.signal?.aborted) throw abortError();\n\t\tconst { platform } = command;\n\t\tif (!platform)\n\t\t\tthrow new TypeError(\n\t\t\t\t'Expo native build command is missing a platform.'\n\t\t\t);\n\t\tconst state: AbsoluteExpoDevState =\n\t\t\tplatform === 'android' ? 'building-android' : 'building-ios';\n\t\tsetState(state);\n\t\tconst started = performance.now();\n\t\tconst child = run(executable, command.args, {\n\t\t\tcwd: plan.project,\n\t\t\tenv: { ...process.env, ...command.env },\n\t\t\tstdio: ['ignore', 'pipe', 'pipe']\n\t\t});\n\t\tforwardLines(child, (line) => {\n\t\t\tif (line) log(`[${platform}] ${line}`);\n\t\t});\n\t\tconst abortChild = () => void stopProcess(child);\n\t\toptions.signal?.addEventListener('abort', abortChild, { once: true });\n\t\tconst exitCode = await waitForExit(child);\n\t\toptions.signal?.removeEventListener('abort', abortChild);\n\t\tif (options.signal?.aborted) throw abortError();\n\t\tif (exitCode !== 0) {\n\t\t\tthrow new Error(\n\t\t\t\t`Expo ${platform} development build exited with status ${exitCode}.`\n\t\t\t);\n\t\t}\n\t\tif (\n\t\t\tplatform === 'ios' &&\n\t\t\toptions.certificateAuthorityPath &&\n\t\t\toptions.iosOrigin &&\n\t\t\tnew URL(options.iosOrigin).protocol === 'https:' &&\n\t\t\t!options.iosDevice\n\t\t) {\n\t\t\tsetState('enrolling-trust');\n\t\t\tconst trustStarted = performance.now();\n\t\t\tconst utilityOptions: ExpoUtilityCommandOptions = {\n\t\t\t\tcwd: plan.project,\n\t\t\t\tsignal: options.signal,\n\t\t\t\tlog: (line: string) => line && log(`[ios-trust] ${line}`)\n\t\t\t};\n\t\t\tconst trustExit = await runUtilityCommand(\n\t\t\t\trun,\n\t\t\t\t'xcrun',\n\t\t\t\t[\n\t\t\t\t\t'simctl',\n\t\t\t\t\t'keychain',\n\t\t\t\t\t'booted',\n\t\t\t\t\t'add-root-cert',\n\t\t\t\t\toptions.certificateAuthorityPath\n\t\t\t\t],\n\t\t\t\tutilityOptions\n\t\t\t);\n\t\t\tif (trustExit !== 0)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Expo iOS Simulator development CA trust exited with status ${trustExit}.`\n\t\t\t\t);\n\t\t\tawait runUtilityCommand(\n\t\t\t\trun,\n\t\t\t\t'xcrun',\n\t\t\t\t['simctl', 'terminate', 'booted', options.config.appId],\n\t\t\t\tutilityOptions\n\t\t\t);\n\t\t\tconst launchExit = await runUtilityCommand(\n\t\t\t\trun,\n\t\t\t\t'xcrun',\n\t\t\t\t['simctl', 'launch', 'booted', options.config.appId],\n\t\t\t\tutilityOptions\n\t\t\t);\n\t\t\tif (launchExit !== 0)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Expo iOS Simulator relaunch exited with status ${launchExit}.`\n\t\t\t\t);\n\t\t\tlog(\n\t\t\t\t'Installed the AbsoluteJS development CA into the Expo iOS Simulator and relaunched the app.'\n\t\t\t);\n\t\t\tpublishTiming('enrolling-trust', performance.now() - trustStarted);\n\t\t}\n\t\tconst durationMs = performance.now() - started;\n\t\ttimings[state] = durationMs;\n\t\toptions.onPhaseTiming?.({ durationMs, phase: state });\n\t};\n\tconst runNativeCommands = async (\n\t\tcommands: AbsoluteExpoDevCommand[]\n\t): Promise<void> => {\n\t\tconst [command, ...remaining] = commands;\n\t\tif (!command) return;\n\t\tawait runNativeCommand(command);\n\t\tawait runNativeCommands(remaining);\n\t};\n\tconst startPhysicalIosEnrollment = async () => {\n\t\tif (\n\t\t\t!options.iosDevice ||\n\t\t\t!options.certificateAuthorityPath ||\n\t\t\t!options.iosOrigin ||\n\t\t\tnew URL(options.iosOrigin).protocol !== 'https:'\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tsetState('enrolling-trust');\n\t\tconst trustStarted = performance.now();\n\t\tconst startEnrollment =\n\t\t\toptions.startCaEnrollmentServer ??\n\t\t\tstartAbsoluteIosCaEnrollmentServer;\n\t\tcaEnrollmentServer = await startEnrollment({\n\t\t\tcertificateAuthorityPath: options.certificateAuthorityPath,\n\t\t\tdisplayHost: new URL(options.iosOrigin).hostname\n\t\t});\n\t\tlog(\n\t\t\t`On the iOS device, open ${caEnrollmentServer.url}, install the AbsoluteJS development CA profile, then enable it under Settings > General > About > Certificate Trust Settings. This public CA endpoint exists only for this dev session.`\n\t\t);\n\t\tpublishTiming('enrolling-trust', performance.now() - trustStarted);\n\t};\n\ttry {\n\t\tawait startPhysicalIosEnrollment();\n\t\tawait metroPromise;\n\t\tif (managedMetro)\n\t\t\tpublishTiming('starting-metro', performance.now() - metroStarted);\n\t\tawait runNativeCommands(nativeCommands);\n\t\tsetState('ready');\n\n\t\treturn {\n\t\t\tmetroPort: plan.metroPort,\n\t\t\tplatforms: options.platforms,\n\t\t\ttimings,\n\t\t\tclose: async () => {\n\t\t\t\toptions.signal?.removeEventListener('abort', abort);\n\t\t\t\tif (metro) await stopProcess(metro);\n\t\t\t\tawait closeEnrollmentServer();\n\t\t\t\tsetState('closed');\n\t\t\t}\n\t\t};\n\t} catch (error) {\n\t\toptions.signal?.removeEventListener('abort', abort);\n\t\tif (metro) await stopProcess(metro);\n\t\tawait closeEnrollmentServer();\n\t\tsetState('failed');\n\t\tthrow error;\n\t}\n};\n",
|
|
49
|
+
"import { existsSync } from 'node:fs';\nimport { access, mkdir, readFile, writeFile } from 'node:fs/promises';\nimport { dirname, extname, relative, resolve, sep } from 'node:path';\nimport type { NormalizedAbsoluteMobileConfig } from './config';\n\nexport const ABSOLUTE_MOBILE_CI_WORKFLOW_FORMAT = 1 as const;\n\nexport type AbsoluteMobileGithubWorkflowOptions = {\n\tconfig: NormalizedAbsoluteMobileConfig;\n\tconfigPath?: string;\n\tforce?: boolean;\n\tincludePublishing?: boolean;\n\toutputPath?: string;\n\tprojectRoot: string;\n\tregistryModule?: string;\n\tsecretEnvironment?: readonly string[];\n\tserverEntry?: string;\n};\n\nexport type AbsoluteMobileGithubWorkflowResult = {\n\tchanged: boolean;\n\tformat: typeof ABSOLUTE_MOBILE_CI_WORKFLOW_FORMAT;\n\tpath: string;\n\tplatforms: ('android' | 'ios')[];\n\tpublishing: boolean;\n\trequiredSecrets: string[];\n};\n\nconst SECRET_NAME_PATTERN = /^[A-Z][A-Z0-9_]*$/u;\nconst CI_ENV_INDENTATION = 6;\nconst RESERVED_SECRET_NAMES = new Set([\n\t'ABSOLUTE_ANDROID_KEYSTORE_BASE64',\n\t'ABSOLUTE_ANDROID_KEYSTORE_PASSWORD',\n\t'ABSOLUTE_ANDROID_KEY_ALIAS',\n\t'ABSOLUTE_ANDROID_KEY_PASSWORD',\n\t'ABSOLUTE_GOOGLE_CREDENTIALS_BASE64',\n\t'ABSOLUTE_IOS_CERTIFICATE_BASE64',\n\t'ABSOLUTE_IOS_CERTIFICATE_PASSWORD',\n\t'ABSOLUTE_IOS_PROVISIONING_PROFILE_BASE64',\n\t'ABSOLUTE_IOS_KEYCHAIN_PASSWORD',\n\t'ABSOLUTE_IOS_DEVELOPMENT_TEAM',\n\t'APP_STORE_CONNECT_ISSUER_ID',\n\t'APP_STORE_CONNECT_KEY_ID',\n\t'APP_STORE_CONNECT_PRIVATE_KEY_BASE64'\n]);\n\nconst exists = async (path: string) => {\n\ttry {\n\t\tawait access(path);\n\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n};\n\nconst yamlString = (value: string) => `'${value.replaceAll(\"'\", \"''\")}'`;\n\nconst projectPath = (\n\tprojectRoot: string,\n\tvalue: string,\n\tfield: string,\n\toptions: { allowMissing?: boolean } = {}\n) => {\n\tconst root = resolve(projectRoot);\n\tconst path = resolve(root, value);\n\tconst portable = relative(root, path).replaceAll('\\\\', '/');\n\tif (\n\t\tportable === '..' ||\n\t\tportable.startsWith(`..${sep}`) ||\n\t\tportable.startsWith('../') ||\n\t\tportable === ''\n\t) {\n\t\tthrow new TypeError(`${field} must remain inside the project root.`);\n\t}\n\tif (/\\r|\\n/u.test(portable) || portable.startsWith('-'))\n\t\tthrow new TypeError(`${field} contains an unsafe path.`);\n\tif (!options.allowMissing && !existsSync(path))\n\t\tthrow new TypeError(`${field} does not exist inside the project.`);\n\n\treturn portable;\n};\n\nconst workflowOutputPath = (projectRoot: string, value?: string) => {\n\tconst root = resolve(projectRoot);\n\tconst workflows = resolve(root, '.github/workflows');\n\tconst path = resolve(\n\t\troot,\n\t\tvalue ?? '.github/workflows/absolute-mobile.yml'\n\t);\n\tconst portable = relative(workflows, path);\n\tif (\n\t\tportable === '..' ||\n\t\tportable.startsWith(`..${sep}`) ||\n\t\t(extname(path) !== '.yml' && extname(path) !== '.yaml')\n\t) {\n\t\tthrow new TypeError(\n\t\t\t'mobile ci github --output must be a .yml or .yaml file inside .github/workflows.'\n\t\t);\n\t}\n\n\treturn path;\n};\n\nconst normalizeSecretEnvironment = (values: readonly string[] = []) => {\n\tconst names = [...new Set(values)].sort();\n\tfor (const name of names) {\n\t\tif (!SECRET_NAME_PATTERN.test(name))\n\t\t\tthrow new TypeError(\n\t\t\t\t'mobile ci github --secret-env values must be uppercase environment variable names.'\n\t\t\t);\n\t\tif (\n\t\t\tname.startsWith('GITHUB_') ||\n\t\t\tname.startsWith('RUNNER_') ||\n\t\t\tname.startsWith('ACTIONS_') ||\n\t\t\tRESERVED_SECRET_NAMES.has(name)\n\t\t) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`mobile ci github --secret-env cannot replace reserved variable ${name}.`\n\t\t\t);\n\t\t}\n\t}\n\n\treturn names;\n};\n\nconst customSecretEnvironment = (\n\tnames: readonly string[],\n\tindentation = CI_ENV_INDENTATION\n) =>\n\tnames\n\t\t.map(\n\t\t\t(name) =>\n\t\t\t\t`${' '.repeat(indentation)}${name}: \\${{ secrets.${name} }}`\n\t\t)\n\t\t.join('\\n');\n\ntype CommandEnvironmentOptions = {\n\tconfigPath?: string;\n\tregistryModule: string;\n\tserverEntry: string;\n};\n\ntype PlatformJobOptions = {\n\tcustomSecrets: readonly string[];\n\tincludePublishing: boolean;\n};\n\nconst commandEnvironment = (options: CommandEnvironmentOptions) =>\n\t` ABSOLUTE_CONFIG_PATH: ${yamlString(options.configPath ?? '')}\n ABSOLUTE_REGISTRY_MODULE: ${yamlString(options.registryModule)}\n ABSOLUTE_SERVER_ENTRY: ${yamlString(options.serverEntry)}`;\n\nconst appendConfigArgument = `if [[ -n \"$ABSOLUTE_CONFIG_PATH\" ]]; then\n args+=(--config \"$ABSOLUTE_CONFIG_PATH\")\n fi`;\n\nconst installSteps = ` - name: Check out source\n uses: actions/checkout@v6\n - name: Install Bun\n uses: oven-sh/setup-bun@v2\n - name: Install exact dependencies\n run: bun ci`;\n\nconst bundleAuditSteps = ` - name: Prepare production mobile bundle\n shell: bash\n run: |\n args=(bunx absolute prepare \"$ABSOLUTE_SERVER_ENTRY\" --outdir .absolutejs/mobile-ci/server)\n ${appendConfigArgument}\n \"\\${args[@]}\"\n - name: Run cryptographic mobile bundle audit\n id: mobile-bundle-audit\n continue-on-error: true\n shell: bash\n run: |\n mkdir -p .absolutejs/mobile-ci\n args=(bunx absolute mobile inspect --json --require-bundle)\n ${appendConfigArgument}\n \"\\${args[@]}\" > .absolutejs/mobile-ci/inspection.json\n - name: Upload mobile inspection report\n if: always()\n uses: actions/upload-artifact@v7\n with:\n name: absolute-mobile-inspection\n path: .absolutejs/mobile-ci/inspection.json\n if-no-files-found: error\n retention-days: 30\n include-hidden-files: true\n - name: Enforce mobile bundle audit\n if: steps.mobile-bundle-audit.outcome != 'success'\n run: exit 1`;\n\nconst releaseAuditSteps = (\n\tplatform: 'android' | 'ios'\n) => ` - name: Run redacted mobile release audit\n id: mobile-release-audit\n continue-on-error: true\n shell: bash\n run: |\n mkdir -p .absolutejs/mobile-ci\n args=(bunx absolute mobile doctor release ${platform} --json)\n ${appendConfigArgument}\n \"\\${args[@]}\" > .absolutejs/mobile-ci/compliance.json\n - name: Upload mobile compliance report\n if: always()\n uses: actions/upload-artifact@v7\n with:\n name: absolute-mobile-compliance-\\${{ github.job }}\n path: .absolutejs/mobile-ci/compliance.json\n if-no-files-found: error\n retention-days: 30\n include-hidden-files: true\n - name: Enforce mobile release audit\n if: steps.mobile-release-audit.outcome != 'success'\n run: exit 1`;\n\nconst platformInput = (platforms: readonly string[]) => {\n\tconst choices = platforms.length === 2 ? ['all', ...platforms] : platforms;\n\n\treturn ` platform:\n description: Native platform to build\n required: true\n type: choice\n default: ${choices[0]}\n options:\n${choices.map((value) => ` - ${value}`).join('\\n')}`;\n};\n\nconst publishingInputs = (\n\tplatforms: readonly string[],\n\tincludePublishing: boolean\n) => {\n\tif (!includePublishing) return '';\n\tconst fields = [\n\t\t` publish:\n description: Publish through mobile.release.ts after the signed build\n required: true\n type: boolean\n default: false`,\n\t\t` channel:\n description: Optional AbsoluteJS immutable release channel\n required: false\n type: string`\n\t];\n\tif (platforms.includes('android'))\n\t\tfields.push(` play_track:\n description: Optional Google Play track\n required: true\n type: choice\n default: registry-only\n options:\n - registry-only\n - internal\n - alpha\n - beta\n - production`);\n\tif (platforms.includes('ios')) {\n\t\tfields.push(` testflight_group:\n description: Optional internal or external TestFlight group\n required: false\n type: string`);\n\t\tfields.push(` submit_testflight_review:\n description: Explicitly submit an external TestFlight build for review\n required: true\n type: boolean\n default: false`);\n\t}\n\n\treturn `\\n${fields.join('\\n')}`;\n};\n\nconst jobCondition = (platform: 'android' | 'ios') =>\n\t`github.event_name == 'workflow_dispatch' && (inputs.platform == 'all' || inputs.platform == '${platform}')`;\n\nconst androidJob = (options: PlatformJobOptions) => {\n\tconst custom = customSecretEnvironment(options.customSecrets);\n\tconst publishEnvironment = options.includePublishing\n\t\t? `\n ABSOLUTE_PUBLISH: \\${{ inputs.publish }}\n ABSOLUTE_RELEASE_CHANNEL: \\${{ inputs.channel }}\n ABSOLUTE_PLAY_TRACK: \\${{ inputs.play_track }}\n ABSOLUTE_GOOGLE_CREDENTIALS_BASE64: \\${{ secrets.ABSOLUTE_GOOGLE_CREDENTIALS_BASE64 }}\n GOOGLE_APPLICATION_CREDENTIALS: \\${{ runner.temp }}/absolute-google-credentials.json`\n\t\t: '';\n\tconst publishCommand = options.includePublishing\n\t\t? `if [[ \"$ABSOLUTE_PUBLISH\" == \"true\" ]]; then\n args=(bunx absolute mobile publish android \"$ABSOLUTE_SERVER_ENTRY\" --registry \"$ABSOLUTE_REGISTRY_MODULE\")\n if [[ -n \"$ABSOLUTE_RELEASE_CHANNEL\" ]]; then\n args+=(--channel \"$ABSOLUTE_RELEASE_CHANNEL\")\n fi\n if [[ \"$ABSOLUTE_PLAY_TRACK\" != \"registry-only\" ]]; then\n args+=(--play-track \"$ABSOLUTE_PLAY_TRACK\")\n fi\n else\n args=(bunx absolute mobile build android \"$ABSOLUTE_SERVER_ENTRY\")\n fi`\n\t\t: `args=(bunx absolute mobile build android \"$ABSOLUTE_SERVER_ENTRY\")`;\n\tconst googleSetup = options.includePublishing\n\t\t? `\n if [[ \"$ABSOLUTE_PUBLISH\" == \"true\" && \"$ABSOLUTE_PLAY_TRACK\" != \"registry-only\" ]]; then\n if [[ -z \"$ABSOLUTE_GOOGLE_CREDENTIALS_BASE64\" ]]; then\n echo \"ABSOLUTE_GOOGLE_CREDENTIALS_BASE64 is required for Google Play publication.\" >&2\n exit 1\n fi\n printf '%s' \"$ABSOLUTE_GOOGLE_CREDENTIALS_BASE64\" | base64 --decode > \"$GOOGLE_APPLICATION_CREDENTIALS\"\n chmod 600 \"$GOOGLE_APPLICATION_CREDENTIALS\"\n fi`\n\t\t: '';\n\n\treturn `\n android:\n name: Signed Android release\n needs: validate\n if: \\${{ ${jobCondition('android')} }}\n runs-on: ubuntu-latest\n environment: absolute-mobile-release\n permissions:\n contents: read\n id-token: write\n attestations: write\n env:\n ABSOLUTE_ANDROID_KEYSTORE_BASE64: \\${{ secrets.ABSOLUTE_ANDROID_KEYSTORE_BASE64 }}\n ABSOLUTE_ANDROID_KEYSTORE_PASSWORD: \\${{ secrets.ABSOLUTE_ANDROID_KEYSTORE_PASSWORD }}\n ABSOLUTE_ANDROID_KEY_ALIAS: \\${{ secrets.ABSOLUTE_ANDROID_KEY_ALIAS }}\n ABSOLUTE_ANDROID_KEY_PASSWORD: \\${{ secrets.ABSOLUTE_ANDROID_KEY_PASSWORD }}\n ABSOLUTE_ANDROID_KEYSTORE_PATH: \\${{ runner.temp }}/absolute-release.jks${publishEnvironment}${custom ? `\\n${custom}` : ''}\n${commandEnvironment({ configPath: undefined, registryModule: '', serverEntry: '' })}\n steps:\n${installSteps}\n - name: Provision Android signing\n shell: bash\n run: |\n required=(\n ABSOLUTE_ANDROID_KEYSTORE_BASE64\n ABSOLUTE_ANDROID_KEYSTORE_PASSWORD\n ABSOLUTE_ANDROID_KEY_ALIAS\n ABSOLUTE_ANDROID_KEY_PASSWORD\n )\n for name in \"\\${required[@]}\"; do\n if [[ -z \"\\${!name}\" ]]; then\n echo \"$name is required in the absolute-mobile-release environment.\" >&2\n exit 1\n fi\n done\n printf '%s' \"$ABSOLUTE_ANDROID_KEYSTORE_BASE64\" | base64 --decode > \"\\${{ runner.temp }}/absolute-release.jks\"\n chmod 600 \"\\${{ runner.temp }}/absolute-release.jks\"${googleSetup}\n - name: Build or publish Android\n shell: bash\n run: |\n ${publishCommand}\n ${appendConfigArgument}\n \"\\${args[@]}\"\n${releaseAuditSteps('android')}\n - name: Attest Android App Bundle\n if: inputs.attest\n uses: actions/attest@v4\n with:\n subject-path: .absolutejs/mobile/releases/android/**/app-release.aab\n - name: Upload Android release\n uses: actions/upload-artifact@v7\n with:\n name: absolute-mobile-android\n path: .absolutejs/mobile/releases/android/\n if-no-files-found: error\n retention-days: 14\n include-hidden-files: true\n - name: Remove Android credentials\n if: always()\n shell: bash\n run: |\n rm -f \"\\${{ runner.temp }}/absolute-release.jks\"\n rm -f \"\\${{ runner.temp }}/absolute-google-credentials.json\"`;\n};\n\nconst iosJob = (options: PlatformJobOptions) => {\n\tconst custom = customSecretEnvironment(options.customSecrets);\n\tconst publishEnvironment = options.includePublishing\n\t\t? `\n ABSOLUTE_PUBLISH: \\${{ inputs.publish }}\n ABSOLUTE_RELEASE_CHANNEL: \\${{ inputs.channel }}\n ABSOLUTE_TESTFLIGHT_GROUP: \\${{ inputs.testflight_group }}\n ABSOLUTE_TESTFLIGHT_SUBMIT_REVIEW: \\${{ inputs.submit_testflight_review }}\n APP_STORE_CONNECT_ISSUER_ID: \\${{ secrets.APP_STORE_CONNECT_ISSUER_ID }}\n APP_STORE_CONNECT_KEY_ID: \\${{ secrets.APP_STORE_CONNECT_KEY_ID }}\n APP_STORE_CONNECT_PRIVATE_KEY_BASE64: \\${{ secrets.APP_STORE_CONNECT_PRIVATE_KEY_BASE64 }}\n APP_STORE_CONNECT_PRIVATE_KEY_PATH: \\${{ runner.temp }}/AuthKey_AbsoluteJS.p8`\n\t\t: '';\n\tconst publishCommand = options.includePublishing\n\t\t? `if [[ \"$ABSOLUTE_PUBLISH\" == \"true\" ]]; then\n args=(bunx absolute mobile publish ios \"$ABSOLUTE_SERVER_ENTRY\" --registry \"$ABSOLUTE_REGISTRY_MODULE\")\n if [[ -n \"$ABSOLUTE_RELEASE_CHANNEL\" ]]; then\n args+=(--channel \"$ABSOLUTE_RELEASE_CHANNEL\")\n fi\n if [[ -n \"$ABSOLUTE_TESTFLIGHT_GROUP\" ]]; then\n args+=(--testflight-group \"$ABSOLUTE_TESTFLIGHT_GROUP\")\n fi\n if [[ \"$ABSOLUTE_TESTFLIGHT_SUBMIT_REVIEW\" == \"true\" ]]; then\n args+=(--testflight-submit-review)\n fi\n else\n args=(bunx absolute mobile build ios \"$ABSOLUTE_SERVER_ENTRY\")\n fi`\n\t\t: `args=(bunx absolute mobile build ios \"$ABSOLUTE_SERVER_ENTRY\")`;\n\tconst appStoreSetup = options.includePublishing\n\t\t? `\n if [[ \"$ABSOLUTE_PUBLISH\" == \"true\" && -n \"$ABSOLUTE_TESTFLIGHT_GROUP\" ]]; then\n required+=(APP_STORE_CONNECT_ISSUER_ID APP_STORE_CONNECT_KEY_ID APP_STORE_CONNECT_PRIVATE_KEY_BASE64)\n fi`\n\t\t: '';\n\tconst appStoreDecode = options.includePublishing\n\t\t? `\n if [[ \"$ABSOLUTE_PUBLISH\" == \"true\" && -n \"$ABSOLUTE_TESTFLIGHT_GROUP\" ]]; then\n printf '%s' \"$APP_STORE_CONNECT_PRIVATE_KEY_BASE64\" | base64 --decode > \"$APP_STORE_CONNECT_PRIVATE_KEY_PATH\"\n chmod 600 \"$APP_STORE_CONNECT_PRIVATE_KEY_PATH\"\n fi`\n\t\t: '';\n\n\treturn `\n ios:\n name: Signed iOS release\n needs: validate\n if: \\${{ ${jobCondition('ios')} }}\n runs-on: macos-latest\n environment: absolute-mobile-release\n permissions:\n contents: read\n id-token: write\n attestations: write\n env:\n ABSOLUTE_IOS_CERTIFICATE_BASE64: \\${{ secrets.ABSOLUTE_IOS_CERTIFICATE_BASE64 }}\n ABSOLUTE_IOS_CERTIFICATE_PASSWORD: \\${{ secrets.ABSOLUTE_IOS_CERTIFICATE_PASSWORD }}\n ABSOLUTE_IOS_PROVISIONING_PROFILE_BASE64: \\${{ secrets.ABSOLUTE_IOS_PROVISIONING_PROFILE_BASE64 }}\n ABSOLUTE_IOS_KEYCHAIN_PASSWORD: \\${{ secrets.ABSOLUTE_IOS_KEYCHAIN_PASSWORD }}${publishEnvironment}${custom ? `\\n${custom}` : ''}\n ABSOLUTE_IOS_DEVELOPMENT_TEAM: \\${{ secrets.ABSOLUTE_IOS_DEVELOPMENT_TEAM }}\n${commandEnvironment({ configPath: undefined, registryModule: '', serverEntry: '' })}\n steps:\n${installSteps}\n - name: Provision iOS signing\n shell: bash\n run: |\n required=(\n ABSOLUTE_IOS_CERTIFICATE_BASE64\n ABSOLUTE_IOS_CERTIFICATE_PASSWORD\n ABSOLUTE_IOS_PROVISIONING_PROFILE_BASE64\n ABSOLUTE_IOS_KEYCHAIN_PASSWORD\n ABSOLUTE_IOS_DEVELOPMENT_TEAM\n )${appStoreSetup}\n for name in \"\\${required[@]}\"; do\n if [[ -z \"\\${!name}\" ]]; then\n echo \"$name is required in the absolute-mobile-release environment.\" >&2\n exit 1\n fi\n done\n CERTIFICATE_PATH=\"\\${{ runner.temp }}/absolute-signing.p12\"\n PROFILE_PATH=\"\\${{ runner.temp }}/absolute.mobileprovision\"\n KEYCHAIN_PATH=\"\\${{ runner.temp }}/absolute-signing.keychain-db\"\n PROFILE_DESTINATION=\"$HOME/Library/MobileDevice/Provisioning Profiles/absolute.mobileprovision\"\n printf '%s' \"$ABSOLUTE_IOS_CERTIFICATE_BASE64\" | base64 --decode > \"$CERTIFICATE_PATH\"\n printf '%s' \"$ABSOLUTE_IOS_PROVISIONING_PROFILE_BASE64\" | base64 --decode > \"$PROFILE_PATH\"\n security create-keychain -p \"$ABSOLUTE_IOS_KEYCHAIN_PASSWORD\" \"$KEYCHAIN_PATH\"\n security set-keychain-settings -lut 21600 \"$KEYCHAIN_PATH\"\n security unlock-keychain -p \"$ABSOLUTE_IOS_KEYCHAIN_PASSWORD\" \"$KEYCHAIN_PATH\"\n security import \"$CERTIFICATE_PATH\" -P \"$ABSOLUTE_IOS_CERTIFICATE_PASSWORD\" -A -t cert -f pkcs12 -k \"$KEYCHAIN_PATH\"\n security set-key-partition-list -S apple-tool:,apple: -k \"$ABSOLUTE_IOS_KEYCHAIN_PASSWORD\" \"$KEYCHAIN_PATH\"\n security list-keychain -d user -s \"$KEYCHAIN_PATH\"\n mkdir -p \"$(dirname \"$PROFILE_DESTINATION\")\"\n cp \"$PROFILE_PATH\" \"$PROFILE_DESTINATION\"${appStoreDecode}\n - name: Build or publish iOS\n shell: bash\n run: |\n ${publishCommand}\n ${appendConfigArgument}\n \"\\${args[@]}\"\n${releaseAuditSteps('ios')}\n - name: Attest iOS IPA\n if: inputs.attest\n uses: actions/attest@v4\n with:\n subject-path: .absolutejs/mobile/releases/ios/**/App.ipa\n - name: Upload iOS release\n uses: actions/upload-artifact@v7\n with:\n name: absolute-mobile-ios\n path: .absolutejs/mobile/releases/ios/\n if-no-files-found: error\n retention-days: 14\n include-hidden-files: true\n - name: Remove iOS credentials\n if: always()\n shell: bash\n run: |\n security delete-keychain \"\\${{ runner.temp }}/absolute-signing.keychain-db\" 2>/dev/null || true\n rm -f \"$HOME/Library/MobileDevice/Provisioning Profiles/absolute.mobileprovision\"\n rm -f \"\\${{ runner.temp }}/absolute-signing.p12\"\n rm -f \"\\${{ runner.temp }}/absolute.mobileprovision\"\n rm -f \"\\${{ runner.temp }}/AuthKey_AbsoluteJS.p8\"`;\n};\n\nconst requiredSecrets = (\n\tplatforms: readonly string[],\n\tincludePublishing: boolean,\n\tcustom: readonly string[]\n) => [\n\t...(platforms.includes('android')\n\t\t? [\n\t\t\t\t'ABSOLUTE_ANDROID_KEYSTORE_BASE64',\n\t\t\t\t'ABSOLUTE_ANDROID_KEYSTORE_PASSWORD',\n\t\t\t\t'ABSOLUTE_ANDROID_KEY_ALIAS',\n\t\t\t\t'ABSOLUTE_ANDROID_KEY_PASSWORD',\n\t\t\t\t...(includePublishing\n\t\t\t\t\t? ['ABSOLUTE_GOOGLE_CREDENTIALS_BASE64']\n\t\t\t\t\t: [])\n\t\t\t]\n\t\t: []),\n\t...(platforms.includes('ios')\n\t\t? [\n\t\t\t\t'ABSOLUTE_IOS_CERTIFICATE_BASE64',\n\t\t\t\t'ABSOLUTE_IOS_CERTIFICATE_PASSWORD',\n\t\t\t\t'ABSOLUTE_IOS_PROVISIONING_PROFILE_BASE64',\n\t\t\t\t'ABSOLUTE_IOS_KEYCHAIN_PASSWORD',\n\t\t\t\t'ABSOLUTE_IOS_DEVELOPMENT_TEAM',\n\t\t\t\t...(includePublishing\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t'APP_STORE_CONNECT_ISSUER_ID',\n\t\t\t\t\t\t\t'APP_STORE_CONNECT_KEY_ID',\n\t\t\t\t\t\t\t'APP_STORE_CONNECT_PRIVATE_KEY_BASE64'\n\t\t\t\t\t\t]\n\t\t\t\t\t: [])\n\t\t\t]\n\t\t: []),\n\t...custom\n];\n\nexport const createAbsoluteMobileGithubWorkflow = (\n\toptions: AbsoluteMobileGithubWorkflowOptions\n) => {\n\tconst platforms: ('android' | 'ios')[] = [\n\t\t...options.config.platforms\n\t].sort();\n\tconst includePublishing = options.includePublishing === true;\n\tconst customSecrets = normalizeSecretEnvironment(options.secretEnvironment);\n\tconst serverEntry = projectPath(\n\t\toptions.projectRoot,\n\t\toptions.serverEntry ?? 'server.ts',\n\t\t'mobile ci github server entry'\n\t);\n\tconst configPath = options.configPath\n\t\t? projectPath(\n\t\t\t\toptions.projectRoot,\n\t\t\t\toptions.configPath,\n\t\t\t\t'mobile ci github --config'\n\t\t\t)\n\t\t: undefined;\n\tconst registryModule = projectPath(\n\t\toptions.projectRoot,\n\t\toptions.registryModule ?? 'mobile.release.ts',\n\t\t'mobile ci github --registry',\n\t\t{ allowMissing: !includePublishing }\n\t);\n\tconst environment = commandEnvironment({\n\t\tconfigPath,\n\t\tregistryModule,\n\t\tserverEntry\n\t});\n\tlet workflow = `# Generated by AbsoluteJS. Regenerate with: absolute mobile ci github${includePublishing ? ' --publish' : ''}\nname: AbsoluteJS Mobile\n\non:\n pull_request:\n workflow_dispatch:\n inputs:\n${platformInput(platforms)}\n attest:\n description: Generate GitHub artifact provenance attestations\n required: true\n type: boolean\n default: false${publishingInputs(platforms, includePublishing)}\n\nconcurrency:\n group: absolute-mobile-\\${{ github.repository }}\n cancel-in-progress: false\n\njobs:\n validate:\n name: Validate mobile release inputs\n runs-on: ubuntu-latest\n permissions:\n contents: read\n env:\n${environment}\n steps:\n${installSteps}\n${bundleAuditSteps}${platforms.includes('android') ? androidJob({ customSecrets, includePublishing }) : ''}${platforms.includes('ios') ? iosJob({ customSecrets, includePublishing }) : ''}\n`;\n\tconst replacements = new Map([\n\t\t[\n\t\t\t\"ABSOLUTE_CONFIG_PATH: ''\",\n\t\t\t`ABSOLUTE_CONFIG_PATH: ${yamlString(configPath ?? '')}`\n\t\t],\n\t\t[\n\t\t\t\"ABSOLUTE_REGISTRY_MODULE: ''\",\n\t\t\t`ABSOLUTE_REGISTRY_MODULE: ${yamlString(registryModule)}`\n\t\t],\n\t\t[\n\t\t\t\"ABSOLUTE_SERVER_ENTRY: ''\",\n\t\t\t`ABSOLUTE_SERVER_ENTRY: ${yamlString(serverEntry)}`\n\t\t]\n\t]);\n\tfor (const [placeholder, replacement] of replacements)\n\t\tworkflow = workflow.replaceAll(placeholder, replacement);\n\n\treturn {\n\t\trequiredSecrets: requiredSecrets(\n\t\t\tplatforms,\n\t\t\tincludePublishing,\n\t\t\tcustomSecrets\n\t\t),\n\t\tworkflow\n\t};\n};\n\nexport const writeAbsoluteMobileGithubWorkflow = async (\n\toptions: AbsoluteMobileGithubWorkflowOptions\n): Promise<AbsoluteMobileGithubWorkflowResult> => {\n\tconst path = workflowOutputPath(options.projectRoot, options.outputPath);\n\tconst generated = createAbsoluteMobileGithubWorkflow(options);\n\tconst previous = (await exists(path))\n\t\t? await readFile(path, 'utf8')\n\t\t: undefined;\n\tif (\n\t\tprevious !== undefined &&\n\t\tprevious !== generated.workflow &&\n\t\t!options.force\n\t)\n\t\tthrow new TypeError(\n\t\t\t`${relative(options.projectRoot, path)} already exists and differs. Rerun with --force to replace the generated workflow.`\n\t\t);\n\tif (previous !== generated.workflow) {\n\t\tawait mkdir(dirname(path), { recursive: true });\n\t\tawait writeFile(path, generated.workflow);\n\t}\n\n\treturn {\n\t\tchanged: previous !== generated.workflow,\n\t\tformat: ABSOLUTE_MOBILE_CI_WORKFLOW_FORMAT,\n\t\tpath,\n\t\tplatforms:\n\t\t\toptions.config.engine === 'expo'\n\t\t\t\t? options.config.platforms.filter(\n\t\t\t\t\t\t(platform): platform is 'android' =>\n\t\t\t\t\t\t\tplatform === 'android'\n\t\t\t\t\t)\n\t\t\t\t: [...options.config.platforms].sort(),\n\t\tpublishing: options.includePublishing === true,\n\t\trequiredSecrets: generated.requiredSecrets\n\t};\n};\n",
|
|
50
|
+
"import { Elysia } from 'elysia';\nimport {\n\tcreateAbsoluteMobileInvalidRequestResponse,\n\tcreateAbsoluteMobilePageErrorResponse,\n\tcreateAbsoluteMobileUpgradeResponse,\n\tMOBILE_PAGE_REQUEST_HEADERS,\n\tparseAbsoluteMobilePageRequest\n} from './pageProtocol';\nimport {\n\tresolveAbsoluteMobileCompatibilityRelease,\n\tretainAbsoluteMobileCompatibilityArtifacts,\n\ttype AbsoluteMobileCompatibilityArtifact\n} from './releaseArtifact';\nimport {\n\tgetCurrentAbsoluteMobileProducerContext,\n\trunWithAbsoluteMobileProducer\n} from './producerContext';\nimport { matchesAbsoluteMobileRoutePattern } from './routeMatcher';\n\nexport type AbsoluteMobileCompatibilityProducerHandler = {\n\thandle: (request: Request) => Promise<Response> | Response;\n};\n\nexport type AbsoluteMobileCompatibilityProducerLoader = (\n\tartifact: AbsoluteMobileCompatibilityArtifact\n) => Promise<AbsoluteMobileCompatibilityProducerHandler>;\n\nexport type AbsoluteMobileCompatibilityDispatcherOptions = {\n\tartifacts: readonly AbsoluteMobileCompatibilityArtifact[];\n\tcurrentReleaseId: string;\n\tloadProducer: AbsoluteMobileCompatibilityProducerLoader;\n};\n\nconst MOBILE_WEBVIEW_ORIGINS = new Set([\n\t'capacitor://localhost',\n\t'http://localhost',\n\t'https://localhost'\n]);\nconst MOBILE_REQUEST_HEADER_NAMES = Object.values(MOBILE_PAGE_REQUEST_HEADERS);\nconst MOBILE_CORS_ALLOW_HEADERS = [\n\t'accept',\n\t'content-type',\n\t'authorization',\n\t'hx-current-url',\n\t'hx-request',\n\t'hx-target',\n\t'hx-trigger',\n\t'hx-trigger-name',\n\t...MOBILE_REQUEST_HEADER_NAMES\n].join(', ');\nconst MOBILE_CORS_METHODS = new Set([\n\t'DELETE',\n\t'GET',\n\t'HEAD',\n\t'OPTIONS',\n\t'PATCH',\n\t'POST',\n\t'PUT'\n]);\n\nconst mobileWebViewOrigin = (request: Request) => {\n\tconst origin = request.headers.get('origin');\n\n\treturn origin && MOBILE_WEBVIEW_ORIGINS.has(origin) ? origin : undefined;\n};\n\nconst applyMobileCorsHeaders = (response: Response, origin: string) => {\n\tresponse.headers.set('access-control-allow-credentials', 'true');\n\tresponse.headers.set('access-control-allow-origin', origin);\n\tresponse.headers.append('vary', 'Origin');\n\n\treturn response;\n};\n\nconst finalizeMobileResponse = (request: Request, response: Response) => {\n\tconst origin = mobileWebViewOrigin(request);\n\n\treturn origin ? applyMobileCorsHeaders(response, origin) : response;\n};\n\nconst mobilePreflightResponse = (request: Request) => {\n\tif (request.method !== 'OPTIONS') return undefined;\n\tconst origin = mobileWebViewOrigin(request);\n\tif (!origin) return undefined;\n\tconst requestedHeaders = request.headers.get(\n\t\t'access-control-request-headers'\n\t);\n\tconst requestedMethod =\n\t\trequest.headers.get('access-control-request-method')?.toUpperCase() ??\n\t\t'';\n\tif (!MOBILE_CORS_METHODS.has(requestedMethod)) return undefined;\n\n\treturn new Response(null, {\n\t\theaders: {\n\t\t\t'access-control-allow-credentials': 'true',\n\t\t\t'access-control-allow-headers':\n\t\t\t\trequestedHeaders || MOBILE_CORS_ALLOW_HEADERS,\n\t\t\t'access-control-allow-methods': [...MOBILE_CORS_METHODS].join(', '),\n\t\t\t'access-control-allow-origin': origin,\n\t\t\t'access-control-max-age': '600',\n\t\t\tvary: 'Origin, Access-Control-Request-Headers'\n\t\t},\n\t\tstatus: 204\n\t});\n};\n\nconst artifactOwnsRequest = (\n\tartifact: AbsoluteMobileCompatibilityArtifact,\n\tpageId: string,\n\trequest: Request\n) => {\n\tconst { pathname } = new URL(request.url);\n\n\treturn artifact.routes.some(\n\t\t(route) =>\n\t\t\troute.pageId === pageId &&\n\t\t\troute.method === request.method &&\n\t\t\tmatchesAbsoluteMobileRoutePattern(route.pattern, pathname)\n\t);\n};\n\nconst createProducerResolver = (\n\tloadProducer: AbsoluteMobileCompatibilityProducerLoader\n) => {\n\tconst producers = new Map<\n\t\tstring,\n\t\tPromise<AbsoluteMobileCompatibilityProducerHandler>\n\t>();\n\n\treturn (artifact: AbsoluteMobileCompatibilityArtifact) => {\n\t\tconst cached = producers.get(artifact.releaseId);\n\t\tif (cached) return cached;\n\n\t\tconst loading = loadProducer(artifact).catch((error: unknown) => {\n\t\t\tproducers.delete(artifact.releaseId);\n\n\t\t\tthrow error;\n\t\t});\n\t\tproducers.set(artifact.releaseId, loading);\n\n\t\treturn loading;\n\t};\n};\n\nexport const createAbsoluteMobileCompatibilityDispatcher = (\n\toptions: AbsoluteMobileCompatibilityDispatcherOptions\n) => {\n\tconst artifacts = retainAbsoluteMobileCompatibilityArtifacts(\n\t\toptions.artifacts\n\t);\n\tif (\n\t\t!artifacts.some(\n\t\t\t({ releaseId }) => releaseId === options.currentReleaseId\n\t\t)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t'currentReleaseId must identify a retained compatibility artifact.'\n\t\t);\n\t}\n\tconst resolveProducer = createProducerResolver(options.loadProducer);\n\n\treturn new Elysia({ name: 'absolutejs-mobile-compatibility-dispatcher' })\n\t\t.request(async ({ request }) => {\n\t\t\tif (getCurrentAbsoluteMobileProducerContext()) return undefined;\n\t\t\tconst preflight = mobilePreflightResponse(request);\n\t\t\tif (preflight) return preflight;\n\t\t\tconst parsed = parseAbsoluteMobilePageRequest(request);\n\t\t\tif (parsed.kind !== 'mobile') return undefined;\n\n\t\t\tconst resolved = resolveAbsoluteMobileCompatibilityRelease(\n\t\t\t\tparsed.client,\n\t\t\t\tartifacts\n\t\t\t);\n\t\t\tif (resolved.kind === 'upgrade-required') {\n\t\t\t\treturn finalizeMobileResponse(\n\t\t\t\t\trequest,\n\t\t\t\t\tcreateAbsoluteMobileUpgradeResponse(resolved.result)\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (\n\t\t\t\t!artifactOwnsRequest(\n\t\t\t\t\tresolved.artifact,\n\t\t\t\t\tparsed.client.pageId,\n\t\t\t\t\trequest\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn finalizeMobileResponse(\n\t\t\t\t\trequest,\n\t\t\t\t\tcreateAbsoluteMobileInvalidRequestResponse(\n\t\t\t\t\t\t'The requested URL is not assigned to this mobile page.'\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (resolved.artifact.releaseId === options.currentReleaseId) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tconst producer = await resolveProducer(resolved.artifact);\n\n\t\t\t\tconst response = await runWithAbsoluteMobileProducer(\n\t\t\t\t\t{\n\t\t\t\t\t\tpage: resolved.page,\n\t\t\t\t\t\treleaseId: resolved.artifact.releaseId\n\t\t\t\t\t},\n\t\t\t\t\t() => producer.handle(request)\n\t\t\t\t);\n\n\t\t\t\treturn finalizeMobileResponse(request, response);\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`[Mobile] Failed to load retained producer ${resolved.artifact.releaseId}:`,\n\t\t\t\t\terror\n\t\t\t\t);\n\n\t\t\t\treturn finalizeMobileResponse(\n\t\t\t\t\trequest,\n\t\t\t\t\tcreateAbsoluteMobilePageErrorResponse(parsed.client.pageId)\n\t\t\t\t);\n\t\t\t}\n\t\t})\n\t\t.afterHandle('global', ({ request, responseValue }) => {\n\t\t\tconst origin = mobileWebViewOrigin(request);\n\t\t\tif (!origin || !(responseValue instanceof Response)) return;\n\n\t\t\tapplyMobileCorsHeaders(responseValue, origin);\n\t\t})\n\t\t.as('global');\n};\n",
|
|
36
51
|
"import { AsyncLocalStorage } from 'node:async_hooks';\nimport {\n\tABSOLUTE_MOBILE_PRODUCER_STORAGE_KEY,\n\ttype AbsoluteMobileProducerContext\n} from './producerContextState';\n\nexport type { AbsoluteMobileProducerContext } from './producerContextState';\nexport { getCurrentAbsoluteMobileProducerContext } from './producerContextState';\n\ntype AbsoluteMobileProducerStorage =\n\tAsyncLocalStorage<AbsoluteMobileProducerContext>;\n\nconst isProducerStorage = (\n\tvalue: unknown\n): value is AbsoluteMobileProducerStorage =>\n\ttypeof value === 'object' &&\n\tvalue !== null &&\n\t'getStore' in value &&\n\ttypeof value.getStore === 'function' &&\n\t'run' in value &&\n\ttypeof value.run === 'function';\n\nconst getProducerStorage = () => {\n\tconst value = Reflect.get(globalThis, ABSOLUTE_MOBILE_PRODUCER_STORAGE_KEY);\n\n\treturn isProducerStorage(value) ? value : undefined;\n};\n\nconst ensureProducerStorage = () => {\n\tconst existing = getProducerStorage();\n\tif (existing) return existing;\n\n\tconst storage = new AsyncLocalStorage<AbsoluteMobileProducerContext>();\n\tReflect.set(globalThis, ABSOLUTE_MOBILE_PRODUCER_STORAGE_KEY, storage);\n\n\treturn storage;\n};\n\nexport const runWithAbsoluteMobileProducer = <Result>(\n\tcontext: AbsoluteMobileProducerContext,\n\tcallback: () => Result\n) => ensureProducerStorage().run(context, callback);\n",
|
|
52
|
+
"import { Elysia } from 'elysia';\nimport type { MobileConfig } from '../../types/build';\nimport { sendTelemetryEvent } from '../cli/telemetryEvent';\n\nexport const ABSOLUTE_MOBILE_PREVIEW_PATH =\n\t'/__absolute/mobile-preview' as const;\n\nconst escapeHtml = (value: string) =>\n\tvalue\n\t\t.replaceAll('&', '&')\n\t\t.replaceAll('<', '<')\n\t\t.replaceAll('>', '>')\n\t\t.replaceAll('\"', '"');\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n\ttypeof value === 'object' && value !== null;\n\nconst normalizeEntry = (entry: string | undefined) => {\n\tconst parsed = new URL(entry ?? '/', 'https://absolute.invalid');\n\n\treturn `${parsed.pathname}${parsed.search}${parsed.hash}`;\n};\n\nexport const absoluteMobilePreviewDocument = (mobile: MobileConfig) => {\n\tconst entry = normalizeEntry(mobile.entry);\n\tconst appName = mobile.appName?.trim() || 'AbsoluteJS App';\n\tconst boot = JSON.stringify({ appName, entry }).replaceAll('<', '\\\\u003c');\n\n\treturn `<!doctype html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n<meta name=\"color-scheme\" content=\"dark\">\n<link rel=\"icon\" href=\"data:,\">\n<title>${escapeHtml(appName)} · Mobile Preview</title>\n<style>\n:root{font-family:Inter,ui-sans-serif,system-ui,sans-serif;color:#e8ecf3;background:#080b12;color-scheme:dark}*{box-sizing:border-box}body{margin:0;min-height:100vh;background:radial-gradient(circle at 30% 0,#17213a 0,#080b12 42%)}button,input,select{font:inherit}.shell{display:grid;grid-template-columns:minmax(320px,1fr) 292px;gap:24px;min-height:100vh;padding:24px}.stage{display:grid;place-items:center;min-width:0}.device{position:relative;width:min(100%,430px);height:min(880px,calc(100vh - 48px));min-height:620px;padding:12px;border:1px solid #343c4d;border-radius:48px;background:#111620;box-shadow:0 35px 80px #0009,inset 0 0 0 1px #ffffff0d}.device.android{border-radius:30px}.screen{position:relative;width:100%;height:100%;overflow:hidden;border-radius:37px;background:#fff}.android .screen{border-radius:20px}.island{position:absolute;z-index:2;top:17px;left:50%;width:112px;height:30px;transform:translateX(-50%);border-radius:18px;background:#080b12;pointer-events:none}.android .island{width:9px;height:9px;top:10px}.app{width:100%;height:100%;border:0;background:#fff}.panel{align-self:start;position:sticky;top:24px;max-height:calc(100vh - 48px);overflow:auto;padding:18px;border:1px solid #262d3a;border-radius:20px;background:#0e131dcc;box-shadow:0 18px 50px #0005;backdrop-filter:blur(18px)}h1{font-size:18px;margin:0}.sub{margin:5px 0 18px;color:#8f9aae;font-size:12px}.status{display:flex;align-items:center;gap:8px;margin-bottom:18px;padding:9px 11px;border-radius:10px;background:#151c28;color:#aeb8ca;font-size:12px}.dot{width:8px;height:8px;border-radius:50%;background:#eab308}.ready .dot{background:#22c55e}.group{padding:14px 0;border-top:1px solid #252c39}.group:first-of-type{border-top:0}.label{display:block;margin-bottom:8px;color:#97a3b7;font-size:11px;font-weight:700;letter-spacing:.08em;text-transform:uppercase}.row{display:flex;gap:8px}.row>*{min-width:0}.grow{flex:1}button,select,input{border:1px solid #30394a;border-radius:9px;background:#171e2b;color:#e8ecf3;padding:9px 10px}button{cursor:pointer}button:hover{border-color:#64748b;background:#202a3a}button.active{border-color:#60a5fa;background:#172b48;color:#bfdbfe}input{width:100%}.events{height:84px;overflow:auto;margin-top:8px;padding:8px;border-radius:9px;background:#090d14;color:#8290a7;font:11px/1.5 ui-monospace,monospace}.hint{margin-top:12px;color:#64748b;font-size:11px;line-height:1.45}@media(max-width:840px){.shell{grid-template-columns:1fr;padding:12px}.device{height:720px}.panel{position:static;max-height:none}}\n</style>\n</head>\n<body>\n<main class=\"shell\">\n<section class=\"stage\"><div class=\"device\" id=\"device\"><div class=\"island\"></div><div class=\"screen\"><iframe class=\"app\" id=\"app\" title=\"${escapeHtml(appName)} mobile runtime\"></iframe></div></div></section>\n<aside class=\"panel\">\n<h1>${escapeHtml(appName)}</h1><p class=\"sub\">AbsoluteJS mobile runtime preview</p>\n<div class=\"status\" id=\"status\"><span class=\"dot\"></span><span id=\"statusText\">Starting runtime…</span></div>\n<div class=\"group\"><span class=\"label\">Device</span><div class=\"row\"><button id=\"ios\" class=\"grow active\">iOS</button><button id=\"android\" class=\"grow\">Android</button></div></div>\n<div class=\"group\"><label class=\"label\" for=\"route\">Route / deep link</label><div class=\"row\"><input id=\"route\" value=\"${escapeHtml(entry)}\"><button id=\"go\">Go</button></div><div class=\"row\" style=\"margin-top:8px\"><button id=\"deepLink\" class=\"grow\">Emit deep link</button><button id=\"back\" class=\"grow\">Hardware back</button></div></div>\n<div class=\"group\"><span class=\"label\">Connection</span><div class=\"row\"><button id=\"online\" class=\"grow active\">Wi-Fi</button><button id=\"cellular\" class=\"grow\">Cellular</button><button id=\"offline\" class=\"grow\">Offline</button></div></div>\n<div class=\"group\"><span class=\"label\">Lifecycle</span><div class=\"row\"><button id=\"active\" class=\"grow active\">Active</button><button id=\"background\" class=\"grow\">Background</button><button id=\"inactive\" class=\"grow\">Inactive</button></div></div>\n<div class=\"group\"><span class=\"label\">Keyboard</span><div class=\"row\"><button id=\"keyboardShow\" class=\"grow\">Show</button><button id=\"keyboardHide\" class=\"grow\">Hide</button></div></div>\n<div class=\"group\"><label class=\"label\" for=\"permission\">Permissions</label><div class=\"row\"><select id=\"permission\" class=\"grow\"><option value=\"camera\">Camera</option><option value=\"location\">Location</option><option value=\"notifications\">Notifications</option></select><select id=\"permissionState\" class=\"grow\"><option value=\"prompt\">Prompt</option><option value=\"granted\">Granted</option><option value=\"denied\">Denied</option><option value=\"blocked\">Blocked</option></select></div><button id=\"applyPermission\" style=\"width:100%;margin-top:8px\">Apply permission state</button></div>\n<div class=\"group\"><span class=\"label\">Runtime events</span><div class=\"events\" id=\"events\" aria-live=\"polite\"></div><p class=\"hint\">This runs the same development pages, HMR client, provider-neutral HTTP, and Devices contracts as an installed target. Native rendering, signing, push delivery, and OS scheduling still require a simulator or physical device.</p></div>\n</aside>\n</main>\n<script>const config=${boot};const frame=document.getElementById('app');const device=document.getElementById('device');const status=document.getElementById('status');const statusText=document.getElementById('statusText');const events=document.getElementById('events');let platform='ios';const event=(text)=>{const line=document.createElement('div');line.textContent=new Date().toLocaleTimeString()+' · '+text;events.prepend(line)};const routeUrl=()=>{const value=document.getElementById('route').value.trim()||config.entry;const url=new URL(value,location.origin);if(url.origin!==location.origin)throw new TypeError('Preview routes must stay on this dev server.');url.searchParams.set('__absolute_target','mobile-preview');url.searchParams.set('__absolute_preview_platform',platform);return url};const load=()=>{try{status.classList.remove('ready');statusText.textContent='Starting runtime…';frame.src=routeUrl().href;event('loaded '+routeUrl().pathname)}catch(error){statusText.textContent=error.message}};const send=(message)=>{if(!frame.contentWindow)return;frame.contentWindow.postMessage(message,location.origin);event(message.type.replace('absolute-preview:',''))};const select=(ids,active)=>ids.forEach(id=>document.getElementById(id).classList.toggle('active',id===active));document.getElementById('ios').onclick=()=>{platform='ios';device.classList.remove('android');select(['ios','android'],'ios');load()};document.getElementById('android').onclick=()=>{platform='android';device.classList.add('android');select(['ios','android'],'android');load()};document.getElementById('go').onclick=load;document.getElementById('route').onkeydown=e=>{if(e.key==='Enter')load()};document.getElementById('deepLink').onclick=()=>send({type:'absolute-preview:deep-link',url:new URL(document.getElementById('route').value,location.origin).href});document.getElementById('back').onclick=()=>send({type:'absolute-preview:back'});[['online',true,'wifi'],['cellular',true,'cellular'],['offline',false,'none']].forEach(([id,connected,connectionType])=>document.getElementById(id).onclick=()=>{select(['online','cellular','offline'],id);send({type:'absolute-preview:network',connected,connectionType})});['active','background','inactive'].forEach(id=>document.getElementById(id).onclick=()=>{select(['active','background','inactive'],id);send({type:'absolute-preview:lifecycle',state:id})});document.getElementById('keyboardShow').onclick=()=>send({type:'absolute-preview:keyboard',visible:true,heightPx:320});document.getElementById('keyboardHide').onclick=()=>send({type:'absolute-preview:keyboard',visible:false,heightPx:0});document.getElementById('applyPermission').onclick=()=>send({type:'absolute-preview:permission',capability:document.getElementById('permission').value,state:document.getElementById('permissionState').value});addEventListener('message',e=>{if(e.origin!==location.origin||e.source!==frame.contentWindow||!e.data||typeof e.data.type!=='string'||!e.data.type.startsWith('absolute-preview:'))return;if(e.data.type==='absolute-preview:ready'){status.classList.add('ready');statusText.textContent=platform==='ios'?'iOS runtime connected':'Android runtime connected'}event(e.data.event||e.data.type.replace('absolute-preview:',''))});load();</script>\n</body>\n</html>`;\n};\n\nexport const createAbsoluteMobilePreviewPlugin = (\n\tmobile: MobileConfig | undefined\n) => {\n\tif (!mobile)\n\t\treturn new Elysia({ name: 'absolutejs-mobile-preview-disabled' });\n\n\treturn new Elysia({ name: 'absolutejs-mobile-preview' })\n\t\t.get(\n\t\t\tABSOLUTE_MOBILE_PREVIEW_PATH,\n\t\t\t() =>\n\t\t\t\tnew Response(absoluteMobilePreviewDocument(mobile), {\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t'Cache-Control': 'no-store',\n\t\t\t\t\t\t'Content-Security-Policy':\n\t\t\t\t\t\t\t\"default-src 'self'; script-src 'unsafe-inline' 'self'; style-src 'unsafe-inline'; frame-src 'self'; img-src 'self' data: blob:; connect-src 'self' ws: wss:\",\n\t\t\t\t\t\t'Content-Type': 'text/html; charset=utf-8',\n\t\t\t\t\t\t'X-Robots-Tag': 'noindex, nofollow'\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t)\n\t\t.post('/__absolute/mobile-preview-telemetry', ({ body, status }) => {\n\t\t\tconst value = isRecord(body) ? body : undefined;\n\t\t\tconst durationMs = value?.durationMs;\n\t\t\tconst platform = value?.platform;\n\t\t\tif (\n\t\t\t\ttypeof durationMs !== 'number' ||\n\t\t\t\t!Number.isFinite(durationMs) ||\n\t\t\t\tdurationMs < 0 ||\n\t\t\t\tdurationMs > 300_000 ||\n\t\t\t\t(platform !== 'android' && platform !== 'ios')\n\t\t\t) {\n\t\t\t\treturn status(400, { error: 'invalid-preview-telemetry' });\n\t\t\t}\n\t\t\tsendTelemetryEvent('mobile:preview-ready', {\n\t\t\t\tdurationMs: Math.round(durationMs),\n\t\t\t\tplatform,\n\t\t\t\tprovider: 'capacitor',\n\t\t\t\ttarget: 'mobile-preview'\n\t\t\t});\n\n\t\t\treturn status(204);\n\t\t});\n};\n",
|
|
37
53
|
"import { readFile, rename, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport type { MobilePlatform } from '../../types/build';\nimport type { NormalizedAbsoluteMobileConfig } from './config';\n\nconst START_MARKER = '<!-- absolutejs:deep-links:start -->';\nconst END_MARKER = '<!-- absolutejs:deep-links:end -->';\nconst IOS_ENTITLEMENTS = 'App/AbsoluteJS.entitlements';\nconst NOT_FOUND = -1;\n\nconst escapeXml = (value: string) =>\n\tvalue\n\t\t.replaceAll('&', '&')\n\t\t.replaceAll('\"', '"')\n\t\t.replaceAll(\"'\", ''')\n\t\t.replaceAll('<', '<')\n\t\t.replaceAll('>', '>');\n\nconst writeChangedFile = async (path: string, source: string) => {\n\tconst current = await readFile(path, 'utf8');\n\tif (current === source) return false;\n\tconst temporary = `${path}.${crypto.randomUUID()}.tmp`;\n\tawait writeFile(temporary, source, { flag: 'wx' });\n\tawait rename(temporary, path);\n\n\treturn true;\n};\n\nconst replaceManagedRegion = (\n\tsource: string,\n\tregion: string,\n\tinsertAt: () => number\n) => {\n\tconst start = source.indexOf(START_MARKER);\n\tconst end = source.indexOf(END_MARKER);\n\tif (\n\t\t(start === NOT_FOUND) !== (end === NOT_FOUND) ||\n\t\t(start !== NOT_FOUND && end < start)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t'AbsoluteJS deep-link ownership markers are malformed.'\n\t\t);\n\t}\n\tif (start !== NOT_FOUND) {\n\t\tconst lineStart = source.lastIndexOf('\\n', start) + 1;\n\t\tconst nextLine = source.indexOf('\\n', end + END_MARKER.length);\n\t\tconst lineEnd = nextLine === NOT_FOUND ? source.length : nextLine + 1;\n\n\t\treturn `${source.slice(0, lineStart)}${region}${source.slice(lineEnd)}`;\n\t}\n\tconst index = insertAt();\n\tif (index === NOT_FOUND) {\n\t\tthrow new TypeError(\n\t\t\t'Could not find a safe native project location for deep-link configuration.'\n\t\t);\n\t}\n\n\treturn `${source.slice(0, index)}${region}${source.slice(index)}`;\n};\n\nconst androidRegion = (config: NormalizedAbsoluteMobileConfig) => {\n\tconst hosts = config.deepLinkHosts\n\t\t.map(\n\t\t\t(host) =>\n\t\t\t\t` <data android:scheme=\"https\" android:host=\"${escapeXml(host)}\" />`\n\t\t)\n\t\t.join('\\n');\n\tconst customScheme = config.deepLinkScheme\n\t\t? `\\n\\n <intent-filter>\\n <action android:name=\"android.intent.action.VIEW\" />\\n <category android:name=\"android.intent.category.DEFAULT\" />\\n <category android:name=\"android.intent.category.BROWSABLE\" />\\n <data android:scheme=\"${escapeXml(config.deepLinkScheme)}\" />\\n </intent-filter>`\n\t\t: '';\n\n\treturn ` ${START_MARKER}\\n <intent-filter android:autoVerify=\"true\">\\n <action android:name=\"android.intent.action.VIEW\" />\\n <category android:name=\"android.intent.category.DEFAULT\" />\\n <category android:name=\"android.intent.category.BROWSABLE\" />\\n${hosts}\\n </intent-filter>${customScheme}\\n ${END_MARKER}\\n`;\n};\n\nconst configureAndroid = async (config: NormalizedAbsoluteMobileConfig) => {\n\tconst path = join(\n\t\tconfig.nativeProjectDirectory,\n\t\t'android/app/src/main/AndroidManifest.xml'\n\t);\n\tconst source = await readFile(path, 'utf8');\n\tconst mainActivity = source.indexOf('android:name=\".MainActivity\"');\n\tif (mainActivity === NOT_FOUND) {\n\t\tthrow new TypeError('Android MainActivity was not found.');\n\t}\n\tconst activityEnd = source.indexOf('</activity>', mainActivity);\n\tconst updated = replaceManagedRegion(source, androidRegion(config), () =>\n\t\tactivityEnd === NOT_FOUND\n\t\t\t? NOT_FOUND\n\t\t\t: source.lastIndexOf('\\n', activityEnd) + 1\n\t);\n\n\treturn writeChangedFile(path, updated);\n};\n\nconst iosSchemeRegion = (scheme: string) =>\n\t`\\t${START_MARKER}\\n\\t<key>CFBundleURLTypes</key>\\n\\t<array>\\n\\t\\t<dict>\\n\\t\\t\\t<key>CFBundleURLName</key>\\n\\t\\t\\t<string>absolutejs</string>\\n\\t\\t\\t<key>CFBundleURLSchemes</key>\\n\\t\\t\\t<array>\\n\\t\\t\\t\\t<string>${escapeXml(scheme)}</string>\\n\\t\\t\\t</array>\\n\\t\\t</dict>\\n\\t</array>\\n\\t${END_MARKER}\\n`;\n\nconst configureIosInfo = async (config: NormalizedAbsoluteMobileConfig) => {\n\tconst path = join(config.nativeProjectDirectory, 'ios/App/App/Info.plist');\n\tconst source = await readFile(path, 'utf8');\n\tconst region = config.deepLinkScheme\n\t\t? iosSchemeRegion(config.deepLinkScheme)\n\t\t: `\\t${START_MARKER}\\n\\t${END_MARKER}\\n`;\n\tconst updated = replaceManagedRegion(source, region, () =>\n\t\tsource.lastIndexOf('</dict>')\n\t);\n\n\treturn writeChangedFile(path, updated);\n};\n\nconst iosEntitlementsSource = (config: NormalizedAbsoluteMobileConfig) => {\n\tconst domains = config.deepLinkHosts\n\t\t.map((host) => `\\t\\t<string>applinks:${escapeXml(host)}</string>`)\n\t\t.join('\\n');\n\n\treturn `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\\t<key>com.apple.developer.associated-domains</key>\n\\t<array>\n${domains}\n\\t</array>\n</dict>\n</plist>\n`;\n};\n\nconst configureIosEntitlements = async (\n\tconfig: NormalizedAbsoluteMobileConfig\n) => {\n\tconst path = join(\n\t\tconfig.nativeProjectDirectory,\n\t\t'ios/App/AbsoluteJS.entitlements'\n\t);\n\tlet current = '';\n\ttry {\n\t\tcurrent = await readFile(path, 'utf8');\n\t} catch (error) {\n\t\tif (\n\t\t\t!(error instanceof Error) ||\n\t\t\t!('code' in error) ||\n\t\t\terror.code !== 'ENOENT'\n\t\t) {\n\t\t\tthrow error;\n\t\t}\n\t}\n\tconst source = iosEntitlementsSource(config);\n\tif (current === source) return false;\n\tconst temporary = `${path}.${crypto.randomUUID()}.tmp`;\n\tawait writeFile(temporary, source, { flag: 'wx' });\n\tawait rename(temporary, path);\n\n\treturn true;\n};\n\nconst configureIosProject = async (config: NormalizedAbsoluteMobileConfig) => {\n\tconst path = join(\n\t\tconfig.nativeProjectDirectory,\n\t\t'ios/App/App.xcodeproj/project.pbxproj'\n\t);\n\tconst source = await readFile(path, 'utf8');\n\tconst declarations = [\n\t\t...source.matchAll(/CODE_SIGN_ENTITLEMENTS = ([^;]+);/g)\n\t].map((match) => match[1]);\n\tif (declarations.some((value) => value !== IOS_ENTITLEMENTS)) {\n\t\tthrow new TypeError(\n\t\t\t'The iOS target already uses a different entitlements file; merge associated domains there before continuing.'\n\t\t);\n\t}\n\tif (declarations.length > 0) return false;\n\tlet count = 0;\n\tconst updated = source.replaceAll(\n\t\t'INFOPLIST_FILE = App/Info.plist;',\n\t\t() => {\n\t\t\tcount += 1;\n\n\t\t\treturn `CODE_SIGN_ENTITLEMENTS = ${IOS_ENTITLEMENTS};\\n\\t\\t\\t\\tINFOPLIST_FILE = App/Info.plist;`;\n\t\t}\n\t);\n\tif (count === 0) {\n\t\tthrow new TypeError(\n\t\t\t'The iOS application target build settings were not found.'\n\t\t);\n\t}\n\n\treturn writeChangedFile(path, updated);\n};\n\nconst configureIos = async (config: NormalizedAbsoluteMobileConfig) => {\n\tconst changed = await Promise.all([\n\t\tconfigureIosInfo(config),\n\t\tconfigureIosEntitlements(config),\n\t\tconfigureIosProject(config)\n\t]);\n\n\treturn changed.some(Boolean);\n};\n\nexport const applyAbsoluteNativeDeepLinks = async (\n\tconfig: NormalizedAbsoluteMobileConfig,\n\tplatforms: readonly MobilePlatform[] = config.platforms\n) => {\n\tconst results = await Promise.all(\n\t\tplatforms.map(async (platform) => {\n\t\t\tconst didChange =\n\t\t\t\tplatform === 'android'\n\t\t\t\t\t? await configureAndroid(config)\n\t\t\t\t\t: await configureIos(config);\n\n\t\t\treturn { didChange, platform };\n\t\t})\n\t);\n\n\treturn {\n\t\tchanged: results\n\t\t\t.filter(({ didChange }) => didChange)\n\t\t\t.map(({ platform }) => platform)\n\t};\n};\n",
|
|
54
|
+
"import { readFile, rename, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport type { MobilePlatform } from '../../types/build';\nimport type { NormalizedAbsoluteMobileConfig } from './config';\nimport {\n\tabsoluteDeviceNativeRequirements,\n\tresolveAbsoluteDeviceCapabilityPlan,\n\ttype AbsoluteDeviceCapabilityPlan,\n\ttype AbsoluteIosUsageDescription\n} from './deviceCapabilities';\n\nconst START_MARKER = '<!-- absolutejs:device-capabilities:start -->';\nconst END_MARKER = '<!-- absolutejs:device-capabilities:end -->';\nconst NOT_FOUND = -1;\nconst IOS_PRIVACY_FILE_REFERENCE = 'A85D0C000000000000000001';\nconst IOS_PRIVACY_BUILD_FILE = 'A85D0C000000000000000002';\nconst PUSH_START_MARKER = 'absolutejs:push-notifications:start';\nconst PUSH_END_MARKER = 'absolutejs:push-notifications:end';\n\nconst escapeXml = (value: string) =>\n\tvalue\n\t\t.replaceAll('&', '&')\n\t\t.replaceAll('\"', '"')\n\t\t.replaceAll(\"'\", ''')\n\t\t.replaceAll('<', '<')\n\t\t.replaceAll('>', '>');\n\nconst writeChangedFile = async (path: string, source: string) => {\n\tconst current = await readFile(path, 'utf8');\n\tif (current === source) return false;\n\tconst temporary = `${path}.${crypto.randomUUID()}.tmp`;\n\tawait writeFile(temporary, source, { flag: 'wx' });\n\tawait rename(temporary, path);\n\n\treturn true;\n};\n\nconst writeOptionalChangedFile = async (path: string, source: string) => {\n\tconst current = await optionalSource(path);\n\tif (current === source) return false;\n\tif (current === null) {\n\t\tawait writeFile(path, source, { flag: 'wx' });\n\n\t\treturn true;\n\t}\n\n\treturn writeChangedFile(path, source);\n};\n\nconst optionalSource = async (path: string) => {\n\ttry {\n\t\treturn await readFile(path, 'utf8');\n\t} catch (error) {\n\t\tif (\n\t\t\ttypeof error === 'object' &&\n\t\t\terror !== null &&\n\t\t\tReflect.get(error, 'code') === 'ENOENT'\n\t\t)\n\t\t\treturn null;\n\t\tthrow error;\n\t}\n};\n\nconst managed = (source: string, region: string, insertion: number) => {\n\tconst start = source.indexOf(START_MARKER);\n\tconst end = source.indexOf(END_MARKER);\n\tif (\n\t\t(start === NOT_FOUND) !== (end === NOT_FOUND) ||\n\t\t(start !== NOT_FOUND && end < start)\n\t)\n\t\tthrow new TypeError(\n\t\t\t'AbsoluteJS device-capability ownership markers are malformed.'\n\t\t);\n\tif (start !== NOT_FOUND) {\n\t\tconst lineStart = source.lastIndexOf('\\n', start) + 1;\n\t\tconst nextLine = source.indexOf('\\n', end + END_MARKER.length);\n\t\tconst lineEnd = nextLine === NOT_FOUND ? source.length : nextLine + 1;\n\n\t\treturn `${source.slice(0, lineStart)}${region}${source.slice(lineEnd)}`;\n\t}\n\tif (region.length === 0) return source;\n\tif (insertion === NOT_FOUND)\n\t\tthrow new TypeError(\n\t\t\t'Could not find a safe native project location for device permissions.'\n\t\t);\n\n\treturn `${source.slice(0, insertion)}${region}${source.slice(insertion)}`;\n};\n\nconst IOS_KEYS: Record<AbsoluteIosUsageDescription, string> = {\n\tcamera: 'NSCameraUsageDescription',\n\t'location-always': 'NSLocationAlwaysAndWhenInUseUsageDescription',\n\t'location-when-in-use': 'NSLocationWhenInUseUsageDescription',\n\t'photo-library': 'NSPhotoLibraryUsageDescription',\n\t'photo-library-add': 'NSPhotoLibraryAddUsageDescription'\n};\n\nconst iosDescription = (\n\tappName: string,\n\tpurpose: AbsoluteIosUsageDescription\n) => {\n\tif (purpose === 'camera')\n\t\treturn `${appName} uses your camera when you choose to take a photo.`;\n\tif (purpose === 'photo-library')\n\t\treturn `${appName} accesses your photo library only for photo actions you choose.`;\n\tif (purpose === 'location-when-in-use')\n\t\treturn `${appName} uses your location only while you are using the app and request a location-based action.`;\n\tif (purpose === 'location-always')\n\t\treturn `${appName} does not track location in the background; this description supports the foreground location provider required by the native runtime.`;\n\n\treturn `${appName} adds to your photo library only for photo actions you choose.`;\n};\n\nconst privacyEntries = (\n\trequirements: ReturnType<typeof absoluteDeviceNativeRequirements>\n) =>\n\trequirements.iosPrivacyAccessedApis\n\t\t.map(\n\t\t\t({ api, reasons }) =>\n\t\t\t\t`\t\t<dict>\\n\t\t\t<key>NSPrivacyAccessedAPIType</key>\\n\t\t\t<string>${escapeXml(api)}</string>\\n\t\t\t<key>NSPrivacyAccessedAPITypeReasons</key>\\n\t\t\t<array>\\n${reasons\n\t\t\t\t\t.map((reason) => `\t\t\t\t<string>${escapeXml(reason)}</string>`)\n\t\t\t\t\t.join('\\n')}\\n\t\t\t</array>\\n\t\t</dict>`\n\t\t)\n\t\t.join('\\n');\n\nconst privacyManifestSource = (\n\tsource: string | null,\n\trequirements: ReturnType<typeof absoluteDeviceNativeRequirements>\n) => {\n\tconst entries = privacyEntries(requirements);\n\tconst wholeRegion = entries\n\t\t? `\t${START_MARKER}\\n\t<key>NSPrivacyAccessedAPITypes</key>\\n\t<array>\\n${entries}\\n\t</array>\\n\t${END_MARKER}\\n`\n\t\t: '';\n\tif (source === null)\n\t\treturn entries\n\t\t\t? `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\\n<plist version=\"1.0\">\\n<dict>\\n${wholeRegion}\t<key>NSPrivacyCollectedDataTypes</key>\\n\t<array/>\\n\t<key>NSPrivacyTracking</key>\\n\t<false/>\\n</dict>\\n</plist>\\n`\n\t\t\t: null;\n\n\tconst start = source.indexOf(START_MARKER);\n\tif (start !== NOT_FOUND) {\n\t\tconst end = source.indexOf(END_MARKER);\n\t\tif (end === NOT_FOUND)\n\t\t\tthrow new TypeError(\n\t\t\t\t'AbsoluteJS device-capability ownership markers are malformed.'\n\t\t\t);\n\t\tconst owned = source.slice(start, end);\n\t\tconst ownsWholeKey = owned.includes('NSPrivacyAccessedAPITypes');\n\t\tlet region = '';\n\t\tif (ownsWholeKey) region = wholeRegion;\n\t\telse if (entries)\n\t\t\tregion = `\t\t${START_MARKER}\\n${entries}\\n\t\t${END_MARKER}\\n`;\n\n\t\treturn managed(source, region, source.lastIndexOf('</dict>'));\n\t}\n\n\tconst key = source.indexOf('<key>NSPrivacyAccessedAPITypes</key>');\n\tif (key === NOT_FOUND)\n\t\treturn managed(source, wholeRegion, source.lastIndexOf('</dict>'));\n\tif (!entries) return source;\n\tconst array = source.indexOf('<array>', key);\n\tif (array === NOT_FOUND)\n\t\tthrow new TypeError(\n\t\t\t'iOS PrivacyInfo.xcprivacy has a malformed NSPrivacyAccessedAPITypes value.'\n\t\t);\n\tconst insertion = source.indexOf('\\n', array);\n\tif (insertion === NOT_FOUND)\n\t\tthrow new TypeError('iOS PrivacyInfo.xcprivacy array is malformed.');\n\n\treturn managed(\n\t\tsource,\n\t\t`\t\t${START_MARKER}\\n${entries}\\n\t\t${END_MARKER}\\n`,\n\t\tinsertion + 1\n\t);\n};\n\nconst writeIosPrivacyManifest = async (\n\tpath: string,\n\tcurrent: string | null,\n\tsource: string | null\n) => {\n\tif (source === null) return false;\n\tif (current !== null) return writeChangedFile(path, source);\n\tawait writeFile(path, source, { flag: 'wx' });\n\n\treturn true;\n};\n\nconst configureIosPrivacyProject = async (\n\tconfig: NormalizedAbsoluteMobileConfig,\n\trequirements: ReturnType<typeof absoluteDeviceNativeRequirements>\n) => {\n\tif (requirements.iosPrivacyAccessedApis.length === 0) return false;\n\tconst projectPath = join(\n\t\tconfig.nativeProjectDirectory,\n\t\t'ios/App/App.xcodeproj/project.pbxproj'\n\t);\n\tconst project = await readFile(projectPath, 'utf8');\n\n\treturn writeChangedFile(\n\t\tprojectPath,\n\t\taddIosPrivacyProjectReference(project)\n\t);\n};\n\nconst addIosPrivacyProjectReference = (source: string) => {\n\tconst fileMatch = source.match(\n\t\t/([A-F0-9]{24}) \\/\\* PrivacyInfo\\.xcprivacy \\*\\/ = \\{isa = PBXFileReference;/u\n\t);\n\tconst fileReference = fileMatch?.[1] ?? IOS_PRIVACY_FILE_REFERENCE;\n\tconst buildMatch = source.match(\n\t\t/([A-F0-9]{24}) \\/\\* PrivacyInfo\\.xcprivacy in Resources \\*\\/ = \\{isa = PBXBuildFile;/u\n\t);\n\tconst buildFile = buildMatch?.[1] ?? IOS_PRIVACY_BUILD_FILE;\n\tif (\n\t\t(!fileMatch && source.includes(fileReference)) ||\n\t\t(!buildMatch && source.includes(buildFile))\n\t)\n\t\tthrow new TypeError(\n\t\t\t'AbsoluteJS iOS privacy-manifest identifiers collide.'\n\t\t);\n\n\tlet next = source;\n\tif (!buildMatch) {\n\t\tconst marker = '/* End PBXBuildFile section */';\n\t\tconst index = next.indexOf(marker);\n\t\tif (index === NOT_FOUND)\n\t\t\tthrow new TypeError('Could not find the iOS PBXBuildFile section.');\n\t\tnext = `${next.slice(0, index)}\t\t${buildFile} /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = ${fileReference} /* PrivacyInfo.xcprivacy */; };\\n${next.slice(index)}`;\n\t}\n\tif (!fileMatch) {\n\t\tconst marker = '/* End PBXFileReference section */';\n\t\tconst index = next.indexOf(marker);\n\t\tif (index === NOT_FOUND)\n\t\t\tthrow new TypeError(\n\t\t\t\t'Could not find the iOS PBXFileReference section.'\n\t\t\t);\n\t\tnext = `${next.slice(0, index)}\t\t${fileReference} /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = \"<group>\"; };\\n${next.slice(index)}`;\n\t}\n\tconst groupsStart = next.indexOf('/* Begin PBXGroup section */');\n\tconst groupsEnd = next.indexOf('/* End PBXGroup section */');\n\tconst groups = next.slice(groupsStart, groupsEnd);\n\tif (!groups.includes(`${fileReference} /* PrivacyInfo.xcprivacy */`)) {\n\t\tconst appGroup = groups.match(\n\t\t\t/[A-F0-9]{24} \\/\\* App \\*\\/ = \\{\\n\\t\\t\\tisa = PBXGroup;\\n\\t\\t\\tchildren = \\(\\n/u\n\t\t);\n\t\tif (!appGroup || appGroup.index === undefined)\n\t\t\tthrow new TypeError('Could not find the iOS App PBXGroup.');\n\t\tconst index = groupsStart + appGroup.index + appGroup[0].length;\n\t\tnext = `${next.slice(0, index)}\t\t\t\t${fileReference} /* PrivacyInfo.xcprivacy */,\\n${next.slice(index)}`;\n\t}\n\tconst resourcesStart = next.indexOf(\n\t\t'/* Begin PBXResourcesBuildPhase section */'\n\t);\n\tconst resourcesEnd = next.indexOf(\n\t\t'/* End PBXResourcesBuildPhase section */'\n\t);\n\tconst resources = next.slice(resourcesStart, resourcesEnd);\n\tif (\n\t\t!resources.includes(\n\t\t\t`${buildFile} /* PrivacyInfo.xcprivacy in Resources */`\n\t\t)\n\t) {\n\t\tconst files = resources.match(\n\t\t\t/isa = PBXResourcesBuildPhase;\\n\\t\\t\\tbuildActionMask = \\d+;\\n\\t\\t\\tfiles = \\(\\n/u\n\t\t);\n\t\tif (!files || files.index === undefined)\n\t\t\tthrow new TypeError(\n\t\t\t\t'Could not find the iOS Resources build phase.'\n\t\t\t);\n\t\tconst index = resourcesStart + files.index + files[0].length;\n\t\tnext = `${next.slice(0, index)}\t\t\t\t${buildFile} /* PrivacyInfo.xcprivacy in Resources */,\\n${next.slice(index)}`;\n\t}\n\n\treturn next;\n};\n\nconst configureIos = async (\n\tconfig: NormalizedAbsoluteMobileConfig,\n\tplan: AbsoluteDeviceCapabilityPlan\n) => {\n\tconst path = join(config.nativeProjectDirectory, 'ios/App/App/Info.plist');\n\tconst source = await readFile(path, 'utf8');\n\tconst requirements = absoluteDeviceNativeRequirements(plan);\n\tconst existingSystemBars = source.match(\n\t\t/<key>UIViewControllerBasedStatusBarAppearance<\\/key>\\s*<(true|false)\\s*\\/>/u\n\t);\n\tconst ownedStart = source.indexOf(START_MARKER);\n\tconst ownedEnd = source.indexOf(END_MARKER);\n\tconst ownsSystemBars =\n\t\townedStart >= 0 &&\n\t\townedEnd > ownedStart &&\n\t\tsource\n\t\t\t.slice(ownedStart, ownedEnd)\n\t\t\t.includes('UIViewControllerBasedStatusBarAppearance');\n\tif (\n\t\trequirements.iosSystemBars &&\n\t\texistingSystemBars?.[1] === 'false' &&\n\t\t!ownsSystemBars\n\t)\n\t\tthrow new TypeError(\n\t\t\t'iOS system bars require UIViewControllerBasedStatusBarAppearance to be true.'\n\t\t);\n\tconst usageContent = requirements.iosUsageDescriptions\n\t\t.map(\n\t\t\t(purpose) =>\n\t\t\t\t`\\t<key>${IOS_KEYS[purpose]}</key>\\n\\t<string>${escapeXml(iosDescription(config.appName, purpose))}</string>`\n\t\t)\n\t\t.join('\\n');\n\tconst systemBarsContent =\n\t\trequirements.iosSystemBars &&\n\t\t(existingSystemBars === null || ownsSystemBars)\n\t\t\t? '\\t<key>UIViewControllerBasedStatusBarAppearance</key>\\n\\t<true/>'\n\t\t\t: '';\n\tconst content = [usageContent, systemBarsContent]\n\t\t.filter(Boolean)\n\t\t.join('\\n');\n\tconst region = content\n\t\t? `\\t${START_MARKER}\\n${content}\\n\\t${END_MARKER}\\n`\n\t\t: '';\n\n\tconst infoChanged = await writeChangedFile(\n\t\tpath,\n\t\tmanaged(source, region, source.lastIndexOf('</dict>'))\n\t);\n\tconst privacyPath = join(\n\t\tconfig.nativeProjectDirectory,\n\t\t'ios/App/App/PrivacyInfo.xcprivacy'\n\t);\n\tconst privacyCurrent = await optionalSource(privacyPath);\n\tconst privacySource = privacyManifestSource(privacyCurrent, requirements);\n\tconst [privacyChanged, projectChanged, pushChanged] = await Promise.all([\n\t\twriteIosPrivacyManifest(privacyPath, privacyCurrent, privacySource),\n\t\tconfigureIosPrivacyProject(config, requirements),\n\t\tconfigureIosPushNotifications(config, requirements.iosPushNotifications)\n\t]);\n\n\treturn infoChanged || privacyChanged || projectChanged || pushChanged;\n};\n\nconst configureIosPushNotifications = async (\n\tconfig: NormalizedAbsoluteMobileConfig,\n\tenabled: boolean\n) => {\n\tconst entitlementsPath = join(\n\t\tconfig.nativeProjectDirectory,\n\t\t'ios/App/AbsoluteJS.entitlements'\n\t);\n\tconst entitlements = await optionalSource(entitlementsPath);\n\tif (entitlements === null && !enabled) return false;\n\tif (entitlements === null)\n\t\tthrow new TypeError(\n\t\t\t'AbsoluteJS iOS entitlements are missing. Run native deep-link projection before device capabilities.'\n\t\t);\n\tconst entitlementRegion = enabled\n\t\t? `\\t<!-- ${PUSH_START_MARKER} -->\\n\\t<key>aps-environment</key>\\n\\t<string>development</string>\\n\\t<!-- ${PUSH_END_MARKER} -->\\n`\n\t\t: '';\n\tconst nextEntitlements = replacePushRegion(\n\t\tentitlements,\n\t\tentitlementRegion,\n\t\tentitlements.lastIndexOf('</dict>')\n\t);\n\tconst delegatePath = join(\n\t\tconfig.nativeProjectDirectory,\n\t\t'ios/App/App/AppDelegate.swift'\n\t);\n\tconst delegate = await optionalSource(delegatePath);\n\tif (delegate === null && !enabled) return false;\n\tif (delegate === null)\n\t\tthrow new TypeError(\n\t\t\t'Capacitor AppDelegate.swift is missing for iOS push notifications.'\n\t\t);\n\tconst hasSuccess = delegate.includes(\n\t\t'didRegisterForRemoteNotificationsWithDeviceToken'\n\t);\n\tconst hasFailure = delegate.includes(\n\t\t'didFailToRegisterForRemoteNotificationsWithError'\n\t);\n\tif (\n\t\tenabled &&\n\t\thasSuccess !== hasFailure &&\n\t\t!delegate.includes(PUSH_START_MARKER)\n\t)\n\t\tthrow new TypeError(\n\t\t\t'iOS AppDelegate has a partial custom remote-notification registration implementation.'\n\t\t);\n\tconst alreadyForwarded =\n\t\tenabled &&\n\t\thasSuccess &&\n\t\thasFailure &&\n\t\tdelegate.includes('capacitorDidRegisterForRemoteNotifications') &&\n\t\tdelegate.includes('capacitorDidFailToRegisterForRemoteNotifications');\n\tconst swiftRegion =\n\t\tenabled && !alreadyForwarded\n\t\t\t? `\\n // ${PUSH_START_MARKER}\\n func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {\\n NotificationCenter.default.post(name: .capacitorDidRegisterForRemoteNotifications, object: deviceToken)\\n }\\n\\n func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {\\n NotificationCenter.default.post(name: .capacitorDidFailToRegisterForRemoteNotifications, object: error)\\n }\\n // ${PUSH_END_MARKER}\\n`\n\t\t\t: '';\n\tconst nextDelegate = alreadyForwarded\n\t\t? delegate\n\t\t: replacePushRegion(delegate, swiftRegion, delegate.lastIndexOf('}'));\n\tconst changed = await Promise.all([\n\t\twriteChangedFile(entitlementsPath, nextEntitlements),\n\t\twriteChangedFile(delegatePath, nextDelegate)\n\t]);\n\n\treturn changed.some(Boolean);\n};\n\nconst replacePushRegion = (\n\tsource: string,\n\tregion: string,\n\tinsertion: number\n) => {\n\tconst start = source.indexOf(PUSH_START_MARKER);\n\tconst end = source.indexOf(PUSH_END_MARKER);\n\tif (start < 0 !== end < 0 || (start >= 0 && end < start))\n\t\tthrow new TypeError(\n\t\t\t'AbsoluteJS push-notification ownership markers are malformed.'\n\t\t);\n\tif (start >= 0) {\n\t\tconst lineStart = source.lastIndexOf('\\n', start) + 1;\n\t\tconst nextLine = source.indexOf('\\n', end + PUSH_END_MARKER.length);\n\t\tconst lineEnd = nextLine < 0 ? source.length : nextLine + 1;\n\n\t\treturn `${source.slice(0, lineStart)}${region}${source.slice(lineEnd)}`;\n\t}\n\tif (!region) return source;\n\tif (insertion < 0)\n\t\tthrow new TypeError(\n\t\t\t'Could not find a safe native project location for push notifications.'\n\t\t);\n\n\treturn `${source.slice(0, insertion)}${region}${source.slice(insertion)}`;\n};\n\nconst configureAndroid = async (\n\tconfig: NormalizedAbsoluteMobileConfig,\n\tplan: AbsoluteDeviceCapabilityPlan\n) => {\n\tconst path = join(\n\t\tconfig.nativeProjectDirectory,\n\t\t'android/app/src/main/AndroidManifest.xml'\n\t);\n\tconst source = await readFile(path, 'utf8');\n\tconst permissions =\n\t\tabsoluteDeviceNativeRequirements(plan).androidPermissions;\n\tconst content = permissions\n\t\t.map(\n\t\t\t(permission) =>\n\t\t\t\t` <uses-permission android:name=\"${escapeXml(permission)}\" />`\n\t\t)\n\t\t.join('\\n');\n\tconst region = content\n\t\t? ` ${START_MARKER}\\n${content}\\n ${END_MARKER}\\n`\n\t\t: '';\n\tconst application = source.indexOf('<application');\n\tconst insertion =\n\t\tapplication === NOT_FOUND\n\t\t\t? NOT_FOUND\n\t\t\t: source.lastIndexOf('\\n', application) + 1;\n\n\tconst nextManifest = managed(source, region, insertion);\n\tif (!plan.capabilities.includes('pushNotifications'))\n\t\treturn writeChangedFile(path, nextManifest);\n\tconst firebaseSource = await optionalSource(\n\t\tconfig.pushAndroidGoogleServicesFile\n\t);\n\tif (firebaseSource === null)\n\t\tthrow new TypeError(\n\t\t\t`Push notifications require Firebase config at ${config.pushAndroidGoogleServicesFile}. Set mobile.pushNotifications.android.googleServicesFile to override it.`\n\t\t);\n\tlet firebase: unknown;\n\ttry {\n\t\tfirebase = JSON.parse(firebaseSource);\n\t} catch (error) {\n\t\tthrow new TypeError('Android google-services.json is invalid JSON.', {\n\t\t\tcause: error\n\t\t});\n\t}\n\tconst clients =\n\t\ttypeof firebase === 'object' && firebase !== null\n\t\t\t? Reflect.get(firebase, 'client')\n\t\t\t: undefined;\n\tconst matchesApp =\n\t\tArray.isArray(clients) &&\n\t\tclients.some((client) => {\n\t\t\tconst info =\n\t\t\t\ttypeof client === 'object' && client !== null\n\t\t\t\t\t? Reflect.get(client, 'client_info')\n\t\t\t\t\t: undefined;\n\t\t\tconst android =\n\t\t\t\ttypeof info === 'object' && info !== null\n\t\t\t\t\t? Reflect.get(info, 'android_client_info')\n\t\t\t\t\t: undefined;\n\n\t\t\treturn (\n\t\t\t\ttypeof android === 'object' &&\n\t\t\t\tandroid !== null &&\n\t\t\t\tReflect.get(android, 'package_name') === config.appId\n\t\t\t);\n\t\t});\n\tif (!matchesApp)\n\t\tthrow new TypeError(\n\t\t\t`Android google-services.json does not contain package ${config.appId}.`\n\t\t);\n\tconst [manifestChanged, firebaseChanged] = await Promise.all([\n\t\twriteChangedFile(path, nextManifest),\n\t\twriteOptionalChangedFile(\n\t\t\tjoin(\n\t\t\t\tconfig.nativeProjectDirectory,\n\t\t\t\t'android/app/google-services.json'\n\t\t\t),\n\t\t\tfirebaseSource\n\t\t)\n\t]);\n\n\treturn manifestChanged || firebaseChanged;\n};\n\nexport const applyAbsoluteNativeDeviceCapabilities = async (\n\tprojectRoot: string,\n\tconfig: NormalizedAbsoluteMobileConfig,\n\tplatforms: readonly MobilePlatform[] = config.platforms,\n\tplan = resolveAbsoluteDeviceCapabilityPlan(projectRoot)\n) => {\n\tconst results = await Promise.all(\n\t\tplatforms.map(async (platform) => ({\n\t\t\tdidChange:\n\t\t\t\tplatform === 'ios'\n\t\t\t\t\t? await configureIos(config, plan)\n\t\t\t\t\t: await configureAndroid(config, plan),\n\t\t\tplatform\n\t\t}))\n\t);\n\n\treturn {\n\t\tchanged: results\n\t\t\t.filter(({ didChange }) => didChange)\n\t\t\t.map(({ platform }) => platform)\n\t};\n};\n",
|
|
38
55
|
"import { access } from 'node:fs/promises';\nimport { isAbsolute, relative, resolve, sep } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport type { AbsoluteAndroidReleaseMetadata } from './androidRelease';\nimport type { AbsoluteIosReleaseMetadata } from './iosRelease';\n\nexport type AbsoluteGooglePlayReleaseTarget = {\n\tchangesNotSentForReview?: boolean;\n\tinAppUpdatePriority?: number;\n\tname?: string;\n\treleaseNotes?: readonly { language: string; text: string }[];\n\treviewBehavior?: 'CANCEL_IN_REVIEW_AND_SUBMIT' | 'ERROR_IF_IN_REVIEW';\n\tstatus?: 'completed' | 'draft' | 'halted' | 'inProgress';\n\ttrack: string;\n\tuserFraction?: number;\n};\n\nexport type AbsoluteAppStoreConnectReleaseTarget = {\n\tgroups?: readonly string[];\n\tsubmitForReview?: boolean;\n\twhatsNew?: readonly { locale: string; text: string }[];\n};\n\nexport type AbsoluteNativeReleasePublication = {\n\tchannel?: {\n\t\tchannel: string;\n\t\treleaseId: string;\n\t};\n\trecord: {\n\t\tmetadata: AbsoluteAndroidReleaseMetadata | AbsoluteIosReleaseMetadata;\n\t};\n\treused: boolean;\n\tgooglePlay?: {\n\t\treceipt: {\n\t\t\tintent: { track: string };\n\t\t\tpackageName: string;\n\t\t\tprovider: 'google-play';\n\t\t\treleaseId: string;\n\t\t\tsha256: string;\n\t\t\tstage: string;\n\t\t\tversionCode?: string;\n\t\t};\n\t\treused: boolean;\n\t};\n\tappStoreConnect?: {\n\t\treceipt: {\n\t\t\tappleAppId: string;\n\t\t\tbuildId?: string;\n\t\t\tbuildNumber: number;\n\t\t\tintent: { groups: string[]; submitForReview: boolean };\n\t\t\tmarketingVersion: string;\n\t\t\tprovider: 'app-store-connect';\n\t\t\treleaseId: string;\n\t\t\tsha256: string;\n\t\t\tstage: string;\n\t\t};\n\t\treused: boolean;\n\t};\n};\n\nexport type AbsoluteNativeReleasePublisher = {\n\tprepareAndroidRelease?: (options: {\n\t\tbuildIdentity: string;\n\t\tgooglePlay?: AbsoluteGooglePlayReleaseTarget;\n\t\tpackageName: string;\n\t\tsignal?: AbortSignal;\n\t}) => Promise<{ versionCode?: number }>;\n\tprepareIosRelease?: (options: {\n\t\tbuildIdentity: string;\n\t\tbundleId: string;\n\t\tmarketingVersion: string;\n\t\tsignal?: AbortSignal;\n\t}) => Promise<{ buildNumber: number }>;\n\tpublish: (options: {\n\t\tallowUnsigned?: boolean;\n\t\tappStoreConnect?: AbsoluteAppStoreConnectReleaseTarget;\n\t\tchannel?: string;\n\t\tgooglePlay?: AbsoluteGooglePlayReleaseTarget;\n\t\treleaseRoot: string;\n\t\tsignal?: AbortSignal;\n\t}) => Promise<AbsoluteNativeReleasePublication>;\n};\n\nexport const prepareAbsoluteIosRelease = async (\n\tpublisher: AbsoluteNativeReleasePublisher,\n\toptions: {\n\t\tbuildIdentity: string;\n\t\tbundleId: string;\n\t\tmarketingVersion: string;\n\t\tsignal?: AbortSignal;\n\t}\n) => {\n\tif (typeof publisher.prepareIosRelease !== 'function') {\n\t\tthrow new TypeError(\n\t\t\t'App Store Connect publishing requires a registry module created with @absolutejs/deploy/app-store-connect.'\n\t\t);\n\t}\n\tconst { buildNumber } = await publisher.prepareIosRelease(options);\n\tif (!Number.isSafeInteger(buildNumber) || buildNumber < 1) {\n\t\tthrow new TypeError(\n\t\t\t'App Store Connect publisher returned an invalid iOS build number.'\n\t\t);\n\t}\n\n\treturn buildNumber;\n};\n\ntype PrepareAbsoluteAndroidReleaseOptions = {\n\tbuildIdentity: string;\n\tgooglePlay: AbsoluteGooglePlayReleaseTarget;\n\tpackageName: string;\n\tsignal?: AbortSignal;\n};\n\nexport const prepareAbsoluteAndroidRelease = async (\n\tpublisher: AbsoluteNativeReleasePublisher,\n\toptions: PrepareAbsoluteAndroidReleaseOptions\n) => {\n\tif (typeof publisher.prepareAndroidRelease !== 'function') {\n\t\tthrow new TypeError(\n\t\t\t'Google Play publishing requires a registry module created with @absolutejs/deploy/google-play.'\n\t\t);\n\t}\n\tconst prepared = await publisher.prepareAndroidRelease(options);\n\tconst { versionCode } = prepared;\n\tif (\n\t\ttypeof versionCode !== 'number' ||\n\t\t!Number.isSafeInteger(versionCode) ||\n\t\tversionCode < 1 ||\n\t\tversionCode > 2_100_000_000\n\t) {\n\t\tthrow new TypeError(\n\t\t\t'Google Play publisher returned an invalid Android versionCode.'\n\t\t);\n\t}\n\n\treturn versionCode;\n};\n\nexport type PublishAbsoluteAndroidReleaseOptions = {\n\tallowUnsigned?: boolean;\n\tchannel?: string;\n\tgooglePlay?: AbsoluteGooglePlayReleaseTarget;\n\tmodulePath: string;\n\tprojectRoot: string;\n\trelease: {\n\t\tmetadata: AbsoluteAndroidReleaseMetadata;\n\t\treleaseRoot: string;\n\t};\n\tsignal?: AbortSignal;\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n\ttypeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst isPublisher = (value: unknown): value is AbsoluteNativeReleasePublisher =>\n\tisRecord(value) && typeof value.publish === 'function';\n\nconst publisherModulePath = (projectRoot: string, requested: string) => {\n\tconst root = resolve(projectRoot);\n\tconst path = resolve(root, requested);\n\tconst projectRelative = relative(root, path);\n\tif (\n\t\tprojectRelative === '..' ||\n\t\tprojectRelative.startsWith(`..${sep}`) ||\n\t\tisAbsolute(projectRelative)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t'mobile publish --registry must remain inside the project.'\n\t\t);\n\t}\n\n\treturn path;\n};\n\nexport const loadAbsoluteNativeReleasePublisher = async (\n\tprojectRoot: string,\n\trequestedModulePath: string\n) => {\n\tconst modulePath = publisherModulePath(projectRoot, requestedModulePath);\n\tawait access(modulePath).catch(() => {\n\t\tthrow new TypeError(\n\t\t\t`Native release registry module does not exist: ${modulePath}`\n\t\t);\n\t});\n\tconst loaded: unknown = await import(pathToFileURL(modulePath).href);\n\tconst publisher = isRecord(loaded)\n\t\t? (loaded.default ?? loaded.registry)\n\t\t: undefined;\n\tif (!isPublisher(publisher)) {\n\t\tthrow new TypeError(\n\t\t\t'Native release registry module must default-export a registry with publish(options).'\n\t\t);\n\t}\n\n\treturn publisher;\n};\n\nexport const publishAbsoluteAndroidRelease = async (\n\toptions: PublishAbsoluteAndroidReleaseOptions\n) => {\n\tconst publisher = await loadAbsoluteNativeReleasePublisher(\n\t\toptions.projectRoot,\n\t\toptions.modulePath\n\t);\n\tconst publication = await publisher.publish({\n\t\tallowUnsigned: options.allowUnsigned,\n\t\tchannel: options.channel,\n\t\tgooglePlay: options.googlePlay,\n\t\treleaseRoot: options.release.releaseRoot,\n\t\tsignal: options.signal\n\t});\n\tconst expected = options.release.metadata;\n\tconst actual = publication.record?.metadata;\n\tif (\n\t\t!actual ||\n\t\tactual.appId !== expected.appId ||\n\t\tactual.platform !== 'android' ||\n\t\tactual.releaseId !== expected.releaseId ||\n\t\tactual.sha256 !== expected.sha256 ||\n\t\tactual.signed !== expected.signed ||\n\t\tactual.versionCode !== expected.versionCode ||\n\t\ttypeof publication.reused !== 'boolean'\n\t) {\n\t\tthrow new TypeError(\n\t\t\t'Native release registry returned a different Android release identity.'\n\t\t);\n\t}\n\tif (\n\t\toptions.channel !== undefined &&\n\t\t(publication.channel?.channel !== options.channel ||\n\t\t\tpublication.channel.releaseId !== expected.releaseId)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t'Native release registry did not promote the requested channel.'\n\t\t);\n\t}\n\tconst { googlePlay } = publication;\n\tif (options.googlePlay) {\n\t\tif (\n\t\t\t!expected.versionCode ||\n\t\t\t!googlePlay ||\n\t\t\tgooglePlay.receipt.provider !== 'google-play' ||\n\t\t\tgooglePlay.receipt.packageName !== expected.appId ||\n\t\t\tgooglePlay.receipt.releaseId !== expected.releaseId ||\n\t\t\tgooglePlay.receipt.sha256 !== expected.sha256 ||\n\t\t\tgooglePlay.receipt.stage !== 'committed' ||\n\t\t\tgooglePlay.receipt.intent.track !== options.googlePlay.track ||\n\t\t\ttypeof googlePlay.receipt.versionCode !== 'string' ||\n\t\t\t!/^\\d+$/.test(googlePlay.receipt.versionCode) ||\n\t\t\tNumber(googlePlay.receipt.versionCode) !== expected.versionCode ||\n\t\t\ttypeof googlePlay.reused !== 'boolean'\n\t\t) {\n\t\t\tthrow new TypeError(\n\t\t\t\t'Native release publisher did not commit the requested Google Play release.'\n\t\t\t);\n\t\t}\n\t}\n\n\treturn publication;\n};\n\nexport const publishAbsoluteIosRelease = async (options: {\n\tallowUnsigned?: boolean;\n\tappStoreConnect?: AbsoluteAppStoreConnectReleaseTarget;\n\tchannel?: string;\n\tmodulePath: string;\n\tprojectRoot: string;\n\trelease: {\n\t\tmetadata: AbsoluteIosReleaseMetadata;\n\t\treleaseRoot: string;\n\t};\n\tsignal?: AbortSignal;\n}) => {\n\tconst publisher = await loadAbsoluteNativeReleasePublisher(\n\t\toptions.projectRoot,\n\t\toptions.modulePath\n\t);\n\tconst publication = await publisher.publish({\n\t\tallowUnsigned: options.allowUnsigned,\n\t\tappStoreConnect: options.appStoreConnect,\n\t\tchannel: options.channel,\n\t\treleaseRoot: options.release.releaseRoot,\n\t\tsignal: options.signal\n\t});\n\tconst expected = options.release.metadata;\n\tconst actual = publication.record?.metadata;\n\tif (\n\t\t!actual ||\n\t\tactual.appId !== expected.appId ||\n\t\tactual.platform !== 'ios' ||\n\t\tactual.releaseId !== expected.releaseId ||\n\t\tactual.sha256 !== expected.sha256 ||\n\t\tactual.signed !== expected.signed ||\n\t\tactual.buildNumber !== expected.buildNumber ||\n\t\tactual.marketingVersion !== expected.marketingVersion ||\n\t\ttypeof publication.reused !== 'boolean'\n\t) {\n\t\tthrow new TypeError(\n\t\t\t'Native release registry returned a different iOS release identity.'\n\t\t);\n\t}\n\tif (\n\t\toptions.channel !== undefined &&\n\t\t(publication.channel?.channel !== options.channel ||\n\t\t\tpublication.channel.releaseId !== expected.releaseId)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t'Native release registry did not promote the requested channel.'\n\t\t);\n\t}\n\tif (options.appStoreConnect) {\n\t\tconst distributed = publication.appStoreConnect;\n\t\tif (\n\t\t\t!expected.buildNumber ||\n\t\t\t!distributed ||\n\t\t\tdistributed.receipt.provider !== 'app-store-connect' ||\n\t\t\tdistributed.receipt.releaseId !== expected.releaseId ||\n\t\t\tdistributed.receipt.sha256 !== expected.sha256 ||\n\t\t\tdistributed.receipt.buildNumber !== expected.buildNumber ||\n\t\t\tdistributed.receipt.marketingVersion !==\n\t\t\t\texpected.marketingVersion ||\n\t\t\t!['distributed', 'review-submitted'].includes(\n\t\t\t\tdistributed.receipt.stage\n\t\t\t) ||\n\t\t\tJSON.stringify([...distributed.receipt.intent.groups].sort()) !==\n\t\t\t\tJSON.stringify(\n\t\t\t\t\t[...(options.appStoreConnect.groups ?? [])].sort()\n\t\t\t\t) ||\n\t\t\tdistributed.receipt.intent.submitForReview !==\n\t\t\t\t(options.appStoreConnect.submitForReview ?? false) ||\n\t\t\ttypeof distributed.reused !== 'boolean'\n\t\t) {\n\t\t\tthrow new TypeError(\n\t\t\t\t'Native release publisher did not complete the requested App Store Connect release.'\n\t\t\t);\n\t\t}\n\t}\n\n\treturn publication;\n};\n",
|
|
39
|
-
"import { existsSync, readFileSync } from 'node:fs';\nimport { dirname, extname, relative, resolve } from 'node:path';\nimport type { BunPlugin } from 'bun';\nimport ts from 'typescript';\nimport { ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION } from './pageProtocol';\nimport { hashAbsoluteMobilePropsSchema } from './releaseArtifact';\nimport {\n\tABSOLUTE_MOBILE_ROUTE_DETAIL,\n\ttype AbsoluteMobileBuildPageMetadata\n} from './buildMetadata';\n\ntype MobileRouteTransformOptions = {\n\tentry: string;\n\tprojectRoot?: string;\n};\n\ntype AnalyzedPageCall = {\n\tinputKind: 'object' | 'static';\n\tmetadata: AbsoluteMobileBuildPageMetadata;\n\tpageCallStart: number;\n\trouteCallSpan: string;\n};\n\ntype AnalyzedFile = {\n\tbyPageCall: Map<number, AnalyzedPageCall>;\n\tbyRouteCall: Map<string, AnalyzedPageCall>;\n};\n\ntype PageHandlerDefinition = {\n\tbundleProperty?: 'index' | 'indexPath';\n\tframework: AbsoluteMobileBuildPageMetadata['framework'];\n\tinputKind?: 'static';\n\tpageProperty?: 'Page';\n\tpropsProperty: 'props' | 'requestContext';\n\tsourceProperty?: 'pagePath';\n};\n\ntype AssetKeyResolver = (\n\texpression: ts.Expression | undefined,\n\tchecker: ts.TypeChecker,\n\tseen?: Set<ts.Symbol>\n) => string | undefined;\n\nconst ROUTE_METHODS = new Set(['get', 'head']);\nconst SOURCE_FILTER = /\\.[cm]?[jt]sx?$/;\nconst PAGE_HANDLERS = new Map<string, PageHandlerDefinition>([\n\t[\n\t\t'handleHTMLPageRequest',\n\t\t{ framework: 'html', inputKind: 'static', propsProperty: 'props' }\n\t],\n\t[\n\t\t'handleHTMXPageRequest',\n\t\t{ framework: 'htmx', inputKind: 'static', propsProperty: 'props' }\n\t],\n\t[\n\t\t'handleAngularPageRequest',\n\t\t{\n\t\t\tbundleProperty: 'indexPath',\n\t\t\tframework: 'angular',\n\t\t\tpropsProperty: 'requestContext',\n\t\t\tsourceProperty: 'pagePath'\n\t\t}\n\t],\n\t[\n\t\t'handleReactPageRequest',\n\t\t{\n\t\t\tbundleProperty: 'index',\n\t\t\tframework: 'react',\n\t\t\tpageProperty: 'Page',\n\t\t\tpropsProperty: 'props'\n\t\t}\n\t],\n\t[\n\t\t'handleSveltePageRequest',\n\t\t{\n\t\t\tbundleProperty: 'indexPath',\n\t\t\tframework: 'svelte',\n\t\t\tpropsProperty: 'props',\n\t\t\tsourceProperty: 'pagePath'\n\t\t}\n\t],\n\t[\n\t\t'handleVuePageRequest',\n\t\t{\n\t\t\tbundleProperty: 'indexPath',\n\t\t\tframework: 'vue',\n\t\t\tpropsProperty: 'props',\n\t\t\tsourceProperty: 'pagePath'\n\t\t}\n\t]\n]);\n\nconst posixPath = (value: string) => value.replace(/\\\\/g, '/');\n\nconst findTsconfig = (entry: string, projectRoot: string) =>\n\tts.findConfigFile(dirname(entry), existsSync, 'tsconfig.json') ??\n\tts.findConfigFile(projectRoot, existsSync, 'tsconfig.json');\n\nconst createProgram = (entry: string, projectRoot: string) => {\n\tconst configPath = findTsconfig(entry, projectRoot);\n\tif (!configPath) {\n\t\treturn ts.createProgram([entry], {\n\t\t\tallowJs: true,\n\t\t\tjsx: ts.JsxEmit.ReactJSX,\n\t\t\tmodule: ts.ModuleKind.ESNext,\n\t\t\tmoduleResolution: ts.ModuleResolutionKind.Bundler,\n\t\t\ttarget: ts.ScriptTarget.ESNext\n\t\t});\n\t}\n\n\tconst parsed = ts.parseJsonConfigFileContent(\n\t\tts.readConfigFile(configPath, (path) => readFileSync(path, 'utf8'))\n\t\t\t.config,\n\t\tts.sys,\n\t\tdirname(configPath)\n\t);\n\tif (!parsed.fileNames.includes(entry)) parsed.fileNames.push(entry);\n\n\treturn ts.createProgram(parsed.fileNames, parsed.options);\n};\n\nconst propertyName = (property: ts.ObjectLiteralElementLike) => {\n\tif (!('name' in property) || !property.name) return undefined;\n\tif (ts.isIdentifier(property.name)) return property.name.text;\n\tif (ts.isStringLiteralLike(property.name)) return property.name.text;\n\n\treturn undefined;\n};\n\nconst objectPropertyExpression = (\n\tobject: ts.ObjectLiteralExpression,\n\tname: string\n) => {\n\tconst property = object.properties.find(\n\t\t(candidate) => propertyName(candidate) === name\n\t);\n\tif (property && ts.isPropertyAssignment(property)) {\n\t\treturn property.initializer;\n\t}\n\tif (property && ts.isShorthandPropertyAssignment(property)) {\n\t\treturn property.name;\n\t}\n\n\treturn undefined;\n};\n\nconst serializeType = (\n\ttype: ts.Type,\n\tchecker: ts.TypeChecker,\n\tancestors = new Set<ts.Type>()\n): unknown => {\n\tif (type.flags & ts.TypeFlags.Any) return { type: 'any' };\n\tif (type.flags & ts.TypeFlags.Unknown) return { type: 'unknown' };\n\tif (type.flags & ts.TypeFlags.Never) return { type: 'never' };\n\tif (type.flags & ts.TypeFlags.StringLike) return { type: 'string' };\n\tif (type.flags & ts.TypeFlags.NumberLike) return { type: 'number' };\n\tif (type.flags & ts.TypeFlags.BooleanLike) return { type: 'boolean' };\n\tif (type.flags & ts.TypeFlags.BigIntLike) return { type: 'bigint' };\n\tif (type.flags & ts.TypeFlags.Null) return { type: 'null' };\n\tif (type.flags & ts.TypeFlags.Undefined) return { type: 'undefined' };\n\tif (type.isUnion()) {\n\t\treturn {\n\t\t\tanyOf: type.types\n\t\t\t\t.map((member) => serializeType(member, checker, ancestors))\n\t\t\t\t.sort((left, right) =>\n\t\t\t\t\tJSON.stringify(left).localeCompare(JSON.stringify(right))\n\t\t\t\t)\n\t\t};\n\t}\n\tif (type.isIntersection()) {\n\t\treturn {\n\t\t\tallOf: type.types\n\t\t\t\t.map((member) => serializeType(member, checker, ancestors))\n\t\t\t\t.sort((left, right) =>\n\t\t\t\t\tJSON.stringify(left).localeCompare(JSON.stringify(right))\n\t\t\t\t)\n\t\t};\n\t}\n\tif (ancestors.has(type)) {\n\t\treturn {\n\t\t\tref: checker.typeToString(\n\t\t\t\ttype,\n\t\t\t\tundefined,\n\t\t\t\tts.TypeFormatFlags.NoTruncation\n\t\t\t)\n\t\t};\n\t}\n\n\tancestors.add(type);\n\tconst arrayElement = checker.getIndexTypeOfType(type, ts.IndexKind.Number);\n\tconst properties = checker.getPropertiesOfType(type);\n\tlet schema: unknown;\n\tif (arrayElement && properties.some(({ name }) => name === 'length')) {\n\t\tschema = {\n\t\t\titems: serializeType(arrayElement, checker, ancestors),\n\t\t\ttype: 'array'\n\t\t};\n\t} else if (properties.length > 0) {\n\t\tconst entries = properties\n\t\t\t.filter(({ name }) => !name.startsWith('__'))\n\t\t\t.map((property) => {\n\t\t\t\tconst declaration =\n\t\t\t\t\tproperty.valueDeclaration ?? property.declarations?.[0];\n\t\t\t\tconst propertyType = declaration\n\t\t\t\t\t? checker.getTypeOfSymbolAtLocation(property, declaration)\n\t\t\t\t\t: checker.getDeclaredTypeOfSymbol(property);\n\n\t\t\t\treturn [\n\t\t\t\t\tproperty.name,\n\t\t\t\t\t{\n\t\t\t\t\t\toptional: Boolean(\n\t\t\t\t\t\t\tproperty.flags & ts.SymbolFlags.Optional\n\t\t\t\t\t\t),\n\t\t\t\t\t\tschema: serializeType(propertyType, checker, ancestors)\n\t\t\t\t\t}\n\t\t\t\t] as const;\n\t\t\t})\n\t\t\t.sort(([left], [right]) => left.localeCompare(right));\n\t\tschema = { properties: Object.fromEntries(entries), type: 'object' };\n\t} else {\n\t\tschema = {\n\t\t\ttype: checker.typeToString(\n\t\t\t\ttype,\n\t\t\t\tundefined,\n\t\t\t\tts.TypeFormatFlags.NoTruncation\n\t\t\t)\n\t\t};\n\t}\n\tancestors.delete(type);\n\n\treturn schema;\n};\n\nconst pagePropsType = (\n\tpageExpression: ts.Expression,\n\tpropsExpression: ts.Expression | undefined,\n\tchecker: ts.TypeChecker\n) => {\n\tconst pageType = checker.getTypeAtLocation(pageExpression);\n\tconst [signature] = pageType.getCallSignatures();\n\tconst [parameter] = signature?.parameters ?? [];\n\tconst declaration =\n\t\tparameter?.valueDeclaration ?? parameter?.declarations?.[0];\n\tif (parameter && declaration) {\n\t\treturn checker.getTypeOfSymbolAtLocation(parameter, declaration);\n\t}\n\n\treturn propsExpression\n\t\t? checker.getTypeAtLocation(propsExpression)\n\t\t: checker.getTypeAtLocation(pageExpression);\n};\n\nconst resolvePageIdentity = (\n\texpression: ts.Expression,\n\tsourceFile: ts.SourceFile,\n\tchecker: ts.TypeChecker,\n\tprojectRoot: string\n) => {\n\tlet symbol = checker.getSymbolAtLocation(expression);\n\tif (symbol?.flags && symbol.flags & ts.SymbolFlags.Alias) {\n\t\tsymbol = checker.getAliasedSymbol(symbol);\n\t}\n\tconst declaration = symbol?.declarations?.[0];\n\tconst file = declaration?.getSourceFile().fileName ?? sourceFile.fileName;\n\tconst exportedName = symbol?.name ?? expression.getText(sourceFile);\n\tconst source = posixPath(relative(projectRoot, file));\n\n\treturn `${source}#${exportedName}`;\n};\n\nconst resolveAlias = (symbol: ts.Symbol, checker: ts.TypeChecker) => {\n\tif (!(symbol.flags & ts.SymbolFlags.Alias)) return symbol;\n\n\treturn checker.getAliasedSymbol(symbol);\n};\n\nconst assetKey: AssetKeyResolver = (\n\texpression,\n\tchecker,\n\tseen = new Set<ts.Symbol>()\n) => {\n\tif (!expression) return undefined;\n\n\tif (ts.isIdentifier(expression)) {\n\t\tconst unresolved = ts.isShorthandPropertyAssignment(expression.parent)\n\t\t\t? checker.getShorthandAssignmentValueSymbol(expression.parent)\n\t\t\t: checker.getSymbolAtLocation(expression);\n\t\tif (!unresolved) return undefined;\n\t\tconst symbol = resolveAlias(unresolved, checker);\n\t\tif (seen.has(symbol)) return undefined;\n\t\tseen.add(symbol);\n\t\tconst declaration = symbol.valueDeclaration ?? symbol.declarations?.[0];\n\t\tif (!declaration || !ts.isVariableDeclaration(declaration))\n\t\t\treturn undefined;\n\n\t\treturn assetKey(declaration.initializer, checker, seen);\n\t}\n\n\tif (!ts.isCallExpression(expression)) return undefined;\n\tif (\n\t\t!ts.isIdentifier(expression.expression) ||\n\t\texpression.expression.text !== 'asset'\n\t) {\n\t\treturn undefined;\n\t}\n\tconst [, key] = expression.arguments;\n\n\treturn key && ts.isStringLiteralLike(key) ? key.text : undefined;\n};\n\nconst staticString = (\n\texpression: ts.Expression,\n\tbindings: ReadonlyMap<string, string>\n): string | undefined => {\n\tif (ts.isStringLiteralLike(expression)) return expression.text;\n\tif (ts.isIdentifier(expression)) return bindings.get(expression.text);\n\tif (ts.isNoSubstitutionTemplateLiteral(expression)) return expression.text;\n\tif (!ts.isTemplateExpression(expression)) return undefined;\n\tlet value = expression.head.text;\n\tfor (const span of expression.templateSpans) {\n\t\tconst substitution = staticString(span.expression, bindings);\n\t\tif (substitution === undefined) return undefined;\n\t\tvalue += substitution + span.literal.text;\n\t}\n\n\treturn value;\n};\n\nconst assetKeyWithBindings = (\n\texpression: ts.Expression | undefined,\n\tchecker: ts.TypeChecker,\n\tbindings: ReadonlyMap<string, string> = new Map()\n) => {\n\tif (!expression) return undefined;\n\tif (\n\t\tts.isCallExpression(expression) &&\n\t\tts.isIdentifier(expression.expression) &&\n\t\texpression.expression.text === 'asset'\n\t) {\n\t\tconst [, key] = expression.arguments;\n\n\t\treturn key ? staticString(key, bindings) : undefined;\n\t}\n\n\treturn assetKey(expression, checker);\n};\n\nconst callableObject = (call: ts.CallExpression, checker: ts.TypeChecker) => {\n\tconst symbol = checker.getSymbolAtLocation(call.expression);\n\tconst resolved = symbol ? resolveAlias(symbol, checker) : undefined;\n\tconst declaration =\n\t\tresolved?.valueDeclaration ?? resolved?.declarations?.[0];\n\tlet callable:\n\t\t| ts.ArrowFunction\n\t\t| ts.FunctionDeclaration\n\t\t| ts.FunctionExpression\n\t\t| undefined;\n\tif (declaration && ts.isFunctionDeclaration(declaration)) {\n\t\tcallable = declaration;\n\t} else if (\n\t\tdeclaration &&\n\t\tts.isVariableDeclaration(declaration) &&\n\t\tdeclaration.initializer &&\n\t\t(ts.isArrowFunction(declaration.initializer) ||\n\t\t\tts.isFunctionExpression(declaration.initializer))\n\t) {\n\t\tcallable = declaration.initializer;\n\t}\n\tif (!callable) return undefined;\n\tconst bindings = new Map<string, string>();\n\tcallable.parameters.forEach((parameter, index) => {\n\t\tif (!ts.isIdentifier(parameter.name)) return;\n\t\tconst argument = call.arguments[index];\n\t\tif (!argument) return;\n\t\tconst value = staticString(argument, new Map());\n\t\tif (value !== undefined) bindings.set(parameter.name.text, value);\n\t});\n\tconst { body } = callable;\n\tif (!body) return undefined;\n\tconst expressionBody = ts.isParenthesizedExpression(body)\n\t\t? body.expression\n\t\t: body;\n\tif (ts.isObjectLiteralExpression(expressionBody)) {\n\t\treturn { bindings, object: expressionBody };\n\t}\n\tif (ts.isBlock(body)) {\n\t\tconst returned = body.statements.find(ts.isReturnStatement)?.expression;\n\t\tif (returned && ts.isObjectLiteralExpression(returned)) {\n\t\t\treturn { bindings, object: returned };\n\t\t}\n\t}\n\n\treturn undefined;\n};\n\nconst spreadObject = (\n\texpression: ts.Expression,\n\tchecker: ts.TypeChecker,\n\tbindings: ReadonlyMap<string, string>\n) => {\n\tif (ts.isObjectLiteralExpression(expression)) {\n\t\treturn { bindings, object: expression };\n\t}\n\tif (!ts.isCallExpression(expression)) return undefined;\n\n\treturn callableObject(expression, checker);\n};\n\nconst objectAssetKey = (\n\tobject: ts.ObjectLiteralExpression,\n\tname: string,\n\tchecker: ts.TypeChecker,\n\tbindings: ReadonlyMap<string, string> = new Map()\n): string | undefined => {\n\tfor (const property of [...object.properties].reverse()) {\n\t\tif (\n\t\t\tpropertyName(property) === name &&\n\t\t\tts.isShorthandPropertyAssignment(property)\n\t\t) {\n\t\t\treturn assetKeyWithBindings(property.name, checker, bindings);\n\t\t}\n\t\tif (\n\t\t\tpropertyName(property) === name &&\n\t\t\tts.isPropertyAssignment(property)\n\t\t) {\n\t\t\treturn assetKeyWithBindings(\n\t\t\t\tproperty.initializer,\n\t\t\t\tchecker,\n\t\t\t\tbindings\n\t\t\t);\n\t\t}\n\t\tif (!ts.isSpreadAssignment(property)) continue;\n\t\tconst nestedObject = spreadObject(\n\t\t\tproperty.expression,\n\t\t\tchecker,\n\t\t\tbindings\n\t\t);\n\t\tif (!nestedObject) continue;\n\t\tconst nested = objectAssetKey(\n\t\t\tnestedObject.object,\n\t\t\tname,\n\t\t\tchecker,\n\t\t\tnestedObject.bindings\n\t\t);\n\t\tif (nested) return nested;\n\t}\n\n\treturn undefined;\n};\n\nconst findPageCall = (nodes: readonly ts.Node[]) => {\n\tlet found:\n\t\t| { definition: PageHandlerDefinition; node: ts.CallExpression }\n\t\t| undefined;\n\tconst visit = (candidate: ts.Node) => {\n\t\tif (found) return;\n\t\tif (\n\t\t\tts.isCallExpression(candidate) &&\n\t\t\tts.isIdentifier(candidate.expression) &&\n\t\t\tPAGE_HANDLERS.has(candidate.expression.text)\n\t\t) {\n\t\t\tconst definition = PAGE_HANDLERS.get(candidate.expression.text);\n\t\t\tif (!definition) return;\n\t\t\tfound = { definition, node: candidate };\n\n\t\t\treturn;\n\t\t}\n\t\tts.forEachChild(candidate, visit);\n\t};\n\tfor (const node of nodes) visit(node);\n\n\treturn found;\n};\n\nconst isProjectSource = (\n\tsourceFile: ts.SourceFile,\n\tresolvedFile: string,\n\tprojectRoot: string\n) =>\n\t!sourceFile.isDeclarationFile &&\n\t!resolvedFile.includes('/node_modules/') &&\n\tresolvedFile.startsWith(`${projectRoot}/`);\n\nconst analyzeRouteCall = (\n\tnode: ts.CallExpression,\n\tsourceFile: ts.SourceFile,\n\tchecker: ts.TypeChecker,\n\tprojectRoot: string\n) => {\n\tconst callee = node.expression;\n\tif (!ts.isPropertyAccessExpression(callee)) return undefined;\n\tif (!ROUTE_METHODS.has(callee.name.text)) return undefined;\n\tconst [routePath] = node.arguments;\n\tif (!routePath || !ts.isStringLiteralLike(routePath)) return undefined;\n\tconst foundPageCall = findPageCall(node.arguments.slice(1));\n\tconst pageCall = foundPageCall?.node;\n\tconst definition = foundPageCall?.definition;\n\tconst [input] = pageCall?.arguments ?? [];\n\tif (!pageCall || !input) {\n\t\treturn undefined;\n\t}\n\tif (!definition) return undefined;\n\tif (definition.inputKind === 'static') {\n\t\tconst bundleKey = assetKey(input, checker);\n\t\tif (!bundleKey) return undefined;\n\t\tconst pageId = `${definition.framework}:${bundleKey}`;\n\t\tconst propsSchemaHash = hashAbsoluteMobilePropsSchema({\n\t\t\tproperties: {},\n\t\t\ttype: 'object'\n\t\t});\n\n\t\treturn {\n\t\t\tinputKind: 'static',\n\t\t\tmetadata: {\n\t\t\t\tbundleKey,\n\t\t\t\tcontract: `${definition.framework}:${pageId}:${propsSchemaHash}`,\n\t\t\t\tframework: definition.framework,\n\t\t\t\tpageId,\n\t\t\t\tpropsSchemaHash\n\t\t\t},\n\t\t\tpageCallStart: pageCall.getStart(sourceFile),\n\t\t\trouteCallSpan: `${node.getStart(sourceFile)}:${node.end}`\n\t\t} satisfies AnalyzedPageCall;\n\t}\n\tif (!ts.isObjectLiteralExpression(input) || !definition.bundleProperty) {\n\t\treturn undefined;\n\t}\n\tconst page = definition.pageProperty\n\t\t? objectPropertyExpression(input, definition.pageProperty)\n\t\t: undefined;\n\tconst source = definition.sourceProperty\n\t\t? objectAssetKey(input, definition.sourceProperty, checker)\n\t\t: undefined;\n\tif (definition.pageProperty && !page) return undefined;\n\tif (definition.sourceProperty && !source) return undefined;\n\tconst props = objectPropertyExpression(input, definition.propsProperty);\n\tconst bundleKey = objectAssetKey(input, definition.bundleProperty, checker);\n\tif (!bundleKey) return undefined;\n\tconst pageId = page\n\t\t? resolvePageIdentity(page, sourceFile, checker, projectRoot)\n\t\t: `${definition.framework}:${source}`;\n\tlet propsType: ts.Type | undefined;\n\tif (page) propsType = pagePropsType(page, props, checker);\n\telse if (props) propsType = checker.getTypeAtLocation(props);\n\tconst schema = propsType\n\t\t? serializeType(propsType, checker)\n\t\t: { properties: {}, type: 'object' };\n\tconst propsSchemaHash = hashAbsoluteMobilePropsSchema(schema);\n\tconst metadata: AbsoluteMobileBuildPageMetadata = {\n\t\tbundleKey,\n\t\tcontract: `${definition.framework}:${pageId}:${propsSchemaHash}`,\n\t\tframework: definition.framework,\n\t\tpageId,\n\t\tpropsSchemaHash\n\t};\n\tconst result: AnalyzedPageCall = {\n\t\tinputKind: 'object',\n\t\tmetadata,\n\t\tpageCallStart: pageCall.getStart(sourceFile),\n\t\trouteCallSpan: `${node.getStart(sourceFile)}:${node.end}`\n\t};\n\n\treturn result;\n};\n\nconst analyzeSourceFile = (\n\tsourceFile: ts.SourceFile,\n\tchecker: ts.TypeChecker,\n\tprojectRoot: string\n) => {\n\tconst analysis: AnalyzedFile = {\n\t\tbyPageCall: new Map(),\n\t\tbyRouteCall: new Map()\n\t};\n\tconst visit = (node: ts.Node) => {\n\t\tconst result = ts.isCallExpression(node)\n\t\t\t? analyzeRouteCall(node, sourceFile, checker, projectRoot)\n\t\t\t: undefined;\n\t\tif (result) {\n\t\t\tanalysis.byPageCall.set(result.pageCallStart, result);\n\t\t\tanalysis.byRouteCall.set(result.routeCallSpan, result);\n\t\t}\n\t\tts.forEachChild(node, visit);\n\t};\n\tts.forEachChild(sourceFile, visit);\n\n\treturn analysis;\n};\n\nconst analyzeProgram = (program: ts.Program, projectRoot: string) => {\n\tconst checker = program.getTypeChecker();\n\tconst analyzed = new Map<string, AnalyzedFile>();\n\tfor (const sourceFile of program.getSourceFiles()) {\n\t\tconst resolvedFile = resolve(sourceFile.fileName);\n\t\tif (!isProjectSource(sourceFile, resolvedFile, projectRoot)) continue;\n\t\tconst analysis = analyzeSourceFile(sourceFile, checker, projectRoot);\n\t\tif (analysis.byPageCall.size > 0) analyzed.set(resolvedFile, analysis);\n\t}\n\n\treturn analyzed;\n};\n\nconst metadataExpression = (metadata: AbsoluteMobileBuildPageMetadata) =>\n\tts.factory.createObjectLiteralExpression(\n\t\tObject.entries(metadata).map(([key, item]) =>\n\t\t\tts.factory.createPropertyAssignment(\n\t\t\t\tts.factory.createStringLiteral(key),\n\t\t\t\tts.factory.createStringLiteral(item)\n\t\t\t)\n\t\t),\n\t\tfalse\n\t);\n\nconst routeOptions = (\n\texisting: ts.Expression | undefined,\n\tmetadata: AbsoluteMobileBuildPageMetadata\n) => {\n\tconst detail = ts.factory.createObjectLiteralExpression([\n\t\tts.factory.createPropertyAssignment(\n\t\t\tts.factory.createStringLiteral(ABSOLUTE_MOBILE_ROUTE_DETAIL),\n\t\t\tmetadataExpression(metadata)\n\t\t)\n\t]);\n\tif (!existing) {\n\t\treturn ts.factory.createObjectLiteralExpression([\n\t\t\tts.factory.createPropertyAssignment('detail', detail)\n\t\t]);\n\t}\n\n\treturn ts.factory.createObjectLiteralExpression([\n\t\tts.factory.createSpreadAssignment(existing),\n\t\tts.factory.createPropertyAssignment(\n\t\t\t'detail',\n\t\t\tts.factory.createObjectLiteralExpression([\n\t\t\t\tts.factory.createSpreadAssignment(\n\t\t\t\t\tts.factory.createPropertyAccessExpression(\n\t\t\t\t\t\texisting,\n\t\t\t\t\t\t'detail'\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t\tts.factory.createPropertyAssignment(\n\t\t\t\t\tts.factory.createStringLiteral(\n\t\t\t\t\t\tABSOLUTE_MOBILE_ROUTE_DETAIL\n\t\t\t\t\t),\n\t\t\t\t\tmetadataExpression(metadata)\n\t\t\t\t)\n\t\t\t])\n\t\t)\n\t]);\n};\n\nconst transformPageCall = (\n\tnode: ts.CallExpression,\n\tpage: AnalyzedPageCall | undefined\n) => {\n\tif (!page) return undefined;\n\tif (page.inputKind === 'static') {\n\t\tconst [pagePath, existingOptions, ...rest] = node.arguments;\n\t\tif (!pagePath) return undefined;\n\t\tconst options = ts.factory.createObjectLiteralExpression([\n\t\t\t...(existingOptions\n\t\t\t\t? [ts.factory.createSpreadAssignment(existingOptions)]\n\t\t\t\t: []),\n\t\t\tts.factory.createPropertyAssignment(\n\t\t\t\t'__absoluteMobile',\n\t\t\t\tmetadataExpression(page.metadata)\n\t\t\t)\n\t\t]);\n\n\t\treturn ts.factory.updateCallExpression(\n\t\t\tnode,\n\t\t\tnode.expression,\n\t\t\tnode.typeArguments,\n\t\t\t[pagePath, options, ...rest]\n\t\t);\n\t}\n\tconst [input] = node.arguments;\n\tif (!input || !ts.isObjectLiteralExpression(input)) return undefined;\n\n\treturn ts.factory.updateCallExpression(\n\t\tnode,\n\t\tnode.expression,\n\t\tnode.typeArguments,\n\t\t[\n\t\t\tts.factory.updateObjectLiteralExpression(input, [\n\t\t\t\t...input.properties,\n\t\t\t\tts.factory.createPropertyAssignment(\n\t\t\t\t\t'__absoluteMobile',\n\t\t\t\t\tmetadataExpression(page.metadata)\n\t\t\t\t)\n\t\t\t]),\n\t\t\t...node.arguments.slice(1)\n\t\t]\n\t);\n};\n\nconst transformRouteCall = (\n\tnode: ts.CallExpression,\n\troute: AnalyzedPageCall | undefined\n) => {\n\tif (!route) return undefined;\n\tconst [path, maybeOptions, maybeHandler, ...rest] = node.arguments;\n\tif (!path || !maybeOptions) return undefined;\n\tconst options = maybeHandler ? maybeOptions : undefined;\n\tconst handler = maybeHandler ?? maybeOptions;\n\n\treturn ts.factory.updateCallExpression(\n\t\tnode,\n\t\tnode.expression,\n\t\tnode.typeArguments,\n\t\t[path, routeOptions(options, route.metadata), handler, ...rest]\n\t);\n};\n\nconst transformFile = (\n\tsource: string,\n\tfileName: string,\n\tanalysis: AnalyzedFile\n) => {\n\tconst sourceFile = ts.createSourceFile(\n\t\tfileName,\n\t\tsource,\n\t\tts.ScriptTarget.Latest,\n\t\ttrue,\n\t\tfileName.endsWith('x') ? ts.ScriptKind.TSX : ts.ScriptKind.TS\n\t);\n\tconst transformer: ts.TransformerFactory<ts.SourceFile> = (context) => {\n\t\tconst visit: ts.Visitor = (node) => {\n\t\t\tif (!ts.isCallExpression(node)) {\n\t\t\t\treturn ts.visitEachChild(node, visit, context);\n\t\t\t}\n\t\t\tconst transformedChildren = ts.visitEachChild(node, visit, context);\n\t\t\tconst page = analysis.byPageCall.get(node.getStart(sourceFile));\n\t\t\tconst transformedPage = transformPageCall(\n\t\t\t\ttransformedChildren,\n\t\t\t\tpage\n\t\t\t);\n\t\t\tif (transformedPage) return transformedPage;\n\t\t\tconst route = analysis.byRouteCall.get(\n\t\t\t\t`${node.getStart(sourceFile)}:${node.end}`\n\t\t\t);\n\t\t\tconst transformedRoute = transformRouteCall(\n\t\t\t\ttransformedChildren,\n\t\t\t\troute\n\t\t\t);\n\t\t\tif (transformedRoute) return transformedRoute;\n\n\t\t\treturn transformedChildren;\n\t\t};\n\n\t\treturn (node) => ts.visitNode(node, visit, ts.isSourceFile) ?? node;\n\t};\n\tconst result = ts.transform(sourceFile, [transformer]);\n\ttry {\n\t\tconst [transformed] = result.transformed;\n\t\tif (!transformed) throw new TypeError('Mobile route transform failed.');\n\n\t\treturn ts.createPrinter().printFile(transformed);\n\t} finally {\n\t\tresult.dispose();\n\t}\n};\n\nexport const ABSOLUTE_MOBILE_TRANSFORM_PROTOCOL =\n\tABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION;\nexport const createAbsoluteMobileRouteMetadataPlugin = (\n\toptions: MobileRouteTransformOptions\n): BunPlugin => {\n\tconst projectRoot = resolve(options.projectRoot ?? process.cwd());\n\tconst entry = resolve(options.entry);\n\tconst analyzed = analyzeProgram(\n\t\tcreateProgram(entry, projectRoot),\n\t\tprojectRoot\n\t);\n\n\treturn {\n\t\tname: 'absolute-mobile-route-metadata',\n\t\tsetup(build) {\n\t\t\tbuild.onLoad({ filter: SOURCE_FILTER }, async ({ path }) => {\n\t\t\t\tconst analysis = analyzed.get(resolve(path));\n\t\t\t\tif (!analysis) return undefined;\n\t\t\t\tconst source = await Bun.file(path).text();\n\n\t\t\t\treturn {\n\t\t\t\t\tcontents: transformFile(source, path, analysis),\n\t\t\t\t\tloader: extname(path).endsWith('x') ? 'tsx' : 'ts'\n\t\t\t\t};\n\t\t\t});\n\t\t}\n\t};\n};\nexport const inspectAbsoluteMobileRouteMetadata = (\n\toptions: MobileRouteTransformOptions\n) => {\n\tconst projectRoot = resolve(options.projectRoot ?? process.cwd());\n\tconst entry = resolve(options.entry);\n\tconst analyzed = analyzeProgram(\n\t\tcreateProgram(entry, projectRoot),\n\t\tprojectRoot\n\t);\n\n\treturn [...analyzed.entries()].flatMap(([file, analysis]) =>\n\t\t[...analysis.byRouteCall.values()].map(({ metadata }) => ({\n\t\t\tfile: posixPath(relative(projectRoot, file)),\n\t\t\tmetadata\n\t\t}))\n\t);\n};\n"
|
|
56
|
+
"import { existsSync, readFileSync } from 'node:fs';\nimport { dirname, extname, relative, resolve } from 'node:path';\nimport type { BunPlugin } from 'bun';\nimport ts from 'typescript';\nimport { ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION } from './pageProtocol';\nimport { hashAbsoluteMobilePropsSchema } from './releaseArtifact';\nimport {\n\tABSOLUTE_MOBILE_ROUTE_DETAIL,\n\ttype AbsoluteMobileBuildPageMetadata\n} from './buildMetadata';\n\ntype MobileRouteTransformOptions = {\n\tentry: string;\n\tprojectRoot?: string;\n};\n\ntype AnalyzedPageCall = {\n\tinputKind: 'object' | 'static';\n\tmetadata: AbsoluteMobileBuildPageMetadata;\n\tpageCallStart: number;\n\trouteCallSpan: string;\n};\n\ntype AnalyzedFile = {\n\tbyPageCall: Map<number, AnalyzedPageCall>;\n\tbyRouteCall: Map<string, AnalyzedPageCall>;\n};\n\ntype PageHandlerDefinition = {\n\tbundleProperty?: 'index' | 'indexPath';\n\tframework: AbsoluteMobileBuildPageMetadata['framework'];\n\tinputKind?: 'static';\n\tpageProperty?: 'Page';\n\tpropsProperty: 'props' | 'requestContext';\n\tsourceProperty?: 'pagePath';\n};\n\ntype AssetKeyResolver = (\n\texpression: ts.Expression | undefined,\n\tchecker: ts.TypeChecker,\n\tseen?: Set<ts.Symbol>\n) => string | undefined;\n\nconst ROUTE_METHODS = new Set(['get', 'head']);\nconst SOURCE_FILTER = /\\.[cm]?[jt]sx?$/;\nconst PAGE_HANDLERS = new Map<string, PageHandlerDefinition>([\n\t[\n\t\t'handleHTMLPageRequest',\n\t\t{ framework: 'html', inputKind: 'static', propsProperty: 'props' }\n\t],\n\t[\n\t\t'handleHTMXPageRequest',\n\t\t{ framework: 'htmx', inputKind: 'static', propsProperty: 'props' }\n\t],\n\t[\n\t\t'handleAngularPageRequest',\n\t\t{\n\t\t\tbundleProperty: 'indexPath',\n\t\t\tframework: 'angular',\n\t\t\tpropsProperty: 'requestContext',\n\t\t\tsourceProperty: 'pagePath'\n\t\t}\n\t],\n\t[\n\t\t'handleReactPageRequest',\n\t\t{\n\t\t\tbundleProperty: 'index',\n\t\t\tframework: 'react',\n\t\t\tpageProperty: 'Page',\n\t\t\tpropsProperty: 'props'\n\t\t}\n\t],\n\t[\n\t\t'handleSveltePageRequest',\n\t\t{\n\t\t\tbundleProperty: 'indexPath',\n\t\t\tframework: 'svelte',\n\t\t\tpropsProperty: 'props',\n\t\t\tsourceProperty: 'pagePath'\n\t\t}\n\t],\n\t[\n\t\t'handleVuePageRequest',\n\t\t{\n\t\t\tbundleProperty: 'indexPath',\n\t\t\tframework: 'vue',\n\t\t\tpropsProperty: 'props',\n\t\t\tsourceProperty: 'pagePath'\n\t\t}\n\t]\n]);\n\nconst posixPath = (value: string) => value.replace(/\\\\/g, '/');\n\nconst findTsconfig = (entry: string, projectRoot: string) =>\n\tts.findConfigFile(dirname(entry), existsSync, 'tsconfig.json') ??\n\tts.findConfigFile(projectRoot, existsSync, 'tsconfig.json');\n\nconst createProgram = (entry: string, projectRoot: string) => {\n\tconst configPath = findTsconfig(entry, projectRoot);\n\tif (!configPath) {\n\t\treturn ts.createProgram([entry], {\n\t\t\tallowJs: true,\n\t\t\tjsx: ts.JsxEmit.ReactJSX,\n\t\t\tmodule: ts.ModuleKind.ESNext,\n\t\t\tmoduleResolution: ts.ModuleResolutionKind.Bundler,\n\t\t\ttarget: ts.ScriptTarget.ESNext\n\t\t});\n\t}\n\n\tconst parsed = ts.parseJsonConfigFileContent(\n\t\tts.readConfigFile(configPath, (path) => readFileSync(path, 'utf8'))\n\t\t\t.config,\n\t\tts.sys,\n\t\tdirname(configPath)\n\t);\n\tif (!parsed.fileNames.includes(entry)) parsed.fileNames.push(entry);\n\n\treturn ts.createProgram(parsed.fileNames, parsed.options);\n};\n\nconst propertyName = (property: ts.ObjectLiteralElementLike) => {\n\tif (!('name' in property) || !property.name) return undefined;\n\tif (ts.isIdentifier(property.name)) return property.name.text;\n\tif (ts.isStringLiteralLike(property.name)) return property.name.text;\n\n\treturn undefined;\n};\n\nconst objectPropertyExpression = (\n\tobject: ts.ObjectLiteralExpression,\n\tname: string\n) => {\n\tconst property = object.properties.find(\n\t\t(candidate) => propertyName(candidate) === name\n\t);\n\tif (property && ts.isPropertyAssignment(property)) {\n\t\treturn property.initializer;\n\t}\n\tif (property && ts.isShorthandPropertyAssignment(property)) {\n\t\treturn property.name;\n\t}\n\n\treturn undefined;\n};\n\nconst serializeType = (\n\ttype: ts.Type,\n\tchecker: ts.TypeChecker,\n\tancestors = new Set<ts.Type>()\n): unknown => {\n\tif (type.flags & ts.TypeFlags.Any) return { type: 'any' };\n\tif (type.flags & ts.TypeFlags.Unknown) return { type: 'unknown' };\n\tif (type.flags & ts.TypeFlags.Never) return { type: 'never' };\n\tif (type.flags & ts.TypeFlags.StringLike) return { type: 'string' };\n\tif (type.flags & ts.TypeFlags.NumberLike) return { type: 'number' };\n\tif (type.flags & ts.TypeFlags.BooleanLike) return { type: 'boolean' };\n\tif (type.flags & ts.TypeFlags.BigIntLike) return { type: 'bigint' };\n\tif (type.flags & ts.TypeFlags.Null) return { type: 'null' };\n\tif (type.flags & ts.TypeFlags.Undefined) return { type: 'undefined' };\n\tif (type.isUnion()) {\n\t\treturn {\n\t\t\tanyOf: type.types\n\t\t\t\t.map((member) => serializeType(member, checker, ancestors))\n\t\t\t\t.sort((left, right) =>\n\t\t\t\t\tJSON.stringify(left).localeCompare(JSON.stringify(right))\n\t\t\t\t)\n\t\t};\n\t}\n\tif (type.isIntersection()) {\n\t\treturn {\n\t\t\tallOf: type.types\n\t\t\t\t.map((member) => serializeType(member, checker, ancestors))\n\t\t\t\t.sort((left, right) =>\n\t\t\t\t\tJSON.stringify(left).localeCompare(JSON.stringify(right))\n\t\t\t\t)\n\t\t};\n\t}\n\tif (ancestors.has(type)) {\n\t\treturn {\n\t\t\tref: checker.typeToString(\n\t\t\t\ttype,\n\t\t\t\tundefined,\n\t\t\t\tts.TypeFormatFlags.NoTruncation\n\t\t\t)\n\t\t};\n\t}\n\n\tancestors.add(type);\n\tconst arrayElement = checker.getIndexTypeOfType(type, ts.IndexKind.Number);\n\tconst properties = checker.getPropertiesOfType(type);\n\tlet schema: unknown;\n\tif (arrayElement && properties.some(({ name }) => name === 'length')) {\n\t\tschema = {\n\t\t\titems: serializeType(arrayElement, checker, ancestors),\n\t\t\ttype: 'array'\n\t\t};\n\t} else if (properties.length > 0) {\n\t\tconst entries = properties\n\t\t\t.filter(({ name }) => !name.startsWith('__'))\n\t\t\t.map((property) => {\n\t\t\t\tconst declaration =\n\t\t\t\t\tproperty.valueDeclaration ?? property.declarations?.[0];\n\t\t\t\tconst propertyType = declaration\n\t\t\t\t\t? checker.getTypeOfSymbolAtLocation(property, declaration)\n\t\t\t\t\t: checker.getDeclaredTypeOfSymbol(property);\n\n\t\t\t\treturn [\n\t\t\t\t\tproperty.name,\n\t\t\t\t\t{\n\t\t\t\t\t\toptional: Boolean(\n\t\t\t\t\t\t\tproperty.flags & ts.SymbolFlags.Optional\n\t\t\t\t\t\t),\n\t\t\t\t\t\tschema: serializeType(propertyType, checker, ancestors)\n\t\t\t\t\t}\n\t\t\t\t] as const;\n\t\t\t})\n\t\t\t.sort(([left], [right]) => left.localeCompare(right));\n\t\tschema = { properties: Object.fromEntries(entries), type: 'object' };\n\t} else {\n\t\tschema = {\n\t\t\ttype: checker.typeToString(\n\t\t\t\ttype,\n\t\t\t\tundefined,\n\t\t\t\tts.TypeFormatFlags.NoTruncation\n\t\t\t)\n\t\t};\n\t}\n\tancestors.delete(type);\n\n\treturn schema;\n};\n\nconst pagePropsType = (\n\tpageExpression: ts.Expression,\n\tpropsExpression: ts.Expression | undefined,\n\tchecker: ts.TypeChecker\n) => {\n\tconst pageType = checker.getTypeAtLocation(pageExpression);\n\tconst [signature] = pageType.getCallSignatures();\n\tconst [parameter] = signature?.parameters ?? [];\n\tconst declaration =\n\t\tparameter?.valueDeclaration ?? parameter?.declarations?.[0];\n\tif (parameter && declaration) {\n\t\treturn checker.getTypeOfSymbolAtLocation(parameter, declaration);\n\t}\n\n\treturn propsExpression\n\t\t? checker.getTypeAtLocation(propsExpression)\n\t\t: checker.getTypeAtLocation(pageExpression);\n};\n\nconst resolvePageIdentity = (\n\texpression: ts.Expression,\n\tsourceFile: ts.SourceFile,\n\tchecker: ts.TypeChecker,\n\tprojectRoot: string\n) => {\n\tlet symbol = checker.getSymbolAtLocation(expression);\n\tif (symbol?.flags && symbol.flags & ts.SymbolFlags.Alias) {\n\t\tsymbol = checker.getAliasedSymbol(symbol);\n\t}\n\tconst declaration = symbol?.declarations?.[0];\n\tconst file = declaration?.getSourceFile().fileName ?? sourceFile.fileName;\n\tconst exportedName = symbol?.name ?? expression.getText(sourceFile);\n\tconst source = posixPath(relative(projectRoot, file));\n\n\treturn `${source}#${exportedName}`;\n};\n\nconst resolveAlias = (symbol: ts.Symbol, checker: ts.TypeChecker) => {\n\tif (!(symbol.flags & ts.SymbolFlags.Alias)) return symbol;\n\n\treturn checker.getAliasedSymbol(symbol);\n};\n\nconst assetKey: AssetKeyResolver = (\n\texpression,\n\tchecker,\n\tseen = new Set<ts.Symbol>()\n) => {\n\tif (!expression) return undefined;\n\n\tif (ts.isIdentifier(expression)) {\n\t\tconst unresolved = ts.isShorthandPropertyAssignment(expression.parent)\n\t\t\t? checker.getShorthandAssignmentValueSymbol(expression.parent)\n\t\t\t: checker.getSymbolAtLocation(expression);\n\t\tif (!unresolved) return undefined;\n\t\tconst symbol = resolveAlias(unresolved, checker);\n\t\tif (seen.has(symbol)) return undefined;\n\t\tseen.add(symbol);\n\t\tconst declaration = symbol.valueDeclaration ?? symbol.declarations?.[0];\n\t\tif (!declaration || !ts.isVariableDeclaration(declaration))\n\t\t\treturn undefined;\n\n\t\treturn assetKey(declaration.initializer, checker, seen);\n\t}\n\n\tif (!ts.isCallExpression(expression)) return undefined;\n\tif (\n\t\t!ts.isIdentifier(expression.expression) ||\n\t\texpression.expression.text !== 'asset'\n\t) {\n\t\treturn undefined;\n\t}\n\tconst [, key] = expression.arguments;\n\n\treturn key && ts.isStringLiteralLike(key) ? key.text : undefined;\n};\n\nconst staticString = (\n\texpression: ts.Expression,\n\tbindings: ReadonlyMap<string, string>\n): string | undefined => {\n\tif (ts.isStringLiteralLike(expression)) return expression.text;\n\tif (ts.isIdentifier(expression)) return bindings.get(expression.text);\n\tif (ts.isNoSubstitutionTemplateLiteral(expression)) return expression.text;\n\tif (!ts.isTemplateExpression(expression)) return undefined;\n\tlet value = expression.head.text;\n\tfor (const span of expression.templateSpans) {\n\t\tconst substitution = staticString(span.expression, bindings);\n\t\tif (substitution === undefined) return undefined;\n\t\tvalue += substitution + span.literal.text;\n\t}\n\n\treturn value;\n};\n\nconst assetKeyWithBindings = (\n\texpression: ts.Expression | undefined,\n\tchecker: ts.TypeChecker,\n\tbindings: ReadonlyMap<string, string> = new Map()\n) => {\n\tif (!expression) return undefined;\n\tif (\n\t\tts.isCallExpression(expression) &&\n\t\tts.isIdentifier(expression.expression) &&\n\t\texpression.expression.text === 'asset'\n\t) {\n\t\tconst [, key] = expression.arguments;\n\n\t\treturn key ? staticString(key, bindings) : undefined;\n\t}\n\n\treturn assetKey(expression, checker);\n};\n\nconst callableObject = (call: ts.CallExpression, checker: ts.TypeChecker) => {\n\tconst symbol = checker.getSymbolAtLocation(call.expression);\n\tconst resolved = symbol ? resolveAlias(symbol, checker) : undefined;\n\tconst declaration =\n\t\tresolved?.valueDeclaration ?? resolved?.declarations?.[0];\n\tlet callable:\n\t\t| ts.ArrowFunction\n\t\t| ts.FunctionDeclaration\n\t\t| ts.FunctionExpression\n\t\t| undefined;\n\tif (declaration && ts.isFunctionDeclaration(declaration)) {\n\t\tcallable = declaration;\n\t} else if (\n\t\tdeclaration &&\n\t\tts.isVariableDeclaration(declaration) &&\n\t\tdeclaration.initializer &&\n\t\t(ts.isArrowFunction(declaration.initializer) ||\n\t\t\tts.isFunctionExpression(declaration.initializer))\n\t) {\n\t\tcallable = declaration.initializer;\n\t}\n\tif (!callable) return undefined;\n\tconst bindings = new Map<string, string>();\n\tcallable.parameters.forEach((parameter, index) => {\n\t\tif (!ts.isIdentifier(parameter.name)) return;\n\t\tconst argument = call.arguments[index];\n\t\tif (!argument) return;\n\t\tconst value = staticString(argument, new Map());\n\t\tif (value !== undefined) bindings.set(parameter.name.text, value);\n\t});\n\tconst { body } = callable;\n\tif (!body) return undefined;\n\tconst expressionBody = ts.isParenthesizedExpression(body)\n\t\t? body.expression\n\t\t: body;\n\tif (ts.isObjectLiteralExpression(expressionBody)) {\n\t\treturn { bindings, object: expressionBody };\n\t}\n\tif (ts.isBlock(body)) {\n\t\tconst returned = body.statements.find(ts.isReturnStatement)?.expression;\n\t\tif (returned && ts.isObjectLiteralExpression(returned)) {\n\t\t\treturn { bindings, object: returned };\n\t\t}\n\t}\n\n\treturn undefined;\n};\n\nconst spreadObject = (\n\texpression: ts.Expression,\n\tchecker: ts.TypeChecker,\n\tbindings: ReadonlyMap<string, string>\n) => {\n\tif (ts.isObjectLiteralExpression(expression)) {\n\t\treturn { bindings, object: expression };\n\t}\n\tif (!ts.isCallExpression(expression)) return undefined;\n\n\treturn callableObject(expression, checker);\n};\n\nconst objectAssetKey = (\n\tobject: ts.ObjectLiteralExpression,\n\tname: string,\n\tchecker: ts.TypeChecker,\n\tbindings: ReadonlyMap<string, string> = new Map()\n): string | undefined => {\n\tfor (const property of [...object.properties].reverse()) {\n\t\tif (\n\t\t\tpropertyName(property) === name &&\n\t\t\tts.isShorthandPropertyAssignment(property)\n\t\t) {\n\t\t\treturn assetKeyWithBindings(property.name, checker, bindings);\n\t\t}\n\t\tif (\n\t\t\tpropertyName(property) === name &&\n\t\t\tts.isPropertyAssignment(property)\n\t\t) {\n\t\t\treturn assetKeyWithBindings(\n\t\t\t\tproperty.initializer,\n\t\t\t\tchecker,\n\t\t\t\tbindings\n\t\t\t);\n\t\t}\n\t\tif (!ts.isSpreadAssignment(property)) continue;\n\t\tconst nestedObject = spreadObject(\n\t\t\tproperty.expression,\n\t\t\tchecker,\n\t\t\tbindings\n\t\t);\n\t\tif (!nestedObject) continue;\n\t\tconst nested = objectAssetKey(\n\t\t\tnestedObject.object,\n\t\t\tname,\n\t\t\tchecker,\n\t\t\tnestedObject.bindings\n\t\t);\n\t\tif (nested) return nested;\n\t}\n\n\treturn undefined;\n};\n\nconst findPageCall = (nodes: readonly ts.Node[]) => {\n\tlet found:\n\t\t| { definition: PageHandlerDefinition; node: ts.CallExpression }\n\t\t| undefined;\n\tconst visit = (candidate: ts.Node) => {\n\t\tif (found) return;\n\t\tif (\n\t\t\tts.isCallExpression(candidate) &&\n\t\t\tts.isIdentifier(candidate.expression) &&\n\t\t\tPAGE_HANDLERS.has(candidate.expression.text)\n\t\t) {\n\t\t\tconst definition = PAGE_HANDLERS.get(candidate.expression.text);\n\t\t\tif (!definition) return;\n\t\t\tfound = { definition, node: candidate };\n\n\t\t\treturn;\n\t\t}\n\t\tts.forEachChild(candidate, visit);\n\t};\n\tfor (const node of nodes) visit(node);\n\n\treturn found;\n};\n\nconst isProjectSource = (\n\tsourceFile: ts.SourceFile,\n\tresolvedFile: string,\n\tprojectRoot: string\n) =>\n\t!sourceFile.isDeclarationFile &&\n\t!resolvedFile.includes('/node_modules/') &&\n\tresolvedFile.startsWith(`${projectRoot}/`);\n\nconst analyzeRouteCall = (\n\tnode: ts.CallExpression,\n\tsourceFile: ts.SourceFile,\n\tchecker: ts.TypeChecker,\n\tprojectRoot: string\n) => {\n\tconst callee = node.expression;\n\tif (!ts.isPropertyAccessExpression(callee)) return undefined;\n\tif (!ROUTE_METHODS.has(callee.name.text)) return undefined;\n\tconst [routePath] = node.arguments;\n\tif (!routePath || !ts.isStringLiteralLike(routePath)) return undefined;\n\tconst foundPageCall = findPageCall(node.arguments.slice(1));\n\tconst pageCall = foundPageCall?.node;\n\tconst definition = foundPageCall?.definition;\n\tconst [input] = pageCall?.arguments ?? [];\n\tif (!pageCall || !input) {\n\t\treturn undefined;\n\t}\n\tif (!definition) return undefined;\n\tif (definition.inputKind === 'static') {\n\t\tconst bundleKey = assetKey(input, checker);\n\t\tif (!bundleKey) return undefined;\n\t\tconst pageId = `${definition.framework}:${bundleKey}`;\n\t\tconst propsSchemaHash = hashAbsoluteMobilePropsSchema({\n\t\t\tproperties: {},\n\t\t\ttype: 'object'\n\t\t});\n\n\t\treturn {\n\t\t\tinputKind: 'static',\n\t\t\tmetadata: {\n\t\t\t\tbundleKey,\n\t\t\t\tcontract: `${definition.framework}:${pageId}:${propsSchemaHash}`,\n\t\t\t\tframework: definition.framework,\n\t\t\t\tpageId,\n\t\t\t\tpropsSchemaHash\n\t\t\t},\n\t\t\tpageCallStart: pageCall.getStart(sourceFile),\n\t\t\trouteCallSpan: `${node.getStart(sourceFile)}:${node.end}`\n\t\t} satisfies AnalyzedPageCall;\n\t}\n\tif (!ts.isObjectLiteralExpression(input) || !definition.bundleProperty) {\n\t\treturn undefined;\n\t}\n\tconst page = definition.pageProperty\n\t\t? objectPropertyExpression(input, definition.pageProperty)\n\t\t: undefined;\n\tconst source = definition.sourceProperty\n\t\t? objectAssetKey(input, definition.sourceProperty, checker)\n\t\t: undefined;\n\tif (definition.pageProperty && !page) return undefined;\n\tif (definition.sourceProperty && !source) return undefined;\n\tconst props = objectPropertyExpression(input, definition.propsProperty);\n\tconst bundleKey = objectAssetKey(input, definition.bundleProperty, checker);\n\tif (!bundleKey) return undefined;\n\tconst pageId = page\n\t\t? resolvePageIdentity(page, sourceFile, checker, projectRoot)\n\t\t: `${definition.framework}:${source}`;\n\tlet propsType: ts.Type | undefined;\n\tif (page) propsType = pagePropsType(page, props, checker);\n\telse if (props) propsType = checker.getTypeAtLocation(props);\n\tconst schema = propsType\n\t\t? serializeType(propsType, checker)\n\t\t: { properties: {}, type: 'object' };\n\tconst propsSchemaHash = hashAbsoluteMobilePropsSchema(schema);\n\tconst metadata: AbsoluteMobileBuildPageMetadata = {\n\t\tbundleKey,\n\t\tcontract: `${definition.framework}:${pageId}:${propsSchemaHash}`,\n\t\tframework: definition.framework,\n\t\tpageId,\n\t\tpropsSchemaHash\n\t};\n\tconst result: AnalyzedPageCall = {\n\t\tinputKind: 'object',\n\t\tmetadata,\n\t\tpageCallStart: pageCall.getStart(sourceFile),\n\t\trouteCallSpan: `${node.getStart(sourceFile)}:${node.end}`\n\t};\n\n\treturn result;\n};\n\nconst analyzeSourceFile = (\n\tsourceFile: ts.SourceFile,\n\tchecker: ts.TypeChecker,\n\tprojectRoot: string\n) => {\n\tconst analysis: AnalyzedFile = {\n\t\tbyPageCall: new Map(),\n\t\tbyRouteCall: new Map()\n\t};\n\tconst visit = (node: ts.Node) => {\n\t\tconst result = ts.isCallExpression(node)\n\t\t\t? analyzeRouteCall(node, sourceFile, checker, projectRoot)\n\t\t\t: undefined;\n\t\tif (result) {\n\t\t\tanalysis.byPageCall.set(result.pageCallStart, result);\n\t\t\tanalysis.byRouteCall.set(result.routeCallSpan, result);\n\t\t}\n\t\tts.forEachChild(node, visit);\n\t};\n\tts.forEachChild(sourceFile, visit);\n\n\treturn analysis;\n};\n\nconst analyzeProgram = (program: ts.Program, projectRoot: string) => {\n\tconst checker = program.getTypeChecker();\n\tconst analyzed = new Map<string, AnalyzedFile>();\n\tfor (const sourceFile of program.getSourceFiles()) {\n\t\tconst resolvedFile = resolve(sourceFile.fileName);\n\t\tif (!isProjectSource(sourceFile, resolvedFile, projectRoot)) continue;\n\t\tconst analysis = analyzeSourceFile(sourceFile, checker, projectRoot);\n\t\tif (analysis.byPageCall.size > 0) analyzed.set(resolvedFile, analysis);\n\t}\n\n\treturn analyzed;\n};\n\nconst metadataExpression = (metadata: AbsoluteMobileBuildPageMetadata) =>\n\tts.factory.createObjectLiteralExpression(\n\t\tObject.entries(metadata).map(([key, item]) =>\n\t\t\tts.factory.createPropertyAssignment(\n\t\t\t\tts.factory.createStringLiteral(key),\n\t\t\t\tts.factory.createStringLiteral(item)\n\t\t\t)\n\t\t),\n\t\tfalse\n\t);\n\nconst routeOptions = (\n\texisting: ts.Expression | undefined,\n\tmetadata: AbsoluteMobileBuildPageMetadata\n) => {\n\tconst detail = ts.factory.createObjectLiteralExpression([\n\t\tts.factory.createPropertyAssignment(\n\t\t\tts.factory.createStringLiteral(ABSOLUTE_MOBILE_ROUTE_DETAIL),\n\t\t\tmetadataExpression(metadata)\n\t\t)\n\t]);\n\tif (!existing) {\n\t\treturn ts.factory.createObjectLiteralExpression([\n\t\t\tts.factory.createPropertyAssignment('detail', detail)\n\t\t]);\n\t}\n\n\treturn ts.factory.createObjectLiteralExpression([\n\t\tts.factory.createSpreadAssignment(existing),\n\t\tts.factory.createPropertyAssignment(\n\t\t\t'detail',\n\t\t\tts.factory.createObjectLiteralExpression([\n\t\t\t\tts.factory.createSpreadAssignment(\n\t\t\t\t\tts.factory.createPropertyAccessExpression(\n\t\t\t\t\t\texisting,\n\t\t\t\t\t\t'detail'\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t\tts.factory.createPropertyAssignment(\n\t\t\t\t\tts.factory.createStringLiteral(\n\t\t\t\t\t\tABSOLUTE_MOBILE_ROUTE_DETAIL\n\t\t\t\t\t),\n\t\t\t\t\tmetadataExpression(metadata)\n\t\t\t\t)\n\t\t\t])\n\t\t)\n\t]);\n};\n\nconst transformPageCall = (\n\tnode: ts.CallExpression,\n\tpage: AnalyzedPageCall | undefined\n) => {\n\tif (!page) return undefined;\n\tif (page.inputKind === 'static') {\n\t\tconst [pagePath, existingOptions, ...rest] = node.arguments;\n\t\tif (!pagePath) return undefined;\n\t\tconst options = ts.factory.createObjectLiteralExpression([\n\t\t\t...(existingOptions\n\t\t\t\t? [ts.factory.createSpreadAssignment(existingOptions)]\n\t\t\t\t: []),\n\t\t\tts.factory.createPropertyAssignment(\n\t\t\t\t'__absoluteMobile',\n\t\t\t\tmetadataExpression(page.metadata)\n\t\t\t)\n\t\t]);\n\n\t\treturn ts.factory.updateCallExpression(\n\t\t\tnode,\n\t\t\tnode.expression,\n\t\t\tnode.typeArguments,\n\t\t\t[pagePath, options, ...rest]\n\t\t);\n\t}\n\tconst [input] = node.arguments;\n\tif (!input || !ts.isObjectLiteralExpression(input)) return undefined;\n\n\treturn ts.factory.updateCallExpression(\n\t\tnode,\n\t\tnode.expression,\n\t\tnode.typeArguments,\n\t\t[\n\t\t\tts.factory.updateObjectLiteralExpression(input, [\n\t\t\t\t...input.properties,\n\t\t\t\tts.factory.createPropertyAssignment(\n\t\t\t\t\t'__absoluteMobile',\n\t\t\t\t\tmetadataExpression(page.metadata)\n\t\t\t\t)\n\t\t\t]),\n\t\t\t...node.arguments.slice(1)\n\t\t]\n\t);\n};\n\nconst transformRouteCall = (\n\tnode: ts.CallExpression,\n\troute: AnalyzedPageCall | undefined\n) => {\n\tif (!route) return undefined;\n\tconst [path, maybeOptions, maybeHandler, ...rest] = node.arguments;\n\tif (!path || !maybeOptions) return undefined;\n\tconst options = maybeHandler ? maybeOptions : undefined;\n\tconst handler = maybeHandler ?? maybeOptions;\n\n\treturn ts.factory.updateCallExpression(\n\t\tnode,\n\t\tnode.expression,\n\t\tnode.typeArguments,\n\t\t[path, routeOptions(options, route.metadata), handler, ...rest]\n\t);\n};\n\nconst transformFile = (\n\tsource: string,\n\tfileName: string,\n\tanalysis: AnalyzedFile\n) => {\n\tconst sourceFile = ts.createSourceFile(\n\t\tfileName,\n\t\tsource,\n\t\tts.ScriptTarget.Latest,\n\t\ttrue,\n\t\tfileName.endsWith('x') ? ts.ScriptKind.TSX : ts.ScriptKind.TS\n\t);\n\tconst transformer: ts.TransformerFactory<ts.SourceFile> = (context) => {\n\t\tconst visit: ts.Visitor = (node) => {\n\t\t\tif (!ts.isCallExpression(node)) {\n\t\t\t\treturn ts.visitEachChild(node, visit, context);\n\t\t\t}\n\t\t\tconst transformedChildren = ts.visitEachChild(node, visit, context);\n\t\t\tconst page = analysis.byPageCall.get(node.getStart(sourceFile));\n\t\t\tconst transformedPage = transformPageCall(\n\t\t\t\ttransformedChildren,\n\t\t\t\tpage\n\t\t\t);\n\t\t\tif (transformedPage) return transformedPage;\n\t\t\tconst route = analysis.byRouteCall.get(\n\t\t\t\t`${node.getStart(sourceFile)}:${node.end}`\n\t\t\t);\n\t\t\tconst transformedRoute = transformRouteCall(\n\t\t\t\ttransformedChildren,\n\t\t\t\troute\n\t\t\t);\n\t\t\tif (transformedRoute) return transformedRoute;\n\n\t\t\treturn transformedChildren;\n\t\t};\n\n\t\treturn (node) => ts.visitNode(node, visit, ts.isSourceFile) ?? node;\n\t};\n\tconst result = ts.transform(sourceFile, [transformer]);\n\ttry {\n\t\tconst [transformed] = result.transformed;\n\t\tif (!transformed) throw new TypeError('Mobile route transform failed.');\n\n\t\treturn ts.createPrinter().printFile(transformed);\n\t} finally {\n\t\tresult.dispose();\n\t}\n};\n\nexport const ABSOLUTE_MOBILE_TRANSFORM_PROTOCOL =\n\tABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION;\nexport const createAbsoluteMobileRouteMetadataPlugin = (\n\toptions: MobileRouteTransformOptions\n): BunPlugin => {\n\tconst projectRoot = resolve(options.projectRoot ?? process.cwd());\n\tconst entry = resolve(options.entry);\n\tconst analyzed = analyzeProgram(\n\t\tcreateProgram(entry, projectRoot),\n\t\tprojectRoot\n\t);\n\n\treturn {\n\t\tname: 'absolute-mobile-route-metadata',\n\t\tsetup(build) {\n\t\t\tbuild.onLoad({ filter: SOURCE_FILTER }, async ({ path }) => {\n\t\t\t\tconst analysis = analyzed.get(resolve(path));\n\t\t\t\tif (!analysis) return undefined;\n\t\t\t\tconst source = await Bun.file(path).text();\n\n\t\t\t\treturn {\n\t\t\t\t\tcontents: transformFile(source, path, analysis),\n\t\t\t\t\tloader: extname(path).endsWith('x') ? 'tsx' : 'ts'\n\t\t\t\t};\n\t\t\t});\n\t\t}\n\t};\n};\nexport const inspectAbsoluteMobileRouteMetadata = (\n\toptions: MobileRouteTransformOptions\n) => {\n\tconst projectRoot = resolve(options.projectRoot ?? process.cwd());\n\tconst entry = resolve(options.entry);\n\tconst analyzed = analyzeProgram(\n\t\tcreateProgram(entry, projectRoot),\n\t\tprojectRoot\n\t);\n\n\treturn [...analyzed.entries()].flatMap(([file, analysis]) =>\n\t\t[...analysis.byRouteCall.values()].map(({ metadata }) => ({\n\t\t\tfile: posixPath(relative(projectRoot, file)),\n\t\t\tmetadata\n\t\t}))\n\t);\n};\n",
|
|
57
|
+
"// src/contracts.ts\nclass AbsoluteHttpError extends Error {\n code;\n cause;\n status;\n url;\n constructor(code, message, options = {}) {\n super(message);\n this.name = \"AbsoluteHttpError\";\n this.code = code;\n this.cause = options.cause;\n this.status = options.status;\n this.url = options.url;\n }\n}\n// src/url.ts\nvar loopbackHosts = new Set([\"127.0.0.1\", \"[::1]\", \"localhost\"]);\nvar normalizeAbsoluteHttpOrigin = (value) => {\n let url;\n try {\n url = new URL(value);\n } catch (cause) {\n throw new AbsoluteHttpError(\"origin\", \"HTTP origin is invalid.\", {\n cause\n });\n }\n const loopback = url.protocol === \"http:\" && loopbackHosts.has(url.hostname);\n if (url.protocol !== \"https:\" && !loopback)\n throw new AbsoluteHttpError(\"origin\", \"HTTP origin must use HTTPS outside loopback development.\");\n if (url.username || url.password || url.pathname !== \"/\" || url.search || url.hash)\n throw new AbsoluteHttpError(\"origin\", \"HTTP origin cannot contain credentials, a path, query, or fragment.\");\n return url.origin;\n};\nvar resolveAbsoluteHttpUrl = (target, origin) => {\n let url;\n try {\n url = new URL(String(target), `${origin}/`);\n } catch (cause) {\n throw new AbsoluteHttpError(\"origin\", \"HTTP request URL is invalid.\", {\n cause\n });\n }\n if (url.username || url.password)\n throw new AbsoluteHttpError(\"origin\", \"HTTP request URLs cannot contain credentials.\");\n if (url.origin !== origin)\n throw new AbsoluteHttpError(\"origin\", \"Absolute HTTP refused a request outside the configured application origin.\", { url: url.href });\n url.hash = \"\";\n return url;\n};\n\n// src/adapters.ts\nvar createAbsoluteHttpTransport = ({\n fetch: fetchImpl = globalThis.fetch,\n origin,\n runtime\n}) => ({\n fetch: fetchImpl,\n origin: normalizeAbsoluteHttpOrigin(origin),\n runtime\n});\nvar createWebHttpTransport = (options = {}) => {\n const origin = options.origin ?? globalThis.location?.origin;\n if (!origin)\n throw new TypeError(\"The web HTTP transport requires a browser origin or explicit origin.\");\n return createAbsoluteHttpTransport({\n ...options.fetch ? { fetch: options.fetch } : {},\n origin,\n runtime: \"web\"\n });\n};\n\n// src/runtime.ts\nvar RUNTIME_REGISTRY = Symbol.for(\"@absolutejs/http/runtime\");\nvar registryHost = globalThis;\nvar isRuntimeRegistry = (value) => typeof value === \"object\" && value !== null && Array.isArray(Reflect.get(value, \"installations\"));\nvar runtimeRegistry = (() => {\n const existing = registryHost[RUNTIME_REGISTRY];\n if (isRuntimeRegistry(existing))\n return existing;\n const created = { installations: [] };\n Object.defineProperty(registryHost, RUNTIME_REGISTRY, {\n configurable: false,\n enumerable: false,\n value: created,\n writable: false\n });\n return created;\n})();\nvar fallbackTransport = () => {\n if (typeof location !== \"undefined\" && location.origin)\n return createWebHttpTransport();\n throw new AbsoluteHttpError(\"not-configured\", \"Absolute HTTP requires a request-scoped SSR transport outside a browser.\");\n};\nvar getAbsoluteHttpTransport = () => runtimeRegistry.installations.at(-1)?.transport ?? (runtimeRegistry.fallback ??= fallbackTransport());\nvar installAbsoluteHttpTransport = (transport) => {\n const installation = { transport };\n runtimeRegistry.installations.push(installation);\n return () => {\n const index = runtimeRegistry.installations.indexOf(installation);\n if (index >= 0)\n runtimeRegistry.installations.splice(index, 1);\n };\n};\n\n// src/client.ts\nvar forbiddenCredentialHeaders = new Set([\n \"authorization\",\n \"cookie\",\n \"proxy-authorization\"\n]);\nvar transportFor = (configured) => configured ?? getAbsoluteHttpTransport();\nvar safeHeaders = (input) => {\n const headers = new Headers(input);\n for (const name of forbiddenCredentialHeaders) {\n if (headers.has(name))\n throw new AbsoluteHttpError(\"origin\", `Absolute HTTP owns the ${name} credential header for trusted transports.`);\n }\n return headers;\n};\nvar requestFor = (target, options, transport) => {\n const source = target instanceof Request ? target : undefined;\n const requestedUrl = source ? source.url : target;\n const url = resolveAbsoluteHttpUrl(requestedUrl, transport.origin);\n const headers = safeHeaders(options?.headers ?? source?.headers);\n return new Request(source ?? url, {\n ...options,\n credentials: transport.runtime === \"web\" ? \"same-origin\" : \"omit\",\n headers,\n redirect: \"error\"\n });\n};\nvar normalizeFetchError = (caught, url) => {\n if (caught instanceof AbsoluteHttpError)\n return caught;\n if (caught instanceof DOMException && (caught.name === \"AbortError\" || caught.name === \"TimeoutError\"))\n return new AbsoluteHttpError(\"aborted\", \"HTTP request was aborted.\", {\n cause: caught,\n url\n });\n return new AbsoluteHttpError(\"network\", \"HTTP request failed.\", {\n cause: caught,\n url\n });\n};\nvar requireOk = (response) => {\n if (!response.ok)\n throw new AbsoluteHttpError(\"http\", `HTTP request failed with status ${response.status}.`, { status: response.status, url: response.url });\n return response;\n};\nvar parseJson = async (response) => {\n const text = await response.text();\n if (text === \"\")\n return;\n try {\n return JSON.parse(text);\n } catch (cause) {\n throw new AbsoluteHttpError(\"response\", \"HTTP response is not valid JSON.\", {\n cause,\n status: response.status,\n url: response.url\n });\n }\n};\nvar jsonOptions = (method, body, options) => {\n const headers = new Headers(options?.headers);\n if (body !== undefined && !headers.has(\"content-type\"))\n headers.set(\"content-type\", \"application/json\");\n let encoded;\n try {\n encoded = body === undefined ? undefined : JSON.stringify(body);\n } catch (cause) {\n throw new AbsoluteHttpError(\"body\", \"HTTP body is not JSON serializable.\", {\n cause\n });\n }\n return encoded === undefined ? { ...options, headers, method } : { ...options, body: encoded, headers, method };\n};\nvar createAbsoluteHttpClient = (options = {}) => {\n const fetchTrusted = async (input, init) => {\n const transport = transportFor(options.transport);\n const request2 = requestFor(input, init, transport);\n try {\n return await transport.fetch(request2);\n } catch (caught) {\n throw normalizeFetchError(caught, request2.url);\n }\n };\n const request = (target, requestOptions) => fetchTrusted(target, requestOptions);\n const json = async (target, requestOptions) => parseJson(requireOk(await request(target, requestOptions)));\n const jsonMethod = (method, target, body, requestOptions) => json(target, jsonOptions(method, body, requestOptions));\n return {\n delete: (target, requestOptions) => {\n const { body, ...optionsWithoutBody } = requestOptions ?? {};\n return jsonMethod(\"DELETE\", target, body, optionsWithoutBody);\n },\n fetch: fetchTrusted,\n get: (target, requestOptions) => json(target, { ...requestOptions, method: \"GET\" }),\n json,\n origin: () => transportFor(options.transport).origin,\n patch: (target, body, requestOptions) => jsonMethod(\"PATCH\", target, body, requestOptions),\n post: (target, body, requestOptions) => jsonMethod(\"POST\", target, body, requestOptions),\n put: (target, body, requestOptions) => jsonMethod(\"PUT\", target, body, requestOptions),\n request,\n text: async (target, requestOptions) => requireOk(await request(target, requestOptions)).text()\n };\n};\nvar http = createAbsoluteHttpClient();\nexport {\n installAbsoluteHttpTransport,\n http,\n createAbsoluteHttpTransport,\n createAbsoluteHttpClient,\n AbsoluteHttpError\n};\n\n//# debugId=EEC17EF6030AA63A64756E2164756E21\n//# sourceMappingURL=index.js.map\n",
|
|
58
|
+
"import {\n\tcreateAbsoluteHttpTransport,\n\tinstallAbsoluteHttpTransport,\n\ttype AbsoluteHttpFetch\n} from '@absolutejs/http';\n\nexport const installAbsoluteMobileShellHttp = (\n\torigin: string,\n\tfetch: AbsoluteHttpFetch = globalThis.fetch\n) =>\n\tinstallAbsoluteHttpTransport(\n\t\tcreateAbsoluteHttpTransport({ fetch, origin, runtime: 'native' })\n\t);\n"
|
|
40
59
|
],
|
|
41
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAa,0BAA0B,KAC1B,mBAAmB,IACnB,qBAAqB,GACrB,cAAc,IACd,gBAAgB,IAChB,gCACZ,8CAMY,kCAEA,oBAAoB,MACpB,qBAAqB,MACrB,kBAAkB,GAClB,6BAA6B,IAC7B,yBAAyB,IACzB,2BAA2B,KAC3B,6BAA6B,KAC7B,qBAAqB,OACrB,sBAAsB,IACtB,eAAe,MACf,iCAAiC,KACjC,sBAAsB,IACtB,8BAA8B,GAC9B,yBAAyB,GACzB,0BAA0B,GAC1B,2BAA2B,GAC3B,6BAA6B,6BAC7B,6BAA6B,MAC7B,sB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