@absolutejs/absolute 0.20.0-beta.4 → 0.20.0-beta.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/README.md +200 -0
  2. package/dist/angular/browser.js +15 -1
  3. package/dist/angular/browser.js.map +3 -3
  4. package/dist/angular/components/core/streamingSlotRegistrar.js +1 -1
  5. package/dist/angular/components/core/streamingSlotRegistry.js +2 -2
  6. package/dist/angular/index.js +361 -30
  7. package/dist/angular/index.js.map +9 -6
  8. package/dist/angular/server.js +361 -30
  9. package/dist/angular/server.js.map +9 -6
  10. package/dist/build.js +2093 -1114
  11. package/dist/build.js.map +20 -16
  12. package/dist/cli/config/server.js +4 -0
  13. package/dist/cli/index.js +6235 -1278
  14. package/dist/dev/client/cssUtils.ts +16 -2
  15. package/dist/dev/client/handlers/rebuild.ts +11 -1
  16. package/dist/dev/client/hmrClient.ts +35 -3
  17. package/dist/dev/client/hmrTiming.ts +16 -7
  18. package/dist/dev/client/syncDevtools.ts +237 -0
  19. package/dist/dev/serverBootstrap.js +28 -0
  20. package/dist/index.js +2925 -1670
  21. package/dist/index.js.map +37 -31
  22. package/dist/mobile/browser.js +123 -1
  23. package/dist/mobile/browser.js.map +6 -4
  24. package/dist/mobile/index.js +4185 -294
  25. package/dist/mobile/index.js.map +38 -18
  26. package/dist/mobile/remoteMacAgentEntry.js +14 -14
  27. package/dist/mobile/shellAuth.js +36 -0
  28. package/dist/mobile/shellBootstrap.js +837 -0
  29. package/dist/mobile/shellExpoDevices.js +99 -0
  30. package/dist/mobile/shellSync.js +173 -0
  31. package/dist/react/index.js +5 -1
  32. package/dist/react/index.js.map +3 -3
  33. package/dist/react/server.js +5 -1
  34. package/dist/react/server.js.map +3 -3
  35. package/dist/src/angular/pageHandler.d.ts +3 -0
  36. package/dist/src/build/pwa.d.ts +16 -0
  37. package/dist/src/cli/config/server.d.ts +1 -1
  38. package/dist/src/cli/instanceStatus.d.ts +1 -0
  39. package/dist/src/cli/scripts/dev.d.ts +2 -0
  40. package/dist/src/core/devBuild.d.ts +1 -0
  41. package/dist/src/core/pageHandlers.d.ts +11 -2
  42. package/dist/src/core/prepare.d.ts +376 -0
  43. package/dist/src/dev/clientManager.d.ts +1 -0
  44. package/dist/src/dev/devCert.d.ts +6 -4
  45. package/dist/src/dev/serverEntryCopies.d.ts +3 -0
  46. package/dist/src/mobile/androidEmulatorController.d.ts +14 -2
  47. package/dist/src/mobile/androidRelease.d.ts +6 -0
  48. package/dist/src/mobile/androidTestReport.d.ts +14 -0
  49. package/dist/src/mobile/androidUpgradeConformance.d.ts +47 -0
  50. package/dist/src/mobile/androidWebView.d.ts +1 -0
  51. package/dist/src/mobile/browser.d.ts +1 -0
  52. package/dist/src/mobile/buildPipeline.d.ts +1 -0
  53. package/dist/src/mobile/capacitorBundle.d.ts +22 -1
  54. package/dist/src/mobile/ciWorkflow.d.ts +26 -0
  55. package/dist/src/mobile/client.d.ts +4 -0
  56. package/dist/src/mobile/config.d.ts +4 -1
  57. package/dist/src/mobile/devDeviceAdapter.d.ts +3 -0
  58. package/dist/src/mobile/deviceCapabilities.d.ts +46 -0
  59. package/dist/src/mobile/expoBridge.d.ts +91 -0
  60. package/dist/src/mobile/expoProject.d.ts +16 -0
  61. package/dist/src/mobile/index.d.ts +13 -0
  62. package/dist/src/mobile/iosDeviceAcceptance.d.ts +32 -0
  63. package/dist/src/mobile/iosPhysicalDeviceTransport.d.ts +16 -0
  64. package/dist/src/mobile/iosRelease.d.ts +4 -1
  65. package/dist/src/mobile/iosSimulatorController.d.ts +20 -2
  66. package/dist/src/mobile/iosTestReport.d.ts +24 -0
  67. package/dist/src/mobile/mobileBundleInspection.d.ts +55 -0
  68. package/dist/src/mobile/mobileInspect.d.ts +136 -0
  69. package/dist/src/mobile/mobilePreview.d.ts +174 -0
  70. package/dist/src/mobile/mobilePreviewClient.d.ts +1 -0
  71. package/dist/src/mobile/nativeAuth.d.ts +17 -0
  72. package/dist/src/mobile/nativeBackgroundSync.d.ts +4 -0
  73. package/dist/src/mobile/nativeDeviceCapabilities.d.ts +6 -0
  74. package/dist/src/mobile/nativeTestReport.d.ts +91 -0
  75. package/dist/src/mobile/releaseArtifact.d.ts +2 -0
  76. package/dist/src/mobile/releaseDoctor.d.ts +23 -1
  77. package/dist/src/mobile/remoteMacProtocol.d.ts +11 -0
  78. package/dist/src/mobile/shellAuth.d.ts +15 -0
  79. package/dist/src/mobile/shellBootstrap.d.ts +23 -1
  80. package/dist/src/mobile/shellExpoDevices.d.ts +3 -0
  81. package/dist/src/mobile/shellHttp.d.ts +2 -0
  82. package/dist/src/mobile/shellPush.d.ts +11 -0
  83. package/dist/src/mobile/shellSync.d.ts +47 -0
  84. package/dist/src/mobile/staticDocument.d.ts +5 -0
  85. package/dist/src/mobile/syncRemediation.d.ts +10 -0
  86. package/dist/src/mobile/syncSchema.d.ts +9 -0
  87. package/dist/src/mobile/transport.d.ts +16 -1
  88. package/dist/src/plugins/hmr.d.ts +3 -0
  89. package/dist/src/plugins/imageOptimizer.d.ts +1 -1
  90. package/dist/src/react/hooks/useMediaQuery.d.ts +1 -1
  91. package/dist/src/svelte/pageHandler.d.ts +3 -0
  92. package/dist/src/utils/imageProcessing.d.ts +3 -0
  93. package/dist/src/utils/loadConfig.d.ts +1 -0
  94. package/dist/src/utils/logger.d.ts +1 -0
  95. package/dist/src/utils/startupBanner.d.ts +1 -0
  96. package/dist/src/utils/userAgentFunctions.d.ts +1 -1
  97. package/dist/src/vue/pageHandler.d.ts +3 -0
  98. package/dist/svelte/index.js +316 -23
  99. package/dist/svelte/index.js.map +8 -5
  100. package/dist/svelte/server.js +311 -18
  101. package/dist/svelte/server.js.map +8 -5
  102. package/dist/types/build.d.ts +50 -3
  103. package/dist/types/cli.d.ts +1 -0
  104. package/dist/types/messages.d.ts +1 -1
  105. package/dist/vue/index.js +316 -23
  106. package/dist/vue/index.js.map +8 -5
  107. package/dist/vue/server.js +311 -18
  108. package/dist/vue/server.js.map +8 -5
  109. package/package.json +41 -11
