@justscale/typescript 0.1.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 (245) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +128 -0
  3. package/dist/api.d.ts +144 -0
  4. package/dist/api.d.ts.map +1 -0
  5. package/dist/api.js +380 -0
  6. package/dist/api.js.map +1 -0
  7. package/dist/compiler/analyzer.d.ts +247 -0
  8. package/dist/compiler/analyzer.d.ts.map +1 -0
  9. package/dist/compiler/analyzer.js +3201 -0
  10. package/dist/compiler/analyzer.js.map +1 -0
  11. package/dist/compiler/cli.d.ts +12 -0
  12. package/dist/compiler/cli.d.ts.map +1 -0
  13. package/dist/compiler/cli.js +209 -0
  14. package/dist/compiler/cli.js.map +1 -0
  15. package/dist/compiler/compile.d.ts +26 -0
  16. package/dist/compiler/compile.d.ts.map +1 -0
  17. package/dist/compiler/compile.js +121 -0
  18. package/dist/compiler/compile.js.map +1 -0
  19. package/dist/compiler/errors.d.ts +336 -0
  20. package/dist/compiler/errors.d.ts.map +1 -0
  21. package/dist/compiler/errors.js +466 -0
  22. package/dist/compiler/errors.js.map +1 -0
  23. package/dist/compiler/exports-prepass.d.ts +31 -0
  24. package/dist/compiler/exports-prepass.d.ts.map +1 -0
  25. package/dist/compiler/exports-prepass.js +249 -0
  26. package/dist/compiler/exports-prepass.js.map +1 -0
  27. package/dist/compiler/hmr-change-detector.d.ts +47 -0
  28. package/dist/compiler/hmr-change-detector.d.ts.map +1 -0
  29. package/dist/compiler/hmr-change-detector.js +395 -0
  30. package/dist/compiler/hmr-change-detector.js.map +1 -0
  31. package/dist/compiler/hmr-transformer.d.ts +54 -0
  32. package/dist/compiler/hmr-transformer.d.ts.map +1 -0
  33. package/dist/compiler/hmr-transformer.js +535 -0
  34. package/dist/compiler/hmr-transformer.js.map +1 -0
  35. package/dist/compiler/index.d.ts +19 -0
  36. package/dist/compiler/index.d.ts.map +1 -0
  37. package/dist/compiler/index.js +16 -0
  38. package/dist/compiler/index.js.map +1 -0
  39. package/dist/compiler/primitive-detector.d.ts +70 -0
  40. package/dist/compiler/primitive-detector.d.ts.map +1 -0
  41. package/dist/compiler/primitive-detector.js +338 -0
  42. package/dist/compiler/primitive-detector.js.map +1 -0
  43. package/dist/compiler/ptsc.d.ts +40 -0
  44. package/dist/compiler/ptsc.d.ts.map +1 -0
  45. package/dist/compiler/ptsc.js +462 -0
  46. package/dist/compiler/ptsc.js.map +1 -0
  47. package/dist/compiler/rewriter.d.ts +96 -0
  48. package/dist/compiler/rewriter.d.ts.map +1 -0
  49. package/dist/compiler/rewriter.js +418 -0
  50. package/dist/compiler/rewriter.js.map +1 -0
  51. package/dist/compiler/step-hash.d.ts +43 -0
  52. package/dist/compiler/step-hash.d.ts.map +1 -0
  53. package/dist/compiler/step-hash.js +83 -0
  54. package/dist/compiler/step-hash.js.map +1 -0
  55. package/dist/compiler/switch-codegen.d.ts +84 -0
  56. package/dist/compiler/switch-codegen.d.ts.map +1 -0
  57. package/dist/compiler/switch-codegen.js +1540 -0
  58. package/dist/compiler/switch-codegen.js.map +1 -0
  59. package/dist/compiler/transformer.d.ts +29 -0
  60. package/dist/compiler/transformer.d.ts.map +1 -0
  61. package/dist/compiler/transformer.js +216 -0
  62. package/dist/compiler/transformer.js.map +1 -0
  63. package/dist/config/index.d.ts +122 -0
  64. package/dist/config/index.d.ts.map +1 -0
  65. package/dist/config/index.js +215 -0
  66. package/dist/config/index.js.map +1 -0
  67. package/dist/di-errors/formatter.d.ts +126 -0
  68. package/dist/di-errors/formatter.d.ts.map +1 -0
  69. package/dist/di-errors/formatter.js +384 -0
  70. package/dist/di-errors/formatter.js.map +1 -0
  71. package/dist/di-errors/index.d.ts +5 -0
  72. package/dist/di-errors/index.d.ts.map +1 -0
  73. package/dist/di-errors/index.js +13 -0
  74. package/dist/di-errors/index.js.map +1 -0
  75. package/dist/editor.d.ts +11 -0
  76. package/dist/editor.d.ts.map +1 -0
  77. package/dist/editor.js +2 -0
  78. package/dist/editor.js.map +1 -0
  79. package/dist/index.d.ts +35 -0
  80. package/dist/index.d.ts.map +1 -0
  81. package/dist/index.js +40 -0
  82. package/dist/index.js.map +1 -0
  83. package/dist/language-service/index.d.ts +52 -0
  84. package/dist/language-service/index.d.ts.map +1 -0
  85. package/dist/language-service/index.js +366 -0
  86. package/dist/language-service/index.js.map +1 -0
  87. package/dist/language-service/process-quick-fixes.d.ts +20 -0
  88. package/dist/language-service/process-quick-fixes.d.ts.map +1 -0
  89. package/dist/language-service/process-quick-fixes.js +114 -0
  90. package/dist/language-service/process-quick-fixes.js.map +1 -0
  91. package/dist/language-service/quick-fix-discovery.d.ts +39 -0
  92. package/dist/language-service/quick-fix-discovery.d.ts.map +1 -0
  93. package/dist/language-service/quick-fix-discovery.js +124 -0
  94. package/dist/language-service/quick-fix-discovery.js.map +1 -0
  95. package/dist/loader/incremental.d.ts +50 -0
  96. package/dist/loader/incremental.d.ts.map +1 -0
  97. package/dist/loader/incremental.js +151 -0
  98. package/dist/loader/incremental.js.map +1 -0
  99. package/dist/loader/index.d.ts +25 -0
  100. package/dist/loader/index.d.ts.map +1 -0
  101. package/dist/loader/index.js +24 -0
  102. package/dist/loader/index.js.map +1 -0
  103. package/dist/loader/loader.d.ts +52 -0
  104. package/dist/loader/loader.d.ts.map +1 -0
  105. package/dist/loader/loader.js +248 -0
  106. package/dist/loader/loader.js.map +1 -0
  107. package/dist/loader/register.d.ts +14 -0
  108. package/dist/loader/register.d.ts.map +1 -0
  109. package/dist/loader/register.js +20 -0
  110. package/dist/loader/register.js.map +1 -0
  111. package/dist/plugins/index.d.ts +13 -0
  112. package/dist/plugins/index.d.ts.map +1 -0
  113. package/dist/plugins/index.js +13 -0
  114. package/dist/plugins/index.js.map +1 -0
  115. package/dist/plugins/index.public.d.ts +13 -0
  116. package/dist/plugins/index.public.d.ts.map +1 -0
  117. package/dist/plugins/index.public.js +13 -0
  118. package/dist/plugins/index.public.js.map +1 -0
  119. package/dist/plugins/types.d.ts +83 -0
  120. package/dist/plugins/types.d.ts.map +1 -0
  121. package/dist/plugins/types.js +24 -0
  122. package/dist/plugins/types.js.map +1 -0
  123. package/dist/server/index.d.ts +33 -0
  124. package/dist/server/index.d.ts.map +1 -0
  125. package/dist/server/index.js +42 -0
  126. package/dist/server/index.js.map +1 -0
  127. package/dist/server/tsserver.d.ts +28 -0
  128. package/dist/server/tsserver.d.ts.map +1 -0
  129. package/dist/server/tsserver.js +126 -0
  130. package/dist/server/tsserver.js.map +1 -0
  131. package/lib/lib.d.ts +20 -0
  132. package/lib/lib.decorators.d.ts +382 -0
  133. package/lib/lib.decorators.legacy.d.ts +20 -0
  134. package/lib/lib.dom.asynciterable.d.ts +18 -0
  135. package/lib/lib.dom.d.ts +45125 -0
  136. package/lib/lib.dom.iterable.d.ts +18 -0
  137. package/lib/lib.es2015.collection.d.ts +150 -0
  138. package/lib/lib.es2015.core.d.ts +595 -0
  139. package/lib/lib.es2015.d.ts +26 -0
  140. package/lib/lib.es2015.generator.d.ts +75 -0
  141. package/lib/lib.es2015.iterable.d.ts +603 -0
  142. package/lib/lib.es2015.promise.d.ts +79 -0
  143. package/lib/lib.es2015.proxy.d.ts +126 -0
  144. package/lib/lib.es2015.reflect.d.ts +142 -0
  145. package/lib/lib.es2015.symbol.d.ts +44 -0
  146. package/lib/lib.es2015.symbol.wellknown.d.ts +324 -0
  147. package/lib/lib.es2016.array.include.d.ts +114 -0
  148. package/lib/lib.es2016.d.ts +19 -0
  149. package/lib/lib.es2016.full.d.ts +21 -0
  150. package/lib/lib.es2016.intl.d.ts +29 -0
  151. package/lib/lib.es2017.arraybuffer.d.ts +19 -0
  152. package/lib/lib.es2017.d.ts +24 -0
  153. package/lib/lib.es2017.date.d.ts +29 -0
  154. package/lib/lib.es2017.full.d.ts +21 -0
  155. package/lib/lib.es2017.intl.d.ts +42 -0
  156. package/lib/lib.es2017.object.d.ts +47 -0
  157. package/lib/lib.es2017.sharedmemory.d.ts +133 -0
  158. package/lib/lib.es2017.string.d.ts +43 -0
  159. package/lib/lib.es2017.typedarrays.d.ts +51 -0
  160. package/lib/lib.es2018.asyncgenerator.d.ts +75 -0
  161. package/lib/lib.es2018.asynciterable.d.ts +51 -0
  162. package/lib/lib.es2018.d.ts +22 -0
  163. package/lib/lib.es2018.full.d.ts +22 -0
  164. package/lib/lib.es2018.intl.d.ts +81 -0
  165. package/lib/lib.es2018.promise.d.ts +28 -0
  166. package/lib/lib.es2018.regexp.d.ts +35 -0
  167. package/lib/lib.es2019.array.d.ts +77 -0
  168. package/lib/lib.es2019.d.ts +22 -0
  169. package/lib/lib.es2019.full.d.ts +22 -0
  170. package/lib/lib.es2019.intl.d.ts +21 -0
  171. package/lib/lib.es2019.object.d.ts +31 -0
  172. package/lib/lib.es2019.string.d.ts +35 -0
  173. package/lib/lib.es2019.symbol.d.ts +22 -0
  174. package/lib/lib.es2020.bigint.d.ts +763 -0
  175. package/lib/lib.es2020.d.ts +25 -0
  176. package/lib/lib.es2020.date.d.ts +40 -0
  177. package/lib/lib.es2020.full.d.ts +22 -0
  178. package/lib/lib.es2020.intl.d.ts +472 -0
  179. package/lib/lib.es2020.number.d.ts +26 -0
  180. package/lib/lib.es2020.promise.d.ts +45 -0
  181. package/lib/lib.es2020.sharedmemory.d.ts +97 -0
  182. package/lib/lib.es2020.string.d.ts +42 -0
  183. package/lib/lib.es2020.symbol.wellknown.d.ts +39 -0
  184. package/lib/lib.es2021.d.ts +21 -0
  185. package/lib/lib.es2021.full.d.ts +22 -0
  186. package/lib/lib.es2021.intl.d.ts +164 -0
  187. package/lib/lib.es2021.promise.d.ts +46 -0
  188. package/lib/lib.es2021.string.d.ts +31 -0
  189. package/lib/lib.es2021.weakref.d.ts +76 -0
  190. package/lib/lib.es2022.array.d.ts +119 -0
  191. package/lib/lib.es2022.d.ts +23 -0
  192. package/lib/lib.es2022.error.d.ts +73 -0
  193. package/lib/lib.es2022.full.d.ts +22 -0
  194. package/lib/lib.es2022.intl.d.ts +143 -0
  195. package/lib/lib.es2022.object.d.ts +24 -0
  196. package/lib/lib.es2022.regexp.d.ts +37 -0
  197. package/lib/lib.es2022.string.d.ts +23 -0
  198. package/lib/lib.es2023.array.d.ts +922 -0
  199. package/lib/lib.es2023.collection.d.ts +19 -0
  200. package/lib/lib.es2023.d.ts +20 -0
  201. package/lib/lib.es2023.full.d.ts +22 -0
  202. package/lib/lib.es2023.intl.d.ts +62 -0
  203. package/lib/lib.es2024.arraybuffer.d.ts +63 -0
  204. package/lib/lib.es2024.collection.d.ts +27 -0
  205. package/lib/lib.es2024.d.ts +24 -0
  206. package/lib/lib.es2024.full.d.ts +22 -0
  207. package/lib/lib.es2024.object.d.ts +27 -0
  208. package/lib/lib.es2024.promise.d.ts +33 -0
  209. package/lib/lib.es2024.regexp.d.ts +23 -0
  210. package/lib/lib.es2024.sharedmemory.d.ts +66 -0
  211. package/lib/lib.es2024.string.d.ts +27 -0
  212. package/lib/lib.es2025.collection.d.ts +94 -0
  213. package/lib/lib.es2025.d.ts +23 -0
  214. package/lib/lib.es2025.float16.d.ts +443 -0
  215. package/lib/lib.es2025.full.d.ts +22 -0
  216. package/lib/lib.es2025.intl.d.ts +200 -0
  217. package/lib/lib.es2025.iterator.d.ts +146 -0
  218. package/lib/lib.es2025.promise.d.ts +32 -0
  219. package/lib/lib.es2025.regexp.d.ts +30 -0
  220. package/lib/lib.es5.d.ts +4599 -0
  221. package/lib/lib.es6.d.ts +21 -0
  222. package/lib/lib.esnext.array.d.ts +33 -0
  223. package/lib/lib.esnext.collection.d.ts +47 -0
  224. package/lib/lib.esnext.d.ts +27 -0
  225. package/lib/lib.esnext.date.d.ts +21 -0
  226. package/lib/lib.esnext.decorators.d.ts +26 -0
  227. package/lib/lib.esnext.disposable.d.ts +191 -0
  228. package/lib/lib.esnext.error.d.ts +22 -0
  229. package/lib/lib.esnext.full.d.ts +22 -0
  230. package/lib/lib.esnext.intl.d.ts +107 -0
  231. package/lib/lib.esnext.sharedmemory.d.ts +23 -0
  232. package/lib/lib.esnext.temporal.d.ts +485 -0
  233. package/lib/lib.esnext.typedarrays.d.ts +90 -0
  234. package/lib/lib.scripthost.d.ts +320 -0
  235. package/lib/lib.webworker.asynciterable.d.ts +18 -0
  236. package/lib/lib.webworker.d.ts +15606 -0
  237. package/lib/lib.webworker.importscripts.d.ts +21 -0
  238. package/lib/lib.webworker.iterable.d.ts +18 -0
  239. package/lib/logger.js +144 -0
  240. package/lib/package.json +7 -0
  241. package/lib/tsserver.js +57 -0
  242. package/lib/tsserverlibrary.js +171 -0
  243. package/lib/typesMap.json +497 -0
  244. package/lib/typescript.js +373 -0
  245. package/package.json +115 -0
