ember-repl 7.1.0 → 7.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.
Files changed (37) hide show
  1. package/declarations/services/known-modules.d.ts.map +1 -1
  2. package/dist/services/compiler.js +404 -1
  3. package/dist/services/compiler.js.map +1 -1
  4. package/dist/services/known-modules.js +8 -7
  5. package/dist/services/known-modules.js.map +1 -1
  6. package/package.json +1 -1
  7. package/src/services/known-modules.ts +8 -7
  8. package/dist/blank-line-Bzg2Qt4K.js +0 -482
  9. package/dist/blank-line-Bzg2Qt4K.js.map +0 -1
  10. package/dist/default-CoqAuVeH.js +0 -4
  11. package/dist/default-CoqAuVeH.js.map +0 -1
  12. package/dist/index-Bm1Y84Cu.js +0 -5721
  13. package/dist/index-Bm1Y84Cu.js.map +0 -1
  14. package/dist/index-Bo3xsMqx.js +0 -410
  15. package/dist/index-Bo3xsMqx.js.map +0 -1
  16. package/dist/index-Bxzjtr16.js +0 -87
  17. package/dist/index-Bxzjtr16.js.map +0 -1
  18. package/dist/index-C-twRw93.js +0 -9988
  19. package/dist/index-C-twRw93.js.map +0 -1
  20. package/dist/index-C371bO_b.js +0 -1553
  21. package/dist/index-C371bO_b.js.map +0 -1
  22. package/dist/index-CDSIcg03.js +0 -9070
  23. package/dist/index-CDSIcg03.js.map +0 -1
  24. package/dist/index-CGDqu098.js +0 -1925
  25. package/dist/index-CGDqu098.js.map +0 -1
  26. package/dist/index-DIRpUv6Z.js +0 -2
  27. package/dist/index-DIRpUv6Z.js.map +0 -1
  28. package/dist/index-DMSCybEq.js +0 -2640
  29. package/dist/index-DMSCybEq.js.map +0 -1
  30. package/dist/index-DP_Su7Zc.js +0 -362
  31. package/dist/index-DP_Su7Zc.js.map +0 -1
  32. package/dist/index-Dr5iYoKt.js +0 -1551
  33. package/dist/index-Dr5iYoKt.js.map +0 -1
  34. package/dist/index-ZyJlPFQY.js +0 -249
  35. package/dist/index-ZyJlPFQY.js.map +0 -1
  36. package/dist/index-k6CfLgeq.js +0 -26
  37. package/dist/index-k6CfLgeq.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"known-modules.d.ts","sourceRoot":"","sources":["../../src/services/known-modules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAwHrD;;;GAGG;AACH,eAAO,MAAM,OAAO,GAAI,cAAc,SAAS,KAAG,SAMhD,CAAC"}
