ember-repl 5.0.1 → 6.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 (35) hide show
  1. package/declarations/compile/formats/gjs/eval.d.ts.map +1 -1
  2. package/declarations/compile/formats/gjs/index.d.ts.map +1 -1
  3. package/declarations/compile/formats/gjs/known-modules.d.ts +3 -1
  4. package/declarations/compile/formats/gjs/known-modules.d.ts.map +1 -1
  5. package/declarations/compile/formats/hbs.d.ts.map +1 -1
  6. package/declarations/compile/formats/markdown.d.ts.map +1 -1
  7. package/declarations/compile/formats.d.ts +1 -2
  8. package/declarations/compile/formats.d.ts.map +1 -1
  9. package/declarations/compile/index.d.ts +1 -2
  10. package/declarations/compile/index.d.ts.map +1 -1
  11. package/dist/compile/formats/gjs/eval.js +1 -2
  12. package/dist/compile/formats/gjs/eval.js.map +1 -1
  13. package/dist/compile/formats/gjs/index.js +12 -10
  14. package/dist/compile/formats/gjs/index.js.map +1 -1
  15. package/dist/compile/formats/gjs/known-modules.js +3 -1
  16. package/dist/compile/formats/gjs/known-modules.js.map +1 -1
  17. package/dist/compile/formats/hbs.js +10 -11
  18. package/dist/compile/formats/hbs.js.map +1 -1
  19. package/dist/compile/formats/markdown.js +23 -21
  20. package/dist/compile/formats/markdown.js.map +1 -1
  21. package/dist/compile/formats.js +14 -14
  22. package/dist/compile/formats.js.map +1 -1
  23. package/dist/compile/index.js +10 -10
  24. package/dist/compile/index.js.map +1 -1
  25. package/dist/compile/utils.js +1 -1
  26. package/dist/compile/utils.js.map +1 -1
  27. package/package.json +42 -50
  28. package/src/compile/formats/gjs/eval.ts +1 -2
  29. package/src/compile/formats/gjs/index.ts +12 -10
  30. package/src/compile/formats/gjs/known-modules.ts +1 -1
  31. package/src/compile/formats/hbs.ts +10 -11
  32. package/src/compile/formats/markdown.ts +22 -21
  33. package/src/compile/formats.ts +15 -16
  34. package/src/compile/index.ts +12 -12
  35. package/src/compile/utils.ts +1 -1
@@ -1,7 +1,7 @@
1
1
  import { invocationName } from './utils.js';
2
2
 
3
3
  async function compileGJSArray(js, importMap) {
4
- let modules = await Promise.all(js.map(async ({
4
+ const modules = await Promise.all(js.map(async ({
5
5
  code
6
6
  }) => {
7
7
  return await compileGJS(code, importMap);
@@ -10,7 +10,7 @@ async function compileGJSArray(js, importMap) {
10
10
  }
11
11
  async function compileGJS(gjsInput, importMap) {
12
12
  try {
13
- let {
13
+ const {
14
14
  compileJS
15
15
  } = await import('./formats/gjs/index.js');
16
16
  return await compileJS(gjsInput, importMap);
@@ -23,7 +23,7 @@ async function compileGJS(gjsInput, importMap) {
23
23
  }
24
24
  async function compileHBS(hbsInput, options) {
25
25
  try {
26
- let {
26
+ const {
27
27
  compileHBS
28
28
  } = await import('./formats/hbs.js');
29
29
  return compileHBS(hbsInput, options);
@@ -35,11 +35,11 @@ async function compileHBS(hbsInput, options) {
35
35
  }
36
36
  }
37
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));
38
+ const scope = [];
39
+ const hbs = liveCode.filter(code => code.lang === 'hbs');
40
+ const js = liveCode.filter(code => ['js', 'gjs'].includes(code.lang));
41
41
  if (js.length > 0) {
42
- let compiled = await compileGJSArray(js, options?.importMap);
42
+ const compiled = await compileGJSArray(js, options?.importMap);
43
43
  await Promise.all(compiled.map(async info => {
44
44
  // using web worker + import maps is not available yet (need firefox support)
45
45
  // (and to somehow be able to point at npm)
@@ -54,10 +54,10 @@ async function extractScope(liveCode, options) {
54
54
  return scope.push(info);
55
55
  }));
56
56
  }
57
- for (let {
57
+ for (const {
58
58
  code
59
59
  } of hbs) {
60
- let compiled = await compileHBS(code, {
60
+ const compiled = await compileHBS(code, {
61
61
  scope: options?.topLevelScope
62
62
  });
63
63
  scope.push(compiled);
@@ -65,7 +65,7 @@ async function extractScope(liveCode, options) {
65
65
  return scope;
66
66
  }
67
67
  async function compileMD(glimdownInput, options) {
68
- let topLevelScope = options?.topLevelScope ?? {};
68
+ const topLevelScope = options?.topLevelScope ?? {};
69
69
  let rootTemplate;
70
70
  let liveCode;
71
71
  let scope = [];
@@ -80,10 +80,10 @@ async function compileMD(glimdownInput, options) {
80
80
  * compiled rootTemplate can invoke them
81
81
  */
82
82
  try {
83
- let {
83
+ const {
84
84
  parseMarkdown
85
85
  } = await import('./formats/markdown.js');
86
- let {
86
+ const {
87
87
  templateOnlyGlimdown,
88
88
  blocks
89
89
  } = await parseMarkdown(glimdownInput, {
@@ -127,7 +127,7 @@ async function compileMD(glimdownInput, options) {
127
127
  * can render the 'Ember' and still highlight the correct line?
128
128
  * or maybe there is a way to highlight in the editor instead?
129
129
  */
130
- for (let {
130
+ for (const {
131
131
  error,
132
132
  component
133
133
  } of scope) {
@@ -146,7 +146,7 @@ async function compileMD(glimdownInput, options) {
146
146
  * Step 4: Compile the Ember Template
147
147
  */
148
148
  try {
149
- let localScope = scope.reduce((accum, {
149
+ const localScope = scope.reduce((accum, {
150
150
  component,
151
151
  name
152
152
  }) => {
@@ -1 +1 @@
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;AACzB,IAAA,OAAO,MAAMC,UAAU,CAACD,IAAI,EAAEL,SAAS,CAAC;AAC1C,GAAC,CACH,CAAC;AAED,EAAA,OAAOC,OAAO;AAChB;AAE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ts"],"sourcesContent":["import { invocationName } from './utils.ts';\n\nimport type { ExtractedCode } from './formats/markdown.ts';\nimport type { CompileResult, EvalImportMap, ScopeMap, UnifiedPlugin } from './types.ts';\n\nasync function compileGJSArray(js: { code: string }[], importMap?: EvalImportMap) {\n const 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 const { 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 const { 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 const scope: CompileResult[] = [];\n\n const hbs = liveCode.filter((code) => code.lang === 'hbs');\n const js = liveCode.filter((code) => ['js', 'gjs'].includes(code.lang));\n\n if (js.length > 0) {\n const 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 (const { code } of hbs) {\n const 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 const 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 const { parseMarkdown } = await import('./formats/markdown.ts');\n const { 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 (const { 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 const 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":";;AAKA,eAAeA,eAAeA,CAACC,EAAsB,EAAEC,SAAyB,EAAE;EAChF,MAAMC,OAAO,GAAG,MAAMC,OAAO,CAACC,GAAG,CAC/BJ,EAAE,CAACK,GAAG,CAAC,OAAO;AAAEC,IAAAA;AAAK,GAAC,KAAK;AACzB,IAAA,OAAO,MAAMC,UAAU,CAACD,IAAI,EAAEL,SAAS,CAAC;AAC1C,GAAC,CACH,CAAC;AAED,EAAA,OAAOC,OAAO;AAChB;AAEO,eAAeK,UAAUA,CAC9BC,QAAgB,EAChBP,SAAyB,EACD;EACxB,IAAI;IACF,MAAM;AAAEQ,MAAAA;AAAU,KAAC,GAAG,MAAM,OAAO,wBAAwB,CAAC;AAE5D,IAAA,OAAO,MAAMA,SAAS,CAACD,QAAQ,EAAEP,SAAS,CAAC;GAC5C,CAAC,OAAOS,KAAK,EAAE;IACd,OAAO;AAAEA,MAAAA,KAAK,EAAEA,KAAc;AAAEC,MAAAA,IAAI,EAAE;KAAW;AACnD;AACF;AAEO,eAAeC,UAAUA,CAC9BC,QAAgB,EAChBC,OAGC,EACuB;EACxB,IAAI;IACF,MAAM;AAAEF,MAAAA;AAAW,KAAC,GAAG,MAAM,OAAO,kBAAkB,CAAC;AAEvD,IAAA,OAAOA,UAAU,CAACC,QAAQ,EAAEC,OAAO,CAAC;GACrC,CAAC,OAAOJ,KAAK,EAAE;IACd,OAAO;AAAEA,MAAAA,KAAK,EAAEA,KAAc;AAAEC,MAAAA,IAAI,EAAE;KAAW;AACnD;AACF;AAEA,eAAeI,YAAYA,CACzBC,QAAyB,EACzBF,OAGC,EACyB;EAC1B,MAAMG,KAAsB,GAAG,EAAE;AAEjC,EAAA,MAAMC,GAAG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K,KAAC,KAAK;AAC9B8B,MAAAA,KAAK,CAACC,cAAc,CAAC/B,IAAI,CAAC,CAAC,GAAG2B,SAAS;AAEvC,MAAA,OAAOG,KAAK;KACb,EACD,EACF,CAAC;AAED,IAAA,OAAO,MAAM7B,UAAU,CAACiB,YAAY,EAAE;AACpCc,MAAAA,UAAU,EAAE,qBAAqB;AACjC1B,MAAAA,KAAK,EAAE;AACL,QAAA,GAAGS,aAAa;QAChB,GAAGa;AACL;AACF,KAAC,CAAC;GACH,CAAC,OAAO7B,KAAK,EAAE;IACd,OAAO;AAAEA,MAAAA,KAAK,EAAEA,KAAc;MAAEmB,YAAY;AAAElB,MAAAA,IAAI,EAAE;KAAW;AACjE;AACF;;;;"}
@@ -24,13 +24,13 @@ const SUPPORTED_FORMATS = ['glimdown', 'gjs', 'hbs'];
24
24
  * This function manages cache, and has events for folks building UIs to hook in to
25
25
  */
26
26
  async function compile(text, options) {
27
- let {
27
+ const {
28
28
  onSuccess,
29
29
  onError,
30
30
  onCompileStart
31
31
  } = options;
32
- let id = nameFor(`${options.format}:${text}`);
33
- let existing = CACHE.get(id);
32
+ const id = nameFor(`${options.format}:${text}`);
33
+ const existing = CACHE.get(id);
34
34
  if (existing) {
35
35
  onSuccess(existing);
36
36
  return;
@@ -75,13 +75,13 @@ async function compile(text, options) {
75
75
  */
76
76
  function Compiled(markdownText, maybeOptions) {
77
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();
78
+ const maybeObject = typeof maybeOptions === 'function' ? maybeOptions() : maybeOptions;
79
+ const format = (typeof maybeObject === 'string' ? maybeObject : maybeObject?.format) || 'glimdown';
80
+ const options = (typeof maybeObject === 'string' ? {} : maybeObject) || {};
81
+ const input = typeof markdownText === 'function' ? markdownText() : markdownText;
82
+ const ready = cell(false);
83
+ const error = cell();
84
+ const result = cell();
85
85
  if (input) {
86
86
  compile(input, {
87
87
  // narrowing is hard here, but this is an implementation detail
@@ -1 +1 @@
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,OA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AK,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
+ {"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, EvalImportMap, ScopeMap, UnifiedPlugin } from './types.ts';\nimport type { ComponentLike } from '@glint/template';\n\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 const { onSuccess, onError, onCompileStart } = options;\n const id = nameFor(`${options.format}:${text}`);\n\n const 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 const maybeObject = typeof maybeOptions === 'function' ? maybeOptions() : maybeOptions;\n const format =\n (typeof maybeObject === 'string' ? maybeObject : maybeObject?.format) || 'glimdown';\n const options = (typeof maybeObject === 'string' ? {} : maybeObject) || {};\n\n const input = typeof markdownText === 'function' ? markdownText() : markdownText;\n const ready = cell(false);\n const error = cell<string | null>();\n const 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,MAAM;IAAEC,SAAS;IAAEC,OAAO;AAAEC,IAAAA;AAAe,GAAC,GAAGH,OAAO;EACtD,MAAMI,EAAE,GAAGC,OAAO,CAAC,CAAA,EAAGL,OAAO,CAACM,MAAM,CAAA,CAAA,EAAIP,IAAI,CAAA,CAAE,CAAC;AAE/C,EAAA,MAAMQ,QAAQ,GAAGZ,KAAK,CAACa,GAAG,CAACJ,EAAE,CAAC;AAE9B,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,OAAO,CAACM,MAAM,KAAK,UAAU,EAAE;AACjCI,IAAAA,MAAM,GAAG,MAAMC,SAAS,CAACZ,IAAI,EAAEC,OAAO,CAAC;AACzC,GAAC,MAAM,IAAIA,OAAO,CAACM,MAAM,KAAK,KA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,MAAMK,KAAK,GAAGC,IAAI,CAAC,KAAK,CAAC;AACzB,IAAA,MAAMX,KAAK,GAAGW,IAAI,EAAiB;AACnC,IAAA,MAAMlB,MAAM,GAAGkB,IAAI,EAAiB;AAEpC,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;;;;"}
@@ -17,7 +17,7 @@ const DEFAULT_PREFIX = 'ember-repl';
17
17
  * and generally allowing a consumer to derive "known references" to user-input
18
18
  */
19
19
  function nameFor(code, prefix = DEFAULT_PREFIX) {
20
- let id = v5(code, NAMESPACE);
20
+ const id = v5(code, NAMESPACE);
21
21
  return `${prefix ? `${prefix}-` : ''}${id}`;
22
22
  }
23
23
 
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../src/compile/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;AACxD,MAAMC,cAAc,GAAG,YAAY;;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;EAEhC,OAAO,CAAA,EAAGI,MAAM,GAAG,CAAGA,EAAAA,MAAM,GAAG,GAAG,EAAE,CAAGC,EAAAA,EAAE,CAAE,CAAA;AAC7C;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASE,YAAYA,CAACC,IAAY,EAAE;AACzCC,EAAAA,MAAM,CACJ,CAAA,kDAAA,EAAqDD,IAAI,CAAA,EAAA,CAAI,EAC7D,OAAOA,IAAI,KAAK,QAAQ,IAAIA,IAAI,CAACE,MAAM,GAAG,CAC5C,CAAC;AAED,EAAA,IAAIF,IAAI,CAACE,MAAM,KAAK,CAAC,EAAE;AACrB,IAAA,MAAM,IAAIC,KAAK,CAAC,CAAA,kDAAA,CAAoD,CAAC;AACvE;AAEA,EAAA,OAAO,CAAIC,CAAAA,EAAAA,cAAc,CAACJ,IAAI,CAAC,CAAK,GAAA,CAAA;AACtC;;AAEA;AACA;AACA;AACA;AACO,SAASI,cAAcA,CAACJ,IAAY,EAAE;EAC3C,OAAOK,UAAU,CAACL,IAAI,CAAC,CAACM,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC;AAC7C;;;;"}
1
+ {"version":3,"file":"utils.js","sources":["../../src/compile/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 const 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;AACxD,MAAMC,cAAc,GAAG,YAAY;;AAEnC;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,OAAOA,CAACC,IAAY,EAAEC,MAAM,GAAGH,cAAc,EAAE;AAC7D,EAAA,MAAMI,EAAE,GAAGC,EAAM,CAACH,IAAI,EAAEH,SAAS,CAAC;EAElC,OAAO,CAAA,EAAGI,MAAM,GAAG,CAAGA,EAAAA,MAAM,GAAG,GAAG,EAAE,CAAGC,EAAAA,EAAE,CAAE,CAAA;AAC7C;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASE,YAAYA,CAACC,IAAY,EAAE;AACzCC,EAAAA,MAAM,CACJ,CAAA,kDAAA,EAAqDD,IAAI,CAAA,EAAA,CAAI,EAC7D,OAAOA,IAAI,KAAK,QAAQ,IAAIA,IAAI,CAACE,MAAM,GAAG,CAC5C,CAAC;AAED,EAAA,IAAIF,IAAI,CAACE,MAAM,KAAK,CAAC,EAAE;AACrB,IAAA,MAAM,IAAIC,KAAK,CAAC,CAAA,kDAAA,CAAoD,CAAC;AACvE;AAEA,EAAA,OAAO,CAAIC,CAAAA,EAAAA,cAAc,CAACJ,IAAI,CAAC,CAAK,GAAA,CAAA;AACtC;;AAEA;AACA;AACA;AACA;AACO,SAASI,cAAcA,CAACJ,IAAY,EAAE;EAC3C,OAAOK,UAAU,CAACL,IAAI,CAAC,CAACM,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC;AAC7C;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-repl",
3
- "version": "5.0.1",
3
+ "version": "6.0.0",
4
4
  "description": "Addon for enabling REPL and Playground creation with Ember/Glimmer",
5
5
  "keywords": [
6
6
  "ember-addon"
@@ -60,8 +60,8 @@
60
60
  "addon-main.cjs"
61
61
  ],
62
62
  "dependencies": {
63
- "@babel/helper-plugin-utils": "^7.25.7",
64
- "@babel/standalone": "^7.25.7",
63
+ "@babel/helper-plugin-utils": "^7.26.5",
64
+ "@babel/standalone": "^7.26.9",
65
65
  "@embroider/addon-shim": "1.8.9",
66
66
  "@embroider/macros": "1.16.9",
67
67
  "babel-import-util": "^3.0.0",
@@ -69,11 +69,11 @@
69
69
  "broccoli-file-creator": "^2.1.1",
70
70
  "change-case": "^5.4.4",
71
71
  "common-tags": "^1.8.2",
72
- "content-tag": "^3.0.0",
72
+ "content-tag": "^3.1.1",
73
73
  "decorator-transforms": "^2.3.0",
74
- "ember-resources": "^7.0.1",
74
+ "ember-resources": "^7.0.3",
75
75
  "line-column": "^1.0.2",
76
- "magic-string": "^0.30.6",
76
+ "magic-string": "^0.30.17",
77
77
  "mdast": "^3.0.0",
78
78
  "parse-static-imports": "^1.1.0",
79
79
  "rehype-raw": "^6.1.1",
@@ -84,58 +84,52 @@
84
84
  "unified": "^10.1.2",
85
85
  "unist-util-visit": "^5.0.0",
86
86
  "uuid": "^10.0.0",
87
- "vfile": "^6.0.1"
87
+ "vfile": "^6.0.3"
88
88
  },
89
89
  "devDependencies": {
90
- "@babel/core": "^7.25.7",
91
- "@babel/plugin-transform-typescript": "^7.25.7",
92
- "@babel/preset-typescript": "^7.25.7",
93
- "@babel/types": "^7.25.7",
94
- "@ember/test-helpers": "^4.0.4",
95
- "@ember/test-waiters": "^3.1.0",
96
- "@embroider/addon-dev": "^5.0.0",
97
- "@glimmer/compiler": "^0.92.0",
90
+ "@babel/core": "^7.26.9",
91
+ "@babel/plugin-transform-typescript": "^7.26.8",
92
+ "@babel/preset-typescript": "^7.26.0",
93
+ "@babel/types": "^7.26.9",
94
+ "@ember/test-helpers": "^5.1.0",
95
+ "@ember/test-waiters": "^4.0.0",
96
+ "@embroider/addon-dev": "^7.1.1",
97
+ "@glimmer/compiler": "^0.92.4",
98
98
  "@glimmer/component": "^2.0.0",
99
- "@glimmer/interfaces": "^0.92.0",
100
- "@glimmer/reference": "^0.92.0",
101
- "@glimmer/syntax": "^0.92.0",
99
+ "@glimmer/interfaces": "^0.94.5",
100
+ "@glimmer/reference": "^0.92.3",
101
+ "@glimmer/syntax": "^0.94.7",
102
102
  "@glimmer/tracking": "^1.1.2",
103
- "@glimmer/util": "^0.92.0",
104
- "@glint/core": "1.4.1-unstable.ff9ea6c",
105
- "@glint/environment-ember-loose": "1.4.1-unstable.ff9ea6c",
106
- "@glint/environment-ember-template-imports": "1.4.1-unstable.ff9ea6c",
107
- "@glint/template": "1.4.1-unstable.ff9ea6c",
108
- "@nullvoxpopuli/eslint-configs": "^4.0.0",
103
+ "@glimmer/util": "^0.94.6",
104
+ "@glint/core": "1.4.1-unstable.0e0d936",
105
+ "@glint/environment-ember-loose": "1.4.1-unstable.0e0d936",
106
+ "@glint/environment-ember-template-imports": "1.4.1-unstable.0e0d936",
107
+ "@glint/template": "1.4.1-unstable.0e0d936",
108
+ "@nullvoxpopuli/eslint-configs": "^5.0.0",
109
109
  "@rollup/plugin-babel": "^6.0.4",
110
- "@rollup/plugin-commonjs": "^28.0.0",
111
- "@tsconfig/ember": "^3.0.7",
110
+ "@rollup/plugin-commonjs": "^28.0.2",
111
+ "@tsconfig/ember": "^3.0.9",
112
112
  "@types/babel__core": "^7.20.5",
113
- "@types/babel__standalone": "^7.1.7",
114
- "@types/babel__traverse": "^7.20.4",
115
- "@types/hast": "^3.0.3",
113
+ "@types/babel__standalone": "^7.1.9",
114
+ "@types/babel__traverse": "^7.20.6",
115
+ "@types/hast": "^3.0.4",
116
116
  "@types/mdast": "^4.0.4",
117
- "@types/unist": "^3.0.2",
117
+ "@types/unist": "^3.0.3",
118
118
  "@types/uuid": "^10.0.0",
119
- "@typescript-eslint/eslint-plugin": "^8.8.0",
120
- "@typescript-eslint/parser": "^8.8.0",
121
- "concurrently": "^9.0.1",
119
+ "concurrently": "^9.1.2",
122
120
  "ember-resources": "^7.0.0",
123
- "ember-source": ">= 5.10.2",
124
- "ember-template-imports": "^4.1.2",
125
- "ember-template-lint": "^6.0.0",
126
- "eslint": "^8.55.0",
127
- "eslint-plugin-ember": "^12.2.1",
128
- "eslint-plugin-n": "^17.10.3",
129
- "eslint-plugin-prettier": "^5.2.1",
121
+ "ember-source": ">= 6.4.0-alpha.3",
122
+ "ember-template-imports": "^4.3.0",
123
+ "ember-template-lint": "^6.1.0",
124
+ "eslint": "^9.21.0",
130
125
  "execa": "^8.0.1",
131
- "prettier": "^3.3.3",
132
- "prettier-plugin-ember-template-tag": "2.0.2",
133
- "publint": "^0.2.6",
134
- "rollup": "~4.24.0",
126
+ "prettier": "^3.5.2",
127
+ "prettier-plugin-ember-template-tag": "2.0.4",
128
+ "publint": "^0.2.12",
129
+ "rollup": "~4.25.0",
135
130
  "rollup-plugin-copy": "^3.5.0",
136
- "typescript": "^5.4.5",
137
- "webpack": ">= 5.92.0",
138
- "@nullvoxpopuli/limber-untyped": "0.0.1"
131
+ "typescript": "5.7.3",
132
+ "webpack": "^5.98.0"
139
133
  },
140
134
  "volta": {
141
135
  "extends": "../../../package.json"
@@ -155,7 +149,7 @@
155
149
  "peerDependencies": {
156
150
  "@glimmer/compiler": ">= 0.86.0",
157
151
  "@glimmer/syntax": ">= 0.86.0",
158
- "@glint/template": "1.4.1-unstable.ff9ea6c",
152
+ "@glint/template": "1.4.1-unstable.0e0d936",
159
153
  "webpack": ">= 5.92.0"
160
154
  },
161
155
  "peerDependenciesMeta": {
@@ -178,8 +172,6 @@
178
172
  "lint:package": "pnpm publint",
179
173
  "lint:js": "pnpm -w exec lint js",
180
174
  "lint:js:fix": "pnpm -w exec lint js:fix",
181
- "lint:hbs": "pnpm -w exec lint hbs",
182
- "lint:hbs:fix": "pnpm -w exec lint hbs:fix",
183
175
  "lint:prettier:fix": "pnpm -w exec lint prettier:fix",
184
176
  "lint:prettier": "pnpm -w exec lint prettier"
185
177
  }
@@ -1,4 +1,3 @@
1
- /* eslint-disable @typescript-eslint/no-unused-vars */
2
1
  import { modules } from './known-modules.ts';
3
2
 
4
3
  import type Component from '@glimmer/component';
@@ -13,7 +12,7 @@ export function evalSnippet(
13
12
  const exports = {};
14
13
 
15
14
  function require(moduleName: keyof typeof modules): unknown {
16
- let preConfigured = modules[moduleName] || extraModules[moduleName];
15
+ const preConfigured = modules[moduleName] || extraModules[moduleName];
17
16
 
18
17
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
19
18
  // @ts-ignore
@@ -1,4 +1,6 @@
1
- import * as compiler from 'ember-template-compiler';
1
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
+ // @ts-ignore
3
+ import * as compiler from 'ember-source/dist/ember-template-compiler.js';
2
4
 
3
5
  import { nameFor } from '../../utils.ts';
4
6
  import { evalSnippet } from './eval.ts';
@@ -32,12 +34,12 @@ export async function compileJS(
32
34
  code: string,
33
35
  extraModules?: Record<string, unknown>
34
36
  ): Promise<CompileResult> {
35
- let name = nameFor(code);
37
+ const name = nameFor(code);
36
38
  let component: undefined | ComponentLike;
37
39
  let error: undefined | Error;
38
40
 
39
41
  try {
40
- let compiled = await transpile({ code: code, name });
42
+ const compiled = await transpile({ code: code, name });
41
43
 
42
44
  if (!compiled) {
43
45
  throw new Error(`Compiled output is missing`);
@@ -52,14 +54,14 @@ export async function compileJS(
52
54
  }
53
55
 
54
56
  async function transpile({ code: input, name }: Info) {
55
- let preprocessed = await preprocess(input, name);
56
- let result = await transform(preprocessed, name);
57
+ const preprocessed = await preprocess(input, name);
58
+ const result = await transform(preprocessed, name);
57
59
 
58
60
  if (!result) {
59
61
  return;
60
62
  }
61
63
 
62
- let { code } = result;
64
+ const { code } = result;
63
65
 
64
66
  return code;
65
67
  }
@@ -75,12 +77,12 @@ async function preprocess(input: string, name: string): Promise<string> {
75
77
  }
76
78
 
77
79
  if (!processor) {
78
- let { Preprocessor } = await fetchingPromise;
80
+ const { Preprocessor } = await fetchingPromise;
79
81
 
80
82
  processor = new Preprocessor();
81
83
  }
82
84
 
83
- let { code /* map */ } = processor.process(input, {
85
+ const { code /* map */ } = processor.process(input, {
84
86
  filename: `${name}.js`,
85
87
  inline_source_map: true,
86
88
  });
@@ -118,9 +120,9 @@ async function transform(
118
120
  : _emberTemplateCompilation;
119
121
 
120
122
  // so we have to use the default export (which is all the exports)
121
- let maybeBabel = (await import('@babel/standalone')) as any;
123
+ const maybeBabel = (await import('@babel/standalone')) as any;
122
124
  // Handle difference between vite and webpack in consuming projects...
123
- let babel: Babel = 'availablePlugins' in maybeBabel ? maybeBabel : maybeBabel.default;
125
+ const babel: Babel = 'availablePlugins' in maybeBabel ? maybeBabel : maybeBabel.default;
124
126
 
125
127
  return babel.transform(intermediate, {
126
128
  filename: `${name}.js`,
@@ -30,7 +30,7 @@ export const modules = {
30
30
  '@ember/array': _array,
31
31
  '@ember/component': _EmberComponent,
32
32
  '@ember/component/helper': _EmberComponentHelper,
33
- '@ember/component/template-only': _TO,
33
+ '@ember/component/template-only': Object.assign(_TO, { default: _TO }),
34
34
  '@ember/debug': _debug,
35
35
  '@ember/destroyable': _destroyable,
36
36
  '@ember/helper': _helpers,
@@ -1,4 +1,3 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
1
  // import { precompileJSON } from '@glimmer/compiler';
3
2
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
4
3
  // @ts-ignore
@@ -26,7 +25,7 @@ import type { ComponentLike } from '@glint/template';
26
25
  * (templates alone do not have a way to import / define complex structures)
27
26
  */
28
27
  export function compileHBS(template: string, options: CompileTemplateOptions = {}): CompileResult {
29
- let name = nameFor(template);
28
+ const name = nameFor(template);
30
29
  let component: undefined | ComponentLike;
31
30
  let error: undefined | Error;
32
31
 
@@ -59,10 +58,10 @@ interface CompileTemplateOptions {
59
58
  * which means that *everything* is undefined.
60
59
  */
61
60
  function compileTemplate(source: string, { moduleName, scope = {} }: CompileTemplateOptions) {
62
- let localScope = { array, concat, fn, get, hash, on, ...scope } as any;
63
- let locals = getTemplateLocals(source);
61
+ const localScope = { array, concat, fn, get, hash, on, ...scope } as any;
62
+ const locals = getTemplateLocals(source);
64
63
 
65
- let options = {
64
+ const options = {
66
65
  strictMode: true,
67
66
  moduleName,
68
67
  locals,
@@ -71,10 +70,10 @@ function compileTemplate(source: string, { moduleName, scope = {} }: CompileTemp
71
70
  };
72
71
 
73
72
  // Copied from @glimmer/compiler/lib/compiler#precompile
74
- let [block, usedLocals] = precompileJSON(source, options);
73
+ const [block, usedLocals] = precompileJSON(source, options);
75
74
 
76
- let usedScope = usedLocals.map((key: string) => {
77
- let value = localScope[key];
75
+ const usedScope = usedLocals.map((key: string) => {
76
+ const value = localScope[key];
78
77
 
79
78
  if (!value) {
80
79
  throw new Error(
@@ -86,8 +85,8 @@ function compileTemplate(source: string, { moduleName, scope = {} }: CompileTemp
86
85
  return value;
87
86
  });
88
87
 
89
- let blockJSON = JSON.stringify(block);
90
- let templateJSONObject = {
88
+ const blockJSON = JSON.stringify(block);
89
+ const templateJSONObject = {
91
90
  id: moduleName,
92
91
  block: blockJSON,
93
92
  moduleName: moduleName ?? '(dynamically compiled component)',
@@ -95,7 +94,7 @@ function compileTemplate(source: string, { moduleName, scope = {} }: CompileTemp
95
94
  isStrictMode: true,
96
95
  };
97
96
 
98
- let factory = createTemplateFactory(templateJSONObject);
97
+ const factory = createTemplateFactory(templateJSONObject);
99
98
 
100
99
  return factory;
101
100
  }