@absolutejs/absolute 0.19.0-beta.695 → 0.19.0-beta.696
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/angular/browser.js +48 -40
- package/dist/angular/browser.js.map +4 -4
- package/dist/angular/index.js +2308 -2232
- package/dist/angular/index.js.map +14 -13
- package/dist/angular/server.js +2279 -2203
- package/dist/angular/server.js.map +14 -14
- package/dist/build.js +42796 -6393
- package/dist/build.js.map +8 -19
- package/dist/cli/index.js +1 -1
- package/dist/core/streamingSlotRegistrar.js +24 -16
- package/dist/core/streamingSlotRegistrar.js.map +2 -2
- package/dist/core/streamingSlotRegistry.js +42 -29
- package/dist/core/streamingSlotRegistry.js.map +2 -2
- package/dist/index.js +42693 -5631
- package/dist/index.js.map +18 -23
- package/dist/react/components/index.js +24 -16
- package/dist/react/components/index.js.map +2 -2
- package/dist/react/index.js +922 -868
- package/dist/react/index.js.map +12 -12
- package/dist/react/server.js +903 -848
- package/dist/react/server.js.map +11 -11
- package/dist/src/build/compileTailwind.d.ts +3 -0
- package/dist/src/core/pageHandlers.d.ts +0 -2
- package/dist/src/core/ssrCache.d.ts +3 -0
- package/dist/svelte/index.js +963 -899
- package/dist/svelte/index.js.map +14 -13
- package/dist/svelte/server.js +777 -712
- package/dist/svelte/server.js.map +12 -12
- package/dist/types/build.d.ts +5 -4
- package/dist/types/index.d.ts +0 -1
- package/dist/types/island.d.ts +14 -11
- package/dist/vue/components/index.js +24 -16
- package/dist/vue/components/index.js.map +2 -2
- package/dist/vue/index.js +1040 -976
- package/dist/vue/index.js.map +12 -12
- package/dist/vue/server.js +908 -841
- package/dist/vue/server.js.map +11 -11
- package/package.json +16 -8
package/dist/angular/index.js
CHANGED
|
@@ -78,99 +78,6 @@ var __legacyMetadataTS = (k, v) => {
|
|
|
78
78
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
79
79
|
var __require = import.meta.require;
|
|
80
80
|
|
|
81
|
-
// src/core/streamingSlotRegistrar.ts
|
|
82
|
-
var STREAMING_SLOT_REGISTRAR_KEY, STREAMING_SLOT_WARNING_STORAGE_KEY, STREAMING_SLOT_COLLECTION_STORAGE_KEY, getRegisteredStreamingSlotRegistrar = () => {
|
|
83
|
-
const value = Reflect.get(globalThis, STREAMING_SLOT_REGISTRAR_KEY);
|
|
84
|
-
if (typeof value === "function" || value === null) {
|
|
85
|
-
return value;
|
|
86
|
-
}
|
|
87
|
-
return;
|
|
88
|
-
}, isObjectRecord = (value) => Boolean(value) && typeof value === "object", isStreamingSlotWarningController = (value) => isObjectRecord(value) && ("maybeWarn" in value) && typeof value.maybeWarn === "function", isStreamingSlotCollectionController = (value) => isObjectRecord(value) && ("isCollecting" in value) && typeof value.isCollecting === "function", getWarningController = () => {
|
|
89
|
-
const value = Reflect.get(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY);
|
|
90
|
-
if (value === null || typeof value === "undefined")
|
|
91
|
-
return;
|
|
92
|
-
return isStreamingSlotWarningController(value) ? value : undefined;
|
|
93
|
-
}, getCollectionController = () => {
|
|
94
|
-
const value = Reflect.get(globalThis, STREAMING_SLOT_COLLECTION_STORAGE_KEY);
|
|
95
|
-
if (value === null || typeof value === "undefined")
|
|
96
|
-
return;
|
|
97
|
-
return isStreamingSlotCollectionController(value) ? value : undefined;
|
|
98
|
-
}, hasRegisteredStreamingSlotRegistrar = () => typeof getRegisteredStreamingSlotRegistrar() === "function", isStreamingSlotCollectionActive = () => getCollectionController()?.isCollecting() === true, registerStreamingSlot = (slot) => {
|
|
99
|
-
getRegisteredStreamingSlotRegistrar()?.(slot);
|
|
100
|
-
}, setStreamingSlotCollectionController = (controller) => {
|
|
101
|
-
Reflect.set(globalThis, STREAMING_SLOT_COLLECTION_STORAGE_KEY, controller);
|
|
102
|
-
}, setStreamingSlotRegistrar = (nextRegistrar) => {
|
|
103
|
-
Reflect.set(globalThis, STREAMING_SLOT_REGISTRAR_KEY, nextRegistrar);
|
|
104
|
-
}, setStreamingSlotWarningController = (controller) => {
|
|
105
|
-
Reflect.set(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY, controller);
|
|
106
|
-
}, warnMissingStreamingSlotCollector = (primitiveName) => {
|
|
107
|
-
if (isStreamingSlotCollectionActive()) {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
getWarningController()?.maybeWarn(primitiveName);
|
|
111
|
-
};
|
|
112
|
-
var init_streamingSlotRegistrar = __esm(() => {
|
|
113
|
-
STREAMING_SLOT_REGISTRAR_KEY = Symbol.for("absolutejs.streamingSlotRegistrar");
|
|
114
|
-
STREAMING_SLOT_WARNING_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotWarningController");
|
|
115
|
-
STREAMING_SLOT_COLLECTION_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotCollectionController");
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
// src/core/streamingSlotRegistry.ts
|
|
119
|
-
var STREAMING_SLOT_STORAGE_KEY, isObjectRecord2 = (value) => Boolean(value) && typeof value === "object", isAsyncLocalStorage = (value) => isObjectRecord2(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function", getStorageGlobal = () => {
|
|
120
|
-
const value = Reflect.get(globalThis, STREAMING_SLOT_STORAGE_KEY);
|
|
121
|
-
if (value === null || typeof value === "undefined") {
|
|
122
|
-
return value;
|
|
123
|
-
}
|
|
124
|
-
return isAsyncLocalStorage(value) ? value : undefined;
|
|
125
|
-
}, isServerRuntime = () => typeof process !== "undefined" && typeof process.versions?.node === "string", ensureAsyncLocalStorage = async () => {
|
|
126
|
-
const storage = getStorageGlobal();
|
|
127
|
-
if (typeof storage !== "undefined") {
|
|
128
|
-
return storage;
|
|
129
|
-
}
|
|
130
|
-
if (!isServerRuntime()) {
|
|
131
|
-
Reflect.set(globalThis, STREAMING_SLOT_STORAGE_KEY, null);
|
|
132
|
-
return getStorageGlobal();
|
|
133
|
-
}
|
|
134
|
-
const mod = await import("async_hooks");
|
|
135
|
-
Reflect.set(globalThis, STREAMING_SLOT_STORAGE_KEY, new mod.AsyncLocalStorage);
|
|
136
|
-
return getStorageGlobal();
|
|
137
|
-
}, getActiveSlotStore = () => {
|
|
138
|
-
const storage = getStorageGlobal();
|
|
139
|
-
if (!storage)
|
|
140
|
-
return;
|
|
141
|
-
return storage.getStore();
|
|
142
|
-
}, registerStreamingSlot2 = (slot) => {
|
|
143
|
-
const store = getActiveSlotStore();
|
|
144
|
-
if (!store)
|
|
145
|
-
return;
|
|
146
|
-
store.set(slot.id, slot);
|
|
147
|
-
}, hasActiveStreamingSlotRegistry = () => getActiveSlotStore() !== undefined, runWithStreamingSlotRegistry = async (task) => {
|
|
148
|
-
const storage = await ensureAsyncLocalStorage();
|
|
149
|
-
if (!storage) {
|
|
150
|
-
const slots = [];
|
|
151
|
-
return {
|
|
152
|
-
result: await task(),
|
|
153
|
-
slots
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
return storage.run(new Map, async () => {
|
|
157
|
-
const result = await task();
|
|
158
|
-
const store = storage.getStore();
|
|
159
|
-
return {
|
|
160
|
-
result,
|
|
161
|
-
slots: store ? [...store.values()] : []
|
|
162
|
-
};
|
|
163
|
-
});
|
|
164
|
-
};
|
|
165
|
-
var init_streamingSlotRegistry = __esm(() => {
|
|
166
|
-
init_streamingSlotRegistrar();
|
|
167
|
-
STREAMING_SLOT_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotAsyncLocalStorage");
|
|
168
|
-
setStreamingSlotRegistrar(registerStreamingSlot2);
|
|
169
|
-
setStreamingSlotCollectionController({
|
|
170
|
-
isCollecting: () => getActiveSlotStore() !== undefined
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
|
|
174
81
|
// src/constants.ts
|
|
175
82
|
var ANGULAR_INIT_TIMEOUT_MS = 500, ANSI_ESCAPE_LENGTH = 3, ASCII_SPACE = 32, BASE_36_RADIX = 36, BUN_BUILD_WARNING_SUPPRESSION = "wildcard sideEffects are not supported yet", BODY_SLICE_LENGTH = 2000, BYTES_PER_KILOBYTE = 1024, CLI_ARGS_OFFSET = 3, CSS_ERROR_RESOLVE_DELAY_MS = 50, CSS_MAX_CHECK_ATTEMPTS = 10, CSS_MAX_PARSE_TIMEOUT_MS = 500, CSS_SHEET_READY_TIMEOUT_MS = 100, DEFAULT_CHUNK_SIZE = 16384, DEFAULT_DEBOUNCE_MS = 15, DEFAULT_PORT = 3000, DEV_SERVER_RESTART_DEBOUNCE_MS = 100, DOM_UPDATE_DELAY_MS = 50, FILE_PROTOCOL_PREFIX_LENGTH = 7, FOCUS_ID_PREFIX_LENGTH = 3, FOCUS_IDX_PREFIX_LENGTH = 4, FOCUS_NAME_PREFIX_LENGTH = 5, HMR_UPDATE_TIMEOUT_MS = 2000, HOOK_SIGNATURE_LENGTH = 12, EXCLUDE_LAST_OFFSET = -1, HTTP_STATUS_OK = 200, HTTP_STATUS_BAD_REQUEST = 400, HTTP_STATUS_NOT_FOUND = 404, HOURS_IN_DAY = 24, HOURS_IN_HALF_DAY = 12, MAX_ERROR_LENGTH = 200, MAX_RECONNECT_ATTEMPTS = 60, MILLISECONDS_IN_A_SECOND = 1000, MINUTES_IN_AN_HOUR = 60, SECONDS_IN_A_MINUTE = 60, MILLISECONDS_IN_A_MINUTE, MILLISECONDS_IN_A_DAY, OVERLAY_FADE_DURATION_MS = 150, PING_INTERVAL_MS = 30000, RAF_BATCH_COUNT = 3, RANDOM_ID_END_INDEX = 11, REBUILD_BATCH_DELAY_MS = 10, REBUILD_RELOAD_DELAY_MS = 200, RECONNECT_INITIAL_DELAY_MS = 500, RECONNECT_POLL_INTERVAL_MS = 300, REACT_STREAM_SLOT_FAST_DELAY_MS = 5, REACT_STREAM_SLOT_SLOW_DELAY_MS = 20, SIGINT_EXIT_CODE = 130, SIGTERM_EXIT_CODE = 143, SVELTE_CSS_LOAD_TIMEOUT_MS = 500, TIME_PRECISION = 2, TWO_THIRDS, UNFOUND_INDEX = -1, WEBSOCKET_NORMAL_CLOSURE = 1000;
|
|
176
83
|
var init_constants = __esm(() => {
|
|
@@ -179,1838 +86,1396 @@ var init_constants = __esm(() => {
|
|
|
179
86
|
TWO_THIRDS = 2 / 3;
|
|
180
87
|
});
|
|
181
88
|
|
|
182
|
-
// src/
|
|
183
|
-
var
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
const bootstrapPath = manifest[BOOTSTRAP_MANIFEST_KEY];
|
|
187
|
-
const bootstrapScript = bootstrapPath ? `<script type="module" src="${bootstrapPath}"></script>` : "";
|
|
188
|
-
return `${manifestScript}${islandStateScript}${bootstrapScript}`;
|
|
189
|
-
}, injectHeadMarkup = (html, markup) => {
|
|
190
|
-
const closingHeadIndex = html.indexOf("</head>");
|
|
191
|
-
if (closingHeadIndex >= 0) {
|
|
192
|
-
return `${html.slice(0, closingHeadIndex)}${markup}${html.slice(closingHeadIndex)}`;
|
|
89
|
+
// src/utils/stringModifiers.ts
|
|
90
|
+
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) => {
|
|
91
|
+
if (!str.includes("-") && !str.includes("_")) {
|
|
92
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
193
93
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
94
|
+
return normalizeSlug(str).split(/[-_]/).filter(Boolean).map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1).toLowerCase()).join("");
|
|
95
|
+
}, toScreamingSnake = (str) => str.replace(/([a-z0-9])([A-Z])/g, "$1_$2").toUpperCase();
|
|
96
|
+
|
|
97
|
+
// src/utils/registerClientScript.ts
|
|
98
|
+
var scriptRegistry, requestCounter = 0, getRequestId = () => `req_${Date.now()}_${++requestCounter}`, ssrContextGetter = null, getSsrContextId = () => ssrContextGetter?.() || Object.getOwnPropertyDescriptor(globalThis, "__absolutejs_requestId")?.value, registerClientScript = (script, requestId) => {
|
|
99
|
+
const id = requestId || getSsrContextId() || getRequestId();
|
|
100
|
+
if (!scriptRegistry.has(id)) {
|
|
101
|
+
scriptRegistry.set(id, new Set);
|
|
102
|
+
}
|
|
103
|
+
scriptRegistry.get(id)?.add(script);
|
|
104
|
+
return id;
|
|
105
|
+
}, setSsrContextGetter = (getter) => {
|
|
106
|
+
ssrContextGetter = getter;
|
|
107
|
+
}, clearAllClientScripts = () => {
|
|
108
|
+
scriptRegistry.clear();
|
|
109
|
+
}, generateClientScriptCode = (scripts) => {
|
|
110
|
+
if (scripts.length === 0) {
|
|
111
|
+
return "";
|
|
112
|
+
}
|
|
113
|
+
const scriptCode = scripts.map((script, index) => {
|
|
114
|
+
const funcString = script.toString();
|
|
115
|
+
const bodyMatch = funcString.match(/\{([\s\S]*)\}/);
|
|
116
|
+
if (!bodyMatch || !bodyMatch[1]) {
|
|
117
|
+
return "";
|
|
199
118
|
}
|
|
119
|
+
const body = bodyMatch[1].trim();
|
|
120
|
+
return `
|
|
121
|
+
(function() {
|
|
122
|
+
var executed = false;
|
|
123
|
+
function executeScript_${index}() {
|
|
124
|
+
if (executed) return;
|
|
125
|
+
executed = true;
|
|
126
|
+
${body}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (document.readyState === 'complete' || document.readyState === 'interactive') {
|
|
130
|
+
executeScript_${index}();
|
|
131
|
+
} else {
|
|
132
|
+
document.addEventListener('DOMContentLoaded', executeScript_${index});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Watch for hydration-added elements
|
|
136
|
+
var observer = new MutationObserver(function() {
|
|
137
|
+
executeScript_${index}();
|
|
138
|
+
if (executed) observer.disconnect();
|
|
139
|
+
});
|
|
140
|
+
if (!executed) {
|
|
141
|
+
observer.observe(document.body || document.documentElement, { childList: true, subtree: true });
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Single fallback timeout
|
|
145
|
+
setTimeout(function() {
|
|
146
|
+
executeScript_${index}();
|
|
147
|
+
observer.disconnect();
|
|
148
|
+
}, 1000);
|
|
149
|
+
})();`;
|
|
150
|
+
}).join(`
|
|
151
|
+
`);
|
|
152
|
+
return `<script>
|
|
153
|
+
(function() {
|
|
154
|
+
${scriptCode}
|
|
155
|
+
})();
|
|
156
|
+
</script>`;
|
|
157
|
+
}, getAndClearClientScripts = (requestId) => {
|
|
158
|
+
const id = requestId || ssrContextGetter?.();
|
|
159
|
+
if (!id)
|
|
160
|
+
return [];
|
|
161
|
+
const scripts = scriptRegistry.get(id);
|
|
162
|
+
if (!scripts) {
|
|
163
|
+
return [];
|
|
200
164
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
165
|
+
const scriptArray = Array.from(scripts);
|
|
166
|
+
scriptRegistry.delete(id);
|
|
167
|
+
return scriptArray;
|
|
168
|
+
};
|
|
169
|
+
var init_registerClientScript = __esm(() => {
|
|
170
|
+
scriptRegistry = new Map;
|
|
171
|
+
if (typeof globalThis !== "undefined") {
|
|
172
|
+
Object.assign(globalThis, { registerClientScript });
|
|
205
173
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
// src/angular/injectorPatch.ts
|
|
177
|
+
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
178
|
+
import { dirname, join, resolve } from "path";
|
|
179
|
+
var applyInjectorPatch = (chunkPath, content) => {
|
|
180
|
+
if (content.includes('Symbol.for("angular.currentInjector")')) {
|
|
181
|
+
return;
|
|
212
182
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
return
|
|
183
|
+
const original = [
|
|
184
|
+
"let _currentInjector = undefined;",
|
|
185
|
+
"function getCurrentInjector() {",
|
|
186
|
+
" return _currentInjector;",
|
|
187
|
+
"}",
|
|
188
|
+
"function setCurrentInjector(injector) {",
|
|
189
|
+
" const former = _currentInjector;",
|
|
190
|
+
" _currentInjector = injector;",
|
|
191
|
+
" return former;",
|
|
192
|
+
"}"
|
|
193
|
+
].join(`
|
|
194
|
+
`);
|
|
195
|
+
const replacement = [
|
|
196
|
+
'const _injSym = Symbol.for("angular.currentInjector");',
|
|
197
|
+
"if (!globalThis[_injSym]) globalThis[_injSym] = { v: undefined };",
|
|
198
|
+
"function getCurrentInjector() {",
|
|
199
|
+
" return globalThis[_injSym].v;",
|
|
200
|
+
"}",
|
|
201
|
+
"function setCurrentInjector(injector) {",
|
|
202
|
+
" const former = globalThis[_injSym].v;",
|
|
203
|
+
" globalThis[_injSym].v = injector;",
|
|
204
|
+
" return former;",
|
|
205
|
+
"}"
|
|
206
|
+
].join(`
|
|
207
|
+
`);
|
|
208
|
+
const patched = content.replace(original, replacement);
|
|
209
|
+
if (patched === content) {
|
|
210
|
+
return;
|
|
222
211
|
}
|
|
223
|
-
|
|
224
|
-
},
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
const
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
};
|
|
277
|
-
return new ReadableStream({
|
|
278
|
-
async start(controller) {
|
|
279
|
-
const reader = stream.getReader();
|
|
280
|
-
try {
|
|
281
|
-
const { injected, pending } = await runHeadInjectionLoop(controller, reader);
|
|
282
|
-
finishHeadInjectionStream(controller, pending, injected);
|
|
283
|
-
} catch (error) {
|
|
284
|
-
controller.error(error);
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
});
|
|
288
|
-
}, pipeStreamWithIslandMarkerDetection = (stream, markup) => {
|
|
289
|
-
const encoder = new TextEncoder;
|
|
290
|
-
const decoder = new TextDecoder;
|
|
291
|
-
const lookbehind = Math.max(ISLAND_MARKER.length, BYTES_PER_KILOBYTE);
|
|
292
|
-
const processPending = (controller, pending, injected) => {
|
|
293
|
-
if (injected) {
|
|
294
|
-
controller.enqueue(encoder.encode(pending));
|
|
295
|
-
return { injected, pending: "" };
|
|
296
|
-
}
|
|
297
|
-
const markerIndex = pending.indexOf(ISLAND_MARKER);
|
|
298
|
-
if (markerIndex >= 0) {
|
|
299
|
-
const tagStart = pending.lastIndexOf("<", markerIndex);
|
|
300
|
-
const injectAt = tagStart >= 0 ? tagStart : markerIndex;
|
|
301
|
-
const next = `${pending.slice(0, injectAt)}${markup}${pending.slice(injectAt)}`;
|
|
302
|
-
controller.enqueue(encoder.encode(next));
|
|
303
|
-
return { injected: true, pending: "" };
|
|
304
|
-
}
|
|
305
|
-
return {
|
|
306
|
-
injected,
|
|
307
|
-
pending: flushSafePendingText(controller, encoder, pending, lookbehind)
|
|
308
|
-
};
|
|
309
|
-
};
|
|
310
|
-
const finishIslandMarkerStream = (controller, pending) => {
|
|
311
|
-
const finalPending = pending + decoder.decode();
|
|
312
|
-
if (finalPending.length > 0) {
|
|
313
|
-
controller.enqueue(encoder.encode(finalPending));
|
|
212
|
+
writeFileSync(chunkPath, patched, "utf-8");
|
|
213
|
+
}, resolveAngularCoreDir = () => {
|
|
214
|
+
const fromProject = resolve(process.cwd(), "node_modules/@angular/core");
|
|
215
|
+
if (existsSync(join(fromProject, "package.json"))) {
|
|
216
|
+
return fromProject;
|
|
217
|
+
}
|
|
218
|
+
return dirname(__require.resolve("@angular/core/package.json"));
|
|
219
|
+
}, patchAngularInjectorSingleton = () => {
|
|
220
|
+
try {
|
|
221
|
+
const coreDir = resolveAngularCoreDir();
|
|
222
|
+
const chunkPath = join(coreDir, "fesm2022", "_not_found-chunk.mjs");
|
|
223
|
+
const content = readFileSync(chunkPath, "utf-8");
|
|
224
|
+
applyInjectorPatch(chunkPath, content);
|
|
225
|
+
} catch {}
|
|
226
|
+
};
|
|
227
|
+
var init_injectorPatch = __esm(() => {
|
|
228
|
+
patchAngularInjectorSingleton();
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
// src/angular/resolveAngularPackage.ts
|
|
232
|
+
import { existsSync as existsSync2 } from "fs";
|
|
233
|
+
import { resolve as resolve2 } from "path";
|
|
234
|
+
var resolveAngularPackage = (specifier) => {
|
|
235
|
+
const fromProject = resolve2(process.cwd(), "node_modules", specifier);
|
|
236
|
+
if (existsSync2(fromProject)) {
|
|
237
|
+
return fromProject;
|
|
238
|
+
}
|
|
239
|
+
return specifier;
|
|
240
|
+
};
|
|
241
|
+
var init_resolveAngularPackage = () => {};
|
|
242
|
+
|
|
243
|
+
// src/angular/angularPatch.ts
|
|
244
|
+
var exports_angularPatch = {};
|
|
245
|
+
__export(exports_angularPatch, {
|
|
246
|
+
applyPatches: () => applyPatches
|
|
247
|
+
});
|
|
248
|
+
var ensureHead = (doc) => {
|
|
249
|
+
if (!doc || doc.head || !doc.documentElement) {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
const head = doc.createElement("head");
|
|
253
|
+
doc.documentElement.insertBefore(head, doc.documentElement.firstChild);
|
|
254
|
+
}, applyPatches = async () => {
|
|
255
|
+
const { \u{275}DominoAdapter } = await import(resolveAngularPackage("@angular/platform-server"));
|
|
256
|
+
if (!\u{275}DominoAdapter?.prototype) {
|
|
257
|
+
console.warn("[Angular Patch] \u0275DominoAdapter not found, skipping patches");
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
const proto = \u{275}DominoAdapter.prototype;
|
|
261
|
+
const origGetBaseHref = proto.getBaseHref;
|
|
262
|
+
proto.getBaseHref = function(doc) {
|
|
263
|
+
if (!doc || !doc.head || typeof doc.head.children === "undefined") {
|
|
264
|
+
return "";
|
|
314
265
|
}
|
|
315
|
-
|
|
266
|
+
return origGetBaseHref.call(this, doc);
|
|
316
267
|
};
|
|
317
|
-
const
|
|
318
|
-
|
|
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
|
-
};
|
|
268
|
+
const origCreateHtmlDocument = proto.createHtmlDocument;
|
|
269
|
+
proto.createHtmlDocument = function() {
|
|
270
|
+
const doc = origCreateHtmlDocument.call(this);
|
|
271
|
+
ensureHead(doc);
|
|
272
|
+
return doc;
|
|
328
273
|
};
|
|
329
|
-
const
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
return { injected, pending };
|
|
335
|
-
}
|
|
336
|
-
return consumeNextIslandChunk(nextState.injected, nextState.pending);
|
|
337
|
-
};
|
|
338
|
-
return consumeNextIslandChunk(false, "");
|
|
274
|
+
const origGetDefaultDocument = proto.getDefaultDocument;
|
|
275
|
+
proto.getDefaultDocument = function() {
|
|
276
|
+
const doc = origGetDefaultDocument.call(this);
|
|
277
|
+
ensureHead(doc);
|
|
278
|
+
return doc;
|
|
339
279
|
};
|
|
340
|
-
return
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
}
|
|
352
|
-
|
|
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);
|
|
280
|
+
return true;
|
|
281
|
+
};
|
|
282
|
+
var init_angularPatch = __esm(() => {
|
|
283
|
+
init_resolveAngularPackage();
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
// src/angular/angularDeps.ts
|
|
287
|
+
var initDominoAdapter = (platformServer) => {
|
|
288
|
+
try {
|
|
289
|
+
const DominoAdapter = platformServer.\u{275}DominoAdapter;
|
|
290
|
+
DominoAdapter?.makeCurrent?.();
|
|
291
|
+
} catch (err) {
|
|
292
|
+
console.error("Failed to initialize DominoAdapter:", err);
|
|
368
293
|
}
|
|
369
|
-
|
|
370
|
-
|
|
294
|
+
}, loadAngularDeps = async () => {
|
|
295
|
+
patchAngularInjectorSingleton();
|
|
296
|
+
await import(resolveAngularPackage("@angular/compiler"));
|
|
297
|
+
const { applyPatches: applyPatches2 } = await Promise.resolve().then(() => (init_angularPatch(), exports_angularPatch));
|
|
298
|
+
await applyPatches2();
|
|
299
|
+
const [platformBrowser, platformServer, common, core] = await Promise.all([
|
|
300
|
+
import(resolveAngularPackage("@angular/platform-browser")),
|
|
301
|
+
import(resolveAngularPackage("@angular/platform-server")),
|
|
302
|
+
import(resolveAngularPackage("@angular/common")),
|
|
303
|
+
import(resolveAngularPackage("@angular/core"))
|
|
304
|
+
]);
|
|
305
|
+
if (false) {}
|
|
306
|
+
initDominoAdapter(platformServer);
|
|
307
|
+
return {
|
|
308
|
+
APP_BASE_HREF: common.APP_BASE_HREF,
|
|
309
|
+
bootstrapApplication: platformBrowser.bootstrapApplication,
|
|
310
|
+
DomSanitizer: platformBrowser.DomSanitizer,
|
|
311
|
+
provideClientHydration: platformBrowser.provideClientHydration,
|
|
312
|
+
provideServerRendering: platformServer.provideServerRendering,
|
|
313
|
+
provideZonelessChangeDetection: core.provideZonelessChangeDetection,
|
|
314
|
+
reflectComponentType: core.reflectComponentType,
|
|
315
|
+
renderApplication: platformServer.renderApplication,
|
|
316
|
+
Sanitizer: core.Sanitizer,
|
|
317
|
+
SecurityContext: core.SecurityContext
|
|
318
|
+
};
|
|
319
|
+
}, angularDeps = null, getAngularDeps = () => {
|
|
320
|
+
if (!angularDeps) {
|
|
321
|
+
angularDeps = loadAngularDeps();
|
|
371
322
|
}
|
|
372
|
-
return
|
|
373
|
-
}, setCurrentIslandManifest = (manifest) => {
|
|
374
|
-
globalThis.__absoluteManifest = manifest;
|
|
323
|
+
return angularDeps;
|
|
375
324
|
};
|
|
376
|
-
var
|
|
377
|
-
|
|
325
|
+
var init_angularDeps = __esm(() => {
|
|
326
|
+
init_injectorPatch();
|
|
327
|
+
init_resolveAngularPackage();
|
|
378
328
|
});
|
|
379
329
|
|
|
380
|
-
// src/
|
|
381
|
-
var
|
|
382
|
-
const
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
330
|
+
// src/core/currentIslandRegistry.ts
|
|
331
|
+
var requireCurrentIslandRegistry = () => {
|
|
332
|
+
const registry = globalThis.__absoluteIslandRegistry;
|
|
333
|
+
if (!registry) {
|
|
334
|
+
throw new Error("No island registry is active. Configure `islands.registry` in absolute.config.ts before rendering <Island />.");
|
|
335
|
+
}
|
|
336
|
+
return registry;
|
|
337
|
+
}, setCurrentIslandRegistry = (registry) => {
|
|
338
|
+
globalThis.__absoluteIslandRegistry = registry;
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
// src/angular/ssrRender.ts
|
|
342
|
+
var routePropsCache, cacheRouteData = (pagePath, data) => {
|
|
343
|
+
const cacheKey = pagePath.split("?")[0] ?? pagePath;
|
|
344
|
+
routePropsCache.set(cacheKey, data);
|
|
345
|
+
}, getCachedRouteData = (pagePath) => routePropsCache.get(pagePath), selectorCache, buildDeps = (ssrResult, baseDeps) => {
|
|
346
|
+
if (!ssrResult?.core) {
|
|
347
|
+
return baseDeps;
|
|
348
|
+
}
|
|
349
|
+
const { common, core, platformBrowser, platformServer } = ssrResult;
|
|
350
|
+
return {
|
|
351
|
+
APP_BASE_HREF: common?.APP_BASE_HREF ?? baseDeps.APP_BASE_HREF,
|
|
352
|
+
bootstrapApplication: platformBrowser?.bootstrapApplication ?? baseDeps.bootstrapApplication,
|
|
353
|
+
DomSanitizer: platformBrowser?.DomSanitizer ?? baseDeps.DomSanitizer,
|
|
354
|
+
provideClientHydration: platformBrowser?.provideClientHydration ?? baseDeps.provideClientHydration,
|
|
355
|
+
provideServerRendering: platformServer?.provideServerRendering ?? baseDeps.provideServerRendering,
|
|
356
|
+
provideZonelessChangeDetection: core.provideZonelessChangeDetection,
|
|
357
|
+
reflectComponentType: core.reflectComponentType,
|
|
358
|
+
renderApplication: platformServer?.renderApplication ?? baseDeps.renderApplication,
|
|
359
|
+
Sanitizer: core.Sanitizer,
|
|
360
|
+
SecurityContext: core.SecurityContext
|
|
389
361
|
};
|
|
390
|
-
|
|
391
|
-
const
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
.
|
|
407
|
-
|
|
408
|
-
.
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
362
|
+
}, buildProviders = (deps, sanitizer, maybeProps, tokenMap) => {
|
|
363
|
+
const providers = [
|
|
364
|
+
deps.provideServerRendering(),
|
|
365
|
+
deps.provideClientHydration(),
|
|
366
|
+
deps.provideZonelessChangeDetection(),
|
|
367
|
+
{ provide: deps.APP_BASE_HREF, useValue: "/" },
|
|
368
|
+
{
|
|
369
|
+
provide: deps.DomSanitizer,
|
|
370
|
+
useValue: sanitizer
|
|
371
|
+
},
|
|
372
|
+
{ provide: deps.Sanitizer, useValue: sanitizer }
|
|
373
|
+
];
|
|
374
|
+
if (!maybeProps) {
|
|
375
|
+
return providers;
|
|
376
|
+
}
|
|
377
|
+
const propProviders = Object.entries(maybeProps).map(([propName, propValue]) => ({
|
|
378
|
+
token: tokenMap.get(toScreamingSnake(propName)),
|
|
379
|
+
value: propValue
|
|
380
|
+
})).filter((entry) => entry.token).map((entry) => ({ provide: entry.token, useValue: entry.value }));
|
|
381
|
+
return [...providers, ...propProviders];
|
|
382
|
+
}, clearSelectorCache = () => selectorCache.clear(), isInjectionToken = (value) => {
|
|
383
|
+
if (!value || typeof value !== "object") {
|
|
384
|
+
return false;
|
|
385
|
+
}
|
|
386
|
+
return "ngMetadataName" in value && value.ngMetadataName === "InjectionToken";
|
|
387
|
+
}, discoverTokens = (pageModule) => new Map(Object.entries(pageModule).filter(([, value]) => isInjectionToken(value))), loadSsrDeps = async (pagePath) => {
|
|
388
|
+
const ssrDepsPath = (pagePath.split("?")[0] ?? pagePath).replace(/\.js$/, ".ssr-deps.js");
|
|
389
|
+
try {
|
|
390
|
+
const ssrDeps = await import(ssrDepsPath);
|
|
391
|
+
const result = {
|
|
392
|
+
common: ssrDeps.__angularCommon,
|
|
393
|
+
core: ssrDeps.__angularCore,
|
|
394
|
+
platformBrowser: ssrDeps.__angularPlatformBrowser,
|
|
395
|
+
platformServer: ssrDeps.__angularPlatformServer
|
|
396
|
+
};
|
|
397
|
+
return result;
|
|
398
|
+
} catch {
|
|
399
|
+
return null;
|
|
400
|
+
}
|
|
401
|
+
}, resolveSelector = (deps, pagePath, PageComponent) => {
|
|
402
|
+
const cached = selectorCache.get(pagePath);
|
|
403
|
+
if (cached) {
|
|
404
|
+
return cached;
|
|
405
|
+
}
|
|
406
|
+
const selector = deps.reflectComponentType(PageComponent)?.selector ?? "ng-app";
|
|
407
|
+
selectorCache.set(pagePath, selector);
|
|
408
|
+
return selector;
|
|
409
|
+
}, injectBeforeClose = (html, snippet) => {
|
|
410
|
+
if (html.includes("</body>")) {
|
|
411
|
+
return html.replace("</body>", `${snippet}</body>`);
|
|
412
|
+
}
|
|
413
|
+
if (html.includes("</html>")) {
|
|
414
|
+
return html.replace("</html>", `${snippet}</html>`);
|
|
415
|
+
}
|
|
416
|
+
return html + snippet;
|
|
417
|
+
}, injectSsrScripts = (html, requestId, indexPath, props) => {
|
|
418
|
+
let result = html;
|
|
419
|
+
const registeredScripts = getAndClearClientScripts(requestId);
|
|
420
|
+
if (registeredScripts.length > 0) {
|
|
421
|
+
result = injectBeforeClose(result, generateClientScriptCode(registeredScripts));
|
|
422
|
+
}
|
|
423
|
+
if (props) {
|
|
424
|
+
result = injectBeforeClose(result, `<script>window.__ABS_ANGULAR_PAGE_PROPS__ = ${JSON.stringify(props)};</script>`);
|
|
425
|
+
}
|
|
426
|
+
if (indexPath) {
|
|
427
|
+
const escapedIndexPath = JSON.stringify(indexPath);
|
|
428
|
+
result = injectBeforeClose(result, `<script>import(${escapedIndexPath});</script>`);
|
|
429
|
+
}
|
|
430
|
+
return result;
|
|
431
|
+
}, renderAngularApp = async (deps, PageComponent, providers, document2) => {
|
|
432
|
+
const bootstrap = (context) => deps.bootstrapApplication(PageComponent, { providers }, context);
|
|
433
|
+
return withSuppressedAngularDevLogs(() => deps.renderApplication(bootstrap, {
|
|
434
|
+
document: document2,
|
|
435
|
+
platformProviders: [],
|
|
436
|
+
url: "/"
|
|
437
|
+
}));
|
|
438
|
+
}, withSuppressedAngularDevLogs = async (render) => {
|
|
439
|
+
const origLog = console.log;
|
|
440
|
+
console.log = (...args) => {
|
|
441
|
+
if (typeof args[0] === "string" && args[0].includes("development mode")) {
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
444
|
+
origLog.apply(console, args);
|
|
445
|
+
};
|
|
446
|
+
try {
|
|
447
|
+
return await render();
|
|
448
|
+
} finally {
|
|
449
|
+
console.log = origLog;
|
|
450
|
+
}
|
|
430
451
|
};
|
|
452
|
+
var init_ssrRender = __esm(() => {
|
|
453
|
+
init_registerClientScript();
|
|
454
|
+
routePropsCache = new Map;
|
|
455
|
+
selectorCache = new Map;
|
|
456
|
+
});
|
|
431
457
|
|
|
432
|
-
// src/
|
|
433
|
-
var
|
|
434
|
-
|
|
435
|
-
|
|
458
|
+
// src/angular/islands.ts
|
|
459
|
+
var exports_islands = {};
|
|
460
|
+
__export(exports_islands, {
|
|
461
|
+
renderAngularIslandToHtml: () => renderAngularIslandToHtml,
|
|
462
|
+
mountAngularIsland: () => mountAngularIsland,
|
|
463
|
+
getAngularIslandSelector: () => getAngularIslandSelector
|
|
464
|
+
});
|
|
465
|
+
var angularIslandSelector = "abs-angular-island", getAngularIslandSelector = (_islandId) => angularIslandSelector, getSelectorFromRenderedIsland = (rootElement) => {
|
|
466
|
+
const firstChild = rootElement.firstElementChild;
|
|
467
|
+
if (!(firstChild instanceof HTMLElement)) {
|
|
468
|
+
return null;
|
|
436
469
|
}
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boolean(value) && typeof value === "object", getMap = () => {
|
|
443
|
-
const value = Reflect.get(globalThis, CONVENTIONS_KEY);
|
|
444
|
-
if (isConventionsMap(value))
|
|
445
|
-
return value;
|
|
446
|
-
const empty = {};
|
|
447
|
-
return empty;
|
|
448
|
-
}, derivePageName = (pagePath) => {
|
|
449
|
-
const base = basename(pagePath);
|
|
450
|
-
const dotIndex = base.indexOf(".");
|
|
451
|
-
const name = dotIndex > 0 ? base.slice(0, dotIndex) : base;
|
|
452
|
-
return toPascal(name);
|
|
453
|
-
}, resolveErrorConventionPath = (framework, pageName) => {
|
|
454
|
-
const conventions = getMap()[framework];
|
|
455
|
-
if (!conventions)
|
|
456
|
-
return;
|
|
457
|
-
return conventions.pages?.[pageName]?.error ?? conventions.defaults?.error;
|
|
458
|
-
}, resolveNotFoundConventionPath = (framework) => getMap()[framework]?.defaults?.notFound, setConventions = (map) => {
|
|
459
|
-
Reflect.set(globalThis, CONVENTIONS_KEY, map);
|
|
460
|
-
}, isDev = () => true, buildErrorProps = (error) => {
|
|
461
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
462
|
-
const stack = isDev() && error instanceof Error ? error.stack : undefined;
|
|
463
|
-
return { error: { message, stack } };
|
|
464
|
-
}, renderReactError = async (conventionPath, errorProps) => {
|
|
465
|
-
const { createElement } = await import("react");
|
|
466
|
-
const { renderToReadableStream } = await import("react-dom/server");
|
|
467
|
-
const mod = await import(conventionPath);
|
|
468
|
-
const [firstKey] = Object.keys(mod);
|
|
469
|
-
const ErrorComponent = mod.default ?? (firstKey ? mod[firstKey] : undefined);
|
|
470
|
-
const element = createElement(ErrorComponent, errorProps);
|
|
471
|
-
const stream = await renderToReadableStream(element);
|
|
472
|
-
return new Response(stream, {
|
|
473
|
-
headers: { "Content-Type": "text/html" },
|
|
474
|
-
status: 500
|
|
475
|
-
});
|
|
476
|
-
}, renderSvelteError = async (conventionPath, errorProps) => {
|
|
477
|
-
const { render } = await import("svelte/server");
|
|
478
|
-
const mod = await import(conventionPath);
|
|
479
|
-
const ErrorComponent = mod.default;
|
|
480
|
-
const { head, body } = render(ErrorComponent, {
|
|
481
|
-
props: errorProps
|
|
482
|
-
});
|
|
483
|
-
const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
|
|
484
|
-
return new Response(html, {
|
|
485
|
-
headers: { "Content-Type": "text/html" },
|
|
486
|
-
status: 500
|
|
487
|
-
});
|
|
488
|
-
}, unescapeVueStyles = (ssrBody) => {
|
|
489
|
-
let styles = "";
|
|
490
|
-
const body = ssrBody.replace(/<style>([\s\S]*?)<\/style>/g, (_, css) => {
|
|
491
|
-
styles += `<style>${css.replace(/"/g, '"').replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")}</style>`;
|
|
492
|
-
return "";
|
|
493
|
-
});
|
|
494
|
-
return { body, styles };
|
|
495
|
-
}, renderVueError = async (conventionPath, errorProps) => {
|
|
496
|
-
const { createSSRApp, h } = await import("vue");
|
|
497
|
-
const { renderToString } = await import("vue/server-renderer");
|
|
498
|
-
const mod = await import(conventionPath);
|
|
499
|
-
const ErrorComponent = mod.default;
|
|
500
|
-
const app = createSSRApp({
|
|
501
|
-
render: () => h(ErrorComponent, errorProps)
|
|
502
|
-
});
|
|
503
|
-
const rawBody = await renderToString(app);
|
|
504
|
-
const { styles, body } = unescapeVueStyles(rawBody);
|
|
505
|
-
const html = `<!DOCTYPE html><html><head>${styles}</head><body><div id="root">${body}</div></body></html>`;
|
|
506
|
-
return new Response(html, {
|
|
507
|
-
headers: { "Content-Type": "text/html" },
|
|
508
|
-
status: 500
|
|
509
|
-
});
|
|
510
|
-
}, renderAngularError = async (conventionPath, errorProps) => {
|
|
511
|
-
const mod = await import(conventionPath);
|
|
512
|
-
const renderError = mod.default ?? mod.renderError;
|
|
513
|
-
if (typeof renderError !== "function")
|
|
470
|
+
const selector = firstChild.tagName.toLowerCase();
|
|
471
|
+
return selector.length > 0 ? selector : null;
|
|
472
|
+
}, getClientAngularComponentSelector = (component) => {
|
|
473
|
+
const maybeDef = Reflect.get(component, "\u0275cmp");
|
|
474
|
+
if (typeof maybeDef !== "object" || maybeDef === null) {
|
|
514
475
|
return null;
|
|
515
|
-
const html = renderError(errorProps);
|
|
516
|
-
return new Response(html, {
|
|
517
|
-
headers: { "Content-Type": "text/html" },
|
|
518
|
-
status: 500
|
|
519
|
-
});
|
|
520
|
-
}, logConventionRenderError = (framework, label, renderError) => {
|
|
521
|
-
const message = renderError instanceof Error ? renderError.message : "";
|
|
522
|
-
if (message.includes("Cannot find module") || message.includes("Cannot find package") || message.includes("not found in module")) {
|
|
523
|
-
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}).`);
|
|
524
|
-
return;
|
|
525
476
|
}
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
const conventionPath = resolveErrorConventionPath(framework, pageName);
|
|
529
|
-
if (!conventionPath)
|
|
477
|
+
const maybeSelectors = Reflect.get(maybeDef, "selectors");
|
|
478
|
+
if (!Array.isArray(maybeSelectors)) {
|
|
530
479
|
return null;
|
|
531
|
-
|
|
532
|
-
const
|
|
533
|
-
if (!
|
|
480
|
+
}
|
|
481
|
+
const [firstSelectorGroup] = maybeSelectors;
|
|
482
|
+
if (!Array.isArray(firstSelectorGroup)) {
|
|
534
483
|
return null;
|
|
535
|
-
try {
|
|
536
|
-
return await renderer(conventionPath, errorProps);
|
|
537
|
-
} catch (renderError) {
|
|
538
|
-
logConventionRenderError(framework, "error", renderError);
|
|
539
484
|
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
const {
|
|
544
|
-
const
|
|
545
|
-
const
|
|
546
|
-
|
|
547
|
-
const element = createElement(NotFoundComponent);
|
|
548
|
-
const stream = await renderToReadableStream(element);
|
|
549
|
-
return new Response(stream, {
|
|
550
|
-
headers: { "Content-Type": "text/html" },
|
|
551
|
-
status: 404
|
|
552
|
-
});
|
|
553
|
-
}, renderSvelteNotFound = async (conventionPath) => {
|
|
554
|
-
const { render } = await import("svelte/server");
|
|
555
|
-
const mod = await import(conventionPath);
|
|
556
|
-
const NotFoundComponent = mod.default;
|
|
557
|
-
const { head, body } = render(NotFoundComponent);
|
|
558
|
-
const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
|
|
559
|
-
return new Response(html, {
|
|
560
|
-
headers: { "Content-Type": "text/html" },
|
|
561
|
-
status: 404
|
|
562
|
-
});
|
|
563
|
-
}, renderVueNotFound = async (conventionPath) => {
|
|
564
|
-
const { createSSRApp, h } = await import("vue");
|
|
565
|
-
const { renderToString } = await import("vue/server-renderer");
|
|
566
|
-
const mod = await import(conventionPath);
|
|
567
|
-
const NotFoundComponent = mod.default;
|
|
568
|
-
const app = createSSRApp({
|
|
569
|
-
render: () => h(NotFoundComponent)
|
|
570
|
-
});
|
|
571
|
-
const rawBody = await renderToString(app);
|
|
572
|
-
const { styles, body } = unescapeVueStyles(rawBody);
|
|
573
|
-
const html = `<!DOCTYPE html><html><head>${styles}</head><body><div id="root">${body}</div></body></html>`;
|
|
574
|
-
return new Response(html, {
|
|
575
|
-
headers: { "Content-Type": "text/html" },
|
|
576
|
-
status: 404
|
|
577
|
-
});
|
|
578
|
-
}, renderAngularNotFound = async (conventionPath) => {
|
|
579
|
-
const mod = await import(conventionPath);
|
|
580
|
-
const renderNotFound = mod.default ?? mod.renderNotFound;
|
|
581
|
-
if (typeof renderNotFound !== "function")
|
|
582
|
-
return null;
|
|
583
|
-
const html = renderNotFound();
|
|
584
|
-
return new Response(html, {
|
|
585
|
-
headers: { "Content-Type": "text/html" },
|
|
586
|
-
status: 404
|
|
485
|
+
const [selector] = firstSelectorGroup;
|
|
486
|
+
return typeof selector === "string" && selector.length > 0 ? selector : null;
|
|
487
|
+
}, createAngularIslandApp = async () => {
|
|
488
|
+
const { EnvironmentInjector, provideZonelessChangeDetection } = await import("@angular/core");
|
|
489
|
+
const { createApplication } = await import("@angular/platform-browser");
|
|
490
|
+
const app = await createApplication({
|
|
491
|
+
providers: [provideZonelessChangeDetection()]
|
|
587
492
|
});
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
493
|
+
const environmentInjector = app.injector.get(EnvironmentInjector);
|
|
494
|
+
return { app, environmentInjector };
|
|
495
|
+
}, angularIslandAppPromise = null, getAngularIslandApp = async () => {
|
|
496
|
+
if (!angularIslandAppPromise) {
|
|
497
|
+
angularIslandAppPromise = createAngularIslandApp();
|
|
498
|
+
}
|
|
499
|
+
return angularIslandAppPromise;
|
|
500
|
+
}, wrapperMetadataCache, requestRenderCache, getRequestRenderCache = () => {
|
|
501
|
+
const requestId = getSsrContextId();
|
|
502
|
+
if (!requestId) {
|
|
594
503
|
return null;
|
|
595
|
-
try {
|
|
596
|
-
return await renderer(conventionPath);
|
|
597
|
-
} catch (renderError) {
|
|
598
|
-
logConventionRenderError(framework, "not-found", renderError);
|
|
599
504
|
}
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
if (!getMap()[framework]?.defaults?.notFound)
|
|
604
|
-
continue;
|
|
605
|
-
const response = await renderConventionNotFound(framework);
|
|
606
|
-
if (response)
|
|
607
|
-
return response;
|
|
505
|
+
const cached = requestRenderCache.get(requestId);
|
|
506
|
+
if (cached) {
|
|
507
|
+
return cached;
|
|
608
508
|
}
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
};
|
|
624
|
-
NOT_FOUND_PRIORITY = [
|
|
625
|
-
"react",
|
|
626
|
-
"svelte",
|
|
627
|
-
"vue",
|
|
628
|
-
"angular"
|
|
629
|
-
];
|
|
630
|
-
});
|
|
509
|
+
const renderCache = new Map;
|
|
510
|
+
requestRenderCache.set(requestId, renderCache);
|
|
511
|
+
return renderCache;
|
|
512
|
+
}, getAngularIslandWrapperKey = (component, _islandId) => {
|
|
513
|
+
const componentName = typeof component.name === "string" && component.name.length > 0 ? component.name : "AngularIsland";
|
|
514
|
+
return `${componentName}:${angularIslandSelector}`;
|
|
515
|
+
}, getIslandRenderCacheKey = (component, props) => {
|
|
516
|
+
const componentName = typeof component.name === "string" && component.name.length > 0 ? component.name : "AngularIsland";
|
|
517
|
+
return `${componentName}:${JSON.stringify(props)}`;
|
|
518
|
+
}, buildAngularIslandWrapperMetadata = async (component, islandId, wrapperKey) => {
|
|
519
|
+
const { Component, InjectionToken, inject } = await import("@angular/core");
|
|
520
|
+
const { NgComponentOutlet } = await import("@angular/common");
|
|
521
|
+
const deps = await getAngularDeps();
|
|
522
|
+
const selector = getAngularIslandSelector(islandId);
|
|
523
|
+
const propsToken = new InjectionToken(`${wrapperKey}:props`);
|
|
631
524
|
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
if (!scriptRegistry.has(id)) {
|
|
636
|
-
scriptRegistry.set(id, new Set);
|
|
525
|
+
class AngularIslandWrapperComponent {
|
|
526
|
+
component = component;
|
|
527
|
+
props = inject(propsToken);
|
|
637
528
|
}
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
529
|
+
return {
|
|
530
|
+
deps,
|
|
531
|
+
propsToken,
|
|
532
|
+
selector,
|
|
533
|
+
WrapperComponent: Component({
|
|
534
|
+
imports: [NgComponentOutlet, component],
|
|
535
|
+
selector,
|
|
536
|
+
standalone: true,
|
|
537
|
+
template: '<ng-container *ngComponentOutlet="component; inputs: props"></ng-container>'
|
|
538
|
+
})(AngularIslandWrapperComponent)
|
|
539
|
+
};
|
|
540
|
+
}, createAngularIslandWrapper = async (component, islandId) => {
|
|
541
|
+
const wrapperKey = getAngularIslandWrapperKey(component, islandId);
|
|
542
|
+
const cached = wrapperMetadataCache.get(wrapperKey);
|
|
543
|
+
if (cached) {
|
|
544
|
+
return cached;
|
|
647
545
|
}
|
|
648
|
-
const
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
(function() {
|
|
657
|
-
var executed = false;
|
|
658
|
-
function executeScript_${index}() {
|
|
659
|
-
if (executed) return;
|
|
660
|
-
executed = true;
|
|
661
|
-
${body}
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
if (document.readyState === 'complete' || document.readyState === 'interactive') {
|
|
665
|
-
executeScript_${index}();
|
|
666
|
-
} else {
|
|
667
|
-
document.addEventListener('DOMContentLoaded', executeScript_${index});
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
// Watch for hydration-added elements
|
|
671
|
-
var observer = new MutationObserver(function() {
|
|
672
|
-
executeScript_${index}();
|
|
673
|
-
if (executed) observer.disconnect();
|
|
674
|
-
});
|
|
675
|
-
if (!executed) {
|
|
676
|
-
observer.observe(document.body || document.documentElement, { childList: true, subtree: true });
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
// Single fallback timeout
|
|
680
|
-
setTimeout(function() {
|
|
681
|
-
executeScript_${index}();
|
|
682
|
-
observer.disconnect();
|
|
683
|
-
}, 1000);
|
|
684
|
-
})();`;
|
|
685
|
-
}).join(`
|
|
686
|
-
`);
|
|
687
|
-
return `<script>
|
|
688
|
-
(function() {
|
|
689
|
-
${scriptCode}
|
|
690
|
-
})();
|
|
691
|
-
</script>`;
|
|
692
|
-
}, getAndClearClientScripts = (requestId) => {
|
|
693
|
-
const id = requestId || ssrContextGetter?.();
|
|
694
|
-
if (!id)
|
|
695
|
-
return [];
|
|
696
|
-
const scripts = scriptRegistry.get(id);
|
|
697
|
-
if (!scripts) {
|
|
698
|
-
return [];
|
|
546
|
+
const metadataPromise = buildAngularIslandWrapperMetadata(component, islandId, wrapperKey);
|
|
547
|
+
wrapperMetadataCache.set(wrapperKey, metadataPromise);
|
|
548
|
+
return metadataPromise;
|
|
549
|
+
}, extractAngularIslandRoot = (html, selector) => {
|
|
550
|
+
const openTag = `<${selector}`;
|
|
551
|
+
const start = html.indexOf(openTag);
|
|
552
|
+
if (start < 0) {
|
|
553
|
+
throw new Error(`Could not find Angular island root "${selector}".`);
|
|
699
554
|
}
|
|
700
|
-
const
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
};
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
555
|
+
const endTag = `</${selector}>`;
|
|
556
|
+
const end = html.indexOf(endTag, start);
|
|
557
|
+
if (end < 0) {
|
|
558
|
+
throw new Error(`Could not close Angular island root "${selector}".`);
|
|
559
|
+
}
|
|
560
|
+
return html.slice(start, end + endTag.length);
|
|
561
|
+
}, mountAngularIsland = async (component, element, props, islandId) => {
|
|
562
|
+
await import("@angular/compiler");
|
|
563
|
+
const { createComponent, inputBinding } = await import("@angular/core");
|
|
564
|
+
const selector = getAngularIslandSelector(islandId);
|
|
565
|
+
const { app, environmentInjector } = await getAngularIslandApp();
|
|
566
|
+
let rootElement = element.querySelector(selector);
|
|
567
|
+
if (!(rootElement instanceof HTMLElement)) {
|
|
568
|
+
element.innerHTML = `<${selector}></${selector}>`;
|
|
569
|
+
rootElement = element.querySelector(selector);
|
|
570
|
+
}
|
|
571
|
+
if (!(rootElement instanceof HTMLElement))
|
|
572
|
+
return app;
|
|
573
|
+
const componentSelector = getClientAngularComponentSelector(component) ?? getSelectorFromRenderedIsland(rootElement);
|
|
574
|
+
if (!componentSelector)
|
|
575
|
+
return app;
|
|
576
|
+
rootElement.innerHTML = `<${componentSelector}></${componentSelector}>`;
|
|
577
|
+
const hostElement = rootElement.querySelector(componentSelector);
|
|
578
|
+
if (!(hostElement instanceof HTMLElement))
|
|
579
|
+
return app;
|
|
580
|
+
const bindings = Object.entries(props).map(([key, value]) => inputBinding(key, () => value));
|
|
581
|
+
const componentRef = createComponent(component, {
|
|
582
|
+
bindings,
|
|
583
|
+
environmentInjector,
|
|
584
|
+
hostElement
|
|
585
|
+
});
|
|
586
|
+
app.attachView(componentRef.hostView);
|
|
587
|
+
componentRef.changeDetectorRef.detectChanges();
|
|
588
|
+
window.__ABS_ANGULAR_ISLAND_APPS__ ??= [];
|
|
589
|
+
window.__ABS_ANGULAR_ISLAND_APPS__.push(app);
|
|
590
|
+
return app;
|
|
591
|
+
}, renderAngularIslandToHtml = async (component, props, islandId) => {
|
|
592
|
+
const requestCache = getRequestRenderCache();
|
|
593
|
+
const renderCacheKey = getIslandRenderCacheKey(component, props);
|
|
594
|
+
const cachedHtml = requestCache?.get(renderCacheKey);
|
|
595
|
+
if (cachedHtml) {
|
|
596
|
+
return cachedHtml;
|
|
708
597
|
}
|
|
598
|
+
const { deps, propsToken, selector, WrapperComponent } = await createAngularIslandWrapper(component, islandId);
|
|
599
|
+
const providers = [
|
|
600
|
+
deps.provideServerRendering(),
|
|
601
|
+
deps.provideZonelessChangeDetection(),
|
|
602
|
+
{ provide: deps.APP_BASE_HREF, useValue: "/" },
|
|
603
|
+
{ provide: propsToken, useValue: props }
|
|
604
|
+
];
|
|
605
|
+
const document2 = `<!DOCTYPE html><html><body><${selector}></${selector}></body></html>`;
|
|
606
|
+
const html = await withSuppressedAngularDevLogs(() => deps.renderApplication((context) => deps.bootstrapApplication(WrapperComponent, { providers }, context), {
|
|
607
|
+
document: document2,
|
|
608
|
+
platformProviders: [],
|
|
609
|
+
url: "/"
|
|
610
|
+
}));
|
|
611
|
+
const islandHtml = extractAngularIslandRoot(html, selector);
|
|
612
|
+
requestCache?.set(renderCacheKey, islandHtml);
|
|
613
|
+
return islandHtml;
|
|
614
|
+
};
|
|
615
|
+
var init_islands = __esm(() => {
|
|
616
|
+
init_angularDeps();
|
|
617
|
+
init_ssrRender();
|
|
618
|
+
init_registerClientScript();
|
|
619
|
+
wrapperMetadataCache = new Map;
|
|
620
|
+
requestRenderCache = new Map;
|
|
709
621
|
});
|
|
710
622
|
|
|
711
|
-
// src/
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
" return former;",
|
|
727
|
-
"}"
|
|
728
|
-
].join(`
|
|
729
|
-
`);
|
|
730
|
-
const replacement = [
|
|
731
|
-
'const _injSym = Symbol.for("angular.currentInjector");',
|
|
732
|
-
"if (!globalThis[_injSym]) globalThis[_injSym] = { v: undefined };",
|
|
733
|
-
"function getCurrentInjector() {",
|
|
734
|
-
" return globalThis[_injSym].v;",
|
|
735
|
-
"}",
|
|
736
|
-
"function setCurrentInjector(injector) {",
|
|
737
|
-
" const former = globalThis[_injSym].v;",
|
|
738
|
-
" globalThis[_injSym].v = injector;",
|
|
739
|
-
" return former;",
|
|
740
|
-
"}"
|
|
741
|
-
].join(`
|
|
742
|
-
`);
|
|
743
|
-
const patched = content.replace(original, replacement);
|
|
744
|
-
if (patched === content) {
|
|
745
|
-
return;
|
|
746
|
-
}
|
|
747
|
-
writeFileSync(chunkPath, patched, "utf-8");
|
|
748
|
-
}, resolveAngularCoreDir = () => {
|
|
749
|
-
const fromProject = resolve(process.cwd(), "node_modules/@angular/core");
|
|
750
|
-
if (existsSync(join(fromProject, "package.json"))) {
|
|
751
|
-
return fromProject;
|
|
752
|
-
}
|
|
753
|
-
return dirname(__require.resolve("@angular/core/package.json"));
|
|
754
|
-
}, patchAngularInjectorSingleton = () => {
|
|
755
|
-
try {
|
|
756
|
-
const coreDir = resolveAngularCoreDir();
|
|
757
|
-
const chunkPath = join(coreDir, "fesm2022", "_not_found-chunk.mjs");
|
|
758
|
-
const content = readFileSync(chunkPath, "utf-8");
|
|
759
|
-
applyInjectorPatch(chunkPath, content);
|
|
760
|
-
} catch {}
|
|
761
|
-
};
|
|
762
|
-
var init_injectorPatch = __esm(() => {
|
|
763
|
-
patchAngularInjectorSingleton();
|
|
623
|
+
// src/core/islandSsr.ts
|
|
624
|
+
var renderAngularIslandToHtmlInternal = async (component, props, islandId) => {
|
|
625
|
+
const { renderAngularIslandToHtml: renderAngularIslandToHtml2 } = await Promise.resolve().then(() => (init_islands(), exports_islands));
|
|
626
|
+
return renderAngularIslandToHtml2(component, props, islandId);
|
|
627
|
+
}, renderAngularIslandToHtml2, renderReactIslandToHtml = (component, props) => import("react").then(({ createElement }) => import("react-dom/server").then(({ renderToStaticMarkup }) => renderToStaticMarkup(createElement(component, props)))), renderSvelteIslandToHtml = (component, props) => import("svelte/server").then(({ render }) => {
|
|
628
|
+
const { body } = render(component, { props });
|
|
629
|
+
return body;
|
|
630
|
+
}), renderVueIslandToHtml = (component, props) => import("vue").then(({ createSSRApp, h }) => {
|
|
631
|
+
const app = createSSRApp({
|
|
632
|
+
render: () => h(component, props)
|
|
633
|
+
});
|
|
634
|
+
return import("vue/server-renderer").then(({ renderToString }) => renderToString(app));
|
|
635
|
+
});
|
|
636
|
+
var init_islandSsr = __esm(() => {
|
|
637
|
+
renderAngularIslandToHtml2 = renderAngularIslandToHtmlInternal;
|
|
764
638
|
});
|
|
765
639
|
|
|
766
|
-
// src/
|
|
767
|
-
import {
|
|
768
|
-
import {
|
|
769
|
-
var
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
640
|
+
// src/build/resolvePackageImport.ts
|
|
641
|
+
import { resolve as resolve3, join as join2 } from "path";
|
|
642
|
+
import { existsSync as existsSync3, readFileSync as readFileSync2 } from "fs";
|
|
643
|
+
var resolveExportPath = (entry, conditions) => {
|
|
644
|
+
if (typeof entry === "string")
|
|
645
|
+
return entry;
|
|
646
|
+
if (!entry || typeof entry !== "object")
|
|
647
|
+
return null;
|
|
648
|
+
for (const condition of conditions) {
|
|
649
|
+
const target = Reflect.get(entry, condition);
|
|
650
|
+
if (typeof target === "string") {
|
|
651
|
+
return target;
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
return null;
|
|
655
|
+
}, resolvePackageImport = (specifier, conditions = ["import"]) => {
|
|
656
|
+
if (specifier.startsWith(".") || specifier.startsWith("/"))
|
|
657
|
+
return null;
|
|
658
|
+
const parts = specifier.split("/");
|
|
659
|
+
const isScoped = specifier.startsWith("@");
|
|
660
|
+
const packageName = isScoped ? `${parts[0]}/${parts[1]}` : parts[0];
|
|
661
|
+
const subpath = isScoped ? parts.slice(2).join("/") : parts.slice(1).join("/");
|
|
662
|
+
const exportKey = subpath ? `./${subpath}` : ".";
|
|
663
|
+
const currentPackageJsonPath = resolve3(process.cwd(), "package.json");
|
|
664
|
+
const currentPackageJson = existsSync3(currentPackageJsonPath) ? JSON.parse(readFileSync2(currentPackageJsonPath, "utf-8")) : null;
|
|
665
|
+
const currentPackageDir = currentPackageJson?.name === packageName ? process.cwd() : null;
|
|
666
|
+
const packageDir = currentPackageDir ?? resolve3(process.cwd(), "node_modules", packageName ?? "");
|
|
667
|
+
const packageJsonPath = join2(packageDir, "package.json");
|
|
668
|
+
if (!existsSync3(packageJsonPath))
|
|
669
|
+
return null;
|
|
670
|
+
try {
|
|
671
|
+
const packageJson = currentPackageDir && currentPackageJson ? currentPackageJson : JSON.parse(readFileSync2(packageJsonPath, "utf-8"));
|
|
672
|
+
const { exports } = packageJson;
|
|
673
|
+
if (!exports)
|
|
674
|
+
return null;
|
|
675
|
+
const entry = exports[exportKey];
|
|
676
|
+
if (!entry)
|
|
677
|
+
return null;
|
|
678
|
+
const importPath = resolveExportPath(entry, conditions);
|
|
679
|
+
if (!importPath)
|
|
680
|
+
return null;
|
|
681
|
+
if (currentPackageDir && importPath.startsWith("./dist/")) {
|
|
682
|
+
const sourceCandidate = resolve3(packageDir, importPath.replace(/^\.\/dist\//, "./src/"));
|
|
683
|
+
if (existsSync3(sourceCandidate)) {
|
|
684
|
+
return sourceCandidate;
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
const resolved = resolve3(packageDir, importPath);
|
|
688
|
+
return existsSync3(resolved) ? resolved : null;
|
|
689
|
+
} catch {
|
|
690
|
+
return null;
|
|
773
691
|
}
|
|
774
|
-
return specifier;
|
|
775
692
|
};
|
|
776
|
-
var
|
|
693
|
+
var init_resolvePackageImport = () => {};
|
|
777
694
|
|
|
778
|
-
// src/
|
|
779
|
-
var
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
695
|
+
// src/svelte/lowerIslandSyntax.ts
|
|
696
|
+
var ISLAND_TAG_RE, extractBracedExpression = (text, braceStart) => {
|
|
697
|
+
let depth = 0;
|
|
698
|
+
for (let index = braceStart;index < text.length; index += 1) {
|
|
699
|
+
const char = text[index];
|
|
700
|
+
if (char === "{")
|
|
701
|
+
depth += 1;
|
|
702
|
+
if (char === "}")
|
|
703
|
+
depth -= 1;
|
|
704
|
+
if (depth === 0) {
|
|
705
|
+
return text.slice(braceStart + 1, index).trim();
|
|
706
|
+
}
|
|
786
707
|
}
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
console.warn("[Angular Patch] \u0275DominoAdapter not found, skipping patches");
|
|
793
|
-
return false;
|
|
708
|
+
return null;
|
|
709
|
+
}, extractIslandAttribute = (attributeString, name) => {
|
|
710
|
+
const quotedMatch = attributeString.match(new RegExp(`\\b${name}\\s*=\\s*["']([^"']+)["']`));
|
|
711
|
+
if (quotedMatch?.[1]) {
|
|
712
|
+
return { expression: JSON.stringify(quotedMatch[1]), found: true };
|
|
794
713
|
}
|
|
795
|
-
const
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
714
|
+
const attributeIndex = attributeString.search(new RegExp(`\\b${name}\\s*=\\s*\\{`));
|
|
715
|
+
if (attributeIndex < 0) {
|
|
716
|
+
return { expression: "", found: false };
|
|
717
|
+
}
|
|
718
|
+
const braceStart = attributeString.indexOf("{", attributeIndex);
|
|
719
|
+
if (braceStart < 0) {
|
|
720
|
+
return { expression: "", found: false };
|
|
721
|
+
}
|
|
722
|
+
const expression = extractBracedExpression(attributeString, braceStart);
|
|
723
|
+
if (expression === null) {
|
|
724
|
+
return { expression: "", found: false };
|
|
725
|
+
}
|
|
726
|
+
return { expression, found: true };
|
|
727
|
+
}, lowerSvelteIslandSyntax = (source, _mode = "server") => {
|
|
728
|
+
if (!source.includes("<Island")) {
|
|
729
|
+
return { code: source, transformed: false };
|
|
730
|
+
}
|
|
731
|
+
let islandIndex = 0;
|
|
732
|
+
const transformedMarkup = source.replace(ISLAND_TAG_RE, (fullMatch, attributeString) => {
|
|
733
|
+
const framework = extractIslandAttribute(attributeString, "framework");
|
|
734
|
+
const component = extractIslandAttribute(attributeString, "component");
|
|
735
|
+
if (!framework.found || !component.found) {
|
|
736
|
+
return fullMatch;
|
|
800
737
|
}
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
const
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
};
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
738
|
+
const hydrate = extractIslandAttribute(attributeString, "hydrate");
|
|
739
|
+
const props = extractIslandAttribute(attributeString, "props");
|
|
740
|
+
const slotId = `absolute-svelte-island-${islandIndex.toString(BASE_36_RADIX)}`;
|
|
741
|
+
islandIndex += 1;
|
|
742
|
+
const resolveExpression = `await __absoluteResolveIslandHtml(${JSON.stringify(slotId)}, { component: ${component.expression}, framework: ${framework.expression}, hydrate: ${hydrate.found ? hydrate.expression : JSON.stringify("load")}, props: ${props.found ? props.expression : "{}"} })`;
|
|
743
|
+
return `<div data-absolute-island-slot="${slotId}" style="display: contents">{@html ${resolveExpression}}</div>`;
|
|
744
|
+
});
|
|
745
|
+
const importLine = 'import { resolveIslandHtml as __absoluteResolveIslandHtml } from "@absolutejs/absolute/svelte";';
|
|
746
|
+
if (transformedMarkup.includes("<script")) {
|
|
747
|
+
return {
|
|
748
|
+
code: transformedMarkup.replace(/<script(\s[^>]*)?>/, (match) => `${match}
|
|
749
|
+
${importLine}
|
|
750
|
+
`),
|
|
751
|
+
transformed: true
|
|
752
|
+
};
|
|
753
|
+
}
|
|
754
|
+
return {
|
|
755
|
+
code: `<script lang="ts">
|
|
756
|
+
${importLine}
|
|
757
|
+
</script>
|
|
758
|
+
${transformedMarkup}`,
|
|
759
|
+
transformed: true
|
|
814
760
|
};
|
|
815
|
-
return true;
|
|
816
761
|
};
|
|
817
|
-
var
|
|
818
|
-
|
|
762
|
+
var init_lowerIslandSyntax = __esm(() => {
|
|
763
|
+
init_constants();
|
|
764
|
+
ISLAND_TAG_RE = /<Island\b([\s\S]*?)\/>/g;
|
|
819
765
|
});
|
|
820
766
|
|
|
821
|
-
// src/
|
|
822
|
-
var
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
767
|
+
// src/svelte/lowerAwaitSlotSyntax.ts
|
|
768
|
+
var AWAIT_BLOCK_RE, escapeTemplateLiteral = (value) => value.replaceAll("\\", "\\\\").replaceAll("`", "\\`").replaceAll("${", "\\${"), markupToTemplateLiteral = (markup) => {
|
|
769
|
+
const escaped = escapeTemplateLiteral(markup.trim());
|
|
770
|
+
const withExpressions = escaped.replace(/\{([^{}]+)\}/g, (_, expression) => `\${${String(expression).trim()}}`);
|
|
771
|
+
return `\`${withExpressions}\``;
|
|
772
|
+
}, lowerSvelteAwaitSlotSyntax = (source) => {
|
|
773
|
+
if (!source.includes("{#await")) {
|
|
774
|
+
return { code: source, transformed: false };
|
|
828
775
|
}
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
reflectComponentType: core.reflectComponentType,
|
|
850
|
-
renderApplication: platformServer.renderApplication,
|
|
851
|
-
Sanitizer: core.Sanitizer,
|
|
852
|
-
SecurityContext: core.SecurityContext
|
|
853
|
-
};
|
|
854
|
-
}, angularDeps = null, getAngularDeps = () => {
|
|
855
|
-
if (!angularDeps) {
|
|
856
|
-
angularDeps = loadAngularDeps();
|
|
857
|
-
}
|
|
858
|
-
return angularDeps;
|
|
859
|
-
};
|
|
860
|
-
var init_angularDeps = __esm(() => {
|
|
861
|
-
init_injectorPatch();
|
|
862
|
-
init_resolveAngularPackage();
|
|
863
|
-
});
|
|
864
|
-
|
|
865
|
-
// src/core/currentIslandRegistry.ts
|
|
866
|
-
var requireCurrentIslandRegistry = () => {
|
|
867
|
-
const registry = globalThis.__absoluteIslandRegistry;
|
|
868
|
-
if (!registry) {
|
|
869
|
-
throw new Error("No island registry is active. Configure `islands.registry` in absolute.config.ts before rendering <Island />.");
|
|
776
|
+
let awaitIndex = 0;
|
|
777
|
+
let transformed = false;
|
|
778
|
+
const lowered = source.replace(AWAIT_BLOCK_RE, (fullMatch, awaitExpression, pendingMarkup, thenIdentifier, thenMarkup, catchIdentifier, catchMarkup) => {
|
|
779
|
+
const trimmedAwaitExpression = awaitExpression.trim();
|
|
780
|
+
if (!trimmedAwaitExpression) {
|
|
781
|
+
return fullMatch;
|
|
782
|
+
}
|
|
783
|
+
const slotId = `absolute-svelte-await-${awaitIndex.toString(BASE_36_RADIX)}`;
|
|
784
|
+
awaitIndex += 1;
|
|
785
|
+
transformed = true;
|
|
786
|
+
const thenValueIdentifier = thenIdentifier?.trim() || "__awaitValue";
|
|
787
|
+
const catchValueIdentifier = catchIdentifier?.trim() || "__awaitError";
|
|
788
|
+
const fallbackHtml = markupToTemplateLiteral(pendingMarkup);
|
|
789
|
+
const resolvedHtml = markupToTemplateLiteral(thenMarkup);
|
|
790
|
+
const rejectedHtml = typeof catchMarkup === "string" ? markupToTemplateLiteral(catchMarkup) : null;
|
|
791
|
+
const catchBranch = rejectedHtml ? `catch (${catchValueIdentifier}) { return ${rejectedHtml}; }` : "catch (_absoluteAwaitError) { throw _absoluteAwaitError; }";
|
|
792
|
+
return `<AbsoluteAwaitSlot id="${slotId}" fallbackHtml={${fallbackHtml}} resolve={async () => { try { const ${thenValueIdentifier} = await (${trimmedAwaitExpression}); return ${resolvedHtml}; } ${catchBranch} }} />`;
|
|
793
|
+
});
|
|
794
|
+
if (!transformed) {
|
|
795
|
+
return { code: source, transformed: false };
|
|
870
796
|
}
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
routePropsCache.set(cacheKey, data);
|
|
880
|
-
}, getCachedRouteData = (pagePath) => routePropsCache.get(pagePath), selectorCache, buildDeps = (ssrResult, baseDeps) => {
|
|
881
|
-
if (!ssrResult?.core) {
|
|
882
|
-
return baseDeps;
|
|
797
|
+
const importLine = 'import AbsoluteAwaitSlot from "@absolutejs/absolute/svelte/components/AwaitSlot.svelte";';
|
|
798
|
+
if (lowered.includes("<script")) {
|
|
799
|
+
return {
|
|
800
|
+
code: lowered.replace(/<script(\s[^>]*)?>/, (match) => `${match}
|
|
801
|
+
${importLine}
|
|
802
|
+
`),
|
|
803
|
+
transformed: true
|
|
804
|
+
};
|
|
883
805
|
}
|
|
884
|
-
const { common, core, platformBrowser, platformServer } = ssrResult;
|
|
885
806
|
return {
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
provideZonelessChangeDetection: core.provideZonelessChangeDetection,
|
|
892
|
-
reflectComponentType: core.reflectComponentType,
|
|
893
|
-
renderApplication: platformServer?.renderApplication ?? baseDeps.renderApplication,
|
|
894
|
-
Sanitizer: core.Sanitizer,
|
|
895
|
-
SecurityContext: core.SecurityContext
|
|
807
|
+
code: `<script lang="ts">
|
|
808
|
+
${importLine}
|
|
809
|
+
</script>
|
|
810
|
+
${lowered}`,
|
|
811
|
+
transformed: true
|
|
896
812
|
};
|
|
897
|
-
}
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
813
|
+
};
|
|
814
|
+
var init_lowerAwaitSlotSyntax = __esm(() => {
|
|
815
|
+
init_constants();
|
|
816
|
+
AWAIT_BLOCK_RE = /\{#await\s+([^}]+)\}([\s\S]*?)\{:then(?:\s+([A-Za-z_$][\w$]*))?\}([\s\S]*?)(?:\{:catch(?:\s+([A-Za-z_$][\w$]*))?\}([\s\S]*?))?\{\/await\}/g;
|
|
817
|
+
});
|
|
818
|
+
|
|
819
|
+
// src/build/stylePreprocessor.ts
|
|
820
|
+
var exports_stylePreprocessor = {};
|
|
821
|
+
__export(exports_stylePreprocessor, {
|
|
822
|
+
stylePreprocessorPlugin: () => stylePreprocessorPlugin,
|
|
823
|
+
isStylePath: () => isStylePath,
|
|
824
|
+
isStyleModulePath: () => isStyleModulePath,
|
|
825
|
+
isPreprocessableStylePath: () => isPreprocessableStylePath,
|
|
826
|
+
getStyleBaseName: () => getStyleBaseName,
|
|
827
|
+
getCssOutputExtension: () => getCssOutputExtension,
|
|
828
|
+
createSvelteStylePreprocessor: () => createSvelteStylePreprocessor,
|
|
829
|
+
createStyleTransformConfig: () => createStyleTransformConfig,
|
|
830
|
+
createStylePreprocessorPlugin: () => createStylePreprocessorPlugin,
|
|
831
|
+
compileStyleSource: () => compileStyleSource,
|
|
832
|
+
compileStyleFileIfNeededSync: () => compileStyleFileIfNeededSync,
|
|
833
|
+
compileStyleFileIfNeeded: () => compileStyleFileIfNeeded
|
|
834
|
+
});
|
|
835
|
+
import { existsSync as existsSync4, readFileSync as readFileSync3 } from "fs";
|
|
836
|
+
import { readFile } from "fs/promises";
|
|
837
|
+
import { createRequire } from "module";
|
|
838
|
+
import { dirname as dirname2, extname, isAbsolute, join as join3, relative, resolve as resolve4 } from "path";
|
|
839
|
+
import { fileURLToPath } from "url";
|
|
840
|
+
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) => {
|
|
841
|
+
const normalized = filePathOrLanguage.toLowerCase();
|
|
842
|
+
if (normalized === "scss" || normalized.endsWith(".scss"))
|
|
843
|
+
return "scss";
|
|
844
|
+
if (normalized === "sass" || normalized.endsWith(".sass"))
|
|
845
|
+
return "sass";
|
|
846
|
+
if (normalized === "less" || normalized.endsWith(".less"))
|
|
847
|
+
return "less";
|
|
848
|
+
if (normalized === "styl" || normalized === "stylus" || normalized.endsWith(".styl") || normalized.endsWith(".stylus"))
|
|
849
|
+
return "stylus";
|
|
850
|
+
return null;
|
|
851
|
+
}, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`), requireOptionalPeerSync = (specifier) => {
|
|
852
|
+
try {
|
|
853
|
+
return requireFromCwd(specifier);
|
|
854
|
+
} catch {
|
|
855
|
+
return requireOptionalPeer(specifier);
|
|
911
856
|
}
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
857
|
+
}, normalizeLoadPaths = (filePath, paths = []) => [
|
|
858
|
+
dirname2(filePath),
|
|
859
|
+
process.cwd(),
|
|
860
|
+
...paths.map((path) => resolve4(process.cwd(), path))
|
|
861
|
+
], tsconfigAliasCache, stripJsonComments = (source) => source.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1"), normalizeAliasEntries = (aliases) => Object.entries(aliases ?? {}).map(([pattern, value]) => ({
|
|
862
|
+
pattern,
|
|
863
|
+
replacements: Array.isArray(value) ? value : [value]
|
|
864
|
+
})), readTsconfigAliases = () => {
|
|
865
|
+
const cwd = process.cwd();
|
|
866
|
+
if (tsconfigAliasCache?.cwd === cwd)
|
|
867
|
+
return tsconfigAliasCache;
|
|
868
|
+
const tsconfigPath = resolve4(cwd, "tsconfig.json");
|
|
869
|
+
const empty = { aliases: [], baseUrl: cwd, cwd };
|
|
870
|
+
if (!existsSync4(tsconfigPath)) {
|
|
871
|
+
tsconfigAliasCache = empty;
|
|
872
|
+
return empty;
|
|
920
873
|
}
|
|
921
|
-
return "ngMetadataName" in value && value.ngMetadataName === "InjectionToken";
|
|
922
|
-
}, discoverTokens = (pageModule) => new Map(Object.entries(pageModule).filter(([, value]) => isInjectionToken(value))), loadSsrDeps = async (pagePath) => {
|
|
923
|
-
const ssrDepsPath = (pagePath.split("?")[0] ?? pagePath).replace(/\.js$/, ".ssr-deps.js");
|
|
924
874
|
try {
|
|
925
|
-
const
|
|
926
|
-
const
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
875
|
+
const parsed = JSON.parse(stripJsonComments(readFileSync3(tsconfigPath, "utf-8")));
|
|
876
|
+
const compilerOptions = parsed.compilerOptions ?? {};
|
|
877
|
+
const baseUrl = resolve4(cwd, compilerOptions.baseUrl ?? ".");
|
|
878
|
+
tsconfigAliasCache = {
|
|
879
|
+
aliases: normalizeAliasEntries(compilerOptions.paths),
|
|
880
|
+
baseUrl,
|
|
881
|
+
cwd
|
|
931
882
|
};
|
|
932
|
-
return result;
|
|
933
883
|
} catch {
|
|
934
|
-
|
|
935
|
-
}
|
|
936
|
-
}, resolveSelector = (deps, pagePath, PageComponent) => {
|
|
937
|
-
const cached = selectorCache.get(pagePath);
|
|
938
|
-
if (cached) {
|
|
939
|
-
return cached;
|
|
940
|
-
}
|
|
941
|
-
const selector = deps.reflectComponentType(PageComponent)?.selector ?? "ng-app";
|
|
942
|
-
selectorCache.set(pagePath, selector);
|
|
943
|
-
return selector;
|
|
944
|
-
}, injectBeforeClose = (html, snippet) => {
|
|
945
|
-
if (html.includes("</body>")) {
|
|
946
|
-
return html.replace("</body>", `${snippet}</body>`);
|
|
947
|
-
}
|
|
948
|
-
if (html.includes("</html>")) {
|
|
949
|
-
return html.replace("</html>", `${snippet}</html>`);
|
|
884
|
+
tsconfigAliasCache = empty;
|
|
950
885
|
}
|
|
951
|
-
return
|
|
952
|
-
},
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
886
|
+
return tsconfigAliasCache;
|
|
887
|
+
}, getAliasEntries = (config) => {
|
|
888
|
+
const tsconfig = readTsconfigAliases();
|
|
889
|
+
return {
|
|
890
|
+
aliases: [...normalizeAliasEntries(config?.aliases), ...tsconfig.aliases],
|
|
891
|
+
baseUrl: tsconfig.baseUrl
|
|
892
|
+
};
|
|
893
|
+
}, aliasPatternToRegExp = (pattern) => new RegExp(`^${pattern.split("*").map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("(.+)")}$`), resolveAliasTargets = (specifier, config) => {
|
|
894
|
+
const { aliases, baseUrl } = getAliasEntries(config);
|
|
895
|
+
const targets = [];
|
|
896
|
+
for (const alias of aliases) {
|
|
897
|
+
const match = specifier.match(aliasPatternToRegExp(alias.pattern));
|
|
898
|
+
if (!match)
|
|
899
|
+
continue;
|
|
900
|
+
const wildcard = match[1] ?? "";
|
|
901
|
+
for (const replacement of alias.replacements) {
|
|
902
|
+
targets.push(resolve4(baseUrl, replacement.replace("*", wildcard)));
|
|
903
|
+
}
|
|
957
904
|
}
|
|
958
|
-
|
|
959
|
-
|
|
905
|
+
return targets;
|
|
906
|
+
}, getLanguageExtensions = (language) => {
|
|
907
|
+
if (language === "less")
|
|
908
|
+
return [".less", ".css"];
|
|
909
|
+
if (language === "stylus")
|
|
910
|
+
return [".styl", ".stylus", ".css"];
|
|
911
|
+
return [".scss", ".sass", ".css"];
|
|
912
|
+
}, getCandidatePaths = (basePath, language) => {
|
|
913
|
+
const ext = extname(basePath);
|
|
914
|
+
const paths = ext ? [basePath] : getLanguageExtensions(language).flatMap((extension) => [
|
|
915
|
+
`${basePath}${extension}`,
|
|
916
|
+
join3(basePath, `index${extension}`)
|
|
917
|
+
]);
|
|
918
|
+
if (language === "scss" || language === "sass") {
|
|
919
|
+
return paths.flatMap((path) => {
|
|
920
|
+
const dir = dirname2(path);
|
|
921
|
+
const base = path.slice(dir.length + 1);
|
|
922
|
+
return [path, join3(dir, `_${base}`)];
|
|
923
|
+
});
|
|
960
924
|
}
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
925
|
+
return paths;
|
|
926
|
+
}, resolveImportPath = (specifier, fromDirectory, loadPaths, language, config) => {
|
|
927
|
+
const rawCandidates = [
|
|
928
|
+
...resolveAliasTargets(specifier, config),
|
|
929
|
+
isAbsolute(specifier) ? specifier : resolve4(fromDirectory, specifier),
|
|
930
|
+
...loadPaths.map((path) => resolve4(path, specifier))
|
|
931
|
+
];
|
|
932
|
+
for (const candidate of rawCandidates.flatMap((path) => getCandidatePaths(path, language))) {
|
|
933
|
+
if (existsSync4(candidate))
|
|
934
|
+
return candidate;
|
|
964
935
|
}
|
|
965
|
-
return
|
|
966
|
-
},
|
|
967
|
-
const
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
}, withSuppressedAngularDevLogs = async (render) => {
|
|
974
|
-
const origLog = console.log;
|
|
975
|
-
console.log = (...args) => {
|
|
976
|
-
if (typeof args[0] === "string" && args[0].includes("development mode")) {
|
|
977
|
-
return;
|
|
978
|
-
}
|
|
979
|
-
origLog.apply(console, args);
|
|
936
|
+
return null;
|
|
937
|
+
}, isExternalCssUrl = (url) => /^(?:[a-z][a-z0-9+.-]*:|\/\/|#|\/)/i.test(url), splitCssUrl = (url) => {
|
|
938
|
+
const markerIndex = url.search(/[?#]/);
|
|
939
|
+
if (markerIndex === -1)
|
|
940
|
+
return { marker: "", path: url };
|
|
941
|
+
return {
|
|
942
|
+
marker: url.slice(markerIndex),
|
|
943
|
+
path: url.slice(0, markerIndex)
|
|
980
944
|
};
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
945
|
+
}, rebaseCssUrls = (contents, sourceFile, entryFile) => {
|
|
946
|
+
const sourceDir = dirname2(sourceFile);
|
|
947
|
+
const entryDir = dirname2(entryFile);
|
|
948
|
+
if (sourceDir === entryDir)
|
|
949
|
+
return contents;
|
|
950
|
+
return contents.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/gi, (match, quote, rawUrl) => {
|
|
951
|
+
const trimmedUrl = rawUrl.trim();
|
|
952
|
+
if (!trimmedUrl || isExternalCssUrl(trimmedUrl))
|
|
953
|
+
return match;
|
|
954
|
+
const { marker, path } = splitCssUrl(trimmedUrl);
|
|
955
|
+
const rebased = relative(entryDir, resolve4(sourceDir, path)).replace(/\\/g, "/");
|
|
956
|
+
const normalized = rebased.startsWith(".") ? rebased : `./${rebased}`;
|
|
957
|
+
const nextQuote = quote || '"';
|
|
958
|
+
return `url(${nextQuote}${normalized}${marker}${nextQuote})`;
|
|
959
|
+
});
|
|
960
|
+
}, rewriteAliasedStyleImports = (contents, sourceFile, loadPaths, language, config) => contents.replace(/(@(?:use|forward|import|require)\s+)(["'])([^"']+)\2/g, (match, prefix, quote, specifier) => {
|
|
961
|
+
if (specifier.startsWith(".") || isAbsolute(specifier) || isExternalCssUrl(specifier))
|
|
962
|
+
return match;
|
|
963
|
+
const resolved = resolveImportPath(specifier, dirname2(sourceFile), loadPaths, language, config);
|
|
964
|
+
return resolved ? `${prefix}${quote}${resolved}${quote}` : match;
|
|
965
|
+
}), preprocessLoadedStyle = (contents, sourceFile, entryFile, loadPaths = [], language, config) => {
|
|
966
|
+
const rebased = rebaseCssUrls(contents, sourceFile, entryFile);
|
|
967
|
+
return language ? rewriteAliasedStyleImports(rebased, sourceFile, loadPaths, language, config) : rebased;
|
|
968
|
+
}, extractCssModuleExports = (css) => {
|
|
969
|
+
const exports = {};
|
|
970
|
+
const nextCss = css.replace(/:export\s*\{([^}]*)\}/g, (_, body) => {
|
|
971
|
+
for (const declaration of body.split(";")) {
|
|
972
|
+
const separator = declaration.indexOf(":");
|
|
973
|
+
if (separator === -1)
|
|
974
|
+
continue;
|
|
975
|
+
const key = declaration.slice(0, separator).trim();
|
|
976
|
+
const value = declaration.slice(separator + 1).trim();
|
|
977
|
+
if (key && value)
|
|
978
|
+
exports[key] = value;
|
|
979
|
+
}
|
|
980
|
+
return "";
|
|
981
|
+
});
|
|
982
|
+
return { css: nextCss, exports };
|
|
983
|
+
}, getSassOptions = (config, language) => ({
|
|
984
|
+
...config?.sass ?? {},
|
|
985
|
+
...language === "scss" ? config?.scss ?? {} : {}
|
|
986
|
+
}), getLessOptions = (config) => config?.less ?? {}, getStylusOptions = (config) => config?.stylus ?? {}, createStyleTransformConfig = (stylePreprocessors, postcss) => postcss === undefined ? stylePreprocessors : { ...stylePreprocessors ?? {}, postcss }, withAdditionalData = (contents, additionalData) => additionalData ? `${additionalData}
|
|
987
|
+
${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
988
|
+
if (mod && typeof mod === "object" && "default" in mod) {
|
|
989
|
+
return mod.default ?? mod;
|
|
1004
990
|
}
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
const
|
|
1009
|
-
|
|
1010
|
-
|
|
991
|
+
return mod;
|
|
992
|
+
}, loadPostcssConfigFile = async (configPath) => {
|
|
993
|
+
const resolved = resolve4(process.cwd(), configPath);
|
|
994
|
+
const loaded = resolved.endsWith(".cjs") || resolved.endsWith(".cts") ? requireOptionalPeerSync(resolved) : await importOptionalPeer(`${new URL(`file://${resolved}`).href}?t=${Date.now()}`);
|
|
995
|
+
const config = normalizePostcssModule(loaded);
|
|
996
|
+
const value = typeof config === "function" ? await config({
|
|
997
|
+
cwd: process.cwd(),
|
|
998
|
+
env: "development"
|
|
999
|
+
}) : config;
|
|
1000
|
+
return normalizePostcssModule(value) ?? {};
|
|
1001
|
+
}, normalizePostcssPlugins = (plugins) => {
|
|
1002
|
+
if (!plugins)
|
|
1003
|
+
return [];
|
|
1004
|
+
if (Array.isArray(plugins))
|
|
1005
|
+
return plugins.filter(Boolean);
|
|
1006
|
+
const resolved = [];
|
|
1007
|
+
for (const [specifier, options] of Object.entries(plugins)) {
|
|
1008
|
+
if (options === false)
|
|
1009
|
+
continue;
|
|
1010
|
+
const mod = normalizePostcssModule(requireOptionalPeerSync(specifier));
|
|
1011
|
+
const plugin = typeof mod === "function" ? mod(options === true ? undefined : options) : mod;
|
|
1012
|
+
if (plugin)
|
|
1013
|
+
resolved.push(plugin);
|
|
1011
1014
|
}
|
|
1012
|
-
|
|
1013
|
-
|
|
1015
|
+
return resolved;
|
|
1016
|
+
}, resolvePostcssConfig = async (config) => {
|
|
1017
|
+
const inlineConfig = config?.postcss;
|
|
1018
|
+
if (!inlineConfig)
|
|
1014
1019
|
return null;
|
|
1015
|
-
}
|
|
1016
|
-
const
|
|
1017
|
-
|
|
1020
|
+
const fileConfig = inlineConfig.config ? await loadPostcssConfigFile(inlineConfig.config) : {};
|
|
1021
|
+
const plugins = [
|
|
1022
|
+
...normalizePostcssPlugins(fileConfig.plugins),
|
|
1023
|
+
...normalizePostcssPlugins(inlineConfig.plugins)
|
|
1024
|
+
];
|
|
1025
|
+
if (plugins.length === 0)
|
|
1018
1026
|
return null;
|
|
1027
|
+
return {
|
|
1028
|
+
options: {
|
|
1029
|
+
...fileConfig.options ?? {},
|
|
1030
|
+
...inlineConfig.options ?? {}
|
|
1031
|
+
},
|
|
1032
|
+
plugins
|
|
1033
|
+
};
|
|
1034
|
+
}, runPostcss = async (css, filePath, config) => {
|
|
1035
|
+
const postcssConfig = await resolvePostcssConfig(config);
|
|
1036
|
+
if (!postcssConfig)
|
|
1037
|
+
return css;
|
|
1038
|
+
let postcssModule;
|
|
1039
|
+
try {
|
|
1040
|
+
postcssModule = await importOptionalPeer("postcss");
|
|
1041
|
+
} catch {
|
|
1042
|
+
throw missingDependencyError("postcss", filePath);
|
|
1019
1043
|
}
|
|
1020
|
-
const
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
const app = await createApplication({
|
|
1026
|
-
providers: [provideZonelessChangeDetection()]
|
|
1044
|
+
const postcss = postcssModule.default ?? postcssModule;
|
|
1045
|
+
const result = await postcss(postcssConfig.plugins).process(css, {
|
|
1046
|
+
from: filePath,
|
|
1047
|
+
map: false,
|
|
1048
|
+
...postcssConfig.options
|
|
1027
1049
|
});
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1050
|
+
return result.css;
|
|
1051
|
+
}, createSassImporter = (entryFile, loadPaths, language, config) => ({
|
|
1052
|
+
canonicalize(specifier, options) {
|
|
1053
|
+
const fromDirectory = options.containingUrl ? dirname2(fileURLToPath(options.containingUrl)) : dirname2(entryFile);
|
|
1054
|
+
const resolved = resolveImportPath(specifier, fromDirectory, loadPaths, language, config);
|
|
1055
|
+
return resolved ? new URL(`file://${resolved}`) : null;
|
|
1056
|
+
},
|
|
1057
|
+
load(canonicalUrl) {
|
|
1058
|
+
const filePath = fileURLToPath(canonicalUrl);
|
|
1059
|
+
const fileLanguage = getStyleLanguage(filePath);
|
|
1060
|
+
if (fileLanguage !== "scss" && fileLanguage !== "sass" && fileLanguage !== null)
|
|
1061
|
+
return null;
|
|
1062
|
+
return {
|
|
1063
|
+
contents: preprocessLoadedStyle(readFileSync3(filePath, "utf-8"), filePath, entryFile, loadPaths, language, config),
|
|
1064
|
+
syntax: filePath.endsWith(".sass") ? "indented" : "scss"
|
|
1065
|
+
};
|
|
1043
1066
|
}
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
}
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
class AngularIslandWrapperComponent {
|
|
1061
|
-
component = component;
|
|
1062
|
-
props = inject(propsToken);
|
|
1067
|
+
}), createLessFileManager = (entryFile, loadPaths, config) => ({
|
|
1068
|
+
install(less, pluginManager) {
|
|
1069
|
+
const baseManager = new less.FileManager;
|
|
1070
|
+
const manager = Object.create(baseManager);
|
|
1071
|
+
manager.supports = (filename, currentDirectory) => Boolean(resolveImportPath(filename, resolve4(currentDirectory), loadPaths, "less", config));
|
|
1072
|
+
manager.loadFile = async (filename, currentDirectory) => {
|
|
1073
|
+
const resolved = resolveImportPath(filename, resolve4(currentDirectory), loadPaths, "less", config);
|
|
1074
|
+
if (!resolved) {
|
|
1075
|
+
throw new Error(`Unable to resolve Less import "${filename}"`);
|
|
1076
|
+
}
|
|
1077
|
+
return {
|
|
1078
|
+
contents: preprocessLoadedStyle(await readFile(resolved, "utf-8"), resolved, entryFile, loadPaths, "less", config),
|
|
1079
|
+
filename: resolved
|
|
1080
|
+
};
|
|
1081
|
+
};
|
|
1082
|
+
pluginManager.addFileManager(manager);
|
|
1063
1083
|
}
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
standalone: true,
|
|
1072
|
-
template: '<ng-container *ngComponentOutlet="component; inputs: props"></ng-container>'
|
|
1073
|
-
})(AngularIslandWrapperComponent)
|
|
1074
|
-
};
|
|
1075
|
-
}, createAngularIslandWrapper = async (component, islandId) => {
|
|
1076
|
-
const wrapperKey = getAngularIslandWrapperKey(component, islandId);
|
|
1077
|
-
const cached = wrapperMetadataCache.get(wrapperKey);
|
|
1078
|
-
if (cached) {
|
|
1079
|
-
return cached;
|
|
1084
|
+
}), renderStylus = async (contents, filePath, loadPaths, options) => {
|
|
1085
|
+
let stylus;
|
|
1086
|
+
try {
|
|
1087
|
+
const stylusModule = await importOptionalPeer("stylus");
|
|
1088
|
+
stylus = stylusModule.default ?? stylusModule;
|
|
1089
|
+
} catch {
|
|
1090
|
+
throw missingDependencyError("stylus", filePath);
|
|
1080
1091
|
}
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
const start = html.indexOf(openTag);
|
|
1087
|
-
if (start < 0) {
|
|
1088
|
-
throw new Error(`Could not find Angular island root "${selector}".`);
|
|
1089
|
-
}
|
|
1090
|
-
const endTag = `</${selector}>`;
|
|
1091
|
-
const end = html.indexOf(endTag, start);
|
|
1092
|
-
if (end < 0) {
|
|
1093
|
-
throw new Error(`Could not close Angular island root "${selector}".`);
|
|
1094
|
-
}
|
|
1095
|
-
return html.slice(start, end + endTag.length);
|
|
1096
|
-
}, mountAngularIsland = async (component, element, props, islandId) => {
|
|
1097
|
-
await import("@angular/compiler");
|
|
1098
|
-
const { createComponent, inputBinding } = await import("@angular/core");
|
|
1099
|
-
const selector = getAngularIslandSelector(islandId);
|
|
1100
|
-
const { app, environmentInjector } = await getAngularIslandApp();
|
|
1101
|
-
let rootElement = element.querySelector(selector);
|
|
1102
|
-
if (!(rootElement instanceof HTMLElement)) {
|
|
1103
|
-
element.innerHTML = `<${selector}></${selector}>`;
|
|
1104
|
-
rootElement = element.querySelector(selector);
|
|
1105
|
-
}
|
|
1106
|
-
if (!(rootElement instanceof HTMLElement))
|
|
1107
|
-
return app;
|
|
1108
|
-
const componentSelector = getClientAngularComponentSelector(component) ?? getSelectorFromRenderedIsland(rootElement);
|
|
1109
|
-
if (!componentSelector)
|
|
1110
|
-
return app;
|
|
1111
|
-
rootElement.innerHTML = `<${componentSelector}></${componentSelector}>`;
|
|
1112
|
-
const hostElement = rootElement.querySelector(componentSelector);
|
|
1113
|
-
if (!(hostElement instanceof HTMLElement))
|
|
1114
|
-
return app;
|
|
1115
|
-
const bindings = Object.entries(props).map(([key, value]) => inputBinding(key, () => value));
|
|
1116
|
-
const componentRef = createComponent(component, {
|
|
1117
|
-
bindings,
|
|
1118
|
-
environmentInjector,
|
|
1119
|
-
hostElement
|
|
1120
|
-
});
|
|
1121
|
-
app.attachView(componentRef.hostView);
|
|
1122
|
-
componentRef.changeDetectorRef.detectChanges();
|
|
1123
|
-
window.__ABS_ANGULAR_ISLAND_APPS__ ??= [];
|
|
1124
|
-
window.__ABS_ANGULAR_ISLAND_APPS__.push(app);
|
|
1125
|
-
return app;
|
|
1126
|
-
}, renderAngularIslandToHtml = async (component, props, islandId) => {
|
|
1127
|
-
const requestCache = getRequestRenderCache();
|
|
1128
|
-
const renderCacheKey = getIslandRenderCacheKey(component, props);
|
|
1129
|
-
const cachedHtml = requestCache?.get(renderCacheKey);
|
|
1130
|
-
if (cachedHtml) {
|
|
1131
|
-
return cachedHtml;
|
|
1132
|
-
}
|
|
1133
|
-
const { deps, propsToken, selector, WrapperComponent } = await createAngularIslandWrapper(component, islandId);
|
|
1134
|
-
const providers = [
|
|
1135
|
-
deps.provideServerRendering(),
|
|
1136
|
-
deps.provideZonelessChangeDetection(),
|
|
1137
|
-
{ provide: deps.APP_BASE_HREF, useValue: "/" },
|
|
1138
|
-
{ provide: propsToken, useValue: props }
|
|
1139
|
-
];
|
|
1140
|
-
const document2 = `<!DOCTYPE html><html><body><${selector}></${selector}></body></html>`;
|
|
1141
|
-
const html = await withSuppressedAngularDevLogs(() => deps.renderApplication((context) => deps.bootstrapApplication(WrapperComponent, { providers }, context), {
|
|
1142
|
-
document: document2,
|
|
1143
|
-
platformProviders: [],
|
|
1144
|
-
url: "/"
|
|
1145
|
-
}));
|
|
1146
|
-
const islandHtml = extractAngularIslandRoot(html, selector);
|
|
1147
|
-
requestCache?.set(renderCacheKey, islandHtml);
|
|
1148
|
-
return islandHtml;
|
|
1149
|
-
};
|
|
1150
|
-
var init_islands = __esm(() => {
|
|
1151
|
-
init_angularDeps();
|
|
1152
|
-
init_ssrRender();
|
|
1153
|
-
init_registerClientScript();
|
|
1154
|
-
wrapperMetadataCache = new Map;
|
|
1155
|
-
requestRenderCache = new Map;
|
|
1156
|
-
});
|
|
1157
|
-
|
|
1158
|
-
// src/core/islandSsr.ts
|
|
1159
|
-
var renderAngularIslandToHtmlInternal = async (component, props, islandId) => {
|
|
1160
|
-
const { renderAngularIslandToHtml: renderAngularIslandToHtml2 } = await Promise.resolve().then(() => (init_islands(), exports_islands));
|
|
1161
|
-
return renderAngularIslandToHtml2(component, props, islandId);
|
|
1162
|
-
}, renderAngularIslandToHtml2, renderReactIslandToHtml = (component, props) => import("react").then(({ createElement }) => import("react-dom/server").then(({ renderToStaticMarkup }) => renderToStaticMarkup(createElement(component, props)))), renderSvelteIslandToHtml = (component, props) => import("svelte/server").then(({ render }) => {
|
|
1163
|
-
const { body } = render(component, { props });
|
|
1164
|
-
return body;
|
|
1165
|
-
}), renderVueIslandToHtml = (component, props) => import("vue").then(({ createSSRApp, h }) => {
|
|
1166
|
-
const app = createSSRApp({
|
|
1167
|
-
render: () => h(component, props)
|
|
1168
|
-
});
|
|
1169
|
-
return import("vue/server-renderer").then(({ renderToString }) => renderToString(app));
|
|
1170
|
-
});
|
|
1171
|
-
var init_islandSsr = __esm(() => {
|
|
1172
|
-
renderAngularIslandToHtml2 = renderAngularIslandToHtmlInternal;
|
|
1173
|
-
});
|
|
1174
|
-
|
|
1175
|
-
// src/build/resolvePackageImport.ts
|
|
1176
|
-
import { resolve as resolve3, join as join2 } from "path";
|
|
1177
|
-
import { existsSync as existsSync3, readFileSync as readFileSync2 } from "fs";
|
|
1178
|
-
var resolveExportPath = (entry, conditions) => {
|
|
1179
|
-
if (typeof entry === "string")
|
|
1180
|
-
return entry;
|
|
1181
|
-
if (!entry || typeof entry !== "object")
|
|
1182
|
-
return null;
|
|
1183
|
-
for (const condition of conditions) {
|
|
1184
|
-
const target = Reflect.get(entry, condition);
|
|
1185
|
-
if (typeof target === "string") {
|
|
1186
|
-
return target;
|
|
1092
|
+
return new Promise((resolveCss, reject) => {
|
|
1093
|
+
const renderer = stylus(contents);
|
|
1094
|
+
renderer.set("filename", filePath);
|
|
1095
|
+
for (const [key, value] of Object.entries(options.options ?? {})) {
|
|
1096
|
+
renderer.set(key, value);
|
|
1187
1097
|
}
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
const
|
|
1199
|
-
const
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
if (!exports)
|
|
1209
|
-
return null;
|
|
1210
|
-
const entry = exports[exportKey];
|
|
1211
|
-
if (!entry)
|
|
1212
|
-
return null;
|
|
1213
|
-
const importPath = resolveExportPath(entry, conditions);
|
|
1214
|
-
if (!importPath)
|
|
1215
|
-
return null;
|
|
1216
|
-
if (currentPackageDir && importPath.startsWith("./dist/")) {
|
|
1217
|
-
const sourceCandidate = resolve3(packageDir, importPath.replace(/^\.\/dist\//, "./src/"));
|
|
1218
|
-
if (existsSync3(sourceCandidate)) {
|
|
1219
|
-
return sourceCandidate;
|
|
1220
|
-
}
|
|
1098
|
+
for (const path of loadPaths)
|
|
1099
|
+
renderer.include(path);
|
|
1100
|
+
renderer.render((error, css) => {
|
|
1101
|
+
if (error)
|
|
1102
|
+
reject(error);
|
|
1103
|
+
else
|
|
1104
|
+
resolveCss(css ?? "");
|
|
1105
|
+
});
|
|
1106
|
+
});
|
|
1107
|
+
}, compileStyleSource = async (filePath, source, languageHint, config) => {
|
|
1108
|
+
const language = getStyleLanguage(languageHint ?? filePath);
|
|
1109
|
+
const rawContents = source ?? await readFile(filePath, "utf-8");
|
|
1110
|
+
if (language === "scss" || language === "sass") {
|
|
1111
|
+
const options = getSassOptions(config, language);
|
|
1112
|
+
const packageName = options.implementation ?? "sass";
|
|
1113
|
+
let sass;
|
|
1114
|
+
try {
|
|
1115
|
+
sass = await importOptionalPeer(packageName);
|
|
1116
|
+
} catch {
|
|
1117
|
+
throw missingDependencyError(packageName, filePath);
|
|
1221
1118
|
}
|
|
1222
|
-
const
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1119
|
+
const contents = withAdditionalData(rawContents, options.additionalData);
|
|
1120
|
+
const loadPaths = normalizeLoadPaths(filePath, options.loadPaths);
|
|
1121
|
+
const result = sass.compileString(contents, {
|
|
1122
|
+
importers: [
|
|
1123
|
+
createSassImporter(filePath, loadPaths, language, config)
|
|
1124
|
+
],
|
|
1125
|
+
loadPaths,
|
|
1126
|
+
style: "expanded",
|
|
1127
|
+
syntax: language === "sass" ? "indented" : "scss",
|
|
1128
|
+
url: new URL(`file://${filePath}`)
|
|
1129
|
+
});
|
|
1130
|
+
return runPostcss(result.css, filePath, config);
|
|
1226
1131
|
}
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
const char = text[index];
|
|
1235
|
-
if (char === "{")
|
|
1236
|
-
depth += 1;
|
|
1237
|
-
if (char === "}")
|
|
1238
|
-
depth -= 1;
|
|
1239
|
-
if (depth === 0) {
|
|
1240
|
-
return text.slice(braceStart + 1, index).trim();
|
|
1132
|
+
if (language === "less") {
|
|
1133
|
+
const options = getLessOptions(config);
|
|
1134
|
+
let lessModule;
|
|
1135
|
+
try {
|
|
1136
|
+
lessModule = await importOptionalPeer("less");
|
|
1137
|
+
} catch {
|
|
1138
|
+
throw missingDependencyError("less", filePath);
|
|
1241
1139
|
}
|
|
1140
|
+
const less = lessModule.render ? lessModule : lessModule.default;
|
|
1141
|
+
const render = less?.render;
|
|
1142
|
+
if (!render)
|
|
1143
|
+
throw missingDependencyError("less", filePath);
|
|
1144
|
+
const contents = withAdditionalData(rawContents, options.additionalData);
|
|
1145
|
+
const loadPaths = normalizeLoadPaths(filePath, options.paths);
|
|
1146
|
+
const result = await render(contents, {
|
|
1147
|
+
...options.options ?? {},
|
|
1148
|
+
filename: filePath,
|
|
1149
|
+
paths: loadPaths,
|
|
1150
|
+
plugins: [
|
|
1151
|
+
...options.options?.plugins ?? [],
|
|
1152
|
+
createLessFileManager(filePath, loadPaths, config)
|
|
1153
|
+
]
|
|
1154
|
+
});
|
|
1155
|
+
return runPostcss(result.css, filePath, config);
|
|
1242
1156
|
}
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
return
|
|
1248
|
-
}
|
|
1249
|
-
const attributeIndex = attributeString.search(new RegExp(`\\b${name}\\s*=\\s*\\{`));
|
|
1250
|
-
if (attributeIndex < 0) {
|
|
1251
|
-
return { expression: "", found: false };
|
|
1252
|
-
}
|
|
1253
|
-
const braceStart = attributeString.indexOf("{", attributeIndex);
|
|
1254
|
-
if (braceStart < 0) {
|
|
1255
|
-
return { expression: "", found: false };
|
|
1256
|
-
}
|
|
1257
|
-
const expression = extractBracedExpression(attributeString, braceStart);
|
|
1258
|
-
if (expression === null) {
|
|
1259
|
-
return { expression: "", found: false };
|
|
1260
|
-
}
|
|
1261
|
-
return { expression, found: true };
|
|
1262
|
-
}, lowerSvelteIslandSyntax = (source, _mode = "server") => {
|
|
1263
|
-
if (!source.includes("<Island")) {
|
|
1264
|
-
return { code: source, transformed: false };
|
|
1157
|
+
if (language === "stylus") {
|
|
1158
|
+
const options = getStylusOptions(config);
|
|
1159
|
+
const loadPaths = normalizeLoadPaths(filePath, options.paths);
|
|
1160
|
+
const contents = withAdditionalData(preprocessLoadedStyle(rawContents, filePath, filePath, loadPaths, "stylus", config), options.additionalData);
|
|
1161
|
+
return runPostcss(await renderStylus(contents, filePath, loadPaths, options), filePath, config);
|
|
1265
1162
|
}
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1163
|
+
return runPostcss(rawContents, filePath, config);
|
|
1164
|
+
}, createStylePreprocessorPlugin = (config) => ({
|
|
1165
|
+
name: "absolute-style-preprocessor",
|
|
1166
|
+
setup(build) {
|
|
1167
|
+
const cssModuleSources = new Map;
|
|
1168
|
+
build.onResolve({ filter: /^absolute-style-module:/ }, ({ path }) => ({
|
|
1169
|
+
namespace: "absolute-style-module",
|
|
1170
|
+
path: path.slice("absolute-style-module:".length)
|
|
1171
|
+
}));
|
|
1172
|
+
build.onLoad({ filter: /\.module\.css$/i, namespace: "absolute-style-module" }, async ({ path }) => {
|
|
1173
|
+
const source = cssModuleSources.get(path);
|
|
1174
|
+
if (!source) {
|
|
1175
|
+
throw new Error(`Unable to resolve CSS module source for ${path}`);
|
|
1176
|
+
}
|
|
1177
|
+
return {
|
|
1178
|
+
contents: source.css,
|
|
1179
|
+
loader: "css"
|
|
1180
|
+
};
|
|
1181
|
+
});
|
|
1182
|
+
build.onLoad({ filter: STYLE_EXTENSION_PATTERN }, async ({ path }) => {
|
|
1183
|
+
if (isStyleModulePath(path)) {
|
|
1184
|
+
const cssModulePath = path.replace(STYLE_EXTENSION_PATTERN, ".css");
|
|
1185
|
+
const compiled = await compileStyleSource(path, undefined, undefined, config);
|
|
1186
|
+
const { css, exports } = extractCssModuleExports(compiled);
|
|
1187
|
+
cssModuleSources.set(cssModulePath, { css, exports });
|
|
1188
|
+
const exportSource = Object.keys(exports).length > 0 ? `import styles from ${JSON.stringify(`absolute-style-module:${cssModulePath}`)}; export default Object.assign({}, styles, ${JSON.stringify(exports)});` : `export { default } from ${JSON.stringify(`absolute-style-module:${cssModulePath}`)};`;
|
|
1189
|
+
return {
|
|
1190
|
+
contents: exportSource,
|
|
1191
|
+
loader: "js"
|
|
1192
|
+
};
|
|
1193
|
+
}
|
|
1194
|
+
return {
|
|
1195
|
+
contents: await compileStyleSource(path, undefined, undefined, config),
|
|
1196
|
+
loader: "css"
|
|
1197
|
+
};
|
|
1198
|
+
});
|
|
1199
|
+
build.onLoad({ filter: CSS_EXTENSION_PATTERN }, async ({ path }) => ({
|
|
1200
|
+
contents: await compileStyleSource(path, undefined, undefined, config),
|
|
1201
|
+
loader: "css"
|
|
1202
|
+
}));
|
|
1203
|
+
}
|
|
1204
|
+
}), stylePreprocessorPlugin, createSvelteStylePreprocessor = (config) => ({
|
|
1205
|
+
style: async ({
|
|
1206
|
+
attributes,
|
|
1207
|
+
content,
|
|
1208
|
+
filename
|
|
1209
|
+
}) => {
|
|
1210
|
+
const language = typeof attributes.lang === "string" ? attributes.lang : typeof attributes.type === "string" ? attributes.type.replace(/^text\//, "") : null;
|
|
1211
|
+
if (!language || !STYLE_LANGUAGE_PATTERN.test(language))
|
|
1212
|
+
return;
|
|
1213
|
+
const path = filename ?? `style.${language}`;
|
|
1214
|
+
return {
|
|
1215
|
+
code: await compileStyleSource(path, content, language, config)
|
|
1287
1216
|
};
|
|
1288
1217
|
}
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
</script>
|
|
1293
|
-
${transformedMarkup}`,
|
|
1294
|
-
transformed: true
|
|
1295
|
-
};
|
|
1296
|
-
};
|
|
1297
|
-
var init_lowerIslandSyntax = __esm(() => {
|
|
1298
|
-
init_constants();
|
|
1299
|
-
ISLAND_TAG_RE = /<Island\b([\s\S]*?)\/>/g;
|
|
1300
|
-
});
|
|
1301
|
-
|
|
1302
|
-
// src/svelte/lowerAwaitSlotSyntax.ts
|
|
1303
|
-
var AWAIT_BLOCK_RE, escapeTemplateLiteral = (value) => value.replaceAll("\\", "\\\\").replaceAll("`", "\\`").replaceAll("${", "\\${"), markupToTemplateLiteral = (markup) => {
|
|
1304
|
-
const escaped = escapeTemplateLiteral(markup.trim());
|
|
1305
|
-
const withExpressions = escaped.replace(/\{([^{}]+)\}/g, (_, expression) => `\${${String(expression).trim()}}`);
|
|
1306
|
-
return `\`${withExpressions}\``;
|
|
1307
|
-
}, lowerSvelteAwaitSlotSyntax = (source) => {
|
|
1308
|
-
if (!source.includes("{#await")) {
|
|
1309
|
-
return { code: source, transformed: false };
|
|
1218
|
+
}), compileStyleFileIfNeeded = async (filePath, config) => {
|
|
1219
|
+
if (!isPreprocessableStylePath(filePath)) {
|
|
1220
|
+
return runPostcss(await readFile(filePath, "utf-8"), filePath, config);
|
|
1310
1221
|
}
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
const
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1222
|
+
return compileStyleSource(filePath, undefined, undefined, config);
|
|
1223
|
+
}, compileStyleFileIfNeededSync = (filePath, config) => {
|
|
1224
|
+
const rawContents = readFileSync3(filePath, "utf-8");
|
|
1225
|
+
const language = getStyleLanguage(filePath);
|
|
1226
|
+
if (config?.postcss) {
|
|
1227
|
+
throw new Error(`Unable to compile ${filePath}: PostCSS preprocessing is async-only.`);
|
|
1228
|
+
}
|
|
1229
|
+
if (language === "scss" || language === "sass") {
|
|
1230
|
+
const options = getSassOptions(config, language);
|
|
1231
|
+
const packageName = options.implementation ?? "sass";
|
|
1232
|
+
let sass;
|
|
1233
|
+
try {
|
|
1234
|
+
sass = requireOptionalPeerSync(packageName);
|
|
1235
|
+
} catch {
|
|
1236
|
+
throw missingDependencyError(packageName, filePath);
|
|
1317
1237
|
}
|
|
1318
|
-
const
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
if (!transformed) {
|
|
1330
|
-
return { code: source, transformed: false };
|
|
1238
|
+
const contents = withAdditionalData(rawContents, options.additionalData);
|
|
1239
|
+
const loadPaths = normalizeLoadPaths(filePath, options.loadPaths);
|
|
1240
|
+
return sass.compileString(contents, {
|
|
1241
|
+
importers: [
|
|
1242
|
+
createSassImporter(filePath, loadPaths, language, config)
|
|
1243
|
+
],
|
|
1244
|
+
loadPaths,
|
|
1245
|
+
style: "expanded",
|
|
1246
|
+
syntax: language === "sass" ? "indented" : "scss",
|
|
1247
|
+
url: new URL(`file://${filePath}`)
|
|
1248
|
+
}).css;
|
|
1331
1249
|
}
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
return {
|
|
1335
|
-
code: lowered.replace(/<script(\s[^>]*)?>/, (match) => `${match}
|
|
1336
|
-
${importLine}
|
|
1337
|
-
`),
|
|
1338
|
-
transformed: true
|
|
1339
|
-
};
|
|
1250
|
+
if (language === "less") {
|
|
1251
|
+
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.`);
|
|
1340
1252
|
}
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1253
|
+
if (language === "stylus") {
|
|
1254
|
+
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.`);
|
|
1255
|
+
}
|
|
1256
|
+
return rawContents;
|
|
1257
|
+
}, getCssOutputExtension = (filePath) => isPreprocessableStylePath(filePath) ? ".css" : extname(filePath);
|
|
1258
|
+
var init_stylePreprocessor = __esm(() => {
|
|
1259
|
+
CSS_EXTENSION_PATTERN = /\.css$/i;
|
|
1260
|
+
STYLE_EXTENSION_PATTERN = /\.(s[ac]ss|less|styl(?:us)?)$/i;
|
|
1261
|
+
STYLE_MODULE_EXTENSION_PATTERN = /\.module\.(s[ac]ss|less|styl(?:us)?)$/i;
|
|
1262
|
+
STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less|styl(?:us)?)$/i;
|
|
1263
|
+
importOptionalPeer = new Function("specifier", "return import(specifier)");
|
|
1264
|
+
requireOptionalPeer = new Function("specifier", "return require(specifier)");
|
|
1265
|
+
requireFromCwd = createRequire(join3(process.cwd(), "package.json"));
|
|
1266
|
+
stylePreprocessorPlugin = createStylePreprocessorPlugin();
|
|
1352
1267
|
});
|
|
1353
1268
|
|
|
1354
|
-
// src/
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
});
|
|
1370
|
-
import { existsSync as existsSync4, readFileSync as readFileSync3 } from "fs";
|
|
1371
|
-
import { readFile } from "fs/promises";
|
|
1372
|
-
import { createRequire } from "module";
|
|
1373
|
-
import { dirname as dirname2, extname, isAbsolute, join as join3, relative, resolve as resolve4 } from "path";
|
|
1374
|
-
import { fileURLToPath } from "url";
|
|
1375
|
-
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) => {
|
|
1376
|
-
const normalized = filePathOrLanguage.toLowerCase();
|
|
1377
|
-
if (normalized === "scss" || normalized.endsWith(".scss"))
|
|
1378
|
-
return "scss";
|
|
1379
|
-
if (normalized === "sass" || normalized.endsWith(".sass"))
|
|
1380
|
-
return "sass";
|
|
1381
|
-
if (normalized === "less" || normalized.endsWith(".less"))
|
|
1382
|
-
return "less";
|
|
1383
|
-
if (normalized === "styl" || normalized === "stylus" || normalized.endsWith(".styl") || normalized.endsWith(".stylus"))
|
|
1384
|
-
return "stylus";
|
|
1269
|
+
// src/core/svelteServerModule.ts
|
|
1270
|
+
import { mkdir, readdir } from "fs/promises";
|
|
1271
|
+
import { basename as basename2, dirname as dirname3, extname as extname2, join as join4, relative as relative2, resolve as resolve5 } from "path";
|
|
1272
|
+
var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, ensureRelativeImportPath = (from, target) => {
|
|
1273
|
+
const importPath = relative2(dirname3(from), target).replace(/\\/g, "/");
|
|
1274
|
+
return importPath.startsWith(".") ? importPath : `./${importPath}`;
|
|
1275
|
+
}, processDirectoryEntries = (entries, dir, targetFileName, stack) => {
|
|
1276
|
+
for (const entry of entries) {
|
|
1277
|
+
const entryPath = join4(dir, entry.name);
|
|
1278
|
+
if (entry.isDirectory())
|
|
1279
|
+
stack.push(entryPath);
|
|
1280
|
+
if (entry.isFile() && entry.name === targetFileName) {
|
|
1281
|
+
return entryPath;
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1385
1284
|
return null;
|
|
1386
|
-
},
|
|
1387
|
-
|
|
1388
|
-
return
|
|
1389
|
-
|
|
1390
|
-
|
|
1285
|
+
}, searchDirectoryLevel = async (dirs, targetFileName) => {
|
|
1286
|
+
if (dirs.length === 0)
|
|
1287
|
+
return null;
|
|
1288
|
+
const nextStack = [];
|
|
1289
|
+
const dirEntries = await Promise.all(dirs.map(async (dir) => ({
|
|
1290
|
+
dir,
|
|
1291
|
+
entries: await readdir(dir, {
|
|
1292
|
+
encoding: "utf-8",
|
|
1293
|
+
withFileTypes: true
|
|
1294
|
+
})
|
|
1295
|
+
})));
|
|
1296
|
+
for (const { dir, entries } of dirEntries) {
|
|
1297
|
+
const found = processDirectoryEntries(entries, dir, targetFileName, nextStack);
|
|
1298
|
+
if (found)
|
|
1299
|
+
return found;
|
|
1391
1300
|
}
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
pattern,
|
|
1398
|
-
replacements: Array.isArray(value) ? value : [value]
|
|
1399
|
-
})), readTsconfigAliases = () => {
|
|
1400
|
-
const cwd = process.cwd();
|
|
1401
|
-
if (tsconfigAliasCache?.cwd === cwd)
|
|
1402
|
-
return tsconfigAliasCache;
|
|
1403
|
-
const tsconfigPath = resolve4(cwd, "tsconfig.json");
|
|
1404
|
-
const empty = { aliases: [], baseUrl: cwd, cwd };
|
|
1405
|
-
if (!existsSync4(tsconfigPath)) {
|
|
1406
|
-
tsconfigAliasCache = empty;
|
|
1407
|
-
return empty;
|
|
1301
|
+
return searchDirectoryLevel(nextStack, targetFileName);
|
|
1302
|
+
}, findSourceFileByBasename = async (searchRoot, targetFileName) => searchDirectoryLevel([searchRoot], targetFileName), normalizeBuiltSvelteFileName = (sourcePath) => basename2(sourcePath).replace(/-[a-z0-9]{6,}(?=\.svelte$)/i, ""), resolveOriginalSourcePath = async (sourcePath) => {
|
|
1303
|
+
const cachedPath = originalSourcePathCache.get(sourcePath);
|
|
1304
|
+
if (cachedPath !== undefined) {
|
|
1305
|
+
return cachedPath;
|
|
1408
1306
|
}
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
const baseUrl = resolve4(cwd, compilerOptions.baseUrl ?? ".");
|
|
1413
|
-
tsconfigAliasCache = {
|
|
1414
|
-
aliases: normalizeAliasEntries(compilerOptions.paths),
|
|
1415
|
-
baseUrl,
|
|
1416
|
-
cwd
|
|
1417
|
-
};
|
|
1418
|
-
} catch {
|
|
1419
|
-
tsconfigAliasCache = empty;
|
|
1420
|
-
}
|
|
1421
|
-
return tsconfigAliasCache;
|
|
1422
|
-
}, getAliasEntries = (config) => {
|
|
1423
|
-
const tsconfig = readTsconfigAliases();
|
|
1424
|
-
return {
|
|
1425
|
-
aliases: [...normalizeAliasEntries(config?.aliases), ...tsconfig.aliases],
|
|
1426
|
-
baseUrl: tsconfig.baseUrl
|
|
1427
|
-
};
|
|
1428
|
-
}, aliasPatternToRegExp = (pattern) => new RegExp(`^${pattern.split("*").map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("(.+)")}$`), resolveAliasTargets = (specifier, config) => {
|
|
1429
|
-
const { aliases, baseUrl } = getAliasEntries(config);
|
|
1430
|
-
const targets = [];
|
|
1431
|
-
for (const alias of aliases) {
|
|
1432
|
-
const match = specifier.match(aliasPatternToRegExp(alias.pattern));
|
|
1433
|
-
if (!match)
|
|
1434
|
-
continue;
|
|
1435
|
-
const wildcard = match[1] ?? "";
|
|
1436
|
-
for (const replacement of alias.replacements) {
|
|
1437
|
-
targets.push(resolve4(baseUrl, replacement.replace("*", wildcard)));
|
|
1438
|
-
}
|
|
1307
|
+
if (!sourcePath.includes(`${join4(process.cwd(), "build")}${process.platform === "win32" ? "" : "/"}`) && !sourcePath.includes("/build/")) {
|
|
1308
|
+
originalSourcePathCache.set(sourcePath, sourcePath);
|
|
1309
|
+
return sourcePath;
|
|
1439
1310
|
}
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
}, getCandidatePaths = (basePath, language) => {
|
|
1448
|
-
const ext = extname(basePath);
|
|
1449
|
-
const paths = ext ? [basePath] : getLanguageExtensions(language).flatMap((extension) => [
|
|
1450
|
-
`${basePath}${extension}`,
|
|
1451
|
-
join3(basePath, `index${extension}`)
|
|
1452
|
-
]);
|
|
1453
|
-
if (language === "scss" || language === "sass") {
|
|
1454
|
-
return paths.flatMap((path) => {
|
|
1455
|
-
const dir = dirname2(path);
|
|
1456
|
-
const base = path.slice(dir.length + 1);
|
|
1457
|
-
return [path, join3(dir, `_${base}`)];
|
|
1458
|
-
});
|
|
1311
|
+
const resolvedSourcePath = await findSourceFileByBasename(join4(process.cwd(), "src"), normalizeBuiltSvelteFileName(sourcePath));
|
|
1312
|
+
const nextPath = resolvedSourcePath ?? sourcePath;
|
|
1313
|
+
originalSourcePathCache.set(sourcePath, nextPath);
|
|
1314
|
+
return nextPath;
|
|
1315
|
+
}, resolveRelativeModule = async (spec, from) => {
|
|
1316
|
+
if (!spec.startsWith(".")) {
|
|
1317
|
+
return null;
|
|
1459
1318
|
}
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1319
|
+
const basePath = resolve5(dirname3(from), spec);
|
|
1320
|
+
const candidates = [
|
|
1321
|
+
basePath,
|
|
1322
|
+
`${basePath}.ts`,
|
|
1323
|
+
`${basePath}.js`,
|
|
1324
|
+
`${basePath}.mjs`,
|
|
1325
|
+
`${basePath}.cjs`,
|
|
1326
|
+
`${basePath}.json`,
|
|
1327
|
+
join4(basePath, "index.ts"),
|
|
1328
|
+
join4(basePath, "index.js"),
|
|
1329
|
+
join4(basePath, "index.mjs"),
|
|
1330
|
+
join4(basePath, "index.cjs"),
|
|
1331
|
+
join4(basePath, "index.json")
|
|
1466
1332
|
];
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1333
|
+
const existResults = await Promise.all(candidates.map((candidate) => Bun.file(candidate).exists()));
|
|
1334
|
+
const foundIndex = existResults.indexOf(true);
|
|
1335
|
+
return foundIndex >= 0 ? candidates[foundIndex] ?? null : null;
|
|
1336
|
+
}, getCachedModulePath = (sourcePath) => {
|
|
1337
|
+
const relativeSourcePath = relative2(process.cwd(), sourcePath).replace(/\\/g, "/");
|
|
1338
|
+
const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
|
|
1339
|
+
return join4(serverCacheRoot, `${normalizedSourcePath}.server.js`);
|
|
1340
|
+
}, resolveSvelteImport = async (spec, from) => {
|
|
1341
|
+
if (!spec.startsWith(".") && !spec.startsWith("/")) {
|
|
1342
|
+
const resolved = resolvePackageImport(spec);
|
|
1343
|
+
return resolved && resolved.endsWith(".svelte") ? resolved : null;
|
|
1344
|
+
}
|
|
1345
|
+
if (spec.startsWith("/")) {
|
|
1346
|
+
return spec;
|
|
1347
|
+
}
|
|
1348
|
+
if (!spec.startsWith(".")) {
|
|
1349
|
+
return null;
|
|
1350
|
+
}
|
|
1351
|
+
const explicitPath = resolve5(dirname3(from), spec);
|
|
1352
|
+
if (extname2(explicitPath) === ".svelte") {
|
|
1353
|
+
return explicitPath;
|
|
1354
|
+
}
|
|
1355
|
+
const candidate = `${explicitPath}.svelte`;
|
|
1356
|
+
if (await Bun.file(candidate).exists() === true) {
|
|
1357
|
+
return candidate;
|
|
1470
1358
|
}
|
|
1471
1359
|
return null;
|
|
1472
|
-
},
|
|
1473
|
-
const
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
};
|
|
1480
|
-
}, rebaseCssUrls = (contents, sourceFile, entryFile) => {
|
|
1481
|
-
const sourceDir = dirname2(sourceFile);
|
|
1482
|
-
const entryDir = dirname2(entryFile);
|
|
1483
|
-
if (sourceDir === entryDir)
|
|
1484
|
-
return contents;
|
|
1485
|
-
return contents.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/gi, (match, quote, rawUrl) => {
|
|
1486
|
-
const trimmedUrl = rawUrl.trim();
|
|
1487
|
-
if (!trimmedUrl || isExternalCssUrl(trimmedUrl))
|
|
1488
|
-
return match;
|
|
1489
|
-
const { marker, path } = splitCssUrl(trimmedUrl);
|
|
1490
|
-
const rebased = relative(entryDir, resolve4(sourceDir, path)).replace(/\\/g, "/");
|
|
1491
|
-
const normalized = rebased.startsWith(".") ? rebased : `./${rebased}`;
|
|
1492
|
-
const nextQuote = quote || '"';
|
|
1493
|
-
return `url(${nextQuote}${normalized}${marker}${nextQuote})`;
|
|
1494
|
-
});
|
|
1495
|
-
}, rewriteAliasedStyleImports = (contents, sourceFile, loadPaths, language, config) => contents.replace(/(@(?:use|forward|import|require)\s+)(["'])([^"']+)\2/g, (match, prefix, quote, specifier) => {
|
|
1496
|
-
if (specifier.startsWith(".") || isAbsolute(specifier) || isExternalCssUrl(specifier))
|
|
1497
|
-
return match;
|
|
1498
|
-
const resolved = resolveImportPath(specifier, dirname2(sourceFile), loadPaths, language, config);
|
|
1499
|
-
return resolved ? `${prefix}${quote}${resolved}${quote}` : match;
|
|
1500
|
-
}), preprocessLoadedStyle = (contents, sourceFile, entryFile, loadPaths = [], language, config) => {
|
|
1501
|
-
const rebased = rebaseCssUrls(contents, sourceFile, entryFile);
|
|
1502
|
-
return language ? rewriteAliasedStyleImports(rebased, sourceFile, loadPaths, language, config) : rebased;
|
|
1503
|
-
}, extractCssModuleExports = (css) => {
|
|
1504
|
-
const exports = {};
|
|
1505
|
-
const nextCss = css.replace(/:export\s*\{([^}]*)\}/g, (_, body) => {
|
|
1506
|
-
for (const declaration of body.split(";")) {
|
|
1507
|
-
const separator = declaration.indexOf(":");
|
|
1508
|
-
if (separator === -1)
|
|
1509
|
-
continue;
|
|
1510
|
-
const key = declaration.slice(0, separator).trim();
|
|
1511
|
-
const value = declaration.slice(separator + 1).trim();
|
|
1512
|
-
if (key && value)
|
|
1513
|
-
exports[key] = value;
|
|
1360
|
+
}, writeIfChanged = async (path, content) => {
|
|
1361
|
+
const targetFile = Bun.file(path);
|
|
1362
|
+
const exists = await targetFile.exists();
|
|
1363
|
+
if (exists) {
|
|
1364
|
+
const currentContent = await targetFile.text();
|
|
1365
|
+
if (currentContent === content) {
|
|
1366
|
+
return;
|
|
1514
1367
|
}
|
|
1515
|
-
return "";
|
|
1516
|
-
});
|
|
1517
|
-
return { css: nextCss, exports };
|
|
1518
|
-
}, getSassOptions = (config, language) => ({
|
|
1519
|
-
...config?.sass ?? {},
|
|
1520
|
-
...language === "scss" ? config?.scss ?? {} : {}
|
|
1521
|
-
}), getLessOptions = (config) => config?.less ?? {}, getStylusOptions = (config) => config?.stylus ?? {}, createStyleTransformConfig = (stylePreprocessors, postcss) => postcss === undefined ? stylePreprocessors : { ...stylePreprocessors ?? {}, postcss }, withAdditionalData = (contents, additionalData) => additionalData ? `${additionalData}
|
|
1522
|
-
${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
1523
|
-
if (mod && typeof mod === "object" && "default" in mod) {
|
|
1524
|
-
return mod.default ?? mod;
|
|
1525
|
-
}
|
|
1526
|
-
return mod;
|
|
1527
|
-
}, loadPostcssConfigFile = async (configPath) => {
|
|
1528
|
-
const resolved = resolve4(process.cwd(), configPath);
|
|
1529
|
-
const loaded = resolved.endsWith(".cjs") || resolved.endsWith(".cts") ? requireOptionalPeerSync(resolved) : await importOptionalPeer(`${new URL(`file://${resolved}`).href}?t=${Date.now()}`);
|
|
1530
|
-
const config = normalizePostcssModule(loaded);
|
|
1531
|
-
const value = typeof config === "function" ? await config({
|
|
1532
|
-
cwd: process.cwd(),
|
|
1533
|
-
env: "development"
|
|
1534
|
-
}) : config;
|
|
1535
|
-
return normalizePostcssModule(value) ?? {};
|
|
1536
|
-
}, normalizePostcssPlugins = (plugins) => {
|
|
1537
|
-
if (!plugins)
|
|
1538
|
-
return [];
|
|
1539
|
-
if (Array.isArray(plugins))
|
|
1540
|
-
return plugins.filter(Boolean);
|
|
1541
|
-
const resolved = [];
|
|
1542
|
-
for (const [specifier, options] of Object.entries(plugins)) {
|
|
1543
|
-
if (options === false)
|
|
1544
|
-
continue;
|
|
1545
|
-
const mod = normalizePostcssModule(requireOptionalPeerSync(specifier));
|
|
1546
|
-
const plugin = typeof mod === "function" ? mod(options === true ? undefined : options) : mod;
|
|
1547
|
-
if (plugin)
|
|
1548
|
-
resolved.push(plugin);
|
|
1549
1368
|
}
|
|
1550
|
-
|
|
1551
|
-
},
|
|
1552
|
-
const
|
|
1553
|
-
if (
|
|
1554
|
-
return
|
|
1555
|
-
const fileConfig = inlineConfig.config ? await loadPostcssConfigFile(inlineConfig.config) : {};
|
|
1556
|
-
const plugins = [
|
|
1557
|
-
...normalizePostcssPlugins(fileConfig.plugins),
|
|
1558
|
-
...normalizePostcssPlugins(inlineConfig.plugins)
|
|
1559
|
-
];
|
|
1560
|
-
if (plugins.length === 0)
|
|
1561
|
-
return null;
|
|
1562
|
-
return {
|
|
1563
|
-
options: {
|
|
1564
|
-
...fileConfig.options ?? {},
|
|
1565
|
-
...inlineConfig.options ?? {}
|
|
1566
|
-
},
|
|
1567
|
-
plugins
|
|
1568
|
-
};
|
|
1569
|
-
}, runPostcss = async (css, filePath, config) => {
|
|
1570
|
-
const postcssConfig = await resolvePostcssConfig(config);
|
|
1571
|
-
if (!postcssConfig)
|
|
1572
|
-
return css;
|
|
1573
|
-
let postcssModule;
|
|
1574
|
-
try {
|
|
1575
|
-
postcssModule = await importOptionalPeer("postcss");
|
|
1576
|
-
} catch {
|
|
1577
|
-
throw missingDependencyError("postcss", filePath);
|
|
1369
|
+
await Bun.write(path, content);
|
|
1370
|
+
}, compileSvelteServerModule = async (sourcePath) => {
|
|
1371
|
+
const cachedModulePath = compiledModuleCache.get(sourcePath);
|
|
1372
|
+
if (cachedModulePath) {
|
|
1373
|
+
return cachedModulePath;
|
|
1578
1374
|
}
|
|
1579
|
-
const
|
|
1580
|
-
const
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
const fileLanguage = getStyleLanguage(filePath);
|
|
1595
|
-
if (fileLanguage !== "scss" && fileLanguage !== "sass" && fileLanguage !== null)
|
|
1375
|
+
const resolutionSourcePath = await resolveOriginalSourcePath(sourcePath);
|
|
1376
|
+
const source = await Bun.file(sourcePath).text();
|
|
1377
|
+
const { compile, preprocess } = await import("svelte/compiler");
|
|
1378
|
+
const loweredAwaitSource = lowerSvelteAwaitSlotSyntax(source);
|
|
1379
|
+
const loweredSource = lowerSvelteIslandSyntax(loweredAwaitSource.code, "server");
|
|
1380
|
+
const preprocessed = await preprocess(loweredSource.code, createSvelteStylePreprocessor());
|
|
1381
|
+
let transpiled = sourcePath.endsWith(".ts") || sourcePath.endsWith(".svelte.ts") ? transpiler.transformSync(preprocessed.code) : preprocessed.code;
|
|
1382
|
+
const childImportSpecs = Array.from(transpiled.matchAll(/from\s+['"]([^'"]+)['"]/g)).map((match) => match[1]).filter((value) => value !== undefined);
|
|
1383
|
+
const resolvedChildModules = await Promise.all(childImportSpecs.map((spec) => resolveSvelteImport(spec, resolutionSourcePath)));
|
|
1384
|
+
const resolvedModuleImports = await Promise.all(childImportSpecs.map((spec) => resolveRelativeModule(spec, resolutionSourcePath)));
|
|
1385
|
+
const childModulePaths = new Map;
|
|
1386
|
+
const rewrittenModulePaths = new Map;
|
|
1387
|
+
const compiledChildren = await Promise.all(childImportSpecs.map(async (spec, index) => {
|
|
1388
|
+
const resolvedChild = resolvedChildModules[index];
|
|
1389
|
+
if (!spec || !resolvedChild)
|
|
1596
1390
|
return null;
|
|
1597
1391
|
return {
|
|
1598
|
-
|
|
1599
|
-
|
|
1392
|
+
compiledPath: await compileSvelteServerModule(resolvedChild),
|
|
1393
|
+
resolvedChild,
|
|
1394
|
+
spec
|
|
1600
1395
|
};
|
|
1396
|
+
}));
|
|
1397
|
+
for (const result of compiledChildren) {
|
|
1398
|
+
if (!result)
|
|
1399
|
+
continue;
|
|
1400
|
+
childModulePaths.set(result.spec, result.compiledPath);
|
|
1401
|
+
childModulePaths.set(result.resolvedChild, result.compiledPath);
|
|
1601
1402
|
}
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
const
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
throw new Error(`Unable to resolve Less import "${filename}"`);
|
|
1611
|
-
}
|
|
1612
|
-
return {
|
|
1613
|
-
contents: preprocessLoadedStyle(await readFile(resolved, "utf-8"), resolved, entryFile, loadPaths, "less", config),
|
|
1614
|
-
filename: resolved
|
|
1615
|
-
};
|
|
1616
|
-
};
|
|
1617
|
-
pluginManager.addFileManager(manager);
|
|
1618
|
-
}
|
|
1619
|
-
}), renderStylus = async (contents, filePath, loadPaths, options) => {
|
|
1620
|
-
let stylus;
|
|
1621
|
-
try {
|
|
1622
|
-
const stylusModule = await importOptionalPeer("stylus");
|
|
1623
|
-
stylus = stylusModule.default ?? stylusModule;
|
|
1624
|
-
} catch {
|
|
1625
|
-
throw missingDependencyError("stylus", filePath);
|
|
1626
|
-
}
|
|
1627
|
-
return new Promise((resolveCss, reject) => {
|
|
1628
|
-
const renderer = stylus(contents);
|
|
1629
|
-
renderer.set("filename", filePath);
|
|
1630
|
-
for (const [key, value] of Object.entries(options.options ?? {})) {
|
|
1631
|
-
renderer.set(key, value);
|
|
1632
|
-
}
|
|
1633
|
-
for (const path of loadPaths)
|
|
1634
|
-
renderer.include(path);
|
|
1635
|
-
renderer.render((error, css) => {
|
|
1636
|
-
if (error)
|
|
1637
|
-
reject(error);
|
|
1638
|
-
else
|
|
1639
|
-
resolveCss(css ?? "");
|
|
1640
|
-
});
|
|
1641
|
-
});
|
|
1642
|
-
}, compileStyleSource = async (filePath, source, languageHint, config) => {
|
|
1643
|
-
const language = getStyleLanguage(languageHint ?? filePath);
|
|
1644
|
-
const rawContents = source ?? await readFile(filePath, "utf-8");
|
|
1645
|
-
if (language === "scss" || language === "sass") {
|
|
1646
|
-
const options = getSassOptions(config, language);
|
|
1647
|
-
const packageName = options.implementation ?? "sass";
|
|
1648
|
-
let sass;
|
|
1649
|
-
try {
|
|
1650
|
-
sass = await importOptionalPeer(packageName);
|
|
1651
|
-
} catch {
|
|
1652
|
-
throw missingDependencyError(packageName, filePath);
|
|
1653
|
-
}
|
|
1654
|
-
const contents = withAdditionalData(rawContents, options.additionalData);
|
|
1655
|
-
const loadPaths = normalizeLoadPaths(filePath, options.loadPaths);
|
|
1656
|
-
const result = sass.compileString(contents, {
|
|
1657
|
-
importers: [
|
|
1658
|
-
createSassImporter(filePath, loadPaths, language, config)
|
|
1659
|
-
],
|
|
1660
|
-
loadPaths,
|
|
1661
|
-
style: "expanded",
|
|
1662
|
-
syntax: language === "sass" ? "indented" : "scss",
|
|
1663
|
-
url: new URL(`file://${filePath}`)
|
|
1664
|
-
});
|
|
1665
|
-
return runPostcss(result.css, filePath, config);
|
|
1666
|
-
}
|
|
1667
|
-
if (language === "less") {
|
|
1668
|
-
const options = getLessOptions(config);
|
|
1669
|
-
let lessModule;
|
|
1670
|
-
try {
|
|
1671
|
-
lessModule = await importOptionalPeer("less");
|
|
1672
|
-
} catch {
|
|
1673
|
-
throw missingDependencyError("less", filePath);
|
|
1674
|
-
}
|
|
1675
|
-
const less = lessModule.render ? lessModule : lessModule.default;
|
|
1676
|
-
const render = less?.render;
|
|
1677
|
-
if (!render)
|
|
1678
|
-
throw missingDependencyError("less", filePath);
|
|
1679
|
-
const contents = withAdditionalData(rawContents, options.additionalData);
|
|
1680
|
-
const loadPaths = normalizeLoadPaths(filePath, options.paths);
|
|
1681
|
-
const result = await render(contents, {
|
|
1682
|
-
...options.options ?? {},
|
|
1683
|
-
filename: filePath,
|
|
1684
|
-
paths: loadPaths,
|
|
1685
|
-
plugins: [
|
|
1686
|
-
...options.options?.plugins ?? [],
|
|
1687
|
-
createLessFileManager(filePath, loadPaths, config)
|
|
1688
|
-
]
|
|
1689
|
-
});
|
|
1690
|
-
return runPostcss(result.css, filePath, config);
|
|
1691
|
-
}
|
|
1692
|
-
if (language === "stylus") {
|
|
1693
|
-
const options = getStylusOptions(config);
|
|
1694
|
-
const loadPaths = normalizeLoadPaths(filePath, options.paths);
|
|
1695
|
-
const contents = withAdditionalData(preprocessLoadedStyle(rawContents, filePath, filePath, loadPaths, "stylus", config), options.additionalData);
|
|
1696
|
-
return runPostcss(await renderStylus(contents, filePath, loadPaths, options), filePath, config);
|
|
1697
|
-
}
|
|
1698
|
-
return runPostcss(rawContents, filePath, config);
|
|
1699
|
-
}, createStylePreprocessorPlugin = (config) => ({
|
|
1700
|
-
name: "absolute-style-preprocessor",
|
|
1701
|
-
setup(build) {
|
|
1702
|
-
const cssModuleSources = new Map;
|
|
1703
|
-
build.onResolve({ filter: /^absolute-style-module:/ }, ({ path }) => ({
|
|
1704
|
-
namespace: "absolute-style-module",
|
|
1705
|
-
path: path.slice("absolute-style-module:".length)
|
|
1706
|
-
}));
|
|
1707
|
-
build.onLoad({ filter: /\.module\.css$/i, namespace: "absolute-style-module" }, async ({ path }) => {
|
|
1708
|
-
const source = cssModuleSources.get(path);
|
|
1709
|
-
if (!source) {
|
|
1710
|
-
throw new Error(`Unable to resolve CSS module source for ${path}`);
|
|
1711
|
-
}
|
|
1712
|
-
return {
|
|
1713
|
-
contents: source.css,
|
|
1714
|
-
loader: "css"
|
|
1715
|
-
};
|
|
1716
|
-
});
|
|
1717
|
-
build.onLoad({ filter: STYLE_EXTENSION_PATTERN }, async ({ path }) => {
|
|
1718
|
-
if (isStyleModulePath(path)) {
|
|
1719
|
-
const cssModulePath = path.replace(STYLE_EXTENSION_PATTERN, ".css");
|
|
1720
|
-
const compiled = await compileStyleSource(path, undefined, undefined, config);
|
|
1721
|
-
const { css, exports } = extractCssModuleExports(compiled);
|
|
1722
|
-
cssModuleSources.set(cssModulePath, { css, exports });
|
|
1723
|
-
const exportSource = Object.keys(exports).length > 0 ? `import styles from ${JSON.stringify(`absolute-style-module:${cssModulePath}`)}; export default Object.assign({}, styles, ${JSON.stringify(exports)});` : `export { default } from ${JSON.stringify(`absolute-style-module:${cssModulePath}`)};`;
|
|
1724
|
-
return {
|
|
1725
|
-
contents: exportSource,
|
|
1726
|
-
loader: "js"
|
|
1727
|
-
};
|
|
1728
|
-
}
|
|
1729
|
-
return {
|
|
1730
|
-
contents: await compileStyleSource(path, undefined, undefined, config),
|
|
1731
|
-
loader: "css"
|
|
1732
|
-
};
|
|
1733
|
-
});
|
|
1734
|
-
build.onLoad({ filter: CSS_EXTENSION_PATTERN }, async ({ path }) => ({
|
|
1735
|
-
contents: await compileStyleSource(path, undefined, undefined, config),
|
|
1736
|
-
loader: "css"
|
|
1737
|
-
}));
|
|
1403
|
+
for (let index = 0;index < childImportSpecs.length; index += 1) {
|
|
1404
|
+
const spec = childImportSpecs[index];
|
|
1405
|
+
const resolvedModuleImport = resolvedModuleImports[index];
|
|
1406
|
+
if (!spec || !resolvedModuleImport)
|
|
1407
|
+
continue;
|
|
1408
|
+
if (resolvedChildModules[index])
|
|
1409
|
+
continue;
|
|
1410
|
+
rewrittenModulePaths.set(spec, ensureRelativeImportPath(getCachedModulePath(sourcePath), resolvedModuleImport));
|
|
1738
1411
|
}
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
attributes,
|
|
1742
|
-
content,
|
|
1743
|
-
filename
|
|
1744
|
-
}) => {
|
|
1745
|
-
const language = typeof attributes.lang === "string" ? attributes.lang : typeof attributes.type === "string" ? attributes.type.replace(/^text\//, "") : null;
|
|
1746
|
-
if (!language || !STYLE_LANGUAGE_PATTERN.test(language))
|
|
1747
|
-
return;
|
|
1748
|
-
const path = filename ?? `style.${language}`;
|
|
1749
|
-
return {
|
|
1750
|
-
code: await compileStyleSource(path, content, language, config)
|
|
1751
|
-
};
|
|
1412
|
+
for (const [spec, resolvedModuleImport] of rewrittenModulePaths) {
|
|
1413
|
+
transpiled = transpiled.replaceAll(spec, resolvedModuleImport);
|
|
1752
1414
|
}
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1415
|
+
let compiledCode = compile(transpiled, {
|
|
1416
|
+
css: "injected",
|
|
1417
|
+
experimental: {
|
|
1418
|
+
async: loweredAwaitSource.transformed || loweredSource.transformed
|
|
1419
|
+
},
|
|
1420
|
+
filename: resolutionSourcePath,
|
|
1421
|
+
generate: "server"
|
|
1422
|
+
}).js.code;
|
|
1423
|
+
for (const [spec, compiledChildPath] of childModulePaths) {
|
|
1424
|
+
compiledCode = compiledCode.replaceAll(spec, ensureRelativeImportPath(getCachedModulePath(sourcePath), compiledChildPath));
|
|
1756
1425
|
}
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
const rawContents = readFileSync3(filePath, "utf-8");
|
|
1760
|
-
const language = getStyleLanguage(filePath);
|
|
1761
|
-
if (config?.postcss) {
|
|
1762
|
-
throw new Error(`Unable to compile ${filePath}: PostCSS preprocessing is async-only.`);
|
|
1426
|
+
for (const [spec, resolvedModuleImport] of rewrittenModulePaths) {
|
|
1427
|
+
compiledCode = compiledCode.replaceAll(spec, resolvedModuleImport);
|
|
1763
1428
|
}
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1429
|
+
const compiledModulePath = getCachedModulePath(sourcePath);
|
|
1430
|
+
await mkdir(dirname3(compiledModulePath), { recursive: true });
|
|
1431
|
+
await writeIfChanged(compiledModulePath, compiledCode);
|
|
1432
|
+
compiledModuleCache.set(sourcePath, compiledModulePath);
|
|
1433
|
+
return compiledModulePath;
|
|
1434
|
+
};
|
|
1435
|
+
var init_svelteServerModule = __esm(() => {
|
|
1436
|
+
init_resolvePackageImport();
|
|
1437
|
+
init_lowerIslandSyntax();
|
|
1438
|
+
init_lowerAwaitSlotSyntax();
|
|
1439
|
+
init_stylePreprocessor();
|
|
1440
|
+
serverCacheRoot = join4(process.cwd(), ".absolutejs", "islands", "svelte");
|
|
1441
|
+
compiledModuleCache = new Map;
|
|
1442
|
+
originalSourcePathCache = new Map;
|
|
1443
|
+
transpiler = new Bun.Transpiler({
|
|
1444
|
+
loader: "ts",
|
|
1445
|
+
target: "browser"
|
|
1446
|
+
});
|
|
1447
|
+
});
|
|
1448
|
+
|
|
1449
|
+
// src/core/islandManifest.ts
|
|
1450
|
+
var toIslandFrameworkSegment = (framework) => framework[0]?.toUpperCase() + framework.slice(1), collectFrameworkIslands = (manifest, prefix) => {
|
|
1451
|
+
const entries = {};
|
|
1452
|
+
let found = false;
|
|
1453
|
+
for (const [key, value] of Object.entries(manifest)) {
|
|
1454
|
+
if (!key.startsWith(prefix))
|
|
1455
|
+
continue;
|
|
1456
|
+
const component = key.slice(prefix.length);
|
|
1457
|
+
if (!component)
|
|
1458
|
+
continue;
|
|
1459
|
+
entries[component] = value;
|
|
1460
|
+
found = true;
|
|
1784
1461
|
}
|
|
1785
|
-
|
|
1786
|
-
|
|
1462
|
+
return found ? entries : undefined;
|
|
1463
|
+
}, getIslandManifestEntries = (manifest) => {
|
|
1464
|
+
const islands = {};
|
|
1465
|
+
const frameworks = ["react", "svelte", "vue", "angular"];
|
|
1466
|
+
for (const framework of frameworks) {
|
|
1467
|
+
const prefix = `Island${toIslandFrameworkSegment(framework)}`;
|
|
1468
|
+
const entries = collectFrameworkIslands(manifest, prefix);
|
|
1469
|
+
if (entries)
|
|
1470
|
+
islands[framework] = entries;
|
|
1787
1471
|
}
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
STYLE_EXTENSION_PATTERN = /\.(s[ac]ss|less|styl(?:us)?)$/i;
|
|
1796
|
-
STYLE_MODULE_EXTENSION_PATTERN = /\.module\.(s[ac]ss|less|styl(?:us)?)$/i;
|
|
1797
|
-
STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less|styl(?:us)?)$/i;
|
|
1798
|
-
importOptionalPeer = new Function("specifier", "return import(specifier)");
|
|
1799
|
-
requireOptionalPeer = new Function("specifier", "return require(specifier)");
|
|
1800
|
-
requireFromCwd = createRequire(join3(process.cwd(), "package.json"));
|
|
1801
|
-
stylePreprocessorPlugin = createStylePreprocessorPlugin();
|
|
1802
|
-
});
|
|
1803
|
-
|
|
1804
|
-
// src/core/svelteServerModule.ts
|
|
1805
|
-
import { mkdir, readdir } from "fs/promises";
|
|
1806
|
-
import { basename as basename2, dirname as dirname3, extname as extname2, join as join4, relative as relative2, resolve as resolve5 } from "path";
|
|
1807
|
-
var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, ensureRelativeImportPath = (from, target) => {
|
|
1808
|
-
const importPath = relative2(dirname3(from), target).replace(/\\/g, "/");
|
|
1809
|
-
return importPath.startsWith(".") ? importPath : `./${importPath}`;
|
|
1810
|
-
}, processDirectoryEntries = (entries, dir, targetFileName, stack) => {
|
|
1811
|
-
for (const entry of entries) {
|
|
1812
|
-
const entryPath = join4(dir, entry.name);
|
|
1813
|
-
if (entry.isDirectory())
|
|
1814
|
-
stack.push(entryPath);
|
|
1815
|
-
if (entry.isFile() && entry.name === targetFileName) {
|
|
1816
|
-
return entryPath;
|
|
1817
|
-
}
|
|
1818
|
-
}
|
|
1819
|
-
return null;
|
|
1820
|
-
}, searchDirectoryLevel = async (dirs, targetFileName) => {
|
|
1821
|
-
if (dirs.length === 0)
|
|
1822
|
-
return null;
|
|
1823
|
-
const nextStack = [];
|
|
1824
|
-
const dirEntries = await Promise.all(dirs.map(async (dir) => ({
|
|
1825
|
-
dir,
|
|
1826
|
-
entries: await readdir(dir, {
|
|
1827
|
-
encoding: "utf-8",
|
|
1828
|
-
withFileTypes: true
|
|
1829
|
-
})
|
|
1830
|
-
})));
|
|
1831
|
-
for (const { dir, entries } of dirEntries) {
|
|
1832
|
-
const found = processDirectoryEntries(entries, dir, targetFileName, nextStack);
|
|
1833
|
-
if (found)
|
|
1834
|
-
return found;
|
|
1835
|
-
}
|
|
1836
|
-
return searchDirectoryLevel(nextStack, targetFileName);
|
|
1837
|
-
}, findSourceFileByBasename = async (searchRoot, targetFileName) => searchDirectoryLevel([searchRoot], targetFileName), normalizeBuiltSvelteFileName = (sourcePath) => basename2(sourcePath).replace(/-[a-z0-9]{6,}(?=\.svelte$)/i, ""), resolveOriginalSourcePath = async (sourcePath) => {
|
|
1838
|
-
const cachedPath = originalSourcePathCache.get(sourcePath);
|
|
1839
|
-
if (cachedPath !== undefined) {
|
|
1840
|
-
return cachedPath;
|
|
1841
|
-
}
|
|
1842
|
-
if (!sourcePath.includes(`${join4(process.cwd(), "build")}${process.platform === "win32" ? "" : "/"}`) && !sourcePath.includes("/build/")) {
|
|
1843
|
-
originalSourcePathCache.set(sourcePath, sourcePath);
|
|
1844
|
-
return sourcePath;
|
|
1845
|
-
}
|
|
1846
|
-
const resolvedSourcePath = await findSourceFileByBasename(join4(process.cwd(), "src"), normalizeBuiltSvelteFileName(sourcePath));
|
|
1847
|
-
const nextPath = resolvedSourcePath ?? sourcePath;
|
|
1848
|
-
originalSourcePathCache.set(sourcePath, nextPath);
|
|
1849
|
-
return nextPath;
|
|
1850
|
-
}, resolveRelativeModule = async (spec, from) => {
|
|
1851
|
-
if (!spec.startsWith(".")) {
|
|
1852
|
-
return null;
|
|
1853
|
-
}
|
|
1854
|
-
const basePath = resolve5(dirname3(from), spec);
|
|
1855
|
-
const candidates = [
|
|
1856
|
-
basePath,
|
|
1857
|
-
`${basePath}.ts`,
|
|
1858
|
-
`${basePath}.js`,
|
|
1859
|
-
`${basePath}.mjs`,
|
|
1860
|
-
`${basePath}.cjs`,
|
|
1861
|
-
`${basePath}.json`,
|
|
1862
|
-
join4(basePath, "index.ts"),
|
|
1863
|
-
join4(basePath, "index.js"),
|
|
1864
|
-
join4(basePath, "index.mjs"),
|
|
1865
|
-
join4(basePath, "index.cjs"),
|
|
1866
|
-
join4(basePath, "index.json")
|
|
1867
|
-
];
|
|
1868
|
-
const existResults = await Promise.all(candidates.map((candidate) => Bun.file(candidate).exists()));
|
|
1869
|
-
const foundIndex = existResults.indexOf(true);
|
|
1870
|
-
return foundIndex >= 0 ? candidates[foundIndex] ?? null : null;
|
|
1871
|
-
}, getCachedModulePath = (sourcePath) => {
|
|
1872
|
-
const relativeSourcePath = relative2(process.cwd(), sourcePath).replace(/\\/g, "/");
|
|
1873
|
-
const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
|
|
1874
|
-
return join4(serverCacheRoot, `${normalizedSourcePath}.server.js`);
|
|
1875
|
-
}, resolveSvelteImport = async (spec, from) => {
|
|
1876
|
-
if (!spec.startsWith(".") && !spec.startsWith("/")) {
|
|
1877
|
-
const resolved = resolvePackageImport(spec);
|
|
1878
|
-
return resolved && resolved.endsWith(".svelte") ? resolved : null;
|
|
1879
|
-
}
|
|
1880
|
-
if (spec.startsWith("/")) {
|
|
1881
|
-
return spec;
|
|
1882
|
-
}
|
|
1883
|
-
if (!spec.startsWith(".")) {
|
|
1884
|
-
return null;
|
|
1885
|
-
}
|
|
1886
|
-
const explicitPath = resolve5(dirname3(from), spec);
|
|
1887
|
-
if (extname2(explicitPath) === ".svelte") {
|
|
1888
|
-
return explicitPath;
|
|
1889
|
-
}
|
|
1890
|
-
const candidate = `${explicitPath}.svelte`;
|
|
1891
|
-
if (await Bun.file(candidate).exists() === true) {
|
|
1892
|
-
return candidate;
|
|
1893
|
-
}
|
|
1894
|
-
return null;
|
|
1895
|
-
}, writeIfChanged = async (path, content) => {
|
|
1896
|
-
const targetFile = Bun.file(path);
|
|
1897
|
-
const exists = await targetFile.exists();
|
|
1898
|
-
if (exists) {
|
|
1899
|
-
const currentContent = await targetFile.text();
|
|
1900
|
-
if (currentContent === content) {
|
|
1901
|
-
return;
|
|
1902
|
-
}
|
|
1903
|
-
}
|
|
1904
|
-
await Bun.write(path, content);
|
|
1905
|
-
}, compileSvelteServerModule = async (sourcePath) => {
|
|
1906
|
-
const cachedModulePath = compiledModuleCache.get(sourcePath);
|
|
1907
|
-
if (cachedModulePath) {
|
|
1908
|
-
return cachedModulePath;
|
|
1909
|
-
}
|
|
1910
|
-
const resolutionSourcePath = await resolveOriginalSourcePath(sourcePath);
|
|
1911
|
-
const source = await Bun.file(sourcePath).text();
|
|
1912
|
-
const { compile, preprocess } = await import("svelte/compiler");
|
|
1913
|
-
const loweredAwaitSource = lowerSvelteAwaitSlotSyntax(source);
|
|
1914
|
-
const loweredSource = lowerSvelteIslandSyntax(loweredAwaitSource.code, "server");
|
|
1915
|
-
const preprocessed = await preprocess(loweredSource.code, createSvelteStylePreprocessor());
|
|
1916
|
-
let transpiled = sourcePath.endsWith(".ts") || sourcePath.endsWith(".svelte.ts") ? transpiler.transformSync(preprocessed.code) : preprocessed.code;
|
|
1917
|
-
const childImportSpecs = Array.from(transpiled.matchAll(/from\s+['"]([^'"]+)['"]/g)).map((match) => match[1]).filter((value) => value !== undefined);
|
|
1918
|
-
const resolvedChildModules = await Promise.all(childImportSpecs.map((spec) => resolveSvelteImport(spec, resolutionSourcePath)));
|
|
1919
|
-
const resolvedModuleImports = await Promise.all(childImportSpecs.map((spec) => resolveRelativeModule(spec, resolutionSourcePath)));
|
|
1920
|
-
const childModulePaths = new Map;
|
|
1921
|
-
const rewrittenModulePaths = new Map;
|
|
1922
|
-
const compiledChildren = await Promise.all(childImportSpecs.map(async (spec, index) => {
|
|
1923
|
-
const resolvedChild = resolvedChildModules[index];
|
|
1924
|
-
if (!spec || !resolvedChild)
|
|
1925
|
-
return null;
|
|
1926
|
-
return {
|
|
1927
|
-
compiledPath: await compileSvelteServerModule(resolvedChild),
|
|
1928
|
-
resolvedChild,
|
|
1929
|
-
spec
|
|
1930
|
-
};
|
|
1931
|
-
}));
|
|
1932
|
-
for (const result of compiledChildren) {
|
|
1933
|
-
if (!result)
|
|
1934
|
-
continue;
|
|
1935
|
-
childModulePaths.set(result.spec, result.compiledPath);
|
|
1936
|
-
childModulePaths.set(result.resolvedChild, result.compiledPath);
|
|
1937
|
-
}
|
|
1938
|
-
for (let index = 0;index < childImportSpecs.length; index += 1) {
|
|
1939
|
-
const spec = childImportSpecs[index];
|
|
1940
|
-
const resolvedModuleImport = resolvedModuleImports[index];
|
|
1941
|
-
if (!spec || !resolvedModuleImport)
|
|
1942
|
-
continue;
|
|
1943
|
-
if (resolvedChildModules[index])
|
|
1944
|
-
continue;
|
|
1945
|
-
rewrittenModulePaths.set(spec, ensureRelativeImportPath(getCachedModulePath(sourcePath), resolvedModuleImport));
|
|
1946
|
-
}
|
|
1947
|
-
for (const [spec, resolvedModuleImport] of rewrittenModulePaths) {
|
|
1948
|
-
transpiled = transpiled.replaceAll(spec, resolvedModuleImport);
|
|
1949
|
-
}
|
|
1950
|
-
let compiledCode = compile(transpiled, {
|
|
1951
|
-
css: "injected",
|
|
1952
|
-
experimental: {
|
|
1953
|
-
async: loweredAwaitSource.transformed || loweredSource.transformed
|
|
1954
|
-
},
|
|
1955
|
-
filename: resolutionSourcePath,
|
|
1956
|
-
generate: "server"
|
|
1957
|
-
}).js.code;
|
|
1958
|
-
for (const [spec, compiledChildPath] of childModulePaths) {
|
|
1959
|
-
compiledCode = compiledCode.replaceAll(spec, ensureRelativeImportPath(getCachedModulePath(sourcePath), compiledChildPath));
|
|
1960
|
-
}
|
|
1961
|
-
for (const [spec, resolvedModuleImport] of rewrittenModulePaths) {
|
|
1962
|
-
compiledCode = compiledCode.replaceAll(spec, resolvedModuleImport);
|
|
1963
|
-
}
|
|
1964
|
-
const compiledModulePath = getCachedModulePath(sourcePath);
|
|
1965
|
-
await mkdir(dirname3(compiledModulePath), { recursive: true });
|
|
1966
|
-
await writeIfChanged(compiledModulePath, compiledCode);
|
|
1967
|
-
compiledModuleCache.set(sourcePath, compiledModulePath);
|
|
1968
|
-
return compiledModulePath;
|
|
1969
|
-
};
|
|
1970
|
-
var init_svelteServerModule = __esm(() => {
|
|
1971
|
-
init_resolvePackageImport();
|
|
1972
|
-
init_lowerIslandSyntax();
|
|
1973
|
-
init_lowerAwaitSlotSyntax();
|
|
1974
|
-
init_stylePreprocessor();
|
|
1975
|
-
serverCacheRoot = join4(process.cwd(), ".absolutejs", "islands", "svelte");
|
|
1976
|
-
compiledModuleCache = new Map;
|
|
1977
|
-
originalSourcePathCache = new Map;
|
|
1978
|
-
transpiler = new Bun.Transpiler({
|
|
1979
|
-
loader: "ts",
|
|
1980
|
-
target: "browser"
|
|
1981
|
-
});
|
|
1982
|
-
});
|
|
1983
|
-
|
|
1984
|
-
// src/core/islandManifest.ts
|
|
1985
|
-
var toIslandFrameworkSegment = (framework) => framework[0]?.toUpperCase() + framework.slice(1), collectFrameworkIslands = (manifest, prefix) => {
|
|
1986
|
-
const entries = {};
|
|
1987
|
-
let found = false;
|
|
1988
|
-
for (const [key, value] of Object.entries(manifest)) {
|
|
1989
|
-
if (!key.startsWith(prefix))
|
|
1990
|
-
continue;
|
|
1991
|
-
const component = key.slice(prefix.length);
|
|
1992
|
-
if (!component)
|
|
1993
|
-
continue;
|
|
1994
|
-
entries[component] = value;
|
|
1995
|
-
found = true;
|
|
1996
|
-
}
|
|
1997
|
-
return found ? entries : undefined;
|
|
1998
|
-
}, getIslandManifestEntries = (manifest) => {
|
|
1999
|
-
const islands = {};
|
|
2000
|
-
const frameworks = ["react", "svelte", "vue", "angular"];
|
|
2001
|
-
for (const framework of frameworks) {
|
|
2002
|
-
const prefix = `Island${toIslandFrameworkSegment(framework)}`;
|
|
2003
|
-
const entries = collectFrameworkIslands(manifest, prefix);
|
|
2004
|
-
if (entries)
|
|
2005
|
-
islands[framework] = entries;
|
|
2006
|
-
}
|
|
2007
|
-
return islands;
|
|
2008
|
-
}, getIslandManifestKey = (framework, component) => `Island${toIslandFrameworkSegment(framework)}${component}`;
|
|
2009
|
-
|
|
2010
|
-
// src/core/islands.ts
|
|
2011
|
-
function getIslandComponent(component) {
|
|
2012
|
-
if (isIslandComponentDefinition(component)) {
|
|
2013
|
-
return component.component;
|
|
1472
|
+
return islands;
|
|
1473
|
+
}, getIslandManifestKey = (framework, component) => `Island${toIslandFrameworkSegment(framework)}${component}`;
|
|
1474
|
+
|
|
1475
|
+
// src/core/islands.ts
|
|
1476
|
+
function getIslandComponent(component) {
|
|
1477
|
+
if (isIslandComponentDefinition(component)) {
|
|
1478
|
+
return component.component;
|
|
2014
1479
|
}
|
|
2015
1480
|
return component;
|
|
2016
1481
|
}
|
|
@@ -2173,102 +1638,24 @@ var init_renderIslandMarkup = __esm(() => {
|
|
|
2173
1638
|
resolvedServerBuildComponentCache = new Map;
|
|
2174
1639
|
});
|
|
2175
1640
|
|
|
2176
|
-
// src/
|
|
2177
|
-
var
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
1641
|
+
// src/core/devRouteRegistrationCallsite.ts
|
|
1642
|
+
var exports_devRouteRegistrationCallsite = {};
|
|
1643
|
+
__export(exports_devRouteRegistrationCallsite, {
|
|
1644
|
+
patchElysiaRouteRegistrationCallsites: () => patchElysiaRouteRegistrationCallsites,
|
|
1645
|
+
getCurrentRouteRegistrationCallsite: () => getCurrentRouteRegistrationCallsite
|
|
1646
|
+
});
|
|
1647
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
1648
|
+
import { Elysia } from "elysia";
|
|
1649
|
+
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 = () => {
|
|
1650
|
+
const value = Reflect.get(globalThis, ROUTE_CALLSITE_STORAGE_KEY);
|
|
1651
|
+
if (value === null || typeof value === "undefined") {
|
|
1652
|
+
return;
|
|
2186
1653
|
}
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
const framework = attributes.get("framework");
|
|
2193
|
-
const hydrate = attributes.get("hydrate") ?? "load";
|
|
2194
|
-
const serializedProps = attributes.get("data-abs-props") ?? "{}";
|
|
2195
|
-
if (!component || !framework) {
|
|
2196
|
-
return null;
|
|
2197
|
-
}
|
|
2198
|
-
if (!isIslandFramework(framework) || !isIslandHydrate(hydrate)) {
|
|
2199
|
-
return null;
|
|
2200
|
-
}
|
|
2201
|
-
let parsedProps = {};
|
|
2202
|
-
try {
|
|
2203
|
-
const candidate = JSON.parse(serializedProps);
|
|
2204
|
-
parsedProps = isRecord3(candidate) ? candidate : {};
|
|
2205
|
-
} catch {}
|
|
2206
|
-
return {
|
|
2207
|
-
component,
|
|
2208
|
-
framework,
|
|
2209
|
-
hydrate,
|
|
2210
|
-
props: parsedProps
|
|
2211
|
-
};
|
|
2212
|
-
}, lowerAngularServerIslands = async (html) => {
|
|
2213
|
-
if (!ANGULAR_ISLAND_TAG_RE.test(html)) {
|
|
2214
|
-
return html;
|
|
2215
|
-
}
|
|
2216
|
-
const registry = requireCurrentIslandRegistry();
|
|
2217
|
-
ANGULAR_ISLAND_TAG_RE.lastIndex = 0;
|
|
2218
|
-
const segments = [];
|
|
2219
|
-
let lastIndex = 0;
|
|
2220
|
-
let match = ANGULAR_ISLAND_TAG_RE.exec(html);
|
|
2221
|
-
while (match) {
|
|
2222
|
-
const [fullMatch, rawAttributeString] = match;
|
|
2223
|
-
const attributeString = rawAttributeString ?? "";
|
|
2224
|
-
segments.push({
|
|
2225
|
-
before: html.slice(lastIndex, match.index),
|
|
2226
|
-
fullMatch,
|
|
2227
|
-
props: parseAngularIslandProps(attributeString)
|
|
2228
|
-
});
|
|
2229
|
-
lastIndex = match.index + fullMatch.length;
|
|
2230
|
-
match = ANGULAR_ISLAND_TAG_RE.exec(html);
|
|
2231
|
-
}
|
|
2232
|
-
ANGULAR_ISLAND_TAG_RE.lastIndex = 0;
|
|
2233
|
-
const renderedSegments = await Promise.all(segments.map(async (segment) => segment.before + (segment.props ? await renderIslandMarkup(registry, segment.props) : segment.fullMatch)));
|
|
2234
|
-
return renderedSegments.join("") + html.slice(lastIndex);
|
|
2235
|
-
};
|
|
2236
|
-
var init_lowerServerIslands = __esm(() => {
|
|
2237
|
-
init_renderIslandMarkup();
|
|
2238
|
-
ANGULAR_ISLAND_TAG_RE = /<absolute-island\b([^>]*)>[\s\S]*?<\/absolute-island>/gi;
|
|
2239
|
-
ATTRIBUTE_RE = /([A-Za-z_:][-A-Za-z0-9_:.]*)\s*=\s*(?:"([^"]*)"|'([^']*)')/g;
|
|
2240
|
-
islandFrameworks = [
|
|
2241
|
-
"react",
|
|
2242
|
-
"svelte",
|
|
2243
|
-
"vue",
|
|
2244
|
-
"angular"
|
|
2245
|
-
];
|
|
2246
|
-
islandHydrationModes = [
|
|
2247
|
-
"load",
|
|
2248
|
-
"idle",
|
|
2249
|
-
"visible",
|
|
2250
|
-
"none"
|
|
2251
|
-
];
|
|
2252
|
-
});
|
|
2253
|
-
|
|
2254
|
-
// src/core/devRouteRegistrationCallsite.ts
|
|
2255
|
-
var exports_devRouteRegistrationCallsite = {};
|
|
2256
|
-
__export(exports_devRouteRegistrationCallsite, {
|
|
2257
|
-
patchElysiaRouteRegistrationCallsites: () => patchElysiaRouteRegistrationCallsites,
|
|
2258
|
-
getCurrentRouteRegistrationCallsite: () => getCurrentRouteRegistrationCallsite
|
|
2259
|
-
});
|
|
2260
|
-
import { AsyncLocalStorage } from "async_hooks";
|
|
2261
|
-
import { Elysia } from "elysia";
|
|
2262
|
-
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 = () => {
|
|
2263
|
-
const value = Reflect.get(globalThis, ROUTE_CALLSITE_STORAGE_KEY);
|
|
2264
|
-
if (value === null || typeof value === "undefined") {
|
|
2265
|
-
return;
|
|
2266
|
-
}
|
|
2267
|
-
return isAsyncLocalStorage2(value) ? value : undefined;
|
|
2268
|
-
}, ensureRouteCallsiteStorage = () => {
|
|
2269
|
-
const existing = getRouteCallsiteStorage();
|
|
2270
|
-
if (existing) {
|
|
2271
|
-
return existing;
|
|
1654
|
+
return isAsyncLocalStorage2(value) ? value : undefined;
|
|
1655
|
+
}, ensureRouteCallsiteStorage = () => {
|
|
1656
|
+
const existing = getRouteCallsiteStorage();
|
|
1657
|
+
if (existing) {
|
|
1658
|
+
return existing;
|
|
2272
1659
|
}
|
|
2273
1660
|
const storage = new AsyncLocalStorage;
|
|
2274
1661
|
Reflect.set(globalThis, ROUTE_CALLSITE_STORAGE_KEY, storage);
|
|
@@ -2337,56 +1724,6 @@ var init_devRouteRegistrationCallsite = __esm(() => {
|
|
|
2337
1724
|
];
|
|
2338
1725
|
});
|
|
2339
1726
|
|
|
2340
|
-
// src/angular/ssrSanitizer.ts
|
|
2341
|
-
var escapeHtml = (str) => String(str).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """), bypassValue = (value) => ({
|
|
2342
|
-
changingThisBreaksApplicationSecurity: value
|
|
2343
|
-
}), ssrSanitizer = null, getSsrSanitizer = (deps) => {
|
|
2344
|
-
if (ssrSanitizer)
|
|
2345
|
-
return ssrSanitizer;
|
|
2346
|
-
const SsrSanitizerClass = class extends deps.DomSanitizer {
|
|
2347
|
-
sanitize(ctx, value) {
|
|
2348
|
-
if (value === null)
|
|
2349
|
-
return null;
|
|
2350
|
-
let strValue;
|
|
2351
|
-
let isTrustedHtml = false;
|
|
2352
|
-
if (typeof value === "string") {
|
|
2353
|
-
strValue = value;
|
|
2354
|
-
} else if (typeof value === "object" && "changingThisBreaksApplicationSecurity" in value) {
|
|
2355
|
-
strValue = String(value.changingThisBreaksApplicationSecurity);
|
|
2356
|
-
isTrustedHtml = true;
|
|
2357
|
-
} else {
|
|
2358
|
-
strValue = String(value);
|
|
2359
|
-
}
|
|
2360
|
-
if (ctx === deps.SecurityContext.HTML) {
|
|
2361
|
-
if (isTrustedHtml) {
|
|
2362
|
-
return strValue;
|
|
2363
|
-
}
|
|
2364
|
-
return escapeHtml(strValue);
|
|
2365
|
-
}
|
|
2366
|
-
return strValue;
|
|
2367
|
-
}
|
|
2368
|
-
bypassSecurityTrustHtml(value) {
|
|
2369
|
-
return bypassValue(value);
|
|
2370
|
-
}
|
|
2371
|
-
bypassSecurityTrustStyle(value) {
|
|
2372
|
-
return bypassValue(value);
|
|
2373
|
-
}
|
|
2374
|
-
bypassSecurityTrustScript(value) {
|
|
2375
|
-
return bypassValue(value);
|
|
2376
|
-
}
|
|
2377
|
-
bypassSecurityTrustUrl(value) {
|
|
2378
|
-
return bypassValue(value);
|
|
2379
|
-
}
|
|
2380
|
-
bypassSecurityTrustResourceUrl(value) {
|
|
2381
|
-
return bypassValue(value);
|
|
2382
|
-
}
|
|
2383
|
-
};
|
|
2384
|
-
ssrSanitizer = new SsrSanitizerClass;
|
|
2385
|
-
return ssrSanitizer;
|
|
2386
|
-
}, resetSsrSanitizer = () => {
|
|
2387
|
-
ssrSanitizer = null;
|
|
2388
|
-
};
|
|
2389
|
-
|
|
2390
1727
|
// src/client/streamSwap.ts
|
|
2391
1728
|
var streamSwapRuntime = () => {
|
|
2392
1729
|
const SLOT_PATCH_EVENT = "absolutejs:slot-patch";
|
|
@@ -3063,53 +2400,6 @@ var init_streamingSlots = __esm(() => {
|
|
|
3063
2400
|
};
|
|
3064
2401
|
});
|
|
3065
2402
|
|
|
3066
|
-
// src/core/responseEnhancers.ts
|
|
3067
|
-
var toResponse = async (responseLike) => responseLike, cloneHeaders = (response) => {
|
|
3068
|
-
const headers = new Headers(response.headers);
|
|
3069
|
-
return headers;
|
|
3070
|
-
}, enhanceHtmlResponseWithStreamingSlots = (response, {
|
|
3071
|
-
nonce,
|
|
3072
|
-
onError,
|
|
3073
|
-
runtimePlacement,
|
|
3074
|
-
runtimePreludeScript,
|
|
3075
|
-
streamingSlots = [],
|
|
3076
|
-
policy
|
|
3077
|
-
} = {}) => {
|
|
3078
|
-
if (!response.body || streamingSlots.length === 0) {
|
|
3079
|
-
return response;
|
|
3080
|
-
}
|
|
3081
|
-
const body = appendStreamingSlotPatchesToStream(response.body, streamingSlots, {
|
|
3082
|
-
nonce,
|
|
3083
|
-
onError,
|
|
3084
|
-
policy,
|
|
3085
|
-
runtimePlacement,
|
|
3086
|
-
runtimePreludeScript
|
|
3087
|
-
});
|
|
3088
|
-
return new Response(body, {
|
|
3089
|
-
headers: cloneHeaders(response),
|
|
3090
|
-
status: response.status,
|
|
3091
|
-
statusText: response.statusText
|
|
3092
|
-
});
|
|
3093
|
-
}, withStreamingSlots = async (responseLike, options = {}) => enhanceHtmlResponseWithStreamingSlots(await toResponse(responseLike), options), mergeStreamingSlots = (registered, explicit) => {
|
|
3094
|
-
const merged = new Map;
|
|
3095
|
-
for (const slot of registered)
|
|
3096
|
-
merged.set(slot.id, slot);
|
|
3097
|
-
for (const slot of explicit)
|
|
3098
|
-
merged.set(slot.id, slot);
|
|
3099
|
-
return [...merged.values()];
|
|
3100
|
-
}, withRegisteredStreamingSlots = async (renderResponse, options = {}) => {
|
|
3101
|
-
const { result, slots } = await runWithStreamingSlotRegistry(renderResponse);
|
|
3102
|
-
const explicit = options.streamingSlots ?? [];
|
|
3103
|
-
return withStreamingSlots(result, {
|
|
3104
|
-
...options,
|
|
3105
|
-
streamingSlots: mergeStreamingSlots(slots, explicit)
|
|
3106
|
-
});
|
|
3107
|
-
};
|
|
3108
|
-
var init_responseEnhancers = __esm(() => {
|
|
3109
|
-
init_streamingSlots();
|
|
3110
|
-
init_streamingSlotRegistry();
|
|
3111
|
-
});
|
|
3112
|
-
|
|
3113
2403
|
// src/utils/getDurationString.ts
|
|
3114
2404
|
var getDurationString = (duration) => {
|
|
3115
2405
|
let durationString;
|
|
@@ -3252,63 +2542,12 @@ var init_logger = __esm(() => {
|
|
|
3252
2542
|
};
|
|
3253
2543
|
});
|
|
3254
2544
|
|
|
3255
|
-
// src/core/
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
}
|
|
3262
|
-
return isAsyncLocalStorage3(value) ? value : undefined;
|
|
3263
|
-
}, ensureWarningStorage = () => {
|
|
3264
|
-
const existing = getWarningStorage();
|
|
3265
|
-
if (existing) {
|
|
3266
|
-
return existing;
|
|
3267
|
-
}
|
|
3268
|
-
const storage = new AsyncLocalStorage2;
|
|
3269
|
-
Reflect.set(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY2, storage);
|
|
3270
|
-
return storage;
|
|
3271
|
-
}, normalizeCallsitePath2 = (value) => value.replace(`${process.cwd()}/`, "").replace(process.cwd(), "").replace(/^\.\/+/, ""), formatWarningCallsite = (callsite) => {
|
|
3272
|
-
const match = callsite.match(/^(.*?)(:\d+:\d+)$/);
|
|
3273
|
-
if (!match) {
|
|
3274
|
-
return `\x1B[36m${callsite}\x1B[0m`;
|
|
3275
|
-
}
|
|
3276
|
-
return `\x1B[36m${match[1]}\x1B[33m${match[2]}\x1B[0m`;
|
|
3277
|
-
}, extractCallsiteFromStack = (stack) => {
|
|
3278
|
-
const frames = stack.split(`
|
|
3279
|
-
`).slice(1).map((line) => line.trim());
|
|
3280
|
-
for (const frame of frames) {
|
|
3281
|
-
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.")) {
|
|
3282
|
-
continue;
|
|
3283
|
-
}
|
|
3284
|
-
const locationMatch = frame.match(/\((\/[^)]+:\d+:\d+)\)$/) ?? frame.match(/at (\/[^ ]+:\d+:\d+)$/);
|
|
3285
|
-
if (locationMatch?.[1]) {
|
|
3286
|
-
return normalizeCallsitePath2(locationMatch[1]);
|
|
3287
|
-
}
|
|
3288
|
-
}
|
|
3289
|
-
return;
|
|
3290
|
-
}, 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 = () => {
|
|
3291
|
-
if (false) {}
|
|
3292
|
-
const { stack } = new Error;
|
|
3293
|
-
if (!stack) {
|
|
3294
|
-
return;
|
|
3295
|
-
}
|
|
3296
|
-
return extractCallsiteFromStack(stack);
|
|
3297
|
-
}, runWithStreamingSlotWarningScope = (task, metadata) => ensureWarningStorage().run({ handlerCallsite: metadata?.handlerCallsite, hasWarned: false }, task);
|
|
3298
|
-
var init_streamingSlotWarningScope = __esm(() => {
|
|
3299
|
-
init_logger();
|
|
3300
|
-
init_streamingSlotRegistrar();
|
|
3301
|
-
STREAMING_SLOT_WARNING_STORAGE_KEY2 = Symbol.for("absolutejs.streamingSlotWarningAsyncLocalStorage");
|
|
3302
|
-
setStreamingSlotWarningController({
|
|
3303
|
-
maybeWarn: (primitiveName) => {
|
|
3304
|
-
const store = getWarningStorage()?.getStore();
|
|
3305
|
-
if (!store || store.hasWarned) {
|
|
3306
|
-
return;
|
|
3307
|
-
}
|
|
3308
|
-
store.hasWarned = true;
|
|
3309
|
-
logWarn(buildMissingCollectorWarning(primitiveName, store.handlerCallsite));
|
|
3310
|
-
}
|
|
3311
|
-
});
|
|
2545
|
+
// src/core/ssrCache.ts
|
|
2546
|
+
var dirtyFrameworks, markSsrCacheDirty = (framework) => {
|
|
2547
|
+
dirtyFrameworks.add(framework);
|
|
2548
|
+
}, isSsrCacheDirty = (framework) => dirtyFrameworks.has(framework);
|
|
2549
|
+
var init_ssrCache = __esm(() => {
|
|
2550
|
+
dirtyFrameworks = new Set;
|
|
3312
2551
|
});
|
|
3313
2552
|
|
|
3314
2553
|
// src/islands/sourceMetadata.ts
|
|
@@ -4673,168 +3912,29 @@ var init_compileAngular = __esm(() => {
|
|
|
4673
3912
|
wrapperOutputCache = new Map;
|
|
4674
3913
|
});
|
|
4675
3914
|
|
|
4676
|
-
//
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
if (!compilerImportPromise) {
|
|
4683
|
-
compilerImportPromise = import("@angular/compiler");
|
|
4684
|
-
}
|
|
4685
|
-
return compilerImportPromise;
|
|
4686
|
-
}, readAngularPageModule = (value) => isRecord5(value) ? value : null, resolveAngularSsrOutDir = () => process.env.ABSOLUTE_ANGULAR_SSR_OUTDIR ?? join6(tmpdir(), "absolutejs", "generated", "angular-ssr"), ensureAngularSsrNodeModules = async (outDir) => {
|
|
4687
|
-
const outRoot = resolve7(dirname5(dirname5(outDir)));
|
|
4688
|
-
const nodeModulesLink = join6(outRoot, "node_modules");
|
|
4689
|
-
if (process.env.ABSOLUTE_ANGULAR_SSR_OUTDIR) {
|
|
4690
|
-
return;
|
|
4691
|
-
}
|
|
4692
|
-
if (nodeModulesLink === resolve7(process.cwd(), "node_modules")) {
|
|
4693
|
-
return;
|
|
4694
|
-
}
|
|
4695
|
-
if (await Bun.file(nodeModulesLink).exists()) {
|
|
4696
|
-
return;
|
|
4697
|
-
}
|
|
4698
|
-
await mkdir2(outRoot, { recursive: true });
|
|
4699
|
-
try {
|
|
4700
|
-
await symlink(resolve7(process.cwd(), "node_modules"), nodeModulesLink, "dir");
|
|
4701
|
-
} catch (error) {
|
|
4702
|
-
if (!(error instanceof Error) || !("code" in error) || error.code !== "EEXIST") {
|
|
4703
|
-
throw error;
|
|
4704
|
-
}
|
|
3915
|
+
// node_modules/rxjs/dist/cjs/internal/util/isFunction.js
|
|
3916
|
+
var require_isFunction = __commonJS((exports) => {
|
|
3917
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3918
|
+
exports.isFunction = undefined;
|
|
3919
|
+
function isFunction(value) {
|
|
3920
|
+
return typeof value === "function";
|
|
4705
3921
|
}
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
await ensureAngularCompiler();
|
|
4723
|
-
const {
|
|
4724
|
-
headTag: resolvedHeadTag,
|
|
4725
|
-
indexPath: resolvedIndexPath,
|
|
4726
|
-
options,
|
|
4727
|
-
pagePath: resolvedPagePath,
|
|
4728
|
-
props: maybeProps
|
|
4729
|
-
} = typeof PageOrInput === "object" && PageOrInput !== null && "pagePath" in PageOrInput && "indexPath" in PageOrInput ? {
|
|
4730
|
-
headTag: PageOrInput.headTag ?? "<head></head>",
|
|
4731
|
-
indexPath: PageOrInput.indexPath,
|
|
4732
|
-
options: PageOrInput,
|
|
4733
|
-
pagePath: PageOrInput.pagePath,
|
|
4734
|
-
props: PageOrInput.props
|
|
4735
|
-
} : {
|
|
4736
|
-
headTag,
|
|
4737
|
-
indexPath: indexPath ?? "",
|
|
4738
|
-
options: args[1],
|
|
4739
|
-
pagePath: pagePath ?? "",
|
|
4740
|
-
props: args[0]
|
|
4741
|
-
};
|
|
4742
|
-
cacheRouteData(resolvedPagePath, {
|
|
4743
|
-
headTag: resolvedHeadTag,
|
|
4744
|
-
props: maybeProps
|
|
4745
|
-
});
|
|
4746
|
-
if (ssrDirty) {
|
|
4747
|
-
const script = resolvedIndexPath ? `<script>import(${JSON.stringify(resolvedIndexPath)});</script>` : "";
|
|
4748
|
-
const html = `<!DOCTYPE html><html>${resolvedHeadTag}<body><${lastSelector}></${lastSelector}>${script}</body></html>`;
|
|
4749
|
-
return new Response(html, {
|
|
4750
|
-
headers: { "Content-Type": "text/html" }
|
|
4751
|
-
});
|
|
4752
|
-
}
|
|
4753
|
-
try {
|
|
4754
|
-
const handlerCallsite = options?.collectStreamingSlots === true ? undefined : getCurrentRouteRegistrationCallsite() ?? captureStreamingSlotWarningCallsite();
|
|
4755
|
-
const renderPageResponse = async () => {
|
|
4756
|
-
const baseDeps = await getAngularDeps();
|
|
4757
|
-
const runtimePagePath = await resolveRuntimeAngularModulePath(resolvedPagePath);
|
|
4758
|
-
const importedPageModule = await import(runtimePagePath);
|
|
4759
|
-
const pageModule = readAngularPageModule(importedPageModule);
|
|
4760
|
-
if (!pageModule) {
|
|
4761
|
-
throw new Error(`Invalid Angular page module: ${resolvedPagePath}`);
|
|
4762
|
-
}
|
|
4763
|
-
const PageComponent = pageModule.default;
|
|
4764
|
-
if (!isAngularComponent(PageComponent)) {
|
|
4765
|
-
throw new Error(`Angular page module must export a component by default: ${resolvedPagePath}`);
|
|
4766
|
-
}
|
|
4767
|
-
const hasIslands = typeof pageModule.__ABSOLUTE_PAGE_HAS_ISLANDS__ === "boolean" ? pageModule.__ABSOLUTE_PAGE_HAS_ISLANDS__ : false;
|
|
4768
|
-
const ssrResult = await loadSsrDeps(runtimePagePath);
|
|
4769
|
-
const deps = buildDeps(ssrResult, baseDeps);
|
|
4770
|
-
const tokenMap = discoverTokens(pageModule);
|
|
4771
|
-
const selector = resolveSelector(deps, resolvedPagePath, PageComponent);
|
|
4772
|
-
lastSelector = selector;
|
|
4773
|
-
const htmlString = `<!DOCTYPE html><html>${resolvedHeadTag}<body><${selector}></${selector}></body></html>`;
|
|
4774
|
-
if (ssrResult?.core)
|
|
4775
|
-
resetSsrSanitizer();
|
|
4776
|
-
const sanitizer = getSsrSanitizer(deps);
|
|
4777
|
-
const providers = buildProviders(deps, sanitizer, maybeProps, tokenMap);
|
|
4778
|
-
const rawHtml = await renderAngularApp(deps, PageComponent, providers, htmlString);
|
|
4779
|
-
const shouldProcessIslands = hasIslands || rawHtml.includes("<absolute-island");
|
|
4780
|
-
const htmlWithLoweredIslands = shouldProcessIslands ? await lowerAngularServerIslands(rawHtml) : rawHtml;
|
|
4781
|
-
const html = injectIslandPageContext(injectSsrScripts(htmlWithLoweredIslands, requestId, resolvedIndexPath, maybeProps), { hasIslands: shouldProcessIslands });
|
|
4782
|
-
return new Response(html, {
|
|
4783
|
-
headers: { "Content-Type": "text/html" }
|
|
4784
|
-
});
|
|
4785
|
-
};
|
|
4786
|
-
return runWithStreamingSlotWarningScope(() => options?.collectStreamingSlots === true ? withRegisteredStreamingSlots(renderPageResponse, options) : renderPageResponse(), { handlerCallsite });
|
|
4787
|
-
} catch (error) {
|
|
4788
|
-
console.error("[SSR] Angular render error:", error);
|
|
4789
|
-
const pageName = derivePageName(resolvedPagePath);
|
|
4790
|
-
const conventionResponse = await renderConventionError("angular", pageName, error);
|
|
4791
|
-
if (conventionResponse)
|
|
4792
|
-
return conventionResponse;
|
|
4793
|
-
return new Response(ssrErrorPage("angular", error), {
|
|
4794
|
-
headers: { "Content-Type": "text/html" },
|
|
4795
|
-
status: 500
|
|
4796
|
-
});
|
|
4797
|
-
}
|
|
4798
|
-
});
|
|
4799
|
-
};
|
|
4800
|
-
var init_pageHandler = __esm(() => {
|
|
4801
|
-
init_constants();
|
|
4802
|
-
init_islandPageContext();
|
|
4803
|
-
init_resolveConvention();
|
|
4804
|
-
init_registerClientScript();
|
|
4805
|
-
init_angularDeps();
|
|
4806
|
-
init_lowerServerIslands();
|
|
4807
|
-
init_devRouteRegistrationCallsite();
|
|
4808
|
-
init_responseEnhancers();
|
|
4809
|
-
init_streamingSlotWarningScope();
|
|
4810
|
-
init_ssrRender();
|
|
4811
|
-
angularSsrContext = new AsyncLocalStorage3;
|
|
4812
|
-
setSsrContextGetter(() => angularSsrContext.getStore());
|
|
4813
|
-
});
|
|
4814
|
-
|
|
4815
|
-
// node_modules/rxjs/dist/cjs/internal/util/isFunction.js
|
|
4816
|
-
var require_isFunction = __commonJS((exports) => {
|
|
4817
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4818
|
-
exports.isFunction = undefined;
|
|
4819
|
-
function isFunction(value) {
|
|
4820
|
-
return typeof value === "function";
|
|
4821
|
-
}
|
|
4822
|
-
exports.isFunction = isFunction;
|
|
4823
|
-
});
|
|
4824
|
-
|
|
4825
|
-
// node_modules/rxjs/dist/cjs/internal/util/createErrorClass.js
|
|
4826
|
-
var require_createErrorClass = __commonJS((exports) => {
|
|
4827
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4828
|
-
exports.createErrorClass = undefined;
|
|
4829
|
-
function createErrorClass(createImpl) {
|
|
4830
|
-
var _super = function(instance) {
|
|
4831
|
-
Error.call(instance);
|
|
4832
|
-
instance.stack = new Error().stack;
|
|
4833
|
-
};
|
|
4834
|
-
var ctorFunc = createImpl(_super);
|
|
4835
|
-
ctorFunc.prototype = Object.create(Error.prototype);
|
|
4836
|
-
ctorFunc.prototype.constructor = ctorFunc;
|
|
4837
|
-
return ctorFunc;
|
|
3922
|
+
exports.isFunction = isFunction;
|
|
3923
|
+
});
|
|
3924
|
+
|
|
3925
|
+
// node_modules/rxjs/dist/cjs/internal/util/createErrorClass.js
|
|
3926
|
+
var require_createErrorClass = __commonJS((exports) => {
|
|
3927
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3928
|
+
exports.createErrorClass = undefined;
|
|
3929
|
+
function createErrorClass(createImpl) {
|
|
3930
|
+
var _super = function(instance) {
|
|
3931
|
+
Error.call(instance);
|
|
3932
|
+
instance.stack = new Error().stack;
|
|
3933
|
+
};
|
|
3934
|
+
var ctorFunc = createImpl(_super);
|
|
3935
|
+
ctorFunc.prototype = Object.create(Error.prototype);
|
|
3936
|
+
ctorFunc.prototype.constructor = ctorFunc;
|
|
3937
|
+
return ctorFunc;
|
|
4838
3938
|
}
|
|
4839
3939
|
exports.createErrorClass = createErrorClass;
|
|
4840
3940
|
});
|
|
@@ -13749,10 +12849,987 @@ var require_cjs = __commonJS((exports) => {
|
|
|
13749
12849
|
} });
|
|
13750
12850
|
});
|
|
13751
12851
|
|
|
12852
|
+
// src/core/streamingSlotRegistrar.ts
|
|
12853
|
+
var STREAMING_SLOT_REGISTRAR_KEY = Symbol.for("absolutejs.streamingSlotRegistrar");
|
|
12854
|
+
var STREAMING_SLOT_WARNING_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotWarningController");
|
|
12855
|
+
var STREAMING_SLOT_COLLECTION_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotCollectionController");
|
|
12856
|
+
var getRegisteredStreamingSlotRegistrar = () => {
|
|
12857
|
+
const value = Reflect.get(globalThis, STREAMING_SLOT_REGISTRAR_KEY);
|
|
12858
|
+
if (typeof value === "function" || value === null) {
|
|
12859
|
+
return value;
|
|
12860
|
+
}
|
|
12861
|
+
return;
|
|
12862
|
+
};
|
|
12863
|
+
var isObjectRecord = (value) => Boolean(value) && typeof value === "object";
|
|
12864
|
+
var isStreamingSlotWarningController = (value) => isObjectRecord(value) && ("maybeWarn" in value) && typeof value.maybeWarn === "function";
|
|
12865
|
+
var isStreamingSlotCollectionController = (value) => isObjectRecord(value) && ("isCollecting" in value) && typeof value.isCollecting === "function";
|
|
12866
|
+
var getWarningController = () => {
|
|
12867
|
+
const value = Reflect.get(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY);
|
|
12868
|
+
if (value === null || typeof value === "undefined")
|
|
12869
|
+
return;
|
|
12870
|
+
return isStreamingSlotWarningController(value) ? value : undefined;
|
|
12871
|
+
};
|
|
12872
|
+
var getCollectionController = () => {
|
|
12873
|
+
const value = Reflect.get(globalThis, STREAMING_SLOT_COLLECTION_STORAGE_KEY);
|
|
12874
|
+
if (value === null || typeof value === "undefined")
|
|
12875
|
+
return;
|
|
12876
|
+
return isStreamingSlotCollectionController(value) ? value : undefined;
|
|
12877
|
+
};
|
|
12878
|
+
var hasRegisteredStreamingSlotRegistrar = () => typeof getRegisteredStreamingSlotRegistrar() === "function";
|
|
12879
|
+
var isStreamingSlotCollectionActive = () => getCollectionController()?.isCollecting() === true;
|
|
12880
|
+
var registerStreamingSlot = (slot) => {
|
|
12881
|
+
getRegisteredStreamingSlotRegistrar()?.(slot);
|
|
12882
|
+
};
|
|
12883
|
+
var setStreamingSlotCollectionController = (controller) => {
|
|
12884
|
+
Reflect.set(globalThis, STREAMING_SLOT_COLLECTION_STORAGE_KEY, controller);
|
|
12885
|
+
};
|
|
12886
|
+
var setStreamingSlotRegistrar = (nextRegistrar) => {
|
|
12887
|
+
Reflect.set(globalThis, STREAMING_SLOT_REGISTRAR_KEY, nextRegistrar);
|
|
12888
|
+
};
|
|
12889
|
+
var setStreamingSlotWarningController = (controller) => {
|
|
12890
|
+
Reflect.set(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY, controller);
|
|
12891
|
+
};
|
|
12892
|
+
var warnMissingStreamingSlotCollector = (primitiveName) => {
|
|
12893
|
+
if (isStreamingSlotCollectionActive()) {
|
|
12894
|
+
return;
|
|
12895
|
+
}
|
|
12896
|
+
getWarningController()?.maybeWarn(primitiveName);
|
|
12897
|
+
};
|
|
12898
|
+
|
|
12899
|
+
// src/core/streamingSlotRegistry.ts
|
|
12900
|
+
var STREAMING_SLOT_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotAsyncLocalStorage");
|
|
12901
|
+
var isObjectRecord2 = (value) => Boolean(value) && typeof value === "object";
|
|
12902
|
+
var isAsyncLocalStorage = (value) => isObjectRecord2(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function";
|
|
12903
|
+
var getStorageGlobal = () => {
|
|
12904
|
+
const value = Reflect.get(globalThis, STREAMING_SLOT_STORAGE_KEY);
|
|
12905
|
+
if (value === null || typeof value === "undefined") {
|
|
12906
|
+
return value;
|
|
12907
|
+
}
|
|
12908
|
+
return isAsyncLocalStorage(value) ? value : undefined;
|
|
12909
|
+
};
|
|
12910
|
+
var isServerRuntime = () => typeof process !== "undefined" && typeof process.versions?.node === "string";
|
|
12911
|
+
var ensureAsyncLocalStorage = async () => {
|
|
12912
|
+
const storage = getStorageGlobal();
|
|
12913
|
+
if (typeof storage !== "undefined") {
|
|
12914
|
+
return storage;
|
|
12915
|
+
}
|
|
12916
|
+
if (!isServerRuntime()) {
|
|
12917
|
+
Reflect.set(globalThis, STREAMING_SLOT_STORAGE_KEY, null);
|
|
12918
|
+
return getStorageGlobal();
|
|
12919
|
+
}
|
|
12920
|
+
const mod = await import("async_hooks");
|
|
12921
|
+
Reflect.set(globalThis, STREAMING_SLOT_STORAGE_KEY, new mod.AsyncLocalStorage);
|
|
12922
|
+
return getStorageGlobal();
|
|
12923
|
+
};
|
|
12924
|
+
var getActiveSlotStore = () => {
|
|
12925
|
+
const storage = getStorageGlobal();
|
|
12926
|
+
if (!storage)
|
|
12927
|
+
return;
|
|
12928
|
+
return storage.getStore();
|
|
12929
|
+
};
|
|
12930
|
+
var registerStreamingSlot2 = (slot) => {
|
|
12931
|
+
const store = getActiveSlotStore();
|
|
12932
|
+
if (!store)
|
|
12933
|
+
return;
|
|
12934
|
+
store.set(slot.id, slot);
|
|
12935
|
+
};
|
|
12936
|
+
setStreamingSlotRegistrar(registerStreamingSlot2);
|
|
12937
|
+
setStreamingSlotCollectionController({
|
|
12938
|
+
isCollecting: () => getActiveSlotStore() !== undefined
|
|
12939
|
+
});
|
|
12940
|
+
var hasActiveStreamingSlotRegistry = () => getActiveSlotStore() !== undefined;
|
|
12941
|
+
var runWithStreamingSlotRegistry = async (task) => {
|
|
12942
|
+
const storage = await ensureAsyncLocalStorage();
|
|
12943
|
+
if (!storage) {
|
|
12944
|
+
const slots = [];
|
|
12945
|
+
return {
|
|
12946
|
+
result: await task(),
|
|
12947
|
+
slots
|
|
12948
|
+
};
|
|
12949
|
+
}
|
|
12950
|
+
return storage.run(new Map, async () => {
|
|
12951
|
+
const result = await task();
|
|
12952
|
+
const store = storage.getStore();
|
|
12953
|
+
return {
|
|
12954
|
+
result,
|
|
12955
|
+
slots: store ? [...store.values()] : []
|
|
12956
|
+
};
|
|
12957
|
+
});
|
|
12958
|
+
};
|
|
12959
|
+
|
|
13752
12960
|
// src/angular/index.ts
|
|
13753
|
-
init_pageHandler();
|
|
13754
12961
|
import"@angular/compiler";
|
|
13755
12962
|
|
|
12963
|
+
// src/angular/pageHandler.ts
|
|
12964
|
+
init_constants();
|
|
12965
|
+
import { AsyncLocalStorage as AsyncLocalStorage3 } from "async_hooks";
|
|
12966
|
+
import { mkdir as mkdir2, symlink } from "fs/promises";
|
|
12967
|
+
import { tmpdir } from "os";
|
|
12968
|
+
import { basename as basename4, dirname as dirname5, join as join6, resolve as resolve7 } from "path";
|
|
12969
|
+
|
|
12970
|
+
// src/core/islandPageContext.ts
|
|
12971
|
+
init_constants();
|
|
12972
|
+
var BOOTSTRAP_MANIFEST_KEY = "BootstrapClient";
|
|
12973
|
+
var ISLAND_MARKER = 'data-island="true"';
|
|
12974
|
+
var MANIFEST_MARKER = "__ABSOLUTE_MANIFEST__";
|
|
12975
|
+
var ISLAND_STATE_MARKER = "__ABS_ISLAND_STATE__";
|
|
12976
|
+
var CLOSING_HEAD_TAG = "</head>";
|
|
12977
|
+
var buildIslandsHeadMarkup = (manifest) => {
|
|
12978
|
+
const manifestScript = `<script>window.__ABSOLUTE_MANIFEST__ = ${JSON.stringify(manifest)}</script>`;
|
|
12979
|
+
const islandStateScript = `<script>window.__ABS_ISLAND_STATE__ = ${JSON.stringify(globalThis.__ABS_ISLAND_STATE__ ?? {})}</script>`;
|
|
12980
|
+
const bootstrapPath = manifest[BOOTSTRAP_MANIFEST_KEY];
|
|
12981
|
+
const bootstrapScript = bootstrapPath ? `<script type="module" src="${bootstrapPath}"></script>` : "";
|
|
12982
|
+
return `${manifestScript}${islandStateScript}${bootstrapScript}`;
|
|
12983
|
+
};
|
|
12984
|
+
var injectHeadMarkup = (html, markup) => {
|
|
12985
|
+
const closingHeadIndex = html.indexOf("</head>");
|
|
12986
|
+
if (closingHeadIndex >= 0) {
|
|
12987
|
+
return `${html.slice(0, closingHeadIndex)}${markup}${html.slice(closingHeadIndex)}`;
|
|
12988
|
+
}
|
|
12989
|
+
const openingBodyIndex = html.indexOf("<body");
|
|
12990
|
+
if (openingBodyIndex >= 0) {
|
|
12991
|
+
const bodyStart = html.indexOf(">", openingBodyIndex);
|
|
12992
|
+
if (bodyStart >= 0) {
|
|
12993
|
+
return `${html.slice(0, openingBodyIndex)}<head>${markup}</head>${html.slice(openingBodyIndex)}`;
|
|
12994
|
+
}
|
|
12995
|
+
}
|
|
12996
|
+
return `<!DOCTYPE html><html><head>${markup}</head><body>${html}</body></html>`;
|
|
12997
|
+
};
|
|
12998
|
+
var streamChunkToString = (value, decoder) => typeof value === "string" ? value : decoder.decode(value, { stream: true });
|
|
12999
|
+
var flushSafePendingText = (controller, encoder, pending, lookbehind) => {
|
|
13000
|
+
if (pending.length <= lookbehind) {
|
|
13001
|
+
return pending;
|
|
13002
|
+
}
|
|
13003
|
+
const safeText = pending.slice(0, pending.length - lookbehind);
|
|
13004
|
+
controller.enqueue(encoder.encode(safeText));
|
|
13005
|
+
return pending.slice(-lookbehind);
|
|
13006
|
+
};
|
|
13007
|
+
var updateInjectedState = (consumed, injected, pending) => {
|
|
13008
|
+
if (consumed.done) {
|
|
13009
|
+
return { done: true, injected, pending };
|
|
13010
|
+
}
|
|
13011
|
+
return {
|
|
13012
|
+
done: false,
|
|
13013
|
+
injected: consumed.injected,
|
|
13014
|
+
pending: consumed.pending
|
|
13015
|
+
};
|
|
13016
|
+
};
|
|
13017
|
+
var readStreamChunk = async (reader) => {
|
|
13018
|
+
const { done, value } = await reader.read();
|
|
13019
|
+
if (done || !value) {
|
|
13020
|
+
return { done, value: undefined };
|
|
13021
|
+
}
|
|
13022
|
+
return { done, value };
|
|
13023
|
+
};
|
|
13024
|
+
var pipeStreamWithHeadInjection = (stream, markup) => {
|
|
13025
|
+
const encoder = new TextEncoder;
|
|
13026
|
+
const decoder = new TextDecoder;
|
|
13027
|
+
const lookbehind = CLOSING_HEAD_TAG.length - 1;
|
|
13028
|
+
const processPending = (controller, pending, injected) => {
|
|
13029
|
+
if (injected) {
|
|
13030
|
+
controller.enqueue(encoder.encode(pending));
|
|
13031
|
+
return { injected, pending: "" };
|
|
13032
|
+
}
|
|
13033
|
+
const headIndex = pending.indexOf(CLOSING_HEAD_TAG);
|
|
13034
|
+
if (headIndex >= 0) {
|
|
13035
|
+
const next = `${pending.slice(0, headIndex)}${markup}${pending.slice(headIndex)}`;
|
|
13036
|
+
controller.enqueue(encoder.encode(next));
|
|
13037
|
+
return { injected: true, pending: "" };
|
|
13038
|
+
}
|
|
13039
|
+
return {
|
|
13040
|
+
injected,
|
|
13041
|
+
pending: flushSafePendingText(controller, encoder, pending, lookbehind)
|
|
13042
|
+
};
|
|
13043
|
+
};
|
|
13044
|
+
const finishHeadInjectionStream = (controller, pending, injected) => {
|
|
13045
|
+
let finalPending = pending + decoder.decode();
|
|
13046
|
+
if (!injected) {
|
|
13047
|
+
finalPending = injectHeadMarkup(finalPending, markup);
|
|
13048
|
+
}
|
|
13049
|
+
if (finalPending.length > 0) {
|
|
13050
|
+
controller.enqueue(encoder.encode(finalPending));
|
|
13051
|
+
}
|
|
13052
|
+
controller.close();
|
|
13053
|
+
};
|
|
13054
|
+
const consumeHeadChunk = async (controller, reader, pending, injected) => {
|
|
13055
|
+
const { done, value } = await readStreamChunk(reader);
|
|
13056
|
+
if (done || !value) {
|
|
13057
|
+
return { done, injected, pending };
|
|
13058
|
+
}
|
|
13059
|
+
const processed = processPending(controller, pending + streamChunkToString(value, decoder), injected);
|
|
13060
|
+
return {
|
|
13061
|
+
done,
|
|
13062
|
+
injected: processed.injected,
|
|
13063
|
+
pending: processed.pending
|
|
13064
|
+
};
|
|
13065
|
+
};
|
|
13066
|
+
const runHeadInjectionLoop = async (controller, reader) => {
|
|
13067
|
+
const consumeNextHeadChunk = async (injected, pending) => {
|
|
13068
|
+
const consumed = await consumeHeadChunk(controller, reader, pending, injected);
|
|
13069
|
+
const nextState = updateInjectedState(consumed, injected, pending);
|
|
13070
|
+
if (nextState.done) {
|
|
13071
|
+
return { injected, pending };
|
|
13072
|
+
}
|
|
13073
|
+
return consumeNextHeadChunk(nextState.injected, nextState.pending);
|
|
13074
|
+
};
|
|
13075
|
+
return consumeNextHeadChunk(false, "");
|
|
13076
|
+
};
|
|
13077
|
+
return new ReadableStream({
|
|
13078
|
+
async start(controller) {
|
|
13079
|
+
const reader = stream.getReader();
|
|
13080
|
+
try {
|
|
13081
|
+
const { injected, pending } = await runHeadInjectionLoop(controller, reader);
|
|
13082
|
+
finishHeadInjectionStream(controller, pending, injected);
|
|
13083
|
+
} catch (error) {
|
|
13084
|
+
controller.error(error);
|
|
13085
|
+
}
|
|
13086
|
+
}
|
|
13087
|
+
});
|
|
13088
|
+
};
|
|
13089
|
+
var pipeStreamWithIslandMarkerDetection = (stream, markup) => {
|
|
13090
|
+
const encoder = new TextEncoder;
|
|
13091
|
+
const decoder = new TextDecoder;
|
|
13092
|
+
const lookbehind = Math.max(ISLAND_MARKER.length, BYTES_PER_KILOBYTE);
|
|
13093
|
+
const processPending = (controller, pending, injected) => {
|
|
13094
|
+
if (injected) {
|
|
13095
|
+
controller.enqueue(encoder.encode(pending));
|
|
13096
|
+
return { injected, pending: "" };
|
|
13097
|
+
}
|
|
13098
|
+
const markerIndex = pending.indexOf(ISLAND_MARKER);
|
|
13099
|
+
if (markerIndex >= 0) {
|
|
13100
|
+
const tagStart = pending.lastIndexOf("<", markerIndex);
|
|
13101
|
+
const injectAt = tagStart >= 0 ? tagStart : markerIndex;
|
|
13102
|
+
const next = `${pending.slice(0, injectAt)}${markup}${pending.slice(injectAt)}`;
|
|
13103
|
+
controller.enqueue(encoder.encode(next));
|
|
13104
|
+
return { injected: true, pending: "" };
|
|
13105
|
+
}
|
|
13106
|
+
return {
|
|
13107
|
+
injected,
|
|
13108
|
+
pending: flushSafePendingText(controller, encoder, pending, lookbehind)
|
|
13109
|
+
};
|
|
13110
|
+
};
|
|
13111
|
+
const finishIslandMarkerStream = (controller, pending) => {
|
|
13112
|
+
const finalPending = pending + decoder.decode();
|
|
13113
|
+
if (finalPending.length > 0) {
|
|
13114
|
+
controller.enqueue(encoder.encode(finalPending));
|
|
13115
|
+
}
|
|
13116
|
+
controller.close();
|
|
13117
|
+
};
|
|
13118
|
+
const consumeIslandChunk = async (controller, reader, pending, injected) => {
|
|
13119
|
+
const { done, value } = await readStreamChunk(reader);
|
|
13120
|
+
if (done || !value) {
|
|
13121
|
+
return { done, injected, pending };
|
|
13122
|
+
}
|
|
13123
|
+
const processed = processPending(controller, pending + streamChunkToString(value, decoder), injected);
|
|
13124
|
+
return {
|
|
13125
|
+
done,
|
|
13126
|
+
injected: processed.injected,
|
|
13127
|
+
pending: processed.pending
|
|
13128
|
+
};
|
|
13129
|
+
};
|
|
13130
|
+
const runIslandMarkerLoop = async (controller, reader) => {
|
|
13131
|
+
const consumeNextIslandChunk = async (injected, pending) => {
|
|
13132
|
+
const consumed = await consumeIslandChunk(controller, reader, pending, injected);
|
|
13133
|
+
const nextState = updateInjectedState(consumed, injected, pending);
|
|
13134
|
+
if (nextState.done) {
|
|
13135
|
+
return { injected, pending };
|
|
13136
|
+
}
|
|
13137
|
+
return consumeNextIslandChunk(nextState.injected, nextState.pending);
|
|
13138
|
+
};
|
|
13139
|
+
return consumeNextIslandChunk(false, "");
|
|
13140
|
+
};
|
|
13141
|
+
return new ReadableStream({
|
|
13142
|
+
async start(controller) {
|
|
13143
|
+
const reader = stream.getReader();
|
|
13144
|
+
try {
|
|
13145
|
+
const { pending } = await runIslandMarkerLoop(controller, reader);
|
|
13146
|
+
finishIslandMarkerStream(controller, pending);
|
|
13147
|
+
} catch (error) {
|
|
13148
|
+
controller.error(error);
|
|
13149
|
+
}
|
|
13150
|
+
}
|
|
13151
|
+
});
|
|
13152
|
+
};
|
|
13153
|
+
var htmlContainsIslands = (html) => html.includes(ISLAND_MARKER);
|
|
13154
|
+
var injectIslandPageContext = (html, options) => {
|
|
13155
|
+
const manifest = globalThis.__absoluteManifest;
|
|
13156
|
+
const hasIslands = options?.hasIslands ?? htmlContainsIslands(html);
|
|
13157
|
+
if (!manifest || !hasIslands) {
|
|
13158
|
+
return html;
|
|
13159
|
+
}
|
|
13160
|
+
if (html.includes(MANIFEST_MARKER) || html.includes(ISLAND_STATE_MARKER)) {
|
|
13161
|
+
return html;
|
|
13162
|
+
}
|
|
13163
|
+
return injectHeadMarkup(html, buildIslandsHeadMarkup(manifest));
|
|
13164
|
+
};
|
|
13165
|
+
var injectIslandPageContextStream = (stream, options) => {
|
|
13166
|
+
const manifest = globalThis.__absoluteManifest;
|
|
13167
|
+
if (!manifest)
|
|
13168
|
+
return stream;
|
|
13169
|
+
const markup = buildIslandsHeadMarkup(manifest);
|
|
13170
|
+
if (options?.hasIslands === true) {
|
|
13171
|
+
return pipeStreamWithHeadInjection(stream, markup);
|
|
13172
|
+
}
|
|
13173
|
+
if (options?.hasIslands === false) {
|
|
13174
|
+
return stream;
|
|
13175
|
+
}
|
|
13176
|
+
return pipeStreamWithIslandMarkerDetection(stream, markup);
|
|
13177
|
+
};
|
|
13178
|
+
var setCurrentIslandManifest = (manifest) => {
|
|
13179
|
+
globalThis.__absoluteManifest = manifest;
|
|
13180
|
+
};
|
|
13181
|
+
|
|
13182
|
+
// src/utils/ssrErrorPage.ts
|
|
13183
|
+
var ssrErrorPage = (framework, error) => {
|
|
13184
|
+
const frameworkColors = {
|
|
13185
|
+
angular: "#dd0031",
|
|
13186
|
+
html: "#e34c26",
|
|
13187
|
+
htmx: "#1a365d",
|
|
13188
|
+
react: "#61dafb",
|
|
13189
|
+
svelte: "#ff3e00",
|
|
13190
|
+
vue: "#42b883"
|
|
13191
|
+
};
|
|
13192
|
+
const accent = frameworkColors[framework] ?? "#94a3b8";
|
|
13193
|
+
const label = framework.charAt(0).toUpperCase() + framework.slice(1);
|
|
13194
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
13195
|
+
return `<!DOCTYPE html>
|
|
13196
|
+
<html>
|
|
13197
|
+
<head>
|
|
13198
|
+
<meta charset="utf-8">
|
|
13199
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
13200
|
+
<title>SSR Error - AbsoluteJS</title>
|
|
13201
|
+
<style>
|
|
13202
|
+
*{margin:0;padding:0;box-sizing:border-box}
|
|
13203
|
+
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}
|
|
13204
|
+
.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}
|
|
13205
|
+
.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)}
|
|
13206
|
+
.brand{font-weight:700;font-size:20px;color:#fff;letter-spacing:-0.02em}
|
|
13207
|
+
.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)}
|
|
13208
|
+
.kind{color:#94a3b8;font-size:13px;font-weight:500}
|
|
13209
|
+
.content{padding:24px}
|
|
13210
|
+
.label{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:0.08em;color:#94a3b8;margin-bottom:8px}
|
|
13211
|
+
.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}
|
|
13212
|
+
.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}
|
|
13213
|
+
</style>
|
|
13214
|
+
</head>
|
|
13215
|
+
<body>
|
|
13216
|
+
<div class="card">
|
|
13217
|
+
<div class="header">
|
|
13218
|
+
<div style="display:flex;align-items:center;gap:12px">
|
|
13219
|
+
<span class="brand">AbsoluteJS</span>
|
|
13220
|
+
<span class="badge">${label}</span>
|
|
13221
|
+
</div>
|
|
13222
|
+
<span class="kind">Server Render Error</span>
|
|
13223
|
+
</div>
|
|
13224
|
+
<div class="content">
|
|
13225
|
+
<div class="label">What went wrong</div>
|
|
13226
|
+
<pre class="message">${message.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")}</pre>
|
|
13227
|
+
<div class="hint">A component threw during server-side rendering. Check the terminal for the full stack trace.</div>
|
|
13228
|
+
</div>
|
|
13229
|
+
</div>
|
|
13230
|
+
</body>
|
|
13231
|
+
</html>`;
|
|
13232
|
+
};
|
|
13233
|
+
|
|
13234
|
+
// src/utils/resolveConvention.ts
|
|
13235
|
+
import { basename } from "path";
|
|
13236
|
+
var CONVENTIONS_KEY = "__absoluteConventions";
|
|
13237
|
+
var isConventionsMap = (value) => Boolean(value) && typeof value === "object";
|
|
13238
|
+
var getMap = () => {
|
|
13239
|
+
const value = Reflect.get(globalThis, CONVENTIONS_KEY);
|
|
13240
|
+
if (isConventionsMap(value))
|
|
13241
|
+
return value;
|
|
13242
|
+
const empty = {};
|
|
13243
|
+
return empty;
|
|
13244
|
+
};
|
|
13245
|
+
var derivePageName = (pagePath) => {
|
|
13246
|
+
const base = basename(pagePath);
|
|
13247
|
+
const dotIndex = base.indexOf(".");
|
|
13248
|
+
const name = dotIndex > 0 ? base.slice(0, dotIndex) : base;
|
|
13249
|
+
return toPascal(name);
|
|
13250
|
+
};
|
|
13251
|
+
var resolveErrorConventionPath = (framework, pageName) => {
|
|
13252
|
+
const conventions = getMap()[framework];
|
|
13253
|
+
if (!conventions)
|
|
13254
|
+
return;
|
|
13255
|
+
return conventions.pages?.[pageName]?.error ?? conventions.defaults?.error;
|
|
13256
|
+
};
|
|
13257
|
+
var resolveNotFoundConventionPath = (framework) => getMap()[framework]?.defaults?.notFound;
|
|
13258
|
+
var setConventions = (map) => {
|
|
13259
|
+
Reflect.set(globalThis, CONVENTIONS_KEY, map);
|
|
13260
|
+
};
|
|
13261
|
+
var isDev = () => true;
|
|
13262
|
+
var buildErrorProps = (error) => {
|
|
13263
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
13264
|
+
const stack = isDev() && error instanceof Error ? error.stack : undefined;
|
|
13265
|
+
return { error: { message, stack } };
|
|
13266
|
+
};
|
|
13267
|
+
var renderReactError = async (conventionPath, errorProps) => {
|
|
13268
|
+
const { createElement } = await import("react");
|
|
13269
|
+
const { renderToReadableStream } = await import("react-dom/server");
|
|
13270
|
+
const mod = await import(conventionPath);
|
|
13271
|
+
const [firstKey] = Object.keys(mod);
|
|
13272
|
+
const ErrorComponent = mod.default ?? (firstKey ? mod[firstKey] : undefined);
|
|
13273
|
+
const element = createElement(ErrorComponent, errorProps);
|
|
13274
|
+
const stream = await renderToReadableStream(element);
|
|
13275
|
+
return new Response(stream, {
|
|
13276
|
+
headers: { "Content-Type": "text/html" },
|
|
13277
|
+
status: 500
|
|
13278
|
+
});
|
|
13279
|
+
};
|
|
13280
|
+
var renderSvelteError = async (conventionPath, errorProps) => {
|
|
13281
|
+
const { render } = await import("svelte/server");
|
|
13282
|
+
const mod = await import(conventionPath);
|
|
13283
|
+
const ErrorComponent = mod.default;
|
|
13284
|
+
const { head, body } = render(ErrorComponent, {
|
|
13285
|
+
props: errorProps
|
|
13286
|
+
});
|
|
13287
|
+
const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
|
|
13288
|
+
return new Response(html, {
|
|
13289
|
+
headers: { "Content-Type": "text/html" },
|
|
13290
|
+
status: 500
|
|
13291
|
+
});
|
|
13292
|
+
};
|
|
13293
|
+
var unescapeVueStyles = (ssrBody) => {
|
|
13294
|
+
let styles = "";
|
|
13295
|
+
const body = ssrBody.replace(/<style>([\s\S]*?)<\/style>/g, (_, css) => {
|
|
13296
|
+
styles += `<style>${css.replace(/"/g, '"').replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")}</style>`;
|
|
13297
|
+
return "";
|
|
13298
|
+
});
|
|
13299
|
+
return { body, styles };
|
|
13300
|
+
};
|
|
13301
|
+
var renderVueError = async (conventionPath, errorProps) => {
|
|
13302
|
+
const { createSSRApp, h } = await import("vue");
|
|
13303
|
+
const { renderToString } = await import("vue/server-renderer");
|
|
13304
|
+
const mod = await import(conventionPath);
|
|
13305
|
+
const ErrorComponent = mod.default;
|
|
13306
|
+
const app = createSSRApp({
|
|
13307
|
+
render: () => h(ErrorComponent, errorProps)
|
|
13308
|
+
});
|
|
13309
|
+
const rawBody = await renderToString(app);
|
|
13310
|
+
const { styles, body } = unescapeVueStyles(rawBody);
|
|
13311
|
+
const html = `<!DOCTYPE html><html><head>${styles}</head><body><div id="root">${body}</div></body></html>`;
|
|
13312
|
+
return new Response(html, {
|
|
13313
|
+
headers: { "Content-Type": "text/html" },
|
|
13314
|
+
status: 500
|
|
13315
|
+
});
|
|
13316
|
+
};
|
|
13317
|
+
var renderAngularError = async (conventionPath, errorProps) => {
|
|
13318
|
+
const mod = await import(conventionPath);
|
|
13319
|
+
const renderError = mod.default ?? mod.renderError;
|
|
13320
|
+
if (typeof renderError !== "function")
|
|
13321
|
+
return null;
|
|
13322
|
+
const html = renderError(errorProps);
|
|
13323
|
+
return new Response(html, {
|
|
13324
|
+
headers: { "Content-Type": "text/html" },
|
|
13325
|
+
status: 500
|
|
13326
|
+
});
|
|
13327
|
+
};
|
|
13328
|
+
var logConventionRenderError = (framework, label, renderError) => {
|
|
13329
|
+
const message = renderError instanceof Error ? renderError.message : "";
|
|
13330
|
+
if (message.includes("Cannot find module") || message.includes("Cannot find package") || message.includes("not found in module")) {
|
|
13331
|
+
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}).`);
|
|
13332
|
+
return;
|
|
13333
|
+
}
|
|
13334
|
+
console.error(`[SSR] Failed to render ${framework} convention ${label} page:`, renderError);
|
|
13335
|
+
};
|
|
13336
|
+
var ERROR_RENDERERS = {
|
|
13337
|
+
angular: renderAngularError,
|
|
13338
|
+
react: renderReactError,
|
|
13339
|
+
svelte: renderSvelteError,
|
|
13340
|
+
vue: renderVueError
|
|
13341
|
+
};
|
|
13342
|
+
var renderConventionError = async (framework, pageName, error) => {
|
|
13343
|
+
const conventionPath = resolveErrorConventionPath(framework, pageName);
|
|
13344
|
+
if (!conventionPath)
|
|
13345
|
+
return null;
|
|
13346
|
+
const errorProps = buildErrorProps(error);
|
|
13347
|
+
const renderer = ERROR_RENDERERS[framework];
|
|
13348
|
+
if (!renderer)
|
|
13349
|
+
return null;
|
|
13350
|
+
try {
|
|
13351
|
+
return await renderer(conventionPath, errorProps);
|
|
13352
|
+
} catch (renderError) {
|
|
13353
|
+
logConventionRenderError(framework, "error", renderError);
|
|
13354
|
+
}
|
|
13355
|
+
return null;
|
|
13356
|
+
};
|
|
13357
|
+
var renderReactNotFound = async (conventionPath) => {
|
|
13358
|
+
const { createElement } = await import("react");
|
|
13359
|
+
const { renderToReadableStream } = await import("react-dom/server");
|
|
13360
|
+
const mod = await import(conventionPath);
|
|
13361
|
+
const [nfKey] = Object.keys(mod);
|
|
13362
|
+
const NotFoundComponent = mod.default ?? (nfKey ? mod[nfKey] : undefined);
|
|
13363
|
+
const element = createElement(NotFoundComponent);
|
|
13364
|
+
const stream = await renderToReadableStream(element);
|
|
13365
|
+
return new Response(stream, {
|
|
13366
|
+
headers: { "Content-Type": "text/html" },
|
|
13367
|
+
status: 404
|
|
13368
|
+
});
|
|
13369
|
+
};
|
|
13370
|
+
var renderSvelteNotFound = async (conventionPath) => {
|
|
13371
|
+
const { render } = await import("svelte/server");
|
|
13372
|
+
const mod = await import(conventionPath);
|
|
13373
|
+
const NotFoundComponent = mod.default;
|
|
13374
|
+
const { head, body } = render(NotFoundComponent);
|
|
13375
|
+
const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
|
|
13376
|
+
return new Response(html, {
|
|
13377
|
+
headers: { "Content-Type": "text/html" },
|
|
13378
|
+
status: 404
|
|
13379
|
+
});
|
|
13380
|
+
};
|
|
13381
|
+
var renderVueNotFound = async (conventionPath) => {
|
|
13382
|
+
const { createSSRApp, h } = await import("vue");
|
|
13383
|
+
const { renderToString } = await import("vue/server-renderer");
|
|
13384
|
+
const mod = await import(conventionPath);
|
|
13385
|
+
const NotFoundComponent = mod.default;
|
|
13386
|
+
const app = createSSRApp({
|
|
13387
|
+
render: () => h(NotFoundComponent)
|
|
13388
|
+
});
|
|
13389
|
+
const rawBody = await renderToString(app);
|
|
13390
|
+
const { styles, body } = unescapeVueStyles(rawBody);
|
|
13391
|
+
const html = `<!DOCTYPE html><html><head>${styles}</head><body><div id="root">${body}</div></body></html>`;
|
|
13392
|
+
return new Response(html, {
|
|
13393
|
+
headers: { "Content-Type": "text/html" },
|
|
13394
|
+
status: 404
|
|
13395
|
+
});
|
|
13396
|
+
};
|
|
13397
|
+
var renderAngularNotFound = async (conventionPath) => {
|
|
13398
|
+
const mod = await import(conventionPath);
|
|
13399
|
+
const renderNotFound = mod.default ?? mod.renderNotFound;
|
|
13400
|
+
if (typeof renderNotFound !== "function")
|
|
13401
|
+
return null;
|
|
13402
|
+
const html = renderNotFound();
|
|
13403
|
+
return new Response(html, {
|
|
13404
|
+
headers: { "Content-Type": "text/html" },
|
|
13405
|
+
status: 404
|
|
13406
|
+
});
|
|
13407
|
+
};
|
|
13408
|
+
var NOT_FOUND_RENDERERS = {
|
|
13409
|
+
angular: renderAngularNotFound,
|
|
13410
|
+
react: renderReactNotFound,
|
|
13411
|
+
svelte: renderSvelteNotFound,
|
|
13412
|
+
vue: renderVueNotFound
|
|
13413
|
+
};
|
|
13414
|
+
var renderConventionNotFound = async (framework) => {
|
|
13415
|
+
const conventionPath = resolveNotFoundConventionPath(framework);
|
|
13416
|
+
if (!conventionPath)
|
|
13417
|
+
return null;
|
|
13418
|
+
const renderer = NOT_FOUND_RENDERERS[framework];
|
|
13419
|
+
if (!renderer)
|
|
13420
|
+
return null;
|
|
13421
|
+
try {
|
|
13422
|
+
return await renderer(conventionPath);
|
|
13423
|
+
} catch (renderError) {
|
|
13424
|
+
logConventionRenderError(framework, "not-found", renderError);
|
|
13425
|
+
}
|
|
13426
|
+
return null;
|
|
13427
|
+
};
|
|
13428
|
+
var NOT_FOUND_PRIORITY = [
|
|
13429
|
+
"react",
|
|
13430
|
+
"svelte",
|
|
13431
|
+
"vue",
|
|
13432
|
+
"angular"
|
|
13433
|
+
];
|
|
13434
|
+
var renderFirstNotFound = async () => {
|
|
13435
|
+
for (const framework of NOT_FOUND_PRIORITY) {
|
|
13436
|
+
if (!getMap()[framework]?.defaults?.notFound)
|
|
13437
|
+
continue;
|
|
13438
|
+
const response = await renderConventionNotFound(framework);
|
|
13439
|
+
if (response)
|
|
13440
|
+
return response;
|
|
13441
|
+
}
|
|
13442
|
+
return null;
|
|
13443
|
+
};
|
|
13444
|
+
|
|
13445
|
+
// src/angular/pageHandler.ts
|
|
13446
|
+
init_registerClientScript();
|
|
13447
|
+
init_angularDeps();
|
|
13448
|
+
|
|
13449
|
+
// src/angular/lowerServerIslands.ts
|
|
13450
|
+
init_renderIslandMarkup();
|
|
13451
|
+
var ANGULAR_ISLAND_TAG_RE = /<absolute-island\b([^>]*)>[\s\S]*?<\/absolute-island>/gi;
|
|
13452
|
+
var ATTRIBUTE_RE = /([A-Za-z_:][-A-Za-z0-9_:.]*)\s*=\s*(?:"([^"]*)"|'([^']*)')/g;
|
|
13453
|
+
var islandFrameworks = [
|
|
13454
|
+
"react",
|
|
13455
|
+
"svelte",
|
|
13456
|
+
"vue",
|
|
13457
|
+
"angular"
|
|
13458
|
+
];
|
|
13459
|
+
var islandHydrationModes = [
|
|
13460
|
+
"load",
|
|
13461
|
+
"idle",
|
|
13462
|
+
"visible",
|
|
13463
|
+
"none"
|
|
13464
|
+
];
|
|
13465
|
+
var decodeHtmlAttribute = (value) => value.replaceAll(""", '"').replaceAll(""", '"').replaceAll("'", "'").replaceAll("'", "'").replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
|
13466
|
+
var isRecord3 = (value) => typeof value === "object" && value !== null;
|
|
13467
|
+
var isIslandFramework = (value) => islandFrameworks.some((framework) => framework === value);
|
|
13468
|
+
var isIslandHydrate = (value) => islandHydrationModes.some((mode) => mode === value);
|
|
13469
|
+
var parseAttributes = (attributeString) => {
|
|
13470
|
+
const attributes = new Map;
|
|
13471
|
+
let match = ATTRIBUTE_RE.exec(attributeString);
|
|
13472
|
+
while (match) {
|
|
13473
|
+
const [, key, doubleQuotedValue, singleQuotedValue] = match;
|
|
13474
|
+
match = ATTRIBUTE_RE.exec(attributeString);
|
|
13475
|
+
if (!key)
|
|
13476
|
+
continue;
|
|
13477
|
+
attributes.set(key, decodeHtmlAttribute(doubleQuotedValue ?? singleQuotedValue ?? ""));
|
|
13478
|
+
}
|
|
13479
|
+
ATTRIBUTE_RE.lastIndex = 0;
|
|
13480
|
+
return attributes;
|
|
13481
|
+
};
|
|
13482
|
+
var parseAngularIslandProps = (attributeString) => {
|
|
13483
|
+
const attributes = parseAttributes(attributeString);
|
|
13484
|
+
const component = attributes.get("component");
|
|
13485
|
+
const framework = attributes.get("framework");
|
|
13486
|
+
const hydrate = attributes.get("hydrate") ?? "load";
|
|
13487
|
+
const serializedProps = attributes.get("data-abs-props") ?? "{}";
|
|
13488
|
+
if (!component || !framework) {
|
|
13489
|
+
return null;
|
|
13490
|
+
}
|
|
13491
|
+
if (!isIslandFramework(framework) || !isIslandHydrate(hydrate)) {
|
|
13492
|
+
return null;
|
|
13493
|
+
}
|
|
13494
|
+
let parsedProps = {};
|
|
13495
|
+
try {
|
|
13496
|
+
const candidate = JSON.parse(serializedProps);
|
|
13497
|
+
parsedProps = isRecord3(candidate) ? candidate : {};
|
|
13498
|
+
} catch {}
|
|
13499
|
+
return {
|
|
13500
|
+
component,
|
|
13501
|
+
framework,
|
|
13502
|
+
hydrate,
|
|
13503
|
+
props: parsedProps
|
|
13504
|
+
};
|
|
13505
|
+
};
|
|
13506
|
+
var lowerAngularServerIslands = async (html) => {
|
|
13507
|
+
if (!ANGULAR_ISLAND_TAG_RE.test(html)) {
|
|
13508
|
+
return html;
|
|
13509
|
+
}
|
|
13510
|
+
const registry = requireCurrentIslandRegistry();
|
|
13511
|
+
ANGULAR_ISLAND_TAG_RE.lastIndex = 0;
|
|
13512
|
+
const segments = [];
|
|
13513
|
+
let lastIndex = 0;
|
|
13514
|
+
let match = ANGULAR_ISLAND_TAG_RE.exec(html);
|
|
13515
|
+
while (match) {
|
|
13516
|
+
const [fullMatch, rawAttributeString] = match;
|
|
13517
|
+
const attributeString = rawAttributeString ?? "";
|
|
13518
|
+
segments.push({
|
|
13519
|
+
before: html.slice(lastIndex, match.index),
|
|
13520
|
+
fullMatch,
|
|
13521
|
+
props: parseAngularIslandProps(attributeString)
|
|
13522
|
+
});
|
|
13523
|
+
lastIndex = match.index + fullMatch.length;
|
|
13524
|
+
match = ANGULAR_ISLAND_TAG_RE.exec(html);
|
|
13525
|
+
}
|
|
13526
|
+
ANGULAR_ISLAND_TAG_RE.lastIndex = 0;
|
|
13527
|
+
const renderedSegments = await Promise.all(segments.map(async (segment) => segment.before + (segment.props ? await renderIslandMarkup(registry, segment.props) : segment.fullMatch)));
|
|
13528
|
+
return renderedSegments.join("") + html.slice(lastIndex);
|
|
13529
|
+
};
|
|
13530
|
+
|
|
13531
|
+
// src/angular/pageHandler.ts
|
|
13532
|
+
init_devRouteRegistrationCallsite();
|
|
13533
|
+
|
|
13534
|
+
// src/angular/ssrSanitizer.ts
|
|
13535
|
+
var escapeHtml = (str) => String(str).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
13536
|
+
var bypassValue = (value) => ({
|
|
13537
|
+
changingThisBreaksApplicationSecurity: value
|
|
13538
|
+
});
|
|
13539
|
+
var ssrSanitizer = null;
|
|
13540
|
+
var getSsrSanitizer = (deps) => {
|
|
13541
|
+
if (ssrSanitizer)
|
|
13542
|
+
return ssrSanitizer;
|
|
13543
|
+
const SsrSanitizerClass = class extends deps.DomSanitizer {
|
|
13544
|
+
sanitize(ctx, value) {
|
|
13545
|
+
if (value === null)
|
|
13546
|
+
return null;
|
|
13547
|
+
let strValue;
|
|
13548
|
+
let isTrustedHtml = false;
|
|
13549
|
+
if (typeof value === "string") {
|
|
13550
|
+
strValue = value;
|
|
13551
|
+
} else if (typeof value === "object" && "changingThisBreaksApplicationSecurity" in value) {
|
|
13552
|
+
strValue = String(value.changingThisBreaksApplicationSecurity);
|
|
13553
|
+
isTrustedHtml = true;
|
|
13554
|
+
} else {
|
|
13555
|
+
strValue = String(value);
|
|
13556
|
+
}
|
|
13557
|
+
if (ctx === deps.SecurityContext.HTML) {
|
|
13558
|
+
if (isTrustedHtml) {
|
|
13559
|
+
return strValue;
|
|
13560
|
+
}
|
|
13561
|
+
return escapeHtml(strValue);
|
|
13562
|
+
}
|
|
13563
|
+
return strValue;
|
|
13564
|
+
}
|
|
13565
|
+
bypassSecurityTrustHtml(value) {
|
|
13566
|
+
return bypassValue(value);
|
|
13567
|
+
}
|
|
13568
|
+
bypassSecurityTrustStyle(value) {
|
|
13569
|
+
return bypassValue(value);
|
|
13570
|
+
}
|
|
13571
|
+
bypassSecurityTrustScript(value) {
|
|
13572
|
+
return bypassValue(value);
|
|
13573
|
+
}
|
|
13574
|
+
bypassSecurityTrustUrl(value) {
|
|
13575
|
+
return bypassValue(value);
|
|
13576
|
+
}
|
|
13577
|
+
bypassSecurityTrustResourceUrl(value) {
|
|
13578
|
+
return bypassValue(value);
|
|
13579
|
+
}
|
|
13580
|
+
};
|
|
13581
|
+
ssrSanitizer = new SsrSanitizerClass;
|
|
13582
|
+
return ssrSanitizer;
|
|
13583
|
+
};
|
|
13584
|
+
var resetSsrSanitizer = () => {
|
|
13585
|
+
ssrSanitizer = null;
|
|
13586
|
+
};
|
|
13587
|
+
|
|
13588
|
+
// src/core/responseEnhancers.ts
|
|
13589
|
+
init_streamingSlots();
|
|
13590
|
+
var toResponse = async (responseLike) => responseLike;
|
|
13591
|
+
var cloneHeaders = (response) => {
|
|
13592
|
+
const headers = new Headers(response.headers);
|
|
13593
|
+
return headers;
|
|
13594
|
+
};
|
|
13595
|
+
var enhanceHtmlResponseWithStreamingSlots = (response, {
|
|
13596
|
+
nonce,
|
|
13597
|
+
onError,
|
|
13598
|
+
runtimePlacement,
|
|
13599
|
+
runtimePreludeScript,
|
|
13600
|
+
streamingSlots = [],
|
|
13601
|
+
policy
|
|
13602
|
+
} = {}) => {
|
|
13603
|
+
if (!response.body || streamingSlots.length === 0) {
|
|
13604
|
+
return response;
|
|
13605
|
+
}
|
|
13606
|
+
const body = appendStreamingSlotPatchesToStream(response.body, streamingSlots, {
|
|
13607
|
+
nonce,
|
|
13608
|
+
onError,
|
|
13609
|
+
policy,
|
|
13610
|
+
runtimePlacement,
|
|
13611
|
+
runtimePreludeScript
|
|
13612
|
+
});
|
|
13613
|
+
return new Response(body, {
|
|
13614
|
+
headers: cloneHeaders(response),
|
|
13615
|
+
status: response.status,
|
|
13616
|
+
statusText: response.statusText
|
|
13617
|
+
});
|
|
13618
|
+
};
|
|
13619
|
+
var withStreamingSlots = async (responseLike, options = {}) => enhanceHtmlResponseWithStreamingSlots(await toResponse(responseLike), options);
|
|
13620
|
+
var mergeStreamingSlots = (registered, explicit) => {
|
|
13621
|
+
const merged = new Map;
|
|
13622
|
+
for (const slot of registered)
|
|
13623
|
+
merged.set(slot.id, slot);
|
|
13624
|
+
for (const slot of explicit)
|
|
13625
|
+
merged.set(slot.id, slot);
|
|
13626
|
+
return [...merged.values()];
|
|
13627
|
+
};
|
|
13628
|
+
var withRegisteredStreamingSlots = async (renderResponse, options = {}) => {
|
|
13629
|
+
const { result, slots } = await runWithStreamingSlotRegistry(renderResponse);
|
|
13630
|
+
const explicit = options.streamingSlots ?? [];
|
|
13631
|
+
return withStreamingSlots(result, {
|
|
13632
|
+
...options,
|
|
13633
|
+
streamingSlots: mergeStreamingSlots(slots, explicit)
|
|
13634
|
+
});
|
|
13635
|
+
};
|
|
13636
|
+
|
|
13637
|
+
// src/core/streamingSlotWarningScope.ts
|
|
13638
|
+
init_logger();
|
|
13639
|
+
import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
|
|
13640
|
+
var STREAMING_SLOT_WARNING_STORAGE_KEY2 = Symbol.for("absolutejs.streamingSlotWarningAsyncLocalStorage");
|
|
13641
|
+
var isObjectRecord4 = (value) => Boolean(value) && typeof value === "object";
|
|
13642
|
+
var isAsyncLocalStorage3 = (value) => isObjectRecord4(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function";
|
|
13643
|
+
var getWarningStorage = () => {
|
|
13644
|
+
const value = Reflect.get(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY2);
|
|
13645
|
+
if (value === null || typeof value === "undefined") {
|
|
13646
|
+
return;
|
|
13647
|
+
}
|
|
13648
|
+
return isAsyncLocalStorage3(value) ? value : undefined;
|
|
13649
|
+
};
|
|
13650
|
+
var ensureWarningStorage = () => {
|
|
13651
|
+
const existing = getWarningStorage();
|
|
13652
|
+
if (existing) {
|
|
13653
|
+
return existing;
|
|
13654
|
+
}
|
|
13655
|
+
const storage = new AsyncLocalStorage2;
|
|
13656
|
+
Reflect.set(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY2, storage);
|
|
13657
|
+
return storage;
|
|
13658
|
+
};
|
|
13659
|
+
var normalizeCallsitePath2 = (value) => value.replace(`${process.cwd()}/`, "").replace(process.cwd(), "").replace(/^\.\/+/, "");
|
|
13660
|
+
var formatWarningCallsite = (callsite) => {
|
|
13661
|
+
const match = callsite.match(/^(.*?)(:\d+:\d+)$/);
|
|
13662
|
+
if (!match) {
|
|
13663
|
+
return `\x1B[36m${callsite}\x1B[0m`;
|
|
13664
|
+
}
|
|
13665
|
+
return `\x1B[36m${match[1]}\x1B[33m${match[2]}\x1B[0m`;
|
|
13666
|
+
};
|
|
13667
|
+
var extractCallsiteFromStack = (stack) => {
|
|
13668
|
+
const frames = stack.split(`
|
|
13669
|
+
`).slice(1).map((line) => line.trim());
|
|
13670
|
+
for (const frame of frames) {
|
|
13671
|
+
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.")) {
|
|
13672
|
+
continue;
|
|
13673
|
+
}
|
|
13674
|
+
const locationMatch = frame.match(/\((\/[^)]+:\d+:\d+)\)$/) ?? frame.match(/at (\/[^ ]+:\d+:\d+)$/);
|
|
13675
|
+
if (locationMatch?.[1]) {
|
|
13676
|
+
return normalizeCallsitePath2(locationMatch[1]);
|
|
13677
|
+
}
|
|
13678
|
+
}
|
|
13679
|
+
return;
|
|
13680
|
+
};
|
|
13681
|
+
var buildMissingCollectorWarning = (primitiveName, handlerCallsite) => `${primitiveName} rendered during SSR without streaming slot collection enabled. Add { collectStreamingSlots: true } to this page handler to enable out-of-order streaming for this route.${handlerCallsite ? ` Update ${formatWarningCallsite(handlerCallsite)}.` : ""}`;
|
|
13682
|
+
setStreamingSlotWarningController({
|
|
13683
|
+
maybeWarn: (primitiveName) => {
|
|
13684
|
+
const store = getWarningStorage()?.getStore();
|
|
13685
|
+
if (!store || store.hasWarned) {
|
|
13686
|
+
return;
|
|
13687
|
+
}
|
|
13688
|
+
store.hasWarned = true;
|
|
13689
|
+
logWarn(buildMissingCollectorWarning(primitiveName, store.handlerCallsite));
|
|
13690
|
+
}
|
|
13691
|
+
});
|
|
13692
|
+
var captureStreamingSlotWarningCallsite = () => {
|
|
13693
|
+
if (false) {}
|
|
13694
|
+
const { stack } = new Error;
|
|
13695
|
+
if (!stack) {
|
|
13696
|
+
return;
|
|
13697
|
+
}
|
|
13698
|
+
return extractCallsiteFromStack(stack);
|
|
13699
|
+
};
|
|
13700
|
+
var runWithStreamingSlotWarningScope = (task, metadata) => ensureWarningStorage().run({ handlerCallsite: metadata?.handlerCallsite, hasWarned: false }, task);
|
|
13701
|
+
|
|
13702
|
+
// src/angular/pageHandler.ts
|
|
13703
|
+
init_ssrCache();
|
|
13704
|
+
init_ssrRender();
|
|
13705
|
+
var lastSelector = "angular-page";
|
|
13706
|
+
var isRecord5 = (value) => typeof value === "object" && value !== null;
|
|
13707
|
+
var isAngularComponent = (value) => typeof value === "function";
|
|
13708
|
+
var compilerImportPromise = null;
|
|
13709
|
+
var ensureAngularCompiler = () => {
|
|
13710
|
+
if (!compilerImportPromise) {
|
|
13711
|
+
compilerImportPromise = import("@angular/compiler");
|
|
13712
|
+
}
|
|
13713
|
+
return compilerImportPromise;
|
|
13714
|
+
};
|
|
13715
|
+
var readAngularPageModule = (value) => isRecord5(value) ? value : null;
|
|
13716
|
+
var resolveAngularSsrOutDir = () => process.env.ABSOLUTE_ANGULAR_SSR_OUTDIR ?? join6(tmpdir(), "absolutejs", "generated", "angular-ssr");
|
|
13717
|
+
var ensureAngularSsrNodeModules = async (outDir) => {
|
|
13718
|
+
const outRoot = resolve7(dirname5(dirname5(outDir)));
|
|
13719
|
+
const nodeModulesLink = join6(outRoot, "node_modules");
|
|
13720
|
+
if (process.env.ABSOLUTE_ANGULAR_SSR_OUTDIR) {
|
|
13721
|
+
return;
|
|
13722
|
+
}
|
|
13723
|
+
if (nodeModulesLink === resolve7(process.cwd(), "node_modules")) {
|
|
13724
|
+
return;
|
|
13725
|
+
}
|
|
13726
|
+
if (await Bun.file(nodeModulesLink).exists()) {
|
|
13727
|
+
return;
|
|
13728
|
+
}
|
|
13729
|
+
await mkdir2(outRoot, { recursive: true });
|
|
13730
|
+
try {
|
|
13731
|
+
await symlink(resolve7(process.cwd(), "node_modules"), nodeModulesLink, "dir");
|
|
13732
|
+
} catch (error) {
|
|
13733
|
+
if (!(error instanceof Error) || !("code" in error) || error.code !== "EEXIST") {
|
|
13734
|
+
throw error;
|
|
13735
|
+
}
|
|
13736
|
+
}
|
|
13737
|
+
};
|
|
13738
|
+
var resolveRuntimeAngularModulePath = async (pagePath) => {
|
|
13739
|
+
if (!pagePath.endsWith(".ts")) {
|
|
13740
|
+
return pagePath;
|
|
13741
|
+
}
|
|
13742
|
+
const outDir = resolveAngularSsrOutDir();
|
|
13743
|
+
await ensureAngularSsrNodeModules(outDir);
|
|
13744
|
+
const { compileAngularFileJIT: compileAngularFileJIT2 } = await Promise.resolve().then(() => (init_compileAngular(), exports_compileAngular));
|
|
13745
|
+
const outputs = await compileAngularFileJIT2(pagePath, outDir, process.cwd());
|
|
13746
|
+
const expectedFileName = basename4(pagePath).replace(/\.ts$/, ".js");
|
|
13747
|
+
return outputs.find((output) => output.endsWith(`/${expectedFileName}`)) ?? outputs.find((output) => output.endsWith(`\\${expectedFileName}`)) ?? outputs[0] ?? pagePath;
|
|
13748
|
+
};
|
|
13749
|
+
var angularSsrContext = new AsyncLocalStorage3;
|
|
13750
|
+
setSsrContextGetter(() => angularSsrContext.getStore());
|
|
13751
|
+
var handleAngularPageRequest = async (PageOrInput, pagePath, indexPath, headTag = "<head></head>", ...args) => {
|
|
13752
|
+
const requestId = `angular_${Date.now()}_${Math.random().toString(BASE_36_RADIX).substring(2, RANDOM_ID_END_INDEX)}`;
|
|
13753
|
+
return angularSsrContext.run(requestId, async () => {
|
|
13754
|
+
await ensureAngularCompiler();
|
|
13755
|
+
const {
|
|
13756
|
+
headTag: resolvedHeadTag,
|
|
13757
|
+
indexPath: resolvedIndexPath,
|
|
13758
|
+
options,
|
|
13759
|
+
pagePath: resolvedPagePath,
|
|
13760
|
+
props: maybeProps
|
|
13761
|
+
} = typeof PageOrInput === "object" && PageOrInput !== null && "pagePath" in PageOrInput && "indexPath" in PageOrInput ? {
|
|
13762
|
+
headTag: PageOrInput.headTag ?? "<head></head>",
|
|
13763
|
+
indexPath: PageOrInput.indexPath,
|
|
13764
|
+
options: PageOrInput,
|
|
13765
|
+
pagePath: PageOrInput.pagePath,
|
|
13766
|
+
props: PageOrInput.props
|
|
13767
|
+
} : {
|
|
13768
|
+
headTag,
|
|
13769
|
+
indexPath: indexPath ?? "",
|
|
13770
|
+
options: args[1],
|
|
13771
|
+
pagePath: pagePath ?? "",
|
|
13772
|
+
props: args[0]
|
|
13773
|
+
};
|
|
13774
|
+
cacheRouteData(resolvedPagePath, {
|
|
13775
|
+
headTag: resolvedHeadTag,
|
|
13776
|
+
props: maybeProps
|
|
13777
|
+
});
|
|
13778
|
+
if (isSsrCacheDirty("angular")) {
|
|
13779
|
+
clearSelectorCache();
|
|
13780
|
+
const script = resolvedIndexPath ? `<script>import(${JSON.stringify(resolvedIndexPath)});</script>` : "";
|
|
13781
|
+
const html = `<!DOCTYPE html><html>${resolvedHeadTag}<body><${lastSelector}></${lastSelector}>${script}</body></html>`;
|
|
13782
|
+
return new Response(html, {
|
|
13783
|
+
headers: { "Content-Type": "text/html" }
|
|
13784
|
+
});
|
|
13785
|
+
}
|
|
13786
|
+
try {
|
|
13787
|
+
const handlerCallsite = options?.collectStreamingSlots === true ? undefined : getCurrentRouteRegistrationCallsite() ?? captureStreamingSlotWarningCallsite();
|
|
13788
|
+
const renderPageResponse = async () => {
|
|
13789
|
+
const baseDeps = await getAngularDeps();
|
|
13790
|
+
const runtimePagePath = await resolveRuntimeAngularModulePath(resolvedPagePath);
|
|
13791
|
+
const importedPageModule = await import(runtimePagePath);
|
|
13792
|
+
const pageModule = readAngularPageModule(importedPageModule);
|
|
13793
|
+
if (!pageModule) {
|
|
13794
|
+
throw new Error(`Invalid Angular page module: ${resolvedPagePath}`);
|
|
13795
|
+
}
|
|
13796
|
+
const PageComponent = pageModule.default;
|
|
13797
|
+
if (!isAngularComponent(PageComponent)) {
|
|
13798
|
+
throw new Error(`Angular page module must export a component by default: ${resolvedPagePath}`);
|
|
13799
|
+
}
|
|
13800
|
+
const hasIslands = typeof pageModule.__ABSOLUTE_PAGE_HAS_ISLANDS__ === "boolean" ? pageModule.__ABSOLUTE_PAGE_HAS_ISLANDS__ : false;
|
|
13801
|
+
const ssrResult = await loadSsrDeps(runtimePagePath);
|
|
13802
|
+
const deps = buildDeps(ssrResult, baseDeps);
|
|
13803
|
+
const tokenMap = discoverTokens(pageModule);
|
|
13804
|
+
const selector = resolveSelector(deps, resolvedPagePath, PageComponent);
|
|
13805
|
+
lastSelector = selector;
|
|
13806
|
+
const htmlString = `<!DOCTYPE html><html>${resolvedHeadTag}<body><${selector}></${selector}></body></html>`;
|
|
13807
|
+
if (ssrResult?.core)
|
|
13808
|
+
resetSsrSanitizer();
|
|
13809
|
+
const sanitizer = getSsrSanitizer(deps);
|
|
13810
|
+
const providers = buildProviders(deps, sanitizer, maybeProps, tokenMap);
|
|
13811
|
+
const rawHtml = await renderAngularApp(deps, PageComponent, providers, htmlString);
|
|
13812
|
+
const shouldProcessIslands = hasIslands || rawHtml.includes("<absolute-island");
|
|
13813
|
+
const htmlWithLoweredIslands = shouldProcessIslands ? await lowerAngularServerIslands(rawHtml) : rawHtml;
|
|
13814
|
+
const html = injectIslandPageContext(injectSsrScripts(htmlWithLoweredIslands, requestId, resolvedIndexPath, maybeProps), { hasIslands: shouldProcessIslands });
|
|
13815
|
+
return new Response(html, {
|
|
13816
|
+
headers: { "Content-Type": "text/html" }
|
|
13817
|
+
});
|
|
13818
|
+
};
|
|
13819
|
+
return runWithStreamingSlotWarningScope(() => options?.collectStreamingSlots === true ? withRegisteredStreamingSlots(renderPageResponse, options) : renderPageResponse(), { handlerCallsite });
|
|
13820
|
+
} catch (error) {
|
|
13821
|
+
console.error("[SSR] Angular render error:", error);
|
|
13822
|
+
const pageName = derivePageName(resolvedPagePath);
|
|
13823
|
+
const conventionResponse = await renderConventionError("angular", pageName, error);
|
|
13824
|
+
if (conventionResponse)
|
|
13825
|
+
return conventionResponse;
|
|
13826
|
+
return new Response(ssrErrorPage("angular", error), {
|
|
13827
|
+
headers: { "Content-Type": "text/html" },
|
|
13828
|
+
status: 500
|
|
13829
|
+
});
|
|
13830
|
+
}
|
|
13831
|
+
});
|
|
13832
|
+
};
|
|
13756
13833
|
// src/angular/createIsland.ts
|
|
13757
13834
|
init_renderIslandMarkup();
|
|
13758
13835
|
var createTypedIsland = (registry) => (props) => renderIslandMarkup(registry, props);
|
|
@@ -13941,7 +14018,6 @@ var IslandStore = IslandStoreImpl;
|
|
|
13941
14018
|
init_renderIslandMarkup();
|
|
13942
14019
|
var renderIsland = (props) => renderIslandMarkup(requireCurrentIslandRegistry(), props);
|
|
13943
14020
|
// src/angular/components/stream-slot.component.ts
|
|
13944
|
-
init_streamingSlotRegistrar();
|
|
13945
14021
|
import {
|
|
13946
14022
|
ChangeDetectionStrategy,
|
|
13947
14023
|
ChangeDetectorRef,
|
|
@@ -14060,5 +14136,5 @@ export {
|
|
|
14060
14136
|
Island
|
|
14061
14137
|
};
|
|
14062
14138
|
|
|
14063
|
-
//# debugId=
|
|
14139
|
+
//# debugId=40D4057260EEC49C64756E2164756E21
|
|
14064
14140
|
//# sourceMappingURL=index.js.map
|