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
@@ -0,0 +1,94 @@
1
+ import { setComponentTemplate } from '@ember/component';
2
+ import _TO from '@ember/component/template-only';
3
+ import { array, concat, fn, get, hash } from '@ember/helper';
4
+ import { on } from '@ember/modifier';
5
+ import { createTemplateFactory } from '@ember/template-factory';
6
+ import { importSync } from '@embroider/macros';
7
+ import { nameFor } from './utils.js';
8
+
9
+ /* eslint-disable @typescript-eslint/no-explicit-any */
10
+ // import { precompileJSON } from '@glimmer/compiler';
11
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
12
+ // @ts-ignore
13
+ // These things are pre-bundled in the old system.
14
+ // ember-template-compiler defines them in AMD/requirejs
15
+ const {
16
+ precompileJSON
17
+ } = importSync('@glimmer/compiler');
18
+ const {
19
+ getTemplateLocals
20
+ } = importSync('@glimmer/syntax');
21
+
22
+ /**
23
+ * compile a template with an empty scope
24
+ * to use components, helpers, etc, you will need to compile with JS
25
+ *
26
+ * (templates alone do not have a way to import / define complex structures)
27
+ */
28
+ function compileHBS(template, options = {}) {
29
+ let name = nameFor(template);
30
+ let component;
31
+ let error;
32
+ try {
33
+ component = setComponentTemplate(compileTemplate(template, {
34
+ moduleName: name,
35
+ ...options
36
+ }), _TO(name));
37
+ } catch (e) {
38
+ error = e;
39
+ }
40
+ return {
41
+ name,
42
+ component,
43
+ error
44
+ };
45
+ }
46
+ /**
47
+ * The reason why we can't use precompile directly is because of this:
48
+ * https://github.com/glimmerjs/glimmer-vm/blob/master/packages/%40glimmer/compiler/lib/compiler.ts#L132
49
+ *
50
+ * Support for dynamically compiling templates in strict mode doesn't seem to be fully their yet.
51
+ * That JSON.stringify (and the lines after) prevent us from easily setting the scope function,
52
+ * which means that *everything* is undefined.
53
+ */
54
+ function compileTemplate(source, {
55
+ moduleName,
56
+ scope = {}
57
+ }) {
58
+ let localScope = {
59
+ array,
60
+ concat,
61
+ fn,
62
+ get,
63
+ hash,
64
+ on,
65
+ ...scope
66
+ };
67
+ let locals = getTemplateLocals(source);
68
+ let options = {
69
+ strictMode: true,
70
+ moduleName,
71
+ locals,
72
+ isProduction: false,
73
+ meta: {
74
+ moduleName
75
+ }
76
+ };
77
+
78
+ // Copied from @glimmer/compiler/lib/compiler#precompile
79
+ let [block, usedLocals] = precompileJSON(source, options);
80
+ let usedScope = usedLocals.map(key => localScope[key]);
81
+ let blockJSON = JSON.stringify(block);
82
+ let templateJSONObject = {
83
+ id: moduleName,
84
+ block: blockJSON,
85
+ moduleName: moduleName ?? '(unknown template module)',
86
+ scope: () => usedScope,
87
+ isStrictMode: true
88
+ };
89
+ let factory = createTemplateFactory(templateJSONObject);
90
+ return factory;
91
+ }
92
+
93
+ export { compileHBS };
94
+ //# sourceMappingURL=hbs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hbs.js","sources":["../../src/browser/hbs.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n// import { precompileJSON } from '@glimmer/compiler';\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { setComponentTemplate } from '@ember/component';\nimport templateOnlyComponent from '@ember/component/template-only';\nimport { array, concat, fn, get, hash } from '@ember/helper';\nimport { on } from '@ember/modifier';\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { createTemplateFactory } from '@ember/template-factory';\nimport { importSync } from '@embroider/macros';\n\nimport { nameFor } from './utils';\n\nimport type { CompileResult } from './types';\nimport type { ComponentLike } from '@glint/template';\n\n// These things are pre-bundled in the old system.\n// ember-template-compiler defines them in AMD/requirejs\nconst { precompileJSON } = importSync('@glimmer/compiler') as any;\nconst { getTemplateLocals } = importSync('@glimmer/syntax') as any;\n\n/**\n * compile a template with an empty scope\n * to use components, helpers, etc, you will need to compile with JS\n *\n * (templates alone do not have a way to import / define complex structures)\n */\nexport function compileHBS(\n template: string,\n options: Omit<CompileTemplateOptions, 'moduleName'> = {}\n): CompileResult {\n let name = nameFor(template);\n let component: undefined | ComponentLike;\n let error: undefined | Error;\n\n try {\n component = setComponentTemplate(\n compileTemplate(template, { moduleName: name, ...options }),\n templateOnlyComponent(name)\n ) as ComponentLike;\n } catch (e) {\n error = e as Error | undefined;\n }\n\n return { name, component, error };\n}\n\ninterface CompileTemplateOptions {\n moduleName: string;\n scope?: Record<string, unknown>;\n}\n\n/**\n * The reason why we can't use precompile directly is because of this:\n * https://github.com/glimmerjs/glimmer-vm/blob/master/packages/%40glimmer/compiler/lib/compiler.ts#L132\n *\n * Support for dynamically compiling templates in strict mode doesn't seem to be fully their yet.\n * That JSON.stringify (and the lines after) prevent us from easily setting the scope function,\n * which means that *everything* is undefined.\n */\nfunction compileTemplate(source: string, { moduleName, scope = {} }: CompileTemplateOptions) {\n let localScope = { array, concat, fn, get, hash, on, ...scope } as any;\n let locals = getTemplateLocals(source);\n\n let options = {\n strictMode: true,\n moduleName,\n locals,\n isProduction: false,\n meta: { moduleName },\n };\n\n // Copied from @glimmer/compiler/lib/compiler#precompile\n let [block, usedLocals] = precompileJSON(source, options);\n\n let usedScope = usedLocals.map((key: string) => localScope[key]);\n\n let blockJSON = JSON.stringify(block);\n let templateJSONObject = {\n id: moduleName,\n block: blockJSON,\n moduleName: moduleName ?? '(unknown template module)',\n scope: () => usedScope,\n isStrictMode: true,\n };\n\n let factory = createTemplateFactory(templateJSONObject);\n\n return factory;\n}\n"],"names":["precompileJSON","importSync","getTemplateLocals","compileHBS","template","options","name","nameFor","component","error","setComponentTemplate","compileTemplate","moduleName","templateOnlyComponent","e","source","scope","localScope","array","concat","fn","get","hash","on","locals","strictMode","isProduction","meta","block","usedLocals","usedScope","map","key","blockJSON","JSON","stringify","templateJSONObject","id","isStrictMode","factory","createTemplateFactory"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AAeA;AACA;AACA,MAAM;AAAEA,EAAAA,cAAAA;AAAe,CAAC,GAAGC,UAAU,CAAC,mBAAmB,CAAQ,CAAA;AACjE,MAAM;AAAEC,EAAAA,iBAAAA;AAAkB,CAAC,GAAGD,UAAU,CAAC,iBAAiB,CAAQ,CAAA;;AAElE;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,UAAUA,CACxBC,QAAgB,EAChBC,OAAmD,GAAG,EAAE,EACzC;AACf,EAAA,IAAIC,IAAI,GAAGC,OAAO,CAACH,QAAQ,CAAC,CAAA;AAC5B,EAAA,IAAII,SAAoC,CAAA;AACxC,EAAA,IAAIC,KAAwB,CAAA;EAE5B,IAAI;AACFD,IAAAA,SAAS,GAAGE,oBAAoB,CAC9BC,eAAe,CAACP,QAAQ,EAAE;AAAEQ,MAAAA,UAAU,EAAEN,IAAI;MAAE,GAAGD,OAAAA;AAAQ,KAAC,CAAC,EAC3DQ,GAAqB,CAACP,IAAI,CAC5B,CAAkB,CAAA;GACnB,CAAC,OAAOQ,CAAC,EAAE;AACVL,IAAAA,KAAK,GAAGK,CAAsB,CAAA;AAChC,GAAA;EAEA,OAAO;IAAER,IAAI;IAAEE,SAAS;AAAEC,IAAAA,KAAAA;GAAO,CAAA;AACnC,CAAA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASE,eAAeA,CAACI,MAAc,EAAE;EAAEH,UAAU;AAAEI,EAAAA,KAAK,GAAG,EAAC;AAA0B,CAAC,EAAE;AAC3F,EAAA,IAAIC,UAAU,GAAG;IAAEC,KAAK;IAAEC,MAAM;IAAEC,EAAE;IAAEC,GAAG;IAAEC,IAAI;IAAEC,EAAE;IAAE,GAAGP,KAAAA;GAAc,CAAA;AACtE,EAAA,IAAIQ,MAAM,GAAGtB,iBAAiB,CAACa,MAAM,CAAC,CAAA;AAEtC,EAAA,IAAIV,OAAO,GAAG;AACZoB,IAAAA,UAAU,EAAE,IAAI;IAChBb,UAAU;IACVY,MAAM;AACNE,IAAAA,YAAY,EAAE,KAAK;AACnBC,IAAAA,IAAI,EAAE;AAAEf,MAAAA,UAAAA;AAAW,KAAA;GACpB,CAAA;;AAED;EACA,IAAI,CAACgB,KAAK,EAAEC,UAAU,CAAC,GAAG7B,cAAc,CAACe,MAAM,EAAEV,OAAO,CAAC,CAAA;AAEzD,EAAA,IAAIyB,SAAS,GAAGD,UAAU,CAACE,GAAG,CAAEC,GAAW,IAAKf,UAAU,CAACe,GAAG,CAAC,CAAC,CAAA;AAEhE,EAAA,IAAIC,SAAS,GAAGC,IAAI,CAACC,SAAS,CAACP,KAAK,CAAC,CAAA;AACrC,EAAA,IAAIQ,kBAAkB,GAAG;AACvBC,IAAAA,EAAE,EAAEzB,UAAU;AACdgB,IAAAA,KAAK,EAAEK,SAAS;IAChBrB,UAAU,EAAEA,UAAU,IAAI,2BAA2B;IACrDI,KAAK,EAAEA,MAAMc,SAAS;AACtBQ,IAAAA,YAAY,EAAE,IAAA;GACf,CAAA;AAED,EAAA,IAAIC,OAAO,GAAGC,qBAAqB,CAACJ,kBAAkB,CAAC,CAAA;AAEvD,EAAA,OAAOG,OAAO,CAAA;AAChB;;;;"}
@@ -0,0 +1,5 @@
1
+ export { compileHBS } from "./hbs.js";
2
+ export { compileJS } from "./js.js";
3
+ export { modules as frameworkModules } from "./known-modules.js";
4
+ export { invocationName, invocationOf, nameFor } from "./utils.js";
5
+ export type { CompileResult } from "./types.js";
@@ -0,0 +1,5 @@
1
+ export { compileHBS } from './hbs.js';
2
+ export { compileJS } from './js.js';
3
+ export { modules as frameworkModules } from './known-modules.js';
4
+ export { invocationName, invocationOf, nameFor } from './utils.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
@@ -1,4 +1,4 @@
1
- import type { ExtraModules, Options } from './types';
1
+ import { CompileResult, ExtraModules, Options } from "./types.js";
2
2
  /**
3
3
  * @public
4
4
  * Transpiles GlimmerJS (*.gjs) formatted text into and evaluates as a JS Module.
@@ -16,8 +16,5 @@ import type { ExtraModules, Options } from './types';
16
16
  * are not provided by extraModules will be searched on npm to see if a package
17
17
  * needs to be downloaded before running the `code` / invoking the component
18
18
  */
