ember-repl 3.0.0-beta.6 → 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 (47) hide show
  1. package/declarations/browser/gjs.d.ts +1 -1
  2. package/declarations/browser/gjs.d.ts.map +1 -1
  3. package/declarations/browser/known-modules.d.ts +4 -0
  4. package/declarations/browser/known-modules.d.ts.map +1 -1
  5. package/dist/browser/cjs/index.js +1 -1
  6. package/dist/browser/cjs/index.js.map +1 -1
  7. package/dist/browser/esm/index.js +1 -1
  8. package/dist/browser/esm/index.js.map +1 -1
  9. package/dist/browser/gjs.js +12 -13
  10. package/dist/browser/gjs.js.map +1 -1
  11. package/dist/browser/known-modules.js +4 -4
  12. package/dist/browser/known-modules.js.map +1 -1
  13. package/package.json +52 -51
  14. package/src/browser/cjs/index.ts +1 -1
  15. package/src/browser/esm/index.ts +1 -1
  16. package/src/browser/gjs.ts +13 -15
  17. package/src/browser/known-modules.ts +4 -2
  18. package/declarations/browser/eti/babel-plugin.d.ts +0 -54
  19. package/declarations/browser/eti/babel-plugin.d.ts.map +0 -1
  20. package/declarations/browser/eti/debug.d.ts +0 -2
  21. package/declarations/browser/eti/debug.d.ts.map +0 -1
  22. package/declarations/browser/eti/parse-templates.d.ts +0 -56
  23. package/declarations/browser/eti/parse-templates.d.ts.map +0 -1
  24. package/declarations/browser/eti/preprocess.d.ts +0 -58
  25. package/declarations/browser/eti/preprocess.d.ts.map +0 -1
  26. package/declarations/browser/eti/template-tag-transform.d.ts +0 -15
  27. package/declarations/browser/eti/template-tag-transform.d.ts.map +0 -1
  28. package/declarations/browser/eti/util.d.ts +0 -14
  29. package/declarations/browser/eti/util.d.ts.map +0 -1
  30. package/dist/browser/eti/babel-plugin.js +0 -95
  31. package/dist/browser/eti/babel-plugin.js.map +0 -1
  32. package/dist/browser/eti/debug.js +0 -9
  33. package/dist/browser/eti/debug.js.map +0 -1
  34. package/dist/browser/eti/parse-templates.js +0 -181
  35. package/dist/browser/eti/parse-templates.js.map +0 -1
  36. package/dist/browser/eti/preprocess.js +0 -106
  37. package/dist/browser/eti/preprocess.js.map +0 -1
  38. package/dist/browser/eti/template-tag-transform.js +0 -46
  39. package/dist/browser/eti/template-tag-transform.js.map +0 -1
  40. package/dist/browser/eti/util.js +0 -39
  41. package/dist/browser/eti/util.js.map +0 -1
  42. package/src/browser/eti/babel-plugin.ts +0 -105
  43. package/src/browser/eti/debug.ts +0 -7
  44. package/src/browser/eti/parse-templates.ts +0 -284
  45. package/src/browser/eti/preprocess.ts +0 -187
  46. package/src/browser/eti/template-tag-transform.ts +0 -100
  47. package/src/browser/eti/util.ts +0 -72
