@absolutejs/absolute 0.20.0-beta.0 → 0.20.0-beta.10

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 (118) hide show
  1. package/README.md +45 -0
  2. package/dist/angular/components/core/streamingSlotRegistrar.js +1 -1
  3. package/dist/angular/components/core/streamingSlotRegistry.js +2 -2
  4. package/dist/angular/index.js +354 -22
  5. package/dist/angular/index.js.map +9 -6
  6. package/dist/angular/server.js +354 -22
  7. package/dist/angular/server.js.map +9 -6
  8. package/dist/build.js +742 -359
  9. package/dist/build.js.map +26 -24
  10. package/dist/cli/config/server.js +2 -2
  11. package/dist/cli/index.js +16105 -8429
  12. package/dist/dev/client/cssUtils.ts +112 -41
  13. package/dist/dev/client/handlers/html.ts +75 -15
  14. package/dist/dev/client/handlers/htmx.ts +43 -8
  15. package/dist/dev/client/handlers/react.ts +114 -32
  16. package/dist/dev/client/handlers/rebuild.ts +38 -8
  17. package/dist/dev/client/handlers/svelte.ts +33 -50
  18. package/dist/dev/client/handlers/vue.ts +36 -45
  19. package/dist/dev/client/hmrClient.ts +38 -6
  20. package/dist/dev/client/hmrTiming.ts +148 -0
  21. package/dist/dev/serverBootstrap.js +20 -11
  22. package/dist/index.js +1728 -864
  23. package/dist/index.js.map +38 -33
  24. package/dist/mobile/browser.js +14 -1
  25. package/dist/mobile/browser.js.map +3 -3
  26. package/dist/mobile/index.js +4853 -279
  27. package/dist/mobile/index.js.map +34 -7
  28. package/dist/mobile/remoteMacAgentEntry.js +29 -0
  29. package/dist/mobile/shellAuth.js +43 -0
  30. package/dist/mobile/shellBootstrap.js +581 -0
  31. package/dist/mobile/shellSync.js +74 -0
  32. package/dist/react/index.js +16 -3
  33. package/dist/react/index.js.map +4 -4
  34. package/dist/react/jsxDevRuntimeCompat.js +22 -2
  35. package/dist/react/jsxDevRuntimeCompat.js.map +5 -4
  36. package/dist/react/jsxRuntimeCompat.js +90 -0
  37. package/dist/react/jsxRuntimeCompat.js.map +10 -0
  38. package/dist/react/server.js +16 -3
  39. package/dist/react/server.js.map +4 -4
  40. package/dist/src/angular/pageHandler.d.ts +3 -0
  41. package/dist/src/build/compileVue.d.ts +1 -1
  42. package/dist/src/build/pwa.d.ts +15 -0
  43. package/dist/src/build/resolveBuildMode.d.ts +7 -0
  44. package/dist/src/cli/config/server.d.ts +1 -1
  45. package/dist/src/cli/scripts/dev.d.ts +4 -1
  46. package/dist/src/cli/scripts/mobile.d.ts +1 -0
  47. package/dist/src/cli/utils.d.ts +2 -2
  48. package/dist/src/core/build.d.ts +1 -1
  49. package/dist/src/core/pageHandlers.d.ts +11 -2
  50. package/dist/src/core/prepare.d.ts +6 -0
  51. package/dist/src/dev/clientManager.d.ts +9 -0
  52. package/dist/src/dev/configResolver.d.ts +2 -0
  53. package/dist/src/dev/moduleMapper.d.ts +1 -1
  54. package/dist/src/dev/moduleServer.d.ts +2 -1
  55. package/dist/src/dev/pathUtils.d.ts +1 -1
  56. package/dist/src/dev/reactComponentClassifier.d.ts +1 -1
  57. package/dist/src/mobile/androidConformance.d.ts +42 -0
  58. package/dist/src/mobile/androidEmulatorController.d.ts +105 -0
  59. package/dist/src/mobile/androidNativeWatcher.d.ts +19 -0
  60. package/dist/src/mobile/androidRelease.d.ts +51 -0
  61. package/dist/src/mobile/androidWebView.d.ts +46 -0
  62. package/dist/src/mobile/associationFiles.d.ts +49 -0
  63. package/dist/src/mobile/buildMetadata.d.ts +10 -0
  64. package/dist/src/mobile/buildPipeline.d.ts +9 -0
  65. package/dist/src/mobile/buildRelease.d.ts +24 -0
  66. package/dist/src/mobile/capacitorBundle.d.ts +42 -0
  67. package/dist/src/mobile/capacitorProject.d.ts +9 -0
  68. package/dist/src/mobile/client.d.ts +5 -1
  69. package/dist/src/mobile/config.d.ts +17 -0
  70. package/dist/src/mobile/emulatorDoctor.d.ts +25 -0
  71. package/dist/src/mobile/emulatorInstaller.d.ts +41 -0
  72. package/dist/src/mobile/index.d.ts +19 -0
  73. package/dist/src/mobile/iosConformance.d.ts +15 -0
  74. package/dist/src/mobile/iosNativeWatcher.d.ts +19 -0
  75. package/dist/src/mobile/iosRelease.d.ts +61 -0
  76. package/dist/src/mobile/iosSimulatorController.d.ts +89 -0
  77. package/dist/src/mobile/materializedBundle.d.ts +14 -0
  78. package/dist/src/mobile/nativeAuth.d.ts +17 -0
  79. package/dist/src/mobile/nativeBackgroundSync.d.ts +4 -0
  80. package/dist/src/mobile/nativeDeepLinks.d.ts +5 -0
  81. package/dist/src/mobile/releaseArtifact.d.ts +3 -0
  82. package/dist/src/mobile/releaseDoctor.d.ts +13 -0
  83. package/dist/src/mobile/releasePublisher.d.ts +130 -0
  84. package/dist/src/mobile/remoteMacAgent.d.ts +2 -0
  85. package/dist/src/mobile/remoteMacAgentEntry.d.ts +1 -0
  86. package/dist/src/mobile/remoteMacProtocol.d.ts +114 -0
  87. package/dist/src/mobile/remoteMacWire.d.ts +2 -0
  88. package/dist/src/mobile/routeMatcher.d.ts +3 -0
  89. package/dist/src/mobile/routeMetadataTransform.d.ts +13 -0
  90. package/dist/src/mobile/shellAuth.d.ts +13 -0
  91. package/dist/src/mobile/shellBootstrap.d.ts +18 -0
  92. package/dist/src/mobile/shellSync.d.ts +19 -0
  93. package/dist/src/mobile/staticDocument.d.ts +5 -0
  94. package/dist/src/mobile/transport.d.ts +43 -0
  95. package/dist/src/plugins/hmr.d.ts +3 -0
  96. package/dist/src/plugins/imageOptimizer.d.ts +1 -1
  97. package/dist/src/react/hooks/useMediaQuery.d.ts +1 -1
  98. package/dist/src/react/jsxDevRuntimeCompat.d.ts +1 -1
  99. package/dist/src/react/jsxRuntimeCompat.d.ts +7 -0
  100. package/dist/src/react/pageHandler.d.ts +3 -0
  101. package/dist/src/svelte/pageHandler.d.ts +3 -0
  102. package/dist/src/utils/loadConfig.d.ts +2 -0
  103. package/dist/src/utils/logger.d.ts +2 -0
  104. package/dist/src/utils/userAgentFunctions.d.ts +1 -1
  105. package/dist/src/vue/pageHandler.d.ts +3 -0
  106. package/dist/svelte/index.js +325 -23
  107. package/dist/svelte/index.js.map +8 -5
  108. package/dist/svelte/server.js +320 -18
  109. package/dist/svelte/server.js.map +8 -5
  110. package/dist/types/build.d.ts +59 -0
  111. package/dist/types/cli.d.ts +2 -0
  112. package/dist/types/globals.d.ts +14 -0
  113. package/dist/types/messages.d.ts +12 -0
  114. package/dist/vue/index.js +325 -23
  115. package/dist/vue/index.js.map +8 -5
  116. package/dist/vue/server.js +320 -18
  117. package/dist/vue/server.js.map +8 -5
  118. package/package.json +52 -8
