ember-repl 2.0.63 → 3.0.0-beta.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.
Files changed (88) hide show
  1. package/README.md +31 -0
  2. package/addon-main.cjs +5 -0
  3. package/dist/browser/cjs/eval.d.ts +10 -0
  4. package/dist/browser/cjs/eval.d.ts.map +1 -0
  5. package/dist/browser/cjs/eval.js +22 -0
  6. package/dist/browser/cjs/eval.js.map +1 -0
  7. package/dist/browser/cjs/index.d.ts +7 -0
  8. package/dist/browser/cjs/index.js +43 -0
  9. package/dist/browser/cjs/index.js.map +1 -0
  10. package/dist/browser/esm/index.d.ts +8 -0
  11. package/dist/browser/esm/index.js +67 -0
  12. package/dist/browser/esm/index.js.map +1 -0
  13. package/dist/browser/eti/babel-plugin.d.ts +54 -0
  14. package/dist/browser/eti/babel-plugin.js +95 -0
  15. package/dist/browser/eti/babel-plugin.js.map +1 -0
  16. package/dist/browser/eti/debug.d.ts +2 -0
  17. package/dist/browser/eti/debug.js +9 -0
  18. package/dist/browser/eti/debug.js.map +1 -0
  19. package/dist/browser/eti/parse-templates.d.ts +56 -0
  20. package/dist/browser/eti/parse-templates.js +181 -0
  21. package/dist/browser/eti/parse-templates.js.map +1 -0
  22. package/dist/browser/eti/preprocess.d.ts +57 -0
  23. package/dist/browser/eti/preprocess.js +271 -0
  24. package/dist/browser/eti/preprocess.js.map +1 -0
  25. package/dist/browser/eti/template-tag-transform.d.ts +15 -0
  26. package/dist/browser/eti/template-tag-transform.js +46 -0
  27. package/dist/browser/eti/template-tag-transform.js.map +1 -0
  28. package/dist/browser/eti/util.d.ts +14 -0
  29. package/dist/browser/eti/util.js +39 -0
  30. package/dist/browser/eti/util.js.map +1 -0
  31. package/dist/browser/gjs.d.ts +4 -0
  32. package/dist/browser/gjs.js +40 -0
  33. package/dist/browser/gjs.js.map +1 -0
  34. package/{hbs.d.ts → dist/browser/hbs.d.ts} +3 -6
  35. package/dist/browser/hbs.js +94 -0
  36. package/dist/browser/hbs.js.map +1 -0
  37. package/dist/browser/index.d.ts +5 -0
  38. package/dist/browser/index.js +5 -0
  39. package/dist/browser/index.js.map +1 -0
  40. package/{js.d.ts → dist/browser/js.d.ts} +3 -6
  41. package/dist/browser/js.js +38 -0
  42. package/dist/browser/js.js.map +1 -0
  43. package/{known-modules.d.ts → dist/browser/known-modules.d.ts} +6 -3
  44. package/dist/browser/known-modules.js +48 -0
  45. package/dist/browser/known-modules.js.map +1 -0
  46. package/dist/browser/types.d.ts +17 -0
  47. package/dist/browser/types.js +2 -0
  48. package/dist/browser/types.js.map +1 -0
  49. package/{utils.d.ts → dist/browser/utils.d.ts} +8 -3
  50. package/dist/browser/utils.js +46 -0
  51. package/dist/browser/utils.js.map +1 -0
  52. package/dist/build/ember-cli.cjs +36 -0
  53. package/package.json +98 -125
  54. package/{addon → src/browser}/cjs/eval.ts +9 -5
  55. package/src/browser/cjs/index.ts +44 -0
  56. package/src/browser/esm/index.ts +80 -0
  57. package/src/browser/eti/babel-plugin.ts +105 -0
  58. package/src/browser/eti/debug.ts +7 -0
  59. package/src/browser/eti/parse-templates.ts +284 -0
  60. package/src/browser/eti/preprocess.ts +187 -0
  61. package/src/browser/eti/template-tag-transform.ts +100 -0
  62. package/src/browser/eti/util.ts +72 -0
  63. package/src/browser/gjs.ts +59 -0
  64. package/{addon → src/browser}/hbs.ts +18 -6
  65. package/{addon → src/browser}/js.ts +6 -2
  66. package/{addon → src/browser}/known-modules.ts +4 -0
  67. package/{addon → src/browser}/types.ts +2 -1
  68. package/{addon → src/browser}/utils.ts +6 -2
  69. package/src/build/ember-cli.cjs +36 -0
  70. package/.github/renovate.json5 +0 -93
  71. package/.github/workflows/ci.yml +0 -120
  72. package/.github/workflows/lint.yml +0 -88
  73. package/.github/workflows/types.yml +0 -30
  74. package/CHANGELOG.md +0 -745
  75. package/addon/cjs/index.ts +0 -100
  76. package/addon/esm/index.ts +0 -131
  77. package/cjs/eval.d.ts +0 -8
  78. package/cjs/index.d.ts +0 -10
  79. package/config/environment.js +0 -5
  80. package/esm/index.d.ts +0 -11
  81. package/index.d.ts +0 -5
  82. package/index.js +0 -105
  83. package/tsconfig.json +0 -56
  84. package/types/dummy/index.d.ts +0 -1
  85. package/types/global.d.ts +0 -43
  86. package/types/overrides.d.ts +0 -18
  87. package/types.d.ts +0 -15
  88. /package/{addon → src/browser}/index.ts +0 -0
package/README.md CHANGED
@@ -28,6 +28,37 @@ your app's initial time-to-interactive/etc stats.
28
28
  ember install ember-repl
