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

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 (99) hide show
  1. package/declarations/browser/__PRIVATE__.d.ts +2 -0
  2. package/declarations/browser/__PRIVATE__.d.ts.map +1 -0
  3. package/declarations/browser/cjs/eval.d.ts +9 -0
  4. package/declarations/browser/cjs/eval.d.ts.map +1 -0
  5. package/declarations/browser/cjs/index.d.ts +7 -0
  6. package/declarations/browser/cjs/index.d.ts.map +1 -0
  7. package/declarations/browser/compile/formats.d.ts +18 -0
  8. package/declarations/browser/compile/formats.d.ts.map +1 -0
  9. package/declarations/browser/compile/index.d.ts +76 -0
  10. package/declarations/browser/compile/index.d.ts.map +1 -0
  11. package/declarations/browser/compile/markdown-to-ember.d.ts +21 -0
  12. package/declarations/browser/compile/markdown-to-ember.d.ts.map +1 -0
  13. package/declarations/browser/compile/types.d.ts +9 -0
  14. package/declarations/browser/compile/types.d.ts.map +1 -0
  15. package/declarations/browser/esm/index.d.ts +8 -0
  16. package/declarations/browser/esm/index.d.ts.map +1 -0
  17. package/{dist → declarations}/browser/eti/babel-plugin.d.ts +2 -2
  18. package/declarations/browser/eti/babel-plugin.d.ts.map +1 -0
  19. package/declarations/browser/eti/debug.d.ts +2 -0
  20. package/declarations/browser/eti/debug.d.ts.map +1 -0
  21. package/{dist → declarations}/browser/eti/parse-templates.d.ts +7 -7
  22. package/declarations/browser/eti/parse-templates.d.ts.map +1 -0
  23. package/{dist → declarations}/browser/eti/preprocess.d.ts +3 -2
  24. package/declarations/browser/eti/preprocess.d.ts.map +1 -0
  25. package/{dist → declarations}/browser/eti/template-tag-transform.d.ts +2 -2
  26. package/declarations/browser/eti/template-tag-transform.d.ts.map +1 -0
  27. package/declarations/browser/eti/util.d.ts +14 -0
  28. package/declarations/browser/eti/util.d.ts.map +1 -0
  29. package/declarations/browser/gjs.d.ts +4 -0
  30. package/declarations/browser/gjs.d.ts.map +1 -0
  31. package/{dist → declarations}/browser/hbs.d.ts +4 -3
  32. package/declarations/browser/hbs.d.ts.map +1 -0
  33. package/declarations/browser/index.d.ts +7 -0
  34. package/declarations/browser/index.d.ts.map +1 -0
  35. package/{dist → declarations}/browser/js.d.ts +3 -3
  36. package/declarations/browser/js.d.ts.map +1 -0
  37. package/{dist → declarations}/browser/known-modules.d.ts +6 -5
  38. package/declarations/browser/known-modules.d.ts.map +1 -0
  39. package/declarations/browser/types.d.ts +21 -0
  40. package/declarations/browser/types.d.ts.map +1 -0
  41. package/{dist → declarations}/browser/utils.d.ts +4 -4
  42. package/declarations/browser/utils.d.ts.map +1 -0
  43. package/declarations/test-support/index.d.ts +2 -0
  44. package/declarations/test-support/index.d.ts.map +1 -0
  45. package/dist/browser/__PRIVATE__.js +2 -0
  46. package/dist/browser/__PRIVATE__.js.map +1 -0
  47. package/dist/browser/cjs/eval.js.map +1 -1
  48. package/dist/browser/cjs/index.js.map +1 -1
  49. package/dist/browser/compile/formats.js +2 -1
  50. package/dist/browser/compile/formats.js.map +1 -1
  51. package/dist/browser/compile/index.js +28 -14
  52. package/dist/browser/compile/index.js.map +1 -1
  53. package/dist/browser/compile/markdown-to-ember.js +28 -10
  54. package/dist/browser/compile/markdown-to-ember.js.map +1 -1
  55. package/dist/browser/compile/types.js +1 -1
  56. package/dist/browser/esm/index.js.map +1 -1
  57. package/dist/browser/eti/babel-plugin.js.map +1 -1
  58. package/dist/browser/eti/parse-templates.js.map +1 -1
  59. package/dist/browser/eti/preprocess.js +2 -167
  60. package/dist/browser/eti/preprocess.js.map +1 -1
  61. package/dist/browser/eti/template-tag-transform.js.map +1 -1
  62. package/dist/browser/eti/util.js.map +1 -1
  63. package/dist/browser/gjs.js.map +1 -1
  64. package/dist/browser/hbs.js.map +1 -1
  65. package/dist/browser/js.js.map +1 -1
  66. package/dist/test-support/index.js.map +1 -1
  67. package/package.json +82 -58
  68. package/src/browser/__PRIVATE__.ts +1 -0
  69. package/src/browser/cjs/eval.ts +2 -2
  70. package/src/browser/cjs/index.ts +4 -4
  71. package/src/browser/compile/formats.ts +17 -11
  72. package/src/browser/compile/index.ts +64 -30
  73. package/src/browser/compile/markdown-to-ember.ts +96 -81
  74. package/src/browser/compile/types.ts +4 -0
  75. package/src/browser/esm/index.ts +4 -4
  76. package/src/browser/eti/babel-plugin.ts +2 -2
  77. package/src/browser/eti/parse-templates.ts +2 -2
  78. package/src/browser/eti/preprocess.ts +3 -3
  79. package/src/browser/eti/template-tag-transform.ts +1 -1
  80. package/src/browser/eti/util.ts +1 -1
  81. package/src/browser/gjs.ts +4 -4
  82. package/src/browser/hbs.ts +2 -2
  83. package/src/browser/index.ts +5 -5
  84. package/src/browser/js.ts +3 -3
  85. package/src/test-support/index.ts +1 -1
  86. package/dist/browser/cjs/eval.d.ts +0 -10
  87. package/dist/browser/cjs/eval.d.ts.map +0 -1
  88. package/dist/browser/cjs/index.d.ts +0 -7
  89. package/dist/browser/compile/formats.d.ts +0 -16
  90. package/dist/browser/compile/index.d.ts +0 -51
  91. package/dist/browser/compile/markdown-to-ember.d.ts +0 -18
  92. package/dist/browser/compile/types.d.ts +0 -7
  93. package/dist/browser/esm/index.d.ts +0 -8
  94. package/dist/browser/eti/debug.d.ts +0 -2
  95. package/dist/browser/eti/util.d.ts +0 -14
  96. package/dist/browser/gjs.d.ts +0 -4
  97. package/dist/browser/index.d.ts +0 -6
  98. package/dist/browser/types.d.ts +0 -21
  99. package/dist/test-support/index.d.ts +0 -2
