shiki-twoslash
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -7,2 +7,3 @@ import { Highlighter, HighlighterOptions } from "shiki"; | ||
import { tsconfigJSONRenderer } from "./renderers/tsconfig"; | ||
import { Meta } from "./utils"; | ||
export interface TwoslashShikiOptions { | ||
@@ -44,3 +45,3 @@ /** A way to turn on the try buttons seen on the TS website */ | ||
*/ | ||
export declare const renderCodeToHTML: (code: string, lang: string, info: string[], shikiOptions?: (HighlighterOptions & TwoSlashOptions & TwoslashShikiOptions & { | ||
export declare const renderCodeToHTML: (code: string, lang: string, meta: Meta, shikiOptions?: (HighlighterOptions & TwoSlashOptions & TwoslashShikiOptions & { | ||
themeName: string; | ||
@@ -52,3 +53,2 @@ }) | undefined, highlighter?: Highlighter | undefined, twoslash?: TwoSlashReturn | undefined) => string; | ||
export declare const runTwoSlash: (input: string, lang: string, settings?: UserConfigSettings) => TwoSlashReturn; | ||
export { parseCodeFenceInfo } from "./parseCodeFenceInfo"; | ||
/** Set of renderers if you want to explicitly call one instead of using renderCodeToHTML */ | ||
@@ -55,0 +55,0 @@ export declare const renderers: { |
@@ -0,1 +1,2 @@ | ||
import { Meta } from "../utils"; | ||
export interface HtmlRendererOptions { | ||
@@ -8,4 +9,4 @@ langId?: string; | ||
/** A func for setting a consistent <pre> */ | ||
export declare const preOpenerFromRenderingOptsWithExtras: (opts: HtmlRendererOptions, fence?: any, classes?: string[] | undefined) => string; | ||
export declare const preOpenerFromRenderingOptsWithExtras: (opts: HtmlRendererOptions, meta: Meta, 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; | ||
export declare function plainTextRenderer(code: string, options: HtmlRendererOptions, meta: Meta): string; |
@@ -0,4 +1,5 @@ | ||
import { Meta } from "../utils"; | ||
import { HtmlRendererOptions } from "./plain"; | ||
declare type Lines = import("shiki").IThemedToken[][]; | ||
export declare function defaultShikiRenderer(lines: Lines, options: HtmlRendererOptions, codefenceMeta: any): string; | ||
export declare function defaultShikiRenderer(lines: Lines, options: HtmlRendererOptions, meta: Meta): string; | ||
export {}; |
declare type Lines = import("shiki").IThemedToken[][]; | ||
import { Meta } from "../utils"; | ||
import { HtmlRendererOptions } from "./plain"; | ||
@@ -8,3 +9,3 @@ /** | ||
*/ | ||
export declare function tsconfigJSONRenderer(lines: Lines, options: HtmlRendererOptions, codefenceMeta: any): string; | ||
export declare function tsconfigJSONRenderer(lines: Lines, options: HtmlRendererOptions, meta: Meta): string; | ||
export {}; |
declare type Lines = import("shiki").IThemedToken[][]; | ||
declare type TwoSlash = import("@typescript/twoslash").TwoSlashReturn; | ||
import { TwoslashShikiOptions } from ".."; | ||
import { Meta } from "../utils"; | ||
import { HtmlRendererOptions } from "./plain"; | ||
export declare function twoslashRenderer(lines: Lines, options: HtmlRendererOptions & TwoslashShikiOptions, twoslash: TwoSlash, codefenceMeta: any): string; | ||
export declare function twoslashRenderer(lines: Lines, options: HtmlRendererOptions & TwoslashShikiOptions, twoslash: TwoSlash, meta: Meta): string; | ||
export {}; |
@@ -26,237 +26,2 @@ 'use strict'; | ||
// Based on https://github.com/andrewbranch/gatsby-remark-vscode/blob/7bf5c036a58652c1f45d27c5874557f7b531102c/src/index.js | ||
// which is MIT https://github.com/andrewbranch/gatsby-remark-vscode/blob/7bf5c036a58652c1f45d27c5874557f7b531102c/LICENSE | ||
// Only difference is conversion to TypeScript, and a replace at the top | ||
var identifierPattern = /[a-z0-9-–—_+#]/i; | ||
var triviaPattern = /\s/; | ||
var startOfNumberPattern = /[0-9-.]/; | ||
var numberPattern = /[0-9-.e]/; // Based on https://github.com/facebook/docusaurus/blob/ed9d2a26f5a7b8096804ae1b3a4fffc504f8f90d/packages/docusaurus-theme-common/src/utils/codeBlockUtils.ts | ||
// which is under MIT License as per the banner | ||
var titlePattern = /title=(["'])(.*?)\1/; | ||
function testRegex(input, pattern) { | ||
if (input === undefined) return false; | ||
return pattern.test(input); | ||
} | ||
/** Takes the language and a meta-string and offers a useful object for looking at params */ | ||
function parseCodeFenceInfo(lang, fullMetaString) { | ||
// Heh | ||
var metaString = fullMetaString.replace("twoslash", ""); | ||
var pos = 0; | ||
var meta = {}; | ||
var languageName = ""; | ||
var input = [lang, metaString].filter(Boolean).join(" "); | ||
skipTrivia(); | ||
if (!isEnd() && current() !== "{") { | ||
languageName = parseIdentifier(); | ||
} | ||
var languageNameEnd = pos; | ||
skipTrivia(); | ||
if (!isEnd() && current() === "{") { | ||
meta = parseObject(); | ||
} | ||
if (!isEnd() && languageNameEnd === pos) { | ||
return fail("Invalid character in language name: '" + current() + "'"); | ||
} | ||
if (fullMetaString.match(titlePattern)) { | ||
var _fullMetaString$match, _fullMetaString$match2; | ||
meta.title = (_fullMetaString$match = (_fullMetaString$match2 = fullMetaString.match(titlePattern)) == null ? void 0 : _fullMetaString$match2[2]) != null ? _fullMetaString$match : ""; | ||
} | ||
return { | ||
languageName: languageName, | ||
meta: meta | ||
}; | ||
function current() { | ||
if (isEnd()) { | ||
return fail("Unexpected end of input"); | ||
} | ||
return input[pos]; | ||
} | ||
function isEnd() { | ||
return pos >= input.length; | ||
} | ||
function fail(message) { | ||
throw new Error("Failed parsing code fence header '" + input + "' at position " + pos + ": " + message); | ||
} | ||
function scanExpected(expected) { | ||
if (isEnd() || current() !== expected) { | ||
return fail("Expected '" + expected + "'"); | ||
} | ||
pos++; | ||
} | ||
function parseIdentifier(errorMessage) { | ||
if (errorMessage === void 0) { | ||
errorMessage = "Expected identifier, but got nothing"; | ||
} | ||
var identifier = ""; | ||
while (!isEnd() && testRegex(current(), identifierPattern)) { | ||
identifier += current(); | ||
pos++; | ||
} | ||
if (!identifier) { | ||
return fail(errorMessage); | ||
} | ||
return identifier; | ||
} | ||
function skipTrivia() { | ||
while (!isEnd() && testRegex(current(), triviaPattern)) { | ||
pos++; | ||
} | ||
} | ||
function parseChar() { | ||
var _char = current(); | ||
if (_char === "\\") { | ||
pos++; | ||
_char += current(); | ||
} | ||
pos++; | ||
return _char; | ||
} | ||
function parseString() { | ||
var str = ""; | ||
var quote = current(); | ||
pos++; | ||
while (true) { | ||
var _char2 = parseChar(); | ||
if (_char2 === quote) break; | ||
str += _char2.replace(/\\/, ""); | ||
} | ||
return str; | ||
} | ||
function parseNumber() { | ||
var numStr = current(); | ||
pos++; | ||
while (!isEnd() && testRegex(current(), numberPattern)) { | ||
numStr += current(); | ||
pos++; | ||
} | ||
return parseFloat(numStr); | ||
} | ||
function parseBoolean() { | ||
var identifier = parseIdentifier("Expected expression, but got nothing"); | ||
switch (identifier) { | ||
case "true": | ||
return true; | ||
case "false": | ||
return false; | ||
case "": | ||
return fail("Expected expression, but got nothing"); | ||
default: | ||
return fail("Unrecognized input '" + identifier + "'"); | ||
} | ||
} | ||
function parseExpression() { | ||
switch (current()) { | ||
case "{": | ||
return parseObject(); | ||
case "'": | ||
case '"': | ||
return parseString(); | ||
} | ||
if (testRegex(current(), startOfNumberPattern)) { | ||
return parseNumber(); | ||
} | ||
return parseBoolean(); | ||
} | ||
function parseObject() { | ||
var obj = {}; | ||
scanExpected("{"); | ||
skipTrivia(); | ||
while (!isEnd() && current() !== "}") { | ||
var key = parseIdentifier(); | ||
var value = true; | ||
skipTrivia(); | ||
if (current() === ":") { | ||
pos++; | ||
skipTrivia(); | ||
value = parseExpression(); | ||
skipTrivia(); | ||
} | ||
obj[key] = value; | ||
if (current() === ",") pos++; | ||
skipTrivia(); | ||
} | ||
scanExpected("}"); | ||
return obj; | ||
} | ||
} | ||
/** Does anything in the object imply that we should highlight any lines? */ | ||
var shouldBeHighlightable = function shouldBeHighlightable(meta) { | ||
return !!Object.keys(meta).find(function (key) { | ||
if (key.includes("-")) return true; | ||
if (!isNaN(parseInt(key))) return true; | ||
return false; | ||
}); | ||
}; | ||
/** Returns a func for figuring out if this line should be highlighted */ | ||
var shouldHighlightLine = function shouldHighlightLine(meta) { | ||
var lines = []; | ||
Object.keys(meta).find(function (key) { | ||
if (!isNaN(parseInt(key))) lines.push(parseInt(key)); | ||
if (key.includes("-")) { | ||
var _key$split = key.split("-"), | ||
first = _key$split[0], | ||
last = _key$split[1]; | ||
var lastIndex = parseInt(last) + 1; | ||
for (var i = parseInt(first); i < lastIndex; i++) { | ||
lines.push(i); | ||
} | ||
} | ||
}); | ||
return function (line) { | ||
return lines.includes(line); | ||
}; | ||
}; | ||
/** | ||
@@ -369,3 +134,3 @@ * We're given the text which lives inside the token, and this function will | ||
return str.replace(/⃟/g, '"'); | ||
}; // Inline strings which are shown at HTML level | ||
}; // Inline strings which are shown at HTML level | ||
@@ -398,23 +163,64 @@ | ||
} | ||
/** Does anything in the object imply that we should highlight any lines? */ | ||
var shouldBeHighlightable = function shouldBeHighlightable(highlight) { | ||
return !!Object.keys(highlight || {}).find(function (key) { | ||
if (key.includes("-")) return true; | ||
if (!isNaN(parseInt(key))) return true; | ||
return false; | ||
}); | ||
}; | ||
/** Returns a func for figuring out if this line should be highlighted */ | ||
var shouldHighlightLine = function shouldHighlightLine(highlight) { | ||
var lines = []; | ||
Object.keys(highlight || {}).find(function (key) { | ||
if (!isNaN(parseInt(key))) lines.push(parseInt(key)); | ||
if (key.includes("-")) { | ||
var _key$split = key.split("-"), | ||
first = _key$split[0], | ||
last = _key$split[1]; | ||
var lastIndex = parseInt(last) + 1; | ||
for (var i = parseInt(first); i < lastIndex; i++) { | ||
lines.push(i); | ||
} | ||
} | ||
}); | ||
return function (line) { | ||
return lines.includes(line); | ||
}; | ||
}; | ||
/** A func for setting a consistent <pre> */ | ||
var preOpenerFromRenderingOptsWithExtras = function preOpenerFromRenderingOptsWithExtras(opts, fence, classes) { | ||
var preOpenerFromRenderingOptsWithExtras = function preOpenerFromRenderingOptsWithExtras(opts, meta, classes) { | ||
var bg = opts.bg || "#fff"; | ||
var fg = opts.fg || "black"; | ||
var theme = opts.themeName || ""; | ||
var fenceClass = fence && fence["class"] || ""; | ||
if (fence && classes && fence.title) classes.push("with-title"); | ||
var extras = classes && classes.join(" ") || ""; // prettier-ignore | ||
var theme = opts.themeName || ""; // shiki + `class` from fence + with-title if title exists + classes | ||
return "<pre class=\"shiki " + [fenceClass, theme, extras].filter(Boolean).join(" ").trim() + "\" style=\"background-color: " + bg + "; color: " + fg + "\">"; | ||
var classList = ["shiki", theme, meta["class"], meta.title ? "with-title" : ""].concat(classes || []).filter(Boolean).join(" ").trim(); | ||
var attributes = Object.entries(meta).filter(function (entry) { | ||
// exclude types other than string, number, boolean | ||
// exclude keys class, twoslash | ||
// exclude falsy booleans | ||
return ["string", "number", "boolean"].includes(typeof entry[1]) && !["class", "twoslash"].includes(entry[0]) && entry[1] !== false; | ||
}).map(function (_ref) { | ||
var key = _ref[0], | ||
value = _ref[1]; | ||
return key + "=\"" + value + "\""; | ||
}).join(" ").trim(); // prettier-ignore | ||
return "<pre class=\"" + classList + "\" style=\"background-color: " + bg + "; color: " + fg + "\"" + (attributes ? " " + attributes : '') + ">"; | ||
}; | ||
/** You don't have a language which shiki twoslash can handle, make a DOM compatible version */ | ||
function plainTextRenderer(code, options, codefenceMeta) { | ||
function plainTextRenderer(code, options, meta) { | ||
var html = ""; | ||
html += preOpenerFromRenderingOptsWithExtras(options, codefenceMeta, []); | ||
html += preOpenerFromRenderingOptsWithExtras(options, meta, []); | ||
if (codefenceMeta.title) { | ||
html += "<div class='code-title'>" + codefenceMeta.title + "</div>"; | ||
if (meta.title) { | ||
html += "<div class='code-title'>" + meta.title + "</div>"; | ||
} | ||
@@ -446,10 +252,10 @@ | ||
function twoslashRenderer(lines, options, twoslash, codefenceMeta) { | ||
function twoslashRenderer(lines, options, twoslash, meta) { | ||
var html = ""; | ||
var hasHighlight = shouldBeHighlightable(codefenceMeta); | ||
var hl = shouldHighlightLine(codefenceMeta); | ||
html += preOpenerFromRenderingOptsWithExtras(options, codefenceMeta, ["twoslash", "lsp"]); | ||
var hasHighlight = meta.highlight && shouldBeHighlightable(meta.highlight); | ||
var hl = shouldHighlightLine(meta.highlight); | ||
html += preOpenerFromRenderingOptsWithExtras(options, meta, ["twoslash", "lsp"]); | ||
if (codefenceMeta.title) { | ||
html += "<div class='code-title'>" + codefenceMeta.title + "</div>"; | ||
if (meta.title) { | ||
html += "<div class='code-title'>" + meta.title + "</div>"; | ||
} | ||
@@ -644,10 +450,10 @@ | ||
function defaultShikiRenderer(lines, options, codefenceMeta) { | ||
function defaultShikiRenderer(lines, options, meta) { | ||
var html = ""; | ||
var hasHighlight = shouldBeHighlightable(codefenceMeta); | ||
var hl = shouldHighlightLine(codefenceMeta); | ||
html += preOpenerFromRenderingOptsWithExtras(options, codefenceMeta, []); | ||
var hasHighlight = meta.highlight && shouldBeHighlightable(meta.highlight); | ||
var hl = shouldHighlightLine(meta.highlight); | ||
html += preOpenerFromRenderingOptsWithExtras(options, meta, []); | ||
if (codefenceMeta.title) { | ||
html += "<div class='code-title'>" + codefenceMeta.title + "</div>"; | ||
if (meta.title) { | ||
html += "<div class='code-title'>" + meta.title + "</div>"; | ||
} | ||
@@ -825,8 +631,8 @@ | ||
function tsconfigJSONRenderer(lines, options, codefenceMeta) { | ||
function tsconfigJSONRenderer(lines, options, meta) { | ||
var html = ""; | ||
html += preOpenerFromRenderingOptsWithExtras(options, codefenceMeta, ["tsconfig", "lsp"]); | ||
html += preOpenerFromRenderingOptsWithExtras(options, meta, ["tsconfig", "lsp"]); | ||
if (codefenceMeta.title) { | ||
html += "<div class=\"code-title\">" + codefenceMeta.title + "</div>"; | ||
if (meta.title) { | ||
html += "<div class=\"code-title\">" + meta.title + "</div>"; | ||
} | ||
@@ -901,3 +707,3 @@ | ||
var renderCodeToHTML = function renderCodeToHTML(code, lang, info, shikiOptions, highlighter, twoslash) { | ||
var renderCodeToHTML = function renderCodeToHTML(code, lang, meta, shikiOptions, highlighter, twoslash) { | ||
if (!highlighter && !storedHighlighter) { | ||
@@ -909,4 +715,2 @@ throw new Error("The highlighter object hasn't been initialised via `setupHighLighter` yet in shiki-twoslash"); | ||
var renderHighlighter = highlighter || storedHighlighter; | ||
var metaInfo = info && typeof info === "string" ? info : info.join(" "); | ||
var codefenceMeta = parseCodeFenceInfo(lang, metaInfo || ""); | ||
@@ -929,15 +733,15 @@ var renderOpts = _extends({ | ||
var note = "<!-- Note from shiki-twoslash: the language " + lang + " was not set up for Shiki to use, and so there is no code highlighting --!>"; | ||
return plainTextRenderer(code, renderOpts, codefenceMeta.meta) + note; | ||
return plainTextRenderer(code, renderOpts, meta) + note; | ||
} // Twoslash specific renderer | ||
if (lang && info.includes("twoslash") && twoslash) { | ||
if (lang && meta.twoslash && twoslash) { | ||
return twoslashRenderer(tokens, _extends({}, renderOpts, { | ||
langId: lang | ||
}), twoslash, codefenceMeta.meta); | ||
}), twoslash, meta); | ||
} // TSConfig renderer | ||
if (lang && lang.startsWith("json") && info.includes("tsconfig")) { | ||
return tsconfigJSONRenderer(tokens, renderOpts, codefenceMeta.meta); | ||
if (lang && lang.startsWith("json") && meta.tsconfig) { | ||
return tsconfigJSONRenderer(tokens, renderOpts, meta); | ||
} // Otherwise just the normal shiki renderer | ||
@@ -948,3 +752,3 @@ | ||
langId: lang | ||
}), codefenceMeta.meta); | ||
}), meta); | ||
}; | ||
@@ -997,3 +801,2 @@ /** | ||
exports.createShikiHighlighter = createShikiHighlighter; | ||
exports.parseCodeFenceInfo = parseCodeFenceInfo; | ||
exports.renderCodeToHTML = renderCodeToHTML; | ||
@@ -1000,0 +803,0 @@ exports.renderers = renderers; |
@@ -1,2 +0,2 @@ | ||
"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 i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e}).apply(this,arguments)}var i=/[a-z0-9-–—_+#]/i,r=/\s/,o=/[0-9-.]/,a=/[0-9-.e]/,s=/title=(["'])(.*?)\1/;function l(e,t){return void 0!==e&&t.test(e)}function c(e,t){var n=t.replace("twoslash",""),c=0,p={},d="",u=[e,n].filter(Boolean).join(" ");S(),y()||"{"===m()||(d=w());var f,h,g=c;return S(),y()||"{"!==m()||(p=x()),y()||g!==c?(t.match(s)&&(p.title=null!=(f=null==(h=t.match(s))?void 0:h[2])?f:""),{languageName:d,meta:p}):v("Invalid character in language name: '"+m()+"'");function m(){return y()?v("Unexpected end of input"):u[c]}function y(){return c>=u.length}function v(e){throw new Error("Failed parsing code fence header '"+u+"' at position "+c+": "+e)}function b(e){if(y()||m()!==e)return v("Expected '"+e+"'");c++}function w(e){void 0===e&&(e="Expected identifier, but got nothing");for(var t="";!y()&&l(m(),i);)t+=m(),c++;return t||v(e)}function S(){for(;!y()&&l(m(),r);)c++}function k(){switch(m()){case"{":return x();case"'":case'"':return function(){var e,t="",n=m();for(c++;;){var i=(e=void 0,"\\"===(e=m())&&(c++,e+=m()),c++,e);if(i===n)break;t+=i.replace(/\\/,"")}return t}()}return l(m(),o)?function(){var e=m();for(c++;!y()&&l(m(),a);)e+=m(),c++;return parseFloat(e)}():function(){var e=w("Expected expression, but got nothing");switch(e){case"true":return!0;case"false":return!1;case"":return v("Expected expression, but got nothing");default:return v("Unrecognized input '"+e+"'")}}()}function x(){var e={};for(b("{"),S();!y()&&"}"!==m();){var t=w(),n=!0;S(),":"===m()&&(c++,S(),n=k(),S()),e[t]=n,","===m()&&c++,S()}return b("}"),e}}var p=function(e){return!!Object.keys(e).find((function(e){return!!e.includes("-")||!isNaN(parseInt(e))}))},d=function(e){var t=[];return Object.keys(e).find((function(e){if(isNaN(parseInt(e))||t.push(parseInt(e)),e.includes("-"))for(var n=e.split("-"),i=n[0],r=parseInt(n[1])+1,o=parseInt(i);o<r;o++)t.push(o)})),function(e){return t.includes(e)}};function u(e){return e.replace(/</g,"<").replace(/>/g,">")}var f=function(e,t,n){var i=e.bg||"#fff",r=e.fg||"black",o=e.themeName||"",a=t&&t.class||"";return t&&n&&t.title&&n.push("with-title"),'<pre class="shiki '+[a,o,n&&n.join(" ")||""].filter(Boolean).join(" ").trim()+'" style="background-color: '+i+"; color: "+r+'">'};function h(e,t,n){var i="";return i+=f(t,n,[]),n.title&&(i+="<div class='code-title'>"+n.title+"</div>"),t.langId&&(i+='<div class="language-id">'+t.langId+"</div>"),i+="<div class='code-container'><code>",(i=(i+=u(e)).replace(/\n*$/,""))+"</code></div></pre>"}function g(e,t,n,i){var r="",o=p(i),a=d(i);r+=f(t,i,["twoslash","lsp"]),i.title&&(r+="<div class='code-title'>"+i.title+"</div>"),t.langId&&(r+='<div class="language-id">'+t.langId+"</div>"),r+="<div class='code-container'><code>";var s,l=m(n.errors,(function(e){return e.line}))||new Map,c=m(n.staticQuickInfos,(function(e){return e.line}))||new Map,h=m(n.queries,(function(e){return e.line-1}))||new Map,g=0;return e.forEach((function(e,n){var i=l.get(n)||[],s=c.get(n)||[],p=h.get(n)||[],d="<div class='line"+(o?a(n)?" highlight":" dim":"")+"'>";if(0===e.length&&0===n)g+=1;else if(0===e.length)r+=d+" </div>",g+=1;else{r+=d;var f=0;e.forEach((function(e){var n,o="",a=function(t){return function(n){return t<=n.character&&t+e.content.length>=n.character+n.length}},l=i.filter(a(f)),c=s.filter(a(f)),d=p.filter(a(f));n=n||c.find((function(e){return e.text===(p.length&&p[0].text)}));var u,h=[].concat(l,c,d).sort((function(e,t){return(e.start||0)-(t.start||0)}));o+=h.length?function(e,t,n){void 0===n&&(n="");var i=function(e){return"⇍"+e+"⇏"},r=function(e,t){switch(e.classes){case"lsp":var r=function(e){return e.replace(/"/g,"⃟")}(e.lsp||"");return i(t?"/data-lsp":"data-lsp lsp=¿"+r+"¿ "+(e.lsp===n?"style=⇯border-bottom: solid 2px lightgrey;⇯":""));case"query":return i((t?"/":"")+"data-highlight");case"err":default:return i((t?"/":"")+"data-err")}};e.sort((function(e,t){var n=function(e){return["err","query","lsp"].indexOf(null!=e?e:"")},i=0;return!(i=e.begin-t.begin)&&!(i=t.end-e.end)&&(i=n(e.classes)-n(t.classes)),i}));var o=0;return function(e){return e.replace(/⃟/g,'"')}(function(e){return e.replace(/⇍/g,"<").replace(/⇏/g,">").replace(/⇯/g,"'").replace(/¿/g,"'")}(function(e){var t={"<":"lt",'"':"quot","'":"apos","&":"amp","\r":"#13","\n":"#10"};return e.toString().replace(/[<"'\r\n&]/g,(function(e){return"&"+t[e]+";"}))}(function e(n){var i="",a=n.shift();return i+=t.substring(o,a.begin),o=a.begin,i+=r(a),n.some((function(e){return e.begin<a.end}))?i+=e(n):(i+=t.substring(a.begin,a.end),o=a.end),i+=r(a,!0),0!==n.length&&(i+=e(n)),i}(JSON.parse(JSON.stringify(e)))+t.substring(o))))}(h.map((function(e){var n={begin:e.start-g,end:e.start+e.length-g};return"renderedMessage"in e&&(n.classes="err"),"kind"in e&&(n.classes=e.kind),"targetString"in e&&(n.classes="lsp",n.lsp=t.includeJSDocInHover&&e.docs?e.docs+"\n\n"+e.text:e.text),n})),e.content,null==(u=n)?void 0:u.text):e.content.replace(/</g,"⇍").replace(/>/g,"⇏").replace(/'/g,"⇯"),r+='<span style="color: '+e.color+'">'+o+"</span>",f+=e.content.length,g+=e.content.length})),r+="</div>",g+=1}if(i.length){var m=i.map((function(e){return u(e.renderedMessage)})).join("</br>"),y=i.map((function(e){return e.code})).join("<br/>");r+='<span class="error"><span>'+m+'</span><span class="code">'+y+"</span></span>",r+='<span class="error-behind">'+m+"</span>"}p.length&&p.forEach((function(e){switch(r+="<div class='meta-line'>",e.kind){case"query":var t=u(e.text),i=(c.get(n)||[]).find((function(e){return e.text===(p.length&&p[0].text)}));r+="<span class='popover-prefix'>"+" ".repeat((i&&i.character+(null==i?void 0:i.length)/2)-1||0)+"</span><span class='popover'><div class='arrow'></div>"+t+"</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,i,r=t.name.substr((null==(n=e.completionsPrefix)?void 0:n.length)||0),o="<span><span class='result-found'>"+(e.completionsPrefix||"")+"</span>"+r+"<span>";return"<li class='"+((null==(i=t.kindModifiers)?void 0:i.split(",").includes("deprecated"))?"deprecated":"")+"'>"+o+"</li>"})).join("");r+=" ".repeat(e.offset)+"<span class='inline-completions'><ul class='dropdown'>"+o+"</ul></span>"}else r+="<span class='query'>//"+"".padStart(e.offset-2)+"^ - No completions found</span>"}r+="</div>"}))})),s=r.replace(/\n*$/,""),r=s.replace(/⇍/g,"<").replace(/⇏/g,">").replace(/⇯/g,"'"),r+=t.addTryButton?"</code><a class='playground-link' href='"+n.playgroundURL+"'>Try</a>":"</code>",r+="</div></pre>"}function m(e,t){var n=new Map;return e.forEach((function(e){var i=t(e),r=n.get(i);r?r.push(e):n.set(i,[e])})),n}function y(e,t,n){var i="",r=p(n),o=d(n);return i+=f(t,n,[]),n.title&&(i+="<div class='code-title'>"+n.title+"</div>"),t.langId&&(i+='<div class="language-id">'+t.langId+"</div>"),i+="<div class='code-container'><code>",e.forEach((function(e,t){if(0===e.length)i+="<div class='line'></div>";else{var n=r?o(t)?" highlight":" dim":"";i+="<div class='line"+n+"'>",e.forEach((function(e){i+='<span style="color: '+e.color+'">'+u(e.content)+"</span>"})),i+="</div>"}})),i=i.replace(/\n*$/,""),i+="</code></div></pre>"}var v={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.",exactOptionalPropertyTypes:"Differentiate between undefined and not present when type checking",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.",useUnknownInCatchVariables:"Default catch clause variables as `unknown` instead of `any`.",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."};function b(e,t,n){var i="";return i+=f(t,n,["tsconfig","lsp"]),n.title&&(i+='<div class="code-title">'+n.title+"</div>"),t.langId&&(i+='<div class="language-id">'+t.langId+"</div>"),i+="<div class='code-container'><code>",e.forEach((function(e){0===e.length?i+="<div class='line'></div>":(i+="<div class='line'>",e.forEach((function(e){if(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 v}(e)){var t=e.content.slice(1,e.content.length-1);i+='<span style="color: '+e.color+'">"<a aria-hidden=true tabindex="-1" href=\'https://www.typescriptlang.org/tsconfig#'+t+"'><data-lsp lsp=\""+v[t]+'">'+u(t)+'</data-lsp></a>"</span>'}else i+='<span style="color: '+e.color+'">'+u(e.content)+"</span>"})),i+="</div>")})),i=i.replace(/\n*$/,""),i+="</code></div></pre>"}var w=null,S={plainTextRenderer:h,defaultShikiRenderer:y,twoslashRenderer:g,tsconfigJSONRenderer:b};exports.createShikiHighlighter=function(t){return w?Promise.resolve(w):e.getHighlighter(t).then((function(e){return w=e}))},exports.parseCodeFenceInfo=c,exports.renderCodeToHTML=function(e,t,i,r,o,a){if(!o&&!w)throw new Error("The highlighter object hasn't been initialised via `setupHighLighter` yet in shiki-twoslash");var s,l=o||w,p=c(t,(i&&"string"==typeof i?i:i.join(" "))||""),d=n({fg:l.getForegroundColor(),bg:l.getBackgroundColor()},r);try{s=l.codeToThemedTokens(e,"jsx"===t?"tsx":t)}catch(n){var u="\x3c!-- Note from shiki-twoslash: the language "+t+" was not set up for Shiki to use, and so there is no code highlighting --!>";return h(e,d,p.meta)+u}return t&&i.includes("twoslash")&&a?g(s,n({},d,{langId:t}),a,p.meta):t&&t.startsWith("json")&&i.includes("tsconfig")?b(s,d,p.meta):y(s,n({},d,{langId:t}),p.meta)},exports.renderers=S,exports.runTwoSlash=function(e,n,i){void 0===i&&(i={});var r=e,o={json5:"json",yml:"yaml"};if(o[n]&&(n=o[n]),["tsx","jsx"].includes(n)&&!i.disableImplicitReactImport){var a="import React from 'react'\n",s="// ---cut---\n";r=r.includes(s)?r.split(s).map((function(e,t){return 0==t?a.concat(e):e})).join(s):[a,s,r].join("")}return t.twoslasher(r,n,i)}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("shiki"),t=require("@typescript/twoslash");function i(){return(i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n])}return e}).apply(this,arguments)}function n(e){return e.replace(/</g,"<").replace(/>/g,">")}var r=function(e){return!!Object.keys(e||{}).find((function(e){return!!e.includes("-")||!isNaN(parseInt(e))}))},o=function(e){var t=[];return Object.keys(e||{}).find((function(e){if(isNaN(parseInt(e))||t.push(parseInt(e)),e.includes("-"))for(var i=e.split("-"),n=i[0],r=parseInt(i[1])+1,o=parseInt(n);o<r;o++)t.push(o)})),function(e){return t.includes(e)}},a=function(e,t,i){var n=e.bg||"#fff",r=e.fg||"black",o=["shiki",e.themeName||"",t.class,t.title?"with-title":""].concat(i||[]).filter(Boolean).join(" ").trim(),a=Object.entries(t).filter((function(e){return["string","number","boolean"].includes(typeof e[1])&&!["class","twoslash"].includes(e[0])&&!1!==e[1]})).map((function(e){return e[0]+'="'+e[1]+'"'})).join(" ").trim();return'<pre class="'+o+'" style="background-color: '+n+"; color: "+r+'"'+(a?" "+a:"")+">"};function s(e,t,i){var r="";return r+=a(t,i,[]),i.title&&(r+="<div class='code-title'>"+i.title+"</div>"),t.langId&&(r+='<div class="language-id">'+t.langId+"</div>"),r+="<div class='code-container'><code>",(r=(r+=n(e)).replace(/\n*$/,""))+"</code></div></pre>"}function l(e,t,i,s){var l="",p=s.highlight&&r(s.highlight),d=o(s.highlight);l+=a(t,s,["twoslash","lsp"]),s.title&&(l+="<div class='code-title'>"+s.title+"</div>"),t.langId&&(l+='<div class="language-id">'+t.langId+"</div>"),l+="<div class='code-container'><code>";var u,f=c(i.errors,(function(e){return e.line}))||new Map,h=c(i.staticQuickInfos,(function(e){return e.line}))||new Map,g=c(i.queries,(function(e){return e.line-1}))||new Map,m=0;return e.forEach((function(e,i){var r=f.get(i)||[],o=h.get(i)||[],a=g.get(i)||[],s="<div class='line"+(p?d(i)?" highlight":" dim":"")+"'>";if(0===e.length&&0===i)m+=1;else if(0===e.length)l+=s+" </div>",m+=1;else{l+=s;var c=0;e.forEach((function(e){var i,n="",s=function(t){return function(i){return t<=i.character&&t+e.content.length>=i.character+i.length}},p=r.filter(s(c)),d=o.filter(s(c)),u=a.filter(s(c));i=i||d.find((function(e){return e.text===(a.length&&a[0].text)}));var f,h=[].concat(p,d,u).sort((function(e,t){return(e.start||0)-(t.start||0)}));n+=h.length?function(e,t,i){void 0===i&&(i="");var n=function(e){return"⇍"+e+"⇏"},r=function(e,t){switch(e.classes){case"lsp":var r=function(e){return e.replace(/"/g,"⃟")}(e.lsp||"");return n(t?"/data-lsp":"data-lsp lsp=¿"+r+"¿ "+(e.lsp===i?"style=⇯border-bottom: solid 2px lightgrey;⇯":""));case"query":return n((t?"/":"")+"data-highlight");case"err":default:return n((t?"/":"")+"data-err")}};e.sort((function(e,t){var i=function(e){return["err","query","lsp"].indexOf(null!=e?e:"")},n=0;return!(n=e.begin-t.begin)&&!(n=t.end-e.end)&&(n=i(e.classes)-i(t.classes)),n}));var o=0;return function(e){return e.replace(/⃟/g,'"')}(function(e){return e.replace(/⇍/g,"<").replace(/⇏/g,">").replace(/⇯/g,"'").replace(/¿/g,"'")}(function(e){var t={"<":"lt",'"':"quot","'":"apos","&":"amp","\r":"#13","\n":"#10"};return e.toString().replace(/[<"'\r\n&]/g,(function(e){return"&"+t[e]+";"}))}(function e(i){var n="",a=i.shift();return n+=t.substring(o,a.begin),o=a.begin,n+=r(a),i.some((function(e){return e.begin<a.end}))?n+=e(i):(n+=t.substring(a.begin,a.end),o=a.end),n+=r(a,!0),0!==i.length&&(n+=e(i)),n}(JSON.parse(JSON.stringify(e)))+t.substring(o))))}(h.map((function(e){var i={begin:e.start-m,end:e.start+e.length-m};return"renderedMessage"in e&&(i.classes="err"),"kind"in e&&(i.classes=e.kind),"targetString"in e&&(i.classes="lsp",i.lsp=t.includeJSDocInHover&&e.docs?e.docs+"\n\n"+e.text:e.text),i})),e.content,null==(f=i)?void 0:f.text):e.content.replace(/</g,"⇍").replace(/>/g,"⇏").replace(/'/g,"⇯"),l+='<span style="color: '+e.color+'">'+n+"</span>",c+=e.content.length,m+=e.content.length})),l+="</div>",m+=1}if(r.length){var u=r.map((function(e){return n(e.renderedMessage)})).join("</br>"),y=r.map((function(e){return e.code})).join("<br/>");l+='<span class="error"><span>'+u+'</span><span class="code">'+y+"</span></span>",l+='<span class="error-behind">'+u+"</span>"}a.length&&a.forEach((function(e){switch(l+="<div class='meta-line'>",e.kind){case"query":var t=n(e.text),r=(h.get(i)||[]).find((function(e){return e.text===(a.length&&a[0].text)}));l+="<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>"+t+"</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 i,n,r=t.name.substr((null==(i=e.completionsPrefix)?void 0:i.length)||0),o="<span><span class='result-found'>"+(e.completionsPrefix||"")+"</span>"+r+"<span>";return"<li class='"+((null==(n=t.kindModifiers)?void 0:n.split(",").includes("deprecated"))?"deprecated":"")+"'>"+o+"</li>"})).join("");l+=" ".repeat(e.offset)+"<span class='inline-completions'><ul class='dropdown'>"+o+"</ul></span>"}else l+="<span class='query'>//"+"".padStart(e.offset-2)+"^ - No completions found</span>"}l+="</div>"}))})),u=l.replace(/\n*$/,""),l=u.replace(/⇍/g,"<").replace(/⇏/g,">").replace(/⇯/g,"'"),l+=t.addTryButton?"</code><a class='playground-link' href='"+i.playgroundURL+"'>Try</a>":"</code>",l+="</div></pre>"}function c(e,t){var i=new Map;return e.forEach((function(e){var n=t(e),r=i.get(n);r?r.push(e):i.set(n,[e])})),i}function p(e,t,i){var s="",l=i.highlight&&r(i.highlight),c=o(i.highlight);return s+=a(t,i,[]),i.title&&(s+="<div class='code-title'>"+i.title+"</div>"),t.langId&&(s+='<div class="language-id">'+t.langId+"</div>"),s+="<div class='code-container'><code>",e.forEach((function(e,t){if(0===e.length)s+="<div class='line'></div>";else{var i=l?c(t)?" highlight":" dim":"";s+="<div class='line"+i+"'>",e.forEach((function(e){s+='<span style="color: '+e.color+'">'+n(e.content)+"</span>"})),s+="</div>"}})),s=s.replace(/\n*$/,""),s+="</code></div></pre>"}var d={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.",exactOptionalPropertyTypes:"Differentiate between undefined and not present when type checking",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.",useUnknownInCatchVariables:"Default catch clause variables as `unknown` instead of `any`.",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."};function u(e,t,i){var r="";return r+=a(t,i,["tsconfig","lsp"]),i.title&&(r+='<div class="code-title">'+i.title+"</div>"),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(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 d}(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=\""+d[t]+'">'+n(t)+'</data-lsp></a>"</span>'}else r+='<span style="color: '+e.color+'">'+n(e.content)+"</span>"})),r+="</div>")})),r=r.replace(/\n*$/,""),r+="</code></div></pre>"}var f=null,h={plainTextRenderer:s,defaultShikiRenderer:p,twoslashRenderer:l,tsconfigJSONRenderer:u};exports.createShikiHighlighter=function(t){return f?Promise.resolve(f):e.getHighlighter(t).then((function(e){return f=e}))},exports.renderCodeToHTML=function(e,t,n,r,o,a){if(!o&&!f)throw new Error("The highlighter object hasn't been initialised via `setupHighLighter` yet in shiki-twoslash");var c,d=o||f,h=i({fg:d.getForegroundColor(),bg:d.getBackgroundColor()},r);try{c=d.codeToThemedTokens(e,"jsx"===t?"tsx":t)}catch(i){var g="\x3c!-- Note from shiki-twoslash: the language "+t+" was not set up for Shiki to use, and so there is no code highlighting --!>";return s(e,h,n)+g}return t&&n.twoslash&&a?l(c,i({},h,{langId:t}),a,n):t&&t.startsWith("json")&&n.tsconfig?u(c,h,n):p(c,i({},h,{langId:t}),n)},exports.renderers=h,exports.runTwoSlash=function(e,i,n){void 0===n&&(n={});var r=e,o={json5:"json",yml:"yaml"};if(o[i]&&(i=o[i]),["tsx","jsx"].includes(i)&&!n.disableImplicitReactImport){var a="import React from 'react'\n",s="// ---cut---\n";r=r.includes(s)?r.split(s).map((function(e,t){return 0==t?a.concat(e):e})).join(s):[a,s,r].join("")}return t.twoslasher(r,i,n)}; | ||
//# sourceMappingURL=shiki-twoslash.cjs.production.min.js.map |
@@ -22,237 +22,2 @@ import { getHighlighter } from 'shiki'; | ||
// Based on https://github.com/andrewbranch/gatsby-remark-vscode/blob/7bf5c036a58652c1f45d27c5874557f7b531102c/src/index.js | ||
// which is MIT https://github.com/andrewbranch/gatsby-remark-vscode/blob/7bf5c036a58652c1f45d27c5874557f7b531102c/LICENSE | ||
// Only difference is conversion to TypeScript, and a replace at the top | ||
var identifierPattern = /[a-z0-9-–—_+#]/i; | ||
var triviaPattern = /\s/; | ||
var startOfNumberPattern = /[0-9-.]/; | ||
var numberPattern = /[0-9-.e]/; // Based on https://github.com/facebook/docusaurus/blob/ed9d2a26f5a7b8096804ae1b3a4fffc504f8f90d/packages/docusaurus-theme-common/src/utils/codeBlockUtils.ts | ||
// which is under MIT License as per the banner | ||
var titlePattern = /title=(["'])(.*?)\1/; | ||
function testRegex(input, pattern) { | ||
if (input === undefined) return false; | ||
return pattern.test(input); | ||
} | ||
/** Takes the language and a meta-string and offers a useful object for looking at params */ | ||
function parseCodeFenceInfo(lang, fullMetaString) { | ||
// Heh | ||
var metaString = fullMetaString.replace("twoslash", ""); | ||
var pos = 0; | ||
var meta = {}; | ||
var languageName = ""; | ||
var input = [lang, metaString].filter(Boolean).join(" "); | ||
skipTrivia(); | ||
if (!isEnd() && current() !== "{") { | ||
languageName = parseIdentifier(); | ||
} | ||
var languageNameEnd = pos; | ||
skipTrivia(); | ||
if (!isEnd() && current() === "{") { | ||
meta = parseObject(); | ||
} | ||
if (!isEnd() && languageNameEnd === pos) { | ||
return fail("Invalid character in language name: '" + current() + "'"); | ||
} | ||
if (fullMetaString.match(titlePattern)) { | ||
var _fullMetaString$match, _fullMetaString$match2; | ||
meta.title = (_fullMetaString$match = (_fullMetaString$match2 = fullMetaString.match(titlePattern)) == null ? void 0 : _fullMetaString$match2[2]) != null ? _fullMetaString$match : ""; | ||
} | ||
return { | ||
languageName: languageName, | ||
meta: meta | ||
}; | ||
function current() { | ||
if (isEnd()) { | ||
return fail("Unexpected end of input"); | ||
} | ||
return input[pos]; | ||
} | ||
function isEnd() { | ||
return pos >= input.length; | ||
} | ||
function fail(message) { | ||
throw new Error("Failed parsing code fence header '" + input + "' at position " + pos + ": " + message); | ||
} | ||
function scanExpected(expected) { | ||
if (isEnd() || current() !== expected) { | ||
return fail("Expected '" + expected + "'"); | ||
} | ||
pos++; | ||
} | ||
function parseIdentifier(errorMessage) { | ||
if (errorMessage === void 0) { | ||
errorMessage = "Expected identifier, but got nothing"; | ||
} | ||
var identifier = ""; | ||
while (!isEnd() && testRegex(current(), identifierPattern)) { | ||
identifier += current(); | ||
pos++; | ||
} | ||
if (!identifier) { | ||
return fail(errorMessage); | ||
} | ||
return identifier; | ||
} | ||
function skipTrivia() { | ||
while (!isEnd() && testRegex(current(), triviaPattern)) { | ||
pos++; | ||
} | ||
} | ||
function parseChar() { | ||
var _char = current(); | ||
if (_char === "\\") { | ||
pos++; | ||
_char += current(); | ||
} | ||
pos++; | ||
return _char; | ||
} | ||
function parseString() { | ||
var str = ""; | ||
var quote = current(); | ||
pos++; | ||
while (true) { | ||
var _char2 = parseChar(); | ||
if (_char2 === quote) break; | ||
str += _char2.replace(/\\/, ""); | ||
} | ||
return str; | ||
} | ||
function parseNumber() { | ||
var numStr = current(); | ||
pos++; | ||
while (!isEnd() && testRegex(current(), numberPattern)) { | ||
numStr += current(); | ||
pos++; | ||
} | ||
return parseFloat(numStr); | ||
} | ||
function parseBoolean() { | ||
var identifier = parseIdentifier("Expected expression, but got nothing"); | ||
switch (identifier) { | ||
case "true": | ||
return true; | ||
case "false": | ||
return false; | ||
case "": | ||
return fail("Expected expression, but got nothing"); | ||
default: | ||
return fail("Unrecognized input '" + identifier + "'"); | ||
} | ||
} | ||
function parseExpression() { | ||
switch (current()) { | ||
case "{": | ||
return parseObject(); | ||
case "'": | ||
case '"': | ||
return parseString(); | ||
} | ||
if (testRegex(current(), startOfNumberPattern)) { | ||
return parseNumber(); | ||
} | ||
return parseBoolean(); | ||
} | ||
function parseObject() { | ||
var obj = {}; | ||
scanExpected("{"); | ||
skipTrivia(); | ||
while (!isEnd() && current() !== "}") { | ||
var key = parseIdentifier(); | ||
var value = true; | ||
skipTrivia(); | ||
if (current() === ":") { | ||
pos++; | ||
skipTrivia(); | ||
value = parseExpression(); | ||
skipTrivia(); | ||
} | ||
obj[key] = value; | ||
if (current() === ",") pos++; | ||
skipTrivia(); | ||
} | ||
scanExpected("}"); | ||
return obj; | ||
} | ||
} | ||
/** Does anything in the object imply that we should highlight any lines? */ | ||
var shouldBeHighlightable = function shouldBeHighlightable(meta) { | ||
return !!Object.keys(meta).find(function (key) { | ||
if (key.includes("-")) return true; | ||
if (!isNaN(parseInt(key))) return true; | ||
return false; | ||
}); | ||
}; | ||
/** Returns a func for figuring out if this line should be highlighted */ | ||
var shouldHighlightLine = function shouldHighlightLine(meta) { | ||
var lines = []; | ||
Object.keys(meta).find(function (key) { | ||
if (!isNaN(parseInt(key))) lines.push(parseInt(key)); | ||
if (key.includes("-")) { | ||
var _key$split = key.split("-"), | ||
first = _key$split[0], | ||
last = _key$split[1]; | ||
var lastIndex = parseInt(last) + 1; | ||
for (var i = parseInt(first); i < lastIndex; i++) { | ||
lines.push(i); | ||
} | ||
} | ||
}); | ||
return function (line) { | ||
return lines.includes(line); | ||
}; | ||
}; | ||
/** | ||
@@ -365,3 +130,3 @@ * We're given the text which lives inside the token, and this function will | ||
return str.replace(/⃟/g, '"'); | ||
}; // Inline strings which are shown at HTML level | ||
}; // Inline strings which are shown at HTML level | ||
@@ -394,23 +159,64 @@ | ||
} | ||
/** Does anything in the object imply that we should highlight any lines? */ | ||
var shouldBeHighlightable = function shouldBeHighlightable(highlight) { | ||
return !!Object.keys(highlight || {}).find(function (key) { | ||
if (key.includes("-")) return true; | ||
if (!isNaN(parseInt(key))) return true; | ||
return false; | ||
}); | ||
}; | ||
/** Returns a func for figuring out if this line should be highlighted */ | ||
var shouldHighlightLine = function shouldHighlightLine(highlight) { | ||
var lines = []; | ||
Object.keys(highlight || {}).find(function (key) { | ||
if (!isNaN(parseInt(key))) lines.push(parseInt(key)); | ||
if (key.includes("-")) { | ||
var _key$split = key.split("-"), | ||
first = _key$split[0], | ||
last = _key$split[1]; | ||
var lastIndex = parseInt(last) + 1; | ||
for (var i = parseInt(first); i < lastIndex; i++) { | ||
lines.push(i); | ||
} | ||
} | ||
}); | ||
return function (line) { | ||
return lines.includes(line); | ||
}; | ||
}; | ||
/** A func for setting a consistent <pre> */ | ||
var preOpenerFromRenderingOptsWithExtras = function preOpenerFromRenderingOptsWithExtras(opts, fence, classes) { | ||
var preOpenerFromRenderingOptsWithExtras = function preOpenerFromRenderingOptsWithExtras(opts, meta, classes) { | ||
var bg = opts.bg || "#fff"; | ||
var fg = opts.fg || "black"; | ||
var theme = opts.themeName || ""; | ||
var fenceClass = fence && fence["class"] || ""; | ||
if (fence && classes && fence.title) classes.push("with-title"); | ||
var extras = classes && classes.join(" ") || ""; // prettier-ignore | ||
var theme = opts.themeName || ""; // shiki + `class` from fence + with-title if title exists + classes | ||
return "<pre class=\"shiki " + [fenceClass, theme, extras].filter(Boolean).join(" ").trim() + "\" style=\"background-color: " + bg + "; color: " + fg + "\">"; | ||
var classList = ["shiki", theme, meta["class"], meta.title ? "with-title" : ""].concat(classes || []).filter(Boolean).join(" ").trim(); | ||
var attributes = Object.entries(meta).filter(function (entry) { | ||
// exclude types other than string, number, boolean | ||
// exclude keys class, twoslash | ||
// exclude falsy booleans | ||
return ["string", "number", "boolean"].includes(typeof entry[1]) && !["class", "twoslash"].includes(entry[0]) && entry[1] !== false; | ||
}).map(function (_ref) { | ||
var key = _ref[0], | ||
value = _ref[1]; | ||
return key + "=\"" + value + "\""; | ||
}).join(" ").trim(); // prettier-ignore | ||
return "<pre class=\"" + classList + "\" style=\"background-color: " + bg + "; color: " + fg + "\"" + (attributes ? " " + attributes : '') + ">"; | ||
}; | ||
/** You don't have a language which shiki twoslash can handle, make a DOM compatible version */ | ||
function plainTextRenderer(code, options, codefenceMeta) { | ||
function plainTextRenderer(code, options, meta) { | ||
var html = ""; | ||
html += preOpenerFromRenderingOptsWithExtras(options, codefenceMeta, []); | ||
html += preOpenerFromRenderingOptsWithExtras(options, meta, []); | ||
if (codefenceMeta.title) { | ||
html += "<div class='code-title'>" + codefenceMeta.title + "</div>"; | ||
if (meta.title) { | ||
html += "<div class='code-title'>" + meta.title + "</div>"; | ||
} | ||
@@ -442,10 +248,10 @@ | ||
function twoslashRenderer(lines, options, twoslash, codefenceMeta) { | ||
function twoslashRenderer(lines, options, twoslash, meta) { | ||
var html = ""; | ||
var hasHighlight = shouldBeHighlightable(codefenceMeta); | ||
var hl = shouldHighlightLine(codefenceMeta); | ||
html += preOpenerFromRenderingOptsWithExtras(options, codefenceMeta, ["twoslash", "lsp"]); | ||
var hasHighlight = meta.highlight && shouldBeHighlightable(meta.highlight); | ||
var hl = shouldHighlightLine(meta.highlight); | ||
html += preOpenerFromRenderingOptsWithExtras(options, meta, ["twoslash", "lsp"]); | ||
if (codefenceMeta.title) { | ||
html += "<div class='code-title'>" + codefenceMeta.title + "</div>"; | ||
if (meta.title) { | ||
html += "<div class='code-title'>" + meta.title + "</div>"; | ||
} | ||
@@ -640,10 +446,10 @@ | ||
function defaultShikiRenderer(lines, options, codefenceMeta) { | ||
function defaultShikiRenderer(lines, options, meta) { | ||
var html = ""; | ||
var hasHighlight = shouldBeHighlightable(codefenceMeta); | ||
var hl = shouldHighlightLine(codefenceMeta); | ||
html += preOpenerFromRenderingOptsWithExtras(options, codefenceMeta, []); | ||
var hasHighlight = meta.highlight && shouldBeHighlightable(meta.highlight); | ||
var hl = shouldHighlightLine(meta.highlight); | ||
html += preOpenerFromRenderingOptsWithExtras(options, meta, []); | ||
if (codefenceMeta.title) { | ||
html += "<div class='code-title'>" + codefenceMeta.title + "</div>"; | ||
if (meta.title) { | ||
html += "<div class='code-title'>" + meta.title + "</div>"; | ||
} | ||
@@ -821,8 +627,8 @@ | ||
function tsconfigJSONRenderer(lines, options, codefenceMeta) { | ||
function tsconfigJSONRenderer(lines, options, meta) { | ||
var html = ""; | ||
html += preOpenerFromRenderingOptsWithExtras(options, codefenceMeta, ["tsconfig", "lsp"]); | ||
html += preOpenerFromRenderingOptsWithExtras(options, meta, ["tsconfig", "lsp"]); | ||
if (codefenceMeta.title) { | ||
html += "<div class=\"code-title\">" + codefenceMeta.title + "</div>"; | ||
if (meta.title) { | ||
html += "<div class=\"code-title\">" + meta.title + "</div>"; | ||
} | ||
@@ -897,3 +703,3 @@ | ||
var renderCodeToHTML = function renderCodeToHTML(code, lang, info, shikiOptions, highlighter, twoslash) { | ||
var renderCodeToHTML = function renderCodeToHTML(code, lang, meta, shikiOptions, highlighter, twoslash) { | ||
if (!highlighter && !storedHighlighter) { | ||
@@ -905,4 +711,2 @@ throw new Error("The highlighter object hasn't been initialised via `setupHighLighter` yet in shiki-twoslash"); | ||
var renderHighlighter = highlighter || storedHighlighter; | ||
var metaInfo = info && typeof info === "string" ? info : info.join(" "); | ||
var codefenceMeta = parseCodeFenceInfo(lang, metaInfo || ""); | ||
@@ -925,15 +729,15 @@ var renderOpts = _extends({ | ||
var note = "<!-- Note from shiki-twoslash: the language " + lang + " was not set up for Shiki to use, and so there is no code highlighting --!>"; | ||
return plainTextRenderer(code, renderOpts, codefenceMeta.meta) + note; | ||
return plainTextRenderer(code, renderOpts, meta) + note; | ||
} // Twoslash specific renderer | ||
if (lang && info.includes("twoslash") && twoslash) { | ||
if (lang && meta.twoslash && twoslash) { | ||
return twoslashRenderer(tokens, _extends({}, renderOpts, { | ||
langId: lang | ||
}), twoslash, codefenceMeta.meta); | ||
}), twoslash, meta); | ||
} // TSConfig renderer | ||
if (lang && lang.startsWith("json") && info.includes("tsconfig")) { | ||
return tsconfigJSONRenderer(tokens, renderOpts, codefenceMeta.meta); | ||
if (lang && lang.startsWith("json") && meta.tsconfig) { | ||
return tsconfigJSONRenderer(tokens, renderOpts, meta); | ||
} // Otherwise just the normal shiki renderer | ||
@@ -944,3 +748,3 @@ | ||
langId: lang | ||
}), codefenceMeta.meta); | ||
}), meta); | ||
}; | ||
@@ -992,3 +796,3 @@ /** | ||
export { createShikiHighlighter, parseCodeFenceInfo, renderCodeToHTML, renderers, runTwoSlash }; | ||
export { createShikiHighlighter, renderCodeToHTML, renderers, runTwoSlash }; | ||
//# sourceMappingURL=shiki-twoslash.esm.js.map |
@@ -0,1 +1,3 @@ | ||
import type { parse } from "fenceparser"; | ||
export declare type Meta = NonNullable<ReturnType<typeof parse>>; | ||
declare type Range = { | ||
@@ -20,2 +22,6 @@ begin: number; | ||
export declare function escapeHtml(html: string): string; | ||
/** Does anything in the object imply that we should highlight any lines? */ | ||
export declare const shouldBeHighlightable: (highlight: any) => boolean; | ||
/** Returns a func for figuring out if this line should be highlighted */ | ||
export declare const shouldHighlightLine: (highlight: any) => (line: number) => boolean; | ||
export {}; |
{ | ||
"name": "shiki-twoslash", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"license": "MIT", | ||
@@ -37,2 +37,3 @@ "homepage": "https://github.com/shikijs/twoslash", | ||
"@types/jest": "^25.1.3", | ||
"fenceparser": "^1.1.0", | ||
"gray-matter": "^4.0.3", | ||
@@ -39,0 +40,0 @@ "jest-file-snapshot": "^0.5.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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
289669
9
18
1674