@absolutejs/absolute 0.12.4 → 0.12.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/index.d.ts +0 -1
- package/dist/core/pageHandlers.d.ts +0 -7
- package/dist/index.js +109 -908
- package/dist/index.js.map +6 -8
- package/package.json +3 -19
- package/dist/build/compileAngular.d.ts +0 -5
- package/dist/core/angularPatch.d.ts +0 -3
package/dist/index.js
CHANGED
|
@@ -1,22 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
-
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
-
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
-
for (let key of __getOwnPropNames(mod))
|
|
11
|
-
if (!__hasOwnProp.call(to, key))
|
|
12
|
-
__defProp(to, key, {
|
|
13
|
-
get: () => mod[key],
|
|
14
|
-
enumerable: true
|
|
15
|
-
});
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __require = import.meta.require;
|
|
19
|
-
|
|
20
2
|
// src/constants.ts
|
|
21
3
|
var UNFOUND_INDEX = -1;
|
|
22
4
|
var SECONDS_IN_A_MINUTE = 60;
|
|
@@ -31,638 +13,23 @@ var DEFAULT_PORT = 3000;
|
|
|
31
13
|
var DEFAULT_CHUNK_SIZE = 16384;
|
|
32
14
|
var BUN_BUILD_WARNING_SUPPRESSION = "wildcard sideEffects are not supported yet";
|
|
33
15
|
var ANGULAR_BUILD_WARNING_SUPPRESSION = "@angular/common/package.json";
|
|
34
|
-
// src/core/angularPatch.ts
|
|
35
|
-
function getStackTrace() {
|
|
36
|
-
const stack = new Error().stack;
|
|
37
|
-
return stack ? stack.split(`
|
|
38
|
-
`).slice(2, 10).join(`
|
|
39
|
-
`) : "No stack trace available";
|
|
40
|
-
}
|
|
41
|
-
function createDocumentProxy(doc) {
|
|
42
|
-
if (!doc || typeof doc !== "object")
|
|
43
|
-
return doc;
|
|
44
|
-
if (doc.__absolutejs_proxied)
|
|
45
|
-
return doc;
|
|
46
|
-
console.log("\uD83D\uDD0D [ANGULAR PATCH] Creating document proxy:", {
|
|
47
|
-
hasHead: !!doc.head,
|
|
48
|
-
headIsNull: doc.head === null,
|
|
49
|
-
headType: typeof doc.head,
|
|
50
|
-
stack: getStackTrace()
|
|
51
|
-
});
|
|
52
|
-
if (doc.head === null || doc.head === undefined) {
|
|
53
|
-
const fakeHead = {
|
|
54
|
-
children: []
|
|
55
|
-
};
|
|
56
|
-
fakeHead.children.length = 0;
|
|
57
|
-
Object.defineProperty(fakeHead, "item", {
|
|
58
|
-
value: () => null,
|
|
59
|
-
writable: false,
|
|
60
|
-
enumerable: false,
|
|
61
|
-
configurable: false
|
|
62
|
-
});
|
|
63
|
-
try {
|
|
64
|
-
Object.defineProperty(doc, "head", {
|
|
65
|
-
value: fakeHead,
|
|
66
|
-
writable: true,
|
|
67
|
-
enumerable: true,
|
|
68
|
-
configurable: true
|
|
69
|
-
});
|
|
70
|
-
} catch (error) {}
|
|
71
|
-
} else if (doc.head && typeof doc.head === "object") {
|
|
72
|
-
if (!doc.head.children || typeof doc.head.children.length === "undefined") {
|
|
73
|
-
const elementNodes = Array.from(doc.head.childNodes || []).filter((node) => node.nodeType === 1);
|
|
74
|
-
const childrenArray = [];
|
|
75
|
-
elementNodes.forEach((node, index) => {
|
|
76
|
-
childrenArray[index] = node;
|
|
77
|
-
});
|
|
78
|
-
childrenArray.length = elementNodes.length;
|
|
79
|
-
try {
|
|
80
|
-
Object.defineProperty(doc.head, "children", {
|
|
81
|
-
value: childrenArray,
|
|
82
|
-
writable: false,
|
|
83
|
-
enumerable: true,
|
|
84
|
-
configurable: false
|
|
85
|
-
});
|
|
86
|
-
} catch (error) {}
|
|
87
|
-
}
|
|
88
|
-
if (doc.head && typeof doc.head.querySelectorAll !== "function") {
|
|
89
|
-
try {
|
|
90
|
-
Object.defineProperty(doc.head, "querySelectorAll", {
|
|
91
|
-
value: function(selector) {
|
|
92
|
-
if (doc.querySelectorAll) {
|
|
93
|
-
const all = doc.querySelectorAll(selector);
|
|
94
|
-
return Array.from(all).filter((el) => el.parentElement === doc.head || doc.head.contains(el));
|
|
95
|
-
}
|
|
96
|
-
return [];
|
|
97
|
-
},
|
|
98
|
-
writable: true,
|
|
99
|
-
enumerable: false,
|
|
100
|
-
configurable: true
|
|
101
|
-
});
|
|
102
|
-
} catch (error) {}
|
|
103
|
-
}
|
|
104
|
-
if (doc.head && typeof doc.head.querySelector !== "function") {
|
|
105
|
-
try {
|
|
106
|
-
Object.defineProperty(doc.head, "querySelector", {
|
|
107
|
-
value: function(selector) {
|
|
108
|
-
if (doc.querySelector) {
|
|
109
|
-
const el = doc.querySelector(selector);
|
|
110
|
-
if (el && (el.parentElement === doc.head || doc.head.contains(el))) {
|
|
111
|
-
return el;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return null;
|
|
115
|
-
},
|
|
116
|
-
writable: true,
|
|
117
|
-
enumerable: false,
|
|
118
|
-
configurable: true
|
|
119
|
-
});
|
|
120
|
-
} catch (error) {}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
const proxy = new Proxy(doc, {
|
|
124
|
-
get(target, prop) {
|
|
125
|
-
if (prop === "head") {
|
|
126
|
-
console.log("\uD83D\uDD0D [ANGULAR PATCH] Proxy: head property accessed:", {
|
|
127
|
-
hasHead: !!target.head,
|
|
128
|
-
headIsNull: target.head === null,
|
|
129
|
-
headType: typeof target.head,
|
|
130
|
-
stack: getStackTrace()
|
|
131
|
-
});
|
|
132
|
-
const head = target.head;
|
|
133
|
-
if (!head || head === null) {
|
|
134
|
-
console.warn("\u26A0\uFE0F [ANGULAR PATCH] Proxy: head is null, returning fake head proxy");
|
|
135
|
-
return new Proxy({}, {
|
|
136
|
-
get(_target, headProp) {
|
|
137
|
-
console.log("\uD83D\uDD0D [ANGULAR PATCH] Fake head proxy: property accessed:", headProp, {
|
|
138
|
-
stack: getStackTrace()
|
|
139
|
-
});
|
|
140
|
-
if (headProp === "children") {
|
|
141
|
-
console.log("\u2705 [ANGULAR PATCH] Fake head proxy: returning empty children array");
|
|
142
|
-
const emptyChildren = [];
|
|
143
|
-
emptyChildren.length = 0;
|
|
144
|
-
Object.defineProperty(emptyChildren, "item", {
|
|
145
|
-
value: () => null,
|
|
146
|
-
writable: false,
|
|
147
|
-
enumerable: false,
|
|
148
|
-
configurable: false
|
|
149
|
-
});
|
|
150
|
-
return emptyChildren;
|
|
151
|
-
}
|
|
152
|
-
if (headProp === "querySelectorAll") {
|
|
153
|
-
return function(selector) {
|
|
154
|
-
const emptyNodeList = [];
|
|
155
|
-
emptyNodeList.length = 0;
|
|
156
|
-
return emptyNodeList;
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
if (headProp === "querySelector") {
|
|
160
|
-
return function(selector) {
|
|
161
|
-
return null;
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
return;
|
|
165
|
-
},
|
|
166
|
-
has() {
|
|
167
|
-
return true;
|
|
168
|
-
},
|
|
169
|
-
ownKeys() {
|
|
170
|
-
return ["children"];
|
|
171
|
-
},
|
|
172
|
-
getOwnPropertyDescriptor() {
|
|
173
|
-
return {
|
|
174
|
-
enumerable: true,
|
|
175
|
-
configurable: false,
|
|
176
|
-
writable: false,
|
|
177
|
-
value: []
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
if (head && typeof head === "object") {
|
|
183
|
-
return createHeadProxy(head);
|
|
184
|
-
}
|
|
185
|
-
return head;
|
|
186
|
-
}
|
|
187
|
-
const value = target[prop];
|
|
188
|
-
if (typeof value === "function") {
|
|
189
|
-
return value.bind(target);
|
|
190
|
-
}
|
|
191
|
-
return value;
|
|
192
|
-
},
|
|
193
|
-
set(target, prop, value) {
|
|
194
|
-
target[prop] = value;
|
|
195
|
-
return true;
|
|
196
|
-
},
|
|
197
|
-
has(target, prop) {
|
|
198
|
-
return prop in target;
|
|
199
|
-
},
|
|
200
|
-
ownKeys(target) {
|
|
201
|
-
return Reflect.ownKeys(target);
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
Object.defineProperty(doc, "__absolutejs_proxied", {
|
|
205
|
-
value: true,
|
|
206
|
-
writable: false,
|
|
207
|
-
configurable: false,
|
|
208
|
-
enumerable: false
|
|
209
|
-
});
|
|
210
|
-
return proxy;
|
|
211
|
-
}
|
|
212
|
-
function createHeadProxy(head) {
|
|
213
|
-
if (head && typeof head === "object") {
|
|
214
|
-
if (typeof head.querySelectorAll !== "function") {
|
|
215
|
-
try {
|
|
216
|
-
Object.defineProperty(head, "querySelectorAll", {
|
|
217
|
-
value: function(selector) {
|
|
218
|
-
if (head.ownerDocument && head.ownerDocument.querySelectorAll) {
|
|
219
|
-
const all = head.ownerDocument.querySelectorAll(selector);
|
|
220
|
-
return Array.from(all).filter((el) => el.parentElement === head || head.contains(el));
|
|
221
|
-
}
|
|
222
|
-
return [];
|
|
223
|
-
},
|
|
224
|
-
writable: true,
|
|
225
|
-
enumerable: false,
|
|
226
|
-
configurable: true
|
|
227
|
-
});
|
|
228
|
-
} catch (e) {}
|
|
229
|
-
}
|
|
230
|
-
if (typeof head.querySelector !== "function") {
|
|
231
|
-
try {
|
|
232
|
-
Object.defineProperty(head, "querySelector", {
|
|
233
|
-
value: function(selector) {
|
|
234
|
-
if (head.ownerDocument && head.ownerDocument.querySelector) {
|
|
235
|
-
const el = head.ownerDocument.querySelector(selector);
|
|
236
|
-
if (el && (el.parentElement === head || head.contains(el))) {
|
|
237
|
-
return el;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
return null;
|
|
241
|
-
},
|
|
242
|
-
writable: true,
|
|
243
|
-
enumerable: false,
|
|
244
|
-
configurable: true
|
|
245
|
-
});
|
|
246
|
-
} catch (e) {}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
if (!head || typeof head !== "object")
|
|
250
|
-
return head;
|
|
251
|
-
if (head.__absolutejs_head_proxied)
|
|
252
|
-
return head;
|
|
253
|
-
const proxy = new Proxy(head, {
|
|
254
|
-
get(target, prop) {
|
|
255
|
-
if (prop === "children") {
|
|
256
|
-
const children = target.children;
|
|
257
|
-
if (!children || typeof children.length === "undefined") {
|
|
258
|
-
const elementNodes = Array.from(target.childNodes || []).filter((node) => node.nodeType === 1);
|
|
259
|
-
const childrenArray = [];
|
|
260
|
-
elementNodes.forEach((node, index) => {
|
|
261
|
-
childrenArray[index] = node;
|
|
262
|
-
});
|
|
263
|
-
childrenArray.length = elementNodes.length;
|
|
264
|
-
return childrenArray;
|
|
265
|
-
}
|
|
266
|
-
return children;
|
|
267
|
-
}
|
|
268
|
-
if (prop === "querySelectorAll" && typeof target.querySelectorAll !== "function") {
|
|
269
|
-
return function(selector) {
|
|
270
|
-
if (target.ownerDocument && target.ownerDocument.querySelectorAll) {
|
|
271
|
-
const all = target.ownerDocument.querySelectorAll(selector);
|
|
272
|
-
return Array.from(all).filter((el) => el.parentElement === target || target.contains(el));
|
|
273
|
-
}
|
|
274
|
-
return [];
|
|
275
|
-
};
|
|
276
|
-
}
|
|
277
|
-
if (prop === "querySelector" && typeof target.querySelector !== "function") {
|
|
278
|
-
return function(selector) {
|
|
279
|
-
if (target.ownerDocument && target.ownerDocument.querySelector) {
|
|
280
|
-
const el = target.ownerDocument.querySelector(selector);
|
|
281
|
-
if (el && (el.parentElement === target || target.contains(el))) {
|
|
282
|
-
return el;
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
return null;
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
const value = target[prop];
|
|
289
|
-
if (typeof value === "function") {
|
|
290
|
-
return value.bind(target);
|
|
291
|
-
}
|
|
292
|
-
return value;
|
|
293
|
-
}
|
|
294
|
-
});
|
|
295
|
-
Object.defineProperty(head, "__absolutejs_head_proxied", {
|
|
296
|
-
value: true,
|
|
297
|
-
writable: false,
|
|
298
|
-
configurable: false,
|
|
299
|
-
enumerable: false
|
|
300
|
-
});
|
|
301
|
-
return proxy;
|
|
302
|
-
}
|
|
303
|
-
var patchesApplied = (async () => {
|
|
304
|
-
try {
|
|
305
|
-
try {
|
|
306
|
-
const originalErrorHandler = globalThis.onerror;
|
|
307
|
-
globalThis.onerror = function(message, source, lineno, colno, error) {
|
|
308
|
-
if (typeof message === "string" && message.includes("doc.head.children")) {
|
|
309
|
-
console.error("\uD83D\uDEA8 [ANGULAR PATCH] Caught doc.head.children error:", {
|
|
310
|
-
message,
|
|
311
|
-
source,
|
|
312
|
-
lineno,
|
|
313
|
-
colno,
|
|
314
|
-
error,
|
|
315
|
-
stack: error?.stack || "No stack trace"
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
if (originalErrorHandler) {
|
|
319
|
-
return originalErrorHandler.call(this, message, source, lineno, colno, error);
|
|
320
|
-
}
|
|
321
|
-
return false;
|
|
322
|
-
};
|
|
323
|
-
} catch (error) {
|
|
324
|
-
console.warn("\u26A0\uFE0F [ANGULAR PATCH] Failed to set global error handler:", error);
|
|
325
|
-
}
|
|
326
|
-
try {
|
|
327
|
-
const originalUnhandledRejection = globalThis.onunhandledrejection;
|
|
328
|
-
globalThis.onunhandledrejection = function(event) {
|
|
329
|
-
if (event.reason && typeof event.reason === "object" && event.reason.message && event.reason.message.includes("doc.head.children")) {
|
|
330
|
-
console.error("\uD83D\uDEA8 [ANGULAR PATCH] Unhandled rejection with doc.head.children error:", {
|
|
331
|
-
reason: event.reason,
|
|
332
|
-
stack: event.reason?.stack || "No stack trace"
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
|
-
if (originalUnhandledRejection) {
|
|
336
|
-
return originalUnhandledRejection.call(this, event);
|
|
337
|
-
}
|
|
338
|
-
};
|
|
339
|
-
} catch (error) {
|
|
340
|
-
console.warn("\u26A0\uFE0F [ANGULAR PATCH] Failed to set unhandled rejection handler:", error);
|
|
341
|
-
}
|
|
342
|
-
const [common, platformServer] = await Promise.all([
|
|
343
|
-
import("@angular/common"),
|
|
344
|
-
import("@angular/platform-server")
|
|
345
|
-
]);
|
|
346
|
-
console.log("\u2705 [ANGULAR PATCH] Angular modules imported, starting patches...");
|
|
347
|
-
const _getDOM = common.\u{275}getDOM;
|
|
348
|
-
if (_getDOM) {
|
|
349
|
-
const originalGetDOM = _getDOM;
|
|
350
|
-
try {
|
|
351
|
-
Object.defineProperty(common, "\u0275getDOM", {
|
|
352
|
-
value: function() {
|
|
353
|
-
const domAdapter = originalGetDOM();
|
|
354
|
-
if (domAdapter && typeof domAdapter.getBaseHref === "function") {
|
|
355
|
-
const adapter = domAdapter;
|
|
356
|
-
if (!adapter.__absolutejs_originalGetBaseHref) {
|
|
357
|
-
adapter.__absolutejs_originalGetBaseHref = domAdapter.getBaseHref.bind(domAdapter);
|
|
358
|
-
}
|
|
359
|
-
Object.defineProperty(domAdapter, "getBaseHref", {
|
|
360
|
-
value: function(doc) {
|
|
361
|
-
console.log("\uD83D\uDD0D [ANGULAR PATCH] getBaseHref called via _getDOM():", {
|
|
362
|
-
hasDoc: !!doc,
|
|
363
|
-
hasHead: !!doc?.head,
|
|
364
|
-
headIsNull: doc?.head === null,
|
|
365
|
-
headType: typeof doc?.head,
|
|
366
|
-
hasChildren: !!doc?.head?.children,
|
|
367
|
-
childrenType: typeof doc?.head?.children,
|
|
368
|
-
stack: getStackTrace()
|
|
369
|
-
});
|
|
370
|
-
if (!doc || !doc.head || typeof doc.head.children === "undefined") {
|
|
371
|
-
console.warn("\u26A0\uFE0F [ANGULAR PATCH] getBaseHref (_getDOM): Returning empty string due to null/undefined head or children");
|
|
372
|
-
return "";
|
|
373
|
-
}
|
|
374
|
-
const result = adapter.__absolutejs_originalGetBaseHref.call(this, doc);
|
|
375
|
-
console.log("\u2705 [ANGULAR PATCH] getBaseHref (_getDOM) result:", result);
|
|
376
|
-
return result;
|
|
377
|
-
},
|
|
378
|
-
writable: false,
|
|
379
|
-
configurable: false,
|
|
380
|
-
enumerable: true
|
|
381
|
-
});
|
|
382
|
-
}
|
|
383
|
-
return domAdapter;
|
|
384
|
-
},
|
|
385
|
-
writable: true,
|
|
386
|
-
configurable: true,
|
|
387
|
-
enumerable: true
|
|
388
|
-
});
|
|
389
|
-
} catch (error) {
|
|
390
|
-
console.warn("\u26A0\uFE0F [ANGULAR PATCH] Failed to patch _getDOM via defineProperty, trying direct assignment:", error);
|
|
391
|
-
try {
|
|
392
|
-
common.\u{275}getDOM = function() {
|
|
393
|
-
const domAdapter = originalGetDOM();
|
|
394
|
-
if (domAdapter && typeof domAdapter.getBaseHref === "function") {
|
|
395
|
-
const adapter = domAdapter;
|
|
396
|
-
if (!adapter.__absolutejs_originalGetBaseHref) {
|
|
397
|
-
adapter.__absolutejs_originalGetBaseHref = domAdapter.getBaseHref.bind(domAdapter);
|
|
398
|
-
}
|
|
399
|
-
Object.defineProperty(domAdapter, "getBaseHref", {
|
|
400
|
-
value: function(doc) {
|
|
401
|
-
if (!doc || !doc.head || typeof doc.head.children === "undefined") {
|
|
402
|
-
return "";
|
|
403
|
-
}
|
|
404
|
-
return adapter.__absolutejs_originalGetBaseHref.call(this, doc);
|
|
405
|
-
},
|
|
406
|
-
writable: false,
|
|
407
|
-
configurable: false,
|
|
408
|
-
enumerable: true
|
|
409
|
-
});
|
|
410
|
-
}
|
|
411
|
-
return domAdapter;
|
|
412
|
-
};
|
|
413
|
-
} catch (assignError) {
|
|
414
|
-
console.warn("\u26A0\uFE0F [ANGULAR PATCH] Failed to patch _getDOM via direct assignment:", assignError);
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
const DominoAdapter = platformServer.DominoAdapter;
|
|
419
|
-
if (DominoAdapter && DominoAdapter.prototype) {
|
|
420
|
-
const prototype = DominoAdapter.prototype;
|
|
421
|
-
if (prototype.getBaseHref && !prototype.__absolutejs_originalGetBaseHref) {
|
|
422
|
-
prototype.__absolutejs_originalGetBaseHref = prototype.getBaseHref;
|
|
423
|
-
prototype.getBaseHref = function(doc) {
|
|
424
|
-
console.log("\uD83D\uDD0D [ANGULAR PATCH] getBaseHref called on DominoAdapter.prototype:", {
|
|
425
|
-
hasDoc: !!doc,
|
|
426
|
-
hasHead: !!doc?.head,
|
|
427
|
-
headIsNull: doc?.head === null,
|
|
428
|
-
headType: typeof doc?.head,
|
|
429
|
-
hasChildren: !!doc?.head?.children,
|
|
430
|
-
childrenType: typeof doc?.head?.children,
|
|
431
|
-
stack: getStackTrace()
|
|
432
|
-
});
|
|
433
|
-
if (!doc || !doc.head || typeof doc.head.children === "undefined") {
|
|
434
|
-
console.warn("\u26A0\uFE0F [ANGULAR PATCH] getBaseHref: Returning empty string due to null/undefined head or children");
|
|
435
|
-
return "";
|
|
436
|
-
}
|
|
437
|
-
const result = prototype.__absolutejs_originalGetBaseHref.call(this, doc);
|
|
438
|
-
console.log("\u2705 [ANGULAR PATCH] getBaseHref result:", result);
|
|
439
|
-
return result;
|
|
440
|
-
};
|
|
441
|
-
}
|
|
442
|
-
if (prototype.createHtmlDocument && !prototype.__absolutejs_originalCreateHtmlDocument) {
|
|
443
|
-
prototype.__absolutejs_originalCreateHtmlDocument = prototype.createHtmlDocument;
|
|
444
|
-
prototype.createHtmlDocument = function() {
|
|
445
|
-
console.log("\uD83D\uDD0D [ANGULAR PATCH] createHtmlDocument called");
|
|
446
|
-
const doc = prototype.__absolutejs_originalCreateHtmlDocument.call(this);
|
|
447
|
-
console.log("\uD83D\uDD0D [ANGULAR PATCH] createHtmlDocument result:", {
|
|
448
|
-
hasDoc: !!doc,
|
|
449
|
-
hasHead: !!doc?.head,
|
|
450
|
-
headIsNull: doc?.head === null,
|
|
451
|
-
stack: getStackTrace()
|
|
452
|
-
});
|
|
453
|
-
return createDocumentProxy(doc);
|
|
454
|
-
};
|
|
455
|
-
}
|
|
456
|
-
if (prototype.getDefaultDocument && !prototype.__absolutejs_originalGetDefaultDocument) {
|
|
457
|
-
prototype.__absolutejs_originalGetDefaultDocument = prototype.getDefaultDocument;
|
|
458
|
-
prototype.getDefaultDocument = function() {
|
|
459
|
-
const doc = prototype.__absolutejs_originalGetDefaultDocument.call(this);
|
|
460
|
-
return createDocumentProxy(doc);
|
|
461
|
-
};
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
try {
|
|
465
|
-
const domino = await import("domino").catch(() => null);
|
|
466
|
-
if (domino) {
|
|
467
|
-
if (domino.createWindow && !domino.__absolutejs_originalCreateWindow) {
|
|
468
|
-
domino.__absolutejs_originalCreateWindow = domino.createWindow;
|
|
469
|
-
domino.createWindow = function(html, url) {
|
|
470
|
-
const window = domino.__absolutejs_originalCreateWindow(html, url);
|
|
471
|
-
if (window && window.document) {
|
|
472
|
-
window.document = createDocumentProxy(window.document);
|
|
473
|
-
}
|
|
474
|
-
return window;
|
|
475
|
-
};
|
|
476
|
-
}
|
|
477
|
-
if (domino.createDocument && !domino.__absolutejs_originalCreateDocument) {
|
|
478
|
-
domino.__absolutejs_originalCreateDocument = domino.createDocument;
|
|
479
|
-
domino.createDocument = function(html) {
|
|
480
|
-
const doc = domino.__absolutejs_originalCreateDocument(html);
|
|
481
|
-
return createDocumentProxy(doc);
|
|
482
|
-
};
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
} catch (error) {}
|
|
486
|
-
try {
|
|
487
|
-
const serverModule = platformServer;
|
|
488
|
-
if (serverModule._document || platformServer.\u{275}_document) {
|
|
489
|
-
const originalDocument = serverModule._document || platformServer.\u{275}_document;
|
|
490
|
-
if (typeof originalDocument === "function") {
|
|
491
|
-
platformServer._document = function(injector) {
|
|
492
|
-
const doc = originalDocument(injector);
|
|
493
|
-
return createDocumentProxy(doc);
|
|
494
|
-
};
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
} catch (error) {}
|
|
498
|
-
console.log("\u2705 Angular SSR patches applied at module resolution time");
|
|
499
|
-
return true;
|
|
500
|
-
} catch (error) {
|
|
501
|
-
console.warn("\u26A0\uFE0F Failed to apply Angular SSR patches at module resolution time:", error);
|
|
502
|
-
return false;
|
|
503
|
-
}
|
|
504
|
-
})();
|
|
505
|
-
var angularPatch_default = patchesApplied;
|
|
506
|
-
|
|
507
16
|
// src/core/build.ts
|
|
508
17
|
import { copyFileSync, cpSync, mkdirSync } from "fs";
|
|
509
18
|
import { rm as rm3 } from "fs/promises";
|
|
510
|
-
import { basename as
|
|
19
|
+
import { basename as basename4, join as join5 } from "path";
|
|
511
20
|
import { cwd, env as env2, exit } from "process";
|
|
512
21
|
var {$, build: bunBuild, Glob: Glob3 } = globalThis.Bun;
|
|
513
22
|
|
|
514
|
-
// src/build/compileAngular.ts
|
|
515
|
-
import { promises as fs } from "fs";
|
|
516
|
-
import { join, basename, sep, dirname, resolve, relative } from "path";
|
|
517
|
-
import {
|
|
518
|
-
readConfiguration,
|
|
519
|
-
performCompilation,
|
|
520
|
-
EmitFlags
|
|
521
|
-
} from "@angular/compiler-cli";
|
|
522
|
-
import ts from "typescript";
|
|
523
|
-
|
|
524
|
-
// src/utils/stringModifiers.ts
|
|
525
|
-
var normalizeSlug = (str) => str.trim().replace(/\s+/g, "-").replace(/[^A-Za-z0-9\-_]+/g, "").replace(/[-_]{2,}/g, "-");
|
|
526
|
-
var toPascal = (str) => {
|
|
527
|
-
if (!str.includes("-") && !str.includes("_")) {
|
|
528
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
529
|
-
}
|
|
530
|
-
return normalizeSlug(str).split(/[-_]/).filter(Boolean).map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1).toLowerCase()).join("");
|
|
531
|
-
};
|
|
532
|
-
var toKebab = (str) => normalizeSlug(str).replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
533
|
-
|
|
534
|
-
// src/build/compileAngular.ts
|
|
535
|
-
var compileAngularFile = async (inputPath, outDir) => {
|
|
536
|
-
const tsPath = __require.resolve("typescript");
|
|
537
|
-
const tsRootDir = dirname(tsPath);
|
|
538
|
-
const tsLibDir = tsRootDir.endsWith("lib") ? tsRootDir : resolve(tsRootDir, "lib");
|
|
539
|
-
const config = readConfiguration("./tsconfig.json");
|
|
540
|
-
const options = {
|
|
541
|
-
newLine: ts.NewLineKind.LineFeed,
|
|
542
|
-
target: ts.ScriptTarget.ES2022,
|
|
543
|
-
module: ts.ModuleKind.ESNext,
|
|
544
|
-
outDir,
|
|
545
|
-
experimentalDecorators: false,
|
|
546
|
-
emitDecoratorMetadata: false,
|
|
547
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
548
|
-
esModuleInterop: true,
|
|
549
|
-
skipLibCheck: true,
|
|
550
|
-
noLib: false,
|
|
551
|
-
...config.options
|
|
552
|
-
};
|
|
553
|
-
options.target = ts.ScriptTarget.ES2022;
|
|
554
|
-
options.newLine = ts.NewLineKind.LineFeed;
|
|
555
|
-
const host = ts.createCompilerHost(options);
|
|
556
|
-
const originalGetDefaultLibLocation = host.getDefaultLibLocation;
|
|
557
|
-
host.getDefaultLibLocation = () => {
|
|
558
|
-
return tsLibDir || (originalGetDefaultLibLocation ? originalGetDefaultLibLocation() : "");
|
|
559
|
-
};
|
|
560
|
-
const originalGetDefaultLibFileName = host.getDefaultLibFileName;
|
|
561
|
-
host.getDefaultLibFileName = (opts) => {
|
|
562
|
-
const fileName = originalGetDefaultLibFileName ? originalGetDefaultLibFileName(opts) : "lib.d.ts";
|
|
563
|
-
return basename(fileName);
|
|
564
|
-
};
|
|
565
|
-
const originalGetSourceFile = host.getSourceFile;
|
|
566
|
-
host.getSourceFile = (fileName, languageVersion, onError) => {
|
|
567
|
-
if (fileName.startsWith("lib.") && fileName.endsWith(".d.ts") && tsLibDir) {
|
|
568
|
-
const resolvedPath = join(tsLibDir, fileName);
|
|
569
|
-
return originalGetSourceFile?.call(host, resolvedPath, languageVersion, onError);
|
|
570
|
-
}
|
|
571
|
-
return originalGetSourceFile?.call(host, fileName, languageVersion, onError);
|
|
572
|
-
};
|
|
573
|
-
const emitted = {};
|
|
574
|
-
host.writeFile = (fileName, text) => {
|
|
575
|
-
const relativePath = fileName.startsWith(outDir) ? fileName.substring(outDir.length + 1) : fileName;
|
|
576
|
-
emitted[relativePath] = text;
|
|
577
|
-
};
|
|
578
|
-
const { diagnostics } = performCompilation({
|
|
579
|
-
emitFlags: EmitFlags.Default,
|
|
580
|
-
host,
|
|
581
|
-
options,
|
|
582
|
-
rootNames: [inputPath]
|
|
583
|
-
});
|
|
584
|
-
if (diagnostics?.length) {
|
|
585
|
-
const errors = diagnostics.filter((d) => d.category === ts.DiagnosticCategory.Error);
|
|
586
|
-
if (errors.length) {
|
|
587
|
-
throw new Error(errors.map((diagnostic) => ts.flattenDiagnosticMessageText(diagnostic.messageText, `
|
|
588
|
-
`)).join(`
|
|
589
|
-
`));
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
const entries = Object.entries(emitted).filter(([fileName]) => fileName.endsWith(".js")).map(([fileName, content]) => {
|
|
593
|
-
const target = join(outDir, fileName);
|
|
594
|
-
let processedContent = content.replace(/from\s+(['"])(\.\.?\/[^'"]+)(\1)/g, (match, quote, path) => {
|
|
595
|
-
if (!path.match(/\.(js|ts|mjs|cjs)$/)) {
|
|
596
|
-
return `from ${quote}${path}.js${quote}`;
|
|
597
|
-
}
|
|
598
|
-
return match;
|
|
599
|
-
});
|
|
600
|
-
processedContent = processedContent.replace(/\u0275\u0275domElementStart/g, "\u0275\u0275elementStart").replace(/\u0275\u0275domElementEnd/g, "\u0275\u0275elementEnd").replace(/\u0275\u0275domElement\(/g, "\u0275\u0275element(").replace(/\u0275\u0275domProperty/g, "\u0275\u0275property").replace(/\u0275\u0275domListener/g, "\u0275\u0275listener");
|
|
601
|
-
processedContent = processedContent.replace(/import\s*{\s*([^}]*)\bInjectFlags\b([^}]*)\s*}\s*from\s*['"]@angular\/core['"]/g, (match, before, after) => {
|
|
602
|
-
const cleaned = (before + after).replace(/,\s*,/g, ",").replace(/^\s*,\s*/, "").replace(/,\s*$/, "");
|
|
603
|
-
return cleaned ? `import { ${cleaned}, InternalInjectFlags } from '@angular/core'` : `import { InternalInjectFlags } from '@angular/core'`;
|
|
604
|
-
});
|
|
605
|
-
processedContent = processedContent.replace(/\bInjectFlags\b/g, "InternalInjectFlags");
|
|
606
|
-
return { content: processedContent, target };
|
|
607
|
-
});
|
|
608
|
-
await Promise.all(entries.map(({ target }) => fs.mkdir(dirname(target), { recursive: true })));
|
|
609
|
-
await Promise.all(entries.map(({ target, content }) => fs.writeFile(target, content, "utf-8")));
|
|
610
|
-
return entries.map(({ target }) => target);
|
|
611
|
-
};
|
|
612
|
-
var compileAngular = async (entryPoints, outRoot) => {
|
|
613
|
-
const compiledRoot = join(outRoot, "compiled");
|
|
614
|
-
const indexesDir = join(compiledRoot, "indexes");
|
|
615
|
-
await fs.rm(compiledRoot, { force: true, recursive: true });
|
|
616
|
-
await fs.mkdir(indexesDir, { recursive: true });
|
|
617
|
-
const compileTasks = entryPoints.map(async (entry) => {
|
|
618
|
-
const outputs = await compileAngularFile(entry, compiledRoot);
|
|
619
|
-
const fileBase = basename(entry).replace(/\.[tj]s$/, "");
|
|
620
|
-
const jsName = `${fileBase}.js`;
|
|
621
|
-
let rawServerFile = outputs.find((f) => f.endsWith(`${sep}pages${sep}${jsName}`));
|
|
622
|
-
if (!rawServerFile) {
|
|
623
|
-
rawServerFile = outputs.find((f) => f.endsWith(`${sep}${jsName}`));
|
|
624
|
-
}
|
|
625
|
-
if (!rawServerFile) {
|
|
626
|
-
throw new Error(`Compiled output not found for ${entry}. Looking for: ${jsName}. Available: ${outputs.join(", ")}`);
|
|
627
|
-
}
|
|
628
|
-
const original = await fs.readFile(rawServerFile, "utf-8");
|
|
629
|
-
const componentClassName = `${toPascal(fileBase)}Component`;
|
|
630
|
-
let rewritten = original.replace(new RegExp(`templateUrl:\\s*['"]\\.\\/${fileBase}\\.html['"]`), `templateUrl: '../../pages/${fileBase}.html'`);
|
|
631
|
-
if (!rewritten.includes("export default")) {
|
|
632
|
-
rewritten += `
|
|
633
|
-
export default ${componentClassName};
|
|
634
|
-
`;
|
|
635
|
-
}
|
|
636
|
-
await fs.writeFile(rawServerFile, rewritten, "utf-8");
|
|
637
|
-
const relativePath = relative(indexesDir, rawServerFile).replace(/\\/g, "/");
|
|
638
|
-
const normalizedImportPath = relativePath.startsWith(".") ? relativePath : "./" + relativePath;
|
|
639
|
-
const clientFile = join(indexesDir, jsName);
|
|
640
|
-
const hydration = `
|
|
641
|
-
import { bootstrapApplication } from '@angular/platform-browser';
|
|
642
|
-
import { provideClientHydration } from '@angular/platform-browser';
|
|
643
|
-
import ${componentClassName} from '${normalizedImportPath}';
|
|
644
|
-
|
|
645
|
-
bootstrapApplication(${componentClassName}, { providers: [provideClientHydration()] });
|
|
646
|
-
`.trim();
|
|
647
|
-
await fs.writeFile(clientFile, hydration, "utf-8");
|
|
648
|
-
return { clientPath: clientFile, serverPath: rawServerFile };
|
|
649
|
-
});
|
|
650
|
-
const results = await Promise.all(compileTasks);
|
|
651
|
-
const serverPaths = results.map((r) => r.serverPath);
|
|
652
|
-
const clientPaths = results.map((r) => r.clientPath);
|
|
653
|
-
return { clientPaths, serverPaths };
|
|
654
|
-
};
|
|
655
|
-
|
|
656
23
|
// src/build/compileSvelte.ts
|
|
657
24
|
import { mkdir, stat } from "fs/promises";
|
|
658
25
|
import {
|
|
659
|
-
dirname
|
|
660
|
-
join
|
|
661
|
-
basename
|
|
26
|
+
dirname,
|
|
27
|
+
join,
|
|
28
|
+
basename,
|
|
662
29
|
extname,
|
|
663
|
-
resolve
|
|
664
|
-
relative
|
|
665
|
-
sep
|
|
30
|
+
resolve,
|
|
31
|
+
relative,
|
|
32
|
+
sep
|
|
666
33
|
} from "path";
|
|
667
34
|
import { env } from "process";
|
|
668
35
|
var {write, file, Transpiler } = globalThis.Bun;
|
|
@@ -677,7 +44,7 @@ var exists = async (path) => {
|
|
|
677
44
|
}
|
|
678
45
|
};
|
|
679
46
|
var resolveSvelte = async (spec, from) => {
|
|
680
|
-
const basePath =
|
|
47
|
+
const basePath = resolve(dirname(from), spec);
|
|
681
48
|
const explicit = /\.(svelte|svelte\.(?:ts|js))$/.test(basePath);
|
|
682
49
|
if (!explicit) {
|
|
683
50
|
const extensions = [".svelte", ".svelte.ts", ".svelte.js"];
|
|
@@ -699,10 +66,10 @@ var resolveSvelte = async (spec, from) => {
|
|
|
699
66
|
return null;
|
|
700
67
|
};
|
|
701
68
|
var compileSvelte = async (entryPoints, svelteRoot, cache = new Map) => {
|
|
702
|
-
const compiledRoot =
|
|
703
|
-
const clientDir =
|
|
704
|
-
const indexDir =
|
|
705
|
-
const pagesDir =
|
|
69
|
+
const compiledRoot = join(svelteRoot, "compiled");
|
|
70
|
+
const clientDir = join(compiledRoot, "client");
|
|
71
|
+
const indexDir = join(compiledRoot, "indexes");
|
|
72
|
+
const pagesDir = join(compiledRoot, "pages");
|
|
706
73
|
await Promise.all([clientDir, indexDir, pagesDir].map((dir) => mkdir(dir, { recursive: true })));
|
|
707
74
|
const dev = env.NODE_ENV === "development";
|
|
708
75
|
const build = async (src) => {
|
|
@@ -713,8 +80,8 @@ var compileSvelte = async (entryPoints, svelteRoot, cache = new Map) => {
|
|
|
713
80
|
const isModule = src.endsWith(".svelte.ts") || src.endsWith(".svelte.js");
|
|
714
81
|
const preprocessed = isModule ? raw : (await preprocess(raw, {})).code;
|
|
715
82
|
const transpiled = src.endsWith(".ts") || src.endsWith(".svelte.ts") ? transpiler.transformSync(preprocessed) : preprocessed;
|
|
716
|
-
const relDir =
|
|
717
|
-
const baseName =
|
|
83
|
+
const relDir = dirname(relative(svelteRoot, src)).replace(/\\/g, "/");
|
|
84
|
+
const baseName = basename(src).replace(/\.svelte(\.(ts|js))?$/, "");
|
|
718
85
|
const importPaths = Array.from(transpiled.matchAll(/from\s+['"]([^'"]+)['"]/g)).map((match) => match[1]).filter((path) => path !== undefined);
|
|
719
86
|
const resolvedImports = await Promise.all(importPaths.map((importPath) => resolveSvelte(importPath, src)));
|
|
720
87
|
const childSources = resolvedImports.filter((path) => path !== null);
|
|
@@ -725,11 +92,11 @@ var compileSvelte = async (entryPoints, svelteRoot, cache = new Map) => {
|
|
|
725
92
|
filename: src,
|
|
726
93
|
generate: mode
|
|
727
94
|
}).js.code).replace(/\.svelte(?:\.(?:ts|js))?(['"])/g, ".js$1");
|
|
728
|
-
const ssrPath =
|
|
729
|
-
const clientPath =
|
|
95
|
+
const ssrPath = join(pagesDir, relDir, `${baseName}.js`);
|
|
96
|
+
const clientPath = join(clientDir, relDir, `${baseName}.js`);
|
|
730
97
|
await Promise.all([
|
|
731
|
-
mkdir(
|
|
732
|
-
mkdir(
|
|
98
|
+
mkdir(dirname(ssrPath), { recursive: true }),
|
|
99
|
+
mkdir(dirname(clientPath), { recursive: true })
|
|
733
100
|
]);
|
|
734
101
|
if (isModule) {
|
|
735
102
|
const bundle = generate("client");
|
|
@@ -751,21 +118,21 @@ var compileSvelte = async (entryPoints, svelteRoot, cache = new Map) => {
|
|
|
751
118
|
};
|
|
752
119
|
const roots = await Promise.all(entryPoints.map(build));
|
|
753
120
|
await Promise.all(roots.map(async ({ client }) => {
|
|
754
|
-
const relClientDir =
|
|
755
|
-
const name =
|
|
756
|
-
const indexPath =
|
|
757
|
-
const importRaw =
|
|
121
|
+
const relClientDir = dirname(relative(clientDir, client));
|
|
122
|
+
const name = basename(client, extname(client));
|
|
123
|
+
const indexPath = join(indexDir, relClientDir, `${name}.js`);
|
|
124
|
+
const importRaw = relative(dirname(indexPath), client).split(sep).join("/");
|
|
758
125
|
const importPath = importRaw.startsWith(".") || importRaw.startsWith("/") ? importRaw : `./${importRaw}`;
|
|
759
126
|
const bootstrap = `import C from "${importPath}";
|
|
760
127
|
import { hydrate } from "svelte";
|
|
761
128
|
hydrate(C,{target:document.body,props:window.__INITIAL_PROPS__??{}});`;
|
|
762
|
-
await mkdir(
|
|
129
|
+
await mkdir(dirname(indexPath), { recursive: true });
|
|
763
130
|
return write(indexPath, bootstrap);
|
|
764
131
|
}));
|
|
765
132
|
return {
|
|
766
133
|
svelteClientPaths: roots.map(({ client }) => {
|
|
767
|
-
const rel =
|
|
768
|
-
return
|
|
134
|
+
const rel = dirname(relative(clientDir, client));
|
|
135
|
+
return join(indexDir, rel, basename(client));
|
|
769
136
|
}),
|
|
770
137
|
svelteServerPaths: roots.map(({ ssr }) => ssr)
|
|
771
138
|
};
|
|
@@ -773,7 +140,7 @@ hydrate(C,{target:document.body,props:window.__INITIAL_PROPS__??{}});`;
|
|
|
773
140
|
|
|
774
141
|
// src/build/compileVue.ts
|
|
775
142
|
import { mkdir as mkdir2 } from "fs/promises";
|
|
776
|
-
import { basename as
|
|
143
|
+
import { basename as basename2, dirname as dirname2, join as join2, relative as relative2, resolve as resolve2 } from "path";
|
|
777
144
|
import {
|
|
778
145
|
parse,
|
|
779
146
|
compileScript,
|
|
@@ -781,6 +148,18 @@ import {
|
|
|
781
148
|
compileStyle
|
|
782
149
|
} from "@vue/compiler-sfc";
|
|
783
150
|
var {file: file2, write: write2, Transpiler: Transpiler2 } = globalThis.Bun;
|
|
151
|
+
|
|
152
|
+
// src/utils/stringModifiers.ts
|
|
153
|
+
var normalizeSlug = (str) => str.trim().replace(/\s+/g, "-").replace(/[^A-Za-z0-9\-_]+/g, "").replace(/[-_]{2,}/g, "-");
|
|
154
|
+
var toPascal = (str) => {
|
|
155
|
+
if (!str.includes("-") && !str.includes("_")) {
|
|
156
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
157
|
+
}
|
|
158
|
+
return normalizeSlug(str).split(/[-_]/).filter(Boolean).map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1).toLowerCase()).join("");
|
|
159
|
+
};
|
|
160
|
+
var toKebab = (str) => normalizeSlug(str).replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
161
|
+
|
|
162
|
+
// src/build/compileVue.ts
|
|
784
163
|
var transpiler2 = new Transpiler2({ loader: "ts", target: "browser" });
|
|
785
164
|
var extractImports = (sourceCode) => Array.from(sourceCode.matchAll(/import\s+[\s\S]+?['"]([^'"]+)['"]/g)).map((match) => match[1]).filter((importPath) => importPath !== undefined);
|
|
786
165
|
var toJs = (filePath) => {
|
|
@@ -813,9 +192,9 @@ var compileVueFile = async (sourceFilePath, outputDirs, cacheMap, isEntryPoint,
|
|
|
813
192
|
const cachedResult = cacheMap.get(sourceFilePath);
|
|
814
193
|
if (cachedResult)
|
|
815
194
|
return cachedResult;
|
|
816
|
-
const relativeFilePath =
|
|
195
|
+
const relativeFilePath = relative2(vueRootDir, sourceFilePath).replace(/\\/g, "/");
|
|
817
196
|
const relativeWithoutExtension = relativeFilePath.replace(/\.vue$/, "");
|
|
818
|
-
const fileBaseName =
|
|
197
|
+
const fileBaseName = basename2(sourceFilePath, ".vue");
|
|
819
198
|
const componentId = toKebab(fileBaseName);
|
|
820
199
|
const sourceContent = await file2(sourceFilePath).text();
|
|
821
200
|
const { descriptor } = parse(sourceContent, { filename: sourceFilePath });
|
|
@@ -823,7 +202,7 @@ var compileVueFile = async (sourceFilePath, outputDirs, cacheMap, isEntryPoint,
|
|
|
823
202
|
const importPaths = extractImports(scriptSource);
|
|
824
203
|
const childComponentPaths = importPaths.filter((path) => path.startsWith(".") && path.endsWith(".vue"));
|
|
825
204
|
const helperModulePaths = importPaths.filter((path) => path.startsWith(".") && !path.endsWith(".vue"));
|
|
826
|
-
const childBuildResults = await Promise.all(childComponentPaths.map((relativeChildPath) => compileVueFile(
|
|
205
|
+
const childBuildResults = await Promise.all(childComponentPaths.map((relativeChildPath) => compileVueFile(resolve2(dirname2(sourceFilePath), relativeChildPath), outputDirs, cacheMap, false, vueRootDir)));
|
|
827
206
|
const compiledScript = compileScript(descriptor, {
|
|
828
207
|
id: componentId,
|
|
829
208
|
inlineTemplate: false
|
|
@@ -855,8 +234,8 @@ var compileVueFile = async (sourceFilePath, outputDirs, cacheMap, isEntryPoint,
|
|
|
855
234
|
];
|
|
856
235
|
let cssOutputPaths = [];
|
|
857
236
|
if (isEntryPoint && allCss.length) {
|
|
858
|
-
const cssOutputFile =
|
|
859
|
-
await mkdir2(
|
|
237
|
+
const cssOutputFile = join2(outputDirs.css, `${toKebab(fileBaseName)}.css`);
|
|
238
|
+
await mkdir2(dirname2(cssOutputFile), { recursive: true });
|
|
860
239
|
await write2(cssOutputFile, allCss.join(`
|
|
861
240
|
`));
|
|
862
241
|
cssOutputPaths = [cssOutputFile];
|
|
@@ -870,10 +249,10 @@ var compileVueFile = async (sourceFilePath, outputDirs, cacheMap, isEntryPoint,
|
|
|
870
249
|
`));
|
|
871
250
|
const clientCode = assembleModule(generateRenderFunction(false), "render");
|
|
872
251
|
const serverCode = assembleModule(generateRenderFunction(true), "ssrRender");
|
|
873
|
-
const clientOutputPath =
|
|
874
|
-
const serverOutputPath =
|
|
875
|
-
await mkdir2(
|
|
876
|
-
await mkdir2(
|
|
252
|
+
const clientOutputPath = join2(outputDirs.client, `${relativeWithoutExtension}.js`);
|
|
253
|
+
const serverOutputPath = join2(outputDirs.server, `${relativeWithoutExtension}.js`);
|
|
254
|
+
await mkdir2(dirname2(clientOutputPath), { recursive: true });
|
|
255
|
+
await mkdir2(dirname2(serverOutputPath), { recursive: true });
|
|
877
256
|
await write2(clientOutputPath, clientCode);
|
|
878
257
|
await write2(serverOutputPath, serverCode);
|
|
879
258
|
const result = {
|
|
@@ -882,7 +261,7 @@ var compileVueFile = async (sourceFilePath, outputDirs, cacheMap, isEntryPoint,
|
|
|
882
261
|
cssPaths: cssOutputPaths,
|
|
883
262
|
serverPath: serverOutputPath,
|
|
884
263
|
tsHelperPaths: [
|
|
885
|
-
...helperModulePaths.map((helper) =>
|
|
264
|
+
...helperModulePaths.map((helper) => resolve2(dirname2(sourceFilePath), helper.endsWith(".ts") ? helper : `${helper}.ts`)),
|
|
886
265
|
...childBuildResults.flatMap((child) => child.tsHelperPaths)
|
|
887
266
|
]
|
|
888
267
|
};
|
|
@@ -890,11 +269,11 @@ var compileVueFile = async (sourceFilePath, outputDirs, cacheMap, isEntryPoint,
|
|
|
890
269
|
return result;
|
|
891
270
|
};
|
|
892
271
|
var compileVue = async (entryPoints, vueRootDir) => {
|
|
893
|
-
const compiledOutputRoot =
|
|
894
|
-
const clientOutputDir =
|
|
895
|
-
const indexOutputDir =
|
|
896
|
-
const serverOutputDir =
|
|
897
|
-
const cssOutputDir =
|
|
272
|
+
const compiledOutputRoot = join2(vueRootDir, "compiled");
|
|
273
|
+
const clientOutputDir = join2(compiledOutputRoot, "client");
|
|
274
|
+
const indexOutputDir = join2(compiledOutputRoot, "indexes");
|
|
275
|
+
const serverOutputDir = join2(compiledOutputRoot, "pages");
|
|
276
|
+
const cssOutputDir = join2(compiledOutputRoot, "styles");
|
|
898
277
|
await Promise.all([
|
|
899
278
|
mkdir2(clientOutputDir, { recursive: true }),
|
|
900
279
|
mkdir2(indexOutputDir, { recursive: true }),
|
|
@@ -904,18 +283,18 @@ var compileVue = async (entryPoints, vueRootDir) => {
|
|
|
904
283
|
const buildCache = new Map;
|
|
905
284
|
const allTsHelperPaths = new Set;
|
|
906
285
|
const compiledPages = await Promise.all(entryPoints.map(async (entryPath) => {
|
|
907
|
-
const result = await compileVueFile(
|
|
286
|
+
const result = await compileVueFile(resolve2(entryPath), {
|
|
908
287
|
client: clientOutputDir,
|
|
909
288
|
css: cssOutputDir,
|
|
910
289
|
server: serverOutputDir
|
|
911
290
|
}, buildCache, true, vueRootDir);
|
|
912
291
|
result.tsHelperPaths.forEach((path) => allTsHelperPaths.add(path));
|
|
913
|
-
const entryBaseName =
|
|
914
|
-
const indexOutputFile =
|
|
915
|
-
const clientOutputFile =
|
|
916
|
-
await mkdir2(
|
|
292
|
+
const entryBaseName = basename2(entryPath, ".vue");
|
|
293
|
+
const indexOutputFile = join2(indexOutputDir, `${entryBaseName}.js`);
|
|
294
|
+
const clientOutputFile = join2(clientOutputDir, relative2(vueRootDir, entryPath).replace(/\\/g, "/").replace(/\.vue$/, ".js"));
|
|
295
|
+
await mkdir2(dirname2(indexOutputFile), { recursive: true });
|
|
917
296
|
await write2(indexOutputFile, [
|
|
918
|
-
`import Comp from "${
|
|
297
|
+
`import Comp from "${relative2(dirname2(indexOutputFile), clientOutputFile)}";`,
|
|
919
298
|
'import { createSSRApp } from "vue";',
|
|
920
299
|
"const props = window.__INITIAL_PROPS__ ?? {};",
|
|
921
300
|
'createSSRApp(Comp, props).mount("#root");'
|
|
@@ -930,11 +309,11 @@ var compileVue = async (entryPoints, vueRootDir) => {
|
|
|
930
309
|
await Promise.all(Array.from(allTsHelperPaths).map(async (tsPath) => {
|
|
931
310
|
const sourceCode = await file2(tsPath).text();
|
|
932
311
|
const transpiledCode = transpiler2.transformSync(sourceCode);
|
|
933
|
-
const relativeJsPath =
|
|
934
|
-
const outClientPath =
|
|
935
|
-
const outServerPath =
|
|
936
|
-
await mkdir2(
|
|
937
|
-
await mkdir2(
|
|
312
|
+
const relativeJsPath = relative2(vueRootDir, tsPath).replace(/\.ts$/, ".js");
|
|
313
|
+
const outClientPath = join2(clientOutputDir, relativeJsPath);
|
|
314
|
+
const outServerPath = join2(serverOutputDir, relativeJsPath);
|
|
315
|
+
await mkdir2(dirname2(outClientPath), { recursive: true });
|
|
316
|
+
await mkdir2(dirname2(outServerPath), { recursive: true });
|
|
938
317
|
await write2(outClientPath, transpiledCode);
|
|
939
318
|
await write2(outServerPath, transpiledCode);
|
|
940
319
|
}));
|
|
@@ -948,9 +327,9 @@ var compileVue = async (entryPoints, vueRootDir) => {
|
|
|
948
327
|
// src/build/generateManifest.ts
|
|
949
328
|
import { extname as extname2 } from "path";
|
|
950
329
|
var generateManifest = (outputs, buildPath) => outputs.reduce((manifest, artifact) => {
|
|
951
|
-
let
|
|
952
|
-
|
|
953
|
-
const segments =
|
|
330
|
+
let relative3 = artifact.path.startsWith(buildPath) ? artifact.path.slice(buildPath.length) : artifact.path;
|
|
331
|
+
relative3 = relative3.replace(/^\/+/, "");
|
|
332
|
+
const segments = relative3.split("/");
|
|
954
333
|
const fileWithHash = segments.pop();
|
|
955
334
|
if (!fileWithHash)
|
|
956
335
|
return manifest;
|
|
@@ -960,24 +339,24 @@ var generateManifest = (outputs, buildPath) => outputs.reduce((manifest, artifac
|
|
|
960
339
|
const pascalName = toPascal(baseName);
|
|
961
340
|
const ext = extname2(fileWithHash);
|
|
962
341
|
if (ext === ".css") {
|
|
963
|
-
manifest[`${pascalName}CSS`] = `/${
|
|
342
|
+
manifest[`${pascalName}CSS`] = `/${relative3}`;
|
|
964
343
|
return manifest;
|
|
965
344
|
}
|
|
966
345
|
const idx = segments.findIndex((seg) => seg === "indexes" || seg === "pages");
|
|
967
346
|
const folder = idx > UNFOUND_INDEX ? segments[idx] : segments[0];
|
|
968
347
|
if (folder === "indexes") {
|
|
969
|
-
manifest[`${pascalName}Index`] = `/${
|
|
348
|
+
manifest[`${pascalName}Index`] = `/${relative3}`;
|
|
970
349
|
} else if (folder === "pages") {
|
|
971
350
|
manifest[pascalName] = artifact.path;
|
|
972
351
|
} else {
|
|
973
|
-
manifest[pascalName] = `/${
|
|
352
|
+
manifest[pascalName] = `/${relative3}`;
|
|
974
353
|
}
|
|
975
354
|
return manifest;
|
|
976
355
|
}, {});
|
|
977
356
|
|
|
978
357
|
// src/build/generateReactIndexes.ts
|
|
979
358
|
import { mkdir as mkdir3, rm, writeFile } from "fs/promises";
|
|
980
|
-
import { basename as
|
|
359
|
+
import { basename as basename3, join as join3 } from "path";
|
|
981
360
|
var {Glob } = globalThis.Bun;
|
|
982
361
|
var generateReactIndexFiles = async (reactPagesDirectory, reactIndexesDirectory) => {
|
|
983
362
|
await rm(reactIndexesDirectory, { force: true, recursive: true });
|
|
@@ -988,7 +367,7 @@ var generateReactIndexFiles = async (reactPagesDirectory, reactIndexesDirectory)
|
|
|
988
367
|
files.push(file3);
|
|
989
368
|
}
|
|
990
369
|
const promises = files.map(async (file3) => {
|
|
991
|
-
const fileName =
|
|
370
|
+
const fileName = basename3(file3);
|
|
992
371
|
const [componentName] = fileName.split(".");
|
|
993
372
|
const content = [
|
|
994
373
|
`import { hydrateRoot } from 'react-dom/client';`,
|
|
@@ -1006,7 +385,7 @@ var generateReactIndexFiles = async (reactPagesDirectory, reactIndexesDirectory)
|
|
|
1006
385
|
`hydrateRoot(document, <${componentName} {...window.__INITIAL_PROPS__} />);`
|
|
1007
386
|
].join(`
|
|
1008
387
|
`);
|
|
1009
|
-
return writeFile(
|
|
388
|
+
return writeFile(join3(reactIndexesDirectory, `${componentName}.tsx`), content);
|
|
1010
389
|
});
|
|
1011
390
|
await Promise.all(promises);
|
|
1012
391
|
};
|
|
@@ -1067,33 +446,33 @@ var updateAssetPaths = async (manifest, directory) => {
|
|
|
1067
446
|
|
|
1068
447
|
// src/utils/cleanup.ts
|
|
1069
448
|
import { rm as rm2 } from "fs/promises";
|
|
1070
|
-
import { join as
|
|
449
|
+
import { join as join4 } from "path";
|
|
1071
450
|
var cleanup = async ({
|
|
1072
451
|
svelteDir,
|
|
1073
452
|
vueDir,
|
|
1074
453
|
reactIndexesPath
|
|
1075
454
|
}) => {
|
|
1076
455
|
if (svelteDir) {
|
|
1077
|
-
await rm2(
|
|
456
|
+
await rm2(join4(svelteDir, "compiled"), { force: true, recursive: true });
|
|
1078
457
|
}
|
|
1079
458
|
if (vueDir) {
|
|
1080
|
-
await rm2(
|
|
459
|
+
await rm2(join4(vueDir, "compiled"), { force: true, recursive: true });
|
|
1081
460
|
}
|
|
1082
461
|
if (reactIndexesPath)
|
|
1083
462
|
await rm2(reactIndexesPath, { force: true, recursive: true });
|
|
1084
463
|
};
|
|
1085
464
|
|
|
1086
465
|
// src/utils/commonAncestor.ts
|
|
1087
|
-
import { sep as
|
|
466
|
+
import { sep as sep2 } from "path";
|
|
1088
467
|
var commonAncestor = (paths, fallback) => {
|
|
1089
468
|
if (paths.length === 0)
|
|
1090
469
|
return fallback;
|
|
1091
|
-
const segmentsList = paths.map((p) => p.split(
|
|
470
|
+
const segmentsList = paths.map((p) => p.split(sep2));
|
|
1092
471
|
const [first] = segmentsList;
|
|
1093
472
|
if (!first)
|
|
1094
473
|
return fallback;
|
|
1095
474
|
const commonSegments = first.filter((segment, index) => segmentsList.every((pathSegs) => pathSegs[index] === segment));
|
|
1096
|
-
return commonSegments.length ? commonSegments.join(
|
|
475
|
+
return commonSegments.length ? commonSegments.join(sep2) : fallback;
|
|
1097
476
|
};
|
|
1098
477
|
|
|
1099
478
|
// src/utils/getDurationString.ts
|
|
@@ -1110,11 +489,11 @@ var getDurationString = (duration) => {
|
|
|
1110
489
|
};
|
|
1111
490
|
|
|
1112
491
|
// src/utils/validateSafePath.ts
|
|
1113
|
-
import { resolve as
|
|
492
|
+
import { resolve as resolve3, relative as relative3, sep as sep3 } from "path";
|
|
1114
493
|
var validateSafePath = (targetPath, baseDirectory) => {
|
|
1115
|
-
const absoluteBase =
|
|
1116
|
-
const absoluteTarget =
|
|
1117
|
-
if (
|
|
494
|
+
const absoluteBase = resolve3(baseDirectory);
|
|
495
|
+
const absoluteTarget = resolve3(baseDirectory, targetPath);
|
|
496
|
+
if (relative3(absoluteBase, absoluteTarget).startsWith(`..${sep3}`)) {
|
|
1118
497
|
throw new Error(`Unsafe path: ${targetPath}`);
|
|
1119
498
|
}
|
|
1120
499
|
return absoluteTarget;
|
|
@@ -1149,14 +528,14 @@ var build = async ({
|
|
|
1149
528
|
const svelteDir = svelteDirectory && validateSafePath(svelteDirectory, projectRoot);
|
|
1150
529
|
const vueDir = vueDirectory && validateSafePath(vueDirectory, projectRoot);
|
|
1151
530
|
const angularDir = angularDirectory && validateSafePath(angularDirectory, projectRoot);
|
|
1152
|
-
const reactIndexesPath = reactDir &&
|
|
1153
|
-
const reactPagesPath = reactDir &&
|
|
1154
|
-
const htmlPagesPath = htmlDir &&
|
|
1155
|
-
const htmlScriptsPath = htmlDir &&
|
|
1156
|
-
const sveltePagesPath = svelteDir &&
|
|
1157
|
-
const vuePagesPath = vueDir &&
|
|
1158
|
-
const htmxPagesPath = htmxDir &&
|
|
1159
|
-
const angularPagesPath = angularDir &&
|
|
531
|
+
const reactIndexesPath = reactDir && join5(reactDir, "indexes");
|
|
532
|
+
const reactPagesPath = reactDir && join5(reactDir, "pages");
|
|
533
|
+
const htmlPagesPath = htmlDir && join5(htmlDir, "pages");
|
|
534
|
+
const htmlScriptsPath = htmlDir && join5(htmlDir, "scripts");
|
|
535
|
+
const sveltePagesPath = svelteDir && join5(svelteDir, "pages");
|
|
536
|
+
const vuePagesPath = vueDir && join5(vueDir, "pages");
|
|
537
|
+
const htmxPagesPath = htmxDir && join5(htmxDir, "pages");
|
|
538
|
+
const angularPagesPath = angularDir && join5(angularDir, "pages");
|
|
1160
539
|
const frontends = [
|
|
1161
540
|
reactDir,
|
|
1162
541
|
htmlDir,
|
|
@@ -1168,9 +547,9 @@ var build = async ({
|
|
|
1168
547
|
const isSingle = frontends.length === 1;
|
|
1169
548
|
let serverOutDir;
|
|
1170
549
|
if (svelteDir)
|
|
1171
|
-
serverOutDir =
|
|
550
|
+
serverOutDir = join5(buildPath, basename4(svelteDir), "pages");
|
|
1172
551
|
else if (vueDir)
|
|
1173
|
-
serverOutDir =
|
|
552
|
+
serverOutDir = join5(buildPath, basename4(vueDir), "pages");
|
|
1174
553
|
let serverRoot;
|
|
1175
554
|
if (sveltePagesPath)
|
|
1176
555
|
serverRoot = sveltePagesPath;
|
|
@@ -1181,36 +560,30 @@ var build = async ({
|
|
|
1181
560
|
if (reactIndexesPath && reactPagesPath)
|
|
1182
561
|
await generateReactIndexFiles(reactPagesPath, reactIndexesPath);
|
|
1183
562
|
if (assetsPath)
|
|
1184
|
-
cpSync(assetsPath,
|
|
563
|
+
cpSync(assetsPath, join5(buildPath, "assets"), {
|
|
1185
564
|
force: true,
|
|
1186
565
|
recursive: true
|
|
1187
566
|
});
|
|
1188
567
|
if (tailwind)
|
|
1189
|
-
await $`bunx @tailwindcss/cli -i ${tailwind.input} -o ${
|
|
568
|
+
await $`bunx @tailwindcss/cli -i ${tailwind.input} -o ${join5(buildPath, tailwind.output)}`;
|
|
1190
569
|
const reactEntries = reactIndexesPath ? await scanEntryPoints(reactIndexesPath, "*.tsx") : [];
|
|
1191
570
|
const htmlEntries = htmlScriptsPath ? await scanEntryPoints(htmlScriptsPath, "*.{js,ts}") : [];
|
|
1192
571
|
const svelteEntries = sveltePagesPath ? await scanEntryPoints(sveltePagesPath, "*.svelte") : [];
|
|
1193
572
|
const vueEntries = vuePagesPath ? await scanEntryPoints(vuePagesPath, "*.vue") : [];
|
|
1194
573
|
const angularEntries = angularPagesPath ? await scanEntryPoints(angularPagesPath, "*.ts") : [];
|
|
1195
|
-
const htmlCssEntries = htmlDir ? await scanEntryPoints(
|
|
1196
|
-
const htmxCssEntries = htmxDir ? await scanEntryPoints(
|
|
1197
|
-
const reactCssEntries = reactDir ? await scanEntryPoints(
|
|
1198
|
-
const svelteCssEntries = svelteDir ? await scanEntryPoints(
|
|
1199
|
-
const angularCssEntries = angularDir ? await scanEntryPoints(
|
|
574
|
+
const htmlCssEntries = htmlDir ? await scanEntryPoints(join5(htmlDir, "styles"), "*.css") : [];
|
|
575
|
+
const htmxCssEntries = htmxDir ? await scanEntryPoints(join5(htmxDir, "styles"), "*.css") : [];
|
|
576
|
+
const reactCssEntries = reactDir ? await scanEntryPoints(join5(reactDir, "styles"), "*.css") : [];
|
|
577
|
+
const svelteCssEntries = svelteDir ? await scanEntryPoints(join5(svelteDir, "styles"), "*.css") : [];
|
|
578
|
+
const angularCssEntries = angularDir ? await scanEntryPoints(join5(angularDir, "styles"), "*.css") : [];
|
|
1200
579
|
const { svelteServerPaths, svelteClientPaths } = svelteDir ? await compileSvelte(svelteEntries, svelteDir) : { svelteClientPaths: [], svelteServerPaths: [] };
|
|
1201
580
|
const { vueServerPaths, vueIndexPaths, vueCssPaths } = vueDir ? await compileVue(vueEntries, vueDir) : { vueCssPaths: [], vueIndexPaths: [], vueServerPaths: [] };
|
|
1202
|
-
const
|
|
1203
|
-
const serverEntryPoints = [
|
|
1204
|
-
...svelteServerPaths,
|
|
1205
|
-
...vueServerPaths,
|
|
1206
|
-
...angularServerPaths
|
|
1207
|
-
];
|
|
581
|
+
const serverEntryPoints = [...svelteServerPaths, ...vueServerPaths];
|
|
1208
582
|
const clientEntryPoints = [
|
|
1209
583
|
...reactEntries,
|
|
1210
584
|
...svelteClientPaths,
|
|
1211
585
|
...htmlEntries,
|
|
1212
|
-
...vueIndexPaths
|
|
1213
|
-
...angularClientPaths
|
|
586
|
+
...vueIndexPaths
|
|
1214
587
|
];
|
|
1215
588
|
const cssEntryPoints = [
|
|
1216
589
|
...vueCssPaths,
|
|
@@ -1274,7 +647,7 @@ var build = async ({
|
|
|
1274
647
|
const { logs, outputs } = await bunBuild({
|
|
1275
648
|
entrypoints: cssEntryPoints,
|
|
1276
649
|
naming: `[name].[hash].[ext]`,
|
|
1277
|
-
outdir:
|
|
650
|
+
outdir: join5(buildPath, basename4(assetsPath), "css"),
|
|
1278
651
|
target: "browser"
|
|
1279
652
|
}).catch((err) => {
|
|
1280
653
|
console.error("CSS build failed:", err);
|
|
@@ -1287,7 +660,7 @@ var build = async ({
|
|
|
1287
660
|
outputLogs(allLogs);
|
|
1288
661
|
const manifest = generateManifest([...serverOutputs, ...clientOutputs, ...cssOutputs], buildPath);
|
|
1289
662
|
if (htmlDir && htmlPagesPath) {
|
|
1290
|
-
const outputHtmlPages = isSingle ?
|
|
663
|
+
const outputHtmlPages = isSingle ? join5(buildPath, "pages") : join5(buildPath, basename4(htmlDir), "pages");
|
|
1291
664
|
mkdirSync(outputHtmlPages, { recursive: true });
|
|
1292
665
|
cpSync(htmlPagesPath, outputHtmlPages, {
|
|
1293
666
|
force: true,
|
|
@@ -1296,18 +669,18 @@ var build = async ({
|
|
|
1296
669
|
await updateAssetPaths(manifest, outputHtmlPages);
|
|
1297
670
|
}
|
|
1298
671
|
if (htmxDir && htmxPagesPath) {
|
|
1299
|
-
const outputHtmxPages = isSingle ?
|
|
672
|
+
const outputHtmxPages = isSingle ? join5(buildPath, "pages") : join5(buildPath, basename4(htmxDir), "pages");
|
|
1300
673
|
mkdirSync(outputHtmxPages, { recursive: true });
|
|
1301
674
|
cpSync(htmxPagesPath, outputHtmxPages, {
|
|
1302
675
|
force: true,
|
|
1303
676
|
recursive: true
|
|
1304
677
|
});
|
|
1305
|
-
const htmxDestDir = isSingle ? buildPath :
|
|
678
|
+
const htmxDestDir = isSingle ? buildPath : join5(buildPath, basename4(htmxDir));
|
|
1306
679
|
mkdirSync(htmxDestDir, { recursive: true });
|
|
1307
680
|
const glob = new Glob3("htmx*.min.js");
|
|
1308
681
|
for (const relativePath of glob.scanSync({ cwd: htmxDir })) {
|
|
1309
|
-
const src =
|
|
1310
|
-
const dest =
|
|
682
|
+
const src = join5(htmxDir, relativePath);
|
|
683
|
+
const dest = join5(htmxDestDir, "htmx.min.js");
|
|
1311
684
|
copyFileSync(src, dest);
|
|
1312
685
|
break;
|
|
1313
686
|
}
|
|
@@ -1323,12 +696,6 @@ var build = async ({
|
|
|
1323
696
|
return manifest;
|
|
1324
697
|
};
|
|
1325
698
|
// src/core/pageHandlers.ts
|
|
1326
|
-
import { bootstrapApplication } from "@angular/platform-browser";
|
|
1327
|
-
import {
|
|
1328
|
-
renderApplication,
|
|
1329
|
-
provideServerRendering
|
|
1330
|
-
} from "@angular/platform-server";
|
|
1331
|
-
import { APP_BASE_HREF } from "@angular/common";
|
|
1332
699
|
var {file: file3 } = globalThis.Bun;
|
|
1333
700
|
import { createElement } from "react";
|
|
1334
701
|
import { renderToReadableStream as renderReactToReadableStream } from "react-dom/server";
|
|
@@ -1419,7 +786,6 @@ var renderToString = (component, props, {
|
|
|
1419
786
|
};
|
|
1420
787
|
|
|
1421
788
|
// src/core/pageHandlers.ts
|
|
1422
|
-
var originalAsyncFunction = (async () => {}).constructor;
|
|
1423
789
|
var handleReactPageRequest = async (pageComponent, index, ...props) => {
|
|
1424
790
|
const [maybeProps] = props;
|
|
1425
791
|
const element = maybeProps !== undefined ? createElement(pageComponent, maybeProps) : createElement(pageComponent);
|
|
@@ -1475,170 +841,6 @@ var handleVuePageRequest = async (_PageComponent, pagePath, indexPath, headTag =
|
|
|
1475
841
|
headers: { "Content-Type": "text/html" }
|
|
1476
842
|
});
|
|
1477
843
|
};
|
|
1478
|
-
var handleAngularPageRequest = async (PageComponent, indexPath, props, template, tokens) => {
|
|
1479
|
-
await angularPatch_default;
|
|
1480
|
-
const CSS_PATH_TOKEN = tokens?.CSS_PATH;
|
|
1481
|
-
const INITIAL_COUNT_TOKEN = tokens?.INITIAL_COUNT;
|
|
1482
|
-
if (!("Zone" in globalThis))
|
|
1483
|
-
await import("zone.js/node");
|
|
1484
|
-
try {
|
|
1485
|
-
const platformServer = await import("@angular/platform-server");
|
|
1486
|
-
const DominoAdapter = platformServer.DominoAdapter;
|
|
1487
|
-
if (DominoAdapter?.makeCurrent) {
|
|
1488
|
-
DominoAdapter.makeCurrent();
|
|
1489
|
-
console.log("\u2705 DominoAdapter initialized (patches already applied at module load)");
|
|
1490
|
-
} else {
|
|
1491
|
-
console.warn("\u26A0\uFE0F DominoAdapter.makeCurrent not available");
|
|
1492
|
-
}
|
|
1493
|
-
} catch (error) {
|
|
1494
|
-
console.warn("Failed to initialize DominoAdapter:", error);
|
|
1495
|
-
}
|
|
1496
|
-
const htmlString = template || "<!DOCTYPE html><html><head></head><body></body></html>";
|
|
1497
|
-
let document = htmlString;
|
|
1498
|
-
if (typeof htmlString === "string") {
|
|
1499
|
-
try {
|
|
1500
|
-
const domino = await import("domino").catch(() => null);
|
|
1501
|
-
if (domino?.createWindow) {
|
|
1502
|
-
const window = domino.createWindow(htmlString, "/");
|
|
1503
|
-
const doc = window.document;
|
|
1504
|
-
if (!doc.head) {
|
|
1505
|
-
const head = doc.createElement("head");
|
|
1506
|
-
if (doc.documentElement) {
|
|
1507
|
-
doc.documentElement.insertBefore(head, doc.documentElement.firstChild);
|
|
1508
|
-
}
|
|
1509
|
-
}
|
|
1510
|
-
if (doc.head && typeof doc.head.querySelectorAll !== "function") {
|
|
1511
|
-
try {
|
|
1512
|
-
Object.defineProperty(doc.head, "querySelectorAll", {
|
|
1513
|
-
value: function(selector) {
|
|
1514
|
-
if (doc.querySelectorAll) {
|
|
1515
|
-
const all = doc.querySelectorAll(selector);
|
|
1516
|
-
return Array.from(all).filter((el) => el.parentElement === doc.head || doc.head.contains(el));
|
|
1517
|
-
}
|
|
1518
|
-
return [];
|
|
1519
|
-
},
|
|
1520
|
-
writable: true,
|
|
1521
|
-
enumerable: false,
|
|
1522
|
-
configurable: true
|
|
1523
|
-
});
|
|
1524
|
-
} catch (e) {
|
|
1525
|
-
console.warn("Failed to add querySelectorAll to head:", e);
|
|
1526
|
-
}
|
|
1527
|
-
}
|
|
1528
|
-
if (doc.head && typeof doc.head.querySelector !== "function") {
|
|
1529
|
-
try {
|
|
1530
|
-
Object.defineProperty(doc.head, "querySelector", {
|
|
1531
|
-
value: function(selector) {
|
|
1532
|
-
if (doc.querySelector) {
|
|
1533
|
-
const el = doc.querySelector(selector);
|
|
1534
|
-
if (el && (el.parentElement === doc.head || doc.head.contains(el))) {
|
|
1535
|
-
return el;
|
|
1536
|
-
}
|
|
1537
|
-
}
|
|
1538
|
-
return null;
|
|
1539
|
-
},
|
|
1540
|
-
writable: true,
|
|
1541
|
-
enumerable: false,
|
|
1542
|
-
configurable: true
|
|
1543
|
-
});
|
|
1544
|
-
} catch (e) {
|
|
1545
|
-
console.warn("Failed to add querySelector to head:", e);
|
|
1546
|
-
}
|
|
1547
|
-
}
|
|
1548
|
-
if (!doc.head.children) {
|
|
1549
|
-
const elementNodes = Array.from(doc.head.childNodes).filter((node) => node.nodeType === 1);
|
|
1550
|
-
const childrenArray = [];
|
|
1551
|
-
elementNodes.forEach((node, index) => {
|
|
1552
|
-
childrenArray[index] = node;
|
|
1553
|
-
});
|
|
1554
|
-
childrenArray.length = elementNodes.length;
|
|
1555
|
-
Object.defineProperty(doc.head, "children", {
|
|
1556
|
-
value: childrenArray,
|
|
1557
|
-
writable: false,
|
|
1558
|
-
enumerable: true,
|
|
1559
|
-
configurable: false
|
|
1560
|
-
});
|
|
1561
|
-
} else {
|
|
1562
|
-
const children = doc.head.children;
|
|
1563
|
-
if (typeof children.length === "undefined" || children[0] === undefined && children.length > 0) {
|
|
1564
|
-
const elementNodes = Array.from(doc.head.childNodes).filter((node) => node.nodeType === 1);
|
|
1565
|
-
const childrenArray = [];
|
|
1566
|
-
elementNodes.forEach((node, index) => {
|
|
1567
|
-
childrenArray[index] = node;
|
|
1568
|
-
});
|
|
1569
|
-
childrenArray.length = elementNodes.length;
|
|
1570
|
-
Object.defineProperty(doc.head, "children", {
|
|
1571
|
-
value: childrenArray,
|
|
1572
|
-
writable: false,
|
|
1573
|
-
enumerable: true,
|
|
1574
|
-
configurable: false
|
|
1575
|
-
});
|
|
1576
|
-
}
|
|
1577
|
-
}
|
|
1578
|
-
document = createDocumentProxy(doc);
|
|
1579
|
-
}
|
|
1580
|
-
} catch (error) {
|
|
1581
|
-
console.warn("Failed to parse document with domino, using string:", error);
|
|
1582
|
-
document = htmlString;
|
|
1583
|
-
}
|
|
1584
|
-
}
|
|
1585
|
-
const providers = [
|
|
1586
|
-
provideServerRendering(),
|
|
1587
|
-
{ provide: APP_BASE_HREF, useValue: "/" }
|
|
1588
|
-
];
|
|
1589
|
-
if (props) {
|
|
1590
|
-
console.log("\uD83D\uDD0D [DEBUG] handleAngularPageRequest props:", props);
|
|
1591
|
-
if (props.cssPath !== undefined && CSS_PATH_TOKEN) {
|
|
1592
|
-
providers.push({
|
|
1593
|
-
provide: CSS_PATH_TOKEN,
|
|
1594
|
-
useValue: props.cssPath
|
|
1595
|
-
});
|
|
1596
|
-
console.log("\uD83D\uDD0D [DEBUG] Providing cssPath via DI token:", props.cssPath, "Token:", CSS_PATH_TOKEN);
|
|
1597
|
-
} else if (props.cssPath !== undefined) {
|
|
1598
|
-
console.warn("\u26A0\uFE0F [DEBUG] cssPath provided but CSS_PATH_TOKEN not available");
|
|
1599
|
-
}
|
|
1600
|
-
if (props.initialCount !== undefined && INITIAL_COUNT_TOKEN) {
|
|
1601
|
-
providers.push({
|
|
1602
|
-
provide: INITIAL_COUNT_TOKEN,
|
|
1603
|
-
useValue: props.initialCount
|
|
1604
|
-
});
|
|
1605
|
-
}
|
|
1606
|
-
}
|
|
1607
|
-
const bootstrap = (context) => {
|
|
1608
|
-
return bootstrapApplication(PageComponent, {
|
|
1609
|
-
providers
|
|
1610
|
-
}, context);
|
|
1611
|
-
};
|
|
1612
|
-
try {
|
|
1613
|
-
let finalDocument = document;
|
|
1614
|
-
if (typeof document !== "string" && document) {
|
|
1615
|
-
finalDocument = createDocumentProxy(document);
|
|
1616
|
-
}
|
|
1617
|
-
const html = await renderApplication(bootstrap, {
|
|
1618
|
-
document: finalDocument,
|
|
1619
|
-
url: "/",
|
|
1620
|
-
platformProviders: []
|
|
1621
|
-
});
|
|
1622
|
-
return new Response(html, {
|
|
1623
|
-
headers: { "Content-Type": "text/html" }
|
|
1624
|
-
});
|
|
1625
|
-
} catch (error) {
|
|
1626
|
-
console.error("\uD83D\uDEA8 [ANGULAR SSR] Error caught in handleAngularPageRequest:", {
|
|
1627
|
-
message: error.message,
|
|
1628
|
-
stack: error.stack,
|
|
1629
|
-
name: error.name,
|
|
1630
|
-
error
|
|
1631
|
-
});
|
|
1632
|
-
if (error.message && error.message.includes("doc.head.children")) {
|
|
1633
|
-
console.error("\uD83D\uDEA8 [ANGULAR SSR] doc.head.children error detected!", {
|
|
1634
|
-
fullError: error,
|
|
1635
|
-
stack: error.stack,
|
|
1636
|
-
message: error.message
|
|
1637
|
-
});
|
|
1638
|
-
}
|
|
1639
|
-
throw error;
|
|
1640
|
-
}
|
|
1641
|
-
};
|
|
1642
844
|
var handleHTMLPageRequest = (html) => file3(html);
|
|
1643
845
|
var handleHTMXPageRequest = (htmx) => file3(htmx);
|
|
1644
846
|
var handlePageRequest = (PageComponent, ...props) => {
|
|
@@ -1730,7 +932,6 @@ export {
|
|
|
1730
932
|
handlePageRequest,
|
|
1731
933
|
handleHTMXPageRequest,
|
|
1732
934
|
handleHTMLPageRequest,
|
|
1733
|
-
handleAngularPageRequest,
|
|
1734
935
|
getLocalIPAddress,
|
|
1735
936
|
getEnv,
|
|
1736
937
|
generateHeadElement,
|
|
@@ -1751,5 +952,5 @@ export {
|
|
|
1751
952
|
ANGULAR_BUILD_WARNING_SUPPRESSION
|
|
1752
953
|
};
|
|
1753
954
|
|
|
1754
|
-
//# debugId=
|
|
955
|
+
//# debugId=898E0366299327F164756E2164756E21
|
|
1755
956
|
//# sourceMappingURL=index.js.map
|