soma-core 1.3.5 → 1.4.0

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 (68) hide show
  1. package/README.md +20 -7
  2. package/app/SomaPageClient.tsx +4 -4
  3. package/app/components/SomaHostPage.tsx +5 -5
  4. package/app/components/SomaHydrationShell.tsx +4 -7
  5. package/app/globals.css +126 -3
  6. package/core/build/{v2 → blocks}/block-compile.ts +17 -17
  7. package/core/build/{v2/soma-file-loader.ts → blocks/block-container.ts} +28 -28
  8. package/core/build/{v2 → blocks}/block-loader.ts +1 -1
  9. package/core/build/{v2 → blocks}/html-index.ts +1 -1
  10. package/core/build/{v2/migrate-v1.ts → blocks/migrate-flat.ts} +27 -27
  11. package/core/build/compiler/host-config-sync.cjs +2 -9
  12. package/core/build/compiler/page-declaration-compiler.ts +2 -2
  13. package/core/build/compiler/soma-manifest-webpack-plugin.js +1 -1
  14. package/core/build/compiler/soma-precompile.js +17 -17
  15. package/core/build/compiler/soma-precompile.ts +2 -2
  16. package/core/client/component/ai-catalog.ts +4 -4
  17. package/core/client/component/contract-compat.ts +32 -3
  18. package/core/client/component/{example-v2.ts → example-blocks.ts} +19 -19
  19. package/core/client/engine/soma-bootstrap.ts +21 -2
  20. package/core/client/engine/style-binder.ts +1 -1
  21. package/core/client/infra/notify/DomNotifyService.ts +2 -1
  22. package/core/client/infra/notify/INotifyTheme.ts +1 -1
  23. package/core/client/parser/{v2 → blocks}/namespace.ts +1 -1
  24. package/core/client/parser/{v2 → blocks}/page-parser.ts +16 -16
  25. package/core/client/parser/{v2 → blocks}/use-parser.ts +20 -14
  26. package/core/client/parser/style-config-parser.ts +7 -7
  27. package/core/client/parser/value-lang.ts +1 -1
  28. package/core/client/registry/index.ts +8 -0
  29. package/core/client/theme/theme-engine.ts +42 -14
  30. package/core/client/typography/typography-base.ts +1 -1
  31. package/core/index.ts +25 -13
  32. package/core/server/host/csp-nonce-metadata.ts +1 -1
  33. package/core/server/host/published-page-assets.ts +3 -8
  34. package/core/server/host/soma-page-compile.ts +1 -1
  35. package/core/server/index.ts +2 -2
  36. package/core/shared/published-page-route.ts +61 -0
  37. package/core/shared/types/adaptive.types.ts +1 -1
  38. package/core/shared/types/data-config.types.ts +30 -2
  39. package/core/shared/types/scope-manifest.types.ts +11 -15
  40. package/core/shared/types/style-config.types.ts +4 -4
  41. package/dist/cli/soma.js +15 -2
  42. package/dist/core/index.cjs +165 -76
  43. package/dist/types/build/{v2 → blocks}/block-compile.d.ts +7 -7
  44. package/dist/types/build/{v2/soma-file-loader.d.ts → blocks/block-container.d.ts} +6 -6
  45. package/dist/types/build/{v2/migrate-v1.d.ts → blocks/migrate-flat.d.ts} +6 -6
  46. package/dist/types/client/component/contract-compat.d.ts +2 -2
  47. package/dist/types/client/component/example-blocks.d.ts +9 -0
  48. package/dist/types/client/infra/notify/DomNotifyService.d.ts +2 -1
  49. package/dist/types/client/infra/notify/INotifyTheme.d.ts +1 -1
  50. package/dist/types/client/parser/{v2 → blocks}/page-parser.d.ts +2 -2
  51. package/dist/types/client/parser/{v2 → blocks}/use-parser.d.ts +1 -1
  52. package/dist/types/client/parser/style-config-parser.d.ts +1 -1
  53. package/dist/types/client/registry/index.d.ts +1 -0
  54. package/dist/types/client/theme/theme-engine.d.ts +11 -0
  55. package/dist/types/index.d.ts +8 -7
  56. package/dist/types/server/host/published-page-assets.d.ts +3 -2
  57. package/dist/types/server/index.d.ts +1 -1
  58. package/dist/types/shared/published-page-route.d.ts +21 -0
  59. package/dist/types/shared/types/data-config.types.d.ts +18 -2
  60. package/dist/types/shared/types/scope-manifest.types.d.ts +11 -11
  61. package/dist/types/shared/types/style-config.types.d.ts +4 -4
  62. package/package.json +1 -6
  63. package/dist/types/client/component/example-v2.d.ts +0 -9
  64. package/postcss.config.js +0 -6
  65. package/tailwind.config.ts +0 -43
  66. /package/dist/types/build/{v2 → blocks}/block-loader.d.ts +0 -0
  67. /package/dist/types/build/{v2 → blocks}/html-index.d.ts +0 -0
  68. /package/dist/types/client/parser/{v2 → blocks}/namespace.d.ts +0 -0
