soma-core 2.2.7 → 2.2.9
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/core/build/compiler/full-manifest-builder.ts +1 -1
- package/core/build/compiler/host-config-sync.cjs +1 -1
- package/core/build/compiler/soma-manifest-webpack-plugin.js +2 -6
- package/core/build/compiler/soma-precompile.js +80 -4
- package/core/client/a11y/announcer.ts +2 -16
- package/core/client/base/SomaPageRootBase.ts +2 -2
- package/core/client/base/defineSomaView.ts +11 -2
- package/core/client/base/runtime-services.types.ts +57 -0
- package/core/client/data/data-object-resolver.ts +36 -5
- package/core/client/data/role-gate.ts +2 -8
- package/core/client/engine/event-engine.ts +1 -0
- package/core/client/engines/chart/adapter-echarts.ts +75 -2
- package/core/client/engines/chart/index.ts +18 -0
- package/core/client/engines/chart/port.ts +13 -0
- package/core/client/engines/diff/adapter-jsdiff.ts +27 -8
- package/core/client/engines/diff/index.ts +81 -6
- package/core/client/engines/diff/items.ts +212 -0
- package/core/client/engines/diff/port.ts +140 -3
- package/core/client/engines/diff/prose.ts +443 -0
- package/core/client/engines/engine-adapters.ts +6 -0
- package/core/client/engines/highlight/adapter-lezer.ts +109 -0
- package/core/client/engines/highlight/index.ts +135 -0
- package/core/client/engines/highlight/port.ts +92 -0
- package/core/client/engines/markdown/adapter-markdown-it.ts +65 -0
- package/core/client/engines/markdown/blocks.ts +335 -0
- package/core/client/engines/markdown/index.ts +51 -0
- package/core/client/engines/markdown/port.ts +94 -0
- package/core/client/engines/markdown/vendor-modules.d.ts +6 -0
- package/core/client/engines/structured/adapter-js-yaml.ts +33 -0
- package/core/client/engines/structured/index.ts +139 -0
- package/core/client/engines/structured/port.ts +59 -0
- package/core/client/infra/http/SomaHttpService.ts +2 -4
- package/core/client/infra/notify/DefaultNotifyService.ts +2 -3
- package/core/client/infra/permission/SomaPermission.ts +1 -1
- package/core/client/render-ports/notify-renderer.ts +2 -46
- package/core/client/runtime/SomaRuntimeServices.ts +16 -45
- package/core/server/host/app-config-composer.ts +6 -52
- package/core/server/host/host-config-paths.cjs +2 -100
- package/core/server/host/precompiled-manifest.ts +69 -0
- package/core/server/infra/host-config-paths.cjs +100 -0
- package/core/server/page-assets.ts +2 -70
- package/core/server/runtime-space/bindings.ts +76 -1
- package/core/server/runtime-space/digest.ts +6 -0
- package/core/server/runtime-space/index.ts +1 -1
- package/core/server/runtime-space/prewarm.ts +8 -8
- package/core/server/runtime-space/store.ts +23 -7
- package/core/server/runtime-space/types.ts +3 -2
- package/core/shared/app-config-merge.ts +59 -0
- package/core/shared/registry-generated/limits.ts +80 -4
- package/core/shared/types/announcer.types.ts +18 -0
- package/core/shared/types/notify.types.ts +26 -0
- package/core/shared/types/role-gate.types.ts +11 -0
- package/dist/browser/runtime-bundle.manifest.json +50 -7
- package/dist/browser/soma-runtime.js +120022 -103991
- package/dist/core/index.cjs +113888 -97846
- package/dist/host-native/aot-builder.cjs +277 -189
- package/dist/host-native/native-server.cjs +245 -84
- package/dist/lsp/component-tree.cjs +80 -4
- package/dist/types/build/compiler/full-manifest-builder.d.ts +1 -1
- package/dist/types/client/a11y/announcer.d.ts +2 -14
- package/dist/types/client/base/SomaPageRootBase.d.ts +2 -2
- package/dist/types/client/base/runtime-services.types.d.ts +50 -0
- package/dist/types/client/data/role-gate.d.ts +2 -8
- package/dist/types/client/engines/chart/index.d.ts +1 -1
- package/dist/types/client/engines/chart/port.d.ts +15 -0
- package/dist/types/client/engines/diff/index.d.ts +1 -1
- package/dist/types/client/engines/diff/items.d.ts +24 -0
- package/dist/types/client/engines/diff/port.d.ts +124 -2
- package/dist/types/client/engines/diff/prose.d.ts +80 -0
- package/dist/types/client/engines/engine-adapters.d.ts +6 -0
- package/dist/types/client/engines/highlight/adapter-lezer.d.ts +6 -0
- package/dist/types/client/engines/highlight/index.d.ts +15 -0
- package/dist/types/client/engines/highlight/port.d.ts +64 -0
- package/dist/types/client/engines/markdown/adapter-markdown-it.d.ts +6 -0
- package/dist/types/client/engines/markdown/blocks.d.ts +29 -0
- package/dist/types/client/engines/markdown/index.d.ts +9 -0
- package/dist/types/client/engines/markdown/port.d.ts +166 -0
- package/dist/types/client/engines/structured/adapter-js-yaml.d.ts +6 -0
- package/dist/types/client/engines/structured/index.d.ts +29 -0
- package/dist/types/client/engines/structured/port.d.ts +45 -0
- package/dist/types/client/infra/http/SomaHttpService.d.ts +1 -1
- package/dist/types/client/infra/notify/DefaultNotifyService.d.ts +2 -3
- package/dist/types/client/infra/permission/SomaPermission.d.ts +1 -1
- package/dist/types/client/render-ports/notify-renderer.d.ts +1 -56
- package/dist/types/client/runtime/SomaRuntimeServices.d.ts +9 -44
- package/dist/types/server/host/app-config-composer.d.ts +2 -3
- package/dist/types/server/host/host-config-paths.d.cts +2 -7
- package/dist/types/server/host/precompiled-manifest.d.ts +5 -0
- package/dist/types/server/infra/host-config-paths.d.cts +7 -0
- package/dist/types/server/page-assets.d.ts +2 -5
- package/dist/types/server/runtime-space/bindings.d.ts +9 -0
- package/dist/types/server/runtime-space/digest.d.ts +5 -0
- package/dist/types/server/runtime-space/index.d.ts +1 -1
- package/dist/types/server/runtime-space/prewarm.d.ts +2 -2
- package/dist/types/server/runtime-space/store.d.ts +4 -0
- package/dist/types/server/runtime-space/types.d.ts +3 -2
- package/dist/types/shared/app-config-merge.d.ts +3 -0
- package/dist/types/shared/registry-generated/limits.d.ts +78 -4
- package/dist/types/shared/types/announcer.types.d.ts +14 -0
- package/dist/types/shared/types/notify.types.d.ts +36 -0
- package/dist/types/shared/types/role-gate.types.d.ts +8 -0
- package/host-native/src/aot-builder.ts +12 -5
- package/host-native/src/dev-chunk-gc.ts +104 -0
- package/host-native/src/host-prepare.ts +19 -2
- package/host-native/src/manifest-http.ts +1 -1
- package/host-native/src/native-server.ts +16 -0
- package/host-native/src/page-http.ts +2 -67
- package/host-native/src/page-payload-cache.ts +68 -0
- package/package.json +16 -2
|
@@ -34,31 +34,31 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
34
34
|
var require_public_packages = __commonJS({
|
|
35
35
|
"host-native/src/public-packages.cjs"(exports2, module2) {
|
|
36
36
|
"use strict";
|
|
37
|
-
var
|
|
38
|
-
var
|
|
37
|
+
var fs3 = require("node:fs");
|
|
38
|
+
var path3 = require("node:path");
|
|
39
39
|
function readJson(filePath) {
|
|
40
40
|
try {
|
|
41
|
-
if (!
|
|
42
|
-
return JSON.parse(
|
|
41
|
+
if (!fs3.existsSync(filePath)) return null;
|
|
42
|
+
return JSON.parse(fs3.readFileSync(filePath, "utf8"));
|
|
43
43
|
} catch {
|
|
44
44
|
return null;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
function isSafePackageChild(packageRoot, candidate) {
|
|
48
|
-
return candidate === packageRoot || candidate.startsWith(`${packageRoot}${
|
|
48
|
+
return candidate === packageRoot || candidate.startsWith(`${packageRoot}${path3.sep}`);
|
|
49
49
|
}
|
|
50
50
|
function collectFiles(root) {
|
|
51
|
-
if (!
|
|
51
|
+
if (!fs3.existsSync(root) || !fs3.statSync(root).isDirectory()) return [];
|
|
52
52
|
const files = [];
|
|
53
|
-
for (const entry of
|
|
54
|
-
const fullPath =
|
|
53
|
+
for (const entry of fs3.readdirSync(root, { withFileTypes: true })) {
|
|
54
|
+
const fullPath = path3.join(root, entry.name);
|
|
55
55
|
if (entry.isDirectory()) files.push(...collectFiles(fullPath));
|
|
56
56
|
else if (entry.isFile()) files.push(fullPath);
|
|
57
57
|
}
|
|
58
58
|
return files;
|
|
59
59
|
}
|
|
60
60
|
function isSafeExportWildcardValue(value) {
|
|
61
|
-
return value.length > 0 && !
|
|
61
|
+
return value.length > 0 && !path3.isAbsolute(value) && value.split(/[\\/]/).every((segment) => segment !== "" && segment !== "." && segment !== "..");
|
|
62
62
|
}
|
|
63
63
|
function expandWildcardExportAliases(packageName, packageRoot, entry, target) {
|
|
64
64
|
if ((entry.match(/\*/g) ?? []).length !== 1 || (target.match(/\*/g) ?? []).length !== 1) return {};
|
|
@@ -68,11 +68,11 @@ var require_public_packages = __commonJS({
|
|
|
68
68
|
const entrySuffix = entry.slice(entryStar + 1);
|
|
69
69
|
const targetPrefix = target.slice(0, targetStar);
|
|
70
70
|
const targetSuffix = target.slice(targetStar + 1);
|
|
71
|
-
const sourceRoot =
|
|
71
|
+
const sourceRoot = path3.resolve(packageRoot, targetPrefix);
|
|
72
72
|
if (!isSafePackageChild(packageRoot, sourceRoot)) return {};
|
|
73
73
|
const aliases = {};
|
|
74
74
|
for (const filePath of collectFiles(sourceRoot)) {
|
|
75
|
-
const relative =
|
|
75
|
+
const relative = path3.relative(sourceRoot, filePath).split(path3.sep).join("/");
|
|
76
76
|
if (!relative.endsWith(targetSuffix)) continue;
|
|
77
77
|
const wildcardValue = relative.slice(0, relative.length - targetSuffix.length);
|
|
78
78
|
if (!isSafeExportWildcardValue(wildcardValue)) continue;
|
|
@@ -83,7 +83,7 @@ var require_public_packages = __commonJS({
|
|
|
83
83
|
return aliases;
|
|
84
84
|
}
|
|
85
85
|
function readPublicPackageAliases(packageName, packageRoot) {
|
|
86
|
-
const exportsMap = readJson(
|
|
86
|
+
const exportsMap = readJson(path3.join(packageRoot, "package.json"))?.exports;
|
|
87
87
|
if (!exportsMap || typeof exportsMap !== "object") return {};
|
|
88
88
|
const exactAliases = {};
|
|
89
89
|
const wildcardAliases = {};
|
|
@@ -108,8 +108,8 @@ var require_public_packages = __commonJS({
|
|
|
108
108
|
);
|
|
109
109
|
continue;
|
|
110
110
|
}
|
|
111
|
-
const resolved =
|
|
112
|
-
if (!isSafePackageChild(packageRoot, resolved) || !
|
|
111
|
+
const resolved = path3.resolve(packageRoot, target);
|
|
112
|
+
if (!isSafePackageChild(packageRoot, resolved) || !fs3.existsSync(resolved)) continue;
|
|
113
113
|
const publicPath = entry === "." ? "" : entry.slice(2);
|
|
114
114
|
const specifier = publicPath ? `${packageName}/${publicPath}` : packageName;
|
|
115
115
|
exactAliases[specifier] = resolved;
|
|
@@ -120,11 +120,11 @@ var require_public_packages = __commonJS({
|
|
|
120
120
|
const aliases = {};
|
|
121
121
|
const searchRoots = [
|
|
122
122
|
repoRoot2,
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
123
|
+
path3.join(repoRoot2, "soma-core"),
|
|
124
|
+
path3.join(repoRoot2, "soma-foundation"),
|
|
125
|
+
path3.join(repoRoot2, "soma-ui"),
|
|
126
|
+
path3.join(repoRoot2, "soma-kit"),
|
|
127
|
+
path3.join(repoRoot2, "soma-ai")
|
|
128
128
|
];
|
|
129
129
|
for (const r of extraRoots) {
|
|
130
130
|
if (r) searchRoots.unshift(r);
|
|
@@ -134,20 +134,20 @@ var require_public_packages = __commonJS({
|
|
|
134
134
|
}
|
|
135
135
|
const seenPackages = /* @__PURE__ */ new Set();
|
|
136
136
|
for (const searchRoot of searchRoots) {
|
|
137
|
-
if (!
|
|
138
|
-
const pkgJsonPath =
|
|
137
|
+
if (!fs3.existsSync(searchRoot)) continue;
|
|
138
|
+
const pkgJsonPath = path3.join(searchRoot, "package.json");
|
|
139
139
|
const pkgJson = readJson(pkgJsonPath);
|
|
140
140
|
if (pkgJson?.name && pkgJson.name.startsWith("soma-") && !seenPackages.has(pkgJson.name)) {
|
|
141
141
|
seenPackages.add(pkgJson.name);
|
|
142
142
|
Object.assign(aliases, readPublicPackageAliases(pkgJson.name, searchRoot));
|
|
143
143
|
}
|
|
144
|
-
const nm =
|
|
145
|
-
if (
|
|
144
|
+
const nm = path3.join(searchRoot, "node_modules");
|
|
145
|
+
if (fs3.existsSync(nm)) {
|
|
146
146
|
try {
|
|
147
|
-
for (const entry of
|
|
147
|
+
for (const entry of fs3.readdirSync(nm, { withFileTypes: true })) {
|
|
148
148
|
if (!entry.isDirectory()) continue;
|
|
149
149
|
if (entry.name.startsWith("soma-") && !seenPackages.has(entry.name)) {
|
|
150
|
-
const pkgPath =
|
|
150
|
+
const pkgPath = path3.join(nm, entry.name);
|
|
151
151
|
seenPackages.add(entry.name);
|
|
152
152
|
Object.assign(aliases, readPublicPackageAliases(entry.name, pkgPath));
|
|
153
153
|
}
|
|
@@ -166,16 +166,16 @@ var require_public_packages = __commonJS({
|
|
|
166
166
|
}
|
|
167
167
|
});
|
|
168
168
|
|
|
169
|
-
// core/server/
|
|
169
|
+
// core/server/infra/host-config-paths.cjs
|
|
170
170
|
var require_host_config_paths = __commonJS({
|
|
171
|
-
"core/server/
|
|
171
|
+
"core/server/infra/host-config-paths.cjs"(exports2, module2) {
|
|
172
172
|
"use strict";
|
|
173
|
-
var
|
|
174
|
-
var
|
|
173
|
+
var fs3 = require("node:fs");
|
|
174
|
+
var path3 = require("node:path");
|
|
175
175
|
function readJson(filePath) {
|
|
176
176
|
try {
|
|
177
|
-
if (!
|
|
178
|
-
return JSON.parse(
|
|
177
|
+
if (!fs3.existsSync(filePath)) return null;
|
|
178
|
+
return JSON.parse(fs3.readFileSync(filePath, "utf8"));
|
|
179
179
|
} catch {
|
|
180
180
|
return null;
|
|
181
181
|
}
|
|
@@ -183,10 +183,10 @@ var require_host_config_paths = __commonJS({
|
|
|
183
183
|
function resolveSafeChildRoot(parent, relativePath, options = {}) {
|
|
184
184
|
const trimmed = typeof relativePath === "string" ? relativePath.trim() : "";
|
|
185
185
|
if (!trimmed) return parent;
|
|
186
|
-
const resolved =
|
|
187
|
-
const normalizedParent =
|
|
188
|
-
if (resolved === normalizedParent || resolved.startsWith(`${normalizedParent}${
|
|
189
|
-
if (options.requireExists && !
|
|
186
|
+
const resolved = path3.resolve(parent, trimmed);
|
|
187
|
+
const normalizedParent = path3.resolve(parent);
|
|
188
|
+
if (resolved === normalizedParent || resolved.startsWith(`${normalizedParent}${path3.sep}`)) {
|
|
189
|
+
if (options.requireExists && !fs3.existsSync(resolved)) {
|
|
190
190
|
return normalizedParent;
|
|
191
191
|
}
|
|
192
192
|
return resolved;
|
|
@@ -205,27 +205,27 @@ var require_host_config_paths = __commonJS({
|
|
|
205
205
|
return normalizeSomaEnv(env.SOMA_ENV ?? env.APP_ENV ?? env.NODE_ENV);
|
|
206
206
|
}
|
|
207
207
|
function resolveHostConfigRoot(hostDir) {
|
|
208
|
-
const normalizedHostDir =
|
|
209
|
-
const packageJson = readJson(
|
|
208
|
+
const normalizedHostDir = path3.resolve(hostDir);
|
|
209
|
+
const packageJson = readJson(path3.join(normalizedHostDir, "package.json"));
|
|
210
210
|
const configured = packageJson?.soma?.configRoot?.trim();
|
|
211
211
|
if (configured) {
|
|
212
212
|
return resolveSafeChildRoot(normalizedHostDir, configured, {
|
|
213
|
-
fallback:
|
|
213
|
+
fallback: path3.join(normalizedHostDir, "config")
|
|
214
214
|
});
|
|
215
215
|
}
|
|
216
216
|
const hostSourceRoot = resolveSafeChildRoot(normalizedHostDir, packageJson?.soma?.hostRoot, {
|
|
217
217
|
requireExists: true
|
|
218
218
|
});
|
|
219
219
|
const candidates = [
|
|
220
|
-
|
|
221
|
-
|
|
220
|
+
path3.join(normalizedHostDir, "config"),
|
|
221
|
+
path3.join(hostSourceRoot, "config")
|
|
222
222
|
];
|
|
223
223
|
for (const candidate of candidates) {
|
|
224
|
-
if (
|
|
224
|
+
if (fs3.existsSync(candidate)) {
|
|
225
225
|
return candidate;
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
|
-
return
|
|
228
|
+
return path3.join(hostSourceRoot, "config");
|
|
229
229
|
}
|
|
230
230
|
function getSomaHostConfigRoot(hostDir) {
|
|
231
231
|
return resolveHostConfigRoot(hostDir);
|
|
@@ -233,11 +233,11 @@ var require_host_config_paths = __commonJS({
|
|
|
233
233
|
function resolveAppConfigPath(configRoot, envName) {
|
|
234
234
|
const env = envName ?? readSomaEnv();
|
|
235
235
|
const candidates = [
|
|
236
|
-
|
|
237
|
-
|
|
236
|
+
path3.join(configRoot, `app.config.${env}.yaml`),
|
|
237
|
+
path3.join(configRoot, "app.config.yaml")
|
|
238
238
|
];
|
|
239
239
|
for (const candidate of candidates) {
|
|
240
|
-
if (
|
|
240
|
+
if (fs3.existsSync(candidate)) {
|
|
241
241
|
return candidate;
|
|
242
242
|
}
|
|
243
243
|
}
|
|
@@ -257,13 +257,21 @@ var require_host_config_paths = __commonJS({
|
|
|
257
257
|
}
|
|
258
258
|
});
|
|
259
259
|
|
|
260
|
+
// core/server/host/host-config-paths.cjs
|
|
261
|
+
var require_host_config_paths2 = __commonJS({
|
|
262
|
+
"core/server/host/host-config-paths.cjs"(exports2, module2) {
|
|
263
|
+
"use strict";
|
|
264
|
+
module2.exports = require_host_config_paths();
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
|
|
260
268
|
// core/server/host/source-packages.cjs
|
|
261
269
|
var require_source_packages = __commonJS({
|
|
262
270
|
"core/server/host/source-packages.cjs"(exports2, module2) {
|
|
263
271
|
"use strict";
|
|
264
|
-
var
|
|
265
|
-
var
|
|
266
|
-
var { getSomaHostConfigRoot } =
|
|
272
|
+
var fs3 = require("node:fs");
|
|
273
|
+
var path3 = require("node:path");
|
|
274
|
+
var { getSomaHostConfigRoot } = require_host_config_paths2();
|
|
267
275
|
var SOMA_SOURCE_PACKAGES_ENV = "SOMA_SOURCE_PACKAGES";
|
|
268
276
|
var MAX_ASSET_SOURCE_CACHE = 64;
|
|
269
277
|
var assetSourcesCache = /* @__PURE__ */ new Map();
|
|
@@ -272,21 +280,21 @@ var require_source_packages = __commonJS({
|
|
|
272
280
|
}
|
|
273
281
|
function readJson(filePath) {
|
|
274
282
|
try {
|
|
275
|
-
if (!
|
|
276
|
-
return JSON.parse(
|
|
283
|
+
if (!fs3.existsSync(filePath)) return null;
|
|
284
|
+
return JSON.parse(fs3.readFileSync(filePath, "utf8"));
|
|
277
285
|
} catch {
|
|
278
286
|
return null;
|
|
279
287
|
}
|
|
280
288
|
}
|
|
281
289
|
function packagePathInNodeModules(hostDir, packageName) {
|
|
282
|
-
return
|
|
290
|
+
return path3.join(hostDir, "node_modules", ...packageName.split("/"));
|
|
283
291
|
}
|
|
284
292
|
function resolvePackageRoot(hostDir, packageName, version) {
|
|
285
293
|
const nodeModulesPath = packagePathInNodeModules(hostDir, packageName);
|
|
286
|
-
if (
|
|
294
|
+
if (fs3.existsSync(nodeModulesPath)) return nodeModulesPath;
|
|
287
295
|
if (typeof version === "string" && version.startsWith("file:")) {
|
|
288
|
-
const fileRoot =
|
|
289
|
-
if (
|
|
296
|
+
const fileRoot = path3.resolve(hostDir, version.slice("file:".length));
|
|
297
|
+
if (fs3.existsSync(fileRoot)) return fileRoot;
|
|
290
298
|
}
|
|
291
299
|
return null;
|
|
292
300
|
}
|
|
@@ -294,19 +302,19 @@ var require_source_packages = __commonJS({
|
|
|
294
302
|
return String(env?.[SOMA_SOURCE_PACKAGES_ENV] ?? "").split(",").map((item) => item.trim()).filter(Boolean);
|
|
295
303
|
}
|
|
296
304
|
function readHostDependencies(hostDir) {
|
|
297
|
-
const packageJson = readJson(
|
|
305
|
+
const packageJson = readJson(path3.join(hostDir, "package.json"));
|
|
298
306
|
return {
|
|
299
307
|
...packageJson?.dependencies ?? {},
|
|
300
308
|
...packageJson?.devDependencies ?? {}
|
|
301
309
|
};
|
|
302
310
|
}
|
|
303
311
|
function resolveSafeChildRoot(parent, relativePath) {
|
|
304
|
-
const normalizedParent =
|
|
312
|
+
const normalizedParent = path3.resolve(parent);
|
|
305
313
|
const trimmed = typeof relativePath === "string" ? relativePath.trim() : "";
|
|
306
314
|
if (!trimmed) return normalizedParent;
|
|
307
|
-
const resolved =
|
|
308
|
-
if (resolved === normalizedParent || resolved.startsWith(`${normalizedParent}${
|
|
309
|
-
return
|
|
315
|
+
const resolved = path3.resolve(normalizedParent, trimmed);
|
|
316
|
+
if (resolved === normalizedParent || resolved.startsWith(`${normalizedParent}${path3.sep}`)) {
|
|
317
|
+
return fs3.existsSync(resolved) ? resolved : normalizedParent;
|
|
310
318
|
}
|
|
311
319
|
return normalizedParent;
|
|
312
320
|
}
|
|
@@ -314,18 +322,18 @@ var require_source_packages = __commonJS({
|
|
|
314
322
|
if (typeof rawPath !== "string") return null;
|
|
315
323
|
const trimmed = rawPath.trim();
|
|
316
324
|
if (!trimmed || trimmed.includes("\0")) return null;
|
|
317
|
-
const resolved =
|
|
318
|
-
if (resolved ===
|
|
319
|
-
if (options.requireExists && !
|
|
325
|
+
const resolved = path3.resolve(baseDir, trimmed);
|
|
326
|
+
if (resolved === path3.parse(resolved).root) return null;
|
|
327
|
+
if (options.requireExists && !fs3.existsSync(resolved)) return null;
|
|
320
328
|
return resolved;
|
|
321
329
|
}
|
|
322
330
|
function getSomaHostSourceRoot2(hostDir, env = process.env) {
|
|
323
|
-
const normalizedHostDir =
|
|
331
|
+
const normalizedHostDir = path3.resolve(hostDir);
|
|
324
332
|
if (env && typeof env.SOMA_WEB_DIR === "string" && env.SOMA_WEB_DIR.trim()) {
|
|
325
333
|
const explicit = resolveExplicitHostPath(normalizedHostDir, env.SOMA_WEB_DIR, { requireExists: false });
|
|
326
334
|
if (explicit) return explicit;
|
|
327
335
|
}
|
|
328
|
-
const packageJson = readJson(
|
|
336
|
+
const packageJson = readJson(path3.join(normalizedHostDir, "package.json"));
|
|
329
337
|
if (typeof packageJson?.soma?.webRoot === "string" && packageJson.soma.webRoot.trim()) {
|
|
330
338
|
const explicit = resolveExplicitHostPath(normalizedHostDir, packageJson.soma.webRoot, { requireExists: true });
|
|
331
339
|
if (explicit) return explicit;
|
|
@@ -333,12 +341,12 @@ var require_source_packages = __commonJS({
|
|
|
333
341
|
return resolveSafeChildRoot(normalizedHostDir, packageJson?.soma?.hostRoot);
|
|
334
342
|
}
|
|
335
343
|
function getSomaHostApiRoot2(hostDir, env = process.env) {
|
|
336
|
-
const normalizedHostDir =
|
|
344
|
+
const normalizedHostDir = path3.resolve(hostDir);
|
|
337
345
|
if (env && typeof env.SOMA_API_DIR === "string" && env.SOMA_API_DIR.trim()) {
|
|
338
346
|
const explicit = resolveExplicitHostPath(normalizedHostDir, env.SOMA_API_DIR, { requireExists: false });
|
|
339
347
|
if (explicit) return explicit;
|
|
340
348
|
}
|
|
341
|
-
const packageJson = readJson(
|
|
349
|
+
const packageJson = readJson(path3.join(normalizedHostDir, "package.json"));
|
|
342
350
|
const candidate = typeof packageJson?.soma?.apiRoot === "string" && packageJson.soma.apiRoot.trim() ? packageJson.soma.apiRoot : typeof packageJson?.soma?.serviceRoot === "string" && packageJson.soma.serviceRoot.trim() ? packageJson.soma.serviceRoot : null;
|
|
343
351
|
if (candidate) {
|
|
344
352
|
const explicit = resolveExplicitHostPath(normalizedHostDir, candidate, { requireExists: true });
|
|
@@ -348,14 +356,14 @@ var require_source_packages = __commonJS({
|
|
|
348
356
|
}
|
|
349
357
|
function isSomaSourcePackage(packageRoot, explicit) {
|
|
350
358
|
if (explicit) return true;
|
|
351
|
-
const packageJson = readJson(
|
|
359
|
+
const packageJson = readJson(path3.join(packageRoot, "package.json"));
|
|
352
360
|
return packageJson?.soma?.source === true;
|
|
353
361
|
}
|
|
354
362
|
function toPackageSource(packageName, packageRoot) {
|
|
355
|
-
const packageJson = readJson(
|
|
363
|
+
const packageJson = readJson(path3.join(packageRoot, "package.json"));
|
|
356
364
|
const codeRoot = resolveSafeChildRoot(packageRoot, packageJson?.soma?.hostRoot);
|
|
357
365
|
const configRoot = resolveSafeChildRoot(packageRoot, packageJson?.soma?.configRoot);
|
|
358
|
-
const hasRootApiService =
|
|
366
|
+
const hasRootApiService = fs3.existsSync(path3.join(packageRoot, "api", "service"));
|
|
359
367
|
const apiRoot = hasRootApiService ? packageRoot : codeRoot;
|
|
360
368
|
return {
|
|
361
369
|
type: "package",
|
|
@@ -368,8 +376,8 @@ var require_source_packages = __commonJS({
|
|
|
368
376
|
};
|
|
369
377
|
}
|
|
370
378
|
function getSomaAssetSources(hostDir, env = process.env) {
|
|
371
|
-
const normalizedHostDir =
|
|
372
|
-
const pkgStat =
|
|
379
|
+
const normalizedHostDir = path3.resolve(hostDir);
|
|
380
|
+
const pkgStat = fs3.statSync(path3.join(normalizedHostDir, "package.json"), { throwIfNoEntry: false });
|
|
373
381
|
const pkgStatKey = pkgStat ? `${pkgStat.mtimeMs}:${pkgStat.size}` : "none";
|
|
374
382
|
const cacheKey = `${normalizedHostDir}\0${env?.[SOMA_SOURCE_PACKAGES_ENV] ?? ""}\0${env?.SOMA_WEB_DIR ?? ""}\0${env?.SOMA_API_DIR ?? ""}\0${pkgStatKey}`;
|
|
375
383
|
const cached = assetSourcesCache.get(cacheKey);
|
|
@@ -412,10 +420,10 @@ var require_source_packages = __commonJS({
|
|
|
412
420
|
];
|
|
413
421
|
}
|
|
414
422
|
function collectHtmlFiles(dir, prefix = "", acc = []) {
|
|
415
|
-
if (!
|
|
416
|
-
for (const entry of
|
|
423
|
+
if (!fs3.existsSync(dir)) return acc;
|
|
424
|
+
for (const entry of fs3.readdirSync(dir, { withFileTypes: true })) {
|
|
417
425
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
418
|
-
const full =
|
|
426
|
+
const full = path3.join(dir, entry.name);
|
|
419
427
|
if (entry.isDirectory()) collectHtmlFiles(full, rel, acc);
|
|
420
428
|
else if (entry.name.endsWith(".html")) acc.push(rel);
|
|
421
429
|
}
|
|
@@ -424,7 +432,7 @@ var require_source_packages = __commonJS({
|
|
|
424
432
|
function collectPageEntries(sources) {
|
|
425
433
|
const byHtmlFile = /* @__PURE__ */ new Map();
|
|
426
434
|
for (const source of orderSourcesForOverride(sources)) {
|
|
427
|
-
const htmlRoot =
|
|
435
|
+
const htmlRoot = path3.join(source.assetRoot, "html");
|
|
428
436
|
for (const htmlFile of collectHtmlFiles(htmlRoot).sort()) {
|
|
429
437
|
byHtmlFile.set(htmlFile, { source, htmlFile });
|
|
430
438
|
}
|
|
@@ -434,11 +442,11 @@ var require_source_packages = __commonJS({
|
|
|
434
442
|
function collectIncludes(sources) {
|
|
435
443
|
const includes = {};
|
|
436
444
|
for (const source of orderSourcesForOverride(sources)) {
|
|
437
|
-
const sharedDir =
|
|
438
|
-
if (!
|
|
439
|
-
for (const entry of
|
|
445
|
+
const sharedDir = path3.join(source.assetRoot, "html", "shared");
|
|
446
|
+
if (!fs3.existsSync(sharedDir)) continue;
|
|
447
|
+
for (const entry of fs3.readdirSync(sharedDir, { withFileTypes: true })) {
|
|
440
448
|
if (!entry.isFile() || !entry.name.endsWith(".html")) continue;
|
|
441
|
-
includes[`shared/${entry.name}`] =
|
|
449
|
+
includes[`shared/${entry.name}`] = fs3.readFileSync(path3.join(sharedDir, entry.name), "utf8");
|
|
442
450
|
}
|
|
443
451
|
}
|
|
444
452
|
return includes;
|
|
@@ -463,8 +471,8 @@ var require_source_packages = __commonJS({
|
|
|
463
471
|
var require_source_aliases = __commonJS({
|
|
464
472
|
"core/server/host/source-aliases.cjs"(exports2, module2) {
|
|
465
473
|
"use strict";
|
|
466
|
-
var
|
|
467
|
-
var
|
|
474
|
+
var fs3 = require("node:fs");
|
|
475
|
+
var path3 = require("node:path");
|
|
468
476
|
var nodeModule = require("node:module");
|
|
469
477
|
var { getSomaHostApiRoot: getSomaHostApiRoot2, getSomaHostSourceRoot: getSomaHostSourceRoot2, resolveSafeChildRoot } = require_source_packages();
|
|
470
478
|
var CODE_INVALID = "CORE-HOST-ALIAS-INVALID";
|
|
@@ -486,8 +494,8 @@ var require_source_aliases = __commonJS({
|
|
|
486
494
|
}
|
|
487
495
|
function readJson(filePath) {
|
|
488
496
|
try {
|
|
489
|
-
if (!
|
|
490
|
-
return JSON.parse(
|
|
497
|
+
if (!fs3.existsSync(filePath)) return null;
|
|
498
|
+
return JSON.parse(fs3.readFileSync(filePath, "utf8"));
|
|
491
499
|
} catch {
|
|
492
500
|
return null;
|
|
493
501
|
}
|
|
@@ -495,7 +503,7 @@ var require_source_aliases = __commonJS({
|
|
|
495
503
|
function readTsconfig(filePath) {
|
|
496
504
|
let raw;
|
|
497
505
|
try {
|
|
498
|
-
raw =
|
|
506
|
+
raw = fs3.readFileSync(filePath, "utf8");
|
|
499
507
|
} catch {
|
|
500
508
|
return null;
|
|
501
509
|
}
|
|
@@ -514,26 +522,26 @@ var require_source_aliases = __commonJS({
|
|
|
514
522
|
}
|
|
515
523
|
function realInside(parent, child) {
|
|
516
524
|
try {
|
|
517
|
-
const p =
|
|
518
|
-
const c =
|
|
519
|
-
return c === p || c.startsWith(`${p}${
|
|
525
|
+
const p = fs3.realpathSync(parent);
|
|
526
|
+
const c = fs3.realpathSync(child);
|
|
527
|
+
return c === p || c.startsWith(`${p}${path3.sep}`);
|
|
520
528
|
} catch {
|
|
521
529
|
return false;
|
|
522
530
|
}
|
|
523
531
|
}
|
|
524
532
|
function resolveSomaSourceRoots(hostDir, env = process.env) {
|
|
525
|
-
let normalizedHostDir =
|
|
526
|
-
if (!
|
|
527
|
-
for (let dir =
|
|
528
|
-
if (
|
|
533
|
+
let normalizedHostDir = path3.resolve(hostDir);
|
|
534
|
+
if (!fs3.existsSync(path3.join(normalizedHostDir, "package.json"))) {
|
|
535
|
+
for (let dir = path3.dirname(normalizedHostDir); ; dir = path3.dirname(dir)) {
|
|
536
|
+
if (fs3.existsSync(path3.join(dir, "package.json"))) {
|
|
529
537
|
normalizedHostDir = dir;
|
|
530
538
|
break;
|
|
531
539
|
}
|
|
532
|
-
if (
|
|
540
|
+
if (path3.dirname(dir) === dir) break;
|
|
533
541
|
}
|
|
534
542
|
}
|
|
535
|
-
const packageJsonPath =
|
|
536
|
-
const stat =
|
|
543
|
+
const packageJsonPath = path3.join(normalizedHostDir, "package.json");
|
|
544
|
+
const stat = fs3.statSync(packageJsonPath, { throwIfNoEntry: false });
|
|
537
545
|
const cacheKey = `${normalizedHostDir}\0${env?.SOMA_API_DIR ?? ""}\0${env?.SOMA_WEB_DIR ?? ""}\0${stat ? `${stat.mtimeMs}:${stat.size}` : "none"}`;
|
|
538
546
|
const cached = resolveCache.get(cacheKey);
|
|
539
547
|
if (cached) return cached;
|
|
@@ -554,14 +562,14 @@ var require_source_aliases = __commonJS({
|
|
|
554
562
|
if (firstRoot === null) firstRoot = rootDir;
|
|
555
563
|
let children;
|
|
556
564
|
try {
|
|
557
|
-
children =
|
|
565
|
+
children = fs3.readdirSync(rootDir, { withFileTypes: true });
|
|
558
566
|
} catch {
|
|
559
567
|
invalid(`\u7684\u6E90\u7801\u6839\u4E0D\u53EF\u8BFB\uFF1A${rootDir}`);
|
|
560
568
|
return;
|
|
561
569
|
}
|
|
562
570
|
for (const entry of children.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
563
|
-
const full =
|
|
564
|
-
const isDir = entry.isDirectory() || entry.isSymbolicLink() &&
|
|
571
|
+
const full = path3.join(rootDir, entry.name);
|
|
572
|
+
const isDir = entry.isDirectory() || entry.isSymbolicLink() && fs3.statSync(full, { throwIfNoEntry: false })?.isDirectory();
|
|
565
573
|
if (!isDir || entry.name.startsWith(".") || entry.name === "node_modules" || !ALIAS_NAME_RE.test(entry.name)) continue;
|
|
566
574
|
candidates.push({ name: entry.name, dir: full });
|
|
567
575
|
}
|
|
@@ -571,9 +579,9 @@ var require_source_aliases = __commonJS({
|
|
|
571
579
|
invalid("\u7684\u8DEF\u5F84\u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32");
|
|
572
580
|
return null;
|
|
573
581
|
}
|
|
574
|
-
const resolved =
|
|
582
|
+
const resolved = path3.resolve(hostDir, rel.trim());
|
|
575
583
|
const safe = resolveSafeChildRoot(hostDir, rel);
|
|
576
|
-
if (safe !== resolved || !
|
|
584
|
+
if (safe !== resolved || !fs3.existsSync(safe) || !fs3.statSync(safe).isDirectory() || !realInside(hostDir, safe)) {
|
|
577
585
|
invalid(`\u7684\u8DEF\u5F84 "${rel}" \u5FC5\u987B\u662F\u5BBF\u4E3B\u76EE\u5F55\u5185\u5DF2\u5B58\u5728\u7684\u76EE\u5F55`);
|
|
578
586
|
return null;
|
|
579
587
|
}
|
|
@@ -626,12 +634,12 @@ var require_source_aliases = __commonJS({
|
|
|
626
634
|
entries.push(candidate);
|
|
627
635
|
}
|
|
628
636
|
for (const { name, dir } of entries) {
|
|
629
|
-
const installed =
|
|
630
|
-
const installedStat =
|
|
637
|
+
const installed = path3.join(hostDir, "node_modules", name);
|
|
638
|
+
const installedStat = fs3.lstatSync(installed, { throwIfNoEntry: false });
|
|
631
639
|
if (!installedStat) continue;
|
|
632
640
|
let same = false;
|
|
633
641
|
try {
|
|
634
|
-
same =
|
|
642
|
+
same = fs3.realpathSync(installed) === fs3.realpathSync(dir);
|
|
635
643
|
} catch {
|
|
636
644
|
same = false;
|
|
637
645
|
}
|
|
@@ -645,13 +653,13 @@ var require_source_aliases = __commonJS({
|
|
|
645
653
|
}
|
|
646
654
|
}
|
|
647
655
|
if (firstRoot !== null) {
|
|
648
|
-
const tsconfig = readTsconfig(
|
|
656
|
+
const tsconfig = readTsconfig(path3.join(hostDir, "tsconfig.json"));
|
|
649
657
|
const baseUrl = tsconfig?.compilerOptions?.baseUrl;
|
|
650
|
-
if (typeof baseUrl === "string" &&
|
|
658
|
+
if (typeof baseUrl === "string" && path3.resolve(hostDir, baseUrl) !== path3.resolve(firstRoot)) {
|
|
651
659
|
diagnostics.push({
|
|
652
660
|
code: CODE_TSCONFIG_DRIFT,
|
|
653
661
|
severity: "warning",
|
|
654
|
-
message: `tsconfig.json \u7684 baseUrl\uFF08${baseUrl}\uFF09\u4E0E soma.sourceRoots \u7684\u6E90\u7801\u6839\uFF08${
|
|
662
|
+
message: `tsconfig.json \u7684 baseUrl\uFF08${baseUrl}\uFF09\u4E0E soma.sourceRoots \u7684\u6E90\u7801\u6839\uFF08${path3.relative(hostDir, firstRoot) || "."}\uFF09\u4E0D\u4E00\u81F4\uFF1A\u7F16\u8F91\u5668\u4E0E\u8FD0\u884C\u671F\u4F1A\u89E3\u6790\u5230\u4E0D\u540C\u76EE\u5F55`
|
|
655
663
|
});
|
|
656
664
|
}
|
|
657
665
|
}
|
|
@@ -672,7 +680,7 @@ var require_source_aliases = __commonJS({
|
|
|
672
680
|
throw error;
|
|
673
681
|
}
|
|
674
682
|
for (const d of resolved.diagnostics) {
|
|
675
|
-
const key = `${
|
|
683
|
+
const key = `${path3.resolve(hostDir)}\0${d.code}\0${d.name ?? ""}\0${d.message}`;
|
|
676
684
|
if (warned.has(key)) continue;
|
|
677
685
|
warned.add(key);
|
|
678
686
|
console.warn(`[soma-core][\u5F15\u64CE] ${d.code} ${d.message}`);
|
|
@@ -696,18 +704,18 @@ var require_source_aliases = __commonJS({
|
|
|
696
704
|
function somaViteAliases(hostDir, env = process.env) {
|
|
697
705
|
return Object.entries(getSomaSourceRootAliases2(hostDir, env)).map(([name, dir]) => ({
|
|
698
706
|
find: new RegExp(`^${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}/`),
|
|
699
|
-
replacement: `${dir.split(
|
|
707
|
+
replacement: `${dir.split(path3.sep).join("/")}/`
|
|
700
708
|
}));
|
|
701
709
|
}
|
|
702
710
|
var HOST_BOOTSTRAP_SPECIFIER = "@soma-host/bootstrap/soma-bootstrap";
|
|
703
711
|
var HOST_BOOTSTRAP_CANDIDATES = ["soma-bootstrap.ts", "soma-bootstrap.js", "soma-bootstrap.mjs"];
|
|
704
712
|
function somaViteHostAliases(hostDir, env = process.env) {
|
|
705
|
-
const sourceRoot = getSomaHostSourceRoot2(
|
|
706
|
-
const found = HOST_BOOTSTRAP_CANDIDATES.map((name) =>
|
|
707
|
-
const target = found ??
|
|
713
|
+
const sourceRoot = getSomaHostSourceRoot2(path3.resolve(hostDir), env);
|
|
714
|
+
const found = HOST_BOOTSTRAP_CANDIDATES.map((name) => path3.join(sourceRoot, "bootstrap", name)).find((file) => fs3.existsSync(file));
|
|
715
|
+
const target = found ?? path3.join(__dirname, "empty-host-bootstrap.mjs");
|
|
708
716
|
return [
|
|
709
717
|
...somaViteAliases(hostDir, env),
|
|
710
|
-
{ find: new RegExp(`^${HOST_BOOTSTRAP_SPECIFIER}$`), replacement: target.split(
|
|
718
|
+
{ find: new RegExp(`^${HOST_BOOTSTRAP_SPECIFIER}$`), replacement: target.split(path3.sep).join("/") }
|
|
711
719
|
];
|
|
712
720
|
}
|
|
713
721
|
module2.exports = {
|
|
@@ -734,12 +742,88 @@ __export(aot_builder_exports, {
|
|
|
734
742
|
buildServerAot: () => buildServerAot
|
|
735
743
|
});
|
|
736
744
|
module.exports = __toCommonJS(aot_builder_exports);
|
|
737
|
-
var
|
|
738
|
-
var
|
|
745
|
+
var import_node_fs2 = __toESM(require("node:fs"));
|
|
746
|
+
var import_node_path2 = __toESM(require("node:path"));
|
|
739
747
|
var import_node_crypto = require("node:crypto");
|
|
740
748
|
var import_esbuild = __toESM(require("esbuild"));
|
|
741
749
|
var import_public_packages = __toESM(require_public_packages());
|
|
742
750
|
|
|
751
|
+
// host-native/src/dev-chunk-gc.ts
|
|
752
|
+
var import_node_fs = __toESM(require("node:fs"));
|
|
753
|
+
var import_node_path = __toESM(require("node:path"));
|
|
754
|
+
var LIVE_DIR = ".live";
|
|
755
|
+
var CHUNKS_DIR = "chunks";
|
|
756
|
+
function isAlive(pid) {
|
|
757
|
+
if (!Number.isInteger(pid) || pid <= 0) return false;
|
|
758
|
+
if (pid === process.pid) return true;
|
|
759
|
+
try {
|
|
760
|
+
process.kill(pid, 0);
|
|
761
|
+
return true;
|
|
762
|
+
} catch (error) {
|
|
763
|
+
return error.code === "EPERM";
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
function readLiveSet(file) {
|
|
767
|
+
try {
|
|
768
|
+
const parsed = JSON.parse(import_node_fs.default.readFileSync(file, "utf8"));
|
|
769
|
+
return Array.isArray(parsed) ? parsed.filter((v) => typeof v === "string") : [];
|
|
770
|
+
} catch {
|
|
771
|
+
return [];
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
function outputsRelativeTo(clientOutDir, outputs) {
|
|
775
|
+
const rel = [];
|
|
776
|
+
for (const out of outputs) {
|
|
777
|
+
const abs = import_node_path.default.resolve(out);
|
|
778
|
+
const r = import_node_path.default.relative(clientOutDir, abs);
|
|
779
|
+
if (r === "" || r.startsWith("..") || import_node_path.default.isAbsolute(r)) continue;
|
|
780
|
+
rel.push(r.split(import_node_path.default.sep).join("/"));
|
|
781
|
+
}
|
|
782
|
+
return rel;
|
|
783
|
+
}
|
|
784
|
+
function collectDevChunks(clientOutDir, ownOutputs) {
|
|
785
|
+
let removed = 0;
|
|
786
|
+
try {
|
|
787
|
+
const liveDir = import_node_path.default.join(clientOutDir, LIVE_DIR);
|
|
788
|
+
import_node_fs.default.mkdirSync(liveDir, { recursive: true });
|
|
789
|
+
import_node_fs.default.writeFileSync(import_node_path.default.join(liveDir, `${process.pid}.json`), JSON.stringify(ownOutputs), "utf8");
|
|
790
|
+
const keep = new Set(ownOutputs);
|
|
791
|
+
for (const name of import_node_fs.default.readdirSync(liveDir)) {
|
|
792
|
+
if (!name.endsWith(".json")) continue;
|
|
793
|
+
const pid = Number(name.slice(0, -".json".length));
|
|
794
|
+
const file = import_node_path.default.join(liveDir, name);
|
|
795
|
+
if (pid === process.pid) continue;
|
|
796
|
+
if (!isAlive(pid)) {
|
|
797
|
+
import_node_fs.default.rmSync(file, { force: true });
|
|
798
|
+
continue;
|
|
799
|
+
}
|
|
800
|
+
for (const rel of readLiveSet(file)) keep.add(rel);
|
|
801
|
+
}
|
|
802
|
+
const chunksDir = import_node_path.default.join(clientOutDir, CHUNKS_DIR);
|
|
803
|
+
if (!import_node_fs.default.existsSync(chunksDir)) return { removed };
|
|
804
|
+
for (const name of import_node_fs.default.readdirSync(chunksDir)) {
|
|
805
|
+
const rel = `${CHUNKS_DIR}/${name}`;
|
|
806
|
+
if (keep.has(rel)) continue;
|
|
807
|
+
const abs = import_node_path.default.join(chunksDir, name);
|
|
808
|
+
try {
|
|
809
|
+
if (import_node_fs.default.statSync(abs).isFile()) {
|
|
810
|
+
import_node_fs.default.rmSync(abs, { force: true });
|
|
811
|
+
removed += 1;
|
|
812
|
+
}
|
|
813
|
+
} catch {
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
} catch {
|
|
817
|
+
}
|
|
818
|
+
return { removed };
|
|
819
|
+
}
|
|
820
|
+
function releaseDevChunks(clientOutDir) {
|
|
821
|
+
try {
|
|
822
|
+
import_node_fs.default.rmSync(import_node_path.default.join(clientOutDir, LIVE_DIR, `${process.pid}.json`), { force: true });
|
|
823
|
+
} catch {
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
|
|
743
827
|
// core/server/api/service-path.ts
|
|
744
828
|
function toPascalCase(str) {
|
|
745
829
|
return str.split(/[-_]/).map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join("");
|
|
@@ -752,7 +836,7 @@ function registerSourceRootResolve(build, hostDir, env) {
|
|
|
752
836
|
const aliases = (0, import_source_aliases.getSomaSourceRootAliases)(hostDir, env);
|
|
753
837
|
const filter = (0, import_source_aliases.somaSourceRootFilter)(aliases);
|
|
754
838
|
if (!filter) return;
|
|
755
|
-
const nodeModulesSegment = `${
|
|
839
|
+
const nodeModulesSegment = `${import_node_path2.default.sep}node_modules${import_node_path2.default.sep}`;
|
|
756
840
|
build.onResolve({ filter }, (args) => {
|
|
757
841
|
if (args.importer.includes(nodeModulesSegment)) return void 0;
|
|
758
842
|
const hit = (0, import_source_aliases.matchSomaSourceRoot)(aliases, args.path);
|
|
@@ -761,26 +845,26 @@ function registerSourceRootResolve(build, hostDir, env) {
|
|
|
761
845
|
});
|
|
762
846
|
}
|
|
763
847
|
function resolveModuleFile(baseDir, subpath) {
|
|
764
|
-
const target = subpath ?
|
|
848
|
+
const target = subpath ? import_node_path2.default.resolve(baseDir, subpath) : import_node_path2.default.resolve(baseDir);
|
|
765
849
|
for (const ext of ["", ".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"]) {
|
|
766
850
|
const candidate = target + ext;
|
|
767
|
-
if (
|
|
851
|
+
if (import_node_fs2.default.existsSync(candidate) && import_node_fs2.default.statSync(candidate).isFile()) {
|
|
768
852
|
return candidate;
|
|
769
853
|
}
|
|
770
854
|
}
|
|
771
|
-
if (
|
|
855
|
+
if (import_node_fs2.default.existsSync(target) && import_node_fs2.default.statSync(target).isDirectory()) {
|
|
772
856
|
for (const index of ["index.ts", "index.tsx", "index.js", "index.mjs", "index.cjs"]) {
|
|
773
|
-
const candidate =
|
|
774
|
-
if (
|
|
857
|
+
const candidate = import_node_path2.default.join(target, index);
|
|
858
|
+
if (import_node_fs2.default.existsSync(candidate) && import_node_fs2.default.statSync(candidate).isFile()) {
|
|
775
859
|
return candidate;
|
|
776
860
|
}
|
|
777
861
|
}
|
|
778
862
|
}
|
|
779
863
|
return target;
|
|
780
864
|
}
|
|
781
|
-
var coreRoot =
|
|
782
|
-
var hostNativeRoot =
|
|
783
|
-
var repoRoot =
|
|
865
|
+
var coreRoot = import_node_path2.default.resolve(__dirname, "../..");
|
|
866
|
+
var hostNativeRoot = import_node_path2.default.join(coreRoot, "host-native");
|
|
867
|
+
var repoRoot = import_node_path2.default.resolve(coreRoot, "..");
|
|
784
868
|
function createBrowserClientPlugin(options) {
|
|
785
869
|
const { hostDir, webRoot } = options;
|
|
786
870
|
const publicAliases = (0, import_public_packages.readAllSomaPublicAliases)(hostDir, repoRoot, [webRoot, coreRoot]);
|
|
@@ -793,30 +877,30 @@ function createBrowserClientPlugin(options) {
|
|
|
793
877
|
);
|
|
794
878
|
});
|
|
795
879
|
build.onResolve({ filter: /^@soma-host\/bootstrap\/soma-bootstrap$/ }, () => {
|
|
796
|
-
const candidateHostFile =
|
|
880
|
+
const candidateHostFile = import_node_path2.default.resolve(webRoot, "bootstrap/soma-bootstrap");
|
|
797
881
|
for (const ext of [".ts", ".js", ".mjs"]) {
|
|
798
|
-
if (
|
|
882
|
+
if (import_node_fs2.default.existsSync(candidateHostFile + ext)) {
|
|
799
883
|
return { path: candidateHostFile + ext };
|
|
800
884
|
}
|
|
801
885
|
}
|
|
802
|
-
if (
|
|
803
|
-
return { path:
|
|
886
|
+
if (import_node_fs2.default.existsSync(import_node_path2.default.resolve(webRoot, "soma.app.ts"))) {
|
|
887
|
+
return { path: import_node_path2.default.resolve(coreRoot, "core/client/host-bridge/soma-bootstrap-from-app.ts") };
|
|
804
888
|
}
|
|
805
|
-
return { path:
|
|
889
|
+
return { path: import_node_path2.default.resolve(coreRoot, "core/client/host-bridge/soma-bootstrap-host.stub.ts") };
|
|
806
890
|
});
|
|
807
891
|
build.onResolve({ filter: /^@soma-host\/bootstrap\/soma-domain-loaders$/ }, () => {
|
|
808
|
-
const candidateLoader =
|
|
892
|
+
const candidateLoader = import_node_path2.default.resolve(webRoot, "bootstrap/soma-domain-loaders");
|
|
809
893
|
for (const ext of [".ts", ".js", ".mjs"]) {
|
|
810
|
-
if (
|
|
894
|
+
if (import_node_fs2.default.existsSync(candidateLoader + ext)) {
|
|
811
895
|
return { path: candidateLoader + ext };
|
|
812
896
|
}
|
|
813
897
|
}
|
|
814
|
-
return { path:
|
|
898
|
+
return { path: import_node_path2.default.resolve(coreRoot, "core/client/host-bridge/soma-domain-loaders.stub.ts") };
|
|
815
899
|
});
|
|
816
900
|
build.onResolve({ filter: /^@soma-host\/domain\/ui\/.*Class\.ts$/ }, (args) => {
|
|
817
|
-
const baseName =
|
|
818
|
-
const diskFile =
|
|
819
|
-
if (
|
|
901
|
+
const baseName = import_node_path2.default.basename(args.path);
|
|
902
|
+
const diskFile = import_node_path2.default.resolve(webRoot, "domain/ui", baseName);
|
|
903
|
+
if (import_node_fs2.default.existsSync(diskFile)) {
|
|
820
904
|
return { path: diskFile };
|
|
821
905
|
}
|
|
822
906
|
return {
|
|
@@ -836,16 +920,16 @@ function createBrowserClientPlugin(options) {
|
|
|
836
920
|
});
|
|
837
921
|
build.onResolve({ filter: /^@soma-host(?:\/.*)?$/ }, (args) => {
|
|
838
922
|
const subpath = args.path.replace(/^@soma-host\/?/, "");
|
|
839
|
-
const target =
|
|
923
|
+
const target = import_node_path2.default.resolve(webRoot, subpath);
|
|
840
924
|
for (const ext of ["", ".ts", ".tsx", ".js", ".jsx", ".mjs"]) {
|
|
841
|
-
if (
|
|
925
|
+
if (import_node_fs2.default.existsSync(target + ext) && import_node_fs2.default.statSync(target + ext).isFile()) {
|
|
842
926
|
return { path: target + ext };
|
|
843
927
|
}
|
|
844
928
|
}
|
|
845
|
-
if (
|
|
929
|
+
if (import_node_fs2.default.existsSync(target) && import_node_fs2.default.statSync(target).isDirectory()) {
|
|
846
930
|
for (const index of ["index.ts", "index.tsx", "index.js", "index.jsx"]) {
|
|
847
|
-
if (
|
|
848
|
-
return { path:
|
|
931
|
+
if (import_node_fs2.default.existsSync(import_node_path2.default.join(target, index))) {
|
|
932
|
+
return { path: import_node_path2.default.join(target, index) };
|
|
849
933
|
}
|
|
850
934
|
}
|
|
851
935
|
}
|
|
@@ -862,7 +946,7 @@ function createBrowserClientPlugin(options) {
|
|
|
862
946
|
});
|
|
863
947
|
build.onResolve({ filter: /^soma-[a-z0-9-]+(?:\/.*)?$/ }, (args) => {
|
|
864
948
|
const direct = publicAliases[args.path];
|
|
865
|
-
if (direct &&
|
|
949
|
+
if (direct && import_node_fs2.default.existsSync(direct)) {
|
|
866
950
|
return { path: direct };
|
|
867
951
|
}
|
|
868
952
|
return void 0;
|
|
@@ -917,17 +1001,17 @@ export default { SVGRenderer, use, init };
|
|
|
917
1001
|
};
|
|
918
1002
|
}
|
|
919
1003
|
async function buildBrowserClient(options) {
|
|
920
|
-
const hostDir =
|
|
921
|
-
const webRoot =
|
|
922
|
-
const outDir =
|
|
923
|
-
const clientOutDir =
|
|
924
|
-
|
|
925
|
-
const clientEntry =
|
|
1004
|
+
const hostDir = import_node_path2.default.resolve(options.hostDir);
|
|
1005
|
+
const webRoot = import_node_path2.default.resolve(options.webRoot || (0, import_source_packages.getSomaHostSourceRoot)(hostDir, options.env));
|
|
1006
|
+
const outDir = import_node_path2.default.resolve(options.outDir);
|
|
1007
|
+
const clientOutDir = import_node_path2.default.join(outDir, "client");
|
|
1008
|
+
import_node_fs2.default.mkdirSync(clientOutDir, { recursive: true });
|
|
1009
|
+
const clientEntry = import_node_path2.default.join(hostNativeRoot, "client/browser-entry.ts");
|
|
926
1010
|
const plugin = createBrowserClientPlugin({ hostDir, webRoot });
|
|
927
|
-
const cssSourcePath =
|
|
1011
|
+
const cssSourcePath = import_node_path2.default.join(hostNativeRoot, "styles/globals.css");
|
|
928
1012
|
let rawCss = "";
|
|
929
1013
|
try {
|
|
930
|
-
rawCss =
|
|
1014
|
+
rawCss = import_node_fs2.default.readFileSync(cssSourcePath, "utf8");
|
|
931
1015
|
} catch {
|
|
932
1016
|
rawCss = "/* soma globals */\n";
|
|
933
1017
|
}
|
|
@@ -944,7 +1028,7 @@ async function buildBrowserClient(options) {
|
|
|
944
1028
|
const hash = (0, import_node_crypto.createHash)("sha256").update(finalCss).digest("hex").slice(0, 8);
|
|
945
1029
|
cssFileName = `globals-${hash}.css`;
|
|
946
1030
|
}
|
|
947
|
-
|
|
1031
|
+
import_node_fs2.default.writeFileSync(import_node_path2.default.join(clientOutDir, cssFileName), finalCss, "utf8");
|
|
948
1032
|
const cssUrl = `/_soma/client/${cssFileName}`;
|
|
949
1033
|
const buildOptions = {
|
|
950
1034
|
entryPoints: {
|
|
@@ -960,7 +1044,7 @@ async function buildBrowserClient(options) {
|
|
|
960
1044
|
sourcemap: options.dev ? "inline" : false,
|
|
961
1045
|
entryNames: options.dev ? "[name]" : "[name]-[hash]",
|
|
962
1046
|
chunkNames: "chunks/[name]-[hash]",
|
|
963
|
-
nodePaths: [
|
|
1047
|
+
nodePaths: [import_node_path2.default.join(webRoot, "node_modules"), import_node_path2.default.join(hostDir, "node_modules"), import_node_path2.default.join(coreRoot, "node_modules")].filter((d) => import_node_fs2.default.existsSync(d)),
|
|
964
1048
|
plugins: [plugin],
|
|
965
1049
|
define: {
|
|
966
1050
|
"process.env.NODE_ENV": JSON.stringify(options.dev ? "development" : "production")
|
|
@@ -968,9 +1052,14 @@ async function buildBrowserClient(options) {
|
|
|
968
1052
|
};
|
|
969
1053
|
let ctx = null;
|
|
970
1054
|
let entryUrl = "/_soma/client/browser-entry.js";
|
|
1055
|
+
const devRebuild = async () => {
|
|
1056
|
+
if (!ctx) return;
|
|
1057
|
+
const result = await ctx.rebuild();
|
|
1058
|
+
if (result.metafile) collectDevChunks(clientOutDir, outputsRelativeTo(clientOutDir, Object.keys(result.metafile.outputs)));
|
|
1059
|
+
};
|
|
971
1060
|
if (options.dev) {
|
|
972
|
-
ctx = await import_esbuild.default.context(buildOptions);
|
|
973
|
-
await
|
|
1061
|
+
ctx = await import_esbuild.default.context({ ...buildOptions, metafile: true });
|
|
1062
|
+
await devRebuild();
|
|
974
1063
|
entryUrl = "/_soma/client/browser-entry.js";
|
|
975
1064
|
} else {
|
|
976
1065
|
const result = await import_esbuild.default.build({
|
|
@@ -979,8 +1068,8 @@ async function buildBrowserClient(options) {
|
|
|
979
1068
|
});
|
|
980
1069
|
if (result.metafile) {
|
|
981
1070
|
for (const [outputPath, meta] of Object.entries(result.metafile.outputs)) {
|
|
982
|
-
if (meta.entryPoint && (meta.entryPoint.endsWith("browser-entry.ts") ||
|
|
983
|
-
const fileName =
|
|
1071
|
+
if (meta.entryPoint && (meta.entryPoint.endsWith("browser-entry.ts") || import_node_path2.default.basename(outputPath).startsWith("browser-entry")) && outputPath.endsWith(".js")) {
|
|
1072
|
+
const fileName = import_node_path2.default.basename(outputPath);
|
|
984
1073
|
entryUrl = `/_soma/client/${fileName}`;
|
|
985
1074
|
break;
|
|
986
1075
|
}
|
|
@@ -988,8 +1077,8 @@ async function buildBrowserClient(options) {
|
|
|
988
1077
|
}
|
|
989
1078
|
}
|
|
990
1079
|
if (!options.dev) {
|
|
991
|
-
|
|
992
|
-
|
|
1080
|
+
import_node_fs2.default.writeFileSync(
|
|
1081
|
+
import_node_path2.default.join(clientOutDir, "client-manifest.json"),
|
|
993
1082
|
JSON.stringify({ entryUrl, cssUrl, cssText: finalCss }, null, 2) + "\n",
|
|
994
1083
|
"utf8"
|
|
995
1084
|
);
|
|
@@ -999,24 +1088,23 @@ async function buildBrowserClient(options) {
|
|
|
999
1088
|
cssUrl,
|
|
1000
1089
|
cssText: finalCss,
|
|
1001
1090
|
rebuild: async () => {
|
|
1002
|
-
|
|
1003
|
-
await ctx.rebuild();
|
|
1004
|
-
}
|
|
1091
|
+
await devRebuild();
|
|
1005
1092
|
},
|
|
1006
1093
|
dispose: async () => {
|
|
1007
1094
|
if (ctx) {
|
|
1008
1095
|
await ctx.dispose();
|
|
1096
|
+
releaseDevChunks(clientOutDir);
|
|
1009
1097
|
}
|
|
1010
1098
|
}
|
|
1011
1099
|
};
|
|
1012
1100
|
}
|
|
1013
1101
|
async function buildServerAot(options) {
|
|
1014
|
-
const hostDir =
|
|
1015
|
-
const webRoot =
|
|
1016
|
-
const apiRoot =
|
|
1017
|
-
const outDir =
|
|
1018
|
-
const aotServerDir =
|
|
1019
|
-
|
|
1102
|
+
const hostDir = import_node_path2.default.resolve(options.hostDir);
|
|
1103
|
+
const webRoot = import_node_path2.default.resolve(options.webRoot || (0, import_source_packages.getSomaHostSourceRoot)(hostDir, options.env));
|
|
1104
|
+
const apiRoot = import_node_path2.default.resolve(options.apiRoot || (0, import_source_packages.getSomaHostApiRoot)(hostDir, options.env));
|
|
1105
|
+
const outDir = import_node_path2.default.resolve(options.outDir);
|
|
1106
|
+
const aotServerDir = import_node_path2.default.join(outDir, "aot-server");
|
|
1107
|
+
import_node_fs2.default.mkdirSync(aotServerDir, { recursive: true });
|
|
1020
1108
|
const serviceFiles = scanServiceFiles(apiRoot, webRoot);
|
|
1021
1109
|
const entryPoints = {};
|
|
1022
1110
|
const routes = {};
|
|
@@ -1035,8 +1123,8 @@ async function buildServerAot(options) {
|
|
|
1035
1123
|
}
|
|
1036
1124
|
}
|
|
1037
1125
|
let hostAppCompiledPath;
|
|
1038
|
-
const hostAppPath =
|
|
1039
|
-
if (
|
|
1126
|
+
const hostAppPath = import_node_path2.default.resolve(webRoot, "soma.app.ts");
|
|
1127
|
+
if (import_node_fs2.default.existsSync(hostAppPath)) {
|
|
1040
1128
|
entryPoints["host-app"] = hostAppPath;
|
|
1041
1129
|
hostAppCompiledPath = "host-app.cjs";
|
|
1042
1130
|
}
|
|
@@ -1049,7 +1137,7 @@ async function buildServerAot(options) {
|
|
|
1049
1137
|
format: "cjs",
|
|
1050
1138
|
target: "node20",
|
|
1051
1139
|
packages: "external",
|
|
1052
|
-
nodePaths: [
|
|
1140
|
+
nodePaths: [import_node_path2.default.join(apiRoot, "node_modules"), import_node_path2.default.join(webRoot, "node_modules"), import_node_path2.default.join(hostDir, "node_modules"), import_node_path2.default.join(coreRoot, "node_modules")].filter((d) => import_node_fs2.default.existsSync(d)),
|
|
1053
1141
|
outExtension: { ".js": ".cjs" },
|
|
1054
1142
|
plugins: [
|
|
1055
1143
|
{
|
|
@@ -1057,37 +1145,37 @@ async function buildServerAot(options) {
|
|
|
1057
1145
|
setup(build) {
|
|
1058
1146
|
const publicAliases = (0, import_public_packages.readAllSomaPublicAliases)(hostDir, repoRoot, [webRoot, apiRoot, coreRoot]);
|
|
1059
1147
|
build.onResolve({ filter: /^server-only$/ }, () => {
|
|
1060
|
-
return { path:
|
|
1148
|
+
return { path: import_node_path2.default.resolve(coreRoot, "core/server/host/server-only-noop.cjs") };
|
|
1061
1149
|
});
|
|
1062
1150
|
build.onResolve({ filter: /^@core(?:\/.*)?$/ }, (args) => {
|
|
1063
1151
|
const subpath = args.path.replace(/^@core\/?/, "");
|
|
1064
|
-
return { path: resolveModuleFile(
|
|
1152
|
+
return { path: resolveModuleFile(import_node_path2.default.resolve(coreRoot, "core"), subpath) };
|
|
1065
1153
|
});
|
|
1066
1154
|
build.onResolve({ filter: /^@soma-host\/bootstrap\/soma-bootstrap$/ }, () => {
|
|
1067
|
-
const candidateHostFile =
|
|
1155
|
+
const candidateHostFile = import_node_path2.default.resolve(webRoot, "bootstrap/soma-bootstrap");
|
|
1068
1156
|
for (const ext of [".ts", ".js", ".mjs"]) {
|
|
1069
|
-
if (
|
|
1157
|
+
if (import_node_fs2.default.existsSync(candidateHostFile + ext)) {
|
|
1070
1158
|
return { path: candidateHostFile + ext };
|
|
1071
1159
|
}
|
|
1072
1160
|
}
|
|
1073
|
-
if (
|
|
1074
|
-
return { path:
|
|
1161
|
+
if (import_node_fs2.default.existsSync(import_node_path2.default.resolve(webRoot, "soma.app.ts"))) {
|
|
1162
|
+
return { path: import_node_path2.default.resolve(coreRoot, "core/client/host-bridge/soma-bootstrap-from-app.ts") };
|
|
1075
1163
|
}
|
|
1076
|
-
return { path:
|
|
1164
|
+
return { path: import_node_path2.default.resolve(coreRoot, "core/client/host-bridge/soma-bootstrap-host.stub.ts") };
|
|
1077
1165
|
});
|
|
1078
1166
|
build.onResolve({ filter: /^@soma-host\/bootstrap\/soma-domain-loaders$/ }, () => {
|
|
1079
|
-
const candidateLoader =
|
|
1167
|
+
const candidateLoader = import_node_path2.default.resolve(webRoot, "bootstrap/soma-domain-loaders");
|
|
1080
1168
|
for (const ext of [".ts", ".js", ".mjs"]) {
|
|
1081
|
-
if (
|
|
1169
|
+
if (import_node_fs2.default.existsSync(candidateLoader + ext)) {
|
|
1082
1170
|
return { path: candidateLoader + ext };
|
|
1083
1171
|
}
|
|
1084
1172
|
}
|
|
1085
|
-
return { path:
|
|
1173
|
+
return { path: import_node_path2.default.resolve(coreRoot, "core/client/host-bridge/soma-domain-loaders.stub.ts") };
|
|
1086
1174
|
});
|
|
1087
1175
|
build.onResolve({ filter: /^@soma-host\/domain\/ui\/.*Class\.ts$/ }, (args) => {
|
|
1088
|
-
const baseName =
|
|
1089
|
-
const diskFile =
|
|
1090
|
-
if (
|
|
1176
|
+
const baseName = import_node_path2.default.basename(args.path);
|
|
1177
|
+
const diskFile = import_node_path2.default.resolve(webRoot, "domain/ui", baseName);
|
|
1178
|
+
if (import_node_fs2.default.existsSync(diskFile)) {
|
|
1091
1179
|
return { path: diskFile };
|
|
1092
1180
|
}
|
|
1093
1181
|
return { path: args.path, namespace: "soma-absent-domain" };
|
|
@@ -1107,7 +1195,7 @@ async function buildServerAot(options) {
|
|
|
1107
1195
|
});
|
|
1108
1196
|
build.onResolve({ filter: /^soma-[a-z0-9-]+(?:\/.*)?$/ }, (args) => {
|
|
1109
1197
|
const direct = publicAliases[args.path];
|
|
1110
|
-
if (direct &&
|
|
1198
|
+
if (direct && import_node_fs2.default.existsSync(direct)) {
|
|
1111
1199
|
return { path: direct };
|
|
1112
1200
|
}
|
|
1113
1201
|
return void 0;
|
|
@@ -1125,29 +1213,29 @@ async function buildServerAot(options) {
|
|
|
1125
1213
|
routes,
|
|
1126
1214
|
...hostAppCompiledPath ? { hostAppCompiledPath } : {}
|
|
1127
1215
|
};
|
|
1128
|
-
const manifestPath =
|
|
1129
|
-
|
|
1216
|
+
const manifestPath = import_node_path2.default.join(aotServerDir, "aot-manifest.json");
|
|
1217
|
+
import_node_fs2.default.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2) + "\n", "utf8");
|
|
1130
1218
|
return manifest;
|
|
1131
1219
|
}
|
|
1132
1220
|
function scanServiceFiles(apiRoot, webRoot) {
|
|
1133
1221
|
const items = [];
|
|
1134
1222
|
const scannedPaths = /* @__PURE__ */ new Set();
|
|
1135
1223
|
const baseCandidates = [
|
|
1136
|
-
{ base:
|
|
1137
|
-
{ base:
|
|
1224
|
+
{ base: import_node_path2.default.join(apiRoot, "api", "service"), isDirect: false },
|
|
1225
|
+
{ base: import_node_path2.default.join(apiRoot, "service"), isDirect: false }
|
|
1138
1226
|
];
|
|
1139
1227
|
if (apiRoot !== webRoot) {
|
|
1140
1228
|
baseCandidates.push({ base: apiRoot, isDirect: true });
|
|
1141
1229
|
}
|
|
1142
1230
|
for (const { base, isDirect } of baseCandidates) {
|
|
1143
|
-
if (!
|
|
1231
|
+
if (!import_node_fs2.default.existsSync(base) || !import_node_fs2.default.statSync(base).isDirectory()) continue;
|
|
1144
1232
|
walk(base, base, isDirect);
|
|
1145
1233
|
break;
|
|
1146
1234
|
}
|
|
1147
1235
|
function walk(currentDir, baseDir, isDirect) {
|
|
1148
1236
|
let entries = [];
|
|
1149
1237
|
try {
|
|
1150
|
-
entries =
|
|
1238
|
+
entries = import_node_fs2.default.readdirSync(currentDir, { withFileTypes: true });
|
|
1151
1239
|
} catch {
|
|
1152
1240
|
return;
|
|
1153
1241
|
}
|
|
@@ -1155,7 +1243,7 @@ function scanServiceFiles(apiRoot, webRoot) {
|
|
|
1155
1243
|
const name = entry.name;
|
|
1156
1244
|
if (name.startsWith(".") || name.startsWith("_")) continue;
|
|
1157
1245
|
if (name === "node_modules" || name === "dist" || name === ".soma" || name === ".next") continue;
|
|
1158
|
-
const fullPath =
|
|
1246
|
+
const fullPath = import_node_path2.default.join(currentDir, name);
|
|
1159
1247
|
if (entry.isDirectory()) {
|
|
1160
1248
|
walk(fullPath, baseDir, isDirect);
|
|
1161
1249
|
} else if (entry.isFile()) {
|
|
@@ -1163,7 +1251,7 @@ function scanServiceFiles(apiRoot, webRoot) {
|
|
|
1163
1251
|
if (name.endsWith(".d.ts") || name.includes(".test.") || name.includes(".spec.")) continue;
|
|
1164
1252
|
if (scannedPaths.has(fullPath)) continue;
|
|
1165
1253
|
scannedPaths.add(fullPath);
|
|
1166
|
-
const rel =
|
|
1254
|
+
const rel = import_node_path2.default.relative(baseDir, fullPath).replace(/\\/g, "/");
|
|
1167
1255
|
const segments = rel.replace(/\.[^.]+$/, "").split("/");
|
|
1168
1256
|
const last = segments[segments.length - 1];
|
|
1169
1257
|
const lowerLast = last.charAt(0).toLowerCase() + last.slice(1);
|