@@ -1,100 +0,0 @@
1
- import { buildPrecompileTemplateCall, registerRefs, TEMPLATE_TAG_NAME } from './util.ts';
2
-
3
- /**
4
- * Supports the following syntaxes:
5
- *
6
- * const Foo = [GLIMMER_TEMPLATE('hello')];
7
- *
8
- * export const Foo = [GLIMMER_TEMPLATE('hello')];
9
- *
10
- * export default [GLIMMER_TEMPLATE('hello')];
11
- *
12
- * class Foo {
13
- * [GLIMMER_TEMPLATE('hello')];
14
- * }
15
- */
16
- export const transformTemplateTag = function (t: any, templatePath: any, state: any) {
17
- let compiled = buildPrecompileTemplateCall(t, templatePath, state);
18
- let path = templatePath.parentPath;
19
-
20
- if (path.type === 'ArrayExpression') {
21
- let arrayParentPath = path.parentPath;
22
- let varId = arrayParentPath.node.id || path.scope.generateUidIdentifier(templatePath);
23
-
24
- const templateOnlyComponentExpression = t.callExpression(
25
- buildSetComponentTemplate(path, state),
26
- [
27
- compiled,
28
- t.callExpression(
29
- state.importUtil.import(
30
- templatePath,
31
- '@ember/component/template-only',
32
- 'default',
33
- 'templateOnly'
34
- ),
35
- [t.stringLiteral('dynamic-runtime-file.js'), t.stringLiteral(varId.name)]
36
- ),
37
- ]
38
- );
39
-
40
- if (
41
- arrayParentPath.type === 'ExpressionStatement' &&
42
- arrayParentPath.parentPath.type === 'Program'
43
- ) {
44
- registerRefs(
45
- arrayParentPath.replaceWith(t.exportDefaultDeclaration(templateOnlyComponentExpression)),
46
- (newPath: any) => [
47
- newPath.get('declaration.callee'),
48
- newPath.get('declaration.arguments.0.callee'),
49
- newPath.get('declaration.arguments.1.callee'),
50
- ]
51
- );
52
- } else {
53
- registerRefs(path.replaceWith(templateOnlyComponentExpression), (newPath: any) => [
54
- newPath.get('callee'),
55
- newPath.get('arguments.0.callee'),
56
- newPath.get('arguments.1.callee'),
57
- ]);
58
- }
59
- } else if (path.type === 'ClassProperty') {
60
- let classPath = path.parentPath.parentPath;
61
-
62
- if (classPath.node.type === 'ClassDeclaration') {
63
- registerRefs(
64
- classPath.insertAfter(
65
- t.expressionStatement(
66
- t.callExpression(buildSetComponentTemplate(path, state), [compiled, classPath.node.id])
67
- )
68
- ),
69
- (newPath: any) => [
70
- newPath.get('expression.callee'),
71
- newPath.get('expression.arguments.0.callee'),
72
- ]
73
- );
74
- } else {
75
- registerRefs(
76
- classPath.replaceWith(
77
- t.expressionStatement(
78
- t.callExpression(buildSetComponentTemplate(path, state), [compiled, classPath.node])
79
- )
80
- ),
81
- (newPath: any) => [
82
- newPath.parentPath.get('callee'),
83
- newPath.parentPath.get('arguments.0.callee'),
84
- ]
85
- );
86
- }
87
-
88
- path.remove();
89
-
90
- return;
91
- } else {
92
- throw path.buildCodeFrameError(
93
- `Attempted to use \`<${TEMPLATE_TAG_NAME}>\` to define a template in an unsupported way. Templates defined using this syntax must be:\n\n1. Assigned to a variable declaration OR\n2. The default export of a file OR\n2. In the top level of the file on their own (sugar for \`export default\`) OR\n4. Used directly within a named class body`
94
- );
95
- }
96
- };
97
-
98
- function buildSetComponentTemplate(path: any, state: any) {
99
- return state.importUtil.import(path, '@ember/component', 'setComponentTemplate');
100
- }
@@ -1,72 +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
-
6
- // const Greeting = <template>Hello</template>
7
- export const TEMPLATE_TAG_NAME = 'template';
8
- export const TEMPLATE_TAG_PLACEHOLDER = '__GLIMMER_TEMPLATE';
9
-
10
- export function isTemplateTag(callExpressionPath: NodePath<CallExpression>) {
11
- const callee = callExpressionPath.get('callee');
12
-
13
- return (
14
- !Array.isArray(callee) && callee.isIdentifier() && callee.node.name === TEMPLATE_TAG_PLACEHOLDER
15
- );
16
- }
17
-
18
- export function buildPrecompileTemplateCall(
19
- t: any,
20
- callExpressionPath: NodePath<CallExpression>,
21
- state: {
22
- importUtil: ImportUtil;
23
- }
24
- ): CallExpression {
25
- const callee = callExpressionPath.get('callee');
26
-
27
- return t.callExpression(
28
- state.importUtil.import(callee, '@ember/template-compilation', 'precompileTemplate'),
29
- callExpressionPath.node.arguments
30
- );
31
- }
32
-
33
- export function registerRefs(
34
- newPath: string | string[],
35
- getRefPaths: (path: string) => NodePath[]
36
- ) {
37
- if (Array.isArray(newPath)) {
38
- if (newPath.length > 1) {
39
- throw new Error(
40
- 'registerRefs is only meant to handle single node transformations. Received more than one path node.'
41
- );
42
- }
43
-
44
- newPath = newPath[0] as string;
45
- }
46
-
47
- const refPaths = getRefPaths(newPath);
48
-
49
- for (const ref of refPaths) {
50
- if (!ref.isIdentifier()) {
51
- throw new Error(
52
- 'ember-template-imports internal assumption that refPath should of type identifier. Please open an issue.'
53
- );
54
- }
55
-
56
- const binding = ref.scope.getBinding(ref.node.name);
57
-
58
- if (binding !== undefined) {
59
- binding.reference(ref);
60
- }
61
- }
62
- }
63
-
64
- const SUPPORTED_EXTENSIONS = ['.js', '.ts', '.gjs', '.gts'];
65
-
66
- export function isSupportedScriptFileExtension(filePath: string) {
67
- return SUPPORTED_EXTENSIONS.some((ext) => filePath.endsWith(ext));
68
- }
69
-
70
- export function isStrictMode(templateInfo: TemplateMatch): boolean {
71
- return templateInfo.type === 'template-tag';
72
- }