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
@@ -1,100 +0,0 @@
1
- import { getTemplateLocals } from '@glimmer/syntax';
2
-
3
- import HTMLBars, { preprocessEmbeddedTemplates } from 'babel-plugin-htmlbars-inline-precompile';
4
- import { precompile as precompileTemplate } from 'ember-template-compiler';
5
-
6
- import { nameFor } from '../utils';
7
- import { evalSnippet } from './eval';
8
-
9
- import type { Babel, ExtraModules } from '../types';
10
-
11
- export interface Info {
12
- code: string;
13
- name: string;
14
- }
15
-
16
- export async function compileJS(code: string, extraModules?: ExtraModules) {
17
- let name = nameFor(code);
18
- let component: undefined | unknown;
19
- let error: undefined | Error;
20
-
21
- try {
22
- let compiled = await compileGJS({ code: code, name });
23
-
24
- if (!compiled) {
25
- throw new Error(`Compiled output is missing`);
26
- }
27
-
28
- component = evalSnippet(compiled, extraModules).default;
29
- } catch (e) {
30
- error = e;
31
- }
32
-
33
- return { name, component, error };
34
- }
35
-
36
- let babel: Babel;
37
-
38
- async function compileGJS({ code: input, name }: Info) {
39
- if (!babel) {
40
- babel = await import('@babel/standalone');
41
- }
42
-
43
- let preprocessed = preprocessEmbeddedTemplates(input, {
44
- getTemplateLocals,
45
- relativePath: `${name}.js`,
46
- includeSourceMaps: false,
47
- includeTemplateTokens: true,
48
- templateTag: 'template',
49
- templateTagReplacement: 'GLIMMER_TEMPLATE',
50
- getTemplateLocalsExportPath: 'getTemplateLocals',
51
- });
52
-
53
- let result = babel.transform(preprocessed.output, {
54
- filename: `${name}.js`,
55
- plugins: [
56
- [
57
- HTMLBars,
58
- {
59
- precompile: precompileTemplate,
60
- // this needs to be true until Ember 3.27+
61
- ensureModuleApiPolyfill: false,
62
- modules: {
63
- 'ember-template-imports': {
64
- export: 'hbs',
65
- useTemplateLiteralProposalSemantics: 1,
66
- },
67
-
68
- 'TEMPLATE-TAG-MODULE': {
69
- export: 'GLIMMER_TEMPLATE',
70
- debugName: '<template>',
71
- useTemplateTagProposalSemantics: 1,
72
- },
73
- },
74
- },
75
- ],
76
- [babel.availablePlugins['proposal-decorators'], { legacy: true }],
77
- [babel.availablePlugins['proposal-class-properties']],
78
- ],
79
- presets: [
80
- [
81
- babel.availablePresets['env'],
82
- {
83
- // false -- keeps ES Modules
84
- modules: 'cjs',
85
- targets: { esmodules: true },
86
- loose: true,
87
- forceAllTransforms: false,
88
- },
89
- ],
90
- ],
91
- });
92
-
93
- if (!result) {
94
- return;
95
- }
96
-
97
- let { code } = result;
98
-
99
- return code;
100
- }
@@ -1,131 +0,0 @@
1
- import { getTemplateLocals } from '@glimmer/syntax';
2
-
3
- import HTMLBars, { preprocessEmbeddedTemplates } from 'babel-plugin-htmlbars-inline-precompile';
4
- import { modules } from 'ember-repl/known-modules';
5
- import { precompile as precompileTemplate } from 'ember-template-compiler';
6
-
7
- import { nameFor } from '../utils';
8
-
9
- import type { ExtraModules } from '../types';
10
- import type Component from '@glimmer/component';
11
-
12
- export interface Info {
13
- code: string;
14
- name: string;
15
- }
16
-
17
- export async function compileJS(code: string, extraModules?: ExtraModules) {
18
- let name = nameFor(code);
19
- let component: undefined | unknown;
20
- let error: undefined | Error;
21
-
22
- try {
23
- let compiled = await compileGJS({ code: code, name });
24
-
25
- if (!compiled) {
26
- throw new Error(`Compiled output is missing`);
27
- }
28
-
29
- // NOTE: we cannot `eval` ESM
30
- compiled = proxyToSkypack(compiled, extraModules);
31
- component = await evalSnippet(compiled);
32
- } catch (e) {
33
- error = e;
34
- }
35
-
36
- return { name, component, error };
37
- }
38
-
39
- export function proxyToSkypack(code: string, extraModules?: ExtraModules) {
40
- let knownModules = [...Object.keys(extraModules || {}), ...Object.keys(modules)];
41
- let origin = location.origin;
42
-
43
- let result = code.replaceAll(/from ('|")([^"']+)('|")/g, (_, __, modulePath) => {
44
- if (knownModules.includes(modulePath)) {
45
- return `from '${origin}/${modulePath}'`;
46
- }
47
-
48
- return `from 'https://cdn.skypack.dev/${modulePath}'`;
49
- });
50
-
51
- return result;
52
- }
53
-
54
- async function evalSnippet(code: string) {
55
- let encodedJs = encodeURIComponent(code);
56
- let result = await import(
57
- /* webpackIgnore: true */ `data:text/javascript;charset=utf-8,${encodedJs}`
58
- );
59
-
60
- if (!result.default) {
61
- throw new Error(`Expected module to have a default export, found ${Object.keys(result)}`);
62
- }
63
-
64
- return result as {
65
- default: Component;
66
- services?: { [key: string]: unknown };
67
- };
68
- }
69
-
70
- async function compileGJS({ code: input, name }: Info) {
71
- let babel = await import('@babel/standalone');
72
-
73
- let preprocessed = preprocessEmbeddedTemplates(input, {
74
- getTemplateLocals,
75
- relativePath: `${name}.js`,
76
- includeSourceMaps: false,
77
- includeTemplateTokens: true,
78
- templateTag: 'template',
79
- templateTagReplacement: 'GLIMMER_TEMPLATE',
80
- getTemplateLocalsExportPath: 'getTemplateLocals',
81
- });
82
-
83
- let result = babel.transform(preprocessed.output, {
84
- filename: `${name}.js`,
85
- plugins: [
86
- [
87
- HTMLBars,
88
- {
89
- precompile: precompileTemplate,
90
- // this needs to be true until Ember 3.27+
91
- ensureModuleApiPolyfill: false,
92
- modules: {
93
- 'ember-template-imports': {
94
- export: 'hbs',
95
- useTemplateLiteralProposalSemantics: 1,
96
- },
97
-
98
- 'TEMPLATE-TAG-MODULE': {
99
- export: 'GLIMMER_TEMPLATE',
100
- debugName: '<template>',
101
- useTemplateTagProposalSemantics: 1,
102
- },
103
- },
104
- },
105
- ],
106
- [babel.availablePlugins['proposal-decorators'], { legacy: true }],
107
- [babel.availablePlugins['proposal-class-properties']],
108
- ],
109
- presets: [
110
- [
111
- babel.availablePresets['env'],
112
- {
113
- // false -- keeps ES Modules...
114
- // it means "compile modules to this: ..."
115
- modules: false,
116
- targets: { esmodules: true },
117
- loose: true,
118
- forceAllTransforms: false,
119
- },
120
- ],
121
- ],
122
- });
123
-
124
- if (!result) {
125
- return;
126
- }
127
-
128
- let { code } = result;
129
-
130
- return code;
131
- }
package/cjs/eval.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import type Component from '@glimmer/component';
2
- import type { ExtraModules } from 'ember-repl/types';
3
- export declare function evalSnippet(compiled: string, extraModules?: ExtraModules): {
4
- default: Component;
5
- services?: {
6
- [key: string]: unknown;
7
- };
8
- };
package/cjs/index.d.ts DELETED
@@ -1,10 +0,0 @@
1
- import type { ExtraModules } from '../types';
2
- export interface Info {
3
- code: string;
4
- name: string;
5
- }
6
- export declare function compileJS(code: string, extraModules?: ExtraModules): Promise<{
7
- name: string;
8
- component: unknown;
9
- error: Error | undefined;
10
- }>;
@@ -1,5 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = function (/* environment, appConfig */) {
4
- return {};
5
- };
package/esm/index.d.ts DELETED
@@ -1,11 +0,0 @@
1
- import type { ExtraModules } from '../types';
2
- export interface Info {
3
- code: string;
4
- name: string;
5
- }
6
- export declare function compileJS(code: string, extraModules?: ExtraModules): Promise<{
7
- name: string;
8
- component: unknown;
9
- error: Error | undefined;
10
- }>;
11
- export declare function proxyToSkypack(code: string, extraModules?: ExtraModules): string;
package/index.d.ts DELETED
@@ -1,5 +0,0 @@
1
- export { compileHBS } from './hbs';
2
- export { compileJS } from './js';
3
- export { modules as frameworkModules } from './known-modules';
4
- export { invocationName, invocationOf, nameFor } from './utils';
5
- export type { CompileResult } from './types';
package/index.js DELETED
@@ -1,105 +0,0 @@
1
- 'use strict';
2
-
3
- const path = require('path');
4
- const { stripIndents } = require('common-tags');
5
- const Funnel = require('broccoli-funnel');
6
- const mergeTrees = require('broccoli-merge-trees');
7
-
8
- module.exports = {
9
- name: require('./package').name,
10
-
11
- options: {
12
- 'ember-cli-babel': {
13
- enableTypeScriptTransform: true,
14
- },
15
- babel: {
16
- plugins: [require.resolve('ember-auto-import/babel-plugin')],
17
- },
18
- autoImport: {
19
- webpack: {
20
- node: {
21
- global: false,
22
- __filename: true,
23
- __dirname: true,
24
- },
25
- resolve: {
26
- fallback: {
27
- path: 'path-browserify',
28
- },
29
- },
30
- },
31
- },
32
- },
33
-
34
- included() {
35
- this._super.included.apply(this, arguments);
36
-
37
- const app = this._findHost(this);
38
-
39
- // Adds:
40
- // - ember-template-compiler
41
- // - @glimmer/syntax
42
- app.import('vendor/ember/ember-template-compiler.js');
43
- },
44
-
45
- /**
46
- * This technique can't be used because it duplicates the modules
47
- * in traditional builds. Additionally, because this way
48
- * doesn't utilize a service worker, we can't also point all the
49
- * imports within these files to the other files we've copied.
50
- */
51
- __treeForPublic() {
52
- const publicTree = this._super.treeForPublic.apply(this, arguments);
53
-
54
- const app = this._findHost(this);
55
- const root = app.project.root;
56
- const dist = path.join(root, 'node_modules/ember-source/dist/packages');
57
- const trees = [];
58
-
59
- if (publicTree) {
60
- trees.push(publicTree);
61
- }
62
-
63
- let packages = new Funnel(dist, {
64
- annotation: 'ember-repl adding ember ESM from ember-source/dist/packages',
65
- destDir: '/',
66
- });
67
-
68
- trees.push(packages);
69
-
70
- return mergeTrees(trees);
71
- },
72
- };
73
-
74
- /**
75
- * Builds a file with a single export, COMPONENT_MAP, that
76
- * is a map of the provided paths *to* all exported identifiers
77
- * from each of the provided paths.
78
- *
79
- * This is helpful for building a map of imports to force to be included
80
- * in the build - a requirement for builds that tend to tree shake.
81
- *
82
- * @param {string[]} paths - list of import paths for each module that you want availableb to the REPL
83
- */
84
- module.exports.buildComponentMap = function buildComponentMap(paths) {
85
- const writeFile = require('broccoli-file-creator');
86
- const fileContent = stripIndents`
87
- ${paths
88
- .map((path, i) => {
89
- return `import * as ComponentMapPart${i} from '${path}';`;
90
- })
91
- .join('\n')}
92
-
93
- export const COMPONENT_MAP = {
94
- ${paths
95
- .map((path, i) => {
96
- return `'${path}': ComponentMapPart${i},`;
97
- })
98
- .join('\n')}
99
- };
100
- `;
101
-
102
- const tree = writeFile('/ember-repl/component-map.js', fileContent);
103
-
104
- return tree;
105
- };
package/tsconfig.json DELETED
@@ -1,56 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es2021",
4
- "allowJs": true,
5
- "moduleResolution": "node",
6
- "allowSyntheticDefaultImports": true,
7
- "noImplicitAny": true,
8
- "noImplicitThis": true,
9
- "alwaysStrict": true,
10
- "strictNullChecks": true,
11
- "strictPropertyInitialization": true,
12
- "noFallthroughCasesInSwitch": true,
13
- "noUnusedLocals": true,
14
- "noUnusedParameters": true,
15
- "noImplicitReturns": true,
16
- "noEmitOnError": false,
17
- "noEmit": true,
18
- "inlineSourceMap": true,
19
- "inlineSources": true,
20
- "baseUrl": ".",
21
- "module": "ESNext",
22
- "experimentalDecorators": true,
23
- "paths": {
24
- "dummy/tests/*": [
25
- "tests/*"
26
- ],
27
- "dummy/*": [
28
- "tests/dummy/app/*",
29
- "app/*"
30
- ],
31
- "ember-repl": [
32
- "addon"
33
- ],
34
- "ember-repl/*": [
35
- "addon/*"
36
- ],
37
- "ember-repl/test-support": [
38
- "addon-test-support"
39
- ],
40
- "ember-repl/test-support/*": [
41
- "addon-test-support/*"
42
- ],
43
- "*": [
44
- "types/*"
45
- ]
46
- }
47
- },
48
- "include": [
49
- "app/**/*",
50
- "addon/**/*",
51
- "tests/**/*",
52
- "types/**/*",
53
- "test-support/**/*",
54
- "addon-test-support/**/*"
55
- ]
56
- }
@@ -1 +0,0 @@
1
-
package/types/global.d.ts DELETED
@@ -1,43 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unused-vars */
2
- // Types for compiled templates
3
- // declare module 'ember-repl/templates/*' {
4
- // import type { TemplateFactory } from 'htmlbars-inline-precompile';
5
- // const tmpl: TemplateFactory;
6
- // export default tmpl;
7
- // }
8
-
9
-
10
- // provided by vendor/ember/ember-template-compiler.js (somehow)
11
- declare module 'ember-template-compiler';
12
-
13
- declare module '@ember/-internals/glimmer';
14
- declare module '@ember/helper';
15
- declare module '@ember/modifier';
16
- declare module '@ember/template-factory';
17
-
18
- /**
19
- * ember-cli-typescript does not provide types for glimmer...
20
- * ember-source does not provide types for glimmer...
21
- */
22
- declare module '@glimmer/compiler' {
23
- import type {PrecompileOptions} from "ember-cli-htmlbars";
24
- export function precompileJSON(source: string, options: PrecompileOptions): [unknown, string[]]
25
- }
26
-
27
- declare module 'babel-plugin-htmlbars-inline-precompile';
28
- declare module '@babel/plugin-proposal-decorators';
29
-
30
- declare module '@ember/template-compilation' {
31
- export interface CompileOptions {
32
- moduleName: string;
33
- strictMode: boolean;
34
- locals?: Array<unknown>;
35
- scope: Record<string, unknown> | (() => Record<string, unknown>);
36
- isProduction?: boolean;
37
- meta?: Record<string, unknown>;
38
- // plugins: {
39
- // ast: Array<unknown>
40
- // }
41
- }
42
- export function compileTemplate(template: string, options: CompileOptions): any;
43
- }
@@ -1,18 +0,0 @@
1
- import '@ember/component';
2
- import type {TemplateFactory} from 'ember-cli-htmlbars';
3
-
4
- /**
5
- * Typed Ember is refraining from adding this because it's not *really* intended for
6
- * mainstream use
7
- */
8
- declare module '@ember/component' {
9
- // https://github.com/glimmerjs/glimmer-vm/blob/1bc620be641d0748e643ce64592e7442d314e590/packages/%40glimmer/manager/lib/public/template.ts#L9
10
- export function setComponentTemplate(factory: TemplateFactory, obj: object): object;
11
- }
12
-
13
-
14
- // provided by vendor/ember/ember-template-compiler.js (somehow)
15
- declare module '@glimmer/syntax' {
16
- export function getTemplateLocals(template: string): string[];
17
- }
18
-
package/types.d.ts DELETED
@@ -1,15 +0,0 @@
1
- import type { availablePlugins, availablePresets, transform } from '@babel/standalone';
2
- export interface CompileResult {
3
- component?: unknown;
4
- error?: Error;
5
- name: string;
6
- }
7
- export interface Babel {
8
- availablePlugins: typeof availablePlugins;
9
- availablePresets: typeof availablePresets;
10
- transform: typeof transform;
11
- }
12
- export declare type Options = {
13
- skypack?: boolean;
14
- };
15
- export declare type ExtraModules = Record<string, unknown>;
File without changes