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.
- package/README.md +20 -7
- package/app/SomaPageClient.tsx +4 -4
- package/app/components/SomaHostPage.tsx +5 -5
- package/app/components/SomaHydrationShell.tsx +4 -7
- package/app/globals.css +126 -3
- package/core/build/{v2 → blocks}/block-compile.ts +17 -17
- package/core/build/{v2/soma-file-loader.ts → blocks/block-container.ts} +28 -28
- package/core/build/{v2 → blocks}/block-loader.ts +1 -1
- package/core/build/{v2 → blocks}/html-index.ts +1 -1
- package/core/build/{v2/migrate-v1.ts → blocks/migrate-flat.ts} +27 -27
- package/core/build/compiler/host-config-sync.cjs +2 -9
- package/core/build/compiler/page-declaration-compiler.ts +2 -2
- package/core/build/compiler/soma-manifest-webpack-plugin.js +1 -1
- package/core/build/compiler/soma-precompile.js +17 -17
- package/core/build/compiler/soma-precompile.ts +2 -2
- package/core/client/component/ai-catalog.ts +4 -4
- package/core/client/component/contract-compat.ts +32 -3
- package/core/client/component/{example-v2.ts → example-blocks.ts} +19 -19
- package/core/client/engine/soma-bootstrap.ts +21 -2
- package/core/client/engine/style-binder.ts +1 -1
- package/core/client/infra/notify/DomNotifyService.ts +2 -1
- package/core/client/infra/notify/INotifyTheme.ts +1 -1
- package/core/client/parser/{v2 → blocks}/namespace.ts +1 -1
- package/core/client/parser/{v2 → blocks}/page-parser.ts +16 -16
- package/core/client/parser/{v2 → blocks}/use-parser.ts +20 -14
- package/core/client/parser/style-config-parser.ts +7 -7
- package/core/client/parser/value-lang.ts +1 -1
- package/core/client/registry/index.ts +8 -0
- package/core/client/theme/theme-engine.ts +42 -14
- package/core/client/typography/typography-base.ts +1 -1
- package/core/index.ts +25 -13
- package/core/server/host/csp-nonce-metadata.ts +1 -1
- package/core/server/host/published-page-assets.ts +3 -8
- package/core/server/host/soma-page-compile.ts +1 -1
- package/core/server/index.ts +2 -2
- package/core/shared/published-page-route.ts +61 -0
- package/core/shared/types/adaptive.types.ts +1 -1
- package/core/shared/types/data-config.types.ts +30 -2
- package/core/shared/types/scope-manifest.types.ts +11 -15
- package/core/shared/types/style-config.types.ts +4 -4
- package/dist/cli/soma.js +15 -2
- package/dist/core/index.cjs +165 -76
- package/dist/types/build/{v2 → blocks}/block-compile.d.ts +7 -7
- package/dist/types/build/{v2/soma-file-loader.d.ts → blocks/block-container.d.ts} +6 -6
- package/dist/types/build/{v2/migrate-v1.d.ts → blocks/migrate-flat.d.ts} +6 -6
- package/dist/types/client/component/contract-compat.d.ts +2 -2
- package/dist/types/client/component/example-blocks.d.ts +9 -0
- package/dist/types/client/infra/notify/DomNotifyService.d.ts +2 -1
- package/dist/types/client/infra/notify/INotifyTheme.d.ts +1 -1
- package/dist/types/client/parser/{v2 → blocks}/page-parser.d.ts +2 -2
- package/dist/types/client/parser/{v2 → blocks}/use-parser.d.ts +1 -1
- package/dist/types/client/parser/style-config-parser.d.ts +1 -1
- package/dist/types/client/registry/index.d.ts +1 -0
- package/dist/types/client/theme/theme-engine.d.ts +11 -0
- package/dist/types/index.d.ts +8 -7
- package/dist/types/server/host/published-page-assets.d.ts +3 -2
- package/dist/types/server/index.d.ts +1 -1
- package/dist/types/shared/published-page-route.d.ts +21 -0
- package/dist/types/shared/types/data-config.types.d.ts +18 -2
- package/dist/types/shared/types/scope-manifest.types.d.ts +11 -11
- package/dist/types/shared/types/style-config.types.d.ts +4 -4
- package/package.json +1 -6
- package/dist/types/client/component/example-v2.d.ts +0 -9
- package/postcss.config.js +0 -6
- package/tailwind.config.ts +0 -43
- /package/dist/types/build/{v2 → blocks}/block-loader.d.ts +0 -0
- /package/dist/types/build/{v2 → blocks}/html-index.d.ts +0 -0
- /package/dist/types/client/parser/{v2 → blocks}/namespace.d.ts +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { UiConfig } from '../../shared/types/ui-config.types';
|
|
2
2
|
import { type HtmlAnchorIndex } from './html-index';
|
|
3
|
-
import { type UseBlockAst } from '../../client/parser/
|
|
4
|
-
export interface
|
|
5
|
-
/**
|
|
3
|
+
import { type UseBlockAst } from '../../client/parser/blocks/use-parser';
|
|
4
|
+
export interface CompiledSomaBlocks {
|
|
5
|
+
/** 平铺等价 UiConfig:直接交既有编译管线 */
|
|
6
6
|
ui: UiConfig;
|
|
7
|
-
/**
|
|
7
|
+
/** 平铺等价事件声明(DOM 事件 + timers/triggers + 组件 emit 路由) */
|
|
8
8
|
event: Record<string, unknown>;
|
|
9
9
|
/** 数据对象声明(页面级 + 各块私有,已带全局身份) */
|
|
10
10
|
data: Record<string, unknown>;
|
|
@@ -12,7 +12,7 @@ export interface CompiledSomaV2 {
|
|
|
12
12
|
blocks: ReadonlyMap<string, UseBlockAst>;
|
|
13
13
|
htmlIndex: HtmlAnchorIndex;
|
|
14
14
|
}
|
|
15
|
-
export interface
|
|
15
|
+
export interface CompileSomaBlocksInput {
|
|
16
16
|
html: string;
|
|
17
17
|
uiYamlRaw: string;
|
|
18
18
|
/** 外置块:锚点名 → 块体原文(服务端由 loadExternalBlocks 提供) */
|
|
@@ -21,8 +21,8 @@ export interface CompileSomaV2Input {
|
|
|
21
21
|
localeKeys?: ReadonlySet<string>;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
24
|
+
* 编译一份块声明。
|
|
25
25
|
*
|
|
26
26
|
* 本函数只接受 canonical 声明,不做旧页面形状回退;旧输入会在开关校验处明确报错。
|
|
27
27
|
*/
|
|
28
|
-
export declare function
|
|
28
|
+
export declare function compileSomaBlocks(input: CompileSomaBlocksInput): CompiledSomaBlocks;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HtmlAnchorIndex } from './html-index';
|
|
2
|
-
export declare class
|
|
2
|
+
export declare class SomaBlockParseError extends Error {
|
|
3
3
|
readonly blockId?: string | undefined;
|
|
4
4
|
readonly line?: number | undefined;
|
|
5
5
|
constructor(message: string, blockId?: string | undefined, line?: number | undefined);
|
|
@@ -23,20 +23,20 @@ export interface SomaFileLoadInput {
|
|
|
23
23
|
/** 外置块文件:锚点名 → 块体原文(由 block-loader 提供) */
|
|
24
24
|
externalBlocks?: ReadonlyMap<string, string>;
|
|
25
25
|
}
|
|
26
|
-
interface
|
|
26
|
+
interface SomaBlockContainer {
|
|
27
27
|
doc: Record<string, unknown>;
|
|
28
28
|
inner: string;
|
|
29
29
|
offset: number;
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
|
-
* 只校验
|
|
32
|
+
* 只校验 单文件块容器本身,不依赖 HTML 锚点。
|
|
33
33
|
*
|
|
34
34
|
* Bundler 的单文件 loader 拿不到同页 HTML,只能在这里确认开关成对、内层 YAML
|
|
35
|
-
* 可解析且顶层是块映射;块 id 与 HTML 的对账仍由页面级
|
|
35
|
+
* 可解析且顶层是块映射;块 id 与 HTML 的对账仍由页面级 compileSomaBlocks 完成。
|
|
36
36
|
*/
|
|
37
|
-
export declare function
|
|
37
|
+
export declare function parseSomaBlockContainer(uiYamlRaw: string): SomaBlockContainer;
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
39
|
+
* 装载块声明文件:开关剥离 → YAML 装载 → 块 id 校验 → 外置块合流。
|
|
40
40
|
*
|
|
41
41
|
* 每条校验都对应一种"静默失效":写了不存在的锚点、同一实例声明两遍、
|
|
42
42
|
* 块挂在普通锚点上——不拦的话都表现为"这段声明没生效",而不报错。
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { UiConfig } from '../../shared/types/ui-config.types';
|
|
2
|
-
export interface
|
|
2
|
+
export interface FlatPageFiles {
|
|
3
3
|
uiYaml: Record<string, unknown>;
|
|
4
4
|
eventYaml?: Record<string, unknown>;
|
|
5
5
|
styleYaml?: Record<string, unknown>;
|
|
@@ -12,21 +12,21 @@ export interface MigrationReport {
|
|
|
12
12
|
manual: string[];
|
|
13
13
|
}
|
|
14
14
|
export interface MigrationResult {
|
|
15
|
-
/**
|
|
15
|
+
/** 块声明文本(含 `{{` 开关) */
|
|
16
16
|
somaText: string;
|
|
17
17
|
/** 结构形态(便于测试与等价比对) */
|
|
18
18
|
blocks: Record<string, unknown>;
|
|
19
19
|
report: MigrationReport;
|
|
20
20
|
}
|
|
21
|
-
/**
|
|
22
|
-
export declare function
|
|
21
|
+
/** 把一页平铺声明迁移为块结构 */
|
|
22
|
+
export declare function migrateFlatToBlocks(files: FlatPageFiles): MigrationResult;
|
|
23
23
|
/**
|
|
24
24
|
* 语义等价比对:迁移前后的作用域清单树必须一致。
|
|
25
25
|
*
|
|
26
26
|
* 比对的是**结构**而非文本——文本必然不同(那正是迁移的目的),
|
|
27
27
|
* 但绑定关系、作用域层级、事件路由必须逐条对得上。
|
|
28
28
|
*/
|
|
29
|
-
export declare function verifyEquivalence(
|
|
29
|
+
export declare function verifyEquivalence(flatUi: UiConfig, blockCompiled: {
|
|
30
30
|
ui: UiConfig;
|
|
31
31
|
event: Record<string, unknown>;
|
|
32
|
-
},
|
|
32
|
+
}, flatEvent?: Record<string, unknown>): string[];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { SomaComponentContract } from '../../shared/types/component-contract.types';
|
|
2
|
-
export type ContractCompatIssueKind = 'prop-missing' | 'prop-type-changed' | 'prop-required-tightened' | 'prop-default-diverged' | 'emit-missing';
|
|
2
|
+
export type ContractCompatIssueKind = 'prop-missing' | 'prop-type-changed' | 'prop-required-tightened' | 'prop-default-diverged' | 'emit-missing' | 'slot-missing' | 'slot-required-tightened';
|
|
3
3
|
export interface ContractCompatIssue {
|
|
4
4
|
kind: ContractCompatIssueKind;
|
|
5
|
-
/** prop
|
|
5
|
+
/** prop / emit / slot 名 */
|
|
6
6
|
member: string;
|
|
7
7
|
/** 点名到具体差异内容——报错信息是接入者读得最认真的文档 */
|
|
8
8
|
detail: string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 由平铺示例派生一行块写法;换算不出来时返回 null。
|
|
3
|
+
*
|
|
4
|
+
* 产出的是**块声明**片段(写进 `_ui.yaml` 的 `{{ … }}` 之内),
|
|
5
|
+
* html 那一行两种写法通用,不重复。
|
|
6
|
+
*/
|
|
7
|
+
export declare function deriveBlockExample(componentName: string, example: string): string | null;
|
|
8
|
+
/** 示例里的 html 行(两种写法通用),供块写法段复用而不重复贴一遍 */
|
|
9
|
+
export declare function exampleHtmlLine(example: string): string | null;
|
|
@@ -2,7 +2,8 @@ import { DefaultNotifyService } from './DefaultNotifyService';
|
|
|
2
2
|
import type { NotifyOptions } from './INotifyService';
|
|
3
3
|
import type { ToastTheme } from './INotifyTheme';
|
|
4
4
|
/**
|
|
5
|
-
* 浏览器端通知:样式类名由宿主 app.config.yaml → notify.toast
|
|
5
|
+
* 浏览器端通知:样式类名由宿主 app.config.yaml → notify.toast 注入;
|
|
6
|
+
* core 不关心这些类名由哪一种 CSS 工具链或业务样式表提供。
|
|
6
7
|
*/
|
|
7
8
|
export declare class DomNotifyService extends DefaultNotifyService {
|
|
8
9
|
private readonly theme;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { UiConfig } from '../../../shared/types/ui-config.types';
|
|
2
2
|
import { type BlockScope } from './namespace';
|
|
3
3
|
export interface PageBlockAst {
|
|
4
|
-
/**
|
|
4
|
+
/** 平铺等价 UiConfig:直接交既有编译管线 */
|
|
5
5
|
ui: UiConfig;
|
|
6
|
-
/** 事件段原文(交 pipeline-parser
|
|
6
|
+
/** 事件段原文(交 pipeline-parser,形状与平铺 _event.yaml 一致) */
|
|
7
7
|
eventRaw: Record<string, unknown>;
|
|
8
8
|
/** 数据段原文(页面级共享对象,交数据对象层) */
|
|
9
9
|
dataRaw?: Record<string, unknown>;
|
|
@@ -56,7 +56,7 @@ export interface UseBlockAst {
|
|
|
56
56
|
/** emit 路由:emit 名 → Pipeline 表达式 */
|
|
57
57
|
emitRoutes: Record<string, string>;
|
|
58
58
|
scope: BlockScope;
|
|
59
|
-
/**
|
|
59
|
+
/** 供既有编译管线消费的 props 形态 */
|
|
60
60
|
toShowValue(): ExtendedShowValue;
|
|
61
61
|
}
|
|
62
62
|
export interface ParseUseInput {
|
|
@@ -10,7 +10,7 @@ export declare class SomaStyleConfigError extends Error {
|
|
|
10
10
|
*
|
|
11
11
|
* 校验规则:
|
|
12
12
|
* - host 必须是非空字符串
|
|
13
|
-
* - base 的值必须是纯
|
|
13
|
+
* - base 的值必须是纯 CSS 类名字符串;core 不解析也不编译具体类名
|
|
14
14
|
* - states 的 condition 必须是纯属性路径,value 必须是基础类型
|
|
15
15
|
* - transitions 的 trigger 必须是有效枚举值
|
|
16
16
|
* - base / themes 命中布局类模式即失败;states / transitions 放行显隐对(F-06)
|
|
@@ -8,3 +8,4 @@
|
|
|
8
8
|
export { createGeneratedPagePreview, type GeneratedPageDeclarations, type GeneratedPagePreviewOptions, type PrecompiledDeclarationAssets, type PreviewHandle, type PreviewObservabilityOptions, } from './declaration-renderer';
|
|
9
9
|
export { createSomaPageLifecycle, SomaPageLifecycle, type MountedPageInfo, type RegisterDeclarationOptions, type SomaPageLifecycleOptions, } from './page-lifecycle';
|
|
10
10
|
export { renderPublishedPage, type PublishedPageHandle, type PublishedPageRecord, type RenderPublishedPageOptions, } from './remote-page';
|
|
11
|
+
export { PUBLISHED_PAGE_SLUG_PATTERN, RESERVED_PUBLISHED_PAGE_SLUGS, isPublishedPageSlug, normalizePublishedPageSlug, publishedPagePath, publishedPageSlugFromPath, } from '../../shared/published-page-route';
|
|
@@ -18,6 +18,17 @@ export interface SomaThemeInput {
|
|
|
18
18
|
dark?: boolean;
|
|
19
19
|
/** 逐令牌精调通道:最后合并进 cssVars 与 darkCssVars,优先级最高(亮暗同时生效) */
|
|
20
20
|
overrides?: Record<string, string>;
|
|
21
|
+
/**
|
|
22
|
+
* 暗色专属精调:只并进 darkCssVars,在 `overrides` **之后**合并(同键胜出)。
|
|
23
|
+
*
|
|
24
|
+
* 为什么需要它:`overrides` 一份表同时盖亮暗两套,等于「一个令牌只能有一个值」。
|
|
25
|
+
* 后果不是理论问题——`soma-ui/src/daisy-presets.ts` 里 daisyLight / daisyDark 因此
|
|
26
|
+
* 被迫拆成两套完整独立预设,而 `ThemeScope` 的 `mode: 'system'` 只认一个预设名,
|
|
27
|
+
* 于是 35 套 daisy 主题的跟随系统亮暗**全部失效**。
|
|
28
|
+
*
|
|
29
|
+
* 缺省不给 = 行为与之前字节级一致(不影响任何既有预设)。
|
|
30
|
+
*/
|
|
31
|
+
darkOverrides?: Record<string, string>;
|
|
21
32
|
}
|
|
22
33
|
export interface SomaThemeMeta {
|
|
23
34
|
/** 本次派生实际生效的轴位(含缺省回落)——诊断与测试的观测面 */
|
package/dist/types/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export type { SomaDataHttpLike, SomaDataResolverOptions, SomaDataResolveResult,
|
|
|
17
17
|
export { parseDataConfig, parseDataYaml, parseDataRef, normalizeDataPipeValue, SomaDataConfigError, } from './client/parser/data-config-parser';
|
|
18
18
|
export type { SomaDataRef } from './client/parser/data-config-parser';
|
|
19
19
|
export type { SomaDataConfig, SomaDataObjectConfig, SomaDataSourceConfig, SomaDataFieldConfig, SomaDataFieldRule, SomaDataFieldOption, SomaDataFieldType, SomaDataFieldPermission, SomaDataDicts, } from './shared/types/data-config.types';
|
|
20
|
+
export { SOMA_DATA_FIELD_TYPES, SOMA_DATA_FIELD_TYPE_ALIASES, } from './shared/types/data-config.types';
|
|
20
21
|
export { deriveTheme, applyTheme, contrastRatio, THEME_SWITCHING_CLASS, } from './client/theme/theme-engine';
|
|
21
22
|
export type { SomaThemeInput, SomaDerivedTheme, SomaThemeMeta } from './client/theme/theme-engine';
|
|
22
23
|
export { themeRootAttributes } from './client/theme/theme-engine';
|
|
@@ -68,16 +69,16 @@ export { resolveHostBootstrapOptions } from './client/host-bridge/resolve-host-b
|
|
|
68
69
|
export type { SomaHostRequestContext, SomaHostRequestKind, SomaRequestHook, } from './server/host/resolve-host-request-hook';
|
|
69
70
|
export type { SomaDomainLoadContext, SomaDomainLoader, SomaDomainLoaderMap, SomaDomainLoaderModule, SomaDomainModule, SomaDomainModuleResolver, } from './client/host-bridge/soma-domain-loaders';
|
|
70
71
|
export { createSomaDomainLoaderKey, findSomaDomainLoader, loadSomaDomainModuleFromRegistry, } from './client/host-bridge/soma-domain-loaders';
|
|
71
|
-
export { createGeneratedPagePreview, createSomaPageLifecycle, renderPublishedPage, SomaPageLifecycle, type GeneratedPageDeclarations, type GeneratedPagePreviewOptions, type PrecompiledDeclarationAssets, type PreviewHandle, type PreviewObservabilityOptions, type MountedPageInfo, type PublishedPageHandle, type PublishedPageRecord, type RegisterDeclarationOptions, type RenderPublishedPageOptions, type SomaPageLifecycleOptions, } from './client/registry/index';
|
|
72
|
+
export { createGeneratedPagePreview, createSomaPageLifecycle, renderPublishedPage, SomaPageLifecycle, type GeneratedPageDeclarations, type GeneratedPagePreviewOptions, type PrecompiledDeclarationAssets, type PreviewHandle, type PreviewObservabilityOptions, type MountedPageInfo, type PublishedPageHandle, type PublishedPageRecord, type RegisterDeclarationOptions, type RenderPublishedPageOptions, type SomaPageLifecycleOptions, PUBLISHED_PAGE_SLUG_PATTERN, RESERVED_PUBLISHED_PAGE_SLUGS, isPublishedPageSlug, normalizePublishedPageSlug, publishedPagePath, publishedPageSlugFromPath, } from './client/registry/index';
|
|
72
73
|
export { composeComponentPacks, generatePackCatalog, ComponentPackError, PACK_NAME_PATTERN, type ComposedComponentPacks, type ComposePacksOptions, type SomaComponentPack, type SomaComponentPackStyles, type PackOverrideEvent, } from './client/component/component-pack';
|
|
73
74
|
export { verifyComponentPack, type VerifyPackOptions } from './client/component/verify-pack';
|
|
74
75
|
export { parseValueSegment, evaluateValueNode, isArithSegment, isPlainPath, describeNode, SomaValueLangError, type ValueNode, type PipedValue, type ValuePosition, type HasVarFn, type EvalOptions, } from './client/parser/value-lang';
|
|
75
|
-
export { loadSomaFile,
|
|
76
|
-
export { buildHtmlAnchorIndex, type HtmlAnchorIndex, type HtmlAnchorInfo, } from './build/
|
|
76
|
+
export { loadSomaFile, SomaBlockParseError, PAGE_BLOCK_ID, type RawBlock, type SomaFileLoadInput, } from './build/blocks/block-container';
|
|
77
|
+
export { buildHtmlAnchorIndex, type HtmlAnchorIndex, type HtmlAnchorInfo, } from './build/blocks/html-index';
|
|
77
78
|
export { compilePageAssets } from './build/compiler/page-assets';
|
|
78
|
-
export {
|
|
79
|
-
export { parsePageBlock, type PageBlockAst, } from './client/parser/
|
|
80
|
-
export { parseUseBlock, type UseBlockAst, type DataObjectDecl, type FieldDecl, type ActionDecl, } from './client/parser/
|
|
81
|
-
export { buildBlockScope, resolvePath, resolveApiRef, expandPath, scopeHasVar, SomaScopeError, type BlockScope, } from './client/parser/
|
|
79
|
+
export { compileSomaBlocks, type CompiledSomaBlocks, type CompileSomaBlocksInput, } from './build/blocks/block-compile';
|
|
80
|
+
export { parsePageBlock, type PageBlockAst, } from './client/parser/blocks/page-parser';
|
|
81
|
+
export { parseUseBlock, type UseBlockAst, type DataObjectDecl, type FieldDecl, type ActionDecl, } from './client/parser/blocks/use-parser';
|
|
82
|
+
export { buildBlockScope, resolvePath, resolveApiRef, expandPath, scopeHasVar, SomaScopeError, type BlockScope, } from './client/parser/blocks/namespace';
|
|
82
83
|
export { checkOverrideCompat, type ContractCompatIssue, type ContractCompatIssueKind, } from './client/component/contract-compat';
|
|
83
84
|
export { attachPackStyles, ensurePackBaseStyles, resetPackStyleInjection, type PackStyleOptions, } from './client/component/pack-styles';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { publishedPageSlugFromPath } from '../../shared/published-page-route';
|
|
2
|
+
/** Registry `myworkspace` 的正式地址是 `/myworkspace`;兼容读取旧 `/pages/myworkspace`。 */
|
|
3
|
+
export declare const registryPageNameFromPath: typeof publishedPageSlugFromPath;
|
|
3
4
|
/** Registry 声明只在服务端编译,浏览器收到的仍是既有运行时资产。 */
|
|
4
5
|
export declare function loadPublishedRegistryPageAssets(pagePath: string): Promise<{
|
|
5
6
|
localeYaml: string;
|
|
@@ -20,7 +20,7 @@ export { readSomaCspNonce, somaCspNonceMetadata, type SomaCspHeaderBag, } from '
|
|
|
20
20
|
export { loadSomaServerPageAssets, SomaPageAssetError, type SomaServerPageAssets, type SomaPageAssetLoadProfile, } from './host/server-page-assets';
|
|
21
21
|
export { loadComponentPackage, loadComponentPackages, scanComponentPackages, SomaComponentPackageError, type LoadPackagesOptions, type PackScanWarning, } from '../build/component/package-loader';
|
|
22
22
|
export { loadComponentPackFromDir, type LoadPackFromDirOptions, } from '../build/component/pack-from-dir';
|
|
23
|
-
export { loadExternalBlocks, blocksDirOf, } from '../build/
|
|
23
|
+
export { loadExternalBlocks, blocksDirOf, } from '../build/blocks/block-loader';
|
|
24
24
|
export { setSomaDb, getSomaDb, resetSomaDb, createSomaDbSingleton, registerSomaDbProvider, disconnectSomaDb, withSomaDb, type ISomaDbProvider, } from './infra/db/soma-db';
|
|
25
25
|
export { SomaQuery } from './infra/db/query/SomaQuery';
|
|
26
26
|
export type { SomaBaseMapper } from './infra/db/mapper/SomaBaseMapper';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry 发布页的公开 URL 契约。
|
|
3
|
+
*
|
|
4
|
+
* 页面名就是根路径 slug:Registry `myworkspace` 对应 `/myworkspace`。
|
|
5
|
+
* `/pages/<name>` 仅保留为存量链接兼容入口,新发布结果不再生成该前缀。
|
|
6
|
+
*/
|
|
7
|
+
export declare const PUBLISHED_PAGE_SLUG_PATTERN: RegExp;
|
|
8
|
+
/** Next/SOMA 内部入口不能被 Registry 根路径页面占用。 */
|
|
9
|
+
export declare const RESERVED_PUBLISHED_PAGE_SLUGS: Set<string>;
|
|
10
|
+
export declare function isPublishedPageSlug(value: unknown): value is string;
|
|
11
|
+
/**
|
|
12
|
+
* 归一化模型或用户给出的候选路径。只做机械变换,不擅自翻译中文;
|
|
13
|
+
* 语义翻译由生成模型负责,调用方可在 null 时提供确定性兜底。
|
|
14
|
+
*/
|
|
15
|
+
export declare function normalizePublishedPageSlug(value: unknown): string | null;
|
|
16
|
+
export declare function publishedPagePath(slug: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* 根路径是正式入口;旧 `/pages/<name>` 继续可读,避免已分享链接立即失效。
|
|
19
|
+
* 只接受单段路径,子路径仍交给 Host 文件页处理。
|
|
20
|
+
*/
|
|
21
|
+
export declare function publishedPageSlugFromPath(pagePath: string): string | null;
|
|
@@ -1,5 +1,21 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 字段类型枚举(决定 soma-ui 双态映射走哪个渲染组件)。
|
|
3
|
+
*
|
|
4
|
+
* **这是字段类型的唯一真源。** 块声明的 `fields.type` 与 soma-ui 的双态映射表
|
|
5
|
+
* 都必须消费它,不得各自再抄一份——此前正是抄成了三份:
|
|
6
|
+
* 数据对象层 11 型、soma-ui 11 型(逐字重复)、块声明 9 型(已漂)。
|
|
7
|
+
* 后果是 `type: url` 在块声明里被解析器拒收,而 `type: percent` 能过解析器
|
|
8
|
+
* 却在 soma-ui 侧没有映射、静默按 text 渲染出来。
|
|
9
|
+
*/
|
|
10
|
+
export type SomaDataFieldType = 'text' | 'int' | 'float' | 'money' | 'bool' | 'enum' | 'date' | 'datetime' | 'image' | 'url' | 'richtext' | 'percent' | 'progress';
|
|
11
|
+
/**
|
|
12
|
+
* 类型别名:块声明历史上用 `number` 表示小数,与本表的 `float` 同义。
|
|
13
|
+
* 保留为可接受拼写而不是二选一,是因为两边都有存量声明——
|
|
14
|
+
* 归一到 `float` 由解析器做,词汇表只认一个概念。
|
|
15
|
+
*/
|
|
16
|
+
export declare const SOMA_DATA_FIELD_TYPE_ALIASES: Readonly<Record<string, SomaDataFieldType>>;
|
|
17
|
+
/** 全部合法字段类型(含别名),供解析器做封闭集校验 */
|
|
18
|
+
export declare const SOMA_DATA_FIELD_TYPES: readonly string[];
|
|
3
19
|
/** 字段权限:r 只读 / w 可写(决定双态映射走 show 还是 edit 形态) */
|
|
4
20
|
export type SomaDataFieldPermission = 'r' | 'w';
|
|
5
21
|
/** 枚举字段候选项(type: enum 专用) */
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import type { SomaCompiledBinding, SomaCompiledEvent
|
|
1
|
+
import type { SomaCompiledBinding, SomaCompiledEvent } from './manifest.types';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* 作用域清单树(组件体系 P0)。
|
|
4
4
|
*
|
|
5
|
-
* 设计规范:soma-core/doc/soma 作用域清单树.md
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* 设计规范:soma-core/doc/archive/soma 作用域清单树.md(事实已并入《运行时引擎详设》)。
|
|
6
|
+
*
|
|
7
|
+
* **状态:目标模型,尚未物化。** 当前运行时以「实例级迷你运行时」承载同一语义
|
|
8
|
+
* (见《soma 运行时引擎详设》§4);本文件先把节点形状定下来,随契约编译器落地。
|
|
9
|
+
* 除下面的管道类型外,其余类型暂无消费者——改动它们不会影响运行行为。
|
|
8
10
|
*
|
|
9
11
|
* 节点结构保持可 JSON 序列化(仅数组/普通对象,无 Map)——构建期产物与
|
|
10
|
-
*
|
|
12
|
+
* 运行期客户端编译产物必须深度相等,索引一律在运行时装配。
|
|
11
13
|
*/
|
|
12
14
|
export type SomaScopeKind = 'page' | 'list' | 'component';
|
|
13
15
|
export type SomaPropMode = 'oneway' | 'model';
|
|
@@ -68,15 +70,13 @@ export interface SomaScopeNode {
|
|
|
68
70
|
listVar?: string;
|
|
69
71
|
/** 异构列表模板选择器的绑定路径(DSL 扩展规范 2.1,行模板后缀 = 该路径取值) */
|
|
70
72
|
roleBy?: string;
|
|
71
|
-
/**
|
|
73
|
+
/** 本作用域直属锚点的绑定(结构与扁平清单逐字段同构) */
|
|
72
74
|
bindings: SomaCompiledBinding[];
|
|
73
75
|
events: SomaCompiledEvent[];
|
|
74
76
|
children: SomaScopeNode[];
|
|
75
77
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
+
/** 作用域树形态的运行清单(目标模型,尚无产出者与消费者) */
|
|
79
|
+
export interface SomaScopeManifest {
|
|
78
80
|
root: SomaScopeNode;
|
|
79
81
|
initProps?: Record<string, unknown>;
|
|
80
82
|
}
|
|
81
|
-
export type SomaAnyRuntimeManifest = SomaRuntimeManifest | SomaRuntimeManifestV2;
|
|
82
|
-
export declare function isManifestV2(manifest: SomaAnyRuntimeManifest): manifest is SomaRuntimeManifestV2;
|
|
@@ -15,7 +15,7 @@ export interface StyleStateRule {
|
|
|
15
15
|
condition: string;
|
|
16
16
|
/** 目标值(基础类型:string | number | boolean | null) */
|
|
17
17
|
value: string | number | boolean | null;
|
|
18
|
-
/** 匹配时应用的
|
|
18
|
+
/** 匹配时应用的 CSS 类名;具体样式由宿主样式系统提供 */
|
|
19
19
|
apply: string;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
@@ -28,7 +28,7 @@ export type TransitionTrigger = 'hover' | 'focus' | 'active' | 'enter' | 'leave'
|
|
|
28
28
|
export interface StyleTransition {
|
|
29
29
|
/** 触发方式 */
|
|
30
30
|
trigger: TransitionTrigger;
|
|
31
|
-
/** 应用的
|
|
31
|
+
/** 应用的 CSS 动画/过渡类名;具体样式由宿主样式系统提供 */
|
|
32
32
|
apply: string;
|
|
33
33
|
/** active_state 类型时的条件路径 */
|
|
34
34
|
condition?: string;
|
|
@@ -45,7 +45,7 @@ export interface ThemeStatesOverride {
|
|
|
45
45
|
* 单个主题配置
|
|
46
46
|
*/
|
|
47
47
|
export interface ThemeConfig {
|
|
48
|
-
/** 基础类名覆盖:somaId →
|
|
48
|
+
/** 基础类名覆盖:somaId → CSS 类名 */
|
|
49
49
|
base: Record<string, string>;
|
|
50
50
|
/** 状态规则覆盖 */
|
|
51
51
|
states: ThemeStatesOverride;
|
|
@@ -59,7 +59,7 @@ export interface ThemeConfig {
|
|
|
59
59
|
export interface StyleConfig {
|
|
60
60
|
/** 所属的业务对象标识(对应 data-soma-host) */
|
|
61
61
|
host: string;
|
|
62
|
-
/** 基础静态样式映射:somaId →
|
|
62
|
+
/** 基础静态样式映射:somaId → CSS 类名 */
|
|
63
63
|
base: Record<string, string>;
|
|
64
64
|
/** 状态驱动样式:somaId → 规则数组 */
|
|
65
65
|
states: Record<string, StyleStateRule[]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "soma-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "SOMA — Semantic Oriented Modular Architecture. A declarative frontend framework runtime built on Next.js 16 App Router.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"soma",
|
|
@@ -107,8 +107,6 @@
|
|
|
107
107
|
"dist/vscode/",
|
|
108
108
|
"proxy.ts",
|
|
109
109
|
"next.config.js",
|
|
110
|
-
"tailwind.config.ts",
|
|
111
|
-
"postcss.config.js",
|
|
112
110
|
"tsconfig.json",
|
|
113
111
|
"global.d.ts"
|
|
114
112
|
],
|
|
@@ -158,17 +156,14 @@
|
|
|
158
156
|
"@types/ws": "^8.5.13",
|
|
159
157
|
"@vitest/coverage-v8": "^3.2.7",
|
|
160
158
|
"ajv-formats": "3.0.1",
|
|
161
|
-
"autoprefixer": "^10.4.17",
|
|
162
159
|
"esbuild": "^0.25.12",
|
|
163
160
|
"js-yaml": "^4.3.1",
|
|
164
161
|
"jsdom": "^26.1.0",
|
|
165
162
|
"next": "16.3.1",
|
|
166
163
|
"playwright": "^1.62.1",
|
|
167
|
-
"postcss": "^8.4.33",
|
|
168
164
|
"react": "^18.3.0",
|
|
169
165
|
"react-dom": "^18.3.0",
|
|
170
166
|
"semver": "^7.8.5",
|
|
171
|
-
"tailwindcss": "^3.4.1",
|
|
172
167
|
"typescript": "^5.3.3",
|
|
173
168
|
"vite": "6.4.3",
|
|
174
169
|
"vitest": "^3.2.7",
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 由 v1 示例派生一行 v2 写法;换算不出来时返回 null。
|
|
3
|
-
*
|
|
4
|
-
* 产出的是**块声明**片段(写进 `_ui.yaml` 的 `{{ … }}` 之内),
|
|
5
|
-
* html 那一行 v1 v2 通用,不重复。
|
|
6
|
-
*/
|
|
7
|
-
export declare function deriveV2Example(componentName: string, example: string): string | null;
|
|
8
|
-
/** 示例里的 html 行(v1 v2 通用),供 v2 段复用而不重复贴一遍 */
|
|
9
|
-
export declare function exampleHtmlLine(example: string): string | null;
|
package/postcss.config.js
DELETED
package/tailwind.config.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { Config } from 'tailwindcss';
|
|
2
|
-
import fs from 'node:fs';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import { createRequire } from 'node:module';
|
|
5
|
-
import { fileURLToPath } from 'node:url';
|
|
6
|
-
import { getSomaAssetSources } from './core/server/host/source-packages';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Framework Tailwind config (loaded with soma-core / Next).
|
|
10
|
-
* Host theme/plugins come from SOMA_HOST_DIR/tailwind.config.cjs/js via presets.
|
|
11
|
-
*/
|
|
12
|
-
if (!process.env.SOMA_HOST_DIR) {
|
|
13
|
-
throw new Error('[soma-core] tailwind: SOMA_HOST_DIR is not set');
|
|
14
|
-
}
|
|
15
|
-
const hostDir = path.resolve(process.env.SOMA_HOST_DIR);
|
|
16
|
-
const require = createRequire(fileURLToPath(import.meta.url));
|
|
17
|
-
|
|
18
|
-
function loadHostPreset(): Config | null {
|
|
19
|
-
for (const name of ['tailwind.config.cjs', 'tailwind.config.js']) {
|
|
20
|
-
const cfgPath = path.join(hostDir, name);
|
|
21
|
-
if (!fs.existsSync(cfgPath)) continue;
|
|
22
|
-
const mod = require(cfgPath) as Config | { default: Config };
|
|
23
|
-
return ('default' in mod && mod.default) ? mod.default : (mod as Config);
|
|
24
|
-
}
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const hostPreset = loadHostPreset();
|
|
29
|
-
const sourceContent = getSomaAssetSources(hostDir).flatMap((source) => [
|
|
30
|
-
path.join(source.assetRoot, 'html/**/*.html'),
|
|
31
|
-
path.join(source.assetRoot, 'styles/**/*.css'),
|
|
32
|
-
]);
|
|
33
|
-
|
|
34
|
-
const config: Config = {
|
|
35
|
-
...(hostPreset ? { presets: [hostPreset] } : {}),
|
|
36
|
-
content: [
|
|
37
|
-
'./app/**/*.{js,ts,jsx,tsx,mdx}',
|
|
38
|
-
'./core/**/*.{js,ts,jsx,tsx}',
|
|
39
|
-
...sourceContent,
|
|
40
|
-
],
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export default config;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|