soma-core 2.1.3 → 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/soma.cjs +6 -0
- package/bin/soma.ts +1 -0
- package/core/build/compiler/soma-precompile.js +4 -10
- package/core/server/host/host-assembly.ts +2 -2
- package/dist/cli/soma.js +1 -0
- package/host-next/bin/host-next.cjs +1 -0
- package/host-next/next.config.js +2 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -51,7 +51,7 @@ Host 文件页优先,Registry 页面在 Host 404 时兜底;存量 `/pages/<n
|
|
|
51
51
|
- `soma CLI 与 Host 工作区.md` — CLI 与 Next Host 实施方案
|
|
52
52
|
- `soma DSL 语法全书.md` — core 标准格式与 `std-grammar` 的实现级语法参考,自成一册(对外入口是 `external-docs/soma-core原生手册.md`;BDL 归 soma-ui、LCL 归 soma-lite)
|
|
53
53
|
|
|
54
|
-
全局架构见仓库 `
|
|
54
|
+
全局架构见仓库 `docs/02-系统架构/SOMA全局系统架构.md`,模块类设计见 `docs/03-类与模块/soma-core类与模块设计.md`。
|
|
55
55
|
|
|
56
56
|
## 测试
|
|
57
57
|
|
package/bin/soma.cjs
CHANGED
|
@@ -24,6 +24,9 @@ const fs = require('node:fs');
|
|
|
24
24
|
const { spawnSync } = require('node:child_process');
|
|
25
25
|
|
|
26
26
|
const command = process.argv[2];
|
|
27
|
+
if (process.env.SOMA_HOST_DIR && process.env.SOMA_HOST_DIR.trim() !== "") {
|
|
28
|
+
process.env.SOMA_HOST_DIR = path.resolve(process.env.SOMA_HOST_DIR);
|
|
29
|
+
}
|
|
27
30
|
|
|
28
31
|
/** core 自己处理(或交 dist 处理)的命令名:不进扩展命令表查找 */
|
|
29
32
|
const CORE_COMMANDS = new Set([
|
|
@@ -191,6 +194,9 @@ if (command === 'help' || command === '--help' || command === '-h') {
|
|
|
191
194
|
} else if (command !== undefined && !CORE_COMMANDS.has(command) && runExtensionCommand(command, process.argv.slice(2))) {
|
|
192
195
|
// 扩展命令已转调
|
|
193
196
|
} else {
|
|
197
|
+
if (['dev', 'build', 'start'].includes(command)) {
|
|
198
|
+
process.env.SOMA_HOST_DIR = path.resolve(process.cwd());
|
|
199
|
+
}
|
|
194
200
|
const distCli = path.resolve(__dirname, '..', 'dist', 'cli', 'soma.js');
|
|
195
201
|
|
|
196
202
|
if (fs.existsSync(distCli)) {
|
package/bin/soma.ts
CHANGED
|
@@ -153,6 +153,7 @@ if (command !== 'check') {
|
|
|
153
153
|
// core 运行时(core/**)不 import 它、不含 Next / React;这里以子进程转调它的命令行,参数、环境变量与退出码透传。
|
|
154
154
|
// Host 目录取当前目录,覆盖外部陈旧的 SOMA_HOST_DIR。
|
|
155
155
|
const hostDir = path.resolve(process.cwd());
|
|
156
|
+
process.env.SOMA_HOST_DIR = hostDir;
|
|
156
157
|
const hostNextCli = locateHostNextCli();
|
|
157
158
|
if (!hostNextCli) {
|
|
158
159
|
console.error(
|
|
@@ -4586,7 +4586,6 @@ function parseUiConfig(raw, options) {
|
|
|
4586
4586
|
}
|
|
4587
4587
|
var FRAGMENTS_ARTIFACT_KEYS = {
|
|
4588
4588
|
format: true,
|
|
4589
|
-
version: true,
|
|
4590
4589
|
regions: true,
|
|
4591
4590
|
scopes: true,
|
|
4592
4591
|
css: true,
|
|
@@ -4606,9 +4605,9 @@ function parseFragmentsSection(raw, label = SOMA_FRAGMENTS_KEY) {
|
|
|
4606
4605
|
);
|
|
4607
4606
|
}
|
|
4608
4607
|
shapeClosedKeys(entry, FRAGMENTS_ARTIFACT_KEYS, label, label);
|
|
4609
|
-
if (entry.format !== SOMA_FRAGMENTS_FORMAT
|
|
4608
|
+
if (entry.format !== SOMA_FRAGMENTS_FORMAT) {
|
|
4610
4609
|
throw new SomaUiConfigError(
|
|
4611
|
-
`${label} \u7684\u683C\u5F0F\u6807\u8BC6\u4E0D\u8BA4\u8BC6\uFF08format \u987B\u4E3A ${SOMA_FRAGMENTS_FORMAT}\
|
|
4610
|
+
`${label} \u7684\u683C\u5F0F\u6807\u8BC6\u4E0D\u8BA4\u8BC6\uFF08format \u987B\u4E3A ${SOMA_FRAGMENTS_FORMAT}\uFF09\uFF0C\u6536\u5230 format=${JSON.stringify(entry.format)}\u2014\u2014\u683C\u5F0F\u5BF9\u4E0D\u4E0A\u7684\u4EA7\u7269\u6574\u4EFD\u4E0D\u53EF\u4FE1\uFF0C\u6309\u65E7\u5B57\u6BB5\u540D\u8BFB\u51FA\u6765\u7684\u754C\u9762\u662F\u8C01\u90FD\u6CA1\u8BBE\u8BA1\u8FC7\u7684\u6837\u5B50`,
|
|
4612
4611
|
`${label}.format`
|
|
4613
4612
|
);
|
|
4614
4613
|
}
|
|
@@ -4621,10 +4620,9 @@ function parseFragmentsSection(raw, label = SOMA_FRAGMENTS_KEY) {
|
|
|
4621
4620
|
}
|
|
4622
4621
|
}
|
|
4623
4622
|
const artifact = {
|
|
4623
|
+
format: SOMA_FRAGMENTS_FORMAT,
|
|
4624
4624
|
regions: entry.regions
|
|
4625
4625
|
};
|
|
4626
|
-
if (entry.format === SOMA_FRAGMENTS_FORMAT) artifact.format = SOMA_FRAGMENTS_FORMAT;
|
|
4627
|
-
if (entry.version === 1) artifact.version = 1;
|
|
4628
4626
|
if (entry.degradedRegions !== void 0) {
|
|
4629
4627
|
if (!Array.isArray(entry.degradedRegions)) {
|
|
4630
4628
|
throw new SomaUiConfigError(`${label}.degradedRegions \u5FC5\u987B\u662F\u6570\u7EC4`, `${label}.degradedRegions`);
|
|
@@ -8799,17 +8797,13 @@ var SOMA_CORE_DIAGNOSTIC_CODES = [
|
|
|
8799
8797
|
// runtime 空间根与存储(RT1)
|
|
8800
8798
|
"CORE-RUNTIME-ROOT-INVALID",
|
|
8801
8799
|
// runtime 根越界(宿主根 / html / ui / public 内、宿主祖先、文件系统根),拒绝启动
|
|
8802
|
-
"CORE-RUNTIME-LEGACY-DIR",
|
|
8803
|
-
// Registry 数据仍在旧目录,正在只读回退;提示运行 soma runtime migrate
|
|
8804
8800
|
"CORE-RUNTIME-ROOT-UNSET",
|
|
8805
8801
|
// 生产环境未设 SOMA_RUNTIME_DIR(soma doctor 告警)
|
|
8806
8802
|
// 地址绑定与注入(RT2 / E2;《core 标准格式与 runtime 空间》§2、§4;《页面级描述与按 URL 注册》§4)
|
|
8807
8803
|
"CORE-FORMAT-VERSION-UNSUPPORTED",
|
|
8808
8804
|
// 注入载荷 format 不是 core 认识的主版本
|
|
8809
8805
|
"CORE-FORMAT-VERSION-MISMATCH",
|
|
8810
|
-
// 载荷 format 与 page 块 soma:
|
|
8811
|
-
"CORE-FORMAT-VERSION-IMPLICIT",
|
|
8812
|
-
// page 块未写 soma:,兼容期按 1 处理(advice)
|
|
8806
|
+
// 载荷 format 与 page 块 soma: 不一致(page 块缺 soma: 同此码)
|
|
8813
8807
|
"CORE-INJECT-NONSTANDARD-KEY",
|
|
8814
8808
|
// 兼容期结束后含方言段拒收
|
|
8815
8809
|
"CORE-RUNTIME-ADDRESS-INVALID",
|
|
@@ -24,7 +24,7 @@ export function createNodeRequire(anchorDir?: string): NodeRequire {
|
|
|
24
24
|
const createReq = (nodeModule as unknown as Record<string, (id: string) => NodeRequire>)[CREATE_REQUIRE_KEY];
|
|
25
25
|
const anchor = anchorDir
|
|
26
26
|
? path.resolve(anchorDir, 'package.json')
|
|
27
|
-
: typeof import.meta
|
|
27
|
+
: typeof import.meta.url === 'string' && import.meta.url.startsWith('file:')
|
|
28
28
|
? import.meta.url
|
|
29
29
|
: path.resolve(process.cwd(), 'package.json');
|
|
30
30
|
return createReq(anchor);
|
|
@@ -213,7 +213,7 @@ export function loadHostAssemblySync(appRoot: string): SomaHostAssembly | null {
|
|
|
213
213
|
*/
|
|
214
214
|
function resolveSelfCoreDir(): string {
|
|
215
215
|
try {
|
|
216
|
-
if (typeof import.meta
|
|
216
|
+
if (typeof import.meta.url === 'string' && import.meta.url.startsWith('file:')) {
|
|
217
217
|
const candidate = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../');
|
|
218
218
|
if (fs.existsSync(candidate)) return candidate;
|
|
219
219
|
}
|
package/dist/cli/soma.js
CHANGED
|
@@ -142,6 +142,7 @@ if (command !== 'check') {
|
|
|
142
142
|
// core 运行时(core/**)不 import 它、不含 Next / React;这里以子进程转调它的命令行,参数、环境变量与退出码透传。
|
|
143
143
|
// Host 目录取当前目录,覆盖外部陈旧的 SOMA_HOST_DIR。
|
|
144
144
|
const hostDir = node_path_1.default.resolve(process.cwd());
|
|
145
|
+
process.env.SOMA_HOST_DIR = hostDir;
|
|
145
146
|
const hostNextCli = locateHostNextCli();
|
|
146
147
|
if (!hostNextCli) {
|
|
147
148
|
console.error(`[soma ${command}] 找不到 Next 宿主壳入口 host-next/bin/host-next.cjs:soma-core 包不完整,请重新安装。`);
|
|
@@ -30,6 +30,7 @@ if (!nextBin) {
|
|
|
30
30
|
const hostDir = path.resolve(process.env.SOMA_HOST_DIR && process.env.SOMA_HOST_DIR.trim() !== ''
|
|
31
31
|
? process.env.SOMA_HOST_DIR
|
|
32
32
|
: process.cwd());
|
|
33
|
+
process.env.SOMA_HOST_DIR = hostDir;
|
|
33
34
|
let nextWorkspace;
|
|
34
35
|
try {
|
|
35
36
|
nextWorkspace = ensureNextWorkspace(hostDir);
|
package/host-next/next.config.js
CHANGED
|
@@ -31,6 +31,7 @@ if (!rawHostDir || !String(rawHostDir).trim()) {
|
|
|
31
31
|
);
|
|
32
32
|
}
|
|
33
33
|
const hostDir = path.resolve(rawHostDir);
|
|
34
|
+
process.env.SOMA_HOST_DIR = hostDir;
|
|
34
35
|
const webpackCacheMode = readSomaWebpackCacheMode();
|
|
35
36
|
|
|
36
37
|
// 壳自有路由(app/ 枚举):经环境变量交给页面入口并入装配的 reservedRoutes(app/soma/_shared/host-prepare.ts)。
|
|
@@ -278,6 +279,7 @@ const allowedDevOrigins = [
|
|
|
278
279
|
const nextConfig = {
|
|
279
280
|
env: {
|
|
280
281
|
SOMA_SHELL_ROUTES: process.env.SOMA_SHELL_ROUTES,
|
|
282
|
+
SOMA_HOST_DIR: hostDir,
|
|
281
283
|
},
|
|
282
284
|
|
|
283
285
|
allowedDevOrigins,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "soma-core",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.4",
|
|
4
4
|
"description": "SOMA — Semantic Oriented Modular Architecture. A declarative frontend framework runtime with no UI framework dependency; the Next.js host shell ships in host-next/ (code-isolated from core/, next/react are optional peer dependencies).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"soma",
|
|
@@ -322,7 +322,7 @@
|
|
|
322
322
|
"parse5": "7.3.0",
|
|
323
323
|
"qrcode-generator": "2.0.4",
|
|
324
324
|
"server-only": "0.0.1",
|
|
325
|
-
"soma-foundation": "^0.1.
|
|
325
|
+
"soma-foundation": "^0.1.1",
|
|
326
326
|
"temporal-polyfill": "0.3.2"
|
|
327
327
|
},
|
|
328
328
|
"peerDependencies": {
|