@glint/ember-tsc 1.0.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/LICENSE +21 -0
- package/README.md +49 -0
- package/bin/ember-tsc.js +4 -0
- package/bin/glint-language-server.js +2 -0
- package/lib/cli/run-volar-tsc.d.ts +2 -0
- package/lib/cli/run-volar-tsc.d.ts.map +1 -0
- package/lib/cli/run-volar-tsc.js +30 -0
- package/lib/cli/run-volar-tsc.js.map +1 -0
- package/lib/config/config.d.ts +15 -0
- package/lib/config/config.d.ts.map +1 -0
- package/lib/config/config.js +21 -0
- package/lib/config/config.js.map +1 -0
- package/lib/config/environment.d.ts +26 -0
- package/lib/config/environment.d.ts.map +1 -0
- package/lib/config/environment.js +96 -0
- package/lib/config/environment.js.map +1 -0
- package/lib/config/index.d.ts +17 -0
- package/lib/config/index.d.ts.map +1 -0
- package/lib/config/index.js +26 -0
- package/lib/config/index.js.map +1 -0
- package/lib/config/loader.d.ts +25 -0
- package/lib/config/loader.d.ts.map +1 -0
- package/lib/config/loader.js +110 -0
- package/lib/config/loader.js.map +1 -0
- package/lib/config/types.cjs +3 -0
- package/lib/config/types.cjs.map +1 -0
- package/lib/config/types.d.cts +60 -0
- package/lib/config/types.d.cts.map +1 -0
- package/lib/environment-ember-template-imports/-private/environment/common.d.ts +13 -0
- package/lib/environment-ember-template-imports/-private/environment/common.d.ts.map +1 -0
- package/lib/environment-ember-template-imports/-private/environment/common.js +2 -0
- package/lib/environment-ember-template-imports/-private/environment/common.js.map +1 -0
- package/lib/environment-ember-template-imports/-private/environment/index.d.ts +3 -0
- package/lib/environment-ember-template-imports/-private/environment/index.d.ts.map +1 -0
- package/lib/environment-ember-template-imports/-private/environment/index.js +76 -0
- package/lib/environment-ember-template-imports/-private/environment/index.js.map +1 -0
- package/lib/environment-ember-template-imports/-private/environment/preprocess.d.ts +4 -0
- package/lib/environment-ember-template-imports/-private/environment/preprocess.d.ts.map +1 -0
- package/lib/environment-ember-template-imports/-private/environment/preprocess.js +73 -0
- package/lib/environment-ember-template-imports/-private/environment/preprocess.js.map +1 -0
- package/lib/environment-ember-template-imports/-private/environment/transform.d.ts +4 -0
- package/lib/environment-ember-template-imports/-private/environment/transform.d.ts.map +1 -0
- package/lib/environment-ember-template-imports/-private/environment/transform.js +134 -0
- package/lib/environment-ember-template-imports/-private/environment/transform.js.map +1 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +6 -0
- package/lib/index.js.map +1 -0
- package/lib/plugins/g-compiler-errors.d.ts +12 -0
- package/lib/plugins/g-compiler-errors.d.ts.map +1 -0
- package/lib/plugins/g-compiler-errors.js +58 -0
- package/lib/plugins/g-compiler-errors.js.map +1 -0
- package/lib/plugins/g-template-tag-symbols.d.ts +11 -0
- package/lib/plugins/g-template-tag-symbols.d.ts.map +1 -0
- package/lib/plugins/g-template-tag-symbols.js +48 -0
- package/lib/plugins/g-template-tag-symbols.js.map +1 -0
- package/lib/plugins/utils.d.ts +25 -0
- package/lib/plugins/utils.d.ts.map +1 -0
- package/lib/plugins/utils.js +63 -0
- package/lib/plugins/utils.js.map +1 -0
- package/lib/transform/diagnostics/augmentation.d.ts +4 -0
- package/lib/transform/diagnostics/augmentation.d.ts.map +1 -0
- package/lib/transform/diagnostics/augmentation.js +223 -0
- package/lib/transform/diagnostics/augmentation.js.map +1 -0
- package/lib/transform/diagnostics/index.d.ts +5 -0
- package/lib/transform/diagnostics/index.d.ts.map +1 -0
- package/lib/transform/diagnostics/index.js +2 -0
- package/lib/transform/diagnostics/index.js.map +1 -0
- package/lib/transform/index.d.ts +4 -0
- package/lib/transform/index.d.ts.map +1 -0
- package/lib/transform/index.js +2 -0
- package/lib/transform/index.js.map +1 -0
- package/lib/transform/template/code-features.d.ts +30 -0
- package/lib/transform/template/code-features.d.ts.map +1 -0
- package/lib/transform/template/code-features.js +26 -0
- package/lib/transform/template/code-features.js.map +1 -0
- package/lib/transform/template/glimmer-ast-mapping-tree.d.ts +80 -0
- package/lib/transform/template/glimmer-ast-mapping-tree.d.ts.map +1 -0
- package/lib/transform/template/glimmer-ast-mapping-tree.js +132 -0
- package/lib/transform/template/glimmer-ast-mapping-tree.js.map +1 -0
- package/lib/transform/template/inlining/index.d.ts +16 -0
- package/lib/transform/template/inlining/index.d.ts.map +1 -0
- package/lib/transform/template/inlining/index.js +21 -0
- package/lib/transform/template/inlining/index.js.map +1 -0
- package/lib/transform/template/inlining/tagged-strings.d.ts +8 -0
- package/lib/transform/template/inlining/tagged-strings.d.ts.map +1 -0
- package/lib/transform/template/inlining/tagged-strings.js +140 -0
- package/lib/transform/template/inlining/tagged-strings.js.map +1 -0
- package/lib/transform/template/map-template-contents.d.ts +121 -0
- package/lib/transform/template/map-template-contents.d.ts.map +1 -0
- package/lib/transform/template/map-template-contents.js +287 -0
- package/lib/transform/template/map-template-contents.js.map +1 -0
- package/lib/transform/template/rewrite-module.d.ts +22 -0
- package/lib/transform/template/rewrite-module.d.ts.map +1 -0
- package/lib/transform/template/rewrite-module.js +265 -0
- package/lib/transform/template/rewrite-module.js.map +1 -0
- package/lib/transform/template/scope-stack.d.ts +13 -0
- package/lib/transform/template/scope-stack.d.ts.map +1 -0
- package/lib/transform/template/scope-stack.js +28 -0
- package/lib/transform/template/scope-stack.js.map +1 -0
- package/lib/transform/template/template-to-typescript.d.ts +19 -0
- package/lib/transform/template/template-to-typescript.d.ts.map +1 -0
- package/lib/transform/template/template-to-typescript.js +1095 -0
- package/lib/transform/template/template-to-typescript.js.map +1 -0
- package/lib/transform/template/transformed-module.d.ts +111 -0
- package/lib/transform/template/transformed-module.d.ts.map +1 -0
- package/lib/transform/template/transformed-module.js +287 -0
- package/lib/transform/template/transformed-module.js.map +1 -0
- package/lib/transform/util.d.ts +7 -0
- package/lib/transform/util.d.ts.map +1 -0
- package/lib/transform/util.js +15 -0
- package/lib/transform/util.js.map +1 -0
- package/lib/volar/ember-language-plugin.d.ts +14 -0
- package/lib/volar/ember-language-plugin.d.ts.map +1 -0
- package/lib/volar/ember-language-plugin.js +91 -0
- package/lib/volar/ember-language-plugin.js.map +1 -0
- package/lib/volar/gts-virtual-code.d.ts +83 -0
- package/lib/volar/gts-virtual-code.d.ts.map +1 -0
- package/lib/volar/gts-virtual-code.js +210 -0
- package/lib/volar/gts-virtual-code.js.map +1 -0
- package/lib/volar/language-server.d.ts +2 -0
- package/lib/volar/language-server.d.ts.map +1 -0
- package/lib/volar/language-server.js +214 -0
- package/lib/volar/language-server.js.map +1 -0
- package/lib/volar/script-snapshot.d.ts +17 -0
- package/lib/volar/script-snapshot.d.ts.map +1 -0
- package/lib/volar/script-snapshot.js +24 -0
- package/lib/volar/script-snapshot.js.map +1 -0
- package/package.json +104 -0
- package/src/cli/run-volar-tsc.ts +36 -0
- package/src/config/config.ts +33 -0
- package/src/config/environment.ts +128 -0
- package/src/config/index.ts +30 -0
- package/src/config/loader.ts +143 -0
- package/src/config/types.cts +85 -0
- package/src/environment-ember-template-imports/-private/environment/common.ts +14 -0
- package/src/environment-ember-template-imports/-private/environment/index.ts +83 -0
- package/src/environment-ember-template-imports/-private/environment/preprocess.ts +90 -0
- package/src/environment-ember-template-imports/-private/environment/transform.ts +202 -0
- package/src/index.ts +9 -0
- package/src/plugins/g-compiler-errors.ts +67 -0
- package/src/plugins/g-template-tag-symbols.ts +54 -0
- package/src/plugins/utils.ts +86 -0
- package/src/transform/diagnostics/augmentation.ts +333 -0
- package/src/transform/diagnostics/index.ts +5 -0
- package/src/transform/index.ts +4 -0
- package/src/transform/template/code-features.ts +30 -0
- package/src/transform/template/glimmer-ast-mapping-tree.ts +173 -0
- package/src/transform/template/inlining/index.ts +33 -0
- package/src/transform/template/inlining/tagged-strings.ts +187 -0
- package/src/transform/template/map-template-contents.ts +501 -0
- package/src/transform/template/rewrite-module.ts +372 -0
- package/src/transform/template/scope-stack.ts +34 -0
- package/src/transform/template/template-to-typescript.ts +1476 -0
- package/src/transform/template/transformed-module.ts +431 -0
- package/src/transform/util.ts +24 -0
- package/src/volar/ember-language-plugin.ts +108 -0
- package/src/volar/gts-virtual-code.ts +249 -0
- package/src/volar/language-server.ts +250 -0
- package/src/volar/script-snapshot.ts +27 -0
- package/types/-private/dsl/globals.d.ts +204 -0
- package/types/-private/dsl/index.d.ts +50 -0
- package/types/-private/dsl/integration-declarations.d.ts +143 -0
- package/types/-private/intrinsics/action.d.ts +45 -0
- package/types/-private/intrinsics/concat.d.ts +6 -0
- package/types/-private/intrinsics/each-in.d.ts +24 -0
- package/types/-private/intrinsics/each.d.ts +17 -0
- package/types/-private/intrinsics/fn.d.ts +44 -0
- package/types/-private/intrinsics/get.d.ts +31 -0
- package/types/-private/intrinsics/input.d.ts +24 -0
- package/types/-private/intrinsics/link-to.d.ts +31 -0
- package/types/-private/intrinsics/log.d.ts +6 -0
- package/types/-private/intrinsics/mount.d.ts +9 -0
- package/types/-private/intrinsics/mut.d.ts +14 -0
- package/types/-private/intrinsics/on.d.ts +21 -0
- package/types/-private/intrinsics/outlet.d.ts +8 -0
- package/types/-private/intrinsics/textarea.d.ts +16 -0
- package/types/-private/intrinsics/unbound.d.ts +10 -0
- package/types/-private/intrinsics/unique-id.d.ts +5 -0
- package/types/globals/index.d.ts +3 -0
- package/types/silent-error.d.ts +4 -0
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
export function augmentDiagnostics(transformedModule, diagnostics) {
|
|
2
|
+
const mappingForDiagnostic = (diagnostic) => {
|
|
3
|
+
if (!transformedModule) {
|
|
4
|
+
return [];
|
|
5
|
+
}
|
|
6
|
+
if (!diagnostic.start || !diagnostic.length) {
|
|
7
|
+
return [];
|
|
8
|
+
}
|
|
9
|
+
const start = diagnostic.start;
|
|
10
|
+
const end = start + diagnostic.length;
|
|
11
|
+
return transformedModule.getExactTransformedRanges(transformedModule.originalFileName, start, end);
|
|
12
|
+
};
|
|
13
|
+
const augmentedDiagnostics = [];
|
|
14
|
+
for (const diagnostic of diagnostics) {
|
|
15
|
+
const augmentedDiagnostic = rewriteMessageText(diagnostic, mappingForDiagnostic);
|
|
16
|
+
augmentedDiagnostics.push(augmentedDiagnostic);
|
|
17
|
+
}
|
|
18
|
+
// @ts-expect-error not sure how to fix
|
|
19
|
+
return augmentedDiagnostics;
|
|
20
|
+
}
|
|
21
|
+
function rewriteMessageText(diagnostic, mappingGetter) {
|
|
22
|
+
const handler = diagnosticHandlers[diagnostic.code?.toString() ?? ''];
|
|
23
|
+
if (!handler) {
|
|
24
|
+
return diagnostic;
|
|
25
|
+
}
|
|
26
|
+
for (let mapping of mappingGetter(diagnostic)) {
|
|
27
|
+
const augmentedDiagnostic = handler(diagnostic, mapping);
|
|
28
|
+
if (augmentedDiagnostic) {
|
|
29
|
+
return augmentedDiagnostic;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return diagnostic;
|
|
33
|
+
}
|
|
34
|
+
const diagnosticHandlers = {
|
|
35
|
+
'2307': checkGlintLibImports, // TS2307: An import cannot be found.
|
|
36
|
+
'2322': checkAssignabilityError, // TS2322: Type 'X' is not assignable to type 'Y'.
|
|
37
|
+
'2345': checkAssignabilityError, // TS2345: Argument of type 'X' is not assignable to parameter of type 'Y'.
|
|
38
|
+
'2554': noteNamedArgsAffectArity, // TS2554: Expected N arguments, but got M.
|
|
39
|
+
'2555': noteNamedArgsAffectArity, // TS2555: Expected at least N arguments, but got M.
|
|
40
|
+
'2769': checkResolveError, // TS2769: No overload matches this call.
|
|
41
|
+
'4111': checkIndexAccessError, // TS4111: Property 'x' comes from an index signature, so it must be accessed with ['x'].
|
|
42
|
+
'7053': checkImplicitAnyError, // TS7053: Element implicitly has an 'any' type because expression of type '"X"' can't be used to index type 'Y'.
|
|
43
|
+
};
|
|
44
|
+
const bindHelpers = ['component', 'helper', 'modifier'];
|
|
45
|
+
function checkGlintLibImports(diagnostic, _mapping) {
|
|
46
|
+
let messageText = typeof diagnostic.messageText === 'string'
|
|
47
|
+
? diagnostic.messageText
|
|
48
|
+
: diagnostic.messageText.messageText;
|
|
49
|
+
const typesModules = '@glint/ember-tsc/-private/dsl';
|
|
50
|
+
if (messageText.includes(typesModules)) {
|
|
51
|
+
return addGlintDetails(diagnostic, 'You appear to be using version 2 of the Glint VS Code extension ' +
|
|
52
|
+
'(or a v2 Glint plugin for another IDE), but your package.json still ' +
|
|
53
|
+
'references version 1 Glint dependencies (or they are missing). You need to either upgrade your `@glint/core` ' +
|
|
54
|
+
'and `@glint/template` project dependencies, or downgrade your VS Code Glint extension to version 1.x. ' +
|
|
55
|
+
'Please see the Glint v2 release notes and upgrade guide for more information.');
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
return diagnostic;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function checkAssignabilityError(diagnostic, mapping) {
|
|
62
|
+
let node = mapping.sourceNode;
|
|
63
|
+
let parentNode = mapping.parent?.sourceNode;
|
|
64
|
+
if (!parentNode)
|
|
65
|
+
return;
|
|
66
|
+
if (parentNode.type === node.type) {
|
|
67
|
+
// For Volar, we added a few more artificial nestings / wrappings around Handlebars
|
|
68
|
+
// AST nodes to provide more hookpoints for TS diagnostics to correctly source-map
|
|
69
|
+
// back to .gts/.hbs source code. The result of this is that sometimes you have
|
|
70
|
+
// things like MustacheNodes being "parents" of MustacheNodes, which we try and
|
|
71
|
+
// detect here.
|
|
72
|
+
//
|
|
73
|
+
// This can go away if/when we refactor the `transformModule` code.
|
|
74
|
+
parentNode = mapping.parent?.parent?.sourceNode;
|
|
75
|
+
if (!parentNode)
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (node.type === 'Identifier' &&
|
|
79
|
+
parentNode.type === 'AttrNode' &&
|
|
80
|
+
!/^(@|\.)/.test(parentNode.name)) {
|
|
81
|
+
// If the assignability issue is on an attribute name and it's not an `@arg`
|
|
82
|
+
// or `...attributes`, then it's an HTML attribute type issue.
|
|
83
|
+
return addGlintDetails(diagnostic, 'Only primitive values (see `AttrValue` in `@glint/template`) are assignable as HTML attributes. ' +
|
|
84
|
+
'If you want to set an event listener, consider using the `{{on}}` modifier instead.');
|
|
85
|
+
}
|
|
86
|
+
else if (node.type === 'AttrNode' &&
|
|
87
|
+
parentNode.type === 'ElementNode' &&
|
|
88
|
+
!/^(@|\.)/.test(node.name)) {
|
|
89
|
+
// If the assignability issue is on an attribute name and it's not an `@arg`
|
|
90
|
+
// or `...attributes`, then it's an HTML attribute type issue.
|
|
91
|
+
return addGlintDetails(diagnostic, 'An Element must be specified in the component signature in order to pass in HTML attributes.');
|
|
92
|
+
}
|
|
93
|
+
else if (node.type === 'MustacheStatement' &&
|
|
94
|
+
(parentNode.type === 'Template' ||
|
|
95
|
+
parentNode.type === 'BlockStatement' ||
|
|
96
|
+
parentNode.type === 'ElementNode') &&
|
|
97
|
+
!(node.path.type === 'PathExpression' && node.path.original === 'yield')) {
|
|
98
|
+
// If we're looking at a top-level {{mustache}}, we first double check whether
|
|
99
|
+
// it's an attempted inline {{component 'foo'}} invocation...
|
|
100
|
+
if (node.path.type === 'PathExpression' && node.path.original === 'component') {
|
|
101
|
+
return addGlintDetails(diagnostic, `The {{component}} helper can't be used to directly invoke a component under Glint. ` +
|
|
102
|
+
`Consider first binding the result to a variable, e.g. ` +
|
|
103
|
+
`'{{#let (component 'component-name') as |ComponentName|}}' and then invoking it as ` +
|
|
104
|
+
`'<ComponentName @arg={{value}} />'.`);
|
|
105
|
+
}
|
|
106
|
+
// Otherwise, it's a DOM content type issue.
|
|
107
|
+
return addGlintDetails(diagnostic, 'Only primitive values and certain DOM objects (see `ContentValue` in `@glint/template`) are ' +
|
|
108
|
+
'usable as top-level template content.');
|
|
109
|
+
}
|
|
110
|
+
else if ((mapping?.sourceNode.type === 'SubExpression' ||
|
|
111
|
+
mapping?.sourceNode.type === 'MustacheStatement') &&
|
|
112
|
+
mapping.sourceNode.path.type === 'PathExpression' &&
|
|
113
|
+
bindHelpers.includes(mapping.sourceNode.path.original)) {
|
|
114
|
+
// If we're looking at a binding helper subexpression like `(component ...)`, error messages
|
|
115
|
+
// may be very straightforward or may be horrendously complex when users start playing games
|
|
116
|
+
// with parametrized types, so we add a hint here.
|
|
117
|
+
let kind = mapping.sourceNode.path.original;
|
|
118
|
+
return {
|
|
119
|
+
...diagnostic,
|
|
120
|
+
messageText: `Unable to pre-bind the given args to the given ${kind}. This likely indicates a type mismatch between its signature and the values you're passing.`,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function noteNamedArgsAffectArity(diagnostic, mapping) {
|
|
125
|
+
// In normal template entity invocations, named args (if specified) are effectively
|
|
126
|
+
// passed as the final positional argument. Because of this, the reported "expected
|
|
127
|
+
// N arguments, but got M" message may appear to be off-by-one to the developer.
|
|
128
|
+
// Since this treatment of named args as a final "options hash" argument is user
|
|
129
|
+
// visible in cases like type errors, we can't just paper over this by subtracting
|
|
130
|
+
// 1 from the numbers in the message. Instead, if the invocation has named args, we
|
|
131
|
+
// explicitly note that they're effectively the final positional parameter.
|
|
132
|
+
let callNode = findAncestor(mapping, 'MustacheStatement', 'SubExpression');
|
|
133
|
+
if (callNode?.path.type === 'PathExpression' && callNode.path.original === 'yield') {
|
|
134
|
+
// Yield is directly transformed rather than being treated as a normal mustache
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
let hasNamedArgs = !!callNode?.hash.pairs.length;
|
|
138
|
+
if (hasNamedArgs) {
|
|
139
|
+
let note = 'Note that named args are passed together as a final argument, so they ' +
|
|
140
|
+
'collectively increase the given arg count by 1.';
|
|
141
|
+
return {
|
|
142
|
+
...diagnostic,
|
|
143
|
+
messageText: `${diagnostic.messageText} ${note}`,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
function checkResolveError(diagnostic, mapping) {
|
|
148
|
+
// The diagnostic might fall on a lone identifier or a full path; if the former,
|
|
149
|
+
// we need to traverse up through the path to find the true parent.
|
|
150
|
+
let sourceMapping = mapping.sourceNode.type === 'Identifier' ? mapping.parent : mapping;
|
|
151
|
+
let parentNode = sourceMapping?.parent?.sourceNode;
|
|
152
|
+
// If this error is on the first param to a {{component}} or other bind invocation, this means
|
|
153
|
+
// we either have a non-component value or a string that's missing from the registry.
|
|
154
|
+
if ((parentNode?.type === 'SubExpression' || parentNode?.type === 'MustacheStatement') &&
|
|
155
|
+
parentNode.path.type === 'PathExpression' &&
|
|
156
|
+
bindHelpers.includes(parentNode.path.original) &&
|
|
157
|
+
parentNode.params[0] === sourceMapping?.sourceNode) {
|
|
158
|
+
let kind = parentNode.path.original;
|
|
159
|
+
if (sourceMapping.sourceNode.type === 'StringLiteral') {
|
|
160
|
+
return addGlintDetails(diagnostic, `Unknown ${kind} name '${sourceMapping.sourceNode.value}'. If this isn't a typo, you may be ` +
|
|
161
|
+
`missing a registry entry for this name; see the Template Registry page in the Glint ` +
|
|
162
|
+
`documentation for more details.`);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
return addGlintDetails(diagnostic, `The type of this expression doesn't appear to be a valid value to pass the {{${kind}}} ` +
|
|
166
|
+
`helper. If possible, you may need to give the expression a narrower type, ` +
|
|
167
|
+
`for example \`'thing-a' | 'thing-b'\` rather than \`string\`.`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
// Otherwise if this is on a top level invocation, we're trying to use a template-unaware
|
|
171
|
+
// value in a template-specific way.
|
|
172
|
+
let nodeType = sourceMapping?.sourceNode.type;
|
|
173
|
+
if (nodeType === 'ElementNode' || nodeType === 'PathExpression' || nodeType === 'Identifier') {
|
|
174
|
+
return addGlintDetails(diagnostic, 'The given value does not appear to be usable as a component, modifier or helper.');
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function checkImplicitAnyError(diagnostic, mapping) {
|
|
178
|
+
let message = diagnostic.messageText;
|
|
179
|
+
// We don't want to bake in assumptions about the exact format of TS error messages,
|
|
180
|
+
// but we can assume that the name of the type we're indexing (`Globals`) will appear
|
|
181
|
+
// in the text in the case we're interested in.
|
|
182
|
+
if (typeof message === 'string' && message.includes('Globals')) {
|
|
183
|
+
let { sourceNode } = mapping;
|
|
184
|
+
// This error may appear either on `<Foo />` or `{{foo}}`/`(foo)`
|
|
185
|
+
let globalName = sourceNode.type === 'ElementNode'
|
|
186
|
+
? sourceNode.path.head.original
|
|
187
|
+
: sourceNode.type === 'PathExpression' && sourceNode.head.type === 'VarHead'
|
|
188
|
+
? sourceNode.head.name
|
|
189
|
+
: null;
|
|
190
|
+
if (globalName) {
|
|
191
|
+
return addGlintDetails(diagnostic, `Unknown name '${globalName}'. If this isn't a typo, you may be missing a registry entry ` +
|
|
192
|
+
`for this value; see the Template Registry page in the Glint documentation for more details.`);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
function checkIndexAccessError(diagnostic, mapping) {
|
|
197
|
+
if (mapping.sourceNode.type === 'Identifier' && typeof diagnostic.messageText === 'string') {
|
|
198
|
+
let message = diagnostic.messageText;
|
|
199
|
+
// "accessed with ['x']" => "accessed with {{get ... 'x'}}"
|
|
200
|
+
return {
|
|
201
|
+
...diagnostic,
|
|
202
|
+
messageText: message.replace(/\[(['"])(.*)\1\]/, `{{get ... $1$2$1}}`),
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
function addGlintDetails(diagnostic, details) {
|
|
207
|
+
return {
|
|
208
|
+
...diagnostic,
|
|
209
|
+
messageText: `${details}\n${diagnostic.messageText}`,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
// Find the nearest mapping node at or above the given one whose `source` AST node
|
|
213
|
+
// matches one of the given types.
|
|
214
|
+
function findAncestor(mapping, ...types) {
|
|
215
|
+
let current = mapping;
|
|
216
|
+
do {
|
|
217
|
+
if (types.includes(current.sourceNode.type)) {
|
|
218
|
+
return current.sourceNode;
|
|
219
|
+
}
|
|
220
|
+
} while ((current = current.parent));
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
//# sourceMappingURL=augmentation.js.map
|
|
@@ -0,0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AAW,EAAE,OAAO,CAAC,OAAO,CAAC,kBAAkB,EAAE,oBAAoB,CAAC;SACvE,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CAAC,UAAsB,EAAE,OAAe;IAC9D,OAAO;QACL,GAAG,UAAU;QACb,WAAW,EAAE,GAAG,OAAO,KAAK,UAAU,CAAC,WAAW,EAAE;KACrD,CAAC;AACJ,CAAC;AAED,kFAAkF;AAClF,kCAAkC;AAClC,SAAS,YAAY,CACnB,OAA8B,EAC9B,GAAG,KAAe;IAElB,IAAI,OAAO,GAAiC,OAAO,CAAC;IACpD,GAAG,CAAC;QACF,IAAI,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,IAAS,CAAC,EAAE,CAAC;YACjD,OAAO,OAAO,CAAC,UAAiD,CAAC;QACnE,CAAC;IACH,CAAC,QAAQ,CAAC,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE;IACrC,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transform/diagnostics/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,MAAM,UAAU,GAAG,EAAE,CAAC,UAAU,GAAG;IACvC,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/transform/diagnostics/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transform/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,SAAS,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAChG,YAAY,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transform/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { CodeInformation } from '@volar/language-server/node.js';
|
|
2
|
+
/**
|
|
3
|
+
* Based on https://github.com/machty/vue-language-tools/blob/deff856aa8c15f691544e646519215a15aacbef1/packages/language-core/lib/codegen/codeFeatures.ts
|
|
4
|
+
*
|
|
5
|
+
* This file exports a "code features" object which provides a useful shorthand/shortcut
|
|
6
|
+
* for specifying a nubmer of Volar CodeInformation configuration options in the code
|
|
7
|
+
* we use for mapping between source code (e.g. .gts files) and transformed (i.e. type-checkable TS) code.
|
|
8
|
+
*
|
|
9
|
+
* Volar uses the CodeInformation we pass along with each mapping to determine what sort of language
|
|
10
|
+
* features should be activated/processed for a given span of code.
|
|
11
|
+
*/
|
|
12
|
+
declare const raw: {
|
|
13
|
+
all: {
|
|
14
|
+
verification: true;
|
|
15
|
+
completion: true;
|
|
16
|
+
semantic: true;
|
|
17
|
+
navigation: true;
|
|
18
|
+
};
|
|
19
|
+
withoutHighlight: {
|
|
20
|
+
semantic: {
|
|
21
|
+
shouldHighlight: () => false;
|
|
22
|
+
};
|
|
23
|
+
verification: true;
|
|
24
|
+
navigation: true;
|
|
25
|
+
completion: true;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export declare const codeFeatures: { [K in keyof typeof raw]: CodeInformation; };
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=code-features.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-features.d.ts","sourceRoot":"","sources":["../../../src/transform/template/code-features.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE;;;;;;;;;GASG;AACH,QAAA,MAAM,GAAG;;;;;;;;;;;;;;;CAakC,CAAC;AAE5C,eAAO,MAAM,YAAY,EAAU,GAChC,CAAC,IAAI,MAAM,OAAO,GAAG,GAAG,eAAe,GACzC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Based on https://github.com/machty/vue-language-tools/blob/deff856aa8c15f691544e646519215a15aacbef1/packages/language-core/lib/codegen/codeFeatures.ts
|
|
3
|
+
*
|
|
4
|
+
* This file exports a "code features" object which provides a useful shorthand/shortcut
|
|
5
|
+
* for specifying a nubmer of Volar CodeInformation configuration options in the code
|
|
6
|
+
* we use for mapping between source code (e.g. .gts files) and transformed (i.e. type-checkable TS) code.
|
|
7
|
+
*
|
|
8
|
+
* Volar uses the CodeInformation we pass along with each mapping to determine what sort of language
|
|
9
|
+
* features should be activated/processed for a given span of code.
|
|
10
|
+
*/
|
|
11
|
+
const raw = {
|
|
12
|
+
all: {
|
|
13
|
+
verification: true,
|
|
14
|
+
completion: true,
|
|
15
|
+
semantic: true,
|
|
16
|
+
navigation: true,
|
|
17
|
+
},
|
|
18
|
+
withoutHighlight: {
|
|
19
|
+
semantic: { shouldHighlight: () => false },
|
|
20
|
+
verification: true,
|
|
21
|
+
navigation: true,
|
|
22
|
+
completion: true,
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
export const codeFeatures = raw;
|
|
26
|
+
//# sourceMappingURL=code-features.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-features.js","sourceRoot":"","sources":["../../../src/transform/template/code-features.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,MAAM,GAAG,GAAG;IACV,GAAG,EAAE;QACH,YAAY,EAAE,IAAI;QAClB,UAAU,EAAE,IAAI;QAChB,QAAQ,EAAE,IAAI;QACd,UAAU,EAAE,IAAI;KACjB;IACD,gBAAgB,EAAE;QAChB,QAAQ,EAAE,EAAE,eAAe,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE;QAC1C,YAAY,EAAE,IAAI;QAClB,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,IAAI;KACjB;CACwC,CAAC;AAE5C,MAAM,CAAC,MAAM,YAAY,GAAG,GAE3B,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { AST } from '@glimmer/syntax';
|
|
2
|
+
import { Range } from './transformed-module.js';
|
|
3
|
+
import { Identifier } from './map-template-contents.js';
|
|
4
|
+
import { CodeInformation } from '@volar/language-server/node.js';
|
|
5
|
+
export type MappingSource = AST.Node | TemplateEmbedding | TextContent | Identifier | ParseError;
|
|
6
|
+
/**
|
|
7
|
+
* In cases where we're unable to parse a template, we still want to
|
|
8
|
+
* be able to hold a placeholder mapping so that we can respond sensibly
|
|
9
|
+
* to offset transformation queries. This class acts as a standin for
|
|
10
|
+
* the proper AST node we were unable to obtain in such cases.
|
|
11
|
+
*/
|
|
12
|
+
export declare class ParseError {
|
|
13
|
+
readonly type = "ParseError";
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The Glimmer AST uses `TextNode` for both string arg values on elements
|
|
17
|
+
* and for top-level text content floating in the DOM itself. Since we
|
|
18
|
+
* want to treat the two differently (namely, string args may have useful
|
|
19
|
+
* completion suggestions but plain text doesn't), we use a stand-in
|
|
20
|
+
* node for the latter.
|
|
21
|
+
*/
|
|
22
|
+
export declare class TextContent {
|
|
23
|
+
readonly type = "TextContent";
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* This node represents the root of an embedded template, including
|
|
27
|
+
* the surrounding `<template>...</template>` boilerplate that designates
|
|
28
|
+
* the surrounded contents as a template.
|
|
29
|
+
*/
|
|
30
|
+
export declare class TemplateEmbedding {
|
|
31
|
+
readonly type = "TemplateEmbedding";
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A `MappingTree` maintains a hierarchy of mappings between ranges of
|
|
35
|
+
* locations in original and transformed source strings. These mappings
|
|
36
|
+
* are naturally hierarchical due to the tree structure of the underlying
|
|
37
|
+
* code.
|
|
38
|
+
*
|
|
39
|
+
* For instance, given an expression like `{{foo.bar}}` in a template, a
|
|
40
|
+
* corresponding expression in TypeScript might be `foo?.bar`. The individual
|
|
41
|
+
* identifiers `foo` and `bar` map directly to one another, but the full
|
|
42
|
+
* expressions do as well. By maintaining a full hierarchy of these mappings,
|
|
43
|
+
* we can always report diagnostics in the template at roughly the same
|
|
44
|
+
* level of granularity as TS itself uses when reporting on the transformed
|
|
45
|
+
* output.
|
|
46
|
+
*/
|
|
47
|
+
export default class GlimmerASTMappingTree {
|
|
48
|
+
transformedRange: Range;
|
|
49
|
+
originalRange: Range;
|
|
50
|
+
children: Array<GlimmerASTMappingTree>;
|
|
51
|
+
sourceNode: MappingSource;
|
|
52
|
+
codeInformation?: CodeInformation | undefined;
|
|
53
|
+
parent: GlimmerASTMappingTree | null;
|
|
54
|
+
constructor(transformedRange: Range, originalRange: Range, children: Array<GlimmerASTMappingTree> | undefined, sourceNode: MappingSource, codeInformation?: CodeInformation | undefined);
|
|
55
|
+
/**
|
|
56
|
+
* Returns the mapping corresponding to the smallest span in the transformed source
|
|
57
|
+
* that contains the given range, or `null` if that range doesn't fall within
|
|
58
|
+
* this mapping tree.
|
|
59
|
+
*/
|
|
60
|
+
narrowestMappingForTransformedRange(range: Range): GlimmerASTMappingTree | null;
|
|
61
|
+
/**
|
|
62
|
+
* Returns the mapping corresponding to the smallest span in the original source
|
|
63
|
+
* that contains the given range, or `null` if that range doesn't fall within
|
|
64
|
+
* this mapping tree.
|
|
65
|
+
*/
|
|
66
|
+
narrowestMappingForOriginalRange(range: Range): GlimmerASTMappingTree | null;
|
|
67
|
+
/**
|
|
68
|
+
* Returns all mappings that exactly match the provided range.
|
|
69
|
+
*/
|
|
70
|
+
exactMappingsForOriginalRange(range: Range): GlimmerASTMappingTree[];
|
|
71
|
+
toDebugString(options: {
|
|
72
|
+
originalStart: number;
|
|
73
|
+
originalSource: string;
|
|
74
|
+
transformedStart: number;
|
|
75
|
+
transformedSource: string;
|
|
76
|
+
indent?: string;
|
|
77
|
+
}): string;
|
|
78
|
+
private getSourceRange;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=glimmer-ast-mapping-tree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glimmer-ast-mapping-tree.d.ts","sourceRoot":"","sources":["../../../src/transform/template/glimmer-ast-mapping-tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,IAAI,GAAG,iBAAiB,GAAG,WAAW,GAAG,UAAU,GAAG,UAAU,CAAC;AAEjG;;;;;GAKG;AACH,qBAAa,UAAU;IACrB,SAAgB,IAAI,gBAAgB;CACrC;AAED;;;;;;GAMG;AACH,qBAAa,WAAW;IACtB,SAAgB,IAAI,iBAAiB;CACtC;AAED;;;;GAIG;AACH,qBAAa,iBAAiB;IAC5B,SAAgB,IAAI,uBAAuB;CAC5C;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,OAAO,qBAAqB;IAI/B,gBAAgB,EAAE,KAAK;IACvB,aAAa,EAAE,KAAK;IACpB,QAAQ,EAAE,KAAK,CAAC,qBAAqB,CAAC;IACtC,UAAU,EAAE,aAAa;IACzB,eAAe,CAAC,EAAE,eAAe;IAPnC,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAAQ;gBAG1C,gBAAgB,EAAE,KAAK,EACvB,aAAa,EAAE,KAAK,EACpB,QAAQ,EAAE,KAAK,CAAC,qBAAqB,CAAC,YAAK,EAC3C,UAAU,EAAE,aAAa,EACzB,eAAe,CAAC,EAAE,eAAe,YAAA;IAK1C;;;;OAIG;IACI,mCAAmC,CAAC,KAAK,EAAE,KAAK,GAAG,qBAAqB,GAAG,IAAI;IAetF;;;;OAIG;IACI,gCAAgC,CAAC,KAAK,EAAE,KAAK,GAAG,qBAAqB,GAAG,IAAI;IAenF;;OAEG;IACI,6BAA6B,CAAC,KAAK,EAAE,KAAK,GAAG,qBAAqB,EAAE;IAkBpE,aAAa,CAAC,OAAO,EAAE;QAC5B,aAAa,EAAE,MAAM,CAAC;QACtB,cAAc,EAAE,MAAM,CAAC;QACvB,gBAAgB,EAAE,MAAM,CAAC;QACzB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,GAAG,MAAM;IAsCV,OAAO,CAAC,cAAc;CAGvB"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In cases where we're unable to parse a template, we still want to
|
|
3
|
+
* be able to hold a placeholder mapping so that we can respond sensibly
|
|
4
|
+
* to offset transformation queries. This class acts as a standin for
|
|
5
|
+
* the proper AST node we were unable to obtain in such cases.
|
|
6
|
+
*/
|
|
7
|
+
export class ParseError {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.type = 'ParseError';
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The Glimmer AST uses `TextNode` for both string arg values on elements
|
|
14
|
+
* and for top-level text content floating in the DOM itself. Since we
|
|
15
|
+
* want to treat the two differently (namely, string args may have useful
|
|
16
|
+
* completion suggestions but plain text doesn't), we use a stand-in
|
|
17
|
+
* node for the latter.
|
|
18
|
+
*/
|
|
19
|
+
export class TextContent {
|
|
20
|
+
constructor() {
|
|
21
|
+
this.type = 'TextContent';
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* This node represents the root of an embedded template, including
|
|
26
|
+
* the surrounding `<template>...</template>` boilerplate that designates
|
|
27
|
+
* the surrounded contents as a template.
|
|
28
|
+
*/
|
|
29
|
+
export class TemplateEmbedding {
|
|
30
|
+
constructor() {
|
|
31
|
+
this.type = 'TemplateEmbedding';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A `MappingTree` maintains a hierarchy of mappings between ranges of
|
|
36
|
+
* locations in original and transformed source strings. These mappings
|
|
37
|
+
* are naturally hierarchical due to the tree structure of the underlying
|
|
38
|
+
* code.
|
|
39
|
+
*
|
|
40
|
+
* For instance, given an expression like `{{foo.bar}}` in a template, a
|
|
41
|
+
* corresponding expression in TypeScript might be `foo?.bar`. The individual
|
|
42
|
+
* identifiers `foo` and `bar` map directly to one another, but the full
|
|
43
|
+
* expressions do as well. By maintaining a full hierarchy of these mappings,
|
|
44
|
+
* we can always report diagnostics in the template at roughly the same
|
|
45
|
+
* level of granularity as TS itself uses when reporting on the transformed
|
|
46
|
+
* output.
|
|
47
|
+
*/
|
|
48
|
+
export default class GlimmerASTMappingTree {
|
|
49
|
+
constructor(transformedRange, originalRange, children = [], sourceNode, codeInformation) {
|
|
50
|
+
this.transformedRange = transformedRange;
|
|
51
|
+
this.originalRange = originalRange;
|
|
52
|
+
this.children = children;
|
|
53
|
+
this.sourceNode = sourceNode;
|
|
54
|
+
this.codeInformation = codeInformation;
|
|
55
|
+
this.parent = null;
|
|
56
|
+
children.forEach((child) => (child.parent = this));
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Returns the mapping corresponding to the smallest span in the transformed source
|
|
60
|
+
* that contains the given range, or `null` if that range doesn't fall within
|
|
61
|
+
* this mapping tree.
|
|
62
|
+
*/
|
|
63
|
+
narrowestMappingForTransformedRange(range) {
|
|
64
|
+
if (range.start < this.transformedRange.start || range.end > this.transformedRange.end) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
for (let child of this.children) {
|
|
68
|
+
let mapping = child.narrowestMappingForTransformedRange(range);
|
|
69
|
+
if (mapping) {
|
|
70
|
+
return mapping;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Returns the mapping corresponding to the smallest span in the original source
|
|
77
|
+
* that contains the given range, or `null` if that range doesn't fall within
|
|
78
|
+
* this mapping tree.
|
|
79
|
+
*/
|
|
80
|
+
narrowestMappingForOriginalRange(range) {
|
|
81
|
+
if (range.start < this.originalRange.start || range.end > this.originalRange.end) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
for (let child of this.children) {
|
|
85
|
+
let mapping = child.narrowestMappingForOriginalRange(range);
|
|
86
|
+
if (mapping) {
|
|
87
|
+
return mapping;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return this;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Returns all mappings that exactly match the provided range.
|
|
94
|
+
*/
|
|
95
|
+
exactMappingsForOriginalRange(range) {
|
|
96
|
+
const results = [];
|
|
97
|
+
if (range.start < this.originalRange.start || range.end > this.originalRange.end) {
|
|
98
|
+
return results;
|
|
99
|
+
}
|
|
100
|
+
if (range.start == this.originalRange.start && range.end == this.originalRange.end) {
|
|
101
|
+
results.push(this);
|
|
102
|
+
}
|
|
103
|
+
for (let child of this.children) {
|
|
104
|
+
results.push(...child.exactMappingsForOriginalRange(range));
|
|
105
|
+
}
|
|
106
|
+
return results;
|
|
107
|
+
}
|
|
108
|
+
toDebugString(options) {
|
|
109
|
+
let { originalSource, transformedSource, indent = '| ' } = options;
|
|
110
|
+
let { sourceNode, originalRange, transformedRange, children } = this;
|
|
111
|
+
let hbsStart = options.originalStart + originalRange.start;
|
|
112
|
+
let hbsEnd = options.originalStart + originalRange.end;
|
|
113
|
+
let tsStart = options.transformedStart + transformedRange.start;
|
|
114
|
+
let tsEnd = options.transformedStart + transformedRange.end;
|
|
115
|
+
let lines = [];
|
|
116
|
+
lines.push(`${indent}Mapping: ${sourceNode.type}`);
|
|
117
|
+
lines.push(`${indent}${` hbs(${hbsStart}:${hbsEnd}):`.padEnd(15)}${this.getSourceRange(originalSource, originalRange)}`);
|
|
118
|
+
lines.push(`${indent}${` ts(${tsStart}:${tsEnd}):`.padEnd(15)}${this.getSourceRange(transformedSource, transformedRange)}`);
|
|
119
|
+
lines.push(indent);
|
|
120
|
+
for (let child of children) {
|
|
121
|
+
lines.push(child.toDebugString({ ...options, indent: indent + '| ' }));
|
|
122
|
+
}
|
|
123
|
+
if (children.length) {
|
|
124
|
+
lines.push(indent);
|
|
125
|
+
}
|
|
126
|
+
return lines.map((line) => line.trimEnd()).join('\n');
|
|
127
|
+
}
|
|
128
|
+
getSourceRange(source, range) {
|
|
129
|
+
return source.slice(range.start, range.end).trim().replace(/\n/g, '\\n').replace(/\r/g, '\\r');
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=glimmer-ast-mapping-tree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glimmer-ast-mapping-tree.js","sourceRoot":"","sources":["../../../src/transform/template/glimmer-ast-mapping-tree.ts"],"names":[],"mappings":"AAOA;;;;;GAKG;AACH,MAAM,OAAO,UAAU;IAAvB;QACkB,SAAI,GAAG,YAAY,CAAC;IACtC,CAAC;CAAA;AAED;;;;;;GAMG;AACH,MAAM,OAAO,WAAW;IAAxB;QACkB,SAAI,GAAG,aAAa,CAAC;IACvC,CAAC;CAAA;AAED;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IAA9B;QACkB,SAAI,GAAG,mBAAmB,CAAC;IAC7C,CAAC;CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,OAAO,qBAAqB;IAGxC,YACS,gBAAuB,EACvB,aAAoB,EACpB,WAAyC,EAAE,EAC3C,UAAyB,EACzB,eAAiC;QAJjC,qBAAgB,GAAhB,gBAAgB,CAAO;QACvB,kBAAa,GAAb,aAAa,CAAO;QACpB,aAAQ,GAAR,QAAQ,CAAmC;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,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,cAAc,CACzE,cAAc,EACd,aAAa,CACd,EAAE,CACJ,CAAC;QAEF,KAAK,CAAC,IAAI,CACR,GAAG,MAAM,GAAG,OAAO,OAAO,IAAI,KAAK,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,cAAc,CACtE,iBAAiB,EACjB,gBAAgB,CACjB,EAAE,CACJ,CAAC;QAEF,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAEnB,KAAK,IAAI,KAAK,IAAI,QAAQ,EAAE,CAAC;YAC3B,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC;QACzE,CAAC;QAED,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC;YACpB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACrB,CAAC;QAED,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxD,CAAC;IAEO,cAAc,CAAC,MAAc,EAAE,KAAY;QACjD,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACjG,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type ts from 'typescript';
|
|
2
|
+
import { CorrelatedSpan, Directive, TransformError } from '../transformed-module.js';
|
|
3
|
+
import { TSLib } from '../../util.js';
|
|
4
|
+
export type PartialCorrelatedSpan = Omit<CorrelatedSpan, 'transformedStart' | 'transformedLength'>;
|
|
5
|
+
export type CorrelatedSpansResult = {
|
|
6
|
+
errors: Array<TransformError>;
|
|
7
|
+
directives: Array<Directive>;
|
|
8
|
+
partialSpans: Array<PartialCorrelatedSpan>;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Given an AST node for an embedded template, determines whether it's embedded
|
|
12
|
+
* within a class in such a way that that class should be treated as its backing
|
|
13
|
+
* value.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isEmbeddedInClass(ts: TSLib, node: ts.Node): boolean;
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/transform/template/inlining/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACrF,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,MAAM,MAAM,qBAAqB,GAAG,IAAI,CAAC,cAAc,EAAE,kBAAkB,GAAG,mBAAmB,CAAC,CAAC;AAEnG,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IAC9B,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAC7B,YAAY,EAAE,KAAK,CAAC,qBAAqB,CAAC,CAAC;CAC5C,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,OAAO,CAenE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Given an AST node for an embedded template, determines whether it's embedded
|
|
3
|
+
* within a class in such a way that that class should be treated as its backing
|
|
4
|
+
* value.
|
|
5
|
+
*/
|
|
6
|
+
export function isEmbeddedInClass(ts, node) {
|
|
7
|
+
let current = node;
|
|
8
|
+
do {
|
|
9
|
+
// TODO: this should likely actually filter on whether the template appears in a
|
|
10
|
+
// static block or property definition, but just "am I in a class body" is the
|
|
11
|
+
// current status quo and has been ok so far.
|
|
12
|
+
if (ts.isHeritageClause(current)) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
if (ts.isClassLike(current)) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
} while ((current = current.parent));
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/transform/template/inlining/index.ts"],"names":[],"mappings":"AAYA;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAAS,EAAE,IAAa;IACxD,IAAI,OAAO,GAAmB,IAAI,CAAC;IACnC,GAAG,CAAC;QACF,gFAAgF;QAChF,8EAA8E;QAC9E,6CAA6C;QAC7C,IAAI,EAAE,CAAC,gBAAgB,CAAC,OAAO,CAAC,EAAE,CAAC;YACjC,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IAAI,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC,QAAQ,CAAC,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE;IAErC,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { GlintEmitMetadata } from '@glint/ember-tsc/config-types';
|
|
2
|
+
import type ts from 'typescript';
|
|
3
|
+
import { GlintEnvironment } from '../../../config/index.js';
|
|
4
|
+
import { TSLib } from '../../util.js';
|
|
5
|
+
import { SourceFile } from '../transformed-module.js';
|
|
6
|
+
import { CorrelatedSpansResult } from './index.js';
|
|
7
|
+
export declare function calculateTaggedTemplateSpans(ts: TSLib, node: ts.TaggedTemplateExpression, meta: GlintEmitMetadata | undefined, script: SourceFile, environment: GlintEnvironment): CorrelatedSpansResult;
|
|
8
|
+
//# sourceMappingURL=tagged-strings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tagged-strings.d.ts","sourceRoot":"","sources":["../../../../src/transform/template/inlining/tagged-strings.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAIlB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAU,KAAK,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EAAoB,UAAU,EAAkB,MAAM,0BAA0B,CAAC;AACxF,OAAO,EAAE,qBAAqB,EAA4C,MAAM,YAAY,CAAC;AAE7F,wBAAgB,4BAA4B,CAC1C,EAAE,EAAE,KAAK,EACT,IAAI,EAAE,EAAE,CAAC,wBAAwB,EACjC,IAAI,EAAE,iBAAiB,GAAG,SAAS,EACnC,MAAM,EAAE,UAAU,EAClB,WAAW,EAAE,gBAAgB,GAC5B,qBAAqB,CAsFvB"}
|