diff --git a/.vscode/launch.json b/.vscode/launch.json index 18e2f5bc0..f6605d35d 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -75,6 +75,8 @@ "lifeart.vscode-glimmer-syntax", "--disable-extension", "unifiedjs.vscode-mdx", + "--disable-extension", + "Vue.volar", "${workspaceFolder}/test-packages/ts-plugin-test-app" ] }, diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c0faa13cb..c1387f76d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -65,13 +65,13 @@ Glint transforms template code into TypeScript code so that it can be type-check ```ts static { ({} as typeof import("@glint/environment-ember-loose/-private/dsl") - .templateForBackingValue(this, function(ššŖ, Ļ‡: typeof import("@glint/environment-ember-loose/-private/dsl")) { + .templateForBackingValue(this, function(__glintRef__, __glintDSL__: typeof import("@glint/environment-ember-loose/-private/dsl")) { { - const š›„ = Ļ‡.emitComponent(Ļ‡.resolve(Ļ‡.Globals["FooComponent"]) - ({ desc: "notchHeight _ footer", ...Ļ‡.NamedArgsMarker })); - š›„; + const __glintY__ = __glintDSL__.emitComponent(__glintDSL__.resolve(__glintDSL__.Globals["FooComponent"]) + ({ desc: "notchHeight _ footer", ...__glintDSL__.NamedArgsMarker })); + __glintY__; { - const [] = š›„.blockParams["default"]; + const [] = __glintY__.blockParams["default"]; { // ... ``` diff --git a/packages/core/__tests__/transform/offset-mapping.test.ts b/packages/core/__tests__/transform/offset-mapping.test.ts index 98f853589..0e630fe9d 100644 --- a/packages/core/__tests__/transform/offset-mapping.test.ts +++ b/packages/core/__tests__/transform/offset-mapping.test.ts @@ -69,7 +69,7 @@ describe.skip('Transform: Source-to-source offset mapping', () => { } function findOccurrence(haystack: string, needle: string, occurrence: number): number { - let offset = haystack.indexOf('function(ššŖ'); + let offset = haystack.indexOf('function(__glintRef__'); for (let i = 0; i < occurrence + 1; i++) { offset = haystack.indexOf(needle, offset + 1); diff --git a/packages/core/__tests__/transform/rewrite.test.ts b/packages/core/__tests__/transform/rewrite.test.ts index 90c8fd224..6bbaee922 100644 --- a/packages/core/__tests__/transform/rewrite.test.ts +++ b/packages/core/__tests__/transform/rewrite.test.ts @@ -25,8 +25,8 @@ describe('Transform: rewriteModule', () => { expect(transformedModule?.transformedContents).toMatchInlineSnapshot(` "import Component from '@glimmer/component'; export default class MyComponent extends Component { - static { ({} as typeof import("@glint/environment-ember-template-imports/-private/dsl")).templateForBackingValue(this, function(ššŖ, Ļ‡: typeof import("@glint/environment-ember-template-imports/-private/dsl")) { - ššŖ; Ļ‡; + static { ({} as typeof import("@glint/environment-ember-template-imports/-private/dsl")).templateForBackingValue(this, function(__glintRef__, __glintDSL__: typeof import("@glint/environment-ember-template-imports/-private/dsl")) { + __glintRef__; __glintDSL__; }) } }" `); @@ -49,8 +49,8 @@ describe('Transform: rewriteModule', () => { expect(transformedModule?.transformedContents).toMatchInlineSnapshot(` "import Component from '@glimmer/component'; export default class MyComponent extends Component<{ value: K }> { - static { ({} as typeof import("@glint/environment-ember-template-imports/-private/dsl")).templateForBackingValue(this, function(ššŖ, Ļ‡: typeof import("@glint/environment-ember-template-imports/-private/dsl")) { - ššŖ; Ļ‡; + static { ({} as typeof import("@glint/environment-ember-template-imports/-private/dsl")).templateForBackingValue(this, function(__glintRef__, __glintDSL__: typeof import("@glint/environment-ember-template-imports/-private/dsl")) { + __glintRef__; __glintDSL__; }) } }" `); @@ -72,8 +72,8 @@ describe('Transform: rewriteModule', () => { expect(transformedModule?.transformedContents).toMatchInlineSnapshot(` "import Component from '@glimmer/component'; export default class extends Component { - static { ({} as typeof import("@glint/environment-ember-template-imports/-private/dsl")).templateForBackingValue(this, function(ššŖ, Ļ‡: typeof import("@glint/environment-ember-template-imports/-private/dsl")) { - ššŖ; Ļ‡; + static { ({} as typeof import("@glint/environment-ember-template-imports/-private/dsl")).templateForBackingValue(this, function(__glintRef__, __glintDSL__: typeof import("@glint/environment-ember-template-imports/-private/dsl")) { + __glintRef__; __glintDSL__; }) } }" `); @@ -98,8 +98,8 @@ describe('Transform: rewriteModule', () => { expect(transformedModule?.transformedContents).toMatchInlineSnapshot(` "import Component from '@glimmer/component'; export default class MyComponent extends Component { - static { ({} as typeof import("@glint/environment-ember-template-imports/-private/dsl")).templateForBackingValue(this, function(ššŖ, Ļ‡: typeof import("@glint/environment-ember-template-imports/-private/dsl")) { - ššŖ; Ļ‡; + static { ({} as typeof import("@glint/environment-ember-template-imports/-private/dsl")).templateForBackingValue(this, function(__glintRef__, __glintDSL__: typeof import("@glint/environment-ember-template-imports/-private/dsl")) { + __glintRef__; __glintDSL__; }) } }" `); @@ -131,8 +131,8 @@ describe('Transform: rewriteModule', () => { "import Component from '@glimmer/component'; export default class MyComponent extends Component { static { - ({} as typeof import("@glint/environment-ember-loose/-private/dsl")).templateForBackingValue(this, function(ššŖ, Ļ‡: typeof import("@glint/environment-ember-loose/-private/dsl")) { - ššŖ; Ļ‡; + ({} as typeof import("@glint/environment-ember-loose/-private/dsl")).templateForBackingValue(this, function(__glintRef__, __glintDSL__: typeof import("@glint/environment-ember-loose/-private/dsl")) { + __glintRef__; __glintDSL__; })} }" `); @@ -161,8 +161,8 @@ describe('Transform: rewriteModule', () => { "import Component from '@glimmer/component'; class MyComponent extends Component { static { - ({} as typeof import("@glint/environment-ember-loose/-private/dsl")).templateForBackingValue(this, function(ššŖ, Ļ‡: typeof import("@glint/environment-ember-loose/-private/dsl")) { - ššŖ; Ļ‡; + ({} as typeof import("@glint/environment-ember-loose/-private/dsl")).templateForBackingValue(this, function(__glintRef__, __glintDSL__: typeof import("@glint/environment-ember-loose/-private/dsl")) { + __glintRef__; __glintDSL__; })} } export default MyComponent;" @@ -191,8 +191,8 @@ describe('Transform: rewriteModule', () => { "import Component from '@glimmer/component'; export default class MyComponent extends Component<{ value: K }> { static { - ({} as typeof import("@glint/environment-ember-loose/-private/dsl")).templateForBackingValue(this, function(ššŖ, Ļ‡: typeof import("@glint/environment-ember-loose/-private/dsl")) { - ššŖ; Ļ‡; + ({} as typeof import("@glint/environment-ember-loose/-private/dsl")).templateForBackingValue(this, function(__glintRef__, __glintDSL__: typeof import("@glint/environment-ember-loose/-private/dsl")) { + __glintRef__; __glintDSL__; })} }" `); @@ -219,8 +219,8 @@ describe('Transform: rewriteModule', () => { "import Component from '@glimmer/component'; export default class extends Component { static { - ({} as typeof import("@glint/environment-ember-loose/-private/dsl")).templateForBackingValue(this, function(ššŖ, Ļ‡: typeof import("@glint/environment-ember-loose/-private/dsl")) { - ššŖ; Ļ‡; + ({} as typeof import("@glint/environment-ember-loose/-private/dsl")).templateForBackingValue(this, function(__glintRef__, __glintDSL__: typeof import("@glint/environment-ember-loose/-private/dsl")) { + __glintRef__; __glintDSL__; })} }" `); @@ -246,9 +246,9 @@ describe('Transform: rewriteModule', () => { expect(transformedModule?.transformedContents).toMatchInlineSnapshot(` "import Component from '@glimmer/component'; export class MyComponent extends Component {} - ({} as typeof import("@glint/environment-ember-loose/-private/dsl")).templateExpression(function(ššŖ, Ļ‡: typeof import("@glint/environment-ember-loose/-private/dsl")) { - Ļ‡.emitContent(Ļ‡.resolveOrReturn(Ļ‡.Globals["hello"])()); - ššŖ; Ļ‡; + ({} as typeof import("@glint/environment-ember-loose/-private/dsl")).templateExpression(function(__glintRef__, __glintDSL__: typeof import("@glint/environment-ember-loose/-private/dsl")) { + __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintDSL__.Globals["hello"])()); + __glintRef__; __glintDSL__; }); " `); @@ -276,8 +276,8 @@ describe('Transform: rewriteModule', () => { "import templateOnly from '@glimmer/component/template-only'; export default templateOnly(); - ({} as typeof import("@glint/environment-ember-loose/-private/dsl")).templateForBackingValue(({} as unknown as typeof import('./test').default), function(ššŖ, Ļ‡: typeof import("@glint/environment-ember-loose/-private/dsl")) { - ššŖ; Ļ‡; + ({} as typeof import("@glint/environment-ember-loose/-private/dsl")).templateForBackingValue(({} as unknown as typeof import('./test').default), function(__glintRef__, __glintDSL__: typeof import("@glint/environment-ember-loose/-private/dsl")) { + __glintRef__; __glintDSL__; }); " `); @@ -305,8 +305,8 @@ describe('Transform: rewriteModule', () => { "import templateOnly from '@glimmer/component/template-only'; export default templateOnly(); - (/** @type {typeof import("@glint/environment-ember-loose/-private/dsl")} */ ({})).templateForBackingValue((/** @type {typeof import('./test').default} */ ({})), function(ššŖ, /** @type {typeof import("@glint/environment-ember-loose/-private/dsl")} */ Ļ‡) { - ššŖ; Ļ‡; + (/** @type {typeof import("@glint/environment-ember-loose/-private/dsl")} */ ({})).templateForBackingValue((/** @type {typeof import('./test').default} */ ({})), function(__glintRef__, /** @type {typeof import("@glint/environment-ember-loose/-private/dsl")} */ __glintDSL__) { + __glintRef__; __glintDSL__; }); " `); @@ -330,9 +330,9 @@ describe('Transform: rewriteModule', () => { expect(transformedModule?.errors).toEqual([]); expect(transformedModule?.transformedContents).toMatchInlineSnapshot(` "export default Foo; - ({} as typeof import("@glint/environment-ember-loose/-private/dsl")).templateForBackingValue(({} as unknown as typeof import('./test').default), function(ššŖ, Ļ‡: typeof import("@glint/environment-ember-loose/-private/dsl")) { - Ļ‡.emitContent(Ļ‡.resolveOrReturn(Ļ‡.Globals["hello"])()); - ššŖ; Ļ‡; + ({} as typeof import("@glint/environment-ember-loose/-private/dsl")).templateForBackingValue(({} as unknown as typeof import('./test').default), function(__glintRef__, __glintDSL__: typeof import("@glint/environment-ember-loose/-private/dsl")) { + __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintDSL__.Globals["hello"])()); + __glintRef__; __glintDSL__; }); " `); @@ -365,8 +365,8 @@ describe('Transform: rewriteModule', () => { "import Component from '@glimmer/component'; export default class MyComponent extends Component { static { - ({} as typeof import("@glint/environment-ember-loose/-private/dsl")).templateForBackingValue(this, function(ššŖ, Ļ‡: typeof import("@glint/environment-ember-loose/-private/dsl")) { - ššŖ; Ļ‡; + ({} as typeof import("@glint/environment-ember-loose/-private/dsl")).templateForBackingValue(this, function(__glintRef__, __glintDSL__: typeof import("@glint/environment-ember-loose/-private/dsl")) { + __glintRef__; __glintDSL__; })} } declare module '@glint/environment-ember-loose/registry' { @@ -401,8 +401,8 @@ describe('Transform: rewriteModule', () => { "import Component from '@glimmer/component'; export default class MyComponent extends Component { static { - ({} as typeof import("@glint/environment-ember-loose/-private/dsl")).templateForBackingValue(this, function(ššŖ, Ļ‡: typeof import("@glint/environment-ember-loose/-private/dsl")) { - ššŖ; Ļ‡; + ({} as typeof import("@glint/environment-ember-loose/-private/dsl")).templateForBackingValue(this, function(__glintRef__, __glintDSL__: typeof import("@glint/environment-ember-loose/-private/dsl")) { + __glintRef__; __glintDSL__; })} }" `); @@ -426,8 +426,8 @@ describe('Transform: rewriteModule', () => { expect(transformedModule?.transformedContents).toMatchInlineSnapshot(` "import Component, { hbs } from 'special/component'; - export default class MyComponent extends Component(({} as typeof import("@glint/environment-ember-template-imports/-private/dsl")).templateExpression(function(ššŖ, Ļ‡: typeof import("@glint/environment-ember-template-imports/-private/dsl")) { - ššŖ; Ļ‡; + export default class MyComponent extends Component(({} as typeof import("@glint/environment-ember-template-imports/-private/dsl")).templateExpression(function(__glintRef__, __glintDSL__: typeof import("@glint/environment-ember-template-imports/-private/dsl")) { + __glintRef__; __glintDSL__; })) { }" @@ -466,42 +466,42 @@ describe('Transform: rewriteModule', () => { | Mapping: TemplateEmbedding | hbs(22:74): - | ts(22:295): static { ({} as typeof import("@glint/environment-ember-template-imports/-private/dsl")).templateForBackingValue(this, function(ššŖ, Ļ‡: typeof import("@glint/environment-ember-template-imports/-private/dsl")) {\\nĻ‡.emitContent(Ļ‡.resolveOrReturn(ššŖ.this.target)());\\nššŖ; Ļ‡;\\n}) } + | ts(22:369): static { ({} as typeof import("@glint/environment-ember-template-imports/-private/dsl")).templateForBackingValue(this, function(__glintRef__, __glintDSL__: typeof import("@glint/environment-ember-template-imports/-private/dsl")) {\\n__glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintRef__.this.target)());\\n__glintRef__; __glintDSL__;\\n}) } | | | Mapping: Template | | hbs(32:63): Hello, {{this.target}}! - | | ts(232:284): Ļ‡.emitContent(Ļ‡.resolveOrReturn(ššŖ.this.target)()); + | | ts(253:337): __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintRef__.this.target)()); | | | | | Mapping: TextContent | | | hbs(37:43): Hello, - | | | ts(232:232): + | | | ts(253:253): | | | | | | Mapping: MustacheStatement | | | hbs(44:59): {{this.target}} - | | | ts(232:282): Ļ‡.emitContent(Ļ‡.resolveOrReturn(ššŖ.this.target)()) + | | | ts(253:335): __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintRef__.this.target)()) | | | | | | | Mapping: MustacheStatement | | | | hbs(44:59): {{this.target}} - | | | | ts(246:281): Ļ‡.resolveOrReturn(ššŖ.this.target)() + | | | | ts(278:334): __glintDSL__.resolveOrReturn(__glintRef__.this.target)() | | | | | | | | | Mapping: PathExpression | | | | | hbs(46:57): this.target - | | | | | ts(264:278): ššŖ.this.target + | | | | | ts(307:331): __glintRef__.this.target | | | | | | | | | | | Mapping: Identifier | | | | | | hbs(46:50): this - | | | | | | ts(267:271): this + | | | | | | ts(320:324): this | | | | | | | | | | | | Mapping: Identifier | | | | | | hbs(51:57): target - | | | | | | ts(272:278): target + | | | | | | ts(325:331): target | | | | | | | | | | | | | | | | | | | | | Mapping: TextContent | | | hbs(59:60): ! - | | | ts(284:284): + | | | ts(337:337): | | | | | |" @@ -524,38 +524,38 @@ describe('Transform: rewriteModule', () => { | Mapping: TemplateEmbedding | hbs(0:44): - | ts(0:266): export default ({} as typeof import("@glint/environment-ember-template-imports/-private/dsl")).templateExpression(function(ššŖ, Ļ‡: typeof import("@glint/environment-ember-template-imports/-private/dsl")) {\\nĻ‡.emitContent(Ļ‡.resolveOrReturn(ššŖ.args.target)());\\nššŖ; Ļ‡;\\n}) + | ts(0:340): export default ({} as typeof import("@glint/environment-ember-template-imports/-private/dsl")).templateExpression(function(__glintRef__, __glintDSL__: typeof import("@glint/environment-ember-template-imports/-private/dsl")) {\\n__glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintRef__.args.target)());\\n__glintRef__; __glintDSL__;\\n}) | | | Mapping: Template | | hbs(10:33): Hello, {{@target}}! - | | ts(205:257): Ļ‡.emitContent(Ļ‡.resolveOrReturn(ššŖ.args.target)()); + | | ts(226:310): __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintRef__.args.target)()); | | | | | Mapping: TextContent | | | hbs(13:19): Hello, - | | | ts(205:205): + | | | ts(226:226): | | | | | | Mapping: MustacheStatement | | | hbs(20:31): {{@target}} - | | | ts(205:255): Ļ‡.emitContent(Ļ‡.resolveOrReturn(ššŖ.args.target)()) + | | | ts(226:308): __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintRef__.args.target)()) | | | | | | | Mapping: MustacheStatement | | | | hbs(20:31): {{@target}} - | | | | ts(219:254): Ļ‡.resolveOrReturn(ššŖ.args.target)() + | | | | ts(251:307): __glintDSL__.resolveOrReturn(__glintRef__.args.target)() | | | | | | | | | Mapping: PathExpression | | | | | hbs(22:29): @target - | | | | | ts(237:251): ššŖ.args.target + | | | | | ts(280:304): __glintRef__.args.target | | | | | | | | | | | Mapping: Identifier | | | | | | hbs(23:29): target - | | | | | | ts(245:251): target + | | | | | | ts(298:304): target | | | | | | | | | | | | | | | | | | | | | Mapping: TextContent | | | hbs(31:32): ! - | | | ts(257:257): + | | | ts(310:310): | | | | | |" @@ -593,27 +593,27 @@ describe('Transform: rewriteModule', () => { | Mapping: TemplateEmbedding | hbs(56:89): - | ts(56:308): ({} as typeof import("@glint/environment-ember-template-imports/-private/dsl")).templateExpression(function(ššŖ, Ļ‡: typeof import("@glint/environment-ember-template-imports/-private/dsl")) {\\nĻ‡.emitContent(Ļ‡.resolveOrReturn(ššŖ.args.message)());\\nššŖ; Ļ‡;\\n}) + | ts(56:382): ({} as typeof import("@glint/environment-ember-template-imports/-private/dsl")).templateExpression(function(__glintRef__, __glintDSL__: typeof import("@glint/environment-ember-template-imports/-private/dsl")) {\\n__glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintRef__.args.message)());\\n__glintRef__; __glintDSL__;\\n}) | | | Mapping: Template | | hbs(66:78): {{@message}} - | | ts(246:299): Ļ‡.emitContent(Ļ‡.resolveOrReturn(ššŖ.args.message)()); + | | ts(267:352): __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintRef__.args.message)()); | | | | | Mapping: MustacheStatement | | | hbs(66:78): {{@message}} - | | | ts(246:297): Ļ‡.emitContent(Ļ‡.resolveOrReturn(ššŖ.args.message)()) + | | | ts(267:350): __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintRef__.args.message)()) | | | | | | | Mapping: MustacheStatement | | | | hbs(66:78): {{@message}} - | | | | ts(260:296): Ļ‡.resolveOrReturn(ššŖ.args.message)() + | | | | ts(292:349): __glintDSL__.resolveOrReturn(__glintRef__.args.message)() | | | | | | | | | Mapping: PathExpression | | | | | hbs(68:76): @message - | | | | | ts(278:293): ššŖ.args.message + | | | | | ts(321:346): __glintRef__.args.message | | | | | | | | | | | Mapping: Identifier | | | | | | hbs(69:76): message - | | | | | | ts(286:293): message + | | | | | | ts(339:346): message | | | | | | | | | | | | | | | @@ -623,31 +623,31 @@ describe('Transform: rewriteModule', () => { | Mapping: TemplateEmbedding | hbs(139:174): - | ts(358:630): static { ({} as typeof import("@glint/environment-ember-template-imports/-private/dsl")).templateForBackingValue(this, function(ššŖ, Ļ‡: typeof import("@glint/environment-ember-template-imports/-private/dsl")) {\\nĻ‡.emitContent(Ļ‡.resolveOrReturn(ššŖ.this.title)());\\nššŖ; Ļ‡;\\n}) } + | ts(432:778): static { ({} as typeof import("@glint/environment-ember-template-imports/-private/dsl")).templateForBackingValue(this, function(__glintRef__, __glintDSL__: typeof import("@glint/environment-ember-template-imports/-private/dsl")) {\\n__glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintRef__.this.title)());\\n__glintRef__; __glintDSL__;\\n}) } | | | Mapping: Template | | hbs(149:163): {{this.title}} - | | ts(568:619): Ļ‡.emitContent(Ļ‡.resolveOrReturn(ššŖ.this.title)()); + | | ts(663:746): __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintRef__.this.title)()); | | | | | Mapping: MustacheStatement | | | hbs(149:163): {{this.title}} - | | | ts(568:617): Ļ‡.emitContent(Ļ‡.resolveOrReturn(ššŖ.this.title)()) + | | | ts(663:744): __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintRef__.this.title)()) | | | | | | | Mapping: MustacheStatement | | | | hbs(149:163): {{this.title}} - | | | | ts(582:616): Ļ‡.resolveOrReturn(ššŖ.this.title)() + | | | | ts(688:743): __glintDSL__.resolveOrReturn(__glintRef__.this.title)() | | | | | | | | | Mapping: PathExpression | | | | | hbs(151:161): this.title - | | | | | ts(600:613): ššŖ.this.title + | | | | | ts(717:740): __glintRef__.this.title | | | | | | | | | | | Mapping: Identifier | | | | | | hbs(151:155): this - | | | | | | ts(603:607): this + | | | | | | ts(730:734): this | | | | | | | | | | | | Mapping: Identifier | | | | | | hbs(156:161): title - | | | | | | ts(608:613): title + | | | | | | ts(735:740): title | | | | | | | | | | | | | | | @@ -679,143 +679,143 @@ describe('Transform: rewriteModule', () => { | Mapping: TemplateEmbedding | hbs(58:210): - | ts(58:535): export default ({} as typeof import("@glint/environment-ember-template-imports/-private/dsl")).templateExpression(function(ššŖ, Ļ‡: typeof import("@glint/environment-ember-template-imports/-private/dsl")) {\\n{\\nconst š›„ = Ļ‡.emitComponent(Ļ‡.resolve(Ļ‡.Globals["let"])((Ļ‡.noop(arr), [1, 2]), (Ļ‡.noop(h), ({\\nred: "blue",\\n}))));\\n{\\nconst [arr, h] = š›„.blockParams["default"];\\nĻ‡.emitContent(Ļ‡.resolveOrReturn(arr)());\\nĻ‡.emitContent(Ļ‡.resolveOrReturn(h)());\\n}\\nĻ‡.Globals["let"];\\n}\\nššŖ; Ļ‡;\\n}) + | ts(58:703): export default ({} as typeof import("@glint/environment-ember-template-imports/-private/dsl")).templateExpression(function(__glintRef__, __glintDSL__: typeof import("@glint/environment-ember-template-imports/-private/dsl")) {\\n{\\nconst __glintY__ = __glintDSL__.emitComponent(__glintDSL__.resolve(__glintDSL__.Globals["let"])((__glintDSL__.noop(arr), [1, 2]), (__glintDSL__.noop(h), ({\\nred: "blue",\\n}))));\\n{\\nconst [arr, h] = __glintY__.blockParams["default"];\\n__glintDSL__.emitContent(__glintDSL__.resolveOrReturn(arr)());\\n__glintDSL__.emitContent(__glintDSL__.resolveOrReturn(h)());\\n}\\n__glintDSL__.Globals["let"];\\n}\\n__glintRef__; __glintDSL__;\\n}) | | | Mapping: Template | | hbs(68:199): {{! Intentionally shadowing }}\\n {{#let (arr 1 2) (h red="blue") as |arr h|}}\\n Array is {{arr}}\\n Hash is {{h}}\\n {{/let}} - | | ts(263:526): {\\nconst š›„ = Ļ‡.emitComponent(Ļ‡.resolve(Ļ‡.Globals["let"])((Ļ‡.noop(arr), [1, 2]), (Ļ‡.noop(h), ({\\nred: "blue",\\n}))));\\n{\\nconst [arr, h] = š›„.blockParams["default"];\\nĻ‡.emitContent(Ļ‡.resolveOrReturn(arr)());\\nĻ‡.emitContent(Ļ‡.resolveOrReturn(h)());\\n}\\nĻ‡.Globals["let"];\\n} + | | ts(284:673): {\\nconst __glintY__ = __glintDSL__.emitComponent(__glintDSL__.resolve(__glintDSL__.Globals["let"])((__glintDSL__.noop(arr), [1, 2]), (__glintDSL__.noop(h), ({\\nred: "blue",\\n}))));\\n{\\nconst [arr, h] = __glintY__.blockParams["default"];\\n__glintDSL__.emitContent(__glintDSL__.resolveOrReturn(arr)());\\n__glintDSL__.emitContent(__glintDSL__.resolveOrReturn(h)());\\n}\\n__glintDSL__.Globals["let"];\\n} | | | | | Mapping: TextContent | | | hbs(68:69): - | | | ts(263:263): + | | | ts(284:284): | | | | | | Mapping: MustacheCommentStatement | | | hbs(71:101): {{! Intentionally shadowing }} - | | | ts(263:263): + | | | ts(284:284): | | | | | | Mapping: BlockStatement | | | hbs(104:198): {{#let (arr 1 2) (h red="blue") as |arr h|}}\\n Array is {{arr}}\\n Hash is {{h}}\\n {{/let}} - | | | ts(263:525): {\\nconst š›„ = Ļ‡.emitComponent(Ļ‡.resolve(Ļ‡.Globals["let"])((Ļ‡.noop(arr), [1, 2]), (Ļ‡.noop(h), ({\\nred: "blue",\\n}))));\\n{\\nconst [arr, h] = š›„.blockParams["default"];\\nĻ‡.emitContent(Ļ‡.resolveOrReturn(arr)());\\nĻ‡.emitContent(Ļ‡.resolveOrReturn(h)());\\n}\\nĻ‡.Globals["let"];\\n} + | | | ts(284:672): {\\nconst __glintY__ = __glintDSL__.emitComponent(__glintDSL__.resolve(__glintDSL__.Globals["let"])((__glintDSL__.noop(arr), [1, 2]), (__glintDSL__.noop(h), ({\\nred: "blue",\\n}))));\\n{\\nconst [arr, h] = __glintY__.blockParams["default"];\\n__glintDSL__.emitContent(__glintDSL__.resolveOrReturn(arr)());\\n__glintDSL__.emitContent(__glintDSL__.resolveOrReturn(h)());\\n}\\n__glintDSL__.Globals["let"];\\n} | | | | | | | Mapping: BlockStatement | | | | hbs(104:198): {{#let (arr 1 2) (h red="blue") as |arr h|}}\\n Array is {{arr}}\\n Hash is {{h}}\\n {{/let}} - | | | | ts(292:375): Ļ‡.resolve(Ļ‡.Globals["let"])((Ļ‡.noop(arr), [1, 2]), (Ļ‡.noop(h), ({\\nred: "blue",\\n}))) + | | | | ts(332:459): __glintDSL__.resolve(__glintDSL__.Globals["let"])((__glintDSL__.noop(arr), [1, 2]), (__glintDSL__.noop(h), ({\\nred: "blue",\\n}))) | | | | | | | | | Mapping: PathExpression | | | | | hbs(107:110): let - | | | | | ts(302:318): Ļ‡.Globals["let"] + | | | | | ts(353:380): __glintDSL__.Globals["let"] | | | | | | | | | | | Mapping: Identifier | | | | | | hbs(107:110): let - | | | | | | ts(313:316): let + | | | | | | ts(375:378): let | | | | | | | | | | | | | | | | Mapping: PathExpression | | | | | hbs(112:115): arr - | | | | | ts(328:331): arr + | | | | | ts(401:404): arr | | | | | | | | | | | Mapping: Identifier | | | | | | hbs(112:115): arr - | | | | | | ts(328:331): arr + | | | | | | ts(401:404): arr | | | | | | | | | | | | | | | | Mapping: SubExpression | | | | | hbs(111:120): (arr 1 2) - | | | | | ts(334:340): [1, 2] + | | | | | ts(407:413): [1, 2] | | | | | | | | | | | Mapping: NumberLiteral | | | | | | hbs(116:117): 1 - | | | | | | ts(335:336): 1 + | | | | | | ts(408:409): 1 | | | | | | | | | | | | Mapping: NumberLiteral | | | | | | hbs(118:119): 2 - | | | | | | ts(338:339): 2 + | | | | | | ts(411:412): 2 | | | | | | | | | | | | | | | | Mapping: PathExpression | | | | | hbs(122:123): h - | | | | | ts(351:352): h + | | | | | ts(435:436): h | | | | | | | | | | | Mapping: Identifier | | | | | | hbs(122:123): h - | | | | | | ts(351:352): h + | | | | | | ts(435:436): h | | | | | | | | | | | | | | | | Mapping: SubExpression | | | | | hbs(121:135): (h red="blue") - | | | | | ts(355:373): ({\\nred: "blue",\\n}) + | | | | | ts(439:457): ({\\nred: "blue",\\n}) | | | | | | | | | | | Mapping: Identifier | | | | | | hbs(124:127): red - | | | | | | ts(358:361): red + | | | | | | ts(442:445): red | | | | | | | | | | | | Mapping: StringLiteral | | | | | | hbs(128:134): "blue" - | | | | | | ts(363:369): "blue" + | | | | | | ts(447:453): "blue" | | | | | | | | | | | | | | | | | | | Mapping: Identifier | | | | hbs(140:143): arr - | | | | ts(387:390): arr + | | | | ts(471:474): arr | | | | | | | | Mapping: Identifier | | | | hbs(144:145): h - | | | | ts(392:393): h + | | | | ts(476:477): h | | | | | | | | Mapping: TextContent | | | | hbs(153:161): Array is - | | | | ts(424:424): + | | | | ts(516:516): | | | | | | | | Mapping: MustacheStatement | | | | hbs(162:169): {{arr}} - | | | | ts(424:463): Ļ‡.emitContent(Ļ‡.resolveOrReturn(arr)()) + | | | | ts(516:577): __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(arr)()) | | | | | | | | | Mapping: MustacheStatement | | | | | hbs(162:169): {{arr}} - | | | | | ts(438:462): Ļ‡.resolveOrReturn(arr)() + | | | | | ts(541:576): __glintDSL__.resolveOrReturn(arr)() | | | | | | | | | | | Mapping: PathExpression | | | | | | hbs(164:167): arr - | | | | | | ts(456:459): arr + | | | | | | ts(570:573): arr | | | | | | | | | | | | | Mapping: Identifier | | | | | | | hbs(164:167): arr - | | | | | | | ts(456:459): arr + | | | | | | | ts(570:573): arr | | | | | | | | | | | | | | | | | | | | | | | | | | Mapping: TextContent | | | | hbs(174:181): Hash is - | | | | ts(465:465): + | | | | ts(579:579): | | | | | | | | Mapping: MustacheStatement | | | | hbs(182:187): {{h}} - | | | | ts(465:502): Ļ‡.emitContent(Ļ‡.resolveOrReturn(h)()) + | | | | ts(579:638): __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(h)()) | | | | | | | | | Mapping: MustacheStatement | | | | | hbs(182:187): {{h}} - | | | | | ts(479:501): Ļ‡.resolveOrReturn(h)() + | | | | | ts(604:637): __glintDSL__.resolveOrReturn(h)() | | | | | | | | | | | Mapping: PathExpression | | | | | | hbs(184:185): h - | | | | | | ts(497:498): h + | | | | | | ts(633:634): h | | | | | | | | | | | | | Mapping: Identifier | | | | | | | hbs(184:185): h - | | | | | | | ts(497:498): h + | | | | | | | ts(633:634): h | | | | | | | | | | | | | | | | | | | | | | | | | | Mapping: TextContent | | | | hbs(187:188): - | | | | ts(504:504): + | | | | ts(640:640): | | | | | | | | Mapping: Identifier | | | | hbs(193:196): let - | | | | ts(517:520): let + | | | | ts(664:667): let | | | | | | | | | diff --git a/packages/core/__tests__/transform/template-to-typescript.test.ts b/packages/core/__tests__/transform/template-to-typescript.test.ts index 615aee142..64c9f5f84 100644 --- a/packages/core/__tests__/transform/template-to-typescript.test.ts +++ b/packages/core/__tests__/transform/template-to-typescript.test.ts @@ -31,8 +31,8 @@ describe('Transform: rewriteTemplate', () => { test('without any specified type parameters or context type', () => { expect(templateToTypescript('', { typesModule: '@glint/template' }).result?.code) .toMatchInlineSnapshot(` - "({} as typeof import("@glint/template")).templateExpression(function(ššŖ, Ļ‡: typeof import("@glint/template")) { - ššŖ; Ļ‡; + "({} as typeof import("@glint/template")).templateExpression(function(__glintRef__, __glintDSL__: typeof import("@glint/template")) { + __glintRef__; __glintDSL__; })" `); }); @@ -42,8 +42,8 @@ describe('Transform: rewriteTemplate', () => { templateToTypescript('', { backingValue: 'someValue', typesModule: '@glint/template' }) .result?.code, ).toMatchInlineSnapshot(` - "({} as typeof import("@glint/template")).templateForBackingValue(someValue, function(ššŖ, Ļ‡: typeof import("@glint/template")) { - ššŖ; Ļ‡; + "({} as typeof import("@glint/template")).templateForBackingValue(someValue, function(__glintRef__, __glintDSL__: typeof import("@glint/template")) { + __glintRef__; __glintDSL__; })" `); }); @@ -53,10 +53,10 @@ describe('Transform: rewriteTemplate', () => { expect(templateToTypescript('', { preamble, typesModule: '@glint/template' }).result?.code) .toMatchInlineSnapshot(` - "({} as typeof import("@glint/template")).templateExpression(function(ššŖ, Ļ‡: typeof import("@glint/template")) { + "({} as typeof import("@glint/template")).templateExpression(function(__glintRef__, __glintDSL__: typeof import("@glint/template")) { console.log("hello!"); throw new Error(); - ššŖ; Ļ‡; + __glintRef__; __glintDSL__; })" `); }); @@ -145,11 +145,11 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template)).toMatchInlineSnapshot(` "// @glint-nocheck { - const š›„ = Ļ‡.emitComponent(Ļ‡.resolve(Ļ‡.Globals["Foo"])()); - š›„; + const __glintY__ = __glintDSL__.emitComponent(__glintDSL__.resolve(__glintDSL__.Globals["Foo"])()); + __glintY__; } - Ļ‡.emitContent(Ļ‡.resolveOrReturn(Ļ‡.Globals["foo-bar"])()); - Ļ‡.emitContent(Ļ‡.resolveOrReturn(ššŖ.this.baz)());" + __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintDSL__.Globals["foo-bar"])()); + __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintRef__.this.baz)());" `); }); @@ -272,7 +272,7 @@ describe('Transform: rewriteTemplate', () => { }); expect(body).toMatchInlineSnapshot(` - "(Ļ‡.noop(obj), ({ + "(__glintDSL__.noop(obj), ({ x: 123, }));" `); @@ -285,7 +285,7 @@ describe('Transform: rewriteTemplate', () => { let specialForms = { testIf: 'if' } as const; expect(templateBody(template, { specialForms })).toMatchInlineSnapshot( - `"(ššŖ.args.foo) ? ("ok") : (undefined);"`, + `"(__glintRef__.args.foo) ? ("ok") : (undefined);"`, ); }); @@ -294,7 +294,7 @@ describe('Transform: rewriteTemplate', () => { let specialForms = { testIf: 'if' } as const; expect(templateBody(template, { specialForms })).toMatchInlineSnapshot( - `"(ššŖ.args.foo) ? ("ok") : ("nope");"`, + `"(__glintRef__.args.foo) ? ("ok") : ("nope");"`, ); }); }); @@ -305,7 +305,7 @@ describe('Transform: rewriteTemplate', () => { let specialForms = { testUnless: 'if-not' } as const; expect(templateBody(template, { specialForms })).toMatchInlineSnapshot( - `"!(ššŖ.args.foo) ? ("ok") : (undefined);"`, + `"!(__glintRef__.args.foo) ? ("ok") : (undefined);"`, ); }); @@ -314,7 +314,7 @@ describe('Transform: rewriteTemplate', () => { let specialForms = { testUnless: 'if-not' } as const; expect(templateBody(template, { specialForms })).toMatchInlineSnapshot( - `"!(ššŖ.args.foo) ? ("ok") : ("nope");"`, + `"!(__glintRef__.args.foo) ? ("ok") : ("nope");"`, ); }); }); @@ -330,8 +330,8 @@ describe('Transform: rewriteTemplate', () => { let specialForms = { testIf: 'if' } as const; expect(templateBody(template, { specialForms })).toMatchInlineSnapshot(` - "if (ššŖ.args.foo) { - Ļ‡.emitContent(Ļ‡.resolveOrReturn(ššŖ.args.ok)()); + "if (__glintRef__.args.foo) { + __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintRef__.args.ok)()); }" `); }); @@ -348,10 +348,10 @@ describe('Transform: rewriteTemplate', () => { let specialForms = { testIf: 'if' } as const; expect(templateBody(template, { specialForms })).toMatchInlineSnapshot(` - "if (ššŖ.args.foo) { - Ļ‡.emitContent(Ļ‡.resolveOrReturn(ššŖ.args.ok)()); + "if (__glintRef__.args.foo) { + __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintRef__.args.ok)()); } else { - Ļ‡.emitContent(Ļ‡.resolveOrReturn(ššŖ.args.noGood)()); + __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintRef__.args.noGood)()); }" `); }); @@ -370,13 +370,13 @@ describe('Transform: rewriteTemplate', () => { let specialForms = { testIf: 'if' } as const; expect(templateBody(template, { specialForms })).toMatchInlineSnapshot(` - "if (ššŖ.args.foo) { - Ļ‡.emitContent(Ļ‡.resolveOrReturn(ššŖ.args.ok)()); + "if (__glintRef__.args.foo) { + __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintRef__.args.ok)()); } else { - if (ššŖ.args.bar) { - Ļ‡.emitContent(Ļ‡.resolveOrReturn(ššŖ.args.noGood)()); + if (__glintRef__.args.bar) { + __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintRef__.args.noGood)()); } else { - Ļ‡.emitContent(Ļ‡.resolveOrReturn(ššŖ.args.done)()); + __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintRef__.args.done)()); } }" `); @@ -396,20 +396,20 @@ describe('Transform: rewriteTemplate', () => { let specialForms = { testIf: 'if' } as const; expect(templateBody(template, { specialForms })).toMatchInlineSnapshot(` - "if (ššŖ.args.foo) { - Ļ‡.emitContent(Ļ‡.resolveOrReturn(ššŖ.args.ok)()); + "if (__glintRef__.args.foo) { + __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintRef__.args.ok)()); } else { { - const š›„ = Ļ‡.emitComponent(Ļ‡.resolve(Ļ‡.Globals["doAThing"])()); + const __glintY__ = __glintDSL__.emitComponent(__glintDSL__.resolve(__glintDSL__.Globals["doAThing"])()); { - const [ok] = š›„.blockParams["default"]; - Ļ‡.emitContent(Ļ‡.resolveOrReturn(ok)()); + const [ok] = __glintY__.blockParams["default"]; + __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(ok)()); } { - const [] = š›„.blockParams["else"]; - Ļ‡.emitContent(Ļ‡.resolveOrReturn(ššŖ.args.nevermind)()); + const [] = __glintY__.blockParams["else"]; + __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintRef__.args.nevermind)()); } - Ļ‡.Globals["doAThing"]; + __glintDSL__.Globals["doAThing"]; } }" `); @@ -427,8 +427,8 @@ describe('Transform: rewriteTemplate', () => { let specialForms = { testUnless: 'if-not' } as const; expect(templateBody(template, { specialForms })).toMatchInlineSnapshot(` - "if (!(ššŖ.args.foo)) { - Ļ‡.emitContent(Ļ‡.resolveOrReturn(ššŖ.args.ok)()); + "if (!(__glintRef__.args.foo)) { + __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintRef__.args.ok)()); }" `); }); @@ -445,10 +445,10 @@ describe('Transform: rewriteTemplate', () => { let specialForms = { testUnless: 'if-not' } as const; expect(templateBody(template, { specialForms })).toMatchInlineSnapshot(` - "if (!(ššŖ.args.foo)) { - Ļ‡.emitContent(Ļ‡.resolveOrReturn(ššŖ.args.ok)()); + "if (!(__glintRef__.args.foo)) { + __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintRef__.args.ok)()); } else { - Ļ‡.emitContent(Ļ‡.resolveOrReturn(ššŖ.args.noGood)()); + __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintRef__.args.noGood)()); }" `); }); @@ -463,7 +463,7 @@ describe('Transform: rewriteTemplate', () => { let specialForms = { testYield: 'yield' } as const; expect(templateBody(template, { specialForms })).toMatchInlineSnapshot( - `"Ļ‡.yieldToBlock(ššŖ, "default")(123, ššŖ.this.message);"`, + `"__glintDSL__.yieldToBlock(__glintRef__, "default")(123, __glintRef__.this.message);"`, ); }); @@ -475,7 +475,7 @@ describe('Transform: rewriteTemplate', () => { let specialForms = { testYield: 'yield' } as const; expect(templateBody(template, { specialForms })).toMatchInlineSnapshot( - `"Ļ‡.yieldToBlock(ššŖ, "body")(123);"`, + `"__glintDSL__.yieldToBlock(__glintRef__, "body")(123);"`, ); }); @@ -487,7 +487,7 @@ describe('Transform: rewriteTemplate', () => { let specialForms = { testYield: 'yield' } as const; expect(templateBody(template, { specialForms })).toMatchInlineSnapshot( - `"Ļ‡.yieldToBlock(ššŖ, "else")(123);"`, + `"__glintDSL__.yieldToBlock(__glintRef__, "else")(123);"`, ); }); @@ -499,7 +499,7 @@ describe('Transform: rewriteTemplate', () => { let specialForms = { testYield: 'yield' } as const; expect(templateBody(template, { specialForms })).toMatchInlineSnapshot( - `"Ļ‡.yieldToBlock(ššŖ, "else")(123);"`, + `"__glintDSL__.yieldToBlock(__glintRef__, "else")(123);"`, ); }); }); @@ -513,7 +513,7 @@ describe('Transform: rewriteTemplate', () => { let specialForms = { testArray: 'array-literal' } as const; expect(templateBody(template, { globals: [], specialForms })).toMatchInlineSnapshot( - '"(Ļ‡.noop(testArray), []);"', + '"(__glintDSL__.noop(testArray), []);"', ); }); @@ -525,7 +525,7 @@ describe('Transform: rewriteTemplate', () => { let specialForms = { testArray: 'array-literal' } as const; expect(templateBody(template, { globals: [], specialForms })).toMatchInlineSnapshot( - `"(Ļ‡.noop(testArray), [1, true, "free"]);"`, + `"(__glintDSL__.noop(testArray), [1, true, "free"]);"`, ); }); @@ -537,7 +537,7 @@ describe('Transform: rewriteTemplate', () => { let specialForms = { testArray: 'array-literal' } as const; expect(templateBody(template, { globals: [], specialForms })).toMatchInlineSnapshot( - `"Ļ‡.emitContent(Ļ‡.resolve(log)((Ļ‡.noop(testArray), [1, true, "free"])));"`, + `"__glintDSL__.emitContent(__glintDSL__.resolve(log)((__glintDSL__.noop(testArray), [1, true, "free"])));"`, ); }); }); @@ -551,7 +551,7 @@ describe('Transform: rewriteTemplate', () => { let specialForms = { testHash: 'object-literal' } as const; expect(templateBody(template, { globals: [], specialForms })).toMatchInlineSnapshot( - '"(Ļ‡.noop(testHash), {});"', + '"(__glintDSL__.noop(testHash), {});"', ); }); @@ -563,7 +563,7 @@ describe('Transform: rewriteTemplate', () => { let specialForms = { testHash: 'object-literal' } as const; expect(templateBody(template, { globals: [], specialForms })).toMatchInlineSnapshot(` - "(Ļ‡.noop(testHash), ({ + "(__glintDSL__.noop(testHash), ({ a: 1, b: "ok", }));" @@ -578,7 +578,7 @@ describe('Transform: rewriteTemplate', () => { let specialForms = { testHash: 'object-literal' } as const; expect(templateBody(template, { globals: [], specialForms })).toMatchInlineSnapshot(` - "Ļ‡.emitContent(Ļ‡.resolve(log)((Ļ‡.noop(testHash), ({ + "__glintDSL__.emitContent(__glintDSL__.resolve(log)((__glintDSL__.noop(testHash), ({ a: 1, b: "ok", }))));" @@ -594,7 +594,7 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template, { globals: ['testEq'], specialForms: { testEq: '===' } })) .toMatchInlineSnapshot(` - "Ļ‡.emitContent(Ļ‡.resolve(log)((1 === 2)));" + "__glintDSL__.emitContent(__glintDSL__.resolve(log)((1 === 2)));" `); }); }); @@ -607,7 +607,7 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template, { globals: ['testNeq'], specialForms: { testNeq: '!==' } })) .toMatchInlineSnapshot(` - "Ļ‡.emitContent(Ļ‡.resolve(log)((1 !== 2)));" + "__glintDSL__.emitContent(__glintDSL__.resolve(log)((1 !== 2)));" `); }); }); @@ -620,7 +620,7 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template, { globals: ['testAnd'], specialForms: { testAnd: '&&' } })) .toMatchInlineSnapshot(` - "Ļ‡.emitContent(Ļ‡.resolve(log)((1 && 2)));" + "__glintDSL__.emitContent(__glintDSL__.resolve(log)((1 && 2)));" `); }); @@ -631,7 +631,7 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template, { globals: ['testAnd'], specialForms: { testAnd: '&&' } })) .toMatchInlineSnapshot(` - "Ļ‡.emitContent(Ļ‡.resolve(log)((1 && 2 && 3)));" + "__glintDSL__.emitContent(__glintDSL__.resolve(log)((1 && 2 && 3)));" `); }); }); @@ -644,7 +644,7 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template, { globals: ['testOr'], specialForms: { testOr: '||' } })) .toMatchInlineSnapshot(` - "Ļ‡.emitContent(Ļ‡.resolve(log)((1 || 2)));" + "__glintDSL__.emitContent(__glintDSL__.resolve(log)((1 || 2)));" `); }); @@ -655,7 +655,7 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template, { globals: ['testOr'], specialForms: { testOr: '||' } })) .toMatchInlineSnapshot(` - "Ļ‡.emitContent(Ļ‡.resolve(log)((1 || 2 || 3)));" + "__glintDSL__.emitContent(__glintDSL__.resolve(log)((1 || 2 || 3)));" `); }); }); @@ -668,7 +668,7 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template, { globals: ['testNot'], specialForms: { testNot: '!' } })) .toMatchInlineSnapshot(` - "Ļ‡.emitContent(Ļ‡.resolve(log)(!1));" + "__glintDSL__.emitContent(__glintDSL__.resolve(log)(!1));" `); }); }); @@ -681,7 +681,7 @@ describe('Transform: rewriteTemplate', () => { let template = '{{message}}'; expect(templateBody(template)).toMatchInlineSnapshot( - `"Ļ‡.emitContent(Ļ‡.resolveOrReturn(Ļ‡.Globals["message"])());"`, + `"__glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintDSL__.Globals["message"])());"`, ); }); @@ -689,7 +689,7 @@ describe('Transform: rewriteTemplate', () => { let template = '{{message}}'; expect(templateBody(template, { globals: [] })).toMatchInlineSnapshot( - '"Ļ‡.emitContent(Ļ‡.resolveOrReturn(message)());"', + '"__glintDSL__.emitContent(__glintDSL__.resolveOrReturn(message)());"', ); }); @@ -697,7 +697,7 @@ describe('Transform: rewriteTemplate', () => { let template = '{{obj.foo.bar}}'; expect(templateBody(template, { globals: [] })).toMatchInlineSnapshot( - '"Ļ‡.emitContent(Ļ‡.resolveOrReturn(obj?.foo?.bar)());"', + '"__glintDSL__.emitContent(__glintDSL__.resolveOrReturn(obj?.foo?.bar)());"', ); }); @@ -705,7 +705,7 @@ describe('Transform: rewriteTemplate', () => { let template = '{{obj.foo-bar.baz}}'; expect(templateBody(template, { globals: [] })).toMatchInlineSnapshot( - `"Ļ‡.emitContent(Ļ‡.resolveOrReturn(obj?.["foo-bar"]?.baz)());"`, + `"__glintDSL__.emitContent(__glintDSL__.resolveOrReturn(obj?.["foo-bar"]?.baz)());"`, ); }); @@ -713,7 +713,7 @@ describe('Transform: rewriteTemplate', () => { let template = '{{this}}'; expect(templateBody(template)).toMatchInlineSnapshot( - '"Ļ‡.emitContent(Ļ‡.resolveOrReturn(ššŖ.this)());"', + '"__glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintRef__.this)());"', ); }); @@ -721,7 +721,7 @@ describe('Transform: rewriteTemplate', () => { let template = '{{this.foo.bar}}'; expect(templateBody(template)).toMatchInlineSnapshot( - '"Ļ‡.emitContent(Ļ‡.resolveOrReturn(ššŖ.this.foo?.bar)());"', + '"__glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintRef__.this.foo?.bar)());"', ); }); @@ -729,7 +729,7 @@ describe('Transform: rewriteTemplate', () => { let template = '{{this.foo-bar}}'; expect(templateBody(template)).toMatchInlineSnapshot( - `"Ļ‡.emitContent(Ļ‡.resolveOrReturn(ššŖ.this["foo-bar"])());"`, + `"__glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintRef__.this["foo-bar"])());"`, ); }); @@ -737,7 +737,7 @@ describe('Transform: rewriteTemplate', () => { let template = '{{@foo}}'; expect(templateBody(template)).toMatchInlineSnapshot( - '"Ļ‡.emitContent(Ļ‡.resolveOrReturn(ššŖ.args.foo)());"', + '"__glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintRef__.args.foo)());"', ); }); @@ -745,7 +745,7 @@ describe('Transform: rewriteTemplate', () => { let template = '{{@foo-bar}}'; expect(templateBody(template)).toMatchInlineSnapshot( - `"Ļ‡.emitContent(Ļ‡.resolveOrReturn(ššŖ.args["foo-bar"])());"`, + `"__glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintRef__.args["foo-bar"])());"`, ); }); @@ -754,9 +754,9 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template, { globals: [] })).toMatchInlineSnapshot(` "{ - const š›„ = Ļ‡.emitComponent(Ļ‡.resolve(Foo)()); - Ļ‡.applyAttributes(š›„.element, { - "data-bar": Ļ‡.resolve(helper)({ param: true , ...Ļ‡.NamedArgsMarker }), + const __glintY__ = __glintDSL__.emitComponent(__glintDSL__.resolve(Foo)()); + __glintDSL__.applyAttributes(__glintY__.element, { + "data-bar": __glintDSL__.resolve(helper)({ param: true , ...__glintDSL__.NamedArgsMarker }), }); }" `); @@ -767,8 +767,8 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template, { globals: [] })).toMatchInlineSnapshot(` "{ - const š›„ = Ļ‡.emitComponent(Ļ‡.resolve(Foo)({ bar: Ļ‡.resolve(helper)({ param: true , ...Ļ‡.NamedArgsMarker }), ...Ļ‡.NamedArgsMarker })); - š›„; + const __glintY__ = __glintDSL__.emitComponent(__glintDSL__.resolve(Foo)({ bar: __glintDSL__.resolve(helper)({ param: true , ...__glintDSL__.NamedArgsMarker }), ...__glintDSL__.NamedArgsMarker })); + __glintY__; }" `); }); @@ -779,7 +779,7 @@ describe('Transform: rewriteTemplate', () => { let template = '{{@input}}'; expect(templateBody(template)).toMatchInlineSnapshot( - '"Ļ‡.emitContent(Ļ‡.resolveOrReturn(ššŖ.args.input)());"', + '"__glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintRef__.args.input)());"', ); }); @@ -788,9 +788,9 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template)).toMatchInlineSnapshot(` "{ - const š›„ = Ļ‡.emitElement("div"); - Ļ‡.applyAttributes(š›„.element, { - "data-attr": Ļ‡.resolveOrReturn(ššŖ.args.input)(), + const __glintY__ = __glintDSL__.emitElement("div"); + __glintDSL__.applyAttributes(__glintY__.element, { + "data-attr": __glintDSL__.resolveOrReturn(__glintRef__.args.input)(), }); }" `); @@ -801,9 +801,9 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template)).toMatchInlineSnapshot(` "{ - const š›„ = Ļ‡.emitElement("div"); - Ļ‡.applyAttributes(š›„.element, { - "data-attr": \`\${Ļ‡.resolveOrReturn(ššŖ.args.input)()}\`, + const __glintY__ = __glintDSL__.emitElement("div"); + __glintDSL__.applyAttributes(__glintY__.element, { + "data-attr": \`\${__glintDSL__.resolveOrReturn(__glintRef__.args.input)()}\`, }); }" `); @@ -815,8 +815,8 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template, { globals: [] })).toMatchInlineSnapshot(` "{ - const š›„ = Ļ‡.emitComponent(Ļ‡.resolve(Greet)({ message: ššŖ.args.arg, ...Ļ‡.NamedArgsMarker })); - š›„; + const __glintY__ = __glintDSL__.emitComponent(__glintDSL__.resolve(Greet)({ message: __glintRef__.args.arg, ...__glintDSL__.NamedArgsMarker })); + __glintY__; }" `); }); @@ -826,8 +826,8 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template, { globals: ['foo'] })).toMatchInlineSnapshot(` "{ - const š›„ = Ļ‡.emitComponent(Ļ‡.resolve(Greet)({ message: Ļ‡.resolveOrReturn(Ļ‡.Globals["foo"])(), ...Ļ‡.NamedArgsMarker })); - š›„; + const __glintY__ = __glintDSL__.emitComponent(__glintDSL__.resolve(Greet)({ message: __glintDSL__.resolveOrReturn(__glintDSL__.Globals["foo"])(), ...__glintDSL__.NamedArgsMarker })); + __glintY__; }" `); }); @@ -837,8 +837,8 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template, { globals: [] })).toMatchInlineSnapshot(` "{ - const š›„ = Ļ‡.emitComponent(Ļ‡.resolve(Greet)({ message: foo, ...Ļ‡.NamedArgsMarker })); - š›„; + const __glintY__ = __glintDSL__.emitComponent(__glintDSL__.resolve(Greet)({ message: foo, ...__glintDSL__.NamedArgsMarker })); + __glintY__; }" `); }); @@ -848,15 +848,15 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template, { globals: ['let', 'foo'] })).toMatchInlineSnapshot(` "{ - const š›„ = Ļ‡.emitComponent(Ļ‡.resolve(Ļ‡.Globals["let"])(Ļ‡.Globals["foo"])); + const __glintY__ = __glintDSL__.emitComponent(__glintDSL__.resolve(__glintDSL__.Globals["let"])(__glintDSL__.Globals["foo"])); { - const [bar] = š›„.blockParams["default"]; + const [bar] = __glintY__.blockParams["default"]; { - const š›„ = Ļ‡.emitComponent(Ļ‡.resolve(Greet)({ message: bar, ...Ļ‡.NamedArgsMarker })); - š›„; + const __glintY__ = __glintDSL__.emitComponent(__glintDSL__.resolve(Greet)({ message: bar, ...__glintDSL__.NamedArgsMarker })); + __glintY__; } } - Ļ‡.Globals["let"]; + __glintDSL__.Globals["let"]; }" `); }); @@ -866,7 +866,7 @@ describe('Transform: rewriteTemplate', () => { let template = '{{(@foo)}}'; expect(templateBody(template)).toMatchInlineSnapshot( - '"Ļ‡.emitContent(Ļ‡.resolveOrReturn(Ļ‡.resolve(ššŖ.args.foo)())());"', + '"__glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintDSL__.resolve(__glintRef__.args.foo)())());"', ); }); }); @@ -903,7 +903,7 @@ describe('Transform: rewriteTemplate', () => { let template = '{{doSomething "hello" 123}}'; expect(templateBody(template, { globals: [] })).toMatchInlineSnapshot( - `"Ļ‡.emitContent(Ļ‡.resolve(doSomething)("hello", 123));"`, + `"__glintDSL__.emitContent(__glintDSL__.resolve(doSomething)("hello", 123));"`, ); }); @@ -911,7 +911,7 @@ describe('Transform: rewriteTemplate', () => { let template = '{{doSomething a=123 b="ok"}}'; expect(templateBody(template, { globals: [] })).toMatchInlineSnapshot( - `"Ļ‡.emitContent(Ļ‡.resolve(doSomething)({ a: 123, b: "ok" , ...Ļ‡.NamedArgsMarker }));"`, + `"__glintDSL__.emitContent(__glintDSL__.resolve(doSomething)({ a: 123, b: "ok" , ...__glintDSL__.NamedArgsMarker }));"`, ); }); @@ -919,7 +919,7 @@ describe('Transform: rewriteTemplate', () => { let template = '{{doSomething "one" true 3 four=4}}'; expect(templateBody(template, { globals: [] })).toMatchInlineSnapshot( - `"Ļ‡.emitContent(Ļ‡.resolve(doSomething)("one", true, 3, { four: 4 , ...Ļ‡.NamedArgsMarker }));"`, + `"__glintDSL__.emitContent(__glintDSL__.resolve(doSomething)("one", true, 3, { four: 4 , ...__glintDSL__.NamedArgsMarker }));"`, ); }); }); @@ -931,8 +931,8 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template, { globals: [] })).toMatchInlineSnapshot(` "{ - const š›„ = Ļ‡.emitElement("div"); - Ļ‡.applyModifier(Ļ‡.resolve(modifier)(š›„.element, { foo: "bar" , ...Ļ‡.NamedArgsMarker })); + const __glintY__ = __glintDSL__.emitElement("div"); + __glintDSL__.applyModifier(__glintDSL__.resolve(modifier)(__glintY__.element, { foo: "bar" , ...__glintDSL__.NamedArgsMarker })); }" `); }); @@ -942,8 +942,8 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template, { globals: [] })).toMatchInlineSnapshot(` "{ - const š›„ = Ļ‡.emitComponent(Ļ‡.resolve(MyComponent)()); - Ļ‡.applyModifier(Ļ‡.resolve(modifier)(š›„.element, { foo: "bar" , ...Ļ‡.NamedArgsMarker })); + const __glintY__ = __glintDSL__.emitComponent(__glintDSL__.resolve(MyComponent)()); + __glintDSL__.applyModifier(__glintDSL__.resolve(modifier)(__glintY__.element, { foo: "bar" , ...__glintDSL__.NamedArgsMarker })); }" `); }); @@ -955,9 +955,9 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template, { globals: [] })).toMatchInlineSnapshot(` "{ - const š›„ = Ļ‡.emitElement("div"); - Ļ‡.applyAttributes(š›„.element, { - "data-attr": Ļ‡.resolve(concat)(Ļ‡.resolve(foo)(1), Ļ‡.resolve(foo)(true)), + const __glintY__ = __glintDSL__.emitElement("div"); + __glintDSL__.applyAttributes(__glintY__.element, { + "data-attr": __glintDSL__.resolve(concat)(__glintDSL__.resolve(foo)(1), __glintDSL__.resolve(foo)(true)), }); }" `); @@ -974,13 +974,13 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template)).toMatchInlineSnapshot(` "{ - const š›„ = Ļ‡.emitComponent(Ļ‡.resolve(Ļ‡.Globals["foo"])()); + const __glintY__ = __glintDSL__.emitComponent(__glintDSL__.resolve(__glintDSL__.Globals["foo"])()); { - const [bar, baz] = š›„.blockParams["default"]; - Ļ‡.emitContent(Ļ‡.resolveOrReturn(bar)()); - Ļ‡.emitContent(Ļ‡.resolveOrReturn(baz)()); + const [bar, baz] = __glintY__.blockParams["default"]; + __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(bar)()); + __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(baz)()); } - Ļ‡.Globals["foo"]; + __glintDSL__.Globals["foo"]; }" `); }); @@ -996,17 +996,17 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template)).toMatchInlineSnapshot(` "{ - const š›„ = Ļ‡.emitComponent(Ļ‡.resolve(Ļ‡.Globals["foo"])()); + const __glintY__ = __glintDSL__.emitComponent(__glintDSL__.resolve(__glintDSL__.Globals["foo"])()); { - const [bar, baz] = š›„.blockParams["default"]; - Ļ‡.emitContent(Ļ‡.resolveOrReturn(bar)()); - Ļ‡.emitContent(Ļ‡.resolveOrReturn(baz)()); + const [bar, baz] = __glintY__.blockParams["default"]; + __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(bar)()); + __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(baz)()); } { - const [] = š›„.blockParams["else"]; - Ļ‡.emitContent(Ļ‡.resolveOrReturn(ššŖ.args.oh)()); + const [] = __glintY__.blockParams["else"]; + __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintRef__.args.oh)()); } - Ļ‡.Globals["foo"]; + __glintDSL__.Globals["foo"]; }" `); }); @@ -1022,17 +1022,17 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template)).toMatchInlineSnapshot(` "{ - const š›„ = Ļ‡.emitComponent(Ļ‡.resolve(Ļ‡.Globals["foo"])()); + const __glintY__ = __glintDSL__.emitComponent(__glintDSL__.resolve(__glintDSL__.Globals["foo"])()); { - const [bar, baz] = š›„.blockParams["default"]; - Ļ‡.emitContent(Ļ‡.resolveOrReturn(bar)()); - Ļ‡.emitContent(Ļ‡.resolveOrReturn(baz)()); + const [bar, baz] = __glintY__.blockParams["default"]; + __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(bar)()); + __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(baz)()); } { - const [] = š›„.blockParams["else"]; - Ļ‡.emitContent(Ļ‡.resolveOrReturn(ššŖ.args.oh)()); + const [] = __glintY__.blockParams["else"]; + __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintRef__.args.oh)()); } - Ļ‡.Globals["foo"]; + __glintDSL__.Globals["foo"]; }" `); }); @@ -1044,9 +1044,9 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template)).toMatchInlineSnapshot(` "{ - const š›„ = Ļ‡.emitElement("div"); - š›„; - Ļ‡.emitContent(Ļ‡.resolveOrReturn(ššŖ.args.foo)()); + const __glintY__ = __glintDSL__.emitElement("div"); + __glintY__; + __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__glintRef__.args.foo)()); }" `); }); @@ -1056,9 +1056,9 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template)).toMatchInlineSnapshot(` "{ - const š›„ = Ļ‡.emitElement("div"); - Ļ‡.applyAttributes(š›„.element, { - "data-foo": Ļ‡.resolveOrReturn(ššŖ.args.foo)(), + const __glintY__ = __glintDSL__.emitElement("div"); + __glintDSL__.applyAttributes(__glintY__.element, { + "data-foo": __glintDSL__.resolveOrReturn(__glintRef__.args.foo)(), }); }" `); @@ -1069,9 +1069,9 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template)).toMatchInlineSnapshot(` "{ - const š›„ = Ļ‡.emitElement("div"); - Ļ‡.applyAttributes(š›„.element, { - "data-foo": \`\${Ļ‡.resolveOrReturn(ššŖ.args.foo)()}\${Ļ‡.resolveOrReturn(ššŖ.args.bar)()}\`, + const __glintY__ = __glintDSL__.emitElement("div"); + __glintDSL__.applyAttributes(__glintY__.element, { + "data-foo": \`\${__glintDSL__.resolveOrReturn(__glintRef__.args.foo)()}\${__glintDSL__.resolveOrReturn(__glintRef__.args.bar)()}\`, }); }" `); @@ -1082,8 +1082,8 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template)).toMatchInlineSnapshot(` "{ - const š›„ = Ļ‡.emitElement("div"); - Ļ‡.applySplattributes(ššŖ.element, š›„.element); + const __glintY__ = __glintDSL__.emitElement("div"); + __glintDSL__.applySplattributes(__glintRef__.element, __glintY__.element); }" `); }); @@ -1095,8 +1095,8 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template)).toMatchInlineSnapshot(` "{ - const š›„ = Ļ‡.emitComponent(Ļ‡.resolve(Ļ‡.Globals["Foo"])({ bar: "hello", ...Ļ‡.NamedArgsMarker })); - š›„; + const __glintY__ = __glintDSL__.emitComponent(__glintDSL__.resolve(__glintDSL__.Globals["Foo"])({ bar: "hello", ...__glintDSL__.NamedArgsMarker })); + __glintY__; }" `); }); @@ -1110,13 +1110,13 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template)).toMatchInlineSnapshot(` "{ - const š›„ = Ļ‡.emitComponent(Ļ‡.resolve(Ļ‡.Globals["Foo"])()); - š›„; + const __glintY__ = __glintDSL__.emitComponent(__glintDSL__.resolve(__glintDSL__.Globals["Foo"])()); + __glintY__; { - const [bar] = š›„.blockParams["default"]; - Ļ‡.emitContent(Ļ‡.resolveOrReturn(bar)()); + const [bar] = __glintY__.blockParams["default"]; + __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(bar)()); } - Ļ‡.Globals["Foo"]; + __glintDSL__.Globals["Foo"]; }" `); }); @@ -1126,8 +1126,8 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template, { globals: [] })).toMatchInlineSnapshot(` "{ - const š›„ = Ļ‡.emitComponent(Ļ‡.resolve(Foo)()); - Ļ‡.applySplattributes(ššŖ.element, š›„.element); + const __glintY__ = __glintDSL__.emitComponent(__glintDSL__.resolve(Foo)()); + __glintDSL__.applySplattributes(__glintRef__.element, __glintY__.element); }" `); }); @@ -1137,19 +1137,19 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template, { globals: ['let'] })).toMatchInlineSnapshot(` "{ - const š›„ = Ļ‡.emitComponent(Ļ‡.resolve(Ļ‡.Globals["let"])("div")); + const __glintY__ = __glintDSL__.emitComponent(__glintDSL__.resolve(__glintDSL__.Globals["let"])("div")); { - const [div] = š›„.blockParams["default"]; + const [div] = __glintY__.blockParams["default"]; { - const š›„ = Ļ‡.emitComponent(Ļ‡.resolve(div)()); - š›„; + const __glintY__ = __glintDSL__.emitComponent(__glintDSL__.resolve(div)()); + __glintY__; { - const [] = š›„.blockParams["default"]; + const [] = __glintY__.blockParams["default"]; } div; } } - Ļ‡.Globals["let"]; + __glintDSL__.Globals["let"]; }" `); }); @@ -1159,8 +1159,8 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template, { globals: [] })).toMatchInlineSnapshot(` "{ - const š›„ = Ļ‡.emitComponent(Ļ‡.resolve(foo?.bar)({ arg: "hello", ...Ļ‡.NamedArgsMarker })); - š›„; + const __glintY__ = __glintDSL__.emitComponent(__glintDSL__.resolve(foo?.bar)({ arg: "hello", ...__glintDSL__.NamedArgsMarker })); + __glintY__; }" `); }); @@ -1170,8 +1170,8 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template)).toMatchInlineSnapshot(` "{ - const š›„ = Ļ‡.emitComponent(Ļ‡.resolve(ššŖ.args.foo)({ arg: "hello", ...Ļ‡.NamedArgsMarker })); - š›„; + const __glintY__ = __glintDSL__.emitComponent(__glintDSL__.resolve(__glintRef__.args.foo)({ arg: "hello", ...__glintDSL__.NamedArgsMarker })); + __glintY__; }" `); }); @@ -1181,8 +1181,8 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template)).toMatchInlineSnapshot(` "{ - const š›„ = Ļ‡.emitComponent(Ļ‡.resolve(ššŖ.this.foo)({ arg: "hello", ...Ļ‡.NamedArgsMarker })); - š›„; + const __glintY__ = __glintDSL__.emitComponent(__glintDSL__.resolve(__glintRef__.this.foo)({ arg: "hello", ...__glintDSL__.NamedArgsMarker })); + __glintY__; }" `); }); @@ -1202,24 +1202,24 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template)).toMatchInlineSnapshot(` "{ - const š›„ = Ļ‡.emitComponent(Ļ‡.resolve(Ļ‡.Globals["Foo"])()); - š›„; + const __glintY__ = __glintDSL__.emitComponent(__glintDSL__.resolve(__glintDSL__.Globals["Foo"])()); + __glintY__; { - const [h] = š›„.blockParams["head"]; - Ļ‡.emitContent(Ļ‡.resolveOrReturn(h)()); + const [h] = __glintY__.blockParams["head"]; + __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(h)()); } { - const [b] = š›„.blockParams["body"]; + const [b] = __glintY__.blockParams["body"]; { - const š›„ = Ļ‡.emitComponent(Ļ‡.resolve(b?.contents)()); - š›„; + const __glintY__ = __glintDSL__.emitComponent(__glintDSL__.resolve(b?.contents)()); + __glintY__; { - const [] = š›„.blockParams["default"]; + const [] = __glintY__.blockParams["default"]; } b?.contents; } } - Ļ‡.Globals["Foo"]; + __glintDSL__.Globals["Foo"]; }" `); }); @@ -1229,8 +1229,8 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template, { globals: [] })).toMatchInlineSnapshot(` "{ - const š›„ = Ļ‡.emitComponent(Ļ‡.resolve(Foo)({ arg: \`\${Ļ‡.resolveOrReturn(baz)()}\`, ...Ļ‡.NamedArgsMarker })); - š›„; + const __glintY__ = __glintDSL__.emitComponent(__glintDSL__.resolve(Foo)({ arg: \`\${__glintDSL__.resolveOrReturn(baz)()}\`, ...__glintDSL__.NamedArgsMarker })); + __glintY__; }" `); }); @@ -1244,18 +1244,18 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template)).toMatchInlineSnapshot(` "{ - const š›„ = Ļ‡.emitComponent(Ļ‡.resolve(Ļ‡.Globals["Foo"])()); - š›„; + const __glintY__ = __glintDSL__.emitComponent(__glintDSL__.resolve(__glintDSL__.Globals["Foo"])()); + __glintY__; { - const [NS] = š›„.blockParams["default"]; + const [NS] = __glintY__.blockParams["default"]; { - const š›„ = Ļ‡.emitComponent(Ļ‡.resolve(NS?.Nested?.Custom)()); - Ļ‡.applyAttributes(š›„.element, { + const __glintY__ = __glintDSL__.emitComponent(__glintDSL__.resolve(NS?.Nested?.Custom)()); + __glintDSL__.applyAttributes(__glintY__.element, { class: "foo", }); } } - Ļ‡.Globals["Foo"]; + __glintDSL__.Globals["Foo"]; }" `); }); @@ -1269,13 +1269,13 @@ describe('Transform: rewriteTemplate', () => { expect(templateBody(template)).toMatchInlineSnapshot(` "{ - const š›„ = Ļ‡.emitComponent(Ļ‡.resolve(Ļ‡.Globals["Foo"])()); - š›„; + const __glintY__ = __glintDSL__.emitComponent(__glintDSL__.resolve(__glintDSL__.Globals["Foo"])()); + __glintY__; { - const [__switch] = š›„.blockParams["default"]; - Ļ‡.emitContent(Ļ‡.resolveOrReturn(__switch)()); + const [__switch] = __glintY__.blockParams["default"]; + __glintDSL__.emitContent(__glintDSL__.resolveOrReturn(__switch)()); } - Ļ‡.Globals["Foo"]; + __glintDSL__.Globals["Foo"]; }" `); }); diff --git a/packages/core/src/transform/template/template-to-typescript.ts b/packages/core/src/transform/template/template-to-typescript.ts index 6d5a2df20..214c0ab65 100644 --- a/packages/core/src/transform/template/template-to-typescript.ts +++ b/packages/core/src/transform/template/template-to-typescript.ts @@ -90,15 +90,15 @@ export function templateToTypescript( } if (backingValue) { - emit.text(`.templateForBackingValue(${backingValue}, function(ššŖ`); + emit.text(`.templateForBackingValue(${backingValue}, function(__glintRef__`); } else { - emit.text(`.templateExpression(function(ššŖ`); + emit.text(`.templateExpression(function(__glintRef__`); } if (useJsDoc) { - emit.text(`, /** @type {typeof import("${typesModule}")} */ Ļ‡) {`); + emit.text(`, /** @type {typeof import("${typesModule}")} */ __glintDSL__) {`); } else { - emit.text(`, Ļ‡: typeof import("${typesModule}")) {`); + emit.text(`, __glintDSL__: typeof import("${typesModule}")) {`); } emit.newline(); @@ -115,7 +115,7 @@ export function templateToTypescript( // Ensure the context and lib variables are always consumed to prevent // an unused variable warning - emit.text('ššŖ; Ļ‡;'); + emit.text('__glintRef__; __glintDSL__;'); emit.newline(); emit.dedent(); @@ -174,7 +174,7 @@ export function templateToTypescript( position: InvokePosition, ): void { if (formInfo.requiresConsumption) { - emit.text('(Ļ‡.noop('); + emit.text('(__glintDSL__.noop('); emitExpression(node.path); emit.text('), '); } @@ -249,7 +249,7 @@ export function templateToTypescript( ); if (position === 'top-level') { - emit.text('Ļ‡.emitContent('); + emit.text('__glintDSL__.emitContent('); } // Treat the first argument to a bind-invokable expression (`{{component}}`, @@ -260,9 +260,9 @@ export function templateToTypescript( // invokable is the source of record for its own type and we don't want inference // from the `resolveForBind` call to be affected by other (potentially incorrect) // parameter types. - emit.text('Ļ‡.resolve('); + emit.text('__glintDSL__.resolve('); emitExpression(node.path); - emit.text(')((() => Ļ‡.resolveForBind('); + emit.text(')((() => __glintDSL__.resolveForBind('); emitExpression(node.params[0]); emit.text('))(), '); emitArgs(node.params.slice(1), node.hash); @@ -528,7 +528,7 @@ export function templateToTypescript( function emitIdentifierReference(name: string, hbsOffset: number): void { if (treatAsGlobal(name)) { - emit.text('Ļ‡.Globals["'); + emit.text('__glintDSL__.Globals["'); emit.identifier(JSON.stringify(name).slice(1, -1), hbsOffset, name.length); emit.text('"]'); } else { @@ -592,7 +592,7 @@ export function templateToTypescript( emit.newline(); emit.indent(); - emit.text('const š›„ = Ļ‡.emitComponent(Ļ‡.resolve('); + emit.text('const __glintY__ = __glintDSL__.emitComponent(__glintDSL__.resolve('); emitPathContents(path, start, kind); emit.text(')('); @@ -625,7 +625,7 @@ export function templateToTypescript( emit.text(', '); } - emit.text('...Ļ‡.NamedArgsMarker }'); + emit.text('...__glintDSL__.NamedArgsMarker }'); } emit.text('));'); @@ -756,7 +756,7 @@ export function templateToTypescript( emit.newline(); emit.indent(); - emit.text('const š›„ = Ļ‡.emitElement('); + emit.text('const __glintY__ = __glintDSL__.emitElement('); emit.text(JSON.stringify(node.tag)); emit.text(');'); emit.newline(); @@ -777,7 +777,7 @@ export function templateToTypescript( let nonArgAttributes = node.attributes.filter((attr) => !attr.name.startsWith('@')); if (!nonArgAttributes.length && !node.modifiers.length) { // Avoid unused-symbol diagnostics - emit.text('š›„;'); + emit.text('__glintY__;'); emit.newline(); } else { emitSplattributes(node); @@ -793,7 +793,7 @@ export function templateToTypescript( if (!attributes.length) return; - emit.text('Ļ‡.applyAttributes(š›„.element, {'); + emit.text('__glintDSL__.applyAttributes(__glintY__.element, {'); emit.newline(); emit.indent(); @@ -834,7 +834,7 @@ export function templateToTypescript( ); emit.forNode(splattributes, () => { - emit.text('Ļ‡.applySplattributes(ššŖ.element, š›„.element);'); + emit.text('__glintDSL__.applySplattributes(__glintRef__.element, __glintY__.element);'); }); emit.newline(); @@ -843,9 +843,9 @@ export function templateToTypescript( function emitModifiers(node: AST.ElementNode): void { for (let modifier of node.modifiers) { emit.forNode(modifier, () => { - emit.text('Ļ‡.applyModifier(Ļ‡.resolve('); + emit.text('__glintDSL__.applyModifier(__glintDSL__.resolve('); emitExpression(modifier.path); - emit.text(')(š›„.element, '); + emit.text(')(__glintY__.element, '); emitArgs(modifier.params, modifier.hash); emit.text('));'); emit.newline(); @@ -879,7 +879,7 @@ export function templateToTypescript( if (!hasParams && position === 'arg' && !isGlobal(node.path)) { emitExpression(node.path); } else if (position === 'top-level') { - emit.text('Ļ‡.emitContent('); + emit.text('__glintDSL__.emitContent('); emitResolve(node, hasParams ? 'resolve' : 'resolveOrReturn'); emit.text(')'); } else { @@ -922,7 +922,7 @@ export function templateToTypescript( to = 'else'; } - emit.text('Ļ‡.yieldToBlock(ššŖ, '); + emit.text('__glintDSL__.yieldToBlock(__glintRef__, '); emit.text(JSON.stringify(to)); emit.text(')('); @@ -1048,7 +1048,7 @@ export function templateToTypescript( emit.newline(); emit.indent(); - emit.text('const š›„ = Ļ‡.emitComponent('); + emit.text('const __glintY__ = __glintDSL__.emitComponent('); emitResolve(node, 'resolve'); emit.text(');'); emit.newline(); @@ -1113,7 +1113,7 @@ export function templateToTypescript( emit.identifier(makeJSSafe(param), start, param.length); } - emit.text('] = š›„.blockParams'); + emit.text('] = __glintY__.blockParams'); emitPropertyAccesss(name, { offset: nameOffset, synthetic: true }); emit.text(';'); emit.newline(); @@ -1150,10 +1150,10 @@ export function templateToTypescript( function emitResolve(node: CurlyInvocationNode, resolveType: string): void { // We use forNode here to wrap the emitted resolve expression here so that when // we convert to Volar mappings, we can create a boundary around - // e.g. "Ļ‡.resolveOrReturn(expectsAtLeastOneArg)()", which is required because + // e.g. "__glintDSL__.resolveOrReturn(expectsAtLeastOneArg)()", which is required because // this is where TS might generate a diagnostic error. emit.forNode(node, () => { - emit.text('Ļ‡.'); + emit.text('__glintDSL__.'); emit.text(resolveType); emit.text('('); emitExpression(node.path); @@ -1198,7 +1198,7 @@ export function templateToTypescript( emit.text(', '); } - emit.text('...Ļ‡.NamedArgsMarker }'); + emit.text('...__glintDSL__.NamedArgsMarker }'); }); } } @@ -1219,11 +1219,11 @@ export function templateToTypescript( function emitPathContents(parts: string[], start: number, kind: PathKind): void { if (kind === 'this') { let thisStart = template.indexOf('this', start); - emit.text('ššŖ.'); + emit.text('__glintRef__.'); emit.identifier('this', thisStart); start = template.indexOf('.', thisStart) + 1; } else if (kind === 'arg') { - emit.text('ššŖ.args'); + emit.text('__glintRef__.args'); start = template.indexOf('@', start) + 1; } diff --git a/packages/core/src/transform/template/transformed-module.ts b/packages/core/src/transform/template/transformed-module.ts index 263809c54..4aaa99444 100644 --- a/packages/core/src/transform/template/transformed-module.ts +++ b/packages/core/src/transform/template/transformed-module.ts @@ -226,7 +226,7 @@ export default class TransformedModule { * * The main difference between the two formats is that while the classic Glint transformation * mappings support mapping a differently sized source region to a differently sized target region - * (e.g. `{{expectsAtLeastOneArg}}` in an .hbs file to `Ļ‡.emitContent(Ļ‡.resolveOrReturn(expectsAtLeastOneArg)());` + * (e.g. `{{expectsAtLeastOneArg}}` in an .hbs file to `__glintDSL__.emitContent(__glintDSL__.resolveOrReturn(expectsAtLeastOneArg)());` * in a generated TS file, in Volar you can only map regions of the same size. * * In the case that you need to map regions of different sizes in Volar, you need to also using @@ -235,7 +235,7 @@ export default class TransformedModule { * * - `{{[[ZEROLEN-A]][[expectsAtLeastOneArg]][[ZEROLEN-B]]}}` * - to - * - `[[ZEROLEN-A]]Ļ‡.emitContent(Ļ‡.resolveOrReturn([[expectsAtLeastOneArg]])());[[ZEROLEN-B]]` + * - `[[ZEROLEN-A]]__glintDSL__.emitContent(__glintDSL__.resolveOrReturn([[expectsAtLeastOneArg]])());[[ZEROLEN-B]]` */ public toVolarMappings(filenameFilter?: string): CodeMapping[] { const sourceOffsets: number[] = []; diff --git a/packages/core/src/volar/ember-language-plugin.ts b/packages/core/src/volar/ember-language-plugin.ts index 7af7ca892..2a7715dfd 100644 --- a/packages/core/src/volar/ember-language-plugin.ts +++ b/packages/core/src/volar/ember-language-plugin.ts @@ -39,24 +39,24 @@ export function createEmberLanguagePlugin( }, // When does this get called? - createVirtualCode(scriptId: URI | string, languageId, snapshot /*, codegenContext */) { + createVirtualCode(scriptId: URI | string, languageId, snapshot, codegenContext) { const scriptIdStr = String(scriptId); // See: https://github.com/JetBrains/intellij-plugins/blob/11a9149e20f4d4ba2c1600da9f2b81ff88bd7c97/Angular/src/angular-service/src/index.ts#L31 if ( + glintConfig.enableTsPlugin && languageId === 'typescript' && !scriptIdStr.endsWith('.d.ts') && scriptIdStr.indexOf('/node_modules/') < 0 ) { // NOTE: scriptId might not be a path when we convert this plugin: // https://github.com/withastro/language-tools/blob/eb7215cc0ab3a8f614455528cd71b81ea994cf68/packages/ts-plugin/src/language.ts#L19 - // TODO: commented out for now because support for ember-loose is blocking behind converting to TS Plugin and this will just slow things down - // return new LooseModeBackingComponentClassVirtualCode( - // glintConfig, - // snapshot, - // scriptId, - // codegenContext, - // ); + return new LooseModeBackingComponentClassVirtualCode( + glintConfig, + snapshot, + scriptId, + codegenContext, + ); } if (languageId === 'glimmer-ts' || languageId === 'glimmer-js') { diff --git a/packages/environment-ember-loose/__tests__/type-tests/ember-component.test.ts b/packages/environment-ember-loose/__tests__/type-tests/ember-component.test.ts index 76c17bcb3..a3b3f1afa 100644 --- a/packages/environment-ember-loose/__tests__/type-tests/ember-component.test.ts +++ b/packages/environment-ember-loose/__tests__/type-tests/ember-component.test.ts @@ -12,8 +12,8 @@ import type { ComponentLike } from '@glint/template'; { class NoArgsComponent extends Component { static { - templateForBackingValue(this, function (ššŖ) { - ššŖ; + templateForBackingValue(this, function (__glintRef__) { + __glintRef__; }); } } @@ -40,10 +40,10 @@ import type { ComponentLike } from '@glint/template'; private foo = 'hello'; static { - templateForBackingValue(this, function* (ššŖ) { - expectTypeOf(ššŖ.this.foo).toEqualTypeOf(); - expectTypeOf(ššŖ.this).toEqualTypeOf(); - expectTypeOf(ššŖ.args).toEqualTypeOf<{}>(); + templateForBackingValue(this, function* (__glintRef__) { + expectTypeOf(__glintRef__.this.foo).toEqualTypeOf(); + expectTypeOf(__glintRef__.this).toEqualTypeOf(); + expectTypeOf(__glintRef__.args).toEqualTypeOf<{}>(); }); } } @@ -67,24 +67,24 @@ import type { ComponentLike } from '@glint/template'; interface YieldingComponent extends YieldingComponentArgs {} class YieldingComponent extends Component> { static { - templateForBackingValue(this, function* (ššŖ) { + templateForBackingValue(this, function* (__glintRef__) { // We can't directly assert on the type of e.g. `@values` here, as we don't // have a name for it in scope: the type `T` is present on the class instance, // but not in a `static` block. However, the yields below confirm that the // `@values` arg, since the only information we have about that type is that // the array element and the yielded value are the same. yieldToBlock( - ššŖ, + __glintRef__, 'default', )( // @ts-expect-error: only a `T` is a valid yield 123, ); - if (ššŖ.args.values.length) { - yieldToBlock(ššŖ, 'default')(ššŖ.args.values[0]); + if (__glintRef__.args.values.length) { + yieldToBlock(__glintRef__, 'default')(__glintRef__.args.values[0]); } else { - yieldToBlock(ššŖ, 'else')(); + yieldToBlock(__glintRef__, 'else')(); } }); } diff --git a/packages/environment-ember-loose/__tests__/type-tests/glimmer-component.test.ts b/packages/environment-ember-loose/__tests__/type-tests/glimmer-component.test.ts index acacc7bb8..364674a6e 100644 --- a/packages/environment-ember-loose/__tests__/type-tests/glimmer-component.test.ts +++ b/packages/environment-ember-loose/__tests__/type-tests/glimmer-component.test.ts @@ -34,10 +34,10 @@ import { ComponentLike } from '@glint/template'; private foo = 'hello'; static { - templateForBackingValue(this, function* (ššŖ) { - expectTypeOf(ššŖ.this.foo).toEqualTypeOf(); - expectTypeOf(ššŖ.this).toEqualTypeOf(); - expectTypeOf(ššŖ.args).toEqualTypeOf<{}>(); + templateForBackingValue(this, function* (__glintRef__) { + expectTypeOf(__glintRef__.this.foo).toEqualTypeOf(); + expectTypeOf(__glintRef__.this).toEqualTypeOf(); + expectTypeOf(__glintRef__.args).toEqualTypeOf<{}>(); }); } } @@ -58,24 +58,24 @@ import { ComponentLike } from '@glint/template'; class YieldingComponent extends Component> { static { - templateForBackingValue(this, function* (ššŖ) { + templateForBackingValue(this, function* (__glintRef__) { // We can't directly assert on the type of e.g. `@values` here, as we don't // have a name for it in scope: the type `T` is present on the class instance, // but not in a `static` block. However, the yields below confirm that the // `@values` arg, since the only information we have about that type is that // the array element and the yielded value are the same. yieldToBlock( - ššŖ, + __glintRef__, 'default', )( // @ts-expect-error: only a `T` is a valid yield 123, ); - if (ššŖ.args.values.length) { - yieldToBlock(ššŖ, 'default')(ššŖ.args.values[0]); + if (__glintRef__.args.values.length) { + yieldToBlock(__glintRef__, 'default')(__glintRef__.args.values[0]); } else { - yieldToBlock(ššŖ, 'else')(); + yieldToBlock(__glintRef__, 'else')(); } }); } diff --git a/packages/environment-ember-loose/__tests__/type-tests/intrinsics/input.test.ts b/packages/environment-ember-loose/__tests__/type-tests/intrinsics/input.test.ts index a5d1a38ec..5d7f15a27 100644 --- a/packages/environment-ember-loose/__tests__/type-tests/intrinsics/input.test.ts +++ b/packages/environment-ember-loose/__tests__/type-tests/intrinsics/input.test.ts @@ -26,8 +26,8 @@ Input({ type: 'string', value: 'hello', ...NamedArgsMarker }); // Ensure we can apply -specific attributes { - const š›„ = emitComponent(Input()); - applySplattributes(new HTMLInputElement(), š›„.element); + const __glintY__ = emitComponent(Input()); + applySplattributes(new HTMLInputElement(), __glintY__.element); } // @ts-expect-error: `checked` only works with `@type=checkbox` diff --git a/packages/environment-ember-loose/__tests__/type-tests/intrinsics/textarea.test.ts b/packages/environment-ember-loose/__tests__/type-tests/intrinsics/textarea.test.ts index ef4f1342e..3eed7d1f9 100644 --- a/packages/environment-ember-loose/__tests__/type-tests/intrinsics/textarea.test.ts +++ b/packages/environment-ember-loose/__tests__/type-tests/intrinsics/textarea.test.ts @@ -20,8 +20,8 @@ Textarea({ value: null, ...NamedArgsMarker }); // Ensure we can apply