@jskit-ai/architecture-inspector 0.1.9 → 0.1.11

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/architecture-inspector",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "Static Vue architecture inspector for the portable architecture-inspection command contract.",
5
5
  "type": "module",
6
6
  "files": [
@@ -17,10 +17,10 @@
17
17
  "jskit-inspect-vue": "./src/cli.js"
18
18
  },
19
19
  "dependencies": {
20
- "@babel/parser": "7.29.9",
21
- "@jskit-ai/kernel": "0.2.11",
22
- "@vue/compiler-sfc": "3.5.44",
23
- "typescript": "6.0.3"
20
+ "@babel/parser": "^7.29.9",
21
+ "@jskit-ai/kernel": "0.2.13",
22
+ "@vue/compiler-sfc": "^3.5.44",
23
+ "typescript": "^6.0.3"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "vue-router": "^5.3.1"
@@ -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
- const text = virtual.get(name)?.text ?? (isLibraryFile(name) ? ts.sys.readFile(name) : undefined);
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),