ember-repl 3.0.0-beta.3 → 3.0.0-beta.5

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 (91) hide show
  1. package/declarations/browser/cjs/eval.d.ts +9 -0
  2. package/declarations/browser/cjs/eval.d.ts.map +1 -0
  3. package/declarations/browser/cjs/index.d.ts +7 -0
  4. package/declarations/browser/cjs/index.d.ts.map +1 -0
  5. package/declarations/browser/compile/formats.d.ts +16 -0
  6. package/declarations/browser/compile/formats.d.ts.map +1 -0
  7. package/declarations/browser/compile/index.d.ts +52 -0
  8. package/declarations/browser/compile/index.d.ts.map +1 -0
  9. package/{dist → declarations}/browser/compile/markdown-to-ember.d.ts +5 -4
  10. package/declarations/browser/compile/markdown-to-ember.d.ts.map +1 -0
  11. package/declarations/browser/compile/types.d.ts +7 -0
  12. package/declarations/browser/compile/types.d.ts.map +1 -0
  13. package/declarations/browser/esm/index.d.ts +8 -0
  14. package/declarations/browser/esm/index.d.ts.map +1 -0
  15. package/{dist → declarations}/browser/eti/babel-plugin.d.ts +2 -2
  16. package/declarations/browser/eti/babel-plugin.d.ts.map +1 -0
  17. package/declarations/browser/eti/debug.d.ts +2 -0
  18. package/declarations/browser/eti/debug.d.ts.map +1 -0
  19. package/{dist → declarations}/browser/eti/parse-templates.d.ts +7 -7
  20. package/declarations/browser/eti/parse-templates.d.ts.map +1 -0
  21. package/{dist → declarations}/browser/eti/preprocess.d.ts +3 -2
  22. package/declarations/browser/eti/preprocess.d.ts.map +1 -0
  23. package/{dist → declarations}/browser/eti/template-tag-transform.d.ts +2 -2
  24. package/declarations/browser/eti/template-tag-transform.d.ts.map +1 -0
  25. package/declarations/browser/eti/util.d.ts +14 -0
  26. package/declarations/browser/eti/util.d.ts.map +1 -0
  27. package/declarations/browser/gjs.d.ts +4 -0
  28. package/declarations/browser/gjs.d.ts.map +1 -0
  29. package/{dist → declarations}/browser/hbs.d.ts +4 -3
  30. package/declarations/browser/hbs.d.ts.map +1 -0
  31. package/declarations/browser/index.d.ts +7 -0
  32. package/declarations/browser/index.d.ts.map +1 -0
  33. package/{dist → declarations}/browser/js.d.ts +3 -3
  34. package/declarations/browser/js.d.ts.map +1 -0
  35. package/{dist → declarations}/browser/known-modules.d.ts +6 -5
  36. package/declarations/browser/known-modules.d.ts.map +1 -0
  37. package/declarations/browser/types.d.ts +21 -0
  38. package/declarations/browser/types.d.ts.map +1 -0
  39. package/{dist → declarations}/browser/utils.d.ts +4 -4
  40. package/declarations/browser/utils.d.ts.map +1 -0
  41. package/declarations/test-support/index.d.ts +2 -0
  42. package/declarations/test-support/index.d.ts.map +1 -0
  43. package/dist/browser/cjs/eval.js.map +1 -1
  44. package/dist/browser/cjs/index.js.map +1 -1
  45. package/dist/browser/compile/formats.js.map +1 -1
  46. package/dist/browser/compile/index.js +18 -8
  47. package/dist/browser/compile/index.js.map +1 -1
  48. package/dist/browser/compile/markdown-to-ember.js +2 -2
  49. package/dist/browser/compile/markdown-to-ember.js.map +1 -1
  50. package/dist/browser/esm/index.js.map +1 -1
  51. package/dist/browser/eti/babel-plugin.js.map +1 -1
  52. package/dist/browser/eti/parse-templates.js.map +1 -1
  53. package/dist/browser/eti/preprocess.js +3 -167
  54. package/dist/browser/eti/preprocess.js.map +1 -1
  55. package/dist/browser/eti/template-tag-transform.js.map +1 -1
  56. package/dist/browser/eti/util.js.map +1 -1
  57. package/dist/browser/gjs.js.map +1 -1
  58. package/dist/browser/hbs.js +3 -0
  59. package/dist/browser/hbs.js.map +1 -1
  60. package/dist/browser/js.js.map +1 -1
  61. package/dist/test-support/index.js.map +1 -1
  62. package/package.json +79 -58
  63. package/src/browser/cjs/eval.ts +2 -2
  64. package/src/browser/cjs/index.ts +4 -4
  65. package/src/browser/compile/formats.ts +14 -11
  66. package/src/browser/compile/index.ts +81 -38
  67. package/src/browser/compile/markdown-to-ember.ts +5 -5
  68. package/src/browser/esm/index.ts +4 -4
  69. package/src/browser/eti/babel-plugin.ts +2 -2
  70. package/src/browser/eti/parse-templates.ts +2 -2
  71. package/src/browser/eti/preprocess.ts +3 -3
  72. package/src/browser/eti/template-tag-transform.ts +1 -1
  73. package/src/browser/eti/util.ts +1 -1
  74. package/src/browser/gjs.ts +4 -4
  75. package/src/browser/hbs.ts +2 -2
  76. package/src/browser/index.ts +5 -5
  77. package/src/browser/js.ts +3 -3
  78. package/src/test-support/index.ts +1 -1
  79. package/dist/browser/cjs/eval.d.ts +0 -10
  80. package/dist/browser/cjs/eval.d.ts.map +0 -1
  81. package/dist/browser/cjs/index.d.ts +0 -7
  82. package/dist/browser/compile/formats.d.ts +0 -16
  83. package/dist/browser/compile/index.d.ts +0 -33
  84. package/dist/browser/compile/types.d.ts +0 -7
  85. package/dist/browser/esm/index.d.ts +0 -8
  86. package/dist/browser/eti/debug.d.ts +0 -2
  87. package/dist/browser/eti/util.d.ts +0 -14
  88. package/dist/browser/gjs.d.ts +0 -4
  89. package/dist/browser/index.d.ts +0 -6
  90. package/dist/browser/types.d.ts +0 -21
  91. package/dist/test-support/index.d.ts +0 -2
