longhun/extensions/ui-editor/editor.worker.b9a77fdc.js

9 lines
171 KiB
JavaScript
Raw Normal View History

2023-03-25 21:54:19 +08:00
(function(){"use strict";class Fn{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout(()=>{throw t.stack?ae.isErrorNoTelemetry(t)?new ae(t.message+`
`+t.stack):new Error(t.message+`
`+t.stack):t},0)}}emit(t){this.listeners.forEach(r=>{r(t)})}onUnexpectedError(t){this.unexpectedErrorHandler(t),this.emit(t)}onUnexpectedExternalError(t){this.unexpectedErrorHandler(t)}}const xn=new Fn;function En(e){Vn(e)||xn.onUnexpectedError(e)}function ct(e){if(e instanceof Error){const{name:t,message:r}=e,s=e.stacktrace||e.stack;return{$isError:!0,name:t,message:r,stack:s,noTelemetry:ae.isErrorNoTelemetry(e)}}return e}const Fe="Canceled";function Vn(e){return e instanceof Bn?!0:e instanceof Error&&e.name===Fe&&e.message===Fe}class Bn extends Error{constructor(){super(Fe),this.name=this.message}}class ae extends Error{constructor(t){super(t),this.name="ErrorNoTelemetry"}static fromError(t){if(t instanceof ae)return t;const r=new ae;return r.message=t.message,r.stack=t.stack,r}static isErrorNoTelemetry(t){return t.name==="ErrorNoTelemetry"}}function Tn(e){const t=this;let r=!1,s;return function(){return r||(r=!0,s=e.apply(t,arguments)),s}}var Ce;(function(e){function t(p){return p&&typeof p=="object"&&typeof p[Symbol.iterator]=="function"}e.is=t;const r=Object.freeze([]);function s(){return r}e.empty=s;function*i(p){yield p}e.single=i;function a(p){return p||r}e.from=a;function o(p){return!p||p[Symbol.iterator]().next().done===!0}e.isEmpty=o;function l(p){return p[Symbol.iterator]().next().value}e.first=l;function u(p,S){for(const b of p)if(S(b))return!0;return!1}e.some=u;function c(p,S){for(const b of p)if(S(b))return b}e.find=c;function*f(p,S){for(const b of p)S(b)&&(yield b)}e.filter=f;function*h(p,S){let b=0;for(const g of p)yield S(g,b++)}e.map=h;function*d(...p){for(const S of p)for(const b of S)yield b}e.concat=d;function*C(p){for(const S of p)for(const b of S)yield b}e.concatNested=C;function v(p,S,b){let g=b;for(const m of p)g=S(g,m);return g}e.reduce=v;function A(p,S){let b=0;for(const g of p)S(g,b++)}e.forEach=A;function*M(p,S,b=p.length){for(S<0&&(S+=p.length),b<0?b+=p.length:b>p.length&&(b=p.length);S<b;S++)yield p[S]}e.slice=M;function R(p,S=Number.POSITIVE_INFINITY){const b=[];if(S===0)return[b,p];const g=p[Symbol.iterator]();for(let m=0;m<S;m++){const w=g.next();if(w.done)return[b,e.empty()];b.push(w.value)}return[b,{[Symbol.iterator](){return g}}]}e.consume=R;function P(p){return R(p)[0]}e.collect=P;function y(p,S,b=(g,m)=>g===m){const g=p[Symbol.iterator](),m=S[Symbol.iterator]();for(;;){const w=g.next(),N=m.next();if(w.done!==N.done)return!1;if(w.done)return!0;if(!b(w.value,N.value))return!1}}e.equals=y})(Ce||(Ce={}));function C1(e){return e}function _1(e,t){}class Un extends Error{constructor(t){super(`Encountered errors while disposing of store. Errors: [${t.join(", ")}]`),this.errors=t}}function ut(e){if(Ce.is(e)){const t=[];for(const r of e)if(r)try{r.dispose()}catch(s){t.push(s)}if(t.length===1)throw t[0];if(t.length>1)throw new Un(t);return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function In(...e){return _e(()=>ut(e))}function _e(e){return{dispose:Tn(()=>{e()})}}class te{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){try{ut(this._toDispose.values())}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?te.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}}te.DISABLE_DISPOSED_WARNING=!1;class xe{constructor(){this._store=new te,this._store}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}}xe.None=Object.freeze({dispose(){}});class qn{constructor(){this.dispose=()=>{},this.unset=()=>{},this.isset=()=>!1}set(t){let r=t;return this.unset=()=>r=void 0,this.isset=()=>r!==void 0,this.dispose=()=>{r&&(r(),r=void 0)},this}}class D{constructor(t){this.element=t,this.next=D.Undefined,this.prev=D.Undefined}}D.Undefined=new D(void 0);class
`).slice(2).join(`
`))}}class Yn{constructor(t,r,s){this.callback=t,this.callbackThis=r,this.stack=s,this.subscription=new qn}invoke(t){this.callback.call(this.callbackThis,t)}}class j{constructor(t){var r,s;this._disposed=!1,this._options=t,this._leakageMon=void 0,this._perfMon=!((r=this._options)===null||r===void 0)&&r._profName?new ve(this._options._profName):void 0,this._deliveryQueue=(s=this._options)===null||s===void 0?void 0:s.deliveryQueue}dispose(){var t,r,s,i;this._disposed||(this._disposed=!0,this._listeners&&this._listeners.clear(),(t=this._deliveryQueue)===null||t===void 0||t.clear(this),(s=(r=this._options)===null||r===void 0?void 0:r.onLastListenerRemove)===null||s===void 0||s.call(r),(i=this._leakageMon)===null||i===void 0||i.dispose())}get event(){return this._event||(this._event=(t,r,s)=>{var i,a,o;this._listeners||(this._listeners=new pe);const l=this._listeners.isEmpty();l&&((i=this._options)===null||i===void 0?void 0:i.onFirstListenerAdd)&&this._options.onFirstListenerAdd(this);let u,c;this._leakageMon&&this._listeners.size>=30&&(c=qe.create(),u=this._leakageMon.check(c,this._listeners.size+1));const f=new Yn(t,r,c),h=this._listeners.push(f);l&&((a=this._options)===null||a===void 0?void 0:a.onFirstListenerDidAdd)&&this._options.onFirstListenerDidAdd(this),!((o=this._options)===null||o===void 0)&&o.onListenerDidAdd&&this._options.onListenerDidAdd(this,t,r);const d=f.subscription.set(()=>{u==null||u(),this._disposed||(h(),this._options&&this._options.onLastListenerRemove&&(this._listeners&&!this._listeners.isEmpty()||this._options.onLastListenerRemove(this)))});return s instanceof te?s.add(d):Array.isArray(s)&&s.push(d),d}),this._event}fire(t){var r,s;if(this._listeners){this._deliveryQueue||(this._deliveryQueue=new Jn);for(const i of this._listeners)this._deliveryQueue.push(this,i,t);(r=this._perfMon)===null||r===void 0||r.start(this._deliveryQueue.size),this._deliveryQueue.deliver(),(s=this._perfMon)===null||s===void 0||s.stop()}}}class Xn{constructor(){this._queue=new pe}get size(){return this._queue.size}push(t,r,s){this._queue.push(new Kn(t,r,s))}clear(t){const r=new pe;for(const s of this._queue)s.emitter!==t&&r.push(s);this._queue=r}deliver(){for(;this._queue.size>0;){const t=this._queue.shift();try{t.listener.invoke(t.event)}catch(r){En(r)}}}}class Jn extends Xn{clear(t){this._queue.clear()}}class Kn{constructor(t,r,s){this.emitter=t,this.listener=r,this.event=s}}function er(e){let t=[],r=Object.getPrototypeOf(e);for(;Object.prototype!==r;)t=t.concat(Object.getOwnPropertyNames(r)),r=Object.getPrototypeOf(r);return t}function He(e){const t=[];for(const r of er(e))typeof e[r]=="function"&&t.push(r);return t}function tr(e,t){const r=i=>function(){const a=Array.prototype.slice.call(arguments,0);return t(i,a)},s={};for(const i of e)s[i]=r(i);return s}function nr(e,t="Unreachable"){throw new Error(t)}class rr{constructor(t){this.fn=t,this.lastCache=void 0,this.lastArgKey=void 0}get(t){const r=JSON.stringify(t);return this.lastArgKey!==r&&(this.lastArgKey=r,this.lastCache=this.fn(t)),this.lastCache}}class ft{constructor(t){this.executor=t,this._didRun=!1}hasValue(){return this._didRun}getValue(){if(!this._didRun)try{this._value=this.executor()}catch(t){this._error=t}finally{this._didRun=!0}if(this._error)throw this._error;return this._value}get rawValue(){return this._value}}var dt;function sr(e){return e.replace(/[\\\{\}\*\+\?\|\^\$\.\[\]\(\)]/g,"\\$&")}function ir(e){return e.split(/\r\n|\r|\n/)}function ar(e){for(let t=0,r=e.length;t<r;t++){const s=e.charCodeAt(t);if(s!==32&&s!==9)return t}return-1}function or(e,t=e.length-1){for(let r=t;r>=0;r--){const s=e.charCodeAt(r);if(s!==32&&s!==9)return r}return-1}function mt(e){return e>=65&&e<=90}function We(e){return 55296<=e&&e<=56319}function lr(e){return 56320<=e&&e<=57343}function cr(e,t){return(e-55296<<10)+(t-56320)+65536}function ur(e,t,r){const s=e.charCodeAt(r);if(We(s)&&r+1<t){const i=e.charCodeAt(r+1);if(lr(i))return cr(s,i)}return s}const hr=/^[\t\n\r\x20-\x7E]*$/;function fr(e){return hr.test(e)}class z{constructor(t){this.confusableDictionary=t}static getIns
`||e===" "}var se=function(e,t,r,s){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function l(f){try{c(s.next(f))}catch(h){o(h)}}function u(f){try{c(s.throw(f))}catch(h){o(h)}}function c(f){f.done?a(f.value):i(f.value).then(l,u)}c((s=s.apply(e,t||[])).next())})};class d1 extends Wr{get uri(){return this._uri}get eol(){return this._eol}getValue(){return this.getText()}getLinesContent(){return this._lines.slice(0)}getLineCount(){return this._lines.length}getLineContent(t){return this._lines[t-1]}getWordAtPosition(t,r){const s=Ze(t.column,Gr(r),this._lines[t.lineNumber-1],0);return s?new x(t.lineNumber,s.startColumn,t.lineNumber,s.endColumn):null}words(t){const r=this._lines,s=this._wordenize.bind(this);let i=0,a="",o=0,l=[];return{*[Symbol.iterator](){for(;;)if(o<l.length){const u=a.substring(l[o].start,l[o].end);o+=1,yield u}else if(i<r.length)a=r[i],l=s(a,t),o=0,i+=1;else break}}}getLineWords(t,r){const s=this._lines[t-1],i=this._wordenize(s,r),a=[];for(const o of i)a.push({word:s.substring(o.start,o.end),startColumn:o.start+1,endColumn:o.end+1});return a}_wordenize(t,r){const s=[];let i;for(r.lastIndex=0;(i=r.exec(t))&&i[0].length!==0;)s.push({start:i.index,end:i.index+i[0].length});return s}getValueInRange(t){if(t=this._validateRange(t),t.startLineNumber===t.endLineNumber)return this._lines[t.startLineNumber-1].substring(t.startColumn-1,t.endColumn-1);const r=this._eol,s=t.startLineNumber-1,i=t.endLineNumber-1,a=[];a.push(this._lines[s].substring(t.startColumn-1));for(let o=s+1;o<i;o++)a.push(this._lines[o]);return a.push(this._lines[i].substring(0,t.endColumn-1)),a.join(r)}offsetAt(t){return t=this._validatePosition(t),this._ensureLineStarts(),this._lineStarts.getPrefixSum(t.lineNumber-2)+(t.column-1)}positionAt(t){t=Math.floor(t),t=Math.max(0,t),this._ensureLineStarts();const r=this._lineStarts.getIndexOf(t),s=this._lines[r.index].length;return{lineNumber:1+r.index,column:1+Math.min(r.remainder,s)}}_validateRange(t){const r=this._validatePosition({lineNumber:t.startLineNumber,column:t.startColumn}),s=this._validatePosition({lineNumber:t.endLineNumber,column:t.endColumn});return r.lineNumber!==t.startLineNumber||r.column!==t.startColumn||s.lineNumber!==t.endLineNumber||s.column!==t.endColumn?{startLineNumber:r.lineNumber,startColumn:r.column,endLineNumber:s.lineNumber,endColumn:s.column}:t}_validatePosition(t){if(!W.isIPosition(t))throw new Error("bad position");let{lineNumber:r,column:s}=t,i=!1;if(r<1)r=1,s=1,i=!0;else if(r>this._lines.length)r=this._lines.length,s=this._lines[r-1].length+1,i=!0;else{const a=this._lines[r-1].length+1;s<1?(s=1,i=!0):s>a&&(s=a,i=!0)}return i?{lineNumber:r,column:s}:t}}class ie{constructor(t,r){this._host=t,this._models=Object.create(null),this._foreignModuleFactory=r,this._foreignModule=null}dispose(){this._models=Object.create(null)}_getModel(t){return this._models[t]}_getModels(){const t=[];return Object.keys(this._models).forEach(r=>t.push(this._models[r])),t}acceptNewModel(t){this._models[t.url]=new d1(re.parse(t.url),t.lines,t.EOL,t.versionId)}acceptModelChanged(t,r){if(!this._models[t])return;this._models[t].onEvents(r)}acceptRemovedModel(t){!this._models[t]||delete this._models[t]}computeUnicodeHighlights(t,r,s){return se(this,void 0,void 0,function*(){const i=this._getModel(t);return i?h1.computeUnicodeHighlights(i,r,s):{ranges:[],hasMore:!1,ambiguousCharacterCount:0,invisibleCharacterCount:0,nonBasicAsciiCharacterCount:0}})}computeDiff(t,r,s,i){return se(this,void 0,void 0,function*(){const a=this._getModel(t),o=this._getModel(r);return!a||!o?null:ie.computeDiff(a,o,s,i)})}static computeDiff(t,r,s,i){const a=t.getLinesContent(),o=r.getLinesContent(),u=new Ir(a,o,{shouldComputeCharChanges:!0,shouldPostProcessCharChanges:!0,shouldIgnoreTrimWhitespace:s,shouldMakePrettyDiff:!0,maxComputationTime:i}).computeDiff(),c=u.changes.length>0?!1:this._modelsAreIdentical(t,r);return{quitEarly:u.quitEarly,identical:c,changes:u.changes}}static _modelsAreIdentical(t,r){const s=t.getLineCount(),i=r.getLineCount();if(s!==i)return!1;for(l