@jskit-ai/architecture-inspector 0.1.8 → 0.1.10
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/package.json +3 -3
- package/src/calls/program.js +23 -1
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jskit-ai/architecture-inspector",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "Static Vue architecture inspector for the portable architecture-inspection command contract.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"src"
|
|
8
8
|
],
|
|
9
9
|
"scripts": {
|
|
10
|
-
"test": "
|
|
10
|
+
"test": "jskit test"
|
|
11
11
|
},
|
|
12
12
|
"exports": {
|
|
13
13
|
"./vue": "./src/inspectVueArchitecture.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@babel/parser": "7.29.9",
|
|
21
|
-
"@jskit-ai/kernel": "0.2.
|
|
21
|
+
"@jskit-ai/kernel": "0.2.12",
|
|
22
22
|
"@vue/compiler-sfc": "3.5.44",
|
|
23
23
|
"typescript": "6.0.3"
|
|
24
24
|
},
|
package/src/calls/program.js
CHANGED
|
@@ -29,6 +29,25 @@ const COMPILER_OPTIONS = Object.freeze({
|
|
|
29
29
|
lib: LIBRARIES
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
+
// TypeScript's default libraries as parsed source files, shared by every program
|
|
33
|
+
// of the process, as TypeScript's own language service shares them through its
|
|
34
|
+
// document registry. Each inspection with calls builds a program, and parsing
|
|
35
|
+
// and binding lib.dom.d.ts again for each one cost most of an inspection of a
|
|
36
|
+
// small project. A library file is the installed TypeScript's own, so its text
|
|
37
|
+
// cannot change while the process runs, and every program uses the same
|
|
38
|
+
// compiler options; the key keeps the parse options the program asks for.
|
|
39
|
+
const librarySourceFiles = new Map();
|
|
40
|
+
|
|
41
|
+
function librarySourceFile(name, languageVersion) {
|
|
42
|
+
const options = typeof languageVersion === "object" ? languageVersion : { languageVersion };
|
|
43
|
+
const key = [name, options.languageVersion, options.impliedNodeFormat, options.jsDocParsingMode].join("\0");
|
|
44
|
+
if (!librarySourceFiles.has(key)) {
|
|
45
|
+
const text = ts.sys.readFile(name);
|
|
46
|
+
librarySourceFiles.set(key, text === undefined ? undefined : ts.createSourceFile(name, text, languageVersion));
|
|
47
|
+
}
|
|
48
|
+
return librarySourceFiles.get(key);
|
|
49
|
+
}
|
|
50
|
+
|
|
32
51
|
// A Vue component's script blocks at their original offsets; template and
|
|
33
52
|
// style text become spaces so every position matches the component file.
|
|
34
53
|
function vueScriptText(source, filePath) {
|
|
@@ -100,7 +119,10 @@ function loadCallProgram({ projectRoot, sources, resolveImport }) {
|
|
|
100
119
|
|
|
101
120
|
const host = {
|
|
102
121
|
getSourceFile(name, languageVersion) {
|
|
103
|
-
|
|
122
|
+
if (!virtual.has(name) && isLibraryFile(name)) {
|
|
123
|
+
return librarySourceFile(name, languageVersion);
|
|
124
|
+
}
|
|
125
|
+
const text = virtual.get(name)?.text;
|
|
104
126
|
return text === undefined ? undefined : ts.createSourceFile(name, text, languageVersion);
|
|
105
127
|
},
|
|
106
128
|
getDefaultLibFileName: (options) => ts.getDefaultLibFilePath(options),
|