ember-repl 5.0.1 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +2 -404
  3. package/config/.try.mjs +87 -0
  4. package/config/addon-main.cjs +7 -0
  5. package/config/attw.json +7 -0
  6. package/config/babel.publish.config.cjs +29 -0
  7. package/config/ember-cli-update.json +21 -0
  8. package/config/rollup.config.mjs +44 -0
  9. package/config/testem.cjs +35 -0
  10. package/config/tsconfig.publish.json +18 -0
  11. package/config/vite.config.mjs +36 -0
  12. package/declarations/compile/Compiled.d.ts +7 -0
  13. package/declarations/compile/Compiled.d.ts.map +1 -0
  14. package/declarations/compile/compile.d.ts +17 -0
  15. package/declarations/compile/compile.d.ts.map +1 -0
  16. package/declarations/compile/state.d.ts +43 -0
  17. package/declarations/compile/state.d.ts.map +1 -0
  18. package/declarations/compile/types.d.ts +5 -12
  19. package/declarations/compile/types.d.ts.map +1 -1
  20. package/declarations/index.d.ts +6 -2
  21. package/declarations/index.d.ts.map +1 -1
  22. package/declarations/services/compiler.d.ts +94 -0
  23. package/declarations/services/compiler.d.ts.map +1 -0
  24. package/declarations/services/known-modules.d.ts +7 -0
  25. package/declarations/services/known-modules.d.ts.map +1 -0
  26. package/declarations/setup.d.ts +7 -0
  27. package/declarations/setup.d.ts.map +1 -0
  28. package/declarations/test-support.d.ts +20 -0
  29. package/declarations/test-support.d.ts.map +1 -0
  30. package/dist/_commonjsHelpers-BAGoDD49.js +37 -0
  31. package/dist/_commonjsHelpers-BAGoDD49.js.map +1 -0
  32. package/dist/babel-8wMrbxkT.js +110427 -0
  33. package/dist/babel-8wMrbxkT.js.map +1 -0
  34. package/dist/blank-line-Bzg2Qt4K.js +482 -0
  35. package/dist/blank-line-Bzg2Qt4K.js.map +1 -0
  36. package/dist/compile/Compiled.js +26 -0
  37. package/dist/compile/Compiled.js.map +1 -0
  38. package/dist/compile/compile.js +62 -0
  39. package/dist/compile/compile.js.map +1 -0
  40. package/dist/compile/state.js +75 -0
  41. package/dist/compile/state.js.map +1 -0
  42. package/dist/compile/utils.js +214 -3
  43. package/dist/compile/utils.js.map +1 -1
  44. package/dist/default-CoqAuVeH.js +4 -0
  45. package/dist/default-CoqAuVeH.js.map +1 -0
  46. package/dist/index-BTx1k6gT.js +323 -0
  47. package/dist/index-BTx1k6gT.js.map +1 -0
  48. package/dist/index-Bxzjtr16.js +87 -0
  49. package/dist/index-Bxzjtr16.js.map +1 -0
  50. package/dist/index-C371bO_b.js +1553 -0
  51. package/dist/index-C371bO_b.js.map +1 -0
  52. package/dist/index-C4AyeeIa.js +5721 -0
  53. package/dist/index-C4AyeeIa.js.map +1 -0
  54. package/dist/index-C8S2G0FH.js +1953 -0
  55. package/dist/index-C8S2G0FH.js.map +1 -0
  56. package/dist/index-CCcIVEUK.js +409 -0
  57. package/dist/index-CCcIVEUK.js.map +1 -0
  58. package/dist/index-CDSIcg03.js +9070 -0
  59. package/dist/index-CDSIcg03.js.map +1 -0
  60. package/dist/index-D8szzCn3.js +2 -0
  61. package/dist/index-D8szzCn3.js.map +1 -0
  62. package/dist/index-DBBNT106.js +2644 -0
  63. package/dist/index-DBBNT106.js.map +1 -0
  64. package/dist/index-DP_Su7Zc.js +362 -0
  65. package/dist/index-DP_Su7Zc.js.map +1 -0
  66. package/dist/index-DejgrVqh.js +11299 -0
  67. package/dist/index-DejgrVqh.js.map +1 -0
  68. package/dist/index-Dr5iYoKt.js +1551 -0
  69. package/dist/index-Dr5iYoKt.js.map +1 -0
  70. package/dist/index-DxolpiGq.js +3336 -0
  71. package/dist/index-DxolpiGq.js.map +1 -0
  72. package/dist/index-ZyJlPFQY.js +249 -0
  73. package/dist/index-ZyJlPFQY.js.map +1 -0
  74. package/dist/index-k6CfLgeq.js +26 -0
  75. package/dist/index-k6CfLgeq.js.map +1 -0
  76. package/dist/index.js +4 -1
  77. package/dist/index.js.map +1 -1
  78. package/dist/services/compiler.js +329 -0
  79. package/dist/services/compiler.js.map +1 -0
  80. package/dist/services/known-modules.js +123 -0
  81. package/dist/services/known-modules.js.map +1 -0
  82. package/dist/setup.js +15 -0
  83. package/dist/setup.js.map +1 -0
  84. package/dist/test-support.js +33 -0
  85. package/dist/test-support.js.map +1 -0
  86. package/package.json +118 -147
  87. package/src/compile/Compiled.ts +45 -0
  88. package/src/compile/compile.ts +89 -0
  89. package/src/compile/state.ts +88 -0
  90. package/src/compile/types.ts +14 -13
  91. package/src/compile/utils.ts +1 -1
  92. package/src/index.ts +6 -2
  93. package/src/services/compiler.ts +401 -0
  94. package/src/services/known-modules.ts +130 -0
  95. package/src/setup.ts +26 -0
  96. package/src/test-support.ts +64 -0
  97. package/addon-main.cjs +0 -5
  98. package/declarations/__PRIVATE__.d.ts +0 -2
  99. package/declarations/__PRIVATE__.d.ts.map +0 -1
  100. package/declarations/compile/formats/gjs/babel.d.ts +0 -7
  101. package/declarations/compile/formats/gjs/babel.d.ts.map +0 -1
  102. package/declarations/compile/formats/gjs/eval.d.ts +0 -8
  103. package/declarations/compile/formats/gjs/eval.d.ts.map +0 -1
  104. package/declarations/compile/formats/gjs/index.d.ts +0 -24
  105. package/declarations/compile/formats/gjs/index.d.ts.map +0 -1
  106. package/declarations/compile/formats/gjs/known-modules.d.ts +0 -46
  107. package/declarations/compile/formats/gjs/known-modules.d.ts.map +0 -1
  108. package/declarations/compile/formats/hbs.d.ts +0 -17
  109. package/declarations/compile/formats/hbs.d.ts.map +0 -1
  110. package/declarations/compile/formats/markdown.d.ts +0 -22
  111. package/declarations/compile/formats/markdown.d.ts.map +0 -1
  112. package/declarations/compile/formats.d.ts +0 -18
  113. package/declarations/compile/formats.d.ts.map +0 -1
  114. package/declarations/compile/index.d.ts +0 -81
  115. package/declarations/compile/index.d.ts.map +0 -1
  116. package/declarations/test-support/index.d.ts +0 -2
  117. package/declarations/test-support/index.d.ts.map +0 -1
  118. package/dist/__PRIVATE__.js +0 -2
  119. package/dist/__PRIVATE__.js.map +0 -1
  120. package/dist/compile/formats/gjs/babel.js +0 -2
  121. package/dist/compile/formats/gjs/babel.js.map +0 -1
  122. package/dist/compile/formats/gjs/eval.js +0 -20
  123. package/dist/compile/formats/gjs/eval.js.map +0 -1
  124. package/dist/compile/formats/gjs/index.js +0 -120
  125. package/dist/compile/formats/gjs/index.js.map +0 -1
  126. package/dist/compile/formats/gjs/known-modules.js +0 -50
  127. package/dist/compile/formats/gjs/known-modules.js.map +0 -1
  128. package/dist/compile/formats/hbs.js +0 -94
  129. package/dist/compile/formats/hbs.js.map +0 -1
  130. package/dist/compile/formats/markdown.js +0 -264
  131. package/dist/compile/formats/markdown.js.map +0 -1
  132. package/dist/compile/formats.js +0 -173
  133. package/dist/compile/formats.js.map +0 -1
  134. package/dist/compile/index.js +0 -113
  135. package/dist/compile/index.js.map +0 -1
  136. package/dist/test-support/index.js +0 -8
  137. package/dist/test-support/index.js.map +0 -1
  138. package/src/__PRIVATE__.ts +0 -1
  139. package/src/compile/formats/gjs/babel.ts +0 -7
  140. package/src/compile/formats/gjs/eval.ts +0 -30
  141. package/src/compile/formats/gjs/index.ts +0 -151
  142. package/src/compile/formats/gjs/known-modules.ts +0 -49
  143. package/src/compile/formats/hbs.ts +0 -101
  144. package/src/compile/formats/markdown.ts +0 -344
  145. package/src/compile/formats.ts +0 -179
  146. package/src/compile/index.ts +0 -219
  147. package/src/test-support/index.ts +0 -5
