@deepseek-ai/dsh-typert-generator 0.2.1-alpha.1 → 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/lib/index.js +21 -4
- package/lib/types/analyzer.js +25 -4
- package/lib/types/tsdown-plugin.js +6 -6
- package/package.json +5 -5
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) {
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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;
|
package/lib/types/analyzer.js
CHANGED
|
@@ -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) {
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
const
|
|
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,
|
|
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,
|
|
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.1-alpha.
|
|
4
|
+
"version": "0.2.1-alpha.2",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"@deepseek-ai/cordis": "~4.0.5-alpha.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"
|
|
43
|
-
"@deepseek-ai/dsh-
|
|
44
|
-
"@deepseek-ai/
|
|
45
|
-
"
|
|
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
|
}
|