From 97fbc42928f5c0a201715ed37a894e84fae50ac6 Mon Sep 17 00:00:00 2001 From: RedCMD Date: Thu, 7 Mar 2024 15:15:48 +1300 Subject: [PATCH] Add CallStack #10 --- .vscode/tasks.json | 3 +- README.md | 3 + out/TextMate.js | 141 + out/TreeDataProvider.js | 641 ++++ out/extension.js | 26 +- out/textmate/debug.js | 10 + out/textmate/diffStateStacks.js | 42 + out/textmate/encodedTokenAttributes.js | 103 + .../grammar/basicScopesAttributeProvider.js | 94 + out/textmate/grammar/grammar.js | 727 +++++ out/textmate/grammar/grammarDependencies.js | 240 ++ out/textmate/grammar/index.js | 20 + out/textmate/grammar/tokenizeString.js | 462 +++ out/textmate/json.js | 440 +++ out/textmate/main.js | 114 + out/textmate/matcher.js | 102 + out/textmate/onigLib.js | 12 + out/textmate/parseRawGrammar.js | 28 + out/textmate/plist.js | 455 +++ out/textmate/rawGrammar.js | 5 + out/textmate/registry.js | 76 + out/textmate/rule.js | 722 +++++ out/textmate/theme.js | 485 +++ out/textmate/utils.js | 174 + out/web/extension.js | 2797 +---------------- package-lock.json | 2742 ++++++++++------ package.json | 86 +- src/TextMate.ts | 460 +++ src/TreeDataProvider.ts | 749 +++++ src/extension.ts | 26 + src/extensions.d.ts | 267 ++ src/textmate/debug.ts | 9 + src/textmate/diffStateStacks.ts | 47 + src/textmate/encodedTokenAttributes.ts | 188 ++ .../grammar/basicScopesAttributeProvider.ts | 111 + src/textmate/grammar/grammar.ts | 1110 +++++++ src/textmate/grammar/grammarDependencies.ts | 295 ++ src/textmate/grammar/index.ts | 5 + src/textmate/grammar/tokenizeString.ts | 657 ++++ src/textmate/json.ts | 521 +++ src/textmate/main.ts | 270 ++ src/textmate/matcher.ts | 106 + src/textmate/onigLib.ts | 57 + src/textmate/parseRawGrammar.ts | 29 + src/textmate/plist.ts | 496 +++ src/textmate/rawGrammar.ts | 76 + src/textmate/registry.ts | 102 + src/textmate/rule.ts | 899 ++++++ src/textmate/theme.ts | 605 ++++ src/textmate/utils.ts | 187 ++ tsconfig.json | 3 +- 51 files changed, 14338 insertions(+), 3687 deletions(-) create mode 100644 out/TextMate.js create mode 100644 out/TreeDataProvider.js create mode 100644 out/textmate/debug.js create mode 100644 out/textmate/diffStateStacks.js create mode 100644 out/textmate/encodedTokenAttributes.js create mode 100644 out/textmate/grammar/basicScopesAttributeProvider.js create mode 100644 out/textmate/grammar/grammar.js create mode 100644 out/textmate/grammar/grammarDependencies.js create mode 100644 out/textmate/grammar/index.js create mode 100644 out/textmate/grammar/tokenizeString.js create mode 100644 out/textmate/json.js create mode 100644 out/textmate/main.js create mode 100644 out/textmate/matcher.js create mode 100644 out/textmate/onigLib.js create mode 100644 out/textmate/parseRawGrammar.js create mode 100644 out/textmate/plist.js create mode 100644 out/textmate/rawGrammar.js create mode 100644 out/textmate/registry.js create mode 100644 out/textmate/rule.js create mode 100644 out/textmate/theme.js create mode 100644 out/textmate/utils.js create mode 100644 src/TextMate.ts create mode 100644 src/TreeDataProvider.ts create mode 100644 src/extensions.d.ts create mode 100644 src/textmate/debug.ts create mode 100644 src/textmate/diffStateStacks.ts create mode 100644 src/textmate/encodedTokenAttributes.ts create mode 100644 src/textmate/grammar/basicScopesAttributeProvider.ts create mode 100644 src/textmate/grammar/grammar.ts create mode 100644 src/textmate/grammar/grammarDependencies.ts create mode 100644 src/textmate/grammar/index.ts create mode 100644 src/textmate/grammar/tokenizeString.ts create mode 100644 src/textmate/json.ts create mode 100644 src/textmate/main.ts create mode 100644 src/textmate/matcher.ts create mode 100644 src/textmate/onigLib.ts create mode 100644 src/textmate/parseRawGrammar.ts create mode 100644 src/textmate/plist.ts create mode 100644 src/textmate/rawGrammar.ts create mode 100644 src/textmate/registry.ts create mode 100644 src/textmate/rule.ts create mode 100644 src/textmate/theme.ts create mode 100644 src/textmate/utils.ts diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 2d185d6..7f52114 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -20,7 +20,6 @@ "color": "terminal.ansiMagenta", "id": "console", }, - "hide": true, }, { // Must remove "extensionDependencies" in `package.json` first @@ -45,7 +44,7 @@ "label": "Launch-TextMate-Web-Extension", "type": "npm", "script": "open-in-browser", - "problemMatcher": "$ts-webpack-watch", + "problemMatcher": [], "isBackground": true, "presentation": { "reveal": "never", diff --git a/README.md b/README.md index 16aa0aa..36f2f4e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ # TmLanguage-Syntax-Highlighter Syntax Highlighter for VSCodes JSON TextMate grammars +# NEW! CallStack feature thingy +Feedback welcomed [Github](https://github.com/RedCMD/TmLanguage-Syntax-Highlighter/issues/10) + ## Features * Syntax Highlighting * Basic Intellisense diff --git a/out/TextMate.js b/out/TextMate.js new file mode 100644 index 0000000..1337acf --- /dev/null +++ b/out/TextMate.js @@ -0,0 +1,141 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.tokenizeFile = exports.tokenizeLine = exports.initTextMate = exports.whileRuleId = exports.endRuleId = void 0; +const vscode = require("vscode"); +const vscodeTextmate = require("./textmate/main"); +// import * as vscodeTextmate from "vscode-textmate"; +const vscodeOniguruma = require("vscode-oniguruma"); +const extension_1 = require("./extension"); +exports.endRuleId = -1; +exports.whileRuleId = -2; +async function onigLibInterface() { + return { + createOnigScanner(sources) { + return new vscodeOniguruma.OnigScanner(sources); + }, + createOnigString(str) { + return new vscodeOniguruma.OnigString(str); + } + }; +} +async function loadGrammar(scopeName) { + for (const extension of vscode.extensions.all) { + const packageJSON = extension.packageJSON; + const grammars = packageJSON.contributes?.grammars; + if (grammars) { + for (const grammar of grammars) { + if (grammar.scopeName == scopeName) { + const path = grammar.path; + if (path) { + const uri = vscode.Uri.joinPath(extension.extensionUri, path); + if (uri.scheme != 'untitled') { + const document = await vscode.workspace.openTextDocument(uri); + const rawGrammar = vscodeTextmate.parseRawGrammar(document.getText(), uri.path); + return rawGrammar; + } + } + } + } + } + } + vscode.window.showInformationMessage(`Unknown scopeName: ${scopeName}`); + console.log(`TextMate: Unknown scope name: ${scopeName}`); + return null; +} +let registry; +function initTextMate(context) { + const options = { + onigLib: onigLibInterface(), + loadGrammar: loadGrammar, + }; + // Create a registry that can create a grammar from a scope name. + registry = new vscodeTextmate.Registry(options); +} +exports.initTextMate = initTextMate; +function getScopeName(lang) { + for (const extension of vscode.extensions.all) { + const packageJSON = extension.packageJSON; + const grammars = packageJSON.contributes?.grammars; + if (grammars) { + for (const grammar of grammars) { + if (grammar.language == lang) { + const scopeName = grammar.scopeName; + if (scopeName) { + return scopeName; + } + } + } + } + } + return null; +} +async function tokenizeLine(document, lineNumber) { + const lang = document.languageId; + const scopeName = getScopeName(lang); + const grammar = await registry.loadGrammar(scopeName); + // vscode.window.showInformationMessage(JSON.stringify(grammar)); + // vscode.window.showInformationMessage(JSON.stringify(grammar, stringify)); + // const text = [ + // `function sayHello(name) {`, + // `\treturn "Hello, " + name;`, + // `}` + // ]; + // const text = document.getText(); + let tokenLineResult; + let ruleStack = vscodeTextmate.INITIAL; + for (let i = 0; i <= lineNumber; i++) { + const line = document.lineAt(i).text; + // const line = text[i]; + // vscode.window.showInformationMessage(JSON.stringify(ruleStack)); + // const lineTokens = tokenizeLine(grammar, line, ruleStack); + const lineTokens = grammar.tokenizeLine(line, ruleStack, 15000); + // vscode.window.showInformationMessage(JSON.stringify(lineTokens)); + // console.log(`\nTokenizing line: ${line}`); + // for (let j = 0; j < lineTokens.tokens.length; j++) { + // const token = lineTokens.tokens[j]; + // console.log(` - token from ${token.startIndex} to ${token.endIndex} ` + + // `(${line.substring(token.startIndex, token.endIndex)}) ` + + // `with scopes ${token.scopes.join(', ')}` + // ); + // } + ruleStack = lineTokens.ruleStack; + tokenLineResult = lineTokens; + } + // vscode.window.showInformationMessage(stringifyMaxDepth(grammar._ruleId2desc, 6)); + // @ts-ignore + // vscode.window.showInformationMessage(JSON.stringify((grammar as Grammar)._ruleId2desc, stringify)); + // vscode.window.showInformationMessage(JSON.stringify(ruleStack, stringify)); + return tokenLineResult; +} +exports.tokenizeLine = tokenizeLine; +async function tokenizeFile(document) { + const lang = document.languageId; + const scopeName = getScopeName(lang); + // const grammar = await registry.loadGrammar(scopeName); + const grammar = await registry.loadGrammar(scopeName); + // Very hacky, assigns array so `_tokenizeString()` can add rules to it + grammar.rules = []; + // const tokenLineResults: vscodeTextmate.ITokenizeLineResult[] = []; + let ruleStack = vscodeTextmate.INITIAL; + for (let i = 0; i < document.lineCount; i++) { + const line = document.lineAt(i).text; + const lineTokens = grammar.tokenizeLine(line, ruleStack, 15000); + // tokenLineResults.push( + // { + // tokens: lineTokens.tokens, + // ruleStack: structuredClone(lineTokens.ruleStack), + // stoppedEarly: lineTokens.stoppedEarly, + // } + // ); + // one liner? + grammar.rules.pop(); + grammar.rules.push(undefined); + ruleStack = lineTokens.ruleStack; + } + // vscode.window.showInformationMessage(JSON.stringify(registry, stringify)); + vscode.window.showInformationMessage(JSON.stringify(grammar, extension_1.stringify)); + // vscode.window.showInformationMessage(JSON.stringify(tokenLineResults, stringify)); + // return tokenLineResults; + return grammar; +} +exports.tokenizeFile = tokenizeFile; diff --git a/out/TreeDataProvider.js b/out/TreeDataProvider.js new file mode 100644 index 0000000..017cf98 --- /dev/null +++ b/out/TreeDataProvider.js @@ -0,0 +1,641 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.initCallStackView = exports.TreeDataProvider = void 0; +const vscode = require("vscode"); +// import * as vscodeTextmate from 'vscode-textmate'; +const path = require("path"); +const TextMate_1 = require("./TextMate"); +const extension_1 = require("./extension"); +const TreeSitter_1 = require("./TreeSitter"); +// const ruleList: rule[] = []; +let grammar; +const FileIcon = path.join(__dirname, '..', 'assets', 'TextMate-file-icon.svg'); +const onDidChangeTreeData = new vscode.EventEmitter(); +exports.TreeDataProvider = { + async getChildren(element) { + // vscode.window.showInformationMessage(JSON.stringify("getChildren")); + // vscode.window.showInformationMessage(JSON.stringify(element)); + if (false) { + const elements = []; + if (!element) { + const activeTextEditor = vscode.window.activeTextEditor; + if (!activeTextEditor) { + return; + } + const element = { + line: -1, + document: activeTextEditor.document, + }; + elements.push(element); + return elements; + } + const document = element.document; + const line = element.line; + if (line == -1) { + for (let index = 0; index < document.lineCount; index++) { + const element = { line: index, document: document }; + elements.push(element); + } + return elements; + } + if (element.token) { + return; + } + const tokenLineResult = await (0, TextMate_1.tokenizeLine)(document, line); + vscode.window.showInformationMessage(JSON.stringify(tokenLineResult, extension_1.stringify)); + const tokens = tokenLineResult.tokens; + if (!tokens) { + return; + } + let count = 0; + for (const token of tokens) { + const element = { + line: line, + document: document, + token: token + }; + elements.push(element); + count++; + if (count > 500) { + return elements; + } + } + return elements; + } + if (false) { + const elements = []; + if (!element) { + const activeTextEditor = vscode.window.activeTextEditor; + if (!activeTextEditor) { + return; + } + const childElement = { + id: -1, + document: activeTextEditor.document, + }; + elements.push(childElement); + return elements; + } + const document = element.document; + if (element.id == -1) { + const tokenLineResults = await (0, TextMate_1.tokenizeFile)(document); + let rootParent = true; + let index = 0; + // for (const tokenLine of tokenLineResults) { + // let parentRule = tokenLine.ruleStack; + // index++; + // const tempRules: rule[] = []; + // while (parentRule) { + // const _enterPos = parentRule._enterPos; + // if (_enterPos != -1) { + // const rule = { + // scopeName: parentRule.nameScopesList.scopePath.scopeName, + // ruleId: parentRule.ruleId, + // depth: parentRule.depth, + // _enterPos: _enterPos, + // line: index, + // }; + // tempRules.unshift(rule); + // } else if (rootParent) { + // const rule = { + // scopeName: parentRule.nameScopesList.scopePath.scopeName, + // ruleId: parentRule.ruleId, + // depth: parentRule.depth, + // _enterPos: -1, + // line: 0, + // }; + // tempRules.unshift(rule); + // rootParent = false; + // } + // parentRule = parentRule.parent; + // } + // ruleList.push(...tempRules); + // } + const childElement = { + id: 0, + document: document, + }; + elements.push(childElement); + return elements; + } + if (true) { + // const id = element.id; + // const depth = ruleList[id].depth; + // for (let index = id + 1; index < ruleList.length; index++) { + // const rule = ruleList[index]; + // const ruleDepth = rule.depth; + // if (ruleDepth == depth) { + // break; + // } + // if (ruleDepth == depth + 1) { + // const childElement: element = { + // id: index, + // document: document, + // }; + // elements.push(childElement); + // } + // } + return elements; + } + } + if (true) { + const elements = []; + if (!element) { + const activeTextEditor = vscode.window.activeTextEditor; + if (!activeTextEditor) { + return; + } + const childElement = { + id: -2, + document: activeTextEditor.document, + }; + elements.push(childElement); + return elements; + } + const document = element.document; + if (element.id == -2) { + grammar = await (0, TextMate_1.tokenizeFile)(document); + // grammar.rules.unshift( + // { + // captureIndices: [ + // { + // start: 0, + // end: 0, + // length: 0, + // } + // ], + // matchedRuleId: 1, + // } + // ); + const childElement = { + line: 0, + id: -1, + document: document, + }; + elements.push(childElement); + return elements; + } + if (true) { + let id = element.id; + const document = element.document; + // vscode.window.showInformationMessage(JSON.stringify(element)); + let depth = 0; + let line = element.line; + // if (element.id) { + // return elements; + // } + // if (element.ruleId != -1) { + // id++; + // line++; + // } + const rule = grammar._ruleId2desc[element.ruleId]; + if (rule) { + if (rule._end) { + id++; + } + else + return elements; + } + for (let index = id; index < grammar.rules.length; index++) { + const matchResult = grammar.rules[index]; + if (matchResult === undefined) { + line++; + continue; + } + if (matchResult == null) { + continue; + } + const ruleId = matchResult.matchedRuleId; + if (ruleId == -1) { + depth--; + if (depth == -1) { + break; + } + continue; + } + if (depth == 0) { + const childElement = { + line: line, + ruleId: ruleId, + id: index, + document: document, + }; + elements.push(childElement); + } + const rule = grammar._ruleId2desc[ruleId]; + if (rule._begin && !rule._while) { + depth++; + } + } + return elements; + } + } + }, + getTreeItem(element) { + // vscode.window.showInformationMessage(JSON.stringify("getTreeItem")); + // vscode.window.showInformationMessage(JSON.stringify(element)); + if (false) { + const document = element.document; + const line = element.line; + if (line == -1) { + const item = new vscode.TreeItem(document.uri); + item.collapsibleState = vscode.TreeItemCollapsibleState.Collapsed; + item.description = document.languageId; + item.iconPath = FileIcon; + return item; + } + const token = element.token; + if (token) { + const item = new vscode.TreeItem(JSON.stringify(token)); + return item; + } + const text = document.lineAt(line).text; + const label = text.replaceAll(' ', 'ยท').replaceAll('\t', 'โ†’') /* + (element + 1 == document.lineCount ? 'โ›”' : 'โŽ') */; + const item = new vscode.TreeItem(label); + item.accessibilityInformation = { label: 'accessibilityInformation', role: 'tree' }; + // item.checkboxState = { + // state: vscode.TreeItemCheckboxState.Unchecked, + // tooltip: 'checkboxtooltip', + // accessibilityInformation: { label: 'checkboxaccessibilityInformation', role: 'menu' } + // }; + item.collapsibleState = vscode.TreeItemCollapsibleState.Collapsed; + item.description = (line + 1).toString(); + // item.id = element.toString(); + // item.resourceUri = document.uri; + item.iconPath = FileIcon; + item.tooltip = `Line: ${line + 1}`; + return item; + } + if (false) { + const document = element.document; + const id = element.id; + if (id == -1) { + const item = new vscode.TreeItem(document.uri); + item.collapsibleState = vscode.TreeItemCollapsibleState.Collapsed; + item.description = document.languageId; + item.iconPath = FileIcon; + return item; + } + // const rule = ruleList[id]; + // const line = rule.line; + // const _enterPos = rule._enterPos; + // const label = rule.scopeName; + // const item = new vscode.TreeItem(label); + // item.collapsibleState = vscode.TreeItemCollapsibleState.Collapsed; + // item.description = line.toString(); + // item.iconPath = FileIcon; + // item.tooltip = `Start Index: ${_enterPos}`; + // const locations: vscode.Location[] = []; + // const range = line == 0 ? + // new vscode.Range(0, 0, document.lineCount, 0) + // : + // new vscode.Range(line - 1, _enterPos, line - 1, _enterPos + 1); + // const location = new vscode.Location( + // document.uri, + // range, + // ); + // locations.push(location); + // const position = line == 0 ? + // new vscode.Position(0, 0) + // : + // new vscode.Position(line - 1, _enterPos); + // const command: vscode.Command = { + // title: `title`, + // tooltip: `tooltip`, + // command: 'editor.action.goToLocations', + // arguments: [ + // document.uri, + // position, + // locations, + // ] + // }; + // item.command = command; + // return item; + } + if (true) { + const id = element.id; + if (id == -1) { + const label = grammar._rootScopeName; + const item = new vscode.TreeItem(label); + item.collapsibleState = vscode.TreeItemCollapsibleState.Collapsed; + item.iconPath = FileIcon; + return item; + } + const document = element.document; + if (id == -2) { + const item = new vscode.TreeItem(document.uri); + item.collapsibleState = vscode.TreeItemCollapsibleState.Collapsed; + item.description = document.languageId; + item.iconPath = FileIcon; + return item; + } + const ruleId = element.ruleId; + const line = element.line; + const cachedRule = grammar._ruleId2desc[ruleId]; + // const _enterPos = rule._enterPos; + const label = cachedRule._name; + const item = new vscode.TreeItem(label); + item.collapsibleState = vscode.TreeItemCollapsibleState.Collapsed; + item.description = line.toString(); + item.iconPath = FileIcon; + item.tooltip = `RuleId: ${cachedRule.id}`; + const rule = grammar.rules[element.id]; + const start = rule.captureIndices[0].start; + const end = rule.captureIndices[0].end; + const locations = []; + const range = new vscode.Range(line - 1, start, line - 1, end); + const location = new vscode.Location(document.uri, range); + locations.push(location); + const position = new vscode.Position(line - 1, start); + const command = { + title: `title`, + tooltip: `tooltip`, + command: 'editor.action.goToLocations', + arguments: [ + document.uri, + position, + locations, + ] + }; + item.command = command; + return item; + } + return; + }, + getParent(element) { + // vscode.window.showInformationMessage(JSON.stringify("getParent")); + // vscode.window.showInformationMessage(JSON.stringify(element)); + // console.log("getParent"); + // console.log(element); + if (element.id == -1) { + const parentElement = { + document: element.document, + id: -2, + }; + return parentElement; + } + return undefined; + }, + resolveTreeItem(item, element, token) { + // vscode.window.showInformationMessage(JSON.stringify("resolveTreeItem")); + // vscode.window.showInformationMessage(JSON.stringify(item)); + // vscode.window.showInformationMessage(JSON.stringify(element)); + return item; + }, + onDidChangeTreeData: onDidChangeTreeData.event, +}; +let treeView; +function initCallStackView(context) { + // vscode.window.showInformationMessage(JSON.stringify("initCallStackView")); + // context.subscriptions.push(vscode.commands.registerCommand("textmate.callstack", CallStackView, 'context')); + context.subscriptions.push(vscode.commands.registerTextEditorCommand("textmate.callstack", CallStackView)); + context.subscriptions.push(vscode.commands.registerCommand("textmate.refresh", refresh)); + context.subscriptions.push(vscode.commands.registerCommand("textmate.goto", goto)); + const options = { + treeDataProvider: exports.TreeDataProvider, + canSelectMany: false, + showCollapseAll: true, + manageCheckboxStateManually: false, + }; + treeView = vscode.window.createTreeView('TextMate', options); + // context.subscriptions.push( + // vscode.window.onDidChangeActiveTextEditor((editor: vscode.TextEditor) => { + // // vscode.window.showInformationMessage(JSON.stringify("active")); + // // vscode.window.showInformationMessage(JSON.stringify(editor)); + // if (!editor) { + // return; + // } + // const document = editor.document; + // const element: element = { + // line: -1, + // document: document, + // }; + // onDidChangeTreeData.fire(element); + // }) + // ); +} +exports.initCallStackView = initCallStackView; +async function CallStackView(textEditor, edit, ...args) { + // vscode.window.showInformationMessage(JSON.stringify("CallStackView")); + // vscode.window.showInformationMessage(JSON.stringify(textEditor)); + // vscode.window.showInformationMessage(JSON.stringify(edit)); + // vscode.window.showInformationMessage(JSON.stringify(args)); + const document = textEditor.document; + const position = textEditor.selection.active; + // const tokenLineResults = await tokenizeFile(document); + // // vscode.window.showInformationMessage(JSON.stringify(tokenLineResults, stringify)); + // let rootParent = true; + // let index = 0; + // const ruleList: { + // scopeName: string, + // ruleId: RuleId, + // depth: number, + // _enterPos: number, + // line: number, + // }[] = []; + // for (const tokenLine of tokenLineResults) { + // let parentRule = tokenLine.ruleStack; + // index++; + // const tempRules = []; + // while (parentRule) { + // if (parentRule._enterPos != -1 || rootParent) { + // const rule = { + // scopeName: parentRule.nameScopesList.scopePath.scopeName, + // ruleId: parentRule.ruleId, + // depth: parentRule.depth, + // _enterPos: parentRule._enterPos, + // line: index, + // }; + // tempRules.unshift(rule); + // rootParent = false; + // } + // parentRule = parentRule.parent; + // } + // ruleList.push(...tempRules); + // // ruleList = [...ruleList, ...tempRules]; + // } + // const ruleTree = {}; + // vscode.window.showInformationMessage(JSON.stringify(ruleList, stringify)); + const grammar = await (0, TextMate_1.tokenizeFile)(document); + // onDidChangeTreeData.fire(undefined); + const activeTextEditor = vscode.window.activeTextEditor; + if (!activeTextEditor) { + return; + } + await treeView.reveal({ + document: activeTextEditor.document, + id: -2, + }, { + expand: true, + focus: false, + select: false, + }); + await treeView.reveal({ + document: activeTextEditor.document, + id: -1, + }, { + expand: 2, + focus: true, + select: true, + }); + treeView.badge = { + tooltip: "tooltip badge 56: is there any use for this number?", + value: 56, + }; + treeView.title = "new title"; +} +function refresh(...args) { + // vscode.window.showInformationMessage(JSON.stringify("refresh")); + // vscode.window.showInformationMessage(JSON.stringify(args)); + const element = args[0]; + if (element) { + onDidChangeTreeData.fire({ + document: element.document, + id: -2, + }); + } + onDidChangeTreeData.fire(undefined); +} +async function goto(...args) { + // vscode.window.showInformationMessage(JSON.stringify("goto")); + // vscode.window.showInformationMessage(JSON.stringify(args)); + const element = args[0]; + if (!element) { + return; + } + const id = element.id; + const document = element.document; + if (id == -2) { + vscode.window.showTextDocument(document); + return; + } + if (id == -1) { + const lang = document.languageId; + for (const extension of vscode.extensions.all) { + const packageJSON = extension.packageJSON; + const grammars = packageJSON.contributes?.grammars; + if (grammars) { + for (const grammar of grammars) { + if (grammar.language == lang) { + const path = grammar.path; + if (path) { + const uri = vscode.Uri.joinPath(extension.extensionUri, path); + vscode.window.showTextDocument(uri); + return; + } + } + } + } + } + } + // locate grammar rule via its id + // annoyingly the ids are assigned on a first-served basis + // including across included/embedded grammars + const ruleId = element.ruleId; + if (!ruleId) { + return; + } + // (json (repository (repo (key) ))) + const path = allChildren(grammar._grammar, ruleId); + vscode.window.showInformationMessage(JSON.stringify(path)); + const grammarDoc = await getGrammarDocument(document); + const trees = (0, TreeSitter_1.getTrees)(grammarDoc); + const tree = trees.jsonTree; + let node = tree.rootNode; + for (const step of path) { + const repo = step.repository; + if (repo != null) { + for (const childNode of node.namedChildren) { + if (childNode.type == 'repository') { + node = childNode; + break; + } + } + for (const repoNode of node.namedChildren) { + if (repoNode.firstNamedChild?.text == repo) { + node = repoNode; + break; + } + } + continue; + } + const pattern = step.patterns; + if (pattern != null) { + for (const patternNode of node.namedChildren) { + if (patternNode.type == 'patterns') { + node = patternNode; + break; + } + } + node = node.namedChild(pattern + 1); + continue; + } + const id = step.id; + if (id != null) { + break; + } + } + const range = (0, TreeSitter_1.toRange)(node); + const uri = grammarDoc.uri; + const location = new vscode.Location(uri, range); + const locations = [location]; + vscode.commands.executeCommand('editor.action.goToLocations', uri, range.start, locations); +} +function allChildren(rules, ruleId) { + for (const key in rules) { + switch (key) { + case 'patterns': + const patterns = rules[key]; + for (let index = 0; index < patterns.length; index++) { + const pattern = patterns[index]; + const path = allChildren(pattern, ruleId); + if (path) { + path.unshift({ "patterns": index }); + return path; + } + } + break; + case 'repository': + const repository = rules[key]; + for (const key in repository) { + const repo = repository[key]; + const path = allChildren(repo, ruleId); + if (path) { + path.unshift({ "repository": key }); + return path; + } + } + break; + case 'id': + // @ts-ignore + const id = rules[key]; + if (id == ruleId) { + // return []; + return [{ id: id }]; + } + default: + break; + } + } +} +async function getGrammarDocument(document) { + const lang = document.languageId; + for (const extension of vscode.extensions.all) { + const packageJSON = extension.packageJSON; + const grammars = packageJSON.contributes?.grammars; + if (grammars) { + for (const grammar of grammars) { + if (grammar.language == lang) { + const path = grammar.path; + if (path) { + const uri = vscode.Uri.joinPath(extension.extensionUri, path); + const grammarDoc = await vscode.workspace.openTextDocument(uri); + if (grammarDoc) { + return grammarDoc; + } + } + } + } + } + } +} diff --git a/out/extension.js b/out/extension.js index 39b3f36..0ec7a0f 100644 --- a/out/extension.js +++ b/out/extension.js @@ -1,11 +1,13 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.deactivate = exports.activate = exports.DocumentSelector = void 0; +exports.stringify = exports.deactivate = exports.activate = exports.DocumentSelector = void 0; const vscode = require("vscode"); const TreeSitter_1 = require("./TreeSitter"); const oniguruma_1 = require("./oniguruma"); +const TextMate_1 = require("./TextMate"); const DiagnosticCollection_1 = require("./DiagnosticCollection"); const tokenColorCustomizations_1 = require("./tokenColorCustomizations"); +const TreeDataProvider_1 = require("./TreeDataProvider"); const RenameProvider_1 = require("./RenameProvider"); const ReferenceProvider_1 = require("./ReferenceProvider"); const DefinitionProvider_1 = require("./DefinitionProvider"); @@ -21,10 +23,13 @@ async function activate(context) { // vscode.window.showInformationMessage(JSON.stringify("TextMate Extension")); await (0, TreeSitter_1.initTreeSitter)(context); await (0, oniguruma_1.initOniguruma)(context); + (0, TextMate_1.initTextMate)(context); (0, DiagnosticCollection_1.initDiagnostics)(context); + (0, TreeDataProvider_1.initCallStackView)(context); (0, tokenColorCustomizations_1.initTokenColorCustomizations)(context); // context.subscriptions.push(vscode.languages.registerHoverProvider(DocumentSelector, HoverProvider)); // Mouse over Hovers context.subscriptions.push(vscode.languages.registerRenameProvider(exports.DocumentSelector, RenameProvider_1.RenameProvider)); // [F2] Rename + // context.subscriptions.push(vscode.languages.registerCodeLensProvider(DocumentSelector, CodeLensProvider)); // Code Lens context.subscriptions.push(vscode.languages.registerReferenceProvider(exports.DocumentSelector, ReferenceProvider_1.ReferenceProvider)); // Go to References context.subscriptions.push(vscode.languages.registerDefinitionProvider(exports.DocumentSelector, DefinitionProvider_1.DefinitionProvider)); // ctrl+click Go to Definition context.subscriptions.push(vscode.languages.registerCallHierarchyProvider(exports.DocumentSelector, CallHierarchyProvider_1.CallHierarchyProvider)); // right click => Peak Call Hierarchy @@ -43,3 +48,22 @@ function deactivate() { // https://github.com/microsoft/vscode/issues/201664 } exports.deactivate = deactivate; +function stringify(key, value) { + if (typeof value === 'function') { + return ""; + } + if (typeof value === 'symbol') { + return ""; + } + if (typeof value === 'undefined') { + return ""; + } + if (value == null) { + return null; + } + if (key.startsWith("HEAP")) { + return ""; + } + return value; +} +exports.stringify = stringify; diff --git a/out/textmate/debug.js b/out/textmate/debug.js new file mode 100644 index 0000000..af42492 --- /dev/null +++ b/out/textmate/debug.js @@ -0,0 +1,10 @@ +"use strict"; +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.UseOnigurumaFindOptions = exports.DebugFlags = void 0; +exports.DebugFlags = { + InDebugMode: (typeof process !== 'undefined' && !!process.env['VSCODE_TEXTMATE_DEBUG']) +}; +exports.UseOnigurumaFindOptions = false; diff --git a/out/textmate/diffStateStacks.js b/out/textmate/diffStateStacks.js new file mode 100644 index 0000000..ad307fd --- /dev/null +++ b/out/textmate/diffStateStacks.js @@ -0,0 +1,42 @@ +"use strict"; +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.applyStateStackDiff = exports.diffStateStacksRefEq = void 0; +const grammar_1 = require("./grammar"); +function diffStateStacksRefEq(first, second) { + let pops = 0; + const newFrames = []; + let curFirst = first; + let curSecond = second; + while (curFirst !== curSecond) { + if (curFirst && (!curSecond || curFirst.depth >= curSecond.depth)) { + // curFirst is certainly not contained in curSecond + pops++; + curFirst = curFirst.parent; + } + else { + // curSecond is certainly not contained in curFirst. + // Also, curSecond must be defined, as otherwise a previous case would match + newFrames.push(curSecond.toStateStackFrame()); + curSecond = curSecond.parent; + } + } + return { + pops, + newFrames: newFrames.reverse(), + }; +} +exports.diffStateStacksRefEq = diffStateStacksRefEq; +function applyStateStackDiff(stack, diff) { + let curStack = stack; + for (let i = 0; i < diff.pops; i++) { + curStack = curStack.parent; + } + for (const frame of diff.newFrames) { + curStack = grammar_1.StateStackImpl.pushFrame(curStack, frame); + } + return curStack; +} +exports.applyStateStackDiff = applyStateStackDiff; diff --git a/out/textmate/encodedTokenAttributes.js b/out/textmate/encodedTokenAttributes.js new file mode 100644 index 0000000..1af0ed0 --- /dev/null +++ b/out/textmate/encodedTokenAttributes.js @@ -0,0 +1,103 @@ +"use strict"; +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.toOptionalTokenType = exports.EncodedTokenAttributes = void 0; +var EncodedTokenAttributes; +(function (EncodedTokenAttributes) { + function toBinaryStr(encodedTokenAttributes) { + return encodedTokenAttributes.toString(2).padStart(32, "0"); + } + EncodedTokenAttributes.toBinaryStr = toBinaryStr; + function print(encodedTokenAttributes) { + const languageId = EncodedTokenAttributes.getLanguageId(encodedTokenAttributes); + const tokenType = EncodedTokenAttributes.getTokenType(encodedTokenAttributes); + const fontStyle = EncodedTokenAttributes.getFontStyle(encodedTokenAttributes); + const foreground = EncodedTokenAttributes.getForeground(encodedTokenAttributes); + const background = EncodedTokenAttributes.getBackground(encodedTokenAttributes); + console.log({ + languageId: languageId, + tokenType: tokenType, + fontStyle: fontStyle, + foreground: foreground, + background: background, + }); + } + EncodedTokenAttributes.print = print; + function getLanguageId(encodedTokenAttributes) { + return ((encodedTokenAttributes & 255 /* EncodedTokenDataConsts.LANGUAGEID_MASK */) >>> + 0 /* EncodedTokenDataConsts.LANGUAGEID_OFFSET */); + } + EncodedTokenAttributes.getLanguageId = getLanguageId; + function getTokenType(encodedTokenAttributes) { + return ((encodedTokenAttributes & 768 /* EncodedTokenDataConsts.TOKEN_TYPE_MASK */) >>> + 8 /* EncodedTokenDataConsts.TOKEN_TYPE_OFFSET */); + } + EncodedTokenAttributes.getTokenType = getTokenType; + function containsBalancedBrackets(encodedTokenAttributes) { + return (encodedTokenAttributes & 1024 /* EncodedTokenDataConsts.BALANCED_BRACKETS_MASK */) !== 0; + } + EncodedTokenAttributes.containsBalancedBrackets = containsBalancedBrackets; + function getFontStyle(encodedTokenAttributes) { + return ((encodedTokenAttributes & 30720 /* EncodedTokenDataConsts.FONT_STYLE_MASK */) >>> + 11 /* EncodedTokenDataConsts.FONT_STYLE_OFFSET */); + } + EncodedTokenAttributes.getFontStyle = getFontStyle; + function getForeground(encodedTokenAttributes) { + return ((encodedTokenAttributes & 16744448 /* EncodedTokenDataConsts.FOREGROUND_MASK */) >>> + 15 /* EncodedTokenDataConsts.FOREGROUND_OFFSET */); + } + EncodedTokenAttributes.getForeground = getForeground; + function getBackground(encodedTokenAttributes) { + return ((encodedTokenAttributes & 4278190080 /* EncodedTokenDataConsts.BACKGROUND_MASK */) >>> + 24 /* EncodedTokenDataConsts.BACKGROUND_OFFSET */); + } + EncodedTokenAttributes.getBackground = getBackground; + /** + * Updates the fields in `metadata`. + * A value of `0`, `NotSet` or `null` indicates that the corresponding field should be left as is. + */ + function set(encodedTokenAttributes, languageId, tokenType, containsBalancedBrackets, fontStyle, foreground, background) { + let _languageId = EncodedTokenAttributes.getLanguageId(encodedTokenAttributes); + let _tokenType = EncodedTokenAttributes.getTokenType(encodedTokenAttributes); + let _containsBalancedBracketsBit = EncodedTokenAttributes.containsBalancedBrackets(encodedTokenAttributes) ? 1 : 0; + let _fontStyle = EncodedTokenAttributes.getFontStyle(encodedTokenAttributes); + let _foreground = EncodedTokenAttributes.getForeground(encodedTokenAttributes); + let _background = EncodedTokenAttributes.getBackground(encodedTokenAttributes); + if (languageId !== 0) { + _languageId = languageId; + } + if (tokenType !== 8 /* OptionalStandardTokenType.NotSet */) { + _tokenType = fromOptionalTokenType(tokenType); + } + if (containsBalancedBrackets !== null) { + _containsBalancedBracketsBit = containsBalancedBrackets ? 1 : 0; + } + if (fontStyle !== -1 /* FontStyle.NotSet */) { + _fontStyle = fontStyle; + } + if (foreground !== 0) { + _foreground = foreground; + } + if (background !== 0) { + _background = background; + } + return (((_languageId << 0 /* EncodedTokenDataConsts.LANGUAGEID_OFFSET */) | + (_tokenType << 8 /* EncodedTokenDataConsts.TOKEN_TYPE_OFFSET */) | + (_containsBalancedBracketsBit << + 10 /* EncodedTokenDataConsts.BALANCED_BRACKETS_OFFSET */) | + (_fontStyle << 11 /* EncodedTokenDataConsts.FONT_STYLE_OFFSET */) | + (_foreground << 15 /* EncodedTokenDataConsts.FOREGROUND_OFFSET */) | + (_background << 24 /* EncodedTokenDataConsts.BACKGROUND_OFFSET */)) >>> + 0); + } + EncodedTokenAttributes.set = set; +})(EncodedTokenAttributes || (exports.EncodedTokenAttributes = EncodedTokenAttributes = {})); +function toOptionalTokenType(standardType) { + return standardType; +} +exports.toOptionalTokenType = toOptionalTokenType; +function fromOptionalTokenType(standardType) { + return standardType; +} diff --git a/out/textmate/grammar/basicScopesAttributeProvider.js b/out/textmate/grammar/basicScopesAttributeProvider.js new file mode 100644 index 0000000..0304011 --- /dev/null +++ b/out/textmate/grammar/basicScopesAttributeProvider.js @@ -0,0 +1,94 @@ +"use strict"; +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.BasicScopeAttributesProvider = exports.BasicScopeAttributes = void 0; +const utils_1 = require("../utils"); +class BasicScopeAttributes { + languageId; + tokenType; + constructor(languageId, tokenType) { + this.languageId = languageId; + this.tokenType = tokenType; + } +} +exports.BasicScopeAttributes = BasicScopeAttributes; +class BasicScopeAttributesProvider { + _defaultAttributes; + _embeddedLanguagesMatcher; + constructor(initialLanguageId, embeddedLanguages) { + this._defaultAttributes = new BasicScopeAttributes(initialLanguageId, 8 /* OptionalStandardTokenType.NotSet */); + this._embeddedLanguagesMatcher = new ScopeMatcher(Object.entries(embeddedLanguages || {})); + } + getDefaultAttributes() { + return this._defaultAttributes; + } + getBasicScopeAttributes(scopeName) { + if (scopeName === null) { + return BasicScopeAttributesProvider._NULL_SCOPE_METADATA; + } + return this._getBasicScopeAttributes.get(scopeName); + } + static _NULL_SCOPE_METADATA = new BasicScopeAttributes(0, 0); + _getBasicScopeAttributes = new utils_1.CachedFn((scopeName) => { + const languageId = this._scopeToLanguage(scopeName); + const standardTokenType = this._toStandardTokenType(scopeName); + return new BasicScopeAttributes(languageId, standardTokenType); + }); + /** + * Given a produced TM scope, return the language that token describes or null if unknown. + * e.g. source.html => html, source.css.embedded.html => css, punctuation.definition.tag.html => null + */ + _scopeToLanguage(scope) { + return this._embeddedLanguagesMatcher.match(scope) || 0; + } + _toStandardTokenType(scopeName) { + const m = scopeName.match(BasicScopeAttributesProvider.STANDARD_TOKEN_TYPE_REGEXP); + if (!m) { + return 8 /* OptionalStandardTokenType.NotSet */; + } + switch (m[1]) { + case "comment": + return 1 /* OptionalStandardTokenType.Comment */; + case "string": + return 2 /* OptionalStandardTokenType.String */; + case "regex": + return 3 /* OptionalStandardTokenType.RegEx */; + case "meta.embedded": + return 0 /* OptionalStandardTokenType.Other */; + } + throw new Error("Unexpected match for standard token type!"); + } + static STANDARD_TOKEN_TYPE_REGEXP = /\b(comment|string|regex|meta\.embedded)\b/; +} +exports.BasicScopeAttributesProvider = BasicScopeAttributesProvider; +class ScopeMatcher { + values; + scopesRegExp; + constructor(values) { + if (values.length === 0) { + this.values = null; + this.scopesRegExp = null; + } + else { + this.values = new Map(values); + // create the regex + const escapedScopes = values.map(([scopeName, value]) => (0, utils_1.escapeRegExpCharacters)(scopeName)); + escapedScopes.sort(); + escapedScopes.reverse(); // Longest scope first + this.scopesRegExp = new RegExp(`^((${escapedScopes.join(")|(")}))($|\\.)`, ""); + } + } + match(scope) { + if (!this.scopesRegExp) { + return undefined; + } + const m = scope.match(this.scopesRegExp); + if (!m) { + // no scopes matched + return undefined; + } + return this.values.get(m[1]); + } +} diff --git a/out/textmate/grammar/grammar.js b/out/textmate/grammar/grammar.js new file mode 100644 index 0000000..b793408 --- /dev/null +++ b/out/textmate/grammar/grammar.js @@ -0,0 +1,727 @@ +"use strict"; +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.LineTokens = exports.BalancedBracketSelectors = exports.StateStackImpl = exports.AttributedScopeStack = exports.Grammar = exports.createGrammar = void 0; +const debug_1 = require("../debug"); +const encodedTokenAttributes_1 = require("../encodedTokenAttributes"); +const matcher_1 = require("../matcher"); +const onigLib_1 = require("../onigLib"); +const rule_1 = require("../rule"); +const theme_1 = require("../theme"); +const utils_1 = require("../utils"); +const basicScopesAttributeProvider_1 = require("./basicScopesAttributeProvider"); +const tokenizeString_1 = require("./tokenizeString"); +function createGrammar(scopeName, grammar, initialLanguage, embeddedLanguages, tokenTypes, balancedBracketSelectors, grammarRepository, onigLib) { + return new Grammar(scopeName, grammar, initialLanguage, embeddedLanguages, tokenTypes, balancedBracketSelectors, grammarRepository, onigLib); //TODO +} +exports.createGrammar = createGrammar; +function collectInjections(result, selector, rule, ruleFactoryHelper, grammar) { + const matchers = (0, matcher_1.createMatchers)(selector, nameMatcher); + const ruleId = rule_1.RuleFactory.getCompiledRuleId(rule, ruleFactoryHelper, grammar.repository); + for (const matcher of matchers) { + result.push({ + debugSelector: selector, + matcher: matcher.matcher, + ruleId: ruleId, + grammar: grammar, + priority: matcher.priority + }); + } +} +function nameMatcher(identifers, scopes) { + if (scopes.length < identifers.length) { + return false; + } + let lastIndex = 0; + return identifers.every(identifier => { + for (let i = lastIndex; i < scopes.length; i++) { + if (scopesAreMatching(scopes[i], identifier)) { + lastIndex = i + 1; + return true; + } + } + return false; + }); +} +function scopesAreMatching(thisScopeName, scopeName) { + if (!thisScopeName) { + return false; + } + if (thisScopeName === scopeName) { + return true; + } + const len = scopeName.length; + return thisScopeName.length > len && thisScopeName.substr(0, len) === scopeName && thisScopeName[len] === '.'; +} +class Grammar { + _rootScopeName; + balancedBracketSelectors; + _onigLib; + _rootId; + _lastRuleId; + _ruleId2desc; + _includedGrammars; + _grammarRepository; + _grammar; + _injections; + _basicScopeAttributesProvider; + _tokenTypeMatchers; + get themeProvider() { return this._grammarRepository; } + constructor(_rootScopeName, grammar, initialLanguage, embeddedLanguages, tokenTypes, balancedBracketSelectors, grammarRepository, _onigLib) { + this._rootScopeName = _rootScopeName; + this.balancedBracketSelectors = balancedBracketSelectors; + this._onigLib = _onigLib; + this._basicScopeAttributesProvider = new basicScopesAttributeProvider_1.BasicScopeAttributesProvider(initialLanguage, embeddedLanguages); + this._rootId = -1; + this._lastRuleId = 0; + this._ruleId2desc = [null]; + this._includedGrammars = {}; + this._grammarRepository = grammarRepository; + this._grammar = initGrammar(grammar, null); + this._injections = null; + this._tokenTypeMatchers = []; + if (tokenTypes) { + for (const selector of Object.keys(tokenTypes)) { + const matchers = (0, matcher_1.createMatchers)(selector, nameMatcher); + for (const matcher of matchers) { + this._tokenTypeMatchers.push({ + matcher: matcher.matcher, + type: tokenTypes[selector], + }); + } + } + } + } + dispose() { + for (const rule of this._ruleId2desc) { + if (rule) { + rule.dispose(); + } + } + } + createOnigScanner(sources) { + return this._onigLib.createOnigScanner(sources); + } + createOnigString(sources) { + return this._onigLib.createOnigString(sources); + } + getMetadataForScope(scope) { + return this._basicScopeAttributesProvider.getBasicScopeAttributes(scope); + } + _collectInjections() { + const grammarRepository = { + lookup: (scopeName) => { + if (scopeName === this._rootScopeName) { + return this._grammar; + } + return this.getExternalGrammar(scopeName); + }, + injections: (scopeName) => { + return this._grammarRepository.injections(scopeName); + }, + }; + const result = []; + const scopeName = this._rootScopeName; + const grammar = grammarRepository.lookup(scopeName); + if (grammar) { + // add injections from the current grammar + const rawInjections = grammar.injections; + if (rawInjections) { + for (let expression in rawInjections) { + collectInjections(result, expression, rawInjections[expression], this, grammar); + } + } + // add injection grammars contributed for the current scope + const injectionScopeNames = this._grammarRepository.injections(scopeName); + if (injectionScopeNames) { + injectionScopeNames.forEach((injectionScopeName) => { + const injectionGrammar = this.getExternalGrammar(injectionScopeName); + if (injectionGrammar) { + const selector = injectionGrammar.injectionSelector; + if (selector) { + collectInjections(result, selector, injectionGrammar, this, injectionGrammar); + } + } + }); + } + } + result.sort((i1, i2) => i1.priority - i2.priority); // sort by priority + return result; + } + getInjections() { + if (this._injections === null) { + this._injections = this._collectInjections(); + if (debug_1.DebugFlags.InDebugMode && this._injections.length > 0) { + console.log(`Grammar ${this._rootScopeName} contains the following injections:`); + for (const injection of this._injections) { + console.log(` - ${injection.debugSelector}`); + } + } + } + return this._injections; + } + registerRule(factory) { + const id = ++this._lastRuleId; + const result = factory((0, rule_1.ruleIdFromNumber)(id)); + this._ruleId2desc[id] = result; + return result; + } + getRule(ruleId) { + return this._ruleId2desc[(0, rule_1.ruleIdToNumber)(ruleId)]; + } + getExternalGrammar(scopeName, repository) { + if (this._includedGrammars[scopeName]) { + return this._includedGrammars[scopeName]; + } + else if (this._grammarRepository) { + const rawIncludedGrammar = this._grammarRepository.lookup(scopeName); + if (rawIncludedGrammar) { + // console.log('LOADED GRAMMAR ' + pattern.include); + this._includedGrammars[scopeName] = initGrammar(rawIncludedGrammar, repository && repository.$base); + return this._includedGrammars[scopeName]; + } + } + return undefined; + } + tokenizeLine(lineText, prevState, timeLimit = 0) { + const r = this._tokenize(lineText, prevState, false, timeLimit); + return { + tokens: r.lineTokens.getResult(r.ruleStack, r.lineLength), + ruleStack: r.ruleStack, + stoppedEarly: r.stoppedEarly, + }; + } + tokenizeLine2(lineText, prevState, timeLimit = 0) { + const r = this._tokenize(lineText, prevState, true, timeLimit); + return { + tokens: r.lineTokens.getBinaryResult(r.ruleStack, r.lineLength), + ruleStack: r.ruleStack, + stoppedEarly: r.stoppedEarly, + }; + } + _tokenize(lineText, prevState, emitBinaryTokens, timeLimit) { + if (this._rootId === -1) { + this._rootId = rule_1.RuleFactory.getCompiledRuleId(this._grammar.repository.$self, this, this._grammar.repository); + // This ensures ids are deterministic, and thus equal in renderer and webworker. + this.getInjections(); + } + let isFirstLine; + if (!prevState || prevState === StateStackImpl.NULL) { + isFirstLine = true; + const rawDefaultMetadata = this._basicScopeAttributesProvider.getDefaultAttributes(); + const defaultStyle = this.themeProvider.getDefaults(); + const defaultMetadata = encodedTokenAttributes_1.EncodedTokenAttributes.set(0, rawDefaultMetadata.languageId, rawDefaultMetadata.tokenType, null, defaultStyle.fontStyle, defaultStyle.foregroundId, defaultStyle.backgroundId); + const rootScopeName = this.getRule(this._rootId).getName(null, null); + let scopeList; + if (rootScopeName) { + scopeList = AttributedScopeStack.createRootAndLookUpScopeName(rootScopeName, defaultMetadata, this); + } + else { + scopeList = AttributedScopeStack.createRoot("unknown", defaultMetadata); + } + prevState = new StateStackImpl(null, this._rootId, -1, -1, false, null, scopeList, scopeList); + } + else { + isFirstLine = false; + prevState.reset(); + } + lineText = lineText + "\n"; + const onigLineText = this.createOnigString(lineText); + const lineLength = onigLineText.content.length; + const lineTokens = new LineTokens(emitBinaryTokens, lineText, this._tokenTypeMatchers, this.balancedBracketSelectors); + const r = (0, tokenizeString_1._tokenizeString)(this, onigLineText, isFirstLine, 0, prevState, lineTokens, true, timeLimit); + (0, onigLib_1.disposeOnigString)(onigLineText); + return { + lineLength: lineLength, + lineTokens: lineTokens, + ruleStack: r.stack, + stoppedEarly: r.stoppedEarly, + }; + } +} +exports.Grammar = Grammar; +function initGrammar(grammar, base) { + grammar = (0, utils_1.clone)(grammar); + grammar.repository = grammar.repository || {}; + grammar.repository.$self = { + $vscodeTextmateLocation: grammar.$vscodeTextmateLocation, + patterns: grammar.patterns, + name: grammar.scopeName + }; + grammar.repository.$base = base || grammar.repository.$self; + return grammar; +} +class AttributedScopeStack { + parent; + scopePath; + tokenAttributes; + static fromExtension(namesScopeList, contentNameScopesList) { + let current = namesScopeList; + let scopeNames = namesScopeList?.scopePath ?? null; + for (const frame of contentNameScopesList) { + scopeNames = theme_1.ScopeStack.push(scopeNames, frame.scopeNames); + current = new AttributedScopeStack(current, scopeNames, frame.encodedTokenAttributes); + } + return current; + } + static createRoot(scopeName, tokenAttributes) { + return new AttributedScopeStack(null, new theme_1.ScopeStack(null, scopeName), tokenAttributes); + } + static createRootAndLookUpScopeName(scopeName, tokenAttributes, grammar) { + const rawRootMetadata = grammar.getMetadataForScope(scopeName); + const scopePath = new theme_1.ScopeStack(null, scopeName); + const rootStyle = grammar.themeProvider.themeMatch(scopePath); + const resolvedTokenAttributes = AttributedScopeStack.mergeAttributes(tokenAttributes, rawRootMetadata, rootStyle); + return new AttributedScopeStack(null, scopePath, resolvedTokenAttributes); + } + get scopeName() { return this.scopePath.scopeName; } + /** + * Invariant: + * ``` + * if (parent && !scopePath.extends(parent.scopePath)) { + * throw new Error(); + * } + * ``` + */ + constructor(parent, scopePath, tokenAttributes) { + this.parent = parent; + this.scopePath = scopePath; + this.tokenAttributes = tokenAttributes; + } + toString() { + return this.getScopeNames().join(' '); + } + equals(other) { + return AttributedScopeStack.equals(this, other); + } + static equals(a, b) { + do { + if (a === b) { + return true; + } + if (!a && !b) { + // End of list reached for both + return true; + } + if (!a || !b) { + // End of list reached only for one + return false; + } + if (a.scopeName !== b.scopeName || a.tokenAttributes !== b.tokenAttributes) { + return false; + } + // Go to previous pair + a = a.parent; + b = b.parent; + } while (true); + } + static mergeAttributes(existingTokenAttributes, basicScopeAttributes, styleAttributes) { + let fontStyle = -1 /* FontStyle.NotSet */; + let foreground = 0; + let background = 0; + if (styleAttributes !== null) { + fontStyle = styleAttributes.fontStyle; + foreground = styleAttributes.foregroundId; + background = styleAttributes.backgroundId; + } + return encodedTokenAttributes_1.EncodedTokenAttributes.set(existingTokenAttributes, basicScopeAttributes.languageId, basicScopeAttributes.tokenType, null, fontStyle, foreground, background); + } + pushAttributed(scopePath, grammar) { + if (scopePath === null) { + return this; + } + if (scopePath.indexOf(' ') === -1) { + // This is the common case and much faster + return AttributedScopeStack._pushAttributed(this, scopePath, grammar); + } + const scopes = scopePath.split(/ /g); + let result = this; + for (const scope of scopes) { + result = AttributedScopeStack._pushAttributed(result, scope, grammar); + } + return result; + } + static _pushAttributed(target, scopeName, grammar) { + const rawMetadata = grammar.getMetadataForScope(scopeName); + const newPath = target.scopePath.push(scopeName); + const scopeThemeMatchResult = grammar.themeProvider.themeMatch(newPath); + const metadata = AttributedScopeStack.mergeAttributes(target.tokenAttributes, rawMetadata, scopeThemeMatchResult); + return new AttributedScopeStack(target, newPath, metadata); + } + getScopeNames() { + return this.scopePath.getSegments(); + } + getExtensionIfDefined(base) { + const result = []; + let self = this; + while (self && self !== base) { + result.push({ + encodedTokenAttributes: self.tokenAttributes, + scopeNames: self.scopePath.getExtensionIfDefined(self.parent?.scopePath ?? null), + }); + self = self.parent; + } + return self === base ? result.reverse() : undefined; + } +} +exports.AttributedScopeStack = AttributedScopeStack; +/** + * Represents a "pushed" state on the stack (as a linked list element). + */ +class StateStackImpl { + parent; + ruleId; + beginRuleCapturedEOL; + endRule; + nameScopesList; + contentNameScopesList; + _stackElementBrand = undefined; + // TODO remove me + static NULL = new StateStackImpl(null, 0, 0, 0, false, null, null, null); + /** + * The position on the current line where this state was pushed. + * This is relevant only while tokenizing a line, to detect endless loops. + * Its value is meaningless across lines. + */ + _enterPos; + /** + * The captured anchor position when this stack element was pushed. + * This is relevant only while tokenizing a line, to restore the anchor position when popping. + * Its value is meaningless across lines. + */ + _anchorPos; + /** + * The depth of the stack. + */ + depth; + /** + * Invariant: + * ``` + * if (contentNameScopesList !== nameScopesList && contentNameScopesList?.parent !== nameScopesList) { + * throw new Error(); + * } + * if (this.parent && !nameScopesList.extends(this.parent.contentNameScopesList)) { + * throw new Error(); + * } + * ``` + */ + constructor( + /** + * The previous state on the stack (or null for the root state). + */ + parent, + /** + * The state (rule) that this element represents. + */ + ruleId, enterPos, anchorPos, + /** + * The state has entered and captured \n. This means that the next line should have an anchorPosition of 0. + */ + beginRuleCapturedEOL, + /** + * The "pop" (end) condition for this state in case that it was dynamically generated through captured text. + */ + endRule, + /** + * The list of scopes containing the "name" for this state. + */ + nameScopesList, + /** + * The list of scopes containing the "contentName" (besides "name") for this state. + * This list **must** contain as an element `scopeName`. + */ + contentNameScopesList) { + this.parent = parent; + this.ruleId = ruleId; + this.beginRuleCapturedEOL = beginRuleCapturedEOL; + this.endRule = endRule; + this.nameScopesList = nameScopesList; + this.contentNameScopesList = contentNameScopesList; + this.depth = this.parent ? this.parent.depth + 1 : 1; + this._enterPos = enterPos; + this._anchorPos = anchorPos; + } + equals(other) { + if (other === null) { + return false; + } + return StateStackImpl._equals(this, other); + } + static _equals(a, b) { + if (a === b) { + return true; + } + if (!this._structuralEquals(a, b)) { + return false; + } + return AttributedScopeStack.equals(a.contentNameScopesList, b.contentNameScopesList); + } + /** + * A structural equals check. Does not take into account `scopes`. + */ + static _structuralEquals(a, b) { + do { + if (a === b) { + return true; + } + if (!a && !b) { + // End of list reached for both + return true; + } + if (!a || !b) { + // End of list reached only for one + return false; + } + if (a.depth !== b.depth || + a.ruleId !== b.ruleId || + a.endRule !== b.endRule) { + return false; + } + // Go to previous pair + a = a.parent; + b = b.parent; + } while (true); + } + clone() { + return this; + } + static _reset(el) { + while (el) { + el._enterPos = -1; + el._anchorPos = -1; + el = el.parent; + } + } + reset() { + StateStackImpl._reset(this); + } + pop() { + return this.parent; + } + safePop() { + if (this.parent) { + return this.parent; + } + return this; + } + push(ruleId, enterPos, anchorPos, beginRuleCapturedEOL, endRule, nameScopesList, contentNameScopesList) { + return new StateStackImpl(this, ruleId, enterPos, anchorPos, beginRuleCapturedEOL, endRule, nameScopesList, contentNameScopesList); + } + getEnterPos() { + return this._enterPos; + } + getAnchorPos() { + return this._anchorPos; + } + getRule(grammar) { + return grammar.getRule(this.ruleId); + } + toString() { + const r = []; + this._writeString(r, 0); + return "[" + r.join(",") + "]"; + } + _writeString(res, outIndex) { + if (this.parent) { + outIndex = this.parent._writeString(res, outIndex); + } + res[outIndex++] = `(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`; + return outIndex; + } + withContentNameScopesList(contentNameScopeStack) { + if (this.contentNameScopesList === contentNameScopeStack) { + return this; + } + return this.parent.push(this.ruleId, this._enterPos, this._anchorPos, this.beginRuleCapturedEOL, this.endRule, this.nameScopesList, contentNameScopeStack); + } + withEndRule(endRule) { + if (this.endRule === endRule) { + return this; + } + return new StateStackImpl(this.parent, this.ruleId, this._enterPos, this._anchorPos, this.beginRuleCapturedEOL, endRule, this.nameScopesList, this.contentNameScopesList); + } + // Used to warn of endless loops + hasSameRuleAs(other) { + let el = this; + while (el && el._enterPos === other._enterPos) { + if (el.ruleId === other.ruleId) { + return true; + } + el = el.parent; + } + return false; + } + toStateStackFrame() { + return { + ruleId: (0, rule_1.ruleIdToNumber)(this.ruleId), + beginRuleCapturedEOL: this.beginRuleCapturedEOL, + endRule: this.endRule, + nameScopesList: this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList ?? null) ?? [], + contentNameScopesList: this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList) ?? [], + }; + } + static pushFrame(self, frame) { + const namesScopeList = AttributedScopeStack.fromExtension(self?.nameScopesList ?? null, frame.nameScopesList); + return new StateStackImpl(self, (0, rule_1.ruleIdFromNumber)(frame.ruleId), frame.enterPos ?? -1, frame.anchorPos ?? -1, frame.beginRuleCapturedEOL, frame.endRule, namesScopeList, AttributedScopeStack.fromExtension(namesScopeList, frame.contentNameScopesList)); + } +} +exports.StateStackImpl = StateStackImpl; +class BalancedBracketSelectors { + balancedBracketScopes; + unbalancedBracketScopes; + allowAny = false; + constructor(balancedBracketScopes, unbalancedBracketScopes) { + this.balancedBracketScopes = balancedBracketScopes.flatMap((selector) => { + if (selector === '*') { + this.allowAny = true; + return []; + } + return (0, matcher_1.createMatchers)(selector, nameMatcher).map((m) => m.matcher); + }); + this.unbalancedBracketScopes = unbalancedBracketScopes.flatMap((selector) => (0, matcher_1.createMatchers)(selector, nameMatcher).map((m) => m.matcher)); + } + get matchesAlways() { + return this.allowAny && this.unbalancedBracketScopes.length === 0; + } + get matchesNever() { + return this.balancedBracketScopes.length === 0 && !this.allowAny; + } + match(scopes) { + for (const excluder of this.unbalancedBracketScopes) { + if (excluder(scopes)) { + return false; + } + } + for (const includer of this.balancedBracketScopes) { + if (includer(scopes)) { + return true; + } + } + return this.allowAny; + } +} +exports.BalancedBracketSelectors = BalancedBracketSelectors; +class LineTokens { + balancedBracketSelectors; + _emitBinaryTokens; + /** + * defined only if `DebugFlags.InDebugMode`. + */ + _lineText; + /** + * used only if `_emitBinaryTokens` is false. + */ + _tokens; + /** + * used only if `_emitBinaryTokens` is true. + */ + _binaryTokens; + _lastTokenEndIndex; + _tokenTypeOverrides; + constructor(emitBinaryTokens, lineText, tokenTypeOverrides, balancedBracketSelectors) { + this.balancedBracketSelectors = balancedBracketSelectors; + this._emitBinaryTokens = emitBinaryTokens; + this._tokenTypeOverrides = tokenTypeOverrides; + if (debug_1.DebugFlags.InDebugMode) { + this._lineText = lineText; + } + else { + this._lineText = null; + } + this._tokens = []; + this._binaryTokens = []; + this._lastTokenEndIndex = 0; + } + produce(stack, endIndex) { + this.produceFromScopes(stack.contentNameScopesList, endIndex); + } + produceFromScopes(scopesList, endIndex) { + if (this._lastTokenEndIndex >= endIndex) { + return; + } + if (this._emitBinaryTokens) { + let metadata = scopesList?.tokenAttributes ?? 0; + let containsBalancedBrackets = false; + if (this.balancedBracketSelectors?.matchesAlways) { + containsBalancedBrackets = true; + } + if (this._tokenTypeOverrides.length > 0 || (this.balancedBracketSelectors && !this.balancedBracketSelectors.matchesAlways && !this.balancedBracketSelectors.matchesNever)) { + // Only generate scope array when required to improve performance + const scopes = scopesList?.getScopeNames() ?? []; + for (const tokenType of this._tokenTypeOverrides) { + if (tokenType.matcher(scopes)) { + metadata = encodedTokenAttributes_1.EncodedTokenAttributes.set(metadata, 0, (0, encodedTokenAttributes_1.toOptionalTokenType)(tokenType.type), null, -1 /* FontStyle.NotSet */, 0, 0); + } + } + if (this.balancedBracketSelectors) { + containsBalancedBrackets = this.balancedBracketSelectors.match(scopes); + } + } + if (containsBalancedBrackets) { + metadata = encodedTokenAttributes_1.EncodedTokenAttributes.set(metadata, 0, 8 /* OptionalStandardTokenType.NotSet */, containsBalancedBrackets, -1 /* FontStyle.NotSet */, 0, 0); + } + if (this._binaryTokens.length > 0 && this._binaryTokens[this._binaryTokens.length - 1] === metadata) { + // no need to push a token with the same metadata + this._lastTokenEndIndex = endIndex; + return; + } + if (debug_1.DebugFlags.InDebugMode) { + const scopes = scopesList?.getScopeNames() ?? []; + console.log(' token: |' + this._lineText.substring(this._lastTokenEndIndex, endIndex).replace(/\n$/, '\\n') + '|'); + for (let k = 0; k < scopes.length; k++) { + console.log(' * ' + scopes[k]); + } + } + this._binaryTokens.push(this._lastTokenEndIndex); + this._binaryTokens.push(metadata); + this._lastTokenEndIndex = endIndex; + return; + } + const scopes = scopesList?.getScopeNames() ?? []; + if (debug_1.DebugFlags.InDebugMode) { + console.log(' token: |' + this._lineText.substring(this._lastTokenEndIndex, endIndex).replace(/\n$/, '\\n') + '|'); + for (let k = 0; k < scopes.length; k++) { + console.log(' * ' + scopes[k]); + } + } + this._tokens.push({ + startIndex: this._lastTokenEndIndex, + endIndex: endIndex, + // value: lineText.substring(lastTokenEndIndex, endIndex), + scopes: scopes + }); + this._lastTokenEndIndex = endIndex; + } + getResult(stack, lineLength) { + if (this._tokens.length > 0 && this._tokens[this._tokens.length - 1].startIndex === lineLength - 1) { + // pop produced token for newline + this._tokens.pop(); + } + if (this._tokens.length === 0) { + this._lastTokenEndIndex = -1; + this.produce(stack, lineLength); + this._tokens[this._tokens.length - 1].startIndex = 0; + } + return this._tokens; + } + getBinaryResult(stack, lineLength) { + if (this._binaryTokens.length > 0 && this._binaryTokens[this._binaryTokens.length - 2] === lineLength - 1) { + // pop produced token for newline + this._binaryTokens.pop(); + this._binaryTokens.pop(); + } + if (this._binaryTokens.length === 0) { + this._lastTokenEndIndex = -1; + this.produce(stack, lineLength); + this._binaryTokens[this._binaryTokens.length - 2] = 0; + } + const result = new Uint32Array(this._binaryTokens.length); + for (let i = 0, len = this._binaryTokens.length; i < len; i++) { + result[i] = this._binaryTokens[i]; + } + return result; + } +} +exports.LineTokens = LineTokens; diff --git a/out/textmate/grammar/grammarDependencies.js b/out/textmate/grammar/grammarDependencies.js new file mode 100644 index 0000000..69580a1 --- /dev/null +++ b/out/textmate/grammar/grammarDependencies.js @@ -0,0 +1,240 @@ +"use strict"; +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.parseInclude = exports.TopLevelRepositoryReference = exports.TopLevelReference = exports.RelativeReference = exports.SelfReference = exports.BaseReference = exports.ScopeDependencyProcessor = exports.ExternalReferenceCollector = exports.TopLevelRepositoryRuleReference = exports.TopLevelRuleReference = void 0; +const utils_1 = require("../utils"); +/** + * References the top level rule of a grammar with the given scope name. +*/ +class TopLevelRuleReference { + scopeName; + constructor(scopeName) { + this.scopeName = scopeName; + } + toKey() { + return this.scopeName; + } +} +exports.TopLevelRuleReference = TopLevelRuleReference; +/** + * References a rule of a grammar in the top level repository section with the given name. +*/ +class TopLevelRepositoryRuleReference { + scopeName; + ruleName; + constructor(scopeName, ruleName) { + this.scopeName = scopeName; + this.ruleName = ruleName; + } + toKey() { + return `${this.scopeName}#${this.ruleName}`; + } +} +exports.TopLevelRepositoryRuleReference = TopLevelRepositoryRuleReference; +class ExternalReferenceCollector { + _references = []; + _seenReferenceKeys = new Set(); + get references() { + return this._references; + } + visitedRule = new Set(); + add(reference) { + const key = reference.toKey(); + if (this._seenReferenceKeys.has(key)) { + return; + } + this._seenReferenceKeys.add(key); + this._references.push(reference); + } +} +exports.ExternalReferenceCollector = ExternalReferenceCollector; +class ScopeDependencyProcessor { + repo; + initialScopeName; + seenFullScopeRequests = new Set(); + seenPartialScopeRequests = new Set(); + Q; + constructor(repo, initialScopeName) { + this.repo = repo; + this.initialScopeName = initialScopeName; + this.seenFullScopeRequests.add(this.initialScopeName); + this.Q = [new TopLevelRuleReference(this.initialScopeName)]; + } + processQueue() { + const q = this.Q; + this.Q = []; + const deps = new ExternalReferenceCollector(); + for (const dep of q) { + collectReferencesOfReference(dep, this.initialScopeName, this.repo, deps); + } + for (const dep of deps.references) { + if (dep instanceof TopLevelRuleReference) { + if (this.seenFullScopeRequests.has(dep.scopeName)) { + // already processed + continue; + } + this.seenFullScopeRequests.add(dep.scopeName); + this.Q.push(dep); + } + else { + if (this.seenFullScopeRequests.has(dep.scopeName)) { + // already processed in full + continue; + } + if (this.seenPartialScopeRequests.has(dep.toKey())) { + // already processed + continue; + } + this.seenPartialScopeRequests.add(dep.toKey()); + this.Q.push(dep); + } + } + } +} +exports.ScopeDependencyProcessor = ScopeDependencyProcessor; +function collectReferencesOfReference(reference, baseGrammarScopeName, repo, result) { + const selfGrammar = repo.lookup(reference.scopeName); + if (!selfGrammar) { + if (reference.scopeName === baseGrammarScopeName) { + throw new Error(`No grammar provided for <${baseGrammarScopeName}>`); + } + return; + } + const baseGrammar = repo.lookup(baseGrammarScopeName); + if (reference instanceof TopLevelRuleReference) { + collectExternalReferencesInTopLevelRule({ baseGrammar, selfGrammar }, result); + } + else { + collectExternalReferencesInTopLevelRepositoryRule(reference.ruleName, { baseGrammar, selfGrammar, repository: selfGrammar.repository }, result); + } + const injections = repo.injections(reference.scopeName); + if (injections) { + for (const injection of injections) { + result.add(new TopLevelRuleReference(injection)); + } + } +} +function collectExternalReferencesInTopLevelRepositoryRule(ruleName, context, result) { + if (context.repository && context.repository[ruleName]) { + const rule = context.repository[ruleName]; + collectExternalReferencesInRules([rule], context, result); + } +} +function collectExternalReferencesInTopLevelRule(context, result) { + if (context.selfGrammar.patterns && Array.isArray(context.selfGrammar.patterns)) { + collectExternalReferencesInRules(context.selfGrammar.patterns, { ...context, repository: context.selfGrammar.repository }, result); + } + if (context.selfGrammar.injections) { + collectExternalReferencesInRules(Object.values(context.selfGrammar.injections), { ...context, repository: context.selfGrammar.repository }, result); + } +} +function collectExternalReferencesInRules(rules, context, result) { + for (const rule of rules) { + if (result.visitedRule.has(rule)) { + continue; + } + result.visitedRule.add(rule); + const patternRepository = rule.repository ? (0, utils_1.mergeObjects)({}, context.repository, rule.repository) : context.repository; + if (Array.isArray(rule.patterns)) { + collectExternalReferencesInRules(rule.patterns, { ...context, repository: patternRepository }, result); + } + const include = rule.include; + if (!include) { + continue; + } + const reference = parseInclude(include); + switch (reference.kind) { + case 0 /* IncludeReferenceKind.Base */: + collectExternalReferencesInTopLevelRule({ ...context, selfGrammar: context.baseGrammar }, result); + break; + case 1 /* IncludeReferenceKind.Self */: + collectExternalReferencesInTopLevelRule(context, result); + break; + case 2 /* IncludeReferenceKind.RelativeReference */: + collectExternalReferencesInTopLevelRepositoryRule(reference.ruleName, { ...context, repository: patternRepository }, result); + break; + case 3 /* IncludeReferenceKind.TopLevelReference */: + case 4 /* IncludeReferenceKind.TopLevelRepositoryReference */: + const selfGrammar = reference.scopeName === context.selfGrammar.scopeName + ? context.selfGrammar + : reference.scopeName === context.baseGrammar.scopeName + ? context.baseGrammar + : undefined; + if (selfGrammar) { + const newContext = { baseGrammar: context.baseGrammar, selfGrammar, repository: patternRepository }; + if (reference.kind === 4 /* IncludeReferenceKind.TopLevelRepositoryReference */) { + collectExternalReferencesInTopLevelRepositoryRule(reference.ruleName, newContext, result); + } + else { + collectExternalReferencesInTopLevelRule(newContext, result); + } + } + else { + if (reference.kind === 4 /* IncludeReferenceKind.TopLevelRepositoryReference */) { + result.add(new TopLevelRepositoryRuleReference(reference.scopeName, reference.ruleName)); + } + else { + result.add(new TopLevelRuleReference(reference.scopeName)); + } + } + break; + } + } +} +class BaseReference { + kind = 0 /* IncludeReferenceKind.Base */; +} +exports.BaseReference = BaseReference; +class SelfReference { + kind = 1 /* IncludeReferenceKind.Self */; +} +exports.SelfReference = SelfReference; +class RelativeReference { + ruleName; + kind = 2 /* IncludeReferenceKind.RelativeReference */; + constructor(ruleName) { + this.ruleName = ruleName; + } +} +exports.RelativeReference = RelativeReference; +class TopLevelReference { + scopeName; + kind = 3 /* IncludeReferenceKind.TopLevelReference */; + constructor(scopeName) { + this.scopeName = scopeName; + } +} +exports.TopLevelReference = TopLevelReference; +class TopLevelRepositoryReference { + scopeName; + ruleName; + kind = 4 /* IncludeReferenceKind.TopLevelRepositoryReference */; + constructor(scopeName, ruleName) { + this.scopeName = scopeName; + this.ruleName = ruleName; + } +} +exports.TopLevelRepositoryReference = TopLevelRepositoryReference; +function parseInclude(include) { + if (include === '$base') { + return new BaseReference(); + } + else if (include === '$self') { + return new SelfReference(); + } + const indexOfSharp = include.indexOf("#"); + if (indexOfSharp === -1) { + return new TopLevelReference(include); + } + else if (indexOfSharp === 0) { + return new RelativeReference(include.substring(1)); + } + else { + const scopeName = include.substring(0, indexOfSharp); + const ruleName = include.substring(indexOfSharp + 1); + return new TopLevelRepositoryReference(scopeName, ruleName); + } +} +exports.parseInclude = parseInclude; diff --git a/out/textmate/grammar/index.js b/out/textmate/grammar/index.js new file mode 100644 index 0000000..4151ac5 --- /dev/null +++ b/out/textmate/grammar/index.js @@ -0,0 +1,20 @@ +"use strict"; +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +__exportStar(require("./grammar"), exports); diff --git a/out/textmate/grammar/tokenizeString.js b/out/textmate/grammar/tokenizeString.js new file mode 100644 index 0000000..361da2c --- /dev/null +++ b/out/textmate/grammar/tokenizeString.js @@ -0,0 +1,462 @@ +"use strict"; +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.LocalStackElement = exports._tokenizeString = void 0; +const debug_1 = require("../debug"); +const onigLib_1 = require("../onigLib"); +const rule_1 = require("../rule"); +const utils_1 = require("../utils"); +class TokenizeStringResult { + stack; + stoppedEarly; + constructor(stack, stoppedEarly) { + this.stack = stack; + this.stoppedEarly = stoppedEarly; + } +} +/** + * Tokenize a string + * @param grammar + * @param lineText + * @param isFirstLine + * @param linePos + * @param stack + * @param lineTokens + * @param checkWhileConditions + * @param timeLimit Use `0` to indicate no time limit + * @returns the StackElement or StackElement.TIME_LIMIT_REACHED if the time limit has been reached + */ +function _tokenizeString(grammar, lineText, isFirstLine, linePos, stack, lineTokens, checkWhileConditions, timeLimit) { + const lineLength = lineText.content.length; + let STOP = false; + let anchorPosition = -1; + if (checkWhileConditions) { + const whileCheckResult = _checkWhileConditions(grammar, lineText, isFirstLine, linePos, stack, lineTokens); + stack = whileCheckResult.stack; + linePos = whileCheckResult.linePos; + isFirstLine = whileCheckResult.isFirstLine; + anchorPosition = whileCheckResult.anchorPosition; + } + const startTime = Date.now(); + while (!STOP) { + if (timeLimit !== 0) { + const elapsedTime = Date.now() - startTime; + if (elapsedTime > timeLimit) { + return new TokenizeStringResult(stack, true); + } + } + scanNext(); // potentially modifies linePos && anchorPosition + } + return new TokenizeStringResult(stack, false); + function scanNext() { + if (debug_1.DebugFlags.InDebugMode) { + console.log(""); + console.log(`@@scanNext ${linePos}: |${lineText.content + .substr(linePos) + .replace(/\n$/, "\\n")}|`); + } + const r = matchRuleOrInjections(grammar, lineText, isFirstLine, linePos, stack, anchorPosition); + // @ts-ignore + grammar.rules.push(r); + // grammar.rules.push( + // { + // ...r, + // ...{ + // lineText: lineText, + // isFirstLine: isFirstLine, + // linePos: linePos, + // // stack: stack, + // anchorPosition: anchorPosition, + // } + // } + // ); + if (!r) { + if (debug_1.DebugFlags.InDebugMode) { + console.log(" no more matches."); + } + // No match + lineTokens.produce(stack, lineLength); + STOP = true; + return; + } + const captureIndices = r.captureIndices; + const matchedRuleId = r.matchedRuleId; + const hasAdvanced = captureIndices && captureIndices.length > 0 + ? captureIndices[0].end > linePos + : false; + if (matchedRuleId === rule_1.endRuleId) { + // We matched the `end` for this rule => pop it + const poppedRule = stack.getRule(grammar); + if (debug_1.DebugFlags.InDebugMode) { + console.log(" popping " + + poppedRule.debugName + + " - " + + poppedRule.debugEndRegExp); + } + lineTokens.produce(stack, captureIndices[0].start); + stack = stack.withContentNameScopesList(stack.nameScopesList); + handleCaptures(grammar, lineText, isFirstLine, stack, lineTokens, poppedRule.endCaptures, captureIndices); + lineTokens.produce(stack, captureIndices[0].end); + // pop + const popped = stack; + stack = stack.parent; + anchorPosition = popped.getAnchorPos(); + if (!hasAdvanced && popped.getEnterPos() === linePos) { + // Grammar pushed & popped a rule without advancing + if (debug_1.DebugFlags.InDebugMode) { + console.error("[1] - Grammar is in an endless loop - Grammar pushed & popped a rule without advancing"); + } + // See https://github.com/Microsoft/vscode-textmate/issues/12 + // Let's assume this was a mistake by the grammar author and the intent was to continue in this state + stack = popped; + lineTokens.produce(stack, lineLength); + STOP = true; + return; + } + } + else { + // We matched a rule! + const _rule = grammar.getRule(matchedRuleId); + lineTokens.produce(stack, captureIndices[0].start); + const beforePush = stack; + // push it on the stack rule + const scopeName = _rule.getName(lineText.content, captureIndices); + const nameScopesList = stack.contentNameScopesList.pushAttributed(scopeName, grammar); + stack = stack.push(matchedRuleId, linePos, anchorPosition, captureIndices[0].end === lineLength, null, nameScopesList, nameScopesList); + if (_rule instanceof rule_1.BeginEndRule) { + const pushedRule = _rule; + if (debug_1.DebugFlags.InDebugMode) { + console.log(" pushing " + + pushedRule.debugName + + " - " + + pushedRule.debugBeginRegExp); + } + handleCaptures(grammar, lineText, isFirstLine, stack, lineTokens, pushedRule.beginCaptures, captureIndices); + lineTokens.produce(stack, captureIndices[0].end); + anchorPosition = captureIndices[0].end; + const contentName = pushedRule.getContentName(lineText.content, captureIndices); + const contentNameScopesList = nameScopesList.pushAttributed(contentName, grammar); + stack = stack.withContentNameScopesList(contentNameScopesList); + if (pushedRule.endHasBackReferences) { + stack = stack.withEndRule(pushedRule.getEndWithResolvedBackReferences(lineText.content, captureIndices)); + } + if (!hasAdvanced && beforePush.hasSameRuleAs(stack)) { + // Grammar pushed the same rule without advancing + if (debug_1.DebugFlags.InDebugMode) { + console.error("[2] - Grammar is in an endless loop - Grammar pushed the same rule without advancing"); + } + stack = stack.pop(); + lineTokens.produce(stack, lineLength); + STOP = true; + return; + } + } + else if (_rule instanceof rule_1.BeginWhileRule) { + const pushedRule = _rule; + if (debug_1.DebugFlags.InDebugMode) { + console.log(" pushing " + pushedRule.debugName); + } + handleCaptures(grammar, lineText, isFirstLine, stack, lineTokens, pushedRule.beginCaptures, captureIndices); + lineTokens.produce(stack, captureIndices[0].end); + anchorPosition = captureIndices[0].end; + const contentName = pushedRule.getContentName(lineText.content, captureIndices); + const contentNameScopesList = nameScopesList.pushAttributed(contentName, grammar); + stack = stack.withContentNameScopesList(contentNameScopesList); + if (pushedRule.whileHasBackReferences) { + stack = stack.withEndRule(pushedRule.getWhileWithResolvedBackReferences(lineText.content, captureIndices)); + } + if (!hasAdvanced && beforePush.hasSameRuleAs(stack)) { + // Grammar pushed the same rule without advancing + if (debug_1.DebugFlags.InDebugMode) { + console.error("[3] - Grammar is in an endless loop - Grammar pushed the same rule without advancing"); + } + stack = stack.pop(); + lineTokens.produce(stack, lineLength); + STOP = true; + return; + } + } + else { + const matchingRule = _rule; + if (debug_1.DebugFlags.InDebugMode) { + console.log(" matched " + + matchingRule.debugName + + " - " + + matchingRule.debugMatchRegExp); + } + handleCaptures(grammar, lineText, isFirstLine, stack, lineTokens, matchingRule.captures, captureIndices); + lineTokens.produce(stack, captureIndices[0].end); + // pop rule immediately since it is a MatchRule + stack = stack.pop(); + if (!hasAdvanced) { + // Grammar is not advancing, nor is it pushing/popping + if (debug_1.DebugFlags.InDebugMode) { + console.error("[4] - Grammar is in an endless loop - Grammar is not advancing, nor is it pushing/popping"); + } + stack = stack.safePop(); + lineTokens.produce(stack, lineLength); + STOP = true; + return; + } + } + } + if (captureIndices[0].end > linePos) { + // Advance stream + linePos = captureIndices[0].end; + isFirstLine = false; + } + } +} +exports._tokenizeString = _tokenizeString; +/** + * Walk the stack from bottom to top, and check each while condition in this order. + * If any fails, cut off the entire stack above the failed while condition. While conditions + * may also advance the linePosition. + */ +function _checkWhileConditions(grammar, lineText, isFirstLine, linePos, stack, lineTokens) { + let anchorPosition = (stack.beginRuleCapturedEOL ? 0 : -1); + const whileRules = []; + for (let node = stack; node; node = node.pop()) { + const nodeRule = node.getRule(grammar); + if (nodeRule instanceof rule_1.BeginWhileRule) { + whileRules.push({ + rule: nodeRule, + stack: node + }); + } + } + for (let whileRule = whileRules.pop(); whileRule; whileRule = whileRules.pop()) { + const { ruleScanner, findOptions } = prepareRuleWhileSearch(whileRule.rule, grammar, whileRule.stack.endRule, isFirstLine, linePos === anchorPosition); + const r = ruleScanner.findNextMatchSync(lineText, linePos, findOptions); + if (debug_1.DebugFlags.InDebugMode) { + console.log(' scanning for while rule'); + console.log(ruleScanner.toString()); + } + if (r) { + const matchedRuleId = r.ruleId; + if (matchedRuleId !== rule_1.whileRuleId) { + // we shouldn't end up here + stack = whileRule.stack.pop(); + break; + } + if (r.captureIndices && r.captureIndices.length) { + lineTokens.produce(whileRule.stack, r.captureIndices[0].start); + handleCaptures(grammar, lineText, isFirstLine, whileRule.stack, lineTokens, whileRule.rule.whileCaptures, r.captureIndices); + lineTokens.produce(whileRule.stack, r.captureIndices[0].end); + anchorPosition = r.captureIndices[0].end; + if (r.captureIndices[0].end > linePos) { + linePos = r.captureIndices[0].end; + isFirstLine = false; + } + } + } + else { + if (debug_1.DebugFlags.InDebugMode) { + console.log(' popping ' + whileRule.rule.debugName + ' - ' + whileRule.rule.debugWhileRegExp); + } + stack = whileRule.stack.pop(); + break; + } + } + return { stack: stack, linePos: linePos, anchorPosition: anchorPosition, isFirstLine: isFirstLine }; +} +function matchRuleOrInjections(grammar, lineText, isFirstLine, linePos, stack, anchorPosition) { + // Look for normal grammar rule + const matchResult = matchRule(grammar, lineText, isFirstLine, linePos, stack, anchorPosition); + // Look for injected rules + const injections = grammar.getInjections(); + if (injections.length === 0) { + // No injections whatsoever => early return + return matchResult; + } + const injectionResult = matchInjections(injections, grammar, lineText, isFirstLine, linePos, stack, anchorPosition); + if (!injectionResult) { + // No injections matched => early return + return matchResult; + } + if (!matchResult) { + // Only injections matched => early return + return injectionResult; + } + // Decide if `matchResult` or `injectionResult` should win + const matchResultScore = matchResult.captureIndices[0].start; + const injectionResultScore = injectionResult.captureIndices[0].start; + if (injectionResultScore < matchResultScore || (injectionResult.priorityMatch && injectionResultScore === matchResultScore)) { + // injection won! + return injectionResult; + } + return matchResult; +} +function matchRule(grammar, lineText, isFirstLine, linePos, stack, anchorPosition) { + const rule = stack.getRule(grammar); + const { ruleScanner, findOptions } = prepareRuleSearch(rule, grammar, stack.endRule, isFirstLine, linePos === anchorPosition); + let perfStart = 0; + if (debug_1.DebugFlags.InDebugMode) { + perfStart = (0, utils_1.performanceNow)(); + } + const r = ruleScanner.findNextMatchSync(lineText, linePos, findOptions); + if (debug_1.DebugFlags.InDebugMode) { + const elapsedMillis = (0, utils_1.performanceNow)() - perfStart; + if (elapsedMillis > 5) { + console.warn(`Rule ${rule.debugName} (${rule.id}) matching took ${elapsedMillis} against '${lineText}'`); + } + console.log(` scanning for (linePos: ${linePos}, anchorPosition: ${anchorPosition})`); + console.log(ruleScanner.toString()); + if (r) { + console.log(`matched rule id: ${r.ruleId} from ${r.captureIndices[0].start} to ${r.captureIndices[0].end}`); + } + } + if (r) { + return { + captureIndices: r.captureIndices, + matchedRuleId: r.ruleId + }; + } + return null; +} +function matchInjections(injections, grammar, lineText, isFirstLine, linePos, stack, anchorPosition) { + // The lower the better + let bestMatchRating = Number.MAX_VALUE; + let bestMatchCaptureIndices = null; + let bestMatchRuleId; + let bestMatchResultPriority = 0; + const scopes = stack.contentNameScopesList.getScopeNames(); + for (let i = 0, len = injections.length; i < len; i++) { + const injection = injections[i]; + if (!injection.matcher(scopes)) { + // injection selector doesn't match stack + continue; + } + const rule = grammar.getRule(injection.ruleId); + const { ruleScanner, findOptions } = prepareRuleSearch(rule, grammar, null, isFirstLine, linePos === anchorPosition); + const matchResult = ruleScanner.findNextMatchSync(lineText, linePos, findOptions); + if (!matchResult) { + continue; + } + if (debug_1.DebugFlags.InDebugMode) { + console.log(` matched injection: ${injection.debugSelector}`); + console.log(ruleScanner.toString()); + } + const matchRating = matchResult.captureIndices[0].start; + if (matchRating >= bestMatchRating) { + // Injections are sorted by priority, so the previous injection had a better or equal priority + continue; + } + bestMatchRating = matchRating; + bestMatchCaptureIndices = matchResult.captureIndices; + bestMatchRuleId = matchResult.ruleId; + bestMatchResultPriority = injection.priority; + if (bestMatchRating === linePos) { + // No more need to look at the rest of the injections. + break; + } + } + if (bestMatchCaptureIndices) { + return { + priorityMatch: bestMatchResultPriority === -1, + captureIndices: bestMatchCaptureIndices, + matchedRuleId: bestMatchRuleId + }; + } + return null; +} +function prepareRuleSearch(rule, grammar, endRegexSource, allowA, allowG) { + if (debug_1.UseOnigurumaFindOptions) { + const ruleScanner = rule.compile(grammar, endRegexSource); + const findOptions = getFindOptions(allowA, allowG); + return { ruleScanner, findOptions }; + } + const ruleScanner = rule.compileAG(grammar, endRegexSource, allowA, allowG); + return { ruleScanner, findOptions: 0 /* FindOption.None */ }; +} +function prepareRuleWhileSearch(rule, grammar, endRegexSource, allowA, allowG) { + if (debug_1.UseOnigurumaFindOptions) { + const ruleScanner = rule.compileWhile(grammar, endRegexSource); + const findOptions = getFindOptions(allowA, allowG); + return { ruleScanner, findOptions }; + } + const ruleScanner = rule.compileWhileAG(grammar, endRegexSource, allowA, allowG); + return { ruleScanner, findOptions: 0 /* FindOption.None */ }; +} +function getFindOptions(allowA, allowG) { + let options = 0 /* FindOption.None */; + if (!allowA) { + options |= 1 /* FindOption.NotBeginString */; + } + if (!allowG) { + options |= 4 /* FindOption.NotBeginPosition */; + } + return options; +} +function handleCaptures(grammar, lineText, isFirstLine, stack, lineTokens, captures, captureIndices) { + if (captures.length === 0) { + return; + } + const lineTextContent = lineText.content; + const len = Math.min(captures.length, captureIndices.length); + const localStack = []; + const maxEnd = captureIndices[0].end; + for (let i = 0; i < len; i++) { + const captureRule = captures[i]; + if (captureRule === null) { + // Not interested + continue; + } + const captureIndex = captureIndices[i]; + if (captureIndex.length === 0) { + // Nothing really captured + continue; + } + if (captureIndex.start > maxEnd) { + // Capture going beyond consumed string + break; + } + // pop captures while needed + while (localStack.length > 0 && localStack[localStack.length - 1].endPos <= captureIndex.start) { + // pop! + lineTokens.produceFromScopes(localStack[localStack.length - 1].scopes, localStack[localStack.length - 1].endPos); + localStack.pop(); + } + if (localStack.length > 0) { + lineTokens.produceFromScopes(localStack[localStack.length - 1].scopes, captureIndex.start); + } + else { + lineTokens.produce(stack, captureIndex.start); + } + if (captureRule.retokenizeCapturedWithRuleId) { + // the capture requires additional matching + const scopeName = captureRule.getName(lineTextContent, captureIndices); + const nameScopesList = stack.contentNameScopesList.pushAttributed(scopeName, grammar); + const contentName = captureRule.getContentName(lineTextContent, captureIndices); + const contentNameScopesList = nameScopesList.pushAttributed(contentName, grammar); + const stackClone = stack.push(captureRule.retokenizeCapturedWithRuleId, captureIndex.start, -1, false, null, nameScopesList, contentNameScopesList); + const onigSubStr = grammar.createOnigString(lineTextContent.substring(0, captureIndex.end)); + _tokenizeString(grammar, onigSubStr, (isFirstLine && captureIndex.start === 0), captureIndex.start, stackClone, lineTokens, false, /* no time limit */ 0); + (0, onigLib_1.disposeOnigString)(onigSubStr); + continue; + } + const captureRuleScopeName = captureRule.getName(lineTextContent, captureIndices); + if (captureRuleScopeName !== null) { + // push + const base = localStack.length > 0 ? localStack[localStack.length - 1].scopes : stack.contentNameScopesList; + const captureRuleScopesList = base.pushAttributed(captureRuleScopeName, grammar); + localStack.push(new LocalStackElement(captureRuleScopesList, captureIndex.end)); + } + } + while (localStack.length > 0) { + // pop! + lineTokens.produceFromScopes(localStack[localStack.length - 1].scopes, localStack[localStack.length - 1].endPos); + localStack.pop(); + } +} +class LocalStackElement { + scopes; + endPos; + constructor(scopes, endPos) { + this.scopes = scopes; + this.endPos = endPos; + } +} +exports.LocalStackElement = LocalStackElement; diff --git a/out/textmate/json.js b/out/textmate/json.js new file mode 100644 index 0000000..3cbbcee --- /dev/null +++ b/out/textmate/json.js @@ -0,0 +1,440 @@ +"use strict"; +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.parseJSON = void 0; +function doFail(streamState, msg) { + // console.log('Near offset ' + streamState.pos + ': ' + msg + ' ~~~' + streamState.source.substr(streamState.pos, 50) + '~~~'); + throw new Error('Near offset ' + streamState.pos + ': ' + msg + ' ~~~' + streamState.source.substr(streamState.pos, 50) + '~~~'); +} +function parseJSON(source, filename, withMetadata) { + let streamState = new JSONStreamState(source); + let token = new JSONToken(); + let state = 0 /* JSONState.ROOT_STATE */; + let cur = null; + let stateStack = []; + let objStack = []; + function pushState() { + stateStack.push(state); + objStack.push(cur); + } + function popState() { + state = stateStack.pop(); + cur = objStack.pop(); + } + function fail(msg) { + doFail(streamState, msg); + } + while (nextJSONToken(streamState, token)) { + if (state === 0 /* JSONState.ROOT_STATE */) { + if (cur !== null) { + fail('too many constructs in root'); + } + if (token.type === 3 /* JSONTokenType.LEFT_CURLY_BRACKET */) { + cur = {}; + if (withMetadata) { + cur.$vscodeTextmateLocation = token.toLocation(filename); + } + pushState(); + state = 1 /* JSONState.DICT_STATE */; + continue; + } + if (token.type === 2 /* JSONTokenType.LEFT_SQUARE_BRACKET */) { + cur = []; + pushState(); + state = 4 /* JSONState.ARR_STATE */; + continue; + } + fail('unexpected token in root'); + } + if (state === 2 /* JSONState.DICT_STATE_COMMA */) { + if (token.type === 5 /* JSONTokenType.RIGHT_CURLY_BRACKET */) { + popState(); + continue; + } + if (token.type === 7 /* JSONTokenType.COMMA */) { + state = 3 /* JSONState.DICT_STATE_NO_CLOSE */; + continue; + } + fail('expected , or }'); + } + if (state === 1 /* JSONState.DICT_STATE */ || state === 3 /* JSONState.DICT_STATE_NO_CLOSE */) { + if (state === 1 /* JSONState.DICT_STATE */ && token.type === 5 /* JSONTokenType.RIGHT_CURLY_BRACKET */) { + popState(); + continue; + } + if (token.type === 1 /* JSONTokenType.STRING */) { + let keyValue = token.value; + if (!nextJSONToken(streamState, token) || /*TS bug*/ token.type !== 6 /* JSONTokenType.COLON */) { + fail('expected colon'); + } + if (!nextJSONToken(streamState, token)) { + fail('expected value'); + } + state = 2 /* JSONState.DICT_STATE_COMMA */; + if (token.type === 1 /* JSONTokenType.STRING */) { + cur[keyValue] = token.value; + continue; + } + if (token.type === 8 /* JSONTokenType.NULL */) { + cur[keyValue] = null; + continue; + } + if (token.type === 9 /* JSONTokenType.TRUE */) { + cur[keyValue] = true; + continue; + } + if (token.type === 10 /* JSONTokenType.FALSE */) { + cur[keyValue] = false; + continue; + } + if (token.type === 11 /* JSONTokenType.NUMBER */) { + cur[keyValue] = parseFloat(token.value); + continue; + } + if (token.type === 2 /* JSONTokenType.LEFT_SQUARE_BRACKET */) { + let newArr = []; + cur[keyValue] = newArr; + pushState(); + state = 4 /* JSONState.ARR_STATE */; + cur = newArr; + continue; + } + if (token.type === 3 /* JSONTokenType.LEFT_CURLY_BRACKET */) { + let newDict = {}; + if (withMetadata) { + newDict.$vscodeTextmateLocation = token.toLocation(filename); + } + cur[keyValue] = newDict; + pushState(); + state = 1 /* JSONState.DICT_STATE */; + cur = newDict; + continue; + } + } + fail('unexpected token in dict'); + } + if (state === 5 /* JSONState.ARR_STATE_COMMA */) { + if (token.type === 4 /* JSONTokenType.RIGHT_SQUARE_BRACKET */) { + popState(); + continue; + } + if (token.type === 7 /* JSONTokenType.COMMA */) { + state = 6 /* JSONState.ARR_STATE_NO_CLOSE */; + continue; + } + fail('expected , or ]'); + } + if (state === 4 /* JSONState.ARR_STATE */ || state === 6 /* JSONState.ARR_STATE_NO_CLOSE */) { + if (state === 4 /* JSONState.ARR_STATE */ && token.type === 4 /* JSONTokenType.RIGHT_SQUARE_BRACKET */) { + popState(); + continue; + } + state = 5 /* JSONState.ARR_STATE_COMMA */; + if (token.type === 1 /* JSONTokenType.STRING */) { + cur.push(token.value); + continue; + } + if (token.type === 8 /* JSONTokenType.NULL */) { + cur.push(null); + continue; + } + if (token.type === 9 /* JSONTokenType.TRUE */) { + cur.push(true); + continue; + } + if (token.type === 10 /* JSONTokenType.FALSE */) { + cur.push(false); + continue; + } + if (token.type === 11 /* JSONTokenType.NUMBER */) { + cur.push(parseFloat(token.value)); + continue; + } + if (token.type === 2 /* JSONTokenType.LEFT_SQUARE_BRACKET */) { + let newArr = []; + cur.push(newArr); + pushState(); + state = 4 /* JSONState.ARR_STATE */; + cur = newArr; + continue; + } + if (token.type === 3 /* JSONTokenType.LEFT_CURLY_BRACKET */) { + let newDict = {}; + if (withMetadata) { + newDict.$vscodeTextmateLocation = token.toLocation(filename); + } + cur.push(newDict); + pushState(); + state = 1 /* JSONState.DICT_STATE */; + cur = newDict; + continue; + } + fail('unexpected token in array'); + } + fail('unknown state'); + } + if (objStack.length !== 0) { + fail('unclosed constructs'); + } + return cur; +} +exports.parseJSON = parseJSON; +class JSONStreamState { + source; + pos; + len; + line; + char; + constructor(source) { + this.source = source; + this.pos = 0; + this.len = source.length; + this.line = 1; + this.char = 0; + } +} +class JSONToken { + value; + type; + offset; + len; + line; /* 1 based line number */ + char; + constructor() { + this.value = null; + this.type = 0 /* JSONTokenType.UNKNOWN */; + this.offset = -1; + this.len = -1; + this.line = -1; + this.char = -1; + } + toLocation(filename) { + return { + filename: filename, + line: this.line, + char: this.char + }; + } +} +/** + * precondition: the string is known to be valid JSON (https://www.ietf.org/rfc/rfc4627.txt) + */ +function nextJSONToken(_state, _out) { + _out.value = null; + _out.type = 0 /* JSONTokenType.UNKNOWN */; + _out.offset = -1; + _out.len = -1; + _out.line = -1; + _out.char = -1; + let source = _state.source; + let pos = _state.pos; + let len = _state.len; + let line = _state.line; + let char = _state.char; + //------------------------ skip whitespace + let chCode; + do { + if (pos >= len) { + return false; /*EOS*/ + } + chCode = source.charCodeAt(pos); + if (chCode === 32 /* ChCode.SPACE */ || chCode === 9 /* ChCode.HORIZONTAL_TAB */ || chCode === 13 /* ChCode.CARRIAGE_RETURN */) { + // regular whitespace + pos++; + char++; + continue; + } + if (chCode === 10 /* ChCode.LINE_FEED */) { + // newline + pos++; + line++; + char = 0; + continue; + } + // not whitespace + break; + } while (true); + _out.offset = pos; + _out.line = line; + _out.char = char; + if (chCode === 34 /* ChCode.QUOTATION_MARK */) { + //------------------------ strings + _out.type = 1 /* JSONTokenType.STRING */; + pos++; + char++; + do { + if (pos >= len) { + return false; /*EOS*/ + } + chCode = source.charCodeAt(pos); + pos++; + char++; + if (chCode === 92 /* ChCode.BACKSLASH */) { + // skip next char + pos++; + char++; + continue; + } + if (chCode === 34 /* ChCode.QUOTATION_MARK */) { + // end of the string + break; + } + } while (true); + _out.value = source.substring(_out.offset + 1, pos - 1).replace(/\\u([0-9A-Fa-f]{4})/g, (_, m0) => { + return String.fromCodePoint(parseInt(m0, 16)); + }).replace(/\\(.)/g, (_, m0) => { + switch (m0) { + case '"': return '"'; + case '\\': return '\\'; + case '/': return '/'; + case 'b': return '\b'; + case 'f': return '\f'; + case 'n': return '\n'; + case 'r': return '\r'; + case 't': return '\t'; + default: doFail(_state, 'invalid escape sequence'); + } + throw new Error('unreachable'); + }); + } + else if (chCode === 91 /* ChCode.LEFT_SQUARE_BRACKET */) { + _out.type = 2 /* JSONTokenType.LEFT_SQUARE_BRACKET */; + pos++; + char++; + } + else if (chCode === 123 /* ChCode.LEFT_CURLY_BRACKET */) { + _out.type = 3 /* JSONTokenType.LEFT_CURLY_BRACKET */; + pos++; + char++; + } + else if (chCode === 93 /* ChCode.RIGHT_SQUARE_BRACKET */) { + _out.type = 4 /* JSONTokenType.RIGHT_SQUARE_BRACKET */; + pos++; + char++; + } + else if (chCode === 125 /* ChCode.RIGHT_CURLY_BRACKET */) { + _out.type = 5 /* JSONTokenType.RIGHT_CURLY_BRACKET */; + pos++; + char++; + } + else if (chCode === 58 /* ChCode.COLON */) { + _out.type = 6 /* JSONTokenType.COLON */; + pos++; + char++; + } + else if (chCode === 44 /* ChCode.COMMA */) { + _out.type = 7 /* JSONTokenType.COMMA */; + pos++; + char++; + } + else if (chCode === 110 /* ChCode.n */) { + //------------------------ null + _out.type = 8 /* JSONTokenType.NULL */; + pos++; + char++; + chCode = source.charCodeAt(pos); + if (chCode !== 117 /* ChCode.u */) { + return false; /* INVALID */ + } + pos++; + char++; + chCode = source.charCodeAt(pos); + if (chCode !== 108 /* ChCode.l */) { + return false; /* INVALID */ + } + pos++; + char++; + chCode = source.charCodeAt(pos); + if (chCode !== 108 /* ChCode.l */) { + return false; /* INVALID */ + } + pos++; + char++; + } + else if (chCode === 116 /* ChCode.t */) { + //------------------------ true + _out.type = 9 /* JSONTokenType.TRUE */; + pos++; + char++; + chCode = source.charCodeAt(pos); + if (chCode !== 114 /* ChCode.r */) { + return false; /* INVALID */ + } + pos++; + char++; + chCode = source.charCodeAt(pos); + if (chCode !== 117 /* ChCode.u */) { + return false; /* INVALID */ + } + pos++; + char++; + chCode = source.charCodeAt(pos); + if (chCode !== 101 /* ChCode.e */) { + return false; /* INVALID */ + } + pos++; + char++; + } + else if (chCode === 102 /* ChCode.f */) { + //------------------------ false + _out.type = 10 /* JSONTokenType.FALSE */; + pos++; + char++; + chCode = source.charCodeAt(pos); + if (chCode !== 97 /* ChCode.a */) { + return false; /* INVALID */ + } + pos++; + char++; + chCode = source.charCodeAt(pos); + if (chCode !== 108 /* ChCode.l */) { + return false; /* INVALID */ + } + pos++; + char++; + chCode = source.charCodeAt(pos); + if (chCode !== 115 /* ChCode.s */) { + return false; /* INVALID */ + } + pos++; + char++; + chCode = source.charCodeAt(pos); + if (chCode !== 101 /* ChCode.e */) { + return false; /* INVALID */ + } + pos++; + char++; + } + else { + //------------------------ numbers + _out.type = 11 /* JSONTokenType.NUMBER */; + do { + if (pos >= len) { + return false; /*EOS*/ + } + chCode = source.charCodeAt(pos); + if (chCode === 46 /* ChCode.DOT */ + || (chCode >= 48 /* ChCode.D0 */ && chCode <= 57 /* ChCode.D9 */) + || (chCode === 101 /* ChCode.e */ || chCode === 69 /* ChCode.E */) + || (chCode === 45 /* ChCode.MINUS */ || chCode === 43 /* ChCode.PLUS */)) { + // looks like a piece of a number + pos++; + char++; + continue; + } + // pos--; char--; + break; + } while (true); + } + _out.len = pos - _out.offset; + if (_out.value === null) { + _out.value = source.substr(_out.offset, _out.len); + } + _state.pos = pos; + _state.line = line; + _state.char = char; + // console.log('PRODUCING TOKEN: ', _out.value, JSONTokenType[_out.type]); + return true; +} diff --git a/out/textmate/main.js b/out/textmate/main.js new file mode 100644 index 0000000..0896dbb --- /dev/null +++ b/out/textmate/main.js @@ -0,0 +1,114 @@ +"use strict"; +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.applyStateStackDiff = exports.diffStateStacksRefEq = exports.parseRawGrammar = exports.INITIAL = exports.Registry = void 0; +const grammar_1 = require("./grammar"); +const grammarReader = require("./parseRawGrammar"); +const registry_1 = require("./registry"); +const theme_1 = require("./theme"); +const grammarDependencies_1 = require("./grammar/grammarDependencies"); +const diffStateStacks_1 = require("./diffStateStacks"); +Object.defineProperty(exports, "applyStateStackDiff", { enumerable: true, get: function () { return diffStateStacks_1.applyStateStackDiff; } }); +Object.defineProperty(exports, "diffStateStacksRefEq", { enumerable: true, get: function () { return diffStateStacks_1.diffStateStacksRefEq; } }); +__exportStar(require("./onigLib"), exports); +/** + * The registry that will hold all grammars. + */ +class Registry { + _options; + _syncRegistry; + _ensureGrammarCache; + constructor(options) { + this._options = options; + this._syncRegistry = new registry_1.SyncRegistry(theme_1.Theme.createFromRawTheme(options.theme, options.colorMap), options.onigLib); + this._ensureGrammarCache = new Map(); + } + dispose() { + this._syncRegistry.dispose(); + } + /** + * Change the theme. Once called, no previous `ruleStack` should be used anymore. + */ + setTheme(theme, colorMap) { + this._syncRegistry.setTheme(theme_1.Theme.createFromRawTheme(theme, colorMap)); + } + /** + * Returns a lookup array for color ids. + */ + getColorMap() { + return this._syncRegistry.getColorMap(); + } + /** + * Load the grammar for `scopeName` and all referenced included grammars asynchronously. + * Please do not use language id 0. + */ + loadGrammarWithEmbeddedLanguages(initialScopeName, initialLanguage, embeddedLanguages) { + return this.loadGrammarWithConfiguration(initialScopeName, initialLanguage, { embeddedLanguages }); + } + /** + * Load the grammar for `scopeName` and all referenced included grammars asynchronously. + * Please do not use language id 0. + */ + loadGrammarWithConfiguration(initialScopeName, initialLanguage, configuration) { + return this._loadGrammar(initialScopeName, initialLanguage, configuration.embeddedLanguages, configuration.tokenTypes, new grammar_1.BalancedBracketSelectors(configuration.balancedBracketSelectors || [], configuration.unbalancedBracketSelectors || [])); + } + /** + * Load the grammar for `scopeName` and all referenced included grammars asynchronously. + */ + loadGrammar(initialScopeName) { + return this._loadGrammar(initialScopeName, 0, null, null, null); + } + async _loadGrammar(initialScopeName, initialLanguage, embeddedLanguages, tokenTypes, balancedBracketSelectors) { + const dependencyProcessor = new grammarDependencies_1.ScopeDependencyProcessor(this._syncRegistry, initialScopeName); + while (dependencyProcessor.Q.length > 0) { + await Promise.all(dependencyProcessor.Q.map((request) => this._loadSingleGrammar(request.scopeName))); + dependencyProcessor.processQueue(); + } + return this._grammarForScopeName(initialScopeName, initialLanguage, embeddedLanguages, tokenTypes, balancedBracketSelectors); + } + async _loadSingleGrammar(scopeName) { + if (!this._ensureGrammarCache.has(scopeName)) { + this._ensureGrammarCache.set(scopeName, this._doLoadSingleGrammar(scopeName)); + } + return this._ensureGrammarCache.get(scopeName); + } + async _doLoadSingleGrammar(scopeName) { + const grammar = await this._options.loadGrammar(scopeName); + if (grammar) { + const injections = typeof this._options.getInjections === "function" ? this._options.getInjections(scopeName) : undefined; + this._syncRegistry.addGrammar(grammar, injections); + } + } + /** + * Adds a rawGrammar. + */ + async addGrammar(rawGrammar, injections = [], initialLanguage = 0, embeddedLanguages = null) { + this._syncRegistry.addGrammar(rawGrammar, injections); + return (await this._grammarForScopeName(rawGrammar.scopeName, initialLanguage, embeddedLanguages)); + } + /** + * Get the grammar for `scopeName`. The grammar must first be created via `loadGrammar` or `addGrammar`. + */ + _grammarForScopeName(scopeName, initialLanguage = 0, embeddedLanguages = null, tokenTypes = null, balancedBracketSelectors = null) { + return this._syncRegistry.grammarForScopeName(scopeName, initialLanguage, embeddedLanguages, tokenTypes, balancedBracketSelectors); + } +} +exports.Registry = Registry; +exports.INITIAL = grammar_1.StateStackImpl.NULL; +exports.parseRawGrammar = grammarReader.parseRawGrammar; diff --git a/out/textmate/matcher.js b/out/textmate/matcher.js new file mode 100644 index 0000000..f18427e --- /dev/null +++ b/out/textmate/matcher.js @@ -0,0 +1,102 @@ +"use strict"; +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.createMatchers = void 0; +function createMatchers(selector, matchesName) { + const results = []; + const tokenizer = newTokenizer(selector); + let token = tokenizer.next(); + while (token !== null) { + let priority = 0; + if (token.length === 2 && token.charAt(1) === ':') { + switch (token.charAt(0)) { + case 'R': + priority = 1; + break; + case 'L': + priority = -1; + break; + default: + console.log(`Unknown priority ${token} in scope selector`); + } + token = tokenizer.next(); + } + let matcher = parseConjunction(); + results.push({ matcher, priority }); + if (token !== ',') { + break; + } + token = tokenizer.next(); + } + return results; + function parseOperand() { + if (token === '-') { + token = tokenizer.next(); + const expressionToNegate = parseOperand(); + return matcherInput => !!expressionToNegate && !expressionToNegate(matcherInput); + } + if (token === '(') { + token = tokenizer.next(); + const expressionInParents = parseInnerExpression(); + if (token === ')') { + token = tokenizer.next(); + } + return expressionInParents; + } + if (isIdentifier(token)) { + const identifiers = []; + do { + identifiers.push(token); + token = tokenizer.next(); + } while (isIdentifier(token)); + return matcherInput => matchesName(identifiers, matcherInput); + } + return null; + } + function parseConjunction() { + const matchers = []; + let matcher = parseOperand(); + while (matcher) { + matchers.push(matcher); + matcher = parseOperand(); + } + return matcherInput => matchers.every(matcher => matcher(matcherInput)); // and + } + function parseInnerExpression() { + const matchers = []; + let matcher = parseConjunction(); + while (matcher) { + matchers.push(matcher); + if (token === '|' || token === ',') { + do { + token = tokenizer.next(); + } while (token === '|' || token === ','); // ignore subsequent commas + } + else { + break; + } + matcher = parseConjunction(); + } + return matcherInput => matchers.some(matcher => matcher(matcherInput)); // or + } +} +exports.createMatchers = createMatchers; +function isIdentifier(token) { + return !!token && !!token.match(/[\w\.:]+/); +} +function newTokenizer(input) { + let regex = /([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g; + let match = regex.exec(input); + return { + next: () => { + if (!match) { + return null; + } + const res = match[0]; + match = regex.exec(input); + return res; + } + }; +} diff --git a/out/textmate/onigLib.js b/out/textmate/onigLib.js new file mode 100644 index 0000000..4a8b8c9 --- /dev/null +++ b/out/textmate/onigLib.js @@ -0,0 +1,12 @@ +"use strict"; +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.disposeOnigString = void 0; +function disposeOnigString(str) { + if (typeof str.dispose === 'function') { + str.dispose(); + } +} +exports.disposeOnigString = disposeOnigString; diff --git a/out/textmate/parseRawGrammar.js b/out/textmate/parseRawGrammar.js new file mode 100644 index 0000000..d4e2a36 --- /dev/null +++ b/out/textmate/parseRawGrammar.js @@ -0,0 +1,28 @@ +"use strict"; +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.parseRawGrammar = void 0; +const plist = require("./plist"); +const debug_1 = require("./debug"); +const json_1 = require("./json"); +function parseRawGrammar(content, filePath = null) { + if (filePath !== null && /\.json$/.test(filePath)) { + return parseJSONGrammar(content, filePath); + } + return parsePLISTGrammar(content, filePath); +} +exports.parseRawGrammar = parseRawGrammar; +function parseJSONGrammar(contents, filename) { + if (debug_1.DebugFlags.InDebugMode) { + return (0, json_1.parseJSON)(contents, filename, true); + } + return JSON.parse(contents); +} +function parsePLISTGrammar(contents, filename) { + if (debug_1.DebugFlags.InDebugMode) { + return plist.parseWithLocation(contents, filename, '$vscodeTextmateLocation'); + } + return plist.parsePLIST(contents); +} diff --git a/out/textmate/plist.js b/out/textmate/plist.js new file mode 100644 index 0000000..074a36b --- /dev/null +++ b/out/textmate/plist.js @@ -0,0 +1,455 @@ +"use strict"; +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.parsePLIST = exports.parseWithLocation = void 0; +function parseWithLocation(content, filename, locationKeyName) { + return _parse(content, filename, locationKeyName); +} +exports.parseWithLocation = parseWithLocation; +/** + * A very fast plist parser + */ +function parsePLIST(content) { + return _parse(content, null, null); +} +exports.parsePLIST = parsePLIST; +function _parse(content, filename, locationKeyName) { + const len = content.length; + let pos = 0; + let line = 1; + let char = 0; + // Skip UTF8 BOM + if (len > 0 && content.charCodeAt(0) === 65279 /* ChCode.BOM */) { + pos = 1; + } + function advancePosBy(by) { + if (locationKeyName === null) { + pos = pos + by; + } + else { + while (by > 0) { + let chCode = content.charCodeAt(pos); + if (chCode === 10 /* ChCode.LINE_FEED */) { + pos++; + line++; + char = 0; + } + else { + pos++; + char++; + } + by--; + } + } + } + function advancePosTo(to) { + if (locationKeyName === null) { + pos = to; + } + else { + advancePosBy(to - pos); + } + } + function skipWhitespace() { + while (pos < len) { + let chCode = content.charCodeAt(pos); + if (chCode !== 32 /* ChCode.SPACE */ && chCode !== 9 /* ChCode.TAB */ && chCode !== 13 /* ChCode.CARRIAGE_RETURN */ && chCode !== 10 /* ChCode.LINE_FEED */) { + break; + } + advancePosBy(1); + } + } + function advanceIfStartsWith(str) { + if (content.substr(pos, str.length) === str) { + advancePosBy(str.length); + return true; + } + return false; + } + function advanceUntil(str) { + let nextOccurence = content.indexOf(str, pos); + if (nextOccurence !== -1) { + advancePosTo(nextOccurence + str.length); + } + else { + // EOF + advancePosTo(len); + } + } + function captureUntil(str) { + let nextOccurence = content.indexOf(str, pos); + if (nextOccurence !== -1) { + let r = content.substring(pos, nextOccurence); + advancePosTo(nextOccurence + str.length); + return r; + } + else { + // EOF + let r = content.substr(pos); + advancePosTo(len); + return r; + } + } + let state = 0 /* State.ROOT_STATE */; + let cur = null; + let stateStack = []; + let objStack = []; + let curKey = null; + function pushState(newState, newCur) { + stateStack.push(state); + objStack.push(cur); + state = newState; + cur = newCur; + } + function popState() { + if (stateStack.length === 0) { + return fail('illegal state stack'); + } + state = stateStack.pop(); + cur = objStack.pop(); + } + function fail(msg) { + throw new Error('Near offset ' + pos + ': ' + msg + ' ~~~' + content.substr(pos, 50) + '~~~'); + } + const dictState = { + enterDict: function () { + if (curKey === null) { + return fail('missing '); + } + let newDict = {}; + if (locationKeyName !== null) { + newDict[locationKeyName] = { + filename: filename, + line: line, + char: char + }; + } + cur[curKey] = newDict; + curKey = null; + pushState(1 /* State.DICT_STATE */, newDict); + }, + enterArray: function () { + if (curKey === null) { + return fail('missing '); + } + let newArr = []; + cur[curKey] = newArr; + curKey = null; + pushState(2 /* State.ARR_STATE */, newArr); + } + }; + const arrState = { + enterDict: function () { + let newDict = {}; + if (locationKeyName !== null) { + newDict[locationKeyName] = { + filename: filename, + line: line, + char: char + }; + } + cur.push(newDict); + pushState(1 /* State.DICT_STATE */, newDict); + }, + enterArray: function () { + let newArr = []; + cur.push(newArr); + pushState(2 /* State.ARR_STATE */, newArr); + } + }; + function enterDict() { + if (state === 1 /* State.DICT_STATE */) { + dictState.enterDict(); + } + else if (state === 2 /* State.ARR_STATE */) { + arrState.enterDict(); + } + else { // ROOT_STATE + cur = {}; + if (locationKeyName !== null) { + cur[locationKeyName] = { + filename: filename, + line: line, + char: char + }; + } + pushState(1 /* State.DICT_STATE */, cur); + } + } + function leaveDict() { + if (state === 1 /* State.DICT_STATE */) { + popState(); + } + else if (state === 2 /* State.ARR_STATE */) { + return fail('unexpected '); + } + else { // ROOT_STATE + return fail('unexpected '); + } + } + function enterArray() { + if (state === 1 /* State.DICT_STATE */) { + dictState.enterArray(); + } + else if (state === 2 /* State.ARR_STATE */) { + arrState.enterArray(); + } + else { // ROOT_STATE + cur = []; + pushState(2 /* State.ARR_STATE */, cur); + } + } + function leaveArray() { + if (state === 1 /* State.DICT_STATE */) { + return fail('unexpected '); + } + else if (state === 2 /* State.ARR_STATE */) { + popState(); + } + else { // ROOT_STATE + return fail('unexpected '); + } + } + function acceptKey(val) { + if (state === 1 /* State.DICT_STATE */) { + if (curKey !== null) { + return fail('too many '); + } + curKey = val; + } + else if (state === 2 /* State.ARR_STATE */) { + return fail('unexpected '); + } + else { // ROOT_STATE + return fail('unexpected '); + } + } + function acceptString(val) { + if (state === 1 /* State.DICT_STATE */) { + if (curKey === null) { + return fail('missing '); + } + cur[curKey] = val; + curKey = null; + } + else if (state === 2 /* State.ARR_STATE */) { + cur.push(val); + } + else { // ROOT_STATE + cur = val; + } + } + function acceptReal(val) { + if (isNaN(val)) { + return fail('cannot parse float'); + } + if (state === 1 /* State.DICT_STATE */) { + if (curKey === null) { + return fail('missing '); + } + cur[curKey] = val; + curKey = null; + } + else if (state === 2 /* State.ARR_STATE */) { + cur.push(val); + } + else { // ROOT_STATE + cur = val; + } + } + function acceptInteger(val) { + if (isNaN(val)) { + return fail('cannot parse integer'); + } + if (state === 1 /* State.DICT_STATE */) { + if (curKey === null) { + return fail('missing '); + } + cur[curKey] = val; + curKey = null; + } + else if (state === 2 /* State.ARR_STATE */) { + cur.push(val); + } + else { // ROOT_STATE + cur = val; + } + } + function acceptDate(val) { + if (state === 1 /* State.DICT_STATE */) { + if (curKey === null) { + return fail('missing '); + } + cur[curKey] = val; + curKey = null; + } + else if (state === 2 /* State.ARR_STATE */) { + cur.push(val); + } + else { // ROOT_STATE + cur = val; + } + } + function acceptData(val) { + if (state === 1 /* State.DICT_STATE */) { + if (curKey === null) { + return fail('missing '); + } + cur[curKey] = val; + curKey = null; + } + else if (state === 2 /* State.ARR_STATE */) { + cur.push(val); + } + else { // ROOT_STATE + cur = val; + } + } + function acceptBool(val) { + if (state === 1 /* State.DICT_STATE */) { + if (curKey === null) { + return fail('missing '); + } + cur[curKey] = val; + curKey = null; + } + else if (state === 2 /* State.ARR_STATE */) { + cur.push(val); + } + else { // ROOT_STATE + cur = val; + } + } + function escapeVal(str) { + return str.replace(/&#([0-9]+);/g, function (_, m0) { + return String.fromCodePoint(parseInt(m0, 10)); + }).replace(/&#x([0-9a-f]+);/g, function (_, m0) { + return String.fromCodePoint(parseInt(m0, 16)); + }).replace(/&|<|>|"|'/g, function (_) { + switch (_) { + case '&': return '&'; + case '<': return '<'; + case '>': return '>'; + case '"': return '"'; + case ''': return '\''; + } + return _; + }); + } + function parseOpenTag() { + let r = captureUntil('>'); + let isClosed = false; + if (r.charCodeAt(r.length - 1) === 47 /* ChCode.SLASH */) { + isClosed = true; + r = r.substring(0, r.length - 1); + } + return { + name: r.trim(), + isClosed: isClosed + }; + } + function parseTagValue(tag) { + if (tag.isClosed) { + return ''; + } + let val = captureUntil(''); + return escapeVal(val); + } + while (pos < len) { + skipWhitespace(); + if (pos >= len) { + break; + } + const chCode = content.charCodeAt(pos); + advancePosBy(1); + if (chCode !== 60 /* ChCode.LESS_THAN */) { + return fail('expected <'); + } + if (pos >= len) { + return fail('unexpected end of input'); + } + const peekChCode = content.charCodeAt(pos); + if (peekChCode === 63 /* ChCode.QUESTION_MARK */) { + advancePosBy(1); + advanceUntil('?>'); + continue; + } + if (peekChCode === 33 /* ChCode.EXCLAMATION_MARK */) { + advancePosBy(1); + if (advanceIfStartsWith('--')) { + advanceUntil('-->'); + continue; + } + advanceUntil('>'); + continue; + } + if (peekChCode === 47 /* ChCode.SLASH */) { + advancePosBy(1); + skipWhitespace(); + if (advanceIfStartsWith('plist')) { + advanceUntil('>'); + continue; + } + if (advanceIfStartsWith('dict')) { + advanceUntil('>'); + leaveDict(); + continue; + } + if (advanceIfStartsWith('array')) { + advanceUntil('>'); + leaveArray(); + continue; + } + return fail('unexpected closed tag'); + } + let tag = parseOpenTag(); + switch (tag.name) { + case 'dict': + enterDict(); + if (tag.isClosed) { + leaveDict(); + } + continue; + case 'array': + enterArray(); + if (tag.isClosed) { + leaveArray(); + } + continue; + case 'key': + acceptKey(parseTagValue(tag)); + continue; + case 'string': + acceptString(parseTagValue(tag)); + continue; + case 'real': + acceptReal(parseFloat(parseTagValue(tag))); + continue; + case 'integer': + acceptInteger(parseInt(parseTagValue(tag), 10)); + continue; + case 'date': + acceptDate(new Date(parseTagValue(tag))); + continue; + case 'data': + acceptData(parseTagValue(tag)); + continue; + case 'true': + parseTagValue(tag); + acceptBool(true); + continue; + case 'false': + parseTagValue(tag); + acceptBool(false); + continue; + } + if (/^plist/.test(tag.name)) { + continue; + } + return fail('unexpected opened tag ' + tag.name); + } + return cur; +} diff --git a/out/textmate/rawGrammar.js b/out/textmate/rawGrammar.js new file mode 100644 index 0000000..6bf9329 --- /dev/null +++ b/out/textmate/rawGrammar.js @@ -0,0 +1,5 @@ +"use strict"; +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/out/textmate/registry.js b/out/textmate/registry.js new file mode 100644 index 0000000..ea79def --- /dev/null +++ b/out/textmate/registry.js @@ -0,0 +1,76 @@ +"use strict"; +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SyncRegistry = void 0; +const grammar_1 = require("./grammar"); +class SyncRegistry { + _onigLibPromise; + _grammars = new Map(); + _rawGrammars = new Map(); + _injectionGrammars = new Map(); + _theme; + constructor(theme, _onigLibPromise) { + this._onigLibPromise = _onigLibPromise; + this._theme = theme; + } + dispose() { + for (const grammar of this._grammars.values()) { + grammar.dispose(); + } + } + setTheme(theme) { + this._theme = theme; + } + getColorMap() { + return this._theme.getColorMap(); + } + /** + * Add `grammar` to registry and return a list of referenced scope names + */ + addGrammar(grammar, injectionScopeNames) { + this._rawGrammars.set(grammar.scopeName, grammar); + if (injectionScopeNames) { + this._injectionGrammars.set(grammar.scopeName, injectionScopeNames); + } + } + /** + * Lookup a raw grammar. + */ + lookup(scopeName) { + return this._rawGrammars.get(scopeName); + } + /** + * Returns the injections for the given grammar + */ + injections(targetScope) { + return this._injectionGrammars.get(targetScope); + } + /** + * Get the default theme settings + */ + getDefaults() { + return this._theme.getDefaults(); + } + /** + * Match a scope in the theme. + */ + themeMatch(scopePath) { + return this._theme.match(scopePath); + } + /** + * Lookup a grammar. + */ + async grammarForScopeName(scopeName, initialLanguage, embeddedLanguages, tokenTypes, balancedBracketSelectors) { + if (!this._grammars.has(scopeName)) { + let rawGrammar = this._rawGrammars.get(scopeName); + if (!rawGrammar) { + return null; + } + this._grammars.set(scopeName, (0, grammar_1.createGrammar)(scopeName, rawGrammar, initialLanguage, embeddedLanguages, tokenTypes, balancedBracketSelectors, this, await this._onigLibPromise)); + } + return this._grammars.get(scopeName); + } +} +exports.SyncRegistry = SyncRegistry; diff --git a/out/textmate/rule.js b/out/textmate/rule.js new file mode 100644 index 0000000..8522c79 --- /dev/null +++ b/out/textmate/rule.js @@ -0,0 +1,722 @@ +"use strict"; +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CompiledRule = exports.RegExpSourceList = exports.RegExpSource = exports.RuleFactory = exports.BeginWhileRule = exports.BeginEndRule = exports.IncludeOnlyRule = exports.MatchRule = exports.CaptureRule = exports.Rule = exports.ruleIdToNumber = exports.ruleIdFromNumber = exports.whileRuleId = exports.endRuleId = void 0; +const utils_1 = require("./utils"); +const grammarDependencies_1 = require("./grammar/grammarDependencies"); +const HAS_BACK_REFERENCES = /\\(\d+)/; +const BACK_REFERENCING_END = /\\(\d+)/g; +const ruleIdSymbol = Symbol('RuleId'); +// This is a special constant to indicate that the end regexp matched. +exports.endRuleId = -1; +// This is a special constant to indicate that the while regexp matched. +exports.whileRuleId = -2; +function ruleIdFromNumber(id) { + return id; +} +exports.ruleIdFromNumber = ruleIdFromNumber; +function ruleIdToNumber(id) { + return id; +} +exports.ruleIdToNumber = ruleIdToNumber; +class Rule { + $location; + id; + _nameIsCapturing; + _name; + _contentNameIsCapturing; + _contentName; + constructor($location, id, name, contentName) { + this.$location = $location; + this.id = id; + this._name = name || null; + this._nameIsCapturing = utils_1.RegexSource.hasCaptures(this._name); + this._contentName = contentName || null; + this._contentNameIsCapturing = utils_1.RegexSource.hasCaptures(this._contentName); + } + get debugName() { + const location = this.$location ? `${(0, utils_1.basename)(this.$location.filename)}:${this.$location.line}` : 'unknown'; + return `${this.constructor.name}#${this.id} @ ${location}`; + } + getName(lineText, captureIndices) { + if (!this._nameIsCapturing || this._name === null || lineText === null || captureIndices === null) { + return this._name; + } + return utils_1.RegexSource.replaceCaptures(this._name, lineText, captureIndices); + } + getContentName(lineText, captureIndices) { + if (!this._contentNameIsCapturing || this._contentName === null) { + return this._contentName; + } + return utils_1.RegexSource.replaceCaptures(this._contentName, lineText, captureIndices); + } +} +exports.Rule = Rule; +class CaptureRule extends Rule { + retokenizeCapturedWithRuleId; + constructor($location, id, name, contentName, retokenizeCapturedWithRuleId) { + super($location, id, name, contentName); + this.retokenizeCapturedWithRuleId = retokenizeCapturedWithRuleId; + } + dispose() { + // nothing to dispose + } + collectPatterns(grammar, out) { + throw new Error('Not supported!'); + } + compile(grammar, endRegexSource) { + throw new Error('Not supported!'); + } + compileAG(grammar, endRegexSource, allowA, allowG) { + throw new Error('Not supported!'); + } +} +exports.CaptureRule = CaptureRule; +class MatchRule extends Rule { + _match; + captures; + _cachedCompiledPatterns; + constructor($location, id, name, match, captures) { + super($location, id, name, null); + this._match = new RegExpSource(match, this.id); + this.captures = captures; + this._cachedCompiledPatterns = null; + } + dispose() { + if (this._cachedCompiledPatterns) { + this._cachedCompiledPatterns.dispose(); + this._cachedCompiledPatterns = null; + } + } + get debugMatchRegExp() { + return `${this._match.source}`; + } + collectPatterns(grammar, out) { + out.push(this._match); + } + compile(grammar, endRegexSource) { + return this._getCachedCompiledPatterns(grammar).compile(grammar); + } + compileAG(grammar, endRegexSource, allowA, allowG) { + return this._getCachedCompiledPatterns(grammar).compileAG(grammar, allowA, allowG); + } + _getCachedCompiledPatterns(grammar) { + if (!this._cachedCompiledPatterns) { + this._cachedCompiledPatterns = new RegExpSourceList(); + this.collectPatterns(grammar, this._cachedCompiledPatterns); + } + return this._cachedCompiledPatterns; + } +} +exports.MatchRule = MatchRule; +class IncludeOnlyRule extends Rule { + hasMissingPatterns; + patterns; + _cachedCompiledPatterns; + constructor($location, id, name, contentName, patterns) { + super($location, id, name, contentName); + this.patterns = patterns.patterns; + this.hasMissingPatterns = patterns.hasMissingPatterns; + this._cachedCompiledPatterns = null; + } + dispose() { + if (this._cachedCompiledPatterns) { + this._cachedCompiledPatterns.dispose(); + this._cachedCompiledPatterns = null; + } + } + collectPatterns(grammar, out) { + for (const pattern of this.patterns) { + const rule = grammar.getRule(pattern); + rule.collectPatterns(grammar, out); + } + } + compile(grammar, endRegexSource) { + return this._getCachedCompiledPatterns(grammar).compile(grammar); + } + compileAG(grammar, endRegexSource, allowA, allowG) { + return this._getCachedCompiledPatterns(grammar).compileAG(grammar, allowA, allowG); + } + _getCachedCompiledPatterns(grammar) { + if (!this._cachedCompiledPatterns) { + this._cachedCompiledPatterns = new RegExpSourceList(); + this.collectPatterns(grammar, this._cachedCompiledPatterns); + } + return this._cachedCompiledPatterns; + } +} +exports.IncludeOnlyRule = IncludeOnlyRule; +class BeginEndRule extends Rule { + _begin; + beginCaptures; + _end; + endHasBackReferences; + endCaptures; + applyEndPatternLast; + hasMissingPatterns; + patterns; + _cachedCompiledPatterns; + constructor($location, id, name, contentName, begin, beginCaptures, end, endCaptures, applyEndPatternLast, patterns) { + super($location, id, name, contentName); + this._begin = new RegExpSource(begin, this.id); + this.beginCaptures = beginCaptures; + this._end = new RegExpSource(end ? end : '\uFFFF', -1); + this.endHasBackReferences = this._end.hasBackReferences; + this.endCaptures = endCaptures; + this.applyEndPatternLast = applyEndPatternLast || false; + this.patterns = patterns.patterns; + this.hasMissingPatterns = patterns.hasMissingPatterns; + this._cachedCompiledPatterns = null; + } + dispose() { + if (this._cachedCompiledPatterns) { + this._cachedCompiledPatterns.dispose(); + this._cachedCompiledPatterns = null; + } + } + get debugBeginRegExp() { + return `${this._begin.source}`; + } + get debugEndRegExp() { + return `${this._end.source}`; + } + getEndWithResolvedBackReferences(lineText, captureIndices) { + return this._end.resolveBackReferences(lineText, captureIndices); + } + collectPatterns(grammar, out) { + out.push(this._begin); + } + compile(grammar, endRegexSource) { + return this._getCachedCompiledPatterns(grammar, endRegexSource).compile(grammar); + } + compileAG(grammar, endRegexSource, allowA, allowG) { + return this._getCachedCompiledPatterns(grammar, endRegexSource).compileAG(grammar, allowA, allowG); + } + _getCachedCompiledPatterns(grammar, endRegexSource) { + if (!this._cachedCompiledPatterns) { + this._cachedCompiledPatterns = new RegExpSourceList(); + for (const pattern of this.patterns) { + const rule = grammar.getRule(pattern); + rule.collectPatterns(grammar, this._cachedCompiledPatterns); + } + if (this.applyEndPatternLast) { + this._cachedCompiledPatterns.push(this._end.hasBackReferences ? this._end.clone() : this._end); + } + else { + this._cachedCompiledPatterns.unshift(this._end.hasBackReferences ? this._end.clone() : this._end); + } + } + if (this._end.hasBackReferences) { + if (this.applyEndPatternLast) { + this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length() - 1, endRegexSource); + } + else { + this._cachedCompiledPatterns.setSource(0, endRegexSource); + } + } + return this._cachedCompiledPatterns; + } +} +exports.BeginEndRule = BeginEndRule; +class BeginWhileRule extends Rule { + _begin; + beginCaptures; + whileCaptures; + _while; + whileHasBackReferences; + hasMissingPatterns; + patterns; + _cachedCompiledPatterns; + _cachedCompiledWhilePatterns; + constructor($location, id, name, contentName, begin, beginCaptures, _while, whileCaptures, patterns) { + super($location, id, name, contentName); + this._begin = new RegExpSource(begin, this.id); + this.beginCaptures = beginCaptures; + this.whileCaptures = whileCaptures; + this._while = new RegExpSource(_while, exports.whileRuleId); + this.whileHasBackReferences = this._while.hasBackReferences; + this.patterns = patterns.patterns; + this.hasMissingPatterns = patterns.hasMissingPatterns; + this._cachedCompiledPatterns = null; + this._cachedCompiledWhilePatterns = null; + } + dispose() { + if (this._cachedCompiledPatterns) { + this._cachedCompiledPatterns.dispose(); + this._cachedCompiledPatterns = null; + } + if (this._cachedCompiledWhilePatterns) { + this._cachedCompiledWhilePatterns.dispose(); + this._cachedCompiledWhilePatterns = null; + } + } + get debugBeginRegExp() { + return `${this._begin.source}`; + } + get debugWhileRegExp() { + return `${this._while.source}`; + } + getWhileWithResolvedBackReferences(lineText, captureIndices) { + return this._while.resolveBackReferences(lineText, captureIndices); + } + collectPatterns(grammar, out) { + out.push(this._begin); + } + compile(grammar, endRegexSource) { + return this._getCachedCompiledPatterns(grammar).compile(grammar); + } + compileAG(grammar, endRegexSource, allowA, allowG) { + return this._getCachedCompiledPatterns(grammar).compileAG(grammar, allowA, allowG); + } + _getCachedCompiledPatterns(grammar) { + if (!this._cachedCompiledPatterns) { + this._cachedCompiledPatterns = new RegExpSourceList(); + for (const pattern of this.patterns) { + const rule = grammar.getRule(pattern); + rule.collectPatterns(grammar, this._cachedCompiledPatterns); + } + } + return this._cachedCompiledPatterns; + } + compileWhile(grammar, endRegexSource) { + return this._getCachedCompiledWhilePatterns(grammar, endRegexSource).compile(grammar); + } + compileWhileAG(grammar, endRegexSource, allowA, allowG) { + return this._getCachedCompiledWhilePatterns(grammar, endRegexSource).compileAG(grammar, allowA, allowG); + } + _getCachedCompiledWhilePatterns(grammar, endRegexSource) { + if (!this._cachedCompiledWhilePatterns) { + this._cachedCompiledWhilePatterns = new RegExpSourceList(); + this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences ? this._while.clone() : this._while); + } + if (this._while.hasBackReferences) { + this._cachedCompiledWhilePatterns.setSource(0, endRegexSource ? endRegexSource : '\uFFFF'); + } + return this._cachedCompiledWhilePatterns; + } +} +exports.BeginWhileRule = BeginWhileRule; +class RuleFactory { + static createCaptureRule(helper, $location, name, contentName, retokenizeCapturedWithRuleId) { + return helper.registerRule((id) => { + return new CaptureRule($location, id, name, contentName, retokenizeCapturedWithRuleId); + }); + } + static getCompiledRuleId(desc, helper, repository) { + if (!desc.id) { + helper.registerRule((id) => { + desc.id = id; + if (desc.match) { + return new MatchRule(desc.$vscodeTextmateLocation, desc.id, desc.name, desc.match, RuleFactory._compileCaptures(desc.captures, helper, repository)); + } + if (typeof desc.begin === 'undefined') { + if (desc.repository) { + repository = (0, utils_1.mergeObjects)({}, repository, desc.repository); + } + let patterns = desc.patterns; + if (typeof patterns === 'undefined' && desc.include) { + patterns = [{ include: desc.include }]; + } + return new IncludeOnlyRule(desc.$vscodeTextmateLocation, desc.id, desc.name, desc.contentName, RuleFactory._compilePatterns(patterns, helper, repository)); + } + if (desc.while) { + return new BeginWhileRule(desc.$vscodeTextmateLocation, desc.id, desc.name, desc.contentName, desc.begin, RuleFactory._compileCaptures(desc.beginCaptures || desc.captures, helper, repository), desc.while, RuleFactory._compileCaptures(desc.whileCaptures || desc.captures, helper, repository), RuleFactory._compilePatterns(desc.patterns, helper, repository)); + } + return new BeginEndRule(desc.$vscodeTextmateLocation, desc.id, desc.name, desc.contentName, desc.begin, RuleFactory._compileCaptures(desc.beginCaptures || desc.captures, helper, repository), desc.end, RuleFactory._compileCaptures(desc.endCaptures || desc.captures, helper, repository), desc.applyEndPatternLast, RuleFactory._compilePatterns(desc.patterns, helper, repository)); + }); + } + return desc.id; + } + static _compileCaptures(captures, helper, repository) { + let r = []; + if (captures) { + // Find the maximum capture id + let maximumCaptureId = 0; + for (const captureId in captures) { + if (captureId === '$vscodeTextmateLocation') { + continue; + } + const numericCaptureId = parseInt(captureId, 10); + if (numericCaptureId > maximumCaptureId) { + maximumCaptureId = numericCaptureId; + } + } + // Initialize result + for (let i = 0; i <= maximumCaptureId; i++) { + r[i] = null; + } + // Fill out result + for (const captureId in captures) { + if (captureId === '$vscodeTextmateLocation') { + continue; + } + const numericCaptureId = parseInt(captureId, 10); + let retokenizeCapturedWithRuleId = 0; + if (captures[captureId].patterns) { + retokenizeCapturedWithRuleId = RuleFactory.getCompiledRuleId(captures[captureId], helper, repository); + } + r[numericCaptureId] = RuleFactory.createCaptureRule(helper, captures[captureId].$vscodeTextmateLocation, captures[captureId].name, captures[captureId].contentName, retokenizeCapturedWithRuleId); + } + } + return r; + } + static _compilePatterns(patterns, helper, repository) { + let r = []; + if (patterns) { + for (let i = 0, len = patterns.length; i < len; i++) { + const pattern = patterns[i]; + let ruleId = -1; + if (pattern.include) { + const reference = (0, grammarDependencies_1.parseInclude)(pattern.include); + switch (reference.kind) { + case 0 /* IncludeReferenceKind.Base */: + case 1 /* IncludeReferenceKind.Self */: + ruleId = RuleFactory.getCompiledRuleId(repository[pattern.include], helper, repository); + break; + case 2 /* IncludeReferenceKind.RelativeReference */: + // Local include found in `repository` + let localIncludedRule = repository[reference.ruleName]; + if (localIncludedRule) { + ruleId = RuleFactory.getCompiledRuleId(localIncludedRule, helper, repository); + } + else { + // console.warn('CANNOT find rule for scopeName: ' + pattern.include + ', I am: ', repository['$base'].name); + } + break; + case 3 /* IncludeReferenceKind.TopLevelReference */: + case 4 /* IncludeReferenceKind.TopLevelRepositoryReference */: + const externalGrammarName = reference.scopeName; + const externalGrammarInclude = reference.kind === 4 /* IncludeReferenceKind.TopLevelRepositoryReference */ + ? reference.ruleName + : null; + // External include + const externalGrammar = helper.getExternalGrammar(externalGrammarName, repository); + if (externalGrammar) { + if (externalGrammarInclude) { + let externalIncludedRule = externalGrammar.repository[externalGrammarInclude]; + if (externalIncludedRule) { + ruleId = RuleFactory.getCompiledRuleId(externalIncludedRule, helper, externalGrammar.repository); + } + else { + // console.warn('CANNOT find rule for scopeName: ' + pattern.include + ', I am: ', repository['$base'].name); + } + } + else { + ruleId = RuleFactory.getCompiledRuleId(externalGrammar.repository.$self, helper, externalGrammar.repository); + } + } + else { + // console.warn('CANNOT find grammar for scopeName: ' + pattern.include + ', I am: ', repository['$base'].name); + } + break; + } + } + else { + ruleId = RuleFactory.getCompiledRuleId(pattern, helper, repository); + } + if (ruleId !== -1) { + const rule = helper.getRule(ruleId); + let skipRule = false; + if (rule instanceof IncludeOnlyRule || rule instanceof BeginEndRule || rule instanceof BeginWhileRule) { + if (rule.hasMissingPatterns && rule.patterns.length === 0) { + skipRule = true; + } + } + if (skipRule) { + // console.log('REMOVING RULE ENTIRELY DUE TO EMPTY PATTERNS THAT ARE MISSING'); + continue; + } + r.push(ruleId); + } + } + } + return { + patterns: r, + hasMissingPatterns: ((patterns ? patterns.length : 0) !== r.length) + }; + } +} +exports.RuleFactory = RuleFactory; +class RegExpSource { + source; + ruleId; + hasAnchor; + hasBackReferences; + _anchorCache; + constructor(regExpSource, ruleId) { + if (regExpSource) { + const len = regExpSource.length; + let lastPushedPos = 0; + let output = []; + let hasAnchor = false; + for (let pos = 0; pos < len; pos++) { + const ch = regExpSource.charAt(pos); + if (ch === '\\') { + if (pos + 1 < len) { + const nextCh = regExpSource.charAt(pos + 1); + if (nextCh === 'z') { + output.push(regExpSource.substring(lastPushedPos, pos)); + output.push('$(?!\\n)(? ' + this.source + ', ' + this.hasAnchor); + } + clone() { + return new RegExpSource(this.source, this.ruleId); + } + setSource(newSource) { + if (this.source === newSource) { + return; + } + this.source = newSource; + if (this.hasAnchor) { + this._anchorCache = this._buildAnchorCache(); + } + } + resolveBackReferences(lineText, captureIndices) { + let capturedValues = captureIndices.map((capture) => { + return lineText.substring(capture.start, capture.end); + }); + BACK_REFERENCING_END.lastIndex = 0; + return this.source.replace(BACK_REFERENCING_END, (match, g1) => { + return (0, utils_1.escapeRegExpCharacters)(capturedValues[parseInt(g1, 10)] || ''); + }); + } + _buildAnchorCache() { + let A0_G0_result = []; + let A0_G1_result = []; + let A1_G0_result = []; + let A1_G1_result = []; + let pos, len, ch, nextCh; + for (pos = 0, len = this.source.length; pos < len; pos++) { + ch = this.source.charAt(pos); + A0_G0_result[pos] = ch; + A0_G1_result[pos] = ch; + A1_G0_result[pos] = ch; + A1_G1_result[pos] = ch; + if (ch === '\\') { + if (pos + 1 < len) { + nextCh = this.source.charAt(pos + 1); + if (nextCh === 'A') { + A0_G0_result[pos + 1] = '\uFFFF'; + A0_G1_result[pos + 1] = '\uFFFF'; + A1_G0_result[pos + 1] = 'A'; + A1_G1_result[pos + 1] = 'A'; + } + else if (nextCh === 'G') { + A0_G0_result[pos + 1] = '\uFFFF'; + A0_G1_result[pos + 1] = 'G'; + A1_G0_result[pos + 1] = '\uFFFF'; + A1_G1_result[pos + 1] = 'G'; + } + else { + A0_G0_result[pos + 1] = nextCh; + A0_G1_result[pos + 1] = nextCh; + A1_G0_result[pos + 1] = nextCh; + A1_G1_result[pos + 1] = nextCh; + } + pos++; + } + } + } + return { + A0_G0: A0_G0_result.join(''), + A0_G1: A0_G1_result.join(''), + A1_G0: A1_G0_result.join(''), + A1_G1: A1_G1_result.join('') + }; + } + resolveAnchors(allowA, allowG) { + if (!this.hasAnchor || !this._anchorCache) { + return this.source; + } + if (allowA) { + if (allowG) { + return this._anchorCache.A1_G1; + } + else { + return this._anchorCache.A1_G0; + } + } + else { + if (allowG) { + return this._anchorCache.A0_G1; + } + else { + return this._anchorCache.A0_G0; + } + } + } +} +exports.RegExpSource = RegExpSource; +class RegExpSourceList { + _items; + _hasAnchors; + _cached; + _anchorCache; + constructor() { + this._items = []; + this._hasAnchors = false; + this._cached = null; + this._anchorCache = { + A0_G0: null, + A0_G1: null, + A1_G0: null, + A1_G1: null + }; + } + dispose() { + this._disposeCaches(); + } + _disposeCaches() { + if (this._cached) { + this._cached.dispose(); + this._cached = null; + } + if (this._anchorCache.A0_G0) { + this._anchorCache.A0_G0.dispose(); + this._anchorCache.A0_G0 = null; + } + if (this._anchorCache.A0_G1) { + this._anchorCache.A0_G1.dispose(); + this._anchorCache.A0_G1 = null; + } + if (this._anchorCache.A1_G0) { + this._anchorCache.A1_G0.dispose(); + this._anchorCache.A1_G0 = null; + } + if (this._anchorCache.A1_G1) { + this._anchorCache.A1_G1.dispose(); + this._anchorCache.A1_G1 = null; + } + } + push(item) { + this._items.push(item); + this._hasAnchors = this._hasAnchors || item.hasAnchor; + } + unshift(item) { + this._items.unshift(item); + this._hasAnchors = this._hasAnchors || item.hasAnchor; + } + length() { + return this._items.length; + } + setSource(index, newSource) { + if (this._items[index].source !== newSource) { + // bust the cache + this._disposeCaches(); + this._items[index].setSource(newSource); + } + } + compile(onigLib) { + if (!this._cached) { + let regExps = this._items.map(e => e.source); + this._cached = new CompiledRule(onigLib, regExps, this._items.map(e => e.ruleId)); + } + return this._cached; + } + compileAG(onigLib, allowA, allowG) { + if (!this._hasAnchors) { + return this.compile(onigLib); + } + else { + if (allowA) { + if (allowG) { + if (!this._anchorCache.A1_G1) { + this._anchorCache.A1_G1 = this._resolveAnchors(onigLib, allowA, allowG); + } + return this._anchorCache.A1_G1; + } + else { + if (!this._anchorCache.A1_G0) { + this._anchorCache.A1_G0 = this._resolveAnchors(onigLib, allowA, allowG); + } + return this._anchorCache.A1_G0; + } + } + else { + if (allowG) { + if (!this._anchorCache.A0_G1) { + this._anchorCache.A0_G1 = this._resolveAnchors(onigLib, allowA, allowG); + } + return this._anchorCache.A0_G1; + } + else { + if (!this._anchorCache.A0_G0) { + this._anchorCache.A0_G0 = this._resolveAnchors(onigLib, allowA, allowG); + } + return this._anchorCache.A0_G0; + } + } + } + } + _resolveAnchors(onigLib, allowA, allowG) { + let regExps = this._items.map(e => e.resolveAnchors(allowA, allowG)); + return new CompiledRule(onigLib, regExps, this._items.map(e => e.ruleId)); + } +} +exports.RegExpSourceList = RegExpSourceList; +class CompiledRule { + regExps; + rules; + scanner; + constructor(onigLib, regExps, rules) { + this.regExps = regExps; + this.rules = rules; + this.scanner = onigLib.createOnigScanner(regExps); + } + dispose() { + if (typeof this.scanner.dispose === "function") { + this.scanner.dispose(); + } + } + toString() { + const r = []; + for (let i = 0, len = this.rules.length; i < len; i++) { + r.push(" - " + this.rules[i] + ": " + this.regExps[i]); + } + return r.join("\n"); + } + findNextMatchSync(string, startPosition, options) { + const result = this.scanner.findNextMatchSync(string, startPosition, options); + if (!result) { + return null; + } + return { + ruleId: this.rules[result.index], + captureIndices: result.captureIndices, + }; + } +} +exports.CompiledRule = CompiledRule; diff --git a/out/textmate/theme.js b/out/textmate/theme.js new file mode 100644 index 0000000..555b1ef --- /dev/null +++ b/out/textmate/theme.js @@ -0,0 +1,485 @@ +"use strict"; +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ThemeTrieElement = exports.ThemeTrieElementRule = exports.ColorMap = exports.fontStyleToString = exports.ParsedThemeRule = exports.parseTheme = exports.StyleAttributes = exports.ScopeStack = exports.Theme = void 0; +const utils_1 = require("./utils"); +class Theme { + _colorMap; + _defaults; + _root; + static createFromRawTheme(source, colorMap) { + return this.createFromParsedTheme(parseTheme(source), colorMap); + } + static createFromParsedTheme(source, colorMap) { + return resolveParsedThemeRules(source, colorMap); + } + _cachedMatchRoot = new utils_1.CachedFn((scopeName) => this._root.match(scopeName)); + constructor(_colorMap, _defaults, _root) { + this._colorMap = _colorMap; + this._defaults = _defaults; + this._root = _root; + } + getColorMap() { + return this._colorMap.getColorMap(); + } + getDefaults() { + return this._defaults; + } + match(scopePath) { + if (scopePath === null) { + return this._defaults; + } + const scopeName = scopePath.scopeName; + const matchingTrieElements = this._cachedMatchRoot.get(scopeName); + const effectiveRule = matchingTrieElements.find((v) => _scopePathMatchesParentScopes(scopePath.parent, v.parentScopes)); + if (!effectiveRule) { + return null; + } + return new StyleAttributes(effectiveRule.fontStyle, effectiveRule.foreground, effectiveRule.background); + } +} +exports.Theme = Theme; +class ScopeStack { + parent; + scopeName; + static push(path, scopeNames) { + for (const name of scopeNames) { + path = new ScopeStack(path, name); + } + return path; + } + static from(...segments) { + let result = null; + for (let i = 0; i < segments.length; i++) { + result = new ScopeStack(result, segments[i]); + } + return result; + } + constructor(parent, scopeName) { + this.parent = parent; + this.scopeName = scopeName; + } + push(scopeName) { + return new ScopeStack(this, scopeName); + } + getSegments() { + let item = this; + const result = []; + while (item) { + result.push(item.scopeName); + item = item.parent; + } + result.reverse(); + return result; + } + toString() { + return this.getSegments().join(' '); + } + extends(other) { + if (this === other) { + return true; + } + if (this.parent === null) { + return false; + } + return this.parent.extends(other); + } + getExtensionIfDefined(base) { + const result = []; + let item = this; + while (item && item !== base) { + result.push(item.scopeName); + item = item.parent; + } + return item === base ? result.reverse() : undefined; + } +} +exports.ScopeStack = ScopeStack; +function _scopePathMatchesParentScopes(scopePath, parentScopes) { + if (parentScopes === null) { + return true; + } + let index = 0; + let scopePattern = parentScopes[index]; + while (scopePath) { + if (_matchesScope(scopePath.scopeName, scopePattern)) { + index++; + if (index === parentScopes.length) { + return true; + } + scopePattern = parentScopes[index]; + } + scopePath = scopePath.parent; + } + return false; +} +function _matchesScope(scopeName, scopePattern) { + return scopePattern === scopeName || (scopeName.startsWith(scopePattern) && scopeName[scopePattern.length] === '.'); +} +class StyleAttributes { + fontStyle; + foregroundId; + backgroundId; + constructor(fontStyle, foregroundId, backgroundId) { + this.fontStyle = fontStyle; + this.foregroundId = foregroundId; + this.backgroundId = backgroundId; + } +} +exports.StyleAttributes = StyleAttributes; +/** + * Parse a raw theme into rules. + */ +function parseTheme(source) { + if (!source) { + return []; + } + if (!source.settings || !Array.isArray(source.settings)) { + return []; + } + let settings = source.settings; + let result = [], resultLen = 0; + for (let i = 0, len = settings.length; i < len; i++) { + let entry = settings[i]; + if (!entry.settings) { + continue; + } + let scopes; + if (typeof entry.scope === 'string') { + let _scope = entry.scope; + // remove leading commas + _scope = _scope.replace(/^[,]+/, ''); + // remove trailing commans + _scope = _scope.replace(/[,]+$/, ''); + scopes = _scope.split(','); + } + else if (Array.isArray(entry.scope)) { + scopes = entry.scope; + } + else { + scopes = ['']; + } + let fontStyle = -1 /* FontStyle.NotSet */; + if (typeof entry.settings.fontStyle === 'string') { + fontStyle = 0 /* FontStyle.None */; + let segments = entry.settings.fontStyle.split(' '); + for (let j = 0, lenJ = segments.length; j < lenJ; j++) { + let segment = segments[j]; + switch (segment) { + case 'italic': + fontStyle = fontStyle | 1 /* FontStyle.Italic */; + break; + case 'bold': + fontStyle = fontStyle | 2 /* FontStyle.Bold */; + break; + case 'underline': + fontStyle = fontStyle | 4 /* FontStyle.Underline */; + break; + case 'strikethrough': + fontStyle = fontStyle | 8 /* FontStyle.Strikethrough */; + break; + } + } + } + let foreground = null; + if (typeof entry.settings.foreground === 'string' && (0, utils_1.isValidHexColor)(entry.settings.foreground)) { + foreground = entry.settings.foreground; + } + let background = null; + if (typeof entry.settings.background === 'string' && (0, utils_1.isValidHexColor)(entry.settings.background)) { + background = entry.settings.background; + } + for (let j = 0, lenJ = scopes.length; j < lenJ; j++) { + let _scope = scopes[j].trim(); + let segments = _scope.split(' '); + let scope = segments[segments.length - 1]; + let parentScopes = null; + if (segments.length > 1) { + parentScopes = segments.slice(0, segments.length - 1); + parentScopes.reverse(); + } + result[resultLen++] = new ParsedThemeRule(scope, parentScopes, i, fontStyle, foreground, background); + } + } + return result; +} +exports.parseTheme = parseTheme; +class ParsedThemeRule { + scope; + parentScopes; + index; + fontStyle; + foreground; + background; + constructor(scope, parentScopes, index, fontStyle, foreground, background) { + this.scope = scope; + this.parentScopes = parentScopes; + this.index = index; + this.fontStyle = fontStyle; + this.foreground = foreground; + this.background = background; + } +} +exports.ParsedThemeRule = ParsedThemeRule; +function fontStyleToString(fontStyle) { + if (fontStyle === -1 /* FontStyle.NotSet */) { + return 'not set'; + } + let style = ''; + if (fontStyle & 1 /* FontStyle.Italic */) { + style += 'italic '; + } + if (fontStyle & 2 /* FontStyle.Bold */) { + style += 'bold '; + } + if (fontStyle & 4 /* FontStyle.Underline */) { + style += 'underline '; + } + if (fontStyle & 8 /* FontStyle.Strikethrough */) { + style += 'strikethrough '; + } + if (style === '') { + style = 'none'; + } + return style.trim(); +} +exports.fontStyleToString = fontStyleToString; +/** + * Resolve rules (i.e. inheritance). + */ +function resolveParsedThemeRules(parsedThemeRules, _colorMap) { + // Sort rules lexicographically, and then by index if necessary + parsedThemeRules.sort((a, b) => { + let r = (0, utils_1.strcmp)(a.scope, b.scope); + if (r !== 0) { + return r; + } + r = (0, utils_1.strArrCmp)(a.parentScopes, b.parentScopes); + if (r !== 0) { + return r; + } + return a.index - b.index; + }); + // Determine defaults + let defaultFontStyle = 0 /* FontStyle.None */; + let defaultForeground = '#000000'; + let defaultBackground = '#ffffff'; + while (parsedThemeRules.length >= 1 && parsedThemeRules[0].scope === '') { + let incomingDefaults = parsedThemeRules.shift(); + if (incomingDefaults.fontStyle !== -1 /* FontStyle.NotSet */) { + defaultFontStyle = incomingDefaults.fontStyle; + } + if (incomingDefaults.foreground !== null) { + defaultForeground = incomingDefaults.foreground; + } + if (incomingDefaults.background !== null) { + defaultBackground = incomingDefaults.background; + } + } + let colorMap = new ColorMap(_colorMap); + let defaults = new StyleAttributes(defaultFontStyle, colorMap.getId(defaultForeground), colorMap.getId(defaultBackground)); + let root = new ThemeTrieElement(new ThemeTrieElementRule(0, null, -1 /* FontStyle.NotSet */, 0, 0), []); + for (let i = 0, len = parsedThemeRules.length; i < len; i++) { + let rule = parsedThemeRules[i]; + root.insert(0, rule.scope, rule.parentScopes, rule.fontStyle, colorMap.getId(rule.foreground), colorMap.getId(rule.background)); + } + return new Theme(colorMap, defaults, root); +} +class ColorMap { + _isFrozen; + _lastColorId; + _id2color; + _color2id; + constructor(_colorMap) { + this._lastColorId = 0; + this._id2color = []; + this._color2id = Object.create(null); + if (Array.isArray(_colorMap)) { + this._isFrozen = true; + for (let i = 0, len = _colorMap.length; i < len; i++) { + this._color2id[_colorMap[i]] = i; + this._id2color[i] = _colorMap[i]; + } + } + else { + this._isFrozen = false; + } + } + getId(color) { + if (color === null) { + return 0; + } + color = color.toUpperCase(); + let value = this._color2id[color]; + if (value) { + return value; + } + if (this._isFrozen) { + throw new Error(`Missing color in color map - ${color}`); + } + value = ++this._lastColorId; + this._color2id[color] = value; + this._id2color[value] = color; + return value; + } + getColorMap() { + return this._id2color.slice(0); + } +} +exports.ColorMap = ColorMap; +class ThemeTrieElementRule { + scopeDepth; + parentScopes; + fontStyle; + foreground; + background; + constructor(scopeDepth, parentScopes, fontStyle, foreground, background) { + this.scopeDepth = scopeDepth; + this.parentScopes = parentScopes; + this.fontStyle = fontStyle; + this.foreground = foreground; + this.background = background; + } + clone() { + return new ThemeTrieElementRule(this.scopeDepth, this.parentScopes, this.fontStyle, this.foreground, this.background); + } + static cloneArr(arr) { + let r = []; + for (let i = 0, len = arr.length; i < len; i++) { + r[i] = arr[i].clone(); + } + return r; + } + acceptOverwrite(scopeDepth, fontStyle, foreground, background) { + if (this.scopeDepth > scopeDepth) { + console.log('how did this happen?'); + } + else { + this.scopeDepth = scopeDepth; + } + // console.log('TODO -> my depth: ' + this.scopeDepth + ', overwriting depth: ' + scopeDepth); + if (fontStyle !== -1 /* FontStyle.NotSet */) { + this.fontStyle = fontStyle; + } + if (foreground !== 0) { + this.foreground = foreground; + } + if (background !== 0) { + this.background = background; + } + } +} +exports.ThemeTrieElementRule = ThemeTrieElementRule; +class ThemeTrieElement { + _mainRule; + _children; + _rulesWithParentScopes; + constructor(_mainRule, rulesWithParentScopes = [], _children = {}) { + this._mainRule = _mainRule; + this._children = _children; + this._rulesWithParentScopes = rulesWithParentScopes; + } + static _sortBySpecificity(arr) { + if (arr.length === 1) { + return arr; + } + arr.sort(this._cmpBySpecificity); + return arr; + } + static _cmpBySpecificity(a, b) { + if (a.scopeDepth === b.scopeDepth) { + const aParentScopes = a.parentScopes; + const bParentScopes = b.parentScopes; + let aParentScopesLen = aParentScopes === null ? 0 : aParentScopes.length; + let bParentScopesLen = bParentScopes === null ? 0 : bParentScopes.length; + if (aParentScopesLen === bParentScopesLen) { + for (let i = 0; i < aParentScopesLen; i++) { + const aLen = aParentScopes[i].length; + const bLen = bParentScopes[i].length; + if (aLen !== bLen) { + return bLen - aLen; + } + } + } + return bParentScopesLen - aParentScopesLen; + } + return b.scopeDepth - a.scopeDepth; + } + match(scope) { + if (scope === '') { + return ThemeTrieElement._sortBySpecificity([].concat(this._mainRule).concat(this._rulesWithParentScopes)); + } + let dotIndex = scope.indexOf('.'); + let head; + let tail; + if (dotIndex === -1) { + head = scope; + tail = ''; + } + else { + head = scope.substring(0, dotIndex); + tail = scope.substring(dotIndex + 1); + } + if (this._children.hasOwnProperty(head)) { + return this._children[head].match(tail); + } + return ThemeTrieElement._sortBySpecificity([].concat(this._mainRule).concat(this._rulesWithParentScopes)); + } + insert(scopeDepth, scope, parentScopes, fontStyle, foreground, background) { + if (scope === '') { + this._doInsertHere(scopeDepth, parentScopes, fontStyle, foreground, background); + return; + } + let dotIndex = scope.indexOf('.'); + let head; + let tail; + if (dotIndex === -1) { + head = scope; + tail = ''; + } + else { + head = scope.substring(0, dotIndex); + tail = scope.substring(dotIndex + 1); + } + let child; + if (this._children.hasOwnProperty(head)) { + child = this._children[head]; + } + else { + child = new ThemeTrieElement(this._mainRule.clone(), ThemeTrieElementRule.cloneArr(this._rulesWithParentScopes)); + this._children[head] = child; + } + child.insert(scopeDepth + 1, tail, parentScopes, fontStyle, foreground, background); + } + _doInsertHere(scopeDepth, parentScopes, fontStyle, foreground, background) { + if (parentScopes === null) { + // Merge into the main rule + this._mainRule.acceptOverwrite(scopeDepth, fontStyle, foreground, background); + return; + } + // Try to merge into existing rule + for (let i = 0, len = this._rulesWithParentScopes.length; i < len; i++) { + let rule = this._rulesWithParentScopes[i]; + if ((0, utils_1.strArrCmp)(rule.parentScopes, parentScopes) === 0) { + // bingo! => we get to merge this into an existing one + rule.acceptOverwrite(scopeDepth, fontStyle, foreground, background); + return; + } + } + // Must add a new rule + // Inherit from main rule + if (fontStyle === -1 /* FontStyle.NotSet */) { + fontStyle = this._mainRule.fontStyle; + } + if (foreground === 0) { + foreground = this._mainRule.foreground; + } + if (background === 0) { + background = this._mainRule.background; + } + this._rulesWithParentScopes.push(new ThemeTrieElementRule(scopeDepth, parentScopes, fontStyle, foreground, background)); + } +} +exports.ThemeTrieElement = ThemeTrieElement; diff --git a/out/textmate/utils.js b/out/textmate/utils.js new file mode 100644 index 0000000..cf280d4 --- /dev/null +++ b/out/textmate/utils.js @@ -0,0 +1,174 @@ +"use strict"; +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.performanceNow = exports.CachedFn = exports.escapeRegExpCharacters = exports.isValidHexColor = exports.strArrCmp = exports.strcmp = exports.RegexSource = exports.basename = exports.mergeObjects = exports.clone = void 0; +function clone(something) { + return doClone(something); +} +exports.clone = clone; +function doClone(something) { + if (Array.isArray(something)) { + return cloneArray(something); + } + if (typeof something === 'object') { + return cloneObj(something); + } + return something; +} +function cloneArray(arr) { + let r = []; + for (let i = 0, len = arr.length; i < len; i++) { + r[i] = doClone(arr[i]); + } + return r; +} +function cloneObj(obj) { + let r = {}; + for (let key in obj) { + r[key] = doClone(obj[key]); + } + return r; +} +function mergeObjects(target, ...sources) { + sources.forEach(source => { + for (let key in source) { + target[key] = source[key]; + } + }); + return target; +} +exports.mergeObjects = mergeObjects; +function basename(path) { + const idx = ~path.lastIndexOf('/') || ~path.lastIndexOf('\\'); + if (idx === 0) { + return path; + } + else if (~idx === path.length - 1) { + return basename(path.substring(0, path.length - 1)); + } + else { + return path.substr(~idx + 1); + } +} +exports.basename = basename; +let CAPTURING_REGEX_SOURCE = /\$(\d+)|\${(\d+):\/(downcase|upcase)}/g; +class RegexSource { + static hasCaptures(regexSource) { + if (regexSource === null) { + return false; + } + CAPTURING_REGEX_SOURCE.lastIndex = 0; + return CAPTURING_REGEX_SOURCE.test(regexSource); + } + static replaceCaptures(regexSource, captureSource, captureIndices) { + return regexSource.replace(CAPTURING_REGEX_SOURCE, (match, index, commandIndex, command) => { + let capture = captureIndices[parseInt(index || commandIndex, 10)]; + if (capture) { + let result = captureSource.substring(capture.start, capture.end); + // Remove leading dots that would make the selector invalid + while (result[0] === '.') { + result = result.substring(1); + } + switch (command) { + case 'downcase': + return result.toLowerCase(); + case 'upcase': + return result.toUpperCase(); + default: + return result; + } + } + else { + return match; + } + }); + } +} +exports.RegexSource = RegexSource; +function strcmp(a, b) { + if (a < b) { + return -1; + } + if (a > b) { + return 1; + } + return 0; +} +exports.strcmp = strcmp; +function strArrCmp(a, b) { + if (a === null && b === null) { + return 0; + } + if (!a) { + return -1; + } + if (!b) { + return 1; + } + let len1 = a.length; + let len2 = b.length; + if (len1 === len2) { + for (let i = 0; i < len1; i++) { + let res = strcmp(a[i], b[i]); + if (res !== 0) { + return res; + } + } + return 0; + } + return len1 - len2; +} +exports.strArrCmp = strArrCmp; +function isValidHexColor(hex) { + if (/^#[0-9a-f]{6}$/i.test(hex)) { + // #rrggbb + return true; + } + if (/^#[0-9a-f]{8}$/i.test(hex)) { + // #rrggbbaa + return true; + } + if (/^#[0-9a-f]{3}$/i.test(hex)) { + // #rgb + return true; + } + if (/^#[0-9a-f]{4}$/i.test(hex)) { + // #rgba + return true; + } + return false; +} +exports.isValidHexColor = isValidHexColor; +/** + * Escapes regular expression characters in a given string + */ +function escapeRegExpCharacters(value) { + return value.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g, '\\$&'); +} +exports.escapeRegExpCharacters = escapeRegExpCharacters; +class CachedFn { + fn; + cache = new Map(); + constructor(fn) { + this.fn = fn; + } + get(key) { + if (this.cache.has(key)) { + return this.cache.get(key); + } + const value = this.fn(key); + this.cache.set(key, value); + return value; + } +} +exports.CachedFn = CachedFn; +exports.performanceNow = typeof performance === "undefined" + // performance.now() is not available in this environment, so use Date.now() + ? function () { + return Date.now(); + } + : function () { + return performance.now(); + }; diff --git a/out/web/extension.js b/out/web/extension.js index d43625f..4e43f31 100644 --- a/out/web/extension.js +++ b/out/web/extension.js @@ -1,2796 +1 @@ -/******/ (() => { // webpackBootstrap -/******/ var __webpack_modules__ = ([ -/* 0 */ -/***/ ((__unused_webpack_module, exports, __webpack_require__) => { - -"use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.deactivate = exports.activate = exports.DocumentSelector = void 0; -const vscode = __webpack_require__(1); -const TreeSitter_1 = __webpack_require__(2); -const oniguruma_1 = __webpack_require__(6); -const DiagnosticCollection_1 = __webpack_require__(27); -const tokenColorCustomizations_1 = __webpack_require__(28); -const RenameProvider_1 = __webpack_require__(30); -const ReferenceProvider_1 = __webpack_require__(32); -const DefinitionProvider_1 = __webpack_require__(33); -const CallHierarchyProvider_1 = __webpack_require__(34); -const DocumentSymbolProvider_1 = __webpack_require__(35); -const DocumentHighlightProvider_1 = __webpack_require__(36); -const CompletionItemProvider_1 = __webpack_require__(37); -const DocumentFormattingEditProvider_1 = __webpack_require__(38); -exports.DocumentSelector = [ - { language: 'json-textmate' } -]; -async function activate(context) { - // vscode.window.showInformationMessage(JSON.stringify("TextMate Extension")); - await (0, TreeSitter_1.initTreeSitter)(context); - await (0, oniguruma_1.initOniguruma)(context); - // initTextMate(context); - (0, DiagnosticCollection_1.initDiagnostics)(context); - (0, tokenColorCustomizations_1.initTokenColorCustomizations)(context); - // initCallStackView(context); - // context.subscriptions.push(vscode.window.registerTreeDataProvider('TextMate', TreeDataProvider)); // Call Stack - // context.subscriptions.push(vscode.languages.registerHoverProvider(DocumentSelector, HoverProvider)); // Mouse over Hovers - context.subscriptions.push(vscode.languages.registerRenameProvider(exports.DocumentSelector, RenameProvider_1.RenameProvider)); // [F2] Rename - // context.subscriptions.push(vscode.languages.registerCodeLensProvider(DocumentSelector, CodeLensProvider)); // Code Lens - context.subscriptions.push(vscode.languages.registerReferenceProvider(exports.DocumentSelector, ReferenceProvider_1.ReferenceProvider)); // Go to References - context.subscriptions.push(vscode.languages.registerDefinitionProvider(exports.DocumentSelector, DefinitionProvider_1.DefinitionProvider)); // ctrl+click Go to Definition - context.subscriptions.push(vscode.languages.registerCallHierarchyProvider(exports.DocumentSelector, CallHierarchyProvider_1.CallHierarchyProvider)); // right click => Peak Call Hierarchy - context.subscriptions.push(vscode.languages.registerDocumentSymbolProvider(exports.DocumentSelector, DocumentSymbolProvider_1.DocumentSymbolProvider)); // Breadcrumbs - context.subscriptions.push(vscode.languages.registerCompletionItemProvider(exports.DocumentSelector, CompletionItemProvider_1.CompletionItemProvider, ...CompletionItemProvider_1.triggerCharacters)); // Intellisense ctrl+space completions - context.subscriptions.push(vscode.languages.registerDocumentHighlightProvider(exports.DocumentSelector, DocumentHighlightProvider_1.DocumentHighlightProvider)); // Context aware variable highlighting - context.subscriptions.push(vscode.languages.registerDocumentFormattingEditProvider(exports.DocumentSelector, DocumentFormattingEditProvider_1.DocumentFormattingEditProvider)); // right-click => Format Document - context.subscriptions.push(vscode.languages.registerDocumentRangeFormattingEditProvider(exports.DocumentSelector, DocumentFormattingEditProvider_1.DocumentRangeFormattingEditProvider)); // right-click => Format Selection - // context.subscriptions.push(vscode.languages.registerDocumentSemanticTokensProvider(DocumentSelector, DocumentSemanticTokensProvider, SemanticTokensLegend)); // Context aware syntax highlighting -} -exports.activate = activate; -// This method is called when your extension is deactivated -function deactivate() { - // vscode.window.showInformationMessage(JSON.stringify("deactivate")); - // https://github.com/microsoft/vscode/issues/105484 - // https://github.com/microsoft/vscode/issues/201664 -} -exports.deactivate = deactivate; -// export function stringify(this: any, key: string, value: any) { -// if (typeof value === 'function') { -// return ""; -// } -// if (typeof value === 'symbol') { -// return ""; -// } -// if (typeof value === 'undefined') { -// return ""; -// } -// if (value === null) { -// return null; -// } -// if (key.startsWith("HEAP")) { -// return ""; -// } -// return value ?? ""; -// } - - -/***/ }), -/* 1 */ -/***/ ((module) => { - -"use strict"; -module.exports = require("vscode"); - -/***/ }), -/* 2 */ -/***/ ((__unused_webpack_module, exports, __webpack_require__) => { - -"use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.initTreeSitter = exports.trueParent = exports.toPoint = exports.toRange = exports.queryForPosition = exports.queryNode = exports.getLastNode = exports.getComment = exports.getRegexNode = exports.getTree = exports.getTrees = void 0; -const vscode = __webpack_require__(1); -const Parser = __webpack_require__(3); -const extension_1 = __webpack_require__(0); -const trees = {}; -function getTrees(source) { - const uriString = 'uri' in source ? source.uri.toString() : source.toString(); - return trees[uriString]; -} -exports.getTrees = getTrees; -/** - * @deprecated use {@link getTrees()} instead - */ -function getTree(document) { - const uriString = document.uri.toString(); - const tree = trees[uriString]?.jsonTree; - return tree; -} -exports.getTree = getTree; -function getRegexNode(source, node) { - const nodeId = typeof node == 'number' ? node : node.id; - if ('uri' in source) { - const uriString = source.uri.toString(); - const regexTrees = trees[uriString]?.regexTrees; - const regexTree = regexTrees[nodeId]; - return regexTree.rootNode; - } - if ('scheme' in source) { - const uriString = source.toString(); - const regexTrees = trees[uriString]?.regexTrees; - const regexTree = regexTrees[nodeId]; - return regexTree.rootNode; - } - if ('regexTrees' in source) { - const regexTrees = source.regexTrees; - const regexTree = regexTrees[nodeId]; - return regexTree.rootNode; - } - const regexTree = source[nodeId]; - return regexTree.rootNode; -} -exports.getRegexNode = getRegexNode; -/** - * Returns the first non-empty comment in the parent node - */ -function getComment(node) { - const parent = trueParent(node); - const query = ` - (comment (value) @comment (.not-eq? @comment "")) - (comment_slash (value) @comment (.not-eq? @comment "")) - `; - const capture = queryNode(parent, query)[0]; - return capture?.node?.text?.replace(/\\(.)?/g, '$1'); -} -exports.getComment = getComment; -function getLastNode(rootNode, type) { - const nodes = rootNode.namedChildren; - while (nodes.length) { - const childNode = nodes.pop(); // bottom up - if (childNode.type == type) { - return childNode; - } - } -} -exports.getLastNode = getLastNode; -function queryNode(node, queryString, startPoint, endPoint) { - const language = node.tree.getLanguage(); - const query = language.query(queryString); - const queryCaptures = query.captures(node, startPoint, endPoint || startPoint); - if (queryCaptures.length > 10000) { - vscode.window.showWarningMessage("Unoptimized Query: " + queryCaptures.length + " results returned:\n" + queryString); - // vscode.window.showInformationMessage(JSON.stringify(queryCaptures)); - } - if (startPoint && !endPoint) { - if (endPoint === false) { - return queryCaptures.pop(); // the last/inner most node - } - const position = new vscode.Position(startPoint.row, startPoint.column); - while (queryCaptures.length) { // TreeSitter doesn't actually check if the captured node intersects the startPoint :/ - const queryCapture = queryCaptures.pop(); // the last/inner most node - if (toRange(queryCapture.node).contains(position)) { - return queryCapture; - } - } - return null; - } - return queryCaptures; -} -exports.queryNode = queryNode; -/** - * @deprecated use {@link queryNode()} instead - */ -function queryForPosition(tree, queryString, point) { - const language = tree.getLanguage(); - const query = language.query(queryString); - const queryCaptures = query.captures(tree.rootNode, point, point); - const queryCapture = queryCaptures.pop(); // the last/inner most node - return queryCapture; -} -exports.queryForPosition = queryForPosition; -function toRange(node) { - if (!node) { - return null; - } - const startPosition = node.startPosition; - const endPosition = node.endPosition; - return new vscode.Range(startPosition.row, startPosition.column, endPosition.row, endPosition.column); -} -exports.toRange = toRange; -function toPoint(position) { - const row = position.line; - const column = position.character; - const point = { row: row, column: column }; - return point; -} -exports.toPoint = toPoint; -/** - * TreeSitter bug - * Using `.parent` on a 0width node returns the `previousSilbing` rather than the `parent` - * https://github.com/tree-sitter/tree-sitter/issues/1872 - */ -function trueParent(node) { - const parent = node.parent; - if (parent == null) { - // vscode.window.showInformationMessage(JSON.stringify(node.toString())); - // vscode.window.showInformationMessage(JSON.stringify(node.type)); - // vscode.window.showInformationMessage(JSON.stringify(node.text)); - return node; - } - if (node.text != '') { - return parent; - } - return parent.parent; - // const sibling = parent.nextSibling; - // return sibling ? sibling.equals(node) ? parent.parent : parent : parent; -} -exports.trueParent = trueParent; -async function initTreeSitter(context) { - // vscode.window.showInformationMessage(JSON.stringify("TreeSitterInit")); - // We only need to provide these options when running in the web worker - const moduleOptions = typeof navigator === 'undefined' - ? undefined - : { - locateFile() { - return vscode.Uri.joinPath(context.extensionUri, 'node_modules', 'web-tree-sitter', 'tree-sitter.wasm').toString(true); - } - }; - await Parser.init(moduleOptions); // Everything MUST wait until TreeSitter initializes - // vscode.window.showInformationMessage(JSON.stringify("Parser")); - const jsonParser = new Parser(); - const jsonWasmUri = vscode.Uri.joinPath(context.extensionUri, 'out', 'tree-sitter-jsontm.wasm'); - const jsonWasm = jsonWasmUri.scheme === 'file' ? jsonWasmUri.fsPath : jsonWasmUri.toString(true); - const jsonLanguage = await Parser.Language.load(jsonWasm); - jsonParser.setLanguage(jsonLanguage); - const regexParser = new Parser(); - const regexWasmUri = vscode.Uri.joinPath(context.extensionUri, 'out', 'tree-sitter-regextm.wasm'); - const regexWasm = regexWasmUri.scheme === 'file' ? regexWasmUri.fsPath : regexWasmUri.toString(true); - const regexLanguage = await Parser.Language.load(regexWasm); - regexParser.setLanguage(regexLanguage); - // vscode.window.showInformationMessage(JSON.stringify("Lang")); - // const jsonParser = new Parser(); - // const jsonWasm = context.asAbsolutePath('out/tree-sitter-jsontm.wasm'); - // const jsonLanguage = await Parser.Language.load(jsonWasm); - // jsonParser.setLanguage(jsonLanguage); - // const regexParser = new Parser(); - // const regexWasm = context.asAbsolutePath('out/tree-sitter-regextm.wasm'); - // const regexLanguage = await Parser.Language.load(regexWasm); - // regexParser.setLanguage(regexLanguage); - vscode.window.visibleTextEditors.forEach(editor => { - // vscode.window.showInformationMessage(JSON.stringify("visible")); - parseTextDocument(editor.document, jsonParser, regexParser); - }); - context.subscriptions.push(vscode.workspace.onDidOpenTextDocument(document => { - // vscode.window.showInformationMessage(JSON.stringify("open")); - parseTextDocument(document, jsonParser, regexParser); - })); - context.subscriptions.push(vscode.workspace.onDidChangeTextDocument(edits => { - // vscode.window.showInformationMessage(JSON.stringify("change")); - reparseTextDocument(edits, jsonParser, regexParser); - })); - context.subscriptions.push(vscode.workspace.onDidCloseTextDocument(document => { - // vscode.window.showInformationMessage(JSON.stringify("close")); - const uriString = document.uri.toString(); - delete trees[uriString]; - })); -} -exports.initTreeSitter = initTreeSitter; -function parseTextDocument(document, jsonParser, regexParser) { - // vscode.window.showInformationMessage(JSON.stringify("ParseTextDocument")); - if (!vscode.languages.match(extension_1.DocumentSelector, document)) { - return; - } - // vscode.window.showInformationMessage(JSON.stringify(document.uri)); - const uriString = document.uri.toString(); - if (uriString in trees) { - console.log("JSON TextMate: Why are we here?"); - vscode.window.showInformationMessage("JSON TextMate: Why are we here?"); - return; - } - const text = document.getText(); - const jsonTree = jsonParser.parse(text); - // const languageJSON = jsonParser.getLanguage(); - // const query = languageJSON.query(`(regex) @regex`); - // const queryCaptures = query.captures(jsonTree.rootNode); - const queryCaptures = queryNode(jsonTree.rootNode, `(regex) @regex`); - const regexTrees = {}; - const regexNodes = {}; - for (const queryCapture of queryCaptures) { - const node = queryCapture.node; - const range = { - startPosition: node.startPosition, - endPosition: node.endPosition, - startIndex: node.startIndex, - endIndex: node.endIndex - }; - const ranges = [range]; - const options = { includedRanges: ranges }; - const regexTree = regexParser.parse(text, null, options); - regexTrees[node.id] = regexTree; - const regexNode = regexTree.rootNode; - regexNodes[regexNode.id] = node; - } - trees[uriString] = { - jsonTree: jsonTree, - regexTrees: regexTrees, - regexNodes: regexNodes, - }; - // let index = 0; - // const regexIds = {}; - // const ranges: Parser.Range[] = []; - // for (const queryCapture of queryCaptures) { - // const node = queryCapture.node; - // const range: Parser.Range = { - // startPosition: node.startPosition, - // endPosition: node.endPosition, - // startIndex: node.startIndex, - // endIndex: node.endIndex - // }; - // ranges.push(range); - // const id = node.id; - // regexIds[id] = index++; - // } - // const Options: Parser.Options = { includedRanges: ranges }; - // const regexTree = regexParser.parse(text, jsonTree, Options); - // if(node.hasChanges()) {} -} -function reparseTextDocument(edits, JSONParser, regexParser) { - // vscode.window.showInformationMessage(JSON.stringify("ReparseTextDocument")); - const document = edits.document; - if (!vscode.languages.match(extension_1.DocumentSelector, document)) { - return; - } - const uriString = document.uri.toString(); - if (!(uriString in trees)) { - return; - } - const jsonTreeOld = trees[uriString].jsonTree; - const text = document.getText(); - // const trees = getTrees(document); - // if (!trees) { - // return; - // } - // const oldTree = trees.jsonTree; - for (const edit of edits.contentChanges) { - const startIndex = edit.rangeOffset; - const oldEndIndex = edit.rangeOffset + edit.rangeLength; - const newEndIndex = edit.rangeOffset + edit.text.length; - const startPos = document.positionAt(startIndex); - const oldEndPos = document.positionAt(oldEndIndex); - const newEndPos = document.positionAt(newEndIndex); - // const startPosition: Parser.Point = { row: startPos.line, column: startPos.character }; - // const oldEndPosition: Parser.Point = { row: oldEndPos.line, column: oldEndPos.character }; - // const newEndPosition: Parser.Point = { row: newEndPos.line, column: newEndPos.character }; - const startPosition = toPoint(startPos); - const oldEndPosition = toPoint(oldEndPos); - const newEndPosition = toPoint(newEndPos); - const delta = { - startIndex, - oldEndIndex, - newEndIndex, - startPosition, - oldEndPosition, - newEndPosition, - }; - jsonTreeOld.edit(delta); - } - const jsonTree = JSONParser.parse(text, jsonTreeOld); - // trees[uriString].jsonTree = jsonTree; - // Todo: only reparse modified regex nodes. tree.getChangedRanges(); - const queryCaptures = queryNode(jsonTree.rootNode, `(regex) @regex`); - const regexTrees = {}; - const regexNodes = {}; - for (const queryCapture of queryCaptures) { - const node = queryCapture.node; - const range = { - startPosition: node.startPosition, - endPosition: node.endPosition, - startIndex: node.startIndex, - endIndex: node.endIndex - }; - const ranges = [range]; - const options = { includedRanges: ranges }; - const regexTree = regexParser.parse(text, jsonTreeOld, options); - regexTrees[node.id] = regexTree; - const regexNode = regexTree.rootNode; - regexNodes[regexNode.id] = node; - } - // vscode.window.showInformationMessage(JSON.stringify(tree)); - // const changedRanges = tree.getChangedRanges(oldTree); - // vscode.window.showInformationMessage(JSON.stringify(tree.rootNode.firstNamedChild)); - // tree.rootNode.firstNamedChild = null; - // vscode.window.showInformationMessage(JSON.stringify(tree.rootNode.firstNamedChild)); - // const regexCaptures = trees[uriString].regexCaptures; - // for (const edit of edits.contentChanges) { - // const editStartIndex = edit.rangeOffset; - // const editEndIndex = edit.rangeOffset + edit.rangeLength; - // for (let index = 0; index < trees[uriString].regexCaptures.length; index++) { - // const regexCapture = trees[uriString].regexCaptures[index]; - // if (regexCapture.node.startIndex <= editStartIndex && // Todo editIndex range can be both outside and inside the regexNode - // regexCapture.node.endIndex >= editEndIndex) { - // const regexTree = trees[uriString].regexTrees[index]; - // const text = tree.rootNode.descendantForIndex(editStartIndex).text; - // const newRegexTree = regexParser.parse(text, regexTree); - // trees[uriString].regexTrees[index] = newRegexTree; - // } - // } - // // for (let regexTree of trees[uriString].regexTrees) { - // // if (regexTree.rootNode.startIndex <= editStartIndex && // Todo editIndex range can be both outside and inside the regexNode - // // regexTree.rootNode.endIndex >= editEndIndex) { - // // const text = tree.rootNode.descendantForIndex(editStartIndex).text; - // // const newRegexTree = regexParser.parse(text, regexTree); - // // const index = trees[uriString].regexTrees.indexOf(regexTree); - // // trees[uriString].regexTrees[index] = newRegexTree; - // // } - // // } - // } - trees[uriString] = { - jsonTree: jsonTree, - regexTrees: regexTrees, - regexNodes: regexNodes, - }; - // vscode.window.showInformationMessage(JSON.stringify(trees[uriString])); -} - - -/***/ }), -/* 3 */ -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -var __dirname = "/"; -var Module=void 0!==Module?Module:{},TreeSitter=function(){var initPromise,document="object"==typeof window?{currentScript:window.document.currentScript}:null;class Parser{constructor(){this.initialize()}initialize(){throw new Error("cannot construct a Parser before calling `init()`")}static init(moduleOptions){return initPromise||(Module=Object.assign({},Module,moduleOptions),initPromise=new Promise((resolveInitPromise=>{var moduleOverrides=Object.assign({},Module),arguments_=[],thisProgram="./this.program",quit_=(e,t)=>{throw t},ENVIRONMENT_IS_WEB="object"==typeof window,ENVIRONMENT_IS_WORKER="function"==typeof importScripts,ENVIRONMENT_IS_NODE="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,scriptDirectory="",read_,readAsync,readBinary,setWindowTitle;function locateFile(e){return Module.locateFile?Module.locateFile(e,scriptDirectory):scriptDirectory+e}function logExceptionOnExit(e){if(e instanceof ExitStatus)return;err("exiting due to exception: "+e)}if(ENVIRONMENT_IS_NODE){var fs=__webpack_require__(4),nodePath=__webpack_require__(5);scriptDirectory=ENVIRONMENT_IS_WORKER?nodePath.dirname(scriptDirectory)+"/":__dirname+"/",read_=(e,t)=>(e=isFileURI(e)?new URL(e):nodePath.normalize(e),fs.readFileSync(e,t?void 0:"utf8")),readBinary=e=>{var t=read_(e,!0);return t.buffer||(t=new Uint8Array(t)),t},readAsync=(e,t,r)=>{e=isFileURI(e)?new URL(e):nodePath.normalize(e),fs.readFile(e,(function(e,_){e?r(e):t(_.buffer)}))},process.argv.length>1&&(thisProgram=process.argv[1].replace(/\\/g,"/")),arguments_=process.argv.slice(2), true&&(module.exports=Module),quit_=(e,t)=>{if(keepRuntimeAlive())throw process.exitCode=e,t;logExceptionOnExit(t),process.exit(e)},Module.inspect=function(){return"[Emscripten Module object]"}}else(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)&&(ENVIRONMENT_IS_WORKER?scriptDirectory=self.location.href:void 0!==document&&document.currentScript&&(scriptDirectory=document.currentScript.src),scriptDirectory=0!==scriptDirectory.indexOf("blob:")?scriptDirectory.substr(0,scriptDirectory.replace(/[?#].*/,"").lastIndexOf("/")+1):"",read_=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},ENVIRONMENT_IS_WORKER&&(readBinary=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),readAsync=(e,t,r)=>{var _=new XMLHttpRequest;_.open("GET",e,!0),_.responseType="arraybuffer",_.onload=()=>{200==_.status||0==_.status&&_.response?t(_.response):r()},_.onerror=r,_.send(null)},setWindowTitle=e=>document.title=e);var out=Module.print||console.log.bind(console),err=Module.printErr||console.warn.bind(console);Object.assign(Module,moduleOverrides),moduleOverrides=null,Module.arguments&&(arguments_=Module.arguments),Module.thisProgram&&(thisProgram=Module.thisProgram),Module.quit&&(quit_=Module.quit);var STACK_ALIGN=16,dynamicLibraries=Module.dynamicLibraries||[],wasmBinary;Module.wasmBinary&&(wasmBinary=Module.wasmBinary);var noExitRuntime=Module.noExitRuntime||!0,wasmMemory;"object"!=typeof WebAssembly&&abort("no native wasm support detected");var ABORT=!1,EXITSTATUS,UTF8Decoder="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,buffer,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function UTF8ArrayToString(e,t,r){for(var _=t+r,n=t;e[n]&&!(n>=_);)++n;if(n-t>16&&e.buffer&&UTF8Decoder)return UTF8Decoder.decode(e.subarray(t,n));for(var s="";t>10,56320|1023&l)}}else s+=String.fromCharCode((31&a)<<6|o)}else s+=String.fromCharCode(a)}return s}function UTF8ToString(e,t){return e?UTF8ArrayToString(HEAPU8,e,t):""}function stringToUTF8Array(e,t,r,_){if(!(_>0))return 0;for(var n=r,s=r+_-1,a=0;a=55296&&o<=57343)o=65536+((1023&o)<<10)|1023&e.charCodeAt(++a);if(o<=127){if(r>=s)break;t[r++]=o}else if(o<=2047){if(r+1>=s)break;t[r++]=192|o>>6,t[r++]=128|63&o}else if(o<=65535){if(r+2>=s)break;t[r++]=224|o>>12,t[r++]=128|o>>6&63,t[r++]=128|63&o}else{if(r+3>=s)break;t[r++]=240|o>>18,t[r++]=128|o>>12&63,t[r++]=128|o>>6&63,t[r++]=128|63&o}}return t[r]=0,r-n}function stringToUTF8(e,t,r){return stringToUTF8Array(e,HEAPU8,t,r)}function lengthBytesUTF8(e){for(var t=0,r=0;r=55296&&_<=57343?(t+=4,++r):t+=3}return t}function updateGlobalBufferAndViews(e){buffer=e,Module.HEAP8=HEAP8=new Int8Array(e),Module.HEAP16=HEAP16=new Int16Array(e),Module.HEAP32=HEAP32=new Int32Array(e),Module.HEAPU8=HEAPU8=new Uint8Array(e),Module.HEAPU16=HEAPU16=new Uint16Array(e),Module.HEAPU32=HEAPU32=new Uint32Array(e),Module.HEAPF32=HEAPF32=new Float32Array(e),Module.HEAPF64=HEAPF64=new Float64Array(e)}var INITIAL_MEMORY=Module.INITIAL_MEMORY||33554432;wasmMemory=Module.wasmMemory?Module.wasmMemory:new WebAssembly.Memory({initial:INITIAL_MEMORY/65536,maximum:32768}),wasmMemory&&(buffer=wasmMemory.buffer),INITIAL_MEMORY=buffer.byteLength,updateGlobalBufferAndViews(buffer);var wasmTable=new WebAssembly.Table({initial:20,element:"anyfunc"}),__ATPRERUN__=[],__ATINIT__=[],__ATMAIN__=[],__ATPOSTRUN__=[],__RELOC_FUNCS__=[],runtimeInitialized=!1;function keepRuntimeAlive(){return noExitRuntime}function preRun(){if(Module.preRun)for("function"==typeof Module.preRun&&(Module.preRun=[Module.preRun]);Module.preRun.length;)addOnPreRun(Module.preRun.shift());callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=!0,callRuntimeCallbacks(__RELOC_FUNCS__),callRuntimeCallbacks(__ATINIT__)}function preMain(){callRuntimeCallbacks(__ATMAIN__)}function postRun(){if(Module.postRun)for("function"==typeof Module.postRun&&(Module.postRun=[Module.postRun]);Module.postRun.length;)addOnPostRun(Module.postRun.shift());callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(e){__ATPRERUN__.unshift(e)}function addOnInit(e){__ATINIT__.unshift(e)}function addOnPostRun(e){__ATPOSTRUN__.unshift(e)}var runDependencies=0,runDependencyWatcher=null,dependenciesFulfilled=null;function addRunDependency(e){runDependencies++,Module.monitorRunDependencies&&Module.monitorRunDependencies(runDependencies)}function removeRunDependency(e){if(runDependencies--,Module.monitorRunDependencies&&Module.monitorRunDependencies(runDependencies),0==runDependencies&&(null!==runDependencyWatcher&&(clearInterval(runDependencyWatcher),runDependencyWatcher=null),dependenciesFulfilled)){var t=dependenciesFulfilled;dependenciesFulfilled=null,t()}}function abort(e){throw Module.onAbort&&Module.onAbort(e),err(e="Aborted("+e+")"),ABORT=!0,EXITSTATUS=1,e+=". Build with -sASSERTIONS for more info.",new WebAssembly.RuntimeError(e)}var dataURIPrefix="data:application/octet-stream;base64,",wasmBinaryFile,tempDouble,tempI64;function isDataURI(e){return e.startsWith(dataURIPrefix)}function isFileURI(e){return e.startsWith("file://")}function getBinary(e){try{if(e==wasmBinaryFile&&wasmBinary)return new Uint8Array(wasmBinary);if(readBinary)return readBinary(e);throw"both async and sync fetching of the wasm failed"}catch(e){abort(e)}}function getBinaryPromise(){if(!wasmBinary&&(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)){if("function"==typeof fetch&&!isFileURI(wasmBinaryFile))return fetch(wasmBinaryFile,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+wasmBinaryFile+"'";return e.arrayBuffer()})).catch((function(){return getBinary(wasmBinaryFile)}));if(readAsync)return new Promise((function(e,t){readAsync(wasmBinaryFile,(function(t){e(new Uint8Array(t))}),t)}))}return Promise.resolve().then((function(){return getBinary(wasmBinaryFile)}))}function createWasm(){var e={env:asmLibraryArg,wasi_snapshot_preview1:asmLibraryArg,"GOT.mem":new Proxy(asmLibraryArg,GOTHandler),"GOT.func":new Proxy(asmLibraryArg,GOTHandler)};function t(e,t){var r=e.exports;r=relocateExports(r,1024);var _=getDylinkMetadata(t);_.neededDynlibs&&(dynamicLibraries=_.neededDynlibs.concat(dynamicLibraries)),mergeLibSymbols(r,"main"),Module.asm=r,addOnInit(Module.asm.__wasm_call_ctors),__RELOC_FUNCS__.push(Module.asm.__wasm_apply_data_relocs),removeRunDependency("wasm-instantiate")}function r(e){t(e.instance,e.module)}function _(t){return getBinaryPromise().then((function(t){return WebAssembly.instantiate(t,e)})).then((function(e){return e})).then(t,(function(e){err("failed to asynchronously prepare wasm: "+e),abort(e)}))}if(addRunDependency("wasm-instantiate"),Module.instantiateWasm)try{return Module.instantiateWasm(e,t)}catch(e){return err("Module.instantiateWasm callback failed with error: "+e),!1}return wasmBinary||"function"!=typeof WebAssembly.instantiateStreaming||isDataURI(wasmBinaryFile)||isFileURI(wasmBinaryFile)||ENVIRONMENT_IS_NODE||"function"!=typeof fetch?_(r):fetch(wasmBinaryFile,{credentials:"same-origin"}).then((function(t){return WebAssembly.instantiateStreaming(t,e).then(r,(function(e){return err("wasm streaming compile failed: "+e),err("falling back to ArrayBuffer instantiation"),_(r)}))})),{}}wasmBinaryFile="tree-sitter.wasm",isDataURI(wasmBinaryFile)||(wasmBinaryFile=locateFile(wasmBinaryFile));var ASM_CONSTS={};function ExitStatus(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}var GOT={},CurrentModuleWeakSymbols=new Set([]),GOTHandler={get:function(e,t){var r=GOT[t];return r||(r=GOT[t]=new WebAssembly.Global({value:"i32",mutable:!0})),CurrentModuleWeakSymbols.has(t)||(r.required=!0),r}};function callRuntimeCallbacks(e){for(;e.length>0;)e.shift()(Module)}function getDylinkMetadata(e){var t=0,r=0;function _(){for(var r=0,_=1;;){var n=e[t++];if(r+=(127&n)*_,_*=128,!(128&n))break}return r}function n(){var r=_();return UTF8ArrayToString(e,(t+=r)-r,r)}function s(e,t){if(e)throw new Error(t)}var a="dylink.0";if(e instanceof WebAssembly.Module){var o=WebAssembly.Module.customSections(e,a);0===o.length&&(a="dylink",o=WebAssembly.Module.customSections(e,a)),s(0===o.length,"need dylink section"),r=(e=new Uint8Array(o[0])).length}else{s(!(1836278016==new Uint32Array(new Uint8Array(e.subarray(0,24)).buffer)[0]),"need to see wasm magic number"),s(0!==e[8],"need the dylink section to be first"),t=9;var i=_();r=t+i,a=n()}var l={neededDynlibs:[],tlsExports:new Set,weakImports:new Set};if("dylink"==a){l.memorySize=_(),l.memoryAlign=_(),l.tableSize=_(),l.tableAlign=_();for(var u=_(),d=0;d>0];case"i16":return HEAP16[e>>1];case"i32":case"i64":return HEAP32[e>>2];case"float":return HEAPF32[e>>2];case"double":return HEAPF64[e>>3];case"*":return HEAPU32[e>>2];default:abort("invalid type for getValue: "+t)}return null}function asmjsMangle(e){return 0==e.indexOf("dynCall_")||["stackAlloc","stackSave","stackRestore","getTempRet0","setTempRet0"].includes(e)?e:"_"+e}function mergeLibSymbols(e,t){for(var r in e)if(e.hasOwnProperty(r)){asmLibraryArg.hasOwnProperty(r)||(asmLibraryArg[r]=e[r]);var _=asmjsMangle(r);Module.hasOwnProperty(_)||(Module[_]=e[r]),"__main_argc_argv"==r&&(Module._main=e[r])}}var LDSO={loadedLibsByName:{},loadedLibsByHandle:{}};function dynCallLegacy(e,t,r){var _=Module["dynCall_"+e];return r&&r.length?_.apply(null,[t].concat(r)):_.call(null,t)}var wasmTableMirror=[];function getWasmTableEntry(e){var t=wasmTableMirror[e];return t||(e>=wasmTableMirror.length&&(wasmTableMirror.length=e+1),wasmTableMirror[e]=t=wasmTable.get(e)),t}function dynCall(e,t,r){return e.includes("j")?dynCallLegacy(e,t,r):getWasmTableEntry(t).apply(null,r)}function createInvokeFunction(e){return function(){var t=stackSave();try{return dynCall(e,arguments[0],Array.prototype.slice.call(arguments,1))}catch(e){if(stackRestore(t),e!==e+0)throw e;_setThrew(1,0)}}}var ___heap_base=78144;function zeroMemory(e,t){return HEAPU8.fill(0,e,e+t),e}function getMemory(e){if(runtimeInitialized)return zeroMemory(_malloc(e),e);var t=___heap_base,r=t+e+15&-16;return ___heap_base=r,GOT.__heap_base.value=r,t}function isInternalSym(e){return["__cpp_exception","__c_longjmp","__wasm_apply_data_relocs","__dso_handle","__tls_size","__tls_align","__set_stack_limits","_emscripten_tls_init","__wasm_init_tls","__wasm_call_ctors","__start_em_asm","__stop_em_asm"].includes(e)}function uleb128Encode(e,t){e<128?t.push(e):t.push(e%128|128,e>>7)}function sigToWasmTypes(e){for(var t={i:"i32",j:"i32",f:"f32",d:"f64",p:"i32"},r={parameters:[],results:"v"==e[0]?[]:[t[e[0]]]},_=1;_>0];if(firstLoad){var memAlign=Math.pow(2,metadata.memoryAlign);memAlign=Math.max(memAlign,STACK_ALIGN);var memoryBase=metadata.memorySize?alignMemory(getMemory(metadata.memorySize+memAlign),memAlign):0,tableBase=metadata.tableSize?wasmTable.length:0;handle&&(HEAP8[handle+12>>0]=1,HEAPU32[handle+16>>2]=memoryBase,HEAP32[handle+20>>2]=metadata.memorySize,HEAPU32[handle+24>>2]=tableBase,HEAP32[handle+28>>2]=metadata.tableSize)}else memoryBase=HEAPU32[handle+16>>2],tableBase=HEAPU32[handle+24>>2];var tableGrowthNeeded=tableBase+metadata.tableSize-wasmTable.length,moduleExports;function resolveSymbol(e){var t=resolveGlobalSymbol(e,!1);return t||(t=moduleExports[e]),t}tableGrowthNeeded>0&&wasmTable.grow(tableGrowthNeeded);var proxyHandler={get:function(e,t){switch(t){case"__memory_base":return memoryBase;case"__table_base":return tableBase}if(t in asmLibraryArg)return asmLibraryArg[t];var r;t in e||(e[t]=function(){return r||(r=resolveSymbol(t)),r.apply(null,arguments)});return e[t]}},proxy=new Proxy({},proxyHandler),info={"GOT.mem":new Proxy({},GOTHandler),"GOT.func":new Proxy({},GOTHandler),env:proxy,wasi_snapshot_preview1:proxy};function postInstantiation(instance){function addEmAsm(addr,body){for(var args=[],arity=0;arity<16&&-1!=body.indexOf("$"+arity);arity++)args.push("$"+arity);args=args.join(",");var func="("+args+" ) => { "+body+"};";ASM_CONSTS[start]=eval(func)}if(updateTableMap(tableBase,metadata.tableSize),moduleExports=relocateExports(instance.exports,memoryBase),flags.allowUndefined||reportUndefinedSymbols(),"__start_em_asm"in moduleExports)for(var start=moduleExports.__start_em_asm,stop=moduleExports.__stop_em_asm;startt(new Uint8Array(e))),r)}));if(!readBinary)throw new Error(e+": file not found, and synchronous loading of external files is not available");return readBinary(e)}function s(){if("undefined"!=typeof preloadedWasm&&preloadedWasm[e]){var _=preloadedWasm[e];return t.loadAsync?Promise.resolve(_):_}return t.loadAsync?n(e).then((function(e){return loadWebAssemblyModule(e,t,r)})):loadWebAssemblyModule(n(e),t,r)}function a(t){_.global&&mergeLibSymbols(t,e),_.module=t}return _={refcount:t.nodelete?1/0:1,name:e,module:"loading",global:t.global},LDSO.loadedLibsByName[e]=_,r&&(LDSO.loadedLibsByHandle[r]=_),t.loadAsync?s().then((function(e){return a(e),!0})):(a(s()),!0)}function reportUndefinedSymbols(){for(var e in GOT)if(0==GOT[e].value){var t=resolveGlobalSymbol(e,!0);if(!t&&!GOT[e].required)continue;if("function"==typeof t)GOT[e].value=addFunction(t,t.sig);else{if("number"!=typeof t)throw new Error("bad export type for `"+e+"`: "+typeof t);GOT[e].value=t}}}function preloadDylibs(){dynamicLibraries.length?(addRunDependency("preloadDylibs"),dynamicLibraries.reduce((function(e,t){return e.then((function(){return loadDynamicLibrary(t,{loadAsync:!0,global:!0,nodelete:!0,allowUndefined:!0})}))}),Promise.resolve()).then((function(){reportUndefinedSymbols(),removeRunDependency("preloadDylibs")}))):reportUndefinedSymbols()}function setValue(e,t,r="i8"){switch(r.endsWith("*")&&(r="*"),r){case"i1":case"i8":HEAP8[e>>0]=t;break;case"i16":HEAP16[e>>1]=t;break;case"i32":HEAP32[e>>2]=t;break;case"i64":tempI64=[t>>>0,(tempDouble=t,+Math.abs(tempDouble)>=1?tempDouble>0?(0|Math.min(+Math.floor(tempDouble/4294967296),4294967295))>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[e>>2]=tempI64[0],HEAP32[e+4>>2]=tempI64[1];break;case"float":HEAPF32[e>>2]=t;break;case"double":HEAPF64[e>>3]=t;break;case"*":HEAPU32[e>>2]=t;break;default:abort("invalid type for setValue: "+r)}}var ___memory_base=new WebAssembly.Global({value:"i32",mutable:!1},1024),___stack_pointer=new WebAssembly.Global({value:"i32",mutable:!0},78144),___table_base=new WebAssembly.Global({value:"i32",mutable:!1},1),nowIsMonotonic=!0,_emscripten_get_now;function __emscripten_get_now_is_monotonic(){return nowIsMonotonic}function _abort(){abort("")}function _emscripten_date_now(){return Date.now()}function _emscripten_memcpy_big(e,t,r){HEAPU8.copyWithin(e,t,t+r)}function getHeapMax(){return 2147483648}function emscripten_realloc_buffer(e){try{return wasmMemory.grow(e-buffer.byteLength+65535>>>16),updateGlobalBufferAndViews(wasmMemory.buffer),1}catch(e){}}function _emscripten_resize_heap(e){var t=HEAPU8.length;e>>>=0;var r=getHeapMax();if(e>r)return!1;for(var _=1;_<=4;_*=2){var n=t*(1+.2/_);if(n=Math.min(n,e+100663296),emscripten_realloc_buffer(Math.min(r,(s=Math.max(e,n))+((a=65536)-s%a)%a)))return!0}var s,a;return!1}__emscripten_get_now_is_monotonic.sig="i",Module._abort=_abort,_abort.sig="v",_emscripten_date_now.sig="d",_emscripten_get_now=ENVIRONMENT_IS_NODE?()=>{var e=process.hrtime();return 1e3*e[0]+e[1]/1e6}:()=>performance.now(),_emscripten_get_now.sig="d",_emscripten_memcpy_big.sig="vppp",_emscripten_resize_heap.sig="ip";var SYSCALLS={DEFAULT_POLLMASK:5,calculateAt:function(e,t,r){if(PATH.isAbs(t))return t;var _;-100===e?_=FS.cwd():_=SYSCALLS.getStreamFromFD(e).path;if(0==t.length){if(!r)throw new FS.ErrnoError(44);return _}return PATH.join2(_,t)},doStat:function(e,t,r){try{var _=e(t)}catch(e){if(e&&e.node&&PATH.normalize(t)!==PATH.normalize(FS.getPath(e.node)))return-54;throw e}HEAP32[r>>2]=_.dev,HEAP32[r+8>>2]=_.ino,HEAP32[r+12>>2]=_.mode,HEAPU32[r+16>>2]=_.nlink,HEAP32[r+20>>2]=_.uid,HEAP32[r+24>>2]=_.gid,HEAP32[r+28>>2]=_.rdev,tempI64=[_.size>>>0,(tempDouble=_.size,+Math.abs(tempDouble)>=1?tempDouble>0?(0|Math.min(+Math.floor(tempDouble/4294967296),4294967295))>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[r+40>>2]=tempI64[0],HEAP32[r+44>>2]=tempI64[1],HEAP32[r+48>>2]=4096,HEAP32[r+52>>2]=_.blocks;var n=_.atime.getTime(),s=_.mtime.getTime(),a=_.ctime.getTime();return tempI64=[Math.floor(n/1e3)>>>0,(tempDouble=Math.floor(n/1e3),+Math.abs(tempDouble)>=1?tempDouble>0?(0|Math.min(+Math.floor(tempDouble/4294967296),4294967295))>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[r+56>>2]=tempI64[0],HEAP32[r+60>>2]=tempI64[1],HEAPU32[r+64>>2]=n%1e3*1e3,tempI64=[Math.floor(s/1e3)>>>0,(tempDouble=Math.floor(s/1e3),+Math.abs(tempDouble)>=1?tempDouble>0?(0|Math.min(+Math.floor(tempDouble/4294967296),4294967295))>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[r+72>>2]=tempI64[0],HEAP32[r+76>>2]=tempI64[1],HEAPU32[r+80>>2]=s%1e3*1e3,tempI64=[Math.floor(a/1e3)>>>0,(tempDouble=Math.floor(a/1e3),+Math.abs(tempDouble)>=1?tempDouble>0?(0|Math.min(+Math.floor(tempDouble/4294967296),4294967295))>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[r+88>>2]=tempI64[0],HEAP32[r+92>>2]=tempI64[1],HEAPU32[r+96>>2]=a%1e3*1e3,tempI64=[_.ino>>>0,(tempDouble=_.ino,+Math.abs(tempDouble)>=1?tempDouble>0?(0|Math.min(+Math.floor(tempDouble/4294967296),4294967295))>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[r+104>>2]=tempI64[0],HEAP32[r+108>>2]=tempI64[1],0},doMsync:function(e,t,r,_,n){if(!FS.isFile(t.node.mode))throw new FS.ErrnoError(43);if(2&_)return 0;var s=HEAPU8.slice(e,e+r);FS.msync(t,s,n,r,_)},varargs:void 0,get:function(){return SYSCALLS.varargs+=4,HEAP32[SYSCALLS.varargs-4>>2]},getStr:function(e){return UTF8ToString(e)},getStreamFromFD:function(e){var t=FS.getStream(e);if(!t)throw new FS.ErrnoError(8);return t}};function _proc_exit(e){EXITSTATUS=e,keepRuntimeAlive()||(Module.onExit&&Module.onExit(e),ABORT=!0),quit_(e,new ExitStatus(e))}function exitJS(e,t){EXITSTATUS=e,_proc_exit(e)}_proc_exit.sig="vi";var _exit=exitJS;function _fd_close(e){try{var t=SYSCALLS.getStreamFromFD(e);return FS.close(t),0}catch(e){if("undefined"==typeof FS||!(e instanceof FS.ErrnoError))throw e;return e.errno}}function convertI32PairToI53Checked(e,t){return t+2097152>>>0<4194305-!!e?(e>>>0)+4294967296*t:NaN}function _fd_seek(e,t,r,_,n){try{var s=convertI32PairToI53Checked(t,r);if(isNaN(s))return 61;var a=SYSCALLS.getStreamFromFD(e);return FS.llseek(a,s,_),tempI64=[a.position>>>0,(tempDouble=a.position,+Math.abs(tempDouble)>=1?tempDouble>0?(0|Math.min(+Math.floor(tempDouble/4294967296),4294967295))>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[n>>2]=tempI64[0],HEAP32[n+4>>2]=tempI64[1],a.getdents&&0===s&&0===_&&(a.getdents=null),0}catch(e){if("undefined"==typeof FS||!(e instanceof FS.ErrnoError))throw e;return e.errno}}function doWritev(e,t,r,_){for(var n=0,s=0;s>2],o=HEAPU32[t+4>>2];t+=8;var i=FS.write(e,HEAP8,a,o,_);if(i<0)return-1;n+=i,void 0!==_&&(_+=i)}return n}function _fd_write(e,t,r,_){try{var n=doWritev(SYSCALLS.getStreamFromFD(e),t,r);return HEAPU32[_>>2]=n,0}catch(e){if("undefined"==typeof FS||!(e instanceof FS.ErrnoError))throw e;return e.errno}}function _tree_sitter_log_callback(e,t){if(currentLogCallback){const r=UTF8ToString(t);currentLogCallback(r,0!==e)}}function _tree_sitter_parse_callback(e,t,r,_,n){var s=currentParseCallback(t,{row:r,column:_});"string"==typeof s?(setValue(n,s.length,"i32"),stringToUTF16(s,e,10240)):setValue(n,0,"i32")}function handleException(e){if(e instanceof ExitStatus||"unwind"==e)return EXITSTATUS;quit_(1,e)}function allocateUTF8OnStack(e){var t=lengthBytesUTF8(e)+1,r=stackAlloc(t);return stringToUTF8Array(e,HEAP8,r,t),r}function stringToUTF16(e,t,r){if(void 0===r&&(r=2147483647),r<2)return 0;for(var _=t,n=(r-=2)<2*e.length?r/2:e.length,s=0;s>1]=a,t+=2}return HEAP16[t>>1]=0,t-_}function AsciiToString(e){for(var t="";;){var r=HEAPU8[e++>>0];if(!r)return t;t+=String.fromCharCode(r)}}_exit.sig="vi",_fd_close.sig="ii",_fd_seek.sig="iijip",_fd_write.sig="iippp";var asmLibraryArg={__heap_base:___heap_base,__indirect_function_table:wasmTable,__memory_base:___memory_base,__stack_pointer:___stack_pointer,__table_base:___table_base,_emscripten_get_now_is_monotonic:__emscripten_get_now_is_monotonic,abort:_abort,emscripten_get_now:_emscripten_get_now,emscripten_memcpy_big:_emscripten_memcpy_big,emscripten_resize_heap:_emscripten_resize_heap,exit:_exit,fd_close:_fd_close,fd_seek:_fd_seek,fd_write:_fd_write,memory:wasmMemory,tree_sitter_log_callback:_tree_sitter_log_callback,tree_sitter_parse_callback:_tree_sitter_parse_callback},asm=createWasm(),___wasm_call_ctors=Module.___wasm_call_ctors=function(){return(___wasm_call_ctors=Module.___wasm_call_ctors=Module.asm.__wasm_call_ctors).apply(null,arguments)},___wasm_apply_data_relocs=Module.___wasm_apply_data_relocs=function(){return(___wasm_apply_data_relocs=Module.___wasm_apply_data_relocs=Module.asm.__wasm_apply_data_relocs).apply(null,arguments)},_malloc=Module._malloc=function(){return(_malloc=Module._malloc=Module.asm.malloc).apply(null,arguments)},_calloc=Module._calloc=function(){return(_calloc=Module._calloc=Module.asm.calloc).apply(null,arguments)},_realloc=Module._realloc=function(){return(_realloc=Module._realloc=Module.asm.realloc).apply(null,arguments)},_free=Module._free=function(){return(_free=Module._free=Module.asm.free).apply(null,arguments)},_ts_language_symbol_count=Module._ts_language_symbol_count=function(){return(_ts_language_symbol_count=Module._ts_language_symbol_count=Module.asm.ts_language_symbol_count).apply(null,arguments)},_ts_language_version=Module._ts_language_version=function(){return(_ts_language_version=Module._ts_language_version=Module.asm.ts_language_version).apply(null,arguments)},_ts_language_field_count=Module._ts_language_field_count=function(){return(_ts_language_field_count=Module._ts_language_field_count=Module.asm.ts_language_field_count).apply(null,arguments)},_ts_language_symbol_name=Module._ts_language_symbol_name=function(){return(_ts_language_symbol_name=Module._ts_language_symbol_name=Module.asm.ts_language_symbol_name).apply(null,arguments)},_ts_language_symbol_for_name=Module._ts_language_symbol_for_name=function(){return(_ts_language_symbol_for_name=Module._ts_language_symbol_for_name=Module.asm.ts_language_symbol_for_name).apply(null,arguments)},_ts_language_symbol_type=Module._ts_language_symbol_type=function(){return(_ts_language_symbol_type=Module._ts_language_symbol_type=Module.asm.ts_language_symbol_type).apply(null,arguments)},_ts_language_field_name_for_id=Module._ts_language_field_name_for_id=function(){return(_ts_language_field_name_for_id=Module._ts_language_field_name_for_id=Module.asm.ts_language_field_name_for_id).apply(null,arguments)},_memset=Module._memset=function(){return(_memset=Module._memset=Module.asm.memset).apply(null,arguments)},_memcpy=Module._memcpy=function(){return(_memcpy=Module._memcpy=Module.asm.memcpy).apply(null,arguments)},_ts_parser_delete=Module._ts_parser_delete=function(){return(_ts_parser_delete=Module._ts_parser_delete=Module.asm.ts_parser_delete).apply(null,arguments)},_ts_parser_reset=Module._ts_parser_reset=function(){return(_ts_parser_reset=Module._ts_parser_reset=Module.asm.ts_parser_reset).apply(null,arguments)},_ts_parser_set_language=Module._ts_parser_set_language=function(){return(_ts_parser_set_language=Module._ts_parser_set_language=Module.asm.ts_parser_set_language).apply(null,arguments)},_ts_parser_timeout_micros=Module._ts_parser_timeout_micros=function(){return(_ts_parser_timeout_micros=Module._ts_parser_timeout_micros=Module.asm.ts_parser_timeout_micros).apply(null,arguments)},_ts_parser_set_timeout_micros=Module._ts_parser_set_timeout_micros=function(){return(_ts_parser_set_timeout_micros=Module._ts_parser_set_timeout_micros=Module.asm.ts_parser_set_timeout_micros).apply(null,arguments)},_memmove=Module._memmove=function(){return(_memmove=Module._memmove=Module.asm.memmove).apply(null,arguments)},_memcmp=Module._memcmp=function(){return(_memcmp=Module._memcmp=Module.asm.memcmp).apply(null,arguments)},_ts_query_new=Module._ts_query_new=function(){return(_ts_query_new=Module._ts_query_new=Module.asm.ts_query_new).apply(null,arguments)},_ts_query_delete=Module._ts_query_delete=function(){return(_ts_query_delete=Module._ts_query_delete=Module.asm.ts_query_delete).apply(null,arguments)},_iswspace=Module._iswspace=function(){return(_iswspace=Module._iswspace=Module.asm.iswspace).apply(null,arguments)},_iswalnum=Module._iswalnum=function(){return(_iswalnum=Module._iswalnum=Module.asm.iswalnum).apply(null,arguments)},_ts_query_pattern_count=Module._ts_query_pattern_count=function(){return(_ts_query_pattern_count=Module._ts_query_pattern_count=Module.asm.ts_query_pattern_count).apply(null,arguments)},_ts_query_capture_count=Module._ts_query_capture_count=function(){return(_ts_query_capture_count=Module._ts_query_capture_count=Module.asm.ts_query_capture_count).apply(null,arguments)},_ts_query_string_count=Module._ts_query_string_count=function(){return(_ts_query_string_count=Module._ts_query_string_count=Module.asm.ts_query_string_count).apply(null,arguments)},_ts_query_capture_name_for_id=Module._ts_query_capture_name_for_id=function(){return(_ts_query_capture_name_for_id=Module._ts_query_capture_name_for_id=Module.asm.ts_query_capture_name_for_id).apply(null,arguments)},_ts_query_string_value_for_id=Module._ts_query_string_value_for_id=function(){return(_ts_query_string_value_for_id=Module._ts_query_string_value_for_id=Module.asm.ts_query_string_value_for_id).apply(null,arguments)},_ts_query_predicates_for_pattern=Module._ts_query_predicates_for_pattern=function(){return(_ts_query_predicates_for_pattern=Module._ts_query_predicates_for_pattern=Module.asm.ts_query_predicates_for_pattern).apply(null,arguments)},_ts_tree_copy=Module._ts_tree_copy=function(){return(_ts_tree_copy=Module._ts_tree_copy=Module.asm.ts_tree_copy).apply(null,arguments)},_ts_tree_delete=Module._ts_tree_delete=function(){return(_ts_tree_delete=Module._ts_tree_delete=Module.asm.ts_tree_delete).apply(null,arguments)},_ts_init=Module._ts_init=function(){return(_ts_init=Module._ts_init=Module.asm.ts_init).apply(null,arguments)},_ts_parser_new_wasm=Module._ts_parser_new_wasm=function(){return(_ts_parser_new_wasm=Module._ts_parser_new_wasm=Module.asm.ts_parser_new_wasm).apply(null,arguments)},_ts_parser_enable_logger_wasm=Module._ts_parser_enable_logger_wasm=function(){return(_ts_parser_enable_logger_wasm=Module._ts_parser_enable_logger_wasm=Module.asm.ts_parser_enable_logger_wasm).apply(null,arguments)},_ts_parser_parse_wasm=Module._ts_parser_parse_wasm=function(){return(_ts_parser_parse_wasm=Module._ts_parser_parse_wasm=Module.asm.ts_parser_parse_wasm).apply(null,arguments)},_ts_language_type_is_named_wasm=Module._ts_language_type_is_named_wasm=function(){return(_ts_language_type_is_named_wasm=Module._ts_language_type_is_named_wasm=Module.asm.ts_language_type_is_named_wasm).apply(null,arguments)},_ts_language_type_is_visible_wasm=Module._ts_language_type_is_visible_wasm=function(){return(_ts_language_type_is_visible_wasm=Module._ts_language_type_is_visible_wasm=Module.asm.ts_language_type_is_visible_wasm).apply(null,arguments)},_ts_tree_root_node_wasm=Module._ts_tree_root_node_wasm=function(){return(_ts_tree_root_node_wasm=Module._ts_tree_root_node_wasm=Module.asm.ts_tree_root_node_wasm).apply(null,arguments)},_ts_tree_edit_wasm=Module._ts_tree_edit_wasm=function(){return(_ts_tree_edit_wasm=Module._ts_tree_edit_wasm=Module.asm.ts_tree_edit_wasm).apply(null,arguments)},_ts_tree_get_changed_ranges_wasm=Module._ts_tree_get_changed_ranges_wasm=function(){return(_ts_tree_get_changed_ranges_wasm=Module._ts_tree_get_changed_ranges_wasm=Module.asm.ts_tree_get_changed_ranges_wasm).apply(null,arguments)},_ts_tree_cursor_new_wasm=Module._ts_tree_cursor_new_wasm=function(){return(_ts_tree_cursor_new_wasm=Module._ts_tree_cursor_new_wasm=Module.asm.ts_tree_cursor_new_wasm).apply(null,arguments)},_ts_tree_cursor_delete_wasm=Module._ts_tree_cursor_delete_wasm=function(){return(_ts_tree_cursor_delete_wasm=Module._ts_tree_cursor_delete_wasm=Module.asm.ts_tree_cursor_delete_wasm).apply(null,arguments)},_ts_tree_cursor_reset_wasm=Module._ts_tree_cursor_reset_wasm=function(){return(_ts_tree_cursor_reset_wasm=Module._ts_tree_cursor_reset_wasm=Module.asm.ts_tree_cursor_reset_wasm).apply(null,arguments)},_ts_tree_cursor_goto_first_child_wasm=Module._ts_tree_cursor_goto_first_child_wasm=function(){return(_ts_tree_cursor_goto_first_child_wasm=Module._ts_tree_cursor_goto_first_child_wasm=Module.asm.ts_tree_cursor_goto_first_child_wasm).apply(null,arguments)},_ts_tree_cursor_goto_next_sibling_wasm=Module._ts_tree_cursor_goto_next_sibling_wasm=function(){return(_ts_tree_cursor_goto_next_sibling_wasm=Module._ts_tree_cursor_goto_next_sibling_wasm=Module.asm.ts_tree_cursor_goto_next_sibling_wasm).apply(null,arguments)},_ts_tree_cursor_goto_parent_wasm=Module._ts_tree_cursor_goto_parent_wasm=function(){return(_ts_tree_cursor_goto_parent_wasm=Module._ts_tree_cursor_goto_parent_wasm=Module.asm.ts_tree_cursor_goto_parent_wasm).apply(null,arguments)},_ts_tree_cursor_current_node_type_id_wasm=Module._ts_tree_cursor_current_node_type_id_wasm=function(){return(_ts_tree_cursor_current_node_type_id_wasm=Module._ts_tree_cursor_current_node_type_id_wasm=Module.asm.ts_tree_cursor_current_node_type_id_wasm).apply(null,arguments)},_ts_tree_cursor_current_node_is_named_wasm=Module._ts_tree_cursor_current_node_is_named_wasm=function(){return(_ts_tree_cursor_current_node_is_named_wasm=Module._ts_tree_cursor_current_node_is_named_wasm=Module.asm.ts_tree_cursor_current_node_is_named_wasm).apply(null,arguments)},_ts_tree_cursor_current_node_is_missing_wasm=Module._ts_tree_cursor_current_node_is_missing_wasm=function(){return(_ts_tree_cursor_current_node_is_missing_wasm=Module._ts_tree_cursor_current_node_is_missing_wasm=Module.asm.ts_tree_cursor_current_node_is_missing_wasm).apply(null,arguments)},_ts_tree_cursor_current_node_id_wasm=Module._ts_tree_cursor_current_node_id_wasm=function(){return(_ts_tree_cursor_current_node_id_wasm=Module._ts_tree_cursor_current_node_id_wasm=Module.asm.ts_tree_cursor_current_node_id_wasm).apply(null,arguments)},_ts_tree_cursor_start_position_wasm=Module._ts_tree_cursor_start_position_wasm=function(){return(_ts_tree_cursor_start_position_wasm=Module._ts_tree_cursor_start_position_wasm=Module.asm.ts_tree_cursor_start_position_wasm).apply(null,arguments)},_ts_tree_cursor_end_position_wasm=Module._ts_tree_cursor_end_position_wasm=function(){return(_ts_tree_cursor_end_position_wasm=Module._ts_tree_cursor_end_position_wasm=Module.asm.ts_tree_cursor_end_position_wasm).apply(null,arguments)},_ts_tree_cursor_start_index_wasm=Module._ts_tree_cursor_start_index_wasm=function(){return(_ts_tree_cursor_start_index_wasm=Module._ts_tree_cursor_start_index_wasm=Module.asm.ts_tree_cursor_start_index_wasm).apply(null,arguments)},_ts_tree_cursor_end_index_wasm=Module._ts_tree_cursor_end_index_wasm=function(){return(_ts_tree_cursor_end_index_wasm=Module._ts_tree_cursor_end_index_wasm=Module.asm.ts_tree_cursor_end_index_wasm).apply(null,arguments)},_ts_tree_cursor_current_field_id_wasm=Module._ts_tree_cursor_current_field_id_wasm=function(){return(_ts_tree_cursor_current_field_id_wasm=Module._ts_tree_cursor_current_field_id_wasm=Module.asm.ts_tree_cursor_current_field_id_wasm).apply(null,arguments)},_ts_tree_cursor_current_node_wasm=Module._ts_tree_cursor_current_node_wasm=function(){return(_ts_tree_cursor_current_node_wasm=Module._ts_tree_cursor_current_node_wasm=Module.asm.ts_tree_cursor_current_node_wasm).apply(null,arguments)},_ts_node_symbol_wasm=Module._ts_node_symbol_wasm=function(){return(_ts_node_symbol_wasm=Module._ts_node_symbol_wasm=Module.asm.ts_node_symbol_wasm).apply(null,arguments)},_ts_node_child_count_wasm=Module._ts_node_child_count_wasm=function(){return(_ts_node_child_count_wasm=Module._ts_node_child_count_wasm=Module.asm.ts_node_child_count_wasm).apply(null,arguments)},_ts_node_named_child_count_wasm=Module._ts_node_named_child_count_wasm=function(){return(_ts_node_named_child_count_wasm=Module._ts_node_named_child_count_wasm=Module.asm.ts_node_named_child_count_wasm).apply(null,arguments)},_ts_node_child_wasm=Module._ts_node_child_wasm=function(){return(_ts_node_child_wasm=Module._ts_node_child_wasm=Module.asm.ts_node_child_wasm).apply(null,arguments)},_ts_node_named_child_wasm=Module._ts_node_named_child_wasm=function(){return(_ts_node_named_child_wasm=Module._ts_node_named_child_wasm=Module.asm.ts_node_named_child_wasm).apply(null,arguments)},_ts_node_child_by_field_id_wasm=Module._ts_node_child_by_field_id_wasm=function(){return(_ts_node_child_by_field_id_wasm=Module._ts_node_child_by_field_id_wasm=Module.asm.ts_node_child_by_field_id_wasm).apply(null,arguments)},_ts_node_next_sibling_wasm=Module._ts_node_next_sibling_wasm=function(){return(_ts_node_next_sibling_wasm=Module._ts_node_next_sibling_wasm=Module.asm.ts_node_next_sibling_wasm).apply(null,arguments)},_ts_node_prev_sibling_wasm=Module._ts_node_prev_sibling_wasm=function(){return(_ts_node_prev_sibling_wasm=Module._ts_node_prev_sibling_wasm=Module.asm.ts_node_prev_sibling_wasm).apply(null,arguments)},_ts_node_next_named_sibling_wasm=Module._ts_node_next_named_sibling_wasm=function(){return(_ts_node_next_named_sibling_wasm=Module._ts_node_next_named_sibling_wasm=Module.asm.ts_node_next_named_sibling_wasm).apply(null,arguments)},_ts_node_prev_named_sibling_wasm=Module._ts_node_prev_named_sibling_wasm=function(){return(_ts_node_prev_named_sibling_wasm=Module._ts_node_prev_named_sibling_wasm=Module.asm.ts_node_prev_named_sibling_wasm).apply(null,arguments)},_ts_node_parent_wasm=Module._ts_node_parent_wasm=function(){return(_ts_node_parent_wasm=Module._ts_node_parent_wasm=Module.asm.ts_node_parent_wasm).apply(null,arguments)},_ts_node_descendant_for_index_wasm=Module._ts_node_descendant_for_index_wasm=function(){return(_ts_node_descendant_for_index_wasm=Module._ts_node_descendant_for_index_wasm=Module.asm.ts_node_descendant_for_index_wasm).apply(null,arguments)},_ts_node_named_descendant_for_index_wasm=Module._ts_node_named_descendant_for_index_wasm=function(){return(_ts_node_named_descendant_for_index_wasm=Module._ts_node_named_descendant_for_index_wasm=Module.asm.ts_node_named_descendant_for_index_wasm).apply(null,arguments)},_ts_node_descendant_for_position_wasm=Module._ts_node_descendant_for_position_wasm=function(){return(_ts_node_descendant_for_position_wasm=Module._ts_node_descendant_for_position_wasm=Module.asm.ts_node_descendant_for_position_wasm).apply(null,arguments)},_ts_node_named_descendant_for_position_wasm=Module._ts_node_named_descendant_for_position_wasm=function(){return(_ts_node_named_descendant_for_position_wasm=Module._ts_node_named_descendant_for_position_wasm=Module.asm.ts_node_named_descendant_for_position_wasm).apply(null,arguments)},_ts_node_start_point_wasm=Module._ts_node_start_point_wasm=function(){return(_ts_node_start_point_wasm=Module._ts_node_start_point_wasm=Module.asm.ts_node_start_point_wasm).apply(null,arguments)},_ts_node_end_point_wasm=Module._ts_node_end_point_wasm=function(){return(_ts_node_end_point_wasm=Module._ts_node_end_point_wasm=Module.asm.ts_node_end_point_wasm).apply(null,arguments)},_ts_node_start_index_wasm=Module._ts_node_start_index_wasm=function(){return(_ts_node_start_index_wasm=Module._ts_node_start_index_wasm=Module.asm.ts_node_start_index_wasm).apply(null,arguments)},_ts_node_end_index_wasm=Module._ts_node_end_index_wasm=function(){return(_ts_node_end_index_wasm=Module._ts_node_end_index_wasm=Module.asm.ts_node_end_index_wasm).apply(null,arguments)},_ts_node_to_string_wasm=Module._ts_node_to_string_wasm=function(){return(_ts_node_to_string_wasm=Module._ts_node_to_string_wasm=Module.asm.ts_node_to_string_wasm).apply(null,arguments)},_ts_node_children_wasm=Module._ts_node_children_wasm=function(){return(_ts_node_children_wasm=Module._ts_node_children_wasm=Module.asm.ts_node_children_wasm).apply(null,arguments)},_ts_node_named_children_wasm=Module._ts_node_named_children_wasm=function(){return(_ts_node_named_children_wasm=Module._ts_node_named_children_wasm=Module.asm.ts_node_named_children_wasm).apply(null,arguments)},_ts_node_descendants_of_type_wasm=Module._ts_node_descendants_of_type_wasm=function(){return(_ts_node_descendants_of_type_wasm=Module._ts_node_descendants_of_type_wasm=Module.asm.ts_node_descendants_of_type_wasm).apply(null,arguments)},_ts_node_is_named_wasm=Module._ts_node_is_named_wasm=function(){return(_ts_node_is_named_wasm=Module._ts_node_is_named_wasm=Module.asm.ts_node_is_named_wasm).apply(null,arguments)},_ts_node_has_changes_wasm=Module._ts_node_has_changes_wasm=function(){return(_ts_node_has_changes_wasm=Module._ts_node_has_changes_wasm=Module.asm.ts_node_has_changes_wasm).apply(null,arguments)},_ts_node_has_error_wasm=Module._ts_node_has_error_wasm=function(){return(_ts_node_has_error_wasm=Module._ts_node_has_error_wasm=Module.asm.ts_node_has_error_wasm).apply(null,arguments)},_ts_node_is_missing_wasm=Module._ts_node_is_missing_wasm=function(){return(_ts_node_is_missing_wasm=Module._ts_node_is_missing_wasm=Module.asm.ts_node_is_missing_wasm).apply(null,arguments)},_ts_query_matches_wasm=Module._ts_query_matches_wasm=function(){return(_ts_query_matches_wasm=Module._ts_query_matches_wasm=Module.asm.ts_query_matches_wasm).apply(null,arguments)},_ts_query_captures_wasm=Module._ts_query_captures_wasm=function(){return(_ts_query_captures_wasm=Module._ts_query_captures_wasm=Module.asm.ts_query_captures_wasm).apply(null,arguments)},___cxa_atexit=Module.___cxa_atexit=function(){return(___cxa_atexit=Module.___cxa_atexit=Module.asm.__cxa_atexit).apply(null,arguments)},_iswdigit=Module._iswdigit=function(){return(_iswdigit=Module._iswdigit=Module.asm.iswdigit).apply(null,arguments)},_iswalpha=Module._iswalpha=function(){return(_iswalpha=Module._iswalpha=Module.asm.iswalpha).apply(null,arguments)},_iswlower=Module._iswlower=function(){return(_iswlower=Module._iswlower=Module.asm.iswlower).apply(null,arguments)},_memchr=Module._memchr=function(){return(_memchr=Module._memchr=Module.asm.memchr).apply(null,arguments)},_strlen=Module._strlen=function(){return(_strlen=Module._strlen=Module.asm.strlen).apply(null,arguments)},_towupper=Module._towupper=function(){return(_towupper=Module._towupper=Module.asm.towupper).apply(null,arguments)},_setThrew=Module._setThrew=function(){return(_setThrew=Module._setThrew=Module.asm.setThrew).apply(null,arguments)},stackSave=Module.stackSave=function(){return(stackSave=Module.stackSave=Module.asm.stackSave).apply(null,arguments)},stackRestore=Module.stackRestore=function(){return(stackRestore=Module.stackRestore=Module.asm.stackRestore).apply(null,arguments)},stackAlloc=Module.stackAlloc=function(){return(stackAlloc=Module.stackAlloc=Module.asm.stackAlloc).apply(null,arguments)},__Znwm=Module.__Znwm=function(){return(__Znwm=Module.__Znwm=Module.asm._Znwm).apply(null,arguments)},__ZdlPv=Module.__ZdlPv=function(){return(__ZdlPv=Module.__ZdlPv=Module.asm._ZdlPv).apply(null,arguments)},__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev=Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev=function(){return(__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev=Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev=Module.asm._ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev).apply(null,arguments)},__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__grow_byEmmmmmm=Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__grow_byEmmmmmm=function(){return(__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__grow_byEmmmmmm=Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__grow_byEmmmmmm=Module.asm._ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__grow_byEmmmmmm).apply(null,arguments)},__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm=Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm=function(){return(__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm=Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm=Module.asm._ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm).apply(null,arguments)},__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7reserveEm=Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7reserveEm=function(){return(__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7reserveEm=Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7reserveEm=Module.asm._ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7reserveEm).apply(null,arguments)},__ZNKSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4copyEPcmm=Module.__ZNKSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4copyEPcmm=function(){return(__ZNKSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4copyEPcmm=Module.__ZNKSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4copyEPcmm=Module.asm._ZNKSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4copyEPcmm).apply(null,arguments)},__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9push_backEc=Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9push_backEc=function(){return(__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9push_backEc=Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9push_backEc=Module.asm._ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9push_backEc).apply(null,arguments)},__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED2Ev=Module.__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED2Ev=function(){return(__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED2Ev=Module.__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED2Ev=Module.asm._ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED2Ev).apply(null,arguments)},__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE9push_backEw=Module.__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE9push_backEw=function(){return(__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE9push_backEw=Module.__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE9push_backEw=Module.asm._ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE9push_backEw).apply(null,arguments)},__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6resizeEmw=Module.__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6resizeEmw=function(){return(__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6resizeEmw=Module.__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6resizeEmw=Module.asm._ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6resizeEmw).apply(null,arguments)},dynCall_jiji=Module.dynCall_jiji=function(){return(dynCall_jiji=Module.dynCall_jiji=Module.asm.dynCall_jiji).apply(null,arguments)},_orig$ts_parser_timeout_micros=Module._orig$ts_parser_timeout_micros=function(){return(_orig$ts_parser_timeout_micros=Module._orig$ts_parser_timeout_micros=Module.asm.orig$ts_parser_timeout_micros).apply(null,arguments)},_orig$ts_parser_set_timeout_micros=Module._orig$ts_parser_set_timeout_micros=function(){return(_orig$ts_parser_set_timeout_micros=Module._orig$ts_parser_set_timeout_micros=Module.asm.orig$ts_parser_set_timeout_micros).apply(null,arguments)},calledRun;function callMain(e){var t=Module._main;if(t){(e=e||[]).unshift(thisProgram);var r=e.length,_=stackAlloc(4*(r+1)),n=_>>2;e.forEach((e=>{HEAP32[n++]=allocateUTF8OnStack(e)})),HEAP32[n]=0;try{var s=t(r,_);return exitJS(s,!0),s}catch(e){return handleException(e)}}}Module.AsciiToString=AsciiToString,Module.stringToUTF16=stringToUTF16,dependenciesFulfilled=function e(){calledRun||run(),calledRun||(dependenciesFulfilled=e)};var dylibsLoaded=!1;function run(e){function t(){calledRun||(calledRun=!0,Module.calledRun=!0,ABORT||(initRuntime(),preMain(),Module.onRuntimeInitialized&&Module.onRuntimeInitialized(),shouldRunNow&&callMain(e),postRun()))}e=e||arguments_,runDependencies>0||!dylibsLoaded&&(preloadDylibs(),dylibsLoaded=!0,runDependencies>0)||(preRun(),runDependencies>0||(Module.setStatus?(Module.setStatus("Running..."),setTimeout((function(){setTimeout((function(){Module.setStatus("")}),1),t()}),1)):t()))}if(Module.preInit)for("function"==typeof Module.preInit&&(Module.preInit=[Module.preInit]);Module.preInit.length>0;)Module.preInit.pop()();var shouldRunNow=!0;Module.noInitialRun&&(shouldRunNow=!1),run();const C=Module,INTERNAL={},SIZE_OF_INT=4,SIZE_OF_NODE=5*SIZE_OF_INT,SIZE_OF_POINT=2*SIZE_OF_INT,SIZE_OF_RANGE=2*SIZE_OF_INT+2*SIZE_OF_POINT,ZERO_POINT={row:0,column:0},QUERY_WORD_REGEX=/[\w-.]*/g,PREDICATE_STEP_TYPE_CAPTURE=1,PREDICATE_STEP_TYPE_STRING=2,LANGUAGE_FUNCTION_REGEX=/^_?tree_sitter_\w+/;var VERSION,MIN_COMPATIBLE_VERSION,TRANSFER_BUFFER,currentParseCallback,currentLogCallback;class ParserImpl{static init(){TRANSFER_BUFFER=C._ts_init(),VERSION=getValue(TRANSFER_BUFFER,"i32"),MIN_COMPATIBLE_VERSION=getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32")}initialize(){C._ts_parser_new_wasm(),this[0]=getValue(TRANSFER_BUFFER,"i32"),this[1]=getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32")}delete(){C._ts_parser_delete(this[0]),C._free(this[1]),this[0]=0,this[1]=0}setLanguage(e){let t;if(e){if(e.constructor!==Language)throw new Error("Argument must be a Language");{t=e[0];const r=C._ts_language_version(t);if(re.slice(t,_);else{if("function"!=typeof e)throw new Error("Argument must be a string or a function");currentParseCallback=e}this.logCallback?(currentLogCallback=this.logCallback,C._ts_parser_enable_logger_wasm(this[0],1)):(currentLogCallback=null,C._ts_parser_enable_logger_wasm(this[0],0));let _=0,n=0;if(r&&r.includedRanges){_=r.includedRanges.length,n=C._calloc(_,SIZE_OF_RANGE);let e=n;for(let t=0;t<_;t++)marshalRange(e,r.includedRanges[t]),e+=SIZE_OF_RANGE}const s=C._ts_parser_parse_wasm(this[0],this[1],t?t[0]:0,n,_);if(!s)throw currentParseCallback=null,currentLogCallback=null,new Error("Parsing failed");const a=new Tree(INTERNAL,s,this.language,currentParseCallback);return currentParseCallback=null,currentLogCallback=null,a}reset(){C._ts_parser_reset(this[0])}setTimeoutMicros(e){C._ts_parser_set_timeout_micros(this[0],e)}getTimeoutMicros(){return C._ts_parser_timeout_micros(this[0])}setLogger(e){if(e){if("function"!=typeof e)throw new Error("Logger callback must be a function")}else e=null;return this.logCallback=e,this}getLogger(){return this.logCallback}}class Tree{constructor(e,t,r,_){assertInternal(e),this[0]=t,this.language=r,this.textCallback=_}copy(){const e=C._ts_tree_copy(this[0]);return new Tree(INTERNAL,e,this.language,this.textCallback)}delete(){C._ts_tree_delete(this[0]),this[0]=0}edit(e){marshalEdit(e),C._ts_tree_edit_wasm(this[0])}get rootNode(){return C._ts_tree_root_node_wasm(this[0]),unmarshalNode(this)}getLanguage(){return this.language}walk(){return this.rootNode.walk()}getChangedRanges(e){if(e.constructor!==Tree)throw new TypeError("Argument must be a Tree");C._ts_tree_get_changed_ranges_wasm(this[0],e[0]);const t=getValue(TRANSFER_BUFFER,"i32"),r=getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),_=new Array(t);if(t>0){let e=r;for(let r=0;r0){let r=t;for(let t=0;t0){let r=t;for(let t=0;t0){let e=o;for(let t=0;t0){if("string"!==n[0].type)throw new Error("Predicates must begin with a literal value");const t=n[0].value;let r=!0;switch(t){case"not-eq?":r=!1;case"eq?":if(3!==n.length)throw new Error("Wrong number of arguments to `#eq?` predicate. Expected 2, got "+(n.length-1));if("capture"!==n[1].type)throw new Error(`First argument of \`#eq?\` predicate must be a capture. Got "${n[1].value}"`);if("capture"===n[2].type){const t=n[1].name,_=n[2].name;m[e].push((function(e){let n,s;for(const r of e)r.name===t&&(n=r.node),r.name===_&&(s=r.node);return void 0===n||void 0===s||n.text===s.text===r}))}else{const t=n[1].name,_=n[2].value;m[e].push((function(e){for(const n of e)if(n.name===t)return n.node.text===_===r;return!0}))}break;case"not-match?":r=!1;case"match?":if(3!==n.length)throw new Error(`Wrong number of arguments to \`#match?\` predicate. Expected 2, got ${n.length-1}.`);if("capture"!==n[1].type)throw new Error(`First argument of \`#match?\` predicate must be a capture. Got "${n[1].value}".`);if("string"!==n[2].type)throw new Error(`Second argument of \`#match?\` predicate must be a string. Got @${n[2].value}.`);const _=n[1].name,s=new RegExp(n[2].value);m[e].push((function(e){for(const t of e)if(t.name===_)return s.test(t.node.text)===r;return!0}));break;case"set!":if(n.length<2||n.length>3)throw new Error(`Wrong number of arguments to \`#set!\` predicate. Expected 1 or 2. Got ${n.length-1}.`);if(n.some((e=>"string"!==e.type)))throw new Error('Arguments to `#set!` predicate must be a strings.".');l[e]||(l[e]={}),l[e][n[1].value]=n[2]?n[2].value:null;break;case"is?":case"is-not?":if(n.length<2||n.length>3)throw new Error(`Wrong number of arguments to \`#${t}\` predicate. Expected 1 or 2. Got ${n.length-1}.`);if(n.some((e=>"string"!==e.type)))throw new Error(`Arguments to \`#${t}\` predicate must be a strings.".`);const a="is?"===t?u:d;a[e]||(a[e]={}),a[e][n[1].value]=n[2]?n[2].value:null;break;default:c[e].push({operator:t,operands:n.slice(1)})}n.length=0}}Object.freeze(l[e]),Object.freeze(u[e]),Object.freeze(d[e])}return C._free(r),new Query(INTERNAL,_,o,m,c,Object.freeze(l),Object.freeze(u),Object.freeze(d))}static load(e){let t;if(e instanceof Uint8Array)t=Promise.resolve(e);else{const r=e;if("undefined"!=typeof process&&process.versions&&process.versions.node){const e=__webpack_require__(4);t=Promise.resolve(e.readFileSync(r))}else t=fetch(r).then((e=>e.arrayBuffer().then((t=>{if(e.ok)return new Uint8Array(t);{const r=new TextDecoder("utf-8").decode(t);throw new Error(`Language.load failed with status ${e.status}.\n\n${r}`)}}))))}const r="function"==typeof loadSideModule?loadSideModule:loadWebAssemblyModule;return t.then((e=>r(e,{loadAsync:!0}))).then((e=>{const t=Object.keys(e),r=t.find((e=>LANGUAGE_FUNCTION_REGEX.test(e)&&!e.includes("external_scanner_")));r||console.log(`Couldn't find language function in WASM file. Symbols:\n${JSON.stringify(t,null,2)}`);const _=e[r]();return new Language(INTERNAL,_)}))}}class Query{constructor(e,t,r,_,n,s,a,o){assertInternal(e),this[0]=t,this.captureNames=r,this.textPredicates=_,this.predicates=n,this.setProperties=s,this.assertedProperties=a,this.refutedProperties=o,this.exceededMatchLimit=!1}delete(){C._ts_query_delete(this[0]),this[0]=0}matches(e,t,r,_){t||(t=ZERO_POINT),r||(r=ZERO_POINT),_||(_={});let n=_.matchLimit;if(void 0===n)n=0;else if("number"!=typeof n)throw new Error("Arguments must be numbers");marshalNode(e),C._ts_query_matches_wasm(this[0],e.tree[0],t.row,t.column,r.row,r.column,n);const s=getValue(TRANSFER_BUFFER,"i32"),a=getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),o=getValue(TRANSFER_BUFFER+2*SIZE_OF_INT,"i32"),i=new Array(s);this.exceededMatchLimit=!!o;let l=0,u=a;for(let t=0;te(n)))){i[l++]={pattern:r,captures:n};const e=this.setProperties[r];e&&(i[t].setProperties=e);const _=this.assertedProperties[r];_&&(i[t].assertedProperties=_);const s=this.refutedProperties[r];s&&(i[t].refutedProperties=s)}}return i.length=l,C._free(a),i}captures(e,t,r,_){t||(t=ZERO_POINT),r||(r=ZERO_POINT),_||(_={});let n=_.matchLimit;if(void 0===n)n=0;else if("number"!=typeof n)throw new Error("Arguments must be numbers");marshalNode(e),C._ts_query_captures_wasm(this[0],e.tree[0],t.row,t.column,r.row,r.column,n);const s=getValue(TRANSFER_BUFFER,"i32"),a=getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),o=getValue(TRANSFER_BUFFER+2*SIZE_OF_INT,"i32"),i=[];this.exceededMatchLimit=!!o;const l=[];let u=a;for(let t=0;te(l)))){const e=l[_],r=this.setProperties[t];r&&(e.setProperties=r);const n=this.assertedProperties[t];n&&(e.assertedProperties=n);const s=this.refutedProperties[t];s&&(e.refutedProperties=s),i.push(e)}}return C._free(a),i}predicatesForPattern(e){return this.predicates[e]}didExceedMatchLimit(){return this.exceededMatchLimit}}function getText(e,t,r){const _=r-t;let n=e.textCallback(t,null,r);for(t+=n.length;t0))break;t+=_.length,n+=_}return t>r&&(n=n.slice(0,_)),n}function unmarshalCaptures(e,t,r,_){for(let n=0,s=_.length;n{ParserImpl.init(),resolveInitPromise()}})))}}return Parser}(); true&&(module.exports=TreeSitter); - - -/***/ }), -/* 4 */ -/***/ (() => { - -/* (ignored) */ - -/***/ }), -/* 5 */ -/***/ ((module) => { - -"use strict"; -// 'path' module extracted from Node.js v8.11.1 (only the posix part) -// transplited with Babel - -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - - - -function assertPath(path) { - if (typeof path !== 'string') { - throw new TypeError('Path must be a string. Received ' + JSON.stringify(path)); - } -} - -// Resolves . and .. elements in a path with directory names -function normalizeStringPosix(path, allowAboveRoot) { - var res = ''; - var lastSegmentLength = 0; - var lastSlash = -1; - var dots = 0; - var code; - for (var i = 0; i <= path.length; ++i) { - if (i < path.length) - code = path.charCodeAt(i); - else if (code === 47 /*/*/) - break; - else - code = 47 /*/*/; - if (code === 47 /*/*/) { - if (lastSlash === i - 1 || dots === 1) { - // NOOP - } else if (lastSlash !== i - 1 && dots === 2) { - if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 /*.*/ || res.charCodeAt(res.length - 2) !== 46 /*.*/) { - if (res.length > 2) { - var lastSlashIndex = res.lastIndexOf('/'); - if (lastSlashIndex !== res.length - 1) { - if (lastSlashIndex === -1) { - res = ''; - lastSegmentLength = 0; - } else { - res = res.slice(0, lastSlashIndex); - lastSegmentLength = res.length - 1 - res.lastIndexOf('/'); - } - lastSlash = i; - dots = 0; - continue; - } - } else if (res.length === 2 || res.length === 1) { - res = ''; - lastSegmentLength = 0; - lastSlash = i; - dots = 0; - continue; - } - } - if (allowAboveRoot) { - if (res.length > 0) - res += '/..'; - else - res = '..'; - lastSegmentLength = 2; - } - } else { - if (res.length > 0) - res += '/' + path.slice(lastSlash + 1, i); - else - res = path.slice(lastSlash + 1, i); - lastSegmentLength = i - lastSlash - 1; - } - lastSlash = i; - dots = 0; - } else if (code === 46 /*.*/ && dots !== -1) { - ++dots; - } else { - dots = -1; - } - } - return res; -} - -function _format(sep, pathObject) { - var dir = pathObject.dir || pathObject.root; - var base = pathObject.base || (pathObject.name || '') + (pathObject.ext || ''); - if (!dir) { - return base; - } - if (dir === pathObject.root) { - return dir + base; - } - return dir + sep + base; -} - -var posix = { - // path.resolve([from ...], to) - resolve: function resolve() { - var resolvedPath = ''; - var resolvedAbsolute = false; - var cwd; - - for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) { - var path; - if (i >= 0) - path = arguments[i]; - else { - if (cwd === undefined) - cwd = process.cwd(); - path = cwd; - } - - assertPath(path); - - // Skip empty entries - if (path.length === 0) { - continue; - } - - resolvedPath = path + '/' + resolvedPath; - resolvedAbsolute = path.charCodeAt(0) === 47 /*/*/; - } - - // At this point the path should be resolved to a full absolute path, but - // handle relative paths to be safe (might happen when process.cwd() fails) - - // Normalize the path - resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute); - - if (resolvedAbsolute) { - if (resolvedPath.length > 0) - return '/' + resolvedPath; - else - return '/'; - } else if (resolvedPath.length > 0) { - return resolvedPath; - } else { - return '.'; - } - }, - - normalize: function normalize(path) { - assertPath(path); - - if (path.length === 0) return '.'; - - var isAbsolute = path.charCodeAt(0) === 47 /*/*/; - var trailingSeparator = path.charCodeAt(path.length - 1) === 47 /*/*/; - - // Normalize the path - path = normalizeStringPosix(path, !isAbsolute); - - if (path.length === 0 && !isAbsolute) path = '.'; - if (path.length > 0 && trailingSeparator) path += '/'; - - if (isAbsolute) return '/' + path; - return path; - }, - - isAbsolute: function isAbsolute(path) { - assertPath(path); - return path.length > 0 && path.charCodeAt(0) === 47 /*/*/; - }, - - join: function join() { - if (arguments.length === 0) - return '.'; - var joined; - for (var i = 0; i < arguments.length; ++i) { - var arg = arguments[i]; - assertPath(arg); - if (arg.length > 0) { - if (joined === undefined) - joined = arg; - else - joined += '/' + arg; - } - } - if (joined === undefined) - return '.'; - return posix.normalize(joined); - }, - - relative: function relative(from, to) { - assertPath(from); - assertPath(to); - - if (from === to) return ''; - - from = posix.resolve(from); - to = posix.resolve(to); - - if (from === to) return ''; - - // Trim any leading backslashes - var fromStart = 1; - for (; fromStart < from.length; ++fromStart) { - if (from.charCodeAt(fromStart) !== 47 /*/*/) - break; - } - var fromEnd = from.length; - var fromLen = fromEnd - fromStart; - - // Trim any leading backslashes - var toStart = 1; - for (; toStart < to.length; ++toStart) { - if (to.charCodeAt(toStart) !== 47 /*/*/) - break; - } - var toEnd = to.length; - var toLen = toEnd - toStart; - - // Compare paths to find the longest common path from root - var length = fromLen < toLen ? fromLen : toLen; - var lastCommonSep = -1; - var i = 0; - for (; i <= length; ++i) { - if (i === length) { - if (toLen > length) { - if (to.charCodeAt(toStart + i) === 47 /*/*/) { - // We get here if `from` is the exact base path for `to`. - // For example: from='/foo/bar'; to='/foo/bar/baz' - return to.slice(toStart + i + 1); - } else if (i === 0) { - // We get here if `from` is the root - // For example: from='/'; to='/foo' - return to.slice(toStart + i); - } - } else if (fromLen > length) { - if (from.charCodeAt(fromStart + i) === 47 /*/*/) { - // We get here if `to` is the exact base path for `from`. - // For example: from='/foo/bar/baz'; to='/foo/bar' - lastCommonSep = i; - } else if (i === 0) { - // We get here if `to` is the root. - // For example: from='/foo'; to='/' - lastCommonSep = 0; - } - } - break; - } - var fromCode = from.charCodeAt(fromStart + i); - var toCode = to.charCodeAt(toStart + i); - if (fromCode !== toCode) - break; - else if (fromCode === 47 /*/*/) - lastCommonSep = i; - } - - var out = ''; - // Generate the relative path based on the path difference between `to` - // and `from` - for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) { - if (i === fromEnd || from.charCodeAt(i) === 47 /*/*/) { - if (out.length === 0) - out += '..'; - else - out += '/..'; - } - } - - // Lastly, append the rest of the destination (`to`) path that comes after - // the common path parts - if (out.length > 0) - return out + to.slice(toStart + lastCommonSep); - else { - toStart += lastCommonSep; - if (to.charCodeAt(toStart) === 47 /*/*/) - ++toStart; - return to.slice(toStart); - } - }, - - _makeLong: function _makeLong(path) { - return path; - }, - - dirname: function dirname(path) { - assertPath(path); - if (path.length === 0) return '.'; - var code = path.charCodeAt(0); - var hasRoot = code === 47 /*/*/; - var end = -1; - var matchedSlash = true; - for (var i = path.length - 1; i >= 1; --i) { - code = path.charCodeAt(i); - if (code === 47 /*/*/) { - if (!matchedSlash) { - end = i; - break; - } - } else { - // We saw the first non-path separator - matchedSlash = false; - } - } - - if (end === -1) return hasRoot ? '/' : '.'; - if (hasRoot && end === 1) return '//'; - return path.slice(0, end); - }, - - basename: function basename(path, ext) { - if (ext !== undefined && typeof ext !== 'string') throw new TypeError('"ext" argument must be a string'); - assertPath(path); - - var start = 0; - var end = -1; - var matchedSlash = true; - var i; - - if (ext !== undefined && ext.length > 0 && ext.length <= path.length) { - if (ext.length === path.length && ext === path) return ''; - var extIdx = ext.length - 1; - var firstNonSlashEnd = -1; - for (i = path.length - 1; i >= 0; --i) { - var code = path.charCodeAt(i); - if (code === 47 /*/*/) { - // If we reached a path separator that was not part of a set of path - // separators at the end of the string, stop now - if (!matchedSlash) { - start = i + 1; - break; - } - } else { - if (firstNonSlashEnd === -1) { - // We saw the first non-path separator, remember this index in case - // we need it if the extension ends up not matching - matchedSlash = false; - firstNonSlashEnd = i + 1; - } - if (extIdx >= 0) { - // Try to match the explicit extension - if (code === ext.charCodeAt(extIdx)) { - if (--extIdx === -1) { - // We matched the extension, so mark this as the end of our path - // component - end = i; - } - } else { - // Extension does not match, so our result is the entire path - // component - extIdx = -1; - end = firstNonSlashEnd; - } - } - } - } - - if (start === end) end = firstNonSlashEnd;else if (end === -1) end = path.length; - return path.slice(start, end); - } else { - for (i = path.length - 1; i >= 0; --i) { - if (path.charCodeAt(i) === 47 /*/*/) { - // If we reached a path separator that was not part of a set of path - // separators at the end of the string, stop now - if (!matchedSlash) { - start = i + 1; - break; - } - } else if (end === -1) { - // We saw the first non-path separator, mark this as the end of our - // path component - matchedSlash = false; - end = i + 1; - } - } - - if (end === -1) return ''; - return path.slice(start, end); - } - }, - - extname: function extname(path) { - assertPath(path); - var startDot = -1; - var startPart = 0; - var end = -1; - var matchedSlash = true; - // Track the state of characters (if any) we see before our first dot and - // after any path separator we find - var preDotState = 0; - for (var i = path.length - 1; i >= 0; --i) { - var code = path.charCodeAt(i); - if (code === 47 /*/*/) { - // If we reached a path separator that was not part of a set of path - // separators at the end of the string, stop now - if (!matchedSlash) { - startPart = i + 1; - break; - } - continue; - } - if (end === -1) { - // We saw the first non-path separator, mark this as the end of our - // extension - matchedSlash = false; - end = i + 1; - } - if (code === 46 /*.*/) { - // If this is our first dot, mark it as the start of our extension - if (startDot === -1) - startDot = i; - else if (preDotState !== 1) - preDotState = 1; - } else if (startDot !== -1) { - // We saw a non-dot and non-path separator before our dot, so we should - // have a good chance at having a non-empty extension - preDotState = -1; - } - } - - if (startDot === -1 || end === -1 || - // We saw a non-dot character immediately before the dot - preDotState === 0 || - // The (right-most) trimmed path component is exactly '..' - preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) { - return ''; - } - return path.slice(startDot, end); - }, - - format: function format(pathObject) { - if (pathObject === null || typeof pathObject !== 'object') { - throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject); - } - return _format('/', pathObject); - }, - - parse: function parse(path) { - assertPath(path); - - var ret = { root: '', dir: '', base: '', ext: '', name: '' }; - if (path.length === 0) return ret; - var code = path.charCodeAt(0); - var isAbsolute = code === 47 /*/*/; - var start; - if (isAbsolute) { - ret.root = '/'; - start = 1; - } else { - start = 0; - } - var startDot = -1; - var startPart = 0; - var end = -1; - var matchedSlash = true; - var i = path.length - 1; - - // Track the state of characters (if any) we see before our first dot and - // after any path separator we find - var preDotState = 0; - - // Get non-dir info - for (; i >= start; --i) { - code = path.charCodeAt(i); - if (code === 47 /*/*/) { - // If we reached a path separator that was not part of a set of path - // separators at the end of the string, stop now - if (!matchedSlash) { - startPart = i + 1; - break; - } - continue; - } - if (end === -1) { - // We saw the first non-path separator, mark this as the end of our - // extension - matchedSlash = false; - end = i + 1; - } - if (code === 46 /*.*/) { - // If this is our first dot, mark it as the start of our extension - if (startDot === -1) startDot = i;else if (preDotState !== 1) preDotState = 1; - } else if (startDot !== -1) { - // We saw a non-dot and non-path separator before our dot, so we should - // have a good chance at having a non-empty extension - preDotState = -1; - } - } - - if (startDot === -1 || end === -1 || - // We saw a non-dot character immediately before the dot - preDotState === 0 || - // The (right-most) trimmed path component is exactly '..' - preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) { - if (end !== -1) { - if (startPart === 0 && isAbsolute) ret.base = ret.name = path.slice(1, end);else ret.base = ret.name = path.slice(startPart, end); - } - } else { - if (startPart === 0 && isAbsolute) { - ret.name = path.slice(1, startDot); - ret.base = path.slice(1, end); - } else { - ret.name = path.slice(startPart, startDot); - ret.base = path.slice(startPart, end); - } - ret.ext = path.slice(startDot, end); - } - - if (startPart > 0) ret.dir = path.slice(0, startPart - 1);else if (isAbsolute) ret.dir = '/'; - - return ret; - }, - - sep: '/', - delimiter: ':', - win32: null, - posix: null -}; - -posix.posix = posix; - -module.exports = posix; - - -/***/ }), -/* 6 */ -/***/ ((__unused_webpack_module, exports, __webpack_require__) => { - -"use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.initOniguruma = void 0; -const vscode = __webpack_require__(1); -const vscodeOniguruma = __webpack_require__(7); -async function initOniguruma(context) { - const uri = vscode.Uri.joinPath(context.extensionUri, 'node_modules', 'vscode-oniguruma', 'release', 'onig.wasm'); - const wasm = await vscode.workspace.fs.readFile(uri); - const options = { - data: wasm, - print(string) { - console.log(string); - } - }; - await vscodeOniguruma.loadWASM(options); - // // https://github.com/microsoft/vscode-oniguruma/issues/10 - // const response = await fetch('/node_modules/vscode-oniguruma/release/onig.wasm'); - // const contentType = response.headers.get('content-type'); - // // Using the response directly only works if the server sets the MIME type 'application/wasm'. - // // Otherwise, a TypeError is thrown when using the streaming compiler. - // // We therefore use the non-streaming compiler :(. - // const wasm = contentType === 'application/wasm' ? response : await response.arrayBuffer(); - // const options: vscodeOniguruma.IDataOptions = { - // data: wasm, - // print(string: string) { - // console.log(string); - // } - // } - // await vscodeOniguruma.loadWASM(options); -} -exports.initOniguruma = initOniguruma; - - -/***/ }), -/* 7 */ -/***/ (function(module) { - -!function(t,n){ true?module.exports=n():0}(this,(()=>{return t={770:function(t,n,e){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(n,"__esModule",{value:!0}),n.setDefaultDebugCall=n.createOnigScanner=n.createOnigString=n.loadWASM=n.OnigScanner=n.OnigString=void 0;const i=r(e(418));let o=null,a=!1;class f{static _utf8ByteLength(t){let n=0;for(let e=0,r=t.length;e=55296&&i<=56319&&e+1=56320&&n<=57343&&(o=65536+(i-55296<<10)|n-56320,a=!0)}n+=o<=127?1:o<=2047?2:o<=65535?3:4,a&&e++}return n}constructor(t){const n=t.length,e=f._utf8ByteLength(t),r=e!==n,i=r?new Uint32Array(n+1):null;r&&(i[n]=e);const o=r?new Uint32Array(e+1):null;r&&(o[e]=n);const a=new Uint8Array(e);let s=0;for(let e=0;e=55296&&f<=56319&&e+1=56320&&n<=57343&&(u=65536+(f-55296<<10)|n-56320,c=!0)}r&&(i[e]=s,c&&(i[e+1]=s),u<=127?o[s+0]=e:u<=2047?(o[s+0]=e,o[s+1]=e):u<=65535?(o[s+0]=e,o[s+1]=e,o[s+2]=e):(o[s+0]=e,o[s+1]=e,o[s+2]=e,o[s+3]=e)),u<=127?a[s++]=u:u<=2047?(a[s++]=192|(1984&u)>>>6,a[s++]=128|(63&u)>>>0):u<=65535?(a[s++]=224|(61440&u)>>>12,a[s++]=128|(4032&u)>>>6,a[s++]=128|(63&u)>>>0):(a[s++]=240|(1835008&u)>>>18,a[s++]=128|(258048&u)>>>12,a[s++]=128|(4032&u)>>>6,a[s++]=128|(63&u)>>>0),c&&e++}this.utf16Length=n,this.utf8Length=e,this.utf16Value=t,this.utf8Value=a,this.utf16OffsetToUtf8=i,this.utf8OffsetToUtf16=o}createString(t){const n=t._omalloc(this.utf8Length);return t.HEAPU8.set(this.utf8Value,n),n}}class s{constructor(t){if(this.id=++s.LAST_ID,!o)throw new Error("Must invoke loadWASM first.");this._onigBinding=o,this.content=t;const n=new f(t);this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!s._sharedPtrInUse?(s._sharedPtr||(s._sharedPtr=o._omalloc(1e4)),s._sharedPtrInUse=!0,o.HEAPU8.set(n.utf8Value,s._sharedPtr),this.ptr=s._sharedPtr):this.ptr=n.createString(o)}convertUtf8OffsetToUtf16(t){return this.utf8OffsetToUtf16?t<0?0:t>this.utf8Length?this.utf16Length:this.utf8OffsetToUtf16[t]:t}convertUtf16OffsetToUtf8(t){return this.utf16OffsetToUtf8?t<0?0:t>this.utf16Length?this.utf8Length:this.utf16OffsetToUtf8[t]:t}dispose(){this.ptr===s._sharedPtr?s._sharedPtrInUse=!1:this._onigBinding._ofree(this.ptr)}}n.OnigString=s,s.LAST_ID=0,s._sharedPtr=0,s._sharedPtrInUse=!1;class u{constructor(t){if(!o)throw new Error("Must invoke loadWASM first.");const n=[],e=[];for(let r=0,i=t.length;rWebAssembly.instantiateStreaming(t,n)}(r):function(t){return async n=>{const e=await t.arrayBuffer();return WebAssembly.instantiate(e,n)}}(r):function(t){return n=>WebAssembly.instantiate(t,n)}(r)}return l=new Promise(((t,n)=>{r=t,a=n})),function(t,n,e,r){(0,i.default)({print:n,instantiateWasm:(n,e)=>{if("undefined"==typeof performance){const t=()=>Date.now();n.env.emscripten_get_now=t,n.wasi_snapshot_preview1.emscripten_get_now=t}return t(n).then((t=>e(t.instance)),r),{}}}).then((t=>{o=t,e()}))}(n,e,r,a),l},n.createOnigString=function(t){return new s(t)},n.createOnigScanner=function(t){return new u(t)},n.setDefaultDebugCall=function(t){a=t}},418:t=>{var n=("undefined"!=typeof document&&document.currentScript&&document.currentScript.src,function(t){var n,e,r=void 0!==(t=t||{})?t:{};r.ready=new Promise((function(t,r){n=t,e=r}));var i,o=Object.assign({},r),a=[],f=!1,s=!1,u=!0,c="";function l(t){return r.locateFile?r.locateFile(t,c):c+t}u&&(i=function(t){let n;return"function"==typeof readbuffer?new Uint8Array(readbuffer(t)):(n=read(t,"binary"),m("object"==typeof n),n)},"undefined"!=typeof scriptArgs?a=scriptArgs:void 0!==arguments&&(a=arguments),"undefined"!=typeof onig_print&&("undefined"==typeof console&&(console={}),console.log=onig_print,console.warn=console.error="undefined"!=typeof printErr?printErr:onig_print));var h,p,d=r.print||console.log.bind(console),g=r.printErr||console.warn.bind(console);Object.assign(r,o),o=null,r.arguments&&(a=r.arguments),r.thisProgram&&r.thisProgram,r.quit&&r.quit,r.wasmBinary&&(h=r.wasmBinary),r.noExitRuntime,"object"!=typeof WebAssembly&&k("no native wasm support detected");var _=!1;function m(t,n){t||k(n)}var y,w,S,v="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function A(t,n,e){for(var r=n+e,i=n;t[i]&&!(i>=r);)++i;if(i-n>16&&t.buffer&&v)return v.decode(t.subarray(n,i));for(var o="";n>10,56320|1023&u)}}else o+=String.fromCharCode((31&a)<<6|f)}else o+=String.fromCharCode(a)}return o}function b(t,n){return t?A(w,t,n):""}function O(t){y=t,r.HEAP8=new Int8Array(t),r.HEAP16=new Int16Array(t),r.HEAP32=new Int32Array(t),r.HEAPU8=w=new Uint8Array(t),r.HEAPU16=new Uint16Array(t),r.HEAPU32=S=new Uint32Array(t),r.HEAPF32=new Float32Array(t),r.HEAPF64=new Float64Array(t)}r.INITIAL_MEMORY;var U=[],P=[],R=[];function x(){if(r.preRun)for("function"==typeof r.preRun&&(r.preRun=[r.preRun]);r.preRun.length;)M(r.preRun.shift());G(U)}function T(){G(P)}function E(){if(r.postRun)for("function"==typeof r.postRun&&(r.postRun=[r.postRun]);r.postRun.length;)I(r.postRun.shift());G(R)}function M(t){U.unshift(t)}function L(t){P.unshift(t)}function I(t){R.unshift(t)}var W=0,D=null,C=null;function N(t){W++,r.monitorRunDependencies&&r.monitorRunDependencies(W)}function j(t){if(W--,r.monitorRunDependencies&&r.monitorRunDependencies(W),0==W&&(null!==D&&(clearInterval(D),D=null),C)){var n=C;C=null,n()}}function k(t){r.onAbort&&r.onAbort(t),g(t="Aborted("+t+")"),_=!0,t+=". Build with -sASSERTIONS for more info.";var n=new WebAssembly.RuntimeError(t);throw e(n),n}var B,H,F="data:application/octet-stream;base64,";function V(t){return t.startsWith(F)}function z(t){try{if(t==B&&h)return new Uint8Array(h);if(i)return i(t);throw"both async and sync fetching of the wasm failed"}catch(t){k(t)}}function q(){return h||!f&&!s||"function"!=typeof fetch?Promise.resolve().then((function(){return z(B)})):fetch(B,{credentials:"same-origin"}).then((function(t){if(!t.ok)throw"failed to load wasm binary file at '"+B+"'";return t.arrayBuffer()})).catch((function(){return z(B)}))}function Y(){var t={env:nt,wasi_snapshot_preview1:nt};function n(t,n){var e=t.exports;r.asm=e,O((p=r.asm.memory).buffer),r.asm.__indirect_function_table,L(r.asm.__wasm_call_ctors),j()}function i(t){n(t.instance)}function o(n){return q().then((function(n){return WebAssembly.instantiate(n,t)})).then((function(t){return t})).then(n,(function(t){g("failed to asynchronously prepare wasm: "+t),k(t)}))}if(N(),r.instantiateWasm)try{return r.instantiateWasm(t,n)}catch(t){g("Module.instantiateWasm callback failed with error: "+t),e(t)}return(h||"function"!=typeof WebAssembly.instantiateStreaming||V(B)||"function"!=typeof fetch?o(i):fetch(B,{credentials:"same-origin"}).then((function(n){return WebAssembly.instantiateStreaming(n,t).then(i,(function(t){return g("wasm streaming compile failed: "+t),g("falling back to ArrayBuffer instantiation"),o(i)}))}))).catch(e),{}}function G(t){for(;t.length>0;)t.shift()(r)}function J(t,n,e){w.copyWithin(t,n,n+e)}function K(t){try{return p.grow(t-y.byteLength+65535>>>16),O(p.buffer),1}catch(t){}}function Q(t){var n,e=w.length,r=2147483648;if((t>>>=0)>r)return!1;for(var i=1;i<=4;i*=2){var o=e*(1+.2/i);if(o=Math.min(o,t+100663296),K(Math.min(r,(n=Math.max(t,o))+(65536-n%65536)%65536)))return!0}return!1}V(B="onig.wasm")||(B=l(B)),H="undefined"!=typeof dateNow?dateNow:()=>performance.now();var X=[null,[],[]];function Z(t,n){var e=X[t];0===n||10===n?((1===t?d:g)(A(e,0)),e.length=0):e.push(n)}function $(t,n,e,r){for(var i=0,o=0;o>2],f=S[n+4>>2];n+=8;for(var s=0;s>2]=i,0}var tt,nt={emscripten_get_now:H,emscripten_memcpy_big:J,emscripten_resize_heap:Q,fd_write:$};function et(t){function e(){tt||(tt=!0,r.calledRun=!0,_||(T(),n(r),r.onRuntimeInitialized&&r.onRuntimeInitialized(),E()))}t=t||a,W>0||(x(),W>0||(r.setStatus?(r.setStatus("Running..."),setTimeout((function(){setTimeout((function(){r.setStatus("")}),1),e()}),1)):e()))}if(Y(),r.___wasm_call_ctors=function(){return(r.___wasm_call_ctors=r.asm.__wasm_call_ctors).apply(null,arguments)},r.___errno_location=function(){return(r.___errno_location=r.asm.__errno_location).apply(null,arguments)},r._omalloc=function(){return(r._omalloc=r.asm.omalloc).apply(null,arguments)},r._ofree=function(){return(r._ofree=r.asm.ofree).apply(null,arguments)},r._getLastOnigError=function(){return(r._getLastOnigError=r.asm.getLastOnigError).apply(null,arguments)},r._createOnigScanner=function(){return(r._createOnigScanner=r.asm.createOnigScanner).apply(null,arguments)},r._freeOnigScanner=function(){return(r._freeOnigScanner=r.asm.freeOnigScanner).apply(null,arguments)},r._findNextOnigScannerMatch=function(){return(r._findNextOnigScannerMatch=r.asm.findNextOnigScannerMatch).apply(null,arguments)},r._findNextOnigScannerMatchDbg=function(){return(r._findNextOnigScannerMatchDbg=r.asm.findNextOnigScannerMatchDbg).apply(null,arguments)},r.stackSave=function(){return(r.stackSave=r.asm.stackSave).apply(null,arguments)},r.stackRestore=function(){return(r.stackRestore=r.asm.stackRestore).apply(null,arguments)},r.stackAlloc=function(){return(r.stackAlloc=r.asm.stackAlloc).apply(null,arguments)},r.dynCall_jiji=function(){return(r.dynCall_jiji=r.asm.dynCall_jiji).apply(null,arguments)},r.UTF8ToString=b,C=function t(){tt||et(),tt||(C=t)},r.preInit)for("function"==typeof r.preInit&&(r.preInit=[r.preInit]);r.preInit.length>0;)r.preInit.pop()();return et(),t.ready});t.exports=n}},n={},function e(r){var i=n[r];if(void 0!==i)return i.exports;var o=n[r]={exports:{}};return t[r].call(o.exports,o,o.exports,e),o.exports}(770);var t,n})); - -/***/ }), -/* 8 */, -/* 9 */, -/* 10 */, -/* 11 */, -/* 12 */, -/* 13 */, -/* 14 */, -/* 15 */, -/* 16 */, -/* 17 */, -/* 18 */, -/* 19 */, -/* 20 */, -/* 21 */, -/* 22 */, -/* 23 */, -/* 24 */, -/* 25 */, -/* 26 */, -/* 27 */ -/***/ ((__unused_webpack_module, exports, __webpack_require__) => { - -"use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.initDiagnostics = void 0; -const vscode = __webpack_require__(1); -const vscodeOniguruma = __webpack_require__(7); -const TreeSitter_1 = __webpack_require__(2); -const extension_1 = __webpack_require__(0); -function initDiagnostics(context) { - // vscode.window.showInformationMessage(JSON.stringify("initDiagnostics")); - const DiagnosticCollection = vscode.languages.createDiagnosticCollection("textmate"); - context.subscriptions.push(DiagnosticCollection); - for (const editor of vscode.window.visibleTextEditors) { - // vscode.window.showInformationMessage(JSON.stringify("visible")); - Diagnostics(editor.document, DiagnosticCollection); - } - context.subscriptions.push(vscode.workspace.onDidOpenTextDocument((document) => { - // vscode.window.showInformationMessage(JSON.stringify("open")); - Diagnostics(document, DiagnosticCollection); - })); - context.subscriptions.push(vscode.workspace.onDidChangeTextDocument((edits) => { - // vscode.window.showInformationMessage(JSON.stringify("change")); - Diagnostics(edits.document, DiagnosticCollection); - })); - context.subscriptions.push(vscode.workspace.onDidCloseTextDocument((document) => { - // vscode.window.showInformationMessage(JSON.stringify("close")); - DiagnosticCollection.delete(document.uri); - })); -} -exports.initDiagnostics = initDiagnostics; -function Diagnostics(document, Diagnostics) { - if (!vscode.languages.match(extension_1.DocumentSelector, document)) { - return; - } - const diagnostics = []; - if (false) {} - if (false) {} - if (true) { // Oniguruma Regex errors. https://github.com/kkos/oniguruma - // vscode.window.showInformationMessage(JSON.stringify("diagnostics Regex Oniguruma")); - const trees = (0, TreeSitter_1.getTrees)(document); - // const jsonTree = trees.jsonTree; - const regexTrees = trees.regexTrees; - const regexNodes = trees.regexNodes; - for (const id in regexTrees) { - const regexTree = regexTrees[id]; - const node = regexTree.rootNode; - const text = node.text; - const regexNode = regexNodes[node.id]; - const key = regexNode.previousNamedSibling; - let regex = text.replace(/\\[\\\/bfnrt"]|\\u[0-9a-fA-F]{4}/g, regexEscapeReplacer); - if (key.text == 'end' || key.text == 'while') { - // `\\3` could be valid; could be invalid. Who knows? - // Would need to check the `begin` regex first for the number of capture groups - // Then how to tell Oniguruma how many are available?? - // Keeping in mind /(?I:...)/ - regex = regex.replace(/\\[1-9](\d{2})?(?!\d)/g, '\\0'); - } - const scanner = new vscodeOniguruma.OnigScanner([regex]); - const onigBinding = scanner._onigBinding; - const errorCode = onigBinding.UTF8ToString(onigBinding._getLastOnigError()); - // const string = vscodeOniguruma.createOnigString(''); // blank. Maybe can test against a user provided string? - // const match = scanner.findNextMatchSync(string, 0); // returns null if `regex` is invalid - if (errorCode != 'undefined error code') { - const range = (0, TreeSitter_1.toRange)(key); - const diagnostic = { - range: range, - message: errorCode, - severity: vscode.DiagnosticSeverity.Error, - source: 'Oniguruma', - }; - diagnostics.push(diagnostic); - } - } - } - // vscode.window.showInformationMessage(JSON.stringify(diagnostics)); - Diagnostics.set(document.uri, diagnostics); -} -function regexEscapeReplacer(substring, ...args) { - const char = substring.charAt(1); - switch (char) { - case '\\': return '\\'; - case '/': return '/'; - case 'b': return '\b'; - case 'f': return '\f'; - case 'n': return '\n'; - case 'r': return '\r'; - case 't': return '\t'; - case '"': return '"'; - case 'u': - const hexStr = substring.substring(2, 6); - const hexCode = parseInt(hexStr, 16); - const char = String.fromCodePoint(hexCode); - return char; - } -} - - -/***/ }), -/* 28 */ -/***/ ((__unused_webpack_module, exports, __webpack_require__) => { - -"use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.initTokenColorCustomizations = void 0; -const vscode = __webpack_require__(1); -function initTokenColorCustomizations(context) { - // vscode.window.showInformationMessage(JSON.stringify("tokenColorCustomizations")); - const activeDocument = vscode.window.activeTextEditor?.document; // `activeTextEditor` can be `undefined`! - update(packageJSON(activeDocument) || jsonTextMate(activeDocument)); - context.subscriptions.push(vscode.window.onDidChangeActiveTextEditor((editor) => { - // vscode.window.showInformationMessage(JSON.stringify("active")); - const document = editor?.document; // `editor` can be `undefined`! - update(packageJSON(document) || jsonTextMate(document)); - })); - context.subscriptions.push(vscode.workspace.onDidOpenTextDocument((document) => { - // vscode.window.showInformationMessage(JSON.stringify("open")); - if (document == vscode.window.activeTextEditor?.document) { // `activeTextEditor` can be `undefined`! - update(packageJSON(document) || jsonTextMate(document)); - } - })); - context.subscriptions.push(vscode.workspace.onDidChangeTextDocument((edits) => { - // vscode.window.showInformationMessage(JSON.stringify("change")); - if (edits.contentChanges.length == 0) { - return; - } - const document = edits.document; - if (vscode.languages.match(packageJSONSelector, document)) { - if (document == vscode.window.activeTextEditor?.document) { // `activeTextEditor` can be `undefined`! - update(packageJSON(document)); - } - } - })); - // context.subscriptions.push( - // vscode.workspace.onDidChangeConfiguration((event: vscode.ConfigurationChangeEvent) => { - // // vscode.window.showInformationMessage(JSON.stringify("config")); - // if (event.affectsConfiguration("editor.tokenColorCustomizations")) { - // const document = vscode.window.activeTextEditor?.document; // `activeTextEditor` can be `undefined`! - // update(packageJSON(document) || jsonTextMate(document)); - // } - // }) - // ); - context.subscriptions.push(vscode.workspace.onDidCloseTextDocument((document) => { - // vscode.window.showInformationMessage(JSON.stringify("close")); - if (document == vscode.window.activeTextEditor?.document) { // `activeTextEditor` can be `undefined`! - update(null); - } - })); -} -exports.initTokenColorCustomizations = initTokenColorCustomizations; -const packageJSONSelector = [ - { pattern: "**/package.json", scheme: "file" }, - { pattern: "**/package.json", scheme: "vscode-vfs" } -]; -const jsonTextMateSelector = [ - { language: "json-textmate", scheme: "file" }, - { language: "json-textmate", scheme: "vscode-vfs" } -]; -// const documentSelector: vscode.DocumentSelector = [packageJSONSelector, jsonTextMateSelector]; -function packageJSON(document) { - // vscode.window.showInformationMessage(JSON.stringify("packageJSON")); - if (!document) { - return null; - } - if (vscode.languages.match(packageJSONSelector, document)) { - const uri = document.uri; - return uri; - } -} -function jsonTextMate(document) { - // vscode.window.showInformationMessage(JSON.stringify("jsonTextMate")); - if (!document) { - return null; - } - if (vscode.languages.match(jsonTextMateSelector, document)) { - const uri = vscode.Uri.joinPath(document.uri, '../../package.json'); - return uri; - } -} -let ignoreFailParse = false; -let hadTokenColorCustomizations = false; -const bak = '[tokenColorCustomizations_bak_JSON_TextMate'; // The square bracket is there on purpose so that the json `settings` schema doesn't complain about it -async function update(uri) { - // vscode.window.showInformationMessage(JSON.stringify("update")); - // Workspace settings have higher priority than Global settings. But... Workspace settings don't work when there is no Workspace - const configurationTarget = vscode.workspace.name ? vscode.ConfigurationTarget.Workspace : vscode.ConfigurationTarget.Global; - const configurationValue = vscode.workspace.name ? 'workspaceValue' : 'globalValue'; - if (uri && uri.scheme != 'untitled') { - try { - const packageDocument = await vscode.workspace.openTextDocument(uri); - const packageParsed = await JSON.parse(packageDocument?.getText()); - const package_tokenColorCustomizations = packageParsed?.contributes?.configurationDefaults?.['editor.tokenColorCustomizations']; - if (package_tokenColorCustomizations) { - const editor = vscode.workspace.getConfiguration("editor"); - const tokenColorCustomizations = editor.inspect("tokenColorCustomizations")[configurationValue] ?? {}; - const tokenColorCustomizations_bak = tokenColorCustomizations[bak] ?? tokenColorCustomizations; - delete tokenColorCustomizations_bak[bak]; - package_tokenColorCustomizations[bak] = tokenColorCustomizations_bak; - editor.update("tokenColorCustomizations", package_tokenColorCustomizations, configurationTarget); - hadTokenColorCustomizations = true; - return; - } - } - catch (error) { - if (hadTokenColorCustomizations && ignoreFailParse == false) { - const message = `Failed to parse package.json:\n${error}`; - const ignore = "Ignore"; - vscode.window.showWarningMessage(message, ignore).then((value) => { - if (value == ignore) { - ignoreFailParse = true; - } - return true; - }); - } - } - } - const editor = vscode.workspace.getConfiguration("editor"); - const tokenColorCustomizations = editor.inspect("tokenColorCustomizations")[configurationValue] ?? {}; - const tokenColorCustomizations_bak = tokenColorCustomizations[bak]; - if (tokenColorCustomizations_bak !== undefined) { - const length = Object.keys(tokenColorCustomizations_bak).length; - editor.update("tokenColorCustomizations", length ? tokenColorCustomizations_bak : undefined, configurationTarget); - } -} - - -/***/ }), -/* 29 */, -/* 30 */ -/***/ ((__unused_webpack_module, exports, __webpack_require__) => { - -"use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.RenameProvider = void 0; -const vscode = __webpack_require__(1); -const TreeSitter_1 = __webpack_require__(2); -const cursorQuery = ` - (include (value (scopeName) @scopeName)) - (include (value (ruleName) @ruleName)) - ;(json (scopeName (value) @root_scopeName)) - (repo (key) @repo) -`; -exports.RenameProvider = { - /* async */ provideRenameEdits(document, position, newName, token) { - // vscode.window.showInformationMessage(JSON.stringify("RenameEdit")); - const trees = (0, TreeSitter_1.getTrees)(document); - const jsonTree = trees.jsonTree; - const point = (0, TreeSitter_1.toPoint)(position); - const cursorCapture = (0, TreeSitter_1.queryNode)(jsonTree.rootNode, cursorQuery, point); - if (!cursorCapture) { - return; - } - const cursorName = cursorCapture.name; - const cursorNode = cursorCapture.node; - const cursorText = cursorNode.text; - const cursorRange = (0, TreeSitter_1.toRange)(cursorNode); - const rootScopeName = (0, TreeSitter_1.queryNode)(jsonTree.rootNode, `(json (scopeName (value) @scopeName))`).pop()?.node?.text; - const edits = []; - const workspaceEdits = new vscode.WorkspaceEdit(); - const uri = document.uri; - let query = ``; - switch (cursorName) { - case 'ruleName': - query += `(repo (key) @repo (#eq? @repo "${cursorText}"))`; - query += `(include (value (ruleName) @ruleName) @include (#eq? @include "#${cursorText}"))`; - if (rootScopeName) { - query += `(include (value (ruleName) @ruleName) @include (#eq? @include "${rootScopeName}#${cursorText}"))`; - } - break; - // case 'root_scopeName': - // const uriPackage = vscode.Uri.joinPath(uri, '../../package.json'); - // await vscode.workspace.openTextDocument(uriPackage); - // for (const textDocument of vscode.workspace.textDocuments) { - // if (!vscode.languages.match({ pattern: "**/package.json", scheme: "file" }, textDocument)) { - // continue; - // } - // try { - // const packageParsed = await JSON.parse(textDocument.getText()); - // const grammars = packageParsed.contributes?.grammars; - // if (grammars) { - // for (const grammar of grammars) { - // if (grammar.scopeName == cursorText) { - // const edit = new vscode.TextEdit(range, newName); // Cant get range - // workspaceEdits.set(textDocument.uri, [edit]); - // } - // } - // } - // } catch (error) { - // } - // } - // break; - case 'scopeName': - query += `(include (value (scopeName) @scopeName (#eq? @scopeName "${cursorText}")))`; - query += `(json (scopeName (value) @scopeName (#eq? @scopeName "${cursorText}")))`; - break; - case 'repo': - query += `(include (value (ruleName) @ruleName) @include (#eq? @include "#${cursorText}"))`; - if (rootScopeName) { - query += `(include (value (ruleName) @ruleName) @include (#eq? @include "${rootScopeName}#${cursorText}"))`; - } - const edit = new vscode.TextEdit(cursorRange, newName); - edits.push(edit); - break; - default: - return; - } - const queryCaptures = (0, TreeSitter_1.queryNode)(jsonTree.rootNode, query); - for (const queryCapture of queryCaptures) { - if (queryCapture.name == 'include') { - continue; - } - const node = queryCapture.node; - const range = (0, TreeSitter_1.toRange)(node); - const edit = new vscode.TextEdit(range, newName); - edits.push(edit); - } - workspaceEdits.set(uri, edits); - // vscode.window.showInformationMessage(JSON.stringify(workspaceEdits)); - return workspaceEdits; - }, - prepareRename(document, position, token) { - // vscode.window.showInformationMessage(JSON.stringify("Rename")); - const trees = (0, TreeSitter_1.getTrees)(document); - const jsonTree = trees.jsonTree; - const point = (0, TreeSitter_1.toPoint)(position); - const cursorCapture = (0, TreeSitter_1.queryNode)(jsonTree.rootNode, cursorQuery, point); - if (!cursorCapture) { - return Promise.reject('Item not renamable'); - } - // const cursorName = cursorCapture.name; - const cursorNode = cursorCapture.node; - const cursorText = cursorNode.text; - const cursorRange = (0, TreeSitter_1.toRange)(cursorNode); - // if (cursorName == 'root_scopeName') { - // const uriPackage = vscode.Uri.joinPath(document.uri, '../../package.json'); - // vscode.workspace.openTextDocument(uriPackage); - // } - const rename = { range: cursorRange, placeholder: cursorText }; - // vscode.window.showInformationMessage(JSON.stringify(rename)); - return rename; - }, -}; - - -/***/ }), -/* 31 */, -/* 32 */ -/***/ ((__unused_webpack_module, exports, __webpack_require__) => { - -"use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.ReferenceProvider = void 0; -const vscode = __webpack_require__(1); -const TreeSitter_1 = __webpack_require__(2); -exports.ReferenceProvider = { - provideReferences(document, position, context, token) { - // vscode.window.showInformationMessage(JSON.stringify("references")); - const tree = (0, TreeSitter_1.getTree)(document); - const point = (0, TreeSitter_1.toPoint)(position); - let queryString; - // vscode.window.showInformationMessage(JSON.stringify(tree.rootNode.namedDescendantForPosition(point).text)); - queryString = ` - ;(json (scopeName (value) @scopeName)) - (include (value) @include) - (repo (key) @repo) - `; - // const referenceQueryCapture = queryForPosition(tree, queryString, point); - const referenceQueryCapture = (0, TreeSitter_1.queryNode)(tree.rootNode, queryString, point); - if (referenceQueryCapture == null) { - return; - } - const node = referenceQueryCapture.node; - const text = node.text; - // vscode.window.showInformationMessage(JSON.stringify(node.toString())); - queryString = `(json (scopeName (value) @scopeName))`; - const rootScopeName = (0, TreeSitter_1.queryForPosition)(tree, queryString)?.node?.text; - switch (referenceQueryCapture.name) { - case 'repo': - if (text == '$self' || text == '$base') { - return; - } - queryString = - `(include (value) @include (#eq? @include "#${text}"))` + - `(repo (key) @repo (#eq? @repo "${text}"))`; - if (rootScopeName && text) - queryString += `(include (value) @include (#eq? @include "${rootScopeName}#${text}"))`; - break; - case 'include': // move to own function. Can be used for code-lens and symbol-highlight etc - /* - *fail - #invalid *fail - invalid *fail - invalid# *fail - invalid#$self *fail - invalid#$base *fail - invalid#invalid *fail - $self $self - #$self $self - source.same $self - source.same# $self - source.same#$self $self - $base $base - #$base $base - source.same#$base $base - source.other#$base $base - # #include - #include #include - source.same#include #include - source.other other - source.other# other - source.other#$self other - source.other#include other#include - */ - if (text == '') { // *fail - // vscode.window.showInformationMessage("*fail"); - return; - } - if (node.childForFieldName('base')) { // $base - // vscode.window.showInformationMessage("$base"); - queryString = `(include (value) @include (#match? @include "^([^#]*#)?\\\\$base$"))`; - } - else { - const scopeName = node.childForFieldName('scopeName')?.text; - const ruleName = node.childForFieldName('ruleName')?.text; - if (scopeName && scopeName != rootScopeName) { - if (ruleName) { // other#include - // vscode.window.showInformationMessage("other#include"); - queryString = `(include (value) @include (#eq? @include "${scopeName}#${ruleName}"))`; - } - else { // other - // vscode.window.showInformationMessage("other"); - queryString = - `(include (value) @include (#eq? @include "${scopeName}"))` + - `(include (value) @include (#eq? @include "${scopeName}#"))` + - `(include (value) @include (#eq? @include "${scopeName}#$self"))`; - } - } - else if (node.childForFieldName('self') || (scopeName && !ruleName)) { // $self - // vscode.window.showInformationMessage("$self"); - queryString = - `(include (value) @include (#match? @include "^#?\\\\$self$"))`; - if (rootScopeName) { - queryString += - `(include (value) @include (#eq? @include "${rootScopeName}"))` + - `(include (value) @include (#eq? @include "${rootScopeName}#"))` + - `(include (value) @include (#eq? @include "${rootScopeName}#$self"))`; - } - } - else { // #include - // vscode.window.showInformationMessage("#include"); - queryString = - `(include (value) @include (#eq? @include "#${ruleName}"))` + - `(repo (key) @repo (#eq? @repo "${ruleName}"))`; - if (ruleName) { - queryString += `(include (value) @include (#eq? @include "${rootScopeName}#${ruleName}"))`; - } - } - } - break; - default: - return; - } - // vscode.window.showInformationMessage(queryString); - const language = tree.getLanguage(); - const query = language.query(queryString); - const queryCaptures = query.captures(tree.rootNode); - const locations = []; - const uri = document.uri; - for (const queryCapture of queryCaptures) { - if (queryCapture.name == 'include') { - const range = (0, TreeSitter_1.toRange)(queryCapture.node); // .parent? - const location = new vscode.Location(uri, range); - locations.push(location); - } - } - // if (referenceQueryCapture.name == 'repo' && locations.length == 0) { - // const range = toRange(node); // .parent? - // const location = new vscode.Location(uri, range); - // locations.push(location); - // } - if (( /* referenceQueryCapture.name == 'repo' && */locations.length == 0) || - (referenceQueryCapture.name == 'include' && locations.length <= 1)) { - for (const queryCapture of queryCaptures) { - if (queryCapture.name == 'repo') { - const range = (0, TreeSitter_1.toRange)(queryCapture.node); // .parent? - const location = new vscode.Location(uri, range); - locations.push(location); - } - } - } - // vscode.window.showInformationMessage(JSON.stringify(locations)); - return locations; - } -}; - - -/***/ }), -/* 33 */ -/***/ ((__unused_webpack_module, exports, __webpack_require__) => { - -"use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.DefinitionProvider = void 0; -const vscode = __webpack_require__(1); -const TreeSitter_1 = __webpack_require__(2); -const extension_1 = __webpack_require__(0); -exports.DefinitionProvider = { - async provideDefinition(document, position, token) { - // vscode.window.showInformationMessage(JSON.stringify("Definition")); - const trees = (0, TreeSitter_1.getTrees)(document); - const tree = trees.jsonTree; - const point = (0, TreeSitter_1.toPoint)(position); - // vscode.window.showInformationMessage(JSON.stringify(tree.rootNode.namedDescendantForPosition(point).text)); - const cursorQuery = ` - (json (scopeName (value) @scopeName)) - (repo (key) @repo) - (include (value) @include) - (captures (capture (key) @capture)) - (beginCaptures (capture (key) @beginCapture)) - (endCaptures (capture (key) @endCapture)) - (whileCaptures (capture (key) @whileCapture)) - ;(match (regex) @regex) - `; - const cursorCapture = (0, TreeSitter_1.queryNode)(tree.rootNode, cursorQuery, point); - // vscode.window.showInformationMessage(JSON.stringify(cursorCapture)); - if (cursorCapture == null) { - return; - } - const node = cursorCapture.node; - // vscode.window.showInformationMessage(JSON.stringify(node)); - const originSelectionRange = (0, TreeSitter_1.toRange)(node); - if (!originSelectionRange.contains(position)) { - return; - } - const text = node.text; - let queryString; - // vscode.window.showInformationMessage(JSON.stringify(node.text)); - const definitions = []; - switch (cursorCapture.name) { - case 'scopeName': - for (const extension of vscode.extensions.all) { - const grammars = extension.packageJSON?.contributes?.grammars; - if (grammars) { - for (const grammar of grammars) { - if (grammar.scopeName == text) { - const uri = vscode.Uri.joinPath(extension.extensionUri, 'package.json'); - await vscode.workspace.openTextDocument(uri); - } - } - } - } - const uri = vscode.Uri.joinPath(document.uri, '../../package.json'); - if (uri) { - await vscode.workspace.openTextDocument(uri); - } - for (const textDocument of vscode.workspace.textDocuments) { - if (!vscode.languages.match({ pattern: "**/package.json" }, textDocument)) { - continue; - } - try { - const packageJSON = await JSON.parse(textDocument.getText()); - const grammars = packageJSON?.contributes?.grammars; - if (grammars) { - for (const grammar of grammars) { - if (grammar.scopeName == text) { - const definitionLink = { - originSelectionRange: originSelectionRange, // Underlined text - targetUri: textDocument.uri, - targetRange: new vscode.Range(0, 0, textDocument.lineCount, 1000), // Hover text - targetSelectionRange: new vscode.Range(0, 0, textDocument.lineCount + 1, 0) // Highlighted text - }; - definitions.push(definitionLink); - } - } - } - } - catch (error) { - } - } - break; - case 'repo': - if (text == '$self' || text == '$base') { - return; - } - // Call ReferenceProvider() (see at bottom) - break; - case 'include': - if (node.childForFieldName('base')) { // $base - // Call ReferenceProvider() (see at bottom) - break; - } - queryString = `(json (scopeName (value) @scopeName))`; - const rootScopeNameNode = (0, TreeSitter_1.queryNode)(tree.rootNode, queryString).pop()?.node ?? null; - const rootScopeNameText = rootScopeNameNode?.text ?? ''; - const scopeName = node.childForFieldName('scopeName')?.text ?? ''; - const ruleName = node.childForFieldName('ruleName')?.text ?? ''; - queryString = `(json (patterns) @patterns)`; - const rootPatternsNode = (0, TreeSitter_1.queryNode)(tree.rootNode, queryString).pop()?.node; - const rootPatternsRange = (0, TreeSitter_1.toRange)(rootPatternsNode); - if ((node.childForFieldName('self') && !scopeName) || (scopeName == rootScopeNameText && !ruleName)) { // $self - if (rootPatternsNode == null) { - break; - } - const targetSelectionRange = rootPatternsRange.contains(originSelectionRange) ? - (0, TreeSitter_1.toRange)(rootPatternsNode.childForFieldName('key')) : - rootPatternsRange; - const locationLink = { - originSelectionRange: originSelectionRange, // Underlined text - targetUri: document.uri, - targetRange: rootPatternsRange, // Hover text - targetSelectionRange: targetSelectionRange // Highlighted text - }; - definitions.push(locationLink); - break; - } - if (!scopeName || scopeName == rootScopeNameText) { // #include - queryString = `(repo - [(patterns) (include)] (repository - (repo - (key) @repo (.eq? @repo "${ruleName}"))) - !match !begin)`; - const nestedRepoNode = (0, TreeSitter_1.queryNode)(tree.rootNode, queryString, point, false)?.node; - if (nestedRepoNode) { - const locationLink = { - originSelectionRange: originSelectionRange, // Underlined text - targetUri: document.uri, - targetRange: (0, TreeSitter_1.toRange)(nestedRepoNode.parent), // Hover text - targetSelectionRange: (0, TreeSitter_1.toRange)(nestedRepoNode) // Highlighted text - }; - definitions.push(locationLink); - break; - } - queryString = `(json (repository (repo (key) @repo (.eq? @repo "${ruleName}"))))`; - const rootRepoNode = (0, TreeSitter_1.queryNode)(tree.rootNode, queryString).pop()?.node; - if (rootRepoNode) { - const locationLink = { - originSelectionRange: originSelectionRange, // Underlined text - targetUri: document.uri, - targetRange: (0, TreeSitter_1.toRange)(rootRepoNode.parent), // Hover text - targetSelectionRange: (0, TreeSitter_1.toRange)(rootRepoNode) // Highlighted text - }; - definitions.push(locationLink); - } - break; - } - for (const extension of vscode.extensions.all) { // other - const grammars = extension.packageJSON?.contributes?.grammars; - if (grammars) { - for (const grammar of grammars) { - if (grammar.scopeName == scopeName) { - const uri = vscode.Uri.joinPath(extension.extensionUri, grammar.path); - const document = await vscode.workspace.openTextDocument(uri); - vscode.languages.setTextDocumentLanguage(document, 'json-textmate'); - } - } - } - } - for (const textDocument of vscode.workspace.textDocuments) { // other#include - if (!vscode.languages.match(extension_1.DocumentSelector, textDocument)) { - continue; - } - const documentTree = (0, TreeSitter_1.getTree)(textDocument); - queryString = `(json (scopeName (value) @scopeName (.eq? @scopeName "${scopeName}")))`; - const documentScopeNameNode = (0, TreeSitter_1.queryNode)(documentTree.rootNode, queryString).pop()?.node; - if (documentScopeNameNode) { - if (ruleName) { // source.other#include - queryString = `(json (repository (repo (key) @repo (.eq? @repo "${ruleName}"))))`; - const repoNode = (0, TreeSitter_1.queryNode)(documentTree.rootNode, queryString).pop()?.node; - if (repoNode) { - const locationLink = { - originSelectionRange: originSelectionRange, // Underlined text - targetUri: textDocument.uri, - targetRange: (0, TreeSitter_1.toRange)(repoNode.parent), // Hover text - targetSelectionRange: (0, TreeSitter_1.toRange)(repoNode) // Highlighted text - }; - definitions.push(locationLink); - } - } - else { // source.other - queryString = `(json (patterns) @patterns)`; - const documentPatternsNode = (0, TreeSitter_1.queryNode)(documentTree.rootNode, queryString).pop()?.node; - const locationLink = { - originSelectionRange: originSelectionRange, // Underlined text - targetUri: textDocument.uri, - targetRange: (0, TreeSitter_1.toRange)(documentPatternsNode), // Hover text - targetSelectionRange: (0, TreeSitter_1.toRange)(documentScopeNameNode) // Highlighted text - }; - definitions.push(locationLink); - } - } - } - break; - case 'capture': - const tripleParent = node.parent.parent.parent; - if (tripleParent.childForFieldName('match')) { - const matchGroup = getRegexGroup(trees, node, 'match'); - const groupRange = (0, TreeSitter_1.toRange)(matchGroup); - const locationLink = { - originSelectionRange: originSelectionRange, // Underlined text - targetUri: document.uri, - targetRange: groupRange, // Hover text - targetSelectionRange: groupRange // Highlighted text - }; - definitions.push(locationLink); - break; - } - if (!tripleParent.childForFieldName('begin')) { - break; - } - if (!(0, TreeSitter_1.getLastNode)(tripleParent, 'beginCaptures')) { - const beginGroup = getRegexGroup(trees, node, 'begin'); - if (beginGroup) { - const groupRange = (0, TreeSitter_1.toRange)(beginGroup); - const locationLink = { - originSelectionRange: originSelectionRange, // Underlined text - targetUri: document.uri, - targetRange: groupRange, // Hover text - targetSelectionRange: groupRange // Highlighted text - }; - definitions.push(locationLink); - } - } - if (tripleParent.childForFieldName('while')) { - if (!tripleParent.childForFieldName('whileCaptures')) { - const whileNode = getRegexGroup(trees, node, 'while'); - if (whileNode) { - const groupRange = (0, TreeSitter_1.toRange)(whileNode); - const locationLink = { - originSelectionRange: originSelectionRange, // Underlined text - targetUri: document.uri, - targetRange: groupRange, // Hover text - targetSelectionRange: groupRange // Highlighted text - }; - definitions.push(locationLink); - } - } - break; - } - if (!tripleParent.childForFieldName('endCaptures')) { - const endGroup = getRegexGroup(trees, node, 'end'); - if (endGroup) { - const groupRange = (0, TreeSitter_1.toRange)(endGroup); - const locationLink = { - originSelectionRange: originSelectionRange, // Underlined text - targetUri: document.uri, - targetRange: groupRange, // Hover text - targetSelectionRange: groupRange // Highlighted text - }; - definitions.push(locationLink); - } - } - break; - case 'beginCapture': - // const beginNode = queryNode(node.parent.parent.parent, `(begin (regex) @begin)`).pop()?.node; - // const beginRegexTrees = trees.regexTrees; - // const beginRegexNode = beginRegexTrees[beginNode.id]?.rootNode; - // const beginIndex = parseInt(text); // Ignores random characters after the first numeric, just like VSCode TextMate - // const beginGroupQuery = ` - // (capture_group) @group - // (capture_group_name) @name - // `; - // const beginGroupCaptures = queryNode(beginRegexNode, beginGroupQuery); - // const beginGroupRange = toRange(beginIndex ? beginGroupCaptures[beginIndex - 1].node : beginRegexNode); - const beginGroupRange = (0, TreeSitter_1.toRange)(getRegexGroup(trees, node, 'begin')); - const beginLocationLink = { - originSelectionRange: originSelectionRange, // Underlined text - targetUri: document.uri, - targetRange: beginGroupRange, // Hover text - targetSelectionRange: beginGroupRange // Highlighted text - }; - definitions.push(beginLocationLink); - break; - case 'endCapture': - // const endNode = queryNode(node.parent.parent.parent, `(end (regex) @end)`).pop()?.node; - // const endRegexTrees = trees.regexTrees; - // const endRegexNode = endRegexTrees[endNode.id]?.rootNode; - // const endIndex = parseInt(text); // Ignores random characters after the first numeric, just like VSCode TextMate - // const endGroupQuery = ` - // (capture_group) @group - // (capture_group_name) @name - // `; - // const endGroupCaptures = queryNode(endRegexNode, endGroupQuery); - // const endGroupRange = toRange(endIndex ? endGroupCaptures[endIndex - 1].node : endRegexNode); - const endGroupRange = (0, TreeSitter_1.toRange)(getRegexGroup(trees, node, 'end')); - const endLocationLink = { - originSelectionRange: originSelectionRange, // Underlined text - targetUri: document.uri, - targetRange: endGroupRange, // Hover text - targetSelectionRange: endGroupRange // Highlighted text - }; - definitions.push(endLocationLink); - break; - case 'whileCapture': - // const whileNode = getLastNode(node.parent.parent.parent, 'while'); - // const whileRegexTrees = trees.regexTrees; - // const whileRegexNode = whileRegexTrees[whileNode.childForFieldName('regex').id]?.rootNode; - // const whileIndex = parseInt(text); // Ignores random characters after the first numeric, just like VSCode TextMate - // const whileGroupQuery = ` - // (capture_group) @group - // (capture_group_name) @name - // `; - // const whileGroupCaptures = queryNode(whileRegexNode, whileGroupQuery); - // const whileGroupRange = toRange(whileIndex ? whileGroupCaptures[whileIndex - 1].node : whileRegexNode); - const whileGroupRange = (0, TreeSitter_1.toRange)(getRegexGroup(trees, node, 'while')); - const whileLocationLink = { - originSelectionRange: originSelectionRange, // Underlined text - targetUri: document.uri, - targetRange: whileGroupRange, // Hover text - targetSelectionRange: whileGroupRange // Highlighted text - }; - definitions.push(whileLocationLink); - break; - case 'regex': - const regexGroupRefs = getCaptureRefs(trees, node, position); - if (!regexGroupRefs) { - return; - } - for (const capture of regexGroupRefs.captures) { - const targetRange = (0, TreeSitter_1.toRange)(capture.node); - const regexLocationLink = { - originSelectionRange: regexGroupRefs.range, // Underlined text - targetUri: document.uri, - targetRange: targetRange, // Hover text - targetSelectionRange: targetRange // Highlighted text - }; - definitions.push(regexLocationLink); - } - return definitions; - default: - return; - } - if (definitions.length == 0) { - // vscode will automatically run the ReferenceProvider() if the only location overlaps with the input - const targetRange = (0, TreeSitter_1.toRange)(node.parent); - const definitionLink = { - originSelectionRange: originSelectionRange, // Underlined text - targetUri: document.uri, - targetRange: targetRange // Hover text - }; - definitions.push(definitionLink); - } - // vscode.window.showInformationMessage(JSON.stringify(definitions)); - return definitions; - } -}; -function getCaptureRefs(trees, node, position) { - const regexTrees = trees.regexTrees; - const regexNode = regexTrees[node.id]?.rootNode; - const captureGroupQuery = ` - (capture_group) @group - (capture_group_extended) @group - (capture_group_name) @name - (capture_group_name_extended) @name - `; - let groupNode; - const groupCaptures = (0, TreeSitter_1.queryNode)(regexNode, captureGroupQuery); - let index = groupCaptures.length; - while (groupCaptures.length) { - const captureNode = groupCaptures.pop().node; - if ((0, TreeSitter_1.toRange)(captureNode).contains(position)) { - groupNode = captureNode; - break; - } - index--; - } - vscode.window.showInformationMessage(JSON.stringify(index)); - if (!groupNode) { - return; - } - const groupSyntaxQuery = ` - "(" @open - ")" @close - "(?<" @open - "(?'" @open - ">" @close - "'" @close - (name) @name - `; - // const startPoint = toPoint(new vscode.Position(position.line, position.character - 1)); - const startPoint = { row: position.line, column: position.character - 1 }; - // const endPoint = toPoint(new vscode.Position(position.line, position.character + 1)); - const endPoint = { row: position.line, column: position.character + 1 }; - const groupSyntaxNode = (0, TreeSitter_1.queryNode)(groupNode, groupSyntaxQuery, startPoint, endPoint).pop()?.node; - if (!groupSyntaxNode) { - return; - } - const targetQuery = ` - ;(regex (subroutine (number)) @subroutine) - (regex (subroutine (number)) @subroutine (#eq? @subroutine "\\\\\\\\g<${index}>")) - `; - const targetCaptures = (0, TreeSitter_1.queryNode)(regexNode, targetQuery); - vscode.window.showInformationMessage(JSON.stringify(regexNode.toString())); - vscode.window.showInformationMessage(JSON.stringify(targetCaptures)); - return { range: (0, TreeSitter_1.toRange)(groupNode), captures: targetCaptures }; -} -function getRegexGroup(trees, captureNode, type) { - const node = (0, TreeSitter_1.getLastNode)(captureNode.parent.parent.parent, type); - const regexTrees = trees.regexTrees; - const regexNode = regexTrees[node.childForFieldName('regex').id]?.rootNode; - const index = parseInt(captureNode.text); // Ignores random characters after the first numeric, just like VSCode TextMate - if (index == 0) { - return regexNode; - } - const query = ` - (capture_group) @group - (capture_group_extended) @group - (capture_group_name) @name - (capture_group_name_extended) @name - `; - const captures = (0, TreeSitter_1.queryNode)(regexNode, query); - return captures[index - 1]?.node; -} - - -/***/ }), -/* 34 */ -/***/ ((__unused_webpack_module, exports, __webpack_require__) => { - -"use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.CallHierarchyProvider = void 0; -const vscode = __webpack_require__(1); -const TreeSitter_1 = __webpack_require__(2); -const DocumentSymbolProvider_1 = __webpack_require__(35); -exports.CallHierarchyProvider = { - prepareCallHierarchy(document, position, token) { - // vscode.window.showInformationMessage(JSON.stringify("CallHierarchy")); - const uri = document.uri; - const trees = (0, TreeSitter_1.getTrees)(uri); - const tree = trees.jsonTree; - const rootNode = tree.rootNode; - const point = (0, TreeSitter_1.toPoint)(position); - const includeQuery = `(include (value !scopeName (ruleName) @include))`; // TODO: support scopeNames - const includeCapture = (0, TreeSitter_1.queryNode)(rootNode, includeQuery, point); - const includeText = includeCapture?.node?.text; - const repoQuery = includeText ? ` - (json (repository (repo (key) @repo (.eq? @repo "${includeText}")))) - (repo - [(patterns) (include)] (repository - (repo - (key) @repo (.eq? @repo "${includeText}"))) - !match !begin) - ` - : `(repo (key) @repo)`; - const repoCapture = (0, TreeSitter_1.queryNode)(rootNode, repoQuery, point, false); - if (!repoCapture) { - return; - } - const node = repoCapture.node; - const selectionRange = (0, TreeSitter_1.toRange)(node); - const range = (0, TreeSitter_1.toRange)((0, TreeSitter_1.trueParent)(node)); - const detail = (0, TreeSitter_1.getComment)(node); - const name = node.text; - const kind = DocumentSymbolProvider_1.SymbolKind[repoCapture.name]; - const callHierarchyItem = new vscode.CallHierarchyItem(kind, name, detail, uri, range, selectionRange); - // vscode.window.showInformationMessage(JSON.stringify(callHierarchyItem)); - return callHierarchyItem; - }, - provideCallHierarchyIncomingCalls(item, token) { - // vscode.window.showInformationMessage(JSON.stringify("CallHierarchyIncoming")); - // vscode.window.showInformationMessage(JSON.stringify(item)); - const uri = item.uri; - const trees = (0, TreeSitter_1.getTrees)(uri); - const tree = trees.jsonTree; - const rootNode = tree.rootNode; - const callHierarchyIncomingCalls = []; - const includeQuery = `(include (value !scopeName (ruleName) @include (.eq? @include "${item.name}")))`; - const includeCaptures = (0, TreeSitter_1.queryNode)(rootNode, includeQuery); - for (const includeCapture of includeCaptures) { - const includeNode = includeCapture.node; - const selectionRange = (0, TreeSitter_1.toRange)(includeNode); - const range = (0, TreeSitter_1.toRange)((0, TreeSitter_1.trueParent)(includeNode)); - const targetQuery = ` - (json (scopeName (value) @scopeName)) - (repo (key) @repo) - `; - const targetCapture = (0, TreeSitter_1.queryNode)(rootNode, targetQuery, includeNode.startPosition, false); - const targetNode = targetCapture.node; - const detail = (0, TreeSitter_1.getComment)(targetNode); - const name = targetNode.text; - const kind = DocumentSymbolProvider_1.SymbolKind[includeCapture.name]; - const callHierarchyItem = new vscode.CallHierarchyItem(kind, name, detail, uri, range, selectionRange); - const ranges = [range]; - const callHierarchyIncomingCall = new vscode.CallHierarchyIncomingCall(callHierarchyItem, ranges); - callHierarchyIncomingCalls.push(callHierarchyIncomingCall); - } - // vscode.window.showInformationMessage(JSON.stringify(callHierarchyOutgoingCalls)); - return callHierarchyIncomingCalls; - }, - provideCallHierarchyOutgoingCalls(item, token) { - // vscode.window.showInformationMessage(JSON.stringify("CallHierarchyOutgoing")); - // vscode.window.showInformationMessage(JSON.stringify(item)); - const uri = item.uri; - const trees = (0, TreeSitter_1.getTrees)(uri); - const tree = trees.jsonTree; - const rootNode = tree.rootNode; - const callHierarchyOutgoingCalls = []; - const includeQuery = ` - ;(include (value) @include) - (include (value !scopeName (ruleName) @include)) - `; - const startPoint = (0, TreeSitter_1.toPoint)(item.range.start); - const endPoint = (0, TreeSitter_1.toPoint)(item.range.end); - const includeCaptures = (0, TreeSitter_1.queryNode)(rootNode, includeQuery, startPoint, endPoint); - for (const includeCapture of includeCaptures) { - const includeNode = includeCapture.node; - const includeText = includeNode.text; - const repoQuery = ` - (json (repository (repo (key) @repo (.eq? @repo "${includeText}")))) - (repo - [(patterns) (include)] (repository - (repo - (key) @repo (.eq? @repo "${includeText}"))) - !match !begin) - `; - const repoCapture = (0, TreeSitter_1.queryNode)(rootNode, repoQuery, startPoint, false); - if (!repoCapture) { - continue; - } - const repoNode = repoCapture.node; - const selectionRange = (0, TreeSitter_1.toRange)(repoNode); - const range = (0, TreeSitter_1.toRange)((0, TreeSitter_1.trueParent)(repoNode)); - const text = repoNode.text; - const detail = (0, TreeSitter_1.getComment)(repoNode); - const kind = DocumentSymbolProvider_1.SymbolKind[repoCapture.name]; - const callHierarchyItem = new vscode.CallHierarchyItem(kind, text, detail, uri, range, selectionRange); - const parentRange = (0, TreeSitter_1.toRange)((0, TreeSitter_1.trueParent)(includeNode)); - const ranges = [parentRange]; - const callHierarchyOutgoingCall = new vscode.CallHierarchyOutgoingCall(callHierarchyItem, ranges); - callHierarchyOutgoingCalls.push(callHierarchyOutgoingCall); - } - // vscode.window.showInformationMessage(JSON.stringify(callHierarchyOutgoingCalls)); - return callHierarchyOutgoingCalls; - }, -}; - - -/***/ }), -/* 35 */ -/***/ ((__unused_webpack_module, exports, __webpack_require__) => { - -"use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.DocumentSymbolProvider = exports.SymbolKind = void 0; -const vscode = __webpack_require__(1); -const TreeSitter_1 = __webpack_require__(2); -exports.SymbolKind = { - /* - 'File': vscode.SymbolKind.File, - 'Module': vscode.SymbolKind.Module, - 'Namespace': vscode.SymbolKind.Namespace, - 'Package': vscode.SymbolKind.Package, - 'Class': vscode.SymbolKind.Class, - 'Method': vscode.SymbolKind.Method, - 'Property': vscode.SymbolKind.Property, - 'Field': vscode.SymbolKind.Field, - 'Constructor': vscode.SymbolKind.Constructor, - 'Enum': vscode.SymbolKind.Enum, - 'Interface': vscode.SymbolKind.Interface, - 'Function': vscode.SymbolKind.Function, - 'Variable': vscode.SymbolKind.Variable, - 'Constant': vscode.SymbolKind.Constant, - 'String': vscode.SymbolKind.String, - 'Number': vscode.SymbolKind.Number, - 'Boolean': vscode.SymbolKind.Boolean, - 'Array': vscode.SymbolKind.Array, - 'Object': vscode.SymbolKind.Object, - 'Key': vscode.SymbolKind.String, - 'Null': vscode.SymbolKind.Null, - 'EnumMember': vscode.SymbolKind.EnumMember, - 'Struct': vscode.SymbolKind.Struct, - 'Event': vscode.SymbolKind.Event, - 'Operator': vscode.SymbolKind.Operator, - 'TypeParameter': vscode.SymbolKind.TypeParameter, - */ - 'json': vscode.SymbolKind.File, - 'patterns': vscode.SymbolKind.Array, - 'pattern': vscode.SymbolKind.Number, - 'repository': vscode.SymbolKind.Object, - 'repo': vscode.SymbolKind.Function, - 'captures': vscode.SymbolKind.Field, - 'beginCaptures': vscode.SymbolKind.Field, - 'endCaptures': vscode.SymbolKind.Field, - 'capture': vscode.SymbolKind.Number, - 'match': vscode.SymbolKind.String, - 'begin': vscode.SymbolKind.String, - 'end': vscode.SymbolKind.String, - 'while': vscode.SymbolKind.String, - 'scopeName': vscode.SymbolKind.String, - 'name_scope': vscode.SymbolKind.String, - 'name': vscode.SymbolKind.String, - 'version': vscode.SymbolKind.String, - 'schema': vscode.SymbolKind.String, - 'fileTypes': vscode.SymbolKind.String, - 'firstLineMatch': vscode.SymbolKind.String, - 'foldingStartMarker': vscode.SymbolKind.String, - 'foldingStopMarker': vscode.SymbolKind.String, - 'uuid': vscode.SymbolKind.Number, - 'injectionSelector': vscode.SymbolKind.String, - 'injections': vscode.SymbolKind.Object, - 'injection': vscode.SymbolKind.Number, - 'include': vscode.SymbolKind.Variable, - 'comment': vscode.SymbolKind.String, - 'comment_slash': vscode.SymbolKind.String, - 'object': vscode.SymbolKind.Object, - 'array': vscode.SymbolKind.Array, - 'item': vscode.SymbolKind.String, - 'value': vscode.SymbolKind.Key, - 'key': vscode.SymbolKind.Property, - 'boolean': vscode.SymbolKind.Boolean, - 'null': vscode.SymbolKind.Null, - 'integer': vscode.SymbolKind.Number, - 'string': vscode.SymbolKind.String, - 'regex': vscode.SymbolKind.Event, - '{': vscode.SymbolKind.Object, - '}': vscode.SymbolKind.Object, - '[': vscode.SymbolKind.Array, - ']': vscode.SymbolKind.Array, - ',': vscode.SymbolKind.Property, - ':': vscode.SymbolKind.Property, - '"': vscode.SymbolKind.Property, - 'literal': vscode.SymbolKind.String, - 'backslash': vscode.SymbolKind.Property, -}; -exports.DocumentSymbolProvider = { - provideDocumentSymbols(document, token) { - // vscode.window.showInformationMessage(JSON.stringify("documentSymbol")); - const trees = (0, TreeSitter_1.getTrees)(document); - const tree = trees.jsonTree; - let node = tree.rootNode; - let index = 0; - let documentSymbol = newDocumentSymbol(node); - const nodeStack = []; - const indexStack = []; - const documentSymbolStack = []; - while (true) { - // let childNode = node.child(index); - let childNode = node.namedChild(index); - if (!childNode) { - node = nodeStack.pop(); - if (node === undefined) { - break; - } - index = indexStack.pop(); - index++; - const tempSymbol = documentSymbolStack.pop(); - tempSymbol.children.push(documentSymbol); - documentSymbol = tempSymbol; - continue; - } - if (childNode.type == 'regex') { - childNode = (0, TreeSitter_1.getRegexNode)(trees, childNode) ?? childNode; - // childNode = regexTrees[childNode.id]?.rootNode ?? childNode; - } - // if (childNode.childCount && indexStack.length < 900) { // StackOverFlow - if (childNode.namedChildCount && indexStack.length < 900) { // StackOverFlow - nodeStack.push(node); - indexStack.push(index); - documentSymbolStack.push(documentSymbol); - documentSymbol = newDocumentSymbol(childNode); - node = childNode; - index = 0; - continue; - } - documentSymbol.children.push(newDocumentSymbol(childNode)); - index++; - } - return [documentSymbol]; - }, -}; -function newDocumentSymbol(node) { - let text; - switch (node.type) { - case 'pattern': - case 'injection': - let index = 0; - let sibling = node; - while (sibling = sibling.previousNamedSibling) { - index++; - } - text = index.toString(); - break; - case 'repo': - case 'capture': - text = node.firstNamedChild.text; - break; - case 'name_scope': - text = 'name'; - break; - case 'value': - text = node.text; - break; - } - const name = text?.slice(0, 50) || node.type; - const detail = node.text.slice(0, 50); - const kind = exports.SymbolKind[node.type] ?? (node.isNamed() ? vscode.SymbolKind.Method : vscode.SymbolKind.Field); - const range = (0, TreeSitter_1.toRange)(node); - const selectionRange = range; - // const selectionRange = toRange(node.firstNamedChild) ?? range; - const documentSymbol = new vscode.DocumentSymbol(name, detail, kind, range, selectionRange); - // vscode.window.showInformationMessage(JSON.stringify(documentSymbol)); - return documentSymbol; -} - - -/***/ }), -/* 36 */ -/***/ ((__unused_webpack_module, exports, __webpack_require__) => { - -"use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.DocumentHighlightProvider = void 0; -const vscode = __webpack_require__(1); -const TreeSitter_1 = __webpack_require__(2); -exports.DocumentHighlightProvider = { - provideDocumentHighlights(document, position, token) { - // vscode.window.showInformationMessage(JSON.stringify("DocumentHighlights")); - const trees = (0, TreeSitter_1.getTrees)(document); - const jsonTree = trees.jsonTree; - const point = (0, TreeSitter_1.toPoint)(position); - const cursorQuery = ` - (key) @key - (value !scopeName !ruleName !self !base) @value - (capture . (key) @key) - (repo . (key) @repo) - (json (scopeName (value) @rootScopeName)) - (include (value (scopeName) !ruleName !base) @scopeName) - (include (value (ruleName)) @include) - (include (value !scopeName (self) @self)) - (include (value (base) @base)) - (name_scope (value (scope) @scope)) - `; - const cursorCapture = (0, TreeSitter_1.queryNode)(jsonTree.rootNode, cursorQuery, point); - if (!cursorCapture) { - return; - } - const cursorName = cursorCapture.name; - const cursorNode = cursorCapture.node; - const cursorText = cursorNode.text; - // const cursorRange = toRange(cursorNode); - // const scopeName = cursorNode.parent.childForFieldName('scopeName')?.text; - const rootScopeName = (0, TreeSitter_1.queryNode)(jsonTree.rootNode, `(json (scopeName (value) @scopeName))`).pop()?.node?.text; - let query = ``; - switch (cursorName) { - case 'key': - const cursorType = (0, TreeSitter_1.trueParent)(cursorNode).type; - // const cursorType = cursorText ? cursorNode.parent.type : cursorNode.parent.parent.type; - query = `(${cursorType} . (key) @key (#eq? @key "${cursorText}"))`; - break; - case 'value': - query = `(_ (value) @value (#eq? @value "${cursorText}"))`; - break; - case 'repo': - query = `(repo (key) @repo (#eq? @repo "${cursorText}"))`; - query += `(include (value (scopeName)? @_scopeName (#eq? @_scopeName "${rootScopeName}") (ruleName) @_ruleName (#eq? @_ruleName "${cursorText}")) @include)`; - break; - case 'self': - case 'rootScopeName': - query = `(json (scopeName (value) @scopeName))`; - query += `(include (value (scopeName) @_scopeName (#eq? @_scopeName "${rootScopeName}") !ruleName !base) @include)`; - query += `(include (value (self) !scopeName) @self)`; - break; - case 'base': - query = `(include (value (base)) @base)`; - break; - case 'scopeName': - const scopeName = cursorNode.childForFieldName('scopeName')?.text; - query = `(include (value (scopeName) @_scopeName (#eq? @_scopeName "${scopeName}") !ruleName !base) @include)`; - if (scopeName == rootScopeName) { - query += `(json (scopeName (value) @scopeName))`; - query += `(include (value (self) !scopeName) @self)`; - } - break; - case 'include': - const scopeName2 = cursorNode.childForFieldName('scopeName')?.text; - const ruleName = cursorNode.childForFieldName('ruleName')?.text; - if (!scopeName2 || scopeName2 == rootScopeName) { - query = `(include (value (scopeName)? @_scopeName (#eq? @_scopeName "${scopeName2 ?? rootScopeName}") (ruleName) @_ruleName (#eq? @_ruleName "${ruleName}")) @include)`; - query += `(repo (key) @repo (#eq? @repo "${ruleName}"))`; - } - else { - query = `(include (value (scopeName) @_scopeName (#eq? @_scopeName "${scopeName2}") (ruleName) @_ruleName (#eq? @_ruleName "${ruleName}")) @include)`; - } - break; - case 'scope': - query = `(name_scope (value (scope) @scope (#eq? @scope "${cursorText}")))`; - break; - default: - return; - } - const documentHighlights = []; - const queryCaptures = (0, TreeSitter_1.queryNode)(jsonTree.rootNode, query); - for (const queryCapture of queryCaptures) { - if (queryCapture.name.charAt(0) == '_') { - // Ignore internal use captures - continue; - } - const node = queryCapture.node; - const range = (0, TreeSitter_1.toRange)(node); - const documentHighlight = new vscode.DocumentHighlight(range, vscode.DocumentHighlightKind.Read); - documentHighlights.push(documentHighlight); - } - // vscode.window.showInformationMessage(JSON.stringify(documentHighlights)); - return documentHighlights; - } -}; - - -/***/ }), -/* 37 */ -/***/ ((__unused_webpack_module, exports, __webpack_require__) => { - -"use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.CompletionItemProvider = exports.triggerCharacters = void 0; -const vscode = __webpack_require__(1); -const TreeSitter_1 = __webpack_require__(2); -const triggerCharactersInclude = ['"', '#', '.', '$']; -const triggerCharactersRegex = ['\\', '(', '?', '<', '\'']; -exports.triggerCharacters = [].concat(triggerCharactersInclude, triggerCharactersRegex); -exports.CompletionItemProvider = { - async provideCompletionItems(document, position, token, context) { - // vscode.window.showInformationMessage(JSON.stringify("Completions")); - const trees = (0, TreeSitter_1.getTrees)(document); - const tree = trees.jsonTree; - const point = (0, TreeSitter_1.toPoint)(position); - const cursorQuery = ` - (include (value) @include) - ;(regex) @regex - `; - const cursorCapture = (0, TreeSitter_1.queryNode)(tree.rootNode, cursorQuery, point); - if (cursorCapture == null) { - return; - } - const cursorNode = cursorCapture.node; - const cursorRange = (0, TreeSitter_1.toRange)(cursorNode); - const completionItems = []; - switch (cursorCapture.name) { - case 'include': - if (context.triggerKind == vscode.CompletionTriggerKind.TriggerCharacter) { - if (triggerCharactersInclude.indexOf(context.triggerCharacter) == -1) { - return; - } - } - const rootPatternsQuery = `(json (patterns) @patterns)`; - const rootPatternsText = (0, TreeSitter_1.queryNode)(tree.rootNode, rootPatternsQuery).pop()?.node?.text; - const selfLabel = { - label: '$self', - description: 'Includes the current grammar file' - }; - const selfDocumentation = new vscode.MarkdownString(); - selfDocumentation.appendCodeblock(rootPatternsText, 'json-textmate'); - const selfCompletionItem = { - label: selfLabel, - range: cursorRange, - kind: vscode.CompletionItemKind.Class, - documentation: selfDocumentation - }; - completionItems.push(selfCompletionItem); - completionItems.push(new vscode.CompletionItem({ label: '$base', description: 'Includes the highest parent grammar' }, vscode.CompletionItemKind.Class)); - repoCompletionItems(completionItems, tree, cursorRange); - const cursorScopeName = cursorNode.childForFieldName('scopeName')?.text; - if (cursorScopeName) { - const rootScopeNameQuery = `(json (scopeName (value) @scopeName))`; - const rootScopeName = (0, TreeSitter_1.queryNode)(tree.rootNode, rootScopeNameQuery).pop()?.node?.text; - const rootScopeNameLabel = { - label: rootScopeName, - description: 'use $self instead' - }; - const rootScopeNameCompletionItem = { - label: rootScopeNameLabel, - range: cursorRange, - kind: vscode.CompletionItemKind.Field, - documentation: selfDocumentation, - commitCharacters: ['#'], - command: { command: 'editor.action.triggerSuggest', title: 'Trigger `source#include` completions' } - }; - completionItems.push(rootScopeNameCompletionItem); - if (rootScopeName == cursorScopeName) { - repoCompletionItems(completionItems, tree, cursorRange, rootScopeName); - } - } - for (const extension of vscode.extensions.all) { - const grammars = extension.packageJSON?.contributes?.grammars; - if (grammars) { - const cursorText = cursorNode.text; - for (const grammar of grammars) { - const grammarScopeName = grammar.scopeName; - if (grammarScopeName) { - const grammarDocumentation = new vscode.MarkdownString(); - if (cursorScopeName == grammarScopeName) { - const grammarUri = vscode.Uri.joinPath(extension.extensionUri, grammar.path); - const grammarDocument = await vscode.workspace.openTextDocument(grammarUri); - const grammarTree = (0, TreeSitter_1.getTree)(grammarDocument); - repoCompletionItems(completionItems, grammarTree, cursorRange, cursorScopeName); - if (cursorText == grammarScopeName) { - const grammarPatternsText = (0, TreeSitter_1.queryNode)(grammarTree.rootNode, rootPatternsQuery).pop()?.node?.text; - // grammarDocumentation.appendCodeblock(grammarPatternsText, 'json-textmate'); // if Word Wrap worked - let grammarDocText; - if (grammarDocument.lineCount == 1) { - try { - const parsedPatterns = JSON.parse('{' + grammarPatternsText + '}'); - grammarDocText = '"patterns": ' + JSON.stringify(parsedPatterns.patterns, null, 2).slice(0, 99900); - } - catch (error) { - grammarDocText = grammarPatternsText.slice(0, 1000); // How to enable Word Wrap? - } - } - else { - grammarDocText = grammarPatternsText.slice(0, 99900); - } - grammarDocumentation.appendCodeblock(grammarDocText, 'json-textmate'); // but no, it doesn't work.... - } - } - else { - grammarDocumentation.appendCodeblock(JSON.stringify(grammar, null, 2), 'json'); - } - const grammarLabel = { - label: grammarScopeName, - description: grammar.language - }; - const grammarCompletion = { - label: grammarLabel, - range: cursorRange, - kind: vscode.CompletionItemKind.Field, - documentation: grammarDocumentation, - commitCharacters: ['#'], - command: { command: 'editor.action.triggerSuggest', title: 'Trigger `source#include` completions' } - }; - completionItems.push(grammarCompletion); - } - } - } - } - break; - case 'regex': - if (context.triggerKind == vscode.CompletionTriggerKind.TriggerCharacter) { - if (triggerCharactersRegex.indexOf(context.triggerCharacter) == -1) { - return; - } - } - vscode.window.showInformationMessage(JSON.stringify(document.getText(new vscode.Range(position.line, position.character - 1, position.line, position.character)))); - const text = document.getText(new vscode.Range(position.line, position.character - 1, position.line, position.character)); - // switch (text) { - // case '\\': - const completionItemQuad = { - label: '\\\\\\\\', - kind: vscode.CompletionItemKind.Class - }; - completionItems.push(completionItemQuad); - const completionItemWhiteSpace = { - label: '\\\\s', - kind: vscode.CompletionItemKind.Class - }; - completionItems.push(completionItemWhiteSpace); - completionItems.push(new vscode.CompletionItem('\\\\w', vscode.CompletionItemKind.Class)); - // break; - // default: - // break; - // } - // const newPoint: Parser.Point = { - // row: point.row, - // column: point.column - 1 - // } - // const regexTrees = trees.regexTrees; - // const regexNode = regexTrees[cursorNode.id].rootNode; - // vscode.window.showInformationMessage("1" + JSON.stringify(regexNode.toString())); - // vscode.window.showInformationMessage("2" + JSON.stringify(regexNode.descendantForPosition(point).text)); - // vscode.window.showInformationMessage("3" + JSON.stringify(regexNode.descendantForPosition(newPoint).text)); - // vscode.window.showInformationMessage("4" + JSON.stringify(regexNode.descendantForPosition(point).toString())); - // vscode.window.showInformationMessage("5" + JSON.stringify(regexNode.descendantForPosition(newPoint).toString())); - // vscode.window.showInformationMessage("6" + JSON.stringify(context.triggerCharacter)); - // vscode.window.showInformationMessage("7" + JSON.stringify(queryNode(regexNode, `(_ _ @node)`, point).node.text)); - // vscode.window.showInformationMessage("8" + JSON.stringify(queryNode(regexNode, `(_ _ @node)`, newPoint).node.text)); - break; - default: - break; - } - const completionList = new vscode.CompletionList(completionItems); - // vscode.window.showInformationMessage(JSON.stringify(completionList)); - return completionList; - } -}; -function repoCompletionItems(completionItems, tree, cursorRange, scopeName) { - const rootNode = tree.rootNode; - const repoQuery = `(json (repository (repo (key) @rootRepo (.not-match? @rootRepo "^\\\\$(self|base)$"))))` + - (scopeName ? `` : - `(repo - [(patterns) (include)] (repository - (repo - (key) @nestRepo (.not-match? @nestRepo "^\\\\$(self|base)$"))) - !match !begin)`); - // const repoCaptures = queryNode(rootNode, repoQuery); - const repoCaptures = scopeName ? (0, TreeSitter_1.queryNode)(rootNode, repoQuery) : (0, TreeSitter_1.queryNode)(rootNode, repoQuery, (0, TreeSitter_1.toPoint)(cursorRange.start), (0, TreeSitter_1.toPoint)(cursorRange.end)); - for (const repoCapture of repoCaptures) { - const repoNode = repoCapture.node; - const repoText = repoNode.text; - const repoNodeParent = repoText ? repoNode.parent : repoNode.parent.parent; // Tree-sitter buggy on 0width nodes - const commentQuery = `(comment (value) @comment (.not-eq? @comment ""))` + - `(comment_slash (value) @comment (.not-eq? @comment ""))`; - const commentText = (0, TreeSitter_1.queryNode)(repoNodeParent, commentQuery)[0]?.node?.text?.replace(/\\(.)?/g, '$1'); - const repoLabel = { - label: (scopeName ?? '') + '#' + repoText, - description: commentText - }; - const repoNodeParentText = repoNodeParent.text; - let repoDocText; - if (rootNode.startPosition.row == rootNode.endPosition.row) { - try { - const repoParsed = JSON.parse('{' + repoNodeParentText + '}'); - repoDocText = `"${repoText}": ` + JSON.stringify(repoParsed[repoText], null, 2).slice(0, 99900); - } - catch (error) { - repoDocText = repoNodeParentText.slice(0, 1000); // How to enable Word Wrap? - } - } - else { - repoDocText = repoNodeParentText.slice(0, 99900); - } - const documentation = new vscode.MarkdownString(); - documentation.appendCodeblock(repoDocText, 'json-textmate'); - // documentation.appendCodeblock(parentRepoNodeText, 'json-textmate'); // if Word Wrap worked - const repoCompletionItem = { - label: repoLabel, - range: cursorRange, - kind: vscode.CompletionItemKind.Function, - documentation: documentation - // sortText: '~#' + repoText - }; - if (repoCapture.name == 'nestRepo') { - repoCompletionItem.sortText = ' #' + repoText; - } - completionItems.push(repoCompletionItem); - } -} - - -/***/ }), -/* 38 */ -/***/ ((__unused_webpack_module, exports, __webpack_require__) => { - -"use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.DocumentRangeFormattingEditProvider = exports.DocumentFormattingEditProvider = void 0; -const vscode = __webpack_require__(1); -const TreeSitter_1 = __webpack_require__(2); -exports.DocumentFormattingEditProvider = { - provideDocumentFormattingEdits(document, options, token) { - // vscode.window.showInformationMessage(JSON.stringify("Format")); - const tree = (0, TreeSitter_1.getTree)(document); - const textEdits = []; - const tabType = options.insertSpaces ? ' ' : '\t'; - const tabSize = options.insertSpaces ? options.tabSize : 1; - parseAllChildren(tree.rootNode, textEdits, 0, tabSize, tabType); - // vscode.window.showInformationMessage(JSON.stringify(textEdits)); - return textEdits; - }, -}; -exports.DocumentRangeFormattingEditProvider = { - provideDocumentRangeFormattingEdits(document, range, options, token) { - // vscode.window.showInformationMessage(JSON.stringify("FormatRange")); - const tree = (0, TreeSitter_1.getTree)(document); - const textEdits = []; - const tabType = options.insertSpaces ? ' ' : '\t'; - const tabSize = options.insertSpaces ? options.tabSize : 1; - const startPoint = (0, TreeSitter_1.toPoint)(range.start); - const endPoint = (0, TreeSitter_1.toPoint)(range.end); - const queryString = `(_) @node`; - const nestedCaptures = (0, TreeSitter_1.queryNode)(tree.rootNode, queryString, startPoint, endPoint); - let level = -1; - let node; - for (const nestedCapture of nestedCaptures) { - const nestedNode = nestedCapture.node; - if (!(0, TreeSitter_1.toRange)(nestedNode).contains(range)) { - break; - } - node = nestedNode; - level++; - } - const indent = Math.min(level, node.startPosition.column); - parseAllChildren(node, textEdits, indent, tabSize, tabType); - // vscode.window.showInformationMessage(JSON.stringify(textEdits)); - return textEdits; - }, -}; -function parseAllChildren(parentNode, textEdits, indent, tabSize, tabType) { - let range; - let whiteSpace; - let textEdit; - let expand = false; - for (const node of parentNode.namedChildren) { - if (parseAllChildren(node, textEdits, indent + tabSize, tabSize, tabType)) { - expand = true; - } - } - if (expand == false) { - const namedChildCount = parentNode.namedChildCount; - if (namedChildCount > 1) { - switch (parentNode.type) { - case 'value': - case 'regex': - break; - case 'repo': - case 'repository': - case 'injection': - expand = true; - break; - case 'patterns': - if (parentNode.parent.type == 'json') { - expand = true; - break; - } - default: - if (namedChildCount > 2) { - expand = true; - break; - } - if (parentNode.firstNamedChild.type != 'key') { - expand = true; - break; - } - if (parentNode.text.length > 2000) { - expand = true; - break; - } - } - } - } - for (const node of parentNode.children) { - switch (node.type) { - case '{': - case '[': - indent += tabSize; - if (node.nextSibling == null) - break; - if (expand == true) - whiteSpace = '\n'.padEnd(indent + 1, tabType); - else - whiteSpace = ' '; - range = new vscode.Range(node.endPosition.row, node.endPosition.column, node.nextSibling.startPosition.row, node.nextSibling.startPosition.column); - textEdit = vscode.TextEdit.replace(range, whiteSpace); - textEdits.push(textEdit); - break; - case '}': - case ']': - indent -= tabSize; - if (node.previousSibling == null) - break; - if (node.previousSibling.type == '{') - break; - if (node.previousSibling.type == '[') - break; - if (expand == true) - whiteSpace = '\n'.padEnd(indent + 1, tabType); - else - whiteSpace = ' '; - range = new vscode.Range(node.previousSibling.endPosition.row, node.previousSibling.endPosition.column, node.startPosition.row, node.startPosition.column); - textEdit = vscode.TextEdit.replace(range, whiteSpace); - textEdits.push(textEdit); - break; - case ',': - if (node.nextSibling == null) - break; - if (expand == true) - whiteSpace = '\n'.padEnd(indent + 1, tabType); - else - whiteSpace = ' '; - range = new vscode.Range(node.endPosition.row, node.endPosition.column, node.nextSibling.startPosition.row, node.nextSibling.startPosition.column); - textEdit = vscode.TextEdit.replace(range, whiteSpace); - textEdits.push(textEdit); - if (node.previousSibling == null) - break; - whiteSpace = ''; - range = new vscode.Range(node.previousSibling.endPosition.row, node.previousSibling.endPosition.column, node.startPosition.row, node.startPosition.column); - textEdit = vscode.TextEdit.replace(range, whiteSpace); - textEdits.push(textEdit); - break; - case ':': - if (node.nextSibling == null) - break; - whiteSpace = ' '; - range = new vscode.Range(node.endPosition.row, node.endPosition.column, node.nextSibling.startPosition.row, node.nextSibling.startPosition.column); - textEdit = vscode.TextEdit.replace(range, whiteSpace); - textEdits.push(textEdit); - if (node.previousSibling == null) - break; - whiteSpace = ''; - range = new vscode.Range(node.previousSibling.endPosition.row, node.previousSibling.endPosition.column, node.startPosition.row, node.startPosition.column); - textEdit = vscode.TextEdit.replace(range, whiteSpace); - textEdits.push(textEdit); - break; - } - } - return expand; -} - - -/***/ }) -/******/ ]); -/************************************************************************/ -/******/ // The module cache -/******/ var __webpack_module_cache__ = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ // Check if module is in cache -/******/ var cachedModule = __webpack_module_cache__[moduleId]; -/******/ if (cachedModule !== undefined) { -/******/ return cachedModule.exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = __webpack_module_cache__[moduleId] = { -/******/ // no module.id needed -/******/ // no module.loaded needed -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/************************************************************************/ -/******/ -/******/ // startup -/******/ // Load entry module and return exports -/******/ // This entry module is referenced by other modules so it can't be inlined -/******/ var __webpack_exports__ = __webpack_require__(0); -/******/ var __webpack_export_target__ = exports; -/******/ for(var i in __webpack_exports__) __webpack_export_target__[i] = __webpack_exports__[i]; -/******/ if(__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, "__esModule", { value: true }); -/******/ -/******/ })() -; -//# sourceMappingURL=extension.js.map \ No newline at end of file +(()=>{var __webpack_modules__={975:e=>{"use strict";function t(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function n(e,t){for(var n,r="",s=0,o=-1,a=0,i=0;i<=e.length;++i){if(i2){var l=r.lastIndexOf("/");if(l!==r.length-1){-1===l?(r="",s=0):s=(r=r.slice(0,l)).length-1-r.lastIndexOf("/"),o=i,a=0;continue}}else if(2===r.length||1===r.length){r="",s=0,o=i,a=0;continue}t&&(r.length>0?r+="/..":r="..",s=2)}else r.length>0?r+="/"+e.slice(o+1,i):r=e.slice(o+1,i),s=i-o-1;o=i,a=0}else 46===n&&-1!==a?++a:a=-1}return r}var r={resolve:function(){for(var e,r="",s=!1,o=arguments.length-1;o>=-1&&!s;o--){var a;o>=0?a=arguments[o]:(void 0===e&&(e=process.cwd()),a=e),t(a),0!==a.length&&(r=a+"/"+r,s=47===a.charCodeAt(0))}return r=n(r,!s),s?r.length>0?"/"+r:"/":r.length>0?r:"."},normalize:function(e){if(t(e),0===e.length)return".";var r=47===e.charCodeAt(0),s=47===e.charCodeAt(e.length-1);return 0!==(e=n(e,!r)).length||r||(e="."),e.length>0&&s&&(e+="/"),r?"/"+e:e},isAbsolute:function(e){return t(e),e.length>0&&47===e.charCodeAt(0)},join:function(){if(0===arguments.length)return".";for(var e,n=0;n0&&(void 0===e?e=s:e+="/"+s)}return void 0===e?".":r.normalize(e)},relative:function(e,n){if(t(e),t(n),e===n)return"";if((e=r.resolve(e))===(n=r.resolve(n)))return"";for(var s=1;sc){if(47===n.charCodeAt(i+_))return n.slice(i+_+1);if(0===_)return n.slice(i+_)}else a>c&&(47===e.charCodeAt(s+_)?u=_:0===_&&(u=0));break}var d=e.charCodeAt(s+_);if(d!==n.charCodeAt(i+_))break;47===d&&(u=_)}var m="";for(_=s+u+1;_<=o;++_)_!==o&&47!==e.charCodeAt(_)||(0===m.length?m+="..":m+="/..");return m.length>0?m+n.slice(i+u):(i+=u,47===n.charCodeAt(i)&&++i,n.slice(i))},_makeLong:function(e){return e},dirname:function(e){if(t(e),0===e.length)return".";for(var n=e.charCodeAt(0),r=47===n,s=-1,o=!0,a=e.length-1;a>=1;--a)if(47===(n=e.charCodeAt(a))){if(!o){s=a;break}}else o=!1;return-1===s?r?"/":".":r&&1===s?"//":e.slice(0,s)},basename:function(e,n){if(void 0!==n&&"string"!=typeof n)throw new TypeError('"ext" argument must be a string');t(e);var r,s=0,o=-1,a=!0;if(void 0!==n&&n.length>0&&n.length<=e.length){if(n.length===e.length&&n===e)return"";var i=n.length-1,l=-1;for(r=e.length-1;r>=0;--r){var c=e.charCodeAt(r);if(47===c){if(!a){s=r+1;break}}else-1===l&&(a=!1,l=r+1),i>=0&&(c===n.charCodeAt(i)?-1==--i&&(o=r):(i=-1,o=l))}return s===o?o=l:-1===o&&(o=e.length),e.slice(s,o)}for(r=e.length-1;r>=0;--r)if(47===e.charCodeAt(r)){if(!a){s=r+1;break}}else-1===o&&(a=!1,o=r+1);return-1===o?"":e.slice(s,o)},extname:function(e){t(e);for(var n=-1,r=0,s=-1,o=!0,a=0,i=e.length-1;i>=0;--i){var l=e.charCodeAt(i);if(47!==l)-1===s&&(o=!1,s=i+1),46===l?-1===n?n=i:1!==a&&(a=1):-1!==n&&(a=-1);else if(!o){r=i+1;break}}return-1===n||-1===s||0===a||1===a&&n===s-1&&n===r+1?"":e.slice(n,s)},format:function(e){if(null===e||"object"!=typeof e)throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return function(e,t){var n=t.dir||t.root,r=t.base||(t.name||"")+(t.ext||"");return n?n===t.root?n+r:n+"/"+r:r}(0,e)},parse:function(e){t(e);var n={root:"",dir:"",base:"",ext:"",name:""};if(0===e.length)return n;var r,s=e.charCodeAt(0),o=47===s;o?(n.root="/",r=1):r=0;for(var a=-1,i=0,l=-1,c=!0,u=e.length-1,_=0;u>=r;--u)if(47!==(s=e.charCodeAt(u)))-1===l&&(c=!1,l=u+1),46===s?-1===a?a=u:1!==_&&(_=1):-1!==a&&(_=-1);else if(!c){i=u+1;break}return-1===a||-1===l||0===_||1===_&&a===l-1&&a===i+1?-1!==l&&(n.base=n.name=0===i&&o?e.slice(1,l):e.slice(i,l)):(0===i&&o?(n.name=e.slice(1,a),n.base=e.slice(1,l)):(n.name=e.slice(i,a),n.base=e.slice(i,l)),n.ext=e.slice(a,l)),i>0?n.dir=e.slice(0,i-1):o&&(n.dir="/"),n},sep:"/",delimiter:":",win32:null,posix:null};r.posix=r,e.exports=r},510:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CallHierarchyProvider=void 0;const r=n(398),s=n(329),o=n(438);t.CallHierarchyProvider={prepareCallHierarchy(e,t,n){const a=e.uri,i=(0,s.getTrees)(a).jsonTree.rootNode,l=(0,s.toPoint)(t),c=(0,s.queryNode)(i,"(include (value !scopeName (ruleName) @include))",l),u=c?.node?.text,_=u?`\n\t\t\t(json (repository (repo (key) @repo (.eq? @repo "${u}"))))\n\t\t\t(repo\n\t\t\t\t[(patterns) (include)] (repository\n\t\t\t\t\t(repo\n\t\t\t\t\t\t(key) @repo (.eq? @repo "${u}")))\n\t\t\t\t!match !begin)\n\t\t`:"(repo (key) @repo)",d=(0,s.queryNode)(i,_,l,!1);if(!d)return;const m=d.node,p=(0,s.toRange)(m),h=(0,s.toRange)((0,s.trueParent)(m)),f=(0,s.getComment)(m),g=m.text,y=o.SymbolKind[d.name];return new r.CallHierarchyItem(y,g,f,a,h,p)},provideCallHierarchyIncomingCalls(e,t){const n=e.uri,a=(0,s.getTrees)(n).jsonTree.rootNode,i=[],l=`(include (value !scopeName (ruleName) @include (.eq? @include "${e.name}")))`,c=(0,s.queryNode)(a,l);for(const e of c){const t=e.node,l=(0,s.toRange)(t),c=(0,s.toRange)((0,s.trueParent)(t)),u="\n\t\t\t\t(json (scopeName (value) @scopeName))\n\t\t\t\t(repo (key) @repo)\n\t\t\t",_=(0,s.queryNode)(a,u,t.startPosition,!1).node,d=(0,s.getComment)(_),m=_.text,p=o.SymbolKind[e.name],h=new r.CallHierarchyItem(p,m,d,n,c,l),f=[c],g=new r.CallHierarchyIncomingCall(h,f);i.push(g)}return i},provideCallHierarchyOutgoingCalls(e,t){const n=e.uri,a=(0,s.getTrees)(n).jsonTree.rootNode,i=[],l=(0,s.toPoint)(e.range.start),c=(0,s.toPoint)(e.range.end),u=(0,s.queryNode)(a,"\n\t\t\t;(include (value) @include)\n\t\t\t(include (value !scopeName (ruleName) @include))\n\t\t",l,c);for(const e of u){const t=e.node,c=t.text,u=`\n\t\t\t\t(json (repository (repo (key) @repo (.eq? @repo "${c}"))))\n\t\t\t\t(repo\n\t\t\t\t\t[(patterns) (include)] (repository\n\t\t\t\t\t\t(repo\n\t\t\t\t\t\t\t(key) @repo (.eq? @repo "${c}")))\n\t\t\t\t\t!match !begin)\n\t\t\t`,_=(0,s.queryNode)(a,u,l,!1);if(!_)continue;const d=_.node,m=(0,s.toRange)(d),p=(0,s.toRange)((0,s.trueParent)(d)),h=d.text,f=(0,s.getComment)(d),g=o.SymbolKind[_.name],y=new r.CallHierarchyItem(g,h,f,n,p,m),b=[(0,s.toRange)((0,s.trueParent)(t))],w=new r.CallHierarchyOutgoingCall(y,b);i.push(w)}return i}}},238:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CompletionItemProvider=t.triggerCharacters=void 0;const r=n(398),s=n(329),o=['"',"#",".","$"],a=["\\","(","?","<","'"];function i(e,t,n,o){const a=t.rootNode,i='(json (repository (repo (key) @rootRepo (.not-match? @rootRepo "^\\\\$(self|base)$"))))'+(o?"":'(repo\n\t\t\t\t[(patterns) (include)] (repository\n\t\t\t\t\t(repo\n\t\t\t\t\t\t(key) @nestRepo (.not-match? @nestRepo "^\\\\$(self|base)$")))\n\t\t\t\t!match !begin)'),l=o?(0,s.queryNode)(a,i):(0,s.queryNode)(a,i,(0,s.toPoint)(n.start),(0,s.toPoint)(n.end));for(const t of l){const i=t.node,l=i.text,c=l?i.parent:i.parent.parent,u='(comment (value) @comment (.not-eq? @comment ""))(comment_slash (value) @comment (.not-eq? @comment ""))',_=(0,s.queryNode)(c,u)[0]?.node?.text?.replace(/\\(.)?/g,"$1"),d={label:(o??"")+"#"+l,description:_},m=c.text;let p;if(a.startPosition.row==a.endPosition.row)try{const e=JSON.parse("{"+m+"}");p=`"${l}": `+JSON.stringify(e[l],null,2).slice(0,99900)}catch(e){p=m.slice(0,1e3)}else p=m.slice(0,99900);const h=new r.MarkdownString;h.appendCodeblock(p,"json-textmate");const f={label:d,range:n,kind:r.CompletionItemKind.Function,documentation:h};"nestRepo"==t.name&&(f.sortText=" #"+l),e.push(f)}}t.triggerCharacters=[].concat(o,a),t.CompletionItemProvider={async provideCompletionItems(e,t,n,l){const c=(0,s.getTrees)(e).jsonTree,u=(0,s.toPoint)(t),_=(0,s.queryNode)(c.rootNode,"\n\t\t\t(include (value) @include)\n\t\t\t;(regex) @regex\n\t\t",u);if(null==_)return;const d=_.node,m=(0,s.toRange)(d),p=[];switch(_.name){case"include":if(l.triggerKind==r.CompletionTriggerKind.TriggerCharacter&&-1==o.indexOf(l.triggerCharacter))return;const n="(json (patterns) @patterns)",u=(0,s.queryNode)(c.rootNode,n).pop()?.node?.text,_={label:"$self",description:"Includes the current grammar file"},h=new r.MarkdownString;h.appendCodeblock(u,"json-textmate");const f={label:_,range:m,kind:r.CompletionItemKind.Class,documentation:h};p.push(f),p.push(new r.CompletionItem({label:"$base",description:"Includes the highest parent grammar"},r.CompletionItemKind.Class)),i(p,c,m);const g=d.childForFieldName("scopeName")?.text;if(g){const e="(json (scopeName (value) @scopeName))",t=(0,s.queryNode)(c.rootNode,e).pop()?.node?.text,n={label:{label:t,description:"use $self instead"},range:m,kind:r.CompletionItemKind.Field,documentation:h,commitCharacters:["#"],command:{command:"editor.action.triggerSuggest",title:"Trigger `source#include` completions"}};p.push(n),t==g&&i(p,c,m,t)}for(const e of r.extensions.all){const t=e.packageJSON?.contributes?.grammars;if(t){const o=d.text;for(const a of t){const t=a.scopeName;if(t){const l=new r.MarkdownString;if(g==t){const c=r.Uri.joinPath(e.extensionUri,a.path),u=await r.workspace.openTextDocument(c),_=(0,s.getTree)(u);if(i(p,_,m,g),o==t){const e=(0,s.queryNode)(_.rootNode,n).pop()?.node?.text;let t;if(1==u.lineCount)try{const n=JSON.parse("{"+e+"}");t='"patterns": '+JSON.stringify(n.patterns,null,2).slice(0,99900)}catch(n){t=e.slice(0,1e3)}else t=e.slice(0,99900);l.appendCodeblock(t,"json-textmate")}}else l.appendCodeblock(JSON.stringify(a,null,2),"json");const c={label:{label:t,description:a.language},range:m,kind:r.CompletionItemKind.Field,documentation:l,commitCharacters:["#"],command:{command:"editor.action.triggerSuggest",title:"Trigger `source#include` completions"}};p.push(c)}}}}break;case"regex":if(l.triggerKind==r.CompletionTriggerKind.TriggerCharacter&&-1==a.indexOf(l.triggerCharacter))return;r.window.showInformationMessage(JSON.stringify(e.getText(new r.Range(t.line,t.character-1,t.line,t.character)))),e.getText(new r.Range(t.line,t.character-1,t.line,t.character));const y={label:"\\\\\\\\",kind:r.CompletionItemKind.Class};p.push(y);const b={label:"\\\\s",kind:r.CompletionItemKind.Class};p.push(b),p.push(new r.CompletionItem("\\\\w",r.CompletionItemKind.Class))}return new r.CompletionList(p)}}},750:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefinitionProvider=void 0;const r=n(398),s=n(329),o=n(265);function a(e,t,n){const r=(0,s.getLastNode)(t.parent.parent.parent,n),o=e.regexTrees,a=o[r.childForFieldName("regex").id]?.rootNode,i=parseInt(t.text);if(0==i)return a;const l=(0,s.queryNode)(a,"\n\t\t(capture_group) @group\n\t\t(capture_group_extended) @group\n\t\t(capture_group_name) @name\n\t\t(capture_group_name_extended) @name\n\t");return l[i-1]?.node}t.DefinitionProvider={async provideDefinition(e,t,n){const i=(0,s.getTrees)(e),l=i.jsonTree,c=(0,s.toPoint)(t),u=(0,s.queryNode)(l.rootNode,"\n\t\t\t(json (scopeName (value) @scopeName))\n\t\t\t(repo (key) @repo)\n\t\t\t(include (value) @include)\n\t\t\t(captures (capture (key) @capture))\n\t\t\t(beginCaptures (capture (key) @beginCapture))\n\t\t\t(endCaptures (capture (key) @endCapture))\n\t\t\t(whileCaptures (capture (key) @whileCapture))\n\t\t\t;(match (regex) @regex)\n\t\t",c);if(null==u)return;const _=u.node,d=(0,s.toRange)(_);if(!d.contains(t))return;const m=_.text;let p;const h=[];switch(u.name){case"scopeName":for(const e of r.extensions.all){const t=e.packageJSON?.contributes?.grammars;if(t)for(const n of t)if(n.scopeName==m){const t=r.Uri.joinPath(e.extensionUri,"package.json");await r.workspace.openTextDocument(t)}}const n=r.Uri.joinPath(e.uri,"../../package.json");n&&await r.workspace.openTextDocument(n);for(const e of r.workspace.textDocuments)if(r.languages.match({pattern:"**/package.json"},e))try{const t=await JSON.parse(e.getText()),n=t?.contributes?.grammars;if(n)for(const t of n)if(t.scopeName==m){const t={originSelectionRange:d,targetUri:e.uri,targetRange:new r.Range(0,0,e.lineCount,1e3),targetSelectionRange:new r.Range(0,0,e.lineCount+1,0)};h.push(t)}}catch(e){}break;case"repo":if("$self"==m||"$base"==m)return;break;case"include":if(_.childForFieldName("base"))break;p="(json (scopeName (value) @scopeName))";const u=(0,s.queryNode)(l.rootNode,p).pop()?.node??null,f=u?.text??"",g=_.childForFieldName("scopeName")?.text??"",y=_.childForFieldName("ruleName")?.text??"";p="(json (patterns) @patterns)";const b=(0,s.queryNode)(l.rootNode,p).pop()?.node,w=(0,s.toRange)(b);if(_.childForFieldName("self")&&!g||g==f&&!y){if(null==b)break;const t=w.contains(d)?(0,s.toRange)(b.childForFieldName("key")):w,n={originSelectionRange:d,targetUri:e.uri,targetRange:w,targetSelectionRange:t};h.push(n);break}if(!g||g==f){p=`(repo\n\t\t\t\t\t\t\t\t\t\t[(patterns) (include)] (repository\n\t\t\t\t\t\t\t\t\t\t\t(repo\n\t\t\t\t\t\t\t\t\t\t\t\t(key) @repo (.eq? @repo "${y}")))\n\t\t\t\t\t\t\t\t\t\t!match !begin)`;const t=(0,s.queryNode)(l.rootNode,p,c,!1)?.node;if(t){const n={originSelectionRange:d,targetUri:e.uri,targetRange:(0,s.toRange)(t.parent),targetSelectionRange:(0,s.toRange)(t)};h.push(n);break}p=`(json (repository (repo (key) @repo (.eq? @repo "${y}"))))`;const n=(0,s.queryNode)(l.rootNode,p).pop()?.node;if(n){const t={originSelectionRange:d,targetUri:e.uri,targetRange:(0,s.toRange)(n.parent),targetSelectionRange:(0,s.toRange)(n)};h.push(t)}break}for(const e of r.extensions.all){const t=e.packageJSON?.contributes?.grammars;if(t)for(const n of t)if(n.scopeName==g){const t=r.Uri.joinPath(e.extensionUri,n.path),s=await r.workspace.openTextDocument(t);r.languages.setTextDocumentLanguage(s,"json-textmate")}}for(const e of r.workspace.textDocuments){if(!r.languages.match(o.DocumentSelector,e))continue;const t=(0,s.getTree)(e);p=`(json (scopeName (value) @scopeName (.eq? @scopeName "${g}")))`;const n=(0,s.queryNode)(t.rootNode,p).pop()?.node;if(n)if(y){p=`(json (repository (repo (key) @repo (.eq? @repo "${y}"))))`;const n=(0,s.queryNode)(t.rootNode,p).pop()?.node;if(n){const t={originSelectionRange:d,targetUri:e.uri,targetRange:(0,s.toRange)(n.parent),targetSelectionRange:(0,s.toRange)(n)};h.push(t)}}else{p="(json (patterns) @patterns)";const r=(0,s.queryNode)(t.rootNode,p).pop()?.node,o={originSelectionRange:d,targetUri:e.uri,targetRange:(0,s.toRange)(r),targetSelectionRange:(0,s.toRange)(n)};h.push(o)}}break;case"capture":const S=_.parent.parent.parent;if(S.childForFieldName("match")){const t=a(i,_,"match"),n=(0,s.toRange)(t),r={originSelectionRange:d,targetUri:e.uri,targetRange:n,targetSelectionRange:n};h.push(r);break}if(!S.childForFieldName("begin"))break;if(!(0,s.getLastNode)(S,"beginCaptures")){const t=a(i,_,"begin");if(t){const n=(0,s.toRange)(t),r={originSelectionRange:d,targetUri:e.uri,targetRange:n,targetSelectionRange:n};h.push(r)}}if(S.childForFieldName("while")){if(!S.childForFieldName("whileCaptures")){const t=a(i,_,"while");if(t){const n=(0,s.toRange)(t),r={originSelectionRange:d,targetUri:e.uri,targetRange:n,targetSelectionRange:n};h.push(r)}}break}if(!S.childForFieldName("endCaptures")){const t=a(i,_,"end");if(t){const n=(0,s.toRange)(t),r={originSelectionRange:d,targetUri:e.uri,targetRange:n,targetSelectionRange:n};h.push(r)}}break;case"beginCapture":const E=(0,s.toRange)(a(i,_,"begin")),N={originSelectionRange:d,targetUri:e.uri,targetRange:E,targetSelectionRange:E};h.push(N);break;case"endCapture":const I=(0,s.toRange)(a(i,_,"end")),M={originSelectionRange:d,targetUri:e.uri,targetRange:I,targetSelectionRange:I};h.push(M);break;case"whileCapture":const v=(0,s.toRange)(a(i,_,"while")),R={originSelectionRange:d,targetUri:e.uri,targetRange:v,targetSelectionRange:v};h.push(R);break;case"regex":const T=function(e,t,n){const o=e.regexTrees,a=o[t.id]?.rootNode;let i;const l=(0,s.queryNode)(a,"\n\t\t(capture_group) @group\n\t\t(capture_group_extended) @group\n\t\t(capture_group_name) @name\n\t\t(capture_group_name_extended) @name\n\t");let c=l.length;for(;l.length;){const e=l.pop().node;if((0,s.toRange)(e).contains(n)){i=e;break}c--}if(r.window.showInformationMessage(JSON.stringify(c)),!i)return;const u={row:n.line,column:n.character-1},_={row:n.line,column:n.character+1},d=(0,s.queryNode)(i,'\n\t\t"(" @open\n\t\t")" @close\n\t\t"(?<" @open\n\t\t"(?\'" @open\n\t\t">" @close\n\t\t"\'" @close\n\t\t(name) @name\n\t',u,_).pop()?.node;if(!d)return;const m=`\n\t\t;(regex (subroutine (number)) @subroutine)\n\t\t(regex (subroutine (number)) @subroutine (#eq? @subroutine "\\\\\\\\g<${c}>"))\n\t`,p=(0,s.queryNode)(a,m);return r.window.showInformationMessage(JSON.stringify(a.toString())),r.window.showInformationMessage(JSON.stringify(p)),{range:(0,s.toRange)(i),captures:p}}(i,_,t);if(!T)return;for(const t of T.captures){const n=(0,s.toRange)(t.node),r={originSelectionRange:T.range,targetUri:e.uri,targetRange:n,targetSelectionRange:n};h.push(r)}return h;default:return}if(0==h.length){const t=(0,s.toRange)(_.parent),n={originSelectionRange:d,targetUri:e.uri,targetRange:t};h.push(n)}return h}}},881:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.initDiagnostics=void 0;const r=n(398),s=n(486),o=n(329),a=n(265);function i(e,t){if(!r.languages.match(a.DocumentSelector,e))return;const n=[];{const t=(0,o.getTrees)(e),a=t.regexTrees,i=t.regexNodes;for(const e in a){const t=a[e].rootNode,c=t.text,u=i[t.id].previousNamedSibling;let _=c.replace(/\\[\\\/bfnrt"]|\\u[0-9a-fA-F]{4}/g,l);"end"!=u.text&&"while"!=u.text||(_=_.replace(/\\[1-9](\d{2})?(?!\d)/g,"\\0"));const d=new s.OnigScanner([_])._onigBinding,m=d.UTF8ToString(d._getLastOnigError());if("undefined error code"!=m){const e={range:(0,o.toRange)(u),message:m,severity:r.DiagnosticSeverity.Error,source:"Oniguruma"};n.push(e)}}}t.set(e.uri,n)}function l(e,...t){switch(e.charAt(1)){case"\\":return"\\";case"/":return"/";case"b":return"\b";case"f":return"\f";case"n":return"\n";case"r":return"\r";case"t":return"\t";case'"':return'"';case"u":const t=e.substring(2,6),n=parseInt(t,16);return String.fromCodePoint(n)}}t.initDiagnostics=function(e){const t=r.languages.createDiagnosticCollection("textmate");e.subscriptions.push(t);for(const e of r.window.visibleTextEditors)i(e.document,t);e.subscriptions.push(r.workspace.onDidOpenTextDocument((e=>{i(e,t)}))),e.subscriptions.push(r.workspace.onDidChangeTextDocument((e=>{i(e.document,t)}))),e.subscriptions.push(r.workspace.onDidCloseTextDocument((e=>{t.delete(e.uri)})))}},333:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DocumentRangeFormattingEditProvider=t.DocumentFormattingEditProvider=void 0;const r=n(398),s=n(329);function o(e,t,n,s,a){let i,l,c,u=!1;for(const r of e.namedChildren)o(r,t,n+s,s,a)&&(u=!0);if(0==u){const t=e.namedChildCount;if(t>1)switch(e.type){case"value":case"regex":break;case"repo":case"repository":case"injection":u=!0;break;case"patterns":if("json"==e.parent.type){u=!0;break}default:if(t>2){u=!0;break}if("key"!=e.firstNamedChild.type){u=!0;break}if(e.text.length>2e3){u=!0;break}}}for(const o of e.children)switch(o.type){case"{":case"[":if(n+=s,null==o.nextSibling)break;l=1==u?"\n".padEnd(n+1,a):" ",i=new r.Range(o.endPosition.row,o.endPosition.column,o.nextSibling.startPosition.row,o.nextSibling.startPosition.column),c=r.TextEdit.replace(i,l),t.push(c);break;case"}":case"]":if(n-=s,null==o.previousSibling)break;if("{"==o.previousSibling.type)break;if("["==o.previousSibling.type)break;l=1==u?"\n".padEnd(n+1,a):" ",i=new r.Range(o.previousSibling.endPosition.row,o.previousSibling.endPosition.column,o.startPosition.row,o.startPosition.column),c=r.TextEdit.replace(i,l),t.push(c);break;case",":if(null==o.nextSibling)break;if(l=1==u?"\n".padEnd(n+1,a):" ",i=new r.Range(o.endPosition.row,o.endPosition.column,o.nextSibling.startPosition.row,o.nextSibling.startPosition.column),c=r.TextEdit.replace(i,l),t.push(c),null==o.previousSibling)break;l="",i=new r.Range(o.previousSibling.endPosition.row,o.previousSibling.endPosition.column,o.startPosition.row,o.startPosition.column),c=r.TextEdit.replace(i,l),t.push(c);break;case":":if(null==o.nextSibling)break;if(l=" ",i=new r.Range(o.endPosition.row,o.endPosition.column,o.nextSibling.startPosition.row,o.nextSibling.startPosition.column),c=r.TextEdit.replace(i,l),t.push(c),null==o.previousSibling)break;l="",i=new r.Range(o.previousSibling.endPosition.row,o.previousSibling.endPosition.column,o.startPosition.row,o.startPosition.column),c=r.TextEdit.replace(i,l),t.push(c)}return u}t.DocumentFormattingEditProvider={provideDocumentFormattingEdits(e,t,n){const r=(0,s.getTree)(e),a=[],i=t.insertSpaces?" ":"\t",l=t.insertSpaces?t.tabSize:1;return o(r.rootNode,a,0,l,i),a}},t.DocumentRangeFormattingEditProvider={provideDocumentRangeFormattingEdits(e,t,n,r){const a=(0,s.getTree)(e),i=[],l=n.insertSpaces?" ":"\t",c=n.insertSpaces?n.tabSize:1,u=(0,s.toPoint)(t.start),_=(0,s.toPoint)(t.end),d=(0,s.queryNode)(a.rootNode,"(_) @node",u,_);let m,p=-1;for(const e of d){const n=e.node;if(!(0,s.toRange)(n).contains(t))break;m=n,p++}return o(m,i,Math.min(p,m.startPosition.column),c,l),i}}},514:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DocumentHighlightProvider=void 0;const r=n(398),s=n(329);t.DocumentHighlightProvider={provideDocumentHighlights(e,t,n){const o=(0,s.getTrees)(e).jsonTree,a=(0,s.toPoint)(t),i=(0,s.queryNode)(o.rootNode,"\n\t\t\t(key) @key\n\t\t\t(value !scopeName !ruleName !self !base) @value\n\t\t\t(capture . (key) @key)\n\t\t\t(repo . (key) @repo)\n\t\t\t(json (scopeName (value) @rootScopeName))\n\t\t\t(include (value (scopeName) !ruleName !base) @scopeName)\n\t\t\t(include (value (ruleName)) @include)\n\t\t\t(include (value !scopeName (self) @self))\n\t\t\t(include (value (base) @base))\n\t\t\t(name_scope (value (scope) @scope))\n\t\t",a);if(!i)return;const l=i.name,c=i.node,u=c.text,_=(0,s.queryNode)(o.rootNode,"(json (scopeName (value) @scopeName))").pop()?.node?.text;let d="";switch(l){case"key":d=`(${(0,s.trueParent)(c).type} . (key) @key (#eq? @key "${u}"))`;break;case"value":d=`(_ (value) @value (#eq? @value "${u}"))`;break;case"repo":d=`(repo (key) @repo (#eq? @repo "${u}"))`,d+=`(include (value (scopeName)? @_scopeName (#eq? @_scopeName "${_}") (ruleName) @_ruleName (#eq? @_ruleName "${u}")) @include)`;break;case"self":case"rootScopeName":d="(json (scopeName (value) @scopeName))",d+=`(include (value (scopeName) @_scopeName (#eq? @_scopeName "${_}") !ruleName !base) @include)`,d+="(include (value (self) !scopeName) @self)";break;case"base":d="(include (value (base)) @base)";break;case"scopeName":const e=c.childForFieldName("scopeName")?.text;d=`(include (value (scopeName) @_scopeName (#eq? @_scopeName "${e}") !ruleName !base) @include)`,e==_&&(d+="(json (scopeName (value) @scopeName))",d+="(include (value (self) !scopeName) @self)");break;case"include":const t=c.childForFieldName("scopeName")?.text,n=c.childForFieldName("ruleName")?.text;t&&t!=_?d=`(include (value (scopeName) @_scopeName (#eq? @_scopeName "${t}") (ruleName) @_ruleName (#eq? @_ruleName "${n}")) @include)`:(d=`(include (value (scopeName)? @_scopeName (#eq? @_scopeName "${t??_}") (ruleName) @_ruleName (#eq? @_ruleName "${n}")) @include)`,d+=`(repo (key) @repo (#eq? @repo "${n}"))`);break;case"scope":d=`(name_scope (value (scope) @scope (#eq? @scope "${u}")))`;break;default:return}const m=[],p=(0,s.queryNode)(o.rootNode,d);for(const e of p){if("_"==e.name.charAt(0))continue;const t=e.node,n=(0,s.toRange)(t),o=new r.DocumentHighlight(n,r.DocumentHighlightKind.Read);m.push(o)}return m}}},438:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DocumentSymbolProvider=t.SymbolKind=void 0;const r=n(398),s=n(329);function o(e){let n;switch(e.type){case"pattern":case"injection":let t=0,r=e;for(;r=r.previousNamedSibling;)t++;n=t.toString();break;case"repo":case"capture":n=e.firstNamedChild.text;break;case"name_scope":n="name";break;case"value":n=e.text}const o=n?.slice(0,50)||e.type,a=e.text.slice(0,50),i=t.SymbolKind[e.type]??(e.isNamed()?r.SymbolKind.Method:r.SymbolKind.Field),l=(0,s.toRange)(e),c=l;return new r.DocumentSymbol(o,a,i,l,c)}t.SymbolKind={json:r.SymbolKind.File,patterns:r.SymbolKind.Array,pattern:r.SymbolKind.Number,repository:r.SymbolKind.Object,repo:r.SymbolKind.Function,captures:r.SymbolKind.Field,beginCaptures:r.SymbolKind.Field,endCaptures:r.SymbolKind.Field,capture:r.SymbolKind.Number,match:r.SymbolKind.String,begin:r.SymbolKind.String,end:r.SymbolKind.String,while:r.SymbolKind.String,scopeName:r.SymbolKind.String,name_scope:r.SymbolKind.String,name:r.SymbolKind.String,version:r.SymbolKind.String,schema:r.SymbolKind.String,fileTypes:r.SymbolKind.String,firstLineMatch:r.SymbolKind.String,foldingStartMarker:r.SymbolKind.String,foldingStopMarker:r.SymbolKind.String,uuid:r.SymbolKind.Number,injectionSelector:r.SymbolKind.String,injections:r.SymbolKind.Object,injection:r.SymbolKind.Number,include:r.SymbolKind.Variable,comment:r.SymbolKind.String,comment_slash:r.SymbolKind.String,object:r.SymbolKind.Object,array:r.SymbolKind.Array,item:r.SymbolKind.String,value:r.SymbolKind.Key,key:r.SymbolKind.Property,boolean:r.SymbolKind.Boolean,null:r.SymbolKind.Null,integer:r.SymbolKind.Number,string:r.SymbolKind.String,regex:r.SymbolKind.Event,"{":r.SymbolKind.Object,"}":r.SymbolKind.Object,"[":r.SymbolKind.Array,"]":r.SymbolKind.Array,",":r.SymbolKind.Property,":":r.SymbolKind.Property,'"':r.SymbolKind.Property,literal:r.SymbolKind.String,backslash:r.SymbolKind.Property},t.DocumentSymbolProvider={provideDocumentSymbols(e,t){const n=(0,s.getTrees)(e);let r=n.jsonTree.rootNode,a=0,i=o(r);const l=[],c=[],u=[];for(;;){let e=r.namedChild(a);if(e)"regex"==e.type&&(e=(0,s.getRegexNode)(n,e)??e),e.namedChildCount&&c.length<900?(l.push(r),c.push(a),u.push(i),i=o(e),r=e,a=0):(i.children.push(o(e)),a++);else{if(r=l.pop(),void 0===r)break;a=c.pop(),a++;const e=u.pop();e.children.push(i),i=e}}return[i]}}},824:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReferenceProvider=void 0;const r=n(398),s=n(329);t.ReferenceProvider={provideReferences(e,t,n,o){const a=(0,s.getTree)(e),i=(0,s.toPoint)(t);let l;l="\n\t\t\t;(json (scopeName (value) @scopeName))\n\t\t\t(include (value) @include)\n\t\t\t(repo (key) @repo)\n\t\t";const c=(0,s.queryNode)(a.rootNode,l,i);if(null==c)return;const u=c.node,_=u.text;l="(json (scopeName (value) @scopeName))";const d=(0,s.queryForPosition)(a,l)?.node?.text;switch(c.name){case"repo":if("$self"==_||"$base"==_)return;l=`(include (value) @include (#eq? @include "#${_}"))(repo (key) @repo (#eq? @repo "${_}"))`,d&&_&&(l+=`(include (value) @include (#eq? @include "${d}#${_}"))`);break;case"include":if(""==_)return;if(u.childForFieldName("base"))l='(include (value) @include (#match? @include "^([^#]*#)?\\\\$base$"))';else{const e=u.childForFieldName("scopeName")?.text,t=u.childForFieldName("ruleName")?.text;e&&e!=d?l=t?`(include (value) @include (#eq? @include "${e}#${t}"))`:`(include (value) @include (#eq? @include "${e}"))(include (value) @include (#eq? @include "${e}#"))(include (value) @include (#eq? @include "${e}#$self"))`:u.childForFieldName("self")||e&&!t?(l='(include (value) @include (#match? @include "^#?\\\\$self$"))',d&&(l+=`(include (value) @include (#eq? @include "${d}"))(include (value) @include (#eq? @include "${d}#"))(include (value) @include (#eq? @include "${d}#$self"))`)):(l=`(include (value) @include (#eq? @include "#${t}"))(repo (key) @repo (#eq? @repo "${t}"))`,t&&(l+=`(include (value) @include (#eq? @include "${d}#${t}"))`))}break;default:return}const m=a.getLanguage().query(l).captures(a.rootNode),p=[],h=e.uri;for(const e of m)if("include"==e.name){const t=(0,s.toRange)(e.node),n=new r.Location(h,t);p.push(n)}if(0==p.length||"include"==c.name&&p.length<=1)for(const e of m)if("repo"==e.name){const t=(0,s.toRange)(e.node),n=new r.Location(h,t);p.push(n)}return p}}},461:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RenameProvider=void 0;const r=n(398),s=n(329),o="\n\t(include (value (scopeName) @scopeName))\n\t(include (value (ruleName) @ruleName))\n\t;(json (scopeName (value) @root_scopeName))\n\t(repo (key) @repo)\n";t.RenameProvider={provideRenameEdits(e,t,n,a){const i=(0,s.getTrees)(e).jsonTree,l=(0,s.toPoint)(t),c=(0,s.queryNode)(i.rootNode,o,l);if(!c)return;const u=c.name,_=c.node,d=_.text,m=(0,s.toRange)(_),p=(0,s.queryNode)(i.rootNode,"(json (scopeName (value) @scopeName))").pop()?.node?.text,h=[],f=new r.WorkspaceEdit,g=e.uri;let y="";switch(u){case"ruleName":y+=`(repo (key) @repo (#eq? @repo "${d}"))`,y+=`(include (value (ruleName) @ruleName) @include (#eq? @include "#${d}"))`,p&&(y+=`(include (value (ruleName) @ruleName) @include (#eq? @include "${p}#${d}"))`);break;case"scopeName":y+=`(include (value (scopeName) @scopeName (#eq? @scopeName "${d}")))`,y+=`(json (scopeName (value) @scopeName (#eq? @scopeName "${d}")))`;break;case"repo":y+=`(include (value (ruleName) @ruleName) @include (#eq? @include "#${d}"))`,p&&(y+=`(include (value (ruleName) @ruleName) @include (#eq? @include "${p}#${d}"))`);const e=new r.TextEdit(m,n);h.push(e);break;default:return}const b=(0,s.queryNode)(i.rootNode,y);for(const e of b){if("include"==e.name)continue;const t=e.node,o=(0,s.toRange)(t),a=new r.TextEdit(o,n);h.push(a)}return f.set(g,h),f},prepareRename(e,t,n){const r=(0,s.getTrees)(e).jsonTree,a=(0,s.toPoint)(t),i=(0,s.queryNode)(r.rootNode,o,a);if(!i)return Promise.reject("Item not renamable");const l=i.node,c=l.text;return{range:(0,s.toRange)(l),placeholder:c}}}},628:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tokenizeFile=t.tokenizeLine=t.initTextMate=t.whileRuleId=t.endRuleId=void 0;const r=n(398),s=n(454),o=n(486),a=n(265);async function i(){return{createOnigScanner:e=>new o.OnigScanner(e),createOnigString:e=>new o.OnigString(e)}}async function l(e){for(const t of r.extensions.all){const n=t.packageJSON,o=n.contributes?.grammars;if(o)for(const n of o)if(n.scopeName==e){const e=n.path;if(e){const n=r.Uri.joinPath(t.extensionUri,e);if("untitled"!=n.scheme){const e=await r.workspace.openTextDocument(n);return s.parseRawGrammar(e.getText(),n.path)}}}}return r.window.showInformationMessage(`Unknown scopeName: ${e}`),console.log(`TextMate: Unknown scope name: ${e}`),null}let c;function u(e){for(const t of r.extensions.all){const n=t.packageJSON,r=n.contributes?.grammars;if(r)for(const t of r)if(t.language==e){const e=t.scopeName;if(e)return e}}return null}t.endRuleId=-1,t.whileRuleId=-2,t.initTextMate=function(e){const t={onigLib:i(),loadGrammar:l};c=new s.Registry(t)},t.tokenizeLine=async function(e,t){const n=u(e.languageId),r=await c.loadGrammar(n);let o,a=s.INITIAL;for(let n=0;n<=t;n++){const t=e.lineAt(n).text,s=r.tokenizeLine(t,a,15e3);a=s.ruleStack,o=s}return o},t.tokenizeFile=async function(e){const t=u(e.languageId),n=await c.loadGrammar(t);n.rules=[];let o=s.INITIAL;for(let t=0;t{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.initCallStackView=t.TreeDataProvider=void 0;const r=n(398),s=n(975),o=n(628),a=(n(265),n(329));let i;const l=s.join("/","..","assets","TextMate-file-icon.svg"),c=new r.EventEmitter;let u;async function _(e,t,...n){const s=e.document,a=(e.selection.active,await(0,o.tokenizeFile)(s),r.window.activeTextEditor);a&&(await u.reveal({document:a.document,id:-2},{expand:!0,focus:!1,select:!1}),await u.reveal({document:a.document,id:-1},{expand:2,focus:!0,select:!0}),u.badge={tooltip:"tooltip badge 56: is there any use for this number?",value:56},u.title="new title")}function d(...e){const t=e[0];t&&c.fire({document:t.document,id:-2}),c.fire(void 0)}async function m(...e){const t=e[0];if(!t)return;const n=t.id,s=t.document;if(-2==n)return void r.window.showTextDocument(s);if(-1==n){const e=s.languageId;for(const t of r.extensions.all){const n=t.packageJSON,s=n.contributes?.grammars;if(s)for(const n of s)if(n.language==e){const e=n.path;if(e){const n=r.Uri.joinPath(t.extensionUri,e);return void r.window.showTextDocument(n)}}}}const o=t.ruleId;if(!o)return;const l=p(i._grammar,o);r.window.showInformationMessage(JSON.stringify(l));const c=await async function(e){const t=e.languageId;for(const e of r.extensions.all){const n=e.packageJSON,s=n.contributes?.grammars;if(s)for(const n of s)if(n.language==t){const t=n.path;if(t){const n=r.Uri.joinPath(e.extensionUri,t),s=await r.workspace.openTextDocument(n);if(s)return s}}}}(s);let u=(0,a.getTrees)(c).jsonTree.rootNode;for(const e of l){const t=e.repository;if(null!=t){for(const e of u.namedChildren)if("repository"==e.type){u=e;break}for(const e of u.namedChildren)if(e.firstNamedChild?.text==t){u=e;break}continue}const n=e.patterns;if(null==n){if(null!=e.id)break}else{for(const e of u.namedChildren)if("patterns"==e.type){u=e;break}u=u.namedChild(n+1)}}const _=(0,a.toRange)(u),d=c.uri,m=[new r.Location(d,_)];r.commands.executeCommand("editor.action.goToLocations",d,_.start,m)}function p(e,t){for(const n in e)switch(n){case"patterns":const r=e[n];for(let e=0;ee,onDidChangeTreeData:c.event},t.initCallStackView=function(e){e.subscriptions.push(r.commands.registerTextEditorCommand("textmate.callstack",_)),e.subscriptions.push(r.commands.registerCommand("textmate.refresh",d)),e.subscriptions.push(r.commands.registerCommand("textmate.goto",m));const n={treeDataProvider:t.TreeDataProvider,canSelectMany:!1,showCollapseAll:!0,manageCheckboxStateManually:!1};u=r.window.createTreeView("TextMate",n)}},329:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.initTreeSitter=t.trueParent=t.toPoint=t.toRange=t.queryForPosition=t.queryNode=t.getLastNode=t.getComment=t.getRegexNode=t.getTree=t.getTrees=void 0;const r=n(398),s=n(812),o=n(265),a={};function i(e,t,n,s){const o=e.tree.getLanguage().query(t).captures(e,n,s||n);if(o.length>1e4&&r.window.showWarningMessage("Unoptimized Query: "+o.length+" results returned:\n"+t),n&&!s){if(!1===s)return o.pop();const e=new r.Position(n.row,n.column);for(;o.length;){const t=o.pop();if(l(t.node).contains(e))return t}return null}return o}function l(e){if(!e)return null;const t=e.startPosition,n=e.endPosition;return new r.Range(t.row,t.column,n.row,n.column)}function c(e){return{row:e.line,column:e.character}}function u(e){const t=e.parent;return null==t?e:""!=e.text?t:t.parent}function _(e,t,n){if(!r.languages.match(o.DocumentSelector,e))return;const s=e.uri.toString();if(s in a)return console.log("JSON TextMate: Why are we here?"),void r.window.showInformationMessage("JSON TextMate: Why are we here?");const l=e.getText(),c=t.parse(l),u=i(c.rootNode,"(regex) @regex"),_={},d={};for(const e of u){const t=e.node,r={includedRanges:[{startPosition:t.startPosition,endPosition:t.endPosition,startIndex:t.startIndex,endIndex:t.endIndex}]},s=n.parse(l,null,r);_[t.id]=s,d[s.rootNode.id]=t}a[s]={jsonTree:c,regexTrees:_,regexNodes:d}}t.getTrees=function(e){const t="uri"in e?e.uri.toString():e.toString();return a[t]},t.getTree=function(e){const t=e.uri.toString(),n=a[t]?.jsonTree;return n},t.getRegexNode=function(e,t){const n="number"==typeof t?t:t.id;if("uri"in e){const t=e.uri.toString(),r=a[t]?.regexTrees;return r[n].rootNode}if("scheme"in e){const t=e.toString(),r=a[t]?.regexTrees;return r[n].rootNode}return"regexTrees"in e?e.regexTrees[n].rootNode:e[n].rootNode},t.getComment=function(e){const t=i(u(e),'\n\t\t(comment (value) @comment (.not-eq? @comment ""))\n\t\t(comment_slash (value) @comment (.not-eq? @comment ""))\n\t')[0];return t?.node?.text?.replace(/\\(.)?/g,"$1")},t.getLastNode=function(e,t){const n=e.namedChildren;for(;n.length;){const e=n.pop();if(e.type==t)return e}},t.queryNode=i,t.queryForPosition=function(e,t,n){return e.getLanguage().query(t).captures(e.rootNode,n,n).pop()},t.toRange=l,t.toPoint=c,t.trueParent=u,t.initTreeSitter=async function(e){const t="undefined"==typeof navigator?void 0:{locateFile:()=>r.Uri.joinPath(e.extensionUri,"node_modules","web-tree-sitter","tree-sitter.wasm").toString(!0)};await s.init(t);const n=new s,l=r.Uri.joinPath(e.extensionUri,"out","tree-sitter-jsontm.wasm"),u="file"===l.scheme?l.fsPath:l.toString(!0),d=await s.Language.load(u);n.setLanguage(d);const m=new s,p=r.Uri.joinPath(e.extensionUri,"out","tree-sitter-regextm.wasm"),h="file"===p.scheme?p.fsPath:p.toString(!0),f=await s.Language.load(h);m.setLanguage(f),r.window.visibleTextEditors.forEach((e=>{_(e.document,n,m)})),e.subscriptions.push(r.workspace.onDidOpenTextDocument((e=>{_(e,n,m)}))),e.subscriptions.push(r.workspace.onDidChangeTextDocument((e=>{!function(e,t,n){const s=e.document;if(!r.languages.match(o.DocumentSelector,s))return;const l=s.uri.toString();if(!(l in a))return;const u=a[l].jsonTree,_=s.getText();for(const t of e.contentChanges){const e=t.rangeOffset,n=t.rangeOffset+t.rangeLength,r=t.rangeOffset+t.text.length,o=s.positionAt(e),a=s.positionAt(n),i=s.positionAt(r),l={startIndex:e,oldEndIndex:n,newEndIndex:r,startPosition:c(o),oldEndPosition:c(a),newEndPosition:c(i)};u.edit(l)}const d=t.parse(_,u),m=i(d.rootNode,"(regex) @regex"),p={},h={};for(const e of m){const t=e.node,r={includedRanges:[{startPosition:t.startPosition,endPosition:t.endPosition,startIndex:t.startIndex,endIndex:t.endIndex}]},s=n.parse(_,u,r);p[t.id]=s,h[s.rootNode.id]=t}a[l]={jsonTree:d,regexTrees:p,regexNodes:h}}(e,n,m)}))),e.subscriptions.push(r.workspace.onDidCloseTextDocument((e=>{const t=e.uri.toString();delete a[t]})))}},265:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stringify=t.deactivate=t.activate=t.DocumentSelector=void 0;const r=n(398),s=n(329),o=n(211),a=n(628),i=n(881),l=n(104),c=n(763),u=n(461),_=n(824),d=n(750),m=n(510),p=n(438),h=n(514),f=n(238),g=n(333);t.DocumentSelector=[{language:"json-textmate"}],t.activate=async function(e){await(0,s.initTreeSitter)(e),await(0,o.initOniguruma)(e),(0,a.initTextMate)(e),(0,i.initDiagnostics)(e),(0,c.initCallStackView)(e),(0,l.initTokenColorCustomizations)(e),e.subscriptions.push(r.languages.registerRenameProvider(t.DocumentSelector,u.RenameProvider)),e.subscriptions.push(r.languages.registerReferenceProvider(t.DocumentSelector,_.ReferenceProvider)),e.subscriptions.push(r.languages.registerDefinitionProvider(t.DocumentSelector,d.DefinitionProvider)),e.subscriptions.push(r.languages.registerCallHierarchyProvider(t.DocumentSelector,m.CallHierarchyProvider)),e.subscriptions.push(r.languages.registerDocumentSymbolProvider(t.DocumentSelector,p.DocumentSymbolProvider)),e.subscriptions.push(r.languages.registerCompletionItemProvider(t.DocumentSelector,f.CompletionItemProvider,...f.triggerCharacters)),e.subscriptions.push(r.languages.registerDocumentHighlightProvider(t.DocumentSelector,h.DocumentHighlightProvider)),e.subscriptions.push(r.languages.registerDocumentFormattingEditProvider(t.DocumentSelector,g.DocumentFormattingEditProvider)),e.subscriptions.push(r.languages.registerDocumentRangeFormattingEditProvider(t.DocumentSelector,g.DocumentRangeFormattingEditProvider))},t.deactivate=function(){},t.stringify=function(e,t){return"function"==typeof t?"":"symbol"==typeof t?"":void 0===t?"":null==t?null:e.startsWith("HEAP")?"":t}},211:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.initOniguruma=void 0;const r=n(398),s=n(486);t.initOniguruma=async function(e){const t=r.Uri.joinPath(e.extensionUri,"node_modules","vscode-oniguruma","release","onig.wasm"),n={data:await r.workspace.fs.readFile(t),print(e){console.log(e)}};await s.loadWASM(n)}},120:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UseOnigurumaFindOptions=t.DebugFlags=void 0,t.DebugFlags={InDebugMode:"undefined"!=typeof process&&!!process.env.VSCODE_TEXTMATE_DEBUG},t.UseOnigurumaFindOptions=!1},254:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.applyStateStackDiff=t.diffStateStacksRefEq=void 0;const r=n(229);t.diffStateStacksRefEq=function(e,t){let n=0;const r=[];let s=e,o=t;for(;s!==o;)s&&(!o||s.depth>=o.depth)?(n++,s=s.parent):(r.push(o.toStateStackFrame()),o=o.parent);return{pops:n,newFrames:r.reverse()}},t.applyStateStackDiff=function(e,t){let n=e;for(let e=0;e{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.toOptionalTokenType=t.EncodedTokenAttributes=void 0,function(e){e.toBinaryStr=function(e){return e.toString(2).padStart(32,"0")},e.print=function(t){const n=e.getLanguageId(t),r=e.getTokenType(t),s=e.getFontStyle(t),o=e.getForeground(t),a=e.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:s,foreground:o,background:a})},e.getLanguageId=function(e){return(255&e)>>>0},e.getTokenType=function(e){return(768&e)>>>8},e.containsBalancedBrackets=function(e){return 0!=(1024&e)},e.getFontStyle=function(e){return(30720&e)>>>11},e.getForeground=function(e){return(16744448&e)>>>15},e.getBackground=function(e){return(4278190080&e)>>>24},e.set=function(t,n,r,s,o,a,i){let l=e.getLanguageId(t),c=e.getTokenType(t),u=e.containsBalancedBrackets(t)?1:0,_=e.getFontStyle(t),d=e.getForeground(t),m=e.getBackground(t);return 0!==n&&(l=n),8!==r&&(c=r),null!==s&&(u=s?1:0),-1!==o&&(_=o),0!==a&&(d=a),0!==i&&(m=i),(l<<0|c<<8|u<<10|_<<11|d<<15|m<<24)>>>0}}(n||(t.EncodedTokenAttributes=n={})),t.toOptionalTokenType=function(e){return e}},785:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BasicScopeAttributesProvider=t.BasicScopeAttributes=void 0;const r=n(306);class s{languageId;tokenType;constructor(e,t){this.languageId=e,this.tokenType=t}}t.BasicScopeAttributes=s;class o{_defaultAttributes;_embeddedLanguagesMatcher;constructor(e,t){this._defaultAttributes=new s(e,8),this._embeddedLanguagesMatcher=new a(Object.entries(t||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(e){return null===e?o._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(e)}static _NULL_SCOPE_METADATA=new s(0,0);_getBasicScopeAttributes=new r.CachedFn((e=>{const t=this._scopeToLanguage(e),n=this._toStandardTokenType(e);return new s(t,n)}));_scopeToLanguage(e){return this._embeddedLanguagesMatcher.match(e)||0}_toStandardTokenType(e){const t=e.match(o.STANDARD_TOKEN_TYPE_REGEXP);if(!t)return 8;switch(t[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw new Error("Unexpected match for standard token type!")}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/}t.BasicScopeAttributesProvider=o;class a{values;scopesRegExp;constructor(e){if(0===e.length)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);const t=e.map((([e,t])=>(0,r.escapeRegExpCharacters)(e)));t.sort(),t.reverse(),this.scopesRegExp=new RegExp(`^((${t.join(")|(")}))($|\\.)`,"")}}match(e){if(!this.scopesRegExp)return;const t=e.match(this.scopesRegExp);return t?this.values.get(t[1]):void 0}}},856:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LineTokens=t.BalancedBracketSelectors=t.StateStackImpl=t.AttributedScopeStack=t.Grammar=t.createGrammar=void 0;const r=n(120),s=n(157),o=n(885),a=n(687),i=n(441),l=n(734),c=n(306),u=n(785),_=n(729);function d(e,t,n,r,s){const a=(0,o.createMatchers)(t,m),l=i.RuleFactory.getCompiledRuleId(n,r,s.repository);for(const n of a)e.push({debugSelector:t,matcher:n.matcher,ruleId:l,grammar:s,priority:n.priority})}function m(e,t){if(t.length{for(let r=n;rn&&e.substr(0,n)===t&&"."===e[n]}t.createGrammar=function(e,t,n,r,s,o,a,i){return new h(e,t,n,r,s,o,a,i)};class h{_rootScopeName;balancedBracketSelectors;_onigLib;_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}constructor(e,t,n,r,s,a,i,l){if(this._rootScopeName=e,this.balancedBracketSelectors=a,this._onigLib=l,this._basicScopeAttributesProvider=new u.BasicScopeAttributesProvider(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=i,this._grammar=f(t,null),this._injections=null,this._tokenTypeMatchers=[],s)for(const e of Object.keys(s)){const t=(0,o.createMatchers)(e,m);for(const n of t)this._tokenTypeMatchers.push({matcher:n.matcher,type:s[e]})}}dispose(){for(const e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){const e=[],t=this._rootScopeName,n=(e=>e===this._rootScopeName?this._grammar:this.getExternalGrammar(e))(t);if(n){const r=n.injections;if(r)for(let t in r)d(e,t,r[t],this,n);const s=this._grammarRepository.injections(t);s&&s.forEach((t=>{const n=this.getExternalGrammar(t);if(n){const t=n.injectionSelector;t&&d(e,t,n,this,n)}}))}return e.sort(((e,t)=>e.priority-t.priority)),e}getInjections(){if(null===this._injections&&(this._injections=this._collectInjections(),r.DebugFlags.InDebugMode&&this._injections.length>0)){console.log(`Grammar ${this._rootScopeName} contains the following injections:`);for(const e of this._injections)console.log(` - ${e.debugSelector}`)}return this._injections}registerRule(e){const t=++this._lastRuleId,n=e((0,i.ruleIdFromNumber)(t));return this._ruleId2desc[t]=n,n}getRule(e){return this._ruleId2desc[(0,i.ruleIdToNumber)(e)]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){const n=this._grammarRepository.lookup(e);if(n)return this._includedGrammars[e]=f(n,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,n=0){const r=this._tokenize(e,t,!1,n);return{tokens:r.lineTokens.getResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}tokenizeLine2(e,t,n=0){const r=this._tokenize(e,t,!0,n);return{tokens:r.lineTokens.getBinaryResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}_tokenize(e,t,n,r){let o;if(-1===this._rootId&&(this._rootId=i.RuleFactory.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections()),t&&t!==y.NULL)o=!1,t.reset();else{o=!0;const e=this._basicScopeAttributesProvider.getDefaultAttributes(),n=this.themeProvider.getDefaults(),r=s.EncodedTokenAttributes.set(0,e.languageId,e.tokenType,null,n.fontStyle,n.foregroundId,n.backgroundId),a=this.getRule(this._rootId).getName(null,null);let i;i=a?g.createRootAndLookUpScopeName(a,r,this):g.createRoot("unknown",r),t=new y(null,this._rootId,-1,-1,!1,null,i,i)}e+="\n";const l=this.createOnigString(e),c=l.content.length,u=new b(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),d=(0,_._tokenizeString)(this,l,o,0,t,u,!0,r);return(0,a.disposeOnigString)(l),{lineLength:c,lineTokens:u,ruleStack:d.stack,stoppedEarly:d.stoppedEarly}}}function f(e,t){return(e=(0,c.clone)(e)).repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}t.Grammar=h;class g{parent;scopePath;tokenAttributes;static fromExtension(e,t){let n=e,r=e?.scopePath??null;for(const e of t)r=l.ScopeStack.push(r,e.scopeNames),n=new g(n,r,e.encodedTokenAttributes);return n}static createRoot(e,t){return new g(null,new l.ScopeStack(null,e),t)}static createRootAndLookUpScopeName(e,t,n){const r=n.getMetadataForScope(e),s=new l.ScopeStack(null,e),o=n.themeProvider.themeMatch(s),a=g.mergeAttributes(t,r,o);return new g(null,s,a)}get scopeName(){return this.scopePath.scopeName}constructor(e,t,n){this.parent=e,this.scopePath=t,this.tokenAttributes=n}toString(){return this.getScopeNames().join(" ")}equals(e){return g.equals(this,e)}static equals(e,t){for(;;){if(e===t)return!0;if(!e&&!t)return!0;if(!e||!t)return!1;if(e.scopeName!==t.scopeName||e.tokenAttributes!==t.tokenAttributes)return!1;e=e.parent,t=t.parent}}static mergeAttributes(e,t,n){let r=-1,o=0,a=0;return null!==n&&(r=n.fontStyle,o=n.foregroundId,a=n.backgroundId),s.EncodedTokenAttributes.set(e,t.languageId,t.tokenType,null,r,o,a)}pushAttributed(e,t){if(null===e)return this;if(-1===e.indexOf(" "))return g._pushAttributed(this,e,t);const n=e.split(/ /g);let r=this;for(const e of n)r=g._pushAttributed(r,e,t);return r}static _pushAttributed(e,t,n){const r=n.getMetadataForScope(t),s=e.scopePath.push(t),o=n.themeProvider.themeMatch(s),a=g.mergeAttributes(e.tokenAttributes,r,o);return new g(e,s,a)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(e){const t=[];let n=this;for(;n&&n!==e;)t.push({encodedTokenAttributes:n.tokenAttributes,scopeNames:n.scopePath.getExtensionIfDefined(n.parent?.scopePath??null)}),n=n.parent;return n===e?t.reverse():void 0}}t.AttributedScopeStack=g;class y{parent;ruleId;beginRuleCapturedEOL;endRule;nameScopesList;contentNameScopesList;_stackElementBrand=void 0;static NULL=new y(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;constructor(e,t,n,r,s,o,a,i){this.parent=e,this.ruleId=t,this.beginRuleCapturedEOL=s,this.endRule=o,this.nameScopesList=a,this.contentNameScopesList=i,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=n,this._anchorPos=r}equals(e){return null!==e&&y._equals(this,e)}static _equals(e,t){return e===t||!!this._structuralEquals(e,t)&&g.equals(e.contentNameScopesList,t.contentNameScopesList)}static _structuralEquals(e,t){for(;;){if(e===t)return!0;if(!e&&!t)return!0;if(!e||!t)return!1;if(e.depth!==t.depth||e.ruleId!==t.ruleId||e.endRule!==t.endRule)return!1;e=e.parent,t=t.parent}}clone(){return this}static _reset(e){for(;e;)e._enterPos=-1,e._anchorPos=-1,e=e.parent}reset(){y._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(e,t,n,r,s,o,a){return new y(this,e,t,n,r,s,o,a)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(e){return e.getRule(this.ruleId)}toString(){const e=[];return this._writeString(e,0),"["+e.join(",")+"]"}_writeString(e,t){return this.parent&&(t=this.parent._writeString(e,t)),e[t++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,t}withContentNameScopesList(e){return this.contentNameScopesList===e?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,e)}withEndRule(e){return this.endRule===e?this:new y(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,e,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(e){let t=this;for(;t&&t._enterPos===e._enterPos;){if(t.ruleId===e.ruleId)return!0;t=t.parent}return!1}toStateStackFrame(){return{ruleId:(0,i.ruleIdToNumber)(this.ruleId),beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(e,t){const n=g.fromExtension(e?.nameScopesList??null,t.nameScopesList);return new y(e,(0,i.ruleIdFromNumber)(t.ruleId),t.enterPos??-1,t.anchorPos??-1,t.beginRuleCapturedEOL,t.endRule,n,g.fromExtension(n,t.contentNameScopesList))}}t.StateStackImpl=y,t.BalancedBracketSelectors=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap((e=>"*"===e?(this.allowAny=!0,[]):(0,o.createMatchers)(e,m).map((e=>e.matcher)))),this.unbalancedBracketScopes=t.flatMap((e=>(0,o.createMatchers)(e,m).map((e=>e.matcher))))}get matchesAlways(){return this.allowAny&&0===this.unbalancedBracketScopes.length}get matchesNever(){return 0===this.balancedBracketScopes.length&&!this.allowAny}match(e){for(const t of this.unbalancedBracketScopes)if(t(e))return!1;for(const t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}};class b{balancedBracketSelectors;_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;constructor(e,t,n,s){this.balancedBracketSelectors=s,this._emitBinaryTokens=e,this._tokenTypeOverrides=n,r.DebugFlags.InDebugMode?this._lineText=t:this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let n=e?.tokenAttributes??0,o=!1;if(this.balancedBracketSelectors?.matchesAlways&&(o=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){const t=e?.getScopeNames()??[];for(const e of this._tokenTypeOverrides)e.matcher(t)&&(n=s.EncodedTokenAttributes.set(n,0,(0,s.toOptionalTokenType)(e.type),null,-1,0,0));this.balancedBracketSelectors&&(o=this.balancedBracketSelectors.match(t))}if(o&&(n=s.EncodedTokenAttributes.set(n,0,8,o,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===n)return void(this._lastTokenEndIndex=t);if(r.DebugFlags.InDebugMode){const n=e?.getScopeNames()??[];console.log(" token: |"+this._lineText.substring(this._lastTokenEndIndex,t).replace(/\n$/,"\\n")+"|");for(let e=0;e0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),0===this._tokens.length&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),0===this._binaryTokens.length&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);const n=new Uint32Array(this._binaryTokens.length);for(let e=0,t=this._binaryTokens.length;e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseInclude=t.TopLevelRepositoryReference=t.TopLevelReference=t.RelativeReference=t.SelfReference=t.BaseReference=t.ScopeDependencyProcessor=t.ExternalReferenceCollector=t.TopLevelRepositoryRuleReference=t.TopLevelRuleReference=void 0;const r=n(306);class s{scopeName;constructor(e){this.scopeName=e}toKey(){return this.scopeName}}t.TopLevelRuleReference=s;class o{scopeName;ruleName;constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}}t.TopLevelRepositoryRuleReference=o;class a{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){const t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}}function i(e,t,n,r){const o=n.lookup(e.scopeName);if(!o){if(e.scopeName===t)throw new Error(`No grammar provided for <${t}>`);return}const a=n.lookup(t);e instanceof s?c({baseGrammar:a,selfGrammar:o},r):l(e.ruleName,{baseGrammar:a,selfGrammar:o,repository:o.repository},r);const i=n.injections(e.scopeName);if(i)for(const e of i)r.add(new s(e))}function l(e,t,n){t.repository&&t.repository[e]&&u([t.repository[e]],t,n)}function c(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&u(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&u(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function u(e,t,n){for(const a of e){if(n.visitedRule.has(a))continue;n.visitedRule.add(a);const e=a.repository?(0,r.mergeObjects)({},t.repository,a.repository):t.repository;Array.isArray(a.patterns)&&u(a.patterns,{...t,repository:e},n);const i=a.include;if(!i)continue;const _=f(i);switch(_.kind){case 0:c({...t,selfGrammar:t.baseGrammar},n);break;case 1:c(t,n);break;case 2:l(_.ruleName,{...t,repository:e},n);break;case 3:case 4:const r=_.scopeName===t.selfGrammar.scopeName?t.selfGrammar:_.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(r){const s={baseGrammar:t.baseGrammar,selfGrammar:r,repository:e};4===_.kind?l(_.ruleName,s,n):c(s,n)}else 4===_.kind?n.add(new o(_.scopeName,_.ruleName)):n.add(new s(_.scopeName))}}}t.ExternalReferenceCollector=a,t.ScopeDependencyProcessor=class{repo;initialScopeName;seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new s(this.initialScopeName)]}processQueue(){const e=this.Q;this.Q=[];const t=new a;for(const n of e)i(n,this.initialScopeName,this.repo,t);for(const e of t.references)if(e instanceof s){if(this.seenFullScopeRequests.has(e.scopeName))continue;this.seenFullScopeRequests.add(e.scopeName),this.Q.push(e)}else{if(this.seenFullScopeRequests.has(e.scopeName))continue;if(this.seenPartialScopeRequests.has(e.toKey()))continue;this.seenPartialScopeRequests.add(e.toKey()),this.Q.push(e)}}};class _{kind=0}t.BaseReference=_;class d{kind=1}t.SelfReference=d;class m{ruleName;kind=2;constructor(e){this.ruleName=e}}t.RelativeReference=m;class p{scopeName;kind=3;constructor(e){this.scopeName=e}}t.TopLevelReference=p;class h{scopeName;ruleName;kind=4;constructor(e,t){this.scopeName=e,this.ruleName=t}}function f(e){if("$base"===e)return new _;if("$self"===e)return new d;const t=e.indexOf("#");if(-1===t)return new p(e);if(0===t)return new m(e.substring(1));{const n=e.substring(0,t),r=e.substring(t+1);return new h(n,r)}}t.TopLevelRepositoryReference=h,t.parseInclude=f},229:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var s=Object.getOwnPropertyDescriptor(t,n);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,s)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),s=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),s(n(856),t)},729:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LocalStackElement=t._tokenizeString=void 0;const r=n(120),s=n(687),o=n(441),a=n(306);class i{stack;stoppedEarly;constructor(e,t){this.stack=e,this.stoppedEarly=t}}function l(e,t,n,s,l,_,m,p){const h=t.content.length;let f=!1,g=-1;if(m){const a=function(e,t,n,s,a,i){let l=a.beginRuleCapturedEOL?0:-1;const c=[];for(let t=a;t;t=t.pop()){const n=t.getRule(e);n instanceof o.BeginWhileRule&&c.push({rule:n,stack:t})}for(let _=c.pop();_;_=c.pop()){const{ruleScanner:c,findOptions:m}=u(_.rule,e,_.stack.endRule,n,s===l),p=c.findNextMatchSync(t,s,m);if(r.DebugFlags.InDebugMode&&(console.log(" scanning for while rule"),console.log(c.toString())),!p){r.DebugFlags.InDebugMode&&console.log(" popping "+_.rule.debugName+" - "+_.rule.debugWhileRegExp),a=_.stack.pop();break}if(p.ruleId!==o.whileRuleId){a=_.stack.pop();break}p.captureIndices&&p.captureIndices.length&&(i.produce(_.stack,p.captureIndices[0].start),d(e,t,n,_.stack,i,_.rule.whileCaptures,p.captureIndices),i.produce(_.stack,p.captureIndices[0].end),l=p.captureIndices[0].end,p.captureIndices[0].end>s&&(s=p.captureIndices[0].end,n=!1))}return{stack:a,linePos:s,anchorPosition:l,isFirstLine:n}}(e,t,n,s,l,_);l=a.stack,s=a.linePos,n=a.isFirstLine,g=a.anchorPosition}const y=Date.now();for(;!f;){if(0!==p&&Date.now()-y>p)return new i(l,!0);b()}return new i(l,!1);function b(){r.DebugFlags.InDebugMode&&(console.log(""),console.log(`@@scanNext ${s}: |${t.content.substr(s).replace(/\n$/,"\\n")}|`));const i=function(e,t,n,s,o,i){const l=function(e,t,n,s,o,i){const l=o.getRule(e),{ruleScanner:u,findOptions:_}=c(l,e,o.endRule,n,s===i);let d=0;r.DebugFlags.InDebugMode&&(d=(0,a.performanceNow)());const m=u.findNextMatchSync(t,s,_);if(r.DebugFlags.InDebugMode){const e=(0,a.performanceNow)()-d;e>5&&console.warn(`Rule ${l.debugName} (${l.id}) matching took ${e} against '${t}'`),console.log(` scanning for (linePos: ${s}, anchorPosition: ${i})`),console.log(u.toString()),m&&console.log(`matched rule id: ${m.ruleId} from ${m.captureIndices[0].start} to ${m.captureIndices[0].end}`)}return m?{captureIndices:m.captureIndices,matchedRuleId:m.ruleId}:null}(e,t,n,s,o,i),u=e.getInjections();if(0===u.length)return l;const _=function(e,t,n,s,o,a,i){let l,u=Number.MAX_VALUE,_=null,d=0;const m=a.contentNameScopesList.getScopeNames();for(let a=0,p=e.length;a=u)&&(u=b,_=y.captureIndices,l=y.ruleId,d=p.priority,u===o))break}return _?{priorityMatch:-1===d,captureIndices:_,matchedRuleId:l}:null}(u,e,t,n,s,o,i);if(!_)return l;if(!l)return _;const d=l.captureIndices[0].start,m=_.captureIndices[0].start;return m0)&&u[0].end>s;if(m===o.endRuleId){const o=l.getRule(e);r.DebugFlags.InDebugMode&&console.log(" popping "+o.debugName+" - "+o.debugEndRegExp),_.produce(l,u[0].start),l=l.withContentNameScopesList(l.nameScopesList),d(e,t,n,l,_,o.endCaptures,u),_.produce(l,u[0].end);const a=l;if(l=l.parent,g=a.getAnchorPos(),!p&&a.getEnterPos()===s)return r.DebugFlags.InDebugMode&&console.error("[1] - Grammar is in an endless loop - Grammar pushed & popped a rule without advancing"),l=a,_.produce(l,h),void(f=!0)}else{const a=e.getRule(m);_.produce(l,u[0].start);const i=l,c=a.getName(t.content,u),y=l.contentNameScopesList.pushAttributed(c,e);if(l=l.push(m,s,g,u[0].end===h,null,y,y),a instanceof o.BeginEndRule){const s=a;r.DebugFlags.InDebugMode&&console.log(" pushing "+s.debugName+" - "+s.debugBeginRegExp),d(e,t,n,l,_,s.beginCaptures,u),_.produce(l,u[0].end),g=u[0].end;const o=s.getContentName(t.content,u),c=y.pushAttributed(o,e);if(l=l.withContentNameScopesList(c),s.endHasBackReferences&&(l=l.withEndRule(s.getEndWithResolvedBackReferences(t.content,u))),!p&&i.hasSameRuleAs(l))return r.DebugFlags.InDebugMode&&console.error("[2] - Grammar is in an endless loop - Grammar pushed the same rule without advancing"),l=l.pop(),_.produce(l,h),void(f=!0)}else if(a instanceof o.BeginWhileRule){const s=a;r.DebugFlags.InDebugMode&&console.log(" pushing "+s.debugName),d(e,t,n,l,_,s.beginCaptures,u),_.produce(l,u[0].end),g=u[0].end;const o=s.getContentName(t.content,u),c=y.pushAttributed(o,e);if(l=l.withContentNameScopesList(c),s.whileHasBackReferences&&(l=l.withEndRule(s.getWhileWithResolvedBackReferences(t.content,u))),!p&&i.hasSameRuleAs(l))return r.DebugFlags.InDebugMode&&console.error("[3] - Grammar is in an endless loop - Grammar pushed the same rule without advancing"),l=l.pop(),_.produce(l,h),void(f=!0)}else{const s=a;if(r.DebugFlags.InDebugMode&&console.log(" matched "+s.debugName+" - "+s.debugMatchRegExp),d(e,t,n,l,_,s.captures,u),_.produce(l,u[0].end),l=l.pop(),!p)return r.DebugFlags.InDebugMode&&console.error("[4] - Grammar is in an endless loop - Grammar is not advancing, nor is it pushing/popping"),l=l.safePop(),_.produce(l,h),void(f=!0)}}u[0].end>s&&(s=u[0].end,n=!1)}}function c(e,t,n,s,o){return r.UseOnigurumaFindOptions?{ruleScanner:e.compile(t,n),findOptions:_(s,o)}:{ruleScanner:e.compileAG(t,n,s,o),findOptions:0}}function u(e,t,n,s,o){return r.UseOnigurumaFindOptions?{ruleScanner:e.compileWhile(t,n),findOptions:_(s,o)}:{ruleScanner:e.compileWhileAG(t,n,s,o),findOptions:0}}function _(e,t){let n=0;return e||(n|=1),t||(n|=4),n}function d(e,t,n,r,o,a,i){if(0===a.length)return;const c=t.content,u=Math.min(a.length,i.length),_=[],d=i[0].end;for(let t=0;td)break;for(;_.length>0&&_[_.length-1].endPos<=p.start;)o.produceFromScopes(_[_.length-1].scopes,_[_.length-1].endPos),_.pop();if(_.length>0?o.produceFromScopes(_[_.length-1].scopes,p.start):o.produce(r,p.start),u.retokenizeCapturedWithRuleId){const t=u.getName(c,i),a=r.contentNameScopesList.pushAttributed(t,e),_=u.getContentName(c,i),d=a.pushAttributed(_,e),m=r.push(u.retokenizeCapturedWithRuleId,p.start,-1,!1,null,a,d),h=e.createOnigString(c.substring(0,p.end));l(e,h,n&&0===p.start,p.start,m,o,!1,0),(0,s.disposeOnigString)(h);continue}const h=u.getName(c,i);if(null!==h){const t=(_.length>0?_[_.length-1].scopes:r.contentNameScopesList).pushAttributed(h,e);_.push(new m(t,p.end))}}for(;_.length>0;)o.produceFromScopes(_[_.length-1].scopes,_[_.length-1].endPos),_.pop()}t._tokenizeString=l;class m{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}}t.LocalStackElement=m},817:(e,t)=>{"use strict";function n(e,t){throw new Error("Near offset "+e.pos+": "+t+" ~~~"+e.source.substr(e.pos,50)+"~~~")}Object.defineProperty(t,"__esModule",{value:!0}),t.parseJSON=void 0,t.parseJSON=function(e,t,a){let i=new r(e),l=new s,c=0,u=null,_=[],d=[];function m(){_.push(c),d.push(u)}function p(){c=_.pop(),u=d.pop()}function h(e){n(i,e)}for(;o(i,l);){if(0===c){if(null!==u&&h("too many constructs in root"),3===l.type){u={},a&&(u.$vscodeTextmateLocation=l.toLocation(t)),m(),c=1;continue}if(2===l.type){u=[],m(),c=4;continue}h("unexpected token in root")}if(2===c){if(5===l.type){p();continue}if(7===l.type){c=3;continue}h("expected , or }")}if(1===c||3===c){if(1===c&&5===l.type){p();continue}if(1===l.type){let e=l.value;if(o(i,l)&&6===l.type||h("expected colon"),o(i,l)||h("expected value"),c=2,1===l.type){u[e]=l.value;continue}if(8===l.type){u[e]=null;continue}if(9===l.type){u[e]=!0;continue}if(10===l.type){u[e]=!1;continue}if(11===l.type){u[e]=parseFloat(l.value);continue}if(2===l.type){let t=[];u[e]=t,m(),c=4,u=t;continue}if(3===l.type){let n={};a&&(n.$vscodeTextmateLocation=l.toLocation(t)),u[e]=n,m(),c=1,u=n;continue}}h("unexpected token in dict")}if(5===c){if(4===l.type){p();continue}if(7===l.type){c=6;continue}h("expected , or ]")}if(4===c||6===c){if(4===c&&4===l.type){p();continue}if(c=5,1===l.type){u.push(l.value);continue}if(8===l.type){u.push(null);continue}if(9===l.type){u.push(!0);continue}if(10===l.type){u.push(!1);continue}if(11===l.type){u.push(parseFloat(l.value));continue}if(2===l.type){let e=[];u.push(e),m(),c=4,u=e;continue}if(3===l.type){let e={};a&&(e.$vscodeTextmateLocation=l.toLocation(t)),u.push(e),m(),c=1,u=e;continue}h("unexpected token in array")}h("unknown state")}return 0!==d.length&&h("unclosed constructs"),u};class r{source;pos;len;line;char;constructor(e){this.source=e,this.pos=0,this.len=e.length,this.line=1,this.char=0}}class s{value;type;offset;len;line;char;constructor(){this.value=null,this.type=0,this.offset=-1,this.len=-1,this.line=-1,this.char=-1}toLocation(e){return{filename:e,line:this.line,char:this.char}}}function o(e,t){t.value=null,t.type=0,t.offset=-1,t.len=-1,t.line=-1,t.char=-1;let r,s=e.source,o=e.pos,a=e.len,i=e.line,l=e.char;for(;;){if(o>=a)return!1;if(r=s.charCodeAt(o),32!==r&&9!==r&&13!==r){if(10!==r)break;o++,i++,l=0}else o++,l++}if(t.offset=o,t.line=i,t.char=l,34===r){for(t.type=1,o++,l++;;){if(o>=a)return!1;if(r=s.charCodeAt(o),o++,l++,92!==r){if(34===r)break}else o++,l++}t.value=s.substring(t.offset+1,o-1).replace(/\\u([0-9A-Fa-f]{4})/g,((e,t)=>String.fromCodePoint(parseInt(t,16)))).replace(/\\(.)/g,((t,r)=>{switch(r){case'"':return'"';case"\\":return"\\";case"/":return"/";case"b":return"\b";case"f":return"\f";case"n":return"\n";case"r":return"\r";case"t":return"\t";default:n(e,"invalid escape sequence")}throw new Error("unreachable")}))}else if(91===r)t.type=2,o++,l++;else if(123===r)t.type=3,o++,l++;else if(93===r)t.type=4,o++,l++;else if(125===r)t.type=5,o++,l++;else if(58===r)t.type=6,o++,l++;else if(44===r)t.type=7,o++,l++;else if(110===r){if(t.type=8,o++,l++,r=s.charCodeAt(o),117!==r)return!1;if(o++,l++,r=s.charCodeAt(o),108!==r)return!1;if(o++,l++,r=s.charCodeAt(o),108!==r)return!1;o++,l++}else if(116===r){if(t.type=9,o++,l++,r=s.charCodeAt(o),114!==r)return!1;if(o++,l++,r=s.charCodeAt(o),117!==r)return!1;if(o++,l++,r=s.charCodeAt(o),101!==r)return!1;o++,l++}else if(102===r){if(t.type=10,o++,l++,r=s.charCodeAt(o),97!==r)return!1;if(o++,l++,r=s.charCodeAt(o),108!==r)return!1;if(o++,l++,r=s.charCodeAt(o),115!==r)return!1;if(o++,l++,r=s.charCodeAt(o),101!==r)return!1;o++,l++}else for(t.type=11;;){if(o>=a)return!1;if(r=s.charCodeAt(o),!(46===r||r>=48&&r<=57||101===r||69===r||45===r||43===r))break;o++,l++}return t.len=o-t.offset,null===t.value&&(t.value=s.substr(t.offset,t.len)),e.pos=o,e.line=i,e.char=l,!0}},454:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var s=Object.getOwnPropertyDescriptor(t,n);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,s)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),s=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.applyStateStackDiff=t.diffStateStacksRefEq=t.parseRawGrammar=t.INITIAL=t.Registry=void 0;const o=n(229),a=n(519),i=n(476),l=n(734),c=n(901),u=n(254);Object.defineProperty(t,"applyStateStackDiff",{enumerable:!0,get:function(){return u.applyStateStackDiff}}),Object.defineProperty(t,"diffStateStacksRefEq",{enumerable:!0,get:function(){return u.diffStateStacksRefEq}}),s(n(687),t),t.Registry=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new i.SyncRegistry(l.Theme.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(l.Theme.createFromRawTheme(e,t))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,t,n){return this.loadGrammarWithConfiguration(e,t,{embeddedLanguages:n})}loadGrammarWithConfiguration(e,t,n){return this._loadGrammar(e,t,n.embeddedLanguages,n.tokenTypes,new o.BalancedBracketSelectors(n.balancedBracketSelectors||[],n.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}async _loadGrammar(e,t,n,r,s){const o=new c.ScopeDependencyProcessor(this._syncRegistry,e);for(;o.Q.length>0;)await Promise.all(o.Q.map((e=>this._loadSingleGrammar(e.scopeName)))),o.processQueue();return this._grammarForScopeName(e,t,n,r,s)}async _loadSingleGrammar(e){return this._ensureGrammarCache.has(e)||this._ensureGrammarCache.set(e,this._doLoadSingleGrammar(e)),this._ensureGrammarCache.get(e)}async _doLoadSingleGrammar(e){const t=await this._options.loadGrammar(e);if(t){const n="function"==typeof this._options.getInjections?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(t,n)}}async addGrammar(e,t=[],n=0,r=null){return this._syncRegistry.addGrammar(e,t),await this._grammarForScopeName(e.scopeName,n,r)}_grammarForScopeName(e,t=0,n=null,r=null,s=null){return this._syncRegistry.grammarForScopeName(e,t,n,r,s)}},t.INITIAL=o.StateStackImpl.NULL,t.parseRawGrammar=a.parseRawGrammar},885:(e,t)=>{"use strict";function n(e){return!!e&&!!e.match(/[\w\.:]+/)}Object.defineProperty(t,"__esModule",{value:!0}),t.createMatchers=void 0,t.createMatchers=function(e,t){const r=[],s=function(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;const r=n[0];return n=t.exec(e),r}}}(e);let o=s.next();for(;null!==o;){let e=0;if(2===o.length&&":"===o.charAt(1)){switch(o.charAt(0)){case"R":e=1;break;case"L":e=-1;break;default:console.log(`Unknown priority ${o} in scope selector`)}o=s.next()}let t=i();if(r.push({matcher:t,priority:e}),","!==o)break;o=s.next()}return r;function a(){if("-"===o){o=s.next();const e=a();return t=>!!e&&!e(t)}if("("===o){o=s.next();const e=function(){const e=[];let t=i();for(;t&&(e.push(t),"|"===o||","===o);){do{o=s.next()}while("|"===o||","===o);t=i()}return t=>e.some((e=>e(t)))}();return")"===o&&(o=s.next()),e}if(n(o)){const e=[];do{e.push(o),o=s.next()}while(n(o));return n=>t(e,n)}return null}function i(){const e=[];let t=a();for(;t;)e.push(t),t=a();return t=>e.every((e=>e(t)))}}},687:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.disposeOnigString=void 0,t.disposeOnigString=function(e){"function"==typeof e.dispose&&e.dispose()}},519:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseRawGrammar=void 0;const r=n(935),s=n(120),o=n(817);t.parseRawGrammar=function(e,t=null){return null!==t&&/\.json$/.test(t)?(n=e,a=t,s.DebugFlags.InDebugMode?(0,o.parseJSON)(n,a,!0):JSON.parse(n)):function(e,t){return s.DebugFlags.InDebugMode?r.parseWithLocation(e,t,"$vscodeTextmateLocation"):r.parsePLIST(e)}(e,t);var n,a}},935:(e,t)=>{"use strict";function n(e,t,n){const r=e.length;let s=0,o=1,a=0;function i(t){if(null===n)s+=t;else for(;t>0;)10===e.charCodeAt(s)?(s++,o++,a=0):(s++,a++),t--}function l(e){null===n?s=e:i(e-s)}function c(){for(;s0&&65279===e.charCodeAt(0)&&(s=1);let m=0,p=null,h=[],f=[],g=null;function y(e,t){h.push(m),f.push(p),m=e,p=t}function b(){if(0===h.length)return w("illegal state stack");m=h.pop(),p=f.pop()}function w(t){throw new Error("Near offset "+s+": "+t+" ~~~"+e.substr(s,50)+"~~~")}const S=function(){if(null===g)return w("missing ");let e={};null!==n&&(e[n]={filename:t,line:o,char:a}),p[g]=e,g=null,y(1,e)},E=function(){if(null===g)return w("missing ");let e=[];p[g]=e,g=null,y(2,e)},N=function(){let e={};null!==n&&(e[n]={filename:t,line:o,char:a}),p.push(e),y(1,e)},I=function(){let e=[];p.push(e),y(2,e)};function M(){if(1!==m)return w("unexpected ");b()}function v(){return 1===m||2!==m?w("unexpected "):void b()}function R(e){if(1===m){if(null===g)return w("missing ");p[g]=e,g=null}else 2===m?p.push(e):p=e}function T(e){if(isNaN(e))return w("cannot parse float");if(1===m){if(null===g)return w("missing ");p[g]=e,g=null}else 2===m?p.push(e):p=e}function C(e){if(isNaN(e))return w("cannot parse integer");if(1===m){if(null===g)return w("missing ");p[g]=e,g=null}else 2===m?p.push(e):p=e}function A(e){if(1===m){if(null===g)return w("missing ");p[g]=e,g=null}else 2===m?p.push(e):p=e}function P(e){if(1===m){if(null===g)return w("missing ");p[g]=e,g=null}else 2===m?p.push(e):p=e}function k(e){if(1===m){if(null===g)return w("missing ");p[g]=e,g=null}else 2===m?p.push(e):p=e}function x(){let e=d(">"),t=!1;return 47===e.charCodeAt(e.length-1)&&(t=!0,e=e.substring(0,e.length-1)),{name:e.trim(),isClosed:t}}function F(e){if(e.isClosed)return"";let t=d(""),t.replace(/&#([0-9]+);/g,(function(e,t){return String.fromCodePoint(parseInt(t,10))})).replace(/&#x([0-9a-f]+);/g,(function(e,t){return String.fromCodePoint(parseInt(t,16))})).replace(/&|<|>|"|'/g,(function(e){switch(e){case"&":return"&";case"<":return"<";case">":return">";case""":return'"';case"'":return"'"}return e}))}for(;s=r));){const l=e.charCodeAt(s);if(i(1),60!==l)return w("expected <");if(s>=r)return w("unexpected end of input");const d=e.charCodeAt(s);if(63===d){i(1),_("?>");continue}if(33===d){if(i(1),u("--")){_("--\x3e");continue}_(">");continue}if(47===d){if(i(1),c(),u("plist")){_(">");continue}if(u("dict")){_(">"),M();continue}if(u("array")){_(">"),v();continue}return w("unexpected closed tag")}let h=x();switch(h.name){case"dict":1===m?S():2===m?N():(p={},null!==n&&(p[n]={filename:t,line:o,char:a}),y(1,p)),h.isClosed&&M();continue;case"array":1===m?E():2===m?I():(p=[],y(2,p)),h.isClosed&&v();continue;case"key":O=F(h),1!==m?w("unexpected "):null!==g?w("too many "):g=O;continue;case"string":R(F(h));continue;case"real":T(parseFloat(F(h)));continue;case"integer":C(parseInt(F(h),10));continue;case"date":A(new Date(F(h)));continue;case"data":P(F(h));continue;case"true":F(h),k(!0);continue;case"false":F(h),k(!1);continue}if(!/^plist/.test(h.name))return w("unexpected opened tag "+h.name)}var O;return p}Object.defineProperty(t,"__esModule",{value:!0}),t.parsePLIST=t.parseWithLocation=void 0,t.parseWithLocation=function(e,t,r){return n(e,t,r)},t.parsePLIST=function(e){return n(e,null,null)}},476:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SyncRegistry=void 0;const r=n(229);t.SyncRegistry=class{_onigLibPromise;_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;constructor(e,t){this._onigLibPromise=t,this._theme=e}dispose(){for(const e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}async grammarForScopeName(e,t,n,s,o){if(!this._grammars.has(e)){let a=this._rawGrammars.get(e);if(!a)return null;this._grammars.set(e,(0,r.createGrammar)(e,a,t,n,s,o,this,await this._onigLibPromise))}return this._grammars.get(e)}}},441:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CompiledRule=t.RegExpSourceList=t.RegExpSource=t.RuleFactory=t.BeginWhileRule=t.BeginEndRule=t.IncludeOnlyRule=t.MatchRule=t.CaptureRule=t.Rule=t.ruleIdToNumber=t.ruleIdFromNumber=t.whileRuleId=t.endRuleId=void 0;const r=n(306),s=n(901),o=/\\(\d+)/,a=/\\(\d+)/g;Symbol("RuleId"),t.endRuleId=-1,t.whileRuleId=-2,t.ruleIdFromNumber=function(e){return e},t.ruleIdToNumber=function(e){return e};class i{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,n,s){this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=r.RegexSource.hasCaptures(this._name),this._contentName=s||null,this._contentNameIsCapturing=r.RegexSource.hasCaptures(this._contentName)}get debugName(){const e=this.$location?`${(0,r.basename)(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return this._nameIsCapturing&&null!==this._name&&null!==e&&null!==t?r.RegexSource.replaceCaptures(this._name,e,t):this._name}getContentName(e,t){return this._contentNameIsCapturing&&null!==this._contentName?r.RegexSource.replaceCaptures(this._contentName,e,t):this._contentName}}t.Rule=i;class l extends i{retokenizeCapturedWithRuleId;constructor(e,t,n,r,s){super(e,t,n,r),this.retokenizeCapturedWithRuleId=s}dispose(){}collectPatterns(e,t){throw new Error("Not supported!")}compile(e,t){throw new Error("Not supported!")}compileAG(e,t,n,r){throw new Error("Not supported!")}}t.CaptureRule=l;class c extends i{_match;captures;_cachedCompiledPatterns;constructor(e,t,n,r,s){super(e,t,n,null),this._match=new p(r,this.id),this.captures=s,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new h,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}}t.MatchRule=c;class u extends i{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,s){super(e,t,n,r),this.patterns=s.patterns,this.hasMissingPatterns=s.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(e,t){for(const n of this.patterns)e.getRule(n).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new h,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}}t.IncludeOnlyRule=u;class _ extends i{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,s,o,a,i,l,c){super(e,t,n,r),this._begin=new p(s,this.id),this.beginCaptures=o,this._end=new p(a||"๏ฟฟ",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=i,this.applyEndPatternLast=l||!1,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e,t).compileAG(e,n,r)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new h;for(const t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}}t.BeginEndRule=_;class d extends i{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,n,r,s,o,a,i,l,c){super(e,n,r,s),this._begin=new p(o,this.id),this.beginCaptures=a,this.whileCaptures=l,this._while=new p(i,t.whileRuleId),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new h;for(const t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,n,r){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,n,r)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new h,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||"๏ฟฟ"),this._cachedCompiledWhilePatterns}}t.BeginWhileRule=d;class m{static createCaptureRule(e,t,n,r,s){return e.registerRule((e=>new l(t,e,n,r,s)))}static getCompiledRuleId(e,t,n){return e.id||t.registerRule((s=>{if(e.id=s,e.match)return new c(e.$vscodeTextmateLocation,e.id,e.name,e.match,m._compileCaptures(e.captures,t,n));if(void 0===e.begin){e.repository&&(n=(0,r.mergeObjects)({},n,e.repository));let s=e.patterns;return void 0===s&&e.include&&(s=[{include:e.include}]),new u(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,m._compilePatterns(s,t,n))}return e.while?new d(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,m._compileCaptures(e.beginCaptures||e.captures,t,n),e.while,m._compileCaptures(e.whileCaptures||e.captures,t,n),m._compilePatterns(e.patterns,t,n)):new _(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,m._compileCaptures(e.beginCaptures||e.captures,t,n),e.end,m._compileCaptures(e.endCaptures||e.captures,t,n),e.applyEndPatternLast,m._compilePatterns(e.patterns,t,n))})),e.id}static _compileCaptures(e,t,n){let r=[];if(e){let s=0;for(const t in e){if("$vscodeTextmateLocation"===t)continue;const e=parseInt(t,10);e>s&&(s=e)}for(let e=0;e<=s;e++)r[e]=null;for(const s in e){if("$vscodeTextmateLocation"===s)continue;const o=parseInt(s,10);let a=0;e[s].patterns&&(a=m.getCompiledRuleId(e[s],t,n)),r[o]=m.createCaptureRule(t,e[s].$vscodeTextmateLocation,e[s].name,e[s].contentName,a)}}return r}static _compilePatterns(e,t,n){let r=[];if(e)for(let o=0,a=e.length;oe.substring(t.start,t.end)));return a.lastIndex=0,this.source.replace(a,((e,t)=>(0,r.escapeRegExpCharacters)(n[parseInt(t,10)]||"")))}_buildAnchorCache(){let e,t,n,r,s=[],o=[],a=[],i=[];for(e=0,t=this.source.length;ee.source));this._cached=new f(e,t,this._items.map((e=>e.ruleId)))}return this._cached}compileAG(e,t,n){return this._hasAnchors?t?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,n){let r=this._items.map((e=>e.resolveAnchors(t,n)));return new f(e,r,this._items.map((e=>e.ruleId)))}}t.RegExpSourceList=h;class f{regExps;rules;scanner;constructor(e,t,n){this.regExps=t,this.rules=n,this.scanner=e.createOnigScanner(t)}dispose(){"function"==typeof this.scanner.dispose&&this.scanner.dispose()}toString(){const e=[];for(let t=0,n=this.rules.length;t{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ThemeTrieElement=t.ThemeTrieElementRule=t.ColorMap=t.fontStyleToString=t.ParsedThemeRule=t.parseTheme=t.StyleAttributes=t.ScopeStack=t.Theme=void 0;const r=n(306);class s{_colorMap;_defaults;_root;static createFromRawTheme(e,t){return this.createFromParsedTheme(l(e),t)}static createFromParsedTheme(e,t){return function(e,t){e.sort(((e,t)=>{let n=(0,r.strcmp)(e.scope,t.scope);return 0!==n?n:(n=(0,r.strArrCmp)(e.parentScopes,t.parentScopes),0!==n?n:e.index-t.index)}));let n=0,o="#000000",a="#ffffff";for(;e.length>=1&&""===e[0].scope;){let t=e.shift();-1!==t.fontStyle&&(n=t.fontStyle),null!==t.foreground&&(o=t.foreground),null!==t.background&&(a=t.background)}let l=new u(t),c=new i(n,l.getId(o),l.getId(a)),m=new d(new _(0,null,-1,0,0),[]);for(let t=0,n=e.length;tthis._root.match(e)));constructor(e,t,n){this._colorMap=e,this._defaults=t,this._root=n}getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(null===e)return this._defaults;const t=e.scopeName,n=this._cachedMatchRoot.get(t).find((t=>function(e,t){if(null===t)return!0;let n=0,r=t[n];for(;e;){if(a(e.scopeName,r)){if(n++,n===t.length)return!0;r=t[n]}e=e.parent}return!1}(e.parent,t.parentScopes)));return n?new i(n.fontStyle,n.foreground,n.background):null}}t.Theme=s;class o{parent;scopeName;static push(e,t){for(const n of t)e=new o(e,n);return e}static from(...e){let t=null;for(let n=0;n1&&(_=r.slice(0,r.length-1),_.reverse()),n[s++]=new c(a,_,e,i,l,u)}}return n}t.StyleAttributes=i,t.parseTheme=l;class c{scope;parentScopes;index;fontStyle;foreground;background;constructor(e,t,n,r,s,o){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=s,this.background=o}}t.ParsedThemeRule=c,t.fontStyleToString=function(e){if(-1===e)return"not set";let t="";return 1&e&&(t+="italic "),2&e&&(t+="bold "),4&e&&(t+="underline "),8&e&&(t+="strikethrough "),""===t&&(t="none"),t.trim()};class u{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,n=e.length;te?console.log("how did this happen?"):this.scopeDepth=e,-1!==t&&(this.fontStyle=t),0!==n&&(this.foreground=n),0!==r&&(this.background=r)}}t.ThemeTrieElementRule=_;class d{_mainRule;_children;_rulesWithParentScopes;constructor(e,t=[],n={}){this._mainRule=e,this._children=n,this._rulesWithParentScopes=t}static _sortBySpecificity(e){return 1===e.length||e.sort(this._cmpBySpecificity),e}static _cmpBySpecificity(e,t){if(e.scopeDepth===t.scopeDepth){const n=e.parentScopes,r=t.parentScopes;let s=null===n?0:n.length,o=null===r?0:r.length;if(s===o)for(let e=0;e{"use strict";function n(e){return Array.isArray(e)?function(e){let t=[];for(let r=0,s=e.length;r{for(let n in t)e[n]=t[n]})),e},t.basename=function e(t){const n=~t.lastIndexOf("/")||~t.lastIndexOf("\\");return 0===n?t:~n==t.length-1?e(t.substring(0,t.length-1)):t.substr(1+~n)};let r=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g;function s(e,t){return et?1:0}t.RegexSource=class{static hasCaptures(e){return null!==e&&(r.lastIndex=0,r.test(e))}static replaceCaptures(e,t,n){return e.replace(r,((e,r,s,o)=>{let a=n[parseInt(r||s,10)];if(!a)return e;{let e=t.substring(a.start,a.end);for(;"."===e[0];)e=e.substring(1);switch(o){case"downcase":return e.toLowerCase();case"upcase":return e.toUpperCase();default:return e}}}))}},t.strcmp=s,t.strArrCmp=function(e,t){if(null===e&&null===t)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,r=t.length;if(n===r){for(let r=0;r{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.initTokenColorCustomizations=void 0;const r=n(398);t.initTokenColorCustomizations=function(e){const t=r.window.activeTextEditor?.document;_(a(t)||i(t)),e.subscriptions.push(r.window.onDidChangeActiveTextEditor((e=>{const t=e?.document;_(a(t)||i(t))}))),e.subscriptions.push(r.workspace.onDidOpenTextDocument((e=>{e==r.window.activeTextEditor?.document&&_(a(e)||i(e))}))),e.subscriptions.push(r.workspace.onDidChangeTextDocument((e=>{if(0==e.contentChanges.length)return;const t=e.document;r.languages.match(s,t)&&t==r.window.activeTextEditor?.document&&_(a(t))}))),e.subscriptions.push(r.workspace.onDidCloseTextDocument((e=>{e==r.window.activeTextEditor?.document&&_(null)})))};const s=[{pattern:"**/package.json",scheme:"file"},{pattern:"**/package.json",scheme:"vscode-vfs"}],o=[{language:"json-textmate",scheme:"file"},{language:"json-textmate",scheme:"vscode-vfs"}];function a(e){return e?r.languages.match(s,e)?e.uri:void 0:null}function i(e){return e?r.languages.match(o,e)?r.Uri.joinPath(e.uri,"../../package.json"):void 0:null}let l=!1,c=!1;const u="[tokenColorCustomizations_bak_JSON_TextMate";async function _(e){const t=r.workspace.name?r.ConfigurationTarget.Workspace:r.ConfigurationTarget.Global,n=r.workspace.name?"workspaceValue":"globalValue";if(e&&"untitled"!=e.scheme)try{const s=await r.workspace.openTextDocument(e),o=await JSON.parse(s?.getText()),a=o?.contributes?.configurationDefaults?.["editor.tokenColorCustomizations"];if(a){const e=r.workspace.getConfiguration("editor"),s=e.inspect("tokenColorCustomizations")[n]??{},o=s[u]??s;return delete o[u],a[u]=o,e.update("tokenColorCustomizations",a,t),void(c=!0)}}catch(e){if(c&&0==l){const t=`Failed to parse package.json:\n${e}`,n="Ignore";r.window.showWarningMessage(t,n).then((e=>(e==n&&(l=!0),!0)))}}const s=r.workspace.getConfiguration("editor"),o=(s.inspect("tokenColorCustomizations")[n]??{})[u];if(void 0!==o){const e=Object.keys(o).length;s.update("tokenColorCustomizations",e?o:void 0,t)}}},486:function(e){var t;t=()=>{return e={770:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setDefaultDebugCall=t.createOnigScanner=t.createOnigString=t.loadWASM=t.OnigScanner=t.OnigString=void 0;const s=r(n(418));let o=null,a=!1;class i{static _utf8ByteLength(e){let t=0;for(let n=0,r=e.length;n=55296&&s<=56319&&n+1=56320&&t<=57343&&(o=65536+(s-55296<<10)|t-56320,a=!0)}t+=o<=127?1:o<=2047?2:o<=65535?3:4,a&&n++}return t}constructor(e){const t=e.length,n=i._utf8ByteLength(e),r=n!==t,s=r?new Uint32Array(t+1):null;r&&(s[t]=n);const o=r?new Uint32Array(n+1):null;r&&(o[n]=t);const a=new Uint8Array(n);let l=0;for(let n=0;n=55296&&i<=56319&&n+1=56320&&t<=57343&&(c=65536+(i-55296<<10)|t-56320,u=!0)}r&&(s[n]=l,u&&(s[n+1]=l),c<=127?o[l+0]=n:c<=2047?(o[l+0]=n,o[l+1]=n):c<=65535?(o[l+0]=n,o[l+1]=n,o[l+2]=n):(o[l+0]=n,o[l+1]=n,o[l+2]=n,o[l+3]=n)),c<=127?a[l++]=c:c<=2047?(a[l++]=192|(1984&c)>>>6,a[l++]=128|(63&c)>>>0):c<=65535?(a[l++]=224|(61440&c)>>>12,a[l++]=128|(4032&c)>>>6,a[l++]=128|(63&c)>>>0):(a[l++]=240|(1835008&c)>>>18,a[l++]=128|(258048&c)>>>12,a[l++]=128|(4032&c)>>>6,a[l++]=128|(63&c)>>>0),u&&n++}this.utf16Length=t,this.utf8Length=n,this.utf16Value=e,this.utf8Value=a,this.utf16OffsetToUtf8=s,this.utf8OffsetToUtf16=o}createString(e){const t=e._omalloc(this.utf8Length);return e.HEAPU8.set(this.utf8Value,t),t}}class l{constructor(e){if(this.id=++l.LAST_ID,!o)throw new Error("Must invoke loadWASM first.");this._onigBinding=o,this.content=e;const t=new i(e);this.utf16Length=t.utf16Length,this.utf8Length=t.utf8Length,this.utf16OffsetToUtf8=t.utf16OffsetToUtf8,this.utf8OffsetToUtf16=t.utf8OffsetToUtf16,this.utf8Length<1e4&&!l._sharedPtrInUse?(l._sharedPtr||(l._sharedPtr=o._omalloc(1e4)),l._sharedPtrInUse=!0,o.HEAPU8.set(t.utf8Value,l._sharedPtr),this.ptr=l._sharedPtr):this.ptr=t.createString(o)}convertUtf8OffsetToUtf16(e){return this.utf8OffsetToUtf16?e<0?0:e>this.utf8Length?this.utf16Length:this.utf8OffsetToUtf16[e]:e}convertUtf16OffsetToUtf8(e){return this.utf16OffsetToUtf8?e<0?0:e>this.utf16Length?this.utf8Length:this.utf16OffsetToUtf8[e]:e}dispose(){this.ptr===l._sharedPtr?l._sharedPtrInUse=!1:this._onigBinding._ofree(this.ptr)}}t.OnigString=l,l.LAST_ID=0,l._sharedPtr=0,l._sharedPtrInUse=!1;class c{constructor(e){if(!o)throw new Error("Must invoke loadWASM first.");const t=[],n=[];for(let r=0,s=e.length;rWebAssembly.instantiateStreaming(e,t)}(r):function(e){return async t=>{const n=await e.arrayBuffer();return WebAssembly.instantiate(n,t)}}(r):function(e){return t=>WebAssembly.instantiate(e,t)}(r)}return _=new Promise(((e,t)=>{r=e,a=t})),function(e,t,n,r){(0,s.default)({print:t,instantiateWasm:(t,n)=>{if("undefined"==typeof performance){const e=()=>Date.now();t.env.emscripten_get_now=e,t.wasi_snapshot_preview1.emscripten_get_now=e}return e(t).then((e=>n(e.instance)),r),{}}}).then((e=>{o=e,n()}))}(t,n,r,a),_},t.createOnigString=function(e){return new l(e)},t.createOnigScanner=function(e){return new c(e)},t.setDefaultDebugCall=function(e){a=e}},418:e=>{var t=("undefined"!=typeof document&&document.currentScript&&document.currentScript.src,function(e){var t,n,r=void 0!==(e=e||{})?e:{};r.ready=new Promise((function(e,r){t=e,n=r}));var s,o=Object.assign({},r),a=[];s=function(e){let t;return"function"==typeof readbuffer?new Uint8Array(readbuffer(e)):(t=read(e,"binary"),function(e,t){e||v(void 0)}("object"==typeof t),t)},"undefined"!=typeof scriptArgs?a=scriptArgs:void 0!==arguments&&(a=arguments),"undefined"!=typeof onig_print&&("undefined"==typeof console&&(console={}),console.log=onig_print,console.warn=console.error="undefined"!=typeof printErr?printErr:onig_print);var i,l,c=r.print||console.log.bind(console),u=r.printErr||console.warn.bind(console);Object.assign(r,o),o=null,r.arguments&&(a=r.arguments),r.thisProgram&&r.thisProgram,r.quit&&r.quit,r.wasmBinary&&(i=r.wasmBinary),r.noExitRuntime,"object"!=typeof WebAssembly&&v("no native wasm support detected");var _,d,m,p=!1,h="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function f(e,t,n){for(var r=t+n,s=t;e[s]&&!(s>=r);)++s;if(s-t>16&&e.buffer&&h)return h.decode(e.subarray(t,s));for(var o="";t>10,56320|1023&c)}}else o+=String.fromCharCode((31&a)<<6|i)}else o+=String.fromCharCode(a)}return o}function g(e){_=e,r.HEAP8=new Int8Array(e),r.HEAP16=new Int16Array(e),r.HEAP32=new Int32Array(e),r.HEAPU8=d=new Uint8Array(e),r.HEAPU16=new Uint16Array(e),r.HEAPU32=m=new Uint32Array(e),r.HEAPF32=new Float32Array(e),r.HEAPF64=new Float64Array(e)}r.INITIAL_MEMORY;var y=[],b=[],w=[];function S(e){y.unshift(e)}function E(e){w.unshift(e)}var N=0,I=null,M=null;function v(e){r.onAbort&&r.onAbort(e),u(e="Aborted("+e+")"),p=!0,e+=". Build with -sASSERTIONS for more info.";var t=new WebAssembly.RuntimeError(e);throw n(t),t}var R,T;function C(e){return e.startsWith("data:application/octet-stream;base64,")}function A(e){try{if(e==R&&i)return new Uint8Array(i);if(s)return s(e);throw"both async and sync fetching of the wasm failed"}catch(e){v(e)}}function P(e){for(;e.length>0;)e.shift()(r)}function k(e){try{return l.grow(e-_.byteLength+65535>>>16),g(l.buffer),1}catch(e){}}C(R="onig.wasm")||(R=function(e){return r.locateFile?r.locateFile(e,""):""+e}(R)),T="undefined"!=typeof dateNow?dateNow:()=>performance.now();var x=[null,[],[]];function F(e,t){var n=x[e];0===t||10===t?((1===e?c:u)(f(n,0)),n.length=0):n.push(t)}var O,D={emscripten_get_now:T,emscripten_memcpy_big:function(e,t,n){d.copyWithin(e,t,t+n)},emscripten_resize_heap:function(e){var t,n=d.length,r=2147483648;if((e>>>=0)>r)return!1;for(var s=1;s<=4;s*=2){var o=n*(1+.2/s);if(o=Math.min(o,e+100663296),k(Math.min(r,(t=Math.max(e,o))+(65536-t%65536)%65536)))return!0}return!1},fd_write:function(e,t,n,r){for(var s=0,o=0;o>2],i=m[t+4>>2];t+=8;for(var l=0;l>2]=s,0}};function L(e){function n(){O||(O=!0,r.calledRun=!0,p||(P(b),t(r),r.onRuntimeInitialized&&r.onRuntimeInitialized(),function(){if(r.postRun)for("function"==typeof r.postRun&&(r.postRun=[r.postRun]);r.postRun.length;)E(r.postRun.shift());P(w)}()))}e=e||a,N>0||(function(){if(r.preRun)for("function"==typeof r.preRun&&(r.preRun=[r.preRun]);r.preRun.length;)S(r.preRun.shift());P(y)}(),N>0||(r.setStatus?(r.setStatus("Running..."),setTimeout((function(){setTimeout((function(){r.setStatus("")}),1),n()}),1)):n()))}if(function(){var e={env:D,wasi_snapshot_preview1:D};function t(e,t){var n=e.exports;r.asm=n,g((l=r.asm.memory).buffer),r.asm.__indirect_function_table,function(e){b.unshift(e)}(r.asm.__wasm_call_ctors),function(e){if(N--,r.monitorRunDependencies&&r.monitorRunDependencies(N),0==N&&(null!==I&&(clearInterval(I),I=null),M)){var t=M;M=null,t()}}()}function s(e){t(e.instance)}function o(t){return Promise.resolve().then((function(){return A(R)})).then((function(t){return WebAssembly.instantiate(t,e)})).then((function(e){return e})).then(t,(function(e){u("failed to asynchronously prepare wasm: "+e),v(e)}))}if(N++,r.monitorRunDependencies&&r.monitorRunDependencies(N),r.instantiateWasm)try{return r.instantiateWasm(e,t)}catch(e){u("Module.instantiateWasm callback failed with error: "+e),n(e)}(i||"function"!=typeof WebAssembly.instantiateStreaming||C(R)||"function"!=typeof fetch?o(s):fetch(R,{credentials:"same-origin"}).then((function(t){return WebAssembly.instantiateStreaming(t,e).then(s,(function(e){return u("wasm streaming compile failed: "+e),u("falling back to ArrayBuffer instantiation"),o(s)}))}))).catch(n)}(),r.___wasm_call_ctors=function(){return(r.___wasm_call_ctors=r.asm.__wasm_call_ctors).apply(null,arguments)},r.___errno_location=function(){return(r.___errno_location=r.asm.__errno_location).apply(null,arguments)},r._omalloc=function(){return(r._omalloc=r.asm.omalloc).apply(null,arguments)},r._ofree=function(){return(r._ofree=r.asm.ofree).apply(null,arguments)},r._getLastOnigError=function(){return(r._getLastOnigError=r.asm.getLastOnigError).apply(null,arguments)},r._createOnigScanner=function(){return(r._createOnigScanner=r.asm.createOnigScanner).apply(null,arguments)},r._freeOnigScanner=function(){return(r._freeOnigScanner=r.asm.freeOnigScanner).apply(null,arguments)},r._findNextOnigScannerMatch=function(){return(r._findNextOnigScannerMatch=r.asm.findNextOnigScannerMatch).apply(null,arguments)},r._findNextOnigScannerMatchDbg=function(){return(r._findNextOnigScannerMatchDbg=r.asm.findNextOnigScannerMatchDbg).apply(null,arguments)},r.stackSave=function(){return(r.stackSave=r.asm.stackSave).apply(null,arguments)},r.stackRestore=function(){return(r.stackRestore=r.asm.stackRestore).apply(null,arguments)},r.stackAlloc=function(){return(r.stackAlloc=r.asm.stackAlloc).apply(null,arguments)},r.dynCall_jiji=function(){return(r.dynCall_jiji=r.asm.dynCall_jiji).apply(null,arguments)},r.UTF8ToString=function(e,t){return e?f(d,e,t):""},M=function e(){O||L(),O||(M=e)},r.preInit)for("function"==typeof r.preInit&&(r.preInit=[r.preInit]);r.preInit.length>0;)r.preInit.pop()();return L(),e.ready});e.exports=t}},t={},function n(r){var s=t[r];if(void 0!==s)return s.exports;var o=t[r]={exports:{}};return e[r].call(o.exports,o,o.exports,n),o.exports}(770);var e,t},e.exports=t()},812:(module,__unused_webpack_exports,__webpack_require__)=>{var __dirname="/",Module=void 0!==Module?Module:{},TreeSitter=function(){var initPromise,document="object"==typeof window?{currentScript:window.document.currentScript}:null;class Parser{constructor(){this.initialize()}initialize(){throw new Error("cannot construct a Parser before calling `init()`")}static init(moduleOptions){return initPromise||(Module=Object.assign({},Module,moduleOptions),initPromise=new Promise((resolveInitPromise=>{var moduleOverrides=Object.assign({},Module),arguments_=[],thisProgram="./this.program",quit_=(e,t)=>{throw t},ENVIRONMENT_IS_WEB="object"==typeof window,ENVIRONMENT_IS_WORKER="function"==typeof importScripts,ENVIRONMENT_IS_NODE="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,scriptDirectory="",read_,readAsync,readBinary,setWindowTitle;function locateFile(e){return Module.locateFile?Module.locateFile(e,scriptDirectory):scriptDirectory+e}function logExceptionOnExit(e){e instanceof ExitStatus||err("exiting due to exception: "+e)}if(ENVIRONMENT_IS_NODE){var fs=__webpack_require__(75),nodePath=__webpack_require__(975);scriptDirectory=ENVIRONMENT_IS_WORKER?nodePath.dirname(scriptDirectory)+"/":__dirname+"/",read_=(e,t)=>(e=isFileURI(e)?new URL(e):nodePath.normalize(e),fs.readFileSync(e,t?void 0:"utf8")),readBinary=e=>{var t=read_(e,!0);return t.buffer||(t=new Uint8Array(t)),t},readAsync=(e,t,n)=>{e=isFileURI(e)?new URL(e):nodePath.normalize(e),fs.readFile(e,(function(e,r){e?n(e):t(r.buffer)}))},process.argv.length>1&&(thisProgram=process.argv[1].replace(/\\/g,"/")),arguments_=process.argv.slice(2),module.exports=Module,quit_=(e,t)=>{if(keepRuntimeAlive())throw process.exitCode=e,t;logExceptionOnExit(t),process.exit(e)},Module.inspect=function(){return"[Emscripten Module object]"}}else(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)&&(ENVIRONMENT_IS_WORKER?scriptDirectory=self.location.href:void 0!==document&&document.currentScript&&(scriptDirectory=document.currentScript.src),scriptDirectory=0!==scriptDirectory.indexOf("blob:")?scriptDirectory.substr(0,scriptDirectory.replace(/[?#].*/,"").lastIndexOf("/")+1):"",read_=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},ENVIRONMENT_IS_WORKER&&(readBinary=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),readAsync=(e,t,n)=>{var r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType="arraybuffer",r.onload=()=>{200==r.status||0==r.status&&r.response?t(r.response):n()},r.onerror=n,r.send(null)},setWindowTitle=e=>document.title=e);var out=Module.print||console.log.bind(console),err=Module.printErr||console.warn.bind(console);Object.assign(Module,moduleOverrides),moduleOverrides=null,Module.arguments&&(arguments_=Module.arguments),Module.thisProgram&&(thisProgram=Module.thisProgram),Module.quit&&(quit_=Module.quit);var STACK_ALIGN=16,dynamicLibraries=Module.dynamicLibraries||[],wasmBinary;Module.wasmBinary&&(wasmBinary=Module.wasmBinary);var noExitRuntime=Module.noExitRuntime||!0,wasmMemory;"object"!=typeof WebAssembly&&abort("no native wasm support detected");var ABORT=!1,EXITSTATUS,UTF8Decoder="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,buffer,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function UTF8ArrayToString(e,t,n){for(var r=t+n,s=t;e[s]&&!(s>=r);)++s;if(s-t>16&&e.buffer&&UTF8Decoder)return UTF8Decoder.decode(e.subarray(t,s));for(var o="";t>10,56320|1023&c)}}else o+=String.fromCharCode((31&a)<<6|i)}else o+=String.fromCharCode(a)}return o}function UTF8ToString(e,t){return e?UTF8ArrayToString(HEAPU8,e,t):""}function stringToUTF8Array(e,t,n,r){if(!(r>0))return 0;for(var s=n,o=n+r-1,a=0;a=55296&&i<=57343&&(i=65536+((1023&i)<<10)|1023&e.charCodeAt(++a)),i<=127){if(n>=o)break;t[n++]=i}else if(i<=2047){if(n+1>=o)break;t[n++]=192|i>>6,t[n++]=128|63&i}else if(i<=65535){if(n+2>=o)break;t[n++]=224|i>>12,t[n++]=128|i>>6&63,t[n++]=128|63&i}else{if(n+3>=o)break;t[n++]=240|i>>18,t[n++]=128|i>>12&63,t[n++]=128|i>>6&63,t[n++]=128|63&i}}return t[n]=0,n-s}function stringToUTF8(e,t,n){return stringToUTF8Array(e,HEAPU8,t,n)}function lengthBytesUTF8(e){for(var t=0,n=0;n=55296&&r<=57343?(t+=4,++n):t+=3}return t}function updateGlobalBufferAndViews(e){buffer=e,Module.HEAP8=HEAP8=new Int8Array(e),Module.HEAP16=HEAP16=new Int16Array(e),Module.HEAP32=HEAP32=new Int32Array(e),Module.HEAPU8=HEAPU8=new Uint8Array(e),Module.HEAPU16=HEAPU16=new Uint16Array(e),Module.HEAPU32=HEAPU32=new Uint32Array(e),Module.HEAPF32=HEAPF32=new Float32Array(e),Module.HEAPF64=HEAPF64=new Float64Array(e)}var INITIAL_MEMORY=Module.INITIAL_MEMORY||33554432;wasmMemory=Module.wasmMemory?Module.wasmMemory:new WebAssembly.Memory({initial:INITIAL_MEMORY/65536,maximum:32768}),wasmMemory&&(buffer=wasmMemory.buffer),INITIAL_MEMORY=buffer.byteLength,updateGlobalBufferAndViews(buffer);var wasmTable=new WebAssembly.Table({initial:20,element:"anyfunc"}),__ATPRERUN__=[],__ATINIT__=[],__ATMAIN__=[],__ATPOSTRUN__=[],__RELOC_FUNCS__=[],runtimeInitialized=!1;function keepRuntimeAlive(){return noExitRuntime}function preRun(){if(Module.preRun)for("function"==typeof Module.preRun&&(Module.preRun=[Module.preRun]);Module.preRun.length;)addOnPreRun(Module.preRun.shift());callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=!0,callRuntimeCallbacks(__RELOC_FUNCS__),callRuntimeCallbacks(__ATINIT__)}function preMain(){callRuntimeCallbacks(__ATMAIN__)}function postRun(){if(Module.postRun)for("function"==typeof Module.postRun&&(Module.postRun=[Module.postRun]);Module.postRun.length;)addOnPostRun(Module.postRun.shift());callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(e){__ATPRERUN__.unshift(e)}function addOnInit(e){__ATINIT__.unshift(e)}function addOnPostRun(e){__ATPOSTRUN__.unshift(e)}var runDependencies=0,runDependencyWatcher=null,dependenciesFulfilled=null;function addRunDependency(e){runDependencies++,Module.monitorRunDependencies&&Module.monitorRunDependencies(runDependencies)}function removeRunDependency(e){if(runDependencies--,Module.monitorRunDependencies&&Module.monitorRunDependencies(runDependencies),0==runDependencies&&(null!==runDependencyWatcher&&(clearInterval(runDependencyWatcher),runDependencyWatcher=null),dependenciesFulfilled)){var t=dependenciesFulfilled;dependenciesFulfilled=null,t()}}function abort(e){throw Module.onAbort&&Module.onAbort(e),err(e="Aborted("+e+")"),ABORT=!0,EXITSTATUS=1,e+=". Build with -sASSERTIONS for more info.",new WebAssembly.RuntimeError(e)}var dataURIPrefix="data:application/octet-stream;base64,",wasmBinaryFile,tempDouble,tempI64;function isDataURI(e){return e.startsWith(dataURIPrefix)}function isFileURI(e){return e.startsWith("file://")}function getBinary(e){try{if(e==wasmBinaryFile&&wasmBinary)return new Uint8Array(wasmBinary);if(readBinary)return readBinary(e);throw"both async and sync fetching of the wasm failed"}catch(e){abort(e)}}function getBinaryPromise(){if(!wasmBinary&&(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)){if("function"==typeof fetch&&!isFileURI(wasmBinaryFile))return fetch(wasmBinaryFile,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+wasmBinaryFile+"'";return e.arrayBuffer()})).catch((function(){return getBinary(wasmBinaryFile)}));if(readAsync)return new Promise((function(e,t){readAsync(wasmBinaryFile,(function(t){e(new Uint8Array(t))}),t)}))}return Promise.resolve().then((function(){return getBinary(wasmBinaryFile)}))}function createWasm(){var e={env:asmLibraryArg,wasi_snapshot_preview1:asmLibraryArg,"GOT.mem":new Proxy(asmLibraryArg,GOTHandler),"GOT.func":new Proxy(asmLibraryArg,GOTHandler)};function t(e,t){var n=e.exports;n=relocateExports(n,1024);var r=getDylinkMetadata(t);r.neededDynlibs&&(dynamicLibraries=r.neededDynlibs.concat(dynamicLibraries)),mergeLibSymbols(n,"main"),Module.asm=n,addOnInit(Module.asm.__wasm_call_ctors),__RELOC_FUNCS__.push(Module.asm.__wasm_apply_data_relocs),removeRunDependency("wasm-instantiate")}function n(e){t(e.instance,e.module)}function r(t){return getBinaryPromise().then((function(t){return WebAssembly.instantiate(t,e)})).then((function(e){return e})).then(t,(function(e){err("failed to asynchronously prepare wasm: "+e),abort(e)}))}if(addRunDependency("wasm-instantiate"),Module.instantiateWasm)try{return Module.instantiateWasm(e,t)}catch(e){return err("Module.instantiateWasm callback failed with error: "+e),!1}return wasmBinary||"function"!=typeof WebAssembly.instantiateStreaming||isDataURI(wasmBinaryFile)||isFileURI(wasmBinaryFile)||ENVIRONMENT_IS_NODE||"function"!=typeof fetch?r(n):fetch(wasmBinaryFile,{credentials:"same-origin"}).then((function(t){return WebAssembly.instantiateStreaming(t,e).then(n,(function(e){return err("wasm streaming compile failed: "+e),err("falling back to ArrayBuffer instantiation"),r(n)}))})),{}}wasmBinaryFile="tree-sitter.wasm",isDataURI(wasmBinaryFile)||(wasmBinaryFile=locateFile(wasmBinaryFile));var ASM_CONSTS={};function ExitStatus(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}var GOT={},CurrentModuleWeakSymbols=new Set([]),GOTHandler={get:function(e,t){var n=GOT[t];return n||(n=GOT[t]=new WebAssembly.Global({value:"i32",mutable:!0})),CurrentModuleWeakSymbols.has(t)||(n.required=!0),n}};function callRuntimeCallbacks(e){for(;e.length>0;)e.shift()(Module)}function getDylinkMetadata(e){var t=0,n=0;function r(){for(var n=0,r=1;;){var s=e[t++];if(n+=(127&s)*r,r*=128,!(128&s))break}return n}function s(){var n=r();return UTF8ArrayToString(e,(t+=n)-n,n)}function o(e,t){if(e)throw new Error(t)}var a="dylink.0";if(e instanceof WebAssembly.Module){var i=WebAssembly.Module.customSections(e,a);0===i.length&&(a="dylink",i=WebAssembly.Module.customSections(e,a)),o(0===i.length,"need dylink section"),n=(e=new Uint8Array(i[0])).length}else{o(!(1836278016==new Uint32Array(new Uint8Array(e.subarray(0,24)).buffer)[0]),"need to see wasm magic number"),o(0!==e[8],"need the dylink section to be first"),t=9;var l=r();n=t+l,a=s()}var c={neededDynlibs:[],tlsExports:new Set,weakImports:new Set};if("dylink"==a){c.memorySize=r(),c.memoryAlign=r(),c.tableSize=r(),c.tableAlign=r();for(var u=r(),_=0;_>0];case"i16":return HEAP16[e>>1];case"i32":case"i64":return HEAP32[e>>2];case"float":return HEAPF32[e>>2];case"double":return HEAPF64[e>>3];case"*":return HEAPU32[e>>2];default:abort("invalid type for getValue: "+t)}return null}function asmjsMangle(e){return 0==e.indexOf("dynCall_")||["stackAlloc","stackSave","stackRestore","getTempRet0","setTempRet0"].includes(e)?e:"_"+e}function mergeLibSymbols(e,t){for(var n in e)if(e.hasOwnProperty(n)){asmLibraryArg.hasOwnProperty(n)||(asmLibraryArg[n]=e[n]);var r=asmjsMangle(n);Module.hasOwnProperty(r)||(Module[r]=e[n]),"__main_argc_argv"==n&&(Module._main=e[n])}}var LDSO={loadedLibsByName:{},loadedLibsByHandle:{}};function dynCallLegacy(e,t,n){var r=Module["dynCall_"+e];return n&&n.length?r.apply(null,[t].concat(n)):r.call(null,t)}var wasmTableMirror=[];function getWasmTableEntry(e){var t=wasmTableMirror[e];return t||(e>=wasmTableMirror.length&&(wasmTableMirror.length=e+1),wasmTableMirror[e]=t=wasmTable.get(e)),t}function dynCall(e,t,n){return e.includes("j")?dynCallLegacy(e,t,n):getWasmTableEntry(t).apply(null,n)}function createInvokeFunction(e){return function(){var t=stackSave();try{return dynCall(e,arguments[0],Array.prototype.slice.call(arguments,1))}catch(e){if(stackRestore(t),e!==e+0)throw e;_setThrew(1,0)}}}var ___heap_base=78144;function zeroMemory(e,t){return HEAPU8.fill(0,e,e+t),e}function getMemory(e){if(runtimeInitialized)return zeroMemory(_malloc(e),e);var t=___heap_base,n=t+e+15&-16;return ___heap_base=n,GOT.__heap_base.value=n,t}function isInternalSym(e){return["__cpp_exception","__c_longjmp","__wasm_apply_data_relocs","__dso_handle","__tls_size","__tls_align","__set_stack_limits","_emscripten_tls_init","__wasm_init_tls","__wasm_call_ctors","__start_em_asm","__stop_em_asm"].includes(e)}function uleb128Encode(e,t){e<128?t.push(e):t.push(e%128|128,e>>7)}function sigToWasmTypes(e){for(var t={i:"i32",j:"i32",f:"f32",d:"f64",p:"i32"},n={parameters:[],results:"v"==e[0]?[]:[t[e[0]]]},r=1;r>0];if(firstLoad){var memAlign=Math.pow(2,metadata.memoryAlign);memAlign=Math.max(memAlign,STACK_ALIGN);var memoryBase=metadata.memorySize?alignMemory(getMemory(metadata.memorySize+memAlign),memAlign):0,tableBase=metadata.tableSize?wasmTable.length:0;handle&&(HEAP8[handle+12>>0]=1,HEAPU32[handle+16>>2]=memoryBase,HEAP32[handle+20>>2]=metadata.memorySize,HEAPU32[handle+24>>2]=tableBase,HEAP32[handle+28>>2]=metadata.tableSize)}else memoryBase=HEAPU32[handle+16>>2],tableBase=HEAPU32[handle+24>>2];var tableGrowthNeeded=tableBase+metadata.tableSize-wasmTable.length,moduleExports;function resolveSymbol(e){var t=resolveGlobalSymbol(e,!1);return t||(t=moduleExports[e]),t}tableGrowthNeeded>0&&wasmTable.grow(tableGrowthNeeded);var proxyHandler={get:function(e,t){switch(t){case"__memory_base":return memoryBase;case"__table_base":return tableBase}return t in asmLibraryArg?asmLibraryArg[t]:(t in e||(e[t]=function(){return n||(n=resolveSymbol(t)),n.apply(null,arguments)}),e[t]);var n}},proxy=new Proxy({},proxyHandler),info={"GOT.mem":new Proxy({},GOTHandler),"GOT.func":new Proxy({},GOTHandler),env:proxy,wasi_snapshot_preview1:proxy};function postInstantiation(instance){function addEmAsm(addr,body){for(var args=[],arity=0;arity<16&&-1!=body.indexOf("$"+arity);arity++)args.push("$"+arity);args=args.join(",");var func="("+args+" ) => { "+body+"};";ASM_CONSTS[start]=eval(func)}if(updateTableMap(tableBase,metadata.tableSize),moduleExports=relocateExports(instance.exports,memoryBase),flags.allowUndefined||reportUndefinedSymbols(),"__start_em_asm"in moduleExports)for(var start=moduleExports.__start_em_asm,stop=moduleExports.__stop_em_asm;startt(new Uint8Array(e))),n)}));if(!readBinary)throw new Error(e+": file not found, and synchronous loading of external files is not available");return readBinary(e)}function o(){if("undefined"!=typeof preloadedWasm&&preloadedWasm[e]){var r=preloadedWasm[e];return t.loadAsync?Promise.resolve(r):r}return t.loadAsync?s(e).then((function(e){return loadWebAssemblyModule(e,t,n)})):loadWebAssemblyModule(s(e),t,n)}function a(t){r.global&&mergeLibSymbols(t,e),r.module=t}return r={refcount:t.nodelete?1/0:1,name:e,module:"loading",global:t.global},LDSO.loadedLibsByName[e]=r,n&&(LDSO.loadedLibsByHandle[n]=r),t.loadAsync?o().then((function(e){return a(e),!0})):(a(o()),!0)}function reportUndefinedSymbols(){for(var e in GOT)if(0==GOT[e].value){var t=resolveGlobalSymbol(e,!0);if(!t&&!GOT[e].required)continue;if("function"==typeof t)GOT[e].value=addFunction(t,t.sig);else{if("number"!=typeof t)throw new Error("bad export type for `"+e+"`: "+typeof t);GOT[e].value=t}}}function preloadDylibs(){dynamicLibraries.length?(addRunDependency("preloadDylibs"),dynamicLibraries.reduce((function(e,t){return e.then((function(){return loadDynamicLibrary(t,{loadAsync:!0,global:!0,nodelete:!0,allowUndefined:!0})}))}),Promise.resolve()).then((function(){reportUndefinedSymbols(),removeRunDependency("preloadDylibs")}))):reportUndefinedSymbols()}function setValue(e,t,n="i8"){switch(n.endsWith("*")&&(n="*"),n){case"i1":case"i8":HEAP8[e>>0]=t;break;case"i16":HEAP16[e>>1]=t;break;case"i32":HEAP32[e>>2]=t;break;case"i64":tempI64=[t>>>0,(tempDouble=t,+Math.abs(tempDouble)>=1?tempDouble>0?(0|Math.min(+Math.floor(tempDouble/4294967296),4294967295))>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[e>>2]=tempI64[0],HEAP32[e+4>>2]=tempI64[1];break;case"float":HEAPF32[e>>2]=t;break;case"double":HEAPF64[e>>3]=t;break;case"*":HEAPU32[e>>2]=t;break;default:abort("invalid type for setValue: "+n)}}var ___memory_base=new WebAssembly.Global({value:"i32",mutable:!1},1024),___stack_pointer=new WebAssembly.Global({value:"i32",mutable:!0},78144),___table_base=new WebAssembly.Global({value:"i32",mutable:!1},1),nowIsMonotonic=!0,_emscripten_get_now;function __emscripten_get_now_is_monotonic(){return nowIsMonotonic}function _abort(){abort("")}function _emscripten_date_now(){return Date.now()}function _emscripten_memcpy_big(e,t,n){HEAPU8.copyWithin(e,t,t+n)}function getHeapMax(){return 2147483648}function emscripten_realloc_buffer(e){try{return wasmMemory.grow(e-buffer.byteLength+65535>>>16),updateGlobalBufferAndViews(wasmMemory.buffer),1}catch(e){}}function _emscripten_resize_heap(e){var t=HEAPU8.length;e>>>=0;var n,r=getHeapMax();if(e>r)return!1;for(var s=1;s<=4;s*=2){var o=t*(1+.2/s);if(o=Math.min(o,e+100663296),emscripten_realloc_buffer(Math.min(r,(n=Math.max(e,o))+(65536-n%65536)%65536)))return!0}return!1}__emscripten_get_now_is_monotonic.sig="i",Module._abort=_abort,_abort.sig="v",_emscripten_date_now.sig="d",_emscripten_get_now=ENVIRONMENT_IS_NODE?()=>{var e=process.hrtime();return 1e3*e[0]+e[1]/1e6}:()=>performance.now(),_emscripten_get_now.sig="d",_emscripten_memcpy_big.sig="vppp",_emscripten_resize_heap.sig="ip";var SYSCALLS={DEFAULT_POLLMASK:5,calculateAt:function(e,t,n){if(PATH.isAbs(t))return t;var r;if(r=-100===e?FS.cwd():SYSCALLS.getStreamFromFD(e).path,0==t.length){if(!n)throw new FS.ErrnoError(44);return r}return PATH.join2(r,t)},doStat:function(e,t,n){try{var r=e(t)}catch(e){if(e&&e.node&&PATH.normalize(t)!==PATH.normalize(FS.getPath(e.node)))return-54;throw e}HEAP32[n>>2]=r.dev,HEAP32[n+8>>2]=r.ino,HEAP32[n+12>>2]=r.mode,HEAPU32[n+16>>2]=r.nlink,HEAP32[n+20>>2]=r.uid,HEAP32[n+24>>2]=r.gid,HEAP32[n+28>>2]=r.rdev,tempI64=[r.size>>>0,(tempDouble=r.size,+Math.abs(tempDouble)>=1?tempDouble>0?(0|Math.min(+Math.floor(tempDouble/4294967296),4294967295))>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[n+40>>2]=tempI64[0],HEAP32[n+44>>2]=tempI64[1],HEAP32[n+48>>2]=4096,HEAP32[n+52>>2]=r.blocks;var s=r.atime.getTime(),o=r.mtime.getTime(),a=r.ctime.getTime();return tempI64=[Math.floor(s/1e3)>>>0,(tempDouble=Math.floor(s/1e3),+Math.abs(tempDouble)>=1?tempDouble>0?(0|Math.min(+Math.floor(tempDouble/4294967296),4294967295))>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[n+56>>2]=tempI64[0],HEAP32[n+60>>2]=tempI64[1],HEAPU32[n+64>>2]=s%1e3*1e3,tempI64=[Math.floor(o/1e3)>>>0,(tempDouble=Math.floor(o/1e3),+Math.abs(tempDouble)>=1?tempDouble>0?(0|Math.min(+Math.floor(tempDouble/4294967296),4294967295))>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[n+72>>2]=tempI64[0],HEAP32[n+76>>2]=tempI64[1],HEAPU32[n+80>>2]=o%1e3*1e3,tempI64=[Math.floor(a/1e3)>>>0,(tempDouble=Math.floor(a/1e3),+Math.abs(tempDouble)>=1?tempDouble>0?(0|Math.min(+Math.floor(tempDouble/4294967296),4294967295))>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[n+88>>2]=tempI64[0],HEAP32[n+92>>2]=tempI64[1],HEAPU32[n+96>>2]=a%1e3*1e3,tempI64=[r.ino>>>0,(tempDouble=r.ino,+Math.abs(tempDouble)>=1?tempDouble>0?(0|Math.min(+Math.floor(tempDouble/4294967296),4294967295))>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[n+104>>2]=tempI64[0],HEAP32[n+108>>2]=tempI64[1],0},doMsync:function(e,t,n,r,s){if(!FS.isFile(t.node.mode))throw new FS.ErrnoError(43);if(2&r)return 0;var o=HEAPU8.slice(e,e+n);FS.msync(t,o,s,n,r)},varargs:void 0,get:function(){return SYSCALLS.varargs+=4,HEAP32[SYSCALLS.varargs-4>>2]},getStr:function(e){return UTF8ToString(e)},getStreamFromFD:function(e){var t=FS.getStream(e);if(!t)throw new FS.ErrnoError(8);return t}};function _proc_exit(e){EXITSTATUS=e,keepRuntimeAlive()||(Module.onExit&&Module.onExit(e),ABORT=!0),quit_(e,new ExitStatus(e))}function exitJS(e,t){EXITSTATUS=e,_proc_exit(e)}_proc_exit.sig="vi";var _exit=exitJS;function _fd_close(e){try{var t=SYSCALLS.getStreamFromFD(e);return FS.close(t),0}catch(e){if("undefined"==typeof FS||!(e instanceof FS.ErrnoError))throw e;return e.errno}}function convertI32PairToI53Checked(e,t){return t+2097152>>>0<4194305-!!e?(e>>>0)+4294967296*t:NaN}function _fd_seek(e,t,n,r,s){try{var o=convertI32PairToI53Checked(t,n);if(isNaN(o))return 61;var a=SYSCALLS.getStreamFromFD(e);return FS.llseek(a,o,r),tempI64=[a.position>>>0,(tempDouble=a.position,+Math.abs(tempDouble)>=1?tempDouble>0?(0|Math.min(+Math.floor(tempDouble/4294967296),4294967295))>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[s>>2]=tempI64[0],HEAP32[s+4>>2]=tempI64[1],a.getdents&&0===o&&0===r&&(a.getdents=null),0}catch(e){if("undefined"==typeof FS||!(e instanceof FS.ErrnoError))throw e;return e.errno}}function doWritev(e,t,n,r){for(var s=0,o=0;o>2],i=HEAPU32[t+4>>2];t+=8;var l=FS.write(e,HEAP8,a,i,r);if(l<0)return-1;s+=l,void 0!==r&&(r+=l)}return s}function _fd_write(e,t,n,r){try{var s=doWritev(SYSCALLS.getStreamFromFD(e),t,n);return HEAPU32[r>>2]=s,0}catch(e){if("undefined"==typeof FS||!(e instanceof FS.ErrnoError))throw e;return e.errno}}function _tree_sitter_log_callback(e,t){if(currentLogCallback){const n=UTF8ToString(t);currentLogCallback(n,0!==e)}}function _tree_sitter_parse_callback(e,t,n,r,s){var o=currentParseCallback(t,{row:n,column:r});"string"==typeof o?(setValue(s,o.length,"i32"),stringToUTF16(o,e,10240)):setValue(s,0,"i32")}function handleException(e){if(e instanceof ExitStatus||"unwind"==e)return EXITSTATUS;quit_(1,e)}function allocateUTF8OnStack(e){var t=lengthBytesUTF8(e)+1,n=stackAlloc(t);return stringToUTF8Array(e,HEAP8,n,t),n}function stringToUTF16(e,t,n){if(void 0===n&&(n=2147483647),n<2)return 0;for(var r=t,s=(n-=2)<2*e.length?n/2:e.length,o=0;o>1]=a,t+=2}return HEAP16[t>>1]=0,t-r}function AsciiToString(e){for(var t="";;){var n=HEAPU8[e++>>0];if(!n)return t;t+=String.fromCharCode(n)}}_exit.sig="vi",_fd_close.sig="ii",_fd_seek.sig="iijip",_fd_write.sig="iippp";var asmLibraryArg={__heap_base:___heap_base,__indirect_function_table:wasmTable,__memory_base:___memory_base,__stack_pointer:___stack_pointer,__table_base:___table_base,_emscripten_get_now_is_monotonic:__emscripten_get_now_is_monotonic,abort:_abort,emscripten_get_now:_emscripten_get_now,emscripten_memcpy_big:_emscripten_memcpy_big,emscripten_resize_heap:_emscripten_resize_heap,exit:_exit,fd_close:_fd_close,fd_seek:_fd_seek,fd_write:_fd_write,memory:wasmMemory,tree_sitter_log_callback:_tree_sitter_log_callback,tree_sitter_parse_callback:_tree_sitter_parse_callback},asm=createWasm(),___wasm_call_ctors=Module.___wasm_call_ctors=function(){return(___wasm_call_ctors=Module.___wasm_call_ctors=Module.asm.__wasm_call_ctors).apply(null,arguments)},___wasm_apply_data_relocs=Module.___wasm_apply_data_relocs=function(){return(___wasm_apply_data_relocs=Module.___wasm_apply_data_relocs=Module.asm.__wasm_apply_data_relocs).apply(null,arguments)},_malloc=Module._malloc=function(){return(_malloc=Module._malloc=Module.asm.malloc).apply(null,arguments)},_calloc=Module._calloc=function(){return(_calloc=Module._calloc=Module.asm.calloc).apply(null,arguments)},_realloc=Module._realloc=function(){return(_realloc=Module._realloc=Module.asm.realloc).apply(null,arguments)},_free=Module._free=function(){return(_free=Module._free=Module.asm.free).apply(null,arguments)},_ts_language_symbol_count=Module._ts_language_symbol_count=function(){return(_ts_language_symbol_count=Module._ts_language_symbol_count=Module.asm.ts_language_symbol_count).apply(null,arguments)},_ts_language_version=Module._ts_language_version=function(){return(_ts_language_version=Module._ts_language_version=Module.asm.ts_language_version).apply(null,arguments)},_ts_language_field_count=Module._ts_language_field_count=function(){return(_ts_language_field_count=Module._ts_language_field_count=Module.asm.ts_language_field_count).apply(null,arguments)},_ts_language_symbol_name=Module._ts_language_symbol_name=function(){return(_ts_language_symbol_name=Module._ts_language_symbol_name=Module.asm.ts_language_symbol_name).apply(null,arguments)},_ts_language_symbol_for_name=Module._ts_language_symbol_for_name=function(){return(_ts_language_symbol_for_name=Module._ts_language_symbol_for_name=Module.asm.ts_language_symbol_for_name).apply(null,arguments)},_ts_language_symbol_type=Module._ts_language_symbol_type=function(){return(_ts_language_symbol_type=Module._ts_language_symbol_type=Module.asm.ts_language_symbol_type).apply(null,arguments)},_ts_language_field_name_for_id=Module._ts_language_field_name_for_id=function(){return(_ts_language_field_name_for_id=Module._ts_language_field_name_for_id=Module.asm.ts_language_field_name_for_id).apply(null,arguments)},_memset=Module._memset=function(){return(_memset=Module._memset=Module.asm.memset).apply(null,arguments)},_memcpy=Module._memcpy=function(){return(_memcpy=Module._memcpy=Module.asm.memcpy).apply(null,arguments)},_ts_parser_delete=Module._ts_parser_delete=function(){return(_ts_parser_delete=Module._ts_parser_delete=Module.asm.ts_parser_delete).apply(null,arguments)},_ts_parser_reset=Module._ts_parser_reset=function(){return(_ts_parser_reset=Module._ts_parser_reset=Module.asm.ts_parser_reset).apply(null,arguments)},_ts_parser_set_language=Module._ts_parser_set_language=function(){return(_ts_parser_set_language=Module._ts_parser_set_language=Module.asm.ts_parser_set_language).apply(null,arguments)},_ts_parser_timeout_micros=Module._ts_parser_timeout_micros=function(){return(_ts_parser_timeout_micros=Module._ts_parser_timeout_micros=Module.asm.ts_parser_timeout_micros).apply(null,arguments)},_ts_parser_set_timeout_micros=Module._ts_parser_set_timeout_micros=function(){return(_ts_parser_set_timeout_micros=Module._ts_parser_set_timeout_micros=Module.asm.ts_parser_set_timeout_micros).apply(null,arguments)},_memmove=Module._memmove=function(){return(_memmove=Module._memmove=Module.asm.memmove).apply(null,arguments)},_memcmp=Module._memcmp=function(){return(_memcmp=Module._memcmp=Module.asm.memcmp).apply(null,arguments)},_ts_query_new=Module._ts_query_new=function(){return(_ts_query_new=Module._ts_query_new=Module.asm.ts_query_new).apply(null,arguments)},_ts_query_delete=Module._ts_query_delete=function(){return(_ts_query_delete=Module._ts_query_delete=Module.asm.ts_query_delete).apply(null,arguments)},_iswspace=Module._iswspace=function(){return(_iswspace=Module._iswspace=Module.asm.iswspace).apply(null,arguments)},_iswalnum=Module._iswalnum=function(){return(_iswalnum=Module._iswalnum=Module.asm.iswalnum).apply(null,arguments)},_ts_query_pattern_count=Module._ts_query_pattern_count=function(){return(_ts_query_pattern_count=Module._ts_query_pattern_count=Module.asm.ts_query_pattern_count).apply(null,arguments)},_ts_query_capture_count=Module._ts_query_capture_count=function(){return(_ts_query_capture_count=Module._ts_query_capture_count=Module.asm.ts_query_capture_count).apply(null,arguments)},_ts_query_string_count=Module._ts_query_string_count=function(){return(_ts_query_string_count=Module._ts_query_string_count=Module.asm.ts_query_string_count).apply(null,arguments)},_ts_query_capture_name_for_id=Module._ts_query_capture_name_for_id=function(){return(_ts_query_capture_name_for_id=Module._ts_query_capture_name_for_id=Module.asm.ts_query_capture_name_for_id).apply(null,arguments)},_ts_query_string_value_for_id=Module._ts_query_string_value_for_id=function(){return(_ts_query_string_value_for_id=Module._ts_query_string_value_for_id=Module.asm.ts_query_string_value_for_id).apply(null,arguments)},_ts_query_predicates_for_pattern=Module._ts_query_predicates_for_pattern=function(){return(_ts_query_predicates_for_pattern=Module._ts_query_predicates_for_pattern=Module.asm.ts_query_predicates_for_pattern).apply(null,arguments)},_ts_tree_copy=Module._ts_tree_copy=function(){return(_ts_tree_copy=Module._ts_tree_copy=Module.asm.ts_tree_copy).apply(null,arguments)},_ts_tree_delete=Module._ts_tree_delete=function(){return(_ts_tree_delete=Module._ts_tree_delete=Module.asm.ts_tree_delete).apply(null,arguments)},_ts_init=Module._ts_init=function(){return(_ts_init=Module._ts_init=Module.asm.ts_init).apply(null,arguments)},_ts_parser_new_wasm=Module._ts_parser_new_wasm=function(){return(_ts_parser_new_wasm=Module._ts_parser_new_wasm=Module.asm.ts_parser_new_wasm).apply(null,arguments)},_ts_parser_enable_logger_wasm=Module._ts_parser_enable_logger_wasm=function(){return(_ts_parser_enable_logger_wasm=Module._ts_parser_enable_logger_wasm=Module.asm.ts_parser_enable_logger_wasm).apply(null,arguments)},_ts_parser_parse_wasm=Module._ts_parser_parse_wasm=function(){return(_ts_parser_parse_wasm=Module._ts_parser_parse_wasm=Module.asm.ts_parser_parse_wasm).apply(null,arguments)},_ts_language_type_is_named_wasm=Module._ts_language_type_is_named_wasm=function(){return(_ts_language_type_is_named_wasm=Module._ts_language_type_is_named_wasm=Module.asm.ts_language_type_is_named_wasm).apply(null,arguments)},_ts_language_type_is_visible_wasm=Module._ts_language_type_is_visible_wasm=function(){return(_ts_language_type_is_visible_wasm=Module._ts_language_type_is_visible_wasm=Module.asm.ts_language_type_is_visible_wasm).apply(null,arguments)},_ts_tree_root_node_wasm=Module._ts_tree_root_node_wasm=function(){return(_ts_tree_root_node_wasm=Module._ts_tree_root_node_wasm=Module.asm.ts_tree_root_node_wasm).apply(null,arguments)},_ts_tree_edit_wasm=Module._ts_tree_edit_wasm=function(){return(_ts_tree_edit_wasm=Module._ts_tree_edit_wasm=Module.asm.ts_tree_edit_wasm).apply(null,arguments)},_ts_tree_get_changed_ranges_wasm=Module._ts_tree_get_changed_ranges_wasm=function(){return(_ts_tree_get_changed_ranges_wasm=Module._ts_tree_get_changed_ranges_wasm=Module.asm.ts_tree_get_changed_ranges_wasm).apply(null,arguments)},_ts_tree_cursor_new_wasm=Module._ts_tree_cursor_new_wasm=function(){return(_ts_tree_cursor_new_wasm=Module._ts_tree_cursor_new_wasm=Module.asm.ts_tree_cursor_new_wasm).apply(null,arguments)},_ts_tree_cursor_delete_wasm=Module._ts_tree_cursor_delete_wasm=function(){return(_ts_tree_cursor_delete_wasm=Module._ts_tree_cursor_delete_wasm=Module.asm.ts_tree_cursor_delete_wasm).apply(null,arguments)},_ts_tree_cursor_reset_wasm=Module._ts_tree_cursor_reset_wasm=function(){return(_ts_tree_cursor_reset_wasm=Module._ts_tree_cursor_reset_wasm=Module.asm.ts_tree_cursor_reset_wasm).apply(null,arguments)},_ts_tree_cursor_goto_first_child_wasm=Module._ts_tree_cursor_goto_first_child_wasm=function(){return(_ts_tree_cursor_goto_first_child_wasm=Module._ts_tree_cursor_goto_first_child_wasm=Module.asm.ts_tree_cursor_goto_first_child_wasm).apply(null,arguments)},_ts_tree_cursor_goto_next_sibling_wasm=Module._ts_tree_cursor_goto_next_sibling_wasm=function(){return(_ts_tree_cursor_goto_next_sibling_wasm=Module._ts_tree_cursor_goto_next_sibling_wasm=Module.asm.ts_tree_cursor_goto_next_sibling_wasm).apply(null,arguments)},_ts_tree_cursor_goto_parent_wasm=Module._ts_tree_cursor_goto_parent_wasm=function(){return(_ts_tree_cursor_goto_parent_wasm=Module._ts_tree_cursor_goto_parent_wasm=Module.asm.ts_tree_cursor_goto_parent_wasm).apply(null,arguments)},_ts_tree_cursor_current_node_type_id_wasm=Module._ts_tree_cursor_current_node_type_id_wasm=function(){return(_ts_tree_cursor_current_node_type_id_wasm=Module._ts_tree_cursor_current_node_type_id_wasm=Module.asm.ts_tree_cursor_current_node_type_id_wasm).apply(null,arguments)},_ts_tree_cursor_current_node_is_named_wasm=Module._ts_tree_cursor_current_node_is_named_wasm=function(){return(_ts_tree_cursor_current_node_is_named_wasm=Module._ts_tree_cursor_current_node_is_named_wasm=Module.asm.ts_tree_cursor_current_node_is_named_wasm).apply(null,arguments)},_ts_tree_cursor_current_node_is_missing_wasm=Module._ts_tree_cursor_current_node_is_missing_wasm=function(){return(_ts_tree_cursor_current_node_is_missing_wasm=Module._ts_tree_cursor_current_node_is_missing_wasm=Module.asm.ts_tree_cursor_current_node_is_missing_wasm).apply(null,arguments)},_ts_tree_cursor_current_node_id_wasm=Module._ts_tree_cursor_current_node_id_wasm=function(){return(_ts_tree_cursor_current_node_id_wasm=Module._ts_tree_cursor_current_node_id_wasm=Module.asm.ts_tree_cursor_current_node_id_wasm).apply(null,arguments)},_ts_tree_cursor_start_position_wasm=Module._ts_tree_cursor_start_position_wasm=function(){return(_ts_tree_cursor_start_position_wasm=Module._ts_tree_cursor_start_position_wasm=Module.asm.ts_tree_cursor_start_position_wasm).apply(null,arguments)},_ts_tree_cursor_end_position_wasm=Module._ts_tree_cursor_end_position_wasm=function(){return(_ts_tree_cursor_end_position_wasm=Module._ts_tree_cursor_end_position_wasm=Module.asm.ts_tree_cursor_end_position_wasm).apply(null,arguments)},_ts_tree_cursor_start_index_wasm=Module._ts_tree_cursor_start_index_wasm=function(){return(_ts_tree_cursor_start_index_wasm=Module._ts_tree_cursor_start_index_wasm=Module.asm.ts_tree_cursor_start_index_wasm).apply(null,arguments)},_ts_tree_cursor_end_index_wasm=Module._ts_tree_cursor_end_index_wasm=function(){return(_ts_tree_cursor_end_index_wasm=Module._ts_tree_cursor_end_index_wasm=Module.asm.ts_tree_cursor_end_index_wasm).apply(null,arguments)},_ts_tree_cursor_current_field_id_wasm=Module._ts_tree_cursor_current_field_id_wasm=function(){return(_ts_tree_cursor_current_field_id_wasm=Module._ts_tree_cursor_current_field_id_wasm=Module.asm.ts_tree_cursor_current_field_id_wasm).apply(null,arguments)},_ts_tree_cursor_current_node_wasm=Module._ts_tree_cursor_current_node_wasm=function(){return(_ts_tree_cursor_current_node_wasm=Module._ts_tree_cursor_current_node_wasm=Module.asm.ts_tree_cursor_current_node_wasm).apply(null,arguments)},_ts_node_symbol_wasm=Module._ts_node_symbol_wasm=function(){return(_ts_node_symbol_wasm=Module._ts_node_symbol_wasm=Module.asm.ts_node_symbol_wasm).apply(null,arguments)},_ts_node_child_count_wasm=Module._ts_node_child_count_wasm=function(){return(_ts_node_child_count_wasm=Module._ts_node_child_count_wasm=Module.asm.ts_node_child_count_wasm).apply(null,arguments)},_ts_node_named_child_count_wasm=Module._ts_node_named_child_count_wasm=function(){return(_ts_node_named_child_count_wasm=Module._ts_node_named_child_count_wasm=Module.asm.ts_node_named_child_count_wasm).apply(null,arguments)},_ts_node_child_wasm=Module._ts_node_child_wasm=function(){return(_ts_node_child_wasm=Module._ts_node_child_wasm=Module.asm.ts_node_child_wasm).apply(null,arguments)},_ts_node_named_child_wasm=Module._ts_node_named_child_wasm=function(){return(_ts_node_named_child_wasm=Module._ts_node_named_child_wasm=Module.asm.ts_node_named_child_wasm).apply(null,arguments)},_ts_node_child_by_field_id_wasm=Module._ts_node_child_by_field_id_wasm=function(){return(_ts_node_child_by_field_id_wasm=Module._ts_node_child_by_field_id_wasm=Module.asm.ts_node_child_by_field_id_wasm).apply(null,arguments)},_ts_node_next_sibling_wasm=Module._ts_node_next_sibling_wasm=function(){return(_ts_node_next_sibling_wasm=Module._ts_node_next_sibling_wasm=Module.asm.ts_node_next_sibling_wasm).apply(null,arguments)},_ts_node_prev_sibling_wasm=Module._ts_node_prev_sibling_wasm=function(){return(_ts_node_prev_sibling_wasm=Module._ts_node_prev_sibling_wasm=Module.asm.ts_node_prev_sibling_wasm).apply(null,arguments)},_ts_node_next_named_sibling_wasm=Module._ts_node_next_named_sibling_wasm=function(){return(_ts_node_next_named_sibling_wasm=Module._ts_node_next_named_sibling_wasm=Module.asm.ts_node_next_named_sibling_wasm).apply(null,arguments)},_ts_node_prev_named_sibling_wasm=Module._ts_node_prev_named_sibling_wasm=function(){return(_ts_node_prev_named_sibling_wasm=Module._ts_node_prev_named_sibling_wasm=Module.asm.ts_node_prev_named_sibling_wasm).apply(null,arguments)},_ts_node_parent_wasm=Module._ts_node_parent_wasm=function(){return(_ts_node_parent_wasm=Module._ts_node_parent_wasm=Module.asm.ts_node_parent_wasm).apply(null,arguments)},_ts_node_descendant_for_index_wasm=Module._ts_node_descendant_for_index_wasm=function(){return(_ts_node_descendant_for_index_wasm=Module._ts_node_descendant_for_index_wasm=Module.asm.ts_node_descendant_for_index_wasm).apply(null,arguments)},_ts_node_named_descendant_for_index_wasm=Module._ts_node_named_descendant_for_index_wasm=function(){return(_ts_node_named_descendant_for_index_wasm=Module._ts_node_named_descendant_for_index_wasm=Module.asm.ts_node_named_descendant_for_index_wasm).apply(null,arguments)},_ts_node_descendant_for_position_wasm=Module._ts_node_descendant_for_position_wasm=function(){return(_ts_node_descendant_for_position_wasm=Module._ts_node_descendant_for_position_wasm=Module.asm.ts_node_descendant_for_position_wasm).apply(null,arguments)},_ts_node_named_descendant_for_position_wasm=Module._ts_node_named_descendant_for_position_wasm=function(){return(_ts_node_named_descendant_for_position_wasm=Module._ts_node_named_descendant_for_position_wasm=Module.asm.ts_node_named_descendant_for_position_wasm).apply(null,arguments)},_ts_node_start_point_wasm=Module._ts_node_start_point_wasm=function(){return(_ts_node_start_point_wasm=Module._ts_node_start_point_wasm=Module.asm.ts_node_start_point_wasm).apply(null,arguments)},_ts_node_end_point_wasm=Module._ts_node_end_point_wasm=function(){return(_ts_node_end_point_wasm=Module._ts_node_end_point_wasm=Module.asm.ts_node_end_point_wasm).apply(null,arguments)},_ts_node_start_index_wasm=Module._ts_node_start_index_wasm=function(){return(_ts_node_start_index_wasm=Module._ts_node_start_index_wasm=Module.asm.ts_node_start_index_wasm).apply(null,arguments)},_ts_node_end_index_wasm=Module._ts_node_end_index_wasm=function(){return(_ts_node_end_index_wasm=Module._ts_node_end_index_wasm=Module.asm.ts_node_end_index_wasm).apply(null,arguments)},_ts_node_to_string_wasm=Module._ts_node_to_string_wasm=function(){return(_ts_node_to_string_wasm=Module._ts_node_to_string_wasm=Module.asm.ts_node_to_string_wasm).apply(null,arguments)},_ts_node_children_wasm=Module._ts_node_children_wasm=function(){return(_ts_node_children_wasm=Module._ts_node_children_wasm=Module.asm.ts_node_children_wasm).apply(null,arguments)},_ts_node_named_children_wasm=Module._ts_node_named_children_wasm=function(){return(_ts_node_named_children_wasm=Module._ts_node_named_children_wasm=Module.asm.ts_node_named_children_wasm).apply(null,arguments)},_ts_node_descendants_of_type_wasm=Module._ts_node_descendants_of_type_wasm=function(){return(_ts_node_descendants_of_type_wasm=Module._ts_node_descendants_of_type_wasm=Module.asm.ts_node_descendants_of_type_wasm).apply(null,arguments)},_ts_node_is_named_wasm=Module._ts_node_is_named_wasm=function(){return(_ts_node_is_named_wasm=Module._ts_node_is_named_wasm=Module.asm.ts_node_is_named_wasm).apply(null,arguments)},_ts_node_has_changes_wasm=Module._ts_node_has_changes_wasm=function(){return(_ts_node_has_changes_wasm=Module._ts_node_has_changes_wasm=Module.asm.ts_node_has_changes_wasm).apply(null,arguments)},_ts_node_has_error_wasm=Module._ts_node_has_error_wasm=function(){return(_ts_node_has_error_wasm=Module._ts_node_has_error_wasm=Module.asm.ts_node_has_error_wasm).apply(null,arguments)},_ts_node_is_missing_wasm=Module._ts_node_is_missing_wasm=function(){return(_ts_node_is_missing_wasm=Module._ts_node_is_missing_wasm=Module.asm.ts_node_is_missing_wasm).apply(null,arguments)},_ts_query_matches_wasm=Module._ts_query_matches_wasm=function(){return(_ts_query_matches_wasm=Module._ts_query_matches_wasm=Module.asm.ts_query_matches_wasm).apply(null,arguments)},_ts_query_captures_wasm=Module._ts_query_captures_wasm=function(){return(_ts_query_captures_wasm=Module._ts_query_captures_wasm=Module.asm.ts_query_captures_wasm).apply(null,arguments)},___cxa_atexit=Module.___cxa_atexit=function(){return(___cxa_atexit=Module.___cxa_atexit=Module.asm.__cxa_atexit).apply(null,arguments)},_iswdigit=Module._iswdigit=function(){return(_iswdigit=Module._iswdigit=Module.asm.iswdigit).apply(null,arguments)},_iswalpha=Module._iswalpha=function(){return(_iswalpha=Module._iswalpha=Module.asm.iswalpha).apply(null,arguments)},_iswlower=Module._iswlower=function(){return(_iswlower=Module._iswlower=Module.asm.iswlower).apply(null,arguments)},_memchr=Module._memchr=function(){return(_memchr=Module._memchr=Module.asm.memchr).apply(null,arguments)},_strlen=Module._strlen=function(){return(_strlen=Module._strlen=Module.asm.strlen).apply(null,arguments)},_towupper=Module._towupper=function(){return(_towupper=Module._towupper=Module.asm.towupper).apply(null,arguments)},_setThrew=Module._setThrew=function(){return(_setThrew=Module._setThrew=Module.asm.setThrew).apply(null,arguments)},stackSave=Module.stackSave=function(){return(stackSave=Module.stackSave=Module.asm.stackSave).apply(null,arguments)},stackRestore=Module.stackRestore=function(){return(stackRestore=Module.stackRestore=Module.asm.stackRestore).apply(null,arguments)},stackAlloc=Module.stackAlloc=function(){return(stackAlloc=Module.stackAlloc=Module.asm.stackAlloc).apply(null,arguments)},__Znwm=Module.__Znwm=function(){return(__Znwm=Module.__Znwm=Module.asm._Znwm).apply(null,arguments)},__ZdlPv=Module.__ZdlPv=function(){return(__ZdlPv=Module.__ZdlPv=Module.asm._ZdlPv).apply(null,arguments)},__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev=Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev=function(){return(__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev=Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev=Module.asm._ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev).apply(null,arguments)},__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__grow_byEmmmmmm=Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__grow_byEmmmmmm=function(){return(__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__grow_byEmmmmmm=Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__grow_byEmmmmmm=Module.asm._ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__grow_byEmmmmmm).apply(null,arguments)},__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm=Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm=function(){return(__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm=Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm=Module.asm._ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm).apply(null,arguments)},__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7reserveEm=Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7reserveEm=function(){return(__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7reserveEm=Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7reserveEm=Module.asm._ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7reserveEm).apply(null,arguments)},__ZNKSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4copyEPcmm=Module.__ZNKSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4copyEPcmm=function(){return(__ZNKSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4copyEPcmm=Module.__ZNKSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4copyEPcmm=Module.asm._ZNKSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4copyEPcmm).apply(null,arguments)},__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9push_backEc=Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9push_backEc=function(){return(__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9push_backEc=Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9push_backEc=Module.asm._ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9push_backEc).apply(null,arguments)},__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED2Ev=Module.__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED2Ev=function(){return(__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED2Ev=Module.__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED2Ev=Module.asm._ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED2Ev).apply(null,arguments)},__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE9push_backEw=Module.__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE9push_backEw=function(){return(__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE9push_backEw=Module.__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE9push_backEw=Module.asm._ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE9push_backEw).apply(null,arguments)},__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6resizeEmw=Module.__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6resizeEmw=function(){return(__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6resizeEmw=Module.__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6resizeEmw=Module.asm._ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6resizeEmw).apply(null,arguments)},dynCall_jiji=Module.dynCall_jiji=function(){return(dynCall_jiji=Module.dynCall_jiji=Module.asm.dynCall_jiji).apply(null,arguments)},_orig$ts_parser_timeout_micros=Module._orig$ts_parser_timeout_micros=function(){return(_orig$ts_parser_timeout_micros=Module._orig$ts_parser_timeout_micros=Module.asm.orig$ts_parser_timeout_micros).apply(null,arguments)},_orig$ts_parser_set_timeout_micros=Module._orig$ts_parser_set_timeout_micros=function(){return(_orig$ts_parser_set_timeout_micros=Module._orig$ts_parser_set_timeout_micros=Module.asm.orig$ts_parser_set_timeout_micros).apply(null,arguments)},calledRun;function callMain(e){var t=Module._main;if(t){(e=e||[]).unshift(thisProgram);var n=e.length,r=stackAlloc(4*(n+1)),s=r>>2;e.forEach((e=>{HEAP32[s++]=allocateUTF8OnStack(e)})),HEAP32[s]=0;try{var o=t(n,r);return exitJS(o,!0),o}catch(e){return handleException(e)}}}Module.AsciiToString=AsciiToString,Module.stringToUTF16=stringToUTF16,dependenciesFulfilled=function e(){calledRun||run(),calledRun||(dependenciesFulfilled=e)};var dylibsLoaded=!1;function run(e){function t(){calledRun||(calledRun=!0,Module.calledRun=!0,ABORT||(initRuntime(),preMain(),Module.onRuntimeInitialized&&Module.onRuntimeInitialized(),shouldRunNow&&callMain(e),postRun()))}e=e||arguments_,runDependencies>0||!dylibsLoaded&&(preloadDylibs(),dylibsLoaded=!0,runDependencies>0)||(preRun(),runDependencies>0||(Module.setStatus?(Module.setStatus("Running..."),setTimeout((function(){setTimeout((function(){Module.setStatus("")}),1),t()}),1)):t()))}if(Module.preInit)for("function"==typeof Module.preInit&&(Module.preInit=[Module.preInit]);Module.preInit.length>0;)Module.preInit.pop()();var shouldRunNow=!0;Module.noInitialRun&&(shouldRunNow=!1),run();const C=Module,INTERNAL={},SIZE_OF_INT=4,SIZE_OF_NODE=5*SIZE_OF_INT,SIZE_OF_POINT=2*SIZE_OF_INT,SIZE_OF_RANGE=2*SIZE_OF_INT+2*SIZE_OF_POINT,ZERO_POINT={row:0,column:0},QUERY_WORD_REGEX=/[\w-.]*/g,PREDICATE_STEP_TYPE_CAPTURE=1,PREDICATE_STEP_TYPE_STRING=2,LANGUAGE_FUNCTION_REGEX=/^_?tree_sitter_\w+/;var VERSION,MIN_COMPATIBLE_VERSION,TRANSFER_BUFFER,currentParseCallback,currentLogCallback;class ParserImpl{static init(){TRANSFER_BUFFER=C._ts_init(),VERSION=getValue(TRANSFER_BUFFER,"i32"),MIN_COMPATIBLE_VERSION=getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32")}initialize(){C._ts_parser_new_wasm(),this[0]=getValue(TRANSFER_BUFFER,"i32"),this[1]=getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32")}delete(){C._ts_parser_delete(this[0]),C._free(this[1]),this[0]=0,this[1]=0}setLanguage(e){let t;if(e){if(e.constructor!==Language)throw new Error("Argument must be a Language");{t=e[0];const n=C._ts_language_version(t);if(ne.slice(t,r);else{if("function"!=typeof e)throw new Error("Argument must be a string or a function");currentParseCallback=e}this.logCallback?(currentLogCallback=this.logCallback,C._ts_parser_enable_logger_wasm(this[0],1)):(currentLogCallback=null,C._ts_parser_enable_logger_wasm(this[0],0));let r=0,s=0;if(n&&n.includedRanges){r=n.includedRanges.length,s=C._calloc(r,SIZE_OF_RANGE);let e=s;for(let t=0;t0){let e=n;for(let n=0;n0){let n=t;for(let t=0;t0){let n=t;for(let t=0;t0){let e=i;for(let t=0;t0){if("string"!==s[0].type)throw new Error("Predicates must begin with a literal value");const t=s[0].value;let n=!0;switch(t){case"not-eq?":n=!1;case"eq?":if(3!==s.length)throw new Error("Wrong number of arguments to `#eq?` predicate. Expected 2, got "+(s.length-1));if("capture"!==s[1].type)throw new Error(`First argument of \`#eq?\` predicate must be a capture. Got "${s[1].value}"`);if("capture"===s[2].type){const t=s[1].name,r=s[2].name;m[e].push((function(e){let s,o;for(const n of e)n.name===t&&(s=n.node),n.name===r&&(o=n.node);return void 0===s||void 0===o||s.text===o.text===n}))}else{const t=s[1].name,r=s[2].value;m[e].push((function(e){for(const s of e)if(s.name===t)return s.node.text===r===n;return!0}))}break;case"not-match?":n=!1;case"match?":if(3!==s.length)throw new Error(`Wrong number of arguments to \`#match?\` predicate. Expected 2, got ${s.length-1}.`);if("capture"!==s[1].type)throw new Error(`First argument of \`#match?\` predicate must be a capture. Got "${s[1].value}".`);if("string"!==s[2].type)throw new Error(`Second argument of \`#match?\` predicate must be a string. Got @${s[2].value}.`);const r=s[1].name,o=new RegExp(s[2].value);m[e].push((function(e){for(const t of e)if(t.name===r)return o.test(t.node.text)===n;return!0}));break;case"set!":if(s.length<2||s.length>3)throw new Error(`Wrong number of arguments to \`#set!\` predicate. Expected 1 or 2. Got ${s.length-1}.`);if(s.some((e=>"string"!==e.type)))throw new Error('Arguments to `#set!` predicate must be a strings.".');c[e]||(c[e]={}),c[e][s[1].value]=s[2]?s[2].value:null;break;case"is?":case"is-not?":if(s.length<2||s.length>3)throw new Error(`Wrong number of arguments to \`#${t}\` predicate. Expected 1 or 2. Got ${s.length-1}.`);if(s.some((e=>"string"!==e.type)))throw new Error(`Arguments to \`#${t}\` predicate must be a strings.".`);const a="is?"===t?u:_;a[e]||(a[e]={}),a[e][s[1].value]=s[2]?s[2].value:null;break;default:d[e].push({operator:t,operands:s.slice(1)})}s.length=0}}Object.freeze(c[e]),Object.freeze(u[e]),Object.freeze(_[e])}return C._free(n),new Query(INTERNAL,r,i,m,d,Object.freeze(c),Object.freeze(u),Object.freeze(_))}static load(e){let t;if(e instanceof Uint8Array)t=Promise.resolve(e);else{const n=e;if("undefined"!=typeof process&&process.versions&&process.versions.node){const e=__webpack_require__(75);t=Promise.resolve(e.readFileSync(n))}else t=fetch(n).then((e=>e.arrayBuffer().then((t=>{if(e.ok)return new Uint8Array(t);{const n=new TextDecoder("utf-8").decode(t);throw new Error(`Language.load failed with status ${e.status}.\n\n${n}`)}}))))}const n="function"==typeof loadSideModule?loadSideModule:loadWebAssemblyModule;return t.then((e=>n(e,{loadAsync:!0}))).then((e=>{const t=Object.keys(e),n=t.find((e=>LANGUAGE_FUNCTION_REGEX.test(e)&&!e.includes("external_scanner_")));n||console.log(`Couldn't find language function in WASM file. Symbols:\n${JSON.stringify(t,null,2)}`);const r=e[n]();return new Language(INTERNAL,r)}))}}class Query{constructor(e,t,n,r,s,o,a,i){assertInternal(e),this[0]=t,this.captureNames=n,this.textPredicates=r,this.predicates=s,this.setProperties=o,this.assertedProperties=a,this.refutedProperties=i,this.exceededMatchLimit=!1}delete(){C._ts_query_delete(this[0]),this[0]=0}matches(e,t,n,r){t||(t=ZERO_POINT),n||(n=ZERO_POINT),r||(r={});let s=r.matchLimit;if(void 0===s)s=0;else if("number"!=typeof s)throw new Error("Arguments must be numbers");marshalNode(e),C._ts_query_matches_wasm(this[0],e.tree[0],t.row,t.column,n.row,n.column,s);const o=getValue(TRANSFER_BUFFER,"i32"),a=getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),i=getValue(TRANSFER_BUFFER+2*SIZE_OF_INT,"i32"),l=new Array(o);this.exceededMatchLimit=!!i;let c=0,u=a;for(let t=0;te(s)))){l[c++]={pattern:n,captures:s};const e=this.setProperties[n];e&&(l[t].setProperties=e);const r=this.assertedProperties[n];r&&(l[t].assertedProperties=r);const o=this.refutedProperties[n];o&&(l[t].refutedProperties=o)}}return l.length=c,C._free(a),l}captures(e,t,n,r){t||(t=ZERO_POINT),n||(n=ZERO_POINT),r||(r={});let s=r.matchLimit;if(void 0===s)s=0;else if("number"!=typeof s)throw new Error("Arguments must be numbers");marshalNode(e),C._ts_query_captures_wasm(this[0],e.tree[0],t.row,t.column,n.row,n.column,s);const o=getValue(TRANSFER_BUFFER,"i32"),a=getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),i=getValue(TRANSFER_BUFFER+2*SIZE_OF_INT,"i32"),l=[];this.exceededMatchLimit=!!i;const c=[];let u=a;for(let t=0;te(c)))){const e=c[r],n=this.setProperties[t];n&&(e.setProperties=n);const s=this.assertedProperties[t];s&&(e.assertedProperties=s);const o=this.refutedProperties[t];o&&(e.refutedProperties=o),l.push(e)}}return C._free(a),l}predicatesForPattern(e){return this.predicates[e]}didExceedMatchLimit(){return this.exceededMatchLimit}}function getText(e,t,n){const r=n-t;let s=e.textCallback(t,null,n);for(t+=s.length;t0))break;t+=r.length,s+=r}return t>n&&(s=s.slice(0,r)),s}function unmarshalCaptures(e,t,n,r){for(let s=0,o=r.length;s{ParserImpl.init(),resolveInitPromise()}})))}}return Parser}();module.exports=TreeSitter},398:e=>{"use strict";e.exports=require("vscode")},75:()=>{}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var n=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e].call(n.exports,n,n.exports,__webpack_require__),n.exports}var __webpack_exports__=__webpack_require__(265),__webpack_export_target__=exports;for(var i in __webpack_exports__)__webpack_export_target__[i]=__webpack_exports__[i];__webpack_exports__.__esModule&&Object.defineProperty(__webpack_export_target__,"__esModule",{value:!0})})(); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index f4ba6f1..37940f8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,145 +1,190 @@ { "name": "tmlanguage-syntax-highlighter", "version": "2.3.0", - "lockfileVersion": 1, + "lockfileVersion": 3, "requires": true, - "dependencies": { - "@discoveryjs/json-ext": { + "packages": { + "": { + "name": "tmlanguage-syntax-highlighter", + "version": "2.3.0", + "dependencies": { + "vscode-oniguruma": "1.7.0", + "vscode-textmate": "9.0.0", + "web-tree-sitter": "^0.20.8" + }, + "devDependencies": { + "@types/vscode": "^1.85.0", + "@vscode/test-web": "^0.0.52", + "@vscode/vsce": "^2.22.0", + "path-browserify": "^1.0.1", + "tree-sitter-cli": "^0.20.8", + "ts-loader": "^9.5.1", + "typescript": "^5.3.3", + "webpack": "^5.90.2", + "webpack-cli": "^5.1.4" + }, + "engines": { + "vscode": "^1.87.0" + } + }, + "node_modules/@discoveryjs/json-ext": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz", "integrity": "sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw==", - "dev": true + "dev": true, + "engines": { + "node": ">=10.0.0" + } }, - "@jridgewell/gen-mapping": { + "node_modules/@jridgewell/gen-mapping": { "version": "0.3.5", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz", "integrity": "sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==", "dev": true, - "requires": { + "dependencies": { "@jridgewell/set-array": "^1.2.1", "@jridgewell/sourcemap-codec": "^1.4.10", "@jridgewell/trace-mapping": "^0.3.24" + }, + "engines": { + "node": ">=6.0.0" } }, - "@jridgewell/resolve-uri": { + "node_modules/@jridgewell/resolve-uri": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", - "dev": true + "dev": true, + "engines": { + "node": ">=6.0.0" + } }, - "@jridgewell/set-array": { + "node_modules/@jridgewell/set-array": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz", "integrity": "sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==", - "dev": true + "dev": true, + "engines": { + "node": ">=6.0.0" + } }, - "@jridgewell/source-map": { + "node_modules/@jridgewell/source-map": { "version": "0.3.5", "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.5.tgz", "integrity": "sha512-UTYAUj/wviwdsMfzoSJspJxbkH5o1snzwX0//0ENX1u/55kkZZkcTZP6u9bwKGkv+dkk9at4m1Cpt0uY80kcpQ==", "dev": true, - "requires": { + "dependencies": { "@jridgewell/gen-mapping": "^0.3.0", "@jridgewell/trace-mapping": "^0.3.9" } }, - "@jridgewell/sourcemap-codec": { + "node_modules/@jridgewell/sourcemap-codec": { "version": "1.4.15", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", "dev": true }, - "@jridgewell/trace-mapping": { + "node_modules/@jridgewell/trace-mapping": { "version": "0.3.25", "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", "dev": true, - "requires": { + "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", "@jridgewell/sourcemap-codec": "^1.4.14" } }, - "@koa/cors": { + "node_modules/@koa/cors": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/@koa/cors/-/cors-5.0.0.tgz", "integrity": "sha512-x/iUDjcS90W69PryLDIMgFyV21YLTnG9zOpPXS7Bkt2b8AsY3zZsIpOLBkYr9fBcF3HbkKaER5hOBZLfpLgYNw==", "dev": true, - "requires": { + "dependencies": { "vary": "^1.1.2" + }, + "engines": { + "node": ">= 14.0.0" } }, - "@koa/router": { + "node_modules/@koa/router": { "version": "12.0.1", "resolved": "https://registry.npmjs.org/@koa/router/-/router-12.0.1.tgz", "integrity": "sha512-ribfPYfHb+Uw3b27Eiw6NPqjhIhTpVFzEWLwyc/1Xp+DCdwRRyIlAUODX+9bPARF6aQtUu1+/PHzdNvRzcs/+Q==", "dev": true, - "requires": { + "dependencies": { "debug": "^4.3.4", "http-errors": "^2.0.0", "koa-compose": "^4.1.0", "methods": "^1.1.2", "path-to-regexp": "^6.2.1" + }, + "engines": { + "node": ">= 12" } }, - "@playwright/browser-chromium": { + "node_modules/@playwright/browser-chromium": { "version": "1.42.1", "resolved": "https://registry.npmjs.org/@playwright/browser-chromium/-/browser-chromium-1.42.1.tgz", "integrity": "sha512-A7pcZIZQIiiafO2UCR/OEdkvGM8Hr2gsjcK0cQ7WStF28HUpPBbJiwR9qmo+rjxaEaK7c9XD1qNXOng8Q+eI0Q==", "dev": true, - "requires": { + "hasInstallScript": true, + "dependencies": { "playwright-core": "1.42.1" + }, + "engines": { + "node": ">=16" } }, - "@types/eslint": { + "node_modules/@types/eslint": { "version": "8.56.5", "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.5.tgz", "integrity": "sha512-u5/YPJHo1tvkSF2CE0USEkxon82Z5DBy2xR+qfyYNszpX9qcs4sT6uq2kBbj4BXY1+DBGDPnrhMZV3pKWGNukw==", "dev": true, - "requires": { + "dependencies": { "@types/estree": "*", "@types/json-schema": "*" } }, - "@types/eslint-scope": { + "node_modules/@types/eslint-scope": { "version": "3.7.7", "resolved": "https://registry.npmjs.org/@types/eslint-scope/-/eslint-scope-3.7.7.tgz", "integrity": "sha512-MzMFlSLBqNF2gcHWO0G1vP/YQyfvrxZ0bF+u7mzUdZ1/xK4A4sru+nraZz5i3iEIk1l1uyicaDVTB4QbbEkAYg==", "dev": true, - "requires": { + "dependencies": { "@types/eslint": "*", "@types/estree": "*" } }, - "@types/estree": { + "node_modules/@types/estree": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", "dev": true }, - "@types/json-schema": { + "node_modules/@types/json-schema": { "version": "7.0.15", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", "dev": true }, - "@types/node": { + "node_modules/@types/node": { "version": "16.18.86", "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.86.tgz", "integrity": "sha512-QMvdZf+ZTSiv7gspwhqbfB7Y5DmbYgCsUnakS8Ul9uRbJQehDKaM7SL+GbcDS003Lh7VK4YlelHsRm9HCv26eA==", "dev": true }, - "@types/vscode": { + "node_modules/@types/vscode": { "version": "1.87.0", "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.87.0.tgz", "integrity": "sha512-y3yYJV2esWr8LNjp3VNbSMWG7Y43jC8pCldG8YwiHGAQbsymkkMMt0aDT1xZIOFM2eFcNiUc+dJMx1+Z0UT8fg==", "dev": true }, - "@vscode/test-web": { + "node_modules/@vscode/test-web": { "version": "0.0.52", "resolved": "https://registry.npmjs.org/@vscode/test-web/-/test-web-0.0.52.tgz", "integrity": "sha512-PEYyru1GTUgNFpICWnvz33MnZ+nIIdG6feYHebvJMyFRZFL4s35Mp/6/aa8xUvfzAz/XBHCsbLRtJ1l067f/eQ==", "dev": true, - "requires": { + "dependencies": { "@koa/cors": "^5.0.0", "@koa/router": "^12.0.1", "@playwright/browser-chromium": "^1.41.2", @@ -154,14 +199,20 @@ "playwright": "^1.41.2", "tar-fs": "^3.0.5", "vscode-uri": "^3.0.8" + }, + "bin": { + "vscode-test-web": "out/index.js" + }, + "engines": { + "node": ">=16" } }, - "@vscode/vsce": { + "node_modules/@vscode/vsce": { "version": "2.24.0", "resolved": "https://registry.npmjs.org/@vscode/vsce/-/vsce-2.24.0.tgz", "integrity": "sha512-p6CIXpH5HXDqmUkgFXvIKTjZpZxy/uDx4d/UsfhS9vQUun43KDNUbYeZocyAHgqcJlPEurgArHz9te1PPiqPyA==", "dev": true, - "requires": { + "dependencies": { "azure-devops-node-api": "^11.0.1", "chalk": "^2.4.2", "cheerio": "^1.0.0-rc.9", @@ -169,7 +220,6 @@ "glob": "^7.0.6", "hosted-git-info": "^4.0.2", "jsonc-parser": "^3.2.0", - "keytar": "^7.7.0", "leven": "^3.1.0", "markdown-it": "^12.3.2", "mime": "^1.3.4", @@ -183,95 +233,104 @@ "xml2js": "^0.5.0", "yauzl": "^2.3.1", "yazl": "^2.2.2" + }, + "bin": { + "vsce": "vsce" + }, + "engines": { + "node": ">= 14" + }, + "optionalDependencies": { + "keytar": "^7.7.0" } }, - "@webassemblyjs/ast": { + "node_modules/@webassemblyjs/ast": { "version": "1.11.6", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.6.tgz", "integrity": "sha512-IN1xI7PwOvLPgjcf180gC1bqn3q/QaOCwYUahIOhbYUu8KA/3tw2RT/T0Gidi1l7Hhj5D/INhJxiICObqpMu4Q==", "dev": true, - "requires": { + "dependencies": { "@webassemblyjs/helper-numbers": "1.11.6", "@webassemblyjs/helper-wasm-bytecode": "1.11.6" } }, - "@webassemblyjs/floating-point-hex-parser": { + "node_modules/@webassemblyjs/floating-point-hex-parser": { "version": "1.11.6", "resolved": "https://registry.npmjs.org/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.11.6.tgz", "integrity": "sha512-ejAj9hfRJ2XMsNHk/v6Fu2dGS+i4UaXBXGemOfQ/JfQ6mdQg/WXtwleQRLLS4OvfDhv8rYnVwH27YJLMyYsxhw==", "dev": true }, - "@webassemblyjs/helper-api-error": { + "node_modules/@webassemblyjs/helper-api-error": { "version": "1.11.6", "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-api-error/-/helper-api-error-1.11.6.tgz", "integrity": "sha512-o0YkoP4pVu4rN8aTJgAyj9hC2Sv5UlkzCHhxqWj8butaLvnpdc2jOwh4ewE6CX0txSfLn/UYaV/pheS2Txg//Q==", "dev": true }, - "@webassemblyjs/helper-buffer": { + "node_modules/@webassemblyjs/helper-buffer": { "version": "1.11.6", "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-buffer/-/helper-buffer-1.11.6.tgz", "integrity": "sha512-z3nFzdcp1mb8nEOFFk8DrYLpHvhKC3grJD2ardfKOzmbmJvEf/tPIqCY+sNcwZIY8ZD7IkB2l7/pqhUhqm7hLA==", "dev": true }, - "@webassemblyjs/helper-numbers": { + "node_modules/@webassemblyjs/helper-numbers": { "version": "1.11.6", "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-numbers/-/helper-numbers-1.11.6.tgz", "integrity": "sha512-vUIhZ8LZoIWHBohiEObxVm6hwP034jwmc9kuq5GdHZH0wiLVLIPcMCdpJzG4C11cHoQ25TFIQj9kaVADVX7N3g==", "dev": true, - "requires": { + "dependencies": { "@webassemblyjs/floating-point-hex-parser": "1.11.6", "@webassemblyjs/helper-api-error": "1.11.6", "@xtuc/long": "4.2.2" } }, - "@webassemblyjs/helper-wasm-bytecode": { + "node_modules/@webassemblyjs/helper-wasm-bytecode": { "version": "1.11.6", "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.11.6.tgz", "integrity": "sha512-sFFHKwcmBprO9e7Icf0+gddyWYDViL8bpPjJJl0WHxCdETktXdmtWLGVzoHbqUcY4Be1LkNfwTmXOJUFZYSJdA==", "dev": true }, - "@webassemblyjs/helper-wasm-section": { + "node_modules/@webassemblyjs/helper-wasm-section": { "version": "1.11.6", "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.11.6.tgz", "integrity": "sha512-LPpZbSOwTpEC2cgn4hTydySy1Ke+XEu+ETXuoyvuyezHO3Kjdu90KK95Sh9xTbmjrCsUwvWwCOQQNta37VrS9g==", "dev": true, - "requires": { + "dependencies": { "@webassemblyjs/ast": "1.11.6", "@webassemblyjs/helper-buffer": "1.11.6", "@webassemblyjs/helper-wasm-bytecode": "1.11.6", "@webassemblyjs/wasm-gen": "1.11.6" } }, - "@webassemblyjs/ieee754": { + "node_modules/@webassemblyjs/ieee754": { "version": "1.11.6", "resolved": "https://registry.npmjs.org/@webassemblyjs/ieee754/-/ieee754-1.11.6.tgz", "integrity": "sha512-LM4p2csPNvbij6U1f19v6WR56QZ8JcHg3QIJTlSwzFcmx6WSORicYj6I63f9yU1kEUtrpG+kjkiIAkevHpDXrg==", "dev": true, - "requires": { + "dependencies": { "@xtuc/ieee754": "^1.2.0" } }, - "@webassemblyjs/leb128": { + "node_modules/@webassemblyjs/leb128": { "version": "1.11.6", "resolved": "https://registry.npmjs.org/@webassemblyjs/leb128/-/leb128-1.11.6.tgz", "integrity": "sha512-m7a0FhE67DQXgouf1tbN5XQcdWoNgaAuoULHIfGFIEVKA6tu/edls6XnIlkmS6FrXAquJRPni3ZZKjw6FSPjPQ==", "dev": true, - "requires": { + "dependencies": { "@xtuc/long": "4.2.2" } }, - "@webassemblyjs/utf8": { + "node_modules/@webassemblyjs/utf8": { "version": "1.11.6", "resolved": "https://registry.npmjs.org/@webassemblyjs/utf8/-/utf8-1.11.6.tgz", "integrity": "sha512-vtXf2wTQ3+up9Zsg8sa2yWiQpzSsMyXj0qViVP6xKGCUT8p8YJ6HqI7l5eCnWx1T/FYdsv07HQs2wTFbbof/RA==", "dev": true }, - "@webassemblyjs/wasm-edit": { + "node_modules/@webassemblyjs/wasm-edit": { "version": "1.11.6", "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-edit/-/wasm-edit-1.11.6.tgz", "integrity": "sha512-Ybn2I6fnfIGuCR+Faaz7YcvtBKxvoLV3Lebn1tM4o/IAJzmi9AWYIPWpyBfU8cC+JxAO57bk4+zdsTjJR+VTOw==", "dev": true, - "requires": { + "dependencies": { "@webassemblyjs/ast": "1.11.6", "@webassemblyjs/helper-buffer": "1.11.6", "@webassemblyjs/helper-wasm-bytecode": "1.11.6", @@ -282,12 +341,12 @@ "@webassemblyjs/wast-printer": "1.11.6" } }, - "@webassemblyjs/wasm-gen": { + "node_modules/@webassemblyjs/wasm-gen": { "version": "1.11.6", "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-gen/-/wasm-gen-1.11.6.tgz", "integrity": "sha512-3XOqkZP/y6B4F0PBAXvI1/bky7GryoogUtfwExeP/v7Nzwo1QLcq5oQmpKlftZLbT+ERUOAZVQjuNVak6UXjPA==", "dev": true, - "requires": { + "dependencies": { "@webassemblyjs/ast": "1.11.6", "@webassemblyjs/helper-wasm-bytecode": "1.11.6", "@webassemblyjs/ieee754": "1.11.6", @@ -295,24 +354,24 @@ "@webassemblyjs/utf8": "1.11.6" } }, - "@webassemblyjs/wasm-opt": { + "node_modules/@webassemblyjs/wasm-opt": { "version": "1.11.6", "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-opt/-/wasm-opt-1.11.6.tgz", "integrity": "sha512-cOrKuLRE7PCe6AsOVl7WasYf3wbSo4CeOk6PkrjS7g57MFfVUF9u6ysQBBODX0LdgSvQqRiGz3CXvIDKcPNy4g==", "dev": true, - "requires": { + "dependencies": { "@webassemblyjs/ast": "1.11.6", "@webassemblyjs/helper-buffer": "1.11.6", "@webassemblyjs/wasm-gen": "1.11.6", "@webassemblyjs/wasm-parser": "1.11.6" } }, - "@webassemblyjs/wasm-parser": { + "node_modules/@webassemblyjs/wasm-parser": { "version": "1.11.6", "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-parser/-/wasm-parser-1.11.6.tgz", "integrity": "sha512-6ZwPeGzMJM3Dqp3hCsLgESxBGtT/OeCvCZ4TA1JUPYgmhAx38tTPR9JaKy0S5H3evQpO/h2uWs2j6Yc/fjkpTQ==", "dev": true, - "requires": { + "dependencies": { "@webassemblyjs/ast": "1.11.6", "@webassemblyjs/helper-api-error": "1.11.6", "@webassemblyjs/helper-wasm-bytecode": "1.11.6", @@ -321,326 +380,461 @@ "@webassemblyjs/utf8": "1.11.6" } }, - "@webassemblyjs/wast-printer": { + "node_modules/@webassemblyjs/wast-printer": { "version": "1.11.6", "resolved": "https://registry.npmjs.org/@webassemblyjs/wast-printer/-/wast-printer-1.11.6.tgz", "integrity": "sha512-JM7AhRcE+yW2GWYaKeHL5vt4xqee5N2WcezptmgyhNS+ScggqcT1OtXykhAb13Sn5Yas0j2uv9tHgrjwvzAP4A==", "dev": true, - "requires": { + "dependencies": { "@webassemblyjs/ast": "1.11.6", "@xtuc/long": "4.2.2" } }, - "@webpack-cli/configtest": { + "node_modules/@webpack-cli/configtest": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/@webpack-cli/configtest/-/configtest-2.1.1.tgz", "integrity": "sha512-wy0mglZpDSiSS0XHrVR+BAdId2+yxPSoJW8fsna3ZpYSlufjvxnP4YbKTCBZnNIcGN4r6ZPXV55X4mYExOfLmw==", - "dev": true + "dev": true, + "engines": { + "node": ">=14.15.0" + }, + "peerDependencies": { + "webpack": "5.x.x", + "webpack-cli": "5.x.x" + } }, - "@webpack-cli/info": { + "node_modules/@webpack-cli/info": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/@webpack-cli/info/-/info-2.0.2.tgz", "integrity": "sha512-zLHQdI/Qs1UyT5UBdWNqsARasIA+AaF8t+4u2aS2nEpBQh2mWIVb8qAklq0eUENnC5mOItrIB4LiS9xMtph18A==", - "dev": true + "dev": true, + "engines": { + "node": ">=14.15.0" + }, + "peerDependencies": { + "webpack": "5.x.x", + "webpack-cli": "5.x.x" + } }, - "@webpack-cli/serve": { + "node_modules/@webpack-cli/serve": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/@webpack-cli/serve/-/serve-2.0.5.tgz", "integrity": "sha512-lqaoKnRYBdo1UgDX8uF24AfGMifWK19TxPmM5FHc2vAGxrJ/qtyUyFBWoY1tISZdelsQ5fBcOusifo5o5wSJxQ==", - "dev": true + "dev": true, + "engines": { + "node": ">=14.15.0" + }, + "peerDependencies": { + "webpack": "5.x.x", + "webpack-cli": "5.x.x" + }, + "peerDependenciesMeta": { + "webpack-dev-server": { + "optional": true + } + } }, - "@xtuc/ieee754": { + "node_modules/@xtuc/ieee754": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@xtuc/ieee754/-/ieee754-1.2.0.tgz", "integrity": "sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA==", "dev": true }, - "@xtuc/long": { + "node_modules/@xtuc/long": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/@xtuc/long/-/long-4.2.2.tgz", "integrity": "sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==", "dev": true }, - "accepts": { + "node_modules/accepts": { "version": "1.3.8", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", "dev": true, - "requires": { + "dependencies": { "mime-types": "~2.1.34", "negotiator": "0.6.3" + }, + "engines": { + "node": ">= 0.6" } }, - "acorn": { + "node_modules/acorn": { "version": "8.11.3", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", - "dev": true + "dev": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } }, - "acorn-import-assertions": { + "node_modules/acorn-import-assertions": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/acorn-import-assertions/-/acorn-import-assertions-1.9.0.tgz", "integrity": "sha512-cmMwop9x+8KFhxvKrKfPYmN6/pKTYYHBqLa0DfvVZcKMJWNyWLnaqND7dx/qn66R7ewM1UX5XMaDVP5wlVTaVA==", - "dev": true + "dev": true, + "peerDependencies": { + "acorn": "^8" + } }, - "agent-base": { + "node_modules/agent-base": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.0.tgz", "integrity": "sha512-o/zjMZRhJxny7OyEF+Op8X+efiELC7k7yOjMzgfzVqOzXqkBkWI79YoTdOtsuWd5BWhAGAuOY/Xa6xpiaWXiNg==", "dev": true, - "requires": { + "dependencies": { "debug": "^4.3.4" + }, + "engines": { + "node": ">= 14" } }, - "ajv": { + "node_modules/ajv": { "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", "dev": true, - "requires": { + "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", "json-schema-traverse": "^0.4.1", "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" } }, - "ajv-keywords": { + "node_modules/ajv-keywords": { "version": "3.5.2", "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==", - "dev": true + "dev": true, + "peerDependencies": { + "ajv": "^6.9.1" + } }, - "ansi-styles": { + "node_modules/ansi-styles": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, - "requires": { + "dependencies": { "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" } }, - "argparse": { + "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, - "azure-devops-node-api": { + "node_modules/azure-devops-node-api": { "version": "11.2.0", "resolved": "https://registry.npmjs.org/azure-devops-node-api/-/azure-devops-node-api-11.2.0.tgz", "integrity": "sha512-XdiGPhrpaT5J8wdERRKs5g8E0Zy1pvOYTli7z9E8nmOn3YGp4FhtjhrOyFmX/8veWCwdI69mCHKJw6l+4J/bHA==", "dev": true, - "requires": { + "dependencies": { "tunnel": "0.0.6", "typed-rest-client": "^1.8.4" } }, - "b4a": { + "node_modules/b4a": { "version": "1.6.6", "resolved": "https://registry.npmjs.org/b4a/-/b4a-1.6.6.tgz", "integrity": "sha512-5Tk1HLk6b6ctmjIkAcU/Ujv/1WqiDl0F0JdRCR80VsOcUlHcu7pWeWRlOqQLHfDEsVx9YH/aif5AG4ehoCtTmg==", "dev": true }, - "balanced-match": { + "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "dev": true }, - "bare-events": { + "node_modules/bare-events": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/bare-events/-/bare-events-2.2.1.tgz", "integrity": "sha512-9GYPpsPFvrWBkelIhOhTWtkeZxVxZOdb3VnFTCzlOo3OjvmTvzLoZFUT8kNFACx0vJej6QPney1Cf9BvzCNE/A==", "dev": true, "optional": true }, - "bare-fs": { + "node_modules/bare-fs": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/bare-fs/-/bare-fs-2.2.1.tgz", "integrity": "sha512-+CjmZANQDFZWy4PGbVdmALIwmt33aJg8qTkVjClU6X4WmZkTPBDxRHiBn7fpqEWEfF3AC2io++erpViAIQbSjg==", "dev": true, "optional": true, - "requires": { + "dependencies": { "bare-events": "^2.0.0", "bare-os": "^2.0.0", "bare-path": "^2.0.0", "streamx": "^2.13.0" } }, - "bare-os": { + "node_modules/bare-os": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/bare-os/-/bare-os-2.2.0.tgz", "integrity": "sha512-hD0rOPfYWOMpVirTACt4/nK8mC55La12K5fY1ij8HAdfQakD62M+H4o4tpfKzVGLgRDTuk3vjA4GqGXXCeFbag==", "dev": true, "optional": true }, - "bare-path": { + "node_modules/bare-path": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/bare-path/-/bare-path-2.1.0.tgz", "integrity": "sha512-DIIg7ts8bdRKwJRJrUMy/PICEaQZaPGZ26lsSx9MJSwIhSrcdHn7/C8W+XmnG/rKi6BaRcz+JO00CjZteybDtw==", "dev": true, "optional": true, - "requires": { + "dependencies": { "bare-os": "^2.1.0" } }, - "base64-js": { + "node_modules/base64-js": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], "optional": true }, - "basic-auth": { + "node_modules/basic-auth": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", "integrity": "sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==", "dev": true, - "requires": { + "dependencies": { "safe-buffer": "5.1.2" + }, + "engines": { + "node": ">= 0.8" } }, - "bl": { + "node_modules/bl": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", "dev": true, "optional": true, - "requires": { + "dependencies": { "buffer": "^5.5.0", "inherits": "^2.0.4", "readable-stream": "^3.4.0" - }, + } + }, + "node_modules/bl/node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "dev": true, + "optional": true, "dependencies": { - "readable-stream": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", - "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", - "dev": true, - "optional": true, - "requires": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - } - } + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" } }, - "boolbase": { + "node_modules/boolbase": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==", "dev": true }, - "brace-expansion": { + "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, - "requires": { + "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, - "braces": { + "node_modules/braces": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", "dev": true, - "requires": { + "dependencies": { "fill-range": "^7.0.1" + }, + "engines": { + "node": ">=8" } }, - "browserify-zlib": { + "node_modules/browserify-zlib": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.1.4.tgz", "integrity": "sha512-19OEpq7vWgsH6WkvkBJQDFvJS1uPcbFOQ4v9CU839dO+ZZXUZO6XpE6hNCqvlIIj+4fZvRiJ6DsAQ382GwiyTQ==", "dev": true, - "requires": { + "dependencies": { "pako": "~0.2.0" } }, - "browserslist": { + "node_modules/browserslist": { "version": "4.23.0", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.23.0.tgz", "integrity": "sha512-QW8HiM1shhT2GuzkvklfjcKDiWFXHOeFCIA/huJPwHsslwcydgk7X+z2zXpEijP98UCY7HbubZt5J2Zgvf0CaQ==", "dev": true, - "requires": { + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { "caniuse-lite": "^1.0.30001587", "electron-to-chromium": "^1.4.668", "node-releases": "^2.0.14", "update-browserslist-db": "^1.0.13" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" } }, - "buffer": { + "node_modules/buffer": { "version": "5.7.1", "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], "optional": true, - "requires": { + "dependencies": { "base64-js": "^1.3.1", "ieee754": "^1.1.13" } }, - "buffer-crc32": { + "node_modules/buffer-crc32": { "version": "0.2.13", "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", "integrity": "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==", - "dev": true + "dev": true, + "engines": { + "node": "*" + } }, - "buffer-from": { + "node_modules/buffer-from": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", "dev": true }, - "cache-content-type": { + "node_modules/cache-content-type": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/cache-content-type/-/cache-content-type-1.0.1.tgz", "integrity": "sha512-IKufZ1o4Ut42YUrZSo8+qnMTrFuKkvyoLXUywKz9GJ5BrhOFGhLdkx9sG4KAnVvbY6kEcSFjLQul+DVmBm2bgA==", "dev": true, - "requires": { + "dependencies": { "mime-types": "^2.1.18", "ylru": "^1.2.0" + }, + "engines": { + "node": ">= 6.0.0" } }, - "call-bind": { + "node_modules/call-bind": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz", "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==", "dev": true, - "requires": { + "dependencies": { "es-define-property": "^1.0.0", "es-errors": "^1.3.0", "function-bind": "^1.1.2", "get-intrinsic": "^1.2.4", "set-function-length": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "caniuse-lite": { + "node_modules/caniuse-lite": { "version": "1.0.30001591", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001591.tgz", "integrity": "sha512-PCzRMei/vXjJyL5mJtzNiUCKP59dm8Apqc3PH8gJkMnMXZGox93RbE76jHsmLwmIo6/3nsYIpJtx0O7u5PqFuQ==", - "dev": true + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ] }, - "chalk": { + "node_modules/chalk": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", "dev": true, - "requires": { + "dependencies": { "ansi-styles": "^3.2.1", "escape-string-regexp": "^1.0.5", "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" } }, - "cheerio": { + "node_modules/cheerio": { "version": "1.0.0-rc.12", "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.12.tgz", "integrity": "sha512-VqR8m68vM46BNnuZ5NtnGBKIE/DfN0cRIzg9n40EIq9NOv90ayxLBXA8fXC5gquFRGJSTRqBq25Jt2ECLR431Q==", "dev": true, - "requires": { + "dependencies": { "cheerio-select": "^2.1.0", "dom-serializer": "^2.0.0", "domhandler": "^5.0.3", @@ -648,887 +842,1202 @@ "htmlparser2": "^8.0.1", "parse5": "^7.0.0", "parse5-htmlparser2-tree-adapter": "^7.0.0" + }, + "engines": { + "node": ">= 6" + }, + "funding": { + "url": "https://github.com/cheeriojs/cheerio?sponsor=1" } }, - "cheerio-select": { + "node_modules/cheerio-select": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/cheerio-select/-/cheerio-select-2.1.0.tgz", "integrity": "sha512-9v9kG0LvzrlcungtnJtpGNxY+fzECQKhK4EGJX2vByejiMX84MFNQw4UxPJl3bFbTMw+Dfs37XaIkCwTZfLh4g==", "dev": true, - "requires": { + "dependencies": { "boolbase": "^1.0.0", "css-select": "^5.1.0", "css-what": "^6.1.0", "domelementtype": "^2.3.0", "domhandler": "^5.0.3", "domutils": "^3.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" } }, - "chownr": { + "node_modules/chownr": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==", "dev": true, "optional": true }, - "chrome-trace-event": { + "node_modules/chrome-trace-event": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz", "integrity": "sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg==", - "dev": true + "dev": true, + "engines": { + "node": ">=6.0" + } }, - "clone-deep": { + "node_modules/clone-deep": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/clone-deep/-/clone-deep-4.0.1.tgz", "integrity": "sha512-neHB9xuzh/wk0dIHweyAXv2aPGZIVk3pLMe+/RNzINf17fe0OG96QroktYAUm7SM1PBnzTabaLboqqxDyMU+SQ==", "dev": true, - "requires": { + "dependencies": { "is-plain-object": "^2.0.4", "kind-of": "^6.0.2", "shallow-clone": "^3.0.0" + }, + "engines": { + "node": ">=6" } }, - "co": { + "node_modules/co": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", "integrity": "sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==", - "dev": true + "dev": true, + "engines": { + "iojs": ">= 1.0.0", + "node": ">= 0.12.0" + } }, - "color-convert": { + "node_modules/color-convert": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", "dev": true, - "requires": { + "dependencies": { "color-name": "1.1.3" } }, - "color-name": { + "node_modules/color-name": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", "dev": true }, - "colorette": { + "node_modules/colorette": { "version": "2.0.20", "resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.20.tgz", "integrity": "sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==", "dev": true }, - "commander": { + "node_modules/commander": { "version": "6.2.1", "resolved": "https://registry.npmjs.org/commander/-/commander-6.2.1.tgz", "integrity": "sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA==", - "dev": true + "dev": true, + "engines": { + "node": ">= 6" + } }, - "concat-map": { + "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", "dev": true }, - "content-disposition": { + "node_modules/content-disposition": { "version": "0.5.4", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", "dev": true, - "requires": { + "dependencies": { "safe-buffer": "5.2.1" }, - "dependencies": { - "safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "dev": true - } + "engines": { + "node": ">= 0.6" } }, - "content-type": { + "node_modules/content-disposition/node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/content-type": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.6" + } }, - "cookies": { + "node_modules/cookies": { "version": "0.9.1", "resolved": "https://registry.npmjs.org/cookies/-/cookies-0.9.1.tgz", "integrity": "sha512-TG2hpqe4ELx54QER/S3HQ9SRVnQnGBtKUz5bLQWtYAQ+o6GpgMs6sYUvaiJjVxb+UXwhRhAEP3m7LbsIZ77Hmw==", "dev": true, - "requires": { + "dependencies": { "depd": "~2.0.0", "keygrip": "~1.1.0" + }, + "engines": { + "node": ">= 0.8" } }, - "core-util-is": { + "node_modules/core-util-is": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", "dev": true }, - "cross-spawn": { + "node_modules/cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", "dev": true, - "requires": { + "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" } }, - "css-select": { + "node_modules/css-select": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/css-select/-/css-select-5.1.0.tgz", "integrity": "sha512-nwoRF1rvRRnnCqqY7updORDsuqKzqYJ28+oSMaJMMgOauh3fvwHqMS7EZpIPqK8GL+g9mKxF1vP/ZjSeNjEVHg==", "dev": true, - "requires": { + "dependencies": { "boolbase": "^1.0.0", "css-what": "^6.1.0", "domhandler": "^5.0.2", "domutils": "^3.0.1", "nth-check": "^2.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" } }, - "css-what": { + "node_modules/css-what": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/css-what/-/css-what-6.1.0.tgz", "integrity": "sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==", - "dev": true + "dev": true, + "engines": { + "node": ">= 6" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" + } }, - "debug": { + "node_modules/debug": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dev": true, - "requires": { + "dependencies": { "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } } }, - "decompress-response": { + "node_modules/decompress-response": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", "dev": true, "optional": true, - "requires": { + "dependencies": { "mimic-response": "^3.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "deep-equal": { + "node_modules/deep-equal": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.0.1.tgz", "integrity": "sha512-bHtC0iYvWhyaTzvV3CZgPeZQqCOBGyGsVV7v4eevpdkLHfiSrXUdBG+qAuSz4RI70sszvjQ1QSZ98An1yNwpSw==", "dev": true }, - "deep-extend": { + "node_modules/deep-extend": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", "dev": true, - "optional": true + "optional": true, + "engines": { + "node": ">=4.0.0" + } }, - "define-data-property": { + "node_modules/define-data-property": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", "dev": true, - "requires": { + "dependencies": { "es-define-property": "^1.0.0", "es-errors": "^1.3.0", "gopd": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "delegates": { + "node_modules/delegates": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", "integrity": "sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==", "dev": true }, - "depd": { + "node_modules/depd": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.8" + } }, - "destroy": { + "node_modules/destroy": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } }, - "detect-libc": { + "node_modules/detect-libc": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.2.tgz", "integrity": "sha512-UX6sGumvvqSaXgdKGUsgZWqcUyIXZ/vZTrlRT/iobiKhGL0zL4d3osHj3uqllWJK+i+sixDS/3COVEOFbupFyw==", "dev": true, - "optional": true + "optional": true, + "engines": { + "node": ">=8" + } }, - "dom-serializer": { + "node_modules/dom-serializer": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==", "dev": true, - "requires": { + "dependencies": { "domelementtype": "^2.3.0", "domhandler": "^5.0.2", "entities": "^4.2.0" + }, + "funding": { + "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" } }, - "domelementtype": { + "node_modules/domelementtype": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", - "dev": true + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ] }, - "domhandler": { + "node_modules/domhandler": { "version": "5.0.3", "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz", "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", "dev": true, - "requires": { + "dependencies": { "domelementtype": "^2.3.0" + }, + "engines": { + "node": ">= 4" + }, + "funding": { + "url": "https://github.com/fb55/domhandler?sponsor=1" } }, - "domutils": { + "node_modules/domutils": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.1.0.tgz", "integrity": "sha512-H78uMmQtI2AhgDJjWeQmHwJJ2bLPD3GMmO7Zja/ZZh84wkm+4ut+IUnUdRa8uCGX88DiVx1j6FRe1XfxEgjEZA==", "dev": true, - "requires": { + "dependencies": { "dom-serializer": "^2.0.0", "domelementtype": "^2.3.0", "domhandler": "^5.0.3" + }, + "funding": { + "url": "https://github.com/fb55/domutils?sponsor=1" } }, - "duplexify": { + "node_modules/duplexify": { "version": "3.7.1", "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.7.1.tgz", "integrity": "sha512-07z8uv2wMyS51kKhD1KsdXJg5WQ6t93RneqRxUHnskXVtlYYkLqM0gqStQZ3pj073g687jPCHrqNfCzawLYh5g==", "dev": true, - "requires": { + "dependencies": { "end-of-stream": "^1.0.0", "inherits": "^2.0.1", "readable-stream": "^2.0.0", "stream-shift": "^1.0.0" } }, - "ee-first": { + "node_modules/ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", "dev": true }, - "electron-to-chromium": { + "node_modules/electron-to-chromium": { "version": "1.4.690", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.690.tgz", "integrity": "sha512-+2OAGjUx68xElQhydpcbqH50hE8Vs2K6TkAeLhICYfndb67CVH0UsZaijmRUE3rHlIxU1u0jxwhgVe6fK3YANA==", "dev": true }, - "encodeurl": { + "node_modules/encodeurl": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.8" + } }, - "end-of-stream": { + "node_modules/end-of-stream": { "version": "1.4.4", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", "dev": true, - "requires": { + "dependencies": { "once": "^1.4.0" } }, - "enhanced-resolve": { + "node_modules/enhanced-resolve": { "version": "5.15.1", "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.15.1.tgz", "integrity": "sha512-3d3JRbwsCLJsYgvb6NuWEG44jjPSOMuS73L/6+7BZuoKm3W+qXnSoIYVHi8dG7Qcg4inAY4jbzkZ7MnskePeDg==", "dev": true, - "requires": { + "dependencies": { "graceful-fs": "^4.2.4", "tapable": "^2.2.0" + }, + "engines": { + "node": ">=10.13.0" } }, - "entities": { + "node_modules/entities": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } }, - "envinfo": { + "node_modules/envinfo": { "version": "7.11.1", "resolved": "https://registry.npmjs.org/envinfo/-/envinfo-7.11.1.tgz", "integrity": "sha512-8PiZgZNIB4q/Lw4AhOvAfB/ityHAd2bli3lESSWmWSzSsl5dKpy5N1d1Rfkd2teq/g9xN90lc6o98DOjMeYHpg==", - "dev": true + "dev": true, + "bin": { + "envinfo": "dist/cli.js" + }, + "engines": { + "node": ">=4" + } }, - "es-define-property": { + "node_modules/es-define-property": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz", "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==", "dev": true, - "requires": { + "dependencies": { "get-intrinsic": "^1.2.4" + }, + "engines": { + "node": ">= 0.4" } }, - "es-errors": { + "node_modules/es-errors": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.4" + } }, - "es-module-lexer": { + "node_modules/es-module-lexer": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.4.1.tgz", "integrity": "sha512-cXLGjP0c4T3flZJKQSuziYoq7MlT+rnvfZjfp7h+I7K9BNX54kP9nyWvdbwjQ4u1iWbOL4u96fgeZLToQlZC7w==", "dev": true }, - "escalade": { + "node_modules/escalade": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz", "integrity": "sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==", - "dev": true + "dev": true, + "engines": { + "node": ">=6" + } }, - "escape-html": { + "node_modules/escape-html": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", "dev": true }, - "escape-string-regexp": { + "node_modules/escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.8.0" + } }, - "eslint-scope": { + "node_modules/eslint-scope": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", "dev": true, - "requires": { + "dependencies": { "esrecurse": "^4.3.0", "estraverse": "^4.1.1" + }, + "engines": { + "node": ">=8.0.0" } }, - "esrecurse": { + "node_modules/esrecurse": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", "dev": true, - "requires": { + "dependencies": { "estraverse": "^5.2.0" }, - "dependencies": { - "estraverse": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", - "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", - "dev": true - } + "engines": { + "node": ">=4.0" } }, - "estraverse": { + "node_modules/esrecurse/node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estraverse": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "dev": true + "dev": true, + "engines": { + "node": ">=4.0" + } }, - "events": { + "node_modules/events": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.8.x" + } }, - "expand-template": { + "node_modules/expand-template": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", "integrity": "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==", "dev": true, - "optional": true + "optional": true, + "engines": { + "node": ">=6" + } }, - "fast-deep-equal": { + "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", "dev": true }, - "fast-fifo": { + "node_modules/fast-fifo": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/fast-fifo/-/fast-fifo-1.3.2.tgz", "integrity": "sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ==", "dev": true }, - "fast-json-stable-stringify": { + "node_modules/fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", "dev": true }, - "fastest-levenshtein": { + "node_modules/fastest-levenshtein": { "version": "1.0.16", "resolved": "https://registry.npmjs.org/fastest-levenshtein/-/fastest-levenshtein-1.0.16.tgz", "integrity": "sha512-eRnCtTTtGZFpQCwhJiUOuxPQWRXVKYDn0b2PeHfXL6/Zi53SLAzAHfVhVWK2AryC/WH05kGfxhFIPvTF0SXQzg==", - "dev": true + "dev": true, + "engines": { + "node": ">= 4.9.1" + } }, - "fd-slicer": { + "node_modules/fd-slicer": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", "integrity": "sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==", "dev": true, - "requires": { + "dependencies": { "pend": "~1.2.0" } }, - "fill-range": { + "node_modules/fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", "dev": true, - "requires": { + "dependencies": { "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" } }, - "find-up": { + "node_modules/find-up": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", "dev": true, - "requires": { + "dependencies": { "locate-path": "^5.0.0", "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" } }, - "flat": { + "node_modules/flat": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", - "dev": true + "dev": true, + "bin": { + "flat": "cli.js" + } }, - "fresh": { + "node_modules/fresh": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.6" + } }, - "fs-constants": { + "node_modules/fs-constants": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==", "dev": true, "optional": true }, - "fs.realpath": { + "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "dev": true }, - "fsevents": { + "node_modules/fsevents": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", "dev": true, - "optional": true + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } }, - "function-bind": { + "node_modules/function-bind": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", - "dev": true + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } }, - "get-intrinsic": { + "node_modules/get-intrinsic": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", "dev": true, - "requires": { + "dependencies": { "es-errors": "^1.3.0", "function-bind": "^1.1.2", "has-proto": "^1.0.1", "has-symbols": "^1.0.3", "hasown": "^2.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "github-from-package": { + "node_modules/github-from-package": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz", "integrity": "sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==", "dev": true, "optional": true }, - "glob": { + "node_modules/glob": { "version": "7.2.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", "dev": true, - "requires": { + "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", "minimatch": "^3.1.1", "once": "^1.3.0", "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" } }, - "glob-to-regexp": { + "node_modules/glob-to-regexp": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz", "integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==", "dev": true }, - "gopd": { + "node_modules/gopd": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", "dev": true, - "requires": { + "dependencies": { "get-intrinsic": "^1.1.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "graceful-fs": { + "node_modules/graceful-fs": { "version": "4.2.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", "dev": true }, - "gunzip-maybe": { + "node_modules/gunzip-maybe": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/gunzip-maybe/-/gunzip-maybe-1.4.2.tgz", "integrity": "sha512-4haO1M4mLO91PW57BMsDFf75UmwoRX0GkdD+Faw+Lr+r/OZrOCS0pIBwOL1xCKQqnQzbNFGgK2V2CpBUPeFNTw==", "dev": true, - "requires": { + "dependencies": { "browserify-zlib": "^0.1.4", "is-deflate": "^1.0.0", "is-gzip": "^1.0.0", "peek-stream": "^1.1.0", "pumpify": "^1.3.3", "through2": "^2.0.3" + }, + "bin": { + "gunzip-maybe": "bin.js" } }, - "has-flag": { + "node_modules/has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", - "dev": true + "dev": true, + "engines": { + "node": ">=4" + } }, - "has-property-descriptors": { + "node_modules/has-property-descriptors": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", "dev": true, - "requires": { + "dependencies": { "es-define-property": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "has-proto": { + "node_modules/has-proto": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.3.tgz", "integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } }, - "has-symbols": { + "node_modules/has-symbols": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } }, - "has-tostringtag": { + "node_modules/has-tostringtag": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", "dev": true, - "requires": { + "dependencies": { "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "hasown": { + "node_modules/hasown": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.1.tgz", "integrity": "sha512-1/th4MHjnwncwXsIW6QMzlvYL9kG5e/CpVvLRZe4XPa8TOUNbCELqmvhDmnkNsAjwaG4+I8gJJL0JBvTTLO9qA==", "dev": true, - "requires": { + "dependencies": { "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" } }, - "hosted-git-info": { + "node_modules/hosted-git-info": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-4.1.0.tgz", "integrity": "sha512-kyCuEOWjJqZuDbRHzL8V93NzQhwIB71oFWSyzVo+KPZI+pnQPPxucdkrOZvkLRnrf5URsQM+IJ09Dw29cRALIA==", "dev": true, - "requires": { + "dependencies": { "lru-cache": "^6.0.0" + }, + "engines": { + "node": ">=10" } }, - "htmlparser2": { + "node_modules/htmlparser2": { "version": "8.0.2", "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-8.0.2.tgz", "integrity": "sha512-GYdjWKDkbRLkZ5geuHs5NY1puJ+PXwP7+fHPRz06Eirsb9ugf6d8kkXav6ADhcODhFFPMIXyxkxSuMf3D6NCFA==", "dev": true, - "requires": { + "funding": [ + "https://github.com/fb55/htmlparser2?sponsor=1", + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ], + "dependencies": { "domelementtype": "^2.3.0", "domhandler": "^5.0.3", "domutils": "^3.0.1", "entities": "^4.4.0" } }, - "http-assert": { + "node_modules/http-assert": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/http-assert/-/http-assert-1.5.0.tgz", "integrity": "sha512-uPpH7OKX4H25hBmU6G1jWNaqJGpTXxey+YOUizJUAgu0AjLUeC8D73hTrhvDS5D+GJN1DN1+hhc/eF/wpxtp0w==", "dev": true, - "requires": { + "dependencies": { "deep-equal": "~1.0.1", "http-errors": "~1.8.0" }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/http-assert/node_modules/depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/http-assert/node_modules/http-errors": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz", + "integrity": "sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==", + "dev": true, "dependencies": { - "depd": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", - "integrity": "sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==", - "dev": true - }, - "http-errors": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz", - "integrity": "sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==", - "dev": true, - "requires": { - "depd": "~1.1.2", - "inherits": "2.0.4", - "setprototypeof": "1.2.0", - "statuses": ">= 1.5.0 < 2", - "toidentifier": "1.0.1" - } - }, - "statuses": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", - "integrity": "sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==", - "dev": true - } + "depd": "~1.1.2", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/http-assert/node_modules/statuses": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", + "integrity": "sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==", + "dev": true, + "engines": { + "node": ">= 0.6" } }, - "http-errors": { + "node_modules/http-errors": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", "dev": true, - "requires": { + "dependencies": { "depd": "2.0.0", "inherits": "2.0.4", "setprototypeof": "1.2.0", "statuses": "2.0.1", "toidentifier": "1.0.1" + }, + "engines": { + "node": ">= 0.8" } }, - "http-proxy-agent": { + "node_modules/http-proxy-agent": { "version": "7.0.2", "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz", "integrity": "sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==", "dev": true, - "requires": { + "dependencies": { "agent-base": "^7.1.0", "debug": "^4.3.4" + }, + "engines": { + "node": ">= 14" } }, - "https-proxy-agent": { + "node_modules/https-proxy-agent": { "version": "7.0.4", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.4.tgz", "integrity": "sha512-wlwpilI7YdjSkWaQ/7omYBMTliDcmCN8OLihO6I9B86g06lMyAoqgoDpV0XqoaPOKj+0DIdAvnsWfyAAhmimcg==", "dev": true, - "requires": { + "dependencies": { "agent-base": "^7.0.2", "debug": "4" + }, + "engines": { + "node": ">= 14" } }, - "ieee754": { + "node_modules/ieee754": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], "optional": true }, - "import-local": { + "node_modules/import-local": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.1.0.tgz", "integrity": "sha512-ASB07uLtnDs1o6EHjKpX34BKYDSqnFerfTOJL2HvMqF70LnxpjkzDB8J44oT9pu4AMPkQwf8jl6szgvNd2tRIg==", "dev": true, - "requires": { + "dependencies": { "pkg-dir": "^4.2.0", "resolve-cwd": "^3.0.0" + }, + "bin": { + "import-local-fixture": "fixtures/cli.js" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "inflight": { + "node_modules/inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", "dev": true, - "requires": { + "dependencies": { "once": "^1.3.0", "wrappy": "1" } }, - "inherits": { + "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "dev": true }, - "ini": { + "node_modules/ini": { "version": "1.3.8", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==", "dev": true, "optional": true }, - "interpret": { + "node_modules/interpret": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/interpret/-/interpret-3.1.1.tgz", "integrity": "sha512-6xwYfHbajpoF0xLW+iwLkhwgvLoZDfjYfoFNu8ftMoXINzwuymNLd9u/KmwtdT2GbR+/Cz66otEGEVVUHX9QLQ==", - "dev": true + "dev": true, + "engines": { + "node": ">=10.13.0" + } }, - "is-core-module": { + "node_modules/is-core-module": { "version": "2.13.1", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.1.tgz", "integrity": "sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==", "dev": true, - "requires": { + "dependencies": { "hasown": "^2.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "is-deflate": { + "node_modules/is-deflate": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-deflate/-/is-deflate-1.0.0.tgz", "integrity": "sha512-YDoFpuZWu1VRXlsnlYMzKyVRITXj7Ej/V9gXQ2/pAe7X1J7M/RNOqaIYi6qUn+B7nGyB9pDXrv02dsB58d2ZAQ==", "dev": true }, - "is-generator-function": { + "node_modules/is-generator-function": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.0.10.tgz", "integrity": "sha512-jsEjy9l3yiXEQ+PsXdmBwEPcOxaXWLspKdplFUVI9vq1iZgIekeC0L167qeu86czQaxed3q/Uzuw0swL0irL8A==", "dev": true, - "requires": { + "dependencies": { "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "is-gzip": { + "node_modules/is-gzip": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-gzip/-/is-gzip-1.0.0.tgz", "integrity": "sha512-rcfALRIb1YewtnksfRIHGcIY93QnK8BIQ/2c9yDYcG/Y6+vRoJuTWBmmSEbyLLYtXm7q35pHOHbZFQBaLrhlWQ==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "is-number": { + "node_modules/is-number": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.12.0" + } }, - "is-plain-object": { + "node_modules/is-plain-object": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", "dev": true, - "requires": { + "dependencies": { "isobject": "^3.0.1" + }, + "engines": { + "node": ">=0.10.0" } }, - "isarray": { + "node_modules/isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", "dev": true }, - "isexe": { + "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "dev": true }, - "isobject": { + "node_modules/isobject": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "jest-worker": { + "node_modules/jest-worker": { "version": "27.5.1", "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-27.5.1.tgz", "integrity": "sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg==", "dev": true, - "requires": { + "dependencies": { "@types/node": "*", "merge-stream": "^2.0.0", "supports-color": "^8.0.0" }, + "engines": { + "node": ">= 10.13.0" + } + }, + "node_modules/jest-worker/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/jest-worker/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, "dependencies": { - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "supports-color": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", - "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" } }, - "json-parse-even-better-errors": { + "node_modules/json-parse-even-better-errors": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", "dev": true }, - "json-schema-traverse": { + "node_modules/json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", "dev": true }, - "jsonc-parser": { + "node_modules/jsonc-parser": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.1.tgz", "integrity": "sha512-AilxAyFOAcK5wA1+LeaySVBrHsGQvUFCDWXKpZjzaL0PqW+xfBOttn8GNtWKFWqneyMZj41MWF9Kl6iPWLwgOA==", "dev": true }, - "keygrip": { + "node_modules/keygrip": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/keygrip/-/keygrip-1.1.0.tgz", "integrity": "sha512-iYSchDJ+liQ8iwbSI2QqsQOvqv58eJCEanyJPJi+Khyu8smkcKSFUCbPwzFcL7YVtZ6eONjqRX/38caJ7QjRAQ==", "dev": true, - "requires": { + "dependencies": { "tsscmp": "1.0.6" + }, + "engines": { + "node": ">= 0.6" } }, - "keytar": { + "node_modules/keytar": { "version": "7.9.0", "resolved": "https://registry.npmjs.org/keytar/-/keytar-7.9.0.tgz", "integrity": "sha512-VPD8mtVtm5JNtA2AErl6Chp06JBfy7diFQ7TQQhdpWOl6MrCRB+eRbvAZUsbGQS9kiMq0coJsy0W0vHpDCkWsQ==", "dev": true, + "hasInstallScript": true, "optional": true, - "requires": { + "dependencies": { "node-addon-api": "^4.3.0", "prebuild-install": "^7.0.1" } }, - "kind-of": { + "node_modules/kind-of": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "koa": { + "node_modules/koa": { "version": "2.15.0", "resolved": "https://registry.npmjs.org/koa/-/koa-2.15.0.tgz", "integrity": "sha512-KEL/vU1knsoUvfP4MC4/GthpQrY/p6dzwaaGI6Rt4NQuFqkw3qrvsdYF5pz3wOfi7IGTvMPHC9aZIcUKYFNxsw==", "dev": true, - "requires": { + "dependencies": { "accepts": "^1.3.5", "cache-content-type": "^1.0.0", "content-disposition": "~0.5.2", @@ -1553,581 +2062,731 @@ "type-is": "^1.6.16", "vary": "^1.1.2" }, - "dependencies": { - "http-errors": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz", - "integrity": "sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==", - "dev": true, - "requires": { - "depd": "~1.1.2", - "inherits": "2.0.4", - "setprototypeof": "1.2.0", - "statuses": ">= 1.5.0 < 2", - "toidentifier": "1.0.1" - }, - "dependencies": { - "depd": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", - "integrity": "sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==", - "dev": true - } - } - }, - "statuses": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", - "integrity": "sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==", - "dev": true - } + "engines": { + "node": "^4.8.4 || ^6.10.1 || ^7.10.1 || >= 8.1.4" } }, - "koa-compose": { + "node_modules/koa-compose": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/koa-compose/-/koa-compose-4.1.0.tgz", "integrity": "sha512-8ODW8TrDuMYvXRwra/Kh7/rJo9BtOfPc6qO8eAfC80CnCvSjSl0bkRM24X6/XBBEyj0v1nRUQ1LyOy3dbqOWXw==", "dev": true }, - "koa-convert": { + "node_modules/koa-convert": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/koa-convert/-/koa-convert-2.0.0.tgz", "integrity": "sha512-asOvN6bFlSnxewce2e/DK3p4tltyfC4VM7ZwuTuepI7dEQVcvpyFuBcEARu1+Hxg8DIwytce2n7jrZtRlPrARA==", "dev": true, - "requires": { + "dependencies": { "co": "^4.6.0", "koa-compose": "^4.1.0" + }, + "engines": { + "node": ">= 10" } }, - "koa-morgan": { + "node_modules/koa-morgan": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/koa-morgan/-/koa-morgan-1.0.1.tgz", "integrity": "sha512-JOUdCNlc21G50afBXfErUrr1RKymbgzlrO5KURY+wmDG1Uvd2jmxUJcHgylb/mYXy2SjiNZyYim/ptUBGsIi3A==", "dev": true, - "requires": { + "dependencies": { "morgan": "^1.6.1" } }, - "koa-mount": { + "node_modules/koa-mount": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/koa-mount/-/koa-mount-4.0.0.tgz", "integrity": "sha512-rm71jaA/P+6HeCpoRhmCv8KVBIi0tfGuO/dMKicbQnQW/YJntJ6MnnspkodoA4QstMVEZArsCphmd0bJEtoMjQ==", "dev": true, - "requires": { + "dependencies": { "debug": "^4.0.1", "koa-compose": "^4.1.0" + }, + "engines": { + "node": ">= 7.6.0" } }, - "koa-send": { + "node_modules/koa-send": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/koa-send/-/koa-send-5.0.1.tgz", "integrity": "sha512-tmcyQ/wXXuxpDxyNXv5yNNkdAMdFRqwtegBXUaowiQzUKqJehttS0x2j0eOZDQAyloAth5w6wwBImnFzkUz3pQ==", "dev": true, - "requires": { + "dependencies": { "debug": "^4.1.1", "http-errors": "^1.7.3", "resolve-path": "^1.4.0" }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/koa-send/node_modules/depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/koa-send/node_modules/http-errors": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz", + "integrity": "sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==", + "dev": true, "dependencies": { - "depd": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", - "integrity": "sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==", - "dev": true - }, - "http-errors": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz", - "integrity": "sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==", - "dev": true, - "requires": { - "depd": "~1.1.2", - "inherits": "2.0.4", - "setprototypeof": "1.2.0", - "statuses": ">= 1.5.0 < 2", - "toidentifier": "1.0.1" - } - }, - "statuses": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", - "integrity": "sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==", - "dev": true - } + "depd": "~1.1.2", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/koa-send/node_modules/statuses": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", + "integrity": "sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==", + "dev": true, + "engines": { + "node": ">= 0.6" } }, - "koa-static": { + "node_modules/koa-static": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/koa-static/-/koa-static-5.0.0.tgz", "integrity": "sha512-UqyYyH5YEXaJrf9S8E23GoJFQZXkBVJ9zYYMPGz919MSX1KuvAcycIuS0ci150HCoPf4XQVhQ84Qf8xRPWxFaQ==", "dev": true, - "requires": { + "dependencies": { "debug": "^3.1.0", "koa-send": "^5.0.0" }, + "engines": { + "node": ">= 7.6.0" + } + }, + "node_modules/koa-static/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, "dependencies": { - "debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "dev": true, - "requires": { - "ms": "^2.1.1" - } - } + "ms": "^2.1.1" + } + }, + "node_modules/koa/node_modules/http-errors": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz", + "integrity": "sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==", + "dev": true, + "dependencies": { + "depd": "~1.1.2", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.1" + }, + "engines": { + "node": ">= 0.6" } }, - "leven": { + "node_modules/koa/node_modules/http-errors/node_modules/depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/koa/node_modules/statuses": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", + "integrity": "sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/leven": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", "integrity": "sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==", - "dev": true + "dev": true, + "engines": { + "node": ">=6" + } }, - "linkify-it": { + "node_modules/linkify-it": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-3.0.3.tgz", "integrity": "sha512-ynTsyrFSdE5oZ/O9GEf00kPngmOfVwazR5GKDq6EYfhlpFug3J2zybX56a2PRRpc9P+FuSoGNAwjlbDs9jJBPQ==", "dev": true, - "requires": { + "dependencies": { "uc.micro": "^1.0.1" } }, - "loader-runner": { + "node_modules/loader-runner": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.3.0.tgz", "integrity": "sha512-3R/1M+yS3j5ou80Me59j7F9IMs4PXs3VqRrm0TU3AbKPxlmpoY1TNscJV/oGJXo8qCatFGTfDbY6W6ipGOYXfg==", - "dev": true + "dev": true, + "engines": { + "node": ">=6.11.5" + } }, - "locate-path": { + "node_modules/locate-path": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", "dev": true, - "requires": { + "dependencies": { "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" } }, - "lru-cache": { + "node_modules/lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "dev": true, - "requires": { + "dependencies": { "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" } }, - "markdown-it": { + "node_modules/markdown-it": { "version": "12.3.2", "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-12.3.2.tgz", "integrity": "sha512-TchMembfxfNVpHkbtriWltGWc+m3xszaRD0CZup7GFFhzIgQqxIfn3eGj1yZpfuflzPvfkt611B2Q/Bsk1YnGg==", "dev": true, - "requires": { + "dependencies": { "argparse": "^2.0.1", "entities": "~2.1.0", "linkify-it": "^3.0.1", "mdurl": "^1.0.1", "uc.micro": "^1.0.5" }, - "dependencies": { - "entities": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-2.1.0.tgz", - "integrity": "sha512-hCx1oky9PFrJ611mf0ifBLBRW8lUUVRlFolb5gWRfIELabBlbp9xZvrqZLZAs+NxFnbfQoeGd8wDkygjg7U85w==", - "dev": true - } + "bin": { + "markdown-it": "bin/markdown-it.js" + } + }, + "node_modules/markdown-it/node_modules/entities": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-2.1.0.tgz", + "integrity": "sha512-hCx1oky9PFrJ611mf0ifBLBRW8lUUVRlFolb5gWRfIELabBlbp9xZvrqZLZAs+NxFnbfQoeGd8wDkygjg7U85w==", + "dev": true, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" } }, - "mdurl": { + "node_modules/mdurl": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz", "integrity": "sha512-/sKlQJCBYVY9Ers9hqzKou4H6V5UWc/M59TH2dvkt+84itfnq7uFOMLpOiOS4ujvHP4etln18fmIxA5R5fll0g==", "dev": true }, - "media-typer": { + "node_modules/media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.6" + } }, - "merge-stream": { + "node_modules/merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", "dev": true }, - "methods": { + "node_modules/methods": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.6" + } }, - "micromatch": { + "node_modules/micromatch": { "version": "4.0.5", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", "dev": true, - "requires": { + "dependencies": { "braces": "^3.0.2", "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" } }, - "mime": { + "node_modules/mime": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", - "dev": true + "dev": true, + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4" + } }, - "mime-db": { + "node_modules/mime-db": { "version": "1.52.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.6" + } }, - "mime-types": { + "node_modules/mime-types": { "version": "2.1.35", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", "dev": true, - "requires": { + "dependencies": { "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" } }, - "mimic-response": { + "node_modules/mimic-response": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==", "dev": true, - "optional": true + "optional": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } }, - "minimatch": { + "node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, - "requires": { + "dependencies": { "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" } }, - "minimist": { + "node_modules/minimist": { "version": "1.2.8", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", - "dev": true + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } }, - "mkdirp-classic": { + "node_modules/mkdirp-classic": { "version": "0.5.3", "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==", "dev": true, "optional": true }, - "morgan": { + "node_modules/morgan": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.10.0.tgz", "integrity": "sha512-AbegBVI4sh6El+1gNwvD5YIck7nSA36weD7xvIxG4in80j/UoK8AEGaWnnz8v1GxonMCltmlNs5ZKbGvl9b1XQ==", "dev": true, - "requires": { + "dependencies": { "basic-auth": "~2.0.1", "debug": "2.6.9", "depd": "~2.0.0", "on-finished": "~2.3.0", "on-headers": "~1.0.2" }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/morgan/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", - "dev": true - }, - "on-finished": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", - "integrity": "sha512-ikqdkGAAyf/X/gPhXGvfgAytDZtDbr+bkNUJ0N9h5MI/dmdgCs3l6hoHrcUv41sRKew3jIwrp4qQDXiK99Utww==", - "dev": true, - "requires": { - "ee-first": "1.1.1" - } - } + "ms": "2.0.0" + } + }, + "node_modules/morgan/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "dev": true + }, + "node_modules/morgan/node_modules/on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha512-ikqdkGAAyf/X/gPhXGvfgAytDZtDbr+bkNUJ0N9h5MI/dmdgCs3l6hoHrcUv41sRKew3jIwrp4qQDXiK99Utww==", + "dev": true, + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" } }, - "ms": { + "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, - "mute-stream": { + "node_modules/mute-stream": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==", "dev": true }, - "napi-build-utils": { + "node_modules/napi-build-utils": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-1.0.2.tgz", "integrity": "sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==", "dev": true, "optional": true }, - "negotiator": { + "node_modules/negotiator": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.6" + } }, - "neo-async": { + "node_modules/neo-async": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", "dev": true }, - "node-abi": { + "node_modules/node-abi": { "version": "3.56.0", "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.56.0.tgz", "integrity": "sha512-fZjdhDOeRcaS+rcpve7XuwHBmktS1nS1gzgghwKUQQ8nTy2FdSDr6ZT8k6YhvlJeHmmQMYiT/IH9hfco5zeW2Q==", "dev": true, "optional": true, - "requires": { + "dependencies": { "semver": "^7.3.5" + }, + "engines": { + "node": ">=10" } }, - "node-addon-api": { + "node_modules/node-addon-api": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-4.3.0.tgz", "integrity": "sha512-73sE9+3UaLYYFmDsFZnqCInzPyh3MqIwZO9cw58yIqAZhONrrabrYyYe3TuIqtIiOuTXVhsGau8hcrhhwSsDIQ==", "dev": true, "optional": true }, - "node-releases": { + "node_modules/node-releases": { "version": "2.0.14", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.14.tgz", "integrity": "sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw==", "dev": true }, - "nth-check": { + "node_modules/nth-check": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz", "integrity": "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==", "dev": true, - "requires": { + "dependencies": { "boolbase": "^1.0.0" + }, + "funding": { + "url": "https://github.com/fb55/nth-check?sponsor=1" } }, - "object-inspect": { + "node_modules/object-inspect": { "version": "1.13.1", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz", "integrity": "sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==", - "dev": true + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } }, - "on-finished": { + "node_modules/on-finished": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", "dev": true, - "requires": { + "dependencies": { "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" } }, - "on-headers": { + "node_modules/on-headers": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.2.tgz", "integrity": "sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.8" + } }, - "once": { + "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", "dev": true, - "requires": { + "dependencies": { "wrappy": "1" } }, - "only": { + "node_modules/only": { "version": "0.0.2", "resolved": "https://registry.npmjs.org/only/-/only-0.0.2.tgz", "integrity": "sha512-Fvw+Jemq5fjjyWz6CpKx6w9s7xxqo3+JCyM0WXWeCSOboZ8ABkyvP8ID4CZuChA/wxSx+XSJmdOm8rGVyJ1hdQ==", "dev": true }, - "p-limit": { + "node_modules/p-limit": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", "dev": true, - "requires": { + "dependencies": { "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "p-locate": { + "node_modules/p-locate": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", "dev": true, - "requires": { + "dependencies": { "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" } }, - "p-try": { + "node_modules/p-try": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "dev": true + "dev": true, + "engines": { + "node": ">=6" + } }, - "pako": { + "node_modules/pako": { "version": "0.2.9", "resolved": "https://registry.npmjs.org/pako/-/pako-0.2.9.tgz", "integrity": "sha512-NUcwaKxUxWrZLpDG+z/xZaCgQITkA/Dv4V/T6bw7VON6l1Xz/VnrBqrYjZQ12TamKHzITTfOEIYUj48y2KXImA==", "dev": true }, - "parse-semver": { + "node_modules/parse-semver": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/parse-semver/-/parse-semver-1.1.1.tgz", "integrity": "sha512-Eg1OuNntBMH0ojvEKSrvDSnwLmvVuUOSdylH/pSCPNMIspLlweJyIWXCE+k/5hm3cj/EBUYwmWkjhBALNP4LXQ==", "dev": true, - "requires": { - "semver": "^5.1.0" - }, "dependencies": { - "semver": { - "version": "5.7.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", - "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", - "dev": true - } + "semver": "^5.1.0" + } + }, + "node_modules/parse-semver/node_modules/semver": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "dev": true, + "bin": { + "semver": "bin/semver" } }, - "parse5": { + "node_modules/parse5": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.1.2.tgz", "integrity": "sha512-Czj1WaSVpaoj0wbhMzLmWD69anp2WH7FXMB9n1Sy8/ZFF9jolSQVMu1Ij5WIyGmcBmhk7EOndpO4mIpihVqAXw==", "dev": true, - "requires": { + "dependencies": { "entities": "^4.4.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" } }, - "parse5-htmlparser2-tree-adapter": { + "node_modules/parse5-htmlparser2-tree-adapter": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-7.0.0.tgz", "integrity": "sha512-B77tOZrqqfUfnVcOrUvfdLbz4pu4RopLD/4vmu3HUPswwTA8OH0EMW9BlWR2B0RCoiZRAHEUu7IxeP1Pd1UU+g==", "dev": true, - "requires": { + "dependencies": { "domhandler": "^5.0.2", "parse5": "^7.0.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" } }, - "parseurl": { + "node_modules/parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.8" + } }, - "path-browserify": { + "node_modules/path-browserify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz", "integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==", "dev": true }, - "path-exists": { + "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true + "dev": true, + "engines": { + "node": ">=8" + } }, - "path-is-absolute": { + "node_modules/path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", - "dev": true - }, - "path-key": { + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-key": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true + "dev": true, + "engines": { + "node": ">=8" + } }, - "path-parse": { + "node_modules/path-parse": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", "dev": true }, - "path-to-regexp": { + "node_modules/path-to-regexp": { "version": "6.2.1", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.2.1.tgz", "integrity": "sha512-JLyh7xT1kizaEvcaXOQwOc2/Yhw6KZOvPf1S8401UyLk86CU79LN3vl7ztXGm/pZ+YjoyAJ4rxmHwbkBXJX+yw==", "dev": true }, - "peek-stream": { + "node_modules/peek-stream": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/peek-stream/-/peek-stream-1.1.3.tgz", "integrity": "sha512-FhJ+YbOSBb9/rIl2ZeE/QHEsWn7PqNYt8ARAY3kIgNGOk13g9FGyIY6JIl/xB/3TFRVoTv5as0l11weORrTekA==", "dev": true, - "requires": { + "dependencies": { "buffer-from": "^1.0.0", "duplexify": "^3.5.0", "through2": "^2.0.3" } }, - "pend": { + "node_modules/pend": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", "integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==", "dev": true }, - "picocolors": { + "node_modules/picocolors": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", "dev": true }, - "picomatch": { + "node_modules/picomatch": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", - "dev": true + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } }, - "pkg-dir": { + "node_modules/pkg-dir": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", "dev": true, - "requires": { + "dependencies": { "find-up": "^4.0.0" + }, + "engines": { + "node": ">=8" } }, - "playwright": { + "node_modules/playwright": { "version": "1.42.1", "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.42.1.tgz", "integrity": "sha512-PgwB03s2DZBcNRoW+1w9E+VkLBxweib6KTXM0M3tkiT4jVxKSi6PmVJ591J+0u10LUrgxB7dLRbiJqO5s2QPMg==", "dev": true, - "requires": { - "fsevents": "2.3.2", + "dependencies": { "playwright-core": "1.42.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=16" + }, + "optionalDependencies": { + "fsevents": "2.3.2" } }, - "playwright-core": { + "node_modules/playwright-core": { "version": "1.42.1", "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.42.1.tgz", "integrity": "sha512-mxz6zclokgrke9p1vtdy/COWBH+eOZgYUVVU34C73M+4j4HLlQJHtfcqiqqxpP0o8HhMkflvfbquLX5dg6wlfA==", - "dev": true + "dev": true, + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=16" + } }, - "prebuild-install": { + "node_modules/prebuild-install": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.2.tgz", "integrity": "sha512-UnNke3IQb6sgarcZIDU3gbMeTp/9SSU1DAIkil7PrqG1vZlBtY5msYccSKSHDqa3hNg436IXK+SNImReuA1wEQ==", "dev": true, "optional": true, - "requires": { + "dependencies": { "detect-libc": "^2.0.0", "expand-template": "^2.0.3", "github-from-package": "0.0.0", @@ -2141,144 +2800,169 @@ "tar-fs": "^2.0.0", "tunnel-agent": "^0.6.0" }, + "bin": { + "prebuild-install": "bin.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/prebuild-install/node_modules/pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "dev": true, + "optional": true, "dependencies": { - "pump": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", - "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", - "dev": true, - "optional": true, - "requires": { - "end-of-stream": "^1.1.0", - "once": "^1.3.1" - } - }, - "readable-stream": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", - "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", - "dev": true, - "optional": true, - "requires": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - } - }, - "tar-fs": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz", - "integrity": "sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==", - "dev": true, - "optional": true, - "requires": { - "chownr": "^1.1.1", - "mkdirp-classic": "^0.5.2", - "pump": "^3.0.0", - "tar-stream": "^2.1.4" - } - }, - "tar-stream": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", - "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", - "dev": true, - "optional": true, - "requires": { - "bl": "^4.0.3", - "end-of-stream": "^1.4.1", - "fs-constants": "^1.0.0", - "inherits": "^2.0.3", - "readable-stream": "^3.1.1" - } - } + "end-of-stream": "^1.1.0", + "once": "^1.3.1" } }, - "process-nextick-args": { + "node_modules/prebuild-install/node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "dev": true, + "optional": true, + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/prebuild-install/node_modules/tar-fs": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz", + "integrity": "sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==", + "dev": true, + "optional": true, + "dependencies": { + "chownr": "^1.1.1", + "mkdirp-classic": "^0.5.2", + "pump": "^3.0.0", + "tar-stream": "^2.1.4" + } + }, + "node_modules/prebuild-install/node_modules/tar-stream": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", + "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", + "dev": true, + "optional": true, + "dependencies": { + "bl": "^4.0.3", + "end-of-stream": "^1.4.1", + "fs-constants": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", "dev": true }, - "pump": { + "node_modules/pump": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/pump/-/pump-2.0.1.tgz", "integrity": "sha512-ruPMNRkN3MHP1cWJc9OWr+T/xDP0jhXYCLfJcBuX54hhfIBnaQmAUMfDcG4DM5UMWByBbJY69QSphm3jtDKIkA==", "dev": true, - "requires": { + "dependencies": { "end-of-stream": "^1.1.0", "once": "^1.3.1" } }, - "pumpify": { + "node_modules/pumpify": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/pumpify/-/pumpify-1.5.1.tgz", "integrity": "sha512-oClZI37HvuUJJxSKKrC17bZ9Cu0ZYhEAGPsPUy9KlMUmv9dKX2o77RUmq7f3XjIxbwyGwYzbzQ1L2Ks8sIradQ==", "dev": true, - "requires": { + "dependencies": { "duplexify": "^3.6.0", "inherits": "^2.0.3", "pump": "^2.0.0" } }, - "punycode": { + "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", - "dev": true + "dev": true, + "engines": { + "node": ">=6" + } }, - "qs": { + "node_modules/qs": { "version": "6.11.2", "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.2.tgz", "integrity": "sha512-tDNIz22aBzCDxLtVH++VnTfzxlfeK5CbqohpSqpJgj1Wg/cQbStNAz3NuqCs5vV+pjBsK4x4pN9HlVh7rcYRiA==", "dev": true, - "requires": { + "dependencies": { "side-channel": "^1.0.4" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "queue-tick": { + "node_modules/queue-tick": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/queue-tick/-/queue-tick-1.0.1.tgz", "integrity": "sha512-kJt5qhMxoszgU/62PLP1CJytzd2NKetjSRnyuj31fDd3Rlcz3fzlFdFLD1SItunPwyqEOkca6GbV612BWfaBag==", "dev": true }, - "randombytes": { + "node_modules/randombytes": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", "dev": true, - "requires": { + "dependencies": { "safe-buffer": "^5.1.0" } }, - "rc": { + "node_modules/rc": { "version": "1.2.8", "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", "dev": true, "optional": true, - "requires": { + "dependencies": { "deep-extend": "^0.6.0", "ini": "~1.3.0", "minimist": "^1.2.0", "strip-json-comments": "~2.0.1" + }, + "bin": { + "rc": "cli.js" } }, - "read": { + "node_modules/read": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/read/-/read-1.0.7.tgz", "integrity": "sha512-rSOKNYUmaxy0om1BNjMN4ezNT6VKK+2xF4GBhc81mkH7L60i6dp8qPYrkndNLT3QPphoII3maL9PVC9XmhHwVQ==", "dev": true, - "requires": { + "dependencies": { "mute-stream": "~0.0.4" + }, + "engines": { + "node": ">=0.8" } }, - "readable-stream": { + "node_modules/readable-stream": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", "dev": true, - "requires": { + "dependencies": { "core-util-is": "~1.0.0", "inherits": "~2.0.3", "isarray": "~1.0.0", @@ -2288,588 +2972,810 @@ "util-deprecate": "~1.0.1" } }, - "rechoir": { + "node_modules/rechoir": { "version": "0.8.0", "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.8.0.tgz", "integrity": "sha512-/vxpCXddiX8NGfGO/mTafwjq4aFa/71pvamip0++IQk3zG8cbCj0fifNPrjjF1XMXUne91jL9OoxmdykoEtifQ==", "dev": true, - "requires": { + "dependencies": { "resolve": "^1.20.0" + }, + "engines": { + "node": ">= 10.13.0" } }, - "resolve": { + "node_modules/resolve": { "version": "1.22.8", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", "dev": true, - "requires": { + "dependencies": { "is-core-module": "^2.13.0", "path-parse": "^1.0.7", "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "resolve-cwd": { + "node_modules/resolve-cwd": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz", "integrity": "sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg==", "dev": true, - "requires": { + "dependencies": { "resolve-from": "^5.0.0" + }, + "engines": { + "node": ">=8" } }, - "resolve-from": { + "node_modules/resolve-from": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", - "dev": true + "dev": true, + "engines": { + "node": ">=8" + } }, - "resolve-path": { + "node_modules/resolve-path": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/resolve-path/-/resolve-path-1.4.0.tgz", "integrity": "sha512-i1xevIst/Qa+nA9olDxLWnLk8YZbi8R/7JPbCMcgyWaFR6bKWaexgJgEB5oc2PKMjYdrHynyz0NY+if+H98t1w==", "dev": true, - "requires": { + "dependencies": { "http-errors": "~1.6.2", "path-is-absolute": "1.0.1" }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/resolve-path/node_modules/depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/resolve-path/node_modules/http-errors": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", + "integrity": "sha512-lks+lVC8dgGyh97jxvxeYTWQFvh4uw4yC12gVl63Cg30sjPX4wuGcdkICVXDAESr6OJGjqGA8Iz5mkeN6zlD7A==", + "dev": true, "dependencies": { - "depd": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", - "integrity": "sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==", - "dev": true - }, - "http-errors": { - "version": "1.6.3", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", - "integrity": "sha512-lks+lVC8dgGyh97jxvxeYTWQFvh4uw4yC12gVl63Cg30sjPX4wuGcdkICVXDAESr6OJGjqGA8Iz5mkeN6zlD7A==", - "dev": true, - "requires": { - "depd": "~1.1.2", - "inherits": "2.0.3", - "setprototypeof": "1.1.0", - "statuses": ">= 1.4.0 < 2" - } - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==", - "dev": true - }, - "setprototypeof": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", - "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==", - "dev": true - }, - "statuses": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", - "integrity": "sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==", - "dev": true - } + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.0", + "statuses": ">= 1.4.0 < 2" + }, + "engines": { + "node": ">= 0.6" } }, - "safe-buffer": { + "node_modules/resolve-path/node_modules/inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==", + "dev": true + }, + "node_modules/resolve-path/node_modules/setprototypeof": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", + "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==", + "dev": true + }, + "node_modules/resolve-path/node_modules/statuses": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", + "integrity": "sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", "dev": true }, - "sax": { + "node_modules/sax": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/sax/-/sax-1.3.0.tgz", "integrity": "sha512-0s+oAmw9zLl1V1cS9BtZN7JAd0cW5e0QH4W3LWEK6a4LaLEA2OTpGYWDY+6XasBLtz6wkm3u1xRw95mRuJ59WA==", "dev": true }, - "schema-utils": { + "node_modules/schema-utils": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.3.0.tgz", "integrity": "sha512-pN/yOAvcC+5rQ5nERGuwrjLlYvLTbCibnZ1I7B1LaiAz9BRBlE9GMgE/eqV30P7aJQUf7Ddimy/RsbYO/GrVGg==", "dev": true, - "requires": { + "dependencies": { "@types/json-schema": "^7.0.8", "ajv": "^6.12.5", "ajv-keywords": "^3.5.2" + }, + "engines": { + "node": ">= 10.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" } }, - "semver": { + "node_modules/semver": { "version": "7.6.0", "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", "dev": true, - "requires": { + "dependencies": { "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" } }, - "serialize-javascript": { + "node_modules/serialize-javascript": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz", "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==", "dev": true, - "requires": { + "dependencies": { "randombytes": "^2.1.0" } }, - "set-function-length": { + "node_modules/set-function-length": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.1.tgz", "integrity": "sha512-j4t6ccc+VsKwYHso+kElc5neZpjtq9EnRICFZtWyBsLojhmeF/ZBd/elqm22WJh/BziDe/SBiOeAt0m2mfLD0g==", "dev": true, - "requires": { + "dependencies": { "define-data-property": "^1.1.2", "es-errors": "^1.3.0", "function-bind": "^1.1.2", "get-intrinsic": "^1.2.3", "gopd": "^1.0.1", "has-property-descriptors": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" } }, - "setprototypeof": { + "node_modules/setprototypeof": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", "dev": true }, - "shallow-clone": { + "node_modules/shallow-clone": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/shallow-clone/-/shallow-clone-3.0.1.tgz", "integrity": "sha512-/6KqX+GVUdqPuPPd2LxDDxzX6CAbjJehAAOKlNpqqUpAqPM6HeL8f+o3a+JsyGjn2lv0WY8UsTgUJjU9Ok55NA==", "dev": true, - "requires": { + "dependencies": { "kind-of": "^6.0.2" + }, + "engines": { + "node": ">=8" } }, - "shebang-command": { + "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", "dev": true, - "requires": { + "dependencies": { "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" } }, - "shebang-regex": { + "node_modules/shebang-regex": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true + "dev": true, + "engines": { + "node": ">=8" + } }, - "side-channel": { + "node_modules/side-channel": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.6.tgz", "integrity": "sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA==", "dev": true, - "requires": { + "dependencies": { "call-bind": "^1.0.7", "es-errors": "^1.3.0", "get-intrinsic": "^1.2.4", "object-inspect": "^1.13.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "simple-concat": { + "node_modules/simple-concat": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==", "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], "optional": true }, - "simple-get": { + "node_modules/simple-get": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-4.0.1.tgz", "integrity": "sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==", "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], "optional": true, - "requires": { + "dependencies": { "decompress-response": "^6.0.0", "once": "^1.3.1", "simple-concat": "^1.0.0" } }, - "source-map": { + "node_modules/source-map": { "version": "0.7.4", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.4.tgz", "integrity": "sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==", - "dev": true + "dev": true, + "engines": { + "node": ">= 8" + } }, - "source-map-support": { + "node_modules/source-map-support": { "version": "0.5.21", "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", "dev": true, - "requires": { + "dependencies": { "buffer-from": "^1.0.0", "source-map": "^0.6.0" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - } } }, - "statuses": { + "node_modules/source-map-support/node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/statuses": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.8" + } }, - "stream-shift": { + "node_modules/stream-shift": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.3.tgz", "integrity": "sha512-76ORR0DO1o1hlKwTbi/DM3EXWGf3ZJYO8cXX5RJwnul2DEg2oyoZyjLNoQM8WsvZiFKCRfC1O0J7iCvie3RZmQ==", "dev": true }, - "streamx": { + "node_modules/streamx": { "version": "2.16.1", "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.16.1.tgz", "integrity": "sha512-m9QYj6WygWyWa3H1YY69amr4nVgy61xfjys7xO7kviL5rfIEc2naf+ewFiOA+aEJD7y0JO3h2GoiUv4TDwEGzQ==", "dev": true, - "requires": { - "bare-events": "^2.2.0", + "dependencies": { "fast-fifo": "^1.1.0", "queue-tick": "^1.0.1" + }, + "optionalDependencies": { + "bare-events": "^2.2.0" } }, - "string_decoder": { + "node_modules/string_decoder": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, - "requires": { + "dependencies": { "safe-buffer": "~5.1.0" } }, - "strip-json-comments": { + "node_modules/strip-json-comments": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", "integrity": "sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==", "dev": true, - "optional": true + "optional": true, + "engines": { + "node": ">=0.10.0" + } }, - "supports-color": { + "node_modules/supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", "dev": true, - "requires": { + "dependencies": { "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" } }, - "supports-preserve-symlinks-flag": { + "node_modules/supports-preserve-symlinks-flag": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } }, - "tapable": { + "node_modules/tapable": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==", - "dev": true + "dev": true, + "engines": { + "node": ">=6" + } }, - "tar-fs": { + "node_modules/tar-fs": { "version": "3.0.5", "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-3.0.5.tgz", "integrity": "sha512-JOgGAmZyMgbqpLwct7ZV8VzkEB6pxXFBVErLtb+XCOqzc6w1xiWKI9GVd6bwk68EX7eJ4DWmfXVmq8K2ziZTGg==", "dev": true, - "requires": { - "bare-fs": "^2.1.1", - "bare-path": "^2.1.0", + "dependencies": { "pump": "^3.0.0", "tar-stream": "^3.1.5" }, + "optionalDependencies": { + "bare-fs": "^2.1.1", + "bare-path": "^2.1.0" + } + }, + "node_modules/tar-fs/node_modules/pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "dev": true, "dependencies": { - "pump": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", - "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", - "dev": true, - "requires": { - "end-of-stream": "^1.1.0", - "once": "^1.3.1" - } - } + "end-of-stream": "^1.1.0", + "once": "^1.3.1" } }, - "tar-stream": { + "node_modules/tar-stream": { "version": "3.1.7", "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-3.1.7.tgz", "integrity": "sha512-qJj60CXt7IU1Ffyc3NJMjh6EkuCFej46zUqJ4J7pqYlThyd9bO0XBTmcOIhSzZJVWfsLks0+nle/j538YAW9RQ==", "dev": true, - "requires": { + "dependencies": { "b4a": "^1.6.4", "fast-fifo": "^1.2.0", "streamx": "^2.15.0" } }, - "terser": { + "node_modules/terser": { "version": "5.28.1", "resolved": "https://registry.npmjs.org/terser/-/terser-5.28.1.tgz", "integrity": "sha512-wM+bZp54v/E9eRRGXb5ZFDvinrJIOaTapx3WUokyVGZu5ucVCK55zEgGd5Dl2fSr3jUo5sDiERErUWLY6QPFyA==", "dev": true, - "requires": { + "dependencies": { "@jridgewell/source-map": "^0.3.3", "acorn": "^8.8.2", "commander": "^2.20.0", "source-map-support": "~0.5.20" }, - "dependencies": { - "commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "dev": true - } + "bin": { + "terser": "bin/terser" + }, + "engines": { + "node": ">=10" } }, - "terser-webpack-plugin": { + "node_modules/terser-webpack-plugin": { "version": "5.3.10", "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.3.10.tgz", "integrity": "sha512-BKFPWlPDndPs+NGGCr1U59t0XScL5317Y0UReNrHaw9/FwhPENlq6bfgs+4yPfyP51vqC1bQ4rp1EfXW5ZSH9w==", "dev": true, - "requires": { + "dependencies": { "@jridgewell/trace-mapping": "^0.3.20", "jest-worker": "^27.4.5", "schema-utils": "^3.1.1", "serialize-javascript": "^6.0.1", "terser": "^5.26.0" + }, + "engines": { + "node": ">= 10.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + }, + "peerDependencies": { + "webpack": "^5.1.0" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "esbuild": { + "optional": true + }, + "uglify-js": { + "optional": true + } } }, - "through2": { + "node_modules/terser/node_modules/commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true + }, + "node_modules/through2": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", "dev": true, - "requires": { + "dependencies": { "readable-stream": "~2.3.6", "xtend": "~4.0.1" } }, - "tmp": { + "node_modules/tmp": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.3.tgz", "integrity": "sha512-nZD7m9iCPC5g0pYmcaxogYKggSfLsdxl8of3Q/oIbqCqLLIO9IAF0GWjX1z9NZRHPiXv8Wex4yDCaZsgEw0Y8w==", - "dev": true + "dev": true, + "engines": { + "node": ">=14.14" + } }, - "to-regex-range": { + "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", "dev": true, - "requires": { + "dependencies": { "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" } }, - "toidentifier": { + "node_modules/toidentifier": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.6" + } }, - "tree-sitter-cli": { + "node_modules/tree-sitter-cli": { "version": "0.20.8", "resolved": "https://registry.npmjs.org/tree-sitter-cli/-/tree-sitter-cli-0.20.8.tgz", "integrity": "sha512-XjTcS3wdTy/2cc/ptMLc/WRyOLECRYcMTrSWyhZnj1oGSOWbHLTklgsgRICU3cPfb0vy+oZCC33M43u6R1HSCA==", - "dev": true + "dev": true, + "hasInstallScript": true, + "bin": { + "tree-sitter": "cli.js" + } }, - "ts-loader": { + "node_modules/ts-loader": { "version": "9.5.1", "resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-9.5.1.tgz", "integrity": "sha512-rNH3sK9kGZcH9dYzC7CewQm4NtxJTjSEVRJ2DyBZR7f8/wcta+iV44UPCXc5+nzDzivKtlzV6c9P4e+oFhDLYg==", "dev": true, - "requires": { + "dependencies": { "chalk": "^4.1.0", "enhanced-resolve": "^5.0.0", "micromatch": "^4.0.0", "semver": "^7.3.4", "source-map": "^0.7.4" }, + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "typescript": "*", + "webpack": "^5.0.0" + } + }, + "node_modules/ts-loader/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/ts-loader/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/ts-loader/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/ts-loader/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/ts-loader/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/ts-loader/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" } }, - "tsscmp": { + "node_modules/tsscmp": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/tsscmp/-/tsscmp-1.0.6.tgz", "integrity": "sha512-LxhtAkPDTkVCMQjt2h6eBVY28KCjikZqZfMcC15YBeNjkgUpdCfBu5HoiOTDu86v6smE8yOjyEktJ8hlbANHQA==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.6.x" + } }, - "tunnel": { + "node_modules/tunnel": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.6.11 <=0.7.0 || >=0.7.3" + } }, - "tunnel-agent": { + "node_modules/tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", "integrity": "sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==", "dev": true, "optional": true, - "requires": { + "dependencies": { "safe-buffer": "^5.0.1" + }, + "engines": { + "node": "*" } }, - "type-is": { + "node_modules/type-is": { "version": "1.6.18", "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", "dev": true, - "requires": { + "dependencies": { "media-typer": "0.3.0", "mime-types": "~2.1.24" + }, + "engines": { + "node": ">= 0.6" } }, - "typed-rest-client": { + "node_modules/typed-rest-client": { "version": "1.8.11", "resolved": "https://registry.npmjs.org/typed-rest-client/-/typed-rest-client-1.8.11.tgz", "integrity": "sha512-5UvfMpd1oelmUPRbbaVnq+rHP7ng2cE4qoQkQeAqxRL6PklkxsM0g32/HL0yfvruK6ojQ5x8EE+HF4YV6DtuCA==", "dev": true, - "requires": { + "dependencies": { "qs": "^6.9.1", "tunnel": "0.0.6", "underscore": "^1.12.1" } }, - "typescript": { + "node_modules/typescript": { "version": "5.3.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", - "dev": true + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } }, - "uc.micro": { + "node_modules/uc.micro": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz", "integrity": "sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==", "dev": true }, - "underscore": { + "node_modules/underscore": { "version": "1.13.6", "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.6.tgz", "integrity": "sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A==", "dev": true }, - "update-browserslist-db": { + "node_modules/update-browserslist-db": { "version": "1.0.13", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz", "integrity": "sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg==", "dev": true, - "requires": { + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { "escalade": "^3.1.1", "picocolors": "^1.0.0" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" } }, - "uri-js": { + "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", "dev": true, - "requires": { + "dependencies": { "punycode": "^2.1.0" } }, - "url-join": { + "node_modules/url-join": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/url-join/-/url-join-4.0.1.tgz", "integrity": "sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA==", "dev": true }, - "util-deprecate": { + "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", "dev": true }, - "vary": { + "node_modules/vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", - "dev": true + "dev": true, + "engines": { + "node": ">= 0.8" + } }, - "vscode-oniguruma": { + "node_modules/vscode-oniguruma": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/vscode-oniguruma/-/vscode-oniguruma-1.7.0.tgz", "integrity": "sha512-L9WMGRfrjOhgHSdOYgCt/yRMsXzLDJSL7BPrOZt73gU0iWO4mpqzqQzOz5srxqTvMBaR0XZTSrVWo4j55Rc6cA==" }, - "vscode-uri": { + "node_modules/vscode-textmate": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-9.0.0.tgz", + "integrity": "sha512-Cl65diFGxz7gpwbav10HqiY/eVYTO1sjQpmRmV991Bj7wAoOAjGQ97PpQcXorDE2Uc4hnGWLY17xme+5t6MlSg==" + }, + "node_modules/vscode-uri": { "version": "3.0.8", "resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-3.0.8.tgz", "integrity": "sha512-AyFQ0EVmsOZOlAnxoFOGOq1SQDWAB7C6aqMGS23svWAllfOaxbuFvcT8D1i8z3Gyn8fraVeZNNmN6e9bxxXkKw==", "dev": true }, - "watchpack": { + "node_modules/watchpack": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.0.tgz", "integrity": "sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg==", "dev": true, - "requires": { + "dependencies": { "glob-to-regexp": "^0.4.1", "graceful-fs": "^4.1.2" + }, + "engines": { + "node": ">=10.13.0" } }, - "web-tree-sitter": { + "node_modules/web-tree-sitter": { "version": "0.20.8", "resolved": "https://registry.npmjs.org/web-tree-sitter/-/web-tree-sitter-0.20.8.tgz", "integrity": "sha512-weOVgZ3aAARgdnb220GqYuh7+rZU0Ka9k9yfKtGAzEYMa6GgiCzW9JjQRJyCJakvibQW+dfjJdihjInKuuCAUQ==" }, - "webpack": { + "node_modules/webpack": { "version": "5.90.3", "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.90.3.tgz", "integrity": "sha512-h6uDYlWCctQRuXBs1oYpVe6sFcWedl0dpcVaTf/YF67J9bKvwJajFulMVSYKHrksMB3I/pIagRzDxwxkebuzKA==", "dev": true, - "requires": { + "dependencies": { "@types/eslint-scope": "^3.7.3", "@types/estree": "^1.0.5", "@webassemblyjs/ast": "^1.11.5", @@ -2894,14 +3800,29 @@ "terser-webpack-plugin": "^5.3.10", "watchpack": "^2.4.0", "webpack-sources": "^3.2.3" + }, + "bin": { + "webpack": "bin/webpack.js" + }, + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + }, + "peerDependenciesMeta": { + "webpack-cli": { + "optional": true + } } }, - "webpack-cli": { + "node_modules/webpack-cli": { "version": "5.1.4", "resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-5.1.4.tgz", "integrity": "sha512-pIDJHIEI9LR0yxHXQ+Qh95k2EvXpWzZ5l+d+jIo+RdSm9MiHfzazIxwwni/p7+x4eJZuvG1AJwgC4TNQ7NRgsg==", "dev": true, - "requires": { + "dependencies": { "@discoveryjs/json-ext": "^0.5.0", "@webpack-cli/configtest": "^2.1.1", "@webpack-cli/info": "^2.0.2", @@ -2916,105 +3837,154 @@ "rechoir": "^0.8.0", "webpack-merge": "^5.7.3" }, - "dependencies": { - "commander": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-10.0.1.tgz", - "integrity": "sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==", - "dev": true + "bin": { + "webpack-cli": "bin/cli.js" + }, + "engines": { + "node": ">=14.15.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + }, + "peerDependencies": { + "webpack": "5.x.x" + }, + "peerDependenciesMeta": { + "@webpack-cli/generators": { + "optional": true + }, + "webpack-bundle-analyzer": { + "optional": true + }, + "webpack-dev-server": { + "optional": true } } }, - "webpack-merge": { + "node_modules/webpack-cli/node_modules/commander": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-10.0.1.tgz", + "integrity": "sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==", + "dev": true, + "engines": { + "node": ">=14" + } + }, + "node_modules/webpack-merge": { "version": "5.10.0", "resolved": "https://registry.npmjs.org/webpack-merge/-/webpack-merge-5.10.0.tgz", "integrity": "sha512-+4zXKdx7UnO+1jaN4l2lHVD+mFvnlZQP/6ljaJVb4SZiwIKeUnrT5l0gkT8z+n4hKpC+jpOv6O9R+gLtag7pSA==", "dev": true, - "requires": { + "dependencies": { "clone-deep": "^4.0.1", "flat": "^5.0.2", "wildcard": "^2.0.0" + }, + "engines": { + "node": ">=10.0.0" } }, - "webpack-sources": { + "node_modules/webpack-sources": { "version": "3.2.3", "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-3.2.3.tgz", "integrity": "sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==", - "dev": true + "dev": true, + "engines": { + "node": ">=10.13.0" + } }, - "which": { + "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", "dev": true, - "requires": { + "dependencies": { "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" } }, - "wildcard": { + "node_modules/wildcard": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/wildcard/-/wildcard-2.0.1.tgz", "integrity": "sha512-CC1bOL87PIWSBhDcTrdeLo6eGT7mCFtrg0uIJtqJUFyK+eJnzl8A1niH56uu7KMa5XFrtiV+AQuHO3n7DsHnLQ==", "dev": true }, - "wrappy": { + "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "dev": true }, - "xml2js": { + "node_modules/xml2js": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.5.0.tgz", "integrity": "sha512-drPFnkQJik/O+uPKpqSgr22mpuFHqKdbS835iAQrUC73L2F5WkboIRd63ai/2Yg6I1jzifPFKH2NTK+cfglkIA==", "dev": true, - "requires": { + "dependencies": { "sax": ">=0.6.0", "xmlbuilder": "~11.0.0" + }, + "engines": { + "node": ">=4.0.0" } }, - "xmlbuilder": { + "node_modules/xmlbuilder": { "version": "11.0.1", "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz", "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==", - "dev": true + "dev": true, + "engines": { + "node": ">=4.0" + } }, - "xtend": { + "node_modules/xtend": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.4" + } }, - "yallist": { + "node_modules/yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "dev": true }, - "yauzl": { + "node_modules/yauzl": { "version": "2.10.0", "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", "integrity": "sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==", "dev": true, - "requires": { + "dependencies": { "buffer-crc32": "~0.2.3", "fd-slicer": "~1.1.0" } }, - "yazl": { + "node_modules/yazl": { "version": "2.5.1", "resolved": "https://registry.npmjs.org/yazl/-/yazl-2.5.1.tgz", "integrity": "sha512-phENi2PLiHnHb6QBVot+dJnaAZ0xosj7p3fWl+znIjBDlnMI2PsZCJZ306BPTFOaHf5qdDEI8x5qFrSOBN5vrw==", "dev": true, - "requires": { + "dependencies": { "buffer-crc32": "~0.2.3" } }, - "ylru": { + "node_modules/ylru": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/ylru/-/ylru-1.3.2.tgz", "integrity": "sha512-RXRJzMiK6U2ye0BlGGZnmpwJDPgakn6aNQ0A7gHRbD4I0uvK4TW6UqkK1V0pp9jskjJBAXd3dRrbzWkqJ+6cxA==", - "dev": true + "dev": true, + "engines": { + "node": ">= 4.0.0" + } } } } diff --git a/package.json b/package.json index f86454a..e51bf14 100644 --- a/package.json +++ b/package.json @@ -187,14 +187,98 @@ "fileMatch": "*.JSON-tmLanguage", "url": "./vscode.tmLanguage.schema.json" } + ], + "viewsContainers": { + "activitybar": [ + { + "id": "TextMate", + "title": "TextMate", + "icon": "assets/TextMate-file-icon.svg" + } + ] + }, + "views": { + "TextMate": [ + { + "id": "TextMate", + "name": "TextMate Call Stack", + "contextualTitle": "TextMate", + "icon": "assets/TextMate-file-icon.svg", + "visibility": "collapsed" + } + ] + }, + "menus": { + "editor/context": [ + { + "command": "textmate.callstack", + "group": "0_navigation@9" + } + ], + "view/title": [ + { + "command": "textmate.refresh", + "group": "navigation", + "when": "view == TextMate" + }, + { + "command": "textmate.follow.cursor", + "group": "config@1", + "when": "view == TextMate" + } + ], + "view/item/context": [ + { + "command": "textmate.goto", + "group": "0_navigation@1", + "when": "view == TextMate" + }, + { + "command": "textmate.refresh", + "group": "inline@1", + "when": "view == TextMate" + }, + { + "command": "textmate.goto", + "group": "inline@2", + "when": "view == TextMate" + } + ] + }, + "commands": [ + { + "command": "textmate.callstack", + "title": "Show TextMate Calling Stack", + "shortTitle": "TextMate Call Stack", + "category": "TextMate", + "icon": "assets/TextMate-file-icon.svg" + }, + { + "command": "textmate.refresh", + "title": "Refresh", + "category": "TextMate", + "icon": "$(refresh)" + }, + { + "command": "textmate.follow.cursor", + "title": "Follow Cursor", + "category": "TextMate", + "icon": "assets/TextMate-file-icon.svg" + }, + { + "command": "textmate.goto", + "title": "Go To", + "category": "TextMate", + "icon": "$(export)" + } ] }, "dependencies": { "vscode-oniguruma": "1.7.0", + "vscode-textmate": "9.0.0", "web-tree-sitter": "^0.20.8" }, "devDependencies": { - "@types/node": "^16.18.83", "@types/vscode": "^1.85.0", "@vscode/test-web": "^0.0.52", "@vscode/vsce": "^2.22.0", diff --git a/src/TextMate.ts b/src/TextMate.ts new file mode 100644 index 0000000..6b57a79 --- /dev/null +++ b/src/TextMate.ts @@ -0,0 +1,460 @@ +import * as vscode from 'vscode'; +import * as vscodeTextmate from './textmate/main'; +// import * as vscodeTextmate from "vscode-textmate"; +import * as vscodeOniguruma from "vscode-oniguruma"; +import { IRelaxedExtensionManifest } from './extensions'; +import { stringify } from './extension'; + +// const ruleIdSymbol = Symbol('RuleId'); +// export type RuleId = { __brand: typeof ruleIdSymbol }; +export type RuleId = number; +export const endRuleId = -1; +export const whileRuleId = -2; + +/** + * Identifiers with a binary dot operator. + * Examples: `baz` or `foo.bar` +*/ +type ScopeName = string; +type ScopeStack = { + + readonly parent: ScopeStack | null, + readonly scopeName: ScopeName +} +type EncodedTokenAttributes = number; + +type AttributedScopeStack = { + + readonly parent: AttributedScopeStack | null, + readonly scopePath: ScopeStack, + readonly tokenAttributes: EncodedTokenAttributes +} + +export type StateStackImpl = vscodeTextmate.StateStack & { + readonly _stackElementBrand: void; + + /** + * The position on the current line where this state was pushed. + * This is relevant only while tokenizing a line, to detect endless loops. + * Its value is meaningless across lines. + */ + readonly _enterPos: number; + + /** + * The captured anchor position when this stack element was pushed. + * This is relevant only while tokenizing a line, to restore the anchor position when popping. + * Its value is meaningless across lines. + */ + readonly _anchorPos: number; + + /** + * The depth of the stack. + */ + readonly depth: number; + + /** + * The previous state on the stack (or null for the root state). + */ + readonly parent: StateStackImpl | null, + + /** + * The state (rule) that this element represents. + */ + readonly ruleId: RuleId, + + /** + * The state has entered and captured \n. This means that the next line should have an anchorPosition of 0. + */ + readonly beginRuleCapturedEOL: boolean, + + /** + * The "pop" (end) condition for this state in case that it was dynamically generated through captured text. + */ + readonly endRule: string | null, + + /** + * The list of scopes containing the "name" for this state. + */ + readonly nameScopesList: AttributedScopeStack | null, + + /** + * The list of scopes containing the "contentName" (besides "name") for this state. + * This list **must** contain as an element `scopeName`. + */ + readonly contentNameScopesList: AttributedScopeStack | null +} + +interface IRegExpSourceAnchorCache { + readonly A0_G0: string; + readonly A0_G1: string; + readonly A1_G0: string; + readonly A1_G1: string; +} + +type RegExpSource = { + + readonly source: string; + readonly ruleId: TRuleId; + readonly hasAnchor: boolean; + readonly hasBackReferences: boolean; + readonly _anchorCache: IRegExpSourceAnchorCache | null; +} + +type CaptureRule = Rule & { + readonly retokenizeCapturedWithRuleId: RuleId | 0; +} + +type IRegExpSourceListAnchorCache = { + readonly A0_G0: CompiledRule | null, + readonly A0_G1: CompiledRule | null, + readonly A1_G0: CompiledRule | null, + readonly A1_G1: CompiledRule | null, +} +export type CompiledRule = { + readonly scanner: vscodeOniguruma.OnigScanner; +} +export type RegExpSourceList = { + + readonly _items: RegExpSource[], + readonly _hasAnchors: boolean, + readonly _cached: CompiledRule | null, + readonly _anchorCache: IRegExpSourceListAnchorCache, +} + +export type Rule = { + readonly $location: undefined; + readonly id: RuleId; + readonly _nameIsCapturing: boolean; + readonly _name: string | null; + readonly _contentNameIsCapturing: boolean; + readonly _contentName: string | null; + + + readonly _begin: RegExpSource, + readonly beginCaptures: (CaptureRule | null)[], + readonly _end: RegExpSource, + readonly endHasBackReferences: boolean, + readonly endCaptures: (CaptureRule | null)[], + readonly applyEndPatternLast: boolean, + readonly hasMissingPatterns: boolean, + readonly patterns: RuleId[], + readonly _cachedCompiledPatterns: RegExpSourceList | null, + + + readonly whileCaptures: (CaptureRule | null)[], + readonly _while: RegExpSource, + readonly whileHasBackReferences: boolean, + _cachedCompiledWhilePatterns: RegExpSourceList | null, +} + +interface IOnigCaptureIndex { + readonly start: number; + readonly end: number; + readonly length: number; +} +export type IMatchResult = { + readonly captureIndices: IOnigCaptureIndex[]; + readonly matchedRuleId: RuleId | typeof endRuleId; +} +type Matcher = { + (matcherInput: T): boolean; +} +type BalancedBracketSelectors = { + readonly balancedBracketScopes: Matcher[]; + readonly unbalancedBracketScopes: Matcher[]; + readonly allowAny: boolean; +} +type IGrammarRepository = { + lookup(scopeName: ScopeName): vscodeTextmate.IRawGrammar | undefined; + injections(scopeName: ScopeName): ScopeName[]; +} +const enum FontStyle { + NotSet = -1, + None = 0, + Italic = 1, + Bold = 2, + Underline = 4, + Strikethrough = 8 +} +type OrMask = number; +type StyleAttributes = { + readonly fontStyle: OrMask, + readonly foregroundId: number, + readonly backgroundId: number +} +type IThemeProvider = { + themeMatch(scopePath: ScopeStack): StyleAttributes | null; + getDefaults(): StyleAttributes; +} +const enum OptionalStandardTokenType { + Other = 0, + Comment = 1, + String = 2, + RegEx = 3, + // Indicates that no token type is set. + NotSet = 8 +} +type BasicScopeAttributes = { + readonly languageId: number, + readonly tokenType: OptionalStandardTokenType +} + +type ScopeMatcher = { + readonly values: ReadonlyMap | null; + readonly scopesRegExp: RegExp | null; +} + +type BasicScopeAttributesProvider = { + readonly _defaultAttributes: BasicScopeAttributes; + readonly _embeddedLanguagesMatcher: ScopeMatcher; +} +type Injection = { + readonly debugSelector: string; + readonly matcher: Matcher; + readonly priority: -1 | 0 | 1; // 0 is the default. -1 for 'L' and 1 for 'R' + readonly ruleId: RuleId; + readonly grammar: vscodeTextmate.IRawGrammar; +} + +const enum StandardTokenType { + Other = 0, + Comment = 1, + String = 2, + RegEx = 3 +} +interface TokenTypeMatcher { + readonly matcher: Matcher; + readonly type: StandardTokenType; +} +export type IGrammar = vscodeTextmate.IGrammar & { + rules: IMatchResult[], + readonly _rootScopeName: ScopeName, + readonly grammar: vscodeTextmate.IRawGrammar, + readonly initialLanguage: number, + readonly embeddedLanguages: vscodeTextmate.IEmbeddedLanguagesMap | null, + readonly tokenTypes: vscodeTextmate.ITokenTypeMap | null, + readonly balancedBracketSelectors: BalancedBracketSelectors | null, + readonly grammarRepository: IGrammarRepository & IThemeProvider, + readonly _onigLib: vscodeTextmate.IOnigLib, + + readonly _rootId: RuleId | -1, + readonly _lastRuleId: number, + readonly _ruleId2desc: Rule[], + readonly _includedGrammars: { [scopeName: string]: vscodeTextmate.IRawGrammar }, + readonly _grammarRepository: IGrammarRepository & IThemeProvider, + readonly _grammar: vscodeTextmate.IRawGrammar, + readonly _injections: Injection[] | null, + readonly _basicScopeAttributesProvider: BasicScopeAttributesProvider, + readonly _tokenTypeMatchers: TokenTypeMatcher[], + +}; + + +type ILocation = { + readonly filename: string; + readonly line: number; + readonly char: number; +} +type ILocatable = { + readonly $vscodeTextmateLocation?: ILocation; +} + +type IncludeString = string; +type RegExpString = string; + +type IRawCaptures = IRawCapturesMap & ILocatable; + +type IRawCapturesMap = { + [captureId: string]: IRawRule; +} + +type IRawRepositoryMap = { + [name: string]: IRawRule; + $self: IRawRule; + $base: IRawRule; +} + +type IRawRepository = IRawRepositoryMap & ILocatable; + +export type IRawRule = ILocatable & { + id?: RuleId; // This is not part of the spec only used internally + + readonly include?: IncludeString; + + readonly name?: ScopeName; + readonly contentName?: ScopeName; + + readonly match?: RegExpString; + readonly captures?: IRawCaptures; + readonly begin?: RegExpString; + readonly beginCaptures?: IRawCaptures; + readonly end?: RegExpString; + readonly endCaptures?: IRawCaptures; + readonly while?: RegExpString; + readonly whileCaptures?: IRawCaptures; + readonly patterns?: IRawRule[]; + + readonly repository?: IRawRepository; + + readonly applyEndPatternLast?: boolean; +} + + +export type IRawGrammar = ILocatable & { + repository: IRawRepository; + readonly scopeName: ScopeName; + readonly patterns: IRawRule[]; + readonly injections?: { [expression: string]: IRawRule }; + readonly injectionSelector?: string; + + readonly fileTypes?: string[]; + readonly name?: string; + readonly firstLineMatch?: string; +} + + +async function onigLibInterface() { + return { + createOnigScanner(sources: string[]): vscodeOniguruma.OnigScanner { + return new vscodeOniguruma.OnigScanner(sources); + }, + createOnigString(str: string) { + return new vscodeOniguruma.OnigString(str); + } + }; +} + +async function loadGrammar(scopeName: string): Promise { + for (const extension of vscode.extensions.all) { + const packageJSON: IRelaxedExtensionManifest = extension.packageJSON; + const grammars = packageJSON.contributes?.grammars; + if (grammars) { + for (const grammar of grammars) { + if (grammar.scopeName == scopeName) { + const path = grammar.path; + if (path) { + const uri = vscode.Uri.joinPath(extension.extensionUri, path); + if (uri.scheme != 'untitled') { + const document = await vscode.workspace.openTextDocument(uri); + const rawGrammar = vscodeTextmate.parseRawGrammar(document.getText(), uri.path); + return rawGrammar; + } + } + } + } + } + } + vscode.window.showInformationMessage(`Unknown scopeName: ${scopeName}`); + console.log(`TextMate: Unknown scope name: ${scopeName}`); + return null; +} + +let registry: vscodeTextmate.Registry; +export function initTextMate(context: vscode.ExtensionContext): void { + const options: vscodeTextmate.RegistryOptions = { + onigLib: onigLibInterface(), + loadGrammar: loadGrammar, + } + + // Create a registry that can create a grammar from a scope name. + registry = new vscodeTextmate.Registry(options); + +} + +function getScopeName(lang: string): string { + for (const extension of vscode.extensions.all) { + const packageJSON: IRelaxedExtensionManifest = extension.packageJSON; + const grammars = packageJSON.contributes?.grammars; + if (grammars) { + for (const grammar of grammars) { + if (grammar.language == lang) { + const scopeName = grammar.scopeName; + if (scopeName) { + return scopeName; + } + } + } + } + } + return null; +} + +export async function tokenizeLine(document: vscode.TextDocument, lineNumber: number) { + const lang = document.languageId; + const scopeName = getScopeName(lang); + const grammar = await registry.loadGrammar(scopeName); + // vscode.window.showInformationMessage(JSON.stringify(grammar)); + // vscode.window.showInformationMessage(JSON.stringify(grammar, stringify)); + + // const text = [ + // `function sayHello(name) {`, + // `\treturn "Hello, " + name;`, + // `}` + // ]; + // const text = document.getText(); + + let tokenLineResult; + let ruleStack = vscodeTextmate.INITIAL; + for (let i = 0; i <= lineNumber; i++) { + const line = document.lineAt(i).text; + // const line = text[i]; + // vscode.window.showInformationMessage(JSON.stringify(ruleStack)); + // const lineTokens = tokenizeLine(grammar, line, ruleStack); + const lineTokens = grammar.tokenizeLine(line, ruleStack, 15000); + // vscode.window.showInformationMessage(JSON.stringify(lineTokens)); + // console.log(`\nTokenizing line: ${line}`); + // for (let j = 0; j < lineTokens.tokens.length; j++) { + // const token = lineTokens.tokens[j]; + // console.log(` - token from ${token.startIndex} to ${token.endIndex} ` + + // `(${line.substring(token.startIndex, token.endIndex)}) ` + + // `with scopes ${token.scopes.join(', ')}` + // ); + // } + ruleStack = lineTokens.ruleStack; + tokenLineResult = lineTokens; + } + + + // vscode.window.showInformationMessage(stringifyMaxDepth(grammar._ruleId2desc, 6)); + // @ts-ignore + // vscode.window.showInformationMessage(JSON.stringify((grammar as Grammar)._ruleId2desc, stringify)); + // vscode.window.showInformationMessage(JSON.stringify(ruleStack, stringify)); + return tokenLineResult; +} + + +export async function tokenizeFile(document: vscode.TextDocument): Promise { + const lang = document.languageId; + const scopeName = getScopeName(lang); + // const grammar = await registry.loadGrammar(scopeName); + + const grammar = await registry.loadGrammar(scopeName); + // Very hacky, assigns array so `_tokenizeString()` can add rules to it + grammar.rules = []; + + // const tokenLineResults: vscodeTextmate.ITokenizeLineResult[] = []; + let ruleStack = vscodeTextmate.INITIAL; + for (let i = 0; i < document.lineCount; i++) { + const line = document.lineAt(i).text; + const lineTokens = grammar.tokenizeLine(line, ruleStack, 15000); + // tokenLineResults.push( + // { + // tokens: lineTokens.tokens, + // ruleStack: structuredClone(lineTokens.ruleStack), + // stoppedEarly: lineTokens.stoppedEarly, + // } + // ); + + // one liner? + grammar.rules.pop(); + grammar.rules.push(undefined); + ruleStack = lineTokens.ruleStack; + } + + // vscode.window.showInformationMessage(JSON.stringify(registry, stringify)); + vscode.window.showInformationMessage(JSON.stringify(grammar, stringify)); + // vscode.window.showInformationMessage(JSON.stringify(tokenLineResults, stringify)); + + // return tokenLineResults; + return grammar; +} \ No newline at end of file diff --git a/src/TreeDataProvider.ts b/src/TreeDataProvider.ts new file mode 100644 index 0000000..c425f3e --- /dev/null +++ b/src/TreeDataProvider.ts @@ -0,0 +1,749 @@ +import * as vscode from 'vscode'; +import * as vscodeTextmate from './textmate/main'; +// import * as vscodeTextmate from 'vscode-textmate'; +import path = require('path'); +import { IGrammar, IRawGrammar, RuleId, StateStackImpl, tokenizeFile, tokenizeLine } from './TextMate'; +import { stringify } from './extension'; +import { IRelaxedExtensionManifest } from './extensions'; +import { IRawRule } from './textmate/rawGrammar'; +import { getTrees, queryNode, toRange } from './TreeSitter'; + +type element = { + line?: number, + document: vscode.TextDocument, + token?: vscodeTextmate.IToken, + id?: number, + ruleId?: RuleId, +}; + +type rule = { + scopeName: string, + ruleId: RuleId, + depth: number, + _enterPos: number, + line: number, +}; +// const ruleList: rule[] = []; + +let grammar: IGrammar; + +const FileIcon = path.join(__dirname, '..', 'assets', 'TextMate-file-icon.svg'); +const onDidChangeTreeData: vscode.EventEmitter = new vscode.EventEmitter(); + +export const TreeDataProvider: vscode.TreeDataProvider = { + async getChildren(element?: element): Promise { + // vscode.window.showInformationMessage(JSON.stringify("getChildren")); + // vscode.window.showInformationMessage(JSON.stringify(element)); + + if (false) { + const elements: element[] = []; + + if (!element) { + const activeTextEditor = vscode.window.activeTextEditor; + if (!activeTextEditor) { + return; + } + const element: element = { + line: -1, + document: activeTextEditor.document, + }; + elements.push(element); + return elements; + } + + const document = element.document; + const line = element.line; + + if (line == -1) { + for (let index = 0; index < document.lineCount; index++) { + const element: element = { line: index, document: document }; + elements.push(element); + } + return elements; + } + + if (element.token) { + return; + } + + const tokenLineResult = await tokenizeLine(document, line); + vscode.window.showInformationMessage(JSON.stringify(tokenLineResult, stringify)); + const tokens = tokenLineResult.tokens; + if (!tokens) { + return; + } + let count = 0; + for (const token of tokens) { + const element: element = { + line: line, + document: document, + token: token + }; + elements.push(element); + count++; + if (count > 500) { + return elements; + } + } + return elements; + } + + if (false) { + const elements: element[] = []; + + if (!element) { + const activeTextEditor = vscode.window.activeTextEditor; + if (!activeTextEditor) { + return; + } + const childElement: element = { + id: -1, + document: activeTextEditor.document, + }; + elements.push(childElement); + return elements; + } + + const document = element.document; + + if (element.id == -1) { + const tokenLineResults = await tokenizeFile(document); + + let rootParent = true; + let index = 0; + // for (const tokenLine of tokenLineResults) { + // let parentRule = tokenLine.ruleStack; + // index++; + // const tempRules: rule[] = []; + // while (parentRule) { + // const _enterPos = parentRule._enterPos; + // if (_enterPos != -1) { + // const rule = { + // scopeName: parentRule.nameScopesList.scopePath.scopeName, + // ruleId: parentRule.ruleId, + // depth: parentRule.depth, + // _enterPos: _enterPos, + // line: index, + // }; + // tempRules.unshift(rule); + // } else if (rootParent) { + // const rule = { + // scopeName: parentRule.nameScopesList.scopePath.scopeName, + // ruleId: parentRule.ruleId, + // depth: parentRule.depth, + // _enterPos: -1, + // line: 0, + // }; + // tempRules.unshift(rule); + // rootParent = false; + // } + // parentRule = parentRule.parent; + // } + // ruleList.push(...tempRules); + // } + const childElement: element = { + id: 0, + document: document, + }; + elements.push(childElement); + return elements; + } + + if (true) { + // const id = element.id; + // const depth = ruleList[id].depth; + // for (let index = id + 1; index < ruleList.length; index++) { + // const rule = ruleList[index]; + // const ruleDepth = rule.depth; + // if (ruleDepth == depth) { + // break; + // } + // if (ruleDepth == depth + 1) { + // const childElement: element = { + // id: index, + // document: document, + // }; + // elements.push(childElement); + // } + // } + return elements; + } + } + + if (true) { + const elements: element[] = []; + + if (!element) { + const activeTextEditor = vscode.window.activeTextEditor; + if (!activeTextEditor) { + return; + } + const childElement: element = { + id: -2, + document: activeTextEditor.document, + }; + elements.push(childElement); + return elements; + } + + const document = element.document; + + if (element.id == -2) { + grammar = await tokenizeFile(document); + + // grammar.rules.unshift( + // { + // captureIndices: [ + // { + // start: 0, + // end: 0, + // length: 0, + // } + // ], + // matchedRuleId: 1, + // } + // ); + + const childElement: element = { + line: 0, + id: -1, + document: document, + }; + elements.push(childElement); + return elements; + } + + if (true) { + let id = element.id; + const document = element.document; + + // vscode.window.showInformationMessage(JSON.stringify(element)); + + + let depth = 0; + let line = element.line; + + // if (element.id) { + // return elements; + // } + + // if (element.ruleId != -1) { + // id++; + // line++; + // } + + const rule = grammar._ruleId2desc[element.ruleId]; + if (rule) { + if (rule._end) { + id++; + } + else + return elements; + } + + for (let index = id; index < grammar.rules.length; index++) { + const matchResult = grammar.rules[index]; + if (matchResult === undefined) { + line++; + continue; + } + if (matchResult == null) { + continue; + } + const ruleId = matchResult.matchedRuleId; + if (ruleId == -1) { + depth--; + if (depth == -1) { + break; + } + continue; + } + if (depth == 0) { + const childElement: element = { + line: line, + ruleId: ruleId, + id: index, + document: document, + }; + elements.push(childElement); + } + const rule = grammar._ruleId2desc[ruleId]; + if (rule._begin && !rule._while) { + depth++; + } + } + + return elements; + } + } + }, + getTreeItem(element: element): vscode.TreeItem { + // vscode.window.showInformationMessage(JSON.stringify("getTreeItem")); + // vscode.window.showInformationMessage(JSON.stringify(element)); + + if (false) { + const document = element.document; + const line = element.line; + + if (line == -1) { + const item = new vscode.TreeItem(document.uri); + item.collapsibleState = vscode.TreeItemCollapsibleState.Collapsed; + item.description = document.languageId; + item.iconPath = FileIcon; + return item; + } + + const token = element.token; + if (token) { + const item = new vscode.TreeItem(JSON.stringify(token)); + return item; + } + + const text = document.lineAt(line).text; + const label = text.replaceAll(' ', 'ยท').replaceAll('\t', 'โ†’') /* + (element + 1 == document.lineCount ? 'โ›”' : 'โŽ') */; + const item = new vscode.TreeItem(label); + item.accessibilityInformation = { label: 'accessibilityInformation', role: 'tree' }; + // item.checkboxState = { + // state: vscode.TreeItemCheckboxState.Unchecked, + // tooltip: 'checkboxtooltip', + // accessibilityInformation: { label: 'checkboxaccessibilityInformation', role: 'menu' } + // }; + item.collapsibleState = vscode.TreeItemCollapsibleState.Collapsed; + item.description = (line + 1).toString(); + // item.id = element.toString(); + // item.resourceUri = document.uri; + item.iconPath = FileIcon; + item.tooltip = `Line: ${line + 1}`; + + return item; + } + + if (false) { + const document = element.document; + const id = element.id; + + if (id == -1) { + const item = new vscode.TreeItem(document.uri); + item.collapsibleState = vscode.TreeItemCollapsibleState.Collapsed; + item.description = document.languageId; + item.iconPath = FileIcon; + return item; + } + + // const rule = ruleList[id]; + // const line = rule.line; + // const _enterPos = rule._enterPos; + + // const label = rule.scopeName; + // const item = new vscode.TreeItem(label); + // item.collapsibleState = vscode.TreeItemCollapsibleState.Collapsed; + // item.description = line.toString(); + // item.iconPath = FileIcon; + // item.tooltip = `Start Index: ${_enterPos}`; + + // const locations: vscode.Location[] = []; + // const range = line == 0 ? + // new vscode.Range(0, 0, document.lineCount, 0) + // : + // new vscode.Range(line - 1, _enterPos, line - 1, _enterPos + 1); + // const location = new vscode.Location( + // document.uri, + // range, + // ); + // locations.push(location); + // const position = line == 0 ? + // new vscode.Position(0, 0) + // : + // new vscode.Position(line - 1, _enterPos); + // const command: vscode.Command = { + // title: `title`, + // tooltip: `tooltip`, + // command: 'editor.action.goToLocations', + // arguments: [ + // document.uri, + // position, + // locations, + // ] + // }; + // item.command = command; + + // return item; + } + + if (true) { + const id = element.id; + + if (id == -1) { + const label = grammar._rootScopeName; + const item = new vscode.TreeItem(label); + item.collapsibleState = vscode.TreeItemCollapsibleState.Collapsed; + item.iconPath = FileIcon; + return item; + } + + const document = element.document; + if (id == -2) { + const item = new vscode.TreeItem(document.uri); + item.collapsibleState = vscode.TreeItemCollapsibleState.Collapsed; + item.description = document.languageId; + item.iconPath = FileIcon; + return item; + } + + const ruleId = element.ruleId; + const line = element.line; + + const cachedRule = grammar._ruleId2desc[ruleId]; + + // const _enterPos = rule._enterPos; + + const label = cachedRule._name; + const item = new vscode.TreeItem(label); + item.collapsibleState = vscode.TreeItemCollapsibleState.Collapsed; + item.description = line.toString(); + item.iconPath = FileIcon; + item.tooltip = `RuleId: ${cachedRule.id}`; + + const rule = grammar.rules[element.id]; + const start = rule.captureIndices[0].start; + const end = rule.captureIndices[0].end; + const locations: vscode.Location[] = []; + const range = new vscode.Range(line - 1, start, line - 1, end); + const location = new vscode.Location( + document.uri, + range, + ); + locations.push(location); + const position = new vscode.Position(line - 1, start); + const command: vscode.Command = { + title: `title`, + tooltip: `tooltip`, + command: 'editor.action.goToLocations', + arguments: [ + document.uri, + position, + locations, + ] + }; + item.command = command; + + return item; + } + + return; + }, + getParent(element: element): element { + // vscode.window.showInformationMessage(JSON.stringify("getParent")); + // vscode.window.showInformationMessage(JSON.stringify(element)); + // console.log("getParent"); + // console.log(element); + + if (element.id == -1) { + const parentElement: element = { + document: element.document, + id: -2, + }; + return parentElement; + } + + return undefined; + }, + resolveTreeItem(item: vscode.TreeItem, element: element, token: vscode.CancellationToken): vscode.TreeItem { + // vscode.window.showInformationMessage(JSON.stringify("resolveTreeItem")); + // vscode.window.showInformationMessage(JSON.stringify(item)); + // vscode.window.showInformationMessage(JSON.stringify(element)); + + return item; + }, + onDidChangeTreeData: onDidChangeTreeData.event, +}; + + +let treeView: vscode.TreeView; + +export function initCallStackView(context: vscode.ExtensionContext): void { + // vscode.window.showInformationMessage(JSON.stringify("initCallStackView")); + // context.subscriptions.push(vscode.commands.registerCommand("textmate.callstack", CallStackView, 'context')); + context.subscriptions.push(vscode.commands.registerTextEditorCommand("textmate.callstack", CallStackView)); + context.subscriptions.push(vscode.commands.registerCommand("textmate.refresh", refresh)); + context.subscriptions.push(vscode.commands.registerCommand("textmate.goto", goto)); + const options: vscode.TreeViewOptions = { + treeDataProvider: TreeDataProvider, + canSelectMany: false, + showCollapseAll: true, + manageCheckboxStateManually: false, + }; + treeView = vscode.window.createTreeView('TextMate', options); + + // context.subscriptions.push( + // vscode.window.onDidChangeActiveTextEditor((editor: vscode.TextEditor) => { + // // vscode.window.showInformationMessage(JSON.stringify("active")); + // // vscode.window.showInformationMessage(JSON.stringify(editor)); + // if (!editor) { + // return; + // } + // const document = editor.document; + // const element: element = { + // line: -1, + // document: document, + // }; + // onDidChangeTreeData.fire(element); + // }) + // ); +} + +async function CallStackView(textEditor: vscode.TextEditor, edit: vscode.TextEditorEdit, ...args: any[]): Promise { + // vscode.window.showInformationMessage(JSON.stringify("CallStackView")); + // vscode.window.showInformationMessage(JSON.stringify(textEditor)); + // vscode.window.showInformationMessage(JSON.stringify(edit)); + // vscode.window.showInformationMessage(JSON.stringify(args)); + const document = textEditor.document; + const position = textEditor.selection.active; + + // const tokenLineResults = await tokenizeFile(document); + // // vscode.window.showInformationMessage(JSON.stringify(tokenLineResults, stringify)); + + // let rootParent = true; + // let index = 0; + // const ruleList: { + // scopeName: string, + // ruleId: RuleId, + // depth: number, + // _enterPos: number, + // line: number, + // }[] = []; + // for (const tokenLine of tokenLineResults) { + // let parentRule = tokenLine.ruleStack; + // index++; + // const tempRules = []; + // while (parentRule) { + // if (parentRule._enterPos != -1 || rootParent) { + // const rule = { + // scopeName: parentRule.nameScopesList.scopePath.scopeName, + // ruleId: parentRule.ruleId, + // depth: parentRule.depth, + // _enterPos: parentRule._enterPos, + // line: index, + // }; + // tempRules.unshift(rule); + // rootParent = false; + // } + // parentRule = parentRule.parent; + // } + // ruleList.push(...tempRules); + // // ruleList = [...ruleList, ...tempRules]; + // } + + // const ruleTree = {}; + + // vscode.window.showInformationMessage(JSON.stringify(ruleList, stringify)); + + const grammar = await tokenizeFile(document); + + // onDidChangeTreeData.fire(undefined); + + const activeTextEditor = vscode.window.activeTextEditor; + if (!activeTextEditor) { + return; + } + await treeView.reveal( + { + document: activeTextEditor.document, + id: -2, + }, + { + expand: true, + focus: false, + select: false, + } + ); + await treeView.reveal( + { + document: activeTextEditor.document, + id: -1, + }, + { + expand: 2, + focus: true, + select: true, + } + ); + treeView.badge = { + tooltip: "tooltip badge 56: is there any use for this number?", + value: 56, + }; + treeView.title = "new title"; + +} + +function refresh(...args: any[]) { + // vscode.window.showInformationMessage(JSON.stringify("refresh")); + // vscode.window.showInformationMessage(JSON.stringify(args)); + + const element: element = args[0]; + if (element) { + onDidChangeTreeData.fire( + { + document: element.document, + id: -2, + } + ); + } + onDidChangeTreeData.fire(undefined); +} + +async function goto(...args: any[]) { + // vscode.window.showInformationMessage(JSON.stringify("goto")); + // vscode.window.showInformationMessage(JSON.stringify(args)); + + const element: element = args[0]; + if (!element) { + return; + } + + const id = element.id; + const document = element.document; + + if (id == -2) { + vscode.window.showTextDocument(document); + return; + } + + if (id == -1) { + const lang = document.languageId; + for (const extension of vscode.extensions.all) { + const packageJSON: IRelaxedExtensionManifest = extension.packageJSON; + const grammars = packageJSON.contributes?.grammars; + if (grammars) { + for (const grammar of grammars) { + if (grammar.language == lang) { + const path = grammar.path; + if (path) { + const uri = vscode.Uri.joinPath(extension.extensionUri, path); + vscode.window.showTextDocument(uri); + return; + } + } + } + } + } + } + + // locate grammar rule via its id + // annoyingly the ids are assigned on a first-served basis + // including across included/embedded grammars + + const ruleId = element.ruleId + if (!ruleId) { + return; + } + // (json (repository (repo (key) ))) + const path = allChildren(grammar._grammar, ruleId); + vscode.window.showInformationMessage(JSON.stringify(path)); + + const grammarDoc = await getGrammarDocument(document); + const trees = getTrees(grammarDoc); + const tree = trees.jsonTree; + let node = tree.rootNode; + + for (const step of path) { + const repo = step.repository; + if (repo != null) { + for (const childNode of node.namedChildren) { + if (childNode.type == 'repository') { + node = childNode; + break; + } + } + for (const repoNode of node.namedChildren) { + if (repoNode.firstNamedChild?.text == repo) { + node = repoNode; + break; + } + } + continue; + } + const pattern = step.patterns; + if (pattern != null) { + for (const patternNode of node.namedChildren) { + if (patternNode.type == 'patterns') { + node = patternNode; + break; + } + } + node = node.namedChild(pattern + 1); + continue; + } + const id = step.id; + if (id != null) { + break; + } + } + + const range = toRange(node); + const uri = grammarDoc.uri; + const location = new vscode.Location(uri, range); + const locations = [location]; + + vscode.commands.executeCommand('editor.action.goToLocations', uri, range.start, locations); +} + +function allChildren(rules: vscodeTextmate.IRawGrammar | IRawRule, ruleId: number): [{ 'repository'?: string, 'patterns'?: number, id?: number }] { + for (const key in rules) { + switch (key) { + case 'patterns': + const patterns = rules[key]; + for (let index = 0; index < patterns.length; index++) { + const pattern = patterns[index]; + const path = allChildren(pattern, ruleId); + if (path) { + path.unshift({ "patterns": index }); + return path; + } + } + break; + case 'repository': + const repository = rules[key]; + for (const key in repository) { + const repo = repository[key]; + const path = allChildren(repo, ruleId); + if (path) { + path.unshift({ "repository": key }); + return path; + } + } + break; + case 'id': + // @ts-ignore + const id = rules[key]; + if (id == ruleId) { + // return []; + return [{ id: id }]; + } + default: + break; + } + } +} + +async function getGrammarDocument(document: vscode.TextDocument) { + const lang = document.languageId; + for (const extension of vscode.extensions.all) { + const packageJSON: IRelaxedExtensionManifest = extension.packageJSON; + const grammars = packageJSON.contributes?.grammars; + if (grammars) { + for (const grammar of grammars) { + if (grammar.language == lang) { + const path = grammar.path; + if (path) { + const uri = vscode.Uri.joinPath(extension.extensionUri, path); + const grammarDoc = await vscode.workspace.openTextDocument(uri); + if (grammarDoc) { + return grammarDoc; + } + } + } + } + } + } +} \ No newline at end of file diff --git a/src/extension.ts b/src/extension.ts index 35edb61..d4c5027 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -2,11 +2,14 @@ import * as vscode from 'vscode'; import { initTreeSitter } from "./TreeSitter"; import { initOniguruma } from './oniguruma'; +import { initTextMate } from './TextMate'; import { initDiagnostics } from "./DiagnosticCollection"; import { initTokenColorCustomizations } from './tokenColorCustomizations'; +import { initCallStackView } from './TreeDataProvider'; import { HoverProvider } from "./HoverProvider"; import { RenameProvider } from "./RenameProvider"; +import { CodeLensProvider } from "./CodeLensProvider"; import { ReferenceProvider } from "./ReferenceProvider"; import { DefinitionProvider } from "./DefinitionProvider"; import { CallHierarchyProvider } from "./CallHierarchyProvider"; @@ -28,11 +31,14 @@ export async function activate(context: vscode.ExtensionContext) { await initTreeSitter(context); await initOniguruma(context); + initTextMate(context); initDiagnostics(context); + initCallStackView(context); initTokenColorCustomizations(context); // context.subscriptions.push(vscode.languages.registerHoverProvider(DocumentSelector, HoverProvider)); // Mouse over Hovers context.subscriptions.push(vscode.languages.registerRenameProvider(DocumentSelector, RenameProvider)); // [F2] Rename + // context.subscriptions.push(vscode.languages.registerCodeLensProvider(DocumentSelector, CodeLensProvider)); // Code Lens context.subscriptions.push(vscode.languages.registerReferenceProvider(DocumentSelector, ReferenceProvider)); // Go to References context.subscriptions.push(vscode.languages.registerDefinitionProvider(DocumentSelector, DefinitionProvider)); // ctrl+click Go to Definition context.subscriptions.push(vscode.languages.registerCallHierarchyProvider(DocumentSelector, CallHierarchyProvider)); // right click => Peak Call Hierarchy @@ -50,4 +56,24 @@ export function deactivate() { // vscode.window.showInformationMessage(JSON.stringify("deactivate")); // https://github.com/microsoft/vscode/issues/105484 // https://github.com/microsoft/vscode/issues/201664 +} + + +export function stringify(this: any, key: string, value: any) { + if (typeof value === 'function') { + return ""; + } + if (typeof value === 'symbol') { + return ""; + } + if (typeof value === 'undefined') { + return ""; + } + if (value == null) { + return null; + } + if (key.startsWith("HEAP")) { + return ""; + } + return value; } \ No newline at end of file diff --git a/src/extensions.d.ts b/src/extensions.d.ts new file mode 100644 index 0000000..b69f920 --- /dev/null +++ b/src/extensions.d.ts @@ -0,0 +1,267 @@ + +export interface IEmbeddedLanguagesMap { + [scopeName: string]: string; +} + +export interface TokenTypesContribution { + [scopeName: string]: string; +} + +export interface ITMSyntaxExtensionPoint { + language: string; + scopeName: string; + path: string; + embeddedLanguages: IEmbeddedLanguagesMap; + tokenTypes: TokenTypesContribution; + injectTo: string[]; + balancedBracketScopes: string[]; + unbalancedBracketScopes: string[]; +} + +export interface ILocalizedString { + + /** + * The localized value of the string. + */ + value: string; + + /** + * The original (non localized value of the string) + */ + original: string; +} + +export interface ICommand { + command: string; + title: string | ILocalizedString; + category?: string | ILocalizedString; +} + +export interface IConfigurationProperty { + description: string; + type: string | string[]; + default?: any; +} + +export interface IConfiguration { + id?: string; + order?: number; + title?: string; + properties: { [key: string]: IConfigurationProperty }; +} + +export interface IDebugger { + label?: string; + type: string; + runtime?: string; +} + +export interface IGrammar extends ITMSyntaxExtensionPoint { + language: string; +} + +export interface IJSONValidation { + fileMatch: string | string[]; + url: string; +} + +export interface IKeyBinding { + command: string; + key: string; + when?: string; + mac?: string; + linux?: string; + win?: string; +} + +export interface ILanguage { + id: string; + extensions: string[]; + aliases: string[]; +} + +export interface IMenu { + command: string; + alt?: string; + when?: string; + group?: string; +} + +export interface ISnippet { + language: string; +} + +export interface ITheme { + label: string; +} + +export interface IViewContainer { + id: string; + title: string; +} + +export interface IView { + id: string; + name: string; +} + +export interface IColor { + id: string; + description: string; + defaults: { light: string; dark: string; highContrast: string }; +} + +interface IWebviewEditor { + readonly viewType: string; + readonly priority: string; + readonly selector: readonly { + readonly filenamePattern?: string; + }[]; +} + +export interface ICodeActionContributionAction { + readonly kind: string; + readonly title: string; + readonly description?: string; +} + +export interface ICodeActionContribution { + readonly languages: readonly string[]; + readonly actions: readonly ICodeActionContributionAction[]; +} + +export interface IAuthenticationContribution { + readonly id: string; + readonly label: string; +} + +export interface IWalkthroughStep { + readonly id: string; + readonly title: string; + readonly description: string | undefined; + readonly media: + | { image: string | { dark: string; light: string; hc: string }; altText: string; markdown?: never; svg?: never } + | { markdown: string; image?: never; svg?: never } + | { svg: string; altText: string; markdown?: never; image?: never }; + readonly completionEvents?: string[]; + /** @deprecated use `completionEvents: 'onCommand:...'` */ + readonly doneOn?: { command: string }; + readonly when?: string; +} + +export interface IWalkthrough { + readonly id: string; + readonly title: string; + readonly icon?: string; + readonly description: string; + readonly steps: IWalkthroughStep[]; + readonly featuredFor: string[] | undefined; + readonly when?: string; +} + +export interface IStartEntry { + readonly title: string; + readonly description: string; + readonly command: string; + readonly when?: string; + readonly category: 'file' | 'folder' | 'notebook'; +} + +export interface INotebookEntry { + readonly type: string; + readonly displayName: string; +} + +export interface INotebookRendererContribution { + readonly id: string; + readonly displayName: string; + readonly mimeTypes: string[]; +} + +export interface IDebugVisualizationContribution { + readonly id: string; + readonly when: string; +} + +export interface ITranslation { + id: string; + path: string; +} + +export interface ILocalizationContribution { + languageId: string; + languageName?: string; + localizedLanguageName?: string; + translations: ITranslation[]; + minimalTranslations?: { [key: string]: string }; +} + +export interface IExtensionContributions { + commands?: ICommand[]; + configuration?: IConfiguration | IConfiguration[]; + debuggers?: IDebugger[]; + grammars?: IGrammar[]; + jsonValidation?: IJSONValidation[]; + keybindings?: IKeyBinding[]; + languages?: ILanguage[]; + menus?: { [context: string]: IMenu[] }; + snippets?: ISnippet[]; + themes?: ITheme[]; + iconThemes?: ITheme[]; + productIconThemes?: ITheme[]; + viewsContainers?: { [location: string]: IViewContainer[] }; + views?: { [location: string]: IView[] }; + colors?: IColor[]; + localizations?: ILocalizationContribution[]; + readonly customEditors?: readonly IWebviewEditor[]; + readonly codeActions?: readonly ICodeActionContribution[]; + authentication?: IAuthenticationContribution[]; + walkthroughs?: IWalkthrough[]; + startEntries?: IStartEntry[]; + readonly notebooks?: INotebookEntry[]; + readonly notebookRenderer?: INotebookRendererContribution[]; + readonly debugVisualizers?: IDebugVisualizationContribution[]; +} + +export type ExtensionKind = 'ui' | 'workspace' | 'web'; + +export interface IExtensionCapabilities { + readonly virtualWorkspaces?: ExtensionVirtualWorkspaceSupport; + readonly untrustedWorkspaces?: ExtensionUntrustedWorkspaceSupport; +} + +export type LimitedWorkspaceSupportType = 'limited'; +export type ExtensionUntrustedWorkspaceSupportType = boolean | LimitedWorkspaceSupportType; +export type ExtensionUntrustedWorkspaceSupport = { supported: true } | { supported: false; description: string } | { supported: LimitedWorkspaceSupportType; description: string; restrictedConfigurations?: string[] }; + +export type ExtensionVirtualWorkspaceSupportType = boolean | LimitedWorkspaceSupportType; +export type ExtensionVirtualWorkspaceSupport = boolean | { supported: true } | { supported: false | LimitedWorkspaceSupportType; description: string }; + +export interface IRelaxedExtensionManifest { + name: string; + displayName?: string; + publisher: string; + version: string; + engines: { readonly vscode: string }; + description?: string; + main?: string; + browser?: string; + preview?: boolean; + // For now this only supports pointing to l10n bundle files + // but it will be used for package.l10n.json files in the future + l10n?: string; + icon?: string; + categories?: string[]; + keywords?: string[]; + activationEvents?: string[]; + extensionDependencies?: string[]; + extensionPack?: string[]; + extensionKind?: ExtensionKind | ExtensionKind[]; + contributes?: IExtensionContributions; + repository?: { url: string }; + bugs?: { url: string }; + enabledApiProposals?: readonly string[]; + api?: string; + scripts?: { [key: string]: string }; + capabilities?: IExtensionCapabilities; +} \ No newline at end of file diff --git a/src/textmate/debug.ts b/src/textmate/debug.ts new file mode 100644 index 0000000..3718c26 --- /dev/null +++ b/src/textmate/debug.ts @@ -0,0 +1,9 @@ +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ + +export const DebugFlags = { + InDebugMode: (typeof process !== 'undefined' && !!process.env['VSCODE_TEXTMATE_DEBUG']) +}; + +export const UseOnigurumaFindOptions = false; diff --git a/src/textmate/diffStateStacks.ts b/src/textmate/diffStateStacks.ts new file mode 100644 index 0000000..d2528e5 --- /dev/null +++ b/src/textmate/diffStateStacks.ts @@ -0,0 +1,47 @@ +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ + +import { StateStackImpl, StateStackFrame } from "./grammar"; +import { StateStack } from "./main"; + +export function diffStateStacksRefEq(first: StateStack, second: StateStack): StackDiff { + let pops = 0; + const newFrames: StateStackFrame[] = []; + + let curFirst: StateStackImpl | null = first as StateStackImpl; + let curSecond: StateStackImpl | null = second as StateStackImpl; + + while (curFirst !== curSecond) { + if (curFirst && (!curSecond || curFirst.depth >= curSecond.depth)) { + // curFirst is certainly not contained in curSecond + pops++; + curFirst = curFirst.parent; + } else { + // curSecond is certainly not contained in curFirst. + // Also, curSecond must be defined, as otherwise a previous case would match + newFrames.push(curSecond!.toStateStackFrame()); + curSecond = curSecond!.parent; + } + } + return { + pops, + newFrames: newFrames.reverse(), + }; +} + +export function applyStateStackDiff(stack: StateStack | null, diff: StackDiff): StateStackImpl | null { + let curStack = stack as StateStackImpl | null; + for (let i = 0; i < diff.pops; i++) { + curStack = curStack!.parent; + } + for (const frame of diff.newFrames) { + curStack = StateStackImpl.pushFrame(curStack, frame); + } + return curStack; +} + +export interface StackDiff { + readonly pops: number; + readonly newFrames: StateStackFrame[]; +} diff --git a/src/textmate/encodedTokenAttributes.ts b/src/textmate/encodedTokenAttributes.ts new file mode 100644 index 0000000..9225b5a --- /dev/null +++ b/src/textmate/encodedTokenAttributes.ts @@ -0,0 +1,188 @@ +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ + +import { FontStyle } from "./theme"; + +export type EncodedTokenAttributes = number; + +export namespace EncodedTokenAttributes { + export function toBinaryStr(encodedTokenAttributes: EncodedTokenAttributes): string { + return encodedTokenAttributes.toString(2).padStart(32, "0"); + } + + export function print(encodedTokenAttributes: EncodedTokenAttributes): void { + const languageId = EncodedTokenAttributes.getLanguageId(encodedTokenAttributes); + const tokenType = EncodedTokenAttributes.getTokenType(encodedTokenAttributes); + const fontStyle = EncodedTokenAttributes.getFontStyle(encodedTokenAttributes); + const foreground = EncodedTokenAttributes.getForeground(encodedTokenAttributes); + const background = EncodedTokenAttributes.getBackground(encodedTokenAttributes); + + console.log({ + languageId: languageId, + tokenType: tokenType, + fontStyle: fontStyle, + foreground: foreground, + background: background, + }); + } + + export function getLanguageId(encodedTokenAttributes: EncodedTokenAttributes): number { + return ( + (encodedTokenAttributes & EncodedTokenDataConsts.LANGUAGEID_MASK) >>> + EncodedTokenDataConsts.LANGUAGEID_OFFSET + ); + } + + export function getTokenType(encodedTokenAttributes: EncodedTokenAttributes): StandardTokenType { + return ( + (encodedTokenAttributes & EncodedTokenDataConsts.TOKEN_TYPE_MASK) >>> + EncodedTokenDataConsts.TOKEN_TYPE_OFFSET + ); + } + + export function containsBalancedBrackets(encodedTokenAttributes: EncodedTokenAttributes): boolean { + return (encodedTokenAttributes & EncodedTokenDataConsts.BALANCED_BRACKETS_MASK) !== 0; + } + + export function getFontStyle(encodedTokenAttributes: EncodedTokenAttributes): number { + return ( + (encodedTokenAttributes & EncodedTokenDataConsts.FONT_STYLE_MASK) >>> + EncodedTokenDataConsts.FONT_STYLE_OFFSET + ); + } + + export function getForeground(encodedTokenAttributes: EncodedTokenAttributes): number { + return ( + (encodedTokenAttributes & EncodedTokenDataConsts.FOREGROUND_MASK) >>> + EncodedTokenDataConsts.FOREGROUND_OFFSET + ); + } + + export function getBackground(encodedTokenAttributes: EncodedTokenAttributes): number { + return ( + (encodedTokenAttributes & EncodedTokenDataConsts.BACKGROUND_MASK) >>> + EncodedTokenDataConsts.BACKGROUND_OFFSET + ); + } + + /** + * Updates the fields in `metadata`. + * A value of `0`, `NotSet` or `null` indicates that the corresponding field should be left as is. + */ + export function set( + encodedTokenAttributes: EncodedTokenAttributes, + languageId: number | 0, + tokenType: OptionalStandardTokenType | OptionalStandardTokenType.NotSet, + containsBalancedBrackets: boolean | null, + fontStyle: FontStyle | FontStyle.NotSet, + foreground: number | 0, + background: number | 0 + ): number { + let _languageId = EncodedTokenAttributes.getLanguageId(encodedTokenAttributes); + let _tokenType = EncodedTokenAttributes.getTokenType(encodedTokenAttributes); + let _containsBalancedBracketsBit: 0 | 1 = + EncodedTokenAttributes.containsBalancedBrackets(encodedTokenAttributes) ? 1 : 0; + let _fontStyle = EncodedTokenAttributes.getFontStyle(encodedTokenAttributes); + let _foreground = EncodedTokenAttributes.getForeground(encodedTokenAttributes); + let _background = EncodedTokenAttributes.getBackground(encodedTokenAttributes); + + if (languageId !== 0) { + _languageId = languageId; + } + if (tokenType !== OptionalStandardTokenType.NotSet) { + _tokenType = fromOptionalTokenType(tokenType); + } + if (containsBalancedBrackets !== null) { + _containsBalancedBracketsBit = containsBalancedBrackets ? 1 : 0; + } + if (fontStyle !== FontStyle.NotSet) { + _fontStyle = fontStyle; + } + if (foreground !== 0) { + _foreground = foreground; + } + if (background !== 0) { + _background = background; + } + + return ( + ((_languageId << EncodedTokenDataConsts.LANGUAGEID_OFFSET) | + (_tokenType << EncodedTokenDataConsts.TOKEN_TYPE_OFFSET) | + (_containsBalancedBracketsBit << + EncodedTokenDataConsts.BALANCED_BRACKETS_OFFSET) | + (_fontStyle << EncodedTokenDataConsts.FONT_STYLE_OFFSET) | + (_foreground << EncodedTokenDataConsts.FOREGROUND_OFFSET) | + (_background << EncodedTokenDataConsts.BACKGROUND_OFFSET)) >>> + 0 + ); + } +} + +/** + * Helpers to manage the "collapsed" metadata of an entire StackElement stack. + * The following assumptions have been made: + * - languageId < 256 => needs 8 bits + * - unique color count < 512 => needs 9 bits + * + * The binary format is: + * - ------------------------------------------- + * 3322 2222 2222 1111 1111 1100 0000 0000 + * 1098 7654 3210 9876 5432 1098 7654 3210 + * - ------------------------------------------- + * xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx + * bbbb bbbb ffff ffff fFFF FBTT LLLL LLLL + * - ------------------------------------------- + * - L = LanguageId (8 bits) + * - T = StandardTokenType (2 bits) + * - B = Balanced bracket (1 bit) + * - F = FontStyle (4 bits) + * - f = foreground color (9 bits) + * - b = background color (9 bits) + */ +const enum EncodedTokenDataConsts { + LANGUAGEID_MASK = 0b00000000000000000000000011111111, + TOKEN_TYPE_MASK = 0b00000000000000000000001100000000, + BALANCED_BRACKETS_MASK = 0b00000000000000000000010000000000, + FONT_STYLE_MASK = 0b00000000000000000111100000000000, + FOREGROUND_MASK = 0b00000000111111111000000000000000, + BACKGROUND_MASK = 0b11111111000000000000000000000000, + + LANGUAGEID_OFFSET = 0, + TOKEN_TYPE_OFFSET = 8, + BALANCED_BRACKETS_OFFSET = 10, + FONT_STYLE_OFFSET = 11, + FOREGROUND_OFFSET = 15, + BACKGROUND_OFFSET = 24 +} + +export const enum StandardTokenType { + Other = 0, + Comment = 1, + String = 2, + RegEx = 3 +} + +export function toOptionalTokenType(standardType: StandardTokenType): OptionalStandardTokenType { + return standardType as any as OptionalStandardTokenType; +} + +function fromOptionalTokenType( + standardType: + | OptionalStandardTokenType.Other + | OptionalStandardTokenType.Comment + | OptionalStandardTokenType.String + | OptionalStandardTokenType.RegEx +): StandardTokenType { + return standardType as any as StandardTokenType; +} + +// Must have the same values as `StandardTokenType`! +export const enum OptionalStandardTokenType { + Other = 0, + Comment = 1, + String = 2, + RegEx = 3, + // Indicates that no token type is set. + NotSet = 8 +} diff --git a/src/textmate/grammar/basicScopesAttributeProvider.ts b/src/textmate/grammar/basicScopesAttributeProvider.ts new file mode 100644 index 0000000..5d32c45 --- /dev/null +++ b/src/textmate/grammar/basicScopesAttributeProvider.ts @@ -0,0 +1,111 @@ +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ + +import { OptionalStandardTokenType } from "../encodedTokenAttributes"; +import { IEmbeddedLanguagesMap } from "../main"; +import { ScopeName } from "../theme"; +import { CachedFn, escapeRegExpCharacters } from "../utils"; + +export class BasicScopeAttributes { + constructor( + public readonly languageId: number, + public readonly tokenType: OptionalStandardTokenType + ) { + } +} + +export class BasicScopeAttributesProvider { + private readonly _defaultAttributes: BasicScopeAttributes; + private readonly _embeddedLanguagesMatcher: ScopeMatcher; + + constructor(initialLanguageId: number, embeddedLanguages: IEmbeddedLanguagesMap | null) { + this._defaultAttributes = new BasicScopeAttributes(initialLanguageId, OptionalStandardTokenType.NotSet); + this._embeddedLanguagesMatcher = new ScopeMatcher(Object.entries(embeddedLanguages || {})); + } + + public getDefaultAttributes(): BasicScopeAttributes { + return this._defaultAttributes; + } + + public getBasicScopeAttributes(scopeName: ScopeName | null): BasicScopeAttributes { + if (scopeName === null) { + return BasicScopeAttributesProvider._NULL_SCOPE_METADATA; + } + return this._getBasicScopeAttributes.get(scopeName); + } + + private static readonly _NULL_SCOPE_METADATA = new BasicScopeAttributes(0, 0); + + private readonly _getBasicScopeAttributes = new CachedFn((scopeName) => { + const languageId = this._scopeToLanguage(scopeName); + const standardTokenType = this._toStandardTokenType(scopeName); + return new BasicScopeAttributes(languageId, standardTokenType); + }); + + /** + * Given a produced TM scope, return the language that token describes or null if unknown. + * e.g. source.html => html, source.css.embedded.html => css, punctuation.definition.tag.html => null + */ + private _scopeToLanguage(scope: ScopeName): number { + return this._embeddedLanguagesMatcher.match(scope) || 0; + } + + private _toStandardTokenType(scopeName: ScopeName): OptionalStandardTokenType { + const m = scopeName.match(BasicScopeAttributesProvider.STANDARD_TOKEN_TYPE_REGEXP); + if (!m) { + return OptionalStandardTokenType.NotSet; + } + switch (m[1]) { + case "comment": + return OptionalStandardTokenType.Comment; + case "string": + return OptionalStandardTokenType.String; + case "regex": + return OptionalStandardTokenType.RegEx; + case "meta.embedded": + return OptionalStandardTokenType.Other; + } + throw new Error("Unexpected match for standard token type!"); + } + + private static STANDARD_TOKEN_TYPE_REGEXP = /\b(comment|string|regex|meta\.embedded)\b/; +} + +class ScopeMatcher { + private readonly values: ReadonlyMap | null; + private readonly scopesRegExp: RegExp | null; + + constructor(values: [ScopeName, TValue][]) { + if (values.length === 0) { + this.values = null; + this.scopesRegExp = null; + } else { + this.values = new Map(values); + + // create the regex + const escapedScopes = values.map( + ([scopeName, value]) => escapeRegExpCharacters(scopeName) + ); + + escapedScopes.sort(); + escapedScopes.reverse(); // Longest scope first + this.scopesRegExp = new RegExp( + `^((${escapedScopes.join(")|(")}))($|\\.)`, + "" + ); + } + } + + public match(scope: ScopeName): TValue | undefined { + if (!this.scopesRegExp) { + return undefined; + } + const m = scope.match(this.scopesRegExp); + if (!m) { + // no scopes matched + return undefined; + } + return this.values!.get(m[1])!; + } +} diff --git a/src/textmate/grammar/grammar.ts b/src/textmate/grammar/grammar.ts new file mode 100644 index 0000000..161949e --- /dev/null +++ b/src/textmate/grammar/grammar.ts @@ -0,0 +1,1110 @@ +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ + +import { DebugFlags } from '../debug'; +import { EncodedTokenAttributes, OptionalStandardTokenType, StandardTokenType, toOptionalTokenType } from '../encodedTokenAttributes'; +import { IEmbeddedLanguagesMap, IGrammar, IToken, ITokenizeLineResult, ITokenizeLineResult2, ITokenTypeMap, StateStack } from '../main'; +import { createMatchers, Matcher } from '../matcher'; +import { disposeOnigString, IOnigLib, OnigScanner, OnigString } from '../onigLib'; +import { IRawGrammar, IRawRepository, IRawRule } from '../rawGrammar'; +import { ruleIdFromNumber, IRuleFactoryHelper, IRuleRegistry, Rule, RuleFactory, RuleId, ruleIdToNumber } from '../rule'; +import { FontStyle, ScopeName, ScopePath, ScopeStack, StyleAttributes } from '../theme'; +import { clone } from '../utils'; +import { BasicScopeAttributes, BasicScopeAttributesProvider } from './basicScopesAttributeProvider'; +import { _tokenizeString } from './tokenizeString'; + +export function createGrammar( + scopeName: ScopeName, + grammar: IRawGrammar, + initialLanguage: number, + embeddedLanguages: IEmbeddedLanguagesMap | null, + tokenTypes: ITokenTypeMap | null, + balancedBracketSelectors: BalancedBracketSelectors | null, + grammarRepository: IGrammarRepository & IThemeProvider, + onigLib: IOnigLib +): Grammar { + return new Grammar( + scopeName, + grammar, + initialLanguage, + embeddedLanguages, + tokenTypes, + balancedBracketSelectors, + grammarRepository, + onigLib + ); //TODO +} + +export interface IThemeProvider { + themeMatch(scopePath: ScopeStack): StyleAttributes | null; + getDefaults(): StyleAttributes; +} + +export interface IGrammarRepository { + lookup(scopeName: ScopeName): IRawGrammar | undefined; + injections(scopeName: ScopeName): ScopeName[]; +} + +export interface Injection { + readonly debugSelector: string; + readonly matcher: Matcher; + readonly priority: -1 | 0 | 1; // 0 is the default. -1 for 'L' and 1 for 'R' + readonly ruleId: RuleId; + readonly grammar: IRawGrammar; +} + +function collectInjections(result: Injection[], selector: string, rule: IRawRule, ruleFactoryHelper: IRuleFactoryHelper, grammar: IRawGrammar): void { + const matchers = createMatchers(selector, nameMatcher); + const ruleId = RuleFactory.getCompiledRuleId(rule, ruleFactoryHelper, grammar.repository); + for (const matcher of matchers) { + result.push({ + debugSelector: selector, + matcher: matcher.matcher, + ruleId: ruleId, + grammar: grammar, + priority: matcher.priority + }); + } +} + +function nameMatcher(identifers: ScopeName[], scopes: ScopeName[]): boolean { + if (scopes.length < identifers.length) { + return false; + } + let lastIndex = 0; + return identifers.every(identifier => { + for (let i = lastIndex; i < scopes.length; i++) { + if (scopesAreMatching(scopes[i], identifier)) { + lastIndex = i + 1; + return true; + } + } + return false; + }); +} + +function scopesAreMatching(thisScopeName: string, scopeName: string): boolean { + if (!thisScopeName) { + return false; + } + if (thisScopeName === scopeName) { + return true; + } + const len = scopeName.length; + return thisScopeName.length > len && thisScopeName.substr(0, len) === scopeName && thisScopeName[len] === '.'; +} + +export class Grammar implements IGrammar, IRuleFactoryHelper, IOnigLib { + private _rootId: RuleId | -1; + private _lastRuleId: number; + private readonly _ruleId2desc: Rule[]; + private readonly _includedGrammars: { [scopeName: string]: IRawGrammar }; + private readonly _grammarRepository: IGrammarRepository & IThemeProvider; + private readonly _grammar: IRawGrammar; + private _injections: Injection[] | null; + private readonly _basicScopeAttributesProvider: BasicScopeAttributesProvider; + private readonly _tokenTypeMatchers: TokenTypeMatcher[]; + + public get themeProvider(): IThemeProvider { return this._grammarRepository; } + + constructor( + private readonly _rootScopeName: ScopeName, + grammar: IRawGrammar, + initialLanguage: number, + embeddedLanguages: IEmbeddedLanguagesMap | null, + tokenTypes: ITokenTypeMap | null, + private readonly balancedBracketSelectors: BalancedBracketSelectors | null, + grammarRepository: IGrammarRepository & IThemeProvider, + private readonly _onigLib: IOnigLib + ) { + this._basicScopeAttributesProvider = new BasicScopeAttributesProvider( + initialLanguage, + embeddedLanguages + ); + + this._rootId = -1; + this._lastRuleId = 0; + this._ruleId2desc = [null!]; + this._includedGrammars = {}; + this._grammarRepository = grammarRepository; + this._grammar = initGrammar(grammar, null); + this._injections = null; + + this._tokenTypeMatchers = []; + if (tokenTypes) { + for (const selector of Object.keys(tokenTypes)) { + const matchers = createMatchers(selector, nameMatcher); + for (const matcher of matchers) { + this._tokenTypeMatchers.push({ + matcher: matcher.matcher, + type: tokenTypes[selector], + }); + } + } + } + } + + public dispose(): void { + for (const rule of this._ruleId2desc) { + if (rule) { + rule.dispose(); + } + } + } + + public createOnigScanner(sources: string[]): OnigScanner { + return this._onigLib.createOnigScanner(sources); + } + + public createOnigString(sources: string): OnigString { + return this._onigLib.createOnigString(sources); + } + + public getMetadataForScope(scope: string): BasicScopeAttributes { + return this._basicScopeAttributesProvider.getBasicScopeAttributes(scope); + } + + private _collectInjections(): Injection[] { + const grammarRepository: IGrammarRepository = { + lookup: (scopeName: string): IRawGrammar | undefined => { + if (scopeName === this._rootScopeName) { + return this._grammar; + } + return this.getExternalGrammar(scopeName); + }, + injections: (scopeName: string): string[] => { + return this._grammarRepository.injections(scopeName); + }, + }; + + const result: Injection[] = []; + + const scopeName = this._rootScopeName; + + const grammar = grammarRepository.lookup(scopeName); + if (grammar) { + // add injections from the current grammar + const rawInjections = grammar.injections; + if (rawInjections) { + for (let expression in rawInjections) { + collectInjections( + result, + expression, + rawInjections[expression], + this, + grammar + ); + } + } + + // add injection grammars contributed for the current scope + + const injectionScopeNames = this._grammarRepository.injections(scopeName); + if (injectionScopeNames) { + injectionScopeNames.forEach((injectionScopeName) => { + const injectionGrammar = + this.getExternalGrammar(injectionScopeName); + if (injectionGrammar) { + const selector = injectionGrammar.injectionSelector; + if (selector) { + collectInjections( + result, + selector, + injectionGrammar, + this, + injectionGrammar + ); + } + } + }); + } + } + + result.sort((i1, i2) => i1.priority - i2.priority); // sort by priority + + return result; + } + + public getInjections(): Injection[] { + if (this._injections === null) { + this._injections = this._collectInjections(); + + if (DebugFlags.InDebugMode && this._injections.length > 0) { + console.log( + `Grammar ${this._rootScopeName} contains the following injections:` + ); + for (const injection of this._injections) { + console.log(` - ${injection.debugSelector}`); + } + } + } + return this._injections; + } + + public registerRule(factory: (id: RuleId) => T): T { + const id = ++this._lastRuleId; + const result = factory(ruleIdFromNumber(id)); + this._ruleId2desc[id] = result; + return result; + } + + public getRule(ruleId: RuleId): Rule { + return this._ruleId2desc[ruleIdToNumber(ruleId)]; + } + + public getExternalGrammar( + scopeName: string, + repository?: IRawRepository + ): IRawGrammar | undefined { + if (this._includedGrammars[scopeName]) { + return this._includedGrammars[scopeName]; + } else if (this._grammarRepository) { + const rawIncludedGrammar = + this._grammarRepository.lookup(scopeName); + if (rawIncludedGrammar) { + // console.log('LOADED GRAMMAR ' + pattern.include); + this._includedGrammars[scopeName] = initGrammar( + rawIncludedGrammar, + repository && repository.$base + ); + return this._includedGrammars[scopeName]; + } + } + return undefined; + } + + public tokenizeLine( + lineText: string, + prevState: StateStackImpl | null, + timeLimit: number = 0 + ): ITokenizeLineResult { + const r = this._tokenize(lineText, prevState, false, timeLimit); + return { + tokens: r.lineTokens.getResult(r.ruleStack, r.lineLength), + ruleStack: r.ruleStack, + stoppedEarly: r.stoppedEarly, + }; + } + + public tokenizeLine2( + lineText: string, + prevState: StateStackImpl | null, + timeLimit: number = 0 + ): ITokenizeLineResult2 { + const r = this._tokenize(lineText, prevState, true, timeLimit); + return { + tokens: r.lineTokens.getBinaryResult(r.ruleStack, r.lineLength), + ruleStack: r.ruleStack, + stoppedEarly: r.stoppedEarly, + }; + } + + private _tokenize( + lineText: string, + prevState: StateStackImpl | null, + emitBinaryTokens: boolean, + timeLimit: number + ): { + lineLength: number; + lineTokens: LineTokens; + ruleStack: StateStackImpl; + stoppedEarly: boolean; + } { + if (this._rootId === -1) { + this._rootId = RuleFactory.getCompiledRuleId( + this._grammar.repository.$self, + this, + this._grammar.repository + ); + // This ensures ids are deterministic, and thus equal in renderer and webworker. + this.getInjections(); + } + + let isFirstLine: boolean; + if (!prevState || prevState === StateStackImpl.NULL) { + isFirstLine = true; + const rawDefaultMetadata = + this._basicScopeAttributesProvider.getDefaultAttributes(); + const defaultStyle = this.themeProvider.getDefaults(); + const defaultMetadata = EncodedTokenAttributes.set( + 0, + rawDefaultMetadata.languageId, + rawDefaultMetadata.tokenType, + null, + defaultStyle.fontStyle, + defaultStyle.foregroundId, + defaultStyle.backgroundId + ); + + const rootScopeName = this.getRule(this._rootId).getName( + null, + null + ); + + let scopeList: AttributedScopeStack; + if (rootScopeName) { + scopeList = AttributedScopeStack.createRootAndLookUpScopeName( + rootScopeName, + defaultMetadata, + this + ); + } else { + scopeList = AttributedScopeStack.createRoot( + "unknown", + defaultMetadata + ); + } + + prevState = new StateStackImpl( + null, + this._rootId, + -1, + -1, + false, + null, + scopeList, + scopeList + ); + } else { + isFirstLine = false; + prevState.reset(); + } + + lineText = lineText + "\n"; + const onigLineText = this.createOnigString(lineText); + const lineLength = onigLineText.content.length; + const lineTokens = new LineTokens( + emitBinaryTokens, + lineText, + this._tokenTypeMatchers, + this.balancedBracketSelectors + ); + const r = _tokenizeString( + this, + onigLineText, + isFirstLine, + 0, + prevState, + lineTokens, + true, + timeLimit + ); + + disposeOnigString(onigLineText); + + return { + lineLength: lineLength, + lineTokens: lineTokens, + ruleStack: r.stack, + stoppedEarly: r.stoppedEarly, + }; + } +} + +function initGrammar(grammar: IRawGrammar, base: IRawRule | null | undefined): IRawGrammar { + grammar = clone(grammar); + + grammar.repository = grammar.repository || {}; + grammar.repository.$self = { + $vscodeTextmateLocation: grammar.$vscodeTextmateLocation, + patterns: grammar.patterns, + name: grammar.scopeName + }; + grammar.repository.$base = base || grammar.repository.$self; + return grammar; +} + +export class AttributedScopeStack { + static fromExtension(namesScopeList: AttributedScopeStack | null, contentNameScopesList: AttributedScopeStackFrame[]): AttributedScopeStack | null { + let current = namesScopeList; + let scopeNames = namesScopeList?.scopePath ?? null; + for (const frame of contentNameScopesList) { + scopeNames = ScopeStack.push(scopeNames, frame.scopeNames); + current = new AttributedScopeStack(current, scopeNames!, frame.encodedTokenAttributes); + } + return current; + } + + public static createRoot(scopeName: ScopeName, tokenAttributes: EncodedTokenAttributes): AttributedScopeStack { + return new AttributedScopeStack(null, new ScopeStack(null, scopeName), tokenAttributes); + } + + public static createRootAndLookUpScopeName(scopeName: ScopeName, tokenAttributes: EncodedTokenAttributes, grammar: Grammar): AttributedScopeStack { + const rawRootMetadata = grammar.getMetadataForScope(scopeName); + const scopePath = new ScopeStack(null, scopeName); + const rootStyle = grammar.themeProvider.themeMatch(scopePath); + + const resolvedTokenAttributes = AttributedScopeStack.mergeAttributes( + tokenAttributes, + rawRootMetadata, + rootStyle + ); + + return new AttributedScopeStack(null, scopePath, resolvedTokenAttributes); + } + + public get scopeName(): ScopeName { return this.scopePath.scopeName; } + + /** + * Invariant: + * ``` + * if (parent && !scopePath.extends(parent.scopePath)) { + * throw new Error(); + * } + * ``` + */ + private constructor( + public readonly parent: AttributedScopeStack | null, + public readonly scopePath: ScopeStack, + public readonly tokenAttributes: EncodedTokenAttributes + ) { + } + + public toString() { + return this.getScopeNames().join(' '); + } + + public equals(other: AttributedScopeStack): boolean { + return AttributedScopeStack.equals(this, other); + } + + public static equals( + a: AttributedScopeStack | null, + b: AttributedScopeStack | null + ): boolean { + do { + if (a === b) { + return true; + } + + if (!a && !b) { + // End of list reached for both + return true; + } + + if (!a || !b) { + // End of list reached only for one + return false; + } + + if (a.scopeName !== b.scopeName || a.tokenAttributes !== b.tokenAttributes) { + return false; + } + + // Go to previous pair + a = a.parent; + b = b.parent; + } while (true); + } + + private static mergeAttributes( + existingTokenAttributes: EncodedTokenAttributes, + basicScopeAttributes: BasicScopeAttributes, + styleAttributes: StyleAttributes | null + ): EncodedTokenAttributes { + let fontStyle = FontStyle.NotSet; + let foreground = 0; + let background = 0; + + if (styleAttributes !== null) { + fontStyle = styleAttributes.fontStyle; + foreground = styleAttributes.foregroundId; + background = styleAttributes.backgroundId; + } + + return EncodedTokenAttributes.set( + existingTokenAttributes, + basicScopeAttributes.languageId, + basicScopeAttributes.tokenType, + null, + fontStyle, + foreground, + background + ); + } + + public pushAttributed(scopePath: ScopePath | null, grammar: Grammar): AttributedScopeStack { + if (scopePath === null) { + return this; + } + + if (scopePath.indexOf(' ') === -1) { + // This is the common case and much faster + + return AttributedScopeStack._pushAttributed(this, scopePath, grammar); + } + + const scopes = scopePath.split(/ /g); + let result: AttributedScopeStack = this; + for (const scope of scopes) { + result = AttributedScopeStack._pushAttributed(result, scope, grammar); + } + return result; + + } + + private static _pushAttributed( + target: AttributedScopeStack, + scopeName: ScopeName, + grammar: Grammar, + ): AttributedScopeStack { + const rawMetadata = grammar.getMetadataForScope(scopeName); + + const newPath = target.scopePath.push(scopeName); + const scopeThemeMatchResult = + grammar.themeProvider.themeMatch(newPath); + const metadata = AttributedScopeStack.mergeAttributes( + target.tokenAttributes, + rawMetadata, + scopeThemeMatchResult + ); + return new AttributedScopeStack(target, newPath, metadata); + } + + public getScopeNames(): string[] { + return this.scopePath.getSegments(); + } + + public getExtensionIfDefined(base: AttributedScopeStack | null): AttributedScopeStackFrame[] | undefined { + const result: AttributedScopeStackFrame[] = []; + let self: AttributedScopeStack | null = this; + + while (self && self !== base) { + result.push({ + encodedTokenAttributes: self.tokenAttributes, + scopeNames: self.scopePath.getExtensionIfDefined(self.parent?.scopePath ?? null)!, + }); + self = self.parent; + } + return self === base ? result.reverse() : undefined; + } +} + +interface AttributedScopeStackFrame { + encodedTokenAttributes: number; + scopeNames: string[]; +} + +/** + * Represents a "pushed" state on the stack (as a linked list element). + */ +export class StateStackImpl implements StateStack { + _stackElementBrand: void = undefined; + + // TODO remove me + public static NULL = new StateStackImpl( + null, + 0 as any, + 0, + 0, + false, + null, + null, + null + ); + + /** + * The position on the current line where this state was pushed. + * This is relevant only while tokenizing a line, to detect endless loops. + * Its value is meaningless across lines. + */ + private _enterPos: number; + + /** + * The captured anchor position when this stack element was pushed. + * This is relevant only while tokenizing a line, to restore the anchor position when popping. + * Its value is meaningless across lines. + */ + private _anchorPos: number; + + + /** + * The depth of the stack. + */ + public readonly depth: number; + + + /** + * Invariant: + * ``` + * if (contentNameScopesList !== nameScopesList && contentNameScopesList?.parent !== nameScopesList) { + * throw new Error(); + * } + * if (this.parent && !nameScopesList.extends(this.parent.contentNameScopesList)) { + * throw new Error(); + * } + * ``` + */ + constructor( + /** + * The previous state on the stack (or null for the root state). + */ + public readonly parent: StateStackImpl | null, + + /** + * The state (rule) that this element represents. + */ + private readonly ruleId: RuleId, + + enterPos: number, + anchorPos: number, + + /** + * The state has entered and captured \n. This means that the next line should have an anchorPosition of 0. + */ + public readonly beginRuleCapturedEOL: boolean, + + /** + * The "pop" (end) condition for this state in case that it was dynamically generated through captured text. + */ + public readonly endRule: string | null, + + /** + * The list of scopes containing the "name" for this state. + */ + public readonly nameScopesList: AttributedScopeStack | null, + + /** + * The list of scopes containing the "contentName" (besides "name") for this state. + * This list **must** contain as an element `scopeName`. + */ + public readonly contentNameScopesList: AttributedScopeStack | null, + ) { + this.depth = this.parent ? this.parent.depth + 1 : 1; + this._enterPos = enterPos; + this._anchorPos = anchorPos; + } + + public equals(other: StateStackImpl): boolean { + if (other === null) { + return false; + } + return StateStackImpl._equals(this, other); + } + + private static _equals(a: StateStackImpl, b: StateStackImpl): boolean { + if (a === b) { + return true; + } + if (!this._structuralEquals(a, b)) { + return false; + } + return AttributedScopeStack.equals(a.contentNameScopesList, b.contentNameScopesList); + } + + /** + * A structural equals check. Does not take into account `scopes`. + */ + private static _structuralEquals( + a: StateStackImpl | null, + b: StateStackImpl | null + ): boolean { + do { + if (a === b) { + return true; + } + + if (!a && !b) { + // End of list reached for both + return true; + } + + if (!a || !b) { + // End of list reached only for one + return false; + } + + if ( + a.depth !== b.depth || + a.ruleId !== b.ruleId || + a.endRule !== b.endRule + ) { + return false; + } + + // Go to previous pair + a = a.parent; + b = b.parent; + } while (true); + } + + public clone(): StateStackImpl { + return this; + } + + private static _reset(el: StateStackImpl | null): void { + while (el) { + el._enterPos = -1; + el._anchorPos = -1; + el = el.parent; + } + } + + public reset(): void { + StateStackImpl._reset(this); + } + + public pop(): StateStackImpl | null { + return this.parent; + } + + public safePop(): StateStackImpl { + if (this.parent) { + return this.parent; + } + return this; + } + + public push( + ruleId: RuleId, + enterPos: number, + anchorPos: number, + beginRuleCapturedEOL: boolean, + endRule: string | null, + nameScopesList: AttributedScopeStack | null, + contentNameScopesList: AttributedScopeStack | null, + ): StateStackImpl { + return new StateStackImpl( + this, + ruleId, + enterPos, + anchorPos, + beginRuleCapturedEOL, + endRule, + nameScopesList, + contentNameScopesList + ); + } + + public getEnterPos(): number { + return this._enterPos; + } + + public getAnchorPos(): number { + return this._anchorPos; + } + + public getRule(grammar: IRuleRegistry): Rule { + return grammar.getRule(this.ruleId); + } + + public toString(): string { + const r: string[] = []; + this._writeString(r, 0); + return "[" + r.join(",") + "]"; + } + + private _writeString(res: string[], outIndex: number): number { + if (this.parent) { + outIndex = this.parent._writeString(res, outIndex); + } + + res[ + outIndex++ + ] = `(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`; + + return outIndex; + } + + public withContentNameScopesList( + contentNameScopeStack: AttributedScopeStack + ): StateStackImpl { + if (this.contentNameScopesList === contentNameScopeStack) { + return this; + } + return this.parent!.push( + this.ruleId, + this._enterPos, + this._anchorPos, + this.beginRuleCapturedEOL, + this.endRule, + this.nameScopesList, + contentNameScopeStack + ); + } + + public withEndRule(endRule: string): StateStackImpl { + if (this.endRule === endRule) { + return this; + } + return new StateStackImpl( + this.parent, + this.ruleId, + this._enterPos, + this._anchorPos, + this.beginRuleCapturedEOL, + endRule, + this.nameScopesList, + this.contentNameScopesList + ); + } + + // Used to warn of endless loops + public hasSameRuleAs(other: StateStackImpl): boolean { + let el: StateStackImpl | null = this; + while (el && el._enterPos === other._enterPos) { + if (el.ruleId === other.ruleId) { + return true; + } + el = el.parent; + } + return false; + } + + public toStateStackFrame(): StateStackFrame { + return { + ruleId: ruleIdToNumber(this.ruleId), + beginRuleCapturedEOL: this.beginRuleCapturedEOL, + endRule: this.endRule, + nameScopesList: this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList ?? null)! ?? [], + contentNameScopesList: this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)! ?? [], + }; + } + + public static pushFrame(self: StateStackImpl | null, frame: StateStackFrame): StateStackImpl { + const namesScopeList = AttributedScopeStack.fromExtension(self?.nameScopesList ?? null, frame.nameScopesList)!; + return new StateStackImpl( + self, + ruleIdFromNumber(frame.ruleId), + frame.enterPos ?? -1, + frame.anchorPos ?? -1, + frame.beginRuleCapturedEOL, + frame.endRule, + namesScopeList, + AttributedScopeStack.fromExtension(namesScopeList, frame.contentNameScopesList)! + ); + } +} + +export interface StateStackFrame { + ruleId: number; + enterPos?: number; + anchorPos?: number; + beginRuleCapturedEOL: boolean; + endRule: string | null; + nameScopesList: AttributedScopeStackFrame[]; + /** + * on top of nameScopesList + */ + contentNameScopesList: AttributedScopeStackFrame[]; +} + +interface TokenTypeMatcher { + readonly matcher: Matcher; + readonly type: StandardTokenType; +} + +export class BalancedBracketSelectors { + private readonly balancedBracketScopes: Matcher[]; + private readonly unbalancedBracketScopes: Matcher[]; + + private allowAny = false; + + constructor( + balancedBracketScopes: string[], + unbalancedBracketScopes: string[], + ) { + this.balancedBracketScopes = balancedBracketScopes.flatMap((selector) => { + if (selector === '*') { + this.allowAny = true; + return []; + } + return createMatchers(selector, nameMatcher).map((m) => m.matcher); + } + ); + this.unbalancedBracketScopes = unbalancedBracketScopes.flatMap((selector) => + createMatchers(selector, nameMatcher).map((m) => m.matcher) + ); + } + + public get matchesAlways(): boolean { + return this.allowAny && this.unbalancedBracketScopes.length === 0; + } + + public get matchesNever(): boolean { + return this.balancedBracketScopes.length === 0 && !this.allowAny; + } + + public match(scopes: string[]): boolean { + for (const excluder of this.unbalancedBracketScopes) { + if (excluder(scopes)) { + return false; + } + } + + for (const includer of this.balancedBracketScopes) { + if (includer(scopes)) { + return true; + } + } + return this.allowAny; + } +} + +export class LineTokens { + private readonly _emitBinaryTokens: boolean; + /** + * defined only if `DebugFlags.InDebugMode`. + */ + private readonly _lineText: string | null; + /** + * used only if `_emitBinaryTokens` is false. + */ + private readonly _tokens: IToken[]; + /** + * used only if `_emitBinaryTokens` is true. + */ + private readonly _binaryTokens: number[]; + + private _lastTokenEndIndex: number; + + private readonly _tokenTypeOverrides: TokenTypeMatcher[]; + + constructor( + emitBinaryTokens: boolean, + lineText: string, + tokenTypeOverrides: TokenTypeMatcher[], + private readonly balancedBracketSelectors: BalancedBracketSelectors | null, + ) { + this._emitBinaryTokens = emitBinaryTokens; + this._tokenTypeOverrides = tokenTypeOverrides; + if (DebugFlags.InDebugMode) { + this._lineText = lineText; + } else { + this._lineText = null; + } + this._tokens = []; + this._binaryTokens = []; + this._lastTokenEndIndex = 0; + } + + public produce(stack: StateStackImpl, endIndex: number): void { + this.produceFromScopes(stack.contentNameScopesList, endIndex); + } + + public produceFromScopes( + scopesList: AttributedScopeStack | null, + endIndex: number + ): void { + if (this._lastTokenEndIndex >= endIndex) { + return; + } + + if (this._emitBinaryTokens) { + let metadata = scopesList?.tokenAttributes ?? 0; + let containsBalancedBrackets = false; + if (this.balancedBracketSelectors?.matchesAlways) { + containsBalancedBrackets = true; + } + + if (this._tokenTypeOverrides.length > 0 || (this.balancedBracketSelectors && !this.balancedBracketSelectors.matchesAlways && !this.balancedBracketSelectors.matchesNever)) { + // Only generate scope array when required to improve performance + const scopes = scopesList?.getScopeNames() ?? []; + for (const tokenType of this._tokenTypeOverrides) { + if (tokenType.matcher(scopes)) { + metadata = EncodedTokenAttributes.set( + metadata, + 0, + toOptionalTokenType(tokenType.type), + null, + FontStyle.NotSet, + 0, + 0 + ); + } + } + if (this.balancedBracketSelectors) { + containsBalancedBrackets = this.balancedBracketSelectors.match(scopes); + } + } + + if (containsBalancedBrackets) { + metadata = EncodedTokenAttributes.set( + metadata, + 0, + OptionalStandardTokenType.NotSet, + containsBalancedBrackets, + FontStyle.NotSet, + 0, + 0 + ); + } + + if (this._binaryTokens.length > 0 && this._binaryTokens[this._binaryTokens.length - 1] === metadata) { + // no need to push a token with the same metadata + this._lastTokenEndIndex = endIndex; + return; + } + + if (DebugFlags.InDebugMode) { + const scopes = scopesList?.getScopeNames() ?? []; + console.log(' token: |' + this._lineText!.substring(this._lastTokenEndIndex, endIndex).replace(/\n$/, '\\n') + '|'); + for (let k = 0; k < scopes.length; k++) { + console.log(' * ' + scopes[k]); + } + } + + this._binaryTokens.push(this._lastTokenEndIndex); + this._binaryTokens.push(metadata); + + this._lastTokenEndIndex = endIndex; + return; + } + + const scopes = scopesList?.getScopeNames() ?? []; + + if (DebugFlags.InDebugMode) { + console.log(' token: |' + this._lineText!.substring(this._lastTokenEndIndex, endIndex).replace(/\n$/, '\\n') + '|'); + for (let k = 0; k < scopes.length; k++) { + console.log(' * ' + scopes[k]); + } + } + + this._tokens.push({ + startIndex: this._lastTokenEndIndex, + endIndex: endIndex, + // value: lineText.substring(lastTokenEndIndex, endIndex), + scopes: scopes + }); + + this._lastTokenEndIndex = endIndex; + } + + public getResult(stack: StateStackImpl, lineLength: number): IToken[] { + if (this._tokens.length > 0 && this._tokens[this._tokens.length - 1].startIndex === lineLength - 1) { + // pop produced token for newline + this._tokens.pop(); + } + + if (this._tokens.length === 0) { + this._lastTokenEndIndex = -1; + this.produce(stack, lineLength); + this._tokens[this._tokens.length - 1].startIndex = 0; + } + + return this._tokens; + } + + public getBinaryResult(stack: StateStackImpl, lineLength: number): Uint32Array { + if (this._binaryTokens.length > 0 && this._binaryTokens[this._binaryTokens.length - 2] === lineLength - 1) { + // pop produced token for newline + this._binaryTokens.pop(); + this._binaryTokens.pop(); + } + + if (this._binaryTokens.length === 0) { + this._lastTokenEndIndex = -1; + this.produce(stack, lineLength); + this._binaryTokens[this._binaryTokens.length - 2] = 0; + } + + const result = new Uint32Array(this._binaryTokens.length); + for (let i = 0, len = this._binaryTokens.length; i < len; i++) { + result[i] = this._binaryTokens[i]; + } + + return result; + } +} + diff --git a/src/textmate/grammar/grammarDependencies.ts b/src/textmate/grammar/grammarDependencies.ts new file mode 100644 index 0000000..4ad2b89 --- /dev/null +++ b/src/textmate/grammar/grammarDependencies.ts @@ -0,0 +1,295 @@ +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ + +import { IRawGrammar, IRawRepository, IRawRule } from '../rawGrammar'; +import { ScopeName } from '../theme'; +import { mergeObjects } from '../utils'; +import { IGrammarRepository } from './grammar'; + +export type AbsoluteRuleReference = TopLevelRuleReference | TopLevelRepositoryRuleReference; + +/** + * References the top level rule of a grammar with the given scope name. +*/ +export class TopLevelRuleReference { + constructor( + public readonly scopeName: ScopeName + ) { } + + public toKey(): string { + return this.scopeName; + } +} + +/** + * References a rule of a grammar in the top level repository section with the given name. +*/ +export class TopLevelRepositoryRuleReference { + constructor( + public readonly scopeName: ScopeName, + public readonly ruleName: string + ) { } + + public toKey(): string { + return `${this.scopeName}#${this.ruleName}`; + } +} + +export class ExternalReferenceCollector { + private readonly _references: AbsoluteRuleReference[] = []; + private readonly _seenReferenceKeys = new Set(); + + public get references(): readonly AbsoluteRuleReference[] { + return this._references; + } + + public readonly visitedRule = new Set(); + + public add(reference: AbsoluteRuleReference): void { + const key = reference.toKey(); + if (this._seenReferenceKeys.has(key)) { + return; + } + this._seenReferenceKeys.add(key); + this._references.push(reference); + } +} + +export class ScopeDependencyProcessor { + public readonly seenFullScopeRequests = new Set(); + public readonly seenPartialScopeRequests = new Set(); + public Q: AbsoluteRuleReference[]; + + constructor( + public readonly repo: IGrammarRepository, + public readonly initialScopeName: ScopeName + ) { + this.seenFullScopeRequests.add(this.initialScopeName); + this.Q = [new TopLevelRuleReference(this.initialScopeName)]; + } + + public processQueue(): void { + const q = this.Q; + this.Q = []; + + const deps = new ExternalReferenceCollector(); + for (const dep of q) { + collectReferencesOfReference(dep, this.initialScopeName, this.repo, deps); + } + + for (const dep of deps.references) { + if (dep instanceof TopLevelRuleReference) { + if (this.seenFullScopeRequests.has(dep.scopeName)) { + // already processed + continue; + } + this.seenFullScopeRequests.add(dep.scopeName); + this.Q.push(dep); + } else { + if (this.seenFullScopeRequests.has(dep.scopeName)) { + // already processed in full + continue; + } + if (this.seenPartialScopeRequests.has(dep.toKey())) { + // already processed + continue; + } + this.seenPartialScopeRequests.add(dep.toKey()); + this.Q.push(dep); + } + } + } +} + +function collectReferencesOfReference( + reference: TopLevelRuleReference | TopLevelRepositoryRuleReference, + baseGrammarScopeName: ScopeName, + repo: IGrammarRepository, + result: ExternalReferenceCollector, +) { + const selfGrammar = repo.lookup(reference.scopeName); + if (!selfGrammar) { + if (reference.scopeName === baseGrammarScopeName) { + throw new Error(`No grammar provided for <${baseGrammarScopeName}>`); + } + return; + } + + const baseGrammar = repo.lookup(baseGrammarScopeName)!; + + if (reference instanceof TopLevelRuleReference) { + collectExternalReferencesInTopLevelRule({ baseGrammar, selfGrammar }, result); + } else { + collectExternalReferencesInTopLevelRepositoryRule( + reference.ruleName, + { baseGrammar, selfGrammar, repository: selfGrammar.repository }, + result + ); + } + + const injections = repo.injections(reference.scopeName); + if (injections) { + for (const injection of injections) { + result.add(new TopLevelRuleReference(injection)); + } + } +} + +interface Context { + baseGrammar: IRawGrammar; + selfGrammar: IRawGrammar; +} + +interface ContextWithRepository { + baseGrammar: IRawGrammar; + selfGrammar: IRawGrammar; + repository: Record | undefined; +} + +function collectExternalReferencesInTopLevelRepositoryRule( + ruleName: string, + context: ContextWithRepository, + result: ExternalReferenceCollector +): void { + if (context.repository && context.repository[ruleName]) { + const rule = context.repository[ruleName]; + collectExternalReferencesInRules([rule], context, result); + } +} + +function collectExternalReferencesInTopLevelRule(context: Context, result: ExternalReferenceCollector): void { + if (context.selfGrammar.patterns && Array.isArray(context.selfGrammar.patterns)) { + collectExternalReferencesInRules( + context.selfGrammar.patterns, + { ...context, repository: context.selfGrammar.repository }, + result + ); + } + if (context.selfGrammar.injections) { + collectExternalReferencesInRules( + Object.values(context.selfGrammar.injections), + { ...context, repository: context.selfGrammar.repository }, + result + ); + } +} + +function collectExternalReferencesInRules( + rules: IRawRule[], + context: ContextWithRepository, + result: ExternalReferenceCollector, +): void { + for (const rule of rules) { + if (result.visitedRule.has(rule)) { + continue; + } + result.visitedRule.add(rule); + + const patternRepository = rule.repository ? mergeObjects({}, context.repository, rule.repository) : context.repository; + + if (Array.isArray(rule.patterns)) { + collectExternalReferencesInRules(rule.patterns, { ...context, repository: patternRepository }, result); + } + + const include = rule.include; + + if (!include) { + continue; + } + + const reference = parseInclude(include); + + switch (reference.kind) { + case IncludeReferenceKind.Base: + collectExternalReferencesInTopLevelRule({ ...context, selfGrammar: context.baseGrammar }, result); + break; + case IncludeReferenceKind.Self: + collectExternalReferencesInTopLevelRule(context, result); + break; + case IncludeReferenceKind.RelativeReference: + collectExternalReferencesInTopLevelRepositoryRule(reference.ruleName, { ...context, repository: patternRepository }, result); + break; + case IncludeReferenceKind.TopLevelReference: + case IncludeReferenceKind.TopLevelRepositoryReference: + const selfGrammar = + reference.scopeName === context.selfGrammar.scopeName + ? context.selfGrammar + : reference.scopeName === context.baseGrammar.scopeName + ? context.baseGrammar + : undefined; + if (selfGrammar) { + const newContext: ContextWithRepository = { baseGrammar: context.baseGrammar, selfGrammar, repository: patternRepository }; + if (reference.kind === IncludeReferenceKind.TopLevelRepositoryReference) { + collectExternalReferencesInTopLevelRepositoryRule(reference.ruleName, newContext, result); + } else { + collectExternalReferencesInTopLevelRule(newContext, result); + } + } else { + if (reference.kind === IncludeReferenceKind.TopLevelRepositoryReference) { + result.add(new TopLevelRepositoryRuleReference(reference.scopeName, reference.ruleName)); + } else { + result.add(new TopLevelRuleReference(reference.scopeName)); + } + } + break; + } + } +} + +export type IncludeReference = + | BaseReference + | SelfReference + | RelativeReference + | TopLevelReference + | TopLevelRepositoryReference; + +export const enum IncludeReferenceKind { + Base, + Self, + RelativeReference, + TopLevelReference, + TopLevelRepositoryReference, +} + +export class BaseReference { + public readonly kind = IncludeReferenceKind.Base; +} + +export class SelfReference { + public readonly kind = IncludeReferenceKind.Self; +} + +export class RelativeReference { + public readonly kind = IncludeReferenceKind.RelativeReference; + constructor(public readonly ruleName: string) {} +} + +export class TopLevelReference { + public readonly kind = IncludeReferenceKind.TopLevelReference; + constructor(public readonly scopeName: ScopeName) {} +} + +export class TopLevelRepositoryReference { + public readonly kind = IncludeReferenceKind.TopLevelRepositoryReference; + constructor(public readonly scopeName: ScopeName, public readonly ruleName: string) {} +} + +export function parseInclude(include: string): IncludeReference { + if (include === '$base') { + return new BaseReference(); + } else if (include === '$self') { + return new SelfReference(); + } + + const indexOfSharp = include.indexOf("#"); + if (indexOfSharp === -1) { + return new TopLevelReference(include); + } else if (indexOfSharp === 0) { + return new RelativeReference(include.substring(1)); + } else { + const scopeName = include.substring(0, indexOfSharp); + const ruleName = include.substring(indexOfSharp + 1); + return new TopLevelRepositoryReference(scopeName, ruleName); + } +} diff --git a/src/textmate/grammar/index.ts b/src/textmate/grammar/index.ts new file mode 100644 index 0000000..7f0446b --- /dev/null +++ b/src/textmate/grammar/index.ts @@ -0,0 +1,5 @@ +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ + +export * from './grammar'; \ No newline at end of file diff --git a/src/textmate/grammar/tokenizeString.ts b/src/textmate/grammar/tokenizeString.ts new file mode 100644 index 0000000..ea26ca5 --- /dev/null +++ b/src/textmate/grammar/tokenizeString.ts @@ -0,0 +1,657 @@ +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ + +import { DebugFlags, UseOnigurumaFindOptions } from '../debug'; +import type { LineTokens, StateStackImpl } from './grammar'; +import { disposeOnigString, FindOption, IOnigCaptureIndex, OnigString } from '../onigLib'; +import { BeginEndRule, BeginWhileRule, CaptureRule, CompiledRule, endRuleId, MatchRule, Rule, RuleId, whileRuleId } from '../rule'; +import { performanceNow } from '../utils'; +import type { AttributedScopeStack, Grammar, Injection } from './grammar'; + +class TokenizeStringResult { + constructor( + public readonly stack: StateStackImpl, + public readonly stoppedEarly: boolean + ) { } +} + +/** + * Tokenize a string + * @param grammar + * @param lineText + * @param isFirstLine + * @param linePos + * @param stack + * @param lineTokens + * @param checkWhileConditions + * @param timeLimit Use `0` to indicate no time limit + * @returns the StackElement or StackElement.TIME_LIMIT_REACHED if the time limit has been reached + */ +export function _tokenizeString( + grammar: Grammar, + lineText: OnigString, + isFirstLine: boolean, + linePos: number, + stack: StateStackImpl, + lineTokens: LineTokens, + checkWhileConditions: boolean, + timeLimit: number +): TokenizeStringResult { + const lineLength = lineText.content.length; + + let STOP = false; + let anchorPosition = -1; + + if (checkWhileConditions) { + const whileCheckResult = _checkWhileConditions( + grammar, + lineText, + isFirstLine, + linePos, + stack, + lineTokens + ); + stack = whileCheckResult.stack; + linePos = whileCheckResult.linePos; + isFirstLine = whileCheckResult.isFirstLine; + anchorPosition = whileCheckResult.anchorPosition; + } + + const startTime = Date.now(); + while (!STOP) { + if (timeLimit !== 0) { + const elapsedTime = Date.now() - startTime; + if (elapsedTime > timeLimit) { + return new TokenizeStringResult(stack, true); + } + } + scanNext(); // potentially modifies linePos && anchorPosition + } + + return new TokenizeStringResult(stack, false); + + function scanNext(): void { + if (DebugFlags.InDebugMode) { + console.log(""); + console.log( + `@@scanNext ${linePos}: |${lineText.content + .substr(linePos) + .replace(/\n$/, "\\n")}|` + ); + } + const r = matchRuleOrInjections( + grammar, + lineText, + isFirstLine, + linePos, + stack, + anchorPosition + ); + + // @ts-ignore + grammar.rules.push(r); + // grammar.rules.push( + // { + // ...r, + // ...{ + // lineText: lineText, + // isFirstLine: isFirstLine, + // linePos: linePos, + // // stack: stack, + // anchorPosition: anchorPosition, + // } + // } + // ); + + if (!r) { + if (DebugFlags.InDebugMode) { + console.log(" no more matches."); + } + // No match + lineTokens.produce(stack, lineLength); + STOP = true; + return; + } + + const captureIndices: IOnigCaptureIndex[] = r.captureIndices; + const matchedRuleId = r.matchedRuleId; + + const hasAdvanced = + captureIndices && captureIndices.length > 0 + ? captureIndices[0].end > linePos + : false; + + if (matchedRuleId === endRuleId) { + // We matched the `end` for this rule => pop it + const poppedRule = stack.getRule(grammar); + + if (DebugFlags.InDebugMode) { + console.log( + " popping " + + poppedRule.debugName + + " - " + + poppedRule.debugEndRegExp + ); + } + + lineTokens.produce(stack, captureIndices[0].start); + stack = stack.withContentNameScopesList(stack.nameScopesList!); + handleCaptures( + grammar, + lineText, + isFirstLine, + stack, + lineTokens, + poppedRule.endCaptures, + captureIndices + ); + lineTokens.produce(stack, captureIndices[0].end); + + // pop + const popped = stack; + stack = stack.parent!; + anchorPosition = popped.getAnchorPos(); + + if (!hasAdvanced && popped.getEnterPos() === linePos) { + // Grammar pushed & popped a rule without advancing + if (DebugFlags.InDebugMode) { + console.error( + "[1] - Grammar is in an endless loop - Grammar pushed & popped a rule without advancing" + ); + } + + // See https://github.com/Microsoft/vscode-textmate/issues/12 + // Let's assume this was a mistake by the grammar author and the intent was to continue in this state + stack = popped; + + lineTokens.produce(stack, lineLength); + STOP = true; + return; + } + } else { + // We matched a rule! + const _rule = grammar.getRule(matchedRuleId); + + lineTokens.produce(stack, captureIndices[0].start); + + const beforePush = stack; + // push it on the stack rule + const scopeName = _rule.getName(lineText.content, captureIndices); + const nameScopesList = stack.contentNameScopesList!.pushAttributed( + scopeName, + grammar + ); + stack = stack.push( + matchedRuleId, + linePos, + anchorPosition, + captureIndices[0].end === lineLength, + null, + nameScopesList, + nameScopesList + ); + + if (_rule instanceof BeginEndRule) { + const pushedRule = _rule; + if (DebugFlags.InDebugMode) { + console.log( + " pushing " + + pushedRule.debugName + + " - " + + pushedRule.debugBeginRegExp + ); + } + + handleCaptures( + grammar, + lineText, + isFirstLine, + stack, + lineTokens, + pushedRule.beginCaptures, + captureIndices + ); + lineTokens.produce(stack, captureIndices[0].end); + anchorPosition = captureIndices[0].end; + + const contentName = pushedRule.getContentName( + lineText.content, + captureIndices + ); + const contentNameScopesList = nameScopesList.pushAttributed( + contentName, + grammar + ); + stack = stack.withContentNameScopesList(contentNameScopesList); + + if (pushedRule.endHasBackReferences) { + stack = stack.withEndRule( + pushedRule.getEndWithResolvedBackReferences( + lineText.content, + captureIndices + ) + ); + } + + if (!hasAdvanced && beforePush.hasSameRuleAs(stack)) { + // Grammar pushed the same rule without advancing + if (DebugFlags.InDebugMode) { + console.error( + "[2] - Grammar is in an endless loop - Grammar pushed the same rule without advancing" + ); + } + stack = stack.pop()!; + lineTokens.produce(stack, lineLength); + STOP = true; + return; + } + } else if (_rule instanceof BeginWhileRule) { + const pushedRule = _rule; + if (DebugFlags.InDebugMode) { + console.log(" pushing " + pushedRule.debugName); + } + + handleCaptures( + grammar, + lineText, + isFirstLine, + stack, + lineTokens, + pushedRule.beginCaptures, + captureIndices + ); + lineTokens.produce(stack, captureIndices[0].end); + anchorPosition = captureIndices[0].end; + const contentName = pushedRule.getContentName( + lineText.content, + captureIndices + ); + const contentNameScopesList = nameScopesList.pushAttributed( + contentName, + grammar + ); + stack = stack.withContentNameScopesList(contentNameScopesList); + + if (pushedRule.whileHasBackReferences) { + stack = stack.withEndRule( + pushedRule.getWhileWithResolvedBackReferences( + lineText.content, + captureIndices + ) + ); + } + + if (!hasAdvanced && beforePush.hasSameRuleAs(stack)) { + // Grammar pushed the same rule without advancing + if (DebugFlags.InDebugMode) { + console.error( + "[3] - Grammar is in an endless loop - Grammar pushed the same rule without advancing" + ); + } + stack = stack.pop()!; + lineTokens.produce(stack, lineLength); + STOP = true; + return; + } + } else { + const matchingRule = _rule; + if (DebugFlags.InDebugMode) { + console.log( + " matched " + + matchingRule.debugName + + " - " + + matchingRule.debugMatchRegExp + ); + } + + handleCaptures( + grammar, + lineText, + isFirstLine, + stack, + lineTokens, + matchingRule.captures, + captureIndices + ); + lineTokens.produce(stack, captureIndices[0].end); + + // pop rule immediately since it is a MatchRule + stack = stack.pop()!; + + if (!hasAdvanced) { + // Grammar is not advancing, nor is it pushing/popping + if (DebugFlags.InDebugMode) { + console.error( + "[4] - Grammar is in an endless loop - Grammar is not advancing, nor is it pushing/popping" + ); + } + stack = stack.safePop(); + lineTokens.produce(stack, lineLength); + STOP = true; + return; + } + } + } + + if (captureIndices[0].end > linePos) { + // Advance stream + linePos = captureIndices[0].end; + isFirstLine = false; + } + } +} + +/** + * Walk the stack from bottom to top, and check each while condition in this order. + * If any fails, cut off the entire stack above the failed while condition. While conditions + * may also advance the linePosition. + */ +function _checkWhileConditions(grammar: Grammar, lineText: OnigString, isFirstLine: boolean, linePos: number, stack: StateStackImpl, lineTokens: LineTokens): IWhileCheckResult { + let anchorPosition = (stack.beginRuleCapturedEOL ? 0 : -1); + + interface IWhileStack { + readonly stack: StateStackImpl; + readonly rule: BeginWhileRule; + } + + const whileRules: IWhileStack[] = []; + for (let node: StateStackImpl | null = stack; node; node = node.pop()) { + const nodeRule = node.getRule(grammar); + if (nodeRule instanceof BeginWhileRule) { + whileRules.push({ + rule: nodeRule, + stack: node + }); + } + } + + for (let whileRule = whileRules.pop(); whileRule; whileRule = whileRules.pop()) { + const { ruleScanner, findOptions } = prepareRuleWhileSearch(whileRule.rule, grammar, whileRule.stack.endRule, isFirstLine, linePos === anchorPosition); + const r = ruleScanner.findNextMatchSync(lineText, linePos, findOptions); + if (DebugFlags.InDebugMode) { + console.log(' scanning for while rule'); + console.log(ruleScanner.toString()); + } + + if (r) { + const matchedRuleId = r.ruleId; + if (matchedRuleId !== whileRuleId) { + // we shouldn't end up here + stack = whileRule.stack.pop()!; + break; + } + if (r.captureIndices && r.captureIndices.length) { + lineTokens.produce(whileRule.stack, r.captureIndices[0].start); + handleCaptures(grammar, lineText, isFirstLine, whileRule.stack, lineTokens, whileRule.rule.whileCaptures, r.captureIndices); + lineTokens.produce(whileRule.stack, r.captureIndices[0].end); + anchorPosition = r.captureIndices[0].end; + if (r.captureIndices[0].end > linePos) { + linePos = r.captureIndices[0].end; + isFirstLine = false; + } + } + } else { + if (DebugFlags.InDebugMode) { + console.log(' popping ' + whileRule.rule.debugName + ' - ' + whileRule.rule.debugWhileRegExp); + } + + stack = whileRule.stack.pop()!; + break; + } + } + + return { stack: stack, linePos: linePos, anchorPosition: anchorPosition, isFirstLine: isFirstLine }; +} + +interface IWhileCheckResult { + readonly stack: StateStackImpl; + readonly linePos: number; + readonly anchorPosition: number; + readonly isFirstLine: boolean; +} + +function matchRuleOrInjections(grammar: Grammar, lineText: OnigString, isFirstLine: boolean, linePos: number, stack: StateStackImpl, anchorPosition: number): IMatchResult | null { + // Look for normal grammar rule + const matchResult = matchRule(grammar, lineText, isFirstLine, linePos, stack, anchorPosition); + + // Look for injected rules + const injections = grammar.getInjections(); + if (injections.length === 0) { + // No injections whatsoever => early return + return matchResult; + } + + const injectionResult = matchInjections(injections, grammar, lineText, isFirstLine, linePos, stack, anchorPosition); + if (!injectionResult) { + // No injections matched => early return + return matchResult; + } + + if (!matchResult) { + // Only injections matched => early return + return injectionResult; + } + + // Decide if `matchResult` or `injectionResult` should win + const matchResultScore = matchResult.captureIndices[0].start; + const injectionResultScore = injectionResult.captureIndices[0].start; + + if (injectionResultScore < matchResultScore || (injectionResult.priorityMatch && injectionResultScore === matchResultScore)) { + // injection won! + return injectionResult; + } + return matchResult; +} + +interface IMatchResult { + readonly captureIndices: IOnigCaptureIndex[]; + readonly matchedRuleId: RuleId | typeof endRuleId; +} + +function matchRule(grammar: Grammar, lineText: OnigString, isFirstLine: boolean, linePos: number, stack: StateStackImpl, anchorPosition: number): IMatchResult | null { + const rule = stack.getRule(grammar); + const { ruleScanner, findOptions } = prepareRuleSearch(rule, grammar, stack.endRule, isFirstLine, linePos === anchorPosition); + + let perfStart = 0; + if (DebugFlags.InDebugMode) { + perfStart = performanceNow(); + } + + const r = ruleScanner.findNextMatchSync(lineText, linePos, findOptions); + + if (DebugFlags.InDebugMode) { + const elapsedMillis = performanceNow() - perfStart; + if (elapsedMillis > 5) { + console.warn(`Rule ${rule.debugName} (${rule.id}) matching took ${elapsedMillis} against '${lineText}'`); + } + console.log(` scanning for (linePos: ${linePos}, anchorPosition: ${anchorPosition})`); + console.log(ruleScanner.toString()); + if (r) { + console.log(`matched rule id: ${r.ruleId} from ${r.captureIndices[0].start} to ${r.captureIndices[0].end}`); + } + } + + if (r) { + return { + captureIndices: r.captureIndices, + matchedRuleId: r.ruleId + }; + } + return null; +} + +function matchInjections(injections: Injection[], grammar: Grammar, lineText: OnigString, isFirstLine: boolean, linePos: number, stack: StateStackImpl, anchorPosition: number): IMatchInjectionsResult | null { + // The lower the better + let bestMatchRating = Number.MAX_VALUE; + let bestMatchCaptureIndices: IOnigCaptureIndex[] | null = null; + let bestMatchRuleId: RuleId | typeof endRuleId; + let bestMatchResultPriority: number = 0; + + const scopes = stack.contentNameScopesList!.getScopeNames(); + + for (let i = 0, len = injections.length; i < len; i++) { + const injection = injections[i]; + if (!injection.matcher(scopes)) { + // injection selector doesn't match stack + continue; + } + const rule = grammar.getRule(injection.ruleId); + const { ruleScanner, findOptions } = prepareRuleSearch(rule, grammar, null, isFirstLine, linePos === anchorPosition); + const matchResult = ruleScanner.findNextMatchSync(lineText, linePos, findOptions); + if (!matchResult) { + continue; + } + + if (DebugFlags.InDebugMode) { + console.log(` matched injection: ${injection.debugSelector}`); + console.log(ruleScanner.toString()); + } + + const matchRating = matchResult.captureIndices[0].start; + if (matchRating >= bestMatchRating) { + // Injections are sorted by priority, so the previous injection had a better or equal priority + continue; + } + + bestMatchRating = matchRating; + bestMatchCaptureIndices = matchResult.captureIndices; + bestMatchRuleId = matchResult.ruleId; + bestMatchResultPriority = injection.priority; + + if (bestMatchRating === linePos) { + // No more need to look at the rest of the injections. + break; + } + } + + if (bestMatchCaptureIndices) { + return { + priorityMatch: bestMatchResultPriority === -1, + captureIndices: bestMatchCaptureIndices, + matchedRuleId: bestMatchRuleId! + }; + } + + return null; +} + +interface IMatchInjectionsResult { + readonly priorityMatch: boolean; + readonly captureIndices: IOnigCaptureIndex[]; + readonly matchedRuleId: RuleId | typeof endRuleId; +} + +function prepareRuleSearch(rule: Rule, grammar: Grammar, endRegexSource: string | null, allowA: boolean, allowG: boolean): { ruleScanner: CompiledRule; findOptions: number; } { + if (UseOnigurumaFindOptions) { + const ruleScanner = rule.compile(grammar, endRegexSource); + const findOptions = getFindOptions(allowA, allowG); + return { ruleScanner, findOptions }; + } + const ruleScanner = rule.compileAG(grammar, endRegexSource, allowA, allowG); + return { ruleScanner, findOptions: FindOption.None }; +} + +function prepareRuleWhileSearch(rule: BeginWhileRule, grammar: Grammar, endRegexSource: string | null, allowA: boolean, allowG: boolean): { ruleScanner: CompiledRule; findOptions: number; } { + if (UseOnigurumaFindOptions) { + const ruleScanner = rule.compileWhile(grammar, endRegexSource); + const findOptions = getFindOptions(allowA, allowG); + return { ruleScanner, findOptions }; + } + const ruleScanner = rule.compileWhileAG(grammar, endRegexSource, allowA, allowG); + return { ruleScanner, findOptions: FindOption.None }; +} + +function getFindOptions(allowA: boolean, allowG: boolean): number { + let options = FindOption.None; + if (!allowA) { + options |= FindOption.NotBeginString; + } + if (!allowG) { + options |= FindOption.NotBeginPosition; + } + return options; +} + +function handleCaptures(grammar: Grammar, lineText: OnigString, isFirstLine: boolean, stack: StateStackImpl, lineTokens: LineTokens, captures: (CaptureRule | null)[], captureIndices: IOnigCaptureIndex[]): void { + if (captures.length === 0) { + return; + } + + const lineTextContent = lineText.content; + + const len = Math.min(captures.length, captureIndices.length); + const localStack: LocalStackElement[] = []; + const maxEnd = captureIndices[0].end; + + for (let i = 0; i < len; i++) { + const captureRule = captures[i]; + if (captureRule === null) { + // Not interested + continue; + } + + const captureIndex = captureIndices[i]; + + if (captureIndex.length === 0) { + // Nothing really captured + continue; + } + + if (captureIndex.start > maxEnd) { + // Capture going beyond consumed string + break; + } + + // pop captures while needed + while (localStack.length > 0 && localStack[localStack.length - 1].endPos <= captureIndex.start) { + // pop! + lineTokens.produceFromScopes(localStack[localStack.length - 1].scopes, localStack[localStack.length - 1].endPos); + localStack.pop(); + } + + if (localStack.length > 0) { + lineTokens.produceFromScopes(localStack[localStack.length - 1].scopes, captureIndex.start); + } else { + lineTokens.produce(stack, captureIndex.start); + } + + if (captureRule.retokenizeCapturedWithRuleId) { + // the capture requires additional matching + const scopeName = captureRule.getName(lineTextContent, captureIndices); + const nameScopesList = stack.contentNameScopesList!.pushAttributed(scopeName, grammar); + const contentName = captureRule.getContentName(lineTextContent, captureIndices); + const contentNameScopesList = nameScopesList.pushAttributed(contentName, grammar); + + const stackClone = stack.push(captureRule.retokenizeCapturedWithRuleId, captureIndex.start, -1, false, null, nameScopesList, contentNameScopesList); + const onigSubStr = grammar.createOnigString(lineTextContent.substring(0, captureIndex.end)); + _tokenizeString(grammar, onigSubStr, (isFirstLine && captureIndex.start === 0), captureIndex.start, stackClone, lineTokens, false, /* no time limit */0); + disposeOnigString(onigSubStr); + continue; + } + + const captureRuleScopeName = captureRule.getName(lineTextContent, captureIndices); + if (captureRuleScopeName !== null) { + // push + const base = localStack.length > 0 ? localStack[localStack.length - 1].scopes : stack.contentNameScopesList; + const captureRuleScopesList = base!.pushAttributed(captureRuleScopeName, grammar); + localStack.push(new LocalStackElement(captureRuleScopesList, captureIndex.end)); + } + } + + while (localStack.length > 0) { + // pop! + lineTokens.produceFromScopes(localStack[localStack.length - 1].scopes, localStack[localStack.length - 1].endPos); + localStack.pop(); + } +} + +export class LocalStackElement { + public readonly scopes: AttributedScopeStack; + public readonly endPos: number; + + constructor(scopes: AttributedScopeStack, endPos: number) { + this.scopes = scopes; + this.endPos = endPos; + } +} diff --git a/src/textmate/json.ts b/src/textmate/json.ts new file mode 100644 index 0000000..4488399 --- /dev/null +++ b/src/textmate/json.ts @@ -0,0 +1,521 @@ +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ + +function doFail(streamState: JSONStreamState, msg: string): void { + // console.log('Near offset ' + streamState.pos + ': ' + msg + ' ~~~' + streamState.source.substr(streamState.pos, 50) + '~~~'); + throw new Error('Near offset ' + streamState.pos + ': ' + msg + ' ~~~' + streamState.source.substr(streamState.pos, 50) + '~~~'); +} + +export interface ILocation { + readonly filename: string | null; + readonly line: number; + readonly char: number; +} + +export function parseJSON(source: string, filename: string | null, withMetadata: boolean): any { + let streamState = new JSONStreamState(source); + let token = new JSONToken(); + let state = JSONState.ROOT_STATE; + let cur: any = null; + let stateStack: JSONState[] = []; + let objStack: any[] = []; + + function pushState(): void { + stateStack.push(state); + objStack.push(cur); + } + + function popState(): void { + state = stateStack.pop()!; + cur = objStack.pop(); + } + + function fail(msg: string): void { + doFail(streamState, msg); + } + + while (nextJSONToken(streamState, token)) { + + if (state === JSONState.ROOT_STATE) { + if (cur !== null) { + fail('too many constructs in root'); + } + + if (token.type === JSONTokenType.LEFT_CURLY_BRACKET) { + cur = {}; + if (withMetadata) { + cur.$vscodeTextmateLocation = token.toLocation(filename); + } + pushState(); + state = JSONState.DICT_STATE; + continue; + } + + if (token.type === JSONTokenType.LEFT_SQUARE_BRACKET) { + cur = []; + pushState(); + state = JSONState.ARR_STATE; + continue; + } + + fail('unexpected token in root'); + + } + + if (state === JSONState.DICT_STATE_COMMA) { + + if (token.type === JSONTokenType.RIGHT_CURLY_BRACKET) { + popState(); + continue; + } + + if (token.type === JSONTokenType.COMMA) { + state = JSONState.DICT_STATE_NO_CLOSE; + continue; + } + + fail('expected , or }'); + + } + + if (state === JSONState.DICT_STATE || state === JSONState.DICT_STATE_NO_CLOSE) { + + if (state === JSONState.DICT_STATE && token.type === JSONTokenType.RIGHT_CURLY_BRACKET) { + popState(); + continue; + } + + if (token.type === JSONTokenType.STRING) { + let keyValue = token.value!; + + if (!nextJSONToken(streamState, token) || (/*TS bug*/token.type) !== JSONTokenType.COLON) { + fail('expected colon'); + } + if (!nextJSONToken(streamState, token)) { + fail('expected value'); + } + + state = JSONState.DICT_STATE_COMMA; + + if (token.type === JSONTokenType.STRING) { + cur[keyValue] = token.value; + continue; + } + if (token.type === JSONTokenType.NULL) { + cur[keyValue] = null; + continue; + } + if (token.type === JSONTokenType.TRUE) { + cur[keyValue] = true; + continue; + } + if (token.type === JSONTokenType.FALSE) { + cur[keyValue] = false; + continue; + } + if (token.type === JSONTokenType.NUMBER) { + cur[keyValue] = parseFloat(token.value!); + continue; + } + if (token.type === JSONTokenType.LEFT_SQUARE_BRACKET) { + let newArr: any[] = []; + cur[keyValue] = newArr; + pushState(); + state = JSONState.ARR_STATE; + cur = newArr; + continue; + } + if (token.type === JSONTokenType.LEFT_CURLY_BRACKET) { + let newDict: any = {}; + if (withMetadata) { + newDict.$vscodeTextmateLocation = token.toLocation(filename); + } + cur[keyValue] = newDict; + pushState(); + state = JSONState.DICT_STATE; + cur = newDict; + continue; + } + } + + fail('unexpected token in dict'); + } + + if (state === JSONState.ARR_STATE_COMMA) { + + if (token.type === JSONTokenType.RIGHT_SQUARE_BRACKET) { + popState(); + continue; + } + + if (token.type === JSONTokenType.COMMA) { + state = JSONState.ARR_STATE_NO_CLOSE; + continue; + } + + fail('expected , or ]'); + } + + if (state === JSONState.ARR_STATE || state === JSONState.ARR_STATE_NO_CLOSE) { + + if (state === JSONState.ARR_STATE && token.type === JSONTokenType.RIGHT_SQUARE_BRACKET) { + popState(); + continue; + } + + state = JSONState.ARR_STATE_COMMA; + + if (token.type === JSONTokenType.STRING) { + cur.push(token.value); + continue; + } + if (token.type === JSONTokenType.NULL) { + cur.push(null); + continue; + } + if (token.type === JSONTokenType.TRUE) { + cur.push(true); + continue; + } + if (token.type === JSONTokenType.FALSE) { + cur.push(false); + continue; + } + if (token.type === JSONTokenType.NUMBER) { + cur.push(parseFloat(token.value!)); + continue; + } + + if (token.type === JSONTokenType.LEFT_SQUARE_BRACKET) { + let newArr: any[] = []; + cur.push(newArr); + pushState(); + state = JSONState.ARR_STATE; + cur = newArr; + continue; + } + if (token.type === JSONTokenType.LEFT_CURLY_BRACKET) { + let newDict: any = {}; + if (withMetadata) { + newDict.$vscodeTextmateLocation = token.toLocation(filename); + } + cur.push(newDict); + pushState(); + state = JSONState.DICT_STATE; + cur = newDict; + continue; + } + + fail('unexpected token in array'); + } + + fail('unknown state'); + } + + if (objStack.length !== 0) { + fail('unclosed constructs'); + } + + return cur; +} + +class JSONStreamState { + source: string; + + pos: number; + len: number; + + line: number; + char: number; + + constructor(source: string) { + this.source = source; + this.pos = 0; + this.len = source.length; + this.line = 1; + this.char = 0; + } +} + +const enum JSONTokenType { + UNKNOWN = 0, + STRING = 1, + LEFT_SQUARE_BRACKET = 2, // [ + LEFT_CURLY_BRACKET = 3, // { + RIGHT_SQUARE_BRACKET = 4, // ] + RIGHT_CURLY_BRACKET = 5, // } + COLON = 6, // : + COMMA = 7, // , + NULL = 8, + TRUE = 9, + FALSE = 10, + NUMBER = 11 +} + +const enum JSONState { + ROOT_STATE = 0, + DICT_STATE = 1, + DICT_STATE_COMMA = 2, + DICT_STATE_NO_CLOSE = 3, + ARR_STATE = 4, + ARR_STATE_COMMA = 5, + ARR_STATE_NO_CLOSE = 6, +} + +const enum ChCode { + SPACE = 0x20, + HORIZONTAL_TAB = 0x09, + CARRIAGE_RETURN = 0x0D, + LINE_FEED = 0x0A, + QUOTATION_MARK = 0x22, + BACKSLASH = 0x5C, + + LEFT_SQUARE_BRACKET = 0x5B, + LEFT_CURLY_BRACKET = 0x7B, + RIGHT_SQUARE_BRACKET = 0x5D, + RIGHT_CURLY_BRACKET = 0x7D, + COLON = 0x3A, + COMMA = 0x2C, + DOT = 0x2E, + + D0 = 0x30, + D9 = 0x39, + + MINUS = 0x2D, + PLUS = 0x2B, + + E = 0x45, + + a = 0x61, + e = 0x65, + f = 0x66, + l = 0x6C, + n = 0x6E, + r = 0x72, + s = 0x73, + t = 0x74, + u = 0x75, +} + +class JSONToken { + value: string | null; + type: JSONTokenType; + + offset: number; + len: number; + + line: number; /* 1 based line number */ + char: number; + + constructor() { + this.value = null; + this.type = JSONTokenType.UNKNOWN; + this.offset = -1; + this.len = -1; + this.line = -1; + this.char = -1; + } + + toLocation(filename: string | null): ILocation { + return { + filename: filename, + line: this.line, + char: this.char + }; + } +} + +/** + * precondition: the string is known to be valid JSON (https://www.ietf.org/rfc/rfc4627.txt) + */ +function nextJSONToken(_state: JSONStreamState, _out: JSONToken): boolean { + _out.value = null; + _out.type = JSONTokenType.UNKNOWN; + _out.offset = -1; + _out.len = -1; + _out.line = -1; + _out.char = -1; + + let source = _state.source; + let pos = _state.pos; + let len = _state.len; + let line = _state.line; + let char = _state.char; + + //------------------------ skip whitespace + let chCode: number; + do { + if (pos >= len) { + return false; /*EOS*/ + } + + chCode = source.charCodeAt(pos); + if (chCode === ChCode.SPACE || chCode === ChCode.HORIZONTAL_TAB || chCode === ChCode.CARRIAGE_RETURN) { + // regular whitespace + pos++; char++; + continue; + } + + if (chCode === ChCode.LINE_FEED) { + // newline + pos++; line++; char = 0; + continue; + } + + // not whitespace + break; + } while (true); + + _out.offset = pos; + _out.line = line; + _out.char = char; + + if (chCode === ChCode.QUOTATION_MARK) { + //------------------------ strings + _out.type = JSONTokenType.STRING; + + pos++; char++; + + do { + if (pos >= len) { + return false; /*EOS*/ + } + + chCode = source.charCodeAt(pos); + pos++; char++; + + if (chCode === ChCode.BACKSLASH) { + // skip next char + pos++; char++; + continue; + } + + if (chCode === ChCode.QUOTATION_MARK) { + // end of the string + break; + } + } while (true); + + _out.value = source.substring(_out.offset + 1, pos - 1).replace(/\\u([0-9A-Fa-f]{4})/g, (_, m0) => { + return (String).fromCodePoint(parseInt(m0, 16)); + }).replace(/\\(.)/g, (_, m0) => { + switch (m0) { + case '"': return '"'; + case '\\': return '\\'; + case '/': return '/'; + case 'b': return '\b'; + case 'f': return '\f'; + case 'n': return '\n'; + case 'r': return '\r'; + case 't': return '\t'; + default: doFail(_state, 'invalid escape sequence'); + } + throw new Error('unreachable'); + }); + + } else if (chCode === ChCode.LEFT_SQUARE_BRACKET) { + + _out.type = JSONTokenType.LEFT_SQUARE_BRACKET; + pos++; char++; + + } else if (chCode === ChCode.LEFT_CURLY_BRACKET) { + + _out.type = JSONTokenType.LEFT_CURLY_BRACKET; + pos++; char++; + + } else if (chCode === ChCode.RIGHT_SQUARE_BRACKET) { + + _out.type = JSONTokenType.RIGHT_SQUARE_BRACKET; + pos++; char++; + + } else if (chCode === ChCode.RIGHT_CURLY_BRACKET) { + + _out.type = JSONTokenType.RIGHT_CURLY_BRACKET; + pos++; char++; + + } else if (chCode === ChCode.COLON) { + + _out.type = JSONTokenType.COLON; + pos++; char++; + + } else if (chCode === ChCode.COMMA) { + + _out.type = JSONTokenType.COMMA; + pos++; char++; + + } else if (chCode === ChCode.n) { + //------------------------ null + + _out.type = JSONTokenType.NULL; + pos++; char++; chCode = source.charCodeAt(pos); + if (chCode !== ChCode.u) { return false; /* INVALID */ } + pos++; char++; chCode = source.charCodeAt(pos); + if (chCode !== ChCode.l) { return false; /* INVALID */ } + pos++; char++; chCode = source.charCodeAt(pos); + if (chCode !== ChCode.l) { return false; /* INVALID */ } + pos++; char++; + + } else if (chCode === ChCode.t) { + //------------------------ true + + _out.type = JSONTokenType.TRUE; + pos++; char++; chCode = source.charCodeAt(pos); + if (chCode !== ChCode.r) { return false; /* INVALID */ } + pos++; char++; chCode = source.charCodeAt(pos); + if (chCode !== ChCode.u) { return false; /* INVALID */ } + pos++; char++; chCode = source.charCodeAt(pos); + if (chCode !== ChCode.e) { return false; /* INVALID */ } + pos++; char++; + + } else if (chCode === ChCode.f) { + //------------------------ false + + _out.type = JSONTokenType.FALSE; + pos++; char++; chCode = source.charCodeAt(pos); + if (chCode !== ChCode.a) { return false; /* INVALID */ } + pos++; char++; chCode = source.charCodeAt(pos); + if (chCode !== ChCode.l) { return false; /* INVALID */ } + pos++; char++; chCode = source.charCodeAt(pos); + if (chCode !== ChCode.s) { return false; /* INVALID */ } + pos++; char++; chCode = source.charCodeAt(pos); + if (chCode !== ChCode.e) { return false; /* INVALID */ } + pos++; char++; + + } else { + //------------------------ numbers + + _out.type = JSONTokenType.NUMBER; + do { + if (pos >= len) { return false; /*EOS*/ } + + chCode = source.charCodeAt(pos); + if ( + chCode === ChCode.DOT + || (chCode >= ChCode.D0 && chCode <= ChCode.D9) + || (chCode === ChCode.e || chCode === ChCode.E) + || (chCode === ChCode.MINUS || chCode === ChCode.PLUS) + ) { + // looks like a piece of a number + pos++; char++; + continue; + } + + // pos--; char--; + break; + } while (true); + } + + _out.len = pos - _out.offset; + if (_out.value === null) { + _out.value = source.substr(_out.offset, _out.len); + } + + _state.pos = pos; + _state.line = line; + _state.char = char; + + // console.log('PRODUCING TOKEN: ', _out.value, JSONTokenType[_out.type]); + + return true; +} diff --git a/src/textmate/main.ts b/src/textmate/main.ts new file mode 100644 index 0000000..b79dd99 --- /dev/null +++ b/src/textmate/main.ts @@ -0,0 +1,270 @@ +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ + +import { BalancedBracketSelectors, StateStackImpl } from './grammar'; +import * as grammarReader from './parseRawGrammar'; +import { IOnigLib } from './onigLib'; +import { IRawGrammar } from './rawGrammar'; +import { SyncRegistry } from './registry'; +import { IRawTheme, ScopeName, Theme } from './theme'; +import { StandardTokenType } from './encodedTokenAttributes'; +import { ScopeDependencyProcessor } from './grammar/grammarDependencies' +import { applyStateStackDiff, diffStateStacksRefEq, StackDiff } from './diffStateStacks'; + +export * from './onigLib'; + +export { IRawGrammar, IRawTheme }; + +/** + * A registry helper that can locate grammar file paths given scope names. + */ +export interface RegistryOptions { + onigLib: Promise; + theme?: IRawTheme; + colorMap?: string[]; + loadGrammar(scopeName: ScopeName): Promise; + getInjections?(scopeName: ScopeName): ScopeName[] | undefined; +} + +/** + * A map from scope name to a language id. Please do not use language id 0. + */ +export interface IEmbeddedLanguagesMap { + [scopeName: string]: number; +} + +/** + * A map from selectors to token types. + */ +export interface ITokenTypeMap { + [selector: string]: StandardTokenType; +} + +export interface IGrammarConfiguration { + embeddedLanguages?: IEmbeddedLanguagesMap; + tokenTypes?: ITokenTypeMap; + balancedBracketSelectors?: string[]; + unbalancedBracketSelectors?: string[]; +} + +/** + * The registry that will hold all grammars. + */ +export class Registry { + private readonly _options: RegistryOptions; + private readonly _syncRegistry: SyncRegistry; + private readonly _ensureGrammarCache: Map>; + + constructor(options: RegistryOptions) { + this._options = options; + this._syncRegistry = new SyncRegistry( + Theme.createFromRawTheme(options.theme, options.colorMap), + options.onigLib + ); + this._ensureGrammarCache = new Map>(); + } + + public dispose(): void { + this._syncRegistry.dispose(); + } + + /** + * Change the theme. Once called, no previous `ruleStack` should be used anymore. + */ + public setTheme(theme: IRawTheme, colorMap?: string[]): void { + this._syncRegistry.setTheme(Theme.createFromRawTheme(theme, colorMap)); + } + + /** + * Returns a lookup array for color ids. + */ + public getColorMap(): string[] { + return this._syncRegistry.getColorMap(); + } + + /** + * Load the grammar for `scopeName` and all referenced included grammars asynchronously. + * Please do not use language id 0. + */ + public loadGrammarWithEmbeddedLanguages( + initialScopeName: ScopeName, + initialLanguage: number, + embeddedLanguages: IEmbeddedLanguagesMap + ): Promise { + return this.loadGrammarWithConfiguration(initialScopeName, initialLanguage, { embeddedLanguages }); + } + + /** + * Load the grammar for `scopeName` and all referenced included grammars asynchronously. + * Please do not use language id 0. + */ + public loadGrammarWithConfiguration( + initialScopeName: ScopeName, + initialLanguage: number, + configuration: IGrammarConfiguration + ): Promise { + return this._loadGrammar( + initialScopeName, + initialLanguage, + configuration.embeddedLanguages, + configuration.tokenTypes, + new BalancedBracketSelectors( + configuration.balancedBracketSelectors || [], + configuration.unbalancedBracketSelectors || [] + ) + ); + } + + /** + * Load the grammar for `scopeName` and all referenced included grammars asynchronously. + */ + public loadGrammar(initialScopeName: ScopeName): Promise { + return this._loadGrammar(initialScopeName, 0, null, null, null); + } + + private async _loadGrammar( + initialScopeName: ScopeName, + initialLanguage: number, + embeddedLanguages: IEmbeddedLanguagesMap | null | undefined, + tokenTypes: ITokenTypeMap | null | undefined, + balancedBracketSelectors: BalancedBracketSelectors | null + ): Promise { + const dependencyProcessor = new ScopeDependencyProcessor(this._syncRegistry, initialScopeName); + while (dependencyProcessor.Q.length > 0) { + await Promise.all(dependencyProcessor.Q.map((request) => this._loadSingleGrammar(request.scopeName))); + dependencyProcessor.processQueue(); + } + + return this._grammarForScopeName( + initialScopeName, + initialLanguage, + embeddedLanguages, + tokenTypes, + balancedBracketSelectors + ); + } + + private async _loadSingleGrammar(scopeName: ScopeName): Promise { + if (!this._ensureGrammarCache.has(scopeName)) { + this._ensureGrammarCache.set(scopeName, this._doLoadSingleGrammar(scopeName)); + } + return this._ensureGrammarCache.get(scopeName); + } + + private async _doLoadSingleGrammar(scopeName: ScopeName): Promise { + const grammar = await this._options.loadGrammar(scopeName); + if (grammar) { + const injections = + typeof this._options.getInjections === "function" ? this._options.getInjections(scopeName) : undefined; + this._syncRegistry.addGrammar(grammar, injections); + } + } + + /** + * Adds a rawGrammar. + */ + public async addGrammar( + rawGrammar: IRawGrammar, + injections: string[] = [], + initialLanguage: number = 0, + embeddedLanguages: IEmbeddedLanguagesMap | null = null + ): Promise { + this._syncRegistry.addGrammar(rawGrammar, injections); + return (await this._grammarForScopeName(rawGrammar.scopeName, initialLanguage, embeddedLanguages))!; + } + + /** + * Get the grammar for `scopeName`. The grammar must first be created via `loadGrammar` or `addGrammar`. + */ + private _grammarForScopeName( + scopeName: string, + initialLanguage: number = 0, + embeddedLanguages: IEmbeddedLanguagesMap | null = null, + tokenTypes: ITokenTypeMap | null = null, + balancedBracketSelectors: BalancedBracketSelectors | null = null + ): Promise { + return this._syncRegistry.grammarForScopeName( + scopeName, + initialLanguage, + embeddedLanguages, + tokenTypes, + balancedBracketSelectors + ); + } +} + +/** + * A grammar + */ +export interface IGrammar { + /** + * Tokenize `lineText` using previous line state `prevState`. + */ + tokenizeLine(lineText: string, prevState: StateStack | null, timeLimit?: number): ITokenizeLineResult; + + /** + * Tokenize `lineText` using previous line state `prevState`. + * The result contains the tokens in binary format, resolved with the following information: + * - language + * - token type (regex, string, comment, other) + * - font style + * - foreground color + * - background color + * e.g. for getting the languageId: `(metadata & MetadataConsts.LANGUAGEID_MASK) >>> MetadataConsts.LANGUAGEID_OFFSET` + */ + tokenizeLine2(lineText: string, prevState: StateStack | null, timeLimit?: number): ITokenizeLineResult2; +} + +export interface ITokenizeLineResult { + readonly tokens: IToken[]; + /** + * The `prevState` to be passed on to the next line tokenization. + */ + readonly ruleStack: StateStack; + /** + * Did tokenization stop early due to reaching the time limit. + */ + readonly stoppedEarly: boolean; +} + +export interface ITokenizeLineResult2 { + /** + * The tokens in binary format. Each token occupies two array indices. For token i: + * - at offset 2*i => startIndex + * - at offset 2*i + 1 => metadata + * + */ + readonly tokens: Uint32Array; + /** + * The `prevState` to be passed on to the next line tokenization. + */ + readonly ruleStack: StateStack; + /** + * Did tokenization stop early due to reaching the time limit. + */ + readonly stoppedEarly: boolean; +} + +export interface IToken { + startIndex: number; + readonly endIndex: number; + readonly scopes: string[]; +} + +/** + * **IMPORTANT** - Immutable! + */ +export interface StateStack { + _stackElementBrand: void; + readonly depth: number; + + clone(): StateStack; + equals(other: StateStack): boolean; +} + +export const INITIAL: StateStack = StateStackImpl.NULL; + +export const parseRawGrammar: (content: string, filePath?: string) => IRawGrammar = grammarReader.parseRawGrammar; + +export { diffStateStacksRefEq, applyStateStackDiff, StackDiff, }; diff --git a/src/textmate/matcher.ts b/src/textmate/matcher.ts new file mode 100644 index 0000000..a0f282b --- /dev/null +++ b/src/textmate/matcher.ts @@ -0,0 +1,106 @@ +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ + +export interface MatcherWithPriority { + matcher: Matcher; + priority: -1 | 0 | 1; +} + +export interface Matcher { + (matcherInput: T): boolean; +} + +export function createMatchers(selector: string, matchesName: (names: string[], matcherInput: T) => boolean): MatcherWithPriority[] { + const results = []>[]; + const tokenizer = newTokenizer(selector); + let token = tokenizer.next(); + while (token !== null) { + let priority: -1 | 0 | 1 = 0; + if (token.length === 2 && token.charAt(1) === ':') { + switch (token.charAt(0)) { + case 'R': priority = 1; break; + case 'L': priority = -1; break; + default: + console.log(`Unknown priority ${token} in scope selector`); + } + token = tokenizer.next(); + } + let matcher = parseConjunction(); + results.push({ matcher, priority }); + if (token !== ',') { + break; + } + token = tokenizer.next(); + } + return results; + + function parseOperand(): Matcher | null { + if (token === '-') { + token = tokenizer.next(); + const expressionToNegate = parseOperand(); + return matcherInput => !!expressionToNegate && !expressionToNegate(matcherInput); + } + if (token === '(') { + token = tokenizer.next(); + const expressionInParents = parseInnerExpression(); + if (token === ')') { + token = tokenizer.next(); + } + return expressionInParents; + } + if (isIdentifier(token)) { + const identifiers: string[] = []; + do { + identifiers.push(token); + token = tokenizer.next(); + } while (isIdentifier(token)); + return matcherInput => matchesName(identifiers, matcherInput); + } + return null; + } + function parseConjunction(): Matcher { + const matchers: Matcher[] = []; + let matcher = parseOperand(); + while (matcher) { + matchers.push(matcher); + matcher = parseOperand(); + } + return matcherInput => matchers.every(matcher => matcher(matcherInput)); // and + } + function parseInnerExpression(): Matcher { + const matchers: Matcher[] = []; + let matcher = parseConjunction(); + while (matcher) { + matchers.push(matcher); + if (token === '|' || token === ',') { + do { + token = tokenizer.next(); + } while (token === '|' || token === ','); // ignore subsequent commas + } else { + break; + } + matcher = parseConjunction(); + } + return matcherInput => matchers.some(matcher => matcher(matcherInput)); // or + } +} + +function isIdentifier(token: string | null): token is string { + return !!token && !!token.match(/[\w\.:]+/); +} + +function newTokenizer(input: string): { next: () => string | null } { + let regex = /([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g; + let match = regex.exec(input); + return { + next: () => { + if (!match) { + return null; + } + const res = match[0]; + match = regex.exec(input); + return res; + } + }; +} diff --git a/src/textmate/onigLib.ts b/src/textmate/onigLib.ts new file mode 100644 index 0000000..dc18448 --- /dev/null +++ b/src/textmate/onigLib.ts @@ -0,0 +1,57 @@ +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ + +import { OrMask } from "./utils"; + +export interface IOnigLib { + createOnigScanner(sources: string[]): OnigScanner; + createOnigString(str: string): OnigString; +} + +export interface IOnigCaptureIndex { + start: number; + end: number; + length: number; +} + +export interface IOnigMatch { + index: number; + captureIndices: IOnigCaptureIndex[]; +} + +export const enum FindOption { + None = 0, + /** + * equivalent of ONIG_OPTION_NOT_BEGIN_STRING: (str) isn't considered as begin of string (* fail \A) + */ + NotBeginString = 1, + /** + * equivalent of ONIG_OPTION_NOT_END_STRING: (end) isn't considered as end of string (* fail \z, \Z) + */ + NotEndString = 2, + /** + * equivalent of ONIG_OPTION_NOT_BEGIN_POSITION: (start) isn't considered as start position of search (* fail \G) + */ + NotBeginPosition = 4, + /** + * used for debugging purposes. + */ + DebugCall = 8, +} + +export interface OnigScanner { + findNextMatchSync(string: string | OnigString, startPosition: number, options: OrMask): IOnigMatch | null; + dispose?(): void; +} + +export interface OnigString { + readonly content: string; + dispose?(): void; +} + +export function disposeOnigString(str: OnigString) { + if (typeof str.dispose === 'function') { + str.dispose(); + } +} \ No newline at end of file diff --git a/src/textmate/parseRawGrammar.ts b/src/textmate/parseRawGrammar.ts new file mode 100644 index 0000000..f64614d --- /dev/null +++ b/src/textmate/parseRawGrammar.ts @@ -0,0 +1,29 @@ +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ + +import { IRawGrammar } from './rawGrammar'; +import * as plist from './plist'; +import { DebugFlags } from './debug'; +import { parseJSON } from './json'; + +export function parseRawGrammar(content: string, filePath: string | null = null): IRawGrammar { + if (filePath !== null && /\.json$/.test(filePath)) { + return parseJSONGrammar(content, filePath); + } + return parsePLISTGrammar(content, filePath); +} + +function parseJSONGrammar(contents: string, filename: string | null): IRawGrammar { + if (DebugFlags.InDebugMode) { + return parseJSON(contents, filename, true); + } + return JSON.parse(contents); +} + +function parsePLISTGrammar(contents: string, filename: string | null): IRawGrammar { + if (DebugFlags.InDebugMode) { + return plist.parseWithLocation(contents, filename, '$vscodeTextmateLocation'); + } + return plist.parsePLIST(contents); +} diff --git a/src/textmate/plist.ts b/src/textmate/plist.ts new file mode 100644 index 0000000..27e5d5b --- /dev/null +++ b/src/textmate/plist.ts @@ -0,0 +1,496 @@ +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ + +const enum ChCode { + BOM = 65279, + + SPACE = 32, + TAB = 9, + CARRIAGE_RETURN = 13, + LINE_FEED = 10, + + SLASH = 47, + + LESS_THAN = 60, + QUESTION_MARK = 63, + EXCLAMATION_MARK = 33, +} + +const enum State { + ROOT_STATE = 0, + DICT_STATE = 1, + ARR_STATE = 2 +} + +export function parseWithLocation(content: string, filename: string | null, locationKeyName: string | null): any { + return _parse(content, filename, locationKeyName); +} + +/** + * A very fast plist parser + */ +export function parsePLIST(content: string): any { + return _parse(content, null, null); +} + +function _parse(content: string, filename: string | null, locationKeyName: string | null): any { + const len = content.length; + + let pos = 0; + let line = 1; + let char = 0; + + // Skip UTF8 BOM + if (len > 0 && content.charCodeAt(0) === ChCode.BOM) { + pos = 1; + } + + function advancePosBy(by: number): void { + if (locationKeyName === null) { + pos = pos + by; + } else { + while (by > 0) { + let chCode = content.charCodeAt(pos); + if (chCode === ChCode.LINE_FEED) { + pos++; line++; char = 0; + } else { + pos++; char++; + } + by--; + } + } + } + function advancePosTo(to: number): void { + if (locationKeyName === null) { + pos = to; + } else { + advancePosBy(to - pos); + } + } + + function skipWhitespace(): void { + while (pos < len) { + let chCode = content.charCodeAt(pos); + if (chCode !== ChCode.SPACE && chCode !== ChCode.TAB && chCode !== ChCode.CARRIAGE_RETURN && chCode !== ChCode.LINE_FEED) { + break; + } + advancePosBy(1); + } + } + + function advanceIfStartsWith(str: string): boolean { + if (content.substr(pos, str.length) === str) { + advancePosBy(str.length); + return true; + } + return false; + } + + function advanceUntil(str: string): void { + let nextOccurence = content.indexOf(str, pos); + if (nextOccurence !== -1) { + advancePosTo(nextOccurence + str.length); + } else { + // EOF + advancePosTo(len); + } + } + + function captureUntil(str: string): string { + let nextOccurence = content.indexOf(str, pos); + if (nextOccurence !== -1) { + let r = content.substring(pos, nextOccurence); + advancePosTo(nextOccurence + str.length); + return r; + } else { + // EOF + let r = content.substr(pos); + advancePosTo(len); + return r; + } + } + + let state = State.ROOT_STATE; + + let cur: any = null; + let stateStack: State[] = []; + let objStack: any[] = []; + let curKey: string | null = null; + + function pushState(newState: State, newCur: any): void { + stateStack.push(state); + objStack.push(cur); + state = newState; + cur = newCur; + } + + function popState(): void { + if (stateStack.length === 0) { + return fail('illegal state stack'); + } + state = stateStack.pop()!; + cur = objStack.pop(); + } + + function fail(msg: string): void { + throw new Error('Near offset ' + pos + ': ' + msg + ' ~~~' + content.substr(pos, 50) + '~~~'); + } + + const dictState = { + enterDict: function () { + if (curKey === null) { + return fail('missing '); + } + let newDict : any = {}; + if (locationKeyName !== null) { + newDict[locationKeyName] = { + filename: filename, + line: line, + char: char + }; + } + cur[curKey] = newDict; + curKey = null; + pushState(State.DICT_STATE, newDict); + }, + enterArray: function () { + if (curKey === null) { + return fail('missing '); + } + let newArr: any[] = []; + cur[curKey] = newArr; + curKey = null; + pushState(State.ARR_STATE, newArr); + } + }; + + const arrState = { + enterDict: function () { + let newDict : any = {}; + if (locationKeyName !== null) { + newDict[locationKeyName] = { + filename: filename, + line: line, + char: char + }; + } + cur.push(newDict); + pushState(State.DICT_STATE, newDict); + }, + enterArray: function () { + let newArr: any[] = []; + cur.push(newArr); + pushState(State.ARR_STATE, newArr); + } + }; + + + function enterDict() { + if (state === State.DICT_STATE) { + dictState.enterDict(); + } else if (state === State.ARR_STATE) { + arrState.enterDict(); + } else { // ROOT_STATE + cur = {}; + if (locationKeyName !== null) { + cur[locationKeyName] = { + filename: filename, + line: line, + char: char + }; + } + pushState(State.DICT_STATE, cur); + } + } + function leaveDict() { + if (state === State.DICT_STATE) { + popState(); + } else if (state === State.ARR_STATE) { + return fail('unexpected '); + } else { // ROOT_STATE + return fail('unexpected '); + } + } + function enterArray() { + if (state === State.DICT_STATE) { + dictState.enterArray(); + } else if (state === State.ARR_STATE) { + arrState.enterArray(); + } else { // ROOT_STATE + cur = []; + pushState(State.ARR_STATE, cur); + } + } + function leaveArray() { + if (state === State.DICT_STATE) { + return fail('unexpected '); + } else if (state === State.ARR_STATE) { + popState(); + } else { // ROOT_STATE + return fail('unexpected '); + } + } + function acceptKey(val: string) { + if (state === State.DICT_STATE) { + if (curKey !== null) { + return fail('too many '); + } + curKey = val; + } else if (state === State.ARR_STATE) { + return fail('unexpected '); + } else { // ROOT_STATE + return fail('unexpected '); + } + } + function acceptString(val: string) { + if (state === State.DICT_STATE) { + if (curKey === null) { + return fail('missing '); + } + cur[curKey] = val; + curKey = null; + } else if (state === State.ARR_STATE) { + cur.push(val); + } else { // ROOT_STATE + cur = val; + } + } + function acceptReal(val: number) { + if (isNaN(val)) { + return fail('cannot parse float'); + } + if (state === State.DICT_STATE) { + if (curKey === null) { + return fail('missing '); + } + cur[curKey] = val; + curKey = null; + } else if (state === State.ARR_STATE) { + cur.push(val); + } else { // ROOT_STATE + cur = val; + } + } + function acceptInteger(val: number) { + if (isNaN(val)) { + return fail('cannot parse integer'); + } + if (state === State.DICT_STATE) { + if (curKey === null) { + return fail('missing '); + } + cur[curKey] = val; + curKey = null; + } else if (state === State.ARR_STATE) { + cur.push(val); + } else { // ROOT_STATE + cur = val; + } + } + function acceptDate(val: Date) { + if (state === State.DICT_STATE) { + if (curKey === null) { + return fail('missing '); + } + cur[curKey] = val; + curKey = null; + } else if (state === State.ARR_STATE) { + cur.push(val); + } else { // ROOT_STATE + cur = val; + } + } + function acceptData(val: string) { + if (state === State.DICT_STATE) { + if (curKey === null) { + return fail('missing '); + } + cur[curKey] = val; + curKey = null; + } else if (state === State.ARR_STATE) { + cur.push(val); + } else { // ROOT_STATE + cur = val; + } + } + function acceptBool(val: boolean) { + if (state === State.DICT_STATE) { + if (curKey === null) { + return fail('missing '); + } + cur[curKey] = val; + curKey = null; + } else if (state === State.ARR_STATE) { + cur.push(val); + } else { // ROOT_STATE + cur = val; + } + } + + function escapeVal(str: string): string { + return str.replace(/&#([0-9]+);/g, function (_: string, m0: string) { + return (String).fromCodePoint(parseInt(m0, 10)); + }).replace(/&#x([0-9a-f]+);/g, function (_: string, m0: string) { + return (String).fromCodePoint(parseInt(m0, 16)); + }).replace(/&|<|>|"|'/g, function (_: string) { + switch (_) { + case '&': return '&'; + case '<': return '<'; + case '>': return '>'; + case '"': return '"'; + case ''': return '\''; + } + return _; + }); + } + + interface IParsedTag { + name: string; + isClosed: boolean; + } + + function parseOpenTag(): IParsedTag { + let r = captureUntil('>'); + let isClosed = false; + if (r.charCodeAt(r.length - 1) === ChCode.SLASH) { + isClosed = true; + r = r.substring(0, r.length - 1); + } + + return { + name: r.trim(), + isClosed: isClosed + }; + } + + function parseTagValue(tag: IParsedTag): string { + if (tag.isClosed) { + return ''; + } + let val = captureUntil(''); + return escapeVal(val); + } + + while (pos < len) { + skipWhitespace(); + if (pos >= len) { + break; + } + + const chCode = content.charCodeAt(pos); + advancePosBy(1); + if (chCode !== ChCode.LESS_THAN) { + return fail('expected <'); + } + + if (pos >= len) { + return fail('unexpected end of input'); + } + + const peekChCode = content.charCodeAt(pos); + + if (peekChCode === ChCode.QUESTION_MARK) { + advancePosBy(1); + advanceUntil('?>'); + continue; + } + + if (peekChCode === ChCode.EXCLAMATION_MARK) { + advancePosBy(1); + + if (advanceIfStartsWith('--')) { + advanceUntil('-->'); + continue; + } + + advanceUntil('>'); + continue; + } + + if (peekChCode === ChCode.SLASH) { + advancePosBy(1); + skipWhitespace(); + + if (advanceIfStartsWith('plist')) { + advanceUntil('>'); + continue; + } + + if (advanceIfStartsWith('dict')) { + advanceUntil('>'); + leaveDict(); + continue; + } + + if (advanceIfStartsWith('array')) { + advanceUntil('>'); + leaveArray(); + continue; + } + + return fail('unexpected closed tag'); + } + + let tag = parseOpenTag(); + + switch (tag.name) { + case 'dict': + enterDict(); + if (tag.isClosed) { + leaveDict(); + } + continue; + + case 'array': + enterArray(); + if (tag.isClosed) { + leaveArray(); + } + continue; + + case 'key': + acceptKey(parseTagValue(tag)); + continue; + + case 'string': + acceptString(parseTagValue(tag)); + continue; + + case 'real': + acceptReal(parseFloat(parseTagValue(tag))); + continue; + + case 'integer': + acceptInteger(parseInt(parseTagValue(tag), 10)); + continue; + + case 'date': + acceptDate(new Date(parseTagValue(tag))); + continue; + + case 'data': + acceptData(parseTagValue(tag)); + continue; + + case 'true': + parseTagValue(tag); + acceptBool(true); + continue; + + case 'false': + parseTagValue(tag); + acceptBool(false); + continue; + } + + if (/^plist/.test(tag.name)) { + continue; + } + + return fail('unexpected opened tag ' + tag.name); + } + + return cur; +} diff --git a/src/textmate/rawGrammar.ts b/src/textmate/rawGrammar.ts new file mode 100644 index 0000000..d0e0d6e --- /dev/null +++ b/src/textmate/rawGrammar.ts @@ -0,0 +1,76 @@ +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ + +import { RuleId } from "./rule"; +import { ScopeName } from "./theme"; + +export interface IRawGrammar extends ILocatable { + repository: IRawRepository; + readonly scopeName: ScopeName; + readonly patterns: IRawRule[]; + readonly injections?: { [expression: string]: IRawRule }; + readonly injectionSelector?: string; + + readonly fileTypes?: string[]; + readonly name?: string; + readonly firstLineMatch?: string; +} + +/** + * Allowed values: + * * Scope Name, e.g. `source.ts` + * * Top level scope reference, e.g. `source.ts#entity.name.class` + * * Relative scope reference, e.g. `#entity.name.class` + * * self, e.g. `$self` + * * base, e.g. `$base` + */ +export type IncludeString = string; +export type RegExpString = string; + +export interface IRawRepositoryMap { + [name: string]: IRawRule; + $self: IRawRule; + $base: IRawRule; +} + +export type IRawRepository = IRawRepositoryMap & ILocatable; + +export interface IRawRule extends ILocatable { + id?: RuleId; // This is not part of the spec only used internally + + readonly include?: IncludeString; + + readonly name?: ScopeName; + readonly contentName?: ScopeName; + + readonly match?: RegExpString; + readonly captures?: IRawCaptures; + readonly begin?: RegExpString; + readonly beginCaptures?: IRawCaptures; + readonly end?: RegExpString; + readonly endCaptures?: IRawCaptures; + readonly while?: RegExpString; + readonly whileCaptures?: IRawCaptures; + readonly patterns?: IRawRule[]; + + readonly repository?: IRawRepository; + + readonly applyEndPatternLast?: boolean; +} + +export type IRawCaptures = IRawCapturesMap & ILocatable; + +export interface IRawCapturesMap { + [captureId: string]: IRawRule; +} + +export interface ILocation { + readonly filename: string; + readonly line: number; + readonly char: number; +} + +export interface ILocatable { + readonly $vscodeTextmateLocation?: ILocation; +} diff --git a/src/textmate/registry.ts b/src/textmate/registry.ts new file mode 100644 index 0000000..600608c --- /dev/null +++ b/src/textmate/registry.ts @@ -0,0 +1,102 @@ +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ + +import { BalancedBracketSelectors, createGrammar, Grammar, IGrammarRepository, IThemeProvider, AttributedScopeStack } from './grammar'; +import { IRawGrammar } from './rawGrammar'; +import { IGrammar, IEmbeddedLanguagesMap, ITokenTypeMap } from './main'; +import { ScopeStack, Theme, StyleAttributes, ThemeTrieElementRule, ScopeName } from './theme'; +import { IOnigLib } from './onigLib'; + +export class SyncRegistry implements IGrammarRepository, IThemeProvider { + private readonly _grammars = new Map(); + private readonly _rawGrammars = new Map(); + private readonly _injectionGrammars = new Map(); + private _theme: Theme; + + constructor(theme: Theme, private readonly _onigLibPromise: Promise) { + this._theme = theme; + } + + public dispose(): void { + for (const grammar of this._grammars.values()) { + grammar.dispose(); + } + } + + public setTheme(theme: Theme): void { + this._theme = theme; + } + + public getColorMap(): string[] { + return this._theme.getColorMap(); + } + + /** + * Add `grammar` to registry and return a list of referenced scope names + */ + public addGrammar(grammar: IRawGrammar, injectionScopeNames?: ScopeName[]): void { + this._rawGrammars.set(grammar.scopeName, grammar); + + if (injectionScopeNames) { + this._injectionGrammars.set(grammar.scopeName, injectionScopeNames); + } + } + + /** + * Lookup a raw grammar. + */ + public lookup(scopeName: ScopeName): IRawGrammar | undefined { + return this._rawGrammars.get(scopeName)!; + } + + /** + * Returns the injections for the given grammar + */ + public injections(targetScope: ScopeName): ScopeName[] { + return this._injectionGrammars.get(targetScope)!; + } + + /** + * Get the default theme settings + */ + public getDefaults(): StyleAttributes { + return this._theme.getDefaults(); + } + + /** + * Match a scope in the theme. + */ + public themeMatch(scopePath: ScopeStack): StyleAttributes | null { + return this._theme.match(scopePath); + } + + /** + * Lookup a grammar. + */ + public async grammarForScopeName( + scopeName: ScopeName, + initialLanguage: number, + embeddedLanguages: IEmbeddedLanguagesMap | null, + tokenTypes: ITokenTypeMap | null, + balancedBracketSelectors: BalancedBracketSelectors | null + ): Promise { + if (!this._grammars.has(scopeName)) { + let rawGrammar = this._rawGrammars.get(scopeName)!; + if (!rawGrammar) { + return null; + } + this._grammars.set(scopeName, createGrammar( + scopeName, + rawGrammar, + initialLanguage, + embeddedLanguages, + tokenTypes, + balancedBracketSelectors, + this, + await this._onigLibPromise + )); + } + return this._grammars.get(scopeName)!; + } +} diff --git a/src/textmate/rule.ts b/src/textmate/rule.ts new file mode 100644 index 0000000..6f30da6 --- /dev/null +++ b/src/textmate/rule.ts @@ -0,0 +1,899 @@ +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ + +import { RegexSource, mergeObjects, basename, escapeRegExpCharacters, OrMask } from './utils'; +import { IOnigLib, OnigScanner, IOnigCaptureIndex, FindOption, IOnigMatch, OnigString } from './onigLib'; +import { ILocation, IRawGrammar, IRawRepository, IRawRule, IRawCaptures } from './rawGrammar'; +import { IncludeReferenceKind, parseInclude } from './grammar/grammarDependencies'; + +const HAS_BACK_REFERENCES = /\\(\d+)/; +const BACK_REFERENCING_END = /\\(\d+)/g; + +const ruleIdSymbol = Symbol('RuleId'); +export type RuleId = { __brand: typeof ruleIdSymbol }; + +// This is a special constant to indicate that the end regexp matched. +export const endRuleId = -1; + +// This is a special constant to indicate that the while regexp matched. +export const whileRuleId = -2; + + +export function ruleIdFromNumber(id: number): RuleId { + return id as any as RuleId; +} + +export function ruleIdToNumber(id: RuleId): number { + return id as any as number; +} + +export interface IRuleRegistry { + getRule(ruleId: RuleId): Rule; + registerRule(factory: (id: RuleId) => T): T; +} + +export interface IGrammarRegistry { + getExternalGrammar(scopeName: string, repository: IRawRepository): IRawGrammar | null | undefined; +} + +export interface IRuleFactoryHelper extends IRuleRegistry, IGrammarRegistry { +} + +export abstract class Rule { + + public readonly $location: ILocation | undefined; + public readonly id: RuleId; + + private readonly _nameIsCapturing: boolean; + private readonly _name: string | null; + + private readonly _contentNameIsCapturing: boolean; + private readonly _contentName: string | null; + + constructor($location: ILocation | undefined, id: RuleId, name: string | null | undefined, contentName: string | null | undefined) { + this.$location = $location; + this.id = id; + this._name = name || null; + this._nameIsCapturing = RegexSource.hasCaptures(this._name); + this._contentName = contentName || null; + this._contentNameIsCapturing = RegexSource.hasCaptures(this._contentName); + } + + public abstract dispose(): void; + + public get debugName(): string { + const location = this.$location ? `${basename(this.$location.filename)}:${this.$location.line}` : 'unknown'; + return `${(this.constructor).name}#${this.id} @ ${location}`; + } + + public getName(lineText: string | null, captureIndices: IOnigCaptureIndex[] | null): string | null { + if (!this._nameIsCapturing || this._name === null || lineText === null || captureIndices === null) { + return this._name; + } + return RegexSource.replaceCaptures(this._name, lineText, captureIndices); + } + + public getContentName(lineText: string, captureIndices: IOnigCaptureIndex[]): string | null { + if (!this._contentNameIsCapturing || this._contentName === null) { + return this._contentName; + } + return RegexSource.replaceCaptures(this._contentName, lineText, captureIndices); + } + + public abstract collectPatterns(grammar: IRuleRegistry, out: RegExpSourceList): void; + + public abstract compile(grammar: IRuleRegistry & IOnigLib, endRegexSource: string | null): CompiledRule; + + public abstract compileAG(grammar: IRuleRegistry & IOnigLib, endRegexSource: string | null, allowA: boolean, allowG: boolean): CompiledRule; +} + +export interface ICompilePatternsResult { + readonly patterns: RuleId[]; + readonly hasMissingPatterns: boolean; +} + +export class CaptureRule extends Rule { + + public readonly retokenizeCapturedWithRuleId: RuleId | 0; + + constructor($location: ILocation | undefined, id: RuleId, name: string | null | undefined, contentName: string | null | undefined, retokenizeCapturedWithRuleId: RuleId | 0) { + super($location, id, name, contentName); + this.retokenizeCapturedWithRuleId = retokenizeCapturedWithRuleId; + } + + public dispose(): void { + // nothing to dispose + } + + public collectPatterns(grammar: IRuleRegistry, out: RegExpSourceList) { + throw new Error('Not supported!'); + } + + public compile(grammar: IRuleRegistry & IOnigLib, endRegexSource: string): CompiledRule { + throw new Error('Not supported!'); + } + + public compileAG(grammar: IRuleRegistry & IOnigLib, endRegexSource: string, allowA: boolean, allowG: boolean): CompiledRule { + throw new Error('Not supported!'); + } +} + +export class MatchRule extends Rule { + private readonly _match: RegExpSource; + public readonly captures: (CaptureRule | null)[]; + private _cachedCompiledPatterns: RegExpSourceList | null; + + constructor($location: ILocation | undefined, id: RuleId, name: string | undefined, match: string, captures: (CaptureRule | null)[]) { + super($location, id, name, null); + this._match = new RegExpSource(match, this.id); + this.captures = captures; + this._cachedCompiledPatterns = null; + } + + public dispose(): void { + if (this._cachedCompiledPatterns) { + this._cachedCompiledPatterns.dispose(); + this._cachedCompiledPatterns = null; + } + } + + public get debugMatchRegExp(): string { + return `${this._match.source}`; + } + + public collectPatterns(grammar: IRuleRegistry, out: RegExpSourceList) { + out.push(this._match); + } + + public compile(grammar: IRuleRegistry & IOnigLib, endRegexSource: string): CompiledRule { + return this._getCachedCompiledPatterns(grammar).compile(grammar); + } + + public compileAG(grammar: IRuleRegistry & IOnigLib, endRegexSource: string, allowA: boolean, allowG: boolean): CompiledRule { + return this._getCachedCompiledPatterns(grammar).compileAG(grammar, allowA, allowG); + } + + private _getCachedCompiledPatterns(grammar: IRuleRegistry & IOnigLib): RegExpSourceList { + if (!this._cachedCompiledPatterns) { + this._cachedCompiledPatterns = new RegExpSourceList(); + this.collectPatterns(grammar, this._cachedCompiledPatterns); + } + return this._cachedCompiledPatterns; + } +} + +export class IncludeOnlyRule extends Rule { + public readonly hasMissingPatterns: boolean; + public readonly patterns: RuleId[]; + private _cachedCompiledPatterns: RegExpSourceList | null; + + constructor($location: ILocation | undefined, id: RuleId, name: string | null | undefined, contentName: string | null | undefined, patterns: ICompilePatternsResult) { + super($location, id, name, contentName); + this.patterns = patterns.patterns; + this.hasMissingPatterns = patterns.hasMissingPatterns; + this._cachedCompiledPatterns = null; + } + + public dispose(): void { + if (this._cachedCompiledPatterns) { + this._cachedCompiledPatterns.dispose(); + this._cachedCompiledPatterns = null; + } + } + + public collectPatterns(grammar: IRuleRegistry, out: RegExpSourceList) { + for (const pattern of this.patterns) { + const rule = grammar.getRule(pattern); + rule.collectPatterns(grammar, out); + } + } + + public compile(grammar: IRuleRegistry & IOnigLib, endRegexSource: string): CompiledRule { + return this._getCachedCompiledPatterns(grammar).compile(grammar); + } + + public compileAG(grammar: IRuleRegistry & IOnigLib, endRegexSource: string, allowA: boolean, allowG: boolean): CompiledRule { + return this._getCachedCompiledPatterns(grammar).compileAG(grammar, allowA, allowG); + } + + private _getCachedCompiledPatterns(grammar: IRuleRegistry & IOnigLib): RegExpSourceList { + if (!this._cachedCompiledPatterns) { + this._cachedCompiledPatterns = new RegExpSourceList(); + this.collectPatterns(grammar, this._cachedCompiledPatterns); + } + return this._cachedCompiledPatterns; + } +} + +export class BeginEndRule extends Rule { + private readonly _begin: RegExpSource; + public readonly beginCaptures: (CaptureRule | null)[]; + private readonly _end: RegExpSource; + public readonly endHasBackReferences: boolean; + public readonly endCaptures: (CaptureRule | null)[]; + public readonly applyEndPatternLast: boolean; + public readonly hasMissingPatterns: boolean; + public readonly patterns: RuleId[]; + private _cachedCompiledPatterns: RegExpSourceList | null; + + constructor($location: ILocation | undefined, id: RuleId, name: string | null | undefined, contentName: string | null | undefined, begin: string, beginCaptures: (CaptureRule | null)[], end: string | undefined, endCaptures: (CaptureRule | null)[], applyEndPatternLast: boolean | undefined, patterns: ICompilePatternsResult) { + super($location, id, name, contentName); + this._begin = new RegExpSource(begin, this.id); + this.beginCaptures = beginCaptures; + this._end = new RegExpSource(end ? end : '\uFFFF', -1); + this.endHasBackReferences = this._end.hasBackReferences; + this.endCaptures = endCaptures; + this.applyEndPatternLast = applyEndPatternLast || false; + this.patterns = patterns.patterns; + this.hasMissingPatterns = patterns.hasMissingPatterns; + this._cachedCompiledPatterns = null; + } + + public dispose(): void { + if (this._cachedCompiledPatterns) { + this._cachedCompiledPatterns.dispose(); + this._cachedCompiledPatterns = null; + } + } + + public get debugBeginRegExp(): string { + return `${this._begin.source}`; + } + + public get debugEndRegExp(): string { + return `${this._end.source}`; + } + + public getEndWithResolvedBackReferences(lineText: string, captureIndices: IOnigCaptureIndex[]): string { + return this._end.resolveBackReferences(lineText, captureIndices); + } + + public collectPatterns(grammar: IRuleRegistry, out: RegExpSourceList) { + out.push(this._begin); + } + + public compile(grammar: IRuleRegistry & IOnigLib, endRegexSource: string): CompiledRule { + return this._getCachedCompiledPatterns(grammar, endRegexSource).compile(grammar); + } + + public compileAG(grammar: IRuleRegistry & IOnigLib, endRegexSource: string, allowA: boolean, allowG: boolean): CompiledRule { + return this._getCachedCompiledPatterns(grammar, endRegexSource).compileAG(grammar, allowA, allowG); + } + + private _getCachedCompiledPatterns(grammar: IRuleRegistry & IOnigLib, endRegexSource: string): RegExpSourceList { + if (!this._cachedCompiledPatterns) { + this._cachedCompiledPatterns = new RegExpSourceList(); + + for (const pattern of this.patterns) { + const rule = grammar.getRule(pattern); + rule.collectPatterns(grammar, this._cachedCompiledPatterns); + } + + if (this.applyEndPatternLast) { + this._cachedCompiledPatterns.push(this._end.hasBackReferences ? this._end.clone() : this._end); + } else { + this._cachedCompiledPatterns.unshift(this._end.hasBackReferences ? this._end.clone() : this._end); + } + } + if (this._end.hasBackReferences) { + if (this.applyEndPatternLast) { + this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length() - 1, endRegexSource); + } else { + this._cachedCompiledPatterns.setSource(0, endRegexSource); + } + } + return this._cachedCompiledPatterns; + } +} + +export class BeginWhileRule extends Rule { + private readonly _begin: RegExpSource; + public readonly beginCaptures: (CaptureRule | null)[]; + public readonly whileCaptures: (CaptureRule | null)[]; + private readonly _while: RegExpSource; + public readonly whileHasBackReferences: boolean; + public readonly hasMissingPatterns: boolean; + public readonly patterns: RuleId[]; + private _cachedCompiledPatterns: RegExpSourceList | null; + private _cachedCompiledWhilePatterns: RegExpSourceList | null; + + constructor($location: ILocation | undefined, id: RuleId, name: string | null | undefined, contentName: string | null | undefined, begin: string, beginCaptures: (CaptureRule | null)[], _while: string, whileCaptures: (CaptureRule | null)[], patterns: ICompilePatternsResult) { + super($location, id, name, contentName); + this._begin = new RegExpSource(begin, this.id); + this.beginCaptures = beginCaptures; + this.whileCaptures = whileCaptures; + this._while = new RegExpSource(_while, whileRuleId); + this.whileHasBackReferences = this._while.hasBackReferences; + this.patterns = patterns.patterns; + this.hasMissingPatterns = patterns.hasMissingPatterns; + this._cachedCompiledPatterns = null; + this._cachedCompiledWhilePatterns = null; + } + + public dispose(): void { + if (this._cachedCompiledPatterns) { + this._cachedCompiledPatterns.dispose(); + this._cachedCompiledPatterns = null; + } + if (this._cachedCompiledWhilePatterns) { + this._cachedCompiledWhilePatterns.dispose(); + this._cachedCompiledWhilePatterns = null; + } + } + + public get debugBeginRegExp(): string { + return `${this._begin.source}`; + } + + public get debugWhileRegExp(): string { + return `${this._while.source}`; + } + + public getWhileWithResolvedBackReferences(lineText: string, captureIndices: IOnigCaptureIndex[]): string { + return this._while.resolveBackReferences(lineText, captureIndices); + } + + public collectPatterns(grammar: IRuleRegistry, out: RegExpSourceList) { + out.push(this._begin); + } + + public compile(grammar: IRuleRegistry & IOnigLib, endRegexSource: string): CompiledRule { + return this._getCachedCompiledPatterns(grammar).compile(grammar); + } + + public compileAG(grammar: IRuleRegistry & IOnigLib, endRegexSource: string, allowA: boolean, allowG: boolean): CompiledRule { + return this._getCachedCompiledPatterns(grammar).compileAG(grammar, allowA, allowG); + } + + private _getCachedCompiledPatterns(grammar: IRuleRegistry & IOnigLib): RegExpSourceList { + if (!this._cachedCompiledPatterns) { + this._cachedCompiledPatterns = new RegExpSourceList(); + + for (const pattern of this.patterns) { + const rule = grammar.getRule(pattern); + rule.collectPatterns(grammar, this._cachedCompiledPatterns); + } + } + return this._cachedCompiledPatterns; + } + + public compileWhile(grammar: IRuleRegistry & IOnigLib, endRegexSource: string | null): CompiledRule { + return this._getCachedCompiledWhilePatterns(grammar, endRegexSource).compile(grammar); + } + + public compileWhileAG(grammar: IRuleRegistry & IOnigLib, endRegexSource: string | null, allowA: boolean, allowG: boolean): CompiledRule { + return this._getCachedCompiledWhilePatterns(grammar, endRegexSource).compileAG(grammar, allowA, allowG); + } + + private _getCachedCompiledWhilePatterns(grammar: IRuleRegistry & IOnigLib, endRegexSource: string | null): RegExpSourceList { + if (!this._cachedCompiledWhilePatterns) { + this._cachedCompiledWhilePatterns = new RegExpSourceList(); + this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences ? this._while.clone() : this._while); + } + if (this._while.hasBackReferences) { + this._cachedCompiledWhilePatterns.setSource(0, endRegexSource ? endRegexSource : '\uFFFF'); + } + return this._cachedCompiledWhilePatterns; + } +} + +export class RuleFactory { + + public static createCaptureRule(helper: IRuleFactoryHelper, $location: ILocation | undefined, name: string | null | undefined, contentName: string | null | undefined, retokenizeCapturedWithRuleId: RuleId | 0): CaptureRule { + return helper.registerRule((id) => { + return new CaptureRule($location, id, name, contentName, retokenizeCapturedWithRuleId); + }); + } + + public static getCompiledRuleId(desc: IRawRule, helper: IRuleFactoryHelper, repository: IRawRepository): RuleId { + if (!desc.id) { + helper.registerRule((id) => { + desc.id = id; + + if (desc.match) { + return new MatchRule( + desc.$vscodeTextmateLocation, + desc.id, + desc.name, + desc.match, + RuleFactory._compileCaptures(desc.captures, helper, repository) + ); + } + + if (typeof desc.begin === 'undefined') { + if (desc.repository) { + repository = mergeObjects({}, repository, desc.repository); + } + let patterns = desc.patterns; + if (typeof patterns === 'undefined' && desc.include) { + patterns = [{ include: desc.include }]; + } + return new IncludeOnlyRule( + desc.$vscodeTextmateLocation, + desc.id, + desc.name, + desc.contentName, + RuleFactory._compilePatterns(patterns, helper, repository) + ); + } + + if (desc.while) { + return new BeginWhileRule( + desc.$vscodeTextmateLocation, + desc.id, + desc.name, + desc.contentName, + desc.begin, RuleFactory._compileCaptures(desc.beginCaptures || desc.captures, helper, repository), + desc.while, RuleFactory._compileCaptures(desc.whileCaptures || desc.captures, helper, repository), + RuleFactory._compilePatterns(desc.patterns, helper, repository) + ); + } + + return new BeginEndRule( + desc.$vscodeTextmateLocation, + desc.id, + desc.name, + desc.contentName, + desc.begin, RuleFactory._compileCaptures(desc.beginCaptures || desc.captures, helper, repository), + desc.end, RuleFactory._compileCaptures(desc.endCaptures || desc.captures, helper, repository), + desc.applyEndPatternLast, + RuleFactory._compilePatterns(desc.patterns, helper, repository) + ); + }); + } + + return desc.id!; + } + + private static _compileCaptures(captures: IRawCaptures | undefined, helper: IRuleFactoryHelper, repository: IRawRepository): (CaptureRule | null)[] { + let r: (CaptureRule | null)[] = []; + + if (captures) { + // Find the maximum capture id + let maximumCaptureId = 0; + for (const captureId in captures) { + if (captureId === '$vscodeTextmateLocation') { + continue; + } + const numericCaptureId = parseInt(captureId, 10); + if (numericCaptureId > maximumCaptureId) { + maximumCaptureId = numericCaptureId; + } + } + + // Initialize result + for (let i = 0; i <= maximumCaptureId; i++) { + r[i] = null; + } + + // Fill out result + for (const captureId in captures) { + if (captureId === '$vscodeTextmateLocation') { + continue; + } + const numericCaptureId = parseInt(captureId, 10); + let retokenizeCapturedWithRuleId: RuleId | 0 = 0; + if (captures[captureId].patterns) { + retokenizeCapturedWithRuleId = RuleFactory.getCompiledRuleId(captures[captureId], helper, repository); + } + r[numericCaptureId] = RuleFactory.createCaptureRule(helper, captures[captureId].$vscodeTextmateLocation, captures[captureId].name, captures[captureId].contentName, retokenizeCapturedWithRuleId); + } + } + + return r; + } + + private static _compilePatterns(patterns: IRawRule[] | undefined, helper: IRuleFactoryHelper, repository: IRawRepository): ICompilePatternsResult { + let r: RuleId[] = []; + + if (patterns) { + for (let i = 0, len = patterns.length; i < len; i++) { + const pattern = patterns[i]; + let ruleId: RuleId | -1 = -1; + + if (pattern.include) { + + const reference = parseInclude(pattern.include); + + switch (reference.kind) { + case IncludeReferenceKind.Base: + case IncludeReferenceKind.Self: + ruleId = RuleFactory.getCompiledRuleId(repository[pattern.include], helper, repository); + break; + + case IncludeReferenceKind.RelativeReference: + // Local include found in `repository` + let localIncludedRule = repository[reference.ruleName]; + if (localIncludedRule) { + ruleId = RuleFactory.getCompiledRuleId(localIncludedRule, helper, repository); + } else { + // console.warn('CANNOT find rule for scopeName: ' + pattern.include + ', I am: ', repository['$base'].name); + } + break; + + case IncludeReferenceKind.TopLevelReference: + case IncludeReferenceKind.TopLevelRepositoryReference: + + const externalGrammarName = reference.scopeName; + const externalGrammarInclude = + reference.kind === IncludeReferenceKind.TopLevelRepositoryReference + ? reference.ruleName + : null; + + // External include + const externalGrammar = helper.getExternalGrammar(externalGrammarName, repository); + + if (externalGrammar) { + if (externalGrammarInclude) { + let externalIncludedRule = externalGrammar.repository[externalGrammarInclude]; + if (externalIncludedRule) { + ruleId = RuleFactory.getCompiledRuleId(externalIncludedRule, helper, externalGrammar.repository); + } else { + // console.warn('CANNOT find rule for scopeName: ' + pattern.include + ', I am: ', repository['$base'].name); + } + } else { + ruleId = RuleFactory.getCompiledRuleId(externalGrammar.repository.$self, helper, externalGrammar.repository); + } + } else { + // console.warn('CANNOT find grammar for scopeName: ' + pattern.include + ', I am: ', repository['$base'].name); + } + break; + } + } else { + ruleId = RuleFactory.getCompiledRuleId(pattern, helper, repository); + } + + if (ruleId !== -1) { + const rule = helper.getRule(ruleId); + + let skipRule = false; + + if (rule instanceof IncludeOnlyRule || rule instanceof BeginEndRule || rule instanceof BeginWhileRule) { + if (rule.hasMissingPatterns && rule.patterns.length === 0) { + skipRule = true; + } + } + + if (skipRule) { + // console.log('REMOVING RULE ENTIRELY DUE TO EMPTY PATTERNS THAT ARE MISSING'); + continue; + } + + r.push(ruleId); + } + } + } + + return { + patterns: r, + hasMissingPatterns: ((patterns ? patterns.length : 0) !== r.length) + }; + } +} + +interface IRegExpSourceAnchorCache { + readonly A0_G0: string; + readonly A0_G1: string; + readonly A1_G0: string; + readonly A1_G1: string; +} + +export class RegExpSource { + + public source: string; + public readonly ruleId: TRuleId; + public hasAnchor: boolean; + public readonly hasBackReferences: boolean; + private _anchorCache: IRegExpSourceAnchorCache | null; + + constructor(regExpSource: string, ruleId: TRuleId) { + if (regExpSource) { + const len = regExpSource.length; + let lastPushedPos = 0; + let output: string[] = []; + + let hasAnchor = false; + for (let pos = 0; pos < len; pos++) { + const ch = regExpSource.charAt(pos); + + if (ch === '\\') { + if (pos + 1 < len) { + const nextCh = regExpSource.charAt(pos + 1); + if (nextCh === 'z') { + output.push(regExpSource.substring(lastPushedPos, pos)); + output.push('$(?!\\n)(? ' + this.source + ', ' + this.hasAnchor); + } + + public clone(): RegExpSource { + return new RegExpSource(this.source, this.ruleId); + } + + public setSource(newSource: string): void { + if (this.source === newSource) { + return; + } + this.source = newSource; + + if (this.hasAnchor) { + this._anchorCache = this._buildAnchorCache(); + } + } + + public resolveBackReferences(lineText: string, captureIndices: IOnigCaptureIndex[]): string { + let capturedValues = captureIndices.map((capture) => { + return lineText.substring(capture.start, capture.end); + }); + BACK_REFERENCING_END.lastIndex = 0; + return this.source.replace(BACK_REFERENCING_END, (match, g1) => { + return escapeRegExpCharacters(capturedValues[parseInt(g1, 10)] || ''); + }); + } + + private _buildAnchorCache(): IRegExpSourceAnchorCache { + let A0_G0_result: string[] = []; + let A0_G1_result: string[] = []; + let A1_G0_result: string[] = []; + let A1_G1_result: string[] = []; + + let pos: number, + len: number, + ch: string, + nextCh: string; + + for (pos = 0, len = this.source.length; pos < len; pos++) { + ch = this.source.charAt(pos); + A0_G0_result[pos] = ch; + A0_G1_result[pos] = ch; + A1_G0_result[pos] = ch; + A1_G1_result[pos] = ch; + + if (ch === '\\') { + if (pos + 1 < len) { + nextCh = this.source.charAt(pos + 1); + if (nextCh === 'A') { + A0_G0_result[pos + 1] = '\uFFFF'; + A0_G1_result[pos + 1] = '\uFFFF'; + A1_G0_result[pos + 1] = 'A'; + A1_G1_result[pos + 1] = 'A'; + } else if (nextCh === 'G') { + A0_G0_result[pos + 1] = '\uFFFF'; + A0_G1_result[pos + 1] = 'G'; + A1_G0_result[pos + 1] = '\uFFFF'; + A1_G1_result[pos + 1] = 'G'; + } else { + A0_G0_result[pos + 1] = nextCh; + A0_G1_result[pos + 1] = nextCh; + A1_G0_result[pos + 1] = nextCh; + A1_G1_result[pos + 1] = nextCh; + } + pos++; + } + } + } + + return { + A0_G0: A0_G0_result.join(''), + A0_G1: A0_G1_result.join(''), + A1_G0: A1_G0_result.join(''), + A1_G1: A1_G1_result.join('') + }; + } + + public resolveAnchors(allowA: boolean, allowG: boolean): string { + if (!this.hasAnchor || !this._anchorCache) { + return this.source; + } + + if (allowA) { + if (allowG) { + return this._anchorCache.A1_G1; + } else { + return this._anchorCache.A1_G0; + } + } else { + if (allowG) { + return this._anchorCache.A0_G1; + } else { + return this._anchorCache.A0_G0; + } + } + } +} + +interface IRegExpSourceListAnchorCache { + A0_G0: CompiledRule | null; + A0_G1: CompiledRule | null; + A1_G0: CompiledRule | null; + A1_G1: CompiledRule | null; +} + +export class RegExpSourceList { + + private readonly _items: RegExpSource[]; + private _hasAnchors: boolean; + private _cached: CompiledRule | null; + private _anchorCache: IRegExpSourceListAnchorCache; + + constructor() { + this._items = []; + this._hasAnchors = false; + this._cached = null; + this._anchorCache = { + A0_G0: null, + A0_G1: null, + A1_G0: null, + A1_G1: null + }; + } + + public dispose(): void { + this._disposeCaches(); + } + + private _disposeCaches(): void { + if (this._cached) { + this._cached.dispose(); + this._cached = null; + } + if (this._anchorCache.A0_G0) { + this._anchorCache.A0_G0.dispose(); + this._anchorCache.A0_G0 = null; + } + if (this._anchorCache.A0_G1) { + this._anchorCache.A0_G1.dispose(); + this._anchorCache.A0_G1 = null; + } + if (this._anchorCache.A1_G0) { + this._anchorCache.A1_G0.dispose(); + this._anchorCache.A1_G0 = null; + } + if (this._anchorCache.A1_G1) { + this._anchorCache.A1_G1.dispose(); + this._anchorCache.A1_G1 = null; + } + } + + public push(item: RegExpSource): void { + this._items.push(item); + this._hasAnchors = this._hasAnchors || item.hasAnchor; + } + + public unshift(item: RegExpSource): void { + this._items.unshift(item); + this._hasAnchors = this._hasAnchors || item.hasAnchor; + } + + public length(): number { + return this._items.length; + } + + public setSource(index: number, newSource: string): void { + if (this._items[index].source !== newSource) { + // bust the cache + this._disposeCaches(); + this._items[index].setSource(newSource); + } + } + + public compile(onigLib: IOnigLib): CompiledRule { + if (!this._cached) { + let regExps = this._items.map(e => e.source); + this._cached = new CompiledRule(onigLib, regExps, this._items.map(e => e.ruleId)); + } + return this._cached; + } + + public compileAG(onigLib: IOnigLib, allowA: boolean, allowG: boolean): CompiledRule { + if (!this._hasAnchors) { + return this.compile(onigLib); + } else { + if (allowA) { + if (allowG) { + if (!this._anchorCache.A1_G1) { + this._anchorCache.A1_G1 = this._resolveAnchors(onigLib, allowA, allowG); + } + return this._anchorCache.A1_G1; + } else { + if (!this._anchorCache.A1_G0) { + this._anchorCache.A1_G0 = this._resolveAnchors(onigLib, allowA, allowG); + } + return this._anchorCache.A1_G0; + } + } else { + if (allowG) { + if (!this._anchorCache.A0_G1) { + this._anchorCache.A0_G1 = this._resolveAnchors(onigLib, allowA, allowG); + } + return this._anchorCache.A0_G1; + } else { + if (!this._anchorCache.A0_G0) { + this._anchorCache.A0_G0 = this._resolveAnchors(onigLib, allowA, allowG); + } + return this._anchorCache.A0_G0; + } + } + } + } + + private _resolveAnchors(onigLib: IOnigLib, allowA: boolean, allowG: boolean): CompiledRule { + let regExps = this._items.map(e => e.resolveAnchors(allowA, allowG)); + return new CompiledRule(onigLib, regExps, this._items.map(e => e.ruleId)); + } +} + +export class CompiledRule { + private readonly scanner: OnigScanner; + + constructor(onigLib: IOnigLib, private readonly regExps: string[], private readonly rules: TRuleId[]) { + this.scanner = onigLib.createOnigScanner(regExps); + } + + public dispose(): void { + if (typeof this.scanner.dispose === "function") { + this.scanner.dispose(); + } + } + + toString(): string { + const r: string[] = []; + for (let i = 0, len = this.rules.length; i < len; i++) { + r.push(" - " + this.rules[i] + ": " + this.regExps[i]); + } + return r.join("\n"); + } + + findNextMatchSync( + string: string | OnigString, + startPosition: number, + options: OrMask + ): IFindNextMatchResult | null { + const result = this.scanner.findNextMatchSync(string, startPosition, options); + if (!result) { + return null; + } + + return { + ruleId: this.rules[result.index], + captureIndices: result.captureIndices, + }; + } +} + +export interface IFindNextMatchResult { + ruleId: TRuleId; + captureIndices: IOnigCaptureIndex[]; +} diff --git a/src/textmate/theme.ts b/src/textmate/theme.ts new file mode 100644 index 0000000..54f8356 --- /dev/null +++ b/src/textmate/theme.ts @@ -0,0 +1,605 @@ +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ + +import { CachedFn, isValidHexColor, OrMask, strArrCmp, strcmp } from './utils'; + +export class Theme { + public static createFromRawTheme( + source: IRawTheme | undefined, + colorMap?: string[] + ): Theme { + return this.createFromParsedTheme(parseTheme(source), colorMap); + } + + public static createFromParsedTheme( + source: ParsedThemeRule[], + colorMap?: string[] + ): Theme { + return resolveParsedThemeRules(source, colorMap); + } + + private readonly _cachedMatchRoot = new CachedFn( + (scopeName) => this._root.match(scopeName) + ); + + constructor( + private readonly _colorMap: ColorMap, + private readonly _defaults: StyleAttributes, + private readonly _root: ThemeTrieElement + ) {} + + public getColorMap(): string[] { + return this._colorMap.getColorMap(); + } + + public getDefaults(): StyleAttributes { + return this._defaults; + } + + public match(scopePath: ScopeStack | null): StyleAttributes | null { + if (scopePath === null) { + return this._defaults; + } + const scopeName = scopePath.scopeName; + const matchingTrieElements = this._cachedMatchRoot.get(scopeName); + + const effectiveRule = matchingTrieElements.find((v) => + _scopePathMatchesParentScopes(scopePath.parent, v.parentScopes) + ); + if (!effectiveRule) { + return null; + } + + return new StyleAttributes( + effectiveRule.fontStyle, + effectiveRule.foreground, + effectiveRule.background + ); + } +} + +/** + * Identifiers with a binary dot operator. + * Examples: `baz` or `foo.bar` +*/ +export type ScopeName = string; + +/** + * An expression language of ScopeNames with a binary space (to indicate nesting) operator. + * Examples: `foo.bar boo.baz` +*/ +export type ScopePath = string; + +/** + * An expression language of ScopePathStr with a binary comma (to indicate alternatives) operator. + * Examples: `foo.bar boo.baz,quick quack` +*/ +export type ScopePattern = string; + +/** + * A TextMate theme. + */ + export interface IRawTheme { + readonly name?: string; + readonly settings: IRawThemeSetting[]; +} + +/** + * A single theme setting. + */ + export interface IRawThemeSetting { + readonly name?: string; + readonly scope?: ScopePattern | ScopePattern[]; + readonly settings: { + readonly fontStyle?: string; + readonly foreground?: string; + readonly background?: string; + }; +} + +export class ScopeStack { + static push(path: ScopeStack | null, scopeNames: ScopeName[]): ScopeStack | null { + for (const name of scopeNames) { + path = new ScopeStack(path, name); + } + return path; + } + + public static from(first: ScopeName, ...segments: ScopeName[]): ScopeStack; + public static from(...segments: ScopeName[]): ScopeStack | null; + public static from(...segments: ScopeName[]): ScopeStack | null { + let result: ScopeStack | null = null; + for (let i = 0; i < segments.length; i++) { + result = new ScopeStack(result, segments[i]); + } + return result; + } + + constructor( + public readonly parent: ScopeStack | null, + public readonly scopeName: ScopeName + ) {} + + public push(scopeName: ScopeName): ScopeStack { + return new ScopeStack(this, scopeName); + } + + public getSegments(): ScopeName[] { + let item: ScopeStack | null = this; + const result: ScopeName[] = []; + while (item) { + result.push(item.scopeName); + item = item.parent; + } + result.reverse(); + return result; + } + + public toString() { + return this.getSegments().join(' '); + } + + public extends(other: ScopeStack): boolean { + if (this === other) { + return true; + } + if (this.parent === null) { + return false; + } + return this.parent.extends(other); + } + + public getExtensionIfDefined(base: ScopeStack | null): string[] | undefined { + const result: string[] = []; + let item: ScopeStack | null = this; + while (item && item !== base) { + result.push(item.scopeName); + item = item.parent; + } + return item === base ? result.reverse() : undefined; + } +} + +function _scopePathMatchesParentScopes(scopePath: ScopeStack | null, parentScopes: ScopeName[] | null): boolean { + if (parentScopes === null) { + return true; + } + + let index = 0; + let scopePattern = parentScopes[index]; + + while (scopePath) { + if (_matchesScope(scopePath.scopeName, scopePattern)) { + index++; + if (index === parentScopes.length) { + return true; + } + scopePattern = parentScopes[index]; + } + scopePath = scopePath.parent; + } + + return false; +} + +function _matchesScope(scopeName: ScopeName, scopePattern: ScopeName): boolean { + return scopePattern === scopeName || (scopeName.startsWith(scopePattern) && scopeName[scopePattern.length] === '.'); +} + +export class StyleAttributes { + constructor( + public readonly fontStyle: OrMask, + public readonly foregroundId: number, + public readonly backgroundId: number + ) {} +} + +/** + * Parse a raw theme into rules. + */ +export function parseTheme(source: IRawTheme | undefined): ParsedThemeRule[] { + if (!source) { + return []; + } + if (!source.settings || !Array.isArray(source.settings)) { + return []; + } + let settings = source.settings; + let result: ParsedThemeRule[] = [], resultLen = 0; + for (let i = 0, len = settings.length; i < len; i++) { + let entry = settings[i]; + + if (!entry.settings) { + continue; + } + + let scopes: string[]; + if (typeof entry.scope === 'string') { + let _scope = entry.scope; + + // remove leading commas + _scope = _scope.replace(/^[,]+/, ''); + + // remove trailing commans + _scope = _scope.replace(/[,]+$/, ''); + + scopes = _scope.split(','); + } else if (Array.isArray(entry.scope)) { + scopes = entry.scope; + } else { + scopes = ['']; + } + + let fontStyle: OrMask = FontStyle.NotSet; + if (typeof entry.settings.fontStyle === 'string') { + fontStyle = FontStyle.None; + + let segments = entry.settings.fontStyle.split(' '); + for (let j = 0, lenJ = segments.length; j < lenJ; j++) { + let segment = segments[j]; + switch (segment) { + case 'italic': + fontStyle = fontStyle | FontStyle.Italic; + break; + case 'bold': + fontStyle = fontStyle | FontStyle.Bold; + break; + case 'underline': + fontStyle = fontStyle | FontStyle.Underline; + break; + case 'strikethrough': + fontStyle = fontStyle | FontStyle.Strikethrough; + break; + } + } + } + + let foreground: string | null = null; + if (typeof entry.settings.foreground === 'string' && isValidHexColor(entry.settings.foreground)) { + foreground = entry.settings.foreground; + } + + let background: string | null = null; + if (typeof entry.settings.background === 'string' && isValidHexColor(entry.settings.background)) { + background = entry.settings.background; + } + + for (let j = 0, lenJ = scopes.length; j < lenJ; j++) { + let _scope = scopes[j].trim(); + + let segments = _scope.split(' '); + + let scope = segments[segments.length - 1]; + let parentScopes: string[] | null = null; + if (segments.length > 1) { + parentScopes = segments.slice(0, segments.length - 1); + parentScopes.reverse(); + } + + result[resultLen++] = new ParsedThemeRule( + scope, + parentScopes, + i, + fontStyle, + foreground, + background + ); + } + } + + return result; +} + +export class ParsedThemeRule { + constructor( + public readonly scope: ScopeName, + public readonly parentScopes: ScopeName[] | null, + public readonly index: number, + public readonly fontStyle: OrMask, + public readonly foreground: string | null, + public readonly background: string | null, + ) { + } +} + +export const enum FontStyle { + NotSet = -1, + None = 0, + Italic = 1, + Bold = 2, + Underline = 4, + Strikethrough = 8 +} + +export function fontStyleToString(fontStyle: OrMask) { + if (fontStyle === FontStyle.NotSet) { + return 'not set'; + } + + let style = ''; + if (fontStyle & FontStyle.Italic) { + style += 'italic '; + } + if (fontStyle & FontStyle.Bold) { + style += 'bold '; + } + if (fontStyle & FontStyle.Underline) { + style += 'underline '; + } + if (fontStyle & FontStyle.Strikethrough) { + style += 'strikethrough '; + } + if (style === '') { + style = 'none'; + } + return style.trim(); +} + +/** + * Resolve rules (i.e. inheritance). + */ +function resolveParsedThemeRules(parsedThemeRules: ParsedThemeRule[], _colorMap: string[] | undefined): Theme { + + // Sort rules lexicographically, and then by index if necessary + parsedThemeRules.sort((a, b) => { + let r = strcmp(a.scope, b.scope); + if (r !== 0) { + return r; + } + r = strArrCmp(a.parentScopes, b.parentScopes); + if (r !== 0) { + return r; + } + return a.index - b.index; + }); + + // Determine defaults + let defaultFontStyle = FontStyle.None; + let defaultForeground = '#000000'; + let defaultBackground = '#ffffff'; + while (parsedThemeRules.length >= 1 && parsedThemeRules[0].scope === '') { + let incomingDefaults = parsedThemeRules.shift()!; + if (incomingDefaults.fontStyle !== FontStyle.NotSet) { + defaultFontStyle = incomingDefaults.fontStyle; + } + if (incomingDefaults.foreground !== null) { + defaultForeground = incomingDefaults.foreground; + } + if (incomingDefaults.background !== null) { + defaultBackground = incomingDefaults.background; + } + } + let colorMap = new ColorMap(_colorMap); + let defaults = new StyleAttributes(defaultFontStyle, colorMap.getId(defaultForeground), colorMap.getId(defaultBackground)); + + let root = new ThemeTrieElement(new ThemeTrieElementRule(0, null, FontStyle.NotSet, 0, 0), []); + for (let i = 0, len = parsedThemeRules.length; i < len; i++) { + let rule = parsedThemeRules[i]; + root.insert(0, rule.scope, rule.parentScopes, rule.fontStyle, colorMap.getId(rule.foreground), colorMap.getId(rule.background)); + } + + return new Theme(colorMap, defaults, root); +} + +export class ColorMap { + private readonly _isFrozen: boolean; + private _lastColorId: number; + private _id2color: string[]; + private _color2id: { [color: string]: number; }; + + constructor(_colorMap?: string[]) { + this._lastColorId = 0; + this._id2color = []; + this._color2id = Object.create(null); + + if (Array.isArray(_colorMap)) { + this._isFrozen = true; + for (let i = 0, len = _colorMap.length; i < len; i++) { + this._color2id[_colorMap[i]] = i; + this._id2color[i] = _colorMap[i]; + } + } else { + this._isFrozen = false; + } + } + + public getId(color: string | null): number { + if (color === null) { + return 0; + } + color = color.toUpperCase(); + let value = this._color2id[color]; + if (value) { + return value; + } + if (this._isFrozen) { + throw new Error(`Missing color in color map - ${color}`); + } + value = ++this._lastColorId; + this._color2id[color] = value; + this._id2color[value] = color; + return value; + } + + public getColorMap(): string[] { + return this._id2color.slice(0); + } +} + +export class ThemeTrieElementRule { + + scopeDepth: number; + parentScopes: ScopeName[] | null; + fontStyle: number; + foreground: number; + background: number; + + constructor(scopeDepth: number, parentScopes: ScopeName[] | null, fontStyle: number, foreground: number, background: number) { + this.scopeDepth = scopeDepth; + this.parentScopes = parentScopes; + this.fontStyle = fontStyle; + this.foreground = foreground; + this.background = background; + } + + public clone(): ThemeTrieElementRule { + return new ThemeTrieElementRule(this.scopeDepth, this.parentScopes, this.fontStyle, this.foreground, this.background); + } + + public static cloneArr(arr:ThemeTrieElementRule[]): ThemeTrieElementRule[] { + let r: ThemeTrieElementRule[] = []; + for (let i = 0, len = arr.length; i < len; i++) { + r[i] = arr[i].clone(); + } + return r; + } + + public acceptOverwrite(scopeDepth: number, fontStyle: number, foreground: number, background: number): void { + if (this.scopeDepth > scopeDepth) { + console.log('how did this happen?'); + } else { + this.scopeDepth = scopeDepth; + } + // console.log('TODO -> my depth: ' + this.scopeDepth + ', overwriting depth: ' + scopeDepth); + if (fontStyle !== FontStyle.NotSet) { + this.fontStyle = fontStyle; + } + if (foreground !== 0) { + this.foreground = foreground; + } + if (background !== 0) { + this.background = background; + } + } +} + +export interface ITrieChildrenMap { + [segment: string]: ThemeTrieElement; +} + +export class ThemeTrieElement { + private readonly _rulesWithParentScopes: ThemeTrieElementRule[]; + + constructor( + private readonly _mainRule: ThemeTrieElementRule, + rulesWithParentScopes: ThemeTrieElementRule[] = [], + private readonly _children: ITrieChildrenMap = {} + ) { + this._rulesWithParentScopes = rulesWithParentScopes; + } + + private static _sortBySpecificity(arr: ThemeTrieElementRule[]): ThemeTrieElementRule[] { + if (arr.length === 1) { + return arr; + } + arr.sort(this._cmpBySpecificity); + return arr; + } + + private static _cmpBySpecificity(a: ThemeTrieElementRule, b: ThemeTrieElementRule): number { + if (a.scopeDepth === b.scopeDepth) { + const aParentScopes = a.parentScopes; + const bParentScopes = b.parentScopes; + let aParentScopesLen = aParentScopes === null ? 0 : aParentScopes.length; + let bParentScopesLen = bParentScopes === null ? 0 : bParentScopes.length; + if (aParentScopesLen === bParentScopesLen) { + for (let i = 0; i < aParentScopesLen; i++) { + const aLen = aParentScopes![i].length; + const bLen = bParentScopes![i].length; + if (aLen !== bLen) { + return bLen - aLen; + } + } + } + return bParentScopesLen - aParentScopesLen; + } + return b.scopeDepth - a.scopeDepth; + } + + public match(scope: ScopeName): ThemeTrieElementRule[] { + if (scope === '') { + return ThemeTrieElement._sortBySpecificity(([]).concat(this._mainRule).concat(this._rulesWithParentScopes)); + } + + let dotIndex = scope.indexOf('.'); + let head: string; + let tail: string; + if (dotIndex === -1) { + head = scope; + tail = ''; + } else { + head = scope.substring(0, dotIndex); + tail = scope.substring(dotIndex + 1); + } + + if (this._children.hasOwnProperty(head)) { + return this._children[head].match(tail); + } + + return ThemeTrieElement._sortBySpecificity(([]).concat(this._mainRule).concat(this._rulesWithParentScopes)); + } + + public insert(scopeDepth: number, scope: ScopeName, parentScopes: ScopeName[] | null, fontStyle: number, foreground: number, background: number): void { + if (scope === '') { + this._doInsertHere(scopeDepth, parentScopes, fontStyle, foreground, background); + return; + } + + let dotIndex = scope.indexOf('.'); + let head: string; + let tail: string; + if (dotIndex === -1) { + head = scope; + tail = ''; + } else { + head = scope.substring(0, dotIndex); + tail = scope.substring(dotIndex + 1); + } + + let child: ThemeTrieElement; + if (this._children.hasOwnProperty(head)) { + child = this._children[head]; + } else { + child = new ThemeTrieElement(this._mainRule.clone(), ThemeTrieElementRule.cloneArr(this._rulesWithParentScopes)); + this._children[head] = child; + } + + child.insert(scopeDepth + 1, tail, parentScopes, fontStyle, foreground, background); + } + + private _doInsertHere(scopeDepth: number, parentScopes: ScopeName[] | null, fontStyle: number, foreground: number, background: number): void { + + if (parentScopes === null) { + // Merge into the main rule + this._mainRule.acceptOverwrite(scopeDepth, fontStyle, foreground, background); + return; + } + + // Try to merge into existing rule + for (let i = 0, len = this._rulesWithParentScopes.length; i < len; i++) { + let rule = this._rulesWithParentScopes[i]; + + if (strArrCmp(rule.parentScopes, parentScopes) === 0) { + // bingo! => we get to merge this into an existing one + rule.acceptOverwrite(scopeDepth, fontStyle, foreground, background); + return; + } + } + + // Must add a new rule + + // Inherit from main rule + if (fontStyle === FontStyle.NotSet) { + fontStyle = this._mainRule.fontStyle; + } + if (foreground === 0) { + foreground = this._mainRule.foreground; + } + if (background === 0) { + background = this._mainRule.background; + } + + this._rulesWithParentScopes.push(new ThemeTrieElementRule(scopeDepth, parentScopes, fontStyle, foreground, background)); + } +} diff --git a/src/textmate/utils.ts b/src/textmate/utils.ts new file mode 100644 index 0000000..46ae13b --- /dev/null +++ b/src/textmate/utils.ts @@ -0,0 +1,187 @@ +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ + +import { IOnigCaptureIndex } from './onigLib'; + +export function clone(something: T): T { + return doClone(something); +} + +function doClone(something: any): any { + if (Array.isArray(something)) { + return cloneArray(something); + } + if (typeof something === 'object') { + return cloneObj(something); + } + return something; +} + +function cloneArray(arr: any[]): any[] { + let r: any[] = []; + for (let i = 0, len = arr.length; i < len; i++) { + r[i] = doClone(arr[i]); + } + return r; +} + +function cloneObj(obj: any): any { + let r: any = {}; + for (let key in obj) { + r[key] = doClone(obj[key]); + } + return r; +} + +export function mergeObjects(target: any, ...sources: any[]): any { + sources.forEach(source => { + for (let key in source) { + target[key] = source[key]; + } + }); + return target; +} + +export function basename(path: string): string { + const idx = ~path.lastIndexOf('/') || ~path.lastIndexOf('\\'); + if (idx === 0) { + return path; + } else if (~idx === path.length - 1) { + return basename(path.substring(0, path.length - 1)); + } else { + return path.substr(~idx + 1); + } +} + +let CAPTURING_REGEX_SOURCE = /\$(\d+)|\${(\d+):\/(downcase|upcase)}/g; + +export class RegexSource { + + public static hasCaptures(regexSource: string | null): boolean { + if (regexSource === null) { + return false; + } + CAPTURING_REGEX_SOURCE.lastIndex = 0; + return CAPTURING_REGEX_SOURCE.test(regexSource); + } + + public static replaceCaptures(regexSource: string, captureSource: string, captureIndices: IOnigCaptureIndex[]): string { + return regexSource.replace(CAPTURING_REGEX_SOURCE, (match: string, index: string, commandIndex: string, command: string) => { + let capture = captureIndices[parseInt(index || commandIndex, 10)]; + if (capture) { + let result = captureSource.substring(capture.start, capture.end); + // Remove leading dots that would make the selector invalid + while (result[0] === '.') { + result = result.substring(1); + } + switch (command) { + case 'downcase': + return result.toLowerCase(); + case 'upcase': + return result.toUpperCase(); + default: + return result; + } + } else { + return match; + } + }); + } +} + +/** + * A union of given const enum values. +*/ +export type OrMask = number; + +export function strcmp(a: string, b: string): number { + if (a < b) { + return -1; + } + if (a > b) { + return 1; + } + return 0; +} + +export function strArrCmp(a: string[] | null, b: string[] | null): number { + if (a === null && b === null) { + return 0; + } + if (!a) { + return -1; + } + if (!b) { + return 1; + } + let len1 = a.length; + let len2 = b.length; + if (len1 === len2) { + for (let i = 0; i < len1; i++) { + let res = strcmp(a[i], b[i]); + if (res !== 0) { + return res; + } + } + return 0; + } + return len1 - len2; +} + +export function isValidHexColor(hex: string): boolean { + if (/^#[0-9a-f]{6}$/i.test(hex)) { + // #rrggbb + return true; + } + + if (/^#[0-9a-f]{8}$/i.test(hex)) { + // #rrggbbaa + return true; + } + + if (/^#[0-9a-f]{3}$/i.test(hex)) { + // #rgb + return true; + } + + if (/^#[0-9a-f]{4}$/i.test(hex)) { + // #rgba + return true; + } + + return false; +} + +/** + * Escapes regular expression characters in a given string + */ +export function escapeRegExpCharacters(value: string): string { + return value.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g, '\\$&'); +} + +export class CachedFn { + private readonly cache = new Map(); + constructor(private readonly fn: (key: TKey) => TValue) { + } + + public get(key: TKey): TValue { + if (this.cache.has(key)) { + return this.cache.get(key)!; + } + const value = this.fn(key); + this.cache.set(key, value); + return value; + } +} + +declare let performance: { now: () => number } | undefined; +export const performanceNow = + typeof performance === "undefined" + // performance.now() is not available in this environment, so use Date.now() + ? function () { + return Date.now(); + } + : function () { + return performance!.now(); + }; \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 5a8e94e..a67420d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -18,9 +18,10 @@ "noUnusedParameters": false, /* Report errors on unused parameters. */ }, "include": [ - "src/*.ts", + "src/**/*.ts", ], "exclude": [ "node_modules", + "out", ] } \ No newline at end of file