ember-repl 3.0.0-beta.5 → 3.0.0-beta.7

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 (71) hide show
  1. package/declarations/browser/__PRIVATE__.d.ts +2 -0
  2. package/declarations/browser/__PRIVATE__.d.ts.map +1 -0
  3. package/declarations/browser/compile/formats.d.ts +2 -0
  4. package/declarations/browser/compile/formats.d.ts.map +1 -1
  5. package/declarations/browser/compile/index.d.ts +31 -7
  6. package/declarations/browser/compile/index.d.ts.map +1 -1
  7. package/declarations/browser/compile/markdown-to-ember.d.ts +2 -0
  8. package/declarations/browser/compile/markdown-to-ember.d.ts.map +1 -1
  9. package/declarations/browser/compile/types.d.ts +2 -0
  10. package/declarations/browser/compile/types.d.ts.map +1 -1
  11. package/declarations/browser/gjs.d.ts +1 -1
  12. package/declarations/browser/gjs.d.ts.map +1 -1
  13. package/declarations/browser/known-modules.d.ts +4 -0
  14. package/declarations/browser/known-modules.d.ts.map +1 -1
  15. package/dist/browser/__PRIVATE__.js +2 -0
  16. package/dist/browser/__PRIVATE__.js.map +1 -0
  17. package/dist/browser/cjs/index.js +1 -1
  18. package/dist/browser/cjs/index.js.map +1 -1
  19. package/dist/browser/compile/formats.js +2 -1
  20. package/dist/browser/compile/formats.js.map +1 -1
  21. package/dist/browser/compile/index.js +28 -14
  22. package/dist/browser/compile/index.js.map +1 -1
  23. package/dist/browser/compile/markdown-to-ember.js +26 -8
  24. package/dist/browser/compile/markdown-to-ember.js.map +1 -1
  25. package/dist/browser/compile/types.js +1 -1
  26. package/dist/browser/esm/index.js +1 -1
  27. package/dist/browser/esm/index.js.map +1 -1
  28. package/dist/browser/gjs.js +12 -13
  29. package/dist/browser/gjs.js.map +1 -1
  30. package/dist/browser/known-modules.js +4 -4
  31. package/dist/browser/known-modules.js.map +1 -1
  32. package/package.json +59 -54
  33. package/src/browser/__PRIVATE__.ts +1 -0
  34. package/src/browser/cjs/index.ts +1 -1
  35. package/src/browser/compile/formats.ts +3 -0
  36. package/src/browser/compile/index.ts +58 -24
  37. package/src/browser/compile/markdown-to-ember.ts +91 -76
  38. package/src/browser/compile/types.ts +4 -0
  39. package/src/browser/esm/index.ts +1 -1
  40. package/src/browser/gjs.ts +13 -15
  41. package/src/browser/known-modules.ts +4 -2
  42. package/declarations/browser/eti/babel-plugin.d.ts +0 -54
  43. package/declarations/browser/eti/babel-plugin.d.ts.map +0 -1
  44. package/declarations/browser/eti/debug.d.ts +0 -2
  45. package/declarations/browser/eti/debug.d.ts.map +0 -1
  46. package/declarations/browser/eti/parse-templates.d.ts +0 -56
  47. package/declarations/browser/eti/parse-templates.d.ts.map +0 -1
  48. package/declarations/browser/eti/preprocess.d.ts +0 -58
  49. package/declarations/browser/eti/preprocess.d.ts.map +0 -1
  50. package/declarations/browser/eti/template-tag-transform.d.ts +0 -15
  51. package/declarations/browser/eti/template-tag-transform.d.ts.map +0 -1
  52. package/declarations/browser/eti/util.d.ts +0 -14
  53. package/declarations/browser/eti/util.d.ts.map +0 -1
  54. package/dist/browser/eti/babel-plugin.js +0 -95
  55. package/dist/browser/eti/babel-plugin.js.map +0 -1
  56. package/dist/browser/eti/debug.js +0 -9
  57. package/dist/browser/eti/debug.js.map +0 -1
  58. package/dist/browser/eti/parse-templates.js +0 -181
  59. package/dist/browser/eti/parse-templates.js.map +0 -1
  60. package/dist/browser/eti/preprocess.js +0 -106
  61. package/dist/browser/eti/preprocess.js.map +0 -1
  62. package/dist/browser/eti/template-tag-transform.js +0 -46
  63. package/dist/browser/eti/template-tag-transform.js.map +0 -1
  64. package/dist/browser/eti/util.js +0 -39
  65. package/dist/browser/eti/util.js.map +0 -1
  66. package/src/browser/eti/babel-plugin.ts +0 -105
  67. package/src/browser/eti/debug.ts +0 -7
  68. package/src/browser/eti/parse-templates.ts +0 -284
  69. package/src/browser/eti/preprocess.ts +0 -187
  70. package/src/browser/eti/template-tag-transform.ts +0 -100
  71. package/src/browser/eti/util.ts +0 -72
