ember-repl 3.0.0-beta.6 → 3.0.0-beta.8

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 (53) hide show
  1. package/README.md +2 -2
  2. package/declarations/browser/compile/index.d.ts +5 -10
  3. package/declarations/browser/compile/index.d.ts.map +1 -1
  4. package/declarations/browser/gjs.d.ts +1 -1
  5. package/declarations/browser/gjs.d.ts.map +1 -1
  6. package/declarations/browser/known-modules.d.ts +26 -0
  7. package/declarations/browser/known-modules.d.ts.map +1 -1
  8. package/dist/browser/cjs/index.js +1 -1
  9. package/dist/browser/cjs/index.js.map +1 -1
  10. package/dist/browser/compile/index.js +7 -8
  11. package/dist/browser/compile/index.js.map +1 -1
  12. package/dist/browser/esm/index.js +1 -1
  13. package/dist/browser/esm/index.js.map +1 -1
  14. package/dist/browser/gjs.js +16 -13
  15. package/dist/browser/gjs.js.map +1 -1
  16. package/dist/browser/known-modules.js +6 -4
  17. package/dist/browser/known-modules.js.map +1 -1
  18. package/package.json +60 -56
  19. package/src/browser/cjs/index.ts +1 -1
  20. package/src/browser/compile/index.ts +11 -14
  21. package/src/browser/esm/index.ts +1 -1
  22. package/src/browser/gjs.ts +15 -15
  23. package/src/browser/known-modules.ts +6 -2
  24. package/declarations/browser/eti/babel-plugin.d.ts +0 -54
  25. package/declarations/browser/eti/babel-plugin.d.ts.map +0 -1
  26. package/declarations/browser/eti/debug.d.ts +0 -2
  27. package/declarations/browser/eti/debug.d.ts.map +0 -1
  28. package/declarations/browser/eti/parse-templates.d.ts +0 -56
  29. package/declarations/browser/eti/parse-templates.d.ts.map +0 -1
  30. package/declarations/browser/eti/preprocess.d.ts +0 -58
  31. package/declarations/browser/eti/preprocess.d.ts.map +0 -1
  32. package/declarations/browser/eti/template-tag-transform.d.ts +0 -15
  33. package/declarations/browser/eti/template-tag-transform.d.ts.map +0 -1
  34. package/declarations/browser/eti/util.d.ts +0 -14
  35. package/declarations/browser/eti/util.d.ts.map +0 -1
  36. package/dist/browser/eti/babel-plugin.js +0 -95
  37. package/dist/browser/eti/babel-plugin.js.map +0 -1
  38. package/dist/browser/eti/debug.js +0 -9
  39. package/dist/browser/eti/debug.js.map +0 -1
  40. package/dist/browser/eti/parse-templates.js +0 -181
  41. package/dist/browser/eti/parse-templates.js.map +0 -1
  42. package/dist/browser/eti/preprocess.js +0 -106
  43. package/dist/browser/eti/preprocess.js.map +0 -1
  44. package/dist/browser/eti/template-tag-transform.js +0 -46
  45. package/dist/browser/eti/template-tag-transform.js.map +0 -1
  46. package/dist/browser/eti/util.js +0 -39
  47. package/dist/browser/eti/util.js.map +0 -1
  48. package/src/browser/eti/babel-plugin.ts +0 -105
  49. package/src/browser/eti/debug.ts +0 -7
  50. package/src/browser/eti/parse-templates.ts +0 -284
  51. package/src/browser/eti/preprocess.ts +0 -187
  52. package/src/browser/eti/template-tag-transform.ts +0 -100
  53. package/src/browser/eti/util.ts +0 -72
@@ -151,16 +151,17 @@ export interface Value {
151
151
  component: ComponentLike;
152
152
  }
153
153
 