@@ -1,44 +1,74 @@
1
1
  import { cell, resource, resourceFactory } from 'ember-resources';
2
2
 
3
- import { nameFor } from '../utils';
3
+ import { nameFor } from '../utils.ts';
4
4
  import {
5
5
  compileGJS as processGJS,
6
6
  compileHBS as processHBS,
7
7
  compileMD as processMD,
8
- } from './formats';
8
+ } from './formats.ts';
9
9
 
10
- import type { CompileResult } from '../types';
11
- import type { EvalImportMap, ScopeMap } from './types';
10
+ import type { CompileResult } from '../types.ts';
11
+ import type { UnifiedPlugin } from './types.ts';
12
+ import type { EvalImportMap, ScopeMap } from './types.ts';
12
13
  import type { ComponentLike } from '@glint/template';
13
14
  type Format = 'glimdown' | 'gjs' | 'hbs';
14
15
 
15
16
  export const CACHE = new Map<string, ComponentLike>();
16
17
 
18
+ interface Events {
19
+ onSuccess: (component: ComponentLike) => Promise<unknown> | unknown;
20
+ onError: (error: string) => Promise<unknown> | unknown;
21
+ onCompileStart: () => Promise<unknown> | unknown;
22
+ }
23
+
24
+ interface Scope {
25
+ importMap?: EvalImportMap;
26
+ }
27
+
17
28
  const SUPPORTED_FORMATS = ['glimdown', 'gjs', 'hbs'];
18
29
 
