Urara-Blog/node_modules/.pnpm-store/v3/files/23/5c8806cd134d19577a5153b0c5f80cb4d077f24b8666c32bce069b1053476f933fd6afcc8eabe88ae5e4b780dec3a12cb69567378917d101f08d070ed2d415
2022-08-14 01:14:53 +08:00

2 lines
15 KiB
Text

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@typescript/vfs");function t(){return(t=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)}function n(e){return(n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function r(e,t){return(r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function i(e,t,n){return(i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}()?Reflect.construct:function(e,t,n){var i=[null];i.push.apply(i,t);var o=new(Function.bind.apply(e,i));return n&&r(o,n.prototype),o}).apply(null,arguments)}function o(e){var t="function"==typeof Map?new Map:void 0;return(o=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,o)}function o(){return i(e,arguments,n(this).constructor)}return o.prototype=Object.create(e.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),r(o,e)})(e)}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function a(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return s(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}function l(e,t){switch(t){case"number":return+e;case"string":return e;case"boolean":return"true"===e.toLowerCase()||0===e.length}throw new p("Unknown primitive value in compiler flag","The only recognized primitives are number, string and boolean. Got "+t+" with "+e+".","This is likely a typo.")}var c=!1;try{c="undefined"!=typeof localStorage}catch(e){}var u="undefined"!=typeof process,f=c&&localStorage.getItem("DEBUG")||u&&process.env.DEBUG?console.log:function(e){return""},p=function(e){var t,n;function i(t,n,r,i){var o,s="\n## "+t+"\n\n"+n+"\n";return r&&(s+="\n"+r),i&&(s+="\n"+i),(o=e.call(this,s)||this).title=void 0,o.description=void 0,o.recommendation=void 0,o.code=void 0,o.title=t,o.description=n,o.recommendation=r,o.code=i,o}return n=e,(t=i).prototype=Object.create(n.prototype),t.prototype.constructor=t,r(t,n),i}(o(Error));function h(e){for(var t=[],n=[],r=0,i=0,o=0,s=function(s){var l=e[s],c=function(){i=r,r+=l.length+1},u=function(t){f("Removing line "+s+" for "+t),o++,e.splice(s,1),s--};if(l.includes("//")){var p=/^\s*\/\/\s*\^+( .+)?$/.exec(l),h=/^\s*\/\/\s*\^\?\s*$/.exec(l),d=/^\s*\/\/ prettier-ignore$/.exec(l),v=/^\s*\/\/\s*\^\|$/.exec(l);if(null!==h){var m=l.indexOf("^");n.push({kind:"query",offset:m,text:void 0,docs:void 0,line:s+o-1}),u("having a query")}else if(null!==p){var g=l.indexOf("^"),y=l.lastIndexOf("^")-g+1,w=p[1]?p[1].trim():"";t.push({kind:"highlight",offset:g+i,length:y,text:w,line:s+o-1,start:g}),u("having a highlight")}else if(null!==d)u("being a prettier ignore");else if(null!==v){var x=l.indexOf("^");n.push({kind:"completion",offset:x,text:void 0,docs:void 0,line:s+o-1}),u("having a completion query")}else c()}else c();a=s},a=0;a<e.length;a++)s(a);return{highlights:t,queries:n}}function d(e,t,n){var r=n.get(t.toLowerCase());if(f("Get "+e+" mapped option: "+t+" => "+r),void 0===r){var i=Array.from(n.keys());throw new p("Invalid inline compiler value","Got "+t+" for "+e+" but it is not a supported value by the TS compiler.","Allowed values: "+i.join(","))}return r}function v(e,t,n,r){f("Setting "+e+" to "+t);for(var i,o=function(){var r=i.value;if(r.name.toLowerCase()===e.toLowerCase()){switch(r.type){case"number":case"string":case"boolean":n[r.name]=l(t,r.type);break;case"list":var o=r.element.type,s=t.split(",");n[r.name]=s.map("string"==typeof o?function(e){return l(e,o)}:function(e){return d(r.name,e,o)});break;default:n[r.name]=d(r.name,t,r.type)}return{v:void 0}}},s=a(r.optionDeclarations);!(i=s()).done;){var c=o();if("object"==typeof c)return c.v}throw new p("Invalid inline compiler flag","There isn't a TypeScript compiler flag called '"+e+"'.","This is likely a typo, you can check all the compiler flags in the TSConfig reference, or check the additional Twoslash flags in the npm page for @typescript/twoslash.")}var m=/^\/\/\s?@(\w+)$/,g=/^\/\/\s?@(\w+):\s?(.+)$/,y={errors:[],noErrors:!1,showEmit:!1,showEmittedFile:void 0,noStaticSemanticInfo:!1,emit:!1,noErrorValidation:!1};exports.TwoslashError=p,exports.twoslasher=function(n,r,i){var o,s,l;void 0===i&&(i={});var c=null!=(o=i.tsModule)?o:require("typescript"),u=null!=(s=i.lzstringModule)?s:require("lz-string"),d=n,w=function(e){var t={js:"js",javascript:"js",ts:"ts",typescript:"ts",tsx:"tsx",jsx:"jsx",json:"json",jsn:"json"};if(t[e])return t[e];throw new p("Unknown TypeScript extension given to Twoslash","Received "+e+" but Twoslash only accepts: "+Object.keys(t)+" ","")}(r),x="index."+w;f("\n\nLooking at code: \n```"+w+"\n"+n+"\n```\n");var b=t({strict:!0,target:c.ScriptTarget.ES2016,allowJs:!0},null!=(l=i.defaultCompilerOptions)?l:{});!function(e){if(e.includes("// @errors "))throw new p("You have '// @errors ' (with a space)","You want '// @errors: ' (with a colon)","This is a pretty common typo");if(e.includes("// @filename "))throw new p("You have '// @filename ' (with a space)","You want '// @filename: ' (with a colon)","This is a pretty common typo")}(n);var j=(n=function(e){return(e=e.replace(/¨D/g,"$")).replace(/¨T/g,"~")}(n)).split(/\r\n?|\n/g),E=i.customTags?function(e,t){for(var n=[],r=0;r<e.length;){var i;(i=g.exec(e[r]))&&t.includes(i[1])&&(n.push({name:i[1],line:r,annotation:e[r].split("@"+i[1]+": ")[1]}),e.splice(r,1)),r++}return n}(j,i.customTags):[],S=t({},function(e){for(var n=t({},y),r=0;r<e.length;r++){var i=void 0;(i=m.exec(e[r]))?i[1]in n&&(n[i[1]]=!0,f("Setting options."+i[1]+" to true"),e.splice(r,1),r--):(i=g.exec(e[r]))&&i[1]in n&&(n[i[1]]=i[2],f("Setting options."+i[1]+" to "+i[2]),e.splice(r,1),r--)}return"errors"in n&&"string"==typeof n.errors&&(n.errors=n.errors.split(" ").map(Number),f("Setting options.error to ",n.errors)),n}(j),i.defaultOptions),T=function(e,n,r){for(var i=t({},n),o=0;o<e.length;){var s=void 0;if(s=m.exec(e[o]))i[s[1]]=!0,v(s[1],"true",i,r);else{if(!(s=g.exec(e[o]))){o++;continue}if("filename"===s[1]){o++;continue}v(s[1],s[2],i,r)}e.splice(o,1)}return i}(j,b,c);S.showEmittedFile||(S.showEmittedFile=T.jsx&&T.jsx===c.JsxEmit.Preserve?"index.jsx":"index.js");var O=function(){var e=require("path");return(i.vfsRoot||process.cwd()).split(e.sep).join(e.posix.sep)},k=!!i.fsMap,F=k&&i.fsMap?i.fsMap:new Map,P=k?e.createSystem(F):e.createFSBackedSystem(F,O(),c),q=k?"/":O()+"/",C=e.createVirtualTypeScriptEnvironment(P,[],c,T,i.customTransformers),A=C.languageService;n=j.join("\n");for(var I,M=[],L=[],_=[],R=function(e,t,n){for(var r,i=e.split(/\r\n?|\n/g),o=e.includes("@filename: "+t)?"global.ts":t,s=[],l=[],c=a(i);!(r=c()).done;){var u=r.value;u.includes("// @filename: ")?(l.push([n+o,s]),o=u.split("// @filename: ")[1].trim(),s=[]):s.push(u)}return l.push([n+o,s]),l.filter((function(e){return e[1].length>0&&(e[1].length>1||""!==e[1][0])}))}(n,x,q),$=["js","jsx","ts","tsx"],D=R.map((function(e){return e[0]})),U=function(){var e=I.value,t=e[0],n=e[1],r=t.split(".").pop()||"",i=T.resolveJsonModule&&"json"===r;if(!$.includes(r)&&!i)return"continue";var o=n.join("\n");C.createFile(t,o);var s=h(n);_=_.concat(s.highlights);var a=s.queries.map((function(e,n){var r=C.getSourceFile(t),i=c.getPositionOfLineAndCharacter(r,e.line,e.offset);switch(e.kind){case"query":var o=A.getQuickInfoAtPosition(t,i);if(!o||!o.displayParts)throw new p("Invalid QuickInfo query","The request on line "+e.line+" in "+t+" for quickinfo via ^? returned no from the compiler.","This is likely that the x positioning is off.");return{kind:"query",text:o.displayParts.map((function(e){return e.text})).join(""),docs:o.documentation?o.documentation.map((function(e){return e.text})).join("<br/>"):void 0,line:e.line-n,offset:e.offset,file:t};case"completion":var s=A.getCompletionsAtPosition(t,i-1,{});if(!s&&!S.noErrorValidation)throw new p("Invalid completion query","The request on line "+e.line+" in "+t+" for completions via ^| returned no completions from the compiler.","This is likely that the positioning is off.");var a=function(e,t){e=String(e),t=Number(t)>>>0;var n=e.slice(0,t+1).search(/\S+$/),r=e.slice(t).search(/\s/);return r<0?{word:e.slice(n),startPos:n}:{word:e.slice(n,r+t),startPos:n}}(r.text,i-1),l=r.text.slice(a.startPos,i).split(".").pop()||"";return{kind:"completions",completions:(null==s?void 0:s.entries)||[],completionPrefix:l,line:e.line-n,offset:e.offset,file:t}}}));M=M.concat(a);var l=n.join("\n");C.updateFile(t,l)},N=a(R);!(I=N()).done;)U();var B=n.split(/\r\n?|\n/g);h(B),n=B.join("\n"),S.emit&&D.forEach((function(e){var t=e.split(".").pop()||"";$.includes(t)&&A.getEmitOutput(e).outputFiles.forEach((function(e){P.writeFile(e.name,e.text)}))}));var G=[],V=[];D.forEach((function(e){var t=e.split(".").pop()||"";if($.includes(t)){S.noErrors||(G=G.concat(A.getSemanticDiagnostics(e),A.getSyntacticDiagnostics(e)));var r=C.sys.readFile(e),i=C.getSourceFile(e);if(!i)throw new p("Could not find a TypeScript sourcefile for '"+e+"' in the Twoslash vfs","It's a little hard to provide useful advice on this error. Maybe you imported something which the compiler doesn't think is a source file?","");if(!S.showEmit){for(var o,s=-1==n.indexOf(r)?0:n.indexOf(r),l=n.slice(0,s).split("\n").length-1,u=a(S.noStaticSemanticInfo?[]:function(e,t){var n=[];return function r(i){e.forEachChild(i,(function(i){if(e.isIdentifier(i)){var o=i.getStart(t,!1);n.push({span:e.createTextSpan(o,i.end-o),text:i.getText(t)})}r(i)}))}(t),n}(c,i));!(o=u()).done;){var f=o.value,h=f.span,d=A.getQuickInfoAtPosition(e,h.start);if(d&&d.displayParts){var v=d.displayParts.map((function(e){return e.text})).join(""),m=f.text,g=d.documentation?d.documentation.map((function(e){return e.text})).join("\n"):void 0,y=h.start+s,w=c.createSourceFile("_.ts",n,c.ScriptTarget.ES2015),x=c.getLineAndCharacterOfPosition(w,y);V.push({text:v,docs:g,start:y,length:h.length,line:x.line,character:x.character,targetString:m})}}M.filter((function(t){return t.file===e})).forEach((function(e){var t=c.getPositionOfLineAndCharacter(i,e.line,e.offset)+s;switch(e.kind){case"query":L.push({docs:e.docs,kind:"query",start:t+s,length:e.text.length,text:e.text,offset:e.offset,line:e.line+l+1});break;case"completions":L.push({completions:e.completions,kind:"completions",start:t+s,completionsPrefix:e.completionPrefix,length:1,offset:e.offset,line:e.line+l+1})}}))}}}));var Q=G.filter((function(e){return e.file&&D.includes(e.file.fileName)}));!S.noErrorValidation&&Q.length&&function(e,t,n,r,i){var o=e.filter((function(e){return!t.errors.includes(e.code)})),s=Array.from(new Set(o.map((function(e){return e.code})))).join(" ");if(o.length){var a=new Set(e.map((function(e){return e.code}))),l="// @errors: "+Array.from(a).join(" "),c=t.errors.length?"\nThe existing annotation specified "+t.errors.join(" "):"\nExpected: "+l,u={},f=[];o.forEach((function(e){var t,n=(null==(t=e.file)?void 0:t.fileName)&&e.file.fileName.replace(i,"");if(n){var r=u[n];r?r.push(e):u[n]=[e]}else f.push(e)}));var h=function(e,t){return e+"\n "+t.map((function(e){return"["+e.code+"] "+e.start+" - "+("string"==typeof e.messageText?e.messageText:e.messageText.messageText)})).join("\n ")},d=[];f.length&&d.push(h("Ambient Errors",f)),Object.keys(u).forEach((function(e){d.push(h(e,u[e]))}));var v=d.join("\n\n"),m=new p("Errors were thrown in the sample, but not included in an errors tag","These errors were not marked as being expected: "+s+". "+c,"Compiler Errors:\n\n"+v);throw m.code="## Code\n\n'''"+n+"\n"+r+"\n'''",m}}(Q,S,r,d,q);for(var Y,z=[],J=a(Q);!(Y=J()).done;){var H=Y.value,K=C.sys.readFile(H.file.fileName),W=n.indexOf(K),X=c.flattenDiagnosticMessageText(H.messageText,"\n"),Z="err-"+H.code+"-"+H.start+"-"+H.length,ee=c.getLineAndCharacterOfPosition(H.file,H.start);z.push({category:H.category,code:H.code,length:H.length,start:H.start?H.start+W:void 0,line:ee.line,character:ee.character,renderedMessage:X,id:Z})}if(S.showEmit){var te=S.showEmittedFile||x,ne=q+te.replace(".jsx","").replace(".js","").replace(".d.ts","").replace(".map",""),re=D.find((function(e){return e===ne+".ts"||e===ne+".tsx"}));if(!re&&!T.outFile){var ie=D.join(", ");throw new p("Could not find source file to show the emit for","Cannot find the corresponding **source** file "+te+" for completions via ^| returned no quickinfo from the compiler.","Looked for: "+ne+" in the vfs - which contains: "+ie)}T.outFile&&(re=D[0]);var oe=A.getEmitOutput(re),se=oe.outputFiles.find((function(e){return e.name===q+S.showEmittedFile||e.name===S.showEmittedFile}));if(!se){var ae=oe.outputFiles.map((function(e){return e.name})).join(", ");throw new p("Cannot find the output file in the Twoslash VFS","Looking for "+S.showEmittedFile+" in the Twoslash vfs after compiling",'Looked for" '+(q+S.showEmittedFile)+" in the vfs - which contains "+ae+".")}n=se.text,r=se.name.split(".").pop(),_=[],M=[],V=[]}var le="https://www.typescriptlang.org/play/#code/"+u.compressToEncodedURIComponent(d),ce="// ---cut---\n";if(n.includes(ce)){var ue=n.indexOf(ce)+ce.length,fe=n.substr(0,ue).split("\n").length-1;n=n.split(ce).pop(),V.forEach((function(e){e.start-=ue,e.line-=fe})),V=V.filter((function(e){return e.start>-1})),z.forEach((function(e){e.start&&(e.start-=ue),e.line&&(e.line-=fe)})),z=z.filter((function(e){return e.start&&e.start>-1})),_.forEach((function(e){e.start-=ue,e.line-=fe})),_=_.filter((function(e){return e.start>-1})),L.forEach((function(e){return e.line-=fe})),L=L.filter((function(e){return e.line>-1})),E.forEach((function(e){return e.line-=fe})),E=E.filter((function(e){return e.line>-1}))}if(n.includes("// ---cut-after---\n")){var pe=n.indexOf("// ---cut-after---\n")+"// ---cut-after---\n".length,he=n.substr(0,pe).split("\n").length-1;n=n.split("// ---cut-after---\n").shift().trimEnd(),V=V.filter((function(e){return e.line<he})),z=z.filter((function(e){return e.line&&e.line<he})),_=_.filter((function(e){return e.line<he})),L=L.filter((function(e){return e.line<he})),E=E.filter((function(e){return e.line<he}))}return{code:n,extension:r,highlights:_,queries:L,staticQuickInfos:V,errors:z,playgroundURL:le,tags:E}};
//# sourceMappingURL=twoslash.cjs.production.min.js.map