@@ -1 +1 @@
1
- {"version":3,"file":"gjs.js","sources":["../../src/browser/gjs.ts"],"sourcesContent":["import { importSync } from '@embroider/macros';\n\nimport babelPluginEmberTemplateCompilation from 'babel-plugin-ember-template-compilation';\n\n// TODO: use real packages, and not these copied files from ember-template-imports\nimport babelPluginIntermediateGJS from './eti/babel-plugin';\nimport { preprocessEmbeddedTemplates } from './eti/preprocess';\nimport { TEMPLATE_TAG_NAME, TEMPLATE_TAG_PLACEHOLDER } from './eti/util';\n\nimport type { Babel } from './types';\n\nconst compiler = importSync('ember-source/dist/ember-template-compiler.js');\n\nexport function preprocess(input: string, name: string) {\n let preprocessed = preprocessEmbeddedTemplates(input, {\n relativePath: `${name}.js`,\n includeSourceMaps: false,\n includeTemplateTokens: true,\n templateTag: TEMPLATE_TAG_NAME,\n templateTagReplacement: TEMPLATE_TAG_PLACEHOLDER,\n });\n\n return preprocessed.output;\n}\n\nexport async function transform(\n intermediate: string,\n name: string,\n options: any = {}\n): Promise<ReturnType<Babel['transform']>> {\n let babel = (await import('@babel/standalone')) as Babel;\n\n return babel.transform(intermediate, {\n filename: `${name}.js`,\n plugins: [\n [babelPluginIntermediateGJS],\n [\n babelPluginEmberTemplateCompilation,\n {\n compiler,\n },\n ],\n [babel.availablePlugins['proposal-decorators'], { legacy: true }],\n [babel.availablePlugins['proposal-class-properties']],\n ],\n presets: [\n [\n babel.availablePresets['env'],\n {\n // false -- keeps ES Modules\n modules: 'cjs',\n targets: { esmodules: true },\n forceAllTransforms: false,\n ...options,\n },\n ],\n ],\n });\n}\n"],"names":["compiler","importSync","preprocess","input","name","preprocessed","preprocessEmbeddedTemplates","relativePath","includeSourceMaps","includeTemplateTokens","templateTag","TEMPLATE_TAG_NAME","templateTagReplacement","TEMPLATE_TAG_PLACEHOLDER","output","transform","intermediate","options","babel","filename","plugins","babelPluginIntermediateGJS","babelPluginEmberTemplateCompilation","availablePlugins","legacy","presets","availablePresets","modules","targets","esmodules","forceAllTransforms"],"mappings":";;;;;;AAWA,MAAMA,QAAQ,GAAGC,UAAU,CAAC,8CAA8C,CAAC,CAAA;AAEpE,SAASC,UAAUA,CAACC,KAAa,EAAEC,IAAY,EAAE;AACtD,EAAA,IAAIC,YAAY,GAAGC,2BAA2B,CAACH,KAAK,EAAE;IACpDI,YAAY,EAAG,CAAEH,EAAAA,IAAK,CAAI,GAAA,CAAA;AAC1BI,IAAAA,iBAAiB,EAAE,KAAK;AACxBC,IAAAA,qBAAqB,EAAE,IAAI;AAC3BC,IAAAA,WAAW,EAAEC,iBAAiB;AAC9BC,IAAAA,sBAAsB,EAAEC,wBAAAA;AAC1B,GAAC,CAAC,CAAA;EAEF,OAAOR,YAAY,CAACS,MAAM,CAAA;AAC5B,CAAA;AAEO,eAAeC,SAASA,CAC7BC,YAAoB,EACpBZ,IAAY,EACZa,OAAY,GAAG,EAAE,EACwB;AACzC,EAAA,IAAIC,KAAK,GAAI,MAAM,OAAO,mBAAmB,CAAW,CAAA;AAExD,EAAA,OAAOA,KAAK,CAACH,SAAS,CAACC,YAAY,EAAE;IACnCG,QAAQ,EAAG,CAAEf,EAAAA,IAAK,CAAI,GAAA,CAAA;IACtBgB,OAAO,EAAE,CACP,CAACC,0BAA0B,CAAC,EAC5B,CACEC,mCAAmC,EACnC;AACEtB,MAAAA,QAAAA;KACD,CACF,EACD,CAACkB,KAAK,CAACK,gBAAgB,CAAC,qBAAqB,CAAC,EAAE;AAAEC,MAAAA,MAAM,EAAE,IAAA;KAAM,CAAC,EACjE,CAACN,KAAK,CAACK,gBAAgB,CAAC,2BAA2B,CAAC,CAAC,CACtD;IACDE,OAAO,EAAE,CACP,CACEP,KAAK,CAACQ,gBAAgB,CAAC,KAAK,CAAC,EAC7B;AACE;AACAC,MAAAA,OAAO,EAAE,KAAK;AACdC,MAAAA,OAAO,EAAE;AAAEC,QAAAA,SAAS,EAAE,IAAA;OAAM;AAC5BC,MAAAA,kBAAkB,EAAE,KAAK;MACzB,GAAGb,OAAAA;AACL,KAAC,CACF,CAAA;AAEL,GAAC,CAAC,CAAA;AACJ;;;;"}
1
+ {"version":3,"file":"gjs.js","sources":["../../src/browser/gjs.ts"],"sourcesContent":["import { importSync } from '@embroider/macros';\n\nimport babelPluginEmberTemplateCompilation from 'babel-plugin-ember-template-compilation';\n\n// TODO: use real packages, and not these copied files from ember-template-imports\nimport babelPluginIntermediateGJS from './eti/babel-plugin.ts';\nimport { preprocessEmbeddedTemplates } from './eti/preprocess.ts';\nimport { TEMPLATE_TAG_NAME, TEMPLATE_TAG_PLACEHOLDER } from './eti/util.ts';\n\nimport type { Babel } from './types.ts';\n\nconst compiler = importSync('ember-source/dist/ember-template-compiler.js');\n\nexport function preprocess(input: string, name: string) {\n let preprocessed = preprocessEmbeddedTemplates(input, {\n relativePath: `${name}.js`,\n includeSourceMaps: false,\n includeTemplateTokens: true,\n templateTag: TEMPLATE_TAG_NAME,\n templateTagReplacement: TEMPLATE_TAG_PLACEHOLDER,\n });\n\n return preprocessed.output;\n}\n\nexport async function transform(\n intermediate: string,\n name: string,\n options: any = {}\n): Promise<ReturnType<Babel['transform']>> {\n let babel = (await import('@babel/standalone')) as Babel;\n\n return babel.transform(intermediate, {\n filename: `${name}.js`,\n plugins: [\n [babelPluginIntermediateGJS],\n [\n babelPluginEmberTemplateCompilation,\n {\n compiler,\n },\n ],\n [babel.availablePlugins['proposal-decorators'], { legacy: true }],\n [babel.availablePlugins['proposal-class-properties']],\n ],\n presets: [\n [\n babel.availablePresets['env'],\n {\n // false -- keeps ES Modules\n modules: 'cjs',\n targets: { esmodules: true },\n forceAllTransforms: false,\n ...options,\n },\n ],\n ],\n });\n}\n"],"names":["compiler","importSync","preprocess","input","name","preprocessed","preprocessEmbeddedTemplates","relativePath","includeSourceMaps","includeTemplateTokens","templateTag","TEMPLATE_TAG_NAME","templateTagReplacement","TEMPLATE_TAG_PLACEHOLDER","output","transform","intermediate","options","babel","filename","plugins","babelPluginIntermediateGJS","babelPluginEmberTemplateCompilation","availablePlugins","legacy","presets","availablePresets","modules","targets","esmodules","forceAllTransforms"],"mappings":";;;;;;AAWA,MAAMA,QAAQ,GAAGC,UAAU,CAAC,8CAA8C,CAAC,CAAA;AAEpE,SAASC,UAAUA,CAACC,KAAa,EAAEC,IAAY,EAAE;AACtD,EAAA,IAAIC,YAAY,GAAGC,2BAA2B,CAACH,KAAK,EAAE;IACpDI,YAAY,EAAG,CAAEH,EAAAA,IAAK,CAAI,GAAA,CAAA;AAC1BI,IAAAA,iBAAiB,EAAE,KAAK;AACxBC,IAAAA,qBAAqB,EAAE,IAAI;AAC3BC,IAAAA,WAAW,EAAEC,iBAAiB;AAC9BC,IAAAA,sBAAsB,EAAEC,wBAAAA;AAC1B,GAAC,CAAC,CAAA;EAEF,OAAOR,YAAY,CAACS,MAAM,CAAA;AAC5B,CAAA;AAEO,eAAeC,SAASA,CAC7BC,YAAoB,EACpBZ,IAAY,EACZa,OAAY,GAAG,EAAE,EACwB;AACzC,EAAA,IAAIC,KAAK,GAAI,MAAM,OAAO,mBAAmB,CAAW,CAAA;AAExD,EAAA,OAAOA,KAAK,CAACH,SAAS,CAACC,YAAY,EAAE;IACnCG,QAAQ,EAAG,CAAEf,EAAAA,IAAK,CAAI,GAAA,CAAA;IACtBgB,OAAO,EAAE,CACP,CAACC,0BAA0B,CAAC,EAC5B,CACEC,mCAAmC,EACnC;AACEtB,MAAAA,QAAAA;KACD,CACF,EACD,CAACkB,KAAK,CAACK,gBAAgB,CAAC,qBAAqB,CAAC,EAAE;AAAEC,MAAAA,MAAM,EAAE,IAAA;KAAM,CAAC,EACjE,CAACN,KAAK,CAACK,gBAAgB,CAAC,2BAA2B,CAAC,CAAC,CACtD;IACDE,OAAO,EAAE,CACP,CACEP,KAAK,CAACQ,gBAAgB,CAAC,KAAK,CAAC,EAC7B;AACE;AACAC,MAAAA,OAAO,EAAE,KAAK;AACdC,MAAAA,OAAO,EAAE;AAAEC,QAAAA,SAAS,EAAE,IAAA;OAAM;AAC5BC,MAAAA,kBAAkB,EAAE,KAAK;MACzB,GAAGb,OAAAA;AACL,KAAC,CACF,CAAA;AAEL,GAAC,CAAC,CAAA;AACJ;;;;"}
@@ -7,6 +7,9 @@ import { importSync } from '@embroider/macros';
7
7
  import { nameFor } from './utils.js';