@@ -65,7 +65,7 @@ async function evalSnippet(code: string) {
65
65
  }
66
66
 
67
67
  async function compileGJS({ code: input, name }: Info) {
68
- let preprocessed = preprocess(input, name);
68
+ let preprocessed = await preprocess(input, name);
69
69
  let result = await transform(preprocessed, name, {
70
70
  modules: false,
71
71
  });
@@ -2,25 +2,23 @@ import { importSync } from '@embroider/macros';
2
2
 
3
3
  import babelPluginEmberTemplateCompilation from 'babel-plugin-ember-template-compilation';
4
4
 
5
- // TODO: use real packages, and not these copied files from ember-template-imports
6
- import babelPluginIntermediateGJS from './eti/babel-plugin.ts';
7
- import { preprocessEmbeddedTemplates } from './eti/preprocess.ts';
8
- import { TEMPLATE_TAG_NAME, TEMPLATE_TAG_PLACEHOLDER } from './eti/util.ts';
9
-
10
5
  import type { Babel } from './types.ts';
11
6
 
12
7
  const compiler = importSync('ember-source/dist/ember-template-compiler.js');
13
8
 
14
- export function preprocess(input: string, name: string) {
15
- let preprocessed = preprocessEmbeddedTemplates(input, {
16
- relativePath: `${name}.js`,
17
- includeSourceMaps: false,
18
- includeTemplateTokens: true,
19
- templateTag: TEMPLATE_TAG_NAME,
20
- templateTagReplacement: TEMPLATE_TAG_PLACEHOLDER,
21
- });
9
+ import { createPreprocessor } from 'content-tag/standalone';
10
+
11
+ let processor;
12
+ let fetchingPromise: Promise<any>;
13
+
14
+ export async function preprocess(input: string, name: string): Promise<string> {
15
+ if (!fetchingPromise) {
16
+ fetchingPromise = createPreprocessor();
17
+ }
18
+
19
+ processor = await fetchingPromise;
22
20
 
23
- return preprocessed.output;
21
+ return processor.process(input, `${name}.js`);
24
22
  }
25
23
 
26
24
  export async function transform(
@@ -33,7 +31,7 @@ export async function transform(
33
31
  return babel.transform(intermediate, {
34
32
  filename: `${name}.js`,
35
33
  plugins: [
36
- [babelPluginIntermediateGJS],
34
+ // [babelPluginIntermediateGJS],
37
35
  [
38
36
  babelPluginEmberTemplateCompilation,
39
37
  {
@@ -13,13 +13,14 @@ import * as _destroyable from '@ember/destroyable';
13
13
  import * as _helpers from '@ember/helper';
14
14
  import * as _modifier from '@ember/modifier';
15
15
  import * as _object from '@ember/object';
16
+ import * as _owner from '@ember/owner';
16
17
  import * as _runloop from '@ember/runloop';
17
18
  import * as _service from '@ember/service';
19
+ import * as _template from '@ember/template';
18
20
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
19
21
  // @ts-ignore
20
22
  import { createTemplateFactory } from '@ember/template-factory';
21
23
  import * as _utils from '@ember/utils';
22
- // import * as _owner from '@ember/owner';
23
24
 
24
25
  export const modules = {
25
26
  '@ember/application': _application,
@@ -35,7 +36,8 @@ export const modules = {
35
36
  '@ember/service': _service,
36
37
  '@ember/template-factory': { createTemplateFactory },
37
38
  '@ember/utils': _utils,
38
- // '@ember/owner': _owner,
39
+ '@ember/template': _template,
40
+ '@ember/owner': _owner,
39
41
 
40
42
  '@glimmer/component': _GlimmerComponent,
41
43
  '@glimmer/tracking': _tracking,
@@ -1,54 +0,0 @@
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
- export default function (babel: any): {
52
- visitor: any;
53
- };
54
- //# sourceMappingURL=babel-plugin.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"babel-plugin.d.ts","sourceRoot":"","sources":["../../../src/browser/eti/babel-plugin.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,MAAM,CAAC,OAAO,WAAW,KAAK,EAAE,GAAG;;EA8ClC"}
@@ -1,2 +0,0 @@
1
- export declare function expect<T>(value: T | null | undefined, message: string): T;
2
- //# sourceMappingURL=debug.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../../src/browser/eti/debug.ts"],"names":[],"mappings":"AAAA,wBAAgB,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC,CAMzE"}
@@ -1,56 +0,0 @@
1
- export type TemplateMatch = TemplateTagMatch;
2
- export 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
- export 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
- export interface ParseTemplatesOptions {
30
- /** Tag to use, if parsing template tags is enabled. */
31
- templateTag?: string;
32
- }
33
- export 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
- export declare function parseTemplates(template: string, relativePath: string, options?: ParseTemplatesOptions): TemplateMatch[];
56
- //# sourceMappingURL=parse-templates.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parse-templates.d.ts","sourceRoot":"","sources":["../../../src/browser/eti/parse-templates.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,aAAa,GAAG,gBAAgB,CAAC;AAE7C,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,cAAc,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,gBAAgB,CAAC;IACxB,GAAG,EAAE,gBAAgB,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,uDAAuD;IACvD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AA8BD,eAAO,MAAM,+BAA+B;;CAE3C,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,OAAO,GAAE,qBAAuD,GAC/D,aAAa,EAAE,CA6LjB"}
@@ -1,58 +0,0 @@
1
- interface PreprocessOptionsEager {
2
- importIdentifier?: string;
3
- importPath?: string;
4
- templateTag?: string;
5
- templateTagReplacement?: string;
6
- relativePath: string;
7
- includeSourceMaps: boolean;
8
- includeTemplateTokens: boolean;
9
- }
10
- interface PreprocessOptionsLazy {
11
- importIdentifier?: string;
12
- importPath?: string;
13
- templateTag?: string;
14
- templateTagReplacement?: string;
15
- relativePath: string;
16
- includeSourceMaps: boolean;
17
- includeTemplateTokens: boolean;
18
- }
19
- type PreprocessOptions = PreprocessOptionsLazy | PreprocessOptionsEager;
20
- interface PreprocessedOutput {
21
- output: string;
22
- replacements: Replacement[];
23
- }
24
- interface Replacement {
25
- type: 'start' | 'end';
26
- index: number;
27
- oldLength: number;
28
- newLength: number;
29
- originalLine: number;
30
- originalCol: number;
31
- }
32
- /**
33
- * Preprocesses all embedded templates within a JavaScript or TypeScript file.
34
- * This function replaces all embedded templates that match our template syntax
35
- * with valid, parseable JS. Optionally, it can also include a source map, and
36
- * it can also include all possible values used within the template.
37
- *
38
- * Input:
39
- *
40
- * <template><MyComponent/><template>
41
- *
42
- * Output:
43
- *
44
- * [GLIMMER_TEMPLATE(`<MyComponent/>`, { scope() { return {MyComponent}; } })];
45
- *
46
- * It can also be used with template literals to provide the in scope values:
47
- *
48
- * Input:
49
- *
50
- * hbs`<MyComponent/>`;
51
- *
52
- * Output
53
- *
54
- * hbs(`<MyComponent/>`, { scope() { return {MyComponent}; } });
55
- */
56
- export declare function preprocessEmbeddedTemplates(template: string, options: PreprocessOptions): PreprocessedOutput;
57
- export {};
58
- //# sourceMappingURL=preprocess.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"preprocess.d.ts","sourceRoot":"","sources":["../../../src/browser/eti/preprocess.ts"],"names":[],"mappings":"AAcA,UAAU,sBAAsB;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAEhC,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,qBAAqB,EAAE,OAAO,CAAC;CAChC;AAED,UAAU,qBAAqB;IAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAEhC,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,qBAAqB,EAAE,OAAO,CAAC;CAChC;AAED,KAAK,iBAAiB,GAAG,qBAAqB,GAAG,sBAAsB,CAAC;AAExE,UAAU,kBAAkB;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,WAAW,EAAE,CAAC;CAC7B;AAED,UAAU,WAAW;IACnB,IAAI,EAAE,OAAO,GAAG,KAAK,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB;AAoED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,iBAAiB,GACzB,kBAAkB,CAgCpB"}
@@ -1,15 +0,0 @@
1
- /**
2
- * Supports the following syntaxes:
3
- *
4
- * const Foo = [GLIMMER_TEMPLATE('hello')];
5
- *
6
- * export const Foo = [GLIMMER_TEMPLATE('hello')];
7
- *
8
- * export default [GLIMMER_TEMPLATE('hello')];
9
- *
10
- * class Foo {
11
- * [GLIMMER_TEMPLATE('hello')];
12
- * }
13
- */
14
- export declare const transformTemplateTag: (t: any, templatePath: any, state: any) => void;
15
- //# sourceMappingURL=template-tag-transform.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"template-tag-transform.d.ts","sourceRoot":"","sources":["../../../src/browser/eti/template-tag-transform.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,oBAAoB,MAAgB,GAAG,gBAAgB,GAAG,SAAS,GAAG,SAgFlF,CAAC"}
@@ -1,14 +0,0 @@
1
- import type { TemplateMatch } from './parse-templates.ts';
2
- import type { NodePath } from '@babel/traverse';
3
- import type { CallExpression } from '@babel/types';
4
- import type { ImportUtil } from 'babel-import-util';
5
- export declare const TEMPLATE_TAG_NAME = "template";
6
- export declare const TEMPLATE_TAG_PLACEHOLDER = "__GLIMMER_TEMPLATE";
7
- export declare function isTemplateTag(callExpressionPath: NodePath<CallExpression>): boolean;
8
- export declare function buildPrecompileTemplateCall(t: any, callExpressionPath: NodePath<CallExpression>, state: {
9
- importUtil: ImportUtil;
10
- }): CallExpression;
11
- export declare function registerRefs(newPath: string | string[], getRefPaths: (path: string) => NodePath[]): void;
12
- export declare function isSupportedScriptFileExtension(filePath: string): boolean;
13
- export declare function isStrictMode(templateInfo: TemplateMatch): boolean;
14
- //# sourceMappingURL=util.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/browser/eti/util.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGpD,eAAO,MAAM,iBAAiB,aAAa,CAAC;AAC5C,eAAO,MAAM,wBAAwB,uBAAuB,CAAC;AAE7D,wBAAgB,aAAa,CAAC,kBAAkB,EAAE,QAAQ,CAAC,cAAc,CAAC,WAMzE;AAED,wBAAgB,2BAA2B,CACzC,CAAC,EAAE,GAAG,EACN,kBAAkB,EAAE,QAAQ,CAAC,cAAc,CAAC,EAC5C,KAAK,EAAE;IACL,UAAU,EAAE,UAAU,CAAC;CACxB,GACA,cAAc,CAOhB;AAED,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,EAC1B,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,QAAQ,EAAE,QA2B1C;AAID,wBAAgB,8BAA8B,CAAC,QAAQ,EAAE,MAAM,WAE9D;AAED,wBAAgB,YAAY,CAAC,YAAY,EAAE,aAAa,GAAG,OAAO,CAEjE"}
@@ -1,95 +0,0 @@
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
@@ -1 +0,0 @@
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.ts';\nimport * as util from './util.ts';\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;;;;"}
@@ -1,9 +0,0 @@
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
@@ -1 +0,0 @@
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;;;;"}
@@ -1,181 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"parse-templates.js","sources":["../../../src/browser/eti/parse-templates.ts"],"sourcesContent":["import { expect } from './debug.ts';\nimport { TEMPLATE_TAG_NAME } from './util.ts';\n\nexport type TemplateMatch = TemplateTagMatch;\n\nexport interface TemplateTagMatch {\n type: 'template-tag';\n tagName: string;\n start: RegExpMatchArray;\n end: RegExpMatchArray;\n contents: string;\n}\n\n/**\n * Represents a static import of a template literal.\n */\nexport interface StaticImportConfig {\n /**\n * The path to the package from which we want to import the template literal\n * (e.g.: 'ember-cli-htmlbars')\n */\n importPath: string;\n /**\n * The name of the template literal (e.g.: 'hbs') or 'default' if this package\n * exports a default function\n */\n importIdentifier: string;\n}\n\n/**\n * The input options to instruct parseTemplates on how to parse the input.\n *\n * @param templateTag\n */\nexport interface ParseTemplatesOptions {\n /** Tag to use, if parsing template tags is enabled. */\n templateTag?: string;\n}\n\nconst escapeChar = '\\\\';\nconst stringDelimiter = /['\"]/;\n\nconst singleLineCommentStart = /\\/\\//;\nconst newLine = /\\n/;\nconst multiLineCommentStart = /\\/\\*/;\nconst multiLineCommentEnd = /\\*\\//;\n\nconst templateLiteralStart = /([$a-zA-Z_][0-9a-zA-Z_$]*)?`/;\nconst templateLiteralEnd = /`/;\n\nconst dynamicSegmentStart = /\\${/;\nconst blockStart = /{/;\nconst dynamicSegmentEnd = /}/;\n\nfunction isEscaped(template: string, _offset: number | undefined) {\n let offset = expect(_offset, 'Expected an index to check escaping');\n\n let count = 0;\n\n while (template[offset - 1] === escapeChar) {\n count++;\n offset--;\n }\n\n return count % 2 === 1;\n}\n\nexport const DEFAULT_PARSE_TEMPLATES_OPTIONS = {\n templateTag: TEMPLATE_TAG_NAME,\n};\n\n/**\n * Parses a template to find all possible valid matches for an embedded template.\n * Supported syntaxes are template literals:\n *\n * hbs`Hello, world!`\n *\n * And template tags\n *\n * <template></template>\n *\n * The parser excludes any values found within strings recursively, and also\n * excludes any string literals with dynamic segments (e.g `${}`) since these\n * cannot be valid templates.\n *\n * @param template The template to parse\n * @param relativePath Relative file path for the template (for errors)\n * @param options optional configuration options for how to parse templates\n * @returns\n */\nexport function parseTemplates(\n template: string,\n relativePath: string,\n options: ParseTemplatesOptions = DEFAULT_PARSE_TEMPLATES_OPTIONS\n): TemplateMatch[] {\n const results: TemplateMatch[] = [];\n const templateTag = options?.templateTag;\n\n const templateTagStart = new RegExp(`<${templateTag}[^<]*>`);\n const templateTagEnd = new RegExp(`</${templateTag}>`);\n const argumentsMatchRegex = new RegExp(`<${templateTag}[^<]*\\\\S[^<]*>`);\n\n const allTokens = new RegExp(\n [\n singleLineCommentStart.source,\n newLine.source,\n multiLineCommentStart.source,\n multiLineCommentEnd.source,\n stringDelimiter.source,\n templateLiteralStart.source,\n templateLiteralEnd.source,\n dynamicSegmentStart.source,\n dynamicSegmentEnd.source,\n blockStart.source,\n templateTagStart.source,\n templateTagEnd.source,\n ].join('|'),\n 'g'\n );\n\n const tokens = Array.from(template.matchAll(allTokens));\n\n while (tokens.length > 0) {\n const currentToken = tokens.shift()!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n\n parseToken(results, template, currentToken, tokens, true);\n }\n\n /**\n * Parse the current token. If top level, then template tags can be parsed.\n * Else, we are nested within a dynamic segment, which is currently unsupported.\n */\n function parseToken(\n results: TemplateMatch[],\n template: string,\n token: RegExpMatchArray,\n tokens: RegExpMatchArray[],\n isTopLevel = false\n ) {\n if (token[0].match(multiLineCommentStart)) {\n parseMultiLineComment(results, template, token, tokens);\n } else if (token[0].match(singleLineCommentStart)) {\n parseSingleLineComment(results, template, token, tokens);\n } else if (token[0].match(templateLiteralStart)) {\n parseTemplateLiteral(template, tokens);\n } else if (\n isTopLevel &&\n templateTag !== undefined &&\n templateTagStart &&\n token[0].match(templateTagStart)\n ) {\n parseTemplateTag(results, template, token, tokens, templateTag);\n } else if (token[0].match(stringDelimiter)) {\n parseString(results, template, token, tokens);\n }\n }\n\n /**\n * Parse a template literal. If a dynamic segment is found, enters the dynamic\n * segment and parses it recursively. If no dynamic segments are found and the\n * literal is top level (e.g. not nested within a dynamic segment) and has a\n * tag, pushes it into the list of results.\n */\n function parseTemplateLiteral(template: string, tokens: RegExpMatchArray[]) {\n while (tokens.length > 0) {\n let currentToken = expect(tokens.shift(), 'expected token');\n\n if (isEscaped(template, currentToken.index)) continue;\n\n if (currentToken[0].match(templateLiteralEnd)) {\n return;\n }\n }\n }\n\n /**\n * Parse a string. All tokens within a string are ignored\n * since there are no dynamic segments within these.\n */\n function parseString(\n _results: TemplateMatch[],\n template: string,\n startToken: RegExpMatchArray,\n tokens: RegExpMatchArray[]\n ) {\n while (tokens.length > 0) {\n const currentToken = expect(tokens.shift(), 'expected token');\n\n if (currentToken[0] === startToken[0] && !isEscaped(template, currentToken.index)) {\n return;\n }\n }\n }\n\n /**\n * Parse a single-line comment. All tokens within a single-line comment are ignored\n * since there are no dynamic segments within them.\n */\n function parseSingleLineComment(\n _results: TemplateMatch[],\n _template: string,\n _startToken: RegExpMatchArray,\n tokens: RegExpMatchArray[]\n ) {\n while (tokens.length > 0) {\n const currentToken = expect(tokens.shift(), 'expected token');\n\n if (currentToken[0] === '\\n') {\n return;\n }\n }\n }\n\n /**\n * Parse a multi-line comment. All tokens within a multi-line comment are ignored\n * since there are no dynamic segments within them.\n */\n function parseMultiLineComment(\n _results: TemplateMatch[],\n _template: string,\n _startToken: RegExpMatchArray,\n tokens: RegExpMatchArray[]\n ) {\n while (tokens.length > 0) {\n const currentToken = expect(tokens.shift(), 'expected token');\n\n if (currentToken[0] === '*/') {\n return;\n }\n }\n }\n\n /**\n * Parses a template tag. Continues parsing until the template tag has closed,\n * accounting for nested template tags.\n */\n function parseTemplateTag(\n results: TemplateMatch[],\n _template: string,\n startToken: RegExpMatchArray,\n tokens: RegExpMatchArray[],\n templateTag: string\n ) {\n let stack = 1;\n\n if (argumentsMatchRegex && startToken[0].match(argumentsMatchRegex)) {\n throw new Error(\n `embedded template preprocessing currently does not support passing arguments, found args in: ${relativePath}`\n );\n }\n\n while (tokens.length > 0) {\n const currentToken = expect(tokens.shift(), 'expected token');\n\n if (currentToken[0].match(templateTagStart)) {\n stack++;\n } else if (currentToken[0].match(templateTagEnd)) {\n stack--;\n }\n\n if (stack === 0) {\n let contents = '';\n\n if (startToken.index !== undefined) {\n const templateStart = startToken.index + startToken[0].length;\n\n contents = template.slice(templateStart, currentToken.index);\n }\n\n results.push({\n type: 'template-tag',\n tagName: templateTag,\n contents: contents,\n start: startToken,\n end: currentToken,\n });\n\n return;\n }\n }\n }\n\n return results;\n}\n"],"names":["escapeChar","stringDelimiter","singleLineCommentStart","newLine","multiLineCommentStart","multiLineCommentEnd","templateLiteralStart","templateLiteralEnd","dynamicSegmentStart","blockStart","dynamicSegmentEnd","isEscaped","template","_offset","offset","expect","count","DEFAULT_PARSE_TEMPLATES_OPTIONS","templateTag","TEMPLATE_TAG_NAME","parseTemplates","relativePath","options","results","templateTagStart","RegExp","templateTagEnd","argumentsMatchRegex","allTokens","source","join","tokens","Array","from","matchAll","length","currentToken","shift","parseToken","token","isTopLevel","match","parseMultiLineComment","parseSingleLineComment","parseTemplateLiteral","undefined","parseTemplateTag","parseString","index","_results","startToken","_template","_startToken","stack","Error","contents","templateStart","slice","push","type","tagName","start","end"],"mappings":";;;AAaA;AACA;AACA;;AAcA;AACA;AACA;AACA;AACA;;AAMA,MAAMA,UAAU,GAAG,IAAI,CAAA;AACvB,MAAMC,eAAe,GAAG,MAAM,CAAA;AAE9B,MAAMC,sBAAsB,GAAG,MAAM,CAAA;AACrC,MAAMC,OAAO,GAAG,IAAI,CAAA;AACpB,MAAMC,qBAAqB,GAAG,MAAM,CAAA;AACpC,MAAMC,mBAAmB,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