29
29
  ```
30
30
 
31
+ ## Setup
32
+
33
+ This library uses babel, which does some goofy things in the browser.
34
+ You'll need to define a global `process` and `Buffer` somewhere in your app.
35
+
36
+ For example:
37
+ ```js
38
+ // app/app.js
39
+
40
+ // @babel/traverse (from babel-plugin-ember-template-imports)
41
+ // accesses process.....
42
+ // maybe one day we can have a browser-only verison?
43
+ // But they aren't used.... so.. that's fun.
44
+ Object.assign(window, {
45
+ process: { env: {} },
46
+ Buffer: {},
47
+ });
48
+
49
+ ```
50
+
51
+ Additionally, because the ember-template-compiler is presently "goofy" in `ember-source`, we must do this in `ember-cli-build.js`:
52
+
53
+ ```js
54
+ const app = new EmberApp(defaults, {
55
+ // ...
56
+ });
57
+ app.import('vendor/ember/ember-template-compiler.js');
58
+
59
+ // ...
60
+ ```
61
+
31
62
  ## Usage
32
63
 
33
64
  **`compileJS`**
package/addon-main.cjs ADDED
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ const { addonV1Shim } = require('@embroider/addon-shim');
4
+
5
+ module.exports = addonV1Shim(__dirname);
@@ -0,0 +1,10 @@
1
+ import { ExtraModules } from "../types.js";
2
+ import Component from '@glimmer/component';
3
+ declare function evalSnippet(compiled: string, extraModules?: ExtraModules): {
4
+ default: Component;
5
+ services?: {
6
+ [key: string]: unknown;
7
+ };
8
+ };
9
+ export { evalSnippet };
10
+ //# sourceMappingURL=browser/cjs/eval.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser/cjs/eval.d.ts","sourceRoot":"","sources":["../src/browser/cjs/eval.ts"],"names":[],"mappings":"AAGA,OAAO,gBAAqB,oBAAiB;AAC7C,OAAO,SAAc,MAAM,oBAAoB,CAAC;AAEhD,iBAAgB,WAAW,CACzB,QAAQ,EAAE,MAAM,EAChB,YAAY,GAAE,YAAiB,GAC9B;IACD,OAAO,EAAE,SAAS,CAAC;IACnB,QAAQ,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;CACvC,CAmBA"}
@@ -0,0 +1,22 @@
1
+ import { modules } from '../known-modules.js';
2
+
3
+ /* eslint-disable @typescript-eslint/no-unused-vars */
4
+ function evalSnippet(compiled, extraModules = {}) {
5
+ const exports = {};
6
+ function require(moduleName) {
7
+ let preConfigured = modules[moduleName] || extraModules[moduleName];
8
+
9
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
10
+ // @ts-ignore
11
+ return preConfigured || window.require(moduleName);
12
+ }
13
+
14
+ // https://github.com/glimmerjs/glimmer-experimental/blob/master/packages/examples/playground/src/utils/eval-snippet.ts
15
+ eval(compiled);
16
+ return Object.assign(exports, {
17
+ require
18
+ });
19
+ }
20
+
21
+ export { evalSnippet };
22
+ //# sourceMappingURL=eval.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eval.js","sources":["../../../src/browser/cjs/eval.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { modules } from '../known-modules';\n\nimport type { ExtraModules } from '../types';\nimport type Component from '@glimmer/component';\n\nexport function evalSnippet(\n compiled: string,\n extraModules: ExtraModules = {}\n): {\n default: Component;\n services?: { [key: string]: unknown };\n} {\n const exports = {};\n\n function require(moduleName: keyof typeof modules): unknown {\n let preConfigured = modules[moduleName] || extraModules[moduleName];\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return preConfigured || window.require(moduleName);\n }\n\n // https://github.com/glimmerjs/glimmer-experimental/blob/master/packages/examples/playground/src/utils/eval-snippet.ts\n eval(compiled);\n\n return Object.assign(exports, { require }) as {\n default: Component;\n services?: { [key: string]: unknown };\n require: unknown;\n };\n}\n"],"names":["evalSnippet","compiled","extraModules","exports","require","moduleName","preConfigured","modules","window","eval","Object","assign"],"mappings":";;AAAA;AAMO,SAASA,WAAWA,CACzBC,QAAgB,EAChBC,YAA0B,GAAG,EAAE,EAI/B;EACA,MAAMC,OAAO,GAAG,EAAE,CAAA;EAElB,SAASC,OAAOA,CAACC,UAAgC,EAAW;IAC1D,IAAIC,aAAa,GAAGC,OAAO,CAACF,UAAU,CAAC,IAAIH,YAAY,CAACG,UAAU,CAAC,CAAA;;AAEnE;AACA;AACA,IAAA,OAAOC,aAAa,IAAIE,MAAM,CAACJ,OAAO,CAACC,UAAU,CAAC,CAAA;AACpD,GAAA;;AAEA;EACAI,IAAI,CAACR,QAAQ,CAAC,CAAA;AAEd,EAAA,OAAOS,MAAM,CAACC,MAAM,CAACR,OAAO,EAAE;AAAEC,IAAAA,OAAAA;AAAQ,GAAC,CAAC,CAAA;AAK5C;;;;"}
@@ -0,0 +1,7 @@
1
+ import { CompileResult, ExtraModules } from "../types.js";
2
+ interface Info {
3
+ code: string;
4
+ name: string;
5
+ }
6
+ declare function compileJS(code: string, extraModules?: ExtraModules): Promise<CompileResult>;
7
+ export { Info, compileJS };
@@ -0,0 +1,43 @@
1
+ import { preprocess, transform } from '../gjs.js';
2
+ import { nameFor } from '../utils.js';
3
+ import { evalSnippet } from './eval.js';
4
+
5
+ async function compileJS(code, extraModules) {
6
+ let name = nameFor(code);
7
+ let component;
8
+ let error;
9
+ try {
10
+ let compiled = await compileGJS({
11
+ code: code,
12
+ name
13
+ });
14
+ if (!compiled) {
15
+ throw new Error(`Compiled output is missing`);
16
+ }
17
+ component = evalSnippet(compiled, extraModules).default;
18
+ } catch (e) {
19
+ error = e;
20
+ }
21
+ return {
22
+ name,
23
+ component,
24
+ error
25
+ };
26
+ }
27
+ async function compileGJS({
28
+ code: input,
29
+ name
30
+ }) {
31
+ let preprocessed = preprocess(input, name);
32
+ let result = await transform(preprocessed, name);
33
+ if (!result) {
34
+ return;
35
+ }
36
+ let {
37
+ code
38
+ } = result;
39
+ return code;
40
+ }
41
+
42
+ export { compileJS };
43
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../src/browser/cjs/index.ts"],"sourcesContent":["import { preprocess, transform } from '../gjs';\nimport { nameFor } from '../utils';\nimport { evalSnippet } from './eval';\n\nimport type { CompileResult, ExtraModules } from '../types';\nimport type { ComponentLike } from '@glint/template';\n\nexport interface Info {\n code: string;\n name: string;\n}\n\nexport async function compileJS(code: string, extraModules?: ExtraModules): Promise<CompileResult> {\n let name = nameFor(code);\n let component: undefined | ComponentLike;\n let error: undefined | Error;\n\n try {\n let compiled = await compileGJS({ code: code, name });\n\n if (!compiled) {\n throw new Error(`Compiled output is missing`);\n }\n\n component = evalSnippet(compiled, extraModules).default as unknown as ComponentLike;\n } catch (e) {\n error = e as Error | undefined;\n }\n\n return { name, component, error };\n}\n\nasync function compileGJS({ code: input, name }: Info) {\n let preprocessed = preprocess(input, name);\n let result = await transform(preprocessed, name);\n\n if (!result) {\n return;\n }\n\n let { code } = result;\n\n return code;\n}\n"],"names":["compileJS","code","extraModules","name","nameFor","component","error","compiled","compileGJS","Error","evalSnippet","default","e","input","preprocessed","preprocess","result","transform"],"mappings":";;;;AAYO,eAAeA,SAASA,CAACC,IAAY,EAAEC,YAA2B,EAA0B;AACjG,EAAA,IAAIC,IAAI,GAAGC,OAAO,CAACH,IAAI,CAAC,CAAA;AACxB,EAAA,IAAII,SAAoC,CAAA;AACxC,EAAA,IAAIC,KAAwB,CAAA;EAE5B,IAAI;AACF,IAAA,IAAIC,QAAQ,GAAG,MAAMC,UAAU,CAAC;AAAEP,MAAAA,IAAI,EAAEA,IAAI;AAAEE,MAAAA,IAAAA;AAAK,KAAC,CAAC,CAAA;IAErD,IAAI,CAACI,QAAQ,EAAE;AACb,MAAA,MAAM,IAAIE,KAAK,CAAE,CAAA,0BAAA,CAA2B,CAAC,CAAA;AAC/C,KAAA;IAEAJ,SAAS,GAAGK,WAAW,CAACH,QAAQ,EAAEL,YAAY,CAAC,CAACS,OAAmC,CAAA;GACpF,CAAC,OAAOC,CAAC,EAAE;AACVN,IAAAA,KAAK,GAAGM,CAAsB,CAAA;AAChC,GAAA;EAEA,OAAO;IAAET,IAAI;IAAEE,SAAS;AAAEC,IAAAA,KAAAA;GAAO,CAAA;AACnC,CAAA;AAEA,eAAeE,UAAUA,CAAC;AAAEP,EAAAA,IAAI,EAAEY,KAAK;AAAEV,EAAAA,IAAAA;AAAW,CAAC,EAAE;AACrD,EAAA,IAAIW,YAAY,GAAGC,UAAU,CAACF,KAAK,EAAEV,IAAI,CAAC,CAAA;EAC1C,IAAIa,MAAM,GAAG,MAAMC,SAAS,CAACH,YAAY,EAAEX,IAAI,CAAC,CAAA;EAEhD,IAAI,CAACa,MAAM,EAAE;AACX,IAAA,OAAA;AACF,GAAA;EAEA,IAAI;AAAEf,IAAAA,IAAAA;AAAK,GAAC,GAAGe,MAAM,CAAA;AAErB,EAAA,OAAOf,IAAI,CAAA;AACb;;;;"}
@@ -0,0 +1,8 @@
1
+ import { CompileResult, ExtraModules } from "../types.js";
2
+ interface Info {
3
+ code: string;
4
+ name: string;
5
+ }
6
+ declare function compileJS(code: string, extraModules?: ExtraModules): Promise<CompileResult>;
7
+ declare function proxyToSkypack(code: string, extraModules?: ExtraModules): string;
8
+ export { Info, compileJS, proxyToSkypack };
@@ -0,0 +1,67 @@
1
+ import { preprocess, transform } from '../gjs.js';
2
+ import { modules } from '../known-modules.js';
3
+ import { nameFor } from '../utils.js';
4
+
5
+ async function compileJS(code, extraModules) {
6
+ let name = nameFor(code);
7
+ let component;
8
+ let error;
9
+ try {
10
+ let compiled = await compileGJS({
11
+ code: code,
12
+ name
13
+ });
14
+ if (!compiled) {
15
+ throw new Error(`Compiled output is missing`);
16
+ }
17
+
18
+ // NOTE: we cannot `eval` ESM
19
+ compiled = proxyToSkypack(compiled, extraModules);
20
+ component = await evalSnippet(compiled);
21
+ } catch (e) {
22
+ error = e;
23
+ }
24
+ return {
25
+ name,
26
+ component,
27
+ error
28
+ };
29
+ }
30
+ function proxyToSkypack(code, extraModules) {
31
+ let knownModules = [...Object.keys(extraModules || {}), ...Object.keys(modules)];
32
+ let origin = location.origin;
33
+ let result = code.replaceAll(/from ('|")([^"']+)('|")/g, (_, __, modulePath) => {
34
+ if (knownModules.includes(modulePath)) {
35
+ return `from '${origin}/${modulePath}'`;
36
+ }
37
+ return `from 'https://cdn.skypack.dev/${modulePath}'`;
38
+ });
39
+ return result;
40
+ }
41
+ async function evalSnippet(code) {
42
+ let encodedJs = encodeURIComponent(code);
43
+ let result = await import( /* webpackIgnore: true */`data:text/javascript;charset=utf-8,${encodedJs}`);
44
+ if (!result.default) {
45
+ throw new Error(`Expected module to have a default export, found ${Object.keys(result)}`);
46
+ }
47
+ return result;
48
+ }
49
+ async function compileGJS({
50
+ code: input,
51
+ name
52
+ }) {
53
+ let preprocessed = preprocess(input, name);
54
+ let result = await transform(preprocessed, name, {
55
+ modules: false
56
+ });
57
+ if (!result) {
58
+ return;
59
+ }
60
+ let {
61
+ code
62
+ } = result;
63
+ return code;
64
+ }
65
+
66
+ export { compileJS, proxyToSkypack };
67
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../src/browser/esm/index.ts"],"sourcesContent":["import { preprocess, transform } from '../gjs';\nimport { modules } from '../known-modules';\nimport { nameFor } from '../utils';\n\nimport type { CompileResult, ExtraModules } from '../types';\nimport type Component from '@glimmer/component';\nimport type { ComponentLike } from '@glint/template';\n\nexport interface Info {\n code: string;\n name: string;\n}\n\nexport async function compileJS(code: string, extraModules?: ExtraModules): Promise<CompileResult> {\n let name = nameFor(code);\n let component: undefined | ComponentLike;\n let error: undefined | Error;\n\n try {\n let compiled = await compileGJS({ code: code, name });\n\n if (!compiled) {\n throw new Error(`Compiled output is missing`);\n }\n\n // NOTE: we cannot `eval` ESM\n compiled = proxyToSkypack(compiled, extraModules);\n component = (await evalSnippet(compiled)) as unknown as ComponentLike;\n } catch (e) {\n error = e as Error | undefined;\n }\n\n return { name, component, error };\n}\n\nexport function proxyToSkypack(code: string, extraModules?: ExtraModules) {\n let knownModules = [...Object.keys(extraModules || {}), ...Object.keys(modules)];\n let origin = location.origin;\n\n let result = code.replaceAll(/from ('|\")([^\"']+)('|\")/g, (_, __, modulePath) => {\n if (knownModules.includes(modulePath)) {\n return `from '${origin}/${modulePath}'`;\n }\n\n return `from 'https://cdn.skypack.dev/${modulePath}'`;\n });\n\n return result;\n}\n\nasync function evalSnippet(code: string) {\n let encodedJs = encodeURIComponent(code);\n let result = await import(\n /* webpackIgnore: true */ `data:text/javascript;charset=utf-8,${encodedJs}`\n );\n\n if (!result.default) {\n throw new Error(`Expected module to have a default export, found ${Object.keys(result)}`);\n }\n\n return result as {\n default: Component;\n services?: { [key: string]: unknown };\n };\n}\n\nasync function compileGJS({ code: input, name }: Info) {\n let preprocessed = preprocess(input, name);\n let result = await transform(preprocessed, name, {\n modules: false,\n });\n\n if (!result) {\n return;\n }\n\n let { code } = result;\n\n return code;\n}\n"],"names":["compileJS","code","extraModules","name","nameFor","component","error","compiled","compileGJS","Error","proxyToSkypack","evalSnippet","e","knownModules","Object","keys","modules","origin","location","result","replaceAll","_","__","modulePath","includes","encodedJs","encodeURIComponent","default","input","preprocessed","preprocess","transform"],"mappings":";;;;AAaO,eAAeA,SAASA,CAACC,IAAY,EAAEC,YAA2B,EAA0B;AACjG,EAAA,IAAIC,IAAI,GAAGC,OAAO,CAACH,IAAI,CAAC,CAAA;AACxB,EAAA,IAAII,SAAoC,CAAA;AACxC,EAAA,IAAIC,KAAwB,CAAA;EAE5B,IAAI;AACF,IAAA,IAAIC,QAAQ,GAAG,MAAMC,UAAU,CAAC;AAAEP,MAAAA,IAAI,EAAEA,IAAI;AAAEE,MAAAA,IAAAA;AAAK,KAAC,CAAC,CAAA;IAErD,IAAI,CAACI,QAAQ,EAAE;AACb,MAAA,MAAM,IAAIE,KAAK,CAAE,CAAA,0BAAA,CAA2B,CAAC,CAAA;AAC/C,KAAA;;AAEA;AACAF,IAAAA,QAAQ,GAAGG,cAAc,CAACH,QAAQ,EAAEL,YAAY,CAAC,CAAA;AACjDG,IAAAA,SAAS,GAAI,MAAMM,WAAW,CAACJ,QAAQ,CAA8B,CAAA;GACtE,CAAC,OAAOK,CAAC,EAAE;AACVN,IAAAA,KAAK,GAAGM,CAAsB,CAAA;AAChC,GAAA;EAEA,OAAO;IAAET,IAAI;IAAEE,SAAS;AAAEC,IAAAA,KAAAA;GAAO,CAAA;AACnC,CAAA;AAEO,SAASI,cAAcA,CAACT,IAAY,EAAEC,YAA2B,EAAE;EACxE,IAAIW,YAAY,GAAG,CAAC,GAAGC,MAAM,CAACC,IAAI,CAACb,YAAY,IAAI,EAAE,CAAC,EAAE,GAAGY,MAAM,CAACC,IAAI,CAACC,OAAO,CAAC,CAAC,CAAA;AAChF,EAAA,IAAIC,MAAM,GAAGC,QAAQ,CAACD,MAAM,CAAA;AAE5B,EAAA,IAAIE,MAAM,GAAGlB,IAAI,CAACmB,UAAU,CAAC,0BAA0B,EAAE,CAACC,CAAC,EAAEC,EAAE,EAAEC,UAAU,KAAK;AAC9E,IAAA,IAAIV,YAAY,CAACW,QAAQ,CAACD,UAAU,CAAC,EAAE;AACrC,MAAA,OAAQ,CAAQN,MAAAA,EAAAA,MAAO,CAAGM,CAAAA,EAAAA,UAAW,CAAE,CAAA,CAAA,CAAA;AACzC,KAAA;IAEA,OAAQ,CAAA,8BAAA,EAAgCA,UAAW,CAAE,CAAA,CAAA,CAAA;AACvD,GAAC,CAAC,CAAA;AAEF,EAAA,OAAOJ,MAAM,CAAA;AACf,CAAA;AAEA,eAAeR,WAAWA,CAACV,IAAY,EAAE;AACvC,EAAA,IAAIwB,SAAS,GAAGC,kBAAkB,CAACzB,IAAI,CAAC,CAAA;EACxC,IAAIkB,MAAM,GAAG,MAAM,iCACU,CAAA,mCAAA,EAAqCM,SAAU,CAAA,CAC5E,CAAC,CAAA;AAED,EAAA,IAAI,CAACN,MAAM,CAACQ,OAAO,EAAE;IACnB,MAAM,IAAIlB,KAAK,CAAE,CAAkDK,gDAAAA,EAAAA,MAAM,CAACC,IAAI,CAACI,MAAM,CAAE,CAAA,CAAC,CAAC,CAAA;AAC3F,GAAA;AAEA,EAAA,OAAOA,MAAM,CAAA;AAIf,CAAA;AAEA,eAAeX,UAAUA,CAAC;AAAEP,EAAAA,IAAI,EAAE2B,KAAK;AAAEzB,EAAAA,IAAAA;AAAW,CAAC,EAAE;AACrD,EAAA,IAAI0B,YAAY,GAAGC,UAAU,CAACF,KAAK,EAAEzB,IAAI,CAAC,CAAA;EAC1C,IAAIgB,MAAM,GAAG,MAAMY,SAAS,CAACF,YAAY,EAAE1B,IAAI,EAAE;AAC/Ca,IAAAA,OAAO,EAAE,KAAA;AACX,GAAC,CAAC,CAAA;EAEF,IAAI,CAACG,MAAM,EAAE;AACX,IAAA,OAAA;AACF,GAAA;EAEA,IAAI;AAAElB,IAAAA,IAAAA;AAAK,GAAC,GAAGkB,MAAM,CAAA;AAErB,EAAA,OAAOlB,IAAI,CAAA;AACb;;;;"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * This Babel plugin takes parseable code emitted by the string-based
3
+ * preprocessor plugin in this package and converts it into calls to
4
+ * the standardized `precompileTemplate` macro from `@ember/template-compilation`.
5
+ *
6
+ * Its goal is to convert code like this:
7
+ *
8
+ * ```js
9
+ * import { hbs } from 'ember-template-imports';
10
+ *
11
+ * const A = hbs(`A`, {...});
12
+ * const B = [__GLIMMER_TEMPLATE(`B`, {...})];
13
+ * class C {
14
+ * template = hbs(`C`, {...});
15
+ * }
16
+ *
17
+ * [__GLIMMER_TEMPLATE(`default`, {...})];
18
+ *
19
+ * class D {
20
+ * [__GLIMMER_TEMPLATE(`D`, {...})]
21
+ * }
22
+ * ```
23
+ *
24
+ * Into this:
25
+ *
26
+ * ```js
27
+ * import { precompileTemplate } from '@ember/template-compilation';
28
+ * import { setComponentTemplate } from '@ember/component';
29
+ * import templateOnlyComponent from '@ember/component/template-only';
30
+ *
31
+ * const A = setComponentTemplate(
32
+ * precompileTemplate(`A`, {...}),
33
+ * templateOnlyComponent('this-module.js', 'A')
34
+ * );
35
+ * const B = setComponentTemplate(
36
+ * precompileTemplate(`B`, {...}),
37
+ * templateOnlyComponent('this-module.js', 'B')
38
+ * );
39
+ * class C {}
40
+ * setComponentTemplate(precompileTemplate(`C`, {...}), C);
41
+ *
42
+ * export default setComponentTemplate(
43
+ * precompileTemplate(`default`, {...}),
44
+ * templateOnlyComponent('this-module.js', '_thisModule')
45
+ * );
46
+ *
47
+ * class D {}
48
+ * setComponentTemplate(precompileTemplate(`D`, {...}), D);
49
+ * ```
50
+ */
51
+ declare function babelPluginFunc(babel: any): {
52
+ visitor: any;
53
+ };
54
+ export { babelPluginFunc as default };
@@ -0,0 +1,95 @@
1
+ import { ImportUtil } from 'babel-import-util';
2
+ import { transformTemplateTag } from './template-tag-transform.js';
3
+ import { isTemplateTag } from './util.js';
4
+
5
+ /**
6
+ * This Babel plugin takes parseable code emitted by the string-based
7
+ * preprocessor plugin in this package and converts it into calls to
8
+ * the standardized `precompileTemplate` macro from `@ember/template-compilation`.
9
+ *
10
+ * Its goal is to convert code like this:
11
+ *
12
+ * ```js
13
+ * import { hbs } from 'ember-template-imports';
14
+ *
15
+ * const A = hbs(`A`, {...});
16
+ * const B = [__GLIMMER_TEMPLATE(`B`, {...})];
17
+ * class C {
18
+ * template = hbs(`C`, {...});
19
+ * }
20
+ *
21
+ * [__GLIMMER_TEMPLATE(`default`, {...})];
22
+ *
23
+ * class D {
24
+ * [__GLIMMER_TEMPLATE(`D`, {...})]
25
+ * }
26
+ * ```
27
+ *
28
+ * Into this:
29
+ *
30
+ * ```js
31
+ * import { precompileTemplate } from '@ember/template-compilation';
32
+ * import { setComponentTemplate } from '@ember/component';
33
+ * import templateOnlyComponent from '@ember/component/template-only';
34
+ *
35
+ * const A = setComponentTemplate(
36
+ * precompileTemplate(`A`, {...}),
37
+ * templateOnlyComponent('this-module.js', 'A')
38
+ * );
39
+ * const B = setComponentTemplate(
40
+ * precompileTemplate(`B`, {...}),
41
+ * templateOnlyComponent('this-module.js', 'B')
42
+ * );
43
+ * class C {}
44
+ * setComponentTemplate(precompileTemplate(`C`, {...}), C);
45
+ *
46
+ * export default setComponentTemplate(
47
+ * precompileTemplate(`default`, {...}),
48
+ * templateOnlyComponent('this-module.js', '_thisModule')
49
+ * );
50
+ *
51
+ * class D {}
52
+ * setComponentTemplate(precompileTemplate(`D`, {...}), D);
53
+ * ```
54
+ */
55
+ function babelPluginIntermediateGJS (babel) {
56
+ let t = babel.types;
57
+ let visitor = {
58
+ Program: {
59
+ enter(path, state) {
60
+ state.importUtil = new ImportUtil(t, path);
61
+ }
62
+ },
63
+ // Process class bodies before things like class properties get transformed
64
+ // into imperative constructor code that we can't recognize. Taken directly
65
+ // from babel-plugin-htmlbars-inline-precompile https://git.io/JMi1G
66
+ Class(path, state) {
67
+ let bodyPath = path.get('body.body');
68
+ if (!Array.isArray(bodyPath)) return;
69
+ bodyPath.forEach(path => {
70
+ if (path.type !== 'ClassProperty') return;
71
+ let keyPath = path.get('key');
72
+ let valuePath = path.get('value');
73
+ if (Array.isArray(keyPath)) return;
74
+ if (keyPath && visitor[keyPath.type]) {
75
+ visitor[keyPath.type](keyPath, state);
76
+ }
77
+ if (Array.isArray(valuePath)) return;
78
+ if (valuePath && visitor[valuePath.type]) {
79
+ visitor[valuePath.type](valuePath, state);
80
+ }
81
+ });
82
+ },
83
+ CallExpression(path, state) {
84
+ if (isTemplateTag(path)) {
85
+ transformTemplateTag(t, path, state);
86
+ }
87
+ }
88
+ };
89
+ return {
90
+ visitor
91
+ };
92
+ }
93
+
94
+ export { babelPluginIntermediateGJS as default };
95
+ //# sourceMappingURL=babel-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"babel-plugin.js","sources":["../../../src/browser/eti/babel-plugin.ts"],"sourcesContent":["import { ImportUtil } from 'babel-import-util';\n\nimport { transformTemplateTag } from './template-tag-transform';\nimport * as util from './util';\n\nimport type { NodePath } from '@babel/traverse';\nimport type { CallExpression, Class, Program } from '@babel/types';\n\n/**\n * This Babel plugin takes parseable code emitted by the string-based\n * preprocessor plugin in this package and converts it into calls to\n * the standardized `precompileTemplate` macro from `@ember/template-compilation`.\n *\n * Its goal is to convert code like this:\n *\n * ```js\n * import { hbs } from 'ember-template-imports';\n *\n * const A = hbs(`A`, {...});\n * const B = [__GLIMMER_TEMPLATE(`B`, {...})];\n * class C {\n * template = hbs(`C`, {...});\n * }\n *\n * [__GLIMMER_TEMPLATE(`default`, {...})];\n *\n * class D {\n * [__GLIMMER_TEMPLATE(`D`, {...})]\n * }\n * ```\n *\n * Into this:\n *\n * ```js\n * import { precompileTemplate } from '@ember/template-compilation';\n * import { setComponentTemplate } from '@ember/component';\n * import templateOnlyComponent from '@ember/component/template-only';\n *\n * const A = setComponentTemplate(\n * precompileTemplate(`A`, {...}),\n * templateOnlyComponent('this-module.js', 'A')\n * );\n * const B = setComponentTemplate(\n * precompileTemplate(`B`, {...}),\n * templateOnlyComponent('this-module.js', 'B')\n * );\n * class C {}\n * setComponentTemplate(precompileTemplate(`C`, {...}), C);\n *\n * export default setComponentTemplate(\n * precompileTemplate(`default`, {...}),\n * templateOnlyComponent('this-module.js', '_thisModule')\n * );\n *\n * class D {}\n * setComponentTemplate(precompileTemplate(`D`, {...}), D);\n * ```\n */\nexport default function (babel: any) {\n let t = babel.types;\n\n let visitor: any = {\n Program: {\n enter(path: NodePath<Program>, state: any) {\n state.importUtil = new ImportUtil(t, path);\n },\n },\n\n // Process class bodies before things like class properties get transformed\n // into imperative constructor code that we can't recognize. Taken directly\n // from babel-plugin-htmlbars-inline-precompile https://git.io/JMi1G\n Class(path: NodePath<Class>, state: any) {\n let bodyPath = path.get('body.body');\n\n if (!Array.isArray(bodyPath)) return;\n\n bodyPath.forEach((path) => {\n if (path.type !== 'ClassProperty') return;\n\n let keyPath = path.get('key');\n let valuePath = path.get('value');\n\n if (Array.isArray(keyPath)) return;\n\n if (keyPath && visitor[keyPath.type]) {\n visitor[keyPath.type](keyPath, state);\n }\n\n if (Array.isArray(valuePath)) return;\n\n if (valuePath && visitor[valuePath.type]) {\n visitor[valuePath.type](valuePath, state);\n }\n });\n },\n\n CallExpression(path: NodePath<CallExpression>, state: any) {\n if (util.isTemplateTag(path)) {\n transformTemplateTag(t, path, state);\n }\n },\n };\n\n return { visitor };\n}\n"],"names":["babel","t","types","visitor","Program","enter","path","state","importUtil","ImportUtil","Class","bodyPath","get","Array","isArray","forEach","type","keyPath","valuePath","CallExpression","util","transformTemplateTag"],"mappings":";;;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,mCAAA,EAAUA,KAAU,EAAE;AACnC,EAAA,IAAIC,CAAC,GAAGD,KAAK,CAACE,KAAK,CAAA;AAEnB,EAAA,IAAIC,OAAY,GAAG;AACjBC,IAAAA,OAAO,EAAE;AACPC,MAAAA,KAAKA,CAACC,IAAuB,EAAEC,KAAU,EAAE;QACzCA,KAAK,CAACC,UAAU,GAAG,IAAIC,UAAU,CAACR,CAAC,EAAEK,IAAI,CAAC,CAAA;AAC5C,OAAA;KACD;AAED;AACA;AACA;AACAI,IAAAA,KAAKA,CAACJ,IAAqB,EAAEC,KAAU,EAAE;AACvC,MAAA,IAAII,QAAQ,GAAGL,IAAI,CAACM,GAAG,CAAC,WAAW,CAAC,CAAA;AAEpC,MAAA,IAAI,CAACC,KAAK,CAACC,OAAO,CAACH,QAAQ,CAAC,EAAE,OAAA;AAE9BA,MAAAA,QAAQ,CAACI,OAAO,CAAET,IAAI,IAAK;AACzB,QAAA,IAAIA,IAAI,CAACU,IAAI,KAAK,eAAe,EAAE,OAAA;AAEnC,QAAA,IAAIC,OAAO,GAAGX,IAAI,CAACM,GAAG,CAAC,KAAK,CAAC,CAAA;AAC7B,QAAA,IAAIM,SAAS,GAAGZ,IAAI,CAACM,GAAG,CAAC,OAAO,CAAC,CAAA;AAEjC,QAAA,IAAIC,KAAK,CAACC,OAAO,CAACG,OAAO,CAAC,EAAE,OAAA;QAE5B,IAAIA,OAAO,IAAId,OAAO,CAACc,OAAO,CAACD,IAAI,CAAC,EAAE;UACpCb,OAAO,CAACc,OAAO,CAACD,IAAI,CAAC,CAACC,OAAO,EAAEV,KAAK,CAAC,CAAA;AACvC,SAAA;AAEA,QAAA,IAAIM,KAAK,CAACC,OAAO,CAACI,SAAS,CAAC,EAAE,OAAA;QAE9B,IAAIA,SAAS,IAAIf,OAAO,CAACe,SAAS,CAACF,IAAI,CAAC,EAAE;UACxCb,OAAO,CAACe,SAAS,CAACF,IAAI,CAAC,CAACE,SAAS,EAAEX,KAAK,CAAC,CAAA;AAC3C,SAAA;AACF,OAAC,CAAC,CAAA;KACH;AAEDY,IAAAA,cAAcA,CAACb,IAA8B,EAAEC,KAAU,EAAE;AACzD,MAAA,IAAIa,aAAkB,CAACd,IAAI,CAAC,EAAE;AAC5Be,QAAAA,oBAAoB,CAACpB,CAAC,EAAEK,IAAI,EAAEC,KAAK,CAAC,CAAA;AACtC,OAAA;AACF,KAAA;GACD,CAAA;EAED,OAAO;AAAEJ,IAAAA,OAAAA;GAAS,CAAA;AACpB;;;;"}
@@ -0,0 +1,2 @@
1
+ declare function expect<T>(value: T | null | undefined, message: string): T;
2
+ export { expect };
@@ -0,0 +1,9 @@
1
+ function expect(value, message) {
2
+ if (value === undefined || value === null) {
3
+ throw new Error(`LIBRARY BUG: ${message}`);
4
+ }
5
+ return value;
6
+ }
7
+
8
+ export { expect };
9
+ //# sourceMappingURL=debug.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug.js","sources":["../../../src/browser/eti/debug.ts"],"sourcesContent":["export function expect<T>(value: T | null | undefined, message: string): T {\n if (value === undefined || value === null) {\n throw new Error(`LIBRARY BUG: ${message}`);\n }\n\n return value;\n}\n"],"names":["expect","value","message","undefined","Error"],"mappings":"AAAO,SAASA,MAAMA,CAAIC,KAA2B,EAAEC,OAAe,EAAK;AACzE,EAAA,IAAID,KAAK,KAAKE,SAAS,IAAIF,KAAK,KAAK,IAAI,EAAE;AACzC,IAAA,MAAM,IAAIG,KAAK,CAAE,CAAeF,aAAAA,EAAAA,OAAQ,EAAC,CAAC,CAAA;AAC5C,GAAA;AAEA,EAAA,OAAOD,KAAK,CAAA;AACd;;;;"}
@@ -0,0 +1,56 @@
1
+ type TemplateMatch = TemplateTagMatch;
2
+ interface TemplateTagMatch {
3
+ type: 'template-tag';
4
+ tagName: string;
5
+ start: RegExpMatchArray;
6
+ end: RegExpMatchArray;
7
+ contents: string;
8
+ }
9
+ /**
10
+ * Represents a static import of a template literal.
11
+ */
12
+ interface StaticImportConfig {
13
+ /**
14
+ * The path to the package from which we want to import the template literal
15
+ * (e.g.: 'ember-cli-htmlbars')
16
+ */
17
+ importPath: string;
18
+ /**
19
+ * The name of the template literal (e.g.: 'hbs') or 'default' if this package
20
+ * exports a default function
21
+ */
22
+ importIdentifier: string;
23
+ }
24
+ /**
25
+ * The input options to instruct parseTemplates on how to parse the input.
26
+ *
27
+ * @param templateTag
28
+ */
29
+ interface ParseTemplatesOptions {
30
+ /** Tag to use, if parsing template tags is enabled. */
31
+ templateTag?: string;
32
+ }
33
+ declare const DEFAULT_PARSE_TEMPLATES_OPTIONS: {
34
+ templateTag: string;
35
+ };
36
+ /**
37
+ * Parses a template to find all possible valid matches for an embedded template.
38
+ * Supported syntaxes are template literals:
39
+ *
40
+ * hbs`Hello, world!`
41
+ *
42
+ * And template tags
43
+ *
44
+ * <template></template>
45
+ *
46
+ * The parser excludes any values found within strings recursively, and also
47
+ * excludes any string literals with dynamic segments (e.g `${}`) since these
48
+ * cannot be valid templates.
49
+ *
50
+ * @param template The template to parse
51
+ * @param relativePath Relative file path for the template (for errors)
52
+ * @param options optional configuration options for how to parse templates
53
+ * @returns
54
+ */
55
+ declare function parseTemplates(template: string, relativePath: string, options?: ParseTemplatesOptions): TemplateMatch[];
56
+ export { TemplateMatch, TemplateTagMatch, StaticImportConfig, ParseTemplatesOptions, DEFAULT_PARSE_TEMPLATES_OPTIONS, parseTemplates };
@@ -0,0 +1,181 @@
1
+ import { expect } from './debug.js';
2
+ import { TEMPLATE_TAG_NAME } from './util.js';
3
+
4
+ /**
5
+ * Represents a static import of a template literal.
6
+ */
7
+
8
+ /**
9
+ * The input options to instruct parseTemplates on how to parse the input.
10
+ *
11
+ * @param templateTag
12
+ */
13
+
14
+ const escapeChar = '\\';
15
+ const stringDelimiter = /['"]/;
16
+ const singleLineCommentStart = /\/\//;
17
+ const newLine = /\n/;
18
+ const multiLineCommentStart = /\/\*/;
19
+ const multiLineCommentEnd = /\*\//;
20
+ const templateLiteralStart = /([$a-zA-Z_][0-9a-zA-Z_$]*)?`/;
21
+ const templateLiteralEnd = /`/;
22
+ const dynamicSegmentStart = /\${/;
23
+ const blockStart = /{/;
24
+ const dynamicSegmentEnd = /}/;
25
+ function isEscaped(template, _offset) {
26
+ let offset = expect(_offset, 'Expected an index to check escaping');
27
+ let count = 0;
28
+ while (template[offset - 1] === escapeChar) {
29
+ count++;
30
+ offset--;
31
+ }
32
+ return count % 2 === 1;
33
+ }
34
+ const DEFAULT_PARSE_TEMPLATES_OPTIONS = {
35
+ templateTag: TEMPLATE_TAG_NAME
36
+ };
37
+
38
+ /**
39
+ * Parses a template to find all possible valid matches for an embedded template.
40
+ * Supported syntaxes are template literals:
41
+ *
42
+ * hbs`Hello, world!`
43
+ *
44
+ * And template tags
45
+ *
46
+ * <template></template>
47
+ *
48
+ * The parser excludes any values found within strings recursively, and also
49
+ * excludes any string literals with dynamic segments (e.g `${}`) since these
50
+ * cannot be valid templates.
51
+ *
52
+ * @param template The template to parse
53
+ * @param relativePath Relative file path for the template (for errors)
54
+ * @param options optional configuration options for how to parse templates
55
+ * @returns
56
+ */
57
+ function parseTemplates(template, relativePath, options = DEFAULT_PARSE_TEMPLATES_OPTIONS) {
58
+ const results = [];
59
+ const templateTag = options?.templateTag;
60
+ const templateTagStart = new RegExp(`<${templateTag}[^<]*>`);
61
+ const templateTagEnd = new RegExp(`</${templateTag}>`);
62
+ const argumentsMatchRegex = new RegExp(`<${templateTag}[^<]*\\S[^<]*>`);
63
+ const allTokens = new RegExp([singleLineCommentStart.source, newLine.source, multiLineCommentStart.source, multiLineCommentEnd.source, stringDelimiter.source, templateLiteralStart.source, templateLiteralEnd.source, dynamicSegmentStart.source, dynamicSegmentEnd.source, blockStart.source, templateTagStart.source, templateTagEnd.source].join('|'), 'g');
64
+ const tokens = Array.from(template.matchAll(allTokens));
65
+ while (tokens.length > 0) {
66
+ const currentToken = tokens.shift(); // eslint-disable-line @typescript-eslint/no-non-null-assertion
67
+
68
+ parseToken(results, template, currentToken, tokens, true);
69
+ }
70
+
71
+ /**
72
+ * Parse the current token. If top level, then template tags can be parsed.
73
+ * Else, we are nested within a dynamic segment, which is currently unsupported.
74
+ */
75
+ function parseToken(results, template, token, tokens, isTopLevel = false) {
76
+ if (token[0].match(multiLineCommentStart)) {
77
+ parseMultiLineComment(results, template, token, tokens);
78
+ } else if (token[0].match(singleLineCommentStart)) {
79
+ parseSingleLineComment(results, template, token, tokens);
80
+ } else if (token[0].match(templateLiteralStart)) {
81
+ parseTemplateLiteral(template, tokens);
82
+ } else if (isTopLevel && templateTag !== undefined && templateTagStart && token[0].match(templateTagStart)) {
83
+ parseTemplateTag(results, template, token, tokens, templateTag);
84
+ } else if (token[0].match(stringDelimiter)) {
85
+ parseString(results, template, token, tokens);
86
+ }
87
+ }
88
+
89
+ /**
90
+ * Parse a template literal. If a dynamic segment is found, enters the dynamic
91
+ * segment and parses it recursively. If no dynamic segments are found and the
92
+ * literal is top level (e.g. not nested within a dynamic segment) and has a
93
+ * tag, pushes it into the list of results.
94
+ */
95
+ function parseTemplateLiteral(template, tokens) {
96
+ while (tokens.length > 0) {
97
+ let currentToken = expect(tokens.shift(), 'expected token');
98
+ if (isEscaped(template, currentToken.index)) continue;
99
+ if (currentToken[0].match(templateLiteralEnd)) {
100
+ return;
101
+ }
102
+ }
103
+ }
104
+
105
+ /**
106
+ * Parse a string. All tokens within a string are ignored
107
+ * since there are no dynamic segments within these.
108
+ */
109
+ function parseString(_results, template, startToken, tokens) {
110
+ while (tokens.length > 0) {
111
+ const currentToken = expect(tokens.shift(), 'expected token');
112
+ if (currentToken[0] === startToken[0] && !isEscaped(template, currentToken.index)) {
113
+ return;
114
+ }
115
+ }
116
+ }
117
+
118
+ /**
119
+ * Parse a single-line comment. All tokens within a single-line comment are ignored
120
+ * since there are no dynamic segments within them.
121
+ */
122
+ function parseSingleLineComment(_results, _template, _startToken, tokens) {
123
+ while (tokens.length > 0) {
124
+ const currentToken = expect(tokens.shift(), 'expected token');
125
+ if (currentToken[0] === '\n') {
126
+ return;
127
+ }
128
+ }
129
+ }
130
+
131
+ /**
132
+ * Parse a multi-line comment. All tokens within a multi-line comment are ignored
133
+ * since there are no dynamic segments within them.
134
+ */
135
+ function parseMultiLineComment(_results, _template, _startToken, tokens) {
136
+ while (tokens.length > 0) {
137
+ const currentToken = expect(tokens.shift(), 'expected token');
138
+ if (currentToken[0] === '*/') {
139
+ return;
140
+ }
141
+ }
142
+ }
143
+
144
+ /**
145
+ * Parses a template tag. Continues parsing until the template tag has closed,
146
+ * accounting for nested template tags.
147
+ */
148
+ function parseTemplateTag(results, _template, startToken, tokens, templateTag) {
149
+ let stack = 1;
150
+ if (argumentsMatchRegex && startToken[0].match(argumentsMatchRegex)) {
151
+ throw new Error(`embedded template preprocessing currently does not support passing arguments, found args in: ${relativePath}`);
152
+ }
153
+ while (tokens.length > 0) {
154
+ const currentToken = expect(tokens.shift(), 'expected token');
155
+ if (currentToken[0].match(templateTagStart)) {
156
+ stack++;
157
+ } else if (currentToken[0].match(templateTagEnd)) {
158
+ stack--;
159
+ }
160
+ if (stack === 0) {
161
+ let contents = '';
162
+ if (startToken.index !== undefined) {
163
+ const templateStart = startToken.index + startToken[0].length;
164
+ contents = template.slice(templateStart, currentToken.index);
165
+ }
166
+ results.push({
167
+ type: 'template-tag',
168
+ tagName: templateTag,
169
+ contents: contents,
170
+ start: startToken,
171
+ end: currentToken
172
+ });
173
+ return;
174
+ }
175
+ }
176
+ }
177
+ return results;
178
+ }
179
+
180
+ export { DEFAULT_PARSE_TEMPLATES_OPTIONS, parseTemplates };
181
+ //# sourceMappingURL=parse-templates.js.map