refactor(ui-kit): theme.css.ts 迁 themes 目录 #76

Merged
arnold.cui merged 2 commits from refactor/theme-css-to-themes into main 2026-12-03 01:46:31 +00:00
Member

背景

themeClass/themeVars 的定义文件一直在 src/tokens/theme.css.ts,而它的消费 barrel 却在 src/themes/index.ts,跨目录反向导入不自洽。语义主题的定义应归 themes 目录。

本 PR 最初叠在 #75 的早期提交上;#75 以 squash 合入 main 后,本分支已重放到 main(dea1162),只保留本 PR 自己的一个提交,tokens/refs.ts 与 #77 的冲突按 main 内容加路径替换解决。

变更内容

  • src/tokens/theme.css.ts → src/themes/theme.css.ts(git mv,保留重命名历史);
  • themes/index.ts 改 ./theme.css 直连;theme.css.ts 自身的 palette 导入改 ../tokens/palette.css;
  • 包内 10 处 themeVars 消费(components/ 下 9 个样式 css.ts,含 #75 迁入的 utilities.css.ts)与 tokens/refs.ts 的 type 导入改为按目录引用 import { themeVars } from '../themes'(dock/dock.css.ts 为 ../../themes),与包出口「按目录、不带文件名」的写法一致;themes/index.ts 相应同时导出 themeVars 与三个主题类;
  • 可行性:stack CLI 的 relativeResolve 会探测目录 index,ve 编译内部的 esbuild 与 TS bundler 模式同样支持目录说明符;.css.ts 在打包前已被 ve 插件编译成自包含 JS,stack 打包器与 SSR 实际不接触该说明符;
  • README 两处路径引用更新。

不动的东西:ve 编译为 roots 全量扫描 + 按导出名匹配主题类,无路径假设;e2e 不断言哈希类名;tokens/ 下 palette/site/refs 原位不动。

自测结果

  • format:check 绿;三个 typecheck 全绿(tutorial tsc -b、ui-kit、site-ui-kit);strip-comments 清除 0。
  • yarn workspace @stack/tutorial build 全量构建绿:24/24 页预渲染、181 模块。
  • 产物与 main 基线对比:迁移改变 ve 文件作用域,themeClass 与契约变量的哈希后缀随之变化(theme_themeClass__16rmnvlp → theme_themeClass__c2zyp1p);归一哈希后 __shared/ui-kit.css 规则内容与 main 完全一致,24 个预渲染 HTML 与 main 逐页相同;:root 桥接块恰好 1 个,--color-ink__ 仅一个作用域,HTML 中 class 含 undefined 0 处。
  • e2e 全量 159 通过(重放后、按目录引用后各跑一次),含全部视觉基线。
  • 按目录引用后与 e1b6e01 产物对比:归一哈希后预渲染 HTML 24/24 相同,ui-kit.css 规则集合完全一致;代价是经 barrel 引用后每个样式模块的编译产物多带一份 site 主题 CSS 块(site.css.ts 块 1 → 10 份,ui-kit.css 2247 → 2355 行),规则集合与渲染不变。
  • 提交作者与签名核对:arnold.cui-agent arnold.cui-agent@idealjs.com G(e1b6e01、326cb7a)。
  • CI / check (pull_request) 绿:run #742,3m52s(head 326cb7a)。
## 背景 `themeClass`/`themeVars` 的定义文件一直在 `src/tokens/theme.css.ts`,而它的消费 barrel 却在 `src/themes/index.ts`,跨目录反向导入不自洽。语义主题的定义应归 themes 目录。 本 PR 最初叠在 #75 的早期提交上;#75 以 squash 合入 main 后,本分支已重放到 main(dea1162),只保留本 PR 自己的一个提交,`tokens/refs.ts` 与 #77 的冲突按 main 内容加路径替换解决。 ## 变更内容 - `src/tokens/theme.css.ts` → `src/themes/theme.css.ts`(git mv,保留重命名历史); - `themes/index.ts` 改 `./theme.css` 直连;`theme.css.ts` 自身的 palette 导入改 `../tokens/palette.css`; - 包内 10 处 `themeVars` 消费(`components/` 下 9 个样式 css.ts,含 #75 迁入的 `utilities.css.ts`)与 `tokens/refs.ts` 的 type 导入改为**按目录引用** `import { themeVars } from '../themes'`(`dock/dock.css.ts` 为 `../../themes`),与包出口「按目录、不带文件名」的写法一致;`themes/index.ts` 相应同时导出 `themeVars` 与三个主题类; - 可行性:stack CLI 的 `relativeResolve` 会探测目录 index,ve 编译内部的 esbuild 与 TS bundler 模式同样支持目录说明符;`.css.ts` 在打包前已被 ve 插件编译成自包含 JS,stack 打包器与 SSR 实际不接触该说明符; - README 两处路径引用更新。 不动的东西:ve 编译为 roots 全量扫描 + 按导出名匹配主题类,无路径假设;e2e 不断言哈希类名;`tokens/` 下 palette/site/refs 原位不动。 ## 自测结果 - `format:check` 绿;三个 typecheck 全绿(tutorial `tsc -b`、ui-kit、site-ui-kit);strip-comments 清除 0。 - `yarn workspace @stack/tutorial build` 全量构建绿:24/24 页预渲染、181 模块。 - 产物与 main 基线对比:迁移改变 ve 文件作用域,`themeClass` 与契约变量的哈希后缀随之变化(`theme_themeClass__16rmnvlp` → `theme_themeClass__c2zyp1p`);归一哈希后 `__shared/ui-kit.css` 规则内容与 main 完全一致,24 个预渲染 HTML 与 main 逐页相同;`:root` 桥接块恰好 1 个,`--color-ink__` 仅一个作用域,HTML 中 `class` 含 `undefined` 0 处。 - e2e 全量 **159 通过**(重放后、按目录引用后各跑一次),含全部视觉基线。 - 按目录引用后与 e1b6e01 产物对比:归一哈希后预渲染 HTML 24/24 相同,`ui-kit.css` 规则集合完全一致;代价是经 barrel 引用后每个样式模块的编译产物多带一份 site 主题 CSS 块(`site.css.ts` 块 1 → 10 份,`ui-kit.css` 2247 → 2355 行),规则集合与渲染不变。 - 提交作者与签名核对:arnold.cui-agent <arnold.cui-agent@idealjs.com> G(e1b6e01、326cb7a)。 - CI / check (pull_request) 绿:[run #742](https://gitea.idealjs.com/idealjs/stack/actions/runs/742/jobs/828),3m52s(head 326cb7a)。
arnold.cui added 1 commit 2026-12-02 13:14:16 +00:00
refactor(ui-kit): theme.css.ts 迁 themes 目录
CI / check (pull_request) Successful in 3m2s
e1b6e01c55
themeClass 的定义一直在 tokens、消费 barrel 却在 themes,跨目录反向
导入不自洽。迁到 src/themes/theme.css.ts 后 themes 目录自有定义,
themes/index.ts 改 './theme.css' 直连;包内 10 处 import 与 README
两处路径同步更新。
arnold.cui force-pushed refactor/theme-css-to-themes from b813fce2f7 to e1b6e01c55 2026-12-02 13:14:16 +00:00 Compare
arnold.cui added 1 commit 2026-12-03 01:07:37 +00:00
组件样式模块对契约 themeVars 的引用从 '../themes/theme.css' 改为 '../themes',
与包出口按目录、不带文件名的写法一致;themes/index.ts 相应导出 themeVars。
tokens/refs.ts 的 type 导入同样改为 '../themes'。

stack CLI 的 relativeResolve 会探测目录 index,ve 编译内部的 esbuild 与 TS
bundler 模式同样支持目录说明符,三条链路均已实证。代价是经 barrel 引用后每个
样式模块的编译产物会多带一份 site 主题的 CSS 块,规则集合与渲染不变。
arnold.cui approved these changes 2026-12-03 01:46:26 +00:00
arnold.cui merged commit 4e4d491a39 into main 2026-12-03 01:46:31 +00:00
arnold.cui deleted branch refactor/theme-css-to-themes 2026-12-03 01:46:31 +00:00
Sign in to join this conversation.
No Reviewers
No labels
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: idealjs/stack#76