ember-repl 5.0.1 → 7.0.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 (147) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +2 -404
  3. package/config/.try.mjs +87 -0
  4. package/config/addon-main.cjs +7 -0
  5. package/config/attw.json +7 -0
  6. package/config/babel.publish.config.cjs +29 -0
  7. package/config/ember-cli-update.json +21 -0
  8. package/config/rollup.config.mjs +44 -0
  9. package/config/testem.cjs +35 -0
  10. package/config/tsconfig.publish.json +18 -0
  11. package/config/vite.config.mjs +36 -0
  12. package/declarations/compile/Compiled.d.ts +7 -0
  13. package/declarations/compile/Compiled.d.ts.map +1 -0
  14. package/declarations/compile/compile.d.ts +17 -0
  15. package/declarations/compile/compile.d.ts.map +1 -0
  16. package/declarations/compile/state.d.ts +43 -0
  17. package/declarations/compile/state.d.ts.map +1 -0
  18. package/declarations/compile/types.d.ts +5 -12
  19. package/declarations/compile/types.d.ts.map +1 -1
  20. package/declarations/index.d.ts +6 -2
  21. package/declarations/index.d.ts.map +1 -1
  22. package/declarations/services/compiler.d.ts +94 -0
  23. package/declarations/services/compiler.d.ts.map +1 -0
  24. package/declarations/services/known-modules.d.ts +7 -0
  25. package/declarations/services/known-modules.d.ts.map +1 -0
  26. package/declarations/setup.d.ts +7 -0
  27. package/declarations/setup.d.ts.map +1 -0
  28. package/declarations/test-support.d.ts +20 -0
  29. package/declarations/test-support.d.ts.map +1 -0
  30. package/dist/_commonjsHelpers-BAGoDD49.js +37 -0
  31. package/dist/_commonjsHelpers-BAGoDD49.js.map +1 -0
  32. package/dist/babel-8wMrbxkT.js +110427 -0
  33. package/dist/babel-8wMrbxkT.js.map +1 -0
  34. package/dist/blank-line-Bzg2Qt4K.js +482 -0
  35. package/dist/blank-line-Bzg2Qt4K.js.map +1 -0
  36. package/dist/compile/Compiled.js +26 -0
  37. package/dist/compile/Compiled.js.map +1 -0
  38. package/dist/compile/compile.js +62 -0
  39. package/dist/compile/compile.js.map +1 -0
  40. package/dist/compile/state.js +75 -0
  41. package/dist/compile/state.js.map +1 -0
  42. package/dist/compile/utils.js +214 -3
  43. package/dist/compile/utils.js.map +1 -1
  44. package/dist/default-CoqAuVeH.js +4 -0
  45. package/dist/default-CoqAuVeH.js.map +1 -0
  46. package/dist/index-BTx1k6gT.js +323 -0
  47. package/dist/index-BTx1k6gT.js.map +1 -0
  48. package/dist/index-Bxzjtr16.js +87 -0
  49. package/dist/index-Bxzjtr16.js.map +1 -0
  50. package/dist/index-C371bO_b.js +1553 -0
  51. package/dist/index-C371bO_b.js.map +1 -0
  52. package/dist/index-C4AyeeIa.js +5721 -0
  53. package/dist/index-C4AyeeIa.js.map +1 -0
  54. package/dist/index-C8S2G0FH.js +1953 -0
  55. package/dist/index-C8S2G0FH.js.map +1 -0
  56. package/dist/index-CCcIVEUK.js +409 -0
  57. package/dist/index-CCcIVEUK.js.map +1 -0
  58. package/dist/index-CDSIcg03.js +9070 -0
  59. package/dist/index-CDSIcg03.js.map +1 -0
  60. package/dist/index-D8szzCn3.js +2 -0
  61. package/dist/index-D8szzCn3.js.map +1 -0
  62. package/dist/index-DBBNT106.js +2644 -0
  63. package/dist/index-DBBNT106.js.map +1 -0
  64. package/dist/index-DP_Su7Zc.js +362 -0
  65. package/dist/index-DP_Su7Zc.js.map +1 -0
  66. package/dist/index-DejgrVqh.js +11299 -0
  67. package/dist/index-DejgrVqh.js.map +1 -0
  68. package/dist/index-Dr5iYoKt.js +1551 -0
  69. package/dist/index-Dr5iYoKt.js.map +1 -0
  70. package/dist/index-DxolpiGq.js +3336 -0
  71. package/dist/index-DxolpiGq.js.map +1 -0
  72. package/dist/index-ZyJlPFQY.js +249 -0
  73. package/dist/index-ZyJlPFQY.js.map +1 -0
  74. package/dist/index-k6CfLgeq.js +26 -0
  75. package/dist/index-k6CfLgeq.js.map +1 -0
  76. package/dist/index.js +4 -1
  77. package/dist/index.js.map +1 -1
  78. package/dist/services/compiler.js +329 -0
  79. package/dist/services/compiler.js.map +1 -0
  80. package/dist/services/known-modules.js +123 -0
  81. package/dist/services/known-modules.js.map +1 -0
  82. package/dist/setup.js +15 -0
  83. package/dist/setup.js.map +1 -0
  84. package/dist/test-support.js +33 -0
  85. package/dist/test-support.js.map +1 -0
  86. package/package.json +118 -147
  87. package/src/compile/Compiled.ts +45 -0
  88. package/src/compile/compile.ts +89 -0
  89. package/src/compile/state.ts +88 -0
  90. package/src/compile/types.ts +14 -13
  91. package/src/compile/utils.ts +1 -1
  92. package/src/index.ts +6 -2
  93. package/src/services/compiler.ts +401 -0
  94. package/src/services/known-modules.ts +130 -0
  95. package/src/setup.ts +26 -0
  96. package/src/test-support.ts +64 -0
  97. package/addon-main.cjs +0 -5
  98. package/declarations/__PRIVATE__.d.ts +0 -2
  99. package/declarations/__PRIVATE__.d.ts.map +0 -1
  100. package/declarations/compile/formats/gjs/babel.d.ts +0 -7
  101. package/declarations/compile/formats/gjs/babel.d.ts.map +0 -1
  102. package/declarations/compile/formats/gjs/eval.d.ts +0 -8
  103. package/declarations/compile/formats/gjs/eval.d.ts.map +0 -1
  104. package/declarations/compile/formats/gjs/index.d.ts +0 -24
  105. package/declarations/compile/formats/gjs/index.d.ts.map +0 -1
  106. package/declarations/compile/formats/gjs/known-modules.d.ts +0 -46
  107. package/declarations/compile/formats/gjs/known-modules.d.ts.map +0 -1
  108. package/declarations/compile/formats/hbs.d.ts +0 -17
  109. package/declarations/compile/formats/hbs.d.ts.map +0 -1
  110. package/declarations/compile/formats/markdown.d.ts +0 -22
  111. package/declarations/compile/formats/markdown.d.ts.map +0 -1
  112. package/declarations/compile/formats.d.ts +0 -18
  113. package/declarations/compile/formats.d.ts.map +0 -1
  114. package/declarations/compile/index.d.ts +0 -81
  115. package/declarations/compile/index.d.ts.map +0 -1
  116. package/declarations/test-support/index.d.ts +0 -2
  117. package/declarations/test-support/index.d.ts.map +0 -1
  118. package/dist/__PRIVATE__.js +0 -2
  119. package/dist/__PRIVATE__.js.map +0 -1
  120. package/dist/compile/formats/gjs/babel.js +0 -2
  121. package/dist/compile/formats/gjs/babel.js.map +0 -1
  122. package/dist/compile/formats/gjs/eval.js +0 -20
  123. package/dist/compile/formats/gjs/eval.js.map +0 -1
  124. package/dist/compile/formats/gjs/index.js +0 -120
  125. package/dist/compile/formats/gjs/index.js.map +0 -1
  126. package/dist/compile/formats/gjs/known-modules.js +0 -50
  127. package/dist/compile/formats/gjs/known-modules.js.map +0 -1
  128. package/dist/compile/formats/hbs.js +0 -94
  129. package/dist/compile/formats/hbs.js.map +0 -1
  130. package/dist/compile/formats/markdown.js +0 -264
  131. package/dist/compile/formats/markdown.js.map +0 -1
  132. package/dist/compile/formats.js +0 -173
  133. package/dist/compile/formats.js.map +0 -1
  134. package/dist/compile/index.js +0 -113
  135. package/dist/compile/index.js.map +0 -1
  136. package/dist/test-support/index.js +0 -8
  137. package/dist/test-support/index.js.map +0 -1
  138. package/src/__PRIVATE__.ts +0 -1
  139. package/src/compile/formats/gjs/babel.ts +0 -7
  140. package/src/compile/formats/gjs/eval.ts +0 -30
  141. package/src/compile/formats/gjs/index.ts +0 -151
  142. package/src/compile/formats/gjs/known-modules.ts +0 -49
  143. package/src/compile/formats/hbs.ts +0 -101
  144. package/src/compile/formats/markdown.ts +0 -344
  145. package/src/compile/formats.ts +0 -179
  146. package/src/compile/index.ts +0 -219
  147. package/src/test-support/index.ts +0 -5
