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

remark-shiki-twoslash

Package Overview
Dependencies
Maintainers
3
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-shiki-twoslash - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

CHANGELOG.md

9

dist/remark-shiki-twoslash.cjs.development.js

@@ -1116,3 +1116,10 @@ 'use strict';

var code = node.value;
var fence = parseFence([node.lang, node.meta].filter(Boolean).join(" "));
var fence = parseFence([node.lang, node.meta].filter(Boolean).join(" ")); // Do nothing if the node has an attribute to ignore
if (Object.keys(fence.meta).filter(function (key) {
return (twoslashSettings.ignoreCodeblocksWithCodefenceMeta || []).includes(key);
}).length > 0) {
return;
}
var twoslash;

@@ -1119,0 +1126,0 @@

2

dist/remark-shiki-twoslash.cjs.production.min.js

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=(t=require("unist-util-visit"))&&"object"==typeof t&&"default"in t?t.default:t,r=require("fenceparser"),n=require("shiki"),o=require("shiki-twoslash"),i=require("@typescript/twoslash");function a(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function s(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function s(t){a(i,n,o,s,c,"next",t)}function c(t){a(i,n,o,s,c,"throw",t)}s(void 0)}))}}function c(){return(c=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function u(t,e){return t(e={exports:{}},e.exports),e.exports}var l=u((function(t){var e=function(t){var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=Object.create((e&&e.prototype instanceof h?e:h).prototype),i=new k(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=x(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,i),o}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function h(){}function f(){}function p(){}var d={};d[o]=function(){return this};var v=Object.getPrototypeOf,m=v&&v(v(L([])));m&&m!==e&&r.call(m,o)&&(d=m);var g=p.prototype=h.prototype=Object.create(d);function y(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){var n;this._invoke=function(o,i){function a(){return new e((function(n,a){!function n(o,i,a,s){var c=u(t[o],t,i);if("throw"!==c.type){var l=c.arg,h=l.value;return h&&"object"==typeof h&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(h).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,s)}))}s(c.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}function x(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,x(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function b(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(b,this),this.reset(!0)}function L(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:j}}function j(){return{value:void 0,done:!0}}return f.prototype=g.constructor=p,p.constructor=f,f.displayName=s(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===f||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,s(t,a,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},y(w.prototype),w.prototype[i]=function(){return this},t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new w(c(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},y(g),s(g,a,"Generator"),g[o]=function(){return this},g.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=L,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:L(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}})),h=function(t,e,r){var n="<pre><code>"+r+"</code></pre>";r instanceof i.TwoslashError?n=function(t){return"\n<h3>"+t.title+"</h3>\n<p>"+t.description.replace(/(?:\r\n|\r|\n)/g,"<br>")+"</p>\n<code>"+t.recommendation.replace(/(?:\r\n|\r|\n)/g,"<br>")+"</code>\n"}(r):r instanceof Error&&(n=function(t){return"<pre><code>"+t.message.split("## Code")[0]+"</code></pre>"}(r));var o="\n <a href='#twoslash-error'><div class='twoslash-fixed-error-note'><span class='twoslash-error-color'></span>Twoslash failure</div></a>\n <div class='twoslash-exception-message'>"+n+"<p>Raising Code:</p><pre class='twoslash-exception-code'><code>"+t+"</code></pre></div>";e.type="html",e.value='<div id=\'twoslash-error\'><style>\n@import url(\'http://fonts.cdnfonts.com/css/caslon-os\'); \n\n.twoslash-fixed-error-note { \n position: fixed;\n top: 20px;\n right: 20px;\n display: flex;\n align-items: center;\n padding: .25rem .75rem;\n color: black;\n background-color: #FCF3D9;\n background-clip: padding-box;\n border-bottom: 1px solid rgba(0,0,0,.05);\n border-radius: .25rem;\n font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";\n } \n\n #__docusaurus .twoslash-fixed-error-note {\n top: 80px;\n }\n\n .twoslash-fixed-error-note:hover {\n border-bottom: 1px solid rgba(226, 61, 30, 0.8);\n }\n\n .twoslash-error-color {\n background-color: #E23D1E;\n width: 18px;\n height: 18px;\n border-radius: 9px;\n margin-right: 10px;\n color: black;\n }\n\n.twoslash-exception-message { \n font-family: \'Caslon OS\', sans-serif; \n background-color: #FCF3D9;\n font-size: 1.1rem;\n padding: 2rem;\n border-left: 2px solid #E23D1E;\n}\n\n.twoslash-exception-message p {\n margin-top: 1rem;\n margin-bottom: 0.6rem;\n}\n\n.twoslash-exception-message h3 { \n margin-top: 0.6rem;\n margin-bottom: 0.3rem;\n font-size: 1.8rem;\n}\n\n.twoslash-exception-message code {\n white-space: pre-wrap;\n font-family: "JetBrains Mono", Menlo, Monaco, Consolas, Courier New, monospace;\n margin-bottom: 20px;\n background-color: #FCF3D9;\n color: black;\n border: none;\n padding-left: 0;\n }\n\n .twoslash-exception-message > code {\n display: block;\n margin-bottom: 1.5rem;\n margin-top: 3rem;\n }\n\n.twoslash-exception-code {\n border-left: 2px solid #E5A604;\n padding-left: 20px;\n background-color: #FCF3D9;\n color: black;\n}\n</style>'+o+"</div>",e.children=[]},f=new Map;function p(t,e,r,n,i){var a,s={json5:"json"};if(s[e.lang]&&(e.lang=s[e.lang]),"twoslash"===e.lang){if(!e.meta.include||"string"!=typeof e.meta.include)throw new Error("A twoslash code block needs a pragma like 'twoslash include [name]'");!function(t,e,r){var n=[];r.split("\n").forEach((function(r,o){var i=r.trim();if(i.startsWith("// - ")){var a=i.split("// - ")[1].split(" ")[0];t.set(e+"-"+a,n.join("\n"))}else n.push(r)})),t.set(e,n.join("\n"))}(f,e.meta.include,t),a=i.wrapFragments?'<div class="shiki-twoslash-fragment"></div>':""}else a=r.map((function(r){var a=r.customName.split("/").pop().replace(".json","");return o.renderCodeToHTML(t,e.lang,e.meta,c({themeName:a},i),r,n)})).join("\n"),r.length>1&&i.wrapFragments&&(a='<div class="shiki-twoslash-fragment">'+a+"</div>");return a}var d=function(t,e,r){var n=e.lang;if(void 0===r&&(r={}),!(process&&process.env&&process.env.TWOSLASH_DISABLE)&&e.meta.twoslash)return function(t,e,r){try{require("crypto")}catch(n){return o.runTwoSlash(t,e,r)}var n=require("crypto").createHash,i=require("fs"),a=i.readFileSync,s=i.existsSync,c=i.mkdirSync,u=i.writeFileSync,l=require("path").join,h=n("sha1").update(t).digest("hex"),f=l(__dirname,"..","..",".cache","twoslash"),p=l(f,h+".json");if(s(p))return JSON.parse(a(p,"utf8"));var d=o.runTwoSlash(t,e,r);return s(f)||c(f,{recursive:!0}),u(p,JSON.stringify(d),"utf8"),d}(function(t,e){for(var r,n=/\/\/ @include: (.*)$/gm,o=[];null!==(r=n.exec(e));){r.index===n.lastIndex&&n.lastIndex++;var i=r[1],a=t.get(i);if(!a){var s="Could not find an include with the key: '"+i+"'.\nThere is: "+Array.from(t.keys())+".";throw new Error(s)}o.push([r.index,r[0].length,a])}var c=e.toString();return o.reverse().forEach((function(t){c=c.substring(0,t[0])+t[2]+c.substring(t[0]+t[1])})),c}(f,t),n,r)},v=new Map,m=function(t){return Promise.all((t.themes||(t.theme?[t.theme]:["light-plus"])).map(function(){var e=s(l.mark((function e(r){var o,i;return l.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=r.name||r,e.next=3,n.getHighlighter(c({},t,{theme:r,themes:void 0}));case 3:return(i=e.sent).customName=o,e.abrupt("return",i);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()))},g=function(t){if(!t.vfsRoot)try{t.vfsRoot=require("path").join(__dirname,"..","..","..")}catch(t){}},y=function(){return f.clear()},w=function(t){var e,n=r.lex(t),o=n[0],i=n.slice(1);if("twoslash"===o){var a=i.indexOf("include");-1!==a&&i.splice(a+1,0,"=")}var s=null!=(e=r.parse(i))?e:{};return{lang:(o||"").toString(),meta:s}},x=function(t,e){return void 0===e&&(e={}),function(r){var n,o=r.value,i=w([r.lang,r.meta].filter(Boolean).join(" "));try{n=d(o,i,e)}catch(t){var a=process&&process.env&&!!process.env.CI,s="undefined"==typeof jest;if(a&&s||e.alwayRaiseForTwoslashExceptions)throw t;return h(o,r,t)}n&&(r.value=n.code,r.lang=n.extension,r.twoslash=n);var c=p(r.value,i,t,n,e);r.type="html",r.value=c,r.children=[]}},b=function(){var t=s(l.mark((function t(e){return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===e&&(e={}),g(e),y(),v.has(e)||v.set(e,m(e)),t.next=6,v.get(e);case 6:return t.abrupt("return",{settings:e,highlighters:t.sent});case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();exports.default=function(t){return void 0===t&&(t={}),g(t),v.has(t)||v.set(t,m(t)),function(){var r=s(l.mark((function r(n){var o;return l.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,v.get(t);case 2:o=r.sent,y(),e(n,"code",x(o,t));case 5:case"end":return r.stop()}}),r)})));return function(t){return r.apply(this,arguments)}}()},exports.highlightersFromSettings=m,exports.remarkVisitor=x,exports.runTwoSlashOnNode=d,exports.setupForFile=b,exports.transformAttributesToHTML=function(t,e,r,n){var o=w(e),i=d(t,o,n);return p(i&&i.code||t,o,r,i,n)};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=(t=require("unist-util-visit"))&&"object"==typeof t&&"default"in t?t.default:t,r=require("fenceparser"),n=require("shiki"),o=require("shiki-twoslash"),i=require("@typescript/twoslash");function a(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function s(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function s(t){a(i,n,o,s,c,"next",t)}function c(t){a(i,n,o,s,c,"throw",t)}s(void 0)}))}}function c(){return(c=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function u(t,e){return t(e={exports:{}},e.exports),e.exports}var l=u((function(t){var e=function(t){var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=Object.create((e&&e.prototype instanceof h?e:h).prototype),i=new k(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=x(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=u(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,i),o}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function h(){}function f(){}function p(){}var d={};d[o]=function(){return this};var v=Object.getPrototypeOf,m=v&&v(v(L([])));m&&m!==e&&r.call(m,o)&&(d=m);var g=p.prototype=h.prototype=Object.create(d);function y(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){var n;this._invoke=function(o,i){function a(){return new e((function(n,a){!function n(o,i,a,s){var c=u(t[o],t,i);if("throw"!==c.type){var l=c.arg,h=l.value;return h&&"object"==typeof h&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(h).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,s)}))}s(c.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}function x(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,x(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=u(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function b(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(b,this),this.reset(!0)}function L(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:j}}function j(){return{value:void 0,done:!0}}return f.prototype=g.constructor=p,p.constructor=f,f.displayName=s(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===f||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,s(t,a,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},y(w.prototype),w.prototype[i]=function(){return this},t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new w(c(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},y(g),s(g,a,"Generator"),g[o]=function(){return this},g.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=L,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:L(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}})),h=function(t,e,r){var n="<pre><code>"+r+"</code></pre>";r instanceof i.TwoslashError?n=function(t){return"\n<h3>"+t.title+"</h3>\n<p>"+t.description.replace(/(?:\r\n|\r|\n)/g,"<br>")+"</p>\n<code>"+t.recommendation.replace(/(?:\r\n|\r|\n)/g,"<br>")+"</code>\n"}(r):r instanceof Error&&(n=function(t){return"<pre><code>"+t.message.split("## Code")[0]+"</code></pre>"}(r));var o="\n <a href='#twoslash-error'><div class='twoslash-fixed-error-note'><span class='twoslash-error-color'></span>Twoslash failure</div></a>\n <div class='twoslash-exception-message'>"+n+"<p>Raising Code:</p><pre class='twoslash-exception-code'><code>"+t+"</code></pre></div>";e.type="html",e.value='<div id=\'twoslash-error\'><style>\n@import url(\'http://fonts.cdnfonts.com/css/caslon-os\'); \n\n.twoslash-fixed-error-note { \n position: fixed;\n top: 20px;\n right: 20px;\n display: flex;\n align-items: center;\n padding: .25rem .75rem;\n color: black;\n background-color: #FCF3D9;\n background-clip: padding-box;\n border-bottom: 1px solid rgba(0,0,0,.05);\n border-radius: .25rem;\n font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";\n } \n\n #__docusaurus .twoslash-fixed-error-note {\n top: 80px;\n }\n\n .twoslash-fixed-error-note:hover {\n border-bottom: 1px solid rgba(226, 61, 30, 0.8);\n }\n\n .twoslash-error-color {\n background-color: #E23D1E;\n width: 18px;\n height: 18px;\n border-radius: 9px;\n margin-right: 10px;\n color: black;\n }\n\n.twoslash-exception-message { \n font-family: \'Caslon OS\', sans-serif; \n background-color: #FCF3D9;\n font-size: 1.1rem;\n padding: 2rem;\n border-left: 2px solid #E23D1E;\n}\n\n.twoslash-exception-message p {\n margin-top: 1rem;\n margin-bottom: 0.6rem;\n}\n\n.twoslash-exception-message h3 { \n margin-top: 0.6rem;\n margin-bottom: 0.3rem;\n font-size: 1.8rem;\n}\n\n.twoslash-exception-message code {\n white-space: pre-wrap;\n font-family: "JetBrains Mono", Menlo, Monaco, Consolas, Courier New, monospace;\n margin-bottom: 20px;\n background-color: #FCF3D9;\n color: black;\n border: none;\n padding-left: 0;\n }\n\n .twoslash-exception-message > code {\n display: block;\n margin-bottom: 1.5rem;\n margin-top: 3rem;\n }\n\n.twoslash-exception-code {\n border-left: 2px solid #E5A604;\n padding-left: 20px;\n background-color: #FCF3D9;\n color: black;\n}\n</style>'+o+"</div>",e.children=[]},f=new Map;function p(t,e,r,n,i){var a,s={json5:"json"};if(s[e.lang]&&(e.lang=s[e.lang]),"twoslash"===e.lang){if(!e.meta.include||"string"!=typeof e.meta.include)throw new Error("A twoslash code block needs a pragma like 'twoslash include [name]'");!function(t,e,r){var n=[];r.split("\n").forEach((function(r,o){var i=r.trim();if(i.startsWith("// - ")){var a=i.split("// - ")[1].split(" ")[0];t.set(e+"-"+a,n.join("\n"))}else n.push(r)})),t.set(e,n.join("\n"))}(f,e.meta.include,t),a=i.wrapFragments?'<div class="shiki-twoslash-fragment"></div>':""}else a=r.map((function(r){var a=r.customName.split("/").pop().replace(".json","");return o.renderCodeToHTML(t,e.lang,e.meta,c({themeName:a},i),r,n)})).join("\n"),r.length>1&&i.wrapFragments&&(a='<div class="shiki-twoslash-fragment">'+a+"</div>");return a}var d=function(t,e,r){var n=e.lang;if(void 0===r&&(r={}),!(process&&process.env&&process.env.TWOSLASH_DISABLE)&&e.meta.twoslash)return function(t,e,r){try{require("crypto")}catch(n){return o.runTwoSlash(t,e,r)}var n=require("crypto").createHash,i=require("fs"),a=i.readFileSync,s=i.existsSync,c=i.mkdirSync,u=i.writeFileSync,l=require("path").join,h=n("sha1").update(t).digest("hex"),f=l(__dirname,"..","..",".cache","twoslash"),p=l(f,h+".json");if(s(p))return JSON.parse(a(p,"utf8"));var d=o.runTwoSlash(t,e,r);return s(f)||c(f,{recursive:!0}),u(p,JSON.stringify(d),"utf8"),d}(function(t,e){for(var r,n=/\/\/ @include: (.*)$/gm,o=[];null!==(r=n.exec(e));){r.index===n.lastIndex&&n.lastIndex++;var i=r[1],a=t.get(i);if(!a){var s="Could not find an include with the key: '"+i+"'.\nThere is: "+Array.from(t.keys())+".";throw new Error(s)}o.push([r.index,r[0].length,a])}var c=e.toString();return o.reverse().forEach((function(t){c=c.substring(0,t[0])+t[2]+c.substring(t[0]+t[1])})),c}(f,t),n,r)},v=new Map,m=function(t){return Promise.all((t.themes||(t.theme?[t.theme]:["light-plus"])).map(function(){var e=s(l.mark((function e(r){var o,i;return l.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=r.name||r,e.next=3,n.getHighlighter(c({},t,{theme:r,themes:void 0}));case 3:return(i=e.sent).customName=o,e.abrupt("return",i);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()))},g=function(t){if(!t.vfsRoot)try{t.vfsRoot=require("path").join(__dirname,"..","..","..")}catch(t){}},y=function(){return f.clear()},w=function(t){var e,n=r.lex(t),o=n[0],i=n.slice(1);if("twoslash"===o){var a=i.indexOf("include");-1!==a&&i.splice(a+1,0,"=")}var s=null!=(e=r.parse(i))?e:{};return{lang:(o||"").toString(),meta:s}},x=function(t,e){return void 0===e&&(e={}),function(r){var n=r.value,o=w([r.lang,r.meta].filter(Boolean).join(" "));if(!(Object.keys(o.meta).filter((function(t){return(e.ignoreCodeblocksWithCodefenceMeta||[]).includes(t)})).length>0)){var i;try{i=d(n,o,e)}catch(t){var a=process&&process.env&&!!process.env.CI,s="undefined"==typeof jest;if(a&&s||e.alwayRaiseForTwoslashExceptions)throw t;return h(n,r,t)}i&&(r.value=i.code,r.lang=i.extension,r.twoslash=i);var c=p(r.value,o,t,i,e);r.type="html",r.value=c,r.children=[]}}},b=function(){var t=s(l.mark((function t(e){return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===e&&(e={}),g(e),y(),v.has(e)||v.set(e,m(e)),t.next=6,v.get(e);case 6:return t.abrupt("return",{settings:e,highlighters:t.sent});case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();exports.default=function(t){return void 0===t&&(t={}),g(t),v.has(t)||v.set(t,m(t)),function(){var r=s(l.mark((function r(n){var o;return l.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,v.get(t);case 2:o=r.sent,y(),e(n,"code",x(o,t));case 5:case"end":return r.stop()}}),r)})));return function(t){return r.apply(this,arguments)}}()},exports.highlightersFromSettings=m,exports.remarkVisitor=x,exports.runTwoSlashOnNode=d,exports.setupForFile=b,exports.transformAttributesToHTML=function(t,e,r,n){var o=w(e),i=d(t,o,n);return p(i&&i.code||t,o,r,i,n)};
//# sourceMappingURL=remark-shiki-twoslash.cjs.production.min.js.map

@@ -1110,3 +1110,10 @@ import visit from 'unist-util-visit';

var code = node.value;
var fence = parseFence([node.lang, node.meta].filter(Boolean).join(" "));
var fence = parseFence([node.lang, node.meta].filter(Boolean).join(" ")); // Do nothing if the node has an attribute to ignore
if (Object.keys(fence.meta).filter(function (key) {
return (twoslashSettings.ignoreCodeblocksWithCodefenceMeta || []).includes(key);
}).length > 0) {
return;
}
var twoslash;

@@ -1113,0 +1120,0 @@

{
"name": "remark-shiki-twoslash",
"version": "2.0.1",
"version": "2.0.2",
"license": "MIT",

@@ -29,3 +29,3 @@ "homepage": "https://github.com/shikijs/twoslash",

"dependencies": {
"@typescript/twoslash": "2.1.0",
"@typescript/twoslash": "2.2.0",
"@typescript/vfs": "1.3.4",

@@ -35,3 +35,3 @@ "fenceparser": "^1.1.0",

"shiki": "0.9.3",
"shiki-twoslash": "2.0.3",
"shiki-twoslash": "2.1.0",
"tslib": "2.1.0",

@@ -38,0 +38,0 @@ "typescript": ">3",

@@ -434,2 +434,17 @@ ### remark-shiki-twoslash

### Using your own VS Code theme with Shiki Twoslash
Every theme from VS Code comes down to a set of `.json` files which are what you pass to shiki. For example, we'll use the theme ["Pop 'n Lock'](https://vscodethemes.com/e/Luxcium.pop-n-lock-theme-vscode). If you look in [`/src/themes`](https://github.com/Luxcium/pop-n-lock-theme-vscode/blob/master/src/themes/) you'll see many theme JSON files. These are what you pass to `themes`.
It's not normal for these themes to be available as npm modules, so you'll need to download the JSON (and handle the licensing!) into your project. Then set your settings like:
```ts
{
remarkPlugins: [[remarkShikiTwoslash, {
themes: [
"vendor/pop-n-lock/Pop-N-Lock.json", "vendor/pop-n-lock/Pop-N-Lock.alexis-black.json"}]
],
}
```
### Editor Experience

@@ -436,0 +451,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc