ember-repl 4.0.3 → 4.1.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../../src/compile/formats/markdown.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAMjD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,kBAAkB;IACjC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,MAAM,EAAE,aAAa,EAAE,CAAC;CACzB;AAuSD,UAAU,oBAAoB;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,aAAa,EAAE,CAAC;IAChC,aAAa,CAAC,EAAE,aAAa,EAAE,CAAC;CACjC;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,kBAAkB,CAAC,CAO7B"}
1
+ {"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../../src/compile/formats/markdown.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAMjD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,kBAAkB;IACjC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,MAAM,EAAE,aAAa,EAAE,CAAC;CACzB;AA0SD,UAAU,oBAAoB;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,aAAa,EAAE,CAAC;IAChC,aAAa,CAAC,EAAE,aAAa,EAAE,CAAC;CACjC;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,kBAAkB,CAAC,CAO7B"}
@@ -1,12 +1,12 @@
1
1
  import type { ComponentLike } from '@glint/template';
2
- import type { Plugin } from 'unified';
2
+ import type { Pluggable } from 'unified';
3
3
  export interface EvalImportMap {
4
4
  [moduleName: string]: ScopeMap;
5
5
  }
6
6
  export interface ScopeMap {
7
7
  [localName: string]: unknown;
8
8
  }
9
- export type UnifiedPlugin = Plugin;
9
+ export type UnifiedPlugin = Pluggable;
10
10
  export interface CompileResult {
11
11
  component?: ComponentLike;
12
12
  error?: Error;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/compile/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtC,MAAM,WAAW,aAAa;IAC5B,CAAC,UAAU,EAAE,MAAM,GAAG,QAAQ,CAAC;CAChC;AAED,MAAM,WAAW,QAAQ;IACvB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;CAC9B;AAED,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC;AAEnC,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,OAAO,GAAG;IACpB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/compile/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,MAAM,WAAW,aAAa;IAC5B,CAAC,UAAU,EAAE,MAAM,GAAG,QAAQ,CAAC;CAChC;AAED,MAAM,WAAW,QAAQ;IACvB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;CAC9B;AAED,MAAM,MAAM,aAAa,GAAG,SAAS,CAAC;AAEtC,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,OAAO,GAAG;IACpB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC"}
@@ -10,21 +10,6 @@ import { nameFor, invocationOf } from '../utils.js';
10
10
  const GLIMDOWN_PREVIEW = Symbol('__GLIMDOWN_PREVIEW__');
11
11
  const GLIMDOWN_RENDER = Symbol('__GLIMDOWN_RENDER__');
12
12
  const ALLOWED_LANGUAGES = ['gjs', 'hbs'];
13
- const escapeCurlies = node => {
14
- if ('value' in node && node.value) {
15
- node.value = node.value.replace(/{{/g, '\\{{');
16
- }
17
- if ('children' in node && node.children) {
18
- node.children.forEach(child => escapeCurlies(child));
19
- }
20
- if (!node.data) {
21
- return;
22
- }
23
- if ('hChildren' in node.data && Array.isArray(node.data['hChildren'])) {
24
- node.data['hChildren'].forEach(escapeCurlies);
25
- return;
26
- }
27
- };
28
13
  function isLive(meta) {
29
14
  return meta.includes('live');
30
15
  }
@@ -155,6 +140,22 @@ function liveCodeExtraction(options = {}) {
155
140
  });
156
141
  };
157
142
  }