@@ -0,0 +1,384 @@
1
+ /**
2
+ * Parses and formats DI type errors into human-readable messages.
3
+ * Detects errors via branded markers (__brand, _missing, _hint) from MissingDepsError.
4
+ * Error codes: DI1001 missing deps, DI1002 circular, DI1003 unsatisfied constraint.
5
+ */
6
+ import ts from 'typescript';
7
+ /**
8
+ * Custom error codes for dependency injection.
9
+ * Range: DI1000-DI9999
10
+ *
11
+ * These are offset by 200000 to avoid collision with TypeScript codes
12
+ * (100000 range is used by TSP process errors).
13
+ */
14
+ export const DIErrorCode = {
15
+ /**
16
+ * DI1001: Missing dependencies.
17
+ *
18
+ * A component requires dependencies that haven't been added to the builder.
19
+ * Add the missing services/repositories before this component.
20
+ *
21
+ * Example:
22
+ * .add(UserService) // Error: requires ModelRepository<User>
23
+ *
24
+ * Fix:
25
+ * .add(ModelRepository.of(User).bind(PgUser))
26
+ * .add(UserService) // Now works
27
+ */
28
+ MissingDependencies: 1001,
29
+ /**
30
+ * DI1002: Circular dependency detected.
31
+ *
32
+ * Two or more components depend on each other in a cycle.
33
+ * Refactor to break the cycle using interfaces or lazy injection.
34
+ */
35
+ CircularDependency: 1002,
36
+ /**
37
+ * DI1003: Unsatisfied constraint.
38
+ *
39
+ * A type constraint (RequiresSatisfied) was not met.
40
+ */
41
+ UnsatisfiedConstraint: 1003,
42
+ };
43
+ /**
44
+ * Base offset for DI error codes to avoid collision with TS/TSP codes.
45
+ */
46
+ const DI_CODE_OFFSET = 200000;
47
+ /**
48
+ * Format error code for display.
49
+ */
50
+ export function formatDIErrorCode(code) {
51
+ return `DI${code}`;
52
+ }
53
+ /**
54
+ * Check if a diagnostic is a DI-specific error.
55
+ */
56
+ export function isDIDiagnostic(diagnostic) {
57
+ return diagnostic.source === 'justscale-di';
58
+ }
59
+ /**
60
+ * Get the DI error code from a diagnostic.
61
+ */
62
+ export function getDIErrorCode(diagnostic) {
63
+ if (!isDIDiagnostic(diagnostic))
64
+ return null;
65
+ return (diagnostic.code - DI_CODE_OFFSET);
66
+ }
67
+ /**
68
+ * Markers that indicate a DI-related type error.
69
+ * These come from the MissingDepsError interface in builder/types.ts:
70
+ * interface MissingDepsError<_C, TMissing> {
71
+ * readonly __brand: 'MissingDependencies'
72
+ * readonly _missing: TMissing
73
+ * readonly _hint: 'Add the missing dependencies before this component'
74
+ * }
75
+ */
76
+ /**
77
+ * Common token patterns and their human-readable formats.
78
+ */
79
+ const TOKEN_PATTERNS = [
80
+ // ModelRepositoryToken<User, {}> or ModelRepositoryToken<User> -> ModelRepository<User>
81
+ {
82
+ pattern: /^ModelRepositoryToken<([^,<>]+)(?:,\s*\{[^}]*\})?>$/,
83
+ format: (m) => `ModelRepository<${m[1].trim()}>`,
84
+ },
85
+ // RepositoryToken<User> -> Repository<User>
86
+ {
87
+ pattern: /^RepositoryToken<([^<>]+)>$/,
88
+ format: (m) => `Repository<${m[1].trim()}>`,
89
+ },
90
+ // typeof AbstractEmailSender -> AbstractEmailSender
91
+ {
92
+ pattern: /^typeof\s+(\w+)$/,
93
+ format: (m) => m[1],
94
+ },
95
+ // ServiceDef<SomeType, {...}> -> Service creating SomeType
96
+ {
97
+ pattern: /^ServiceDef<([^,<>]+)(?:,\s*\{[^}]*\})?>$/,
98
+ format: (m) => `Service<${m[1].trim()}>`,
99
+ },
100
+ // FeatureToken<[...], [...]> -> Feature (we'll get name from context)
101
+ {
102
+ pattern: /^FeatureToken<\[([^\]]*)\],\s*\[([^\]]*)\]>$/,
103
+ format: () => 'Feature',
104
+ },
105
+ ];
106
+ /**
107
+ * Format a single token type string to a human-readable name.
108
+ */
109
+ export function formatTokenName(typeStr) {
110
+ const trimmed = typeStr.trim();
111
+ // Try each pattern
112
+ for (const { pattern, format } of TOKEN_PATTERNS) {
113
+ const match = trimmed.match(pattern);
114
+ if (match) {
115
+ return format(match);
116
+ }
117
+ }
118
+ // Fallback: clean up common noise
119
+ return trimmed
120
+ .replace(/\s*\{\s*\}/g, '') // Remove empty objects
121
+ .replace(/\s*\[\.\.\.\]/g, '') // Remove [...]
122
+ .replace(/\s+/g, ' '); // Normalize whitespace
123
+ }
124
+ /**
125
+ * Parse a union type string into individual types.
126
+ * Handles nested generics correctly.
127
+ *
128
+ * Example: "A<B> | C | D<E, F>" -> ["A<B>", "C", "D<E, F>"]
129
+ */
130
+ export function parseUnionType(typeStr) {
131
+ const results = [];
132
+ let current = '';
133
+ let depth = 0;
134
+ for (const char of typeStr) {
135
+ if (char === '<' || char === '[' || char === '(') {
136
+ depth++;
137
+ current += char;
138
+ }
139
+ else if (char === '>' || char === ']' || char === ')') {
140
+ depth--;
141
+ current += char;
142
+ }
143
+ else if (char === '|' && depth === 0) {
144
+ const trimmed = current.trim();
145
+ if (trimmed) {
146
+ results.push(trimmed);
147
+ }
148
+ current = '';
149
+ }
150
+ else {
151
+ current += char;
152
+ }
153
+ }
154
+ const trimmed = current.trim();
155
+ if (trimmed) {
156
+ results.push(trimmed);
157
+ }
158
+ return results;
159
+ }
160
+ /**
161
+ * Extract the inner types from a generic type.
162
+ * Example: "MissingDepsError<A, B>" -> ["A", "B"]
163
+ */
164
+ export function extractGenericArgs(typeStr) {
165
+ const start = typeStr.indexOf('<');
166
+ if (start === -1)
167
+ return [];
168
+ // Find matching >
169
+ let depth = 1;
170
+ let end = start + 1;
171
+ for (; end < typeStr.length && depth > 0; end++) {
172
+ if (typeStr[end] === '<')
173
+ depth++;
174
+ else if (typeStr[end] === '>')
175
+ depth--;
176
+ }
177
+ const inner = typeStr.slice(start + 1, end - 1);
178
+ // Split by top-level commas
179
+ const args = [];
180
+ let current = '';
181
+ depth = 0;
182
+ for (const char of inner) {
183
+ if (char === '<' || char === '[' || char === '(') {
184
+ depth++;
185
+ current += char;
186
+ }
187
+ else if (char === '>' || char === ']' || char === ')') {
188
+ depth--;
189
+ current += char;
190
+ }
191
+ else if (char === ',' && depth === 0) {
192
+ args.push(current.trim());
193
+ current = '';
194
+ }
195
+ else {
196
+ current += char;
197
+ }
198
+ }
199
+ if (current.trim()) {
200
+ args.push(current.trim());
201
+ }
202
+ return args;
203
+ }
204
+ /**
205
+ * Check if a type string contains DI error markers.
206
+ * Looks for the branded fields from MissingDepsError:
207
+ * - __brand: 'MissingDependencies'
208
+ * - _missing: <type>
209
+ * - _hint: 'Add the missing dependencies...'
210
+ */
211
+ export function hasDIErrorMarkers(typeStr) {
212
+ // Look for the branded markers
213
+ return (
214
+ // __brand: "MissingDependencies" or __brand: 'MissingDependencies'
215
+ /\b__brand\s*:\s*["']MissingDependencies["']/.test(typeStr) ||
216
+ // _missing: <some type>
217
+ /\b_missing\s*:/.test(typeStr) ||
218
+ // _hint: "Add the missing dependencies..."
219
+ /\b_hint\s*:\s*["']Add the missing dependencies/.test(typeStr) ||
220
+ // The generic type name itself
221
+ typeStr.includes('MissingDepsError'));
222
+ }
223
+ /**
224
+ * Extract the _missing type value from a type string.
225
+ * Looks for patterns like: _missing: TypeA | TypeB
226
+ */
227
+ function extractMissingFromBrandedType(typeStr) {
228
+ // Match _missing: <type> where type ends at ; or }
229
+ const match = typeStr.match(/_missing\s*:\s*([^;}\n]+)/);
230
+ if (match) {
231
+ return match[1].trim();
232
+ }
233
+ return null;
234
+ }
235
+ /**
236
+ * Parse a MissingDepsError type string.
237
+ * Handles both:
238
+ * 1. Generic form: MissingDepsError<Component, Missing>
239
+ * 2. Structural form: { __brand: 'MissingDependencies'; _missing: Type; _hint: ... }
240
+ *
241
+ * @param typeStr The full type string
242
+ * @returns Parsed error info, or null if not a MissingDepsError
243
+ */
244
+ export function parseMissingDepsError(typeStr) {
245
+ // First, check for structural form with _missing field
246
+ const missingFromBranded = extractMissingFromBrandedType(typeStr);
247
+ if (missingFromBranded) {
248
+ const missingDeps = parseUnionType(missingFromBranded);
249
+ return {
250
+ component: null,
251
+ componentName: 'component',
252
+ missingDeps,
253
+ missingDepNames: missingDeps.map(formatTokenName),
254
+ };
255
+ }
256
+ // Try generic form: MissingDepsError<Component, Missing>
257
+ if (!typeStr.includes('MissingDepsError')) {
258
+ return null;
259
+ }
260
+ // Find the MissingDepsError part
261
+ const match = typeStr.match(/MissingDepsError</);
262
+ if (!match)
263
+ return null;
264
+ const startIdx = typeStr.indexOf('MissingDepsError<');
265
+ let depth = 1;
266
+ let endIdx = startIdx + 'MissingDepsError<'.length;
267
+ for (; endIdx < typeStr.length && depth > 0; endIdx++) {
268
+ if (typeStr[endIdx] === '<')
269
+ depth++;
270
+ else if (typeStr[endIdx] === '>')
271
+ depth--;
272
+ }
273
+ const errorPart = typeStr.slice(startIdx, endIdx);
274
+ const args = extractGenericArgs(errorPart);
275
+ if (args.length < 2) {
276
+ return null;
277
+ }
278
+ const [component, missing] = args;
279
+ const missingDeps = parseUnionType(missing);
280
+ return {
281
+ component,
282
+ componentName: formatTokenName(component),
283
+ missingDeps,
284
+ missingDepNames: missingDeps.map(formatTokenName),
285
+ };
286
+ }
287
+ /**
288
+ * Format a parsed DI error into a human-readable message.
289
+ * Includes the DI error code prefix.
290
+ */
291
+ export function formatDIError(parsed, code = DIErrorCode.MissingDependencies) {
292
+ const codePrefix = formatDIErrorCode(code);
293
+ const lines = [];
294
+ lines.push(`${codePrefix}: Missing dependencies for ${parsed.componentName}:`);
295
+ lines.push('');
296
+ for (const depName of parsed.missingDepNames) {
297
+ lines.push(` - ${depName}`);
298
+ }
299
+ lines.push('');
300
+ lines.push('Hint: Add the missing dependencies before this component using .add()');
301
+ lines.push(' For repositories, use ModelRepository.of(Model).bind(StorageModel)');
302
+ return lines.join('\n');
303
+ }
304
+ /**
305
+ * Check if a diagnostic is a DI-related type error.
306
+ * Uses the branded markers (__brand, _missing, _hint) for reliable detection.
307
+ */
308
+ export function isDITypeDiagnostic(diagnostic) {
309
+ const messageText = getDiagnosticMessageText(diagnostic);
310
+ return (
311
+ // Check for branded markers first (most reliable)
312
+ hasDIErrorMarkers(messageText) ||
313
+ // Fallback patterns for edge cases
314
+ messageText.includes('RequiresSatisfied') ||
315
+ (messageText.includes('is not assignable') && messageText.includes('FeatureToken')));
316
+ }
317
+ /**
318
+ * Get the full message text from a diagnostic.
319
+ */
320
+ function getDiagnosticMessageText(diagnostic) {
321
+ if (typeof diagnostic.messageText === 'string') {
322
+ return diagnostic.messageText;
323
+ }
324
+ // DiagnosticMessageChain - flatten it
325
+ return flattenDiagnosticMessageChain(diagnostic.messageText);
326
+ }
327
+ /**
328
+ * Flatten a diagnostic message chain into a single string.
329
+ */
330
+ function flattenDiagnosticMessageChain(chain) {
331
+ let result = chain.messageText;
332
+ if (chain.next) {
333
+ for (const next of chain.next) {
334
+ result += '\n' + flattenDiagnosticMessageChain(next);
335
+ }
336
+ }
337
+ return result;
338
+ }
339
+ /**
340
+ * Try to rewrite a diagnostic with better DI error formatting.
341
+ * Returns null if the diagnostic shouldn't be rewritten.
342
+ */
343
+ export function rewriteDIDiagnostic(diagnostic) {
344
+ if (!isDITypeDiagnostic(diagnostic)) {
345
+ return null;
346
+ }
347
+ const messageText = getDiagnosticMessageText(diagnostic);
348
+ const parsed = parseMissingDepsError(messageText);
349
+ if (!parsed) {
350
+ return null;
351
+ }
352
+ const errorCode = DIErrorCode.MissingDependencies;
353
+ const newMessage = formatDIError(parsed, errorCode);
354
+ return {
355
+ ...diagnostic,
356
+ messageText: newMessage,
357
+ code: DI_CODE_OFFSET + errorCode,
358
+ source: 'justscale-di',
359
+ };
360
+ }
361
+ /**
362
+ * Create a DI diagnostic from scratch.
363
+ */
364
+ export function createDIDiagnostic(code, file, start, length, message) {
365
+ return {
366
+ file,
367
+ start,
368
+ length,
369
+ messageText: `${formatDIErrorCode(code)}: ${message}`,
370
+ category: ts.DiagnosticCategory.Error,
371
+ code: DI_CODE_OFFSET + code,
372
+ source: 'justscale-di',
373
+ };
374
+ }
375
+ /**
376
+ * Process diagnostics and rewrite DI errors with better messages.
377
+ */
378
+ export function processDIDiagnostics(diagnostics) {
379
+ return diagnostics.map((diag) => {
380
+ const rewritten = rewriteDIDiagnostic(diag);
381
+ return rewritten ?? diag;
382
+ });
383
+ }
384
+ //# sourceMappingURL=formatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatter.js","sourceRoot":"","sources":["../../src/di-errors/formatter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB;;;;;;;;;;;;OAYG;IACH,mBAAmB,EAAE,IAAI;IAEzB;;;;;OAKG;IACH,kBAAkB,EAAE,IAAI;IAExB;;;;OAIG;IACH,qBAAqB,EAAE,IAAI;CACnB,CAAC;AAIX;;GAEG;AACH,MAAM,cAAc,GAAG,MAAM,CAAC;AAE9B;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAiB;IACjD,OAAO,KAAK,IAAI,EAAE,CAAC;AACrB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,UAAyB;IACtD,OAAO,UAAU,CAAC,MAAM,KAAK,cAAc,CAAC;AAC9C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,UAAyB;IACtD,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC;QAAE,OAAO,IAAI,CAAC;IAC7C,OAAO,CAAC,UAAU,CAAC,IAAI,GAAG,cAAc,CAAgB,CAAC;AAC3D,CAAC;AAED;;;;;;;;GAQG;AACH;;GAEG;AACH,MAAM,cAAc,G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S,IAAI,IAAI,CAAC;IAC3B,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * DI error codes and diagnostics. See formatter.ts for details.
3
+ */
4
+ export { DIErrorCode, formatDIErrorCode, isDIDiagnostic, getDIErrorCode, createDIDiagnostic, formatTokenName, parseUnionType, extractGenericArgs, hasDIErrorMarkers, parseMissingDepsError, formatDIError, isDITypeDiagnostic, rewriteDIDiagnostic, processDIDiagnostics, type ParsedDIError, } from './formatter.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/di-errors/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAEL,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,kBAAkB,EAElB,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EAErB,aAAa,EAEb,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EAEpB,KAAK,aAAa,GACnB,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * DI error codes and diagnostics. See formatter.ts for details.
3
+ */
4
+ export {
5
+ // Error codes
6
+ DIErrorCode, formatDIErrorCode, isDIDiagnostic, getDIErrorCode, createDIDiagnostic,
7
+ // Parsing utilities
8
+ formatTokenName, parseUnionType, extractGenericArgs, hasDIErrorMarkers, parseMissingDepsError,
9
+ // Formatting
10
+ formatDIError,
11
+ // Diagnostic processing
12
+ isDITypeDiagnostic, rewriteDIDiagnostic, processDIDiagnostics, } from './formatter.js';
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/di-errors/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO;AACL,cAAc;AACd,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,kBAAkB;AAClB,oBAAoB;AACpB,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB;AACrB,aAAa;AACb,aAAa;AACb,wBAAwB;AACxB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,GAGrB,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @justscale/typescript/editor
3
+ *
4
+ * Exports the QuickFixDefinition interface for packages that contribute
5
+ * IDE quick fixes via the "justscale" field in package.json.
6
+ *
7
+ * Usage:
8
+ * import type { QuickFixDefinition } from '@justscale/typescript/editor'
9
+ */
10
+ export type { QuickFixDefinition } from './language-service/quick-fix-discovery.js';
11
+ //# sourceMappingURL=editor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../src/editor.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,YAAY,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC"}
package/dist/editor.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=editor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editor.js","sourceRoot":"","sources":["../src/editor.ts"],"names":[],"mappings":""}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @justscale/typescript
3
+ *
4
+ * Drop-in TypeScript replacement with JustScale process compilation support.
5
+ *
6
+ * Features:
7
+ * - ptsc: Drop-in replacement for tsc with process diagnostics (TSPxxxx)
8
+ * - ptscserver: Drop-in replacement for tsserver with IDE support
9
+ * - LSP plugin: Language service plugin for VS Code and other IDEs
10
+ * - Programmatic API: Transpile processes programmatically
11
+ * - Configuration: Custom tsconfig.json section for JustScale options
12
+ *
13
+ * Quick Start:
14
+ * ```bash
15
+ * # Install
16
+ * npm install @justscale/typescript typescript
17
+ *
18
+ * # Use ptsc instead of tsc
19
+ * npx ptsc
20
+ *
21
+ * # Or configure VS Code
22
+ * # Add to settings.json:
23
+ * # "typescript.tsdk": "node_modules/@justscale/typescript/lib"
24
+ * ```
25
+ *
26
+ * @packageDocumentation
27
+ */
28
+ export { createProcessTransformer, compileProcessSource, compileProcessFile, formatDiagnostics, analyzeHandler, ProcessErrorCode, createProcessDiagnostic, formatErrorCode, isProcessDiagnostic, getProcessErrorCode, DiagnosticCollector, cli, detectChanges, mightContainServices, } from './compiler/index.js';
29
+ export type { ServiceChange, ChangeDetectionResult, } from './compiler/hmr-change-detector.js';
30
+ export type { ProcessCompilerOptions, CompileResult, AnalysisResult, BlockDefinition, SignalInfo, VariableInfo, } from './compiler/index.js';
31
+ export { parseConfig, findConfig, isProcessFile, defaultConfig, mergeConfig, } from './config/index.js';
32
+ export type { JustScaleConfig, ParsedConfig, PluginConfig, } from './config/index.js';
33
+ export { transpile, transpileProject, createProgram, getProcessDiagnostics, } from './api.js';
34
+ export type { TranspileResult, TranspileProjectResult, TranspileOptions, } from './api.js';
35
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGH,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,uBAAuB,EACvB,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,GAAG,EAGH,aAAa,EACb,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAE7B,YAAY,EACV,aAAa,EACb,qBAAqB,GACtB,MAAM,mCAAmC,CAAC;AAE3C,YAAY,EACV,sBAAsB,EACtB,aAAa,EACb,cAAc,EACd,eAAe,EACf,UAAU,EACV,YAAY,GACb,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,WAAW,EACX,UAAU,EACV,aAAa,EACb,aAAa,EACb,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EACV,eAAe,EACf,YAAY,EACZ,YAAY,GACb,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,qBAAqB,GACtB,MAAM,UAAU,CAAC;AAElB,YAAY,EACV,eAAe,EACf,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,UAAU,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @justscale/typescript
3
+ *
4
+ * Drop-in TypeScript replacement with JustScale process compilation support.
5
+ *
6
+ * Features:
7
+ * - ptsc: Drop-in replacement for tsc with process diagnostics (TSPxxxx)
8
+ * - ptscserver: Drop-in replacement for tsserver with IDE support
9
+ * - LSP plugin: Language service plugin for VS Code and other IDEs
10
+ * - Programmatic API: Transpile processes programmatically
11
+ * - Configuration: Custom tsconfig.json section for JustScale options
12
+ *
13
+ * Quick Start:
14
+ * ```bash
15
+ * # Install
16
+ * npm install @justscale/typescript typescript
17
+ *
18
+ * # Use ptsc instead of tsc
19
+ * npx ptsc
20
+ *
21
+ * # Or configure VS Code
22
+ * # Add to settings.json:
23
+ * # "typescript.tsdk": "node_modules/@justscale/typescript/lib"
24
+ * ```
25
+ *
26
+ * @packageDocumentation
27
+ */
28
+ // Re-export compiler functionality
29
+ export { createProcessTransformer, compileProcessSource, compileProcessFile, formatDiagnostics, analyzeHandler, ProcessErrorCode, createProcessDiagnostic, formatErrorCode, isProcessDiagnostic, getProcessErrorCode, DiagnosticCollector, cli,
30
+ // HMR change detection (pure library fn, consumed by @justscale/core
31
+ // /hmr-watcher in dev mode to pick method-patch vs full-reload).
32
+ detectChanges, mightContainServices, } from './compiler/index.js';
33
+ // Re-export configuration
34
+ export { parseConfig, findConfig, isProcessFile, defaultConfig, mergeConfig, } from './config/index.js';
35
+ // Re-export programmatic API
36
+ export { transpile, transpileProject, createProgram, getProcessDiagnostics, } from './api.js';
37
+ // Protobuf and Cap'n Proto integrations are not shipped in 0.x.
38
+ // They live in private compiler plugins and will graduate to a separate
39
+ // `@justscale/format-*` family once the plugin contract stabilises.
40
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,mCAAmC;AACnC,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,uBAAuB,EACvB,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,GAAG;AACH,qEAAqE;AACrE,iEAAiE;AACjE,aAAa,EACb,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAgB7B,0BAA0B;AAC1B,OAAO,EACL,WAAW,EACX,UAAU,EACV,aAAa,EACb,aAAa,EACb,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAQ3B,6BAA6B;AAC7B,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,qBAAqB,GACtB,MAAM,UAAU,CAAC;AAQlB,gEAAgE;AAChE,wEAAwE;AACxE,oEAAoE"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * TypeScript Language Service Plugin for @justscale/typescript
3
+ *
4
+ * Provides enhanced IDE support:
5
+ * - TSPxxxx diagnostics for JustScale processes
6
+ * - Proto and Cap'n Proto schema integration (.proto, .capnp files)
7
+ * - Human-readable DI error messages
8
+ *
9
+ * Based on TypeScriptToLua's plugin pattern.
10
+ *
11
+ * Usage in tsconfig.json:
12
+ * {
13
+ * "compilerOptions": {
14
+ * "plugins": [{ "name": "@justscale/typescript/language-service" }]
15
+ * }
16
+ * }
17
+ */
18
+ import type ts from 'typescript';
19
+ import '../plugins/index.js';
20
+ type TS = typeof ts;
21
+ type LanguageService = ts.LanguageService;
22
+ interface ServerHost {
23
+ readFile(path: string, encoding?: string): string | undefined;
24
+ }
25
+ interface Project {
26
+ log(message: string): void;
27
+ getProjectName(): string;
28
+ }
29
+ interface LanguageServiceHost {
30
+ getScriptSnapshot(fileName: string): ts.IScriptSnapshot | undefined;
31
+ getScriptVersion(fileName: string): string;
32
+ }
33
+ interface PluginCreateInfo {
34
+ languageService: LanguageService;
35
+ languageServiceHost: LanguageServiceHost;
36
+ project: Project;
37
+ serverHost: ServerHost;
38
+ }
39
+ interface PluginModule {
40
+ create(info: PluginCreateInfo): LanguageService;
41
+ }
42
+ interface PluginModuleFactory {
43
+ (mod: {
44
+ typescript: TS;
45
+ }): PluginModule;
46
+ }
47
+ /**
48
+ * Plugin factory - entry point for TypeScript Language Service.
49
+ */
50
+ declare const init: PluginModuleFactory;
51
+ export default init;
52
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/language-service/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,qBAAqB,CAAC;AAW7B,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC;AACpB,KAAK,eAAe,GAAG,EAAE,CAAC,eAAe,CAAC;AAU1C,UAAU,UAAU;IAClB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;CAC9D;AAED,UAAU,OAAO;IACf,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,cAAc,IAAI,MAAM,CAAA;CACzB;AA+WD,UAAU,mBAAmB;IAC3B,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,EAAE,CAAC,eAAe,GAAG,SAAS,CAAA;IACnE,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAA;CAC3C;AAED,UAAU,gBAAgB;IACxB,eAAe,EAAE,eAAe,CAAA;IAChC,mBAAmB,EAAE,mBAAmB,CAAA;IACxC,OAAO,EAAE,OAAO,CAAA;IAChB,UAAU,EAAE,UAAU,CAAA;CACvB;AAED,UAAU,YAAY;IACpB,MAAM,CAAC,IAAI,EAAE,gBAAgB,GAAG,eAAe,CAAA;CAChD;AAED,UAAU,mBAAmB;IAC3B,CAAC,GAAG,EAAE;QAAE,UAAU,EAAE,EAAE,CAAA;KAAE,GAAG,YAAY,CAAA;CACxC;AAeD;;GAEG;AACH,QAAA,MAAM,IAAI,EAAE,mBAaX,CAAC;AAGF,eAAe,IAAI,CAGlB"}