11 lines
47 KiB
JavaScript
11 lines
47 KiB
JavaScript
|
"use strict";var q=Object.defineProperty;var V=(t,e,n)=>e in t?q(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var L=(t,e,n)=>V(t,typeof e!="symbol"?e+"":e,n);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const obsidian=require("obsidian"),equalFn=(t,e)=>t===e,$PROXY=Symbol("solid-proxy"),$TRACK=Symbol("solid-track"),signalOptions={equals:equalFn};let runEffects=runQueue;const STALE=1,PENDING=2,UNOWNED={owned:null,cleanups:null,context:null,owner:null};var Owner=null;let Transition=null,ExternalSourceConfig=null,Listener=null,Updates=null,Effects=null,ExecCount=0;function createRoot(t,e){const n=Listener,o=Owner,s=t.length===0,i=e===void 0?o:e,a=s?UNOWNED:{owned:null,cleanups:null,context:i?i.context:null,owner:i},c=s?t:()=>t(()=>untrack(()=>cleanNode(a)));Owner=a,Listener=null;try{return runUpdates(c,!0)}finally{Listener=n,Owner=o}}function createSignal(t,e){e=e?Object.assign({},signalOptions,e):signalOptions;const n={value:t,observers:null,observerSlots:null,comparator:e.equals||void 0},o=s=>(typeof s=="function"&&(s=s(n.value)),writeSignal(n,s));return[readSignal.bind(n),o]}function createRenderEffect(t,e,n){const o=createComputation(t,e,!1,STALE);updateComputation(o)}function createEffect(t,e,n){runEffects=runUserEffects;const o=createComputation(t,e,!1,STALE);o.user=!0,Effects?Effects.push(o):updateComputation(o)}function createMemo(t,e,n){n=n?Object.assign({},signalOptions,n):signalOptions;const o=createComputation(t,e,!0,0);return o.observers=null,o.observerSlots=null,o.comparator=n.equals||void 0,updateComputation(o),readSignal.bind(o)}function batch(t){return runUpdates(t,!1)}function untrack(t){if(Listener===null)return t();const e=Listener;Listener=null;try{return t()}finally{Listener=e}}function onMount(t){createEffect(()=>untrack(t))}function onCleanup(t){return Owner===null||(Owner.cleanups===null?Owner.cleanups=[t]:Owner.cleanups.push(t)),t}function getListener(){return Listener}function readSignal(){if(this.sources&&this.state)if(this.state===STALE)updateComputation(this);else{const t=Updates;Updates=null,runUpdates(()=>lookUpstream(this),!1),Updates=t}if(Listener){const t=this.observers?this.observers.length:0;Listener.sources?(Listener.sources.push(this),Listener.sourceSlots.push(t)):(Listener.sources=[this],Listener.sourceSlots=[t]),this.observers?(this.observers.push(Listener),this.observerSlots.push(Listener.sources.length-1)):(this.observers=[Listener],this.observerSlots=[Listener.sources.length-1])}return this.value}function writeSignal(t,e,n){let o=t.value;return(!t.comparator||!t.comparator(o,e))&&(t.value=e,t.observers&&t.observers.length&&runUpdates(()=>{for(let s=0;s<t.observers.length;s+=1){const i=t.observers[s],a=Transition&&Transition.running;a&&Transition.disposed.has(i),(a?!i.tState:!i.state)&&(i.pure?Updates.push(i):Effects.push(i),i.observers&&markDownstream(i)),a||(i.state=STALE)}if(Updates.length>1e6)throw Updates=[],new Error},!1)),e}function updateComputation(t){if(!t.fn)return;cleanNode(t);const e=ExecCount;runComputation(t,t.value,e)}function runComputation(t,e,n){let o;const s=Owner,i=Listener;Listener=Owner=t;try{o=t.fn(e)}catch(a){return t.pure&&(t.state=STALE,t.owned&&t.owned.forEach(cleanNode),t.owned=null),t.updatedAt=n+1,handleError(a)}finally{Listener=i,Owner=s}(!t.updatedAt||t.updatedAt<=n)&&(t.updatedAt!=null&&"observers"in t?writeSignal(t,o):t.value=o,t.updatedAt=n)}function createComputation(t,e,n,o=STALE,s){const i={fn:t,state:o,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:e,owner:Owner,context:Owner?Owner.context:null,pure:n};return Owner===null||Owner!==UNOWNED&&(Owner.owned?Owner.owned.push(i):Owner.owned=[i]),i}function runTop(t){if(t.state===0)return;if(t.state===PENDING)return lookUpstream(t);if(t.suspense&&untrack(t.suspense.inFallback))return t.suspense.effects.push(t);const e=[t];for(;(t=t.owner)&&(!t.updatedAt||t.updatedAt<ExecCount);)t.state&&e.push(t);for(let n=e.length-1;n>=0;n--)if(t=e[n],t.state===STALE)updateComputation(t);else if(t.state===PENDING){cons
|
||
|
`))}async function go(t,e){const n=await run(t,"go");n.success?e.stdout(n.data.output):e.stderr((n.errors??[]).join(`
|
||
|
`))}const nativeGlobal=new Function("return this")(),fnRegexCheckCacheMap=new WeakMap;function isConstructable(t){const e=t.prototype&&t.prototype.constructor===t&&Object.getOwnPropertyNames(t.prototype).length>1;if(e)return!0;if(fnRegexCheckCacheMap.has(t))return fnRegexCheckCacheMap.get(t);let n=e;if(!n){const o=t.toString(),s=/^function\b\s[A-Z].*/,i=/^class\b/;n=s.test(o)||i.test(o)}return fnRegexCheckCacheMap.set(t,n),n}const naughtySafari=typeof document.all=="function"&&typeof document.all>"u",callableFnCacheMap=new WeakMap,isCallable=t=>{if(callableFnCacheMap.has(t))return!0;const e=naughtySafari?typeof t=="function"&&typeof t<"u":typeof t=="function";return e&&callableFnCacheMap.set(t,e),e},boundedMap=new WeakMap;function isBoundedFunction(t){if(boundedMap.has(t))return boundedMap.get(t);const e=t.name.indexOf("bound ")===0&&!t.hasOwnProperty("prototype");return boundedMap.set(t,e),e}const functionBoundedValueMap=new WeakMap;function getTargetValue(t,e){if(isCallable(e)&&!isBoundedFunction(e)&&!isConstructable(e)){const n=functionBoundedValueMap.get(e);if(n)return n;const o=Function.prototype.bind.call(e,t);for(const s in e)o[s]=e[s];if(e.hasOwnProperty("prototype")&&!o.hasOwnProperty("prototype")&&Object.defineProperty(o,"prototype",{value:e.prototype,enumerable:!1,writable:!0}),typeof e.toString=="function"){const s=e.hasOwnProperty("toString")&&!o.hasOwnProperty("toString"),i=o.toString===Function.prototype.toString;if(s||i){const a=Object.getOwnPropertyDescriptor(s?e:Function.prototype,"toString");Object.defineProperty(o,"toString",{...a,...a!=null&&a.get?null:{value:()=>e.toString()}})}}return functionBoundedValueMap.set(e,o),o}return e}function uniq(t){return t.filter(function(n){return n in this?!1:this[n]=!0},Object.create(null))}const rawObjectDefineProperty=Object.defineProperty,NODE_ENV=(typeof process<"u"?process.env.NODE_ENV:void 0)??"production",variableWhiteListInDev=NODE_ENV==="development"||window.__QIANKUN_DEVELOPMENT__?["__REACT_ERROR_OVERLAY_GLOBAL_HOOK__"]:[],variableWhiteList=["System","__cjsWrapper",...variableWhiteListInDev],unscopables={undefined:!0,Array:!0,Object:!0,String:!0,Boolean:!0,Math:!0,Number:!0,Symbol:!0,parseFloat:!0,Float32Array:!0,isNaN:!0,Infinity:!0,Reflect:!0,Float64Array:!0,Function:!0,Map:!0,NaN:!0,Promise:!0,Proxy:!0,Set:!0,parseInt:!0,requestAnimationFrame:!0},scopables={console};function makeScope(t,e){const n=scopables[e];t[e]=new Proxy({},{get(o,s,i){return o[s]??n[s]},set(o,s,i,a){return i===n[s]?delete o[e]:o[s]=i,!0}})}const useNativeWindowForBindingsProps=new Map([["fetch",!0],["mockDomAPIInBlackList",NODE_ENV==="test"]]);function createFakeWindow(t){const e=new Map,n={};return Object.getOwnPropertyNames(t).filter(o=>{if(o in scopables)return!0;const s=Object.getOwnPropertyDescriptor(t,o);return!(s!=null&&s.configurable)}).forEach(o=>{if(o in scopables){makeScope(n,o);return}const s=Object.getOwnPropertyDescriptor(t,o);if(s){const i=Object.prototype.hasOwnProperty.call(s,"get");(o==="top"||o==="parent"||o==="self"||o==="window"||NODE_ENV==="test"&&(o==="mockTop"||o==="mockSafariTop"))&&(s.configurable=!0,i||(s.writable=!0)),i&&e.set(o,!0),rawObjectDefineProperty(n,o,Object.freeze(s))}}),{fakeWindow:n,propertiesWithGetter:e}}let activeSandboxCount=0;class ProxySandbox{constructor(e,n=window){L(this,"updatedValueSet",new Set);L(this,"name");L(this,"proxy");L(this,"globalContext");L(this,"sandboxRunning",!0);L(this,"latestSetProp",null);this.name=e,this.globalContext=n;const{updatedValueSet:o}=this,{fakeWindow:s,propertiesWithGetter:i}=createFakeWindow(n),a=new Map,c=l=>s.hasOwnProperty(l)||n.hasOwnProperty(l),m=new Proxy(s,{set:(l,f,d)=>{if(this.sandboxRunning){if(!l.hasOwnProperty(f)&&n.hasOwnProperty(f)){const $=Object.getOwnPropertyDescriptor(n,f),{writable:C,configurable:A,enumerable:S}=$;C&&Object.defineProperty(l,f,{configurable:A,enumerable:S,writable:C,value:d})}else l[f]=d;return variableWhiteList.indexOf(f)!==-1&&(n[f]=d),o.add(f),this.latestSetProp=f,!0}return NODE_ENV==="development"&&console.warn(`[qiankun] Set window.${f.toString()} while sandbox
|
||
|
`))}typeof process<"u"&&typeof process.browser>"u"&&(process.browser=!0);const default_cdn="https://cdn.jsdelivr.net/pyodide/v0.26.2/full/",setMplTarget=t=>{t?document.pyodideMplTarget=t:delete document.pyodideMplTarget};let cache=null;const python=function(t){const e=default_cdn;if((cache==null?void 0:cache.cdn)===e)return cache.backend;let n=null,o=null,s=null;const i=async(a,c)=>{n||await s(),o=c;try{setMplTarget(c.viewEl),await n.runPythonAsync(a)}catch(m){c.stderr(m)}finally{setMplTarget(void 0)}};return i.loading=!0,s=async()=>{n=await(await urlImport(`${e}pyodide.js`,()=>window.loadPyodide))({indexURL:e,stdout:c=>o==null?void 0:o.stdout(c),stderr:c=>o==null?void 0:o.stderr(c)}),await n.loadPackage("micropip"),console.log("python loaded."),i.loading=!1},cache={cdn:e,backend:i},i}();async function csharp(t,e){const n=await run(t,"cs");n.success?e.stdout(n.data.output):e.stderr((n.errors??[]).join(`
|
||
|
`))}async function swift(t,e){const n=await run(t,"swift");n.success?e.stdout(n.data.output):e.stderr((n.errors??[]).join(`
|
||
|
`))}const url$1="https://play.vosca.dev/run";async function v(t,e){var i;const n=new FormData;n.append("code",t);const s=await(await fetch(url$1,{method:"POST",body:n})).json();((i=s.error)==null?void 0:i.length)>0?e.stderr(s.error):e.stdout(s.output)}const cdn="https://unpkg.com/@wenyan/core/index.min.js",wy=function(){let t=null,e=null;const n=async function(o,s){t||await e();const i=t.compile(o);console.log("wenyan:"),console.log(i),await js(`(async () => { ${i} })();`,s)};return n.loading=!0,e=async()=>{t=await urlImport(cdn,()=>window.Wenyan),n.loading=!1,console.log("wenyan loaded.")},n}(),url="https://play.crystal-lang.org/run_requests";async function crystal(t,e){const i=(await(await fetch(url,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({run_request:{language:"crystal",version:"1.8.2",code:t}})})).json()).run_request.run;i.stderr?e.stderr(i.stderr):e.stdout(i.stdout)}async function r(t,e){const n=await run(t,"r");n.success?e.stdout(n.data.output):e.stderr((n.errors??[]).join(`
|
||
|
`))}var _tmpl$$6=template("<div class=html-viewer><div>");async function html(t,e){render(()=>createComponent(HtmlViewer,{code:t}),e.viewEl)}const HtmlViewer=t=>{let e,n,o;return onMount(()=>{e&&(o=e.attachShadow({mode:"closed"}),o.appendChild(n))}),onCleanup(()=>{e==null||e.detach()}),(()=>{var s=_tmpl$$6(),i=s.firstChild,a=e;typeof a=="function"?use(a,s):e=s;var c=n;return typeof c=="function"?use(c,i):n=i,createRenderEffect(()=>i.innerHTML=t.code),s})()},languages={kotlin,rust,java,c:cpp,cpp,csharp,js,javascript:js,html,ts,typescript:ts,python,go,swift,v,vlang:v,wy,wenyan:wy,crystal,cr:crystal,r,R:r};function createStdio(){let t=[],e=[];const n=l=>{t=l(t);for(const f of e)f(t)},o=l=>{n(()=>l)},s=(...l)=>{const f=l.join(",");n(d=>[...d,f])},i=(...l)=>{const f=l.join(",");n(d=>[...d,f])},a=document.createElement("div");return{subscribe:l=>(e.push(l),()=>{e=e.filter(f=>f!==l)}),write:s,viewEl:a,stdout:s,stderr:i,clear:()=>{o([]),a.empty()},update:n,set:o}}const backend={...languages};var _tmpl$$5=template('<div class="setting-item mod-toggle"><div class=setting-item-info><div class=setting-item-name>Auto run</div><div class=setting-item-description>Automatically run markdown CodeBlock</div></div><div class=setting-item-control><div class=checkbox-container><input type=checkbox>');const SettingTab=t=>(()=>{var e=_tmpl$$5(),n=e.firstChild,o=n.nextSibling,s=o.firstChild,i=s.firstChild;return s.$$click=()=>t.settingsUpdate("autoRun",a=>!a),createRenderEffect(()=>s.classList.toggle("is-enabled",!!t.settings.autoRun)),createRenderEffect(()=>i.checked=t.settings.autoRun),e})();delegateEvents(["click"]);var _tmpl$$4=template("<div class=lds-ellipsis><div class=dot></div><div class=dot></div><div class=dot></div><div class=dot>");const Spin=()=>_tmpl$$4();var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function getDefaultExportFromCjs(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var md5$1={exports:{}};function commonjsRequire(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var core={exports:{}},hasRequiredCore;function requireCore(){return hasRequiredCore||(hasRequiredCore=1,function(t,e){(function(n,o){t.exports=o()})(commonjsGlobal,function(){var n=n||function(o,s){var i;if(typeof window<"u"&&window.crypto&&(i=window.crypto),typeof self<"u"&&self.crypto&&(i=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(i=globalThis.crypto),!i&&typeof window<"u"&&window.msCrypto&&(i=window.msCrypto),!i&&typeof commonjsGlobal<"u"&&commonjsGlobal.crypto&&(i=commonjsGlobal.crypto),!i&&typeof commonjsRequire=="function")try{i=require("crypto")}catch{}var a=function(){if(i){if(typeof i.getRandomValues=="function")try{return i.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof i.randomBytes=="function")try{return i.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},c=Object.create||function(){function u(){}return function(w){var b;return u.prototype=w,b=new u,u.prototype=null,b}}(),m={},l=m.lib={},f=l.Base=function(){return{extend:function(u){var w=c(this);return u&&w.mixIn(u),(!w.hasOwnProperty("init")||this.init===w.init)&&(w.init=function(){w.$super.init.apply(this,arguments)}),w.init.prototype=w,w.$super=this,w},create:function(){var u=this.extend();return u.init.apply(u,arguments),u},init:function(){},mixIn:function(u){for(var w in u)u.hasOwnProperty(w)&&(this[w]=u[w]);u.hasOwnProperty("toString")&&(this.toString=u.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),d=l.WordArray=f.extend({init:function(u,w){u=this.words=u||[],w!=s?this.sigBytes=w:this.sigBytes=u.length*4},toString:function(u){return(u||C).stringify(this)},concat:function(u){var w=this.words,b=u.words,E=this.sigBytes,x=u.sigBytes;if(this.clamp(),E%4)for(var P=0;P<x;P++){var B=b[P>>>2]>>>24-
|
||
|
`).map(i=>denormalizeBrightness(o+replaceAll(normalizeBrightness(i),s,o)+s)).join(`
|
||
|
`)},camel=(t,e)=>t+e.charAt(0).toUpperCase()+e.slice(1),stringWrappingMethods=[...colorCodes.map((t,e)=>t?[[t,30+e,Code.noColor],[camel("bg",t),40+e,Code.noBgColor]]:[]),...colorCodesLight.map((t,e)=>t?[[t,90+e,Code.noColor],[camel("bg",t),100+e,Code.noBgColor]]:[]),...["","BrightRed","BrightGreen","BrightYellow","BrightBlue","BrightMagenta","BrightCyan"].map((t,e)=>t?[["bg"+t,100+e,Code.noBgColor]]:[]),...styleCodes.map((t,e)=>t?[[t,e,t==="bright"||t==="dim"?Code.noBrightness:20+e]]:[])].reduce((t,e)=>t.concat(e)),assignStringWrappingAPI=(t,e=t)=>stringWrappingMethods.reduce((n,[o,s,i])=>O.defineProperty(n,o,{get:()=>assignStringWrappingAPI(a=>e(wrap(a,s,i)))}),t),TEXT=0,BRACKET=1,CODE=2;class Span{constructor(e,n){this.code=e,this.text=n,this.css="",this.color=void 0,this.bgColor=void 0,this.bold=void 0,this.inverse=void 0,this.italic=void 0,this.underline=void 0,this.bright=void 0,this.dim=void 0}}function*rawParse(t){const e={state:TEXT,buffer:"",text:"",code:"",codes:[]},o=splitStringToChunksOfSize(t(),1048576);for(let s=0;s<o.length;s++){const i=o[s];o[s]=void 0,yield*processChunk(i,e)}e.state!==TEXT&&(e.text+=e.buffer),e.text&&(yield new Span(new Code,e.text))}function splitStringToChunksOfSize(t,e){const n=[],o=Math.ceil(t.length/e);for(let s=0,i=0;s<o;++s,i+=e)n.push(t.substring(i,i+e));return n}function*processChunk(t,e){const n=t,o=t.length;for(let s=0;s<o;s++){const i=n[s];switch(e.buffer+=i,e.state){case TEXT:i==="\x1B"?(e.state=BRACKET,e.buffer=i):e.text+=i;break;case BRACKET:i==="["?(e.state=CODE,e.code="",e.codes=[]):(e.state=TEXT,e.text+=e.buffer);break;case CODE:if(i>="0"&&i<="9")e.code+=i;else if(i===";")e.codes.push(new Code(e.code)),e.code="";else if(i==="m"){e.code=e.code||"0";for(const a of e.codes)yield new Span(a,e.text),e.text="";yield new Span(new Code(e.code),e.text),e.text="",e.state=TEXT}else e.state=TEXT,e.text+=e.buffer}}}function*parseAnsi(t){let e=new Color,n=new Color(!0),o,s=new Set;function i(){e=new Color,n=new Color(!0),o=void 0,s.clear()}i();for(const a of t){const c=a.code;if(a.text!==""){const m=s.has("inverse"),l=s.has("underline")?"text-decoration: underline;":"",f=s.has("italic")?"font-style: italic;":"",d=o===Code.bright?"font-weight: bold;":"",$=e.defaultBrightness(o),C=new Span(a.code?a.code.clone():void 0,a.text);C.css=a.css?a.css:d+f+l+$.css(m)+n.css(m),C.bold=a.bold?a.bold:!!d,C.color=a.color?a.color:$.clean,C.bgColor=a.bgColor?a.bgColor:n.clean,C.inverse=m,C.italic=!!f,C.underline=!!l,C.bright=s.has("bright"),C.dim=s.has("dim"),yield C}if(c.isBrightness){o=c.value;continue}if(a.code.value!==void 0){if(a.code.value===Code.reset){i();continue}switch(a.code.type){case"color":case"colorLight":e=new Color(!1,c.subtype);break;case"bgColor":case"bgColorLight":n=new Color(!0,c.subtype);break;case"style":s.add(c.subtype);break;case"unstyle":s.delete(c.subtype);break}}}}class Colors{constructor(e){this.spans=e?Array.from(rawParse(typeof e=="string"?()=>e:e)):[]}get str(){return this.spans.reduce((e,n)=>e+n.text+n.code.str,"")}get parsed(){const e=new Colors;return e.spans=Array.from(parseAnsi(this.spans)),e}get asChromeConsoleLogArguments(){const e=this.parsed.spans;return[e.map(n=>"%c"+n.text).join(""),...e.map(n=>n.css)]}get browserConsoleArguments(){return this.asChromeConsoleLogArguments}static get nice(){return Colors.names.forEach(e=>{e in String.prototype||O.defineProperty(String.prototype,e,{get:function(){return Colors[e](this)}})}),Colors}static parse(e){return new Colors(e).parsed}static parseIterator(e){return parseAnsi(rawParse(typeof e=="string"?()=>e:e))}static strip(e){return e.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-PRZcf-nqry=><]/g,"")}static isEscaped(e){return e=String(e),Colors.strip(e)!==e}[Symbol.iterator](){return this.spans[Symbol.iterator]()}static get ansicolor(){return Colors}}assignStringWrappingAPI(Colors,t=>t);Colors.names=stringWrappingMethods.map(([t])=>t);Colors.rgb={black:[0,0,0],darkGray:[100,100,100],lightGray:[200,200,200],white:[255,255,255],red:[204,0,0],lightRed:[255,51,0],green:[0,204,0],lightGreen:[51,204,51
|
||
|
|
||
|
/* nosourcemap */
|