@deepseek-ai/dsh-typert-generator 0.2.0-rc.2 → 0.2.1-alpha.2

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.i18n.yaml CHANGED
@@ -21,8 +21,8 @@
21
21
  en: b8720f6ac186a8e8
22
22
  zh: 3e04a4c1bebc2cf4
23
23
  /deepseek-ai-dsh-typert-generator/use-this-package/analyzing-a-workspace-statically:
24
- en: 88f4e7fc9d4c7701
25
- zh: cecd35ff4f35bfd2
24
+ en: 4ea0e4977cefa39d
25
+ zh: 41bdb6047bc79524
26
26
  /deepseek-ai-dsh-typert-generator/use-this-package/running-generation-inside-a-tsdown-build:
27
27
  en: cc3f7d23739380f6
28
28
  zh: 864d15088f581271
@@ -57,5 +57,5 @@
57
57
  en: f3b1002133fe8736
58
58
  zh: e8d5fecd10db5e3a
59
59
  /deepseek-ai-dsh-typert-generator/known-limitations-and-deferred-work/dev-note:
60
- en: cc7e47f271475e4c
61
- zh: 8426eb322816bd28
60
+ en: e67f633dc6fe7773
61
+ zh: 3bb0c20c93f16f98
package/README.md CHANGED
@@ -47,6 +47,8 @@ After the build, `lib/typert.host.js` and `lib/typert.host.d.ts` exist and the [
47
47
 
48
48
  Static consumers call `WorkspaceAnalyzer` directly against the workspace's `tsconfig.host.json` and `tsconfig.client.json` aggregates, select a face and package subset, and read the resulting `FaceModel` and type graph without emitting or loading runtime artifacts. `analyzeInBatches()` processes a large package selection through bounded compiler programs with the same model shape, and `discoverPackages()` finds contributing packages without building a type-checker program.
49
49
 
50
+ JSON, YAML, SVG, PNG, JPEG, and WebP resource exports contribute no TypeScript declarations and are excluded from the API model. Missing JavaScript or TypeScript export sources remain errors.
51
+
50
52
  ### Running generation inside a tsdown build
51
53
 
52
54
  The package's `./tsdown` subpath provides `typertPlugin()` for the root tsdown config: it lowers standard decorators in TypeScript dependencies before bundling and emits the model-driven face artifacts at the package output root. In `package` mode it emits only the bundled package; in `workspace` mode it emits every explicit contributor once.
@@ -141,5 +143,3 @@ These limits define what the generator cannot model or emit; they are current pa
141
143
  None.
142
144
 
143
145
  </details>
144
-
145
- **Runtime invariant:** No companion is published. The source-project analyzer and build-time emitter run outside any Cordis runtime; model snapshots, executable artifacts, and consuming-package typechecks enforce the output contract.
package/README.zh.md CHANGED
@@ -47,6 +47,8 @@ files:
47
47
 
48
48
  静态消费方直接针对工作区的 `tsconfig.host.json` 与 `tsconfig.client.json` 聚合配置调用 `WorkspaceAnalyzer`,选择 face 与包子集,并在不生成或加载运行时产物的前提下读取生成的 `FaceModel` 与类型图。`analyzeInBatches()` 通过有界的编译器程序处理大批量包选择,模型形态保持一致;`discoverPackages()` 无需构建类型检查程序即可找出参与贡献的包。
49
49
 
50
+ JSON、YAML、SVG、PNG、JPEG 和 WebP 资源导出不提供 TypeScript 声明,因此不进入 API 模型。JavaScript 或 TypeScript 导出源文件缺失时仍报错。
51
+
50
52
  ### 在 tsdown 构建中运行生成
51
53
 
52
54
  包的 `./tsdown` 子路径为根 tsdown 配置提供 `typertPlugin()`:它在打包前转换 TypeScript 依赖中的标准装饰器,并在包输出根目录生成模型驱动的 face 产物。`package` 模式只生成当前打包的包;`workspace` 模式对每个显式贡献方各生成一次。
@@ -141,5 +143,3 @@ Host 与 Client 是两个独立的 TypeScript 程序。直接项目引用确定
141
143
  无。
142
144
 
143
145
  </details>
144
-
145
- **运行时不变式:** 不发布伴生入口。源码项目分析器与构建时 emitter 均不在任何 Cordis 运行时中运行;模型快照、可执行产物与消费方包的类型检查会强制执行其输出约定。
package/lib/index.js CHANGED
@@ -370,6 +370,9 @@ var FaceAnalyzer = class {
370
370
  nodes = /* @__PURE__ */ new Map();
371
371
  exportsByPackage = /* @__PURE__ */ new Map();
372
372
  nodeOrdinals = /* @__PURE__ */ new Map();
373
+ /** Registration and package lookups per source path; the registration set is fixed per analyzer. */
374
+ registrationByFile = /* @__PURE__ */ new Map();
375
+ packageNameByFile = /* @__PURE__ */ new Map();
373
376
  staticLookups;
374
377
  staticContexts;
375
378
  constructor(options) {
@@ -455,7 +458,7 @@ var FaceAnalyzer = class {
455
458
  const targets = packageExportTargets(registration.manifest).filter(([subpath]) => registration.exportSubpaths === void 0 || registration.exportSubpaths.includes(subpath));
456
459
  const records = [];
457
460
  for (const [subpath, target] of targets) {
458
- if (target.includes("*") || subpath === "./package.json" || subpath === "./typert" || subpath === "./client/typert" || subpath === "./remote" || target.endsWith(".json") || target.endsWith(".yml") || target.endsWith(".yaml")) continue;
461
+ if (target.includes("*") || subpath === "./package.json" || subpath === "./typert" || subpath === "./client/typert" || subpath === "./remote" || /\.(?:json|ya?ml|svg|png|jpe?g|webp)$/iu.test(target)) continue;
459
462
  const sourcePath = sourcePathForExport(registration.root, target);
460
463
  const sourceFile = this.sourceFiles.get(realPath(sourcePath));
461
464
  if (sourceFile === void 0) throw new TypertAnalysisError(`typert(${this.face}): ${registration.name} export ${subpath} resolves to missing source ${sourcePath}`);
@@ -1954,12 +1957,19 @@ var FaceAnalyzer = class {
1954
1957
  return `${this.packageNameForFile(declaration.getSourceFile().fileName)}:${location.file}#${symbol.name}`;
1955
1958
  }
1956
1959
  registrationForFile(file) {
1960
+ if (this.registrationByFile.has(file)) return this.registrationByFile.get(file);
1957
1961
  const path = realPath(file);
1958
- return this.allRegistrations.find((registration) => registration.face === this.face && isWithin(path, registration.root));
1962
+ const registration = this.allRegistrations.find((registration) => registration.face === this.face && isWithin(path, registration.root));
1963
+ this.registrationByFile.set(file, registration);
1964
+ return registration;
1959
1965
  }
1960
1966
  packageNameForFile(file) {
1967
+ const cached = this.packageNameByFile.get(file);
1968
+ if (cached !== void 0) return cached;
1961
1969
  const path = realPath(file);
1962
- return this.allRegistrations.find((registration) => isWithin(path, registration.root))?.name ?? "<external>";
1970
+ const name = this.allRegistrations.find((registration) => isWithin(path, registration.root))?.name ?? "<external>";
1971
+ this.packageNameByFile.set(file, name);
1972
+ return name;
1963
1973
  }
1964
1974
  allocateNodeId(site) {
1965
1975
  const location = this.locationKey(site);
@@ -2140,7 +2150,8 @@ function declarationText(declaration) {
2140
2150
  function classShape(node) {
2141
2151
  const nonPublic = (member) => (ts.canHaveModifiers(member) ? ts.getModifiers(member) : void 0)?.some((modifier) => modifier.kind === ts.SyntaxKind.PrivateKeyword || modifier.kind === ts.SyntaxKind.ProtectedKeyword) ?? false;
2142
2152
  const members = node.members.flatMap((member) => {
2143
- if (nonPublic(member) || ts.isPropertyDeclaration(member) && ts.isPrivateIdentifier(member.name)) return [];
2153
+ const name = ts.getNameOfDeclaration(member);
2154
+ if (ts.isClassStaticBlockDeclaration(member) || nonPublic(member) || name !== void 0 && ts.isPrivateIdentifier(name)) return [];
2144
2155
  if (ts.isMethodDeclaration(member)) return [ts.factory.updateMethodDeclaration(member, member.modifiers, member.asteriskToken, member.name, member.questionToken, member.typeParameters, member.parameters, member.type, void 0)];
2145
2156
  if (ts.isConstructorDeclaration(member)) return [ts.factory.updateConstructorDeclaration(member, member.modifiers, member.parameters, void 0)];
2146
2157
  if (ts.isGetAccessorDeclaration(member)) return [ts.factory.updateGetAccessorDeclaration(member, member.modifiers, member.name, member.parameters, member.type, void 0)];
@@ -2383,8 +2394,14 @@ function formatProgramDiagnostic(root, face, diagnostic) {
2383
2394
  return `typert(${face}): ${slash(relative(root, diagnostic.file.fileName))}:${String(position.line + 1)}:${String(position.character + 1)}: TypeScript TS${String(diagnostic.code)}: ${message}`;
2384
2395
  }
2385
2396
  const realPathCache = /* @__PURE__ */ new Map();
2397
+ /** Normalized form per requested path; `resolve` reads only the process working directory. */
2398
+ const absolutePathCache = /* @__PURE__ */ new Map();
2386
2399
  function realPath(path) {
2387
- const absolute = resolve(path);
2400
+ let absolute = absolutePathCache.get(path);
2401
+ if (absolute === void 0) {
2402
+ absolute = resolve(path);
2403
+ absolutePathCache.set(path, absolute);
2404
+ }
2388
2405
  const cached = realPathCache.get(absolute);
2389
2406
  if (cached !== void 0) return cached;
2390
2407
  if (!existsSync(absolute)) return absolute;
@@ -437,6 +437,9 @@ class FaceAnalyzer {
437
437
  nodes = new Map();
438
438
  exportsByPackage = new Map();
439
439
  nodeOrdinals = new Map();
440
+ /** Registration and package lookups per source path; the registration set is fixed per analyzer. */
441
+ registrationByFile = new Map();
442
+ packageNameByFile = new Map();
440
443
  staticLookups;
441
444
  staticContexts;
442
445
  constructor(options) {
@@ -556,8 +559,8 @@ class FaceAnalyzer {
556
559
  for (const [subpath, target] of targets) {
557
560
  if (target.includes('*') || subpath === './package.json'
558
561
  || subpath === './typert' || subpath === './client/typert' || subpath === './remote'
559
- // Data exports (bundle patch lists, JSON manifests) carry no TypeScript API.
560
- || target.endsWith('.json') || target.endsWith('.yml') || target.endsWith('.yaml'))
562
+ // Data exports carry no TypeScript API; their owning readers validate the resources.
563
+ || /\.(?:json|ya?ml|svg|png|jpe?g|webp)$/iu.test(target))
561
564
  continue;
562
565
  const sourcePath = sourcePathForExport(registration.root, target);
563
566
  const sourceFile = this.sourceFiles.get(realPath(sourcePath));
@@ -2337,13 +2340,23 @@ class FaceAnalyzer {
2337
2340
  return `${this.packageNameForFile(declaration.getSourceFile().fileName)}:${location.file}#${symbol.name}`;
2338
2341
  }
2339
2342
  registrationForFile(file) {
2343
+ if (this.registrationByFile.has(file))
2344
+ return this.registrationByFile.get(file);
2340
2345
  const path = realPath(file);
2341
- return this.allRegistrations
2346
+ const registration = this.allRegistrations
2342
2347
  .find(registration => registration.face === this.face && isWithin(path, registration.root));
2348
+ this.registrationByFile.set(file, registration);
2349
+ return registration;
2343
2350
  }
2344
2351
  packageNameForFile(file) {
2352
+ const cached = this.packageNameByFile.get(file);
2353
+ if (cached !== undefined)
2354
+ return cached;
2345
2355
  const path = realPath(file);
2346
- return this.allRegistrations.find(registration => isWithin(path, registration.root))?.name ?? '<external>';
2356
+ const name = this.allRegistrations
2357
+ .find(registration => isWithin(path, registration.root))?.name ?? '<external>';
2358
+ this.packageNameByFile.set(file, name);
2359
+ return name;
2347
2360
  }
2348
2361
  allocateNodeId(site) {
2349
2362
  const location = this.locationKey(site);
@@ -2587,7 +2600,9 @@ function declarationText(declaration) {
2587
2600
  function classShape(node) {
2588
2601
  const nonPublic = (member) => (ts.canHaveModifiers(member) ? ts.getModifiers(member) : undefined)?.some(modifier => modifier.kind === ts.SyntaxKind.PrivateKeyword || modifier.kind === ts.SyntaxKind.ProtectedKeyword) ?? false;
2589
2602
  const members = node.members.flatMap((member) => {
2590
- if (nonPublic(member) || (ts.isPropertyDeclaration(member) && ts.isPrivateIdentifier(member.name)))
2603
+ const name = ts.getNameOfDeclaration(member);
2604
+ if (ts.isClassStaticBlockDeclaration(member) || nonPublic(member)
2605
+ || (name !== undefined && ts.isPrivateIdentifier(name)))
2591
2606
  return [];
2592
2607
  if (ts.isMethodDeclaration(member)) {
2593
2608
  return [ts.factory.updateMethodDeclaration(member, member.modifiers, member.asteriskToken, member.name, member.questionToken, member.typeParameters, member.parameters, member.type, undefined)];
@@ -2865,8 +2880,14 @@ function formatProgramDiagnostic(root, face, diagnostic) {
2865
2880
  return `typert(${face}): ${file}:${String(position.line + 1)}:${String(position.character + 1)}: TypeScript TS${String(diagnostic.code)}: ${message}`;
2866
2881
  }
2867
2882
  const realPathCache = new Map();
2883
+ /** Normalized form per requested path; `resolve` reads only the process working directory. */
2884
+ const absolutePathCache = new Map();
2868
2885
  function realPath(path) {
2869
- const absolute = resolve(path);
2886
+ let absolute = absolutePathCache.get(path);
2887
+ if (absolute === undefined) {
2888
+ absolute = resolve(path);
2889
+ absolutePathCache.set(path, absolute);
2890
+ }
2870
2891
  const cached = realPathCache.get(absolute);
2871
2892
  if (cached !== undefined)
2872
2893
  return cached;
@@ -10,10 +10,10 @@ import { dirname, join, resolve } from 'node:path';
10
10
  import ts from 'typescript';
11
11
  import { WorkspaceTypertGenerator } from "./workspace.js";
12
12
  const DECORATOR_SYNTAX = /^\s*@[A-Za-z_$][\w$]*/m;
13
- // This plugin consumes tsc-emitted `lib/types` output, so every project it
14
- // would re-diagnose has already passed the workspace tsc build in the same
15
- // orchestration; the generator skips its per-package diagnostic pass here.
16
- const TSC_VERIFIED_INPUT = { checkDiagnostics: false };
13
+ // Full builds and typecheck own TypeScript diagnostics. Benchmark-only emission
14
+ // defers them to the required full-build CI jobs; Typert generates reflection
15
+ // without repeating those diagnostics.
16
+ const TSC_OWNED_DIAGNOSTICS = { checkDiagnostics: false };
17
17
  /**
18
18
  * Create the decorator-lowering and typert-generation plugin for the root tsdown config.
19
19
  * @param pluginOptions - package/workspace emission mode and independent program faces.
@@ -64,7 +64,7 @@ export function typertPlugin(pluginOptions = {}) {
64
64
  return;
65
65
  let artifacts = artifactsByRoot.get(root);
66
66
  if (artifacts === undefined) {
67
- const generator = new WorkspaceTypertGenerator(root, TSC_VERIFIED_INPUT);
67
+ const generator = new WorkspaceTypertGenerator(root, TSC_OWNED_DIAGNOSTICS);
68
68
  artifacts = pluginOptions.faces === undefined
69
69
  ? generator.generate()
70
70
  : generator.generate(undefined, pluginOptions.faces);
@@ -74,7 +74,7 @@ export function typertPlugin(pluginOptions = {}) {
74
74
  },
75
75
  };
76
76
  function emitWorkspace(root, faces) {
77
- const generator = new WorkspaceTypertGenerator(root, TSC_VERIFIED_INPUT);
77
+ const generator = new WorkspaceTypertGenerator(root, TSC_OWNED_DIAGNOSTICS);
78
78
  const packages = generator.discover(faces)
79
79
  .filter(candidate => hasTypertExport(readManifest(join(root, candidate.root)).exports))
80
80
  .map(candidate => candidate.package);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-typert-generator",
3
3
  "description": "TypeScript project analyzer and model-driven Typert artifact generator",
4
- "version": "0.2.0-rc.2",
4
+ "version": "0.2.1-alpha.2",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -36,12 +36,12 @@
36
36
  "typescript": "^6.0.3"
37
37
  },
38
38
  "peerDependencies": {
39
- "@deepseek-ai/cordis": "~4.0.4"
39
+ "@deepseek-ai/cordis": "~4.0.5-alpha.1"
40
40
  },
41
41
  "devDependencies": {
42
- "zod": "^4.4.3",
43
- "@deepseek-ai/dsh-tool-cordis": "0.2.0-rc.2",
44
- "@deepseek-ai/dsh-typert-registry": "0.2.0-rc.2",
45
- "@deepseek-ai/cordis": "~4.0.4"
42
+ "@deepseek-ai/dsh-tool-cordis": "0.2.1-alpha.2",
43
+ "@deepseek-ai/dsh-typert-registry": "0.2.1-alpha.2",
44
+ "@deepseek-ai/cordis": "~4.0.5-alpha.1",
45
+ "zod": "^4.4.3"
46
46
  }
47
47
  }