soma-kit 0.1.16 → 0.1.18
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/package.json +2 -2
- package/spec/kit-grammar.json +42 -1
- package/src/app/component-gate.ts +437 -55
- package/src/app/define-kit-app.ts +75 -6
- package/src/app/internal-lab.ts +90 -0
- package/src/app/server.ts +40 -7
- package/src/biz/define.ts +30 -1
- package/src/biz/master-sub/shell.ts +6 -9
- package/src/biz/shared/compile-helpers.ts +24 -2
- package/src/biz/types.ts +8 -0
- package/src/generated/kit-grammar-runtime.ts +6 -2
- package/src/object-renderer/table-actions.ts +3 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "soma-kit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
4
4
|
"description": "SOMA 第三条 UI 路线:写死模板与规则,DSL 显式传入,基础组件 + 数据组件",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"jiti": "1.21.7",
|
|
54
54
|
"js-yaml": "4.3.2",
|
|
55
55
|
"soma-core": "^2.2.11",
|
|
56
|
-
"soma-foundation": "^0.1.
|
|
56
|
+
"soma-foundation": "^0.1.8",
|
|
57
57
|
"tailwindcss": "^4.1.0",
|
|
58
58
|
"typescript": "5.9.3"
|
|
59
59
|
},
|
package/spec/kit-grammar.json
CHANGED
|
@@ -880,7 +880,7 @@
|
|
|
880
880
|
"cardsList": "grid gap-4",
|
|
881
881
|
"cardsItem": "rounded-card border-edge border-border-container bg-surface p-card transition-shadow hover:shadow-sm",
|
|
882
882
|
"stackList": "flex flex-col gap-4",
|
|
883
|
-
"stackItem": "rounded-card border-edge border-border-container bg-surface p-3
|
|
883
|
+
"stackItem": "rounded-card border-edge border-border-container bg-surface p-3",
|
|
884
884
|
"compactList": "@container flex flex-col",
|
|
885
885
|
"compactItem": "inset-row flex flex-wrap items-center gap-x-3 gap-y-1 px-3 in-data-kit-axis:px-card py-2 border-b-hairline border-border-subtle last:border-b-0 text-sm text-fg transition-colors hover:bg-state-layer-row-hover active:bg-state-layer-press data-kit-selected:bg-state-layer-selected data-kit-selected:sel-bar data-kit-selected:hover:bg-state-layer-tonal-hover data-kit-fresh:bg-primary-soft",
|
|
886
886
|
"compactBody": "flex min-w-40 flex-1 flex-col gap-0.5",
|
|
@@ -6061,6 +6061,10 @@
|
|
|
6061
6061
|
"KIT-APP-013": "应用代码直接 import \"soma-core\" 或 \"soma-core/*\"(含 import type、export … from、动态 import、require);应用唯一的接触面是 soma-kit/app(tests/ 与 test/ 目录豁免)",
|
|
6062
6062
|
"KIT-APP-014": "应用组件的 controllerFactory 必须由 createKitController((api) => ({ ... })) 生成(不接受纯声明式无控制器组件或手写工厂)",
|
|
6063
6063
|
"KIT-APP-015": "应用违反双平面与四层分层边界(R-APP-1/2/3):客户端面(web/、soma.app.ts、views/、actions/、components/)静态引用了服务端面(bff/、api/、config/、soma.server.*),或服务端面反向引用客户端面,或 shared/ 引用了端侧或 Node 内置模块,或 BFF 下层(foundation/、domain/)反向引用上层,或页面视图 views/*.view.ts 之间横向互引",
|
|
6064
|
+
"KIT-APP-016": "业务应用禁止注册非业务/非数据的野生 baseComponents(基础控件一律复用官方闭集);外部界面扩展仅开放两档:① 业务组件 bizComponents(静态画布 + 按 DSL 装配,可自带私有 dataComponents);② 纯数据驱动自定义数据组件 staticObjectComponents(一份数据一个组件、数据进事件出,供业务组件 DSL 槽位按名选用)",
|
|
6065
|
+
"KIT-APP-017": "禁止野生样式表与野生页面 HTML:应用目录不得出现 .css / .scss / .less / .sass / .styl 文件或在源码中 import / export / require 样式表,kit.app.yaml 不得配置 style: 外链样式,且 pages/、src/web/、views/、components/ 下不得手写 .html / .htm;样式外观统一走 kit.app.yaml#theme 14 维 DSL 与 Tailwind 刻度类",
|
|
6066
|
+
"KIT-APP-018": "禁止命令式浮层、非组件 DOM 构造与伪造框架内部符号:全应用禁止调用 .showModal() / .showPopover() / createElement('dialog') / document.body.append* 及引用或伪造 Symbol.for('soma-kit.*');components/ 之外的源码禁止调用 createElement / createElementNS / insertAdjacentHTML 或写入 innerHTML / outerHTML",
|
|
6067
|
+
"KIT-APP-019": "自定义业务组件或其私有协作组件违反纯声明式装数据契约:业务组件未经 defineKitBizComponent 构造、组件源码内手写 <table> / <thead> / <form> / <dialog> 或直接调用 fetch() / new XMLHttpRequest,或业务组件源码硬编码 '/api/...' 接口路径(必须从页面 input.objects 的 behavior.from 与具名动作读取)",
|
|
6064
6068
|
"KIT-COMP-002": "业务组件定义非法:名字不是 PascalCase、没有必填角色槽、areas 重名、缺 compile(),或 composeKitBizComponents 的子部件 / 角色映射不成立",
|
|
6065
6069
|
"KIT-COMP-003": "组件候选类 / rootClass / slotClass 含非法 Tailwind 类(不在刻度内或带方括号任意值)",
|
|
6066
6070
|
"KIT-COMP-004": "数据组件定义 / 包装 / 登记非法:缺 define()、accept 不是 single / list、被包装组件无控制器、登记名与契约名不一致、layer 不是 data、事件名不是 snake_case,或 composeKitDataComponents 没有子部件",
|
|
@@ -6369,6 +6373,43 @@
|
|
|
6369
6373
|
"bad": "// src/web/views/orders.view.ts\nimport { orderRepo } from '../../bff/foundation/repositories/orderRepo';",
|
|
6370
6374
|
"good": "// src/web/views/orders.view.ts\nimport type { OrderDto } from '../../shared/contracts/orders';"
|
|
6371
6375
|
},
|
|
6376
|
+
"KIT-APP-016": {
|
|
6377
|
+
"causes": [
|
|
6378
|
+
"在 defineKitApp({ baseComponents }) 中注册了非业务/非数据的野生基础组件",
|
|
6379
|
+
"在 kit.app.yaml 中声明了 baseComponents"
|
|
6380
|
+
],
|
|
6381
|
+
"bad": "defineKitApp({\n baseComponents: {\n AppWildButton: declareKitUses(AppWildButton, [])\n }\n});",
|
|
6382
|
+
"good": "// 方式 ①:纯数据驱动自定义数据组件(一份数据一个组件、数据进事件出,供页面 staticComponent 槽位按名选用)\ndefineKitApp({\n staticObjectComponents: {\n AppDocAnnotationView: { define: declareKitUses(AppDocAnnotationView, ['Button'], ['flex', 'gap-2']), accept: 'single' }\n }\n});\n// 方式 ②:自定义业务组件(可自带私有 dataComponents 与 candidates)\ndefineKitApp({\n bizComponents: {\n AnnotationBoard: defineKitBizComponent({\n kind: 'AnnotationBoard',\n roles: { document: { required: true, views: ['summary'] } },\n areas: ['root', 'canvas'],\n dataComponents: { AnnotationCanvasCore: declareKitUses(AnnotationCanvasCore, ['Button'], ['flex', 'gap-2']) },\n candidates: ['rounded-card', 'bg-surface'],\n compile(input, ctx) { /* 按 input.objects 编排返回 KitFragment */ }\n })\n }\n});"
|
|
6383
|
+
},
|
|
6384
|
+
"KIT-APP-017": {
|
|
6385
|
+
"causes": [
|
|
6386
|
+
"应用目录下存在手写的 .css / .scss / .less / .sass / .styl 样式文件",
|
|
6387
|
+
"TS / JS 源码通过 import / export / require 加载了样式表文件",
|
|
6388
|
+
"kit.app.yaml 配置了 style: 自定义 CSS 文件路径",
|
|
6389
|
+
"pages/、src/web/、views/ 或 components/ 目录下存在手写 .html / .htm 页面文件"
|
|
6390
|
+
],
|
|
6391
|
+
"bad": "# kit.app.yaml\nstyle: custom.css\n// 或源码中 import './override.css' / pages/dashboard.html",
|
|
6392
|
+
"good": "# kit.app.yaml\ntheme:\n preset: portal\n palette: blue\n layering: paper\n# 页面一律写 pages/*.kit.yaml,样式由框架主题引擎与 Tailwind 刻度类统一生成"
|
|
6393
|
+
},
|
|
6394
|
+
"KIT-APP-018": {
|
|
6395
|
+
"causes": [
|
|
6396
|
+
"调用了 .showModal()、.showPopover()、createElement('dialog') 或 document.body.appendChild(...) 构造命令式浮层",
|
|
6397
|
+
"在 actions/、views/、api/ 或 soma.app.ts 等非 components/ 目录中调用 createElement / createElementNS / insertAdjacentHTML 或写入 innerHTML / outerHTML",
|
|
6398
|
+
"在外部应用源码中引用或伪造 Symbol.for('soma-kit.*') 框架内部符号"
|
|
6399
|
+
],
|
|
6400
|
+
"bad": "// actions/open-modal.ts\nconst dlg = document.createElement('dialog');\ndocument.body.appendChild(dlg);\ndlg.showModal();",
|
|
6401
|
+
"good": "# pages/orders.kit.yaml\noverlays:\n edit:\n kind: dialog\n title: 编辑订单\n view: { form: { fields: [title] } }"
|
|
6402
|
+
},
|
|
6403
|
+
"KIT-APP-019": {
|
|
6404
|
+
"causes": [
|
|
6405
|
+
"bizComponents 中登记了未经 defineKitBizComponent(...) 构造的裸对象",
|
|
6406
|
+
"自定义组件或业务组件私有协作内核中手写了 <table> / <thead> / <form> / <dialog> 规整结构",
|
|
6407
|
+
"自定义组件源码中直接调用 fetch() 或 new XMLHttpRequest 绕过数据与动作管道",
|
|
6408
|
+
"defineKitBizComponent 所在文件在函数体内硬编码了 '/api/...' 接口路径"
|
|
6409
|
+
],
|
|
6410
|
+
"bad": "// components/BadBoard.ts\nconst html = '<table><thead><tr><th>标题</th></tr></thead></table>';\nawait fetch('/api/orders');",
|
|
6411
|
+
"good": "// 业务组件只负责编排 input.objects 与私有协作内核;数据读取由页面 behavior.from 声明,写操作交 defineKitActions\nconst from = input.objects.orders.behavior?.from;"
|
|
6412
|
+
},
|
|
6372
6413
|
"KIT-COMP-002": {
|
|
6373
6414
|
"causes": [
|
|
6374
6415
|
"kind 小写开头",
|