@azerothjs/language-service 0.4.0-beta.1

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.
Files changed (98) hide show
  1. package/README.md +259 -0
  2. package/dist/html-source.d.ts +12 -0
  3. package/dist/html-source.d.ts.map +1 -0
  4. package/dist/html-source.js +108 -0
  5. package/dist/html-source.js.map +1 -0
  6. package/dist/index.d.ts +12 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +29 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/language-data.d.ts +41 -0
  11. package/dist/language-data.d.ts.map +1 -0
  12. package/dist/language-data.js +164 -0
  13. package/dist/language-data.js.map +1 -0
  14. package/dist/mapping.d.ts +71 -0
  15. package/dist/mapping.d.ts.map +1 -0
  16. package/dist/mapping.js +123 -0
  17. package/dist/mapping.js.map +1 -0
  18. package/dist/markup-model.d.ts +67 -0
  19. package/dist/markup-model.d.ts.map +1 -0
  20. package/dist/markup-model.js +313 -0
  21. package/dist/markup-model.js.map +1 -0
  22. package/dist/protocol.d.ts +176 -0
  23. package/dist/protocol.d.ts.map +1 -0
  24. package/dist/protocol.js +58 -0
  25. package/dist/protocol.js.map +1 -0
  26. package/dist/providers/completion.d.ts +26 -0
  27. package/dist/providers/completion.d.ts.map +1 -0
  28. package/dist/providers/completion.js +339 -0
  29. package/dist/providers/completion.js.map +1 -0
  30. package/dist/providers/css-service.d.ts +7 -0
  31. package/dist/providers/css-service.d.ts.map +1 -0
  32. package/dist/providers/css-service.js +84 -0
  33. package/dist/providers/css-service.js.map +1 -0
  34. package/dist/providers/diagnostics.d.ts +5 -0
  35. package/dist/providers/diagnostics.d.ts.map +1 -0
  36. package/dist/providers/diagnostics.js +89 -0
  37. package/dist/providers/diagnostics.js.map +1 -0
  38. package/dist/providers/editing.d.ts +17 -0
  39. package/dist/providers/editing.d.ts.map +1 -0
  40. package/dist/providers/editing.js +176 -0
  41. package/dist/providers/editing.js.map +1 -0
  42. package/dist/providers/hover.d.ts +5 -0
  43. package/dist/providers/hover.d.ts.map +1 -0
  44. package/dist/providers/hover.js +213 -0
  45. package/dist/providers/hover.js.map +1 -0
  46. package/dist/providers/html-service.d.ts +8 -0
  47. package/dist/providers/html-service.d.ts.map +1 -0
  48. package/dist/providers/html-service.js +108 -0
  49. package/dist/providers/html-service.js.map +1 -0
  50. package/dist/providers/inlay-hints.d.ts +25 -0
  51. package/dist/providers/inlay-hints.d.ts.map +1 -0
  52. package/dist/providers/inlay-hints.js +52 -0
  53. package/dist/providers/inlay-hints.js.map +1 -0
  54. package/dist/providers/navigation.d.ts +16 -0
  55. package/dist/providers/navigation.d.ts.map +1 -0
  56. package/dist/providers/navigation.js +107 -0
  57. package/dist/providers/navigation.js.map +1 -0
  58. package/dist/providers/semantic-tokens.d.ts +5 -0
  59. package/dist/providers/semantic-tokens.d.ts.map +1 -0
  60. package/dist/providers/semantic-tokens.js +63 -0
  61. package/dist/providers/semantic-tokens.js.map +1 -0
  62. package/dist/providers/signature.d.ts +5 -0
  63. package/dist/providers/signature.d.ts.map +1 -0
  64. package/dist/providers/signature.js +38 -0
  65. package/dist/providers/signature.js.map +1 -0
  66. package/dist/providers/structure.d.ts +19 -0
  67. package/dist/providers/structure.d.ts.map +1 -0
  68. package/dist/providers/structure.js +188 -0
  69. package/dist/providers/structure.js.map +1 -0
  70. package/dist/providers/symbols.d.ts +8 -0
  71. package/dist/providers/symbols.d.ts.map +1 -0
  72. package/dist/providers/symbols.js +108 -0
  73. package/dist/providers/symbols.js.map +1 -0
  74. package/dist/request.d.ts +37 -0
  75. package/dist/request.d.ts.map +1 -0
  76. package/dist/request.js +49 -0
  77. package/dist/request.js.map +1 -0
  78. package/dist/service.d.ts +73 -0
  79. package/dist/service.d.ts.map +1 -0
  80. package/dist/service.js +177 -0
  81. package/dist/service.js.map +1 -0
  82. package/dist/text.d.ts +25 -0
  83. package/dist/text.d.ts.map +1 -0
  84. package/dist/text.js +66 -0
  85. package/dist/text.js.map +1 -0
  86. package/dist/ts-project.d.ts +75 -0
  87. package/dist/ts-project.d.ts.map +1 -0
  88. package/dist/ts-project.js +266 -0
  89. package/dist/ts-project.js.map +1 -0
  90. package/dist/uri.d.ts +21 -0
  91. package/dist/uri.d.ts.map +1 -0
  92. package/dist/uri.js +41 -0
  93. package/dist/uri.js.map +1 -0
  94. package/dist/virtual-code.d.ts +27 -0
  95. package/dist/virtual-code.d.ts.map +1 -0
  96. package/dist/virtual-code.js +360 -0
  97. package/dist/virtual-code.js.map +1 -0
  98. package/package.json +61 -0
@@ -0,0 +1,177 @@
1
+ // The public facade. One AzerothLanguageService per workspace owns an
2
+ // AzerothProject (the TypeScript bridge) and exposes one method per editor
3
+ // feature. Callers speak `.azeroth` document URIs and line/character positions;
4
+ // the facade builds a RequestContext (original source, line index, virtual
5
+ // module + mapping) and hands it to the focused providers, which do the real
6
+ // work. The `@azerothjs/language-server` adapter is a thin translation layer on
7
+ // top of this.
8
+ import { AzerothProject, toVirtualFile } from "./ts-project.js";
9
+ import { uriToPath } from "./uri.js";
10
+ import { LineIndex } from "./text.js";
11
+ import { getCompletions, resolveCompletion } from "./providers/completion.js";
12
+ import { getHover } from "./providers/hover.js";
13
+ import { getDefinition, getDocumentHighlights, getReferences, getRenameEdits, getTypeDefinition } from "./providers/navigation.js";
14
+ import { getDocumentSymbols, getWorkspaceSymbols } from "./providers/symbols.js";
15
+ import { getDiagnostics } from "./providers/diagnostics.js";
16
+ import { getSignatureHelp } from "./providers/signature.js";
17
+ import { getSemanticTokens } from "./providers/semantic-tokens.js";
18
+ import { getCodeActions, getFoldingRanges, getFormattingEdits, getOnTypeFormattingEdits, getSelectionRanges } from "./providers/structure.js";
19
+ import { getAutoCloseTag, getLinkedEditingRanges } from "./providers/editing.js";
20
+ import { getInlayHints } from "./providers/inlay-hints.js";
21
+ /**
22
+ * Compiler-aware language intelligence for `.azeroth` files.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * const ls = new AzerothLanguageService(process.cwd());
27
+ * ls.didOpen('file:///App.azeroth', 'export default () => <h1>Hi {name()}</h1>;');
28
+ * ls.getHover('file:///App.azeroth', { line: 0, character: 36 }); // type of name()
29
+ * ```
30
+ */
31
+ export class AzerothLanguageService {
32
+ project;
33
+ constructor(workspaceDirectory, configPath) {
34
+ this.project = new AzerothProject(workspaceDirectory, configPath);
35
+ }
36
+ /** Registers or replaces a document's content. */
37
+ didOpen(uri, source) {
38
+ this.project.openDocument(uriToPath(uri), source);
39
+ }
40
+ /** Updates a document's content. */
41
+ didChange(uri, source) {
42
+ this.project.openDocument(uriToPath(uri), source);
43
+ }
44
+ /** Drops a document. */
45
+ didClose(uri) {
46
+ this.project.closeDocument(uriToPath(uri));
47
+ }
48
+ /** Context-aware completion at a position. */
49
+ getCompletions(uri, position, options) {
50
+ const ctx = this.context(uri);
51
+ return ctx ? getCompletions(ctx, ctx.lineIndex.offsetAt(position), options) : [];
52
+ }
53
+ /** Lazily fills in a completion item's documentation/detail. */
54
+ resolveCompletion(uri, item) {
55
+ const ctx = this.context(uri);
56
+ return ctx ? resolveCompletion(ctx, item) : item;
57
+ }
58
+ /** Hover information at a position. */
59
+ getHover(uri, position) {
60
+ const ctx = this.context(uri);
61
+ return ctx ? getHover(ctx, ctx.lineIndex.offsetAt(position)) : null;
62
+ }
63
+ /** Definition location(s) for the symbol at a position. */
64
+ getDefinition(uri, position) {
65
+ const ctx = this.context(uri);
66
+ return ctx ? getDefinition(ctx, ctx.lineIndex.offsetAt(position)) : [];
67
+ }
68
+ /** Type-definition location(s) for the symbol at a position. */
69
+ getTypeDefinition(uri, position) {
70
+ const ctx = this.context(uri);
71
+ return ctx ? getTypeDefinition(ctx, ctx.lineIndex.offsetAt(position)) : [];
72
+ }
73
+ /** All references to the symbol at a position. */
74
+ getReferences(uri, position) {
75
+ const ctx = this.context(uri);
76
+ return ctx ? getReferences(ctx, ctx.lineIndex.offsetAt(position)) : [];
77
+ }
78
+ /** Occurrences of the symbol at a position, for editor highlighting. */
79
+ getDocumentHighlights(uri, position) {
80
+ const ctx = this.context(uri);
81
+ return ctx ? getDocumentHighlights(ctx, ctx.lineIndex.offsetAt(position)) : [];
82
+ }
83
+ /** Workspace edit to rename the symbol at a position. */
84
+ getRenameEdits(uri, position, newName) {
85
+ const ctx = this.context(uri);
86
+ return ctx ? getRenameEdits(ctx, ctx.lineIndex.offsetAt(position), newName) : null;
87
+ }
88
+ /** The document outline. */
89
+ getDocumentSymbols(uri) {
90
+ const ctx = this.context(uri);
91
+ return ctx ? getDocumentSymbols(ctx) : [];
92
+ }
93
+ /** Project-wide symbol search. */
94
+ getWorkspaceSymbols(query) {
95
+ return getWorkspaceSymbols(this.project, query);
96
+ }
97
+ /** Signature help for the call enclosing a position. */
98
+ getSignatureHelp(uri, position) {
99
+ const ctx = this.context(uri);
100
+ return ctx ? getSignatureHelp(ctx, ctx.lineIndex.offsetAt(position)) : null;
101
+ }
102
+ /** Diagnostics for the document. */
103
+ getDiagnostics(uri) {
104
+ const ctx = this.context(uri);
105
+ return ctx ? getDiagnostics(ctx) : [];
106
+ }
107
+ /** Packed semantic tokens for the markup in the document. */
108
+ getSemanticTokens(uri) {
109
+ const ctx = this.context(uri);
110
+ return ctx ? getSemanticTokens(ctx) : { data: [] };
111
+ }
112
+ /** Folding ranges for the document. */
113
+ getFoldingRanges(uri) {
114
+ const ctx = this.context(uri);
115
+ return ctx ? getFoldingRanges(ctx) : [];
116
+ }
117
+ /** Code actions (quick fixes) for a range. */
118
+ getCodeActions(uri, range, errorCodes = []) {
119
+ const ctx = this.context(uri);
120
+ return ctx ? getCodeActions(ctx, range, errorCodes) : [];
121
+ }
122
+ /** Whole-document formatting edits (script/expression regions only). */
123
+ getFormattingEdits(uri) {
124
+ const ctx = this.context(uri);
125
+ return ctx ? getFormattingEdits(ctx) : [];
126
+ }
127
+ /** Inline parameter-name / inferred-type hints for a range. */
128
+ getInlayHints(uri, range, options) {
129
+ const ctx = this.context(uri);
130
+ return ctx ? getInlayHints(ctx, range, options) : [];
131
+ }
132
+ /** Smart-selection (Expand/Shrink Selection) chains for the given carets. */
133
+ getSelectionRanges(uri, positions) {
134
+ const ctx = this.context(uri);
135
+ return ctx ? getSelectionRanges(ctx, positions) : positions.map(position => ({ range: { start: position, end: position } }));
136
+ }
137
+ /** Formatting edits triggered by typing `ch` at a position. */
138
+ getOnTypeFormattingEdits(uri, position, ch) {
139
+ const ctx = this.context(uri);
140
+ return ctx ? getOnTypeFormattingEdits(ctx, position, ch) : [];
141
+ }
142
+ /**
143
+ * After the caret types `>`, returns a snippet closing the just-opened tag
144
+ * (e.g. `$0</div>`), or null. Powers JSX-style tag auto-closing.
145
+ */
146
+ getAutoCloseTag(uri, position) {
147
+ const ctx = this.context(uri);
148
+ return ctx ? getAutoCloseTag(ctx, ctx.lineIndex.offsetAt(position)) : null;
149
+ }
150
+ /** Opening/closing tag-name ranges to edit together (linked editing). */
151
+ getLinkedEditingRanges(uri, position) {
152
+ const ctx = this.context(uri);
153
+ return ctx ? getLinkedEditingRanges(ctx, ctx.lineIndex.offsetAt(position)) : null;
154
+ }
155
+ /** The compiled virtual TS for a document - exposed for tests/tooling. */
156
+ getVirtualCode(uri) {
157
+ return this.project.getVirtual(uriToPath(uri)).code;
158
+ }
159
+ /** Builds a RequestContext for a known document, or null if unknown. */
160
+ context(uri) {
161
+ const azerothPath = uriToPath(uri);
162
+ const source = this.project.getSource(azerothPath);
163
+ if (source === undefined) {
164
+ return null;
165
+ }
166
+ return {
167
+ project: this.project,
168
+ uri,
169
+ azerothPath,
170
+ virtualFile: toVirtualFile(azerothPath),
171
+ source,
172
+ virtual: this.project.getVirtual(azerothPath),
173
+ lineIndex: new LineIndex(source)
174
+ };
175
+ }
176
+ }
177
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,2EAA2E;AAC3E,gFAAgF;AAChF,2EAA2E;AAC3E,6EA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AO;YACrB,GAAG;YACH,WAAW;YACX,WAAW,EAAE,aAAa,CAAC,WAAW,CAAC;YACvC,MAAM;YACN,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC;YAC7C,SAAS,EAAE,IAAI,SAAS,CAAC,MAAM,CAAC;SACnC,CAAC;IACN,CAAC;CACJ"}
package/dist/text.d.ts ADDED
@@ -0,0 +1,25 @@
1
+ import type { Position, Range } from './protocol.ts';
2
+ /**
3
+ * Precomputed line-start offsets for a source string.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * const idx = new LineIndex('a\nbc');
8
+ * idx.positionAt(3); // { line: 1, character: 1 }
9
+ * idx.offsetAt({ line: 1, character: 1 }); // 3
10
+ * ```
11
+ */
12
+ export declare class LineIndex {
13
+ private readonly text;
14
+ private readonly lineStarts;
15
+ constructor(text: string);
16
+ /** Converts a byte offset to a zero-based position. */
17
+ positionAt(offset: number): Position;
18
+ /** Converts a zero-based position to a byte offset. */
19
+ offsetAt(position: Position): number;
20
+ /** Converts a `[start, end)` offset span to a Range. */
21
+ rangeAt(start: number, end: number): Range;
22
+ /** Total line count. */
23
+ get lineCount(): number;
24
+ }
25
+ //# sourceMappingURL=text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAErD;;;;;;;;;GASG;AACH,qBAAa,SAAS;IAIN,OAAO,CAAC,QAAQ,CAAC,IAAI;IAFjC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAW;gBAET,IAAI,EAAE,MAAM;IAYzC,uDAAuD;IAChD,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ;IAoB3C,uDAAuD;IAChD,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM;IAiB3C,wDAAwD;IACjD,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,KAAK;IAKjD,wBAAwB;IACxB,IAAW,SAAS,IAAI,MAAM,CAG7B;CACJ"}
package/dist/text.js ADDED
@@ -0,0 +1,66 @@
1
+ // Offset <-> line/character conversion. The compiler and TypeScript both work
2
+ // in byte offsets; LSP speaks line/character. A LineIndex precomputes the start
3
+ // offset of every line so conversions in either direction are a binary search,
4
+ // which matters when translating the many ranges a "find references" returns.
5
+ /**
6
+ * Precomputed line-start offsets for a source string.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const idx = new LineIndex('a\nbc');
11
+ * idx.positionAt(3); // { line: 1, character: 1 }
12
+ * idx.offsetAt({ line: 1, character: 1 }); // 3
13
+ * ```
14
+ */
15
+ export class LineIndex {
16
+ text;
17
+ lineStarts;
18
+ constructor(text) {
19
+ this.text = text;
20
+ this.lineStarts = [0];
21
+ for (let i = 0; i < text.length; i++) {
22
+ if (text[i] === '\n') {
23
+ this.lineStarts.push(i + 1);
24
+ }
25
+ }
26
+ }
27
+ /** Converts a byte offset to a zero-based position. */
28
+ positionAt(offset) {
29
+ const clamped = Math.max(0, Math.min(offset, this.text.length));
30
+ let lo = 0;
31
+ let hi = this.lineStarts.length - 1;
32
+ while (lo < hi) {
33
+ const mid = (lo + hi + 1) >> 1;
34
+ if (this.lineStarts[mid] <= clamped) {
35
+ lo = mid;
36
+ }
37
+ else {
38
+ hi = mid - 1;
39
+ }
40
+ }
41
+ return { line: lo, character: clamped - this.lineStarts[lo] };
42
+ }
43
+ /** Converts a zero-based position to a byte offset. */
44
+ offsetAt(position) {
45
+ if (position.line < 0) {
46
+ return 0;
47
+ }
48
+ if (position.line >= this.lineStarts.length) {
49
+ return this.text.length;
50
+ }
51
+ const lineStart = this.lineStarts[position.line];
52
+ const nextLine = position.line + 1 < this.lineStarts.length
53
+ ? this.lineStarts[position.line + 1]
54
+ : this.text.length + 1;
55
+ return Math.min(lineStart + Math.max(0, position.character), nextLine - 1);
56
+ }
57
+ /** Converts a `[start, end)` offset span to a Range. */
58
+ rangeAt(start, end) {
59
+ return { start: this.positionAt(start), end: this.positionAt(end) };
60
+ }
61
+ /** Total line count. */
62
+ get lineCount() {
63
+ return this.lineStarts.length;
64
+ }
65
+ }
66
+ //# sourceMappingURL=text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.js","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,gFAAgF;AAChF,+EAA+E;AAC/E,8EAA8E;AAI9E;;;;;;;;;GASG;AACH,MAAM,OAAO,SAAS;IAIW;IAFZ,UAAU,CAAW;IAEtC,YAA6B,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;QAErC,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC;QACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EACpC,CAAC;YACG,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,EACpB,CAAC;gBACG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAChC,CAAC;QACL,CAAC;IACL,CAAC;IAED,uDAAuD;IAChD,UAAU,CAAC,MAAc;QAE5B,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAChE,IAAI,EAAE,GAAG,CAAC,CAAC;QACX,IAAI,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;QACpC,OAAO,EAAE,GAAG,EAAE,EACd,CAAC;YACG,MAAM,GAAG,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;YAC/B,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,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,SAAS;QAEhB,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;IAClC,CAAC;CACJ"}
@@ -0,0 +1,75 @@
1
+ import ts from 'typescript';
2
+ import { type VirtualCode } from './virtual-code.ts';
3
+ /** True for a synthetic virtual file name. */
4
+ export declare function isVirtualFile(fileName: string): boolean;
5
+ /** Maps a `.azeroth` path to its virtual TS file name. */
6
+ export declare function toVirtualFile(azerothPath: string): string;
7
+ /** Maps a virtual TS file name back to its `.azeroth` path. */
8
+ export declare function toAzerothPath(virtualFile: string): string;
9
+ /**
10
+ * Hosts a TypeScript language service over the workspace's `.azeroth` (and
11
+ * real) files. One instance per workspace folder.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * const project = new AzerothProject(process.cwd());
16
+ * project.openDocument('/abs/App.azeroth', 'export default () => <h1>Hi</h1>;');
17
+ * const { mapping } = project.getVirtual('/abs/App.azeroth');
18
+ * project.service.getQuickInfoAtPosition('/abs/App.azeroth.ts', mapping.toGenerated(0)!);
19
+ * ```
20
+ */
21
+ export declare class AzerothProject {
22
+ private readonly currentDirectory;
23
+ /** The underlying TypeScript language service. */
24
+ readonly service: ts.LanguageService;
25
+ private readonly open;
26
+ private readonly virtualCache;
27
+ private readonly options;
28
+ /** Virtual names of every `.azeroth` file found in the workspace. */
29
+ private readonly discovered;
30
+ private projectVersion;
31
+ constructor(currentDirectory: string, configPath?: string);
32
+ /** Path of the injected ambient declarations file. */
33
+ private readonly intrinsicsFile;
34
+ /**
35
+ * Finds every `.azeroth` file in the workspace so they all join the TS
36
+ * program - enabling cross-file go-to-definition and auto-import of
37
+ * components defined in other `.azeroth` files, plus workspace symbols.
38
+ */
39
+ private discoverWorkspace;
40
+ /** Registers/updates an open `.azeroth` document. */
41
+ openDocument(azerothPath: string, source: string): void;
42
+ /** Drops an open document (e.g. the editor closed it). */
43
+ closeDocument(azerothPath: string): void;
44
+ /** All currently-open `.azeroth` paths. */
45
+ openPaths(): string[];
46
+ /** The current source of a `.azeroth` document (open buffer or disk). */
47
+ getSource(azerothPath: string): string | undefined;
48
+ /**
49
+ * Returns the virtual compilation for a `.azeroth` path, building it from
50
+ * the open document or from disk. Cached against the exact source so the
51
+ * mapping always matches the snapshot TypeScript analyzed.
52
+ */
53
+ getVirtual(azerothPath: string): VirtualCode;
54
+ /** Reads a `.azeroth` source from the open set or disk. */
55
+ private readAzeroth;
56
+ /** Builds the language service host backing the virtual project. */
57
+ private createHost;
58
+ /** fileExists that also reports the synthetic virtual twins as present. */
59
+ private hostFileExists;
60
+ /** readFile that materializes the virtual TS for a `.azeroth` twin. */
61
+ private hostReadFile;
62
+ /**
63
+ * Resolves each import. `*.azeroth` specifiers point at the importer's
64
+ * sibling `.azeroth` file and resolve to its virtual twin; everything else
65
+ * goes through standard TypeScript resolution (which honours tsconfig
66
+ * `paths` for the `@azerothjs/*` packages and node_modules).
67
+ */
68
+ private resolveModules;
69
+ /**
70
+ * Discovers the nearest tsconfig and forces the options the virtual modules
71
+ * need (TS source, bundler resolution), keeping the project's `paths`.
72
+ */
73
+ private static resolveOptions;
74
+ }
75
+ //# sourceMappingURL=ts-project.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ts-project.d.ts","sourceRoot":"","sources":["../src/ts-project.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAwB1E,8CAA8C;AAC9C,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAGvD;AAED,0DAA0D;AAC1D,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAGzD;AAED,+DAA+D;AAC/D,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAGzD;AAeD;;;;;;;;;;;GAWG;AACH,qBAAa,cAAc;IAgBX,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IAd7C,kDAAkD;IAClD,SAAgB,OAAO,EAAE,EAAE,CAAC,eAAe,CAAC;IAE5C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA8B;IAEnD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAoC;IAEjE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;IAE7C,qEAAqE;IACrE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAW;IAEtC,OAAO,CAAC,cAAc,CAAK;gBAEE,gBAAgB,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;IAQ1E,sDAAsD;IACtD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IAExC;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAkBzB,qDAAqD;IAC9C,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAQ9D,0DAA0D;IACnD,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAO/C,2CAA2C;IACpC,SAAS,IAAI,MAAM,EAAE;IAK5B,yEAAyE;IAClE,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAKzD;;;;OAIG;IACI,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,WAAW;IAcnD,2DAA2D;IAC3D,OAAO,CAAC,WAAW;IAUnB,oEAAoE;IACpE,OAAO,CAAC,UAAU;IAoElB,2EAA2E;IAC3E,OAAO,CAAC,cAAc;IAgBtB,uEAAuE;IACvE,OAAO,CAAC,YAAY;IAkBpB;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IA8BtB;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;CAyBhC"}
@@ -0,0 +1,266 @@
1
+ // The TypeScript bridge. A `.azeroth` file is a TS module with markup regions;
2
+ // once the markup is compiled to `h(...)` calls (virtual-code.ts) the result is
3
+ // ordinary TypeScript, so the authoritative engine for type inference,
4
+ // completion, hover, definitions, references, rename, signatures, and
5
+ // diagnostics is the TypeScript language service itself.
6
+ //
7
+ // This module runs a single `ts.LanguageService` over a virtual project:
8
+ // - each `.azeroth` file is presented to TS under the synthetic name
9
+ // `<path>.azeroth.ts`, whose contents are the compiled virtual module;
10
+ // - imports of other `.azeroth` files are resolved to their virtual twin, so
11
+ // definitions/types flow across `.azeroth` modules;
12
+ // - every real file (the runtime packages, node_modules, lib.d.ts) is read
13
+ // from disk through ts.sys.
14
+ //
15
+ // Callers work in original `.azeroth` offsets; the CodeMapping returned by
16
+ // `getVirtual` translates to and from the virtual offsets TS understands.
17
+ import ts from 'typescript';
18
+ import { generateVirtualCode } from "./virtual-code.js";
19
+ /** Suffix that marks a synthetic virtual file backing a `.azeroth` module. */
20
+ const VIRTUAL_SUFFIX = '.azeroth.ts';
21
+ /** Basename of the injected ambient declarations (always in the program). */
22
+ const INTRINSICS_BASENAME = '__azeroth-intrinsics.d.ts';
23
+ /**
24
+ * Ambient types injected into every project. `AzerothHandler<'onClick'>` maps a
25
+ * camelCase event prop to the right DOM event (via lib.dom's
26
+ * GlobalEventHandlersEventMap), so the virtual code can contextually type host
27
+ * event handlers - `<button onClick={(e) => …}>` infers `e: MouseEvent` - without
28
+ * imposing strict attribute checking that the permissive `h()` runtime doesn't.
29
+ */
30
+ const INTRINSICS_CONTENT = `
31
+ type AzerothHandler<N extends string> =
32
+ N extends \`on\${infer E}\`
33
+ ? (event: Lowercase<E> extends keyof GlobalEventHandlersEventMap
34
+ ? GlobalEventHandlersEventMap[Lowercase<E>]
35
+ : Event) => unknown
36
+ : (event: Event) => unknown;
37
+ `;
38
+ /** True for a synthetic virtual file name. */
39
+ export function isVirtualFile(fileName) {
40
+ return fileName.endsWith(VIRTUAL_SUFFIX);
41
+ }
42
+ /** Maps a `.azeroth` path to its virtual TS file name. */
43
+ export function toVirtualFile(azerothPath) {
44
+ return `${azerothPath}.ts`;
45
+ }
46
+ /** Maps a virtual TS file name back to its `.azeroth` path. */
47
+ export function toAzerothPath(virtualFile) {
48
+ return virtualFile.slice(0, -3);
49
+ }
50
+ /**
51
+ * Hosts a TypeScript language service over the workspace's `.azeroth` (and
52
+ * real) files. One instance per workspace folder.
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * const project = new AzerothProject(process.cwd());
57
+ * project.openDocument('/abs/App.azeroth', 'export default () => <h1>Hi</h1>;');
58
+ * const { mapping } = project.getVirtual('/abs/App.azeroth');
59
+ * project.service.getQuickInfoAtPosition('/abs/App.azeroth.ts', mapping.toGenerated(0)!);
60
+ * ```
61
+ */
62
+ export class AzerothProject {
63
+ currentDirectory;
64
+ /** The underlying TypeScript language service. */
65
+ service;
66
+ open = new Map();
67
+ virtualCache = new Map();
68
+ options;
69
+ /** Virtual names of every `.azeroth` file found in the workspace. */
70
+ discovered;
71
+ projectVersion = 0;
72
+ constructor(currentDirectory, configPath) {
73
+ this.currentDirectory = currentDirectory;
74
+ this.options = AzerothProject.resolveOptions(currentDirectory, configPath);
75
+ this.intrinsicsFile = `${currentDirectory.replace(/\\/g, '/').replace(/\/$/, '')}/${INTRINSICS_BASENAME}`;
76
+ this.discovered = this.discoverWorkspace();
77
+ this.service = ts.createLanguageService(this.createHost(), ts.createDocumentRegistry());
78
+ }
79
+ /** Path of the injected ambient declarations file. */
80
+ intrinsicsFile;
81
+ /**
82
+ * Finds every `.azeroth` file in the workspace so they all join the TS
83
+ * program - enabling cross-file go-to-definition and auto-import of
84
+ * components defined in other `.azeroth` files, plus workspace symbols.
85
+ */
86
+ discoverWorkspace() {
87
+ try {
88
+ const files = ts.sys.readDirectory(this.currentDirectory, ['.azeroth'], ['**/node_modules/**', '**/dist/**', '**/.git/**'], ['**/*.azeroth']);
89
+ return files.map(toVirtualFile);
90
+ }
91
+ catch {
92
+ return [];
93
+ }
94
+ }
95
+ /** Registers/updates an open `.azeroth` document. */
96
+ openDocument(azerothPath, source) {
97
+ const prev = this.open.get(azerothPath);
98
+ this.open.set(azerothPath, { source, version: (prev?.version ?? 0) + 1 });
99
+ this.virtualCache.delete(azerothPath);
100
+ this.projectVersion++;
101
+ }
102
+ /** Drops an open document (e.g. the editor closed it). */
103
+ closeDocument(azerothPath) {
104
+ this.open.delete(azerothPath);
105
+ this.virtualCache.delete(azerothPath);
106
+ this.projectVersion++;
107
+ }
108
+ /** All currently-open `.azeroth` paths. */
109
+ openPaths() {
110
+ return [...this.open.keys()];
111
+ }
112
+ /** The current source of a `.azeroth` document (open buffer or disk). */
113
+ getSource(azerothPath) {
114
+ return this.readAzeroth(azerothPath);
115
+ }
116
+ /**
117
+ * Returns the virtual compilation for a `.azeroth` path, building it from
118
+ * the open document or from disk. Cached against the exact source so the
119
+ * mapping always matches the snapshot TypeScript analyzed.
120
+ */
121
+ getVirtual(azerothPath) {
122
+ const source = this.readAzeroth(azerothPath) ?? '';
123
+ const cached = this.virtualCache.get(azerothPath);
124
+ if (cached && cached.source === source) {
125
+ return cached;
126
+ }
127
+ const built = generateVirtualCode(source);
128
+ const entry = { ...built, source };
129
+ this.virtualCache.set(azerothPath, entry);
130
+ return entry;
131
+ }
132
+ /** Reads a `.azeroth` source from the open set or disk. */
133
+ readAzeroth(azerothPath) {
134
+ const doc = this.open.get(azerothPath);
135
+ if (doc) {
136
+ return doc.source;
137
+ }
138
+ return ts.sys.readFile(azerothPath);
139
+ }
140
+ /** Builds the language service host backing the virtual project. */
141
+ createHost() {
142
+ // Every member below is an arrow function, so `this` is lexically the
143
+ // project instance; no alias is needed.
144
+ const host = {
145
+ getScriptFileNames: () => [this.intrinsicsFile, ...new Set([...this.openPaths().map(toVirtualFile), ...this.discovered])],
146
+ getProjectVersion: () => String(this.projectVersion),
147
+ getScriptVersion: (fileName) => {
148
+ if (fileName === this.intrinsicsFile) {
149
+ return '1';
150
+ }
151
+ if (isVirtualFile(fileName)) {
152
+ const azerothPath = toAzerothPath(fileName);
153
+ const doc = this.open.get(azerothPath);
154
+ if (doc) {
155
+ return `o${doc.version}`;
156
+ }
157
+ return `d${ts.sys.getModifiedTime?.(azerothPath)?.getTime() ?? 0}`;
158
+ }
159
+ return `${ts.sys.getModifiedTime?.(fileName)?.getTime() ?? 0}`;
160
+ },
161
+ getScriptSnapshot: (fileName) => {
162
+ if (fileName === this.intrinsicsFile) {
163
+ return ts.ScriptSnapshot.fromString(INTRINSICS_CONTENT);
164
+ }
165
+ if (isVirtualFile(fileName)) {
166
+ const azerothPath = toAzerothPath(fileName);
167
+ if (this.readAzeroth(azerothPath) === undefined) {
168
+ return undefined;
169
+ }
170
+ return ts.ScriptSnapshot.fromString(this.getVirtual(azerothPath).code);
171
+ }
172
+ const contents = ts.sys.readFile(fileName);
173
+ return contents === undefined ? undefined : ts.ScriptSnapshot.fromString(contents);
174
+ },
175
+ getCurrentDirectory: () => this.currentDirectory,
176
+ getCompilationSettings: () => this.options,
177
+ getDefaultLibFileName: (opts) => ts.getDefaultLibFilePath(opts),
178
+ fileExists: (fileName) => this.hostFileExists(fileName),
179
+ readFile: (fileName) => this.hostReadFile(fileName),
180
+ readDirectory: ts.sys.readDirectory,
181
+ directoryExists: ts.sys.directoryExists,
182
+ getDirectories: ts.sys.getDirectories,
183
+ realpath: ts.sys.realpath,
184
+ useCaseSensitiveFileNames: () => ts.sys.useCaseSensitiveFileNames,
185
+ resolveModuleNameLiterals: (literals, containingFile, _redirect, options) => this.resolveModules(literals, containingFile, options)
186
+ };
187
+ return host;
188
+ }
189
+ /** fileExists that also reports the synthetic virtual twins as present. */
190
+ hostFileExists(fileName) {
191
+ if (fileName === this.intrinsicsFile) {
192
+ return true;
193
+ }
194
+ if (isVirtualFile(fileName)) {
195
+ const azerothPath = toAzerothPath(fileName);
196
+ return this.open.has(azerothPath) || ts.sys.fileExists(azerothPath);
197
+ }
198
+ return ts.sys.fileExists(fileName);
199
+ }
200
+ /** readFile that materializes the virtual TS for a `.azeroth` twin. */
201
+ hostReadFile(fileName) {
202
+ if (fileName === this.intrinsicsFile) {
203
+ return INTRINSICS_CONTENT;
204
+ }
205
+ if (isVirtualFile(fileName)) {
206
+ const azerothPath = toAzerothPath(fileName);
207
+ return this.readAzeroth(azerothPath) === undefined
208
+ ? undefined
209
+ : this.getVirtual(azerothPath).code;
210
+ }
211
+ return ts.sys.readFile(fileName);
212
+ }
213
+ /**
214
+ * Resolves each import. `*.azeroth` specifiers point at the importer's
215
+ * sibling `.azeroth` file and resolve to its virtual twin; everything else
216
+ * goes through standard TypeScript resolution (which honours tsconfig
217
+ * `paths` for the `@azerothjs/*` packages and node_modules).
218
+ */
219
+ resolveModules(literals, containingFile, options) {
220
+ return literals.map((literal) => {
221
+ const text = literal.text;
222
+ if (text.endsWith('.azeroth') && (text.startsWith('.') || text.startsWith('/'))) {
223
+ const dir = ts.sys.resolvePath(containingFile).replace(/[\\/][^\\/]*$/, '');
224
+ const candidate = ts.sys.resolvePath(`${dir}/${text}`);
225
+ if (this.hostFileExists(toVirtualFile(candidate))) {
226
+ return {
227
+ resolvedModule: {
228
+ resolvedFileName: toVirtualFile(candidate),
229
+ extension: ts.Extension.Ts,
230
+ isExternalLibraryImport: false
231
+ },
232
+ failedLookupLocations: []
233
+ };
234
+ }
235
+ }
236
+ return ts.resolveModuleName(text, containingFile, options, ts.sys);
237
+ });
238
+ }
239
+ /**
240
+ * Discovers the nearest tsconfig and forces the options the virtual modules
241
+ * need (TS source, bundler resolution), keeping the project's `paths`.
242
+ */
243
+ static resolveOptions(currentDirectory, configPath) {
244
+ let options = {};
245
+ const found = configPath ?? ts.findConfigFile(currentDirectory, ts.sys.fileExists, 'tsconfig.json');
246
+ if (found) {
247
+ const read = ts.readConfigFile(found, ts.sys.readFile);
248
+ const parsed = ts.parseJsonConfigFileContent(read.config ?? {}, ts.sys, found.replace(/[\\/][^\\/]*$/, ''));
249
+ options = parsed.options;
250
+ }
251
+ return {
252
+ ...options,
253
+ allowJs: true,
254
+ checkJs: false,
255
+ noEmit: true,
256
+ jsx: ts.JsxEmit.Preserve,
257
+ module: options.module ?? ts.ModuleKind.ESNext,
258
+ target: options.target ?? ts.ScriptTarget.ESNext,
259
+ moduleResolution: options.moduleResolution ?? ts.ModuleResolutionKind.Bundler,
260
+ allowImportingTsExtensions: true,
261
+ skipLibCheck: true,
262
+ lib: options.lib ?? ['lib.esnext.d.ts', 'lib.dom.d.ts', 'lib.dom.iterable.d.ts']
263
+ };
264
+ }
265
+ }
266
+ //# sourceMappingURL=ts-project.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ts-project.js","sourceRoot":"","sources":["../src/ts-project.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,gFAAgF;AAChF,uEAAuE;AACvE,sEAAsE;AACtE,yDAAyD;AACzD,EAAE;AACF,yEAAyE;AACzE,uEAAuE;AACvE,2EAA2E;AAC3E,+EAA+E;AAC/E,wDAAwD;AACxD,6EAA6E;AAC7E,gCAAgC;AAChC,EAAE;AACF,2EAA2E;AAC3E,0EAA0E;AAE1E,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,mBAAmB,EAAoB,MAAM,mBAAmB,CAAC;AAE1E,8EAA8E;AAC9E,MAAM,cAAc,GAAG,aAAa,CAAC;AAErC,6EAA6E;AAC7E,MAAM,mBAAmB,GAAG,2BAA2B,CAAC;AAExD;;;;;;GAMG;AACH,MAAM,kBAAkB,GAAG;;;;;;;CAO1B,CAAC;AAEF,8CAA8C;AAC9C,MAAM,UAAU,aAAa,CAAC,QAAgB;IAE1C,OAAO,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;AAC7C,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,aAAa,CAAC,WAAmB;IAE7C,OAAO,GAAI,WAAY,KAAK,CAAC;AACjC,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,aAAa,CAAC,WAAmB;IAE7C,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACpC,CAAC;AAeD;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,cAAc;IAgBM;IAd7B,kDAAkD;IAClC,OAAO,CAAqB;IAE3B,IAAI,GA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