@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
@@ -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
  }
@@ -2848,6 +2852,278 @@ var setCurrentIslandManifest = (manifest) => {
2848
2852
 
2849
2853
  // src/svelte/pageHandler.ts
2850
2854
  init_devRouteRegistrationCallsite();
2855
+
2856
+ // src/core/requestContext.ts
2857
+ import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
2858
+ import { Elysia as Elysia2 } from "elysia";
2859
+ var REQUEST_STORAGE_KEY = Symbol.for("absolutejs.requestAsyncLocalStorage");
2860
+ var isAbsoluteRequestStorage = (value) => typeof value === "object" && value !== null && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function";
2861
+ var getRequestStorage = () => {
2862
+ const value = Reflect.get(globalThis, REQUEST_STORAGE_KEY);
2863
+ return isAbsoluteRequestStorage(value) ? value : undefined;
2864
+ };
2865
+ var ensureRequestStorage = () => {
2866
+ const existing = getRequestStorage();
2867
+ if (existing)
2868
+ return existing;
2869
+ const storage = new AsyncLocalStorage2;
2870
+ Reflect.set(globalThis, REQUEST_STORAGE_KEY, storage);
2871
+ return storage;
2872
+ };
2873
+ var absoluteRequestContext = new Elysia2({
2874
+ name: "absolutejs-request-context"
2875
+ }).request(({ request }) => {
2876
+ ensureRequestStorage().enterWith({ request });
2877
+ }).as("global");
2878
+ var getCurrentAbsoluteRequest = () => getRequestStorage()?.getStore()?.request;
2879
+ var runWithAbsoluteRequest = (request, callback) => ensureRequestStorage().run({ request }, callback);
2880
+
2881
+ // src/mobile/producerContextState.ts
2882
+ var ABSOLUTE_MOBILE_PRODUCER_STORAGE_KEY = Symbol.for("absolutejs.mobileProducerAsyncLocalStorage");
2883
+ var frameworks = new Set([
2884
+ "angular",
2885
+ "ember",
2886
+ "html",
2887
+ "htmx",
2888
+ "react",
2889
+ "svelte",
2890
+ "vue"
2891
+ ]);
2892
+ 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";
2893
+ var getCurrentAbsoluteMobileProducerContext = () => {
2894
+ const value = Reflect.get(globalThis, ABSOLUTE_MOBILE_PRODUCER_STORAGE_KEY);
2895
+ if (typeof value !== "object" || value === null || !("getStore" in value) || typeof value.getStore !== "function") {
2896
+ return;
2897
+ }
2898
+ const context = value.getStore();
2899
+ if (typeof context !== "object" || context === null || !("page" in context) || !isCompatibilityPage(context.page) || !("releaseId" in context) || typeof context.releaseId !== "string") {
2900
+ return;
2901
+ }
2902
+ return { page: context.page, releaseId: context.releaseId };
2903
+ };
2904
+
2905
+ // src/mobile/pageProtocol.ts
2906
+ var ABSOLUTE_MOBILE_PAGE_MEDIA_TYPE = "application/vnd.absolute.page+json";
2907
+ var ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION = 1;
2908
+ var BAD_REQUEST_STATUS = 400;
2909
+ var OK_STATUS = 200;
2910
+ var SERVER_ERROR_STATUS = 500;
2911
+ var UPGRADE_REQUIRED_STATUS = 426;
2912
+ var MOBILE_PAGE_REQUEST_HEADERS = {
2913
+ appBuild: "x-absolute-mobile-app-build",
2914
+ pageBundle: "x-absolute-mobile-page-bundle",
2915
+ pageContracts: "x-absolute-mobile-page-contracts",
2916
+ pageId: "x-absolute-mobile-page-id",
2917
+ protocol: "x-absolute-mobile-protocol",
2918
+ runtime: "x-absolute-mobile-runtime"
2919
+ };
2920
+ var parseMediaType = (value) => value.split(";", 1)[0]?.trim().toLowerCase();
2921
+ var acceptsAbsoluteMobilePage = (request) => {
2922
+ if (!request)
2923
+ return false;
2924
+ return (request.headers.get("accept") ?? "").split(",").some((value) => parseMediaType(value) === ABSOLUTE_MOBILE_PAGE_MEDIA_TYPE);
2925
+ };
2926
+ var readRequiredHeader = (request, name) => {
2927
+ const value = request.headers.get(name)?.trim();
2928
+ return value ? value : undefined;
2929
+ };
2930
+ var parseAbsoluteMobilePageRequest = (request) => {
2931
+ if (!request || !acceptsAbsoluteMobilePage(request)) {
2932
+ return { kind: "not-mobile" };
2933
+ }
2934
+ const protocolValue = readRequiredHeader(request, MOBILE_PAGE_REQUEST_HEADERS.protocol);
2935
+ const runtime = readRequiredHeader(request, MOBILE_PAGE_REQUEST_HEADERS.runtime);
2936
+ const appBuild = readRequiredHeader(request, MOBILE_PAGE_REQUEST_HEADERS.appBuild);
2937
+ const pageBundle = readRequiredHeader(request, MOBILE_PAGE_REQUEST_HEADERS.pageBundle);
2938
+ const pageContractsValue = readRequiredHeader(request, MOBILE_PAGE_REQUEST_HEADERS.pageContracts);
2939
+ const pageId = readRequiredHeader(request, MOBILE_PAGE_REQUEST_HEADERS.pageId);
2940
+ if (!protocolValue || !/^\d+$/.test(protocolValue)) {
2941
+ return {
2942
+ kind: "invalid",
2943
+ message: `Missing or invalid ${MOBILE_PAGE_REQUEST_HEADERS.protocol} header.`
2944
+ };
2945
+ }
2946
+ if (!runtime) {
2947
+ return {
2948
+ kind: "invalid",
2949
+ message: `Missing ${MOBILE_PAGE_REQUEST_HEADERS.runtime} header.`
2950
+ };
2951
+ }
2952
+ if (!appBuild) {
2953
+ return {
2954
+ kind: "invalid",
2955
+ message: `Missing ${MOBILE_PAGE_REQUEST_HEADERS.appBuild} header.`
2956
+ };
2957
+ }
2958
+ if (!pageBundle) {
2959
+ return {
2960
+ kind: "invalid",
2961
+ message: `Missing ${MOBILE_PAGE_REQUEST_HEADERS.pageBundle} header.`
2962
+ };
2963
+ }
2964
+ if (!pageContractsValue) {
2965
+ return {
2966
+ kind: "invalid",
2967
+ message: `Missing ${MOBILE_PAGE_REQUEST_HEADERS.pageContracts} header.`
2968
+ };
2969
+ }
2970
+ if (!pageId) {
2971
+ return {
2972
+ kind: "invalid",
2973
+ message: `Missing ${MOBILE_PAGE_REQUEST_HEADERS.pageId} header.`
2974
+ };
2975
+ }
2976
+ const pageContracts = [
2977
+ ...new Set(pageContractsValue.split(",").map((value) => value.trim()).filter(Boolean))
2978
+ ];
2979
+ if (pageContracts.length === 0) {
2980
+ return {
2981
+ kind: "invalid",
2982
+ message: `${MOBILE_PAGE_REQUEST_HEADERS.pageContracts} must contain at least one contract.`
2983
+ };
2984
+ }
2985
+ return {
2986
+ client: {
2987
+ appBuild,
2988
+ pageBundle,
2989
+ pageContracts,
2990
+ pageId,
2991
+ protocol: Number(protocolValue),
2992
+ runtime
2993
+ },
2994
+ kind: "mobile"
2995
+ };
2996
+ };
2997
+ var responseHeaders = () => {
2998
+ const headers = new Headers({
2999
+ "cache-control": "no-store",
3000
+ "content-type": `${ABSOLUTE_MOBILE_PAGE_MEDIA_TYPE}; version=${ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION}`
3001
+ });
3002
+ headerVaryValues.forEach((value) => headers.append("vary", value));
3003
+ return headers;
3004
+ };
3005
+ var headerVaryValues = [
3006
+ "Accept",
3007
+ MOBILE_PAGE_REQUEST_HEADERS.protocol,
3008
+ MOBILE_PAGE_REQUEST_HEADERS.runtime,
3009
+ MOBILE_PAGE_REQUEST_HEADERS.appBuild,
3010
+ MOBILE_PAGE_REQUEST_HEADERS.pageBundle,
3011
+ MOBILE_PAGE_REQUEST_HEADERS.pageContracts,
3012
+ MOBILE_PAGE_REQUEST_HEADERS.pageId
3013
+ ];
3014
+ var envelopeResponse = (response, status) => new Response(JSON.stringify({
3015
+ protocol: ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION,
3016
+ response
3017
+ }), { headers: responseHeaders(), status });
3018
+ var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
3019
+ var normalizeJsonValue = (value) => {
3020
+ const serialized = JSON.stringify(value);
3021
+ if (serialized === undefined) {
3022
+ throw new TypeError("Mobile page props must be JSON-serializable.");
3023
+ }
3024
+ const parsed = JSON.parse(serialized);
3025
+ if (!isRecord(parsed)) {
3026
+ throw new TypeError("Mobile page props must serialize to an object.");
3027
+ }
3028
+ return parsed;
3029
+ };
3030
+ var finalizeArchivedMobilePage = (context, input) => {
3031
+ const { page } = context;
3032
+ if (page.pageId !== input.compatibility.pageId || page.framework !== input.compatibility.framework) {
3033
+ return envelopeResponse({
3034
+ kind: "invalid-request",
3035
+ message: "Archived producer page identity does not match its release artifact."
3036
+ }, BAD_REQUEST_STATUS);
3037
+ }
3038
+ try {
3039
+ const [currentRepresentation] = input.compatibility.representations;
3040
+ if (!currentRepresentation) {
3041
+ throw new TypeError("Mobile page has no current representation.");
3042
+ }
3043
+ return envelopeResponse({
3044
+ contract: page.contract,
3045
+ framework: page.framework,
3046
+ kind: "page",
3047
+ pageId: page.pageId,
3048
+ props: normalizeJsonValue(currentRepresentation.mapProps(input.props)),
3049
+ status: input.status ?? OK_STATUS
3050
+ }, input.status ?? OK_STATUS);
3051
+ } catch (error) {
3052
+ console.error(`[Mobile] Archived producer ${context.releaseId} failed for ${page.pageId}:`, error);
3053
+ return createAbsoluteMobilePageErrorResponse(page.pageId);
3054
+ }
3055
+ };
3056
+ var createAbsoluteMobileInvalidRequestResponse = (message) => envelopeResponse({ kind: "invalid-request", message }, BAD_REQUEST_STATUS);
3057
+ var createAbsoluteMobilePageErrorResponse = (pageId) => envelopeResponse({
3058
+ code: "representation-failed",
3059
+ kind: "error",
3060
+ pageId,
3061
+ status: SERVER_ERROR_STATUS
3062
+ }, SERVER_ERROR_STATUS);
3063
+ var createAbsoluteMobileUpgradeResponse = (result) => envelopeResponse(result, UPGRADE_REQUIRED_STATUS);
3064
+ var finalizeAbsoluteMobilePage = (input) => {
3065
+ const parsed = parseAbsoluteMobilePageRequest(input.request);
3066
+ if (parsed.kind === "not-mobile")
3067
+ return;
3068
+ if (parsed.kind === "invalid") {
3069
+ return envelopeResponse({ kind: "invalid-request", message: parsed.message }, BAD_REQUEST_STATUS);
3070
+ }
3071
+ const { client } = parsed;
3072
+ if (client.pageId !== input.compatibility.pageId) {
3073
+ return envelopeResponse({
3074
+ kind: "invalid-request",
3075
+ message: `Requested mobile page ${client.pageId} does not match ${input.compatibility.pageId}.`
3076
+ }, BAD_REQUEST_STATUS);
3077
+ }
3078
+ const producerContext = getCurrentAbsoluteMobileProducerContext();
3079
+ if (producerContext)
3080
+ return finalizeArchivedMobilePage(producerContext, input);
3081
+ if (client.protocol !== ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION) {
3082
+ return envelopeResponse({
3083
+ kind: "upgrade-required",
3084
+ pageId: input.compatibility.pageId,
3085
+ reason: "protocol"
3086
+ }, UPGRADE_REQUIRED_STATUS);
3087
+ }
3088
+ if (!input.compatibility.runtimes.includes(client.runtime)) {
3089
+ return envelopeResponse({
3090
+ kind: "upgrade-required",
3091
+ pageId: input.compatibility.pageId,
3092
+ reason: "runtime",
3093
+ supportedRuntimes: [...input.compatibility.runtimes]
3094
+ }, UPGRADE_REQUIRED_STATUS);
3095
+ }
3096
+ const clientContracts = new Set(client.pageContracts);
3097
+ const representation = input.compatibility.representations.find(({ contract }) => clientContracts.has(contract));
3098
+ if (!representation) {
3099
+ return envelopeResponse({
3100
+ kind: "upgrade-required",
3101
+ pageId: input.compatibility.pageId,
3102
+ reason: "page-contract",
3103
+ supportedContracts: input.compatibility.representations.map(({ contract }) => contract)
3104
+ }, UPGRADE_REQUIRED_STATUS);
3105
+ }
3106
+ try {
3107
+ return envelopeResponse({
3108
+ contract: representation.contract,
3109
+ framework: input.compatibility.framework,
3110
+ kind: "page",
3111
+ pageId: input.compatibility.pageId,
3112
+ props: normalizeJsonValue(representation.mapProps(input.props)),
3113
+ status: input.status ?? OK_STATUS
3114
+ }, input.status ?? OK_STATUS);
3115
+ } catch (error) {
3116
+ console.error(`[Mobile] Failed to produce ${input.compatibility.pageId} representation ${representation.contract}:`, error);
3117
+ return envelopeResponse({
3118
+ code: "representation-failed",
3119
+ kind: "error",
3120
+ pageId: input.compatibility.pageId,
3121
+ status: SERVER_ERROR_STATUS
3122
+ }, SERVER_ERROR_STATUS);
3123
+ }
3124
+ };
3125
+
3126
+ // src/svelte/pageHandler.ts
2851
3127
  init_pageResponseCache();
2852
3128
 
2853
3129
  // src/core/responseEnhancers.ts
@@ -2904,7 +3180,7 @@ var withRegisteredStreamingSlots = async (renderResponse, options = {}) => {
2904
3180
 
2905
3181
  // src/core/streamingSlotWarningScope.ts
2906
3182
  init_logger();
2907
- import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
3183
+ import { AsyncLocalStorage as AsyncLocalStorage3 } from "async_hooks";
2908
3184
  var STREAMING_SLOT_WARNING_STORAGE_KEY2 = Symbol.for("absolutejs.streamingSlotWarningAsyncLocalStorage");
2909
3185
  var isObjectRecord4 = (value) => Boolean(value) && typeof value === "object";
2910
3186
  var isAsyncLocalStorage3 = (value) => isObjectRecord4(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function";
@@ -2920,7 +3196,7 @@ var ensureWarningStorage = () => {
2920
3196
  if (existing) {
2921
3197
  return existing;
2922
3198
  }
2923
- const storage = new AsyncLocalStorage2;
3199
+ const storage = new AsyncLocalStorage3;
2924
3200
  Reflect.set(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY2, storage);
2925
3201
  return storage;
2926
3202
  };
@@ -2964,15 +3240,15 @@ var runWithStreamingSlotWarningScope = (task, metadata) => ensureWarningStorage(
2964
3240
  init_inlinePageCss();
2965
3241
  init_spaRouteManifest();
2966
3242
  init_resolveConvention();
2967
- var isRecord2 = (value) => typeof value === "object" && value !== null;
2968
- var isGenericSvelteComponent = (value) => typeof value === "function" || isRecord2(value);
3243
+ var isRecord3 = (value) => typeof value === "object" && value !== null;
3244
+ var isGenericSvelteComponent = (value) => typeof value === "function" || isRecord3(value);
2969
3245
  var readHasIslands = (value) => {
2970
- if (!isRecord2(value))
3246
+ if (!isRecord3(value))
2971
3247
  return false;
2972
3248
  const hasIslands = value["__ABSOLUTE_PAGE_HAS_ISLANDS__"];
2973
3249
  return typeof hasIslands === "boolean" ? hasIslands : false;
2974
3250
  };
2975
- var readDefaultExport = (value) => isRecord2(value) ? value.default : undefined;
3251
+ var readDefaultExport = (value) => isRecord3(value) ? value.default : undefined;
2976
3252
  var primeSvelteStream = async (stream) => {
2977
3253
  const reader = stream.getReader();
2978
3254
  const firstChunk = await reader.read();
@@ -3007,15 +3283,32 @@ var handleSveltePageRequest = async (input) => {
3007
3283
  const resolvedOptions = input;
3008
3284
  const resolvedPagePath = input.pagePath;
3009
3285
  const userProps = input.props;
3010
- const requestPathname = resolveRequestPathname(input.request);
3011
- const resolvedProps = requestPathname !== undefined && (!isRecord2(userProps) || !("url" in userProps)) ? {
3286
+ const request = input.request ?? getCurrentAbsoluteRequest();
3287
+ const requestPathname = resolveRequestPathname(request);
3288
+ const resolvedProps = requestPathname !== undefined && (!isRecord3(userProps) || !("url" in userProps)) ? {
3012
3289
  ...userProps ?? {},
3013
3290
  url: requestPathname
3014
3291
  } : userProps;
3292
+ const pageId = input.__absoluteMobile?.pageId ?? derivePageName(resolvedPagePath);
3293
+ const currentContract = input.__absoluteMobile?.contract ?? `svelte:${pageId}:${ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION}`;
3294
+ const mobileResponse = finalizeAbsoluteMobilePage({
3295
+ compatibility: {
3296
+ framework: "svelte",
3297
+ pageId,
3298
+ representations: [
3299
+ { contract: currentContract, mapProps: (props) => props }
3300
+ ],
3301
+ runtimes: [String(ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION)]
3302
+ },
3303
+ props: resolvedProps ?? Object.create(null),
3304
+ request
3305
+ });
3306
+ if (mobileResponse)
3307
+ return mobileResponse;
3015
3308
  try {
3016
- const spaNotFound = await renderSpaNotFound("svelte", derivePageName(resolvedPagePath), input.request);
3309
+ const spaNotFound = await renderSpaNotFound("svelte", derivePageName(resolvedPagePath), request);
3017
3310
  if (spaNotFound)
3018
- return withPageCacheHeaders(spaNotFound, input.request);
3311
+ return withPageCacheHeaders(spaNotFound, request);
3019
3312
  const handlerCallsite = resolvedOptions?.collectStreamingSlots === true ? undefined : getCurrentRouteRegistrationCallsite() ?? captureStreamingSlotWarningCallsite();
3020
3313
  const renderPageResponse = async () => {
3021
3314
  const resolvePageComponent = async () => {
@@ -3066,7 +3359,7 @@ var handleSveltePageRequest = async (input) => {
3066
3359
  ...resolvedOptions,
3067
3360
  runtimePlacement: resolvedOptions.runtimePlacement ?? "body"
3068
3361
  }) : renderPageResponse(), { handlerCallsite });
3069
- return withPageCacheHeaders(pageResponse, input.request, {
3362
+ return withPageCacheHeaders(pageResponse, request, {
3070
3363
  bufferStreamForEtag: input.bufferStreamForEtag
3071
3364
  });
3072
3365
  } catch (error) {
@@ -3074,17 +3367,17 @@ var handleSveltePageRequest = async (input) => {
3074
3367
  const pageName = derivePageName(resolvedPagePath);
3075
3368
  const conventionResponse = await renderConventionError("svelte", pageName, error);
3076
3369
  if (conventionResponse) {
3077
- return withPageCacheHeaders(conventionResponse, input.request);
3370
+ return withPageCacheHeaders(conventionResponse, request);
3078
3371
  }
3079
3372
  return withPageCacheHeaders(new Response(ssrErrorPage("svelte", error), {
3080
3373
  headers: { "Content-Type": "text/html" },
3081
3374
  status: 500
3082
- }), input.request);
3375
+ }), request);
3083
3376
  }
3084
3377
  };
3085
3378
  export {
3086
3379
  handleSveltePageRequest
3087
3380
  };
3088
3381
 
3089
- //# debugId=3689ECCA0C4862B064756E2164756E21
3382
+ //# debugId=A90651B0A555C0FD64756E2164756E21
3090
3383
  //# sourceMappingURL=server.js.map