soma-core 2.2.5 → 2.2.7

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.
Files changed (283) hide show
  1. package/README.md +5 -6
  2. package/bin/soma.cjs +2 -2
  3. package/core/build/compiler/flat-page.ts +16 -0
  4. package/core/build/compiler/full-manifest-builder.ts +0 -3
  5. package/core/build/compiler/page-assets.ts +0 -1
  6. package/core/build/compiler/page-closure.ts +245 -0
  7. package/core/build/compiler/page-declaration-compiler.ts +2 -5
  8. package/core/build/compiler/soma-precompile.js +1972 -3312
  9. package/core/build/compiler/soma-precompile.ts +4 -7
  10. package/core/build/component-tree/artifact-codec.ts +4 -8
  11. package/core/build/lsp/soma-declaration.cjs +1 -1
  12. package/core/build/lsp/std-completion.generated.json +3 -3
  13. package/core/client/a11y/a11y-config.ts +2 -1
  14. package/core/client/a11y/dom-id.ts +1 -1
  15. package/core/client/base/SomaHttpClient.ts +11 -3
  16. package/core/client/base/SomaPageRootBase.ts +6 -0
  17. package/core/client/base/defineSomaView.ts +178 -0
  18. package/core/client/base/index.ts +13 -0
  19. package/core/client/base/view-context.ts +328 -0
  20. package/core/client/behavior/adapter-collection.ts +2 -2
  21. package/core/client/compiler/manifest-compiler.ts +5 -36
  22. package/core/client/component/component-definition.types.ts +2 -1
  23. package/core/client/component/component-manager.ts +110 -20
  24. package/core/client/component/structure-adapter.ts +3 -7
  25. package/core/client/container/IContainerAdapter.ts +4 -0
  26. package/core/client/container/SomaContainerAdapter.ts +52 -3
  27. package/core/client/data/data-object-resolver.ts +523 -184
  28. package/core/client/data/data-write-actions.ts +79 -15
  29. package/core/client/data/format-config.ts +3 -1
  30. package/core/client/data/region-scope-port.ts +11 -0
  31. package/core/client/engine/asset-resolver.ts +2 -5
  32. package/core/client/engine/dom-renderer.ts +7 -40
  33. package/core/client/engine/event-engine.ts +29 -108
  34. package/core/client/engine/property-watcher.ts +1 -1
  35. package/core/client/engine/reactive-proxy.ts +78 -17
  36. package/core/client/engine/runtime-builder.ts +0 -14
  37. package/core/client/engine/scope-resolver.ts +18 -0
  38. package/core/client/engine/soma-bootstrap.ts +387 -99
  39. package/core/client/engine/style-binder.ts +49 -106
  40. package/core/client/engine/timer-engine.ts +11 -1
  41. package/core/client/host-bridge/load-host-domain-class.ts +2 -1
  42. package/core/client/infra/http/SomaHttpService.ts +15 -4
  43. package/core/client/infra/i18n/pack-locales.ts +2 -2
  44. package/core/client/infra/notify/DefaultNotifyService.ts +2 -2
  45. package/core/client/mount/domain-rule.ts +7 -3
  46. package/core/client/mount/mount-page.ts +38 -5
  47. package/core/client/mount/types.ts +2 -0
  48. package/core/client/parser/confirm-spec.ts +100 -7
  49. package/core/client/parser/data-config-parser.ts +28 -211
  50. package/core/client/parser/pipeline-parser.ts +16 -60
  51. package/core/client/parser/style-config-parser.ts +101 -95
  52. package/core/client/parser/timer-parser.ts +21 -0
  53. package/core/client/parser/ui-config-parser.ts +64 -12
  54. package/core/client/registry/declaration-renderer.ts +1 -1
  55. package/core/client/render-ports/hide-transition.ts +9 -0
  56. package/core/client/render-ports/index.ts +4 -0
  57. package/core/client/render-ports/notify-renderer.ts +2 -1
  58. package/core/client/runtime/SomaRuntimeServices.ts +2 -1
  59. package/core/client/runtime/SomaSnapshotStore.ts +5 -0
  60. package/core/client/security/url-guard.ts +71 -11
  61. package/core/client/validation/async-check-registry.ts +2 -1
  62. package/core/client/validation/contract-validator.ts +2 -6
  63. package/core/client/validation/field-rules.ts +3 -13
  64. package/core/client/validation/object-rules.ts +2 -10
  65. package/core/index.ts +17 -39
  66. package/core/inspect/check-product.ts +5 -5
  67. package/core/inspect/runtime.ts +2 -1
  68. package/core/server/api/dispatch-service-api.ts +35 -36
  69. package/core/server/api/load-host-service.ts +8 -4
  70. package/core/server/api/paged-list.ts +259 -0
  71. package/core/server/compile-port.ts +1 -1
  72. package/core/server/host/app-config-composer.ts +2 -1
  73. package/core/server/host/empty-host-bootstrap.mjs +3 -0
  74. package/core/server/host/host-assembly-entry.ts +1 -0
  75. package/core/server/host/host-assembly.ts +50 -3
  76. package/core/server/host/host-caller.ts +2 -1
  77. package/core/server/host/host-dir.ts +9 -0
  78. package/core/server/host/host-response-headers.ts +2 -1
  79. package/core/server/host/invoke-host-request-hook.ts +28 -4
  80. package/core/server/host/published-page-assets.ts +2 -1
  81. package/core/server/host/resolve-host-request-hook.ts +25 -7
  82. package/core/server/host/server-page-assets.ts +4 -4
  83. package/core/server/host/source-aliases.cjs +345 -0
  84. package/core/server/host/source-aliases.ts +32 -0
  85. package/core/server/host/source-packages.cjs +1 -0
  86. package/core/server/host/virtual-pages.ts +3 -2
  87. package/core/server/infra/cache/ServerFileCache.ts +83 -10
  88. package/core/server/node.ts +10 -0
  89. package/core/server/registry/api-registry-store.ts +3 -1
  90. package/core/server/registry/declaration-precompiler.ts +0 -2
  91. package/core/server/registry/page-registry-repository.ts +2 -1
  92. package/core/server/registry/page-registry-store.ts +2 -1
  93. package/core/server/registry/registry-error.ts +6 -1
  94. package/core/server/registry/registry-file-lock.ts +296 -23
  95. package/core/server/registry/request-body-limit.ts +3 -2
  96. package/core/server/registry/validation/declaration-safety-scan.ts +151 -27
  97. package/core/server/runtime-space/access-gate.ts +21 -7
  98. package/core/server/runtime-space/bindings.ts +3 -6
  99. package/core/server/runtime-space/dynamic-pages.ts +181 -49
  100. package/core/server/runtime-space/errors.ts +3 -0
  101. package/core/server/runtime-space/inject.ts +78 -16
  102. package/core/server/runtime-space/page-grants.ts +7 -1
  103. package/core/server/runtime-space/resolve.ts +66 -19
  104. package/core/server/runtime-space/store.ts +32 -3
  105. package/core/server/runtime-space/submit-steps.ts +2 -1
  106. package/core/server/runtime-space/types.ts +3 -1
  107. package/core/shared/component-tree-errors.ts +2 -1
  108. package/core/shared/contract-a11y.ts +1 -1
  109. package/core/shared/contract-sections.ts +2 -2
  110. package/core/shared/core-diagnostic-codes.ts +14 -0
  111. package/core/shared/data-declaration-checks.ts +29 -3
  112. package/core/shared/declaration-keys.ts +1 -1
  113. package/core/shared/engines/engine-error.ts +2 -1
  114. package/core/shared/generation-error.ts +2 -1
  115. package/core/shared/page-envelope.ts +1 -1
  116. package/core/shared/pure-binding.ts +88 -0
  117. package/core/shared/registry-generated/diagnostic-registry-index.ts +21 -19
  118. package/core/shared/registry-generated/diagnostic-registry.ts +170 -177
  119. package/core/shared/registry-generated/limits.ts +65 -13
  120. package/core/shared/registry-generated/std-grammar-completion.ts +0 -4
  121. package/core/shared/registry-generated/std-grammar-views.ts +40 -10
  122. package/core/shared/registry-generated/std-grammar.ts +43 -21
  123. package/core/shared/soma-error.ts +36 -0
  124. package/core/shared/types/compile-port.types.ts +1 -1
  125. package/core/shared/types/data-config.types.ts +20 -18
  126. package/core/shared/types/engine.types.ts +0 -3
  127. package/core/shared/types/event.types.ts +10 -11
  128. package/core/shared/types/generation-error.types.ts +5 -1
  129. package/core/shared/types/host-assembly.types.ts +7 -1
  130. package/core/shared/types/manifest.types.ts +0 -3
  131. package/core/shared/types/region-scope.types.ts +5 -1
  132. package/core/shared/types/scope-manifest.types.ts +0 -2
  133. package/core/shared/types/style-config.types.ts +21 -21
  134. package/core/shared/types/ui-config.types.ts +4 -5
  135. package/core/shared/types/watcher.types.ts +1 -1
  136. package/dist/browser/runtime-bundle.manifest.json +11 -13
  137. package/dist/browser/soma-runtime.js +2733 -2712
  138. package/dist/core/index.cjs +5665 -5534
  139. package/dist/host-native/aot-builder.cjs +330 -1
  140. package/dist/host-native/native-server.cjs +5434 -4726
  141. package/dist/lsp/component-tree.cjs +5868 -7040
  142. package/dist/types/build/compiler/full-manifest-builder.d.ts +0 -2
  143. package/dist/types/build/compiler/page-closure.d.ts +21 -0
  144. package/dist/types/build/compiler/page-declaration-compiler.d.ts +2 -4
  145. package/dist/types/build/compiler/soma-precompile.d.ts +1 -3
  146. package/dist/types/build/component-tree/artifact-codec.d.ts +0 -2
  147. package/dist/types/client/a11y/a11y-config.d.ts +2 -1
  148. package/dist/types/client/base/SomaHttpClient.d.ts +1 -1
  149. package/dist/types/client/base/SomaPageRootBase.d.ts +5 -0
  150. package/dist/types/client/base/defineSomaView.d.ts +46 -0
  151. package/dist/types/client/base/index.d.ts +2 -0
  152. package/dist/types/client/base/view-context.d.ts +136 -0
  153. package/dist/types/client/behavior/adapter-collection.d.ts +1 -1
  154. package/dist/types/client/compiler/manifest-compiler.d.ts +0 -3
  155. package/dist/types/client/component/component-definition.types.d.ts +2 -1
  156. package/dist/types/client/component/component-manager.d.ts +29 -0
  157. package/dist/types/client/container/IContainerAdapter.d.ts +3 -0
  158. package/dist/types/client/container/SomaContainerAdapter.d.ts +5 -0
  159. package/dist/types/client/data/data-object-resolver.d.ts +93 -31
  160. package/dist/types/client/data/format-config.d.ts +2 -1
  161. package/dist/types/client/engine/dom-renderer.d.ts +1 -2
  162. package/dist/types/client/engine/event-engine.d.ts +0 -7
  163. package/dist/types/client/engine/reactive-proxy.d.ts +11 -4
  164. package/dist/types/client/engine/runtime-builder.d.ts +0 -4
  165. package/dist/types/client/engine/soma-bootstrap.d.ts +44 -6
  166. package/dist/types/client/engine/style-binder.d.ts +8 -4
  167. package/dist/types/client/host-bridge/load-host-domain-class.d.ts +2 -1
  168. package/dist/types/client/mount/domain-rule.d.ts +2 -0
  169. package/dist/types/client/mount/mount-page.d.ts +2 -1
  170. package/dist/types/client/mount/types.d.ts +2 -0
  171. package/dist/types/client/parser/confirm-spec.d.ts +27 -3
  172. package/dist/types/client/parser/data-config-parser.d.ts +6 -5
  173. package/dist/types/client/parser/style-config-parser.d.ts +7 -3
  174. package/dist/types/client/parser/timer-parser.d.ts +5 -0
  175. package/dist/types/client/parser/ui-config-parser.d.ts +6 -2
  176. package/dist/types/client/render-ports/hide-transition.d.ts +9 -0
  177. package/dist/types/client/render-ports/index.d.ts +4 -0
  178. package/dist/types/client/render-ports/notify-renderer.d.ts +2 -1
  179. package/dist/types/client/runtime/SomaSnapshotStore.d.ts +2 -0
  180. package/dist/types/client/security/url-guard.d.ts +14 -0
  181. package/dist/types/client/validation/async-check-registry.d.ts +2 -1
  182. package/dist/types/client/validation/object-rules.d.ts +0 -5
  183. package/dist/types/index.d.ts +6 -11
  184. package/dist/types/inspect/runtime.d.ts +2 -1
  185. package/dist/types/server/api/dispatch-service-api.d.ts +5 -0
  186. package/dist/types/server/api/load-host-service.d.ts +1 -1
  187. package/dist/types/server/api/paged-list.d.ts +101 -0
  188. package/dist/types/server/compile-port.d.ts +1 -1
  189. package/dist/types/server/host/host-assembly-entry.d.ts +1 -1
  190. package/dist/types/server/host/host-assembly.d.ts +2 -0
  191. package/dist/types/server/host/host-dir.d.ts +2 -0
  192. package/dist/types/server/host/invoke-host-request-hook.d.ts +10 -3
  193. package/dist/types/server/host/published-page-assets.d.ts +2 -1
  194. package/dist/types/server/host/resolve-host-request-hook.d.ts +18 -5
  195. package/dist/types/server/host/server-page-assets.d.ts +2 -1
  196. package/dist/types/server/host/source-aliases.d.cts +53 -0
  197. package/dist/types/server/host/source-aliases.d.ts +30 -0
  198. package/dist/types/server/host/source-packages.d.cts +2 -0
  199. package/dist/types/server/infra/cache/ServerFileCache.d.ts +8 -0
  200. package/dist/types/server/node.d.ts +1 -0
  201. package/dist/types/server/registry/declaration-precompiler.d.ts +0 -1
  202. package/dist/types/server/registry/registry-error.d.ts +5 -1
  203. package/dist/types/server/registry/registry-file-lock.d.ts +30 -0
  204. package/dist/types/server/registry/request-body-limit.d.ts +3 -2
  205. package/dist/types/server/registry/validation/declaration-safety-scan.d.ts +3 -0
  206. package/dist/types/server/runtime-space/access-gate.d.ts +7 -0
  207. package/dist/types/server/runtime-space/bindings.d.ts +3 -2
  208. package/dist/types/server/runtime-space/dynamic-pages.d.ts +6 -1
  209. package/dist/types/server/runtime-space/errors.d.ts +1 -1
  210. package/dist/types/server/runtime-space/resolve.d.ts +2 -0
  211. package/dist/types/server/runtime-space/store.d.ts +8 -1
  212. package/dist/types/server/runtime-space/submit-steps.d.ts +2 -1
  213. package/dist/types/server/runtime-space/types.d.ts +3 -1
  214. package/dist/types/shared/component-tree-errors.d.ts +2 -1
  215. package/dist/types/shared/core-diagnostic-codes.d.ts +1 -1
  216. package/dist/types/shared/declaration-keys.d.ts +1 -1
  217. package/dist/types/shared/engines/engine-error.d.ts +2 -1
  218. package/dist/types/shared/generation-error.d.ts +2 -1
  219. package/dist/types/shared/pure-binding.d.ts +48 -0
  220. package/dist/types/shared/registry-generated/diagnostic-registry.d.ts +149 -158
  221. package/dist/types/shared/registry-generated/limits.d.ts +54 -10
  222. package/dist/types/shared/registry-generated/std-grammar-completion.d.ts +0 -30
  223. package/dist/types/shared/registry-generated/std-grammar-views.d.ts +97 -23
  224. package/dist/types/shared/registry-generated/std-grammar.d.ts +110 -242
  225. package/dist/types/shared/soma-error.d.ts +15 -0
  226. package/dist/types/shared/types/data-config.types.d.ts +17 -17
  227. package/dist/types/shared/types/engine.types.d.ts +0 -3
  228. package/dist/types/shared/types/event.types.d.ts +9 -7
  229. package/dist/types/shared/types/generation-error.types.d.ts +1 -1
  230. package/dist/types/shared/types/host-assembly.types.d.ts +2 -0
  231. package/dist/types/shared/types/manifest.types.d.ts +0 -3
  232. package/dist/types/shared/types/region-scope.types.d.ts +4 -1
  233. package/dist/types/shared/types/scope-manifest.types.d.ts +0 -2
  234. package/dist/types/shared/types/style-config.types.d.ts +17 -19
  235. package/dist/types/shared/types/ui-config.types.d.ts +4 -5
  236. package/host-native/bin/host-native.cjs +22 -1
  237. package/host-native/client/browser-entry.ts +21 -172
  238. package/host-native/src/aot-builder.ts +75 -0
  239. package/host-native/src/host-prepare.ts +39 -5
  240. package/host-native/src/manifest-http.ts +2 -3
  241. package/host-native/src/native-server.ts +812 -174
  242. package/host-native/src/page-http.ts +3 -3
  243. package/host-native/src/public-packages.cjs +0 -1
  244. package/host-native/src/registry-handler.ts +12 -5
  245. package/host-native/src/static-file.ts +203 -53
  246. package/host-native/styles/globals.css +30 -28
  247. package/package.json +14 -2
  248. package/core/client/engine/step-runner.ts +0 -212
  249. package/core/client/engine/trigger-engine.ts +0 -55
  250. package/core/client/format/zoned.ts +0 -10
  251. package/core/client/parser/step-parser.ts +0 -359
  252. package/core/client/parser/trigger-parser.ts +0 -90
  253. package/core/client/parser/value-lang.ts +0 -340
  254. package/core/client/time/instant.ts +0 -2
  255. package/core/shared/calc/coerce.ts +0 -2
  256. package/core/shared/calc/errors.ts +0 -40
  257. package/core/shared/calc/evaluator.ts +0 -113
  258. package/core/shared/calc/index.ts +0 -11
  259. package/core/shared/calc/lexer.ts +0 -189
  260. package/core/shared/calc/parser.ts +0 -193
  261. package/core/shared/calc/typer.ts +0 -171
  262. package/core/shared/date-parts.ts +0 -2
  263. package/core/shared/show-when.ts +0 -77
  264. package/core/shared/types/step.types.ts +0 -91
  265. package/core/shared/types/trigger.types.ts +0 -14
  266. package/dist/types/client/engine/step-runner.d.ts +0 -42
  267. package/dist/types/client/engine/trigger-engine.d.ts +0 -16
  268. package/dist/types/client/format/zoned.d.ts +0 -1
  269. package/dist/types/client/parser/step-parser.d.ts +0 -23
  270. package/dist/types/client/parser/trigger-parser.d.ts +0 -13
  271. package/dist/types/client/parser/value-lang.d.ts +0 -63
  272. package/dist/types/client/time/instant.d.ts +0 -1
  273. package/dist/types/shared/calc/coerce.d.ts +0 -1
  274. package/dist/types/shared/calc/errors.d.ts +0 -14
  275. package/dist/types/shared/calc/evaluator.d.ts +0 -2
  276. package/dist/types/shared/calc/index.d.ts +0 -6
  277. package/dist/types/shared/calc/lexer.d.ts +0 -19
  278. package/dist/types/shared/calc/parser.d.ts +0 -43
  279. package/dist/types/shared/calc/typer.d.ts +0 -11
  280. package/dist/types/shared/date-parts.d.ts +0 -1
  281. package/dist/types/shared/show-when.d.ts +0 -21
  282. package/dist/types/shared/types/step.types.d.ts +0 -76
  283. package/dist/types/shared/types/trigger.types.d.ts +0 -12
@@ -1,212 +0,0 @@
1
- // 动作编排运行时(REQ-010 S4)——按编译好的图走一遍。
2
- //
3
- // 这里刻意很短:难的部分(可终止性、槽的可见性、并行分支不互引)在解析期就判完了,
4
- // 运行期只需要照着走。这正是「编排图是纯数据」的收益——
5
- // 如果编排是一段脚本,这些判断就只能在运行时做,也就是只能在出事之后做。
6
- //
7
- // 一条纪律:**输出槽只活在本次事件里**。事件一结束就销毁,绝不写进页面状态。
8
- // 写进去的话,「这个值是谁放的」就取决于用户最近点过什么——那正是 amis 的运行时数据链
9
- // 难以排查的根源。
10
-
11
- import { evaluatePredicate } from '../../shared/predicates';
12
- import type { SomaFieldPredicate } from '../../shared/predicates';
13
- import type { ParsedEvent, SomaConfirmSpec } from '../../shared/types/event.types';
14
- import type { SomaCompiledStep, SomaStepGraph } from '../../shared/types/step.types';
15
-
16
- export interface StepRunContext {
17
- /** 事件载荷:`when` 的字段来源之一 */
18
- payload: Record<string, unknown>;
19
- /** 执行一条已解析的管道;返回值进输出槽 */
20
- dispatch(pipeline: Omit<ParsedEvent, 'somaId' | 'domEvent'>, scope?: Record<string, unknown>): Promise<unknown>;
21
- /** bootstrap 注册的具名动作 */
22
- actions?: Record<string, (payload: Record<string, unknown>) => Promise<unknown> | unknown>;
23
- /** 出错落点;不给就 console.error */
24
- onError?(message: string, detail: { step: number; cause: unknown }): void;
25
- isValid?(): boolean;
26
- /**
27
- * 确认分级的执行口(R-23):步骤管道带 `confirm`(plain 文案或 typed / consent 规格)时,执行前先过它;
28
- * 返回 false = 用户取消,整条编排中止(`stopped` + `cancelled`),与单管道事件「取消即中止」同口径。
29
- * 不给就不确认。步骤类型不限:ACTION 步骤与其余步骤一样先过它。
30
- */
31
- confirm?(spec: SomaConfirmSpec): boolean | Promise<boolean>;
32
- /**
33
- * 权限码判据(管道尾段 `permission:code`):返回 false = 拒绝,整条编排中止(`stopped` + `denied: 'permission'`),
34
- * 与单管道事件被权限中间件拦下同口径;提示由实现方负责。不给就不判。
35
- */
36
- permission?(code: string): boolean | Promise<boolean>;
37
- /** 角色判据(管道尾段 `roles:a,b`):返回 false = 拒绝,整条编排中止(`denied: 'roles'`),与单管道的角色门同口径。不给就不判。 */
38
- roles?(roles: readonly string[]): boolean;
39
- }
40
-
41
- export interface StepRunResult {
42
- /** 实际执行过的步骤序号(顺序即执行序,`goto` 会让它跳号) */
43
- executed: number[];
44
- /** 事件结束时的槽(仅用于测试与诊断;运行期不外泄) */
45
- slots: Record<string, unknown>;
46
- /** 是否被 on_error: stop 中断 */
47
- stopped: boolean;
48
- /** 因某步确认被取消而中止(`stopped` 同为 true) */
49
- cancelled?: boolean;
50
- /** 因某步权限码或角色不通过而中止(`stopped` 同为 true) */
51
- denied?: 'permission' | 'roles';
52
- }
53
-
54
- export async function runSteps(
55
- graph: SomaStepGraph,
56
- ctx: StepRunContext,
57
- ): Promise<StepRunResult> {
58
- const slots: Record<string, unknown> = {};
59
- const executed: number[] = [];
60
- let stopped = false;
61
- let invalidated = false;
62
- let cancelled = false;
63
- let denied: 'permission' | 'roles' | undefined;
64
-
65
- const isValid = (): boolean => {
66
- if (!invalidated) {
67
- try {
68
- invalidated = ctx.isValid?.() === false;
69
- } catch {
70
- invalidated = true;
71
- }
72
- }
73
- if (invalidated) stopped = true;
74
- return !invalidated;
75
- };
76
-
77
- const report = (message: string, step: number, cause: unknown): void => {
78
- if (ctx.onError) ctx.onError(message, { step, cause });
79
- else console.error(`[soma-core][引擎] 第 ${step + 1} 步失败:${message}`, cause);
80
- };
81
-
82
- /** `when` 的取值面:事件载荷 ⊕ 当前槽。槽在后,同名时槽赢(它更晚、更具体) */
83
- const scope = (extra?: Record<string, unknown>): Record<string, unknown> =>
84
- ({ ...ctx.payload, ...slots, ...extra });
85
-
86
- const holds = (when: SomaFieldPredicate | undefined, extra?: Record<string, unknown>): boolean => {
87
- if (!isValid()) return false;
88
- if (when === undefined) return true;
89
- const values = scope(extra);
90
- if (!isValid()) return false;
91
- const matches = evaluatePredicate(when, values, {});
92
- return isValid() && matches;
93
- };
94
-
95
- const call = async (
96
- pipeline: Omit<ParsedEvent, 'somaId' | 'domEvent'>,
97
- extra?: Record<string, unknown>,
98
- ): Promise<unknown> => {
99
- if (!isValid()) return undefined;
100
- // 尾段闸门,所有步骤类型同一份(含 ACTION),顺序与单管道一致:权限 -> 确认 -> 角色
101
- if (pipeline.permission && ctx.permission) {
102
- const allowed = await ctx.permission(pipeline.permission);
103
- if (!isValid()) return undefined;
104
- if (!allowed) {
105
- denied = 'permission';
106
- stopped = true;
107
- return undefined;
108
- }
109
- }
110
- if (pipeline.confirm && ctx.confirm) {
111
- const spec: SomaConfirmSpec = pipeline.confirmSpec ?? { level: 'plain', text: pipeline.confirm };
112
- const accepted = await ctx.confirm(spec);
113
- if (!isValid()) return undefined;
114
- if (!accepted) {
115
- cancelled = true;
116
- stopped = true;
117
- return undefined;
118
- }
119
- }
120
- if (pipeline.roles && pipeline.roles.length > 0 && ctx.roles) {
121
- if (!ctx.roles(pipeline.roles)) {
122
- denied = 'roles';
123
- stopped = true;
124
- return undefined;
125
- }
126
- }
127
- if (pipeline.type === 'ACTION') {
128
- const name = String(pipeline.funcPath ?? '');
129
- const action = ctx.actions?.[name];
130
- if (typeof action !== 'function') {
131
- // 解析期与 bootstrap 期都查过一遍,走到这里说明注册表在运行中被换过。
132
- // 抛而不是静默跳过:一个"没执行但也没报错"的动作是排查不出来的。
133
- throw new Error(`具名动作 "${name}" 未注册`);
134
- }
135
- const payload = scope(extra);
136
- if (!isValid()) return undefined;
137
- return action(payload);
138
- }
139
- return ctx.dispatch(pipeline, scope(extra));
140
- };
141
-
142
- /**
143
- * 走一串步骤。
144
- *
145
- * `goto` 只在同一层内跳(解析期保证它只向后),所以这里用一个下标游标而不是递归,
146
- * 跳转就是把游标挪过去。
147
- */
148
- const walk = async (list: SomaCompiledStep[], extra?: Record<string, unknown>): Promise<void> => {
149
- let cursor = 0;
150
- while (cursor < list.length) {
151
- if (stopped || !isValid()) return;
152
- const step = list[cursor];
153
-
154
- if (!holds(step.when, extra)) {
155
- if (!isValid()) return;
156
- cursor += 1;
157
- continue;
158
- }
159
- executed.push(step.index);
160
-
161
- try {
162
- if (step.kind === 'do') {
163
- const value = await call(step.pipeline!, extra);
164
- if (!isValid() || cancelled || denied) return;
165
- if (step.output !== undefined) slots[step.output] = value;
166
- } else if (step.kind === 'switch') {
167
- // 取**第一个**成立的分支。otherwise 解析期已保证在末尾,所以顺序扫即可。
168
- const branch = (step.branches ?? []).find((item) => isValid() && (item.otherwise || holds(item.when, extra)));
169
- if (branch !== undefined) {
170
- const value = await call(branch.pipeline, extra);
171
- if (!isValid() || cancelled || denied) return;
172
- if (branch.output !== undefined) slots[branch.output] = value;
173
- }
174
- } else if (step.kind === 'parallel') {
175
- // 分支之间不互引槽(解析期已判),所以真并行是安全的
176
- await Promise.all((step.children ?? []).map((child) => walk([child], extra)));
177
- if (!isValid()) return;
178
- } else if (step.kind === 'for_each') {
179
- const source = scope(extra)[step.over!];
180
- const items = Array.isArray(source) ? source : [];
181
- for (const item of items) {
182
- if (stopped || !isValid()) break;
183
- // 项名只在体内可见:出了循环体就没了,不写进 slots
184
- await walk(step.children ?? [], { ...extra, [step.as!]: item });
185
- if (!isValid()) return;
186
- }
187
- }
188
- } catch (cause) {
189
- if (!isValid()) return;
190
- const message = cause instanceof Error ? cause.message : String(cause);
191
- report(message, step.index, cause);
192
- if (!isValid()) return;
193
- if (step.onError === 'continue') {
194
- cursor += 1;
195
- continue;
196
- }
197
- if (step.onError.startsWith('goto:')) {
198
- // 声明里的序号是**从 1 起**的人类序号,游标是从 0 起的下标
199
- cursor = Number(step.onError.slice(5)) - 1;
200
- continue;
201
- }
202
- stopped = true;
203
- return;
204
- }
205
- cursor += 1;
206
- }
207
- };
208
-
209
- await walk(graph.steps);
210
- isValid();
211
- return { executed, slots, stopped, ...(cancelled ? { cancelled: true } : {}), ...(denied ? { denied } : {}) };
212
- }
@@ -1,55 +0,0 @@
1
- // core/client/engine/trigger-engine.ts
2
- // 属性变化触发 DOM 事件 — 对应 _event.yaml triggers 块
3
-
4
- import type { IContainerAdapter } from '../container/IContainerAdapter';
5
- import type { PropertyTrigger } from '../../shared/types/trigger.types';
6
- import type { SomaScopeResolver } from './scope-resolver';
7
- import type { SomaPropertyWatcher } from './property-watcher';
8
-
9
- export interface SomaTriggerEngineOptions {
10
- propertyWatcher: SomaPropertyWatcher;
11
- resolver: SomaScopeResolver;
12
- container: HTMLElement;
13
- adapter: IContainerAdapter;
14
- triggers: PropertyTrigger[];
15
- }
16
-
17
- export class SomaTriggerEngine {
18
- private readonly unwatchers: Array<() => void> = [];
19
-
20
- init(options: SomaTriggerEngineOptions): void {
21
- for (const trigger of options.triggers) {
22
- const resolvedPath = options.resolver.resolvePath(trigger.condition);
23
-
24
- const unwatch = options.propertyWatcher.watch(
25
- resolvedPath,
26
- (newValue) => {
27
- if (newValue !== trigger.value) {
28
- return;
29
- }
30
-
31
- const targetEl = options.adapter.findAnchor(options.container, trigger.target);
32
- if (!targetEl) {
33
- return;
34
- }
35
-
36
- const eventInit: CustomEventInit = {
37
- bubbles: true,
38
- detail: trigger.detail,
39
- };
40
- targetEl.dispatchEvent(new CustomEvent(trigger.event, eventInit));
41
- },
42
- { prefix: false },
43
- );
44
-
45
- this.unwatchers.push(unwatch);
46
- }
47
- }
48
-
49
- destroy(): void {
50
- for (const unwatch of this.unwatchers) {
51
- unwatch();
52
- }
53
- this.unwatchers.length = 0;
54
- }
55
- }
@@ -1,10 +0,0 @@
1
- // 分区时间换算已下沉通用值区 `soma-foundation/values`;这里只再导出,保住 core 内现有 import。
2
- export {
3
- MS_PER_DAY,
4
- civilDayNumber,
5
- civilUtcMs,
6
- isValidTimeZone,
7
- zonedPartsOf,
8
- zonedTimeToMs,
9
- type ZonedParts,
10
- } from 'soma-foundation/values';
@@ -1,359 +0,0 @@
1
- // `steps:` 段解析(REQ-010 S4)——把一串交互编译成一张可终止、可画的图。
2
- //
3
- // 六步(《架构设计》§4.2):管道 → 条件 → 输出槽 → 控制流 → 可终止性 → 出图。
4
- //
5
- // 为什么可终止性要在**声明期**判:一条不终止的编排在运行期的表现是页面卡死,
6
- // 而卡死的现场什么都留不下。所以这里干脆不给出不终止的写法——
7
- // 没有 `while`,`goto` 只许向后,`for_each` 的 `over` 必须有界且嵌套不超过两层。
8
- // 这三条加起来,步骤图是一个有限的 DAG,走完它的步数有上界。
9
-
10
- import { collectPredicateFields, validatePredicate } from '../../shared/predicates';
11
- import type { ParsedEvent } from '../../shared/types/event.types';
12
- import type {
13
- SomaCompiledStep,
14
- SomaStepGraph,
15
- SomaStepOnError,
16
- SomaStepSlot,
17
- } from '../../shared/types/step.types';
18
-
19
- export interface StepParseInput {
20
- raw: unknown;
21
- /** 事件载荷里的字段名:`when` 的作用域起点 */
22
- payloadFields: readonly string[];
23
- /** bootstrap 注册的具名动作;给了就校验 `do: ACTION | <name>` 的名字存在 */
24
- actionNames?: readonly string[];
25
- path: string;
26
- }
27
-
28
- export interface StepParseDeps {
29
- fail(message: string, path: string): never;
30
- /**
31
- * 单条管道的解析器(`pipeline-parser` 的 `parsePipelineBody`)。
32
- *
33
- * 由调用方注入而不是直接 import,是为了不成环:`pipeline-parser` 的
34
- * `parseEventConfig` 要认 `{ steps: [...] }` 形态,于是它得调本模块;
35
- * 本模块再反向 import 它就构成循环,而循环 import 在 ESM 下"多数时候能跑"
36
- * ——它坏起来是模块初始化顺序变了之后的一个 undefined,跟本次改动毫无关联。
37
- */
38
- parsePipeline(expression: string): Omit<ParsedEvent, 'somaId' | 'domEvent'>;
39
- }
40
-
41
- /** `for_each` 最多两层。三层嵌套的遍历在声明层几乎肯定是数据结构没设计对 */
42
- const MAX_FOR_EACH_DEPTH = 2;
43
-
44
- const STEP_KEYS = new Set(['when', 'do', 'output', 'on_error', 'switch', 'parallel', 'for_each']);
45
- const SLOT_NAME_PATTERN = /^[a-z][a-z0-9_]*$/;
46
-
47
- function isPlainObject(value: unknown): value is Record<string, unknown> {
48
- return value !== null && typeof value === 'object' && !Array.isArray(value);
49
- }
50
-
51
- /** 返回数组的动作:`for_each.over` 只认这种槽 */
52
- function producesArray(pipelineType: string): boolean {
53
- // 只有 Host 函数(UI_REFRESH / NAV_ACTION / ACTION)能返回数组;
54
- // 导航与 UI 交互返回的是「做完了」,不是数据。
55
- return pipelineType === 'UI_REFRESH' || pipelineType === 'NAV_ACTION' || pipelineType === 'ACTION';
56
- }
57
-
58
- export function parseSteps(input: StepParseInput, deps: StepParseDeps): SomaStepGraph {
59
- const { raw, payloadFields, path } = input;
60
- // 显式标注:解构出来的方法不带控制流断言,收窄会整片失效
61
- const fail: (message: string, at: string) => never = deps.fail;
62
-
63
- if (!Array.isArray(raw) || raw.length === 0) {
64
- fail('steps 必须是非空数组', path);
65
- }
66
-
67
- const slots: Record<string, SomaStepSlot> = {};
68
- const edges: Array<[number, number]> = [];
69
- let counter = 0;
70
-
71
- /** `when` 的作用域:事件载荷字段 ∪ 已声明的输出槽(槽以 `名.子键` 的形态被引用) */
72
- const scopeKeys = (): string[] => [...payloadFields, ...Object.keys(slots)];
73
-
74
- const checkWhen = (when: unknown, at: string): void => {
75
- if (when === undefined || when === null) return;
76
-
77
- // 根引用先查,再走通用谓词校验。次序要紧:通用校验对"字段不在作用域里"只会说
78
- // 「引用了不存在的字段」,而在编排里这句话答不了作者真正的问题——
79
- // 到底是载荷里没有这个字段,还是槽声明在后面。先查根,才能把这两种情况分开说。
80
- //
81
- // 引用只许向后:槽必须**先于**引用它的步骤声明。少了这条,一个引用后面步骤输出的
82
- // 条件会永远读到 undefined 并静默判假——那条分支于是永远不走,而且看不出来。
83
- for (const field of collectPredicateFields(when as Parameters<typeof collectPredicateFields>[0])) {
84
- const root = field.split('.')[0];
85
- if (!payloadFields.includes(root) && slots[root] === undefined) {
86
- fail(
87
- `${at} 引用了 "${root}",但它既不是事件载荷字段`
88
- + `(${payloadFields.join(' / ') || '无'}),也不是先于本步声明的输出槽`
89
- + `(${Object.keys(slots).join(' / ') || '无'})`,
90
- at,
91
- );
92
- }
93
- }
94
-
95
- const issues = validatePredicate(when, scopeKeys(), at, {});
96
- if (issues.length > 0) fail(issues.join(';'), at);
97
- };
98
-
99
- const declareSlot = (name: unknown, at: string, index: number, pipelineType: string): string => {
100
- const slot = String(name ?? '');
101
- if (!SLOT_NAME_PATTERN.test(slot)) {
102
- fail(`${at}.output "${slot}" 不是合法槽名(小写字母开头、下划线分隔)`, `${at}.output`);
103
- }
104
- if (slots[slot] !== undefined) {
105
- fail(
106
- `${at}.output 槽名 "${slot}" 与第 ${slots[slot].declaredAt + 1} 步重名`
107
- + '——同名槽的后写会覆盖前写,而引用它的条件读到哪一个取决于步骤次序',
108
- `${at}.output`,
109
- );
110
- }
111
- slots[slot] = { declaredAt: index, producedBy: pipelineType, bounded: producesArray(pipelineType) };
112
- return slot;
113
- };
114
-
115
- const parsePipe = (expression: unknown, at: string): Omit<ParsedEvent, 'somaId' | 'domEvent'> => {
116
- if (typeof expression !== 'string' || expression.trim() === '') {
117
- fail(`${at}.do 必须是管道表达式字符串`, `${at}.do`);
118
- }
119
- try {
120
- return deps.parsePipeline(expression);
121
- } catch (error) {
122
- // 管道自己的报错already说清了问题("未知事件类型 X"),原样转出去,
123
- // 只补上是哪一步——包一层自己的话,作者会看到两句话说同一件事。
124
- fail(error instanceof Error ? error.message : String(error), `${at}.do`);
125
- }
126
- };
127
-
128
- const parseOnError = (value: unknown, at: string, total: number, index: number): SomaStepOnError => {
129
- if (value === undefined) return 'stop';
130
- const raw2 = String(value);
131
- if (raw2 === 'stop' || raw2 === 'continue') return raw2;
132
- const match = /^goto:(\d+)$/.exec(raw2);
133
- if (!match) {
134
- fail(`${at}.on_error 只能是 stop / continue / goto:<步骤序号>(收到 "${raw2}")`, `${at}.on_error`);
135
- }
136
- const target = Number(match[1]);
137
- // 只许向后跳。向前跳就能构造循环,而一条不终止的编排在运行期的表现是页面卡死,
138
- // 现场什么都留不下。这是 AO-1 的核心一条。
139
- if (target <= index + 1) {
140
- fail(
141
- `${at}.on_error 的 goto:${target} 指向第 ${target} 步,不在本步(第 ${index + 1} 步)之后`
142
- + '——只许向后跳,否则编排可以不终止',
143
- `${at}.on_error`,
144
- );
145
- }
146
- if (target > total) {
147
- fail(`${at}.on_error 的 goto:${target} 越过了末步(共 ${total} 步)`, `${at}.on_error`);
148
- }
149
- return `goto:${target}`;
150
- };
151
-
152
- const walk = (
153
- list: unknown[],
154
- at: string,
155
- depth: number,
156
- inParallel: boolean,
157
- ): SomaCompiledStep[] => {
158
- const out: SomaCompiledStep[] = [];
159
- /** parallel 分支内声明的槽:分支之间不许互引(AO-2) */
160
- const parallelLocalSlots: string[] = [];
161
-
162
- list.forEach((entry, position) => {
163
- const stepAt = `${at}[${position}]`;
164
- if (!isPlainObject(entry)) fail(`${stepAt} 必须是映射`, stepAt);
165
- for (const key of Object.keys(entry)) {
166
- if (!STEP_KEYS.has(key)) {
167
- fail(`${stepAt} 有未知键 "${key}"(支持: ${[...STEP_KEYS].join(' / ')})`, `${stepAt}.${key}`);
168
- }
169
- }
170
- const index = counter;
171
- counter += 1;
172
- if (out.length > 0) edges.push([out[out.length - 1].index, index]);
173
-
174
- // ── parallel ────────────────────────────────────────────────
175
- if (entry.parallel !== undefined) {
176
- if (!Array.isArray(entry.parallel) || entry.parallel.length < 2) {
177
- fail(`${stepAt}.parallel 至少要两个分支(一个分支的并行就是顺序)`, `${stepAt}.parallel`);
178
- }
179
- const before = new Set(Object.keys(slots));
180
- const children = walk(entry.parallel as unknown[], `${stepAt}.parallel`, depth, true);
181
- const declared = Object.keys(slots).filter((name) => !before.has(name));
182
- parallelLocalSlots.push(...declared);
183
- out.push({ index, kind: 'parallel', onError: 'stop', children });
184
- return;
185
- }
186
-
187
- // ── for_each ────────────────────────────────────────────────
188
- if (entry.for_each !== undefined) {
189
- if (depth + 1 > MAX_FOR_EACH_DEPTH) {
190
- fail(
191
- `${stepAt}.for_each 嵌套超过 ${MAX_FOR_EACH_DEPTH} 层`
192
- + '——三层遍历在声明层几乎肯定是数据结构没设计对',
193
- `${stepAt}.for_each`,
194
- );
195
- }
196
- const box = entry.for_each;
197
- if (!isPlainObject(box)) fail(`${stepAt}.for_each 必须是 { over, as, steps }`, `${stepAt}.for_each`);
198
- const over = String(box.over ?? '');
199
- const as = String(box.as ?? '');
200
- // `over` 必须有界:遍历一个来路不明的东西,步数就没有上界了
201
- const isPayload = payloadFields.includes(over);
202
- const slot = slots[over];
203
- if (!isPayload && slot === undefined) {
204
- fail(
205
- `${stepAt}.for_each.over "${over}" 既不是事件载荷字段,也不是先于本步声明的输出槽`,
206
- `${stepAt}.for_each.over`,
207
- );
208
- }
209
- if (slot !== undefined && !slot.bounded) {
210
- fail(
211
- `${stepAt}.for_each.over "${over}" 来自 ${slot.producedBy},它不返回数组`
212
- + '——遍历一个不是数组的东西,步数就没有上界了',
213
- `${stepAt}.for_each.over`,
214
- );
215
- }
216
- if (!SLOT_NAME_PATTERN.test(as)) {
217
- fail(`${stepAt}.for_each.as "${as}" 不是合法项名`, `${stepAt}.for_each.as`);
218
- }
219
- if (!Array.isArray(box.steps) || box.steps.length === 0) {
220
- fail(`${stepAt}.for_each.steps 必须是非空数组`, `${stepAt}.for_each.steps`);
221
- }
222
- // 项名在体内可见:登记成一个有界槽,体内的 when 才能引用它
223
- slots[as] = { declaredAt: index, producedBy: 'for_each', bounded: false };
224
- const children = walk(box.steps as unknown[], `${stepAt}.for_each.steps`, depth + 1, inParallel);
225
- delete slots[as];
226
- out.push({ index, kind: 'for_each', onError: 'stop', over, as, children });
227
- return;
228
- }
229
-
230
- // ── switch ──────────────────────────────────────────────────
231
- if (entry.switch !== undefined) {
232
- if (!Array.isArray(entry.switch) || entry.switch.length === 0) {
233
- fail(`${stepAt}.switch 必须是非空分支数组`, `${stepAt}.switch`);
234
- }
235
- checkWhen(entry.when, `${stepAt}.when`);
236
- const list2 = entry.switch as unknown[];
237
- const branches: NonNullable<SomaCompiledStep['branches']> = [];
238
-
239
- // 两条规则的判定次序要紧:先数个数、再看位置。反过来的话,两个 otherwise
240
- // 的写法会先撞上「必须在末尾」,于是「只能有一个」那条永远走不到——
241
- // 一条永远走不到的校验分支和没写是一样的。
242
- const otherwiseAt = list2
243
- .map((branch, position) => (isPlainObject(branch) && branch.otherwise === true ? position : -1))
244
- .filter((position) => position !== -1);
245
- if (otherwiseAt.length > 1) {
246
- fail(
247
- `${stepAt}.switch 有 ${otherwiseAt.length} 个 otherwise 分支(第 ${otherwiseAt.map((n) => n + 1).join(' / ')} 个)`
248
- + '——兜底只能有一个',
249
- `${stepAt}.switch`,
250
- );
251
- }
252
- if (otherwiseAt.length === 1 && otherwiseAt[0] !== list2.length - 1) {
253
- fail(
254
- `${stepAt}.switch[${otherwiseAt[0]}] 的 otherwise 必须是最后一个分支`
255
- + '(它是兜底,后面的分支永远走不到)',
256
- `${stepAt}.switch[${otherwiseAt[0]}]`,
257
- );
258
- }
259
-
260
- list2.forEach((branchRaw, branchIndex) => {
261
- const branchAt = `${stepAt}.switch[${branchIndex}]`;
262
- if (!isPlainObject(branchRaw)) fail(`${branchAt} 必须是映射`, branchAt);
263
- const otherwise = branchRaw.otherwise === true;
264
- if (!otherwise && branchRaw.when === undefined) {
265
- fail(`${branchAt} 既没有 when 也不是 otherwise——它会无条件命中并吃掉后面的分支`, branchAt);
266
- }
267
- if (!otherwise) checkWhen(branchRaw.when, `${branchAt}.when`);
268
- const pipeline = parsePipe(branchRaw.do, branchAt);
269
- const output = branchRaw.output === undefined
270
- ? undefined
271
- : declareSlot(branchRaw.output, branchAt, index, pipeline.type);
272
- branches.push({
273
- ...(otherwise ? {} : { when: branchRaw.when as never }),
274
- otherwise,
275
- pipeline,
276
- ...(output === undefined ? {} : { output }),
277
- });
278
- });
279
- out.push({ index, kind: 'switch', when: entry.when as never, onError: 'stop', branches });
280
- return;
281
- }
282
-
283
- // ── do ──────────────────────────────────────────────────────
284
- checkWhen(entry.when, `${stepAt}.when`);
285
- const pipeline = parsePipe(entry.do, stepAt);
286
- const onError = parseOnError(entry.on_error, stepAt, list.length, position);
287
- if (onError.startsWith('goto:')) {
288
- edges.push([index, index + (Number(onError.slice(5)) - position - 1)]);
289
- }
290
- const output = entry.output === undefined
291
- ? undefined
292
- : declareSlot(entry.output, stepAt, index, pipeline.type);
293
- if (inParallel && output !== undefined) parallelLocalSlots.push(output);
294
- out.push({
295
- index,
296
- kind: 'do',
297
- ...(entry.when === undefined ? {} : { when: entry.when as never }),
298
- pipeline,
299
- onError,
300
- ...(output === undefined ? {} : { output }),
301
- });
302
- });
303
-
304
- // 并行分支之间不许互引槽(AO-2):互引就意味着有顺序,那它就不是并行。
305
- // 检法是「本层某个分支的 when 引用了本层另一个分支声明的槽」——
306
- // 这在顺序执行下能跑通,一旦真的并行起来就变成竞态,而竞态只在压力下暴露。
307
- if (inParallel && parallelLocalSlots.length > 0) {
308
- out.forEach((step, position) => {
309
- const refs = step.when === undefined ? [] : collectPredicateFields(step.when);
310
- for (const ref of refs) {
311
- const root = ref.split('.')[0];
312
- if (!parallelLocalSlots.includes(root)) continue;
313
- const owner = out.findIndex((other) => other.output === root);
314
- if (owner !== -1 && owner !== position) {
315
- fail(
316
- `${at}[${position}] 的 when 引用了同一个 parallel 里另一个分支的输出槽 "${root}"`
317
- + '——并行分支之间不许互引:互引就意味着有顺序,那它就不该写成 parallel',
318
- `${at}[${position}].when`,
319
- );
320
- }
321
- }
322
- });
323
- }
324
-
325
- return out;
326
- };
327
-
328
- const steps = walk(raw as unknown[], path, 0, false);
329
-
330
- // 具名动作全部可解析(AO-3 的声明期一半;bootstrap 期还会再查一次注册表)
331
- if (input.actionNames !== undefined) {
332
- const known = new Set(input.actionNames);
333
- const visit = (list: SomaCompiledStep[]): void => {
334
- for (const step of list) {
335
- const pipes = [
336
- ...(step.pipeline ? [step.pipeline] : []),
337
- ...(step.branches ?? []).map((branch) => branch.pipeline),
338
- ];
339
- for (const pipe of pipes) {
340
- if (pipe.type !== 'ACTION') continue;
341
- const name = String(pipe.funcPath ?? '');
342
- if (!known.has(name)) {
343
- fail(
344
- `do: ACTION | ${name} —— 未注册的具名动作`
345
- + `(已注册:${[...known].join(' / ') || '无'})。`
346
- + '具名动作在 bootstrap 的 options.actions 里登记,这是 custom(script) 的替代:'
347
- + '实现在 Host 代码里、有名字、可审计。',
348
- path,
349
- );
350
- }
351
- }
352
- if (step.children) visit(step.children);
353
- }
354
- };
355
- visit(steps);
356
- }
357
-
358
- return { steps, slots, edges };
359
- }