30
+ interface GlimdownOptions extends Scope, Events {
31
+ format: 'glimdown';
32
+ remarkPlugins?: UnifiedPlugin[];
33
+ CopyComponent?: string;
34
+ ShadowComponent?: string;
35
+ topLevelScope?: ScopeMap;
36
+ }
37
+ interface GJSOptions extends Scope, Events {
38
+ format: 'gjs';
39
+ }
40
+
41
+ interface HBSOptions extends Scope, Events {
42
+ format: 'hbs';
43
+ topLevelScope?: ScopeMap;
44
+ }
45
+
46
+ /**
47
+ * Compile GitHub-flavored Markdown with GJS support
48
+ * and optionally render gjs-snippets via a `live` meta tag
49
+ * on the code fences.
50
+ */
51
+ export async function compile(text: string, options: GlimdownOptions): Promise<void>;
52
+
53
+ /**
54
+ * Compile GJS
55
+ */
56
+ export async function compile(text: string, options: GJSOptions): Promise<void>;
57
+
58
+ /**
59
+ * Compile a stateless component using just the template
60
+ */
61
+ export async function compile(text: string, options: HBSOptions): Promise<void>;
62
+
19
63
  /**
20
64
  * This compileMD is a more robust version of the raw compiling used in "formats".
21
65
  * This function manages cache, and has events for folks building UIs to hook in to
22
66
  */