8
8
 
9
9
  /* eslint-disable @typescript-eslint/no-explicit-any */
10
+ // import { precompileJSON } from '@glimmer/compiler';
11
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
12
+ // @ts-ignore
10
13
  // These things are pre-bundled in the old system.
11
14
  // ember-template-compiler defines them in AMD/requirejs
12
15
  const {
@@ -1 +1 @@
1
- {"version":3,"file":"hbs.js","sources":["../../src/browser/hbs.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n// import { precompileJSON } from '@glimmer/compiler';\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { setComponentTemplate } from '@ember/component';\nimport templateOnlyComponent from '@ember/component/template-only';\nimport { array, concat, fn, get, hash } from '@ember/helper';\nimport { on } from '@ember/modifier';\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { createTemplateFactory } from '@ember/template-factory';\nimport { importSync } from '@embroider/macros';\n\nimport { nameFor } from './utils';\n\nimport type { CompileResult } from './types';\nimport type { ComponentLike } from '@glint/template';\n\n// These things are pre-bundled in the old system.\n// ember-template-compiler defines them in AMD/requirejs\nconst { precompileJSON } = importSync('@glimmer/compiler') as any;\nconst { getTemplateLocals } = importSync('@glimmer/syntax') as any;\n\n/**\n * compile a template with an empty scope\n * to use components, helpers, etc, you will need to compile with JS\n *\n * (templates alone do not have a way to import / define complex structures)\n */\nexport function compileHBS(template: string, options: CompileTemplateOptions = {}): CompileResult {\n let name = nameFor(template);\n let component: undefined | ComponentLike;\n let error: undefined | Error;\n\n try {\n component = setComponentTemplate(\n compileTemplate(template, { moduleName: options.moduleName || name, ...options }),\n templateOnlyComponent(options.moduleName || name)\n ) as ComponentLike;\n } catch (e) {\n error = e as Error | undefined;\n }\n\n return { name, component, error };\n}\n\ninterface CompileTemplateOptions {\n /**\n * Used for debug viewing\n */\n moduleName?: string;\n scope?: Record<string, unknown>;\n}\n\n/**\n * The reason why we can't use precompile directly is because of this:\n * https://github.com/glimmerjs/glimmer-vm/blob/master/packages/%40glimmer/compiler/lib/compiler.ts#L132\n *\n * Support for dynamically compiling templates in strict mode doesn't seem to be fully their yet.\n * That JSON.stringify (and the lines after) prevent us from easily setting the scope function,\n * which means that *everything* is undefined.\n */\nfunction compileTemplate(source: string, { moduleName, scope = {} }: CompileTemplateOptions) {\n let localScope = { array, concat, fn, get, hash, on, ...scope } as any;\n let locals = getTemplateLocals(source);\n\n let options = {\n strictMode: true,\n moduleName,\n locals,\n isProduction: false,\n meta: { moduleName },\n };\n\n // Copied from @glimmer/compiler/lib/compiler#precompile\n let [block, usedLocals] = precompileJSON(source, options);\n\n let usedScope = usedLocals.map((key: string) => localScope[key]);\n\n let blockJSON = JSON.stringify(block);\n let templateJSONObject = {\n id: moduleName,\n block: blockJSON,\n moduleName: moduleName ?? '(unknown template module)',\n scope: () => usedScope,\n isStrictMode: true,\n };\n\n let factory = createTemplateFactory(templateJSONObject);\n\n return factory;\n}\n"],"names":["precompileJSON","importSync","getTemplateLocals","compileHBS","template","options","name","nameFor","component","error","setComponentTemplate","compileTemplate","moduleName","templateOnlyComponent","e","source","scope","localScope","array","concat","fn","get","hash","on","locals","strictMode","isProduction","meta","block","usedLocals","usedScope","map","key","blockJSON","JSON","stringify","templateJSONObject","id","isStrictMode","factory","createTemplateFactory"],"mappings":";;;;;;;;AAAA;AAkBA;AACA;AACA,MAAM;AAAEA,EAAAA,cAAAA;AAAe,CAAC,GAAGC,UAAU,CAAC,mBAAmB,CAAQ,CAAA;AACjE,MAAM;AAAEC,EAAAA,iBAAAA;AAAkB,CAAC,GAAGD,UAAU,CAAC,iBAAiB,CAAQ,CAAA;;AAElE;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,UAAUA,CAACC,QAAgB,EAAEC,OAA+B,GAAG,EAAE,EAAiB;AAChG,EAAA,IAAIC,IAAI,GAAGC,OAAO,CAACH,QAAQ,CAAC,CAAA;AAC5B,EAAA,IAAII,SAAoC,CAAA;AACxC,EAAA,IAAIC,KAAwB,CAAA;EAE5B,IAAI;AACFD,IAAAA,SAAS,GAAGE,oBAAoB,CAC9BC,eAAe,CAACP,QAAQ,EAAE;AAAEQ,MAAAA,UAAU,EAAEP,OAAO,CAACO,UAAU,IAAIN,IAAI;MAAE,GAAGD,OAAAA;KAAS,CAAC,EACjFQ,GAAqB,CAACR,OAAO,CAACO,UAAU,IAAIN,IAAI,CAClD,CAAkB,CAAA;GACnB,CAAC,OAAOQ,CAAC,EAAE;AACVL,IAAAA,KAAK,GAAGK,CAAsB,CAAA;AAChC,GAAA;EAEA,OAAO;IAAER,IAAI;IAAEE,SAAS;AAAEC,IAAAA,KAAAA;GAAO,CAAA;AACnC,CAAA;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASE,eAAeA,CAACI,MAAc,EAAE;EAAEH,UAAU;AAAEI,EAAAA,KAAK,GAAG,EAAC;AAA0B,CAAC,EAAE;AAC3F,EAAA,IAAIC,UAAU,GAAG;IAAEC,KAAK;IAAEC,MAAM;IAAEC,EAAE;IAAEC,GAAG;IAAEC,IAAI;IAAEC,EAAE;IAAE,GAAGP,KAAAA;GAAc,CAAA;AACtE,EAAA,IAAIQ,MAAM,GAAGtB,iBAAiB,CAACa,MAAM,CAAC,CAAA;AAEtC,EAAA,IAAIV,OAAO,GAAG;AACZoB,IAAAA,UAAU,EAAE,IAAI;IAChBb,UAAU;IACVY,MAAM;AACNE,IAAAA,YAAY,EAAE,KAAK;AACnBC,IAAAA,IAAI,EAAE;AAAEf,MAAAA,UAAAA;AAAW,KAAA;GACpB,CAAA;;AAED;EACA,IAAI,CAACgB,KAAK,EAAEC,UAAU,CAAC,GAAG7B,cAAc,CAACe,MAAM,EAAEV,OAAO,CAAC,CAAA;AAEzD,EAAA,IAAIyB,SAAS,GAAGD,UAAU,CAACE,GAAG,CAAEC,GAAW,IAAKf,UAAU,CAACe,GAAG,CAAC,CAAC,CAAA;AAEhE,EAAA,IAAIC,SAAS,GAAGC,IAAI,CAACC,SAAS,CAACP,KAAK,CAAC,CAAA;AACrC,EAAA,IAAIQ,kBAAkB,GAAG;AACvBC,IAAAA,EAAE,EAAEzB,UAAU;AACdgB,IAAAA,KAAK,EAAEK,SAAS;IAChBrB,UAAU,EAAEA,UAAU,IAAI,2BAA2B;IACrDI,KAAK,EAAEA,MAAMc,SAAS;AACtBQ,IAAAA,YAAY,EAAE,IAAA;GACf,CAAA;AAED,EAAA,IAAIC,OAAO,GAAGC,qBAAqB,CAACJ,kBAAkB,CAAC,CAAA;AAEvD,EAAA,OAAOG,OAAO,CAAA;AAChB;;;;"}
1
+ {"version":3,"file":"hbs.js","sources":["../../src/browser/hbs.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n// import { precompileJSON } from '@glimmer/compiler';\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { setComponentTemplate } from '@ember/component';\nimport templateOnlyComponent from '@ember/component/template-only';\nimport { array, concat, fn, get, hash } from '@ember/helper';\nimport { on } from '@ember/modifier';\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { createTemplateFactory } from '@ember/template-factory';\nimport { importSync } from '@embroider/macros';\n\nimport { nameFor } from './utils.ts';\n\nimport type { CompileResult } from './types.ts';\nimport type { ComponentLike } from '@glint/template';\n\n// These things are pre-bundled in the old system.\n// ember-template-compiler defines them in AMD/requirejs\nconst { precompileJSON } = importSync('@glimmer/compiler') as any;\nconst { getTemplateLocals } = importSync('@glimmer/syntax') as any;\n\n/**\n * compile a template with an empty scope\n * to use components, helpers, etc, you will need to compile with JS\n *\n * (templates alone do not have a way to import / define complex structures)\n */\nexport function compileHBS(template: string, options: CompileTemplateOptions = {}): CompileResult {\n let name = nameFor(template);\n let component: undefined | ComponentLike;\n let error: undefined | Error;\n\n try {\n component = setComponentTemplate(\n compileTemplate(template, { moduleName: options.moduleName || name, ...options }),\n templateOnlyComponent(options.moduleName || name)\n ) as ComponentLike;\n } catch (e) {\n error = e as Error | undefined;\n }\n\n return { name, component, error };\n}\n\ninterface CompileTemplateOptions {\n /**\n * Used for debug viewing\n */\n moduleName?: string;\n scope?: Record<string, unknown>;\n}\n\n/**\n * The reason why we can't use precompile directly is because of this:\n * https://github.com/glimmerjs/glimmer-vm/blob/master/packages/%40glimmer/compiler/lib/compiler.ts#L132\n *\n * Support for dynamically compiling templates in strict mode doesn't seem to be fully their yet.\n * That JSON.stringify (and the lines after) prevent us from easily setting the scope function,\n * which means that *everything* is undefined.\n */\nfunction compileTemplate(source: string, { moduleName, scope = {} }: CompileTemplateOptions) {\n let localScope = { array, concat, fn, get, hash, on, ...scope } as any;\n let locals = getTemplateLocals(source);\n\n let options = {\n strictMode: true,\n moduleName,\n locals,\n isProduction: false,\n meta: { moduleName },\n };\n\n // Copied from @glimmer/compiler/lib/compiler#precompile\n let [block, usedLocals] = precompileJSON(source, options);\n\n let usedScope = usedLocals.map((key: string) => localScope[key]);\n\n let blockJSON = JSON.stringify(block);\n let templateJSONObject = {\n id: moduleName,\n block: blockJSON,\n moduleName: moduleName ?? '(unknown template module)',\n scope: () => usedScope,\n isStrictMode: true,\n };\n\n let factory = createTemplateFactory(templateJSONObject);\n\n return factory;\n}\n"],"names":["precompileJSON","importSync","getTemplateLocals","compileHBS","template","options","name","nameFor","component","error","setComponentTemplate","compileTemplate","moduleName","templateOnlyComponent","e","source","scope","localScope","array","concat","fn","get","hash","on","locals","strictMode","isProduction","meta","block","usedLocals","usedScope","map","key","blockJSON","JSON","stringify","templateJSONObject","id","isStrictMode","factory","createTemplateFactory"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AAeA;AACA;AACA,MAAM;AAAEA,EAAAA,cAAAA;AAAe,CAAC,GAAGC,UAAU,CAAC,mBAAmB,CAAQ,CAAA;AACjE,MAAM;AAAEC,EAAAA,iBAAAA;AAAkB,CAAC,GAAGD,UAAU,CAAC,iBAAiB,CAAQ,CAAA;;AAElE;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,UAAUA,CAACC,QAAgB,EAAEC,OAA+B,GAAG,EAAE,EAAiB;AAChG,EAAA,IAAIC,IAAI,GAAGC,OAAO,CAACH,QAAQ,CAAC,CAAA;AAC5B,EAAA,IAAII,SAAoC,CAAA;AACxC,EAAA,IAAIC,KAAwB,CAAA;EAE5B,IAAI;AACFD,IAAAA,SAAS,GAAGE,oBAAoB,CAC9BC,eAAe,CAACP,QAAQ,EAAE;AAAEQ,MAAAA,UAAU,EAAEP,OAAO,CAACO,UAAU,IAAIN,IAAI;MAAE,GAAGD,OAAAA;KAAS,CAAC,EACjFQ,GAAqB,CAACR,OAAO,CAACO,UAAU,IAAIN,IAAI,CAClD,CAAkB,CAAA;GACnB,CAAC,OAAOQ,CAAC,EAAE;AACVL,IAAAA,KAAK,GAAGK,CAAsB,CAAA;AAChC,GAAA;EAEA,OAAO;IAAER,IAAI;IAAEE,SAAS;AAAEC,IAAAA,KAAAA;GAAO,CAAA;AACnC,CAAA;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASE,eAAeA,CAACI,MAAc,EAAE;EAAEH,UAAU;AAAEI,EAAAA,KAAK,GAAG,EAAC;AAA0B,CAAC,EAAE;AAC3F,EAAA,IAAIC,UAAU,GAAG;IAAEC,KAAK;IAAEC,MAAM;IAAEC,EAAE;IAAEC,GAAG;IAAEC,IAAI;IAAEC,EAAE;IAAE,GAAGP,KAAAA;GAAc,CAAA;AACtE,EAAA,IAAIQ,MAAM,GAAGtB,iBAAiB,CAACa,MAAM,CAAC,CAAA;AAEtC,EAAA,IAAIV,OAAO,GAAG;AACZoB,IAAAA,UAAU,EAAE,IAAI;IAChBb,UAAU;IACVY,MAAM;AACNE,IAAAA,YAAY,EAAE,KAAK;AACnBC,IAAAA,IAAI,EAAE;AAAEf,MAAAA,UAAAA;AAAW,KAAA;GACpB,CAAA;;AAED;EACA,IAAI,CAACgB,KAAK,EAAEC,UAAU,CAAC,GAAG7B,cAAc,CAACe,MAAM,EAAEV,OAAO,CAAC,CAAA;AAEzD,EAAA,IAAIyB,SAAS,GAAGD,UAAU,CAACE,GAAG,CAAEC,GAAW,IAAKf,UAAU,CAACe,GAAG,CAAC,CAAC,CAAA;AAEhE,EAAA,IAAIC,SAAS,GAAGC,IAAI,CAACC,SAAS,CAACP,KAAK,CAAC,CAAA;AACrC,EAAA,IAAIQ,kBAAkB,GAAG;AACvBC,IAAAA,EAAE,EAAEzB,UAAU;AACdgB,IAAAA,KAAK,EAAEK,SAAS;IAChBrB,UAAU,EAAEA,UAAU,IAAI,2BAA2B;IACrDI,KAAK,EAAEA,MAAMc,SAAS;AACtBQ,IAAAA,YAAY,EAAE,IAAA;GACf,CAAA;AAED,EAAA,IAAIC,OAAO,GAAGC,qBAAqB,CAACJ,kBAAkB,CAAC,CAAA;AAEvD,EAAA,OAAOG,OAAO,CAAA;AAChB;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"js.js","sources":["../../src/browser/js.ts"],"sourcesContent":["import { compileJS as compileAMD } from './cjs';\nimport { compileJS as compileESM } from './esm';\n\nimport type { CompileResult, ExtraModules, Options } from './types';\n\n/**\n * @public\n * Transpiles GlimmerJS (*.gjs) formatted text into and evaluates as a JS Module.\n * The returned component can be invoked explicitly in the consuming project.\n *\n * SEE: README for example usage\n *\n * @param {string} code: the code to be compiled\n * @param {Object} extraModules: map of import paths to modules. This isn't needed\n * for classic ember projects, but for strict static ember projects, extraModules\n * will need to be pasesd if compileJS is intended to be used in a styleguide or\n * if there are additional modules that could be imported in the passed `code`.\n *\n * Later on, imports that are not present by default (ember/glimmer) or that\n * are not provided by extraModules will be searched on npm to see if a package\n * needs to be downloaded before running the `code` / invoking the component\n */\nexport function compileJS(\n code: string,\n extraModules?: ExtraModules,\n options?: Options\n): Promise<CompileResult> {\n if (options?.skypack) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n // if (!(window as any).webpackChunkDummy) {\n // return {\n // component: undefined,\n // name: undefined,\n // error: `Your environment is using AMD utilities -- using native ESM is not allowed unless the environment is also ESM`,\n // };\n // }\n\n return compileESM(code, extraModules);\n }\n\n return compileAMD(code, extraModules);\n}\n"],"names":["compileJS","code","extraModules","options","skypack","compileESM","compileAMD"],"mappings":";;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,SAASA,CACvBC,IAAY,EACZC,YAA2B,EAC3BC,OAAiB,EACO;EACxB,IAAIA,OAAO,EAAEC,OAAO,EAAE;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,IAAA,OAAOC,WAAU,CAACJ,IAAI,EAAEC,YAAY,CAAC,CAAA;AACvC,GAAA;AAEA,EAAA,OAAOI,WAAU,CAACL,IAAI,EAAEC,YAAY,CAAC,CAAA;AACvC;;;;"}
1
+ {"version":3,"file":"js.js","sources":["../../src/browser/js.ts"],"sourcesContent":["import { compileJS as compileAMD } from './cjs/index.ts';\nimport { compileJS as compileESM } from './esm/index.ts';\n\nimport type { CompileResult, ExtraModules, Options } from './types.ts';\n\n/**\n * @public\n * Transpiles GlimmerJS (*.gjs) formatted text into and evaluates as a JS Module.\n * The returned component can be invoked explicitly in the consuming project.\n *\n * SEE: README for example usage\n *\n * @param {string} code: the code to be compiled\n * @param {Object} extraModules: map of import paths to modules. This isn't needed\n * for classic ember projects, but for strict static ember projects, extraModules\n * will need to be pasesd if compileJS is intended to be used in a styleguide or\n * if there are additional modules that could be imported in the passed `code`.\n *\n * Later on, imports that are not present by default (ember/glimmer) or that\n * are not provided by extraModules will be searched on npm to see if a package\n * needs to be downloaded before running the `code` / invoking the component\n */\nexport function compileJS(\n code: string,\n extraModules?: ExtraModules,\n options?: Options\n): Promise<CompileResult> {\n if (options?.skypack) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n // if (!(window as any).webpackChunkDummy) {\n // return {\n // component: undefined,\n // name: undefined,\n // error: `Your environment is using AMD utilities -- using native ESM is not allowed unless the environment is also ESM`,\n // };\n // }\n\n return compileESM(code, extraModules);\n }\n\n return compileAMD(code, extraModules);\n}\n"],"names":["compileJS","code","extraModules","options","skypack","compileESM","compileAMD"],"mappings":";;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,SAASA,CACvBC,IAAY,EACZC,YAA2B,EAC3BC,OAAiB,EACO;EACxB,IAAIA,OAAO,EAAEC,OAAO,EAAE;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,IAAA,OAAOC,WAAU,CAACJ,IAAI,EAAEC,YAAY,CAAC,CAAA;AACvC,GAAA;AAEA,EAAA,OAAOI,WAAU,CAACL,IAAI,EAAEC,YAAY,CAAC,CAAA;AACvC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/test-support/index.ts"],"sourcesContent":["import { CACHE } from '../browser/compile/index';\n\nexport function clearCompileCache() {\n CACHE.clear();\n}\n"],"names":["clearCompileCache","CACHE","clear"],"mappings":";;AAEO,SAASA,iBAAiBA,GAAG;EAClCC,KAAK,CAACC,KAAK,EAAE,CAAA;AACf;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/test-support/index.ts"],"sourcesContent":["import { CACHE } from '../browser/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,CAAA;AACf;;;;"}
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "ember-repl",
3
- "version": "3.0.0-beta.3",
3
+ "version": "3.0.0-beta.5",
4
4
  "description": "Addon for enabling REPL and Playground creation with Ember/Glimmer",
5
5
  "keywords": [
6
6
  "ember-addon"
7
7
  ],
8
8
  "repository": {
9
- "type": "https",
10
- "url": "https://github.com/NullVoxPopuli/limber",
9
+ "type": "git",
10
+ "url": "https://github.com/NullVoxPopuli/limber.git",
11
11
  "directory": "packages/ember-repl/addon"
12
12
  },
13
13
  "license": "MIT",
@@ -15,62 +15,76 @@
15
15
  "typesVersions": {
16
16
  "*": {
17
17
  "test-support": [
18
- "dist/test-support/index.d.ts"
18
+ "declarations/test-support/index.d.ts"
19
19
  ],
20
20
  "markdown/parse": [
21
- "./dist/browser/compile/markdown-to-ember.d.ts"
21
+ "./declarations/browser/compile/markdown-to-ember.d.ts"
22
22
  ],
23
23
  "*": [
24
- "dist/browser/*",
25
- "dist/browser/*/index.d.ts"
24
+ "declarations/browser/*",
25
+ "declarations/browser/*/index.d.ts"
26
26
  ]
27
27
  }
28
28
  },
29
29
  "exports": {
30
- ".": "./dist/browser/index.js",
31
- "./esm": "./dist/browser/esm/index.js",
32
- "./markdown/parse": "./dist/browser/compile/markdown-to-ember.js",
30
+ ".": {
31
+ "types": "./declarations/browser/index.d.ts",
32
+ "default": "./dist/browser/index.js"
33
+ },
34
+ "./esm": {
35
+ "types": "./declarations/browser/esm/index.d.ts",
36
+ "default": "./dist/browser/esm/index.js"
37
+ },
38
+ "./markdown/parse": {
39
+ "types": "./declarations/browser/compile/markdown-to-ember.d.ts",
40
+ "default": "./dist/browser/compile/markdown-to-ember.js"
41
+ },
33
42
  "./ember-cli": {
34
43
  "require": "./src/build/ember-cli.cjs"
35
44
  },
36
- "./test-support": "./dist/test-support/index.js",
45
+ "./test-support": {
46
+ "types": "./declarations/test-support/index.d.ts",
47
+ "default": "./dist/test-support/index.js"
48
+ },
37
49
  "./addon-main.js": "./addon-main.cjs"
38
50
  },
39
51
  "files": [
40
52
  "src",
41
53
  "dist",
54
+ "declarations",
42
55
  "addon-main.cjs"
43
56
  ],
44
57
  "dependencies": {
45
- "@babel/helper-plugin-utils": "^7.21.5",
46
- "@babel/standalone": "^7.21.8",
47
- "@embroider/addon-shim": "1.8.5",
48
- "@embroider/macros": "1.11.0",
49
- "babel-import-util": "^1.3.0",
50
- "babel-plugin-ember-template-compilation": "^2.0.3",
58
+ "@babel/helper-plugin-utils": "^7.22.5",
59
+ "@babel/standalone": "^7.22.10",
60
+ "@embroider/addon-shim": "1.8.6",
61
+ "@embroider/macros": "1.13.1",
62
+ "babel-import-util": "^1.4.1",
63
+ "babel-plugin-ember-template-compilation": "^2.2.0",
51
64
  "broccoli-file-creator": "^2.1.1",
52
65
  "change-case": "^4.1.2",
53
66
  "common-tags": "^1.8.2",
54
67
  "line-column": "^1.0.2",
55
- "magic-string": "^0.30.0",
68
+ "magic-string": "^0.30.2",
56
69
  "mdast": "^3.0.0",
57
70
  "parse-static-imports": "^1.1.0",
58
71
  "rehype-raw": "^6.1.1",
59
- "rehype-stringify": "^9.0.3",
72
+ "rehype-stringify": "^9.0.4",
60
73
  "remark-gfm": "^3.0.1",
61
74
  "remark-parse": "^10.0.2",
62
75
  "remark-rehype": "^10.1.0",
63
76
  "unified": "^10.1.2",
64
- "unist-util-visit": "^4.1.2",
77
+ "unist-util-visit": "^5.0.0",
65
78
  "uuid": "^9.0.0",
66
- "vfile": "^5.3.7"
79
+ "vfile": "^6.0.1"
67
80
  },
68
81
  "devDependencies": {
69
- "@babel/core": "^7.21.8",
70
- "@babel/types": "^7.21.5",
71
- "@ember/test-helpers": "^2.9.3",
82
+ "@babel/core": "^7.22.10",
83
+ "@babel/preset-typescript": "^7.22.5",
84
+ "@babel/types": "^7.22.10",
85
+ "@ember/test-helpers": "^3.2.0",
72
86
  "@ember/test-waiters": "^3.0.2",
73
- "@embroider/addon-dev": "3.1.1",
87
+ "@embroider/addon-dev": "4.1.0",
74
88
  "@glimmer/compiler": "^0.84.3",
75
89
  "@glimmer/component": "^1.1.2",
76
90
  "@glimmer/interfaces": "^0.84.3",
@@ -78,39 +92,39 @@
78
92
  "@glimmer/syntax": "^0.84.3",
79
93
  "@glimmer/tracking": "^1.1.2",
80
94
  "@glimmer/util": "^0.84.3",
81
- "@glint/core": "^1.0.2",
82
- "@glint/environment-ember-loose": "^1.0.2",
83
- "@glint/environment-ember-template-imports": "^1.0.2",
84
- "@glint/template": "^1.0.2",
85
- "@nullvoxpopuli/eslint-configs": "^3.1.3",
86
- "@rollup/plugin-commonjs": "^25.0.1",
87
- "@tsconfig/ember": "^2.0.0",
88
- "@types/babel__core": "^7.20.0",
95
+ "@glint/core": "^1.1.0",
96
+ "@glint/environment-ember-loose": "^1.1.0",
97
+ "@glint/environment-ember-template-imports": "^1.1.0",
98
+ "@glint/template": "^1.1.0",
99
+ "@nullvoxpopuli/eslint-configs": "^3.2.2",
100
+ "@rollup/plugin-babel": "^6.0.3",
101
+ "@rollup/plugin-commonjs": "^25.0.4",
102
+ "@tsconfig/ember": "^3.0.0",
103
+ "@types/babel__core": "^7.20.1",
89
104
  "@types/babel__standalone": "^7.1.4",
90
- "@types/babel__traverse": "^7.18.5",
91
- "@types/hast": "^2.3.4",
92
- "@types/mdast": "^3.0.11",
93
- "@types/unist": "^2.0.6",
94
- "@types/uuid": "^9.0.1",
95
- "@typescript-eslint/eslint-plugin": "^5.59.11",
96
- "@typescript-eslint/parser": "^5.59.11",
97
- "concurrently": "^8.0.1",
98
- "ember-resources": "^6.1.0",
99
- "ember-source": "^5.0.0",
105
+ "@types/babel__traverse": "^7.20.1",
106
+ "@types/hast": "^3.0.0",
107
+ "@types/mdast": "^4.0.0",
108
+ "@types/unist": "^3.0.0",
109
+ "@types/uuid": "^9.0.2",
110
+ "@typescript-eslint/eslint-plugin": "^6.4.0",
111
+ "@typescript-eslint/parser": "^6.4.0",
112
+ "concurrently": "^8.2.0",
113
+ "ember-resources": "^6.4.0",
114
+ "ember-source": "^5.2.0",
100
115
  "ember-template-imports": "^3.4.2",
101
- "ember-template-lint": "^5.10.1",
102
- "eslint": "^8.42.0",
103
- "eslint-plugin-ember": "^11.8.0",
116
+ "ember-template-lint": "^5.11.2",
117
+ "eslint": "^8.47.0",
118
+ "eslint-plugin-ember": "^11.10.0",
104
119
  "eslint-plugin-node": "^11.1.0",
105
- "eslint-plugin-prettier": "^4.2.1",
106
- "prettier": "^2.8.8",
107
- "prettier-plugin-ember-template-tag": "^0.3.2",
108
- "publint": "^0.1.12",
109
- "rollup": "~3.21.0",
120
+ "eslint-plugin-prettier": "^5.0.0",
121
+ "prettier": "^3.0.2",
122
+ "prettier-plugin-ember-template-tag": "^1.0.2",
123
+ "publint": "^0.2.1",
124
+ "rollup": "~3.28.0",
110
125
  "rollup-plugin-copy": "^3.4.0",
111
126
  "rollup-plugin-glimmer-template-tag": "^0.4.1",
112
- "rollup-plugin-ts": "^3.2.0",
113
- "typescript": "^5.0.4",
127
+ "typescript": "^5.1.6",
114
128
  "@nullvoxpopuli/limber-untyped": "0.0.0"
115
129
  },
116
130
  "volta": {
@@ -129,13 +143,20 @@
129
143
  "@glimmer/compiler": "^0.84.3",
130
144
  "@glimmer/component": "^1.1.2",
131
145
  "@glimmer/syntax": "^0.84.3",
132
- "@glint/template": "^1.0.2",
133
- "ember-resources": "^6.1.0",
134
- "ember-source": "^5.0.0"
146
+ "@glint/template": "^1.1.0",
147
+ "ember-resources": "^6.4.0",
148
+ "ember-source": "^5.2.0"
149
+ },
150
+ "engines": {
151
+ "node": ">= v16",
152
+ "npm": "use pnpm",
153
+ "yarn": "use pnpm"
135
154
  },
136
155
  "scripts": {
137
- "build": "rollup --config",
138
- "lint:types": "glint",
156
+ "build": "concurrently 'npm:build:*'",
157
+ "build:js": "rollup --config",
158
+ "build:types": "tsc --emitDeclarationOnly --noEmit false",
159
+ "lint:types": "tsc --noEmit",
139
160
  "lint:fix": "pnpm -w exec lint fix",
140
161
  "start": "rollup --config --watch",
141
162
  "lint": "pnpm -w exec lint",
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable @typescript-eslint/no-unused-vars */
2
- import { modules } from '../known-modules';
2
+ import { modules } from '../known-modules.ts';
3
3
 
4
- import type { ExtraModules } from '../types';
4
+ import type { ExtraModules } from '../types.ts';
5
5
  import type Component from '@glimmer/component';
6
6
 
7
7
  export function evalSnippet(
@@ -1,8 +1,8 @@
1
- import { preprocess, transform } from '../gjs';
2
- import { nameFor } from '../utils';
3
- import { evalSnippet } from './eval';
1
+ import { preprocess, transform } from '../gjs.ts';
2
+ import { nameFor } from '../utils.ts';
3
+ import { evalSnippet } from './eval.ts';
4
4
 
5
- import type { CompileResult, ExtraModules } from '../types';
5
+ import type { CompileResult, ExtraModules } from '../types.ts';
6
6
  import type { ComponentLike } from '@glint/template';
7
7
 
8
8
  export interface Info {
@@ -1,8 +1,8 @@
1
- import { invocationName } from '../utils';
1
+ import { invocationName } from '../utils.ts';
2
2
 
3
- import type { CompileResult } from '../types';
4
- import type { ExtractedCode } from './markdown-to-ember';
5
- import type { EvalImportMap, ScopeMap } from './types';
3
+ import type { CompileResult } from '../types.ts';
4
+ import type { ExtractedCode } from './markdown-to-ember.ts';
5
+ import type { EvalImportMap, ScopeMap } from './types.ts';
6
6
 
7
7
  async function compileAll(js: { code: string }[], importMap?: EvalImportMap) {
8
8
  let modules = await Promise.all(
@@ -19,7 +19,7 @@ export async function compileGJS(
19
19
  importMap?: EvalImportMap
20
20
  ): Promise<CompileResult> {
21
21
  try {
22
- let { compileJS } = await import('../js');
22
+ let { compileJS } = await import('../js.ts');
23
23
 
24
24
  return await compileJS(gjsInput, importMap);
25
25
  } catch (error) {
@@ -35,7 +35,7 @@ export async function compileHBS(
35
35
  }
36
36
  ): Promise<CompileResult> {
37
37
  try {
38
- let { compileHBS } = await import('../hbs');
38
+ let { compileHBS } = await import('../hbs.ts');
39
39
 
40
40
  return compileHBS(hbsInput, options);
41
41
  } catch (error) {
@@ -106,7 +106,7 @@ export async function compileMD(
106
106
  * compiled rootTemplate can invoke them
107
107
  */
108
108
  try {
109
- let { parseMarkdown } = await import('./markdown-to-ember');
109
+ let { parseMarkdown } = await import('./markdown-to-ember.ts');
110
110
  let { templateOnlyGlimdown, blocks } = await parseMarkdown(glimdownInput, {
111
111
  CopyComponent: options?.CopyComponent,
112
112
  ShadowComponent: options?.ShadowComponent,
@@ -151,11 +151,14 @@ export async function compileMD(
151
151
  * Step 4: Compile the Ember Template
152
152
  */
153
153
  try {
154
- let localScope = scope.reduce((accum, { component, name }) => {
155
- accum[invocationName(name)] = component;
154
+ let localScope = scope.reduce(
155
+ (accum, { component, name }) => {
156
+ accum[invocationName(name)] = component;
156
157
 
157
- return accum;
158
- }, {} as Record<string, unknown>);
158
+ return accum;
159
+ },
160
+ {} as Record<string, unknown>
161
+ );
159
162
 
160
163
  return await compileHBS(rootTemplate, {
161
164
  moduleName: 'DynamicRootTemplate',
@@ -1,14 +1,14 @@
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 { EvalImportMap, ScopeMap } from './types.ts';
12
12
  import type { ComponentLike } from '@glint/template';
13
13
  type Format = 'glimdown' | 'gjs' | 'hbs';
14
14
 
@@ -92,41 +92,84 @@ export async function compile(
92
92
 
93
93
  type Input = string | undefined | null;
94
94
 
95
+ type ExtraOptions =
96
+ | {
97
+ format: 'glimdown';
98
+ importMap?: EvalImportMap;
99
+ CopyComponent?: string;
100
+ ShadowComponent?: string;
101
+ topLevelScope?: ScopeMap;
102
+ }
103
+ | {
104
+ format: 'hbs';
105
+ topLevelScope?: ScopeMap;
106
+ }
107
+ | {
108
+ format: 'gjs';
109
+ importMap?: EvalImportMap;
110
+ };
111
+
95
112
  /**
96
- * By default, this compiles to `glimdown`. A Markdown format which
97
- * extracts `live` tagged code snippets and compiles them to components.
113
+ * @internal
98
114
  */
99
- export const Compiled = resourceFactory(
100
- (markdownText: Input | (() => Input), format?: Format | (() => Format)) => {
101
- return resource(() => {
102
- let _format: Format = (typeof format === 'function' ? format() : format) || 'glimdown';
103
- let input = typeof markdownText === 'function' ? markdownText() : markdownText;
104
- let ready = cell(false);
105
- let error = cell();
106
- let result = cell<ComponentLike>();
107
-
108
- if (input) {
109
- compile(input, {
110
- format: _format,
111
- onSuccess: async (component) => {
112
- result.current = component;
113
- ready.set(true);
114
- error.set(null);
115
- },
116
- onError: async (e) => {
117
- error.set(e);
118
- },
119
- onCompileStart: async () => {
120
- ready.set(false);
121
- },
122
- });
123
- }
124
-
125
- return () => ({
126
- isReady: ready.current,
127
- error: error.current,
128
- component: result.current,
115
+ export interface Value {
116
+ isReady: boolean;
117
+ error: string | null;
118
+ component: ComponentLike;
119
+ }
120
+
121
+ export function buildCompiler(markdownText: Input | (() => Input)): Value;
122
+ export function buildCompiler(markdownText: Input | (() => Input), options?: Format): Value;
123
+ export function buildCompiler(markdownText: Input | (() => Input), options?: () => Format): Value;
124
+ export function buildCompiler(markdownText: Input | (() => Input), options?: ExtraOptions): Value;
125
+ export function buildCompiler(
126
+ markdownText: Input | (() => Input),
127
+ options?: () => ExtraOptions
128
+ ): Value;
129
+
130
+ export function buildCompiler(
131
+ markdownText: Input | (() => Input),
132
+ maybeOptions?: Format | (() => Format) | ExtraOptions | (() => ExtraOptions)
133
+ ): Value {
134
+ return resource(() => {
135
+ let maybeObject = typeof maybeOptions === 'function' ? maybeOptions() : maybeOptions;
136
+ let format =
137
+ (typeof maybeObject === 'string' ? maybeObject : maybeObject?.format) || 'glimdown';
138
+ let options = (typeof maybeObject === 'string' ? {} : maybeObject) || {};
139
+
140
+ let input = typeof markdownText === 'function' ? markdownText() : markdownText;
141
+ let ready = cell(false);
142
+ let error = cell<string | null>();
143
+ let result = cell<ComponentLike>();
144
+
145
+ if (input) {
146
+ compile(input, {
147
+ format,
148
+ onSuccess: async (component) => {
149
+ result.current = component;
150
+ ready.set(true);
151
+ error.set(null);
152
+ },
153
+ onError: async (e) => {
154
+ error.set(e);
155
+ },
156
+ onCompileStart: async () => {
157
+ ready.set(false);
158
+ },
159
+ ...options,
129
160
  });
161
+ }
162
+
163
+ return () => ({
164
+ isReady: ready.current,
165
+ error: error.current,
166
+ component: result.current,
130
167
  });
131
- }
132
- );
168
+ });
169
+ }
170
+
171
+ /**
172
+ * By default, this compiles to `glimdown`. A Markdown format which
173
+ * extracts `live` tagged code snippets and compiles them to components.
174
+ */
175
+ export const Compiled = resourceFactory(buildCompiler) as typeof buildCompiler;
@@ -6,7 +6,7 @@ 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
11
  import type { Node } from 'hast';
12
12
  import type { Code, Text } from 'mdast';
@@ -114,9 +114,9 @@ function liveCodeExtraction(options: Options = {}) {
114
114
 
115
115
  function enhance(code: Code) {
116
116
  code.data ??= {};
117
- code.data['hProperties'] ??= {};
117
+ (code.data as any)['hProperties'] ??= {};
118
118
  // 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;
119
+ (code.data as any)['hProperties'][GLIMDOWN_PREVIEW] = true;
120
120
 
121
121
  return {
122
122
  data: {
@@ -138,8 +138,8 @@ function liveCodeExtraction(options: Options = {}) {
138
138
 
139
139
  return function transformer(tree: Parent, file: VFileWithMeta) {
140
140
  visit(tree, ['code'], function (node, index, parent) {
141
- if (parent === null) return;
142
- if (index === null) return;
141
+ if (parent === null || parent === undefined) return;
142
+ if (index === null || index === undefined) return;
143
143
 
144
144
  if (!isRelevantCode(node as Code)) {
145
145
  let enhanced = enhance(node as Code);
@@ -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