@@ -15,6 +15,7 @@ export declare const logReady: (options: {
15
15
  port: string | number;
16
16
  host: string;
17
17
  networkUrl?: string;
18
+ mobilePreviewUrl?: string;
18
19
  protocol?: string;
19
20
  }) => void;
20
21
  /**
@@ -6,5 +6,6 @@ export declare const startupBanner: (options: {
6
6
  port: string | number;
7
7
  host: string;
8
8
  networkUrl?: string;
9
+ mobilePreviewUrl?: string;
9
10
  protocol?: string;
10
11
  }) => void;
@@ -1 +1 @@
1
- export declare const getUserAgentType: (userAgent: string) => "console" | "other" | "bot" | "phone" | "tablet" | "tv" | "car" | "iot" | "desktop";
1
+ export declare const getUserAgentType: (userAgent: string) => "console" | "other" | "phone" | "tablet" | "desktop" | "bot" | "tv" | "car" | "iot";
@@ -1,5 +1,6 @@
1
1
  import type { Component as VueComponent } from 'vue';
2
2
  import type { VuePropsOf } from '../../types/vue';
3
+ import type { AbsoluteMobileBuildPageMetadata } from '../mobile/buildMetadata';
3
4
  import { type StreamingSlotEnhancerOptions } from '../core/responseEnhancers';
4
5
  type VuePageRenderOptions = StreamingSlotEnhancerOptions & {
5
6
  collectStreamingSlots?: boolean;
@@ -29,6 +30,8 @@ type VuePageClientMode = {
29
30
  indexPath: string;
30
31
  };
31
32
  export type VuePageRequestInput<Component extends VueComponent> = VuePageRenderOptions & VuePageClientMode & {
33
+ /** @internal Build-generated mobile identity. Application code must not set this. */
34
+ __absoluteMobile?: AbsoluteMobileBuildPageMetadata;
32
35
  headTag?: `<head>${string}</head>`;
33
36
  pagePath: string;
34
37
  Page?: Component;
