ember-repl 8.2.2 → 8.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/declarations/compile/Compiled.d.ts +11 -0
- package/declarations/compile/Compiled.d.ts.map +1 -1
- package/declarations/compile/compile.d.ts +9 -0
- package/declarations/compile/compile.d.ts.map +1 -1
- package/declarations/compile/state.d.ts +0 -5
- package/declarations/compile/state.d.ts.map +1 -1
- package/declarations/compile/types.d.ts +1 -1
- package/declarations/compile/types.d.ts.map +1 -1
- package/declarations/services/compiler.d.ts +22 -1
- package/declarations/services/compiler.d.ts.map +1 -1
- package/declarations/services/known-modules.d.ts +9 -0
- package/declarations/services/known-modules.d.ts.map +1 -1
- package/declarations/setup.d.ts.map +1 -1
- package/dist/{_commonjsHelpers-BAGoDD49.js → _commonjsHelpers-Bssqqw1Q.js} +2 -4
- package/dist/_commonjsHelpers-Bssqqw1Q.js.map +1 -0
- package/dist/compile/Compiled.js +7 -1
- package/dist/compile/Compiled.js.map +1 -1
- package/dist/compile/compile.js +0 -5
- package/dist/compile/compile.js.map +1 -1
- package/dist/compile/state.js +1 -13
- package/dist/compile/state.js.map +1 -1
- package/dist/compile/utils.js.map +1 -1
- package/dist/{index-DNPwtadt.js → index-CPzChcIg.js} +2 -2
- package/dist/{index-DNPwtadt.js.map → index-CPzChcIg.js.map} +1 -1
- package/dist/{index-C0sat7kP.js → index-D55gYNjO.js} +29 -8
- package/dist/index-D55gYNjO.js.map +1 -0
- package/dist/index-DNctqogm.js +70615 -0
- package/dist/index-DNctqogm.js.map +1 -0
- package/dist/{plugin-ZDtYFKJg.js → plugin-Deq-PxMR.js} +58 -37
- package/dist/plugin-Deq-PxMR.js.map +1 -0
- package/dist/services/compiler.js +90 -36
- package/dist/services/compiler.js.map +1 -1
- package/dist/services/known-modules.js +72 -60
- package/dist/services/known-modules.js.map +1 -1
- package/dist/setup.js +1 -4
- package/dist/setup.js.map +1 -1
- package/dist/test-support.js.map +1 -1
- package/package.json +35 -36
- package/src/compile/Compiled.ts +17 -0
- package/src/compile/compile.ts +9 -7
- package/src/compile/state.ts +0 -15
- package/src/compile/types.ts +2 -0
- package/src/services/compiler.ts +117 -31
- package/src/services/known-modules.ts +87 -56
- package/src/setup.ts +1 -8
- package/dist/_commonjsHelpers-BAGoDD49.js.map +0 -1
- package/dist/babel-DbH-RlNa.js +0 -106895
- package/dist/babel-DbH-RlNa.js.map +0 -1
- package/dist/index-C0sat7kP.js.map +0 -1
- package/dist/plugin-ZDtYFKJg.js.map +0 -1
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import { tracked } from '@glimmer/tracking';
|
|
2
1
|
import { setComponentTemplate } from '@ember/component';
|
|
3
2
|
import templateOnly from '@ember/component/template-only';
|
|
4
3
|
import { assert } from '@ember/debug';
|
|
5
4
|
import { registerDestructor } from '@ember/destroyable';
|
|
6
|
-
import { hash, get, fn, concat, array } from '@ember/helper';
|
|
7
|
-
import { on } from '@ember/modifier';
|
|
8
5
|
import { getOwner } from '@ember/owner';
|
|
6
|
+
import { trackedArray, trackedMap } from '@ember/reactive/collections';
|
|
9
7
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
10
8
|
import { waitFor } from '@ember/test-waiters';
|
|
11
9
|
import { createStore } from 'ember-primitives/store';
|
|
12
10
|
import { resource } from 'ember-resources';
|
|
13
11
|
import { Compiler } from 'repl-sdk';
|
|
14
12
|
import { nameFor } from '../compile/utils.js';
|
|
15
|
-
import { modules } from './known-modules.js';
|
|
16
|
-
import {
|
|
13
|
+
import { modules, packagesFor } from './known-modules.js';
|
|
14
|
+
import { n } from 'decorator-transforms/runtime-esm';
|
|
17
15
|
|
|
18
16
|
/**
|
|
19
17
|
* @import {Node, Parent} from 'unist'
|
|
@@ -454,14 +452,6 @@ function rendersElement(x) {
|
|
|
454
452
|
* HBS isn't used in real apps (that are fully up to date)
|
|
455
453
|
*/
|
|
456
454
|
const standardScope = {
|
|
457
|
-
// These are only added here because it's convenient for hbs
|
|
458
|
-
// to have them
|
|
459
|
-
array,
|
|
460
|
-
concat,
|
|
461
|
-
fn,
|
|
462
|
-
get,
|
|
463
|
-
hash,
|
|
464
|
-
on,
|
|
465
455
|
// The default available scope for gjs:
|
|
466
456
|
//
|
|
467
457
|
// We don't use gjs transpilation here, because hbs transpilation
|
|
@@ -521,6 +511,14 @@ const standardScope = {
|
|
|
521
511
|
// WHATWG
|
|
522
512
|
isSecureContext
|
|
523
513
|
};
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* A spread would read the getters of `standardScope` once, before any compile.
|
|
517
|
+
*/
|
|
518
|
+
function withStandardScope(extra) {
|
|
519
|
+
const scope = Object.defineProperties({}, Object.getOwnPropertyDescriptors(standardScope));
|
|
520
|
+
return Object.defineProperties(scope, Object.getOwnPropertyDescriptors(extra ?? {}));
|
|
521
|
+
}
|
|
524
522
|
class CompilerService {
|
|
525
523
|
#compiler;
|
|
526
524
|
constructor() {
|
|
@@ -534,12 +532,39 @@ class CompilerService {
|
|
|
534
532
|
delete global.REPL?.compiler;
|
|
535
533
|
});
|
|
536
534
|
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
535
|
+
messages = trackedArray();
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* The packages that the last compile imported, as name → version.
|
|
539
|
+
* The version is `undefined` for modules that ember-repl or the host app provides.
|
|
540
|
+
*/
|
|
541
|
+
dependencies = trackedMap();
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* The packages of the compile in progress.
|
|
545
|
+
* They replace `dependencies` when the compile ends,
|
|
546
|
+
* so that the list does not empty out while a compile runs.
|
|
547
|
+
*/
|
|
548
|
+
#pending;
|
|
549
|
+
#dependencyListeners = new Set();
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* Calls `listener` with all of `dependencies` after each change,
|
|
553
|
+
* for a page that shows them in another window.
|
|
554
|
+
*
|
|
555
|
+
* Returns a function that stops the calls.
|
|
556
|
+
*/
|
|
557
|
+
onDependencies(listener) {
|
|
558
|
+
this.#dependencyListeners.add(listener);
|
|
559
|
+
return () => this.#dependencyListeners.delete(listener);
|
|
560
|
+
}
|
|
561
|
+
#reportDependencies() {
|
|
562
|
+
if (this.#dependencyListeners.size === 0) return;
|
|
563
|
+
const entries = Array.from(this.dependencies);
|
|
564
|
+
for (const listener of this.#dependencyListeners) {
|
|
565
|
+
listener(entries);
|
|
566
|
+
}
|
|
541
567
|
}
|
|
542
|
-
#messages = (i(this, "messages"), void 0);
|
|
543
568
|
get lastInfo() {
|
|
544
569
|
const m = this.messages;
|
|
545
570
|
for (let i = m.length - 1; i >= 0; i--) {
|
|
@@ -590,18 +615,30 @@ class CompilerService {
|
|
|
590
615
|
};
|
|
591
616
|
this.#compiler = new Compiler({
|
|
592
617
|
logging: location.search.includes('debug'),
|
|
593
|
-
resolve:
|
|
594
|
-
|
|
595
|
-
},
|
|
618
|
+
resolve: localModules,
|
|
619
|
+
packages: packagesFor(Object.keys(localModules)),
|
|
596
620
|
on: {
|
|
597
|
-
log: (type, message) => {
|
|
598
|
-
this.messages.push({
|
|
621
|
+
log: (type, message, error) => {
|
|
622
|
+
this.messages.push(type === 'error' ? {
|
|
623
|
+
type,
|
|
624
|
+
message,
|
|
625
|
+
error
|
|
626
|
+
} : {
|
|
599
627
|
type,
|
|
600
628
|
message
|
|
601
629
|
});
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
this
|
|
630
|
+
},
|
|
631
|
+
dependency: (name, version) => {
|
|
632
|
+
if (this.#pending) {
|
|
633
|
+
this.#pending.set(name, version);
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* An `import()` that runs after the compile.
|
|
639
|
+
*/
|
|
640
|
+
this.dependencies.set(name, version);
|
|
641
|
+
this.#reportDependencies();
|
|
605
642
|
}
|
|
606
643
|
},
|
|
607
644
|
options: {
|
|
@@ -610,13 +647,14 @@ class CompilerService {
|
|
|
610
647
|
owner,
|
|
611
648
|
...(options.gjs ?? {})
|
|
612
649
|
},
|
|
650
|
+
gts: {
|
|
651
|
+
owner,
|
|
652
|
+
...(options.gts ?? {})
|
|
653
|
+
},
|
|
613
654
|
gmd: {
|
|
614
655
|
owner,
|
|
615
656
|
...(options.gmd ?? {}),
|
|
616
|
-
scope:
|
|
617
|
-
...standardScope,
|
|
618
|
-
...(options.gmd?.scope ?? {})
|
|
619
|
-
},
|
|
657
|
+
scope: withStandardScope(options.gmd?.scope),
|
|
620
658
|
remarkPlugins: [function defaultHbsToEmber() {
|
|
621
659
|
return function transformer(tree) {
|
|
622
660
|
visit(tree, 'code', node => {
|
|
@@ -637,10 +675,7 @@ class CompilerService {
|
|
|
637
675
|
ember: {
|
|
638
676
|
owner,
|
|
639
677
|
...(options.hbs ?? {}),
|
|
640
|
-
scope:
|
|
641
|
-
...standardScope,
|
|
642
|
-
...(options.hbs?.scope ?? {})
|
|
643
|
-
}
|
|
678
|
+
scope: withStandardScope(options.hbs?.scope)
|
|
644
679
|
}
|
|
645
680
|
}
|
|
646
681
|
}
|
|
@@ -669,8 +704,27 @@ class CompilerService {
|
|
|
669
704
|
* worry about invalidation or anything.
|
|
670
705
|
*/
|
|
671
706
|
await Promise.resolve();
|
|
672
|
-
this.messages =
|
|
673
|
-
|
|
707
|
+
this.messages.length = 0;
|
|
708
|
+
const pending = new Map();
|
|
709
|
+
this.#pending = pending;
|
|
710
|
+
try {
|
|
711
|
+
return await this.compiler.compile(ext, text, options ?? {});
|
|
712
|
+
} finally {
|
|
713
|
+
/**
|
|
714
|
+
* A newer compile owns the list now.
|
|
715
|
+
*/
|
|
716
|
+
if (this.#pending === pending) {
|
|
717
|
+
this.#pending = undefined;
|
|
718
|
+
this.#publishDependencies(pending);
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
#publishDependencies(entries) {
|
|
723
|
+
this.dependencies.clear();
|
|
724
|
+
for (const [name, version] of entries) {
|
|
725
|
+
this.dependencies.set(name, version);
|
|
726
|
+
}
|
|
727
|
+
this.#reportDependencies();
|
|
674
728
|
}
|
|
675
729
|
|
|
676
730
|
/**
|
|
@@ -1 +1 @@
|
|
|
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.1.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 * @import {Node as UnistNode, Parent as UnistParent} from 'unist'\n * @import {VisitorResult} from 'unist-util-visit-parents'\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 ReadonlyArray<any>\n * ? MatchesOne<Value, Check[number]>\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(\n `Missing owner. Cannot use ember-repl's compiler without an owner.`,\n owner\n );\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: {\n element: Element;\n destroy: () => void;\n}): 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 gjs?: {\n owner?: 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 const parentOwner = getOwner(this);\n const owner = {\n name: 'ember-repl owner',\n parent: parentOwner,\n /**\n * @param {string} name\n */\n lookup(name: `${string}:${string}`): unknown {\n if (!parentOwner) return;\n\n return parentOwner.lookup(name);\n },\n /**\n * @param {string} name\n */\n resolveRegistration(name: string): unknown {\n if (!parentOwner) return;\n\n // @ts-expect-error\n return parentOwner.resolveRegistration(name);\n },\n };\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,\n ...(options.gjs ?? {}),\n },\n gmd: {\n owner,\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 owner,\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 options ||= {};\n\n try {\n if (ext === 'hbs') {\n /**\n * Are there other hbs-using frameworks?\n */\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 * @param {object} [options] additional render options (e.g. `args`)\n */\n compileGJS(\n code: string,\n options?: Record<string, unknown>\n ): Promise<CompileResult> {\n return this.compile('gjs', code, options);\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","parentOwner","lookup","resolveRegistration","Compiler","logging","location","search","includes","resolve","log","message","push","gjs","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,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C,EAAE;AACV;AACA;AACAC,MAAAA,OAAO,CAACH,KAAK,CAACE,CAAC,CAAC;AAChBF,MAAAA,KAAK,GAAGE,CAAsB;AAChC,IAAA;IAEA,OAAO;MAAExH,IAAI;MAAEqH,SAAS;AAAEC,MAAAA;KAAO;AACnC,EAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AARE,EAAA;IAAAI,CAAA,CAAA,IAAA,CAAA9C,SAAA,EAAA,SAAA,EAAA,CA7BC+C,OAAO,CAAA,CAAA;AAAA;AAsCRC,EAAAA,UAAUA,CACRC,IAAY,EACZvC,OAAiC,EACT;IACxB,OAAO,IAAI,CAAC6B,OAAO,CAAC,KAAK,EAAEU,IAAI,EAAEvC,OAAO,CAAC;AAC3C,EAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;EACE,MACMwC,UAAUA,CACdC,MAAc,EACdzC,OAUC,GAAG,EAAE,EACkB;IACxB,OAAO,IAAI,CAAC6B,OAAO,CAAC,KAAK,EAAEY,MAAM,EAAEzC,OAAO,CAAC;AAC7C,EAAA;AAAC,EAAA;IAAAoC,CAAA,CAAA,IAAA,CAAA9C,SAAA,EAAA,YAAA,EAAA,CAhBA+C,OAAO,CAAA,CAAA;AAAA;AAmBRK,EAAAA,SAASA,CACPD,MAAc,EACdzC,OAGC,EACuB;IACxB,OAAO,IAAI,CAAC6B,OAAO,CAAC,IAAI,EAAEY,MAAM,EAAEzC,OAAO,CAAC;AAC5C,EAAA;AAAC,EAAA;IAAAoC,CAAA,CAAA,IAAA,CAAA9C,SAAA,EAAA,WAAA,EAAA,CATA+C,OAAO,CAAA,CAAA;AAAA;AAUV;AAEA,SAASpD,SAASA,GAAG;AACnB,EAAA,OAAO3B,UAAU;AAKnB;;;;","x_google_ignoreList":[0,1,2,3]}
|
|
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.1.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 * @import {Node as UnistNode, Parent as UnistParent} from 'unist'\n * @import {VisitorResult} from 'unist-util-visit-parents'\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 ReadonlyArray<any>\n * ? MatchesOne<Value, Check[number]>\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 { setComponentTemplate } from '@ember/component';\nimport templateOnly from '@ember/component/template-only';\nimport { assert } from '@ember/debug';\nimport { registerDestructor } from '@ember/destroyable';\nimport { getOwner } from '@ember/owner';\nimport { trackedArray, trackedMap } from '@ember/reactive/collections';\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, packagesFor } 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(\n `Missing owner. Cannot use ember-repl's compiler without an owner.`,\n owner\n );\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: {\n element: Element;\n destroy: () => void;\n}): 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 gjs?: {\n owner?: unknown;\n };\n gts?: {\n owner?: 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 // 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\n/**\n * A spread would read the getters of `standardScope` once, before any compile.\n */\nfunction withStandardScope(extra: Record<string, unknown> | undefined) {\n const scope = Object.defineProperties(\n {},\n Object.getOwnPropertyDescriptors(standardScope)\n );\n\n return Object.defineProperties(\n scope,\n Object.getOwnPropertyDescriptors(extra ?? {})\n );\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 readonly messages = trackedArray<Message>();\n\n /**\n * The packages that the last compile imported, as name → version.\n * The version is `undefined` for modules that ember-repl or the host app provides.\n */\n readonly dependencies = trackedMap<string, string | undefined>();\n\n /**\n * The packages of the compile in progress.\n * They replace `dependencies` when the compile ends,\n * so that the list does not empty out while a compile runs.\n */\n #pending: Map<string, string | undefined> | undefined;\n\n #dependencyListeners = new Set<\n (entries: [string, string | undefined][]) => void\n >();\n\n /**\n * Calls `listener` with all of `dependencies` after each change,\n * for a page that shows them in another window.\n *\n * Returns a function that stops the calls.\n */\n onDependencies(listener: (entries: [string, string | undefined][]) => void) {\n this.#dependencyListeners.add(listener);\n\n return () => this.#dependencyListeners.delete(listener);\n }\n\n #reportDependencies() {\n if (this.#dependencyListeners.size === 0) return;\n\n const entries = Array.from(this.dependencies);\n\n for (const listener of this.#dependencyListeners) {\n listener(entries);\n }\n }\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 const parentOwner = getOwner(this);\n const owner = {\n name: 'ember-repl owner',\n parent: parentOwner,\n /**\n * @param {string} name\n */\n lookup(name: `${string}:${string}`): unknown {\n if (!parentOwner) return;\n\n return parentOwner.lookup(name);\n },\n /**\n * @param {string} name\n */\n resolveRegistration(name: string): unknown {\n if (!parentOwner) return;\n\n // @ts-expect-error\n return parentOwner.resolveRegistration(name);\n },\n };\n\n this.#compiler = new Compiler({\n logging: location.search.includes('debug'),\n resolve: localModules,\n packages: packagesFor(Object.keys(localModules)),\n on: {\n log: (type: Message['type'], message: string, error?: unknown) => {\n this.messages.push(\n type === 'error' ? { type, message, error } : { type, message }\n );\n },\n dependency: (name: string, version: string | undefined) => {\n if (this.#pending) {\n this.#pending.set(name, version);\n\n return;\n }\n\n /**\n * An `import()` that runs after the compile.\n */\n this.dependencies.set(name, version);\n this.#reportDependencies();\n },\n },\n options: {\n ...options,\n gjs: {\n owner,\n ...(options.gjs ?? {}),\n },\n gts: {\n owner,\n ...(options.gts ?? {}),\n },\n gmd: {\n owner,\n ...(options.gmd ?? {}),\n scope: withStandardScope(options.gmd?.scope),\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 owner,\n ...(options.hbs ?? {}),\n scope: withStandardScope(options.hbs?.scope),\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 * Shows another file, with its own undo history.\n * `format` is undefined for a file with no language support.\n */\n openDocument: (key: string, text: string, format: string | undefined) => Promise<void>;\n forgetDocument: (key: string) => 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.length = 0;\n\n const pending = new Map<string, string | undefined>();\n\n this.#pending = pending;\n\n try {\n return await this.compiler.compile(ext, text, options ?? {});\n } finally {\n /**\n * A newer compile owns the list now.\n */\n if (this.#pending === pending) {\n this.#pending = undefined;\n this.#publishDependencies(pending);\n }\n }\n }\n\n #publishDependencies(entries: Map<string, string | undefined>) {\n this.dependencies.clear();\n\n for (const [name, version] of entries) {\n this.dependencies.set(name, version);\n }\n\n this.#reportDependencies();\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 options ||= {};\n\n try {\n if (ext === 'hbs') {\n /**\n * Are there other hbs-using frameworks?\n */\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 * @param {object} [options] additional render options (e.g. `args`)\n */\n compileGJS(\n code: string,\n options?: Record<string, unknown>\n ): Promise<CompileResult> {\n return this.compile('gjs', code, options);\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":[],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AACA;;;AAwHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,OAAO;AAClB;AACA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEI;AACJ;AACA;AACA;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