@@ -1,14 +1,16 @@
1
- import type { SomaCompiledBinding, SomaCompiledEvent, SomaRuntimeManifest } from './manifest.types';
1
+ import type { SomaCompiledBinding, SomaCompiledEvent } from './manifest.types';
2
2
 
3
3
  /**
4
- * v2 作用域清单树(组件体系 P0)。
4
+ * 作用域清单树(组件体系 P0)。
5
5
  *
6
- * 设计规范:soma-core/doc/soma 作用域清单树.md
7
- * 兼容承诺:v1 清单(SomaRuntimeManifest)长期保留;无组件页面继续走 v1 原路径,
8
- * 本文件只做类型新增,不修改任何既有类型。
6
+ * 设计规范:soma-core/doc/archive/soma 作用域清单树.md(事实已并入《运行时引擎详设》)。
7
+ *
8
+ * **状态:目标模型,尚未物化。** 当前运行时以「实例级迷你运行时」承载同一语义
9
+ * (见《soma 运行时引擎详设》§4);本文件先把节点形状定下来,随契约编译器落地。
10
+ * 除下面的管道类型外,其余类型暂无消费者——改动它们不会影响运行行为。
9
11
  *
10
12
  * 节点结构保持可 JSON 序列化(仅数组/普通对象,无 Map)——构建期产物与
11
- * 运行期客户端编译产物必须深度相等(规范 7.4),索引一律在运行时装配。
13
+ * 运行期客户端编译产物必须深度相等,索引一律在运行时装配。
12
14
  */
13
15
 
14
16
  export type SomaScopeKind = 'page' | 'list' | 'component';
@@ -77,20 +79,14 @@ export interface SomaScopeNode {
77
79
  listVar?: string;
78
80
  /** 异构列表模板选择器的绑定路径(DSL 扩展规范 2.1,行模板后缀 = 该路径取值) */
79
81
  roleBy?: string;
80
- /** 本作用域直属锚点的绑定(结构与 v1 逐字段同构) */
82
+ /** 本作用域直属锚点的绑定(结构与扁平清单逐字段同构) */
81
83
  bindings: SomaCompiledBinding[];
82
84
  events: SomaCompiledEvent[];
83
85
  children: SomaScopeNode[];
84
86
  }
85
87
 