1
+ {"version":3,"file":"known-modules.d.ts","sourceRoot":"","sources":["../../src/services/known-modules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAyHrD;;;GAGG;AACH,eAAO,MAAM,OAAO,GAAI,cAAc,SAAS,KAAG,SAMhD,CAAC"}
@@ -14,7 +14,410 @@ import { Compiler } from 'repl-sdk';
14
14
  import { nameFor } from '../compile/utils.js';
15
15
  import { modules } from './known-modules.js';
16
16
  import { g, i, n } from 'decorator-transforms/runtime-esm';
17
- import { v as visit } from '../index-Bo3xsMqx.js';
17
+
18
+ /**
19
+ * @import {Node, Parent} from 'unist'
20
+ */
21
+
22
+
23
+ /**
24
+ * Generate an assertion from a test.
25
+ *
26
+ * Useful if you’re going to test many nodes, for example when creating a
27
+ * utility where something else passes a compatible test.
28
+ *
29
+ * The created function is a bit faster because it expects valid input only:
30
+ * a `node`, `index`, and `parent`.
31
+ *
32
+ * @param {Test} test
33
+ * * when nullish, checks if `node` is a `Node`.
34
+ * * when `string`, works like passing `(node) => node.type === test`.
35
+ * * when `function` checks if function passed the node is true.
36
+ * * when `object`, checks that all keys in test are in node, and that they have (strictly) equal values.
37
+ * * when `array`, checks if any one of the subtests pass.
38
+ * @returns {Check}
39
+ * An assertion.
40
+ */
41
+ const convert =
42
+ // Note: overloads in JSDoc can’t yet use different `@template`s.
43
+ /**
44
+ * @type {(
45
+ * (<Condition extends string>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition}) &
46
+ * (<Condition extends Props>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Condition) &
47
+ * (<Condition extends TestFunction>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Predicate<Condition, Node>) &
48
+ * ((test?: null | undefined) => (node?: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node) &
49
+ * ((test?: Test) => Check)
50
+ * )}
51
+ */
52
+
53
+ /**
54
+ * @param {Test} [test]
55
+ * @returns {Check}
56
+ */
57
+ function (test) {
58
+ if (test === null || test === undefined) {
59
+ return ok;
60
+ }
61
+ if (typeof test === 'function') {
62
+ return castFactory(test);
63
+ }
64
+ if (typeof test === 'object') {
65
+ return Array.isArray(test) ? anyFactory(test) :
66
+ // Cast because `ReadonlyArray` goes into the above but `isArray`
67
+ // narrows to `Array`.
68
+ propertiesFactory(/** @type {Props} */test);
69
+ }
70
+ if (typeof test === 'string') {
71
+ return typeFactory(test);
72
+ }
73
+ throw new Error('Expected function, string, or object as test');
74
+ };
75
+
76
+ /**
77
+ * @param {Array<Props | TestFunction | string>} tests
78
+ * @returns {Check}
79
+ */
80
+ function anyFactory(tests) {
81
+ /** @type {Array<Check>} */
82
+ const checks = [];
83
+ let index = -1;
84
+ while (++index < tests.length) {
85
+ checks[index] = convert(tests[index]);
86
+ }
87
+ return castFactory(any);
88
+
89
+ /**
90
+ * @this {unknown}
91
+ * @type {TestFunction}
92
+ */
93
+ function any(...parameters) {
94
+ let index = -1;
95
+ while (++index < checks.length) {
96
+ if (checks[index].apply(this, parameters)) return true;
97
+ }
98
+ return false;
99
+ }
100
+ }
101
+
102
+ /**
103
+ * Turn an object into a test for a node with a certain fields.
104
+ *
105
+ * @param {Props} check
106
+ * @returns {Check}
107
+ */
108
+ function propertiesFactory(check) {
109
+ const checkAsRecord = /** @type {Record<string, unknown>} */check;
110
+ return castFactory(all);
111
+
112
+ /**
113
+ * @param {Node} node
114
+ * @returns {boolean}
115
+ */
116
+ function all(node) {
117
+ const nodeAsRecord = /** @type {Record<string, unknown>} */
118
+ /** @type {unknown} */node;
119
+
120
+ /** @type {string} */
121
+ let key;
122
+ for (key in check) {
123
+ if (nodeAsRecord[key] !== checkAsRecord[key]) return false;
124
+ }
125
+ return true;
126
+ }
127
+ }
128
+
129
+ /**
130
+ * Turn a string into a test for a node with a certain type.
131
+ *
132
+ * @param {string} check
133
+ * @returns {Check}
134
+ */
135
+ function typeFactory(check) {
136
+ return castFactory(type);
137
+
138
+ /**
139
+ * @param {Node} node
140
+ */
141
+ function type(node) {
142
+ return node && node.type === check;
143
+ }
144
+ }
145
+
146
+ /**
147
+ * Turn a custom test into a test for a node that passes that test.
148
+ *
149
+ * @param {TestFunction} testFunction
150
+ * @returns {Check}
151
+ */
152
+ function castFactory(testFunction) {
153
+ return check;
154
+
155
+ /**
156
+ * @this {unknown}
157
+ * @type {Check}
158
+ */
159
+ function check(value, index, parent) {
160
+ return Boolean(looksLikeANode(value) && testFunction.call(this, value, typeof index === 'number' ? index : undefined, parent || undefined));
161
+ }
162
+ }
163
+ function ok() {
164
+ return true;
165
+ }
166
+
167
+ /**
168
+ * @param {unknown} value
169
+ * @returns {value is Node}
170
+ */
171
+ function looksLikeANode(value) {
172
+ return value !== null && typeof value === 'object' && 'type' in value;
173
+ }
174
+
175
+ /**
176
+ * @param {string} d
177
+ * @returns {string}
178
+ */
179
+ function color(d) {
180
+ return d;
181
+ }
182
+
183
+ /**
184
+ * @import {Node as UnistNode, Parent as UnistParent} from 'unist'
185
+ */
186
+
187
+
188
+ /** @type {Readonly<ActionTuple>} */
189
+ const empty = [];
190
+
191
+ /**
192
+ * Continue traversing as normal.
193
+ */
194
+ const CONTINUE = true;
195
+
196
+ /**
197
+ * Stop traversing immediately.
198
+ */
199
+ const EXIT = false;
200
+
201
+ /**
202
+ * Do not traverse this node’s children.
203
+ */
204
+ const SKIP = 'skip';
205
+
206
+ /**
207
+ * Visit nodes, with ancestral information.
208
+ *
209
+ * This algorithm performs *depth-first* *tree traversal* in *preorder*
210
+ * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).
211
+ *
212
+ * You can choose for which nodes `visitor` is called by passing a `test`.
213
+ * For complex tests, you should test yourself in `visitor`, as it will be
214
+ * faster and will have improved type information.
215
+ *
216
+ * Walking the tree is an intensive task.
217
+ * Make use of the return values of the visitor when possible.
218
+ * Instead of walking a tree multiple times, walk it once, use `unist-util-is`
219
+ * to check if a node matches, and then perform different operations.
220
+ *
221
+ * You can change the tree.
222
+ * See `Visitor` for more info.
223
+ *
224
+ * @overload
225
+ * @param {Tree} tree
226
+ * @param {Check} check
227
+ * @param {BuildVisitor<Tree, Check>} visitor
228
+ * @param {boolean | null | undefined} [reverse]
229
+ * @returns {undefined}
230
+ *
231
+ * @overload
232
+ * @param {Tree} tree
233
+ * @param {BuildVisitor<Tree>} visitor
234
+ * @param {boolean | null | undefined} [reverse]
235
+ * @returns {undefined}
236
+ *
237
+ * @param {UnistNode} tree
238
+ * Tree to traverse.
239
+ * @param {Visitor | Test} test
240
+ * `unist-util-is`-compatible test
241
+ * @param {Visitor | boolean | null | undefined} [visitor]
242
+ * Handle each node.
243
+ * @param {boolean | null | undefined} [reverse]
244
+ * Traverse in reverse preorder (NRL) instead of the default preorder (NLR).
245
+ * @returns {undefined}
246
+ * Nothing.
247
+ *
248
+ * @template {UnistNode} Tree
249
+ * Node type.
250
+ * @template {Test} Check
251
+ * `unist-util-is`-compatible test.
252
+ */
253
+ function visitParents(tree, test, visitor, reverse) {
254
+ /** @type {Test} */
255
+ let check;
256
+ if (typeof test === 'function' && typeof visitor !== 'function') {
257
+ reverse = visitor;
258
+ // @ts-expect-error no visitor given, so `visitor` is test.
259
+ visitor = test;
260
+ } else {
261
+ // @ts-expect-error visitor given, so `test` isn’t a visitor.
262
+ check = test;
263
+ }
264
+ const is = convert(check);
265
+ const step = reverse ? -1 : 1;
266
+ factory(tree, undefined, [])();
267
+
268
+ /**
269
+ * @param {UnistNode} node
270
+ * @param {number | undefined} index
271
+ * @param {Array<UnistParent>} parents
272
+ */
273
+ function factory(node, index, parents) {
274
+ const value = /** @type {Record<string, unknown>} */
275
+ node && typeof node === 'object' ? node : {};
276
+ if (typeof value.type === 'string') {
277
+ const name =
278
+ // `hast`
279
+ typeof value.tagName === 'string' ? value.tagName :
280
+ // `xast`
281
+ typeof value.name === 'string' ? value.name : undefined;
282
+ Object.defineProperty(visit, 'name', {
283
+ value: 'node (' + color(node.type + (name ? '<' + name + '>' : '')) + ')'
284
+ });
285
+ }
286
+ return visit;
287
+ function visit() {
288
+ /** @type {Readonly<ActionTuple>} */
289
+ let result = empty;
290
+ /** @type {Readonly<ActionTuple>} */
291
+ let subresult;
292
+ /** @type {number} */
293
+ let offset;
294
+ /** @type {Array<UnistParent>} */
295
+ let grandparents;
296
+ if (!test || is(node, index, parents[parents.length - 1] || undefined)) {
297
+ // @ts-expect-error: `visitor` is now a visitor.
298
+ result = toResult(visitor(node, parents));
299
+ if (result[0] === EXIT) {
300
+ return result;
301
+ }
302
+ }
303
+ if ('children' in node && node.children) {
304
+ const nodeAsParent = /** @type {UnistParent} */node;
305
+ if (nodeAsParent.children && result[0] !== SKIP) {
306
+ offset = (reverse ? nodeAsParent.children.length : -1) + step;
307
+ grandparents = parents.concat(nodeAsParent);
308
+ while (offset > -1 && offset < nodeAsParent.children.length) {
309
+ const child = nodeAsParent.children[offset];
310
+ subresult = factory(child, offset, grandparents)();
311
+ if (subresult[0] === EXIT) {
312
+ return subresult;
313
+ }
314
+ offset = typeof subresult[1] === 'number' ? subresult[1] : offset + step;
315
+ }
316
+ }
317
+ }
318
+ return result;
319
+ }
320
+ }
321
+ }
322
+
323
+ /**
324
+ * Turn a return value into a clean result.
325
+ *
326
+ * @param {VisitorResult} value
327
+ * Valid return values from visitors.
328
+ * @returns {Readonly<ActionTuple>}
329
+ * Clean result.
330
+ */
331
+ function toResult(value) {
332
+ if (Array.isArray(value)) {
333
+ return value;
334
+ }
335
+ if (typeof value === 'number') {
336
+ return [CONTINUE, value];
337
+ }
338
+ return value === null || value === undefined ? empty : [value];
339
+ }
340
+
341
+ /**
342
+ * @typedef {import('unist').Node} UnistNode
343
+ * @typedef {import('unist').Parent} UnistParent
344
+ * @typedef {import('unist-util-visit-parents').VisitorResult} VisitorResult
345
+ */
346
+
347
+
348
+ /**
349
+ * Visit nodes.
350
+ *
351
+ * This algorithm performs *depth-first* *tree traversal* in *preorder*
352
+ * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).
353
+ *
354
+ * You can choose for which nodes `visitor` is called by passing a `test`.
355
+ * For complex tests, you should test yourself in `visitor`, as it will be
356
+ * faster and will have improved type information.
357
+ *
358
+ * Walking the tree is an intensive task.
359
+ * Make use of the return values of the visitor when possible.
360
+ * Instead of walking a tree multiple times, walk it once, use `unist-util-is`
361
+ * to check if a node matches, and then perform different operations.
362
+ *
363
+ * You can change the tree.
364
+ * See `Visitor` for more info.
365
+ *
366
+ * @overload
367
+ * @param {Tree} tree
368
+ * @param {Check} check
369
+ * @param {BuildVisitor<Tree, Check>} visitor
370
+ * @param {boolean | null | undefined} [reverse]
371
+ * @returns {undefined}
372
+ *
373
+ * @overload
374
+ * @param {Tree} tree
375
+ * @param {BuildVisitor<Tree>} visitor
376
+ * @param {boolean | null | undefined} [reverse]
377
+ * @returns {undefined}
378
+ *
379
+ * @param {UnistNode} tree
380
+ * Tree to traverse.
381
+ * @param {Visitor | Test} testOrVisitor
382
+ * `unist-util-is`-compatible test (optional, omit to pass a visitor).
383
+ * @param {Visitor | boolean | null | undefined} [visitorOrReverse]
384
+ * Handle each node (when test is omitted, pass `reverse`).
385
+ * @param {boolean | null | undefined} [maybeReverse=false]
386
+ * Traverse in reverse preorder (NRL) instead of the default preorder (NLR).
387
+ * @returns {undefined}
388
+ * Nothing.
389
+ *
390
+ * @template {UnistNode} Tree
391
+ * Node type.
392
+ * @template {Test} Check
393
+ * `unist-util-is`-compatible test.
394
+ */
395
+ function visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {
396
+ /** @type {boolean | null | undefined} */
397
+ let reverse;
398
+ /** @type {Test} */
399
+ let test;
400
+ /** @type {Visitor} */
401
+ let visitor;
402
+ {
403
+ // @ts-expect-error: assume the overload with test was given.
404
+ test = testOrVisitor;
405
+ // @ts-expect-error: assume the overload with test was given.
406
+ visitor = visitorOrReverse;
407
+ reverse = maybeReverse;
408
+ }
409
+ visitParents(tree, test, overload, reverse);
410
+
411
+ /**
412
+ * @param {UnistNode} node
413
+ * @param {Array<UnistParent>} parents
414
+ */
415
+ function overload(node, parents) {
416
+ const parent = parents[parents.length - 1];
417
+ const index = parent ? parent.children.indexOf(node) : undefined;
418
+ return visitor(node, index, parent);
419
+ }
420
+ }
18
421
 
19
422
  /* eslint-disable getter-return */
20
423
 
@@ -1 +1 @@
1
- {"version":3,"file":"compiler.js","sources":["../../src/services/compiler.ts"],"sourcesContent":["/* eslint-disable getter-return */\n \n// @ts-ignore\nimport { tracked } from '@glimmer/tracking';\nimport { setComponentTemplate } from '@ember/component';\nimport templateOnly from '@ember/component/template-only';\nimport { assert } from '@ember/debug';\nimport { registerDestructor } from '@ember/destroyable';\nimport { array, concat, fn, get, hash } from '@ember/helper';\nimport { on } from '@ember/modifier';\nimport { getOwner } from '@ember/owner';\nimport { precompileTemplate } from '@ember/template-compilation';\nimport { waitFor } from '@ember/test-waiters';\n\nimport { createStore } from 'ember-primitives/store';\nimport { resource } from 'ember-resources';\nimport { Compiler } from 'repl-sdk';\nimport { visit } from 'unist-util-visit';\n\nimport { nameFor } from '../compile/utils.ts';\nimport { modules } from './known-modules.ts';\n\nimport type { CompileResult, ModuleMap } from '../compile/types.ts';\nimport type { ComponentLike } from '@glint/template';\nimport type { EditorView } from 'codemirror';\nimport type { ErrorMessage, InfoMessage, Message } from 'repl-sdk';\n\nexport function getCompiler(context: object) {\n const owner = getOwner(context) ?? context;\n\n assert(`Missing owner. Cannot use ember-repl's compiler without an owner.`, owner);\n\n return createStore(owner, CompilerService);\n}\n\n/**\n * Old way to make static components, because\n * https://github.com/emberjs/ember.js/issues/20913\n *\n * The runtime compiler doesn't allow you to catch compiler errors.\n * This particular component doesn't need to be runtime anyway.\n */\nfunction rendersElement(x: { element: Element; destroy: () => void }): ComponentLike {\n const render = resource(({ on }) => {\n on.cleanup(() => {\n x.destroy();\n });\n\n return x.element;\n });\n\n return setComponentTemplate(\n precompileTemplate(`{{render}}`, {\n strictMode: true,\n scope: () => ({ render }),\n }),\n templateOnly()\n ) as ComponentLike;\n}\n\ninterface CompilerOptions {\n hbs?: {\n scope?: Record<string, unknown>;\n };\n md?: {\n remarkPlugins?: unknown[];\n rehypePlugins?: unknown[];\n };\n gmd?: {\n scope?: Record<string, unknown>;\n remarkPlugins?: unknown[];\n rehypePlugins?: unknown[];\n };\n}\n\n/**\n * Standard for the REPL, not real apps.\n * HBS isn't used in real apps (that are fully up to date)\n */\nconst standardScope = {\n // These are only added here because it's convenient for hbs\n // to have them\n array,\n concat,\n fn,\n get,\n hash,\n on,\n // The default available scope for gjs:\n //\n // We don't use gjs transpilation here, because hbs transpilation\n // doesn't need to go through the babel infra, so it's faster this way,\n // even though it's more \"verbose\" and could get out of sync from the\n // implementations / source-of-truth.\n //\n // https://github.com/emberjs/babel-plugin-ember-template-compilation/blob/main/src/scope-locals.ts#L16\n //\n // ////////////////\n // namespaces\n // ////////////////\n // TC39\n globalThis,\n Atomics,\n JSON,\n Math,\n Reflect,\n // WHATWG\n localStorage,\n sessionStorage,\n URL,\n // ////////////////\n // functions / utilities\n // ////////////////\n // TC39\n isNaN,\n isFinite,\n parseInt,\n parseFloat,\n decodeURI,\n decodeURIComponent,\n encodeURI,\n encodeURIComponent,\n // WHATWG\n postMessage,\n structuredClone,\n // ////////////////\n // new-less Constructors (still functions)\n // ////////////////\n // TC39\n Array, // different behavior from (array)\n BigInt,\n Boolean,\n Date,\n Number,\n Object, // different behavior from (hash)\n String,\n // ////////////////\n // Values\n // ////////////////\n // TC39\n Infinity,\n NaN,\n // WHATWG\n isSecureContext,\n};\n\nexport default class CompilerService {\n #compiler: Compiler | undefined;\n\n constructor() {\n const global = getGlobal();\n\n global.REPL ||= {};\n\n if (global.REPL.compiler) {\n return global.REPL.compiler;\n }\n\n global.REPL.compiler = this;\n\n registerDestructor(this, () => {\n delete global.REPL?.compiler;\n });\n }\n\n @tracked messages: Message[] = [];\n\n get lastInfo(): InfoMessage | undefined {\n const m = this.messages;\n\n for (let i = m.length - 1; i >= 0; i--) {\n const current = m[i];\n\n if (current?.type === 'info') return current;\n }\n }\n\n get lastError(): ErrorMessage | undefined {\n const m = this.messages;\n\n for (let i = m.length - 1; i >= 0; i--) {\n const current = m[i];\n\n if (current?.type === 'error') return current;\n }\n }\n\n /**\n * @param {ModuleMap} [ extraModules ]: map of import paths to modules.\n * These modules are useful if you need to document a library or a any design system or a styleguide or\n * if there are additional modules that could be imported in the passed `code`.\n * @param {object} [options] optional compiler options for each format/flavor\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 */\n setup = (extraModules: ModuleMap = {}, options: CompilerOptions = {}) => {\n const localModules = modules(extraModules);\n\n this.#compiler = new Compiler({\n logging: location.search.includes('debug'),\n resolve: {\n ...localModules,\n },\n on: {\n log: (type: Message['type'], message: string) => {\n this.messages.push({ type, message });\n // Waiting on better array primitive\n // eslint-disable-next-line no-self-assign\n this.messages = this.messages;\n },\n },\n options: {\n ...options,\n gjs: {\n // owner: getOwner(this),\n owner: {\n lookup: () => {},\n resolveRegistration: () => {},\n },\n },\n gmd: {\n ...(options.gmd ?? {}),\n scope: {\n ...standardScope,\n ...(options.gmd?.scope ?? {}),\n },\n remarkPlugins: [\n function defaultHbsToEmber() {\n return function transformer(tree: any) {\n visit(tree, 'code', (node) => {\n if (node.lang === 'hbs') {\n if (!node.meta) {\n node.meta = 'ember';\n } else {\n node.meta += ' ember';\n }\n\n return node;\n }\n });\n\n return tree;\n };\n },\n ...(options.gmd?.remarkPlugins ?? []),\n ],\n },\n hbs: {\n ember: {\n ...(options.hbs ?? {}),\n scope: {\n ...standardScope,\n ...(options.hbs?.scope ?? {}),\n },\n },\n },\n },\n });\n };\n\n get compiler(): Compiler {\n /**\n * This is useful for our own testing.\n * not sure if this would be a footgun for consumers' usage\n */\n if (!this.#compiler) {\n this.setup();\n }\n\n assert(\n `Expected a compiled to be setup on the compiler service. Use \\`compiler.setup()\\` first.`,\n this.#compiler\n );\n\n return this.#compiler;\n }\n\n async createEditor(\n element: HTMLElement,\n options: {\n text: string | null | undefined;\n format: string;\n handleUpdate: (text: string) => void;\n extensions?: unknown[];\n }\n ): Promise<{\n view: EditorView;\n setText: (text: string, format: string) => Promise<void>;\n setFormat: (format: string) => Promise<void>;\n }> {\n return this.compiler.createEditor(element, options);\n }\n\n async #compile(ext: string, text: string, options?: Record<string, unknown>) {\n /**\n * Protect from accidental backtracking-render assertions\n * (infinite loop protection)\n *\n * This function doesn't ready any tracked data, so we don't need to\n * worry about invalidation or anything.\n */\n await Promise.resolve();\n\n this.messages = [];\n\n return this.compiler.compile(ext, text, options ?? {});\n }\n\n /**\n * @public\n *\n * Defers to the underlying repl-SDK and gives us a component we can render.\n *\n * @param {string} ext the ext/format to be compiled\n * @param {string} text the code to be compiled using the configured compiler for the ext\n */\n @waitFor\n async compile(ext: string, text: string, options?: Record<string, unknown>) {\n const name = nameFor(text);\n let component: undefined | ComponentLike;\n let error: undefined | Error;\n\n try {\n if (ext === 'hbs') {\n /**\n * Are there other hbs-using frameworks?\n */\n options ||= {};\n options.flavor = 'ember';\n }\n\n const result = await this.#compile(ext, text, options);\n\n component = rendersElement(result);\n } catch (e) {\n // Put a breakpoint here to debug\n // debugger;\n console.error(e);\n error = e as Error | undefined;\n }\n\n return { name, component, error };\n }\n\n /**\n * @public\n *\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 * @param {string} code the code to be compiled\n */\n compileGJS(code: string): Promise<CompileResult> {\n return this.compile('gjs', code);\n }\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 */\n @waitFor\n async compileHBS(\n source: string,\n options: {\n /**\n * Used for debug viewing\n */\n moduleName?: string;\n /**\n * Additional values to include in hbs scope.\n * This is a _strict mode_ hbs component.\n */\n scope?: Record<string, unknown>;\n } = {}\n ): Promise<CompileResult> {\n return this.compile('hbs', source, options);\n }\n\n @waitFor\n compileMD(\n source: string,\n options?: {\n remarkPlugins?: unknown[];\n rehypePlugins?: unknown[];\n }\n ): Promise<CompileResult> {\n return this.compile('md', source, options);\n }\n}\n\nfunction getGlobal() {\n return globalThis as {\n REPL?: {\n compiler?: CompilerService;\n };\n };\n}\n"],"names":["getCompiler","context","owner","getOwner","assert","createStore","CompilerService","rendersElement","x","render","resource","on","cleanup","destroy","element","setComponentTemplate","precompileTemplate","strictMode","scope","templateOnly","standardScope","array","concat","fn","get","hash","globalThis","Atomics","JSON","Math","Reflect","localStorage","sessionStorage","URL","isNaN","isFinite","parseInt","parseFloat","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","postMessage","structuredClone","Array","BigInt","Boolean","Date","Number","Object","String","Infinity","NaN","isSecureContext","constructor","global","getGlobal","REPL","compiler","registerDestructor","g","prototype","tracked","i","lastInfo","m","messages","length","current","type","lastError","setup","extraModules","options","localModules","modules","Compiler","logging","location","search","includes","resolve","log","message","push","gjs","lookup","resolveRegistration","gmd","remarkPlugins","defaultHbsToEmber","transformer","tree","visit","node","lang","meta","hbs","ember","createEditor","#compile","ext","text","Promise","compile","name","nameFor","component","error","flavor","result","e","console","n","waitFor","compileGJS","code","compileHBS","source","compileMD"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;AA2BO,SAASA,WAAWA,CAACC,OAAe,EAAE;AAC3C,EAAA,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,CA5BCqD,OAAO,CAAA,CAAA;AAAA;EAoCRC,UAAUA,CAACC,IAAY,EAA0B;AAC/C,IAAA,OAAO,IAAI,CAACZ,OAAO,CAAC,KAAK,EAAEY,IAAI,CAAC;AAClC,EAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;EACE,MACMC,UAAUA,CACdC,MAAc,EACd7C,OAUC,GAAG,EAAE,EACkB;IACxB,OAAO,IAAI,CAAC+B,OAAO,CAAC,KAAK,EAAEc,MAAM,EAAE7C,OAAO,CAAC;AAC7C,EAAA;AAAC,EAAA;IAAAwC,CAAA,CAAA,IAAA,CAAApD,SAAA,EAAA,YAAA,EAAA,CAhBAqD,OAAO,CAAA,CAAA;AAAA;AAmBRK,EAAAA,SAASA,CACPD,MAAc,EACd7C,OAGC,EACuB;IACxB,OAAO,IAAI,CAAC+B,OAAO,CAAC,IAAI,EAAEc,MAAM,EAAE7C,OAAO,CAAC;AAC5C,EAAA;AAAC,EAAA;IAAAwC,CAAA,CAAA,IAAA,CAAApD,SAAA,EAAA,WAAA,EAAA,CATAqD,OAAO,CAAA,CAAA;AAAA;AAUV;AAEA,SAAS1D,SAASA,GAAG;AACnB,EAAA,OAAO9B,UAAU;AAKnB;;;;"}
1
+ {"version":3,"file":"compiler.js","sources":["../../../../node_modules/.pnpm/unist-util-is@6.0.1/node_modules/unist-util-is/lib/index.js","../../../../node_modules/.pnpm/unist-util-visit-parents@6.0.2/node_modules/unist-util-visit-parents/lib/color.js","../../../../node_modules/.pnpm/unist-util-visit-parents@6.0.2/node_modules/unist-util-visit-parents/lib/index.js","../../../../node_modules/.pnpm/unist-util-visit@5.0.0/node_modules/unist-util-visit/lib/index.js","../../src/services/compiler.ts"],"sourcesContent":["/**\n * @import {Node, Parent} from 'unist'\n */\n\n/**\n * @template Fn\n * @template Fallback\n * @typedef {Fn extends (value: any) => value is infer Thing ? Thing : Fallback} Predicate\n */\n\n/**\n * @callback Check\n * Check that an arbitrary value is a node.\n * @param {unknown} this\n * The given context.\n * @param {unknown} [node]\n * Anything (typically a node).\n * @param {number | null | undefined} [index]\n * The node’s position in its parent.\n * @param {Parent | null | undefined} [parent]\n * The node’s parent.\n * @returns {boolean}\n * Whether this is a node and passes a test.\n *\n * @typedef {Record<string, unknown> | Node} Props\n * Object to check for equivalence.\n *\n * Note: `Node` is included as it is common but is not indexable.\n *\n * @typedef {Array<Props | TestFunction | string> | ReadonlyArray<Props | TestFunction | string> | Props | TestFunction | string | null | undefined} Test\n * Check for an arbitrary node.\n *\n * @callback TestFunction\n * Check if a node passes a test.\n * @param {unknown} this\n * The given context.\n * @param {Node} node\n * A node.\n * @param {number | undefined} [index]\n * The node’s position in its parent.\n * @param {Parent | undefined} [parent]\n * The node’s parent.\n * @returns {boolean | undefined | void}\n * Whether this node passes the test.\n *\n * Note: `void` is included until TS sees no return as `undefined`.\n */\n\n/**\n * Check if `node` is a `Node` and whether it passes the given test.\n *\n * @param {unknown} node\n * Thing to check, typically `Node`.\n * @param {Test} test\n * A check for a specific node.\n * @param {number | null | undefined} index\n * The node’s position in its parent.\n * @param {Parent | null | undefined} parent\n * The node’s parent.\n * @param {unknown} context\n * Context object (`this`) to pass to `test` functions.\n * @returns {boolean}\n * Whether `node` is a node and passes a test.\n */\nexport const is =\n // Note: overloads in JSDoc can’t yet use different `@template`s.\n /**\n * @type {(\n * (<Condition extends ReadonlyArray<string>>(node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition[number]}) &\n * (<Condition extends Array<string>>(node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition[number]}) &\n * (<Condition extends string>(node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition}) &\n * (<Condition extends Props>(node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Condition) &\n * (<Condition extends TestFunction>(node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Predicate<Condition, Node>) &\n * ((node?: null | undefined) => false) &\n * ((node: unknown, test?: null | undefined, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node) &\n * ((node: unknown, test?: Test, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => boolean)\n * )}\n */\n (\n /**\n * @param {unknown} [node]\n * @param {Test} [test]\n * @param {number | null | undefined} [index]\n * @param {Parent | null | undefined} [parent]\n * @param {unknown} [context]\n * @returns {boolean}\n */\n // eslint-disable-next-line max-params\n function (node, test, index, parent, context) {\n const check = convert(test)\n\n if (\n index !== undefined &&\n index !== null &&\n (typeof index !== 'number' ||\n index < 0 ||\n index === Number.POSITIVE_INFINITY)\n ) {\n throw new Error('Expected positive finite index')\n }\n\n if (\n parent !== undefined &&\n parent !== null &&\n (!is(parent) || !parent.children)\n ) {\n throw new Error('Expected parent node')\n }\n\n if (\n (parent === undefined || parent === null) !==\n (index === undefined || index === null)\n ) {\n throw new Error('Expected both parent and index')\n }\n\n return looksLikeANode(node)\n ? check.call(context, node, index, parent)\n : false\n }\n )\n\n/**\n * Generate an assertion from a test.\n *\n * Useful if you’re going to test many nodes, for example when creating a\n * utility where something else passes a compatible test.\n *\n * The created function is a bit faster because it expects valid input only:\n * a `node`, `index`, and `parent`.\n *\n * @param {Test} test\n * * when nullish, checks if `node` is a `Node`.\n * * when `string`, works like passing `(node) => node.type === test`.\n * * when `function` checks if function passed the node is true.\n * * when `object`, checks that all keys in test are in node, and that they have (strictly) equal values.\n * * when `array`, checks if any one of the subtests pass.\n * @returns {Check}\n * An assertion.\n */\nexport const convert =\n // Note: overloads in JSDoc can’t yet use different `@template`s.\n /**\n * @type {(\n * (<Condition extends string>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition}) &\n * (<Condition extends Props>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Condition) &\n * (<Condition extends TestFunction>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Predicate<Condition, Node>) &\n * ((test?: null | undefined) => (node?: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node) &\n * ((test?: Test) => Check)\n * )}\n */\n (\n /**\n * @param {Test} [test]\n * @returns {Check}\n */\n function (test) {\n if (test === null || test === undefined) {\n return ok\n }\n\n if (typeof test === 'function') {\n return castFactory(test)\n }\n\n if (typeof test === 'object') {\n return Array.isArray(test)\n ? anyFactory(test)\n : // Cast because `ReadonlyArray` goes into the above but `isArray`\n // narrows to `Array`.\n propertiesFactory(/** @type {Props} */ (test))\n }\n\n if (typeof test === 'string') {\n return typeFactory(test)\n }\n\n throw new Error('Expected function, string, or object as test')\n }\n )\n\n/**\n * @param {Array<Props | TestFunction | string>} tests\n * @returns {Check}\n */\nfunction anyFactory(tests) {\n /** @type {Array<Check>} */\n const checks = []\n let index = -1\n\n while (++index < tests.length) {\n checks[index] = convert(tests[index])\n }\n\n return castFactory(any)\n\n /**\n * @this {unknown}\n * @type {TestFunction}\n */\n function any(...parameters) {\n let index = -1\n\n while (++index < checks.length) {\n if (checks[index].apply(this, parameters)) return true\n }\n\n return false\n }\n}\n\n/**\n * Turn an object into a test for a node with a certain fields.\n *\n * @param {Props} check\n * @returns {Check}\n */\nfunction propertiesFactory(check) {\n const checkAsRecord = /** @type {Record<string, unknown>} */ (check)\n\n return castFactory(all)\n\n /**\n * @param {Node} node\n * @returns {boolean}\n */\n function all(node) {\n const nodeAsRecord = /** @type {Record<string, unknown>} */ (\n /** @type {unknown} */ (node)\n )\n\n /** @type {string} */\n let key\n\n for (key in check) {\n if (nodeAsRecord[key] !== checkAsRecord[key]) return false\n }\n\n return true\n }\n}\n\n/**\n * Turn a string into a test for a node with a certain type.\n *\n * @param {string} check\n * @returns {Check}\n */\nfunction typeFactory(check) {\n return castFactory(type)\n\n /**\n * @param {Node} node\n */\n function type(node) {\n return node && node.type === check\n }\n}\n\n/**\n * Turn a custom test into a test for a node that passes that test.\n *\n * @param {TestFunction} testFunction\n * @returns {Check}\n */\nfunction castFactory(testFunction) {\n return check\n\n /**\n * @this {unknown}\n * @type {Check}\n */\n function check(value, index, parent) {\n return Boolean(\n looksLikeANode(value) &&\n testFunction.call(\n this,\n value,\n typeof index === 'number' ? index : undefined,\n parent || undefined\n )\n )\n }\n}\n\nfunction ok() {\n return true\n}\n\n/**\n * @param {unknown} value\n * @returns {value is Node}\n */\nfunction looksLikeANode(value) {\n return value !== null && typeof value === 'object' && 'type' in value\n}\n","/**\n * @param {string} d\n * @returns {string}\n */\nexport function color(d) {\n return d\n}\n","/**\n * @import {Node as UnistNode, Parent as UnistParent} from 'unist'\n */\n\n/**\n * @typedef {Exclude<import('unist-util-is').Test, undefined> | undefined} Test\n * Test from `unist-util-is`.\n *\n * Note: we have remove and add `undefined`, because otherwise when generating\n * automatic `.d.ts` files, TS tries to flatten paths from a local perspective,\n * which doesn’t work when publishing on npm.\n */\n\n/**\n * @typedef {(\n * Fn extends (value: any) => value is infer Thing\n * ? Thing\n * : Fallback\n * )} Predicate\n * Get the value of a type guard `Fn`.\n * @template Fn\n * Value; typically function that is a type guard (such as `(x): x is Y`).\n * @template Fallback\n * Value to yield if `Fn` is not a type guard.\n */\n\n/**\n * @typedef {(\n * Check extends null | undefined // No test.\n * ? Value\n * : Value extends {type: Check} // String (type) test.\n * ? Value\n * : Value extends Check // Partial test.\n * ? Value\n * : Check extends Function // Function test.\n * ? Predicate<Check, Value> extends Value\n * ? Predicate<Check, Value>\n * : never\n * : never // Some other test?\n * )} MatchesOne\n * Check whether a node matches a primitive check in the type system.\n * @template Value\n * Value; typically unist `Node`.\n * @template Check\n * Value; typically `unist-util-is`-compatible test, but not arrays.\n */\n\n/**\n * @typedef {(\n * Check extends ReadonlyArray<infer T>\n * ? MatchesOne<Value, T>\n * : Check extends Array<infer T>\n * ? MatchesOne<Value, T>\n * : MatchesOne<Value, Check>\n * )} Matches\n * Check whether a node matches a check in the type system.\n * @template Value\n * Value; typically unist `Node`.\n * @template Check\n * Value; typically `unist-util-is`-compatible test.\n */\n\n/**\n * @typedef {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10} Uint\n * Number; capped reasonably.\n */\n\n/**\n * @typedef {I extends 0 ? 1 : I extends 1 ? 2 : I extends 2 ? 3 : I extends 3 ? 4 : I extends 4 ? 5 : I extends 5 ? 6 : I extends 6 ? 7 : I extends 7 ? 8 : I extends 8 ? 9 : 10} Increment\n * Increment a number in the type system.\n * @template {Uint} [I=0]\n * Index.\n */\n\n/**\n * @typedef {(\n * Node extends UnistParent\n * ? Node extends {children: Array<infer Children>}\n * ? Child extends Children ? Node : never\n * : never\n * : never\n * )} InternalParent\n * Collect nodes that can be parents of `Child`.\n * @template {UnistNode} Node\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @typedef {InternalParent<InclusiveDescendant<Tree>, Child>} Parent\n * Collect nodes in `Tree` that can be parents of `Child`.\n * @template {UnistNode} Tree\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @typedef {(\n * Depth extends Max\n * ? never\n * :\n * | InternalParent<Node, Child>\n * | InternalAncestor<Node, InternalParent<Node, Child>, Max, Increment<Depth>>\n * )} InternalAncestor\n * Collect nodes in `Tree` that can be ancestors of `Child`.\n * @template {UnistNode} Node\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n * @template {Uint} [Max=10]\n * Max; searches up to this depth.\n * @template {Uint} [Depth=0]\n * Current depth.\n */\n\n/**\n * @typedef {InternalAncestor<InclusiveDescendant<Tree>, Child>} Ancestor\n * Collect nodes in `Tree` that can be ancestors of `Child`.\n * @template {UnistNode} Tree\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @typedef {(\n * Tree extends UnistParent\n * ? Depth extends Max\n * ? Tree\n * : Tree | InclusiveDescendant<Tree['children'][number], Max, Increment<Depth>>\n * : Tree\n * )} InclusiveDescendant\n * Collect all (inclusive) descendants of `Tree`.\n *\n * > 👉 **Note**: for performance reasons, this seems to be the fastest way to\n * > recurse without actually running into an infinite loop, which the\n * > previous version did.\n * >\n * > Practically, a max of `2` is typically enough assuming a `Root` is\n * > passed, but it doesn’t improve performance.\n * > It gets higher with `List > ListItem > Table > TableRow > TableCell`.\n * > Using up to `10` doesn’t hurt or help either.\n * @template {UnistNode} Tree\n * Tree type.\n * @template {Uint} [Max=10]\n * Max; searches up to this depth.\n * @template {Uint} [Depth=0]\n * Current depth.\n */\n\n/**\n * @typedef {'skip' | boolean} Action\n * Union of the action types.\n *\n * @typedef {number} Index\n * Move to the sibling at `index` next (after node itself is completely\n * traversed).\n *\n * Useful if mutating the tree, such as removing the node the visitor is\n * currently on, or any of its previous siblings.\n * Results less than 0 or greater than or equal to `children.length` stop\n * traversing the parent.\n *\n * @typedef {[(Action | null | undefined | void)?, (Index | null | undefined)?]} ActionTuple\n * List with one or two values, the first an action, the second an index.\n *\n * @typedef {Action | ActionTuple | Index | null | undefined | void} VisitorResult\n * Any value that can be returned from a visitor.\n */\n\n/**\n * @callback Visitor\n * Handle a node (matching `test`, if given).\n *\n * Visitors are free to transform `node`.\n * They can also transform the parent of node (the last of `ancestors`).\n *\n * Replacing `node` itself, if `SKIP` is not returned, still causes its\n * descendants to be walked (which is a bug).\n *\n * When adding or removing previous siblings of `node` (or next siblings, in\n * case of reverse), the `Visitor` should return a new `Index` to specify the\n * sibling to traverse after `node` is traversed.\n * Adding or removing next siblings of `node` (or previous siblings, in case\n * of reverse) is handled as expected without needing to return a new `Index`.\n *\n * Removing the children property of an ancestor still results in them being\n * traversed.\n * @param {Visited} node\n * Found node.\n * @param {Array<VisitedParents>} ancestors\n * Ancestors of `node`.\n * @returns {VisitorResult}\n * What to do next.\n *\n * An `Index` is treated as a tuple of `[CONTINUE, Index]`.\n * An `Action` is treated as a tuple of `[Action]`.\n *\n * Passing a tuple back only makes sense if the `Action` is `SKIP`.\n * When the `Action` is `EXIT`, that action can be returned.\n * When the `Action` is `CONTINUE`, `Index` can be returned.\n * @template {UnistNode} [Visited=UnistNode]\n * Visited node type.\n * @template {UnistParent} [VisitedParents=UnistParent]\n * Ancestor type.\n */\n\n/**\n * @typedef {Visitor<Matches<InclusiveDescendant<Tree>, Check>, Ancestor<Tree, Matches<InclusiveDescendant<Tree>, Check>>>} BuildVisitor\n * Build a typed `Visitor` function from a tree and a test.\n *\n * It will infer which values are passed as `node` and which as `parents`.\n * @template {UnistNode} [Tree=UnistNode]\n * Tree type.\n * @template {Test} [Check=Test]\n * Test type.\n */\n\nimport {convert} from 'unist-util-is'\nimport {color} from 'unist-util-visit-parents/do-not-use-color'\n\n/** @type {Readonly<ActionTuple>} */\nconst empty = []\n\n/**\n * Continue traversing as normal.\n */\nexport const CONTINUE = true\n\n/**\n * Stop traversing immediately.\n */\nexport const EXIT = false\n\n/**\n * Do not traverse this node’s children.\n */\nexport const SKIP = 'skip'\n\n/**\n * Visit nodes, with ancestral information.\n *\n * This algorithm performs *depth-first* *tree traversal* in *preorder*\n * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).\n *\n * You can choose for which nodes `visitor` is called by passing a `test`.\n * For complex tests, you should test yourself in `visitor`, as it will be\n * faster and will have improved type information.\n *\n * Walking the tree is an intensive task.\n * Make use of the return values of the visitor when possible.\n * Instead of walking a tree multiple times, walk it once, use `unist-util-is`\n * to check if a node matches, and then perform different operations.\n *\n * You can change the tree.\n * See `Visitor` for more info.\n *\n * @overload\n * @param {Tree} tree\n * @param {Check} check\n * @param {BuildVisitor<Tree, Check>} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {undefined}\n *\n * @overload\n * @param {Tree} tree\n * @param {BuildVisitor<Tree>} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {undefined}\n *\n * @param {UnistNode} tree\n * Tree to traverse.\n * @param {Visitor | Test} test\n * `unist-util-is`-compatible test\n * @param {Visitor | boolean | null | undefined} [visitor]\n * Handle each node.\n * @param {boolean | null | undefined} [reverse]\n * Traverse in reverse preorder (NRL) instead of the default preorder (NLR).\n * @returns {undefined}\n * Nothing.\n *\n * @template {UnistNode} Tree\n * Node type.\n * @template {Test} Check\n * `unist-util-is`-compatible test.\n */\nexport function visitParents(tree, test, visitor, reverse) {\n /** @type {Test} */\n let check\n\n if (typeof test === 'function' && typeof visitor !== 'function') {\n reverse = visitor\n // @ts-expect-error no visitor given, so `visitor` is test.\n visitor = test\n } else {\n // @ts-expect-error visitor given, so `test` isn’t a visitor.\n check = test\n }\n\n const is = convert(check)\n const step = reverse ? -1 : 1\n\n factory(tree, undefined, [])()\n\n /**\n * @param {UnistNode} node\n * @param {number | undefined} index\n * @param {Array<UnistParent>} parents\n */\n function factory(node, index, parents) {\n const value = /** @type {Record<string, unknown>} */ (\n node && typeof node === 'object' ? node : {}\n )\n\n if (typeof value.type === 'string') {\n const name =\n // `hast`\n typeof value.tagName === 'string'\n ? value.tagName\n : // `xast`\n typeof value.name === 'string'\n ? value.name\n : undefined\n\n Object.defineProperty(visit, 'name', {\n value:\n 'node (' + color(node.type + (name ? '<' + name + '>' : '')) + ')'\n })\n }\n\n return visit\n\n function visit() {\n /** @type {Readonly<ActionTuple>} */\n let result = empty\n /** @type {Readonly<ActionTuple>} */\n let subresult\n /** @type {number} */\n let offset\n /** @type {Array<UnistParent>} */\n let grandparents\n\n if (!test || is(node, index, parents[parents.length - 1] || undefined)) {\n // @ts-expect-error: `visitor` is now a visitor.\n result = toResult(visitor(node, parents))\n\n if (result[0] === EXIT) {\n return result\n }\n }\n\n if ('children' in node && node.children) {\n const nodeAsParent = /** @type {UnistParent} */ (node)\n\n if (nodeAsParent.children && result[0] !== SKIP) {\n offset = (reverse ? nodeAsParent.children.length : -1) + step\n grandparents = parents.concat(nodeAsParent)\n\n while (offset > -1 && offset < nodeAsParent.children.length) {\n const child = nodeAsParent.children[offset]\n\n subresult = factory(child, offset, grandparents)()\n\n if (subresult[0] === EXIT) {\n return subresult\n }\n\n offset =\n typeof subresult[1] === 'number' ? subresult[1] : offset + step\n }\n }\n }\n\n return result\n }\n }\n}\n\n/**\n * Turn a return value into a clean result.\n *\n * @param {VisitorResult} value\n * Valid return values from visitors.\n * @returns {Readonly<ActionTuple>}\n * Clean result.\n */\nfunction toResult(value) {\n if (Array.isArray(value)) {\n return value\n }\n\n if (typeof value === 'number') {\n return [CONTINUE, value]\n }\n\n return value === null || value === undefined ? empty : [value]\n}\n","/**\n * @typedef {import('unist').Node} UnistNode\n * @typedef {import('unist').Parent} UnistParent\n * @typedef {import('unist-util-visit-parents').VisitorResult} VisitorResult\n */\n\n/**\n * @typedef {Exclude<import('unist-util-is').Test, undefined> | undefined} Test\n * Test from `unist-util-is`.\n *\n * Note: we have remove and add `undefined`, because otherwise when generating\n * automatic `.d.ts` files, TS tries to flatten paths from a local perspective,\n * which doesn’t work when publishing on npm.\n */\n\n// To do: use types from `unist-util-visit-parents` when it’s released.\n\n/**\n * @typedef {(\n * Fn extends (value: any) => value is infer Thing\n * ? Thing\n * : Fallback\n * )} Predicate\n * Get the value of a type guard `Fn`.\n * @template Fn\n * Value; typically function that is a type guard (such as `(x): x is Y`).\n * @template Fallback\n * Value to yield if `Fn` is not a type guard.\n */\n\n/**\n * @typedef {(\n * Check extends null | undefined // No test.\n * ? Value\n * : Value extends {type: Check} // String (type) test.\n * ? Value\n * : Value extends Check // Partial test.\n * ? Value\n * : Check extends Function // Function test.\n * ? Predicate<Check, Value> extends Value\n * ? Predicate<Check, Value>\n * : never\n * : never // Some other test?\n * )} MatchesOne\n * Check whether a node matches a primitive check in the type system.\n * @template Value\n * Value; typically unist `Node`.\n * @template Check\n * Value; typically `unist-util-is`-compatible test, but not arrays.\n */\n\n/**\n * @typedef {(\n * Check extends Array<any>\n * ? MatchesOne<Value, Check[keyof Check]>\n * : MatchesOne<Value, Check>\n * )} Matches\n * Check whether a node matches a check in the type system.\n * @template Value\n * Value; typically unist `Node`.\n * @template Check\n * Value; typically `unist-util-is`-compatible test.\n */\n\n/**\n * @typedef {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10} Uint\n * Number; capped reasonably.\n */\n\n/**\n * @typedef {I extends 0 ? 1 : I extends 1 ? 2 : I extends 2 ? 3 : I extends 3 ? 4 : I extends 4 ? 5 : I extends 5 ? 6 : I extends 6 ? 7 : I extends 7 ? 8 : I extends 8 ? 9 : 10} Increment\n * Increment a number in the type system.\n * @template {Uint} [I=0]\n * Index.\n */\n\n/**\n * @typedef {(\n * Node extends UnistParent\n * ? Node extends {children: Array<infer Children>}\n * ? Child extends Children ? Node : never\n * : never\n * : never\n * )} InternalParent\n * Collect nodes that can be parents of `Child`.\n * @template {UnistNode} Node\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @typedef {InternalParent<InclusiveDescendant<Tree>, Child>} Parent\n * Collect nodes in `Tree` that can be parents of `Child`.\n * @template {UnistNode} Tree\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n */\n\n/**\n * @typedef {(\n * Depth extends Max\n * ? never\n * :\n * | InternalParent<Node, Child>\n * | InternalAncestor<Node, InternalParent<Node, Child>, Max, Increment<Depth>>\n * )} InternalAncestor\n * Collect nodes in `Tree` that can be ancestors of `Child`.\n * @template {UnistNode} Node\n * All node types in a tree.\n * @template {UnistNode} Child\n * Node to search for.\n * @template {Uint} [Max=10]\n * Max; searches up to this depth.\n * @template {Uint} [Depth=0]\n * Current depth.\n */\n\n/**\n * @typedef {(\n * Tree extends UnistParent\n * ? Depth extends Max\n * ? Tree\n * : Tree | InclusiveDescendant<Tree['children'][number], Max, Increment<Depth>>\n * : Tree\n * )} InclusiveDescendant\n * Collect all (inclusive) descendants of `Tree`.\n *\n * > 👉 **Note**: for performance reasons, this seems to be the fastest way to\n * > recurse without actually running into an infinite loop, which the\n * > previous version did.\n * >\n * > Practically, a max of `2` is typically enough assuming a `Root` is\n * > passed, but it doesn’t improve performance.\n * > It gets higher with `List > ListItem > Table > TableRow > TableCell`.\n * > Using up to `10` doesn’t hurt or help either.\n * @template {UnistNode} Tree\n * Tree type.\n * @template {Uint} [Max=10]\n * Max; searches up to this depth.\n * @template {Uint} [Depth=0]\n * Current depth.\n */\n\n/**\n * @callback Visitor\n * Handle a node (matching `test`, if given).\n *\n * Visitors are free to transform `node`.\n * They can also transform `parent`.\n *\n * Replacing `node` itself, if `SKIP` is not returned, still causes its\n * descendants to be walked (which is a bug).\n *\n * When adding or removing previous siblings of `node` (or next siblings, in\n * case of reverse), the `Visitor` should return a new `Index` to specify the\n * sibling to traverse after `node` is traversed.\n * Adding or removing next siblings of `node` (or previous siblings, in case\n * of reverse) is handled as expected without needing to return a new `Index`.\n *\n * Removing the children property of `parent` still results in them being\n * traversed.\n * @param {Visited} node\n * Found node.\n * @param {Visited extends UnistNode ? number | undefined : never} index\n * Index of `node` in `parent`.\n * @param {Ancestor extends UnistParent ? Ancestor | undefined : never} parent\n * Parent of `node`.\n * @returns {VisitorResult}\n * What to do next.\n *\n * An `Index` is treated as a tuple of `[CONTINUE, Index]`.\n * An `Action` is treated as a tuple of `[Action]`.\n *\n * Passing a tuple back only makes sense if the `Action` is `SKIP`.\n * When the `Action` is `EXIT`, that action can be returned.\n * When the `Action` is `CONTINUE`, `Index` can be returned.\n * @template {UnistNode} [Visited=UnistNode]\n * Visited node type.\n * @template {UnistParent} [Ancestor=UnistParent]\n * Ancestor type.\n */\n\n/**\n * @typedef {Visitor<Visited, Parent<Ancestor, Visited>>} BuildVisitorFromMatch\n * Build a typed `Visitor` function from a node and all possible parents.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n * @template {UnistNode} Visited\n * Node type.\n * @template {UnistParent} Ancestor\n * Parent type.\n */\n\n/**\n * @typedef {(\n * BuildVisitorFromMatch<\n * Matches<Descendant, Check>,\n * Extract<Descendant, UnistParent>\n * >\n * )} BuildVisitorFromDescendants\n * Build a typed `Visitor` function from a list of descendants and a test.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n * @template {UnistNode} Descendant\n * Node type.\n * @template {Test} Check\n * Test type.\n */\n\n/**\n * @typedef {(\n * BuildVisitorFromDescendants<\n * InclusiveDescendant<Tree>,\n * Check\n * >\n * )} BuildVisitor\n * Build a typed `Visitor` function from a tree and a test.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n * @template {UnistNode} [Tree=UnistNode]\n * Node type.\n * @template {Test} [Check=Test]\n * Test type.\n */\n\nimport {visitParents} from 'unist-util-visit-parents'\n\nexport {CONTINUE, EXIT, SKIP} from 'unist-util-visit-parents'\n\n/**\n * Visit nodes.\n *\n * This algorithm performs *depth-first* *tree traversal* in *preorder*\n * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).\n *\n * You can choose for which nodes `visitor` is called by passing a `test`.\n * For complex tests, you should test yourself in `visitor`, as it will be\n * faster and will have improved type information.\n *\n * Walking the tree is an intensive task.\n * Make use of the return values of the visitor when possible.\n * Instead of walking a tree multiple times, walk it once, use `unist-util-is`\n * to check if a node matches, and then perform different operations.\n *\n * You can change the tree.\n * See `Visitor` for more info.\n *\n * @overload\n * @param {Tree} tree\n * @param {Check} check\n * @param {BuildVisitor<Tree, Check>} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {undefined}\n *\n * @overload\n * @param {Tree} tree\n * @param {BuildVisitor<Tree>} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {undefined}\n *\n * @param {UnistNode} tree\n * Tree to traverse.\n * @param {Visitor | Test} testOrVisitor\n * `unist-util-is`-compatible test (optional, omit to pass a visitor).\n * @param {Visitor | boolean | null | undefined} [visitorOrReverse]\n * Handle each node (when test is omitted, pass `reverse`).\n * @param {boolean | null | undefined} [maybeReverse=false]\n * Traverse in reverse preorder (NRL) instead of the default preorder (NLR).\n * @returns {undefined}\n * Nothing.\n *\n * @template {UnistNode} Tree\n * Node type.\n * @template {Test} Check\n * `unist-util-is`-compatible test.\n */\nexport function visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {\n /** @type {boolean | null | undefined} */\n let reverse\n /** @type {Test} */\n let test\n /** @type {Visitor} */\n let visitor\n\n if (\n typeof testOrVisitor === 'function' &&\n typeof visitorOrReverse !== 'function'\n ) {\n test = undefined\n visitor = testOrVisitor\n reverse = visitorOrReverse\n } else {\n // @ts-expect-error: assume the overload with test was given.\n test = testOrVisitor\n // @ts-expect-error: assume the overload with test was given.\n visitor = visitorOrReverse\n reverse = maybeReverse\n }\n\n visitParents(tree, test, overload, reverse)\n\n /**\n * @param {UnistNode} node\n * @param {Array<UnistParent>} parents\n */\n function overload(node, parents) {\n const parent = parents[parents.length - 1]\n const index = parent ? parent.children.indexOf(node) : undefined\n return visitor(node, index, parent)\n }\n}\n","/* eslint-disable getter-return */\n \n// @ts-ignore\nimport { tracked } from '@glimmer/tracking';\nimport { setComponentTemplate } from '@ember/component';\nimport templateOnly from '@ember/component/template-only';\nimport { assert } from '@ember/debug';\nimport { registerDestructor } from '@ember/destroyable';\nimport { array, concat, fn, get, hash } from '@ember/helper';\nimport { on } from '@ember/modifier';\nimport { getOwner } from '@ember/owner';\nimport { precompileTemplate } from '@ember/template-compilation';\nimport { waitFor } from '@ember/test-waiters';\n\nimport { createStore } from 'ember-primitives/store';\nimport { resource } from 'ember-resources';\nimport { Compiler } from 'repl-sdk';\nimport { visit } from 'unist-util-visit';\n\nimport { nameFor } from '../compile/utils.ts';\nimport { modules } from './known-modules.ts';\n\nimport type { CompileResult, ModuleMap } from '../compile/types.ts';\nimport type { ComponentLike } from '@glint/template';\nimport type { EditorView } from 'codemirror';\nimport type { ErrorMessage, InfoMessage, Message } from 'repl-sdk';\n\nexport function getCompiler(context: object) {\n const owner = getOwner(context) ?? context;\n\n assert(`Missing owner. Cannot use ember-repl's compiler without an owner.`, owner);\n\n return createStore(owner, CompilerService);\n}\n\n/**\n * Old way to make static components, because\n * https://github.com/emberjs/ember.js/issues/20913\n *\n * The runtime compiler doesn't allow you to catch compiler errors.\n * This particular component doesn't need to be runtime anyway.\n */\nfunction rendersElement(x: { element: Element; destroy: () => void }): ComponentLike {\n const render = resource(({ on }) => {\n on.cleanup(() => {\n x.destroy();\n });\n\n return x.element;\n });\n\n return setComponentTemplate(\n precompileTemplate(`{{render}}`, {\n strictMode: true,\n scope: () => ({ render }),\n }),\n templateOnly()\n ) as ComponentLike;\n}\n\ninterface CompilerOptions {\n hbs?: {\n scope?: Record<string, unknown>;\n };\n md?: {\n remarkPlugins?: unknown[];\n rehypePlugins?: unknown[];\n };\n gmd?: {\n scope?: Record<string, unknown>;\n remarkPlugins?: unknown[];\n rehypePlugins?: unknown[];\n };\n}\n\n/**\n * Standard for the REPL, not real apps.\n * HBS isn't used in real apps (that are fully up to date)\n */\nconst standardScope = {\n // These are only added here because it's convenient for hbs\n // to have them\n array,\n concat,\n fn,\n get,\n hash,\n on,\n // The default available scope for gjs:\n //\n // We don't use gjs transpilation here, because hbs transpilation\n // doesn't need to go through the babel infra, so it's faster this way,\n // even though it's more \"verbose\" and could get out of sync from the\n // implementations / source-of-truth.\n //\n // https://github.com/emberjs/babel-plugin-ember-template-compilation/blob/main/src/scope-locals.ts#L16\n //\n // ////////////////\n // namespaces\n // ////////////////\n // TC39\n globalThis,\n Atomics,\n JSON,\n Math,\n Reflect,\n // WHATWG\n localStorage,\n sessionStorage,\n URL,\n // ////////////////\n // functions / utilities\n // ////////////////\n // TC39\n isNaN,\n isFinite,\n parseInt,\n parseFloat,\n decodeURI,\n decodeURIComponent,\n encodeURI,\n encodeURIComponent,\n // WHATWG\n postMessage,\n structuredClone,\n // ////////////////\n // new-less Constructors (still functions)\n // ////////////////\n // TC39\n Array, // different behavior from (array)\n BigInt,\n Boolean,\n Date,\n Number,\n Object, // different behavior from (hash)\n String,\n // ////////////////\n // Values\n // ////////////////\n // TC39\n Infinity,\n NaN,\n // WHATWG\n isSecureContext,\n};\n\nexport default class CompilerService {\n #compiler: Compiler | undefined;\n\n constructor() {\n const global = getGlobal();\n\n global.REPL ||= {};\n\n if (global.REPL.compiler) {\n return global.REPL.compiler;\n }\n\n global.REPL.compiler = this;\n\n registerDestructor(this, () => {\n delete global.REPL?.compiler;\n });\n }\n\n @tracked messages: Message[] = [];\n\n get lastInfo(): InfoMessage | undefined {\n const m = this.messages;\n\n for (let i = m.length - 1; i >= 0; i--) {\n const current = m[i];\n\n if (current?.type === 'info') return current;\n }\n }\n\n get lastError(): ErrorMessage | undefined {\n const m = this.messages;\n\n for (let i = m.length - 1; i >= 0; i--) {\n const current = m[i];\n\n if (current?.type === 'error') return current;\n }\n }\n\n /**\n * @param {ModuleMap} [ extraModules ]: map of import paths to modules.\n * These modules are useful if you need to document a library or a any design system or a styleguide or\n * if there are additional modules that could be imported in the passed `code`.\n * @param {object} [options] optional compiler options for each format/flavor\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 */\n setup = (extraModules: ModuleMap = {}, options: CompilerOptions = {}) => {\n const localModules = modules(extraModules);\n\n this.#compiler = new Compiler({\n logging: location.search.includes('debug'),\n resolve: {\n ...localModules,\n },\n on: {\n log: (type: Message['type'], message: string) => {\n this.messages.push({ type, message });\n // Waiting on better array primitive\n // eslint-disable-next-line no-self-assign\n this.messages = this.messages;\n },\n },\n options: {\n ...options,\n gjs: {\n // owner: getOwner(this),\n owner: {\n lookup: () => {},\n resolveRegistration: () => {},\n },\n },\n gmd: {\n ...(options.gmd ?? {}),\n scope: {\n ...standardScope,\n ...(options.gmd?.scope ?? {}),\n },\n remarkPlugins: [\n function defaultHbsToEmber() {\n return function transformer(tree: any) {\n visit(tree, 'code', (node) => {\n if (node.lang === 'hbs') {\n if (!node.meta) {\n node.meta = 'ember';\n } else {\n node.meta += ' ember';\n }\n\n return node;\n }\n });\n\n return tree;\n };\n },\n ...(options.gmd?.remarkPlugins ?? []),\n ],\n },\n hbs: {\n ember: {\n ...(options.hbs ?? {}),\n scope: {\n ...standardScope,\n ...(options.hbs?.scope ?? {}),\n },\n },\n },\n },\n });\n };\n\n get compiler(): Compiler {\n /**\n * This is useful for our own testing.\n * not sure if this would be a footgun for consumers' usage\n */\n if (!this.#compiler) {\n this.setup();\n }\n\n assert(\n `Expected a compiled to be setup on the compiler service. Use \\`compiler.setup()\\` first.`,\n this.#compiler\n );\n\n return this.#compiler;\n }\n\n async createEditor(\n element: HTMLElement,\n options: {\n text: string | null | undefined;\n format: string;\n handleUpdate: (text: string) => void;\n extensions?: unknown[];\n }\n ): Promise<{\n view: EditorView;\n setText: (text: string, format: string) => Promise<void>;\n setFormat: (format: string) => Promise<void>;\n }> {\n return this.compiler.createEditor(element, options);\n }\n\n async #compile(ext: string, text: string, options?: Record<string, unknown>) {\n /**\n * Protect from accidental backtracking-render assertions\n * (infinite loop protection)\n *\n * This function doesn't ready any tracked data, so we don't need to\n * worry about invalidation or anything.\n */\n await Promise.resolve();\n\n this.messages = [];\n\n return this.compiler.compile(ext, text, options ?? {});\n }\n\n /**\n * @public\n *\n * Defers to the underlying repl-SDK and gives us a component we can render.\n *\n * @param {string} ext the ext/format to be compiled\n * @param {string} text the code to be compiled using the configured compiler for the ext\n */\n @waitFor\n async compile(ext: string, text: string, options?: Record<string, unknown>) {\n const name = nameFor(text);\n let component: undefined | ComponentLike;\n let error: undefined | Error;\n\n try {\n if (ext === 'hbs') {\n /**\n * Are there other hbs-using frameworks?\n */\n options ||= {};\n options.flavor = 'ember';\n }\n\n const result = await this.#compile(ext, text, options);\n\n component = rendersElement(result);\n } catch (e) {\n // Put a breakpoint here to debug\n // debugger;\n console.error(e);\n error = e as Error | undefined;\n }\n\n return { name, component, error };\n }\n\n /**\n * @public\n *\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 * @param {string} code the code to be compiled\n */\n compileGJS(code: string): Promise<CompileResult> {\n return this.compile('gjs', code);\n }\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 */\n @waitFor\n async compileHBS(\n source: string,\n options: {\n /**\n * Used for debug viewing\n */\n moduleName?: string;\n /**\n * Additional values to include in hbs scope.\n * This is a _strict mode_ hbs component.\n */\n scope?: Record<string, unknown>;\n } = {}\n ): Promise<CompileResult> {\n return this.compile('hbs', source, options);\n }\n\n @waitFor\n compileMD(\n source: string,\n options?: {\n remarkPlugins?: unknown[];\n rehypePlugins?: unknown[];\n }\n ): Promise<CompileResult> {\n return this.compile('md', source, options);\n }\n}\n\nfunction getGlobal() {\n return globalThis as {\n REPL?: {\n compiler?: CompilerService;\n };\n };\n}\n"],"names":["convert","test","undefined","ok","castFactory","Array","isArray","anyFactory","propertiesFactory","typeFactory","Error","tests","checks","index","length","any","parameters","apply","check","checkAsRecord","all","node","nodeAsRecord","key","type","testFunction","value","parent","Boolean","looksLikeANode","call","color","d","empty","CONTINUE","EXIT","SKIP","visitParents","tree","visitor","reverse","is","step","factory","parents","name","tagName","Object","defineProperty","visit","result","subresult","offset","grandparents","toResult","children","nodeAsParent","concat","child","testOrVisitor","visitorOrReverse","maybeReverse","overload","indexOf","getCompiler","context","owner","getOwner","assert","createStore","CompilerService","rendersElement","x","render","resource","on","cleanup","destroy","element","setComponentTemplate","precompileTemplate","strictMode","scope","templateOnly","standardScope","array","fn","get","hash","globalThis","Atomics","JSON","Math","Reflect","localStorage","sessionStorage","URL","isNaN","isFinite","parseInt","parseFloat","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","postMessage","structuredClone","BigInt","Date","Number","String","Infinity","NaN","isSecureContext","constructor","global","getGlobal","REPL","compiler","registerDestructor","g","prototype","tracked","i","lastInfo","m","messages","current","lastError","setup","extraModules","options","localModules","modules","Compiler","logging","location","search","includes","resolve","log","message","push","gjs","lookup","resolveRegistration","gmd","remarkPlugins","defaultHbsToEmber","transformer","lang","meta","hbs","ember","createEditor","#compile","ext","text","Promise","compile","nameFor","component","error","flavor","e","console","n","waitFor","compileGJS","code","compileHBS","source","compileMD"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AACA;AACA;;;AAwHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,OAAO;AAClB;AACA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEI;AACJ;AACA;AACA;AACI,UAAUC,IAAI,EAAE;AACd,EAAA,IAAIA,IAAI,KAAK,IAAI,IAAIA,IAAI,KAAKC,SAAS,EAAE;AACvC,IAAA,OAAOC,EAAE;AACX,EAAA;AAEA,EAAA,IAAI,OAAOF,IAAI,KAAK,UAAU,EAAE;IAC9B,OAAOG,WAAW,CAACH,IAAI,CAAC;AAC1B,EAAA;AAEA,EAAA,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;IAC5B,OAAOI,KAAK,CAACC,OAAO,CAACL,IAAI,CAAC,GACtBM,UAAU,CAACN,IAAI,CAAC;AAChB;AACA;IACAO,iBAAiB,qBAAuBP,IAAK,CAAC;AACpD,EAAA;AAEA,EAAA,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;IAC5B,OAAOQ,WAAW,CAACR,IAAI,CAAC;AAC1B,EAAA;AAEA,EAAA,MAAM,IAAIS,KAAK,CAAC,8CAA8C,CAAC;AACjE,CACD;;AAEH;AACA;AACA;AACA;AACA,SAASH,UAAUA,CAACI,KAAK,EAAE;AACzB;EACA,MAAMC,MAAM,GAAG,EAAE;EACjB,IAAIC,KAAK,GAAG,EAAE;AAEd,EAAA,OAAO,EAAEA,KAAK,GAAGF,KAAK,CAACG,MAAM,EAAE;IAC7BF,MAAM,CAACC,KAAK,CAAC,GAAGb,OAAO,CAACW,KAAK,CAACE,KAAK,CAAC,CAAC;AACvC,EAAA;EAEA,OAAOT,WAAW,CAACW,GAAG,CAAC;;AAEvB;AACF;AACA;AACA;AACE,EAAA,SAASA,GAAGA,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S;AAAEC,MAAAA;KAAO;AACnC,EAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AAPE,EAAA;IAAAI,CAAA,CAAA,IAAA,CAAA7C,SAAA,EAAA,SAAA,EAAA,CA5BC8C,OAAO,CAAA,CAAA;AAAA;EAoCRC,UAAUA,CAACC,IAAY,EAA0B;AAC/C,IAAA,OAAO,IAAI,CAACV,OAAO,CAAC,KAAK,EAAEU,IAAI,CAAC;AAClC,EAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;EACE,MACMC,UAAUA,CACdC,MAAc,EACdxC,OAUC,GAAG,EAAE,EACkB;IACxB,OAAO,IAAI,CAAC4B,OAAO,CAAC,KAAK,EAAEY,MAAM,EAAExC,OAAO,CAAC;AAC7C,EAAA;AAAC,EAAA;IAAAmC,CAAA,CAAA,IAAA,CAAA7C,SAAA,EAAA,YAAA,EAAA,CAhBA8C,OAAO,CAAA,CAAA;AAAA;AAmBRK,EAAAA,SAASA,CACPD,MAAc,EACdxC,OAGC,EACuB;IACxB,OAAO,IAAI,CAAC4B,OAAO,CAAC,IAAI,EAAEY,MAAM,EAAExC,OAAO,CAAC;AAC5C,EAAA;AAAC,EAAA;IAAAmC,CAAA,CAAA,IAAA,CAAA7C,SAAA,EAAA,WAAA,EAAA,CATA8C,OAAO,CAAA,CAAA;AAAA;AAUV;AAEA,SAASnD,SAASA,GAAG;AACnB,EAAA,OAAO3B,UAAU;AAKnB;;;;","x_google_ignoreList":[0,1,2,3]}
@@ -96,13 +96,14 @@ const emberCompilationModules = {
96
96
  })
97
97
  };
98
98
  const markdownCompilationModules = {
99
- 'rehype-raw': () => import('../index-C-twRw93.js'),
100
- 'rehype-stringify': () => import('../index-C371bO_b.js'),
101
- 'remark-gfm': () => import('../index-Bm1Y84Cu.js'),
102
- 'remark-parse': () => import('../index-CDSIcg03.js'),
103
- 'remark-rehype': () => import('../index-CGDqu098.js'),
104
- unified: () => import('../index-DMSCybEq.js'),
105
- 'unist-util-visit': () => import('../index-DIRpUv6Z.js')
99
+ // Provided directly in repl-sdk, but could be overridden
100
+ // 'rehype-raw': () => import('rehype-raw'),
101
+ // 'rehype-stringify': () => import('rehype-stringify'),
102
+ // 'remark-gfm': () => import('remark-gfm'),
103
+ // 'remark-parse': () => import('remark-parse'),
104
+ // 'remark-rehype': () => import('remark-rehype'),
105
+ // unified: () => import('unified'),
106
+ // 'unist-util-visit': () => import('unist-util-visit'),
106
107
  };
107
108
 
108
109
  /**