@absolutejs/absolute 0.19.0-beta.694 → 0.19.0-beta.695
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/dist/angular/index.js +135 -11
- package/dist/angular/index.js.map +3 -3
- package/dist/angular/server.js +135 -11
- package/dist/angular/server.js.map +3 -3
- package/dist/build.js +158 -27
- package/dist/build.js.map +5 -5
- package/dist/cli/index.js +1 -0
- package/dist/index.js +1562 -1586
- package/dist/index.js.map +26 -33
- package/dist/islands/index.js +135 -11
- package/dist/islands/index.js.map +3 -3
- package/dist/react/index.js +140 -11
- package/dist/react/index.js.map +3 -3
- package/dist/react/server.js +6 -1
- package/dist/react/server.js.map +2 -2
- 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 +2 -1
- package/dist/svelte/index.js +135 -11
- package/dist/svelte/index.js.map +3 -3
- package/dist/svelte/server.js +135 -11
- package/dist/svelte/server.js.map +3 -3
- package/dist/types/build.d.ts +13 -0
- package/dist/vue/index.js +135 -11
- package/dist/vue/index.js.map +3 -3
- package/package.json +11 -7
package/dist/index.js
CHANGED
|
@@ -171,6 +171,29 @@ var init_streamingSlotRegistry = __esm(() => {
|
|
|
171
171
|
});
|
|
172
172
|
});
|
|
173
173
|
|
|
174
|
+
// types/typeGuards.ts
|
|
175
|
+
var isValidHMRClientMessage = (data) => {
|
|
176
|
+
if (!data || typeof data !== "object") {
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
if (!("type" in data) || typeof data.type !== "string") {
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
switch (data.type) {
|
|
183
|
+
case "ping":
|
|
184
|
+
case "ready":
|
|
185
|
+
case "request-rebuild":
|
|
186
|
+
case "hydration-error":
|
|
187
|
+
case "hmr-timing":
|
|
188
|
+
return true;
|
|
189
|
+
default:
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
// types/websocket.ts
|
|
195
|
+
var WS_READY_STATE_OPEN = 1;
|
|
196
|
+
|
|
174
197
|
// src/constants.ts
|
|
175
198
|
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
199
|
var init_constants = __esm(() => {
|
|
@@ -179,375 +202,142 @@ var init_constants = __esm(() => {
|
|
|
179
202
|
TWO_THIRDS = 2 / 3;
|
|
180
203
|
});
|
|
181
204
|
|
|
182
|
-
// src/core/
|
|
183
|
-
var
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
const openingBodyIndex = html.indexOf("<body");
|
|
195
|
-
if (openingBodyIndex >= 0) {
|
|
196
|
-
const bodyStart = html.indexOf(">", openingBodyIndex);
|
|
197
|
-
if (bodyStart >= 0) {
|
|
198
|
-
return `${html.slice(0, openingBodyIndex)}<head>${markup}</head>${html.slice(openingBodyIndex)}`;
|
|
199
|
-
}
|
|
205
|
+
// src/core/islandManifest.ts
|
|
206
|
+
var toIslandFrameworkSegment = (framework) => framework[0]?.toUpperCase() + framework.slice(1), collectFrameworkIslands = (manifest, prefix) => {
|
|
207
|
+
const entries = {};
|
|
208
|
+
let found = false;
|
|
209
|
+
for (const [key, value] of Object.entries(manifest)) {
|
|
210
|
+
if (!key.startsWith(prefix))
|
|
211
|
+
continue;
|
|
212
|
+
const component = key.slice(prefix.length);
|
|
213
|
+
if (!component)
|
|
214
|
+
continue;
|
|
215
|
+
entries[component] = value;
|
|
216
|
+
found = true;
|
|
200
217
|
}
|
|
201
|
-
return
|
|
202
|
-
},
|
|
203
|
-
|
|
204
|
-
|
|
218
|
+
return found ? entries : undefined;
|
|
219
|
+
}, getIslandManifestEntries = (manifest) => {
|
|
220
|
+
const islands = {};
|
|
221
|
+
const frameworks = ["react", "svelte", "vue", "angular"];
|
|
222
|
+
for (const framework of frameworks) {
|
|
223
|
+
const prefix = `Island${toIslandFrameworkSegment(framework)}`;
|
|
224
|
+
const entries = collectFrameworkIslands(manifest, prefix);
|
|
225
|
+
if (entries)
|
|
226
|
+
islands[framework] = entries;
|
|
205
227
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
228
|
+
return islands;
|
|
229
|
+
}, getIslandManifestKey = (framework, component) => `Island${toIslandFrameworkSegment(framework)}${component}`;
|
|
230
|
+
|
|
231
|
+
// src/core/islands.ts
|
|
232
|
+
function getIslandComponent(component) {
|
|
233
|
+
if (isIslandComponentDefinition(component)) {
|
|
234
|
+
return component.component;
|
|
212
235
|
}
|
|
236
|
+
return component;
|
|
237
|
+
}
|
|
238
|
+
var defineIslandComponent = (component, options) => ({
|
|
239
|
+
component,
|
|
240
|
+
export: options.export,
|
|
241
|
+
source: options.source
|
|
242
|
+
}), defineIslandRegistry = (registry) => registry, isRecord = (value) => typeof value === "object" && value !== null, getIslandBuildReference = (component) => {
|
|
243
|
+
if (!isIslandComponentDefinition(component))
|
|
244
|
+
return null;
|
|
213
245
|
return {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
pending: consumed.pending
|
|
246
|
+
export: component.export,
|
|
247
|
+
source: component.source
|
|
217
248
|
};
|
|
218
|
-
},
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
249
|
+
}, isIslandComponentDefinition = (value) => isRecord(value) && ("component" in value) && ("source" in value) && typeof value.source === "string", parseIslandProps = (rawProps) => {
|
|
250
|
+
if (!rawProps)
|
|
251
|
+
return {};
|
|
252
|
+
return JSON.parse(rawProps);
|
|
253
|
+
}, serializeIslandProps = (props) => JSON.stringify(props ?? {});
|
|
254
|
+
var init_islands = () => {};
|
|
255
|
+
|
|
256
|
+
// src/client/streamSwap.ts
|
|
257
|
+
var streamSwapRuntime = () => {
|
|
258
|
+
const SLOT_PATCH_EVENT = "absolutejs:slot-patch";
|
|
259
|
+
if (window.__ABS_SLOT_RUNTIME__ === true)
|
|
260
|
+
return;
|
|
261
|
+
window.__ABS_SLOT_RUNTIME__ = true;
|
|
262
|
+
window.__ABS_SLOT_CONSUMERS__ = window.__ABS_SLOT_CONSUMERS__ ?? {};
|
|
263
|
+
window.__ABS_SLOT_PENDING__ = window.__ABS_SLOT_PENDING__ ?? {};
|
|
264
|
+
const consumers = window.__ABS_SLOT_CONSUMERS__;
|
|
265
|
+
const pending = window.__ABS_SLOT_PENDING__;
|
|
266
|
+
const isObjectRecord3 = (value) => Boolean(value) && typeof value === "object";
|
|
267
|
+
const isPatchedPendingEntry = (value) => {
|
|
268
|
+
if (!isObjectRecord3(value))
|
|
269
|
+
return false;
|
|
270
|
+
return value.domPatched === true && "payload" in value;
|
|
271
|
+
};
|
|
272
|
+
const unwrapPendingPayload = (value) => isPatchedPendingEntry(value) ? value.payload : value;
|
|
273
|
+
const canApplyImmediately = () => window.__ABS_SLOT_HYDRATION_PENDING__ !== true;
|
|
274
|
+
const isAngularDeferPayload = (payload) => {
|
|
275
|
+
if (!isObjectRecord3(payload))
|
|
276
|
+
return false;
|
|
277
|
+
return payload.kind === "angular-defer";
|
|
278
|
+
};
|
|
279
|
+
const isVueSuspensePayload = (payload) => {
|
|
280
|
+
if (!isObjectRecord3(payload))
|
|
281
|
+
return false;
|
|
282
|
+
return payload.kind === "vue-suspense";
|
|
283
|
+
};
|
|
284
|
+
const resolveHtml = (payload) => {
|
|
285
|
+
if (!isObjectRecord3(payload)) {
|
|
286
|
+
return typeof payload === "string" ? payload : "";
|
|
232
287
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
const next = `${pending.slice(0, headIndex)}${markup}${pending.slice(headIndex)}`;
|
|
236
|
-
controller.enqueue(encoder.encode(next));
|
|
237
|
-
return { injected: true, pending: "" };
|
|
288
|
+
if (typeof payload.html === "string") {
|
|
289
|
+
return payload.html;
|
|
238
290
|
}
|
|
239
|
-
return
|
|
240
|
-
injected,
|
|
241
|
-
pending: flushSafePendingText(controller, encoder, pending, lookbehind)
|
|
242
|
-
};
|
|
291
|
+
return "";
|
|
243
292
|
};
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
if (!
|
|
247
|
-
|
|
293
|
+
const apply = (id, pendingEntry) => {
|
|
294
|
+
const payload = unwrapPendingPayload(pendingEntry);
|
|
295
|
+
if (!canApplyImmediately()) {
|
|
296
|
+
pending[id] = payload;
|
|
297
|
+
return;
|
|
248
298
|
}
|
|
249
|
-
|
|
250
|
-
|
|
299
|
+
const consumer = consumers[id];
|
|
300
|
+
if (typeof consumer !== "function") {
|
|
301
|
+
applyToDom(id, payload, pendingEntry);
|
|
302
|
+
return;
|
|
251
303
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
if (done || !value) {
|
|
257
|
-
return { done, injected, pending };
|
|
304
|
+
const handled = consumer(payload);
|
|
305
|
+
if (handled !== false) {
|
|
306
|
+
delete pending[id];
|
|
307
|
+
return;
|
|
258
308
|
}
|
|
259
|
-
|
|
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, "");
|
|
309
|
+
applyToDom(id, payload, pendingEntry);
|
|
276
310
|
};
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
const { injected, pending } = await runHeadInjectionLoop(controller, reader);
|
|
282
|
-
finishHeadInjectionStream(controller, pending, injected);
|
|
283
|
-
} catch (error) {
|
|
284
|
-
controller.error(error);
|
|
285
|
-
}
|
|
311
|
+
const applyToDom = (id, payload, pendingEntry) => {
|
|
312
|
+
if (isAngularDeferPayload(payload)) {
|
|
313
|
+
pending[id] = payload;
|
|
314
|
+
return;
|
|
286
315
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
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: "" };
|
|
316
|
+
const node = document.getElementById(id);
|
|
317
|
+
if (!node) {
|
|
318
|
+
pending[id] = payload;
|
|
319
|
+
return;
|
|
296
320
|
}
|
|
297
|
-
const
|
|
298
|
-
if (
|
|
299
|
-
|
|
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: "" };
|
|
321
|
+
const html = resolveHtml(payload);
|
|
322
|
+
if (isVueSuspensePayload(payload) && isPatchedPendingEntry(pendingEntry)) {
|
|
323
|
+
return;
|
|
304
324
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
controller.enqueue(encoder.encode(finalPending));
|
|
325
|
+
node.innerHTML = html;
|
|
326
|
+
node.setAttribute("data-absolute-slot-state", "resolved");
|
|
327
|
+
window.dispatchEvent(new CustomEvent(SLOT_PATCH_EVENT, {
|
|
328
|
+
detail: { html, id, payload }
|
|
329
|
+
}));
|
|
330
|
+
if (isVueSuspensePayload(payload)) {
|
|
331
|
+
pending[id] = { domPatched: true, payload };
|
|
332
|
+
return;
|
|
314
333
|
}
|
|
315
|
-
|
|
334
|
+
delete pending[id];
|
|
316
335
|
};
|
|
317
|
-
const
|
|
318
|
-
const
|
|
319
|
-
|
|
320
|
-
|
|
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;
|
|
508
|
-
}
|
|
509
|
-
const consumer = consumers[id];
|
|
510
|
-
if (typeof consumer !== "function") {
|
|
511
|
-
applyToDom(id, payload, pendingEntry);
|
|
512
|
-
return;
|
|
513
|
-
}
|
|
514
|
-
const handled = consumer(payload);
|
|
515
|
-
if (handled !== false) {
|
|
516
|
-
delete pending[id];
|
|
517
|
-
return;
|
|
518
|
-
}
|
|
519
|
-
applyToDom(id, payload, pendingEntry);
|
|
520
|
-
};
|
|
521
|
-
const applyToDom = (id, payload, pendingEntry) => {
|
|
522
|
-
if (isAngularDeferPayload(payload)) {
|
|
523
|
-
pending[id] = payload;
|
|
524
|
-
return;
|
|
525
|
-
}
|
|
526
|
-
const node = document.getElementById(id);
|
|
527
|
-
if (!node) {
|
|
528
|
-
pending[id] = payload;
|
|
529
|
-
return;
|
|
530
|
-
}
|
|
531
|
-
const html = resolveHtml(payload);
|
|
532
|
-
if (isVueSuspensePayload(payload) && isPatchedPendingEntry(pendingEntry)) {
|
|
533
|
-
return;
|
|
534
|
-
}
|
|
535
|
-
node.innerHTML = html;
|
|
536
|
-
node.setAttribute("data-absolute-slot-state", "resolved");
|
|
537
|
-
window.dispatchEvent(new CustomEvent(SLOT_PATCH_EVENT, {
|
|
538
|
-
detail: { html, id, payload }
|
|
539
|
-
}));
|
|
540
|
-
if (isVueSuspensePayload(payload)) {
|
|
541
|
-
pending[id] = { domPatched: true, payload };
|
|
542
|
-
return;
|
|
543
|
-
}
|
|
544
|
-
delete pending[id];
|
|
545
|
-
};
|
|
546
|
-
const flush = () => {
|
|
547
|
-
for (const id in pending) {
|
|
548
|
-
if (!Object.prototype.hasOwnProperty.call(pending, id))
|
|
549
|
-
continue;
|
|
550
|
-
apply(id, pending[id] ?? "");
|
|
336
|
+
const flush = () => {
|
|
337
|
+
for (const id in pending) {
|
|
338
|
+
if (!Object.prototype.hasOwnProperty.call(pending, id))
|
|
339
|
+
continue;
|
|
340
|
+
apply(id, pending[id] ?? "");
|
|
551
341
|
}
|
|
552
342
|
};
|
|
553
343
|
window.__ABS_SLOT_FLUSH__ = flush;
|
|
@@ -586,14 +376,14 @@ var init_escapeScriptContent = __esm(() => {
|
|
|
586
376
|
});
|
|
587
377
|
|
|
588
378
|
// src/utils/streamingSlots.ts
|
|
589
|
-
var SLOT_ID_PREFIX = "abs-slot-", CLOSING_BODY_TAG = "</body>",
|
|
379
|
+
var SLOT_ID_PREFIX = "abs-slot-", CLOSING_BODY_TAG = "</body>", CLOSING_HEAD_TAG = "</head>", CLOSING_BODY_TAG_LENGTH, CLOSING_HEAD_TAG_LENGTH, CLOSING_PAGE_TAG_REGEX, STREAMING_RUNTIME_GLOBAL = "__ABS_SLOT_ENQUEUE__", STREAMING_PENDING_GLOBAL = "__ABS_SLOT_PENDING__", STREAM_TAIL_LOOKBEHIND = 128, STREAMING_SLOT_TIMEOUT_MS = 5000, STREAMING_SLOT_MAX_PER_RESPONSE = 128, STREAMING_SLOT_MAX_HTML_BYTES = 64000, createSlotPatchStatement = (id, payload) => `(window.${STREAMING_RUNTIME_GLOBAL}||function(i,p){window.${STREAMING_PENDING_GLOBAL}=window.${STREAMING_PENDING_GLOBAL}||{};window.${STREAMING_PENDING_GLOBAL}[i]=p;})(${JSON.stringify(id)},${JSON.stringify(payload)});`, createNonceAttr = (nonce) => nonce ? ` nonce="${nonce}"` : "", createStreamingSlotId = () => `${SLOT_ID_PREFIX}${Math.random().toString(BASE_36_RADIX).slice(2, RANDOM_ID_END_INDEX)}`, getStreamingSlotsRuntimeScript = () => getStreamSwapRuntimeScript(), injectHtmlIntoBody = (html, injection) => {
|
|
590
380
|
const closingBodyIndex = html.indexOf(CLOSING_BODY_TAG);
|
|
591
381
|
if (closingBodyIndex >= 0) {
|
|
592
382
|
return `${html.slice(0, closingBodyIndex)}${injection}${html.slice(closingBodyIndex)}`;
|
|
593
383
|
}
|
|
594
384
|
return `${html}${injection}`;
|
|
595
385
|
}, injectHtmlIntoHead = (html, injection) => {
|
|
596
|
-
const closingHeadIndex = html.indexOf(
|
|
386
|
+
const closingHeadIndex = html.indexOf(CLOSING_HEAD_TAG);
|
|
597
387
|
if (closingHeadIndex >= 0) {
|
|
598
388
|
return `${html.slice(0, closingHeadIndex)}${injection}${html.slice(closingHeadIndex)}`;
|
|
599
389
|
}
|
|
@@ -604,7 +394,7 @@ var SLOT_ID_PREFIX = "abs-slot-", CLOSING_BODY_TAG = "</body>", CLOSING_HEAD_TAG
|
|
|
604
394
|
getStreamingSlotsRuntimeScript()
|
|
605
395
|
].filter(Boolean).join(";");
|
|
606
396
|
return `<script${createNonceAttr(nonce)}>${escapeScriptContent(runtimeBody)}</script>`;
|
|
607
|
-
}, toUint8 = (value, encoder) => encoder.encode(value),
|
|
397
|
+
}, toUint8 = (value, encoder) => encoder.encode(value), isRecord2 = (value) => Boolean(value) && typeof value === "object", isSafeHtmlLike = (value) => isRecord2(value) && typeof value.changingThisBreaksApplicationSecurity === "string", normalizeSafeHtml = (value) => {
|
|
608
398
|
if (isSafeHtmlLike(value)) {
|
|
609
399
|
return value.changingThisBreaksApplicationSecurity;
|
|
610
400
|
}
|
|
@@ -665,7 +455,7 @@ var SLOT_ID_PREFIX = "abs-slot-", CLOSING_BODY_TAG = "</body>", CLOSING_HEAD_TAG
|
|
|
665
455
|
}, createTimeoutError = (slot, timeoutMs) => {
|
|
666
456
|
const error = Object.assign(new Error(`Streaming slot "${slot.id}" timed out after ${timeoutMs}ms`), { __absTimeout: true });
|
|
667
457
|
return error;
|
|
668
|
-
}, isSlotPatchPayloadObject = (value) =>
|
|
458
|
+
}, isSlotPatchPayloadObject = (value) => isRecord2(value) && ("html" in value), isTimeoutError = (error) => isRecord2(error) && error.__absTimeout === true, toStreamingSlot = (slot, policy) => ({
|
|
669
459
|
errorHtml: slot.errorHtml === undefined ? policy.errorHtml : slot.errorHtml,
|
|
670
460
|
fallbackHtml: normalizeSlotText(slot.fallbackHtml, policy.fallbackHtml),
|
|
671
461
|
id: slot.id ?? createStreamingSlotId(),
|
|
@@ -840,7 +630,7 @@ var SLOT_ID_PREFIX = "abs-slot-", CLOSING_BODY_TAG = "</body>", CLOSING_HEAD_TAG
|
|
|
840
630
|
result
|
|
841
631
|
})));
|
|
842
632
|
return Promise.race(wrapped);
|
|
843
|
-
},
|
|
633
|
+
}, streamChunkToString = (value, decoder) => typeof value === "string" ? value : decoder.decode(value, { stream: true }), appendStreamingSlotPatchesToStream = (stream, slots = [], {
|
|
844
634
|
injectRuntime = true,
|
|
845
635
|
nonce,
|
|
846
636
|
onError,
|
|
@@ -927,7 +717,7 @@ var SLOT_ID_PREFIX = "abs-slot-", CLOSING_BODY_TAG = "</body>", CLOSING_HEAD_TAG
|
|
|
927
717
|
if (!winner.value) {
|
|
928
718
|
return { baseDone: false, baseRead, footer, handled: true, tail };
|
|
929
719
|
}
|
|
930
|
-
const nextTail = flushTailLookbehind(controller, tail +
|
|
720
|
+
const nextTail = flushTailLookbehind(controller, tail + streamChunkToString(winner.value, decoder));
|
|
931
721
|
return {
|
|
932
722
|
baseDone: false,
|
|
933
723
|
baseRead: reader.read(),
|
|
@@ -988,7 +778,7 @@ var SLOT_ID_PREFIX = "abs-slot-", CLOSING_BODY_TAG = "</body>", CLOSING_HEAD_TAG
|
|
|
988
778
|
const runtimeTag = renderStreamingSlotsRuntimeTag(nonce, runtimePreludeScript);
|
|
989
779
|
const encoder = new TextEncoder;
|
|
990
780
|
const decoder = new TextDecoder;
|
|
991
|
-
const closingTag = runtimePlacement === "body" ? CLOSING_BODY_TAG :
|
|
781
|
+
const closingTag = runtimePlacement === "body" ? CLOSING_BODY_TAG : CLOSING_HEAD_TAG;
|
|
992
782
|
const lookbehind = (runtimePlacement === "body" ? CLOSING_BODY_TAG_LENGTH : CLOSING_HEAD_TAG_LENGTH) - 1;
|
|
993
783
|
const flushRuntimeLookbehind = (controller, pending) => {
|
|
994
784
|
if (pending.length <= lookbehind) {
|
|
@@ -1026,7 +816,7 @@ var SLOT_ID_PREFIX = "abs-slot-", CLOSING_BODY_TAG = "</body>", CLOSING_HEAD_TAG
|
|
|
1026
816
|
if (done || !value) {
|
|
1027
817
|
return done;
|
|
1028
818
|
}
|
|
1029
|
-
pending +=
|
|
819
|
+
pending += streamChunkToString(value, decoder);
|
|
1030
820
|
({ injected, pending } = processRuntimePending(controller, pending, injected));
|
|
1031
821
|
return false;
|
|
1032
822
|
};
|
|
@@ -1128,7 +918,7 @@ var init_streamingSlots = __esm(() => {
|
|
|
1128
918
|
init_constants();
|
|
1129
919
|
init_escapeScriptContent();
|
|
1130
920
|
CLOSING_BODY_TAG_LENGTH = CLOSING_BODY_TAG.length;
|
|
1131
|
-
CLOSING_HEAD_TAG_LENGTH =
|
|
921
|
+
CLOSING_HEAD_TAG_LENGTH = CLOSING_HEAD_TAG.length;
|
|
1132
922
|
CLOSING_PAGE_TAG_REGEX = /<\/body>\s*<\/html>\s*$/i;
|
|
1133
923
|
currentStreamingSlotPolicy = {
|
|
1134
924
|
errorHtml: undefined,
|
|
@@ -1139,305 +929,159 @@ var init_streamingSlots = __esm(() => {
|
|
|
1139
929
|
};
|
|
1140
930
|
});
|
|
1141
931
|
|
|
1142
|
-
// src/
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
onError,
|
|
1149
|
-
runtimePlacement,
|
|
1150
|
-
runtimePreludeScript,
|
|
1151
|
-
streamingSlots = [],
|
|
1152
|
-
policy
|
|
1153
|
-
} = {}) => {
|
|
1154
|
-
if (!response.body || streamingSlots.length === 0) {
|
|
1155
|
-
return response;
|
|
932
|
+
// src/angular/injectorPatch.ts
|
|
933
|
+
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
934
|
+
import { dirname, join, resolve } from "path";
|
|
935
|
+
var applyInjectorPatch = (chunkPath, content) => {
|
|
936
|
+
if (content.includes('Symbol.for("angular.currentInjector")')) {
|
|
937
|
+
return;
|
|
1156
938
|
}
|
|
1157
|
-
const
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
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`;
|
|
939
|
+
const original = [
|
|
940
|
+
"let _currentInjector = undefined;",
|
|
941
|
+
"function getCurrentInjector() {",
|
|
942
|
+
" return _currentInjector;",
|
|
943
|
+
"}",
|
|
944
|
+
"function setCurrentInjector(injector) {",
|
|
945
|
+
" const former = _currentInjector;",
|
|
946
|
+
" _currentInjector = injector;",
|
|
947
|
+
" return former;",
|
|
948
|
+
"}"
|
|
949
|
+
].join(`
|
|
950
|
+
`);
|
|
951
|
+
const replacement = [
|
|
952
|
+
'const _injSym = Symbol.for("angular.currentInjector");',
|
|
953
|
+
"if (!globalThis[_injSym]) globalThis[_injSym] = { v: undefined };",
|
|
954
|
+
"function getCurrentInjector() {",
|
|
955
|
+
" return globalThis[_injSym].v;",
|
|
956
|
+
"}",
|
|
957
|
+
"function setCurrentInjector(injector) {",
|
|
958
|
+
" const former = globalThis[_injSym].v;",
|
|
959
|
+
" globalThis[_injSym].v = injector;",
|
|
960
|
+
" return former;",
|
|
961
|
+
"}"
|
|
962
|
+
].join(`
|
|
963
|
+
`);
|
|
964
|
+
const patched = content.replace(original, replacement);
|
|
965
|
+
if (patched === content) {
|
|
966
|
+
return;
|
|
1198
967
|
}
|
|
1199
|
-
|
|
968
|
+
writeFileSync(chunkPath, patched, "utf-8");
|
|
969
|
+
}, resolveAngularCoreDir = () => {
|
|
970
|
+
const fromProject = resolve(process.cwd(), "node_modules/@angular/core");
|
|
971
|
+
if (existsSync(join(fromProject, "package.json"))) {
|
|
972
|
+
return fromProject;
|
|
973
|
+
}
|
|
974
|
+
return dirname(__require.resolve("@angular/core/package.json"));
|
|
975
|
+
}, patchAngularInjectorSingleton = () => {
|
|
976
|
+
try {
|
|
977
|
+
const coreDir = resolveAngularCoreDir();
|
|
978
|
+
const chunkPath = join(coreDir, "fesm2022", "_not_found-chunk.mjs");
|
|
979
|
+
const content = readFileSync(chunkPath, "utf-8");
|
|
980
|
+
applyInjectorPatch(chunkPath, content);
|
|
981
|
+
} catch {}
|
|
1200
982
|
};
|
|
1201
|
-
var
|
|
1202
|
-
|
|
983
|
+
var init_injectorPatch = __esm(() => {
|
|
984
|
+
patchAngularInjectorSingleton();
|
|
1203
985
|
});
|
|
1204
986
|
|
|
1205
|
-
// src/
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
const
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
const seconds = now.getSeconds().toString().padStart(2, "0");
|
|
1213
|
-
const ampm = hours >= HOURS_IN_HALF_DAY ? "PM" : "AM";
|
|
1214
|
-
hours = hours % HOURS_IN_HALF_DAY || HOURS_IN_HALF_DAY;
|
|
1215
|
-
return `${month} ${day} ${hours}:${minutes}:${seconds} ${ampm}`;
|
|
1216
|
-
}, startupBanner = (options) => {
|
|
1217
|
-
const {
|
|
1218
|
-
version,
|
|
1219
|
-
readyDuration,
|
|
1220
|
-
buildDuration,
|
|
1221
|
-
port,
|
|
1222
|
-
host,
|
|
1223
|
-
networkUrl,
|
|
1224
|
-
protocol = "http"
|
|
1225
|
-
} = options;
|
|
1226
|
-
const name = `${colors.cyan}${colors.bold}ABSOLUTEJS${colors.reset}`;
|
|
1227
|
-
const ver = `${colors.dim}v${version}${colors.reset}`;
|
|
1228
|
-
const time = `${colors.dim}ready in${colors.reset} ${colors.bold}${getDurationString(readyDuration)}${colors.reset}`;
|
|
1229
|
-
const build = typeof buildDuration === "number" && Number.isFinite(buildDuration) ? ` ${colors.dim}(build ${getDurationString(buildDuration)})${colors.reset}` : "";
|
|
1230
|
-
console.log("");
|
|
1231
|
-
console.log(` ${name} ${ver} ${time}${build}`);
|
|
1232
|
-
console.log("");
|
|
1233
|
-
console.log(` ${colors.green}\u279C${colors.reset} ${colors.bold}Local:${colors.reset} ${protocol}://${host === "0.0.0.0" ? "localhost" : host}:${port}/`);
|
|
1234
|
-
if (networkUrl) {
|
|
1235
|
-
console.log(` ${colors.green}\u279C${colors.reset} ${colors.bold}Network:${colors.reset} ${networkUrl}`);
|
|
987
|
+
// src/angular/resolveAngularPackage.ts
|
|
988
|
+
import { existsSync as existsSync2 } from "fs";
|
|
989
|
+
import { resolve as resolve2 } from "path";
|
|
990
|
+
var resolveAngularPackage = (specifier) => {
|
|
991
|
+
const fromProject = resolve2(process.cwd(), "node_modules", specifier);
|
|
992
|
+
if (existsSync2(fromProject)) {
|
|
993
|
+
return fromProject;
|
|
1236
994
|
}
|
|
1237
|
-
|
|
995
|
+
return specifier;
|
|
1238
996
|
};
|
|
1239
|
-
var
|
|
1240
|
-
init_constants();
|
|
1241
|
-
init_getDurationString();
|
|
1242
|
-
colors = {
|
|
1243
|
-
bold: "\x1B[1m",
|
|
1244
|
-
cyan: "\x1B[36m",
|
|
1245
|
-
dim: "\x1B[2m",
|
|
1246
|
-
green: "\x1B[32m",
|
|
1247
|
-
reset: "\x1B[0m"
|
|
1248
|
-
};
|
|
1249
|
-
MONTHS = [
|
|
1250
|
-
"Jan",
|
|
1251
|
-
"Feb",
|
|
1252
|
-
"Mar",
|
|
1253
|
-
"Apr",
|
|
1254
|
-
"May",
|
|
1255
|
-
"Jun",
|
|
1256
|
-
"Jul",
|
|
1257
|
-
"Aug",
|
|
1258
|
-
"Sep",
|
|
1259
|
-
"Oct",
|
|
1260
|
-
"Nov",
|
|
1261
|
-
"Dec"
|
|
1262
|
-
];
|
|
1263
|
-
});
|
|
997
|
+
var init_resolveAngularPackage = () => {};
|
|
1264
998
|
|
|
1265
|
-
// src/
|
|
1266
|
-
var
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
return relative;
|
|
1274
|
-
}, getFrameworkColor = (framework) => frameworkColors[framework] || colors2.white, log = (action, options) => {
|
|
1275
|
-
const timestamp = `${colors2.dim}${formatTimestamp()}${colors2.reset}`;
|
|
1276
|
-
const tag = `${colors2.cyan}[hmr]${colors2.reset}`;
|
|
1277
|
-
let message = action;
|
|
1278
|
-
if (options?.path) {
|
|
1279
|
-
const pathColor = options.framework ? getFrameworkColor(options.framework) : colors2.white;
|
|
1280
|
-
message += ` ${pathColor}${formatPath(options.path)}${colors2.reset}`;
|
|
999
|
+
// src/angular/angularPatch.ts
|
|
1000
|
+
var exports_angularPatch = {};
|
|
1001
|
+
__export(exports_angularPatch, {
|
|
1002
|
+
applyPatches: () => applyPatches
|
|
1003
|
+
});
|
|
1004
|
+
var ensureHead = (doc) => {
|
|
1005
|
+
if (!doc || doc.head || !doc.documentElement) {
|
|
1006
|
+
return;
|
|
1281
1007
|
}
|
|
1282
|
-
|
|
1283
|
-
|
|
1008
|
+
const head = doc.createElement("head");
|
|
1009
|
+
doc.documentElement.insertBefore(head, doc.documentElement.firstChild);
|
|
1010
|
+
}, applyPatches = async () => {
|
|
1011
|
+
const { \u{275}DominoAdapter } = await import(resolveAngularPackage("@angular/platform-server"));
|
|
1012
|
+
if (!\u{275}DominoAdapter?.prototype) {
|
|
1013
|
+
console.warn("[Angular Patch] \u0275DominoAdapter not found, skipping patches");
|
|
1014
|
+
return false;
|
|
1284
1015
|
}
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
const fullMessage = `${colors2.red}error${colors2.reset} ${message}${errorMsg ? `: ${errorMsg}` : ""}`;
|
|
1293
|
-
console.error(`${timestamp} ${tag} ${fullMessage}`);
|
|
1294
|
-
}, logHmrUpdate = (path, framework, duration) => {
|
|
1295
|
-
log("hmr update", { duration, framework, path });
|
|
1296
|
-
}, logScriptUpdate = (path, framework, duration) => {
|
|
1297
|
-
log("script update", { duration, framework, path });
|
|
1298
|
-
}, logServerReload = () => {
|
|
1299
|
-
log(`${colors2.cyan}server module reloaded${colors2.reset}`);
|
|
1300
|
-
}, logWarn = (message) => {
|
|
1301
|
-
const timestamp = `${colors2.dim}${formatTimestamp()}${colors2.reset}`;
|
|
1302
|
-
const tag = `${colors2.yellow}[hmr]${colors2.reset}`;
|
|
1303
|
-
console.log(`${timestamp} ${tag} ${colors2.yellow}warning ${message}${colors2.reset}`);
|
|
1304
|
-
};
|
|
1305
|
-
var init_logger = __esm(() => {
|
|
1306
|
-
init_startupBanner();
|
|
1307
|
-
colors2 = {
|
|
1308
|
-
blue: "\x1B[34m",
|
|
1309
|
-
bold: "\x1B[1m",
|
|
1310
|
-
cyan: "\x1B[36m",
|
|
1311
|
-
dim: "\x1B[2m",
|
|
1312
|
-
green: "\x1B[32m",
|
|
1313
|
-
magenta: "\x1B[35m",
|
|
1314
|
-
red: "\x1B[31m",
|
|
1315
|
-
reset: "\x1B[0m",
|
|
1316
|
-
white: "\x1B[37m",
|
|
1317
|
-
yellow: "\x1B[33m"
|
|
1016
|
+
const proto = \u{275}DominoAdapter.prototype;
|
|
1017
|
+
const origGetBaseHref = proto.getBaseHref;
|
|
1018
|
+
proto.getBaseHref = function(doc) {
|
|
1019
|
+
if (!doc || !doc.head || typeof doc.head.children === "undefined") {
|
|
1020
|
+
return "";
|
|
1021
|
+
}
|
|
1022
|
+
return origGetBaseHref.call(this, doc);
|
|
1318
1023
|
};
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1024
|
+
const origCreateHtmlDocument = proto.createHtmlDocument;
|
|
1025
|
+
proto.createHtmlDocument = function() {
|
|
1026
|
+
const doc = origCreateHtmlDocument.call(this);
|
|
1027
|
+
ensureHead(doc);
|
|
1028
|
+
return doc;
|
|
1029
|
+
};
|
|
1030
|
+
const origGetDefaultDocument = proto.getDefaultDocument;
|
|
1031
|
+
proto.getDefaultDocument = function() {
|
|
1032
|
+
const doc = origGetDefaultDocument.call(this);
|
|
1033
|
+
ensureHead(doc);
|
|
1034
|
+
return doc;
|
|
1328
1035
|
};
|
|
1036
|
+
return true;
|
|
1037
|
+
};
|
|
1038
|
+
var init_angularPatch = __esm(() => {
|
|
1039
|
+
init_resolveAngularPackage();
|
|
1329
1040
|
});
|
|
1330
1041
|
|
|
1331
|
-
// src/
|
|
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`;
|
|
1042
|
+
// src/angular/angularDeps.ts
|
|
1043
|
+
var initDominoAdapter = (platformServer) => {
|
|
1044
|
+
try {
|
|
1045
|
+
const DominoAdapter = platformServer.\u{275}DominoAdapter;
|
|
1046
|
+
DominoAdapter?.makeCurrent?.();
|
|
1047
|
+
} catch (err) {
|
|
1048
|
+
console.error("Failed to initialize DominoAdapter:", err);
|
|
1351
1049
|
}
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
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 = () => {
|
|
1050
|
+
}, loadAngularDeps = async () => {
|
|
1051
|
+
patchAngularInjectorSingleton();
|
|
1052
|
+
await import(resolveAngularPackage("@angular/compiler"));
|
|
1053
|
+
const { applyPatches: applyPatches2 } = await Promise.resolve().then(() => (init_angularPatch(), exports_angularPatch));
|
|
1054
|
+
await applyPatches2();
|
|
1055
|
+
const [platformBrowser, platformServer, common, core] = await Promise.all([
|
|
1056
|
+
import(resolveAngularPackage("@angular/platform-browser")),
|
|
1057
|
+
import(resolveAngularPackage("@angular/platform-server")),
|
|
1058
|
+
import(resolveAngularPackage("@angular/common")),
|
|
1059
|
+
import(resolveAngularPackage("@angular/core"))
|
|
1060
|
+
]);
|
|
1367
1061
|
if (false) {}
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
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
|
-
});
|
|
1388
|
-
});
|
|
1389
|
-
|
|
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"
|
|
1062
|
+
initDominoAdapter(platformServer);
|
|
1063
|
+
return {
|
|
1064
|
+
APP_BASE_HREF: common.APP_BASE_HREF,
|
|
1065
|
+
bootstrapApplication: platformBrowser.bootstrapApplication,
|
|
1066
|
+
DomSanitizer: platformBrowser.DomSanitizer,
|
|
1067
|
+
provideClientHydration: platformBrowser.provideClientHydration,
|
|
1068
|
+
provideServerRendering: platformServer.provideServerRendering,
|
|
1069
|
+
provideZonelessChangeDetection: core.provideZonelessChangeDetection,
|
|
1070
|
+
reflectComponentType: core.reflectComponentType,
|
|
1071
|
+
renderApplication: platformServer.renderApplication,
|
|
1072
|
+
Sanitizer: core.Sanitizer,
|
|
1073
|
+
SecurityContext: core.SecurityContext
|
|
1399
1074
|
};
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
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>`;
|
|
1075
|
+
}, angularDeps = null, getAngularDeps = () => {
|
|
1076
|
+
if (!angularDeps) {
|
|
1077
|
+
angularDeps = loadAngularDeps();
|
|
1078
|
+
}
|
|
1079
|
+
return angularDeps;
|
|
1440
1080
|
};
|
|
1081
|
+
var init_angularDeps = __esm(() => {
|
|
1082
|
+
init_injectorPatch();
|
|
1083
|
+
init_resolveAngularPackage();
|
|
1084
|
+
});
|
|
1441
1085
|
|
|
1442
1086
|
// src/utils/stringModifiers.ts
|
|
1443
1087
|
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) => {
|
|
@@ -1447,721 +1091,224 @@ var normalizeSlug = (str) => str.trim().replace(/\s+/g, "-").replace(/[^A-Za-z0-
|
|
|
1447
1091
|
return normalizeSlug(str).split(/[-_]/).filter(Boolean).map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1).toLowerCase()).join("");
|
|
1448
1092
|
}, toScreamingSnake = (str) => str.replace(/([a-z0-9])([A-Z])/g, "$1_$2").toUpperCase();
|
|
1449
1093
|
|
|
1450
|
-
// src/utils/
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
return value;
|
|
1456
|
-
const empty = {};
|
|
1457
|
-
return empty;
|
|
1458
|
-
}, derivePageName = (pagePath) => {
|
|
1459
|
-
const base = basename(pagePath);
|
|
1460
|
-
const dotIndex = base.indexOf(".");
|
|
1461
|
-
const name = dotIndex > 0 ? base.slice(0, dotIndex) : base;
|
|
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;
|
|
1094
|
+
// src/utils/registerClientScript.ts
|
|
1095
|
+
var scriptRegistry, requestCounter = 0, getRequestId = () => `req_${Date.now()}_${++requestCounter}`, ssrContextGetter = null, getSsrContextId = () => ssrContextGetter?.() || Object.getOwnPropertyDescriptor(globalThis, "__absolutejs_requestId")?.value, registerClientScript = (script, requestId) => {
|
|
1096
|
+
const id = requestId || getSsrContextId() || getRequestId();
|
|
1097
|
+
if (!scriptRegistry.has(id)) {
|
|
1098
|
+
scriptRegistry.set(id, new Set);
|
|
1535
1099
|
}
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
if (
|
|
1544
|
-
return
|
|
1545
|
-
try {
|
|
1546
|
-
return await renderer(conventionPath, errorProps);
|
|
1547
|
-
} catch (renderError) {
|
|
1548
|
-
logConventionRenderError(framework, "error", renderError);
|
|
1100
|
+
scriptRegistry.get(id)?.add(script);
|
|
1101
|
+
return id;
|
|
1102
|
+
}, setSsrContextGetter = (getter) => {
|
|
1103
|
+
ssrContextGetter = getter;
|
|
1104
|
+
}, clearAllClientScripts = () => {
|
|
1105
|
+
scriptRegistry.clear();
|
|
1106
|
+
}, generateClientScriptCode = (scripts) => {
|
|
1107
|
+
if (scripts.length === 0) {
|
|
1108
|
+
return "";
|
|
1549
1109
|
}
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
}
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
})
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
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;
|
|
1110
|
+
const scriptCode = scripts.map((script, index) => {
|
|
1111
|
+
const funcString = script.toString();
|
|
1112
|
+
const bodyMatch = funcString.match(/\{([\s\S]*)\}/);
|
|
1113
|
+
if (!bodyMatch || !bodyMatch[1]) {
|
|
1114
|
+
return "";
|
|
1115
|
+
}
|
|
1116
|
+
const body = bodyMatch[1].trim();
|
|
1117
|
+
return `
|
|
1118
|
+
(function() {
|
|
1119
|
+
var executed = false;
|
|
1120
|
+
function executeScript_${index}() {
|
|
1121
|
+
if (executed) return;
|
|
1122
|
+
executed = true;
|
|
1123
|
+
${body}
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
if (document.readyState === 'complete' || document.readyState === 'interactive') {
|
|
1127
|
+
executeScript_${index}();
|
|
1128
|
+
} else {
|
|
1129
|
+
document.addEventListener('DOMContentLoaded', executeScript_${index});
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
// Watch for hydration-added elements
|
|
1133
|
+
var observer = new MutationObserver(function() {
|
|
1134
|
+
executeScript_${index}();
|
|
1135
|
+
if (executed) observer.disconnect();
|
|
1136
|
+
});
|
|
1137
|
+
if (!executed) {
|
|
1138
|
+
observer.observe(document.body || document.documentElement, { childList: true, subtree: true });
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
// Single fallback timeout
|
|
1142
|
+
setTimeout(function() {
|
|
1143
|
+
executeScript_${index}();
|
|
1144
|
+
observer.disconnect();
|
|
1145
|
+
}, 1000);
|
|
1146
|
+
})();`;
|
|
1147
|
+
}).join(`
|
|
1148
|
+
`);
|
|
1149
|
+
return `<script>
|
|
1150
|
+
(function() {
|
|
1151
|
+
${scriptCode}
|
|
1152
|
+
})();
|
|
1153
|
+
</script>`;
|
|
1154
|
+
}, getAndClearClientScripts = (requestId) => {
|
|
1155
|
+
const id = requestId || ssrContextGetter?.();
|
|
1156
|
+
if (!id)
|
|
1157
|
+
return [];
|
|
1158
|
+
const scripts = scriptRegistry.get(id);
|
|
1159
|
+
if (!scripts) {
|
|
1160
|
+
return [];
|
|
1618
1161
|
}
|
|
1619
|
-
|
|
1162
|
+
const scriptArray = Array.from(scripts);
|
|
1163
|
+
scriptRegistry.delete(id);
|
|
1164
|
+
return scriptArray;
|
|
1620
1165
|
};
|
|
1621
|
-
var
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
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
|
-
];
|
|
1166
|
+
var init_registerClientScript = __esm(() => {
|
|
1167
|
+
scriptRegistry = new Map;
|
|
1168
|
+
if (typeof globalThis !== "undefined") {
|
|
1169
|
+
Object.assign(globalThis, { registerClientScript });
|
|
1170
|
+
}
|
|
1640
1171
|
});
|
|
1641
1172
|
|
|
1642
|
-
// src/
|
|
1643
|
-
var
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
},
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
const
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
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]
|
|
1173
|
+
// src/angular/ssrRender.ts
|
|
1174
|
+
var routePropsCache, cacheRouteData = (pagePath, data) => {
|
|
1175
|
+
const cacheKey = pagePath.split("?")[0] ?? pagePath;
|
|
1176
|
+
routePropsCache.set(cacheKey, data);
|
|
1177
|
+
}, getCachedRouteData = (pagePath) => routePropsCache.get(pagePath), selectorCache, buildDeps = (ssrResult, baseDeps) => {
|
|
1178
|
+
if (!ssrResult?.core) {
|
|
1179
|
+
return baseDeps;
|
|
1180
|
+
}
|
|
1181
|
+
const { common, core, platformBrowser, platformServer } = ssrResult;
|
|
1182
|
+
return {
|
|
1183
|
+
APP_BASE_HREF: common?.APP_BASE_HREF ?? baseDeps.APP_BASE_HREF,
|
|
1184
|
+
bootstrapApplication: platformBrowser?.bootstrapApplication ?? baseDeps.bootstrapApplication,
|
|
1185
|
+
DomSanitizer: platformBrowser?.DomSanitizer ?? baseDeps.DomSanitizer,
|
|
1186
|
+
provideClientHydration: platformBrowser?.provideClientHydration ?? baseDeps.provideClientHydration,
|
|
1187
|
+
provideServerRendering: platformServer?.provideServerRendering ?? baseDeps.provideServerRendering,
|
|
1188
|
+
provideZonelessChangeDetection: core.provideZonelessChangeDetection,
|
|
1189
|
+
reflectComponentType: core.reflectComponentType,
|
|
1190
|
+
renderApplication: platformServer?.renderApplication ?? baseDeps.renderApplication,
|
|
1191
|
+
Sanitizer: core.Sanitizer,
|
|
1192
|
+
SecurityContext: core.SecurityContext
|
|
1671
1193
|
};
|
|
1672
|
-
|
|
1673
|
-
|
|
1194
|
+
}, buildProviders = (deps, sanitizer, maybeProps, tokenMap) => {
|
|
1195
|
+
const providers = [
|
|
1196
|
+
deps.provideServerRendering(),
|
|
1197
|
+
deps.provideClientHydration(),
|
|
1198
|
+
deps.provideZonelessChangeDetection(),
|
|
1199
|
+
{ provide: deps.APP_BASE_HREF, useValue: "/" },
|
|
1200
|
+
{
|
|
1201
|
+
provide: deps.DomSanitizer,
|
|
1202
|
+
useValue: sanitizer
|
|
1203
|
+
},
|
|
1204
|
+
{ provide: deps.Sanitizer, useValue: sanitizer }
|
|
1205
|
+
];
|
|
1206
|
+
if (!maybeProps) {
|
|
1207
|
+
return providers;
|
|
1208
|
+
}
|
|
1209
|
+
const propProviders = Object.entries(maybeProps).map(([propName, propValue]) => ({
|
|
1210
|
+
token: tokenMap.get(toScreamingSnake(propName)),
|
|
1211
|
+
value: propValue
|
|
1212
|
+
})).filter((entry) => entry.token).map((entry) => ({ provide: entry.token, useValue: entry.value }));
|
|
1213
|
+
return [...providers, ...propProviders];
|
|
1214
|
+
}, clearSelectorCache = () => selectorCache.clear(), isInjectionToken = (value) => {
|
|
1215
|
+
if (!value || typeof value !== "object") {
|
|
1216
|
+
return false;
|
|
1674
1217
|
}
|
|
1218
|
+
return "ngMetadataName" in value && value.ngMetadataName === "InjectionToken";
|
|
1219
|
+
}, discoverTokens = (pageModule) => new Map(Object.entries(pageModule).filter(([, value]) => isInjectionToken(value))), loadSsrDeps = async (pagePath) => {
|
|
1220
|
+
const ssrDepsPath = (pagePath.split("?")[0] ?? pagePath).replace(/\.js$/, ".ssr-deps.js");
|
|
1675
1221
|
try {
|
|
1676
|
-
const
|
|
1677
|
-
const
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
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
|
-
});
|
|
1222
|
+
const ssrDeps = await import(ssrDepsPath);
|
|
1223
|
+
const result = {
|
|
1224
|
+
common: ssrDeps.__angularCommon,
|
|
1225
|
+
core: ssrDeps.__angularCore,
|
|
1226
|
+
platformBrowser: ssrDeps.__angularPlatformBrowser,
|
|
1227
|
+
platformServer: ssrDeps.__angularPlatformServer
|
|
1694
1228
|
};
|
|
1695
|
-
return
|
|
1696
|
-
} catch
|
|
1697
|
-
|
|
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
|
-
});
|
|
1229
|
+
return result;
|
|
1230
|
+
} catch {
|
|
1231
|
+
return null;
|
|
1706
1232
|
}
|
|
1707
|
-
},
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
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;
|
|
1233
|
+
}, resolveSelector = (deps, pagePath, PageComponent) => {
|
|
1234
|
+
const cached = selectorCache.get(pagePath);
|
|
1235
|
+
if (cached) {
|
|
1236
|
+
return cached;
|
|
1730
1237
|
}
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
const entries = collectFrameworkIslands(manifest, prefix);
|
|
1738
|
-
if (entries)
|
|
1739
|
-
islands[framework] = entries;
|
|
1740
|
-
}
|
|
1741
|
-
return islands;
|
|
1742
|
-
}, getIslandManifestKey = (framework, component) => `Island${toIslandFrameworkSegment(framework)}${component}`;
|
|
1743
|
-
|
|
1744
|
-
// src/core/islands.ts
|
|
1745
|
-
function getIslandComponent(component) {
|
|
1746
|
-
if (isIslandComponentDefinition(component)) {
|
|
1747
|
-
return component.component;
|
|
1238
|
+
const selector = deps.reflectComponentType(PageComponent)?.selector ?? "ng-app";
|
|
1239
|
+
selectorCache.set(pagePath, selector);
|
|
1240
|
+
return selector;
|
|
1241
|
+
}, injectBeforeClose = (html, snippet) => {
|
|
1242
|
+
if (html.includes("</body>")) {
|
|
1243
|
+
return html.replace("</body>", `${snippet}</body>`);
|
|
1748
1244
|
}
|
|
1749
|
-
|
|
1750
|
-
}
|
|
1751
|
-
var defineIslandComponent = (component, options) => ({
|
|
1752
|
-
component,
|
|
1753
|
-
export: options.export,
|
|
1754
|
-
source: options.source
|
|
1755
|
-
}), defineIslandRegistry = (registry) => registry, isRecord2 = (value) => typeof value === "object" && value !== null, getIslandBuildReference = (component) => {
|
|
1756
|
-
if (!isIslandComponentDefinition(component))
|
|
1757
|
-
return null;
|
|
1758
|
-
return {
|
|
1759
|
-
export: component.export,
|
|
1760
|
-
source: component.source
|
|
1761
|
-
};
|
|
1762
|
-
}, isIslandComponentDefinition = (value) => isRecord2(value) && ("component" in value) && ("source" in value) && typeof value.source === "string", parseIslandProps = (rawProps) => {
|
|
1763
|
-
if (!rawProps)
|
|
1764
|
-
return {};
|
|
1765
|
-
return JSON.parse(rawProps);
|
|
1766
|
-
}, serializeIslandProps = (props) => JSON.stringify(props ?? {});
|
|
1767
|
-
var init_islands = () => {};
|
|
1768
|
-
|
|
1769
|
-
// src/core/islandMarkupAttributes.ts
|
|
1770
|
-
var getIslandMarkerAttributes = (props, islandId) => ({
|
|
1771
|
-
"data-component": props.component,
|
|
1772
|
-
"data-framework": props.framework,
|
|
1773
|
-
"data-hydrate": props.hydrate ?? "load",
|
|
1774
|
-
"data-island": "true",
|
|
1775
|
-
...islandId ? { "data-island-id": islandId } : {},
|
|
1776
|
-
"data-props": serializeIslandProps(props.props)
|
|
1777
|
-
}), escapeHtmlAttribute = (value) => value.replaceAll("&", "&").replaceAll('"', """).replaceAll("<", "<").replaceAll(">", ">"), serializeIslandAttributes = (attributes) => Object.entries(attributes).map(([key, value]) => `${key}="${escapeHtmlAttribute(value)}"`).join(" ");
|
|
1778
|
-
var init_islandMarkupAttributes = __esm(() => {
|
|
1779
|
-
init_islands();
|
|
1780
|
-
});
|
|
1781
|
-
|
|
1782
|
-
// src/core/currentIslandRegistry.ts
|
|
1783
|
-
var requireCurrentIslandRegistry = () => {
|
|
1784
|
-
const registry = globalThis.__absoluteIslandRegistry;
|
|
1785
|
-
if (!registry) {
|
|
1786
|
-
throw new Error("No island registry is active. Configure `islands.registry` in absolute.config.ts before rendering <Island />.");
|
|
1245
|
+
if (html.includes("</html>")) {
|
|
1246
|
+
return html.replace("</html>", `${snippet}</html>`);
|
|
1787
1247
|
}
|
|
1788
|
-
return
|
|
1789
|
-
},
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
1795
|
-
import { dirname, join, resolve } from "path";
|
|
1796
|
-
var applyInjectorPatch = (chunkPath, content) => {
|
|
1797
|
-
if (content.includes('Symbol.for("angular.currentInjector")')) {
|
|
1798
|
-
return;
|
|
1248
|
+
return html + snippet;
|
|
1249
|
+
}, injectSsrScripts = (html, requestId, indexPath, props) => {
|
|
1250
|
+
let result = html;
|
|
1251
|
+
const registeredScripts = getAndClearClientScripts(requestId);
|
|
1252
|
+
if (registeredScripts.length > 0) {
|
|
1253
|
+
result = injectBeforeClose(result, generateClientScriptCode(registeredScripts));
|
|
1799
1254
|
}
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
"function getCurrentInjector() {",
|
|
1803
|
-
" return _currentInjector;",
|
|
1804
|
-
"}",
|
|
1805
|
-
"function setCurrentInjector(injector) {",
|
|
1806
|
-
" const former = _currentInjector;",
|
|
1807
|
-
" _currentInjector = injector;",
|
|
1808
|
-
" return former;",
|
|
1809
|
-
"}"
|
|
1810
|
-
].join(`
|
|
1811
|
-
`);
|
|
1812
|
-
const replacement = [
|
|
1813
|
-
'const _injSym = Symbol.for("angular.currentInjector");',
|
|
1814
|
-
"if (!globalThis[_injSym]) globalThis[_injSym] = { v: undefined };",
|
|
1815
|
-
"function getCurrentInjector() {",
|
|
1816
|
-
" return globalThis[_injSym].v;",
|
|
1817
|
-
"}",
|
|
1818
|
-
"function setCurrentInjector(injector) {",
|
|
1819
|
-
" const former = globalThis[_injSym].v;",
|
|
1820
|
-
" globalThis[_injSym].v = injector;",
|
|
1821
|
-
" return former;",
|
|
1822
|
-
"}"
|
|
1823
|
-
].join(`
|
|
1824
|
-
`);
|
|
1825
|
-
const patched = content.replace(original, replacement);
|
|
1826
|
-
if (patched === content) {
|
|
1827
|
-
return;
|
|
1255
|
+
if (props) {
|
|
1256
|
+
result = injectBeforeClose(result, `<script>window.__ABS_ANGULAR_PAGE_PROPS__ = ${JSON.stringify(props)};</script>`);
|
|
1828
1257
|
}
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
if (existsSync(join(fromProject, "package.json"))) {
|
|
1833
|
-
return fromProject;
|
|
1258
|
+
if (indexPath) {
|
|
1259
|
+
const escapedIndexPath = JSON.stringify(indexPath);
|
|
1260
|
+
result = injectBeforeClose(result, `<script>import(${escapedIndexPath});</script>`);
|
|
1834
1261
|
}
|
|
1835
|
-
return
|
|
1836
|
-
},
|
|
1262
|
+
return result;
|
|
1263
|
+
}, renderAngularApp = async (deps, PageComponent, providers, document2) => {
|
|
1264
|
+
const bootstrap = (context) => deps.bootstrapApplication(PageComponent, { providers }, context);
|
|
1265
|
+
return withSuppressedAngularDevLogs(() => deps.renderApplication(bootstrap, {
|
|
1266
|
+
document: document2,
|
|
1267
|
+
platformProviders: [],
|
|
1268
|
+
url: "/"
|
|
1269
|
+
}));
|
|
1270
|
+
}, withSuppressedAngularDevLogs = async (render) => {
|
|
1271
|
+
const origLog = console.log;
|
|
1272
|
+
console.log = (...args) => {
|
|
1273
|
+
if (typeof args[0] === "string" && args[0].includes("development mode")) {
|
|
1274
|
+
return;
|
|
1275
|
+
}
|
|
1276
|
+
origLog.apply(console, args);
|
|
1277
|
+
};
|
|
1837
1278
|
try {
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
applyInjectorPatch(chunkPath, content);
|
|
1842
|
-
} catch {}
|
|
1843
|
-
};
|
|
1844
|
-
var init_injectorPatch = __esm(() => {
|
|
1845
|
-
patchAngularInjectorSingleton();
|
|
1846
|
-
});
|
|
1847
|
-
|
|
1848
|
-
// src/angular/resolveAngularPackage.ts
|
|
1849
|
-
import { existsSync as existsSync2 } from "fs";
|
|
1850
|
-
import { resolve as resolve2 } from "path";
|
|
1851
|
-
var resolveAngularPackage = (specifier) => {
|
|
1852
|
-
const fromProject = resolve2(process.cwd(), "node_modules", specifier);
|
|
1853
|
-
if (existsSync2(fromProject)) {
|
|
1854
|
-
return fromProject;
|
|
1279
|
+
return await render();
|
|
1280
|
+
} finally {
|
|
1281
|
+
console.log = origLog;
|
|
1855
1282
|
}
|
|
1856
|
-
return specifier;
|
|
1857
1283
|
};
|
|
1858
|
-
var
|
|
1284
|
+
var init_ssrRender = __esm(() => {
|
|
1285
|
+
init_registerClientScript();
|
|
1286
|
+
routePropsCache = new Map;
|
|
1287
|
+
selectorCache = new Map;
|
|
1288
|
+
});
|
|
1859
1289
|
|
|
1860
|
-
// src/angular/
|
|
1861
|
-
var
|
|
1862
|
-
__export(
|
|
1863
|
-
|
|
1290
|
+
// src/angular/islands.ts
|
|
1291
|
+
var exports_islands = {};
|
|
1292
|
+
__export(exports_islands, {
|
|
1293
|
+
renderAngularIslandToHtml: () => renderAngularIslandToHtml,
|
|
1294
|
+
mountAngularIsland: () => mountAngularIsland,
|
|
1295
|
+
getAngularIslandSelector: () => getAngularIslandSelector
|
|
1864
1296
|
});
|
|
1865
|
-
var
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
const head = doc.createElement("head");
|
|
1870
|
-
doc.documentElement.insertBefore(head, doc.documentElement.firstChild);
|
|
1871
|
-
}, applyPatches = async () => {
|
|
1872
|
-
const { \u{275}DominoAdapter } = await import(resolveAngularPackage("@angular/platform-server"));
|
|
1873
|
-
if (!\u{275}DominoAdapter?.prototype) {
|
|
1874
|
-
console.warn("[Angular Patch] \u0275DominoAdapter not found, skipping patches");
|
|
1875
|
-
return false;
|
|
1297
|
+
var angularIslandSelector = "abs-angular-island", getAngularIslandSelector = (_islandId) => angularIslandSelector, getSelectorFromRenderedIsland = (rootElement) => {
|
|
1298
|
+
const firstChild = rootElement.firstElementChild;
|
|
1299
|
+
if (!(firstChild instanceof HTMLElement)) {
|
|
1300
|
+
return null;
|
|
1876
1301
|
}
|
|
1877
|
-
const
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
return origGetBaseHref.call(this, doc);
|
|
1884
|
-
};
|
|
1885
|
-
const origCreateHtmlDocument = proto.createHtmlDocument;
|
|
1886
|
-
proto.createHtmlDocument = function() {
|
|
1887
|
-
const doc = origCreateHtmlDocument.call(this);
|
|
1888
|
-
ensureHead(doc);
|
|
1889
|
-
return doc;
|
|
1890
|
-
};
|
|
1891
|
-
const origGetDefaultDocument = proto.getDefaultDocument;
|
|
1892
|
-
proto.getDefaultDocument = function() {
|
|
1893
|
-
const doc = origGetDefaultDocument.call(this);
|
|
1894
|
-
ensureHead(doc);
|
|
1895
|
-
return doc;
|
|
1896
|
-
};
|
|
1897
|
-
return true;
|
|
1898
|
-
};
|
|
1899
|
-
var init_angularPatch = __esm(() => {
|
|
1900
|
-
init_resolveAngularPackage();
|
|
1901
|
-
});
|
|
1902
|
-
|
|
1903
|
-
// src/angular/angularDeps.ts
|
|
1904
|
-
var initDominoAdapter = (platformServer) => {
|
|
1905
|
-
try {
|
|
1906
|
-
const DominoAdapter = platformServer.\u{275}DominoAdapter;
|
|
1907
|
-
DominoAdapter?.makeCurrent?.();
|
|
1908
|
-
} catch (err) {
|
|
1909
|
-
console.error("Failed to initialize DominoAdapter:", err);
|
|
1302
|
+
const selector = firstChild.tagName.toLowerCase();
|
|
1303
|
+
return selector.length > 0 ? selector : null;
|
|
1304
|
+
}, getClientAngularComponentSelector = (component) => {
|
|
1305
|
+
const maybeDef = Reflect.get(component, "\u0275cmp");
|
|
1306
|
+
if (typeof maybeDef !== "object" || maybeDef === null) {
|
|
1307
|
+
return null;
|
|
1910
1308
|
}
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
const { applyPatches: applyPatches2 } = await Promise.resolve().then(() => (init_angularPatch(), exports_angularPatch));
|
|
1915
|
-
await applyPatches2();
|
|
1916
|
-
const [platformBrowser, platformServer, common, core] = await Promise.all([
|
|
1917
|
-
import(resolveAngularPackage("@angular/platform-browser")),
|
|
1918
|
-
import(resolveAngularPackage("@angular/platform-server")),
|
|
1919
|
-
import(resolveAngularPackage("@angular/common")),
|
|
1920
|
-
import(resolveAngularPackage("@angular/core"))
|
|
1921
|
-
]);
|
|
1922
|
-
if (false) {}
|
|
1923
|
-
initDominoAdapter(platformServer);
|
|
1924
|
-
return {
|
|
1925
|
-
APP_BASE_HREF: common.APP_BASE_HREF,
|
|
1926
|
-
bootstrapApplication: platformBrowser.bootstrapApplication,
|
|
1927
|
-
DomSanitizer: platformBrowser.DomSanitizer,
|
|
1928
|
-
provideClientHydration: platformBrowser.provideClientHydration,
|
|
1929
|
-
provideServerRendering: platformServer.provideServerRendering,
|
|
1930
|
-
provideZonelessChangeDetection: core.provideZonelessChangeDetection,
|
|
1931
|
-
reflectComponentType: core.reflectComponentType,
|
|
1932
|
-
renderApplication: platformServer.renderApplication,
|
|
1933
|
-
Sanitizer: core.Sanitizer,
|
|
1934
|
-
SecurityContext: core.SecurityContext
|
|
1935
|
-
};
|
|
1936
|
-
}, angularDeps = null, getAngularDeps = () => {
|
|
1937
|
-
if (!angularDeps) {
|
|
1938
|
-
angularDeps = loadAngularDeps();
|
|
1939
|
-
}
|
|
1940
|
-
return angularDeps;
|
|
1941
|
-
};
|
|
1942
|
-
var init_angularDeps = __esm(() => {
|
|
1943
|
-
init_injectorPatch();
|
|
1944
|
-
init_resolveAngularPackage();
|
|
1945
|
-
});
|
|
1946
|
-
|
|
1947
|
-
// src/utils/registerClientScript.ts
|
|
1948
|
-
var scriptRegistry, requestCounter = 0, getRequestId = () => `req_${Date.now()}_${++requestCounter}`, ssrContextGetter = null, getSsrContextId = () => ssrContextGetter?.() || Object.getOwnPropertyDescriptor(globalThis, "__absolutejs_requestId")?.value, registerClientScript = (script, requestId) => {
|
|
1949
|
-
const id = requestId || getSsrContextId() || getRequestId();
|
|
1950
|
-
if (!scriptRegistry.has(id)) {
|
|
1951
|
-
scriptRegistry.set(id, new Set);
|
|
1952
|
-
}
|
|
1953
|
-
scriptRegistry.get(id)?.add(script);
|
|
1954
|
-
return id;
|
|
1955
|
-
}, setSsrContextGetter = (getter) => {
|
|
1956
|
-
ssrContextGetter = getter;
|
|
1957
|
-
}, clearAllClientScripts = () => {
|
|
1958
|
-
scriptRegistry.clear();
|
|
1959
|
-
}, generateClientScriptCode = (scripts) => {
|
|
1960
|
-
if (scripts.length === 0) {
|
|
1961
|
-
return "";
|
|
1962
|
-
}
|
|
1963
|
-
const scriptCode = scripts.map((script, index) => {
|
|
1964
|
-
const funcString = script.toString();
|
|
1965
|
-
const bodyMatch = funcString.match(/\{([\s\S]*)\}/);
|
|
1966
|
-
if (!bodyMatch || !bodyMatch[1]) {
|
|
1967
|
-
return "";
|
|
1968
|
-
}
|
|
1969
|
-
const body = bodyMatch[1].trim();
|
|
1970
|
-
return `
|
|
1971
|
-
(function() {
|
|
1972
|
-
var executed = false;
|
|
1973
|
-
function executeScript_${index}() {
|
|
1974
|
-
if (executed) return;
|
|
1975
|
-
executed = true;
|
|
1976
|
-
${body}
|
|
1977
|
-
}
|
|
1978
|
-
|
|
1979
|
-
if (document.readyState === 'complete' || document.readyState === 'interactive') {
|
|
1980
|
-
executeScript_${index}();
|
|
1981
|
-
} else {
|
|
1982
|
-
document.addEventListener('DOMContentLoaded', executeScript_${index});
|
|
1983
|
-
}
|
|
1984
|
-
|
|
1985
|
-
// Watch for hydration-added elements
|
|
1986
|
-
var observer = new MutationObserver(function() {
|
|
1987
|
-
executeScript_${index}();
|
|
1988
|
-
if (executed) observer.disconnect();
|
|
1989
|
-
});
|
|
1990
|
-
if (!executed) {
|
|
1991
|
-
observer.observe(document.body || document.documentElement, { childList: true, subtree: true });
|
|
1992
|
-
}
|
|
1993
|
-
|
|
1994
|
-
// Single fallback timeout
|
|
1995
|
-
setTimeout(function() {
|
|
1996
|
-
executeScript_${index}();
|
|
1997
|
-
observer.disconnect();
|
|
1998
|
-
}, 1000);
|
|
1999
|
-
})();`;
|
|
2000
|
-
}).join(`
|
|
2001
|
-
`);
|
|
2002
|
-
return `<script>
|
|
2003
|
-
(function() {
|
|
2004
|
-
${scriptCode}
|
|
2005
|
-
})();
|
|
2006
|
-
</script>`;
|
|
2007
|
-
}, getAndClearClientScripts = (requestId) => {
|
|
2008
|
-
const id = requestId || ssrContextGetter?.();
|
|
2009
|
-
if (!id)
|
|
2010
|
-
return [];
|
|
2011
|
-
const scripts = scriptRegistry.get(id);
|
|
2012
|
-
if (!scripts) {
|
|
2013
|
-
return [];
|
|
2014
|
-
}
|
|
2015
|
-
const scriptArray = Array.from(scripts);
|
|
2016
|
-
scriptRegistry.delete(id);
|
|
2017
|
-
return scriptArray;
|
|
2018
|
-
};
|
|
2019
|
-
var init_registerClientScript = __esm(() => {
|
|
2020
|
-
scriptRegistry = new Map;
|
|
2021
|
-
if (typeof globalThis !== "undefined") {
|
|
2022
|
-
Object.assign(globalThis, { registerClientScript });
|
|
2023
|
-
}
|
|
2024
|
-
});
|
|
2025
|
-
|
|
2026
|
-
// src/angular/ssrRender.ts
|
|
2027
|
-
var routePropsCache, cacheRouteData = (pagePath, data) => {
|
|
2028
|
-
const cacheKey = pagePath.split("?")[0] ?? pagePath;
|
|
2029
|
-
routePropsCache.set(cacheKey, data);
|
|
2030
|
-
}, getCachedRouteData = (pagePath) => routePropsCache.get(pagePath), selectorCache, buildDeps = (ssrResult, baseDeps) => {
|
|
2031
|
-
if (!ssrResult?.core) {
|
|
2032
|
-
return baseDeps;
|
|
2033
|
-
}
|
|
2034
|
-
const { common, core, platformBrowser, platformServer } = ssrResult;
|
|
2035
|
-
return {
|
|
2036
|
-
APP_BASE_HREF: common?.APP_BASE_HREF ?? baseDeps.APP_BASE_HREF,
|
|
2037
|
-
bootstrapApplication: platformBrowser?.bootstrapApplication ?? baseDeps.bootstrapApplication,
|
|
2038
|
-
DomSanitizer: platformBrowser?.DomSanitizer ?? baseDeps.DomSanitizer,
|
|
2039
|
-
provideClientHydration: platformBrowser?.provideClientHydration ?? baseDeps.provideClientHydration,
|
|
2040
|
-
provideServerRendering: platformServer?.provideServerRendering ?? baseDeps.provideServerRendering,
|
|
2041
|
-
provideZonelessChangeDetection: core.provideZonelessChangeDetection,
|
|
2042
|
-
reflectComponentType: core.reflectComponentType,
|
|
2043
|
-
renderApplication: platformServer?.renderApplication ?? baseDeps.renderApplication,
|
|
2044
|
-
Sanitizer: core.Sanitizer,
|
|
2045
|
-
SecurityContext: core.SecurityContext
|
|
2046
|
-
};
|
|
2047
|
-
}, buildProviders = (deps, sanitizer, maybeProps, tokenMap) => {
|
|
2048
|
-
const providers = [
|
|
2049
|
-
deps.provideServerRendering(),
|
|
2050
|
-
deps.provideClientHydration(),
|
|
2051
|
-
deps.provideZonelessChangeDetection(),
|
|
2052
|
-
{ provide: deps.APP_BASE_HREF, useValue: "/" },
|
|
2053
|
-
{
|
|
2054
|
-
provide: deps.DomSanitizer,
|
|
2055
|
-
useValue: sanitizer
|
|
2056
|
-
},
|
|
2057
|
-
{ provide: deps.Sanitizer, useValue: sanitizer }
|
|
2058
|
-
];
|
|
2059
|
-
if (!maybeProps) {
|
|
2060
|
-
return providers;
|
|
2061
|
-
}
|
|
2062
|
-
const propProviders = Object.entries(maybeProps).map(([propName, propValue]) => ({
|
|
2063
|
-
token: tokenMap.get(toScreamingSnake(propName)),
|
|
2064
|
-
value: propValue
|
|
2065
|
-
})).filter((entry) => entry.token).map((entry) => ({ provide: entry.token, useValue: entry.value }));
|
|
2066
|
-
return [...providers, ...propProviders];
|
|
2067
|
-
}, clearSelectorCache = () => selectorCache.clear(), isInjectionToken = (value) => {
|
|
2068
|
-
if (!value || typeof value !== "object") {
|
|
2069
|
-
return false;
|
|
2070
|
-
}
|
|
2071
|
-
return "ngMetadataName" in value && value.ngMetadataName === "InjectionToken";
|
|
2072
|
-
}, discoverTokens = (pageModule) => new Map(Object.entries(pageModule).filter(([, value]) => isInjectionToken(value))), loadSsrDeps = async (pagePath) => {
|
|
2073
|
-
const ssrDepsPath = (pagePath.split("?")[0] ?? pagePath).replace(/\.js$/, ".ssr-deps.js");
|
|
2074
|
-
try {
|
|
2075
|
-
const ssrDeps = await import(ssrDepsPath);
|
|
2076
|
-
const result = {
|
|
2077
|
-
common: ssrDeps.__angularCommon,
|
|
2078
|
-
core: ssrDeps.__angularCore,
|
|
2079
|
-
platformBrowser: ssrDeps.__angularPlatformBrowser,
|
|
2080
|
-
platformServer: ssrDeps.__angularPlatformServer
|
|
2081
|
-
};
|
|
2082
|
-
return result;
|
|
2083
|
-
} catch {
|
|
2084
|
-
return null;
|
|
2085
|
-
}
|
|
2086
|
-
}, resolveSelector = (deps, pagePath, PageComponent) => {
|
|
2087
|
-
const cached = selectorCache.get(pagePath);
|
|
2088
|
-
if (cached) {
|
|
2089
|
-
return cached;
|
|
2090
|
-
}
|
|
2091
|
-
const selector = deps.reflectComponentType(PageComponent)?.selector ?? "ng-app";
|
|
2092
|
-
selectorCache.set(pagePath, selector);
|
|
2093
|
-
return selector;
|
|
2094
|
-
}, injectBeforeClose = (html, snippet) => {
|
|
2095
|
-
if (html.includes("</body>")) {
|
|
2096
|
-
return html.replace("</body>", `${snippet}</body>`);
|
|
2097
|
-
}
|
|
2098
|
-
if (html.includes("</html>")) {
|
|
2099
|
-
return html.replace("</html>", `${snippet}</html>`);
|
|
2100
|
-
}
|
|
2101
|
-
return html + snippet;
|
|
2102
|
-
}, injectSsrScripts = (html, requestId, indexPath, props) => {
|
|
2103
|
-
let result = html;
|
|
2104
|
-
const registeredScripts = getAndClearClientScripts(requestId);
|
|
2105
|
-
if (registeredScripts.length > 0) {
|
|
2106
|
-
result = injectBeforeClose(result, generateClientScriptCode(registeredScripts));
|
|
2107
|
-
}
|
|
2108
|
-
if (props) {
|
|
2109
|
-
result = injectBeforeClose(result, `<script>window.__ABS_ANGULAR_PAGE_PROPS__ = ${JSON.stringify(props)};</script>`);
|
|
2110
|
-
}
|
|
2111
|
-
if (indexPath) {
|
|
2112
|
-
const escapedIndexPath = JSON.stringify(indexPath);
|
|
2113
|
-
result = injectBeforeClose(result, `<script>import(${escapedIndexPath});</script>`);
|
|
2114
|
-
}
|
|
2115
|
-
return result;
|
|
2116
|
-
}, renderAngularApp = async (deps, PageComponent, providers, document2) => {
|
|
2117
|
-
const bootstrap = (context) => deps.bootstrapApplication(PageComponent, { providers }, context);
|
|
2118
|
-
return withSuppressedAngularDevLogs(() => deps.renderApplication(bootstrap, {
|
|
2119
|
-
document: document2,
|
|
2120
|
-
platformProviders: [],
|
|
2121
|
-
url: "/"
|
|
2122
|
-
}));
|
|
2123
|
-
}, withSuppressedAngularDevLogs = async (render) => {
|
|
2124
|
-
const origLog = console.log;
|
|
2125
|
-
console.log = (...args) => {
|
|
2126
|
-
if (typeof args[0] === "string" && args[0].includes("development mode")) {
|
|
2127
|
-
return;
|
|
2128
|
-
}
|
|
2129
|
-
origLog.apply(console, args);
|
|
2130
|
-
};
|
|
2131
|
-
try {
|
|
2132
|
-
return await render();
|
|
2133
|
-
} finally {
|
|
2134
|
-
console.log = origLog;
|
|
2135
|
-
}
|
|
2136
|
-
};
|
|
2137
|
-
var init_ssrRender = __esm(() => {
|
|
2138
|
-
init_registerClientScript();
|
|
2139
|
-
routePropsCache = new Map;
|
|
2140
|
-
selectorCache = new Map;
|
|
2141
|
-
});
|
|
2142
|
-
|
|
2143
|
-
// src/angular/islands.ts
|
|
2144
|
-
var exports_islands = {};
|
|
2145
|
-
__export(exports_islands, {
|
|
2146
|
-
renderAngularIslandToHtml: () => renderAngularIslandToHtml,
|
|
2147
|
-
mountAngularIsland: () => mountAngularIsland,
|
|
2148
|
-
getAngularIslandSelector: () => getAngularIslandSelector
|
|
2149
|
-
});
|
|
2150
|
-
var angularIslandSelector = "abs-angular-island", getAngularIslandSelector = (_islandId) => angularIslandSelector, getSelectorFromRenderedIsland = (rootElement) => {
|
|
2151
|
-
const firstChild = rootElement.firstElementChild;
|
|
2152
|
-
if (!(firstChild instanceof HTMLElement)) {
|
|
2153
|
-
return null;
|
|
2154
|
-
}
|
|
2155
|
-
const selector = firstChild.tagName.toLowerCase();
|
|
2156
|
-
return selector.length > 0 ? selector : null;
|
|
2157
|
-
}, getClientAngularComponentSelector = (component) => {
|
|
2158
|
-
const maybeDef = Reflect.get(component, "\u0275cmp");
|
|
2159
|
-
if (typeof maybeDef !== "object" || maybeDef === null) {
|
|
2160
|
-
return null;
|
|
2161
|
-
}
|
|
2162
|
-
const maybeSelectors = Reflect.get(maybeDef, "selectors");
|
|
2163
|
-
if (!Array.isArray(maybeSelectors)) {
|
|
2164
|
-
return null;
|
|
1309
|
+
const maybeSelectors = Reflect.get(maybeDef, "selectors");
|
|
1310
|
+
if (!Array.isArray(maybeSelectors)) {
|
|
1311
|
+
return null;
|
|
2165
1312
|
}
|
|
2166
1313
|
const [firstSelectorGroup] = maybeSelectors;
|
|
2167
1314
|
if (!Array.isArray(firstSelectorGroup)) {
|
|
@@ -2502,12 +1649,27 @@ var init_lowerAwaitSlotSyntax = __esm(() => {
|
|
|
2502
1649
|
});
|
|
2503
1650
|
|
|
2504
1651
|
// src/build/stylePreprocessor.ts
|
|
1652
|
+
var exports_stylePreprocessor = {};
|
|
1653
|
+
__export(exports_stylePreprocessor, {
|
|
1654
|
+
stylePreprocessorPlugin: () => stylePreprocessorPlugin,
|
|
1655
|
+
isStylePath: () => isStylePath,
|
|
1656
|
+
isStyleModulePath: () => isStyleModulePath,
|
|
1657
|
+
isPreprocessableStylePath: () => isPreprocessableStylePath,
|
|
1658
|
+
getStyleBaseName: () => getStyleBaseName,
|
|
1659
|
+
getCssOutputExtension: () => getCssOutputExtension,
|
|
1660
|
+
createSvelteStylePreprocessor: () => createSvelteStylePreprocessor,
|
|
1661
|
+
createStyleTransformConfig: () => createStyleTransformConfig,
|
|
1662
|
+
createStylePreprocessorPlugin: () => createStylePreprocessorPlugin,
|
|
1663
|
+
compileStyleSource: () => compileStyleSource,
|
|
1664
|
+
compileStyleFileIfNeededSync: () => compileStyleFileIfNeededSync,
|
|
1665
|
+
compileStyleFileIfNeeded: () => compileStyleFileIfNeeded
|
|
1666
|
+
});
|
|
2505
1667
|
import { existsSync as existsSync4, readFileSync as readFileSync3 } from "fs";
|
|
2506
1668
|
import { readFile } from "fs/promises";
|
|
2507
1669
|
import { createRequire } from "module";
|
|
2508
1670
|
import { dirname as dirname2, extname, isAbsolute, join as join3, relative, resolve as resolve4 } from "path";
|
|
2509
1671
|
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) => {
|
|
1672
|
+
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
1673
|
const normalized = filePathOrLanguage.toLowerCase();
|
|
2512
1674
|
if (normalized === "scss" || normalized.endsWith(".scss"))
|
|
2513
1675
|
return "scss";
|
|
@@ -2518,7 +1680,13 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
|
|
|
2518
1680
|
if (normalized === "styl" || normalized === "stylus" || normalized.endsWith(".styl") || normalized.endsWith(".stylus"))
|
|
2519
1681
|
return "stylus";
|
|
2520
1682
|
return null;
|
|
2521
|
-
}, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`),
|
|
1683
|
+
}, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`), requireOptionalPeerSync = (specifier) => {
|
|
1684
|
+
try {
|
|
1685
|
+
return requireFromCwd(specifier);
|
|
1686
|
+
} catch {
|
|
1687
|
+
return requireOptionalPeer(specifier);
|
|
1688
|
+
}
|
|
1689
|
+
}, normalizeLoadPaths = (filePath, paths = []) => [
|
|
2522
1690
|
dirname2(filePath),
|
|
2523
1691
|
process.cwd(),
|
|
2524
1692
|
...paths.map((path) => resolve4(process.cwd(), path))
|
|
@@ -2647,8 +1815,72 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
|
|
|
2647
1815
|
}, getSassOptions = (config, language) => ({
|
|
2648
1816
|
...config?.sass ?? {},
|
|
2649
1817
|
...language === "scss" ? config?.scss ?? {} : {}
|
|
2650
|
-
}), getLessOptions = (config) => config?.less ?? {}, getStylusOptions = (config) => config?.stylus ?? {}, withAdditionalData = (contents, additionalData) => additionalData ? `${additionalData}
|
|
2651
|
-
${contents}` : contents,
|
|
1818
|
+
}), getLessOptions = (config) => config?.less ?? {}, getStylusOptions = (config) => config?.stylus ?? {}, createStyleTransformConfig = (stylePreprocessors, postcss) => postcss === undefined ? stylePreprocessors : { ...stylePreprocessors ?? {}, postcss }, withAdditionalData = (contents, additionalData) => additionalData ? `${additionalData}
|
|
1819
|
+
${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
1820
|
+
if (mod && typeof mod === "object" && "default" in mod) {
|
|
1821
|
+
return mod.default ?? mod;
|
|
1822
|
+
}
|
|
1823
|
+
return mod;
|
|
1824
|
+
}, loadPostcssConfigFile = async (configPath) => {
|
|
1825
|
+
const resolved = resolve4(process.cwd(), configPath);
|
|
1826
|
+
const loaded = resolved.endsWith(".cjs") || resolved.endsWith(".cts") ? requireOptionalPeerSync(resolved) : await importOptionalPeer(`${new URL(`file://${resolved}`).href}?t=${Date.now()}`);
|
|
1827
|
+
const config = normalizePostcssModule(loaded);
|
|
1828
|
+
const value = typeof config === "function" ? await config({
|
|
1829
|
+
cwd: process.cwd(),
|
|
1830
|
+
env: "development"
|
|
1831
|
+
}) : config;
|
|
1832
|
+
return normalizePostcssModule(value) ?? {};
|
|
1833
|
+
}, normalizePostcssPlugins = (plugins) => {
|
|
1834
|
+
if (!plugins)
|
|
1835
|
+
return [];
|
|
1836
|
+
if (Array.isArray(plugins))
|
|
1837
|
+
return plugins.filter(Boolean);
|
|
1838
|
+
const resolved = [];
|
|
1839
|
+
for (const [specifier, options] of Object.entries(plugins)) {
|
|
1840
|
+
if (options === false)
|
|
1841
|
+
continue;
|
|
1842
|
+
const mod = normalizePostcssModule(requireOptionalPeerSync(specifier));
|
|
1843
|
+
const plugin = typeof mod === "function" ? mod(options === true ? undefined : options) : mod;
|
|
1844
|
+
if (plugin)
|
|
1845
|
+
resolved.push(plugin);
|
|
1846
|
+
}
|
|
1847
|
+
return resolved;
|
|
1848
|
+
}, resolvePostcssConfig = async (config) => {
|
|
1849
|
+
const inlineConfig = config?.postcss;
|
|
1850
|
+
if (!inlineConfig)
|
|
1851
|
+
return null;
|
|
1852
|
+
const fileConfig = inlineConfig.config ? await loadPostcssConfigFile(inlineConfig.config) : {};
|
|
1853
|
+
const plugins = [
|
|
1854
|
+
...normalizePostcssPlugins(fileConfig.plugins),
|
|
1855
|
+
...normalizePostcssPlugins(inlineConfig.plugins)
|
|
1856
|
+
];
|
|
1857
|
+
if (plugins.length === 0)
|
|
1858
|
+
return null;
|
|
1859
|
+
return {
|
|
1860
|
+
options: {
|
|
1861
|
+
...fileConfig.options ?? {},
|
|
1862
|
+
...inlineConfig.options ?? {}
|
|
1863
|
+
},
|
|
1864
|
+
plugins
|
|
1865
|
+
};
|
|
1866
|
+
}, runPostcss = async (css, filePath, config) => {
|
|
1867
|
+
const postcssConfig = await resolvePostcssConfig(config);
|
|
1868
|
+
if (!postcssConfig)
|
|
1869
|
+
return css;
|
|
1870
|
+
let postcssModule;
|
|
1871
|
+
try {
|
|
1872
|
+
postcssModule = await importOptionalPeer("postcss");
|
|
1873
|
+
} catch {
|
|
1874
|
+
throw missingDependencyError("postcss", filePath);
|
|
1875
|
+
}
|
|
1876
|
+
const postcss = postcssModule.default ?? postcssModule;
|
|
1877
|
+
const result = await postcss(postcssConfig.plugins).process(css, {
|
|
1878
|
+
from: filePath,
|
|
1879
|
+
map: false,
|
|
1880
|
+
...postcssConfig.options
|
|
1881
|
+
});
|
|
1882
|
+
return result.css;
|
|
1883
|
+
}, createSassImporter = (entryFile, loadPaths, language, config) => ({
|
|
2652
1884
|
canonicalize(specifier, options) {
|
|
2653
1885
|
const fromDirectory = options.containingUrl ? dirname2(fileURLToPath(options.containingUrl)) : dirname2(entryFile);
|
|
2654
1886
|
const resolved = resolveImportPath(specifier, fromDirectory, loadPaths, language, config);
|
|
@@ -2727,7 +1959,7 @@ ${contents}` : contents, createSassImporter = (entryFile, loadPaths, language, c
|
|
|
2727
1959
|
syntax: language === "sass" ? "indented" : "scss",
|
|
2728
1960
|
url: new URL(`file://${filePath}`)
|
|
2729
1961
|
});
|
|
2730
|
-
return result.css;
|
|
1962
|
+
return runPostcss(result.css, filePath, config);
|
|
2731
1963
|
}
|
|
2732
1964
|
if (language === "less") {
|
|
2733
1965
|
const options = getLessOptions(config);
|
|
@@ -2752,24 +1984,24 @@ ${contents}` : contents, createSassImporter = (entryFile, loadPaths, language, c
|
|
|
2752
1984
|
createLessFileManager(filePath, loadPaths, config)
|
|
2753
1985
|
]
|
|
2754
1986
|
});
|
|
2755
|
-
return result.css;
|
|
1987
|
+
return runPostcss(result.css, filePath, config);
|
|
2756
1988
|
}
|
|
2757
1989
|
if (language === "stylus") {
|
|
2758
1990
|
const options = getStylusOptions(config);
|
|
2759
1991
|
const loadPaths = normalizeLoadPaths(filePath, options.paths);
|
|
2760
1992
|
const contents = withAdditionalData(preprocessLoadedStyle(rawContents, filePath, filePath, loadPaths, "stylus", config), options.additionalData);
|
|
2761
|
-
return renderStylus(contents, filePath, loadPaths, options);
|
|
1993
|
+
return runPostcss(await renderStylus(contents, filePath, loadPaths, options), filePath, config);
|
|
2762
1994
|
}
|
|
2763
|
-
return rawContents;
|
|
1995
|
+
return runPostcss(rawContents, filePath, config);
|
|
2764
1996
|
}, createStylePreprocessorPlugin = (config) => ({
|
|
2765
1997
|
name: "absolute-style-preprocessor",
|
|
2766
|
-
setup(
|
|
1998
|
+
setup(build2) {
|
|
2767
1999
|
const cssModuleSources = new Map;
|
|
2768
|
-
|
|
2000
|
+
build2.onResolve({ filter: /^absolute-style-module:/ }, ({ path }) => ({
|
|
2769
2001
|
namespace: "absolute-style-module",
|
|
2770
2002
|
path: path.slice("absolute-style-module:".length)
|
|
2771
2003
|
}));
|
|
2772
|
-
|
|
2004
|
+
build2.onLoad({ filter: /\.module\.css$/i, namespace: "absolute-style-module" }, async ({ path }) => {
|
|
2773
2005
|
const source = cssModuleSources.get(path);
|
|
2774
2006
|
if (!source) {
|
|
2775
2007
|
throw new Error(`Unable to resolve CSS module source for ${path}`);
|
|
@@ -2779,7 +2011,7 @@ ${contents}` : contents, createSassImporter = (entryFile, loadPaths, language, c
|
|
|
2779
2011
|
loader: "css"
|
|
2780
2012
|
};
|
|
2781
2013
|
});
|
|
2782
|
-
|
|
2014
|
+
build2.onLoad({ filter: STYLE_EXTENSION_PATTERN }, async ({ path }) => {
|
|
2783
2015
|
if (isStyleModulePath(path)) {
|
|
2784
2016
|
const cssModulePath = path.replace(STYLE_EXTENSION_PATTERN, ".css");
|
|
2785
2017
|
const compiled = await compileStyleSource(path, undefined, undefined, config);
|
|
@@ -2796,6 +2028,10 @@ ${contents}` : contents, createSassImporter = (entryFile, loadPaths, language, c
|
|
|
2796
2028
|
loader: "css"
|
|
2797
2029
|
};
|
|
2798
2030
|
});
|
|
2031
|
+
build2.onLoad({ filter: CSS_EXTENSION_PATTERN }, async ({ path }) => ({
|
|
2032
|
+
contents: await compileStyleSource(path, undefined, undefined, config),
|
|
2033
|
+
loader: "css"
|
|
2034
|
+
}));
|
|
2799
2035
|
}
|
|
2800
2036
|
}), stylePreprocessorPlugin, createSvelteStylePreprocessor = (config) => ({
|
|
2801
2037
|
style: async ({
|
|
@@ -2813,23 +2049,58 @@ ${contents}` : contents, createSassImporter = (entryFile, loadPaths, language, c
|
|
|
2813
2049
|
}
|
|
2814
2050
|
}), compileStyleFileIfNeeded = async (filePath, config) => {
|
|
2815
2051
|
if (!isPreprocessableStylePath(filePath)) {
|
|
2816
|
-
return readFile(filePath, "utf-8");
|
|
2052
|
+
return runPostcss(await readFile(filePath, "utf-8"), filePath, config);
|
|
2817
2053
|
}
|
|
2818
2054
|
return compileStyleSource(filePath, undefined, undefined, config);
|
|
2819
|
-
}
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2055
|
+
}, compileStyleFileIfNeededSync = (filePath, config) => {
|
|
2056
|
+
const rawContents = readFileSync3(filePath, "utf-8");
|
|
2057
|
+
const language = getStyleLanguage(filePath);
|
|
2058
|
+
if (config?.postcss) {
|
|
2059
|
+
throw new Error(`Unable to compile ${filePath}: PostCSS preprocessing is async-only.`);
|
|
2060
|
+
}
|
|
2061
|
+
if (language === "scss" || language === "sass") {
|
|
2062
|
+
const options = getSassOptions(config, language);
|
|
2063
|
+
const packageName = options.implementation ?? "sass";
|
|
2064
|
+
let sass;
|
|
2065
|
+
try {
|
|
2066
|
+
sass = requireOptionalPeerSync(packageName);
|
|
2067
|
+
} catch {
|
|
2068
|
+
throw missingDependencyError(packageName, filePath);
|
|
2069
|
+
}
|
|
2070
|
+
const contents = withAdditionalData(rawContents, options.additionalData);
|
|
2071
|
+
const loadPaths = normalizeLoadPaths(filePath, options.loadPaths);
|
|
2072
|
+
return sass.compileString(contents, {
|
|
2073
|
+
importers: [
|
|
2074
|
+
createSassImporter(filePath, loadPaths, language, config)
|
|
2075
|
+
],
|
|
2076
|
+
loadPaths,
|
|
2077
|
+
style: "expanded",
|
|
2078
|
+
syntax: language === "sass" ? "indented" : "scss",
|
|
2079
|
+
url: new URL(`file://${filePath}`)
|
|
2080
|
+
}).css;
|
|
2081
|
+
}
|
|
2082
|
+
if (language === "less") {
|
|
2083
|
+
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.`);
|
|
2084
|
+
}
|
|
2085
|
+
if (language === "stylus") {
|
|
2086
|
+
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.`);
|
|
2087
|
+
}
|
|
2088
|
+
return rawContents;
|
|
2089
|
+
}, getCssOutputExtension = (filePath) => isPreprocessableStylePath(filePath) ? ".css" : extname(filePath);
|
|
2090
|
+
var init_stylePreprocessor = __esm(() => {
|
|
2091
|
+
CSS_EXTENSION_PATTERN = /\.css$/i;
|
|
2092
|
+
STYLE_EXTENSION_PATTERN = /\.(s[ac]ss|less|styl(?:us)?)$/i;
|
|
2093
|
+
STYLE_MODULE_EXTENSION_PATTERN = /\.module\.(s[ac]ss|less|styl(?:us)?)$/i;
|
|
2094
|
+
STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less|styl(?:us)?)$/i;
|
|
2095
|
+
importOptionalPeer = new Function("specifier", "return import(specifier)");
|
|
2096
|
+
requireOptionalPeer = new Function("specifier", "return require(specifier)");
|
|
2097
|
+
requireFromCwd = createRequire(join3(process.cwd(), "package.json"));
|
|
2098
|
+
stylePreprocessorPlugin = createStylePreprocessorPlugin();
|
|
2828
2099
|
});
|
|
2829
2100
|
|
|
2830
2101
|
// src/core/svelteServerModule.ts
|
|
2831
2102
|
import { mkdir, readdir } from "fs/promises";
|
|
2832
|
-
import { basename
|
|
2103
|
+
import { basename, dirname as dirname3, extname as extname2, join as join4, relative as relative2, resolve as resolve5 } from "path";
|
|
2833
2104
|
var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, ensureRelativeImportPath = (from, target) => {
|
|
2834
2105
|
const importPath = relative2(dirname3(from), target).replace(/\\/g, "/");
|
|
2835
2106
|
return importPath.startsWith(".") ? importPath : `./${importPath}`;
|
|
@@ -2860,7 +2131,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
2860
2131
|
return found;
|
|
2861
2132
|
}
|
|
2862
2133
|
return searchDirectoryLevel(nextStack, targetFileName);
|
|
2863
|
-
}, findSourceFileByBasename = async (searchRoot, targetFileName) => searchDirectoryLevel([searchRoot], targetFileName), normalizeBuiltSvelteFileName = (sourcePath) =>
|
|
2134
|
+
}, findSourceFileByBasename = async (searchRoot, targetFileName) => searchDirectoryLevel([searchRoot], targetFileName), normalizeBuiltSvelteFileName = (sourcePath) => basename(sourcePath).replace(/-[a-z0-9]{6,}(?=\.svelte$)/i, ""), resolveOriginalSourcePath = async (sourcePath) => {
|
|
2864
2135
|
const cachedPath = originalSourcePathCache.get(sourcePath);
|
|
2865
2136
|
if (cachedPath !== undefined) {
|
|
2866
2137
|
return cachedPath;
|
|
@@ -3007,6 +2278,19 @@ var init_svelteServerModule = __esm(() => {
|
|
|
3007
2278
|
});
|
|
3008
2279
|
});
|
|
3009
2280
|
|
|
2281
|
+
// src/core/islandMarkupAttributes.ts
|
|
2282
|
+
var getIslandMarkerAttributes = (props, islandId) => ({
|
|
2283
|
+
"data-component": props.component,
|
|
2284
|
+
"data-framework": props.framework,
|
|
2285
|
+
"data-hydrate": props.hydrate ?? "load",
|
|
2286
|
+
"data-island": "true",
|
|
2287
|
+
...islandId ? { "data-island-id": islandId } : {},
|
|
2288
|
+
"data-props": serializeIslandProps(props.props)
|
|
2289
|
+
}), escapeHtmlAttribute = (value) => value.replaceAll("&", "&").replaceAll('"', """).replaceAll("<", "<").replaceAll(">", ">"), serializeIslandAttributes = (attributes) => Object.entries(attributes).map(([key, value]) => `${key}="${escapeHtmlAttribute(value)}"`).join(" ");
|
|
2290
|
+
var init_islandMarkupAttributes = __esm(() => {
|
|
2291
|
+
init_islands();
|
|
2292
|
+
});
|
|
2293
|
+
|
|
3010
2294
|
// src/core/renderIslandMarkup.ts
|
|
3011
2295
|
var islandSequence = 0, resolvedServerComponentCache, resolvedServerBuildComponentCache, nextIslandId = () => {
|
|
3012
2296
|
islandSequence += 1;
|
|
@@ -3135,29 +2419,6 @@ var init_renderIslandMarkup = __esm(() => {
|
|
|
3135
2419
|
resolvedServerBuildComponentCache = new Map;
|
|
3136
2420
|
});
|
|
3137
2421
|
|
|
3138
|
-
// types/typeGuards.ts
|
|
3139
|
-
var isValidHMRClientMessage = (data) => {
|
|
3140
|
-
if (!data || typeof data !== "object") {
|
|
3141
|
-
return false;
|
|
3142
|
-
}
|
|
3143
|
-
if (!("type" in data) || typeof data.type !== "string") {
|
|
3144
|
-
return false;
|
|
3145
|
-
}
|
|
3146
|
-
switch (data.type) {
|
|
3147
|
-
case "ping":
|
|
3148
|
-
case "ready":
|
|
3149
|
-
case "request-rebuild":
|
|
3150
|
-
case "hydration-error":
|
|
3151
|
-
case "hmr-timing":
|
|
3152
|
-
return true;
|
|
3153
|
-
default:
|
|
3154
|
-
return false;
|
|
3155
|
-
}
|
|
3156
|
-
};
|
|
3157
|
-
|
|
3158
|
-
// types/websocket.ts
|
|
3159
|
-
var WS_READY_STATE_OPEN = 1;
|
|
3160
|
-
|
|
3161
2422
|
// src/build/islandEntries.ts
|
|
3162
2423
|
import {
|
|
3163
2424
|
mkdirSync,
|
|
@@ -3375,6 +2636,17 @@ var init_islandEntries = __esm(() => {
|
|
|
3375
2636
|
];
|
|
3376
2637
|
});
|
|
3377
2638
|
|
|
2639
|
+
// src/core/currentIslandRegistry.ts
|
|
2640
|
+
var requireCurrentIslandRegistry = () => {
|
|
2641
|
+
const registry = globalThis.__absoluteIslandRegistry;
|
|
2642
|
+
if (!registry) {
|
|
2643
|
+
throw new Error("No island registry is active. Configure `islands.registry` in absolute.config.ts before rendering <Island />.");
|
|
2644
|
+
}
|
|
2645
|
+
return registry;
|
|
2646
|
+
}, setCurrentIslandRegistry = (registry) => {
|
|
2647
|
+
globalThis.__absoluteIslandRegistry = registry;
|
|
2648
|
+
};
|
|
2649
|
+
|
|
3378
2650
|
// src/core/staticStreaming.ts
|
|
3379
2651
|
var STATIC_SLOT_TAG_RE, ATTRIBUTE_RE, parseAttributes = (attributeString) => {
|
|
3380
2652
|
const attributes = new Map;
|
|
@@ -3558,41 +2830,898 @@ var ISLAND_TAG_RE_SOURCE = "<(?:absolute-island|island)\\b([^>]*?)(?:\\/\\>|>(?:
|
|
|
3558
2830
|
nextIndex = match.index + fullMatch.length;
|
|
3559
2831
|
match = tagRe.exec(originalHtml);
|
|
3560
2832
|
}
|
|
3561
|
-
return result + originalHtml.slice(nextIndex);
|
|
3562
|
-
}, transformStaticPage = async (pagePath, registry) => {
|
|
3563
|
-
const originalHtml = readFileSync4(pagePath, "utf-8");
|
|
3564
|
-
const transformedHtml = await transformStaticPageHtml(originalHtml, registry);
|
|
3565
|
-
if (transformedHtml !== originalHtml) {
|
|
3566
|
-
writeFileSync3(pagePath, transformedHtml);
|
|
2833
|
+
return result + originalHtml.slice(nextIndex);
|
|
2834
|
+
}, transformStaticPage = async (pagePath, registry) => {
|
|
2835
|
+
const originalHtml = readFileSync4(pagePath, "utf-8");
|
|
2836
|
+
const transformedHtml = await transformStaticPageHtml(originalHtml, registry);
|
|
2837
|
+
if (transformedHtml !== originalHtml) {
|
|
2838
|
+
writeFileSync3(pagePath, transformedHtml);
|
|
2839
|
+
}
|
|
2840
|
+
}, transformCurrentStaticPageHtml = async (html, options = {}) => {
|
|
2841
|
+
const transformedHTMXStreamingHtml = options.enableHTMXStreaming === false ? html : transformStaticHTMXStreamSlotHtml(html);
|
|
2842
|
+
const transformedStreamingHtml = options.enableStaticStreaming === false ? transformedHTMXStreamingHtml : transformStaticStreamingSlotHtml(transformedHTMXStreamingHtml);
|
|
2843
|
+
const islandTagRe = new RegExp(ISLAND_TAG_RE_SOURCE, "i");
|
|
2844
|
+
if (!islandTagRe.test(transformedStreamingHtml)) {
|
|
2845
|
+
return transformedStreamingHtml;
|
|
2846
|
+
}
|
|
2847
|
+
return transformStaticPageHtml(transformedStreamingHtml, requireCurrentIslandRegistry());
|
|
2848
|
+
}, transformStaticPagesWithIslands = async (registryPath, pagePaths) => {
|
|
2849
|
+
if (!registryPath || pagePaths.length === 0) {
|
|
2850
|
+
return;
|
|
2851
|
+
}
|
|
2852
|
+
const { registry } = await loadIslandRegistryBuildInfo(registryPath);
|
|
2853
|
+
await Promise.all(pagePaths.map((pagePath) => transformStaticPage(pagePath, registry)));
|
|
2854
|
+
};
|
|
2855
|
+
var init_staticIslandPages = __esm(() => {
|
|
2856
|
+
init_streamingSlots();
|
|
2857
|
+
init_renderIslandMarkup();
|
|
2858
|
+
init_islandEntries();
|
|
2859
|
+
init_staticStreaming();
|
|
2860
|
+
islandFrameworks = [
|
|
2861
|
+
"react",
|
|
2862
|
+
"svelte",
|
|
2863
|
+
"vue",
|
|
2864
|
+
"angular"
|
|
2865
|
+
];
|
|
2866
|
+
islandHydrationModes = ["load", "idle", "visible", "none"];
|
|
2867
|
+
HTMX_STREAM_SLOT_TAG_RE = /<abs-htmx-stream-slot\b([^>]*?)(?:\/>|>([\s\S]*?)<\/abs-htmx-stream-slot>)/gi;
|
|
2868
|
+
});
|
|
2869
|
+
|
|
2870
|
+
// src/core/islandPageContext.ts
|
|
2871
|
+
var BOOTSTRAP_MANIFEST_KEY = "BootstrapClient", ISLAND_MARKER = 'data-island="true"', MANIFEST_MARKER = "__ABSOLUTE_MANIFEST__", ISLAND_STATE_MARKER = "__ABS_ISLAND_STATE__", CLOSING_HEAD_TAG2 = "</head>", buildIslandsHeadMarkup = (manifest) => {
|
|
2872
|
+
const manifestScript = `<script>window.__ABSOLUTE_MANIFEST__ = ${JSON.stringify(manifest)}</script>`;
|
|
2873
|
+
const islandStateScript = `<script>window.__ABS_ISLAND_STATE__ = ${JSON.stringify(globalThis.__ABS_ISLAND_STATE__ ?? {})}</script>`;
|
|
2874
|
+
const bootstrapPath = manifest[BOOTSTRAP_MANIFEST_KEY];
|
|
2875
|
+
const bootstrapScript = bootstrapPath ? `<script type="module" src="${bootstrapPath}"></script>` : "";
|
|
2876
|
+
return `${manifestScript}${islandStateScript}${bootstrapScript}`;
|
|
2877
|
+
}, injectHeadMarkup = (html, markup) => {
|
|
2878
|
+
const closingHeadIndex = html.indexOf("</head>");
|
|
2879
|
+
if (closingHeadIndex >= 0) {
|
|
2880
|
+
return `${html.slice(0, closingHeadIndex)}${markup}${html.slice(closingHeadIndex)}`;
|
|
2881
|
+
}
|
|
2882
|
+
const openingBodyIndex = html.indexOf("<body");
|
|
2883
|
+
if (openingBodyIndex >= 0) {
|
|
2884
|
+
const bodyStart = html.indexOf(">", openingBodyIndex);
|
|
2885
|
+
if (bodyStart >= 0) {
|
|
2886
|
+
return `${html.slice(0, openingBodyIndex)}<head>${markup}</head>${html.slice(openingBodyIndex)}`;
|
|
2887
|
+
}
|
|
2888
|
+
}
|
|
2889
|
+
return `<!DOCTYPE html><html><head>${markup}</head><body>${html}</body></html>`;
|
|
2890
|
+
}, streamChunkToString2 = (value, decoder) => typeof value === "string" ? value : decoder.decode(value, { stream: true }), flushSafePendingText = (controller, encoder, pending, lookbehind) => {
|
|
2891
|
+
if (pending.length <= lookbehind) {
|
|
2892
|
+
return pending;
|
|
2893
|
+
}
|
|
2894
|
+
const safeText = pending.slice(0, pending.length - lookbehind);
|
|
2895
|
+
controller.enqueue(encoder.encode(safeText));
|
|
2896
|
+
return pending.slice(-lookbehind);
|
|
2897
|
+
}, updateInjectedState = (consumed, injected, pending) => {
|
|
2898
|
+
if (consumed.done) {
|
|
2899
|
+
return { done: true, injected, pending };
|
|
2900
|
+
}
|
|
2901
|
+
return {
|
|
2902
|
+
done: false,
|
|
2903
|
+
injected: consumed.injected,
|
|
2904
|
+
pending: consumed.pending
|
|
2905
|
+
};
|
|
2906
|
+
}, readStreamChunk = async (reader) => {
|
|
2907
|
+
const { done, value } = await reader.read();
|
|
2908
|
+
if (done || !value) {
|
|
2909
|
+
return { done, value: undefined };
|
|
2910
|
+
}
|
|
2911
|
+
return { done, value };
|
|
2912
|
+
}, pipeStreamWithHeadInjection = (stream, markup) => {
|
|
2913
|
+
const encoder = new TextEncoder;
|
|
2914
|
+
const decoder = new TextDecoder;
|
|
2915
|
+
const lookbehind = CLOSING_HEAD_TAG2.length - 1;
|
|
2916
|
+
const processPending = (controller, pending, injected) => {
|
|
2917
|
+
if (injected) {
|
|
2918
|
+
controller.enqueue(encoder.encode(pending));
|
|
2919
|
+
return { injected, pending: "" };
|
|
2920
|
+
}
|
|
2921
|
+
const headIndex = pending.indexOf(CLOSING_HEAD_TAG2);
|
|
2922
|
+
if (headIndex >= 0) {
|
|
2923
|
+
const next = `${pending.slice(0, headIndex)}${markup}${pending.slice(headIndex)}`;
|
|
2924
|
+
controller.enqueue(encoder.encode(next));
|
|
2925
|
+
return { injected: true, pending: "" };
|
|
2926
|
+
}
|
|
2927
|
+
return {
|
|
2928
|
+
injected,
|
|
2929
|
+
pending: flushSafePendingText(controller, encoder, pending, lookbehind)
|
|
2930
|
+
};
|
|
2931
|
+
};
|
|
2932
|
+
const finishHeadInjectionStream = (controller, pending, injected) => {
|
|
2933
|
+
let finalPending = pending + decoder.decode();
|
|
2934
|
+
if (!injected) {
|
|
2935
|
+
finalPending = injectHeadMarkup(finalPending, markup);
|
|
2936
|
+
}
|
|
2937
|
+
if (finalPending.length > 0) {
|
|
2938
|
+
controller.enqueue(encoder.encode(finalPending));
|
|
2939
|
+
}
|
|
2940
|
+
controller.close();
|
|
2941
|
+
};
|
|
2942
|
+
const consumeHeadChunk = async (controller, reader, pending, injected) => {
|
|
2943
|
+
const { done, value } = await readStreamChunk(reader);
|
|
2944
|
+
if (done || !value) {
|
|
2945
|
+
return { done, injected, pending };
|
|
2946
|
+
}
|
|
2947
|
+
const processed = processPending(controller, pending + streamChunkToString2(value, decoder), injected);
|
|
2948
|
+
return {
|
|
2949
|
+
done,
|
|
2950
|
+
injected: processed.injected,
|
|
2951
|
+
pending: processed.pending
|
|
2952
|
+
};
|
|
2953
|
+
};
|
|
2954
|
+
const runHeadInjectionLoop = async (controller, reader) => {
|
|
2955
|
+
const consumeNextHeadChunk = async (injected, pending) => {
|
|
2956
|
+
const consumed = await consumeHeadChunk(controller, reader, pending, injected);
|
|
2957
|
+
const nextState = updateInjectedState(consumed, injected, pending);
|
|
2958
|
+
if (nextState.done) {
|
|
2959
|
+
return { injected, pending };
|
|
2960
|
+
}
|
|
2961
|
+
return consumeNextHeadChunk(nextState.injected, nextState.pending);
|
|
2962
|
+
};
|
|
2963
|
+
return consumeNextHeadChunk(false, "");
|
|
2964
|
+
};
|
|
2965
|
+
return new ReadableStream({
|
|
2966
|
+
async start(controller) {
|
|
2967
|
+
const reader = stream.getReader();
|
|
2968
|
+
try {
|
|
2969
|
+
const { injected, pending } = await runHeadInjectionLoop(controller, reader);
|
|
2970
|
+
finishHeadInjectionStream(controller, pending, injected);
|
|
2971
|
+
} catch (error) {
|
|
2972
|
+
controller.error(error);
|
|
2973
|
+
}
|
|
2974
|
+
}
|
|
2975
|
+
});
|
|
2976
|
+
}, pipeStreamWithIslandMarkerDetection = (stream, markup) => {
|
|
2977
|
+
const encoder = new TextEncoder;
|
|
2978
|
+
const decoder = new TextDecoder;
|
|
2979
|
+
const lookbehind = Math.max(ISLAND_MARKER.length, BYTES_PER_KILOBYTE);
|
|
2980
|
+
const processPending = (controller, pending, injected) => {
|
|
2981
|
+
if (injected) {
|
|
2982
|
+
controller.enqueue(encoder.encode(pending));
|
|
2983
|
+
return { injected, pending: "" };
|
|
2984
|
+
}
|
|
2985
|
+
const markerIndex = pending.indexOf(ISLAND_MARKER);
|
|
2986
|
+
if (markerIndex >= 0) {
|
|
2987
|
+
const tagStart = pending.lastIndexOf("<", markerIndex);
|
|
2988
|
+
const injectAt = tagStart >= 0 ? tagStart : markerIndex;
|
|
2989
|
+
const next = `${pending.slice(0, injectAt)}${markup}${pending.slice(injectAt)}`;
|
|
2990
|
+
controller.enqueue(encoder.encode(next));
|
|
2991
|
+
return { injected: true, pending: "" };
|
|
2992
|
+
}
|
|
2993
|
+
return {
|
|
2994
|
+
injected,
|
|
2995
|
+
pending: flushSafePendingText(controller, encoder, pending, lookbehind)
|
|
2996
|
+
};
|
|
2997
|
+
};
|
|
2998
|
+
const finishIslandMarkerStream = (controller, pending) => {
|
|
2999
|
+
const finalPending = pending + decoder.decode();
|
|
3000
|
+
if (finalPending.length > 0) {
|
|
3001
|
+
controller.enqueue(encoder.encode(finalPending));
|
|
3002
|
+
}
|
|
3003
|
+
controller.close();
|
|
3004
|
+
};
|
|
3005
|
+
const consumeIslandChunk = async (controller, reader, pending, injected) => {
|
|
3006
|
+
const { done, value } = await readStreamChunk(reader);
|
|
3007
|
+
if (done || !value) {
|
|
3008
|
+
return { done, injected, pending };
|
|
3009
|
+
}
|
|
3010
|
+
const processed = processPending(controller, pending + streamChunkToString2(value, decoder), injected);
|
|
3011
|
+
return {
|
|
3012
|
+
done,
|
|
3013
|
+
injected: processed.injected,
|
|
3014
|
+
pending: processed.pending
|
|
3015
|
+
};
|
|
3016
|
+
};
|
|
3017
|
+
const runIslandMarkerLoop = async (controller, reader) => {
|
|
3018
|
+
const consumeNextIslandChunk = async (injected, pending) => {
|
|
3019
|
+
const consumed = await consumeIslandChunk(controller, reader, pending, injected);
|
|
3020
|
+
const nextState = updateInjectedState(consumed, injected, pending);
|
|
3021
|
+
if (nextState.done) {
|
|
3022
|
+
return { injected, pending };
|
|
3023
|
+
}
|
|
3024
|
+
return consumeNextIslandChunk(nextState.injected, nextState.pending);
|
|
3025
|
+
};
|
|
3026
|
+
return consumeNextIslandChunk(false, "");
|
|
3027
|
+
};
|
|
3028
|
+
return new ReadableStream({
|
|
3029
|
+
async start(controller) {
|
|
3030
|
+
const reader = stream.getReader();
|
|
3031
|
+
try {
|
|
3032
|
+
const { pending } = await runIslandMarkerLoop(controller, reader);
|
|
3033
|
+
finishIslandMarkerStream(controller, pending);
|
|
3034
|
+
} catch (error) {
|
|
3035
|
+
controller.error(error);
|
|
3036
|
+
}
|
|
3037
|
+
}
|
|
3038
|
+
});
|
|
3039
|
+
}, htmlContainsIslands = (html) => html.includes(ISLAND_MARKER), injectIslandPageContext = (html, options) => {
|
|
3040
|
+
const manifest = globalThis.__absoluteManifest;
|
|
3041
|
+
const hasIslands = options?.hasIslands ?? htmlContainsIslands(html);
|
|
3042
|
+
if (!manifest || !hasIslands) {
|
|
3043
|
+
return html;
|
|
3044
|
+
}
|
|
3045
|
+
if (html.includes(MANIFEST_MARKER) || html.includes(ISLAND_STATE_MARKER)) {
|
|
3046
|
+
return html;
|
|
3047
|
+
}
|
|
3048
|
+
return injectHeadMarkup(html, buildIslandsHeadMarkup(manifest));
|
|
3049
|
+
}, injectIslandPageContextStream = (stream, options) => {
|
|
3050
|
+
const manifest = globalThis.__absoluteManifest;
|
|
3051
|
+
if (!manifest)
|
|
3052
|
+
return stream;
|
|
3053
|
+
const markup = buildIslandsHeadMarkup(manifest);
|
|
3054
|
+
if (options?.hasIslands === true) {
|
|
3055
|
+
return pipeStreamWithHeadInjection(stream, markup);
|
|
3056
|
+
}
|
|
3057
|
+
if (options?.hasIslands === false) {
|
|
3058
|
+
return stream;
|
|
3059
|
+
}
|
|
3060
|
+
return pipeStreamWithIslandMarkerDetection(stream, markup);
|
|
3061
|
+
}, setCurrentIslandManifest = (manifest) => {
|
|
3062
|
+
globalThis.__absoluteManifest = manifest;
|
|
3063
|
+
};
|
|
3064
|
+
var init_islandPageContext = __esm(() => {
|
|
3065
|
+
init_constants();
|
|
3066
|
+
});
|
|
3067
|
+
|
|
3068
|
+
// src/core/responseEnhancers.ts
|
|
3069
|
+
var toResponse = async (responseLike) => responseLike, cloneHeaders = (response) => {
|
|
3070
|
+
const headers = new Headers(response.headers);
|
|
3071
|
+
return headers;
|
|
3072
|
+
}, enhanceHtmlResponseWithStreamingSlots = (response, {
|
|
3073
|
+
nonce,
|
|
3074
|
+
onError,
|
|
3075
|
+
runtimePlacement,
|
|
3076
|
+
runtimePreludeScript,
|
|
3077
|
+
streamingSlots = [],
|
|
3078
|
+
policy
|
|
3079
|
+
} = {}) => {
|
|
3080
|
+
if (!response.body || streamingSlots.length === 0) {
|
|
3081
|
+
return response;
|
|
3082
|
+
}
|
|
3083
|
+
const body = appendStreamingSlotPatchesToStream(response.body, streamingSlots, {
|
|
3084
|
+
nonce,
|
|
3085
|
+
onError,
|
|
3086
|
+
policy,
|
|
3087
|
+
runtimePlacement,
|
|
3088
|
+
runtimePreludeScript
|
|
3089
|
+
});
|
|
3090
|
+
return new Response(body, {
|
|
3091
|
+
headers: cloneHeaders(response),
|
|
3092
|
+
status: response.status,
|
|
3093
|
+
statusText: response.statusText
|
|
3094
|
+
});
|
|
3095
|
+
}, withStreamingSlots = async (responseLike, options = {}) => enhanceHtmlResponseWithStreamingSlots(await toResponse(responseLike), options), mergeStreamingSlots = (registered, explicit) => {
|
|
3096
|
+
const merged = new Map;
|
|
3097
|
+
for (const slot of registered)
|
|
3098
|
+
merged.set(slot.id, slot);
|
|
3099
|
+
for (const slot of explicit)
|
|
3100
|
+
merged.set(slot.id, slot);
|
|
3101
|
+
return [...merged.values()];
|
|
3102
|
+
}, withRegisteredStreamingSlots = async (renderResponse, options = {}) => {
|
|
3103
|
+
const { result, slots } = await runWithStreamingSlotRegistry(renderResponse);
|
|
3104
|
+
const explicit = options.streamingSlots ?? [];
|
|
3105
|
+
return withStreamingSlots(result, {
|
|
3106
|
+
...options,
|
|
3107
|
+
streamingSlots: mergeStreamingSlots(slots, explicit)
|
|
3108
|
+
});
|
|
3109
|
+
};
|
|
3110
|
+
var init_responseEnhancers = __esm(() => {
|
|
3111
|
+
init_streamingSlots();
|
|
3112
|
+
init_streamingSlotRegistry();
|
|
3113
|
+
});
|
|
3114
|
+
|
|
3115
|
+
// src/core/devRouteRegistrationCallsite.ts
|
|
3116
|
+
var exports_devRouteRegistrationCallsite = {};
|
|
3117
|
+
__export(exports_devRouteRegistrationCallsite, {
|
|
3118
|
+
patchElysiaRouteRegistrationCallsites: () => patchElysiaRouteRegistrationCallsites,
|
|
3119
|
+
getCurrentRouteRegistrationCallsite: () => getCurrentRouteRegistrationCallsite
|
|
3120
|
+
});
|
|
3121
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
3122
|
+
import { Elysia } from "elysia";
|
|
3123
|
+
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 = () => {
|
|
3124
|
+
const value = Reflect.get(globalThis, ROUTE_CALLSITE_STORAGE_KEY);
|
|
3125
|
+
if (value === null || typeof value === "undefined") {
|
|
3126
|
+
return;
|
|
3127
|
+
}
|
|
3128
|
+
return isAsyncLocalStorage2(value) ? value : undefined;
|
|
3129
|
+
}, ensureRouteCallsiteStorage = () => {
|
|
3130
|
+
const existing = getRouteCallsiteStorage();
|
|
3131
|
+
if (existing) {
|
|
3132
|
+
return existing;
|
|
3133
|
+
}
|
|
3134
|
+
const storage = new AsyncLocalStorage;
|
|
3135
|
+
Reflect.set(globalThis, ROUTE_CALLSITE_STORAGE_KEY, storage);
|
|
3136
|
+
return storage;
|
|
3137
|
+
}, normalizeCallsitePath = (value) => value.replace(`${process.cwd()}/`, "").replace(process.cwd(), "").replace(/^\.\/+/, ""), extractRouteRegistrationCallsite = (stack) => {
|
|
3138
|
+
const frames = stack.split(`
|
|
3139
|
+
`).slice(1).map((line) => line.trim());
|
|
3140
|
+
for (const frame of frames) {
|
|
3141
|
+
if (frame.includes("/node_modules/") || frame.includes("/dist/") || frame.includes("/src/core/devRouteRegistrationCallsite.")) {
|
|
3142
|
+
continue;
|
|
3143
|
+
}
|
|
3144
|
+
const locationMatch = frame.match(/\((\/[^)]+:\d+:\d+)\)$/) ?? frame.match(/at (\/[^ ]+:\d+:\d+)$/);
|
|
3145
|
+
if (locationMatch?.[1]) {
|
|
3146
|
+
return normalizeCallsitePath(locationMatch[1]);
|
|
3147
|
+
}
|
|
3148
|
+
}
|
|
3149
|
+
return;
|
|
3150
|
+
}, captureRouteRegistrationCallsite = () => {
|
|
3151
|
+
const { stack } = new Error;
|
|
3152
|
+
if (!stack) {
|
|
3153
|
+
return;
|
|
3154
|
+
}
|
|
3155
|
+
return extractRouteRegistrationCallsite(stack);
|
|
3156
|
+
}, wrapRouteHandlerWithCallsite = (handler, callsite) => {
|
|
3157
|
+
if (typeof handler !== "function" || !callsite) {
|
|
3158
|
+
return handler;
|
|
3159
|
+
}
|
|
3160
|
+
const storage = ensureRouteCallsiteStorage();
|
|
3161
|
+
return function wrappedRouteHandler(...args) {
|
|
3162
|
+
return storage.run({ callsite }, () => Reflect.apply(handler, this, args));
|
|
3163
|
+
};
|
|
3164
|
+
}, getCurrentRouteRegistrationCallsite = () => getRouteCallsiteStorage()?.getStore()?.callsite, patchElysiaRouteRegistrationCallsites = () => {
|
|
3165
|
+
if (false) {}
|
|
3166
|
+
if (Reflect.get(globalThis, ROUTE_CALLSITE_PATCHED_KEY) === true) {
|
|
3167
|
+
return;
|
|
3168
|
+
}
|
|
3169
|
+
const prototype = Elysia.prototype;
|
|
3170
|
+
for (const methodName of ROUTE_METHOD_NAMES) {
|
|
3171
|
+
const originalMethod = prototype[methodName];
|
|
3172
|
+
if (typeof originalMethod !== "function") {
|
|
3173
|
+
continue;
|
|
3174
|
+
}
|
|
3175
|
+
prototype[methodName] = function patchedRouteMethod(path, handler, ...rest) {
|
|
3176
|
+
const callsite = captureRouteRegistrationCallsite();
|
|
3177
|
+
return Reflect.apply(originalMethod, this, [
|
|
3178
|
+
path,
|
|
3179
|
+
wrapRouteHandlerWithCallsite(handler, callsite),
|
|
3180
|
+
...rest
|
|
3181
|
+
]);
|
|
3182
|
+
};
|
|
3183
|
+
}
|
|
3184
|
+
Reflect.set(globalThis, ROUTE_CALLSITE_PATCHED_KEY, true);
|
|
3185
|
+
};
|
|
3186
|
+
var init_devRouteRegistrationCallsite = __esm(() => {
|
|
3187
|
+
ROUTE_CALLSITE_STORAGE_KEY = Symbol.for("absolutejs.devRouteRegistrationCallsiteStorage");
|
|
3188
|
+
ROUTE_CALLSITE_PATCHED_KEY = Symbol.for("absolutejs.devRouteRegistrationCallsitePatched");
|
|
3189
|
+
ROUTE_METHOD_NAMES = [
|
|
3190
|
+
"all",
|
|
3191
|
+
"delete",
|
|
3192
|
+
"get",
|
|
3193
|
+
"head",
|
|
3194
|
+
"options",
|
|
3195
|
+
"patch",
|
|
3196
|
+
"post",
|
|
3197
|
+
"put"
|
|
3198
|
+
];
|
|
3199
|
+
});
|
|
3200
|
+
|
|
3201
|
+
// src/utils/getDurationString.ts
|
|
3202
|
+
var getDurationString = (duration) => {
|
|
3203
|
+
let durationString;
|
|
3204
|
+
if (duration < MILLISECONDS_IN_A_SECOND) {
|
|
3205
|
+
durationString = `${duration.toFixed(TIME_PRECISION)}ms`;
|
|
3206
|
+
} else if (duration < MILLISECONDS_IN_A_MINUTE) {
|
|
3207
|
+
durationString = `${(duration / MILLISECONDS_IN_A_SECOND).toFixed(TIME_PRECISION)}s`;
|
|
3208
|
+
} else {
|
|
3209
|
+
durationString = `${(duration / MILLISECONDS_IN_A_MINUTE).toFixed(TIME_PRECISION)}m`;
|
|
3210
|
+
}
|
|
3211
|
+
return durationString;
|
|
3212
|
+
};
|
|
3213
|
+
var init_getDurationString = __esm(() => {
|
|
3214
|
+
init_constants();
|
|
3215
|
+
});
|
|
3216
|
+
|
|
3217
|
+
// src/utils/startupBanner.ts
|
|
3218
|
+
var colors, MONTHS, formatTimestamp = () => {
|
|
3219
|
+
const now = new Date;
|
|
3220
|
+
const month = MONTHS[now.getMonth()];
|
|
3221
|
+
const day = now.getDate().toString().padStart(2, "0");
|
|
3222
|
+
let hours = now.getHours();
|
|
3223
|
+
const minutes = now.getMinutes().toString().padStart(2, "0");
|
|
3224
|
+
const seconds = now.getSeconds().toString().padStart(2, "0");
|
|
3225
|
+
const ampm = hours >= HOURS_IN_HALF_DAY ? "PM" : "AM";
|
|
3226
|
+
hours = hours % HOURS_IN_HALF_DAY || HOURS_IN_HALF_DAY;
|
|
3227
|
+
return `${month} ${day} ${hours}:${minutes}:${seconds} ${ampm}`;
|
|
3228
|
+
}, startupBanner = (options) => {
|
|
3229
|
+
const {
|
|
3230
|
+
version,
|
|
3231
|
+
readyDuration,
|
|
3232
|
+
buildDuration,
|
|
3233
|
+
port,
|
|
3234
|
+
host,
|
|
3235
|
+
networkUrl,
|
|
3236
|
+
protocol = "http"
|
|
3237
|
+
} = options;
|
|
3238
|
+
const name = `${colors.cyan}${colors.bold}ABSOLUTEJS${colors.reset}`;
|
|
3239
|
+
const ver = `${colors.dim}v${version}${colors.reset}`;
|
|
3240
|
+
const time = `${colors.dim}ready in${colors.reset} ${colors.bold}${getDurationString(readyDuration)}${colors.reset}`;
|
|
3241
|
+
const build2 = typeof buildDuration === "number" && Number.isFinite(buildDuration) ? ` ${colors.dim}(build ${getDurationString(buildDuration)})${colors.reset}` : "";
|
|
3242
|
+
console.log("");
|
|
3243
|
+
console.log(` ${name} ${ver} ${time}${build2}`);
|
|
3244
|
+
console.log("");
|
|
3245
|
+
console.log(` ${colors.green}\u279C${colors.reset} ${colors.bold}Local:${colors.reset} ${protocol}://${host === "0.0.0.0" ? "localhost" : host}:${port}/`);
|
|
3246
|
+
if (networkUrl) {
|
|
3247
|
+
console.log(` ${colors.green}\u279C${colors.reset} ${colors.bold}Network:${colors.reset} ${networkUrl}`);
|
|
3248
|
+
}
|
|
3249
|
+
console.log("");
|
|
3250
|
+
};
|
|
3251
|
+
var init_startupBanner = __esm(() => {
|
|
3252
|
+
init_constants();
|
|
3253
|
+
init_getDurationString();
|
|
3254
|
+
colors = {
|
|
3255
|
+
bold: "\x1B[1m",
|
|
3256
|
+
cyan: "\x1B[36m",
|
|
3257
|
+
dim: "\x1B[2m",
|
|
3258
|
+
green: "\x1B[32m",
|
|
3259
|
+
reset: "\x1B[0m"
|
|
3260
|
+
};
|
|
3261
|
+
MONTHS = [
|
|
3262
|
+
"Jan",
|
|
3263
|
+
"Feb",
|
|
3264
|
+
"Mar",
|
|
3265
|
+
"Apr",
|
|
3266
|
+
"May",
|
|
3267
|
+
"Jun",
|
|
3268
|
+
"Jul",
|
|
3269
|
+
"Aug",
|
|
3270
|
+
"Sep",
|
|
3271
|
+
"Oct",
|
|
3272
|
+
"Nov",
|
|
3273
|
+
"Dec"
|
|
3274
|
+
];
|
|
3275
|
+
});
|
|
3276
|
+
|
|
3277
|
+
// src/utils/logger.ts
|
|
3278
|
+
var colors2, frameworkColors, formatPath = (filePath) => {
|
|
3279
|
+
const cwd = process.cwd();
|
|
3280
|
+
let relative4 = filePath.startsWith(cwd) ? filePath.slice(cwd.length + 1) : filePath;
|
|
3281
|
+
relative4 = relative4.replace(/\\/g, "/");
|
|
3282
|
+
if (!relative4.startsWith("/")) {
|
|
3283
|
+
relative4 = `/${relative4}`;
|
|
3284
|
+
}
|
|
3285
|
+
return relative4;
|
|
3286
|
+
}, getFrameworkColor = (framework) => frameworkColors[framework] || colors2.white, log = (action, options) => {
|
|
3287
|
+
const timestamp = `${colors2.dim}${formatTimestamp()}${colors2.reset}`;
|
|
3288
|
+
const tag = `${colors2.cyan}[hmr]${colors2.reset}`;
|
|
3289
|
+
let message = action;
|
|
3290
|
+
if (options?.path) {
|
|
3291
|
+
const pathColor = options.framework ? getFrameworkColor(options.framework) : colors2.white;
|
|
3292
|
+
message += ` ${pathColor}${formatPath(options.path)}${colors2.reset}`;
|
|
3293
|
+
}
|
|
3294
|
+
if (options?.duration !== undefined) {
|
|
3295
|
+
message += ` ${colors2.dim}(${options.duration}ms)${colors2.reset}`;
|
|
3296
|
+
}
|
|
3297
|
+
console.log(`${timestamp} ${tag} ${message}`);
|
|
3298
|
+
}, logCssUpdate = (path, framework, duration) => {
|
|
3299
|
+
log("css update", { duration, framework: framework ?? "css", path });
|
|
3300
|
+
}, logError = (message, error) => {
|
|
3301
|
+
const timestamp = `${colors2.dim}${formatTimestamp()}${colors2.reset}`;
|
|
3302
|
+
const tag = `${colors2.red}[hmr]${colors2.reset}`;
|
|
3303
|
+
const errorMsg = error instanceof Error ? error.message : error;
|
|
3304
|
+
const fullMessage = `${colors2.red}error${colors2.reset} ${message}${errorMsg ? `: ${errorMsg}` : ""}`;
|
|
3305
|
+
console.error(`${timestamp} ${tag} ${fullMessage}`);
|
|
3306
|
+
}, logHmrUpdate = (path, framework, duration) => {
|
|
3307
|
+
log("hmr update", { duration, framework, path });
|
|
3308
|
+
}, logScriptUpdate = (path, framework, duration) => {
|
|
3309
|
+
log("script update", { duration, framework, path });
|
|
3310
|
+
}, logServerReload = () => {
|
|
3311
|
+
log(`${colors2.cyan}server module reloaded${colors2.reset}`);
|
|
3312
|
+
}, logWarn = (message) => {
|
|
3313
|
+
const timestamp = `${colors2.dim}${formatTimestamp()}${colors2.reset}`;
|
|
3314
|
+
const tag = `${colors2.yellow}[hmr]${colors2.reset}`;
|
|
3315
|
+
console.log(`${timestamp} ${tag} ${colors2.yellow}warning ${message}${colors2.reset}`);
|
|
3316
|
+
};
|
|
3317
|
+
var init_logger = __esm(() => {
|
|
3318
|
+
init_startupBanner();
|
|
3319
|
+
colors2 = {
|
|
3320
|
+
blue: "\x1B[34m",
|
|
3321
|
+
bold: "\x1B[1m",
|
|
3322
|
+
cyan: "\x1B[36m",
|
|
3323
|
+
dim: "\x1B[2m",
|
|
3324
|
+
green: "\x1B[32m",
|
|
3325
|
+
magenta: "\x1B[35m",
|
|
3326
|
+
red: "\x1B[31m",
|
|
3327
|
+
reset: "\x1B[0m",
|
|
3328
|
+
white: "\x1B[37m",
|
|
3329
|
+
yellow: "\x1B[33m"
|
|
3330
|
+
};
|
|
3331
|
+
frameworkColors = {
|
|
3332
|
+
angular: colors2.magenta,
|
|
3333
|
+
assets: colors2.dim,
|
|
3334
|
+
css: colors2.cyan,
|
|
3335
|
+
html: colors2.white,
|
|
3336
|
+
htmx: colors2.white,
|
|
3337
|
+
react: colors2.blue,
|
|
3338
|
+
svelte: colors2.yellow,
|
|
3339
|
+
vue: colors2.green
|
|
3340
|
+
};
|
|
3341
|
+
});
|
|
3342
|
+
|
|
3343
|
+
// src/core/streamingSlotWarningScope.ts
|
|
3344
|
+
import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
|
|
3345
|
+
var STREAMING_SLOT_WARNING_STORAGE_KEY2, isObjectRecord4 = (value) => Boolean(value) && typeof value === "object", isAsyncLocalStorage3 = (value) => isObjectRecord4(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function", getWarningStorage = () => {
|
|
3346
|
+
const value = Reflect.get(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY2);
|
|
3347
|
+
if (value === null || typeof value === "undefined") {
|
|
3348
|
+
return;
|
|
3349
|
+
}
|
|
3350
|
+
return isAsyncLocalStorage3(value) ? value : undefined;
|
|
3351
|
+
}, ensureWarningStorage = () => {
|
|
3352
|
+
const existing = getWarningStorage();
|
|
3353
|
+
if (existing) {
|
|
3354
|
+
return existing;
|
|
3355
|
+
}
|
|
3356
|
+
const storage = new AsyncLocalStorage2;
|
|
3357
|
+
Reflect.set(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY2, storage);
|
|
3358
|
+
return storage;
|
|
3359
|
+
}, normalizeCallsitePath2 = (value) => value.replace(`${process.cwd()}/`, "").replace(process.cwd(), "").replace(/^\.\/+/, ""), formatWarningCallsite = (callsite) => {
|
|
3360
|
+
const match = callsite.match(/^(.*?)(:\d+:\d+)$/);
|
|
3361
|
+
if (!match) {
|
|
3362
|
+
return `\x1B[36m${callsite}\x1B[0m`;
|
|
3363
|
+
}
|
|
3364
|
+
return `\x1B[36m${match[1]}\x1B[33m${match[2]}\x1B[0m`;
|
|
3365
|
+
}, extractCallsiteFromStack = (stack) => {
|
|
3366
|
+
const frames = stack.split(`
|
|
3367
|
+
`).slice(1).map((line) => line.trim());
|
|
3368
|
+
for (const frame of frames) {
|
|
3369
|
+
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.")) {
|
|
3370
|
+
continue;
|
|
3371
|
+
}
|
|
3372
|
+
const locationMatch = frame.match(/\((\/[^)]+:\d+:\d+)\)$/) ?? frame.match(/at (\/[^ ]+:\d+:\d+)$/);
|
|
3373
|
+
if (locationMatch?.[1]) {
|
|
3374
|
+
return normalizeCallsitePath2(locationMatch[1]);
|
|
3375
|
+
}
|
|
3376
|
+
}
|
|
3377
|
+
return;
|
|
3378
|
+
}, 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 = () => {
|
|
3379
|
+
if (false) {}
|
|
3380
|
+
const { stack } = new Error;
|
|
3381
|
+
if (!stack) {
|
|
3382
|
+
return;
|
|
3383
|
+
}
|
|
3384
|
+
return extractCallsiteFromStack(stack);
|
|
3385
|
+
}, runWithStreamingSlotWarningScope = (task, metadata2) => ensureWarningStorage().run({ handlerCallsite: metadata2?.handlerCallsite, hasWarned: false }, task);
|
|
3386
|
+
var init_streamingSlotWarningScope = __esm(() => {
|
|
3387
|
+
init_logger();
|
|
3388
|
+
init_streamingSlotRegistrar();
|
|
3389
|
+
STREAMING_SLOT_WARNING_STORAGE_KEY2 = Symbol.for("absolutejs.streamingSlotWarningAsyncLocalStorage");
|
|
3390
|
+
setStreamingSlotWarningController({
|
|
3391
|
+
maybeWarn: (primitiveName) => {
|
|
3392
|
+
const store = getWarningStorage()?.getStore();
|
|
3393
|
+
if (!store || store.hasWarned) {
|
|
3394
|
+
return;
|
|
3395
|
+
}
|
|
3396
|
+
store.hasWarned = true;
|
|
3397
|
+
logWarn(buildMissingCollectorWarning(primitiveName, store.handlerCallsite));
|
|
3398
|
+
}
|
|
3399
|
+
});
|
|
3400
|
+
});
|
|
3401
|
+
|
|
3402
|
+
// src/utils/ssrErrorPage.ts
|
|
3403
|
+
var ssrErrorPage = (framework, error) => {
|
|
3404
|
+
const frameworkColors2 = {
|
|
3405
|
+
angular: "#dd0031",
|
|
3406
|
+
html: "#e34c26",
|
|
3407
|
+
htmx: "#1a365d",
|
|
3408
|
+
react: "#61dafb",
|
|
3409
|
+
svelte: "#ff3e00",
|
|
3410
|
+
vue: "#42b883"
|
|
3411
|
+
};
|
|
3412
|
+
const accent = frameworkColors2[framework] ?? "#94a3b8";
|
|
3413
|
+
const label = framework.charAt(0).toUpperCase() + framework.slice(1);
|
|
3414
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
3415
|
+
return `<!DOCTYPE html>
|
|
3416
|
+
<html>
|
|
3417
|
+
<head>
|
|
3418
|
+
<meta charset="utf-8">
|
|
3419
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
3420
|
+
<title>SSR Error - AbsoluteJS</title>
|
|
3421
|
+
<style>
|
|
3422
|
+
*{margin:0;padding:0;box-sizing:border-box}
|
|
3423
|
+
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}
|
|
3424
|
+
.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}
|
|
3425
|
+
.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)}
|
|
3426
|
+
.brand{font-weight:700;font-size:20px;color:#fff;letter-spacing:-0.02em}
|
|
3427
|
+
.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)}
|
|
3428
|
+
.kind{color:#94a3b8;font-size:13px;font-weight:500}
|
|
3429
|
+
.content{padding:24px}
|
|
3430
|
+
.label{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:0.08em;color:#94a3b8;margin-bottom:8px}
|
|
3431
|
+
.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}
|
|
3432
|
+
.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}
|
|
3433
|
+
</style>
|
|
3434
|
+
</head>
|
|
3435
|
+
<body>
|
|
3436
|
+
<div class="card">
|
|
3437
|
+
<div class="header">
|
|
3438
|
+
<div style="display:flex;align-items:center;gap:12px">
|
|
3439
|
+
<span class="brand">AbsoluteJS</span>
|
|
3440
|
+
<span class="badge">${label}</span>
|
|
3441
|
+
</div>
|
|
3442
|
+
<span class="kind">Server Render Error</span>
|
|
3443
|
+
</div>
|
|
3444
|
+
<div class="content">
|
|
3445
|
+
<div class="label">What went wrong</div>
|
|
3446
|
+
<pre class="message">${message.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")}</pre>
|
|
3447
|
+
<div class="hint">A component threw during server-side rendering. Check the terminal for the full stack trace.</div>
|
|
3448
|
+
</div>
|
|
3449
|
+
</div>
|
|
3450
|
+
</body>
|
|
3451
|
+
</html>`;
|
|
3452
|
+
};
|
|
3453
|
+
|
|
3454
|
+
// src/utils/resolveConvention.ts
|
|
3455
|
+
import { basename as basename2 } from "path";
|
|
3456
|
+
var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boolean(value) && typeof value === "object", getMap = () => {
|
|
3457
|
+
const value = Reflect.get(globalThis, CONVENTIONS_KEY);
|
|
3458
|
+
if (isConventionsMap(value))
|
|
3459
|
+
return value;
|
|
3460
|
+
const empty = {};
|
|
3461
|
+
return empty;
|
|
3462
|
+
}, derivePageName = (pagePath) => {
|
|
3463
|
+
const base = basename2(pagePath);
|
|
3464
|
+
const dotIndex = base.indexOf(".");
|
|
3465
|
+
const name = dotIndex > 0 ? base.slice(0, dotIndex) : base;
|
|
3466
|
+
return toPascal(name);
|
|
3467
|
+
}, resolveErrorConventionPath = (framework, pageName) => {
|
|
3468
|
+
const conventions2 = getMap()[framework];
|
|
3469
|
+
if (!conventions2)
|
|
3470
|
+
return;
|
|
3471
|
+
return conventions2.pages?.[pageName]?.error ?? conventions2.defaults?.error;
|
|
3472
|
+
}, resolveNotFoundConventionPath = (framework) => getMap()[framework]?.defaults?.notFound, setConventions = (map) => {
|
|
3473
|
+
Reflect.set(globalThis, CONVENTIONS_KEY, map);
|
|
3474
|
+
}, isDev = () => true, buildErrorProps = (error) => {
|
|
3475
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
3476
|
+
const stack = isDev() && error instanceof Error ? error.stack : undefined;
|
|
3477
|
+
return { error: { message, stack } };
|
|
3478
|
+
}, renderReactError = async (conventionPath, errorProps) => {
|
|
3479
|
+
const { createElement } = await import("react");
|
|
3480
|
+
const { renderToReadableStream } = await import("react-dom/server");
|
|
3481
|
+
const mod = await import(conventionPath);
|
|
3482
|
+
const [firstKey] = Object.keys(mod);
|
|
3483
|
+
const ErrorComponent = mod.default ?? (firstKey ? mod[firstKey] : undefined);
|
|
3484
|
+
const element = createElement(ErrorComponent, errorProps);
|
|
3485
|
+
const stream = await renderToReadableStream(element);
|
|
3486
|
+
return new Response(stream, {
|
|
3487
|
+
headers: { "Content-Type": "text/html" },
|
|
3488
|
+
status: 500
|
|
3489
|
+
});
|
|
3490
|
+
}, renderSvelteError = async (conventionPath, errorProps) => {
|
|
3491
|
+
const { render } = await import("svelte/server");
|
|
3492
|
+
const mod = await import(conventionPath);
|
|
3493
|
+
const ErrorComponent = mod.default;
|
|
3494
|
+
const { head, body } = render(ErrorComponent, {
|
|
3495
|
+
props: errorProps
|
|
3496
|
+
});
|
|
3497
|
+
const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
|
|
3498
|
+
return new Response(html, {
|
|
3499
|
+
headers: { "Content-Type": "text/html" },
|
|
3500
|
+
status: 500
|
|
3501
|
+
});
|
|
3502
|
+
}, unescapeVueStyles = (ssrBody) => {
|
|
3503
|
+
let styles = "";
|
|
3504
|
+
const body = ssrBody.replace(/<style>([\s\S]*?)<\/style>/g, (_, css) => {
|
|
3505
|
+
styles += `<style>${css.replace(/"/g, '"').replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")}</style>`;
|
|
3506
|
+
return "";
|
|
3507
|
+
});
|
|
3508
|
+
return { body, styles };
|
|
3509
|
+
}, renderVueError = async (conventionPath, errorProps) => {
|
|
3510
|
+
const { createSSRApp, h } = await import("vue");
|
|
3511
|
+
const { renderToString } = await import("vue/server-renderer");
|
|
3512
|
+
const mod = await import(conventionPath);
|
|
3513
|
+
const ErrorComponent = mod.default;
|
|
3514
|
+
const app = createSSRApp({
|
|
3515
|
+
render: () => h(ErrorComponent, errorProps)
|
|
3516
|
+
});
|
|
3517
|
+
const rawBody = await renderToString(app);
|
|
3518
|
+
const { styles, body } = unescapeVueStyles(rawBody);
|
|
3519
|
+
const html = `<!DOCTYPE html><html><head>${styles}</head><body><div id="root">${body}</div></body></html>`;
|
|
3520
|
+
return new Response(html, {
|
|
3521
|
+
headers: { "Content-Type": "text/html" },
|
|
3522
|
+
status: 500
|
|
3523
|
+
});
|
|
3524
|
+
}, renderAngularError = async (conventionPath, errorProps) => {
|
|
3525
|
+
const mod = await import(conventionPath);
|
|
3526
|
+
const renderError = mod.default ?? mod.renderError;
|
|
3527
|
+
if (typeof renderError !== "function")
|
|
3528
|
+
return null;
|
|
3529
|
+
const html = renderError(errorProps);
|
|
3530
|
+
return new Response(html, {
|
|
3531
|
+
headers: { "Content-Type": "text/html" },
|
|
3532
|
+
status: 500
|
|
3533
|
+
});
|
|
3534
|
+
}, logConventionRenderError = (framework, label, renderError) => {
|
|
3535
|
+
const message = renderError instanceof Error ? renderError.message : "";
|
|
3536
|
+
if (message.includes("Cannot find module") || message.includes("Cannot find package") || message.includes("not found in module")) {
|
|
3537
|
+
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}).`);
|
|
3538
|
+
return;
|
|
3539
|
+
}
|
|
3540
|
+
console.error(`[SSR] Failed to render ${framework} convention ${label} page:`, renderError);
|
|
3541
|
+
}, ERROR_RENDERERS, renderConventionError = async (framework, pageName, error) => {
|
|
3542
|
+
const conventionPath = resolveErrorConventionPath(framework, pageName);
|
|
3543
|
+
if (!conventionPath)
|
|
3544
|
+
return null;
|
|
3545
|
+
const errorProps = buildErrorProps(error);
|
|
3546
|
+
const renderer = ERROR_RENDERERS[framework];
|
|
3547
|
+
if (!renderer)
|
|
3548
|
+
return null;
|
|
3549
|
+
try {
|
|
3550
|
+
return await renderer(conventionPath, errorProps);
|
|
3551
|
+
} catch (renderError) {
|
|
3552
|
+
logConventionRenderError(framework, "error", renderError);
|
|
3567
3553
|
}
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
const
|
|
3571
|
-
const
|
|
3572
|
-
|
|
3573
|
-
|
|
3554
|
+
return null;
|
|
3555
|
+
}, renderReactNotFound = async (conventionPath) => {
|
|
3556
|
+
const { createElement } = await import("react");
|
|
3557
|
+
const { renderToReadableStream } = await import("react-dom/server");
|
|
3558
|
+
const mod = await import(conventionPath);
|
|
3559
|
+
const [nfKey] = Object.keys(mod);
|
|
3560
|
+
const NotFoundComponent = mod.default ?? (nfKey ? mod[nfKey] : undefined);
|
|
3561
|
+
const element = createElement(NotFoundComponent);
|
|
3562
|
+
const stream = await renderToReadableStream(element);
|
|
3563
|
+
return new Response(stream, {
|
|
3564
|
+
headers: { "Content-Type": "text/html" },
|
|
3565
|
+
status: 404
|
|
3566
|
+
});
|
|
3567
|
+
}, renderSvelteNotFound = async (conventionPath) => {
|
|
3568
|
+
const { render } = await import("svelte/server");
|
|
3569
|
+
const mod = await import(conventionPath);
|
|
3570
|
+
const NotFoundComponent = mod.default;
|
|
3571
|
+
const { head, body } = render(NotFoundComponent);
|
|
3572
|
+
const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
|
|
3573
|
+
return new Response(html, {
|
|
3574
|
+
headers: { "Content-Type": "text/html" },
|
|
3575
|
+
status: 404
|
|
3576
|
+
});
|
|
3577
|
+
}, renderVueNotFound = async (conventionPath) => {
|
|
3578
|
+
const { createSSRApp, h } = await import("vue");
|
|
3579
|
+
const { renderToString } = await import("vue/server-renderer");
|
|
3580
|
+
const mod = await import(conventionPath);
|
|
3581
|
+
const NotFoundComponent = mod.default;
|
|
3582
|
+
const app = createSSRApp({
|
|
3583
|
+
render: () => h(NotFoundComponent)
|
|
3584
|
+
});
|
|
3585
|
+
const rawBody = await renderToString(app);
|
|
3586
|
+
const { styles, body } = unescapeVueStyles(rawBody);
|
|
3587
|
+
const html = `<!DOCTYPE html><html><head>${styles}</head><body><div id="root">${body}</div></body></html>`;
|
|
3588
|
+
return new Response(html, {
|
|
3589
|
+
headers: { "Content-Type": "text/html" },
|
|
3590
|
+
status: 404
|
|
3591
|
+
});
|
|
3592
|
+
}, renderAngularNotFound = async (conventionPath) => {
|
|
3593
|
+
const mod = await import(conventionPath);
|
|
3594
|
+
const renderNotFound = mod.default ?? mod.renderNotFound;
|
|
3595
|
+
if (typeof renderNotFound !== "function")
|
|
3596
|
+
return null;
|
|
3597
|
+
const html = renderNotFound();
|
|
3598
|
+
return new Response(html, {
|
|
3599
|
+
headers: { "Content-Type": "text/html" },
|
|
3600
|
+
status: 404
|
|
3601
|
+
});
|
|
3602
|
+
}, NOT_FOUND_RENDERERS, renderConventionNotFound = async (framework) => {
|
|
3603
|
+
const conventionPath = resolveNotFoundConventionPath(framework);
|
|
3604
|
+
if (!conventionPath)
|
|
3605
|
+
return null;
|
|
3606
|
+
const renderer = NOT_FOUND_RENDERERS[framework];
|
|
3607
|
+
if (!renderer)
|
|
3608
|
+
return null;
|
|
3609
|
+
try {
|
|
3610
|
+
return await renderer(conventionPath);
|
|
3611
|
+
} catch (renderError) {
|
|
3612
|
+
logConventionRenderError(framework, "not-found", renderError);
|
|
3574
3613
|
}
|
|
3575
|
-
return
|
|
3576
|
-
},
|
|
3577
|
-
|
|
3578
|
-
|
|
3614
|
+
return null;
|
|
3615
|
+
}, NOT_FOUND_PRIORITY, renderFirstNotFound = async () => {
|
|
3616
|
+
for (const framework of NOT_FOUND_PRIORITY) {
|
|
3617
|
+
if (!getMap()[framework]?.defaults?.notFound)
|
|
3618
|
+
continue;
|
|
3619
|
+
const response = await renderConventionNotFound(framework);
|
|
3620
|
+
if (response)
|
|
3621
|
+
return response;
|
|
3579
3622
|
}
|
|
3580
|
-
|
|
3581
|
-
await Promise.all(pagePaths.map((pagePath) => transformStaticPage(pagePath, registry)));
|
|
3623
|
+
return null;
|
|
3582
3624
|
};
|
|
3583
|
-
var
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3625
|
+
var init_resolveConvention = __esm(() => {
|
|
3626
|
+
ERROR_RENDERERS = {
|
|
3627
|
+
angular: renderAngularError,
|
|
3628
|
+
react: renderReactError,
|
|
3629
|
+
svelte: renderSvelteError,
|
|
3630
|
+
vue: renderVueError
|
|
3631
|
+
};
|
|
3632
|
+
NOT_FOUND_RENDERERS = {
|
|
3633
|
+
angular: renderAngularNotFound,
|
|
3634
|
+
react: renderReactNotFound,
|
|
3635
|
+
svelte: renderSvelteNotFound,
|
|
3636
|
+
vue: renderVueNotFound
|
|
3637
|
+
};
|
|
3638
|
+
NOT_FOUND_PRIORITY = [
|
|
3589
3639
|
"react",
|
|
3590
3640
|
"svelte",
|
|
3591
3641
|
"vue",
|
|
3592
3642
|
"angular"
|
|
3593
3643
|
];
|
|
3594
|
-
|
|
3595
|
-
|
|
3644
|
+
});
|
|
3645
|
+
|
|
3646
|
+
// src/react/pageHandler.ts
|
|
3647
|
+
var exports_pageHandler = {};
|
|
3648
|
+
__export(exports_pageHandler, {
|
|
3649
|
+
invalidateReactSsrCache: () => invalidateReactSsrCache,
|
|
3650
|
+
handleReactPageRequest: () => handleReactPageRequest
|
|
3651
|
+
});
|
|
3652
|
+
var ssrDirty = false, buildRefreshSetup = () => {
|
|
3653
|
+
if (false) {}
|
|
3654
|
+
return "window.__REFRESH_BUFFER__=[];" + "window.$RefreshReg$=function(t,i){window.__REFRESH_BUFFER__.push([t,i])};" + "window.$RefreshSig$=function(){return function(t){return t}};";
|
|
3655
|
+
}, buildDirtyResponse = (index, maybeProps) => {
|
|
3656
|
+
const propsScript = maybeProps ? `window.__INITIAL_PROPS__=${JSON.stringify(maybeProps)};` : "";
|
|
3657
|
+
const dirtyFlag = "window.__SSR_DIRTY__=true;";
|
|
3658
|
+
const refreshSetup = buildRefreshSetup();
|
|
3659
|
+
const inlineScript = `${propsScript}${dirtyFlag}${refreshSetup}`;
|
|
3660
|
+
const html = `<!DOCTYPE html><html><head></head><body>` + `<script>${inlineScript}</script>` + `<script type="module" src="${index}"></script>` + `</body></html>`;
|
|
3661
|
+
return new Response(html, {
|
|
3662
|
+
headers: { "Content-Type": "text/html" }
|
|
3663
|
+
});
|
|
3664
|
+
}, handleReactPageRequest = async (PageComponentOrInput, index, ...args) => {
|
|
3665
|
+
const {
|
|
3666
|
+
Page,
|
|
3667
|
+
index: resolvedIndex,
|
|
3668
|
+
options,
|
|
3669
|
+
props: maybeProps
|
|
3670
|
+
} = typeof PageComponentOrInput === "object" && PageComponentOrInput !== null && "Page" in PageComponentOrInput ? {
|
|
3671
|
+
index: PageComponentOrInput.index,
|
|
3672
|
+
options: PageComponentOrInput,
|
|
3673
|
+
Page: PageComponentOrInput.Page,
|
|
3674
|
+
props: PageComponentOrInput.props
|
|
3675
|
+
} : {
|
|
3676
|
+
index: index ?? "",
|
|
3677
|
+
options: args[1],
|
|
3678
|
+
Page: PageComponentOrInput,
|
|
3679
|
+
props: args[0]
|
|
3680
|
+
};
|
|
3681
|
+
if (ssrDirty) {
|
|
3682
|
+
return buildDirtyResponse(resolvedIndex, maybeProps);
|
|
3683
|
+
}
|
|
3684
|
+
try {
|
|
3685
|
+
const handlerCallsite = options?.collectStreamingSlots === true ? undefined : getCurrentRouteRegistrationCallsite() ?? captureStreamingSlotWarningCallsite();
|
|
3686
|
+
const renderPageResponse = async () => {
|
|
3687
|
+
const { createElement } = await import("react");
|
|
3688
|
+
const { renderToReadableStream } = await import("react-dom/server");
|
|
3689
|
+
const element = maybeProps !== undefined ? createElement(Page, maybeProps) : createElement(Page);
|
|
3690
|
+
const propsScript = maybeProps ? `window.__INITIAL_PROPS__=${JSON.stringify(maybeProps)};` : "";
|
|
3691
|
+
const refreshSetup = buildRefreshSetup();
|
|
3692
|
+
const stream = await renderToReadableStream(element, {
|
|
3693
|
+
bootstrapModules: [resolvedIndex],
|
|
3694
|
+
bootstrapScriptContent: propsScript + refreshSetup || undefined,
|
|
3695
|
+
onError(error) {
|
|
3696
|
+
console.error("[SSR] React streaming error:", error);
|
|
3697
|
+
}
|
|
3698
|
+
});
|
|
3699
|
+
const htmlStream = injectIslandPageContextStream(stream);
|
|
3700
|
+
return new Response(htmlStream, {
|
|
3701
|
+
headers: { "Content-Type": "text/html" }
|
|
3702
|
+
});
|
|
3703
|
+
};
|
|
3704
|
+
return runWithStreamingSlotWarningScope(() => options?.collectStreamingSlots === true ? withRegisteredStreamingSlots(renderPageResponse, options) : renderPageResponse(), { handlerCallsite });
|
|
3705
|
+
} catch (error) {
|
|
3706
|
+
console.error("[SSR] React render error:", error);
|
|
3707
|
+
const pageName = Page.name || Page.displayName || "";
|
|
3708
|
+
const conventionResponse = await renderConventionError("react", pageName, error);
|
|
3709
|
+
if (conventionResponse)
|
|
3710
|
+
return conventionResponse;
|
|
3711
|
+
return new Response(ssrErrorPage("react", error), {
|
|
3712
|
+
headers: { "Content-Type": "text/html" },
|
|
3713
|
+
status: 500
|
|
3714
|
+
});
|
|
3715
|
+
}
|
|
3716
|
+
}, invalidateReactSsrCache = () => {
|
|
3717
|
+
ssrDirty = true;
|
|
3718
|
+
};
|
|
3719
|
+
var init_pageHandler = __esm(() => {
|
|
3720
|
+
init_islandPageContext();
|
|
3721
|
+
init_devRouteRegistrationCallsite();
|
|
3722
|
+
init_responseEnhancers();
|
|
3723
|
+
init_streamingSlotWarningScope();
|
|
3724
|
+
init_resolveConvention();
|
|
3596
3725
|
});
|
|
3597
3726
|
|
|
3598
3727
|
// src/build/scanEntryPoints.ts
|
|
@@ -7820,6 +7949,7 @@ ${content.slice(firstUseIdx)}`;
|
|
|
7820
7949
|
vueDirectory,
|
|
7821
7950
|
stylesConfig,
|
|
7822
7951
|
stylePreprocessors,
|
|
7952
|
+
postcss,
|
|
7823
7953
|
tailwind,
|
|
7824
7954
|
options,
|
|
7825
7955
|
incrementalFiles,
|
|
@@ -7829,7 +7959,8 @@ ${content.slice(firstUseIdx)}`;
|
|
|
7829
7959
|
const projectRoot = cwd();
|
|
7830
7960
|
await resolveAbsoluteVersion();
|
|
7831
7961
|
const isIncremental = incrementalFiles && incrementalFiles.length > 0;
|
|
7832
|
-
const
|
|
7962
|
+
const styleTransformConfig = createStyleTransformConfig(stylePreprocessors, postcss);
|
|
7963
|
+
const stylePreprocessorPlugin2 = createStylePreprocessorPlugin(styleTransformConfig);
|
|
7833
7964
|
const normalizedIncrementalFiles = incrementalFiles?.map(normalizePath);
|
|
7834
7965
|
const throwOnError = options?.throwOnError === true;
|
|
7835
7966
|
const hmr = options?.injectHMR === true;
|
|
@@ -8025,28 +8156,28 @@ ${content.slice(firstUseIdx)}`;
|
|
|
8025
8156
|
{ vueClientPaths: islandVueClientPaths },
|
|
8026
8157
|
{ clientPaths: islandAngularClientPaths }
|
|
8027
8158
|
] = await Promise.all([
|
|
8028
|
-
shouldCompileSvelte ? Promise.resolve().then(() => (init_compileSvelte(), exports_compileSvelte)).then((mod) => mod.compileSvelte(svelteEntries, svelteDir, new Map, hmr,
|
|
8159
|
+
shouldCompileSvelte ? Promise.resolve().then(() => (init_compileSvelte(), exports_compileSvelte)).then((mod) => mod.compileSvelte(svelteEntries, svelteDir, new Map, hmr, styleTransformConfig)) : {
|
|
8029
8160
|
svelteClientPaths: [...emptyStringArray],
|
|
8030
8161
|
svelteIndexPaths: [...emptyStringArray],
|
|
8031
8162
|
svelteServerPaths: [...emptyStringArray]
|
|
8032
8163
|
},
|
|
8033
|
-
shouldCompileVue ? Promise.resolve().then(() => (init_compileVue(), exports_compileVue)).then((mod) => mod.compileVue(vueEntries, vueDir, hmr,
|
|
8164
|
+
shouldCompileVue ? Promise.resolve().then(() => (init_compileVue(), exports_compileVue)).then((mod) => mod.compileVue(vueEntries, vueDir, hmr, styleTransformConfig)) : {
|
|
8034
8165
|
vueClientPaths: [...emptyStringArray],
|
|
8035
8166
|
vueCssPaths: [...emptyStringArray],
|
|
8036
8167
|
vueIndexPaths: [...emptyStringArray],
|
|
8037
8168
|
vueServerPaths: [...emptyStringArray]
|
|
8038
8169
|
},
|
|
8039
|
-
shouldCompileAngular ? Promise.resolve().then(() => (init_compileAngular(), exports_compileAngular)).then((mod) => mod.compileAngular(angularEntries, angularDir, hmr,
|
|
8170
|
+
shouldCompileAngular ? Promise.resolve().then(() => (init_compileAngular(), exports_compileAngular)).then((mod) => mod.compileAngular(angularEntries, angularDir, hmr, styleTransformConfig)) : {
|
|
8040
8171
|
clientPaths: [...emptyStringArray],
|
|
8041
8172
|
serverPaths: [...emptyStringArray]
|
|
8042
8173
|
},
|
|
8043
|
-
shouldCompileIslandSvelte ? Promise.resolve().then(() => (init_compileSvelte(), exports_compileSvelte)).then((mod) => mod.compileSvelte(islandSvelteSources, svelteDir, new Map, hmr,
|
|
8174
|
+
shouldCompileIslandSvelte ? Promise.resolve().then(() => (init_compileSvelte(), exports_compileSvelte)).then((mod) => mod.compileSvelte(islandSvelteSources, svelteDir, new Map, hmr, styleTransformConfig)) : {
|
|
8044
8175
|
svelteClientPaths: [...emptyStringArray]
|
|
8045
8176
|
},
|
|
8046
|
-
shouldCompileIslandVue ? Promise.resolve().then(() => (init_compileVue(), exports_compileVue)).then((mod) => mod.compileVue(islandVueSources, vueDir, hmr,
|
|
8177
|
+
shouldCompileIslandVue ? Promise.resolve().then(() => (init_compileVue(), exports_compileVue)).then((mod) => mod.compileVue(islandVueSources, vueDir, hmr, styleTransformConfig)) : {
|
|
8047
8178
|
vueClientPaths: [...emptyStringArray]
|
|
8048
8179
|
},
|
|
8049
|
-
shouldCompileIslandAngular ? Promise.resolve().then(() => (init_compileAngular(), exports_compileAngular)).then((mod) => mod.compileAngular(islandAngularSources, angularDir, hmr,
|
|
8180
|
+
shouldCompileIslandAngular ? Promise.resolve().then(() => (init_compileAngular(), exports_compileAngular)).then((mod) => mod.compileAngular(islandAngularSources, angularDir, hmr, styleTransformConfig)) : {
|
|
8050
8181
|
clientPaths: [...emptyStringArray]
|
|
8051
8182
|
}
|
|
8052
8183
|
]);
|
|
@@ -8078,8 +8209,8 @@ ${content.slice(firstUseIdx)}`;
|
|
|
8078
8209
|
const vueConventionSources = collectConventionSourceFiles(conventionsMap.vue);
|
|
8079
8210
|
if (svelteConventionSources.length > 0 || vueConventionSources.length > 0) {
|
|
8080
8211
|
const [svelteConvResult, vueConvResult] = await Promise.all([
|
|
8081
|
-
svelteConventionSources.length > 0 && svelteDir ? Promise.resolve().then(() => (init_compileSvelte(), exports_compileSvelte)).then((mod) => mod.compileSvelte(svelteConventionSources, svelteDir, new Map, false,
|
|
8082
|
-
vueConventionSources.length > 0 && vueDir ? Promise.resolve().then(() => (init_compileVue(), exports_compileVue)).then((mod) => mod.compileVue(vueConventionSources, vueDir, false,
|
|
8212
|
+
svelteConventionSources.length > 0 && svelteDir ? Promise.resolve().then(() => (init_compileSvelte(), exports_compileSvelte)).then((mod) => mod.compileSvelte(svelteConventionSources, svelteDir, new Map, false, styleTransformConfig)) : { svelteServerPaths: emptyStringArray },
|
|
8213
|
+
vueConventionSources.length > 0 && vueDir ? Promise.resolve().then(() => (init_compileVue(), exports_compileVue)).then((mod) => mod.compileVue(vueConventionSources, vueDir, false, styleTransformConfig)) : { vueServerPaths: emptyStringArray }
|
|
8083
8214
|
]);
|
|
8084
8215
|
const copyConventionFiles = (framework, sources, compiledPaths) => {
|
|
8085
8216
|
const destDir = join19(buildPath, "conventions", framework);
|
|
@@ -10827,7 +10958,7 @@ var init_simpleHTMXHMR = () => {};
|
|
|
10827
10958
|
// src/dev/rebuildTrigger.ts
|
|
10828
10959
|
import { existsSync as existsSync22 } from "fs";
|
|
10829
10960
|
import { basename as basename13, dirname as dirname15, relative as relative12, resolve as resolve32 } from "path";
|
|
10830
|
-
var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseErrorLocationFromMessage = (msg) => {
|
|
10961
|
+
var moduleServerPromise, getModuleServer = () => moduleServerPromise, getStyleTransformConfig = (config) => createStyleTransformConfig(config.stylePreprocessors, config.postcss), parseErrorLocationFromMessage = (msg) => {
|
|
10831
10962
|
const pathLineCol = msg.match(/^([^\s:]+):(\d+)(?::(\d+))?/);
|
|
10832
10963
|
if (pathLineCol) {
|
|
10833
10964
|
const [, file4, lineStr, colStr] = pathLineCol;
|
|
@@ -11135,7 +11266,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
|
|
|
11135
11266
|
naming: "[dir]/[name].[hash].[ext]",
|
|
11136
11267
|
outdir: buildDir,
|
|
11137
11268
|
plugins: [
|
|
11138
|
-
createStylePreprocessorPlugin(state.config
|
|
11269
|
+
createStylePreprocessorPlugin(getStyleTransformConfig(state.config))
|
|
11139
11270
|
],
|
|
11140
11271
|
root: clientRoot,
|
|
11141
11272
|
target: "browser",
|
|
@@ -11177,7 +11308,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
|
|
|
11177
11308
|
});
|
|
11178
11309
|
}, compileAndBundleAngular = async (state, pageEntries, angularDir) => {
|
|
11179
11310
|
const { compileAngular: compileAngular2 } = await Promise.resolve().then(() => (init_compileAngular(), exports_compileAngular));
|
|
11180
|
-
const { clientPaths, serverPaths } = await compileAngular2(pageEntries, angularDir, true, state.config
|
|
11311
|
+
const { clientPaths, serverPaths } = await compileAngular2(pageEntries, angularDir, true, getStyleTransformConfig(state.config));
|
|
11181
11312
|
serverPaths.forEach((serverPath) => {
|
|
11182
11313
|
const fileBase = basename13(serverPath, ".js");
|
|
11183
11314
|
state.manifest[toPascal(fileBase)] = resolve32(serverPath);
|
|
@@ -11270,7 +11401,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
|
|
|
11270
11401
|
naming: "[dir]/[name].[hash].[ext]",
|
|
11271
11402
|
outdir: buildDir,
|
|
11272
11403
|
plugins: [
|
|
11273
|
-
createStylePreprocessorPlugin(state.config
|
|
11404
|
+
createStylePreprocessorPlugin(getStyleTransformConfig(state.config))
|
|
11274
11405
|
],
|
|
11275
11406
|
reactFastRefresh: true,
|
|
11276
11407
|
root: clientRoot,
|
|
@@ -11444,7 +11575,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
|
|
|
11444
11575
|
const { compileSvelte: compileSvelte2 } = await Promise.resolve().then(() => (init_compileSvelte(), exports_compileSvelte));
|
|
11445
11576
|
const { build: bunBuild7 } = await Promise.resolve(globalThis.Bun);
|
|
11446
11577
|
const clientRoot = await computeClientRoot(state.resolvedPaths);
|
|
11447
|
-
const { svelteServerPaths, svelteIndexPaths, svelteClientPaths } = await compileSvelte2(svelteFiles, svelteDir, new Map, true, state.config
|
|
11578
|
+
const { svelteServerPaths, svelteIndexPaths, svelteClientPaths } = await compileSvelte2(svelteFiles, svelteDir, new Map, true, getStyleTransformConfig(state.config));
|
|
11448
11579
|
const serverEntries = [...svelteServerPaths];
|
|
11449
11580
|
const clientEntries = [...svelteIndexPaths, ...svelteClientPaths];
|
|
11450
11581
|
const serverRoot = resolve32(svelteDir, "generated", "server");
|
|
@@ -11464,7 +11595,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
|
|
|
11464
11595
|
naming: "[dir]/[name].[hash].[ext]",
|
|
11465
11596
|
outdir: serverOutDir,
|
|
11466
11597
|
plugins: [
|
|
11467
|
-
createStylePreprocessorPlugin(state.config
|
|
11598
|
+
createStylePreprocessorPlugin(getStyleTransformConfig(state.config))
|
|
11468
11599
|
],
|
|
11469
11600
|
root: serverRoot,
|
|
11470
11601
|
target: "bun",
|
|
@@ -11476,7 +11607,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
|
|
|
11476
11607
|
naming: "[dir]/[name].[hash].[ext]",
|
|
11477
11608
|
outdir: buildDir,
|
|
11478
11609
|
plugins: [
|
|
11479
|
-
createStylePreprocessorPlugin(state.config
|
|
11610
|
+
createStylePreprocessorPlugin(getStyleTransformConfig(state.config))
|
|
11480
11611
|
],
|
|
11481
11612
|
root: clientRoot,
|
|
11482
11613
|
target: "browser",
|
|
@@ -13440,167 +13571,6 @@ var MAX_STARTUP_ATTEMPTS = 50, STARTUP_POLL_INTERVAL_MS = 100, PRERENDER_BYPASS_
|
|
|
13440
13571
|
return result;
|
|
13441
13572
|
};
|
|
13442
13573
|
var init_prerender = () => {};
|
|
13443
|
-
|
|
13444
|
-
// src/react/index.ts
|
|
13445
|
-
init_pageHandler();
|
|
13446
|
-
|
|
13447
|
-
// src/react/Island.tsx
|
|
13448
|
-
init_islandMarkupAttributes();
|
|
13449
|
-
init_renderIslandMarkup();
|
|
13450
|
-
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
13451
|
-
var Island = async (props) => {
|
|
13452
|
-
if (typeof window !== "undefined") {
|
|
13453
|
-
return /* @__PURE__ */ jsxDEV("div", {
|
|
13454
|
-
...getIslandMarkerAttributes(props),
|
|
13455
|
-
suppressHydrationWarning: true
|
|
13456
|
-
}, undefined, false, undefined, this);
|
|
13457
|
-
}
|
|
13458
|
-
const result = await renderIslandResult(requireCurrentIslandRegistry(), props);
|
|
13459
|
-
return /* @__PURE__ */ jsxDEV("div", {
|
|
13460
|
-
...result.attributes,
|
|
13461
|
-
dangerouslySetInnerHTML: { __html: result.html }
|
|
13462
|
-
}, undefined, false, undefined, this);
|
|
13463
|
-
};
|
|
13464
|
-
// src/react/createIsland.tsx
|
|
13465
|
-
init_islandMarkupAttributes();
|
|
13466
|
-
init_renderIslandMarkup();
|
|
13467
|
-
import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
|
|
13468
|
-
var createTypedIsland = (registry) => {
|
|
13469
|
-
const Island2 = async (props) => {
|
|
13470
|
-
if (typeof window !== "undefined") {
|
|
13471
|
-
return /* @__PURE__ */ jsxDEV2("div", {
|
|
13472
|
-
...getIslandMarkerAttributes(props),
|
|
13473
|
-
suppressHydrationWarning: true
|
|
13474
|
-
}, undefined, false, undefined, this);
|
|
13475
|
-
}
|
|
13476
|
-
const result = await renderIslandResult(registry, props);
|
|
13477
|
-
return /* @__PURE__ */ jsxDEV2("div", {
|
|
13478
|
-
...result.attributes,
|
|
13479
|
-
dangerouslySetInnerHTML: { __html: result.html }
|
|
13480
|
-
}, undefined, false, undefined, this);
|
|
13481
|
-
};
|
|
13482
|
-
return Island2;
|
|
13483
|
-
};
|
|
13484
|
-
// src/react/hooks/useIslandStore.ts
|
|
13485
|
-
import { useSyncExternalStore } from "react";
|
|
13486
|
-
|
|
13487
|
-
// node_modules/zustand/esm/vanilla.mjs
|
|
13488
|
-
var createStoreImpl = (createState) => {
|
|
13489
|
-
let state;
|
|
13490
|
-
const listeners = /* @__PURE__ */ new Set;
|
|
13491
|
-
const setState = (partial, replace) => {
|
|
13492
|
-
const nextState = typeof partial === "function" ? partial(state) : partial;
|
|
13493
|
-
if (!Object.is(nextState, state)) {
|
|
13494
|
-
const previousState = state;
|
|
13495
|
-
state = (replace != null ? replace : typeof nextState !== "object" || nextState === null) ? nextState : Object.assign({}, state, nextState);
|
|
13496
|
-
listeners.forEach((listener) => listener(state, previousState));
|
|
13497
|
-
}
|
|
13498
|
-
};
|
|
13499
|
-
const getState = () => state;
|
|
13500
|
-
const getInitialState = () => initialState;
|
|
13501
|
-
const subscribe = (listener) => {
|
|
13502
|
-
listeners.add(listener);
|
|
13503
|
-
return () => listeners.delete(listener);
|
|
13504
|
-
};
|
|
13505
|
-
const api = { setState, getState, getInitialState, subscribe };
|
|
13506
|
-
const initialState = state = createState(setState, getState, api);
|
|
13507
|
-
return api;
|
|
13508
|
-
};
|
|
13509
|
-
var createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;
|
|
13510
|
-
|
|
13511
|
-
// node_modules/zustand/esm/middleware.mjs
|
|
13512
|
-
function combine(initialState, create) {
|
|
13513
|
-
return (...args) => Object.assign({}, initialState, create(...args));
|
|
13514
|
-
}
|
|
13515
|
-
|
|
13516
|
-
// src/client/islandStore.ts
|
|
13517
|
-
var getIslandStoreSnapshot = () => {
|
|
13518
|
-
globalThis.__ABS_ISLAND_STATE__ ??= {};
|
|
13519
|
-
return globalThis.__ABS_ISLAND_STATE__;
|
|
13520
|
-
};
|
|
13521
|
-
var getIslandStores = () => {
|
|
13522
|
-
globalThis.__ABS_ISLAND_STORES__ ??= new Map;
|
|
13523
|
-
return globalThis.__ABS_ISLAND_STORES__;
|
|
13524
|
-
};
|
|
13525
|
-
var isSerializableValue = (value) => typeof value !== "function" && value !== undefined;
|
|
13526
|
-
var toSerializableState = (state) => Object.fromEntries(Object.entries(state).filter(([, value]) => isSerializableValue(value)));
|
|
13527
|
-
var applySnapshot = (store, snapshot) => {
|
|
13528
|
-
if (!snapshot) {
|
|
13529
|
-
return;
|
|
13530
|
-
}
|
|
13531
|
-
store.setState({
|
|
13532
|
-
...store.getState(),
|
|
13533
|
-
...snapshot
|
|
13534
|
-
});
|
|
13535
|
-
};
|
|
13536
|
-
var getPeerStores = (storeInstances, ownerStore) => [...storeInstances].filter((peer) => peer.store !== ownerStore);
|
|
13537
|
-
var syncIslandSnapshot = (storeId, state, storeInstances, ownerStore) => {
|
|
13538
|
-
const nextSnapshot = toSerializableState(state);
|
|
13539
|
-
getIslandStoreSnapshot()[storeId] = nextSnapshot;
|
|
13540
|
-
for (const peerStore of getPeerStores(storeInstances, ownerStore)) {
|
|
13541
|
-
peerStore.applyExternalSnapshot(nextSnapshot);
|
|
13542
|
-
}
|
|
13543
|
-
};
|
|
13544
|
-
var createIslandStore = (storeId, initialState, createState) => {
|
|
13545
|
-
const store = createStore(combine(initialState, createState));
|
|
13546
|
-
const stores = getIslandStores();
|
|
13547
|
-
const storeInstances = stores.get(storeId) ?? new Set;
|
|
13548
|
-
const initialSnapshot = getIslandStoreSnapshot()[storeId];
|
|
13549
|
-
applySnapshot(store, initialSnapshot);
|
|
13550
|
-
let isApplyingExternalSnapshot = false;
|
|
13551
|
-
const applyExternalSnapshot = (snapshot) => {
|
|
13552
|
-
isApplyingExternalSnapshot = true;
|
|
13553
|
-
applySnapshot(store, snapshot);
|
|
13554
|
-
};
|
|
13555
|
-
storeInstances.add({
|
|
13556
|
-
applyExternalSnapshot,
|
|
13557
|
-
store
|
|
13558
|
-
});
|
|
13559
|
-
stores.set(storeId, storeInstances);
|
|
13560
|
-
syncIslandSnapshot(storeId, store.getState(), storeInstances, store);
|
|
13561
|
-
store.subscribe((state) => {
|
|
13562
|
-
if (isApplyingExternalSnapshot) {
|
|
13563
|
-
isApplyingExternalSnapshot = false;
|
|
13564
|
-
return;
|
|
13565
|
-
}
|
|
13566
|
-
syncIslandSnapshot(storeId, state, storeInstances, store);
|
|
13567
|
-
});
|
|
13568
|
-
return store;
|
|
13569
|
-
};
|
|
13570
|
-
var getIslandStoreServerSnapshot = (store, selector) => selector(store.getInitialState());
|
|
13571
|
-
var applySnapshotToStoreInstances = (storeId, instances, snapshot) => {
|
|
13572
|
-
for (const instance of instances) {
|
|
13573
|
-
instance.applyExternalSnapshot(snapshot[storeId] ?? {});
|
|
13574
|
-
}
|
|
13575
|
-
};
|
|
13576
|
-
var initializeIslandStores = (state) => {
|
|
13577
|
-
const currentSnapshot = getIslandStoreSnapshot();
|
|
13578
|
-
const nextSnapshot = {
|
|
13579
|
-
...state,
|
|
13580
|
-
...currentSnapshot
|
|
13581
|
-
};
|
|
13582
|
-
globalThis.__ABS_ISLAND_STATE__ = nextSnapshot;
|
|
13583
|
-
for (const [storeId, store] of getIslandStores()) {
|
|
13584
|
-
applySnapshotToStoreInstances(storeId, store, nextSnapshot);
|
|
13585
|
-
}
|
|
13586
|
-
};
|
|
13587
|
-
var readIslandStore = (store, selector) => selector(store.getState());
|
|
13588
|
-
var subscribeIslandStore = (store, selector, listener) => {
|
|
13589
|
-
let currentSelection = selector(store.getState());
|
|
13590
|
-
return store.subscribe((state) => {
|
|
13591
|
-
const nextSelection = selector(state);
|
|
13592
|
-
if (Object.is(nextSelection, currentSelection)) {
|
|
13593
|
-
return;
|
|
13594
|
-
}
|
|
13595
|
-
currentSelection = nextSelection;
|
|
13596
|
-
listener(nextSelection);
|
|
13597
|
-
});
|
|
13598
|
-
};
|
|
13599
|
-
|
|
13600
|
-
// src/react/hooks/useIslandStore.ts
|
|
13601
|
-
var useIslandStore = (store, selector) => useSyncExternalStore((listener) => subscribeIslandStore(store, selector, () => {
|
|
13602
|
-
listener();
|
|
13603
|
-
}), () => readIslandStore(store, selector), () => getIslandStoreServerSnapshot(store, selector));
|
|
13604
13574
|
// types/client.ts
|
|
13605
13575
|
var hmrState = {
|
|
13606
13576
|
isConnected: false,
|
|
@@ -13630,6 +13600,10 @@ init_islandPageContext();
|
|
|
13630
13600
|
init_staticStreaming();
|
|
13631
13601
|
init_responseEnhancers();
|
|
13632
13602
|
var {file } = globalThis.Bun;
|
|
13603
|
+
var handleReactPageRequest2 = async (...args) => {
|
|
13604
|
+
const { handleReactPageRequest: handle } = await Promise.resolve().then(() => (init_pageHandler(), exports_pageHandler));
|
|
13605
|
+
return handle(...args);
|
|
13606
|
+
};
|
|
13633
13607
|
var handleStaticPageRequest = async (pagePath, options = {}, settings = {}) => {
|
|
13634
13608
|
const html = await file(pagePath).text();
|
|
13635
13609
|
const transformedHtml = await transformCurrentStaticPageHtml(html, settings);
|
|
@@ -13688,6 +13662,7 @@ var RESERVED_TOP_LEVEL_KEYS = new Set([
|
|
|
13688
13662
|
"mode",
|
|
13689
13663
|
"options",
|
|
13690
13664
|
"port",
|
|
13665
|
+
"postcss",
|
|
13691
13666
|
"publicDirectory",
|
|
13692
13667
|
"reactDirectory",
|
|
13693
13668
|
"sitemap",
|
|
@@ -13909,6 +13884,7 @@ var prepareDev = async (config, buildDir) => {
|
|
|
13909
13884
|
...depVendorPaths
|
|
13910
13885
|
};
|
|
13911
13886
|
const { setGlobalModuleServer: setGlobalModuleServer2 } = await Promise.resolve().then(() => (init_moduleServer(), exports_moduleServer));
|
|
13887
|
+
const { createStyleTransformConfig: createStyleTransformConfig2 } = await Promise.resolve().then(() => (init_stylePreprocessor(), exports_stylePreprocessor));
|
|
13912
13888
|
const moduleHandler = createModuleServer2({
|
|
13913
13889
|
frameworkDirs: {
|
|
13914
13890
|
angular: config.angularDirectory,
|
|
@@ -13917,7 +13893,7 @@ var prepareDev = async (config, buildDir) => {
|
|
|
13917
13893
|
vue: config.vueDirectory
|
|
13918
13894
|
},
|
|
13919
13895
|
projectRoot: process.cwd(),
|
|
13920
|
-
stylePreprocessors: config.stylePreprocessors,
|
|
13896
|
+
stylePreprocessors: createStyleTransformConfig2(config.stylePreprocessors, config.postcss),
|
|
13921
13897
|
vendorPaths: allVendorPaths
|
|
13922
13898
|
});
|
|
13923
13899
|
setGlobalModuleServer2(moduleHandler);
|
|
@@ -20612,7 +20588,7 @@ export {
|
|
|
20612
20588
|
injectHtmlIntoHead,
|
|
20613
20589
|
injectHtmlIntoBody,
|
|
20614
20590
|
hmrState,
|
|
20615
|
-
handleReactPageRequest,
|
|
20591
|
+
handleReactPageRequest2 as handleReactPageRequest,
|
|
20616
20592
|
handleHTMXPageRequest,
|
|
20617
20593
|
handleHTMLPageRequest,
|
|
20618
20594
|
getStreamingSlotsRuntimeScript,
|
|
@@ -20695,5 +20671,5 @@ export {
|
|
|
20695
20671
|
ANGULAR_INIT_TIMEOUT_MS
|
|
20696
20672
|
};
|
|
20697
20673
|
|
|
20698
|
-
//# debugId=
|
|
20674
|
+
//# debugId=97970AA6F03C57D864756E2164756E21
|
|
20699
20675
|
//# sourceMappingURL=index.js.map
|