19
- export declare function compileJS(code: string, extraModules?: ExtraModules, options?: Options): Promise<{
20
- name: string;
21
- component: unknown;
22
- error: Error | undefined;
23
- }>;
19
+ declare function compileJS(code: string, extraModules?: ExtraModules, options?: Options): Promise<CompileResult>;
20
+ export { compileJS };
@@ -0,0 +1,38 @@
1
+ import { compileJS as compileJS$2 } from './cjs/index.js';
2
+ import { compileJS as compileJS$1 } from './esm/index.js';
3
+
4
+ /**
5
+ * @public
6
+ * Transpiles GlimmerJS (*.gjs) formatted text into and evaluates as a JS Module.
7
+ * The returned component can be invoked explicitly in the consuming project.
8
+ *
9
+ * SEE: README for example usage
10
+ *
11
+ * @param {string} code: the code to be compiled
12
+ * @param {Object} extraModules: map of import paths to modules. This isn't needed
13
+ * for classic ember projects, but for strict static ember projects, extraModules
14
+ * will need to be pasesd if compileJS is intended to be used in a styleguide or
15
+ * if there are additional modules that could be imported in the passed `code`.
16
+ *
17
+ * Later on, imports that are not present by default (ember/glimmer) or that
18
+ * are not provided by extraModules will be searched on npm to see if a package
19
+ * needs to be downloaded before running the `code` / invoking the component
20
+ */
21
+ function compileJS(code, extraModules, options) {
22
+ if (options?.skypack) {
23
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
24
+ // if (!(window as any).webpackChunkDummy) {
25
+ // return {
26
+ // component: undefined,
27
+ // name: undefined,
28
+ // error: `Your environment is using AMD utilities -- using native ESM is not allowed unless the environment is also ESM`,
29
+ // };
30
+ // }
31
+
32
+ return compileJS$1(code, extraModules);
33
+ }
34
+ return compileJS$2(code, extraModules);
35
+ }
36
+
37
+ export { compileJS };
38
+ //# sourceMappingURL=js.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"js.js","sources":["../../src/browser/js.ts"],"sourcesContent":["import { compileJS as compileAMD } from './cjs';\nimport { compileJS as compileESM } from './esm';\n\nimport type { CompileResult, ExtraModules, Options } from './types';\n\n/**\n * @public\n * Transpiles GlimmerJS (*.gjs) formatted text into and evaluates as a JS Module.\n * The returned component can be invoked explicitly in the consuming project.\n *\n * SEE: README for example usage\n *\n * @param {string} code: the code to be compiled\n * @param {Object} extraModules: map of import paths to modules. This isn't needed\n * for classic ember projects, but for strict static ember projects, extraModules\n * will need to be pasesd if compileJS is intended to be used in a styleguide or\n * if there are additional modules that could be imported in the passed `code`.\n *\n * Later on, imports that are not present by default (ember/glimmer) or that\n * are not provided by extraModules will be searched on npm to see if a package\n * needs to be downloaded before running the `code` / invoking the component\n */\nexport function compileJS(\n code: string,\n extraModules?: ExtraModules,\n options?: Options\n): Promise<CompileResult> {\n if (options?.skypack) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n // if (!(window as any).webpackChunkDummy) {\n // return {\n // component: undefined,\n // name: undefined,\n // error: `Your environment is using AMD utilities -- using native ESM is not allowed unless the environment is also ESM`,\n // };\n // }\n\n return compileESM(code, extraModules);\n }\n\n return compileAMD(code, extraModules);\n}\n"],"names":["compileJS","code","extraModules","options","skypack","compileESM","compileAMD"],"mappings":";;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,SAASA,CACvBC,IAAY,EACZC,YAA2B,EAC3BC,OAAiB,EACO;EACxB,IAAIA,OAAO,EAAEC,OAAO,EAAE;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,IAAA,OAAOC,WAAU,CAACJ,IAAI,EAAEC,YAAY,CAAC,CAAA;AACvC,GAAA;AAEA,EAAA,OAAOI,WAAU,CAACL,IAAI,EAAEC,YAAY,CAAC,CAAA;AACvC;;;;"}
@@ -10,20 +10,22 @@ import * as _EmberComponent from '@ember/component';
10
10
  import _TO from '@ember/component/template-only';
