@absolutejs/absolute 0.19.0-beta.694 → 0.19.0-beta.696
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 +3090 -2890
- package/dist/angular/index.js.map +15 -14
- package/dist/angular/server.js +3083 -2883
- package/dist/angular/server.js.map +15 -15
- package/dist/build.js +42942 -6408
- package/dist/build.js.map +9 -20
- package/dist/cli/index.js +2 -1
- 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 +41443 -4405
- package/dist/index.js.map +28 -40
- package/dist/islands/index.js +135 -11
- package/dist/islands/index.js.map +3 -3
- package/dist/react/components/index.js +24 -16
- package/dist/react/components/index.js.map +2 -2
- package/dist/react/index.js +1056 -873
- package/dist/react/index.js.map +13 -13
- package/dist/react/server.js +903 -843
- package/dist/react/server.js.map +11 -11
- package/dist/src/build/compileTailwind.d.ts +3 -0
- package/dist/src/build/stylePreprocessor.d.ts +2 -1
- package/dist/src/core/build.d.ts +1 -1
- package/dist/src/core/pageHandlers.d.ts +0 -1
- package/dist/src/core/ssrCache.d.ts +3 -0
- package/dist/svelte/index.js +1104 -916
- package/dist/svelte/index.js.map +15 -14
- package/dist/svelte/server.js +891 -702
- package/dist/svelte/server.js.map +13 -13
- package/dist/types/build.d.ts +18 -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 +1144 -956
- package/dist/vue/index.js.map +13 -13
- package/dist/vue/server.js +908 -841
- package/dist/vue/server.js.map +11 -11
- package/package.json +20 -8
package/dist/react/index.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/constants.ts
|
|
175
82
|
var ANGULAR_INIT_TIMEOUT_MS = 500, ANSI_ESCAPE_LENGTH = 3, ASCII_SPACE = 32, BASE_36_RADIX = 36, BUN_BUILD_WARNING_SUPPRESSION = "wildcard sideEffects are not supported yet", BODY_SLICE_LENGTH = 2000, BYTES_PER_KILOBYTE = 1024, CLI_ARGS_OFFSET = 3, CSS_ERROR_RESOLVE_DELAY_MS = 50, CSS_MAX_CHECK_ATTEMPTS = 10, CSS_MAX_PARSE_TIMEOUT_MS = 500, CSS_SHEET_READY_TIMEOUT_MS = 100, DEFAULT_CHUNK_SIZE = 16384, DEFAULT_DEBOUNCE_MS = 15, DEFAULT_PORT = 3000, DEV_SERVER_RESTART_DEBOUNCE_MS = 100, DOM_UPDATE_DELAY_MS = 50, FILE_PROTOCOL_PREFIX_LENGTH = 7, FOCUS_ID_PREFIX_LENGTH = 3, FOCUS_IDX_PREFIX_LENGTH = 4, FOCUS_NAME_PREFIX_LENGTH = 5, HMR_UPDATE_TIMEOUT_MS = 2000, HOOK_SIGNATURE_LENGTH = 12, EXCLUDE_LAST_OFFSET = -1, HTTP_STATUS_OK = 200, HTTP_STATUS_BAD_REQUEST = 400, HTTP_STATUS_NOT_FOUND = 404, HOURS_IN_DAY = 24, HOURS_IN_HALF_DAY = 12, MAX_ERROR_LENGTH = 200, MAX_RECONNECT_ATTEMPTS = 60, MILLISECONDS_IN_A_SECOND = 1000, MINUTES_IN_AN_HOUR = 60, SECONDS_IN_A_MINUTE = 60, MILLISECONDS_IN_A_MINUTE, MILLISECONDS_IN_A_DAY, OVERLAY_FADE_DURATION_MS = 150, PING_INTERVAL_MS = 30000, RAF_BATCH_COUNT = 3, RANDOM_ID_END_INDEX = 11, REBUILD_BATCH_DELAY_MS = 10, REBUILD_RELOAD_DELAY_MS = 200, RECONNECT_INITIAL_DELAY_MS = 500, RECONNECT_POLL_INTERVAL_MS = 300, REACT_STREAM_SLOT_FAST_DELAY_MS = 5, REACT_STREAM_SLOT_SLOW_DELAY_MS = 20, SIGINT_EXIT_CODE = 130, SIGTERM_EXIT_CODE = 143, SVELTE_CSS_LOAD_TIMEOUT_MS = 500, TIME_PRECISION = 2, TWO_THIRDS, UNFOUND_INDEX = -1, WEBSOCKET_NORMAL_CLOSURE = 1000;
|
|
176
83
|
var init_constants = __esm(() => {
|
|
@@ -179,332 +86,134 @@ var init_constants = __esm(() => {
|
|
|
179
86
|
TWO_THIRDS = 2 / 3;
|
|
180
87
|
});
|
|
181
88
|
|
|
182
|
-
// src/core/
|
|
183
|
-
var
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
89
|
+
// src/core/devRouteRegistrationCallsite.ts
|
|
90
|
+
var exports_devRouteRegistrationCallsite = {};
|
|
91
|
+
__export(exports_devRouteRegistrationCallsite, {
|
|
92
|
+
patchElysiaRouteRegistrationCallsites: () => patchElysiaRouteRegistrationCallsites,
|
|
93
|
+
getCurrentRouteRegistrationCallsite: () => getCurrentRouteRegistrationCallsite
|
|
94
|
+
});
|
|
95
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
96
|
+
import { Elysia } from "elysia";
|
|
97
|
+
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 = () => {
|
|
98
|
+
const value = Reflect.get(globalThis, ROUTE_CALLSITE_STORAGE_KEY);
|
|
99
|
+
if (value === null || typeof value === "undefined") {
|
|
100
|
+
return;
|
|
193
101
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
102
|
+
return isAsyncLocalStorage2(value) ? value : undefined;
|
|
103
|
+
}, ensureRouteCallsiteStorage = () => {
|
|
104
|
+
const existing = getRouteCallsiteStorage();
|
|
105
|
+
if (existing) {
|
|
106
|
+
return existing;
|
|
107
|
+
}
|
|
108
|
+
const storage = new AsyncLocalStorage;
|
|
109
|
+
Reflect.set(globalThis, ROUTE_CALLSITE_STORAGE_KEY, storage);
|
|
110
|
+
return storage;
|
|
111
|
+
}, normalizeCallsitePath = (value) => value.replace(`${process.cwd()}/`, "").replace(process.cwd(), "").replace(/^\.\/+/, ""), extractRouteRegistrationCallsite = (stack) => {
|
|
112
|
+
const frames = stack.split(`
|
|
113
|
+
`).slice(1).map((line) => line.trim());
|
|
114
|
+
for (const frame of frames) {
|
|
115
|
+
if (frame.includes("/node_modules/") || frame.includes("/dist/") || frame.includes("/src/core/devRouteRegistrationCallsite.")) {
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
const locationMatch = frame.match(/\((\/[^)]+:\d+:\d+)\)$/) ?? frame.match(/at (\/[^ ]+:\d+:\d+)$/);
|
|
119
|
+
if (locationMatch?.[1]) {
|
|
120
|
+
return normalizeCallsitePath(locationMatch[1]);
|
|
199
121
|
}
|
|
200
122
|
}
|
|
201
|
-
return
|
|
202
|
-
},
|
|
203
|
-
|
|
204
|
-
|
|
123
|
+
return;
|
|
124
|
+
}, captureRouteRegistrationCallsite = () => {
|
|
125
|
+
const { stack } = new Error;
|
|
126
|
+
if (!stack) {
|
|
127
|
+
return;
|
|
205
128
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
if (consumed.done) {
|
|
211
|
-
return { done: true, injected, pending };
|
|
129
|
+
return extractRouteRegistrationCallsite(stack);
|
|
130
|
+
}, wrapRouteHandlerWithCallsite = (handler, callsite) => {
|
|
131
|
+
if (typeof handler !== "function" || !callsite) {
|
|
132
|
+
return handler;
|
|
212
133
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
pending: consumed.pending
|
|
134
|
+
const storage = ensureRouteCallsiteStorage();
|
|
135
|
+
return function wrappedRouteHandler(...args) {
|
|
136
|
+
return storage.run({ callsite }, () => Reflect.apply(handler, this, args));
|
|
217
137
|
};
|
|
218
|
-
},
|
|
219
|
-
|
|
220
|
-
if (
|
|
221
|
-
return
|
|
138
|
+
}, getCurrentRouteRegistrationCallsite = () => getRouteCallsiteStorage()?.getStore()?.callsite, patchElysiaRouteRegistrationCallsites = () => {
|
|
139
|
+
if (false) {}
|
|
140
|
+
if (Reflect.get(globalThis, ROUTE_CALLSITE_PATCHED_KEY) === true) {
|
|
141
|
+
return;
|
|
222
142
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
const processPending = (controller, pending, injected) => {
|
|
229
|
-
if (injected) {
|
|
230
|
-
controller.enqueue(encoder.encode(pending));
|
|
231
|
-
return { injected, pending: "" };
|
|
232
|
-
}
|
|
233
|
-
const headIndex = pending.indexOf(CLOSING_HEAD_TAG);
|
|
234
|
-
if (headIndex >= 0) {
|
|
235
|
-
const next = `${pending.slice(0, headIndex)}${markup}${pending.slice(headIndex)}`;
|
|
236
|
-
controller.enqueue(encoder.encode(next));
|
|
237
|
-
return { injected: true, pending: "" };
|
|
143
|
+
const prototype = Elysia.prototype;
|
|
144
|
+
for (const methodName of ROUTE_METHOD_NAMES) {
|
|
145
|
+
const originalMethod = prototype[methodName];
|
|
146
|
+
if (typeof originalMethod !== "function") {
|
|
147
|
+
continue;
|
|
238
148
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
149
|
+
prototype[methodName] = function patchedRouteMethod(path, handler, ...rest) {
|
|
150
|
+
const callsite = captureRouteRegistrationCallsite();
|
|
151
|
+
return Reflect.apply(originalMethod, this, [
|
|
152
|
+
path,
|
|
153
|
+
wrapRouteHandlerWithCallsite(handler, callsite),
|
|
154
|
+
...rest
|
|
155
|
+
]);
|
|
242
156
|
};
|
|
157
|
+
}
|
|
158
|
+
Reflect.set(globalThis, ROUTE_CALLSITE_PATCHED_KEY, true);
|
|
159
|
+
};
|
|
160
|
+
var init_devRouteRegistrationCallsite = __esm(() => {
|
|
161
|
+
ROUTE_CALLSITE_STORAGE_KEY = Symbol.for("absolutejs.devRouteRegistrationCallsiteStorage");
|
|
162
|
+
ROUTE_CALLSITE_PATCHED_KEY = Symbol.for("absolutejs.devRouteRegistrationCallsitePatched");
|
|
163
|
+
ROUTE_METHOD_NAMES = [
|
|
164
|
+
"all",
|
|
165
|
+
"delete",
|
|
166
|
+
"get",
|
|
167
|
+
"head",
|
|
168
|
+
"options",
|
|
169
|
+
"patch",
|
|
170
|
+
"post",
|
|
171
|
+
"put"
|
|
172
|
+
];
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
// src/client/streamSwap.ts
|
|
176
|
+
var streamSwapRuntime = () => {
|
|
177
|
+
const SLOT_PATCH_EVENT = "absolutejs:slot-patch";
|
|
178
|
+
if (window.__ABS_SLOT_RUNTIME__ === true)
|
|
179
|
+
return;
|
|
180
|
+
window.__ABS_SLOT_RUNTIME__ = true;
|
|
181
|
+
window.__ABS_SLOT_CONSUMERS__ = window.__ABS_SLOT_CONSUMERS__ ?? {};
|
|
182
|
+
window.__ABS_SLOT_PENDING__ = window.__ABS_SLOT_PENDING__ ?? {};
|
|
183
|
+
const consumers = window.__ABS_SLOT_CONSUMERS__;
|
|
184
|
+
const pending = window.__ABS_SLOT_PENDING__;
|
|
185
|
+
const isObjectRecord4 = (value) => Boolean(value) && typeof value === "object";
|
|
186
|
+
const isPatchedPendingEntry = (value) => {
|
|
187
|
+
if (!isObjectRecord4(value))
|
|
188
|
+
return false;
|
|
189
|
+
return value.domPatched === true && "payload" in value;
|
|
243
190
|
};
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
191
|
+
const unwrapPendingPayload = (value) => isPatchedPendingEntry(value) ? value.payload : value;
|
|
192
|
+
const canApplyImmediately = () => window.__ABS_SLOT_HYDRATION_PENDING__ !== true;
|
|
193
|
+
const isAngularDeferPayload = (payload) => {
|
|
194
|
+
if (!isObjectRecord4(payload))
|
|
195
|
+
return false;
|
|
196
|
+
return payload.kind === "angular-defer";
|
|
197
|
+
};
|
|
198
|
+
const isVueSuspensePayload = (payload) => {
|
|
199
|
+
if (!isObjectRecord4(payload))
|
|
200
|
+
return false;
|
|
201
|
+
return payload.kind === "vue-suspense";
|
|
202
|
+
};
|
|
203
|
+
const resolveHtml = (payload) => {
|
|
204
|
+
if (!isObjectRecord4(payload)) {
|
|
205
|
+
return typeof payload === "string" ? payload : "";
|
|
248
206
|
}
|
|
249
|
-
if (
|
|
250
|
-
|
|
207
|
+
if (typeof payload.html === "string") {
|
|
208
|
+
return payload.html;
|
|
251
209
|
}
|
|
252
|
-
|
|
210
|
+
return "";
|
|
253
211
|
};
|
|
254
|
-
const
|
|
255
|
-
const
|
|
256
|
-
if (
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
const processed = processPending(controller, pending + streamChunkToString(value, decoder), injected);
|
|
260
|
-
return {
|
|
261
|
-
done,
|
|
262
|
-
injected: processed.injected,
|
|
263
|
-
pending: processed.pending
|
|
264
|
-
};
|
|
265
|
-
};
|
|
266
|
-
const runHeadInjectionLoop = async (controller, reader) => {
|
|
267
|
-
const consumeNextHeadChunk = async (injected, pending) => {
|
|
268
|
-
const consumed = await consumeHeadChunk(controller, reader, pending, injected);
|
|
269
|
-
const nextState = updateInjectedState(consumed, injected, pending);
|
|
270
|
-
if (nextState.done) {
|
|
271
|
-
return { injected, pending };
|
|
272
|
-
}
|
|
273
|
-
return consumeNextHeadChunk(nextState.injected, nextState.pending);
|
|
274
|
-
};
|
|
275
|
-
return consumeNextHeadChunk(false, "");
|
|
276
|
-
};
|
|
277
|
-
return new ReadableStream({
|
|
278
|
-
async start(controller) {
|
|
279
|
-
const reader = stream.getReader();
|
|
280
|
-
try {
|
|
281
|
-
const { injected, pending } = await runHeadInjectionLoop(controller, reader);
|
|
282
|
-
finishHeadInjectionStream(controller, pending, injected);
|
|
283
|
-
} catch (error) {
|
|
284
|
-
controller.error(error);
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
});
|
|
288
|
-
}, pipeStreamWithIslandMarkerDetection = (stream, markup) => {
|
|
289
|
-
const encoder = new TextEncoder;
|
|
290
|
-
const decoder = new TextDecoder;
|
|
291
|
-
const lookbehind = Math.max(ISLAND_MARKER.length, BYTES_PER_KILOBYTE);
|
|
292
|
-
const processPending = (controller, pending, injected) => {
|
|
293
|
-
if (injected) {
|
|
294
|
-
controller.enqueue(encoder.encode(pending));
|
|
295
|
-
return { injected, pending: "" };
|
|
296
|
-
}
|
|
297
|
-
const markerIndex = pending.indexOf(ISLAND_MARKER);
|
|
298
|
-
if (markerIndex >= 0) {
|
|
299
|
-
const tagStart = pending.lastIndexOf("<", markerIndex);
|
|
300
|
-
const injectAt = tagStart >= 0 ? tagStart : markerIndex;
|
|
301
|
-
const next = `${pending.slice(0, injectAt)}${markup}${pending.slice(injectAt)}`;
|
|
302
|
-
controller.enqueue(encoder.encode(next));
|
|
303
|
-
return { injected: true, pending: "" };
|
|
304
|
-
}
|
|
305
|
-
return {
|
|
306
|
-
injected,
|
|
307
|
-
pending: flushSafePendingText(controller, encoder, pending, lookbehind)
|
|
308
|
-
};
|
|
309
|
-
};
|
|
310
|
-
const finishIslandMarkerStream = (controller, pending) => {
|
|
311
|
-
const finalPending = pending + decoder.decode();
|
|
312
|
-
if (finalPending.length > 0) {
|
|
313
|
-
controller.enqueue(encoder.encode(finalPending));
|
|
314
|
-
}
|
|
315
|
-
controller.close();
|
|
316
|
-
};
|
|
317
|
-
const consumeIslandChunk = async (controller, reader, pending, injected) => {
|
|
318
|
-
const { done, value } = await readStreamChunk(reader);
|
|
319
|
-
if (done || !value) {
|
|
320
|
-
return { done, injected, pending };
|
|
321
|
-
}
|
|
322
|
-
const processed = processPending(controller, pending + streamChunkToString(value, decoder), injected);
|
|
323
|
-
return {
|
|
324
|
-
done,
|
|
325
|
-
injected: processed.injected,
|
|
326
|
-
pending: processed.pending
|
|
327
|
-
};
|
|
328
|
-
};
|
|
329
|
-
const runIslandMarkerLoop = async (controller, reader) => {
|
|
330
|
-
const consumeNextIslandChunk = async (injected, pending) => {
|
|
331
|
-
const consumed = await consumeIslandChunk(controller, reader, pending, injected);
|
|
332
|
-
const nextState = updateInjectedState(consumed, injected, pending);
|
|
333
|
-
if (nextState.done) {
|
|
334
|
-
return { injected, pending };
|
|
335
|
-
}
|
|
336
|
-
return consumeNextIslandChunk(nextState.injected, nextState.pending);
|
|
337
|
-
};
|
|
338
|
-
return consumeNextIslandChunk(false, "");
|
|
339
|
-
};
|
|
340
|
-
return new ReadableStream({
|
|
341
|
-
async start(controller) {
|
|
342
|
-
const reader = stream.getReader();
|
|
343
|
-
try {
|
|
344
|
-
const { pending } = await runIslandMarkerLoop(controller, reader);
|
|
345
|
-
finishIslandMarkerStream(controller, pending);
|
|
346
|
-
} catch (error) {
|
|
347
|
-
controller.error(error);
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
});
|
|
351
|
-
}, htmlContainsIslands = (html) => html.includes(ISLAND_MARKER), injectIslandPageContext = (html, options) => {
|
|
352
|
-
const manifest = globalThis.__absoluteManifest;
|
|
353
|
-
const hasIslands = options?.hasIslands ?? htmlContainsIslands(html);
|
|
354
|
-
if (!manifest || !hasIslands) {
|
|
355
|
-
return html;
|
|
356
|
-
}
|
|
357
|
-
if (html.includes(MANIFEST_MARKER) || html.includes(ISLAND_STATE_MARKER)) {
|
|
358
|
-
return html;
|
|
359
|
-
}
|
|
360
|
-
return injectHeadMarkup(html, buildIslandsHeadMarkup(manifest));
|
|
361
|
-
}, injectIslandPageContextStream = (stream, options) => {
|
|
362
|
-
const manifest = globalThis.__absoluteManifest;
|
|
363
|
-
if (!manifest)
|
|
364
|
-
return stream;
|
|
365
|
-
const markup = buildIslandsHeadMarkup(manifest);
|
|
366
|
-
if (options?.hasIslands === true) {
|
|
367
|
-
return pipeStreamWithHeadInjection(stream, markup);
|
|
368
|
-
}
|
|
369
|
-
if (options?.hasIslands === false) {
|
|
370
|
-
return stream;
|
|
371
|
-
}
|
|
372
|
-
return pipeStreamWithIslandMarkerDetection(stream, markup);
|
|
373
|
-
}, setCurrentIslandManifest = (manifest) => {
|
|
374
|
-
globalThis.__absoluteManifest = manifest;
|
|
375
|
-
};
|
|
376
|
-
var init_islandPageContext = __esm(() => {
|
|
377
|
-
init_constants();
|
|
378
|
-
});
|
|
379
|
-
|
|
380
|
-
// src/core/devRouteRegistrationCallsite.ts
|
|
381
|
-
var exports_devRouteRegistrationCallsite = {};
|
|
382
|
-
__export(exports_devRouteRegistrationCallsite, {
|
|
383
|
-
patchElysiaRouteRegistrationCallsites: () => patchElysiaRouteRegistrationCallsites,
|
|
384
|
-
getCurrentRouteRegistrationCallsite: () => getCurrentRouteRegistrationCallsite
|
|
385
|
-
});
|
|
386
|
-
import { AsyncLocalStorage } from "async_hooks";
|
|
387
|
-
import { Elysia } from "elysia";
|
|
388
|
-
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 = () => {
|
|
389
|
-
const value = Reflect.get(globalThis, ROUTE_CALLSITE_STORAGE_KEY);
|
|
390
|
-
if (value === null || typeof value === "undefined") {
|
|
391
|
-
return;
|
|
392
|
-
}
|
|
393
|
-
return isAsyncLocalStorage2(value) ? value : undefined;
|
|
394
|
-
}, ensureRouteCallsiteStorage = () => {
|
|
395
|
-
const existing = getRouteCallsiteStorage();
|
|
396
|
-
if (existing) {
|
|
397
|
-
return existing;
|
|
398
|
-
}
|
|
399
|
-
const storage = new AsyncLocalStorage;
|
|
400
|
-
Reflect.set(globalThis, ROUTE_CALLSITE_STORAGE_KEY, storage);
|
|
401
|
-
return storage;
|
|
402
|
-
}, normalizeCallsitePath = (value) => value.replace(`${process.cwd()}/`, "").replace(process.cwd(), "").replace(/^\.\/+/, ""), extractRouteRegistrationCallsite = (stack) => {
|
|
403
|
-
const frames = stack.split(`
|
|
404
|
-
`).slice(1).map((line) => line.trim());
|
|
405
|
-
for (const frame of frames) {
|
|
406
|
-
if (frame.includes("/node_modules/") || frame.includes("/dist/") || frame.includes("/src/core/devRouteRegistrationCallsite.")) {
|
|
407
|
-
continue;
|
|
408
|
-
}
|
|
409
|
-
const locationMatch = frame.match(/\((\/[^)]+:\d+:\d+)\)$/) ?? frame.match(/at (\/[^ ]+:\d+:\d+)$/);
|
|
410
|
-
if (locationMatch?.[1]) {
|
|
411
|
-
return normalizeCallsitePath(locationMatch[1]);
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
return;
|
|
415
|
-
}, captureRouteRegistrationCallsite = () => {
|
|
416
|
-
const { stack } = new Error;
|
|
417
|
-
if (!stack) {
|
|
418
|
-
return;
|
|
419
|
-
}
|
|
420
|
-
return extractRouteRegistrationCallsite(stack);
|
|
421
|
-
}, wrapRouteHandlerWithCallsite = (handler, callsite) => {
|
|
422
|
-
if (typeof handler !== "function" || !callsite) {
|
|
423
|
-
return handler;
|
|
424
|
-
}
|
|
425
|
-
const storage = ensureRouteCallsiteStorage();
|
|
426
|
-
return function wrappedRouteHandler(...args) {
|
|
427
|
-
return storage.run({ callsite }, () => Reflect.apply(handler, this, args));
|
|
428
|
-
};
|
|
429
|
-
}, getCurrentRouteRegistrationCallsite = () => getRouteCallsiteStorage()?.getStore()?.callsite, patchElysiaRouteRegistrationCallsites = () => {
|
|
430
|
-
if (false) {}
|
|
431
|
-
if (Reflect.get(globalThis, ROUTE_CALLSITE_PATCHED_KEY) === true) {
|
|
432
|
-
return;
|
|
433
|
-
}
|
|
434
|
-
const prototype = Elysia.prototype;
|
|
435
|
-
for (const methodName of ROUTE_METHOD_NAMES) {
|
|
436
|
-
const originalMethod = prototype[methodName];
|
|
437
|
-
if (typeof originalMethod !== "function") {
|
|
438
|
-
continue;
|
|
439
|
-
}
|
|
440
|
-
prototype[methodName] = function patchedRouteMethod(path, handler, ...rest) {
|
|
441
|
-
const callsite = captureRouteRegistrationCallsite();
|
|
442
|
-
return Reflect.apply(originalMethod, this, [
|
|
443
|
-
path,
|
|
444
|
-
wrapRouteHandlerWithCallsite(handler, callsite),
|
|
445
|
-
...rest
|
|
446
|
-
]);
|
|
447
|
-
};
|
|
448
|
-
}
|
|
449
|
-
Reflect.set(globalThis, ROUTE_CALLSITE_PATCHED_KEY, true);
|
|
450
|
-
};
|
|
451
|
-
var init_devRouteRegistrationCallsite = __esm(() => {
|
|
452
|
-
ROUTE_CALLSITE_STORAGE_KEY = Symbol.for("absolutejs.devRouteRegistrationCallsiteStorage");
|
|
453
|
-
ROUTE_CALLSITE_PATCHED_KEY = Symbol.for("absolutejs.devRouteRegistrationCallsitePatched");
|
|
454
|
-
ROUTE_METHOD_NAMES = [
|
|
455
|
-
"all",
|
|
456
|
-
"delete",
|
|
457
|
-
"get",
|
|
458
|
-
"head",
|
|
459
|
-
"options",
|
|
460
|
-
"patch",
|
|
461
|
-
"post",
|
|
462
|
-
"put"
|
|
463
|
-
];
|
|
464
|
-
});
|
|
465
|
-
|
|
466
|
-
// src/client/streamSwap.ts
|
|
467
|
-
var streamSwapRuntime = () => {
|
|
468
|
-
const SLOT_PATCH_EVENT = "absolutejs:slot-patch";
|
|
469
|
-
if (window.__ABS_SLOT_RUNTIME__ === true)
|
|
470
|
-
return;
|
|
471
|
-
window.__ABS_SLOT_RUNTIME__ = true;
|
|
472
|
-
window.__ABS_SLOT_CONSUMERS__ = window.__ABS_SLOT_CONSUMERS__ ?? {};
|
|
473
|
-
window.__ABS_SLOT_PENDING__ = window.__ABS_SLOT_PENDING__ ?? {};
|
|
474
|
-
const consumers = window.__ABS_SLOT_CONSUMERS__;
|
|
475
|
-
const pending = window.__ABS_SLOT_PENDING__;
|
|
476
|
-
const isObjectRecord4 = (value) => Boolean(value) && typeof value === "object";
|
|
477
|
-
const isPatchedPendingEntry = (value) => {
|
|
478
|
-
if (!isObjectRecord4(value))
|
|
479
|
-
return false;
|
|
480
|
-
return value.domPatched === true && "payload" in value;
|
|
481
|
-
};
|
|
482
|
-
const unwrapPendingPayload = (value) => isPatchedPendingEntry(value) ? value.payload : value;
|
|
483
|
-
const canApplyImmediately = () => window.__ABS_SLOT_HYDRATION_PENDING__ !== true;
|
|
484
|
-
const isAngularDeferPayload = (payload) => {
|
|
485
|
-
if (!isObjectRecord4(payload))
|
|
486
|
-
return false;
|
|
487
|
-
return payload.kind === "angular-defer";
|
|
488
|
-
};
|
|
489
|
-
const isVueSuspensePayload = (payload) => {
|
|
490
|
-
if (!isObjectRecord4(payload))
|
|
491
|
-
return false;
|
|
492
|
-
return payload.kind === "vue-suspense";
|
|
493
|
-
};
|
|
494
|
-
const resolveHtml = (payload) => {
|
|
495
|
-
if (!isObjectRecord4(payload)) {
|
|
496
|
-
return typeof payload === "string" ? payload : "";
|
|
497
|
-
}
|
|
498
|
-
if (typeof payload.html === "string") {
|
|
499
|
-
return payload.html;
|
|
500
|
-
}
|
|
501
|
-
return "";
|
|
502
|
-
};
|
|
503
|
-
const apply = (id, pendingEntry) => {
|
|
504
|
-
const payload = unwrapPendingPayload(pendingEntry);
|
|
505
|
-
if (!canApplyImmediately()) {
|
|
506
|
-
pending[id] = payload;
|
|
507
|
-
return;
|
|
212
|
+
const apply = (id, pendingEntry) => {
|
|
213
|
+
const payload = unwrapPendingPayload(pendingEntry);
|
|
214
|
+
if (!canApplyImmediately()) {
|
|
215
|
+
pending[id] = payload;
|
|
216
|
+
return;
|
|
508
217
|
}
|
|
509
218
|
const consumer = consumers[id];
|
|
510
219
|
if (typeof consumer !== "function") {
|
|
@@ -1139,62 +848,15 @@ var init_streamingSlots = __esm(() => {
|
|
|
1139
848
|
};
|
|
1140
849
|
});
|
|
1141
850
|
|
|
1142
|
-
// src/
|
|
1143
|
-
var
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
streamingSlots = [],
|
|
1152
|
-
policy
|
|
1153
|
-
} = {}) => {
|
|
1154
|
-
if (!response.body || streamingSlots.length === 0) {
|
|
1155
|
-
return response;
|
|
1156
|
-
}
|
|
1157
|
-
const body = appendStreamingSlotPatchesToStream(response.body, streamingSlots, {
|
|
1158
|
-
nonce,
|
|
1159
|
-
onError,
|
|
1160
|
-
policy,
|
|
1161
|
-
runtimePlacement,
|
|
1162
|
-
runtimePreludeScript
|
|
1163
|
-
});
|
|
1164
|
-
return new Response(body, {
|
|
1165
|
-
headers: cloneHeaders(response),
|
|
1166
|
-
status: response.status,
|
|
1167
|
-
statusText: response.statusText
|
|
1168
|
-
});
|
|
1169
|
-
}, withStreamingSlots = async (responseLike, options = {}) => enhanceHtmlResponseWithStreamingSlots(await toResponse(responseLike), options), mergeStreamingSlots = (registered, explicit) => {
|
|
1170
|
-
const merged = new Map;
|
|
1171
|
-
for (const slot of registered)
|
|
1172
|
-
merged.set(slot.id, slot);
|
|
1173
|
-
for (const slot of explicit)
|
|
1174
|
-
merged.set(slot.id, slot);
|
|
1175
|
-
return [...merged.values()];
|
|
1176
|
-
}, withRegisteredStreamingSlots = async (renderResponse, options = {}) => {
|
|
1177
|
-
const { result, slots } = await runWithStreamingSlotRegistry(renderResponse);
|
|
1178
|
-
const explicit = options.streamingSlots ?? [];
|
|
1179
|
-
return withStreamingSlots(result, {
|
|
1180
|
-
...options,
|
|
1181
|
-
streamingSlots: mergeStreamingSlots(slots, explicit)
|
|
1182
|
-
});
|
|
1183
|
-
};
|
|
1184
|
-
var init_responseEnhancers = __esm(() => {
|
|
1185
|
-
init_streamingSlots();
|
|
1186
|
-
init_streamingSlotRegistry();
|
|
1187
|
-
});
|
|
1188
|
-
|
|
1189
|
-
// src/utils/getDurationString.ts
|
|
1190
|
-
var getDurationString = (duration) => {
|
|
1191
|
-
let durationString;
|
|
1192
|
-
if (duration < MILLISECONDS_IN_A_SECOND) {
|
|
1193
|
-
durationString = `${duration.toFixed(TIME_PRECISION)}ms`;
|
|
1194
|
-
} else if (duration < MILLISECONDS_IN_A_MINUTE) {
|
|
1195
|
-
durationString = `${(duration / MILLISECONDS_IN_A_SECOND).toFixed(TIME_PRECISION)}s`;
|
|
1196
|
-
} else {
|
|
1197
|
-
durationString = `${(duration / MILLISECONDS_IN_A_MINUTE).toFixed(TIME_PRECISION)}m`;
|
|
851
|
+
// src/utils/getDurationString.ts
|
|
852
|
+
var getDurationString = (duration) => {
|
|
853
|
+
let durationString;
|
|
854
|
+
if (duration < MILLISECONDS_IN_A_SECOND) {
|
|
855
|
+
durationString = `${duration.toFixed(TIME_PRECISION)}ms`;
|
|
856
|
+
} else if (duration < MILLISECONDS_IN_A_MINUTE) {
|
|
857
|
+
durationString = `${(duration / MILLISECONDS_IN_A_SECOND).toFixed(TIME_PRECISION)}s`;
|
|
858
|
+
} else {
|
|
859
|
+
durationString = `${(duration / MILLISECONDS_IN_A_MINUTE).toFixed(TIME_PRECISION)}m`;
|
|
1198
860
|
}
|
|
1199
861
|
return durationString;
|
|
1200
862
|
};
|
|
@@ -1328,117 +990,14 @@ var init_logger = __esm(() => {
|
|
|
1328
990
|
};
|
|
1329
991
|
});
|
|
1330
992
|
|
|
1331
|
-
// src/core/
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
}
|
|
1338
|
-
return isAsyncLocalStorage3(value) ? value : undefined;
|
|
1339
|
-
}, ensureWarningStorage = () => {
|
|
1340
|
-
const existing = getWarningStorage();
|
|
1341
|
-
if (existing) {
|
|
1342
|
-
return existing;
|
|
1343
|
-
}
|
|
1344
|
-
const storage = new AsyncLocalStorage2;
|
|
1345
|
-
Reflect.set(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY2, storage);
|
|
1346
|
-
return storage;
|
|
1347
|
-
}, normalizeCallsitePath2 = (value) => value.replace(`${process.cwd()}/`, "").replace(process.cwd(), "").replace(/^\.\/+/, ""), formatWarningCallsite = (callsite) => {
|
|
1348
|
-
const match = callsite.match(/^(.*?)(:\d+:\d+)$/);
|
|
1349
|
-
if (!match) {
|
|
1350
|
-
return `\x1B[36m${callsite}\x1B[0m`;
|
|
1351
|
-
}
|
|
1352
|
-
return `\x1B[36m${match[1]}\x1B[33m${match[2]}\x1B[0m`;
|
|
1353
|
-
}, extractCallsiteFromStack = (stack) => {
|
|
1354
|
-
const frames = stack.split(`
|
|
1355
|
-
`).slice(1).map((line) => line.trim());
|
|
1356
|
-
for (const frame of frames) {
|
|
1357
|
-
if (frame.includes("/node_modules/") || frame.includes("/dist/") || frame.includes("/src/react/pageHandler.") || frame.includes("/src/vue/pageHandler.") || frame.includes("/src/svelte/pageHandler.") || frame.includes("/src/angular/pageHandler.") || frame.includes("/src/core/streamingSlotWarningScope.")) {
|
|
1358
|
-
continue;
|
|
1359
|
-
}
|
|
1360
|
-
const locationMatch = frame.match(/\((\/[^)]+:\d+:\d+)\)$/) ?? frame.match(/at (\/[^ ]+:\d+:\d+)$/);
|
|
1361
|
-
if (locationMatch?.[1]) {
|
|
1362
|
-
return normalizeCallsitePath2(locationMatch[1]);
|
|
1363
|
-
}
|
|
1364
|
-
}
|
|
1365
|
-
return;
|
|
1366
|
-
}, 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)}.` : ""}`, captureStreamingSlotWarningCallsite = () => {
|
|
1367
|
-
if (false) {}
|
|
1368
|
-
const { stack } = new Error;
|
|
1369
|
-
if (!stack) {
|
|
1370
|
-
return;
|
|
1371
|
-
}
|
|
1372
|
-
return extractCallsiteFromStack(stack);
|
|
1373
|
-
}, runWithStreamingSlotWarningScope = (task, metadata) => ensureWarningStorage().run({ handlerCallsite: metadata?.handlerCallsite, hasWarned: false }, task);
|
|
1374
|
-
var init_streamingSlotWarningScope = __esm(() => {
|
|
1375
|
-
init_logger();
|
|
1376
|
-
init_streamingSlotRegistrar();
|
|
1377
|
-
STREAMING_SLOT_WARNING_STORAGE_KEY2 = Symbol.for("absolutejs.streamingSlotWarningAsyncLocalStorage");
|
|
1378
|
-
setStreamingSlotWarningController({
|
|
1379
|
-
maybeWarn: (primitiveName) => {
|
|
1380
|
-
const store = getWarningStorage()?.getStore();
|
|
1381
|
-
if (!store || store.hasWarned) {
|
|
1382
|
-
return;
|
|
1383
|
-
}
|
|
1384
|
-
store.hasWarned = true;
|
|
1385
|
-
logWarn(buildMissingCollectorWarning(primitiveName, store.handlerCallsite));
|
|
1386
|
-
}
|
|
1387
|
-
});
|
|
993
|
+
// src/core/ssrCache.ts
|
|
994
|
+
var dirtyFrameworks, markSsrCacheDirty = (framework) => {
|
|
995
|
+
dirtyFrameworks.add(framework);
|
|
996
|
+
}, isSsrCacheDirty = (framework) => dirtyFrameworks.has(framework);
|
|
997
|
+
var init_ssrCache = __esm(() => {
|
|
998
|
+
dirtyFrameworks = new Set;
|
|
1388
999
|
});
|
|
1389
1000
|
|
|
1390
|
-
// src/utils/ssrErrorPage.ts
|
|
1391
|
-
var ssrErrorPage = (framework, error) => {
|
|
1392
|
-
const frameworkColors2 = {
|
|
1393
|
-
angular: "#dd0031",
|
|
1394
|
-
html: "#e34c26",
|
|
1395
|
-
htmx: "#1a365d",
|
|
1396
|
-
react: "#61dafb",
|
|
1397
|
-
svelte: "#ff3e00",
|
|
1398
|
-
vue: "#42b883"
|
|
1399
|
-
};
|
|
1400
|
-
const accent = frameworkColors2[framework] ?? "#94a3b8";
|
|
1401
|
-
const label = framework.charAt(0).toUpperCase() + framework.slice(1);
|
|
1402
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
1403
|
-
return `<!DOCTYPE html>
|
|
1404
|
-
<html>
|
|
1405
|
-
<head>
|
|
1406
|
-
<meta charset="utf-8">
|
|
1407
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
1408
|
-
<title>SSR Error - AbsoluteJS</title>
|
|
1409
|
-
<style>
|
|
1410
|
-
*{margin:0;padding:0;box-sizing:border-box}
|
|
1411
|
-
body{min-height:100vh;background:linear-gradient(135deg,rgba(15,23,42,0.98) 0%,rgba(30,41,59,0.98) 100%);color:#e2e8f0;font-family:"JetBrains Mono","Fira Code",ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;font-size:14px;line-height:1.6;display:flex;align-items:flex-start;justify-content:center;padding:32px}
|
|
1412
|
-
.card{max-width:720px;width:100%;background:rgba(30,41,59,0.6);border:1px solid rgba(71,85,105,0.5);border-radius:16px;box-shadow:0 25px 50px -12px rgba(0,0,0,0.5),0 0 0 1px rgba(255,255,255,0.05);overflow:hidden}
|
|
1413
|
-
.header{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:20px 24px;background:rgba(15,23,42,0.5);border-bottom:1px solid rgba(71,85,105,0.4)}
|
|
1414
|
-
.brand{font-weight:700;font-size:20px;color:#fff;letter-spacing:-0.02em}
|
|
1415
|
-
.badge{padding:5px 10px;border-radius:8px;font-size:12px;font-weight:600;background:${accent};color:#fff;opacity:0.95;box-shadow:0 2px 4px rgba(0,0,0,0.2)}
|
|
1416
|
-
.kind{color:#94a3b8;font-size:13px;font-weight:500}
|
|
1417
|
-
.content{padding:24px}
|
|
1418
|
-
.label{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:0.08em;color:#94a3b8;margin-bottom:8px}
|
|
1419
|
-
.message{margin:0;padding:16px 20px;background:rgba(239,68,68,0.12);border:1px solid rgba(239,68,68,0.25);border-radius:10px;overflow-x:auto;white-space:pre-wrap;word-break:break-word;color:#fca5a5;font-size:13px;line-height:1.5}
|
|
1420
|
-
.hint{margin-top:20px;padding:12px 20px;background:rgba(71,85,105,0.3);border-radius:10px;border:1px solid rgba(71,85,105,0.4);color:#cbd5e1;font-size:13px}
|
|
1421
|
-
</style>
|
|
1422
|
-
</head>
|
|
1423
|
-
<body>
|
|
1424
|
-
<div class="card">
|
|
1425
|
-
<div class="header">
|
|
1426
|
-
<div style="display:flex;align-items:center;gap:12px">
|
|
1427
|
-
<span class="brand">AbsoluteJS</span>
|
|
1428
|
-
<span class="badge">${label}</span>
|
|
1429
|
-
</div>
|
|
1430
|
-
<span class="kind">Server Render Error</span>
|
|
1431
|
-
</div>
|
|
1432
|
-
<div class="content">
|
|
1433
|
-
<div class="label">What went wrong</div>
|
|
1434
|
-
<pre class="message">${message.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")}</pre>
|
|
1435
|
-
<div class="hint">A component threw during server-side rendering. Check the terminal for the full stack trace.</div>
|
|
1436
|
-
</div>
|
|
1437
|
-
</div>
|
|
1438
|
-
</body>
|
|
1439
|
-
</html>`;
|
|
1440
|
-
};
|
|
1441
|
-
|
|
1442
1001
|
// src/utils/stringModifiers.ts
|
|
1443
1002
|
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) => {
|
|
1444
1003
|
if (!str.includes("-") && !str.includes("_")) {
|
|
@@ -1447,296 +1006,28 @@ var normalizeSlug = (str) => str.trim().replace(/\s+/g, "-").replace(/[^A-Za-z0-
|
|
|
1447
1006
|
return normalizeSlug(str).split(/[-_]/).filter(Boolean).map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1).toLowerCase()).join("");
|
|
1448
1007
|
}, toScreamingSnake = (str) => str.replace(/([a-z0-9])([A-Z])/g, "$1_$2").toUpperCase();
|
|
1449
1008
|
|
|
1450
|
-
// src/
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
return toPascal(name);
|
|
1463
|
-
}, resolveErrorConventionPath = (framework, pageName) => {
|
|
1464
|
-
const conventions = getMap()[framework];
|
|
1465
|
-
if (!conventions)
|
|
1466
|
-
return;
|
|
1467
|
-
return conventions.pages?.[pageName]?.error ?? conventions.defaults?.error;
|
|
1468
|
-
}, resolveNotFoundConventionPath = (framework) => getMap()[framework]?.defaults?.notFound, setConventions = (map) => {
|
|
1469
|
-
Reflect.set(globalThis, CONVENTIONS_KEY, map);
|
|
1470
|
-
}, isDev = () => true, buildErrorProps = (error) => {
|
|
1471
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
1472
|
-
const stack = isDev() && error instanceof Error ? error.stack : undefined;
|
|
1473
|
-
return { error: { message, stack } };
|
|
1474
|
-
}, renderReactError = async (conventionPath, errorProps) => {
|
|
1475
|
-
const { createElement } = await import("react");
|
|
1476
|
-
const { renderToReadableStream } = await import("react-dom/server");
|
|
1477
|
-
const mod = await import(conventionPath);
|
|
1478
|
-
const [firstKey] = Object.keys(mod);
|
|
1479
|
-
const ErrorComponent = mod.default ?? (firstKey ? mod[firstKey] : undefined);
|
|
1480
|
-
const element = createElement(ErrorComponent, errorProps);
|
|
1481
|
-
const stream = await renderToReadableStream(element);
|
|
1482
|
-
return new Response(stream, {
|
|
1483
|
-
headers: { "Content-Type": "text/html" },
|
|
1484
|
-
status: 500
|
|
1485
|
-
});
|
|
1486
|
-
}, renderSvelteError = async (conventionPath, errorProps) => {
|
|
1487
|
-
const { render } = await import("svelte/server");
|
|
1488
|
-
const mod = await import(conventionPath);
|
|
1489
|
-
const ErrorComponent = mod.default;
|
|
1490
|
-
const { head, body } = render(ErrorComponent, {
|
|
1491
|
-
props: errorProps
|
|
1492
|
-
});
|
|
1493
|
-
const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
|
|
1494
|
-
return new Response(html, {
|
|
1495
|
-
headers: { "Content-Type": "text/html" },
|
|
1496
|
-
status: 500
|
|
1497
|
-
});
|
|
1498
|
-
}, unescapeVueStyles = (ssrBody) => {
|
|
1499
|
-
let styles = "";
|
|
1500
|
-
const body = ssrBody.replace(/<style>([\s\S]*?)<\/style>/g, (_, css) => {
|
|
1501
|
-
styles += `<style>${css.replace(/"/g, '"').replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")}</style>`;
|
|
1502
|
-
return "";
|
|
1503
|
-
});
|
|
1504
|
-
return { body, styles };
|
|
1505
|
-
}, renderVueError = async (conventionPath, errorProps) => {
|
|
1506
|
-
const { createSSRApp, h } = await import("vue");
|
|
1507
|
-
const { renderToString } = await import("vue/server-renderer");
|
|
1508
|
-
const mod = await import(conventionPath);
|
|
1509
|
-
const ErrorComponent = mod.default;
|
|
1510
|
-
const app = createSSRApp({
|
|
1511
|
-
render: () => h(ErrorComponent, errorProps)
|
|
1512
|
-
});
|
|
1513
|
-
const rawBody = await renderToString(app);
|
|
1514
|
-
const { styles, body } = unescapeVueStyles(rawBody);
|
|
1515
|
-
const html = `<!DOCTYPE html><html><head>${styles}</head><body><div id="root">${body}</div></body></html>`;
|
|
1516
|
-
return new Response(html, {
|
|
1517
|
-
headers: { "Content-Type": "text/html" },
|
|
1518
|
-
status: 500
|
|
1519
|
-
});
|
|
1520
|
-
}, renderAngularError = async (conventionPath, errorProps) => {
|
|
1521
|
-
const mod = await import(conventionPath);
|
|
1522
|
-
const renderError = mod.default ?? mod.renderError;
|
|
1523
|
-
if (typeof renderError !== "function")
|
|
1524
|
-
return null;
|
|
1525
|
-
const html = renderError(errorProps);
|
|
1526
|
-
return new Response(html, {
|
|
1527
|
-
headers: { "Content-Type": "text/html" },
|
|
1528
|
-
status: 500
|
|
1529
|
-
});
|
|
1530
|
-
}, logConventionRenderError = (framework, label, renderError) => {
|
|
1531
|
-
const message = renderError instanceof Error ? renderError.message : "";
|
|
1532
|
-
if (message.includes("Cannot find module") || message.includes("Cannot find package") || message.includes("not found in module")) {
|
|
1533
|
-
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}).`);
|
|
1534
|
-
return;
|
|
1009
|
+
// src/core/islandManifest.ts
|
|
1010
|
+
var toIslandFrameworkSegment = (framework) => framework[0]?.toUpperCase() + framework.slice(1), collectFrameworkIslands = (manifest, prefix) => {
|
|
1011
|
+
const entries = {};
|
|
1012
|
+
let found = false;
|
|
1013
|
+
for (const [key, value] of Object.entries(manifest)) {
|
|
1014
|
+
if (!key.startsWith(prefix))
|
|
1015
|
+
continue;
|
|
1016
|
+
const component = key.slice(prefix.length);
|
|
1017
|
+
if (!component)
|
|
1018
|
+
continue;
|
|
1019
|
+
entries[component] = value;
|
|
1020
|
+
found = true;
|
|
1535
1021
|
}
|
|
1536
|
-
|
|
1537
|
-
},
|
|
1538
|
-
const
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
try {
|
|
1546
|
-
return await renderer(conventionPath, errorProps);
|
|
1547
|
-
} catch (renderError) {
|
|
1548
|
-
logConventionRenderError(framework, "error", renderError);
|
|
1549
|
-
}
|
|
1550
|
-
return null;
|
|
1551
|
-
}, renderReactNotFound = async (conventionPath) => {
|
|
1552
|
-
const { createElement } = await import("react");
|
|
1553
|
-
const { renderToReadableStream } = await import("react-dom/server");
|
|
1554
|
-
const mod = await import(conventionPath);
|
|
1555
|
-
const [nfKey] = Object.keys(mod);
|
|
1556
|
-
const NotFoundComponent = mod.default ?? (nfKey ? mod[nfKey] : undefined);
|
|
1557
|
-
const element = createElement(NotFoundComponent);
|
|
1558
|
-
const stream = await renderToReadableStream(element);
|
|
1559
|
-
return new Response(stream, {
|
|
1560
|
-
headers: { "Content-Type": "text/html" },
|
|
1561
|
-
status: 404
|
|
1562
|
-
});
|
|
1563
|
-
}, renderSvelteNotFound = async (conventionPath) => {
|
|
1564
|
-
const { render } = await import("svelte/server");
|
|
1565
|
-
const mod = await import(conventionPath);
|
|
1566
|
-
const NotFoundComponent = mod.default;
|
|
1567
|
-
const { head, body } = render(NotFoundComponent);
|
|
1568
|
-
const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
|
|
1569
|
-
return new Response(html, {
|
|
1570
|
-
headers: { "Content-Type": "text/html" },
|
|
1571
|
-
status: 404
|
|
1572
|
-
});
|
|
1573
|
-
}, renderVueNotFound = async (conventionPath) => {
|
|
1574
|
-
const { createSSRApp, h } = await import("vue");
|
|
1575
|
-
const { renderToString } = await import("vue/server-renderer");
|
|
1576
|
-
const mod = await import(conventionPath);
|
|
1577
|
-
const NotFoundComponent = mod.default;
|
|
1578
|
-
const app = createSSRApp({
|
|
1579
|
-
render: () => h(NotFoundComponent)
|
|
1580
|
-
});
|
|
1581
|
-
const rawBody = await renderToString(app);
|
|
1582
|
-
const { styles, body } = unescapeVueStyles(rawBody);
|
|
1583
|
-
const html = `<!DOCTYPE html><html><head>${styles}</head><body><div id="root">${body}</div></body></html>`;
|
|
1584
|
-
return new Response(html, {
|
|
1585
|
-
headers: { "Content-Type": "text/html" },
|
|
1586
|
-
status: 404
|
|
1587
|
-
});
|
|
1588
|
-
}, renderAngularNotFound = async (conventionPath) => {
|
|
1589
|
-
const mod = await import(conventionPath);
|
|
1590
|
-
const renderNotFound = mod.default ?? mod.renderNotFound;
|
|
1591
|
-
if (typeof renderNotFound !== "function")
|
|
1592
|
-
return null;
|
|
1593
|
-
const html = renderNotFound();
|
|
1594
|
-
return new Response(html, {
|
|
1595
|
-
headers: { "Content-Type": "text/html" },
|
|
1596
|
-
status: 404
|
|
1597
|
-
});
|
|
1598
|
-
}, NOT_FOUND_RENDERERS, renderConventionNotFound = async (framework) => {
|
|
1599
|
-
const conventionPath = resolveNotFoundConventionPath(framework);
|
|
1600
|
-
if (!conventionPath)
|
|
1601
|
-
return null;
|
|
1602
|
-
const renderer = NOT_FOUND_RENDERERS[framework];
|
|
1603
|
-
if (!renderer)
|
|
1604
|
-
return null;
|
|
1605
|
-
try {
|
|
1606
|
-
return await renderer(conventionPath);
|
|
1607
|
-
} catch (renderError) {
|
|
1608
|
-
logConventionRenderError(framework, "not-found", renderError);
|
|
1609
|
-
}
|
|
1610
|
-
return null;
|
|
1611
|
-
}, NOT_FOUND_PRIORITY, renderFirstNotFound = async () => {
|
|
1612
|
-
for (const framework of NOT_FOUND_PRIORITY) {
|
|
1613
|
-
if (!getMap()[framework]?.defaults?.notFound)
|
|
1614
|
-
continue;
|
|
1615
|
-
const response = await renderConventionNotFound(framework);
|
|
1616
|
-
if (response)
|
|
1617
|
-
return response;
|
|
1618
|
-
}
|
|
1619
|
-
return null;
|
|
1620
|
-
};
|
|
1621
|
-
var init_resolveConvention = __esm(() => {
|
|
1622
|
-
ERROR_RENDERERS = {
|
|
1623
|
-
angular: renderAngularError,
|
|
1624
|
-
react: renderReactError,
|
|
1625
|
-
svelte: renderSvelteError,
|
|
1626
|
-
vue: renderVueError
|
|
1627
|
-
};
|
|
1628
|
-
NOT_FOUND_RENDERERS = {
|
|
1629
|
-
angular: renderAngularNotFound,
|
|
1630
|
-
react: renderReactNotFound,
|
|
1631
|
-
svelte: renderSvelteNotFound,
|
|
1632
|
-
vue: renderVueNotFound
|
|
1633
|
-
};
|
|
1634
|
-
NOT_FOUND_PRIORITY = [
|
|
1635
|
-
"react",
|
|
1636
|
-
"svelte",
|
|
1637
|
-
"vue",
|
|
1638
|
-
"angular"
|
|
1639
|
-
];
|
|
1640
|
-
});
|
|
1641
|
-
|
|
1642
|
-
// src/react/pageHandler.ts
|
|
1643
|
-
var ssrDirty = false, buildRefreshSetup = () => {
|
|
1644
|
-
if (false) {}
|
|
1645
|
-
return "window.__REFRESH_BUFFER__=[];" + "window.$RefreshReg$=function(t,i){window.__REFRESH_BUFFER__.push([t,i])};" + "window.$RefreshSig$=function(){return function(t){return t}};";
|
|
1646
|
-
}, buildDirtyResponse = (index, maybeProps) => {
|
|
1647
|
-
const propsScript = maybeProps ? `window.__INITIAL_PROPS__=${JSON.stringify(maybeProps)};` : "";
|
|
1648
|
-
const dirtyFlag = "window.__SSR_DIRTY__=true;";
|
|
1649
|
-
const refreshSetup = buildRefreshSetup();
|
|
1650
|
-
const inlineScript = `${propsScript}${dirtyFlag}${refreshSetup}`;
|
|
1651
|
-
const html = `<!DOCTYPE html><html><head></head><body>` + `<script>${inlineScript}</script>` + `<script type="module" src="${index}"></script>` + `</body></html>`;
|
|
1652
|
-
return new Response(html, {
|
|
1653
|
-
headers: { "Content-Type": "text/html" }
|
|
1654
|
-
});
|
|
1655
|
-
}, handleReactPageRequest = async (PageComponentOrInput, index, ...args) => {
|
|
1656
|
-
const {
|
|
1657
|
-
Page,
|
|
1658
|
-
index: resolvedIndex,
|
|
1659
|
-
options,
|
|
1660
|
-
props: maybeProps
|
|
1661
|
-
} = typeof PageComponentOrInput === "object" && PageComponentOrInput !== null && "Page" in PageComponentOrInput ? {
|
|
1662
|
-
index: PageComponentOrInput.index,
|
|
1663
|
-
options: PageComponentOrInput,
|
|
1664
|
-
Page: PageComponentOrInput.Page,
|
|
1665
|
-
props: PageComponentOrInput.props
|
|
1666
|
-
} : {
|
|
1667
|
-
index: index ?? "",
|
|
1668
|
-
options: args[1],
|
|
1669
|
-
Page: PageComponentOrInput,
|
|
1670
|
-
props: args[0]
|
|
1671
|
-
};
|
|
1672
|
-
if (ssrDirty) {
|
|
1673
|
-
return buildDirtyResponse(resolvedIndex, maybeProps);
|
|
1674
|
-
}
|
|
1675
|
-
try {
|
|
1676
|
-
const handlerCallsite = options?.collectStreamingSlots === true ? undefined : getCurrentRouteRegistrationCallsite() ?? captureStreamingSlotWarningCallsite();
|
|
1677
|
-
const renderPageResponse = async () => {
|
|
1678
|
-
const { createElement } = await import("react");
|
|
1679
|
-
const { renderToReadableStream } = await import("react-dom/server");
|
|
1680
|
-
const element = maybeProps !== undefined ? createElement(Page, maybeProps) : createElement(Page);
|
|
1681
|
-
const propsScript = maybeProps ? `window.__INITIAL_PROPS__=${JSON.stringify(maybeProps)};` : "";
|
|
1682
|
-
const refreshSetup = buildRefreshSetup();
|
|
1683
|
-
const stream = await renderToReadableStream(element, {
|
|
1684
|
-
bootstrapModules: [resolvedIndex],
|
|
1685
|
-
bootstrapScriptContent: propsScript + refreshSetup || undefined,
|
|
1686
|
-
onError(error) {
|
|
1687
|
-
console.error("[SSR] React streaming error:", error);
|
|
1688
|
-
}
|
|
1689
|
-
});
|
|
1690
|
-
const htmlStream = injectIslandPageContextStream(stream);
|
|
1691
|
-
return new Response(htmlStream, {
|
|
1692
|
-
headers: { "Content-Type": "text/html" }
|
|
1693
|
-
});
|
|
1694
|
-
};
|
|
1695
|
-
return runWithStreamingSlotWarningScope(() => options?.collectStreamingSlots === true ? withRegisteredStreamingSlots(renderPageResponse, options) : renderPageResponse(), { handlerCallsite });
|
|
1696
|
-
} catch (error) {
|
|
1697
|
-
console.error("[SSR] React render error:", error);
|
|
1698
|
-
const pageName = Page.name || Page.displayName || "";
|
|
1699
|
-
const conventionResponse = await renderConventionError("react", pageName, error);
|
|
1700
|
-
if (conventionResponse)
|
|
1701
|
-
return conventionResponse;
|
|
1702
|
-
return new Response(ssrErrorPage("react", error), {
|
|
1703
|
-
headers: { "Content-Type": "text/html" },
|
|
1704
|
-
status: 500
|
|
1705
|
-
});
|
|
1706
|
-
}
|
|
1707
|
-
}, invalidateReactSsrCache = () => {
|
|
1708
|
-
ssrDirty = true;
|
|
1709
|
-
};
|
|
1710
|
-
var init_pageHandler = __esm(() => {
|
|
1711
|
-
init_islandPageContext();
|
|
1712
|
-
init_devRouteRegistrationCallsite();
|
|
1713
|
-
init_responseEnhancers();
|
|
1714
|
-
init_streamingSlotWarningScope();
|
|
1715
|
-
init_resolveConvention();
|
|
1716
|
-
});
|
|
1717
|
-
|
|
1718
|
-
// src/core/islandManifest.ts
|
|
1719
|
-
var toIslandFrameworkSegment = (framework) => framework[0]?.toUpperCase() + framework.slice(1), collectFrameworkIslands = (manifest, prefix) => {
|
|
1720
|
-
const entries = {};
|
|
1721
|
-
let found = false;
|
|
1722
|
-
for (const [key, value] of Object.entries(manifest)) {
|
|
1723
|
-
if (!key.startsWith(prefix))
|
|
1724
|
-
continue;
|
|
1725
|
-
const component = key.slice(prefix.length);
|
|
1726
|
-
if (!component)
|
|
1727
|
-
continue;
|
|
1728
|
-
entries[component] = value;
|
|
1729
|
-
found = true;
|
|
1730
|
-
}
|
|
1731
|
-
return found ? entries : undefined;
|
|
1732
|
-
}, getIslandManifestEntries = (manifest) => {
|
|
1733
|
-
const islands = {};
|
|
1734
|
-
const frameworks = ["react", "svelte", "vue", "angular"];
|
|
1735
|
-
for (const framework of frameworks) {
|
|
1736
|
-
const prefix = `Island${toIslandFrameworkSegment(framework)}`;
|
|
1737
|
-
const entries = collectFrameworkIslands(manifest, prefix);
|
|
1738
|
-
if (entries)
|
|
1739
|
-
islands[framework] = entries;
|
|
1022
|
+
return found ? entries : undefined;
|
|
1023
|
+
}, getIslandManifestEntries = (manifest) => {
|
|
1024
|
+
const islands = {};
|
|
1025
|
+
const frameworks = ["react", "svelte", "vue", "angular"];
|
|
1026
|
+
for (const framework of frameworks) {
|
|
1027
|
+
const prefix = `Island${toIslandFrameworkSegment(framework)}`;
|
|
1028
|
+
const entries = collectFrameworkIslands(manifest, prefix);
|
|
1029
|
+
if (entries)
|
|
1030
|
+
islands[framework] = entries;
|
|
1740
1031
|
}
|
|
1741
1032
|
return islands;
|
|
1742
1033
|
}, getIslandManifestKey = (framework, component) => `Island${toIslandFrameworkSegment(framework)}${component}`;
|
|
@@ -2502,12 +1793,27 @@ var init_lowerAwaitSlotSyntax = __esm(() => {
|
|
|
2502
1793
|
});
|
|
2503
1794
|
|
|
2504
1795
|
// src/build/stylePreprocessor.ts
|
|
1796
|
+
var exports_stylePreprocessor = {};
|
|
1797
|
+
__export(exports_stylePreprocessor, {
|
|
1798
|
+
stylePreprocessorPlugin: () => stylePreprocessorPlugin,
|
|
1799
|
+
isStylePath: () => isStylePath,
|
|
1800
|
+
isStyleModulePath: () => isStyleModulePath,
|
|
1801
|
+
isPreprocessableStylePath: () => isPreprocessableStylePath,
|
|
1802
|
+
getStyleBaseName: () => getStyleBaseName,
|
|
1803
|
+
getCssOutputExtension: () => getCssOutputExtension,
|
|
1804
|
+
createSvelteStylePreprocessor: () => createSvelteStylePreprocessor,
|
|
1805
|
+
createStyleTransformConfig: () => createStyleTransformConfig,
|
|
1806
|
+
createStylePreprocessorPlugin: () => createStylePreprocessorPlugin,
|
|
1807
|
+
compileStyleSource: () => compileStyleSource,
|
|
1808
|
+
compileStyleFileIfNeededSync: () => compileStyleFileIfNeededSync,
|
|
1809
|
+
compileStyleFileIfNeeded: () => compileStyleFileIfNeeded
|
|
1810
|
+
});
|
|
2505
1811
|
import { existsSync as existsSync4, readFileSync as readFileSync3 } from "fs";
|
|
2506
1812
|
import { readFile } from "fs/promises";
|
|
2507
1813
|
import { createRequire } from "module";
|
|
2508
1814
|
import { dirname as dirname2, extname, isAbsolute, join as join3, relative, resolve as resolve4 } from "path";
|
|
2509
1815
|
import { fileURLToPath } from "url";
|
|
2510
|
-
var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATTERN, importOptionalPeer, requireOptionalPeer, requireFromCwd, isPreprocessableStylePath = (filePath) => STYLE_EXTENSION_PATTERN.test(filePath), isStyleModulePath = (filePath) => STYLE_MODULE_EXTENSION_PATTERN.test(filePath), isStylePath = (filePath) => /\.(css|s[ac]ss|less|styl(?:us)?)$/i.test(filePath), getStyleBaseName = (filePath) => filePath.replace(/\.(css|s[ac]ss|less|styl(?:us)?)$/i, ""), getStyleLanguage = (filePathOrLanguage) => {
|
|
1816
|
+
var CSS_EXTENSION_PATTERN, STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATTERN, importOptionalPeer, requireOptionalPeer, requireFromCwd, isPreprocessableStylePath = (filePath) => STYLE_EXTENSION_PATTERN.test(filePath), isStyleModulePath = (filePath) => STYLE_MODULE_EXTENSION_PATTERN.test(filePath), isStylePath = (filePath) => /\.(css|s[ac]ss|less|styl(?:us)?)$/i.test(filePath), getStyleBaseName = (filePath) => filePath.replace(/\.(css|s[ac]ss|less|styl(?:us)?)$/i, ""), getStyleLanguage = (filePathOrLanguage) => {
|
|
2511
1817
|
const normalized = filePathOrLanguage.toLowerCase();
|
|
2512
1818
|
if (normalized === "scss" || normalized.endsWith(".scss"))
|
|
2513
1819
|
return "scss";
|
|
@@ -2518,7 +1824,13 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
|
|
|
2518
1824
|
if (normalized === "styl" || normalized === "stylus" || normalized.endsWith(".styl") || normalized.endsWith(".stylus"))
|
|
2519
1825
|
return "stylus";
|
|
2520
1826
|
return null;
|
|
2521
|
-
}, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`),
|
|
1827
|
+
}, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`), requireOptionalPeerSync = (specifier) => {
|
|
1828
|
+
try {
|
|
1829
|
+
return requireFromCwd(specifier);
|
|
1830
|
+
} catch {
|
|
1831
|
+
return requireOptionalPeer(specifier);
|
|
1832
|
+
}
|
|
1833
|
+
}, normalizeLoadPaths = (filePath, paths = []) => [
|
|
2522
1834
|
dirname2(filePath),
|
|
2523
1835
|
process.cwd(),
|
|
2524
1836
|
...paths.map((path) => resolve4(process.cwd(), path))
|
|
@@ -2647,8 +1959,72 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
|
|
|
2647
1959
|
}, getSassOptions = (config, language) => ({
|
|
2648
1960
|
...config?.sass ?? {},
|
|
2649
1961
|
...language === "scss" ? config?.scss ?? {} : {}
|
|
2650
|
-
}), getLessOptions = (config) => config?.less ?? {}, getStylusOptions = (config) => config?.stylus ?? {}, withAdditionalData = (contents, additionalData) => additionalData ? `${additionalData}
|
|
2651
|
-
${contents}` : contents,
|
|
1962
|
+
}), getLessOptions = (config) => config?.less ?? {}, getStylusOptions = (config) => config?.stylus ?? {}, createStyleTransformConfig = (stylePreprocessors, postcss) => postcss === undefined ? stylePreprocessors : { ...stylePreprocessors ?? {}, postcss }, withAdditionalData = (contents, additionalData) => additionalData ? `${additionalData}
|
|
1963
|
+
${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
1964
|
+
if (mod && typeof mod === "object" && "default" in mod) {
|
|
1965
|
+
return mod.default ?? mod;
|
|
1966
|
+
}
|
|
1967
|
+
return mod;
|
|
1968
|
+
}, loadPostcssConfigFile = async (configPath) => {
|
|
1969
|
+
const resolved = resolve4(process.cwd(), configPath);
|
|
1970
|
+
const loaded = resolved.endsWith(".cjs") || resolved.endsWith(".cts") ? requireOptionalPeerSync(resolved) : await importOptionalPeer(`${new URL(`file://${resolved}`).href}?t=${Date.now()}`);
|
|
1971
|
+
const config = normalizePostcssModule(loaded);
|
|
1972
|
+
const value = typeof config === "function" ? await config({
|
|
1973
|
+
cwd: process.cwd(),
|
|
1974
|
+
env: "development"
|
|
1975
|
+
}) : config;
|
|
1976
|
+
return normalizePostcssModule(value) ?? {};
|
|
1977
|
+
}, normalizePostcssPlugins = (plugins) => {
|
|
1978
|
+
if (!plugins)
|
|
1979
|
+
return [];
|
|
1980
|
+
if (Array.isArray(plugins))
|
|
1981
|
+
return plugins.filter(Boolean);
|
|
1982
|
+
const resolved = [];
|
|
1983
|
+
for (const [specifier, options] of Object.entries(plugins)) {
|
|
1984
|
+
if (options === false)
|
|
1985
|
+
continue;
|
|
1986
|
+
const mod = normalizePostcssModule(requireOptionalPeerSync(specifier));
|
|
1987
|
+
const plugin = typeof mod === "function" ? mod(options === true ? undefined : options) : mod;
|
|
1988
|
+
if (plugin)
|
|
1989
|
+
resolved.push(plugin);
|
|
1990
|
+
}
|
|
1991
|
+
return resolved;
|
|
1992
|
+
}, resolvePostcssConfig = async (config) => {
|
|
1993
|
+
const inlineConfig = config?.postcss;
|
|
1994
|
+
if (!inlineConfig)
|
|
1995
|
+
return null;
|
|
1996
|
+
const fileConfig = inlineConfig.config ? await loadPostcssConfigFile(inlineConfig.config) : {};
|
|
1997
|
+
const plugins = [
|
|
1998
|
+
...normalizePostcssPlugins(fileConfig.plugins),
|
|
1999
|
+
...normalizePostcssPlugins(inlineConfig.plugins)
|
|
2000
|
+
];
|
|
2001
|
+
if (plugins.length === 0)
|
|
2002
|
+
return null;
|
|
2003
|
+
return {
|
|
2004
|
+
options: {
|
|
2005
|
+
...fileConfig.options ?? {},
|
|
2006
|
+
...inlineConfig.options ?? {}
|
|
2007
|
+
},
|
|
2008
|
+
plugins
|
|
2009
|
+
};
|
|
2010
|
+
}, runPostcss = async (css, filePath, config) => {
|
|
2011
|
+
const postcssConfig = await resolvePostcssConfig(config);
|
|
2012
|
+
if (!postcssConfig)
|
|
2013
|
+
return css;
|
|
2014
|
+
let postcssModule;
|
|
2015
|
+
try {
|
|
2016
|
+
postcssModule = await importOptionalPeer("postcss");
|
|
2017
|
+
} catch {
|
|
2018
|
+
throw missingDependencyError("postcss", filePath);
|
|
2019
|
+
}
|
|
2020
|
+
const postcss = postcssModule.default ?? postcssModule;
|
|
2021
|
+
const result = await postcss(postcssConfig.plugins).process(css, {
|
|
2022
|
+
from: filePath,
|
|
2023
|
+
map: false,
|
|
2024
|
+
...postcssConfig.options
|
|
2025
|
+
});
|
|
2026
|
+
return result.css;
|
|
2027
|
+
}, createSassImporter = (entryFile, loadPaths, language, config) => ({
|
|
2652
2028
|
canonicalize(specifier, options) {
|
|
2653
2029
|
const fromDirectory = options.containingUrl ? dirname2(fileURLToPath(options.containingUrl)) : dirname2(entryFile);
|
|
2654
2030
|
const resolved = resolveImportPath(specifier, fromDirectory, loadPaths, language, config);
|
|
@@ -2727,7 +2103,7 @@ ${contents}` : contents, createSassImporter = (entryFile, loadPaths, language, c
|
|
|
2727
2103
|
syntax: language === "sass" ? "indented" : "scss",
|
|
2728
2104
|
url: new URL(`file://${filePath}`)
|
|
2729
2105
|
});
|
|
2730
|
-
return result.css;
|
|
2106
|
+
return runPostcss(result.css, filePath, config);
|
|
2731
2107
|
}
|
|
2732
2108
|
if (language === "less") {
|
|
2733
2109
|
const options = getLessOptions(config);
|
|
@@ -2752,15 +2128,15 @@ ${contents}` : contents, createSassImporter = (entryFile, loadPaths, language, c
|
|
|
2752
2128
|
createLessFileManager(filePath, loadPaths, config)
|
|
2753
2129
|
]
|
|
2754
2130
|
});
|
|
2755
|
-
return result.css;
|
|
2131
|
+
return runPostcss(result.css, filePath, config);
|
|
2756
2132
|
}
|
|
2757
2133
|
if (language === "stylus") {
|
|
2758
2134
|
const options = getStylusOptions(config);
|
|
2759
2135
|
const loadPaths = normalizeLoadPaths(filePath, options.paths);
|
|
2760
2136
|
const contents = withAdditionalData(preprocessLoadedStyle(rawContents, filePath, filePath, loadPaths, "stylus", config), options.additionalData);
|
|
2761
|
-
return renderStylus(contents, filePath, loadPaths, options);
|
|
2137
|
+
return runPostcss(await renderStylus(contents, filePath, loadPaths, options), filePath, config);
|
|
2762
2138
|
}
|
|
2763
|
-
return rawContents;
|
|
2139
|
+
return runPostcss(rawContents, filePath, config);
|
|
2764
2140
|
}, createStylePreprocessorPlugin = (config) => ({
|
|
2765
2141
|
name: "absolute-style-preprocessor",
|
|
2766
2142
|
setup(build) {
|
|
@@ -2796,6 +2172,10 @@ ${contents}` : contents, createSassImporter = (entryFile, loadPaths, language, c
|
|
|
2796
2172
|
loader: "css"
|
|
2797
2173
|
};
|
|
2798
2174
|
});
|
|
2175
|
+
build.onLoad({ filter: CSS_EXTENSION_PATTERN }, async ({ path }) => ({
|
|
2176
|
+
contents: await compileStyleSource(path, undefined, undefined, config),
|
|
2177
|
+
loader: "css"
|
|
2178
|
+
}));
|
|
2799
2179
|
}
|
|
2800
2180
|
}), stylePreprocessorPlugin, createSvelteStylePreprocessor = (config) => ({
|
|
2801
2181
|
style: async ({
|
|
@@ -2813,11 +2193,46 @@ ${contents}` : contents, createSassImporter = (entryFile, loadPaths, language, c
|
|
|
2813
2193
|
}
|
|
2814
2194
|
}), compileStyleFileIfNeeded = async (filePath, config) => {
|
|
2815
2195
|
if (!isPreprocessableStylePath(filePath)) {
|
|
2816
|
-
return readFile(filePath, "utf-8");
|
|
2196
|
+
return runPostcss(await readFile(filePath, "utf-8"), filePath, config);
|
|
2817
2197
|
}
|
|
2818
2198
|
return compileStyleSource(filePath, undefined, undefined, config);
|
|
2819
|
-
}
|
|
2199
|
+
}, compileStyleFileIfNeededSync = (filePath, config) => {
|
|
2200
|
+
const rawContents = readFileSync3(filePath, "utf-8");
|
|
2201
|
+
const language = getStyleLanguage(filePath);
|
|
2202
|
+
if (config?.postcss) {
|
|
2203
|
+
throw new Error(`Unable to compile ${filePath}: PostCSS preprocessing is async-only.`);
|
|
2204
|
+
}
|
|
2205
|
+
if (language === "scss" || language === "sass") {
|
|
2206
|
+
const options = getSassOptions(config, language);
|
|
2207
|
+
const packageName = options.implementation ?? "sass";
|
|
2208
|
+
let sass;
|
|
2209
|
+
try {
|
|
2210
|
+
sass = requireOptionalPeerSync(packageName);
|
|
2211
|
+
} catch {
|
|
2212
|
+
throw missingDependencyError(packageName, filePath);
|
|
2213
|
+
}
|
|
2214
|
+
const contents = withAdditionalData(rawContents, options.additionalData);
|
|
2215
|
+
const loadPaths = normalizeLoadPaths(filePath, options.loadPaths);
|
|
2216
|
+
return sass.compileString(contents, {
|
|
2217
|
+
importers: [
|
|
2218
|
+
createSassImporter(filePath, loadPaths, language, config)
|
|
2219
|
+
],
|
|
2220
|
+
loadPaths,
|
|
2221
|
+
style: "expanded",
|
|
2222
|
+
syntax: language === "sass" ? "indented" : "scss",
|
|
2223
|
+
url: new URL(`file://${filePath}`)
|
|
2224
|
+
}).css;
|
|
2225
|
+
}
|
|
2226
|
+
if (language === "less") {
|
|
2227
|
+
throw new Error(`Unable to compile ${filePath}: Less styleUrl preprocessing is async-only. Import the Less file from a bundled entrypoint or use SCSS/CSS for Angular styleUrl.`);
|
|
2228
|
+
}
|
|
2229
|
+
if (language === "stylus") {
|
|
2230
|
+
throw new Error(`Unable to compile ${filePath}: Stylus styleUrl preprocessing is async-only. Import the Stylus file from a bundled entrypoint or use SCSS/CSS for Angular styleUrl.`);
|
|
2231
|
+
}
|
|
2232
|
+
return rawContents;
|
|
2233
|
+
}, getCssOutputExtension = (filePath) => isPreprocessableStylePath(filePath) ? ".css" : extname(filePath);
|
|
2820
2234
|
var init_stylePreprocessor = __esm(() => {
|
|
2235
|
+
CSS_EXTENSION_PATTERN = /\.css$/i;
|
|
2821
2236
|
STYLE_EXTENSION_PATTERN = /\.(s[ac]ss|less|styl(?:us)?)$/i;
|
|
2822
2237
|
STYLE_MODULE_EXTENSION_PATTERN = /\.module\.(s[ac]ss|less|styl(?:us)?)$/i;
|
|
2823
2238
|
STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less|styl(?:us)?)$/i;
|
|
@@ -3135,9 +2550,777 @@ var init_renderIslandMarkup = __esm(() => {
|
|
|
3135
2550
|
resolvedServerBuildComponentCache = new Map;
|
|
3136
2551
|
});
|
|
3137
2552
|
|
|
3138
|
-
// src/
|
|
3139
|
-
|
|
2553
|
+
// src/core/streamingSlotRegistrar.ts
|
|
2554
|
+
var STREAMING_SLOT_REGISTRAR_KEY = Symbol.for("absolutejs.streamingSlotRegistrar");
|
|
2555
|
+
var STREAMING_SLOT_WARNING_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotWarningController");
|
|
2556
|
+
var STREAMING_SLOT_COLLECTION_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotCollectionController");
|
|
2557
|
+
var getRegisteredStreamingSlotRegistrar = () => {
|
|
2558
|
+
const value = Reflect.get(globalThis, STREAMING_SLOT_REGISTRAR_KEY);
|
|
2559
|
+
if (typeof value === "function" || value === null) {
|
|
2560
|
+
return value;
|
|
2561
|
+
}
|
|
2562
|
+
return;
|
|
2563
|
+
};
|
|
2564
|
+
var isObjectRecord = (value) => Boolean(value) && typeof value === "object";
|
|
2565
|
+
var isStreamingSlotWarningController = (value) => isObjectRecord(value) && ("maybeWarn" in value) && typeof value.maybeWarn === "function";
|
|
2566
|
+
var isStreamingSlotCollectionController = (value) => isObjectRecord(value) && ("isCollecting" in value) && typeof value.isCollecting === "function";
|
|
2567
|
+
var getWarningController = () => {
|
|
2568
|
+
const value = Reflect.get(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY);
|
|
2569
|
+
if (value === null || typeof value === "undefined")
|
|
2570
|
+
return;
|
|
2571
|
+
return isStreamingSlotWarningController(value) ? value : undefined;
|
|
2572
|
+
};
|
|
2573
|
+
var getCollectionController = () => {
|
|
2574
|
+
const value = Reflect.get(globalThis, STREAMING_SLOT_COLLECTION_STORAGE_KEY);
|
|
2575
|
+
if (value === null || typeof value === "undefined")
|
|
2576
|
+
return;
|
|
2577
|
+
return isStreamingSlotCollectionController(value) ? value : undefined;
|
|
2578
|
+
};
|
|
2579
|
+
var hasRegisteredStreamingSlotRegistrar = () => typeof getRegisteredStreamingSlotRegistrar() === "function";
|
|
2580
|
+
var isStreamingSlotCollectionActive = () => getCollectionController()?.isCollecting() === true;
|
|
2581
|
+
var registerStreamingSlot = (slot) => {
|
|
2582
|
+
getRegisteredStreamingSlotRegistrar()?.(slot);
|
|
2583
|
+
};
|
|
2584
|
+
var setStreamingSlotCollectionController = (controller) => {
|
|
2585
|
+
Reflect.set(globalThis, STREAMING_SLOT_COLLECTION_STORAGE_KEY, controller);
|
|
2586
|
+
};
|
|
2587
|
+
var setStreamingSlotRegistrar = (nextRegistrar) => {
|
|
2588
|
+
Reflect.set(globalThis, STREAMING_SLOT_REGISTRAR_KEY, nextRegistrar);
|
|
2589
|
+
};
|
|
2590
|
+
var setStreamingSlotWarningController = (controller) => {
|
|
2591
|
+
Reflect.set(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY, controller);
|
|
2592
|
+
};
|
|
2593
|
+
var warnMissingStreamingSlotCollector = (primitiveName) => {
|
|
2594
|
+
if (isStreamingSlotCollectionActive()) {
|
|
2595
|
+
return;
|
|
2596
|
+
}
|
|
2597
|
+
getWarningController()?.maybeWarn(primitiveName);
|
|
2598
|
+
};
|
|
2599
|
+
|
|
2600
|
+
// src/core/streamingSlotRegistry.ts
|
|
2601
|
+
var STREAMING_SLOT_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotAsyncLocalStorage");
|
|
2602
|
+
var isObjectRecord2 = (value) => Boolean(value) && typeof value === "object";
|
|
2603
|
+
var isAsyncLocalStorage = (value) => isObjectRecord2(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function";
|
|
2604
|
+
var getStorageGlobal = () => {
|
|
2605
|
+
const value = Reflect.get(globalThis, STREAMING_SLOT_STORAGE_KEY);
|
|
2606
|
+
if (value === null || typeof value === "undefined") {
|
|
2607
|
+
return value;
|
|
2608
|
+
}
|
|
2609
|
+
return isAsyncLocalStorage(value) ? value : undefined;
|
|
2610
|
+
};
|
|
2611
|
+
var isServerRuntime = () => typeof process !== "undefined" && typeof process.versions?.node === "string";
|
|
2612
|
+
var ensureAsyncLocalStorage = async () => {
|
|
2613
|
+
const storage = getStorageGlobal();
|
|
2614
|
+
if (typeof storage !== "undefined") {
|
|
2615
|
+
return storage;
|
|
2616
|
+
}
|
|
2617
|
+
if (!isServerRuntime()) {
|
|
2618
|
+
Reflect.set(globalThis, STREAMING_SLOT_STORAGE_KEY, null);
|
|
2619
|
+
return getStorageGlobal();
|
|
2620
|
+
}
|
|
2621
|
+
const mod = await import("async_hooks");
|
|
2622
|
+
Reflect.set(globalThis, STREAMING_SLOT_STORAGE_KEY, new mod.AsyncLocalStorage);
|
|
2623
|
+
return getStorageGlobal();
|
|
2624
|
+
};
|
|
2625
|
+
var getActiveSlotStore = () => {
|
|
2626
|
+
const storage = getStorageGlobal();
|
|
2627
|
+
if (!storage)
|
|
2628
|
+
return;
|
|
2629
|
+
return storage.getStore();
|
|
2630
|
+
};
|
|
2631
|
+
var registerStreamingSlot2 = (slot) => {
|
|
2632
|
+
const store = getActiveSlotStore();
|
|
2633
|
+
if (!store)
|
|
2634
|
+
return;
|
|
2635
|
+
store.set(slot.id, slot);
|
|
2636
|
+
};
|
|
2637
|
+
setStreamingSlotRegistrar(registerStreamingSlot2);
|
|
2638
|
+
setStreamingSlotCollectionController({
|
|
2639
|
+
isCollecting: () => getActiveSlotStore() !== undefined
|
|
2640
|
+
});
|
|
2641
|
+
var hasActiveStreamingSlotRegistry = () => getActiveSlotStore() !== undefined;
|
|
2642
|
+
var runWithStreamingSlotRegistry = async (task) => {
|
|
2643
|
+
const storage = await ensureAsyncLocalStorage();
|
|
2644
|
+
if (!storage) {
|
|
2645
|
+
const slots = [];
|
|
2646
|
+
return {
|
|
2647
|
+
result: await task(),
|
|
2648
|
+
slots
|
|
2649
|
+
};
|
|
2650
|
+
}
|
|
2651
|
+
return storage.run(new Map, async () => {
|
|
2652
|
+
const result = await task();
|
|
2653
|
+
const store = storage.getStore();
|
|
2654
|
+
return {
|
|
2655
|
+
result,
|
|
2656
|
+
slots: store ? [...store.values()] : []
|
|
2657
|
+
};
|
|
2658
|
+
});
|
|
2659
|
+
};
|
|
3140
2660
|
|
|
2661
|
+
// src/core/islandPageContext.ts
|
|
2662
|
+
init_constants();
|
|
2663
|
+
var BOOTSTRAP_MANIFEST_KEY = "BootstrapClient";
|
|
2664
|
+
var ISLAND_MARKER = 'data-island="true"';
|
|
2665
|
+
var MANIFEST_MARKER = "__ABSOLUTE_MANIFEST__";
|
|
2666
|
+
var ISLAND_STATE_MARKER = "__ABS_ISLAND_STATE__";
|
|
2667
|
+
var CLOSING_HEAD_TAG = "</head>";
|
|
2668
|
+
var buildIslandsHeadMarkup = (manifest) => {
|
|
2669
|
+
const manifestScript = `<script>window.__ABSOLUTE_MANIFEST__ = ${JSON.stringify(manifest)}</script>`;
|
|
2670
|
+
const islandStateScript = `<script>window.__ABS_ISLAND_STATE__ = ${JSON.stringify(globalThis.__ABS_ISLAND_STATE__ ?? {})}</script>`;
|
|
2671
|
+
const bootstrapPath = manifest[BOOTSTRAP_MANIFEST_KEY];
|
|
2672
|
+
const bootstrapScript = bootstrapPath ? `<script type="module" src="${bootstrapPath}"></script>` : "";
|
|
2673
|
+
return `${manifestScript}${islandStateScript}${bootstrapScript}`;
|
|
2674
|
+
};
|
|
2675
|
+
var injectHeadMarkup = (html, markup) => {
|
|
2676
|
+
const closingHeadIndex = html.indexOf("</head>");
|
|
2677
|
+
if (closingHeadIndex >= 0) {
|
|
2678
|
+
return `${html.slice(0, closingHeadIndex)}${markup}${html.slice(closingHeadIndex)}`;
|
|
2679
|
+
}
|
|
2680
|
+
const openingBodyIndex = html.indexOf("<body");
|
|
2681
|
+
if (openingBodyIndex >= 0) {
|
|
2682
|
+
const bodyStart = html.indexOf(">", openingBodyIndex);
|
|
2683
|
+
if (bodyStart >= 0) {
|
|
2684
|
+
return `${html.slice(0, openingBodyIndex)}<head>${markup}</head>${html.slice(openingBodyIndex)}`;
|
|
2685
|
+
}
|
|
2686
|
+
}
|
|
2687
|
+
return `<!DOCTYPE html><html><head>${markup}</head><body>${html}</body></html>`;
|
|
2688
|
+
};
|
|
2689
|
+
var streamChunkToString = (value, decoder) => typeof value === "string" ? value : decoder.decode(value, { stream: true });
|
|
2690
|
+
var flushSafePendingText = (controller, encoder, pending, lookbehind) => {
|
|
2691
|
+
if (pending.length <= lookbehind) {
|
|
2692
|
+
return pending;
|
|
2693
|
+
}
|
|
2694
|
+
const safeText = pending.slice(0, pending.length - lookbehind);
|
|
2695
|
+
controller.enqueue(encoder.encode(safeText));
|
|
2696
|
+
return pending.slice(-lookbehind);
|
|
2697
|
+
};
|
|
2698
|
+
var updateInjectedState = (consumed, injected, pending) => {
|
|
2699
|
+
if (consumed.done) {
|
|
2700
|
+
return { done: true, injected, pending };
|
|
2701
|
+
}
|
|
2702
|
+
return {
|
|
2703
|
+
done: false,
|
|
2704
|
+
injected: consumed.injected,
|
|
2705
|
+
pending: consumed.pending
|
|
2706
|
+
};
|
|
2707
|
+
};
|
|
2708
|
+
var readStreamChunk = async (reader) => {
|
|
2709
|
+
const { done, value } = await reader.read();
|
|
2710
|
+
if (done || !value) {
|
|
2711
|
+
return { done, value: undefined };
|
|
2712
|
+
}
|
|
2713
|
+
return { done, value };
|
|
2714
|
+
};
|
|
2715
|
+
var pipeStreamWithHeadInjection = (stream, markup) => {
|
|
2716
|
+
const encoder = new TextEncoder;
|
|
2717
|
+
const decoder = new TextDecoder;
|
|
2718
|
+
const lookbehind = CLOSING_HEAD_TAG.length - 1;
|
|
2719
|
+
const processPending = (controller, pending, injected) => {
|
|
2720
|
+
if (injected) {
|
|
2721
|
+
controller.enqueue(encoder.encode(pending));
|
|
2722
|
+
return { injected, pending: "" };
|
|
2723
|
+
}
|
|
2724
|
+
const headIndex = pending.indexOf(CLOSING_HEAD_TAG);
|
|
2725
|
+
if (headIndex >= 0) {
|
|
2726
|
+
const next = `${pending.slice(0, headIndex)}${markup}${pending.slice(headIndex)}`;
|
|
2727
|
+
controller.enqueue(encoder.encode(next));
|
|
2728
|
+
return { injected: true, pending: "" };
|
|
2729
|
+
}
|
|
2730
|
+
return {
|
|
2731
|
+
injected,
|
|
2732
|
+
pending: flushSafePendingText(controller, encoder, pending, lookbehind)
|
|
2733
|
+
};
|
|
2734
|
+
};
|
|
2735
|
+
const finishHeadInjectionStream = (controller, pending, injected) => {
|
|
2736
|
+
let finalPending = pending + decoder.decode();
|
|
2737
|
+
if (!injected) {
|
|
2738
|
+
finalPending = injectHeadMarkup(finalPending, markup);
|
|
2739
|
+
}
|
|
2740
|
+
if (finalPending.length > 0) {
|
|
2741
|
+
controller.enqueue(encoder.encode(finalPending));
|
|
2742
|
+
}
|
|
2743
|
+
controller.close();
|
|
2744
|
+
};
|
|
2745
|
+
const consumeHeadChunk = async (controller, reader, pending, injected) => {
|
|
2746
|
+
const { done, value } = await readStreamChunk(reader);
|
|
2747
|
+
if (done || !value) {
|
|
2748
|
+
return { done, injected, pending };
|
|
2749
|
+
}
|
|
2750
|
+
const processed = processPending(controller, pending + streamChunkToString(value, decoder), injected);
|
|
2751
|
+
return {
|
|
2752
|
+
done,
|
|
2753
|
+
injected: processed.injected,
|
|
2754
|
+
pending: processed.pending
|
|
2755
|
+
};
|
|
2756
|
+
};
|
|
2757
|
+
const runHeadInjectionLoop = async (controller, reader) => {
|
|
2758
|
+
const consumeNextHeadChunk = async (injected, pending) => {
|
|
2759
|
+
const consumed = await consumeHeadChunk(controller, reader, pending, injected);
|
|
2760
|
+
const nextState = updateInjectedState(consumed, injected, pending);
|
|
2761
|
+
if (nextState.done) {
|
|
2762
|
+
return { injected, pending };
|
|
2763
|
+
}
|
|
2764
|
+
return consumeNextHeadChunk(nextState.injected, nextState.pending);
|
|
2765
|
+
};
|
|
2766
|
+
return consumeNextHeadChunk(false, "");
|
|
2767
|
+
};
|
|
2768
|
+
return new ReadableStream({
|
|
2769
|
+
async start(controller) {
|
|
2770
|
+
const reader = stream.getReader();
|
|
2771
|
+
try {
|
|
2772
|
+
const { injected, pending } = await runHeadInjectionLoop(controller, reader);
|
|
2773
|
+
finishHeadInjectionStream(controller, pending, injected);
|
|
2774
|
+
} catch (error) {
|
|
2775
|
+
controller.error(error);
|
|
2776
|
+
}
|
|
2777
|
+
}
|
|
2778
|
+
});
|
|
2779
|
+
};
|
|
2780
|
+
var pipeStreamWithIslandMarkerDetection = (stream, markup) => {
|
|
2781
|
+
const encoder = new TextEncoder;
|
|
2782
|
+
const decoder = new TextDecoder;
|
|
2783
|
+
const lookbehind = Math.max(ISLAND_MARKER.length, BYTES_PER_KILOBYTE);
|
|
2784
|
+
const processPending = (controller, pending, injected) => {
|
|
2785
|
+
if (injected) {
|
|
2786
|
+
controller.enqueue(encoder.encode(pending));
|
|
2787
|
+
return { injected, pending: "" };
|
|
2788
|
+
}
|
|
2789
|
+
const markerIndex = pending.indexOf(ISLAND_MARKER);
|
|
2790
|
+
if (markerIndex >= 0) {
|
|
2791
|
+
const tagStart = pending.lastIndexOf("<", markerIndex);
|
|
2792
|
+
const injectAt = tagStart >= 0 ? tagStart : markerIndex;
|
|
2793
|
+
const next = `${pending.slice(0, injectAt)}${markup}${pending.slice(injectAt)}`;
|
|
2794
|
+
controller.enqueue(encoder.encode(next));
|
|
2795
|
+
return { injected: true, pending: "" };
|
|
2796
|
+
}
|
|
2797
|
+
return {
|
|
2798
|
+
injected,
|
|
2799
|
+
pending: flushSafePendingText(controller, encoder, pending, lookbehind)
|
|
2800
|
+
};
|
|
2801
|
+
};
|
|
2802
|
+
const finishIslandMarkerStream = (controller, pending) => {
|
|
2803
|
+
const finalPending = pending + decoder.decode();
|
|
2804
|
+
if (finalPending.length > 0) {
|
|
2805
|
+
controller.enqueue(encoder.encode(finalPending));
|
|
2806
|
+
}
|
|
2807
|
+
controller.close();
|
|
2808
|
+
};
|
|
2809
|
+
const consumeIslandChunk = async (controller, reader, pending, injected) => {
|
|
2810
|
+
const { done, value } = await readStreamChunk(reader);
|
|
2811
|
+
if (done || !value) {
|
|
2812
|
+
return { done, injected, pending };
|
|
2813
|
+
}
|
|
2814
|
+
const processed = processPending(controller, pending + streamChunkToString(value, decoder), injected);
|
|
2815
|
+
return {
|
|
2816
|
+
done,
|
|
2817
|
+
injected: processed.injected,
|
|
2818
|
+
pending: processed.pending
|
|
2819
|
+
};
|
|
2820
|
+
};
|
|
2821
|
+
const runIslandMarkerLoop = async (controller, reader) => {
|
|
2822
|
+
const consumeNextIslandChunk = async (injected, pending) => {
|
|
2823
|
+
const consumed = await consumeIslandChunk(controller, reader, pending, injected);
|
|
2824
|
+
const nextState = updateInjectedState(consumed, injected, pending);
|
|
2825
|
+
if (nextState.done) {
|
|
2826
|
+
return { injected, pending };
|
|
2827
|
+
}
|
|
2828
|
+
return consumeNextIslandChunk(nextState.injected, nextState.pending);
|
|
2829
|
+
};
|
|
2830
|
+
return consumeNextIslandChunk(false, "");
|
|
2831
|
+
};
|
|
2832
|
+
return new ReadableStream({
|
|
2833
|
+
async start(controller) {
|
|
2834
|
+
const reader = stream.getReader();
|
|
2835
|
+
try {
|
|
2836
|
+
const { pending } = await runIslandMarkerLoop(controller, reader);
|
|
2837
|
+
finishIslandMarkerStream(controller, pending);
|
|
2838
|
+
} catch (error) {
|
|
2839
|
+
controller.error(error);
|
|
2840
|
+
}
|
|
2841
|
+
}
|
|
2842
|
+
});
|
|
2843
|
+
};
|
|
2844
|
+
var htmlContainsIslands = (html) => html.includes(ISLAND_MARKER);
|
|
2845
|
+
var injectIslandPageContext = (html, options) => {
|
|
2846
|
+
const manifest = globalThis.__absoluteManifest;
|
|
2847
|
+
const hasIslands = options?.hasIslands ?? htmlContainsIslands(html);
|
|
2848
|
+
if (!manifest || !hasIslands) {
|
|
2849
|
+
return html;
|
|
2850
|
+
}
|
|
2851
|
+
if (html.includes(MANIFEST_MARKER) || html.includes(ISLAND_STATE_MARKER)) {
|
|
2852
|
+
return html;
|
|
2853
|
+
}
|
|
2854
|
+
return injectHeadMarkup(html, buildIslandsHeadMarkup(manifest));
|
|
2855
|
+
};
|
|
2856
|
+
var injectIslandPageContextStream = (stream, options) => {
|
|
2857
|
+
const manifest = globalThis.__absoluteManifest;
|
|
2858
|
+
if (!manifest)
|
|
2859
|
+
return stream;
|
|
2860
|
+
const markup = buildIslandsHeadMarkup(manifest);
|
|
2861
|
+
if (options?.hasIslands === true) {
|
|
2862
|
+
return pipeStreamWithHeadInjection(stream, markup);
|
|
2863
|
+
}
|
|
2864
|
+
if (options?.hasIslands === false) {
|
|
2865
|
+
return stream;
|
|
2866
|
+
}
|
|
2867
|
+
return pipeStreamWithIslandMarkerDetection(stream, markup);
|
|
2868
|
+
};
|
|
2869
|
+
var setCurrentIslandManifest = (manifest) => {
|
|
2870
|
+
globalThis.__absoluteManifest = manifest;
|
|
2871
|
+
};
|
|
2872
|
+
|
|
2873
|
+
// src/react/pageHandler.ts
|
|
2874
|
+
init_devRouteRegistrationCallsite();
|
|
2875
|
+
|
|
2876
|
+
// src/core/responseEnhancers.ts
|
|
2877
|
+
init_streamingSlots();
|
|
2878
|
+
var toResponse = async (responseLike) => responseLike;
|
|
2879
|
+
var cloneHeaders = (response) => {
|
|
2880
|
+
const headers = new Headers(response.headers);
|
|
2881
|
+
return headers;
|
|
2882
|
+
};
|
|
2883
|
+
var enhanceHtmlResponseWithStreamingSlots = (response, {
|
|
2884
|
+
nonce,
|
|
2885
|
+
onError,
|
|
2886
|
+
runtimePlacement,
|
|
2887
|
+
runtimePreludeScript,
|
|
2888
|
+
streamingSlots = [],
|
|
2889
|
+
policy
|
|
2890
|
+
} = {}) => {
|
|
2891
|
+
if (!response.body || streamingSlots.length === 0) {
|
|
2892
|
+
return response;
|
|
2893
|
+
}
|
|
2894
|
+
const body = appendStreamingSlotPatchesToStream(response.body, streamingSlots, {
|
|
2895
|
+
nonce,
|
|
2896
|
+
onError,
|
|
2897
|
+
policy,
|
|
2898
|
+
runtimePlacement,
|
|
2899
|
+
runtimePreludeScript
|
|
2900
|
+
});
|
|
2901
|
+
return new Response(body, {
|
|
2902
|
+
headers: cloneHeaders(response),
|
|
2903
|
+
status: response.status,
|
|
2904
|
+
statusText: response.statusText
|
|
2905
|
+
});
|
|
2906
|
+
};
|
|
2907
|
+
var withStreamingSlots = async (responseLike, options = {}) => enhanceHtmlResponseWithStreamingSlots(await toResponse(responseLike), options);
|
|
2908
|
+
var mergeStreamingSlots = (registered, explicit) => {
|
|
2909
|
+
const merged = new Map;
|
|
2910
|
+
for (const slot of registered)
|
|
2911
|
+
merged.set(slot.id, slot);
|
|
2912
|
+
for (const slot of explicit)
|
|
2913
|
+
merged.set(slot.id, slot);
|
|
2914
|
+
return [...merged.values()];
|
|
2915
|
+
};
|
|
2916
|
+
var withRegisteredStreamingSlots = async (renderResponse, options = {}) => {
|
|
2917
|
+
const { result, slots } = await runWithStreamingSlotRegistry(renderResponse);
|
|
2918
|
+
const explicit = options.streamingSlots ?? [];
|
|
2919
|
+
return withStreamingSlots(result, {
|
|
2920
|
+
...options,
|
|
2921
|
+
streamingSlots: mergeStreamingSlots(slots, explicit)
|
|
2922
|
+
});
|
|
2923
|
+
};
|
|
2924
|
+
|
|
2925
|
+
// src/core/streamingSlotWarningScope.ts
|
|
2926
|
+
init_logger();
|
|
2927
|
+
import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
|
|
2928
|
+
var STREAMING_SLOT_WARNING_STORAGE_KEY2 = Symbol.for("absolutejs.streamingSlotWarningAsyncLocalStorage");
|
|
2929
|
+
var isObjectRecord4 = (value) => Boolean(value) && typeof value === "object";
|
|
2930
|
+
var isAsyncLocalStorage3 = (value) => isObjectRecord4(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function";
|
|
2931
|
+
var getWarningStorage = () => {
|
|
2932
|
+
const value = Reflect.get(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY2);
|
|
2933
|
+
if (value === null || typeof value === "undefined") {
|
|
2934
|
+
return;
|
|
2935
|
+
}
|
|
2936
|
+
return isAsyncLocalStorage3(value) ? value : undefined;
|
|
2937
|
+
};
|
|
2938
|
+
var ensureWarningStorage = () => {
|
|
2939
|
+
const existing = getWarningStorage();
|
|
2940
|
+
if (existing) {
|
|
2941
|
+
return existing;
|
|
2942
|
+
}
|
|
2943
|
+
const storage = new AsyncLocalStorage2;
|
|
2944
|
+
Reflect.set(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY2, storage);
|
|
2945
|
+
return storage;
|
|
2946
|
+
};
|
|
2947
|
+
var normalizeCallsitePath2 = (value) => value.replace(`${process.cwd()}/`, "").replace(process.cwd(), "").replace(/^\.\/+/, "");
|
|
2948
|
+
var formatWarningCallsite = (callsite) => {
|
|
2949
|
+
const match = callsite.match(/^(.*?)(:\d+:\d+)$/);
|
|
2950
|
+
if (!match) {
|
|
2951
|
+
return `\x1B[36m${callsite}\x1B[0m`;
|
|
2952
|
+
}
|
|
2953
|
+
return `\x1B[36m${match[1]}\x1B[33m${match[2]}\x1B[0m`;
|
|
2954
|
+
};
|
|
2955
|
+
var extractCallsiteFromStack = (stack) => {
|
|
2956
|
+
const frames = stack.split(`
|
|
2957
|
+
`).slice(1).map((line) => line.trim());
|
|
2958
|
+
for (const frame of frames) {
|
|
2959
|
+
if (frame.includes("/node_modules/") || frame.includes("/dist/") || frame.includes("/src/react/pageHandler.") || frame.includes("/src/vue/pageHandler.") || frame.includes("/src/svelte/pageHandler.") || frame.includes("/src/angular/pageHandler.") || frame.includes("/src/core/streamingSlotWarningScope.")) {
|
|
2960
|
+
continue;
|
|
2961
|
+
}
|
|
2962
|
+
const locationMatch = frame.match(/\((\/[^)]+:\d+:\d+)\)$/) ?? frame.match(/at (\/[^ ]+:\d+:\d+)$/);
|
|
2963
|
+
if (locationMatch?.[1]) {
|
|
2964
|
+
return normalizeCallsitePath2(locationMatch[1]);
|
|
2965
|
+
}
|
|
2966
|
+
}
|
|
2967
|
+
return;
|
|
2968
|
+
};
|
|
2969
|
+
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)}.` : ""}`;
|
|
2970
|
+
setStreamingSlotWarningController({
|
|
2971
|
+
maybeWarn: (primitiveName) => {
|
|
2972
|
+
const store = getWarningStorage()?.getStore();
|
|
2973
|
+
if (!store || store.hasWarned) {
|
|
2974
|
+
return;
|
|
2975
|
+
}
|
|
2976
|
+
store.hasWarned = true;
|
|
2977
|
+
logWarn(buildMissingCollectorWarning(primitiveName, store.handlerCallsite));
|
|
2978
|
+
}
|
|
2979
|
+
});
|
|
2980
|
+
var captureStreamingSlotWarningCallsite = () => {
|
|
2981
|
+
if (false) {}
|
|
2982
|
+
const { stack } = new Error;
|
|
2983
|
+
if (!stack) {
|
|
2984
|
+
return;
|
|
2985
|
+
}
|
|
2986
|
+
return extractCallsiteFromStack(stack);
|
|
2987
|
+
};
|
|
2988
|
+
var runWithStreamingSlotWarningScope = (task, metadata) => ensureWarningStorage().run({ handlerCallsite: metadata?.handlerCallsite, hasWarned: false }, task);
|
|
2989
|
+
|
|
2990
|
+
// src/react/pageHandler.ts
|
|
2991
|
+
init_ssrCache();
|
|
2992
|
+
|
|
2993
|
+
// src/utils/ssrErrorPage.ts
|
|
2994
|
+
var ssrErrorPage = (framework, error) => {
|
|
2995
|
+
const frameworkColors2 = {
|
|
2996
|
+
angular: "#dd0031",
|
|
2997
|
+
html: "#e34c26",
|
|
2998
|
+
htmx: "#1a365d",
|
|
2999
|
+
react: "#61dafb",
|
|
3000
|
+
svelte: "#ff3e00",
|
|
3001
|
+
vue: "#42b883"
|
|
3002
|
+
};
|
|
3003
|
+
const accent = frameworkColors2[framework] ?? "#94a3b8";
|
|
3004
|
+
const label = framework.charAt(0).toUpperCase() + framework.slice(1);
|
|
3005
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
3006
|
+
return `<!DOCTYPE html>
|
|
3007
|
+
<html>
|
|
3008
|
+
<head>
|
|
3009
|
+
<meta charset="utf-8">
|
|
3010
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
3011
|
+
<title>SSR Error - AbsoluteJS</title>
|
|
3012
|
+
<style>
|
|
3013
|
+
*{margin:0;padding:0;box-sizing:border-box}
|
|
3014
|
+
body{min-height:100vh;background:linear-gradient(135deg,rgba(15,23,42,0.98) 0%,rgba(30,41,59,0.98) 100%);color:#e2e8f0;font-family:"JetBrains Mono","Fira Code",ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;font-size:14px;line-height:1.6;display:flex;align-items:flex-start;justify-content:center;padding:32px}
|
|
3015
|
+
.card{max-width:720px;width:100%;background:rgba(30,41,59,0.6);border:1px solid rgba(71,85,105,0.5);border-radius:16px;box-shadow:0 25px 50px -12px rgba(0,0,0,0.5),0 0 0 1px rgba(255,255,255,0.05);overflow:hidden}
|
|
3016
|
+
.header{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:20px 24px;background:rgba(15,23,42,0.5);border-bottom:1px solid rgba(71,85,105,0.4)}
|
|
3017
|
+
.brand{font-weight:700;font-size:20px;color:#fff;letter-spacing:-0.02em}
|
|
3018
|
+
.badge{padding:5px 10px;border-radius:8px;font-size:12px;font-weight:600;background:${accent};color:#fff;opacity:0.95;box-shadow:0 2px 4px rgba(0,0,0,0.2)}
|
|
3019
|
+
.kind{color:#94a3b8;font-size:13px;font-weight:500}
|
|
3020
|
+
.content{padding:24px}
|
|
3021
|
+
.label{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:0.08em;color:#94a3b8;margin-bottom:8px}
|
|
3022
|
+
.message{margin:0;padding:16px 20px;background:rgba(239,68,68,0.12);border:1px solid rgba(239,68,68,0.25);border-radius:10px;overflow-x:auto;white-space:pre-wrap;word-break:break-word;color:#fca5a5;font-size:13px;line-height:1.5}
|
|
3023
|
+
.hint{margin-top:20px;padding:12px 20px;background:rgba(71,85,105,0.3);border-radius:10px;border:1px solid rgba(71,85,105,0.4);color:#cbd5e1;font-size:13px}
|
|
3024
|
+
</style>
|
|
3025
|
+
</head>
|
|
3026
|
+
<body>
|
|
3027
|
+
<div class="card">
|
|
3028
|
+
<div class="header">
|
|
3029
|
+
<div style="display:flex;align-items:center;gap:12px">
|
|
3030
|
+
<span class="brand">AbsoluteJS</span>
|
|
3031
|
+
<span class="badge">${label}</span>
|
|
3032
|
+
</div>
|
|
3033
|
+
<span class="kind">Server Render Error</span>
|
|
3034
|
+
</div>
|
|
3035
|
+
<div class="content">
|
|
3036
|
+
<div class="label">What went wrong</div>
|
|
3037
|
+
<pre class="message">${message.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")}</pre>
|
|
3038
|
+
<div class="hint">A component threw during server-side rendering. Check the terminal for the full stack trace.</div>
|
|
3039
|
+
</div>
|
|
3040
|
+
</div>
|
|
3041
|
+
</body>
|
|
3042
|
+
</html>`;
|
|
3043
|
+
};
|
|
3044
|
+
|
|
3045
|
+
// src/utils/resolveConvention.ts
|
|
3046
|
+
import { basename } from "path";
|
|
3047
|
+
var CONVENTIONS_KEY = "__absoluteConventions";
|
|
3048
|
+
var isConventionsMap = (value) => Boolean(value) && typeof value === "object";
|
|
3049
|
+
var getMap = () => {
|
|
3050
|
+
const value = Reflect.get(globalThis, CONVENTIONS_KEY);
|
|
3051
|
+
if (isConventionsMap(value))
|
|
3052
|
+
return value;
|
|
3053
|
+
const empty = {};
|
|
3054
|
+
return empty;
|
|
3055
|
+
};
|
|
3056
|
+
var derivePageName = (pagePath) => {
|
|
3057
|
+
const base = basename(pagePath);
|
|
3058
|
+
const dotIndex = base.indexOf(".");
|
|
3059
|
+
const name = dotIndex > 0 ? base.slice(0, dotIndex) : base;
|
|
3060
|
+
return toPascal(name);
|
|
3061
|
+
};
|
|
3062
|
+
var resolveErrorConventionPath = (framework, pageName) => {
|
|
3063
|
+
const conventions = getMap()[framework];
|
|
3064
|
+
if (!conventions)
|
|
3065
|
+
return;
|
|
3066
|
+
return conventions.pages?.[pageName]?.error ?? conventions.defaults?.error;
|
|
3067
|
+
};
|
|
3068
|
+
var resolveNotFoundConventionPath = (framework) => getMap()[framework]?.defaults?.notFound;
|
|
3069
|
+
var setConventions = (map) => {
|
|
3070
|
+
Reflect.set(globalThis, CONVENTIONS_KEY, map);
|
|
3071
|
+
};
|
|
3072
|
+
var isDev = () => true;
|
|
3073
|
+
var buildErrorProps = (error) => {
|
|
3074
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
3075
|
+
const stack = isDev() && error instanceof Error ? error.stack : undefined;
|
|
3076
|
+
return { error: { message, stack } };
|
|
3077
|
+
};
|
|
3078
|
+
var renderReactError = async (conventionPath, errorProps) => {
|
|
3079
|
+
const { createElement } = await import("react");
|
|
3080
|
+
const { renderToReadableStream } = await import("react-dom/server");
|
|
3081
|
+
const mod = await import(conventionPath);
|
|
3082
|
+
const [firstKey] = Object.keys(mod);
|
|
3083
|
+
const ErrorComponent = mod.default ?? (firstKey ? mod[firstKey] : undefined);
|
|
3084
|
+
const element = createElement(ErrorComponent, errorProps);
|
|
3085
|
+
const stream = await renderToReadableStream(element);
|
|
3086
|
+
return new Response(stream, {
|
|
3087
|
+
headers: { "Content-Type": "text/html" },
|
|
3088
|
+
status: 500
|
|
3089
|
+
});
|
|
3090
|
+
};
|
|
3091
|
+
var renderSvelteError = async (conventionPath, errorProps) => {
|
|
3092
|
+
const { render } = await import("svelte/server");
|
|
3093
|
+
const mod = await import(conventionPath);
|
|
3094
|
+
const ErrorComponent = mod.default;
|
|
3095
|
+
const { head, body } = render(ErrorComponent, {
|
|
3096
|
+
props: errorProps
|
|
3097
|
+
});
|
|
3098
|
+
const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
|
|
3099
|
+
return new Response(html, {
|
|
3100
|
+
headers: { "Content-Type": "text/html" },
|
|
3101
|
+
status: 500
|
|
3102
|
+
});
|
|
3103
|
+
};
|
|
3104
|
+
var unescapeVueStyles = (ssrBody) => {
|
|
3105
|
+
let styles = "";
|
|
3106
|
+
const body = ssrBody.replace(/<style>([\s\S]*?)<\/style>/g, (_, css) => {
|
|
3107
|
+
styles += `<style>${css.replace(/"/g, '"').replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")}</style>`;
|
|
3108
|
+
return "";
|
|
3109
|
+
});
|
|
3110
|
+
return { body, styles };
|
|
3111
|
+
};
|
|
3112
|
+
var renderVueError = async (conventionPath, errorProps) => {
|
|
3113
|
+
const { createSSRApp, h } = await import("vue");
|
|
3114
|
+
const { renderToString } = await import("vue/server-renderer");
|
|
3115
|
+
const mod = await import(conventionPath);
|
|
3116
|
+
const ErrorComponent = mod.default;
|
|
3117
|
+
const app = createSSRApp({
|
|
3118
|
+
render: () => h(ErrorComponent, errorProps)
|
|
3119
|
+
});
|
|
3120
|
+
const rawBody = await renderToString(app);
|
|
3121
|
+
const { styles, body } = unescapeVueStyles(rawBody);
|
|
3122
|
+
const html = `<!DOCTYPE html><html><head>${styles}</head><body><div id="root">${body}</div></body></html>`;
|
|
3123
|
+
return new Response(html, {
|
|
3124
|
+
headers: { "Content-Type": "text/html" },
|
|
3125
|
+
status: 500
|
|
3126
|
+
});
|
|
3127
|
+
};
|
|
3128
|
+
var renderAngularError = async (conventionPath, errorProps) => {
|
|
3129
|
+
const mod = await import(conventionPath);
|
|
3130
|
+
const renderError = mod.default ?? mod.renderError;
|
|
3131
|
+
if (typeof renderError !== "function")
|
|
3132
|
+
return null;
|
|
3133
|
+
const html = renderError(errorProps);
|
|
3134
|
+
return new Response(html, {
|
|
3135
|
+
headers: { "Content-Type": "text/html" },
|
|
3136
|
+
status: 500
|
|
3137
|
+
});
|
|
3138
|
+
};
|
|
3139
|
+
var logConventionRenderError = (framework, label, renderError) => {
|
|
3140
|
+
const message = renderError instanceof Error ? renderError.message : "";
|
|
3141
|
+
if (message.includes("Cannot find module") || message.includes("Cannot find package") || message.includes("not found in module")) {
|
|
3142
|
+
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}).`);
|
|
3143
|
+
return;
|
|
3144
|
+
}
|
|
3145
|
+
console.error(`[SSR] Failed to render ${framework} convention ${label} page:`, renderError);
|
|
3146
|
+
};
|
|
3147
|
+
var ERROR_RENDERERS = {
|
|
3148
|
+
angular: renderAngularError,
|
|
3149
|
+
react: renderReactError,
|
|
3150
|
+
svelte: renderSvelteError,
|
|
3151
|
+
vue: renderVueError
|
|
3152
|
+
};
|
|
3153
|
+
var renderConventionError = async (framework, pageName, error) => {
|
|
3154
|
+
const conventionPath = resolveErrorConventionPath(framework, pageName);
|
|
3155
|
+
if (!conventionPath)
|
|
3156
|
+
return null;
|
|
3157
|
+
const errorProps = buildErrorProps(error);
|
|
3158
|
+
const renderer = ERROR_RENDERERS[framework];
|
|
3159
|
+
if (!renderer)
|
|
3160
|
+
return null;
|
|
3161
|
+
try {
|
|
3162
|
+
return await renderer(conventionPath, errorProps);
|
|
3163
|
+
} catch (renderError) {
|
|
3164
|
+
logConventionRenderError(framework, "error", renderError);
|
|
3165
|
+
}
|
|
3166
|
+
return null;
|
|
3167
|
+
};
|
|
3168
|
+
var renderReactNotFound = async (conventionPath) => {
|
|
3169
|
+
const { createElement } = await import("react");
|
|
3170
|
+
const { renderToReadableStream } = await import("react-dom/server");
|
|
3171
|
+
const mod = await import(conventionPath);
|
|
3172
|
+
const [nfKey] = Object.keys(mod);
|
|
3173
|
+
const NotFoundComponent = mod.default ?? (nfKey ? mod[nfKey] : undefined);
|
|
3174
|
+
const element = createElement(NotFoundComponent);
|
|
3175
|
+
const stream = await renderToReadableStream(element);
|
|
3176
|
+
return new Response(stream, {
|
|
3177
|
+
headers: { "Content-Type": "text/html" },
|
|
3178
|
+
status: 404
|
|
3179
|
+
});
|
|
3180
|
+
};
|
|
3181
|
+
var renderSvelteNotFound = async (conventionPath) => {
|
|
3182
|
+
const { render } = await import("svelte/server");
|
|
3183
|
+
const mod = await import(conventionPath);
|
|
3184
|
+
const NotFoundComponent = mod.default;
|
|
3185
|
+
const { head, body } = render(NotFoundComponent);
|
|
3186
|
+
const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
|
|
3187
|
+
return new Response(html, {
|
|
3188
|
+
headers: { "Content-Type": "text/html" },
|
|
3189
|
+
status: 404
|
|
3190
|
+
});
|
|
3191
|
+
};
|
|
3192
|
+
var renderVueNotFound = async (conventionPath) => {
|
|
3193
|
+
const { createSSRApp, h } = await import("vue");
|
|
3194
|
+
const { renderToString } = await import("vue/server-renderer");
|
|
3195
|
+
const mod = await import(conventionPath);
|
|
3196
|
+
const NotFoundComponent = mod.default;
|
|
3197
|
+
const app = createSSRApp({
|
|
3198
|
+
render: () => h(NotFoundComponent)
|
|
3199
|
+
});
|
|
3200
|
+
const rawBody = await renderToString(app);
|
|
3201
|
+
const { styles, body } = unescapeVueStyles(rawBody);
|
|
3202
|
+
const html = `<!DOCTYPE html><html><head>${styles}</head><body><div id="root">${body}</div></body></html>`;
|
|
3203
|
+
return new Response(html, {
|
|
3204
|
+
headers: { "Content-Type": "text/html" },
|
|
3205
|
+
status: 404
|
|
3206
|
+
});
|
|
3207
|
+
};
|
|
3208
|
+
var renderAngularNotFound = async (conventionPath) => {
|
|
3209
|
+
const mod = await import(conventionPath);
|
|
3210
|
+
const renderNotFound = mod.default ?? mod.renderNotFound;
|
|
3211
|
+
if (typeof renderNotFound !== "function")
|
|
3212
|
+
return null;
|
|
3213
|
+
const html = renderNotFound();
|
|
3214
|
+
return new Response(html, {
|
|
3215
|
+
headers: { "Content-Type": "text/html" },
|
|
3216
|
+
status: 404
|
|
3217
|
+
});
|
|
3218
|
+
};
|
|
3219
|
+
var NOT_FOUND_RENDERERS = {
|
|
3220
|
+
angular: renderAngularNotFound,
|
|
3221
|
+
react: renderReactNotFound,
|
|
3222
|
+
svelte: renderSvelteNotFound,
|
|
3223
|
+
vue: renderVueNotFound
|
|
3224
|
+
};
|
|
3225
|
+
var renderConventionNotFound = async (framework) => {
|
|
3226
|
+
const conventionPath = resolveNotFoundConventionPath(framework);
|
|
3227
|
+
if (!conventionPath)
|
|
3228
|
+
return null;
|
|
3229
|
+
const renderer = NOT_FOUND_RENDERERS[framework];
|
|
3230
|
+
if (!renderer)
|
|
3231
|
+
return null;
|
|
3232
|
+
try {
|
|
3233
|
+
return await renderer(conventionPath);
|
|
3234
|
+
} catch (renderError) {
|
|
3235
|
+
logConventionRenderError(framework, "not-found", renderError);
|
|
3236
|
+
}
|
|
3237
|
+
return null;
|
|
3238
|
+
};
|
|
3239
|
+
var NOT_FOUND_PRIORITY = [
|
|
3240
|
+
"react",
|
|
3241
|
+
"svelte",
|
|
3242
|
+
"vue",
|
|
3243
|
+
"angular"
|
|
3244
|
+
];
|
|
3245
|
+
var renderFirstNotFound = async () => {
|
|
3246
|
+
for (const framework of NOT_FOUND_PRIORITY) {
|
|
3247
|
+
if (!getMap()[framework]?.defaults?.notFound)
|
|
3248
|
+
continue;
|
|
3249
|
+
const response = await renderConventionNotFound(framework);
|
|
3250
|
+
if (response)
|
|
3251
|
+
return response;
|
|
3252
|
+
}
|
|
3253
|
+
return null;
|
|
3254
|
+
};
|
|
3255
|
+
|
|
3256
|
+
// src/react/pageHandler.ts
|
|
3257
|
+
var buildRefreshSetup = () => {
|
|
3258
|
+
if (false) {}
|
|
3259
|
+
return "window.__REFRESH_BUFFER__=[];" + "window.$RefreshReg$=function(t,i){window.__REFRESH_BUFFER__.push([t,i])};" + "window.$RefreshSig$=function(){return function(t){return t}};";
|
|
3260
|
+
};
|
|
3261
|
+
var buildDirtyResponse = (index, maybeProps) => {
|
|
3262
|
+
const propsScript = maybeProps ? `window.__INITIAL_PROPS__=${JSON.stringify(maybeProps)};` : "";
|
|
3263
|
+
const dirtyFlag = "window.__SSR_DIRTY__=true;";
|
|
3264
|
+
const refreshSetup = buildRefreshSetup();
|
|
3265
|
+
const inlineScript = `${propsScript}${dirtyFlag}${refreshSetup}`;
|
|
3266
|
+
const html = `<!DOCTYPE html><html><head></head><body>` + `<script>${inlineScript}</script>` + `<script type="module" src="${index}"></script>` + `</body></html>`;
|
|
3267
|
+
return new Response(html, {
|
|
3268
|
+
headers: { "Content-Type": "text/html" }
|
|
3269
|
+
});
|
|
3270
|
+
};
|
|
3271
|
+
var handleReactPageRequest = async (PageComponentOrInput, index, ...args) => {
|
|
3272
|
+
const {
|
|
3273
|
+
Page,
|
|
3274
|
+
index: resolvedIndex,
|
|
3275
|
+
options,
|
|
3276
|
+
props: maybeProps
|
|
3277
|
+
} = typeof PageComponentOrInput === "object" && PageComponentOrInput !== null && "Page" in PageComponentOrInput ? {
|
|
3278
|
+
index: PageComponentOrInput.index,
|
|
3279
|
+
options: PageComponentOrInput,
|
|
3280
|
+
Page: PageComponentOrInput.Page,
|
|
3281
|
+
props: PageComponentOrInput.props
|
|
3282
|
+
} : {
|
|
3283
|
+
index: index ?? "",
|
|
3284
|
+
options: args[1],
|
|
3285
|
+
Page: PageComponentOrInput,
|
|
3286
|
+
props: args[0]
|
|
3287
|
+
};
|
|
3288
|
+
if (isSsrCacheDirty("react")) {
|
|
3289
|
+
return buildDirtyResponse(resolvedIndex, maybeProps);
|
|
3290
|
+
}
|
|
3291
|
+
try {
|
|
3292
|
+
const handlerCallsite = options?.collectStreamingSlots === true ? undefined : getCurrentRouteRegistrationCallsite() ?? captureStreamingSlotWarningCallsite();
|
|
3293
|
+
const renderPageResponse = async () => {
|
|
3294
|
+
const { createElement } = await import("react");
|
|
3295
|
+
const { renderToReadableStream } = await import("react-dom/server");
|
|
3296
|
+
const element = maybeProps !== undefined ? createElement(Page, maybeProps) : createElement(Page);
|
|
3297
|
+
const propsScript = maybeProps ? `window.__INITIAL_PROPS__=${JSON.stringify(maybeProps)};` : "";
|
|
3298
|
+
const refreshSetup = buildRefreshSetup();
|
|
3299
|
+
const stream = await renderToReadableStream(element, {
|
|
3300
|
+
bootstrapModules: [resolvedIndex],
|
|
3301
|
+
bootstrapScriptContent: propsScript + refreshSetup || undefined,
|
|
3302
|
+
onError(error) {
|
|
3303
|
+
console.error("[SSR] React streaming error:", error);
|
|
3304
|
+
}
|
|
3305
|
+
});
|
|
3306
|
+
const htmlStream = injectIslandPageContextStream(stream);
|
|
3307
|
+
return new Response(htmlStream, {
|
|
3308
|
+
headers: { "Content-Type": "text/html" }
|
|
3309
|
+
});
|
|
3310
|
+
};
|
|
3311
|
+
return runWithStreamingSlotWarningScope(() => options?.collectStreamingSlots === true ? withRegisteredStreamingSlots(renderPageResponse, options) : renderPageResponse(), { handlerCallsite });
|
|
3312
|
+
} catch (error) {
|
|
3313
|
+
console.error("[SSR] React render error:", error);
|
|
3314
|
+
const pageName = Page.name || Page.displayName || "";
|
|
3315
|
+
const conventionResponse = await renderConventionError("react", pageName, error);
|
|
3316
|
+
if (conventionResponse)
|
|
3317
|
+
return conventionResponse;
|
|
3318
|
+
return new Response(ssrErrorPage("react", error), {
|
|
3319
|
+
headers: { "Content-Type": "text/html" },
|
|
3320
|
+
status: 500
|
|
3321
|
+
});
|
|
3322
|
+
}
|
|
3323
|
+
};
|
|
3141
3324
|
// src/react/Island.tsx
|
|
3142
3325
|
init_islandMarkupAttributes();
|
|
3143
3326
|
init_renderIslandMarkup();
|
|
@@ -3302,5 +3485,5 @@ export {
|
|
|
3302
3485
|
Island
|
|
3303
3486
|
};
|
|
3304
3487
|
|
|
3305
|
-
//# debugId=
|
|
3488
|
+
//# debugId=58532B7D77CCF47E64756E2164756E21
|
|
3306
3489
|
//# sourceMappingURL=index.js.map
|