@absolutejs/absolute 0.19.0-beta.808 → 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 +1100 -40
- 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/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-0kdc6r16.js +0 -20
- package/dist/chunk-0kdc6r16.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-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-38jwhqcw.js +0 -4410
- package/dist/chunk-38jwhqcw.js.map +0 -28
- package/dist/chunk-3g91wb4f.js +0 -358
- package/dist/chunk-3g91wb4f.js.map +0 -10
- 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-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-8qqxc1h2.js +0 -426
- package/dist/chunk-8qqxc1h2.js.map +0 -14
- 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-94gvx0hg.js +0 -28
- package/dist/chunk-94gvx0hg.js.map +0 -10
- package/dist/chunk-9c5tj4k3.js +0 -130
- package/dist/chunk-9c5tj4k3.js.map +0 -10
- 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-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-cwfy538a.js +0 -51
- package/dist/chunk-cwfy538a.js.map +0 -9
- package/dist/chunk-d7mwkzry.js +0 -261
- package/dist/chunk-d7mwkzry.js.map +0 -10
- package/dist/chunk-d8w0qm28.js +0 -184
- package/dist/chunk-d8w0qm28.js.map +0 -11
- 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-ff70rnhd.js +0 -672
- package/dist/chunk-ff70rnhd.js.map +0 -15
- 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-j88z31ep.js +0 -25
- package/dist/chunk-j88z31ep.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-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-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-wwzvp0zn.js +0 -192
- package/dist/chunk-wwzvp0zn.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/islands/index.js
CHANGED
|
@@ -1,26 +1,1917 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
function __accessProp(key) {
|
|
8
|
+
return this[key];
|
|
9
|
+
}
|
|
10
|
+
var __toESMCache_node;
|
|
11
|
+
var __toESMCache_esm;
|
|
12
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
13
|
+
var canCache = mod != null && typeof mod === "object";
|
|
14
|
+
if (canCache) {
|
|
15
|
+
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
16
|
+
var cached = cache.get(mod);
|
|
17
|
+
if (cached)
|
|
18
|
+
return cached;
|
|
19
|
+
}
|
|
20
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
21
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
22
|
+
for (let key of __getOwnPropNames(mod))
|
|
23
|
+
if (!__hasOwnProp.call(to, key))
|
|
24
|
+
__defProp(to, key, {
|
|
25
|
+
get: __accessProp.bind(mod, key),
|
|
26
|
+
enumerable: true
|
|
27
|
+
});
|
|
28
|
+
if (canCache)
|
|
29
|
+
cache.set(mod, to);
|
|
30
|
+
return to;
|
|
31
|
+
};
|
|
32
|
+
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
33
|
+
var __returnValue = (v) => v;
|
|
34
|
+
function __exportSetter(name, newValue) {
|
|
35
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
36
|
+
}
|
|
37
|
+
var __export = (target, all) => {
|
|
38
|
+
for (var name in all)
|
|
39
|
+
__defProp(target, name, {
|
|
40
|
+
get: all[name],
|
|
41
|
+
enumerable: true,
|
|
42
|
+
configurable: true,
|
|
43
|
+
set: __exportSetter.bind(all, name)
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
var __legacyDecorateClassTS = function(decorators, target, key, desc) {
|
|
47
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
48
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
49
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
50
|
+
else
|
|
51
|
+
for (var i = decorators.length - 1;i >= 0; i--)
|
|
52
|
+
if (d = decorators[i])
|
|
53
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
54
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
55
|
+
};
|
|
56
|
+
var __legacyMetadataTS = (k, v) => {
|
|
57
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
58
|
+
return Reflect.metadata(k, v);
|
|
59
|
+
};
|
|
60
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
61
|
+
var __require = import.meta.require;
|
|
62
|
+
|
|
63
|
+
// src/core/islandManifest.ts
|
|
64
|
+
var toIslandFrameworkSegment = (framework) => framework[0]?.toUpperCase() + framework.slice(1), collectFrameworkIslands = (manifest, prefix) => {
|
|
65
|
+
const entries = {};
|
|
66
|
+
let found = false;
|
|
67
|
+
for (const [key, value] of Object.entries(manifest)) {
|
|
68
|
+
if (!key.startsWith(prefix))
|
|
69
|
+
continue;
|
|
70
|
+
const component = key.slice(prefix.length);
|
|
71
|
+
if (!component)
|
|
72
|
+
continue;
|
|
73
|
+
entries[component] = value;
|
|
74
|
+
found = true;
|
|
75
|
+
}
|
|
76
|
+
return found ? entries : undefined;
|
|
77
|
+
}, getIslandManifestEntries = (manifest) => {
|
|
78
|
+
const islands = {};
|
|
79
|
+
const frameworks = ["react", "svelte", "vue", "angular"];
|
|
80
|
+
for (const framework of frameworks) {
|
|
81
|
+
const prefix = `Island${toIslandFrameworkSegment(framework)}`;
|
|
82
|
+
const entries = collectFrameworkIslands(manifest, prefix);
|
|
83
|
+
if (entries)
|
|
84
|
+
islands[framework] = entries;
|
|
85
|
+
}
|
|
86
|
+
return islands;
|
|
87
|
+
}, getIslandManifestKey = (framework, component) => `Island${toIslandFrameworkSegment(framework)}${component}`;
|
|
88
|
+
|
|
89
|
+
// src/core/islands.ts
|
|
90
|
+
function getIslandComponent(component) {
|
|
91
|
+
if (isIslandComponentDefinition(component)) {
|
|
92
|
+
return component.component;
|
|
93
|
+
}
|
|
94
|
+
return component;
|
|
95
|
+
}
|
|
96
|
+
var defineIslandComponent = (component, options) => ({
|
|
97
|
+
component,
|
|
98
|
+
export: options.export,
|
|
99
|
+
source: options.source
|
|
100
|
+
}), defineIslandRegistry = (registry) => registry, isRecord = (value) => typeof value === "object" && value !== null, getIslandBuildReference = (component) => {
|
|
101
|
+
if (!isIslandComponentDefinition(component))
|
|
102
|
+
return null;
|
|
103
|
+
return {
|
|
104
|
+
export: component.export,
|
|
105
|
+
source: component.source
|
|
106
|
+
};
|
|
107
|
+
}, isIslandComponentDefinition = (value) => isRecord(value) && ("component" in value) && ("source" in value) && typeof value.source === "string", parseIslandProps = (rawProps) => {
|
|
108
|
+
if (!rawProps)
|
|
109
|
+
return {};
|
|
110
|
+
return JSON.parse(rawProps);
|
|
111
|
+
}, serializeIslandProps = (props) => JSON.stringify(props ?? {});
|
|
112
|
+
var init_islands = () => {};
|
|
113
|
+
|
|
114
|
+
// src/angular/resolveAngularPackage.ts
|
|
115
|
+
import { existsSync, readFileSync } from "fs";
|
|
116
|
+
import { join, resolve } from "path";
|
|
117
|
+
var resolveAngularPackageDir = (specifier) => {
|
|
118
|
+
const fromCompiledRuntime = process.env.ABSOLUTE_BUILD_DIR ? resolve(process.env.ABSOLUTE_BUILD_DIR, "node_modules", specifier) : null;
|
|
119
|
+
if (fromCompiledRuntime && existsSync(fromCompiledRuntime)) {
|
|
120
|
+
return fromCompiledRuntime;
|
|
121
|
+
}
|
|
122
|
+
const fromProject = resolve(process.cwd(), "node_modules", specifier);
|
|
123
|
+
if (existsSync(fromProject)) {
|
|
124
|
+
return fromProject;
|
|
125
|
+
}
|
|
126
|
+
return null;
|
|
127
|
+
}, resolvePackageEntry = (packageDir) => {
|
|
128
|
+
try {
|
|
129
|
+
const pkg = JSON.parse(readFileSync(join(packageDir, "package.json"), "utf-8"));
|
|
130
|
+
const rootExport = pkg.exports?.["."];
|
|
131
|
+
const entry = (typeof rootExport === "string" ? rootExport : rootExport?.default) ?? pkg.module ?? pkg.main ?? "index.js";
|
|
132
|
+
return join(packageDir, entry);
|
|
133
|
+
} catch {
|
|
134
|
+
return packageDir;
|
|
135
|
+
}
|
|
136
|
+
}, resolveAngularPackage = (specifier) => {
|
|
137
|
+
const packageDir = resolveAngularPackageDir(specifier);
|
|
138
|
+
if (packageDir)
|
|
139
|
+
return resolvePackageEntry(packageDir);
|
|
140
|
+
return specifier;
|
|
141
|
+
}, toSafeVendorName = (specifier) => specifier.replace(/^@/, "").replace(/\//g, "_"), resolveAngularRuntimePath = (specifier) => {
|
|
142
|
+
const buildDir = process.env.ABSOLUTE_BUILD_DIR;
|
|
143
|
+
if (buildDir) {
|
|
144
|
+
const vendorPath = join(buildDir, "angular", "vendor", "server", `${toSafeVendorName(specifier)}.js`);
|
|
145
|
+
if (existsSync(vendorPath))
|
|
146
|
+
return vendorPath;
|
|
147
|
+
}
|
|
148
|
+
return resolveAngularPackage(specifier);
|
|
149
|
+
};
|
|
150
|
+
var init_resolveAngularPackage = () => {};
|
|
151
|
+
|
|
152
|
+
// src/angular/angularPatch.ts
|
|
153
|
+
var exports_angularPatch = {};
|
|
154
|
+
__export(exports_angularPatch, {
|
|
155
|
+
applyPatches: () => applyPatches
|
|
156
|
+
});
|
|
157
|
+
var ensureHead = (doc) => {
|
|
158
|
+
if (!doc || doc.head || !doc.documentElement) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const head = doc.createElement("head");
|
|
162
|
+
doc.documentElement.insertBefore(head, doc.documentElement.firstChild);
|
|
163
|
+
}, SSR_LAYOUT_RECT, layoutPatchApplied = false, collectPrototypeChain = (instance) => {
|
|
164
|
+
const protos = [];
|
|
165
|
+
let current = instance ? Object.getPrototypeOf(instance) : null;
|
|
166
|
+
while (current && current !== Object.prototype) {
|
|
167
|
+
protos.push(current);
|
|
168
|
+
current = Object.getPrototypeOf(current);
|
|
169
|
+
}
|
|
170
|
+
return protos;
|
|
171
|
+
}, patchElementLayout = (doc) => {
|
|
172
|
+
if (layoutPatchApplied || !doc) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
let element;
|
|
176
|
+
try {
|
|
177
|
+
element = doc.createElement("div");
|
|
178
|
+
} catch {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
const protos = collectPrototypeChain(element);
|
|
182
|
+
if (protos.length === 0)
|
|
183
|
+
return;
|
|
184
|
+
const copyLayoutRect = (rect) => ({ ...rect });
|
|
185
|
+
const createLayoutRect = () => copyLayoutRect(SSR_LAYOUT_RECT);
|
|
186
|
+
const getClientRects = () => [];
|
|
187
|
+
const noop = () => {
|
|
188
|
+
return;
|
|
189
|
+
};
|
|
190
|
+
const numericProps = [
|
|
191
|
+
"clientWidth",
|
|
192
|
+
"clientHeight",
|
|
193
|
+
"clientLeft",
|
|
194
|
+
"clientTop",
|
|
195
|
+
"offsetWidth",
|
|
196
|
+
"offsetHeight",
|
|
197
|
+
"offsetLeft",
|
|
198
|
+
"offsetTop",
|
|
199
|
+
"scrollWidth",
|
|
200
|
+
"scrollHeight",
|
|
201
|
+
"scrollLeft",
|
|
202
|
+
"scrollTop"
|
|
203
|
+
];
|
|
204
|
+
for (const proto of protos) {
|
|
205
|
+
const define = (name, value) => {
|
|
206
|
+
const descriptor = Object.getOwnPropertyDescriptor(proto, name);
|
|
207
|
+
if (typeof descriptor?.value === "function")
|
|
208
|
+
return;
|
|
209
|
+
Object.defineProperty(proto, name, {
|
|
210
|
+
configurable: true,
|
|
211
|
+
value,
|
|
212
|
+
writable: true
|
|
213
|
+
});
|
|
214
|
+
};
|
|
215
|
+
define("getBoundingClientRect", createLayoutRect);
|
|
216
|
+
define("getClientRects", getClientRects);
|
|
217
|
+
define("scrollTo", noop);
|
|
218
|
+
define("scrollBy", noop);
|
|
219
|
+
define("scrollIntoView", noop);
|
|
220
|
+
define("focus", noop);
|
|
221
|
+
define("blur", noop);
|
|
222
|
+
for (const prop of numericProps) {
|
|
223
|
+
const desc = Object.getOwnPropertyDescriptor(proto, prop);
|
|
224
|
+
if (desc)
|
|
225
|
+
continue;
|
|
226
|
+
Object.defineProperty(proto, prop, {
|
|
227
|
+
configurable: true,
|
|
228
|
+
get: () => 0
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
layoutPatchApplied = true;
|
|
233
|
+
}, applyPatches = async () => {
|
|
234
|
+
const { \u{275}DominoAdapter } = await import(resolveAngularRuntimePath("@angular/platform-server"));
|
|
235
|
+
if (!\u{275}DominoAdapter?.prototype) {
|
|
236
|
+
console.warn("[Angular Patch] \u0275DominoAdapter not found, skipping patches");
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
try {
|
|
240
|
+
const adapter = new \u{275}DominoAdapter;
|
|
241
|
+
const seedDoc = typeof adapter.createHtmlDocument === "function" ? adapter.createHtmlDocument() : typeof adapter.getDefaultDocument === "function" ? adapter.getDefaultDocument() : null;
|
|
242
|
+
if (seedDoc) {
|
|
243
|
+
patchElementLayout(seedDoc);
|
|
244
|
+
const probe = seedDoc.createElement("div");
|
|
245
|
+
if (typeof probe.getBoundingClientRect !== "function") {
|
|
246
|
+
console.warn("[Angular Patch] Layout shim did not stick on probe element prototype chain");
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
} catch (error) {
|
|
250
|
+
console.warn("[Angular Patch] Could not eagerly patch Element prototypes:", error);
|
|
251
|
+
}
|
|
252
|
+
const proto = \u{275}DominoAdapter.prototype;
|
|
253
|
+
const origGetBaseHref = proto.getBaseHref;
|
|
254
|
+
proto.getBaseHref = function(doc) {
|
|
255
|
+
if (!doc || !doc.head || typeof doc.head.children === "undefined") {
|
|
256
|
+
return "";
|
|
257
|
+
}
|
|
258
|
+
return origGetBaseHref.call(this, doc);
|
|
259
|
+
};
|
|
260
|
+
const origCreateHtmlDocument = proto.createHtmlDocument;
|
|
261
|
+
proto.createHtmlDocument = function() {
|
|
262
|
+
const doc = origCreateHtmlDocument.call(this);
|
|
263
|
+
ensureHead(doc);
|
|
264
|
+
patchElementLayout(doc);
|
|
265
|
+
return doc;
|
|
266
|
+
};
|
|
267
|
+
const origGetDefaultDocument = proto.getDefaultDocument;
|
|
268
|
+
proto.getDefaultDocument = function() {
|
|
269
|
+
const doc = origGetDefaultDocument.call(this);
|
|
270
|
+
ensureHead(doc);
|
|
271
|
+
patchElementLayout(doc);
|
|
272
|
+
return doc;
|
|
273
|
+
};
|
|
274
|
+
return true;
|
|
275
|
+
};
|
|
276
|
+
var init_angularPatch = __esm(() => {
|
|
277
|
+
init_resolveAngularPackage();
|
|
278
|
+
SSR_LAYOUT_RECT = Object.freeze({
|
|
279
|
+
bottom: 0,
|
|
280
|
+
height: 0,
|
|
281
|
+
left: 0,
|
|
282
|
+
right: 0,
|
|
283
|
+
top: 0,
|
|
284
|
+
width: 0,
|
|
285
|
+
x: 0,
|
|
286
|
+
y: 0,
|
|
287
|
+
toJSON() {
|
|
288
|
+
return this;
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
// src/angular/angularDeps.ts
|
|
294
|
+
var initDominoAdapter = (platformServer) => {
|
|
295
|
+
try {
|
|
296
|
+
platformServer.\u{275}DominoAdapter?.makeCurrent?.();
|
|
297
|
+
} catch (err) {
|
|
298
|
+
console.error("Failed to initialize DominoAdapter:", err);
|
|
299
|
+
}
|
|
300
|
+
}, loadAngularDeps = async () => {
|
|
301
|
+
if (true) {
|
|
302
|
+
await import(resolveAngularRuntimePath("@angular/compiler"));
|
|
303
|
+
}
|
|
304
|
+
const { applyPatches: applyPatches2 } = await Promise.resolve().then(() => (init_angularPatch(), exports_angularPatch));
|
|
305
|
+
await applyPatches2();
|
|
306
|
+
const [platformBrowser, platformServer, common, core] = await Promise.all([
|
|
307
|
+
import(resolveAngularRuntimePath("@angular/platform-browser")),
|
|
308
|
+
import(resolveAngularRuntimePath("@angular/platform-server")),
|
|
309
|
+
import(resolveAngularRuntimePath("@angular/common")),
|
|
310
|
+
import(resolveAngularRuntimePath("@angular/core"))
|
|
311
|
+
]);
|
|
312
|
+
if (false) {}
|
|
313
|
+
initDominoAdapter(platformServer);
|
|
314
|
+
return {
|
|
315
|
+
APP_BASE_HREF: common.APP_BASE_HREF,
|
|
316
|
+
bootstrapApplication: platformBrowser.bootstrapApplication,
|
|
317
|
+
DomSanitizer: platformBrowser.DomSanitizer,
|
|
318
|
+
ENVIRONMENT_INITIALIZER: core.ENVIRONMENT_INITIALIZER,
|
|
319
|
+
inject: core.inject,
|
|
320
|
+
provideClientHydration: platformBrowser.provideClientHydration,
|
|
321
|
+
provideServerRendering: platformServer.provideServerRendering,
|
|
322
|
+
provideZonelessChangeDetection: core.provideZonelessChangeDetection,
|
|
323
|
+
reflectComponentType: core.reflectComponentType,
|
|
324
|
+
renderApplication: platformServer.renderApplication,
|
|
325
|
+
REQUEST: core.REQUEST,
|
|
326
|
+
REQUEST_CONTEXT: core.REQUEST_CONTEXT,
|
|
327
|
+
RESPONSE_INIT: core.RESPONSE_INIT,
|
|
328
|
+
Sanitizer: core.Sanitizer,
|
|
329
|
+
SecurityContext: core.SecurityContext,
|
|
330
|
+
withHttpTransferCacheOptions: platformBrowser.withHttpTransferCacheOptions
|
|
331
|
+
};
|
|
332
|
+
}, angularDeps = null, getAngularDeps = () => {
|
|
333
|
+
if (!angularDeps) {
|
|
334
|
+
angularDeps = loadAngularDeps();
|
|
335
|
+
}
|
|
336
|
+
return angularDeps;
|
|
337
|
+
};
|
|
338
|
+
var init_angularDeps = __esm(() => {
|
|
339
|
+
init_resolveAngularPackage();
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
// src/utils/stringModifiers.ts
|
|
343
|
+
var normalizeSlug = (str) => str.trim().replace(/\s+/g, "-").replace(/[^A-Za-z0-9\-_]+/g, "").replace(/[-_]{2,}/g, "-"), toKebab = (str) => normalizeSlug(str).replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), toPascal = (str) => {
|
|
344
|
+
if (!str.includes("-") && !str.includes("_")) {
|
|
345
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
346
|
+
}
|
|
347
|
+
return normalizeSlug(str).split(/[-_]/).filter(Boolean).map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1).toLowerCase()).join("");
|
|
348
|
+
}, toScreamingSnake = (str) => str.replace(/([a-z0-9])([A-Z])/g, "$1_$2").toUpperCase();
|
|
349
|
+
|
|
350
|
+
// src/utils/registerClientScript.ts
|
|
351
|
+
var scriptRegistry, requestCounter = 0, getRequestId = () => `req_${Date.now()}_${++requestCounter}`, ssrContextGetter = null, getSsrContextId = () => ssrContextGetter?.() || Object.getOwnPropertyDescriptor(globalThis, "__absolutejs_requestId")?.value, registerClientScript = (script, requestId) => {
|
|
352
|
+
const id = requestId || getSsrContextId() || getRequestId();
|
|
353
|
+
if (!scriptRegistry.has(id)) {
|
|
354
|
+
scriptRegistry.set(id, new Set);
|
|
355
|
+
}
|
|
356
|
+
scriptRegistry.get(id)?.add(script);
|
|
357
|
+
return id;
|
|
358
|
+
}, setSsrContextGetter = (getter) => {
|
|
359
|
+
ssrContextGetter = getter;
|
|
360
|
+
}, clearAllClientScripts = () => {
|
|
361
|
+
scriptRegistry.clear();
|
|
362
|
+
}, generateClientScriptCode = (scripts) => {
|
|
363
|
+
if (scripts.length === 0) {
|
|
364
|
+
return "";
|
|
365
|
+
}
|
|
366
|
+
const scriptCode = scripts.map((script, index) => {
|
|
367
|
+
const funcString = script.toString();
|
|
368
|
+
const bodyMatch = funcString.match(/\{([\s\S]*)\}/);
|
|
369
|
+
if (!bodyMatch || !bodyMatch[1]) {
|
|
370
|
+
return "";
|
|
371
|
+
}
|
|
372
|
+
const body = bodyMatch[1].trim();
|
|
373
|
+
return `
|
|
374
|
+
(function() {
|
|
375
|
+
var executed = false;
|
|
376
|
+
function executeScript_${index}() {
|
|
377
|
+
if (executed) return;
|
|
378
|
+
executed = true;
|
|
379
|
+
${body}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
if (document.readyState === 'complete' || document.readyState === 'interactive') {
|
|
383
|
+
executeScript_${index}();
|
|
384
|
+
} else {
|
|
385
|
+
document.addEventListener('DOMContentLoaded', executeScript_${index});
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// Watch for hydration-added elements
|
|
389
|
+
var observer = new MutationObserver(function() {
|
|
390
|
+
executeScript_${index}();
|
|
391
|
+
if (executed) observer.disconnect();
|
|
392
|
+
});
|
|
393
|
+
if (!executed) {
|
|
394
|
+
observer.observe(document.body || document.documentElement, { childList: true, subtree: true });
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// Single fallback timeout
|
|
398
|
+
setTimeout(function() {
|
|
399
|
+
executeScript_${index}();
|
|
400
|
+
observer.disconnect();
|
|
401
|
+
}, 1000);
|
|
402
|
+
})();`;
|
|
403
|
+
}).join(`
|
|
404
|
+
`);
|
|
405
|
+
return `<script>
|
|
406
|
+
(function() {
|
|
407
|
+
${scriptCode}
|
|
408
|
+
})();
|
|
409
|
+
</script>`;
|
|
410
|
+
}, getAndClearClientScripts = (requestId) => {
|
|
411
|
+
const id = requestId || ssrContextGetter?.();
|
|
412
|
+
if (!id)
|
|
413
|
+
return [];
|
|
414
|
+
const scripts = scriptRegistry.get(id);
|
|
415
|
+
if (!scripts) {
|
|
416
|
+
return [];
|
|
417
|
+
}
|
|
418
|
+
const scriptArray = Array.from(scripts);
|
|
419
|
+
scriptRegistry.delete(id);
|
|
420
|
+
return scriptArray;
|
|
421
|
+
};
|
|
422
|
+
var init_registerClientScript = __esm(() => {
|
|
423
|
+
scriptRegistry = new Map;
|
|
424
|
+
if (typeof globalThis !== "undefined") {
|
|
425
|
+
Object.assign(globalThis, { registerClientScript });
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
// src/angular/httpTransferCache.ts
|
|
430
|
+
var ABSOLUTE_HTTP_TRANSFER_CACHE_SKIP_HEADER = "x-skip-transfer-cache", buildAbsoluteHttpTransferCacheOptions = (options = {}) => {
|
|
431
|
+
const {
|
|
432
|
+
filter: userFilter,
|
|
433
|
+
skipHeader = ABSOLUTE_HTTP_TRANSFER_CACHE_SKIP_HEADER,
|
|
434
|
+
...angularOptions
|
|
435
|
+
} = options;
|
|
436
|
+
return {
|
|
437
|
+
includePostRequests: false,
|
|
438
|
+
includeRequestsWithAuthHeaders: false,
|
|
439
|
+
...angularOptions,
|
|
440
|
+
filter: (request) => !request.headers.has(skipHeader) && (userFilter?.(request) ?? true)
|
|
441
|
+
};
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
// src/angular/requestProviders.ts
|
|
445
|
+
import { REQUEST, REQUEST_CONTEXT, RESPONSE_INIT } from "@angular/core";
|
|
446
|
+
var buildRequestProviders = (deps, request, requestContext, responseInit) => [
|
|
447
|
+
{ provide: deps.REQUEST, useValue: request ?? null },
|
|
448
|
+
{ provide: deps.REQUEST_CONTEXT, useValue: requestContext ?? null },
|
|
449
|
+
{ provide: deps.RESPONSE_INIT, useValue: responseInit ?? null }
|
|
450
|
+
];
|
|
451
|
+
var init_requestProviders = () => {};
|
|
452
|
+
|
|
453
|
+
// src/angular/ssrRender.ts
|
|
454
|
+
var routePropsCache, cacheRouteData = (pagePath, data) => {
|
|
455
|
+
const cacheKey = pagePath.split("?")[0] ?? pagePath;
|
|
456
|
+
routePropsCache.set(cacheKey, data);
|
|
457
|
+
}, getCachedRouteData = (pagePath) => routePropsCache.get(pagePath), selectorCache, buildProviders = (deps, sanitizer, maybeProps, tokenMap, request, requestContext, responseInit, userProviders = []) => {
|
|
458
|
+
const providers = [
|
|
459
|
+
deps.provideServerRendering(),
|
|
460
|
+
deps.provideClientHydration(deps.withHttpTransferCacheOptions(buildAbsoluteHttpTransferCacheOptions())),
|
|
461
|
+
deps.provideZonelessChangeDetection(),
|
|
462
|
+
{ provide: deps.APP_BASE_HREF, useValue: "/" },
|
|
463
|
+
{
|
|
464
|
+
provide: deps.DomSanitizer,
|
|
465
|
+
useValue: sanitizer
|
|
466
|
+
},
|
|
467
|
+
{ provide: deps.Sanitizer, useValue: sanitizer },
|
|
468
|
+
...buildRequestProviders(deps, request, requestContext, responseInit),
|
|
469
|
+
...userProviders
|
|
470
|
+
];
|
|
471
|
+
if (!maybeProps) {
|
|
472
|
+
return providers;
|
|
473
|
+
}
|
|
474
|
+
const propProviders = Object.entries(maybeProps).map(([propName, propValue]) => ({
|
|
475
|
+
token: tokenMap.get(toScreamingSnake(propName)),
|
|
476
|
+
value: propValue
|
|
477
|
+
})).filter((entry) => entry.token).map((entry) => ({ provide: entry.token, useValue: entry.value }));
|
|
478
|
+
return [...providers, ...propProviders];
|
|
479
|
+
}, clearSelectorCache = () => selectorCache.clear(), isInjectionToken = (value) => {
|
|
480
|
+
if (!value || typeof value !== "object") {
|
|
481
|
+
return false;
|
|
482
|
+
}
|
|
483
|
+
return "ngMetadataName" in value && value.ngMetadataName === "InjectionToken";
|
|
484
|
+
}, discoverTokens = (pageModule) => new Map(Object.entries(pageModule).filter(([, value]) => isInjectionToken(value))), resolveSelector = (deps, pagePath, PageComponent) => {
|
|
485
|
+
const cached = selectorCache.get(pagePath);
|
|
486
|
+
if (cached) {
|
|
487
|
+
return cached;
|
|
488
|
+
}
|
|
489
|
+
const selector = deps.reflectComponentType(PageComponent)?.selector ?? "ng-app";
|
|
490
|
+
selectorCache.set(pagePath, selector);
|
|
491
|
+
return selector;
|
|
492
|
+
}, injectBeforeClose = (html, snippet) => {
|
|
493
|
+
if (html.includes("</body>")) {
|
|
494
|
+
return html.replace("</body>", `${snippet}</body>`);
|
|
495
|
+
}
|
|
496
|
+
if (html.includes("</html>")) {
|
|
497
|
+
return html.replace("</html>", `${snippet}</html>`);
|
|
498
|
+
}
|
|
499
|
+
return html + snippet;
|
|
500
|
+
}, injectSsrScripts = (html, requestId, indexPath, props) => {
|
|
501
|
+
let result = html;
|
|
502
|
+
const registeredScripts = getAndClearClientScripts(requestId);
|
|
503
|
+
if (registeredScripts.length > 0) {
|
|
504
|
+
result = injectBeforeClose(result, generateClientScriptCode(registeredScripts));
|
|
505
|
+
}
|
|
506
|
+
if (props) {
|
|
507
|
+
result = injectBeforeClose(result, `<script>window.__ABS_ANGULAR_PAGE_PROPS__ = ${JSON.stringify(props)};</script>`);
|
|
508
|
+
}
|
|
509
|
+
if (indexPath) {
|
|
510
|
+
const escapedIndexPath = JSON.stringify(indexPath);
|
|
511
|
+
result = injectBeforeClose(result, `<script>import(${escapedIndexPath});</script>`);
|
|
512
|
+
}
|
|
513
|
+
return result;
|
|
514
|
+
}, renderAngularApp = async (deps, PageComponent, providers, document, url = "/") => {
|
|
515
|
+
const bootstrap = (context) => deps.bootstrapApplication(PageComponent, { providers }, context);
|
|
516
|
+
return withSuppressedAngularDevLogs(() => deps.renderApplication(bootstrap, {
|
|
517
|
+
document,
|
|
518
|
+
platformProviders: [],
|
|
519
|
+
url
|
|
520
|
+
}));
|
|
521
|
+
}, withSuppressedAngularDevLogs = async (render) => {
|
|
522
|
+
const origLog = console.log;
|
|
523
|
+
console.log = (...args) => {
|
|
524
|
+
if (typeof args[0] === "string" && args[0].includes("development mode")) {
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
origLog.apply(console, args);
|
|
528
|
+
};
|
|
529
|
+
try {
|
|
530
|
+
return await render();
|
|
531
|
+
} finally {
|
|
532
|
+
console.log = origLog;
|
|
533
|
+
}
|
|
534
|
+
};
|
|
535
|
+
var init_ssrRender = __esm(() => {
|
|
536
|
+
init_registerClientScript();
|
|
537
|
+
init_requestProviders();
|
|
538
|
+
routePropsCache = new Map;
|
|
539
|
+
selectorCache = new Map;
|
|
540
|
+
});
|
|
541
|
+
|
|
542
|
+
// src/angular/islands.ts
|
|
543
|
+
var exports_islands = {};
|
|
544
|
+
__export(exports_islands, {
|
|
545
|
+
renderAngularIslandToHtml: () => renderAngularIslandToHtml,
|
|
546
|
+
mountAngularIsland: () => mountAngularIsland,
|
|
547
|
+
isAngularComponent: () => isAngularComponent,
|
|
548
|
+
getAngularIslandSelector: () => getAngularIslandSelector
|
|
549
|
+
});
|
|
550
|
+
var angularIslandSelector = "abs-angular-island", isAngularComponent = (value) => typeof value === "function", getAngularIslandSelector = (_islandId) => angularIslandSelector, getSelectorFromRenderedIsland = (rootElement) => {
|
|
551
|
+
const firstChild = rootElement.firstElementChild;
|
|
552
|
+
if (!(firstChild instanceof HTMLElement)) {
|
|
553
|
+
return null;
|
|
554
|
+
}
|
|
555
|
+
const selector = firstChild.tagName.toLowerCase();
|
|
556
|
+
return selector.length > 0 ? selector : null;
|
|
557
|
+
}, getClientAngularComponentSelector = (component) => {
|
|
558
|
+
const maybeDef = Reflect.get(component, "\u0275cmp");
|
|
559
|
+
if (typeof maybeDef !== "object" || maybeDef === null) {
|
|
560
|
+
return null;
|
|
561
|
+
}
|
|
562
|
+
const maybeSelectors = Reflect.get(maybeDef, "selectors");
|
|
563
|
+
if (!Array.isArray(maybeSelectors)) {
|
|
564
|
+
return null;
|
|
565
|
+
}
|
|
566
|
+
const [firstSelectorGroup] = maybeSelectors;
|
|
567
|
+
if (!Array.isArray(firstSelectorGroup)) {
|
|
568
|
+
return null;
|
|
569
|
+
}
|
|
570
|
+
const [selector] = firstSelectorGroup;
|
|
571
|
+
return typeof selector === "string" && selector.length > 0 ? selector : null;
|
|
572
|
+
}, createAngularIslandApp = async () => {
|
|
573
|
+
const { EnvironmentInjector, provideZonelessChangeDetection } = await import("@angular/core");
|
|
574
|
+
const { createApplication } = await import("@angular/platform-browser");
|
|
575
|
+
const app = await createApplication({
|
|
576
|
+
providers: [provideZonelessChangeDetection()]
|
|
577
|
+
});
|
|
578
|
+
const environmentInjector = app.injector.get(EnvironmentInjector);
|
|
579
|
+
return { app, environmentInjector };
|
|
580
|
+
}, angularIslandAppPromise = null, getAngularIslandApp = async () => {
|
|
581
|
+
if (!angularIslandAppPromise) {
|
|
582
|
+
angularIslandAppPromise = createAngularIslandApp();
|
|
583
|
+
}
|
|
584
|
+
return angularIslandAppPromise;
|
|
585
|
+
}, wrapperMetadataCache, requestRenderCache, getRequestRenderCache = () => {
|
|
586
|
+
const requestId = getSsrContextId();
|
|
587
|
+
if (!requestId) {
|
|
588
|
+
return null;
|
|
589
|
+
}
|
|
590
|
+
const cached = requestRenderCache.get(requestId);
|
|
591
|
+
if (cached) {
|
|
592
|
+
return cached;
|
|
593
|
+
}
|
|
594
|
+
const renderCache = new Map;
|
|
595
|
+
requestRenderCache.set(requestId, renderCache);
|
|
596
|
+
return renderCache;
|
|
597
|
+
}, getAngularIslandWrapperKey = (component, _islandId) => {
|
|
598
|
+
const componentName = typeof component.name === "string" && component.name.length > 0 ? component.name : "AngularIsland";
|
|
599
|
+
return `${componentName}:${angularIslandSelector}`;
|
|
600
|
+
}, getIslandRenderCacheKey = (component, props) => {
|
|
601
|
+
const componentName = typeof component.name === "string" && component.name.length > 0 ? component.name : "AngularIsland";
|
|
602
|
+
return `${componentName}:${JSON.stringify(props)}`;
|
|
603
|
+
}, buildAngularIslandWrapperMetadata = async (component, islandId, wrapperKey) => {
|
|
604
|
+
const { Component, InjectionToken, inject } = await import("@angular/core");
|
|
605
|
+
const { NgComponentOutlet } = await import("@angular/common");
|
|
606
|
+
const deps = await getAngularDeps();
|
|
607
|
+
const selector = getAngularIslandSelector(islandId);
|
|
608
|
+
const propsToken = new InjectionToken(`${wrapperKey}:props`);
|
|
609
|
+
|
|
610
|
+
class AngularIslandWrapperComponent {
|
|
611
|
+
component = component;
|
|
612
|
+
props = inject(propsToken);
|
|
613
|
+
}
|
|
614
|
+
return {
|
|
615
|
+
deps,
|
|
616
|
+
propsToken,
|
|
617
|
+
selector,
|
|
618
|
+
WrapperComponent: Component({
|
|
619
|
+
imports: [NgComponentOutlet, component],
|
|
620
|
+
selector,
|
|
621
|
+
standalone: true,
|
|
622
|
+
template: '<ng-container *ngComponentOutlet="component; inputs: props"></ng-container>'
|
|
623
|
+
})(AngularIslandWrapperComponent)
|
|
624
|
+
};
|
|
625
|
+
}, createAngularIslandWrapper = async (component, islandId) => {
|
|
626
|
+
const wrapperKey = getAngularIslandWrapperKey(component, islandId);
|
|
627
|
+
const cached = wrapperMetadataCache.get(wrapperKey);
|
|
628
|
+
if (cached) {
|
|
629
|
+
return cached;
|
|
630
|
+
}
|
|
631
|
+
const metadataPromise = buildAngularIslandWrapperMetadata(component, islandId, wrapperKey);
|
|
632
|
+
wrapperMetadataCache.set(wrapperKey, metadataPromise);
|
|
633
|
+
return metadataPromise;
|
|
634
|
+
}, extractAngularIslandRoot = (html, selector) => {
|
|
635
|
+
const openTag = `<${selector}`;
|
|
636
|
+
const start = html.indexOf(openTag);
|
|
637
|
+
if (start < 0) {
|
|
638
|
+
throw new Error(`Could not find Angular island root "${selector}".`);
|
|
639
|
+
}
|
|
640
|
+
const endTag = `</${selector}>`;
|
|
641
|
+
const end = html.indexOf(endTag, start);
|
|
642
|
+
if (end < 0) {
|
|
643
|
+
throw new Error(`Could not close Angular island root "${selector}".`);
|
|
644
|
+
}
|
|
645
|
+
return html.slice(start, end + endTag.length);
|
|
646
|
+
}, mountAngularIsland = async (component, element, props, islandId) => {
|
|
647
|
+
await import("@angular/compiler");
|
|
648
|
+
const { createComponent, inputBinding } = await import("@angular/core");
|
|
649
|
+
const selector = getAngularIslandSelector(islandId);
|
|
650
|
+
const { app, environmentInjector } = await getAngularIslandApp();
|
|
651
|
+
let rootElement = element.querySelector(selector);
|
|
652
|
+
if (!(rootElement instanceof HTMLElement)) {
|
|
653
|
+
element.innerHTML = `<${selector}></${selector}>`;
|
|
654
|
+
rootElement = element.querySelector(selector);
|
|
655
|
+
}
|
|
656
|
+
if (!(rootElement instanceof HTMLElement))
|
|
657
|
+
return app;
|
|
658
|
+
const componentSelector = getClientAngularComponentSelector(component) ?? getSelectorFromRenderedIsland(rootElement);
|
|
659
|
+
if (!componentSelector)
|
|
660
|
+
return app;
|
|
661
|
+
rootElement.innerHTML = `<${componentSelector}></${componentSelector}>`;
|
|
662
|
+
const hostElement = rootElement.querySelector(componentSelector);
|
|
663
|
+
if (!(hostElement instanceof HTMLElement))
|
|
664
|
+
return app;
|
|
665
|
+
const bindings = Object.entries(props).map(([key, value]) => inputBinding(key, () => value));
|
|
666
|
+
const componentRef = createComponent(component, {
|
|
667
|
+
bindings,
|
|
668
|
+
environmentInjector,
|
|
669
|
+
hostElement
|
|
670
|
+
});
|
|
671
|
+
app.attachView(componentRef.hostView);
|
|
672
|
+
componentRef.changeDetectorRef.detectChanges();
|
|
673
|
+
window.__ABS_ANGULAR_ISLAND_APPS__ ??= [];
|
|
674
|
+
window.__ABS_ANGULAR_ISLAND_APPS__.push(app);
|
|
675
|
+
return app;
|
|
676
|
+
}, renderAngularIslandToHtml = async (component, props, islandId) => {
|
|
677
|
+
const requestCache = getRequestRenderCache();
|
|
678
|
+
const renderCacheKey = getIslandRenderCacheKey(component, props);
|
|
679
|
+
const cachedHtml = requestCache?.get(renderCacheKey);
|
|
680
|
+
if (cachedHtml) {
|
|
681
|
+
return cachedHtml;
|
|
682
|
+
}
|
|
683
|
+
const { deps, propsToken, selector, WrapperComponent } = await createAngularIslandWrapper(component, islandId);
|
|
684
|
+
const providers = [
|
|
685
|
+
deps.provideServerRendering(),
|
|
686
|
+
deps.provideZonelessChangeDetection(),
|
|
687
|
+
{ provide: deps.APP_BASE_HREF, useValue: "/" },
|
|
688
|
+
{ provide: propsToken, useValue: props }
|
|
689
|
+
];
|
|
690
|
+
const document = `<!DOCTYPE html><html><body><${selector}></${selector}></body></html>`;
|
|
691
|
+
const html = await withSuppressedAngularDevLogs(() => deps.renderApplication((context) => deps.bootstrapApplication(WrapperComponent, { providers }, context), {
|
|
692
|
+
document,
|
|
693
|
+
platformProviders: [],
|
|
694
|
+
url: "/"
|
|
695
|
+
}));
|
|
696
|
+
const islandHtml = extractAngularIslandRoot(html, selector);
|
|
697
|
+
requestCache?.set(renderCacheKey, islandHtml);
|
|
698
|
+
return islandHtml;
|
|
699
|
+
};
|
|
700
|
+
var init_islands2 = __esm(() => {
|
|
701
|
+
init_angularDeps();
|
|
702
|
+
init_ssrRender();
|
|
703
|
+
init_registerClientScript();
|
|
704
|
+
wrapperMetadataCache = new Map;
|
|
705
|
+
requestRenderCache = new Map;
|
|
706
|
+
});
|
|
707
|
+
|
|
708
|
+
// src/core/islandSsr.ts
|
|
709
|
+
var renderAngularIslandToHtmlInternal = async (component, props, islandId) => {
|
|
710
|
+
const { renderAngularIslandToHtml: renderAngularIslandToHtml2 } = await Promise.resolve().then(() => (init_islands2(), exports_islands));
|
|
711
|
+
return renderAngularIslandToHtml2(component, props, islandId);
|
|
712
|
+
}, renderAngularIslandToHtml2, renderReactIslandToHtml = (component, props) => import("react").then(({ createElement }) => import("react-dom/server").then(({ renderToStaticMarkup }) => renderToStaticMarkup(createElement(component, props)))), renderSvelteIslandToHtml = (component, props) => import("svelte/server").then(({ render }) => {
|
|
713
|
+
const { body } = render(component, { props });
|
|
714
|
+
return body;
|
|
715
|
+
}), renderVueIslandToHtml = (component, props) => import("vue").then(({ createSSRApp, h: createVueVNode }) => {
|
|
716
|
+
const app = createSSRApp({
|
|
717
|
+
render: () => createVueVNode(component, props)
|
|
718
|
+
});
|
|
719
|
+
return import("vue/server-renderer").then(({ renderToString }) => renderToString(app));
|
|
720
|
+
});
|
|
721
|
+
var init_islandSsr = __esm(() => {
|
|
722
|
+
renderAngularIslandToHtml2 = renderAngularIslandToHtmlInternal;
|
|
723
|
+
});
|
|
724
|
+
|
|
725
|
+
// src/build/resolvePackageImport.ts
|
|
726
|
+
import { resolve as resolve2, join as join2 } from "path";
|
|
727
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
|
|
728
|
+
var resolveExportPath = (entry, conditions) => {
|
|
729
|
+
if (typeof entry === "string")
|
|
730
|
+
return entry;
|
|
731
|
+
if (!entry || typeof entry !== "object")
|
|
732
|
+
return null;
|
|
733
|
+
for (const condition of conditions) {
|
|
734
|
+
const target = Reflect.get(entry, condition);
|
|
735
|
+
if (typeof target === "string") {
|
|
736
|
+
return target;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
return null;
|
|
740
|
+
}, resolvePackageImport = (specifier, conditions = ["import"]) => {
|
|
741
|
+
if (specifier.startsWith(".") || specifier.startsWith("/"))
|
|
742
|
+
return null;
|
|
743
|
+
const parts = specifier.split("/");
|
|
744
|
+
const isScoped = specifier.startsWith("@");
|
|
745
|
+
const packageName = isScoped ? `${parts[0]}/${parts[1]}` : parts[0];
|
|
746
|
+
const subpath = isScoped ? parts.slice(2).join("/") : parts.slice(1).join("/");
|
|
747
|
+
const exportKey = subpath ? `./${subpath}` : ".";
|
|
748
|
+
const currentPackageJsonPath = resolve2(process.cwd(), "package.json");
|
|
749
|
+
const currentPackageJson = existsSync2(currentPackageJsonPath) ? JSON.parse(readFileSync2(currentPackageJsonPath, "utf-8")) : null;
|
|
750
|
+
const currentPackageDir = currentPackageJson?.name === packageName ? process.cwd() : null;
|
|
751
|
+
const packageDir = currentPackageDir ?? resolve2(process.cwd(), "node_modules", packageName ?? "");
|
|
752
|
+
const packageJsonPath = join2(packageDir, "package.json");
|
|
753
|
+
if (!existsSync2(packageJsonPath))
|
|
754
|
+
return null;
|
|
755
|
+
try {
|
|
756
|
+
const packageJson = currentPackageDir && currentPackageJson ? currentPackageJson : JSON.parse(readFileSync2(packageJsonPath, "utf-8"));
|
|
757
|
+
const { exports } = packageJson;
|
|
758
|
+
if (!exports)
|
|
759
|
+
return null;
|
|
760
|
+
const entry = exports[exportKey];
|
|
761
|
+
if (!entry)
|
|
762
|
+
return null;
|
|
763
|
+
const importPath = resolveExportPath(entry, conditions);
|
|
764
|
+
if (!importPath)
|
|
765
|
+
return null;
|
|
766
|
+
if (currentPackageDir && importPath.startsWith("./dist/")) {
|
|
767
|
+
const sourceCandidate = resolve2(packageDir, importPath.replace(/^\.\/dist\//, "./src/"));
|
|
768
|
+
if (existsSync2(sourceCandidate)) {
|
|
769
|
+
return sourceCandidate;
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
const resolved = resolve2(packageDir, importPath);
|
|
773
|
+
return existsSync2(resolved) ? resolved : null;
|
|
774
|
+
} catch {
|
|
775
|
+
return null;
|
|
776
|
+
}
|
|
777
|
+
};
|
|
778
|
+
var init_resolvePackageImport = () => {};
|
|
779
|
+
|
|
780
|
+
// src/constants.ts
|
|
781
|
+
var ANGULAR_INIT_TIMEOUT_MS = 500, ANSI_ESCAPE_CODE = 27, ANSI_ESCAPE_LENGTH = 3, ASCII_SPACE = 32, BASE_36_RADIX = 36, BUN_BUILD_WARNING_SUPPRESSION = "wildcard sideEffects are not supported yet", BODY_SLICE_LENGTH = 2000, BYTES_PER_KILOBYTE = 1024, CLI_ARGS_OFFSET = 3, CSS_ERROR_RESOLVE_DELAY_MS = 50, CSS_MAX_CHECK_ATTEMPTS = 10, CSS_MAX_PARSE_TIMEOUT_MS = 500, CSS_SHEET_READY_TIMEOUT_MS = 100, DEFAULT_CHUNK_SIZE = 16384, DEFAULT_DEBOUNCE_MS = 15, DEFAULT_PORT = 3000, DEV_SERVER_RESTART_DEBOUNCE_MS = 100, DOM_UPDATE_DELAY_MS = 50, FILE_PROTOCOL_PREFIX_LENGTH = 7, FOCUS_ID_PREFIX_LENGTH = 3, FOCUS_IDX_PREFIX_LENGTH = 4, FOCUS_NAME_PREFIX_LENGTH = 5, HMR_UPDATE_TIMEOUT_MS = 2000, HOOK_SIGNATURE_LENGTH = 12, EXCLUDE_LAST_OFFSET = -1, HTTP_STATUS_OK = 200, HTTP_STATUS_BAD_REQUEST = 400, HTTP_STATUS_NOT_FOUND = 404, HOURS_IN_DAY = 24, HOURS_IN_HALF_DAY = 12, IMAGE_DEFAULT_DEVICE_SIZES, IMAGE_DEFAULT_IMAGE_SIZES, IMAGE_DEFAULT_QUALITY = 75, IMAGE_GLOB_SUFFIX_LENGTH = 2, MAX_ERROR_LENGTH = 200, MAX_RECONNECT_ATTEMPTS = 60, MILLISECONDS_IN_A_SECOND = 1000, MINUTES_IN_AN_HOUR = 60, SECONDS_IN_A_MINUTE = 60, MILLISECONDS_IN_A_MINUTE, MILLISECONDS_IN_A_DAY, OVERLAY_FADE_DURATION_MS = 150, PING_INTERVAL_MS = 30000, RAF_BATCH_COUNT = 3, RANDOM_ID_END_INDEX = 11, REBUILD_BATCH_DELAY_MS = 10, REBUILD_RELOAD_DELAY_MS = 200, RECONNECT_INITIAL_DELAY_MS = 500, RECONNECT_POLL_INTERVAL_MS = 300, REACT_STREAM_SLOT_FAST_DELAY_MS = 5, REACT_STREAM_SLOT_SLOW_DELAY_MS = 20, SIGINT_EXIT_CODE = 130, SIGTERM_EXIT_CODE = 143, SVELTE_CSS_LOAD_TIMEOUT_MS = 500, TIME_PRECISION = 2, TWO_THIRDS, UNFOUND_INDEX = -1, WEBSOCKET_NORMAL_CLOSURE = 1000, WORKSPACE_COMMAND_ARGS_OFFSET = 3, WORKSPACE_FAILURE_LOG_PRINT_LIMIT = 30, WORKSPACE_FAILURE_RECENT_LOG_LIMIT = 60, WORKSPACE_READY_ATTEMPT_TIMEOUT_MS = 5000, WORKSPACE_READY_PROBE_INTERVAL_MS = 250, WORKSPACE_READY_TIMEOUT_MS = 30000, WORKSPACE_SHUTDOWN_TIMEOUT_MS = 1e4, WORKSPACE_TUI_DEFAULT_HEIGHT = 28, WORKSPACE_TUI_DEFAULT_WIDTH = 100, WORKSPACE_TUI_ESCAPE_SEQUENCE_TIMEOUT_MS = 30, WORKSPACE_TUI_FOOTER_LINE_COUNT = 3, WORKSPACE_TUI_MIN_LOG_HEIGHT = 3, WORKSPACE_TUI_MIN_SERVICE_NAME_WIDTH = 7, WORKSPACE_TUI_MIN_TARGET_WIDTH = 8, WORKSPACE_TUI_MIN_WRAP_WIDTH = 12, WORKSPACE_TUI_PROMPT_CURSOR_OFFSET = 3, WORKSPACE_TUI_RECENT_LOG_LIMIT = 40, WORKSPACE_TUI_RENDER_DEBOUNCE_MS = 16, WORKSPACE_TUI_STATUS_WIDTH = 10, WORKSPACE_TUI_TARGET_PADDING_WIDTH = 6, WORKSPACE_TUI_VISIBILITY_WIDTH = 8;
|
|
782
|
+
var init_constants = __esm(() => {
|
|
783
|
+
IMAGE_DEFAULT_DEVICE_SIZES = [
|
|
784
|
+
640,
|
|
785
|
+
750,
|
|
786
|
+
828,
|
|
787
|
+
1080,
|
|
788
|
+
1200,
|
|
789
|
+
1920,
|
|
790
|
+
2048,
|
|
791
|
+
3840
|
|
792
|
+
];
|
|
793
|
+
IMAGE_DEFAULT_IMAGE_SIZES = [16, 32, 48, 64, 96, 128, 256, 384];
|
|
794
|
+
MILLISECONDS_IN_A_MINUTE = MILLISECONDS_IN_A_SECOND * SECONDS_IN_A_MINUTE;
|
|
795
|
+
MILLISECONDS_IN_A_DAY = MILLISECONDS_IN_A_SECOND * SECONDS_IN_A_MINUTE * MINUTES_IN_AN_HOUR * HOURS_IN_DAY;
|
|
796
|
+
TWO_THIRDS = 2 / 3;
|
|
797
|
+
});
|
|
798
|
+
|
|
799
|
+
// src/svelte/lowerIslandSyntax.ts
|
|
800
|
+
var ISLAND_TAG_RE, extractBracedExpression = (text, braceStart) => {
|
|
801
|
+
let depth = 0;
|
|
802
|
+
for (let index = braceStart;index < text.length; index += 1) {
|
|
803
|
+
const char = text[index];
|
|
804
|
+
if (char === "{")
|
|
805
|
+
depth += 1;
|
|
806
|
+
if (char === "}")
|
|
807
|
+
depth -= 1;
|
|
808
|
+
if (depth === 0) {
|
|
809
|
+
return text.slice(braceStart + 1, index).trim();
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
return null;
|
|
813
|
+
}, extractIslandAttribute = (attributeString, name) => {
|
|
814
|
+
const quotedMatch = attributeString.match(new RegExp(`\\b${name}\\s*=\\s*["']([^"']+)["']`));
|
|
815
|
+
if (quotedMatch?.[1]) {
|
|
816
|
+
return { expression: JSON.stringify(quotedMatch[1]), found: true };
|
|
817
|
+
}
|
|
818
|
+
const attributeIndex = attributeString.search(new RegExp(`\\b${name}\\s*=\\s*\\{`));
|
|
819
|
+
if (attributeIndex < 0) {
|
|
820
|
+
return { expression: "", found: false };
|
|
821
|
+
}
|
|
822
|
+
const braceStart = attributeString.indexOf("{", attributeIndex);
|
|
823
|
+
if (braceStart < 0) {
|
|
824
|
+
return { expression: "", found: false };
|
|
825
|
+
}
|
|
826
|
+
const expression = extractBracedExpression(attributeString, braceStart);
|
|
827
|
+
if (expression === null) {
|
|
828
|
+
return { expression: "", found: false };
|
|
829
|
+
}
|
|
830
|
+
return { expression, found: true };
|
|
831
|
+
}, lowerSvelteIslandSyntax = (source, _mode = "server") => {
|
|
832
|
+
if (!source.includes("<Island")) {
|
|
833
|
+
return { code: source, transformed: false };
|
|
834
|
+
}
|
|
835
|
+
let islandIndex = 0;
|
|
836
|
+
const transformedMarkup = source.replace(ISLAND_TAG_RE, (fullMatch, attributeString) => {
|
|
837
|
+
const framework = extractIslandAttribute(attributeString, "framework");
|
|
838
|
+
const component = extractIslandAttribute(attributeString, "component");
|
|
839
|
+
if (!framework.found || !component.found) {
|
|
840
|
+
return fullMatch;
|
|
841
|
+
}
|
|
842
|
+
const hydrate = extractIslandAttribute(attributeString, "hydrate");
|
|
843
|
+
const props = extractIslandAttribute(attributeString, "props");
|
|
844
|
+
const slotId = `absolute-svelte-island-${islandIndex.toString(BASE_36_RADIX)}`;
|
|
845
|
+
islandIndex += 1;
|
|
846
|
+
const resolveExpression = `await __absoluteResolveIslandHtml(${JSON.stringify(slotId)}, { component: ${component.expression}, framework: ${framework.expression}, hydrate: ${hydrate.found ? hydrate.expression : JSON.stringify("load")}, props: ${props.found ? props.expression : "{}"} })`;
|
|
847
|
+
return `<div data-absolute-island-slot="${slotId}" style="display: contents">{@html ${resolveExpression}}</div>`;
|
|
848
|
+
});
|
|
849
|
+
const importLine = 'import { resolveIslandHtml as __absoluteResolveIslandHtml } from "@absolutejs/absolute/svelte";';
|
|
850
|
+
if (transformedMarkup.includes("<script")) {
|
|
851
|
+
return {
|
|
852
|
+
code: transformedMarkup.replace(/<script(\s[^>]*)?>/, (match) => `${match}
|
|
853
|
+
${importLine}
|
|
854
|
+
`),
|
|
855
|
+
transformed: true
|
|
856
|
+
};
|
|
857
|
+
}
|
|
858
|
+
return {
|
|
859
|
+
code: `<script lang="ts">
|
|
860
|
+
${importLine}
|
|
861
|
+
</script>
|
|
862
|
+
${transformedMarkup}`,
|
|
863
|
+
transformed: true
|
|
864
|
+
};
|
|
865
|
+
};
|
|
866
|
+
var init_lowerIslandSyntax = __esm(() => {
|
|
867
|
+
init_constants();
|
|
868
|
+
ISLAND_TAG_RE = /<Island\b([\s\S]*?)\/>/g;
|
|
869
|
+
});
|
|
870
|
+
|
|
871
|
+
// src/svelte/lowerAwaitSlotSyntax.ts
|
|
872
|
+
var AWAIT_BLOCK_RE, escapeTemplateLiteral = (value) => value.replaceAll("\\", "\\\\").replaceAll("`", "\\`").replaceAll("${", "\\${"), markupToTemplateLiteral = (markup) => {
|
|
873
|
+
const escaped = escapeTemplateLiteral(markup.trim());
|
|
874
|
+
const withExpressions = escaped.replace(/\{([^{}]+)\}/g, (_, expression) => `\${${String(expression).trim()}}`);
|
|
875
|
+
return `\`${withExpressions}\``;
|
|
876
|
+
}, lowerSvelteAwaitSlotSyntax = (source) => {
|
|
877
|
+
if (!source.includes("{#await")) {
|
|
878
|
+
return { code: source, transformed: false };
|
|
879
|
+
}
|
|
880
|
+
let awaitIndex = 0;
|
|
881
|
+
let transformed = false;
|
|
882
|
+
const lowered = source.replace(AWAIT_BLOCK_RE, (fullMatch, awaitExpression, pendingMarkup, thenIdentifier, thenMarkup, catchIdentifier, catchMarkup) => {
|
|
883
|
+
const trimmedAwaitExpression = awaitExpression.trim();
|
|
884
|
+
if (!trimmedAwaitExpression) {
|
|
885
|
+
return fullMatch;
|
|
886
|
+
}
|
|
887
|
+
const slotId = `absolute-svelte-await-${awaitIndex.toString(BASE_36_RADIX)}`;
|
|
888
|
+
awaitIndex += 1;
|
|
889
|
+
transformed = true;
|
|
890
|
+
const thenValueIdentifier = thenIdentifier?.trim() || "__awaitValue";
|
|
891
|
+
const catchValueIdentifier = catchIdentifier?.trim() || "__awaitError";
|
|
892
|
+
const fallbackHtml = markupToTemplateLiteral(pendingMarkup);
|
|
893
|
+
const resolvedHtml = markupToTemplateLiteral(thenMarkup);
|
|
894
|
+
const rejectedHtml = typeof catchMarkup === "string" ? markupToTemplateLiteral(catchMarkup) : null;
|
|
895
|
+
const catchBranch = rejectedHtml ? `catch (${catchValueIdentifier}) { return ${rejectedHtml}; }` : "catch (_absoluteAwaitError) { throw _absoluteAwaitError; }";
|
|
896
|
+
return `<AbsoluteAwaitSlot id="${slotId}" fallbackHtml={${fallbackHtml}} resolve={async () => { try { const ${thenValueIdentifier} = await (${trimmedAwaitExpression}); return ${resolvedHtml}; } ${catchBranch} }} />`;
|
|
897
|
+
});
|
|
898
|
+
if (!transformed) {
|
|
899
|
+
return { code: source, transformed: false };
|
|
900
|
+
}
|
|
901
|
+
const importLine = 'import AbsoluteAwaitSlot from "@absolutejs/absolute/svelte/components/AwaitSlot.svelte";';
|
|
902
|
+
if (lowered.includes("<script")) {
|
|
903
|
+
return {
|
|
904
|
+
code: lowered.replace(/<script(\s[^>]*)?>/, (match) => `${match}
|
|
905
|
+
${importLine}
|
|
906
|
+
`),
|
|
907
|
+
transformed: true
|
|
908
|
+
};
|
|
909
|
+
}
|
|
910
|
+
return {
|
|
911
|
+
code: `<script lang="ts">
|
|
912
|
+
${importLine}
|
|
913
|
+
</script>
|
|
914
|
+
${lowered}`,
|
|
915
|
+
transformed: true
|
|
916
|
+
};
|
|
917
|
+
};
|
|
918
|
+
var init_lowerAwaitSlotSyntax = __esm(() => {
|
|
919
|
+
init_constants();
|
|
920
|
+
AWAIT_BLOCK_RE = /\{#await\s+([^}]+)\}([\s\S]*?)\{:then(?:\s+([A-Za-z_$][\w$]*))?\}([\s\S]*?)(?:\{:catch(?:\s+([A-Za-z_$][\w$]*))?\}([\s\S]*?))?\{\/await\}/g;
|
|
921
|
+
});
|
|
922
|
+
|
|
923
|
+
// src/build/stylePreprocessor.ts
|
|
924
|
+
var exports_stylePreprocessor = {};
|
|
925
|
+
__export(exports_stylePreprocessor, {
|
|
926
|
+
stylePreprocessorPlugin: () => stylePreprocessorPlugin,
|
|
927
|
+
recordStyleOutput: () => recordStyleOutput,
|
|
928
|
+
isStylePath: () => isStylePath,
|
|
929
|
+
isStyleModulePath: () => isStyleModulePath,
|
|
930
|
+
isPreprocessableStylePath: () => isPreprocessableStylePath,
|
|
931
|
+
getStyleBaseName: () => getStyleBaseName,
|
|
932
|
+
getCssOutputExtension: () => getCssOutputExtension,
|
|
933
|
+
forgetStyleEntry: () => forgetStyleEntry,
|
|
934
|
+
findStyleEntriesImporting: () => findStyleEntriesImporting,
|
|
935
|
+
createSvelteStylePreprocessor: () => createSvelteStylePreprocessor,
|
|
936
|
+
createStyleTransformConfig: () => createStyleTransformConfig,
|
|
937
|
+
createStylePreprocessorPlugin: () => createStylePreprocessorPlugin,
|
|
938
|
+
compileStyleSource: () => compileStyleSource,
|
|
939
|
+
compileStyleFileIfNeededSync: () => compileStyleFileIfNeededSync,
|
|
940
|
+
compileStyleFileIfNeeded: () => compileStyleFileIfNeeded,
|
|
941
|
+
addStyleImporter: () => addStyleImporter
|
|
942
|
+
});
|
|
943
|
+
import { createHash } from "crypto";
|
|
944
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
|
|
945
|
+
import { readFile } from "fs/promises";
|
|
946
|
+
import { createRequire } from "module";
|
|
2
947
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
948
|
+
dirname,
|
|
949
|
+
extname,
|
|
950
|
+
isAbsolute,
|
|
951
|
+
join as join3,
|
|
952
|
+
relative,
|
|
953
|
+
resolve as resolve3
|
|
954
|
+
} from "path";
|
|
955
|
+
import { fileURLToPath } from "url";
|
|
956
|
+
var CSS_EXTENSION_PATTERN, STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATTERN, importOptionalPeer, requireOptionalPeer, requireFromCwd, isPreprocessableStylePath = (filePath) => STYLE_EXTENSION_PATTERN.test(filePath), isStyleModulePath = (filePath) => STYLE_MODULE_EXTENSION_PATTERN.test(filePath), isStylePath = (filePath) => /\.(css|s[ac]ss|less|styl(?:us)?)$/i.test(filePath), getStyleBaseName = (filePath) => filePath.replace(/\.(css|s[ac]ss|less|styl(?:us)?)$/i, ""), getStyleLanguage = (filePathOrLanguage) => {
|
|
957
|
+
const normalized = filePathOrLanguage.toLowerCase();
|
|
958
|
+
if (normalized === "scss" || normalized.endsWith(".scss"))
|
|
959
|
+
return "scss";
|
|
960
|
+
if (normalized === "sass" || normalized.endsWith(".sass"))
|
|
961
|
+
return "sass";
|
|
962
|
+
if (normalized === "less" || normalized.endsWith(".less"))
|
|
963
|
+
return "less";
|
|
964
|
+
if (normalized === "styl" || normalized === "stylus" || normalized.endsWith(".styl") || normalized.endsWith(".stylus"))
|
|
965
|
+
return "stylus";
|
|
966
|
+
return null;
|
|
967
|
+
}, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`), throwPreprocessorError = (error, filePath, language) => {
|
|
968
|
+
if (!(error instanceof Error)) {
|
|
969
|
+
throw new Error(`${language} compile failed in ${filePath}: ${String(error)}`);
|
|
970
|
+
}
|
|
971
|
+
const detail = error;
|
|
972
|
+
const sassLine = detail.span?.start?.line;
|
|
973
|
+
const sassCol = detail.span?.start?.column;
|
|
974
|
+
const line = detail.line ?? sassLine;
|
|
975
|
+
const column = detail.column ?? sassCol;
|
|
976
|
+
const location = typeof line === "number" ? `:${line}${typeof column === "number" ? `:${column}` : ""}` : "";
|
|
977
|
+
const message = detail.formatted ?? detail.message;
|
|
978
|
+
const wrapped = new Error(`${language} compile failed in ${filePath}${location}
|
|
979
|
+
${message}`);
|
|
980
|
+
wrapped.cause = error;
|
|
981
|
+
throw wrapped;
|
|
982
|
+
}, requireOptionalPeerSync = (specifier) => {
|
|
983
|
+
try {
|
|
984
|
+
return requireFromCwd(specifier);
|
|
985
|
+
} catch {
|
|
986
|
+
return requireOptionalPeer(specifier);
|
|
987
|
+
}
|
|
988
|
+
}, normalizeLoadPaths = (filePath, paths = []) => [
|
|
989
|
+
dirname(filePath),
|
|
990
|
+
process.cwd(),
|
|
991
|
+
...paths.map((path) => resolve3(process.cwd(), path))
|
|
992
|
+
], tsconfigAliasCache, stripJsonComments = (source) => source.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1"), normalizeAliasEntries = (aliases) => Object.entries(aliases ?? {}).map(([pattern, value]) => ({
|
|
993
|
+
pattern,
|
|
994
|
+
replacements: Array.isArray(value) ? value : [value]
|
|
995
|
+
})), readTsconfigAliases = () => {
|
|
996
|
+
const cwd = process.cwd();
|
|
997
|
+
if (tsconfigAliasCache?.cwd === cwd)
|
|
998
|
+
return tsconfigAliasCache;
|
|
999
|
+
const tsconfigPath = resolve3(cwd, "tsconfig.json");
|
|
1000
|
+
const empty = { aliases: [], baseUrl: cwd, cwd };
|
|
1001
|
+
if (!existsSync3(tsconfigPath)) {
|
|
1002
|
+
tsconfigAliasCache = empty;
|
|
1003
|
+
return empty;
|
|
1004
|
+
}
|
|
1005
|
+
try {
|
|
1006
|
+
const parsed = JSON.parse(stripJsonComments(readFileSync3(tsconfigPath, "utf-8")));
|
|
1007
|
+
const compilerOptions = parsed.compilerOptions ?? {};
|
|
1008
|
+
const baseUrl = resolve3(cwd, compilerOptions.baseUrl ?? ".");
|
|
1009
|
+
tsconfigAliasCache = {
|
|
1010
|
+
aliases: normalizeAliasEntries(compilerOptions.paths),
|
|
1011
|
+
baseUrl,
|
|
1012
|
+
cwd
|
|
1013
|
+
};
|
|
1014
|
+
} catch {
|
|
1015
|
+
tsconfigAliasCache = empty;
|
|
1016
|
+
}
|
|
1017
|
+
return tsconfigAliasCache;
|
|
1018
|
+
}, getAliasEntries = (config) => {
|
|
1019
|
+
const tsconfig = readTsconfigAliases();
|
|
1020
|
+
return {
|
|
1021
|
+
aliases: [
|
|
1022
|
+
...normalizeAliasEntries(config?.aliases),
|
|
1023
|
+
...tsconfig.aliases
|
|
1024
|
+
],
|
|
1025
|
+
baseUrl: tsconfig.baseUrl
|
|
1026
|
+
};
|
|
1027
|
+
}, aliasPatternToRegExp = (pattern) => new RegExp(`^${pattern.split("*").map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("(.+)")}$`), resolveAliasTargets = (specifier, config) => {
|
|
1028
|
+
const { aliases, baseUrl } = getAliasEntries(config);
|
|
1029
|
+
const targets = [];
|
|
1030
|
+
for (const alias of aliases) {
|
|
1031
|
+
const match = specifier.match(aliasPatternToRegExp(alias.pattern));
|
|
1032
|
+
if (!match)
|
|
1033
|
+
continue;
|
|
1034
|
+
const wildcard = match[1] ?? "";
|
|
1035
|
+
for (const replacement of alias.replacements) {
|
|
1036
|
+
targets.push(resolve3(baseUrl, replacement.replace("*", wildcard)));
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
return targets;
|
|
1040
|
+
}, getLanguageExtensions = (language) => {
|
|
1041
|
+
if (language === "less")
|
|
1042
|
+
return [".less", ".css"];
|
|
1043
|
+
if (language === "stylus")
|
|
1044
|
+
return [".styl", ".stylus", ".css"];
|
|
1045
|
+
return [".scss", ".sass", ".css"];
|
|
1046
|
+
}, getCandidatePaths = (basePath, language) => {
|
|
1047
|
+
const ext = extname(basePath);
|
|
1048
|
+
const paths = ext ? [basePath] : getLanguageExtensions(language).flatMap((extension) => [
|
|
1049
|
+
`${basePath}${extension}`,
|
|
1050
|
+
join3(basePath, `index${extension}`)
|
|
1051
|
+
]);
|
|
1052
|
+
if (language === "scss" || language === "sass") {
|
|
1053
|
+
return paths.flatMap((path) => {
|
|
1054
|
+
const dir = dirname(path);
|
|
1055
|
+
const base = path.slice(dir.length + 1);
|
|
1056
|
+
return [path, join3(dir, `_${base}`)];
|
|
1057
|
+
});
|
|
1058
|
+
}
|
|
1059
|
+
return paths;
|
|
1060
|
+
}, resolveImportPath = (specifier, fromDirectory, loadPaths, language, config) => {
|
|
1061
|
+
const rawCandidates = [
|
|
1062
|
+
...resolveAliasTargets(specifier, config),
|
|
1063
|
+
isAbsolute(specifier) ? specifier : resolve3(fromDirectory, specifier),
|
|
1064
|
+
...loadPaths.map((path) => resolve3(path, specifier))
|
|
1065
|
+
];
|
|
1066
|
+
for (const candidate of rawCandidates.flatMap((path) => getCandidatePaths(path, language))) {
|
|
1067
|
+
if (existsSync3(candidate))
|
|
1068
|
+
return candidate;
|
|
1069
|
+
}
|
|
1070
|
+
return null;
|
|
1071
|
+
}, isExternalCssUrl = (url) => /^(?:[a-z][a-z0-9+.-]*:|\/\/|#|\/)/i.test(url), splitCssUrl = (url) => {
|
|
1072
|
+
const markerIndex = url.search(/[?#]/);
|
|
1073
|
+
if (markerIndex === -1)
|
|
1074
|
+
return { marker: "", path: url };
|
|
1075
|
+
return {
|
|
1076
|
+
marker: url.slice(markerIndex),
|
|
1077
|
+
path: url.slice(0, markerIndex)
|
|
1078
|
+
};
|
|
1079
|
+
}, rebaseCssUrls = (contents, sourceFile, entryFile) => {
|
|
1080
|
+
const sourceDir = dirname(sourceFile);
|
|
1081
|
+
const entryDir = dirname(entryFile);
|
|
1082
|
+
if (sourceDir === entryDir)
|
|
1083
|
+
return contents;
|
|
1084
|
+
return contents.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/gi, (match, quote, rawUrl) => {
|
|
1085
|
+
const trimmedUrl = rawUrl.trim();
|
|
1086
|
+
if (!trimmedUrl || isExternalCssUrl(trimmedUrl))
|
|
1087
|
+
return match;
|
|
1088
|
+
const { marker, path } = splitCssUrl(trimmedUrl);
|
|
1089
|
+
const rebased = relative(entryDir, resolve3(sourceDir, path)).replace(/\\/g, "/");
|
|
1090
|
+
const normalized = rebased.startsWith(".") ? rebased : `./${rebased}`;
|
|
1091
|
+
const nextQuote = quote || '"';
|
|
1092
|
+
return `url(${nextQuote}${normalized}${marker}${nextQuote})`;
|
|
1093
|
+
});
|
|
1094
|
+
}, rewriteAliasedStyleImports = (contents, sourceFile, loadPaths, language, config) => contents.replace(/(@(?:use|forward|import|require)\s+)(["'])([^"']+)\2/g, (match, prefix, quote, specifier) => {
|
|
1095
|
+
if (specifier.startsWith(".") || isAbsolute(specifier) || isExternalCssUrl(specifier))
|
|
1096
|
+
return match;
|
|
1097
|
+
const resolved = resolveImportPath(specifier, dirname(sourceFile), loadPaths, language, config);
|
|
1098
|
+
return resolved ? `${prefix}${quote}${resolved}${quote}` : match;
|
|
1099
|
+
}), preprocessLoadedStyle = (contents, sourceFile, entryFile, loadPaths = [], language, config) => {
|
|
1100
|
+
const rebased = rebaseCssUrls(contents, sourceFile, entryFile);
|
|
1101
|
+
return language ? rewriteAliasedStyleImports(rebased, sourceFile, loadPaths, language, config) : rebased;
|
|
1102
|
+
}, extractCssModuleExports = (css) => {
|
|
1103
|
+
const exports = {};
|
|
1104
|
+
const nextCss = css.replace(/:export\s*\{([^}]*)\}/g, (_, body) => {
|
|
1105
|
+
for (const declaration of body.split(";")) {
|
|
1106
|
+
const separator = declaration.indexOf(":");
|
|
1107
|
+
if (separator === -1)
|
|
1108
|
+
continue;
|
|
1109
|
+
const key = declaration.slice(0, separator).trim();
|
|
1110
|
+
const value = declaration.slice(separator + 1).trim();
|
|
1111
|
+
if (key && value)
|
|
1112
|
+
exports[key] = value;
|
|
1113
|
+
}
|
|
1114
|
+
return "";
|
|
1115
|
+
});
|
|
1116
|
+
return { css: nextCss, exports };
|
|
1117
|
+
}, getSassOptions = (config, language) => ({
|
|
1118
|
+
...config?.sass ?? {},
|
|
1119
|
+
...language === "scss" ? config?.scss ?? {} : {}
|
|
1120
|
+
}), getLessOptions = (config) => config?.less ?? {}, getStylusOptions = (config) => config?.stylus ?? {}, createStyleTransformConfig = (stylePreprocessors, postcss) => postcss === undefined ? stylePreprocessors : { ...stylePreprocessors ?? {}, postcss }, withAdditionalData = (contents, additionalData) => additionalData ? `${additionalData}
|
|
1121
|
+
${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
1122
|
+
if (mod && typeof mod === "object" && "default" in mod) {
|
|
1123
|
+
return mod.default ?? mod;
|
|
1124
|
+
}
|
|
1125
|
+
return mod;
|
|
1126
|
+
}, loadPostcssConfigFile = async (configPath) => {
|
|
1127
|
+
const resolved = resolve3(process.cwd(), configPath);
|
|
1128
|
+
const loaded = resolved.endsWith(".cjs") || resolved.endsWith(".cts") ? requireOptionalPeerSync(resolved) : await importOptionalPeer(`${new URL(`file://${resolved}`).href}?t=${Date.now()}`);
|
|
1129
|
+
const config = normalizePostcssModule(loaded);
|
|
1130
|
+
const value = typeof config === "function" ? await config({
|
|
1131
|
+
cwd: process.cwd(),
|
|
1132
|
+
env: "development"
|
|
1133
|
+
}) : config;
|
|
1134
|
+
return normalizePostcssModule(value) ?? {};
|
|
1135
|
+
}, normalizePostcssPlugins = (plugins) => {
|
|
1136
|
+
if (!plugins)
|
|
1137
|
+
return [];
|
|
1138
|
+
if (Array.isArray(plugins))
|
|
1139
|
+
return plugins.filter(Boolean);
|
|
1140
|
+
const resolved = [];
|
|
1141
|
+
for (const [specifier, options] of Object.entries(plugins)) {
|
|
1142
|
+
if (options === false)
|
|
1143
|
+
continue;
|
|
1144
|
+
const mod = normalizePostcssModule(requireOptionalPeerSync(specifier));
|
|
1145
|
+
const plugin = typeof mod === "function" ? mod(options === true ? undefined : options) : mod;
|
|
1146
|
+
if (plugin)
|
|
1147
|
+
resolved.push(plugin);
|
|
1148
|
+
}
|
|
1149
|
+
return resolved;
|
|
1150
|
+
}, resolvePostcssConfig = async (config) => {
|
|
1151
|
+
const inlineConfig = config?.postcss;
|
|
1152
|
+
if (!inlineConfig)
|
|
1153
|
+
return null;
|
|
1154
|
+
const fileConfig = inlineConfig.config ? await loadPostcssConfigFile(inlineConfig.config) : {};
|
|
1155
|
+
const plugins = [
|
|
1156
|
+
...normalizePostcssPlugins(fileConfig.plugins),
|
|
1157
|
+
...normalizePostcssPlugins(inlineConfig.plugins)
|
|
1158
|
+
];
|
|
1159
|
+
if (plugins.length === 0)
|
|
1160
|
+
return null;
|
|
1161
|
+
return {
|
|
1162
|
+
options: {
|
|
1163
|
+
...fileConfig.options ?? {},
|
|
1164
|
+
...inlineConfig.options ?? {}
|
|
1165
|
+
},
|
|
1166
|
+
plugins
|
|
1167
|
+
};
|
|
1168
|
+
}, runPostcss = async (css, filePath, config) => {
|
|
1169
|
+
const postcssConfig = await resolvePostcssConfig(config);
|
|
1170
|
+
if (!postcssConfig)
|
|
1171
|
+
return css;
|
|
1172
|
+
let postcssModule;
|
|
1173
|
+
try {
|
|
1174
|
+
postcssModule = await importOptionalPeer("postcss");
|
|
1175
|
+
} catch {
|
|
1176
|
+
throw missingDependencyError("postcss", filePath);
|
|
1177
|
+
}
|
|
1178
|
+
const postcss = postcssModule.default ?? postcssModule;
|
|
1179
|
+
const result = await postcss(postcssConfig.plugins).process(css, {
|
|
1180
|
+
from: filePath,
|
|
1181
|
+
map: false,
|
|
1182
|
+
...postcssConfig.options
|
|
1183
|
+
});
|
|
1184
|
+
return result.css;
|
|
1185
|
+
}, createSassImporter = (entryFile, loadPaths, language, config, deps) => ({
|
|
1186
|
+
canonicalize(specifier, options) {
|
|
1187
|
+
const fromDirectory = options.containingUrl ? dirname(fileURLToPath(options.containingUrl)) : dirname(entryFile);
|
|
1188
|
+
const resolved = resolveImportPath(specifier, fromDirectory, loadPaths, language, config);
|
|
1189
|
+
return resolved ? new URL(`file://${resolved}`) : null;
|
|
1190
|
+
},
|
|
1191
|
+
load(canonicalUrl) {
|
|
1192
|
+
const filePath = fileURLToPath(canonicalUrl);
|
|
1193
|
+
deps?.add(filePath);
|
|
1194
|
+
const fileLanguage = getStyleLanguage(filePath);
|
|
1195
|
+
if (fileLanguage !== "scss" && fileLanguage !== "sass" && fileLanguage !== null)
|
|
1196
|
+
return null;
|
|
1197
|
+
return {
|
|
1198
|
+
contents: preprocessLoadedStyle(readFileSync3(filePath, "utf-8"), filePath, entryFile, loadPaths, language, config),
|
|
1199
|
+
syntax: filePath.endsWith(".sass") ? "indented" : "scss"
|
|
1200
|
+
};
|
|
1201
|
+
}
|
|
1202
|
+
}), createLessFileManager = (entryFile, loadPaths, config, deps) => ({
|
|
1203
|
+
install(less, pluginManager) {
|
|
1204
|
+
const baseManager = new less.FileManager;
|
|
1205
|
+
const manager = Object.create(baseManager);
|
|
1206
|
+
manager.supports = (filename, currentDirectory) => Boolean(resolveImportPath(filename, resolve3(currentDirectory), loadPaths, "less", config));
|
|
1207
|
+
manager.loadFile = async (filename, currentDirectory) => {
|
|
1208
|
+
const resolved = resolveImportPath(filename, resolve3(currentDirectory), loadPaths, "less", config);
|
|
1209
|
+
if (!resolved) {
|
|
1210
|
+
throw new Error(`Unable to resolve Less import "${filename}"`);
|
|
1211
|
+
}
|
|
1212
|
+
deps?.add(resolved);
|
|
1213
|
+
return {
|
|
1214
|
+
contents: preprocessLoadedStyle(await readFile(resolved, "utf-8"), resolved, entryFile, loadPaths, "less", config),
|
|
1215
|
+
filename: resolved
|
|
1216
|
+
};
|
|
1217
|
+
};
|
|
1218
|
+
pluginManager.addFileManager(manager);
|
|
1219
|
+
}
|
|
1220
|
+
}), renderStylus = async (contents, filePath, loadPaths, options, deps) => {
|
|
1221
|
+
let stylus;
|
|
1222
|
+
try {
|
|
1223
|
+
const stylusModule = await importOptionalPeer("stylus");
|
|
1224
|
+
stylus = stylusModule.default ?? stylusModule;
|
|
1225
|
+
} catch {
|
|
1226
|
+
throw missingDependencyError("stylus", filePath);
|
|
1227
|
+
}
|
|
1228
|
+
return new Promise((resolveCss, reject) => {
|
|
1229
|
+
const renderer = stylus(contents);
|
|
1230
|
+
renderer.set("filename", filePath);
|
|
1231
|
+
for (const [key, value] of Object.entries(options.options ?? {})) {
|
|
1232
|
+
renderer.set(key, value);
|
|
1233
|
+
}
|
|
1234
|
+
for (const path of loadPaths)
|
|
1235
|
+
renderer.include(path);
|
|
1236
|
+
renderer.render((error, css) => {
|
|
1237
|
+
if (error) {
|
|
1238
|
+
reject(error);
|
|
1239
|
+
return;
|
|
1240
|
+
}
|
|
1241
|
+
if (deps) {
|
|
1242
|
+
const stylusDeps = renderer.deps?.();
|
|
1243
|
+
if (Array.isArray(stylusDeps)) {
|
|
1244
|
+
for (const dep of stylusDeps)
|
|
1245
|
+
deps.add(resolve3(dep));
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
resolveCss(css ?? "");
|
|
1249
|
+
});
|
|
1250
|
+
});
|
|
1251
|
+
}, styleDependencyGraph, styleOutputHashes, recordStyleDeps = (entry, deps) => {
|
|
1252
|
+
const key = resolve3(entry);
|
|
1253
|
+
const stripped = new Set;
|
|
1254
|
+
for (const dep of deps) {
|
|
1255
|
+
const resolved = resolve3(dep);
|
|
1256
|
+
if (resolved !== key)
|
|
1257
|
+
stripped.add(resolved);
|
|
1258
|
+
}
|
|
1259
|
+
styleDependencyGraph.set(key, stripped);
|
|
1260
|
+
}, addStyleImporter = (importerPath, stylePath) => {
|
|
1261
|
+
const key = resolve3(importerPath);
|
|
1262
|
+
const target = resolve3(stylePath);
|
|
1263
|
+
const deps = styleDependencyGraph.get(key) ?? new Set;
|
|
1264
|
+
deps.add(target);
|
|
1265
|
+
styleDependencyGraph.set(key, deps);
|
|
1266
|
+
}, findStyleEntriesImporting = (changedPath) => {
|
|
1267
|
+
const target = resolve3(changedPath);
|
|
1268
|
+
const importers = [];
|
|
1269
|
+
for (const [entry, deps] of styleDependencyGraph) {
|
|
1270
|
+
if (deps.has(target))
|
|
1271
|
+
importers.push(entry);
|
|
1272
|
+
}
|
|
1273
|
+
return importers;
|
|
1274
|
+
}, recordStyleOutput = (entry, css) => {
|
|
1275
|
+
const key = resolve3(entry);
|
|
1276
|
+
const hash = createHash("sha1").update(css).digest("hex");
|
|
1277
|
+
const previous = styleOutputHashes.get(key);
|
|
1278
|
+
styleOutputHashes.set(key, hash);
|
|
1279
|
+
return previous !== hash;
|
|
1280
|
+
}, forgetStyleEntry = (entry) => {
|
|
1281
|
+
const key = resolve3(entry);
|
|
1282
|
+
styleDependencyGraph.delete(key);
|
|
1283
|
+
styleOutputHashes.delete(key);
|
|
1284
|
+
}, compileStyleSource = async (filePath, source, languageHint, config) => {
|
|
1285
|
+
const language = getStyleLanguage(languageHint ?? filePath);
|
|
1286
|
+
const rawContents = source ?? await readFile(filePath, "utf-8");
|
|
1287
|
+
const deps = new Set;
|
|
1288
|
+
if (language === "scss" || language === "sass") {
|
|
1289
|
+
const options = getSassOptions(config, language);
|
|
1290
|
+
const packageName = options.implementation ?? "sass";
|
|
1291
|
+
let sass;
|
|
1292
|
+
try {
|
|
1293
|
+
sass = await importOptionalPeer(packageName);
|
|
1294
|
+
} catch {
|
|
1295
|
+
throw missingDependencyError(packageName, filePath);
|
|
1296
|
+
}
|
|
1297
|
+
const contents = withAdditionalData(rawContents, options.additionalData);
|
|
1298
|
+
const loadPaths = normalizeLoadPaths(filePath, options.loadPaths);
|
|
1299
|
+
try {
|
|
1300
|
+
const result = sass.compileString(contents, {
|
|
1301
|
+
importers: [
|
|
1302
|
+
createSassImporter(filePath, loadPaths, language, config, deps)
|
|
1303
|
+
],
|
|
1304
|
+
loadPaths,
|
|
1305
|
+
style: "expanded",
|
|
1306
|
+
syntax: language === "sass" ? "indented" : "scss",
|
|
1307
|
+
url: new URL(`file://${filePath}`)
|
|
1308
|
+
});
|
|
1309
|
+
const css = await runPostcss(result.css, filePath, config);
|
|
1310
|
+
recordStyleDeps(filePath, deps);
|
|
1311
|
+
return css;
|
|
1312
|
+
} catch (error) {
|
|
1313
|
+
throwPreprocessorError(error, filePath, language);
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
if (language === "less") {
|
|
1317
|
+
const options = getLessOptions(config);
|
|
1318
|
+
let lessModule;
|
|
1319
|
+
try {
|
|
1320
|
+
lessModule = await importOptionalPeer("less");
|
|
1321
|
+
} catch {
|
|
1322
|
+
throw missingDependencyError("less", filePath);
|
|
1323
|
+
}
|
|
1324
|
+
const less = lessModule.render ? lessModule : lessModule.default;
|
|
1325
|
+
const render = less?.render;
|
|
1326
|
+
if (!render)
|
|
1327
|
+
throw missingDependencyError("less", filePath);
|
|
1328
|
+
const contents = withAdditionalData(rawContents, options.additionalData);
|
|
1329
|
+
const loadPaths = normalizeLoadPaths(filePath, options.paths);
|
|
1330
|
+
try {
|
|
1331
|
+
const result = await render(contents, {
|
|
1332
|
+
...options.options ?? {},
|
|
1333
|
+
filename: filePath,
|
|
1334
|
+
paths: loadPaths,
|
|
1335
|
+
plugins: [
|
|
1336
|
+
...options.options?.plugins ?? [],
|
|
1337
|
+
createLessFileManager(filePath, loadPaths, config, deps)
|
|
1338
|
+
]
|
|
1339
|
+
});
|
|
1340
|
+
const css = await runPostcss(result.css, filePath, config);
|
|
1341
|
+
recordStyleDeps(filePath, deps);
|
|
1342
|
+
return css;
|
|
1343
|
+
} catch (error) {
|
|
1344
|
+
throwPreprocessorError(error, filePath, "less");
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
if (language === "stylus") {
|
|
1348
|
+
const options = getStylusOptions(config);
|
|
1349
|
+
const loadPaths = normalizeLoadPaths(filePath, options.paths);
|
|
1350
|
+
const contents = withAdditionalData(preprocessLoadedStyle(rawContents, filePath, filePath, loadPaths, "stylus", config), options.additionalData);
|
|
1351
|
+
try {
|
|
1352
|
+
const css = await runPostcss(await renderStylus(contents, filePath, loadPaths, options, deps), filePath, config);
|
|
1353
|
+
recordStyleDeps(filePath, deps);
|
|
1354
|
+
return css;
|
|
1355
|
+
} catch (error) {
|
|
1356
|
+
throwPreprocessorError(error, filePath, "stylus");
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
return runPostcss(rawContents, filePath, config);
|
|
1360
|
+
}, createStylePreprocessorPlugin = (config) => ({
|
|
1361
|
+
name: "absolute-style-preprocessor",
|
|
1362
|
+
setup(build) {
|
|
1363
|
+
const cssModuleSources = new Map;
|
|
1364
|
+
build.onResolve({ filter: /^absolute-style-module:/ }, ({ path }) => ({
|
|
1365
|
+
namespace: "absolute-style-module",
|
|
1366
|
+
path: path.slice("absolute-style-module:".length)
|
|
1367
|
+
}));
|
|
1368
|
+
build.onLoad({ filter: /\.module\.css$/i, namespace: "absolute-style-module" }, async ({ path }) => {
|
|
1369
|
+
const source = cssModuleSources.get(path);
|
|
1370
|
+
if (!source) {
|
|
1371
|
+
throw new Error(`Unable to resolve CSS module source for ${path}`);
|
|
1372
|
+
}
|
|
1373
|
+
return {
|
|
1374
|
+
contents: source.css,
|
|
1375
|
+
loader: "css"
|
|
1376
|
+
};
|
|
1377
|
+
});
|
|
1378
|
+
build.onLoad({ filter: STYLE_EXTENSION_PATTERN }, async ({ path }) => {
|
|
1379
|
+
if (isStyleModulePath(path)) {
|
|
1380
|
+
const cssModulePath = path.replace(STYLE_EXTENSION_PATTERN, ".css");
|
|
1381
|
+
const compiled = await compileStyleSource(path, undefined, undefined, config);
|
|
1382
|
+
const { css, exports } = extractCssModuleExports(compiled);
|
|
1383
|
+
cssModuleSources.set(cssModulePath, { css, exports });
|
|
1384
|
+
const exportSource = Object.keys(exports).length > 0 ? `import styles from ${JSON.stringify(`absolute-style-module:${cssModulePath}`)}; export default Object.assign({}, styles, ${JSON.stringify(exports)});` : `export { default } from ${JSON.stringify(`absolute-style-module:${cssModulePath}`)};`;
|
|
1385
|
+
return {
|
|
1386
|
+
contents: exportSource,
|
|
1387
|
+
loader: "js"
|
|
1388
|
+
};
|
|
1389
|
+
}
|
|
1390
|
+
return {
|
|
1391
|
+
contents: await compileStyleSource(path, undefined, undefined, config),
|
|
1392
|
+
loader: "css"
|
|
1393
|
+
};
|
|
1394
|
+
});
|
|
1395
|
+
build.onLoad({ filter: CSS_EXTENSION_PATTERN }, async ({ path }) => ({
|
|
1396
|
+
contents: await compileStyleSource(path, undefined, undefined, config),
|
|
1397
|
+
loader: "css"
|
|
1398
|
+
}));
|
|
1399
|
+
}
|
|
1400
|
+
}), stylePreprocessorPlugin, createSvelteStylePreprocessor = (config) => ({
|
|
1401
|
+
style: async ({
|
|
1402
|
+
attributes,
|
|
1403
|
+
content,
|
|
1404
|
+
filename
|
|
1405
|
+
}) => {
|
|
1406
|
+
const language = typeof attributes.lang === "string" ? attributes.lang : typeof attributes.type === "string" ? attributes.type.replace(/^text\//, "") : null;
|
|
1407
|
+
if (!language || !STYLE_LANGUAGE_PATTERN.test(language))
|
|
1408
|
+
return;
|
|
1409
|
+
const path = filename ?? `style.${language}`;
|
|
1410
|
+
return {
|
|
1411
|
+
code: await compileStyleSource(path, content, language, config)
|
|
1412
|
+
};
|
|
1413
|
+
}
|
|
1414
|
+
}), compileStyleFileIfNeeded = async (filePath, config) => {
|
|
1415
|
+
if (!isPreprocessableStylePath(filePath)) {
|
|
1416
|
+
return runPostcss(await readFile(filePath, "utf-8"), filePath, config);
|
|
1417
|
+
}
|
|
1418
|
+
return compileStyleSource(filePath, undefined, undefined, config);
|
|
1419
|
+
}, compileStyleFileIfNeededSync = (filePath, config) => {
|
|
1420
|
+
const rawContents = readFileSync3(filePath, "utf-8");
|
|
1421
|
+
const language = getStyleLanguage(filePath);
|
|
1422
|
+
if (config?.postcss) {
|
|
1423
|
+
throw new Error(`Unable to compile ${filePath}: PostCSS preprocessing is async-only.`);
|
|
1424
|
+
}
|
|
1425
|
+
if (language === "scss" || language === "sass") {
|
|
1426
|
+
const options = getSassOptions(config, language);
|
|
1427
|
+
const packageName = options.implementation ?? "sass";
|
|
1428
|
+
let sass;
|
|
1429
|
+
try {
|
|
1430
|
+
sass = requireOptionalPeerSync(packageName);
|
|
1431
|
+
} catch {
|
|
1432
|
+
throw missingDependencyError(packageName, filePath);
|
|
1433
|
+
}
|
|
1434
|
+
const contents = withAdditionalData(rawContents, options.additionalData);
|
|
1435
|
+
const loadPaths = normalizeLoadPaths(filePath, options.loadPaths);
|
|
1436
|
+
return sass.compileString(contents, {
|
|
1437
|
+
importers: [
|
|
1438
|
+
createSassImporter(filePath, loadPaths, language, config)
|
|
1439
|
+
],
|
|
1440
|
+
loadPaths,
|
|
1441
|
+
style: "expanded",
|
|
1442
|
+
syntax: language === "sass" ? "indented" : "scss",
|
|
1443
|
+
url: new URL(`file://${filePath}`)
|
|
1444
|
+
}).css;
|
|
1445
|
+
}
|
|
1446
|
+
if (language === "less") {
|
|
1447
|
+
throw new Error(`Unable to compile ${filePath}: Less styleUrl preprocessing is async-only. Import the Less file from a bundled entrypoint or use SCSS/CSS for Angular styleUrl.`);
|
|
1448
|
+
}
|
|
1449
|
+
if (language === "stylus") {
|
|
1450
|
+
throw new Error(`Unable to compile ${filePath}: Stylus styleUrl preprocessing is async-only. Import the Stylus file from a bundled entrypoint or use SCSS/CSS for Angular styleUrl.`);
|
|
1451
|
+
}
|
|
1452
|
+
return rawContents;
|
|
1453
|
+
}, getCssOutputExtension = (filePath) => isPreprocessableStylePath(filePath) ? ".css" : extname(filePath);
|
|
1454
|
+
var init_stylePreprocessor = __esm(() => {
|
|
1455
|
+
CSS_EXTENSION_PATTERN = /\.css$/i;
|
|
1456
|
+
STYLE_EXTENSION_PATTERN = /\.(s[ac]ss|less|styl(?:us)?)$/i;
|
|
1457
|
+
STYLE_MODULE_EXTENSION_PATTERN = /\.module\.(s[ac]ss|less|styl(?:us)?)$/i;
|
|
1458
|
+
STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less|styl(?:us)?)$/i;
|
|
1459
|
+
importOptionalPeer = new Function("specifier", "return import(specifier)");
|
|
1460
|
+
requireOptionalPeer = new Function("specifier", "return require(specifier)");
|
|
1461
|
+
requireFromCwd = createRequire(join3(process.cwd(), "package.json"));
|
|
1462
|
+
styleDependencyGraph = new Map;
|
|
1463
|
+
styleOutputHashes = new Map;
|
|
1464
|
+
stylePreprocessorPlugin = createStylePreprocessorPlugin();
|
|
1465
|
+
});
|
|
1466
|
+
|
|
1467
|
+
// src/core/svelteServerModule.ts
|
|
1468
|
+
import { mkdir, readdir } from "fs/promises";
|
|
1469
|
+
import { basename, dirname as dirname2, extname as extname2, join as join4, relative as relative2, resolve as resolve4 } from "path";
|
|
1470
|
+
var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, ensureRelativeImportPath = (from, target) => {
|
|
1471
|
+
const importPath = relative2(dirname2(from), target).replace(/\\/g, "/");
|
|
1472
|
+
return importPath.startsWith(".") ? importPath : `./${importPath}`;
|
|
1473
|
+
}, processDirectoryEntries = (entries, dir, targetFileName, stack) => {
|
|
1474
|
+
for (const entry of entries) {
|
|
1475
|
+
const entryPath = join4(dir, entry.name);
|
|
1476
|
+
if (entry.isDirectory())
|
|
1477
|
+
stack.push(entryPath);
|
|
1478
|
+
if (entry.isFile() && entry.name === targetFileName) {
|
|
1479
|
+
return entryPath;
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
return null;
|
|
1483
|
+
}, searchDirectoryLevel = async (dirs, targetFileName) => {
|
|
1484
|
+
if (dirs.length === 0)
|
|
1485
|
+
return null;
|
|
1486
|
+
const nextStack = [];
|
|
1487
|
+
const dirEntries = await Promise.all(dirs.map(async (dir) => ({
|
|
1488
|
+
dir,
|
|
1489
|
+
entries: await readdir(dir, {
|
|
1490
|
+
encoding: "utf-8",
|
|
1491
|
+
withFileTypes: true
|
|
1492
|
+
})
|
|
1493
|
+
})));
|
|
1494
|
+
for (const { dir, entries } of dirEntries) {
|
|
1495
|
+
const found = processDirectoryEntries(entries, dir, targetFileName, nextStack);
|
|
1496
|
+
if (found)
|
|
1497
|
+
return found;
|
|
1498
|
+
}
|
|
1499
|
+
return searchDirectoryLevel(nextStack, targetFileName);
|
|
1500
|
+
}, findSourceFileByBasename = async (searchRoot, targetFileName) => searchDirectoryLevel([searchRoot], targetFileName), normalizeBuiltSvelteFileName = (sourcePath) => basename(sourcePath).replace(/-[a-z0-9]{6,}(?=\.svelte$)/i, ""), resolveOriginalSourcePath = async (sourcePath) => {
|
|
1501
|
+
const cachedPath = originalSourcePathCache.get(sourcePath);
|
|
1502
|
+
if (cachedPath !== undefined) {
|
|
1503
|
+
return cachedPath;
|
|
1504
|
+
}
|
|
1505
|
+
if (!sourcePath.includes(`${join4(process.cwd(), "build")}${process.platform === "win32" ? "" : "/"}`) && !sourcePath.includes("/build/")) {
|
|
1506
|
+
originalSourcePathCache.set(sourcePath, sourcePath);
|
|
1507
|
+
return sourcePath;
|
|
1508
|
+
}
|
|
1509
|
+
const resolvedSourcePath = await findSourceFileByBasename(join4(process.cwd(), "src"), normalizeBuiltSvelteFileName(sourcePath));
|
|
1510
|
+
const nextPath = resolvedSourcePath ?? sourcePath;
|
|
1511
|
+
originalSourcePathCache.set(sourcePath, nextPath);
|
|
1512
|
+
return nextPath;
|
|
1513
|
+
}, resolveRelativeModule = async (spec, from) => {
|
|
1514
|
+
if (!spec.startsWith(".")) {
|
|
1515
|
+
return null;
|
|
1516
|
+
}
|
|
1517
|
+
const basePath = resolve4(dirname2(from), spec);
|
|
1518
|
+
const candidates = [
|
|
1519
|
+
basePath,
|
|
1520
|
+
`${basePath}.ts`,
|
|
1521
|
+
`${basePath}.js`,
|
|
1522
|
+
`${basePath}.mjs`,
|
|
1523
|
+
`${basePath}.cjs`,
|
|
1524
|
+
`${basePath}.json`,
|
|
1525
|
+
join4(basePath, "index.ts"),
|
|
1526
|
+
join4(basePath, "index.js"),
|
|
1527
|
+
join4(basePath, "index.mjs"),
|
|
1528
|
+
join4(basePath, "index.cjs"),
|
|
1529
|
+
join4(basePath, "index.json")
|
|
1530
|
+
];
|
|
1531
|
+
const existResults = await Promise.all(candidates.map((candidate) => Bun.file(candidate).exists()));
|
|
1532
|
+
const foundIndex = existResults.indexOf(true);
|
|
1533
|
+
return foundIndex >= 0 ? candidates[foundIndex] ?? null : null;
|
|
1534
|
+
}, getCachedModulePath = (sourcePath) => {
|
|
1535
|
+
const relativeSourcePath = relative2(process.cwd(), sourcePath).replace(/\\/g, "/");
|
|
1536
|
+
const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
|
|
1537
|
+
return join4(serverCacheRoot, `${normalizedSourcePath}.server.js`);
|
|
1538
|
+
}, resolveSvelteImport = async (spec, from) => {
|
|
1539
|
+
if (!spec.startsWith(".") && !spec.startsWith("/")) {
|
|
1540
|
+
const resolved = resolvePackageImport(spec);
|
|
1541
|
+
return resolved && resolved.endsWith(".svelte") ? resolved : null;
|
|
1542
|
+
}
|
|
1543
|
+
if (spec.startsWith("/")) {
|
|
1544
|
+
return spec;
|
|
1545
|
+
}
|
|
1546
|
+
if (!spec.startsWith(".")) {
|
|
1547
|
+
return null;
|
|
1548
|
+
}
|
|
1549
|
+
const explicitPath = resolve4(dirname2(from), spec);
|
|
1550
|
+
if (extname2(explicitPath) === ".svelte") {
|
|
1551
|
+
return explicitPath;
|
|
1552
|
+
}
|
|
1553
|
+
const candidate = `${explicitPath}.svelte`;
|
|
1554
|
+
if (await Bun.file(candidate).exists() === true) {
|
|
1555
|
+
return candidate;
|
|
1556
|
+
}
|
|
1557
|
+
return null;
|
|
1558
|
+
}, writeIfChanged = async (path, content) => {
|
|
1559
|
+
const targetFile = Bun.file(path);
|
|
1560
|
+
const exists = await targetFile.exists();
|
|
1561
|
+
if (exists) {
|
|
1562
|
+
const currentContent = await targetFile.text();
|
|
1563
|
+
if (currentContent === content) {
|
|
1564
|
+
return;
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
await Bun.write(path, content);
|
|
1568
|
+
}, compileSvelteServerModule = async (sourcePath) => {
|
|
1569
|
+
const cachedModulePath = compiledModuleCache.get(sourcePath);
|
|
1570
|
+
if (cachedModulePath) {
|
|
1571
|
+
return cachedModulePath;
|
|
1572
|
+
}
|
|
1573
|
+
const resolutionSourcePath = await resolveOriginalSourcePath(sourcePath);
|
|
1574
|
+
const source = await Bun.file(sourcePath).text();
|
|
1575
|
+
const { compile, preprocess } = await import("svelte/compiler");
|
|
1576
|
+
const loweredAwaitSource = lowerSvelteAwaitSlotSyntax(source);
|
|
1577
|
+
const loweredSource = lowerSvelteIslandSyntax(loweredAwaitSource.code, "server");
|
|
1578
|
+
const preprocessed = await preprocess(loweredSource.code, createSvelteStylePreprocessor());
|
|
1579
|
+
let transpiled = sourcePath.endsWith(".ts") || sourcePath.endsWith(".svelte.ts") ? transpiler.transformSync(preprocessed.code) : preprocessed.code;
|
|
1580
|
+
const childImportSpecs = Array.from(transpiled.matchAll(/from\s+['"]([^'"]+)['"]/g)).map((match) => match[1]).filter((value) => value !== undefined);
|
|
1581
|
+
const resolvedChildModules = await Promise.all(childImportSpecs.map((spec) => resolveSvelteImport(spec, resolutionSourcePath)));
|
|
1582
|
+
const resolvedModuleImports = await Promise.all(childImportSpecs.map((spec) => resolveRelativeModule(spec, resolutionSourcePath)));
|
|
1583
|
+
const childModulePaths = new Map;
|
|
1584
|
+
const rewrittenModulePaths = new Map;
|
|
1585
|
+
const compiledChildren = await Promise.all(childImportSpecs.map(async (spec, index) => {
|
|
1586
|
+
const resolvedChild = resolvedChildModules[index];
|
|
1587
|
+
if (!spec || !resolvedChild)
|
|
1588
|
+
return null;
|
|
1589
|
+
return {
|
|
1590
|
+
compiledPath: await compileSvelteServerModule(resolvedChild),
|
|
1591
|
+
resolvedChild,
|
|
1592
|
+
spec
|
|
1593
|
+
};
|
|
1594
|
+
}));
|
|
1595
|
+
for (const result of compiledChildren) {
|
|
1596
|
+
if (!result)
|
|
1597
|
+
continue;
|
|
1598
|
+
childModulePaths.set(result.spec, result.compiledPath);
|
|
1599
|
+
childModulePaths.set(result.resolvedChild, result.compiledPath);
|
|
1600
|
+
}
|
|
1601
|
+
for (let index = 0;index < childImportSpecs.length; index += 1) {
|
|
1602
|
+
const spec = childImportSpecs[index];
|
|
1603
|
+
const resolvedModuleImport = resolvedModuleImports[index];
|
|
1604
|
+
if (!spec || !resolvedModuleImport)
|
|
1605
|
+
continue;
|
|
1606
|
+
if (resolvedChildModules[index])
|
|
1607
|
+
continue;
|
|
1608
|
+
rewrittenModulePaths.set(spec, ensureRelativeImportPath(getCachedModulePath(sourcePath), resolvedModuleImport));
|
|
1609
|
+
}
|
|
1610
|
+
for (const [spec, resolvedModuleImport] of rewrittenModulePaths) {
|
|
1611
|
+
transpiled = transpiled.replaceAll(spec, resolvedModuleImport);
|
|
1612
|
+
}
|
|
1613
|
+
let compiledCode = compile(transpiled, {
|
|
1614
|
+
css: "injected",
|
|
1615
|
+
experimental: {
|
|
1616
|
+
async: loweredAwaitSource.transformed || loweredSource.transformed
|
|
1617
|
+
},
|
|
1618
|
+
filename: resolutionSourcePath,
|
|
1619
|
+
generate: "server"
|
|
1620
|
+
}).js.code;
|
|
1621
|
+
for (const [spec, compiledChildPath] of childModulePaths) {
|
|
1622
|
+
compiledCode = compiledCode.replaceAll(spec, ensureRelativeImportPath(getCachedModulePath(sourcePath), compiledChildPath));
|
|
1623
|
+
}
|
|
1624
|
+
for (const [spec, resolvedModuleImport] of rewrittenModulePaths) {
|
|
1625
|
+
compiledCode = compiledCode.replaceAll(spec, resolvedModuleImport);
|
|
1626
|
+
}
|
|
1627
|
+
const compiledModulePath = getCachedModulePath(sourcePath);
|
|
1628
|
+
await mkdir(dirname2(compiledModulePath), { recursive: true });
|
|
1629
|
+
await writeIfChanged(compiledModulePath, compiledCode);
|
|
1630
|
+
compiledModuleCache.set(sourcePath, compiledModulePath);
|
|
1631
|
+
return compiledModulePath;
|
|
1632
|
+
};
|
|
1633
|
+
var init_svelteServerModule = __esm(() => {
|
|
1634
|
+
init_resolvePackageImport();
|
|
1635
|
+
init_lowerIslandSyntax();
|
|
1636
|
+
init_lowerAwaitSlotSyntax();
|
|
1637
|
+
init_stylePreprocessor();
|
|
1638
|
+
serverCacheRoot = join4(process.cwd(), ".absolutejs", "islands", "svelte");
|
|
1639
|
+
compiledModuleCache = new Map;
|
|
1640
|
+
originalSourcePathCache = new Map;
|
|
1641
|
+
transpiler = new Bun.Transpiler({
|
|
1642
|
+
loader: "ts",
|
|
1643
|
+
target: "browser"
|
|
1644
|
+
});
|
|
1645
|
+
});
|
|
1646
|
+
|
|
1647
|
+
// src/core/islandMarkupAttributes.ts
|
|
1648
|
+
var getIslandMarkerAttributes = (props, islandId) => ({
|
|
1649
|
+
"data-component": props.component,
|
|
1650
|
+
"data-framework": props.framework,
|
|
1651
|
+
"data-hydrate": props.hydrate ?? "load",
|
|
1652
|
+
"data-island": "true",
|
|
1653
|
+
...islandId ? { "data-island-id": islandId } : {},
|
|
1654
|
+
"data-props": serializeIslandProps(props.props)
|
|
1655
|
+
}), escapeHtmlAttribute = (value) => value.replaceAll("&", "&").replaceAll('"', """).replaceAll("<", "<").replaceAll(">", ">"), serializeIslandAttributes = (attributes) => Object.entries(attributes).map(([key, value]) => `${key}="${escapeHtmlAttribute(value)}"`).join(" ");
|
|
1656
|
+
var init_islandMarkupAttributes = __esm(() => {
|
|
1657
|
+
init_islands();
|
|
1658
|
+
});
|
|
1659
|
+
|
|
1660
|
+
// src/core/renderIslandMarkup.ts
|
|
1661
|
+
var islandSequence = 0, resolvedServerComponentCache, resolvedServerBuildComponentCache, nextIslandId = () => {
|
|
1662
|
+
islandSequence += 1;
|
|
1663
|
+
return `island-${islandSequence}`;
|
|
1664
|
+
}, isRecord2 = (value) => typeof value === "object" && value !== null, isReactServerIslandComponent = (value) => typeof value === "function", isSvelteServerIslandComponent = (value) => typeof value === "function", isVueServerIslandComponent = (value) => typeof value === "function" || isRecord2(value), isAngularServerIslandComponent = (value) => typeof value === "function", resolveBuildReferencePath = (source, registryPath) => {
|
|
1665
|
+
if (source.startsWith("file://"))
|
|
1666
|
+
return new URL(source).pathname;
|
|
1667
|
+
if (source.startsWith("."))
|
|
1668
|
+
return new URL(source, registryPath).pathname;
|
|
1669
|
+
return source;
|
|
1670
|
+
}, loadAndCompileServerBuildComponent = async (buildReferencePath) => {
|
|
1671
|
+
const compiledModulePath = await compileSvelteServerModule(buildReferencePath);
|
|
1672
|
+
const loadedModule = await import(compiledModulePath);
|
|
1673
|
+
return "default" in loadedModule ? loadedModule.default : loadedModule;
|
|
1674
|
+
}, loadServerBuildComponent = async (buildReferencePath) => {
|
|
1675
|
+
const cachedBuildComponent = resolvedServerBuildComponentCache.get(buildReferencePath);
|
|
1676
|
+
if (cachedBuildComponent) {
|
|
1677
|
+
return cachedBuildComponent;
|
|
1678
|
+
}
|
|
1679
|
+
const loadPromise = loadAndCompileServerBuildComponent(buildReferencePath);
|
|
1680
|
+
resolvedServerBuildComponentCache.set(buildReferencePath, loadPromise);
|
|
1681
|
+
return loadPromise;
|
|
1682
|
+
}, loadServerImportComponent = async (resolvedComponent, exportName) => {
|
|
1683
|
+
const resolvedModulePath = resolvedComponent.startsWith(".") ? new URL(resolvedComponent, import.meta.url).pathname : resolvedComponent;
|
|
1684
|
+
const importTarget = resolvedModulePath.endsWith(".svelte") ? await compileSvelteServerModule(resolvedModulePath) : resolvedModulePath;
|
|
1685
|
+
const loadedModule = await import(importTarget);
|
|
1686
|
+
if (exportName && exportName !== "default" && exportName in loadedModule) {
|
|
1687
|
+
return loadedModule[exportName];
|
|
1688
|
+
}
|
|
1689
|
+
return "default" in loadedModule ? loadedModule.default : loadedModule;
|
|
1690
|
+
}, resolveIslandComponent = async (component) => {
|
|
1691
|
+
const buildReference = getIslandBuildReference(component);
|
|
1692
|
+
const buildReferencePath = buildReference?.source ? resolveBuildReferencePath(buildReference.source, import.meta.url) : null;
|
|
1693
|
+
if (buildReferencePath?.endsWith(".svelte")) {
|
|
1694
|
+
return loadServerBuildComponent(buildReferencePath);
|
|
1695
|
+
}
|
|
1696
|
+
if (buildReferencePath) {
|
|
1697
|
+
return loadServerImportComponent(buildReferencePath, buildReference?.export);
|
|
1698
|
+
}
|
|
1699
|
+
const resolvedComponent = getIslandComponent(component);
|
|
1700
|
+
if (typeof resolvedComponent !== "string") {
|
|
1701
|
+
return resolvedComponent;
|
|
1702
|
+
}
|
|
1703
|
+
return loadServerImportComponent(resolvedComponent);
|
|
1704
|
+
}, resolveServerIslandComponent = async (component) => {
|
|
1705
|
+
const cachedResolvedComponent = resolvedServerComponentCache.get(component);
|
|
1706
|
+
if (cachedResolvedComponent) {
|
|
1707
|
+
return cachedResolvedComponent;
|
|
1708
|
+
}
|
|
1709
|
+
const resolutionPromise = resolveIslandComponent(component);
|
|
1710
|
+
resolvedServerComponentCache.set(component, resolutionPromise);
|
|
1711
|
+
return resolutionPromise;
|
|
1712
|
+
}, resolveReactServerIslandComponent = async (component) => {
|
|
1713
|
+
const resolvedComponent = await resolveServerIslandComponent(component);
|
|
1714
|
+
if (!isReactServerIslandComponent(resolvedComponent)) {
|
|
1715
|
+
throw new Error("Resolved React island is not a valid React component.");
|
|
1716
|
+
}
|
|
1717
|
+
return resolvedComponent;
|
|
1718
|
+
}, resolveSvelteServerIslandComponent = async (component) => {
|
|
1719
|
+
const resolvedComponent = await resolveServerIslandComponent(component);
|
|
1720
|
+
if (!isSvelteServerIslandComponent(resolvedComponent)) {
|
|
1721
|
+
throw new Error("Resolved Svelte island is not a valid Svelte component.");
|
|
1722
|
+
}
|
|
1723
|
+
return resolvedComponent;
|
|
1724
|
+
}, resolveVueServerIslandComponent = async (component) => {
|
|
1725
|
+
const resolvedComponent = await resolveServerIslandComponent(component);
|
|
1726
|
+
if (!isVueServerIslandComponent(resolvedComponent)) {
|
|
1727
|
+
throw new Error("Resolved Vue island is not a valid Vue component.");
|
|
1728
|
+
}
|
|
1729
|
+
return resolvedComponent;
|
|
1730
|
+
}, resolveAngularServerIslandComponent = async (component) => {
|
|
1731
|
+
const resolvedComponent = await resolveServerIslandComponent(component);
|
|
1732
|
+
if (!isAngularServerIslandComponent(resolvedComponent)) {
|
|
1733
|
+
throw new Error("Resolved Angular island is not a valid Angular component.");
|
|
1734
|
+
}
|
|
1735
|
+
return resolvedComponent;
|
|
1736
|
+
}, renderIslandMarkup = async (registry, props) => {
|
|
1737
|
+
const result = await renderIslandResult(registry, props);
|
|
1738
|
+
return `<div ${serializeIslandAttributes(result.attributes)}>${result.html}</div>`;
|
|
1739
|
+
}, renderIslandResult = async (registry, props) => {
|
|
1740
|
+
const islandId = nextIslandId();
|
|
1741
|
+
const attributes = getIslandMarkerAttributes(props);
|
|
1742
|
+
if (props.framework === "react") {
|
|
1743
|
+
const entry = registry.react?.[props.component];
|
|
1744
|
+
if (!entry) {
|
|
1745
|
+
throw new Error(`Island component "${props.component}" is not registered for framework "react".`);
|
|
1746
|
+
}
|
|
1747
|
+
const component = await resolveReactServerIslandComponent(entry);
|
|
1748
|
+
const html = await renderReactIslandToHtml(component, props.props);
|
|
1749
|
+
return { attributes, html };
|
|
1750
|
+
}
|
|
1751
|
+
if (props.framework === "svelte") {
|
|
1752
|
+
const entry = registry.svelte?.[props.component];
|
|
1753
|
+
if (!entry) {
|
|
1754
|
+
throw new Error(`Island component "${props.component}" is not registered for framework "svelte".`);
|
|
1755
|
+
}
|
|
1756
|
+
const component = await resolveSvelteServerIslandComponent(entry);
|
|
1757
|
+
const html = await renderSvelteIslandToHtml(component, props.props);
|
|
1758
|
+
return { attributes, html };
|
|
1759
|
+
}
|
|
1760
|
+
if (props.framework === "vue") {
|
|
1761
|
+
const entry = registry.vue?.[props.component];
|
|
1762
|
+
if (!entry) {
|
|
1763
|
+
throw new Error(`Island component "${props.component}" is not registered for framework "vue".`);
|
|
1764
|
+
}
|
|
1765
|
+
const component = await resolveVueServerIslandComponent(entry);
|
|
1766
|
+
const html = await renderVueIslandToHtml(component, props.props);
|
|
1767
|
+
return { attributes, html };
|
|
1768
|
+
}
|
|
1769
|
+
if (props.framework === "angular") {
|
|
1770
|
+
const entry = registry.angular?.[props.component];
|
|
1771
|
+
if (!entry) {
|
|
1772
|
+
throw new Error(`Island component "${props.component}" is not registered for framework "angular".`);
|
|
1773
|
+
}
|
|
1774
|
+
const component = await resolveAngularServerIslandComponent(entry);
|
|
1775
|
+
const html = await renderAngularIslandToHtml2(component, props.props, islandId);
|
|
1776
|
+
return {
|
|
1777
|
+
attributes: {
|
|
1778
|
+
...getIslandMarkerAttributes(props, islandId)
|
|
1779
|
+
},
|
|
1780
|
+
html
|
|
1781
|
+
};
|
|
1782
|
+
}
|
|
1783
|
+
throw new Error(`Framework "${props.framework}" is not implemented in this prototype.`);
|
|
1784
|
+
};
|
|
1785
|
+
var init_renderIslandMarkup = __esm(() => {
|
|
1786
|
+
init_islandSsr();
|
|
1787
|
+
init_svelteServerModule();
|
|
1788
|
+
init_islandMarkupAttributes();
|
|
1789
|
+
init_islands();
|
|
1790
|
+
resolvedServerComponentCache = new Map;
|
|
1791
|
+
resolvedServerBuildComponentCache = new Map;
|
|
1792
|
+
});
|
|
1793
|
+
|
|
1794
|
+
// src/islands/index.ts
|
|
1795
|
+
init_islands();
|
|
1796
|
+
init_renderIslandMarkup();
|
|
1797
|
+
|
|
1798
|
+
// node_modules/zustand/esm/vanilla.mjs
|
|
1799
|
+
var createStoreImpl = (createState) => {
|
|
1800
|
+
let state;
|
|
1801
|
+
const listeners = /* @__PURE__ */ new Set;
|
|
1802
|
+
const setState = (partial, replace) => {
|
|
1803
|
+
const nextState = typeof partial === "function" ? partial(state) : partial;
|
|
1804
|
+
if (!Object.is(nextState, state)) {
|
|
1805
|
+
const previousState = state;
|
|
1806
|
+
state = (replace != null ? replace : typeof nextState !== "object" || nextState === null) ? nextState : Object.assign({}, state, nextState);
|
|
1807
|
+
listeners.forEach((listener) => listener(state, previousState));
|
|
1808
|
+
}
|
|
1809
|
+
};
|
|
1810
|
+
const getState = () => state;
|
|
1811
|
+
const getInitialState = () => initialState;
|
|
1812
|
+
const subscribe = (listener) => {
|
|
1813
|
+
listeners.add(listener);
|
|
1814
|
+
return () => listeners.delete(listener);
|
|
1815
|
+
};
|
|
1816
|
+
const api = { setState, getState, getInitialState, subscribe };
|
|
1817
|
+
const initialState = state = createState(setState, getState, api);
|
|
1818
|
+
return api;
|
|
1819
|
+
};
|
|
1820
|
+
var createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;
|
|
1821
|
+
|
|
1822
|
+
// node_modules/zustand/esm/middleware.mjs
|
|
1823
|
+
function combine(initialState, create) {
|
|
1824
|
+
return (...args) => Object.assign({}, initialState, create(...args));
|
|
1825
|
+
}
|
|
1826
|
+
|
|
1827
|
+
// src/client/islandStore.ts
|
|
1828
|
+
var getIslandStoreSnapshot = () => {
|
|
1829
|
+
globalThis.__ABS_ISLAND_STATE__ ??= {};
|
|
1830
|
+
return globalThis.__ABS_ISLAND_STATE__;
|
|
1831
|
+
};
|
|
1832
|
+
var getIslandStores = () => {
|
|
1833
|
+
globalThis.__ABS_ISLAND_STORES__ ??= new Map;
|
|
1834
|
+
return globalThis.__ABS_ISLAND_STORES__;
|
|
1835
|
+
};
|
|
1836
|
+
var isSerializableValue = (value) => typeof value !== "function" && value !== undefined;
|
|
1837
|
+
var toSerializableState = (state) => Object.fromEntries(Object.entries(state).filter(([, value]) => isSerializableValue(value)));
|
|
1838
|
+
var applySnapshot = (store, snapshot) => {
|
|
1839
|
+
if (!snapshot) {
|
|
1840
|
+
return;
|
|
1841
|
+
}
|
|
1842
|
+
store.setState({
|
|
1843
|
+
...store.getState(),
|
|
1844
|
+
...snapshot
|
|
1845
|
+
});
|
|
1846
|
+
};
|
|
1847
|
+
var getPeerStores = (storeInstances, ownerStore) => [...storeInstances].filter((peer) => peer.store !== ownerStore);
|
|
1848
|
+
var syncIslandSnapshot = (storeId, state, storeInstances, ownerStore) => {
|
|
1849
|
+
const nextSnapshot = toSerializableState(state);
|
|
1850
|
+
getIslandStoreSnapshot()[storeId] = nextSnapshot;
|
|
1851
|
+
for (const peerStore of getPeerStores(storeInstances, ownerStore)) {
|
|
1852
|
+
peerStore.applyExternalSnapshot(nextSnapshot);
|
|
1853
|
+
}
|
|
1854
|
+
};
|
|
1855
|
+
var createIslandStore = (storeId, initialState, createState) => {
|
|
1856
|
+
const store = createStore(combine(initialState, createState));
|
|
1857
|
+
const stores = getIslandStores();
|
|
1858
|
+
const storeInstances = stores.get(storeId) ?? new Set;
|
|
1859
|
+
const initialSnapshot = getIslandStoreSnapshot()[storeId];
|
|
1860
|
+
applySnapshot(store, initialSnapshot);
|
|
1861
|
+
let isApplyingExternalSnapshot = false;
|
|
1862
|
+
const applyExternalSnapshot = (snapshot) => {
|
|
1863
|
+
isApplyingExternalSnapshot = true;
|
|
1864
|
+
applySnapshot(store, snapshot);
|
|
1865
|
+
};
|
|
1866
|
+
storeInstances.add({
|
|
1867
|
+
applyExternalSnapshot,
|
|
1868
|
+
store
|
|
1869
|
+
});
|
|
1870
|
+
stores.set(storeId, storeInstances);
|
|
1871
|
+
syncIslandSnapshot(storeId, store.getState(), storeInstances, store);
|
|
1872
|
+
store.subscribe((state) => {
|
|
1873
|
+
if (isApplyingExternalSnapshot) {
|
|
1874
|
+
isApplyingExternalSnapshot = false;
|
|
1875
|
+
return;
|
|
1876
|
+
}
|
|
1877
|
+
syncIslandSnapshot(storeId, state, storeInstances, store);
|
|
1878
|
+
});
|
|
1879
|
+
return store;
|
|
1880
|
+
};
|
|
1881
|
+
var getIslandStoreServerSnapshot = (store, selector) => selector(store.getInitialState());
|
|
1882
|
+
var applySnapshotToStoreInstances = (storeId, instances, snapshot) => {
|
|
1883
|
+
for (const instance of instances) {
|
|
1884
|
+
instance.applyExternalSnapshot(snapshot[storeId] ?? {});
|
|
1885
|
+
}
|
|
1886
|
+
};
|
|
1887
|
+
var initializeIslandStores = (state) => {
|
|
1888
|
+
const currentSnapshot = getIslandStoreSnapshot();
|
|
1889
|
+
const nextSnapshot = {
|
|
1890
|
+
...state,
|
|
1891
|
+
...currentSnapshot
|
|
1892
|
+
};
|
|
1893
|
+
globalThis.__ABS_ISLAND_STATE__ = nextSnapshot;
|
|
1894
|
+
for (const [storeId, store] of getIslandStores()) {
|
|
1895
|
+
applySnapshotToStoreInstances(storeId, store, nextSnapshot);
|
|
1896
|
+
}
|
|
1897
|
+
};
|
|
1898
|
+
var readIslandStore = (store, selector) => selector(store.getState());
|
|
1899
|
+
var subscribeIslandStore = (store, selector, listener) => {
|
|
1900
|
+
let currentSelection = selector(store.getState());
|
|
1901
|
+
return store.subscribe((state) => {
|
|
1902
|
+
const nextSelection = selector(state);
|
|
1903
|
+
if (Object.is(nextSelection, currentSelection)) {
|
|
1904
|
+
return;
|
|
1905
|
+
}
|
|
1906
|
+
currentSelection = nextSelection;
|
|
1907
|
+
listener(nextSelection);
|
|
1908
|
+
});
|
|
1909
|
+
};
|
|
19
1910
|
export {
|
|
20
1911
|
renderIslandMarkup,
|
|
21
1912
|
defineIslandRegistry,
|
|
22
1913
|
createIslandStore
|
|
23
1914
|
};
|
|
24
1915
|
|
|
25
|
-
//# debugId=
|
|
1916
|
+
//# debugId=588A32FFA954FF4A64756E2164756E21
|
|
26
1917
|
//# sourceMappingURL=index.js.map
|