23
67
  export async function compile(
24
68
  text: string,
25
- {
26
- format,
27
- onSuccess,
28
- onError,
29
- onCompileStart,
30
- ...options
31
- }: {
32
- format: Format;
33
- onSuccess: (component: ComponentLike) => Promise<unknown> | unknown;
34
- onError: (error: string) => Promise<unknown> | unknown;
35
- onCompileStart: () => Promise<unknown> | unknown;
36
- importMap?: EvalImportMap;
37
- CopyComponent?: string;
38
- ShadowComponent?: string;
39
- topLevelScope?: ScopeMap;
40
- }
41
- ) {
69
+ options: GlimdownOptions | GJSOptions | HBSOptions
70
+ ): Promise<void> {
71
+ let { onSuccess, onError, onCompileStart } = options;
42
72
  let id = nameFor(text);
43
73
 
44
74
  let existing = CACHE.get(id);
@@ -49,8 +79,8 @@ export async function compile(
49
79
  return;
50
80
  }
51
81
 
52
- if (!SUPPORTED_FORMATS.includes(format)) {
53
- await onError(`Unsupported format: ${format}. Supported formats: ${SUPPORTED_FORMATS}`);
82
+ if (!SUPPORTED_FORMATS.includes(options.format)) {
83
+ await onError(`Unsupported format: ${options.format}. Supported formats: ${SUPPORTED_FORMATS}`);
54
84
 
55
85
  return;
56
86
  }
@@ -65,16 +95,18 @@ export async function compile(
65
95
 
66
96
  let result: CompileResult;
67
97
 
68
- if (format === 'glimdown') {
98
+ if (options.format === 'glimdown') {
69
99
  result = await processMD(text, options);
70
- } else if (format === 'gjs') {
100
+ } else if (options.format === 'gjs') {
71
101
  result = await processGJS(text, options.importMap);
72
- } else if (format === 'hbs') {
102
+ } else if (options.format === 'hbs') {
73
103
  result = await processHBS(text, {
74
104
  scope: options.topLevelScope,
75
105
  });
76
106
  } else {
77
- await onError(`Unsupported format: ${format}. Supported formats: ${SUPPORTED_FORMATS}`);
107
+ await onError(
108
+ `Unsupported format: ${(options as any).format}. Supported formats: ${SUPPORTED_FORMATS}`
109
+ );
78
110
 
79
111
  return;
80
112
  }
@@ -95,6 +127,7 @@ type Input = string | undefined | null;
95
127
  type ExtraOptions =
96
128
  | {
97
129
  format: 'glimdown';
130
+ remarkPlugins?: UnifiedPlugin[];
98
131
  importMap?: EvalImportMap;
99
132
  CopyComponent?: string;
100
133
  ShadowComponent?: string;
@@ -114,7 +147,7 @@ type ExtraOptions =
114
147
  */
115
148
  export interface Value {
116
149
  isReady: boolean;
117
- error: unknown;
150
+ error: string | null;
118
151
  component: ComponentLike;
119
152
  }
120
153
 
@@ -139,12 +172,13 @@ export function buildCompiler(
139
172
 
140
173
  let input = typeof markdownText === 'function' ? markdownText() : markdownText;
141
174
  let ready = cell(false);
142
- let error = cell();
175
+ let error = cell<string | null>();
143
176
  let result = cell<ComponentLike>();
144
177
 
145
178
  if (input) {
146
179
  compile(input, {
147
- format,
180
+ // narrowing is hard here, but this is an implementation detail
181
+ format: format as any,
148
182
  onSuccess: async (component) => {
149
183
  result.current = component;
150
184
  ready.set(true);
@@ -6,8 +6,9 @@ import remarkRehype from 'remark-rehype';
6
6
  import { unified } from 'unified';
7
7
  import { visit } from 'unist-util-visit';
8
8
 
9
- import { invocationOf, nameFor } from '../utils';
9
+ import { invocationOf, nameFor } from '../utils.ts';
10
10
 
11
+ import type { UnifiedPlugin } from './types.ts';
11
12
  import type { Node } from 'hast';
12
13
  import type { Code, Text } from 'mdast';
13
14
  import type { Parent } from 'unist';
@@ -114,9 +115,9 @@ function liveCodeExtraction(options: Options = {}) {
114
115
 
115
116
  function enhance(code: Code) {
116
117
  code.data ??= {};
117
- code.data['hProperties'] ??= {};
118
+ (code.data as any)['hProperties'] ??= {};
118
119
  // This is secret-to-us-only API, so we don't really care about the type
119
- (code.data['hProperties'] as any)[GLIMDOWN_PREVIEW] = true;
120
+ (code.data as any)['hProperties'][GLIMDOWN_PREVIEW] = true;
120
121
 
121
122
  return {
122
123
  data: {
@@ -138,8 +139,8 @@ function liveCodeExtraction(options: Options = {}) {
138
139
 
139
140
  return function transformer(tree: Parent, file: VFileWithMeta) {
140
141
  visit(tree, ['code'], function (node, index, parent) {
141
- if (parent === null) return;
142
- if (index === null) return;
142
+ if (parent === null || parent === undefined) return;
143
+ if (index === null || index === undefined) return;
143
144
 
144
145
  if (!isRelevantCode(node as Code)) {
145
146
  let enhanced = enhance(node as Code);
@@ -218,89 +219,103 @@ function liveCodeExtraction(options: Options = {}) {
218
219
  }
219
220
 
220
221
  function buildCompiler(options: ParseMarkdownOptions) {
221
- return (
222
- unified()
223
- .use(remarkParse)
224
- .use(remarkGfm)
225
- // TODO: we only want to do this when we have pre > code.
226
- // code can exist inline.
227
- .use(liveCodeExtraction, {
228
- snippets: {
229
- classList: ['glimdown-snippet', 'relative'],
230
- },
231
- demo: {
232
- classList: ['glimdown-render'],
233
- },
234
- copyComponent: options?.CopyComponent,
235
- shadowComponent: options?.ShadowComponent,
236
- })
237
- // .use(() => (tree) => visit(tree, (node) => console.log('i', node)))
238
- // remark rehype is needed to convert markdown to HTML
239
- // However, it also changes all the nodes, so we need another pass
240
- // to make sure our Glimmer-aware nodes are in tact
241
- .use(remarkRehype, { allowDangerousHtml: true })
242
- // Convert invocables to raw format, so Glimmer can invoke them
243
- .use(() => (tree: Node) => {
244
- visit(tree, function (node) {
245
- // We rely on an implicit transformation of data.hProperties => properties
246
- let properties = (node as any).properties;
247
-
248
- if (properties?.[GLIMDOWN_PREVIEW]) {
249
- // Have to sanitize anything Glimmer could try to render
250
- escapeCurlies(node as Parent);
251
-
252
- return 'skip';
253
- }
254
-
255
- if (node.type === 'element' || ('tagName' in node && node.tagName === 'code')) {
256
- if (properties?.[GLIMDOWN_RENDER]) {
257
- node.type = 'glimmer_raw';
258
-
259
- return;
260
- }
261
-
262
- escapeCurlies(node as Parent);
263
-
264
- return 'skip';
265
- }
266
-
267
- if (node.type === 'text' || node.type === 'raw') {
268
- // definitively not the better way, but this is supposed to detect "glimmer" nodes
269
- if (
270
- 'value' in node &&
271
- typeof node.value === 'string' &&
272
- node.value.match(/<\/?[_A-Z:0-9].*>/g)
273
- ) {
274
- node.type = 'glimmer_raw';
275
- }
276
-
277
- node.type = 'glimmer_raw';
278
-
279
- return 'skip';
280
- }
222
+ let compiler = unified().use(remarkParse).use(remarkGfm);
223
+
224
+ // TODO: we only want to do this when we have pre > code.
225
+ // code can exist inline.
226
+ compiler = compiler.use(liveCodeExtraction, {
227
+ snippets: {
228
+ classList: ['glimdown-snippet', 'relative'],
229
+ },
230
+ demo: {
231
+ classList: ['glimdown-render'],
232
+ },
233
+ copyComponent: options?.CopyComponent,
234
+ shadowComponent: options?.ShadowComponent,
235
+ });
236
+
237
+ /**
238
+ * If this were "use"d after `remarkRehype`,
239
+ * remark is gone, and folks would need to work with rehype trees
240
+ */
241
+ if (options.remarkPlugins) {
242
+ options.remarkPlugins.forEach((plugin) => {
243
+ compiler = compiler.use(plugin) as any;
244
+ });
245
+ }
246
+
247
+ // .use(() => (tree) => visit(tree, (node) => console.log('i', node)))
248
+ // remark rehype is needed to convert markdown to HTML
249
+ // However, it also changes all the nodes, so we need another pass
250
+ // to make sure our Glimmer-aware nodes are in tact
251
+ compiler = compiler.use(remarkRehype, { allowDangerousHtml: true });
252
+
253
+ // Convert invocables to raw format, so Glimmer can invoke them
254
+ compiler = compiler.use(() => (tree: Node) => {
255
+ visit(tree, function (node) {
256
+ // We rely on an implicit transformation of data.hProperties => properties
257
+ let properties = (node as any).properties;
258
+
259
+ if (properties?.[GLIMDOWN_PREVIEW]) {
260
+ // Have to sanitize anything Glimmer could try to render
261
+ escapeCurlies(node as Parent);
262
+
263
+ return 'skip';
264
+ }
265
+
266
+ if (node.type === 'element' || ('tagName' in node && node.tagName === 'code')) {
267
+ if (properties?.[GLIMDOWN_RENDER]) {
268
+ node.type = 'glimmer_raw';
281
269
 
282
270
  return;
283
- });
284
- })
285
- .use(rehypeRaw, { passThrough: ['glimmer_raw', 'raw'] })
286
- .use(() => (tree) => {
287
- visit(tree, 'glimmer_raw', (node: Node) => {
288
- node.type = 'raw';
289
- });
290
- })
291
- .use(rehypeStringify, {
292
- collapseEmptyAttributes: true,
293
- closeSelfClosing: true,
294
- allowParseErrors: true,
295
- allowDangerousCharacters: true,
296
- allowDangerousHtml: true,
297
- })
298
- );
271
+ }
272
+
273
+ escapeCurlies(node as Parent);
274
+
275
+ return 'skip';
276
+ }
277
+
278
+ if (node.type === 'text' || node.type === 'raw') {
279
+ // definitively not the better way, but this is supposed to detect "glimmer" nodes
280
+ if (
281
+ 'value' in node &&
282
+ typeof node.value === 'string' &&
283
+ node.value.match(/<\/?[_A-Z:0-9].*>/g)
284
+ ) {
285
+ node.type = 'glimmer_raw';
286
+ }
287
+
288
+ node.type = 'glimmer_raw';
289
+
290
+ return 'skip';
291
+ }
292
+
293
+ return;
294
+ });
295
+ });
296
+
297
+ compiler = compiler.use(rehypeRaw, { passThrough: ['glimmer_raw', 'raw'] }).use(() => (tree) => {
298
+ visit(tree, 'glimmer_raw', (node: Node) => {
299
+ node.type = 'raw';
300
+ });
301
+ });
302
+
303
+ // Finally convert to string! oofta!
304
+ compiler = compiler.use(rehypeStringify, {
305
+ collapseEmptyAttributes: true,
306
+ closeSelfClosing: true,
307
+ allowParseErrors: true,
308
+ allowDangerousCharacters: true,
309
+ allowDangerousHtml: true,
310
+ }) as any;
311
+
312
+ return compiler as ReturnType<typeof unified>;
299
313
  }
300
314
 
301
315
  interface ParseMarkdownOptions {
302
316
  CopyComponent?: string;
303
317
  ShadowComponent?: string;
318
+ remarkPlugins?: UnifiedPlugin[];
304
319
  }
305
320
 
306
321
  /**
@@ -1,3 +1,5 @@
1
+ import { type Plugin } from 'unified';
2
+
1
3
  export interface EvalImportMap {
2
4
  [moduleName: string]: ScopeMap;
3
5
  }
@@ -5,3 +7,5 @@ export interface EvalImportMap {
5
7
  export interface ScopeMap {
6
8
  [localName: string]: unknown;
7
9
  }
10
+
11
+ export type UnifiedPlugin = Plugin; // Parameters<ReturnType<typeof unified>['use']>[0];
@@ -1,8 +1,8 @@
1
- import { preprocess, transform } from '../gjs';
2
- import { modules } from '../known-modules';
3
- import { nameFor } from '../utils';
1
+ import { preprocess, transform } from '../gjs.ts';
2
+ import { modules } from '../known-modules.ts';
3
+ import { nameFor } from '../utils.ts';
4
4
 
5
- import type { CompileResult, ExtraModules } from '../types';
5
+ import type { CompileResult, ExtraModules } from '../types.ts';
6
6
  import type Component from '@glimmer/component';
7
7
  import type { ComponentLike } from '@glint/template';
8
8
 
@@ -1,7 +1,7 @@
1
1
  import { ImportUtil } from 'babel-import-util';
2
2
 
3
- import { transformTemplateTag } from './template-tag-transform';
4
- import * as util from './util';
3
+ import { transformTemplateTag } from './template-tag-transform.ts';
4
+ import * as util from './util.ts';
5
5
 
6
6
  import type { NodePath } from '@babel/traverse';
7
7
  import type { CallExpression, Class, Program } from '@babel/types';
@@ -1,5 +1,5 @@
1
- import { expect } from './debug';
2
- import { TEMPLATE_TAG_NAME } from './util';
1
+ import { expect } from './debug.ts';
2
+ import { TEMPLATE_TAG_NAME } from './util.ts';
3
3
 
4
4
  export type TemplateMatch = TemplateTagMatch;
5
5
 
@@ -7,10 +7,10 @@ import { getTemplateLocals } from '@glimmer/syntax';
7
7
  import lineColumn from 'line-column';
8
8
  import MagicString from 'magic-string';
9
9
 
10
- import { expect } from './debug';
11
- import { parseTemplates } from './parse-templates';
10
+ import { expect } from './debug.ts';
11
+ import { parseTemplates } from './parse-templates.ts';
12
12
 
13
- import type { ParseTemplatesOptions, TemplateMatch } from './parse-templates';
13
+ import type { ParseTemplatesOptions, TemplateMatch } from './parse-templates.ts';
14
14
 
15
15
  interface PreprocessOptionsEager {
16
16
  importIdentifier?: string;
@@ -1,4 +1,4 @@
1
- import { buildPrecompileTemplateCall, registerRefs, TEMPLATE_TAG_NAME } from './util';
1
+ import { buildPrecompileTemplateCall, registerRefs, TEMPLATE_TAG_NAME } from './util.ts';
2
2
 
3
3
  /**
4
4
  * Supports the following syntaxes:
@@ -1,4 +1,4 @@
1
- import type { TemplateMatch } from './parse-templates';
1
+ import type { TemplateMatch } from './parse-templates.ts';
2
2
  import type { NodePath } from '@babel/traverse';
3
3
  import type { CallExpression } from '@babel/types';
4
4
  import type { ImportUtil } from 'babel-import-util';
@@ -3,11 +3,11 @@ import { importSync } from '@embroider/macros';
3
3
  import babelPluginEmberTemplateCompilation from 'babel-plugin-ember-template-compilation';
4
4
 
5
5
  // TODO: use real packages, and not these copied files from ember-template-imports
6
- import babelPluginIntermediateGJS from './eti/babel-plugin';
7
- import { preprocessEmbeddedTemplates } from './eti/preprocess';
8
- import { TEMPLATE_TAG_NAME, TEMPLATE_TAG_PLACEHOLDER } from './eti/util';
6
+ import babelPluginIntermediateGJS from './eti/babel-plugin.ts';
7
+ import { preprocessEmbeddedTemplates } from './eti/preprocess.ts';
8
+ import { TEMPLATE_TAG_NAME, TEMPLATE_TAG_PLACEHOLDER } from './eti/util.ts';
9
9
 
10
- import type { Babel } from './types';
10
+ import type { Babel } from './types.ts';
11
11
 
12
12
  const compiler = importSync('ember-source/dist/ember-template-compiler.js');
13
13
 
@@ -11,9 +11,9 @@ import { on } from '@ember/modifier';
11
11
  import { createTemplateFactory } from '@ember/template-factory';
12
12
  import { importSync } from '@embroider/macros';
13
13
 
14
- import { nameFor } from './utils';
14
+ import { nameFor } from './utils.ts';
15
15
 
16
- import type { CompileResult } from './types';
16
+ import type { CompileResult } from './types.ts';
17
17
  import type { ComponentLike } from '@glint/template';
18
18
 
19
19
  // These things are pre-bundled in the old system.
@@ -1,8 +1,8 @@
1
- export { compile, Compiled } from './compile';
2
- export { compileHBS } from './hbs';
3
- export { compileJS } from './js';
4
- export { modules as frameworkModules } from './known-modules';
5
- export { invocationName, invocationOf, nameFor } from './utils';
1
+ export { compile, Compiled } from './compile/index.ts';
2
+ export { compileHBS } from './hbs.ts';
3
+ export { compileJS } from './js.ts';
4
+ export { modules as frameworkModules } from './known-modules.ts';
5
+ export { invocationName, invocationOf, nameFor } from './utils.ts';
6
6
 
7
7
  // Public Types
8
8
  export type { CompileResult } from './types';
package/src/browser/js.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { compileJS as compileAMD } from './cjs';
2
- import { compileJS as compileESM } from './esm';
1
+ import { compileJS as compileAMD } from './cjs/index.ts';
2
+ import { compileJS as compileESM } from './esm/index.ts';
3
3
 
4
- import type { CompileResult, ExtraModules, Options } from './types';
4
+ import type { CompileResult, ExtraModules, Options } from './types.ts';
5
5
 
6
6
  /**
7
7
  * @public
@@ -1,4 +1,4 @@
1
- import { CACHE } from '../browser/compile/index';
1
+ import { CACHE } from '../browser/compile/index.ts';
2
2
 
3
3
  export function clearCompileCache() {
4
4
  CACHE.clear();
@@ -1,10 +0,0 @@
1
- import { ExtraModules } from "../types.js";
2
- import Component from '@glimmer/component';
3
- declare function evalSnippet(compiled: string, extraModules?: ExtraModules): {
4
- default: Component;
5
- services?: {
6
- [key: string]: unknown;
7
- };
8
- };
9
- export { evalSnippet };
10
- //# sourceMappingURL=browser/cjs/eval.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"browser/cjs/eval.d.ts","sourceRoot":"","sources":["../src/browser/cjs/eval.ts"],"names":[],"mappings":"AAGA,OAAO,gBAAqB,oBAAiB;AAC7C,OAAO,SAAc,MAAM,oBAAoB,CAAC;AAEhD,iBAAgB,WAAW,CACzB,QAAQ,EAAE,MAAM,EAChB,YAAY,GAAE,YAAiB,GAC9B;IACD,OAAO,EAAE,SAAS,CAAC;IACnB,QAAQ,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;CACvC,CAmBA"}
@@ -1,7 +0,0 @@
1
- import { CompileResult, ExtraModules } from "../types.js";
2
- interface Info {
3
- code: string;
4
- name: string;
5
- }
6
- declare function compileJS(code: string, extraModules?: ExtraModules): Promise<CompileResult>;
7
- export { Info, compileJS };
@@ -1,16 +0,0 @@
1
- import { CompileResult } from "../types.js";
2
- import { EvalImportMap, ScopeMap } from "./types.js";
3
- declare function compileGJS(gjsInput: string, importMap?: EvalImportMap): Promise<CompileResult>;
4
- declare function compileHBS(hbsInput: string, options?: {
5
- moduleName?: string;
6
- scope?: Record<string, unknown>;
7
- }): Promise<CompileResult>;
8
- declare function compileMD(glimdownInput: string, options?: {
9
- importMap?: EvalImportMap;
10
- topLevelScope?: ScopeMap;
11
- CopyComponent?: string;
12
- ShadowComponent?: string;
13
- }): Promise<CompileResult & {
14
- rootTemplate?: string;
15
- }>;
16
- export { compileGJS, compileHBS, compileMD };
@@ -1,51 +0,0 @@
1
- import { EvalImportMap, ScopeMap } from "./types.js";
2
- import { ComponentLike } from '@glint/template';
3
- type Format = 'glimdown' | 'gjs' | 'hbs';
4
- declare const CACHE: Map<string, ComponentLike>;
5
- /**
6
- * This compileMD is a more robust version of the raw compiling used in "formats".
7
- * This function manages cache, and has events for folks building UIs to hook in to
8
- */
9
- declare function compile(text: string, { format, onSuccess, onError, onCompileStart, ...options }: {
10
- format: Format;
11
- onSuccess: (component: ComponentLike) => Promise<unknown> | unknown;
12
- onError: (error: string) => Promise<unknown> | unknown;
13
- onCompileStart: () => Promise<unknown> | unknown;
14
- importMap?: EvalImportMap;
15
- CopyComponent?: string;
16
- ShadowComponent?: string;
17
- topLevelScope?: ScopeMap;
18
- }): Promise<void>;
19
- type Input = string | undefined | null;
20
- type ExtraOptions = {
21
- format: 'glimdown';
22
- importMap?: EvalImportMap;
23
- CopyComponent?: string;
24
- ShadowComponent?: string;
25
- topLevelScope?: ScopeMap;
26
- } | {
27
- format: 'hbs';
28
- topLevelScope?: ScopeMap;
29
- } | {
30
- format: 'gjs';
31
- importMap?: EvalImportMap;
32
- };
33
- /**
34
- * @internal
35
- */
36
- interface Value {
37
- isReady: boolean;
38
- error: unknown;
39
- component: ComponentLike;
40
- }
41
- declare function buildCompiler(markdownText: Input | (() => Input)): Value;
42
- declare function buildCompiler(markdownText: Input | (() => Input), options?: Format): Value;
43
- declare function buildCompiler(markdownText: Input | (() => Input), options?: () => Format): Value;
44
- declare function buildCompiler(markdownText: Input | (() => Input), options?: ExtraOptions): Value;
45
- declare function buildCompiler(markdownText: Input | (() => Input), options?: () => ExtraOptions): Value;
46
- /**
47
- * By default, this compiles to `glimdown`. A Markdown format which
48
- * extracts `live` tagged code snippets and compiles them to components.
49
- */
50
- declare const Compiled: typeof buildCompiler;
51
- export { CACHE, compile, Value, buildCompiler, Compiled };
@@ -1,18 +0,0 @@
1
- interface ExtractedCode {
2
- name: string;
3
- code: string;
4
- lang: string;
5
- }
6
- interface LiveCodeExtraction {
7
- templateOnlyGlimdown: string;
8
- blocks: ExtractedCode[];
9
- }
10
- interface ParseMarkdownOptions {
11
- CopyComponent?: string;
12
- ShadowComponent?: string;
13
- }
14
- /**
15
- * @internal not under semver
16
- */
17
- declare function parseMarkdown(input: string, options?: ParseMarkdownOptions): Promise<LiveCodeExtraction>;
18
- export { ExtractedCode, LiveCodeExtraction, parseMarkdown };
@@ -1,7 +0,0 @@
1
- interface EvalImportMap {
2
- [moduleName: string]: ScopeMap;
3
- }
4
- interface ScopeMap {
5
- [localName: string]: unknown;
6
- }
7
- export { EvalImportMap, ScopeMap };
@@ -1,8 +0,0 @@
1
- import { CompileResult, ExtraModules } from "../types.js";
2
- interface Info {
3
- code: string;
4
- name: string;
5
- }
6
- declare function compileJS(code: string, extraModules?: ExtraModules): Promise<CompileResult>;
7
- declare function proxyToSkypack(code: string, extraModules?: ExtraModules): string;
8
- export { Info, compileJS, proxyToSkypack };
@@ -1,2 +0,0 @@
1
- declare function expect<T>(value: T | null | undefined, message: string): T;
2
- export { expect };