@@ -1333,7 +1333,7 @@ var SLOT_ID_PREFIX = "abs-slot-", CLOSING_BODY_TAG = "</body>", CLOSING_HEAD_TAG
1333
1333
  getStreamingSlotsRuntimeScript()
1334
1334
  ].filter(Boolean).join(";");
1335
1335
  return `<script${createNonceAttr(nonce)}>${escapeScriptContent(runtimeBody)}</script>`;
1336
- }, toUint8 = (value, encoder) => encoder.encode(value), isRecord = (value) => Boolean(value) && typeof value === "object", isSafeHtmlLike = (value) => isRecord(value) && typeof value.changingThisBreaksApplicationSecurity === "string", normalizeSafeHtml = (value) => {
1336
+ }, toUint8 = (value, encoder) => encoder.encode(value), isRecord2 = (value) => Boolean(value) && typeof value === "object", isSafeHtmlLike = (value) => isRecord2(value) && typeof value.changingThisBreaksApplicationSecurity === "string", normalizeSafeHtml = (value) => {
1337
1337
  if (isSafeHtmlLike(value)) {
1338
1338
  return value.changingThisBreaksApplicationSecurity;
1339
1339
  }
@@ -1394,7 +1394,7 @@ var SLOT_ID_PREFIX = "abs-slot-", CLOSING_BODY_TAG = "</body>", CLOSING_HEAD_TAG
1394
1394
  }, createTimeoutError = (slot, timeoutMs) => {
1395
1395
  const error = Object.assign(new Error(`Streaming slot "${slot.id}" timed out after ${timeoutMs}ms`), { __absTimeout: true });
1396
1396
  return error;
1397
- }, isSlotPatchPayloadObject = (value) => isRecord(value) && ("html" in value), isTimeoutError = (error) => isRecord(error) && error.__absTimeout === true, toStreamingSlot = (slot, policy) => ({
1397
+ }, isSlotPatchPayloadObject = (value) => isRecord2(value) && ("html" in value), isTimeoutError = (error) => isRecord2(error) && error.__absTimeout === true, toStreamingSlot = (slot, policy) => ({
1398
1398
  errorHtml: slot.errorHtml === undefined ? policy.errorHtml : slot.errorHtml,
1399
1399
  fallbackHtml: normalizeSlotText(slot.fallbackHtml, policy.fallbackHtml),
1400
1400
  id: slot.id ?? createStreamingSlotId(),
@@ -1906,6 +1906,7 @@ var colors, MONTHS, formatTimestamp = () => {
1906
1906
  port,
1907
1907
  host,
1908
1908
  networkUrl,
1909
+ mobilePreviewUrl,
1909
1910
  protocol = "http"
1910
1911
  } = options;
1911
1912
  const name = `${colors.cyan}${colors.bold}ABSOLUTEJS${colors.reset}`;
@@ -1919,6 +1920,9 @@ var colors, MONTHS, formatTimestamp = () => {
1919
1920
  if (networkUrl) {
1920
1921
  console.log(` ${colors.green}\u279C${colors.reset} ${colors.bold}Network:${colors.reset} ${networkUrl}`);
1921
1922
  }
1923
+ if (mobilePreviewUrl) {
1924
+ console.log(` ${colors.green}\u279C${colors.reset} ${colors.bold}Mobile:${colors.reset} ${mobilePreviewUrl}`);
1925
+ }
1922
1926
  console.log("");
1923
1927
  };
1924
1928
  var init_startupBanner = __esm(() => {
@@ -2349,8 +2353,8 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
2349
2353
  }
2350
2354
  return null;
2351
2355
  }, NOT_FOUND_PRIORITY, renderFirstNotFound = async () => {
2352
- const renderNext = async (frameworks) => {
2353
- const [framework, ...remaining] = frameworks;
2356
+ const renderNext = async (frameworks2) => {
2357
+ const [framework, ...remaining] = frameworks2;
2354
2358
  if (!framework) {
2355
2359
  return null;
2356
2360
  }
@@ -3820,8 +3824,8 @@ var toIslandFrameworkSegment = (framework) => framework[0]?.toUpperCase() + fram
3820
3824
  return found ? entries : undefined;
3821
3825
  }, getIslandManifestEntries = (manifest) => {
3822
3826
  const islands = {};
3823
- const frameworks = ["react", "svelte", "vue", "angular"];
3824
- for (const framework of frameworks) {
3827
+ const frameworks2 = ["react", "svelte", "vue", "angular"];
3828
+ for (const framework of frameworks2) {
3825
3829
  const prefix = `Island${toIslandFrameworkSegment(framework)}`;
3826
3830
  const entries = collectFrameworkIslands(manifest, prefix);
3827
3831
  if (entries)
@@ -3841,14 +3845,14 @@ var defineIslandComponent = (component, options) => ({
3841
3845
  component,
3842
3846
  export: options.export,
3843
3847
  source: options.source
3844
- }), defineIslandRegistry = (registry) => registry, isRecord3 = (value) => typeof value === "object" && value !== null, getIslandBuildReference = (component) => {
3848
+ }), defineIslandRegistry = (registry) => registry, isRecord4 = (value) => typeof value === "object" && value !== null, getIslandBuildReference = (component) => {
3845
3849
  if (!isIslandComponentDefinition(component))
3846
3850
  return null;
3847
3851
  return {
3848
3852
  export: component.export,
3849
3853
  source: component.source
3850
3854
  };
3851
- }, isIslandComponentDefinition = (value) => isRecord3(value) && ("component" in value) && ("source" in value) && typeof value.source === "string", parseIslandProps = (rawProps) => {
3855
+ }, isIslandComponentDefinition = (value) => isRecord4(value) && ("component" in value) && ("source" in value) && typeof value.source === "string", parseIslandProps = (rawProps) => {
3852
3856
  if (!rawProps)
3853
3857
  return {};
3854
3858
  return JSON.parse(rawProps);
@@ -3872,7 +3876,7 @@ var init_islandMarkupAttributes = __esm(() => {
3872
3876
  var islandSequence = 0, resolvedServerComponentCache, resolvedServerBuildComponentCache, nextIslandId = () => {
3873
3877
  islandSequence += 1;
3874
3878
  return `island-${islandSequence}`;
3875
- }, isRecord4 = (value) => typeof value === "object" && value !== null, isReactServerIslandComponent = (value) => typeof value === "function", isSvelteServerIslandComponent = (value) => typeof value === "function", isVueServerIslandComponent = (value) => typeof value === "function" || isRecord4(value), isAngularServerIslandComponent = (value) => typeof value === "function", resolveBuildReferencePath = (source, registryPath) => {
3879
+ }, isRecord5 = (value) => typeof value === "object" && value !== null, isReactServerIslandComponent = (value) => typeof value === "function", isSvelteServerIslandComponent = (value) => typeof value === "function", isVueServerIslandComponent = (value) => typeof value === "function" || isRecord5(value), isAngularServerIslandComponent = (value) => typeof value === "function", resolveBuildReferencePath = (source, registryPath) => {
3876
3880
  if (source.startsWith("file://"))
3877
3881
  return new URL(source).pathname;
3878
3882
  if (source.startsWith("."))
@@ -4364,6 +4368,278 @@ var setCurrentIslandManifest = (manifest) => {
4364
4368
 
4365
4369
  // src/svelte/pageHandler.ts
4366
4370
  init_devRouteRegistrationCallsite();
4371
+
4372
+ // src/core/requestContext.ts
4373
+ import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
4374
+ import { Elysia as Elysia2 } from "elysia";
4375
+ var REQUEST_STORAGE_KEY = Symbol.for("absolutejs.requestAsyncLocalStorage");
4376
+ var isAbsoluteRequestStorage = (value) => typeof value === "object" && value !== null && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function";
4377
+ var getRequestStorage = () => {
4378
+ const value = Reflect.get(globalThis, REQUEST_STORAGE_KEY);
4379
+ return isAbsoluteRequestStorage(value) ? value : undefined;
4380
+ };
4381
+ var ensureRequestStorage = () => {
4382
+ const existing = getRequestStorage();
4383
+ if (existing)
4384
+ return existing;
4385
+ const storage = new AsyncLocalStorage2;
4386
+ Reflect.set(globalThis, REQUEST_STORAGE_KEY, storage);
4387
+ return storage;
4388
+ };
4389
+ var absoluteRequestContext = new Elysia2({
4390
+ name: "absolutejs-request-context"
4391
+ }).request(({ request }) => {
4392
+ ensureRequestStorage().enterWith({ request });
4393
+ }).as("global");
4394
+ var getCurrentAbsoluteRequest = () => getRequestStorage()?.getStore()?.request;
4395
+ var runWithAbsoluteRequest = (request, callback) => ensureRequestStorage().run({ request }, callback);
4396
+
4397
+ // src/mobile/producerContextState.ts
4398
+ var ABSOLUTE_MOBILE_PRODUCER_STORAGE_KEY = Symbol.for("absolutejs.mobileProducerAsyncLocalStorage");
4399
+ var frameworks = new Set([
4400
+ "angular",
4401
+ "ember",
4402
+ "html",
4403
+ "htmx",
4404
+ "react",
4405
+ "svelte",
4406
+ "vue"
4407
+ ]);
4408
+ var isCompatibilityPage = (value) => typeof value === "object" && value !== null && ("bundleHash" in value) && typeof value.bundleHash === "string" && ("contract" in value) && typeof value.contract === "string" && ("framework" in value) && typeof value.framework === "string" && frameworks.has(value.framework) && ("pageId" in value) && typeof value.pageId === "string" && ("propsSchemaHash" in value) && typeof value.propsSchemaHash === "string";
4409
+ var getCurrentAbsoluteMobileProducerContext = () => {
4410
+ const value = Reflect.get(globalThis, ABSOLUTE_MOBILE_PRODUCER_STORAGE_KEY);
4411
+ if (typeof value !== "object" || value === null || !("getStore" in value) || typeof value.getStore !== "function") {
4412
+ return;
4413
+ }
4414
+ const context = value.getStore();
4415
+ if (typeof context !== "object" || context === null || !("page" in context) || !isCompatibilityPage(context.page) || !("releaseId" in context) || typeof context.releaseId !== "string") {
4416
+ return;
4417
+ }
4418
+ return { page: context.page, releaseId: context.releaseId };
4419
+ };
4420
+
4421
+ // src/mobile/pageProtocol.ts
4422
+ var ABSOLUTE_MOBILE_PAGE_MEDIA_TYPE = "application/vnd.absolute.page+json";
4423
+ var ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION = 1;
4424
+ var BAD_REQUEST_STATUS = 400;
4425
+ var OK_STATUS = 200;
4426
+ var SERVER_ERROR_STATUS = 500;
4427
+ var UPGRADE_REQUIRED_STATUS = 426;
4428
+ var MOBILE_PAGE_REQUEST_HEADERS = {
4429
+ appBuild: "x-absolute-mobile-app-build",
4430
+ pageBundle: "x-absolute-mobile-page-bundle",
4431
+ pageContracts: "x-absolute-mobile-page-contracts",
4432
+ pageId: "x-absolute-mobile-page-id",
4433
+ protocol: "x-absolute-mobile-protocol",
4434
+ runtime: "x-absolute-mobile-runtime"
4435
+ };
4436
+ var parseMediaType = (value) => value.split(";", 1)[0]?.trim().toLowerCase();
4437
+ var acceptsAbsoluteMobilePage = (request) => {
4438
+ if (!request)
4439
+ return false;
4440
+ return (request.headers.get("accept") ?? "").split(",").some((value) => parseMediaType(value) === ABSOLUTE_MOBILE_PAGE_MEDIA_TYPE);
4441
+ };
4442
+ var readRequiredHeader = (request, name) => {
4443
+ const value = request.headers.get(name)?.trim();
4444
+ return value ? value : undefined;
4445
+ };
4446
+ var parseAbsoluteMobilePageRequest = (request) => {
4447
+ if (!request || !acceptsAbsoluteMobilePage(request)) {
4448
+ return { kind: "not-mobile" };
4449
+ }
4450
+ const protocolValue = readRequiredHeader(request, MOBILE_PAGE_REQUEST_HEADERS.protocol);
4451
+ const runtime = readRequiredHeader(request, MOBILE_PAGE_REQUEST_HEADERS.runtime);
4452
+ const appBuild = readRequiredHeader(request, MOBILE_PAGE_REQUEST_HEADERS.appBuild);
4453
+ const pageBundle = readRequiredHeader(request, MOBILE_PAGE_REQUEST_HEADERS.pageBundle);
4454
+ const pageContractsValue = readRequiredHeader(request, MOBILE_PAGE_REQUEST_HEADERS.pageContracts);
4455
+ const pageId = readRequiredHeader(request, MOBILE_PAGE_REQUEST_HEADERS.pageId);
4456
+ if (!protocolValue || !/^\d+$/.test(protocolValue)) {
4457
+ return {
4458
+ kind: "invalid",
4459
+ message: `Missing or invalid ${MOBILE_PAGE_REQUEST_HEADERS.protocol} header.`
4460
+ };
4461
+ }
4462
+ if (!runtime) {
4463
+ return {
4464
+ kind: "invalid",
4465
+ message: `Missing ${MOBILE_PAGE_REQUEST_HEADERS.runtime} header.`
4466
+ };
4467
+ }
4468
+ if (!appBuild) {
4469
+ return {
4470
+ kind: "invalid",
4471
+ message: `Missing ${MOBILE_PAGE_REQUEST_HEADERS.appBuild} header.`
4472
+ };
4473
+ }
4474
+ if (!pageBundle) {
4475
+ return {
4476
+ kind: "invalid",
4477
+ message: `Missing ${MOBILE_PAGE_REQUEST_HEADERS.pageBundle} header.`
4478
+ };
4479
+ }
4480
+ if (!pageContractsValue) {
4481
+ return {
4482
+ kind: "invalid",
4483
+ message: `Missing ${MOBILE_PAGE_REQUEST_HEADERS.pageContracts} header.`
4484
+ };
4485
+ }
4486
+ if (!pageId) {
4487
+ return {
4488
+ kind: "invalid",
4489
+ message: `Missing ${MOBILE_PAGE_REQUEST_HEADERS.pageId} header.`
4490
+ };
4491
+ }
4492
+ const pageContracts = [
4493
+ ...new Set(pageContractsValue.split(",").map((value) => value.trim()).filter(Boolean))
4494
+ ];
4495
+ if (pageContracts.length === 0) {
4496
+ return {
4497
+ kind: "invalid",
4498
+ message: `${MOBILE_PAGE_REQUEST_HEADERS.pageContracts} must contain at least one contract.`
4499
+ };
4500
+ }
4501
+ return {
4502
+ client: {
4503
+ appBuild,
4504
+ pageBundle,
4505
+ pageContracts,
4506
+ pageId,
4507
+ protocol: Number(protocolValue),
4508
+ runtime
4509
+ },
4510
+ kind: "mobile"
4511
+ };
4512
+ };
4513
+ var responseHeaders = () => {
4514
+ const headers = new Headers({
4515
+ "cache-control": "no-store",
4516
+ "content-type": `${ABSOLUTE_MOBILE_PAGE_MEDIA_TYPE}; version=${ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION}`
4517
+ });
4518
+ headerVaryValues.forEach((value) => headers.append("vary", value));
4519
+ return headers;
4520
+ };
4521
+ var headerVaryValues = [
4522
+ "Accept",
4523
+ MOBILE_PAGE_REQUEST_HEADERS.protocol,
4524
+ MOBILE_PAGE_REQUEST_HEADERS.runtime,
4525
+ MOBILE_PAGE_REQUEST_HEADERS.appBuild,
4526
+ MOBILE_PAGE_REQUEST_HEADERS.pageBundle,
4527
+ MOBILE_PAGE_REQUEST_HEADERS.pageContracts,
4528
+ MOBILE_PAGE_REQUEST_HEADERS.pageId
4529
+ ];
4530
+ var envelopeResponse = (response, status) => new Response(JSON.stringify({
4531
+ protocol: ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION,
4532
+ response
4533
+ }), { headers: responseHeaders(), status });
4534
+ var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
4535
+ var normalizeJsonValue = (value) => {
4536
+ const serialized = JSON.stringify(value);
4537
+ if (serialized === undefined) {
4538
+ throw new TypeError("Mobile page props must be JSON-serializable.");
4539
+ }
4540
+ const parsed = JSON.parse(serialized);
4541
+ if (!isRecord(parsed)) {
4542
+ throw new TypeError("Mobile page props must serialize to an object.");
4543
+ }
4544
+ return parsed;
4545
+ };
4546
+ var finalizeArchivedMobilePage = (context, input) => {
4547
+ const { page } = context;
4548
+ if (page.pageId !== input.compatibility.pageId || page.framework !== input.compatibility.framework) {
4549
+ return envelopeResponse({
4550
+ kind: "invalid-request",
4551
+ message: "Archived producer page identity does not match its release artifact."
4552
+ }, BAD_REQUEST_STATUS);
4553
+ }
4554
+ try {
4555
+ const [currentRepresentation] = input.compatibility.representations;
4556
+ if (!currentRepresentation) {
4557
+ throw new TypeError("Mobile page has no current representation.");
4558
+ }
4559
+ return envelopeResponse({
4560
+ contract: page.contract,
4561
+ framework: page.framework,
4562
+ kind: "page",
4563
+ pageId: page.pageId,
4564
+ props: normalizeJsonValue(currentRepresentation.mapProps(input.props)),
4565
+ status: input.status ?? OK_STATUS
4566
+ }, input.status ?? OK_STATUS);
4567
+ } catch (error) {
4568
+ console.error(`[Mobile] Archived producer ${context.releaseId} failed for ${page.pageId}:`, error);
4569
+ return createAbsoluteMobilePageErrorResponse(page.pageId);
4570
+ }
4571
+ };
4572
+ var createAbsoluteMobileInvalidRequestResponse = (message) => envelopeResponse({ kind: "invalid-request", message }, BAD_REQUEST_STATUS);
4573
+ var createAbsoluteMobilePageErrorResponse = (pageId) => envelopeResponse({
4574
+ code: "representation-failed",
4575
+ kind: "error",
4576
+ pageId,
4577
+ status: SERVER_ERROR_STATUS
4578
+ }, SERVER_ERROR_STATUS);
4579
+ var createAbsoluteMobileUpgradeResponse = (result) => envelopeResponse(result, UPGRADE_REQUIRED_STATUS);
4580
+ var finalizeAbsoluteMobilePage = (input) => {
4581
+ const parsed = parseAbsoluteMobilePageRequest(input.request);
4582
+ if (parsed.kind === "not-mobile")
4583
+ return;
4584
+ if (parsed.kind === "invalid") {
4585
+ return envelopeResponse({ kind: "invalid-request", message: parsed.message }, BAD_REQUEST_STATUS);
4586
+ }
4587
+ const { client } = parsed;
4588
+ if (client.pageId !== input.compatibility.pageId) {
4589
+ return envelopeResponse({
4590
+ kind: "invalid-request",
4591
+ message: `Requested mobile page ${client.pageId} does not match ${input.compatibility.pageId}.`
4592
+ }, BAD_REQUEST_STATUS);
4593
+ }
4594
+ const producerContext = getCurrentAbsoluteMobileProducerContext();
4595
+ if (producerContext)
4596
+ return finalizeArchivedMobilePage(producerContext, input);
4597
+ if (client.protocol !== ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION) {
4598
+ return envelopeResponse({
4599
+ kind: "upgrade-required",
4600
+ pageId: input.compatibility.pageId,
4601
+ reason: "protocol"
4602
+ }, UPGRADE_REQUIRED_STATUS);
4603
+ }
4604
+ if (!input.compatibility.runtimes.includes(client.runtime)) {
4605
+ return envelopeResponse({
4606
+ kind: "upgrade-required",
4607
+ pageId: input.compatibility.pageId,
4608
+ reason: "runtime",
4609
+ supportedRuntimes: [...input.compatibility.runtimes]
4610
+ }, UPGRADE_REQUIRED_STATUS);
4611
+ }
4612
+ const clientContracts = new Set(client.pageContracts);
4613
+ const representation = input.compatibility.representations.find(({ contract }) => clientContracts.has(contract));
4614
+ if (!representation) {
4615
+ return envelopeResponse({
4616
+ kind: "upgrade-required",
4617
+ pageId: input.compatibility.pageId,
4618
+ reason: "page-contract",
4619
+ supportedContracts: input.compatibility.representations.map(({ contract }) => contract)
4620
+ }, UPGRADE_REQUIRED_STATUS);
4621
+ }
4622
+ try {
4623
+ return envelopeResponse({
4624
+ contract: representation.contract,
4625
+ framework: input.compatibility.framework,
4626
+ kind: "page",
4627
+ pageId: input.compatibility.pageId,
4628
+ props: normalizeJsonValue(representation.mapProps(input.props)),
4629
+ status: input.status ?? OK_STATUS
4630
+ }, input.status ?? OK_STATUS);
4631
+ } catch (error) {
4632
+ console.error(`[Mobile] Failed to produce ${input.compatibility.pageId} representation ${representation.contract}:`, error);
4633
+ return envelopeResponse({
4634
+ code: "representation-failed",
4635
+ kind: "error",
4636
+ pageId: input.compatibility.pageId,
4637
+ status: SERVER_ERROR_STATUS
4638
+ }, SERVER_ERROR_STATUS);
4639
+ }
4640
+ };
4641
+
4642
+ // src/svelte/pageHandler.ts
4367
4643
  init_pageResponseCache();
4368
4644
 
4369
4645
  // src/core/responseEnhancers.ts
@@ -4420,7 +4696,7 @@ var withRegisteredStreamingSlots = async (renderResponse, options = {}) => {
4420
4696
 
4421
4697
  // src/core/streamingSlotWarningScope.ts
4422
4698
  init_logger();
4423
- import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
4699
+ import { AsyncLocalStorage as AsyncLocalStorage3 } from "async_hooks";
4424
4700
  var STREAMING_SLOT_WARNING_STORAGE_KEY2 = Symbol.for("absolutejs.streamingSlotWarningAsyncLocalStorage");
4425
4701
  var isObjectRecord4 = (value) => Boolean(value) && typeof value === "object";
4426
4702
  var isAsyncLocalStorage3 = (value) => isObjectRecord4(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function";
@@ -4436,7 +4712,7 @@ var ensureWarningStorage = () => {
4436
4712
  if (existing) {
4437
4713
  return existing;
4438
4714
  }
4439
- const storage = new AsyncLocalStorage2;
4715
+ const storage = new AsyncLocalStorage3;
4440
4716
  Reflect.set(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY2, storage);
4441
4717
  return storage;
4442
4718
  };
@@ -4480,15 +4756,15 @@ var runWithStreamingSlotWarningScope = (task, metadata) => ensureWarningStorage(
4480
4756
  init_inlinePageCss();
4481
4757
  init_spaRouteManifest();
4482
4758
  init_resolveConvention();
4483
- var isRecord2 = (value) => typeof value === "object" && value !== null;
4484
- var isGenericSvelteComponent = (value) => typeof value === "function" || isRecord2(value);
4759
+ var isRecord3 = (value) => typeof value === "object" && value !== null;
4760
+ var isGenericSvelteComponent = (value) => typeof value === "function" || isRecord3(value);
4485
4761
  var readHasIslands = (value) => {
4486
- if (!isRecord2(value))
4762
+ if (!isRecord3(value))
4487
4763
  return false;
4488
4764
  const hasIslands = value["__ABSOLUTE_PAGE_HAS_ISLANDS__"];
4489
4765
  return typeof hasIslands === "boolean" ? hasIslands : false;
4490
4766
  };
4491
- var readDefaultExport = (value) => isRecord2(value) ? value.default : undefined;
4767
+ var readDefaultExport = (value) => isRecord3(value) ? value.default : undefined;
4492
4768
  var primeSvelteStream = async (stream) => {
4493
4769
  const reader = stream.getReader();
4494
4770
  const firstChunk = await reader.read();
@@ -4523,15 +4799,32 @@ var handleSveltePageRequest = async (input) => {
4523
4799
  const resolvedOptions = input;
4524
4800
  const resolvedPagePath = input.pagePath;
4525
4801
  const userProps = input.props;
4526
- const requestPathname = resolveRequestPathname(input.request);
4527
- const resolvedProps = requestPathname !== undefined && (!isRecord2(userProps) || !("url" in userProps)) ? {
4802
+ const request = input.request ?? getCurrentAbsoluteRequest();
4803
+ const requestPathname = resolveRequestPathname(request);
4804
+ const resolvedProps = requestPathname !== undefined && (!isRecord3(userProps) || !("url" in userProps)) ? {
4528
4805
  ...userProps ?? {},
4529
4806
  url: requestPathname
4530
4807
  } : userProps;
4808
+ const pageId = input.__absoluteMobile?.pageId ?? derivePageName(resolvedPagePath);
4809
+ const currentContract = input.__absoluteMobile?.contract ?? `svelte:${pageId}:${ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION}`;
4810
+ const mobileResponse = finalizeAbsoluteMobilePage({
4811
+ compatibility: {
4812
+ framework: "svelte",
4813
+ pageId,
4814
+ representations: [
4815
+ { contract: currentContract, mapProps: (props) => props }
4816
+ ],
4817
+ runtimes: [String(ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION)]
4818
+ },
4819
+ props: resolvedProps ?? Object.create(null),
4820
+ request
4821
+ });
4822
+ if (mobileResponse)
4823
+ return mobileResponse;
4531
4824
  try {
4532
- const spaNotFound = await renderSpaNotFound("svelte", derivePageName(resolvedPagePath), input.request);
4825
+ const spaNotFound = await renderSpaNotFound("svelte", derivePageName(resolvedPagePath), request);
4533
4826
  if (spaNotFound)
4534
- return withPageCacheHeaders(spaNotFound, input.request);
4827
+ return withPageCacheHeaders(spaNotFound, request);
4535
4828
  const handlerCallsite = resolvedOptions?.collectStreamingSlots === true ? undefined : getCurrentRouteRegistrationCallsite() ?? captureStreamingSlotWarningCallsite();
4536
4829
  const renderPageResponse = async () => {
4537
4830
  const resolvePageComponent = async () => {
@@ -4582,7 +4875,7 @@ var handleSveltePageRequest = async (input) => {
4582
4875
  ...resolvedOptions,
4583
4876
  runtimePlacement: resolvedOptions.runtimePlacement ?? "body"
4584
4877
  }) : renderPageResponse(), { handlerCallsite });
4585
- return withPageCacheHeaders(pageResponse, input.request, {
4878
+ return withPageCacheHeaders(pageResponse, request, {
4586
4879
  bufferStreamForEtag: input.bufferStreamForEtag
4587
4880
  });
4588
4881
  } catch (error) {
@@ -4590,12 +4883,12 @@ var handleSveltePageRequest = async (input) => {
4590
4883
  const pageName = derivePageName(resolvedPagePath);
4591
4884
  const conventionResponse = await renderConventionError("svelte", pageName, error);
4592
4885
  if (conventionResponse) {
4593
- return withPageCacheHeaders(conventionResponse, input.request);
4886
+ return withPageCacheHeaders(conventionResponse, request);
4594
4887
  }
4595
4888
  return withPageCacheHeaders(new Response(ssrErrorPage("svelte", error), {
4596
4889
  headers: { "Content-Type": "text/html" },
4597
4890
  status: 500
4598
- }), input.request);
4891
+ }), request);
4599
4892
  }
4600
4893
  };
4601
4894
  // src/svelte/createIsland.ts
@@ -4739,5 +5032,5 @@ export {
4739
5032
  createTypedIsland
4740
5033
  };
4741
5034
 
4742
- //# debugId=8B013C6A3D2007D964756E2164756E21
5035
+ //# debugId=3E3D5F46B1EEB57764756E2164756E21
4743
5036
  //# sourceMappingURL=index.js.map