11
11
  import * as _debug from '@ember/debug';
12
12
  import * as _destroyable from '@ember/destroyable';
13
+ import * as _helpers from '@ember/helper';
14
+ import * as _modifier from '@ember/modifier';
13
15
  import * as _object from '@ember/object';
14
16
  import * as _runloop from '@ember/runloop';
15
17
  import * as _service from '@ember/service';
16
18
  import * as _string from '@ember/string';
17
19
  import * as _utils from '@ember/utils';
18
- export declare const modules: {
20
+ declare const modules: {
19
21
  '@ember/application': typeof _application;
20
22
  '@ember/array': typeof _array;
21
23
  '@ember/component': typeof _EmberComponent;
22
24
  '@ember/component/template-only': typeof _TO;
23
25
  '@ember/debug': typeof _debug;
24
26
  '@ember/destroyable': typeof _destroyable;
25
- '@ember/helper': any;
26
- '@ember/modifier': any;
27
+ '@ember/helper': typeof _helpers;
28
+ '@ember/modifier': typeof _modifier;
27
29
  '@ember/object': typeof _object;
28
30
  '@ember/runloop': typeof _runloop;
29
31
  '@ember/service': typeof _service;
@@ -35,3 +37,4 @@ export declare const modules: {
35
37
  '@glimmer/component': typeof _GlimmerComponent;
36
38
  '@glimmer/tracking': typeof _tracking;
37
39
  };
40
+ export { modules };
@@ -0,0 +1,48 @@
1
+ import _GlimmerComponent from '@glimmer/component';
2
+ import * as _tracking from '@glimmer/tracking';
3
+ import * as _application from '@ember/application';
4
+ import * as _array from '@ember/array';
5
+ import * as _EmberComponent from '@ember/component';
6
+ import _TO from '@ember/component/template-only';
7
+ import * as _debug from '@ember/debug';
8
+ import * as _destroyable from '@ember/destroyable';
9
+ import * as _helpers from '@ember/helper';
10
+ import * as _modifier from '@ember/modifier';
11
+ import * as _object from '@ember/object';
12
+ import * as _runloop from '@ember/runloop';
13
+ import * as _service from '@ember/service';
14
+ import * as _string from '@ember/string';
15
+ import { createTemplateFactory } from '@ember/template-factory';
16
+ import * as _utils from '@ember/utils';
17
+
18
+ /**
19
+ * We need to import and hang on to these references so that they
20
+ * don't get optimized away during deploy
21
+ */
22
+ // import * as _owner from '@ember/owner';
23
+
24
+ const modules = {
25
+ '@ember/application': _application,
26
+ '@ember/array': _array,
27
+ '@ember/component': _EmberComponent,
28
+ '@ember/component/template-only': _TO,
29
+ '@ember/debug': _debug,
30
+ '@ember/destroyable': _destroyable,
31
+ '@ember/helper': _helpers,
32
+ '@ember/modifier': _modifier,
33
+ '@ember/object': _object,
34
+ '@ember/runloop': _runloop,
35
+ '@ember/service': _service,
36
+ '@ember/string': _string,
37
+ '@ember/template-factory': {
38
+ createTemplateFactory
39
+ },
40
+ '@ember/utils': _utils,
41
+ // '@ember/owner': _owner,
42
+
43
+ '@glimmer/component': _GlimmerComponent,
44
+ '@glimmer/tracking': _tracking
45
+ };
46
+
47
+ export { modules };
48
+ //# sourceMappingURL=known-modules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"known-modules.js","sources":["../../src/browser/known-modules.ts"],"sourcesContent":["/**\n * We need to import and hang on to these references so that they\n * don't get optimized away during deploy\n */\nimport _GlimmerComponent from '@glimmer/component';\nimport * as _tracking from '@glimmer/tracking';\nimport * as _application from '@ember/application';\nimport * as _array from '@ember/array';\nimport * as _EmberComponent from '@ember/component';\nimport _TO from '@ember/component/template-only';\nimport * as _debug from '@ember/debug';\nimport * as _destroyable from '@ember/destroyable';\nimport * as _helpers from '@ember/helper';\nimport * as _modifier from '@ember/modifier';\nimport * as _object from '@ember/object';\nimport * as _runloop from '@ember/runloop';\nimport * as _service from '@ember/service';\nimport * as _string from '@ember/string';\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { createTemplateFactory } from '@ember/template-factory';\nimport * as _utils from '@ember/utils';\n// import * as _owner from '@ember/owner';\n\nexport const modules = {\n '@ember/application': _application,\n '@ember/array': _array,\n '@ember/component': _EmberComponent,\n '@ember/component/template-only': _TO,\n '@ember/debug': _debug,\n '@ember/destroyable': _destroyable,\n '@ember/helper': _helpers,\n '@ember/modifier': _modifier,\n '@ember/object': _object,\n '@ember/runloop': _runloop,\n '@ember/service': _service,\n '@ember/string': _string,\n '@ember/template-factory': { createTemplateFactory },\n '@ember/utils': _utils,\n // '@ember/owner': _owner,\n\n '@glimmer/component': _GlimmerComponent,\n '@glimmer/tracking': _tracking,\n};\n"],"names":["modules","_application","_array","_EmberComponent","_TO","_debug","_destroyable","_helpers","_modifier","_object","_runloop","_service","_string","createTemplateFactory","_utils","_GlimmerComponent","_tracking"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AAmBA;;AAEO,MAAMA,OAAO,GAAG;AACrB,EAAA,oBAAoB,EAAEC,YAAY;AAClC,EAAA,cAAc,EAAEC,MAAM;AACtB,EAAA,kBAAkB,EAAEC,eAAe;AACnC,EAAA,gCAAgC,EAAEC,GAAG;AACrC,EAAA,cAAc,EAAEC,MAAM;AACtB,EAAA,oBAAoB,EAAEC,YAAY;AAClC,EAAA,eAAe,EAAEC,QAAQ;AACzB,EAAA,iBAAiB,EAAEC,SAAS;AAC5B,EAAA,eAAe,EAAEC,OAAO;AACxB,EAAA,gBAAgB,EAAEC,QAAQ;AAC1B,EAAA,gBAAgB,EAAEC,QAAQ;AAC1B,EAAA,eAAe,EAAEC,OAAO;AACxB,EAAA,yBAAyB,EAAE;AAAEC,IAAAA,qBAAAA;GAAuB;AACpD,EAAA,cAAc,EAAEC,MAAM;AACtB;;AAEA,EAAA,oBAAoB,EAAEC,iBAAiB;AACvC,EAAA,mBAAmB,EAAEC,SAAAA;AACvB;;;;"}
@@ -0,0 +1,17 @@
1
+ import { availablePlugins, availablePresets, transform } from '@babel/standalone';
2
+ import { ComponentLike } from '@glint/template';
3
+ interface CompileResult {
4
+ component?: ComponentLike;
5
+ error?: Error;
6
+ name: string;
7
+ }
8
+ interface Babel {
9
+ availablePlugins: typeof availablePlugins;
10
+ availablePresets: typeof availablePresets;
11
+ transform: typeof transform;
12
+ }
13
+ type Options = {
14
+ skypack?: boolean;
15
+ };
16
+ type ExtraModules = Record<string, unknown>;
17
+ export { CompileResult, Babel, Options, ExtraModules };
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -4,11 +4,16 @@
4
4
  * This can help with cacheing previously compiled components,
5
5
  * and generally allowing a consumer to derive "known references" to user-input
6
6
  */
7
- export declare function nameFor(code: string, prefix?: string): string;
7
+ declare function nameFor(code: string, prefix?: string): string;
8
8
  /**
9
9
  * Returns the text for invoking a component with a given name.
10
10
  * It is assumed the component takes no arguments, as would be the
11
11
  * case in REPLs / Playgrounds for the "root" component.
12
12
  */
13
- export declare function invocationOf(name: string): string;
14
- export declare function invocationName(name: string): string;
13
+ declare function invocationOf(name: string): string;
14
+ /**
15
+ * Core team does not want to support changes to '@ember/string' (v2 addonification, specifically)
16
+ * inflection does not support hyphens
17
+ */
18
+ declare function invocationName(name: string): string;
19
+ export { nameFor, invocationOf, invocationName };
@@ -0,0 +1,46 @@
1
+ import { assert } from '@ember/debug';
2
+ import { pascalCase } from 'change-case';
3
+ import { v5 } from 'uuid';
4
+
5
+ /**
6
+ * a namespace is required for uuid v5
7
+ *
8
+ * it helps generate stable outputs for for any given input.
9
+ */
10
+ const NAMESPACE = '926f034a-f480-4112-a363-321244f4e5de';
11
+ const DEFAULT_PREFIX = 'ember-repl';
12
+
13
+ /**
14
+ * For any given code block, a reasonably stable name can be
15
+ * generated.
16
+ * This can help with cacheing previously compiled components,
17
+ * and generally allowing a consumer to derive "known references" to user-input
18
+ */
19
+ function nameFor(code, prefix = DEFAULT_PREFIX) {
20
+ let id = v5(code, NAMESPACE);
21
+ return `${prefix ? `${prefix}-` : ''}${id}`;
22
+ }
23
+
24
+ /**
25
+ * Returns the text for invoking a component with a given name.
26
+ * It is assumed the component takes no arguments, as would be the
27
+ * case in REPLs / Playgrounds for the "root" component.
28
+ */
29
+ function invocationOf(name) {
30
+ assert(`You must pass a name to invocationOf. Received: \`${name}\``, typeof name === 'string' && name.length > 0);
31
+ if (name.length === 0) {
32
+ throw new Error(`name passed to invocationOf must have non-0 length`);
33
+ }
34
+ return `<${invocationName(name)} />`;
35
+ }
36
+
37
+ /**
38
+ * Core team does not want to support changes to '@ember/string' (v2 addonification, specifically)
39
+ * inflection does not support hyphens
40
+ */
41
+ function invocationName(name) {
42
+ return pascalCase(name).replaceAll('_', '');
43
+ }
44
+
45
+ export { invocationName, invocationOf, nameFor };
46
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sources":["../../src/browser/utils.ts"],"sourcesContent":["import { assert } from '@ember/debug';\n\nimport { pascalCase } from 'change-case';\nimport { v5 as uuidv5 } from 'uuid';\n\n/**\n * a namespace is required for uuid v5\n *\n * it helps generate stable outputs for for any given input.\n */\nconst NAMESPACE = '926f034a-f480-4112-a363-321244f4e5de';\nconst DEFAULT_PREFIX = 'ember-repl';\n\n/**\n * For any given code block, a reasonably stable name can be\n * generated.\n * This can help with cacheing previously compiled components,\n * and generally allowing a consumer to derive \"known references\" to user-input\n */\nexport function nameFor(code: string, prefix = DEFAULT_PREFIX) {\n let id = uuidv5(code, NAMESPACE);\n\n return `${prefix ? `${prefix}-` : ''}${id}`;\n}\n\n/**\n * Returns the text for invoking a component with a given name.\n * It is assumed the component takes no arguments, as would be the\n * case in REPLs / Playgrounds for the \"root\" component.\n */\nexport function invocationOf(name: string) {\n assert(\n `You must pass a name to invocationOf. Received: \\`${name}\\``,\n typeof name === 'string' && name.length > 0\n );\n\n if (name.length === 0) {\n throw new Error(`name passed to invocationOf must have non-0 length`);\n }\n\n return `<${invocationName(name)} />`;\n}\n\n/**\n * Core team does not want to support changes to '@ember/string' (v2 addonification, specifically)\n * inflection does not support hyphens\n */\nexport function invocationName(name: string) {\n return pascalCase(name).replaceAll('_', '');\n}\n"],"names":["NAMESPACE","DEFAULT_PREFIX","nameFor","code","prefix","id","uuidv5","invocationOf","name","assert","length","Error","invocationName","pascalCase","replaceAll"],"mappings":";;;;AAKA;AACA;AACA;AACA;AACA;AACA,MAAMA,SAAS,GAAG,sCAAsC,CAAA;AACxD,MAAMC,cAAc,GAAG,YAAY,CAAA;;AAEnC;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,OAAOA,CAACC,IAAY,EAAEC,MAAM,GAAGH,cAAc,EAAE;AAC7D,EAAA,IAAII,EAAE,GAAGC,EAAM,CAACH,IAAI,EAAEH,SAAS,CAAC,CAAA;EAEhC,OAAQ,CAAA,EAAEI,MAAM,GAAI,CAAEA,EAAAA,MAAO,GAAE,GAAG,EAAG,CAAEC,EAAAA,EAAG,CAAC,CAAA,CAAA;AAC7C,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASE,YAAYA,CAACC,IAAY,EAAE;AACzCC,EAAAA,MAAM,CACH,CAAA,kDAAA,EAAoDD,IAAK,CAAA,EAAA,CAAG,EAC7D,OAAOA,IAAI,KAAK,QAAQ,IAAIA,IAAI,CAACE,MAAM,GAAG,CAC5C,CAAC,CAAA;AAED,EAAA,IAAIF,IAAI,CAACE,MAAM,KAAK,CAAC,EAAE;AACrB,IAAA,MAAM,IAAIC,KAAK,CAAE,CAAA,kDAAA,CAAmD,CAAC,CAAA;AACvE,GAAA;AAEA,EAAA,OAAQ,CAAGC,CAAAA,EAAAA,cAAc,CAACJ,IAAI,CAAE,CAAI,GAAA,CAAA,CAAA;AACtC,CAAA;;AAEA;AACA;AACA;AACA;AACO,SAASI,cAAcA,CAACJ,IAAY,EAAE;EAC3C,OAAOK,UAAU,CAACL,IAAI,CAAC,CAACM,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;AAC7C;;;;"}
@@ -0,0 +1,36 @@
1
+ 'use strict';
2
+
3
+ const { stripIndents } = require('common-tags');
4
+
5
+ /**
6
+ * Builds a file with a single export, COMPONENT_MAP, that
7
+ * is a map of the provided paths *to* all exported identifiers
8
+ * from each of the provided paths.
9
+ *
10
+ * This is helpful for building a map of imports to force to be included
11
+ * in the build - a requirement for builds that tend to tree shake.
12
+ *
13
+ * @param {string[]} paths - list of import paths for each module that you want availableb to the REPL
14
+ */
15
+ module.exports.buildComponentMap = function buildComponentMap(paths) {
16
+ const writeFile = require('broccoli-file-creator');
17
+ const fileContent = stripIndents`
18
+ ${paths
19
+ .map((path, i) => {
20
+ return `import * as ComponentMapPart${i} from '${path}';`;
21
+ })
22
+ .join('\n')}
23
+
24
+ export const COMPONENT_MAP = {
25
+ ${paths
26
+ .map((path, i) => {
27
+ return `'${path}': ComponentMapPart${i},`;
28
+ })
29
+ .join('\n')}
30
+ };
31
+ `;
32
+
33
+ const tree = writeFile('/ember-repl/component-map.js', fileContent);
34
+
35
+ return tree;
36
+ };