Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

shiki-twoslash

Package Overview
Dependencies
Maintainers
3
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.4.2 to 1.4.3

6

dist/shiki-twoslash.cjs.development.js

@@ -308,3 +308,3 @@ 'use strict';

return htmlAttrUnReplacer(replaceTripleArrow(stripHTML(html)));
} // HTML attributes have different rules,
} // HTML attributes have different rules,

@@ -335,4 +335,4 @@ var htmlAttrReplacer = function htmlAttrReplacer(str) {

"&": "amp",
"\r": "#10",
"\n": "#13"
"\r": "#13",
"\n": "#10"
};

@@ -339,0 +339,0 @@ return text.toString().replace(/[<"'\r\n&]/g, function (chr) {

@@ -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 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}}function l(e){return e.replace(/</g,"&lt;").replace(/>/g,"&gt;")}var p=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 d(e,t,n){var r="";return r+=p(t,n,[]),t.langId&&(r+='<div class="language-id">'+t.langId+"</div>"),r+="<div class='code-container'><code>",(r=(r+=l(e)).replace(/\n*$/,""))+"</code></div></pre>"}function u(e,t,n,r){var i="",o=!!Object.keys(r).find((function(e){return!!e.includes("-")||NaN!==parseInt(e)})),a=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)}}(r);i+=p(t,r,["twoslash","lsp"]),t.langId&&(i+='<div class="language-id">'+t.langId+"</div>"),i+="<div class='code-container'><code>";var s,c=f(n.errors,(function(e){return e.line}))||new Map,d=f(n.staticQuickInfos,(function(e){return e.line}))||new Map,u=f(n.queries,(function(e){return e.line-1}))||new Map,h=0;return e.forEach((function(e,t){var n=c.get(t)||[],r=d.get(t)||[],s=u.get(t)||[];if(0===e.length&&0===t)h+=1;else if(0===e.length)h+=1,i+="\n";else{var p=o?a(t)?" highlight":" dim":"";i+="<div class='line"+p+"'>";var f=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}},c=n.filter(a(f)),l=r.filter(a(f)),p=s.filter(a(f));t=t||l.find((function(e){return e.text===(s.length&&s[0].text)}));var d,u=[].concat(c,l,p).sort((function(e,t){return(e.start||0)-(t.start||0)}));o+=u.length?function(e,t,n){void 0===n&&(n="");var r=[],i=!1;e.forEach((function(e){if("lsp"===e.classes){var t=function(e){return e.replace(/"/g,"⃟")}(e.lsp||""),o=e.lsp===n?"style=⇯border-bottom: solid 2px lightgrey;⇯":"";r.push({text:"⇍/data-lsp⇏",index:e.end}),r.push({text:"⇍data-lsp lsp=¿"+t+"¿ "+o+"⇏",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){var t,n,r;r=e.text,o=(t=o).slice(0,n=e.index)+r+t.slice(n+Math.abs(0))})),i&&(o="⇍data-err⇏"+o+"⇍/data-err⇏"),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":"#10","\n":"#13"};return e.toString().replace(/[<"'\r\n&]/g,(function(e){return"&"+t[e]+";"}))}(o)))}(u.map((function(e){var t={begin:e.start-h,end:e.start+e.length-h};return"renderedMessage"in e&&(t.classes="err"),"kind"in e&&(t.classes=e.kind),"targetString"in e&&(t.classes="lsp",t.lsp=e.text),t})),e.content,null==(d=t)?void 0:d.text):e.content.replace(/</g,"⇍").replace(/>/g,"⇏").replace(/'/g,"⇯"),i+='<span style="color: '+e.color+'">'+o+"</span>",f+=e.content.length,h+=e.content.length})),i+="</div>",h+=1}if(n.length){var g=n.map((function(e){return l(e.renderedMessage)})).join("</br>"),m=n.map((function(e){return e.code})).join("<br/>");i+='<span class="error"><span>'+g+'</span><span class="code">'+m+"</span></span>",i+='<span class="error-behind">'+g+"</span>"}s.length&&(s.forEach((function(e){switch(e.kind){case"query":var n=l(e.text),r=(d.get(t)||[]).find((function(e){return e.text===(s.length&&s[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")})),s=i.replace(/\n*$/,""),i=s.replace(/⇍/g,"&lt;").replace(/⇏/g,"&gt;").replace(/⇯/g,"&apos;"),i+=t.addTryButton?"</code><a class='playground-link' href='"+n.playgroundURL+"'>Try</a>":"</code>",i+="</div></pre>"}function f(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 h(e,t,n){var r="";return r+=p(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+'">'+l(e.content)+"</span>"})),r+="</div>")})),r=r.replace(/\n*$/,""),r+="</code></div></pre>"}var g={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."};function m(e,t,n){var r="";return r+=p(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(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 g}(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=\""+g[t]+'">'+l(t)+'</data-lsp></a>"</span>'}else r+='<span style="color: '+e.color+'">'+l(e.content)+"</span>"})),r+="</div>")})),r=r.replace(/\n*$/,""),r+="</code></div></pre>"}var y=null,v={plainTextRenderer:d,defaultShikiRenderer:h,twoslashRenderer:u,tsconfigJSONRenderer:m};exports.createShikiHighlighter=function(t){return y?Promise.resolve(y):e.getHighlighter(t).then((function(e){return y=e}))},exports.parseCodeFenceInfo=c,exports.renderCodeToHTML=function(e,t,r,i,o,a){if(!o&&!y)throw new Error("The highlighter object hasn't been initialised via `setupHighLighter` yet in shiki-twoslash");var s,l=o||y,p=c(t,(r&&"string"==typeof r?r:r.join(" "))||""),f=n({fg:l.getForegroundColor(),bg:l.getBackgroundColor()},i);try{s=l.codeToThemedTokens(e,"jsx"===t?"tsx":t)}catch(n){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 d(e,f,p.meta)+g}return t&&r.includes("twoslash")&&a?u(s,n({},f,{langId:t}),a,p.meta):t&&t.startsWith("json")&&r.includes("tsconfig")?m(s,f,p.meta):h(s,n({},f,{langId:t}),p.meta)},exports.renderers=v,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}}function l(e){return e.replace(/</g,"&lt;").replace(/>/g,"&gt;")}var p=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 d(e,t,n){var r="";return r+=p(t,n,[]),t.langId&&(r+='<div class="language-id">'+t.langId+"</div>"),r+="<div class='code-container'><code>",(r=(r+=l(e)).replace(/\n*$/,""))+"</code></div></pre>"}function u(e,t,n,r){var i="",o=!!Object.keys(r).find((function(e){return!!e.includes("-")||NaN!==parseInt(e)})),a=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)}}(r);i+=p(t,r,["twoslash","lsp"]),t.langId&&(i+='<div class="language-id">'+t.langId+"</div>"),i+="<div class='code-container'><code>";var s,c=f(n.errors,(function(e){return e.line}))||new Map,d=f(n.staticQuickInfos,(function(e){return e.line}))||new Map,u=f(n.queries,(function(e){return e.line-1}))||new Map,h=0;return e.forEach((function(e,t){var n=c.get(t)||[],r=d.get(t)||[],s=u.get(t)||[];if(0===e.length&&0===t)h+=1;else if(0===e.length)h+=1,i+="\n";else{var p=o?a(t)?" highlight":" dim":"";i+="<div class='line"+p+"'>";var f=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}},c=n.filter(a(f)),l=r.filter(a(f)),p=s.filter(a(f));t=t||l.find((function(e){return e.text===(s.length&&s[0].text)}));var d,u=[].concat(c,l,p).sort((function(e,t){return(e.start||0)-(t.start||0)}));o+=u.length?function(e,t,n){void 0===n&&(n="");var r=[],i=!1;e.forEach((function(e){if("lsp"===e.classes){var t=function(e){return e.replace(/"/g,"⃟")}(e.lsp||""),o=e.lsp===n?"style=⇯border-bottom: solid 2px lightgrey;⇯":"";r.push({text:"⇍/data-lsp⇏",index:e.end}),r.push({text:"⇍data-lsp lsp=¿"+t+"¿ "+o+"⇏",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){var t,n,r;r=e.text,o=(t=o).slice(0,n=e.index)+r+t.slice(n+Math.abs(0))})),i&&(o="⇍data-err⇏"+o+"⇍/data-err⇏"),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]+";"}))}(o)))}(u.map((function(e){var t={begin:e.start-h,end:e.start+e.length-h};return"renderedMessage"in e&&(t.classes="err"),"kind"in e&&(t.classes=e.kind),"targetString"in e&&(t.classes="lsp",t.lsp=e.text),t})),e.content,null==(d=t)?void 0:d.text):e.content.replace(/</g,"⇍").replace(/>/g,"⇏").replace(/'/g,"⇯"),i+='<span style="color: '+e.color+'">'+o+"</span>",f+=e.content.length,h+=e.content.length})),i+="</div>",h+=1}if(n.length){var g=n.map((function(e){return l(e.renderedMessage)})).join("</br>"),m=n.map((function(e){return e.code})).join("<br/>");i+='<span class="error"><span>'+g+'</span><span class="code">'+m+"</span></span>",i+='<span class="error-behind">'+g+"</span>"}s.length&&(s.forEach((function(e){switch(e.kind){case"query":var n=l(e.text),r=(d.get(t)||[]).find((function(e){return e.text===(s.length&&s[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")})),s=i.replace(/\n*$/,""),i=s.replace(/⇍/g,"&lt;").replace(/⇏/g,"&gt;").replace(/⇯/g,"&apos;"),i+=t.addTryButton?"</code><a class='playground-link' href='"+n.playgroundURL+"'>Try</a>":"</code>",i+="</div></pre>"}function f(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 h(e,t,n){var r="";return r+=p(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+'">'+l(e.content)+"</span>"})),r+="</div>")})),r=r.replace(/\n*$/,""),r+="</code></div></pre>"}var g={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."};function m(e,t,n){var r="";return r+=p(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(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 g}(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=\""+g[t]+'">'+l(t)+'</data-lsp></a>"</span>'}else r+='<span style="color: '+e.color+'">'+l(e.content)+"</span>"})),r+="</div>")})),r=r.replace(/\n*$/,""),r+="</code></div></pre>"}var y=null,v={plainTextRenderer:d,defaultShikiRenderer:h,twoslashRenderer:u,tsconfigJSONRenderer:m};exports.createShikiHighlighter=function(t){return y?Promise.resolve(y):e.getHighlighter(t).then((function(e){return y=e}))},exports.parseCodeFenceInfo=c,exports.renderCodeToHTML=function(e,t,r,i,o,a){if(!o&&!y)throw new Error("The highlighter object hasn't been initialised via `setupHighLighter` yet in shiki-twoslash");var s,l=o||y,p=c(t,(r&&"string"==typeof r?r:r.join(" "))||""),f=n({fg:l.getForegroundColor(),bg:l.getBackgroundColor()},i);try{s=l.codeToThemedTokens(e,"jsx"===t?"tsx":t)}catch(n){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 d(e,f,p.meta)+g}return t&&r.includes("twoslash")&&a?u(s,n({},f,{langId:t}),a,p.meta):t&&t.startsWith("json")&&r.includes("tsconfig")?m(s,f,p.meta):h(s,n({},f,{langId:t}),p.meta)},exports.renderers=v,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

@@ -304,3 +304,3 @@ import { getHighlighter } from 'shiki';

return htmlAttrUnReplacer(replaceTripleArrow(stripHTML(html)));
} // HTML attributes have different rules,
} // HTML attributes have different rules,

@@ -331,4 +331,4 @@ var htmlAttrReplacer = function htmlAttrReplacer(str) {

"&": "amp",
"\r": "#10",
"\n": "#13"
"\r": "#13",
"\n": "#10"
};

@@ -335,0 +335,0 @@ return text.toString().replace(/[<"'\r\n&]/g, function (chr) {

{
"name": "shiki-twoslash",
"version": "1.4.2",
"version": "1.4.3",
"license": "MIT",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/shikijs/twoslash",

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