@absolutejs/absolute 0.19.0-beta.695 → 0.19.0-beta.697
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 +1 -1
- package/dist/angular/browser.js +48 -40
- package/dist/angular/browser.js.map +4 -4
- package/dist/angular/index.js +2308 -2232
- package/dist/angular/index.js.map +14 -13
- package/dist/angular/server.js +2279 -2203
- package/dist/angular/server.js.map +14 -14
- package/dist/build.js +42796 -6393
- package/dist/build.js.map +9 -20
- package/dist/cli/index.js +9 -2
- package/dist/core/streamingSlotRegistrar.js +24 -16
- package/dist/core/streamingSlotRegistrar.js.map +2 -2
- package/dist/core/streamingSlotRegistry.js +42 -29
- package/dist/core/streamingSlotRegistry.js.map +2 -2
- package/dist/index.js +42693 -5631
- package/dist/index.js.map +19 -24
- package/dist/react/components/index.js +24 -16
- package/dist/react/components/index.js.map +2 -2
- package/dist/react/index.js +922 -868
- package/dist/react/index.js.map +12 -12
- package/dist/react/server.js +903 -848
- package/dist/react/server.js.map +11 -11
- package/dist/src/build/compileTailwind.d.ts +3 -0
- package/dist/src/core/pageHandlers.d.ts +0 -2
- package/dist/src/core/ssrCache.d.ts +3 -0
- package/dist/svelte/index.js +963 -899
- package/dist/svelte/index.js.map +14 -13
- package/dist/svelte/server.js +777 -712
- package/dist/svelte/server.js.map +12 -12
- package/dist/types/build.d.ts +5 -4
- package/dist/types/index.d.ts +0 -1
- package/dist/types/island.d.ts +14 -11
- package/dist/vue/components/index.js +24 -16
- package/dist/vue/components/index.js.map +2 -2
- package/dist/vue/index.js +1040 -976
- package/dist/vue/index.js.map +12 -12
- package/dist/vue/server.js +908 -841
- package/dist/vue/server.js.map +11 -11
- package/package.json +16 -8
package/dist/svelte/server.js
CHANGED
|
@@ -78,99 +78,6 @@ var __legacyMetadataTS = (k, v) => {
|
|
|
78
78
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
79
79
|
var __require = import.meta.require;
|
|
80
80
|
|
|
81
|
-
// src/core/streamingSlotRegistrar.ts
|
|
82
|
-
var STREAMING_SLOT_REGISTRAR_KEY, STREAMING_SLOT_WARNING_STORAGE_KEY, STREAMING_SLOT_COLLECTION_STORAGE_KEY, getRegisteredStreamingSlotRegistrar = () => {
|
|
83
|
-
const value = Reflect.get(globalThis, STREAMING_SLOT_REGISTRAR_KEY);
|
|
84
|
-
if (typeof value === "function" || value === null) {
|
|
85
|
-
return value;
|
|
86
|
-
}
|
|
87
|
-
return;
|
|
88
|
-
}, isObjectRecord = (value) => Boolean(value) && typeof value === "object", isStreamingSlotWarningController = (value) => isObjectRecord(value) && ("maybeWarn" in value) && typeof value.maybeWarn === "function", isStreamingSlotCollectionController = (value) => isObjectRecord(value) && ("isCollecting" in value) && typeof value.isCollecting === "function", getWarningController = () => {
|
|
89
|
-
const value = Reflect.get(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY);
|
|
90
|
-
if (value === null || typeof value === "undefined")
|
|
91
|
-
return;
|
|
92
|
-
return isStreamingSlotWarningController(value) ? value : undefined;
|
|
93
|
-
}, getCollectionController = () => {
|
|
94
|
-
const value = Reflect.get(globalThis, STREAMING_SLOT_COLLECTION_STORAGE_KEY);
|
|
95
|
-
if (value === null || typeof value === "undefined")
|
|
96
|
-
return;
|
|
97
|
-
return isStreamingSlotCollectionController(value) ? value : undefined;
|
|
98
|
-
}, hasRegisteredStreamingSlotRegistrar = () => typeof getRegisteredStreamingSlotRegistrar() === "function", isStreamingSlotCollectionActive = () => getCollectionController()?.isCollecting() === true, registerStreamingSlot = (slot) => {
|
|
99
|
-
getRegisteredStreamingSlotRegistrar()?.(slot);
|
|
100
|
-
}, setStreamingSlotCollectionController = (controller) => {
|
|
101
|
-
Reflect.set(globalThis, STREAMING_SLOT_COLLECTION_STORAGE_KEY, controller);
|
|
102
|
-
}, setStreamingSlotRegistrar = (nextRegistrar) => {
|
|
103
|
-
Reflect.set(globalThis, STREAMING_SLOT_REGISTRAR_KEY, nextRegistrar);
|
|
104
|
-
}, setStreamingSlotWarningController = (controller) => {
|
|
105
|
-
Reflect.set(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY, controller);
|
|
106
|
-
}, warnMissingStreamingSlotCollector = (primitiveName) => {
|
|
107
|
-
if (isStreamingSlotCollectionActive()) {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
getWarningController()?.maybeWarn(primitiveName);
|
|
111
|
-
};
|
|
112
|
-
var init_streamingSlotRegistrar = __esm(() => {
|
|
113
|
-
STREAMING_SLOT_REGISTRAR_KEY = Symbol.for("absolutejs.streamingSlotRegistrar");
|
|
114
|
-
STREAMING_SLOT_WARNING_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotWarningController");
|
|
115
|
-
STREAMING_SLOT_COLLECTION_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotCollectionController");
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
// src/core/streamingSlotRegistry.ts
|
|
119
|
-
var STREAMING_SLOT_STORAGE_KEY, isObjectRecord2 = (value) => Boolean(value) && typeof value === "object", isAsyncLocalStorage = (value) => isObjectRecord2(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function", getStorageGlobal = () => {
|
|
120
|
-
const value = Reflect.get(globalThis, STREAMING_SLOT_STORAGE_KEY);
|
|
121
|
-
if (value === null || typeof value === "undefined") {
|
|
122
|
-
return value;
|
|
123
|
-
}
|
|
124
|
-
return isAsyncLocalStorage(value) ? value : undefined;
|
|
125
|
-
}, isServerRuntime = () => typeof process !== "undefined" && typeof process.versions?.node === "string", ensureAsyncLocalStorage = async () => {
|
|
126
|
-
const storage = getStorageGlobal();
|
|
127
|
-
if (typeof storage !== "undefined") {
|
|
128
|
-
return storage;
|
|
129
|
-
}
|
|
130
|
-
if (!isServerRuntime()) {
|
|
131
|
-
Reflect.set(globalThis, STREAMING_SLOT_STORAGE_KEY, null);
|
|
132
|
-
return getStorageGlobal();
|
|
133
|
-
}
|
|
134
|
-
const mod = await import("async_hooks");
|
|
135
|
-
Reflect.set(globalThis, STREAMING_SLOT_STORAGE_KEY, new mod.AsyncLocalStorage);
|
|
136
|
-
return getStorageGlobal();
|
|
137
|
-
}, getActiveSlotStore = () => {
|
|
138
|
-
const storage = getStorageGlobal();
|
|
139
|
-
if (!storage)
|
|
140
|
-
return;
|
|
141
|
-
return storage.getStore();
|
|
142
|
-
}, registerStreamingSlot2 = (slot) => {
|
|
143
|
-
const store = getActiveSlotStore();
|
|
144
|
-
if (!store)
|
|
145
|
-
return;
|
|
146
|
-
store.set(slot.id, slot);
|
|
147
|
-
}, hasActiveStreamingSlotRegistry = () => getActiveSlotStore() !== undefined, runWithStreamingSlotRegistry = async (task) => {
|
|
148
|
-
const storage = await ensureAsyncLocalStorage();
|
|
149
|
-
if (!storage) {
|
|
150
|
-
const slots = [];
|
|
151
|
-
return {
|
|
152
|
-
result: await task(),
|
|
153
|
-
slots
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
return storage.run(new Map, async () => {
|
|
157
|
-
const result = await task();
|
|
158
|
-
const store = storage.getStore();
|
|
159
|
-
return {
|
|
160
|
-
result,
|
|
161
|
-
slots: store ? [...store.values()] : []
|
|
162
|
-
};
|
|
163
|
-
});
|
|
164
|
-
};
|
|
165
|
-
var init_streamingSlotRegistry = __esm(() => {
|
|
166
|
-
init_streamingSlotRegistrar();
|
|
167
|
-
STREAMING_SLOT_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotAsyncLocalStorage");
|
|
168
|
-
setStreamingSlotRegistrar(registerStreamingSlot2);
|
|
169
|
-
setStreamingSlotCollectionController({
|
|
170
|
-
isCollecting: () => getActiveSlotStore() !== undefined
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
|
|
174
81
|
// src/build/resolvePackageImport.ts
|
|
175
82
|
import { resolve, join } from "path";
|
|
176
83
|
import { existsSync, readFileSync } from "fs";
|
|
@@ -988,332 +895,134 @@ var init_svelteServerModule = __esm(() => {
|
|
|
988
895
|
});
|
|
989
896
|
});
|
|
990
897
|
|
|
991
|
-
// src/core/
|
|
992
|
-
var
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
898
|
+
// src/core/devRouteRegistrationCallsite.ts
|
|
899
|
+
var exports_devRouteRegistrationCallsite = {};
|
|
900
|
+
__export(exports_devRouteRegistrationCallsite, {
|
|
901
|
+
patchElysiaRouteRegistrationCallsites: () => patchElysiaRouteRegistrationCallsites,
|
|
902
|
+
getCurrentRouteRegistrationCallsite: () => getCurrentRouteRegistrationCallsite
|
|
903
|
+
});
|
|
904
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
905
|
+
import { Elysia } from "elysia";
|
|
906
|
+
var ROUTE_CALLSITE_STORAGE_KEY, ROUTE_CALLSITE_PATCHED_KEY, ROUTE_METHOD_NAMES, isObjectRecord3 = (value) => Boolean(value) && typeof value === "object", isAsyncLocalStorage2 = (value) => isObjectRecord3(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function", getRouteCallsiteStorage = () => {
|
|
907
|
+
const value = Reflect.get(globalThis, ROUTE_CALLSITE_STORAGE_KEY);
|
|
908
|
+
if (value === null || typeof value === "undefined") {
|
|
909
|
+
return;
|
|
1002
910
|
}
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
911
|
+
return isAsyncLocalStorage2(value) ? value : undefined;
|
|
912
|
+
}, ensureRouteCallsiteStorage = () => {
|
|
913
|
+
const existing = getRouteCallsiteStorage();
|
|
914
|
+
if (existing) {
|
|
915
|
+
return existing;
|
|
916
|
+
}
|
|
917
|
+
const storage = new AsyncLocalStorage;
|
|
918
|
+
Reflect.set(globalThis, ROUTE_CALLSITE_STORAGE_KEY, storage);
|
|
919
|
+
return storage;
|
|
920
|
+
}, normalizeCallsitePath = (value) => value.replace(`${process.cwd()}/`, "").replace(process.cwd(), "").replace(/^\.\/+/, ""), extractRouteRegistrationCallsite = (stack) => {
|
|
921
|
+
const frames = stack.split(`
|
|
922
|
+
`).slice(1).map((line) => line.trim());
|
|
923
|
+
for (const frame of frames) {
|
|
924
|
+
if (frame.includes("/node_modules/") || frame.includes("/dist/") || frame.includes("/src/core/devRouteRegistrationCallsite.")) {
|
|
925
|
+
continue;
|
|
926
|
+
}
|
|
927
|
+
const locationMatch = frame.match(/\((\/[^)]+:\d+:\d+)\)$/) ?? frame.match(/at (\/[^ ]+:\d+:\d+)$/);
|
|
928
|
+
if (locationMatch?.[1]) {
|
|
929
|
+
return normalizeCallsitePath(locationMatch[1]);
|
|
1008
930
|
}
|
|
1009
931
|
}
|
|
1010
|
-
return
|
|
1011
|
-
},
|
|
1012
|
-
|
|
1013
|
-
|
|
932
|
+
return;
|
|
933
|
+
}, captureRouteRegistrationCallsite = () => {
|
|
934
|
+
const { stack } = new Error;
|
|
935
|
+
if (!stack) {
|
|
936
|
+
return;
|
|
1014
937
|
}
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
if (consumed.done) {
|
|
1020
|
-
return { done: true, injected, pending };
|
|
938
|
+
return extractRouteRegistrationCallsite(stack);
|
|
939
|
+
}, wrapRouteHandlerWithCallsite = (handler, callsite) => {
|
|
940
|
+
if (typeof handler !== "function" || !callsite) {
|
|
941
|
+
return handler;
|
|
1021
942
|
}
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
pending: consumed.pending
|
|
943
|
+
const storage = ensureRouteCallsiteStorage();
|
|
944
|
+
return function wrappedRouteHandler(...args) {
|
|
945
|
+
return storage.run({ callsite }, () => Reflect.apply(handler, this, args));
|
|
1026
946
|
};
|
|
1027
|
-
},
|
|
1028
|
-
|
|
1029
|
-
if (
|
|
1030
|
-
return
|
|
947
|
+
}, getCurrentRouteRegistrationCallsite = () => getRouteCallsiteStorage()?.getStore()?.callsite, patchElysiaRouteRegistrationCallsites = () => {
|
|
948
|
+
if (false) {}
|
|
949
|
+
if (Reflect.get(globalThis, ROUTE_CALLSITE_PATCHED_KEY) === true) {
|
|
950
|
+
return;
|
|
1031
951
|
}
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
const processPending = (controller, pending, injected) => {
|
|
1038
|
-
if (injected) {
|
|
1039
|
-
controller.enqueue(encoder.encode(pending));
|
|
1040
|
-
return { injected, pending: "" };
|
|
1041
|
-
}
|
|
1042
|
-
const headIndex = pending.indexOf(CLOSING_HEAD_TAG);
|
|
1043
|
-
if (headIndex >= 0) {
|
|
1044
|
-
const next = `${pending.slice(0, headIndex)}${markup}${pending.slice(headIndex)}`;
|
|
1045
|
-
controller.enqueue(encoder.encode(next));
|
|
1046
|
-
return { injected: true, pending: "" };
|
|
952
|
+
const prototype = Elysia.prototype;
|
|
953
|
+
for (const methodName of ROUTE_METHOD_NAMES) {
|
|
954
|
+
const originalMethod = prototype[methodName];
|
|
955
|
+
if (typeof originalMethod !== "function") {
|
|
956
|
+
continue;
|
|
1047
957
|
}
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
958
|
+
prototype[methodName] = function patchedRouteMethod(path, handler, ...rest) {
|
|
959
|
+
const callsite = captureRouteRegistrationCallsite();
|
|
960
|
+
return Reflect.apply(originalMethod, this, [
|
|
961
|
+
path,
|
|
962
|
+
wrapRouteHandlerWithCallsite(handler, callsite),
|
|
963
|
+
...rest
|
|
964
|
+
]);
|
|
1051
965
|
};
|
|
966
|
+
}
|
|
967
|
+
Reflect.set(globalThis, ROUTE_CALLSITE_PATCHED_KEY, true);
|
|
968
|
+
};
|
|
969
|
+
var init_devRouteRegistrationCallsite = __esm(() => {
|
|
970
|
+
ROUTE_CALLSITE_STORAGE_KEY = Symbol.for("absolutejs.devRouteRegistrationCallsiteStorage");
|
|
971
|
+
ROUTE_CALLSITE_PATCHED_KEY = Symbol.for("absolutejs.devRouteRegistrationCallsitePatched");
|
|
972
|
+
ROUTE_METHOD_NAMES = [
|
|
973
|
+
"all",
|
|
974
|
+
"delete",
|
|
975
|
+
"get",
|
|
976
|
+
"head",
|
|
977
|
+
"options",
|
|
978
|
+
"patch",
|
|
979
|
+
"post",
|
|
980
|
+
"put"
|
|
981
|
+
];
|
|
982
|
+
});
|
|
983
|
+
|
|
984
|
+
// src/client/streamSwap.ts
|
|
985
|
+
var streamSwapRuntime = () => {
|
|
986
|
+
const SLOT_PATCH_EVENT = "absolutejs:slot-patch";
|
|
987
|
+
if (window.__ABS_SLOT_RUNTIME__ === true)
|
|
988
|
+
return;
|
|
989
|
+
window.__ABS_SLOT_RUNTIME__ = true;
|
|
990
|
+
window.__ABS_SLOT_CONSUMERS__ = window.__ABS_SLOT_CONSUMERS__ ?? {};
|
|
991
|
+
window.__ABS_SLOT_PENDING__ = window.__ABS_SLOT_PENDING__ ?? {};
|
|
992
|
+
const consumers = window.__ABS_SLOT_CONSUMERS__;
|
|
993
|
+
const pending = window.__ABS_SLOT_PENDING__;
|
|
994
|
+
const isObjectRecord4 = (value) => Boolean(value) && typeof value === "object";
|
|
995
|
+
const isPatchedPendingEntry = (value) => {
|
|
996
|
+
if (!isObjectRecord4(value))
|
|
997
|
+
return false;
|
|
998
|
+
return value.domPatched === true && "payload" in value;
|
|
1052
999
|
};
|
|
1053
|
-
const
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1000
|
+
const unwrapPendingPayload = (value) => isPatchedPendingEntry(value) ? value.payload : value;
|
|
1001
|
+
const canApplyImmediately = () => window.__ABS_SLOT_HYDRATION_PENDING__ !== true;
|
|
1002
|
+
const isAngularDeferPayload = (payload) => {
|
|
1003
|
+
if (!isObjectRecord4(payload))
|
|
1004
|
+
return false;
|
|
1005
|
+
return payload.kind === "angular-defer";
|
|
1006
|
+
};
|
|
1007
|
+
const isVueSuspensePayload = (payload) => {
|
|
1008
|
+
if (!isObjectRecord4(payload))
|
|
1009
|
+
return false;
|
|
1010
|
+
return payload.kind === "vue-suspense";
|
|
1011
|
+
};
|
|
1012
|
+
const resolveHtml = (payload) => {
|
|
1013
|
+
if (!isObjectRecord4(payload)) {
|
|
1014
|
+
return typeof payload === "string" ? payload : "";
|
|
1057
1015
|
}
|
|
1058
|
-
if (
|
|
1059
|
-
|
|
1016
|
+
if (typeof payload.html === "string") {
|
|
1017
|
+
return payload.html;
|
|
1060
1018
|
}
|
|
1061
|
-
|
|
1019
|
+
return "";
|
|
1062
1020
|
};
|
|
1063
|
-
const
|
|
1064
|
-
const
|
|
1065
|
-
if (
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
const processed = processPending(controller, pending + streamChunkToString(value, decoder), injected);
|
|
1069
|
-
return {
|
|
1070
|
-
done,
|
|
1071
|
-
injected: processed.injected,
|
|
1072
|
-
pending: processed.pending
|
|
1073
|
-
};
|
|
1074
|
-
};
|
|
1075
|
-
const runHeadInjectionLoop = async (controller, reader) => {
|
|
1076
|
-
const consumeNextHeadChunk = async (injected, pending) => {
|
|
1077
|
-
const consumed = await consumeHeadChunk(controller, reader, pending, injected);
|
|
1078
|
-
const nextState = updateInjectedState(consumed, injected, pending);
|
|
1079
|
-
if (nextState.done) {
|
|
1080
|
-
return { injected, pending };
|
|
1081
|
-
}
|
|
1082
|
-
return consumeNextHeadChunk(nextState.injected, nextState.pending);
|
|
1083
|
-
};
|
|
1084
|
-
return consumeNextHeadChunk(false, "");
|
|
1085
|
-
};
|
|
1086
|
-
return new ReadableStream({
|
|
1087
|
-
async start(controller) {
|
|
1088
|
-
const reader = stream.getReader();
|
|
1089
|
-
try {
|
|
1090
|
-
const { injected, pending } = await runHeadInjectionLoop(controller, reader);
|
|
1091
|
-
finishHeadInjectionStream(controller, pending, injected);
|
|
1092
|
-
} catch (error) {
|
|
1093
|
-
controller.error(error);
|
|
1094
|
-
}
|
|
1095
|
-
}
|
|
1096
|
-
});
|
|
1097
|
-
}, pipeStreamWithIslandMarkerDetection = (stream, markup) => {
|
|
1098
|
-
const encoder = new TextEncoder;
|
|
1099
|
-
const decoder = new TextDecoder;
|
|
1100
|
-
const lookbehind = Math.max(ISLAND_MARKER.length, BYTES_PER_KILOBYTE);
|
|
1101
|
-
const processPending = (controller, pending, injected) => {
|
|
1102
|
-
if (injected) {
|
|
1103
|
-
controller.enqueue(encoder.encode(pending));
|
|
1104
|
-
return { injected, pending: "" };
|
|
1105
|
-
}
|
|
1106
|
-
const markerIndex = pending.indexOf(ISLAND_MARKER);
|
|
1107
|
-
if (markerIndex >= 0) {
|
|
1108
|
-
const tagStart = pending.lastIndexOf("<", markerIndex);
|
|
1109
|
-
const injectAt = tagStart >= 0 ? tagStart : markerIndex;
|
|
1110
|
-
const next = `${pending.slice(0, injectAt)}${markup}${pending.slice(injectAt)}`;
|
|
1111
|
-
controller.enqueue(encoder.encode(next));
|
|
1112
|
-
return { injected: true, pending: "" };
|
|
1113
|
-
}
|
|
1114
|
-
return {
|
|
1115
|
-
injected,
|
|
1116
|
-
pending: flushSafePendingText(controller, encoder, pending, lookbehind)
|
|
1117
|
-
};
|
|
1118
|
-
};
|
|
1119
|
-
const finishIslandMarkerStream = (controller, pending) => {
|
|
1120
|
-
const finalPending = pending + decoder.decode();
|
|
1121
|
-
if (finalPending.length > 0) {
|
|
1122
|
-
controller.enqueue(encoder.encode(finalPending));
|
|
1123
|
-
}
|
|
1124
|
-
controller.close();
|
|
1125
|
-
};
|
|
1126
|
-
const consumeIslandChunk = async (controller, reader, pending, injected) => {
|
|
1127
|
-
const { done, value } = await readStreamChunk(reader);
|
|
1128
|
-
if (done || !value) {
|
|
1129
|
-
return { done, injected, pending };
|
|
1130
|
-
}
|
|
1131
|
-
const processed = processPending(controller, pending + streamChunkToString(value, decoder), injected);
|
|
1132
|
-
return {
|
|
1133
|
-
done,
|
|
1134
|
-
injected: processed.injected,
|
|
1135
|
-
pending: processed.pending
|
|
1136
|
-
};
|
|
1137
|
-
};
|
|
1138
|
-
const runIslandMarkerLoop = async (controller, reader) => {
|
|
1139
|
-
const consumeNextIslandChunk = async (injected, pending) => {
|
|
1140
|
-
const consumed = await consumeIslandChunk(controller, reader, pending, injected);
|
|
1141
|
-
const nextState = updateInjectedState(consumed, injected, pending);
|
|
1142
|
-
if (nextState.done) {
|
|
1143
|
-
return { injected, pending };
|
|
1144
|
-
}
|
|
1145
|
-
return consumeNextIslandChunk(nextState.injected, nextState.pending);
|
|
1146
|
-
};
|
|
1147
|
-
return consumeNextIslandChunk(false, "");
|
|
1148
|
-
};
|
|
1149
|
-
return new ReadableStream({
|
|
1150
|
-
async start(controller) {
|
|
1151
|
-
const reader = stream.getReader();
|
|
1152
|
-
try {
|
|
1153
|
-
const { pending } = await runIslandMarkerLoop(controller, reader);
|
|
1154
|
-
finishIslandMarkerStream(controller, pending);
|
|
1155
|
-
} catch (error) {
|
|
1156
|
-
controller.error(error);
|
|
1157
|
-
}
|
|
1158
|
-
}
|
|
1159
|
-
});
|
|
1160
|
-
}, htmlContainsIslands = (html) => html.includes(ISLAND_MARKER), injectIslandPageContext = (html, options) => {
|
|
1161
|
-
const manifest = globalThis.__absoluteManifest;
|
|
1162
|
-
const hasIslands = options?.hasIslands ?? htmlContainsIslands(html);
|
|
1163
|
-
if (!manifest || !hasIslands) {
|
|
1164
|
-
return html;
|
|
1165
|
-
}
|
|
1166
|
-
if (html.includes(MANIFEST_MARKER) || html.includes(ISLAND_STATE_MARKER)) {
|
|
1167
|
-
return html;
|
|
1168
|
-
}
|
|
1169
|
-
return injectHeadMarkup(html, buildIslandsHeadMarkup(manifest));
|
|
1170
|
-
}, injectIslandPageContextStream = (stream, options) => {
|
|
1171
|
-
const manifest = globalThis.__absoluteManifest;
|
|
1172
|
-
if (!manifest)
|
|
1173
|
-
return stream;
|
|
1174
|
-
const markup = buildIslandsHeadMarkup(manifest);
|
|
1175
|
-
if (options?.hasIslands === true) {
|
|
1176
|
-
return pipeStreamWithHeadInjection(stream, markup);
|
|
1177
|
-
}
|
|
1178
|
-
if (options?.hasIslands === false) {
|
|
1179
|
-
return stream;
|
|
1180
|
-
}
|
|
1181
|
-
return pipeStreamWithIslandMarkerDetection(stream, markup);
|
|
1182
|
-
}, setCurrentIslandManifest = (manifest) => {
|
|
1183
|
-
globalThis.__absoluteManifest = manifest;
|
|
1184
|
-
};
|
|
1185
|
-
var init_islandPageContext = __esm(() => {
|
|
1186
|
-
init_constants();
|
|
1187
|
-
});
|
|
1188
|
-
|
|
1189
|
-
// src/core/devRouteRegistrationCallsite.ts
|
|
1190
|
-
var exports_devRouteRegistrationCallsite = {};
|
|
1191
|
-
__export(exports_devRouteRegistrationCallsite, {
|
|
1192
|
-
patchElysiaRouteRegistrationCallsites: () => patchElysiaRouteRegistrationCallsites,
|
|
1193
|
-
getCurrentRouteRegistrationCallsite: () => getCurrentRouteRegistrationCallsite
|
|
1194
|
-
});
|
|
1195
|
-
import { AsyncLocalStorage } from "async_hooks";
|
|
1196
|
-
import { Elysia } from "elysia";
|
|
1197
|
-
var ROUTE_CALLSITE_STORAGE_KEY, ROUTE_CALLSITE_PATCHED_KEY, ROUTE_METHOD_NAMES, isObjectRecord3 = (value) => Boolean(value) && typeof value === "object", isAsyncLocalStorage2 = (value) => isObjectRecord3(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function", getRouteCallsiteStorage = () => {
|
|
1198
|
-
const value = Reflect.get(globalThis, ROUTE_CALLSITE_STORAGE_KEY);
|
|
1199
|
-
if (value === null || typeof value === "undefined") {
|
|
1200
|
-
return;
|
|
1201
|
-
}
|
|
1202
|
-
return isAsyncLocalStorage2(value) ? value : undefined;
|
|
1203
|
-
}, ensureRouteCallsiteStorage = () => {
|
|
1204
|
-
const existing = getRouteCallsiteStorage();
|
|
1205
|
-
if (existing) {
|
|
1206
|
-
return existing;
|
|
1207
|
-
}
|
|
1208
|
-
const storage = new AsyncLocalStorage;
|
|
1209
|
-
Reflect.set(globalThis, ROUTE_CALLSITE_STORAGE_KEY, storage);
|
|
1210
|
-
return storage;
|
|
1211
|
-
}, normalizeCallsitePath = (value) => value.replace(`${process.cwd()}/`, "").replace(process.cwd(), "").replace(/^\.\/+/, ""), extractRouteRegistrationCallsite = (stack) => {
|
|
1212
|
-
const frames = stack.split(`
|
|
1213
|
-
`).slice(1).map((line) => line.trim());
|
|
1214
|
-
for (const frame of frames) {
|
|
1215
|
-
if (frame.includes("/node_modules/") || frame.includes("/dist/") || frame.includes("/src/core/devRouteRegistrationCallsite.")) {
|
|
1216
|
-
continue;
|
|
1217
|
-
}
|
|
1218
|
-
const locationMatch = frame.match(/\((\/[^)]+:\d+:\d+)\)$/) ?? frame.match(/at (\/[^ ]+:\d+:\d+)$/);
|
|
1219
|
-
if (locationMatch?.[1]) {
|
|
1220
|
-
return normalizeCallsitePath(locationMatch[1]);
|
|
1221
|
-
}
|
|
1222
|
-
}
|
|
1223
|
-
return;
|
|
1224
|
-
}, captureRouteRegistrationCallsite = () => {
|
|
1225
|
-
const { stack } = new Error;
|
|
1226
|
-
if (!stack) {
|
|
1227
|
-
return;
|
|
1228
|
-
}
|
|
1229
|
-
return extractRouteRegistrationCallsite(stack);
|
|
1230
|
-
}, wrapRouteHandlerWithCallsite = (handler, callsite) => {
|
|
1231
|
-
if (typeof handler !== "function" || !callsite) {
|
|
1232
|
-
return handler;
|
|
1233
|
-
}
|
|
1234
|
-
const storage = ensureRouteCallsiteStorage();
|
|
1235
|
-
return function wrappedRouteHandler(...args) {
|
|
1236
|
-
return storage.run({ callsite }, () => Reflect.apply(handler, this, args));
|
|
1237
|
-
};
|
|
1238
|
-
}, getCurrentRouteRegistrationCallsite = () => getRouteCallsiteStorage()?.getStore()?.callsite, patchElysiaRouteRegistrationCallsites = () => {
|
|
1239
|
-
if (false) {}
|
|
1240
|
-
if (Reflect.get(globalThis, ROUTE_CALLSITE_PATCHED_KEY) === true) {
|
|
1241
|
-
return;
|
|
1242
|
-
}
|
|
1243
|
-
const prototype = Elysia.prototype;
|
|
1244
|
-
for (const methodName of ROUTE_METHOD_NAMES) {
|
|
1245
|
-
const originalMethod = prototype[methodName];
|
|
1246
|
-
if (typeof originalMethod !== "function") {
|
|
1247
|
-
continue;
|
|
1248
|
-
}
|
|
1249
|
-
prototype[methodName] = function patchedRouteMethod(path, handler, ...rest) {
|
|
1250
|
-
const callsite = captureRouteRegistrationCallsite();
|
|
1251
|
-
return Reflect.apply(originalMethod, this, [
|
|
1252
|
-
path,
|
|
1253
|
-
wrapRouteHandlerWithCallsite(handler, callsite),
|
|
1254
|
-
...rest
|
|
1255
|
-
]);
|
|
1256
|
-
};
|
|
1257
|
-
}
|
|
1258
|
-
Reflect.set(globalThis, ROUTE_CALLSITE_PATCHED_KEY, true);
|
|
1259
|
-
};
|
|
1260
|
-
var init_devRouteRegistrationCallsite = __esm(() => {
|
|
1261
|
-
ROUTE_CALLSITE_STORAGE_KEY = Symbol.for("absolutejs.devRouteRegistrationCallsiteStorage");
|
|
1262
|
-
ROUTE_CALLSITE_PATCHED_KEY = Symbol.for("absolutejs.devRouteRegistrationCallsitePatched");
|
|
1263
|
-
ROUTE_METHOD_NAMES = [
|
|
1264
|
-
"all",
|
|
1265
|
-
"delete",
|
|
1266
|
-
"get",
|
|
1267
|
-
"head",
|
|
1268
|
-
"options",
|
|
1269
|
-
"patch",
|
|
1270
|
-
"post",
|
|
1271
|
-
"put"
|
|
1272
|
-
];
|
|
1273
|
-
});
|
|
1274
|
-
|
|
1275
|
-
// src/client/streamSwap.ts
|
|
1276
|
-
var streamSwapRuntime = () => {
|
|
1277
|
-
const SLOT_PATCH_EVENT = "absolutejs:slot-patch";
|
|
1278
|
-
if (window.__ABS_SLOT_RUNTIME__ === true)
|
|
1279
|
-
return;
|
|
1280
|
-
window.__ABS_SLOT_RUNTIME__ = true;
|
|
1281
|
-
window.__ABS_SLOT_CONSUMERS__ = window.__ABS_SLOT_CONSUMERS__ ?? {};
|
|
1282
|
-
window.__ABS_SLOT_PENDING__ = window.__ABS_SLOT_PENDING__ ?? {};
|
|
1283
|
-
const consumers = window.__ABS_SLOT_CONSUMERS__;
|
|
1284
|
-
const pending = window.__ABS_SLOT_PENDING__;
|
|
1285
|
-
const isObjectRecord4 = (value) => Boolean(value) && typeof value === "object";
|
|
1286
|
-
const isPatchedPendingEntry = (value) => {
|
|
1287
|
-
if (!isObjectRecord4(value))
|
|
1288
|
-
return false;
|
|
1289
|
-
return value.domPatched === true && "payload" in value;
|
|
1290
|
-
};
|
|
1291
|
-
const unwrapPendingPayload = (value) => isPatchedPendingEntry(value) ? value.payload : value;
|
|
1292
|
-
const canApplyImmediately = () => window.__ABS_SLOT_HYDRATION_PENDING__ !== true;
|
|
1293
|
-
const isAngularDeferPayload = (payload) => {
|
|
1294
|
-
if (!isObjectRecord4(payload))
|
|
1295
|
-
return false;
|
|
1296
|
-
return payload.kind === "angular-defer";
|
|
1297
|
-
};
|
|
1298
|
-
const isVueSuspensePayload = (payload) => {
|
|
1299
|
-
if (!isObjectRecord4(payload))
|
|
1300
|
-
return false;
|
|
1301
|
-
return payload.kind === "vue-suspense";
|
|
1302
|
-
};
|
|
1303
|
-
const resolveHtml = (payload) => {
|
|
1304
|
-
if (!isObjectRecord4(payload)) {
|
|
1305
|
-
return typeof payload === "string" ? payload : "";
|
|
1306
|
-
}
|
|
1307
|
-
if (typeof payload.html === "string") {
|
|
1308
|
-
return payload.html;
|
|
1309
|
-
}
|
|
1310
|
-
return "";
|
|
1311
|
-
};
|
|
1312
|
-
const apply = (id, pendingEntry) => {
|
|
1313
|
-
const payload = unwrapPendingPayload(pendingEntry);
|
|
1314
|
-
if (!canApplyImmediately()) {
|
|
1315
|
-
pending[id] = payload;
|
|
1316
|
-
return;
|
|
1021
|
+
const apply = (id, pendingEntry) => {
|
|
1022
|
+
const payload = unwrapPendingPayload(pendingEntry);
|
|
1023
|
+
if (!canApplyImmediately()) {
|
|
1024
|
+
pending[id] = payload;
|
|
1025
|
+
return;
|
|
1317
1026
|
}
|
|
1318
1027
|
const consumer = consumers[id];
|
|
1319
1028
|
if (typeof consumer !== "function") {
|
|
@@ -1948,25 +1657,567 @@ var init_streamingSlots = __esm(() => {
|
|
|
1948
1657
|
};
|
|
1949
1658
|
});
|
|
1950
1659
|
|
|
1951
|
-
// src/
|
|
1952
|
-
var
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
streamingSlots = [],
|
|
1961
|
-
policy
|
|
1962
|
-
} = {}) => {
|
|
1963
|
-
if (!response.body || streamingSlots.length === 0) {
|
|
1964
|
-
return response;
|
|
1660
|
+
// src/utils/getDurationString.ts
|
|
1661
|
+
var getDurationString = (duration) => {
|
|
1662
|
+
let durationString;
|
|
1663
|
+
if (duration < MILLISECONDS_IN_A_SECOND) {
|
|
1664
|
+
durationString = `${duration.toFixed(TIME_PRECISION)}ms`;
|
|
1665
|
+
} else if (duration < MILLISECONDS_IN_A_MINUTE) {
|
|
1666
|
+
durationString = `${(duration / MILLISECONDS_IN_A_SECOND).toFixed(TIME_PRECISION)}s`;
|
|
1667
|
+
} else {
|
|
1668
|
+
durationString = `${(duration / MILLISECONDS_IN_A_MINUTE).toFixed(TIME_PRECISION)}m`;
|
|
1965
1669
|
}
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1670
|
+
return durationString;
|
|
1671
|
+
};
|
|
1672
|
+
var init_getDurationString = __esm(() => {
|
|
1673
|
+
init_constants();
|
|
1674
|
+
});
|
|
1675
|
+
|
|
1676
|
+
// src/utils/startupBanner.ts
|
|
1677
|
+
var colors, MONTHS, formatTimestamp = () => {
|
|
1678
|
+
const now = new Date;
|
|
1679
|
+
const month = MONTHS[now.getMonth()];
|
|
1680
|
+
const day = now.getDate().toString().padStart(2, "0");
|
|
1681
|
+
let hours = now.getHours();
|
|
1682
|
+
const minutes = now.getMinutes().toString().padStart(2, "0");
|
|
1683
|
+
const seconds = now.getSeconds().toString().padStart(2, "0");
|
|
1684
|
+
const ampm = hours >= HOURS_IN_HALF_DAY ? "PM" : "AM";
|
|
1685
|
+
hours = hours % HOURS_IN_HALF_DAY || HOURS_IN_HALF_DAY;
|
|
1686
|
+
return `${month} ${day} ${hours}:${minutes}:${seconds} ${ampm}`;
|
|
1687
|
+
}, startupBanner = (options) => {
|
|
1688
|
+
const {
|
|
1689
|
+
version,
|
|
1690
|
+
readyDuration,
|
|
1691
|
+
buildDuration,
|
|
1692
|
+
port,
|
|
1693
|
+
host,
|
|
1694
|
+
networkUrl,
|
|
1695
|
+
protocol = "http"
|
|
1696
|
+
} = options;
|
|
1697
|
+
const name = `${colors.cyan}${colors.bold}ABSOLUTEJS${colors.reset}`;
|
|
1698
|
+
const ver = `${colors.dim}v${version}${colors.reset}`;
|
|
1699
|
+
const time = `${colors.dim}ready in${colors.reset} ${colors.bold}${getDurationString(readyDuration)}${colors.reset}`;
|
|
1700
|
+
const build = typeof buildDuration === "number" && Number.isFinite(buildDuration) ? ` ${colors.dim}(build ${getDurationString(buildDuration)})${colors.reset}` : "";
|
|
1701
|
+
console.log("");
|
|
1702
|
+
console.log(` ${name} ${ver} ${time}${build}`);
|
|
1703
|
+
console.log("");
|
|
1704
|
+
console.log(` ${colors.green}\u279C${colors.reset} ${colors.bold}Local:${colors.reset} ${protocol}://${host === "0.0.0.0" ? "localhost" : host}:${port}/`);
|
|
1705
|
+
if (networkUrl) {
|
|
1706
|
+
console.log(` ${colors.green}\u279C${colors.reset} ${colors.bold}Network:${colors.reset} ${networkUrl}`);
|
|
1707
|
+
}
|
|
1708
|
+
console.log("");
|
|
1709
|
+
};
|
|
1710
|
+
var init_startupBanner = __esm(() => {
|
|
1711
|
+
init_constants();
|
|
1712
|
+
init_getDurationString();
|
|
1713
|
+
colors = {
|
|
1714
|
+
bold: "\x1B[1m",
|
|
1715
|
+
cyan: "\x1B[36m",
|
|
1716
|
+
dim: "\x1B[2m",
|
|
1717
|
+
green: "\x1B[32m",
|
|
1718
|
+
reset: "\x1B[0m"
|
|
1719
|
+
};
|
|
1720
|
+
MONTHS = [
|
|
1721
|
+
"Jan",
|
|
1722
|
+
"Feb",
|
|
1723
|
+
"Mar",
|
|
1724
|
+
"Apr",
|
|
1725
|
+
"May",
|
|
1726
|
+
"Jun",
|
|
1727
|
+
"Jul",
|
|
1728
|
+
"Aug",
|
|
1729
|
+
"Sep",
|
|
1730
|
+
"Oct",
|
|
1731
|
+
"Nov",
|
|
1732
|
+
"Dec"
|
|
1733
|
+
];
|
|
1734
|
+
});
|
|
1735
|
+
|
|
1736
|
+
// src/utils/logger.ts
|
|
1737
|
+
var colors2, frameworkColors, formatPath = (filePath) => {
|
|
1738
|
+
const cwd = process.cwd();
|
|
1739
|
+
let relative3 = filePath.startsWith(cwd) ? filePath.slice(cwd.length + 1) : filePath;
|
|
1740
|
+
relative3 = relative3.replace(/\\/g, "/");
|
|
1741
|
+
if (!relative3.startsWith("/")) {
|
|
1742
|
+
relative3 = `/${relative3}`;
|
|
1743
|
+
}
|
|
1744
|
+
return relative3;
|
|
1745
|
+
}, getFrameworkColor = (framework) => frameworkColors[framework] || colors2.white, log = (action, options) => {
|
|
1746
|
+
const timestamp = `${colors2.dim}${formatTimestamp()}${colors2.reset}`;
|
|
1747
|
+
const tag = `${colors2.cyan}[hmr]${colors2.reset}`;
|
|
1748
|
+
let message = action;
|
|
1749
|
+
if (options?.path) {
|
|
1750
|
+
const pathColor = options.framework ? getFrameworkColor(options.framework) : colors2.white;
|
|
1751
|
+
message += ` ${pathColor}${formatPath(options.path)}${colors2.reset}`;
|
|
1752
|
+
}
|
|
1753
|
+
if (options?.duration !== undefined) {
|
|
1754
|
+
message += ` ${colors2.dim}(${options.duration}ms)${colors2.reset}`;
|
|
1755
|
+
}
|
|
1756
|
+
console.log(`${timestamp} ${tag} ${message}`);
|
|
1757
|
+
}, logCssUpdate = (path, framework, duration) => {
|
|
1758
|
+
log("css update", { duration, framework: framework ?? "css", path });
|
|
1759
|
+
}, logError = (message, error) => {
|
|
1760
|
+
const timestamp = `${colors2.dim}${formatTimestamp()}${colors2.reset}`;
|
|
1761
|
+
const tag = `${colors2.red}[hmr]${colors2.reset}`;
|
|
1762
|
+
const errorMsg = error instanceof Error ? error.message : error;
|
|
1763
|
+
const fullMessage = `${colors2.red}error${colors2.reset} ${message}${errorMsg ? `: ${errorMsg}` : ""}`;
|
|
1764
|
+
console.error(`${timestamp} ${tag} ${fullMessage}`);
|
|
1765
|
+
}, logHmrUpdate = (path, framework, duration) => {
|
|
1766
|
+
log("hmr update", { duration, framework, path });
|
|
1767
|
+
}, logScriptUpdate = (path, framework, duration) => {
|
|
1768
|
+
log("script update", { duration, framework, path });
|
|
1769
|
+
}, logServerReload = () => {
|
|
1770
|
+
log(`${colors2.cyan}server module reloaded${colors2.reset}`);
|
|
1771
|
+
}, logWarn = (message) => {
|
|
1772
|
+
const timestamp = `${colors2.dim}${formatTimestamp()}${colors2.reset}`;
|
|
1773
|
+
const tag = `${colors2.yellow}[hmr]${colors2.reset}`;
|
|
1774
|
+
console.log(`${timestamp} ${tag} ${colors2.yellow}warning ${message}${colors2.reset}`);
|
|
1775
|
+
};
|
|
1776
|
+
var init_logger = __esm(() => {
|
|
1777
|
+
init_startupBanner();
|
|
1778
|
+
colors2 = {
|
|
1779
|
+
blue: "\x1B[34m",
|
|
1780
|
+
bold: "\x1B[1m",
|
|
1781
|
+
cyan: "\x1B[36m",
|
|
1782
|
+
dim: "\x1B[2m",
|
|
1783
|
+
green: "\x1B[32m",
|
|
1784
|
+
magenta: "\x1B[35m",
|
|
1785
|
+
red: "\x1B[31m",
|
|
1786
|
+
reset: "\x1B[0m",
|
|
1787
|
+
white: "\x1B[37m",
|
|
1788
|
+
yellow: "\x1B[33m"
|
|
1789
|
+
};
|
|
1790
|
+
frameworkColors = {
|
|
1791
|
+
angular: colors2.magenta,
|
|
1792
|
+
assets: colors2.dim,
|
|
1793
|
+
css: colors2.cyan,
|
|
1794
|
+
html: colors2.white,
|
|
1795
|
+
htmx: colors2.white,
|
|
1796
|
+
react: colors2.blue,
|
|
1797
|
+
svelte: colors2.yellow,
|
|
1798
|
+
vue: colors2.green
|
|
1799
|
+
};
|
|
1800
|
+
});
|
|
1801
|
+
|
|
1802
|
+
// src/core/ssrCache.ts
|
|
1803
|
+
var dirtyFrameworks, markSsrCacheDirty = (framework) => {
|
|
1804
|
+
dirtyFrameworks.add(framework);
|
|
1805
|
+
}, isSsrCacheDirty = (framework) => dirtyFrameworks.has(framework);
|
|
1806
|
+
var init_ssrCache = __esm(() => {
|
|
1807
|
+
dirtyFrameworks = new Set;
|
|
1808
|
+
});
|
|
1809
|
+
|
|
1810
|
+
// src/utils/stringModifiers.ts
|
|
1811
|
+
var normalizeSlug = (str) => str.trim().replace(/\s+/g, "-").replace(/[^A-Za-z0-9\-_]+/g, "").replace(/[-_]{2,}/g, "-"), toKebab = (str) => normalizeSlug(str).replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), toPascal = (str) => {
|
|
1812
|
+
if (!str.includes("-") && !str.includes("_")) {
|
|
1813
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
1814
|
+
}
|
|
1815
|
+
return normalizeSlug(str).split(/[-_]/).filter(Boolean).map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1).toLowerCase()).join("");
|
|
1816
|
+
}, toScreamingSnake = (str) => str.replace(/([a-z0-9])([A-Z])/g, "$1_$2").toUpperCase();
|
|
1817
|
+
|
|
1818
|
+
// src/svelte/renderToReadableStream.ts
|
|
1819
|
+
var exports_renderToReadableStream = {};
|
|
1820
|
+
__export(exports_renderToReadableStream, {
|
|
1821
|
+
renderToReadableStream: () => renderToReadableStream,
|
|
1822
|
+
SVELTE_PAGE_ROOT_ID: () => SVELTE_PAGE_ROOT_ID
|
|
1823
|
+
});
|
|
1824
|
+
var SVELTE_PAGE_ROOT_ID = "__absolute_svelte_root__", renderToReadableStream = async (component, props, {
|
|
1825
|
+
bootstrapScriptContent,
|
|
1826
|
+
bootstrapScripts = [],
|
|
1827
|
+
bootstrapModules = [],
|
|
1828
|
+
nonce,
|
|
1829
|
+
onError = console.error,
|
|
1830
|
+
progressiveChunkSize = DEFAULT_CHUNK_SIZE,
|
|
1831
|
+
signal,
|
|
1832
|
+
headContent,
|
|
1833
|
+
bodyContent
|
|
1834
|
+
} = {}) => {
|
|
1835
|
+
try {
|
|
1836
|
+
const { render } = await import("svelte/server");
|
|
1837
|
+
const rendered = typeof props === "undefined" ? await render(component) : await render(component, { props });
|
|
1838
|
+
const { head, body } = rendered;
|
|
1839
|
+
const nonceAttr = nonce ? ` nonce="${nonce}"` : "";
|
|
1840
|
+
const scripts = (bootstrapScriptContent ? `<script${nonceAttr}>${escapeScriptContent(bootstrapScriptContent)}</script>` : "") + bootstrapScripts.map((src) => `<script${nonceAttr} src="${src}"></script>`).join("") + bootstrapModules.map((src) => `<script${nonceAttr} type="module" src="${src}"></script>`).join("");
|
|
1841
|
+
const encoder = new TextEncoder;
|
|
1842
|
+
const full = encoder.encode(`<!DOCTYPE html><html lang="en"><head>${head}${headContent ?? ""}</head><body><div id="${SVELTE_PAGE_ROOT_ID}">${body}</div>${scripts}${bodyContent ?? ""}</body></html>`);
|
|
1843
|
+
let offset = 0;
|
|
1844
|
+
return new ReadableStream({
|
|
1845
|
+
type: "bytes",
|
|
1846
|
+
cancel(reason) {
|
|
1847
|
+
onError?.(reason);
|
|
1848
|
+
},
|
|
1849
|
+
pull(controller) {
|
|
1850
|
+
if (signal?.aborted) {
|
|
1851
|
+
controller.close();
|
|
1852
|
+
return;
|
|
1853
|
+
}
|
|
1854
|
+
if (offset >= full.length) {
|
|
1855
|
+
controller.close();
|
|
1856
|
+
return;
|
|
1857
|
+
}
|
|
1858
|
+
const end = Math.min(offset + progressiveChunkSize, full.length);
|
|
1859
|
+
controller.enqueue(full.subarray(offset, end));
|
|
1860
|
+
offset = end;
|
|
1861
|
+
}
|
|
1862
|
+
});
|
|
1863
|
+
} catch (error) {
|
|
1864
|
+
onError?.(error);
|
|
1865
|
+
throw error;
|
|
1866
|
+
}
|
|
1867
|
+
};
|
|
1868
|
+
var init_renderToReadableStream = __esm(() => {
|
|
1869
|
+
init_constants();
|
|
1870
|
+
init_escapeScriptContent();
|
|
1871
|
+
});
|
|
1872
|
+
|
|
1873
|
+
// src/core/streamingSlotRegistrar.ts
|
|
1874
|
+
var STREAMING_SLOT_REGISTRAR_KEY = Symbol.for("absolutejs.streamingSlotRegistrar");
|
|
1875
|
+
var STREAMING_SLOT_WARNING_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotWarningController");
|
|
1876
|
+
var STREAMING_SLOT_COLLECTION_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotCollectionController");
|
|
1877
|
+
var getRegisteredStreamingSlotRegistrar = () => {
|
|
1878
|
+
const value = Reflect.get(globalThis, STREAMING_SLOT_REGISTRAR_KEY);
|
|
1879
|
+
if (typeof value === "function" || value === null) {
|
|
1880
|
+
return value;
|
|
1881
|
+
}
|
|
1882
|
+
return;
|
|
1883
|
+
};
|
|
1884
|
+
var isObjectRecord = (value) => Boolean(value) && typeof value === "object";
|
|
1885
|
+
var isStreamingSlotWarningController = (value) => isObjectRecord(value) && ("maybeWarn" in value) && typeof value.maybeWarn === "function";
|
|
1886
|
+
var isStreamingSlotCollectionController = (value) => isObjectRecord(value) && ("isCollecting" in value) && typeof value.isCollecting === "function";
|
|
1887
|
+
var getWarningController = () => {
|
|
1888
|
+
const value = Reflect.get(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY);
|
|
1889
|
+
if (value === null || typeof value === "undefined")
|
|
1890
|
+
return;
|
|
1891
|
+
return isStreamingSlotWarningController(value) ? value : undefined;
|
|
1892
|
+
};
|
|
1893
|
+
var getCollectionController = () => {
|
|
1894
|
+
const value = Reflect.get(globalThis, STREAMING_SLOT_COLLECTION_STORAGE_KEY);
|
|
1895
|
+
if (value === null || typeof value === "undefined")
|
|
1896
|
+
return;
|
|
1897
|
+
return isStreamingSlotCollectionController(value) ? value : undefined;
|
|
1898
|
+
};
|
|
1899
|
+
var hasRegisteredStreamingSlotRegistrar = () => typeof getRegisteredStreamingSlotRegistrar() === "function";
|
|
1900
|
+
var isStreamingSlotCollectionActive = () => getCollectionController()?.isCollecting() === true;
|
|
1901
|
+
var registerStreamingSlot = (slot) => {
|
|
1902
|
+
getRegisteredStreamingSlotRegistrar()?.(slot);
|
|
1903
|
+
};
|
|
1904
|
+
var setStreamingSlotCollectionController = (controller) => {
|
|
1905
|
+
Reflect.set(globalThis, STREAMING_SLOT_COLLECTION_STORAGE_KEY, controller);
|
|
1906
|
+
};
|
|
1907
|
+
var setStreamingSlotRegistrar = (nextRegistrar) => {
|
|
1908
|
+
Reflect.set(globalThis, STREAMING_SLOT_REGISTRAR_KEY, nextRegistrar);
|
|
1909
|
+
};
|
|
1910
|
+
var setStreamingSlotWarningController = (controller) => {
|
|
1911
|
+
Reflect.set(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY, controller);
|
|
1912
|
+
};
|
|
1913
|
+
var warnMissingStreamingSlotCollector = (primitiveName) => {
|
|
1914
|
+
if (isStreamingSlotCollectionActive()) {
|
|
1915
|
+
return;
|
|
1916
|
+
}
|
|
1917
|
+
getWarningController()?.maybeWarn(primitiveName);
|
|
1918
|
+
};
|
|
1919
|
+
|
|
1920
|
+
// src/core/streamingSlotRegistry.ts
|
|
1921
|
+
var STREAMING_SLOT_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotAsyncLocalStorage");
|
|
1922
|
+
var isObjectRecord2 = (value) => Boolean(value) && typeof value === "object";
|
|
1923
|
+
var isAsyncLocalStorage = (value) => isObjectRecord2(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function";
|
|
1924
|
+
var getStorageGlobal = () => {
|
|
1925
|
+
const value = Reflect.get(globalThis, STREAMING_SLOT_STORAGE_KEY);
|
|
1926
|
+
if (value === null || typeof value === "undefined") {
|
|
1927
|
+
return value;
|
|
1928
|
+
}
|
|
1929
|
+
return isAsyncLocalStorage(value) ? value : undefined;
|
|
1930
|
+
};
|
|
1931
|
+
var isServerRuntime = () => typeof process !== "undefined" && typeof process.versions?.node === "string";
|
|
1932
|
+
var ensureAsyncLocalStorage = async () => {
|
|
1933
|
+
const storage = getStorageGlobal();
|
|
1934
|
+
if (typeof storage !== "undefined") {
|
|
1935
|
+
return storage;
|
|
1936
|
+
}
|
|
1937
|
+
if (!isServerRuntime()) {
|
|
1938
|
+
Reflect.set(globalThis, STREAMING_SLOT_STORAGE_KEY, null);
|
|
1939
|
+
return getStorageGlobal();
|
|
1940
|
+
}
|
|
1941
|
+
const mod = await import("async_hooks");
|
|
1942
|
+
Reflect.set(globalThis, STREAMING_SLOT_STORAGE_KEY, new mod.AsyncLocalStorage);
|
|
1943
|
+
return getStorageGlobal();
|
|
1944
|
+
};
|
|
1945
|
+
var getActiveSlotStore = () => {
|
|
1946
|
+
const storage = getStorageGlobal();
|
|
1947
|
+
if (!storage)
|
|
1948
|
+
return;
|
|
1949
|
+
return storage.getStore();
|
|
1950
|
+
};
|
|
1951
|
+
var registerStreamingSlot2 = (slot) => {
|
|
1952
|
+
const store = getActiveSlotStore();
|
|
1953
|
+
if (!store)
|
|
1954
|
+
return;
|
|
1955
|
+
store.set(slot.id, slot);
|
|
1956
|
+
};
|
|
1957
|
+
setStreamingSlotRegistrar(registerStreamingSlot2);
|
|
1958
|
+
setStreamingSlotCollectionController({
|
|
1959
|
+
isCollecting: () => getActiveSlotStore() !== undefined
|
|
1960
|
+
});
|
|
1961
|
+
var hasActiveStreamingSlotRegistry = () => getActiveSlotStore() !== undefined;
|
|
1962
|
+
var runWithStreamingSlotRegistry = async (task) => {
|
|
1963
|
+
const storage = await ensureAsyncLocalStorage();
|
|
1964
|
+
if (!storage) {
|
|
1965
|
+
const slots = [];
|
|
1966
|
+
return {
|
|
1967
|
+
result: await task(),
|
|
1968
|
+
slots
|
|
1969
|
+
};
|
|
1970
|
+
}
|
|
1971
|
+
return storage.run(new Map, async () => {
|
|
1972
|
+
const result = await task();
|
|
1973
|
+
const store = storage.getStore();
|
|
1974
|
+
return {
|
|
1975
|
+
result,
|
|
1976
|
+
slots: store ? [...store.values()] : []
|
|
1977
|
+
};
|
|
1978
|
+
});
|
|
1979
|
+
};
|
|
1980
|
+
|
|
1981
|
+
// src/svelte/pageHandler.ts
|
|
1982
|
+
init_svelteServerModule();
|
|
1983
|
+
|
|
1984
|
+
// src/core/islandPageContext.ts
|
|
1985
|
+
init_constants();
|
|
1986
|
+
var BOOTSTRAP_MANIFEST_KEY = "BootstrapClient";
|
|
1987
|
+
var ISLAND_MARKER = 'data-island="true"';
|
|
1988
|
+
var MANIFEST_MARKER = "__ABSOLUTE_MANIFEST__";
|
|
1989
|
+
var ISLAND_STATE_MARKER = "__ABS_ISLAND_STATE__";
|
|
1990
|
+
var CLOSING_HEAD_TAG = "</head>";
|
|
1991
|
+
var buildIslandsHeadMarkup = (manifest) => {
|
|
1992
|
+
const manifestScript = `<script>window.__ABSOLUTE_MANIFEST__ = ${JSON.stringify(manifest)}</script>`;
|
|
1993
|
+
const islandStateScript = `<script>window.__ABS_ISLAND_STATE__ = ${JSON.stringify(globalThis.__ABS_ISLAND_STATE__ ?? {})}</script>`;
|
|
1994
|
+
const bootstrapPath = manifest[BOOTSTRAP_MANIFEST_KEY];
|
|
1995
|
+
const bootstrapScript = bootstrapPath ? `<script type="module" src="${bootstrapPath}"></script>` : "";
|
|
1996
|
+
return `${manifestScript}${islandStateScript}${bootstrapScript}`;
|
|
1997
|
+
};
|
|
1998
|
+
var injectHeadMarkup = (html, markup) => {
|
|
1999
|
+
const closingHeadIndex = html.indexOf("</head>");
|
|
2000
|
+
if (closingHeadIndex >= 0) {
|
|
2001
|
+
return `${html.slice(0, closingHeadIndex)}${markup}${html.slice(closingHeadIndex)}`;
|
|
2002
|
+
}
|
|
2003
|
+
const openingBodyIndex = html.indexOf("<body");
|
|
2004
|
+
if (openingBodyIndex >= 0) {
|
|
2005
|
+
const bodyStart = html.indexOf(">", openingBodyIndex);
|
|
2006
|
+
if (bodyStart >= 0) {
|
|
2007
|
+
return `${html.slice(0, openingBodyIndex)}<head>${markup}</head>${html.slice(openingBodyIndex)}`;
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
return `<!DOCTYPE html><html><head>${markup}</head><body>${html}</body></html>`;
|
|
2011
|
+
};
|
|
2012
|
+
var streamChunkToString = (value, decoder) => typeof value === "string" ? value : decoder.decode(value, { stream: true });
|
|
2013
|
+
var flushSafePendingText = (controller, encoder, pending, lookbehind) => {
|
|
2014
|
+
if (pending.length <= lookbehind) {
|
|
2015
|
+
return pending;
|
|
2016
|
+
}
|
|
2017
|
+
const safeText = pending.slice(0, pending.length - lookbehind);
|
|
2018
|
+
controller.enqueue(encoder.encode(safeText));
|
|
2019
|
+
return pending.slice(-lookbehind);
|
|
2020
|
+
};
|
|
2021
|
+
var updateInjectedState = (consumed, injected, pending) => {
|
|
2022
|
+
if (consumed.done) {
|
|
2023
|
+
return { done: true, injected, pending };
|
|
2024
|
+
}
|
|
2025
|
+
return {
|
|
2026
|
+
done: false,
|
|
2027
|
+
injected: consumed.injected,
|
|
2028
|
+
pending: consumed.pending
|
|
2029
|
+
};
|
|
2030
|
+
};
|
|
2031
|
+
var readStreamChunk = async (reader) => {
|
|
2032
|
+
const { done, value } = await reader.read();
|
|
2033
|
+
if (done || !value) {
|
|
2034
|
+
return { done, value: undefined };
|
|
2035
|
+
}
|
|
2036
|
+
return { done, value };
|
|
2037
|
+
};
|
|
2038
|
+
var pipeStreamWithHeadInjection = (stream, markup) => {
|
|
2039
|
+
const encoder = new TextEncoder;
|
|
2040
|
+
const decoder = new TextDecoder;
|
|
2041
|
+
const lookbehind = CLOSING_HEAD_TAG.length - 1;
|
|
2042
|
+
const processPending = (controller, pending, injected) => {
|
|
2043
|
+
if (injected) {
|
|
2044
|
+
controller.enqueue(encoder.encode(pending));
|
|
2045
|
+
return { injected, pending: "" };
|
|
2046
|
+
}
|
|
2047
|
+
const headIndex = pending.indexOf(CLOSING_HEAD_TAG);
|
|
2048
|
+
if (headIndex >= 0) {
|
|
2049
|
+
const next = `${pending.slice(0, headIndex)}${markup}${pending.slice(headIndex)}`;
|
|
2050
|
+
controller.enqueue(encoder.encode(next));
|
|
2051
|
+
return { injected: true, pending: "" };
|
|
2052
|
+
}
|
|
2053
|
+
return {
|
|
2054
|
+
injected,
|
|
2055
|
+
pending: flushSafePendingText(controller, encoder, pending, lookbehind)
|
|
2056
|
+
};
|
|
2057
|
+
};
|
|
2058
|
+
const finishHeadInjectionStream = (controller, pending, injected) => {
|
|
2059
|
+
let finalPending = pending + decoder.decode();
|
|
2060
|
+
if (!injected) {
|
|
2061
|
+
finalPending = injectHeadMarkup(finalPending, markup);
|
|
2062
|
+
}
|
|
2063
|
+
if (finalPending.length > 0) {
|
|
2064
|
+
controller.enqueue(encoder.encode(finalPending));
|
|
2065
|
+
}
|
|
2066
|
+
controller.close();
|
|
2067
|
+
};
|
|
2068
|
+
const consumeHeadChunk = async (controller, reader, pending, injected) => {
|
|
2069
|
+
const { done, value } = await readStreamChunk(reader);
|
|
2070
|
+
if (done || !value) {
|
|
2071
|
+
return { done, injected, pending };
|
|
2072
|
+
}
|
|
2073
|
+
const processed = processPending(controller, pending + streamChunkToString(value, decoder), injected);
|
|
2074
|
+
return {
|
|
2075
|
+
done,
|
|
2076
|
+
injected: processed.injected,
|
|
2077
|
+
pending: processed.pending
|
|
2078
|
+
};
|
|
2079
|
+
};
|
|
2080
|
+
const runHeadInjectionLoop = async (controller, reader) => {
|
|
2081
|
+
const consumeNextHeadChunk = async (injected, pending) => {
|
|
2082
|
+
const consumed = await consumeHeadChunk(controller, reader, pending, injected);
|
|
2083
|
+
const nextState = updateInjectedState(consumed, injected, pending);
|
|
2084
|
+
if (nextState.done) {
|
|
2085
|
+
return { injected, pending };
|
|
2086
|
+
}
|
|
2087
|
+
return consumeNextHeadChunk(nextState.injected, nextState.pending);
|
|
2088
|
+
};
|
|
2089
|
+
return consumeNextHeadChunk(false, "");
|
|
2090
|
+
};
|
|
2091
|
+
return new ReadableStream({
|
|
2092
|
+
async start(controller) {
|
|
2093
|
+
const reader = stream.getReader();
|
|
2094
|
+
try {
|
|
2095
|
+
const { injected, pending } = await runHeadInjectionLoop(controller, reader);
|
|
2096
|
+
finishHeadInjectionStream(controller, pending, injected);
|
|
2097
|
+
} catch (error) {
|
|
2098
|
+
controller.error(error);
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
2101
|
+
});
|
|
2102
|
+
};
|
|
2103
|
+
var pipeStreamWithIslandMarkerDetection = (stream, markup) => {
|
|
2104
|
+
const encoder = new TextEncoder;
|
|
2105
|
+
const decoder = new TextDecoder;
|
|
2106
|
+
const lookbehind = Math.max(ISLAND_MARKER.length, BYTES_PER_KILOBYTE);
|
|
2107
|
+
const processPending = (controller, pending, injected) => {
|
|
2108
|
+
if (injected) {
|
|
2109
|
+
controller.enqueue(encoder.encode(pending));
|
|
2110
|
+
return { injected, pending: "" };
|
|
2111
|
+
}
|
|
2112
|
+
const markerIndex = pending.indexOf(ISLAND_MARKER);
|
|
2113
|
+
if (markerIndex >= 0) {
|
|
2114
|
+
const tagStart = pending.lastIndexOf("<", markerIndex);
|
|
2115
|
+
const injectAt = tagStart >= 0 ? tagStart : markerIndex;
|
|
2116
|
+
const next = `${pending.slice(0, injectAt)}${markup}${pending.slice(injectAt)}`;
|
|
2117
|
+
controller.enqueue(encoder.encode(next));
|
|
2118
|
+
return { injected: true, pending: "" };
|
|
2119
|
+
}
|
|
2120
|
+
return {
|
|
2121
|
+
injected,
|
|
2122
|
+
pending: flushSafePendingText(controller, encoder, pending, lookbehind)
|
|
2123
|
+
};
|
|
2124
|
+
};
|
|
2125
|
+
const finishIslandMarkerStream = (controller, pending) => {
|
|
2126
|
+
const finalPending = pending + decoder.decode();
|
|
2127
|
+
if (finalPending.length > 0) {
|
|
2128
|
+
controller.enqueue(encoder.encode(finalPending));
|
|
2129
|
+
}
|
|
2130
|
+
controller.close();
|
|
2131
|
+
};
|
|
2132
|
+
const consumeIslandChunk = async (controller, reader, pending, injected) => {
|
|
2133
|
+
const { done, value } = await readStreamChunk(reader);
|
|
2134
|
+
if (done || !value) {
|
|
2135
|
+
return { done, injected, pending };
|
|
2136
|
+
}
|
|
2137
|
+
const processed = processPending(controller, pending + streamChunkToString(value, decoder), injected);
|
|
2138
|
+
return {
|
|
2139
|
+
done,
|
|
2140
|
+
injected: processed.injected,
|
|
2141
|
+
pending: processed.pending
|
|
2142
|
+
};
|
|
2143
|
+
};
|
|
2144
|
+
const runIslandMarkerLoop = async (controller, reader) => {
|
|
2145
|
+
const consumeNextIslandChunk = async (injected, pending) => {
|
|
2146
|
+
const consumed = await consumeIslandChunk(controller, reader, pending, injected);
|
|
2147
|
+
const nextState = updateInjectedState(consumed, injected, pending);
|
|
2148
|
+
if (nextState.done) {
|
|
2149
|
+
return { injected, pending };
|
|
2150
|
+
}
|
|
2151
|
+
return consumeNextIslandChunk(nextState.injected, nextState.pending);
|
|
2152
|
+
};
|
|
2153
|
+
return consumeNextIslandChunk(false, "");
|
|
2154
|
+
};
|
|
2155
|
+
return new ReadableStream({
|
|
2156
|
+
async start(controller) {
|
|
2157
|
+
const reader = stream.getReader();
|
|
2158
|
+
try {
|
|
2159
|
+
const { pending } = await runIslandMarkerLoop(controller, reader);
|
|
2160
|
+
finishIslandMarkerStream(controller, pending);
|
|
2161
|
+
} catch (error) {
|
|
2162
|
+
controller.error(error);
|
|
2163
|
+
}
|
|
2164
|
+
}
|
|
2165
|
+
});
|
|
2166
|
+
};
|
|
2167
|
+
var htmlContainsIslands = (html) => html.includes(ISLAND_MARKER);
|
|
2168
|
+
var injectIslandPageContext = (html, options) => {
|
|
2169
|
+
const manifest = globalThis.__absoluteManifest;
|
|
2170
|
+
const hasIslands = options?.hasIslands ?? htmlContainsIslands(html);
|
|
2171
|
+
if (!manifest || !hasIslands) {
|
|
2172
|
+
return html;
|
|
2173
|
+
}
|
|
2174
|
+
if (html.includes(MANIFEST_MARKER) || html.includes(ISLAND_STATE_MARKER)) {
|
|
2175
|
+
return html;
|
|
2176
|
+
}
|
|
2177
|
+
return injectHeadMarkup(html, buildIslandsHeadMarkup(manifest));
|
|
2178
|
+
};
|
|
2179
|
+
var injectIslandPageContextStream = (stream, options) => {
|
|
2180
|
+
const manifest = globalThis.__absoluteManifest;
|
|
2181
|
+
if (!manifest)
|
|
2182
|
+
return stream;
|
|
2183
|
+
const markup = buildIslandsHeadMarkup(manifest);
|
|
2184
|
+
if (options?.hasIslands === true) {
|
|
2185
|
+
return pipeStreamWithHeadInjection(stream, markup);
|
|
2186
|
+
}
|
|
2187
|
+
if (options?.hasIslands === false) {
|
|
2188
|
+
return stream;
|
|
2189
|
+
}
|
|
2190
|
+
return pipeStreamWithIslandMarkerDetection(stream, markup);
|
|
2191
|
+
};
|
|
2192
|
+
var setCurrentIslandManifest = (manifest) => {
|
|
2193
|
+
globalThis.__absoluteManifest = manifest;
|
|
2194
|
+
};
|
|
2195
|
+
|
|
2196
|
+
// src/svelte/pageHandler.ts
|
|
2197
|
+
init_devRouteRegistrationCallsite();
|
|
2198
|
+
|
|
2199
|
+
// src/core/responseEnhancers.ts
|
|
2200
|
+
init_streamingSlots();
|
|
2201
|
+
var toResponse = async (responseLike) => responseLike;
|
|
2202
|
+
var cloneHeaders = (response) => {
|
|
2203
|
+
const headers = new Headers(response.headers);
|
|
2204
|
+
return headers;
|
|
2205
|
+
};
|
|
2206
|
+
var enhanceHtmlResponseWithStreamingSlots = (response, {
|
|
2207
|
+
nonce,
|
|
2208
|
+
onError,
|
|
2209
|
+
runtimePlacement,
|
|
2210
|
+
runtimePreludeScript,
|
|
2211
|
+
streamingSlots = [],
|
|
2212
|
+
policy
|
|
2213
|
+
} = {}) => {
|
|
2214
|
+
if (!response.body || streamingSlots.length === 0) {
|
|
2215
|
+
return response;
|
|
2216
|
+
}
|
|
2217
|
+
const body = appendStreamingSlotPatchesToStream(response.body, streamingSlots, {
|
|
2218
|
+
nonce,
|
|
2219
|
+
onError,
|
|
2220
|
+
policy,
|
|
1970
2221
|
runtimePlacement,
|
|
1971
2222
|
runtimePreludeScript
|
|
1972
2223
|
});
|
|
@@ -1975,14 +2226,17 @@ var toResponse = async (responseLike) => responseLike, cloneHeaders = (response)
|
|
|
1975
2226
|
status: response.status,
|
|
1976
2227
|
statusText: response.statusText
|
|
1977
2228
|
});
|
|
1978
|
-
}
|
|
2229
|
+
};
|
|
2230
|
+
var withStreamingSlots = async (responseLike, options = {}) => enhanceHtmlResponseWithStreamingSlots(await toResponse(responseLike), options);
|
|
2231
|
+
var mergeStreamingSlots = (registered, explicit) => {
|
|
1979
2232
|
const merged = new Map;
|
|
1980
2233
|
for (const slot of registered)
|
|
1981
2234
|
merged.set(slot.id, slot);
|
|
1982
2235
|
for (const slot of explicit)
|
|
1983
2236
|
merged.set(slot.id, slot);
|
|
1984
2237
|
return [...merged.values()];
|
|
1985
|
-
}
|
|
2238
|
+
};
|
|
2239
|
+
var withRegisteredStreamingSlots = async (renderResponse, options = {}) => {
|
|
1986
2240
|
const { result, slots } = await runWithStreamingSlotRegistry(renderResponse);
|
|
1987
2241
|
const explicit = options.streamingSlots ?? [];
|
|
1988
2242
|
return withStreamingSlots(result, {
|
|
@@ -1990,162 +2244,21 @@ var toResponse = async (responseLike) => responseLike, cloneHeaders = (response)
|
|
|
1990
2244
|
streamingSlots: mergeStreamingSlots(slots, explicit)
|
|
1991
2245
|
});
|
|
1992
2246
|
};
|
|
1993
|
-
var init_responseEnhancers = __esm(() => {
|
|
1994
|
-
init_streamingSlots();
|
|
1995
|
-
init_streamingSlotRegistry();
|
|
1996
|
-
});
|
|
1997
|
-
|
|
1998
|
-
// src/utils/getDurationString.ts
|
|
1999
|
-
var getDurationString = (duration) => {
|
|
2000
|
-
let durationString;
|
|
2001
|
-
if (duration < MILLISECONDS_IN_A_SECOND) {
|
|
2002
|
-
durationString = `${duration.toFixed(TIME_PRECISION)}ms`;
|
|
2003
|
-
} else if (duration < MILLISECONDS_IN_A_MINUTE) {
|
|
2004
|
-
durationString = `${(duration / MILLISECONDS_IN_A_SECOND).toFixed(TIME_PRECISION)}s`;
|
|
2005
|
-
} else {
|
|
2006
|
-
durationString = `${(duration / MILLISECONDS_IN_A_MINUTE).toFixed(TIME_PRECISION)}m`;
|
|
2007
|
-
}
|
|
2008
|
-
return durationString;
|
|
2009
|
-
};
|
|
2010
|
-
var init_getDurationString = __esm(() => {
|
|
2011
|
-
init_constants();
|
|
2012
|
-
});
|
|
2013
|
-
|
|
2014
|
-
// src/utils/startupBanner.ts
|
|
2015
|
-
var colors, MONTHS, formatTimestamp = () => {
|
|
2016
|
-
const now = new Date;
|
|
2017
|
-
const month = MONTHS[now.getMonth()];
|
|
2018
|
-
const day = now.getDate().toString().padStart(2, "0");
|
|
2019
|
-
let hours = now.getHours();
|
|
2020
|
-
const minutes = now.getMinutes().toString().padStart(2, "0");
|
|
2021
|
-
const seconds = now.getSeconds().toString().padStart(2, "0");
|
|
2022
|
-
const ampm = hours >= HOURS_IN_HALF_DAY ? "PM" : "AM";
|
|
2023
|
-
hours = hours % HOURS_IN_HALF_DAY || HOURS_IN_HALF_DAY;
|
|
2024
|
-
return `${month} ${day} ${hours}:${minutes}:${seconds} ${ampm}`;
|
|
2025
|
-
}, startupBanner = (options) => {
|
|
2026
|
-
const {
|
|
2027
|
-
version,
|
|
2028
|
-
readyDuration,
|
|
2029
|
-
buildDuration,
|
|
2030
|
-
port,
|
|
2031
|
-
host,
|
|
2032
|
-
networkUrl,
|
|
2033
|
-
protocol = "http"
|
|
2034
|
-
} = options;
|
|
2035
|
-
const name = `${colors.cyan}${colors.bold}ABSOLUTEJS${colors.reset}`;
|
|
2036
|
-
const ver = `${colors.dim}v${version}${colors.reset}`;
|
|
2037
|
-
const time = `${colors.dim}ready in${colors.reset} ${colors.bold}${getDurationString(readyDuration)}${colors.reset}`;
|
|
2038
|
-
const build = typeof buildDuration === "number" && Number.isFinite(buildDuration) ? ` ${colors.dim}(build ${getDurationString(buildDuration)})${colors.reset}` : "";
|
|
2039
|
-
console.log("");
|
|
2040
|
-
console.log(` ${name} ${ver} ${time}${build}`);
|
|
2041
|
-
console.log("");
|
|
2042
|
-
console.log(` ${colors.green}\u279C${colors.reset} ${colors.bold}Local:${colors.reset} ${protocol}://${host === "0.0.0.0" ? "localhost" : host}:${port}/`);
|
|
2043
|
-
if (networkUrl) {
|
|
2044
|
-
console.log(` ${colors.green}\u279C${colors.reset} ${colors.bold}Network:${colors.reset} ${networkUrl}`);
|
|
2045
|
-
}
|
|
2046
|
-
console.log("");
|
|
2047
|
-
};
|
|
2048
|
-
var init_startupBanner = __esm(() => {
|
|
2049
|
-
init_constants();
|
|
2050
|
-
init_getDurationString();
|
|
2051
|
-
colors = {
|
|
2052
|
-
bold: "\x1B[1m",
|
|
2053
|
-
cyan: "\x1B[36m",
|
|
2054
|
-
dim: "\x1B[2m",
|
|
2055
|
-
green: "\x1B[32m",
|
|
2056
|
-
reset: "\x1B[0m"
|
|
2057
|
-
};
|
|
2058
|
-
MONTHS = [
|
|
2059
|
-
"Jan",
|
|
2060
|
-
"Feb",
|
|
2061
|
-
"Mar",
|
|
2062
|
-
"Apr",
|
|
2063
|
-
"May",
|
|
2064
|
-
"Jun",
|
|
2065
|
-
"Jul",
|
|
2066
|
-
"Aug",
|
|
2067
|
-
"Sep",
|
|
2068
|
-
"Oct",
|
|
2069
|
-
"Nov",
|
|
2070
|
-
"Dec"
|
|
2071
|
-
];
|
|
2072
|
-
});
|
|
2073
|
-
|
|
2074
|
-
// src/utils/logger.ts
|
|
2075
|
-
var colors2, frameworkColors, formatPath = (filePath) => {
|
|
2076
|
-
const cwd = process.cwd();
|
|
2077
|
-
let relative3 = filePath.startsWith(cwd) ? filePath.slice(cwd.length + 1) : filePath;
|
|
2078
|
-
relative3 = relative3.replace(/\\/g, "/");
|
|
2079
|
-
if (!relative3.startsWith("/")) {
|
|
2080
|
-
relative3 = `/${relative3}`;
|
|
2081
|
-
}
|
|
2082
|
-
return relative3;
|
|
2083
|
-
}, getFrameworkColor = (framework) => frameworkColors[framework] || colors2.white, log = (action, options) => {
|
|
2084
|
-
const timestamp = `${colors2.dim}${formatTimestamp()}${colors2.reset}`;
|
|
2085
|
-
const tag = `${colors2.cyan}[hmr]${colors2.reset}`;
|
|
2086
|
-
let message = action;
|
|
2087
|
-
if (options?.path) {
|
|
2088
|
-
const pathColor = options.framework ? getFrameworkColor(options.framework) : colors2.white;
|
|
2089
|
-
message += ` ${pathColor}${formatPath(options.path)}${colors2.reset}`;
|
|
2090
|
-
}
|
|
2091
|
-
if (options?.duration !== undefined) {
|
|
2092
|
-
message += ` ${colors2.dim}(${options.duration}ms)${colors2.reset}`;
|
|
2093
|
-
}
|
|
2094
|
-
console.log(`${timestamp} ${tag} ${message}`);
|
|
2095
|
-
}, logCssUpdate = (path, framework, duration) => {
|
|
2096
|
-
log("css update", { duration, framework: framework ?? "css", path });
|
|
2097
|
-
}, logError = (message, error) => {
|
|
2098
|
-
const timestamp = `${colors2.dim}${formatTimestamp()}${colors2.reset}`;
|
|
2099
|
-
const tag = `${colors2.red}[hmr]${colors2.reset}`;
|
|
2100
|
-
const errorMsg = error instanceof Error ? error.message : error;
|
|
2101
|
-
const fullMessage = `${colors2.red}error${colors2.reset} ${message}${errorMsg ? `: ${errorMsg}` : ""}`;
|
|
2102
|
-
console.error(`${timestamp} ${tag} ${fullMessage}`);
|
|
2103
|
-
}, logHmrUpdate = (path, framework, duration) => {
|
|
2104
|
-
log("hmr update", { duration, framework, path });
|
|
2105
|
-
}, logScriptUpdate = (path, framework, duration) => {
|
|
2106
|
-
log("script update", { duration, framework, path });
|
|
2107
|
-
}, logServerReload = () => {
|
|
2108
|
-
log(`${colors2.cyan}server module reloaded${colors2.reset}`);
|
|
2109
|
-
}, logWarn = (message) => {
|
|
2110
|
-
const timestamp = `${colors2.dim}${formatTimestamp()}${colors2.reset}`;
|
|
2111
|
-
const tag = `${colors2.yellow}[hmr]${colors2.reset}`;
|
|
2112
|
-
console.log(`${timestamp} ${tag} ${colors2.yellow}warning ${message}${colors2.reset}`);
|
|
2113
|
-
};
|
|
2114
|
-
var init_logger = __esm(() => {
|
|
2115
|
-
init_startupBanner();
|
|
2116
|
-
colors2 = {
|
|
2117
|
-
blue: "\x1B[34m",
|
|
2118
|
-
bold: "\x1B[1m",
|
|
2119
|
-
cyan: "\x1B[36m",
|
|
2120
|
-
dim: "\x1B[2m",
|
|
2121
|
-
green: "\x1B[32m",
|
|
2122
|
-
magenta: "\x1B[35m",
|
|
2123
|
-
red: "\x1B[31m",
|
|
2124
|
-
reset: "\x1B[0m",
|
|
2125
|
-
white: "\x1B[37m",
|
|
2126
|
-
yellow: "\x1B[33m"
|
|
2127
|
-
};
|
|
2128
|
-
frameworkColors = {
|
|
2129
|
-
angular: colors2.magenta,
|
|
2130
|
-
assets: colors2.dim,
|
|
2131
|
-
css: colors2.cyan,
|
|
2132
|
-
html: colors2.white,
|
|
2133
|
-
htmx: colors2.white,
|
|
2134
|
-
react: colors2.blue,
|
|
2135
|
-
svelte: colors2.yellow,
|
|
2136
|
-
vue: colors2.green
|
|
2137
|
-
};
|
|
2138
|
-
});
|
|
2139
2247
|
|
|
2140
2248
|
// src/core/streamingSlotWarningScope.ts
|
|
2249
|
+
init_logger();
|
|
2141
2250
|
import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
|
|
2142
|
-
var STREAMING_SLOT_WARNING_STORAGE_KEY2
|
|
2251
|
+
var STREAMING_SLOT_WARNING_STORAGE_KEY2 = Symbol.for("absolutejs.streamingSlotWarningAsyncLocalStorage");
|
|
2252
|
+
var isObjectRecord4 = (value) => Boolean(value) && typeof value === "object";
|
|
2253
|
+
var isAsyncLocalStorage3 = (value) => isObjectRecord4(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function";
|
|
2254
|
+
var getWarningStorage = () => {
|
|
2143
2255
|
const value = Reflect.get(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY2);
|
|
2144
2256
|
if (value === null || typeof value === "undefined") {
|
|
2145
2257
|
return;
|
|
2146
2258
|
}
|
|
2147
2259
|
return isAsyncLocalStorage3(value) ? value : undefined;
|
|
2148
|
-
}
|
|
2260
|
+
};
|
|
2261
|
+
var ensureWarningStorage = () => {
|
|
2149
2262
|
const existing = getWarningStorage();
|
|
2150
2263
|
if (existing) {
|
|
2151
2264
|
return existing;
|
|
@@ -2153,13 +2266,16 @@ var STREAMING_SLOT_WARNING_STORAGE_KEY2, isObjectRecord4 = (value) => Boolean(va
|
|
|
2153
2266
|
const storage = new AsyncLocalStorage2;
|
|
2154
2267
|
Reflect.set(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY2, storage);
|
|
2155
2268
|
return storage;
|
|
2156
|
-
}
|
|
2269
|
+
};
|
|
2270
|
+
var normalizeCallsitePath2 = (value) => value.replace(`${process.cwd()}/`, "").replace(process.cwd(), "").replace(/^\.\/+/, "");
|
|
2271
|
+
var formatWarningCallsite = (callsite) => {
|
|
2157
2272
|
const match = callsite.match(/^(.*?)(:\d+:\d+)$/);
|
|
2158
2273
|
if (!match) {
|
|
2159
2274
|
return `\x1B[36m${callsite}\x1B[0m`;
|
|
2160
2275
|
}
|
|
2161
2276
|
return `\x1B[36m${match[1]}\x1B[33m${match[2]}\x1B[0m`;
|
|
2162
|
-
}
|
|
2277
|
+
};
|
|
2278
|
+
var extractCallsiteFromStack = (stack) => {
|
|
2163
2279
|
const frames = stack.split(`
|
|
2164
2280
|
`).slice(1).map((line) => line.trim());
|
|
2165
2281
|
for (const frame of frames) {
|
|
@@ -2172,29 +2288,30 @@ var STREAMING_SLOT_WARNING_STORAGE_KEY2, isObjectRecord4 = (value) => Boolean(va
|
|
|
2172
2288
|
}
|
|
2173
2289
|
}
|
|
2174
2290
|
return;
|
|
2175
|
-
}
|
|
2291
|
+
};
|
|
2292
|
+
var buildMissingCollectorWarning = (primitiveName, handlerCallsite) => `${primitiveName} rendered during SSR without streaming slot collection enabled. Add { collectStreamingSlots: true } to this page handler to enable out-of-order streaming for this route.${handlerCallsite ? ` Update ${formatWarningCallsite(handlerCallsite)}.` : ""}`;
|
|
2293
|
+
setStreamingSlotWarningController({
|
|
2294
|
+
maybeWarn: (primitiveName) => {
|
|
2295
|
+
const store = getWarningStorage()?.getStore();
|
|
2296
|
+
if (!store || store.hasWarned) {
|
|
2297
|
+
return;
|
|
2298
|
+
}
|
|
2299
|
+
store.hasWarned = true;
|
|
2300
|
+
logWarn(buildMissingCollectorWarning(primitiveName, store.handlerCallsite));
|
|
2301
|
+
}
|
|
2302
|
+
});
|
|
2303
|
+
var captureStreamingSlotWarningCallsite = () => {
|
|
2176
2304
|
if (false) {}
|
|
2177
2305
|
const { stack } = new Error;
|
|
2178
2306
|
if (!stack) {
|
|
2179
2307
|
return;
|
|
2180
2308
|
}
|
|
2181
2309
|
return extractCallsiteFromStack(stack);
|
|
2182
|
-
}
|
|
2183
|
-
var
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
setStreamingSlotWarningController({
|
|
2188
|
-
maybeWarn: (primitiveName) => {
|
|
2189
|
-
const store = getWarningStorage()?.getStore();
|
|
2190
|
-
if (!store || store.hasWarned) {
|
|
2191
|
-
return;
|
|
2192
|
-
}
|
|
2193
|
-
store.hasWarned = true;
|
|
2194
|
-
logWarn(buildMissingCollectorWarning(primitiveName, store.handlerCallsite));
|
|
2195
|
-
}
|
|
2196
|
-
});
|
|
2197
|
-
});
|
|
2310
|
+
};
|
|
2311
|
+
var runWithStreamingSlotWarningScope = (task, metadata) => ensureWarningStorage().run({ handlerCallsite: metadata?.handlerCallsite, hasWarned: false }, task);
|
|
2312
|
+
|
|
2313
|
+
// src/svelte/pageHandler.ts
|
|
2314
|
+
init_ssrCache();
|
|
2198
2315
|
|
|
2199
2316
|
// src/utils/ssrErrorPage.ts
|
|
2200
2317
|
var ssrErrorPage = (framework, error) => {
|
|
@@ -2248,39 +2365,40 @@ body{min-height:100vh;background:linear-gradient(135deg,rgba(15,23,42,0.98) 0%,r
|
|
|
2248
2365
|
</html>`;
|
|
2249
2366
|
};
|
|
2250
2367
|
|
|
2251
|
-
// src/utils/stringModifiers.ts
|
|
2252
|
-
var normalizeSlug = (str) => str.trim().replace(/\s+/g, "-").replace(/[^A-Za-z0-9\-_]+/g, "").replace(/[-_]{2,}/g, "-"), toKebab = (str) => normalizeSlug(str).replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), toPascal = (str) => {
|
|
2253
|
-
if (!str.includes("-") && !str.includes("_")) {
|
|
2254
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
2255
|
-
}
|
|
2256
|
-
return normalizeSlug(str).split(/[-_]/).filter(Boolean).map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1).toLowerCase()).join("");
|
|
2257
|
-
}, toScreamingSnake = (str) => str.replace(/([a-z0-9])([A-Z])/g, "$1_$2").toUpperCase();
|
|
2258
|
-
|
|
2259
2368
|
// src/utils/resolveConvention.ts
|
|
2260
2369
|
import { basename as basename2 } from "path";
|
|
2261
|
-
var CONVENTIONS_KEY = "__absoluteConventions"
|
|
2370
|
+
var CONVENTIONS_KEY = "__absoluteConventions";
|
|
2371
|
+
var isConventionsMap = (value) => Boolean(value) && typeof value === "object";
|
|
2372
|
+
var getMap = () => {
|
|
2262
2373
|
const value = Reflect.get(globalThis, CONVENTIONS_KEY);
|
|
2263
2374
|
if (isConventionsMap(value))
|
|
2264
2375
|
return value;
|
|
2265
2376
|
const empty = {};
|
|
2266
2377
|
return empty;
|
|
2267
|
-
}
|
|
2378
|
+
};
|
|
2379
|
+
var derivePageName = (pagePath) => {
|
|
2268
2380
|
const base = basename2(pagePath);
|
|
2269
2381
|
const dotIndex = base.indexOf(".");
|
|
2270
2382
|
const name = dotIndex > 0 ? base.slice(0, dotIndex) : base;
|
|
2271
2383
|
return toPascal(name);
|
|
2272
|
-
}
|
|
2384
|
+
};
|
|
2385
|
+
var resolveErrorConventionPath = (framework, pageName) => {
|
|
2273
2386
|
const conventions = getMap()[framework];
|
|
2274
2387
|
if (!conventions)
|
|
2275
2388
|
return;
|
|
2276
2389
|
return conventions.pages?.[pageName]?.error ?? conventions.defaults?.error;
|
|
2277
|
-
}
|
|
2390
|
+
};
|
|
2391
|
+
var resolveNotFoundConventionPath = (framework) => getMap()[framework]?.defaults?.notFound;
|
|
2392
|
+
var setConventions = (map) => {
|
|
2278
2393
|
Reflect.set(globalThis, CONVENTIONS_KEY, map);
|
|
2279
|
-
}
|
|
2394
|
+
};
|
|
2395
|
+
var isDev = () => true;
|
|
2396
|
+
var buildErrorProps = (error) => {
|
|
2280
2397
|
const message = error instanceof Error ? error.message : String(error);
|
|
2281
2398
|
const stack = isDev() && error instanceof Error ? error.stack : undefined;
|
|
2282
2399
|
return { error: { message, stack } };
|
|
2283
|
-
}
|
|
2400
|
+
};
|
|
2401
|
+
var renderReactError = async (conventionPath, errorProps) => {
|
|
2284
2402
|
const { createElement } = await import("react");
|
|
2285
2403
|
const { renderToReadableStream } = await import("react-dom/server");
|
|
2286
2404
|
const mod = await import(conventionPath);
|
|
@@ -2292,7 +2410,8 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
|
|
|
2292
2410
|
headers: { "Content-Type": "text/html" },
|
|
2293
2411
|
status: 500
|
|
2294
2412
|
});
|
|
2295
|
-
}
|
|
2413
|
+
};
|
|
2414
|
+
var renderSvelteError = async (conventionPath, errorProps) => {
|
|
2296
2415
|
const { render } = await import("svelte/server");
|
|
2297
2416
|
const mod = await import(conventionPath);
|
|
2298
2417
|
const ErrorComponent = mod.default;
|
|
@@ -2304,14 +2423,16 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
|
|
|
2304
2423
|
headers: { "Content-Type": "text/html" },
|
|
2305
2424
|
status: 500
|
|
2306
2425
|
});
|
|
2307
|
-
}
|
|
2426
|
+
};
|
|
2427
|
+
var unescapeVueStyles = (ssrBody) => {
|
|
2308
2428
|
let styles = "";
|
|
2309
2429
|
const body = ssrBody.replace(/<style>([\s\S]*?)<\/style>/g, (_, css) => {
|
|
2310
2430
|
styles += `<style>${css.replace(/"/g, '"').replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")}</style>`;
|
|
2311
2431
|
return "";
|
|
2312
2432
|
});
|
|
2313
2433
|
return { body, styles };
|
|
2314
|
-
}
|
|
2434
|
+
};
|
|
2435
|
+
var renderVueError = async (conventionPath, errorProps) => {
|
|
2315
2436
|
const { createSSRApp, h } = await import("vue");
|
|
2316
2437
|
const { renderToString } = await import("vue/server-renderer");
|
|
2317
2438
|
const mod = await import(conventionPath);
|
|
@@ -2326,7 +2447,8 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
|
|
|
2326
2447
|
headers: { "Content-Type": "text/html" },
|
|
2327
2448
|
status: 500
|
|
2328
2449
|
});
|
|
2329
|
-
}
|
|
2450
|
+
};
|
|
2451
|
+
var renderAngularError = async (conventionPath, errorProps) => {
|
|
2330
2452
|
const mod = await import(conventionPath);
|
|
2331
2453
|
const renderError = mod.default ?? mod.renderError;
|
|
2332
2454
|
if (typeof renderError !== "function")
|
|
@@ -2336,14 +2458,22 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
|
|
|
2336
2458
|
headers: { "Content-Type": "text/html" },
|
|
2337
2459
|
status: 500
|
|
2338
2460
|
});
|
|
2339
|
-
}
|
|
2461
|
+
};
|
|
2462
|
+
var logConventionRenderError = (framework, label, renderError) => {
|
|
2340
2463
|
const message = renderError instanceof Error ? renderError.message : "";
|
|
2341
2464
|
if (message.includes("Cannot find module") || message.includes("Cannot find package") || message.includes("not found in module")) {
|
|
2342
2465
|
console.error(`[SSR] Convention ${label} page for ${framework} failed: missing framework package. Ensure the ${framework} runtime is installed (e.g. bun add ${framework === "react" ? "react react-dom" : framework}).`);
|
|
2343
2466
|
return;
|
|
2344
2467
|
}
|
|
2345
2468
|
console.error(`[SSR] Failed to render ${framework} convention ${label} page:`, renderError);
|
|
2346
|
-
}
|
|
2469
|
+
};
|
|
2470
|
+
var ERROR_RENDERERS = {
|
|
2471
|
+
angular: renderAngularError,
|
|
2472
|
+
react: renderReactError,
|
|
2473
|
+
svelte: renderSvelteError,
|
|
2474
|
+
vue: renderVueError
|
|
2475
|
+
};
|
|
2476
|
+
var renderConventionError = async (framework, pageName, error) => {
|
|
2347
2477
|
const conventionPath = resolveErrorConventionPath(framework, pageName);
|
|
2348
2478
|
if (!conventionPath)
|
|
2349
2479
|
return null;
|
|
@@ -2357,7 +2487,8 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
|
|
|
2357
2487
|
logConventionRenderError(framework, "error", renderError);
|
|
2358
2488
|
}
|
|
2359
2489
|
return null;
|
|
2360
|
-
}
|
|
2490
|
+
};
|
|
2491
|
+
var renderReactNotFound = async (conventionPath) => {
|
|
2361
2492
|
const { createElement } = await import("react");
|
|
2362
2493
|
const { renderToReadableStream } = await import("react-dom/server");
|
|
2363
2494
|
const mod = await import(conventionPath);
|
|
@@ -2369,7 +2500,8 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
|
|
|
2369
2500
|
headers: { "Content-Type": "text/html" },
|
|
2370
2501
|
status: 404
|
|
2371
2502
|
});
|
|
2372
|
-
}
|
|
2503
|
+
};
|
|
2504
|
+
var renderSvelteNotFound = async (conventionPath) => {
|
|
2373
2505
|
const { render } = await import("svelte/server");
|
|
2374
2506
|
const mod = await import(conventionPath);
|
|
2375
2507
|
const NotFoundComponent = mod.default;
|
|
@@ -2379,7 +2511,8 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
|
|
|
2379
2511
|
headers: { "Content-Type": "text/html" },
|
|
2380
2512
|
status: 404
|
|
2381
2513
|
});
|
|
2382
|
-
}
|
|
2514
|
+
};
|
|
2515
|
+
var renderVueNotFound = async (conventionPath) => {
|
|
2383
2516
|
const { createSSRApp, h } = await import("vue");
|
|
2384
2517
|
const { renderToString } = await import("vue/server-renderer");
|
|
2385
2518
|
const mod = await import(conventionPath);
|
|
@@ -2394,7 +2527,8 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
|
|
|
2394
2527
|
headers: { "Content-Type": "text/html" },
|
|
2395
2528
|
status: 404
|
|
2396
2529
|
});
|
|
2397
|
-
}
|
|
2530
|
+
};
|
|
2531
|
+
var renderAngularNotFound = async (conventionPath) => {
|
|
2398
2532
|
const mod = await import(conventionPath);
|
|
2399
2533
|
const renderNotFound = mod.default ?? mod.renderNotFound;
|
|
2400
2534
|
if (typeof renderNotFound !== "function")
|
|
@@ -2404,7 +2538,14 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
|
|
|
2404
2538
|
headers: { "Content-Type": "text/html" },
|
|
2405
2539
|
status: 404
|
|
2406
2540
|
});
|
|
2407
|
-
}
|
|
2541
|
+
};
|
|
2542
|
+
var NOT_FOUND_RENDERERS = {
|
|
2543
|
+
angular: renderAngularNotFound,
|
|
2544
|
+
react: renderReactNotFound,
|
|
2545
|
+
svelte: renderSvelteNotFound,
|
|
2546
|
+
vue: renderVueNotFound
|
|
2547
|
+
};
|
|
2548
|
+
var renderConventionNotFound = async (framework) => {
|
|
2408
2549
|
const conventionPath = resolveNotFoundConventionPath(framework);
|
|
2409
2550
|
if (!conventionPath)
|
|
2410
2551
|
return null;
|
|
@@ -2417,7 +2558,14 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
|
|
|
2417
2558
|
logConventionRenderError(framework, "not-found", renderError);
|
|
2418
2559
|
}
|
|
2419
2560
|
return null;
|
|
2420
|
-
}
|
|
2561
|
+
};
|
|
2562
|
+
var NOT_FOUND_PRIORITY = [
|
|
2563
|
+
"react",
|
|
2564
|
+
"svelte",
|
|
2565
|
+
"vue",
|
|
2566
|
+
"angular"
|
|
2567
|
+
];
|
|
2568
|
+
var renderFirstNotFound = async () => {
|
|
2421
2569
|
for (const framework of NOT_FOUND_PRIORITY) {
|
|
2422
2570
|
if (!getMap()[framework]?.defaults?.notFound)
|
|
2423
2571
|
continue;
|
|
@@ -2427,96 +2575,26 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
|
|
|
2427
2575
|
}
|
|
2428
2576
|
return null;
|
|
2429
2577
|
};
|
|
2430
|
-
var init_resolveConvention = __esm(() => {
|
|
2431
|
-
ERROR_RENDERERS = {
|
|
2432
|
-
angular: renderAngularError,
|
|
2433
|
-
react: renderReactError,
|
|
2434
|
-
svelte: renderSvelteError,
|
|
2435
|
-
vue: renderVueError
|
|
2436
|
-
};
|
|
2437
|
-
NOT_FOUND_RENDERERS = {
|
|
2438
|
-
angular: renderAngularNotFound,
|
|
2439
|
-
react: renderReactNotFound,
|
|
2440
|
-
svelte: renderSvelteNotFound,
|
|
2441
|
-
vue: renderVueNotFound
|
|
2442
|
-
};
|
|
2443
|
-
NOT_FOUND_PRIORITY = [
|
|
2444
|
-
"react",
|
|
2445
|
-
"svelte",
|
|
2446
|
-
"vue",
|
|
2447
|
-
"angular"
|
|
2448
|
-
];
|
|
2449
|
-
});
|
|
2450
|
-
|
|
2451
|
-
// src/svelte/renderToReadableStream.ts
|
|
2452
|
-
var exports_renderToReadableStream = {};
|
|
2453
|
-
__export(exports_renderToReadableStream, {
|
|
2454
|
-
renderToReadableStream: () => renderToReadableStream,
|
|
2455
|
-
SVELTE_PAGE_ROOT_ID: () => SVELTE_PAGE_ROOT_ID
|
|
2456
|
-
});
|
|
2457
|
-
var SVELTE_PAGE_ROOT_ID = "__absolute_svelte_root__", renderToReadableStream = async (component, props, {
|
|
2458
|
-
bootstrapScriptContent,
|
|
2459
|
-
bootstrapScripts = [],
|
|
2460
|
-
bootstrapModules = [],
|
|
2461
|
-
nonce,
|
|
2462
|
-
onError = console.error,
|
|
2463
|
-
progressiveChunkSize = DEFAULT_CHUNK_SIZE,
|
|
2464
|
-
signal,
|
|
2465
|
-
headContent,
|
|
2466
|
-
bodyContent
|
|
2467
|
-
} = {}) => {
|
|
2468
|
-
try {
|
|
2469
|
-
const { render } = await import("svelte/server");
|
|
2470
|
-
const rendered = typeof props === "undefined" ? await render(component) : await render(component, { props });
|
|
2471
|
-
const { head, body } = rendered;
|
|
2472
|
-
const nonceAttr = nonce ? ` nonce="${nonce}"` : "";
|
|
2473
|
-
const scripts = (bootstrapScriptContent ? `<script${nonceAttr}>${escapeScriptContent(bootstrapScriptContent)}</script>` : "") + bootstrapScripts.map((src) => `<script${nonceAttr} src="${src}"></script>`).join("") + bootstrapModules.map((src) => `<script${nonceAttr} type="module" src="${src}"></script>`).join("");
|
|
2474
|
-
const encoder = new TextEncoder;
|
|
2475
|
-
const full = encoder.encode(`<!DOCTYPE html><html lang="en"><head>${head}${headContent ?? ""}</head><body><div id="${SVELTE_PAGE_ROOT_ID}">${body}</div>${scripts}${bodyContent ?? ""}</body></html>`);
|
|
2476
|
-
let offset = 0;
|
|
2477
|
-
return new ReadableStream({
|
|
2478
|
-
type: "bytes",
|
|
2479
|
-
cancel(reason) {
|
|
2480
|
-
onError?.(reason);
|
|
2481
|
-
},
|
|
2482
|
-
pull(controller) {
|
|
2483
|
-
if (signal?.aborted) {
|
|
2484
|
-
controller.close();
|
|
2485
|
-
return;
|
|
2486
|
-
}
|
|
2487
|
-
if (offset >= full.length) {
|
|
2488
|
-
controller.close();
|
|
2489
|
-
return;
|
|
2490
|
-
}
|
|
2491
|
-
const end = Math.min(offset + progressiveChunkSize, full.length);
|
|
2492
|
-
controller.enqueue(full.subarray(offset, end));
|
|
2493
|
-
offset = end;
|
|
2494
|
-
}
|
|
2495
|
-
});
|
|
2496
|
-
} catch (error) {
|
|
2497
|
-
onError?.(error);
|
|
2498
|
-
throw error;
|
|
2499
|
-
}
|
|
2500
|
-
};
|
|
2501
|
-
var init_renderToReadableStream = __esm(() => {
|
|
2502
|
-
init_constants();
|
|
2503
|
-
init_escapeScriptContent();
|
|
2504
|
-
});
|
|
2505
2578
|
|
|
2506
2579
|
// src/svelte/pageHandler.ts
|
|
2507
|
-
var
|
|
2580
|
+
var isRecord2 = (value) => typeof value === "object" && value !== null;
|
|
2581
|
+
var isGenericSvelteComponent = (value) => typeof value === "function" || isRecord2(value);
|
|
2582
|
+
var readHasIslands = (value) => {
|
|
2508
2583
|
if (!isRecord2(value))
|
|
2509
2584
|
return false;
|
|
2510
2585
|
const hasIslands = value["__ABSOLUTE_PAGE_HAS_ISLANDS__"];
|
|
2511
2586
|
return typeof hasIslands === "boolean" ? hasIslands : false;
|
|
2512
|
-
}
|
|
2587
|
+
};
|
|
2588
|
+
var readDefaultExport = (value) => isRecord2(value) ? value.default : undefined;
|
|
2589
|
+
var buildDirtyResponse = (indexPath, props) => {
|
|
2513
2590
|
const propsScript = `window.__ABS_SLOT_HYDRATION_PENDING__=true;window.__INITIAL_PROPS__=${JSON.stringify(props)};${indexPath ? `import(${JSON.stringify(indexPath)});` : ""}`;
|
|
2514
2591
|
const dirtyFlag = "window.__SSR_DIRTY__=true;";
|
|
2515
2592
|
const html = `<!DOCTYPE html><html><head></head><body><script>${propsScript}${dirtyFlag}</script></body></html>`;
|
|
2516
2593
|
return new Response(html, {
|
|
2517
2594
|
headers: { "Content-Type": "text/html" }
|
|
2518
2595
|
});
|
|
2519
|
-
}
|
|
2596
|
+
};
|
|
2597
|
+
var handleSveltePageRequest = async (PageComponentOrInput, pagePath, indexPath, props, options) => {
|
|
2520
2598
|
const {
|
|
2521
2599
|
PageComponent,
|
|
2522
2600
|
indexPath: resolvedIndexPath,
|
|
@@ -2536,7 +2614,7 @@ var ssrDirty = false, isRecord2 = (value) => typeof value === "object" && value
|
|
|
2536
2614
|
pagePath: pagePath ?? "",
|
|
2537
2615
|
props
|
|
2538
2616
|
};
|
|
2539
|
-
if (
|
|
2617
|
+
if (isSsrCacheDirty("svelte")) {
|
|
2540
2618
|
return buildDirtyResponse(resolvedIndexPath, resolvedProps);
|
|
2541
2619
|
}
|
|
2542
2620
|
try {
|
|
@@ -2607,23 +2685,10 @@ var ssrDirty = false, isRecord2 = (value) => typeof value === "object" && value
|
|
|
2607
2685
|
status: 500
|
|
2608
2686
|
});
|
|
2609
2687
|
}
|
|
2610
|
-
}, invalidateSvelteSsrCache = () => {
|
|
2611
|
-
ssrDirty = true;
|
|
2612
2688
|
};
|
|
2613
|
-
var init_pageHandler = __esm(() => {
|
|
2614
|
-
init_svelteServerModule();
|
|
2615
|
-
init_islandPageContext();
|
|
2616
|
-
init_devRouteRegistrationCallsite();
|
|
2617
|
-
init_responseEnhancers();
|
|
2618
|
-
init_streamingSlotWarningScope();
|
|
2619
|
-
init_resolveConvention();
|
|
2620
|
-
});
|
|
2621
|
-
|
|
2622
|
-
// src/svelte/server.ts
|
|
2623
|
-
init_pageHandler();
|
|
2624
2689
|
export {
|
|
2625
2690
|
handleSveltePageRequest
|
|
2626
2691
|
};
|
|
2627
2692
|
|
|
2628
|
-
//# debugId=
|
|
2693
|
+
//# debugId=30012EB2373C394964756E2164756E21
|
|
2629
2694
|
//# sourceMappingURL=server.js.map
|