diff --git a/.gitignore b/.gitignore index 35d5efd59e..db6b97fad2 100644 --- a/.gitignore +++ b/.gitignore @@ -47,6 +47,7 @@ report.html coverage/ *.local.ts +*.local.md # Dependency directories node_modules/ @@ -132,4 +133,4 @@ packages/vchart/__tests__/runtime/node/**.png # env files .env.local -*.tsbuildinfo \ No newline at end of file +*.tsbuildinfo diff --git a/.trae/jobs/README.md b/.trae/jobs/README.md new file mode 100644 index 0000000000..d262cdb3df --- /dev/null +++ b/.trae/jobs/README.md @@ -0,0 +1,78 @@ +# 通过说明文件驱动执行 + +## 目的 + +- 不依赖“工作流模版”概念,仅在仓库中放置一个说明文件,描述任务与参数;我将按说明执行并回传报告。 + +## 放置位置 + +- 目录:`.trae/jobs/` +- 文件:建议使用 `*.request.md` 或 `*.request.json`,便于版本化与审阅。 + +## 通用字段 + +- `Task`:任务标识,例如 `Autotest (diff-with-develop)`。 +- `Parameters`:运行参数,例如 `sinceBranch`、`project`、`mode`、`noSnapshot`、`onlyNew`、`reportFormat`。 +- `ExecutionHints`(可选):执行提示,如是否跳过快照、是否仅分析、不写补丁、选择包。 +- `StepsOverride`(可选):覆盖默认执行步骤的命令或动作(如自定义 diff 命令)。 + +## 示例(Markdown 请求) + +``` +# Task +Autotest (diff-with-develop) + +# Parameters +sinceBranch: develop +project: '' +mode: full +noSnapshot: false +onlyNew: false +reportFormat: md + +# ExecutionHints +- skipWrite: false +- stopOnError: true + +# StepsOverride +- git fetch --all --prune +- git diff --name-status --diff-filter=AMR develop...HEAD +- rush run -s test +- rush run -s test-cov +``` + +## 使用方式 + +- 推荐入口文件:`.trae/jobs/autotest.md`(已提供,含参数、步骤、人工覆写与成功标准) +- 最简用法(默认参数):在聊天中发起“执行 Autotest Job(.trae/jobs/autotest.md)”。 +- 可选覆盖参数:`project=@visactor/vchart-theme`、`reportFormat=json`、`replaceAutogen=true` 等。 +- 我将按 `.trae/jobs/autotest.md` 的步骤顺序执行:采集差异、分析缺口、生成/更新测试(含函数级注释)、运行覆盖率、生成报告、插入人工节点。 + +## 结果与报告 + +- 报告以 `reportFormat` 指定(`md` 或 `json`)。 +- 我会附带执行日志摘要、受影响包、生成/跳过的测试、覆盖率与人工节点清单。 + +## 旧方案清理 + +- 旧的“工作流模版”文件与文档已移除: + - `.trae/workflows/autotest.diff-with-develop.json` + - `docs/autotest-workflow.md` +- 现仅保留 Job 文件方案(`.trae/jobs/autotest.md`)。 + +## 默认参数(参考) + +- `sinceBranch=develop` +- `project=auto`(自动按 diff 识别变更包) +- `mode=full` +- `noSnapshot=false` +- `onlyNew=false` +- `reportFormat=md` +- `applyManualOverrides=true` +- `replaceAutogen=false` +- `dryRun=false` +- `preview=false` +- `stopOnError=true` +- `focusChangedOnly=true` +- `snapshotStrategy=combined` +- `mockDefaults: time=fixed(2020-01-01T00:00:00Z), random=seed(42)` diff --git a/.trae/jobs/autotest.md b/.trae/jobs/autotest.md new file mode 100644 index 0000000000..acf9b3b68c --- /dev/null +++ b/.trae/jobs/autotest.md @@ -0,0 +1,137 @@ +--- +job: unit-test-autogen +intent: generate-unit-tests-from-diff +version: v1 +domain: testing +runner: trae-solo +parameters: + sinceBranch: develop + project: auto + mode: full + noSnapshot: false + onlyNew: false + reportFormat: md + applyManualOverrides: true + replaceAutogen: false + dryRun: false + preview: false + stopOnError: true + focusChangedOnly: true + snapshotStrategy: combined + tempReportPath: .trae/jobs/autotest.report.local.md + mockDefaults: + time: fixed(2020-01-01T00:00:00Z) + random: seed(42) +constraints: + framework: jest-ts-jest + layout: __tests__/*.test.ts + comments: function-level-jsdoc +outputs: + - test_files + - snapshots + - coverage_report + - manual_nodes + - temp_markdown_report +success_criteria: + - tests_generated_for_changed_exports + - compile_without_errors + - coverage_increase_or_maintained +manual_overrides: [] +--- + +# Autotest Job(差异驱动单元测试自动生成) + +## 步骤 + +1. 差异采集 + +- 运行 `git fetch --all --prune` +- 运行 `git diff --name-status --diff-filter=AMR {{sinceBranch}}...HEAD` +- 对每个变更文件,运行 `git diff --unified=0 {{sinceBranch}}...HEAD ` 获取行级差异 + +2. 影响分析 + +- 识别导出符号、类型签名与逻辑分支;在包内搜索已有 `__tests__` 及缺口 + +3. 测试生成 + +- 在 `__tests__` 下创建或更新 `.test.ts` 文件;为每个 `describe/it` 添加函数级注释(JSDoc,说明目的、前置/输入、断言点) +- 策略: + - 纯函数/工具:正常/边界/异常分支 + - 主题 JSON:`toMatchSnapshot()` + 关键字段断言(颜色、字体、间距) + - 转换器:代表性输入,断言输出结构与关键键值;必要时增量快照 +- Mock/Spy:固定时间与随机数;隔离外部依赖(网络/FS) +- 自动化区块命名规则: + - `describe('autogen:/::')` + - `it('autogen::')` + +4. 放置与命名 + +- `src/foo.ts` → `__tests__/foo.test.ts`;若已有则增量插入新的自动化区块 +- 导入路径优先使用公开 API(例如 `src/index.ts`) + +5. 执行与覆盖率 + +- 若指定 `project`:`rush run -p {{project}} -s test` 与 `test-cov` +- 未指定则按变更包批量执行上述命令 + +6. 诊断与报告 + +- TypeScript 诊断:收集编译错误并在报告中标注阻断项 +- 报告输出(`{{reportFormat}}`):列出变更文件 → 新增/更新测试 → 通过/失败 → 覆盖率增量 → 人工节点清单 +- 临时报告写入:将本次执行结果以 Markdown 形式写入 `{{tempReportPath}}` + + - 必含内容: + - 变更摘要(文件列表与关键行级片段定位) + - 新增/更新测试用例与断言点说明 + - 运行结果(套件/用例通过统计、覆盖率摘要、TS 诊断) + - 重点一致性问题与潜在错误点(类型/注释一致性、契约风险、默认值依赖、测试桩稳定性) + - 建议与后续动作(文档补充、契约确认、健壮性增强) + - 示例结构: + + ```md + # Autotest 临时报告 + + ## 变更摘要 + + ## 行级差异(关键片段) + + ## 新增/更新的测试 + + ## 运行结果 + + ## 一致性与潜在风险(重点) + + ## 建议与后续动作 + ``` + +7. 人工节点与二次执行 + +- 初次生成时对不明确 Mock/快照的用例插入占位并标记:`it('autogen:MANUAL_REQUIRED:')` 与 `test.skip(...)` +- 二次执行流程: + - 在本文件 `manual_overrides` 段中添加结构化覆写策略(见下例)或直接编辑测试文件中的占位并移除 `skip` + - 默认不覆盖人工命名块(不含 `autogen:` 前缀);仅增量生成缺失的自动化区块 + - 若 `replaceAutogen=true`,允许替换已有 `autogen:` 区块 + +## manual_overrides 示例 + +```yaml +manual_overrides: + - target: packages/vchart-theme/src/foo.ts#exportedFn + mocks: + date: fixed(2020-01-01T00:00:00Z) + random: seed(42) + external: "jest.mock('@pkg/bar', () => ({ /* ... */ }))" + inputs: + - { args: [1, 2], desc: '正常路径' } + - { args: [null], desc: '异常路径' } + asserts: + - { expect: 'toEqual', value: { ok: true } } +``` + +## 执行(Solo 模式) + +- 最简用法(使用默认参数):在聊天中发起“执行 Autotest Job(.trae/jobs/autotest.md)”。 +- 可选覆盖参数示例:`project=@visactor/vchart-theme`、`reportFormat=json`、`replaceAutogen=true`。 +- 我将按上述步骤顺序执行,并返回报告与人工节点处理结果。 +- 临时报告路径可通过 `tempReportPath` 覆盖,默认:`.trae/jobs/autotest.report.local.md`。 diff --git a/.trae/jobs/autotest.request.md b/.trae/jobs/autotest.request.md new file mode 100644 index 0000000000..5ecd56f3e6 --- /dev/null +++ b/.trae/jobs/autotest.request.md @@ -0,0 +1,21 @@ +# Task +Autotest (diff-with-develop) + +# Parameters +sinceBranch: develop +project: '' +mode: full +noSnapshot: false +onlyNew: false +reportFormat: md + +# ExecutionHints +- skipWrite: false +- stopOnError: true + +# StepsOverride +# 如需覆盖默认步骤,取消下面行的注释并按需修改 +# - git fetch --all --prune +# - git diff --name-status --diff-filter=AMR develop...HEAD +# - rush run -s test +# - rush run -s test-cov diff --git a/common/autoinstallers/run-script/pnpm-lock.yaml b/common/autoinstallers/run-script/pnpm-lock.yaml index 56d9164962..1612401b2c 100644 --- a/common/autoinstallers/run-script/pnpm-lock.yaml +++ b/common/autoinstallers/run-script/pnpm-lock.yaml @@ -10,20 +10,20 @@ importers: dependencies: '@microsoft/rush-lib': specifier: 5.148.0 - version: 5.148.0(@types/node@25.0.3) + version: 5.148.0(@types/node@25.0.1) minimist: specifier: 1.2.8 version: 1.2.8 ts-node: specifier: 10.9.0 - version: 10.9.0(@types/node@25.0.3)(typescript@4.9.5) + version: 10.9.0(@types/node@25.0.1)(typescript@4.9.5) devDependencies: '@types/minimist': specifier: 1.2.2 version: 1.2.2 '@types/node': specifier: '*' - version: 25.0.3 + version: 25.0.1 typescript: specifier: 4.9.5 version: 4.9.5 @@ -348,8 +348,8 @@ packages: '@types/minimist@1.2.2': resolution: {integrity: sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ==} - '@types/node@25.0.3': - resolution: {integrity: sha512-W609buLVRVmeW693xKfzHeIV6nJGGz98uCPfeXI1ELMLXVeKYZ9m15fAMSaUPBHYLGFsVRcMmSCksQOrZV9BYA==} + '@types/node@25.0.1': + resolution: {integrity: sha512-czWPzKIAXucn9PtsttxmumiQ9N0ok9FrBwgRWrwmVLlp86BrMExzvXRLFYRJ+Ex3g6yqj+KuaxfX1JTgV2lpfg==} '@types/normalize-package-data@2.4.4': resolution: {integrity: sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==} @@ -776,8 +776,8 @@ packages: resolution: {integrity: sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==} engines: {node: '>=8.6.0'} - fast-xml-parser@5.3.3: - resolution: {integrity: sha512-2O3dkPAAC6JavuMm8+4+pgTk+5hoAs+CjZ+sWcQLkX9+/tHRuTkQh/Oaifr8qDmZ8iEHb771Ea6G8CdwkrgvYA==} + fast-xml-parser@5.3.2: + resolution: {integrity: sha512-n8v8b6p4Z1sMgqRmqLJm3awW4NX7NkaKPfb3uJIBTSH7Pdvufi3PQ3/lJLQrvxcMYl7JI2jnDO90siPEpD8JBA==} hasBin: true fastq@1.19.1: @@ -1799,8 +1799,8 @@ packages: resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==} engines: {node: '>=8'} - strnum@2.1.2: - resolution: {integrity: sha512-l63NF9y/cLROq/yqKXSLtcMeeyOfnSQlfMSlzFt/K73oIaD8DGaQWd7Z34X9GPiKqP5rbSh84Hl4bOlLcjiSrQ==} + strnum@2.1.1: + resolution: {integrity: sha512-7ZvoFTiCnGxBtDqJ//Cu6fWtZtc7Y3x+QOirG15wztbdngGSkht27o2pyGWrVy0b4WAy3jbKmnoK6g5VlVNUUw==} supports-color@5.5.0: resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==} @@ -2094,7 +2094,7 @@ snapshots: '@azure/core-xml@1.5.0': dependencies: - fast-xml-parser: 5.3.3 + fast-xml-parser: 5.3.2 tslib: 2.8.1 '@azure/identity@4.5.0': @@ -2235,23 +2235,23 @@ snapshots: dependencies: jsep: 1.4.0 - '@microsoft/rush-lib@5.148.0(@types/node@25.0.3)': + '@microsoft/rush-lib@5.148.0(@types/node@25.0.1)': dependencies: '@pnpm/dependency-path': 5.1.7 '@pnpm/dependency-path-lockfile-pre-v9': '@pnpm/dependency-path@2.1.8' '@pnpm/link-bins': 5.3.25 - '@rushstack/heft-config-file': 0.16.3(@types/node@25.0.3) - '@rushstack/lookup-by-path': 0.5.2(@types/node@25.0.3) - '@rushstack/node-core-library': 5.10.2(@types/node@25.0.3) - '@rushstack/package-deps-hash': 4.3.3(@types/node@25.0.3) - '@rushstack/package-extractor': 0.10.7(@types/node@25.0.3) + '@rushstack/heft-config-file': 0.16.3(@types/node@25.0.1) + '@rushstack/lookup-by-path': 0.5.2(@types/node@25.0.1) + '@rushstack/node-core-library': 5.10.2(@types/node@25.0.1) + '@rushstack/package-deps-hash': 4.3.3(@types/node@25.0.1) + '@rushstack/package-extractor': 0.10.7(@types/node@25.0.1) '@rushstack/rig-package': 0.5.3 - '@rushstack/rush-amazon-s3-build-cache-plugin': 5.148.0(@types/node@25.0.3) - '@rushstack/rush-azure-storage-build-cache-plugin': 5.148.0(@types/node@25.0.3) - '@rushstack/rush-http-build-cache-plugin': 5.148.0(@types/node@25.0.3) - '@rushstack/stream-collator': 4.1.81(@types/node@25.0.3) - '@rushstack/terminal': 0.14.5(@types/node@25.0.3) - '@rushstack/ts-command-line': 4.23.3(@types/node@25.0.3) + '@rushstack/rush-amazon-s3-build-cache-plugin': 5.148.0(@types/node@25.0.1) + '@rushstack/rush-azure-storage-build-cache-plugin': 5.148.0(@types/node@25.0.1) + '@rushstack/rush-http-build-cache-plugin': 5.148.0(@types/node@25.0.1) + '@rushstack/stream-collator': 4.1.81(@types/node@25.0.1) + '@rushstack/terminal': 0.14.5(@types/node@25.0.1) + '@rushstack/ts-command-line': 4.23.3(@types/node@25.0.1) '@yarnpkg/lockfile': 1.0.2 builtin-modules: 3.1.0 cli-table: 0.3.11 @@ -2393,20 +2393,20 @@ snapshots: write-file-atomic: 3.0.3 write-yaml-file: 4.2.0 - '@rushstack/heft-config-file@0.16.3(@types/node@25.0.3)': + '@rushstack/heft-config-file@0.16.3(@types/node@25.0.1)': dependencies: - '@rushstack/node-core-library': 5.10.2(@types/node@25.0.3) + '@rushstack/node-core-library': 5.10.2(@types/node@25.0.1) '@rushstack/rig-package': 0.5.3 - '@rushstack/terminal': 0.14.5(@types/node@25.0.3) + '@rushstack/terminal': 0.14.5(@types/node@25.0.1) jsonpath-plus: 10.2.0 transitivePeerDependencies: - '@types/node' - '@rushstack/lookup-by-path@0.5.2(@types/node@25.0.3)': + '@rushstack/lookup-by-path@0.5.2(@types/node@25.0.1)': optionalDependencies: - '@types/node': 25.0.3 + '@types/node': 25.0.1 - '@rushstack/node-core-library@5.10.2(@types/node@25.0.3)': + '@rushstack/node-core-library@5.10.2(@types/node@25.0.1)': dependencies: ajv: 8.13.0 ajv-draft-04: 1.0.0(ajv@8.13.0) @@ -2417,20 +2417,20 @@ snapshots: resolve: 1.22.11 semver: 7.5.4 optionalDependencies: - '@types/node': 25.0.3 + '@types/node': 25.0.1 - '@rushstack/package-deps-hash@4.3.3(@types/node@25.0.3)': + '@rushstack/package-deps-hash@4.3.3(@types/node@25.0.1)': dependencies: - '@rushstack/node-core-library': 5.10.2(@types/node@25.0.3) + '@rushstack/node-core-library': 5.10.2(@types/node@25.0.1) transitivePeerDependencies: - '@types/node' - '@rushstack/package-extractor@0.10.7(@types/node@25.0.3)': + '@rushstack/package-extractor@0.10.7(@types/node@25.0.1)': dependencies: '@pnpm/link-bins': 5.3.25 - '@rushstack/node-core-library': 5.10.2(@types/node@25.0.3) - '@rushstack/terminal': 0.14.5(@types/node@25.0.3) - '@rushstack/ts-command-line': 4.23.3(@types/node@25.0.3) + '@rushstack/node-core-library': 5.10.2(@types/node@25.0.1) + '@rushstack/terminal': 0.14.5(@types/node@25.0.1) + '@rushstack/ts-command-line': 4.23.3(@types/node@25.0.1) ignore: 5.1.9 jszip: 3.8.0 minimatch: 3.0.8 @@ -2444,64 +2444,64 @@ snapshots: resolve: 1.22.11 strip-json-comments: 3.1.1 - '@rushstack/rush-amazon-s3-build-cache-plugin@5.148.0(@types/node@25.0.3)': + '@rushstack/rush-amazon-s3-build-cache-plugin@5.148.0(@types/node@25.0.1)': dependencies: - '@rushstack/node-core-library': 5.10.2(@types/node@25.0.3) - '@rushstack/rush-sdk': 5.148.0(@types/node@25.0.3) - '@rushstack/terminal': 0.14.5(@types/node@25.0.3) + '@rushstack/node-core-library': 5.10.2(@types/node@25.0.1) + '@rushstack/rush-sdk': 5.148.0(@types/node@25.0.1) + '@rushstack/terminal': 0.14.5(@types/node@25.0.1) https-proxy-agent: 5.0.1 transitivePeerDependencies: - '@types/node' - supports-color - '@rushstack/rush-azure-storage-build-cache-plugin@5.148.0(@types/node@25.0.3)': + '@rushstack/rush-azure-storage-build-cache-plugin@5.148.0(@types/node@25.0.1)': dependencies: '@azure/identity': 4.5.0 '@azure/storage-blob': 12.26.0 - '@rushstack/node-core-library': 5.10.2(@types/node@25.0.3) - '@rushstack/rush-sdk': 5.148.0(@types/node@25.0.3) - '@rushstack/terminal': 0.14.5(@types/node@25.0.3) + '@rushstack/node-core-library': 5.10.2(@types/node@25.0.1) + '@rushstack/rush-sdk': 5.148.0(@types/node@25.0.1) + '@rushstack/terminal': 0.14.5(@types/node@25.0.1) transitivePeerDependencies: - '@types/node' - supports-color - '@rushstack/rush-http-build-cache-plugin@5.148.0(@types/node@25.0.3)': + '@rushstack/rush-http-build-cache-plugin@5.148.0(@types/node@25.0.1)': dependencies: - '@rushstack/node-core-library': 5.10.2(@types/node@25.0.3) - '@rushstack/rush-sdk': 5.148.0(@types/node@25.0.3) + '@rushstack/node-core-library': 5.10.2(@types/node@25.0.1) + '@rushstack/rush-sdk': 5.148.0(@types/node@25.0.1) https-proxy-agent: 5.0.1 transitivePeerDependencies: - '@types/node' - supports-color - '@rushstack/rush-sdk@5.148.0(@types/node@25.0.3)': + '@rushstack/rush-sdk@5.148.0(@types/node@25.0.1)': dependencies: '@pnpm/lockfile.types': 1.0.3 - '@rushstack/lookup-by-path': 0.5.2(@types/node@25.0.3) - '@rushstack/node-core-library': 5.10.2(@types/node@25.0.3) - '@rushstack/package-deps-hash': 4.3.3(@types/node@25.0.3) - '@rushstack/terminal': 0.14.5(@types/node@25.0.3) + '@rushstack/lookup-by-path': 0.5.2(@types/node@25.0.1) + '@rushstack/node-core-library': 5.10.2(@types/node@25.0.1) + '@rushstack/package-deps-hash': 4.3.3(@types/node@25.0.1) + '@rushstack/terminal': 0.14.5(@types/node@25.0.1) tapable: 2.2.1 transitivePeerDependencies: - '@types/node' - '@rushstack/stream-collator@4.1.81(@types/node@25.0.3)': + '@rushstack/stream-collator@4.1.81(@types/node@25.0.1)': dependencies: - '@rushstack/node-core-library': 5.10.2(@types/node@25.0.3) - '@rushstack/terminal': 0.14.5(@types/node@25.0.3) + '@rushstack/node-core-library': 5.10.2(@types/node@25.0.1) + '@rushstack/terminal': 0.14.5(@types/node@25.0.1) transitivePeerDependencies: - '@types/node' - '@rushstack/terminal@0.14.5(@types/node@25.0.3)': + '@rushstack/terminal@0.14.5(@types/node@25.0.1)': dependencies: - '@rushstack/node-core-library': 5.10.2(@types/node@25.0.3) + '@rushstack/node-core-library': 5.10.2(@types/node@25.0.1) supports-color: 8.1.1 optionalDependencies: - '@types/node': 25.0.3 + '@types/node': 25.0.1 - '@rushstack/ts-command-line@4.23.3(@types/node@25.0.3)': + '@rushstack/ts-command-line@4.23.3(@types/node@25.0.1)': dependencies: - '@rushstack/terminal': 0.14.5(@types/node@25.0.3) + '@rushstack/terminal': 0.14.5(@types/node@25.0.1) '@types/argparse': 1.0.38 argparse: 1.0.10 string-argv: 0.3.2 @@ -2526,7 +2526,7 @@ snapshots: '@types/keyv@3.1.4': dependencies: - '@types/node': 25.0.3 + '@types/node': 25.0.1 '@types/lodash@4.17.21': {} @@ -2534,7 +2534,7 @@ snapshots: '@types/minimist@1.2.2': {} - '@types/node@25.0.3': + '@types/node@25.0.1': dependencies: undici-types: 7.16.0 @@ -2544,7 +2544,7 @@ snapshots: '@types/responselike@1.0.3': dependencies: - '@types/node': 25.0.3 + '@types/node': 25.0.1 '@typespec/ts-http-runtime@0.3.2': dependencies: @@ -2985,9 +2985,9 @@ snapshots: merge2: 1.4.1 micromatch: 4.0.8 - fast-xml-parser@5.3.3: + fast-xml-parser@5.3.2: dependencies: - strnum: 2.1.2 + strnum: 2.1.1 fastq@1.19.1: dependencies: @@ -4017,7 +4017,7 @@ snapshots: strip-json-comments@3.1.1: {} - strnum@2.1.2: {} + strnum@2.1.1: {} supports-color@5.5.0: dependencies: @@ -4072,14 +4072,14 @@ snapshots: true-case-path@2.2.1: {} - ts-node@10.9.0(@types/node@25.0.3)(typescript@4.9.5): + ts-node@10.9.0(@types/node@25.0.1)(typescript@4.9.5): dependencies: '@cspotcode/source-map-support': 0.8.1 '@tsconfig/node10': 1.0.12 '@tsconfig/node12': 1.0.11 '@tsconfig/node14': 1.0.3 '@tsconfig/node16': 1.0.4 - '@types/node': 25.0.3 + '@types/node': 25.0.1 acorn: 8.15.0 acorn-walk: 8.3.4 arg: 4.1.3 diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 1fa307ea0d..fabb6057f5 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -37,11 +37,11 @@ importers: specifier: 1.2.4-alpha.5 version: 1.2.4-alpha.5 '@visactor/vrender': - specifier: ~1.0.32 - version: 1.0.32 + specifier: ~1.0.35 + version: 1.0.35 '@visactor/vrender-kits': - specifier: ~1.0.32 - version: 1.0.32 + specifier: ~1.0.35 + version: 1.0.35 '@visactor/vtable': specifier: 1.19.0-alpha.0 version: 1.19.0-alpha.0 @@ -203,11 +203,11 @@ importers: specifier: workspace:2.0.11 version: link:../vchart '@visactor/vrender-core': - specifier: ~1.0.32 - version: 1.0.32 + specifier: ~1.0.35 + version: 1.0.35 '@visactor/vrender-kits': - specifier: ~1.0.32 - version: 1.0.32 + specifier: ~1.0.35 + version: 1.0.35 '@visactor/vutils': specifier: ~1.0.12 version: 1.0.21 @@ -294,11 +294,11 @@ importers: specifier: workspace:2.0.11 version: link:../vchart-extension '@visactor/vrender-core': - specifier: ~1.0.32 - version: 1.0.32 + specifier: ~1.0.35 + version: 1.0.35 '@visactor/vrender-kits': - specifier: ~1.0.32 - version: 1.0.32 + specifier: ~1.0.35 + version: 1.0.35 '@visactor/vutils': specifier: ~1.0.12 version: 1.0.21 @@ -529,17 +529,17 @@ importers: specifier: ~1.0.12 version: 1.0.21 '@visactor/vrender-animate': - specifier: ~1.0.32 - version: 1.0.32 + specifier: ~1.0.35 + version: 1.0.35 '@visactor/vrender-components': - specifier: ~1.0.32 - version: 1.0.32 + specifier: ~1.0.35 + version: 1.0.35 '@visactor/vrender-core': - specifier: ~1.0.32 - version: 1.0.32 + specifier: ~1.0.35 + version: 1.0.35 '@visactor/vrender-kits': - specifier: ~1.0.32 - version: 1.0.32 + specifier: ~1.0.35 + version: 1.0.35 '@visactor/vscale': specifier: ~1.0.12 version: 1.0.21 @@ -692,17 +692,17 @@ importers: specifier: ~1.0.12 version: 1.0.21 '@visactor/vrender-animate': - specifier: ~1.0.32 - version: 1.0.32 + specifier: ~1.0.35 + version: 1.0.35 '@visactor/vrender-components': - specifier: ~1.0.32 - version: 1.0.32 + specifier: ~1.0.35 + version: 1.0.35 '@visactor/vrender-core': - specifier: ~1.0.32 - version: 1.0.32 + specifier: ~1.0.35 + version: 1.0.35 '@visactor/vrender-kits': - specifier: ~1.0.32 - version: 1.0.32 + specifier: ~1.0.35 + version: 1.0.35 '@visactor/vutils': specifier: ~1.0.12 version: 1.0.21 @@ -1260,14 +1260,14 @@ importers: specifier: workspace:2.0.11 version: link:../../packages/vchart '@visactor/vrender': - specifier: ~1.0.32 - version: 1.0.32 + specifier: ~1.0.35 + version: 1.0.35 '@visactor/vrender-core': - specifier: ~1.0.32 - version: 1.0.32 + specifier: ~1.0.35 + version: 1.0.35 '@visactor/vrender-kits': - specifier: ~1.0.32 - version: 1.0.32 + specifier: ~1.0.35 + version: 1.0.35 '@visactor/vutils': specifier: ~1.0.12 version: 1.0.21 @@ -3073,29 +3073,29 @@ packages: '@visactor/vrender-animate@1.0.0-alpha.18': resolution: {integrity: sha512-9kTtvp1ef+1t+AtUiza6A7qBQP7SmvOu3/ILGrqs/HGdZVj1XGjbYvD/X/zwKJ3LEb7gGV5fa8x95e4czTvRSA==} - '@visactor/vrender-animate@1.0.32': - resolution: {integrity: sha512-zRHJgT2V0OdyPcjPl2Ix6mktIM9AAMyyXaeCwbtoZqMkmYgjRZDpfPwpLy+nQqOI+L/rOvOv6NLepQbwKirP1w==} + '@visactor/vrender-animate@1.0.35': + resolution: {integrity: sha512-0NIYadX++XXGTUsuEiyubuS1zGGgz9u6PZPDkfyLPft2H66VYTtK9QgkJk8Tmvcke3j5ahhzgo3YGjsKYtvhJQ==} '@visactor/vrender-components@1.0.0-alpha.18': resolution: {integrity: sha512-7Euq+ZfswL74n2pgkaqZSsPxoSa5SPIGyXatN1eUrdzM2Z0kX6U0RcJg01fctvRs4op6WhcecRLqGvnHcBeb9Q==} - '@visactor/vrender-components@1.0.32': - resolution: {integrity: sha512-nH2criP27xdUIGYK6YjE1vQ6dXZUQ63or3ssDXJpiuNteQw4x9RfiUT8YYSmDAm8zLplTH7eUdGOolk0+8qLXg==} + '@visactor/vrender-components@1.0.35': + resolution: {integrity: sha512-hUOLymrJRWKGw2M6N/9yIonw6avqQ1FZRqrGy7Oz2iJhIFICyeWBSmv05/ZNgHZkPYgUZ5iWafhRzEg+7yNCWw==} '@visactor/vrender-core@1.0.0-alpha.18': resolution: {integrity: sha512-0ihtNvCyNkOsWPFgRqowHzq0IcQgS2Wl/nPpKbVtxWKveenwlhA+ZKoQvam6VJyBY7jeNe1pROy0mJMDyVAJQw==} - '@visactor/vrender-core@1.0.32': - resolution: {integrity: sha512-Z7gliAn/YNFMgByow9xJCZjvrsC4wgYI+kqSrz26eGP2X9eGqo4J5FaDppc8gUlwm7sXv+73bXhY8L35Umow0w==} + '@visactor/vrender-core@1.0.35': + resolution: {integrity: sha512-l+4NcRAxc3CmndzwjZfNPrxA5rFxfGN0qHKN3N3je+EaLdkgOkqhdKTcCGxnoC+48QljidkQJQnw0i7oUPoeGQ==} '@visactor/vrender-kits@1.0.0-alpha.18': resolution: {integrity: sha512-Tvolkq+4G8qiPFZo0Aj8M//Yr6jR2h8FNkFEyWM9gbQbEiTkjpmHAJOYnoSsaPtPrcMSlG4EhJSFDk6ymANHVg==} - '@visactor/vrender-kits@1.0.32': - resolution: {integrity: sha512-58PHHHBRCy+q5YYAmkFi6FMrqBHURPkYBaTkF3V1+IyUVElo/xHQ076DyiHylIq+pQCnx1L5M+iL2pQG5PSLYg==} + '@visactor/vrender-kits@1.0.35': + resolution: {integrity: sha512-uPc6hoBfdKwoM9v9jOeNJDAq5T+2HpYE/qldrhIZjgTx+ZPQHLD04pUxBxBI9+ZITaANGUgOW4I8acO/G5QzPA==} - '@visactor/vrender@1.0.32': - resolution: {integrity: sha512-s1B9X2wi7eSSJ/vSouymISl2/GG7XYqpbguaTi/wskU/JthShjDSbukRW5B3RUTIRqaaOrLWP+dFRTl8D7sQ6w==} + '@visactor/vrender@1.0.35': + resolution: {integrity: sha512-BmVWcrY2o8+s3eTTW2J3qux5VEQ/cii8zW/qW8D/sgkZ174gC6J3TnuPzUn6Ytuawj7gc+XykXUrdahwuDpNzA==} '@visactor/vscale@0.18.18': resolution: {integrity: sha512-iRG4kv+5Fv4KX3AxEfV95XU3I6OmF0QizyAhqHxKa7L1MaT+MRvDDk5zHWf1E8gialLbL2xDe3GnT6g/4u5jhA==} @@ -13702,7 +13702,7 @@ snapshots: transitivePeerDependencies: - supports-color - '@jest/test-sequencer@26.6.3(canvas@2.11.2(encoding@0.1.13))(ts-node@10.9.0(@types/node@18.19.0)(typescript@4.9.5))': + '@jest/test-sequencer@26.6.3': dependencies: '@jest/test-result': 26.6.2 graceful-fs: 4.2.11 @@ -13710,25 +13710,7 @@ snapshots: jest-runner: 26.6.3(canvas@2.11.2(encoding@0.1.13))(ts-node@10.9.0(@types/node@18.19.0)(typescript@4.9.5)) jest-runtime: 26.6.3(canvas@2.11.2(encoding@0.1.13))(ts-node@10.9.0(@types/node@18.19.0)(typescript@4.9.5)) transitivePeerDependencies: - - bufferutil - - canvas - - supports-color - - ts-node - - utf-8-validate - - '@jest/test-sequencer@26.6.3(canvas@2.11.2(encoding@0.1.13))(ts-node@10.9.0(@types/node@18.19.0)(typescript@5.4.5))': - dependencies: - '@jest/test-result': 26.6.2 - graceful-fs: 4.2.11 - jest-haste-map: 26.6.2 - jest-runner: 26.6.3(canvas@2.11.2(encoding@0.1.13))(ts-node@10.9.0(@types/node@18.19.0)(typescript@5.4.5)) - jest-runtime: 26.6.3(canvas@2.11.2(encoding@0.1.13))(ts-node@10.9.0(@types/node@18.19.0)(typescript@4.9.5)) - transitivePeerDependencies: - - bufferutil - - canvas - supports-color - - ts-node - - utf-8-validate '@jest/transform@24.9.0': dependencies: @@ -15026,9 +15008,9 @@ snapshots: '@visactor/vrender-core': 1.0.0-alpha.18 '@visactor/vutils': 1.0.4 - '@visactor/vrender-animate@1.0.32': + '@visactor/vrender-animate@1.0.35': dependencies: - '@visactor/vrender-core': 1.0.32 + '@visactor/vrender-core': 1.0.35 '@visactor/vutils': 1.0.21 '@visactor/vrender-components@1.0.0-alpha.18': @@ -15039,11 +15021,11 @@ snapshots: '@visactor/vscale': 1.0.4 '@visactor/vutils': 1.0.4 - '@visactor/vrender-components@1.0.32': + '@visactor/vrender-components@1.0.35': dependencies: - '@visactor/vrender-animate': 1.0.32 - '@visactor/vrender-core': 1.0.32 - '@visactor/vrender-kits': 1.0.32 + '@visactor/vrender-animate': 1.0.35 + '@visactor/vrender-core': 1.0.35 + '@visactor/vrender-kits': 1.0.35 '@visactor/vscale': 1.0.21 '@visactor/vutils': 1.0.21 @@ -15052,7 +15034,7 @@ snapshots: '@visactor/vutils': 1.0.4 color-convert: 2.0.1 - '@visactor/vrender-core@1.0.32': + '@visactor/vrender-core@1.0.35': dependencies: '@visactor/vutils': 1.0.21 color-convert: 2.0.1 @@ -15066,21 +15048,21 @@ snapshots: lottie-web: 5.13.0 roughjs: 4.5.2 - '@visactor/vrender-kits@1.0.32': + '@visactor/vrender-kits@1.0.35': dependencies: '@resvg/resvg-js': 2.4.1 - '@visactor/vrender-core': 1.0.32 + '@visactor/vrender-core': 1.0.35 '@visactor/vutils': 1.0.21 gifuct-js: 2.1.2 lottie-web: 5.13.0 roughjs: 4.6.6 - '@visactor/vrender@1.0.32': + '@visactor/vrender@1.0.35': dependencies: - '@visactor/vrender-animate': 1.0.32 - '@visactor/vrender-components': 1.0.32 - '@visactor/vrender-core': 1.0.32 - '@visactor/vrender-kits': 1.0.32 + '@visactor/vrender-animate': 1.0.35 + '@visactor/vrender-components': 1.0.35 + '@visactor/vrender-core': 1.0.35 + '@visactor/vrender-kits': 1.0.35 '@visactor/vscale@0.18.18': dependencies: @@ -20872,7 +20854,7 @@ snapshots: jest-config@26.6.3(canvas@2.11.2(encoding@0.1.13))(ts-node@10.9.0(@types/node@18.19.0)(typescript@4.9.5)): dependencies: '@babel/core': 7.20.12 - '@jest/test-sequencer': 26.6.3(canvas@2.11.2(encoding@0.1.13))(ts-node@10.9.0(@types/node@18.19.0)(typescript@4.9.5)) + '@jest/test-sequencer': 26.6.3 '@jest/types': 26.6.2 babel-jest: 26.6.3(@babel/core@7.20.12) chalk: 4.1.2 @@ -20900,7 +20882,7 @@ snapshots: jest-config@26.6.3(canvas@2.11.2(encoding@0.1.13))(ts-node@10.9.0(@types/node@18.19.0)(typescript@5.4.5)): dependencies: '@babel/core': 7.20.12 - '@jest/test-sequencer': 26.6.3(canvas@2.11.2(encoding@0.1.13))(ts-node@10.9.0(@types/node@18.19.0)(typescript@5.4.5)) + '@jest/test-sequencer': 26.6.3 '@jest/types': 26.6.2 babel-jest: 26.6.3(@babel/core@7.20.12) chalk: 4.1.2 diff --git a/docs/package.json b/docs/package.json index 7d9425ab1c..c870248bb2 100644 --- a/docs/package.json +++ b/docs/package.json @@ -19,8 +19,8 @@ "@visactor/vchart-theme": "~1.6.6", "@visactor/vmind": "1.2.4-alpha.5", "@visactor/vutils": "~1.0.12", - "@visactor/vrender": "~1.0.32", - "@visactor/vrender-kits": "~1.0.32", + "@visactor/vrender": "~1.0.35", + "@visactor/vrender-kits": "~1.0.35", "@visactor/vtable": "1.19.0-alpha.0", "@visactor/vtable-editors": "1.19.0-alpha.0", "@visactor/vtable-gantt": "1.19.0-alpha.0", diff --git a/packages/openinula-vchart/package.json b/packages/openinula-vchart/package.json index 6e62032c0b..aac98d947d 100644 --- a/packages/openinula-vchart/package.json +++ b/packages/openinula-vchart/package.json @@ -30,8 +30,8 @@ "dependencies": { "@visactor/vchart": "workspace:2.0.11", "@visactor/vutils": "~1.0.12", - "@visactor/vrender-core": "~1.0.32", - "@visactor/vrender-kits": "~1.0.32", + "@visactor/vrender-core": "~1.0.35", + "@visactor/vrender-kits": "~1.0.35", "react-is": "^18.2.0" }, "devDependencies": { @@ -78,4 +78,4 @@ "access": "public", "registry": "https://registry.npmjs.org/" } -} +} \ No newline at end of file diff --git a/packages/react-vchart/package.json b/packages/react-vchart/package.json index 7e2d2f79a2..39223a378b 100644 --- a/packages/react-vchart/package.json +++ b/packages/react-vchart/package.json @@ -31,8 +31,8 @@ "@visactor/vchart": "workspace:2.0.11", "@visactor/vchart-extension": "workspace:2.0.11", "@visactor/vutils": "~1.0.12", - "@visactor/vrender-core": "~1.0.32", - "@visactor/vrender-kits": "~1.0.32", + "@visactor/vrender-core": "~1.0.35", + "@visactor/vrender-kits": "~1.0.35", "react-is": "^18.2.0" }, "devDependencies": { @@ -83,4 +83,4 @@ "access": "public", "registry": "https://registry.npmjs.org/" } -} +} \ No newline at end of file diff --git a/packages/vchart-extension/package.json b/packages/vchart-extension/package.json index 68d21d94b2..a36207a764 100644 --- a/packages/vchart-extension/package.json +++ b/packages/vchart-extension/package.json @@ -21,10 +21,10 @@ "start": "ts-node __tests__/runtime/browser/scripts/initVite.ts && vite serve __tests__/runtime/browser" }, "dependencies": { - "@visactor/vrender-core": "~1.0.32", - "@visactor/vrender-kits": "~1.0.32", - "@visactor/vrender-components": "~1.0.32", - "@visactor/vrender-animate": "~1.0.32", + "@visactor/vrender-core": "~1.0.35", + "@visactor/vrender-kits": "~1.0.35", + "@visactor/vrender-components": "~1.0.35", + "@visactor/vrender-animate": "~1.0.35", "@visactor/vchart": "workspace:2.0.11", "@visactor/vutils": "~1.0.12", "@visactor/vdataset": "~1.0.12", diff --git a/packages/vchart/__tests__/unit/component/polar/axis/auto-label-max-width.test.ts b/packages/vchart/__tests__/unit/component/polar/axis/auto-label-max-width.test.ts new file mode 100644 index 0000000000..9e5ffdbca2 --- /dev/null +++ b/packages/vchart/__tests__/unit/component/polar/axis/auto-label-max-width.test.ts @@ -0,0 +1,84 @@ +import { DataSet } from '@visactor/vdataset'; +import { EventDispatcher } from '../../../../../src/event/event-dispatcher'; +import type { IEventDispatcher } from '../../../../../src/event/interface'; +import { ComponentTypeEnum } from '../../../../../src/component/interface'; +import type { IComponentOption } from '../../../../../src/component/interface'; +import type { PolarLinearAxis } from '../../../../../src/index'; +import { PolarAxis } from '../../../../../src/index'; +import { getTheme } from '../../../../util/context'; +import { getTestCompiler } from '../../../../util/factory/compiler'; + +const dataSet = new DataSet(); + +/** + * 验证:极坐标角度轴在布局阶段向组件属性传递 `autoLabelMaxWidth` + * 前置:构造最小上下文、Mock `_update` 捕获属性 + * 断言:`_update` 接收的属性包含 `autoLabelMaxWidth` 与 `layoutRect` + */ +test('autogen:polar/axis:autoLabelMaxWidth 应传递到组件属性', () => { + const layoutRect = { x: 0, y: 0, width: 400, height: 300 } as any; + const regionStub = { + id: 'region-0', + getLayoutRect: () => layoutRect, + getLayoutStartPoint: () => ({ x: 0, y: 0 }), + getSeries: (): any[] => [] + } as any; + + const ctx: IComponentOption = { + type: ComponentTypeEnum.polarLinearAxis, + eventDispatcher: new EventDispatcher({} as any, { addEventListener: () => {} } as any) as IEventDispatcher, + dataSet, + map: new Map(), + mode: 'desktop-browser', + globalInstance: { + isAnimationEnable: () => false, + getContainer: () => ({}), + getStage: () => ({ find: () => ({}) }) + } as any, + getCompiler: getTestCompiler, + getAllRegions: () => [regionStub], + getRegionsInIndex: () => [regionStub], + getChart: () => ({ getSpec: () => ({}) } as any), + getRegionsInIds: () => [regionStub], + getRegionsInUserIdOrIndex: () => [regionStub], + getAllSeries: () => [], + getSeriesInIndex: () => [], + getSeriesInIds: () => [], + getSeriesInUserIdOrIndex: () => [], + getAllComponents: () => [], + getComponentByUserId: () => undefined, + getComponentByIndex: () => undefined, + getComponentsByKey: () => [], + getComponentsByType: () => [], + getChartLayoutRect: () => ({ width: 0, height: 0, x: 0, y: 0 }), + getChartViewRect: () => ({ width: 500, height: 500 } as any), + globalScale: {} as any, + getTheme: getTheme, + animation: false, + onError: () => {}, + getSeriesData: () => undefined + }; + + const spec = { + orient: 'angle', + label: { visible: true, autoLabelMaxWidth: true }, + grid: { visible: false }, + subGrid: { visible: false }, + title: { visible: false }, + // 半径配置以避免计算过程依赖系列 + outerRadius: 1, + innerRadius: 0 + } as any; + + const axis = PolarAxis.createComponent({ type: ComponentTypeEnum.polarLinearAxis, spec }, ctx) as PolarLinearAxis; + axis.created(); + + const updateSpy = jest.spyOn(axis as any, '_update').mockImplementation(() => {}); + + axis.updateLayoutAttribute(); + + expect(updateSpy).toHaveBeenCalled(); + const callArgs = updateSpy.mock.calls[0][0] as any; + expect(callArgs.autoLabelMaxWidth).toBe(true); + expect(callArgs.layoutRect).toEqual(layoutRect); +}); diff --git a/packages/vchart/package.json b/packages/vchart/package.json index 0543b8977f..fbb33411d2 100644 --- a/packages/vchart/package.json +++ b/packages/vchart/package.json @@ -122,14 +122,14 @@ "@visactor/vdataset": "~1.0.12", "@visactor/vscale": "~1.0.12", "@visactor/vlayouts": "~1.0.12", - "@visactor/vrender-core": "~1.0.32", - "@visactor/vrender-kits": "~1.0.32", - "@visactor/vrender-components": "~1.0.32", - "@visactor/vrender-animate": "~1.0.32", + "@visactor/vrender-core": "~1.0.35", + "@visactor/vrender-kits": "~1.0.35", + "@visactor/vrender-components": "~1.0.35", + "@visactor/vrender-animate": "~1.0.35", "@visactor/vutils-extension": "workspace:2.0.11" }, "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" } -} +} \ No newline at end of file diff --git a/packages/vchart/src/component/axis/polar/axis.ts b/packages/vchart/src/component/axis/polar/axis.ts index 5fff3e6eab..9bb5755bf1 100644 --- a/packages/vchart/src/component/axis/polar/axis.ts +++ b/packages/vchart/src/component/axis/polar/axis.ts @@ -442,6 +442,8 @@ export abstract class PolarAxis; + > & { + /** + * 是否自动限制标签最大宽度(开启基于布局的宽度控制) + * @since 2.0.12 + */ + autoLabelMaxWidth?: boolean; + }; export type IPolarAxisCommonSpec = Omit & { /** diff --git a/tools/story-player/package.json b/tools/story-player/package.json index a633e6a637..d28900ec99 100644 --- a/tools/story-player/package.json +++ b/tools/story-player/package.json @@ -56,10 +56,10 @@ "vite": "3.2.6" }, "dependencies": { - "@visactor/vrender-core": "~1.0.32", - "@visactor/vrender-kits": "~1.0.32", + "@visactor/vrender-core": "~1.0.35", + "@visactor/vrender-kits": "~1.0.35", "@visactor/vchart": "workspace:2.0.11", - "@visactor/vrender": "~1.0.32", + "@visactor/vrender": "~1.0.35", "@visactor/vutils": "~1.0.12" } } \ No newline at end of file