@@ -1,120 +0,0 @@
1
- import * as compiler from 'ember-template-compiler';
2
- import { nameFor } from '../../utils.js';
3
- import { evalSnippet } from './eval.js';
4
-
5
- /**
6
- * @public
7
- * Transpiles GlimmerJS (*.gjs) formatted text into and evaluates as a JS Module.
8
- * The returned component can be invoked explicitly in the consuming project.
9
- *
10
- * SEE: README for example usage
11
- *
12
- * @param {string} code: the code to be compiled
13
- * @param {Object} extraModules: map of import paths to modules. This isn't needed
14
- * for classic ember projects, but for strict static ember projects, extraModules
15
- * will need to be pasesd if compileJS is intended to be used in a styleguide or
16
- * if there are additional modules that could be imported in the passed `code`.
17
- *
18
- * Later on, imports that are not present by default (ember/glimmer) or that
19
- * are not provided by extraModules will be searched on npm to see if a package
20
- * needs to be downloaded before running the `code` / invoking the component
21
- */
22
- async function compileJS(code, extraModules) {
23
- let name = nameFor(code);
24
- let component;
25
- let error;
26
- try {
27
- let compiled = await transpile({
28
- code: code,
29
- name
30
- });
31
- if (!compiled) {
32
- throw new Error(`Compiled output is missing`);
33
- }
34
- component = evalSnippet(compiled, extraModules).default;
35
- } catch (e) {
36
- error = e;
37
- }
38
- return {
39
- name,
40
- component,
41
- error
42
- };
43
- }
44
- async function transpile({
45
- code: input,
46
- name
47
- }) {
48
- let preprocessed = await preprocess(input, name);
49
- let result = await transform(preprocessed, name);
50
- if (!result) {
51
- return;
52
- }
53
- let {
54
- code
55
- } = result;
56
- return code;
57
- }
58
- let processor;
59
- let fetchingPromise;
60
- async function preprocess(input, name) {
61
- if (!fetchingPromise) {
62
- fetchingPromise = import('content-tag');
63
- }
64
- if (!processor) {
65
- let {
66
- Preprocessor
67
- } = await fetchingPromise;
68
- processor = new Preprocessor();
69
- }
70
- let {
71
- code /* map */
72
- } = processor.process(input, {
73
- filename: `${name}.js`,
74
- inline_source_map: true
75
- });
76
- return code;
77
- }
78
- async function transform(intermediate, name) {
79
- const [
80
- // _parser, _traverse, _generator,
81
- _decoratorTransforms, _emberTemplateCompilation] = await Promise.all([
82
- // @babel/* doesn't have the greatest ESM compat yet
83
- // https://github.com/babel/babel/issues/14314#issuecomment-1054505190
84
- //
85
- // babel-standalone is so easy...
86
- // import('@babel/parser'),
87
- // import('@babel/traverse'),
88
- // import('@babel/generator'),
89
- import('decorator-transforms'), import('babel-plugin-ember-template-compilation')]);
90
-
91
- // These libraries are compiled incorrectly for cjs<->ESM compat
92
- const decoratorTransforms = 'default' in _decoratorTransforms ? _decoratorTransforms.default : _decoratorTransforms;
93
- const emberTemplateCompilation = 'default' in _emberTemplateCompilation ? _emberTemplateCompilation.default : _emberTemplateCompilation;
94
-
95
- // so we have to use the default export (which is all the exports)
96
- let maybeBabel = await import('@babel/standalone');
97
- // Handle difference between vite and webpack in consuming projects...
98
- let babel = 'availablePlugins' in maybeBabel ? maybeBabel : maybeBabel.default;
99
- return babel.transform(intermediate, {
100
- filename: `${name}.js`,
101
- plugins: [[emberTemplateCompilation, {
102
- compiler
103
- }], [
104
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
105
- // @ts-ignore - we don't care about types here..
106
- decoratorTransforms, {
107
- runtime: {
108
- import: 'decorator-transforms/runtime'
109
- }
110
- }],
111
- // Womp.
112
- // See this exploration into true ESM:
113
- // https://github.com/NullVoxPopuli/limber/pull/1805
114
- [babel.availablePlugins['transform-modules-commonjs']]],
115
- presets: []
116
- });
117
- }
118
-
119
- export { compileJS };
120
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/compile/formats/gjs/index.ts"],"sourcesContent":["import * as compiler from 'ember-template-compiler';\n\nimport { nameFor } from '../../utils.ts';\nimport { evalSnippet } from './eval.ts';\n\nimport type { CompileResult } from '../../types.ts';\nimport type { ComponentLike } from '@glint/template';\n\nexport interface Info {\n code: string;\n name: string;\n}\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 async function compileJS(\n code: string,\n extraModules?: Record<string, unknown>\n): Promise<CompileResult> {\n let name = nameFor(code);\n let component: undefined | ComponentLike;\n let error: undefined | Error;\n\n try {\n let compiled = await transpile({ code: code, name });\n\n if (!compiled) {\n throw new Error(`Compiled output is missing`);\n }\n\n component = evalSnippet(compiled, extraModules).default as unknown as ComponentLike;\n } catch (e) {\n error = e as Error | undefined;\n }\n\n return { name, component, error };\n}\n\nasync function transpile({ code: input, name }: Info) {\n let preprocessed = await preprocess(input, name);\n let result = await transform(preprocessed, name);\n\n if (!result) {\n return;\n }\n\n let { code } = result;\n\n return code;\n}\n\nimport type { Babel } from './babel.ts';\n\nlet processor: any;\nlet fetchingPromise: Promise<any>;\n\nasync function preprocess(input: string, name: string): Promise<string> {\n if (!fetchingPromise) {\n fetchingPromise = import('content-tag');\n }\n\n if (!processor) {\n let { Preprocessor } = await fetchingPromise;\n\n processor = new Preprocessor();\n }\n\n let { code /* map */ } = processor.process(input, {\n filename: `${name}.js`,\n inline_source_map: true,\n });\n\n return code;\n}\n\nasync function transform(\n intermediate: string,\n name: string\n): Promise<ReturnType<Babel['transform']>> {\n const [\n // _parser, _traverse, _generator,\n _decoratorTransforms,\n _emberTemplateCompilation,\n ] = await Promise.all([\n // @babel/* doesn't have the greatest ESM compat yet\n // https://github.com/babel/babel/issues/14314#issuecomment-1054505190\n //\n // babel-standalone is so easy...\n // import('@babel/parser'),\n // import('@babel/traverse'),\n // import('@babel/generator'),\n import('decorator-transforms'),\n import('babel-plugin-ember-template-compilation'),\n ]);\n\n // These libraries are compiled incorrectly for cjs<->ESM compat\n const decoratorTransforms =\n 'default' in _decoratorTransforms ? _decoratorTransforms.default : _decoratorTransforms;\n\n const emberTemplateCompilation =\n 'default' in _emberTemplateCompilation\n ? _emberTemplateCompilation.default\n : _emberTemplateCompilation;\n\n // so we have to use the default export (which is all the exports)\n let maybeBabel = (await import('@babel/standalone')) as any;\n // Handle difference between vite and webpack in consuming projects...\n let babel: Babel = 'availablePlugins' in maybeBabel ? maybeBabel : maybeBabel.default;\n\n return babel.transform(intermediate, {\n filename: `${name}.js`,\n plugins: [\n [\n emberTemplateCompilation,\n {\n compiler,\n },\n ],\n [\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - we don't care about types here..\n decoratorTransforms,\n {\n runtime: {\n import: 'decorator-transforms/runtime',\n },\n },\n ],\n // Womp.\n // See this exploration into true ESM:\n // https://github.com/NullVoxPopuli/limber/pull/1805\n [babel.availablePlugins['transform-modules-commonjs']],\n ],\n presets: [],\n });\n}\n"],"names":["compileJS","code","extraModules","name","nameFor","component","error","compiled","transpile","Error","evalSnippet","default","e","input","preprocessed","preprocess","result","transform","processor","fetchingPromise","Preprocessor","process","filename","inline_source_map","intermediate","_decoratorTransforms","_emberTemplateCompilation","Promise","all","decoratorTransforms","emberTemplateCompilation","maybeBabel","babel","plugins","compiler","runtime","import","availablePlugins","presets"],"mappings":";;;;AAaA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeA,SAASA,CAC7BC,IAAY,EACZC,YAAsC,EACd;AACxB,EAAA,IAAIC,IAAI,GAAGC,OAAO,CAACH,IAAI,CAAC;AACxB,EAAA,IAAII,SAAoC;AACxC,EAAA,IAAIC,KAAwB;EAE5B,IAAI;AACF,IAAA,IAAIC,QAAQ,GAAG,MAAMC,SAAS,CAAC;AAAEP,MAAAA,IAAI,EAAEA,IAAI;AAAEE,MAAAA;AAAK,KAAC,CAAC;IAEpD,IAAI,CAACI,QAAQ,EAAE;AACb,MAAA,MAAM,IAAIE,KAAK,CAAC,CAAA,0BAAA,CAA4B,CAAC;AAC/C;IAEAJ,SAAS,GAAGK,WAAW,CAACH,QAAQ,EAAEL,YAAY,CAAC,CAACS,OAAmC;GACpF,CAAC,OAAOC,CAAC,EAAE;AACVN,IAAAA,KAAK,GAAGM,CAAsB;AAChC;EAEA,OAAO;IAAET,IAAI;IAAEE,SAAS;AAAEC,IAAAA;GAAO;AACnC;AAEA,eAAeE,SAASA,CAAC;AAAEP,EAAAA,IAAI,EAAEY,KAAK;AAAEV,EAAAA;AAAW,CA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AyB,CAACf,OAAO,GACjCe,yBAAyB;;AAE/B;AACA,EAAA,IAAIK,UAAU,GAAI,MAAM,OAAO,mBAAmB,CAAS;AAC3D;EACA,IAAIC,KAAY,GAAG,kBAAkB,IAAID,UAAU,GAAGA,UAAU,GAAGA,UAAU,CAACpB,OAAO;AAErF,EAAA,OAAOqB,KAAK,CAACf,SAAS,CAACO,YAAY,EAAE;IACnCF,QAAQ,EAAE,CAAGnB,EAAAA,IAAI,CAAK,GAAA,CAAA;AACtB8B,IAAAA,OAAO,EAAE,CACP,CACEH,wBAAwB,EACxB;AACEI,MAAAA;AACF,KAAC,CACF,EACD;AACE;AACA;AACAL,IAAAA,mBAAmB,EACnB;AACEM,MAAAA,OAAO,EAAE;AACPC,QAAAA,MAAM,EAAE;AACV;AACF,KAAC,CACF;AACD;AACA;AACA;AACA,IAAA,CAACJ,KAAK,CAACK,gBAAgB,CAAC,4BAA4B,CAAC,CAAC,CACvD;AACDC,IAAAA,OAAO,EAAE;AACX,GAAC,CAAC;AACJ;;;;"}
@@ -1,50 +0,0 @@
1
- import _GlimmerComponent from '@glimmer/component';
2
- import * as _tracking from '@glimmer/tracking';
3
- import * as _application from '@ember/application';
4
- import * as _array from '@ember/array';
5
- import * as _EmberComponent from '@ember/component';
6
- import * as _EmberComponentHelper from '@ember/component/helper';
7
- import _TO from '@ember/component/template-only';
8
- import * as _debug from '@ember/debug';
9
- import * as _destroyable from '@ember/destroyable';
10
- import * as _helpers from '@ember/helper';
11
- import * as _modifier from '@ember/modifier';
12
- import * as _object from '@ember/object';
13
- import * as _owner from '@ember/owner';
14
- import * as _runloop from '@ember/runloop';
15
- import * as _service from '@ember/service';
16
- import * as _template from '@ember/template';
17
- import { createTemplateFactory } from '@ember/template-factory';
18
- import * as _utils from '@ember/utils';
19
- import * as _decoratorsRuntime from 'decorator-transforms/runtime';
20
-
21
- /**
22
- * We need to import and hang on to these references so that they
23
- * don't get optimized away during deploy
24
- */
25
- const modules = {
26
- '@ember/application': _application,
27
- '@ember/array': _array,
28
- '@ember/component': _EmberComponent,
29
- '@ember/component/helper': _EmberComponentHelper,
30
- '@ember/component/template-only': _TO,
31
- '@ember/debug': _debug,
32
- '@ember/destroyable': _destroyable,
33
- '@ember/helper': _helpers,
34
- '@ember/modifier': _modifier,
35
- '@ember/object': _object,
36
- '@ember/runloop': _runloop,
37
- '@ember/service': _service,
38
- '@ember/template-factory': {
39
- createTemplateFactory
40
- },
41
- '@ember/utils': _utils,
42
- '@ember/template': _template,
43
- '@ember/owner': _owner,
44
- '@glimmer/component': _GlimmerComponent,
45
- '@glimmer/tracking': _tracking,
46
- 'decorator-transforms/runtime': _decoratorsRuntime
47
- };
48
-
49
- export { modules };
50
- //# sourceMappingURL=known-modules.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"known-modules.js","sources":["../../../../src/compile/formats/gjs/known-modules.ts"],"sourcesContent":["/**\n * We need to import and hang on to these references so that they\n * don't get optimized away during deploy\n */\nimport _GlimmerComponent from '@glimmer/component';\nimport * as _tracking from '@glimmer/tracking';\nimport * as _application from '@ember/application';\nimport * as _array from '@ember/array';\nimport * as _EmberComponent from '@ember/component';\nimport * as _EmberComponentHelper from '@ember/component/helper';\nimport _TO from '@ember/component/template-only';\nimport * as _debug from '@ember/debug';\nimport * as _destroyable from '@ember/destroyable';\nimport * as _helpers from '@ember/helper';\nimport * as _modifier from '@ember/modifier';\nimport * as _object from '@ember/object';\nimport * as _owner from '@ember/owner';\nimport * as _runloop from '@ember/runloop';\nimport * as _service from '@ember/service';\nimport * as _template from '@ember/template';\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { createTemplateFactory } from '@ember/template-factory';\nimport * as _utils from '@ember/utils';\n\nimport * as _decoratorsRuntime from 'decorator-transforms/runtime';\n\nexport const modules = {\n '@ember/application': _application,\n '@ember/array': _array,\n '@ember/component': _EmberComponent,\n '@ember/component/helper': _EmberComponentHelper,\n '@ember/component/template-only': _TO,\n '@ember/debug': _debug,\n '@ember/destroyable': _destroyable,\n '@ember/helper': _helpers,\n '@ember/modifier': _modifier,\n '@ember/object': _object,\n '@ember/runloop': _runloop,\n '@ember/service': _service,\n '@ember/template-factory': { createTemplateFactory },\n '@ember/utils': _utils,\n '@ember/template': _template,\n '@ember/owner': _owner,\n\n '@glimmer/component': _GlimmerComponent,\n '@glimmer/tracking': _tracking,\n 'decorator-transforms/runtime': _decoratorsRuntime,\n};\n"],"names":["modules","_application","_array","_EmberComponent","_EmberComponentHelper","_TO","_debug","_destroyable","_helpers","_modifier","_object","_runloop","_service","createTemplateFactory","_utils","_template","_owner","_GlimmerComponent","_tracking","_decoratorsRuntime"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AAwBO,MAAMA,OAAO,GAAG;AACrB,EAAA,oBAAoB,EAAEC,YAAY;AAClC,EAAA,cAAc,EAAEC,MAAM;AACtB,EAAA,kBAAkB,EAAEC,eAAe;AACnC,EAAA,yBAAyB,EAAEC,qBAAqB;AAChD,EAAA,gCAAgC,EAAEC,GAAG;AACrC,EAAA,cAAc,EAAEC,MAAM;AACtB,EAAA,oBAAoB,EAAEC,YAAY;AAClC,EAAA,eAAe,EAAEC,QAAQ;AACzB,EAAA,iBAAiB,EAAEC,SAAS;AAC5B,EAAA,eAAe,EAAEC,OAAO;AACxB,EAAA,gBAAgB,EAAEC,QAAQ;AAC1B,EAAA,gBAAgB,EAAEC,QAAQ;AAC1B,EAAA,yBAAyB,EAAE;AAAEC,IAAAA;GAAuB;AACpD,EAAA,cAAc,EAAEC,MAAM;AACtB,EAAA,iBAAiB,EAAEC,SAAS;AAC5B,EAAA,cAAc,EAAEC,MAAM;AAEtB,EAAA,oBAAoB,EAAEC,iBAAiB;AACvC,EAAA,mBAAmB,EAAEC,SAAS;AAC9B,EAAA,8BAA8B,EAAEC;AAClC;;;;"}
@@ -1,94 +0,0 @@
1
- import { precompileJSON } from '@glimmer/compiler';
2
- import { getTemplateLocals } from '@glimmer/syntax';
3
- import { setComponentTemplate } from '@ember/component';
4
- import _TO from '@ember/component/template-only';
5
- import { array, concat, fn, get, hash } from '@ember/helper';
6
- import { on } from '@ember/modifier';
7
- import { createTemplateFactory } from '@ember/template-factory';
8
- import { nameFor } from '../utils.js';
9
-
10
- /* eslint-disable @typescript-eslint/no-explicit-any */
11
- // import { precompileJSON } from '@glimmer/compiler';
12
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
13
- // @ts-ignore
14
- // These things are pre-bundled in the old system.
15
- // ember-template-compiler defines them in AMD/requirejs
16
- /**
17
- * compile a template with an empty scope
18
- * to use components, helpers, etc, you will need to compile with JS
19
- *
20
- * (templates alone do not have a way to import / define complex structures)
21
- */
22
- function compileHBS(template, options = {}) {
23
- let name = nameFor(template);
24
- let component;
25
- let error;
26
- try {
27
- component = setComponentTemplate(compileTemplate(template, {
28
- moduleName: options.moduleName || name,
29
- ...options
30
- }), _TO(options.moduleName || name));
31
- } catch (e) {
32
- error = e;
33
- }
34
- return {
35
- name,
36
- component,
37
- error
38
- };
39
- }
40
- /**
41
- * The reason why we can't use precompile directly is because of this:
42
- * https://github.com/glimmerjs/glimmer-vm/blob/master/packages/%40glimmer/compiler/lib/compiler.ts#L132
43
- *
44
- * Support for dynamically compiling templates in strict mode doesn't seem to be fully their yet.
45
- * That JSON.stringify (and the lines after) prevent us from easily setting the scope function,
46
- * which means that *everything* is undefined.
47
- */
48
- function compileTemplate(source, {
49
- moduleName,
50
- scope = {}
51
- }) {
52
- let localScope = {
53
- array,
54
- concat,
55
- fn,
56
- get,
57
- hash,
58
- on,
59
- ...scope
60
- };
61
- let locals = getTemplateLocals(source);
62
- let options = {
63
- strictMode: true,
64
- moduleName,
65
- locals,
66
- isProduction: false,
67
- meta: {
68
- moduleName
69
- }
70
- };
71
-
72
- // Copied from @glimmer/compiler/lib/compiler#precompile
73
- let [block, usedLocals] = precompileJSON(source, options);
74
- let usedScope = usedLocals.map(key => {
75
- let value = localScope[key];
76
- if (!value) {
77
- throw new Error(`Attempt to use ${key} in compiled hbs, but it was not available in scope. ` + `Available scope includes: ${Object.keys(localScope)}`);
78
- }
79
- return value;
80
- });
81
- let blockJSON = JSON.stringify(block);
82
- let templateJSONObject = {
83
- id: moduleName,
84
- block: blockJSON,
85
- moduleName: moduleName ?? '(dynamically compiled component)',
86
- scope: () => usedScope,
87
- isStrictMode: true
88
- };
89
- let factory = createTemplateFactory(templateJSONObject);
90
- return factory;
91
- }
92
-
93
- export { compileHBS };
94
- //# sourceMappingURL=hbs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hbs.js","sources":["../../../src/compile/formats/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\n// These things are pre-bundled in the old system.\n// ember-template-compiler defines them in AMD/requirejs\nimport { precompileJSON } from '@glimmer/compiler';\nimport { getTemplateLocals } from '@glimmer/syntax';\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';\n\nimport { nameFor } from '../utils.ts';\n\nimport type { CompileResult } from '../types.ts';\nimport type { ComponentLike } from '@glint/template';\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) => {\n let value = localScope[key];\n\n if (!value) {\n throw new Error(\n `Attempt to use ${key} in compiled hbs, but it was not available in scope. ` +\n `Available scope includes: ${Object.keys(localScope)}`\n );\n }\n\n return value;\n });\n\n let blockJSON = JSON.stringify(block);\n let templateJSONObject = {\n id: moduleName,\n block: blockJSON,\n moduleName: moduleName ?? '(dynamically compiled component)',\n scope: () => usedScope,\n isStrictMode: true,\n };\n\n let factory = createTemplateFactory(templateJSONObject);\n\n return factory;\n}\n"],"names":["compileHBS","template","options","name","nameFor","component","error","setComponentTemplate","compileTemplate","moduleName","templateOnlyComponent","e","source","scope","localScope","array","concat","fn","get","hash","on","locals","getTemplateLocals","strictMode","isProduction","meta","block","usedLocals","precompileJSON","usedScope","map","key","value","Error","Object","keys","blockJSON","JSON","stringify","templateJSONObject","id","isStrictMode","factory","createTemplateFactory"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AAgBA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,UAAUA,CAACC,QAAgB,EAAEC,OAA+B,GAAG,EAAE,EAAiB;AAChG,EAAA,IAAIC,IAAI,GAAGC,OAAO,CAACH,QAAQ,C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A,EAAkBF,GAAG,CAAuD,qDAAA,CAAA,GAC1E,CAA6BG,0BAAAA,EAAAA,MAAM,CAACC,IAAI,CAACrB,UAAU,CAAC,EACxD,CAAC;AACH;AAEA,IAAA,OAAOkB,KAAK;AACd,GAAC,CAAC;AAEF,EAAA,IAAII,SAAS,GAAGC,IAAI,CAACC,SAAS,CAACZ,KAAK,CAAC;AACrC,EAAA,IAAIa,kBAAkB,GAAG;AACvBC,IAAAA,EAAE,EAAE/B,UAAU;AACdiB,IAAAA,KAAK,EAAEU,SAAS;IAChB3B,UAAU,EAAEA,UAAU,IAAI,kCAAkC;IAC5DI,KAAK,EAAEA,MAAMgB,SAAS;AACtBY,IAAAA,YAAY,EAAE;GACf;AAED,EAAA,IAAIC,OAAO,GAAGC,qBAAqB,CAACJ,kBAAkB,CAAC;AAEvD,EAAA,OAAOG,OAAO;AAChB;;;;"}
@@ -1,264 +0,0 @@
1
- import rehypeRaw from 'rehype-raw';
2
- import rehypeStringify from 'rehype-stringify';
3
- import remarkGfm from 'remark-gfm';
4
- import remarkParse from 'remark-parse';
5
- import remarkRehype from 'remark-rehype';
6
- import { unified } from 'unified';
7
- import { visit } from 'unist-util-visit';
8
- import { nameFor, invocationOf } from '../utils.js';
9
-
10
- const GLIMDOWN_PREVIEW = Symbol('__GLIMDOWN_PREVIEW__');
11
- const GLIMDOWN_RENDER = Symbol('__GLIMDOWN_RENDER__');
12
- const ALLOWED_LANGUAGES = ['gjs', 'hbs'];
13
- function isLive(meta) {
14
- return meta.includes('live');
15
- }
16
- function isPreview(meta) {
17
- return meta.includes('preview');
18
- }
19
- function isBelow(meta) {
20
- return meta.includes('below');
21
- }
22
-
23
- // TODO: extract and publish remark plugin
24
- function liveCodeExtraction(options = {}) {
25
- let {
26
- copyComponent,
27
- snippets,
28
- demo
29
- } = options;
30
- let {
31
- classList: snippetClasses
32
- } = snippets || {};
33
- let {
34
- classList: demoClasses
35
- } = demo || {};
36
- snippetClasses ??= [];
37
- demoClasses ??= [];
38
- function isRelevantCode(node) {
39
- if (node.type !== 'code') return false;
40
- let {
41
- meta,
42
- lang
43
- } = node;
44
- meta = meta?.trim();
45
- if (!meta || !lang) return false;
46
- if (!meta.includes('live')) {
47
- return false;
48
- }
49
- if (!ALLOWED_LANGUAGES.includes(lang)) return false;
50
- return true;
51
- }
52
- let copyNode = {
53
- type: 'html',
54
- value: copyComponent
55
- };
56
- function enhance(code) {
57
- code.data ??= {};
58
- code.data['hProperties'] ??= {};
59
- // This is secret-to-us-only API, so we don't really care about the type
60
- code.data['hProperties'][GLIMDOWN_PREVIEW] = true;
61
- return {
62
- data: {
63
- hProperties: {
64
- className: snippetClasses
65
- }
66
- },
67
- type: 'div',
68
- hProperties: {
69
- className: snippetClasses
70
- },
71
- children: [code, copyNode]
72
- };
73
- }
74
- function flatReplaceAt(array, index, replacement) {
75
- array.splice(index, 1, ...replacement);
76
- }
77
-
78
- // because we mutate the tree as we iterate,
79
- // we need to make sure we don't loop forever
80
- const seen = new Set();
81
- return function transformer(tree, file) {
82
- visit(tree, ['code'], function (node, index, parent) {
83
- if (parent === null || parent === undefined) return;
84
- if (index === null || index === undefined) return;
85
- if (!isRelevantCode(node)) {
86
- let enhanced = enhance(node);
87
- parent.children[index] = enhanced;
88
- return 'skip';
89
- }
90
- if (seen.has(node)) return 'skip';
91
- seen.add(node);
92
- let {
93
- meta,
94
- lang,
95
- value
96
- } = node;
97
- if (!meta) return 'skip';
98
- if (!lang) return 'skip';
99
- file.data.liveCode ??= [];
100
- let code = value.trim();
101
- let name = nameFor(code);
102
- let invocation = invocationOf(name);
103
- let shadow = options.shadowComponent;
104
- let wrapInShadow = shadow && !meta?.includes('no-shadow');
105
- if (wrapInShadow) {
106
- invocation = `<${shadow}>${invocation}</${shadow}>`;
107
- }
108
- let invokeNode = {
109
- type: 'html',
110
- data: {
111
- hProperties: {
112
- [GLIMDOWN_RENDER]: true
113
- }
114
- },
115
- value: `<div class="${demoClasses}">${invocation}</div>`
116
- };
117
- let wrapper = enhance(node);
118
- file.data.liveCode.push({
119
- lang,
120
- name,
121
- code
122
- });
123
- let live = isLive(meta);
124
- let preview = isPreview(meta);
125
- let below = isBelow(meta);
126
- if (live && preview && below) {
127
- flatReplaceAt(parent.children, index, [wrapper, invokeNode]);
128
- return 'skip';
129
- }
130
- if (live && preview) {
131
- flatReplaceAt(parent.children, index, [invokeNode, wrapper]);
132
- return 'skip';
133
- }
134
- if (live) {
135
- parent.children[index] = invokeNode;
136
- return 'skip';
137
- }
138
- parent.children[index] = wrapper;
139
- return;
140
- });
141
- };
142
- }
143
- function sanitizeForGlimmer(/* options */
144
- ) {
145
- return tree => {
146
- visit(tree, 'element', node => {
147
- if ('tagName' in node) {
148
- if (!['pre', 'code'].includes(node.tagName)) return;
149
- visit(node, 'text', textNode => {
150
- if ('value' in textNode && textNode.value) {
151
- textNode.value = textNode.value.replace(/{{/g, '\\{{');
152
- }
153
- });
154
- return 'skip';
155
- }
156
- });
157
- };
158
- }
159
- function buildCompiler(options) {
160
- let compiler = unified().use(remarkParse).use(remarkGfm);
161
-
162
- /**
163
- * If this were "use"d after `remarkRehype`,
164
- * remark is gone, and folks would need to work with rehype trees
165
- */
166
- if (options.remarkPlugins) {
167
- options.remarkPlugins.forEach(plugin => {
168
- // Arrays are how plugins are passed options (for some reason?)
169
- // why not just invoke the the function?
170
- let p = Array.isArray(plugin) ? plugin : [plugin];
171
- compiler = compiler.use(...p);
172
- });
173
- }
174
-
175
- // TODO: we only want to do this when we have pre > code.
176
- // code can exist inline.
177
- compiler = compiler.use(liveCodeExtraction, {
178
- snippets: {
179
- classList: ['glimdown-snippet', 'relative']
180
- },
181
- demo: {
182
- classList: ['glimdown-render']
183
- },
184
- copyComponent: options?.CopyComponent,
185
- shadowComponent: options?.ShadowComponent
186
- });
187
-
188
- // .use(() => (tree) => visit(tree, (node) => console.log('i', node)))
189
- // remark rehype is needed to convert markdown to HTML
190
- // However, it also changes all the nodes, so we need another pass
191
- // to make sure our Glimmer-aware nodes are in tact
192
- compiler = compiler.use(remarkRehype, {
193
- allowDangerousHtml: true
194
- });
195
-
196
- // Convert invocables to raw format, so Glimmer can invoke them
197
- compiler = compiler.use(() => tree => {
198
- visit(tree, function (node) {
199
- // We rely on an implicit transformation of data.hProperties => properties
200
- let properties = node.properties;
201
- if (properties?.[GLIMDOWN_PREVIEW]) {
202
- return 'skip';
203
- }
204
- if (node.type === 'element' || 'tagName' in node && node.tagName === 'code') {
205
- if (properties?.[GLIMDOWN_RENDER]) {
206
- node.type = 'glimmer_raw';
207
- return;
208
- }
209
- return 'skip';
210
- }
211
- if (node.type === 'text' || node.type === 'raw') {
212
- // definitively not the better way, but this is supposed to detect "glimmer" nodes
213
- if ('value' in node && typeof node.value === 'string' && node.value.match(/<\/?[_A-Z:0-9].*>/g)) {
214
- node.type = 'glimmer_raw';
215
- }
216
- node.type = 'glimmer_raw';
217
- return 'skip';
218
- }
219
- return;
220
- });
221
- });
222
- if (options.rehypePlugins) {
223
- options.rehypePlugins.forEach(plugin => {
224
- // Arrays are how plugins are passed options (for some reason?)
225
- // why not just invoke the the function?
226
- let p = Array.isArray(plugin) ? plugin : [plugin];
227
- compiler = compiler.use(...p);
228
- });
229
- }
230
- compiler = compiler.use(rehypeRaw, {
231
- passThrough: ['glimmer_raw', 'raw']
232
- }).use(() => tree => {
233
- visit(tree, 'glimmer_raw', node => {
234
- node.type = 'raw';
235
- });
236
- });
237
- compiler = compiler.use(sanitizeForGlimmer);
238
-
239
- // Finally convert to string! oofta!
240
- compiler = compiler.use(rehypeStringify, {
241
- collapseEmptyAttributes: true,
242
- closeSelfClosing: true,
243
- allowParseErrors: true,
244
- allowDangerousCharacters: true,
245
- allowDangerousHtml: true
246
- });
247
- return compiler;
248
- }
249
- /**
250
- * @internal not under semver
251
- */
252
- async function parseMarkdown(input, options = {}) {
253
- let markdownCompiler = buildCompiler(options);
254
- let processed = await markdownCompiler.process(input);
255
- let liveCode = processed.data.liveCode || [];
256
- let templateOnly = processed.toString();
257
- return {
258
- templateOnlyGlimdown: templateOnly,
259
- blocks: liveCode
260
- };
261
- }
262
-
263
- export { parseMarkdown };
264
- //# sourceMappingURL=markdown.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"markdown.js","sources":["../../../src/compile/formats/markdown.ts"],"sourcesContent":["import rehypeRaw from 'rehype-raw';\nimport rehypeStringify from 'rehype-stringify';\nimport remarkGfm from 'remark-gfm';\nimport remarkParse from 'remark-parse';\nimport remarkRehype from 'remark-rehype';\nimport { unified } from 'unified';\nimport { visit } from 'unist-util-visit';\n\nimport { invocationOf, nameFor } from '../utils.ts';\n\nimport type { UnifiedPlugin } from '../types.ts';\nimport type { Node } from 'hast';\nimport type { Code, Text } from 'mdast';\nimport type { Parent } from 'unist';\nimport type { VFile } from 'vfile';\n\nexport interface ExtractedCode {\n name: string;\n code: string;\n lang: string;\n}\n\nexport interface LiveCodeExtraction {\n templateOnlyGlimdown: string;\n blocks: ExtractedCode[];\n}\ntype LiveData = {\n liveCode?: ExtractedCode[];\n};\ntype VFileWithMeta = VFile & {\n data: LiveData;\n};\n\ninterface Options {\n snippets?: {\n classList?: string[];\n };\n demo?: {\n classList?: string[];\n };\n copyComponent?: string;\n shadowComponent?: string;\n}\n\nconst GLIMDOWN_PREVIEW = Symbol('__GLIMDOWN_PREVIEW__');\nconst GLIMDOWN_RENDER = Symbol('__GLIMDOWN_RENDER__');\nconst ALLOWED_LANGUAGES = ['gjs', 'hbs'] as const;\n\ntype AllowedLanguage = (typeof ALLOWED_LANGUAGES)[number];\ntype RelevantCode = Omit<Code, 'lang'> & { lang: AllowedLanguage };\n\nfunction isLive(meta: string) {\n return meta.includes('live');\n}\n\nfunction isPreview(meta: string) {\n return meta.includes('preview');\n}\n\nfunction isBelow(meta: string) {\n return meta.includes('below');\n}\n\n// TODO: extract and publish remark plugin\nfunction liveCodeExtraction(options: Options = {}) {\n let { copyComponent, snippets, demo } = options;\n let { classList: snippetClasses } = snippets || {};\n let { classList: demoClasses } = demo || {};\n\n snippetClasses ??= [];\n demoClasses ??= [];\n\n function isRelevantCode(node: Code): node is RelevantCode {\n if (node.type !== 'code') return false;\n\n let { meta, lang } = node;\n\n meta = meta?.trim();\n\n if (!meta || !lang) return false;\n\n if (!meta.includes('live')) {\n return false;\n }\n\n if (!(ALLOWED_LANGUAGES as unknown as string[]).includes(lang)) return false;\n\n return true;\n }\n\n let copyNode = {\n type: 'html',\n value: copyComponent,\n };\n\n function enhance(code: Code) {\n code.data ??= {};\n (code.data as any)['hProperties'] ??= {};\n // This is secret-to-us-only API, so we don't really care about the type\n (code.data as any)['hProperties'][GLIMDOWN_PREVIEW] = true;\n\n return {\n data: {\n hProperties: { className: snippetClasses },\n },\n type: 'div',\n hProperties: { className: snippetClasses },\n children: [code, copyNode],\n };\n }\n\n function flatReplaceAt<T>(array: T[], index: number, replacement: T[]) {\n array.splice(index, 1, ...replacement);\n }\n\n // because we mutate the tree as we iterate,\n // we need to make sure we don't loop forever\n const seen = new Set();\n\n return function transformer(tree: Parent, file: VFileWithMeta) {\n visit(tree, ['code'], function (node, index, parent) {\n if (parent === null || parent === undefined) return;\n if (index === null || index === undefined) return;\n\n if (!isRelevantCode(node as Code)) {\n let enhanced = enhance(node as Code);\n\n parent.children[index] = enhanced;\n\n return 'skip';\n }\n\n if (seen.has(node)) return 'skip';\n\n seen.add(node);\n\n let { meta, lang, value } = node as Code;\n\n if (!meta) return 'skip';\n if (!lang) return 'skip';\n\n file.data.liveCode ??= [];\n\n let code = value.trim();\n let name = nameFor(code);\n let invocation = invocationOf(name);\n\n let shadow = options.shadowComponent;\n\n let wrapInShadow = shadow && !meta?.includes('no-shadow');\n\n if (wrapInShadow) {\n invocation = `<${shadow}>${invocation}</${shadow}>`;\n }\n\n let invokeNode = {\n type: 'html',\n data: {\n hProperties: { [GLIMDOWN_RENDER]: true },\n },\n value: `<div class=\"${demoClasses}\">${invocation}</div>`,\n };\n\n let wrapper = enhance(node as Code);\n\n file.data.liveCode.push({\n lang,\n name,\n code,\n });\n\n let live = isLive(meta);\n let preview = isPreview(meta);\n let below = isBelow(meta);\n\n if (live && preview && below) {\n flatReplaceAt(parent.children, index, [wrapper, invokeNode]);\n\n return 'skip';\n }\n\n if (live && preview) {\n flatReplaceAt(parent.children, index, [invokeNode, wrapper]);\n\n return 'skip';\n }\n\n if (live) {\n parent.children[index] = invokeNode;\n\n return 'skip';\n }\n\n parent.children[index] = wrapper;\n\n return;\n });\n };\n}\n\nfunction sanitizeForGlimmer(/* options */) {\n return (tree: Parent) => {\n visit(tree, 'element', (node: Parent) => {\n if ('tagName' in node) {\n if (!['pre', 'code'].includes(node.tagName as string)) return;\n\n visit(node, 'text', (textNode: Text) => {\n if ('value' in textNode && textNode.value) {\n textNode.value = textNode.value.replace(/{{/g, '\\\\{{');\n }\n });\n\n return 'skip';\n }\n });\n };\n}\n\nfunction buildCompiler(options: ParseMarkdownOptions) {\n let compiler = unified().use(remarkParse).use(remarkGfm);\n\n /**\n * If this were \"use\"d after `remarkRehype`,\n * remark is gone, and folks would need to work with rehype trees\n */\n if (options.remarkPlugins) {\n options.remarkPlugins.forEach((plugin) => {\n // Arrays are how plugins are passed options (for some reason?)\n // why not just invoke the the function?\n let p = Array.isArray(plugin) ? plugin : [plugin];\n\n compiler = compiler.use(...(p as [any]));\n });\n }\n\n // TODO: we only want to do this when we have pre > code.\n // code can exist inline.\n compiler = compiler.use(liveCodeExtraction, {\n snippets: {\n classList: ['glimdown-snippet', 'relative'],\n },\n demo: {\n classList: ['glimdown-render'],\n },\n copyComponent: options?.CopyComponent,\n shadowComponent: options?.ShadowComponent,\n });\n\n // .use(() => (tree) => visit(tree, (node) => console.log('i', node)))\n // remark rehype is needed to convert markdown to HTML\n // However, it also changes all the nodes, so we need another pass\n // to make sure our Glimmer-aware nodes are in tact\n compiler = compiler.use(remarkRehype, { allowDangerousHtml: true });\n\n // Convert invocables to raw format, so Glimmer can invoke them\n compiler = compiler.use(() => (tree: Node) => {\n visit(tree, function (node) {\n // We rely on an implicit transformation of data.hProperties => properties\n let properties = (node as any).properties;\n\n if (properties?.[GLIMDOWN_PREVIEW]) {\n return 'skip';\n }\n\n if (node.type === 'element' || ('tagName' in node && node.tagName === 'code')) {\n if (properties?.[GLIMDOWN_RENDER]) {\n node.type = 'glimmer_raw';\n\n return;\n }\n\n return 'skip';\n }\n\n if (node.type === 'text' || node.type === 'raw') {\n // definitively not the better way, but this is supposed to detect \"glimmer\" nodes\n if (\n 'value' in node &&\n typeof node.value === 'string' &&\n node.value.match(/<\\/?[_A-Z:0-9].*>/g)\n ) {\n node.type = 'glimmer_raw';\n }\n\n node.type = 'glimmer_raw';\n\n return 'skip';\n }\n\n return;\n });\n });\n\n if (options.rehypePlugins) {\n options.rehypePlugins.forEach((plugin) => {\n // Arrays are how plugins are passed options (for some reason?)\n // why not just invoke the the function?\n let p = Array.isArray(plugin) ? plugin : [plugin];\n\n compiler = compiler.use(...(p as [any]));\n });\n }\n\n compiler = compiler.use(rehypeRaw, { passThrough: ['glimmer_raw', 'raw'] }).use(() => (tree) => {\n visit(tree, 'glimmer_raw', (node: Node) => {\n node.type = 'raw';\n });\n });\n\n compiler = compiler.use(sanitizeForGlimmer);\n\n // Finally convert to string! oofta!\n compiler = compiler.use(rehypeStringify, {\n collapseEmptyAttributes: true,\n closeSelfClosing: true,\n allowParseErrors: true,\n allowDangerousCharacters: true,\n allowDangerousHtml: true,\n }) as any;\n\n return compiler as ReturnType<typeof unified>;\n}\n\ninterface ParseMarkdownOptions {\n CopyComponent?: string;\n ShadowComponent?: string;\n remarkPlugins?: UnifiedPlugin[];\n rehypePlugins?: UnifiedPlugin[];\n}\n\n/**\n * @internal not under semver\n */\nexport async function parseMarkdown(\n input: string,\n options: ParseMarkdownOptions = {}\n): Promise<LiveCodeExtraction> {\n let markdownCompiler = buildCompiler(options);\n let processed = await markdownCompiler.process(input);\n let liveCode = (processed.data as LiveData).liveCode || [];\n let templateOnly = processed.toString();\n\n return { templateOnlyGlimdown: templateOnly, blocks: liveCode };\n}\n"],"names":["GLIMDOWN_PREVIEW","Symbol","GLIMDOWN_RENDER","ALLOWED_LANGUAGES","isLive","meta","includes","isPreview","isBelow","liveCodeExtraction","options","copyComponent","snippets","demo","classList","snippetClasses","demoClasses","isRelevantCode","node","type","lang","trim","copyNode","value","enhance","code","data","hProperties","className","children","flatReplaceAt","array","index","replacement","splice","seen","Set","transformer","tree","file","visit","parent","undefined","enhanced","has","add","liveCode","name","nameFor","invocation","invocationOf","shadow","shadowComponent","wrapInShadow","invokeNode","wrapper","push","live","preview","below","sanitizeForGlimmer","tagName","textNode","replace","buildCompiler","compiler","unified","use","remarkParse","remarkGfm","remarkPlugins","forEach","plugin","p","Array","isArray","CopyComponent","ShadowComponent","remarkRehype","allowDangerousHtml","properties","match","rehypePlugins","rehypeRaw","passThrough","rehypeStringify","collapseEmptyAttributes","closeSelfClosing","allowParseErrors","allowDangerousCharacters","parseMarkdown","input","markdownCompiler","processed","process","templateOnly","toString","templateOnlyGlimdown","blocks"],"mappings":";;;;;;;;;AA4CA,MAAMA,gBAAgB,GAAGC,MAAM,CAAC,sBAAsB,CAAC;AACvD,MAAMC,eAAe,GAAGD,MAAM,CAAC,qBAAqB,CAAC;AACrD,MAAME,iBAAiB,GAAG,CAAC,KAAK,EAAE,KAAK,CAAU;AAKjD,SAASC,MAAMA,CAACC,IAAY,EAAE;AAC5B,EAAA,OAAOA,IAAI,CAACC,QAAQ,CAAC,MAAM,CAAC;AAC9B;AAEA,SAASC,SAASA,CAACF,IAAY,EAAE;AAC/B,EAAA,OAAOA,IAAI,CAACC,QAAQ,CAAC,SAAS,CAAC;AACjC;AAEA,SAASE,OAAOA,CAACH,IAAY,EAAE;AAC7B,EAAA,OAAOA,IAAI,CAACC,QAAQ,CAAC,OAAO,CAAC;AAC/B;;AAEA;AACA,SAASG,kBAAkBA,CAACC,OAAgB,GAAG,EAAE,EAAE;EACjD,IAAI;IAAEC,aAAa;IAAEC,QAAQ;AAAEC,IAAAA;AAAK,GAAC,GAAGH,OA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