@absolutejs/absolute 0.19.0-beta.807 → 0.19.0-beta.809
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/angular/browser.js +9801 -57
- package/dist/angular/browser.js.map +246 -4
- package/dist/angular/components/core/streamingSlotRegistrar.js +1 -1
- package/dist/angular/components/core/streamingSlotRegistry.js +2 -2
- package/dist/angular/index.js +14877 -60
- package/dist/angular/index.js.map +281 -4
- package/dist/angular/server.js +5610 -45
- package/dist/angular/server.js.map +51 -3
- package/dist/build.js +18092 -45
- package/dist/build.js.map +99 -3
- package/dist/cli/index.js +317 -86
- package/dist/client/index.js +1091 -70
- package/dist/client/index.js.map +24 -4
- package/dist/core/streamingSlotRegistrar.js +108 -11
- package/dist/core/streamingSlotRegistrar.js.map +4 -3
- package/dist/core/streamingSlotRegistry.js +169 -7
- package/dist/core/streamingSlotRegistry.js.map +5 -3
- package/dist/index.js +19957 -547
- package/dist/index.js.map +116 -3
- package/dist/islands/browser.js +228 -9
- package/dist/islands/browser.js.map +9 -4
- package/dist/islands/index.js +1908 -17
- package/dist/islands/index.js.map +27 -3
- package/dist/react/browser.js +328 -12
- package/dist/react/browser.js.map +12 -4
- package/dist/react/components/index.js +167 -16
- package/dist/react/components/index.js.map +6 -3
- package/dist/react/hooks/index.js +183 -8
- package/dist/react/hooks/index.js.map +7 -3
- package/dist/react/index.js +3627 -36
- package/dist/react/index.js.map +45 -4
- package/dist/react/jsxDevRuntimeCompat.js +61 -2
- package/dist/react/jsxDevRuntimeCompat.js.map +2 -2
- package/dist/react/server.js +1789 -18
- package/dist/react/server.js.map +21 -3
- package/dist/src/angular/injectorPatch.d.ts +1 -0
- package/dist/src/angular/islands.d.ts +1 -0
- package/dist/src/client/hydrators/react.d.ts +3 -0
- package/dist/src/client/hydrators/svelte.d.ts +2 -0
- package/dist/src/client/hydrators/vue.d.ts +2 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/svelte/browser.js +247 -12
- package/dist/svelte/browser.js.map +10 -3
- package/dist/svelte/index.js +3732 -37
- package/dist/svelte/index.js.map +47 -4
- package/dist/svelte/server.js +2794 -21
- package/dist/svelte/server.js.map +27 -3
- package/dist/vue/browser.js +348 -12
- package/dist/vue/browser.js.map +12 -4
- package/dist/vue/components/Image.js +240 -7
- package/dist/vue/components/Image.js.map +6 -3
- package/dist/vue/components/index.js +544 -11
- package/dist/vue/components/index.js.map +9 -3
- package/dist/vue/index.js +4212 -52
- package/dist/vue/index.js.map +50 -4
- package/dist/vue/server.js +1849 -18
- package/dist/vue/server.js.map +21 -3
- package/package.json +1 -1
- package/dist/chunk-0867j0r0.js +0 -136
- package/dist/chunk-0867j0r0.js.map +0 -10
- package/dist/chunk-102fp7xe.js +0 -63
- package/dist/chunk-102fp7xe.js.map +0 -10
- package/dist/chunk-11zpfqz6.js +0 -19
- package/dist/chunk-11zpfqz6.js.map +0 -10
- package/dist/chunk-1rfh7hw9.js +0 -319
- package/dist/chunk-1rfh7hw9.js.map +0 -11
- package/dist/chunk-1x4fxm57.js +0 -51
- package/dist/chunk-1x4fxm57.js.map +0 -9
- package/dist/chunk-25v9t56f.js +0 -29
- package/dist/chunk-25v9t56f.js.map +0 -11
- package/dist/chunk-2f21eenc.js +0 -21
- package/dist/chunk-2f21eenc.js.map +0 -10
- package/dist/chunk-2ga2znex.js +0 -13
- package/dist/chunk-2ga2znex.js.map +0 -9
- package/dist/chunk-30yrw0f6.js +0 -33
- package/dist/chunk-30yrw0f6.js.map +0 -10
- package/dist/chunk-3g91wb4f.js +0 -358
- package/dist/chunk-3g91wb4f.js.map +0 -10
- package/dist/chunk-3rea1gam.js +0 -4403
- package/dist/chunk-3rea1gam.js.map +0 -28
- package/dist/chunk-3yjzpcne.js +0 -34
- package/dist/chunk-3yjzpcne.js.map +0 -10
- package/dist/chunk-41bf6aqt.js +0 -17
- package/dist/chunk-41bf6aqt.js.map +0 -9
- package/dist/chunk-4d39r92n.js +0 -81
- package/dist/chunk-4d39r92n.js.map +0 -10
- package/dist/chunk-5003emhv.js +0 -17
- package/dist/chunk-5003emhv.js.map +0 -10
- package/dist/chunk-5f67rsed.js +0 -466
- package/dist/chunk-5f67rsed.js.map +0 -10
- package/dist/chunk-5fhp1jap.js +0 -9169
- package/dist/chunk-5fhp1jap.js.map +0 -236
- package/dist/chunk-629x0yh4.js +0 -20
- package/dist/chunk-629x0yh4.js.map +0 -9
- package/dist/chunk-6pdj08z3.js +0 -73
- package/dist/chunk-6pdj08z3.js.map +0 -12
- package/dist/chunk-6qjbrt0k.js +0 -13
- package/dist/chunk-6qjbrt0k.js.map +0 -9
- package/dist/chunk-6sccb4jr.js +0 -14
- package/dist/chunk-6sccb4jr.js.map +0 -9
- package/dist/chunk-798spvzv.js +0 -50
- package/dist/chunk-798spvzv.js.map +0 -10
- package/dist/chunk-7fw6x3js.js +0 -131
- package/dist/chunk-7fw6x3js.js.map +0 -11
- package/dist/chunk-7kjj42xm.js +0 -11
- package/dist/chunk-7kjj42xm.js.map +0 -10
- package/dist/chunk-7mtstdqn.js +0 -90
- package/dist/chunk-7mtstdqn.js.map +0 -10
- package/dist/chunk-851whwc7.js +0 -17
- package/dist/chunk-851whwc7.js.map +0 -10
- package/dist/chunk-85n68sy6.js +0 -103
- package/dist/chunk-85n68sy6.js.map +0 -10
- package/dist/chunk-8kcfffry.js +0 -35
- package/dist/chunk-8kcfffry.js.map +0 -10
- package/dist/chunk-92fsjfpp.js +0 -1731
- package/dist/chunk-92fsjfpp.js.map +0 -11
- package/dist/chunk-93sqk7be.js +0 -139
- package/dist/chunk-93sqk7be.js.map +0 -12
- package/dist/chunk-9c5tj4k3.js +0 -130
- package/dist/chunk-9c5tj4k3.js.map +0 -10
- package/dist/chunk-9j59emg3.js +0 -184
- package/dist/chunk-9j59emg3.js.map +0 -11
- package/dist/chunk-9ve9jq72.js +0 -203
- package/dist/chunk-9ve9jq72.js.map +0 -10
- package/dist/chunk-9xrsjeem.js +0 -12
- package/dist/chunk-9xrsjeem.js.map +0 -9
- package/dist/chunk-a9mvyp04.js +0 -87
- package/dist/chunk-a9mvyp04.js.map +0 -10
- package/dist/chunk-b3gbnrwe.js +0 -21
- package/dist/chunk-b3gbnrwe.js.map +0 -10
- package/dist/chunk-bgb8k1qs.js +0 -672
- package/dist/chunk-bgb8k1qs.js.map +0 -15
- package/dist/chunk-bmgqm774.js +0 -65
- package/dist/chunk-bmgqm774.js.map +0 -9
- package/dist/chunk-bxfghpma.js +0 -69
- package/dist/chunk-bxfghpma.js.map +0 -10
- package/dist/chunk-c1jfjnka.js +0 -74
- package/dist/chunk-c1jfjnka.js.map +0 -10
- package/dist/chunk-cbkrwmvh.js +0 -80
- package/dist/chunk-cbkrwmvh.js.map +0 -10
- package/dist/chunk-cdxd7sy2.js +0 -71
- package/dist/chunk-cdxd7sy2.js.map +0 -10
- package/dist/chunk-cg95827x.js +0 -21
- package/dist/chunk-cg95827x.js.map +0 -10
- package/dist/chunk-cm0g4q6w.js +0 -149
- package/dist/chunk-cm0g4q6w.js.map +0 -10
- package/dist/chunk-d7mwkzry.js +0 -261
- package/dist/chunk-d7mwkzry.js.map +0 -10
- package/dist/chunk-d9c0am65.js +0 -12
- package/dist/chunk-d9c0am65.js.map +0 -10
- package/dist/chunk-daqghmg8.js +0 -12
- package/dist/chunk-daqghmg8.js.map +0 -9
- package/dist/chunk-e3r9fxaa.js +0 -149
- package/dist/chunk-e3r9fxaa.js.map +0 -10
- package/dist/chunk-e8eecyrq.js +0 -244
- package/dist/chunk-e8eecyrq.js.map +0 -10
- package/dist/chunk-ex2hxe0v.js +0 -160
- package/dist/chunk-ex2hxe0v.js.map +0 -11
- package/dist/chunk-fak944et.js +0 -91
- package/dist/chunk-fak944et.js.map +0 -10
- package/dist/chunk-fygx2ymm.js +0 -118
- package/dist/chunk-fygx2ymm.js.map +0 -12
- package/dist/chunk-g15qj669.js +0 -271
- package/dist/chunk-g15qj669.js.map +0 -11
- package/dist/chunk-gd6wmknh.js +0 -121
- package/dist/chunk-gd6wmknh.js.map +0 -11
- package/dist/chunk-gf0ygptk.js +0 -85
- package/dist/chunk-gf0ygptk.js.map +0 -11
- package/dist/chunk-gytkmthr.js +0 -220
- package/dist/chunk-gytkmthr.js.map +0 -10
- package/dist/chunk-h5bbfn3n.js +0 -28
- package/dist/chunk-h5bbfn3n.js.map +0 -11
- package/dist/chunk-h6mye9r3.js +0 -93
- package/dist/chunk-h6mye9r3.js.map +0 -10
- package/dist/chunk-hcsmxw1v.js +0 -85
- package/dist/chunk-hcsmxw1v.js.map +0 -10
- package/dist/chunk-hyjs4bqs.js +0 -8
- package/dist/chunk-hyjs4bqs.js.map +0 -10
- package/dist/chunk-jn91vzkh.js +0 -66
- package/dist/chunk-jn91vzkh.js.map +0 -10
- package/dist/chunk-jpkjdgsk.js +0 -167
- package/dist/chunk-jpkjdgsk.js.map +0 -11
- package/dist/chunk-jwxt8gnp.js +0 -13
- package/dist/chunk-jwxt8gnp.js.map +0 -9
- package/dist/chunk-kk8w9rh5.js +0 -195
- package/dist/chunk-kk8w9rh5.js.map +0 -10
- package/dist/chunk-kwgh8rmg.js +0 -426
- package/dist/chunk-kwgh8rmg.js.map +0 -14
- package/dist/chunk-m97ze5hz.js +0 -46
- package/dist/chunk-m97ze5hz.js.map +0 -10
- package/dist/chunk-mbazhahf.js +0 -60
- package/dist/chunk-mbazhahf.js.map +0 -10
- package/dist/chunk-mgfwq18r.js +0 -15
- package/dist/chunk-mgfwq18r.js.map +0 -9
- package/dist/chunk-mtgf69xn.js +0 -88
- package/dist/chunk-mtgf69xn.js.map +0 -10
- package/dist/chunk-mtxzyxpg.js +0 -102
- package/dist/chunk-mtxzyxpg.js.map +0 -10
- package/dist/chunk-nehhtthw.js +0 -225
- package/dist/chunk-nehhtthw.js.map +0 -10
- package/dist/chunk-p5504p14.js +0 -16
- package/dist/chunk-p5504p14.js.map +0 -10
- package/dist/chunk-p5zgj77m.js +0 -184
- package/dist/chunk-p5zgj77m.js.map +0 -10
- package/dist/chunk-pnscgw95.js +0 -90
- package/dist/chunk-pnscgw95.js.map +0 -10
- package/dist/chunk-pvpp4pvs.js +0 -17
- package/dist/chunk-pvpp4pvs.js.map +0 -10
- package/dist/chunk-qh75agse.js +0 -95
- package/dist/chunk-qh75agse.js.map +0 -10
- package/dist/chunk-qxq2zcty.js +0 -52
- package/dist/chunk-qxq2zcty.js.map +0 -10
- package/dist/chunk-r6e8pytx.js +0 -22
- package/dist/chunk-r6e8pytx.js.map +0 -9
- package/dist/chunk-r7jmgqnw.js +0 -114
- package/dist/chunk-r7jmgqnw.js.map +0 -10
- package/dist/chunk-s6defjk2.js +0 -116
- package/dist/chunk-s6defjk2.js.map +0 -10
- package/dist/chunk-sd39p726.js +0 -619
- package/dist/chunk-sd39p726.js.map +0 -10
- package/dist/chunk-swrnzs4c.js +0 -63
- package/dist/chunk-swrnzs4c.js.map +0 -10
- package/dist/chunk-tfe3sb44.js +0 -33
- package/dist/chunk-tfe3sb44.js.map +0 -10
- package/dist/chunk-tjr0kcev.js +0 -41
- package/dist/chunk-tjr0kcev.js.map +0 -9
- package/dist/chunk-tx9edm1x.js +0 -34
- package/dist/chunk-tx9edm1x.js.map +0 -10
- package/dist/chunk-txhm2vb5.js +0 -18
- package/dist/chunk-txhm2vb5.js.map +0 -9
- package/dist/chunk-v5vmsxmy.js +0 -526
- package/dist/chunk-v5vmsxmy.js.map +0 -12
- package/dist/chunk-vjhxm8n2.js +0 -29
- package/dist/chunk-vjhxm8n2.js.map +0 -9
- package/dist/chunk-vkrpm7kc.js +0 -247
- package/dist/chunk-vkrpm7kc.js.map +0 -12
- package/dist/chunk-w3m4m5we.js +0 -4925
- package/dist/chunk-w3m4m5we.js.map +0 -12
- package/dist/chunk-wrxtn9ve.js +0 -18
- package/dist/chunk-wrxtn9ve.js.map +0 -10
- package/dist/chunk-x09cskqd.js +0 -377
- package/dist/chunk-x09cskqd.js.map +0 -10
- package/dist/chunk-xnt8c6h2.js +0 -576
- package/dist/chunk-xnt8c6h2.js.map +0 -10
- package/dist/chunk-xw0tx842.js +0 -13
- package/dist/chunk-xw0tx842.js.map +0 -9
- package/dist/chunk-xx5b6b9m.js +0 -69
- package/dist/chunk-xx5b6b9m.js.map +0 -10
- package/dist/chunk-xz1kdswj.js +0 -21
- package/dist/chunk-xz1kdswj.js.map +0 -9
- package/dist/chunk-y84qnsd3.js +0 -32
- package/dist/chunk-y84qnsd3.js.map +0 -10
- package/dist/chunk-ywjn0rad.js +0 -14
- package/dist/chunk-ywjn0rad.js.map +0 -9
- package/dist/chunk-z9nvhm6r.js +0 -13
- package/dist/chunk-z9nvhm6r.js.map +0 -9
- package/dist/chunk-zhmvdpk6.js +0 -15
- package/dist/chunk-zhmvdpk6.js.map +0 -9
- package/dist/chunk-zrg9d4zw.js +0 -784
- package/dist/chunk-zrg9d4zw.js.map +0 -10
package/dist/chunk-92fsjfpp.js
DELETED
|
@@ -1,1731 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
buildIslandMetadataExports
|
|
4
|
-
} from "./chunk-a9mvyp04.js";
|
|
5
|
-
import {
|
|
6
|
-
toPascal
|
|
7
|
-
} from "./chunk-p5504p14.js";
|
|
8
|
-
import {
|
|
9
|
-
compileStyleFileIfNeeded
|
|
10
|
-
} from "./chunk-xnt8c6h2.js";
|
|
11
|
-
import {
|
|
12
|
-
BASE_36_RADIX,
|
|
13
|
-
MILLISECONDS_IN_A_SECOND
|
|
14
|
-
} from "./chunk-qh75agse.js";
|
|
15
|
-
import {
|
|
16
|
-
__require
|
|
17
|
-
} from "./chunk-bmgqm774.js";
|
|
18
|
-
|
|
19
|
-
// src/build/compileAngular.ts
|
|
20
|
-
import { existsSync, readFileSync, promises as fs } from "fs";
|
|
21
|
-
import { join, basename, sep, dirname, resolve, relative } from "path";
|
|
22
|
-
import ts from "typescript";
|
|
23
|
-
|
|
24
|
-
// src/angular/lowerDeferSyntax.ts
|
|
25
|
-
var isInterpolatedExpressionStart = (value, index) => value[index] === "{" && value[index + 1] === "{";
|
|
26
|
-
var skipInterpolatedExpression = (value, start) => {
|
|
27
|
-
const cursor = start + 2;
|
|
28
|
-
while (cursor < value.length - 1) {
|
|
29
|
-
const end = value.indexOf("}}", cursor);
|
|
30
|
-
if (end < 0) {
|
|
31
|
-
return value.length;
|
|
32
|
-
}
|
|
33
|
-
return end + 2;
|
|
34
|
-
}
|
|
35
|
-
return value.length;
|
|
36
|
-
};
|
|
37
|
-
var updateBlockDepth = (char, depth) => {
|
|
38
|
-
if (char === "{") {
|
|
39
|
-
return depth + 1;
|
|
40
|
-
}
|
|
41
|
-
if (char === "}") {
|
|
42
|
-
return depth - 1;
|
|
43
|
-
}
|
|
44
|
-
return depth;
|
|
45
|
-
};
|
|
46
|
-
var updateParenthesisDepth = (char, depth) => {
|
|
47
|
-
if (char === "(") {
|
|
48
|
-
return depth + 1;
|
|
49
|
-
}
|
|
50
|
-
if (char === ")") {
|
|
51
|
-
return depth - 1;
|
|
52
|
-
}
|
|
53
|
-
return depth;
|
|
54
|
-
};
|
|
55
|
-
var appendResolvedChunk = (value, template, cursor, interpolationStart) => {
|
|
56
|
-
const nextTemplate = template + value.slice(cursor, interpolationStart);
|
|
57
|
-
const nextCursor = skipInterpolatedExpression(value, interpolationStart);
|
|
58
|
-
if (nextCursor > value.length) {
|
|
59
|
-
return {
|
|
60
|
-
bindings: undefined,
|
|
61
|
-
cursor: value.length,
|
|
62
|
-
done: true,
|
|
63
|
-
template: nextTemplate + value.slice(interpolationStart)
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
const expression = value.slice(interpolationStart + 2, nextCursor - 2).trim();
|
|
67
|
-
return {
|
|
68
|
-
bindings: expression,
|
|
69
|
-
cursor: nextCursor,
|
|
70
|
-
done: false,
|
|
71
|
-
template: nextTemplate
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
var appendTrailingTemplate = (value, template, cursor) => template + value.slice(cursor);
|
|
75
|
-
var consumeDeferredAuxiliaryBlock = (input) => {
|
|
76
|
-
const parsedBlock = parseDeferredAuxiliaryBlock(input.template, input.cursorAfterResolved, input.keyword);
|
|
77
|
-
if (!parsedBlock) {
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
return {
|
|
81
|
-
content: parsedBlock.content.trim(),
|
|
82
|
-
nextIndex: input.keyword === "@placeholder" ? skipWhitespace(input.template, parsedBlock.nextIndex) : parsedBlock.nextIndex
|
|
83
|
-
};
|
|
84
|
-
};
|
|
85
|
-
var resolveDeferSlotStart = (template, deferIndex, markerCursor) => {
|
|
86
|
-
const nextMarkerCursor = skipWhitespace(template, markerCursor);
|
|
87
|
-
if (template[nextMarkerCursor] === "{") {
|
|
88
|
-
return {
|
|
89
|
-
changed: false,
|
|
90
|
-
cursor: deferIndex,
|
|
91
|
-
markerCursor: nextMarkerCursor,
|
|
92
|
-
templatePrefix: ""
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
return {
|
|
96
|
-
changed: true,
|
|
97
|
-
cursor: deferIndex + "@defer".length,
|
|
98
|
-
markerCursor: nextMarkerCursor,
|
|
99
|
-
templatePrefix: "@defer"
|
|
100
|
-
};
|
|
101
|
-
};
|
|
102
|
-
var consumeBlockCursor = (value, start, cursor, depth) => {
|
|
103
|
-
if (isInterpolatedExpressionStart(value, cursor)) {
|
|
104
|
-
return {
|
|
105
|
-
cursor: skipInterpolatedExpression(value, cursor),
|
|
106
|
-
depth,
|
|
107
|
-
result: null
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
const char = value[cursor] ?? "";
|
|
111
|
-
const nextDepth = updateBlockDepth(char, depth);
|
|
112
|
-
if (char === "}" && nextDepth === 0) {
|
|
113
|
-
return {
|
|
114
|
-
cursor,
|
|
115
|
-
depth,
|
|
116
|
-
result: {
|
|
117
|
-
content: value.slice(start + 1, cursor),
|
|
118
|
-
nextIndex: cursor + 1
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
return {
|
|
123
|
-
cursor: cursor + 1,
|
|
124
|
-
depth: nextDepth,
|
|
125
|
-
result: null
|
|
126
|
-
};
|
|
127
|
-
};
|
|
128
|
-
var consumeResolvedTemplateChunk = (value, template, cursor, bindingsLength) => {
|
|
129
|
-
const interpolationStart = value.indexOf("{{", cursor);
|
|
130
|
-
if (interpolationStart < 0) {
|
|
131
|
-
return {
|
|
132
|
-
binding: null,
|
|
133
|
-
cursor,
|
|
134
|
-
done: true,
|
|
135
|
-
template: appendTrailingTemplate(value, template, cursor)
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
const nextChunk = appendResolvedChunk(value, template, cursor, interpolationStart);
|
|
139
|
-
if (nextChunk.done || nextChunk.bindings === undefined) {
|
|
140
|
-
return {
|
|
141
|
-
binding: null,
|
|
142
|
-
cursor,
|
|
143
|
-
done: true,
|
|
144
|
-
template: nextChunk.template
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
const key = `e${bindingsLength.toString(BASE_36_RADIX)}`;
|
|
148
|
-
return {
|
|
149
|
-
binding: {
|
|
150
|
-
expression: nextChunk.bindings,
|
|
151
|
-
key
|
|
152
|
-
},
|
|
153
|
-
cursor: nextChunk.cursor,
|
|
154
|
-
done: false,
|
|
155
|
-
template: `${nextChunk.template}{{ slotData["${key}"] }}`
|
|
156
|
-
};
|
|
157
|
-
};
|
|
158
|
-
var readNextDeferBlock = (template, cursor) => {
|
|
159
|
-
const deferIndex = template.indexOf("@defer", cursor);
|
|
160
|
-
if (deferIndex < 0) {
|
|
161
|
-
return null;
|
|
162
|
-
}
|
|
163
|
-
return {
|
|
164
|
-
deferIndex,
|
|
165
|
-
prefix: template.slice(cursor, deferIndex)
|
|
166
|
-
};
|
|
167
|
-
};
|
|
168
|
-
var buildDeferredSlot = (input) => {
|
|
169
|
-
const {
|
|
170
|
-
cursorAfterResolved,
|
|
171
|
-
errorHtml,
|
|
172
|
-
placeholderHtml,
|
|
173
|
-
resolvedBlock,
|
|
174
|
-
slotIndex,
|
|
175
|
-
triggerExpression
|
|
176
|
-
} = input;
|
|
177
|
-
const resolvedHtml = resolvedBlock.content.trim();
|
|
178
|
-
const transformedResolved = transformResolvedTemplate(resolvedHtml);
|
|
179
|
-
const id = `absolute-angular-defer-${slotIndex.toString(BASE_36_RADIX)}`;
|
|
180
|
-
const slot = {
|
|
181
|
-
delayMs: parseDelayMs(triggerExpression),
|
|
182
|
-
errorHtml,
|
|
183
|
-
fallbackHtml: placeholderHtml,
|
|
184
|
-
id,
|
|
185
|
-
resolvedBindings: transformedResolved.bindings,
|
|
186
|
-
resolvedHtml,
|
|
187
|
-
resolvedTemplate: transformedResolved.template
|
|
188
|
-
};
|
|
189
|
-
return {
|
|
190
|
-
cursorAfterResolved,
|
|
191
|
-
markup: `<abs-defer-slot [id]="'${id}'" [resolve]="__absoluteDeferResolvePayload${slotIndex}">${buildSlotTemplates(slot)}</abs-defer-slot>`,
|
|
192
|
-
slot
|
|
193
|
-
};
|
|
194
|
-
};
|
|
195
|
-
var applyConsumedResolvedTemplateChunk = (bindings, nextChunk) => {
|
|
196
|
-
if (nextChunk.binding) {
|
|
197
|
-
bindings.push(nextChunk.binding);
|
|
198
|
-
}
|
|
199
|
-
return {
|
|
200
|
-
cursor: nextChunk.done ? Number.POSITIVE_INFINITY : nextChunk.cursor,
|
|
201
|
-
done: nextChunk.done,
|
|
202
|
-
template: nextChunk.template
|
|
203
|
-
};
|
|
204
|
-
};
|
|
205
|
-
var applyConsumedDeferredBlock = (content, parsedBlock, cursorAfterResolved) => {
|
|
206
|
-
if (!parsedBlock) {
|
|
207
|
-
return {
|
|
208
|
-
content,
|
|
209
|
-
cursorAfterResolved
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
return {
|
|
213
|
-
content: parsedBlock.content || null,
|
|
214
|
-
cursorAfterResolved: parsedBlock.nextIndex
|
|
215
|
-
};
|
|
216
|
-
};
|
|
217
|
-
var applyConsumedPlaceholderBlock = (placeholderHtml, parsedBlock, cursorAfterResolved) => {
|
|
218
|
-
const nextState = applyConsumedDeferredBlock(placeholderHtml, parsedBlock, cursorAfterResolved);
|
|
219
|
-
return {
|
|
220
|
-
cursorAfterResolved: nextState.cursorAfterResolved,
|
|
221
|
-
placeholderHtml: nextState.content ?? ""
|
|
222
|
-
};
|
|
223
|
-
};
|
|
224
|
-
var applyConsumedErrorBlock = (errorHtml, parsedBlock, cursorAfterResolved) => {
|
|
225
|
-
const nextState = applyConsumedDeferredBlock(errorHtml, parsedBlock, cursorAfterResolved);
|
|
226
|
-
return {
|
|
227
|
-
cursorAfterResolved: nextState.cursorAfterResolved,
|
|
228
|
-
errorHtml: nextState.content
|
|
229
|
-
};
|
|
230
|
-
};
|
|
231
|
-
var resolveNextLoweredTemplateChunk = (template, cursor) => {
|
|
232
|
-
const nextDeferBlock = readNextDeferBlock(template, cursor);
|
|
233
|
-
if (nextDeferBlock) {
|
|
234
|
-
return nextDeferBlock;
|
|
235
|
-
}
|
|
236
|
-
return {
|
|
237
|
-
deferIndex: -1,
|
|
238
|
-
prefix: template.slice(cursor)
|
|
239
|
-
};
|
|
240
|
-
};
|
|
241
|
-
var applyInvalidDeferSlotStart = (loweredTemplate, slotStart) => {
|
|
242
|
-
if (!slotStart.changed) {
|
|
243
|
-
return null;
|
|
244
|
-
}
|
|
245
|
-
return {
|
|
246
|
-
changed: true,
|
|
247
|
-
cursor: slotStart.cursor,
|
|
248
|
-
template: loweredTemplate + slotStart.templatePrefix
|
|
249
|
-
};
|
|
250
|
-
};
|
|
251
|
-
var applyEmptyResolvedBlock = (loweredTemplate, template, deferIndex, resolvedBlock) => {
|
|
252
|
-
if (resolvedBlock.content.trim()) {
|
|
253
|
-
return null;
|
|
254
|
-
}
|
|
255
|
-
return {
|
|
256
|
-
cursor: resolvedBlock.nextIndex,
|
|
257
|
-
template: loweredTemplate + template.slice(deferIndex, resolvedBlock.nextIndex)
|
|
258
|
-
};
|
|
259
|
-
};
|
|
260
|
-
var applyNextLoweredTemplateChunk = (loweredTemplate, nextDeferBlock) => ({
|
|
261
|
-
deferIndex: nextDeferBlock.deferIndex,
|
|
262
|
-
done: nextDeferBlock.deferIndex < 0,
|
|
263
|
-
template: loweredTemplate + nextDeferBlock.prefix
|
|
264
|
-
});
|
|
265
|
-
var applyParsedSlotStart = (changed, cursor, loweredTemplate, slotStart) => {
|
|
266
|
-
const invalidSlotStart = applyInvalidDeferSlotStart(loweredTemplate, slotStart);
|
|
267
|
-
if (!invalidSlotStart) {
|
|
268
|
-
return {
|
|
269
|
-
changed,
|
|
270
|
-
cursor,
|
|
271
|
-
template: loweredTemplate
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
|
-
return {
|
|
275
|
-
changed: true,
|
|
276
|
-
cursor: invalidSlotStart.cursor,
|
|
277
|
-
template: invalidSlotStart.template
|
|
278
|
-
};
|
|
279
|
-
};
|
|
280
|
-
var applyResolvedBlockState = (cursor, loweredTemplate, template, deferIndex, resolvedBlock) => {
|
|
281
|
-
const emptyResolvedBlock = applyEmptyResolvedBlock(loweredTemplate, template, deferIndex, resolvedBlock);
|
|
282
|
-
if (!emptyResolvedBlock) {
|
|
283
|
-
return {
|
|
284
|
-
cursor,
|
|
285
|
-
template: loweredTemplate
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
return emptyResolvedBlock;
|
|
289
|
-
};
|
|
290
|
-
var consumeResolvedTemplateStep = (value, template, cursor, bindings) => {
|
|
291
|
-
const nextChunk = consumeResolvedTemplateChunk(value, template, cursor, bindings.length);
|
|
292
|
-
return applyConsumedResolvedTemplateChunk(bindings, nextChunk);
|
|
293
|
-
};
|
|
294
|
-
var consumeLoweredDeferStep = (input) => {
|
|
295
|
-
const { changed, cursor, loweredTemplate, slotIndex, slots, template } = input;
|
|
296
|
-
const nextDeferBlock = resolveNextLoweredTemplateChunk(template, cursor);
|
|
297
|
-
const nextLoweredChunk = applyNextLoweredTemplateChunk(loweredTemplate, nextDeferBlock);
|
|
298
|
-
if (nextLoweredChunk.done) {
|
|
299
|
-
return null;
|
|
300
|
-
}
|
|
301
|
-
const { deferIndex } = nextLoweredChunk;
|
|
302
|
-
let markerCursor = deferIndex + "@defer".length;
|
|
303
|
-
const triggerInfo = parseOptionalTriggerExpression(template, markerCursor);
|
|
304
|
-
const { triggerExpression } = triggerInfo;
|
|
305
|
-
({ markerCursor } = triggerInfo);
|
|
306
|
-
const slotStart = resolveDeferSlotStart(template, deferIndex, markerCursor);
|
|
307
|
-
({ markerCursor } = slotStart);
|
|
308
|
-
const slotStartState = applyParsedSlotStart(changed, cursor, nextLoweredChunk.template, slotStart);
|
|
309
|
-
if (slotStartState.changed !== changed) {
|
|
310
|
-
return {
|
|
311
|
-
changed: slotStartState.changed,
|
|
312
|
-
cursor: slotStartState.cursor,
|
|
313
|
-
slotIndex,
|
|
314
|
-
template: slotStartState.template
|
|
315
|
-
};
|
|
316
|
-
}
|
|
317
|
-
const resolvedBlock = skipMatchingBlock(template, markerCursor);
|
|
318
|
-
const resolvedBlockState = applyResolvedBlockState(cursor, nextLoweredChunk.template, template, deferIndex, resolvedBlock);
|
|
319
|
-
if (resolvedBlockState.cursor !== cursor) {
|
|
320
|
-
return {
|
|
321
|
-
changed,
|
|
322
|
-
cursor: resolvedBlockState.cursor,
|
|
323
|
-
slotIndex,
|
|
324
|
-
template: resolvedBlockState.template
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
const blockContent = parsePlaceholderAndErrorBlocks(template, skipWhitespace(template, resolvedBlock.nextIndex));
|
|
328
|
-
const builtSlot = buildDeferredSlot({
|
|
329
|
-
cursorAfterResolved: blockContent.cursorAfterResolved,
|
|
330
|
-
errorHtml: blockContent.errorHtml,
|
|
331
|
-
placeholderHtml: blockContent.placeholderHtml,
|
|
332
|
-
resolvedBlock,
|
|
333
|
-
slotIndex,
|
|
334
|
-
triggerExpression
|
|
335
|
-
});
|
|
336
|
-
slots.push(builtSlot.slot);
|
|
337
|
-
return {
|
|
338
|
-
changed: true,
|
|
339
|
-
cursor: builtSlot.cursorAfterResolved,
|
|
340
|
-
slotIndex: slotIndex + 1,
|
|
341
|
-
template: nextLoweredChunk.template + builtSlot.markup
|
|
342
|
-
};
|
|
343
|
-
};
|
|
344
|
-
var skipMatchingBlock = (value, start) => {
|
|
345
|
-
if (value[start] !== "{") {
|
|
346
|
-
return { content: "", nextIndex: start };
|
|
347
|
-
}
|
|
348
|
-
let cursor = start + 1;
|
|
349
|
-
let depth = 1;
|
|
350
|
-
while (cursor < value.length) {
|
|
351
|
-
const consumed = consumeBlockCursor(value, start, cursor, depth);
|
|
352
|
-
if (consumed.result) {
|
|
353
|
-
return consumed.result;
|
|
354
|
-
}
|
|
355
|
-
({ cursor, depth } = consumed);
|
|
356
|
-
}
|
|
357
|
-
return { content: value.slice(start + 1), nextIndex: value.length };
|
|
358
|
-
};
|
|
359
|
-
var skipWhitespace = (value, index) => {
|
|
360
|
-
let cursor = index;
|
|
361
|
-
while (cursor < value.length && /\s/.test(value[cursor] ?? "")) {
|
|
362
|
-
cursor += 1;
|
|
363
|
-
}
|
|
364
|
-
return cursor;
|
|
365
|
-
};
|
|
366
|
-
var parseOptionalParenthesizedBlock = (value, index) => {
|
|
367
|
-
let cursor = skipWhitespace(value, index);
|
|
368
|
-
if (value[cursor] !== "(") {
|
|
369
|
-
return null;
|
|
370
|
-
}
|
|
371
|
-
cursor += 1;
|
|
372
|
-
let depth = 1;
|
|
373
|
-
const start = cursor;
|
|
374
|
-
while (cursor < value.length) {
|
|
375
|
-
const char = value[cursor] ?? "";
|
|
376
|
-
const nextDepth = updateParenthesisDepth(char, depth);
|
|
377
|
-
if (char === ")" && nextDepth === 0) {
|
|
378
|
-
return {
|
|
379
|
-
expression: value.slice(start, cursor),
|
|
380
|
-
nextIndex: cursor + 1
|
|
381
|
-
};
|
|
382
|
-
}
|
|
383
|
-
depth = nextDepth;
|
|
384
|
-
cursor += 1;
|
|
385
|
-
}
|
|
386
|
-
return { expression: value.slice(start), nextIndex: value.length };
|
|
387
|
-
};
|
|
388
|
-
var parseDelayMs = (triggerExpression) => {
|
|
389
|
-
if (!triggerExpression)
|
|
390
|
-
return 0;
|
|
391
|
-
const timerMsMatch = triggerExpression.match(/timer\(\s*(\d+)\s*ms\s*\)/i);
|
|
392
|
-
if (timerMsMatch?.[1])
|
|
393
|
-
return Number.parseInt(timerMsMatch[1], 10);
|
|
394
|
-
const timerSecondsMatch = triggerExpression.match(/timer\(\s*(\d+)\s*s\s*\)/i);
|
|
395
|
-
if (timerSecondsMatch?.[1]) {
|
|
396
|
-
return Number.parseInt(timerSecondsMatch[1], 10) * MILLISECONDS_IN_A_SECOND;
|
|
397
|
-
}
|
|
398
|
-
if (/\bon\s+immediate\b/i.test(triggerExpression))
|
|
399
|
-
return 0;
|
|
400
|
-
if (/\bon\s+idle\b/i.test(triggerExpression))
|
|
401
|
-
return 1;
|
|
402
|
-
return 0;
|
|
403
|
-
};
|
|
404
|
-
var transformResolvedTemplate = (value) => {
|
|
405
|
-
const bindings = [];
|
|
406
|
-
let template = "";
|
|
407
|
-
let cursor = 0;
|
|
408
|
-
while (cursor < value.length) {
|
|
409
|
-
const appliedChunk = consumeResolvedTemplateStep(value, template, cursor, bindings);
|
|
410
|
-
({ cursor, template } = appliedChunk);
|
|
411
|
-
}
|
|
412
|
-
return {
|
|
413
|
-
bindings,
|
|
414
|
-
template
|
|
415
|
-
};
|
|
416
|
-
};
|
|
417
|
-
var parseOptionalTriggerExpression = (template, markerCursor) => {
|
|
418
|
-
const parsedTrigger = parseOptionalParenthesizedBlock(template, markerCursor);
|
|
419
|
-
if (!parsedTrigger) {
|
|
420
|
-
return {
|
|
421
|
-
markerCursor,
|
|
422
|
-
triggerExpression: undefined
|
|
423
|
-
};
|
|
424
|
-
}
|
|
425
|
-
return {
|
|
426
|
-
markerCursor: parsedTrigger.nextIndex,
|
|
427
|
-
triggerExpression: parsedTrigger.expression.trim()
|
|
428
|
-
};
|
|
429
|
-
};
|
|
430
|
-
var parseDeferredAuxiliaryBlock = (template, cursorAfterResolved, keyword) => {
|
|
431
|
-
if (!template.startsWith(keyword, cursorAfterResolved)) {
|
|
432
|
-
return null;
|
|
433
|
-
}
|
|
434
|
-
const blockKeywordCursor = cursorAfterResolved + keyword.length;
|
|
435
|
-
const blockStart = skipWhitespace(template, blockKeywordCursor);
|
|
436
|
-
if (template[blockStart] !== "{") {
|
|
437
|
-
return null;
|
|
438
|
-
}
|
|
439
|
-
return skipMatchingBlock(template, blockStart);
|
|
440
|
-
};
|
|
441
|
-
var parsePlaceholderAndErrorBlocks = (template, startCursor) => {
|
|
442
|
-
let cursorAfterResolved = startCursor;
|
|
443
|
-
let placeholderHtml = "";
|
|
444
|
-
let errorHtml = null;
|
|
445
|
-
const parsedPlaceholder = consumeDeferredAuxiliaryBlock({
|
|
446
|
-
cursorAfterResolved,
|
|
447
|
-
keyword: "@placeholder",
|
|
448
|
-
template
|
|
449
|
-
});
|
|
450
|
-
({ placeholderHtml, cursorAfterResolved } = applyConsumedPlaceholderBlock(placeholderHtml, parsedPlaceholder, cursorAfterResolved));
|
|
451
|
-
const parsedError = consumeDeferredAuxiliaryBlock({
|
|
452
|
-
cursorAfterResolved,
|
|
453
|
-
keyword: "@error",
|
|
454
|
-
template
|
|
455
|
-
});
|
|
456
|
-
({ errorHtml, cursorAfterResolved } = applyConsumedErrorBlock(errorHtml, parsedError, cursorAfterResolved));
|
|
457
|
-
return {
|
|
458
|
-
cursorAfterResolved,
|
|
459
|
-
errorHtml,
|
|
460
|
-
placeholderHtml
|
|
461
|
-
};
|
|
462
|
-
};
|
|
463
|
-
var buildSlotTemplates = (slot) => {
|
|
464
|
-
const templates = [
|
|
465
|
-
`<ng-template absDeferResolved let-slotData>${slot.resolvedTemplate}</ng-template>`
|
|
466
|
-
];
|
|
467
|
-
if (slot.fallbackHtml.length > 0) {
|
|
468
|
-
templates.push(`<ng-template absDeferFallback>${slot.fallbackHtml}</ng-template>`);
|
|
469
|
-
}
|
|
470
|
-
if (slot.errorHtml) {
|
|
471
|
-
templates.push(`<ng-template absDeferError>${slot.errorHtml}</ng-template>`);
|
|
472
|
-
}
|
|
473
|
-
return templates.join("");
|
|
474
|
-
};
|
|
475
|
-
var lowerAngularDeferSyntax = (template) => {
|
|
476
|
-
if (!template.includes("@defer")) {
|
|
477
|
-
return {
|
|
478
|
-
slots: [],
|
|
479
|
-
template,
|
|
480
|
-
transformed: false
|
|
481
|
-
};
|
|
482
|
-
}
|
|
483
|
-
let cursor = 0;
|
|
484
|
-
let slotIndex = 0;
|
|
485
|
-
const slots = [];
|
|
486
|
-
let loweredTemplate = "";
|
|
487
|
-
let changed = false;
|
|
488
|
-
let nextState = consumeLoweredDeferStep({
|
|
489
|
-
changed,
|
|
490
|
-
cursor,
|
|
491
|
-
loweredTemplate,
|
|
492
|
-
slotIndex,
|
|
493
|
-
slots,
|
|
494
|
-
template
|
|
495
|
-
});
|
|
496
|
-
while (nextState) {
|
|
497
|
-
({ changed, cursor, slotIndex, template: loweredTemplate } = nextState);
|
|
498
|
-
nextState = consumeLoweredDeferStep({
|
|
499
|
-
changed,
|
|
500
|
-
cursor,
|
|
501
|
-
loweredTemplate,
|
|
502
|
-
slotIndex,
|
|
503
|
-
slots,
|
|
504
|
-
template
|
|
505
|
-
});
|
|
506
|
-
}
|
|
507
|
-
const transformedTemplate = slots.length > 0 ? loweredTemplate + template.slice(cursor) : template.replaceAll("@defer", "@defer");
|
|
508
|
-
return {
|
|
509
|
-
slots,
|
|
510
|
-
template: transformedTemplate,
|
|
511
|
-
transformed: slots.length > 0
|
|
512
|
-
};
|
|
513
|
-
};
|
|
514
|
-
|
|
515
|
-
// src/build/compileAngular.ts
|
|
516
|
-
var traceAngularPhase = async (name, fn, metadata) => {
|
|
517
|
-
const tracePhase = globalThis.__absoluteBuildTracePhase;
|
|
518
|
-
return tracePhase ? tracePhase(`compile/angular/${name}`, fn, metadata) : await fn();
|
|
519
|
-
};
|
|
520
|
-
var readTsconfigPathAliases = () => {
|
|
521
|
-
try {
|
|
522
|
-
const configPath = resolve(process.cwd(), "tsconfig.json");
|
|
523
|
-
const config = ts.readConfigFile(configPath, ts.sys.readFile).config;
|
|
524
|
-
const compilerOptions = config?.compilerOptions ?? {};
|
|
525
|
-
const baseUrl = resolve(process.cwd(), compilerOptions.baseUrl ?? ".");
|
|
526
|
-
const aliases = Object.entries(compilerOptions.paths ?? {}).map(([pattern, replacements]) => ({ pattern, replacements }));
|
|
527
|
-
return { aliases, baseUrl };
|
|
528
|
-
} catch {
|
|
529
|
-
return { aliases: [], baseUrl: process.cwd() };
|
|
530
|
-
}
|
|
531
|
-
};
|
|
532
|
-
var matchTsconfigAlias = (specifier, aliases, baseUrl, resolveSourceFile) => {
|
|
533
|
-
for (const alias of aliases) {
|
|
534
|
-
const wildcardIndex = alias.pattern.indexOf("*");
|
|
535
|
-
const exactMatch = wildcardIndex === -1;
|
|
536
|
-
if (exactMatch && specifier !== alias.pattern)
|
|
537
|
-
continue;
|
|
538
|
-
const prefix = exactMatch ? alias.pattern : alias.pattern.slice(0, wildcardIndex);
|
|
539
|
-
const suffix = exactMatch ? "" : alias.pattern.slice(wildcardIndex + 1);
|
|
540
|
-
if (!exactMatch && (!specifier.startsWith(prefix) || !specifier.endsWith(suffix))) {
|
|
541
|
-
continue;
|
|
542
|
-
}
|
|
543
|
-
const wildcardValue = exactMatch ? "" : specifier.slice(prefix.length, specifier.length - suffix.length);
|
|
544
|
-
for (const replacement of alias.replacements) {
|
|
545
|
-
const candidate = replacement.replace("*", wildcardValue);
|
|
546
|
-
const resolved = resolveSourceFile(resolve(baseUrl, candidate));
|
|
547
|
-
if (resolved)
|
|
548
|
-
return resolved;
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
return;
|
|
552
|
-
};
|
|
553
|
-
var resolveSourceFile = (candidate) => {
|
|
554
|
-
const candidates = candidate.match(/\.[cm]?[tj]sx?$/) ? [candidate] : [
|
|
555
|
-
`${candidate}.ts`,
|
|
556
|
-
`${candidate}.tsx`,
|
|
557
|
-
`${candidate}.js`,
|
|
558
|
-
`${candidate}.jsx`,
|
|
559
|
-
join(candidate, "index.ts"),
|
|
560
|
-
join(candidate, "index.tsx"),
|
|
561
|
-
join(candidate, "index.js"),
|
|
562
|
-
join(candidate, "index.jsx")
|
|
563
|
-
];
|
|
564
|
-
return candidates.find((file) => existsSync(file));
|
|
565
|
-
};
|
|
566
|
-
var createLegacyAngularAnimationUsageResolver = (rootDir) => {
|
|
567
|
-
const baseDir = resolve(rootDir);
|
|
568
|
-
const tsconfigAliases = readTsconfigPathAliases();
|
|
569
|
-
const transpiler = new Bun.Transpiler({ loader: "tsx" });
|
|
570
|
-
const scanCache = new Map;
|
|
571
|
-
const resolveLocalImport = (specifier, fromDir) => {
|
|
572
|
-
if (specifier.startsWith(".") || specifier.startsWith("/")) {
|
|
573
|
-
return resolveSourceFile(resolve(fromDir, specifier));
|
|
574
|
-
}
|
|
575
|
-
const aliased = matchTsconfigAlias(specifier, tsconfigAliases.aliases, tsconfigAliases.baseUrl, resolveSourceFile);
|
|
576
|
-
if (aliased)
|
|
577
|
-
return aliased;
|
|
578
|
-
try {
|
|
579
|
-
const resolved = Bun.resolveSync(specifier, fromDir);
|
|
580
|
-
if (resolved.includes("/node_modules/"))
|
|
581
|
-
return;
|
|
582
|
-
const absolute = resolve(resolved);
|
|
583
|
-
if (!absolute.startsWith(baseDir))
|
|
584
|
-
return;
|
|
585
|
-
return resolveSourceFile(absolute);
|
|
586
|
-
} catch {
|
|
587
|
-
return;
|
|
588
|
-
}
|
|
589
|
-
};
|
|
590
|
-
const scanFile = (filePath) => {
|
|
591
|
-
const actualPath = resolveSourceFile(filePath);
|
|
592
|
-
if (!actualPath) {
|
|
593
|
-
return Promise.resolve({
|
|
594
|
-
imports: [],
|
|
595
|
-
usesLegacyAnimations: false
|
|
596
|
-
});
|
|
597
|
-
}
|
|
598
|
-
const resolved = resolve(actualPath);
|
|
599
|
-
const cached = scanCache.get(resolved);
|
|
600
|
-
if (cached)
|
|
601
|
-
return cached;
|
|
602
|
-
const promise = (async () => {
|
|
603
|
-
let sourceCode;
|
|
604
|
-
try {
|
|
605
|
-
sourceCode = await fs.readFile(resolved, "utf-8");
|
|
606
|
-
} catch {
|
|
607
|
-
return { imports: [], usesLegacyAnimations: false };
|
|
608
|
-
}
|
|
609
|
-
let imports;
|
|
610
|
-
try {
|
|
611
|
-
imports = transpiler.scanImports(sourceCode);
|
|
612
|
-
} catch {
|
|
613
|
-
return { imports: [], usesLegacyAnimations: false };
|
|
614
|
-
}
|
|
615
|
-
return {
|
|
616
|
-
imports: imports.map((imp) => imp.path),
|
|
617
|
-
usesLegacyAnimations: imports.some((imp) => imp.path === "@angular/animations")
|
|
618
|
-
};
|
|
619
|
-
})();
|
|
620
|
-
scanCache.set(resolved, promise);
|
|
621
|
-
return promise;
|
|
622
|
-
};
|
|
623
|
-
const visit = async (filePath, visited = new Set) => {
|
|
624
|
-
const actualPath = resolveSourceFile(filePath);
|
|
625
|
-
if (!actualPath)
|
|
626
|
-
return false;
|
|
627
|
-
const resolved = resolve(actualPath);
|
|
628
|
-
if (visited.has(resolved))
|
|
629
|
-
return false;
|
|
630
|
-
visited.add(resolved);
|
|
631
|
-
const scan = await scanFile(resolved);
|
|
632
|
-
if (scan.usesLegacyAnimations)
|
|
633
|
-
return true;
|
|
634
|
-
for (const specifier of scan.imports) {
|
|
635
|
-
const importedPath = resolveLocalImport(specifier, dirname(resolved));
|
|
636
|
-
if (importedPath && await visit(importedPath, visited)) {
|
|
637
|
-
return true;
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
return false;
|
|
641
|
-
};
|
|
642
|
-
return (entryPath) => visit(entryPath);
|
|
643
|
-
};
|
|
644
|
-
var resolveDevClientDir = () => {
|
|
645
|
-
const projectRoot = process.cwd();
|
|
646
|
-
const fromSource = resolve(import.meta.dir, "../dev/client");
|
|
647
|
-
if (existsSync(fromSource) && fromSource.startsWith(projectRoot)) {
|
|
648
|
-
return fromSource;
|
|
649
|
-
}
|
|
650
|
-
const fromNodeModules = resolve(projectRoot, "node_modules/@absolutejs/absolute/dist/dev/client");
|
|
651
|
-
if (existsSync(fromNodeModules))
|
|
652
|
-
return fromNodeModules;
|
|
653
|
-
return resolve(import.meta.dir, "./dev/client");
|
|
654
|
-
};
|
|
655
|
-
var devClientDir = resolveDevClientDir();
|
|
656
|
-
var hmrClientPath = join(devClientDir, "hmrClient.ts").replace(/\\/g, "/");
|
|
657
|
-
var hmrRuntimePath = join(devClientDir, "handlers", "angularRuntime.ts").replace(/\\/g, "/");
|
|
658
|
-
var injectHMRRegistration = (content, sourceId) => {
|
|
659
|
-
const componentClassRegex = /(?:export\s+)?class\s+(\w+Component)\s/g;
|
|
660
|
-
const componentNames = [];
|
|
661
|
-
let match;
|
|
662
|
-
while ((match = componentClassRegex.exec(content)) !== null) {
|
|
663
|
-
if (match[1])
|
|
664
|
-
componentNames.push(match[1]);
|
|
665
|
-
}
|
|
666
|
-
if (componentNames.length === 0)
|
|
667
|
-
return content;
|
|
668
|
-
const registrations = componentNames.map((name) => ` if (typeof ${name} === 'function') window.__ANGULAR_HMR__.register('${sourceId}#${name}', ${name});`).join(`
|
|
669
|
-
`);
|
|
670
|
-
const hmrBlock = `
|
|
671
|
-
// Angular HMR Runtime Layer (Level 3) \u2014 Auto-registration
|
|
672
|
-
if (typeof window !== 'undefined' && window.__ANGULAR_HMR__) {
|
|
673
|
-
${registrations}
|
|
674
|
-
}
|
|
675
|
-
`;
|
|
676
|
-
return content + hmrBlock;
|
|
677
|
-
};
|
|
678
|
-
var formatDiagnosticMessage = (diagnostic) => {
|
|
679
|
-
try {
|
|
680
|
-
return ts.flattenDiagnosticMessageText(diagnostic.messageText, `
|
|
681
|
-
`);
|
|
682
|
-
} catch {
|
|
683
|
-
return String(diagnostic.messageText || "Unknown error");
|
|
684
|
-
}
|
|
685
|
-
};
|
|
686
|
-
var throwOnCompilationErrors = (diagnostics) => {
|
|
687
|
-
if (!diagnostics?.length)
|
|
688
|
-
return;
|
|
689
|
-
const errors = diagnostics.filter((diag) => diag.category === ts.DiagnosticCategory.Error);
|
|
690
|
-
if (!errors.length)
|
|
691
|
-
return;
|
|
692
|
-
const fullMessage = errors.map(formatDiagnosticMessage).join(`
|
|
693
|
-
`);
|
|
694
|
-
console.error("Angular compilation errors:", fullMessage);
|
|
695
|
-
throw new Error(fullMessage);
|
|
696
|
-
};
|
|
697
|
-
var resolveRelativePath = (fileName, resolvedOutDir, outDir) => {
|
|
698
|
-
if (fileName.startsWith(resolvedOutDir))
|
|
699
|
-
return fileName.substring(resolvedOutDir.length + 1);
|
|
700
|
-
if (fileName.startsWith(outDir))
|
|
701
|
-
return fileName.substring(outDir.length + 1);
|
|
702
|
-
return fileName;
|
|
703
|
-
};
|
|
704
|
-
var hasJsLikeExtension = (path) => /\.(js|ts|mjs|cjs)$/.test(path);
|
|
705
|
-
var rewriteRelativeJsSpecifier = (importerOutputPath, specifier, outputFiles) => {
|
|
706
|
-
if (specifier.endsWith(".ts"))
|
|
707
|
-
return specifier.replace(/\.ts$/, ".js");
|
|
708
|
-
if (hasJsLikeExtension(specifier))
|
|
709
|
-
return specifier;
|
|
710
|
-
const importerDir = dirname(importerOutputPath);
|
|
711
|
-
const fileCandidate = resolve(importerDir, `${specifier}.js`);
|
|
712
|
-
if (outputFiles?.has(fileCandidate) || existsSync(fileCandidate)) {
|
|
713
|
-
return `${specifier}.js`;
|
|
714
|
-
}
|
|
715
|
-
const indexCandidate = resolve(importerDir, specifier, "index.js");
|
|
716
|
-
if (outputFiles?.has(indexCandidate) || existsSync(indexCandidate)) {
|
|
717
|
-
return `${specifier}/index.js`;
|
|
718
|
-
}
|
|
719
|
-
return `${specifier}.js`;
|
|
720
|
-
};
|
|
721
|
-
var isRelativeModuleSpecifier = (specifier) => specifier.startsWith("./") || specifier.startsWith("../");
|
|
722
|
-
var extractLocalImportSpecifiers = (source, fileName) => {
|
|
723
|
-
const sourceFile = ts.createSourceFile(fileName, source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
|
|
724
|
-
const specifiers = [];
|
|
725
|
-
const addSpecifier = (node) => {
|
|
726
|
-
if (!node || !ts.isStringLiteralLike(node))
|
|
727
|
-
return;
|
|
728
|
-
const specifier = node.text;
|
|
729
|
-
if (isRelativeModuleSpecifier(specifier))
|
|
730
|
-
specifiers.push(specifier);
|
|
731
|
-
};
|
|
732
|
-
const visit = (node) => {
|
|
733
|
-
if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) {
|
|
734
|
-
addSpecifier(node.moduleSpecifier);
|
|
735
|
-
} else if (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword) {
|
|
736
|
-
addSpecifier(node.arguments[0]);
|
|
737
|
-
}
|
|
738
|
-
ts.forEachChild(node, visit);
|
|
739
|
-
};
|
|
740
|
-
visit(sourceFile);
|
|
741
|
-
return specifiers;
|
|
742
|
-
};
|
|
743
|
-
var resolveLocalTsImport = (fromFile, specifier) => {
|
|
744
|
-
if (!isRelativeModuleSpecifier(specifier))
|
|
745
|
-
return null;
|
|
746
|
-
const basePath = resolve(dirname(fromFile), specifier);
|
|
747
|
-
const candidates = /\.[cm]?[tj]sx?$/.test(basePath) ? [basePath] : [
|
|
748
|
-
`${basePath}.ts`,
|
|
749
|
-
`${basePath}.tsx`,
|
|
750
|
-
`${basePath}.mts`,
|
|
751
|
-
`${basePath}.cts`,
|
|
752
|
-
join(basePath, "index.ts"),
|
|
753
|
-
join(basePath, "index.tsx"),
|
|
754
|
-
join(basePath, "index.mts"),
|
|
755
|
-
join(basePath, "index.cts")
|
|
756
|
-
];
|
|
757
|
-
return candidates.map((candidate) => resolve(candidate)).find((candidate) => existsSync(candidate) && !candidate.endsWith(".d.ts")) ?? null;
|
|
758
|
-
};
|
|
759
|
-
var readFileForAotTransform = async (fileName, readFile) => {
|
|
760
|
-
const hostSource = readFile?.(fileName);
|
|
761
|
-
if (typeof hostSource === "string")
|
|
762
|
-
return hostSource;
|
|
763
|
-
return fs.readFile(fileName, "utf-8");
|
|
764
|
-
};
|
|
765
|
-
var safeStableStringify = (value) => {
|
|
766
|
-
const seen = new WeakSet;
|
|
767
|
-
return JSON.stringify(value, (_key, entry) => {
|
|
768
|
-
if (typeof entry === "function")
|
|
769
|
-
return `[Function:${entry.name}]`;
|
|
770
|
-
if (!entry || typeof entry !== "object")
|
|
771
|
-
return entry;
|
|
772
|
-
if (seen.has(entry))
|
|
773
|
-
return "[Circular]";
|
|
774
|
-
seen.add(entry);
|
|
775
|
-
if (Array.isArray(entry))
|
|
776
|
-
return entry;
|
|
777
|
-
return Object.fromEntries(Object.entries(entry).sort(([left], [right]) => left.localeCompare(right)));
|
|
778
|
-
});
|
|
779
|
-
};
|
|
780
|
-
var collectAngularResourcePaths = (source, fileDir) => {
|
|
781
|
-
const paths = [];
|
|
782
|
-
const templateUrlMatch = findUncommentedMatch(source, /templateUrl\s*:\s*['"]([^'"]+)['"]/);
|
|
783
|
-
if (templateUrlMatch?.[1])
|
|
784
|
-
paths.push(join(fileDir, templateUrlMatch[1]));
|
|
785
|
-
const styleUrlMatch = findUncommentedMatch(source, /styleUrl\s*:\s*['"]([^'"]+)['"]/);
|
|
786
|
-
if (styleUrlMatch?.[1])
|
|
787
|
-
paths.push(join(fileDir, styleUrlMatch[1]));
|
|
788
|
-
const styleUrlsMatch = findUncommentedMatch(source, /styleUrls\s*:\s*\[([^\]]+)\]/);
|
|
789
|
-
const urlMatches = styleUrlsMatch?.[1]?.match(/['"]([^'"]+)['"]/g);
|
|
790
|
-
if (urlMatches) {
|
|
791
|
-
for (const urlMatch of urlMatches) {
|
|
792
|
-
paths.push(join(fileDir, urlMatch.replace(/['"]/g, "")));
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
return paths.map((path) => resolve(path));
|
|
796
|
-
};
|
|
797
|
-
var readResourceCacheFile = async (cachePath) => {
|
|
798
|
-
try {
|
|
799
|
-
const entry = JSON.parse(await fs.readFile(cachePath, "utf-8"));
|
|
800
|
-
if (entry.version !== 1 || typeof entry.source !== "string") {
|
|
801
|
-
return null;
|
|
802
|
-
}
|
|
803
|
-
return entry;
|
|
804
|
-
} catch {
|
|
805
|
-
return null;
|
|
806
|
-
}
|
|
807
|
-
};
|
|
808
|
-
var writeResourceCacheFile = async (cachePath, source) => {
|
|
809
|
-
await fs.mkdir(dirname(cachePath), { recursive: true });
|
|
810
|
-
await fs.writeFile(cachePath, JSON.stringify({
|
|
811
|
-
source,
|
|
812
|
-
version: 1
|
|
813
|
-
}), "utf-8");
|
|
814
|
-
};
|
|
815
|
-
var resolveResourceTransformCachePath = async (filePath, source, stylePreprocessors) => {
|
|
816
|
-
const resourcePaths = collectAngularResourcePaths(source, dirname(filePath));
|
|
817
|
-
const resourceContents = await Promise.all(resourcePaths.map(async (resourcePath) => {
|
|
818
|
-
const content = await fs.readFile(resourcePath, "utf-8");
|
|
819
|
-
return `${resourcePath}\x00${content}`;
|
|
820
|
-
}));
|
|
821
|
-
const cacheInput = [
|
|
822
|
-
"v1",
|
|
823
|
-
filePath,
|
|
824
|
-
source,
|
|
825
|
-
...resourceContents,
|
|
826
|
-
safeStableStringify(stylePreprocessors ?? null)
|
|
827
|
-
].join("\x00");
|
|
828
|
-
const cacheKey = Bun.hash(cacheInput).toString(BASE_36_RADIX);
|
|
829
|
-
return join(process.cwd(), ".absolutejs", "cache", "angular-resources", `${cacheKey}.json`);
|
|
830
|
-
};
|
|
831
|
-
var precomputeAotResourceTransforms = async (inputPaths, readFile, stylePreprocessors) => {
|
|
832
|
-
const transformedSources = new Map;
|
|
833
|
-
const visited = new Set;
|
|
834
|
-
const stats = {
|
|
835
|
-
cacheHits: 0,
|
|
836
|
-
cacheMisses: 0,
|
|
837
|
-
filesVisited: 0,
|
|
838
|
-
transformedFiles: 0
|
|
839
|
-
};
|
|
840
|
-
const transformFile = async (filePath) => {
|
|
841
|
-
const resolvedPath = resolve(filePath);
|
|
842
|
-
if (visited.has(resolvedPath))
|
|
843
|
-
return;
|
|
844
|
-
visited.add(resolvedPath);
|
|
845
|
-
if (!existsSync(resolvedPath) || resolvedPath.endsWith(".d.ts"))
|
|
846
|
-
return;
|
|
847
|
-
stats.filesVisited += 1;
|
|
848
|
-
const source = await readFileForAotTransform(resolvedPath, readFile);
|
|
849
|
-
const cachePath = await resolveResourceTransformCachePath(resolvedPath, source, stylePreprocessors);
|
|
850
|
-
const cached = await readResourceCacheFile(cachePath);
|
|
851
|
-
let transformedSource;
|
|
852
|
-
if (cached) {
|
|
853
|
-
stats.cacheHits += 1;
|
|
854
|
-
transformedSource = cached.source;
|
|
855
|
-
} else {
|
|
856
|
-
stats.cacheMisses += 1;
|
|
857
|
-
const transformed = await inlineResources(source, dirname(resolvedPath), stylePreprocessors);
|
|
858
|
-
transformedSource = transformed.source;
|
|
859
|
-
await writeResourceCacheFile(cachePath, transformedSource);
|
|
860
|
-
}
|
|
861
|
-
if (transformedSource !== source) {
|
|
862
|
-
stats.transformedFiles += 1;
|
|
863
|
-
transformedSources.set(resolvedPath, transformedSource);
|
|
864
|
-
}
|
|
865
|
-
const imports = extractLocalImportSpecifiers(source, resolvedPath);
|
|
866
|
-
await Promise.all(imports.map(async (specifier) => {
|
|
867
|
-
const resolvedImport = resolveLocalTsImport(resolvedPath, specifier);
|
|
868
|
-
if (resolvedImport)
|
|
869
|
-
await transformFile(resolvedImport);
|
|
870
|
-
}));
|
|
871
|
-
};
|
|
872
|
-
await Promise.all(inputPaths.map((inputPath) => transformFile(inputPath)));
|
|
873
|
-
return { stats, transformedSources };
|
|
874
|
-
};
|
|
875
|
-
var compileAngularFiles = async (inputPaths, outDir, stylePreprocessors) => {
|
|
876
|
-
const islandMetadataByOutputPath = await traceAngularPhase("aot/island-metadata", () => new Map(inputPaths.map((inputPath) => {
|
|
877
|
-
const outputPath = resolve(join(outDir, relative(process.cwd(), resolve(inputPath)).replace(/\.[cm]?[tj]sx?$/, ".js")));
|
|
878
|
-
return [
|
|
879
|
-
outputPath,
|
|
880
|
-
buildIslandMetadataExports(readFileSync(inputPath, "utf-8"))
|
|
881
|
-
];
|
|
882
|
-
})), { entries: inputPaths.length });
|
|
883
|
-
await traceAngularPhase("aot/preload-compiler", () => import("@angular/compiler"));
|
|
884
|
-
const { readConfiguration, performCompilation, EmitFlags } = await traceAngularPhase("aot/import-compiler-cli", () => import("@angular/compiler-cli"));
|
|
885
|
-
const tsLibDir = await traceAngularPhase("aot/resolve-typescript-lib", () => {
|
|
886
|
-
const tsPath = __require.resolve("typescript");
|
|
887
|
-
const tsRootDir = dirname(tsPath);
|
|
888
|
-
return tsRootDir.endsWith("lib") ? tsRootDir : resolve(tsRootDir, "lib");
|
|
889
|
-
});
|
|
890
|
-
const config = await traceAngularPhase("aot/read-configuration", () => readConfiguration("./tsconfig.json"));
|
|
891
|
-
const options = {
|
|
892
|
-
emitDecoratorMetadata: true,
|
|
893
|
-
esModuleInterop: true,
|
|
894
|
-
experimentalDecorators: true,
|
|
895
|
-
module: ts.ModuleKind.ESNext,
|
|
896
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
897
|
-
newLine: ts.NewLineKind.LineFeed,
|
|
898
|
-
noLib: false,
|
|
899
|
-
outDir,
|
|
900
|
-
skipLibCheck: true,
|
|
901
|
-
target: ts.ScriptTarget.ES2022,
|
|
902
|
-
...config.options
|
|
903
|
-
};
|
|
904
|
-
options.target = ts.ScriptTarget.ES2022;
|
|
905
|
-
options.experimentalDecorators = true;
|
|
906
|
-
options.emitDecoratorMetadata = true;
|
|
907
|
-
options.newLine = ts.NewLineKind.LineFeed;
|
|
908
|
-
options.outDir = outDir;
|
|
909
|
-
options.noEmit = false;
|
|
910
|
-
options.incremental = false;
|
|
911
|
-
options.tsBuildInfoFile = undefined;
|
|
912
|
-
options.rootDir = process.cwd();
|
|
913
|
-
const host = await traceAngularPhase("aot/create-compiler-host", () => ts.createCompilerHost(options));
|
|
914
|
-
const originalGetDefaultLibLocation = host.getDefaultLibLocation;
|
|
915
|
-
host.getDefaultLibLocation = () => tsLibDir || (originalGetDefaultLibLocation ? originalGetDefaultLibLocation() : "");
|
|
916
|
-
const originalGetDefaultLibFileName = host.getDefaultLibFileName;
|
|
917
|
-
host.getDefaultLibFileName = (opts) => {
|
|
918
|
-
const fileName = originalGetDefaultLibFileName ? originalGetDefaultLibFileName(opts) : "lib.d.ts";
|
|
919
|
-
return basename(fileName);
|
|
920
|
-
};
|
|
921
|
-
const originalGetSourceFile = host.getSourceFile;
|
|
922
|
-
host.getSourceFile = (fileName, languageVersion, onError) => {
|
|
923
|
-
if (fileName.startsWith("lib.") && fileName.endsWith(".d.ts") && tsLibDir) {
|
|
924
|
-
const resolvedPath = join(tsLibDir, fileName);
|
|
925
|
-
return originalGetSourceFile?.call(host, resolvedPath, languageVersion, onError);
|
|
926
|
-
}
|
|
927
|
-
return originalGetSourceFile?.call(host, fileName, languageVersion, onError);
|
|
928
|
-
};
|
|
929
|
-
const emitted = {};
|
|
930
|
-
const resolvedOutDir = resolve(outDir);
|
|
931
|
-
host.writeFile = (fileName, text) => {
|
|
932
|
-
const relativePath = resolveRelativePath(fileName, resolvedOutDir, outDir);
|
|
933
|
-
emitted[relativePath] = text;
|
|
934
|
-
};
|
|
935
|
-
const originalReadFile = host.readFile;
|
|
936
|
-
const { stats: aotResourceTransformStats, transformedSources } = await traceAngularPhase("aot/precompute-resources", () => precomputeAotResourceTransforms(inputPaths, originalReadFile?.bind(host), stylePreprocessors), { entries: inputPaths.length });
|
|
937
|
-
await traceAngularPhase("aot/resource-cache-summary", () => {
|
|
938
|
-
return;
|
|
939
|
-
}, {
|
|
940
|
-
cacheHits: aotResourceTransformStats.cacheHits,
|
|
941
|
-
cacheMisses: aotResourceTransformStats.cacheMisses,
|
|
942
|
-
filesVisited: aotResourceTransformStats.filesVisited,
|
|
943
|
-
transformedFiles: aotResourceTransformStats.transformedFiles
|
|
944
|
-
});
|
|
945
|
-
host.readFile = (fileName) => {
|
|
946
|
-
const source = originalReadFile ? originalReadFile.call(host, fileName) : undefined;
|
|
947
|
-
if (typeof source !== "string")
|
|
948
|
-
return source;
|
|
949
|
-
if (!fileName.endsWith(".ts") || fileName.endsWith(".d.ts")) {
|
|
950
|
-
return source;
|
|
951
|
-
}
|
|
952
|
-
const resolvedPath = resolve(fileName);
|
|
953
|
-
return transformedSources.get(resolvedPath) ?? source;
|
|
954
|
-
};
|
|
955
|
-
const originalGetSourceFileForCompile = host.getSourceFile;
|
|
956
|
-
host.getSourceFile = (fileName, languageVersion, onError) => {
|
|
957
|
-
const source = transformedSources.get(resolve(fileName));
|
|
958
|
-
if (source) {
|
|
959
|
-
return ts.createSourceFile(fileName, source, languageVersion, true);
|
|
960
|
-
}
|
|
961
|
-
return originalGetSourceFileForCompile?.call(host, fileName, languageVersion, onError);
|
|
962
|
-
};
|
|
963
|
-
let diagnostics;
|
|
964
|
-
try {
|
|
965
|
-
({ diagnostics } = await traceAngularPhase("aot/perform-compilation", () => performCompilation({
|
|
966
|
-
emitFlags: EmitFlags.Default,
|
|
967
|
-
host,
|
|
968
|
-
options,
|
|
969
|
-
rootNames: inputPaths
|
|
970
|
-
}), { entries: inputPaths.length }));
|
|
971
|
-
} finally {
|
|
972
|
-
host.readFile = originalReadFile;
|
|
973
|
-
host.getSourceFile = originalGetSourceFileForCompile;
|
|
974
|
-
}
|
|
975
|
-
await traceAngularPhase("aot/check-diagnostics", () => throwOnCompilationErrors(diagnostics));
|
|
976
|
-
const entries = await traceAngularPhase("aot/postprocess-emitted-js", () => {
|
|
977
|
-
const rawEntries = Object.entries(emitted).filter(([fileName]) => fileName.endsWith(".js")).map(([fileName, content]) => ({
|
|
978
|
-
content,
|
|
979
|
-
target: join(outDir, fileName)
|
|
980
|
-
}));
|
|
981
|
-
const outputFiles = new Set(rawEntries.map(({ target }) => resolve(target)));
|
|
982
|
-
return rawEntries.map(({ content, target }) => {
|
|
983
|
-
let processedContent = content.replace(/from\s+(['"])(\.\.?\/[^'"]+)(\1)/g, (match, quote, path) => {
|
|
984
|
-
const rewritten = rewriteRelativeJsSpecifier(target, path, outputFiles);
|
|
985
|
-
if (rewritten !== path) {
|
|
986
|
-
return `from ${quote}${rewritten}${quote}`;
|
|
987
|
-
}
|
|
988
|
-
return match;
|
|
989
|
-
});
|
|
990
|
-
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");
|
|
991
|
-
processedContent = processedContent.replace(/import\s*{\s*([^}]*)\bInjectFlags\b([^}]*)\s*}\s*from\s*['"]@angular\/core['"]/g, (match, before, after) => {
|
|
992
|
-
const cleaned = (before + after).replace(/,\s*,/g, ",").replace(/^\s*,\s*/, "").replace(/,\s*$/, "");
|
|
993
|
-
return cleaned ? `import { ${cleaned}, InternalInjectFlags } from '@angular/core'` : `import { InternalInjectFlags } from '@angular/core'`;
|
|
994
|
-
});
|
|
995
|
-
processedContent = processedContent.replace(/\b(?<!Internal)InjectFlags\b/g, "InternalInjectFlags");
|
|
996
|
-
processedContent += islandMetadataByOutputPath.get(resolve(target)) ?? "";
|
|
997
|
-
return { content: processedContent, target };
|
|
998
|
-
});
|
|
999
|
-
});
|
|
1000
|
-
await traceAngularPhase("aot/write-output", () => Promise.all(entries.map(async ({ target, content }) => {
|
|
1001
|
-
await fs.mkdir(dirname(target), { recursive: true });
|
|
1002
|
-
await fs.writeFile(target, content, "utf-8");
|
|
1003
|
-
})), { outputs: entries.length });
|
|
1004
|
-
return await traceAngularPhase("aot/collect-output-paths", () => entries.map(({ target }) => target), { outputs: entries.length });
|
|
1005
|
-
};
|
|
1006
|
-
var compileAngularFile = async (inputPath, outDir, stylePreprocessors) => compileAngularFiles([inputPath], outDir, stylePreprocessors);
|
|
1007
|
-
var jitContentCache = new Map;
|
|
1008
|
-
var wrapperOutputCache = new Map;
|
|
1009
|
-
var escapeTemplateContent = (content) => content.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$\{/g, "\\${");
|
|
1010
|
-
var findUncommentedMatch = (source, pattern) => {
|
|
1011
|
-
const re = new RegExp(pattern.source, pattern.flags.includes("g") ? pattern.flags : pattern.flags + "g");
|
|
1012
|
-
let match;
|
|
1013
|
-
while ((match = re.exec(source)) !== null) {
|
|
1014
|
-
const lineStart = source.lastIndexOf(`
|
|
1015
|
-
`, match.index - 1) + 1;
|
|
1016
|
-
const beforeMatch = source.slice(lineStart, match.index);
|
|
1017
|
-
if (!/^\s*\/\//.test(beforeMatch))
|
|
1018
|
-
return match;
|
|
1019
|
-
}
|
|
1020
|
-
return null;
|
|
1021
|
-
};
|
|
1022
|
-
var resolveAngularDeferImportSpecifier = () => {
|
|
1023
|
-
const sourceEntry = resolve(import.meta.dir, "../angular/components/index.ts");
|
|
1024
|
-
if (existsSync(sourceEntry)) {
|
|
1025
|
-
return sourceEntry.replace(/\\/g, "/");
|
|
1026
|
-
}
|
|
1027
|
-
return "@absolutejs/absolute/angular/components";
|
|
1028
|
-
};
|
|
1029
|
-
var ensureDeferSlotImport = (source, importSpecifier = "@absolutejs/absolute/angular/components") => {
|
|
1030
|
-
if (source.includes("DeferSlotComponent"))
|
|
1031
|
-
return source;
|
|
1032
|
-
const resolvedImportSpecifier = JSON.stringify(importSpecifier);
|
|
1033
|
-
const importLine = `import { DeferErrorTemplateDirective, DeferFallbackTemplateDirective, DeferResolvedTemplateDirective, DeferSlotComponent } from ${resolvedImportSpecifier};
|
|
1034
|
-
`;
|
|
1035
|
-
const lastImportMatch = [...source.matchAll(/^import[\s\S]*?;$/gm)].pop();
|
|
1036
|
-
if (!lastImportMatch || lastImportMatch.index === undefined) {
|
|
1037
|
-
return importLine + source;
|
|
1038
|
-
}
|
|
1039
|
-
const insertAt = lastImportMatch.index + lastImportMatch[0].length;
|
|
1040
|
-
return `${source.slice(0, insertAt)}
|
|
1041
|
-
${importLine}${source.slice(insertAt)}`;
|
|
1042
|
-
};
|
|
1043
|
-
var ensureComponentImportsHasDeferSlot = (source) => {
|
|
1044
|
-
const importListMatch = source.match(/imports\s*:\s*\[([\s\S]*?)\]/);
|
|
1045
|
-
if (importListMatch) {
|
|
1046
|
-
if (/\bDeferSlotComponent\b/.test(importListMatch[1] ?? "") && /\bDeferResolvedTemplateDirective\b/.test(importListMatch[1] ?? "") && /\bDeferFallbackTemplateDirective\b/.test(importListMatch[1] ?? "") && /\bDeferErrorTemplateDirective\b/.test(importListMatch[1] ?? "")) {
|
|
1047
|
-
return source;
|
|
1048
|
-
}
|
|
1049
|
-
return source.replace(/imports\s*:\s*\[([\s\S]*?)\]/, (match, importsContent) => {
|
|
1050
|
-
const trimmed = importsContent.trim();
|
|
1051
|
-
const entries = trimmed.split(",").map((entry) => entry.trim()).filter(Boolean);
|
|
1052
|
-
for (const requiredImport of [
|
|
1053
|
-
"DeferSlotComponent",
|
|
1054
|
-
"DeferResolvedTemplateDirective",
|
|
1055
|
-
"DeferFallbackTemplateDirective",
|
|
1056
|
-
"DeferErrorTemplateDirective"
|
|
1057
|
-
]) {
|
|
1058
|
-
if (!entries.includes(requiredImport)) {
|
|
1059
|
-
entries.push(requiredImport);
|
|
1060
|
-
}
|
|
1061
|
-
}
|
|
1062
|
-
const nextContent = entries.join(", ");
|
|
1063
|
-
return `imports: [${nextContent}]`;
|
|
1064
|
-
});
|
|
1065
|
-
}
|
|
1066
|
-
return source.replace(/@Component\(\s*{/, `@Component({
|
|
1067
|
-
imports: [DeferSlotComponent, DeferResolvedTemplateDirective, DeferFallbackTemplateDirective, DeferErrorTemplateDirective],`);
|
|
1068
|
-
};
|
|
1069
|
-
var escapeTemplateLiteralValue = (value) => value.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$\{/g, "\\${");
|
|
1070
|
-
var skipInterpolatedExpression2 = (value, start) => {
|
|
1071
|
-
const cursor = start + 2;
|
|
1072
|
-
while (cursor < value.length - 1) {
|
|
1073
|
-
const end = value.indexOf("}}", cursor);
|
|
1074
|
-
if (end < 0) {
|
|
1075
|
-
return value.length;
|
|
1076
|
-
}
|
|
1077
|
-
return end + 2;
|
|
1078
|
-
}
|
|
1079
|
-
return value.length;
|
|
1080
|
-
};
|
|
1081
|
-
var buildResolverTemplateLiteral = (value) => {
|
|
1082
|
-
const parts = [];
|
|
1083
|
-
let cursor = 0;
|
|
1084
|
-
while (cursor < value.length) {
|
|
1085
|
-
const interpolationStart = value.indexOf("{{", cursor);
|
|
1086
|
-
if (interpolationStart < 0) {
|
|
1087
|
-
parts.push(escapeTemplateLiteralValue(value.slice(cursor)));
|
|
1088
|
-
break;
|
|
1089
|
-
}
|
|
1090
|
-
parts.push(escapeTemplateLiteralValue(value.slice(cursor, interpolationStart)));
|
|
1091
|
-
const nextCursor = skipInterpolatedExpression2(value, interpolationStart);
|
|
1092
|
-
if (nextCursor >= value.length) {
|
|
1093
|
-
parts.push(escapeTemplateLiteralValue(value.slice(interpolationStart)));
|
|
1094
|
-
break;
|
|
1095
|
-
}
|
|
1096
|
-
const rawExpression = value.slice(interpolationStart + 2, nextCursor - 2).trim();
|
|
1097
|
-
const expression = rawExpression.length === 0 ? "''" : rawExpression;
|
|
1098
|
-
const expressionLiteral = JSON.stringify(expression);
|
|
1099
|
-
parts.push(`\${this.__absoluteDeferResolveTemplateExpression(${expressionLiteral})}`);
|
|
1100
|
-
cursor = nextCursor;
|
|
1101
|
-
}
|
|
1102
|
-
return parts.join("");
|
|
1103
|
-
};
|
|
1104
|
-
var buildDeferSlotTemplateResolver = () => ` __absoluteDeferTemplateExpressionCache = new Map<string, string>();
|
|
1105
|
-
` + ` __absoluteDeferResolveTemplateExpression(expression: string) {
|
|
1106
|
-
` + ` const cached = this.__absoluteDeferTemplateExpressionCache.get(expression);
|
|
1107
|
-
` + ` if (cached !== undefined) return cached;
|
|
1108
|
-
` + `
|
|
1109
|
-
` + ` const scope = new Proxy(this, {
|
|
1110
|
-
` + ` get: (_target, property) => {
|
|
1111
|
-
` + ` const value = (this as Record<PropertyKey, unknown>)[property];
|
|
1112
|
-
` + ` return typeof value === "function" ? value.bind(this) : value;
|
|
1113
|
-
` + ` }
|
|
1114
|
-
` + ` });
|
|
1115
|
-
` + ` let value = '';
|
|
1116
|
-
` + ` try {
|
|
1117
|
-
` + ` const evaluate = new Function(
|
|
1118
|
-
` + ` 'scope',
|
|
1119
|
-
` + ` "with (scope) { return (" + expression + "); }"
|
|
1120
|
-
` + ` );
|
|
1121
|
-
` + `
|
|
1122
|
-
` + ` const resolvedValue = evaluate(scope);
|
|
1123
|
-
` + ` value = resolvedValue == null ? '' : String(resolvedValue);
|
|
1124
|
-
` + ` } catch (_error) {
|
|
1125
|
-
` + ` value = '';
|
|
1126
|
-
` + ` }
|
|
1127
|
-
` + ` this.__absoluteDeferTemplateExpressionCache.set(expression, value);
|
|
1128
|
-
` + ` return value;
|
|
1129
|
-
` + ` }
|
|
1130
|
-
|
|
1131
|
-
`;
|
|
1132
|
-
var buildDeferSlotFields = (slots) => [
|
|
1133
|
-
buildDeferSlotTemplateResolver(),
|
|
1134
|
-
...slots.map((slot, index) => {
|
|
1135
|
-
const htmlField = ` __absoluteDeferHtml${index} = () => \`${buildResolverTemplateLiteral(slot.resolvedHtml)}\`;
|
|
1136
|
-
`;
|
|
1137
|
-
const dataField = slot.resolvedBindings.length > 0 ? ` __absoluteDeferData${index} = () => ({
|
|
1138
|
-
${slot.resolvedBindings.map((binding) => ` "${binding.key}": this.__absoluteDeferResolveTemplateExpression(${JSON.stringify(binding.expression)})`).join(`,
|
|
1139
|
-
`)}
|
|
1140
|
-
});
|
|
1141
|
-
` : ` __absoluteDeferData${index} = () => ({});
|
|
1142
|
-
`;
|
|
1143
|
-
return `${htmlField + dataField} __absoluteDeferResolvePayload${index} = () => new Promise<any>((resolve) => {
|
|
1144
|
-
` + ` setTimeout(() => resolve({ kind: 'angular-defer', state: 'resolved', html: this.__absoluteDeferHtml${index}(), data: this.__absoluteDeferData${index}() }), ${slot.delayMs});
|
|
1145
|
-
` + ` });
|
|
1146
|
-
`;
|
|
1147
|
-
})
|
|
1148
|
-
].join(`
|
|
1149
|
-
`);
|
|
1150
|
-
var injectDeferSlotFields = (source, slots, importSpecifier = "@absolutejs/absolute/angular") => {
|
|
1151
|
-
if (slots.length === 0)
|
|
1152
|
-
return source;
|
|
1153
|
-
let rewritten = ensureDeferSlotImport(source, importSpecifier);
|
|
1154
|
-
rewritten = ensureComponentImportsHasDeferSlot(rewritten);
|
|
1155
|
-
const fields = buildDeferSlotFields(slots);
|
|
1156
|
-
return rewritten.replace(/export(?:\s+default)?\s+class\s+([A-Za-z_$][\w$]*)\s*{/, (match) => `${match}
|
|
1157
|
-
${fields}
|
|
1158
|
-
`);
|
|
1159
|
-
};
|
|
1160
|
-
var readAndEscapeFile = async (filePath, stylePreprocessors) => {
|
|
1161
|
-
if (!existsSync(filePath)) {
|
|
1162
|
-
throw new Error(`Unable to inline Angular style resource: file not found at ${filePath}`);
|
|
1163
|
-
}
|
|
1164
|
-
const content = await compileStyleFileIfNeeded(filePath, stylePreprocessors);
|
|
1165
|
-
return escapeTemplateContent(content);
|
|
1166
|
-
};
|
|
1167
|
-
var inlineTemplateAndLowerDefer = async (source, fileDir) => {
|
|
1168
|
-
const templateUrlMatch = findUncommentedMatch(source, /templateUrl\s*:\s*['"]([^'"]+)['"]/);
|
|
1169
|
-
if (templateUrlMatch?.[1]) {
|
|
1170
|
-
const templatePath = join(fileDir, templateUrlMatch[1]);
|
|
1171
|
-
if (!existsSync(templatePath)) {
|
|
1172
|
-
throw new Error(`Unable to inline Angular templateUrl "${templateUrlMatch[1]}": file not found at ${templatePath}`);
|
|
1173
|
-
}
|
|
1174
|
-
const templateRaw2 = await fs.readFile(templatePath, "utf-8");
|
|
1175
|
-
const lowered2 = lowerAngularDeferSyntax(templateRaw2);
|
|
1176
|
-
const escaped2 = escapeTemplateContent(lowered2.template);
|
|
1177
|
-
const replacedSource2 = source.slice(0, templateUrlMatch.index) + `template: \`${escaped2}\`` + source.slice(templateUrlMatch.index + templateUrlMatch[0].length);
|
|
1178
|
-
return {
|
|
1179
|
-
deferSlots: lowered2.slots,
|
|
1180
|
-
source: injectDeferSlotFields(replacedSource2, lowered2.slots, resolveAngularDeferImportSpecifier())
|
|
1181
|
-
};
|
|
1182
|
-
}
|
|
1183
|
-
const inlineTemplateMatch = findUncommentedMatch(source, /template\s*:\s*(`([\s\S]*?)`|'([^']*)'|"([^"]*)")/);
|
|
1184
|
-
if (!inlineTemplateMatch) {
|
|
1185
|
-
return { deferSlots: [], source };
|
|
1186
|
-
}
|
|
1187
|
-
const templateRaw = inlineTemplateMatch[2] ?? inlineTemplateMatch[3] ?? inlineTemplateMatch[4] ?? "";
|
|
1188
|
-
const lowered = lowerAngularDeferSyntax(templateRaw);
|
|
1189
|
-
if (lowered.slots.length === 0 && lowered.template === templateRaw) {
|
|
1190
|
-
return { deferSlots: lowered.slots, source };
|
|
1191
|
-
}
|
|
1192
|
-
const escaped = escapeTemplateContent(lowered.template);
|
|
1193
|
-
const replacedSource = source.slice(0, inlineTemplateMatch.index) + `template: \`${escaped}\`` + source.slice(inlineTemplateMatch.index + inlineTemplateMatch[0].length);
|
|
1194
|
-
return {
|
|
1195
|
-
deferSlots: lowered.slots,
|
|
1196
|
-
source: injectDeferSlotFields(replacedSource, lowered.slots, resolveAngularDeferImportSpecifier())
|
|
1197
|
-
};
|
|
1198
|
-
};
|
|
1199
|
-
var inlineTemplateAndLowerDeferSync = (source, fileDir) => {
|
|
1200
|
-
const templateUrlMatch = findUncommentedMatch(source, /templateUrl\s*:\s*['"]([^'"]+)['"]/);
|
|
1201
|
-
if (templateUrlMatch?.[1]) {
|
|
1202
|
-
const templatePath = join(fileDir, templateUrlMatch[1]);
|
|
1203
|
-
if (!existsSync(templatePath)) {
|
|
1204
|
-
throw new Error(`Unable to inline Angular templateUrl "${templateUrlMatch[1]}": file not found at ${templatePath}`);
|
|
1205
|
-
}
|
|
1206
|
-
const templateRaw2 = readFileSync(templatePath, "utf-8");
|
|
1207
|
-
const lowered2 = lowerAngularDeferSyntax(templateRaw2);
|
|
1208
|
-
const escaped2 = escapeTemplateContent(lowered2.template);
|
|
1209
|
-
const replacedSource2 = source.slice(0, templateUrlMatch.index) + `template: \`${escaped2}\`` + source.slice(templateUrlMatch.index + templateUrlMatch[0].length);
|
|
1210
|
-
return {
|
|
1211
|
-
deferSlots: lowered2.slots,
|
|
1212
|
-
source: injectDeferSlotFields(replacedSource2, lowered2.slots, resolveAngularDeferImportSpecifier())
|
|
1213
|
-
};
|
|
1214
|
-
}
|
|
1215
|
-
const inlineTemplateMatch = findUncommentedMatch(source, /template\s*:\s*(`([\s\S]*?)`|'([^']*)'|"([^"]*)")/);
|
|
1216
|
-
if (!inlineTemplateMatch) {
|
|
1217
|
-
return { deferSlots: [], source };
|
|
1218
|
-
}
|
|
1219
|
-
const templateRaw = inlineTemplateMatch[2] ?? inlineTemplateMatch[3] ?? inlineTemplateMatch[4] ?? "";
|
|
1220
|
-
const lowered = lowerAngularDeferSyntax(templateRaw);
|
|
1221
|
-
if (lowered.slots.length === 0 && lowered.template === templateRaw) {
|
|
1222
|
-
return { deferSlots: lowered.slots, source };
|
|
1223
|
-
}
|
|
1224
|
-
const escaped = escapeTemplateContent(lowered.template);
|
|
1225
|
-
const replacedSource = source.slice(0, inlineTemplateMatch.index) + `template: \`${escaped}\`` + source.slice(inlineTemplateMatch.index + inlineTemplateMatch[0].length);
|
|
1226
|
-
return {
|
|
1227
|
-
deferSlots: lowered.slots,
|
|
1228
|
-
source: injectDeferSlotFields(replacedSource, lowered.slots, resolveAngularDeferImportSpecifier())
|
|
1229
|
-
};
|
|
1230
|
-
};
|
|
1231
|
-
var inlineStyleUrls = async (source, fileDir, stylePreprocessors) => {
|
|
1232
|
-
const styleUrlsMatch = findUncommentedMatch(source, /styleUrls\s*:\s*\[([^\]]+)\]/);
|
|
1233
|
-
if (!styleUrlsMatch?.[1])
|
|
1234
|
-
return source;
|
|
1235
|
-
const urlMatches = styleUrlsMatch[1].match(/['"]([^'"]+)['"]/g);
|
|
1236
|
-
if (!urlMatches)
|
|
1237
|
-
return source;
|
|
1238
|
-
const stylePromises = urlMatches.map((urlMatch) => {
|
|
1239
|
-
const styleUrl = urlMatch.replace(/['"]/g, "");
|
|
1240
|
-
return readAndEscapeFile(join(fileDir, styleUrl), stylePreprocessors);
|
|
1241
|
-
});
|
|
1242
|
-
const results = await Promise.all(stylePromises);
|
|
1243
|
-
const inlinedStyles = results.filter(Boolean).map((escaped) => `\`${escaped}\``);
|
|
1244
|
-
if (inlinedStyles.length === 0)
|
|
1245
|
-
return source;
|
|
1246
|
-
return source.slice(0, styleUrlsMatch.index) + `styles: [${inlinedStyles.join(", ")}]` + source.slice(styleUrlsMatch.index + styleUrlsMatch[0].length);
|
|
1247
|
-
};
|
|
1248
|
-
var inlineSingleStyleUrl = async (source, fileDir, stylePreprocessors) => {
|
|
1249
|
-
const styleUrlMatch = findUncommentedMatch(source, /styleUrl\s*:\s*['"]([^'"]+)['"]/);
|
|
1250
|
-
if (!styleUrlMatch?.[1])
|
|
1251
|
-
return source;
|
|
1252
|
-
const escaped = await readAndEscapeFile(join(fileDir, styleUrlMatch[1]), stylePreprocessors);
|
|
1253
|
-
if (!escaped)
|
|
1254
|
-
return source;
|
|
1255
|
-
return source.slice(0, styleUrlMatch.index) + `styles: [\`${escaped}\`]` + source.slice(styleUrlMatch.index + styleUrlMatch[0].length);
|
|
1256
|
-
};
|
|
1257
|
-
var inlineResources = async (source, fileDir, stylePreprocessors) => {
|
|
1258
|
-
const inlinedTemplate = await inlineTemplateAndLowerDefer(source, fileDir);
|
|
1259
|
-
let result = inlinedTemplate.source;
|
|
1260
|
-
result = await inlineStyleUrls(result, fileDir, stylePreprocessors);
|
|
1261
|
-
result = await inlineSingleStyleUrl(result, fileDir, stylePreprocessors);
|
|
1262
|
-
return {
|
|
1263
|
-
deferSlots: inlinedTemplate.deferSlots,
|
|
1264
|
-
source: result
|
|
1265
|
-
};
|
|
1266
|
-
};
|
|
1267
|
-
var compileAngularFileJIT = async (inputPath, outDir, rootDir, stylePreprocessors) => {
|
|
1268
|
-
const entryPath = resolve(inputPath);
|
|
1269
|
-
const allOutputs = [];
|
|
1270
|
-
const visited = new Set;
|
|
1271
|
-
const baseDir = resolve(rootDir ?? process.cwd());
|
|
1272
|
-
let usesLegacyAnimations = false;
|
|
1273
|
-
const angularTranspiler = new Bun.Transpiler({
|
|
1274
|
-
loader: "ts",
|
|
1275
|
-
tsconfig: JSON.stringify({
|
|
1276
|
-
compilerOptions: {
|
|
1277
|
-
emitDecoratorMetadata: true,
|
|
1278
|
-
experimentalDecorators: true
|
|
1279
|
-
}
|
|
1280
|
-
})
|
|
1281
|
-
});
|
|
1282
|
-
const tsconfigAliases = readTsconfigPathAliases();
|
|
1283
|
-
const resolveSourceFile2 = (candidate) => {
|
|
1284
|
-
const candidates = candidate.match(/\.[cm]?[tj]sx?$/) ? [candidate] : [
|
|
1285
|
-
`${candidate}.ts`,
|
|
1286
|
-
`${candidate}.tsx`,
|
|
1287
|
-
`${candidate}.js`,
|
|
1288
|
-
`${candidate}.jsx`,
|
|
1289
|
-
join(candidate, "index.ts"),
|
|
1290
|
-
join(candidate, "index.tsx"),
|
|
1291
|
-
join(candidate, "index.js"),
|
|
1292
|
-
join(candidate, "index.jsx")
|
|
1293
|
-
];
|
|
1294
|
-
return candidates.find((file) => existsSync(file));
|
|
1295
|
-
};
|
|
1296
|
-
const resolveLocalImport = (specifier, fromDir) => {
|
|
1297
|
-
if (specifier.startsWith(".") || specifier.startsWith("/")) {
|
|
1298
|
-
return resolveSourceFile2(resolve(fromDir, specifier));
|
|
1299
|
-
}
|
|
1300
|
-
const aliased = matchTsconfigAlias(specifier, tsconfigAliases.aliases, tsconfigAliases.baseUrl, resolveSourceFile2);
|
|
1301
|
-
if (aliased)
|
|
1302
|
-
return aliased;
|
|
1303
|
-
try {
|
|
1304
|
-
const resolved = Bun.resolveSync(specifier, fromDir);
|
|
1305
|
-
if (resolved.includes("/node_modules/"))
|
|
1306
|
-
return;
|
|
1307
|
-
const absolute = resolve(resolved);
|
|
1308
|
-
if (!absolute.startsWith(baseDir))
|
|
1309
|
-
return;
|
|
1310
|
-
return resolveSourceFile2(absolute);
|
|
1311
|
-
} catch {
|
|
1312
|
-
return;
|
|
1313
|
-
}
|
|
1314
|
-
};
|
|
1315
|
-
const toOutputPath = (sourcePath) => {
|
|
1316
|
-
const inputDir = dirname(sourcePath);
|
|
1317
|
-
const relativeDir = inputDir.startsWith(baseDir) ? inputDir.substring(baseDir.length + 1) : inputDir;
|
|
1318
|
-
const fileBase = basename(sourcePath).replace(/\.[cm]?[tj]sx?$/, ".js");
|
|
1319
|
-
return join(outDir, relativeDir, fileBase);
|
|
1320
|
-
};
|
|
1321
|
-
const transpileAndRewrite = (sourceCode, relativeDir, actualPath, importRewrites) => {
|
|
1322
|
-
let processedContent = angularTranspiler.transformSync(sourceCode);
|
|
1323
|
-
const outputPath = toOutputPath(actualPath);
|
|
1324
|
-
const rewriteBareImport = (prefix, specifier, suffix) => {
|
|
1325
|
-
const rewritten = importRewrites.get(specifier);
|
|
1326
|
-
if (rewritten) {
|
|
1327
|
-
return `${prefix}${rewritten}${suffix}`;
|
|
1328
|
-
}
|
|
1329
|
-
if (specifier.startsWith(".") || specifier.startsWith("/")) {
|
|
1330
|
-
return `${prefix}${specifier}${suffix}`;
|
|
1331
|
-
}
|
|
1332
|
-
return `${prefix}${specifier}${suffix}`;
|
|
1333
|
-
};
|
|
1334
|
-
processedContent = processedContent.replace(/(from\s+['"])([^'"]+)(['"])/g, (_, prefix, specifier, suffix) => rewriteBareImport(prefix, specifier, suffix));
|
|
1335
|
-
processedContent = processedContent.replace(/(import\s+['"])([^'"]+)(['"])/g, (_, prefix, specifier, suffix) => rewriteBareImport(prefix, specifier, suffix));
|
|
1336
|
-
processedContent = processedContent.replace(/(import\(\s*['"])([^'"]+)(['"]\s*\))/g, (_, prefix, specifier, suffix) => rewriteBareImport(prefix, specifier, suffix));
|
|
1337
|
-
processedContent = processedContent.replace(/from\s+(['"])(\.\.?\/[^'"]+)(\1)/g, (match, quote, path) => {
|
|
1338
|
-
const rewritten = rewriteRelativeJsSpecifier(outputPath, path);
|
|
1339
|
-
if (rewritten !== path) {
|
|
1340
|
-
return `from ${quote}${rewritten}${quote}`;
|
|
1341
|
-
}
|
|
1342
|
-
return match;
|
|
1343
|
-
});
|
|
1344
|
-
const relDepth = relativeDir === "" || relativeDir === "." ? 0 : relativeDir.split("/").length;
|
|
1345
|
-
processedContent = processedContent.replace(/(from\s+['"])(\.\.\/(?:\.\.\/)*)/g, (_, prefix, dots) => {
|
|
1346
|
-
const upCount = dots.split("/").length - 1;
|
|
1347
|
-
if (upCount <= relDepth)
|
|
1348
|
-
return `${prefix}${dots}`;
|
|
1349
|
-
return `${prefix}../${dots}`;
|
|
1350
|
-
});
|
|
1351
|
-
if (resolve(actualPath) === entryPath) {
|
|
1352
|
-
processedContent += buildIslandMetadataExports(sourceCode);
|
|
1353
|
-
}
|
|
1354
|
-
return processedContent;
|
|
1355
|
-
};
|
|
1356
|
-
const transpileFile = async (filePath) => {
|
|
1357
|
-
const resolved = resolve(filePath);
|
|
1358
|
-
if (visited.has(resolved))
|
|
1359
|
-
return;
|
|
1360
|
-
visited.add(resolved);
|
|
1361
|
-
let actualPath = resolved;
|
|
1362
|
-
if (!actualPath.endsWith(".ts"))
|
|
1363
|
-
actualPath += ".ts";
|
|
1364
|
-
if (!existsSync(actualPath))
|
|
1365
|
-
return;
|
|
1366
|
-
let sourceCode = await fs.readFile(actualPath, "utf-8");
|
|
1367
|
-
const inlined = await inlineResources(sourceCode, dirname(actualPath), stylePreprocessors);
|
|
1368
|
-
sourceCode = inlineTemplateAndLowerDeferSync(inlined.source, dirname(actualPath)).source;
|
|
1369
|
-
const inputDir = dirname(actualPath);
|
|
1370
|
-
const relativeDir = inputDir.startsWith(baseDir) ? inputDir.substring(baseDir.length + 1) : inputDir;
|
|
1371
|
-
const fileBase = basename(actualPath).replace(/\.[cm]?[tj]sx?$/, ".js");
|
|
1372
|
-
const targetDir = join(outDir, relativeDir);
|
|
1373
|
-
const targetPath = toOutputPath(actualPath);
|
|
1374
|
-
const localImports = [];
|
|
1375
|
-
const importRewrites = new Map;
|
|
1376
|
-
const fromRegex = /(?:from|import)\s+['"]([^'".][^'"]*|\.\.?\/[^'"]+)['"]/g;
|
|
1377
|
-
const dynamicImportRegex = /import\(\s*['"]([^'".][^'"]*|\.\.?\/[^'"]+)['"]\s*\)/g;
|
|
1378
|
-
let importMatch;
|
|
1379
|
-
while ((importMatch = fromRegex.exec(sourceCode)) !== null) {
|
|
1380
|
-
if (importMatch[1])
|
|
1381
|
-
localImports.push(importMatch[1]);
|
|
1382
|
-
}
|
|
1383
|
-
while ((importMatch = dynamicImportRegex.exec(sourceCode)) !== null) {
|
|
1384
|
-
if (importMatch[1])
|
|
1385
|
-
localImports.push(importMatch[1]);
|
|
1386
|
-
}
|
|
1387
|
-
if (localImports.includes("@angular/animations")) {
|
|
1388
|
-
usesLegacyAnimations = true;
|
|
1389
|
-
}
|
|
1390
|
-
const localImportPaths = localImports.map((specifier) => {
|
|
1391
|
-
const resolved2 = resolveLocalImport(specifier, inputDir);
|
|
1392
|
-
if (!resolved2)
|
|
1393
|
-
return null;
|
|
1394
|
-
const relativeImport = relative(targetDir, toOutputPath(resolved2)).replace(/\\/g, "/").replace(/\.js$/, "");
|
|
1395
|
-
importRewrites.set(specifier, relativeImport.startsWith(".") ? relativeImport : `./${relativeImport}`);
|
|
1396
|
-
return resolved2;
|
|
1397
|
-
}).filter((path) => Boolean(path));
|
|
1398
|
-
const contentHash = Bun.hash(sourceCode).toString(BASE_36_RADIX);
|
|
1399
|
-
const cacheKey = actualPath;
|
|
1400
|
-
if (jitContentCache.get(cacheKey) === contentHash && existsSync(targetPath)) {
|
|
1401
|
-
allOutputs.push(targetPath);
|
|
1402
|
-
} else {
|
|
1403
|
-
const processedContent = transpileAndRewrite(sourceCode, relativeDir, actualPath, importRewrites);
|
|
1404
|
-
await fs.mkdir(targetDir, { recursive: true });
|
|
1405
|
-
await fs.writeFile(targetPath, processedContent, "utf-8");
|
|
1406
|
-
allOutputs.push(targetPath);
|
|
1407
|
-
jitContentCache.set(cacheKey, contentHash);
|
|
1408
|
-
}
|
|
1409
|
-
await Promise.all(localImportPaths.map((importPath) => transpileFile(importPath)));
|
|
1410
|
-
};
|
|
1411
|
-
await transpileFile(inputPath);
|
|
1412
|
-
const entryOutputPath = toOutputPath(entryPath);
|
|
1413
|
-
if (existsSync(entryOutputPath)) {
|
|
1414
|
-
const entryOutput = await fs.readFile(entryOutputPath, "utf-8");
|
|
1415
|
-
const withoutLegacyFlag = entryOutput.replace(/\nexport const __ABSOLUTE_PAGE_USES_LEGACY_ANIMATIONS__ = true;\n?/g, `
|
|
1416
|
-
`);
|
|
1417
|
-
const nextEntryOutput = usesLegacyAnimations ? `${withoutLegacyFlag}
|
|
1418
|
-
export const __ABSOLUTE_PAGE_USES_LEGACY_ANIMATIONS__ = true;
|
|
1419
|
-
` : withoutLegacyFlag;
|
|
1420
|
-
if (nextEntryOutput !== entryOutput) {
|
|
1421
|
-
await fs.writeFile(entryOutputPath, nextEntryOutput, "utf-8");
|
|
1422
|
-
}
|
|
1423
|
-
}
|
|
1424
|
-
return allOutputs;
|
|
1425
|
-
};
|
|
1426
|
-
var compileAngular = async (entryPoints, outRoot, hmr = false, stylePreprocessors) => {
|
|
1427
|
-
const compiledParent = join(outRoot, "generated");
|
|
1428
|
-
if (entryPoints.length === 0) {
|
|
1429
|
-
const emptyPaths = [];
|
|
1430
|
-
return { clientPaths: [...emptyPaths], serverPaths: [...emptyPaths] };
|
|
1431
|
-
}
|
|
1432
|
-
const compiledRoot = compiledParent;
|
|
1433
|
-
const indexesDir = join(compiledParent, "indexes");
|
|
1434
|
-
await traceAngularPhase("setup/create-indexes-dir", () => fs.mkdir(indexesDir, { recursive: true }));
|
|
1435
|
-
const aotOutputs = hmr ? [] : await traceAngularPhase("aot/compile-files", () => compileAngularFiles(entryPoints.map((entry) => resolve(entry)), compiledRoot, stylePreprocessors), { entries: entryPoints.length });
|
|
1436
|
-
const usesLegacyAngularAnimations = await traceAngularPhase("setup/legacy-animation-resolver", () => createLegacyAngularAnimationUsageResolver(outRoot));
|
|
1437
|
-
const compileTasks = entryPoints.map(async (entry) => {
|
|
1438
|
-
const resolvedEntry = resolve(entry);
|
|
1439
|
-
const relativeEntry = relative(outRoot, resolvedEntry).replace(/\.[tj]s$/, ".js");
|
|
1440
|
-
const compileEntry = () => compileAngularFileJIT(resolvedEntry, compiledRoot, outRoot, stylePreprocessors);
|
|
1441
|
-
let outputs = hmr ? await traceAngularPhase("jit/compile-entry", compileEntry, {
|
|
1442
|
-
entry: resolvedEntry
|
|
1443
|
-
}) : aotOutputs;
|
|
1444
|
-
const fileBase = basename(resolvedEntry).replace(/\.[tj]s$/, "");
|
|
1445
|
-
const jsName = `${fileBase}.js`;
|
|
1446
|
-
const compiledFallbackPaths = [
|
|
1447
|
-
join(compiledRoot, relativeEntry),
|
|
1448
|
-
join(compiledRoot, "pages", jsName),
|
|
1449
|
-
join(compiledRoot, jsName)
|
|
1450
|
-
].map((file) => resolve(file));
|
|
1451
|
-
const resolveRawServerFile = (candidatePaths) => {
|
|
1452
|
-
const normalizedCandidates = [
|
|
1453
|
-
...candidatePaths.map((file) => resolve(file)),
|
|
1454
|
-
...compiledFallbackPaths
|
|
1455
|
-
];
|
|
1456
|
-
let candidate = normalizedCandidates.find((file) => existsSync(file) && file.endsWith(`${sep}pages${sep}${jsName}`));
|
|
1457
|
-
if (!candidate) {
|
|
1458
|
-
candidate = normalizedCandidates.find((file) => existsSync(file) && file.endsWith(`${sep}${jsName}`));
|
|
1459
|
-
}
|
|
1460
|
-
if (!candidate) {
|
|
1461
|
-
candidate = normalizedCandidates.find((file) => existsSync(file));
|
|
1462
|
-
}
|
|
1463
|
-
return candidate;
|
|
1464
|
-
};
|
|
1465
|
-
let rawServerFile = await traceAngularPhase("wrapper/resolve-server-output", () => resolveRawServerFile(outputs), { entry: resolvedEntry });
|
|
1466
|
-
if (!rawServerFile) {
|
|
1467
|
-
rawServerFile = await traceAngularPhase("wrapper/resolve-server-output-fallback", () => resolveRawServerFile([]), { entry: resolvedEntry });
|
|
1468
|
-
}
|
|
1469
|
-
if (rawServerFile && !existsSync(rawServerFile)) {
|
|
1470
|
-
outputs = hmr ? await compileEntry() : aotOutputs;
|
|
1471
|
-
rawServerFile = await traceAngularPhase("wrapper/resolve-server-output-retry", () => resolveRawServerFile(outputs), { entry: resolvedEntry });
|
|
1472
|
-
}
|
|
1473
|
-
if (!rawServerFile || !existsSync(rawServerFile)) {
|
|
1474
|
-
throw new Error(`Compiled output not found for ${entry}. Looking for: ${jsName}. Available: ${[
|
|
1475
|
-
...outputs,
|
|
1476
|
-
...compiledFallbackPaths
|
|
1477
|
-
].join(", ")}`);
|
|
1478
|
-
}
|
|
1479
|
-
const original = await traceAngularPhase("wrapper/read-server-output", () => fs.readFile(rawServerFile, "utf-8"), { entry: resolvedEntry });
|
|
1480
|
-
const detectExportedComponentClass = (source, fallback) => {
|
|
1481
|
-
const defaultMatch = source.match(/export\s+default\s+([A-Za-z_$][\w$]*)\s*;/);
|
|
1482
|
-
if (defaultMatch)
|
|
1483
|
-
return defaultMatch[1];
|
|
1484
|
-
const exportClassMatch = source.match(/export\s+(?:default\s+)?class\s+([A-Za-z_$][\w$]*)/);
|
|
1485
|
-
if (exportClassMatch)
|
|
1486
|
-
return exportClassMatch[1];
|
|
1487
|
-
return fallback;
|
|
1488
|
-
};
|
|
1489
|
-
const componentClassName = await traceAngularPhase("wrapper/detect-component-class", () => detectExportedComponentClass(original, `${toPascal(fileBase)}Component`), { entry: resolvedEntry });
|
|
1490
|
-
const usesLegacyAnimations = await traceAngularPhase("wrapper/detect-legacy-animations", () => usesLegacyAngularAnimations(resolvedEntry), { entry: resolvedEntry });
|
|
1491
|
-
const serverContentHash = Bun.hash(original).toString(BASE_36_RADIX);
|
|
1492
|
-
const cachedWrapper = wrapperOutputCache.get(resolvedEntry);
|
|
1493
|
-
const clientFile = join(indexesDir, jsName);
|
|
1494
|
-
if (hmr && cachedWrapper && cachedWrapper.serverHash === serverContentHash && existsSync(clientFile) && (usesLegacyAnimations || !original.includes("__ABSOLUTE_PAGE_USES_LEGACY_ANIMATIONS__")) && (!usesLegacyAnimations || original.includes("__ABSOLUTE_PAGE_USES_LEGACY_ANIMATIONS__"))) {
|
|
1495
|
-
return {
|
|
1496
|
-
clientPath: clientFile,
|
|
1497
|
-
indexUnchanged: true,
|
|
1498
|
-
serverPath: rawServerFile
|
|
1499
|
-
};
|
|
1500
|
-
}
|
|
1501
|
-
let rewritten = original;
|
|
1502
|
-
rewritten = rewritten.replace(/\nexport const __ABSOLUTE_PAGE_USES_LEGACY_ANIMATIONS__ = true;\n?/g, `
|
|
1503
|
-
`);
|
|
1504
|
-
if (!rewritten.includes(`import '@angular/compiler';`)) {
|
|
1505
|
-
rewritten = `import '@angular/compiler';
|
|
1506
|
-
${rewritten}`;
|
|
1507
|
-
}
|
|
1508
|
-
rewritten = rewritten.replace(new RegExp(`templateUrl:\\s*['"]\\.\\/${fileBase}\\.html['"]`), `templateUrl: '../../pages/${fileBase}.html'`);
|
|
1509
|
-
if (!rewritten.includes("export default")) {
|
|
1510
|
-
rewritten += `
|
|
1511
|
-
export default ${componentClassName};
|
|
1512
|
-
`;
|
|
1513
|
-
}
|
|
1514
|
-
if (usesLegacyAnimations) {
|
|
1515
|
-
rewritten += `
|
|
1516
|
-
export const __ABSOLUTE_PAGE_USES_LEGACY_ANIMATIONS__ = true;
|
|
1517
|
-
`;
|
|
1518
|
-
}
|
|
1519
|
-
if (hmr) {
|
|
1520
|
-
rewritten = injectHMRRegistration(rewritten, resolvedEntry);
|
|
1521
|
-
}
|
|
1522
|
-
await traceAngularPhase("wrapper/write-server-output", () => fs.writeFile(rawServerFile, rewritten, "utf-8"), { entry: resolvedEntry });
|
|
1523
|
-
const relativePath = relative(indexesDir, rawServerFile).replace(/\\/g, "/");
|
|
1524
|
-
const normalizedImportPath = relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
|
|
1525
|
-
const hmrPreamble = hmr ? `window.__HMR_FRAMEWORK__ = "angular";
|
|
1526
|
-
import "${hmrRuntimePath}";
|
|
1527
|
-
import "${hmrClientPath}";
|
|
1528
|
-
` : "";
|
|
1529
|
-
const hydration = hmr ? `${hmrPreamble}
|
|
1530
|
-
import '@angular/compiler';
|
|
1531
|
-
import { bootstrapApplication } from '@angular/platform-browser';
|
|
1532
|
-
import { provideClientHydration } from '@angular/platform-browser';
|
|
1533
|
-
import { withHttpTransferCacheOptions } from '@angular/platform-browser';
|
|
1534
|
-
import { provideZonelessChangeDetection } from '@angular/core';
|
|
1535
|
-
import * as pageModule from '${normalizedImportPath}';
|
|
1536
|
-
|
|
1537
|
-
var ${componentClassName} = pageModule.default;
|
|
1538
|
-
var toScreamingSnake = function(str) {
|
|
1539
|
-
return str.replace(/([a-z0-9])([A-Z])/g, '$1_$2').toUpperCase();
|
|
1540
|
-
};
|
|
1541
|
-
var isInjectionToken = function(value) {
|
|
1542
|
-
return Boolean(value) && typeof value === 'object' && value.ngMetadataName === 'InjectionToken';
|
|
1543
|
-
};
|
|
1544
|
-
var pageProps = window.__ABS_ANGULAR_PAGE_PROPS__ || {};
|
|
1545
|
-
var pageHasIslands = Boolean(pageModule.__ABSOLUTE_PAGE_HAS_ISLANDS__) || Boolean(document.querySelector('[data-island="true"]'));
|
|
1546
|
-
var pageHasRawStreamingSlots = Boolean(document.querySelector('[data-absolute-raw-slot="true"]'));
|
|
1547
|
-
var pageHasStreamingSlots = Boolean(document.querySelector('[data-absolute-slot="true"]'));
|
|
1548
|
-
var propProviders = Object.entries(pageProps).map(function(entry) {
|
|
1549
|
-
var propName = entry[0];
|
|
1550
|
-
var propValue = entry[1];
|
|
1551
|
-
var token = pageModule[toScreamingSnake(propName)];
|
|
1552
|
-
return isInjectionToken(token) ? { provide: token, useValue: propValue } : null;
|
|
1553
|
-
}).filter(Boolean);
|
|
1554
|
-
// Page-level providers, opt-in via \`export const providers = [...]\` in the
|
|
1555
|
-
// page module. Required so DI tokens that the component (or any service it
|
|
1556
|
-
// injects) needs are available client-side too \u2014 without these, services
|
|
1557
|
-
// that worked in SSR fail with NG0201 after hydration.
|
|
1558
|
-
var maybePageProviders = Reflect.get(pageModule, 'providers');
|
|
1559
|
-
var pageProviders = Array.isArray(maybePageProviders) ? maybePageProviders : [];
|
|
1560
|
-
var absoluteHttpTransferCacheOptions = {
|
|
1561
|
-
includePostRequests: false,
|
|
1562
|
-
includeRequestsWithAuthHeaders: false,
|
|
1563
|
-
filter: function(request) {
|
|
1564
|
-
return !request.headers.has('x-skip-transfer-cache');
|
|
1565
|
-
}
|
|
1566
|
-
};
|
|
1567
|
-
|
|
1568
|
-
// Re-export the page module so HMR fast-patch (in handlers/angular.ts) can
|
|
1569
|
-
// dynamically import this chunk and discover the freshly-built component
|
|
1570
|
-
// classes without needing a separate build artifact.
|
|
1571
|
-
export * from '${normalizedImportPath}';
|
|
1572
|
-
|
|
1573
|
-
// Record this evaluation's \`routes\` and \`providers\` exports for the
|
|
1574
|
-
// HMR fast-patch to compare against on the next reload. If they change
|
|
1575
|
-
// (a new route was added, a provider was edited), fast-patch falls back
|
|
1576
|
-
// to a full re-bootstrap because those values are consumed once at
|
|
1577
|
-
// bootstrap and won't propagate to the running router/injector via an
|
|
1578
|
-
// in-place component patch.
|
|
1579
|
-
if (typeof window !== 'undefined' && window.__ANGULAR_HMR__ && typeof window.__ANGULAR_HMR__.recordPageExports === 'function') {
|
|
1580
|
-
var __abs_hmr_routes = Reflect.get(pageModule, 'routes');
|
|
1581
|
-
window.__ANGULAR_HMR__.recordPageExports('${resolvedEntry}', __abs_hmr_routes, maybePageProviders);
|
|
1582
|
-
}
|
|
1583
|
-
|
|
1584
|
-
// Re-Bootstrap HMR with View Transitions API.
|
|
1585
|
-
// Skipped during fast-patch: the HMR client sets
|
|
1586
|
-
// window.__ANGULAR_HMR_FAST_PATCH__ = true before \`import()\`-ing this
|
|
1587
|
-
// chunk so it can read the new component classes via \`export *\` above
|
|
1588
|
-
// without destroying the running app.
|
|
1589
|
-
if (!window.__ANGULAR_HMR_FAST_PATCH__) {
|
|
1590
|
-
if (window.__ANGULAR_APP__) {
|
|
1591
|
-
try { window.__ANGULAR_APP__.destroy(); } catch (_err) { /* ignore */ }
|
|
1592
|
-
window.__ANGULAR_APP__ = null;
|
|
1593
|
-
}
|
|
1594
|
-
|
|
1595
|
-
// Ensure root element exists after destroy (Angular removes it)
|
|
1596
|
-
var _sel = ${componentClassName}.\u0275cmp?.selectors?.[0]?.[0] || 'ng-app';
|
|
1597
|
-
if (!document.querySelector(_sel)) {
|
|
1598
|
-
(document.getElementById('root') || document.body).appendChild(document.createElement(_sel));
|
|
1599
|
-
}
|
|
1600
|
-
|
|
1601
|
-
var providers = [provideZonelessChangeDetection()];
|
|
1602
|
-
if (!window.__HMR_SKIP_HYDRATION__ && !pageHasIslands) {
|
|
1603
|
-
providers.push(provideClientHydration(withHttpTransferCacheOptions(absoluteHttpTransferCacheOptions)));
|
|
1604
|
-
}
|
|
1605
|
-
delete window.__HMR_SKIP_HYDRATION__;
|
|
1606
|
-
providers.push.apply(providers, pageProviders);
|
|
1607
|
-
providers.push.apply(providers, propProviders);
|
|
1608
|
-
window.__ABS_SLOT_HYDRATION_PENDING__ = pageHasRawStreamingSlots;
|
|
1609
|
-
|
|
1610
|
-
if (pageHasRawStreamingSlots) {
|
|
1611
|
-
window.__ABS_SLOT_HYDRATION_PENDING__ = false;
|
|
1612
|
-
if (typeof window.__ABS_SLOT_FLUSH__ === 'function') {
|
|
1613
|
-
requestAnimationFrame(function() {
|
|
1614
|
-
window.__ABS_SLOT_FLUSH__();
|
|
1615
|
-
});
|
|
1616
|
-
}
|
|
1617
|
-
} else {
|
|
1618
|
-
bootstrapApplication(${componentClassName}, {
|
|
1619
|
-
providers: providers
|
|
1620
|
-
}).then(function (appRef) {
|
|
1621
|
-
window.__ANGULAR_APP__ = appRef;
|
|
1622
|
-
window.__ABS_SLOT_HYDRATION_PENDING__ = false;
|
|
1623
|
-
if (typeof window.__ABS_SLOT_FLUSH__ === 'function') {
|
|
1624
|
-
requestAnimationFrame(function() {
|
|
1625
|
-
window.__ABS_SLOT_FLUSH__();
|
|
1626
|
-
});
|
|
1627
|
-
}
|
|
1628
|
-
});
|
|
1629
|
-
}
|
|
1630
|
-
}
|
|
1631
|
-
`.trim() : `
|
|
1632
|
-
import '@angular/compiler';
|
|
1633
|
-
import { bootstrapApplication } from '@angular/platform-browser';
|
|
1634
|
-
import { provideClientHydration } from '@angular/platform-browser';
|
|
1635
|
-
import { withHttpTransferCacheOptions } from '@angular/platform-browser';
|
|
1636
|
-
import { enableProdMode, provideZonelessChangeDetection } from '@angular/core';
|
|
1637
|
-
import * as pageModule from '${normalizedImportPath}';
|
|
1638
|
-
|
|
1639
|
-
var ${componentClassName} = pageModule.default;
|
|
1640
|
-
var toScreamingSnake = function(str) {
|
|
1641
|
-
return str.replace(/([a-z0-9])([A-Z])/g, '$1_$2').toUpperCase();
|
|
1642
|
-
};
|
|
1643
|
-
var isInjectionToken = function(value) {
|
|
1644
|
-
return Boolean(value) && typeof value === 'object' && value.ngMetadataName === 'InjectionToken';
|
|
1645
|
-
};
|
|
1646
|
-
var pageProps = window.__ABS_ANGULAR_PAGE_PROPS__ || {};
|
|
1647
|
-
var pageHasIslands = Boolean(pageModule.__ABSOLUTE_PAGE_HAS_ISLANDS__) || Boolean(document.querySelector('[data-island="true"]'));
|
|
1648
|
-
var pageHasRawStreamingSlots = Boolean(document.querySelector('[data-absolute-raw-slot="true"]'));
|
|
1649
|
-
var pageHasStreamingSlots = Boolean(document.querySelector('[data-absolute-slot="true"]'));
|
|
1650
|
-
var propProviders = Object.entries(pageProps).map(function(entry) {
|
|
1651
|
-
var propName = entry[0];
|
|
1652
|
-
var propValue = entry[1];
|
|
1653
|
-
var token = pageModule[toScreamingSnake(propName)];
|
|
1654
|
-
return isInjectionToken(token) ? { provide: token, useValue: propValue } : null;
|
|
1655
|
-
}).filter(Boolean);
|
|
1656
|
-
// Page-level providers, opt-in via \`export const providers = [...]\` in the
|
|
1657
|
-
// page module. Required so DI tokens that the component (or any service it
|
|
1658
|
-
// injects) needs are available client-side too \u2014 without these, services
|
|
1659
|
-
// that worked in SSR fail with NG0201 after hydration.
|
|
1660
|
-
var maybePageProviders = Reflect.get(pageModule, 'providers');
|
|
1661
|
-
var pageProviders = Array.isArray(maybePageProviders) ? maybePageProviders : [];
|
|
1662
|
-
var absoluteHttpTransferCacheOptions = {
|
|
1663
|
-
includePostRequests: false,
|
|
1664
|
-
includeRequestsWithAuthHeaders: false,
|
|
1665
|
-
filter: function(request) {
|
|
1666
|
-
return !request.headers.has('x-skip-transfer-cache');
|
|
1667
|
-
}
|
|
1668
|
-
};
|
|
1669
|
-
|
|
1670
|
-
enableProdMode();
|
|
1671
|
-
|
|
1672
|
-
var providers = [provideZonelessChangeDetection()].concat(pageProviders).concat(propProviders);
|
|
1673
|
-
if (!pageHasIslands) {
|
|
1674
|
-
providers.unshift(provideClientHydration(withHttpTransferCacheOptions(absoluteHttpTransferCacheOptions)));
|
|
1675
|
-
}
|
|
1676
|
-
window.__ABS_SLOT_HYDRATION_PENDING__ = pageHasRawStreamingSlots;
|
|
1677
|
-
|
|
1678
|
-
if (pageHasRawStreamingSlots) {
|
|
1679
|
-
window.__ABS_SLOT_HYDRATION_PENDING__ = false;
|
|
1680
|
-
if (typeof window.__ABS_SLOT_FLUSH__ === 'function') {
|
|
1681
|
-
requestAnimationFrame(function() {
|
|
1682
|
-
window.__ABS_SLOT_FLUSH__();
|
|
1683
|
-
});
|
|
1684
|
-
}
|
|
1685
|
-
} else {
|
|
1686
|
-
bootstrapApplication(${componentClassName}, {
|
|
1687
|
-
providers: providers
|
|
1688
|
-
}).then(function (appRef) {
|
|
1689
|
-
window.__ANGULAR_APP__ = appRef;
|
|
1690
|
-
window.__ABS_SLOT_HYDRATION_PENDING__ = false;
|
|
1691
|
-
if (typeof window.__ABS_SLOT_FLUSH__ === 'function') {
|
|
1692
|
-
requestAnimationFrame(function() {
|
|
1693
|
-
window.__ABS_SLOT_FLUSH__();
|
|
1694
|
-
});
|
|
1695
|
-
}
|
|
1696
|
-
});
|
|
1697
|
-
}
|
|
1698
|
-
`.trim();
|
|
1699
|
-
const indexHash = Bun.hash(hydration).toString(BASE_36_RADIX);
|
|
1700
|
-
const indexUnchanged = cachedWrapper?.indexHash === indexHash;
|
|
1701
|
-
await traceAngularPhase("wrapper/write-client-index", () => fs.writeFile(clientFile, hydration, "utf-8"), { entry: resolvedEntry });
|
|
1702
|
-
wrapperOutputCache.set(resolvedEntry, {
|
|
1703
|
-
indexHash,
|
|
1704
|
-
serverHash: serverContentHash
|
|
1705
|
-
});
|
|
1706
|
-
return {
|
|
1707
|
-
clientPath: clientFile,
|
|
1708
|
-
indexUnchanged,
|
|
1709
|
-
serverPath: rawServerFile
|
|
1710
|
-
};
|
|
1711
|
-
});
|
|
1712
|
-
const results = await traceAngularPhase("wrapper/process-entries", () => Promise.all(compileTasks), { entries: entryPoints.length });
|
|
1713
|
-
const { clientPaths, serverPaths } = await traceAngularPhase("wrapper/collect-paths", () => ({
|
|
1714
|
-
clientPaths: results.map((r) => r.clientPath),
|
|
1715
|
-
serverPaths: results.map((r) => r.serverPath)
|
|
1716
|
-
}), { entries: results.length });
|
|
1717
|
-
return {
|
|
1718
|
-
allIndexesUnchanged: hmr && results.every((r) => r.indexUnchanged),
|
|
1719
|
-
clientPaths,
|
|
1720
|
-
serverPaths
|
|
1721
|
-
};
|
|
1722
|
-
};
|
|
1723
|
-
export {
|
|
1724
|
-
compileAngularFiles,
|
|
1725
|
-
compileAngularFileJIT,
|
|
1726
|
-
compileAngularFile,
|
|
1727
|
-
compileAngular
|
|
1728
|
-
};
|
|
1729
|
-
|
|
1730
|
-
//# debugId=F70C8C2EEC6A3A1764756E2164756E21
|
|
1731
|
-
//# sourceMappingURL=chunk-92fsjfpp.js.map
|