soma-core 1.4.2 → 1.5.1
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/bin/component.cjs +240 -0
- package/bin/eject.cjs +174 -0
- package/bin/migrate.cjs +362 -0
- package/core/build/blocks/block-compile.ts +143 -17
- package/core/build/blocks/migrate-flat.ts +118 -25
- package/core/build/compiler/page-declaration-compiler.ts +149 -5
- package/core/build/compiler/route-builder.ts +0 -4
- package/core/build/compiler/soma-precompile.js +431 -26
- package/core/build/component/component-graph.ts +28 -105
- package/core/build/component/package-loader.ts +18 -4
- package/core/build/eject/component-eject.ts +8 -2
- package/core/build/layout/constraint-solver.ts +131 -16
- package/core/build/layout/css-emitter.ts +29 -10
- package/core/build/ooui/artifact/artifact.types.ts +275 -0
- package/core/build/ooui/artifact/emit-artifact.ts +269 -0
- package/core/build/ooui/artifact/emit-html.ts +204 -0
- package/core/build/ooui/artifact/index.ts +53 -0
- package/core/build/ooui/artifact/spatial-tree.ts +268 -0
- package/core/build/ooui/artifact/utility-class.ts +83 -0
- package/core/build/ooui/composition/candidate.types.ts +323 -0
- package/core/build/ooui/composition/control-model.ts +114 -0
- package/core/build/ooui/composition/registry.ts +520 -0
- package/core/build/ooui/composition/select.ts +232 -0
- package/core/build/ooui/diagnostics/codes.ts +230 -0
- package/core/build/ooui/diagnostics/error.ts +235 -0
- package/core/build/ooui/diagnostics/format.ts +106 -0
- package/core/build/ooui/diagnostics/index.ts +62 -0
- package/core/build/ooui/diagnostics/issue.types.ts +112 -0
- package/core/build/ooui/engine-slot.ts +184 -0
- package/core/build/ooui/index.ts +1427 -0
- package/core/build/ooui/intent/derive-intent.ts +450 -0
- package/core/build/ooui/intent/field-rules.ts +330 -0
- package/core/build/ooui/intent/intent.types.ts +476 -0
- package/core/build/ooui/intent/verb-events.ts +285 -0
- package/core/build/ooui/page/budget.ts +503 -0
- package/core/build/ooui/page/compose-page.ts +736 -0
- package/core/build/ooui/page/index.ts +66 -0
- package/core/build/ooui/page/page.types.ts +402 -0
- package/core/build/ooui/page/region-row.ts +241 -0
- package/core/build/ooui/semantic/expand-page-surface.ts +180 -0
- package/core/build/ooui/semantic/kernel.types.ts +187 -0
- package/core/build/ooui/semantic/normalize.ts +784 -0
- package/core/build/ooui/semantic/origin.types.ts +211 -0
- package/core/build/ooui/semantic/role-alias.ts +154 -0
- package/core/build/ooui/semantic/shorthand.ts +233 -0
- package/core/build/ooui/semantic/surface.types.ts +78 -0
- package/core/build/ooui/semantic/validate-request.ts +267 -0
- package/core/build/ooui/spatial/emit-utility.ts +480 -0
- package/core/build/ooui/spatial/ir.types.ts +443 -0
- package/core/build/ooui/spatial/registry.ts +565 -0
- package/core/build/ooui/spatial/solve.ts +769 -0
- package/core/build/ooui/spatial/utility.types.ts +242 -0
- package/core/build/ooui/trace/index.ts +40 -0
- package/core/build/ooui/trace/render.ts +190 -0
- package/core/build/ooui/trace/source.types.ts +69 -0
- package/core/build/ooui/trace/trace.types.ts +326 -0
- package/core/client/component/component-expander.ts +18 -3
- package/core/client/component/component-manager.ts +4 -0
- package/core/client/component/example-blocks.ts +1 -7
- package/core/client/component/theme-component-tokens.ts +12 -15
- package/core/client/component/verify-pack.ts +43 -0
- package/core/client/data/data-object-resolver.ts +27 -8
- package/core/client/diagnostics/telemetry-context.ts +0 -4
- package/core/client/engine/asset-resolver.ts +0 -1
- package/core/client/engine/event-engine.ts +7 -3
- package/core/client/engine/soma-bootstrap.ts +292 -34
- package/core/client/engine/style-binder.ts +0 -1
- package/core/client/infra/http/IHttpClient.ts +0 -6
- package/core/client/infra/http/SomaHttpService.ts +4 -1
- package/core/client/infra/notify/DomNotifyService.ts +1 -1
- package/core/client/infra/router/router-path.ts +0 -6
- package/core/client/parser/annotation-extractor.ts +1 -1
- package/core/client/parser/blocks/namespace.ts +30 -5
- package/core/client/parser/blocks/page-parser.ts +44 -1
- package/core/client/parser/blocks/use-parser.ts +266 -46
- package/core/client/parser/data-config-parser.ts +71 -3
- package/core/client/parser/layout-parser.ts +4 -3
- package/core/client/parser/reaction-parser.ts +0 -1
- package/core/client/parser/ui-config-parser.ts +212 -74
- package/core/client/theme/scene-tokens.ts +9 -3
- package/core/client/theme/theme-axes.ts +74 -16
- package/core/client/theme/theme-engine.ts +341 -70
- package/core/client/theme/tone-solver.ts +9 -8
- package/core/index.ts +24 -5
- package/core/server/api/load-host-service.ts +8 -2
- package/core/server/declaration-safety.ts +11 -0
- package/core/server/host/page-response-request.ts +0 -2
- package/core/server/host/published-page-artifact-cache.ts +244 -0
- package/core/server/host/published-page-assets.ts +44 -5
- package/core/server/mock/node/cli.mjs +0 -1
- package/core/server/mock/node/schema-generator.mjs +0 -1
- package/core/server/ooui.ts +34 -0
- package/core/server/page-assets.ts +8 -0
- package/core/server/page-declaration.ts +18 -0
- package/core/server/registry/asset-store.ts +327 -0
- package/core/server/registry/declaration-precompiler.ts +49 -6
- package/core/server/registry/index.ts +47 -1
- package/core/server/registry/page-registry-repository.ts +6 -2
- package/core/server/registry/page-registry-store.ts +133 -19
- package/core/server/registry/publish-asset-pin.ts +557 -0
- package/core/server/registry/services/pages/List.ts +15 -3
- package/core/server/registry/validation/compile-gate.ts +180 -8
- package/core/server/registry/validation/declaration-safety-scan.ts +113 -23
- package/core/shared/component/derive-sample.ts +201 -16
- package/core/shared/component/field-lines.ts +98 -8
- package/core/shared/container-breakpoints.ts +46 -0
- package/core/shared/object-semantics.ts +240 -0
- package/core/shared/ooui-declaration.ts +235 -0
- package/core/shared/types/component-contract.types.ts +7 -6
- package/core/shared/types/data-config.types.ts +95 -0
- package/core/shared/types/domain.types.ts +0 -24
- package/core/shared/types/engine.types.ts +0 -5
- package/core/shared/types/layout-constraint.types.ts +16 -0
- package/core/shared/types/ui-config.types.ts +163 -13
- package/dist/cli/soma.js +24 -11
- package/dist/core/index.cjs +1829 -1028
- package/dist/types/build/blocks/block-compile.d.ts +16 -1
- package/dist/types/build/blocks/migrate-flat.d.ts +17 -0
- package/dist/types/build/compiler/page-declaration-compiler.d.ts +46 -0
- package/dist/types/build/compiler/route-builder.d.ts +0 -1
- package/dist/types/build/component/component-graph.d.ts +17 -53
- package/dist/types/build/component/package-loader.d.ts +8 -1
- package/dist/types/build/layout/constraint-solver.d.ts +46 -4
- package/dist/types/build/ooui/artifact/artifact.types.d.ts +180 -0
- package/dist/types/build/ooui/artifact/emit-artifact.d.ts +58 -0
- package/dist/types/build/ooui/artifact/emit-html.d.ts +53 -0
- package/dist/types/build/ooui/artifact/index.d.ts +5 -0
- package/dist/types/build/ooui/artifact/spatial-tree.d.ts +48 -0
- package/dist/types/build/ooui/artifact/utility-class.d.ts +46 -0
- package/dist/types/build/ooui/composition/candidate.types.d.ts +206 -0
- package/dist/types/build/ooui/composition/control-model.d.ts +37 -0
- package/dist/types/build/ooui/composition/registry.d.ts +66 -0
- package/dist/types/build/ooui/composition/select.d.ts +63 -0
- package/dist/types/build/ooui/diagnostics/codes.d.ts +28 -0
- package/dist/types/build/ooui/diagnostics/error.d.ts +135 -0
- package/dist/types/build/ooui/diagnostics/format.d.ts +51 -0
- package/dist/types/build/ooui/diagnostics/index.d.ts +25 -0
- package/dist/types/build/ooui/diagnostics/issue.types.d.ts +56 -0
- package/dist/types/build/ooui/engine-slot.d.ts +41 -0
- package/dist/types/build/ooui/index.d.ts +286 -0
- package/dist/types/build/ooui/intent/derive-intent.d.ts +32 -0
- package/dist/types/build/ooui/intent/field-rules.d.ts +99 -0
- package/dist/types/build/ooui/intent/intent.types.d.ts +318 -0
- package/dist/types/build/ooui/intent/verb-events.d.ts +70 -0
- package/dist/types/build/ooui/page/budget.d.ts +28 -0
- package/dist/types/build/ooui/page/compose-page.d.ts +41 -0
- package/dist/types/build/ooui/page/index.d.ts +4 -0
- package/dist/types/build/ooui/page/page.types.d.ts +264 -0
- package/dist/types/build/ooui/page/region-row.d.ts +16 -0
- package/dist/types/build/ooui/semantic/expand-page-surface.d.ts +33 -0
- package/dist/types/build/ooui/semantic/kernel.types.d.ts +125 -0
- package/dist/types/build/ooui/semantic/normalize.d.ts +45 -0
- package/dist/types/build/ooui/semantic/origin.types.d.ts +95 -0
- package/dist/types/build/ooui/semantic/role-alias.d.ts +35 -0
- package/dist/types/build/ooui/semantic/shorthand.d.ts +60 -0
- package/dist/types/build/ooui/semantic/surface.types.d.ts +16 -0
- package/dist/types/build/ooui/semantic/validate-request.d.ts +19 -0
- package/dist/types/build/ooui/spatial/emit-utility.d.ts +43 -0
- package/dist/types/build/ooui/spatial/ir.types.d.ts +280 -0
- package/dist/types/build/ooui/spatial/registry.d.ts +110 -0
- package/dist/types/build/ooui/spatial/solve.d.ts +42 -0
- package/dist/types/build/ooui/spatial/utility.types.d.ts +191 -0
- package/dist/types/build/ooui/trace/index.d.ts +3 -0
- package/dist/types/build/ooui/trace/render.d.ts +42 -0
- package/dist/types/build/ooui/trace/source.types.d.ts +25 -0
- package/dist/types/build/ooui/trace/trace.types.d.ts +143 -0
- package/dist/types/client/component/component-expander.d.ts +1 -0
- package/dist/types/client/component/example-blocks.d.ts +0 -2
- package/dist/types/client/component/theme-component-tokens.d.ts +8 -5
- package/dist/types/client/data/data-object-resolver.d.ts +10 -2
- package/dist/types/client/diagnostics/telemetry-context.d.ts +0 -1
- package/dist/types/client/engine/soma-bootstrap.d.ts +123 -10
- package/dist/types/client/infra/http/IHttpClient.d.ts +0 -5
- package/dist/types/client/infra/http/SomaHttpService.d.ts +1 -1
- package/dist/types/client/infra/router/router-path.d.ts +0 -2
- package/dist/types/client/parser/blocks/namespace.d.ts +20 -0
- package/dist/types/client/parser/blocks/page-parser.d.ts +9 -0
- package/dist/types/client/parser/blocks/use-parser.d.ts +38 -4
- package/dist/types/client/parser/data-config-parser.d.ts +13 -0
- package/dist/types/client/parser/ui-config-parser.d.ts +1 -11
- package/dist/types/client/theme/scene-tokens.d.ts +9 -3
- package/dist/types/client/theme/theme-axes.d.ts +64 -1
- package/dist/types/client/theme/theme-engine.d.ts +13 -8
- package/dist/types/client/theme/tone-solver.d.ts +9 -5
- package/dist/types/index.d.ts +4 -6
- package/dist/types/server/declaration-safety.d.ts +7 -0
- package/dist/types/server/host/page-response-request.d.ts +0 -1
- package/dist/types/server/host/published-page-artifact-cache.d.ts +64 -0
- package/dist/types/server/ooui.d.ts +18 -0
- package/dist/types/server/page-assets.d.ts +7 -0
- package/dist/types/server/page-declaration.d.ts +14 -0
- package/dist/types/server/registry/asset-store.d.ts +112 -0
- package/dist/types/server/registry/declaration-precompiler.d.ts +23 -3
- package/dist/types/server/registry/index.d.ts +3 -1
- package/dist/types/server/registry/page-registry-store.d.ts +57 -4
- package/dist/types/server/registry/publish-asset-pin.d.ts +166 -0
- package/dist/types/server/registry/services/pages/List.d.ts +9 -3
- package/dist/types/server/registry/validation/compile-gate.d.ts +63 -0
- package/dist/types/shared/component/derive-sample.d.ts +14 -0
- package/dist/types/shared/container-breakpoints.d.ts +42 -0
- package/dist/types/shared/object-semantics.d.ts +42 -0
- package/dist/types/shared/ooui-declaration.d.ts +135 -0
- package/dist/types/shared/types/component-contract.types.d.ts +7 -6
- package/dist/types/shared/types/data-config.types.d.ts +86 -0
- package/dist/types/shared/types/domain.types.d.ts +0 -21
- package/dist/types/shared/types/engine.types.d.ts +0 -4
- package/dist/types/shared/types/layout-constraint.types.d.ts +1 -0
- package/dist/types/shared/types/ui-config.types.d.ts +157 -12
- package/next.config.js +106 -13
- package/package.json +29 -2
- package/core/client/host-bridge/index.ts +0 -27
- package/core/client/parser/yaml-loader.ts +0 -36
- package/core/shared/manifest/manifest-contract.ts +0 -12
- package/dist/types/client/host-bridge/index.d.ts +0 -9
- package/dist/types/client/parser/yaml-loader.d.ts +0 -21
- package/dist/types/shared/manifest/manifest-contract.d.ts +0 -4
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
// 发布资产的内容寻址存储:字节按哈希落库,页面版本只引用哈希。
|
|
2
|
+
//
|
|
3
|
+
// ── 这个失败模式为什么是静默的 ─────────────────────────────────────────
|
|
4
|
+
// Registry 存 `declaration` + `compiled` + 版本号,组件 CSS **一个字节都不在其中**——
|
|
5
|
+
// 它在 npm 包里,随组件实例化注入 `document.head`
|
|
6
|
+
// (`core/client/component/pack-styles.ts` 的 `injectOnce`)。
|
|
7
|
+
// 于是"回滚"只回滚了一半:页面回到 v3 的 DOM,样式却是**今天部署的 soma-ui 的**。
|
|
8
|
+
// 表现是页面照常打开、组件照常渲染、控制台一行都没有,只有间距、字号、断点跟 v3
|
|
9
|
+
// 上线那天不一样——而"不一样"没有任何东西去比对,因为库里根本没有 v3 那天的字节可比。
|
|
10
|
+
// 回滚回了一半,而回滚成功的回执是完整的:HTTP 200、新版本号、声明逐字正确。
|
|
11
|
+
//
|
|
12
|
+
// 演绎产物让这件事更急。产物是 `(声明, 引擎版本, 词表版本)` 的函数(架构 §19.3):
|
|
13
|
+
// 声明回滚了,后两个仍跟着当前部署走。同一份 v3 声明,今天演绎出的组件选择可以与
|
|
14
|
+
// 那天不同,而三者都不报错。
|
|
15
|
+
//
|
|
16
|
+
// ── 为什么内容寻址,而不是"给资产编个版本号" ─────────────────────────
|
|
17
|
+
// 编号需要有人维护"这个号对应哪份字节",而那个映射一旦与实际字节漂开,
|
|
18
|
+
// 漂开的方式恰好是静默的(号对上了,字节不对)。内容寻址让**名字就是字节的摘要**:
|
|
19
|
+
// 名字对上 ⇒ 字节对上,这是同一件事,没有第二份台账可漂。
|
|
20
|
+
// 参照 Bazel/Nix 的做法(动作/派生的输出按内容入库,消费方引用摘要)与 SDUI 的能力协商
|
|
21
|
+
// (客户端把自己"有什么"报上来,服务端据此裁剪),两者的共同点是:
|
|
22
|
+
// **身份由内容决定,不由声明者自称决定。**
|
|
23
|
+
//
|
|
24
|
+
// ── 摘要为什么用全长 64 位十六进制,而不是 §19.3 注入键那样的前 8 位 ──────
|
|
25
|
+
// `ooui:<sha256 前 8 位>`(`core/build/ooui/index.ts` 的 `oouiStyleKey`)只需要在
|
|
26
|
+
// **一次页面加载内**区分几张样式表,前 8 位(32 bit)够用。这里的摘要是**持久对象的
|
|
27
|
+
// 身份**:一个仓库的资产数以万计、生命周期以年计,32 bit 在几万个对象上就已经
|
|
28
|
+
// 有可观的碰撞概率(生日界 2^16 ≈ 6.5 万),而碰撞的表现是"取到了别人的 CSS"——
|
|
29
|
+
// 又是静默的。持久身份不省这几十个字节。
|
|
30
|
+
|
|
31
|
+
import fs from 'node:fs';
|
|
32
|
+
import path from 'node:path';
|
|
33
|
+
import { createHash } from 'node:crypto';
|
|
34
|
+
import { writeFileAtomic } from './registry-file-lock';
|
|
35
|
+
|
|
36
|
+
/** 摘要算法。只增不改:换算法要新起前缀,老摘要仍按老前缀能读回来。 */
|
|
37
|
+
export const SOMA_ASSET_DIGEST_ALGO = 'sha256';
|
|
38
|
+
|
|
39
|
+
/** 摘要形状:`sha256-<64 位小写十六进制>`。校验用它,不用 `startsWith`。 */
|
|
40
|
+
export const SOMA_ASSET_DIGEST_PATTERN = /^sha256-[0-9a-f]{64}$/;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* 单份资产体积上限 = 2,097,152 字节(2MiB)。
|
|
44
|
+
*
|
|
45
|
+
* 依据(实测,2026-09-10,`soma-ui/src/styles.ts`):
|
|
46
|
+
* - **全库** `SOMA_UI_CSS` = 1,351,112 字节(1319.4KB)。这是"某页引用了全部 325 个
|
|
47
|
+
* 组件"时组件 CSS 闭包的物理上界,任何合法闭包都必须能进来,所以上限必须高于它;
|
|
48
|
+
* - 325 个组件分片合计 1,303,452 字节,单片中位 4,197 / p90 6,251 / 最大 7,558;
|
|
49
|
+
* 13 个共享分片合计 33,376;基座 + 换肤抑制 14,284;
|
|
50
|
+
* - 实测五个真实页面(`soma-web/html/*.html`)的组件 CSS 闭包:
|
|
51
|
+
* assets 14,465 / index 18,607 / components 25,344 / generate 31,097 /
|
|
52
|
+
* architecture 40,785 字节——离全库上界还有 32 倍余量。
|
|
53
|
+
*
|
|
54
|
+
* 2MiB = 全库上界的 1.55 倍。比全库还大的"组件 CSS 闭包"在物理上不可能,
|
|
55
|
+
* 撞到这条线的只能是喂错了东西(把图片 base64、把整个 npm 包塞进来),那正是要拒的。
|
|
56
|
+
* 上限卡在入库这一刀,因为入库之后每次对账都要为它付一遍哈希代价。
|
|
57
|
+
*/
|
|
58
|
+
export const REGISTRY_ASSET_MAX_BYTES = 2_097_152;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* 资产类型。**只增不改**——它是引用方(钉子)的分类,不进摘要、不进路径。
|
|
62
|
+
* 同一份字节在两个类型下必须是同一个对象,否则内容寻址就有了两个真值。
|
|
63
|
+
*/
|
|
64
|
+
export type SomaAssetKind = 'component-css';
|
|
65
|
+
|
|
66
|
+
/** 一份入库资产的引用:摘要 + 字节数 + 类型。页面版本存的就是这个,不存字节。 */
|
|
67
|
+
export interface SomaAssetRef {
|
|
68
|
+
kind: SomaAssetKind;
|
|
69
|
+
/** `sha256-<64 hex>` */
|
|
70
|
+
digest: string;
|
|
71
|
+
/** UTF-8 字节数(对账时"少了多少"看得见,不必读回字节) */
|
|
72
|
+
bytes: number;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* 资产库。**同步 API**——`createPageVersionRecord` 是同步的,
|
|
77
|
+
* 而钉住资产必须与产生版本记录在同一步完成:分成两步就有了"版本已落库、
|
|
78
|
+
* 资产还没落库"的中间态,而那个中间态崩一次就留下一个指向不存在字节的钉子。
|
|
79
|
+
*/
|
|
80
|
+
export interface RegistryAssetStore {
|
|
81
|
+
/** 入库并返回引用。同摘要已在库中即复用,不重写。 */
|
|
82
|
+
put(kind: SomaAssetKind, content: string): SomaAssetRef;
|
|
83
|
+
/**
|
|
84
|
+
* 按摘要读回字节;不在库中返回 null。读回时**重算摘要**,不符即抛;
|
|
85
|
+
* 在库里却读不出来(权限、IO)同样抛——"读不到"不等于"不在"。
|
|
86
|
+
*/
|
|
87
|
+
read(digest: string): string | null;
|
|
88
|
+
/** 摘要是否在库中(对账判"这次漂移还能不能恢复");查询本身失败即抛,不答 false */
|
|
89
|
+
has(digest: string): boolean;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** 算一段文本的资产摘要。UTF-8 计,与 `Buffer.byteLength` 同一口径。 */
|
|
93
|
+
export function somaAssetDigest(content: string): string {
|
|
94
|
+
const hex = createHash(SOMA_ASSET_DIGEST_ALGO).update(content, 'utf8').digest('hex');
|
|
95
|
+
return `${SOMA_ASSET_DIGEST_ALGO}-${hex}`;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** 摘要形状校验。形状不对一律当"不是摘要"处理,不去猜。 */
|
|
99
|
+
export function isSomaAssetDigest(value: unknown): value is string {
|
|
100
|
+
return typeof value === 'string' && SOMA_ASSET_DIGEST_PATTERN.test(value);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* 入库前的体积/内容闸门。返回中文问题清单(空数组 = 可入库)。
|
|
105
|
+
*
|
|
106
|
+
* 条目不带域前缀:两个调用方(`put` 抛错、`pinPublishedAssets` 告警)各自已写
|
|
107
|
+
* `[soma-core][注册中心]`,条目再带一个 `[注册中心]` 就成了一行里两遍同一个域。
|
|
108
|
+
*/
|
|
109
|
+
export function assetIntakeIssues(content: unknown): string[] {
|
|
110
|
+
if (typeof content !== 'string') {
|
|
111
|
+
return ['资产内容必须是字符串'];
|
|
112
|
+
}
|
|
113
|
+
if (content === '') {
|
|
114
|
+
return ['资产内容为空;空资产不入库(钉子应当整份缺席,而不是钉一份空的)'];
|
|
115
|
+
}
|
|
116
|
+
const bytes = Buffer.byteLength(content, 'utf8');
|
|
117
|
+
if (bytes > REGISTRY_ASSET_MAX_BYTES) {
|
|
118
|
+
const kb = (n: number) => `${(n / 1024).toFixed(1)}KB`;
|
|
119
|
+
return [
|
|
120
|
+
`资产体积超限:当前 ${bytes} 字节(${kb(bytes)})/ 上限 `
|
|
121
|
+
+ `${REGISTRY_ASSET_MAX_BYTES} 字节(${kb(REGISTRY_ASSET_MAX_BYTES)})。`
|
|
122
|
+
+ '组件 CSS 闭包的物理上界是整库 1,351,112 字节;比整库还大只能是喂错了东西。',
|
|
123
|
+
];
|
|
124
|
+
}
|
|
125
|
+
return [];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* 「不在库中」只有一种读法:文件不存在(ENOENT)。
|
|
130
|
+
*
|
|
131
|
+
* 无权限、路径是目录、IO 错……都是**库本身**出了问题。把它们也读成"不在库中",
|
|
132
|
+
* 对账就会报"钉住的字节已不在资产库、无法按摘要恢复"——而字节其实就在盘上,
|
|
133
|
+
* 只是这个进程读不到。那句误报会把人引去回退组件库,而真正要修的是目录权限。
|
|
134
|
+
*/
|
|
135
|
+
function isAbsent(error: unknown): boolean {
|
|
136
|
+
return (error as NodeJS.ErrnoException | null)?.code === 'ENOENT';
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function errorMessage(error: unknown): string {
|
|
140
|
+
return error instanceof Error ? error.message : String(error);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* 摘要 → 相对路径。`sha256/<前 2 位>/<后 62 位>`。
|
|
145
|
+
*
|
|
146
|
+
* 分两级目录是为了别让一个目录里堆几万个条目(ext4 单目录线性查找会变慢,
|
|
147
|
+
* 而变慢不报错)。**不带类型后缀**:同一份字节在两个类型下必须是同一个文件,
|
|
148
|
+
* 后缀会把它变成两个,内容寻址随即有了两个真值。
|
|
149
|
+
*/
|
|
150
|
+
export function assetRelativePath(digest: string): string {
|
|
151
|
+
if (!isSomaAssetDigest(digest)) {
|
|
152
|
+
throw new Error(`[soma-core][注册中心] 资产摘要形状非法:${String(digest)}`);
|
|
153
|
+
}
|
|
154
|
+
const hex = digest.slice(`${SOMA_ASSET_DIGEST_ALGO}-`.length);
|
|
155
|
+
return path.join(SOMA_ASSET_DIGEST_ALGO, hex.slice(0, 2), hex.slice(2));
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** 共享文件系统资产库。写用原子落盘(临时文件 + rename),写一半被杀不留半个对象。 */
|
|
159
|
+
export class FileRegistryAssetStore implements RegistryAssetStore {
|
|
160
|
+
private readonly baseDir: string;
|
|
161
|
+
|
|
162
|
+
constructor(baseDir: string) {
|
|
163
|
+
this.baseDir = path.resolve(baseDir);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
directory(): string {
|
|
167
|
+
return this.baseDir;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
put(kind: SomaAssetKind, content: string): SomaAssetRef {
|
|
171
|
+
const issues = assetIntakeIssues(content);
|
|
172
|
+
if (issues.length > 0) {
|
|
173
|
+
throw new Error(`[soma-core][注册中心] 资产入库被拒:${issues.join(';')}`);
|
|
174
|
+
}
|
|
175
|
+
const digest = somaAssetDigest(content);
|
|
176
|
+
const bytes = Buffer.byteLength(content, 'utf8');
|
|
177
|
+
const filePath = path.join(this.baseDir, assetRelativePath(digest));
|
|
178
|
+
const existing = this.sizeOf(filePath);
|
|
179
|
+
if (existing !== null) {
|
|
180
|
+
// 同摘要已在库:不重写(内容寻址的幂等就在这一行)。
|
|
181
|
+
// 只核字节数——它是 O(1) 的 stat,而 sha256 相同且长度相同基本排除了
|
|
182
|
+
// "同名不同内容"。长度不符说明库被改坏了(或写了一半),那必须响:
|
|
183
|
+
// 一个名字与内容不符的内容寻址库,取到的每一份字节都是错的,而且不报错。
|
|
184
|
+
if (existing !== bytes) {
|
|
185
|
+
throw new Error(
|
|
186
|
+
`[soma-core][注册中心] 资产库内容与摘要不符:${digest} 落盘 ${existing} 字节、`
|
|
187
|
+
+ `本次 ${bytes} 字节。库已损坏,请核对 ${filePath} 后再发布。`,
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
return { kind, digest, bytes };
|
|
191
|
+
}
|
|
192
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
193
|
+
writeFileAtomic(filePath, content);
|
|
194
|
+
return { kind, digest, bytes };
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
read(digest: string): string | null {
|
|
198
|
+
if (!isSomaAssetDigest(digest)) return null;
|
|
199
|
+
const filePath = path.join(this.baseDir, assetRelativePath(digest));
|
|
200
|
+
let content: string;
|
|
201
|
+
try {
|
|
202
|
+
content = fs.readFileSync(filePath, 'utf8');
|
|
203
|
+
} catch (error) {
|
|
204
|
+
if (isAbsent(error)) return null;
|
|
205
|
+
throw new Error(
|
|
206
|
+
`[soma-core][注册中心] 资产读取失败:${filePath}(${errorMessage(error)})。`
|
|
207
|
+
+ '文件在库里但读不出来——先查资产目录的权限与挂载,再谈字节在不在。',
|
|
208
|
+
{ cause: error },
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
// 读回时重算摘要:内容寻址库最坏的坏法是"名字对、字节不对",
|
|
212
|
+
// 那时候取到的是别人的样式表,页面照常渲染。宁可这里抛,也不能把它发出去。
|
|
213
|
+
const actual = somaAssetDigest(content);
|
|
214
|
+
if (actual !== digest) {
|
|
215
|
+
throw new Error(
|
|
216
|
+
`[soma-core][注册中心] 资产库损坏:${filePath} 的实际摘要是 ${actual},`
|
|
217
|
+
+ `与文件名摘要 ${digest} 不符。`,
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
return content;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
has(digest: string): boolean {
|
|
224
|
+
if (!isSomaAssetDigest(digest)) return false;
|
|
225
|
+
return this.sizeOf(path.join(this.baseDir, assetRelativePath(digest))) !== null;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/** 落盘字节数;不在库中返回 null。判据与 `read` 同一条:只有 ENOENT 算"不在" */
|
|
229
|
+
private sizeOf(filePath: string): number | null {
|
|
230
|
+
try {
|
|
231
|
+
return fs.statSync(filePath).size;
|
|
232
|
+
} catch (error) {
|
|
233
|
+
if (isAbsent(error)) return null;
|
|
234
|
+
throw new Error(
|
|
235
|
+
`[soma-core][注册中心] 资产库查询失败:${filePath}(${errorMessage(error)})`,
|
|
236
|
+
{ cause: error },
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* 内存资产库。测试用,也给"页面走对象存储 CAS、资产还没接后端"的部署当显式占位——
|
|
244
|
+
* 它是**进程内**的,重启即空,所以对账会如实报"钉住的字节不在库中"而不是假装齐全。
|
|
245
|
+
*/
|
|
246
|
+
export class InMemoryRegistryAssetStore implements RegistryAssetStore {
|
|
247
|
+
private readonly objects = new Map<string, string>();
|
|
248
|
+
|
|
249
|
+
put(kind: SomaAssetKind, content: string): SomaAssetRef {
|
|
250
|
+
const issues = assetIntakeIssues(content);
|
|
251
|
+
if (issues.length > 0) {
|
|
252
|
+
throw new Error(`[soma-core][注册中心] 资产入库被拒:${issues.join(';')}`);
|
|
253
|
+
}
|
|
254
|
+
const digest = somaAssetDigest(content);
|
|
255
|
+
const bytes = Buffer.byteLength(content, 'utf8');
|
|
256
|
+
const existing = this.objects.get(digest);
|
|
257
|
+
if (existing !== undefined) {
|
|
258
|
+
if (existing !== content) {
|
|
259
|
+
throw new Error(`[soma-core][注册中心] 资产库内容与摘要不符:${digest}`);
|
|
260
|
+
}
|
|
261
|
+
return { kind, digest, bytes };
|
|
262
|
+
}
|
|
263
|
+
this.objects.set(digest, content);
|
|
264
|
+
return { kind, digest, bytes };
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
read(digest: string): string | null {
|
|
268
|
+
const content = this.objects.get(digest);
|
|
269
|
+
if (content === undefined) return null;
|
|
270
|
+
const actual = somaAssetDigest(content);
|
|
271
|
+
if (actual !== digest) {
|
|
272
|
+
throw new Error(`[soma-core][注册中心] 资产库损坏:${digest} 的实际摘要是 ${actual}`);
|
|
273
|
+
}
|
|
274
|
+
return content;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
has(digest: string): boolean {
|
|
278
|
+
return this.objects.has(digest);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/** 测试与巡检用:库里有多少个对象 */
|
|
282
|
+
size(): number {
|
|
283
|
+
return this.objects.size;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// ---------------------------------------------------------------------------
|
|
288
|
+
// 进程级共享资产库
|
|
289
|
+
// ---------------------------------------------------------------------------
|
|
290
|
+
|
|
291
|
+
let sharedStore: RegistryAssetStore | undefined;
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* 缺省资产目录。
|
|
295
|
+
*
|
|
296
|
+
* 取 `SOMA_REGISTRY_ASSET_DIR`;没配就取**页面目录的同级 `assets`**。
|
|
297
|
+
* 为什么要跟着页面目录走:宿主把 `SOMA_PAGE_REGISTRY_DIR` 挪到共享卷上,资产若仍落在
|
|
298
|
+
* 进程本地的 `data/soma-runtime/assets`,表现是"发布成功、钉子有摘要、
|
|
299
|
+
* 另一个实例对账时说字节不在库中"——而那台机器上确实不在。
|
|
300
|
+
* 两份存储必须一起挪,所以缺省就绑在一起。
|
|
301
|
+
*
|
|
302
|
+
* **页面走对象存储 CAS 的部署必须显式换库**:那条路径
|
|
303
|
+
* (`ConditionalPageRegistryRepository`)的页面数据在对象存储里,而这里的缺省后端是
|
|
304
|
+
* 本地文件系统——多实例部署下每台机器各写一份局部资产,对账在"没写过这份"的实例上
|
|
305
|
+
* 一律报不可恢复。这条缺省不会报错,所以写在这里:
|
|
306
|
+
* 那种部署要 `setRegistryAssetStore(自己的对象存储后端)`。
|
|
307
|
+
*/
|
|
308
|
+
export function defaultRegistryAssetDir(): string {
|
|
309
|
+
const explicit = process.env.SOMA_REGISTRY_ASSET_DIR;
|
|
310
|
+
if (typeof explicit === 'string' && explicit.trim() !== '') return explicit;
|
|
311
|
+
const pages = process.env.SOMA_PAGE_REGISTRY_DIR;
|
|
312
|
+
if (typeof pages === 'string' && pages.trim() !== '') {
|
|
313
|
+
return path.join(pages, '..', 'assets');
|
|
314
|
+
}
|
|
315
|
+
return path.join('data', 'soma-runtime', 'assets');
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/** 共享资产库(缺省文件后端;目录见 `defaultRegistryAssetDir`) */
|
|
319
|
+
export function getRegistryAssetStore(): RegistryAssetStore {
|
|
320
|
+
sharedStore ??= new FileRegistryAssetStore(defaultRegistryAssetDir());
|
|
321
|
+
return sharedStore;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/** 替换 / 复位共享资产库(测试与自定义后端;不传参即复位,下次访问按当前环境重建) */
|
|
325
|
+
export function setRegistryAssetStore(store?: RegistryAssetStore | null): void {
|
|
326
|
+
sharedStore = store ?? undefined;
|
|
327
|
+
}
|
|
@@ -10,9 +10,23 @@
|
|
|
10
10
|
// 它挂了就当没有这份缓存——绝不能让一个性能优化变成发布的新失败面。
|
|
11
11
|
// 3. **只编译纯数据部分**。html 不编译(它本来就是字符串),
|
|
12
12
|
// locale / appConfig 归宿主而不归声明。
|
|
13
|
+
//
|
|
14
|
+
// ── 为什么"编译器版本对上"还不够(`assetSupplyKey` 那道闸) ────────────────
|
|
15
|
+
// 产物是 `(声明, 引擎版本, 词表版本)` 的函数(架构 §19.3)。`compilerVersion` 只锁住
|
|
16
|
+
// 中间那一项:引擎住在 soma-core,版本随本包走。**词表不住在这里**——演绎的候选表与
|
|
17
|
+
// 空间词汇住在组件库(soma-ui / 业务包),`verify-ooui-dep-graph` 的 `CORE-IMPORTS-UI`
|
|
18
|
+
// 明令 core 不许 import 它们。于是 soma-ui 升一个版本、soma-core 一动不动,
|
|
19
|
+
// 同一份声明能编出**不同的产物**,而版本闸恒真、缓存照用。
|
|
20
|
+
// 表现是:某一页的演绎结果换了一批组件或换了一套断点,`compilerVersion` 分毫未变,
|
|
21
|
+
// 没有一行日志。所以第三道闸判"供货是不是同一批"——判据由宿主报上来
|
|
22
|
+
// (`publish-asset-pin.ts` 的 `packs`),报不上来就不判,而不是拿一个猜的键去判。
|
|
13
23
|
|
|
14
24
|
import { createRequire } from 'node:module';
|
|
15
|
-
import {
|
|
25
|
+
import {
|
|
26
|
+
compilePageDeclaration,
|
|
27
|
+
type CompiledPageDeclaration,
|
|
28
|
+
} from '../../build/compiler/page-declaration-compiler';
|
|
29
|
+
import { currentAssetSupplyKey } from './publish-asset-pin';
|
|
16
30
|
import type { PageRegistryDeclaration } from './page-registry-store';
|
|
17
31
|
|
|
18
32
|
/**
|
|
@@ -42,6 +56,11 @@ function readCoreVersion(): string {
|
|
|
42
56
|
/** 落库的完整运行时产物。 */
|
|
43
57
|
export interface CompiledDeclaration {
|
|
44
58
|
compilerVersion: string;
|
|
59
|
+
/**
|
|
60
|
+
* 供货指纹(词表版本那一维,可选)。缺席 = 编译那一刻宿主没报供货版本,
|
|
61
|
+
* 此时第三道闸**不判**——见文件头。只增不改:老产物没有这个键,判据自动降级为原来两条。
|
|
62
|
+
*/
|
|
63
|
+
assetSupplyKey?: string;
|
|
45
64
|
uiConfig?: unknown;
|
|
46
65
|
eventConfig?: unknown;
|
|
47
66
|
triggerConfig?: unknown;
|
|
@@ -53,20 +72,28 @@ export interface CompiledDeclaration {
|
|
|
53
72
|
/**
|
|
54
73
|
* 把统一声明一次编译成运行时可直接消费的完整配置对象。
|
|
55
74
|
* 编译失败返回 null,不产生可被误用的半成品。
|
|
75
|
+
*
|
|
76
|
+
* `compiledPage`:调用方手里已经有**这同一份** `declaration` 的编译结果时传进来
|
|
77
|
+
* (发布路径上编译闸门那一次,见 `page-registry-store` 的 `normalizeDeclaration`),
|
|
78
|
+
* 这里就不再编第二遍。产物由下面同一段映射得出,与自己编出来的逐字相同;
|
|
79
|
+
* 供货指纹仍在此刻读取,与自己编时同一时点。保证它编的是同一份声明,是传入方的责任。
|
|
56
80
|
*/
|
|
57
81
|
export function precompileDeclaration(
|
|
58
82
|
declaration: PageRegistryDeclaration,
|
|
83
|
+
compiledPage?: CompiledPageDeclaration,
|
|
59
84
|
): CompiledDeclaration | null {
|
|
60
85
|
try {
|
|
61
|
-
const page = compilePageDeclaration({
|
|
86
|
+
const page = compiledPage ?? compilePageDeclaration({
|
|
62
87
|
html: declaration.html,
|
|
63
88
|
uiYaml: declaration.uiYaml,
|
|
64
89
|
...(declaration.eventYaml ? { eventYaml: declaration.eventYaml } : {}),
|
|
65
90
|
...(declaration.styleYaml ? { styleYaml: declaration.styleYaml } : {}),
|
|
66
91
|
...(declaration.dataYaml ? { dataYaml: declaration.dataYaml } : {}),
|
|
67
92
|
});
|
|
93
|
+
const supplyKey = currentAssetSupplyKey();
|
|
68
94
|
return {
|
|
69
95
|
compilerVersion: DECLARATION_COMPILER_VERSION,
|
|
96
|
+
...(supplyKey ? { assetSupplyKey: supplyKey } : {}),
|
|
70
97
|
uiConfig: page.uiConfig,
|
|
71
98
|
eventConfig: page.eventConfig,
|
|
72
99
|
triggerConfig: page.triggers,
|
|
@@ -81,17 +108,33 @@ export function precompileDeclaration(
|
|
|
81
108
|
}
|
|
82
109
|
|
|
83
110
|
/**
|
|
84
|
-
*
|
|
111
|
+
* 消费端的版本闸:编译器版本或供货版本对不上就整份丢弃。
|
|
85
112
|
* 这是"缓存不是真理"那条纪律的执行点。
|
|
113
|
+
*
|
|
114
|
+
* 三条判据:
|
|
115
|
+
* 1. 编译器版本(引擎那一维)必须逐字相同;
|
|
116
|
+
* 2. 结构必须齐(`uiConfig` / `eventConfig` 都在);
|
|
117
|
+
* 3. **供货指纹(词表那一维)不许相左**——但只在**两侧都有键**时才判。
|
|
118
|
+
* 单侧有键就不判是刻意的:老产物没有这个键,一律判假会让每次取页都重编译一遍
|
|
119
|
+
* (功能全对、只有耗时在涨,正是这条路径上最典型的静默退化);
|
|
120
|
+
* 而运行时问不到自己的供货版本时判假,等于拿"我不知道"当"不一致"。
|
|
121
|
+
* 失败方向仍然安全:第三道闸判假只导致**重新编译**,不导致拒绝。
|
|
86
122
|
*/
|
|
87
123
|
export function isCompiledUsable(
|
|
88
124
|
compiled: CompiledDeclaration | null | undefined,
|
|
89
125
|
runtimeVersion = DECLARATION_COMPILER_VERSION,
|
|
126
|
+
runtimeSupplyKey = currentAssetSupplyKey(),
|
|
90
127
|
): boolean {
|
|
91
128
|
if (!compiled || typeof compiled !== 'object') return false;
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
129
|
+
if (compiled.compilerVersion !== runtimeVersion) return false;
|
|
130
|
+
if (compiled.uiConfig === undefined || compiled.eventConfig === undefined) return false;
|
|
131
|
+
const stored = compiled.assetSupplyKey;
|
|
132
|
+
if (typeof stored === 'string' && stored !== ''
|
|
133
|
+
&& typeof runtimeSupplyKey === 'string' && runtimeSupplyKey !== ''
|
|
134
|
+
&& stored !== runtimeSupplyKey) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
return true;
|
|
95
138
|
}
|
|
96
139
|
|
|
97
140
|
function message(error: unknown): string {
|
|
@@ -103,6 +103,45 @@ export {
|
|
|
103
103
|
DECLARATION_COMPILER_VERSION,
|
|
104
104
|
type CompiledDeclaration,
|
|
105
105
|
} from './declaration-precompiler';
|
|
106
|
+
export {
|
|
107
|
+
assetIntakeIssues,
|
|
108
|
+
assetRelativePath,
|
|
109
|
+
defaultRegistryAssetDir,
|
|
110
|
+
FileRegistryAssetStore,
|
|
111
|
+
getRegistryAssetStore,
|
|
112
|
+
InMemoryRegistryAssetStore,
|
|
113
|
+
isSomaAssetDigest,
|
|
114
|
+
REGISTRY_ASSET_MAX_BYTES,
|
|
115
|
+
setRegistryAssetStore,
|
|
116
|
+
somaAssetDigest,
|
|
117
|
+
SOMA_ASSET_DIGEST_ALGO,
|
|
118
|
+
SOMA_ASSET_DIGEST_PATTERN,
|
|
119
|
+
type RegistryAssetStore,
|
|
120
|
+
type SomaAssetKind,
|
|
121
|
+
type SomaAssetRef,
|
|
122
|
+
} from './asset-store';
|
|
123
|
+
export {
|
|
124
|
+
ASSET_PIN_VERSION,
|
|
125
|
+
assembleComponentCss,
|
|
126
|
+
assetPinByteSize,
|
|
127
|
+
assetSupplyDriftNotice,
|
|
128
|
+
currentAssetSupply,
|
|
129
|
+
currentAssetSupplyKey,
|
|
130
|
+
pinnedAssetMembers,
|
|
131
|
+
pinPublishedAssets,
|
|
132
|
+
reconcilePinnedAssets,
|
|
133
|
+
setPublishedAssetSource,
|
|
134
|
+
type AssembledComponentCss,
|
|
135
|
+
type PinnableDeclaration,
|
|
136
|
+
type PinPublishedAssetsOptions,
|
|
137
|
+
type PublishedAssetSource,
|
|
138
|
+
type PublishedAssetSupply,
|
|
139
|
+
type ReconcilableRecord,
|
|
140
|
+
type SomaAssetPin,
|
|
141
|
+
type SomaAssetReconciliation,
|
|
142
|
+
type SomaAssetReconcileStatus,
|
|
143
|
+
type SomaPinnedAsset,
|
|
144
|
+
} from './publish-asset-pin';
|
|
106
145
|
export { scanDeclarationSafety, type ScannableDeclaration } from './validation/declaration-safety-scan';
|
|
107
146
|
export { RegistryError } from './registry-error';
|
|
108
147
|
export {
|
|
@@ -125,7 +164,14 @@ export {
|
|
|
125
164
|
type ApiRegistryStoreOptions,
|
|
126
165
|
} from './api-registry-store';
|
|
127
166
|
export { scanCredentialLeak, type CredentialScannable } from './validation/credential-ban';
|
|
128
|
-
export {
|
|
167
|
+
export {
|
|
168
|
+
dryRunCompile,
|
|
169
|
+
dryRunCompileWithDiagnostics,
|
|
170
|
+
type CompilableDeclaration,
|
|
171
|
+
type CompileGateResult,
|
|
172
|
+
type SomaCompileDiagnostic,
|
|
173
|
+
type SomaCompileDiagnosticSource,
|
|
174
|
+
} from './validation/compile-gate';
|
|
129
175
|
export {
|
|
130
176
|
collectReferencedComponents,
|
|
131
177
|
scanUnknownComponents,
|
|
@@ -128,7 +128,8 @@ export class ConditionalPageRegistryRepository implements PageRegistryRepository
|
|
|
128
128
|
): Promise<PublishResult> {
|
|
129
129
|
const safeName = assertPageName(name);
|
|
130
130
|
const normalizedOptions = normalizePublishOptions(options);
|
|
131
|
-
|
|
131
|
+
// 闸门那一次的编译结果一路带到落库:CAS 冲突重试也只是换版本号,不重编同一份声明
|
|
132
|
+
const { declaration: normalized, compiledPage } = normalizeDeclaration(declaration);
|
|
132
133
|
return this.mutate(safeName, (aggregate) => {
|
|
133
134
|
const record = createPageVersionRecord(safeName, aggregate.versions, {
|
|
134
135
|
declaration: normalized,
|
|
@@ -137,6 +138,7 @@ export class ConditionalPageRegistryRepository implements PageRegistryRepository
|
|
|
137
138
|
tags: normalizedOptions.tags ?? [],
|
|
138
139
|
meta: normalizedOptions.meta,
|
|
139
140
|
operator: normalizedOptions.operator,
|
|
141
|
+
compiledPage,
|
|
140
142
|
}, this.now());
|
|
141
143
|
aggregate.versions.push(record);
|
|
142
144
|
return { value: { record: cloneRecord(record) }, aggregate };
|
|
@@ -161,7 +163,9 @@ export class ConditionalPageRegistryRepository implements PageRegistryRepository
|
|
|
161
163
|
const latest = aggregate.versions[aggregate.versions.length - 1];
|
|
162
164
|
if (!latest) continue;
|
|
163
165
|
if (options.publishedOnly && latest.status !== 'published') continue;
|
|
164
|
-
if (
|
|
166
|
+
if (options.status !== undefined) {
|
|
167
|
+
if (latest.status !== options.status) continue;
|
|
168
|
+
} else if (!options.includeArchived && latest.status === 'archived') continue;
|
|
165
169
|
if (options.app !== undefined && latest.app !== options.app) continue;
|
|
166
170
|
const title = latest.meta?.title;
|
|
167
171
|
if (keyword) {
|