143
+ function sanitizeForGlimmer( /* options */
144
+ ) {
145
+ return tree => {
146
+ visit(tree, 'element', node => {
147
+ if ('tagName' in node) {
148
+ if (node.tagName !== 'pre') 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
+ }
158
159
  function buildCompiler(options) {
159
160
  let compiler = unified().use(remarkParse).use(remarkGfm);
160
161
 
@@ -177,7 +178,10 @@ function buildCompiler(options) {
177
178
  */
178
179
  if (options.remarkPlugins) {
179
180
  options.remarkPlugins.forEach(plugin => {
180
- compiler = compiler.use(plugin);
181
+ // Arrays are how plugins are passed options (for some reason?)
182
+ // why not just invoke the the function?
183
+ let p = Array.isArray(plugin) ? plugin : [plugin];
184
+ compiler = compiler.use(...p);
181
185
  });
182
186
  }
183
187
 
@@ -195,8 +199,6 @@ function buildCompiler(options) {
195
199
  // We rely on an implicit transformation of data.hProperties => properties
196
200
  let properties = node.properties;
197
201
  if (properties?.[GLIMDOWN_PREVIEW]) {
198
- // Have to sanitize anything Glimmer could try to render
199
- escapeCurlies(node);
200
202
  return 'skip';
201
203
  }
202
204
  if (node.type === 'element' || 'tagName' in node && node.tagName === 'code') {
@@ -204,7 +206,6 @@ function buildCompiler(options) {
204
206
  node.type = 'glimmer_raw';
205
207
  return;
206
208
  }
207
- escapeCurlies(node);
208
209
  return 'skip';
209
210
  }
210
211
  if (node.type === 'text' || node.type === 'raw') {
@@ -220,7 +221,10 @@ function buildCompiler(options) {
220
221
  });
221
222
  if (options.rehypePlugins) {
222
223
  options.rehypePlugins.forEach(plugin => {
223
- compiler = compiler.use(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);
224
228
  });
225
229
  }
226
230
  compiler = compiler.use(rehypeRaw, {
@@ -230,6 +234,7 @@ function buildCompiler(options) {
230
234
  node.type = 'raw';
231
235
  });
232
236
  });
237
+ compiler = compiler.use(sanitizeForGlimmer);
233
238
 
234
239
  // Finally convert to string! oofta!
235
240
  compiler = compiler.use(rehypeStringify, {
@@ -1 +1 @@
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\nconst escapeCurlies = (node: Text | Parent) => {\n if ('value' in node && node.value) {\n node.value = node.value.replace(/{{/g, '\\\\{{');\n }\n\n if ('children' in node && node.children) {\n node.children.forEach((child) => escapeCurlies(child as Parent));\n }\n\n if (!node.data) {\n return;\n }\n\n if ('hChildren' in node.data && Array.isArray(node.data['hChildren'])) {\n node.data['hChildren'].forEach(escapeCurlies);\n\n return;\n }\n};\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 buildCompiler(options: ParseMarkdownOptions) {\n let compiler = unified().use(remarkParse).use(remarkGfm);\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 /**\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 compiler = compiler.use(plugin) as any;\n });\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 // Have to sanitize anything Glimmer could try to render\n escapeCurlies(node as Parent);\n\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 escapeCurlies(node as Parent);\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 compiler = compiler.use(plugin) 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 // 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","escapeCurlies","node","value","replace","children","forEach","child","data","Array","isArray","isLive","meta","includes","isPreview","isBelow","liveCodeExtraction","options","copyComponent","snippets","demo","classList","snippetClasses","demoClasses","isRelevantCode","type","lang","trim","copyNode","enhance","code","hProperties","className","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","buildCompiler","compiler","unified","use","remarkParse","remarkGfm","CopyComponent","ShadowComponent","remarkPlugins","plugin","remarkRehype","allowDangerousHtml","properties","tagName","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,CAAA;AACvD,MAAMC,eAAe,GAAGD,MAAM,CAAC,qBAAqB,CAAC,CAAA;AACrD,MAAME,iBAAiB,GAAG,CAAC,KAAK,EAAE,KAAK,CAAU,CAAA;AAKjD,MAAMC,aAAa,GAAIC,IAAmB,IAAK;AAC7C,EAAA,IAAI,OAAO,IAAIA,IAAI,IAAIA,IAAI,CAACC,KAAK,EAAE;AACjCD,IAAAA,IAAI,CAACC,KAAK,GAAGD,IAAI,CAACC,KAAK,CAACC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;AAChD,GAAA;AAEA,EAAA,IAAI,UAAU,IAAIF,IAAI,IAAIA,IAAI,CAACG,QAAQ,EAAE;IACvCH,IAAI,CAACG,QAAQ,CAACC,OAAO,CAAEC,KAAK,IAAKN,aAAa,CAACM,KAAe,CAAC,CAAC,CAAA;AAClE,GAAA;AAEA,EAAA,IAAI,CAACL,IAAI,CAACM,IAAI,EAAE;AACd,IAAA,OAAA;AACF,GAAA;AAEA,EAAA,IAAI,WAAW,IAAIN,IAAI,CAACM,IAAI,IAAIC,KAAK,CAACC,OAAO,CAACR,IAAI,CAACM,IAAI,CAAC,WAAW,CAAC,CAAC,EAAE;IACrEN,IAAI,CAACM,IAAI,CAAC,WAAW,CAA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Raw 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 (node.tagName !== 'pre') 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 // 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 /**\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 // .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","CopyComponent","ShadowComponent","remarkPlugins","forEach","plugin","p","Array","isArray","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,CAAA;AACvD,MAAMC,eAAe,GAAGD,MAAM,CAAC,qBAAqB,CAAC,CAAA;AACrD,MAAME,iBAAiB,GAAG,CAAC,KAAK,EAAE,KAAK,CAAU,CAAA;AAKjD,SAASC,MAAMA,CAACC,IAAY,EAAE;AAC5B,EAAA,OAAOA,IAAI,CAACC,QAAQ,CAAC,MAAM,CAAC,CAAA;AAC9B,CAAA;AAEA,SAASC,SAASA,CAACF,IAAY,EAAE;AAC/B,EAAA,OAAOA,IAAI,CAACC,QAAQ,CAAC,SAAS,CAAC,CAAA;AACjC,CAAA;AAEA,SAASE,OAAOA,CAACH,IAAY,EAAE;AAC7B,EAAA,OAAOA,IAAI,CAACC,QAAQ,CAAC,OAAO,CAAC,CAAA;AAC/B,CAAA;;AAEA;AACA,SAASG,kBAAkBA,CAACC,OAAgB,GAAG,EAAE,EAAE;EACjD,IAAI;IAAEC,aAAa;IAAEC,QAAQ;AAAEC,IAAAA,IAAAA;AAAK,GAAC,GAAGH,OAAO,CAAA;EAC/C,IAAI;AAAEI,IAAAA,SAAS,EAAEC,cAAAA;AAAe,GAAC,GAAGH,QAAQ,IAAI,EAAE,CAAA;EAClD,IAAI;AAAEE,IAAAA,SAAS,E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AAAA,MAAM,EAAEpD,QAAAA;GAAU,CAAA;AACjE;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-repl",
3
- "version": "4.0.3",
3
+ "version": "4.1.1",
4
4
  "description": "Addon for enabling REPL and Playground creation with Ember/Glimmer",
5
5
  "keywords": [
6
6
  "ember-addon"
@@ -49,26 +49,6 @@ const ALLOWED_LANGUAGES = ['gjs', 'hbs'] as const;
49
49
  type AllowedLanguage = (typeof ALLOWED_LANGUAGES)[number];
50
50
  type RelevantCode = Omit<Code, 'lang'> & { lang: AllowedLanguage };
51
51
 
52
- const escapeCurlies = (node: Text | Parent) => {
53
- if ('value' in node && node.value) {
54
- node.value = node.value.replace(/{{/g, '\\{{');
55
- }
56
-
57
- if ('children' in node && node.children) {
58
- node.children.forEach((child) => escapeCurlies(child as Parent));
59
- }
60
-
61
- if (!node.data) {
62
- return;
63
- }
64
-
65
- if ('hChildren' in node.data && Array.isArray(node.data['hChildren'])) {
66
- node.data['hChildren'].forEach(escapeCurlies);
67
-
68
- return;
69
- }
70
- };
71
-
72
52
  function isLive(meta: string) {
73
53
  return meta.includes('live');
74
54
  }
@@ -218,6 +198,24 @@ function liveCodeExtraction(options: Options = {}) {
218
198
  };
219
199
  }
220
200
 
201
+ function sanitizeForGlimmer(/* options */) {
202
+ return (tree: Parent) => {
203
+ visit(tree, 'element', (node: Parent) => {
204
+ if ('tagName' in node) {
205
+ if (node.tagName !== 'pre') return;
206
+
207
+ visit(node, 'text', (textNode: Text) => {
208
+ if ('value' in textNode && textNode.value) {
209
+ textNode.value = textNode.value.replace(/{{/g, '\\{{');
210
+ }
211
+ });
212
+
213
+ return 'skip';
214
+ }
215
+ });
216
+ };
217
+ }
218
+
221
219
  function buildCompiler(options: ParseMarkdownOptions) {
222
220
  let compiler = unified().use(remarkParse).use(remarkGfm);
223
221
 
@@ -240,7 +238,11 @@ function buildCompiler(options: ParseMarkdownOptions) {
240
238
  */
241
239
  if (options.remarkPlugins) {
242
240
  options.remarkPlugins.forEach((plugin) => {
243
- compiler = compiler.use(plugin) as any;
241
+ // Arrays are how plugins are passed options (for some reason?)
242
+ // why not just invoke the the function?
243
+ let p = Array.isArray(plugin) ? plugin : [plugin];
244
+
245
+ compiler = compiler.use(...(p as [any]));
244
246
  });
245
247
  }
246
248
 
@@ -257,9 +259,6 @@ function buildCompiler(options: ParseMarkdownOptions) {
257
259
  let properties = (node as any).properties;
258
260
 
259
261
  if (properties?.[GLIMDOWN_PREVIEW]) {
260
- // Have to sanitize anything Glimmer could try to render
261
- escapeCurlies(node as Parent);
262
-
263
262
  return 'skip';
264
263
  }
265
264
 
@@ -270,8 +269,6 @@ function buildCompiler(options: ParseMarkdownOptions) {
270
269
  return;
271
270
  }
272
271
 
273
- escapeCurlies(node as Parent);
274
-
275
272
  return 'skip';
276
273
  }
277
274
 
@@ -296,7 +293,11 @@ function buildCompiler(options: ParseMarkdownOptions) {
296
293
 
297
294
  if (options.rehypePlugins) {
298
295
  options.rehypePlugins.forEach((plugin) => {
299
- compiler = compiler.use(plugin) as any;
296
+ // Arrays are how plugins are passed options (for some reason?)
297
+ // why not just invoke the the function?
298
+ let p = Array.isArray(plugin) ? plugin : [plugin];
299
+
300
+ compiler = compiler.use(...(p as [any]));
300
301
  });
301
302
  }
302
303
 
@@ -306,6 +307,8 @@ function buildCompiler(options: ParseMarkdownOptions) {
306
307
  });
307
308
  });
308
309
 
310
+ compiler = compiler.use(sanitizeForGlimmer);
311
+
309
312
  // Finally convert to string! oofta!
310
313
  compiler = compiler.use(rehypeStringify, {
311
314
  collapseEmptyAttributes: true,
@@ -1,5 +1,5 @@
1
1
  import type { ComponentLike } from '@glint/template';
2
- import type { Plugin } from 'unified';
2
+ import type { Pluggable } from 'unified';
3
3
 
4
4
  export interface EvalImportMap {
5
5
  [moduleName: string]: ScopeMap;
@@ -9,7 +9,7 @@ export interface ScopeMap {
9
9
  [localName: string]: unknown;
10
10
  }
11
11
 
12
- export type UnifiedPlugin = Plugin; // Parameters<ReturnType<typeof unified>['use']>[0];
12
+ export type UnifiedPlugin = Pluggable;
13
13
 
14
14
  export interface CompileResult {
15
15
  component?: ComponentLike;