@@ -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(),
@@ -1976,6 +1976,19 @@ var colors2, frameworkColors, formatPath = (filePath) => {
1976
1976
  const errorMsg = error instanceof Error ? error.message : error;
1977
1977
  const fullMessage = `${colors2.red}error${colors2.reset} ${message}${errorMsg ? `: ${errorMsg}` : ""}`;
1978
1978
  console.error(`${timestamp} ${tag} ${fullMessage}`);
1979
+ }, logHmrClientUpdate = (path, framework, duration, target, serverMs, clientMs, outcome = "applied", kind) => {
1980
+ const timestamp = `${colors2.dim}${formatTimestamp()}${colors2.reset}`;
1981
+ const targetLabel = target.startsWith("capacitor-") ? target.slice("capacitor-".length) : target;
1982
+ const tag = `${colors2.cyan}[hmr:${targetLabel}]${colors2.reset}`;
1983
+ const pathColor = framework ? getFrameworkColor(framework) : colors2.white;
1984
+ const breakdown = serverMs === undefined || clientMs === undefined ? "" : `; server ${serverMs}ms, client ${clientMs}ms`;
1985
+ let action = "failed after";
1986
+ if (outcome === "applied")
1987
+ action = "applied in";
1988
+ else if (outcome === "reloaded")
1989
+ action = "falling back to reload after";
1990
+ const kindLabel = kind ? `${kind} ` : "";
1991
+ console.log(`${timestamp} ${tag} ${framework ?? "update"} ${kindLabel}${pathColor}${formatPath(path)}${colors2.reset} ${colors2.dim}${action} ${duration}ms${breakdown}${colors2.reset}`);
1979
1992
  }, logHmrUpdate = (path, framework, duration) => {
1980
1993
  log("hmr update", { duration, framework, path });
1981
1994
  }, logInfo = (message) => {
@@ -2336,8 +2349,8 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
2336
2349
  }