154
- export function buildCompiler(markdownText: Input | (() => Input)): Value;
155
- export function buildCompiler(markdownText: Input | (() => Input), options?: Format): Value;
156
- export function buildCompiler(markdownText: Input | (() => Input), options?: () => Format): Value;
157
- export function buildCompiler(markdownText: Input | (() => Input), options?: ExtraOptions): Value;
158
- export function buildCompiler(
159
- markdownText: Input | (() => Input),
160
- options?: () => ExtraOptions
161
- ): Value;
154
+ export function Compiled(markdownText: Input | (() => Input)): Value;
155
+ export function Compiled(markdownText: Input | (() => Input), options?: Format): Value;
156
+ export function Compiled(markdownText: Input | (() => Input), options?: () => Format): Value;
157
+ export function Compiled(markdownText: Input | (() => Input), options?: ExtraOptions): Value;
158
+ export function Compiled(markdownText: Input | (() => Input), options?: () => ExtraOptions): Value;
162
159
 
163
- export function buildCompiler(
160
+ /**
161
+ * By default, this compiles to `glimdown`. A Markdown format which
162
+ * extracts `live` tagged code snippets and compiles them to components.
163
+ */
164
+ export function Compiled(
164
165
  markdownText: Input | (() => Input),
165
166
  maybeOptions?: Format | (() => Format) | ExtraOptions | (() => ExtraOptions)
166
167
  ): Value {
@@ -202,8 +203,4 @@ export function buildCompiler(
202
203
  });
203
204
  }
204
205
 
205
- /**
206
- * By default, this compiles to `glimdown`. A Markdown format which
207
- * extracts `live` tagged code snippets and compiles them to components.
208
- */
209
- export const Compiled = resourceFactory(buildCompiler) as typeof buildCompiler;
206
+ resourceFactory(Compiled);
@@ -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,25 @@ 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
+ let processor: any;
10
+ let fetchingPromise: Promise<any>;
11
+
12
+ export async function preprocess(input: string, name: string): Promise<string> {
13
+ if (!fetchingPromise) {
14
+ fetchingPromise = import('content-tag');
15
+ }
16
+
17
+ if (!processor) {
18
+ let { Preprocessor } = await fetchingPromise;
19
+
20
+ processor = new Preprocessor();
21
+ }
22
22
 
23
- return preprocessed.output;
23
+ return processor.process(input, `${name}.js`);
24
24
  }
25
25
 
26
26
  export async function transform(
@@ -33,7 +33,7 @@ export async function transform(
33
33
  return babel.transform(intermediate, {
34
34
  filename: `${name}.js`,
35
35
  plugins: [
36
- [babelPluginIntermediateGJS],
36
+ // [babelPluginIntermediateGJS],
37
37
  [
38
38
  babelPluginEmberTemplateCompilation,
39
39
  {
@@ -7,24 +7,27 @@ import * as _tracking from '@glimmer/tracking';
7
7
  import * as _application from '@ember/application';
8
8
  import * as _array from '@ember/array';
9
9
  import * as _EmberComponent from '@ember/component';
10
+ import * as _EmberComponentHelper from '@ember/component/helper';
10
11
  import _TO from '@ember/component/template-only';
11
12
  import * as _debug from '@ember/debug';
12
13
  import * as _destroyable from '@ember/destroyable';
13
14
  import * as _helpers from '@ember/helper';
14
15
  import * as _modifier from '@ember/modifier';
15
16
  import * as _object from '@ember/object';
17
+ import * as _owner from '@ember/owner';
16
18
  import * as _runloop from '@ember/runloop';
17
19
  import * as _service from '@ember/service';
20
+ import * as _template from '@ember/template';
18
21
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
19
22
  // @ts-ignore
20
23
  import { createTemplateFactory } from '@ember/template-factory';
21
24
  import * as _utils from '@ember/utils';
22
- // import * as _owner from '@ember/owner';
23
25
 
24
26
  export const modules = {
25
27
  '@ember/application': _application,
26
28
  '@ember/array': _array,
27
29
  '@ember/component': _EmberComponent,
30
+ '@ember/component/helper': _EmberComponentHelper,
28
31
  '@ember/component/template-only': _TO,
29
32
  '@ember/debug': _debug,
30
33
  '@ember/destroyable': _destroyable,
@@ -35,7 +38,8 @@ export const modules = {
35
38
  '@ember/service': _service,
36
39
  '@ember/template-factory': { createTemplateFactory },
37
40
  '@ember/utils': _utils,
38
- // '@ember/owner': _owner,
41
+ '@ember/template': _template,
42
+ '@ember/owner': _owner,
39
43
 
40
44
  '@glimmer/component': _GlimmerComponent,
41
45
  '@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;;;;"}