8 lines
131 KiB
JavaScript
8 lines
131 KiB
JavaScript
"use strict";var e=require("obsidian"),t=require("path"),n=require("@codemirror/view"),r=require("@codemirror/state"),i=require("@codemirror/language");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=o(t);function s(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){e.done?i(e.value):function(e){return e instanceof n?e:new n((function(t){t(e)}))}(e.value).then(a,s)}u((r=r.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class u extends Map{constructor(e={}){if(super(),!(e.maxSize&&e.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");if("number"==typeof e.maxAge&&0===e.maxAge)throw new TypeError("`maxAge` must be a number greater than 0");this.maxSize=e.maxSize,this.maxAge=e.maxAge||Number.POSITIVE_INFINITY,this.onEviction=e.onEviction,this.cache=new Map,this.oldCache=new Map,this._size=0}_emitEvictions(e){if("function"==typeof this.onEviction)for(const[t,n]of e)this.onEviction(t,n.value)}_deleteIfExpired(e,t){return"number"==typeof t.expiry&&t.expiry<=Date.now()&&("function"==typeof this.onEviction&&this.onEviction(e,t.value),this.delete(e))}_getOrDeleteIfExpired(e,t){if(!1===this._deleteIfExpired(e,t))return t.value}_getItemValue(e,t){return t.expiry?this._getOrDeleteIfExpired(e,t):t.value}_peek(e,t){const n=t.get(e);return this._getItemValue(e,n)}_set(e,t){this.cache.set(e,t),this._size++,this._size>=this.maxSize&&(this._size=0,this._emitEvictions(this.oldCache),this.oldCache=this.cache,this.cache=new Map)}_moveToRecent(e,t){this.oldCache.delete(e),this._set(e,t)}*_entriesAscending(){for(const e of this.oldCache){const[t,n]=e;if(!this.cache.has(t)){!1===this._deleteIfExpired(t,n)&&(yield e)}}for(const e of this.cache){const[t,n]=e;!1===this._deleteIfExpired(t,n)&&(yield e)}}get(e){if(this.cache.has(e)){const t=this.cache.get(e);return this._getItemValue(e,t)}if(this.oldCache.has(e)){const t=this.oldCache.get(e);if(!1===this._deleteIfExpired(e,t))return this._moveToRecent(e,t),t.value}}set(e,t,{maxAge:n=this.maxAge}={}){const r="number"==typeof n&&n!==Number.POSITIVE_INFINITY?Date.now()+n:void 0;return this.cache.has(e)?this.cache.set(e,{value:t,expiry:r}):this._set(e,{value:t,expiry:r}),this}has(e){return this.cache.has(e)?!this._deleteIfExpired(e,this.cache.get(e)):!!this.oldCache.has(e)&&!this._deleteIfExpired(e,this.oldCache.get(e))}peek(e){return this.cache.has(e)?this._peek(e,this.cache):this.oldCache.has(e)?this._peek(e,this.oldCache):void 0}delete(e){const t=this.cache.delete(e);return t&&this._size--,this.oldCache.delete(e)||t}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}resize(e){if(!(e&&e>0))throw new TypeError("`maxSize` must be a number greater than 0");const t=[...this._entriesAscending()],n=t.length-e;n<0?(this.cache=new Map(t),this.oldCache=new Map,this._size=t.length):(n>0&&this._emitEvictions(t.slice(0,n)),this.oldCache=new Map(t.slice(n)),this.cache=new Map,this._size=0),this.maxSize=e}*keys(){for(const[e]of this)yield e}*values(){for(const[,e]of this)yield e}*[Symbol.iterator](){for(const e of this.cache){const[t,n]=e;!1===this._deleteIfExpired(t,n)&&(yield[t,n.value])}for(const e of this.oldCache){const[t,n]=e;if(!this.cache.has(t)){!1===this._deleteIfExpired(t,n)&&(yield[t,n.value])}}}*entriesDescending(){let e=[...this.cache];for(let t=e.length-1;t>=0;--t){const n=e[t],[r,i]=n;!1===this._deleteIfExpired(r,i)&&(yield[r,i.value])}e=[...this.oldCache];for(let t=e.length-1;t>=0;--t){const n=e[t],[r,i]=n;if(!this.cache.has(r)){!1===this._deleteIfExpired(r,i)&&(yield[r,i.value])}}}*entriesAscending(){for(const[e,t]of this._entriesAscending())yield[e,t.value]}get size(){if(!this._size)return this.oldCache.size;let e=0;for(const t of this.oldCache.keys())this.cache.has(t)||e++;return Math.min(this._size+e,this.maxSize)}entries(){return this.entriesAscending()}forEach(e,t=this){for(const[n,r]of this.entriesAscending())e.call(t,r,n,this)}get[Symbol.toStringTag](){return JSON.stringify([...this.entries
|
|||
|
|
/*!
|
||
|
|
* Determine if an object is a Buffer
|
||
|
|
*
|
||
|
|
* @author Feross Aboukhadijeh <https://feross.org>
|
||
|
|
* @license MIT
|
||
|
|
*/;var Kt=function(e){return null!=e&&null!=e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},Xt=Object.prototype.hasOwnProperty,en=Object.prototype.toString,tn=Object.defineProperty,nn=Object.getOwnPropertyDescriptor,rn=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===en.call(e)},on=function(e){if(!e||"[object Object]"!==en.call(e))return!1;var t,n=Xt.call(e,"constructor"),r=e.constructor&&e.constructor.prototype&&Xt.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!n&&!r)return!1;for(t in e);return void 0===t||Xt.call(e,t)},an=function(e,t){tn&&"__proto__"===t.name?tn(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},sn=function(e,t){if("__proto__"===t){if(!Xt.call(e,t))return;if(nn)return nn(e,t).value}return e[t]},un=function e(){var t,n,r,i,o,a,s=arguments[0],u=1,c=arguments.length,l=!1;for("boolean"==typeof s&&(l=s,s=arguments[1]||{},u=2),(null==s||"object"!=typeof s&&"function"!=typeof s)&&(s={});u<c;++u)if(null!=(t=arguments[u]))for(n in t)r=sn(s,n),s!==(i=sn(t,n))&&(l&&i&&(on(i)||(o=rn(i)))?(o?(o=!1,a=r&&rn(r)?r:[]):a=r&&on(r)?r:{},an(s,{name:n,newValue:e(l,a,i)})):void 0!==i&&an(s,{name:n,newValue:i}));return s},cn=e=>{if("[object Object]"!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype},ln=[].slice,fn=function(e,t){var n;return function(){var t,o=ln.call(arguments,0),a=e.length>o.length;a&&o.push(r);try{t=e.apply(null,o)}catch(e){if(a&&n)throw e;return r(e)}a||(t&&"function"==typeof t.then?t.then(i,r):t instanceof Error?r(t):i(t))};function r(){n||(n=!0,t.apply(null,arguments))}function i(e){r(null,e)}};var dn=pn;pn.wrap=fn;var hn=[].slice;function pn(){var e=[],t={run:function(){var t=-1,n=hn.call(arguments,0,-1),r=arguments[arguments.length-1];if("function"!=typeof r)throw new Error("Expected function as last argument, not "+r);(function i(o){var a=e[++t],s=hn.call(arguments,0).slice(1),u=n.length,c=-1;if(o)r(o);else{for(;++c<u;)null!==s[c]&&void 0!==s[c]||(s[c]=n[c]);n=s,a?fn(a,i).apply(null,n):r.apply(null,[null].concat(n))}}).apply(null,[null].concat(n))},use:function(n){if("function"!=typeof n)throw new Error("Expected `fn` to be a function, not "+n);return e.push(n),t}};return t}var gn=yn;function mn(){}mn.prototype=Error.prototype,yn.prototype=new mn;var vn=yn.prototype;function yn(e,t,n){var r,i,o;"string"==typeof t&&(n=t,t=null),r=function(e){var t,n=[null,null];"string"==typeof e&&(-1===(t=e.indexOf(":"))?n[1]=e:(n[0]=e.slice(0,t),n[1]=e.slice(t+1)));return n}(n),i=jt(t)||"1:1",o={start:{line:null,column:null},end:{line:null,column:null}},t&&t.position&&(t=t.position),t&&(t.start?(o=t,t=t.start):o.start=t),e.stack&&(this.stack=e.stack,e=e.message),this.message=e,this.name=i,this.reason=e,this.line=t?t.line:null,this.column=t?t.column:null,this.location=o,this.source=r[0],this.ruleId=r[1]}vn.file="",vn.name="",vn.reason="",vn.message="",vn.stack="",vn.fatal=null,vn.column=null,vn.line=null;var kn=a.default,xn="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function bn(){throw new Error("setTimeout has not been defined")}function wn(){throw new Error("clearTimeout has not been defined")}var En=bn,Sn=wn;function Cn(e){if(En===setTimeout)return setTimeout(e,0);if((En===bn||!En)&&setTimeout)return En=setTimeout,setTimeout(e,0);try{return En(e,0)}catch(t){try{return En.call(null,e,0)}catch(t){return En.call(this,e,0)}}}"function"==typeof xn.setTimeout&&(En=setTimeout),"function"==typeof xn.clearTimeout&&(Sn=clearTimeout);var An,Dn=[],Tn=!1,qn=-1;function Ln(){Tn&&An&&(Tn=!1,An.length?Dn=An.concat(Dn):qn=-1,Dn.length&&Fn())}function Fn(){if(!Tn){var e=Cn(Ln);Tn=!0;for(var t=Dn.length;t;){for(An=Dn,Dn=[];++qn<t;)An&&An[qn].run();qn=-1,t=Dn.length}An=null,Tn=!1,function(e){if(Sn===clearTimeout)return clearTimeout(e);if((Sn===wn||!Sn)&&clearTimeout)return Sn=clearTimeout,clearTimeout(e);try{return Sn(e)}catch(t){try{return Sn.call(null,e)}catch(t){return Sn.ca
|