86
- export interface SomaRuntimeManifestV2 {
87
- version: 2;
88
+ /** 作用域树形态的运行清单(目标模型,尚无产出者与消费者) */
89
+ export interface SomaScopeManifest {
88
90
  root: SomaScopeNode;
89
91
  initProps?: Record<string, unknown>;
90
92
  }
91
-
92
- export type SomaAnyRuntimeManifest = SomaRuntimeManifest | SomaRuntimeManifestV2;
93
-
94
- export function isManifestV2(manifest: SomaAnyRuntimeManifest): manifest is SomaRuntimeManifestV2 {
95
- return (manifest as SomaRuntimeManifestV2).version === 2;
96
- }
@@ -19,7 +19,7 @@ export interface StyleStateRule {
19
19
  condition: string;
20
20
  /** 目标值(基础类型:string | number | boolean | null) */
21
21
  value: string | number | boolean | null;
22
- /** 匹配时应用的 Tailwind 类名 */
22
+ /** 匹配时应用的 CSS 类名;具体样式由宿主样式系统提供 */
23
23
  apply: string;
24
24
  }
25
25
 
@@ -40,7 +40,7 @@ export type TransitionTrigger =
40
40
  export interface StyleTransition {
41
41
  /** 触发方式 */
42
42
  trigger: TransitionTrigger;
43
- /** 应用的 Tailwind 动画/过渡类名 */
43
+ /** 应用的 CSS 动画/过渡类名;具体样式由宿主样式系统提供 */
44
44
  apply: string;
45
45
  /** active_state 类型时的条件路径 */
46
46
  condition?: string;
@@ -59,7 +59,7 @@ export interface ThemeStatesOverride {
59
59
  * 单个主题配置
60
60
  */
61
61
  export interface ThemeConfig {
62
- /** 基础类名覆盖:somaId → Tailwind 类名 */
62
+ /** 基础类名覆盖:somaId → CSS 类名 */
63
63
  base: Record<string, string>;
64
64
  /** 状态规则覆盖 */
65
65
  states: ThemeStatesOverride;
@@ -74,7 +74,7 @@ export interface ThemeConfig {
74
74
  export interface StyleConfig {
75
75
  /** 所属的业务对象标识(对应 data-soma-host) */
76
76
  host: string;
77
- /** 基础静态样式映射:somaId → Tailwind 类名 */
77
+ /** 基础静态样式映射:somaId → CSS 类名 */
78
78
  base: Record<string, string>;
79
79
  /** 状态驱动样式:somaId → 规则数组 */
80
80
  states: Record<string, StyleStateRule[]>;
package/dist/cli/soma.js CHANGED
@@ -76,6 +76,20 @@ function linkOrCopy(targetPath, linkPath, type) {
76
76
  }
77
77
  }
78
78
  }
79
+ /** Remove only the old framework-owned style config links from a generated workspace. */
80
+ function removeLegacyStyleConfigLinks(workspaceDir) {
81
+ for (const fileName of ['postcss.config.js', 'tailwind.config.ts']) {
82
+ const linkPath = node_path_1.default.join(workspaceDir, fileName);
83
+ const stat = lstatIfPresent(linkPath);
84
+ if (!stat?.isSymbolicLink())
85
+ continue;
86
+ const linkedTarget = node_path_1.default.resolve(node_path_1.default.dirname(linkPath), node_fs_1.default.readlinkSync(linkPath));
87
+ const legacyTarget = node_path_1.default.resolve(node_path_1.default.join(packageRoot, fileName));
88
+ if (linkedTarget === legacyTarget) {
89
+ node_fs_1.default.unlinkSync(linkPath);
90
+ }
91
+ }
92
+ }
79
93
  function copyDirectory(targetPath, destPath) {
80
94
  const existingDest = rejectWorkspaceSymlink(destPath);
81
95
  if (existingDest) {
@@ -394,13 +408,12 @@ function ensureNextWorkspace(hostDir) {
394
408
  node_fs_1.default.mkdirSync(workspaceDir, { recursive: true });
395
409
  writeFileIfChanged(node_path_1.default.join(workspaceDir, 'package.json'), JSON.stringify({ private: true, name: 'soma-next-workspace' }, null, 2) + '\n');
396
410
  copyDirectory(node_path_1.default.join(packageRoot, 'app'), node_path_1.default.join(workspaceDir, 'app'));
411
+ removeLegacyStyleConfigLinks(workspaceDir);
397
412
  linkOrCopy(node_path_1.default.join(packageRoot, 'core'), node_path_1.default.join(workspaceDir, 'core'), 'dir');
398
413
  const legacyMiddleware = node_path_1.default.join(workspaceDir, 'middleware.ts');
399
414
  if (lstatIfPresent(legacyMiddleware))
400
415
  node_fs_1.default.unlinkSync(legacyMiddleware);
401
416
  linkOrCopy(node_path_1.default.join(packageRoot, 'proxy.ts'), node_path_1.default.join(workspaceDir, 'proxy.ts'), 'file');
402
- linkOrCopy(node_path_1.default.join(packageRoot, 'postcss.config.js'), node_path_1.default.join(workspaceDir, 'postcss.config.js'), 'file');
403
- linkOrCopy(node_path_1.default.join(packageRoot, 'tailwind.config.ts'), node_path_1.default.join(workspaceDir, 'tailwind.config.ts'), 'file');
404
417
  linkOrCopy(node_path_1.default.join(packageRoot, 'global.d.ts'), node_path_1.default.join(workspaceDir, 'global.d.ts'), 'file');
405
418
  ensureHostPublicAssets(hostDir, workspaceDir);
406
419
  const hasWorkspaceNodeModules = ensureWorkspaceNodeModules(workspaceDir);