soma-core 2.2.5 → 2.2.6
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 +5 -6
- package/bin/soma.cjs +2 -2
- package/core/build/compiler/flat-page.ts +16 -0
- package/core/build/compiler/full-manifest-builder.ts +0 -3
- package/core/build/compiler/page-assets.ts +0 -1
- package/core/build/compiler/page-closure.ts +245 -0
- package/core/build/compiler/page-declaration-compiler.ts +2 -5
- package/core/build/compiler/soma-precompile.js +1848 -3244
- package/core/build/compiler/soma-precompile.ts +4 -7
- package/core/build/component-tree/artifact-codec.ts +4 -8
- package/core/build/lsp/soma-declaration.cjs +1 -1
- package/core/build/lsp/std-completion.generated.json +3 -3
- package/core/client/a11y/a11y-config.ts +2 -1
- package/core/client/a11y/dom-id.ts +1 -1
- package/core/client/base/SomaHttpClient.ts +11 -3
- package/core/client/base/SomaPageRootBase.ts +6 -0
- package/core/client/base/defineSomaView.ts +178 -0
- package/core/client/base/index.ts +13 -0
- package/core/client/base/view-context.ts +328 -0
- package/core/client/behavior/adapter-collection.ts +2 -2
- package/core/client/compiler/manifest-compiler.ts +5 -36
- package/core/client/component/component-definition.types.ts +2 -1
- package/core/client/component/component-manager.ts +110 -20
- package/core/client/component/structure-adapter.ts +3 -7
- package/core/client/container/SomaContainerAdapter.ts +9 -1
- package/core/client/data/data-object-resolver.ts +516 -181
- package/core/client/data/data-write-actions.ts +79 -15
- package/core/client/data/format-config.ts +3 -1
- package/core/client/data/region-scope-port.ts +11 -0
- package/core/client/engine/asset-resolver.ts +2 -5
- package/core/client/engine/dom-renderer.ts +7 -40
- package/core/client/engine/event-engine.ts +1 -105
- package/core/client/engine/property-watcher.ts +1 -1
- package/core/client/engine/reactive-proxy.ts +78 -17
- package/core/client/engine/runtime-builder.ts +0 -14
- package/core/client/engine/scope-resolver.ts +18 -0
- package/core/client/engine/soma-bootstrap.ts +385 -98
- package/core/client/engine/style-binder.ts +49 -106
- package/core/client/engine/timer-engine.ts +11 -1
- package/core/client/host-bridge/load-host-domain-class.ts +2 -1
- package/core/client/infra/http/SomaHttpService.ts +15 -4
- package/core/client/infra/i18n/pack-locales.ts +2 -2
- package/core/client/mount/domain-rule.ts +7 -3
- package/core/client/mount/mount-page.ts +38 -5
- package/core/client/mount/types.ts +2 -0
- package/core/client/parser/confirm-spec.ts +1 -1
- package/core/client/parser/data-config-parser.ts +27 -210
- package/core/client/parser/pipeline-parser.ts +14 -59
- package/core/client/parser/style-config-parser.ts +101 -95
- package/core/client/parser/timer-parser.ts +21 -0
- package/core/client/parser/ui-config-parser.ts +64 -12
- package/core/client/registry/declaration-renderer.ts +1 -1
- package/core/client/runtime/SomaRuntimeServices.ts +2 -1
- package/core/client/runtime/SomaSnapshotStore.ts +5 -0
- package/core/client/security/url-guard.ts +71 -11
- package/core/client/validation/async-check-registry.ts +2 -1
- package/core/client/validation/contract-validator.ts +2 -6
- package/core/client/validation/field-rules.ts +3 -13
- package/core/client/validation/object-rules.ts +2 -10
- package/core/index.ts +1 -35
- package/core/inspect/check-product.ts +5 -5
- package/core/inspect/runtime.ts +2 -1
- package/core/server/api/dispatch-service-api.ts +35 -36
- package/core/server/api/load-host-service.ts +5 -4
- package/core/server/compile-port.ts +1 -1
- package/core/server/host/app-config-composer.ts +2 -1
- package/core/server/host/host-assembly-entry.ts +1 -0
- package/core/server/host/host-assembly.ts +47 -3
- package/core/server/host/host-caller.ts +2 -1
- package/core/server/host/host-dir.ts +9 -0
- package/core/server/host/host-response-headers.ts +2 -1
- package/core/server/host/invoke-host-request-hook.ts +28 -4
- package/core/server/host/published-page-assets.ts +2 -1
- package/core/server/host/resolve-host-request-hook.ts +25 -7
- package/core/server/host/server-page-assets.ts +4 -4
- package/core/server/host/virtual-pages.ts +3 -2
- package/core/server/infra/cache/ServerFileCache.ts +79 -9
- package/core/server/registry/api-registry-store.ts +3 -1
- package/core/server/registry/declaration-precompiler.ts +0 -2
- package/core/server/registry/page-registry-repository.ts +2 -1
- package/core/server/registry/page-registry-store.ts +2 -1
- package/core/server/registry/registry-error.ts +6 -1
- package/core/server/registry/registry-file-lock.ts +296 -23
- package/core/server/registry/request-body-limit.ts +3 -2
- package/core/server/registry/validation/declaration-safety-scan.ts +151 -27
- package/core/server/runtime-space/access-gate.ts +21 -7
- package/core/server/runtime-space/bindings.ts +3 -6
- package/core/server/runtime-space/dynamic-pages.ts +181 -49
- package/core/server/runtime-space/errors.ts +3 -0
- package/core/server/runtime-space/inject.ts +74 -15
- package/core/server/runtime-space/page-grants.ts +7 -1
- package/core/server/runtime-space/resolve.ts +66 -19
- package/core/server/runtime-space/store.ts +32 -3
- package/core/server/runtime-space/submit-steps.ts +2 -1
- package/core/server/runtime-space/types.ts +3 -1
- package/core/shared/component-tree-errors.ts +2 -1
- package/core/shared/contract-a11y.ts +1 -1
- package/core/shared/contract-sections.ts +2 -2
- package/core/shared/core-diagnostic-codes.ts +8 -0
- package/core/shared/declaration-keys.ts +1 -1
- package/core/shared/engines/engine-error.ts +2 -1
- package/core/shared/generation-error.ts +2 -1
- package/core/shared/page-envelope.ts +1 -1
- package/core/shared/pure-binding.ts +88 -0
- package/core/shared/registry-generated/diagnostic-registry-index.ts +16 -19
- package/core/shared/registry-generated/diagnostic-registry.ts +135 -177
- package/core/shared/registry-generated/limits.ts +49 -13
- package/core/shared/registry-generated/std-grammar-completion.ts +0 -4
- package/core/shared/registry-generated/std-grammar-views.ts +40 -10
- package/core/shared/registry-generated/std-grammar.ts +42 -20
- package/core/shared/soma-error.ts +36 -0
- package/core/shared/types/compile-port.types.ts +1 -1
- package/core/shared/types/data-config.types.ts +17 -17
- package/core/shared/types/engine.types.ts +0 -3
- package/core/shared/types/event.types.ts +1 -11
- package/core/shared/types/generation-error.types.ts +5 -1
- package/core/shared/types/host-assembly.types.ts +7 -1
- package/core/shared/types/manifest.types.ts +0 -3
- package/core/shared/types/region-scope.types.ts +5 -1
- package/core/shared/types/scope-manifest.types.ts +0 -2
- package/core/shared/types/style-config.types.ts +21 -21
- package/core/shared/types/ui-config.types.ts +4 -5
- package/core/shared/types/watcher.types.ts +1 -1
- package/dist/browser/runtime-bundle.manifest.json +11 -13
- package/dist/browser/soma-runtime.js +2567 -2696
- package/dist/core/index.cjs +5446 -5486
- package/dist/host-native/aot-builder.cjs +46 -1
- package/dist/host-native/native-server.cjs +4879 -4505
- package/dist/lsp/component-tree.cjs +5814 -7042
- package/dist/types/build/compiler/full-manifest-builder.d.ts +0 -2
- package/dist/types/build/compiler/page-closure.d.ts +21 -0
- package/dist/types/build/compiler/page-declaration-compiler.d.ts +2 -4
- package/dist/types/build/compiler/soma-precompile.d.ts +1 -3
- package/dist/types/build/component-tree/artifact-codec.d.ts +0 -2
- package/dist/types/client/a11y/a11y-config.d.ts +2 -1
- package/dist/types/client/base/SomaHttpClient.d.ts +1 -1
- package/dist/types/client/base/SomaPageRootBase.d.ts +5 -0
- package/dist/types/client/base/defineSomaView.d.ts +46 -0
- package/dist/types/client/base/index.d.ts +2 -0
- package/dist/types/client/base/view-context.d.ts +136 -0
- package/dist/types/client/behavior/adapter-collection.d.ts +1 -1
- package/dist/types/client/compiler/manifest-compiler.d.ts +0 -3
- package/dist/types/client/component/component-definition.types.d.ts +2 -1
- package/dist/types/client/component/component-manager.d.ts +29 -0
- package/dist/types/client/data/data-object-resolver.d.ts +91 -31
- package/dist/types/client/data/format-config.d.ts +2 -1
- package/dist/types/client/engine/dom-renderer.d.ts +1 -2
- package/dist/types/client/engine/event-engine.d.ts +0 -7
- package/dist/types/client/engine/reactive-proxy.d.ts +11 -4
- package/dist/types/client/engine/runtime-builder.d.ts +0 -4
- package/dist/types/client/engine/soma-bootstrap.d.ts +44 -6
- package/dist/types/client/engine/style-binder.d.ts +8 -4
- package/dist/types/client/host-bridge/load-host-domain-class.d.ts +2 -1
- package/dist/types/client/mount/domain-rule.d.ts +2 -0
- package/dist/types/client/mount/mount-page.d.ts +2 -1
- package/dist/types/client/mount/types.d.ts +2 -0
- package/dist/types/client/parser/data-config-parser.d.ts +6 -5
- package/dist/types/client/parser/style-config-parser.d.ts +7 -3
- package/dist/types/client/parser/timer-parser.d.ts +5 -0
- package/dist/types/client/parser/ui-config-parser.d.ts +6 -2
- package/dist/types/client/runtime/SomaSnapshotStore.d.ts +2 -0
- package/dist/types/client/security/url-guard.d.ts +14 -0
- package/dist/types/client/validation/async-check-registry.d.ts +2 -1
- package/dist/types/client/validation/object-rules.d.ts +0 -5
- package/dist/types/index.d.ts +2 -7
- package/dist/types/inspect/runtime.d.ts +2 -1
- package/dist/types/server/api/dispatch-service-api.d.ts +5 -0
- package/dist/types/server/api/load-host-service.d.ts +1 -1
- package/dist/types/server/compile-port.d.ts +1 -1
- package/dist/types/server/host/host-assembly-entry.d.ts +1 -1
- package/dist/types/server/host/host-assembly.d.ts +2 -0
- package/dist/types/server/host/host-dir.d.ts +2 -0
- package/dist/types/server/host/invoke-host-request-hook.d.ts +10 -3
- package/dist/types/server/host/published-page-assets.d.ts +2 -1
- package/dist/types/server/host/resolve-host-request-hook.d.ts +18 -5
- package/dist/types/server/host/server-page-assets.d.ts +2 -1
- package/dist/types/server/infra/cache/ServerFileCache.d.ts +8 -0
- package/dist/types/server/registry/declaration-precompiler.d.ts +0 -1
- package/dist/types/server/registry/registry-error.d.ts +5 -1
- package/dist/types/server/registry/registry-file-lock.d.ts +30 -0
- package/dist/types/server/registry/request-body-limit.d.ts +3 -2
- package/dist/types/server/registry/validation/declaration-safety-scan.d.ts +3 -0
- package/dist/types/server/runtime-space/access-gate.d.ts +7 -0
- package/dist/types/server/runtime-space/bindings.d.ts +3 -2
- package/dist/types/server/runtime-space/dynamic-pages.d.ts +6 -1
- package/dist/types/server/runtime-space/errors.d.ts +1 -1
- package/dist/types/server/runtime-space/resolve.d.ts +2 -0
- package/dist/types/server/runtime-space/store.d.ts +8 -1
- package/dist/types/server/runtime-space/submit-steps.d.ts +2 -1
- package/dist/types/server/runtime-space/types.d.ts +3 -1
- package/dist/types/shared/component-tree-errors.d.ts +2 -1
- package/dist/types/shared/core-diagnostic-codes.d.ts +1 -1
- package/dist/types/shared/declaration-keys.d.ts +1 -1
- package/dist/types/shared/engines/engine-error.d.ts +2 -1
- package/dist/types/shared/generation-error.d.ts +2 -1
- package/dist/types/shared/pure-binding.d.ts +48 -0
- package/dist/types/shared/registry-generated/diagnostic-registry.d.ts +119 -158
- package/dist/types/shared/registry-generated/limits.d.ts +40 -10
- package/dist/types/shared/registry-generated/std-grammar-completion.d.ts +0 -30
- package/dist/types/shared/registry-generated/std-grammar-views.d.ts +97 -23
- package/dist/types/shared/registry-generated/std-grammar.d.ts +109 -241
- package/dist/types/shared/soma-error.d.ts +15 -0
- package/dist/types/shared/types/data-config.types.d.ts +14 -16
- package/dist/types/shared/types/engine.types.d.ts +0 -3
- package/dist/types/shared/types/event.types.d.ts +1 -7
- package/dist/types/shared/types/generation-error.types.d.ts +1 -1
- package/dist/types/shared/types/host-assembly.types.d.ts +2 -0
- package/dist/types/shared/types/manifest.types.d.ts +0 -3
- package/dist/types/shared/types/region-scope.types.d.ts +4 -1
- package/dist/types/shared/types/scope-manifest.types.d.ts +0 -2
- package/dist/types/shared/types/style-config.types.d.ts +17 -19
- package/dist/types/shared/types/ui-config.types.d.ts +4 -5
- package/host-native/bin/host-native.cjs +22 -1
- package/host-native/client/browser-entry.ts +21 -172
- package/host-native/src/aot-builder.ts +52 -0
- package/host-native/src/host-prepare.ts +39 -5
- package/host-native/src/manifest-http.ts +2 -3
- package/host-native/src/native-server.ts +812 -174
- package/host-native/src/page-http.ts +3 -3
- package/host-native/src/public-packages.cjs +0 -1
- package/host-native/src/registry-handler.ts +12 -5
- package/host-native/src/static-file.ts +203 -53
- package/package.json +3 -2
- package/core/client/engine/step-runner.ts +0 -212
- package/core/client/engine/trigger-engine.ts +0 -55
- package/core/client/format/zoned.ts +0 -10
- package/core/client/parser/step-parser.ts +0 -359
- package/core/client/parser/trigger-parser.ts +0 -90
- package/core/client/parser/value-lang.ts +0 -340
- package/core/client/time/instant.ts +0 -2
- package/core/shared/calc/coerce.ts +0 -2
- package/core/shared/calc/errors.ts +0 -40
- package/core/shared/calc/evaluator.ts +0 -113
- package/core/shared/calc/index.ts +0 -11
- package/core/shared/calc/lexer.ts +0 -189
- package/core/shared/calc/parser.ts +0 -193
- package/core/shared/calc/typer.ts +0 -171
- package/core/shared/date-parts.ts +0 -2
- package/core/shared/show-when.ts +0 -77
- package/core/shared/types/step.types.ts +0 -91
- package/core/shared/types/trigger.types.ts +0 -14
- package/dist/types/client/engine/step-runner.d.ts +0 -42
- package/dist/types/client/engine/trigger-engine.d.ts +0 -16
- package/dist/types/client/format/zoned.d.ts +0 -1
- package/dist/types/client/parser/step-parser.d.ts +0 -23
- package/dist/types/client/parser/trigger-parser.d.ts +0 -13
- package/dist/types/client/parser/value-lang.d.ts +0 -63
- package/dist/types/client/time/instant.d.ts +0 -1
- package/dist/types/shared/calc/coerce.d.ts +0 -1
- package/dist/types/shared/calc/errors.d.ts +0 -14
- package/dist/types/shared/calc/evaluator.d.ts +0 -2
- package/dist/types/shared/calc/index.d.ts +0 -6
- package/dist/types/shared/calc/lexer.d.ts +0 -19
- package/dist/types/shared/calc/parser.d.ts +0 -43
- package/dist/types/shared/calc/typer.d.ts +0 -11
- package/dist/types/shared/date-parts.d.ts +0 -1
- package/dist/types/shared/show-when.d.ts +0 -21
- package/dist/types/shared/types/step.types.d.ts +0 -76
- package/dist/types/shared/types/trigger.types.d.ts +0 -12
|
@@ -49,6 +49,7 @@ import {
|
|
|
49
49
|
hasNavProvider,
|
|
50
50
|
currentHostDir,
|
|
51
51
|
ensureLoaded,
|
|
52
|
+
findEntry,
|
|
52
53
|
isExpiredAddress,
|
|
53
54
|
matchEntries,
|
|
54
55
|
runtimeStore,
|
|
@@ -86,6 +87,7 @@ export type SomaLoadedPage = SomaRuntimePageResult & {
|
|
|
86
87
|
};
|
|
87
88
|
|
|
88
89
|
const fileCache = ServerFileCache.getInstance();
|
|
90
|
+
const HTTP_NOT_FOUND = 404;
|
|
89
91
|
|
|
90
92
|
// ── 只查表 ────────────────────────────────────────────────────────────────────
|
|
91
93
|
|
|
@@ -275,12 +277,10 @@ function compileStandardPage(
|
|
|
275
277
|
return { assets, degraded: compiled.degradedRegions.length > 0 };
|
|
276
278
|
}
|
|
277
279
|
|
|
278
|
-
/** 编译结果键 = 摘要 + 页面形态 + core 编译版本 + 编译身份(组件供货 / 设计规则 /
|
|
279
|
-
function compileKey(digest: string): string | null {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
if (identity === null || identity === '') return null;
|
|
283
|
-
return createHash('sha256').update(`${digest}|${DECLARATION_COMPILER_VERSION}|${identity}`).digest('hex');
|
|
280
|
+
/** 编译结果键 = 摘要 + 页面形态 + core 编译版本 + 编译身份(组件供货 / 设计规则 / 主题指纹)+ 绑定地址(产物带 URL 相关标识,同内容异址不得互相命中);读不到身份就不缓存 */
|
|
281
|
+
export function compileKey(digest: string, binding?: SomaRuntimeBinding): string | null {
|
|
282
|
+
const identity = `${binding?.owner ?? 'native'}:${binding?.version ?? digest}`;
|
|
283
|
+
return createHash('sha256').update(`${digest}|${DECLARATION_COMPILER_VERSION}|${identity}|${binding?.address ?? ''}`).digest('hex');
|
|
284
284
|
}
|
|
285
285
|
|
|
286
286
|
function servePage(
|
|
@@ -290,7 +290,7 @@ function servePage(
|
|
|
290
290
|
hostDir: string | undefined,
|
|
291
291
|
): SomaServerPageAssets {
|
|
292
292
|
const store = runtimeStore();
|
|
293
|
-
const key = binding.cache === 'store' ? compileKey(digest) : null;
|
|
293
|
+
const key = binding.cache === 'store' ? compileKey(digest, binding) : null;
|
|
294
294
|
if (key !== null) {
|
|
295
295
|
const hot = store.compiled.get(key) as SomaServerPageAssets | undefined;
|
|
296
296
|
if (hot !== undefined) return hot;
|
|
@@ -314,7 +314,7 @@ function withCurrentPage(view: SomaNavView, address: string, envelope: SomaStand
|
|
|
314
314
|
return { ...view, current: { address, ...(listed ? { parent: parent as string } : {}) } };
|
|
315
315
|
}
|
|
316
316
|
|
|
317
|
-
/**
|
|
317
|
+
/** 一次取页共用的访问上下文:策略惰性读一次(成功与失败都记忆;只有真正裁决 / 过滤时才读)、身份至多解析一次 */
|
|
318
318
|
interface AccessContext {
|
|
319
319
|
readonly policy: SomaAccessPolicy;
|
|
320
320
|
readonly identity: SomaIdentityResolver;
|
|
@@ -339,7 +339,14 @@ async function finish(
|
|
|
339
339
|
const query = restoreQuery(envelope, context.search);
|
|
340
340
|
const title = assets.title ?? binding.title;
|
|
341
341
|
// 目录按身份裁剪;只有目录里确有带访问规则的项(或有人替换了目录提供者)才解析身份,其余页面不碰 Host 身份
|
|
342
|
-
|
|
342
|
+
// 策略读取失败(装配损坏)时静态页仍要可达,但导航项是否受访问规则保护无从判定:安全降级为空导航,不暴露任何项
|
|
343
|
+
let policy: SomaAccessPolicy | null = null;
|
|
344
|
+
try {
|
|
345
|
+
policy = context.access.policy;
|
|
346
|
+
} catch {
|
|
347
|
+
policy = null;
|
|
348
|
+
}
|
|
349
|
+
const identity = policy !== null && (navNeedsIdentity(allEntries(), policy) || hasNavProvider())
|
|
343
350
|
? await context.access.identity()
|
|
344
351
|
: SOMA_ANONYMOUS_ACCESS_IDENTITY;
|
|
345
352
|
const queryContract = queryContractOf(envelope);
|
|
@@ -353,17 +360,25 @@ async function finish(
|
|
|
353
360
|
query,
|
|
354
361
|
...(queryContract !== undefined ? { queryContract } : {}),
|
|
355
362
|
nav: withCurrentPage(
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
363
|
+
policy === null
|
|
364
|
+
? { generation: 0, entries: [] }
|
|
365
|
+
: buildNavView({
|
|
366
|
+
identity,
|
|
367
|
+
policy,
|
|
368
|
+
...(context.request !== undefined ? { request: context.request } : {}),
|
|
369
|
+
}),
|
|
361
370
|
binding.address,
|
|
362
371
|
envelope,
|
|
363
372
|
),
|
|
364
373
|
};
|
|
365
374
|
}
|
|
366
375
|
|
|
376
|
+
/**
|
|
377
|
+
* 访问门等待期间表项代次变化后「再过门」的次数上限。结构性常量(两次再过门),不是可调阈值:
|
|
378
|
+
* 设计真源 limits 里的重试值(CAS / 归档 / 发布回合)语义不符,故不复用;超过即按未找到处理。
|
|
379
|
+
*/
|
|
380
|
+
const ACCESS_REGATE_LIMIT = 2;
|
|
381
|
+
|
|
367
382
|
function isNotFound(error: unknown): boolean {
|
|
368
383
|
return error instanceof SomaPageAssetError && error.code === 'SOMA_PAGE_NOT_FOUND';
|
|
369
384
|
}
|
|
@@ -441,7 +456,21 @@ export async function loadPageByAddress(
|
|
|
441
456
|
const hostDir = options.hostDir ?? currentHostDir();
|
|
442
457
|
const requestPath = normalizeRequestPath(urlPath);
|
|
443
458
|
const search = searchOf(urlPath, request, requestPath);
|
|
444
|
-
|
|
459
|
+
let policyMemo: { readonly value: SomaAccessPolicy } | { readonly error: unknown } | null = null;
|
|
460
|
+
const access: AccessContext = {
|
|
461
|
+
get policy(): SomaAccessPolicy {
|
|
462
|
+
policyMemo ??= (() => {
|
|
463
|
+
try {
|
|
464
|
+
return { value: readAccessPolicy(hostDir) };
|
|
465
|
+
} catch (error) {
|
|
466
|
+
return { error };
|
|
467
|
+
}
|
|
468
|
+
})();
|
|
469
|
+
if ('error' in policyMemo) throw policyMemo.error;
|
|
470
|
+
return policyMemo.value;
|
|
471
|
+
},
|
|
472
|
+
identity: createIdentityResolver(hostDir, request),
|
|
473
|
+
};
|
|
445
474
|
const common = { search, access, ...(request !== undefined ? { request } : {}) };
|
|
446
475
|
ensureLoaded();
|
|
447
476
|
if (hostDir !== undefined) ensureVirtualPagesOnce(hostDir);
|
|
@@ -459,7 +488,7 @@ export async function loadPageByAddress(
|
|
|
459
488
|
|
|
460
489
|
// 1. 精确 / 模式
|
|
461
490
|
for (const hit of hits) {
|
|
462
|
-
|
|
491
|
+
let { entry } = hit;
|
|
463
492
|
if (entry.binding.kind === 'prefix') continue;
|
|
464
493
|
if (entry.binding.origin === 'registry' && entry.registryName !== null) {
|
|
465
494
|
const served = await serveRegistry(entry.registryName, common, entry);
|
|
@@ -469,9 +498,26 @@ export async function loadPageByAddress(
|
|
|
469
498
|
if (entry.page !== null && entry.binding.digest !== null) {
|
|
470
499
|
// 先过访问门(未授权的人不该靠 404 / 非 404 的差别探到参数契约),再校验参数、再编译
|
|
471
500
|
await gateAccess(entry.binding, entry.envelope, access.policy, access.identity, requestPath);
|
|
501
|
+
// 门是异步的:等待期间该地址可能被撤下 / 覆盖。重读当前绑定——没了按未找到;
|
|
502
|
+
// 代次变了就用新表项重过门,循环到「过门前后代次一致」为止(保证服务的表项其当前规则被裁决过)
|
|
503
|
+
let settled = false;
|
|
504
|
+
let vanished = false;
|
|
505
|
+
for (let regate = 0; regate <= ACCESS_REGATE_LIMIT; regate += 1) {
|
|
506
|
+
const latest = findEntry(entry.binding.address);
|
|
507
|
+
if (latest === undefined || latest.page === null || latest.binding.digest === null) { vanished = true; break; }
|
|
508
|
+
if (latest.binding.generation === entry.binding.generation) { settled = true; break; }
|
|
509
|
+
entry = latest;
|
|
510
|
+
if (regate === ACCESS_REGATE_LIMIT) break;
|
|
511
|
+
await gateAccess(entry.binding, entry.envelope, access.policy, access.identity, requestPath);
|
|
512
|
+
}
|
|
513
|
+
if (vanished) continue;
|
|
514
|
+
// 反复被覆盖、始终没稳定:不服务任何内容,口径与未找到一致(不泄露页面存在性)
|
|
515
|
+
if (!settled) throw new SomaPageAssetError('SOMA_PAGE_NOT_FOUND', HTTP_NOT_FOUND, `Page not found: ${urlPath}`);
|
|
516
|
+
const page = entry.page as SomaStandardPage;
|
|
517
|
+
const digest = entry.binding.digest as string;
|
|
472
518
|
restoreParams(entry, hit.params, entry.binding.address); // 类型不合先 404,不编译
|
|
473
|
-
const assets = servePage(
|
|
474
|
-
return finish(assets, entry.binding, { entry, rawParams: hit.params, address: entry.binding.address, ...common });
|
|
519
|
+
const assets = servePage(page, digest, entry.binding, hostDir);
|
|
520
|
+
return finish(assets, entry.binding, { entry, rawParams: hit.params, address: entry.binding.address, ...common });
|
|
475
521
|
}
|
|
476
522
|
}
|
|
477
523
|
|
|
@@ -513,7 +559,8 @@ return finish(assets, entry.binding, { entry, rawParams: hit.params, address: en
|
|
|
513
559
|
assertStandardPageShape(result.page, entry.binding.address);
|
|
514
560
|
// 解析出的页面自带 access 时再过一遍(前缀授权下限与缺省策略已在上面过过,重复判定无副作用)
|
|
515
561
|
await gateAccess(entry.binding, result.page.envelope ?? null, access.policy, access.identity, requestPath);
|
|
516
|
-
|
|
562
|
+
// 摘要只由「前缀绑定地址 + 页面内容」决定,不混请求路径:同前缀下内容相同的页面跨请求路径命中同一条编译缓存(编译产物只用绑定地址,不含请求路径)
|
|
563
|
+
const digest = createHash('sha256').update(`${entry.binding.address}|${JSON.stringify(result.page)}`).digest('hex');
|
|
517
564
|
const assets = servePage(result.page, digest, entry.binding, hostDir);
|
|
518
565
|
return finish({ ...assets, ...(result.title !== undefined ? { title: result.title } : {}) }, entry.binding, {
|
|
519
566
|
entry, rawParams: hit.params, address: entry.binding.address, envelope: result.page.envelope ?? null, ...common,
|
|
@@ -38,7 +38,7 @@ export class RuntimeLru<V> {
|
|
|
38
38
|
private misses = 0;
|
|
39
39
|
private evictions = 0;
|
|
40
40
|
|
|
41
|
-
constructor(private readonly capacity: number) {
|
|
41
|
+
constructor(private readonly capacity: number, private readonly onEvict?: (key: string) => void) {
|
|
42
42
|
if (!Number.isInteger(capacity) || capacity < 1) throw new RangeError('RuntimeLru: capacity 必须是正整数');
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -62,6 +62,7 @@ export class RuntimeLru<V> {
|
|
|
62
62
|
if (oldest.done) break;
|
|
63
63
|
this.map.delete(oldest.value);
|
|
64
64
|
this.evictions += 1;
|
|
65
|
+
this.onEvict?.(oldest.value);
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
|
|
@@ -101,13 +102,15 @@ export class SomaRuntimeStore {
|
|
|
101
102
|
private readonly pages: RuntimeLru<SomaStandardPage>;
|
|
102
103
|
/** 摘要 → 它的编译结果键(只记键,不持有产物) */
|
|
103
104
|
private readonly compiledKeys = new Map<string, Set<string>>();
|
|
105
|
+
/** 编译结果键 → 所属摘要(LRU 淘汰时反查,同步清 compiledKeys) */
|
|
106
|
+
private readonly keyDigest = new Map<string, string>();
|
|
104
107
|
|
|
105
108
|
constructor(
|
|
106
109
|
readonly dirs: Pick<SomaRuntimeDirs, 'artifacts' | 'bindings' | 'prewarm'>,
|
|
107
110
|
options: { readonly cacheEntries?: number } = {},
|
|
108
111
|
) {
|
|
109
112
|
const capacity = options.cacheEntries ?? resolveRuntimeCacheEntries(process.env[SOMA_RUNTIME_CACHE_ENTRIES_ENV]);
|
|
110
|
-
this.compiled = new RuntimeLru(capacity);
|
|
113
|
+
this.compiled = new RuntimeLru(capacity, (key) => this.forgetCompiledKey(key));
|
|
111
114
|
this.pages = new RuntimeLru(capacity);
|
|
112
115
|
}
|
|
113
116
|
|
|
@@ -152,6 +155,18 @@ export class SomaRuntimeStore {
|
|
|
152
155
|
this.compiledKeys.set(digest, keys);
|
|
153
156
|
}
|
|
154
157
|
keys.add(key);
|
|
158
|
+
this.keyDigest.set(key, digest);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** LRU 淘汰 / 作废一个编译键后,同步从 compiledKeys 摘掉它(Set 空了连摘要条目一起删) */
|
|
162
|
+
private forgetCompiledKey(key: string): void {
|
|
163
|
+
const digest = this.keyDigest.get(key);
|
|
164
|
+
if (digest === undefined) return;
|
|
165
|
+
this.keyDigest.delete(key);
|
|
166
|
+
const keys = this.compiledKeys.get(digest);
|
|
167
|
+
if (keys === undefined) return;
|
|
168
|
+
keys.delete(key);
|
|
169
|
+
if (keys.size === 0) this.compiledKeys.delete(digest);
|
|
155
170
|
}
|
|
156
171
|
|
|
157
172
|
/** 绑定表装入后丢弃 L1 里的旧摘要(源变化即失效),连同该摘要的编译结果 */
|
|
@@ -159,7 +174,10 @@ export class SomaRuntimeStore {
|
|
|
159
174
|
this.pages.delete(digest);
|
|
160
175
|
const keys = this.compiledKeys.get(digest);
|
|
161
176
|
if (keys !== undefined) {
|
|
162
|
-
for (const key of keys)
|
|
177
|
+
for (const key of keys) {
|
|
178
|
+
this.compiled.delete(key);
|
|
179
|
+
this.keyDigest.delete(key);
|
|
180
|
+
}
|
|
163
181
|
this.compiledKeys.delete(digest);
|
|
164
182
|
}
|
|
165
183
|
}
|
|
@@ -210,6 +228,17 @@ export class SomaRuntimeStore {
|
|
|
210
228
|
}
|
|
211
229
|
}
|
|
212
230
|
|
|
231
|
+
/** 严格删除:文件本来就不在返回 false(视为成功);其他失败(权限 / IO)原样抛出,不吞 */
|
|
232
|
+
removeBindingStrict(address: string): boolean {
|
|
233
|
+
try {
|
|
234
|
+
fs.unlinkSync(this.bindingFile(address));
|
|
235
|
+
return true;
|
|
236
|
+
} catch (error) {
|
|
237
|
+
if ((error as NodeJS.ErrnoException)?.code === 'ENOENT') return false;
|
|
238
|
+
throw error;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
213
242
|
/** 读 `bindings/` 下全部绑定(启动装入用);损坏文件跳过 */
|
|
214
243
|
listBindings(): readonly SomaBindingRead[] {
|
|
215
244
|
let names: string[];
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// 纪律:不执行任何方言代码、不回调编译器、不写字面 owner / format(都是参数),不新增写口
|
|
6
6
|
// (`registerSomaPage` 仍是唯一注入入口)。拒收一律抛 `SomaSubmitStepError`(plain 三段式),方言在自己的 catch 里转自己的错误类。
|
|
7
7
|
|
|
8
|
+
import { SomaError } from '../../shared/soma-error';
|
|
8
9
|
import { PROVENANCE_REJECT_CODE, frozenProvenance, provenanceProblem, type ProvenanceCheckOptions } from '../../page-target/provenance';
|
|
9
10
|
import type { PageProvenance } from '../../page-target/types';
|
|
10
11
|
import { computeStandardPageDigest } from './digest';
|
|
@@ -21,7 +22,7 @@ import type {
|
|
|
21
22
|
} from './types';
|
|
22
23
|
|
|
23
24
|
/** 步骤拒收:三段式 + 位置;message = `situation:problem` */
|
|
24
|
-
export class SomaSubmitStepError extends
|
|
25
|
+
export class SomaSubmitStepError extends SomaError implements SomaSubmitStepIssue {
|
|
25
26
|
readonly code: string;
|
|
26
27
|
readonly situation: string;
|
|
27
28
|
readonly problem: string;
|
|
@@ -89,7 +89,7 @@ export interface SomaRuntimeBinding {
|
|
|
89
89
|
/** D6:不透明来源标记;无则 null */
|
|
90
90
|
readonly source: SomaRuntimeSource | null;
|
|
91
91
|
/**
|
|
92
|
-
* URL 注册表的来源类型:一个 URL 只挂一个来源类型(`native` / `soma-ui` / `soma-
|
|
92
|
+
* URL 注册表的来源类型:一个 URL 只挂一个来源类型(`native` / `soma-ui` / `soma-kit`)。
|
|
93
93
|
* 同类型再注册 = 覆盖;不同类型 = 冲突(保留先挂的,注册日志记 error);撤下只能同类型。同类型内部的重复由来源自己处理。旧绑定与 Registry 绑定无此字段。
|
|
94
94
|
*/
|
|
95
95
|
readonly owner?: string;
|
|
@@ -119,6 +119,8 @@ export interface SomaInjectOptions {
|
|
|
119
119
|
readonly expiresAt?: number;
|
|
120
120
|
/** D6:不透明来源标记 */
|
|
121
121
|
readonly source?: SomaRuntimeSource;
|
|
122
|
+
/** 页面 `domain:` 指向的展示对象类由 Host 浏览器侧的 `pageRoots` 类表提供(方言所有者声明):注入期不再提示 CORE-RUNTIME-DOMAIN-STATIC-ONLY */
|
|
123
|
+
readonly domainProvided?: boolean;
|
|
122
124
|
}
|
|
123
125
|
|
|
124
126
|
/** D6:批量注入的一条 */
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SomaError } from './soma-error';
|
|
1
2
|
import type { SourceSpan } from './types/component-tree.types';
|
|
2
3
|
|
|
3
4
|
export type ComponentTreeErrorCode =
|
|
@@ -25,7 +26,7 @@ export interface ComponentTreeDiagnostic {
|
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
/** Stable, serializable diagnostics without retaining the page source or context. */
|
|
28
|
-
export class SomaComponentTreeError extends
|
|
29
|
+
export class SomaComponentTreeError extends SomaError {
|
|
29
30
|
readonly code: ComponentTreeErrorCode;
|
|
30
31
|
readonly diagnostic: Readonly<ComponentTreeDiagnostic>;
|
|
31
32
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// 契约通用 a11y 诊断(S12-a;《core 标准能力补齐方案》;护栏 #11 / #48 / #49 / #58)。
|
|
2
2
|
//
|
|
3
3
|
// 纯函数、无 DOM、无组件名:只看契约结构(`overlay:` / `keyboard:` / `structure.slots`)与页面期的地标实例信息,
|
|
4
|
-
// 不认任何具体组件。soma-
|
|
4
|
+
// 不认任何具体组件。soma-ui 的契约编译调用同一函数,两线对「同一份契约是否可达」只有一个答案。
|
|
5
5
|
//
|
|
6
6
|
// 分两条:
|
|
7
7
|
// · 契约期 `checkContractA11y(contract)`:①模态浮层的关闭途径全关(#49);②集合宿主缺 `keyboard:` 声明(#11 / #58);
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// 键盘布局与机器 / 角色是否对得上)归 `contract-a11y.ts` 的 `checkContractA11y`。
|
|
6
6
|
//
|
|
7
7
|
// 纯函数、无 DOM、不认组件名;运行期注册的契约
|
|
8
|
-
// (`SomaComponentRegistry.register`)调同一函数,两线(soma-ui / soma-
|
|
8
|
+
// (`SomaComponentRegistry.register`)调同一函数,两线(soma-ui / soma-kit 的契约翻译)对「这段声明合不合法」只有一个答案。
|
|
9
9
|
//
|
|
10
10
|
// 越界一律给出问题,不静默丢弃:
|
|
11
11
|
// · kind: 'shape' 段 / 值的类型不对(段不是对象、布尔写成字符串、数组为空…)
|
|
@@ -270,7 +270,7 @@ const OWNER_OF_KEY: ReadonlyMap<string, ContractSectionName> = (() => {
|
|
|
270
270
|
})();
|
|
271
271
|
|
|
272
272
|
/**
|
|
273
|
-
*
|
|
273
|
+
* 契约顶层不该出现、必然是写错段的键(方言直译常见:把 `landmark` / `name_from` 平铺到顶层)。
|
|
274
274
|
* 刻意只收这几个独有名:顶层其余未知段对 core 不透明(KI-18),不在这里拒。
|
|
275
275
|
*/
|
|
276
276
|
const TOP_LEVEL_MISPLACED = ['machines', 'collection', 'name_from', 'landmark'] as const;
|
|
@@ -39,6 +39,11 @@ export const SOMA_CORE_DIAGNOSTIC_CODES = [
|
|
|
39
39
|
'CORE-FORMAT-VERSION-UNSUPPORTED', // 注入载荷 format 不是 core 认识的主版本
|
|
40
40
|
'CORE-FORMAT-VERSION-MISMATCH', // 载荷 format 与 page 块 soma: 不一致(page 块缺 soma: 同此码)
|
|
41
41
|
'CORE-INJECT-NONSTANDARD-KEY', // 兼容期结束后含方言段拒收
|
|
42
|
+
'CORE-INJECT-PAGE-LOGIC', // 页面含逻辑写法(对象谓词 when / rules[].when / predicates / transform / calc / derive / steps / triggers 等,见 std-grammar#pageForbiddenLogicKeys):拒收,不降级放行
|
|
43
|
+
'CORE-INJECT-PAGE-CLOSURE', // 四件套某处越出闭集(未知键 / 形状不合 / 事件声明形态不合):拒收,不静默忽略
|
|
44
|
+
'CORE-PAGE-NEGATE-FORBIDDEN', // 页面里的路径带 `!` 取反前缀(when / class 值 / props 值):页面只读展示对象,相反的值由展示对象另给成员(如 remarkHidden)
|
|
45
|
+
'CORE-STYLE-COMPARE-FORBIDDEN', // _style 的 states / transitions.active_state 写了「condition 路径 == value」比较形:改成 bind + tiers 纯绑定
|
|
46
|
+
'CORE-PAGE-ROLE-BY-INVALID', // bind.role_by 不是纯路径(表达式 / 取反 / 管道 / 映射):行字段的值直接作为 item:取值 模板名
|
|
42
47
|
'CORE-RUNTIME-ADDRESS-INVALID', // 地址文法不合(缺前导 /、尾随 /、大写、查询串、.. // 百分号、段数 / 长度超限)
|
|
43
48
|
'CORE-RUNTIME-ADDRESS-RESERVED', // 首段是保留名或宿主外壳路由
|
|
44
49
|
'CORE-RUNTIME-ADDRESS-STATIC', // 与静态页 / 表内固定页同址或覆盖其地址;后出现的静态页落进已有动态地址(409)
|
|
@@ -60,6 +65,9 @@ export const SOMA_CORE_DIAGNOSTIC_CODES = [
|
|
|
60
65
|
// 返回栈
|
|
61
66
|
'CORE-NAV-BACK-INVALID', // nav.back 声明不合(fallback 非站内路径 / exclude 形状 / previousCount 非正整数):声明期拒收
|
|
62
67
|
// 浏览器运行时入口与组件适配器(RT4)
|
|
68
|
+
'CORE-VIEW-DEFINE',
|
|
69
|
+
'CORE-VIEW-CTX',
|
|
70
|
+
'CORE-REACTIVE-WRITE',
|
|
63
71
|
'CORE-RUNTIME-DOMAIN-STATIC-ONLY', // 动态来源页面写了 domain: 类名;Domain 类只对静态页加载,运行期退成缺省根(advice)
|
|
64
72
|
'CORE-RUNTIME-MOUNT', // mountSomaPage 失败:来源缺失 / 端点非 2xx / 载荷形状不对(带 HTTP 状态)
|
|
65
73
|
'CORE-ADAPTER-EMIT', // 适配组件发出契约 emits 之外的事件,已拒收
|
|
@@ -24,7 +24,7 @@ export function nonStandardPageKeys(doc: unknown): string[] {
|
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* 文本是不是旧「块声明」容器(首个非空非注释行是 `{{` 开关行)。
|
|
27
|
-
* 块声明已退出 core 原生格式:它由方言(soma-ui / soma-
|
|
27
|
+
* 块声明已退出 core 原生格式:它由方言(soma-ui / soma-kit)自己编译成四件套后再交给 core。
|
|
28
28
|
*/
|
|
29
29
|
export function looksLikeBlockDeclaration(text: string): boolean {
|
|
30
30
|
for (const line of text.split('\n')) {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// 引擎端口的统一错误(core 引擎端口设计 §1.2、§1.5)。
|
|
2
2
|
// 住 shared:无 DOM、无 Node 专属 API,SSR 可 import;码值取自 `SOMA_CORE_DIAGNOSTIC_CODES`。
|
|
3
3
|
|
|
4
|
+
import { SomaError } from '../soma-error';
|
|
4
5
|
import type { SomaCoreOwnDiagnosticCode } from '../core-diagnostic-codes';
|
|
5
6
|
|
|
6
7
|
/** 引擎端口抛出的错误:`code` 是 core 自有码;`engine` 是引擎 id(不带文件路径) */
|
|
7
|
-
export class SomaEngineError extends
|
|
8
|
+
export class SomaEngineError extends SomaError {
|
|
8
9
|
readonly code: SomaCoreOwnDiagnosticCode;
|
|
9
10
|
readonly engine: string;
|
|
10
11
|
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// 抛的都是它,靠 `layer` 与 `code` 区分。不为每一层再派生子类——
|
|
5
5
|
// 子类一多,「能被 catch 成同一种东西」就没了,诊断汇总要逐类 instanceof。
|
|
6
6
|
|
|
7
|
+
import { SomaError } from './soma-error';
|
|
7
8
|
import type {
|
|
8
9
|
SomaGenerationErrorShape,
|
|
9
10
|
SomaGenerationErrorCode,
|
|
@@ -22,7 +23,7 @@ export function formatGenerationError(shape: SomaGenerationErrorShape): string {
|
|
|
22
23
|
return `${head}(${where})${near}`;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
export class SomaGenerationError extends
|
|
26
|
+
export class SomaGenerationError extends SomaError implements SomaGenerationErrorShape {
|
|
26
27
|
readonly code: SomaGenerationErrorCode;
|
|
27
28
|
readonly layer: SomaGenerationLayer;
|
|
28
29
|
readonly situation: string;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// 所以接口、类型、诊断里没有任何产生方的名字;「谁能写哪些键」只用写面表达(`full` / `restricted`,见 `SomaEnvelopeWriter`)。
|
|
6
6
|
//
|
|
7
7
|
// 唯一实现:信封键集与取值判定、参数值还原(`parseParamValue`)、地址文法(`parseEnvelopeUrl`)都只在本文件;
|
|
8
|
-
// 方言线(soma-ui / soma-
|
|
8
|
+
// 方言线(soma-ui / soma-kit)经公开子路径调 `checkPageEnvelope`,不得另写同名或同义实现。
|
|
9
9
|
// 键集、取值域与数字上限的真源:soma-design 的 std-grammar(上下文 `page.envelope*`)与 limits(`envelope.*`)。
|
|
10
10
|
//
|
|
11
11
|
// 本文件无 DOM、无 Node 专属 API、只 import shared 内部文件(KI-8 规则 1)。
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// 纯绑定判据:展示对象的值对页面只读,页面只做纯路径读取,不在页面里取反、比较、映射。
|
|
2
|
+
//
|
|
3
|
+
// 三处共用同一份判据(解析器、注入口闭集、测试):
|
|
4
|
+
// · `!path` 取反前缀(when / class 值 / props 值) → CORE-PAGE-NEGATE-FORBIDDEN
|
|
5
|
+
// · _style states / active_state 的 condition + value 比较形 → CORE-STYLE-COMPARE-FORBIDDEN(解析器处判)
|
|
6
|
+
// · bind.role_by 不是纯路径 → CORE-PAGE-ROLE-BY-INVALID
|
|
7
|
+
// 形态与档位上限只读 `std-grammar.json#pageForbiddenLogicKeys.pureBinding`,本文件不写字面量。
|
|
8
|
+
// 纯函数,无 DOM、无 Node 专属 API。
|
|
9
|
+
|
|
10
|
+
import { SOMA_STD_PAGE_FORBIDDEN_LOGIC_KEYS } from './registry-generated/std-grammar-views';
|
|
11
|
+
|
|
12
|
+
interface PureBindingTruth {
|
|
13
|
+
readonly negatedPath: { readonly code: string; readonly prefix: string; readonly pathPattern: string; readonly remedy: string };
|
|
14
|
+
readonly styleComparison: { readonly code: string; readonly keys: readonly string[]; readonly remedy: string };
|
|
15
|
+
readonly styleTier: { readonly keys: readonly string[]; readonly tierNamePattern: string; readonly maxTiers: number };
|
|
16
|
+
readonly roleBy: { readonly code: string; readonly pathPattern: string; readonly remedy: string };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const TRUTH = SOMA_STD_PAGE_FORBIDDEN_LOGIC_KEYS.pureBinding as unknown as PureBindingTruth;
|
|
20
|
+
|
|
21
|
+
export const SOMA_PURE_BINDING = TRUTH;
|
|
22
|
+
|
|
23
|
+
/** 纯绑定违规码(码表在 core-diagnostic-codes.ts) */
|
|
24
|
+
export type SomaPureBindingCode =
|
|
25
|
+
| 'CORE-PAGE-NEGATE-FORBIDDEN'
|
|
26
|
+
| 'CORE-STYLE-COMPARE-FORBIDDEN'
|
|
27
|
+
| 'CORE-PAGE-ROLE-BY-INVALID';
|
|
28
|
+
|
|
29
|
+
const NEGATED_PATH = new RegExp(TRUTH.negatedPath.pathPattern);
|
|
30
|
+
const ROLE_BY_PATH = new RegExp(TRUTH.roleBy.pathPattern);
|
|
31
|
+
const TIER_NAME = new RegExp(TRUTH.styleTier.tierNamePattern);
|
|
32
|
+
|
|
33
|
+
/** 严格位(when / class 值):任何以取反前缀开头的值都是取反写法 */
|
|
34
|
+
export function hasNegationPrefix(value: string): boolean {
|
|
35
|
+
return value.trimStart().startsWith(TRUTH.negatedPath.prefix);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** 宽位(props 值):`!` + 点分路径才算取反;以 `!` 开头的普通文字(如 `!关闭`)不是路径,放行 */
|
|
39
|
+
export function isNegatedPathLiteral(value: string): boolean {
|
|
40
|
+
return NEGATED_PATH.test(value);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** 递归找 props 值里的取反路径,返回第一处的相对路径(无则 undefined) */
|
|
44
|
+
export function findNegatedPathIn(value: unknown, at = ''): { at: string; value: string } | undefined {
|
|
45
|
+
if (typeof value === 'string') return isNegatedPathLiteral(value) ? { at, value } : undefined;
|
|
46
|
+
if (Array.isArray(value)) {
|
|
47
|
+
for (let i = 0; i < value.length; i += 1) {
|
|
48
|
+
const hit = findNegatedPathIn(value[i], `${at}[${i}]`);
|
|
49
|
+
if (hit) return hit;
|
|
50
|
+
}
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
if (value !== null && typeof value === 'object') {
|
|
54
|
+
for (const [key, item] of Object.entries(value)) {
|
|
55
|
+
const hit = findNegatedPathIn(item, at ? `${at}.${key}` : key);
|
|
56
|
+
if (hit) return hit;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function negationMessage(where: string, value: string): string {
|
|
63
|
+
return `${where} 不能写取反 "${value}":展示对象的值对页面只读,页面不取反;${TRUTH.negatedPath.remedy}`;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** role_by 是不是纯路径(行字段的值直接作为模板名) */
|
|
67
|
+
export function isPureRolePath(value: unknown): value is string {
|
|
68
|
+
return typeof value === 'string' && ROLE_BY_PATH.test(value);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function roleByMessage(value: unknown): string {
|
|
72
|
+
return `bind.role_by 必须是纯路径(当前值: ${JSON.stringify(value)});${TRUTH.roleBy.remedy}`;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** 样式绑定的 bind 路径:与 role_by 同形的纯路径(点分标识符,无取反 / 管道 / 运算符) */
|
|
76
|
+
export function isPureBindPath(value: unknown): value is string {
|
|
77
|
+
return isPureRolePath(value);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function isTierName(name: string): boolean {
|
|
81
|
+
return TIER_NAME.test(name);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export const SOMA_STYLE_TIER_MAX = TRUTH.styleTier.maxTiers;
|
|
85
|
+
export const SOMA_STYLE_COMPARE_KEYS: ReadonlySet<string> = new Set(TRUTH.styleComparison.keys);
|
|
86
|
+
export const SOMA_STYLE_COMPARE_REMEDY = TRUTH.styleComparison.remedy;
|
|
87
|
+
export const SOMA_STYLE_TIER_KEYS: readonly string[] = TRUTH.styleTier.keys;
|
|
88
|
+
export const SOMA_STYLE_TIER_NAME_PATTERN = TRUTH.styleTier.tierNamePattern;
|
|
@@ -88,6 +88,11 @@ export const SOMA_DIAGNOSTIC_CODE_INDEX: readonly (readonly [code: string, famil
|
|
|
88
88
|
['CORE-FRAGMENTS-CONFLICT', 'CORE', 'core', 'error'],
|
|
89
89
|
['CORE-HOOK-UNCOMPILED', 'CORE', 'core', 'warn'],
|
|
90
90
|
['CORE-INJECT-NONSTANDARD-KEY', 'CORE', 'core', 'error'],
|
|
91
|
+
['CORE-INJECT-PAGE-LOGIC', 'CORE', 'core', 'error'],
|
|
92
|
+
['CORE-PAGE-NEGATE-FORBIDDEN', 'CORE', 'core', 'error'],
|
|
93
|
+
['CORE-STYLE-COMPARE-FORBIDDEN', 'CORE', 'core', 'error'],
|
|
94
|
+
['CORE-PAGE-ROLE-BY-INVALID', 'CORE', 'core', 'error'],
|
|
95
|
+
['CORE-INJECT-PAGE-CLOSURE', 'CORE', 'core', 'error'],
|
|
91
96
|
['CORE-REG-INPUT-INVALID', 'CORE', 'core', 'error'],
|
|
92
97
|
['CORE-REG-NO-COMPILED-ARTIFACT', 'CORE', 'core', 'error'],
|
|
93
98
|
['CORE-KEYBOARD-DECL', 'CORE', 'core', 'error'],
|
|
@@ -209,7 +214,6 @@ export const SOMA_DIAGNOSTIC_CODE_INDEX: readonly (readonly [code: string, famil
|
|
|
209
214
|
['CORE-TIME-REMINDER', 'CORE', 'core', 'error'],
|
|
210
215
|
['CORE-TIME-SERIES', 'CORE', 'core', 'error'],
|
|
211
216
|
['CORE-TIME-TERM', 'CORE', 'core', 'error'],
|
|
212
|
-
['CORE-TONES-INVALID', 'CORE', 'core', 'warn'],
|
|
213
217
|
['CORE-QUERY-URL-INVALID', 'CORE', 'core', 'warn'],
|
|
214
218
|
['CORE-QUERY-DECL-INVALID', 'CORE', 'core', 'error'],
|
|
215
219
|
['CORE-QUERY-PREFS-DENIED', 'CORE', 'core', 'warn'],
|
|
@@ -286,6 +290,10 @@ export const SOMA_DIAGNOSTIC_CODE_INDEX: readonly (readonly [code: string, famil
|
|
|
286
290
|
['ERR-APP-013', 'ERR-APP', 'app', 'error'],
|
|
287
291
|
['ERR-APP-014', 'ERR-APP', 'app', 'error'],
|
|
288
292
|
['ERR-APP-015', 'ERR-APP', 'app', 'error'],
|
|
293
|
+
['ERR-APP-016', 'ERR-APP', 'app', 'error'],
|
|
294
|
+
['ERR-APP-017', 'ERR-APP', 'app', 'error'],
|
|
295
|
+
['ERR-APP-018', 'ERR-APP', 'app', 'error'],
|
|
296
|
+
['ERR-APP-019', 'ERR-APP', 'app', 'error'],
|
|
289
297
|
['ERR-BIZ-001', 'ERR-BIZ', 'biz', 'error'],
|
|
290
298
|
['ERR-BIZ-002', 'ERR-BIZ', 'biz', 'error'],
|
|
291
299
|
['ERR-BIZ-003', 'ERR-BIZ', 'biz', 'error'],
|
|
@@ -304,7 +312,6 @@ export const SOMA_DIAGNOSTIC_CODE_INDEX: readonly (readonly [code: string, famil
|
|
|
304
312
|
['ERR-BIZ-016', 'ERR-BIZ', 'biz', 'error'],
|
|
305
313
|
['ERR-BIZ-017', 'ERR-BIZ', 'biz', 'error'],
|
|
306
314
|
['ERR-BIZ-018', 'ERR-BIZ', 'biz', 'error'],
|
|
307
|
-
['ERR-BIZ-019', 'ERR-BIZ', 'biz', 'error'],
|
|
308
315
|
['ERR-CAP-002', 'ERR-CAP', 'unit', 'error'],
|
|
309
316
|
['ERR-CAP-003', 'ERR-CAP', 'unit', 'error'],
|
|
310
317
|
['ERR-CAP-004', 'ERR-CAP', 'unit', 'error'],
|
|
@@ -465,9 +472,7 @@ export const SOMA_DIAGNOSTIC_CODE_INDEX: readonly (readonly [code: string, famil
|
|
|
465
472
|
['ERR-DSN-960', 'ERR-DSN', 'design', 'error'],
|
|
466
473
|
['ERR-DSN-961', 'ERR-DSN', 'design', 'warn'],
|
|
467
474
|
['ERR-DSN-962', 'ERR-DSN', 'design', 'warn'],
|
|
468
|
-
['ERR-DSN-963', 'ERR-DSN', 'design', 'warn'],
|
|
469
475
|
['ERR-DSN-964', 'ERR-DSN', 'design', 'warn'],
|
|
470
|
-
['ERR-DSN-965', 'ERR-DSN', 'design', 'warn'],
|
|
471
476
|
['ERR-DSN-966', 'ERR-DSN', 'design', 'error'],
|
|
472
477
|
['ERR-DSN-967', 'ERR-DSN', 'design', 'warn'],
|
|
473
478
|
['ERR-EXPAND-001', 'ERR-EXPAND', 'unit', 'error'],
|
|
@@ -512,6 +517,13 @@ export const SOMA_DIAGNOSTIC_CODE_INDEX: readonly (readonly [code: string, famil
|
|
|
512
517
|
['ERR-PAGE-007', 'ERR-PAGE', 'page', 'error'],
|
|
513
518
|
['ERR-PAGE-008', 'ERR-PAGE', 'page', 'error'],
|
|
514
519
|
['ERR-PAGE-009', 'ERR-PAGE', 'page', 'error'],
|
|
520
|
+
['ERR-PAGE-010', 'ERR-PAGE', 'page', 'error'],
|
|
521
|
+
['ERR-PAGE-011', 'ERR-PAGE', 'page', 'error'],
|
|
522
|
+
['ERR-PAGE-012', 'ERR-PAGE', 'page', 'error'],
|
|
523
|
+
['ERR-PAGE-013', 'ERR-PAGE', 'page', 'error'],
|
|
524
|
+
['ERR-PAGE-014', 'ERR-PAGE', 'page', 'error'],
|
|
525
|
+
['ERR-PAGE-015', 'ERR-PAGE', 'page', 'error'],
|
|
526
|
+
['ERR-PAGE-016', 'ERR-PAGE', 'page', 'error'],
|
|
515
527
|
['ERR-PUB-001', 'ERR-PUB', 'publish', 'error'],
|
|
516
528
|
['ERR-PUB-002', 'ERR-PUB', 'publish', 'error'],
|
|
517
529
|
['ERR-PUB-003', 'ERR-PUB', 'publish', 'error'],
|
|
@@ -618,11 +630,8 @@ export const SOMA_DIAGNOSTIC_CODE_INDEX: readonly (readonly [code: string, famil
|
|
|
618
630
|
['OOUI-SEM-ANCHOR-UNKNOWN', 'OOUI-SEM', 'ooui', 'error'],
|
|
619
631
|
['OOUI-SEM-BINDING-CYCLE', 'OOUI-SEM', 'ooui', 'error'],
|
|
620
632
|
['OOUI-SEM-BINDING-EVENT-UNKNOWN', 'OOUI-SEM', 'ooui', 'error'],
|
|
621
|
-
['OOUI-SEM-BINDING-KEY-UNKNOWN', 'OOUI-SEM', 'ooui', 'error'],
|
|
622
|
-
['OOUI-SEM-BINDING-REGION-UNKNOWN', 'OOUI-SEM', 'ooui', 'error'],
|
|
623
633
|
['OOUI-SEM-BINDING-UNSUPPORTED', 'OOUI-SEM', 'ooui', 'error'],
|
|
624
634
|
['OOUI-SEM-BLOCK-SHAPE', 'OOUI-SEM', 'ooui', 'error'],
|
|
625
|
-
['OOUI-SEM-CALC-NOT-WRITABLE', 'OOUI-SEM', 'ooui', 'error'],
|
|
626
635
|
['OOUI-SEM-COPY-INVALID', 'OOUI-SEM', 'ooui', 'error'],
|
|
627
636
|
['OOUI-SEM-CROSS-OBJECT-REF', 'OOUI-SEM', 'ooui', 'error'],
|
|
628
637
|
['OOUI-SEM-FIELD-KEY-UNKNOWN', 'OOUI-SEM', 'ooui', 'error'],
|
|
@@ -762,9 +771,7 @@ export const SOMA_DIAGNOSTIC_CODE_INDEX: readonly (readonly [code: string, famil
|
|
|
762
771
|
['THM-VF-NOOP-NOTE', 'THM-VF', 'theme', 'advice'],
|
|
763
772
|
['THM-VF-COLOR-COUPLE', 'THM-VF', 'theme', 'warn'],
|
|
764
773
|
['THM-VF-DENSITY-MISMATCH', 'THM-VF', 'theme', 'warn'],
|
|
765
|
-
['THM-VF-SHADOW-COLLISION', 'THM-VF', 'theme', 'warn'],
|
|
766
774
|
['THM-VF-TINT-PURIFIED', 'THM-VF', 'theme', 'advice'],
|
|
767
|
-
['THM-VF-CHROMA-GUARD', 'THM-VF', 'theme', 'warn'],
|
|
768
775
|
['THM-ROLE-UNKNOWN-CLASS', 'THM-ROLE', 'theme', 'error'],
|
|
769
776
|
['THM-ROLE-NONCANONICAL', 'THM-ROLE', 'theme', 'error'],
|
|
770
777
|
['THM-ROLE-ILLEGAL-COMBO', 'THM-ROLE', 'theme', 'error'],
|
|
@@ -772,25 +779,15 @@ export const SOMA_DIAGNOSTIC_CODE_INDEX: readonly (readonly [code: string, famil
|
|
|
772
779
|
['THM-ROLE-BARE-COLOR', 'THM-ROLE', 'theme', 'error'],
|
|
773
780
|
['THM-ROLE-INLINE-STYLE', 'THM-ROLE', 'theme', 'error'],
|
|
774
781
|
['THM-ROLE-VISUAL-IN-SKELETON', 'THM-ROLE', 'theme', 'error'],
|
|
775
|
-
['THM-ROLE-MULTIPLE', 'THM-ROLE', 'theme', 'error'],
|
|
776
782
|
['THM-ROLE-ELEMENT', 'THM-ROLE', 'theme', 'error'],
|
|
777
783
|
['THM-ROLE-NESTING', 'THM-ROLE', 'theme', 'error'],
|
|
778
784
|
['THM-ROLE-EMBEDDED-OUTSIDE-SHELL', 'THM-ROLE', 'theme', 'error'],
|
|
779
|
-
['THM-ROLE-COVERAGE', 'THM-ROLE', 'theme', 'error'],
|
|
780
785
|
['THM-ROLE-UNKNOWN-WORD', 'THM-ROLE', 'theme', 'error'],
|
|
781
786
|
['THM-ROLE-DUPLICATE-SLOT', 'THM-ROLE', 'theme', 'error'],
|
|
782
787
|
['THM-ROLE-REALIZE', 'THM-ROLE', 'theme', 'error'],
|
|
783
|
-
['THM-OUT-BARE-LITERAL', 'THM-OUT', 'theme', 'error'],
|
|
784
788
|
['THM-OUT-DANGLING-VAR', 'THM-OUT', 'theme', 'error'],
|
|
785
789
|
['THM-OUT-LAYER', 'THM-OUT', 'theme', 'error'],
|
|
786
|
-
['THM-OUT-GEOMETRY-DRIFT', 'THM-OUT', 'theme', 'error'],
|
|
787
|
-
['THM-OUT-PAIRING', 'THM-OUT', 'theme', 'error'],
|
|
788
|
-
['THM-OUT-TRACE-BROKEN', 'THM-OUT', 'theme', 'error'],
|
|
789
|
-
['THM-OUT-BUDGET', 'THM-OUT', 'theme', 'error'],
|
|
790
790
|
['THM-OUT-NO-TOKENS', 'THM-OUT', 'theme', 'error'],
|
|
791
791
|
['THM-COORD-ACCENT-BUDGET', 'THM-COORD', 'theme', 'error'],
|
|
792
792
|
['THM-COORD-NEST-NOTE', 'THM-COORD', 'theme', 'advice'],
|
|
793
|
-
['THM-OUT-OPTICAL-BUDGET', 'THM-OUT', 'theme', 'error'],
|
|
794
|
-
['THM-OUT-UNUSED-COORD-VAR', 'THM-OUT', 'theme', 'error'],
|
|
795
|
-
['THM-OUT-SOLID-FACE', 'THM-OUT', 'theme', 'error'],
|
|
796
793
|
];
|