@typespec/html-program-viewer 0.83.0-dev.2 → 0.84.0-dev.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.
@@ -1443,6 +1443,10 @@ var { createDiagnostic, reportDiagnostic } = createDiagnosticCreator({
1443
1443
  severity: "error",
1444
1444
  messages: { default: paramMessage`Property "${"option"}" can only be used in a project config (with \`kind: project\`).` }
1445
1445
  },
1446
+ "config-unknown-feature": {
1447
+ severity: "error",
1448
+ messages: { default: paramMessage`Unknown compiler feature "${"feature"}".` }
1449
+ },
1446
1450
  "config-project-not-as-cli-config": {
1447
1451
  severity: "error",
1448
1452
  messages: { default: "`--config` cannot point to a project config (with `kind: project`). Use a non-project build config that `extends` the project config instead." }
@@ -1779,215 +1783,507 @@ var { createDiagnostic, reportDiagnostic } = createDiagnosticCreator({
1779
1783
  }
1780
1784
  });
1781
1785
  //#endregion
1782
- //#region ../../node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/code.js
1783
- var require_code$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
1784
- Object.defineProperty(exports, "__esModule", { value: true });
1785
- exports.regexpCode = exports.getEsmExportName = exports.getProperty = exports.safeStringify = exports.stringify = exports.strConcat = exports.addCodeArg = exports.str = exports._ = exports.nil = exports._Code = exports.Name = exports.IDENTIFIER = exports._CodeOrName = void 0;
1786
- var _CodeOrName = class {};
1787
- exports._CodeOrName = _CodeOrName;
1788
- exports.IDENTIFIER = /^[a-z$_][a-z$_0-9]*$/i;
1789
- var Name = class extends _CodeOrName {
1790
- constructor(s) {
1791
- super();
1792
- if (!exports.IDENTIFIER.test(s)) throw new Error("CodeGen: name must be a valid identifier");
1793
- this.str = s;
1794
- }
1795
- toString() {
1796
- return this.str;
1797
- }
1798
- emptyStr() {
1799
- return false;
1800
- }
1801
- get names() {
1802
- return { [this.str]: 1 };
1803
- }
1804
- };
1805
- exports.Name = Name;
1806
- var _Code = class extends _CodeOrName {
1807
- constructor(code) {
1808
- super();
1809
- this._items = typeof code === "string" ? [code] : code;
1810
- }
1811
- toString() {
1812
- return this.str;
1813
- }
1814
- emptyStr() {
1815
- if (this._items.length > 1) return false;
1816
- const item = this._items[0];
1817
- return item === "" || item === "\"\"";
1818
- }
1819
- get str() {
1820
- var _a;
1821
- return (_a = this._str) !== null && _a !== void 0 ? _a : this._str = this._items.reduce((s, c) => `${s}${c}`, "");
1822
- }
1823
- get names() {
1824
- var _a;
1825
- return (_a = this._names) !== null && _a !== void 0 ? _a : this._names = this._items.reduce((names, c) => {
1826
- if (c instanceof Name) names[c.str] = (names[c.str] || 0) + 1;
1827
- return names;
1828
- }, {});
1829
- }
1786
+ //#region ../compiler/dist/src/core/source-file.js
1787
+ function createSourceFile(text, path) {
1788
+ let lineStarts = void 0;
1789
+ return {
1790
+ text,
1791
+ path,
1792
+ getLineStarts,
1793
+ getLineAndCharacterOfPosition
1830
1794
  };
1831
- exports._Code = _Code;
1832
- exports.nil = new _Code("");
1833
- function _(strs, ...args) {
1834
- const code = [strs[0]];
1835
- let i = 0;
1836
- while (i < args.length) {
1837
- addCodeArg(code, args[i]);
1838
- code.push(strs[++i]);
1839
- }
1840
- return new _Code(code);
1841
- }
1842
- exports._ = _;
1843
- var plus = new _Code("+");
1844
- function str(strs, ...args) {
1845
- const expr = [safeStringify(strs[0])];
1846
- let i = 0;
1847
- while (i < args.length) {
1848
- expr.push(plus);
1849
- addCodeArg(expr, args[i]);
1850
- expr.push(plus, safeStringify(strs[++i]));
1851
- }
1852
- optimize(expr);
1853
- return new _Code(expr);
1854
- }
1855
- exports.str = str;
1856
- function addCodeArg(code, arg) {
1857
- if (arg instanceof _Code) code.push(...arg._items);
1858
- else if (arg instanceof Name) code.push(arg);
1859
- else code.push(interpolate(arg));
1795
+ function getLineStarts() {
1796
+ return lineStarts = lineStarts ?? scanLineStarts(text);
1860
1797
  }
1861
- exports.addCodeArg = addCodeArg;
1862
- function optimize(expr) {
1863
- let i = 1;
1864
- while (i < expr.length - 1) {
1865
- if (expr[i] === plus) {
1866
- const res = mergeExprItems(expr[i - 1], expr[i + 1]);
1867
- if (res !== void 0) {
1868
- expr.splice(i - 1, 3, res);
1869
- continue;
1870
- }
1871
- expr[i++] = "+";
1872
- }
1873
- i++;
1874
- }
1798
+ function getLineAndCharacterOfPosition(position) {
1799
+ const starts = getLineStarts();
1800
+ let line = binarySearch(starts, position);
1801
+ if (line < 0) line = ~line - 1;
1802
+ return {
1803
+ line,
1804
+ character: position - starts[line]
1805
+ };
1875
1806
  }
1876
- function mergeExprItems(a, b) {
1877
- if (b === "\"\"") return a;
1878
- if (a === "\"\"") return b;
1879
- if (typeof a == "string") {
1880
- if (b instanceof Name || a[a.length - 1] !== "\"") return;
1881
- if (typeof b != "string") return `${a.slice(0, -1)}${b}"`;
1882
- if (b[0] === "\"") return a.slice(0, -1) + b.slice(1);
1883
- return;
1807
+ }
1808
+ function scanLineStarts(text) {
1809
+ const starts = [];
1810
+ let start = 0;
1811
+ let pos = 0;
1812
+ while (pos < text.length) {
1813
+ const ch = text.charCodeAt(pos);
1814
+ pos++;
1815
+ switch (ch) {
1816
+ case 13: if (text.charCodeAt(pos) === 10) pos++;
1817
+ case 10:
1818
+ starts.push(start);
1819
+ start = pos;
1820
+ break;
1884
1821
  }
1885
- if (typeof b == "string" && b[0] === "\"" && !(a instanceof Name)) return `"${a}${b.slice(1)}`;
1886
- }
1887
- function strConcat(c1, c2) {
1888
- return c2.emptyStr() ? c1 : c1.emptyStr() ? c2 : str`${c1}${c2}`;
1889
- }
1890
- exports.strConcat = strConcat;
1891
- function interpolate(x) {
1892
- return typeof x == "number" || typeof x == "boolean" || x === null ? x : safeStringify(Array.isArray(x) ? x.join(",") : x);
1893
- }
1894
- function stringify(x) {
1895
- return new _Code(safeStringify(x));
1896
1822
  }
1897
- exports.stringify = stringify;
1898
- function safeStringify(x) {
1899
- return JSON.stringify(x).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
1900
- }
1901
- exports.safeStringify = safeStringify;
1902
- function getProperty(key) {
1903
- return typeof key == "string" && exports.IDENTIFIER.test(key) ? new _Code(`.${key}`) : _`[${key}]`;
1904
- }
1905
- exports.getProperty = getProperty;
1906
- function getEsmExportName(key) {
1907
- if (typeof key == "string" && exports.IDENTIFIER.test(key)) return new _Code(`${key}`);
1908
- throw new Error(`CodeGen: invalid export name: ${key}, use explicit $id name mapping`);
1909
- }
1910
- exports.getEsmExportName = getEsmExportName;
1911
- function regexpCode(rx) {
1912
- return new _Code(rx.toString());
1823
+ starts.push(start);
1824
+ return starts;
1825
+ }
1826
+ /**
1827
+ * Search sorted array of numbers for the given value. If found, return index
1828
+ * in array where value was found. If not found, return a negative number that
1829
+ * is the bitwise complement of the index where value would need to be inserted
1830
+ * to keep the array sorted.
1831
+ */
1832
+ function binarySearch(array, value) {
1833
+ let low = 0;
1834
+ let high = array.length - 1;
1835
+ while (low <= high) {
1836
+ const middle = low + (high - low >> 1);
1837
+ const v = array[middle];
1838
+ if (v < value) low = middle + 1;
1839
+ else if (v > value) high = middle - 1;
1840
+ else return middle;
1913
1841
  }
1914
- exports.regexpCode = regexpCode;
1915
- }));
1842
+ return ~low;
1843
+ }
1916
1844
  //#endregion
1917
- //#region ../../node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/scope.js
1918
- var require_scope = /* @__PURE__ */ __commonJSMin(((exports) => {
1919
- Object.defineProperty(exports, "__esModule", { value: true });
1920
- exports.ValueScope = exports.ValueScopeName = exports.Scope = exports.varKinds = exports.UsedValueState = void 0;
1921
- var code_1 = require_code$1();
1922
- var ValueError = class extends Error {
1923
- constructor(name) {
1924
- super(`CodeGen: "code" for ${name} not defined`);
1925
- this.value = name.value;
1926
- }
1927
- };
1928
- var UsedValueState;
1929
- (function(UsedValueState) {
1930
- UsedValueState[UsedValueState["Started"] = 0] = "Started";
1931
- UsedValueState[UsedValueState["Completed"] = 1] = "Completed";
1932
- })(UsedValueState || (exports.UsedValueState = UsedValueState = {}));
1933
- exports.varKinds = {
1934
- const: new code_1.Name("const"),
1935
- let: new code_1.Name("let"),
1936
- var: new code_1.Name("var")
1937
- };
1938
- var Scope = class {
1939
- constructor({ prefixes, parent } = {}) {
1940
- this._names = {};
1941
- this._prefixes = prefixes;
1942
- this._parent = parent;
1943
- }
1944
- toName(nameOrPrefix) {
1945
- return nameOrPrefix instanceof code_1.Name ? nameOrPrefix : this.name(nameOrPrefix);
1946
- }
1947
- name(prefix) {
1948
- return new code_1.Name(this._newName(prefix));
1949
- }
1950
- _newName(prefix) {
1951
- const ng = this._names[prefix] || this._nameGroup(prefix);
1952
- return `${prefix}${ng.index++}`;
1953
- }
1954
- _nameGroup(prefix) {
1955
- var _a, _b;
1956
- if (((_b = (_a = this._parent) === null || _a === void 0 ? void 0 : _a._prefixes) === null || _b === void 0 ? void 0 : _b.has(prefix)) || this._prefixes && !this._prefixes.has(prefix)) throw new Error(`CodeGen: prefix "${prefix}" is not allowed in this scope`);
1957
- return this._names[prefix] = {
1958
- prefix,
1959
- index: 0
1960
- };
1961
- }
1962
- };
1963
- exports.Scope = Scope;
1964
- var ValueScopeName = class extends code_1.Name {
1965
- constructor(prefix, nameStr) {
1966
- super(nameStr);
1967
- this.prefix = prefix;
1968
- }
1969
- setValue(value, { property, itemIndex }) {
1970
- this.value = value;
1971
- this.scopePath = (0, code_1._)`.${new code_1.Name(property)}[${itemIndex}]`;
1972
- }
1973
- };
1974
- exports.ValueScopeName = ValueScopeName;
1975
- var line = (0, code_1._)`\n`;
1976
- var ValueScope = class extends Scope {
1977
- constructor(opts) {
1978
- super(opts);
1979
- this._values = {};
1980
- this._scope = opts.scope;
1981
- this.opts = {
1982
- ...opts,
1983
- _n: opts.lines ? line : code_1.nil
1984
- };
1985
- }
1986
- get() {
1987
- return this._scope;
1988
- }
1989
- name(prefix) {
1990
- return new ValueScopeName(prefix, this._newName(prefix));
1845
+ //#region ../compiler/dist/src/core/types.js
1846
+ var ResolutionResultFlags;
1847
+ (function(ResolutionResultFlags) {
1848
+ ResolutionResultFlags[ResolutionResultFlags["None"] = 0] = "None";
1849
+ ResolutionResultFlags[ResolutionResultFlags["Resolved"] = 2] = "Resolved";
1850
+ ResolutionResultFlags[ResolutionResultFlags["Unknown"] = 4] = "Unknown";
1851
+ ResolutionResultFlags[ResolutionResultFlags["Ambiguous"] = 8] = "Ambiguous";
1852
+ ResolutionResultFlags[ResolutionResultFlags["NotFound"] = 16] = "NotFound";
1853
+ ResolutionResultFlags[ResolutionResultFlags["ResolutionFailed"] = 28] = "ResolutionFailed";
1854
+ })(ResolutionResultFlags || (ResolutionResultFlags = {}));
1855
+ /**
1856
+ * AST types
1857
+ */
1858
+ var SyntaxKind;
1859
+ (function(SyntaxKind) {
1860
+ SyntaxKind[SyntaxKind["TypeSpecScript"] = 0] = "TypeSpecScript";
1861
+ SyntaxKind[SyntaxKind["JsSourceFile"] = 1] = "JsSourceFile";
1862
+ SyntaxKind[SyntaxKind["ImportStatement"] = 2] = "ImportStatement";
1863
+ SyntaxKind[SyntaxKind["Identifier"] = 3] = "Identifier";
1864
+ SyntaxKind[SyntaxKind["AugmentDecoratorStatement"] = 4] = "AugmentDecoratorStatement";
1865
+ SyntaxKind[SyntaxKind["DecoratorExpression"] = 5] = "DecoratorExpression";
1866
+ SyntaxKind[SyntaxKind["DirectiveExpression"] = 6] = "DirectiveExpression";
1867
+ SyntaxKind[SyntaxKind["MemberExpression"] = 7] = "MemberExpression";
1868
+ SyntaxKind[SyntaxKind["NamespaceStatement"] = 8] = "NamespaceStatement";
1869
+ SyntaxKind[SyntaxKind["UsingStatement"] = 9] = "UsingStatement";
1870
+ SyntaxKind[SyntaxKind["OperationStatement"] = 10] = "OperationStatement";
1871
+ SyntaxKind[SyntaxKind["OperationSignatureDeclaration"] = 11] = "OperationSignatureDeclaration";
1872
+ SyntaxKind[SyntaxKind["OperationSignatureReference"] = 12] = "OperationSignatureReference";
1873
+ SyntaxKind[SyntaxKind["ModelStatement"] = 13] = "ModelStatement";
1874
+ SyntaxKind[SyntaxKind["ModelExpression"] = 14] = "ModelExpression";
1875
+ SyntaxKind[SyntaxKind["ModelProperty"] = 15] = "ModelProperty";
1876
+ SyntaxKind[SyntaxKind["ModelSpreadProperty"] = 16] = "ModelSpreadProperty";
1877
+ SyntaxKind[SyntaxKind["ScalarStatement"] = 17] = "ScalarStatement";
1878
+ SyntaxKind[SyntaxKind["InterfaceStatement"] = 18] = "InterfaceStatement";
1879
+ SyntaxKind[SyntaxKind["UnionStatement"] = 19] = "UnionStatement";
1880
+ SyntaxKind[SyntaxKind["UnionVariant"] = 20] = "UnionVariant";
1881
+ SyntaxKind[SyntaxKind["EnumStatement"] = 21] = "EnumStatement";
1882
+ SyntaxKind[SyntaxKind["EnumMember"] = 22] = "EnumMember";
1883
+ SyntaxKind[SyntaxKind["EnumSpreadMember"] = 23] = "EnumSpreadMember";
1884
+ SyntaxKind[SyntaxKind["AliasStatement"] = 24] = "AliasStatement";
1885
+ SyntaxKind[SyntaxKind["DecoratorDeclarationStatement"] = 25] = "DecoratorDeclarationStatement";
1886
+ SyntaxKind[SyntaxKind["FunctionDeclarationStatement"] = 26] = "FunctionDeclarationStatement";
1887
+ SyntaxKind[SyntaxKind["FunctionParameter"] = 27] = "FunctionParameter";
1888
+ SyntaxKind[SyntaxKind["UnionExpression"] = 28] = "UnionExpression";
1889
+ SyntaxKind[SyntaxKind["IntersectionExpression"] = 29] = "IntersectionExpression";
1890
+ SyntaxKind[SyntaxKind["TupleExpression"] = 30] = "TupleExpression";
1891
+ SyntaxKind[SyntaxKind["ArrayExpression"] = 31] = "ArrayExpression";
1892
+ SyntaxKind[SyntaxKind["StringLiteral"] = 32] = "StringLiteral";
1893
+ SyntaxKind[SyntaxKind["NumericLiteral"] = 33] = "NumericLiteral";
1894
+ SyntaxKind[SyntaxKind["BooleanLiteral"] = 34] = "BooleanLiteral";
1895
+ SyntaxKind[SyntaxKind["StringTemplateExpression"] = 35] = "StringTemplateExpression";
1896
+ SyntaxKind[SyntaxKind["StringTemplateHead"] = 36] = "StringTemplateHead";
1897
+ SyntaxKind[SyntaxKind["StringTemplateMiddle"] = 37] = "StringTemplateMiddle";
1898
+ SyntaxKind[SyntaxKind["StringTemplateTail"] = 38] = "StringTemplateTail";
1899
+ SyntaxKind[SyntaxKind["StringTemplateSpan"] = 39] = "StringTemplateSpan";
1900
+ SyntaxKind[SyntaxKind["ExternKeyword"] = 40] = "ExternKeyword";
1901
+ SyntaxKind[SyntaxKind["VoidKeyword"] = 41] = "VoidKeyword";
1902
+ SyntaxKind[SyntaxKind["NeverKeyword"] = 42] = "NeverKeyword";
1903
+ SyntaxKind[SyntaxKind["UnknownKeyword"] = 43] = "UnknownKeyword";
1904
+ SyntaxKind[SyntaxKind["ValueOfExpression"] = 44] = "ValueOfExpression";
1905
+ SyntaxKind[SyntaxKind["TypeReference"] = 45] = "TypeReference";
1906
+ SyntaxKind[SyntaxKind["TemplateParameterDeclaration"] = 46] = "TemplateParameterDeclaration";
1907
+ SyntaxKind[SyntaxKind["EmptyStatement"] = 47] = "EmptyStatement";
1908
+ SyntaxKind[SyntaxKind["InvalidStatement"] = 48] = "InvalidStatement";
1909
+ SyntaxKind[SyntaxKind["LineComment"] = 49] = "LineComment";
1910
+ SyntaxKind[SyntaxKind["BlockComment"] = 50] = "BlockComment";
1911
+ SyntaxKind[SyntaxKind["Doc"] = 51] = "Doc";
1912
+ SyntaxKind[SyntaxKind["DocText"] = 52] = "DocText";
1913
+ SyntaxKind[SyntaxKind["DocParamTag"] = 53] = "DocParamTag";
1914
+ SyntaxKind[SyntaxKind["DocPropTag"] = 54] = "DocPropTag";
1915
+ SyntaxKind[SyntaxKind["DocReturnsTag"] = 55] = "DocReturnsTag";
1916
+ SyntaxKind[SyntaxKind["DocErrorsTag"] = 56] = "DocErrorsTag";
1917
+ SyntaxKind[SyntaxKind["DocTemplateTag"] = 57] = "DocTemplateTag";
1918
+ SyntaxKind[SyntaxKind["DocUnknownTag"] = 58] = "DocUnknownTag";
1919
+ SyntaxKind[SyntaxKind["Return"] = 59] = "Return";
1920
+ SyntaxKind[SyntaxKind["JsNamespaceDeclaration"] = 60] = "JsNamespaceDeclaration";
1921
+ SyntaxKind[SyntaxKind["TemplateArgument"] = 61] = "TemplateArgument";
1922
+ SyntaxKind[SyntaxKind["TypeOfExpression"] = 62] = "TypeOfExpression";
1923
+ SyntaxKind[SyntaxKind["ObjectLiteral"] = 63] = "ObjectLiteral";
1924
+ SyntaxKind[SyntaxKind["ObjectLiteralProperty"] = 64] = "ObjectLiteralProperty";
1925
+ SyntaxKind[SyntaxKind["ObjectLiteralSpreadProperty"] = 65] = "ObjectLiteralSpreadProperty";
1926
+ SyntaxKind[SyntaxKind["ArrayLiteral"] = 66] = "ArrayLiteral";
1927
+ SyntaxKind[SyntaxKind["ConstStatement"] = 67] = "ConstStatement";
1928
+ SyntaxKind[SyntaxKind["CallExpression"] = 68] = "CallExpression";
1929
+ SyntaxKind[SyntaxKind["ScalarConstructor"] = 69] = "ScalarConstructor";
1930
+ SyntaxKind[SyntaxKind["InternalKeyword"] = 70] = "InternalKeyword";
1931
+ SyntaxKind[SyntaxKind["FunctionTypeExpression"] = 71] = "FunctionTypeExpression";
1932
+ })(SyntaxKind || (SyntaxKind = {}));
1933
+ var IdentifierKind;
1934
+ (function(IdentifierKind) {
1935
+ IdentifierKind[IdentifierKind["TypeReference"] = 0] = "TypeReference";
1936
+ IdentifierKind[IdentifierKind["TemplateArgument"] = 1] = "TemplateArgument";
1937
+ IdentifierKind[IdentifierKind["Decorator"] = 2] = "Decorator";
1938
+ IdentifierKind[IdentifierKind["Function"] = 3] = "Function";
1939
+ IdentifierKind[IdentifierKind["Using"] = 4] = "Using";
1940
+ IdentifierKind[IdentifierKind["Declaration"] = 5] = "Declaration";
1941
+ IdentifierKind[IdentifierKind["ModelExpressionProperty"] = 6] = "ModelExpressionProperty";
1942
+ IdentifierKind[IdentifierKind["ModelStatementProperty"] = 7] = "ModelStatementProperty";
1943
+ IdentifierKind[IdentifierKind["ObjectLiteralProperty"] = 8] = "ObjectLiteralProperty";
1944
+ IdentifierKind[IdentifierKind["Other"] = 9] = "Other";
1945
+ })(IdentifierKind || (IdentifierKind = {}));
1946
+ /** Used to explicitly specify that a diagnostic has no target. */
1947
+ var NoTarget = Symbol.for("NoTarget");
1948
+ var ListenerFlow;
1949
+ (function(ListenerFlow) {
1950
+ /**
1951
+ * Do not navigate any containing or referenced type.
1952
+ */
1953
+ ListenerFlow[ListenerFlow["NoRecursion"] = 1] = "NoRecursion";
1954
+ })(ListenerFlow || (ListenerFlow = {}));
1955
+ //#endregion
1956
+ //#region ../compiler/dist/src/core/diagnostics.js
1957
+ /**
1958
+ * Find the syntax node for a TypeSpec diagnostic target.
1959
+ *
1960
+ * This function extracts the AST node from various types of diagnostic targets:
1961
+ * - For template instance targets: returns the node of the template declaration
1962
+ * - For symbols: returns the first declaration node (or symbol source for using symbols)
1963
+ * - For AST nodes: returns the node itself
1964
+ * - For types: returns the node associated with the type
1965
+ *
1966
+ * @param target The diagnostic target to extract a node from. Can be a template instance,
1967
+ * symbol, AST node, or type.
1968
+ * @returns The AST node associated with the target, or undefined if the target is a type
1969
+ * or symbol that doesn't have an associated node.
1970
+ */
1971
+ function getNodeForTarget(target) {
1972
+ if (!("kind" in target) && !("entityKind" in target)) {
1973
+ if (!("declarations" in target)) return target.node;
1974
+ if (target.flags & 8192) target = target.symbolSource;
1975
+ return target.declarations[0];
1976
+ } else if ("kind" in target && typeof target.kind === "number") return target;
1977
+ else return target.node;
1978
+ }
1979
+ function getSourceLocation(target, options = {}) {
1980
+ if (target === NoTarget || target === void 0) return;
1981
+ if ("file" in target) return target;
1982
+ const node = getNodeForTarget(target);
1983
+ return node ? getSourceLocationOfNode(node, options) : createSyntheticSourceLocation();
1984
+ }
1985
+ function createSyntheticSourceLocation(loc = "<unknown location>") {
1986
+ return {
1987
+ file: createSourceFile("", loc),
1988
+ pos: 0,
1989
+ end: 0,
1990
+ isSynthetic: true
1991
+ };
1992
+ }
1993
+ function getSourceLocationOfNode(node, options) {
1994
+ let root = node;
1995
+ while (root.parent !== void 0) root = root.parent;
1996
+ if (root.kind !== SyntaxKind.TypeSpecScript && root.kind !== SyntaxKind.JsSourceFile) return createSyntheticSourceLocation(node.flags & 8 ? void 0 : "<unknown location - cannot obtain source location of unbound node - file bug at https://github.com/microsoft/typespec>");
1997
+ if (options.locateId && "id" in node && node.id !== void 0) node = node.id;
1998
+ return {
1999
+ file: root.file,
2000
+ pos: node.pos,
2001
+ end: node.end
2002
+ };
2003
+ }
2004
+ /**
2005
+ * Use this to report bugs in the compiler, and not errors in the source code
2006
+ * being compiled.
2007
+ *
2008
+ * @param condition Throw if this is not true.
2009
+ *
2010
+ * @param message Error message.
2011
+ *
2012
+ * @param target Optional location in source code that might give a clue about
2013
+ * what got the compiler off track.
2014
+ */
2015
+ function compilerAssert(condition, message, target) {
2016
+ if (condition) return;
2017
+ if (target) {
2018
+ let location;
2019
+ try {
2020
+ location = getSourceLocation(target);
2021
+ } catch (err) {}
2022
+ if (location) {
2023
+ const pos = location.file.getLineAndCharacterOfPosition(location.pos);
2024
+ const file = location.file.path;
2025
+ const line = pos.line + 1;
2026
+ const col = pos.character + 1;
2027
+ message += `\nOccurred while compiling code in ${file} near line ${line}, column ${col}`;
2028
+ }
2029
+ }
2030
+ throw new Error(message);
2031
+ }
2032
+ /**
2033
+ * Create a new instance of the @see DiagnosticCollector.
2034
+ */
2035
+ function createDiagnosticCollector() {
2036
+ const diagnostics = [];
2037
+ return {
2038
+ diagnostics,
2039
+ add,
2040
+ pipe,
2041
+ wrap,
2042
+ join
2043
+ };
2044
+ function add(diagnostic) {
2045
+ diagnostics.push(diagnostic);
2046
+ }
2047
+ function pipe(result) {
2048
+ const [value, diags] = result;
2049
+ for (const diag of diags) diagnostics.push(diag);
2050
+ return value;
2051
+ }
2052
+ function wrap(value) {
2053
+ return [value, diagnostics];
2054
+ }
2055
+ function join(result) {
2056
+ const [value, diags] = result;
2057
+ for (const diag of diags) diagnostics.push(diag);
2058
+ return [value, diagnostics];
2059
+ }
2060
+ }
2061
+ /**
2062
+ * Ignore the diagnostics emitted by the diagnostic accessor pattern and just return the actual result.
2063
+ * @param result Accessor pattern tuple result including the actual result and the list of diagnostics.
2064
+ * @returns Actual result.
2065
+ */
2066
+ function ignoreDiagnostics(result) {
2067
+ return result[0];
2068
+ }
2069
+ //#endregion
2070
+ //#region ../compiler/dist/src/core/helpers/location-context.js
2071
+ function getLocationContext(program, type) {
2072
+ const sourceLocation = getSourceLocation(type);
2073
+ if (sourceLocation.isSynthetic) return { type: "synthetic" };
2074
+ return program.getSourceFileLocationContext(sourceLocation.file);
2075
+ }
2076
+ new Set(Object.keys({ "function-declarations": { description: "Allows use of function declarations without experimental warnings in project code." } }));
2077
+ //#endregion
2078
+ //#region ../../node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/code.js
2079
+ var require_code$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
2080
+ Object.defineProperty(exports, "__esModule", { value: true });
2081
+ exports.regexpCode = exports.getEsmExportName = exports.getProperty = exports.safeStringify = exports.stringify = exports.strConcat = exports.addCodeArg = exports.str = exports._ = exports.nil = exports._Code = exports.Name = exports.IDENTIFIER = exports._CodeOrName = void 0;
2082
+ var _CodeOrName = class {};
2083
+ exports._CodeOrName = _CodeOrName;
2084
+ exports.IDENTIFIER = /^[a-z$_][a-z$_0-9]*$/i;
2085
+ var Name = class extends _CodeOrName {
2086
+ constructor(s) {
2087
+ super();
2088
+ if (!exports.IDENTIFIER.test(s)) throw new Error("CodeGen: name must be a valid identifier");
2089
+ this.str = s;
2090
+ }
2091
+ toString() {
2092
+ return this.str;
2093
+ }
2094
+ emptyStr() {
2095
+ return false;
2096
+ }
2097
+ get names() {
2098
+ return { [this.str]: 1 };
2099
+ }
2100
+ };
2101
+ exports.Name = Name;
2102
+ var _Code = class extends _CodeOrName {
2103
+ constructor(code) {
2104
+ super();
2105
+ this._items = typeof code === "string" ? [code] : code;
2106
+ }
2107
+ toString() {
2108
+ return this.str;
2109
+ }
2110
+ emptyStr() {
2111
+ if (this._items.length > 1) return false;
2112
+ const item = this._items[0];
2113
+ return item === "" || item === "\"\"";
2114
+ }
2115
+ get str() {
2116
+ var _a;
2117
+ return (_a = this._str) !== null && _a !== void 0 ? _a : this._str = this._items.reduce((s, c) => `${s}${c}`, "");
2118
+ }
2119
+ get names() {
2120
+ var _a;
2121
+ return (_a = this._names) !== null && _a !== void 0 ? _a : this._names = this._items.reduce((names, c) => {
2122
+ if (c instanceof Name) names[c.str] = (names[c.str] || 0) + 1;
2123
+ return names;
2124
+ }, {});
2125
+ }
2126
+ };
2127
+ exports._Code = _Code;
2128
+ exports.nil = new _Code("");
2129
+ function _(strs, ...args) {
2130
+ const code = [strs[0]];
2131
+ let i = 0;
2132
+ while (i < args.length) {
2133
+ addCodeArg(code, args[i]);
2134
+ code.push(strs[++i]);
2135
+ }
2136
+ return new _Code(code);
2137
+ }
2138
+ exports._ = _;
2139
+ var plus = new _Code("+");
2140
+ function str(strs, ...args) {
2141
+ const expr = [safeStringify(strs[0])];
2142
+ let i = 0;
2143
+ while (i < args.length) {
2144
+ expr.push(plus);
2145
+ addCodeArg(expr, args[i]);
2146
+ expr.push(plus, safeStringify(strs[++i]));
2147
+ }
2148
+ optimize(expr);
2149
+ return new _Code(expr);
2150
+ }
2151
+ exports.str = str;
2152
+ function addCodeArg(code, arg) {
2153
+ if (arg instanceof _Code) code.push(...arg._items);
2154
+ else if (arg instanceof Name) code.push(arg);
2155
+ else code.push(interpolate(arg));
2156
+ }
2157
+ exports.addCodeArg = addCodeArg;
2158
+ function optimize(expr) {
2159
+ let i = 1;
2160
+ while (i < expr.length - 1) {
2161
+ if (expr[i] === plus) {
2162
+ const res = mergeExprItems(expr[i - 1], expr[i + 1]);
2163
+ if (res !== void 0) {
2164
+ expr.splice(i - 1, 3, res);
2165
+ continue;
2166
+ }
2167
+ expr[i++] = "+";
2168
+ }
2169
+ i++;
2170
+ }
2171
+ }
2172
+ function mergeExprItems(a, b) {
2173
+ if (b === "\"\"") return a;
2174
+ if (a === "\"\"") return b;
2175
+ if (typeof a == "string") {
2176
+ if (b instanceof Name || a[a.length - 1] !== "\"") return;
2177
+ if (typeof b != "string") return `${a.slice(0, -1)}${b}"`;
2178
+ if (b[0] === "\"") return a.slice(0, -1) + b.slice(1);
2179
+ return;
2180
+ }
2181
+ if (typeof b == "string" && b[0] === "\"" && !(a instanceof Name)) return `"${a}${b.slice(1)}`;
2182
+ }
2183
+ function strConcat(c1, c2) {
2184
+ return c2.emptyStr() ? c1 : c1.emptyStr() ? c2 : str`${c1}${c2}`;
2185
+ }
2186
+ exports.strConcat = strConcat;
2187
+ function interpolate(x) {
2188
+ return typeof x == "number" || typeof x == "boolean" || x === null ? x : safeStringify(Array.isArray(x) ? x.join(",") : x);
2189
+ }
2190
+ function stringify(x) {
2191
+ return new _Code(safeStringify(x));
2192
+ }
2193
+ exports.stringify = stringify;
2194
+ function safeStringify(x) {
2195
+ return JSON.stringify(x).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
2196
+ }
2197
+ exports.safeStringify = safeStringify;
2198
+ function getProperty(key) {
2199
+ return typeof key == "string" && exports.IDENTIFIER.test(key) ? new _Code(`.${key}`) : _`[${key}]`;
2200
+ }
2201
+ exports.getProperty = getProperty;
2202
+ function getEsmExportName(key) {
2203
+ if (typeof key == "string" && exports.IDENTIFIER.test(key)) return new _Code(`${key}`);
2204
+ throw new Error(`CodeGen: invalid export name: ${key}, use explicit $id name mapping`);
2205
+ }
2206
+ exports.getEsmExportName = getEsmExportName;
2207
+ function regexpCode(rx) {
2208
+ return new _Code(rx.toString());
2209
+ }
2210
+ exports.regexpCode = regexpCode;
2211
+ }));
2212
+ //#endregion
2213
+ //#region ../../node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/scope.js
2214
+ var require_scope = /* @__PURE__ */ __commonJSMin(((exports) => {
2215
+ Object.defineProperty(exports, "__esModule", { value: true });
2216
+ exports.ValueScope = exports.ValueScopeName = exports.Scope = exports.varKinds = exports.UsedValueState = void 0;
2217
+ var code_1 = require_code$1();
2218
+ var ValueError = class extends Error {
2219
+ constructor(name) {
2220
+ super(`CodeGen: "code" for ${name} not defined`);
2221
+ this.value = name.value;
2222
+ }
2223
+ };
2224
+ var UsedValueState;
2225
+ (function(UsedValueState) {
2226
+ UsedValueState[UsedValueState["Started"] = 0] = "Started";
2227
+ UsedValueState[UsedValueState["Completed"] = 1] = "Completed";
2228
+ })(UsedValueState || (exports.UsedValueState = UsedValueState = {}));
2229
+ exports.varKinds = {
2230
+ const: new code_1.Name("const"),
2231
+ let: new code_1.Name("let"),
2232
+ var: new code_1.Name("var")
2233
+ };
2234
+ var Scope = class {
2235
+ constructor({ prefixes, parent } = {}) {
2236
+ this._names = {};
2237
+ this._prefixes = prefixes;
2238
+ this._parent = parent;
2239
+ }
2240
+ toName(nameOrPrefix) {
2241
+ return nameOrPrefix instanceof code_1.Name ? nameOrPrefix : this.name(nameOrPrefix);
2242
+ }
2243
+ name(prefix) {
2244
+ return new code_1.Name(this._newName(prefix));
2245
+ }
2246
+ _newName(prefix) {
2247
+ const ng = this._names[prefix] || this._nameGroup(prefix);
2248
+ return `${prefix}${ng.index++}`;
2249
+ }
2250
+ _nameGroup(prefix) {
2251
+ var _a, _b;
2252
+ if (((_b = (_a = this._parent) === null || _a === void 0 ? void 0 : _a._prefixes) === null || _b === void 0 ? void 0 : _b.has(prefix)) || this._prefixes && !this._prefixes.has(prefix)) throw new Error(`CodeGen: prefix "${prefix}" is not allowed in this scope`);
2253
+ return this._names[prefix] = {
2254
+ prefix,
2255
+ index: 0
2256
+ };
2257
+ }
2258
+ };
2259
+ exports.Scope = Scope;
2260
+ var ValueScopeName = class extends code_1.Name {
2261
+ constructor(prefix, nameStr) {
2262
+ super(nameStr);
2263
+ this.prefix = prefix;
2264
+ }
2265
+ setValue(value, { property, itemIndex }) {
2266
+ this.value = value;
2267
+ this.scopePath = (0, code_1._)`.${new code_1.Name(property)}[${itemIndex}]`;
2268
+ }
2269
+ };
2270
+ exports.ValueScopeName = ValueScopeName;
2271
+ var line = (0, code_1._)`\n`;
2272
+ var ValueScope = class extends Scope {
2273
+ constructor(opts) {
2274
+ super(opts);
2275
+ this._values = {};
2276
+ this._scope = opts.scope;
2277
+ this.opts = {
2278
+ ...opts,
2279
+ _n: opts.lines ? line : code_1.nil
2280
+ };
2281
+ }
2282
+ get() {
2283
+ return this._scope;
2284
+ }
2285
+ name(prefix) {
2286
+ return new ValueScopeName(prefix, this._newName(prefix));
1991
2287
  }
1992
2288
  value(nameOrPrefix, value) {
1993
2289
  var _a;
@@ -9496,531 +9792,247 @@ var jsonScalars = [
9496
9792
  {
9497
9793
  identify: (value) => typeof value === "number",
9498
9794
  default: true,
9499
- tag: "tag:yaml.org,2002:float",
9500
- test: /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,
9501
- resolve: (str) => parseFloat(str),
9502
- stringify: stringifyJSON
9503
- }
9504
- ];
9505
- [map, seq].concat(jsonScalars, {
9506
- default: true,
9507
- tag: "",
9508
- test: /^/,
9509
- resolve(str, onError) {
9510
- onError(`Unresolved plain scalar ${JSON.stringify(str)}`);
9511
- return str;
9512
- }
9513
- });
9514
- //#endregion
9515
- //#region ../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js
9516
- function createPairs(schema, iterable, ctx) {
9517
- const { replacer } = ctx;
9518
- const pairs = new YAMLSeq(schema);
9519
- pairs.tag = "tag:yaml.org,2002:pairs";
9520
- let i = 0;
9521
- if (iterable && Symbol.iterator in Object(iterable)) for (let it of iterable) {
9522
- if (typeof replacer === "function") it = replacer.call(iterable, String(i++), it);
9523
- let key, value;
9524
- if (Array.isArray(it)) if (it.length === 2) {
9525
- key = it[0];
9526
- value = it[1];
9527
- } else throw new TypeError(`Expected [key, value] tuple: ${it}`);
9528
- else if (it && it instanceof Object) {
9529
- const keys = Object.keys(it);
9530
- if (keys.length === 1) {
9531
- key = keys[0];
9532
- value = it[key];
9533
- } else throw new TypeError(`Expected tuple with one key, not ${keys.length} keys`);
9534
- } else key = it;
9535
- pairs.items.push(createPair(key, value, ctx));
9536
- }
9537
- return pairs;
9538
- }
9539
- //#endregion
9540
- //#region ../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/omap.js
9541
- var YAMLOMap = class YAMLOMap extends YAMLSeq {
9542
- constructor() {
9543
- super();
9544
- this.add = YAMLMap.prototype.add.bind(this);
9545
- this.delete = YAMLMap.prototype.delete.bind(this);
9546
- this.get = YAMLMap.prototype.get.bind(this);
9547
- this.has = YAMLMap.prototype.has.bind(this);
9548
- this.set = YAMLMap.prototype.set.bind(this);
9549
- this.tag = YAMLOMap.tag;
9550
- }
9551
- /**
9552
- * If `ctx` is given, the return type is actually `Map<unknown, unknown>`,
9553
- * but TypeScript won't allow widening the signature of a child method.
9554
- */
9555
- toJSON(_, ctx) {
9556
- if (!ctx) return super.toJSON(_);
9557
- const map = /* @__PURE__ */ new Map();
9558
- if (ctx?.onCreate) ctx.onCreate(map);
9559
- for (const pair of this.items) {
9560
- let key, value;
9561
- if (isPair(pair)) {
9562
- key = toJS(pair.key, "", ctx);
9563
- value = toJS(pair.value, key, ctx);
9564
- } else key = toJS(pair, "", ctx);
9565
- if (map.has(key)) throw new Error("Ordered maps must not include duplicate keys");
9566
- map.set(key, value);
9567
- }
9568
- return map;
9569
- }
9570
- static from(schema, iterable, ctx) {
9571
- const pairs = createPairs(schema, iterable, ctx);
9572
- const omap = new this();
9573
- omap.items = pairs.items;
9574
- return omap;
9575
- }
9576
- };
9577
- YAMLOMap.tag = "tag:yaml.org,2002:omap";
9578
- //#endregion
9579
- //#region ../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/set.js
9580
- var YAMLSet = class YAMLSet extends YAMLMap {
9581
- constructor(schema) {
9582
- super(schema);
9583
- this.tag = YAMLSet.tag;
9584
- }
9585
- add(key) {
9586
- let pair;
9587
- if (isPair(key)) pair = key;
9588
- else if (key && typeof key === "object" && "key" in key && "value" in key && key.value === null) pair = new Pair(key.key, null);
9589
- else pair = new Pair(key, null);
9590
- if (!findPair(this.items, pair.key)) this.items.push(pair);
9591
- }
9592
- /**
9593
- * If `keepPair` is `true`, returns the Pair matching `key`.
9594
- * Otherwise, returns the value of that Pair's key.
9595
- */
9596
- get(key, keepPair) {
9597
- const pair = findPair(this.items, key);
9598
- return !keepPair && isPair(pair) ? isScalar(pair.key) ? pair.key.value : pair.key : pair;
9599
- }
9600
- set(key, value) {
9601
- if (typeof value !== "boolean") throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof value}`);
9602
- const prev = findPair(this.items, key);
9603
- if (prev && !value) this.items.splice(this.items.indexOf(prev), 1);
9604
- else if (!prev && value) this.items.push(new Pair(key));
9605
- }
9606
- toJSON(_, ctx) {
9607
- return super.toJSON(_, ctx, Set);
9608
- }
9609
- toString(ctx, onComment, onChompKeep) {
9610
- if (!ctx) return JSON.stringify(this);
9611
- if (this.hasAllNullValues(true)) return super.toString(Object.assign({}, ctx, { allNullValues: true }), onComment, onChompKeep);
9612
- else throw new Error("Set items must all have null values");
9613
- }
9614
- static from(schema, iterable, ctx) {
9615
- const { replacer } = ctx;
9616
- const set = new this(schema);
9617
- if (iterable && Symbol.iterator in Object(iterable)) for (let value of iterable) {
9618
- if (typeof replacer === "function") value = replacer.call(iterable, value, value);
9619
- set.items.push(createPair(value, null, ctx));
9620
- }
9621
- return set;
9622
- }
9623
- };
9624
- YAMLSet.tag = "tag:yaml.org,2002:set";
9625
- //#endregion
9626
- //#region ../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/parse/cst-visit.js
9627
- var BREAK = Symbol("break visit");
9628
- var SKIP = Symbol("skip children");
9629
- var REMOVE = Symbol("remove item");
9630
- /**
9631
- * Apply a visitor to a CST document or item.
9632
- *
9633
- * Walks through the tree (depth-first) starting from the root, calling a
9634
- * `visitor` function with two arguments when entering each item:
9635
- * - `item`: The current item, which included the following members:
9636
- * - `start: SourceToken[]` – Source tokens before the key or value,
9637
- * possibly including its anchor or tag.
9638
- * - `key?: Token | null` – Set for pair values. May then be `null`, if
9639
- * the key before the `:` separator is empty.
9640
- * - `sep?: SourceToken[]` – Source tokens between the key and the value,
9641
- * which should include the `:` map value indicator if `value` is set.
9642
- * - `value?: Token` – The value of a sequence item, or of a map pair.
9643
- * - `path`: The steps from the root to the current node, as an array of
9644
- * `['key' | 'value', number]` tuples.
9645
- *
9646
- * The return value of the visitor may be used to control the traversal:
9647
- * - `undefined` (default): Do nothing and continue
9648
- * - `visit.SKIP`: Do not visit the children of this token, continue with
9649
- * next sibling
9650
- * - `visit.BREAK`: Terminate traversal completely
9651
- * - `visit.REMOVE`: Remove the current item, then continue with the next one
9652
- * - `number`: Set the index of the next step. This is useful especially if
9653
- * the index of the current token has changed.
9654
- * - `function`: Define the next visitor for this item. After the original
9655
- * visitor is called on item entry, next visitors are called after handling
9656
- * a non-empty `key` and when exiting the item.
9657
- */
9658
- function visit(cst, visitor) {
9659
- if ("type" in cst && cst.type === "document") cst = {
9660
- start: cst.start,
9661
- value: cst.value
9662
- };
9663
- _visit(Object.freeze([]), cst, visitor);
9664
- }
9665
- /** Terminate visit traversal completely */
9666
- visit.BREAK = BREAK;
9667
- /** Do not visit the children of the current item */
9668
- visit.SKIP = SKIP;
9669
- /** Remove the current item */
9670
- visit.REMOVE = REMOVE;
9671
- /** Find the item at `path` from `cst` as the root */
9672
- visit.itemAtPath = (cst, path) => {
9673
- let item = cst;
9674
- for (const [field, index] of path) {
9675
- const tok = item?.[field];
9676
- if (tok && "items" in tok) item = tok.items[index];
9677
- else return void 0;
9678
- }
9679
- return item;
9680
- };
9681
- /**
9682
- * Get the immediate parent collection of the item at `path` from `cst` as the root.
9683
- *
9684
- * Throws an error if the collection is not found, which should never happen if the item itself exists.
9685
- */
9686
- visit.parentCollection = (cst, path) => {
9687
- const parent = visit.itemAtPath(cst, path.slice(0, -1));
9688
- const field = path[path.length - 1][0];
9689
- const coll = parent?.[field];
9690
- if (coll && "items" in coll) return coll;
9691
- throw new Error("Parent collection not found");
9692
- };
9693
- function _visit(path, item, visitor) {
9694
- let ctrl = visitor(item, path);
9695
- if (typeof ctrl === "symbol") return ctrl;
9696
- for (const field of ["key", "value"]) {
9697
- const token = item[field];
9698
- if (token && "items" in token) {
9699
- for (let i = 0; i < token.items.length; ++i) {
9700
- const ci = _visit(Object.freeze(path.concat([[field, i]])), token.items[i], visitor);
9701
- if (typeof ci === "number") i = ci - 1;
9702
- else if (ci === BREAK) return BREAK;
9703
- else if (ci === REMOVE) {
9704
- token.items.splice(i, 1);
9705
- i -= 1;
9706
- }
9707
- }
9708
- if (typeof ctrl === "function" && field === "key") ctrl = ctrl(item, path);
9709
- }
9795
+ tag: "tag:yaml.org,2002:float",
9796
+ test: /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,
9797
+ resolve: (str) => parseFloat(str),
9798
+ stringify: stringifyJSON
9710
9799
  }
9711
- return typeof ctrl === "function" ? ctrl(item, path) : ctrl;
9712
- }
9800
+ ];
9801
+ [map, seq].concat(jsonScalars, {
9802
+ default: true,
9803
+ tag: "",
9804
+ test: /^/,
9805
+ resolve(str, onError) {
9806
+ onError(`Unresolved plain scalar ${JSON.stringify(str)}`);
9807
+ return str;
9808
+ }
9809
+ });
9713
9810
  //#endregion
9714
- //#region ../compiler/dist/src/yaml/diagnostics.js
9715
- function getLocationInYamlScript(file, path, kind = "value") {
9716
- const node = findYamlNode(file, path, kind);
9717
- return {
9718
- file: file.file,
9719
- pos: node?.range?.[0] ?? 0,
9720
- end: node?.range?.[1] ?? 0
9721
- };
9722
- }
9723
- function findYamlNode(file, path, kind = "value") {
9724
- let current = file.doc.contents;
9725
- for (let i = 0; i < path.length; i++) {
9726
- const key = path[i];
9727
- const isLast = i === path.length - 1;
9728
- if (isScalar(current)) return current;
9729
- else if (isCollection(current)) if (isLast) if (kind === "value" || !isMap(current)) if (Array.isArray(current.items) && current.items.every((item) => isScalar(item))) return current.items.find((m) => m.source && m.source === key);
9730
- else return current.get(key, true);
9731
- else {
9732
- const pair = findPair(current.items, key);
9733
- if (kind === "key") return pair?.key;
9734
- else return pair;
9735
- }
9736
- else current = current.get(key, true);
9737
- else continue;
9811
+ //#region ../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js
9812
+ function createPairs(schema, iterable, ctx) {
9813
+ const { replacer } = ctx;
9814
+ const pairs = new YAMLSeq(schema);
9815
+ pairs.tag = "tag:yaml.org,2002:pairs";
9816
+ let i = 0;
9817
+ if (iterable && Symbol.iterator in Object(iterable)) for (let it of iterable) {
9818
+ if (typeof replacer === "function") it = replacer.call(iterable, String(i++), it);
9819
+ let key, value;
9820
+ if (Array.isArray(it)) if (it.length === 2) {
9821
+ key = it[0];
9822
+ value = it[1];
9823
+ } else throw new TypeError(`Expected [key, value] tuple: ${it}`);
9824
+ else if (it && it instanceof Object) {
9825
+ const keys = Object.keys(it);
9826
+ if (keys.length === 1) {
9827
+ key = keys[0];
9828
+ value = it[key];
9829
+ } else throw new TypeError(`Expected tuple with one key, not ${keys.length} keys`);
9830
+ } else key = it;
9831
+ pairs.items.push(createPair(key, value, ctx));
9738
9832
  }
9739
- return current ?? void 0;
9833
+ return pairs;
9740
9834
  }
9741
9835
  //#endregion
9742
- //#region ../compiler/dist/src/core/source-file.js
9743
- function createSourceFile(text, path) {
9744
- let lineStarts = void 0;
9745
- return {
9746
- text,
9747
- path,
9748
- getLineStarts,
9749
- getLineAndCharacterOfPosition
9750
- };
9751
- function getLineStarts() {
9752
- return lineStarts = lineStarts ?? scanLineStarts(text);
9753
- }
9754
- function getLineAndCharacterOfPosition(position) {
9755
- const starts = getLineStarts();
9756
- let line = binarySearch(starts, position);
9757
- if (line < 0) line = ~line - 1;
9758
- return {
9759
- line,
9760
- character: position - starts[line]
9761
- };
9836
+ //#region ../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/omap.js
9837
+ var YAMLOMap = class YAMLOMap extends YAMLSeq {
9838
+ constructor() {
9839
+ super();
9840
+ this.add = YAMLMap.prototype.add.bind(this);
9841
+ this.delete = YAMLMap.prototype.delete.bind(this);
9842
+ this.get = YAMLMap.prototype.get.bind(this);
9843
+ this.has = YAMLMap.prototype.has.bind(this);
9844
+ this.set = YAMLMap.prototype.set.bind(this);
9845
+ this.tag = YAMLOMap.tag;
9762
9846
  }
9763
- }
9764
- function scanLineStarts(text) {
9765
- const starts = [];
9766
- let start = 0;
9767
- let pos = 0;
9768
- while (pos < text.length) {
9769
- const ch = text.charCodeAt(pos);
9770
- pos++;
9771
- switch (ch) {
9772
- case 13: if (text.charCodeAt(pos) === 10) pos++;
9773
- case 10:
9774
- starts.push(start);
9775
- start = pos;
9776
- break;
9847
+ /**
9848
+ * If `ctx` is given, the return type is actually `Map<unknown, unknown>`,
9849
+ * but TypeScript won't allow widening the signature of a child method.
9850
+ */
9851
+ toJSON(_, ctx) {
9852
+ if (!ctx) return super.toJSON(_);
9853
+ const map = /* @__PURE__ */ new Map();
9854
+ if (ctx?.onCreate) ctx.onCreate(map);
9855
+ for (const pair of this.items) {
9856
+ let key, value;
9857
+ if (isPair(pair)) {
9858
+ key = toJS(pair.key, "", ctx);
9859
+ value = toJS(pair.value, key, ctx);
9860
+ } else key = toJS(pair, "", ctx);
9861
+ if (map.has(key)) throw new Error("Ordered maps must not include duplicate keys");
9862
+ map.set(key, value);
9777
9863
  }
9864
+ return map;
9778
9865
  }
9779
- starts.push(start);
9780
- return starts;
9781
- }
9782
- /**
9783
- * Search sorted array of numbers for the given value. If found, return index
9784
- * in array where value was found. If not found, return a negative number that
9785
- * is the bitwise complement of the index where value would need to be inserted
9786
- * to keep the array sorted.
9787
- */
9788
- function binarySearch(array, value) {
9789
- let low = 0;
9790
- let high = array.length - 1;
9791
- while (low <= high) {
9792
- const middle = low + (high - low >> 1);
9793
- const v = array[middle];
9794
- if (v < value) low = middle + 1;
9795
- else if (v > value) high = middle - 1;
9796
- else return middle;
9866
+ static from(schema, iterable, ctx) {
9867
+ const pairs = createPairs(schema, iterable, ctx);
9868
+ const omap = new this();
9869
+ omap.items = pairs.items;
9870
+ return omap;
9871
+ }
9872
+ };
9873
+ YAMLOMap.tag = "tag:yaml.org,2002:omap";
9874
+ //#endregion
9875
+ //#region ../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/set.js
9876
+ var YAMLSet = class YAMLSet extends YAMLMap {
9877
+ constructor(schema) {
9878
+ super(schema);
9879
+ this.tag = YAMLSet.tag;
9880
+ }
9881
+ add(key) {
9882
+ let pair;
9883
+ if (isPair(key)) pair = key;
9884
+ else if (key && typeof key === "object" && "key" in key && "value" in key && key.value === null) pair = new Pair(key.key, null);
9885
+ else pair = new Pair(key, null);
9886
+ if (!findPair(this.items, pair.key)) this.items.push(pair);
9797
9887
  }
9798
- return ~low;
9799
- }
9800
- //#endregion
9801
- //#region ../compiler/dist/src/core/types.js
9802
- var ResolutionResultFlags;
9803
- (function(ResolutionResultFlags) {
9804
- ResolutionResultFlags[ResolutionResultFlags["None"] = 0] = "None";
9805
- ResolutionResultFlags[ResolutionResultFlags["Resolved"] = 2] = "Resolved";
9806
- ResolutionResultFlags[ResolutionResultFlags["Unknown"] = 4] = "Unknown";
9807
- ResolutionResultFlags[ResolutionResultFlags["Ambiguous"] = 8] = "Ambiguous";
9808
- ResolutionResultFlags[ResolutionResultFlags["NotFound"] = 16] = "NotFound";
9809
- ResolutionResultFlags[ResolutionResultFlags["ResolutionFailed"] = 28] = "ResolutionFailed";
9810
- })(ResolutionResultFlags || (ResolutionResultFlags = {}));
9811
- /**
9812
- * AST types
9813
- */
9814
- var SyntaxKind;
9815
- (function(SyntaxKind) {
9816
- SyntaxKind[SyntaxKind["TypeSpecScript"] = 0] = "TypeSpecScript";
9817
- SyntaxKind[SyntaxKind["JsSourceFile"] = 1] = "JsSourceFile";
9818
- SyntaxKind[SyntaxKind["ImportStatement"] = 2] = "ImportStatement";
9819
- SyntaxKind[SyntaxKind["Identifier"] = 3] = "Identifier";
9820
- SyntaxKind[SyntaxKind["AugmentDecoratorStatement"] = 4] = "AugmentDecoratorStatement";
9821
- SyntaxKind[SyntaxKind["DecoratorExpression"] = 5] = "DecoratorExpression";
9822
- SyntaxKind[SyntaxKind["DirectiveExpression"] = 6] = "DirectiveExpression";
9823
- SyntaxKind[SyntaxKind["MemberExpression"] = 7] = "MemberExpression";
9824
- SyntaxKind[SyntaxKind["NamespaceStatement"] = 8] = "NamespaceStatement";
9825
- SyntaxKind[SyntaxKind["UsingStatement"] = 9] = "UsingStatement";
9826
- SyntaxKind[SyntaxKind["OperationStatement"] = 10] = "OperationStatement";
9827
- SyntaxKind[SyntaxKind["OperationSignatureDeclaration"] = 11] = "OperationSignatureDeclaration";
9828
- SyntaxKind[SyntaxKind["OperationSignatureReference"] = 12] = "OperationSignatureReference";
9829
- SyntaxKind[SyntaxKind["ModelStatement"] = 13] = "ModelStatement";
9830
- SyntaxKind[SyntaxKind["ModelExpression"] = 14] = "ModelExpression";
9831
- SyntaxKind[SyntaxKind["ModelProperty"] = 15] = "ModelProperty";
9832
- SyntaxKind[SyntaxKind["ModelSpreadProperty"] = 16] = "ModelSpreadProperty";
9833
- SyntaxKind[SyntaxKind["ScalarStatement"] = 17] = "ScalarStatement";
9834
- SyntaxKind[SyntaxKind["InterfaceStatement"] = 18] = "InterfaceStatement";
9835
- SyntaxKind[SyntaxKind["UnionStatement"] = 19] = "UnionStatement";
9836
- SyntaxKind[SyntaxKind["UnionVariant"] = 20] = "UnionVariant";
9837
- SyntaxKind[SyntaxKind["EnumStatement"] = 21] = "EnumStatement";
9838
- SyntaxKind[SyntaxKind["EnumMember"] = 22] = "EnumMember";
9839
- SyntaxKind[SyntaxKind["EnumSpreadMember"] = 23] = "EnumSpreadMember";
9840
- SyntaxKind[SyntaxKind["AliasStatement"] = 24] = "AliasStatement";
9841
- SyntaxKind[SyntaxKind["DecoratorDeclarationStatement"] = 25] = "DecoratorDeclarationStatement";
9842
- SyntaxKind[SyntaxKind["FunctionDeclarationStatement"] = 26] = "FunctionDeclarationStatement";
9843
- SyntaxKind[SyntaxKind["FunctionParameter"] = 27] = "FunctionParameter";
9844
- SyntaxKind[SyntaxKind["UnionExpression"] = 28] = "UnionExpression";
9845
- SyntaxKind[SyntaxKind["IntersectionExpression"] = 29] = "IntersectionExpression";
9846
- SyntaxKind[SyntaxKind["TupleExpression"] = 30] = "TupleExpression";
9847
- SyntaxKind[SyntaxKind["ArrayExpression"] = 31] = "ArrayExpression";
9848
- SyntaxKind[SyntaxKind["StringLiteral"] = 32] = "StringLiteral";
9849
- SyntaxKind[SyntaxKind["NumericLiteral"] = 33] = "NumericLiteral";
9850
- SyntaxKind[SyntaxKind["BooleanLiteral"] = 34] = "BooleanLiteral";
9851
- SyntaxKind[SyntaxKind["StringTemplateExpression"] = 35] = "StringTemplateExpression";
9852
- SyntaxKind[SyntaxKind["StringTemplateHead"] = 36] = "StringTemplateHead";
9853
- SyntaxKind[SyntaxKind["StringTemplateMiddle"] = 37] = "StringTemplateMiddle";
9854
- SyntaxKind[SyntaxKind["StringTemplateTail"] = 38] = "StringTemplateTail";
9855
- SyntaxKind[SyntaxKind["StringTemplateSpan"] = 39] = "StringTemplateSpan";
9856
- SyntaxKind[SyntaxKind["ExternKeyword"] = 40] = "ExternKeyword";
9857
- SyntaxKind[SyntaxKind["VoidKeyword"] = 41] = "VoidKeyword";
9858
- SyntaxKind[SyntaxKind["NeverKeyword"] = 42] = "NeverKeyword";
9859
- SyntaxKind[SyntaxKind["UnknownKeyword"] = 43] = "UnknownKeyword";
9860
- SyntaxKind[SyntaxKind["ValueOfExpression"] = 44] = "ValueOfExpression";
9861
- SyntaxKind[SyntaxKind["TypeReference"] = 45] = "TypeReference";
9862
- SyntaxKind[SyntaxKind["TemplateParameterDeclaration"] = 46] = "TemplateParameterDeclaration";
9863
- SyntaxKind[SyntaxKind["EmptyStatement"] = 47] = "EmptyStatement";
9864
- SyntaxKind[SyntaxKind["InvalidStatement"] = 48] = "InvalidStatement";
9865
- SyntaxKind[SyntaxKind["LineComment"] = 49] = "LineComment";
9866
- SyntaxKind[SyntaxKind["BlockComment"] = 50] = "BlockComment";
9867
- SyntaxKind[SyntaxKind["Doc"] = 51] = "Doc";
9868
- SyntaxKind[SyntaxKind["DocText"] = 52] = "DocText";
9869
- SyntaxKind[SyntaxKind["DocParamTag"] = 53] = "DocParamTag";
9870
- SyntaxKind[SyntaxKind["DocPropTag"] = 54] = "DocPropTag";
9871
- SyntaxKind[SyntaxKind["DocReturnsTag"] = 55] = "DocReturnsTag";
9872
- SyntaxKind[SyntaxKind["DocErrorsTag"] = 56] = "DocErrorsTag";
9873
- SyntaxKind[SyntaxKind["DocTemplateTag"] = 57] = "DocTemplateTag";
9874
- SyntaxKind[SyntaxKind["DocUnknownTag"] = 58] = "DocUnknownTag";
9875
- SyntaxKind[SyntaxKind["Return"] = 59] = "Return";
9876
- SyntaxKind[SyntaxKind["JsNamespaceDeclaration"] = 60] = "JsNamespaceDeclaration";
9877
- SyntaxKind[SyntaxKind["TemplateArgument"] = 61] = "TemplateArgument";
9878
- SyntaxKind[SyntaxKind["TypeOfExpression"] = 62] = "TypeOfExpression";
9879
- SyntaxKind[SyntaxKind["ObjectLiteral"] = 63] = "ObjectLiteral";
9880
- SyntaxKind[SyntaxKind["ObjectLiteralProperty"] = 64] = "ObjectLiteralProperty";
9881
- SyntaxKind[SyntaxKind["ObjectLiteralSpreadProperty"] = 65] = "ObjectLiteralSpreadProperty";
9882
- SyntaxKind[SyntaxKind["ArrayLiteral"] = 66] = "ArrayLiteral";
9883
- SyntaxKind[SyntaxKind["ConstStatement"] = 67] = "ConstStatement";
9884
- SyntaxKind[SyntaxKind["CallExpression"] = 68] = "CallExpression";
9885
- SyntaxKind[SyntaxKind["ScalarConstructor"] = 69] = "ScalarConstructor";
9886
- SyntaxKind[SyntaxKind["InternalKeyword"] = 70] = "InternalKeyword";
9887
- SyntaxKind[SyntaxKind["FunctionTypeExpression"] = 71] = "FunctionTypeExpression";
9888
- })(SyntaxKind || (SyntaxKind = {}));
9889
- var IdentifierKind;
9890
- (function(IdentifierKind) {
9891
- IdentifierKind[IdentifierKind["TypeReference"] = 0] = "TypeReference";
9892
- IdentifierKind[IdentifierKind["TemplateArgument"] = 1] = "TemplateArgument";
9893
- IdentifierKind[IdentifierKind["Decorator"] = 2] = "Decorator";
9894
- IdentifierKind[IdentifierKind["Function"] = 3] = "Function";
9895
- IdentifierKind[IdentifierKind["Using"] = 4] = "Using";
9896
- IdentifierKind[IdentifierKind["Declaration"] = 5] = "Declaration";
9897
- IdentifierKind[IdentifierKind["ModelExpressionProperty"] = 6] = "ModelExpressionProperty";
9898
- IdentifierKind[IdentifierKind["ModelStatementProperty"] = 7] = "ModelStatementProperty";
9899
- IdentifierKind[IdentifierKind["ObjectLiteralProperty"] = 8] = "ObjectLiteralProperty";
9900
- IdentifierKind[IdentifierKind["Other"] = 9] = "Other";
9901
- })(IdentifierKind || (IdentifierKind = {}));
9902
- /** Used to explicitly specify that a diagnostic has no target. */
9903
- var NoTarget = Symbol.for("NoTarget");
9904
- var ListenerFlow;
9905
- (function(ListenerFlow) {
9906
9888
  /**
9907
- * Do not navigate any containing or referenced type.
9889
+ * If `keepPair` is `true`, returns the Pair matching `key`.
9890
+ * Otherwise, returns the value of that Pair's key.
9908
9891
  */
9909
- ListenerFlow[ListenerFlow["NoRecursion"] = 1] = "NoRecursion";
9910
- })(ListenerFlow || (ListenerFlow = {}));
9892
+ get(key, keepPair) {
9893
+ const pair = findPair(this.items, key);
9894
+ return !keepPair && isPair(pair) ? isScalar(pair.key) ? pair.key.value : pair.key : pair;
9895
+ }
9896
+ set(key, value) {
9897
+ if (typeof value !== "boolean") throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof value}`);
9898
+ const prev = findPair(this.items, key);
9899
+ if (prev && !value) this.items.splice(this.items.indexOf(prev), 1);
9900
+ else if (!prev && value) this.items.push(new Pair(key));
9901
+ }
9902
+ toJSON(_, ctx) {
9903
+ return super.toJSON(_, ctx, Set);
9904
+ }
9905
+ toString(ctx, onComment, onChompKeep) {
9906
+ if (!ctx) return JSON.stringify(this);
9907
+ if (this.hasAllNullValues(true)) return super.toString(Object.assign({}, ctx, { allNullValues: true }), onComment, onChompKeep);
9908
+ else throw new Error("Set items must all have null values");
9909
+ }
9910
+ static from(schema, iterable, ctx) {
9911
+ const { replacer } = ctx;
9912
+ const set = new this(schema);
9913
+ if (iterable && Symbol.iterator in Object(iterable)) for (let value of iterable) {
9914
+ if (typeof replacer === "function") value = replacer.call(iterable, value, value);
9915
+ set.items.push(createPair(value, null, ctx));
9916
+ }
9917
+ return set;
9918
+ }
9919
+ };
9920
+ YAMLSet.tag = "tag:yaml.org,2002:set";
9911
9921
  //#endregion
9912
- //#region ../compiler/dist/src/core/diagnostics.js
9922
+ //#region ../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/parse/cst-visit.js
9923
+ var BREAK = Symbol("break visit");
9924
+ var SKIP = Symbol("skip children");
9925
+ var REMOVE = Symbol("remove item");
9913
9926
  /**
9914
- * Find the syntax node for a TypeSpec diagnostic target.
9927
+ * Apply a visitor to a CST document or item.
9915
9928
  *
9916
- * This function extracts the AST node from various types of diagnostic targets:
9917
- * - For template instance targets: returns the node of the template declaration
9918
- * - For symbols: returns the first declaration node (or symbol source for using symbols)
9919
- * - For AST nodes: returns the node itself
9920
- * - For types: returns the node associated with the type
9929
+ * Walks through the tree (depth-first) starting from the root, calling a
9930
+ * `visitor` function with two arguments when entering each item:
9931
+ * - `item`: The current item, which included the following members:
9932
+ * - `start: SourceToken[]` Source tokens before the key or value,
9933
+ * possibly including its anchor or tag.
9934
+ * - `key?: Token | null` – Set for pair values. May then be `null`, if
9935
+ * the key before the `:` separator is empty.
9936
+ * - `sep?: SourceToken[]` – Source tokens between the key and the value,
9937
+ * which should include the `:` map value indicator if `value` is set.
9938
+ * - `value?: Token` – The value of a sequence item, or of a map pair.
9939
+ * - `path`: The steps from the root to the current node, as an array of
9940
+ * `['key' | 'value', number]` tuples.
9921
9941
  *
9922
- * @param target The diagnostic target to extract a node from. Can be a template instance,
9923
- * symbol, AST node, or type.
9924
- * @returns The AST node associated with the target, or undefined if the target is a type
9925
- * or symbol that doesn't have an associated node.
9942
+ * The return value of the visitor may be used to control the traversal:
9943
+ * - `undefined` (default): Do nothing and continue
9944
+ * - `visit.SKIP`: Do not visit the children of this token, continue with
9945
+ * next sibling
9946
+ * - `visit.BREAK`: Terminate traversal completely
9947
+ * - `visit.REMOVE`: Remove the current item, then continue with the next one
9948
+ * - `number`: Set the index of the next step. This is useful especially if
9949
+ * the index of the current token has changed.
9950
+ * - `function`: Define the next visitor for this item. After the original
9951
+ * visitor is called on item entry, next visitors are called after handling
9952
+ * a non-empty `key` and when exiting the item.
9926
9953
  */
9927
- function getNodeForTarget(target) {
9928
- if (!("kind" in target) && !("entityKind" in target)) {
9929
- if (!("declarations" in target)) return target.node;
9930
- if (target.flags & 8192) target = target.symbolSource;
9931
- return target.declarations[0];
9932
- } else if ("kind" in target && typeof target.kind === "number") return target;
9933
- else return target.node;
9934
- }
9935
- function getSourceLocation(target, options = {}) {
9936
- if (target === NoTarget || target === void 0) return;
9937
- if ("file" in target) return target;
9938
- const node = getNodeForTarget(target);
9939
- return node ? getSourceLocationOfNode(node, options) : createSyntheticSourceLocation();
9940
- }
9941
- function createSyntheticSourceLocation(loc = "<unknown location>") {
9942
- return {
9943
- file: createSourceFile("", loc),
9944
- pos: 0,
9945
- end: 0,
9946
- isSynthetic: true
9947
- };
9948
- }
9949
- function getSourceLocationOfNode(node, options) {
9950
- let root = node;
9951
- while (root.parent !== void 0) root = root.parent;
9952
- if (root.kind !== SyntaxKind.TypeSpecScript && root.kind !== SyntaxKind.JsSourceFile) return createSyntheticSourceLocation(node.flags & 8 ? void 0 : "<unknown location - cannot obtain source location of unbound node - file bug at https://github.com/microsoft/typespec>");
9953
- if (options.locateId && "id" in node && node.id !== void 0) node = node.id;
9954
- return {
9955
- file: root.file,
9956
- pos: node.pos,
9957
- end: node.end
9954
+ function visit(cst, visitor) {
9955
+ if ("type" in cst && cst.type === "document") cst = {
9956
+ start: cst.start,
9957
+ value: cst.value
9958
9958
  };
9959
+ _visit(Object.freeze([]), cst, visitor);
9959
9960
  }
9961
+ /** Terminate visit traversal completely */
9962
+ visit.BREAK = BREAK;
9963
+ /** Do not visit the children of the current item */
9964
+ visit.SKIP = SKIP;
9965
+ /** Remove the current item */
9966
+ visit.REMOVE = REMOVE;
9967
+ /** Find the item at `path` from `cst` as the root */
9968
+ visit.itemAtPath = (cst, path) => {
9969
+ let item = cst;
9970
+ for (const [field, index] of path) {
9971
+ const tok = item?.[field];
9972
+ if (tok && "items" in tok) item = tok.items[index];
9973
+ else return void 0;
9974
+ }
9975
+ return item;
9976
+ };
9960
9977
  /**
9961
- * Use this to report bugs in the compiler, and not errors in the source code
9962
- * being compiled.
9963
- *
9964
- * @param condition Throw if this is not true.
9965
- *
9966
- * @param message Error message.
9978
+ * Get the immediate parent collection of the item at `path` from `cst` as the root.
9967
9979
  *
9968
- * @param target Optional location in source code that might give a clue about
9969
- * what got the compiler off track.
9980
+ * Throws an error if the collection is not found, which should never happen if the item itself exists.
9970
9981
  */
9971
- function compilerAssert(condition, message, target) {
9972
- if (condition) return;
9973
- if (target) {
9974
- let location;
9975
- try {
9976
- location = getSourceLocation(target);
9977
- } catch (err) {}
9978
- if (location) {
9979
- const pos = location.file.getLineAndCharacterOfPosition(location.pos);
9980
- const file = location.file.path;
9981
- const line = pos.line + 1;
9982
- const col = pos.character + 1;
9983
- message += `\nOccurred while compiling code in ${file} near line ${line}, column ${col}`;
9982
+ visit.parentCollection = (cst, path) => {
9983
+ const parent = visit.itemAtPath(cst, path.slice(0, -1));
9984
+ const field = path[path.length - 1][0];
9985
+ const coll = parent?.[field];
9986
+ if (coll && "items" in coll) return coll;
9987
+ throw new Error("Parent collection not found");
9988
+ };
9989
+ function _visit(path, item, visitor) {
9990
+ let ctrl = visitor(item, path);
9991
+ if (typeof ctrl === "symbol") return ctrl;
9992
+ for (const field of ["key", "value"]) {
9993
+ const token = item[field];
9994
+ if (token && "items" in token) {
9995
+ for (let i = 0; i < token.items.length; ++i) {
9996
+ const ci = _visit(Object.freeze(path.concat([[field, i]])), token.items[i], visitor);
9997
+ if (typeof ci === "number") i = ci - 1;
9998
+ else if (ci === BREAK) return BREAK;
9999
+ else if (ci === REMOVE) {
10000
+ token.items.splice(i, 1);
10001
+ i -= 1;
10002
+ }
10003
+ }
10004
+ if (typeof ctrl === "function" && field === "key") ctrl = ctrl(item, path);
9984
10005
  }
9985
10006
  }
9986
- throw new Error(message);
10007
+ return typeof ctrl === "function" ? ctrl(item, path) : ctrl;
9987
10008
  }
9988
- /**
9989
- * Create a new instance of the @see DiagnosticCollector.
9990
- */
9991
- function createDiagnosticCollector() {
9992
- const diagnostics = [];
10009
+ //#endregion
10010
+ //#region ../compiler/dist/src/yaml/diagnostics.js
10011
+ function getLocationInYamlScript(file, path, kind = "value") {
10012
+ const node = findYamlNode(file, path, kind);
9993
10013
  return {
9994
- diagnostics,
9995
- add,
9996
- pipe,
9997
- wrap,
9998
- join
10014
+ file: file.file,
10015
+ pos: node?.range?.[0] ?? 0,
10016
+ end: node?.range?.[1] ?? 0
9999
10017
  };
10000
- function add(diagnostic) {
10001
- diagnostics.push(diagnostic);
10002
- }
10003
- function pipe(result) {
10004
- const [value, diags] = result;
10005
- for (const diag of diags) diagnostics.push(diag);
10006
- return value;
10007
- }
10008
- function wrap(value) {
10009
- return [value, diagnostics];
10010
- }
10011
- function join(result) {
10012
- const [value, diags] = result;
10013
- for (const diag of diags) diagnostics.push(diag);
10014
- return [value, diagnostics];
10015
- }
10016
10018
  }
10017
- /**
10018
- * Ignore the diagnostics emitted by the diagnostic accessor pattern and just return the actual result.
10019
- * @param result Accessor pattern tuple result including the actual result and the list of diagnostics.
10020
- * @returns Actual result.
10021
- */
10022
- function ignoreDiagnostics(result) {
10023
- return result[0];
10019
+ function findYamlNode(file, path, kind = "value") {
10020
+ let current = file.doc.contents;
10021
+ for (let i = 0; i < path.length; i++) {
10022
+ const key = path[i];
10023
+ const isLast = i === path.length - 1;
10024
+ if (isScalar(current)) return current;
10025
+ else if (isCollection(current)) if (isLast) if (kind === "value" || !isMap(current)) if (Array.isArray(current.items) && current.items.every((item) => isScalar(item))) return current.items.find((m) => m.source && m.source === key);
10026
+ else return current.get(key, true);
10027
+ else {
10028
+ const pair = findPair(current.items, key);
10029
+ if (kind === "key") return pair?.key;
10030
+ else return pair;
10031
+ }
10032
+ else current = current.get(key, true);
10033
+ else continue;
10034
+ }
10035
+ return current ?? void 0;
10024
10036
  }
10025
10037
  //#endregion
10026
10038
  //#region ../compiler/dist/src/core/schema-validator.js
@@ -10130,6 +10142,11 @@ var TypeSpecConfigJsonSchema = {
10130
10142
  type: "string",
10131
10143
  nullable: true
10132
10144
  },
10145
+ features: {
10146
+ type: "array",
10147
+ nullable: true,
10148
+ items: { type: "string" }
10149
+ },
10133
10150
  "environment-variables": {
10134
10151
  type: "object",
10135
10152
  nullable: true,
@@ -14008,13 +14025,6 @@ function getLifecycleVisibilityEnum(program) {
14008
14025
  return type;
14009
14026
  }
14010
14027
  //#endregion
14011
- //#region ../compiler/dist/src/core/helpers/location-context.js
14012
- function getLocationContext(program, type) {
14013
- const sourceLocation = getSourceLocation(type);
14014
- if (sourceLocation.isSynthetic) return { type: "synthetic" };
14015
- return program.getSourceFileLocationContext(sourceLocation.file);
14016
- }
14017
- //#endregion
14018
14028
  //#region ../compiler/dist/src/utils/custom-key-map.js
14019
14029
  /**
14020
14030
  * This is a map type that allows providing a custom keyer function. The keyer
@@ -21069,7 +21079,7 @@ globalThis[globalLibraryUrlsLoadedSym];
21069
21079
  //#region ../compiler/dist/src/manifest.js
21070
21080
  var manifest;
21071
21081
  try {
21072
- manifest = (await import("../manifest-BNef1S5o.js")).default;
21082
+ manifest = (await import("../manifest-Bu4Jq7Zd.js")).default;
21073
21083
  } catch {
21074
21084
  manifest = (await import(
21075
21085
  /* @vite-ignore */