@@ -1,173 +0,0 @@
1
- import { invocationName } from './utils.js';
2
-
3
- async function compileGJSArray(js, importMap) {
4
- let modules = await Promise.all(js.map(async ({
5
- code
6
- }) => {
7
- return await compileGJS(code, importMap);
8
- }));
9
- return modules;
10
- }
11
- async function compileGJS(gjsInput, importMap) {
12
- try {
13
- let {
14
- compileJS
15
- } = await import('./formats/gjs/index.js');
16
- return await compileJS(gjsInput, importMap);
17
- } catch (error) {
18
- return {
19
- error: error,
20
- name: 'unknown'
21
- };
22
- }
23
- }
24
- async function compileHBS(hbsInput, options) {
25
- try {
26
- let {
27
- compileHBS
28
- } = await import('./formats/hbs.js');
29
- return compileHBS(hbsInput, options);
30
- } catch (error) {
31
- return {
32
- error: error,
33
- name: 'unknown'
34
- };
35
- }
36
- }
37
- async function extractScope(liveCode, options) {
38
- let scope = [];
39
- let hbs = liveCode.filter(code => code.lang === 'hbs');
40
- let js = liveCode.filter(code => ['js', 'gjs'].includes(code.lang));
41
- if (js.length > 0) {
42
- let compiled = await compileGJSArray(js, options?.importMap);
43
- await Promise.all(compiled.map(async info => {
44
- // using web worker + import maps is not available yet (need firefox support)
45
- // (and to somehow be able to point at npm)
46
- //
47
- // if ('importPath' in info) {
48
- // return scope.push({
49
- // moduleName: name,
50
- // component: await import(/* webpackIgnore: true */ info.importPath),
51
- // });
52
- // }
53
-
54
- return scope.push(info);
55
- }));
56
- }
57
- for (let {
58
- code
59
- } of hbs) {
60
- let compiled = await compileHBS(code, {
61
- scope: options?.topLevelScope
62
- });
63
- scope.push(compiled);
64
- }
65
- return scope;
66
- }
67
- async function compileMD(glimdownInput, options) {
68
- let topLevelScope = options?.topLevelScope ?? {};
69
- let rootTemplate;
70
- let liveCode;
71
- let scope = [];
72
-
73
- /**
74
- * Step 1: Convert Markdown To HTML (Ember).
75
- *
76
- * The remark plugin, remark-code-extra also extracts
77
- * and transforms the code blocks we care about.
78
- *
79
- * These blocks will be compiled through babel and eval'd so the
80
- * compiled rootTemplate can invoke them
81
- */
82
- try {
83
- let {
84
- parseMarkdown
85
- } = await import('./formats/markdown.js');
86
- let {
87
- templateOnlyGlimdown,
88
- blocks
89
- } = await parseMarkdown(glimdownInput, {
90
- CopyComponent: options?.CopyComponent,
91
- ShadowComponent: options?.ShadowComponent,
92
- remarkPlugins: options?.remarkPlugins,
93
- rehypePlugins: options?.rehypePlugins
94
- });
95
- rootTemplate = templateOnlyGlimdown;
96
- liveCode = blocks;
97
- } catch (error) {
98
- return {
99
- error: error,
100
- name: 'unknown'
101
- };
102
- }
103
-
104
- /**
105
- * Step 2: Compile the live code samples
106
- */
107
- if (liveCode.length > 0) {
108
- try {
109
- scope = await extractScope(liveCode, options);
110
- } catch (error) {
111
- console.info({
112
- scope
113
- });
114
- console.error(error);
115
- return {
116
- error: error,
117
- rootTemplate,
118
- name: 'unknown'
119
- };
120
- }
121
- }
122
-
123
- /**
124
- * Make sure non of our snippets errored
125
- *
126
- * TODO: for these errors, report them differently so that we
127
- * can render the 'Ember' and still highlight the correct line?
128
- * or maybe there is a way to highlight in the editor instead?
129
- */
130
- for (let {
131
- error,
132
- component
133
- } of scope) {
134
- if (!component) {
135
- if (error) {
136
- return {
137
- error,
138
- rootTemplate,
139
- name: 'unknown'
140
- };
141
- }
142
- }
143
- }
144
-
145
- /**
146
- * Step 4: Compile the Ember Template
147
- */
148
- try {
149
- let localScope = scope.reduce((accum, {
150
- component,
151
- name
152
- }) => {
153
- accum[invocationName(name)] = component;
154
- return accum;
155
- }, {});
156
- return await compileHBS(rootTemplate, {
157
- moduleName: 'DynamicRootTemplate',
158
- scope: {
159
- ...topLevelScope,
160
- ...localScope
161
- }
162
- });
163
- } catch (error) {
164
- return {
165
- error: error,
166
- rootTemplate,
167
- name: 'unknown'
168
- };
169
- }
170
- }
171
-
172
- export { compileGJS, compileHBS, compileMD };
173
- //# sourceMappingURL=formats.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"formats.js","sources":["../../src/compile/formats.ts"],"sourcesContent":["import { invocationName } from './utils.ts';\n\nimport type { ExtractedCode } from './formats/markdown.ts';\nimport type { CompileResult, UnifiedPlugin } from './types.ts';\nimport type { EvalImportMap, ScopeMap } from './types.ts';\n\nasync function compileGJSArray(js: { code: string }[], importMap?: EvalImportMap) {\n let modules = await Promise.all(\n js.map(async ({ code }) => {\n return await compileGJS(code, importMap);\n })\n );\n\n return modules;\n}\n\nexport async function compileGJS(\n gjsInput: string,\n importMap?: EvalImportMap\n): Promise<CompileResult> {\n try {\n let { compileJS } = await import('./formats/gjs/index.ts');\n\n return await compileJS(gjsInput, importMap);\n } catch (error) {\n return { error: error as Error, name: 'unknown' };\n }\n}\n\nexport async function compileHBS(\n hbsInput: string,\n options?: {\n moduleName?: string;\n scope?: Record<string, unknown>;\n }\n): Promise<CompileResult> {\n try {\n let { compileHBS } = await import('./formats/hbs.ts');\n\n return compileHBS(hbsInput, options);\n } catch (error) {\n return { error: error as Error, name: 'unknown' };\n }\n}\n\nasync function extractScope(\n liveCode: ExtractedCode[],\n options?: {\n importMap?: EvalImportMap;\n topLevelScope?: ScopeMap;\n }\n): Promise<CompileResult[]> {\n let scope: CompileResult[] = [];\n\n let hbs = liveCode.filter((code) => code.lang === 'hbs');\n let js = liveCode.filter((code) => ['js', 'gjs'].includes(code.lang));\n\n if (js.length > 0) {\n let compiled = await compileGJSArray(js, options?.importMap);\n\n await Promise.all(\n compiled.map(async (info) => {\n // using web worker + import maps is not available yet (need firefox support)\n // (and to somehow be able to point at npm)\n //\n // if ('importPath' in info) {\n // return scope.push({\n // moduleName: name,\n // component: await import(/* webpackIgnore: true */ info.importPath),\n // });\n // }\n\n return scope.push(info);\n })\n );\n }\n\n for (let { code } of hbs) {\n let compiled = await compileHBS(code, { scope: options?.topLevelScope });\n\n scope.push(compiled);\n }\n\n return scope;\n}\n\nexport async function compileMD(\n glimdownInput: string,\n options?: {\n importMap?: EvalImportMap;\n topLevelScope?: ScopeMap;\n remarkPlugins?: UnifiedPlugin[];\n rehypePlugins?: UnifiedPlugin[];\n CopyComponent?: string;\n ShadowComponent?: string;\n }\n): Promise<CompileResult & { rootTemplate?: string }> {\n let topLevelScope = options?.topLevelScope ?? {};\n let rootTemplate: string;\n let liveCode: ExtractedCode[];\n let scope: CompileResult[] = [];\n\n /**\n * Step 1: Convert Markdown To HTML (Ember).\n *\n * The remark plugin, remark-code-extra also extracts\n * and transforms the code blocks we care about.\n *\n * These blocks will be compiled through babel and eval'd so the\n * compiled rootTemplate can invoke them\n */\n try {\n let { parseMarkdown } = await import('./formats/markdown.ts');\n let { templateOnlyGlimdown, blocks } = await parseMarkdown(glimdownInput, {\n CopyComponent: options?.CopyComponent,\n ShadowComponent: options?.ShadowComponent,\n remarkPlugins: options?.remarkPlugins,\n rehypePlugins: options?.rehypePlugins,\n });\n\n rootTemplate = templateOnlyGlimdown;\n liveCode = blocks;\n } catch (error) {\n return { error: error as Error, name: 'unknown' };\n }\n\n /**\n * Step 2: Compile the live code samples\n */\n if (liveCode.length > 0) {\n try {\n scope = await extractScope(liveCode, options);\n } catch (error) {\n console.info({ scope });\n console.error(error);\n\n return { error: error as Error, rootTemplate, name: 'unknown' };\n }\n }\n\n /**\n * Make sure non of our snippets errored\n *\n * TODO: for these errors, report them differently so that we\n * can render the 'Ember' and still highlight the correct line?\n * or maybe there is a way to highlight in the editor instead?\n */\n for (let { error, component } of scope) {\n if (!component) {\n if (error) {\n return { error, rootTemplate, name: 'unknown' };\n }\n }\n }\n\n /**\n * Step 4: Compile the Ember Template\n */\n try {\n let localScope = scope.reduce(\n (accum, { component, name }) => {\n accum[invocationName(name)] = component;\n\n return accum;\n },\n {} as Record<string, unknown>\n );\n\n return await compileHBS(rootTemplate, {\n moduleName: 'DynamicRootTemplate',\n scope: {\n ...topLevelScope,\n ...localScope,\n },\n });\n } catch (error) {\n return { error: error as Error, rootTemplate, name: 'unknown' };\n }\n}\n"],"names":["compileGJSArray","js","importMap","modules","Promise","all","map","code","compileGJS","gjsInput","compileJS","error","name","compileHBS","hbsInput","options","extractScope","liveCode","scope","hbs","filter","lang","includes","length","compiled","info","push","topLevelScope","compileMD","glimdownInput","rootTemplate","parseMarkdown","templateOnlyGlimdown","blocks","CopyComponent","ShadowComponent","remarkPlugins","rehypePlugins","console","component","localScope","reduce","accum","invocationName","moduleName"],"mappings":";;AAMA,eAAeA,eAAeA,CAACC,EAAsB,EAAEC,SAAyB,EAAE;EAChF,IAAIC,OAAO,GAAG,MAAMC,OAAO,CAACC,GAAG,CAC7BJ,EAAE,CAACK,GAAG,CAAC,OAAO;AAAEC,IAAAA;AAAK,GAAC,KAAK;AAC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AAEA,KAAc;MAAEmB,YAAY;AAAElB,MAAAA,IAAI,EAAE;KAAW;AACjE;AACF;;;;"}
@@ -1,113 +0,0 @@
1
- import { resourceFactory, resource, cell } from 'ember-resources';
2
- import { compileMD, compileGJS, compileHBS } from './formats.js';
3
- import { nameFor } from './utils.js';
4
-
5
- const CACHE = new Map();
6
- const SUPPORTED_FORMATS = ['glimdown', 'gjs', 'hbs'];
7
-
8
- /**
9
- * Compile GitHub-flavored Markdown with GJS support
10
- * and optionally render gjs-snippets via a `live` meta tag
11
- * on the code fences.
12
- */
13
-
14
- /**
15
- * Compile GJS
16
- */
17
-
18
- /**
19
- * Compile a stateless component using just the template
20
- */
21
-
22
- /**
23
- * This compileMD is a more robust version of the raw compiling used in "formats".
24
- * This function manages cache, and has events for folks building UIs to hook in to
25
- */
26
- async function compile(text, options) {
27
- let {
28
- onSuccess,
29
- onError,
30
- onCompileStart
31
- } = options;
32
- let id = nameFor(`${options.format}:${text}`);
33
- let existing = CACHE.get(id);
34
- if (existing) {
35
- onSuccess(existing);
36
- return;
37
- }
38
- if (!SUPPORTED_FORMATS.includes(options.format)) {
39
- await onError(`Unsupported format: ${options.format}. Supported formats: ${SUPPORTED_FORMATS}`);
40
- return;
41
- }
42
- await onCompileStart();
43
- if (!text) {
44
- await onError('No Input Document yet');
45
- return;
46
- }
47
- let result;
48
- if (options.format === 'glimdown') {
49
- result = await compileMD(text, options);
50
- } else if (options.format === 'gjs') {
51
- result = await compileGJS(text, options.importMap);
52
- } else if (options.format === 'hbs') {
53
- result = await compileHBS(text, {
54
- scope: options.topLevelScope
55
- });
56
- } else {
57
- await onError(`Unsupported format: ${options.format}. Supported formats: ${SUPPORTED_FORMATS}`);
58
- return;
59
- }
60
- if (result.error) {
61
- await onError(result.error.message || `${result.error}`);
62
- return;
63
- }
64
- CACHE.set(id, result.component);
65
- await onSuccess(result.component);
66
- }
67
-
68
- /**
69
- * @internal
70
- */
71
-
72
- /**
73
- * By default, this compiles to `glimdown`. A Markdown format which
74
- * extracts `live` tagged code snippets and compiles them to components.
75
- */
76
- function Compiled(markdownText, maybeOptions) {
77
- return resource(() => {
78
- let maybeObject = typeof maybeOptions === 'function' ? maybeOptions() : maybeOptions;
79
- let format = (typeof maybeObject === 'string' ? maybeObject : maybeObject?.format) || 'glimdown';
80
- let options = (typeof maybeObject === 'string' ? {} : maybeObject) || {};
81
- let input = typeof markdownText === 'function' ? markdownText() : markdownText;
82
- let ready = cell(false);
83
- let error = cell();
84
- let result = cell();
85
- if (input) {
86
- compile(input, {
87
- // narrowing is hard here, but this is an implementation detail
88
- format: format,
89
- onSuccess: async component => {
90
- result.current = component;
91
- ready.set(true);
92
- error.set(null);
93
- },
94
- onError: async e => {
95
- error.set(e);
96
- },
97
- onCompileStart: async () => {
98
- ready.set(false);
99
- },
100
- ...options
101
- });
102
- }
103
- return () => ({
104
- isReady: ready.current,
105
- error: error.current,
106
- component: result.current
107
- });
108
- });
109
- }
110
- resourceFactory(Compiled);
111
-
112
- export { CACHE, Compiled, compile };
113
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../../src/compile/index.ts"],"sourcesContent":["import { cell, resource, resourceFactory } from 'ember-resources';\n\nimport {\n compileGJS as processGJS,\n compileHBS as processHBS,\n compileMD as processMD,\n} from './formats.ts';\nimport { nameFor } from './utils.ts';\n\nimport type { CompileResult, UnifiedPlugin } from './types.ts';\nimport type { EvalImportMap, ScopeMap } from './types.ts';\nimport type { ComponentLike } from '@glint/template';\ntype Format = 'glimdown' | 'gjs' | 'hbs';\n\nexport const CACHE = new Map<string, ComponentLike>();\n\ninterface Events {\n onSuccess: (component: ComponentLike) => Promise<unknown> | unknown;\n onError: (error: string) => Promise<unknown> | unknown;\n onCompileStart: () => Promise<unknown> | unknown;\n}\n\ninterface Scope {\n importMap?: EvalImportMap;\n}\n\nconst SUPPORTED_FORMATS = ['glimdown', 'gjs', 'hbs'];\n\ninterface GlimdownOptions extends Scope, Events {\n format: 'glimdown';\n remarkPlugins?: UnifiedPlugin[];\n rehypePlugins?: UnifiedPlugin[];\n CopyComponent?: string;\n ShadowComponent?: string;\n topLevelScope?: ScopeMap;\n}\ninterface GJSOptions extends Scope, Events {\n format: 'gjs';\n\n // Make overloads easier?\n remarkPlugins?: never;\n rehypePlugins?: never;\n CopyComponent?: never;\n ShadowComponent?: never;\n}\n\ninterface HBSOptions extends Scope, Events {\n format: 'hbs';\n topLevelScope?: ScopeMap;\n\n // Make overloads easier?\n remarkPlugins?: never;\n rehypePlugins?: never;\n CopyComponent?: never;\n ShadowComponent?: never;\n}\n\n/**\n * Compile GitHub-flavored Markdown with GJS support\n * and optionally render gjs-snippets via a `live` meta tag\n * on the code fences.\n */\nexport async function compile(text: string, options: GlimdownOptions): Promise<void>;\n\n/**\n * Compile GJS\n */\nexport async function compile(text: string, options: GJSOptions): Promise<void>;\n\n/**\n * Compile a stateless component using just the template\n */\nexport async function compile(text: string, options: HBSOptions): Promise<void>;\n\n/**\n * This compileMD is a more robust version of the raw compiling used in \"formats\".\n * This function manages cache, and has events for folks building UIs to hook in to\n */\nexport async function compile(\n text: string,\n options: GlimdownOptions | GJSOptions | HBSOptions\n): Promise<void> {\n let { onSuccess, onError, onCompileStart } = options;\n let id = nameFor(`${options.format}:${text}`);\n\n let existing = CACHE.get(id);\n\n if (existing) {\n onSuccess(existing);\n\n return;\n }\n\n if (!SUPPORTED_FORMATS.includes(options.format)) {\n await onError(`Unsupported format: ${options.format}. Supported formats: ${SUPPORTED_FORMATS}`);\n\n return;\n }\n\n await onCompileStart();\n\n if (!text) {\n await onError('No Input Document yet');\n\n return;\n }\n\n let result: CompileResult;\n\n if (options.format === 'glimdown') {\n result = await processMD(text, options);\n } else if (options.format === 'gjs') {\n result = await processGJS(text, options.importMap);\n } else if (options.format === 'hbs') {\n result = await processHBS(text, {\n scope: options.topLevelScope,\n });\n } else {\n await onError(\n `Unsupported format: ${(options as any).format}. Supported formats: ${SUPPORTED_FORMATS}`\n );\n\n return;\n }\n\n if (result.error) {\n await onError(result.error.message || `${result.error}`);\n\n return;\n }\n\n CACHE.set(id, result.component as ComponentLike);\n\n await onSuccess(result.component as ComponentLike);\n}\n\ntype Input = string | undefined | null;\n\ntype ExtraOptions =\n | {\n format: 'glimdown';\n remarkPlugins?: UnifiedPlugin[];\n rehypePlugins?: UnifiedPlugin[];\n importMap?: EvalImportMap;\n CopyComponent?: string;\n ShadowComponent?: string;\n topLevelScope?: ScopeMap;\n }\n | {\n format: 'hbs';\n topLevelScope?: ScopeMap;\n }\n | {\n format: 'gjs';\n importMap?: EvalImportMap;\n };\n\n/**\n * @internal\n */\nexport interface Value {\n isReady: boolean;\n error: string | null;\n component: ComponentLike;\n}\n\nexport function Compiled(markdownText: Input | (() => Input)): Value;\nexport function Compiled(markdownText: Input | (() => Input), options?: Format): Value;\nexport function Compiled(markdownText: Input | (() => Input), options?: () => Format): Value;\nexport function Compiled(markdownText: Input | (() => Input), options?: ExtraOptions): Value;\nexport function Compiled(markdownText: Input | (() => Input), options?: () => ExtraOptions): Value;\n\n/**\n * By default, this compiles to `glimdown`. A Markdown format which\n * extracts `live` tagged code snippets and compiles them to components.\n */\nexport function Compiled(\n markdownText: Input | (() => Input),\n maybeOptions?: Format | (() => Format) | ExtraOptions | (() => ExtraOptions)\n): Value {\n return resource(() => {\n let maybeObject = typeof maybeOptions === 'function' ? maybeOptions() : maybeOptions;\n let format =\n (typeof maybeObject === 'string' ? maybeObject : maybeObject?.format) || 'glimdown';\n let options = (typeof maybeObject === 'string' ? {} : maybeObject) || {};\n\n let input = typeof markdownText === 'function' ? markdownText() : markdownText;\n let ready = cell(false);\n let error = cell<string | null>();\n let result = cell<ComponentLike>();\n\n if (input) {\n compile(input, {\n // narrowing is hard here, but this is an implementation detail\n format: format as any,\n onSuccess: async (component) => {\n result.current = component;\n ready.set(true);\n error.set(null);\n },\n onError: async (e) => {\n error.set(e);\n },\n onCompileStart: async () => {\n ready.set(false);\n },\n ...options,\n });\n }\n\n return () => ({\n isReady: ready.current,\n error: error.current,\n component: result.current,\n });\n });\n}\n\nresourceFactory(Compiled);\n"],"names":["CACHE","Map","SUPPORTED_FORMATS","compile","text","options","onSuccess","onError","onCompileStart","id","nameFor","format","existing","get","includes","result","processMD","processGJS","importMap","processHBS","scope","topLevelScope","error","message","set","component","Compiled","markdownText","maybeOptions","resource","maybeObject","input","ready","cell","current","e","isReady","resourceFactory"],"mappings":";;;;MAcaA,KAAK,GAAG,IAAIC,GAAG;AAY5B,MAAMC,iBAAiB,GAAG,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,CAAC;;AA+BpD;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACO,eAAeC,OAAOA,CAC3BC,IAAY,EACZC,OAAkD,EACnC;EACf,IAAI;IAAEC,SAAS;IAAEC,OAAO;AAAEC,IAAAA;AAAe,GAAC,GAAGH,OAAO;EACpD,IAAII,EAAE,GAAGC,OAAO,CAAC,CAAA,EAAGL,OAAO,CAACM,MAAM,CAAA,CAAA,EAAIP,IAAI,CAAA,CAAE,CAAC;AAE7C,EAAA,IAAIQ,QAAQ,GAAGZ,KAAK,CAACa,GAAG,CAACJ,EAAE,CAAC;AAE5B,EAAA,IAAIG,QAAQ,EAAE;IACZN,SAAS,CAACM,QAAQ,CAAC;AAEnB,IAAA;AACF;EAEA,IAAI,CAACV,iBAAiB,CAACY,QAAQ,CAACT,OAAO,CAACM,MAAM,CAAC,EAAE;IAC/C,MAAMJ,OAAO,CAAC,CAAuBF,oBAAAA,EAAAA,OAAO,CAACM,MAAM,CAAA,qBAAA,EAAwBT,iBAAiB,CAAA,CAAE,CAAC;AAE/F,IAAA;AACF;EAEA,MAAMM,cAAc,EAAE;EAEtB,IAAI,CAACJ,IAAI,EAAE;IACT,MAAMG,OAAO,CAAC,uBAAuB,CAAC;AAEtC,IAAA;AACF;AAEA,EAAA,IAAIQ,MAAqB;AAEzB,EAAA,IAAIV,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AAOyB,WAAW,KAAK,QAAQ,GAAG,EAAE,GAAGA,WAAW,KAAK,EAAE;IAExE,IAAIC,KAAK,GAAG,OAAOJ,YAAY,KAAK,UAAU,GAAGA,YAAY,EAAE,GAAGA,YAAY;AAC9E,IAAA,IAAIK,KAAK,GAAGC,IAAI,CAAC,KAAK,CAAC;AACvB,IAAA,IAAIX,KAAK,GAAGW,IAAI,EAAiB;AACjC,IAAA,IAAIlB,MAAM,GAAGkB,IAAI,EAAiB;AAElC,IAAA,IAAIF,KAAK,EAAE;MACT5B,OAAO,CAAC4B,KAAK,EAAE;AACb;AACApB,QAAAA,MAAM,EAAEA,MAAa;QACrBL,SAAS,EAAE,MAAOmB,SAAS,IAAK;UAC9BV,MAAM,CAACmB,OAAO,GAAGT,SAAS;AAC1BO,UAAAA,KAAK,CAACR,GAAG,CAAC,IAAI,CAAC;AACfF,UAAAA,KAAK,CAACE,GAAG,CAAC,IAAI,CAAC;SAChB;QACDjB,OAAO,EAAE,MAAO4B,CAAC,IAAK;AACpBb,UAAAA,KAAK,CAACE,GAAG,CAACW,CAAC,CAAC;SACb;QACD3B,cAAc,EAAE,YAAY;AAC1BwB,UAAAA,KAAK,CAACR,GAAG,CAAC,KAAK,CAAC;SACjB;QACD,GAAGnB;AACL,OAAC,CAAC;AACJ;AAEA,IAAA,OAAO,OAAO;MACZ+B,OAAO,EAAEJ,KAAK,CAACE,OAAO;MACtBZ,KAAK,EAAEA,KAAK,CAACY,OAAO;MACpBT,SAAS,EAAEV,MAAM,CAACmB;AACpB,KAAC,CAAC;AACJ,GAAC,CAAC;AACJ;AAEAG,eAAe,CAACX,QAAQ,CAAC;;;;"}
@@ -1,8 +0,0 @@
1
- import { CACHE } from '../compile/index.js';
2
-
3
- function clearCompileCache() {
4
- CACHE.clear();
5
- }
6
-
7
- export { clearCompileCache };
8
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../../src/test-support/index.ts"],"sourcesContent":["import { CACHE } from '../compile/index.ts';\n\nexport function clearCompileCache() {\n CACHE.clear();\n}\n"],"names":["clearCompileCache","CACHE","clear"],"mappings":";;AAEO,SAASA,iBAAiBA,GAAG;EAClCC,KAAK,CAACC,KAAK,EAAE;AACf;;;;"}
@@ -1 +0,0 @@
1
- export { CACHE } from './compile/index.ts';
@@ -1,7 +0,0 @@
1
- import type { availablePlugins, availablePresets, transform } from '@babel/standalone';
2
-
3
- export interface Babel {
4
- availablePlugins: typeof availablePlugins;
5
- availablePresets: typeof availablePresets;
6
- transform: typeof transform;
7
- }
@@ -1,30 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unused-vars */
2
- import { modules } from './known-modules.ts';
3
-
4
- import type Component from '@glimmer/component';
5
-
6
- export function evalSnippet(
7
- compiled: string,
8
- extraModules: Record<string, unknown /* imported module */> = {}
9
- ): {
10
- default: Component;
11
- services?: { [key: string]: unknown };
12
- } {
13
- const exports = {};
14
-
15
- function require(moduleName: keyof typeof modules): unknown {
16
- let preConfigured = modules[moduleName] || extraModules[moduleName];
17
-
18
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
19
- // @ts-ignore
20
- return preConfigured || window.require(moduleName);
21
- }
22
-
23
- eval(compiled);
24
-
25
- return Object.assign(exports, { require }) as {
26
- default: Component;
27
- services?: { [key: string]: unknown };
28
- require: unknown;
29
- };
30
- }
@@ -1,151 +0,0 @@
1
- import * as compiler from 'ember-template-compiler';
2
-
3
- import { nameFor } from '../../utils.ts';
4
- import { evalSnippet } from './eval.ts';
5
-
6
- import type { CompileResult } from '../../types.ts';
7
- import type { ComponentLike } from '@glint/template';
8
-
9
- export interface Info {
10
- code: string;
11
- name: string;
12
- }
13
-
14
- /**
15
- * @public
16
- * Transpiles GlimmerJS (*.gjs) formatted text into and evaluates as a JS Module.
17
- * The returned component can be invoked explicitly in the consuming project.
18
- *
19
- * SEE: README for example usage
20
- *
21
- * @param {string} code: the code to be compiled
22
- * @param {Object} extraModules: map of import paths to modules. This isn't needed
23
- * for classic ember projects, but for strict static ember projects, extraModules
24
- * will need to be pasesd if compileJS is intended to be used in a styleguide or
25
- * if there are additional modules that could be imported in the passed `code`.
26
- *
27
- * Later on, imports that are not present by default (ember/glimmer) or that
28
- * are not provided by extraModules will be searched on npm to see if a package
29
- * needs to be downloaded before running the `code` / invoking the component
30
- */
31
- export async function compileJS(
32
- code: string,
33
- extraModules?: Record<string, unknown>
34
- ): Promise<CompileResult> {
35
- let name = nameFor(code);
36
- let component: undefined | ComponentLike;
37
- let error: undefined | Error;
38
-
39
- try {
40
- let compiled = await transpile({ code: code, name });
41
-
42
- if (!compiled) {
43
- throw new Error(`Compiled output is missing`);
44
- }
45
-
46
- component = evalSnippet(compiled, extraModules).default as unknown as ComponentLike;
47
- } catch (e) {
48
- error = e as Error | undefined;
49
- }
50
-
51
- return { name, component, error };
52
- }
53
-
54
- async function transpile({ code: input, name }: Info) {
55
- let preprocessed = await preprocess(input, name);
56
- let result = await transform(preprocessed, name);
57
-
58
- if (!result) {
59
- return;
60
- }
61
-
62
- let { code } = result;
63
-
64
- return code;
65
- }
66
-
67
- import type { Babel } from './babel.ts';
68
-
69
- let processor: any;
70
- let fetchingPromise: Promise<any>;
71
-
72
- async function preprocess(input: string, name: string): Promise<string> {
73
- if (!fetchingPromise) {
74
- fetchingPromise = import('content-tag');
75
- }
76
-
77
- if (!processor) {
78
- let { Preprocessor } = await fetchingPromise;
79
-
80
- processor = new Preprocessor();
81
- }
82
-
83
- let { code /* map */ } = processor.process(input, {
84
- filename: `${name}.js`,
85
- inline_source_map: true,
86
- });
87
-
88
- return code;
89
- }
90
-
91
- async function transform(
92
- intermediate: string,
93
- name: string
94
- ): Promise<ReturnType<Babel['transform']>> {
95
- const [
96
- // _parser, _traverse, _generator,
97
- _decoratorTransforms,
98
- _emberTemplateCompilation,
99
- ] = await Promise.all([
100
- // @babel/* doesn't have the greatest ESM compat yet
101
- // https://github.com/babel/babel/issues/14314#issuecomment-1054505190
102
- //
103
- // babel-standalone is so easy...
104
- // import('@babel/parser'),
105
- // import('@babel/traverse'),
106
- // import('@babel/generator'),
107
- import('decorator-transforms'),
108
- import('babel-plugin-ember-template-compilation'),
109
- ]);
110
-
111
- // These libraries are compiled incorrectly for cjs<->ESM compat
112
- const decoratorTransforms =
113
- 'default' in _decoratorTransforms ? _decoratorTransforms.default : _decoratorTransforms;
114
-
115
- const emberTemplateCompilation =
116
- 'default' in _emberTemplateCompilation
117
- ? _emberTemplateCompilation.default
118
- : _emberTemplateCompilation;
119
-
120
- // so we have to use the default export (which is all the exports)
121
- let maybeBabel = (await import('@babel/standalone')) as any;
122
- // Handle difference between vite and webpack in consuming projects...
123
- let babel: Babel = 'availablePlugins' in maybeBabel ? maybeBabel : maybeBabel.default;
124
-
125
- return babel.transform(intermediate, {
126
- filename: `${name}.js`,
127
- plugins: [
128
- [
129
- emberTemplateCompilation,
130
- {
131
- compiler,
132
- },
133
- ],
134
- [
135
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
136
- // @ts-ignore - we don't care about types here..
137
- decoratorTransforms,
138
- {
139
- runtime: {
140
- import: 'decorator-transforms/runtime',
141
- },
142
- },
143
- ],
144
- // Womp.
145
- // See this exploration into true ESM:
146
- // https://github.com/NullVoxPopuli/limber/pull/1805
147
- [babel.availablePlugins['transform-modules-commonjs']],
148
- ],
149
- presets: [],
150
- });
151
- }
@@ -1,49 +0,0 @@
1
- /**
2
- * We need to import and hang on to these references so that they
3
- * don't get optimized away during deploy
4
- */
5
- import _GlimmerComponent from '@glimmer/component';
6
- import * as _tracking from '@glimmer/tracking';
7
- import * as _application from '@ember/application';
8
- import * as _array from '@ember/array';
9
- import * as _EmberComponent from '@ember/component';
10
- import * as _EmberComponentHelper from '@ember/component/helper';
11
- import _TO from '@ember/component/template-only';
12
- import * as _debug from '@ember/debug';
13
- import * as _destroyable from '@ember/destroyable';
14
- import * as _helpers from '@ember/helper';
15
- import * as _modifier from '@ember/modifier';
16
- import * as _object from '@ember/object';
17
- import * as _owner from '@ember/owner';
18
- import * as _runloop from '@ember/runloop';
19
- import * as _service from '@ember/service';
20
- import * as _template from '@ember/template';
21
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
22
- // @ts-ignore
23
- import { createTemplateFactory } from '@ember/template-factory';
24
- import * as _utils from '@ember/utils';
25
-
26
- import * as _decoratorsRuntime from 'decorator-transforms/runtime';
27
-
28
- export const modules = {
29
- '@ember/application': _application,
30
- '@ember/array': _array,
31
- '@ember/component': _EmberComponent,
32
- '@ember/component/helper': _EmberComponentHelper,
33
- '@ember/component/template-only': _TO,
34
- '@ember/debug': _debug,
35
- '@ember/destroyable': _destroyable,
36
- '@ember/helper': _helpers,
37
- '@ember/modifier': _modifier,
38
- '@ember/object': _object,
39
- '@ember/runloop': _runloop,
40
- '@ember/service': _service,
41
- '@ember/template-factory': { createTemplateFactory },
42
- '@ember/utils': _utils,
43
- '@ember/template': _template,
44
- '@ember/owner': _owner,
45
-
46
- '@glimmer/component': _GlimmerComponent,
47
- '@glimmer/tracking': _tracking,
48
- 'decorator-transforms/runtime': _decoratorsRuntime,
49
- };