2337
2350
  return null;
2338
2351
  }, NOT_FOUND_PRIORITY, renderFirstNotFound = async () => {
2339
- const renderNext = async (frameworks) => {
2340
- const [framework, ...remaining] = frameworks;
2352
+ const renderNext = async (frameworks2) => {
2353
+ const [framework, ...remaining] = frameworks2;
2341
2354
  if (!framework) {
2342
2355
  return null;
2343
2356
  }
@@ -2835,6 +2848,278 @@ var setCurrentIslandManifest = (manifest) => {
2835
2848
 
2836
2849
  // src/svelte/pageHandler.ts
2837
2850
  init_devRouteRegistrationCallsite();
2851
+
2852
+ // src/core/requestContext.ts
2853
+ import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
2854
+ import { Elysia as Elysia2 } from "elysia";
2855
+ var REQUEST_STORAGE_KEY = Symbol.for("absolutejs.requestAsyncLocalStorage");
2856
+ var isAbsoluteRequestStorage = (value) => typeof value === "object" && value !== null && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function";
2857
+ var getRequestStorage = () => {
2858
+ const value = Reflect.get(globalThis, REQUEST_STORAGE_KEY);
2859
+ return isAbsoluteRequestStorage(value) ? value : undefined;
2860
+ };
2861
+ var ensureRequestStorage = () => {
2862
+ const existing = getRequestStorage();
2863
+ if (existing)
2864
+ return existing;
2865
+ const storage = new AsyncLocalStorage2;
2866
+ Reflect.set(globalThis, REQUEST_STORAGE_KEY, storage);
2867
+ return storage;
2868
+ };
2869
+ var absoluteRequestContext = new Elysia2({
2870
+ name: "absolutejs-request-context"
2871
+ }).request(({ request }) => {
2872
+ ensureRequestStorage().enterWith({ request });
2873
+ }).as("global");
2874
+ var getCurrentAbsoluteRequest = () => getRequestStorage()?.getStore()?.request;
2875
+ var runWithAbsoluteRequest = (request, callback) => ensureRequestStorage().run({ request }, callback);
2876
+
2877
+ // src/mobile/producerContextState.ts
2878
+ var ABSOLUTE_MOBILE_PRODUCER_STORAGE_KEY = Symbol.for("absolutejs.mobileProducerAsyncLocalStorage");
2879
+ var frameworks = new Set([
2880
+ "angular",
2881
+ "ember",
2882
+ "html",
2883
+ "htmx",
2884
+ "react",
2885
+ "svelte",
2886
+ "vue"
2887
+ ]);
2888
+ 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";
2889
+ var getCurrentAbsoluteMobileProducerContext = () => {
2890
+ const value = Reflect.get(globalThis, ABSOLUTE_MOBILE_PRODUCER_STORAGE_KEY);
2891
+ if (typeof value !== "object" || value === null || !("getStore" in value) || typeof value.getStore !== "function") {
2892
+ return;
2893
+ }
2894
+ const context = value.getStore();
2895
+ if (typeof context !== "object" || context === null || !("page" in context) || !isCompatibilityPage(context.page) || !("releaseId" in context) || typeof context.releaseId !== "string") {
2896
+ return;
2897
+ }
2898
+ return { page: context.page, releaseId: context.releaseId };
2899
+ };
2900
+
2901
+ // src/mobile/pageProtocol.ts
2902
+ var ABSOLUTE_MOBILE_PAGE_MEDIA_TYPE = "application/vnd.absolute.page+json";
2903
+ var ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION = 1;
2904
+ var BAD_REQUEST_STATUS = 400;
2905
+ var OK_STATUS = 200;
2906
+ var SERVER_ERROR_STATUS = 500;
2907
+ var UPGRADE_REQUIRED_STATUS = 426;
2908
+ var MOBILE_PAGE_REQUEST_HEADERS = {
2909
+ appBuild: "x-absolute-mobile-app-build",
2910
+ pageBundle: "x-absolute-mobile-page-bundle",
2911
+ pageContracts: "x-absolute-mobile-page-contracts",
2912
+ pageId: "x-absolute-mobile-page-id",
2913
+ protocol: "x-absolute-mobile-protocol",
2914
+ runtime: "x-absolute-mobile-runtime"
2915
+ };
2916
+ var parseMediaType = (value) => value.split(";", 1)[0]?.trim().toLowerCase();
2917
+ var acceptsAbsoluteMobilePage = (request) => {
2918
+ if (!request)
2919
+ return false;
2920
+ return (request.headers.get("accept") ?? "").split(",").some((value) => parseMediaType(value) === ABSOLUTE_MOBILE_PAGE_MEDIA_TYPE);
2921
+ };
2922
+ var readRequiredHeader = (request, name) => {
2923
+ const value = request.headers.get(name)?.trim();
2924
+ return value ? value : undefined;
2925
+ };
2926
+ var parseAbsoluteMobilePageRequest = (request) => {
2927
+ if (!request || !acceptsAbsoluteMobilePage(request)) {
2928
+ return { kind: "not-mobile" };
2929
+ }
2930
+ const protocolValue = readRequiredHeader(request, MOBILE_PAGE_REQUEST_HEADERS.protocol);
2931
+ const runtime = readRequiredHeader(request, MOBILE_PAGE_REQUEST_HEADERS.runtime);
2932
+ const appBuild = readRequiredHeader(request, MOBILE_PAGE_REQUEST_HEADERS.appBuild);
2933
+ const pageBundle = readRequiredHeader(request, MOBILE_PAGE_REQUEST_HEADERS.pageBundle);
2934
+ const pageContractsValue = readRequiredHeader(request, MOBILE_PAGE_REQUEST_HEADERS.pageContracts);
2935
+ const pageId = readRequiredHeader(request, MOBILE_PAGE_REQUEST_HEADERS.pageId);
2936
+ if (!protocolValue || !/^\d+$/.test(protocolValue)) {
2937
+ return {
2938
+ kind: "invalid",
2939
+ message: `Missing or invalid ${MOBILE_PAGE_REQUEST_HEADERS.protocol} header.`
2940
+ };
2941
+ }
2942
+ if (!runtime) {
2943
+ return {
2944
+ kind: "invalid",
2945
+ message: `Missing ${MOBILE_PAGE_REQUEST_HEADERS.runtime} header.`
2946
+ };
2947
+ }
2948
+ if (!appBuild) {
2949
+ return {
2950
+ kind: "invalid",
2951
+ message: `Missing ${MOBILE_PAGE_REQUEST_HEADERS.appBuild} header.`
2952
+ };
2953
+ }
2954
+ if (!pageBundle) {
2955
+ return {
2956
+ kind: "invalid",
2957
+ message: `Missing ${MOBILE_PAGE_REQUEST_HEADERS.pageBundle} header.`
2958
+ };
2959
+ }
2960
+ if (!pageContractsValue) {
2961
+ return {
2962
+ kind: "invalid",
2963
+ message: `Missing ${MOBILE_PAGE_REQUEST_HEADERS.pageContracts} header.`
2964
+ };
2965
+ }
2966
+ if (!pageId) {
2967
+ return {
2968
+ kind: "invalid",
2969
+ message: `Missing ${MOBILE_PAGE_REQUEST_HEADERS.pageId} header.`
2970
+ };
2971
+ }
2972
+ const pageContracts = [
2973
+ ...new Set(pageContractsValue.split(",").map((value) => value.trim()).filter(Boolean))
2974
+ ];
2975
+ if (pageContracts.length === 0) {
2976
+ return {
2977
+ kind: "invalid",
2978
+ message: `${MOBILE_PAGE_REQUEST_HEADERS.pageContracts} must contain at least one contract.`
2979
+ };
2980
+ }
2981
+ return {
2982
+ client: {
2983
+ appBuild,
2984
+ pageBundle,
2985
+ pageContracts,
2986
+ pageId,
2987
+ protocol: Number(protocolValue),
2988
+ runtime
2989
+ },
2990
+ kind: "mobile"
2991
+ };
2992
+ };
2993
+ var responseHeaders = () => {
2994
+ const headers = new Headers({
2995
+ "cache-control": "no-store",
2996
+ "content-type": `${ABSOLUTE_MOBILE_PAGE_MEDIA_TYPE}; version=${ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION}`
2997
+ });
2998
+ headerVaryValues.forEach((value) => headers.append("vary", value));
2999
+ return headers;
3000
+ };
3001
+ var headerVaryValues = [
3002
+ "Accept",
3003
+ MOBILE_PAGE_REQUEST_HEADERS.protocol,
3004
+ MOBILE_PAGE_REQUEST_HEADERS.runtime,
3005
+ MOBILE_PAGE_REQUEST_HEADERS.appBuild,
3006
+ MOBILE_PAGE_REQUEST_HEADERS.pageBundle,
3007
+ MOBILE_PAGE_REQUEST_HEADERS.pageContracts,
3008
+ MOBILE_PAGE_REQUEST_HEADERS.pageId
3009
+ ];
3010
+ var envelopeResponse = (response, status) => new Response(JSON.stringify({
3011
+ protocol: ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION,
3012
+ response
3013
+ }), { headers: responseHeaders(), status });
3014
+ var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
3015
+ var normalizeJsonValue = (value) => {
3016
+ const serialized = JSON.stringify(value);
3017
+ if (serialized === undefined) {
3018
+ throw new TypeError("Mobile page props must be JSON-serializable.");
3019
+ }
3020
+ const parsed = JSON.parse(serialized);
3021
+ if (!isRecord(parsed)) {
3022
+ throw new TypeError("Mobile page props must serialize to an object.");
3023
+ }
3024
+ return parsed;
3025
+ };
3026
+ var finalizeArchivedMobilePage = (context, input) => {
3027
+ const { page } = context;
3028
+ if (page.pageId !== input.compatibility.pageId || page.framework !== input.compatibility.framework) {
3029
+ return envelopeResponse({
3030
+ kind: "invalid-request",
3031
+ message: "Archived producer page identity does not match its release artifact."
3032
+ }, BAD_REQUEST_STATUS);
3033
+ }
3034
+ try {
3035
+ const [currentRepresentation] = input.compatibility.representations;
3036
+ if (!currentRepresentation) {
3037
+ throw new TypeError("Mobile page has no current representation.");
3038
+ }
3039
+ return envelopeResponse({
3040
+ contract: page.contract,
3041
+ framework: page.framework,
3042
+ kind: "page",
3043
+ pageId: page.pageId,
3044
+ props: normalizeJsonValue(currentRepresentation.mapProps(input.props)),
3045
+ status: input.status ?? OK_STATUS
3046
+ }, input.status ?? OK_STATUS);
3047
+ } catch (error) {
3048
+ console.error(`[Mobile] Archived producer ${context.releaseId} failed for ${page.pageId}:`, error);
3049
+ return createAbsoluteMobilePageErrorResponse(page.pageId);
3050
+ }
3051
+ };
3052
+ var createAbsoluteMobileInvalidRequestResponse = (message) => envelopeResponse({ kind: "invalid-request", message }, BAD_REQUEST_STATUS);
3053
+ var createAbsoluteMobilePageErrorResponse = (pageId) => envelopeResponse({
3054
+ code: "representation-failed",
3055
+ kind: "error",
3056
+ pageId,
3057
+ status: SERVER_ERROR_STATUS
3058
+ }, SERVER_ERROR_STATUS);
3059
+ var createAbsoluteMobileUpgradeResponse = (result) => envelopeResponse(result, UPGRADE_REQUIRED_STATUS);
3060
+ var finalizeAbsoluteMobilePage = (input) => {
3061
+ const parsed = parseAbsoluteMobilePageRequest(input.request);
3062
+ if (parsed.kind === "not-mobile")
3063
+ return;
3064
+ if (parsed.kind === "invalid") {
3065
+ return envelopeResponse({ kind: "invalid-request", message: parsed.message }, BAD_REQUEST_STATUS);
3066
+ }
3067
+ const { client } = parsed;
3068
+ if (client.pageId !== input.compatibility.pageId) {
3069
+ return envelopeResponse({
3070
+ kind: "invalid-request",
3071
+ message: `Requested mobile page ${client.pageId} does not match ${input.compatibility.pageId}.`
3072
+ }, BAD_REQUEST_STATUS);
3073
+ }
3074
+ const producerContext = getCurrentAbsoluteMobileProducerContext();
3075
+ if (producerContext)
3076
+ return finalizeArchivedMobilePage(producerContext, input);
3077
+ if (client.protocol !== ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION) {
3078
+ return envelopeResponse({
3079
+ kind: "upgrade-required",
3080
+ pageId: input.compatibility.pageId,
3081
+ reason: "protocol"
3082
+ }, UPGRADE_REQUIRED_STATUS);
3083
+ }
3084
+ if (!input.compatibility.runtimes.includes(client.runtime)) {
3085
+ return envelopeResponse({
3086
+ kind: "upgrade-required",
3087
+ pageId: input.compatibility.pageId,
3088
+ reason: "runtime",
3089
+ supportedRuntimes: [...input.compatibility.runtimes]
3090
+ }, UPGRADE_REQUIRED_STATUS);
3091
+ }
3092
+ const clientContracts = new Set(client.pageContracts);
3093
+ const representation = input.compatibility.representations.find(({ contract }) => clientContracts.has(contract));
3094
+ if (!representation) {
3095
+ return envelopeResponse({
3096
+ kind: "upgrade-required",
3097
+ pageId: input.compatibility.pageId,
3098
+ reason: "page-contract",
3099
+ supportedContracts: input.compatibility.representations.map(({ contract }) => contract)
3100
+ }, UPGRADE_REQUIRED_STATUS);
3101
+ }
3102
+ try {
3103
+ return envelopeResponse({
3104
+ contract: representation.contract,
3105
+ framework: input.compatibility.framework,
3106
+ kind: "page",
3107
+ pageId: input.compatibility.pageId,
3108
+ props: normalizeJsonValue(representation.mapProps(input.props)),
3109
+ status: input.status ?? OK_STATUS
3110
+ }, input.status ?? OK_STATUS);
3111
+ } catch (error) {
3112
+ console.error(`[Mobile] Failed to produce ${input.compatibility.pageId} representation ${representation.contract}:`, error);
3113
+ return envelopeResponse({
3114
+ code: "representation-failed",
3115
+ kind: "error",
3116
+ pageId: input.compatibility.pageId,
3117
+ status: SERVER_ERROR_STATUS
3118
+ }, SERVER_ERROR_STATUS);
3119
+ }
3120
+ };
3121
+
3122
+ // src/svelte/pageHandler.ts
2838
3123
  init_pageResponseCache();
2839
3124
 
2840
3125
  // src/core/responseEnhancers.ts
@@ -2891,7 +3176,7 @@ var withRegisteredStreamingSlots = async (renderResponse, options = {}) => {
2891
3176
 
2892
3177
  // src/core/streamingSlotWarningScope.ts
2893
3178
  init_logger();
2894
- import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
3179
+ import { AsyncLocalStorage as AsyncLocalStorage3 } from "async_hooks";
2895
3180
  var STREAMING_SLOT_WARNING_STORAGE_KEY2 = Symbol.for("absolutejs.streamingSlotWarningAsyncLocalStorage");
2896
3181
  var isObjectRecord4 = (value) => Boolean(value) && typeof value === "object";
2897
3182
  var isAsyncLocalStorage3 = (value) => isObjectRecord4(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function";
@@ -2907,7 +3192,7 @@ var ensureWarningStorage = () => {
2907
3192
  if (existing) {
2908
3193
  return existing;
2909
3194
  }
2910
- const storage = new AsyncLocalStorage2;
3195
+ const storage = new AsyncLocalStorage3;
2911
3196
  Reflect.set(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY2, storage);
2912
3197
  return storage;
2913
3198
  };
@@ -2951,15 +3236,15 @@ var runWithStreamingSlotWarningScope = (task, metadata) => ensureWarningStorage(
2951
3236
  init_inlinePageCss();
2952
3237
  init_spaRouteManifest();
2953
3238
  init_resolveConvention();
2954
- var isRecord2 = (value) => typeof value === "object" && value !== null;
2955
- var isGenericSvelteComponent = (value) => typeof value === "function" || isRecord2(value);
3239
+ var isRecord3 = (value) => typeof value === "object" && value !== null;
3240
+ var isGenericSvelteComponent = (value) => typeof value === "function" || isRecord3(value);
2956
3241
  var readHasIslands = (value) => {
2957
- if (!isRecord2(value))
3242
+ if (!isRecord3(value))
2958
3243
  return false;
2959
3244
  const hasIslands = value["__ABSOLUTE_PAGE_HAS_ISLANDS__"];
2960
3245
  return typeof hasIslands === "boolean" ? hasIslands : false;
2961
3246
  };
2962
- var readDefaultExport = (value) => isRecord2(value) ? value.default : undefined;
3247
+ var readDefaultExport = (value) => isRecord3(value) ? value.default : undefined;
2963
3248
  var primeSvelteStream = async (stream) => {
2964
3249
  const reader = stream.getReader();
2965
3250
  const firstChunk = await reader.read();
@@ -2994,15 +3279,32 @@ var handleSveltePageRequest = async (input) => {
2994
3279
  const resolvedOptions = input;
2995
3280
  const resolvedPagePath = input.pagePath;
2996
3281
  const userProps = input.props;
2997
- const requestPathname = resolveRequestPathname(input.request);
2998
- const resolvedProps = requestPathname !== undefined && (!isRecord2(userProps) || !("url" in userProps)) ? {
3282
+ const request = input.request ?? getCurrentAbsoluteRequest();
3283
+ const requestPathname = resolveRequestPathname(request);
3284
+ const resolvedProps = requestPathname !== undefined && (!isRecord3(userProps) || !("url" in userProps)) ? {
2999
3285
  ...userProps ?? {},
3000
3286
  url: requestPathname
3001
3287
  } : userProps;
3288
+ const pageId = input.__absoluteMobile?.pageId ?? derivePageName(resolvedPagePath);
3289
+ const currentContract = input.__absoluteMobile?.contract ?? `svelte:${pageId}:${ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION}`;
3290
+ const mobileResponse = finalizeAbsoluteMobilePage({
3291
+ compatibility: {
3292
+ framework: "svelte",
3293
+ pageId,
3294
+ representations: [
3295
+ { contract: currentContract, mapProps: (props) => props }
3296
+ ],
3297
+ runtimes: [String(ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION)]
3298
+ },
3299
+ props: resolvedProps ?? Object.create(null),
3300
+ request
3301
+ });
3302
+ if (mobileResponse)
3303
+ return mobileResponse;
3002
3304
  try {
3003
- const spaNotFound = await renderSpaNotFound("svelte", derivePageName(resolvedPagePath), input.request);
3305
+ const spaNotFound = await renderSpaNotFound("svelte", derivePageName(resolvedPagePath), request);
3004
3306
  if (spaNotFound)
3005
- return withPageCacheHeaders(spaNotFound, input.request);
3307
+ return withPageCacheHeaders(spaNotFound, request);
3006
3308
  const handlerCallsite = resolvedOptions?.collectStreamingSlots === true ? undefined : getCurrentRouteRegistrationCallsite() ?? captureStreamingSlotWarningCallsite();
3007
3309
  const renderPageResponse = async () => {
3008
3310
  const resolvePageComponent = async () => {
@@ -3053,7 +3355,7 @@ var handleSveltePageRequest = async (input) => {
3053
3355
  ...resolvedOptions,
3054
3356
  runtimePlacement: resolvedOptions.runtimePlacement ?? "body"
3055
3357
  }) : renderPageResponse(), { handlerCallsite });
3056
- return withPageCacheHeaders(pageResponse, input.request, {
3358
+ return withPageCacheHeaders(pageResponse, request, {
3057
3359
  bufferStreamForEtag: input.bufferStreamForEtag
3058
3360
  });
3059
3361
  } catch (error) {
@@ -3061,17 +3363,17 @@ var handleSveltePageRequest = async (input) => {
3061
3363
  const pageName = derivePageName(resolvedPagePath);
3062
3364
  const conventionResponse = await renderConventionError("svelte", pageName, error);
3063
3365
  if (conventionResponse) {
3064
- return withPageCacheHeaders(conventionResponse, input.request);
3366
+ return withPageCacheHeaders(conventionResponse, request);
3065
3367
  }
3066
3368
  return withPageCacheHeaders(new Response(ssrErrorPage("svelte", error), {
3067
3369
  headers: { "Content-Type": "text/html" },
3068
3370
  status: 500
3069
- }), input.request);
3371
+ }), request);
3070
3372
  }
3071
3373
  };
3072
3374
  export {
3073
3375
  handleSveltePageRequest
3074
3376
  };
3075
3377
 
3076
- //# debugId=FDE142E42A6858C564756E2164756E21
3378
+ //# debugId=11B3526360898D0764756E2164756E21
3077
3379
  //# sourceMappingURL=server.js.map