Socket
Socket
Sign inDemoInstall

shiki-twoslash

Package Overview
Dependencies
Maintainers
2
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shiki-twoslash - npm Package Compare versions

Comparing version 1.2.7 to 1.3.0

3

dist/renderers/plain.d.ts

@@ -5,4 +5,7 @@ export interface HtmlRendererOptions {

bg?: string;
themeName?: string;
}
/** A func for setting a consistent <pre> */
export declare const preOpenerFromRenderingOptsWithExtras: (opts: HtmlRendererOptions, fence?: any, classes?: string[] | undefined) => string;
/** You don't have a language which shiki twoslash can handle, make a DOM compatible version */
export declare function plainTextRenderer(code: string, options: HtmlRendererOptions, codefenceMeta: any): string;

134

dist/shiki-twoslash.cjs.development.js

@@ -8,2 +8,20 @@ 'use strict';

function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
// Based on https://github.com/andrewbranch/gatsby-remark-vscode/blob/7bf5c036a58652c1f45d27c5874557f7b531102c/src/index.js

@@ -244,3 +262,7 @@ // which is MIT https://github.com/andrewbranch/gatsby-remark-vscode/blob/7bf5c036a58652c1f45d27c5874557f7b531102c/LICENSE

function createHighlightedString2(ranges, text) {
function createHighlightedString2(ranges, text, targetedWord) {
if (targetedWord === void 0) {
targetedWord = "";
}
var actions = [];

@@ -254,2 +276,3 @@ var hasErrors = false; // Why the weird chars? We need to make sure that generic syntax isn't

if (r.classes === "lsp") {
var underLineTargetedWord = r.lsp === targetedWord ? "style=⇯border-bottom: solid 2px lightgrey;⇯" : "";
actions.push({

@@ -260,3 +283,3 @@ text: "⇍/data-lsp⇏",

actions.push({
text: "\u21CDdata-lsp lsp=\u21EF" + (r.lsp || "") + "\u21EF\u21CF",
text: "\u21CDdata-lsp lsp=\u21EF" + (r.lsp || "") + "\u21EF " + underLineTargetedWord + "\u21CF",
index: r.begin

@@ -313,2 +336,30 @@ });

/** A func for setting a consistent <pre> */
var preOpenerFromRenderingOptsWithExtras = function preOpenerFromRenderingOptsWithExtras(opts, fence, classes) {
var bg = opts.bg || "#fff";
var fg = opts.fg || "black";
var theme = opts.themeName || "";
var fenceClass = fence && fence["class"] || "";
var extras = classes && classes.join(" ") || "";
return "<pre class=\"shiki " + fenceClass + " " + theme + " " + extras + "\" style=\"background-color: " + bg + "; color: " + fg + "\">";
};
/** You don't have a language which shiki twoslash can handle, make a DOM compatible version */
function plainTextRenderer(code, options, codefenceMeta) {
var html = "";
html += preOpenerFromRenderingOptsWithExtras(options, codefenceMeta, []);
if (options.langId) {
html += "<div class=\"language-id\">" + options.langId + "</div>";
}
html += "<div class='code-container'><code>";
html += escapeHtml(code);
html = html.replace(/\n*$/, ""); // Get rid of final new lines
html += "</code></div></pre>";
return html;
}
// What we're trying to do is merge two sets of information into a single tree for HTML

@@ -323,3 +374,3 @@ // 1: Syntax highlight info from shiki

// - Twoslash results can be multi-file
// - the DOM requires a flattened graph of html elements
// - the DOM requires a flattened graph of html elements (e.g. spans can' be interspersed)
//

@@ -331,6 +382,3 @@

var hl = shouldHighlightLine(codefenceMeta);
var bg = options.bg || "#fff";
var fg = options.fg || "black";
var classes = codefenceMeta["class"] || "";
html += "<pre class=\"shiki twoslash lsp " + classes + "\" style=\"background-color: " + bg + "; color: " + fg + "\">";
html += preOpenerFromRenderingOptsWithExtras(options, codefenceMeta, ["twoslash", "lsp"]);

@@ -377,2 +425,3 @@ if (options.langId) {

l.forEach(function (token) {
var targetedQueryWord;
var tokenContent = ""; // Underlining particular words

@@ -388,3 +437,7 @@

var lspResponsesInToken = lspValues.filter(findTokenFunc(tokenPos));
var queriesInToken = queries.filter(findTokenFunc(tokenPos));
var queriesInToken = queries.filter(findTokenFunc(tokenPos)); // Does this line have a word targeted by a query?
targetedQueryWord || (targetedQueryWord = lspResponsesInToken.find(function (response) {
return response.text === (queries.length && queries[0].text);
}));
var allTokens = [].concat(errorsInToken, lspResponsesInToken, queriesInToken);

@@ -396,2 +449,4 @@ var allTokensByStart = allTokens.sort(function (l, r) {

if (allTokensByStart.length) {
var _targetedQueryWord;
var ranges = allTokensByStart.map(function (token) {

@@ -413,3 +468,3 @@ var range = {

});
tokenContent += createHighlightedString2(ranges, token.content);
tokenContent += createHighlightedString2(ranges, token.content, (_targetedQueryWord = targetedQueryWord) == null ? void 0 : _targetedQueryWord.text);
} else {

@@ -446,13 +501,12 @@ tokenContent += subTripleArrow(token.content);

{
var _, _$exec, _query$text;
var queryTextWithPrefix = escapeHtml(query.text);
var previousLine = ((_ = (lines[i - 1] || [])[0]) == null ? void 0 : _.content) || "";
var previousLineWhitespace = previousLine.slice(0, ((_$exec = /\S/.exec(previousLine)) == null ? void 0 : _$exec.index) || 0); // prettier-ignore
var _lspValues = staticQuickInfosGroupedByLine.get(i) || [];
var linePrefix = previousLineWhitespace + "//" + "".padStart(query.offset - 2 - previousLineWhitespace.length); // prettier-ignore
var targetedWord = _lspValues.find(function (response) {
return response.text === (queries.length && queries[0].text);
});
var queryTextWithPrefix = (_query$text = query.text) == null ? void 0 : _query$text.split("\n").map(function (l, i) {
return i !== 0 ? linePrefix + l : l;
}).join("\n");
html += "<span class='query'>" + (linePrefix + "^ = " + queryTextWithPrefix) + "</span>";
var halfWayAcrossTheTargetedWord = (targetedWord && targetedWord.character + (targetedWord == null ? void 0 : targetedWord.length) / 2) - 1 || 0;
html += "<span class='popover-prefix'>" + " ".repeat(halfWayAcrossTheTargetedWord) + "</span>" + ("<span class='popover'><div class='arrow'></div>" + queryTextWithPrefix + "</span>");
break;

@@ -511,29 +565,5 @@ }

/** You don't have a language which shiki twoslash can handle, make a DOM compatible version */
function plainTextRenderer(code, options, codefenceMeta) {
var html = "";
var bg = options.bg || "#fff";
var fg = options.fg || "black";
var classes = codefenceMeta && codefenceMeta["class"] || "";
html += "<pre class=\"shiki " + classes + "\" style=\"background-color: " + bg + "; color: " + fg + "\">";
if (options.langId) {
html += "<div class=\"language-id\">" + options.langId + "</div>";
}
html += "<div class='code-container'><code>";
html += escapeHtml(code);
html = html.replace(/\n*$/, ""); // Get rid of final new lines
html += "</code></div></pre>";
return html;
}
function defaultShikiRenderer(lines, options, codefenceMeta) {
var html = "";
var bg = options.bg || "#fff";
var fg = options.fg || "black";
var classes = codefenceMeta && codefenceMeta["class"] || "";
html += "<pre class=\"shiki " + classes + "\" style=\"background-color: " + bg + "; color: " + fg + "\">";
html += preOpenerFromRenderingOptsWithExtras(options, codefenceMeta, []);

@@ -574,2 +604,3 @@ if (options.langId) {

checkJs: "Enable error reporting in type-checked JavaScript files.",
clean: "Delete the outputs of all projects.",
composite: "Enable constraints that allow a TypeScript project to be used with project references.",

@@ -580,2 +611,3 @@ declaration: "Generate .d.ts files from TypeScript and JavaScript files in your project.",

diagnostics: "Output compiler performance information after building.",
disableFilenameBasedTypeAcquisition: "Disables inference for type acquisition by looking at filenames in a project.",
disableReferencedProjectLoad: "Reduce the number of projects loaded automatically by TypeScript.",

@@ -589,4 +621,7 @@ disableSizeLimit: "Remove the 20mb cap on total source code size for JavaScript files in the TypeScript language server.",

emitDecoratorMetadata: "Emit design-type metadata for decorated declarations in source files.",
enable: "Disable the type acquisition for JavaScript projects",
esModuleInterop: "Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility.",
exclude: "Filters results from the `include` option.",
excludeDirectories: "Remove a list of directories from the watch process.",
excludeFiles: "Remove a list of files from the watch mode's processing.",
experimentalDecorators: "Enable experimental support for TC39 stage 2 draft decorators.",

@@ -598,2 +633,3 @@ explainFiles: "Print files read during the compilation including why it was included.",

files: "Include a list of files. This does not support glob patterns, as opposed to `include`.",
force: "Build all projects, including those that appear to be up to date",
forceConsistentCasingInFileNames: "Ensure that casing is correct in imports.",

@@ -628,2 +664,3 @@ generateCpuProfile: "Emit a v8 CPU profile of the compiler run for debugging.",

noImplicitAny: "Enable error reporting for expressions and declarations with an implied `any` type..",
noImplicitOverride: "Ensure overriding members in derived classes are marked with an override modifier.",
noImplicitReturns: "Enable error reporting for codepaths that do not explicitly return in a function.",

@@ -666,2 +703,3 @@ noImplicitThis: "Enable error reporting when `this` is given the type `any`.",

suppressImplicitAnyIndexErrors: "Suppress `noImplicitAny` errors when indexing objects that lack index signatures.",
synchronousWatchDirectory: "Synchronously call callbacks and update the state of directory watchers on platforms that don`t support recursive watching natively.",
target: "Set the JavaScript language version for emitted JavaScript and include compatible library declarations.",

@@ -674,2 +712,3 @@ traceResolution: "Log paths used during the `moduleResolution` process.",

useDefineForClassFields: "Emit ECMAScript-standard-compliant class fields.",
verbose: "Enable verbose logging",
watchDirectory: "Specify how directories are watched on systems that lack recursive file-watching functionality.",

@@ -706,6 +745,3 @@ watchFile: "Specify how the TypeScript watch mode works."

var html = "";
var bg = options.bg || "#fff";
var fg = options.fg || "black";
var classes = codefenceMeta["class"] || "";
html += "<pre class=\"shiki tsconfig lsp " + classes + "\" style=\"background-color: " + bg + "; color: " + fg + "\">";
html += preOpenerFromRenderingOptsWithExtras(options, codefenceMeta, ["tsconfig", "lsp"]);

@@ -728,3 +764,3 @@ if (options.langId) {

html += "<span style=\"color: " + token.color + "\">\"<a aria-hidden=true href='https://www.typescriptlang.org/tsconfig#" + key + "'><data-lsp lsp=\"" + oneliner + "\">" + escapeHtml(key) + "</data-lsp></a>\"</span>";
html += "<span style=\"color: " + token.color + "\">\"<a aria-hidden=true tabindex=\"-1\" href='https://www.typescriptlang.org/tsconfig#" + key + "'><data-lsp lsp=\"" + oneliner + "\">" + escapeHtml(key) + "</data-lsp></a>\"</span>";
} else {

@@ -808,5 +844,5 @@ html += "<span style=\"color: " + token.color + "\">" + escapeHtml(token.content) + "</span>";

return defaultShikiRenderer(tokens, {
return defaultShikiRenderer(tokens, _extends({}, shikiOptions, {
langId: lang
}, codefenceMeta.meta);
}), codefenceMeta.meta);
};

@@ -813,0 +849,0 @@ /**

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("shiki"),t=require("@typescript/twoslash"),n=/[a-z0-9-–—_+#]/i,r=/\s/,i=/[0-9-.]/,o=/[0-9-.e]/;function a(e,t){return void 0!==e&&t.test(e)}function s(e,t){var s=t.replace("twoslash",""),c=0,l={},p="",d=[e,s].filter(Boolean).join(" ");b(),h()||"{"===f()||(p=y());var u=c;return b(),h()||"{"!==f()||(l=S()),h()||u!==c?{languageName:p,meta:l}:g("Invalid character in language name: '"+f()+"'");function f(){return h()?g("Unexpected end of input"):d[c]}function h(){return c>=d.length}function g(e){throw new Error("Failed parsing code fence header '"+d+"' at position "+c+": "+e)}function m(e){if(h()||f()!==e)return g("Expected '"+e+"'");c++}function y(e){void 0===e&&(e="Expected identifier, but got nothing");for(var t="";!h()&&a(f(),n);)t+=f(),c++;return t||g(e)}function b(){for(;!h()&&a(f(),r);)c++}function v(){switch(f()){case"{":return S();case"'":case'"':return function(){var e,t="",n=f();for(c++;;){var r=(e=void 0,"\\"===(e=f())&&(c++,e+=f()),c++,e);if(r===n)break;t+=r.replace(/\\/,"")}return t}()}return a(f(),i)?function(){var e=f();for(c++;!h()&&a(f(),o);)e+=f(),c++;return parseFloat(e)}():function(){var e=y("Expected expression, but got nothing");switch(e){case"true":return!0;case"false":return!1;case"":return g("Expected expression, but got nothing");default:return g("Unrecognized input '"+e+"'")}}()}function S(){var e={};for(m("{"),b();!h()&&"}"!==f();){var t=y(),n=!0;b(),":"===f()&&(c++,b(),n=v(),b()),e[t]=n,","===f()&&c++,b()}return m("}"),e}}var c=function(e){return!!Object.keys(e).find((function(e){return!!e.includes("-")||NaN!==parseInt(e)}))},l=function(e){var t=[];return Object.keys(e).find((function(e){if(NaN!==parseInt(e)&&t.push(parseInt(e)),e.includes("-"))for(var n=e.split("-"),r=n[0],i=parseInt(n[1])+1,o=parseInt(r);o<i;o++)t.push(o)})),function(e){return t.includes(e)}},p=function(e,t,n,r){return e.slice(0,t)+r+e.slice(t+Math.abs(n))},d=function(e){return e.replace(/</g,"⇍").replace(/>/g,"⇏").replace(/'/g,"⇯")},u=function(e){return e.replace(/⇍/g,"<").replace(/⇏/g,">").replace(/⇯/g,"'")},f=function(e){return e.replace(/⇍/g,"&lt;").replace(/⇏/g,"&gt;").replace(/⇯/g,"&apos;")};function h(e){var t={"<":"lt",'"':"quot","'":"apos","&":"amp","\r":"#10","\n":"#13"};return e.toString().replace(/[<"'\r\n&]/g,(function(e){return"&"+t[e]+";"}))}function g(e){return e.replace(/</g,"&lt;").replace(/>/g,"&gt;")}function m(e,t,n,r){var i="",o=c(r),a=l(r);i+='<pre class="shiki twoslash lsp '+(r.class||"")+'" style="background-color: '+(t.bg||"#fff")+"; color: "+(t.fg||"black")+'">',t.langId&&(i+='<div class="language-id">'+t.langId+"</div>"),i+="<div class='code-container'><code>";var s=y(n.errors,(function(e){return e.line}))||new Map,m=y(n.staticQuickInfos,(function(e){return e.line}))||new Map,b=y(n.queries,(function(e){return e.line-1}))||new Map,v=0;return e.forEach((function(t,n){var r=s.get(n)||[],c=m.get(n)||[],l=b.get(n)||[];if(0===t.length&&0===n)v+=1;else if(0===t.length)v+=1,i+="\n";else{var f=o?a(n)?" highlight":" dim":"";i+="<div class='line"+f+"'>";var y=0;t.forEach((function(e){var t="",n=function(t){return function(n){return t<=n.character&&t+e.content.length>=n.character+n.length}},o=r.filter(n(y)),a=c.filter(n(y)),s=l.filter(n(y)),f=[].concat(o,a,s).sort((function(e,t){return(e.start||0)-(t.start||0)}));t+=f.length?function(e,t){var n=[],r=!1;e.forEach((function(e){"lsp"===e.classes?(n.push({text:"⇍/data-lsp⇏",index:e.end}),n.push({text:"⇍data-lsp lsp=⇯"+(e.lsp||"")+"⇯⇏",index:e.begin})):"err"===e.classes?r=!0:"query"===e.classes&&(n.push({text:"⇍/data-highlight⇏",index:e.end}),n.push({text:"⇍data-highlight'⇏",index:e.begin}))}));var i=(" "+t).slice(1);return n.sort((function(e,t){return t.index-e.index})).forEach((function(e){i=p(i,e.index,0,e.text)})),r&&(i="⇍data-err⇏"+i+"⇍/data-err⇏"),u(h(i))}(f.map((function(e){var t={begin:e.start-v,end:e.start+e.length-v};return"renderedMessage"in e&&(t.classes="err"),"kind"in e&&(t.classes=e.kind),"targetString"in e&&(t.classes="lsp",t.lsp=h(e.text)),t})),e.content):d(e.content),i+='<span style="color: '+e.color+'">'+t+"</span>",y+=e.content.length,v+=e.content.length})),i+="</div>",v+=1}if(r.length){var S=r.map((function(e){return g(e.renderedMessage)})).join("</br>"),w=r.map((function(e){return e.code})).join("<br/>");i+='<span class="error"><span>'+S+'</span><span class="code">'+w+"</span></span>",i+='<span class="error-behind">'+S+"</span>"}l.length&&(l.forEach((function(t){switch(t.kind){case"query":var r,o,a,s=(null==(r=(e[n-1]||[])[0])?void 0:r.content)||"",c=s.slice(0,(null==(o=/\S/.exec(s))?void 0:o.index)||0),l=c+"//"+"".padStart(t.offset-2-c.length),p=null==(a=t.text)?void 0:a.split("\n").map((function(e,t){return 0!==t?l+e:e})).join("\n");i+="<span class='query'>"+l+"^ = "+p+"</span>";break;case"completions":if(t.completions){var d=t.completions.filter((function(e){return e.name.startsWith(t.completionsPrefix||"____")})).sort((function(e,t){return e.name.localeCompare(t.name)})).map((function(e){var n,r,i=e.name.substr((null==(n=t.completionsPrefix)?void 0:n.length)||0),o="<span><span class='result-found'>"+(t.completionsPrefix||"")+"</span>"+i+"<span>";return"<li class='"+((null==(r=e.kindModifiers)?void 0:r.split(",").includes("deprecated"))?"deprecated":"")+"'>"+o+"</li>"})).join("");i+="".padStart(t.offset)+"<span class='inline-completions'><ul class='dropdown'>"+d+"</ul></span>"}else i+="<span class='query'>//"+"".padStart(t.offset-2)+"^ - No completions found</span>"}})),i+="\n")})),i=f(i.replace(/\n*$/,"")),i+="</code><a href='"+n.playgroundURL+"'>Try</a></div></pre>"}function y(e,t){var n=new Map;return e.forEach((function(e){var r=t(e),i=n.get(r);i?i.push(e):n.set(r,[e])})),n}function b(e,t,n){var r="";return r+='<pre class="shiki '+(n&&n.class||"")+'" style="background-color: '+(t.bg||"#fff")+"; color: "+(t.fg||"black")+'">',t.langId&&(r+='<div class="language-id">'+t.langId+"</div>"),r+="<div class='code-container'><code>",(r=(r+=g(e)).replace(/\n*$/,""))+"</code></div></pre>"}function v(e,t,n){var r="";return r+='<pre class="shiki '+(n&&n.class||"")+'" style="background-color: '+(t.bg||"#fff")+"; color: "+(t.fg||"black")+'">',t.langId&&(r+='<div class="language-id">'+t.langId+"</div>"),r+="<div class='code-container'><code>",e.forEach((function(e){0===e.length?r+="<div class='line'></div>":(r+="<div class='line'>",e.forEach((function(e){r+='<span style="color: '+e.color+'">'+g(e.content)+"</span>"})),r+="</div>")})),r=r.replace(/\n*$/,""),r+="</code></div></pre>"}var S={compilerOptions:"The set of compiler options for your project",allowJs:"Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files.",allowSyntheticDefaultImports:"Allow 'import x from y' when a module doesn't have a default export.",allowUmdGlobalAccess:"Allow accessing UMD globals from modules.",allowUnreachableCode:"Disable error reporting for unreachable code.",allowUnusedLabels:"Disable error reporting for unused labels.",alwaysStrict:"Ensure 'use strict' is always emitted.",assumeChangesOnlyAffectDirectDependencies:"Have recompiles in projects that use `incremental` and `watch` mode assume that changes within a file will only affect files directly depending on it.",baseUrl:"Specify the base directory to resolve non-relative module names.",charset:"No longer supported. In early versions, manually set the text encoding for reading files.",checkJs:"Enable error reporting in type-checked JavaScript files.",composite:"Enable constraints that allow a TypeScript project to be used with project references.",declaration:"Generate .d.ts files from TypeScript and JavaScript files in your project.",declarationDir:"Specify the output directory for generated declaration files.",declarationMap:"Create sourcemaps for d.ts files.",diagnostics:"Output compiler performance information after building.",disableReferencedProjectLoad:"Reduce the number of projects loaded automatically by TypeScript.",disableSizeLimit:"Remove the 20mb cap on total source code size for JavaScript files in the TypeScript language server.",disableSolutionSearching:"Opt a project out of multi-project reference checking when editing.",disableSourceOfProjectReferenceRedirect:"Disable preferring source files instead of declaration files when referencing composite projects",downlevelIteration:"Emit more compliant, but verbose and less performant JavaScript for iteration.",emitBOM:"Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files.",emitDeclarationOnly:"Only output d.ts files and not JavaScript files.",emitDecoratorMetadata:"Emit design-type metadata for decorated declarations in source files.",esModuleInterop:"Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility.",exclude:"Filters results from the `include` option.",experimentalDecorators:"Enable experimental support for TC39 stage 2 draft decorators.",explainFiles:"Print files read during the compilation including why it was included.",extendedDiagnostics:"Output more detailed compiler performance information after building.",extends:"Specify one or more path or node module references to base configuration files from which settings are inherited.",fallbackPolling:"Specify what approach the watcher should use if the system runs out of native file watchers.",files:"Include a list of files. This does not support glob patterns, as opposed to `include`.",forceConsistentCasingInFileNames:"Ensure that casing is correct in imports.",generateCpuProfile:"Emit a v8 CPU profile of the compiler run for debugging.",importHelpers:"Allow importing helper functions from tslib once per project, instead of including them per-file.",importsNotUsedAsValues:"Specify emit/checking behavior for imports that are only used for types.",include:"Specify a list of glob patterns that match files to be included in compilation.",incremental:"Save .tsbuildinfo files to allow for incremental compilation of projects.",inlineSourceMap:"Include sourcemap files inside the emitted JavaScript.",inlineSources:"Include source code in the sourcemaps inside the emitted JavaScript.",isolatedModules:"Ensure that each file can be safely transpiled without relying on other imports.",jsx:"Specify what JSX code is generated.",jsxFactory:"Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'",jsxFragmentFactory:"Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'.",jsxImportSource:"Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.`",keyofStringsOnly:"Make keyof only return strings instead of string, numbers or symbols. Legacy option.",lib:"Specify a set of bundled library declaration files that describe the target runtime environment.",listEmittedFiles:"Print the names of emitted files after a compilation.",listFiles:"Print all of the files read during the compilation.",locale:"Set the language of the messaging from TypeScript. This does not affect emit.",mapRoot:"Specify the location where debugger should locate map files instead of generated locations.",maxNodeModuleJsDepth:"Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`.",module:"Specify what module code is generated.",moduleResolution:"Specify how TypeScript looks up a file from a given module specifier.",newLine:"Set the newline character for emitting files.",noEmit:"Disable emitting file from a compilation.",noEmitHelpers:"Disable generating custom helper functions like `__extends` in compiled output.",noEmitOnError:"Disable emitting files if any type checking errors are reported.",noErrorTruncation:"Disable truncating types in error messages.",noFallthroughCasesInSwitch:"Enable error reporting for fallthrough cases in switch statements.",noImplicitAny:"Enable error reporting for expressions and declarations with an implied `any` type..",noImplicitReturns:"Enable error reporting for codepaths that do not explicitly return in a function.",noImplicitThis:"Enable error reporting when `this` is given the type `any`.",noImplicitUseStrict:"Disable adding 'use strict' directives in emitted JavaScript files.",noLib:"Disable including any library files, including the default lib.d.ts.",noPropertyAccessFromIndexSignature:"Enforces using indexed accessors for keys declared using an indexed type",noResolve:"Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project.",noStrictGenericChecks:"Disable strict checking of generic signatures in function types.",noUncheckedIndexedAccess:"Add `undefined` to a type when accessed using an index.",noUnusedLocals:"Enable error reporting when a local variables aren't read.",noUnusedParameters:"Raise an error when a function parameter isn't read",out:"Deprecated setting. Use `outFile` instead.",outDir:"Specify an output folder for all emitted files.",outFile:"Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output.",paths:"Specify a set of entries that re-map imports to additional lookup locations.",plugins:"Specify a list of language service plugins to include.",preserveConstEnums:"Disable erasing `const enum` declarations in generated code.",preserveSymlinks:"Disable resolving symlinks to their realpath. This correlates to the same flag in node.",preserveWatchOutput:"Disable wiping the console in watch mode",pretty:"Enable color and formatting in output to make compiler errors easier to read",reactNamespace:"Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit.",references:"Specify an array of objects that specify paths for projects. Used in project references.",removeComments:"Disable emitting comments.",resolveJsonModule:"Enable importing .json files",rootDir:"Specify the root folder within your source files.",rootDirs:"Allow multiple folders to be treated as one when resolving modules.",skipDefaultLibCheck:"Skip type checking .d.ts files that are included with TypeScript.",skipLibCheck:"Skip type checking all .d.ts files.",sourceMap:"Create source map files for emitted JavaScript files.",sourceRoot:"Specify the root path for debuggers to find the reference source code.",strict:"Enable all strict type checking options.",strictBindCallApply:"Check that the arguments for `bind`, `call`, and `apply` methods match the original function.",strictFunctionTypes:"When assigning functions, check to ensure parameters and the return values are subtype-compatible.",strictNullChecks:"When type checking, take into account `null` and `undefined`.",strictPropertyInitialization:"Check for class properties that are declared but not set in the constructor.",stripInternal:"Disable emitting declarations that have `@internal` in their JSDoc comments.",suppressExcessPropertyErrors:"Disable reporting of excess property errors during the creation of object literals.",suppressImplicitAnyIndexErrors:"Suppress `noImplicitAny` errors when indexing objects that lack index signatures.",target:"Set the JavaScript language version for emitted JavaScript and include compatible library declarations.",traceResolution:"Log paths used during the `moduleResolution` process.",tsBuildInfoFile:"Specify the folder for .tsbuildinfo incremental compilation files.",typeAcquisition:"Specify options for automatic acquisition of declaration files.",typeRoots:"Specify multiple folders that act like `./node_modules/@types`.",types:"Specify type package names to be included without being referenced in a source file.",useDefineForClassFields:"Emit ECMAScript-standard-compliant class fields.",watchDirectory:"Specify how directories are watched on systems that lack recursive file-watching functionality.",watchFile:"Specify how the TypeScript watch mode works."},w=function(e){return!!e.explanation&&e.explanation.find((function(e){return e.scopes.find((function(e){return e.scopeName.includes("support.type.property-name")}))}))},k=function(e){if('"'!==e.content)return e.content.slice(1,e.content.length-1)in S};function x(e,t,n){var r="";return r+='<pre class="shiki tsconfig lsp '+(n.class||"")+'" style="background-color: '+(t.bg||"#fff")+"; color: "+(t.fg||"black")+'">',t.langId&&(r+='<div class="language-id">'+t.langId+"</div>"),r+="<div class='code-container'><code>",e.forEach((function(e){0===e.length?r+="<div class='line'></div>":(r+="<div class='line'>",e.forEach((function(e){if(w(e)&&k(e)){var t=e.content.slice(1,e.content.length-1);r+='<span style="color: '+e.color+'">"<a aria-hidden=true href=\'https://www.typescriptlang.org/tsconfig#'+t+"'><data-lsp lsp=\""+S[t]+'">'+g(t)+'</data-lsp></a>"</span>'}else r+='<span style="color: '+e.color+'">'+g(e.content)+"</span>"})),r+="</div>")})),r=r.replace(/\n*$/,""),r+="</code></div></pre>"}var E=null,I={plainTextRenderer:b,defaultShikiRenderer:v,twoslashRenderer:m,tsconfigJSONRenderer:x};exports.createShikiHighlighter=function(t){return E?Promise.resolve(E):e.getHighlighter(t).then((function(e){return E=e}))},exports.parseCodeFenceInfo=s,exports.renderCodeToHTML=function(e,t,n,r,i,o){if(!i&&!E)throw new Error("The highlighter object hasn't been initialised via `setupHighLighter` yet in render-shiki-twoslash");var a,c=i||E,l=s(t,(n&&"string"==typeof n?n:n.join(" "))||"");try{a=c.codeToThemedTokens(e,t)}catch(t){return b(e,r||{},l.meta)}return n.includes("twoslash")&&o?m(a,r||{},o,l.meta):t&&t.startsWith("json")&&n.includes("tsconfig")?x(a,r||{},l.meta):v(a,{langId:t},l.meta)},exports.renderers=I,exports.runTwoSlash=function(e,n,r){void 0===r&&(r={});var i={json5:"json",yml:"yaml"};return i[n]&&(n=i[n]),t.twoslasher(e,n,r)};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("shiki"),t=require("@typescript/twoslash");function n(){return(n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var r=/[a-z0-9-–—_+#]/i,i=/\s/,o=/[0-9-.]/,a=/[0-9-.e]/;function s(e,t){return void 0!==e&&t.test(e)}function c(e,t){var n=t.replace("twoslash",""),c=0,l={},p="",d=[e,n].filter(Boolean).join(" ");v(),h()||"{"===f()||(p=y());var u=c;return v(),h()||"{"!==f()||(l=S()),h()||u!==c?{languageName:p,meta:l}:g("Invalid character in language name: '"+f()+"'");function f(){return h()?g("Unexpected end of input"):d[c]}function h(){return c>=d.length}function g(e){throw new Error("Failed parsing code fence header '"+d+"' at position "+c+": "+e)}function m(e){if(h()||f()!==e)return g("Expected '"+e+"'");c++}function y(e){void 0===e&&(e="Expected identifier, but got nothing");for(var t="";!h()&&s(f(),r);)t+=f(),c++;return t||g(e)}function v(){for(;!h()&&s(f(),i);)c++}function b(){switch(f()){case"{":return S();case"'":case'"':return function(){var e,t="",n=f();for(c++;;){var r=(e=void 0,"\\"===(e=f())&&(c++,e+=f()),c++,e);if(r===n)break;t+=r.replace(/\\/,"")}return t}()}return s(f(),o)?function(){var e=f();for(c++;!h()&&s(f(),a);)e+=f(),c++;return parseFloat(e)}():function(){var e=y("Expected expression, but got nothing");switch(e){case"true":return!0;case"false":return!1;case"":return g("Expected expression, but got nothing");default:return g("Unrecognized input '"+e+"'")}}()}function S(){var e={};for(m("{"),v();!h()&&"}"!==f();){var t=y(),n=!0;v(),":"===f()&&(c++,v(),n=b(),v()),e[t]=n,","===f()&&c++,v()}return m("}"),e}}var l=function(e){return!!Object.keys(e).find((function(e){return!!e.includes("-")||NaN!==parseInt(e)}))},p=function(e){var t=[];return Object.keys(e).find((function(e){if(NaN!==parseInt(e)&&t.push(parseInt(e)),e.includes("-"))for(var n=e.split("-"),r=n[0],i=parseInt(n[1])+1,o=parseInt(r);o<i;o++)t.push(o)})),function(e){return t.includes(e)}},d=function(e,t,n,r){return e.slice(0,t)+r+e.slice(t+Math.abs(n))},u=function(e){return e.replace(/</g,"⇍").replace(/>/g,"⇏").replace(/'/g,"⇯")},f=function(e){return e.replace(/⇍/g,"<").replace(/⇏/g,">").replace(/⇯/g,"'")},h=function(e){return e.replace(/⇍/g,"&lt;").replace(/⇏/g,"&gt;").replace(/⇯/g,"&apos;")};function g(e){var t={"<":"lt",'"':"quot","'":"apos","&":"amp","\r":"#10","\n":"#13"};return e.toString().replace(/[<"'\r\n&]/g,(function(e){return"&"+t[e]+";"}))}function m(e){return e.replace(/</g,"&lt;").replace(/>/g,"&gt;")}var y=function(e,t,n){var r=e.bg||"#fff",i=e.fg||"black";return'<pre class="shiki '+(t&&t.class||"")+" "+(e.themeName||"")+" "+(n&&n.join(" ")||"")+'" style="background-color: '+r+"; color: "+i+'">'};function v(e,t,n){var r="";return r+=y(t,n,[]),t.langId&&(r+='<div class="language-id">'+t.langId+"</div>"),r+="<div class='code-container'><code>",(r=(r+=m(e)).replace(/\n*$/,""))+"</code></div></pre>"}function b(e,t,n,r){var i="",o=l(r),a=p(r);i+=y(t,r,["twoslash","lsp"]),t.langId&&(i+='<div class="language-id">'+t.langId+"</div>"),i+="<div class='code-container'><code>";var s=S(n.errors,(function(e){return e.line}))||new Map,c=S(n.staticQuickInfos,(function(e){return e.line}))||new Map,v=S(n.queries,(function(e){return e.line-1}))||new Map,b=0;return e.forEach((function(e,t){var n=s.get(t)||[],r=c.get(t)||[],l=v.get(t)||[];if(0===e.length&&0===t)b+=1;else if(0===e.length)b+=1,i+="\n";else{var p=o?a(t)?" highlight":" dim":"";i+="<div class='line"+p+"'>";var h=0;e.forEach((function(e){var t,o="",a=function(t){return function(n){return t<=n.character&&t+e.content.length>=n.character+n.length}},s=n.filter(a(h)),c=r.filter(a(h)),p=l.filter(a(h));t||(t=c.find((function(e){return e.text===(l.length&&l[0].text)})));var m,y=[].concat(s,c,p).sort((function(e,t){return(e.start||0)-(t.start||0)}));o+=y.length?function(e,t,n){void 0===n&&(n="");var r=[],i=!1;e.forEach((function(e){if("lsp"===e.classes){var t=e.lsp===n?"style=⇯border-bottom: solid 2px lightgrey;⇯":"";r.push({text:"⇍/data-lsp⇏",index:e.end}),r.push({text:"⇍data-lsp lsp=⇯"+(e.lsp||"")+"⇯ "+t+"⇏",index:e.begin})}else"err"===e.classes?i=!0:"query"===e.classes&&(r.push({text:"⇍/data-highlight⇏",index:e.end}),r.push({text:"⇍data-highlight'⇏",index:e.begin}))}));var o=(" "+t).slice(1);return r.sort((function(e,t){return t.index-e.index})).forEach((function(e){o=d(o,e.index,0,e.text)})),i&&(o="⇍data-err⇏"+o+"⇍/data-err⇏"),f(g(o))}(y.map((function(e){var t={begin:e.start-b,end:e.start+e.length-b};return"renderedMessage"in e&&(t.classes="err"),"kind"in e&&(t.classes=e.kind),"targetString"in e&&(t.classes="lsp",t.lsp=g(e.text)),t})),e.content,null==(m=t)?void 0:m.text):u(e.content),i+='<span style="color: '+e.color+'">'+o+"</span>",h+=e.content.length,b+=e.content.length})),i+="</div>",b+=1}if(n.length){var y=n.map((function(e){return m(e.renderedMessage)})).join("</br>"),S=n.map((function(e){return e.code})).join("<br/>");i+='<span class="error"><span>'+y+'</span><span class="code">'+S+"</span></span>",i+='<span class="error-behind">'+y+"</span>"}l.length&&(l.forEach((function(e){switch(e.kind){case"query":var n=m(e.text),r=(c.get(t)||[]).find((function(e){return e.text===(l.length&&l[0].text)}));i+="<span class='popover-prefix'>"+" ".repeat((r&&r.character+(null==r?void 0:r.length)/2)-1||0)+"</span><span class='popover'><div class='arrow'></div>"+n+"</span>";break;case"completions":if(e.completions){var o=e.completions.filter((function(t){return t.name.startsWith(e.completionsPrefix||"____")})).sort((function(e,t){return e.name.localeCompare(t.name)})).map((function(t){var n,r,i=t.name.substr((null==(n=e.completionsPrefix)?void 0:n.length)||0),o="<span><span class='result-found'>"+(e.completionsPrefix||"")+"</span>"+i+"<span>";return"<li class='"+((null==(r=t.kindModifiers)?void 0:r.split(",").includes("deprecated"))?"deprecated":"")+"'>"+o+"</li>"})).join("");i+="".padStart(e.offset)+"<span class='inline-completions'><ul class='dropdown'>"+o+"</ul></span>"}else i+="<span class='query'>//"+"".padStart(e.offset-2)+"^ - No completions found</span>"}})),i+="\n")})),i=h(i.replace(/\n*$/,"")),i+="</code><a href='"+n.playgroundURL+"'>Try</a></div></pre>"}function S(e,t){var n=new Map;return e.forEach((function(e){var r=t(e),i=n.get(r);i?i.push(e):n.set(r,[e])})),n}function w(e,t,n){var r="";return r+=y(t,n,[]),t.langId&&(r+='<div class="language-id">'+t.langId+"</div>"),r+="<div class='code-container'><code>",e.forEach((function(e){0===e.length?r+="<div class='line'></div>":(r+="<div class='line'>",e.forEach((function(e){r+='<span style="color: '+e.color+'">'+m(e.content)+"</span>"})),r+="</div>")})),r=r.replace(/\n*$/,""),r+="</code></div></pre>"}var x={compilerOptions:"The set of compiler options for your project",allowJs:"Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files.",allowSyntheticDefaultImports:"Allow 'import x from y' when a module doesn't have a default export.",allowUmdGlobalAccess:"Allow accessing UMD globals from modules.",allowUnreachableCode:"Disable error reporting for unreachable code.",allowUnusedLabels:"Disable error reporting for unused labels.",alwaysStrict:"Ensure 'use strict' is always emitted.",assumeChangesOnlyAffectDirectDependencies:"Have recompiles in projects that use `incremental` and `watch` mode assume that changes within a file will only affect files directly depending on it.",baseUrl:"Specify the base directory to resolve non-relative module names.",charset:"No longer supported. In early versions, manually set the text encoding for reading files.",checkJs:"Enable error reporting in type-checked JavaScript files.",clean:"Delete the outputs of all projects.",composite:"Enable constraints that allow a TypeScript project to be used with project references.",declaration:"Generate .d.ts files from TypeScript and JavaScript files in your project.",declarationDir:"Specify the output directory for generated declaration files.",declarationMap:"Create sourcemaps for d.ts files.",diagnostics:"Output compiler performance information after building.",disableFilenameBasedTypeAcquisition:"Disables inference for type acquisition by looking at filenames in a project.",disableReferencedProjectLoad:"Reduce the number of projects loaded automatically by TypeScript.",disableSizeLimit:"Remove the 20mb cap on total source code size for JavaScript files in the TypeScript language server.",disableSolutionSearching:"Opt a project out of multi-project reference checking when editing.",disableSourceOfProjectReferenceRedirect:"Disable preferring source files instead of declaration files when referencing composite projects",downlevelIteration:"Emit more compliant, but verbose and less performant JavaScript for iteration.",emitBOM:"Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files.",emitDeclarationOnly:"Only output d.ts files and not JavaScript files.",emitDecoratorMetadata:"Emit design-type metadata for decorated declarations in source files.",enable:"Disable the type acquisition for JavaScript projects",esModuleInterop:"Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility.",exclude:"Filters results from the `include` option.",excludeDirectories:"Remove a list of directories from the watch process.",excludeFiles:"Remove a list of files from the watch mode's processing.",experimentalDecorators:"Enable experimental support for TC39 stage 2 draft decorators.",explainFiles:"Print files read during the compilation including why it was included.",extendedDiagnostics:"Output more detailed compiler performance information after building.",extends:"Specify one or more path or node module references to base configuration files from which settings are inherited.",fallbackPolling:"Specify what approach the watcher should use if the system runs out of native file watchers.",files:"Include a list of files. This does not support glob patterns, as opposed to `include`.",force:"Build all projects, including those that appear to be up to date",forceConsistentCasingInFileNames:"Ensure that casing is correct in imports.",generateCpuProfile:"Emit a v8 CPU profile of the compiler run for debugging.",importHelpers:"Allow importing helper functions from tslib once per project, instead of including them per-file.",importsNotUsedAsValues:"Specify emit/checking behavior for imports that are only used for types.",include:"Specify a list of glob patterns that match files to be included in compilation.",incremental:"Save .tsbuildinfo files to allow for incremental compilation of projects.",inlineSourceMap:"Include sourcemap files inside the emitted JavaScript.",inlineSources:"Include source code in the sourcemaps inside the emitted JavaScript.",isolatedModules:"Ensure that each file can be safely transpiled without relying on other imports.",jsx:"Specify what JSX code is generated.",jsxFactory:"Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'",jsxFragmentFactory:"Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'.",jsxImportSource:"Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.`",keyofStringsOnly:"Make keyof only return strings instead of string, numbers or symbols. Legacy option.",lib:"Specify a set of bundled library declaration files that describe the target runtime environment.",listEmittedFiles:"Print the names of emitted files after a compilation.",listFiles:"Print all of the files read during the compilation.",locale:"Set the language of the messaging from TypeScript. This does not affect emit.",mapRoot:"Specify the location where debugger should locate map files instead of generated locations.",maxNodeModuleJsDepth:"Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`.",module:"Specify what module code is generated.",moduleResolution:"Specify how TypeScript looks up a file from a given module specifier.",newLine:"Set the newline character for emitting files.",noEmit:"Disable emitting file from a compilation.",noEmitHelpers:"Disable generating custom helper functions like `__extends` in compiled output.",noEmitOnError:"Disable emitting files if any type checking errors are reported.",noErrorTruncation:"Disable truncating types in error messages.",noFallthroughCasesInSwitch:"Enable error reporting for fallthrough cases in switch statements.",noImplicitAny:"Enable error reporting for expressions and declarations with an implied `any` type..",noImplicitOverride:"Ensure overriding members in derived classes are marked with an override modifier.",noImplicitReturns:"Enable error reporting for codepaths that do not explicitly return in a function.",noImplicitThis:"Enable error reporting when `this` is given the type `any`.",noImplicitUseStrict:"Disable adding 'use strict' directives in emitted JavaScript files.",noLib:"Disable including any library files, including the default lib.d.ts.",noPropertyAccessFromIndexSignature:"Enforces using indexed accessors for keys declared using an indexed type",noResolve:"Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project.",noStrictGenericChecks:"Disable strict checking of generic signatures in function types.",noUncheckedIndexedAccess:"Add `undefined` to a type when accessed using an index.",noUnusedLocals:"Enable error reporting when a local variables aren't read.",noUnusedParameters:"Raise an error when a function parameter isn't read",out:"Deprecated setting. Use `outFile` instead.",outDir:"Specify an output folder for all emitted files.",outFile:"Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output.",paths:"Specify a set of entries that re-map imports to additional lookup locations.",plugins:"Specify a list of language service plugins to include.",preserveConstEnums:"Disable erasing `const enum` declarations in generated code.",preserveSymlinks:"Disable resolving symlinks to their realpath. This correlates to the same flag in node.",preserveWatchOutput:"Disable wiping the console in watch mode",pretty:"Enable color and formatting in output to make compiler errors easier to read",reactNamespace:"Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit.",references:"Specify an array of objects that specify paths for projects. Used in project references.",removeComments:"Disable emitting comments.",resolveJsonModule:"Enable importing .json files",rootDir:"Specify the root folder within your source files.",rootDirs:"Allow multiple folders to be treated as one when resolving modules.",skipDefaultLibCheck:"Skip type checking .d.ts files that are included with TypeScript.",skipLibCheck:"Skip type checking all .d.ts files.",sourceMap:"Create source map files for emitted JavaScript files.",sourceRoot:"Specify the root path for debuggers to find the reference source code.",strict:"Enable all strict type checking options.",strictBindCallApply:"Check that the arguments for `bind`, `call`, and `apply` methods match the original function.",strictFunctionTypes:"When assigning functions, check to ensure parameters and the return values are subtype-compatible.",strictNullChecks:"When type checking, take into account `null` and `undefined`.",strictPropertyInitialization:"Check for class properties that are declared but not set in the constructor.",stripInternal:"Disable emitting declarations that have `@internal` in their JSDoc comments.",suppressExcessPropertyErrors:"Disable reporting of excess property errors during the creation of object literals.",suppressImplicitAnyIndexErrors:"Suppress `noImplicitAny` errors when indexing objects that lack index signatures.",synchronousWatchDirectory:"Synchronously call callbacks and update the state of directory watchers on platforms that don`t support recursive watching natively.",target:"Set the JavaScript language version for emitted JavaScript and include compatible library declarations.",traceResolution:"Log paths used during the `moduleResolution` process.",tsBuildInfoFile:"Specify the folder for .tsbuildinfo incremental compilation files.",typeAcquisition:"Specify options for automatic acquisition of declaration files.",typeRoots:"Specify multiple folders that act like `./node_modules/@types`.",types:"Specify type package names to be included without being referenced in a source file.",useDefineForClassFields:"Emit ECMAScript-standard-compliant class fields.",verbose:"Enable verbose logging",watchDirectory:"Specify how directories are watched on systems that lack recursive file-watching functionality.",watchFile:"Specify how the TypeScript watch mode works."},k=function(e){return!!e.explanation&&e.explanation.find((function(e){return e.scopes.find((function(e){return e.scopeName.includes("support.type.property-name")}))}))},E=function(e){if('"'!==e.content)return e.content.slice(1,e.content.length-1)in x};function j(e,t,n){var r="";return r+=y(t,n,["tsconfig","lsp"]),t.langId&&(r+='<div class="language-id">'+t.langId+"</div>"),r+="<div class='code-container'><code>",e.forEach((function(e){0===e.length?r+="<div class='line'></div>":(r+="<div class='line'>",e.forEach((function(e){if(k(e)&&E(e)){var t=e.content.slice(1,e.content.length-1);r+='<span style="color: '+e.color+'">"<a aria-hidden=true tabindex="-1" href=\'https://www.typescriptlang.org/tsconfig#'+t+"'><data-lsp lsp=\""+x[t]+'">'+m(t)+'</data-lsp></a>"</span>'}else r+='<span style="color: '+e.color+'">'+m(e.content)+"</span>"})),r+="</div>")})),r=r.replace(/\n*$/,""),r+="</code></div></pre>"}var I=null,D={plainTextRenderer:v,defaultShikiRenderer:w,twoslashRenderer:b,tsconfigJSONRenderer:j};exports.createShikiHighlighter=function(t){return I?Promise.resolve(I):e.getHighlighter(t).then((function(e){return I=e}))},exports.parseCodeFenceInfo=c,exports.renderCodeToHTML=function(e,t,r,i,o,a){if(!o&&!I)throw new Error("The highlighter object hasn't been initialised via `setupHighLighter` yet in render-shiki-twoslash");var s,l=o||I,p=c(t,(r&&"string"==typeof r?r:r.join(" "))||"");try{s=l.codeToThemedTokens(e,t)}catch(t){return v(e,i||{},p.meta)}return r.includes("twoslash")&&a?b(s,i||{},a,p.meta):t&&t.startsWith("json")&&r.includes("tsconfig")?j(s,i||{},p.meta):w(s,n({},i,{langId:t}),p.meta)},exports.renderers=D,exports.runTwoSlash=function(e,n,r){void 0===r&&(r={});var i={json5:"json",yml:"yaml"};return i[n]&&(n=i[n]),t.twoslasher(e,n,r)};
//# sourceMappingURL=shiki-twoslash.cjs.production.min.js.map
import { getHighlighter } from 'shiki';
import { twoslasher } from '@typescript/twoslash';
function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
// Based on https://github.com/andrewbranch/gatsby-remark-vscode/blob/7bf5c036a58652c1f45d27c5874557f7b531102c/src/index.js

@@ -239,3 +257,7 @@ // which is MIT https://github.com/andrewbranch/gatsby-remark-vscode/blob/7bf5c036a58652c1f45d27c5874557f7b531102c/LICENSE

function createHighlightedString2(ranges, text) {
function createHighlightedString2(ranges, text, targetedWord) {
if (targetedWord === void 0) {
targetedWord = "";
}
var actions = [];

@@ -249,2 +271,3 @@ var hasErrors = false; // Why the weird chars? We need to make sure that generic syntax isn't

if (r.classes === "lsp") {
var underLineTargetedWord = r.lsp === targetedWord ? "style=⇯border-bottom: solid 2px lightgrey;⇯" : "";
actions.push({

@@ -255,3 +278,3 @@ text: "⇍/data-lsp⇏",

actions.push({
text: "\u21CDdata-lsp lsp=\u21EF" + (r.lsp || "") + "\u21EF\u21CF",
text: "\u21CDdata-lsp lsp=\u21EF" + (r.lsp || "") + "\u21EF " + underLineTargetedWord + "\u21CF",
index: r.begin

@@ -308,2 +331,30 @@ });

/** A func for setting a consistent <pre> */
var preOpenerFromRenderingOptsWithExtras = function preOpenerFromRenderingOptsWithExtras(opts, fence, classes) {
var bg = opts.bg || "#fff";
var fg = opts.fg || "black";
var theme = opts.themeName || "";
var fenceClass = fence && fence["class"] || "";
var extras = classes && classes.join(" ") || "";
return "<pre class=\"shiki " + fenceClass + " " + theme + " " + extras + "\" style=\"background-color: " + bg + "; color: " + fg + "\">";
};
/** You don't have a language which shiki twoslash can handle, make a DOM compatible version */
function plainTextRenderer(code, options, codefenceMeta) {
var html = "";
html += preOpenerFromRenderingOptsWithExtras(options, codefenceMeta, []);
if (options.langId) {
html += "<div class=\"language-id\">" + options.langId + "</div>";
}
html += "<div class='code-container'><code>";
html += escapeHtml(code);
html = html.replace(/\n*$/, ""); // Get rid of final new lines
html += "</code></div></pre>";
return html;
}
// What we're trying to do is merge two sets of information into a single tree for HTML

@@ -318,3 +369,3 @@ // 1: Syntax highlight info from shiki

// - Twoslash results can be multi-file
// - the DOM requires a flattened graph of html elements
// - the DOM requires a flattened graph of html elements (e.g. spans can' be interspersed)
//

@@ -326,6 +377,3 @@

var hl = shouldHighlightLine(codefenceMeta);
var bg = options.bg || "#fff";
var fg = options.fg || "black";
var classes = codefenceMeta["class"] || "";
html += "<pre class=\"shiki twoslash lsp " + classes + "\" style=\"background-color: " + bg + "; color: " + fg + "\">";
html += preOpenerFromRenderingOptsWithExtras(options, codefenceMeta, ["twoslash", "lsp"]);

@@ -372,2 +420,3 @@ if (options.langId) {

l.forEach(function (token) {
var targetedQueryWord;
var tokenContent = ""; // Underlining particular words

@@ -383,3 +432,7 @@

var lspResponsesInToken = lspValues.filter(findTokenFunc(tokenPos));
var queriesInToken = queries.filter(findTokenFunc(tokenPos));
var queriesInToken = queries.filter(findTokenFunc(tokenPos)); // Does this line have a word targeted by a query?
targetedQueryWord || (targetedQueryWord = lspResponsesInToken.find(function (response) {
return response.text === (queries.length && queries[0].text);
}));
var allTokens = [].concat(errorsInToken, lspResponsesInToken, queriesInToken);

@@ -391,2 +444,4 @@ var allTokensByStart = allTokens.sort(function (l, r) {

if (allTokensByStart.length) {
var _targetedQueryWord;
var ranges = allTokensByStart.map(function (token) {

@@ -408,3 +463,3 @@ var range = {

});
tokenContent += createHighlightedString2(ranges, token.content);
tokenContent += createHighlightedString2(ranges, token.content, (_targetedQueryWord = targetedQueryWord) == null ? void 0 : _targetedQueryWord.text);
} else {

@@ -441,13 +496,12 @@ tokenContent += subTripleArrow(token.content);

{
var _, _$exec, _query$text;
var queryTextWithPrefix = escapeHtml(query.text);
var previousLine = ((_ = (lines[i - 1] || [])[0]) == null ? void 0 : _.content) || "";
var previousLineWhitespace = previousLine.slice(0, ((_$exec = /\S/.exec(previousLine)) == null ? void 0 : _$exec.index) || 0); // prettier-ignore
var _lspValues = staticQuickInfosGroupedByLine.get(i) || [];
var linePrefix = previousLineWhitespace + "//" + "".padStart(query.offset - 2 - previousLineWhitespace.length); // prettier-ignore
var targetedWord = _lspValues.find(function (response) {
return response.text === (queries.length && queries[0].text);
});
var queryTextWithPrefix = (_query$text = query.text) == null ? void 0 : _query$text.split("\n").map(function (l, i) {
return i !== 0 ? linePrefix + l : l;
}).join("\n");
html += "<span class='query'>" + (linePrefix + "^ = " + queryTextWithPrefix) + "</span>";
var halfWayAcrossTheTargetedWord = (targetedWord && targetedWord.character + (targetedWord == null ? void 0 : targetedWord.length) / 2) - 1 || 0;
html += "<span class='popover-prefix'>" + " ".repeat(halfWayAcrossTheTargetedWord) + "</span>" + ("<span class='popover'><div class='arrow'></div>" + queryTextWithPrefix + "</span>");
break;

@@ -506,29 +560,5 @@ }

/** You don't have a language which shiki twoslash can handle, make a DOM compatible version */
function plainTextRenderer(code, options, codefenceMeta) {
var html = "";
var bg = options.bg || "#fff";
var fg = options.fg || "black";
var classes = codefenceMeta && codefenceMeta["class"] || "";
html += "<pre class=\"shiki " + classes + "\" style=\"background-color: " + bg + "; color: " + fg + "\">";
if (options.langId) {
html += "<div class=\"language-id\">" + options.langId + "</div>";
}
html += "<div class='code-container'><code>";
html += escapeHtml(code);
html = html.replace(/\n*$/, ""); // Get rid of final new lines
html += "</code></div></pre>";
return html;
}
function defaultShikiRenderer(lines, options, codefenceMeta) {
var html = "";
var bg = options.bg || "#fff";
var fg = options.fg || "black";
var classes = codefenceMeta && codefenceMeta["class"] || "";
html += "<pre class=\"shiki " + classes + "\" style=\"background-color: " + bg + "; color: " + fg + "\">";
html += preOpenerFromRenderingOptsWithExtras(options, codefenceMeta, []);

@@ -569,2 +599,3 @@ if (options.langId) {

checkJs: "Enable error reporting in type-checked JavaScript files.",
clean: "Delete the outputs of all projects.",
composite: "Enable constraints that allow a TypeScript project to be used with project references.",

@@ -575,2 +606,3 @@ declaration: "Generate .d.ts files from TypeScript and JavaScript files in your project.",

diagnostics: "Output compiler performance information after building.",
disableFilenameBasedTypeAcquisition: "Disables inference for type acquisition by looking at filenames in a project.",
disableReferencedProjectLoad: "Reduce the number of projects loaded automatically by TypeScript.",

@@ -584,4 +616,7 @@ disableSizeLimit: "Remove the 20mb cap on total source code size for JavaScript files in the TypeScript language server.",

emitDecoratorMetadata: "Emit design-type metadata for decorated declarations in source files.",
enable: "Disable the type acquisition for JavaScript projects",
esModuleInterop: "Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility.",
exclude: "Filters results from the `include` option.",
excludeDirectories: "Remove a list of directories from the watch process.",
excludeFiles: "Remove a list of files from the watch mode's processing.",
experimentalDecorators: "Enable experimental support for TC39 stage 2 draft decorators.",

@@ -593,2 +628,3 @@ explainFiles: "Print files read during the compilation including why it was included.",

files: "Include a list of files. This does not support glob patterns, as opposed to `include`.",
force: "Build all projects, including those that appear to be up to date",
forceConsistentCasingInFileNames: "Ensure that casing is correct in imports.",

@@ -623,2 +659,3 @@ generateCpuProfile: "Emit a v8 CPU profile of the compiler run for debugging.",

noImplicitAny: "Enable error reporting for expressions and declarations with an implied `any` type..",
noImplicitOverride: "Ensure overriding members in derived classes are marked with an override modifier.",
noImplicitReturns: "Enable error reporting for codepaths that do not explicitly return in a function.",

@@ -661,2 +698,3 @@ noImplicitThis: "Enable error reporting when `this` is given the type `any`.",

suppressImplicitAnyIndexErrors: "Suppress `noImplicitAny` errors when indexing objects that lack index signatures.",
synchronousWatchDirectory: "Synchronously call callbacks and update the state of directory watchers on platforms that don`t support recursive watching natively.",
target: "Set the JavaScript language version for emitted JavaScript and include compatible library declarations.",

@@ -669,2 +707,3 @@ traceResolution: "Log paths used during the `moduleResolution` process.",

useDefineForClassFields: "Emit ECMAScript-standard-compliant class fields.",
verbose: "Enable verbose logging",
watchDirectory: "Specify how directories are watched on systems that lack recursive file-watching functionality.",

@@ -701,6 +740,3 @@ watchFile: "Specify how the TypeScript watch mode works."

var html = "";
var bg = options.bg || "#fff";
var fg = options.fg || "black";
var classes = codefenceMeta["class"] || "";
html += "<pre class=\"shiki tsconfig lsp " + classes + "\" style=\"background-color: " + bg + "; color: " + fg + "\">";
html += preOpenerFromRenderingOptsWithExtras(options, codefenceMeta, ["tsconfig", "lsp"]);

@@ -723,3 +759,3 @@ if (options.langId) {

html += "<span style=\"color: " + token.color + "\">\"<a aria-hidden=true href='https://www.typescriptlang.org/tsconfig#" + key + "'><data-lsp lsp=\"" + oneliner + "\">" + escapeHtml(key) + "</data-lsp></a>\"</span>";
html += "<span style=\"color: " + token.color + "\">\"<a aria-hidden=true tabindex=\"-1\" href='https://www.typescriptlang.org/tsconfig#" + key + "'><data-lsp lsp=\"" + oneliner + "\">" + escapeHtml(key) + "</data-lsp></a>\"</span>";
} else {

@@ -803,5 +839,5 @@ html += "<span style=\"color: " + token.color + "\">" + escapeHtml(token.content) + "</span>";

return defaultShikiRenderer(tokens, {
return defaultShikiRenderer(tokens, _extends({}, shikiOptions, {
langId: lang
}, codefenceMeta.meta);
}), codefenceMeta.meta);
};

@@ -808,0 +844,0 @@ /**

@@ -13,2 +13,3 @@ export declare const tsconfig: {

checkJs: string;
clean: string;
composite: string;

@@ -19,2 +20,3 @@ declaration: string;

diagnostics: string;
disableFilenameBasedTypeAcquisition: string;
disableReferencedProjectLoad: string;

@@ -28,4 +30,7 @@ disableSizeLimit: string;

emitDecoratorMetadata: string;
enable: string;
esModuleInterop: string;
exclude: string;
excludeDirectories: string;
excludeFiles: string;
experimentalDecorators: string;

@@ -37,2 +42,3 @@ explainFiles: string;

files: string;
force: string;
forceConsistentCasingInFileNames: string;

@@ -67,2 +73,3 @@ generateCpuProfile: string;

noImplicitAny: string;
noImplicitOverride: string;
noImplicitReturns: string;

@@ -105,2 +112,3 @@ noImplicitThis: string;

suppressImplicitAnyIndexErrors: string;
synchronousWatchDirectory: string;
target: string;

@@ -113,4 +121,5 @@ traceResolution: string;

useDefineForClassFields: string;
verbose: string;
watchDirectory: string;
watchFile: string;
};

@@ -14,3 +14,3 @@ declare type Range = {

*/
export declare function createHighlightedString2(ranges: Range[], text: string): string;
export declare function createHighlightedString2(ranges: Range[], text: string, targetedWord?: string): string;
export declare const subTripleArrow: (str: string) => string;

@@ -17,0 +17,0 @@ export declare const replaceTripleArrow: (str: string) => string;

{
"name": "shiki-twoslash",
"version": "1.2.7",
"version": "1.3.0",
"license": "MIT",

@@ -8,3 +8,3 @@ "homepage": "https://github.com/microsoft/TypeScript-Website",

"url": "https://github.com/microsoft/TypeScript-Website.git",
"directory": "packages/create-typescript-playground-plugin",
"directory": "packages/shiki-twoslash",
"type": "git"

@@ -34,3 +34,3 @@ },

"@typescript/vfs": "1.3.4",
"shiki": "^0.9.1",
"shiki": "^0.9.3",
"typescript": "*"

@@ -37,0 +37,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc