@rs-x/compiler 2.0.0-next.0

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/dist/index.js ADDED
@@ -0,0 +1,2272 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // lib/compiler/expression-aot-generator.ts
5
+ import { CompiledExpressionCompiler, JsExpressionAstParser } from "@rs-x/expression-parser";
6
+
7
+ // lib/compiler/expression-site-detector.ts
8
+ import ts from "typescript";
9
+ function detectExpressionSites(program) {
10
+ const checker = program.getTypeChecker();
11
+ const detections = [];
12
+ for (const sourceFile of program.getSourceFiles()) {
13
+ if (sourceFile.isDeclarationFile) {
14
+ continue;
15
+ }
16
+ detections.push(...detectExpressionSitesInSourceFile(sourceFile, checker));
17
+ }
18
+ return detections;
19
+ }
20
+ __name(detectExpressionSites, "detectExpressionSites");
21
+ function detectExpressionSitesInSourceFile(sourceFile, checker) {
22
+ const detections = [];
23
+ const visit = /* @__PURE__ */ __name((node) => {
24
+ if (ts.isCallExpression(node)) {
25
+ const rsxDetection = tryDetectRsxEntryPoint(node, checker);
26
+ if (rsxDetection) {
27
+ detections.push(rsxDetection);
28
+ }
29
+ const factoryDetection = tryDetectFactoryEntryPoint(node, checker);
30
+ if (factoryDetection) {
31
+ detections.push(factoryDetection);
32
+ }
33
+ }
34
+ ts.forEachChild(node, visit);
35
+ }, "visit");
36
+ visit(sourceFile);
37
+ return detections;
38
+ }
39
+ __name(detectExpressionSitesInSourceFile, "detectExpressionSitesInSourceFile");
40
+ function tryDetectRsxEntryPoint(callExpression, checker) {
41
+ if (!ts.isCallExpression(callExpression.expression)) {
42
+ return null;
43
+ }
44
+ const rsxInvocation = callExpression.expression;
45
+ if (rsxInvocation.arguments.length < 1 || rsxInvocation.arguments.length > 2) {
46
+ return null;
47
+ }
48
+ const expressionLiteral = resolveStaticExpressionLiteral(rsxInvocation.arguments[0]);
49
+ if (!expressionLiteral) {
50
+ return null;
51
+ }
52
+ if (!isRsxCallee(rsxInvocation.expression, checker)) {
53
+ return null;
54
+ }
55
+ const rsxOptions = resolveRsxOptions(rsxInvocation.arguments[1]);
56
+ return {
57
+ kind: "rsx",
58
+ expression: expressionLiteral.text,
59
+ preparse: rsxOptions.preparse,
60
+ lazy: rsxOptions.lazy,
61
+ compiled: rsxOptions.compiled,
62
+ expressionLiteral,
63
+ callExpression,
64
+ sourceFile: callExpression.getSourceFile()
65
+ };
66
+ }
67
+ __name(tryDetectRsxEntryPoint, "tryDetectRsxEntryPoint");
68
+ function isRsxCallee(expression, checker) {
69
+ const symbol = checker.getSymbolAtLocation(expression);
70
+ if (!symbol) {
71
+ return false;
72
+ }
73
+ if (isAliasImportedFromExpressionParser(symbol, checker)) {
74
+ return true;
75
+ }
76
+ const resolvedSymbol = symbol.flags & ts.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
77
+ if (resolvedSymbol.getName() !== "rsx") {
78
+ return false;
79
+ }
80
+ const declarations = resolvedSymbol.declarations ?? [];
81
+ return declarations.some((declaration) => {
82
+ const sourcePath = declaration.getSourceFile().fileName.replace(/\\/gu, "/");
83
+ return sourcePath.includes("/rs-x-expression-parser/") || sourcePath.includes("/@rs-x/expression-parser/");
84
+ });
85
+ }
86
+ __name(isRsxCallee, "isRsxCallee");
87
+ function isAliasImportedFromExpressionParser(symbol, checker, seenSymbols = /* @__PURE__ */ new Set()) {
88
+ if (seenSymbols.has(symbol)) {
89
+ return false;
90
+ }
91
+ seenSymbols.add(symbol);
92
+ if ((symbol.flags & ts.SymbolFlags.Alias) === 0) {
93
+ const declarations2 = symbol.declarations ?? [];
94
+ for (const declaration of declarations2) {
95
+ if (!ts.isVariableDeclaration(declaration) || !declaration.initializer) {
96
+ continue;
97
+ }
98
+ const initializerSymbol = checker.getSymbolAtLocation(declaration.initializer);
99
+ if (initializerSymbol && isAliasImportedFromExpressionParser(initializerSymbol, checker, seenSymbols)) {
100
+ return true;
101
+ }
102
+ }
103
+ return false;
104
+ }
105
+ const declarations = symbol.declarations ?? [];
106
+ return declarations.some((declaration) => {
107
+ if (!ts.isImportSpecifier(declaration)) {
108
+ return false;
109
+ }
110
+ let current = declaration;
111
+ while (current && !ts.isImportDeclaration(current)) {
112
+ current = current.parent;
113
+ }
114
+ if (!current) {
115
+ return false;
116
+ }
117
+ const moduleSpecifier = current.moduleSpecifier;
118
+ if (!ts.isStringLiteral(moduleSpecifier)) {
119
+ return false;
120
+ }
121
+ return moduleSpecifier.text === "@rs-x/expression-parser";
122
+ });
123
+ }
124
+ __name(isAliasImportedFromExpressionParser, "isAliasImportedFromExpressionParser");
125
+ function tryDetectFactoryEntryPoint(callExpression, checker) {
126
+ if (!ts.isPropertyAccessExpression(callExpression.expression)) {
127
+ return null;
128
+ }
129
+ if (callExpression.expression.name.text !== "create") {
130
+ return null;
131
+ }
132
+ if (callExpression.arguments.length < 2) {
133
+ return null;
134
+ }
135
+ const expressionLiteral = resolveStaticExpressionLiteral(callExpression.arguments[1]);
136
+ if (!expressionLiteral) {
137
+ return null;
138
+ }
139
+ const factoryType = checker.getTypeAtLocation(callExpression.expression.expression);
140
+ if (!isExpressionFactoryType(factoryType, checker, /* @__PURE__ */ new Set())) {
141
+ return null;
142
+ }
143
+ return {
144
+ kind: "factory-create",
145
+ expression: expressionLiteral.text,
146
+ preparse: true,
147
+ lazy: false,
148
+ compiled: true,
149
+ expressionLiteral,
150
+ callExpression,
151
+ sourceFile: callExpression.getSourceFile()
152
+ };
153
+ }
154
+ __name(tryDetectFactoryEntryPoint, "tryDetectFactoryEntryPoint");
155
+ function resolveRsxOptions(optionArgument) {
156
+ let preparse = true;
157
+ let lazy = false;
158
+ let compiled = true;
159
+ if (!optionArgument || !ts.isObjectLiteralExpression(optionArgument)) {
160
+ return {
161
+ preparse,
162
+ lazy,
163
+ compiled
164
+ };
165
+ }
166
+ for (let i = 0; i < optionArgument.properties.length; i += 1) {
167
+ const property = optionArgument.properties[i];
168
+ if (!ts.isPropertyAssignment(property)) {
169
+ continue;
170
+ }
171
+ if (isPropertyName(property.name, "preparse")) {
172
+ if (property.initializer.kind === ts.SyntaxKind.FalseKeyword) {
173
+ preparse = false;
174
+ }
175
+ if (property.initializer.kind === ts.SyntaxKind.TrueKeyword) {
176
+ preparse = true;
177
+ }
178
+ continue;
179
+ }
180
+ if (isPropertyName(property.name, "lazy")) {
181
+ if (property.initializer.kind === ts.SyntaxKind.TrueKeyword) {
182
+ lazy = true;
183
+ }
184
+ if (property.initializer.kind === ts.SyntaxKind.FalseKeyword) {
185
+ lazy = false;
186
+ }
187
+ continue;
188
+ }
189
+ if (isPropertyName(property.name, "compiled")) {
190
+ if (property.initializer.kind === ts.SyntaxKind.TrueKeyword) {
191
+ compiled = true;
192
+ }
193
+ if (property.initializer.kind === ts.SyntaxKind.FalseKeyword) {
194
+ compiled = false;
195
+ }
196
+ }
197
+ }
198
+ return {
199
+ preparse,
200
+ lazy,
201
+ compiled
202
+ };
203
+ }
204
+ __name(resolveRsxOptions, "resolveRsxOptions");
205
+ function isPropertyName(propertyName, expectedName) {
206
+ if (ts.isIdentifier(propertyName)) {
207
+ return propertyName.text === expectedName;
208
+ }
209
+ if (ts.isStringLiteral(propertyName)) {
210
+ return propertyName.text === expectedName;
211
+ }
212
+ return false;
213
+ }
214
+ __name(isPropertyName, "isPropertyName");
215
+ function resolveStaticExpressionLiteral(node) {
216
+ if (ts.isStringLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node)) {
217
+ return node;
218
+ }
219
+ return null;
220
+ }
221
+ __name(resolveStaticExpressionLiteral, "resolveStaticExpressionLiteral");
222
+ function isExpressionFactoryType(type, checker, seenTypes) {
223
+ if (seenTypes.has(type)) {
224
+ return false;
225
+ }
226
+ seenTypes.add(type);
227
+ const symbolName = type.getSymbol()?.getName();
228
+ if (symbolName === "IExpressionFactory") {
229
+ return true;
230
+ }
231
+ if (type.isUnionOrIntersection()) {
232
+ return type.types.some((unionType) => isExpressionFactoryType(unionType, checker, seenTypes));
233
+ }
234
+ if (isExpressionFactoryByCreateSignature(type, checker)) {
235
+ return true;
236
+ }
237
+ const baseTypes = getBaseTypes(type);
238
+ return baseTypes.some((baseType) => isExpressionFactoryType(baseType, checker, seenTypes));
239
+ }
240
+ __name(isExpressionFactoryType, "isExpressionFactoryType");
241
+ function getBaseTypes(type) {
242
+ if (!("getBaseTypes" in type)) {
243
+ return [];
244
+ }
245
+ const baseTypes = type.getBaseTypes?.();
246
+ return baseTypes ?? [];
247
+ }
248
+ __name(getBaseTypes, "getBaseTypes");
249
+ function isExpressionFactoryByCreateSignature(type, checker) {
250
+ const createProperty = type.getProperty("create");
251
+ if (!createProperty) {
252
+ return false;
253
+ }
254
+ const declaration = createProperty.valueDeclaration ?? createProperty.declarations?.[0];
255
+ if (!declaration) {
256
+ return false;
257
+ }
258
+ const createType = checker.getTypeOfSymbolAtLocation(createProperty, declaration);
259
+ const signatures = createType.getCallSignatures();
260
+ if (signatures.length === 0) {
261
+ return false;
262
+ }
263
+ return signatures.some((signature) => {
264
+ const secondParameter = signature.parameters[1];
265
+ if (!secondParameter) {
266
+ return false;
267
+ }
268
+ const parameterDeclaration = secondParameter.valueDeclaration ?? secondParameter.declarations?.[0];
269
+ if (!parameterDeclaration) {
270
+ return false;
271
+ }
272
+ const secondParameterType = checker.getTypeOfSymbolAtLocation(secondParameter, parameterDeclaration);
273
+ const secondParameterIsString = (secondParameterType.flags & ts.TypeFlags.StringLike) !== 0;
274
+ if (!secondParameterIsString) {
275
+ return false;
276
+ }
277
+ const returnType = signature.getReturnType();
278
+ return isExpressionLikeReturnType(returnType);
279
+ });
280
+ }
281
+ __name(isExpressionFactoryByCreateSignature, "isExpressionFactoryByCreateSignature");
282
+ function isExpressionLikeReturnType(type) {
283
+ const hasExpressionString = Boolean(type.getProperty("expressionString"));
284
+ const hasType = Boolean(type.getProperty("type"));
285
+ return hasExpressionString && hasType;
286
+ }
287
+ __name(isExpressionLikeReturnType, "isExpressionLikeReturnType");
288
+
289
+ // lib/compiler/expression-aot-generator.ts
290
+ function generateAotCompiledExpressionsModule(program, options = {}) {
291
+ const includeResolvedEvaluator = options.includeResolvedEvaluator === true;
292
+ const detections = detectExpressionSites(program);
293
+ const uniqueExpressions = [
294
+ ...new Set(detections.filter((detection) => detection.preparse && !detection.lazy && detection.compiled).map((detection) => detection.expression))
295
+ ];
296
+ uniqueExpressions.sort();
297
+ const compiler = new CompiledExpressionCompiler(new JsExpressionAstParser());
298
+ const compiledPlans = [];
299
+ const skippedExpressions = [];
300
+ for (let i = 0; i < uniqueExpressions.length; i++) {
301
+ const expression = uniqueExpressions[i];
302
+ const plan = compiler.tryCompile(expression);
303
+ if (!plan) {
304
+ skippedExpressions.push(expression);
305
+ continue;
306
+ }
307
+ compiledPlans.push({
308
+ expression,
309
+ plan
310
+ });
311
+ }
312
+ const compactEntries = compiledPlans.map(({ plan }) => serializeCompactPlanEntry(plan, {
313
+ includeResolvedEvaluator
314
+ })).join(",\n");
315
+ const code = [
316
+ "import { registerCompiledExpressionPlansInExpressionCache } from '@rs-x/expression-parser';",
317
+ "",
318
+ "const compactPlans = [",
319
+ compactEntries,
320
+ "];",
321
+ "",
322
+ "function deserializeMemberChain(memberChain) {",
323
+ " if (!memberChain) return undefined;",
324
+ " const segments = new Array(memberChain[1].length);",
325
+ " for (let i = 0; i < memberChain[1].length; i += 1) {",
326
+ " const segment = memberChain[1][i];",
327
+ ' if (segment[0] === "s") {',
328
+ ' segments[i] = { kind: "static", key: segment[1] };',
329
+ " continue;",
330
+ " }",
331
+ " segments[i] = {",
332
+ ' kind: "computed",',
333
+ " key: undefined,",
334
+ " expressionString: segment[1],",
335
+ " dependencyNames: segment[2],",
336
+ " evaluateIndex: segment[3],",
337
+ " evaluateIndexByOwnDependencies: segment[4],",
338
+ " };",
339
+ " }",
340
+ " return { rootIdentifier: memberChain[0], segments };",
341
+ "}",
342
+ "",
343
+ "function deserializeSequenceOperands(sequenceOperands) {",
344
+ " if (!sequenceOperands) return undefined;",
345
+ " const operands = new Array(sequenceOperands.length);",
346
+ " for (let i = 0; i < sequenceOperands.length; i += 1) {",
347
+ " const operand = sequenceOperands[i];",
348
+ " operands[i] = {",
349
+ " expressionString: operand[0],",
350
+ " dependencyNames: operand[1],",
351
+ " evaluate: operand[2],",
352
+ " };",
353
+ " }",
354
+ " return operands;",
355
+ "}",
356
+ "",
357
+ "function expandCompiledPlans(compact, includeResolvedEvaluator) {",
358
+ " const expanded = {};",
359
+ " for (let i = 0; i < compact.length; i += 1) {",
360
+ " const entry = compact[i];",
361
+ " const expressionString = entry[0];",
362
+ " const watchDependenciesCompact = entry[2];",
363
+ " const watchDependencies = new Array(watchDependenciesCompact.length);",
364
+ " for (let j = 0; j < watchDependenciesCompact.length; j += 1) {",
365
+ " const watchDependency = watchDependenciesCompact[j];",
366
+ " watchDependencies[j] = {",
367
+ " name: watchDependency[0],",
368
+ " ownerPath: watchDependency[1],",
369
+ " isLeaf: watchDependency[2],",
370
+ " isMemberExpressionSegment: watchDependency[3],",
371
+ " };",
372
+ " }",
373
+ " const expandedPlan = {",
374
+ " expressionString,",
375
+ " dependencyNames: entry[1],",
376
+ " watchDependencies,",
377
+ " expressionType: entry[3],",
378
+ " hasHiddenArgumentArray: entry[4],",
379
+ " memberChain: deserializeMemberChain(entry[5]),",
380
+ " sequenceOperands: deserializeSequenceOperands(entry[6]),",
381
+ " evaluate: entry[7],",
382
+ " };",
383
+ " if (includeResolvedEvaluator && entry[8]) {",
384
+ " expandedPlan.evaluateResolvedDependencies = entry[8];",
385
+ " }",
386
+ " expanded[expressionString] = expandedPlan;",
387
+ " }",
388
+ " return expanded;",
389
+ "}",
390
+ "",
391
+ "export function registerRsxAotCompiledExpressions(): void {",
392
+ ` registerCompiledExpressionPlansInExpressionCache(expandCompiledPlans(compactPlans, ${String(includeResolvedEvaluator)}));`,
393
+ "}",
394
+ ""
395
+ ].join("\n");
396
+ return {
397
+ code,
398
+ expressions: compiledPlans.map((item) => item.expression),
399
+ skippedExpressions
400
+ };
401
+ }
402
+ __name(generateAotCompiledExpressionsModule, "generateAotCompiledExpressionsModule");
403
+ function generateAotParsedExpressionCacheModule(program) {
404
+ const detections = detectExpressionSites(program);
405
+ const uniqueExpressions = [
406
+ ...new Set(detections.filter((detection) => detection.preparse && !detection.lazy).map((detection) => detection.expression))
407
+ ];
408
+ uniqueExpressions.sort();
409
+ const parser2 = new JsExpressionAstParser();
410
+ const parsedExpressions = [];
411
+ const skippedExpressions = [];
412
+ for (let i = 0; i < uniqueExpressions.length; i++) {
413
+ const expression = uniqueExpressions[i];
414
+ try {
415
+ const expressionAst = parser2.parse(expression);
416
+ parsedExpressions.push({
417
+ expression,
418
+ expressionAst
419
+ });
420
+ } catch {
421
+ skippedExpressions.push(expression);
422
+ }
423
+ }
424
+ const astObject = parsedExpressions.map(({ expression, expressionAst }) => `${JSON.stringify(expression)}: ${JSON.stringify(expressionAst)}`).join(",\n");
425
+ const code = [
426
+ "import {",
427
+ " registerPreparsedExpressionAsts,",
428
+ "} from '@rs-x/expression-parser';",
429
+ "",
430
+ "const preparsedExpressionAsts: Record<string, unknown> = {",
431
+ astObject,
432
+ "};",
433
+ "",
434
+ "export function registerRsxAotParsedExpressionCache(): void {",
435
+ " registerPreparsedExpressionAsts(preparsedExpressionAsts as any);",
436
+ "}",
437
+ ""
438
+ ].join("\n");
439
+ return {
440
+ code,
441
+ expressions: parsedExpressions.map((item) => item.expression),
442
+ skippedExpressions
443
+ };
444
+ }
445
+ __name(generateAotParsedExpressionCacheModule, "generateAotParsedExpressionCacheModule");
446
+ function generateAotLazyExpressionPreloadManifestModule(program) {
447
+ const detections = detectExpressionSites(program);
448
+ const uniqueExpressions = [
449
+ ...new Set(detections.filter((detection) => detection.preparse && detection.lazy).map((detection) => detection.expression))
450
+ ];
451
+ uniqueExpressions.sort();
452
+ const manifestObject = uniqueExpressions.map((expression) => `${JSON.stringify(expression)}: true`).join(",\n");
453
+ const code = [
454
+ "import { registerLazyExpressionPreloader } from '@rs-x/expression-parser';",
455
+ "",
456
+ `export const rsxAotLazyExpressionManifest: Record<string, true> = {${manifestObject ? `
457
+ ${manifestObject}
458
+ ` : ""}};`,
459
+ "",
460
+ "export function registerRsxAotLazyExpressionPreloaders(",
461
+ " loadExpressionByString: (expressionString: string) => void | Promise<void>,",
462
+ "): void {",
463
+ " for (const expressionString of Object.keys(rsxAotLazyExpressionManifest)) {",
464
+ " registerLazyExpressionPreloader(expressionString, () =>",
465
+ " loadExpressionByString(expressionString),",
466
+ " );",
467
+ " }",
468
+ "}",
469
+ ""
470
+ ].join("\n");
471
+ return {
472
+ code,
473
+ expressions: uniqueExpressions
474
+ };
475
+ }
476
+ __name(generateAotLazyExpressionPreloadManifestModule, "generateAotLazyExpressionPreloadManifestModule");
477
+ function serializeCompactPlanEntry(plan, options) {
478
+ return `[${[
479
+ JSON.stringify(plan.expressionString),
480
+ serializeStringArray(plan.dependencyNames),
481
+ serializeCompactWatchDependencies(plan.watchDependencies),
482
+ JSON.stringify(plan.expressionType),
483
+ String(plan.hasHiddenArgumentArray),
484
+ serializeCompactMemberChain(plan.memberChain),
485
+ serializeCompactSequenceOperands(plan.sequenceOperands),
486
+ serializeFunction(plan.evaluate),
487
+ options.includeResolvedEvaluator && plan.evaluateResolvedDependencies ? serializeFunction(plan.evaluateResolvedDependencies) : "undefined"
488
+ ].join(",")}]`;
489
+ }
490
+ __name(serializeCompactPlanEntry, "serializeCompactPlanEntry");
491
+ function serializeCompactWatchDependencies(dependencies) {
492
+ return `[${dependencies.map((dependency) => `[${JSON.stringify(dependency.name)},${serializeStringArray(dependency.ownerPath)},${String(dependency.isLeaf)},${String(dependency.isMemberExpressionSegment)}]`).join(",")}]`;
493
+ }
494
+ __name(serializeCompactWatchDependencies, "serializeCompactWatchDependencies");
495
+ function serializeCompactMemberChain(plan) {
496
+ if (!plan) {
497
+ return "null";
498
+ }
499
+ return `[${JSON.stringify(plan.rootIdentifier)},[${plan.segments.map((segment) => serializeCompactMemberSegment(segment)).join(",")}]]`;
500
+ }
501
+ __name(serializeCompactMemberChain, "serializeCompactMemberChain");
502
+ function serializeCompactMemberSegment(segment) {
503
+ if (segment.kind === "static") {
504
+ return `["s",${JSON.stringify(segment.key)}]`;
505
+ }
506
+ return `["c",${JSON.stringify(segment.expressionString)},${serializeStringArray(segment.dependencyNames ?? [])},${segment.evaluateIndex ? serializeFunction(segment.evaluateIndex) : "undefined"},${segment.evaluateIndexByOwnDependencies ? serializeFunction(segment.evaluateIndexByOwnDependencies) : "undefined"}]`;
507
+ }
508
+ __name(serializeCompactMemberSegment, "serializeCompactMemberSegment");
509
+ function serializeCompactSequenceOperands(operands) {
510
+ if (!operands || operands.length === 0) {
511
+ return "null";
512
+ }
513
+ return `[${operands.map((operand) => `[${JSON.stringify(operand.expressionString)},${serializeStringArray(operand.dependencyNames)},${serializeFunction(operand.evaluate)}]`).join(",")}]`;
514
+ }
515
+ __name(serializeCompactSequenceOperands, "serializeCompactSequenceOperands");
516
+ function serializeStringArray(values) {
517
+ return `[${values.map((value) => JSON.stringify(value)).join(",")}]`;
518
+ }
519
+ __name(serializeStringArray, "serializeStringArray");
520
+ function serializeFunction(fn) {
521
+ return `(${fn.toString()})`;
522
+ }
523
+ __name(serializeFunction, "serializeFunction");
524
+
525
+ // lib/compiler/expression-site-validator.ts
526
+ import ts2 from "typescript";
527
+ import { ExpressionType, GlobalIdentifierOwnerResolver, JsEspreeExpressionParser, JsExpressionAstParser as JsExpressionAstParser3 } from "@rs-x/expression-parser";
528
+
529
+ // lib/diagnostics/expression-diagnostics.ts
530
+ import { JsExpressionAstParser as JsExpressionAstParser2, JsExpressionParser } from "@rs-x/expression-parser";
531
+ var parser = new JsExpressionParser(new JsExpressionAstParser2());
532
+ var trailingOperators = [
533
+ "instanceof",
534
+ ">>>",
535
+ ">>",
536
+ "<<",
537
+ "===",
538
+ "!==",
539
+ "==",
540
+ "!=",
541
+ ">=",
542
+ "<=",
543
+ "&&",
544
+ "||",
545
+ "??",
546
+ "**",
547
+ "+",
548
+ "-",
549
+ "*",
550
+ "/",
551
+ "%",
552
+ "&",
553
+ "|",
554
+ "^",
555
+ ">",
556
+ "<",
557
+ "in",
558
+ "?"
559
+ ];
560
+ function parseExpressionDiagnostic(expression) {
561
+ try {
562
+ parser.parse(expression);
563
+ return null;
564
+ } catch (error) {
565
+ const message = error instanceof Error ? error.message : "Unknown parser error";
566
+ return classifyParserError(expression, message);
567
+ }
568
+ }
569
+ __name(parseExpressionDiagnostic, "parseExpressionDiagnostic");
570
+ function classifyParserError(expression, parserMessage) {
571
+ const normalizedExpression = expression.trim();
572
+ if (isUnsupportedMessage(parserMessage)) {
573
+ return {
574
+ category: "unsupported",
575
+ message: extractUnsupportedMessage(parserMessage)
576
+ };
577
+ }
578
+ const missingOperand = tryCreateMissingOperandMessage(normalizedExpression);
579
+ if (missingOperand) {
580
+ return {
581
+ category: "syntax",
582
+ message: missingOperand
583
+ };
584
+ }
585
+ const unterminatedLiteral = tryCreateUnterminatedLiteralMessage(normalizedExpression);
586
+ if (unterminatedLiteral) {
587
+ return {
588
+ category: "syntax",
589
+ message: unterminatedLiteral
590
+ };
591
+ }
592
+ const missingRightOperand = tryCreateMissingRightOperandMessage(normalizedExpression);
593
+ if (missingRightOperand) {
594
+ return {
595
+ category: "syntax",
596
+ message: missingRightOperand
597
+ };
598
+ }
599
+ const unclosedToken = tryCreateUnclosedTokenMessage(normalizedExpression, parserMessage);
600
+ if (unclosedToken) {
601
+ return {
602
+ category: "syntax",
603
+ message: unclosedToken
604
+ };
605
+ }
606
+ return {
607
+ category: "syntax",
608
+ message: `Syntax error in expression '${normalizedExpression}'.`
609
+ };
610
+ }
611
+ __name(classifyParserError, "classifyParserError");
612
+ function isUnsupportedMessage(message) {
613
+ return message.includes("not supported") || message.includes("Unsupported expression type") || message.includes("Unsupported");
614
+ }
615
+ __name(isUnsupportedMessage, "isUnsupportedMessage");
616
+ function sanitizeParserMessage(message) {
617
+ return message.replace(/^Line \d+:\s*/u, "").trim();
618
+ }
619
+ __name(sanitizeParserMessage, "sanitizeParserMessage");
620
+ function tryCreateMissingRightOperandMessage(normalizedExpression) {
621
+ for (const operator of trailingOperators) {
622
+ if (endsWithOperator(normalizedExpression, operator)) {
623
+ return `Missing right operand for '${normalizedExpression}'.`;
624
+ }
625
+ }
626
+ if (normalizedExpression.endsWith(":")) {
627
+ return `Missing right operand for '${normalizedExpression}'.`;
628
+ }
629
+ return null;
630
+ }
631
+ __name(tryCreateMissingRightOperandMessage, "tryCreateMissingRightOperandMessage");
632
+ function tryCreateMissingOperandMessage(normalizedExpression) {
633
+ if (normalizedExpression === "!" || normalizedExpression === "~" || normalizedExpression === "+" || normalizedExpression === "-" || normalizedExpression === "typeof" || normalizedExpression === "new") {
634
+ return `Missing operand for '${normalizedExpression}'.`;
635
+ }
636
+ return null;
637
+ }
638
+ __name(tryCreateMissingOperandMessage, "tryCreateMissingOperandMessage");
639
+ function tryCreateUnterminatedLiteralMessage(normalizedExpression) {
640
+ if (hasUnterminatedQuotedLiteral(normalizedExpression, '"')) {
641
+ return `Unterminated string literal in '${normalizedExpression}'.`;
642
+ }
643
+ if (hasUnterminatedQuotedLiteral(normalizedExpression, "'")) {
644
+ return `Unterminated string literal in '${normalizedExpression}'.`;
645
+ }
646
+ if (normalizedExpression.startsWith("`") && !normalizedExpression.endsWith("`")) {
647
+ return `Unterminated template literal in '${normalizedExpression}'.`;
648
+ }
649
+ if (normalizedExpression.startsWith("/") && normalizedExpression.length > 1 && normalizedExpression.lastIndexOf("/") === 0) {
650
+ return `Unterminated regular expression literal in '${normalizedExpression}'.`;
651
+ }
652
+ return null;
653
+ }
654
+ __name(tryCreateUnterminatedLiteralMessage, "tryCreateUnterminatedLiteralMessage");
655
+ function hasUnterminatedQuotedLiteral(expression, quoteCharacter) {
656
+ if (!expression.startsWith(quoteCharacter)) {
657
+ return false;
658
+ }
659
+ return countUnescapedCharacter(expression, quoteCharacter) % 2 !== 0;
660
+ }
661
+ __name(hasUnterminatedQuotedLiteral, "hasUnterminatedQuotedLiteral");
662
+ function countUnescapedCharacter(expression, character) {
663
+ let count = 0;
664
+ for (let index = 0; index < expression.length; index += 1) {
665
+ if (expression[index] !== character) {
666
+ continue;
667
+ }
668
+ const previous = expression[index - 1];
669
+ if (previous !== "\\") {
670
+ count += 1;
671
+ }
672
+ }
673
+ return count;
674
+ }
675
+ __name(countUnescapedCharacter, "countUnescapedCharacter");
676
+ function tryCreateUnclosedTokenMessage(normalizedExpression, parserMessage) {
677
+ if (!hasUnclosedTokenSignal(normalizedExpression, parserMessage)) {
678
+ return null;
679
+ }
680
+ return `Unclosed token in '${normalizedExpression}'.`;
681
+ }
682
+ __name(tryCreateUnclosedTokenMessage, "tryCreateUnclosedTokenMessage");
683
+ function hasUnclosedTokenSignal(normalizedExpression, parserMessage) {
684
+ const message = sanitizeParserMessage(parserMessage).toLowerCase();
685
+ if (message.includes("unexpected end of input") || message.includes("unterminated")) {
686
+ return true;
687
+ }
688
+ return hasUnbalancedDelimiters(normalizedExpression);
689
+ }
690
+ __name(hasUnclosedTokenSignal, "hasUnclosedTokenSignal");
691
+ function extractUnsupportedMessage(parserMessage) {
692
+ const sanitizedMessage = sanitizeParserMessage(parserMessage);
693
+ const unsupportedMatch = sanitizedMessage.match(/([^.]*not supported[^.]*)/iu);
694
+ if (!unsupportedMatch) {
695
+ return sanitizedMessage;
696
+ }
697
+ return unsupportedMatch[1].trim();
698
+ }
699
+ __name(extractUnsupportedMessage, "extractUnsupportedMessage");
700
+ function endsWithOperator(expression, operator) {
701
+ if ((operator === "+" || operator === "-") && /(?:\d+(?:\.\d+)?)[eE][+-]$/u.test(expression)) {
702
+ return false;
703
+ }
704
+ const escapedOperator = operator.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
705
+ const operatorPattern = operator === "instanceof" || operator === "in" ? `\\b${escapedOperator}\\s*$` : `${escapedOperator}\\s*$`;
706
+ return new RegExp(operatorPattern, "u").test(expression);
707
+ }
708
+ __name(endsWithOperator, "endsWithOperator");
709
+ function hasUnbalancedDelimiters(expression) {
710
+ let roundDepth = 0;
711
+ let squareDepth = 0;
712
+ let curlyDepth = 0;
713
+ for (const character of expression) {
714
+ if (character === "(") {
715
+ roundDepth += 1;
716
+ } else if (character === ")") {
717
+ roundDepth -= 1;
718
+ } else if (character === "[") {
719
+ squareDepth += 1;
720
+ } else if (character === "]") {
721
+ squareDepth -= 1;
722
+ } else if (character === "{") {
723
+ curlyDepth += 1;
724
+ } else if (character === "}") {
725
+ curlyDepth -= 1;
726
+ }
727
+ }
728
+ return roundDepth !== 0 || squareDepth !== 0 || curlyDepth !== 0;
729
+ }
730
+ __name(hasUnbalancedDelimiters, "hasUnbalancedDelimiters");
731
+
732
+ // lib/compiler/expression-site-validator.ts
733
+ var globalIdentifierOwnerResolver = new GlobalIdentifierOwnerResolver();
734
+ var supportedDateProperties = /* @__PURE__ */ new Set([
735
+ "year",
736
+ "utcYear",
737
+ "month",
738
+ "utcMonth",
739
+ "date",
740
+ "utcDate",
741
+ "hours",
742
+ "utcHours",
743
+ "minutes",
744
+ "utcMinutes",
745
+ "seconds",
746
+ "utcSeconds",
747
+ "milliseconds",
748
+ "utcMilliseconds",
749
+ "time"
750
+ ]);
751
+ function validateExpressionSites(program) {
752
+ const checker = program.getTypeChecker();
753
+ const parser2 = new JsEspreeExpressionParser(new JsExpressionAstParser3());
754
+ return detectExpressionSites(program).map((site) => validateExpressionSite(site, checker, parser2));
755
+ }
756
+ __name(validateExpressionSites, "validateExpressionSites");
757
+ function validateExpressionSite(site, checker, parser2 = new JsEspreeExpressionParser(new JsExpressionAstParser3())) {
758
+ const diagnostics = [];
759
+ const modelType = resolveModelType(site, checker);
760
+ if (!modelType) {
761
+ diagnostics.push({
762
+ category: "semantic",
763
+ message: "Could not resolve model type for expression entry point."
764
+ });
765
+ return {
766
+ ...site,
767
+ diagnostics
768
+ };
769
+ }
770
+ let parsedExpression;
771
+ try {
772
+ parsedExpression = parser2.parse(site.expression);
773
+ } catch (error) {
774
+ const message = error instanceof Error ? error.message : "Unknown parser error";
775
+ diagnostics.push(classifyParserError(site.expression, message));
776
+ return {
777
+ ...site,
778
+ diagnostics
779
+ };
780
+ }
781
+ resolveExpressionType(parsedExpression, modelType, modelType, checker, diagnostics);
782
+ return {
783
+ ...site,
784
+ diagnostics
785
+ };
786
+ }
787
+ __name(validateExpressionSite, "validateExpressionSite");
788
+ function resolveModelType(site, checker) {
789
+ const modelArgument = site.callExpression.arguments[0];
790
+ if (!modelArgument) {
791
+ return null;
792
+ }
793
+ return checker.getTypeAtLocation(modelArgument);
794
+ }
795
+ __name(resolveModelType, "resolveModelType");
796
+ function resolveExpressionType(expression, currentContextType, rootModelType, checker, diagnostics) {
797
+ switch (expression.type) {
798
+ case ExpressionType.Identifier:
799
+ return resolveIdentifierType(expression.expressionString, currentContextType, checker, diagnostics);
800
+ case ExpressionType.Member:
801
+ return resolveMemberType(expression, currentContextType, rootModelType, checker, diagnostics);
802
+ case ExpressionType.Function:
803
+ return resolveFunctionType(expression, currentContextType, rootModelType, checker, diagnostics);
804
+ case ExpressionType.Number:
805
+ return {
806
+ primitive: "number"
807
+ };
808
+ case ExpressionType.String:
809
+ return {
810
+ primitive: "string"
811
+ };
812
+ case ExpressionType.Boolean:
813
+ return {
814
+ primitive: "boolean"
815
+ };
816
+ case ExpressionType.BigInt:
817
+ return {
818
+ primitive: "bigint"
819
+ };
820
+ case ExpressionType.Null:
821
+ return {
822
+ primitive: "null"
823
+ };
824
+ case ExpressionType.Multiplication:
825
+ return resolveNumericBinaryType(expression, currentContextType, rootModelType, checker, diagnostics, "*");
826
+ case ExpressionType.Subtraction:
827
+ return resolveNumericBinaryType(expression, currentContextType, rootModelType, checker, diagnostics, "-");
828
+ case ExpressionType.Division:
829
+ return resolveNumericBinaryType(expression, currentContextType, rootModelType, checker, diagnostics, "/");
830
+ case ExpressionType.Remainder:
831
+ return resolveNumericBinaryType(expression, currentContextType, rootModelType, checker, diagnostics, "%");
832
+ case ExpressionType.Exponentiation:
833
+ return resolveNumericBinaryType(expression, currentContextType, rootModelType, checker, diagnostics, "**");
834
+ case ExpressionType.Addition:
835
+ return resolveAdditionType(expression, currentContextType, rootModelType, checker, diagnostics);
836
+ case ExpressionType.UnaryPlus:
837
+ case ExpressionType.UnaryNegation:
838
+ return resolveNumericUnaryType(expression, currentContextType, rootModelType, checker, diagnostics);
839
+ default:
840
+ return resolveNestedExpressionType(expression, currentContextType, rootModelType, checker, diagnostics);
841
+ }
842
+ }
843
+ __name(resolveExpressionType, "resolveExpressionType");
844
+ function resolveIdentifierType(identifier, contextType, checker, diagnostics) {
845
+ const normalizedIdentifier = String(identifier);
846
+ contextType = checker.getNonNullableType(unwrapRsxExpressionType(contextType, checker));
847
+ if (contextType.flags & (ts2.TypeFlags.Any | ts2.TypeFlags.Unknown)) {
848
+ return {};
849
+ }
850
+ const property = contextType.getProperty(normalizedIdentifier);
851
+ if (!property) {
852
+ const mapValueType = resolveMapValueType(contextType, checker);
853
+ if (mapValueType) {
854
+ return mapValueType;
855
+ }
856
+ if (supportedDateProperties.has(normalizedIdentifier) && isDateLikeType(contextType, checker)) {
857
+ return {
858
+ primitive: "number"
859
+ };
860
+ }
861
+ const indexedType = resolveIdentifierAsIndexedAccess(normalizedIdentifier, contextType, checker);
862
+ if (indexedType) {
863
+ return indexedType;
864
+ }
865
+ if (isAllowedGlobalIdentifier(normalizedIdentifier)) {
866
+ return {};
867
+ }
868
+ diagnostics.push({
869
+ category: "semantic",
870
+ message: `Identifier '${normalizedIdentifier}' does not exist on model type.`,
871
+ token: normalizedIdentifier
872
+ });
873
+ return {};
874
+ }
875
+ const declaration = property.valueDeclaration ?? property.declarations?.[0];
876
+ if (!declaration) {
877
+ return {};
878
+ }
879
+ return {
880
+ tsType: unwrapRsxExpressionType(checker.getTypeOfSymbolAtLocation(property, declaration), checker)
881
+ };
882
+ }
883
+ __name(resolveIdentifierType, "resolveIdentifierType");
884
+ function resolveIdentifierAsIndexedAccess(identifier, contextType, checker) {
885
+ const numericIdentifier = Number(identifier);
886
+ const isCanonicalNumberIdentifier = Number.isInteger(numericIdentifier) && String(numericIdentifier) === identifier;
887
+ if (isCanonicalNumberIdentifier) {
888
+ const numberIndexType = contextType.getNumberIndexType();
889
+ if (numberIndexType) {
890
+ return {
891
+ tsType: unwrapRsxExpressionType(numberIndexType, checker)
892
+ };
893
+ }
894
+ }
895
+ const stringIndexType = contextType.getStringIndexType();
896
+ if (stringIndexType) {
897
+ return {
898
+ tsType: unwrapRsxExpressionType(stringIndexType, checker)
899
+ };
900
+ }
901
+ return null;
902
+ }
903
+ __name(resolveIdentifierAsIndexedAccess, "resolveIdentifierAsIndexedAccess");
904
+ function isAllowedGlobalIdentifier(identifier) {
905
+ return globalIdentifierOwnerResolver.resolve(identifier) !== null;
906
+ }
907
+ __name(isAllowedGlobalIdentifier, "isAllowedGlobalIdentifier");
908
+ function isDateLikeType(type, checker) {
909
+ type = unwrapRsxExpressionType(type, checker);
910
+ if (type.isUnionOrIntersection()) {
911
+ return type.types.some((memberType) => isDateLikeType(memberType, checker));
912
+ }
913
+ return Boolean(type.getProperty("getFullYear") && type.getProperty("setFullYear") && type.getProperty("getTime") && type.getProperty("setTime"));
914
+ }
915
+ __name(isDateLikeType, "isDateLikeType");
916
+ function resolveMapValueType(type, checker) {
917
+ type = unwrapRsxExpressionType(type, checker);
918
+ if (type.isUnionOrIntersection()) {
919
+ for (const memberType of type.types) {
920
+ const memberMapValueType = resolveMapValueType(memberType, checker);
921
+ if (memberMapValueType) {
922
+ return memberMapValueType;
923
+ }
924
+ }
925
+ return null;
926
+ }
927
+ const symbolName = (type.aliasSymbol ?? type.getSymbol())?.getName();
928
+ if (symbolName !== "Map") {
929
+ return null;
930
+ }
931
+ const typeArguments = checker.getTypeArguments(type);
932
+ if (typeArguments.length < 2) {
933
+ return {};
934
+ }
935
+ return {
936
+ tsType: unwrapRsxExpressionType(typeArguments[1], checker)
937
+ };
938
+ }
939
+ __name(resolveMapValueType, "resolveMapValueType");
940
+ function resolveSetValueType(type, checker) {
941
+ type = unwrapRsxExpressionType(type, checker);
942
+ if (type.isUnionOrIntersection()) {
943
+ for (const memberType of type.types) {
944
+ const memberSetValueType = resolveSetValueType(memberType, checker);
945
+ if (memberSetValueType) {
946
+ return memberSetValueType;
947
+ }
948
+ }
949
+ return null;
950
+ }
951
+ const symbolName = (type.aliasSymbol ?? type.getSymbol())?.getName();
952
+ if (symbolName !== "Set") {
953
+ return null;
954
+ }
955
+ const typeArguments = checker.getTypeArguments(type);
956
+ if (typeArguments.length < 1) {
957
+ return {};
958
+ }
959
+ return {
960
+ tsType: unwrapRsxExpressionType(typeArguments[0], checker)
961
+ };
962
+ }
963
+ __name(resolveSetValueType, "resolveSetValueType");
964
+ function resolveMemberType(memberExpression, contextType, rootModelType, checker, diagnostics) {
965
+ const segments = memberExpression.childExpressions;
966
+ if (segments.length === 0) {
967
+ return {};
968
+ }
969
+ let currentType = resolveExpressionType(segments[0], contextType, rootModelType, checker, diagnostics);
970
+ for (let i = 1; i < segments.length; i++) {
971
+ const segment = segments[i];
972
+ if (!currentType.tsType) {
973
+ return {};
974
+ }
975
+ const currentTsType = unwrapRsxExpressionType(currentType.tsType, checker);
976
+ if (segment.type === ExpressionType.Identifier) {
977
+ currentType = resolveIdentifierType(segment.expressionString, currentTsType, checker, diagnostics);
978
+ continue;
979
+ }
980
+ if (segment.type === ExpressionType.ComputedIndex) {
981
+ const indexExpression = segment.childExpressions[0];
982
+ const resolvedIndexType = resolveExpressionType(indexExpression, rootModelType, rootModelType, checker, diagnostics);
983
+ currentType = resolveIndexedType(currentTsType, resolvedIndexType, checker, diagnostics);
984
+ continue;
985
+ }
986
+ if (segment.type === ExpressionType.Function) {
987
+ currentType = resolveFunctionTypeFromKnownContext(segment, currentTsType, rootModelType, checker, diagnostics);
988
+ continue;
989
+ }
990
+ currentType = resolveExpressionType(segment, currentTsType, rootModelType, checker, diagnostics);
991
+ }
992
+ return currentType;
993
+ }
994
+ __name(resolveMemberType, "resolveMemberType");
995
+ function resolveIndexedType(targetType, indexType, checker, diagnostics) {
996
+ targetType = unwrapRsxExpressionType(targetType, checker);
997
+ const mapValueType = resolveMapValueType(targetType, checker);
998
+ if (mapValueType) {
999
+ return mapValueType;
1000
+ }
1001
+ const setValueType = resolveSetValueType(targetType, checker);
1002
+ if (setValueType) {
1003
+ return setValueType;
1004
+ }
1005
+ const isNumberIndexType = indexType.primitive === "number" || (indexType.tsType ? tsTypeMatches(indexType.tsType, ts2.TypeFlags.NumberLike, checker) : false);
1006
+ if (isNumberIndexType) {
1007
+ const numberIndexType = targetType.getNumberIndexType();
1008
+ if (!numberIndexType) {
1009
+ diagnostics.push({
1010
+ category: "semantic",
1011
+ message: "Index access with number is not valid for this type."
1012
+ });
1013
+ return {};
1014
+ }
1015
+ return {
1016
+ tsType: numberIndexType
1017
+ };
1018
+ }
1019
+ if (indexType.primitive === "string") {
1020
+ return {};
1021
+ }
1022
+ const stringIndexType = targetType.getStringIndexType();
1023
+ if (!stringIndexType) {
1024
+ diagnostics.push({
1025
+ category: "semantic",
1026
+ message: "Index access is not valid for this type."
1027
+ });
1028
+ return {};
1029
+ }
1030
+ return {
1031
+ tsType: stringIndexType
1032
+ };
1033
+ }
1034
+ __name(resolveIndexedType, "resolveIndexedType");
1035
+ function resolveFunctionType(functionExpression, contextType, rootModelType, checker, diagnostics) {
1036
+ const objectExpression = functionExpression.childExpressions[0];
1037
+ const functionNameExpression = functionExpression.childExpressions[1];
1038
+ const objectType = objectExpression.type === ExpressionType.Null ? {
1039
+ tsType: contextType
1040
+ } : resolveExpressionType(objectExpression, contextType, rootModelType, checker, diagnostics);
1041
+ if (!objectType.tsType) {
1042
+ return {};
1043
+ }
1044
+ return resolveFunctionTypeFromKnownContext(functionExpression, objectType.tsType, rootModelType, checker, diagnostics, functionNameExpression);
1045
+ }
1046
+ __name(resolveFunctionType, "resolveFunctionType");
1047
+ function resolveFunctionTypeFromKnownContext(functionExpression, objectType, rootModelType, checker, diagnostics, functionNameExpression) {
1048
+ objectType = unwrapRsxExpressionType(objectType, checker);
1049
+ if (objectType.flags & (ts2.TypeFlags.Any | ts2.TypeFlags.Unknown)) {
1050
+ return {};
1051
+ }
1052
+ const fnExpression = functionNameExpression ?? functionExpression.childExpressions[1];
1053
+ const argsContainer = functionExpression.childExpressions[2];
1054
+ const argumentExpressions = argsContainer?.childExpressions ?? [];
1055
+ const functionName = fnExpression.expressionString;
1056
+ const functionProperty = objectType.getProperty(functionName);
1057
+ if (!functionProperty) {
1058
+ diagnostics.push({
1059
+ category: "semantic",
1060
+ message: `Function '${functionName}' does not exist on target type.`,
1061
+ token: functionName
1062
+ });
1063
+ return {};
1064
+ }
1065
+ const declaration = functionProperty.valueDeclaration ?? functionProperty.declarations?.[0];
1066
+ if (!declaration) {
1067
+ return {};
1068
+ }
1069
+ const functionType = checker.getTypeOfSymbolAtLocation(functionProperty, declaration);
1070
+ const signatures = functionType.getCallSignatures();
1071
+ if (signatures.length === 0) {
1072
+ diagnostics.push({
1073
+ category: "semantic",
1074
+ message: `'${functionName}' is not callable.`,
1075
+ token: functionName
1076
+ });
1077
+ return {};
1078
+ }
1079
+ const resolvedArguments = argumentExpressions.map((argumentExpression) => resolveExpressionType(argumentExpression, rootModelType, rootModelType, checker, diagnostics));
1080
+ const matchingSignature = signatures.find((signature) => doesArgumentListMatchSignature(resolvedArguments, signature, checker));
1081
+ if (!matchingSignature) {
1082
+ diagnostics.push({
1083
+ category: "semantic",
1084
+ message: `Arguments for '${functionName}' do not match any call signature.`,
1085
+ token: functionName
1086
+ });
1087
+ return {};
1088
+ }
1089
+ return {
1090
+ tsType: matchingSignature.getReturnType()
1091
+ };
1092
+ }
1093
+ __name(resolveFunctionTypeFromKnownContext, "resolveFunctionTypeFromKnownContext");
1094
+ function doesArgumentListMatchSignature(resolvedArguments, signature, checker) {
1095
+ const parameters = signature.getParameters();
1096
+ if (resolvedArguments.length < getRequiredParameterCount(parameters)) {
1097
+ return false;
1098
+ }
1099
+ if (resolvedArguments.length > parameters.length) {
1100
+ return false;
1101
+ }
1102
+ for (let i = 0; i < resolvedArguments.length; i++) {
1103
+ const parameter = parameters[i];
1104
+ if (!parameter) {
1105
+ return false;
1106
+ }
1107
+ const declaration = parameter.valueDeclaration ?? parameter.declarations?.[0];
1108
+ if (!declaration) {
1109
+ return false;
1110
+ }
1111
+ const parameterType = checker.getTypeOfSymbolAtLocation(parameter, declaration);
1112
+ if (!isAssignableToParameter(resolvedArguments[i], parameterType, checker)) {
1113
+ return false;
1114
+ }
1115
+ }
1116
+ return true;
1117
+ }
1118
+ __name(doesArgumentListMatchSignature, "doesArgumentListMatchSignature");
1119
+ function getRequiredParameterCount(parameters) {
1120
+ return parameters.filter((parameter) => {
1121
+ const declaration = parameter.valueDeclaration;
1122
+ return !declaration?.questionToken && !declaration?.initializer;
1123
+ }).length;
1124
+ }
1125
+ __name(getRequiredParameterCount, "getRequiredParameterCount");
1126
+ function isAssignableToParameter(argumentType, parameterType, checker) {
1127
+ if (argumentType.tsType) {
1128
+ return checker.isTypeAssignableTo(unwrapRsxExpressionType(argumentType.tsType, checker), parameterType);
1129
+ }
1130
+ if (!argumentType.primitive) {
1131
+ return false;
1132
+ }
1133
+ return isPrimitiveAssignable(argumentType.primitive, parameterType);
1134
+ }
1135
+ __name(isAssignableToParameter, "isAssignableToParameter");
1136
+ function isPrimitiveAssignable(primitive, parameterType) {
1137
+ if (!primitive) {
1138
+ return false;
1139
+ }
1140
+ if (parameterType.isUnionOrIntersection()) {
1141
+ return parameterType.types.some((type) => isPrimitiveAssignable(primitive, type));
1142
+ }
1143
+ switch (primitive) {
1144
+ case "string":
1145
+ return (parameterType.flags & ts2.TypeFlags.StringLike) !== 0;
1146
+ case "number":
1147
+ return (parameterType.flags & ts2.TypeFlags.NumberLike) !== 0;
1148
+ case "boolean":
1149
+ return (parameterType.flags & ts2.TypeFlags.BooleanLike) !== 0;
1150
+ case "bigint":
1151
+ return (parameterType.flags & ts2.TypeFlags.BigIntLike) !== 0;
1152
+ case "null":
1153
+ return (parameterType.flags & ts2.TypeFlags.Null) !== 0;
1154
+ default:
1155
+ return false;
1156
+ }
1157
+ }
1158
+ __name(isPrimitiveAssignable, "isPrimitiveAssignable");
1159
+ function resolveNumericBinaryType(expression, contextType, rootModelType, checker, diagnostics, operator) {
1160
+ const leftExpression = expression.childExpressions[0];
1161
+ const rightExpression = expression.childExpressions[1];
1162
+ const leftType = resolveExpressionType(leftExpression, contextType, rootModelType, checker, diagnostics);
1163
+ const rightType = resolveExpressionType(rightExpression, contextType, rootModelType, checker, diagnostics);
1164
+ if (!isNumberLike(leftType, checker) || !isNumberLike(rightType, checker)) {
1165
+ const token = pickIncompatibleOperandToken({
1166
+ leftExpression,
1167
+ leftType,
1168
+ rightExpression,
1169
+ rightType,
1170
+ checker
1171
+ });
1172
+ diagnostics.push({
1173
+ category: "semantic",
1174
+ message: `Operator "${operator}" requires both left and right operands to be number-compatible.`,
1175
+ token
1176
+ });
1177
+ }
1178
+ return {
1179
+ primitive: "number"
1180
+ };
1181
+ }
1182
+ __name(resolveNumericBinaryType, "resolveNumericBinaryType");
1183
+ function resolveAdditionType(expression, contextType, rootModelType, checker, diagnostics) {
1184
+ const leftExpression = expression.childExpressions[0];
1185
+ const rightExpression = expression.childExpressions[1];
1186
+ const leftType = resolveExpressionType(leftExpression, contextType, rootModelType, checker, diagnostics);
1187
+ const rightType = resolveExpressionType(rightExpression, contextType, rootModelType, checker, diagnostics);
1188
+ if (isStringLike(leftType, checker) || isStringLike(rightType, checker)) {
1189
+ return {
1190
+ primitive: "string"
1191
+ };
1192
+ }
1193
+ if (isNumberLike(leftType, checker) && isNumberLike(rightType, checker)) {
1194
+ return {
1195
+ primitive: "number"
1196
+ };
1197
+ }
1198
+ if (hasMissingIdentifierDiagnostic(leftExpression, diagnostics) || hasMissingIdentifierDiagnostic(rightExpression, diagnostics)) {
1199
+ return {};
1200
+ }
1201
+ const token = pickIncompatibleOperandToken({
1202
+ leftExpression,
1203
+ leftType,
1204
+ rightExpression,
1205
+ rightType,
1206
+ checker
1207
+ });
1208
+ diagnostics.push({
1209
+ category: "semantic",
1210
+ message: 'Operator "+" requires compatible operands (both number-like or at least one string-like).',
1211
+ token
1212
+ });
1213
+ return {};
1214
+ }
1215
+ __name(resolveAdditionType, "resolveAdditionType");
1216
+ function hasMissingIdentifierDiagnostic(expression, diagnostics) {
1217
+ if (expression.type !== ExpressionType.Identifier) {
1218
+ return false;
1219
+ }
1220
+ const identifier = expression.expressionString;
1221
+ const expectedMessage = `Identifier '${identifier}' does not exist on model type.`;
1222
+ return diagnostics.some((diagnostic) => diagnostic.category === "semantic" && diagnostic.message === expectedMessage);
1223
+ }
1224
+ __name(hasMissingIdentifierDiagnostic, "hasMissingIdentifierDiagnostic");
1225
+ function resolveNumericUnaryType(expression, contextType, rootModelType, checker, diagnostics) {
1226
+ const operandExpression = expression.childExpressions[0];
1227
+ const operandType = resolveExpressionType(operandExpression, contextType, rootModelType, checker, diagnostics);
1228
+ if (!isNumberLike(operandType, checker)) {
1229
+ diagnostics.push({
1230
+ category: "semantic",
1231
+ message: "Unary numeric operator requires a number-compatible operand.",
1232
+ token: operandExpression.type === ExpressionType.Identifier ? operandExpression.expressionString : void 0
1233
+ });
1234
+ }
1235
+ return {
1236
+ primitive: "number"
1237
+ };
1238
+ }
1239
+ __name(resolveNumericUnaryType, "resolveNumericUnaryType");
1240
+ function isNumberLike(type, checker) {
1241
+ if (type.primitive === "number") {
1242
+ return true;
1243
+ }
1244
+ if (!type.tsType) {
1245
+ return false;
1246
+ }
1247
+ const unwrappedType = unwrapRsxExpressionType(type.tsType, checker);
1248
+ if ((unwrappedType.flags & ts2.TypeFlags.Any) !== 0) {
1249
+ return true;
1250
+ }
1251
+ return tsTypeMatches(unwrappedType, ts2.TypeFlags.NumberLike, checker);
1252
+ }
1253
+ __name(isNumberLike, "isNumberLike");
1254
+ function isStringLike(type, checker) {
1255
+ if (type.primitive === "string") {
1256
+ return true;
1257
+ }
1258
+ if (!type.tsType) {
1259
+ return false;
1260
+ }
1261
+ const unwrappedType = unwrapRsxExpressionType(type.tsType, checker);
1262
+ if ((unwrappedType.flags & ts2.TypeFlags.Any) !== 0) {
1263
+ return true;
1264
+ }
1265
+ return tsTypeMatches(unwrappedType, ts2.TypeFlags.StringLike, checker);
1266
+ }
1267
+ __name(isStringLike, "isStringLike");
1268
+ function pickIncompatibleOperandToken(args) {
1269
+ const { leftExpression, leftType, rightExpression, rightType, checker } = args;
1270
+ const leftCompatible = isNumberLike(leftType, checker) || isStringLike(leftType, checker);
1271
+ const rightCompatible = isNumberLike(rightType, checker) || isStringLike(rightType, checker);
1272
+ if (!leftCompatible && leftExpression.type === ExpressionType.Identifier) {
1273
+ return leftExpression.expressionString;
1274
+ }
1275
+ if (!rightCompatible && rightExpression.type === ExpressionType.Identifier) {
1276
+ return rightExpression.expressionString;
1277
+ }
1278
+ return void 0;
1279
+ }
1280
+ __name(pickIncompatibleOperandToken, "pickIncompatibleOperandToken");
1281
+ function resolveNestedExpressionType(expression, currentContextType, rootModelType, checker, diagnostics) {
1282
+ const childExpressions = expression.childExpressions;
1283
+ if (childExpressions.length === 0) {
1284
+ return {};
1285
+ }
1286
+ const resolvedChildren = childExpressions.map((childExpression) => resolveExpressionType(childExpression, currentContextType, rootModelType, checker, diagnostics));
1287
+ if (resolvedChildren.length === 1) {
1288
+ return resolvedChildren[0] ?? {};
1289
+ }
1290
+ return {};
1291
+ }
1292
+ __name(resolveNestedExpressionType, "resolveNestedExpressionType");
1293
+ function tsTypeMatches(type, mask, checker) {
1294
+ type = unwrapRsxExpressionType(type, checker);
1295
+ if ((type.flags & mask) !== 0) {
1296
+ return true;
1297
+ }
1298
+ if (type.isUnionOrIntersection()) {
1299
+ return type.types.some((memberType) => tsTypeMatches(memberType, mask, checker));
1300
+ }
1301
+ return false;
1302
+ }
1303
+ __name(tsTypeMatches, "tsTypeMatches");
1304
+ function unwrapRsxExpressionType(type, checker) {
1305
+ let currentType = type;
1306
+ while (true) {
1307
+ const unwrappedType = tryUnwrapRsxExpressionType(currentType, checker);
1308
+ if (!unwrappedType || unwrappedType === currentType) {
1309
+ break;
1310
+ }
1311
+ currentType = unwrappedType;
1312
+ }
1313
+ return currentType;
1314
+ }
1315
+ __name(unwrapRsxExpressionType, "unwrapRsxExpressionType");
1316
+ function tryUnwrapRsxExpressionType(type, checker) {
1317
+ const symbol = type.aliasSymbol ?? type.getSymbol();
1318
+ const symbolName = symbol?.getName();
1319
+ const typeArguments = checker.getTypeArguments(type);
1320
+ const hasThen = Boolean(type.getProperty("then"));
1321
+ const hasSubscribe = Boolean(type.getProperty("subscribe"));
1322
+ const isKnownExpressionWrapper = symbolName === "IExpression" || symbolName === "Promise" || symbolName === "Observable" || symbolName === "Subject" || symbolName === "BehaviorSubject";
1323
+ const isThenableLike = hasThen;
1324
+ const isObservableLike = hasSubscribe;
1325
+ if (typeArguments.length > 0 && (isKnownExpressionWrapper || isThenableLike || isObservableLike)) {
1326
+ return typeArguments[0];
1327
+ }
1328
+ if (isKnownExpressionWrapper || isObservableLike) {
1329
+ const valueLikeType = tryResolveValuePropertyType(type, checker) ?? tryResolveGetValueReturnType(type, checker);
1330
+ if (valueLikeType) {
1331
+ return valueLikeType;
1332
+ }
1333
+ }
1334
+ const hasExpressionShape = type.getProperty("value") && type.getProperty("expressionString") && type.getProperty("childExpressions") && type.getProperty("changed");
1335
+ if (!hasExpressionShape) {
1336
+ return null;
1337
+ }
1338
+ const valueProperty = type.getProperty("value");
1339
+ const declaration = valueProperty?.valueDeclaration ?? valueProperty?.declarations?.[0];
1340
+ if (!valueProperty || !declaration) {
1341
+ return null;
1342
+ }
1343
+ return checker.getTypeOfSymbolAtLocation(valueProperty, declaration);
1344
+ }
1345
+ __name(tryUnwrapRsxExpressionType, "tryUnwrapRsxExpressionType");
1346
+ function tryResolveValuePropertyType(type, checker) {
1347
+ const valueProperty = type.getProperty("value");
1348
+ const declaration = valueProperty?.valueDeclaration ?? valueProperty?.declarations?.[0];
1349
+ if (!valueProperty || !declaration) {
1350
+ return null;
1351
+ }
1352
+ return checker.getTypeOfSymbolAtLocation(valueProperty, declaration);
1353
+ }
1354
+ __name(tryResolveValuePropertyType, "tryResolveValuePropertyType");
1355
+ function tryResolveGetValueReturnType(type, checker) {
1356
+ const getValueSymbol = type.getProperty("getValue");
1357
+ const declaration = getValueSymbol?.valueDeclaration ?? getValueSymbol?.declarations?.[0];
1358
+ if (!getValueSymbol || !declaration) {
1359
+ return null;
1360
+ }
1361
+ const getValueType = checker.getTypeOfSymbolAtLocation(getValueSymbol, declaration);
1362
+ const signatures = getValueType.getCallSignatures();
1363
+ if (signatures.length === 0) {
1364
+ return null;
1365
+ }
1366
+ return signatures[0].getReturnType();
1367
+ }
1368
+ __name(tryResolveGetValueReturnType, "tryResolveGetValueReturnType");
1369
+
1370
+ // lib/compiler/index.ts
1371
+ function createCompilerScaffold() {
1372
+ return {
1373
+ phase: 0,
1374
+ scope: "project-setup",
1375
+ packageName: "@rs-x/compiler"
1376
+ };
1377
+ }
1378
+ __name(createCompilerScaffold, "createCompilerScaffold");
1379
+
1380
+ // lib/diagnostics/index.ts
1381
+ function createDiagnosticsScaffold() {
1382
+ return {
1383
+ folder: "diagnostics",
1384
+ categories: [
1385
+ "syntax",
1386
+ "semantic",
1387
+ "unsupported"
1388
+ ]
1389
+ };
1390
+ }
1391
+ __name(createDiagnosticsScaffold, "createDiagnosticsScaffold");
1392
+
1393
+ // lib/language-service/rsx-expression-lexing.ts
1394
+ var RSX_KEYWORDS = /* @__PURE__ */ new Set([
1395
+ "true",
1396
+ "false",
1397
+ "null",
1398
+ "undefined",
1399
+ "new",
1400
+ "typeof",
1401
+ "instanceof",
1402
+ "in",
1403
+ "void",
1404
+ "delete",
1405
+ "this"
1406
+ ]);
1407
+ var OPERATOR_HEAD = /* @__PURE__ */ new Set([
1408
+ "+",
1409
+ "-",
1410
+ "*",
1411
+ "/",
1412
+ "%",
1413
+ "=",
1414
+ "!",
1415
+ "<",
1416
+ ">",
1417
+ "&",
1418
+ "|",
1419
+ "^",
1420
+ "~",
1421
+ "?"
1422
+ ]);
1423
+ var OPERATORS = [
1424
+ ">>>",
1425
+ "===",
1426
+ "!==",
1427
+ "<<=",
1428
+ ">>=",
1429
+ "&&",
1430
+ "||",
1431
+ "??",
1432
+ "==",
1433
+ "!=",
1434
+ "<=",
1435
+ ">=",
1436
+ "=>",
1437
+ "<<",
1438
+ ">>",
1439
+ "**",
1440
+ "?.",
1441
+ "+=",
1442
+ "-=",
1443
+ "*=",
1444
+ "/=",
1445
+ "%=",
1446
+ "&=",
1447
+ "|=",
1448
+ "^=",
1449
+ "++",
1450
+ "--"
1451
+ ];
1452
+ var PUNCTUATION = /* @__PURE__ */ new Set([
1453
+ "(",
1454
+ ")",
1455
+ "[",
1456
+ "]",
1457
+ "{",
1458
+ "}",
1459
+ ".",
1460
+ ",",
1461
+ ":",
1462
+ ";"
1463
+ ]);
1464
+ function isWhitespace(char) {
1465
+ return /\s/u.test(char);
1466
+ }
1467
+ __name(isWhitespace, "isWhitespace");
1468
+ function isIdentifierStart(char) {
1469
+ return /[A-Za-z_$]/u.test(char);
1470
+ }
1471
+ __name(isIdentifierStart, "isIdentifierStart");
1472
+ function isIdentifierPart(char) {
1473
+ return /[A-Za-z0-9_$]/u.test(char);
1474
+ }
1475
+ __name(isIdentifierPart, "isIdentifierPart");
1476
+ function consumeIdentifier(text, start) {
1477
+ let end = start + 1;
1478
+ while (end < text.length && isIdentifierPart(text[end])) {
1479
+ end++;
1480
+ }
1481
+ return end;
1482
+ }
1483
+ __name(consumeIdentifier, "consumeIdentifier");
1484
+ function isNumberStart(text, index) {
1485
+ const char = text[index];
1486
+ const next = text[index + 1];
1487
+ if (/\d/u.test(char)) {
1488
+ return true;
1489
+ }
1490
+ return char === "." && /\d/u.test(next);
1491
+ }
1492
+ __name(isNumberStart, "isNumberStart");
1493
+ function consumeNumber(text, start) {
1494
+ let index = start;
1495
+ if (text[index] === "0" && index + 1 < text.length) {
1496
+ const marker = text[index + 1];
1497
+ if (marker === "x" || marker === "X") {
1498
+ index += 2;
1499
+ while (index < text.length && /[0-9A-Fa-f_]/u.test(text[index])) {
1500
+ index++;
1501
+ }
1502
+ return index;
1503
+ }
1504
+ if (marker === "b" || marker === "B") {
1505
+ index += 2;
1506
+ while (index < text.length && /[01_]/u.test(text[index])) {
1507
+ index++;
1508
+ }
1509
+ return index;
1510
+ }
1511
+ if (marker === "o" || marker === "O") {
1512
+ index += 2;
1513
+ while (index < text.length && /[0-7_]/u.test(text[index])) {
1514
+ index++;
1515
+ }
1516
+ return index;
1517
+ }
1518
+ }
1519
+ while (index < text.length && /[0-9_]/u.test(text[index])) {
1520
+ index++;
1521
+ }
1522
+ if (text[index] === ".") {
1523
+ index++;
1524
+ while (index < text.length && /[0-9_]/u.test(text[index])) {
1525
+ index++;
1526
+ }
1527
+ }
1528
+ if (text[index] === "e" || text[index] === "E") {
1529
+ const exponentStart = index;
1530
+ index++;
1531
+ if (text[index] === "+" || text[index] === "-") {
1532
+ index++;
1533
+ }
1534
+ const digitsStart = index;
1535
+ while (index < text.length && /[0-9_]/u.test(text[index])) {
1536
+ index++;
1537
+ }
1538
+ if (digitsStart === index) {
1539
+ return exponentStart;
1540
+ }
1541
+ }
1542
+ if (text[index] === "n") {
1543
+ index++;
1544
+ }
1545
+ return index;
1546
+ }
1547
+ __name(consumeNumber, "consumeNumber");
1548
+ function isQuote(char) {
1549
+ return char === "'" || char === '"' || char === "`";
1550
+ }
1551
+ __name(isQuote, "isQuote");
1552
+ function consumeQuoted(text, start, quote) {
1553
+ let index = start + 1;
1554
+ while (index < text.length) {
1555
+ const char = text[index];
1556
+ if (char === "\\") {
1557
+ index += 2;
1558
+ continue;
1559
+ }
1560
+ index++;
1561
+ if (char === quote) {
1562
+ return index;
1563
+ }
1564
+ }
1565
+ return text.length;
1566
+ }
1567
+ __name(consumeQuoted, "consumeQuoted");
1568
+ function matchOperator(text, index) {
1569
+ for (const op of OPERATORS) {
1570
+ if (text.startsWith(op, index)) {
1571
+ return op;
1572
+ }
1573
+ }
1574
+ return null;
1575
+ }
1576
+ __name(matchOperator, "matchOperator");
1577
+ function tokenizeRsxExpression(text) {
1578
+ const tokens = [];
1579
+ let index = 0;
1580
+ while (index < text.length) {
1581
+ const char = text[index];
1582
+ if (isWhitespace(char)) {
1583
+ index++;
1584
+ continue;
1585
+ }
1586
+ if (isQuote(char)) {
1587
+ const end = consumeQuoted(text, index, char);
1588
+ tokens.push({
1589
+ start: index,
1590
+ end,
1591
+ kind: "string"
1592
+ });
1593
+ index = end;
1594
+ continue;
1595
+ }
1596
+ if (isNumberStart(text, index)) {
1597
+ const end = consumeNumber(text, index);
1598
+ tokens.push({
1599
+ start: index,
1600
+ end,
1601
+ kind: "number"
1602
+ });
1603
+ index = end;
1604
+ continue;
1605
+ }
1606
+ if (isIdentifierStart(char)) {
1607
+ const end = consumeIdentifier(text, index);
1608
+ const value = text.slice(index, end);
1609
+ tokens.push({
1610
+ start: index,
1611
+ end,
1612
+ kind: RSX_KEYWORDS.has(value) ? "keyword" : "identifier"
1613
+ });
1614
+ index = end;
1615
+ continue;
1616
+ }
1617
+ const operator = matchOperator(text, index);
1618
+ if (operator) {
1619
+ tokens.push({
1620
+ start: index,
1621
+ end: index + operator.length,
1622
+ kind: "operator"
1623
+ });
1624
+ index += operator.length;
1625
+ continue;
1626
+ }
1627
+ if (PUNCTUATION.has(char)) {
1628
+ tokens.push({
1629
+ start: index,
1630
+ end: index + 1,
1631
+ kind: "punctuation"
1632
+ });
1633
+ index += 1;
1634
+ continue;
1635
+ }
1636
+ if (OPERATOR_HEAD.has(char)) {
1637
+ tokens.push({
1638
+ start: index,
1639
+ end: index + 1,
1640
+ kind: "operator"
1641
+ });
1642
+ index += 1;
1643
+ continue;
1644
+ }
1645
+ index += 1;
1646
+ }
1647
+ return tokens;
1648
+ }
1649
+ __name(tokenizeRsxExpression, "tokenizeRsxExpression");
1650
+ function consumeUntilMatchingQuote(args) {
1651
+ const { text, start, quote } = args;
1652
+ let index = start;
1653
+ while (index < text.length) {
1654
+ const char = text[index];
1655
+ if (char === "\\") {
1656
+ index += 2;
1657
+ continue;
1658
+ }
1659
+ if (char === quote) {
1660
+ return index;
1661
+ }
1662
+ index++;
1663
+ }
1664
+ return -1;
1665
+ }
1666
+ __name(consumeUntilMatchingQuote, "consumeUntilMatchingQuote");
1667
+ function findRsxExpressionLiteralRanges(sourceText) {
1668
+ const ranges = [];
1669
+ let cursor = 0;
1670
+ while (cursor < sourceText.length) {
1671
+ const rsxCallStart = sourceText.indexOf("rsx", cursor);
1672
+ if (rsxCallStart === -1) {
1673
+ break;
1674
+ }
1675
+ let index = rsxCallStart + 3;
1676
+ while (index < sourceText.length && /\s/u.test(sourceText[index])) {
1677
+ index++;
1678
+ }
1679
+ if (sourceText[index] !== "(") {
1680
+ cursor = rsxCallStart + 3;
1681
+ continue;
1682
+ }
1683
+ index++;
1684
+ while (index < sourceText.length && /\s/u.test(sourceText[index])) {
1685
+ index++;
1686
+ }
1687
+ const quote = sourceText[index];
1688
+ if (quote !== "'" && quote !== '"' && quote !== "`") {
1689
+ cursor = rsxCallStart + 3;
1690
+ continue;
1691
+ }
1692
+ const contentStart = index + 1;
1693
+ const quoteEnd = consumeUntilMatchingQuote({
1694
+ text: sourceText,
1695
+ start: contentStart,
1696
+ quote
1697
+ });
1698
+ if (quoteEnd === -1) {
1699
+ break;
1700
+ }
1701
+ ranges.push({
1702
+ start: contentStart,
1703
+ end: quoteEnd,
1704
+ expression: sourceText.slice(contentStart, quoteEnd)
1705
+ });
1706
+ cursor = quoteEnd + 1;
1707
+ }
1708
+ return ranges;
1709
+ }
1710
+ __name(findRsxExpressionLiteralRanges, "findRsxExpressionLiteralRanges");
1711
+
1712
+ // lib/language-service/rsx-language-service.ts
1713
+ import ts3 from "typescript";
1714
+ function findRsxExpressionRegionAtPosition(program, fileName, position) {
1715
+ const context = resolveExpressionContext(program, fileName, position);
1716
+ if (!context) {
1717
+ return null;
1718
+ }
1719
+ return {
1720
+ expression: context.expression,
1721
+ start: context.expressionStart,
1722
+ end: context.expressionEnd
1723
+ };
1724
+ }
1725
+ __name(findRsxExpressionRegionAtPosition, "findRsxExpressionRegionAtPosition");
1726
+ function getRsxCompletionsAtPosition(program, fileName, position) {
1727
+ const context = resolveExpressionContext(program, fileName, position);
1728
+ if (!context) {
1729
+ return [];
1730
+ }
1731
+ const expressionOffset = position - context.expressionStart;
1732
+ const prefixSource = context.expression.slice(0, expressionOffset);
1733
+ const constructorPrefix = resolveConstructorCompletionPrefix(prefixSource);
1734
+ if (constructorPrefix !== null) {
1735
+ return resolveConstructorCompletions(context, constructorPrefix);
1736
+ }
1737
+ const completionTarget = resolveCompletionTarget(prefixSource);
1738
+ const targetType = completionTarget.chain.length ? resolveChainType(context.modelType, completionTarget.chain, context.checker) : context.modelType;
1739
+ if (!targetType) {
1740
+ return [];
1741
+ }
1742
+ if (isDateLikeType(targetType, context.checker)) {
1743
+ const names2 = [
1744
+ ...supportedDateProperties
1745
+ ].filter((name) => name.startsWith(completionTarget.prefix)).sort();
1746
+ return names2.map((name) => ({
1747
+ name,
1748
+ kind: "property"
1749
+ }));
1750
+ }
1751
+ const names = targetType.getProperties().map((propertySymbol) => propertySymbol.getName()).filter((name) => name.startsWith(completionTarget.prefix)).filter((name, index, collection) => collection.indexOf(name) === index).sort();
1752
+ return names.map((name) => ({
1753
+ name,
1754
+ kind: isCallableProperty(targetType, name, context.checker) ? "method" : "property"
1755
+ }));
1756
+ }
1757
+ __name(getRsxCompletionsAtPosition, "getRsxCompletionsAtPosition");
1758
+ function getRsxDiagnosticsForFile(program, fileName) {
1759
+ const sourceFile = program.getSourceFile(fileName);
1760
+ if (!sourceFile) {
1761
+ return [];
1762
+ }
1763
+ const checker = program.getTypeChecker();
1764
+ const sites = detectExpressionSitesInSourceFile(sourceFile, checker);
1765
+ return sites.flatMap((site) => {
1766
+ const result = validateExpressionSite(site, checker);
1767
+ const literalStart = site.expressionLiteral.getStart(sourceFile) + 1;
1768
+ const literalEnd = site.expressionLiteral.getEnd() - 1;
1769
+ const expressionText = site.expression;
1770
+ return result.diagnostics.map((diagnostic) => {
1771
+ const tokenRange = resolveDiagnosticTokenRangeInExpression({
1772
+ expression: expressionText,
1773
+ token: diagnostic.token
1774
+ });
1775
+ const start = tokenRange === null ? literalStart : literalStart + tokenRange.start;
1776
+ const end = tokenRange === null ? literalEnd : literalStart + tokenRange.end;
1777
+ return {
1778
+ category: diagnostic.category,
1779
+ message: diagnostic.message,
1780
+ start,
1781
+ end
1782
+ };
1783
+ });
1784
+ });
1785
+ }
1786
+ __name(getRsxDiagnosticsForFile, "getRsxDiagnosticsForFile");
1787
+ function resolveDiagnosticTokenRangeInExpression(args) {
1788
+ const { expression, token } = args;
1789
+ if (!token) {
1790
+ return null;
1791
+ }
1792
+ const escapedToken = token.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
1793
+ const pattern = new RegExp(`\\b${escapedToken}\\b`, "u");
1794
+ const match = pattern.exec(expression);
1795
+ if (!match || typeof match.index !== "number") {
1796
+ return null;
1797
+ }
1798
+ return {
1799
+ start: match.index,
1800
+ end: match.index + token.length
1801
+ };
1802
+ }
1803
+ __name(resolveDiagnosticTokenRangeInExpression, "resolveDiagnosticTokenRangeInExpression");
1804
+ function getRsxHoverAtPosition(program, fileName, position) {
1805
+ const context = resolveExpressionContext(program, fileName, position);
1806
+ if (!context) {
1807
+ return null;
1808
+ }
1809
+ const expressionOffset = position - context.expressionStart;
1810
+ const tokenRange = resolveIdentifierTokenRange(context.expression, expressionOffset);
1811
+ if (!tokenRange) {
1812
+ return null;
1813
+ }
1814
+ const textToTokenEnd = context.expression.slice(0, tokenRange.end);
1815
+ const chain = resolveChainFromSuffix(textToTokenEnd);
1816
+ if (!chain.length) {
1817
+ return null;
1818
+ }
1819
+ const resolvedType = resolveChainType(context.modelType, chain, context.checker);
1820
+ if (!resolvedType) {
1821
+ return null;
1822
+ }
1823
+ return {
1824
+ text: context.checker.typeToString(resolvedType),
1825
+ start: context.expressionStart + tokenRange.start,
1826
+ end: context.expressionStart + tokenRange.end
1827
+ };
1828
+ }
1829
+ __name(getRsxHoverAtPosition, "getRsxHoverAtPosition");
1830
+ function getRsxSignatureHelpAtPosition(program, fileName, position) {
1831
+ const context = resolveExpressionContext(program, fileName, position);
1832
+ if (!context) {
1833
+ return null;
1834
+ }
1835
+ const expressionOffset = position - context.expressionStart;
1836
+ const prefixSource = context.expression.slice(0, expressionOffset);
1837
+ const activeCall = resolveActiveCallContext(prefixSource);
1838
+ if (!activeCall) {
1839
+ return null;
1840
+ }
1841
+ const callableType = resolveCallableType(context.modelType, activeCall.chain, context.sourceFile, context.checker, activeCall.isConstructorCall);
1842
+ if (!callableType) {
1843
+ return null;
1844
+ }
1845
+ const signatures = activeCall.isConstructorCall ? callableType.getConstructSignatures() : callableType.getCallSignatures();
1846
+ if (signatures.length === 0) {
1847
+ return null;
1848
+ }
1849
+ const items = signatures.map((signature) => {
1850
+ const parameters = signature.getParameters().map((parameter) => {
1851
+ const declaration = parameter.valueDeclaration ?? parameter.declarations?.[0];
1852
+ const typeText = declaration ? context.checker.typeToString(context.checker.getTypeOfSymbolAtLocation(parameter, declaration)) : "unknown";
1853
+ const declarations = parameter.declarations ?? [];
1854
+ const isOptionalByDeclaration = declarations.some((node) => ts3.isParameter(node) && (Boolean(node.questionToken) || Boolean(node.initializer)));
1855
+ const isRest = declarations.some((node) => ts3.isParameter(node) && Boolean(node.dotDotDotToken));
1856
+ return {
1857
+ name: parameter.getName(),
1858
+ typeText,
1859
+ isOptional: (parameter.flags & ts3.SymbolFlags.Optional) !== 0 || isOptionalByDeclaration,
1860
+ isRest
1861
+ };
1862
+ });
1863
+ return {
1864
+ parameters,
1865
+ returnTypeText: context.checker.typeToString(signature.getReturnType())
1866
+ };
1867
+ });
1868
+ return {
1869
+ items,
1870
+ argumentIndex: activeCall.argumentIndex,
1871
+ argumentCount: activeCall.argumentCount,
1872
+ applicableStart: context.expressionStart + activeCall.applicableStartOffset,
1873
+ applicableEnd: context.expressionStart + activeCall.applicableEndOffset
1874
+ };
1875
+ }
1876
+ __name(getRsxSignatureHelpAtPosition, "getRsxSignatureHelpAtPosition");
1877
+ function resolveExpressionContext(program, fileName, position) {
1878
+ const sourceFile = program.getSourceFile(fileName);
1879
+ if (!sourceFile) {
1880
+ return null;
1881
+ }
1882
+ const checker = program.getTypeChecker();
1883
+ const sites = detectExpressionSitesInSourceFile(sourceFile, checker);
1884
+ for (const site of sites) {
1885
+ const expressionStart = site.expressionLiteral.getStart(sourceFile) + 1;
1886
+ const expressionEnd = site.expressionLiteral.getEnd() - 1;
1887
+ if (position < expressionStart || position > expressionEnd) {
1888
+ continue;
1889
+ }
1890
+ const modelNode = site.callExpression.arguments[0];
1891
+ if (!modelNode) {
1892
+ return null;
1893
+ }
1894
+ return {
1895
+ sourceFile,
1896
+ expression: site.expression,
1897
+ expressionStart,
1898
+ expressionEnd,
1899
+ modelType: checker.getTypeAtLocation(modelNode),
1900
+ checker
1901
+ };
1902
+ }
1903
+ return null;
1904
+ }
1905
+ __name(resolveExpressionContext, "resolveExpressionContext");
1906
+ function resolveCompletionTarget(prefixSource) {
1907
+ const chainMatch = prefixSource.match(/([A-Za-z_$][\w$]*(?:(?:\(\))|(?:\[\d+\]))?(?:\.[A-Za-z_$][\w$]*(?:(?:\(\))|(?:\[\d+\]))?)*)\.([A-Za-z_$][\w$]*)?$/u);
1908
+ if (chainMatch) {
1909
+ return {
1910
+ chain: splitChain(chainMatch[1]),
1911
+ prefix: chainMatch[2] ?? ""
1912
+ };
1913
+ }
1914
+ const trailingDotChainMatch = prefixSource.match(/([A-Za-z_$][\w$]*(?:(?:\(\))|(?:\[\d+\]))?(?:\.[A-Za-z_$][\w$]*(?:(?:\(\))|(?:\[\d+\]))?)*)\.$/u);
1915
+ if (trailingDotChainMatch) {
1916
+ return {
1917
+ chain: splitChain(trailingDotChainMatch[1]),
1918
+ prefix: ""
1919
+ };
1920
+ }
1921
+ const rootPrefixMatch = prefixSource.match(/([A-Za-z_$][\w$]*)$/u);
1922
+ return {
1923
+ chain: [],
1924
+ prefix: rootPrefixMatch?.[1] ?? ""
1925
+ };
1926
+ }
1927
+ __name(resolveCompletionTarget, "resolveCompletionTarget");
1928
+ function resolveIdentifierTokenRange(expression, offset) {
1929
+ const isIdentifierChar = /* @__PURE__ */ __name((char) => /[A-Za-z0-9_$]/u.test(char), "isIdentifierChar");
1930
+ if (offset < 0 || offset > expression.length) {
1931
+ return null;
1932
+ }
1933
+ let start = offset;
1934
+ let end = offset;
1935
+ if (offset < expression.length && isIdentifierChar(expression[offset])) {
1936
+ start = offset;
1937
+ end = offset + 1;
1938
+ } else if (offset > 0 && isIdentifierChar(expression[offset - 1])) {
1939
+ start = offset - 1;
1940
+ end = offset;
1941
+ } else {
1942
+ return null;
1943
+ }
1944
+ while (start > 0 && isIdentifierChar(expression[start - 1])) {
1945
+ start -= 1;
1946
+ }
1947
+ while (end < expression.length && isIdentifierChar(expression[end])) {
1948
+ end += 1;
1949
+ }
1950
+ return {
1951
+ start,
1952
+ end
1953
+ };
1954
+ }
1955
+ __name(resolveIdentifierTokenRange, "resolveIdentifierTokenRange");
1956
+ function resolveChainFromSuffix(prefix) {
1957
+ const chainMatch = prefix.match(/([A-Za-z_$][\w$]*(?:\(\))?(?:\.[A-Za-z_$][\w$]*(?:\(\))?)*)$/u);
1958
+ if (!chainMatch) {
1959
+ return [];
1960
+ }
1961
+ return splitChain(chainMatch[1]);
1962
+ }
1963
+ __name(resolveChainFromSuffix, "resolveChainFromSuffix");
1964
+ function splitChain(chainText) {
1965
+ return chainText.split(".").filter(Boolean);
1966
+ }
1967
+ __name(splitChain, "splitChain");
1968
+ function resolveChainType(modelType, chain, checker) {
1969
+ let currentType = modelType;
1970
+ for (const segment of chain) {
1971
+ if (!currentType) {
1972
+ return null;
1973
+ }
1974
+ currentType = unwrapRsxExpressionType2(currentType, checker);
1975
+ const arrayIndexMatch = segment.match(/^([A-Za-z_$][\w$]*)?\[(\d+)\]$/u);
1976
+ if (arrayIndexMatch) {
1977
+ const propName = arrayIndexMatch[1];
1978
+ let typeToIndex = currentType;
1979
+ if (propName) {
1980
+ const property2 = typeToIndex.getProperty(propName);
1981
+ if (!property2) return null;
1982
+ const declaration2 = property2.valueDeclaration ?? property2.declarations?.[0];
1983
+ if (!declaration2) return null;
1984
+ typeToIndex = checker.getNonNullableType(unwrapRsxExpressionType2(checker.getTypeOfSymbolAtLocation(property2, declaration2), checker));
1985
+ }
1986
+ const numberIndexType = typeToIndex.getNumberIndexType();
1987
+ if (numberIndexType) {
1988
+ currentType = checker.getNonNullableType(unwrapRsxExpressionType2(numberIndexType, checker));
1989
+ } else {
1990
+ const typeArgs = checker.getTypeArguments(typeToIndex);
1991
+ if (typeArgs.length > 0 && typeArgs[0]) {
1992
+ currentType = checker.getNonNullableType(unwrapRsxExpressionType2(typeArgs[0], checker));
1993
+ } else {
1994
+ return null;
1995
+ }
1996
+ }
1997
+ continue;
1998
+ }
1999
+ const isMethodCall = segment.endsWith("()");
2000
+ const name = isMethodCall ? segment.slice(0, -2) : segment;
2001
+ const property = currentType.getProperty(name);
2002
+ if (!property) {
2003
+ return null;
2004
+ }
2005
+ const declaration = property.valueDeclaration ?? property.declarations?.[0];
2006
+ if (!declaration) {
2007
+ return null;
2008
+ }
2009
+ const propertyType = checker.getTypeOfSymbolAtLocation(property, declaration);
2010
+ if (!isMethodCall) {
2011
+ currentType = checker.getNonNullableType(unwrapRsxExpressionType2(propertyType, checker));
2012
+ continue;
2013
+ }
2014
+ const signatures = propertyType.getCallSignatures();
2015
+ if (signatures.length === 0) {
2016
+ return null;
2017
+ }
2018
+ currentType = checker.getNonNullableType(unwrapRsxExpressionType2(signatures[0].getReturnType(), checker));
2019
+ }
2020
+ return currentType;
2021
+ }
2022
+ __name(resolveChainType, "resolveChainType");
2023
+ function resolveCallableType(modelType, chain, sourceFile, checker, isConstructorCall) {
2024
+ if (chain.length === 0) {
2025
+ return null;
2026
+ }
2027
+ if (isConstructorCall) {
2028
+ return resolveConstructorType(chain, sourceFile, checker);
2029
+ }
2030
+ const containerChain = chain.slice(0, -1);
2031
+ const callableName = chain[chain.length - 1];
2032
+ if (!callableName || callableName.endsWith("()")) {
2033
+ return null;
2034
+ }
2035
+ const containerType = containerChain.length ? resolveChainType(modelType, containerChain, checker) : modelType;
2036
+ if (!containerType) {
2037
+ return null;
2038
+ }
2039
+ const callableProperty = containerType.getProperty(callableName);
2040
+ if (!callableProperty) {
2041
+ return null;
2042
+ }
2043
+ const declaration = callableProperty.valueDeclaration ?? callableProperty.declarations?.[0];
2044
+ if (!declaration) {
2045
+ return null;
2046
+ }
2047
+ return unwrapRsxExpressionType2(checker.getTypeOfSymbolAtLocation(callableProperty, declaration), checker);
2048
+ }
2049
+ __name(resolveCallableType, "resolveCallableType");
2050
+ function resolveActiveCallContext(prefixSource) {
2051
+ const callStack = [];
2052
+ let inSingleQuote = false;
2053
+ let inDoubleQuote = false;
2054
+ let inTemplate = false;
2055
+ let escaped = false;
2056
+ for (let index = 0; index < prefixSource.length; index += 1) {
2057
+ const char = prefixSource[index];
2058
+ if (escaped) {
2059
+ escaped = false;
2060
+ continue;
2061
+ }
2062
+ if (inSingleQuote) {
2063
+ if (char === "\\") {
2064
+ escaped = true;
2065
+ } else if (char === "'") {
2066
+ inSingleQuote = false;
2067
+ }
2068
+ continue;
2069
+ }
2070
+ if (inDoubleQuote) {
2071
+ if (char === "\\") {
2072
+ escaped = true;
2073
+ } else if (char === '"') {
2074
+ inDoubleQuote = false;
2075
+ }
2076
+ continue;
2077
+ }
2078
+ if (inTemplate) {
2079
+ if (char === "\\") {
2080
+ escaped = true;
2081
+ } else if (char === "`") {
2082
+ inTemplate = false;
2083
+ }
2084
+ continue;
2085
+ }
2086
+ if (char === "'") {
2087
+ inSingleQuote = true;
2088
+ continue;
2089
+ }
2090
+ if (char === '"') {
2091
+ inDoubleQuote = true;
2092
+ continue;
2093
+ }
2094
+ if (char === "`") {
2095
+ inTemplate = true;
2096
+ continue;
2097
+ }
2098
+ if (char === "(") {
2099
+ callStack.push({
2100
+ openOffset: index,
2101
+ commaCount: 0
2102
+ });
2103
+ continue;
2104
+ }
2105
+ if (char === ")") {
2106
+ if (callStack.length > 0) {
2107
+ callStack.pop();
2108
+ }
2109
+ continue;
2110
+ }
2111
+ if (char === "," && callStack.length > 0) {
2112
+ const activeCall2 = callStack[callStack.length - 1];
2113
+ activeCall2.commaCount += 1;
2114
+ }
2115
+ }
2116
+ if (callStack.length === 0) {
2117
+ return null;
2118
+ }
2119
+ const activeCall = callStack[callStack.length - 1];
2120
+ const callTargetSource = prefixSource.slice(0, activeCall.openOffset).trimEnd();
2121
+ const chainMatch = callTargetSource.match(/([A-Za-z_$][\w$]*(?:\(\))?(?:\.[A-Za-z_$][\w$]*(?:\(\))?)*)$/u);
2122
+ if (!chainMatch) {
2123
+ return null;
2124
+ }
2125
+ const chain = splitChain(chainMatch[1]);
2126
+ const constructorMatch = callTargetSource.match(/(?:^|[^\w$])new\s+([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)$/u);
2127
+ const hasArgumentText = prefixSource.slice(activeCall.openOffset + 1).trim().length > 0;
2128
+ return {
2129
+ chain,
2130
+ isConstructorCall: Boolean(constructorMatch) && constructorMatch?.[1] === chainMatch[1],
2131
+ argumentIndex: activeCall.commaCount,
2132
+ argumentCount: hasArgumentText ? activeCall.commaCount + 1 : 0,
2133
+ applicableStartOffset: activeCall.openOffset + 1,
2134
+ applicableEndOffset: prefixSource.length
2135
+ };
2136
+ }
2137
+ __name(resolveActiveCallContext, "resolveActiveCallContext");
2138
+ function resolveConstructorCompletionPrefix(prefixSource) {
2139
+ const constructorPrefixMatch = prefixSource.match(/(?:^|[^\w$])new\s+([A-Za-z_$][\w$]*)?$/u);
2140
+ if (!constructorPrefixMatch) {
2141
+ return null;
2142
+ }
2143
+ return constructorPrefixMatch[1] ?? "";
2144
+ }
2145
+ __name(resolveConstructorCompletionPrefix, "resolveConstructorCompletionPrefix");
2146
+ function resolveConstructorCompletions(context, prefix) {
2147
+ const constructableNames = context.checker.getSymbolsInScope(context.sourceFile, ts3.SymbolFlags.Value | ts3.SymbolFlags.Type | ts3.SymbolFlags.Namespace | ts3.SymbolFlags.Alias).filter((symbol) => !symbol.getName().startsWith("__")).filter((symbol) => symbol.getName().startsWith(prefix)).filter((symbol) => resolveConstructableTypeFromSymbol(symbol, context.sourceFile, context.checker) !== null).map((symbol) => symbol.getName()).filter((name, index, collection) => collection.indexOf(name) === index).sort();
2148
+ return constructableNames.map((name) => ({
2149
+ name,
2150
+ kind: "constructor"
2151
+ }));
2152
+ }
2153
+ __name(resolveConstructorCompletions, "resolveConstructorCompletions");
2154
+ function resolveConstructorType(chain, sourceFile, checker) {
2155
+ const [rootName, ...rest] = chain;
2156
+ if (!rootName) {
2157
+ return null;
2158
+ }
2159
+ const rootSymbol = checker.getSymbolsInScope(sourceFile, ts3.SymbolFlags.Value | ts3.SymbolFlags.Type | ts3.SymbolFlags.Namespace | ts3.SymbolFlags.Alias).find((symbol) => symbol.getName() === rootName);
2160
+ if (!rootSymbol) {
2161
+ return null;
2162
+ }
2163
+ const rootType = resolveConstructableTypeFromSymbol(rootSymbol, sourceFile, checker);
2164
+ if (!rootType) {
2165
+ return null;
2166
+ }
2167
+ if (rest.length === 0) {
2168
+ return rootType;
2169
+ }
2170
+ let currentType = rootType;
2171
+ for (const segment of rest) {
2172
+ if (!currentType) {
2173
+ return null;
2174
+ }
2175
+ const property = currentType.getProperty(segment);
2176
+ if (!property) {
2177
+ return null;
2178
+ }
2179
+ const declaration = property.valueDeclaration ?? property.declarations?.[0];
2180
+ if (!declaration) {
2181
+ return null;
2182
+ }
2183
+ currentType = checker.getTypeOfSymbolAtLocation(property, declaration);
2184
+ }
2185
+ return currentType;
2186
+ }
2187
+ __name(resolveConstructorType, "resolveConstructorType");
2188
+ function resolveConstructableTypeFromSymbol(symbol, sourceFile, checker) {
2189
+ const resolvedSymbol = symbol.flags & ts3.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
2190
+ const declaration = resolvedSymbol.valueDeclaration ?? resolvedSymbol.declarations?.[0] ?? symbol.valueDeclaration ?? symbol.declarations?.[0] ?? sourceFile;
2191
+ const symbolType = checker.getTypeOfSymbolAtLocation(resolvedSymbol, declaration);
2192
+ if (symbolType.getConstructSignatures().length > 0) {
2193
+ return symbolType;
2194
+ }
2195
+ return null;
2196
+ }
2197
+ __name(resolveConstructableTypeFromSymbol, "resolveConstructableTypeFromSymbol");
2198
+ function isCallableProperty(targetType, name, checker) {
2199
+ const property = targetType.getProperty(name);
2200
+ if (!property) {
2201
+ return false;
2202
+ }
2203
+ const declaration = property.valueDeclaration ?? property.declarations?.[0];
2204
+ if (!declaration) {
2205
+ return false;
2206
+ }
2207
+ const propertyType = unwrapRsxExpressionType2(checker.getTypeOfSymbolAtLocation(property, declaration), checker);
2208
+ return propertyType.getCallSignatures().length > 0;
2209
+ }
2210
+ __name(isCallableProperty, "isCallableProperty");
2211
+ function unwrapRsxExpressionType2(type, checker) {
2212
+ const symbol = type.aliasSymbol ?? type.getSymbol();
2213
+ if (symbol?.getName() === "IExpression") {
2214
+ const typeArguments = checker.getTypeArguments(type);
2215
+ if (typeArguments.length > 0) {
2216
+ return typeArguments[0];
2217
+ }
2218
+ }
2219
+ const hasExpressionShape = type.getProperty("value") && type.getProperty("expressionString") && type.getProperty("childExpressions") && type.getProperty("changed");
2220
+ if (!hasExpressionShape) {
2221
+ return type;
2222
+ }
2223
+ const valueProperty = type.getProperty("value");
2224
+ const declaration = valueProperty?.valueDeclaration ?? valueProperty?.declarations?.[0];
2225
+ if (!valueProperty || !declaration) {
2226
+ return type;
2227
+ }
2228
+ return checker.getTypeOfSymbolAtLocation(valueProperty, declaration);
2229
+ }
2230
+ __name(unwrapRsxExpressionType2, "unwrapRsxExpressionType");
2231
+
2232
+ // lib/language-service/index.ts
2233
+ function createLanguageServiceScaffold() {
2234
+ return {
2235
+ folder: "language-service",
2236
+ supportsIntelliSense: true
2237
+ };
2238
+ }
2239
+ __name(createLanguageServiceScaffold, "createLanguageServiceScaffold");
2240
+
2241
+ // lib/transformer/index.ts
2242
+ function createTransformerScaffold() {
2243
+ return {
2244
+ folder: "transformer",
2245
+ enabled: false
2246
+ };
2247
+ }
2248
+ __name(createTransformerScaffold, "createTransformerScaffold");
2249
+ export {
2250
+ classifyParserError,
2251
+ createCompilerScaffold,
2252
+ createDiagnosticsScaffold,
2253
+ createLanguageServiceScaffold,
2254
+ createTransformerScaffold,
2255
+ detectExpressionSites,
2256
+ detectExpressionSitesInSourceFile,
2257
+ findRsxExpressionLiteralRanges,
2258
+ findRsxExpressionRegionAtPosition,
2259
+ generateAotCompiledExpressionsModule,
2260
+ generateAotLazyExpressionPreloadManifestModule,
2261
+ generateAotParsedExpressionCacheModule,
2262
+ getRsxCompletionsAtPosition,
2263
+ getRsxDiagnosticsForFile,
2264
+ getRsxHoverAtPosition,
2265
+ getRsxSignatureHelpAtPosition,
2266
+ isDateLikeType,
2267
+ parseExpressionDiagnostic,
2268
+ supportedDateProperties,
2269
+ tokenizeRsxExpression,
2270
+ validateExpressionSite,
2271
+ validateExpressionSites
2272
+ };