From e2bcdc7c8abc64098c25fd0e4378e2ea15f605ab Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Wed, 27 May 2020 16:16:45 +0200 Subject: [PATCH 01/26] First iteration of xjson in monaco --- .../monaco/index.ts | 24 ++ .../monaco/xjson_lang/README.md | 44 +++ .../monaco/xjson_lang/constants.ts | 20 ++ .../xjson_lang/dist/bundle.amd.worker.js | 1 + .../monaco/xjson_lang/grammar.ts | 213 ++++++++++++++ .../monaco/xjson_lang/index.ts | 23 ++ .../monaco/xjson_lang/language.ts | 86 ++++++ .../monaco/xjson_lang/lexer_rules/esql.ts | 273 ++++++++++++++++++ .../monaco/xjson_lang/lexer_rules/index.ts | 20 ++ .../monaco/xjson_lang/lexer_rules/painless.ts | 194 +++++++++++++ .../monaco/xjson_lang/lexer_rules/shared.ts | 22 ++ .../monaco/xjson_lang/lexer_rules/xjson.ts | 139 +++++++++ .../xjson_lang/webpack.xjson-worker.config.js | 51 ++++ .../monaco/xjson_lang/worker/index.ts | 20 ++ .../monaco/xjson_lang/worker/xjson.worker.ts | 30 ++ .../monaco/xjson_lang/worker/xjson_worker.ts | 34 +++ .../monaco/xjson_lang/worker_proxy_service.ts | 55 ++++ .../es_ui_shared/public/console_lang/index.ts | 2 + src/plugins/es_ui_shared/public/index.ts | 1 + 19 files changed, 1252 insertions(+) create mode 100644 src/plugins/es_ui_shared/__packages_do_not_import__/monaco/index.ts create mode 100644 src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/README.md create mode 100644 src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/constants.ts create mode 100644 src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/dist/bundle.amd.worker.js create mode 100644 src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/grammar.ts create mode 100644 src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/index.ts create mode 100644 src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/language.ts create mode 100644 src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/lexer_rules/esql.ts create mode 100644 src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/lexer_rules/index.ts create mode 100644 src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/lexer_rules/painless.ts create mode 100644 src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/lexer_rules/shared.ts create mode 100644 src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/lexer_rules/xjson.ts create mode 100644 src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/webpack.xjson-worker.config.js create mode 100644 src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/worker/index.ts create mode 100644 src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/worker/xjson.worker.ts create mode 100644 src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/worker/xjson_worker.ts create mode 100644 src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/worker_proxy_service.ts diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/index.ts b/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/index.ts new file mode 100644 index 00000000000000..341800956e27de --- /dev/null +++ b/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/index.ts @@ -0,0 +1,24 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import * as XJsonLang from './xjson_lang'; + +export const monaco = { + XJsonLang, +}; diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/README.md b/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/README.md new file mode 100644 index 00000000000000..c13a9cc84796f5 --- /dev/null +++ b/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/README.md @@ -0,0 +1,44 @@ +# README + +This folder contains the language definitions for XJSON used by the Monaco editor. + +## Summary of contents + +Note: All source code. + +### ./worker + +The worker proxy and worker instantiation code used in both the main thread and the worker thread. + +### ./dist + +The transpiled, production-ready version of the worker code that will be loaded by Monaco client side. +Currently this is not served by Kibana but raw-loaded as a string and served with the source code via +the "raw-loader". + +See the related ./webpack.xjson-worker.config.js file that is runnable with Kibana's webpack with: + +```sh +yarn webpack --config ./src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/webpack.xjson-worker.config.js +``` + +### ./lexer_rules + +Contains the Monarch-specific language tokenization rules for XJSON + +### ./constants.ts + +Contains the unique language ID. + +### ./language + +Takes care of global setup steps for the language (like registering it against Monaco) and exports a way to load up +the grammar parser. + +### ./worker_proxy_service + +A stateful mechanism for holding a reference to the Monaco-provided proxy getter. + +### ./grammar + +The parser logic that lives inside of the worker. Takes in a string and returns annotations for XJSON. diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/constants.ts b/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/constants.ts new file mode 100644 index 00000000000000..dc107abff4ffe4 --- /dev/null +++ b/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/constants.ts @@ -0,0 +1,20 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export const ID = 'xjson'; diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/dist/bundle.amd.worker.js b/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/dist/bundle.amd.worker.js new file mode 100644 index 00000000000000..4e9798e4e77a2a --- /dev/null +++ b/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/dist/bundle.amd.worker.js @@ -0,0 +1 @@ +/*! /* eslint-disable * / */!function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=6)}([function(e,t,n){"use strict";(function(e,r){n.d(t,"c",(function(){return m})),n.d(t,"b",(function(){return p})),n.d(t,"a",(function(){return g}));var i=!1,o=!1,s=!1,u=!1,a=!1,l=void 0!==e&&void 0!==e.versions&&void 0!==e.versions.electron&&"renderer"===e.type;if("object"!=typeof navigator||l){if("object"==typeof e){i="win32"===e.platform,o="darwin"===e.platform,s="linux"===e.platform,"en","en";var c=e.env.VSCODE_NLS_CONFIG;if(c)try{var f=JSON.parse(c),h=f.availableLanguages["*"];f.locale,h||"en",f._translationsConfigFile}catch(e){}u=!0}}else{var d=navigator.userAgent;i=d.indexOf("Windows")>=0,o=d.indexOf("Macintosh")>=0,s=d.indexOf("Linux")>=0,a=!0,navigator.language}var m=i,p=a,g="object"==typeof self?self:"object"==typeof r?r:{}}).call(this,n(2),n(1))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t){var n,r,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function u(e){if(n===setTimeout)return setTimeout(e,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(e){n=o}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();var a,l=[],c=!1,f=-1;function h(){c&&a&&(c=!1,a.length?l=a.concat(l):f=-1,l.length&&d())}function d(){if(!c){var e=u(h);c=!0;for(var t=l.length;t;){for(a=l,l=[];++f1)for(var n=1;n=0&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),t))},n(5),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,n(1))},function(e,t,n){(function(e,t){!function(e,n){"use strict";if(!e.setImmediate){var r,i,o,s,u,a=1,l={},c=!1,f=e.document,h=Object.getPrototypeOf&&Object.getPrototypeOf(e);h=h&&h.setTimeout?h:e,"[object process]"==={}.toString.call(e.process)?r=function(e){t.nextTick((function(){m(e)}))}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=n,t}}()?e.MessageChannel?((o=new MessageChannel).port1.onmessage=function(e){m(e.data)},r=function(e){o.port2.postMessage(e)}):f&&"onreadystatechange"in f.createElement("script")?(i=f.documentElement,r=function(e){var t=f.createElement("script");t.onreadystatechange=function(){m(e),t.onreadystatechange=null,i.removeChild(t),t=null},i.appendChild(t)}):r=function(e){setTimeout(m,0,e)}:(s="setImmediate$"+Math.random()+"$",u=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(s)&&m(+t.data.slice(s.length))},e.addEventListener?e.addEventListener("message",u,!1):e.attachEvent("onmessage",u),r=function(t){e.postMessage(s+t,"*")}),h.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;nr?e[a]=o[u++]:u>i?e[a]=o[s++]:t(o[u],o[s])<0?e[a]=o[u++]:e[a]=o[s++]}(t,n,r,s,i,o)}(e,t,0,e.length-1,[]),e}var _=function(){function e(e,t,n,r){this.originalStart=e,this.originalLength=t,this.modifiedStart=n,this.modifiedLength=r}return e.prototype.getOriginalEnd=function(){return this.originalStart+this.originalLength},e.prototype.getModifiedEnd=function(){return this.modifiedStart+this.modifiedLength},e}();function v(e){return{getLength:function(){return e.length},getElementAtIndex:function(t){return e.charCodeAt(t)}}}function y(e,t,n){return new E(v(e),v(t)).ComputeDiff(n)}var C,b=function(){function e(){}return e.Assert=function(e,t){if(!e)throw new Error(t)},e}(),L=function(){function e(){}return e.Copy=function(e,t,n,r,i){for(var o=0;o0||this.m_modifiedCount>0)&&this.m_changes.push(new _(this.m_originalStart,this.m_originalCount,this.m_modifiedStart,this.m_modifiedCount)),this.m_originalCount=0,this.m_modifiedCount=0,this.m_originalStart=Number.MAX_VALUE,this.m_modifiedStart=Number.MAX_VALUE},e.prototype.AddOriginalElement=function(e,t){this.m_originalStart=Math.min(this.m_originalStart,e),this.m_modifiedStart=Math.min(this.m_modifiedStart,t),this.m_originalCount++},e.prototype.AddModifiedElement=function(e,t){this.m_originalStart=Math.min(this.m_originalStart,e),this.m_modifiedStart=Math.min(this.m_modifiedStart,t),this.m_modifiedCount++},e.prototype.getChanges=function(){return(this.m_originalCount>0||this.m_modifiedCount>0)&&this.MarkNextChange(),this.m_changes},e.prototype.getReverseChanges=function(){return(this.m_originalCount>0||this.m_modifiedCount>0)&&this.MarkNextChange(),this.m_changes.reverse(),this.m_changes},e}(),E=function(){function e(e,t,n){void 0===n&&(n=null),this.OriginalSequence=e,this.ModifiedSequence=t,this.ContinueProcessingPredicate=n,this.m_forwardHistory=[],this.m_reverseHistory=[]}return e.prototype.ElementsAreEqual=function(e,t){return this.OriginalSequence.getElementAtIndex(e)===this.ModifiedSequence.getElementAtIndex(t)},e.prototype.OriginalElementsAreEqual=function(e,t){return this.OriginalSequence.getElementAtIndex(e)===this.OriginalSequence.getElementAtIndex(t)},e.prototype.ModifiedElementsAreEqual=function(e,t){return this.ModifiedSequence.getElementAtIndex(e)===this.ModifiedSequence.getElementAtIndex(t)},e.prototype.ComputeDiff=function(e){return this._ComputeDiff(0,this.OriginalSequence.getLength()-1,0,this.ModifiedSequence.getLength()-1,e)},e.prototype._ComputeDiff=function(e,t,n,r,i){var o=this.ComputeDiffRecursive(e,t,n,r,[!1]);return i?this.PrettifyChanges(o):o},e.prototype.ComputeDiffRecursive=function(e,t,n,r,i){for(i[0]=!1;e<=t&&n<=r&&this.ElementsAreEqual(e,n);)e++,n++;for(;t>=e&&r>=n&&this.ElementsAreEqual(t,r);)t--,r--;if(e>t||n>r){var o=void 0;return n<=r?(b.Assert(e===t+1,"originalStart should only be one more than originalEnd"),o=[new _(e,0,n,r-n+1)]):e<=t?(b.Assert(n===r+1,"modifiedStart should only be one more than modifiedEnd"),o=[new _(e,t-e+1,n,0)]):(b.Assert(e===t+1,"originalStart should only be one more than originalEnd"),b.Assert(n===r+1,"modifiedStart should only be one more than modifiedEnd"),o=[]),o}var s=[0],u=[0],a=this.ComputeRecursionPoint(e,t,n,r,s,u,i),l=s[0],c=u[0];if(null!==a)return a;if(!i[0]){var f=this.ComputeDiffRecursive(e,l,n,c,i),h=[];return h=i[0]?[new _(l+1,t-(l+1)+1,c+1,r-(c+1)+1)]:this.ComputeDiffRecursive(l+1,t,c+1,r,i),this.ConcatenateChanges(f,h)}return[new _(e,t-e+1,n,r-n+1)]},e.prototype.WALKTRACE=function(e,t,n,r,i,o,s,u,a,l,c,f,h,d,m,p,g,v){var y,C,b=null,L=new N,E=t,S=n,w=h[0]-p[0]-r,A=Number.MIN_VALUE,M=this.m_forwardHistory.length-1;do{(C=w+e)===E||C=0&&(e=(a=this.m_forwardHistory[M])[0],E=1,S=a.length-1)}while(--M>=-1);if(y=L.getReverseChanges(),v[0]){var T=h[0]+1,P=p[0]+1;if(null!==y&&y.length>0){var O=y[y.length-1];T=Math.max(T,O.getOriginalEnd()),P=Math.max(P,O.getModifiedEnd())}b=[new _(T,f-T+1,P,m-P+1)]}else{L=new N,E=o,S=s,w=h[0]-p[0]-u,A=Number.MAX_VALUE,M=g?this.m_reverseHistory.length-1:this.m_reverseHistory.length-2;do{(C=w+i)===E||C=l[C+1]?(d=(c=l[C+1]-1)-w-u,c>A&&L.MarkNextChange(),A=c+1,L.AddOriginalElement(c+1,d+1),w=C+1-i):(d=(c=l[C-1])-w-u,c>A&&L.MarkNextChange(),A=c,L.AddModifiedElement(c+1,d+1),w=C-1-i),M>=0&&(i=(l=this.m_reverseHistory[M])[0],E=1,S=l.length-1)}while(--M>=-1);b=L.getChanges()}return this.ConcatenateChanges(y,b)},e.prototype.ComputeRecursionPoint=function(e,t,n,r,i,o,s){var u,a=0,l=0,c=0,f=0,h=0,d=0;e--,n--,i[0]=0,o[0]=0,this.m_forwardHistory=[],this.m_reverseHistory=[];var m,p,g=t-e+(r-n),v=g+1,y=new Array(v),C=new Array(v),b=r-n,N=t-e,E=e-n,S=t-r,w=(N-b)%2==0;for(y[b]=e,C[N]=t,s[0]=!1,u=1;u<=g/2+1;u++){var A=0,M=0;for(c=this.ClipDiagonalBound(b-u,u,b,v),f=this.ClipDiagonalBound(b+u,u,b,v),m=c;m<=f;m+=2){for(l=(a=m===c||mA+M&&(A=a,M=l),!w&&Math.abs(m-N)<=u-1&&a>=C[m])return i[0]=a,o[0]=l,p<=C[m]&&u<=1448?this.WALKTRACE(b,c,f,E,N,h,d,S,y,C,a,t,i,l,r,o,w,s):null}var T=(A-e+(M-n)-u)/2;if(null!==this.ContinueProcessingPredicate&&!this.ContinueProcessingPredicate(A,this.OriginalSequence,T))return s[0]=!0,i[0]=A,o[0]=M,T>0&&u<=1448?this.WALKTRACE(b,c,f,E,N,h,d,S,y,C,a,t,i,l,r,o,w,s):(e++,n++,[new _(e,t-e+1,n,r-n+1)]);for(h=this.ClipDiagonalBound(N-u,u,N,v),d=this.ClipDiagonalBound(N+u,u,N,v),m=h;m<=d;m+=2){for(l=(a=m===h||m=C[m+1]?C[m+1]-1:C[m-1])-(m-N)-S,p=a;a>e&&l>n&&this.ElementsAreEqual(a,l);)a--,l--;if(C[m]=a,w&&Math.abs(m-b)<=u&&a<=y[m])return i[0]=a,o[0]=l,p>=y[m]&&u<=1448?this.WALKTRACE(b,c,f,E,N,h,d,S,y,C,a,t,i,l,r,o,w,s):null}if(u<=1447){var P=new Array(f-c+2);P[0]=b-c+1,L.Copy(y,c,P,1,f-c+1),this.m_forwardHistory.push(P),(P=new Array(d-h+2))[0]=N-h+1,L.Copy(C,h,P,1,d-h+1),this.m_reverseHistory.push(P)}}return this.WALKTRACE(b,c,f,E,N,h,d,S,y,C,a,t,i,l,r,o,w,s)},e.prototype.PrettifyChanges=function(e){for(var t=0;t0,s=n.modifiedLength>0;n.originalStart+n.originalLength=0;t--){n=e[t],r=0,i=0;if(t>0){var a=e[t-1];a.originalLength>0&&(r=a.originalStart+a.originalLength),a.modifiedLength>0&&(i=a.modifiedStart+a.modifiedLength)}o=n.originalLength>0,s=n.modifiedLength>0;for(var l=0,c=this._boundaryScore(n.originalStart,n.originalLength,n.modifiedStart,n.modifiedLength),f=1;;f++){var h=n.originalStart-f,d=n.modifiedStart-f;if(hc&&(c=m,l=f)}n.originalStart-=l,n.modifiedStart-=l}return e},e.prototype._OriginalIsBoundary=function(e){if(e<=0||e>=this.OriginalSequence.getLength()-1)return!0;var t=this.OriginalSequence.getElementAtIndex(e);return"string"==typeof t&&/^\s*$/.test(t)},e.prototype._OriginalRegionIsBoundary=function(e,t){if(this._OriginalIsBoundary(e)||this._OriginalIsBoundary(e-1))return!0;if(t>0){var n=e+t;if(this._OriginalIsBoundary(n-1)||this._OriginalIsBoundary(n))return!0}return!1},e.prototype._ModifiedIsBoundary=function(e){if(e<=0||e>=this.ModifiedSequence.getLength()-1)return!0;var t=this.ModifiedSequence.getElementAtIndex(e);return"string"==typeof t&&/^\s*$/.test(t)},e.prototype._ModifiedRegionIsBoundary=function(e,t){if(this._ModifiedIsBoundary(e)||this._ModifiedIsBoundary(e-1))return!0;if(t>0){var n=e+t;if(this._ModifiedIsBoundary(n-1)||this._ModifiedIsBoundary(n))return!0}return!1},e.prototype._boundaryScore=function(e,t,n,r){return(this._OriginalRegionIsBoundary(e,t)?1:0)+(this._ModifiedRegionIsBoundary(n,r)?1:0)},e.prototype.ConcatenateChanges=function(e,t){var n=[];if(0===e.length||0===t.length)return t.length>0?t:e;if(this.ChangesOverlap(e[e.length-1],t[0],n)){var r=new Array(e.length+t.length-1);return L.Copy(e,0,r,0,e.length-1),r[e.length-1]=n[0],L.Copy(t,1,r,e.length,t.length-1),r}r=new Array(e.length+t.length);return L.Copy(e,0,r,0,e.length),L.Copy(t,0,r,e.length,t.length),r},e.prototype.ChangesOverlap=function(e,t,n){if(b.Assert(e.originalStart<=t.originalStart,"Left change is not less than or equal to right change"),b.Assert(e.modifiedStart<=t.modifiedStart,"Left change is not less than or equal to right change"),e.originalStart+e.originalLength>=t.originalStart||e.modifiedStart+e.modifiedLength>=t.modifiedStart){var r=e.originalStart,i=e.originalLength,o=e.modifiedStart,s=e.modifiedLength;return e.originalStart+e.originalLength>=t.originalStart&&(i=t.originalStart+t.originalLength-e.originalStart),e.modifiedStart+e.modifiedLength>=t.modifiedStart&&(s=t.modifiedStart+t.modifiedLength-e.modifiedStart),n[0]=new _(r,i,o,s),!0}return n[0]=null,!1},e.prototype.ClipDiagonalBound=function(e,t,n,r){if(e>=0&&e=n?w:{done:!1,value:e[t++]}}}},e.from=function(t){return t?Array.isArray(t)?e.fromArray(t):t:e.empty()},e.map=function(e,t){return{next:function(){var n=e.next();return n.done?w:{done:!1,value:t(n.value)}}}},e.filter=function(e,t){return{next:function(){for(;;){var n=e.next();if(n.done)return w;if(t(n.value))return{done:!1,value:n.value}}}}},e.forEach=n,e.collect=function(e){var t=[];return n(e,(function(e){return t.push(e)})),t}}(C||(C={}));(function(e){function t(t,n,r,i){return void 0===n&&(n=0),void 0===r&&(r=t.length),void 0===i&&(i=n-1),e.call(this,t,n,r,i)||this}S(t,e),t.prototype.current=function(){return e.prototype.current.call(this)},t.prototype.previous=function(){return this.index=Math.max(this.index-1,this.start-1),this.current()},t.prototype.first=function(){return this.index=this.start,this.current()},t.prototype.last=function(){return this.index=this.end-1,this.current()},t.prototype.parent=function(){return null}})(function(){function e(e,t,n,r){void 0===t&&(t=0),void 0===n&&(n=e.length),void 0===r&&(r=t-1),this.items=e,this.start=t,this.end=n,this.index=r}return e.prototype.next=function(){return this.index=Math.min(this.index+1,this.end),this.current()},e.prototype.current=function(){return this.index===this.start-1||this.index===this.end?null:this.items[this.index]},e}()),function(){function e(e,t){this.iterator=e,this.fn=t}e.prototype.next=function(){return this.fn(this.iterator.next())}}();var A,M=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),T=/^\w[\w\d+.-]*$/,P=/^\//,O=/^\/\//;var x="",I="/",R=/^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,k=function(){function e(e,t,n,r,i,o){void 0===o&&(o=!1),"object"==typeof e?(this.scheme=e.scheme||x,this.authority=e.authority||x,this.path=e.path||x,this.query=e.query||x,this.fragment=e.fragment||x):(this.scheme=e||x,this.authority=t||x,this.path=function(e,t){switch(e){case"https":case"http":case"file":t?t[0]!==I&&(t=I+t):t=I}return t}(this.scheme,n||x),this.query=r||x,this.fragment=i||x,function(e,t){if(!e.scheme)throw new Error('[UriError]: Scheme is missing: {scheme: "", authority: "'+e.authority+'", path: "'+e.path+'", query: "'+e.query+'", fragment: "'+e.fragment+'"}');if(e.scheme&&!T.test(e.scheme))throw new Error("[UriError]: Scheme contains illegal characters.");if(e.path)if(e.authority){if(!P.test(e.path))throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character')}else if(O.test(e.path))throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")')}(this))}return e.isUri=function(t){return t instanceof e||!!t&&("string"==typeof t.authority&&"string"==typeof t.fragment&&"string"==typeof t.path&&"string"==typeof t.query&&"string"==typeof t.scheme&&"function"==typeof t.fsPath&&"function"==typeof t.with&&"function"==typeof t.toString)},Object.defineProperty(e.prototype,"fsPath",{get:function(){return q(this)},enumerable:!0,configurable:!0}),e.prototype.with=function(e){if(!e)return this;var t=e.scheme,n=e.authority,r=e.path,i=e.query,o=e.fragment;return void 0===t?t=this.scheme:null===t&&(t=x),void 0===n?n=this.authority:null===n&&(n=x),void 0===r?r=this.path:null===r&&(r=x),void 0===i?i=this.query:null===i&&(i=x),void 0===o?o=this.fragment:null===o&&(o=x),t===this.scheme&&n===this.authority&&r===this.path&&i===this.query&&o===this.fragment?this:new U(t,n,r,i,o)},e.parse=function(e,t){void 0===t&&(t=!1);var n=R.exec(e);return n?new U(n[2]||x,decodeURIComponent(n[4]||x),decodeURIComponent(n[5]||x),decodeURIComponent(n[7]||x),decodeURIComponent(n[9]||x),t):new U(x,x,x,x,x)},e.file=function(e){var t=x;if(c.c&&(e=e.replace(/\\/g,I)),e[0]===I&&e[1]===I){var n=e.indexOf(I,2);-1===n?(t=e.substring(2),e=I):(t=e.substring(2,n),e=e.substring(n)||I)}return new U("file",t,e,x,x)},e.from=function(e){return new U(e.scheme,e.authority,e.path,e.query,e.fragment)},e.prototype.toString=function(e){return void 0===e&&(e=!1),V(this,e)},e.prototype.toJSON=function(){return this},e.revive=function(t){if(t){if(t instanceof e)return t;var n=new U(t);return n._fsPath=t.fsPath,n._formatted=t.external,n}return t},e}(),U=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._formatted=null,t._fsPath=null,t}return M(t,e),Object.defineProperty(t.prototype,"fsPath",{get:function(){return this._fsPath||(this._fsPath=q(this)),this._fsPath},enumerable:!0,configurable:!0}),t.prototype.toString=function(e){return void 0===e&&(e=!1),e?V(this,!0):(this._formatted||(this._formatted=V(this,!1)),this._formatted)},t.prototype.toJSON=function(){var e={$mid:1};return this._fsPath&&(e.fsPath=this._fsPath),this._formatted&&(e.external=this._formatted),this.path&&(e.path=this.path),this.scheme&&(e.scheme=this.scheme),this.authority&&(e.authority=this.authority),this.query&&(e.query=this.query),this.fragment&&(e.fragment=this.fragment),e},t}(k),F=((A={})[58]="%3A",A[47]="%2F",A[63]="%3F",A[35]="%23",A[91]="%5B",A[93]="%5D",A[64]="%40",A[33]="%21",A[36]="%24",A[38]="%26",A[39]="%27",A[40]="%28",A[41]="%29",A[42]="%2A",A[43]="%2B",A[44]="%2C",A[59]="%3B",A[61]="%3D",A[32]="%20",A);function D(e,t){for(var n=void 0,r=-1,i=0;i=97&&o<=122||o>=65&&o<=90||o>=48&&o<=57||45===o||46===o||95===o||126===o||t&&47===o)-1!==r&&(n+=encodeURIComponent(e.substring(r,i)),r=-1),void 0!==n&&(n+=e.charAt(i));else{void 0===n&&(n=e.substr(0,i));var s=F[o];void 0!==s?(-1!==r&&(n+=encodeURIComponent(e.substring(r,i)),r=-1),n+=s):-1===r&&(r=i)}}return-1!==r&&(n+=encodeURIComponent(e.substring(r))),void 0!==n?n:e}function K(e){for(var t=void 0,n=0;n1&&"file"===e.scheme?"//"+e.authority+e.path:47===e.path.charCodeAt(0)&&(e.path.charCodeAt(1)>=65&&e.path.charCodeAt(1)<=90||e.path.charCodeAt(1)>=97&&e.path.charCodeAt(1)<=122)&&58===e.path.charCodeAt(2)?e.path[1].toLowerCase()+e.path.substr(2):e.path,c.c&&(t=t.replace(/\//g,"\\")),t}function V(e,t){var n=t?K:D,r="",i=e.scheme,o=e.authority,s=e.path,u=e.query,a=e.fragment;if(i&&(r+=i,r+=":"),(o||"file"===i)&&(r+=I,r+=I),o){var l=o.indexOf("@");if(-1!==l){var c=o.substr(0,l);o=o.substr(l+1),-1===(l=c.indexOf(":"))?r+=n(c,!1):(r+=n(c.substr(0,l),!1),r+=":",r+=n(c.substr(l+1),!1)),r+="@"}-1===(l=(o=o.toLowerCase()).indexOf(":"))?r+=n(o,!1):(r+=n(o.substr(0,l),!1),r+=o.substr(l))}if(s){if(s.length>=3&&47===s.charCodeAt(0)&&58===s.charCodeAt(2))(f=s.charCodeAt(1))>=65&&f<=90&&(s="/"+String.fromCharCode(f+32)+":"+s.substr(3));else if(s.length>=2&&58===s.charCodeAt(1)){var f;(f=s.charCodeAt(0))>=65&&f<=90&&(s=String.fromCharCode(f+32)+":"+s.substr(2))}r+=n(s,!0)}return u&&(r+="?",r+=n(u,!1)),a&&(r+="#",r+=t?a:D(a,!1)),r}var B=function(){function e(e,t){this.lineNumber=e,this.column=t}return e.prototype.with=function(t,n){return void 0===t&&(t=this.lineNumber),void 0===n&&(n=this.column),t===this.lineNumber&&n===this.column?this:new e(t,n)},e.prototype.delta=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=0),this.with(this.lineNumber+e,this.column+t)},e.prototype.equals=function(t){return e.equals(this,t)},e.equals=function(e,t){return!e&&!t||!!e&&!!t&&e.lineNumber===t.lineNumber&&e.column===t.column},e.prototype.isBefore=function(t){return e.isBefore(this,t)},e.isBefore=function(e,t){return e.lineNumbern||e===n&&t>r?(this.startLineNumber=n,this.startColumn=r,this.endLineNumber=e,this.endColumn=t):(this.startLineNumber=e,this.startColumn=t,this.endLineNumber=n,this.endColumn=r)}return e.prototype.isEmpty=function(){return e.isEmpty(this)},e.isEmpty=function(e){return e.startLineNumber===e.endLineNumber&&e.startColumn===e.endColumn},e.prototype.containsPosition=function(t){return e.containsPosition(this,t)},e.containsPosition=function(e,t){return!(t.lineNumbere.endLineNumber)&&(!(t.lineNumber===e.startLineNumber&&t.columne.endColumn))},e.prototype.containsRange=function(t){return e.containsRange(this,t)},e.containsRange=function(e,t){return!(t.startLineNumbere.endLineNumber||t.endLineNumber>e.endLineNumber)&&(!(t.startLineNumber===e.startLineNumber&&t.startColumne.endColumn)))},e.prototype.plusRange=function(t){return e.plusRange(this,t)},e.plusRange=function(t,n){var r,i,o,s;return n.startLineNumbert.endLineNumber?(o=n.endLineNumber,s=n.endColumn):n.endLineNumber===t.endLineNumber?(o=n.endLineNumber,s=Math.max(n.endColumn,t.endColumn)):(o=t.endLineNumber,s=t.endColumn),new e(r,i,o,s)},e.prototype.intersectRanges=function(t){return e.intersectRanges(this,t)},e.intersectRanges=function(t,n){var r=t.startLineNumber,i=t.startColumn,o=t.endLineNumber,s=t.endColumn,u=n.startLineNumber,a=n.startColumn,l=n.endLineNumber,c=n.endColumn;return rl?(o=l,s=c):o===l&&(s=Math.min(s,c)),r>o?null:r===o&&i>s?null:new e(r,i,o,s)},e.prototype.equalsRange=function(t){return e.equalsRange(this,t)},e.equalsRange=function(e,t){return!!e&&!!t&&e.startLineNumber===t.startLineNumber&&e.startColumn===t.startColumn&&e.endLineNumber===t.endLineNumber&&e.endColumn===t.endColumn},e.prototype.getEndPosition=function(){return new B(this.endLineNumber,this.endColumn)},e.prototype.getStartPosition=function(){return new B(this.startLineNumber,this.startColumn)},e.prototype.toString=function(){return"["+this.startLineNumber+","+this.startColumn+" -> "+this.endLineNumber+","+this.endColumn+"]"},e.prototype.setEndPosition=function(t,n){return new e(this.startLineNumber,this.startColumn,t,n)},e.prototype.setStartPosition=function(t,n){return new e(t,n,this.endLineNumber,this.endColumn)},e.prototype.collapseToStart=function(){return e.collapseToStart(this)},e.collapseToStart=function(t){return new e(t.startLineNumber,t.startColumn,t.startLineNumber,t.startColumn)},e.fromPositions=function(t,n){return void 0===n&&(n=t),new e(t.lineNumber,t.column,n.lineNumber,n.column)},e.lift=function(t){return t?new e(t.startLineNumber,t.startColumn,t.endLineNumber,t.endColumn):null},e.isIRange=function(e){return e&&"number"==typeof e.startLineNumber&&"number"==typeof e.startColumn&&"number"==typeof e.endLineNumber&&"number"==typeof e.endColumn},e.areIntersectingOrTouching=function(e,t){return!(e.endLineNumbere.startLineNumber},e}();String.fromCharCode(65279);function Y(e,t,n,r){return new E(e,t,n).ComputeDiff(r)}var W=function(){function e(t){for(var n=[],r=[],i=0,o=t.length;i=0;n--){var r=e.charCodeAt(n);if(32!==r&&9!==r)return n}return-1}(e);return-1===n?t:n+2},e.prototype.getCharSequence=function(e,t,n){for(var r=[],i=[],o=[],s=0,u=t;u<=n;u++)for(var a=this._lines[u],l=e?this._startColumns[u]:1,c=e?this._endColumns[u]:a.length+1,f=l;f1&&m>1;){if(f.charCodeAt(d-2)!==h.charCodeAt(m-2))break;d--,m--}(d>1||m>1)&&this._pushTrimWhitespaceCharChange(i,o+1,1,d,s+1,1,m);for(var p=W._getLastNonBlankColumn(f,1),g=W._getLastNonBlankColumn(h,1),_=f.length+1,v=h.length+1;p<_&&g255?255:0|e}function J(e){return e<0?0:e>4294967295?4294967295:0|e}var Z=function(e,t){this.index=e,this.remainder=t},ee=function(){function e(e){this.values=e,this.prefixSum=new Uint32Array(e.length),this.prefixSumValidIndex=new Int32Array(1),this.prefixSumValidIndex[0]=-1}return e.prototype.getCount=function(){return this.values.length},e.prototype.insertValues=function(e,t){e=J(e);var n=this.values,r=this.prefixSum,i=t.length;return 0!==i&&(this.values=new Uint32Array(n.length+i),this.values.set(n.subarray(0,e),0),this.values.set(n.subarray(e),e+i),this.values.set(t,e),e-1=0&&this.prefixSum.set(r.subarray(0,this.prefixSumValidIndex[0]+1)),!0)},e.prototype.changeValue=function(e,t){return e=J(e),t=J(t),this.values[e]!==t&&(this.values[e]=t,e-1=n.length)return!1;var i=n.length-e;return t>=i&&(t=i),0!==t&&(this.values=new Uint32Array(n.length-t),this.values.set(n.subarray(0,e),0),this.values.set(n.subarray(e+t),e),this.prefixSum=new Uint32Array(this.values.length),e-1=0&&this.prefixSum.set(r.subarray(0,this.prefixSumValidIndex[0]+1)),!0)},e.prototype.getTotalValue=function(){return 0===this.values.length?0:this._getAccumulatedValue(this.values.length-1)},e.prototype.getAccumulatedValue=function(e){return e<0?0:(e=J(e),this._getAccumulatedValue(e))},e.prototype._getAccumulatedValue=function(e){if(e<=this.prefixSumValidIndex[0])return this.prefixSum[e];var t=this.prefixSumValidIndex[0]+1;0===t&&(this.prefixSum[0]=this.values[0],t++),e>=this.values.length&&(e=this.values.length-1);for(var n=t;n<=e;n++)this.prefixSum[n]=this.prefixSum[n-1]+this.values[n];return this.prefixSumValidIndex[0]=Math.max(this.prefixSumValidIndex[0],e),this.prefixSum[e]},e.prototype.getIndexOf=function(e){e=Math.floor(e),this.getTotalValue();for(var t=0,n=this.values.length-1,r=0,i=0,o=0;t<=n;)if(r=t+(n-t)/2|0,e<(o=(i=this.prefixSum[r])-this.values[r]))n=r-1;else{if(!(e>=i))break;t=r+1}return new Z(r,e-o)},e}(),te=(function(){function e(e){this._cacheAccumulatedValueStart=0,this._cache=null,this._actual=new ee(e),this._bustCache()}e.prototype._bustCache=function(){this._cacheAccumulatedValueStart=0,this._cache=null},e.prototype.insertValues=function(e,t){this._actual.insertValues(e,t)&&this._bustCache()},e.prototype.changeValue=function(e,t){this._actual.changeValue(e,t)&&this._bustCache()},e.prototype.removeValues=function(e,t){this._actual.removeValues(e,t)&&this._bustCache()},e.prototype.getTotalValue=function(){return this._actual.getTotalValue()},e.prototype.getAccumulatedValue=function(e){return this._actual.getAccumulatedValue(e)},e.prototype.getIndexOf=function(e){if(e=Math.floor(e),null!==this._cache){var t=e-this._cacheAccumulatedValueStart;if(t>=0&&t/?".length;n++){var r="`~!@#$%^&*()-=+[{]}\\|;:'\",.<>/?"[n];e.indexOf(r)>=0||(t+="\\"+r)}return t+="\\s]+)",new RegExp(t,"g")}();var re=function(){function e(t){var n=$(t);this._defaultValue=n,this._asciiMap=e._createAsciiMap(n),this._map=new Map}return e._createAsciiMap=function(e){for(var t=new Uint8Array(256),n=0;n<256;n++)t[n]=e;return t},e.prototype.set=function(e,t){var n=$(t);e>=0&&e<256?this._asciiMap[e]=n:this._map.set(e,n)},e.prototype.get=function(e){return e>=0&&e<256?this._asciiMap[e]:this._map.get(e)||this._defaultValue},e}(),ie=(function(){function e(){this._actual=new re(0)}e.prototype.add=function(e){this._actual.set(e,1)},e.prototype.has=function(e){return 1===this._actual.get(e)}}(),function(){function e(e){for(var t=0,n=0,r=0,i=e.length;rt&&(t=l),s>n&&(n=s),(c=o[2])>n&&(n=c)}t++,n++;var u=new X(n,t,0);for(r=0,i=e.length;r=this._maxCharCode?0:this._states.get(e,t)},e}()),oe=null;var se=null;var ue=function(){function e(){}return e._createLink=function(e,t,n,r,i){var o=i-1;do{var s=t.charCodeAt(o);if(2!==e.get(s))break;o--}while(o>r);if(r>0){var u=t.charCodeAt(r-1),a=t.charCodeAt(o);(40===u&&41===a||91===u&&93===a||123===u&&125===a)&&o--}return{range:{startLineNumber:n,startColumn:r+1,endLineNumber:n,endColumn:o+2},url:t.substring(r,o+1)}},e.computeLinks=function(t,n){void 0===n&&(null===oe&&(oe=new ie([[1,104,2],[1,72,2],[1,102,6],[1,70,6],[2,116,3],[2,84,3],[3,116,4],[3,84,4],[4,112,5],[4,80,5],[5,115,9],[5,83,9],[5,58,10],[6,105,7],[6,73,7],[7,108,8],[7,76,8],[8,101,9],[8,69,9],[9,58,10],[10,47,11],[11,47,12]])),n=oe);for(var r=function(){if(null===se){se=new re(0);for(var e=0;e<" \t<>'\"、。。、,.:;?!@#$%&*‘“〈《「『【〔([{「」}])〕】』」》〉”’`~…".length;e++)se.set(" \t<>'\"、。。、,.:;?!@#$%&*‘“〈《「『【〔([{「」}])〕】』」》〉”’`~…".charCodeAt(e),1);for(e=0;e<".,;".length;e++)se.set(".,;".charCodeAt(e),2)}return se}(),i=[],o=1,s=t.getLineCount();o<=s;o++){for(var u=t.getLineContent(o),a=u.length,l=0,c=0,f=0,h=1,d=!1,m=!1,p=!1;l=0?((r+=n?1:-1)<0?r=e.length-1:r%=e.length,e[r]):null},e.INSTANCE=new e,e}();n(3);var le,ce=function(){function e(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}return e.Undefined=new e(void 0),e}(),fe=function(){function e(){this._first=ce.Undefined,this._last=ce.Undefined,this._size=0}return Object.defineProperty(e.prototype,"size",{get:function(){return this._size},enumerable:!0,configurable:!0}),e.prototype.isEmpty=function(){return this._first===ce.Undefined},e.prototype.clear=function(){this._first=ce.Undefined,this._last=ce.Undefined,this._size=0},e.prototype.unshift=function(e){return this._insert(e,!1)},e.prototype.push=function(e){return this._insert(e,!0)},e.prototype._insert=function(e,t){var n=this,r=new ce(e);if(this._first===ce.Undefined)this._first=r,this._last=r;else if(t){var i=this._last;this._last=r,r.prev=i,i.next=r}else{var o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;var s=!1;return function(){s||(s=!0,n._remove(r))}},e.prototype.shift=function(){if(this._first!==ce.Undefined){var e=this._first.element;return this._remove(this._first),e}},e.prototype._remove=function(e){if(e.prev!==ce.Undefined&&e.next!==ce.Undefined){var t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===ce.Undefined&&e.next===ce.Undefined?(this._first=ce.Undefined,this._last=ce.Undefined):e.next===ce.Undefined?(this._last=this._last.prev,this._last.next=ce.Undefined):e.prev===ce.Undefined&&(this._first=this._first.next,this._first.prev=ce.Undefined);this._size-=1},e.prototype.iterator=function(){var e,t=this._first;return{next:function(){return t===ce.Undefined?w:(e?e.value=t.element:e={done:!1,value:t.element},t=t.next,e)}}},e.prototype.toArray=function(){for(var e=[],t=this._first;t!==ce.Undefined;t=t.next)e.push(t.element);return e},e}(),he=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();!function(e){var t={dispose:function(){}};function n(e){return function(t,n,r){void 0===n&&(n=null);var i,o=!1;return i=e((function(e){if(!o)return i?i.dispose():o=!0,t.call(n,e)}),null,r),o&&i.dispose(),i}}function r(e,t){return u((function(n,r,i){return void 0===r&&(r=null),e((function(e){return n.call(r,t(e))}),null,i)}))}function i(e,t){return u((function(n,r,i){return void 0===r&&(r=null),e((function(e){t(e),n.call(r,e)}),null,i)}))}function o(e,t){return u((function(n,r,i){return void 0===r&&(r=null),e((function(e){return t(e)&&n.call(r,e)}),null,i)}))}function s(e,t,n){var i=n;return r(e,(function(e){return i=t(i,e)}))}function u(e){var t,n=new pe({onFirstListenerAdd:function(){t=e(n.fire,n)},onLastListenerRemove:function(){t.dispose()}});return n.event}function l(e){var t,n=!0;return o(e,(function(e){var r=n||e!==t;return n=!1,t=e,r}))}e.None=function(){return t},e.once=n,e.map=r,e.forEach=i,e.filter=o,e.signal=function(e){return e},e.any=function(){for(var e=[],t=0;t1)&&l.fire(e),a=0}),n)}))},onLastListenerRemove:function(){o.dispose()}});return l.event},e.stopwatch=function(e){var t=(new Date).getTime();return r(n(e),(function(e){return(new Date).getTime()-t}))},e.latch=l,e.buffer=function(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=[]);var r=n.slice(),i=e((function(e){r?r.push(e):s.fire(e)})),o=function(){r&&r.forEach((function(e){return s.fire(e)})),r=null},s=new pe({onFirstListenerAdd:function(){i||(i=e((function(e){return s.fire(e)})))},onFirstListenerDidAdd:function(){r&&(t?setTimeout(o):o())},onLastListenerRemove:function(){i&&i.dispose(),i=null}});return s.event};var c=function(){function e(e){this.event=e}return e.prototype.map=function(t){return new e(r(this.event,t))},e.prototype.forEach=function(t){return new e(i(this.event,t))},e.prototype.filter=function(t){return new e(o(this.event,t))},e.prototype.reduce=function(t,n){return new e(s(this.event,t,n))},e.prototype.latch=function(){return new e(l(this.event))},e.prototype.on=function(e,t,n){return this.event(e,t,n)},e.prototype.once=function(e,t,r){return n(this.event)(e,t,r)},e}();e.chain=function(e){return new c(e)},e.fromNodeEventEmitter=function(e,t,n){void 0===n&&(n=function(e){return e});var r=function(){for(var e=[],t=0;t0;){var r=this._deliveryQueue.shift(),o=r[0],s=r[1];try{"function"==typeof o?o.call(void 0,s):o[0].call(o[1],s)}catch(n){i(n)}}}},e.prototype.dispose=function(){this._listeners&&this._listeners.clear(),this._deliveryQueue&&this._deliveryQueue.clear(),this._leakageMon&&this._leakageMon.dispose(),this._disposed=!0},e._noop=function(){},e}(),ge=(function(e){function t(t){var n=e.call(this,t)||this;return n._isPaused=0,n._eventQueue=new fe,n._mergeFn=t&&t.merge,n}he(t,e),t.prototype.pause=function(){this._isPaused++},t.prototype.resume=function(){if(0!==this._isPaused&&0==--this._isPaused)if(this._mergeFn){var t=this._eventQueue.toArray();this._eventQueue.clear(),e.prototype.fire.call(this,this._mergeFn(t))}else for(;!this._isPaused&&0!==this._eventQueue.size;)e.prototype.fire.call(this,this._eventQueue.shift())},t.prototype.fire=function(t){this._listeners&&(0!==this._isPaused?this._eventQueue.push(t):e.prototype.fire.call(this,t))}}(pe),function(){function e(){var e=this;this.hasListeners=!1,this.events=[],this.emitter=new pe({onFirstListenerAdd:function(){return e.onFirstListenerAdd()},onLastListenerRemove:function(){return e.onLastListenerRemove()}})}Object.defineProperty(e.prototype,"event",{get:function(){return this.emitter.event},enumerable:!0,configurable:!0}),e.prototype.add=function(e){var t=this,n={event:e,listener:null};this.events.push(n),this.hasListeners&&this.hook(n);return function(e){return{dispose:function(){e()}}}(function(e){var t,n=this,r=!1;return function(){return r?t:(r=!0,t=e.apply(n,arguments))}}((function(){t.hasListeners&&t.unhook(n);var e=t.events.indexOf(n);t.events.splice(e,1)})))},e.prototype.onFirstListenerAdd=function(){var e=this;this.hasListeners=!0,this.events.forEach((function(t){return e.hook(t)}))},e.prototype.onLastListenerRemove=function(){var e=this;this.hasListeners=!1,this.events.forEach((function(t){return e.unhook(t)}))},e.prototype.hook=function(e){var t=this;e.listener=e.event((function(e){return t.emitter.fire(e)}))},e.prototype.unhook=function(e){e.listener&&e.listener.dispose(),e.listener=null},e.prototype.dispose=function(){this.emitter.dispose()}}(),function(){function e(){this.buffers=[]}e.prototype.wrapEvent=function(e){var t=this;return function(n,r,i){return e((function(e){var i=t.buffers[t.buffers.length-1];i?i.push((function(){return n.call(r,e)})):n.call(r,e)}),void 0,i)}},e.prototype.bufferEvents=function(e){var t=[];this.buffers.push(t);var n=e();return this.buffers.pop(),t.forEach((function(e){return e()})),n}}(),function(){function e(){var e=this;this.listening=!1,this.inputEvent=le.None,this.inputEventListener=l.None,this.emitter=new pe({onFirstListenerDidAdd:function(){e.listening=!0,e.inputEventListener=e.inputEvent(e.emitter.fire,e.emitter)},onLastListenerRemove:function(){e.listening=!1,e.inputEventListener.dispose()}}),this.event=this.emitter.event}Object.defineProperty(e.prototype,"input",{set:function(e){this.inputEvent=e,this.listening&&(this.inputEventListener.dispose(),this.inputEventListener=e(this.emitter.fire,this.emitter))},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){this.inputEventListener.dispose(),this.emitter.dispose()}}(),Object.freeze((function(e,t){var n=setTimeout(e.bind(t),0);return{dispose:function(){clearTimeout(n)}}})));(me=de||(de={})).isCancellationToken=function(e){return e===me.None||e===me.Cancelled||e instanceof ve||!(!e||"object"!=typeof e)&&"boolean"==typeof e.isCancellationRequested&&"function"==typeof e.onCancellationRequested},me.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:le.None}),me.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:ge});var _e,ve=function(){function e(){this._isCancelled=!1,this._emitter=null}return e.prototype.cancel=function(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))},Object.defineProperty(e.prototype,"isCancellationRequested",{get:function(){return this._isCancelled},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onCancellationRequested",{get:function(){return this._isCancelled?ge:(this._emitter||(this._emitter=new pe),this._emitter.event)},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){this._emitter&&(this._emitter.dispose(),this._emitter=null)},e}(),ye=function(){function e(e){this._token=void 0,this._parentListener=void 0,this._parentListener=e&&e.onCancellationRequested(this.cancel,this)}return Object.defineProperty(e.prototype,"token",{get:function(){return this._token||(this._token=new ve),this._token},enumerable:!0,configurable:!0}),e.prototype.cancel=function(){this._token?this._token instanceof ve&&this._token.cancel():this._token=de.Cancelled},e.prototype.dispose=function(){this._parentListener&&this._parentListener.dispose(),this._token?this._token instanceof ve&&this._token.dispose():this._token=de.None},e}(),Ce=function(){function e(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}return e.prototype.define=function(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e},e.prototype.keyCodeToStr=function(e){return this._keyCodeToStr[e]},e.prototype.strToKeyCode=function(e){return this._strToKeyCode[e.toLowerCase()]||0},e}(),be=new Ce,Le=new Ce,Ne=new Ce;!function(){function e(e,t,n,r){void 0===n&&(n=t),void 0===r&&(r=n),be.define(e,t),Le.define(e,n),Ne.define(e,r)}e(0,"unknown"),e(1,"Backspace"),e(2,"Tab"),e(3,"Enter"),e(4,"Shift"),e(5,"Ctrl"),e(6,"Alt"),e(7,"PauseBreak"),e(8,"CapsLock"),e(9,"Escape"),e(10,"Space"),e(11,"PageUp"),e(12,"PageDown"),e(13,"End"),e(14,"Home"),e(15,"LeftArrow","Left"),e(16,"UpArrow","Up"),e(17,"RightArrow","Right"),e(18,"DownArrow","Down"),e(19,"Insert"),e(20,"Delete"),e(21,"0"),e(22,"1"),e(23,"2"),e(24,"3"),e(25,"4"),e(26,"5"),e(27,"6"),e(28,"7"),e(29,"8"),e(30,"9"),e(31,"A"),e(32,"B"),e(33,"C"),e(34,"D"),e(35,"E"),e(36,"F"),e(37,"G"),e(38,"H"),e(39,"I"),e(40,"J"),e(41,"K"),e(42,"L"),e(43,"M"),e(44,"N"),e(45,"O"),e(46,"P"),e(47,"Q"),e(48,"R"),e(49,"S"),e(50,"T"),e(51,"U"),e(52,"V"),e(53,"W"),e(54,"X"),e(55,"Y"),e(56,"Z"),e(57,"Meta"),e(58,"ContextMenu"),e(59,"F1"),e(60,"F2"),e(61,"F3"),e(62,"F4"),e(63,"F5"),e(64,"F6"),e(65,"F7"),e(66,"F8"),e(67,"F9"),e(68,"F10"),e(69,"F11"),e(70,"F12"),e(71,"F13"),e(72,"F14"),e(73,"F15"),e(74,"F16"),e(75,"F17"),e(76,"F18"),e(77,"F19"),e(78,"NumLock"),e(79,"ScrollLock"),e(80,";",";","OEM_1"),e(81,"=","=","OEM_PLUS"),e(82,",",",","OEM_COMMA"),e(83,"-","-","OEM_MINUS"),e(84,".",".","OEM_PERIOD"),e(85,"/","/","OEM_2"),e(86,"`","`","OEM_3"),e(110,"ABNT_C1"),e(111,"ABNT_C2"),e(87,"[","[","OEM_4"),e(88,"\\","\\","OEM_5"),e(89,"]","]","OEM_6"),e(90,"'","'","OEM_7"),e(91,"OEM_8"),e(92,"OEM_102"),e(93,"NumPad0"),e(94,"NumPad1"),e(95,"NumPad2"),e(96,"NumPad3"),e(97,"NumPad4"),e(98,"NumPad5"),e(99,"NumPad6"),e(100,"NumPad7"),e(101,"NumPad8"),e(102,"NumPad9"),e(103,"NumPad_Multiply"),e(104,"NumPad_Add"),e(105,"NumPad_Separator"),e(106,"NumPad_Subtract"),e(107,"NumPad_Decimal"),e(108,"NumPad_Divide")}(),function(e){e.toString=function(e){return be.keyCodeToStr(e)},e.fromString=function(e){return be.strToKeyCode(e)},e.toUserSettingsUS=function(e){return Le.keyCodeToStr(e)},e.toUserSettingsGeneral=function(e){return Ne.keyCodeToStr(e)},e.fromUserSettings=function(e){return Le.strToKeyCode(e)||Ne.strToKeyCode(e)}}(_e||(_e={}));!function(){function e(e,t,n,r,i){this.ctrlKey=e,this.shiftKey=t,this.altKey=n,this.metaKey=r,this.keyCode=i}e.prototype.equals=function(e){return this.ctrlKey===e.ctrlKey&&this.shiftKey===e.shiftKey&&this.altKey===e.altKey&&this.metaKey===e.metaKey&&this.keyCode===e.keyCode},e.prototype.isModifierKey=function(){return 0===this.keyCode||5===this.keyCode||57===this.keyCode||6===this.keyCode||4===this.keyCode},e.prototype.toChord=function(){return new $e([this])},e.prototype.isDuplicateModifierCase=function(){return this.ctrlKey&&5===this.keyCode||this.shiftKey&&4===this.keyCode||this.altKey&&6===this.keyCode||this.metaKey&&57===this.keyCode}}();var Ee,Se,we,Ae,Me,Te,Pe,Oe,xe,Ie,Re,ke,Ue,Fe,De,Ke,qe,Ve,Be,je,Ye,We,He,Ge,Qe,ze,Xe,$e=function(){function e(e){if(0===e.length)throw(t="parts")?new Error("Illegal argument: "+t):new Error("Illegal argument");var t;this.parts=e}return e.prototype.equals=function(e){if(null===e)return!1;if(this.parts.length!==e.parts.length)return!1;for(var t=0;t "+this.positionLineNumber+","+this.positionColumn+"]"},t.prototype.equalsSelection=function(e){return t.selectionsEqual(this,e)},t.selectionsEqual=function(e,t){return e.selectionStartLineNumber===t.selectionStartLineNumber&&e.selectionStartColumn===t.selectionStartColumn&&e.positionLineNumber===t.positionLineNumber&&e.positionColumn===t.positionColumn},t.prototype.getDirection=function(){return this.selectionStartLineNumber===this.startLineNumber&&this.selectionStartColumn===this.startColumn?0:1},t.prototype.setEndPosition=function(e,n){return 0===this.getDirection()?new t(this.startLineNumber,this.startColumn,e,n):new t(e,n,this.startLineNumber,this.startColumn)},t.prototype.getPosition=function(){return new B(this.positionLineNumber,this.positionColumn)},t.prototype.setStartPosition=function(e,n){return 0===this.getDirection()?new t(e,n,this.endLineNumber,this.endColumn):new t(this.endLineNumber,this.endColumn,e,n)},t.fromPositions=function(e,n){return void 0===n&&(n=e),new t(e.lineNumber,e.column,n.lineNumber,n.column)},t.liftSelection=function(e){return new t(e.selectionStartLineNumber,e.selectionStartColumn,e.positionLineNumber,e.positionColumn)},t.selectionsArrEqual=function(e,t){if(e&&!t||!e&&t)return!1;if(!e&&!t)return!0;if(e.length!==t.length)return!1;for(var n=0,r=e.length;n>>0)>>>0}(e,t)},e.CtrlCmd=2048,e.Shift=1024,e.Alt=512,e.WinCtrl=256,e}();var nt=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),rt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return nt(t,e),Object.defineProperty(t.prototype,"uri",{get:function(){return this._uri},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"version",{get:function(){return this._versionId},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"eol",{get:function(){return this._eol},enumerable:!0,configurable:!0}),t.prototype.getValue=function(){return this.getText()},t.prototype.getLinesContent=function(){return this._lines.slice(0)},t.prototype.getLineCount=function(){return this._lines.length},t.prototype.getLineContent=function(e){return this._lines[e-1]},t.prototype.getWordAtPosition=function(e,t){var n=function(e,t,n,r){t.lastIndex=0;var i=t.exec(n);if(!i)return null;var o=i[0].indexOf(" ")>=0?function(e,t,n,r){var i,o=e-1-r;for(t.lastIndex=0;i=t.exec(n);){var s=i.index||0;if(s>o)return null;if(t.lastIndex>=o)return{word:i[0],startColumn:r+1+s,endColumn:r+1+t.lastIndex}}return null}(e,t,n,r):function(e,t,n,r){var i,o=e-1-r,s=n.lastIndexOf(" ",o-1)+1;for(t.lastIndex=s;i=t.exec(n);){var u=i.index||0;if(u<=o&&t.lastIndex>=o)return{word:i[0],startColumn:r+1+u,endColumn:r+1+t.lastIndex}}return null}(e,t,n,r);return t.lastIndex=0,o}(e.column,function(e){var t=ne;if(e&&e instanceof RegExp)if(e.global)t=e;else{var n="g";e.ignoreCase&&(n+="i"),e.multiline&&(n+="m"),e.unicode&&(n+="u"),t=new RegExp(e.source,n)}return t.lastIndex=0,t}(t),this._lines[e.lineNumber-1],0);return n?new j(e.lineNumber,n.startColumn,e.lineNumber,n.endColumn):null},t.prototype.getWordUntilPosition=function(e,t){var n=this.getWordAtPosition(e,t);return n?{word:this._lines[e.lineNumber-1].substring(n.startColumn-1,e.column-1),startColumn:n.startColumn,endColumn:e.column}:{word:"",startColumn:e.column,endColumn:e.column}},t.prototype.createWordIterator=function(e){var t,n,r=this,i=0,o=0,s=[],u=function(){if(o=r._lines.length?w:(n=r._lines[i],s=r._wordenize(n,e),o=0,i+=1,u())};return{next:u}},t.prototype.getLineWords=function(e,t){for(var n=this._lines[e-1],r=[],i=0,o=this._wordenize(n,t);ithis._lines.length)t=this._lines.length,n=this._lines[t-1].length+1,r=!0;else{var i=this._lines[t-1].length+1;n<1?(n=1,r=!0):n>i&&(n=i,r=!0)}return r?{lineNumber:t,column:n}:e},t}(te),it=function(e){function t(t){var n=e.call(this,t)||this;return n._models=Object.create(null),n}return nt(t,e),t.prototype.dispose=function(){this._models=Object.create(null)},t.prototype._getModel=function(e){return this._models[e]},t.prototype._getModels=function(){var e=this,t=[];return Object.keys(this._models).forEach((function(n){return t.push(e._models[n])})),t},t.prototype.acceptNewModel=function(e){this._models[e.url]=new rt(k.parse(e.url),e.lines,e.EOL,e.versionId)},t.prototype.acceptModelChanged=function(e,t){this._models[e]&&this._models[e].onEvents(t)},t.prototype.acceptRemovedModel=function(e){this._models[e]&&delete this._models[e]},t}(function(){function e(e){this._foreignModuleFactory=e,this._foreignModule=null}return e.prototype.computeDiff=function(e,t,n){var r=this._getModel(e),i=this._getModel(t);if(!r||!i)return Promise.resolve(null);var o=r.getLinesContent(),s=i.getLinesContent(),u=new z(o,s,{shouldComputeCharChanges:!0,shouldPostProcessCharChanges:!0,shouldIgnoreTrimWhitespace:n,shouldMakePrettyDiff:!0}).computeDiff(),a=!(u.length>0)&&this._modelsAreIdentical(r,i);return Promise.resolve({identical:a,changes:u})},e.prototype._modelsAreIdentical=function(e,t){var n=e.getLineCount();if(n!==t.getLineCount())return!1;for(var r=1;r<=n;r++){if(e.getLineContent(r)!==t.getLineContent(r))return!1}return!0},e.prototype.computeMoreMinimalEdits=function(t,n){var r=this._getModel(t);if(!r)return Promise.resolve(n);for(var i=[],o=void 0,s=0,u=n=g(n,(function(e,t){return e.range&&t.range?j.compareRangesUsingStarts(e.range,t.range):(e.range?0:1)-(t.range?0:1)}));se._diffLimit)i.push({range:l,text:c});else for(var d=y(h,c,!1),m=r.offsetAt(j.lift(l).getStartPosition()),p=0,_=d;p<_.length;p++){var v=_[p],C=r.positionAt(m+v.originalStart),b=r.positionAt(m+v.originalStart+v.originalLength),L={text:c.substr(v.modifiedStart,v.modifiedLength),range:{startLineNumber:C.lineNumber,startColumn:C.column,endLineNumber:b.lineNumber,endColumn:b.column}};r.getValueInRange(L.range)!==L.text&&i.push(L)}}}return"number"==typeof o&&i.push({eol:o,text:"",range:{startLineNumber:0,startColumn:0,endLineNumber:0,endColumn:0}}),Promise.resolve(i)},e.prototype.computeLinks=function(e){var t=this._getModel(e);return t?Promise.resolve(function(e){return e&&"function"==typeof e.getLineCount&&"function"==typeof e.getLineContent?ue.computeLinks(e):[]}(t)):Promise.resolve(null)},e.prototype.textualSuggest=function(t,n,r,i){var o=this._getModel(t);if(!o)return Promise.resolve(null);var s=Object.create(null),u=[],a=new RegExp(r,i),l=o.getWordUntilPosition(n,a),c=o.getWordAtPosition(n,a);c&&(s[o.getValueInRange(c)]=!0);for(var f=o.createWordIterator(a),h=f.next();!h.done&&u.length<=e._suggestionsLimit;h=f.next()){var d=h.value;s[d]||(s[d]=!0,isNaN(Number(d))&&u.push({kind:18,label:d,insertText:d,range:{startLineNumber:n.lineNumber,startColumn:l.startColumn,endLineNumber:n.lineNumber,endColumn:l.endColumn}}))}return Promise.resolve({suggestions:u})},e.prototype.computeWordRanges=function(e,t,n,r){var i=this._getModel(e);if(!i)return Promise.resolve(Object.create(null));for(var o=new RegExp(n,r),s=Object.create(null),u=t.startLineNumber;u{let e,t,n,r,i,o={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},s=function(t){throw{at:e,text:t,message:t}},u=function(t){return t&&t!==n&&s("Expected '"+t+"' instead of '"+n+"'"),n=r.charAt(e),e+=1,n},a=function(t,i){let o=e,u=r.indexOf(t,o);var a;return u<0&&s(i||"Expected '"+t+"'"),a=u+t.length,n=r.charAt(a),e=a+1,r.substring(o,u)},l=function(){var e,t="";for("-"===n&&(t="-",u("-"));n>="0"&&"9">=n;)t+=n,u();if("."===n)for(t+=".";u()&&n>="0"&&"9">=n;)t+=n;if("e"===n||"E"===n)for(t+=n,u(),("-"===n||"+"===n)&&(t+=n,u());n>="0"&&"9">=n;)t+=n,u();return e=+t,isNaN(e)?void s("Bad number"):e},c=function(){let t,i,l,c="";if('"'===n){if(f='""',r.substr(e,f.length)===f)return u('"'),u('"'),a('"""','failed to find closing \'"""\'');for(;u();){if('"'===n)return u(),c;if("\\"===n)if(u(),"u"===n){for(l=0,i=0;4>i&&(t=parseInt(u(),16),isFinite(t));i+=1)l=16*l+t;c+=String.fromCharCode(l)}else{if("string"!=typeof o[n])break;c+=o[n]}else c+=n}}var f;s("Bad string")},f=function(){for(;n&&" ">=n;)u()};return i=function(){switch(f(),n){case"{":return function(){var r,o,a,l={};if("{"===n){if(u("{"),f(),"}"===n)return u("}"),l;for(;n;){let s=e;if(r=c(),f(),u(":"),Object.hasOwnProperty.call(l,r)&&(o='Duplicate key "'+r+'"',a=s,t.push({type:ut.warning,at:a,text:o})),l[r]=i(),f(),"}"===n)return u("}"),l;u(","),f()}}s("Bad object")}();case"[":return function(){var e=[];if("["===n){if(u("["),f(),"]"===n)return u("]"),e;for(;n;){if(e.push(i()),f(),"]"===n)return u("]"),e;u(","),f()}}s("Bad array")}();case'"':return c();case"-":return l();default:return n>="0"&&"9">=n?l():function(){switch(n){case"t":return u("t"),u("r"),u("u"),u("e"),!0;case"f":return u("f"),u("a"),u("l"),u("s"),u("e"),!1;case"n":return u("n"),u("u"),u("l"),u("l"),null}s("Unexpected '"+n+"'")}()}},function(o){t=[];let u=!1;r=o,e=0,n=" ",f();try{i()}catch(e){u=!0,t.push({type:ut.error,at:e.at-1,text:e.message})}return!u&&n&&s("Syntax error"),{annotations:t}}};class lt{constructor(e){this.ctx=e}async parse(){this.parser||(this.parser=at());const[e]=this.ctx.getMirrorModels();return this.parser(e.getValue())}}self.onmessage=()=>{st((e,t)=>new lt(e))}}]); \ No newline at end of file diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/grammar.ts b/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/grammar.ts new file mode 100644 index 00000000000000..e95059f9ece2dd --- /dev/null +++ b/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/grammar.ts @@ -0,0 +1,213 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export enum AnnoTypes { + error = 'error', + warning = 'warning', +} + +/* eslint-disable */ + +export const createParser = () => { + 'use strict'; + let at: any, + annos: any[], // annotations + ch: any, + text: any, + value: any, + escapee: any = { + '"': '"', + '\\': '\\', + '/': '/', + b: '\b', + f: '\f', + n: '\n', + r: '\r', + t: ' ', + }, + error = function (m: string) { + throw { + at: at, + text: m, + message: m, + }; + }, + warning = function (m: string, idx: number) { + annos.push({ + type: AnnoTypes.warning, + at: idx, + text: m, + }); + }, + reset = function (newAt: number) { + ch = text.charAt(newAt); + at = newAt + 1; + }, + next = function (c?: string) { + return ( + c && c !== ch && error("Expected '" + c + "' instead of '" + ch + "'"), + (ch = text.charAt(at)), + (at += 1), + ch + ); + }, + nextUpTo = function (upTo: any, errorMessage: string) { + let currentAt = at, + i = text.indexOf(upTo, currentAt); + if (i < 0) { + error(errorMessage || "Expected '" + upTo + "'"); + } + reset(i + upTo.length); + return text.substring(currentAt, i); + }, + peek = function (c: string) { + return text.substr(at, c.length) === c; // nocommit - double check + }, + number = function () { + var number, + string = ''; + for ('-' === ch && ((string = '-'), next('-')); ch >= '0' && '9' >= ch; ) + (string += ch), next(); + if ('.' === ch) for (string += '.'; next() && ch >= '0' && '9' >= ch; ) string += ch; + if ('e' === ch || 'E' === ch) + for ( + string += ch, next(), ('-' === ch || '+' === ch) && ((string += ch), next()); + ch >= '0' && '9' >= ch; + + ) + (string += ch), next(); + return (number = +string), isNaN(number) ? (error('Bad number'), void 0) : number; + }, + string = function () { + let hex: any, + i: any, + uffff: any, + string = ''; + if ('"' === ch) { + if (peek('""')) { + // literal + next('"'); + next('"'); + return nextUpTo('"""', 'failed to find closing \'"""\''); + } else { + for (; next(); ) { + if ('"' === ch) return next(), string; + if ('\\' === ch) + if ((next(), 'u' === ch)) { + for ( + uffff = 0, i = 0; + 4 > i && ((hex = parseInt(next(), 16)), isFinite(hex)); + i += 1 + ) + uffff = 16 * uffff + hex; + string += String.fromCharCode(uffff); + } else { + if ('string' != typeof escapee[ch]) break; + string += escapee[ch]; + } + else string += ch; + } + } + } + error('Bad string'); + }, + white = function () { + for (; ch && ' ' >= ch; ) next(); + }, + word = function () { + switch (ch) { + case 't': + return next('t'), next('r'), next('u'), next('e'), !0; + case 'f': + return next('f'), next('a'), next('l'), next('s'), next('e'), !1; + case 'n': + return next('n'), next('u'), next('l'), next('l'), null; + } + error("Unexpected '" + ch + "'"); + }, + array = function () { + var array: any[] = []; + if ('[' === ch) { + if ((next('['), white(), ']' === ch)) return next(']'), array; + for (; ch; ) { + if ((array.push(value()), white(), ']' === ch)) return next(']'), array; + next(','), white(); + } + } + error('Bad array'); + }, + object = function () { + var key, + object: any = {}; + if ('{' === ch) { + if ((next('{'), white(), '}' === ch)) return next('}'), object; + for (; ch; ) { + let latchKeyStart = at; + if ( + ((key = string()), + white(), + next(':'), + Object.hasOwnProperty.call(object, key) && + warning('Duplicate key "' + key + '"', latchKeyStart), + (object[key] = value()), + white(), + '}' === ch) + ) + return next('}'), object; + next(','), white(); + } + } + error('Bad object'); + }; + return ( + (value = function () { + switch ((white(), ch)) { + case '{': + return object(); + case '[': + return array(); + case '"': + return string(); + case '-': + return number(); + default: + return ch >= '0' && '9' >= ch ? number() : word(); + } + }), + function (source: string) { + annos = []; + let errored = false; + text = source; + at = 0; + ch = ' '; + white(); + + try { + value(); + } catch (e) { + errored = true; + annos.push({ type: AnnoTypes.error, at: e.at - 1, text: e.message }); + } + if (!errored && ch) { + error('Syntax error'); + } + return { annotations: annos }; + } + ); +}; diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/index.ts b/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/index.ts new file mode 100644 index 00000000000000..16629b1375dab9 --- /dev/null +++ b/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/index.ts @@ -0,0 +1,23 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +// This export also registers the language globally +export { registerGrammarChecker } from './language'; + +export { ID } from './constants'; diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/language.ts b/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/language.ts new file mode 100644 index 00000000000000..32782b328c4cd4 --- /dev/null +++ b/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/language.ts @@ -0,0 +1,86 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import 'monaco-editor/esm/vs/editor/contrib/hover/hover'; +import 'monaco-editor/esm/vs/editor/contrib/wordOperations/wordOperations'; +import { monaco } from '@kbn/ui-shared-deps/monaco'; +import { WorkerProxyService } from './worker_proxy_service'; +import './lexer_rules'; +import { ID } from './constants'; +// @ts-ignore +import workerSrc from '!!raw-loader!./dist/bundle.amd.worker.js'; + +const wps = new WorkerProxyService(); + +// In future we will need to make this map languages to workers using "id" and/or "label" values +// that get passed in. +// @ts-ignore +window.MonacoEnvironment = { + getWorker: (id: any, label: any) => { + // In kibana we will probably build this once and then load with raw-loader + const blob = new Blob([workerSrc], { type: 'application/javascript' }); + return new Worker(URL.createObjectURL(blob)); + }, +}; + +monaco.languages.onLanguage(ID, async () => { + return wps.setup(); +}); + +const OWNER = 'XJSON_GRAMMAR_CHECKER'; +export const registerGrammarChecker = (editor: monaco.editor.IEditor) => { + const allDisposables: monaco.IDisposable[] = []; + + const updateAnnos = async () => { + const { annotations } = await wps.getAnnos(); + const model = editor.getModel() as monaco.editor.ITextModel; + monaco.editor.setModelMarkers( + model, + OWNER, + annotations.map(({ at, text, type }) => { + const { column, lineNumber } = model.getPositionAt(at); + return { + startLineNumber: lineNumber, + startColumn: column, + endLineNumber: lineNumber, + endColumn: column, + message: text, + severity: type === 'error' ? monaco.MarkerSeverity.Error : monaco.MarkerSeverity.Warning, + }; + }) + ); + }; + + const onModelAdd = (model: monaco.editor.IModel) => { + allDisposables.push( + model.onDidChangeContent(async () => { + updateAnnos(); + }) + ); + + updateAnnos(); + }; + + allDisposables.push(monaco.editor.onDidCreateModel(onModelAdd)); + monaco.editor.getModels().forEach(onModelAdd); + return () => { + wps.stop(); + allDisposables.forEach((d) => d.dispose()); + }; +}; diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/lexer_rules/esql.ts b/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/lexer_rules/esql.ts new file mode 100644 index 00000000000000..58adf738132a87 --- /dev/null +++ b/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/lexer_rules/esql.ts @@ -0,0 +1,273 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { monaco } from '@kbn/ui-shared-deps/monaco'; + +const ID = 'esql'; + +const brackets = [ + { open: '[', close: ']', token: 'delimiter.square' }, + { open: '(', close: ')', token: 'delimiter.parenthesis' }, +]; + +const keywords = [ + 'describe', + 'between', + 'in', + 'like', + 'not', + 'and', + 'or', + 'desc', + 'select', + 'from', + 'where', + 'having', + 'group', + 'by', + 'order', + 'asc', + 'desc', + 'pivot', + 'for', + 'in', + 'as', + 'show', + 'columns', + 'include', + 'frozen', + 'tables', + 'escape', + 'limit', + 'rlike', + 'all', + 'distinct', + 'is', +]; +const builtinFunctions = [ + 'avg', + 'count', + 'first', + 'first_value', + 'last', + 'last_value', + 'max', + 'min', + 'sum', + 'kurtosis', + 'mad', + 'percentile', + 'percentile_rank', + 'skewness', + 'stddev_pop', + 'sum_of_squares', + 'var_pop', + 'histogram', + 'case', + 'coalesce', + 'greatest', + 'ifnull', + 'iif', + 'isnull', + 'least', + 'nullif', + 'nvl', + 'curdate', + 'current_date', + 'current_time', + 'current_timestamp', + 'curtime', + 'dateadd', + 'datediff', + 'datepart', + 'datetrunc', + 'date_add', + 'date_diff', + 'date_part', + 'date_trunc', + 'day', + 'dayname', + 'dayofmonth', + 'dayofweek', + 'dayofyear', + 'day_name', + 'day_of_month', + 'day_of_week', + 'day_of_year', + 'dom', + 'dow', + 'doy', + 'hour', + 'hour_of_day', + 'idow', + 'isodayofweek', + 'isodow', + 'isoweek', + 'isoweekofyear', + 'iso_day_of_week', + 'iso_week_of_year', + 'iw', + 'iwoy', + 'minute', + 'minute_of_day', + 'minute_of_hour', + 'month', + 'monthname', + 'month_name', + 'month_of_year', + 'now', + 'quarter', + 'second', + 'second_of_minute', + 'timestampadd', + 'timestampdiff', + 'timestamp_add', + 'timestamp_diff', + 'today', + 'week', + 'week_of_year', + 'year', + 'abs', + 'acos', + 'asin', + 'atan', + 'atan2', + 'cbrt', + 'ceil', + 'ceiling', + 'cos', + 'cosh', + 'cot', + 'degrees', + 'e', + 'exp', + 'expm1', + 'floor', + 'log', + 'log10', + 'mod', + 'pi', + 'power', + 'radians', + 'rand', + 'random', + 'round', + 'sign', + 'signum|sin', + 'sinh', + 'sqrt', + 'tan', + 'truncate', + 'ascii', + 'bit_length', + 'char', + 'character_length', + 'char_length', + 'concat', + 'insert', + 'lcase', + 'left', + 'length', + 'locate', + 'ltrim', + 'octet_length', + 'position', + 'repeat', + 'replace', + 'right', + 'rtrim', + 'space', + 'substring', + 'ucase', + 'cast', + 'convert', + 'database', + 'user', + 'st_astext', + 'st_aswkt', + 'st_distance', + 'st_geometrytype', + 'st_geomfromtext', + 'st_wkttosql', + 'st_x', + 'st_y', + 'st_z', + 'score', +]; + +export const lexerRules = { + defaultToken: 'invalid', + ignoreCase: true, + tokenPostfix: '', + keywords, + builtinFunctions, + brackets, + tokenizer: { + root: [ + [ + /[a-zA-Z_$][a-zA-Z0-9_$]*\b/, + { + cases: { + '@keywords': 'keyword', + '@builtinFunctions': 'identifier', + '@default': 'identifier', + }, + }, + ], + [/[()]/, '@brackets'], + [/--.*$/, 'comment'], + [/\/\*/, 'comment', '@comment'], + [/\/.*$/, 'comment'], + + [/".*?"/, 'string'], + + [/'.*?'/, 'constant'], + [/`.*?`/, 'string'], + // whitespace + [/[ \t\r\n]+/, { token: '@whitespace' }], + [/[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b/, 'entity.name.function'], + [/⇐|<⇒|\*|\.|\:\:|\+|\-|\/|\/\/|%|&|\^|~|<|>|<=|=>|==|!=|<>|=/, 'keyword.operator'], + [/[\(]/, 'paren.lparen'], + [/[\)]/, 'paren.rparen'], + [/\s+/, 'text'], + ], + numbers: [ + [/0[xX][0-9a-fA-F]*/, 'number'], + [/[$][+-]*\d*(\.\d*)?/, 'number'], + [/((\d+(\.\d*)?)|(\.\d+))([eE][\-+]?\d+)?/, 'number'], + ], + strings: [ + [/N'/, { token: 'string', next: '@string' }], + [/'/, { token: 'string', next: '@string' }], + ], + string: [ + [/[^']+/, 'string'], + [/''/, 'string'], + [/'/, { token: 'string', next: '@pop' }], + ], + comment: [ + [/[^\/*]+/, 'comment'], + [/\*\//, 'comment', '@pop'], + [/[\/*]/, 'comment'], + ], + }, +} as monaco.languages.IMonarchLanguage; + +monaco.languages.register({ id: ID }); +monaco.languages.setMonarchTokensProvider(ID, lexerRules); diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/lexer_rules/index.ts b/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/lexer_rules/index.ts new file mode 100644 index 00000000000000..810e78b6b4aa73 --- /dev/null +++ b/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/lexer_rules/index.ts @@ -0,0 +1,20 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export { lexerRules } from './xjson'; diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/lexer_rules/painless.ts b/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/lexer_rules/painless.ts new file mode 100644 index 00000000000000..c24537a60bf49d --- /dev/null +++ b/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/lexer_rules/painless.ts @@ -0,0 +1,194 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { monaco } from '@kbn/ui-shared-deps/monaco'; + +const ID = 'painless'; + +/** + * Extends the default type for a Monarch language so we can use + * attribute references (like @keywords to reference the keywords list) + * in the defined tokenizer + */ +interface Language extends monaco.languages.IMonarchLanguage { + default: string; + brackets: any; + keywords: string[]; + symbols: RegExp; + escapes: RegExp; + digits: RegExp; + primitives: string[]; + octaldigits: RegExp; + binarydigits: RegExp; + constants: string[]; + operators: string[]; +} + +export const lexerRules = { + default: 'invalid', + tokenPostfix: '', + // painless does not use < >, so we define our own + brackets: [ + ['{', '}', 'delimiter.curly'], + ['[', ']', 'delimiter.square'], + ['(', ')', 'delimiter.parenthesis'], + ], + keywords: [ + 'if', + 'in', + 'else', + 'while', + 'do', + 'for', + 'continue', + 'break', + 'return', + 'new', + 'try', + 'catch', + 'throw', + 'this', + 'instanceof', + ], + primitives: ['void', 'boolean', 'byte', 'short', 'char', 'int', 'long', 'float', 'double', 'def'], + constants: ['true', 'false'], + operators: [ + '=', + '>', + '<', + '!', + '~', + '?', + '?:', + '?.', + ':', + '==', + '===', + '<=', + '>=', + '!=', + '!==', + '&&', + '||', + '++', + '--', + '+', + '-', + '*', + '/', + '&', + '|', + '^', + '%', + '<<', + '>>', + '>>>', + '+=', + '-=', + '*=', + '/=', + '&=', + '|=', + '^=', + '%=', + '<<=', + '>>=', + '>>>=', + '->', + '::', + '=~', + '==~', + ], + symbols: /[=> ({ + mode: 'production', + entry: path.resolve(__dirname, `./worker/${lang}.worker.ts`), + output: { + path: path.resolve(__dirname, 'dist'), + filename: 'bundle.amd.worker.js', + }, + resolve: { + modules: ['node_modules'], + extensions: ['.js', '.ts', '.tsx'], + }, + module: { + rules: [ + { + test: /\.ts$/, + exclude: /node_modules/, + use: { + loader: 'babel-loader', + options: { + presets: ['@babel/typescript'], + }, + }, + }, + ], + }, + plugins: [new webpack.BannerPlugin('/* eslint-disable */')], +}); + +module.exports = createConfig('xjson'); diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/worker/index.ts b/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/worker/index.ts new file mode 100644 index 00000000000000..87c3c3c46b81e2 --- /dev/null +++ b/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/worker/index.ts @@ -0,0 +1,20 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export { XJsonWorker } from './xjson_worker'; diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/worker/xjson.worker.ts b/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/worker/xjson.worker.ts new file mode 100644 index 00000000000000..5e6482fcbda65b --- /dev/null +++ b/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/worker/xjson.worker.ts @@ -0,0 +1,30 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +// Please note: this module is intended to be run inside of a webworker. + +// @ts-ignore +import * as worker from 'monaco-editor/esm/vs/editor/editor.worker'; +import { XJsonWorker } from './xjson_worker'; + +self.onmessage = () => { + worker.initialize((ctx: any, createData: any) => { + return new XJsonWorker(ctx); + }); +}; diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/worker/xjson_worker.ts b/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/worker/xjson_worker.ts new file mode 100644 index 00000000000000..5bc0f9fb91ab93 --- /dev/null +++ b/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/worker/xjson_worker.ts @@ -0,0 +1,34 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import * as monaco from 'monaco-editor/esm/vs/editor/editor.api'; +import { createParser } from '../grammar'; + +export class XJsonWorker { + constructor(private ctx: monaco.worker.IWorkerContext) {} + private parser: any; + + async parse() { + if (!this.parser) { + this.parser = createParser(); + } + const [model] = this.ctx.getMirrorModels(); + return this.parser(model.getValue()); + } +} diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/worker_proxy_service.ts b/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/worker_proxy_service.ts new file mode 100644 index 00000000000000..66eb72b03c3fc9 --- /dev/null +++ b/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/worker_proxy_service.ts @@ -0,0 +1,55 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { monaco } from '@kbn/ui-shared-deps/monaco'; +import { XJsonWorker } from './worker'; +import { AnnoTypes } from './grammar'; +import { ID } from './constants'; + +export interface Annotation { + name?: string; + type: AnnoTypes; + text: string; + at: number; +} + +export interface AnnotationsResponse { + annotations: Annotation[]; +} + +export class WorkerProxyService { + private worker: monaco.editor.MonacoWebWorker | undefined; + + public async getAnnos(): Promise { + if (!this.worker) { + throw new Error('Worker Proxy Service has not been setup!'); + } + await this.worker.withSyncedResources(monaco.editor.getModels().map(({ uri }) => uri)); + const proxy = await this.worker.getProxy(); + return proxy.parse(); + } + + public setup() { + this.worker = monaco.editor.createWebWorker({ label: ID }); + } + + public stop() { + if (this.worker) this.worker.dispose(); + } +} diff --git a/src/plugins/es_ui_shared/public/console_lang/index.ts b/src/plugins/es_ui_shared/public/console_lang/index.ts index 7d83191569622e..131eb1291e334f 100644 --- a/src/plugins/es_ui_shared/public/console_lang/index.ts +++ b/src/plugins/es_ui_shared/public/console_lang/index.ts @@ -20,6 +20,8 @@ // Lib is intentionally not included in this barrel export file to separate worker logic // from being imported with pure functions +export { monaco } from '../../__packages_do_not_import__/monaco'; + export { ElasticsearchSqlHighlightRules, ScriptHighlightRules, diff --git a/src/plugins/es_ui_shared/public/index.ts b/src/plugins/es_ui_shared/public/index.ts index 7e5510d7c9c651..63c4f8d1b2a8e0 100644 --- a/src/plugins/es_ui_shared/public/index.ts +++ b/src/plugins/es_ui_shared/public/index.ts @@ -45,6 +45,7 @@ export { XJsonHighlightRules, collapseLiteralStrings, expandLiteralStrings, + monaco, } from './console_lang'; export { From c584bc5843262f5df9cbcb85d1075f7956db06cc Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Wed, 27 May 2020 16:17:04 +0200 Subject: [PATCH 02/26] Throwaway implementation in painless lab - THIS MUST BE REVERTED --- .../public/application/components/editor.tsx | 7 ++++- .../public/services/language_service.ts | 29 +++++++++---------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/x-pack/plugins/painless_lab/public/application/components/editor.tsx b/x-pack/plugins/painless_lab/public/application/components/editor.tsx index b8891ce6524f55..74454ad52c7f9f 100644 --- a/x-pack/plugins/painless_lab/public/application/components/editor.tsx +++ b/x-pack/plugins/painless_lab/public/application/components/editor.tsx @@ -6,6 +6,8 @@ import React from 'react'; import { CodeEditor } from '../../../../../../src/plugins/kibana_react/public'; +import { monaco } from '../../../../../../src/plugins/es_ui_shared/public'; + interface Props { code: string; onChange: (code: string) => void; @@ -14,10 +16,13 @@ interface Props { export function Editor({ code, onChange }: Props) { return ( { + monaco.XJsonLang.registerGrammarChecker(editor); + }} value={code} onChange={onChange} options={{ diff --git a/x-pack/plugins/painless_lab/public/services/language_service.ts b/x-pack/plugins/painless_lab/public/services/language_service.ts index efff9cd0e78d5e..e6d56a3e16910c 100644 --- a/x-pack/plugins/painless_lab/public/services/language_service.ts +++ b/x-pack/plugins/painless_lab/public/services/language_service.ts @@ -23,23 +23,22 @@ export class LanguageService { private originalMonacoEnvironment: any; public setup() { - monaco.languages.register({ id: LANGUAGE_ID }); - monaco.languages.setMonarchTokensProvider(LANGUAGE_ID, monacoPainlessLang); - - if (CAN_CREATE_WORKER) { - this.originalMonacoEnvironment = (window as any).MonacoEnvironment; - (window as any).MonacoEnvironment = { - getWorker: () => { - const blob = new Blob([workerSrc], { type: 'application/javascript' }); - return new Worker(window.URL.createObjectURL(blob)); - }, - }; - } + // monaco.languages.register({ id: LANGUAGE_ID }); + // monaco.languages.setMonarchTokensProvider(LANGUAGE_ID, monacoPainlessLang); + // if (CAN_CREATE_WORKER) { + // this.originalMonacoEnvironment = (window as any).MonacoEnvironment; + // (window as any).MonacoEnvironment = { + // getWorker: () => { + // const blob = new Blob([workerSrc], { type: 'application/javascript' }); + // return new Worker(window.URL.createObjectURL(blob)); + // }, + // }; + // } } public stop() { - if (CAN_CREATE_WORKER) { - (window as any).MonacoEnvironment = this.originalMonacoEnvironment; - } + // if (CAN_CREATE_WORKER) { + // (window as any).MonacoEnvironment = this.originalMonacoEnvironment; + // } } } From 573cb7d49684793128a6d1355925347206a89a00 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Thu, 28 May 2020 13:34:43 +0200 Subject: [PATCH 03/26] WiP on build process for new kbn-lang package --- packages/kbn-langs/index.ts | 20 +++++ packages/kbn-langs/package.json | 22 ++++++ packages/kbn-langs/scripts/build.js | 78 +++++++++++++++++++ packages/kbn-langs/webpack.config.js | 45 +++++++++++ .../kbn-langs/xjson}/grammar.ts | 0 packages/kbn-langs/xjson/index.ts | 20 +++++ .../kbn-langs/xjson/monaco}/README.md | 2 +- .../kbn-langs/xjson/monaco}/constants.ts | 0 .../xjson/monaco}/dist/bundle.amd.worker.js | 0 .../kbn-langs/xjson/monaco}/index.ts | 0 .../kbn-langs/xjson/monaco}/language.ts | 0 .../xjson/monaco}/lexer_rules/esql.ts | 0 .../xjson/monaco}/lexer_rules/index.ts | 0 .../xjson/monaco}/lexer_rules/painless.ts | 0 .../xjson/monaco}/lexer_rules/shared.ts | 0 .../xjson/monaco}/lexer_rules/xjson.ts | 0 .../monaco}/webpack.xjson-worker.config.js | 0 .../kbn-langs/xjson/monaco}/worker/index.ts | 0 .../xjson/monaco}/worker/xjson.worker.ts | 0 .../xjson/monaco}/worker/xjson_worker.ts | 2 +- .../xjson/monaco}/worker_proxy_service.ts | 2 +- .../es_ui_shared/public/console_lang/index.ts | 2 - src/plugins/es_ui_shared/public/index.ts | 1 - 23 files changed, 188 insertions(+), 6 deletions(-) create mode 100644 packages/kbn-langs/index.ts create mode 100644 packages/kbn-langs/package.json create mode 100644 packages/kbn-langs/scripts/build.js create mode 100644 packages/kbn-langs/webpack.config.js rename {src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang => packages/kbn-langs/xjson}/grammar.ts (100%) create mode 100644 packages/kbn-langs/xjson/index.ts rename {src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang => packages/kbn-langs/xjson/monaco}/README.md (98%) rename {src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang => packages/kbn-langs/xjson/monaco}/constants.ts (100%) rename {src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang => packages/kbn-langs/xjson/monaco}/dist/bundle.amd.worker.js (100%) rename {src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang => packages/kbn-langs/xjson/monaco}/index.ts (100%) rename {src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang => packages/kbn-langs/xjson/monaco}/language.ts (100%) rename {src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang => packages/kbn-langs/xjson/monaco}/lexer_rules/esql.ts (100%) rename {src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang => packages/kbn-langs/xjson/monaco}/lexer_rules/index.ts (100%) rename {src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang => packages/kbn-langs/xjson/monaco}/lexer_rules/painless.ts (100%) rename {src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang => packages/kbn-langs/xjson/monaco}/lexer_rules/shared.ts (100%) rename {src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang => packages/kbn-langs/xjson/monaco}/lexer_rules/xjson.ts (100%) rename {src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang => packages/kbn-langs/xjson/monaco}/webpack.xjson-worker.config.js (100%) rename {src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang => packages/kbn-langs/xjson/monaco}/worker/index.ts (100%) rename {src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang => packages/kbn-langs/xjson/monaco}/worker/xjson.worker.ts (100%) rename {src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang => packages/kbn-langs/xjson/monaco}/worker/xjson_worker.ts (96%) rename {src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang => packages/kbn-langs/xjson/monaco}/worker_proxy_service.ts (97%) diff --git a/packages/kbn-langs/index.ts b/packages/kbn-langs/index.ts new file mode 100644 index 00000000000000..6bdafd2463c171 --- /dev/null +++ b/packages/kbn-langs/index.ts @@ -0,0 +1,20 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export * from './xjson'; diff --git a/packages/kbn-langs/package.json b/packages/kbn-langs/package.json new file mode 100644 index 00000000000000..d252ed800eede4 --- /dev/null +++ b/packages/kbn-langs/package.json @@ -0,0 +1,22 @@ +{ + "name": "@kbn/langs", + "version": "1.0.0", + "main": "./target/index.js", + "license": "MIT", + "private": true, + "dependencies": { + "monaco-editor": "~0.17.0" + }, + "devDependencies": { + "getopts": "^2.2.4", + "babel-loader": "^8.0.6", + "webpack": "^4.41.5", + "webpack-cli": "^3.3.10", + "supports-color": "^7.0.0", + "del": "^5.1.0" + }, + "scripts": { + "//": "At this point in time we only have one language in here", + "build": "node ./scripts/build.js" + } +} diff --git a/packages/kbn-langs/scripts/build.js b/packages/kbn-langs/scripts/build.js new file mode 100644 index 00000000000000..59853f2820f1e9 --- /dev/null +++ b/packages/kbn-langs/scripts/build.js @@ -0,0 +1,78 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +const path = require('path'); +const del = require('del'); +const getopts = require('getopts'); +const supportsColor = require('supports-color'); +const { ToolingLog, withProcRunner, pickLevelFromFlags } = require('@kbn/dev-utils'); + +const TARGET_BUILD_DIR = path.resolve(__dirname, '../target'); +const WORKER_BUILD_DIRS = [path.resolve(__dirname, '../xjson/monaco')]; +const ROOT_DIR = path.resolve(__dirname, '../'); + +const flags = getopts(process.argv, { + boolean: ['watch', 'dev', 'help', 'debug'], +}); + +const log = new ToolingLog({ + level: pickLevelFromFlags(flags), + writeTo: process.stdout, +}); + +withProcRunner(log, async (proc) => { + log.info('Deleting old output'); + + await del(TARGET_BUILD_DIR); + + for (const workerBuildDir of WORKER_BUILD_DIRS) { + await del(`${workerBuildDir}/dist`); + } + + const cwd = ROOT_DIR; + const env = { ...process.env }; + if (supportsColor.stdout) { + env.FORCE_COLOR = 'true'; + } + + await Promise.all([ + WORKER_BUILD_DIRS.map((buildDir) => + proc.run(`webpack ${buildDir}`, { + cmd: 'webpack', + args: ['--config', `${buildDir}/webpack.worker.config.js`], + wait: true, + env, + cwd, + }) + ), + ]); + + await proc.run('webpack ', { + cmd: 'webpack', + args: ['--config', `${ROOT_DIR}/webpack.config.js`], + wait: true, + env, + cwd, + }); + + log.success('Complete'); +}).catch((error) => { + log.error(error); + process.exit(1); +}); diff --git a/packages/kbn-langs/webpack.config.js b/packages/kbn-langs/webpack.config.js new file mode 100644 index 00000000000000..cd9ffe174065e7 --- /dev/null +++ b/packages/kbn-langs/webpack.config.js @@ -0,0 +1,45 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +const path = require('path'); + +module.exports = { + mode: 'production', + entry: './index.ts', + output: { + path: path.resolve(__dirname, 'target'), + }, + resolve: { + modules: ['node_modules'], + extensions: ['.js', '.ts', '.tsx'], + }, + module: { + rules: [ + { + test: /\.ts$/, + exclude: /node_modules/, + use: { + loader: 'babel-loader', + options: { + presets: ['@babel/typescript'], + }, + }, + }, + ], + }, +}; diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/grammar.ts b/packages/kbn-langs/xjson/grammar.ts similarity index 100% rename from src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/grammar.ts rename to packages/kbn-langs/xjson/grammar.ts diff --git a/packages/kbn-langs/xjson/index.ts b/packages/kbn-langs/xjson/index.ts new file mode 100644 index 00000000000000..6f163ac6816254 --- /dev/null +++ b/packages/kbn-langs/xjson/index.ts @@ -0,0 +1,20 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export { monaco } from './monaco'; diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/README.md b/packages/kbn-langs/xjson/monaco/README.md similarity index 98% rename from src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/README.md rename to packages/kbn-langs/xjson/monaco/README.md index c13a9cc84796f5..49831670934874 100644 --- a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/README.md +++ b/packages/kbn-langs/xjson/monaco/README.md @@ -39,6 +39,6 @@ the grammar parser. A stateful mechanism for holding a reference to the Monaco-provided proxy getter. -### ./grammar +### ../grammar The parser logic that lives inside of the worker. Takes in a string and returns annotations for XJSON. diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/constants.ts b/packages/kbn-langs/xjson/monaco/constants.ts similarity index 100% rename from src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/constants.ts rename to packages/kbn-langs/xjson/monaco/constants.ts diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/dist/bundle.amd.worker.js b/packages/kbn-langs/xjson/monaco/dist/bundle.amd.worker.js similarity index 100% rename from src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/dist/bundle.amd.worker.js rename to packages/kbn-langs/xjson/monaco/dist/bundle.amd.worker.js diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/index.ts b/packages/kbn-langs/xjson/monaco/index.ts similarity index 100% rename from src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/index.ts rename to packages/kbn-langs/xjson/monaco/index.ts diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/language.ts b/packages/kbn-langs/xjson/monaco/language.ts similarity index 100% rename from src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/language.ts rename to packages/kbn-langs/xjson/monaco/language.ts diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/lexer_rules/esql.ts b/packages/kbn-langs/xjson/monaco/lexer_rules/esql.ts similarity index 100% rename from src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/lexer_rules/esql.ts rename to packages/kbn-langs/xjson/monaco/lexer_rules/esql.ts diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/lexer_rules/index.ts b/packages/kbn-langs/xjson/monaco/lexer_rules/index.ts similarity index 100% rename from src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/lexer_rules/index.ts rename to packages/kbn-langs/xjson/monaco/lexer_rules/index.ts diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/lexer_rules/painless.ts b/packages/kbn-langs/xjson/monaco/lexer_rules/painless.ts similarity index 100% rename from src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/lexer_rules/painless.ts rename to packages/kbn-langs/xjson/monaco/lexer_rules/painless.ts diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/lexer_rules/shared.ts b/packages/kbn-langs/xjson/monaco/lexer_rules/shared.ts similarity index 100% rename from src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/lexer_rules/shared.ts rename to packages/kbn-langs/xjson/monaco/lexer_rules/shared.ts diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/lexer_rules/xjson.ts b/packages/kbn-langs/xjson/monaco/lexer_rules/xjson.ts similarity index 100% rename from src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/lexer_rules/xjson.ts rename to packages/kbn-langs/xjson/monaco/lexer_rules/xjson.ts diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/webpack.xjson-worker.config.js b/packages/kbn-langs/xjson/monaco/webpack.xjson-worker.config.js similarity index 100% rename from src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/webpack.xjson-worker.config.js rename to packages/kbn-langs/xjson/monaco/webpack.xjson-worker.config.js diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/worker/index.ts b/packages/kbn-langs/xjson/monaco/worker/index.ts similarity index 100% rename from src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/worker/index.ts rename to packages/kbn-langs/xjson/monaco/worker/index.ts diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/worker/xjson.worker.ts b/packages/kbn-langs/xjson/monaco/worker/xjson.worker.ts similarity index 100% rename from src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/worker/xjson.worker.ts rename to packages/kbn-langs/xjson/monaco/worker/xjson.worker.ts diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/worker/xjson_worker.ts b/packages/kbn-langs/xjson/monaco/worker/xjson_worker.ts similarity index 96% rename from src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/worker/xjson_worker.ts rename to packages/kbn-langs/xjson/monaco/worker/xjson_worker.ts index 5bc0f9fb91ab93..d7901d1b9fcefb 100644 --- a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/worker/xjson_worker.ts +++ b/packages/kbn-langs/xjson/monaco/worker/xjson_worker.ts @@ -18,7 +18,7 @@ */ import * as monaco from 'monaco-editor/esm/vs/editor/editor.api'; -import { createParser } from '../grammar'; +import { createParser } from '../../grammar'; export class XJsonWorker { constructor(private ctx: monaco.worker.IWorkerContext) {} diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/worker_proxy_service.ts b/packages/kbn-langs/xjson/monaco/worker_proxy_service.ts similarity index 97% rename from src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/worker_proxy_service.ts rename to packages/kbn-langs/xjson/monaco/worker_proxy_service.ts index 66eb72b03c3fc9..1a50b9d14d9fc1 100644 --- a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/worker_proxy_service.ts +++ b/packages/kbn-langs/xjson/monaco/worker_proxy_service.ts @@ -19,7 +19,7 @@ import { monaco } from '@kbn/ui-shared-deps/monaco'; import { XJsonWorker } from './worker'; -import { AnnoTypes } from './grammar'; +import { AnnoTypes } from '../grammar'; import { ID } from './constants'; export interface Annotation { diff --git a/src/plugins/es_ui_shared/public/console_lang/index.ts b/src/plugins/es_ui_shared/public/console_lang/index.ts index 131eb1291e334f..7d83191569622e 100644 --- a/src/plugins/es_ui_shared/public/console_lang/index.ts +++ b/src/plugins/es_ui_shared/public/console_lang/index.ts @@ -20,8 +20,6 @@ // Lib is intentionally not included in this barrel export file to separate worker logic // from being imported with pure functions -export { monaco } from '../../__packages_do_not_import__/monaco'; - export { ElasticsearchSqlHighlightRules, ScriptHighlightRules, diff --git a/src/plugins/es_ui_shared/public/index.ts b/src/plugins/es_ui_shared/public/index.ts index 63c4f8d1b2a8e0..7e5510d7c9c651 100644 --- a/src/plugins/es_ui_shared/public/index.ts +++ b/src/plugins/es_ui_shared/public/index.ts @@ -45,7 +45,6 @@ export { XJsonHighlightRules, collapseLiteralStrings, expandLiteralStrings, - monaco, } from './console_lang'; export { From 86bb6ce33c62d2e12f8b1f0515dc8e39cbe18c37 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Thu, 28 May 2020 14:44:58 +0200 Subject: [PATCH 04/26] new @kbn/langs package and update ui-shared-deps --- packages/kbn-langs/index.ts | 4 +++- packages/kbn-langs/package.json | 7 ++---- packages/kbn-langs/scripts/build.js | 21 +--------------- packages/kbn-langs/webpack.config.js | 1 + packages/kbn-langs/xjson/index.ts | 2 +- packages/kbn-ui-shared-deps/entry.js | 2 +- .../{monaco.ts => monaco/index.ts} | 2 ++ .../monaco/xjson}/README.md | 6 +---- .../monaco/xjson}/constants.ts | 0 .../monaco/xjson}/dist/bundle.amd.worker.js | 0 .../monaco/xjson/dist/bundle.editor.worker.js | 1 + .../monaco/xjson}/index.ts | 7 +++--- .../monaco/xjson}/language.ts | 6 ++--- .../monaco/xjson}/lexer_rules/esql.ts | 2 +- .../monaco/xjson}/lexer_rules/index.ts | 0 .../monaco/xjson}/lexer_rules/painless.ts | 2 +- .../monaco/xjson}/lexer_rules/shared.ts | 0 .../monaco/xjson}/lexer_rules/xjson.ts | 2 +- .../monaco/xjson/webpack.worker.config.js} | 2 +- .../monaco/xjson}/worker/index.ts | 0 .../monaco/xjson}/worker/xjson.worker.ts | 0 .../monaco/xjson}/worker/xjson_worker.ts | 4 ++-- .../monaco/xjson}/worker_proxy_service.ts | 8 +++---- packages/kbn-ui-shared-deps/tsconfig.json | 5 +--- packages/kbn-ui-shared-deps/webpack.config.js | 14 ++++++++++- .../monaco/index.ts | 24 ------------------- 26 files changed, 43 insertions(+), 79 deletions(-) rename packages/kbn-ui-shared-deps/{monaco.ts => monaco/index.ts} (97%) rename packages/{kbn-langs/xjson/monaco => kbn-ui-shared-deps/monaco/xjson}/README.md (80%) rename packages/{kbn-langs/xjson/monaco => kbn-ui-shared-deps/monaco/xjson}/constants.ts (100%) rename packages/{kbn-langs/xjson/monaco => kbn-ui-shared-deps/monaco/xjson}/dist/bundle.amd.worker.js (100%) create mode 100644 packages/kbn-ui-shared-deps/monaco/xjson/dist/bundle.editor.worker.js rename packages/{kbn-langs/xjson/monaco => kbn-ui-shared-deps/monaco/xjson}/index.ts (80%) rename packages/{kbn-langs/xjson/monaco => kbn-ui-shared-deps/monaco/xjson}/language.ts (91%) rename packages/{kbn-langs/xjson/monaco => kbn-ui-shared-deps/monaco/xjson}/lexer_rules/esql.ts (98%) rename packages/{kbn-langs/xjson/monaco => kbn-ui-shared-deps/monaco/xjson}/lexer_rules/index.ts (100%) rename packages/{kbn-langs/xjson/monaco => kbn-ui-shared-deps/monaco/xjson}/lexer_rules/painless.ts (98%) rename packages/{kbn-langs/xjson/monaco => kbn-ui-shared-deps/monaco/xjson}/lexer_rules/shared.ts (100%) rename packages/{kbn-langs/xjson/monaco => kbn-ui-shared-deps/monaco/xjson}/lexer_rules/xjson.ts (98%) rename packages/{kbn-langs/xjson/monaco/webpack.xjson-worker.config.js => kbn-ui-shared-deps/monaco/xjson/webpack.worker.config.js} (97%) rename packages/{kbn-langs/xjson/monaco => kbn-ui-shared-deps/monaco/xjson}/worker/index.ts (100%) rename packages/{kbn-langs/xjson/monaco => kbn-ui-shared-deps/monaco/xjson}/worker/xjson.worker.ts (100%) rename packages/{kbn-langs/xjson/monaco => kbn-ui-shared-deps/monaco/xjson}/worker/xjson_worker.ts (92%) rename packages/{kbn-langs/xjson/monaco => kbn-ui-shared-deps/monaco/xjson}/worker_proxy_service.ts (89%) delete mode 100644 src/plugins/es_ui_shared/__packages_do_not_import__/monaco/index.ts diff --git a/packages/kbn-langs/index.ts b/packages/kbn-langs/index.ts index 6bdafd2463c171..9c9024673b6e76 100644 --- a/packages/kbn-langs/index.ts +++ b/packages/kbn-langs/index.ts @@ -17,4 +17,6 @@ * under the License. */ -export * from './xjson'; +import * as XJsonGrammar from './xjson'; + +export { XJsonGrammar }; diff --git a/packages/kbn-langs/package.json b/packages/kbn-langs/package.json index d252ed800eede4..a777c18248024d 100644 --- a/packages/kbn-langs/package.json +++ b/packages/kbn-langs/package.json @@ -4,19 +4,16 @@ "main": "./target/index.js", "license": "MIT", "private": true, - "dependencies": { - "monaco-editor": "~0.17.0" - }, "devDependencies": { "getopts": "^2.2.4", "babel-loader": "^8.0.6", "webpack": "^4.41.5", "webpack-cli": "^3.3.10", "supports-color": "^7.0.0", - "del": "^5.1.0" + "del": "^5.1.0", + "raw-loader": "3.1.0" }, "scripts": { - "//": "At this point in time we only have one language in here", "build": "node ./scripts/build.js" } } diff --git a/packages/kbn-langs/scripts/build.js b/packages/kbn-langs/scripts/build.js index 59853f2820f1e9..aada4c75cbd7ca 100644 --- a/packages/kbn-langs/scripts/build.js +++ b/packages/kbn-langs/scripts/build.js @@ -24,12 +24,9 @@ const supportsColor = require('supports-color'); const { ToolingLog, withProcRunner, pickLevelFromFlags } = require('@kbn/dev-utils'); const TARGET_BUILD_DIR = path.resolve(__dirname, '../target'); -const WORKER_BUILD_DIRS = [path.resolve(__dirname, '../xjson/monaco')]; const ROOT_DIR = path.resolve(__dirname, '../'); -const flags = getopts(process.argv, { - boolean: ['watch', 'dev', 'help', 'debug'], -}); +const flags = getopts(process.argv); const log = new ToolingLog({ level: pickLevelFromFlags(flags), @@ -41,28 +38,12 @@ withProcRunner(log, async (proc) => { await del(TARGET_BUILD_DIR); - for (const workerBuildDir of WORKER_BUILD_DIRS) { - await del(`${workerBuildDir}/dist`); - } - const cwd = ROOT_DIR; const env = { ...process.env }; if (supportsColor.stdout) { env.FORCE_COLOR = 'true'; } - await Promise.all([ - WORKER_BUILD_DIRS.map((buildDir) => - proc.run(`webpack ${buildDir}`, { - cmd: 'webpack', - args: ['--config', `${buildDir}/webpack.worker.config.js`], - wait: true, - env, - cwd, - }) - ), - ]); - await proc.run('webpack ', { cmd: 'webpack', args: ['--config', `${ROOT_DIR}/webpack.config.js`], diff --git a/packages/kbn-langs/webpack.config.js b/packages/kbn-langs/webpack.config.js index cd9ffe174065e7..28da10ced58eb4 100644 --- a/packages/kbn-langs/webpack.config.js +++ b/packages/kbn-langs/webpack.config.js @@ -28,6 +28,7 @@ module.exports = { modules: ['node_modules'], extensions: ['.js', '.ts', '.tsx'], }, + stats: 'errors-only', module: { rules: [ { diff --git a/packages/kbn-langs/xjson/index.ts b/packages/kbn-langs/xjson/index.ts index 6f163ac6816254..45ed22c9d32c54 100644 --- a/packages/kbn-langs/xjson/index.ts +++ b/packages/kbn-langs/xjson/index.ts @@ -17,4 +17,4 @@ * under the License. */ -export { monaco } from './monaco'; +export { createParser, AnnoTypes } from './grammar'; diff --git a/packages/kbn-ui-shared-deps/entry.js b/packages/kbn-ui-shared-deps/entry.js index 26efd174f4e39a..2b8a4d687439a2 100644 --- a/packages/kbn-ui-shared-deps/entry.js +++ b/packages/kbn-ui-shared-deps/entry.js @@ -30,7 +30,7 @@ export const KbnI18nReact = require('@kbn/i18n/react'); export const Angular = require('angular'); export const Moment = require('moment'); export const MomentTimezone = require('moment-timezone/moment-timezone'); -export const Monaco = require('./monaco.ts'); +export const Monaco = require('./monaco/index.ts'); export const MonacoBare = require('monaco-editor/esm/vs/editor/editor.api'); export const React = require('react'); export const ReactDom = require('react-dom'); diff --git a/packages/kbn-ui-shared-deps/monaco.ts b/packages/kbn-ui-shared-deps/monaco/index.ts similarity index 97% rename from packages/kbn-ui-shared-deps/monaco.ts rename to packages/kbn-ui-shared-deps/monaco/index.ts index 42801c69a3e2c1..c29282865131ef 100644 --- a/packages/kbn-ui-shared-deps/monaco.ts +++ b/packages/kbn-ui-shared-deps/monaco/index.ts @@ -31,4 +31,6 @@ import 'monaco-editor/esm/vs/editor/contrib/suggest/suggestController.js'; // Ne import 'monaco-editor/esm/vs/editor/contrib/hover/hover.js'; // Needed for hover import 'monaco-editor/esm/vs/editor/contrib/parameterHints/parameterHints.js'; // Needed for signature +export { XJsonLang } from './xjson'; + export { monaco }; diff --git a/packages/kbn-langs/xjson/monaco/README.md b/packages/kbn-ui-shared-deps/monaco/xjson/README.md similarity index 80% rename from packages/kbn-langs/xjson/monaco/README.md rename to packages/kbn-ui-shared-deps/monaco/xjson/README.md index 49831670934874..7dd940069fbb9b 100644 --- a/packages/kbn-langs/xjson/monaco/README.md +++ b/packages/kbn-ui-shared-deps/monaco/xjson/README.md @@ -19,7 +19,7 @@ the "raw-loader". See the related ./webpack.xjson-worker.config.js file that is runnable with Kibana's webpack with: ```sh -yarn webpack --config ./src/plugins/es_ui_shared/__packages_do_not_import__/monaco/xjson_lang/webpack.xjson-worker.config.js +yarn webpack --config ./monaco/xjson/webpack.worker.config.js ``` ### ./lexer_rules @@ -38,7 +38,3 @@ the grammar parser. ### ./worker_proxy_service A stateful mechanism for holding a reference to the Monaco-provided proxy getter. - -### ../grammar - -The parser logic that lives inside of the worker. Takes in a string and returns annotations for XJSON. diff --git a/packages/kbn-langs/xjson/monaco/constants.ts b/packages/kbn-ui-shared-deps/monaco/xjson/constants.ts similarity index 100% rename from packages/kbn-langs/xjson/monaco/constants.ts rename to packages/kbn-ui-shared-deps/monaco/xjson/constants.ts diff --git a/packages/kbn-langs/xjson/monaco/dist/bundle.amd.worker.js b/packages/kbn-ui-shared-deps/monaco/xjson/dist/bundle.amd.worker.js similarity index 100% rename from packages/kbn-langs/xjson/monaco/dist/bundle.amd.worker.js rename to packages/kbn-ui-shared-deps/monaco/xjson/dist/bundle.amd.worker.js diff --git a/packages/kbn-ui-shared-deps/monaco/xjson/dist/bundle.editor.worker.js b/packages/kbn-ui-shared-deps/monaco/xjson/dist/bundle.editor.worker.js new file mode 100644 index 00000000000000..48106b652e700e --- /dev/null +++ b/packages/kbn-ui-shared-deps/monaco/xjson/dist/bundle.editor.worker.js @@ -0,0 +1 @@ +/*! /* eslint-disable * / */!function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=6)}([function(e,t,n){"use strict";(function(e,r){n.d(t,"c",(function(){return m})),n.d(t,"b",(function(){return p})),n.d(t,"a",(function(){return g}));var i=!1,o=!1,s=!1,u=!1,a=!1,l=void 0!==e&&void 0!==e.versions&&void 0!==e.versions.electron&&"renderer"===e.type;if("object"!=typeof navigator||l){if("object"==typeof e){i="win32"===e.platform,o="darwin"===e.platform,s="linux"===e.platform,"en","en";var c=e.env.VSCODE_NLS_CONFIG;if(c)try{var f=JSON.parse(c),h=f.availableLanguages["*"];f.locale,h||"en",f._translationsConfigFile}catch(e){}u=!0}}else{var d=navigator.userAgent;i=d.indexOf("Windows")>=0,o=d.indexOf("Macintosh")>=0,s=d.indexOf("Linux")>=0,a=!0,navigator.language}var m=i,p=a,g="object"==typeof self?self:"object"==typeof r?r:{}}).call(this,n(2),n(1))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t){var n,r,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function u(e){if(n===setTimeout)return setTimeout(e,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(e){n=o}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();var a,l=[],c=!1,f=-1;function h(){c&&a&&(c=!1,a.length?l=a.concat(l):f=-1,l.length&&d())}function d(){if(!c){var e=u(h);c=!0;for(var t=l.length;t;){for(a=l,l=[];++f1)for(var n=1;n=0&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),t))},n(5),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,n(1))},function(e,t,n){(function(e,t){!function(e,n){"use strict";if(!e.setImmediate){var r,i,o,s,u,a=1,l={},c=!1,f=e.document,h=Object.getPrototypeOf&&Object.getPrototypeOf(e);h=h&&h.setTimeout?h:e,"[object process]"==={}.toString.call(e.process)?r=function(e){t.nextTick((function(){m(e)}))}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=n,t}}()?e.MessageChannel?((o=new MessageChannel).port1.onmessage=function(e){m(e.data)},r=function(e){o.port2.postMessage(e)}):f&&"onreadystatechange"in f.createElement("script")?(i=f.documentElement,r=function(e){var t=f.createElement("script");t.onreadystatechange=function(){m(e),t.onreadystatechange=null,i.removeChild(t),t=null},i.appendChild(t)}):r=function(e){setTimeout(m,0,e)}:(s="setImmediate$"+Math.random()+"$",u=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(s)&&m(+t.data.slice(s.length))},e.addEventListener?e.addEventListener("message",u,!1):e.attachEvent("onmessage",u),r=function(t){e.postMessage(s+t,"*")}),h.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;nr?e[a]=o[u++]:u>i?e[a]=o[s++]:t(o[u],o[s])<0?e[a]=o[u++]:e[a]=o[s++]}(t,n,r,s,i,o)}(e,t,0,e.length-1,[]),e}var v=function(){function e(e,t,n,r){this.originalStart=e,this.originalLength=t,this.modifiedStart=n,this.modifiedLength=r}return e.prototype.getOriginalEnd=function(){return this.originalStart+this.originalLength},e.prototype.getModifiedEnd=function(){return this.modifiedStart+this.modifiedLength},e}();function y(e){return{getLength:function(){return e.length},getElementAtIndex:function(t){return e.charCodeAt(t)}}}function C(e,t,n){return new S(y(e),y(t)).ComputeDiff(n)}var b,L=function(){function e(){}return e.Assert=function(e,t){if(!e)throw new Error(t)},e}(),N=function(){function e(){}return e.Copy=function(e,t,n,r,i){for(var o=0;o0||this.m_modifiedCount>0)&&this.m_changes.push(new v(this.m_originalStart,this.m_originalCount,this.m_modifiedStart,this.m_modifiedCount)),this.m_originalCount=0,this.m_modifiedCount=0,this.m_originalStart=Number.MAX_VALUE,this.m_modifiedStart=Number.MAX_VALUE},e.prototype.AddOriginalElement=function(e,t){this.m_originalStart=Math.min(this.m_originalStart,e),this.m_modifiedStart=Math.min(this.m_modifiedStart,t),this.m_originalCount++},e.prototype.AddModifiedElement=function(e,t){this.m_originalStart=Math.min(this.m_originalStart,e),this.m_modifiedStart=Math.min(this.m_modifiedStart,t),this.m_modifiedCount++},e.prototype.getChanges=function(){return(this.m_originalCount>0||this.m_modifiedCount>0)&&this.MarkNextChange(),this.m_changes},e.prototype.getReverseChanges=function(){return(this.m_originalCount>0||this.m_modifiedCount>0)&&this.MarkNextChange(),this.m_changes.reverse(),this.m_changes},e}(),S=function(){function e(e,t,n){void 0===n&&(n=null),this.OriginalSequence=e,this.ModifiedSequence=t,this.ContinueProcessingPredicate=n,this.m_forwardHistory=[],this.m_reverseHistory=[]}return e.prototype.ElementsAreEqual=function(e,t){return this.OriginalSequence.getElementAtIndex(e)===this.ModifiedSequence.getElementAtIndex(t)},e.prototype.OriginalElementsAreEqual=function(e,t){return this.OriginalSequence.getElementAtIndex(e)===this.OriginalSequence.getElementAtIndex(t)},e.prototype.ModifiedElementsAreEqual=function(e,t){return this.ModifiedSequence.getElementAtIndex(e)===this.ModifiedSequence.getElementAtIndex(t)},e.prototype.ComputeDiff=function(e){return this._ComputeDiff(0,this.OriginalSequence.getLength()-1,0,this.ModifiedSequence.getLength()-1,e)},e.prototype._ComputeDiff=function(e,t,n,r,i){var o=this.ComputeDiffRecursive(e,t,n,r,[!1]);return i?this.PrettifyChanges(o):o},e.prototype.ComputeDiffRecursive=function(e,t,n,r,i){for(i[0]=!1;e<=t&&n<=r&&this.ElementsAreEqual(e,n);)e++,n++;for(;t>=e&&r>=n&&this.ElementsAreEqual(t,r);)t--,r--;if(e>t||n>r){var o=void 0;return n<=r?(L.Assert(e===t+1,"originalStart should only be one more than originalEnd"),o=[new v(e,0,n,r-n+1)]):e<=t?(L.Assert(n===r+1,"modifiedStart should only be one more than modifiedEnd"),o=[new v(e,t-e+1,n,0)]):(L.Assert(e===t+1,"originalStart should only be one more than originalEnd"),L.Assert(n===r+1,"modifiedStart should only be one more than modifiedEnd"),o=[]),o}var s=[0],u=[0],a=this.ComputeRecursionPoint(e,t,n,r,s,u,i),l=s[0],c=u[0];if(null!==a)return a;if(!i[0]){var f=this.ComputeDiffRecursive(e,l,n,c,i),h=[];return h=i[0]?[new v(l+1,t-(l+1)+1,c+1,r-(c+1)+1)]:this.ComputeDiffRecursive(l+1,t,c+1,r,i),this.ConcatenateChanges(f,h)}return[new v(e,t-e+1,n,r-n+1)]},e.prototype.WALKTRACE=function(e,t,n,r,i,o,s,u,a,l,c,f,h,d,m,p,g,_){var y,C,b=null,L=new E,N=t,S=n,w=h[0]-p[0]-r,A=Number.MIN_VALUE,T=this.m_forwardHistory.length-1;do{(C=w+e)===N||C=0&&(e=(a=this.m_forwardHistory[T])[0],N=1,S=a.length-1)}while(--T>=-1);if(y=L.getReverseChanges(),_[0]){var M=h[0]+1,P=p[0]+1;if(null!==y&&y.length>0){var O=y[y.length-1];M=Math.max(M,O.getOriginalEnd()),P=Math.max(P,O.getModifiedEnd())}b=[new v(M,f-M+1,P,m-P+1)]}else{L=new E,N=o,S=s,w=h[0]-p[0]-u,A=Number.MAX_VALUE,T=g?this.m_reverseHistory.length-1:this.m_reverseHistory.length-2;do{(C=w+i)===N||C=l[C+1]?(d=(c=l[C+1]-1)-w-u,c>A&&L.MarkNextChange(),A=c+1,L.AddOriginalElement(c+1,d+1),w=C+1-i):(d=(c=l[C-1])-w-u,c>A&&L.MarkNextChange(),A=c,L.AddModifiedElement(c+1,d+1),w=C-1-i),T>=0&&(i=(l=this.m_reverseHistory[T])[0],N=1,S=l.length-1)}while(--T>=-1);b=L.getChanges()}return this.ConcatenateChanges(y,b)},e.prototype.ComputeRecursionPoint=function(e,t,n,r,i,o,s){var u,a=0,l=0,c=0,f=0,h=0,d=0;e--,n--,i[0]=0,o[0]=0,this.m_forwardHistory=[],this.m_reverseHistory=[];var m,p,g=t-e+(r-n),_=g+1,y=new Array(_),C=new Array(_),b=r-n,L=t-e,E=e-n,S=t-r,w=(L-b)%2==0;for(y[b]=e,C[L]=t,s[0]=!1,u=1;u<=g/2+1;u++){var A=0,T=0;for(c=this.ClipDiagonalBound(b-u,u,b,_),f=this.ClipDiagonalBound(b+u,u,b,_),m=c;m<=f;m+=2){for(l=(a=m===c||mA+T&&(A=a,T=l),!w&&Math.abs(m-L)<=u-1&&a>=C[m])return i[0]=a,o[0]=l,p<=C[m]&&u<=1448?this.WALKTRACE(b,c,f,E,L,h,d,S,y,C,a,t,i,l,r,o,w,s):null}var M=(A-e+(T-n)-u)/2;if(null!==this.ContinueProcessingPredicate&&!this.ContinueProcessingPredicate(A,this.OriginalSequence,M))return s[0]=!0,i[0]=A,o[0]=T,M>0&&u<=1448?this.WALKTRACE(b,c,f,E,L,h,d,S,y,C,a,t,i,l,r,o,w,s):(e++,n++,[new v(e,t-e+1,n,r-n+1)]);for(h=this.ClipDiagonalBound(L-u,u,L,_),d=this.ClipDiagonalBound(L+u,u,L,_),m=h;m<=d;m+=2){for(l=(a=m===h||m=C[m+1]?C[m+1]-1:C[m-1])-(m-L)-S,p=a;a>e&&l>n&&this.ElementsAreEqual(a,l);)a--,l--;if(C[m]=a,w&&Math.abs(m-b)<=u&&a<=y[m])return i[0]=a,o[0]=l,p>=y[m]&&u<=1448?this.WALKTRACE(b,c,f,E,L,h,d,S,y,C,a,t,i,l,r,o,w,s):null}if(u<=1447){var P=new Array(f-c+2);P[0]=b-c+1,N.Copy(y,c,P,1,f-c+1),this.m_forwardHistory.push(P),(P=new Array(d-h+2))[0]=L-h+1,N.Copy(C,h,P,1,d-h+1),this.m_reverseHistory.push(P)}}return this.WALKTRACE(b,c,f,E,L,h,d,S,y,C,a,t,i,l,r,o,w,s)},e.prototype.PrettifyChanges=function(e){for(var t=0;t0,s=n.modifiedLength>0;n.originalStart+n.originalLength=0;t--){n=e[t],r=0,i=0;if(t>0){var a=e[t-1];a.originalLength>0&&(r=a.originalStart+a.originalLength),a.modifiedLength>0&&(i=a.modifiedStart+a.modifiedLength)}o=n.originalLength>0,s=n.modifiedLength>0;for(var l=0,c=this._boundaryScore(n.originalStart,n.originalLength,n.modifiedStart,n.modifiedLength),f=1;;f++){var h=n.originalStart-f,d=n.modifiedStart-f;if(hc&&(c=m,l=f)}n.originalStart-=l,n.modifiedStart-=l}return e},e.prototype._OriginalIsBoundary=function(e){if(e<=0||e>=this.OriginalSequence.getLength()-1)return!0;var t=this.OriginalSequence.getElementAtIndex(e);return"string"==typeof t&&/^\s*$/.test(t)},e.prototype._OriginalRegionIsBoundary=function(e,t){if(this._OriginalIsBoundary(e)||this._OriginalIsBoundary(e-1))return!0;if(t>0){var n=e+t;if(this._OriginalIsBoundary(n-1)||this._OriginalIsBoundary(n))return!0}return!1},e.prototype._ModifiedIsBoundary=function(e){if(e<=0||e>=this.ModifiedSequence.getLength()-1)return!0;var t=this.ModifiedSequence.getElementAtIndex(e);return"string"==typeof t&&/^\s*$/.test(t)},e.prototype._ModifiedRegionIsBoundary=function(e,t){if(this._ModifiedIsBoundary(e)||this._ModifiedIsBoundary(e-1))return!0;if(t>0){var n=e+t;if(this._ModifiedIsBoundary(n-1)||this._ModifiedIsBoundary(n))return!0}return!1},e.prototype._boundaryScore=function(e,t,n,r){return(this._OriginalRegionIsBoundary(e,t)?1:0)+(this._ModifiedRegionIsBoundary(n,r)?1:0)},e.prototype.ConcatenateChanges=function(e,t){var n=[];if(0===e.length||0===t.length)return t.length>0?t:e;if(this.ChangesOverlap(e[e.length-1],t[0],n)){var r=new Array(e.length+t.length-1);return N.Copy(e,0,r,0,e.length-1),r[e.length-1]=n[0],N.Copy(t,1,r,e.length,t.length-1),r}r=new Array(e.length+t.length);return N.Copy(e,0,r,0,e.length),N.Copy(t,0,r,e.length,t.length),r},e.prototype.ChangesOverlap=function(e,t,n){if(L.Assert(e.originalStart<=t.originalStart,"Left change is not less than or equal to right change"),L.Assert(e.modifiedStart<=t.modifiedStart,"Left change is not less than or equal to right change"),e.originalStart+e.originalLength>=t.originalStart||e.modifiedStart+e.modifiedLength>=t.modifiedStart){var r=e.originalStart,i=e.originalLength,o=e.modifiedStart,s=e.modifiedLength;return e.originalStart+e.originalLength>=t.originalStart&&(i=t.originalStart+t.originalLength-e.originalStart),e.modifiedStart+e.modifiedLength>=t.modifiedStart&&(s=t.modifiedStart+t.modifiedLength-e.modifiedStart),n[0]=new v(r,i,o,s),!0}return n[0]=null,!1},e.prototype.ClipDiagonalBound=function(e,t,n,r){if(e>=0&&e=n?A:{done:!1,value:e[t++]}}}},e.from=function(t){return t?Array.isArray(t)?e.fromArray(t):t:e.empty()},e.map=function(e,t){return{next:function(){var n=e.next();return n.done?A:{done:!1,value:t(n.value)}}}},e.filter=function(e,t){return{next:function(){for(;;){var n=e.next();if(n.done)return A;if(t(n.value))return{done:!1,value:n.value}}}}},e.forEach=n,e.collect=function(e){var t=[];return n(e,(function(e){return t.push(e)})),t}}(b||(b={}));(function(e){function t(t,n,r,i){return void 0===n&&(n=0),void 0===r&&(r=t.length),void 0===i&&(i=n-1),e.call(this,t,n,r,i)||this}w(t,e),t.prototype.current=function(){return e.prototype.current.call(this)},t.prototype.previous=function(){return this.index=Math.max(this.index-1,this.start-1),this.current()},t.prototype.first=function(){return this.index=this.start,this.current()},t.prototype.last=function(){return this.index=this.end-1,this.current()},t.prototype.parent=function(){return null}})(function(){function e(e,t,n,r){void 0===t&&(t=0),void 0===n&&(n=e.length),void 0===r&&(r=t-1),this.items=e,this.start=t,this.end=n,this.index=r}return e.prototype.next=function(){return this.index=Math.min(this.index+1,this.end),this.current()},e.prototype.current=function(){return this.index===this.start-1||this.index===this.end?null:this.items[this.index]},e}()),function(){function e(e,t){this.iterator=e,this.fn=t}e.prototype.next=function(){return this.fn(this.iterator.next())}}();var T,M=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),P=/^\w[\w\d+.-]*$/,O=/^\//,x=/^\/\//;var I="",R="/",k=/^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,U=function(){function e(e,t,n,r,i,o){void 0===o&&(o=!1),"object"==typeof e?(this.scheme=e.scheme||I,this.authority=e.authority||I,this.path=e.path||I,this.query=e.query||I,this.fragment=e.fragment||I):(this.scheme=e||I,this.authority=t||I,this.path=function(e,t){switch(e){case"https":case"http":case"file":t?t[0]!==R&&(t=R+t):t=R}return t}(this.scheme,n||I),this.query=r||I,this.fragment=i||I,function(e,t){if(!e.scheme)throw new Error('[UriError]: Scheme is missing: {scheme: "", authority: "'+e.authority+'", path: "'+e.path+'", query: "'+e.query+'", fragment: "'+e.fragment+'"}');if(e.scheme&&!P.test(e.scheme))throw new Error("[UriError]: Scheme contains illegal characters.");if(e.path)if(e.authority){if(!O.test(e.path))throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character')}else if(x.test(e.path))throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")')}(this))}return e.isUri=function(t){return t instanceof e||!!t&&("string"==typeof t.authority&&"string"==typeof t.fragment&&"string"==typeof t.path&&"string"==typeof t.query&&"string"==typeof t.scheme&&"function"==typeof t.fsPath&&"function"==typeof t.with&&"function"==typeof t.toString)},Object.defineProperty(e.prototype,"fsPath",{get:function(){return V(this)},enumerable:!0,configurable:!0}),e.prototype.with=function(e){if(!e)return this;var t=e.scheme,n=e.authority,r=e.path,i=e.query,o=e.fragment;return void 0===t?t=this.scheme:null===t&&(t=I),void 0===n?n=this.authority:null===n&&(n=I),void 0===r?r=this.path:null===r&&(r=I),void 0===i?i=this.query:null===i&&(i=I),void 0===o?o=this.fragment:null===o&&(o=I),t===this.scheme&&n===this.authority&&r===this.path&&i===this.query&&o===this.fragment?this:new F(t,n,r,i,o)},e.parse=function(e,t){void 0===t&&(t=!1);var n=k.exec(e);return n?new F(n[2]||I,decodeURIComponent(n[4]||I),decodeURIComponent(n[5]||I),decodeURIComponent(n[7]||I),decodeURIComponent(n[9]||I),t):new F(I,I,I,I,I)},e.file=function(e){var t=I;if(f.c&&(e=e.replace(/\\/g,R)),e[0]===R&&e[1]===R){var n=e.indexOf(R,2);-1===n?(t=e.substring(2),e=R):(t=e.substring(2,n),e=e.substring(n)||R)}return new F("file",t,e,I,I)},e.from=function(e){return new F(e.scheme,e.authority,e.path,e.query,e.fragment)},e.prototype.toString=function(e){return void 0===e&&(e=!1),B(this,e)},e.prototype.toJSON=function(){return this},e.revive=function(t){if(t){if(t instanceof e)return t;var n=new F(t);return n._fsPath=t.fsPath,n._formatted=t.external,n}return t},e}(),F=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._formatted=null,t._fsPath=null,t}return M(t,e),Object.defineProperty(t.prototype,"fsPath",{get:function(){return this._fsPath||(this._fsPath=V(this)),this._fsPath},enumerable:!0,configurable:!0}),t.prototype.toString=function(e){return void 0===e&&(e=!1),e?B(this,!0):(this._formatted||(this._formatted=B(this,!1)),this._formatted)},t.prototype.toJSON=function(){var e={$mid:1};return this._fsPath&&(e.fsPath=this._fsPath),this._formatted&&(e.external=this._formatted),this.path&&(e.path=this.path),this.scheme&&(e.scheme=this.scheme),this.authority&&(e.authority=this.authority),this.query&&(e.query=this.query),this.fragment&&(e.fragment=this.fragment),e},t}(U),D=((T={})[58]="%3A",T[47]="%2F",T[63]="%3F",T[35]="%23",T[91]="%5B",T[93]="%5D",T[64]="%40",T[33]="%21",T[36]="%24",T[38]="%26",T[39]="%27",T[40]="%28",T[41]="%29",T[42]="%2A",T[43]="%2B",T[44]="%2C",T[59]="%3B",T[61]="%3D",T[32]="%20",T);function K(e,t){for(var n=void 0,r=-1,i=0;i=97&&o<=122||o>=65&&o<=90||o>=48&&o<=57||45===o||46===o||95===o||126===o||t&&47===o)-1!==r&&(n+=encodeURIComponent(e.substring(r,i)),r=-1),void 0!==n&&(n+=e.charAt(i));else{void 0===n&&(n=e.substr(0,i));var s=D[o];void 0!==s?(-1!==r&&(n+=encodeURIComponent(e.substring(r,i)),r=-1),n+=s):-1===r&&(r=i)}}return-1!==r&&(n+=encodeURIComponent(e.substring(r))),void 0!==n?n:e}function q(e){for(var t=void 0,n=0;n1&&"file"===e.scheme?"//"+e.authority+e.path:47===e.path.charCodeAt(0)&&(e.path.charCodeAt(1)>=65&&e.path.charCodeAt(1)<=90||e.path.charCodeAt(1)>=97&&e.path.charCodeAt(1)<=122)&&58===e.path.charCodeAt(2)?e.path[1].toLowerCase()+e.path.substr(2):e.path,f.c&&(t=t.replace(/\//g,"\\")),t}function B(e,t){var n=t?q:K,r="",i=e.scheme,o=e.authority,s=e.path,u=e.query,a=e.fragment;if(i&&(r+=i,r+=":"),(o||"file"===i)&&(r+=R,r+=R),o){var l=o.indexOf("@");if(-1!==l){var c=o.substr(0,l);o=o.substr(l+1),-1===(l=c.indexOf(":"))?r+=n(c,!1):(r+=n(c.substr(0,l),!1),r+=":",r+=n(c.substr(l+1),!1)),r+="@"}-1===(l=(o=o.toLowerCase()).indexOf(":"))?r+=n(o,!1):(r+=n(o.substr(0,l),!1),r+=o.substr(l))}if(s){if(s.length>=3&&47===s.charCodeAt(0)&&58===s.charCodeAt(2))(f=s.charCodeAt(1))>=65&&f<=90&&(s="/"+String.fromCharCode(f+32)+":"+s.substr(3));else if(s.length>=2&&58===s.charCodeAt(1)){var f;(f=s.charCodeAt(0))>=65&&f<=90&&(s=String.fromCharCode(f+32)+":"+s.substr(2))}r+=n(s,!0)}return u&&(r+="?",r+=n(u,!1)),a&&(r+="#",r+=t?a:K(a,!1)),r}var j=function(){function e(e,t){this.lineNumber=e,this.column=t}return e.prototype.with=function(t,n){return void 0===t&&(t=this.lineNumber),void 0===n&&(n=this.column),t===this.lineNumber&&n===this.column?this:new e(t,n)},e.prototype.delta=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=0),this.with(this.lineNumber+e,this.column+t)},e.prototype.equals=function(t){return e.equals(this,t)},e.equals=function(e,t){return!e&&!t||!!e&&!!t&&e.lineNumber===t.lineNumber&&e.column===t.column},e.prototype.isBefore=function(t){return e.isBefore(this,t)},e.isBefore=function(e,t){return e.lineNumbern||e===n&&t>r?(this.startLineNumber=n,this.startColumn=r,this.endLineNumber=e,this.endColumn=t):(this.startLineNumber=e,this.startColumn=t,this.endLineNumber=n,this.endColumn=r)}return e.prototype.isEmpty=function(){return e.isEmpty(this)},e.isEmpty=function(e){return e.startLineNumber===e.endLineNumber&&e.startColumn===e.endColumn},e.prototype.containsPosition=function(t){return e.containsPosition(this,t)},e.containsPosition=function(e,t){return!(t.lineNumbere.endLineNumber)&&(!(t.lineNumber===e.startLineNumber&&t.columne.endColumn))},e.prototype.containsRange=function(t){return e.containsRange(this,t)},e.containsRange=function(e,t){return!(t.startLineNumbere.endLineNumber||t.endLineNumber>e.endLineNumber)&&(!(t.startLineNumber===e.startLineNumber&&t.startColumne.endColumn)))},e.prototype.plusRange=function(t){return e.plusRange(this,t)},e.plusRange=function(t,n){var r,i,o,s;return n.startLineNumbert.endLineNumber?(o=n.endLineNumber,s=n.endColumn):n.endLineNumber===t.endLineNumber?(o=n.endLineNumber,s=Math.max(n.endColumn,t.endColumn)):(o=t.endLineNumber,s=t.endColumn),new e(r,i,o,s)},e.prototype.intersectRanges=function(t){return e.intersectRanges(this,t)},e.intersectRanges=function(t,n){var r=t.startLineNumber,i=t.startColumn,o=t.endLineNumber,s=t.endColumn,u=n.startLineNumber,a=n.startColumn,l=n.endLineNumber,c=n.endColumn;return rl?(o=l,s=c):o===l&&(s=Math.min(s,c)),r>o?null:r===o&&i>s?null:new e(r,i,o,s)},e.prototype.equalsRange=function(t){return e.equalsRange(this,t)},e.equalsRange=function(e,t){return!!e&&!!t&&e.startLineNumber===t.startLineNumber&&e.startColumn===t.startColumn&&e.endLineNumber===t.endLineNumber&&e.endColumn===t.endColumn},e.prototype.getEndPosition=function(){return new j(this.endLineNumber,this.endColumn)},e.prototype.getStartPosition=function(){return new j(this.startLineNumber,this.startColumn)},e.prototype.toString=function(){return"["+this.startLineNumber+","+this.startColumn+" -> "+this.endLineNumber+","+this.endColumn+"]"},e.prototype.setEndPosition=function(t,n){return new e(this.startLineNumber,this.startColumn,t,n)},e.prototype.setStartPosition=function(t,n){return new e(t,n,this.endLineNumber,this.endColumn)},e.prototype.collapseToStart=function(){return e.collapseToStart(this)},e.collapseToStart=function(t){return new e(t.startLineNumber,t.startColumn,t.startLineNumber,t.startColumn)},e.fromPositions=function(t,n){return void 0===n&&(n=t),new e(t.lineNumber,t.column,n.lineNumber,n.column)},e.lift=function(t){return t?new e(t.startLineNumber,t.startColumn,t.endLineNumber,t.endColumn):null},e.isIRange=function(e){return e&&"number"==typeof e.startLineNumber&&"number"==typeof e.startColumn&&"number"==typeof e.endLineNumber&&"number"==typeof e.endColumn},e.areIntersectingOrTouching=function(e,t){return!(e.endLineNumbere.startLineNumber},e}();String.fromCharCode(65279);function W(e,t,n,r){return new S(e,t,n).ComputeDiff(r)}var H=function(){function e(t){for(var n=[],r=[],i=0,o=t.length;i=0;n--){var r=e.charCodeAt(n);if(32!==r&&9!==r)return n}return-1}(e);return-1===n?t:n+2},e.prototype.getCharSequence=function(e,t,n){for(var r=[],i=[],o=[],s=0,u=t;u<=n;u++)for(var a=this._lines[u],l=e?this._startColumns[u]:1,c=e?this._endColumns[u]:a.length+1,f=l;f1&&m>1;){if(f.charCodeAt(d-2)!==h.charCodeAt(m-2))break;d--,m--}(d>1||m>1)&&this._pushTrimWhitespaceCharChange(i,o+1,1,d,s+1,1,m);for(var p=H._getLastNonBlankColumn(f,1),g=H._getLastNonBlankColumn(h,1),_=f.length+1,v=h.length+1;p<_&&g255?255:0|e}function Z(e){return e<0?0:e>4294967295?4294967295:0|e}var ee=function(e,t){this.index=e,this.remainder=t},te=function(){function e(e){this.values=e,this.prefixSum=new Uint32Array(e.length),this.prefixSumValidIndex=new Int32Array(1),this.prefixSumValidIndex[0]=-1}return e.prototype.getCount=function(){return this.values.length},e.prototype.insertValues=function(e,t){e=Z(e);var n=this.values,r=this.prefixSum,i=t.length;return 0!==i&&(this.values=new Uint32Array(n.length+i),this.values.set(n.subarray(0,e),0),this.values.set(n.subarray(e),e+i),this.values.set(t,e),e-1=0&&this.prefixSum.set(r.subarray(0,this.prefixSumValidIndex[0]+1)),!0)},e.prototype.changeValue=function(e,t){return e=Z(e),t=Z(t),this.values[e]!==t&&(this.values[e]=t,e-1=n.length)return!1;var i=n.length-e;return t>=i&&(t=i),0!==t&&(this.values=new Uint32Array(n.length-t),this.values.set(n.subarray(0,e),0),this.values.set(n.subarray(e+t),e),this.prefixSum=new Uint32Array(this.values.length),e-1=0&&this.prefixSum.set(r.subarray(0,this.prefixSumValidIndex[0]+1)),!0)},e.prototype.getTotalValue=function(){return 0===this.values.length?0:this._getAccumulatedValue(this.values.length-1)},e.prototype.getAccumulatedValue=function(e){return e<0?0:(e=Z(e),this._getAccumulatedValue(e))},e.prototype._getAccumulatedValue=function(e){if(e<=this.prefixSumValidIndex[0])return this.prefixSum[e];var t=this.prefixSumValidIndex[0]+1;0===t&&(this.prefixSum[0]=this.values[0],t++),e>=this.values.length&&(e=this.values.length-1);for(var n=t;n<=e;n++)this.prefixSum[n]=this.prefixSum[n-1]+this.values[n];return this.prefixSumValidIndex[0]=Math.max(this.prefixSumValidIndex[0],e),this.prefixSum[e]},e.prototype.getIndexOf=function(e){e=Math.floor(e),this.getTotalValue();for(var t=0,n=this.values.length-1,r=0,i=0,o=0;t<=n;)if(r=t+(n-t)/2|0,e<(o=(i=this.prefixSum[r])-this.values[r]))n=r-1;else{if(!(e>=i))break;t=r+1}return new ee(r,e-o)},e}(),ne=(function(){function e(e){this._cacheAccumulatedValueStart=0,this._cache=null,this._actual=new te(e),this._bustCache()}e.prototype._bustCache=function(){this._cacheAccumulatedValueStart=0,this._cache=null},e.prototype.insertValues=function(e,t){this._actual.insertValues(e,t)&&this._bustCache()},e.prototype.changeValue=function(e,t){this._actual.changeValue(e,t)&&this._bustCache()},e.prototype.removeValues=function(e,t){this._actual.removeValues(e,t)&&this._bustCache()},e.prototype.getTotalValue=function(){return this._actual.getTotalValue()},e.prototype.getAccumulatedValue=function(e){return this._actual.getAccumulatedValue(e)},e.prototype.getIndexOf=function(e){if(e=Math.floor(e),null!==this._cache){var t=e-this._cacheAccumulatedValueStart;if(t>=0&&t/?".length;n++){var r="`~!@#$%^&*()-=+[{]}\\|;:'\",.<>/?"[n];e.indexOf(r)>=0||(t+="\\"+r)}return t+="\\s]+)",new RegExp(t,"g")}();var ie=function(){function e(t){var n=J(t);this._defaultValue=n,this._asciiMap=e._createAsciiMap(n),this._map=new Map}return e._createAsciiMap=function(e){for(var t=new Uint8Array(256),n=0;n<256;n++)t[n]=e;return t},e.prototype.set=function(e,t){var n=J(t);e>=0&&e<256?this._asciiMap[e]=n:this._map.set(e,n)},e.prototype.get=function(e){return e>=0&&e<256?this._asciiMap[e]:this._map.get(e)||this._defaultValue},e}(),oe=(function(){function e(){this._actual=new ie(0)}e.prototype.add=function(e){this._actual.set(e,1)},e.prototype.has=function(e){return 1===this._actual.get(e)}}(),function(){function e(e){for(var t=0,n=0,r=0,i=e.length;rt&&(t=l),s>n&&(n=s),(c=o[2])>n&&(n=c)}t++,n++;var u=new $(n,t,0);for(r=0,i=e.length;r=this._maxCharCode?0:this._states.get(e,t)},e}()),se=null;var ue=null;var ae=function(){function e(){}return e._createLink=function(e,t,n,r,i){var o=i-1;do{var s=t.charCodeAt(o);if(2!==e.get(s))break;o--}while(o>r);if(r>0){var u=t.charCodeAt(r-1),a=t.charCodeAt(o);(40===u&&41===a||91===u&&93===a||123===u&&125===a)&&o--}return{range:{startLineNumber:n,startColumn:r+1,endLineNumber:n,endColumn:o+2},url:t.substring(r,o+1)}},e.computeLinks=function(t,n){void 0===n&&(null===se&&(se=new oe([[1,104,2],[1,72,2],[1,102,6],[1,70,6],[2,116,3],[2,84,3],[3,116,4],[3,84,4],[4,112,5],[4,80,5],[5,115,9],[5,83,9],[5,58,10],[6,105,7],[6,73,7],[7,108,8],[7,76,8],[8,101,9],[8,69,9],[9,58,10],[10,47,11],[11,47,12]])),n=se);for(var r=function(){if(null===ue){ue=new ie(0);for(var e=0;e<" \t<>'\"、。。、,.:;?!@#$%&*‘“〈《「『【〔([{「」}])〕】』」》〉”’`~…".length;e++)ue.set(" \t<>'\"、。。、,.:;?!@#$%&*‘“〈《「『【〔([{「」}])〕】』」》〉”’`~…".charCodeAt(e),1);for(e=0;e<".,;".length;e++)ue.set(".,;".charCodeAt(e),2)}return ue}(),i=[],o=1,s=t.getLineCount();o<=s;o++){for(var u=t.getLineContent(o),a=u.length,l=0,c=0,f=0,h=1,d=!1,m=!1,p=!1;l=0?((r+=n?1:-1)<0?r=e.length-1:r%=e.length,e[r]):null},e.INSTANCE=new e,e}();n(3);var ce,fe=function(){function e(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}return e.Undefined=new e(void 0),e}(),he=function(){function e(){this._first=fe.Undefined,this._last=fe.Undefined,this._size=0}return Object.defineProperty(e.prototype,"size",{get:function(){return this._size},enumerable:!0,configurable:!0}),e.prototype.isEmpty=function(){return this._first===fe.Undefined},e.prototype.clear=function(){this._first=fe.Undefined,this._last=fe.Undefined,this._size=0},e.prototype.unshift=function(e){return this._insert(e,!1)},e.prototype.push=function(e){return this._insert(e,!0)},e.prototype._insert=function(e,t){var n=this,r=new fe(e);if(this._first===fe.Undefined)this._first=r,this._last=r;else if(t){var i=this._last;this._last=r,r.prev=i,i.next=r}else{var o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;var s=!1;return function(){s||(s=!0,n._remove(r))}},e.prototype.shift=function(){if(this._first!==fe.Undefined){var e=this._first.element;return this._remove(this._first),e}},e.prototype._remove=function(e){if(e.prev!==fe.Undefined&&e.next!==fe.Undefined){var t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===fe.Undefined&&e.next===fe.Undefined?(this._first=fe.Undefined,this._last=fe.Undefined):e.next===fe.Undefined?(this._last=this._last.prev,this._last.next=fe.Undefined):e.prev===fe.Undefined&&(this._first=this._first.next,this._first.prev=fe.Undefined);this._size-=1},e.prototype.iterator=function(){var e,t=this._first;return{next:function(){return t===fe.Undefined?A:(e?e.value=t.element:e={done:!1,value:t.element},t=t.next,e)}}},e.prototype.toArray=function(){for(var e=[],t=this._first;t!==fe.Undefined;t=t.next)e.push(t.element);return e},e}(),de=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();!function(e){var t={dispose:function(){}};function n(e){return function(t,n,r){void 0===n&&(n=null);var i,o=!1;return i=e((function(e){if(!o)return i?i.dispose():o=!0,t.call(n,e)}),null,r),o&&i.dispose(),i}}function r(e,t){return u((function(n,r,i){return void 0===r&&(r=null),e((function(e){return n.call(r,t(e))}),null,i)}))}function i(e,t){return u((function(n,r,i){return void 0===r&&(r=null),e((function(e){t(e),n.call(r,e)}),null,i)}))}function o(e,t){return u((function(n,r,i){return void 0===r&&(r=null),e((function(e){return t(e)&&n.call(r,e)}),null,i)}))}function s(e,t,n){var i=n;return r(e,(function(e){return i=t(i,e)}))}function u(e){var t,n=new ge({onFirstListenerAdd:function(){t=e(n.fire,n)},onLastListenerRemove:function(){t.dispose()}});return n.event}function a(e){var t,n=!0;return o(e,(function(e){var r=n||e!==t;return n=!1,t=e,r}))}e.None=function(){return t},e.once=n,e.map=r,e.forEach=i,e.filter=o,e.signal=function(e){return e},e.any=function(){for(var e=[],t=0;t1)&&l.fire(e),a=0}),n)}))},onLastListenerRemove:function(){o.dispose()}});return l.event},e.stopwatch=function(e){var t=(new Date).getTime();return r(n(e),(function(e){return(new Date).getTime()-t}))},e.latch=a,e.buffer=function(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=[]);var r=n.slice(),i=e((function(e){r?r.push(e):s.fire(e)})),o=function(){r&&r.forEach((function(e){return s.fire(e)})),r=null},s=new ge({onFirstListenerAdd:function(){i||(i=e((function(e){return s.fire(e)})))},onFirstListenerDidAdd:function(){r&&(t?setTimeout(o):o())},onLastListenerRemove:function(){i&&i.dispose(),i=null}});return s.event};var c=function(){function e(e){this.event=e}return e.prototype.map=function(t){return new e(r(this.event,t))},e.prototype.forEach=function(t){return new e(i(this.event,t))},e.prototype.filter=function(t){return new e(o(this.event,t))},e.prototype.reduce=function(t,n){return new e(s(this.event,t,n))},e.prototype.latch=function(){return new e(a(this.event))},e.prototype.on=function(e,t,n){return this.event(e,t,n)},e.prototype.once=function(e,t,r){return n(this.event)(e,t,r)},e}();e.chain=function(e){return new c(e)},e.fromNodeEventEmitter=function(e,t,n){void 0===n&&(n=function(e){return e});var r=function(){for(var e=[],t=0;t0;){var r=this._deliveryQueue.shift(),i=r[0],s=r[1];try{"function"==typeof i?i.call(void 0,s):i[0].call(i[1],s)}catch(n){o(n)}}}},e.prototype.dispose=function(){this._listeners&&this._listeners.clear(),this._deliveryQueue&&this._deliveryQueue.clear(),this._leakageMon&&this._leakageMon.dispose(),this._disposed=!0},e._noop=function(){},e}(),_e=(function(e){function t(t){var n=e.call(this,t)||this;return n._isPaused=0,n._eventQueue=new he,n._mergeFn=t&&t.merge,n}de(t,e),t.prototype.pause=function(){this._isPaused++},t.prototype.resume=function(){if(0!==this._isPaused&&0==--this._isPaused)if(this._mergeFn){var t=this._eventQueue.toArray();this._eventQueue.clear(),e.prototype.fire.call(this,this._mergeFn(t))}else for(;!this._isPaused&&0!==this._eventQueue.size;)e.prototype.fire.call(this,this._eventQueue.shift())},t.prototype.fire=function(t){this._listeners&&(0!==this._isPaused?this._eventQueue.push(t):e.prototype.fire.call(this,t))}}(ge),function(){function e(){var e=this;this.hasListeners=!1,this.events=[],this.emitter=new ge({onFirstListenerAdd:function(){return e.onFirstListenerAdd()},onLastListenerRemove:function(){return e.onLastListenerRemove()}})}Object.defineProperty(e.prototype,"event",{get:function(){return this.emitter.event},enumerable:!0,configurable:!0}),e.prototype.add=function(e){var t=this,n={event:e,listener:null};this.events.push(n),this.hasListeners&&this.hook(n);return function(e){return{dispose:function(){e()}}}(function(e){var t,n=this,r=!1;return function(){return r?t:(r=!0,t=e.apply(n,arguments))}}((function(){t.hasListeners&&t.unhook(n);var e=t.events.indexOf(n);t.events.splice(e,1)})))},e.prototype.onFirstListenerAdd=function(){var e=this;this.hasListeners=!0,this.events.forEach((function(t){return e.hook(t)}))},e.prototype.onLastListenerRemove=function(){var e=this;this.hasListeners=!1,this.events.forEach((function(t){return e.unhook(t)}))},e.prototype.hook=function(e){var t=this;e.listener=e.event((function(e){return t.emitter.fire(e)}))},e.prototype.unhook=function(e){e.listener&&e.listener.dispose(),e.listener=null},e.prototype.dispose=function(){this.emitter.dispose()}}(),function(){function e(){this.buffers=[]}e.prototype.wrapEvent=function(e){var t=this;return function(n,r,i){return e((function(e){var i=t.buffers[t.buffers.length-1];i?i.push((function(){return n.call(r,e)})):n.call(r,e)}),void 0,i)}},e.prototype.bufferEvents=function(e){var t=[];this.buffers.push(t);var n=e();return this.buffers.pop(),t.forEach((function(e){return e()})),n}}(),function(){function e(){var e=this;this.listening=!1,this.inputEvent=ce.None,this.inputEventListener=c.None,this.emitter=new ge({onFirstListenerDidAdd:function(){e.listening=!0,e.inputEventListener=e.inputEvent(e.emitter.fire,e.emitter)},onLastListenerRemove:function(){e.listening=!1,e.inputEventListener.dispose()}}),this.event=this.emitter.event}Object.defineProperty(e.prototype,"input",{set:function(e){this.inputEvent=e,this.listening&&(this.inputEventListener.dispose(),this.inputEventListener=e(this.emitter.fire,this.emitter))},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){this.inputEventListener.dispose(),this.emitter.dispose()}}(),Object.freeze((function(e,t){var n=setTimeout(e.bind(t),0);return{dispose:function(){clearTimeout(n)}}})));(pe=me||(me={})).isCancellationToken=function(e){return e===pe.None||e===pe.Cancelled||e instanceof ye||!(!e||"object"!=typeof e)&&"boolean"==typeof e.isCancellationRequested&&"function"==typeof e.onCancellationRequested},pe.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:ce.None}),pe.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:_e});var ve,ye=function(){function e(){this._isCancelled=!1,this._emitter=null}return e.prototype.cancel=function(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))},Object.defineProperty(e.prototype,"isCancellationRequested",{get:function(){return this._isCancelled},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onCancellationRequested",{get:function(){return this._isCancelled?_e:(this._emitter||(this._emitter=new ge),this._emitter.event)},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){this._emitter&&(this._emitter.dispose(),this._emitter=null)},e}(),Ce=function(){function e(e){this._token=void 0,this._parentListener=void 0,this._parentListener=e&&e.onCancellationRequested(this.cancel,this)}return Object.defineProperty(e.prototype,"token",{get:function(){return this._token||(this._token=new ye),this._token},enumerable:!0,configurable:!0}),e.prototype.cancel=function(){this._token?this._token instanceof ye&&this._token.cancel():this._token=me.Cancelled},e.prototype.dispose=function(){this._parentListener&&this._parentListener.dispose(),this._token?this._token instanceof ye&&this._token.dispose():this._token=me.None},e}(),be=function(){function e(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}return e.prototype.define=function(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e},e.prototype.keyCodeToStr=function(e){return this._keyCodeToStr[e]},e.prototype.strToKeyCode=function(e){return this._strToKeyCode[e.toLowerCase()]||0},e}(),Le=new be,Ne=new be,Ee=new be;!function(){function e(e,t,n,r){void 0===n&&(n=t),void 0===r&&(r=n),Le.define(e,t),Ne.define(e,n),Ee.define(e,r)}e(0,"unknown"),e(1,"Backspace"),e(2,"Tab"),e(3,"Enter"),e(4,"Shift"),e(5,"Ctrl"),e(6,"Alt"),e(7,"PauseBreak"),e(8,"CapsLock"),e(9,"Escape"),e(10,"Space"),e(11,"PageUp"),e(12,"PageDown"),e(13,"End"),e(14,"Home"),e(15,"LeftArrow","Left"),e(16,"UpArrow","Up"),e(17,"RightArrow","Right"),e(18,"DownArrow","Down"),e(19,"Insert"),e(20,"Delete"),e(21,"0"),e(22,"1"),e(23,"2"),e(24,"3"),e(25,"4"),e(26,"5"),e(27,"6"),e(28,"7"),e(29,"8"),e(30,"9"),e(31,"A"),e(32,"B"),e(33,"C"),e(34,"D"),e(35,"E"),e(36,"F"),e(37,"G"),e(38,"H"),e(39,"I"),e(40,"J"),e(41,"K"),e(42,"L"),e(43,"M"),e(44,"N"),e(45,"O"),e(46,"P"),e(47,"Q"),e(48,"R"),e(49,"S"),e(50,"T"),e(51,"U"),e(52,"V"),e(53,"W"),e(54,"X"),e(55,"Y"),e(56,"Z"),e(57,"Meta"),e(58,"ContextMenu"),e(59,"F1"),e(60,"F2"),e(61,"F3"),e(62,"F4"),e(63,"F5"),e(64,"F6"),e(65,"F7"),e(66,"F8"),e(67,"F9"),e(68,"F10"),e(69,"F11"),e(70,"F12"),e(71,"F13"),e(72,"F14"),e(73,"F15"),e(74,"F16"),e(75,"F17"),e(76,"F18"),e(77,"F19"),e(78,"NumLock"),e(79,"ScrollLock"),e(80,";",";","OEM_1"),e(81,"=","=","OEM_PLUS"),e(82,",",",","OEM_COMMA"),e(83,"-","-","OEM_MINUS"),e(84,".",".","OEM_PERIOD"),e(85,"/","/","OEM_2"),e(86,"`","`","OEM_3"),e(110,"ABNT_C1"),e(111,"ABNT_C2"),e(87,"[","[","OEM_4"),e(88,"\\","\\","OEM_5"),e(89,"]","]","OEM_6"),e(90,"'","'","OEM_7"),e(91,"OEM_8"),e(92,"OEM_102"),e(93,"NumPad0"),e(94,"NumPad1"),e(95,"NumPad2"),e(96,"NumPad3"),e(97,"NumPad4"),e(98,"NumPad5"),e(99,"NumPad6"),e(100,"NumPad7"),e(101,"NumPad8"),e(102,"NumPad9"),e(103,"NumPad_Multiply"),e(104,"NumPad_Add"),e(105,"NumPad_Separator"),e(106,"NumPad_Subtract"),e(107,"NumPad_Decimal"),e(108,"NumPad_Divide")}(),function(e){e.toString=function(e){return Le.keyCodeToStr(e)},e.fromString=function(e){return Le.strToKeyCode(e)},e.toUserSettingsUS=function(e){return Ne.keyCodeToStr(e)},e.toUserSettingsGeneral=function(e){return Ee.keyCodeToStr(e)},e.fromUserSettings=function(e){return Ne.strToKeyCode(e)||Ee.strToKeyCode(e)}}(ve||(ve={}));!function(){function e(e,t,n,r,i){this.ctrlKey=e,this.shiftKey=t,this.altKey=n,this.metaKey=r,this.keyCode=i}e.prototype.equals=function(e){return this.ctrlKey===e.ctrlKey&&this.shiftKey===e.shiftKey&&this.altKey===e.altKey&&this.metaKey===e.metaKey&&this.keyCode===e.keyCode},e.prototype.isModifierKey=function(){return 0===this.keyCode||5===this.keyCode||57===this.keyCode||6===this.keyCode||4===this.keyCode},e.prototype.toChord=function(){return new Je([this])},e.prototype.isDuplicateModifierCase=function(){return this.ctrlKey&&5===this.keyCode||this.shiftKey&&4===this.keyCode||this.altKey&&6===this.keyCode||this.metaKey&&57===this.keyCode}}();var Se,we,Ae,Te,Me,Pe,Oe,xe,Ie,Re,ke,Ue,Fe,De,Ke,qe,Ve,Be,je,Ye,We,He,Ge,Qe,ze,Xe,$e,Je=function(){function e(e){if(0===e.length)throw(t="parts")?new Error("Illegal argument: "+t):new Error("Illegal argument");var t;this.parts=e}return e.prototype.equals=function(e){if(null===e)return!1;if(this.parts.length!==e.parts.length)return!1;for(var t=0;t "+this.positionLineNumber+","+this.positionColumn+"]"},t.prototype.equalsSelection=function(e){return t.selectionsEqual(this,e)},t.selectionsEqual=function(e,t){return e.selectionStartLineNumber===t.selectionStartLineNumber&&e.selectionStartColumn===t.selectionStartColumn&&e.positionLineNumber===t.positionLineNumber&&e.positionColumn===t.positionColumn},t.prototype.getDirection=function(){return this.selectionStartLineNumber===this.startLineNumber&&this.selectionStartColumn===this.startColumn?0:1},t.prototype.setEndPosition=function(e,n){return 0===this.getDirection()?new t(this.startLineNumber,this.startColumn,e,n):new t(e,n,this.startLineNumber,this.startColumn)},t.prototype.getPosition=function(){return new j(this.positionLineNumber,this.positionColumn)},t.prototype.setStartPosition=function(e,n){return 0===this.getDirection()?new t(e,n,this.endLineNumber,this.endColumn):new t(this.endLineNumber,this.endColumn,e,n)},t.fromPositions=function(e,n){return void 0===n&&(n=e),new t(e.lineNumber,e.column,n.lineNumber,n.column)},t.liftSelection=function(e){return new t(e.selectionStartLineNumber,e.selectionStartColumn,e.positionLineNumber,e.positionColumn)},t.selectionsArrEqual=function(e,t){if(e&&!t||!e&&t)return!1;if(!e&&!t)return!0;if(e.length!==t.length)return!1;for(var n=0,r=e.length;n>>0)>>>0}(e,t)},e.CtrlCmd=2048,e.Shift=1024,e.Alt=512,e.WinCtrl=256,e}();var rt=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),it=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return rt(t,e),Object.defineProperty(t.prototype,"uri",{get:function(){return this._uri},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"version",{get:function(){return this._versionId},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"eol",{get:function(){return this._eol},enumerable:!0,configurable:!0}),t.prototype.getValue=function(){return this.getText()},t.prototype.getLinesContent=function(){return this._lines.slice(0)},t.prototype.getLineCount=function(){return this._lines.length},t.prototype.getLineContent=function(e){return this._lines[e-1]},t.prototype.getWordAtPosition=function(e,t){var n=function(e,t,n,r){t.lastIndex=0;var i=t.exec(n);if(!i)return null;var o=i[0].indexOf(" ")>=0?function(e,t,n,r){var i,o=e-1-r;for(t.lastIndex=0;i=t.exec(n);){var s=i.index||0;if(s>o)return null;if(t.lastIndex>=o)return{word:i[0],startColumn:r+1+s,endColumn:r+1+t.lastIndex}}return null}(e,t,n,r):function(e,t,n,r){var i,o=e-1-r,s=n.lastIndexOf(" ",o-1)+1;for(t.lastIndex=s;i=t.exec(n);){var u=i.index||0;if(u<=o&&t.lastIndex>=o)return{word:i[0],startColumn:r+1+u,endColumn:r+1+t.lastIndex}}return null}(e,t,n,r);return t.lastIndex=0,o}(e.column,function(e){var t=re;if(e&&e instanceof RegExp)if(e.global)t=e;else{var n="g";e.ignoreCase&&(n+="i"),e.multiline&&(n+="m"),e.unicode&&(n+="u"),t=new RegExp(e.source,n)}return t.lastIndex=0,t}(t),this._lines[e.lineNumber-1],0);return n?new Y(e.lineNumber,n.startColumn,e.lineNumber,n.endColumn):null},t.prototype.getWordUntilPosition=function(e,t){var n=this.getWordAtPosition(e,t);return n?{word:this._lines[e.lineNumber-1].substring(n.startColumn-1,e.column-1),startColumn:n.startColumn,endColumn:e.column}:{word:"",startColumn:e.column,endColumn:e.column}},t.prototype.createWordIterator=function(e){var t,n,r=this,i=0,o=0,s=[],u=function(){if(o=r._lines.length?A:(n=r._lines[i],s=r._wordenize(n,e),o=0,i+=1,u())};return{next:u}},t.prototype.getLineWords=function(e,t){for(var n=this._lines[e-1],r=[],i=0,o=this._wordenize(n,t);ithis._lines.length)t=this._lines.length,n=this._lines[t-1].length+1,r=!0;else{var i=this._lines[t-1].length+1;n<1?(n=1,r=!0):n>i&&(n=i,r=!0)}return r?{lineNumber:t,column:n}:e},t}(ne),ot=function(e){function t(t){var n=e.call(this,t)||this;return n._models=Object.create(null),n}return rt(t,e),t.prototype.dispose=function(){this._models=Object.create(null)},t.prototype._getModel=function(e){return this._models[e]},t.prototype._getModels=function(){var e=this,t=[];return Object.keys(this._models).forEach((function(n){return t.push(e._models[n])})),t},t.prototype.acceptNewModel=function(e){this._models[e.url]=new it(U.parse(e.url),e.lines,e.EOL,e.versionId)},t.prototype.acceptModelChanged=function(e,t){this._models[e]&&this._models[e].onEvents(t)},t.prototype.acceptRemovedModel=function(e){this._models[e]&&delete this._models[e]},t}(function(){function e(e){this._foreignModuleFactory=e,this._foreignModule=null}return e.prototype.computeDiff=function(e,t,n){var r=this._getModel(e),i=this._getModel(t);if(!r||!i)return Promise.resolve(null);var o=r.getLinesContent(),s=i.getLinesContent(),u=new X(o,s,{shouldComputeCharChanges:!0,shouldPostProcessCharChanges:!0,shouldIgnoreTrimWhitespace:n,shouldMakePrettyDiff:!0}).computeDiff(),a=!(u.length>0)&&this._modelsAreIdentical(r,i);return Promise.resolve({identical:a,changes:u})},e.prototype._modelsAreIdentical=function(e,t){var n=e.getLineCount();if(n!==t.getLineCount())return!1;for(var r=1;r<=n;r++){if(e.getLineContent(r)!==t.getLineContent(r))return!1}return!0},e.prototype.computeMoreMinimalEdits=function(t,n){var r=this._getModel(t);if(!r)return Promise.resolve(n);for(var i=[],o=void 0,s=0,u=n=_(n,(function(e,t){return e.range&&t.range?Y.compareRangesUsingStarts(e.range,t.range):(e.range?0:1)-(t.range?0:1)}));se._diffLimit)i.push({range:l,text:c});else for(var d=C(h,c,!1),m=r.offsetAt(Y.lift(l).getStartPosition()),p=0,g=d;p{let e,t,n,r,i,o={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},s=function(t){throw{at:e,text:t,message:t}},u=function(t){return t&&t!==n&&s("Expected '"+t+"' instead of '"+n+"'"),n=r.charAt(e),e+=1,n},a=function(t,i){let o=e,u=r.indexOf(t,o);var a;return u<0&&s(i||"Expected '"+t+"'"),a=u+t.length,n=r.charAt(a),e=a+1,r.substring(o,u)},l=function(){var e,t="";for("-"===n&&(t="-",u("-"));n>="0"&&"9">=n;)t+=n,u();if("."===n)for(t+=".";u()&&n>="0"&&"9">=n;)t+=n;if("e"===n||"E"===n)for(t+=n,u(),("-"===n||"+"===n)&&(t+=n,u());n>="0"&&"9">=n;)t+=n,u();return e=+t,isNaN(e)?void s("Bad number"):e},c=function(){let t,i,l,c="";if('"'===n){if(f='""',r.substr(e,f.length)===f)return u('"'),u('"'),a('"""','failed to find closing \'"""\'');for(;u();){if('"'===n)return u(),c;if("\\"===n)if(u(),"u"===n){for(l=0,i=0;4>i&&(t=parseInt(u(),16),isFinite(t));i+=1)l=16*l+t;c+=String.fromCharCode(l)}else{if("string"!=typeof o[n])break;c+=o[n]}else c+=n}}var f;s("Bad string")},f=function(){for(;n&&" ">=n;)u()};return i=function(){switch(f(),n){case"{":return function(){var r,o,a,l={};if("{"===n){if(u("{"),f(),"}"===n)return u("}"),l;for(;n;){let s=e;if(r=c(),f(),u(":"),Object.hasOwnProperty.call(l,r)&&(o='Duplicate key "'+r+'"',a=s,t.push({type:at.warning,at:a,text:o})),l[r]=i(),f(),"}"===n)return u("}"),l;u(","),f()}}s("Bad object")}();case"[":return function(){var e=[];if("["===n){if(u("["),f(),"]"===n)return u("]"),e;for(;n;){if(e.push(i()),f(),"]"===n)return u("]"),e;u(","),f()}}s("Bad array")}();case'"':return c();case"-":return l();default:return n>="0"&&"9">=n?l():function(){switch(n){case"t":return u("t"),u("r"),u("u"),u("e"),!0;case"f":return u("f"),u("a"),u("l"),u("s"),u("e"),!1;case"n":return u("n"),u("u"),u("l"),u("l"),null}s("Unexpected '"+n+"'")}()}},function(o){t=[];let u=!1;r=o,e=0,n=" ",f();try{i()}catch(e){u=!0,t.push({type:at.error,at:e.at-1,text:e.message})}return!u&&n&&s("Syntax error"),{annotations:t}}};class ct{constructor(e){this.ctx=e}async parse(){this.parser||(this.parser=r.createParser());const[e]=this.ctx.getMirrorModels();return this.parser(e.getValue())}}self.onmessage=()=>{ut((e,t)=>new ct(e))}}]); \ No newline at end of file diff --git a/packages/kbn-langs/xjson/monaco/index.ts b/packages/kbn-ui-shared-deps/monaco/xjson/index.ts similarity index 80% rename from packages/kbn-langs/xjson/monaco/index.ts rename to packages/kbn-ui-shared-deps/monaco/xjson/index.ts index 16629b1375dab9..ea6be0c98d105a 100644 --- a/packages/kbn-langs/xjson/monaco/index.ts +++ b/packages/kbn-ui-shared-deps/monaco/xjson/index.ts @@ -17,7 +17,8 @@ * under the License. */ -// This export also registers the language globally -export { registerGrammarChecker } from './language'; +// This import also registers the language globally +import { registerGrammarChecker } from './language'; +import { ID } from './constants'; -export { ID } from './constants'; +export const XJsonLang = { ID, registerGrammarChecker }; diff --git a/packages/kbn-langs/xjson/monaco/language.ts b/packages/kbn-ui-shared-deps/monaco/xjson/language.ts similarity index 91% rename from packages/kbn-langs/xjson/monaco/language.ts rename to packages/kbn-ui-shared-deps/monaco/xjson/language.ts index 32782b328c4cd4..285687296b30ab 100644 --- a/packages/kbn-langs/xjson/monaco/language.ts +++ b/packages/kbn-ui-shared-deps/monaco/xjson/language.ts @@ -17,14 +17,12 @@ * under the License. */ -import 'monaco-editor/esm/vs/editor/contrib/hover/hover'; -import 'monaco-editor/esm/vs/editor/contrib/wordOperations/wordOperations'; -import { monaco } from '@kbn/ui-shared-deps/monaco'; +import { monaco } from '../'; import { WorkerProxyService } from './worker_proxy_service'; import './lexer_rules'; import { ID } from './constants'; // @ts-ignore -import workerSrc from '!!raw-loader!./dist/bundle.amd.worker.js'; +import workerSrc from '!!raw-loader!./dist/bundle.editor.worker.js'; const wps = new WorkerProxyService(); diff --git a/packages/kbn-langs/xjson/monaco/lexer_rules/esql.ts b/packages/kbn-ui-shared-deps/monaco/xjson/lexer_rules/esql.ts similarity index 98% rename from packages/kbn-langs/xjson/monaco/lexer_rules/esql.ts rename to packages/kbn-ui-shared-deps/monaco/xjson/lexer_rules/esql.ts index 58adf738132a87..f30d7219db1203 100644 --- a/packages/kbn-langs/xjson/monaco/lexer_rules/esql.ts +++ b/packages/kbn-ui-shared-deps/monaco/xjson/lexer_rules/esql.ts @@ -17,7 +17,7 @@ * under the License. */ -import { monaco } from '@kbn/ui-shared-deps/monaco'; +import { monaco } from '../../'; const ID = 'esql'; diff --git a/packages/kbn-langs/xjson/monaco/lexer_rules/index.ts b/packages/kbn-ui-shared-deps/monaco/xjson/lexer_rules/index.ts similarity index 100% rename from packages/kbn-langs/xjson/monaco/lexer_rules/index.ts rename to packages/kbn-ui-shared-deps/monaco/xjson/lexer_rules/index.ts diff --git a/packages/kbn-langs/xjson/monaco/lexer_rules/painless.ts b/packages/kbn-ui-shared-deps/monaco/xjson/lexer_rules/painless.ts similarity index 98% rename from packages/kbn-langs/xjson/monaco/lexer_rules/painless.ts rename to packages/kbn-ui-shared-deps/monaco/xjson/lexer_rules/painless.ts index c24537a60bf49d..226255b009bfc6 100644 --- a/packages/kbn-langs/xjson/monaco/lexer_rules/painless.ts +++ b/packages/kbn-ui-shared-deps/monaco/xjson/lexer_rules/painless.ts @@ -17,7 +17,7 @@ * under the License. */ -import { monaco } from '@kbn/ui-shared-deps/monaco'; +import { monaco } from '../../'; const ID = 'painless'; diff --git a/packages/kbn-langs/xjson/monaco/lexer_rules/shared.ts b/packages/kbn-ui-shared-deps/monaco/xjson/lexer_rules/shared.ts similarity index 100% rename from packages/kbn-langs/xjson/monaco/lexer_rules/shared.ts rename to packages/kbn-ui-shared-deps/monaco/xjson/lexer_rules/shared.ts diff --git a/packages/kbn-langs/xjson/monaco/lexer_rules/xjson.ts b/packages/kbn-ui-shared-deps/monaco/xjson/lexer_rules/xjson.ts similarity index 98% rename from packages/kbn-langs/xjson/monaco/lexer_rules/xjson.ts rename to packages/kbn-ui-shared-deps/monaco/xjson/lexer_rules/xjson.ts index 4197bcdfaf394a..94077c937c24ed 100644 --- a/packages/kbn-langs/xjson/monaco/lexer_rules/xjson.ts +++ b/packages/kbn-ui-shared-deps/monaco/xjson/lexer_rules/xjson.ts @@ -17,7 +17,7 @@ * under the License. */ -import { monaco } from '@kbn/ui-shared-deps/monaco'; +import { monaco } from '../../'; import { ID } from '../constants'; import './painless'; import './esql'; diff --git a/packages/kbn-langs/xjson/monaco/webpack.xjson-worker.config.js b/packages/kbn-ui-shared-deps/monaco/xjson/webpack.worker.config.js similarity index 97% rename from packages/kbn-langs/xjson/monaco/webpack.xjson-worker.config.js rename to packages/kbn-ui-shared-deps/monaco/xjson/webpack.worker.config.js index 6f65756e91079c..a560a1c9ef736d 100644 --- a/packages/kbn-langs/xjson/monaco/webpack.xjson-worker.config.js +++ b/packages/kbn-ui-shared-deps/monaco/xjson/webpack.worker.config.js @@ -25,7 +25,7 @@ const createConfig = (lang) => ({ entry: path.resolve(__dirname, `./worker/${lang}.worker.ts`), output: { path: path.resolve(__dirname, 'dist'), - filename: 'bundle.amd.worker.js', + filename: 'bundle.editor.worker.js', }, resolve: { modules: ['node_modules'], diff --git a/packages/kbn-langs/xjson/monaco/worker/index.ts b/packages/kbn-ui-shared-deps/monaco/xjson/worker/index.ts similarity index 100% rename from packages/kbn-langs/xjson/monaco/worker/index.ts rename to packages/kbn-ui-shared-deps/monaco/xjson/worker/index.ts diff --git a/packages/kbn-langs/xjson/monaco/worker/xjson.worker.ts b/packages/kbn-ui-shared-deps/monaco/xjson/worker/xjson.worker.ts similarity index 100% rename from packages/kbn-langs/xjson/monaco/worker/xjson.worker.ts rename to packages/kbn-ui-shared-deps/monaco/xjson/worker/xjson.worker.ts diff --git a/packages/kbn-langs/xjson/monaco/worker/xjson_worker.ts b/packages/kbn-ui-shared-deps/monaco/xjson/worker/xjson_worker.ts similarity index 92% rename from packages/kbn-langs/xjson/monaco/worker/xjson_worker.ts rename to packages/kbn-ui-shared-deps/monaco/xjson/worker/xjson_worker.ts index d7901d1b9fcefb..94325fb2507d07 100644 --- a/packages/kbn-langs/xjson/monaco/worker/xjson_worker.ts +++ b/packages/kbn-ui-shared-deps/monaco/xjson/worker/xjson_worker.ts @@ -18,7 +18,7 @@ */ import * as monaco from 'monaco-editor/esm/vs/editor/editor.api'; -import { createParser } from '../../grammar'; +import { XJsonGrammar } from '@kbn/langs'; export class XJsonWorker { constructor(private ctx: monaco.worker.IWorkerContext) {} @@ -26,7 +26,7 @@ export class XJsonWorker { async parse() { if (!this.parser) { - this.parser = createParser(); + this.parser = XJsonGrammar.createParser(); } const [model] = this.ctx.getMirrorModels(); return this.parser(model.getValue()); diff --git a/packages/kbn-langs/xjson/monaco/worker_proxy_service.ts b/packages/kbn-ui-shared-deps/monaco/xjson/worker_proxy_service.ts similarity index 89% rename from packages/kbn-langs/xjson/monaco/worker_proxy_service.ts rename to packages/kbn-ui-shared-deps/monaco/xjson/worker_proxy_service.ts index 1a50b9d14d9fc1..b052b9318a4652 100644 --- a/packages/kbn-langs/xjson/monaco/worker_proxy_service.ts +++ b/packages/kbn-ui-shared-deps/monaco/xjson/worker_proxy_service.ts @@ -17,14 +17,14 @@ * under the License. */ -import { monaco } from '@kbn/ui-shared-deps/monaco'; +import { XJsonGrammar } from '@kbn/langs'; +import { monaco } from '../'; import { XJsonWorker } from './worker'; -import { AnnoTypes } from '../grammar'; import { ID } from './constants'; export interface Annotation { name?: string; - type: AnnoTypes; + type: XJsonGrammar.AnnoTypes; text: string; at: number; } @@ -46,7 +46,7 @@ export class WorkerProxyService { } public setup() { - this.worker = monaco.editor.createWebWorker({ label: ID }); + this.worker = monaco.editor.createWebWorker({ label: ID, moduleId: '' }); } public stop() { diff --git a/packages/kbn-ui-shared-deps/tsconfig.json b/packages/kbn-ui-shared-deps/tsconfig.json index 5d981c73f1d211..5aa0f45e4100d4 100644 --- a/packages/kbn-ui-shared-deps/tsconfig.json +++ b/packages/kbn-ui-shared-deps/tsconfig.json @@ -1,7 +1,4 @@ { "extends": "../../tsconfig.json", - "include": [ - "index.d.ts", - "monaco.ts" - ] + "include": ["index.d.ts", "./monaco"] } diff --git a/packages/kbn-ui-shared-deps/webpack.config.js b/packages/kbn-ui-shared-deps/webpack.config.js index 7295f2e88c530f..9abd00a5b401f1 100644 --- a/packages/kbn-ui-shared-deps/webpack.config.js +++ b/packages/kbn-ui-shared-deps/webpack.config.js @@ -79,7 +79,18 @@ exports.getWebpackConfig = ({ dev = false } = {}) => ({ use: [MiniCssExtractPlugin.loader, 'css-loader'], }, { - include: [require.resolve('./monaco.ts')], + include: [require.resolve('./monaco/index.ts')], + use: [ + { + loader: 'babel-loader', + options: { + presets: [require.resolve('@kbn/babel-preset/webpack_preset')], + }, + }, + ], + }, + { + test: /\.ts$/, use: [ { loader: 'babel-loader', @@ -96,6 +107,7 @@ exports.getWebpackConfig = ({ dev = false } = {}) => ({ alias: { moment: MOMENT_SRC, }, + extensions: ['.js', '.ts'], }, optimization: { diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/index.ts b/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/index.ts deleted file mode 100644 index 341800956e27de..00000000000000 --- a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/index.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import * as XJsonLang from './xjson_lang'; - -export const monaco = { - XJsonLang, -}; From d5f7baae63dde184df94c7743d98e306b2397d33 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Thu, 28 May 2020 15:19:18 +0200 Subject: [PATCH 05/26] Update jest config for new work files --- src/dev/jest/config.js | 3 ++- .../mocks/{ace_worker_module_mock.js => worker_module_mock.js} | 0 x-pack/dev-tools/jest/create_jest_config.js | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) rename src/dev/jest/mocks/{ace_worker_module_mock.js => worker_module_mock.js} (100%) diff --git a/src/dev/jest/config.js b/src/dev/jest/config.js index 497a639ecab565..64db131f5219af 100644 --- a/src/dev/jest/config.js +++ b/src/dev/jest/config.js @@ -64,7 +64,8 @@ export default { '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '/src/dev/jest/mocks/file_mock.js', '\\.(css|less|scss)$': '/src/dev/jest/mocks/style_mock.js', - '\\.ace\\.worker.js$': '/src/dev/jest/mocks/ace_worker_module_mock.js', + '\\.ace\\.worker.js$': '/src/dev/jest/mocks/worker_module_mock.js', + '\\.editor\\.worker.js$': '/src/dev/jest/mocks/worker_module_mock.js', '^(!!)?file-loader!': '/src/dev/jest/mocks/file_mock.js', }, setupFiles: [ diff --git a/src/dev/jest/mocks/ace_worker_module_mock.js b/src/dev/jest/mocks/worker_module_mock.js similarity index 100% rename from src/dev/jest/mocks/ace_worker_module_mock.js rename to src/dev/jest/mocks/worker_module_mock.js diff --git a/x-pack/dev-tools/jest/create_jest_config.js b/x-pack/dev-tools/jest/create_jest_config.js index 3d8b45e7d1b837..1c0a3d47aca69e 100644 --- a/x-pack/dev-tools/jest/create_jest_config.js +++ b/x-pack/dev-tools/jest/create_jest_config.js @@ -24,7 +24,8 @@ export function createJestConfig({ kibanaDirectory, xPackKibanaDirectory }) { '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': fileMockPath, '\\.module.(css|scss)$': `${kibanaDirectory}/src/dev/jest/mocks/css_module_mock.js`, '\\.(css|less|scss)$': `${kibanaDirectory}/src/dev/jest/mocks/style_mock.js`, - '\\.ace\\.worker.js$': `${kibanaDirectory}/src/dev/jest/mocks/ace_worker_module_mock.js`, + '\\.ace\\.worker.js$': `${kibanaDirectory}/src/dev/jest/mocks/worker_module_mock.js`, + '\\.editor\\.worker.js$': `${kibanaDirectory}/src/dev/jest/mocks/worker_module_mock.js`, '^test_utils/enzyme_helpers': `${xPackKibanaDirectory}/test_utils/enzyme_helpers.tsx`, '^test_utils/find_test_subject': `${xPackKibanaDirectory}/test_utils/find_test_subject.ts`, '^test_utils/stub_web_worker': `${xPackKibanaDirectory}/test_utils/stub_web_worker.ts`, From e19dd177a6438463b403e71cbb46fdd839076688 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Thu, 28 May 2020 15:20:00 +0200 Subject: [PATCH 06/26] Update painless lab -- REVERT THIS COMMIT --- .../painless_lab/public/application/components/editor.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/painless_lab/public/application/components/editor.tsx b/x-pack/plugins/painless_lab/public/application/components/editor.tsx index 74454ad52c7f9f..462ab0c1db89cc 100644 --- a/x-pack/plugins/painless_lab/public/application/components/editor.tsx +++ b/x-pack/plugins/painless_lab/public/application/components/editor.tsx @@ -4,10 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ import React from 'react'; +import { XJsonLang } from '@kbn/ui-shared-deps/monaco'; import { CodeEditor } from '../../../../../../src/plugins/kibana_react/public'; -import { monaco } from '../../../../../../src/plugins/es_ui_shared/public'; - interface Props { code: string; onChange: (code: string) => void; @@ -16,12 +15,12 @@ interface Props { export function Editor({ code, onChange }: Props) { return ( { - monaco.XJsonLang.registerGrammarChecker(editor); + XJsonLang.registerGrammarChecker(editor); }} value={code} onChange={onChange} From 44a12ea912ca581031474b07c75a3d69ce23a09f Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Thu, 28 May 2020 15:55:51 +0200 Subject: [PATCH 07/26] Create shared useXJson mode hook --- .../monaco/index.ts | 20 +++++++++ .../monaco/use_xjson_mode.ts | 32 +++++++++++++++ .../__packages_do_not_import__/xjson/index.ts | 20 +++++++++ .../xjson/use_xjson_mode.ts | 41 +++++++++++++++++++ src/plugins/es_ui_shared/public/index.ts | 4 ++ .../es_ui_shared/public/monaco/index.ts | 20 +++++++++ .../static/ace_x_json/hooks/use_x_json.ts | 19 ++++----- 7 files changed, 144 insertions(+), 12 deletions(-) create mode 100644 src/plugins/es_ui_shared/__packages_do_not_import__/monaco/index.ts create mode 100644 src/plugins/es_ui_shared/__packages_do_not_import__/monaco/use_xjson_mode.ts create mode 100644 src/plugins/es_ui_shared/__packages_do_not_import__/xjson/index.ts create mode 100644 src/plugins/es_ui_shared/__packages_do_not_import__/xjson/use_xjson_mode.ts create mode 100644 src/plugins/es_ui_shared/public/monaco/index.ts diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/index.ts b/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/index.ts new file mode 100644 index 00000000000000..a9c6ea1e01d544 --- /dev/null +++ b/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/index.ts @@ -0,0 +1,20 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export { useXJsonMode } from './use_xjson_mode'; diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/use_xjson_mode.ts b/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/use_xjson_mode.ts new file mode 100644 index 00000000000000..8e71e50fa72043 --- /dev/null +++ b/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/use_xjson_mode.ts @@ -0,0 +1,32 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { XJsonLang } from '@kbn/ui-shared-deps/monaco'; +import { useXJsonMode as useBaseXJsonMode } from '../xjson'; + +interface ReturnValue extends ReturnType { + XJsonLang: typeof XJsonLang; +} + +export const useXJsonMode = (json: Parameters[0]): ReturnValue => { + return { + ...useBaseXJsonMode(json), + XJsonLang, + }; +}; diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/xjson/index.ts b/src/plugins/es_ui_shared/__packages_do_not_import__/xjson/index.ts new file mode 100644 index 00000000000000..a9c6ea1e01d544 --- /dev/null +++ b/src/plugins/es_ui_shared/__packages_do_not_import__/xjson/index.ts @@ -0,0 +1,20 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export { useXJsonMode } from './use_xjson_mode'; diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/xjson/use_xjson_mode.ts b/src/plugins/es_ui_shared/__packages_do_not_import__/xjson/use_xjson_mode.ts new file mode 100644 index 00000000000000..7dcc7c9ed83bcb --- /dev/null +++ b/src/plugins/es_ui_shared/__packages_do_not_import__/xjson/use_xjson_mode.ts @@ -0,0 +1,41 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { useState, Dispatch } from 'react'; +import { collapseLiteralStrings, expandLiteralStrings } from '../../public'; + +interface ReturnValue { + xJson: string; + setXJson: Dispatch; + convertToJson: typeof collapseLiteralStrings; +} + +export const useXJsonMode = (json: Record | string | null): ReturnValue => { + const [xJson, setXJson] = useState(() => + json === null + ? '' + : expandLiteralStrings(typeof json === 'string' ? json : JSON.stringify(json, null, 2)) + ); + + return { + xJson, + setXJson, + convertToJson: collapseLiteralStrings, + }; +}; diff --git a/src/plugins/es_ui_shared/public/index.ts b/src/plugins/es_ui_shared/public/index.ts index 7e5510d7c9c651..4ab791289dd886 100644 --- a/src/plugins/es_ui_shared/public/index.ts +++ b/src/plugins/es_ui_shared/public/index.ts @@ -47,6 +47,10 @@ export { expandLiteralStrings, } from './console_lang'; +import * as Monaco from './monaco'; + +export { Monaco }; + export { AuthorizationContext, AuthorizationProvider, diff --git a/src/plugins/es_ui_shared/public/monaco/index.ts b/src/plugins/es_ui_shared/public/monaco/index.ts new file mode 100644 index 00000000000000..23ba93e913234c --- /dev/null +++ b/src/plugins/es_ui_shared/public/monaco/index.ts @@ -0,0 +1,20 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export { useXJsonMode } from '../../__packages_do_not_import__/monaco'; diff --git a/src/plugins/es_ui_shared/static/ace_x_json/hooks/use_x_json.ts b/src/plugins/es_ui_shared/static/ace_x_json/hooks/use_x_json.ts index 2b0bf0c8a3a7cb..3a093ac6869d0b 100644 --- a/src/plugins/es_ui_shared/static/ace_x_json/hooks/use_x_json.ts +++ b/src/plugins/es_ui_shared/static/ace_x_json/hooks/use_x_json.ts @@ -16,23 +16,18 @@ * specific language governing permissions and limitations * under the License. */ - -import { useState } from 'react'; -import { XJsonMode, collapseLiteralStrings, expandLiteralStrings } from '../../../public'; +import { XJsonMode } from '../../../public'; +import { useXJsonMode as useBaseXJsonMode } from '../../../__packages_do_not_import__/xjson'; const xJsonMode = new XJsonMode(); -export const useXJsonMode = (json: Record | string | null) => { - const [xJson, setXJson] = useState(() => - json === null - ? '' - : expandLiteralStrings(typeof json === 'string' ? json : JSON.stringify(json, null, 2)) - ); +interface ReturnValue extends ReturnType { + xJsonMode: typeof xJsonMode; +} +export const useXJsonMode = (json: Parameters[0]): ReturnValue => { return { - xJson, - setXJson, + ...useBaseXJsonMode(json), xJsonMode, - convertToJson: collapseLiteralStrings, }; }; From b1ca795dfdaabbc17aaa9f42328a5dcec8168a0a Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Thu, 28 May 2020 15:56:51 +0200 Subject: [PATCH 08/26] Final update to using the new shared useXJsonMode hook -- REVERT --- .../public/application/components/editor.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/painless_lab/public/application/components/editor.tsx b/x-pack/plugins/painless_lab/public/application/components/editor.tsx index 462ab0c1db89cc..b2f4081a094df4 100644 --- a/x-pack/plugins/painless_lab/public/application/components/editor.tsx +++ b/x-pack/plugins/painless_lab/public/application/components/editor.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import React from 'react'; -import { XJsonLang } from '@kbn/ui-shared-deps/monaco'; +import { Monaco } from '../../../../../../src/plugins/es_ui_shared/public'; import { CodeEditor } from '../../../../../../src/plugins/kibana_react/public'; interface Props { @@ -13,6 +13,7 @@ interface Props { } export function Editor({ code, onChange }: Props) { + const { XJsonLang, xJson, convertToJson, setXJson } = Monaco.useXJsonMode(code); return ( { XJsonLang.registerGrammarChecker(editor); }} - value={code} - onChange={onChange} + value={xJson} + onChange={(value) => { + console.log(convertToJson(value)); + setXJson(value); + onChange(value); + }} options={{ fontSize: 12, minimap: { From bce6a278d45f8fafdc9846cd6d7b665db6029a64 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Fri, 29 May 2020 18:27:32 +0200 Subject: [PATCH 09/26] Created @kbn/monaco and share through shared deps --- .eslintignore | 1 + packages/kbn-langs/index.ts | 22 ------- packages/kbn-langs/package.json | 19 ------ .../xjson/lexer_rules => kbn-monaco}/index.ts | 2 +- .../monaco/index.ts => kbn-monaco/monaco.ts} | 0 packages/kbn-monaco/package.json | 28 +++++++++ .../scripts/build.js | 14 ++++- packages/kbn-monaco/tsconfig.json | 9 +++ packages/kbn-monaco/webpack.config.js | 63 +++++++++++++++++++ .../monaco => kbn-monaco}/xjson/README.md | 4 +- .../monaco => kbn-monaco}/xjson/constants.ts | 0 .../xjson/dist/bundle.editor.worker.js | 1 + .../xjson/grammar.ts | 0 .../monaco => kbn-monaco}/xjson/index.ts | 4 +- .../monaco => kbn-monaco}/xjson/language.ts | 9 ++- .../xjson/lexer_rules/esql.ts | 7 +-- .../xjson/lexer_rules/index.ts} | 38 ++++------- .../xjson/lexer_rules/painless.ts | 4 +- .../xjson/lexer_rules/shared.ts | 0 .../xjson/lexer_rules/xjson.ts | 4 +- .../xjson/webpack.worker.config.js | 2 - .../xjson/worker/index.ts | 0 .../xjson/worker/xjson.worker.ts | 0 .../xjson/worker/xjson_worker.ts | 4 +- .../xjson/worker_proxy_service.ts | 6 +- packages/kbn-monaco/yarn.lock | 1 + packages/kbn-ui-shared-deps/entry.js | 2 +- .../index.ts => kbn-ui-shared-deps/monaco.ts} | 2 +- .../monaco/xjson/dist/bundle.amd.worker.js | 1 - .../monaco/xjson/dist/bundle.editor.worker.js | 1 - packages/kbn-ui-shared-deps/package.json | 2 +- packages/kbn-ui-shared-deps/webpack.config.js | 2 +- 32 files changed, 155 insertions(+), 97 deletions(-) delete mode 100644 packages/kbn-langs/index.ts delete mode 100644 packages/kbn-langs/package.json rename packages/{kbn-ui-shared-deps/monaco/xjson/lexer_rules => kbn-monaco}/index.ts (95%) rename packages/{kbn-ui-shared-deps/monaco/index.ts => kbn-monaco/monaco.ts} (100%) create mode 100644 packages/kbn-monaco/package.json rename packages/{kbn-langs => kbn-monaco}/scripts/build.js (85%) create mode 100644 packages/kbn-monaco/tsconfig.json create mode 100644 packages/kbn-monaco/webpack.config.js rename packages/{kbn-ui-shared-deps/monaco => kbn-monaco}/xjson/README.md (90%) rename packages/{kbn-ui-shared-deps/monaco => kbn-monaco}/xjson/constants.ts (100%) create mode 100644 packages/kbn-monaco/xjson/dist/bundle.editor.worker.js rename packages/{kbn-langs => kbn-monaco}/xjson/grammar.ts (100%) rename packages/{kbn-ui-shared-deps/monaco => kbn-monaco}/xjson/index.ts (89%) rename packages/{kbn-ui-shared-deps/monaco => kbn-monaco}/xjson/language.ts (91%) rename packages/{kbn-ui-shared-deps/monaco => kbn-monaco}/xjson/lexer_rules/esql.ts (96%) rename packages/{kbn-langs/webpack.config.js => kbn-monaco/xjson/lexer_rules/index.ts} (58%) rename packages/{kbn-ui-shared-deps/monaco => kbn-monaco}/xjson/lexer_rules/painless.ts (98%) rename packages/{kbn-ui-shared-deps/monaco => kbn-monaco}/xjson/lexer_rules/shared.ts (100%) rename packages/{kbn-ui-shared-deps/monaco => kbn-monaco}/xjson/lexer_rules/xjson.ts (98%) rename packages/{kbn-ui-shared-deps/monaco => kbn-monaco}/xjson/webpack.worker.config.js (93%) rename packages/{kbn-ui-shared-deps/monaco => kbn-monaco}/xjson/worker/index.ts (100%) rename packages/{kbn-ui-shared-deps/monaco => kbn-monaco}/xjson/worker/xjson.worker.ts (100%) rename packages/{kbn-ui-shared-deps/monaco => kbn-monaco}/xjson/worker/xjson_worker.ts (92%) rename packages/{kbn-ui-shared-deps/monaco => kbn-monaco}/xjson/worker_proxy_service.ts (93%) create mode 120000 packages/kbn-monaco/yarn.lock rename packages/{kbn-langs/xjson/index.ts => kbn-ui-shared-deps/monaco.ts} (93%) delete mode 100644 packages/kbn-ui-shared-deps/monaco/xjson/dist/bundle.amd.worker.js delete mode 100644 packages/kbn-ui-shared-deps/monaco/xjson/dist/bundle.editor.worker.js diff --git a/.eslintignore b/.eslintignore index 362b3e42d48e5f..e0ada106059eaa 100644 --- a/.eslintignore +++ b/.eslintignore @@ -46,4 +46,5 @@ target /packages/kbn-ui-framework/dist /packages/kbn-ui-framework/doc_site/build /packages/kbn-ui-framework/generator-kui/*/templates/ +/packages/kbn-monaco/xjson/dist diff --git a/packages/kbn-langs/index.ts b/packages/kbn-langs/index.ts deleted file mode 100644 index 9c9024673b6e76..00000000000000 --- a/packages/kbn-langs/index.ts +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import * as XJsonGrammar from './xjson'; - -export { XJsonGrammar }; diff --git a/packages/kbn-langs/package.json b/packages/kbn-langs/package.json deleted file mode 100644 index a777c18248024d..00000000000000 --- a/packages/kbn-langs/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "@kbn/langs", - "version": "1.0.0", - "main": "./target/index.js", - "license": "MIT", - "private": true, - "devDependencies": { - "getopts": "^2.2.4", - "babel-loader": "^8.0.6", - "webpack": "^4.41.5", - "webpack-cli": "^3.3.10", - "supports-color": "^7.0.0", - "del": "^5.1.0", - "raw-loader": "3.1.0" - }, - "scripts": { - "build": "node ./scripts/build.js" - } -} diff --git a/packages/kbn-ui-shared-deps/monaco/xjson/lexer_rules/index.ts b/packages/kbn-monaco/index.ts similarity index 95% rename from packages/kbn-ui-shared-deps/monaco/xjson/lexer_rules/index.ts rename to packages/kbn-monaco/index.ts index 810e78b6b4aa73..ad74ca76c0dd0f 100644 --- a/packages/kbn-ui-shared-deps/monaco/xjson/lexer_rules/index.ts +++ b/packages/kbn-monaco/index.ts @@ -17,4 +17,4 @@ * under the License. */ -export { lexerRules } from './xjson'; +export * from './monaco'; diff --git a/packages/kbn-ui-shared-deps/monaco/index.ts b/packages/kbn-monaco/monaco.ts similarity index 100% rename from packages/kbn-ui-shared-deps/monaco/index.ts rename to packages/kbn-monaco/monaco.ts diff --git a/packages/kbn-monaco/package.json b/packages/kbn-monaco/package.json new file mode 100644 index 00000000000000..e239eb9f24e855 --- /dev/null +++ b/packages/kbn-monaco/package.json @@ -0,0 +1,28 @@ +{ + "name": "@kbn/monaco", + "version": "1.0.0", + "license": "MIT", + "private": true, + "types": "./target/types/index.d.ts", + "main": "./target/index.js", + "dependencies": { + "monaco-editor": "~0.17.0" + }, + "devDependencies": { + "@kbn/dev-utils": "1.0.0", + "getopts": "^2.2.4", + "babel-loader": "^8.0.6", + "webpack": "^4.41.5", + "webpack-cli": "^3.3.10", + "supports-color": "^7.0.0", + "del": "^5.1.0", + "raw-loader": "3.1.0", + "css-loader": "^3.4.2", + "mini-css-extract-plugin": "0.8.0", + "typescript": "3.7.2" + }, + "scripts": { + "build": "node ./scripts/build.js", + "kbn:bootstrap": "yarn build --dev" + } +} diff --git a/packages/kbn-langs/scripts/build.js b/packages/kbn-monaco/scripts/build.js similarity index 85% rename from packages/kbn-langs/scripts/build.js rename to packages/kbn-monaco/scripts/build.js index aada4c75cbd7ca..39599afc47f0d0 100644 --- a/packages/kbn-langs/scripts/build.js +++ b/packages/kbn-monaco/scripts/build.js @@ -26,7 +26,9 @@ const { ToolingLog, withProcRunner, pickLevelFromFlags } = require('@kbn/dev-uti const TARGET_BUILD_DIR = path.resolve(__dirname, '../target'); const ROOT_DIR = path.resolve(__dirname, '../'); -const flags = getopts(process.argv); +const flags = getopts(process.argv, { + boolean: ['dev'], +}); const log = new ToolingLog({ level: pickLevelFromFlags(flags), @@ -46,7 +48,15 @@ withProcRunner(log, async (proc) => { await proc.run('webpack ', { cmd: 'webpack', - args: ['--config', `${ROOT_DIR}/webpack.config.js`], + args: ['--config', `${ROOT_DIR}/webpack.config.js`, flags.dev ? '--env.dev' : '--env.prod'], + wait: true, + env, + cwd, + }); + + await proc.run('tsc ', { + cmd: 'tsc', + args: ['--emitDeclarationOnly'], wait: true, env, cwd, diff --git a/packages/kbn-monaco/tsconfig.json b/packages/kbn-monaco/tsconfig.json new file mode 100644 index 00000000000000..32c7ca98c1bc86 --- /dev/null +++ b/packages/kbn-monaco/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.json", + "include": ["xjson/**/*.ts", "index.ts", "monaco.ts"], + "compilerOptions": { + "declaration": true, + "declarationDir": "./target/types", + "types": ["jest", "node"] + } +} diff --git a/packages/kbn-monaco/webpack.config.js b/packages/kbn-monaco/webpack.config.js new file mode 100644 index 00000000000000..6301456ba26ef0 --- /dev/null +++ b/packages/kbn-monaco/webpack.config.js @@ -0,0 +1,63 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +const path = require('path'); +const MiniCssExtractPlugin = require('mini-css-extract-plugin'); + +module.exports = (env) => { + return { + mode: env.prod ? 'production' : 'development', + devtool: env.prod ? false : '#cheap-source-map', + entry: './index.ts', + output: { + filename: 'index.js', + path: path.resolve(__dirname, 'target'), + libraryTarget: 'commonjs', + }, + resolve: { + modules: ['node_modules'], + extensions: ['.js', '.ts'], + }, + stats: 'errors-only', + module: { + rules: [ + { + test: /\.ts$/, + exclude: /node_modules/, + use: [ + { + loader: 'babel-loader', + options: { + presets: ['@babel/typescript'], + }, + }, + ], + }, + { + test: /\.css$/, + use: [MiniCssExtractPlugin.loader, 'css-loader'], + }, + ], + }, + plugins: [ + new MiniCssExtractPlugin({ + filename: 'index.css', + }), + ], + }; +}; diff --git a/packages/kbn-ui-shared-deps/monaco/xjson/README.md b/packages/kbn-monaco/xjson/README.md similarity index 90% rename from packages/kbn-ui-shared-deps/monaco/xjson/README.md rename to packages/kbn-monaco/xjson/README.md index 7dd940069fbb9b..a419db122bc6c0 100644 --- a/packages/kbn-ui-shared-deps/monaco/xjson/README.md +++ b/packages/kbn-monaco/xjson/README.md @@ -19,12 +19,12 @@ the "raw-loader". See the related ./webpack.xjson-worker.config.js file that is runnable with Kibana's webpack with: ```sh -yarn webpack --config ./monaco/xjson/webpack.worker.config.js +yarn webpack --config ./xjson/webpack.worker.config.js ``` ### ./lexer_rules -Contains the Monarch-specific language tokenization rules for XJSON +Contains the Monarch-specific language tokenization rules for XJSON. Each set of rules registers itself against monaco. ### ./constants.ts diff --git a/packages/kbn-ui-shared-deps/monaco/xjson/constants.ts b/packages/kbn-monaco/xjson/constants.ts similarity index 100% rename from packages/kbn-ui-shared-deps/monaco/xjson/constants.ts rename to packages/kbn-monaco/xjson/constants.ts diff --git a/packages/kbn-monaco/xjson/dist/bundle.editor.worker.js b/packages/kbn-monaco/xjson/dist/bundle.editor.worker.js new file mode 100644 index 00000000000000..44487983574ccb --- /dev/null +++ b/packages/kbn-monaco/xjson/dist/bundle.editor.worker.js @@ -0,0 +1 @@ +!function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=6)}([function(e,t,n){"use strict";(function(e,r){n.d(t,"c",(function(){return m})),n.d(t,"b",(function(){return p})),n.d(t,"a",(function(){return g}));var i=!1,o=!1,s=!1,u=!1,a=!1,l=void 0!==e&&void 0!==e.versions&&void 0!==e.versions.electron&&"renderer"===e.type;if("object"!=typeof navigator||l){if("object"==typeof e){i="win32"===e.platform,o="darwin"===e.platform,s="linux"===e.platform,"en","en";var c=e.env.VSCODE_NLS_CONFIG;if(c)try{var f=JSON.parse(c),h=f.availableLanguages["*"];f.locale,h||"en",f._translationsConfigFile}catch(e){}u=!0}}else{var d=navigator.userAgent;i=d.indexOf("Windows")>=0,o=d.indexOf("Macintosh")>=0,s=d.indexOf("Linux")>=0,a=!0,navigator.language}var m=i,p=a,g="object"==typeof self?self:"object"==typeof r?r:{}}).call(this,n(2),n(1))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t){var n,r,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function u(e){if(n===setTimeout)return setTimeout(e,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(e){n=o}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();var a,l=[],c=!1,f=-1;function h(){c&&a&&(c=!1,a.length?l=a.concat(l):f=-1,l.length&&d())}function d(){if(!c){var e=u(h);c=!0;for(var t=l.length;t;){for(a=l,l=[];++f1)for(var n=1;n=0&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),t))},n(5),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,n(1))},function(e,t,n){(function(e,t){!function(e,n){"use strict";if(!e.setImmediate){var r,i,o,s,u,a=1,l={},c=!1,f=e.document,h=Object.getPrototypeOf&&Object.getPrototypeOf(e);h=h&&h.setTimeout?h:e,"[object process]"==={}.toString.call(e.process)?r=function(e){t.nextTick((function(){m(e)}))}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=n,t}}()?e.MessageChannel?((o=new MessageChannel).port1.onmessage=function(e){m(e.data)},r=function(e){o.port2.postMessage(e)}):f&&"onreadystatechange"in f.createElement("script")?(i=f.documentElement,r=function(e){var t=f.createElement("script");t.onreadystatechange=function(){m(e),t.onreadystatechange=null,i.removeChild(t),t=null},i.appendChild(t)}):r=function(e){setTimeout(m,0,e)}:(s="setImmediate$"+Math.random()+"$",u=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(s)&&m(+t.data.slice(s.length))},e.addEventListener?e.addEventListener("message",u,!1):e.attachEvent("onmessage",u),r=function(t){e.postMessage(s+t,"*")}),h.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;nr?e[a]=o[u++]:u>i?e[a]=o[s++]:t(o[u],o[s])<0?e[a]=o[u++]:e[a]=o[s++]}(t,n,r,s,i,o)}(e,t,0,e.length-1,[]),e}var _=function(){function e(e,t,n,r){this.originalStart=e,this.originalLength=t,this.modifiedStart=n,this.modifiedLength=r}return e.prototype.getOriginalEnd=function(){return this.originalStart+this.originalLength},e.prototype.getModifiedEnd=function(){return this.modifiedStart+this.modifiedLength},e}();function v(e){return{getLength:function(){return e.length},getElementAtIndex:function(t){return e.charCodeAt(t)}}}function y(e,t,n){return new E(v(e),v(t)).ComputeDiff(n)}var C,b=function(){function e(){}return e.Assert=function(e,t){if(!e)throw new Error(t)},e}(),L=function(){function e(){}return e.Copy=function(e,t,n,r,i){for(var o=0;o0||this.m_modifiedCount>0)&&this.m_changes.push(new _(this.m_originalStart,this.m_originalCount,this.m_modifiedStart,this.m_modifiedCount)),this.m_originalCount=0,this.m_modifiedCount=0,this.m_originalStart=Number.MAX_VALUE,this.m_modifiedStart=Number.MAX_VALUE},e.prototype.AddOriginalElement=function(e,t){this.m_originalStart=Math.min(this.m_originalStart,e),this.m_modifiedStart=Math.min(this.m_modifiedStart,t),this.m_originalCount++},e.prototype.AddModifiedElement=function(e,t){this.m_originalStart=Math.min(this.m_originalStart,e),this.m_modifiedStart=Math.min(this.m_modifiedStart,t),this.m_modifiedCount++},e.prototype.getChanges=function(){return(this.m_originalCount>0||this.m_modifiedCount>0)&&this.MarkNextChange(),this.m_changes},e.prototype.getReverseChanges=function(){return(this.m_originalCount>0||this.m_modifiedCount>0)&&this.MarkNextChange(),this.m_changes.reverse(),this.m_changes},e}(),E=function(){function e(e,t,n){void 0===n&&(n=null),this.OriginalSequence=e,this.ModifiedSequence=t,this.ContinueProcessingPredicate=n,this.m_forwardHistory=[],this.m_reverseHistory=[]}return e.prototype.ElementsAreEqual=function(e,t){return this.OriginalSequence.getElementAtIndex(e)===this.ModifiedSequence.getElementAtIndex(t)},e.prototype.OriginalElementsAreEqual=function(e,t){return this.OriginalSequence.getElementAtIndex(e)===this.OriginalSequence.getElementAtIndex(t)},e.prototype.ModifiedElementsAreEqual=function(e,t){return this.ModifiedSequence.getElementAtIndex(e)===this.ModifiedSequence.getElementAtIndex(t)},e.prototype.ComputeDiff=function(e){return this._ComputeDiff(0,this.OriginalSequence.getLength()-1,0,this.ModifiedSequence.getLength()-1,e)},e.prototype._ComputeDiff=function(e,t,n,r,i){var o=this.ComputeDiffRecursive(e,t,n,r,[!1]);return i?this.PrettifyChanges(o):o},e.prototype.ComputeDiffRecursive=function(e,t,n,r,i){for(i[0]=!1;e<=t&&n<=r&&this.ElementsAreEqual(e,n);)e++,n++;for(;t>=e&&r>=n&&this.ElementsAreEqual(t,r);)t--,r--;if(e>t||n>r){var o=void 0;return n<=r?(b.Assert(e===t+1,"originalStart should only be one more than originalEnd"),o=[new _(e,0,n,r-n+1)]):e<=t?(b.Assert(n===r+1,"modifiedStart should only be one more than modifiedEnd"),o=[new _(e,t-e+1,n,0)]):(b.Assert(e===t+1,"originalStart should only be one more than originalEnd"),b.Assert(n===r+1,"modifiedStart should only be one more than modifiedEnd"),o=[]),o}var s=[0],u=[0],a=this.ComputeRecursionPoint(e,t,n,r,s,u,i),l=s[0],c=u[0];if(null!==a)return a;if(!i[0]){var f=this.ComputeDiffRecursive(e,l,n,c,i),h=[];return h=i[0]?[new _(l+1,t-(l+1)+1,c+1,r-(c+1)+1)]:this.ComputeDiffRecursive(l+1,t,c+1,r,i),this.ConcatenateChanges(f,h)}return[new _(e,t-e+1,n,r-n+1)]},e.prototype.WALKTRACE=function(e,t,n,r,i,o,s,u,a,l,c,f,h,d,m,p,g,v){var y,C,b=null,L=new N,E=t,S=n,w=h[0]-p[0]-r,A=Number.MIN_VALUE,M=this.m_forwardHistory.length-1;do{(C=w+e)===E||C=0&&(e=(a=this.m_forwardHistory[M])[0],E=1,S=a.length-1)}while(--M>=-1);if(y=L.getReverseChanges(),v[0]){var T=h[0]+1,P=p[0]+1;if(null!==y&&y.length>0){var O=y[y.length-1];T=Math.max(T,O.getOriginalEnd()),P=Math.max(P,O.getModifiedEnd())}b=[new _(T,f-T+1,P,m-P+1)]}else{L=new N,E=o,S=s,w=h[0]-p[0]-u,A=Number.MAX_VALUE,M=g?this.m_reverseHistory.length-1:this.m_reverseHistory.length-2;do{(C=w+i)===E||C=l[C+1]?(d=(c=l[C+1]-1)-w-u,c>A&&L.MarkNextChange(),A=c+1,L.AddOriginalElement(c+1,d+1),w=C+1-i):(d=(c=l[C-1])-w-u,c>A&&L.MarkNextChange(),A=c,L.AddModifiedElement(c+1,d+1),w=C-1-i),M>=0&&(i=(l=this.m_reverseHistory[M])[0],E=1,S=l.length-1)}while(--M>=-1);b=L.getChanges()}return this.ConcatenateChanges(y,b)},e.prototype.ComputeRecursionPoint=function(e,t,n,r,i,o,s){var u,a=0,l=0,c=0,f=0,h=0,d=0;e--,n--,i[0]=0,o[0]=0,this.m_forwardHistory=[],this.m_reverseHistory=[];var m,p,g=t-e+(r-n),v=g+1,y=new Array(v),C=new Array(v),b=r-n,N=t-e,E=e-n,S=t-r,w=(N-b)%2==0;for(y[b]=e,C[N]=t,s[0]=!1,u=1;u<=g/2+1;u++){var A=0,M=0;for(c=this.ClipDiagonalBound(b-u,u,b,v),f=this.ClipDiagonalBound(b+u,u,b,v),m=c;m<=f;m+=2){for(l=(a=m===c||mA+M&&(A=a,M=l),!w&&Math.abs(m-N)<=u-1&&a>=C[m])return i[0]=a,o[0]=l,p<=C[m]&&u<=1448?this.WALKTRACE(b,c,f,E,N,h,d,S,y,C,a,t,i,l,r,o,w,s):null}var T=(A-e+(M-n)-u)/2;if(null!==this.ContinueProcessingPredicate&&!this.ContinueProcessingPredicate(A,this.OriginalSequence,T))return s[0]=!0,i[0]=A,o[0]=M,T>0&&u<=1448?this.WALKTRACE(b,c,f,E,N,h,d,S,y,C,a,t,i,l,r,o,w,s):(e++,n++,[new _(e,t-e+1,n,r-n+1)]);for(h=this.ClipDiagonalBound(N-u,u,N,v),d=this.ClipDiagonalBound(N+u,u,N,v),m=h;m<=d;m+=2){for(l=(a=m===h||m=C[m+1]?C[m+1]-1:C[m-1])-(m-N)-S,p=a;a>e&&l>n&&this.ElementsAreEqual(a,l);)a--,l--;if(C[m]=a,w&&Math.abs(m-b)<=u&&a<=y[m])return i[0]=a,o[0]=l,p>=y[m]&&u<=1448?this.WALKTRACE(b,c,f,E,N,h,d,S,y,C,a,t,i,l,r,o,w,s):null}if(u<=1447){var P=new Array(f-c+2);P[0]=b-c+1,L.Copy(y,c,P,1,f-c+1),this.m_forwardHistory.push(P),(P=new Array(d-h+2))[0]=N-h+1,L.Copy(C,h,P,1,d-h+1),this.m_reverseHistory.push(P)}}return this.WALKTRACE(b,c,f,E,N,h,d,S,y,C,a,t,i,l,r,o,w,s)},e.prototype.PrettifyChanges=function(e){for(var t=0;t0,s=n.modifiedLength>0;n.originalStart+n.originalLength=0;t--){n=e[t],r=0,i=0;if(t>0){var a=e[t-1];a.originalLength>0&&(r=a.originalStart+a.originalLength),a.modifiedLength>0&&(i=a.modifiedStart+a.modifiedLength)}o=n.originalLength>0,s=n.modifiedLength>0;for(var l=0,c=this._boundaryScore(n.originalStart,n.originalLength,n.modifiedStart,n.modifiedLength),f=1;;f++){var h=n.originalStart-f,d=n.modifiedStart-f;if(hc&&(c=m,l=f)}n.originalStart-=l,n.modifiedStart-=l}return e},e.prototype._OriginalIsBoundary=function(e){if(e<=0||e>=this.OriginalSequence.getLength()-1)return!0;var t=this.OriginalSequence.getElementAtIndex(e);return"string"==typeof t&&/^\s*$/.test(t)},e.prototype._OriginalRegionIsBoundary=function(e,t){if(this._OriginalIsBoundary(e)||this._OriginalIsBoundary(e-1))return!0;if(t>0){var n=e+t;if(this._OriginalIsBoundary(n-1)||this._OriginalIsBoundary(n))return!0}return!1},e.prototype._ModifiedIsBoundary=function(e){if(e<=0||e>=this.ModifiedSequence.getLength()-1)return!0;var t=this.ModifiedSequence.getElementAtIndex(e);return"string"==typeof t&&/^\s*$/.test(t)},e.prototype._ModifiedRegionIsBoundary=function(e,t){if(this._ModifiedIsBoundary(e)||this._ModifiedIsBoundary(e-1))return!0;if(t>0){var n=e+t;if(this._ModifiedIsBoundary(n-1)||this._ModifiedIsBoundary(n))return!0}return!1},e.prototype._boundaryScore=function(e,t,n,r){return(this._OriginalRegionIsBoundary(e,t)?1:0)+(this._ModifiedRegionIsBoundary(n,r)?1:0)},e.prototype.ConcatenateChanges=function(e,t){var n=[];if(0===e.length||0===t.length)return t.length>0?t:e;if(this.ChangesOverlap(e[e.length-1],t[0],n)){var r=new Array(e.length+t.length-1);return L.Copy(e,0,r,0,e.length-1),r[e.length-1]=n[0],L.Copy(t,1,r,e.length,t.length-1),r}r=new Array(e.length+t.length);return L.Copy(e,0,r,0,e.length),L.Copy(t,0,r,e.length,t.length),r},e.prototype.ChangesOverlap=function(e,t,n){if(b.Assert(e.originalStart<=t.originalStart,"Left change is not less than or equal to right change"),b.Assert(e.modifiedStart<=t.modifiedStart,"Left change is not less than or equal to right change"),e.originalStart+e.originalLength>=t.originalStart||e.modifiedStart+e.modifiedLength>=t.modifiedStart){var r=e.originalStart,i=e.originalLength,o=e.modifiedStart,s=e.modifiedLength;return e.originalStart+e.originalLength>=t.originalStart&&(i=t.originalStart+t.originalLength-e.originalStart),e.modifiedStart+e.modifiedLength>=t.modifiedStart&&(s=t.modifiedStart+t.modifiedLength-e.modifiedStart),n[0]=new _(r,i,o,s),!0}return n[0]=null,!1},e.prototype.ClipDiagonalBound=function(e,t,n,r){if(e>=0&&e=n?w:{done:!1,value:e[t++]}}}},e.from=function(t){return t?Array.isArray(t)?e.fromArray(t):t:e.empty()},e.map=function(e,t){return{next:function(){var n=e.next();return n.done?w:{done:!1,value:t(n.value)}}}},e.filter=function(e,t){return{next:function(){for(;;){var n=e.next();if(n.done)return w;if(t(n.value))return{done:!1,value:n.value}}}}},e.forEach=n,e.collect=function(e){var t=[];return n(e,(function(e){return t.push(e)})),t}}(C||(C={}));(function(e){function t(t,n,r,i){return void 0===n&&(n=0),void 0===r&&(r=t.length),void 0===i&&(i=n-1),e.call(this,t,n,r,i)||this}S(t,e),t.prototype.current=function(){return e.prototype.current.call(this)},t.prototype.previous=function(){return this.index=Math.max(this.index-1,this.start-1),this.current()},t.prototype.first=function(){return this.index=this.start,this.current()},t.prototype.last=function(){return this.index=this.end-1,this.current()},t.prototype.parent=function(){return null}})(function(){function e(e,t,n,r){void 0===t&&(t=0),void 0===n&&(n=e.length),void 0===r&&(r=t-1),this.items=e,this.start=t,this.end=n,this.index=r}return e.prototype.next=function(){return this.index=Math.min(this.index+1,this.end),this.current()},e.prototype.current=function(){return this.index===this.start-1||this.index===this.end?null:this.items[this.index]},e}()),function(){function e(e,t){this.iterator=e,this.fn=t}e.prototype.next=function(){return this.fn(this.iterator.next())}}();var A,M=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),T=/^\w[\w\d+.-]*$/,P=/^\//,O=/^\/\//;var x="",I="/",R=/^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,k=function(){function e(e,t,n,r,i,o){void 0===o&&(o=!1),"object"==typeof e?(this.scheme=e.scheme||x,this.authority=e.authority||x,this.path=e.path||x,this.query=e.query||x,this.fragment=e.fragment||x):(this.scheme=e||x,this.authority=t||x,this.path=function(e,t){switch(e){case"https":case"http":case"file":t?t[0]!==I&&(t=I+t):t=I}return t}(this.scheme,n||x),this.query=r||x,this.fragment=i||x,function(e,t){if(!e.scheme)throw new Error('[UriError]: Scheme is missing: {scheme: "", authority: "'+e.authority+'", path: "'+e.path+'", query: "'+e.query+'", fragment: "'+e.fragment+'"}');if(e.scheme&&!T.test(e.scheme))throw new Error("[UriError]: Scheme contains illegal characters.");if(e.path)if(e.authority){if(!P.test(e.path))throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character')}else if(O.test(e.path))throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")')}(this))}return e.isUri=function(t){return t instanceof e||!!t&&("string"==typeof t.authority&&"string"==typeof t.fragment&&"string"==typeof t.path&&"string"==typeof t.query&&"string"==typeof t.scheme&&"function"==typeof t.fsPath&&"function"==typeof t.with&&"function"==typeof t.toString)},Object.defineProperty(e.prototype,"fsPath",{get:function(){return q(this)},enumerable:!0,configurable:!0}),e.prototype.with=function(e){if(!e)return this;var t=e.scheme,n=e.authority,r=e.path,i=e.query,o=e.fragment;return void 0===t?t=this.scheme:null===t&&(t=x),void 0===n?n=this.authority:null===n&&(n=x),void 0===r?r=this.path:null===r&&(r=x),void 0===i?i=this.query:null===i&&(i=x),void 0===o?o=this.fragment:null===o&&(o=x),t===this.scheme&&n===this.authority&&r===this.path&&i===this.query&&o===this.fragment?this:new U(t,n,r,i,o)},e.parse=function(e,t){void 0===t&&(t=!1);var n=R.exec(e);return n?new U(n[2]||x,decodeURIComponent(n[4]||x),decodeURIComponent(n[5]||x),decodeURIComponent(n[7]||x),decodeURIComponent(n[9]||x),t):new U(x,x,x,x,x)},e.file=function(e){var t=x;if(c.c&&(e=e.replace(/\\/g,I)),e[0]===I&&e[1]===I){var n=e.indexOf(I,2);-1===n?(t=e.substring(2),e=I):(t=e.substring(2,n),e=e.substring(n)||I)}return new U("file",t,e,x,x)},e.from=function(e){return new U(e.scheme,e.authority,e.path,e.query,e.fragment)},e.prototype.toString=function(e){return void 0===e&&(e=!1),V(this,e)},e.prototype.toJSON=function(){return this},e.revive=function(t){if(t){if(t instanceof e)return t;var n=new U(t);return n._fsPath=t.fsPath,n._formatted=t.external,n}return t},e}(),U=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._formatted=null,t._fsPath=null,t}return M(t,e),Object.defineProperty(t.prototype,"fsPath",{get:function(){return this._fsPath||(this._fsPath=q(this)),this._fsPath},enumerable:!0,configurable:!0}),t.prototype.toString=function(e){return void 0===e&&(e=!1),e?V(this,!0):(this._formatted||(this._formatted=V(this,!1)),this._formatted)},t.prototype.toJSON=function(){var e={$mid:1};return this._fsPath&&(e.fsPath=this._fsPath),this._formatted&&(e.external=this._formatted),this.path&&(e.path=this.path),this.scheme&&(e.scheme=this.scheme),this.authority&&(e.authority=this.authority),this.query&&(e.query=this.query),this.fragment&&(e.fragment=this.fragment),e},t}(k),F=((A={})[58]="%3A",A[47]="%2F",A[63]="%3F",A[35]="%23",A[91]="%5B",A[93]="%5D",A[64]="%40",A[33]="%21",A[36]="%24",A[38]="%26",A[39]="%27",A[40]="%28",A[41]="%29",A[42]="%2A",A[43]="%2B",A[44]="%2C",A[59]="%3B",A[61]="%3D",A[32]="%20",A);function D(e,t){for(var n=void 0,r=-1,i=0;i=97&&o<=122||o>=65&&o<=90||o>=48&&o<=57||45===o||46===o||95===o||126===o||t&&47===o)-1!==r&&(n+=encodeURIComponent(e.substring(r,i)),r=-1),void 0!==n&&(n+=e.charAt(i));else{void 0===n&&(n=e.substr(0,i));var s=F[o];void 0!==s?(-1!==r&&(n+=encodeURIComponent(e.substring(r,i)),r=-1),n+=s):-1===r&&(r=i)}}return-1!==r&&(n+=encodeURIComponent(e.substring(r))),void 0!==n?n:e}function K(e){for(var t=void 0,n=0;n1&&"file"===e.scheme?"//"+e.authority+e.path:47===e.path.charCodeAt(0)&&(e.path.charCodeAt(1)>=65&&e.path.charCodeAt(1)<=90||e.path.charCodeAt(1)>=97&&e.path.charCodeAt(1)<=122)&&58===e.path.charCodeAt(2)?e.path[1].toLowerCase()+e.path.substr(2):e.path,c.c&&(t=t.replace(/\//g,"\\")),t}function V(e,t){var n=t?K:D,r="",i=e.scheme,o=e.authority,s=e.path,u=e.query,a=e.fragment;if(i&&(r+=i,r+=":"),(o||"file"===i)&&(r+=I,r+=I),o){var l=o.indexOf("@");if(-1!==l){var c=o.substr(0,l);o=o.substr(l+1),-1===(l=c.indexOf(":"))?r+=n(c,!1):(r+=n(c.substr(0,l),!1),r+=":",r+=n(c.substr(l+1),!1)),r+="@"}-1===(l=(o=o.toLowerCase()).indexOf(":"))?r+=n(o,!1):(r+=n(o.substr(0,l),!1),r+=o.substr(l))}if(s){if(s.length>=3&&47===s.charCodeAt(0)&&58===s.charCodeAt(2))(f=s.charCodeAt(1))>=65&&f<=90&&(s="/"+String.fromCharCode(f+32)+":"+s.substr(3));else if(s.length>=2&&58===s.charCodeAt(1)){var f;(f=s.charCodeAt(0))>=65&&f<=90&&(s=String.fromCharCode(f+32)+":"+s.substr(2))}r+=n(s,!0)}return u&&(r+="?",r+=n(u,!1)),a&&(r+="#",r+=t?a:D(a,!1)),r}var B=function(){function e(e,t){this.lineNumber=e,this.column=t}return e.prototype.with=function(t,n){return void 0===t&&(t=this.lineNumber),void 0===n&&(n=this.column),t===this.lineNumber&&n===this.column?this:new e(t,n)},e.prototype.delta=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=0),this.with(this.lineNumber+e,this.column+t)},e.prototype.equals=function(t){return e.equals(this,t)},e.equals=function(e,t){return!e&&!t||!!e&&!!t&&e.lineNumber===t.lineNumber&&e.column===t.column},e.prototype.isBefore=function(t){return e.isBefore(this,t)},e.isBefore=function(e,t){return e.lineNumbern||e===n&&t>r?(this.startLineNumber=n,this.startColumn=r,this.endLineNumber=e,this.endColumn=t):(this.startLineNumber=e,this.startColumn=t,this.endLineNumber=n,this.endColumn=r)}return e.prototype.isEmpty=function(){return e.isEmpty(this)},e.isEmpty=function(e){return e.startLineNumber===e.endLineNumber&&e.startColumn===e.endColumn},e.prototype.containsPosition=function(t){return e.containsPosition(this,t)},e.containsPosition=function(e,t){return!(t.lineNumbere.endLineNumber)&&(!(t.lineNumber===e.startLineNumber&&t.columne.endColumn))},e.prototype.containsRange=function(t){return e.containsRange(this,t)},e.containsRange=function(e,t){return!(t.startLineNumbere.endLineNumber||t.endLineNumber>e.endLineNumber)&&(!(t.startLineNumber===e.startLineNumber&&t.startColumne.endColumn)))},e.prototype.plusRange=function(t){return e.plusRange(this,t)},e.plusRange=function(t,n){var r,i,o,s;return n.startLineNumbert.endLineNumber?(o=n.endLineNumber,s=n.endColumn):n.endLineNumber===t.endLineNumber?(o=n.endLineNumber,s=Math.max(n.endColumn,t.endColumn)):(o=t.endLineNumber,s=t.endColumn),new e(r,i,o,s)},e.prototype.intersectRanges=function(t){return e.intersectRanges(this,t)},e.intersectRanges=function(t,n){var r=t.startLineNumber,i=t.startColumn,o=t.endLineNumber,s=t.endColumn,u=n.startLineNumber,a=n.startColumn,l=n.endLineNumber,c=n.endColumn;return rl?(o=l,s=c):o===l&&(s=Math.min(s,c)),r>o?null:r===o&&i>s?null:new e(r,i,o,s)},e.prototype.equalsRange=function(t){return e.equalsRange(this,t)},e.equalsRange=function(e,t){return!!e&&!!t&&e.startLineNumber===t.startLineNumber&&e.startColumn===t.startColumn&&e.endLineNumber===t.endLineNumber&&e.endColumn===t.endColumn},e.prototype.getEndPosition=function(){return new B(this.endLineNumber,this.endColumn)},e.prototype.getStartPosition=function(){return new B(this.startLineNumber,this.startColumn)},e.prototype.toString=function(){return"["+this.startLineNumber+","+this.startColumn+" -> "+this.endLineNumber+","+this.endColumn+"]"},e.prototype.setEndPosition=function(t,n){return new e(this.startLineNumber,this.startColumn,t,n)},e.prototype.setStartPosition=function(t,n){return new e(t,n,this.endLineNumber,this.endColumn)},e.prototype.collapseToStart=function(){return e.collapseToStart(this)},e.collapseToStart=function(t){return new e(t.startLineNumber,t.startColumn,t.startLineNumber,t.startColumn)},e.fromPositions=function(t,n){return void 0===n&&(n=t),new e(t.lineNumber,t.column,n.lineNumber,n.column)},e.lift=function(t){return t?new e(t.startLineNumber,t.startColumn,t.endLineNumber,t.endColumn):null},e.isIRange=function(e){return e&&"number"==typeof e.startLineNumber&&"number"==typeof e.startColumn&&"number"==typeof e.endLineNumber&&"number"==typeof e.endColumn},e.areIntersectingOrTouching=function(e,t){return!(e.endLineNumbere.startLineNumber},e}();String.fromCharCode(65279);function Y(e,t,n,r){return new E(e,t,n).ComputeDiff(r)}var W=function(){function e(t){for(var n=[],r=[],i=0,o=t.length;i=0;n--){var r=e.charCodeAt(n);if(32!==r&&9!==r)return n}return-1}(e);return-1===n?t:n+2},e.prototype.getCharSequence=function(e,t,n){for(var r=[],i=[],o=[],s=0,u=t;u<=n;u++)for(var a=this._lines[u],l=e?this._startColumns[u]:1,c=e?this._endColumns[u]:a.length+1,f=l;f1&&m>1;){if(f.charCodeAt(d-2)!==h.charCodeAt(m-2))break;d--,m--}(d>1||m>1)&&this._pushTrimWhitespaceCharChange(i,o+1,1,d,s+1,1,m);for(var p=W._getLastNonBlankColumn(f,1),g=W._getLastNonBlankColumn(h,1),_=f.length+1,v=h.length+1;p<_&&g255?255:0|e}function J(e){return e<0?0:e>4294967295?4294967295:0|e}var Z=function(e,t){this.index=e,this.remainder=t},ee=function(){function e(e){this.values=e,this.prefixSum=new Uint32Array(e.length),this.prefixSumValidIndex=new Int32Array(1),this.prefixSumValidIndex[0]=-1}return e.prototype.getCount=function(){return this.values.length},e.prototype.insertValues=function(e,t){e=J(e);var n=this.values,r=this.prefixSum,i=t.length;return 0!==i&&(this.values=new Uint32Array(n.length+i),this.values.set(n.subarray(0,e),0),this.values.set(n.subarray(e),e+i),this.values.set(t,e),e-1=0&&this.prefixSum.set(r.subarray(0,this.prefixSumValidIndex[0]+1)),!0)},e.prototype.changeValue=function(e,t){return e=J(e),t=J(t),this.values[e]!==t&&(this.values[e]=t,e-1=n.length)return!1;var i=n.length-e;return t>=i&&(t=i),0!==t&&(this.values=new Uint32Array(n.length-t),this.values.set(n.subarray(0,e),0),this.values.set(n.subarray(e+t),e),this.prefixSum=new Uint32Array(this.values.length),e-1=0&&this.prefixSum.set(r.subarray(0,this.prefixSumValidIndex[0]+1)),!0)},e.prototype.getTotalValue=function(){return 0===this.values.length?0:this._getAccumulatedValue(this.values.length-1)},e.prototype.getAccumulatedValue=function(e){return e<0?0:(e=J(e),this._getAccumulatedValue(e))},e.prototype._getAccumulatedValue=function(e){if(e<=this.prefixSumValidIndex[0])return this.prefixSum[e];var t=this.prefixSumValidIndex[0]+1;0===t&&(this.prefixSum[0]=this.values[0],t++),e>=this.values.length&&(e=this.values.length-1);for(var n=t;n<=e;n++)this.prefixSum[n]=this.prefixSum[n-1]+this.values[n];return this.prefixSumValidIndex[0]=Math.max(this.prefixSumValidIndex[0],e),this.prefixSum[e]},e.prototype.getIndexOf=function(e){e=Math.floor(e),this.getTotalValue();for(var t=0,n=this.values.length-1,r=0,i=0,o=0;t<=n;)if(r=t+(n-t)/2|0,e<(o=(i=this.prefixSum[r])-this.values[r]))n=r-1;else{if(!(e>=i))break;t=r+1}return new Z(r,e-o)},e}(),te=(function(){function e(e){this._cacheAccumulatedValueStart=0,this._cache=null,this._actual=new ee(e),this._bustCache()}e.prototype._bustCache=function(){this._cacheAccumulatedValueStart=0,this._cache=null},e.prototype.insertValues=function(e,t){this._actual.insertValues(e,t)&&this._bustCache()},e.prototype.changeValue=function(e,t){this._actual.changeValue(e,t)&&this._bustCache()},e.prototype.removeValues=function(e,t){this._actual.removeValues(e,t)&&this._bustCache()},e.prototype.getTotalValue=function(){return this._actual.getTotalValue()},e.prototype.getAccumulatedValue=function(e){return this._actual.getAccumulatedValue(e)},e.prototype.getIndexOf=function(e){if(e=Math.floor(e),null!==this._cache){var t=e-this._cacheAccumulatedValueStart;if(t>=0&&t/?".length;n++){var r="`~!@#$%^&*()-=+[{]}\\|;:'\",.<>/?"[n];e.indexOf(r)>=0||(t+="\\"+r)}return t+="\\s]+)",new RegExp(t,"g")}();var re=function(){function e(t){var n=$(t);this._defaultValue=n,this._asciiMap=e._createAsciiMap(n),this._map=new Map}return e._createAsciiMap=function(e){for(var t=new Uint8Array(256),n=0;n<256;n++)t[n]=e;return t},e.prototype.set=function(e,t){var n=$(t);e>=0&&e<256?this._asciiMap[e]=n:this._map.set(e,n)},e.prototype.get=function(e){return e>=0&&e<256?this._asciiMap[e]:this._map.get(e)||this._defaultValue},e}(),ie=(function(){function e(){this._actual=new re(0)}e.prototype.add=function(e){this._actual.set(e,1)},e.prototype.has=function(e){return 1===this._actual.get(e)}}(),function(){function e(e){for(var t=0,n=0,r=0,i=e.length;rt&&(t=l),s>n&&(n=s),(c=o[2])>n&&(n=c)}t++,n++;var u=new X(n,t,0);for(r=0,i=e.length;r=this._maxCharCode?0:this._states.get(e,t)},e}()),oe=null;var se=null;var ue=function(){function e(){}return e._createLink=function(e,t,n,r,i){var o=i-1;do{var s=t.charCodeAt(o);if(2!==e.get(s))break;o--}while(o>r);if(r>0){var u=t.charCodeAt(r-1),a=t.charCodeAt(o);(40===u&&41===a||91===u&&93===a||123===u&&125===a)&&o--}return{range:{startLineNumber:n,startColumn:r+1,endLineNumber:n,endColumn:o+2},url:t.substring(r,o+1)}},e.computeLinks=function(t,n){void 0===n&&(null===oe&&(oe=new ie([[1,104,2],[1,72,2],[1,102,6],[1,70,6],[2,116,3],[2,84,3],[3,116,4],[3,84,4],[4,112,5],[4,80,5],[5,115,9],[5,83,9],[5,58,10],[6,105,7],[6,73,7],[7,108,8],[7,76,8],[8,101,9],[8,69,9],[9,58,10],[10,47,11],[11,47,12]])),n=oe);for(var r=function(){if(null===se){se=new re(0);for(var e=0;e<" \t<>'\"、。。、,.:;?!@#$%&*‘“〈《「『【〔([{「」}])〕】』」》〉”’`~…".length;e++)se.set(" \t<>'\"、。。、,.:;?!@#$%&*‘“〈《「『【〔([{「」}])〕】』」》〉”’`~…".charCodeAt(e),1);for(e=0;e<".,;".length;e++)se.set(".,;".charCodeAt(e),2)}return se}(),i=[],o=1,s=t.getLineCount();o<=s;o++){for(var u=t.getLineContent(o),a=u.length,l=0,c=0,f=0,h=1,d=!1,m=!1,p=!1;l=0?((r+=n?1:-1)<0?r=e.length-1:r%=e.length,e[r]):null},e.INSTANCE=new e,e}();n(3);var le,ce=function(){function e(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}return e.Undefined=new e(void 0),e}(),fe=function(){function e(){this._first=ce.Undefined,this._last=ce.Undefined,this._size=0}return Object.defineProperty(e.prototype,"size",{get:function(){return this._size},enumerable:!0,configurable:!0}),e.prototype.isEmpty=function(){return this._first===ce.Undefined},e.prototype.clear=function(){this._first=ce.Undefined,this._last=ce.Undefined,this._size=0},e.prototype.unshift=function(e){return this._insert(e,!1)},e.prototype.push=function(e){return this._insert(e,!0)},e.prototype._insert=function(e,t){var n=this,r=new ce(e);if(this._first===ce.Undefined)this._first=r,this._last=r;else if(t){var i=this._last;this._last=r,r.prev=i,i.next=r}else{var o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;var s=!1;return function(){s||(s=!0,n._remove(r))}},e.prototype.shift=function(){if(this._first!==ce.Undefined){var e=this._first.element;return this._remove(this._first),e}},e.prototype._remove=function(e){if(e.prev!==ce.Undefined&&e.next!==ce.Undefined){var t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===ce.Undefined&&e.next===ce.Undefined?(this._first=ce.Undefined,this._last=ce.Undefined):e.next===ce.Undefined?(this._last=this._last.prev,this._last.next=ce.Undefined):e.prev===ce.Undefined&&(this._first=this._first.next,this._first.prev=ce.Undefined);this._size-=1},e.prototype.iterator=function(){var e,t=this._first;return{next:function(){return t===ce.Undefined?w:(e?e.value=t.element:e={done:!1,value:t.element},t=t.next,e)}}},e.prototype.toArray=function(){for(var e=[],t=this._first;t!==ce.Undefined;t=t.next)e.push(t.element);return e},e}(),he=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();!function(e){var t={dispose:function(){}};function n(e){return function(t,n,r){void 0===n&&(n=null);var i,o=!1;return i=e((function(e){if(!o)return i?i.dispose():o=!0,t.call(n,e)}),null,r),o&&i.dispose(),i}}function r(e,t){return u((function(n,r,i){return void 0===r&&(r=null),e((function(e){return n.call(r,t(e))}),null,i)}))}function i(e,t){return u((function(n,r,i){return void 0===r&&(r=null),e((function(e){t(e),n.call(r,e)}),null,i)}))}function o(e,t){return u((function(n,r,i){return void 0===r&&(r=null),e((function(e){return t(e)&&n.call(r,e)}),null,i)}))}function s(e,t,n){var i=n;return r(e,(function(e){return i=t(i,e)}))}function u(e){var t,n=new pe({onFirstListenerAdd:function(){t=e(n.fire,n)},onLastListenerRemove:function(){t.dispose()}});return n.event}function l(e){var t,n=!0;return o(e,(function(e){var r=n||e!==t;return n=!1,t=e,r}))}e.None=function(){return t},e.once=n,e.map=r,e.forEach=i,e.filter=o,e.signal=function(e){return e},e.any=function(){for(var e=[],t=0;t1)&&l.fire(e),a=0}),n)}))},onLastListenerRemove:function(){o.dispose()}});return l.event},e.stopwatch=function(e){var t=(new Date).getTime();return r(n(e),(function(e){return(new Date).getTime()-t}))},e.latch=l,e.buffer=function(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=[]);var r=n.slice(),i=e((function(e){r?r.push(e):s.fire(e)})),o=function(){r&&r.forEach((function(e){return s.fire(e)})),r=null},s=new pe({onFirstListenerAdd:function(){i||(i=e((function(e){return s.fire(e)})))},onFirstListenerDidAdd:function(){r&&(t?setTimeout(o):o())},onLastListenerRemove:function(){i&&i.dispose(),i=null}});return s.event};var c=function(){function e(e){this.event=e}return e.prototype.map=function(t){return new e(r(this.event,t))},e.prototype.forEach=function(t){return new e(i(this.event,t))},e.prototype.filter=function(t){return new e(o(this.event,t))},e.prototype.reduce=function(t,n){return new e(s(this.event,t,n))},e.prototype.latch=function(){return new e(l(this.event))},e.prototype.on=function(e,t,n){return this.event(e,t,n)},e.prototype.once=function(e,t,r){return n(this.event)(e,t,r)},e}();e.chain=function(e){return new c(e)},e.fromNodeEventEmitter=function(e,t,n){void 0===n&&(n=function(e){return e});var r=function(){for(var e=[],t=0;t0;){var r=this._deliveryQueue.shift(),o=r[0],s=r[1];try{"function"==typeof o?o.call(void 0,s):o[0].call(o[1],s)}catch(n){i(n)}}}},e.prototype.dispose=function(){this._listeners&&this._listeners.clear(),this._deliveryQueue&&this._deliveryQueue.clear(),this._leakageMon&&this._leakageMon.dispose(),this._disposed=!0},e._noop=function(){},e}(),ge=(function(e){function t(t){var n=e.call(this,t)||this;return n._isPaused=0,n._eventQueue=new fe,n._mergeFn=t&&t.merge,n}he(t,e),t.prototype.pause=function(){this._isPaused++},t.prototype.resume=function(){if(0!==this._isPaused&&0==--this._isPaused)if(this._mergeFn){var t=this._eventQueue.toArray();this._eventQueue.clear(),e.prototype.fire.call(this,this._mergeFn(t))}else for(;!this._isPaused&&0!==this._eventQueue.size;)e.prototype.fire.call(this,this._eventQueue.shift())},t.prototype.fire=function(t){this._listeners&&(0!==this._isPaused?this._eventQueue.push(t):e.prototype.fire.call(this,t))}}(pe),function(){function e(){var e=this;this.hasListeners=!1,this.events=[],this.emitter=new pe({onFirstListenerAdd:function(){return e.onFirstListenerAdd()},onLastListenerRemove:function(){return e.onLastListenerRemove()}})}Object.defineProperty(e.prototype,"event",{get:function(){return this.emitter.event},enumerable:!0,configurable:!0}),e.prototype.add=function(e){var t=this,n={event:e,listener:null};this.events.push(n),this.hasListeners&&this.hook(n);return function(e){return{dispose:function(){e()}}}(function(e){var t,n=this,r=!1;return function(){return r?t:(r=!0,t=e.apply(n,arguments))}}((function(){t.hasListeners&&t.unhook(n);var e=t.events.indexOf(n);t.events.splice(e,1)})))},e.prototype.onFirstListenerAdd=function(){var e=this;this.hasListeners=!0,this.events.forEach((function(t){return e.hook(t)}))},e.prototype.onLastListenerRemove=function(){var e=this;this.hasListeners=!1,this.events.forEach((function(t){return e.unhook(t)}))},e.prototype.hook=function(e){var t=this;e.listener=e.event((function(e){return t.emitter.fire(e)}))},e.prototype.unhook=function(e){e.listener&&e.listener.dispose(),e.listener=null},e.prototype.dispose=function(){this.emitter.dispose()}}(),function(){function e(){this.buffers=[]}e.prototype.wrapEvent=function(e){var t=this;return function(n,r,i){return e((function(e){var i=t.buffers[t.buffers.length-1];i?i.push((function(){return n.call(r,e)})):n.call(r,e)}),void 0,i)}},e.prototype.bufferEvents=function(e){var t=[];this.buffers.push(t);var n=e();return this.buffers.pop(),t.forEach((function(e){return e()})),n}}(),function(){function e(){var e=this;this.listening=!1,this.inputEvent=le.None,this.inputEventListener=l.None,this.emitter=new pe({onFirstListenerDidAdd:function(){e.listening=!0,e.inputEventListener=e.inputEvent(e.emitter.fire,e.emitter)},onLastListenerRemove:function(){e.listening=!1,e.inputEventListener.dispose()}}),this.event=this.emitter.event}Object.defineProperty(e.prototype,"input",{set:function(e){this.inputEvent=e,this.listening&&(this.inputEventListener.dispose(),this.inputEventListener=e(this.emitter.fire,this.emitter))},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){this.inputEventListener.dispose(),this.emitter.dispose()}}(),Object.freeze((function(e,t){var n=setTimeout(e.bind(t),0);return{dispose:function(){clearTimeout(n)}}})));(me=de||(de={})).isCancellationToken=function(e){return e===me.None||e===me.Cancelled||e instanceof ve||!(!e||"object"!=typeof e)&&"boolean"==typeof e.isCancellationRequested&&"function"==typeof e.onCancellationRequested},me.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:le.None}),me.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:ge});var _e,ve=function(){function e(){this._isCancelled=!1,this._emitter=null}return e.prototype.cancel=function(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))},Object.defineProperty(e.prototype,"isCancellationRequested",{get:function(){return this._isCancelled},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onCancellationRequested",{get:function(){return this._isCancelled?ge:(this._emitter||(this._emitter=new pe),this._emitter.event)},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){this._emitter&&(this._emitter.dispose(),this._emitter=null)},e}(),ye=function(){function e(e){this._token=void 0,this._parentListener=void 0,this._parentListener=e&&e.onCancellationRequested(this.cancel,this)}return Object.defineProperty(e.prototype,"token",{get:function(){return this._token||(this._token=new ve),this._token},enumerable:!0,configurable:!0}),e.prototype.cancel=function(){this._token?this._token instanceof ve&&this._token.cancel():this._token=de.Cancelled},e.prototype.dispose=function(){this._parentListener&&this._parentListener.dispose(),this._token?this._token instanceof ve&&this._token.dispose():this._token=de.None},e}(),Ce=function(){function e(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}return e.prototype.define=function(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e},e.prototype.keyCodeToStr=function(e){return this._keyCodeToStr[e]},e.prototype.strToKeyCode=function(e){return this._strToKeyCode[e.toLowerCase()]||0},e}(),be=new Ce,Le=new Ce,Ne=new Ce;!function(){function e(e,t,n,r){void 0===n&&(n=t),void 0===r&&(r=n),be.define(e,t),Le.define(e,n),Ne.define(e,r)}e(0,"unknown"),e(1,"Backspace"),e(2,"Tab"),e(3,"Enter"),e(4,"Shift"),e(5,"Ctrl"),e(6,"Alt"),e(7,"PauseBreak"),e(8,"CapsLock"),e(9,"Escape"),e(10,"Space"),e(11,"PageUp"),e(12,"PageDown"),e(13,"End"),e(14,"Home"),e(15,"LeftArrow","Left"),e(16,"UpArrow","Up"),e(17,"RightArrow","Right"),e(18,"DownArrow","Down"),e(19,"Insert"),e(20,"Delete"),e(21,"0"),e(22,"1"),e(23,"2"),e(24,"3"),e(25,"4"),e(26,"5"),e(27,"6"),e(28,"7"),e(29,"8"),e(30,"9"),e(31,"A"),e(32,"B"),e(33,"C"),e(34,"D"),e(35,"E"),e(36,"F"),e(37,"G"),e(38,"H"),e(39,"I"),e(40,"J"),e(41,"K"),e(42,"L"),e(43,"M"),e(44,"N"),e(45,"O"),e(46,"P"),e(47,"Q"),e(48,"R"),e(49,"S"),e(50,"T"),e(51,"U"),e(52,"V"),e(53,"W"),e(54,"X"),e(55,"Y"),e(56,"Z"),e(57,"Meta"),e(58,"ContextMenu"),e(59,"F1"),e(60,"F2"),e(61,"F3"),e(62,"F4"),e(63,"F5"),e(64,"F6"),e(65,"F7"),e(66,"F8"),e(67,"F9"),e(68,"F10"),e(69,"F11"),e(70,"F12"),e(71,"F13"),e(72,"F14"),e(73,"F15"),e(74,"F16"),e(75,"F17"),e(76,"F18"),e(77,"F19"),e(78,"NumLock"),e(79,"ScrollLock"),e(80,";",";","OEM_1"),e(81,"=","=","OEM_PLUS"),e(82,",",",","OEM_COMMA"),e(83,"-","-","OEM_MINUS"),e(84,".",".","OEM_PERIOD"),e(85,"/","/","OEM_2"),e(86,"`","`","OEM_3"),e(110,"ABNT_C1"),e(111,"ABNT_C2"),e(87,"[","[","OEM_4"),e(88,"\\","\\","OEM_5"),e(89,"]","]","OEM_6"),e(90,"'","'","OEM_7"),e(91,"OEM_8"),e(92,"OEM_102"),e(93,"NumPad0"),e(94,"NumPad1"),e(95,"NumPad2"),e(96,"NumPad3"),e(97,"NumPad4"),e(98,"NumPad5"),e(99,"NumPad6"),e(100,"NumPad7"),e(101,"NumPad8"),e(102,"NumPad9"),e(103,"NumPad_Multiply"),e(104,"NumPad_Add"),e(105,"NumPad_Separator"),e(106,"NumPad_Subtract"),e(107,"NumPad_Decimal"),e(108,"NumPad_Divide")}(),function(e){e.toString=function(e){return be.keyCodeToStr(e)},e.fromString=function(e){return be.strToKeyCode(e)},e.toUserSettingsUS=function(e){return Le.keyCodeToStr(e)},e.toUserSettingsGeneral=function(e){return Ne.keyCodeToStr(e)},e.fromUserSettings=function(e){return Le.strToKeyCode(e)||Ne.strToKeyCode(e)}}(_e||(_e={}));!function(){function e(e,t,n,r,i){this.ctrlKey=e,this.shiftKey=t,this.altKey=n,this.metaKey=r,this.keyCode=i}e.prototype.equals=function(e){return this.ctrlKey===e.ctrlKey&&this.shiftKey===e.shiftKey&&this.altKey===e.altKey&&this.metaKey===e.metaKey&&this.keyCode===e.keyCode},e.prototype.isModifierKey=function(){return 0===this.keyCode||5===this.keyCode||57===this.keyCode||6===this.keyCode||4===this.keyCode},e.prototype.toChord=function(){return new $e([this])},e.prototype.isDuplicateModifierCase=function(){return this.ctrlKey&&5===this.keyCode||this.shiftKey&&4===this.keyCode||this.altKey&&6===this.keyCode||this.metaKey&&57===this.keyCode}}();var Ee,Se,we,Ae,Me,Te,Pe,Oe,xe,Ie,Re,ke,Ue,Fe,De,Ke,qe,Ve,Be,je,Ye,We,He,Ge,Qe,ze,Xe,$e=function(){function e(e){if(0===e.length)throw(t="parts")?new Error("Illegal argument: "+t):new Error("Illegal argument");var t;this.parts=e}return e.prototype.equals=function(e){if(null===e)return!1;if(this.parts.length!==e.parts.length)return!1;for(var t=0;t "+this.positionLineNumber+","+this.positionColumn+"]"},t.prototype.equalsSelection=function(e){return t.selectionsEqual(this,e)},t.selectionsEqual=function(e,t){return e.selectionStartLineNumber===t.selectionStartLineNumber&&e.selectionStartColumn===t.selectionStartColumn&&e.positionLineNumber===t.positionLineNumber&&e.positionColumn===t.positionColumn},t.prototype.getDirection=function(){return this.selectionStartLineNumber===this.startLineNumber&&this.selectionStartColumn===this.startColumn?0:1},t.prototype.setEndPosition=function(e,n){return 0===this.getDirection()?new t(this.startLineNumber,this.startColumn,e,n):new t(e,n,this.startLineNumber,this.startColumn)},t.prototype.getPosition=function(){return new B(this.positionLineNumber,this.positionColumn)},t.prototype.setStartPosition=function(e,n){return 0===this.getDirection()?new t(e,n,this.endLineNumber,this.endColumn):new t(this.endLineNumber,this.endColumn,e,n)},t.fromPositions=function(e,n){return void 0===n&&(n=e),new t(e.lineNumber,e.column,n.lineNumber,n.column)},t.liftSelection=function(e){return new t(e.selectionStartLineNumber,e.selectionStartColumn,e.positionLineNumber,e.positionColumn)},t.selectionsArrEqual=function(e,t){if(e&&!t||!e&&t)return!1;if(!e&&!t)return!0;if(e.length!==t.length)return!1;for(var n=0,r=e.length;n>>0)>>>0}(e,t)},e.CtrlCmd=2048,e.Shift=1024,e.Alt=512,e.WinCtrl=256,e}();var nt=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),rt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return nt(t,e),Object.defineProperty(t.prototype,"uri",{get:function(){return this._uri},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"version",{get:function(){return this._versionId},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"eol",{get:function(){return this._eol},enumerable:!0,configurable:!0}),t.prototype.getValue=function(){return this.getText()},t.prototype.getLinesContent=function(){return this._lines.slice(0)},t.prototype.getLineCount=function(){return this._lines.length},t.prototype.getLineContent=function(e){return this._lines[e-1]},t.prototype.getWordAtPosition=function(e,t){var n=function(e,t,n,r){t.lastIndex=0;var i=t.exec(n);if(!i)return null;var o=i[0].indexOf(" ")>=0?function(e,t,n,r){var i,o=e-1-r;for(t.lastIndex=0;i=t.exec(n);){var s=i.index||0;if(s>o)return null;if(t.lastIndex>=o)return{word:i[0],startColumn:r+1+s,endColumn:r+1+t.lastIndex}}return null}(e,t,n,r):function(e,t,n,r){var i,o=e-1-r,s=n.lastIndexOf(" ",o-1)+1;for(t.lastIndex=s;i=t.exec(n);){var u=i.index||0;if(u<=o&&t.lastIndex>=o)return{word:i[0],startColumn:r+1+u,endColumn:r+1+t.lastIndex}}return null}(e,t,n,r);return t.lastIndex=0,o}(e.column,function(e){var t=ne;if(e&&e instanceof RegExp)if(e.global)t=e;else{var n="g";e.ignoreCase&&(n+="i"),e.multiline&&(n+="m"),e.unicode&&(n+="u"),t=new RegExp(e.source,n)}return t.lastIndex=0,t}(t),this._lines[e.lineNumber-1],0);return n?new j(e.lineNumber,n.startColumn,e.lineNumber,n.endColumn):null},t.prototype.getWordUntilPosition=function(e,t){var n=this.getWordAtPosition(e,t);return n?{word:this._lines[e.lineNumber-1].substring(n.startColumn-1,e.column-1),startColumn:n.startColumn,endColumn:e.column}:{word:"",startColumn:e.column,endColumn:e.column}},t.prototype.createWordIterator=function(e){var t,n,r=this,i=0,o=0,s=[],u=function(){if(o=r._lines.length?w:(n=r._lines[i],s=r._wordenize(n,e),o=0,i+=1,u())};return{next:u}},t.prototype.getLineWords=function(e,t){for(var n=this._lines[e-1],r=[],i=0,o=this._wordenize(n,t);ithis._lines.length)t=this._lines.length,n=this._lines[t-1].length+1,r=!0;else{var i=this._lines[t-1].length+1;n<1?(n=1,r=!0):n>i&&(n=i,r=!0)}return r?{lineNumber:t,column:n}:e},t}(te),it=function(e){function t(t){var n=e.call(this,t)||this;return n._models=Object.create(null),n}return nt(t,e),t.prototype.dispose=function(){this._models=Object.create(null)},t.prototype._getModel=function(e){return this._models[e]},t.prototype._getModels=function(){var e=this,t=[];return Object.keys(this._models).forEach((function(n){return t.push(e._models[n])})),t},t.prototype.acceptNewModel=function(e){this._models[e.url]=new rt(k.parse(e.url),e.lines,e.EOL,e.versionId)},t.prototype.acceptModelChanged=function(e,t){this._models[e]&&this._models[e].onEvents(t)},t.prototype.acceptRemovedModel=function(e){this._models[e]&&delete this._models[e]},t}(function(){function e(e){this._foreignModuleFactory=e,this._foreignModule=null}return e.prototype.computeDiff=function(e,t,n){var r=this._getModel(e),i=this._getModel(t);if(!r||!i)return Promise.resolve(null);var o=r.getLinesContent(),s=i.getLinesContent(),u=new z(o,s,{shouldComputeCharChanges:!0,shouldPostProcessCharChanges:!0,shouldIgnoreTrimWhitespace:n,shouldMakePrettyDiff:!0}).computeDiff(),a=!(u.length>0)&&this._modelsAreIdentical(r,i);return Promise.resolve({identical:a,changes:u})},e.prototype._modelsAreIdentical=function(e,t){var n=e.getLineCount();if(n!==t.getLineCount())return!1;for(var r=1;r<=n;r++){if(e.getLineContent(r)!==t.getLineContent(r))return!1}return!0},e.prototype.computeMoreMinimalEdits=function(t,n){var r=this._getModel(t);if(!r)return Promise.resolve(n);for(var i=[],o=void 0,s=0,u=n=g(n,(function(e,t){return e.range&&t.range?j.compareRangesUsingStarts(e.range,t.range):(e.range?0:1)-(t.range?0:1)}));se._diffLimit)i.push({range:l,text:c});else for(var d=y(h,c,!1),m=r.offsetAt(j.lift(l).getStartPosition()),p=0,_=d;p<_.length;p++){var v=_[p],C=r.positionAt(m+v.originalStart),b=r.positionAt(m+v.originalStart+v.originalLength),L={text:c.substr(v.modifiedStart,v.modifiedLength),range:{startLineNumber:C.lineNumber,startColumn:C.column,endLineNumber:b.lineNumber,endColumn:b.column}};r.getValueInRange(L.range)!==L.text&&i.push(L)}}}return"number"==typeof o&&i.push({eol:o,text:"",range:{startLineNumber:0,startColumn:0,endLineNumber:0,endColumn:0}}),Promise.resolve(i)},e.prototype.computeLinks=function(e){var t=this._getModel(e);return t?Promise.resolve(function(e){return e&&"function"==typeof e.getLineCount&&"function"==typeof e.getLineContent?ue.computeLinks(e):[]}(t)):Promise.resolve(null)},e.prototype.textualSuggest=function(t,n,r,i){var o=this._getModel(t);if(!o)return Promise.resolve(null);var s=Object.create(null),u=[],a=new RegExp(r,i),l=o.getWordUntilPosition(n,a),c=o.getWordAtPosition(n,a);c&&(s[o.getValueInRange(c)]=!0);for(var f=o.createWordIterator(a),h=f.next();!h.done&&u.length<=e._suggestionsLimit;h=f.next()){var d=h.value;s[d]||(s[d]=!0,isNaN(Number(d))&&u.push({kind:18,label:d,insertText:d,range:{startLineNumber:n.lineNumber,startColumn:l.startColumn,endLineNumber:n.lineNumber,endColumn:l.endColumn}}))}return Promise.resolve({suggestions:u})},e.prototype.computeWordRanges=function(e,t,n,r){var i=this._getModel(e);if(!i)return Promise.resolve(Object.create(null));for(var o=new RegExp(n,r),s=Object.create(null),u=t.startLineNumber;u{let e,t,n,r,i,o={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},s=function(t){throw{at:e,text:t,message:t}},u=function(t){return t&&t!==n&&s("Expected '"+t+"' instead of '"+n+"'"),n=r.charAt(e),e+=1,n},a=function(t,i){let o=e,u=r.indexOf(t,o);var a;return u<0&&s(i||"Expected '"+t+"'"),a=u+t.length,n=r.charAt(a),e=a+1,r.substring(o,u)},l=function(){var e,t="";for("-"===n&&(t="-",u("-"));n>="0"&&"9">=n;)t+=n,u();if("."===n)for(t+=".";u()&&n>="0"&&"9">=n;)t+=n;if("e"===n||"E"===n)for(t+=n,u(),("-"===n||"+"===n)&&(t+=n,u());n>="0"&&"9">=n;)t+=n,u();return e=+t,isNaN(e)?void s("Bad number"):e},c=function(){let t,i,l,c="";if('"'===n){if(f='""',r.substr(e,f.length)===f)return u('"'),u('"'),a('"""','failed to find closing \'"""\'');for(;u();){if('"'===n)return u(),c;if("\\"===n)if(u(),"u"===n){for(l=0,i=0;4>i&&(t=parseInt(u(),16),isFinite(t));i+=1)l=16*l+t;c+=String.fromCharCode(l)}else{if("string"!=typeof o[n])break;c+=o[n]}else c+=n}}var f;s("Bad string")},f=function(){for(;n&&" ">=n;)u()};return i=function(){switch(f(),n){case"{":return function(){var r,o,a,l={};if("{"===n){if(u("{"),f(),"}"===n)return u("}"),l;for(;n;){let s=e;if(r=c(),f(),u(":"),Object.hasOwnProperty.call(l,r)&&(o='Duplicate key "'+r+'"',a=s,t.push({type:ut.warning,at:a,text:o})),l[r]=i(),f(),"}"===n)return u("}"),l;u(","),f()}}s("Bad object")}();case"[":return function(){var e=[];if("["===n){if(u("["),f(),"]"===n)return u("]"),e;for(;n;){if(e.push(i()),f(),"]"===n)return u("]"),e;u(","),f()}}s("Bad array")}();case'"':return c();case"-":return l();default:return n>="0"&&"9">=n?l():function(){switch(n){case"t":return u("t"),u("r"),u("u"),u("e"),!0;case"f":return u("f"),u("a"),u("l"),u("s"),u("e"),!1;case"n":return u("n"),u("u"),u("l"),u("l"),null}s("Unexpected '"+n+"'")}()}},function(o){t=[];let u=!1;r=o,e=0,n=" ",f();try{i()}catch(e){u=!0,t.push({type:ut.error,at:e.at-1,text:e.message})}return!u&&n&&s("Syntax error"),{annotations:t}}};class lt{constructor(e){this.ctx=e}async parse(){this.parser||(this.parser=at());const[e]=this.ctx.getMirrorModels();return this.parser(e.getValue())}}self.onmessage=()=>{st((e,t)=>new lt(e))}}]); \ No newline at end of file diff --git a/packages/kbn-langs/xjson/grammar.ts b/packages/kbn-monaco/xjson/grammar.ts similarity index 100% rename from packages/kbn-langs/xjson/grammar.ts rename to packages/kbn-monaco/xjson/grammar.ts diff --git a/packages/kbn-ui-shared-deps/monaco/xjson/index.ts b/packages/kbn-monaco/xjson/index.ts similarity index 89% rename from packages/kbn-ui-shared-deps/monaco/xjson/index.ts rename to packages/kbn-monaco/xjson/index.ts index ea6be0c98d105a..35fd35887bc561 100644 --- a/packages/kbn-ui-shared-deps/monaco/xjson/index.ts +++ b/packages/kbn-monaco/xjson/index.ts @@ -17,8 +17,8 @@ * under the License. */ -// This import also registers the language globally import { registerGrammarChecker } from './language'; + import { ID } from './constants'; -export const XJsonLang = { ID, registerGrammarChecker }; +export const XJsonLang = { registerGrammarChecker, ID }; diff --git a/packages/kbn-ui-shared-deps/monaco/xjson/language.ts b/packages/kbn-monaco/xjson/language.ts similarity index 91% rename from packages/kbn-ui-shared-deps/monaco/xjson/language.ts rename to packages/kbn-monaco/xjson/language.ts index 285687296b30ab..79a2ed7c0241d9 100644 --- a/packages/kbn-ui-shared-deps/monaco/xjson/language.ts +++ b/packages/kbn-monaco/xjson/language.ts @@ -17,15 +17,20 @@ * under the License. */ -import { monaco } from '../'; +// This file contains a lot of single setup logic for registering a language globally + +import { monaco } from '../monaco'; import { WorkerProxyService } from './worker_proxy_service'; -import './lexer_rules'; +import { registerLexerRules } from './lexer_rules'; import { ID } from './constants'; // @ts-ignore import workerSrc from '!!raw-loader!./dist/bundle.editor.worker.js'; const wps = new WorkerProxyService(); +// Register rules against shared monaco instance. +registerLexerRules(monaco); + // In future we will need to make this map languages to workers using "id" and/or "label" values // that get passed in. // @ts-ignore diff --git a/packages/kbn-ui-shared-deps/monaco/xjson/lexer_rules/esql.ts b/packages/kbn-monaco/xjson/lexer_rules/esql.ts similarity index 96% rename from packages/kbn-ui-shared-deps/monaco/xjson/lexer_rules/esql.ts rename to packages/kbn-monaco/xjson/lexer_rules/esql.ts index f30d7219db1203..e75b1013d3727c 100644 --- a/packages/kbn-ui-shared-deps/monaco/xjson/lexer_rules/esql.ts +++ b/packages/kbn-monaco/xjson/lexer_rules/esql.ts @@ -17,9 +17,9 @@ * under the License. */ -import { monaco } from '../../'; +import { monaco } from '../../monaco'; -const ID = 'esql'; +export const ID = 'esql'; const brackets = [ { open: '[', close: ']', token: 'delimiter.square' }, @@ -268,6 +268,3 @@ export const lexerRules = { ], }, } as monaco.languages.IMonarchLanguage; - -monaco.languages.register({ id: ID }); -monaco.languages.setMonarchTokensProvider(ID, lexerRules); diff --git a/packages/kbn-langs/webpack.config.js b/packages/kbn-monaco/xjson/lexer_rules/index.ts similarity index 58% rename from packages/kbn-langs/webpack.config.js rename to packages/kbn-monaco/xjson/lexer_rules/index.ts index 28da10ced58eb4..7063fb0aa8f8b8 100644 --- a/packages/kbn-langs/webpack.config.js +++ b/packages/kbn-monaco/xjson/lexer_rules/index.ts @@ -16,31 +16,17 @@ * specific language governing permissions and limitations * under the License. */ -const path = require('path'); -module.exports = { - mode: 'production', - entry: './index.ts', - output: { - path: path.resolve(__dirname, 'target'), - }, - resolve: { - modules: ['node_modules'], - extensions: ['.js', '.ts', '.tsx'], - }, - stats: 'errors-only', - module: { - rules: [ - { - test: /\.ts$/, - exclude: /node_modules/, - use: { - loader: 'babel-loader', - options: { - presets: ['@babel/typescript'], - }, - }, - }, - ], - }, +import * as monaco from 'monaco-editor/esm/vs/editor/editor.api'; +import * as xJson from './xjson'; +import * as esql from './esql'; +import * as painless from './painless'; + +export const registerLexerRules = (m: typeof monaco) => { + m.languages.register({ id: xJson.ID }); + m.languages.setMonarchTokensProvider(xJson.ID, xJson.lexerRules); + m.languages.register({ id: painless.ID }); + m.languages.setMonarchTokensProvider(painless.ID, painless.lexerRules); + m.languages.register({ id: esql.ID }); + m.languages.setMonarchTokensProvider(esql.ID, esql.lexerRules); }; diff --git a/packages/kbn-ui-shared-deps/monaco/xjson/lexer_rules/painless.ts b/packages/kbn-monaco/xjson/lexer_rules/painless.ts similarity index 98% rename from packages/kbn-ui-shared-deps/monaco/xjson/lexer_rules/painless.ts rename to packages/kbn-monaco/xjson/lexer_rules/painless.ts index 226255b009bfc6..676eb3134026aa 100644 --- a/packages/kbn-ui-shared-deps/monaco/xjson/lexer_rules/painless.ts +++ b/packages/kbn-monaco/xjson/lexer_rules/painless.ts @@ -17,9 +17,9 @@ * under the License. */ -import { monaco } from '../../'; +import { monaco } from '../../monaco'; -const ID = 'painless'; +export const ID = 'painless'; /** * Extends the default type for a Monarch language so we can use diff --git a/packages/kbn-ui-shared-deps/monaco/xjson/lexer_rules/shared.ts b/packages/kbn-monaco/xjson/lexer_rules/shared.ts similarity index 100% rename from packages/kbn-ui-shared-deps/monaco/xjson/lexer_rules/shared.ts rename to packages/kbn-monaco/xjson/lexer_rules/shared.ts diff --git a/packages/kbn-ui-shared-deps/monaco/xjson/lexer_rules/xjson.ts b/packages/kbn-monaco/xjson/lexer_rules/xjson.ts similarity index 98% rename from packages/kbn-ui-shared-deps/monaco/xjson/lexer_rules/xjson.ts rename to packages/kbn-monaco/xjson/lexer_rules/xjson.ts index 94077c937c24ed..d6fea9e91acfbe 100644 --- a/packages/kbn-ui-shared-deps/monaco/xjson/lexer_rules/xjson.ts +++ b/packages/kbn-monaco/xjson/lexer_rules/xjson.ts @@ -17,13 +17,15 @@ * under the License. */ -import { monaco } from '../../'; +import { monaco } from '../../monaco'; import { ID } from '../constants'; import './painless'; import './esql'; import { globals } from './shared'; +export { ID }; + export const lexerRules: monaco.languages.IMonarchLanguage = { ...(globals as any), diff --git a/packages/kbn-ui-shared-deps/monaco/xjson/webpack.worker.config.js b/packages/kbn-monaco/xjson/webpack.worker.config.js similarity index 93% rename from packages/kbn-ui-shared-deps/monaco/xjson/webpack.worker.config.js rename to packages/kbn-monaco/xjson/webpack.worker.config.js index a560a1c9ef736d..2c89c78fe83653 100644 --- a/packages/kbn-ui-shared-deps/monaco/xjson/webpack.worker.config.js +++ b/packages/kbn-monaco/xjson/webpack.worker.config.js @@ -18,7 +18,6 @@ */ const path = require('path'); -const webpack = require('webpack'); const createConfig = (lang) => ({ mode: 'production', @@ -45,7 +44,6 @@ const createConfig = (lang) => ({ }, ], }, - plugins: [new webpack.BannerPlugin('/* eslint-disable */')], }); module.exports = createConfig('xjson'); diff --git a/packages/kbn-ui-shared-deps/monaco/xjson/worker/index.ts b/packages/kbn-monaco/xjson/worker/index.ts similarity index 100% rename from packages/kbn-ui-shared-deps/monaco/xjson/worker/index.ts rename to packages/kbn-monaco/xjson/worker/index.ts diff --git a/packages/kbn-ui-shared-deps/monaco/xjson/worker/xjson.worker.ts b/packages/kbn-monaco/xjson/worker/xjson.worker.ts similarity index 100% rename from packages/kbn-ui-shared-deps/monaco/xjson/worker/xjson.worker.ts rename to packages/kbn-monaco/xjson/worker/xjson.worker.ts diff --git a/packages/kbn-ui-shared-deps/monaco/xjson/worker/xjson_worker.ts b/packages/kbn-monaco/xjson/worker/xjson_worker.ts similarity index 92% rename from packages/kbn-ui-shared-deps/monaco/xjson/worker/xjson_worker.ts rename to packages/kbn-monaco/xjson/worker/xjson_worker.ts index 94325fb2507d07..5bc0f9fb91ab93 100644 --- a/packages/kbn-ui-shared-deps/monaco/xjson/worker/xjson_worker.ts +++ b/packages/kbn-monaco/xjson/worker/xjson_worker.ts @@ -18,7 +18,7 @@ */ import * as monaco from 'monaco-editor/esm/vs/editor/editor.api'; -import { XJsonGrammar } from '@kbn/langs'; +import { createParser } from '../grammar'; export class XJsonWorker { constructor(private ctx: monaco.worker.IWorkerContext) {} @@ -26,7 +26,7 @@ export class XJsonWorker { async parse() { if (!this.parser) { - this.parser = XJsonGrammar.createParser(); + this.parser = createParser(); } const [model] = this.ctx.getMirrorModels(); return this.parser(model.getValue()); diff --git a/packages/kbn-ui-shared-deps/monaco/xjson/worker_proxy_service.ts b/packages/kbn-monaco/xjson/worker_proxy_service.ts similarity index 93% rename from packages/kbn-ui-shared-deps/monaco/xjson/worker_proxy_service.ts rename to packages/kbn-monaco/xjson/worker_proxy_service.ts index b052b9318a4652..17d6d56e51e598 100644 --- a/packages/kbn-ui-shared-deps/monaco/xjson/worker_proxy_service.ts +++ b/packages/kbn-monaco/xjson/worker_proxy_service.ts @@ -17,14 +17,14 @@ * under the License. */ -import { XJsonGrammar } from '@kbn/langs'; -import { monaco } from '../'; +import { AnnoTypes } from './grammar'; +import { monaco } from '../monaco'; import { XJsonWorker } from './worker'; import { ID } from './constants'; export interface Annotation { name?: string; - type: XJsonGrammar.AnnoTypes; + type: AnnoTypes; text: string; at: number; } diff --git a/packages/kbn-monaco/yarn.lock b/packages/kbn-monaco/yarn.lock new file mode 120000 index 00000000000000..3f82ebc9cdbae3 --- /dev/null +++ b/packages/kbn-monaco/yarn.lock @@ -0,0 +1 @@ +../../yarn.lock \ No newline at end of file diff --git a/packages/kbn-ui-shared-deps/entry.js b/packages/kbn-ui-shared-deps/entry.js index 2b8a4d687439a2..26efd174f4e39a 100644 --- a/packages/kbn-ui-shared-deps/entry.js +++ b/packages/kbn-ui-shared-deps/entry.js @@ -30,7 +30,7 @@ export const KbnI18nReact = require('@kbn/i18n/react'); export const Angular = require('angular'); export const Moment = require('moment'); export const MomentTimezone = require('moment-timezone/moment-timezone'); -export const Monaco = require('./monaco/index.ts'); +export const Monaco = require('./monaco.ts'); export const MonacoBare = require('monaco-editor/esm/vs/editor/editor.api'); export const React = require('react'); export const ReactDom = require('react-dom'); diff --git a/packages/kbn-langs/xjson/index.ts b/packages/kbn-ui-shared-deps/monaco.ts similarity index 93% rename from packages/kbn-langs/xjson/index.ts rename to packages/kbn-ui-shared-deps/monaco.ts index 45ed22c9d32c54..dc57a07055e050 100644 --- a/packages/kbn-langs/xjson/index.ts +++ b/packages/kbn-ui-shared-deps/monaco.ts @@ -17,4 +17,4 @@ * under the License. */ -export { createParser, AnnoTypes } from './grammar'; +export { monaco, XJsonLang } from '@kbn/monaco/monaco'; diff --git a/packages/kbn-ui-shared-deps/monaco/xjson/dist/bundle.amd.worker.js b/packages/kbn-ui-shared-deps/monaco/xjson/dist/bundle.amd.worker.js deleted file mode 100644 index 4e9798e4e77a2a..00000000000000 --- a/packages/kbn-ui-shared-deps/monaco/xjson/dist/bundle.amd.worker.js +++ /dev/null @@ -1 +0,0 @@ -/*! /* eslint-disable * / */!function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=6)}([function(e,t,n){"use strict";(function(e,r){n.d(t,"c",(function(){return m})),n.d(t,"b",(function(){return p})),n.d(t,"a",(function(){return g}));var i=!1,o=!1,s=!1,u=!1,a=!1,l=void 0!==e&&void 0!==e.versions&&void 0!==e.versions.electron&&"renderer"===e.type;if("object"!=typeof navigator||l){if("object"==typeof e){i="win32"===e.platform,o="darwin"===e.platform,s="linux"===e.platform,"en","en";var c=e.env.VSCODE_NLS_CONFIG;if(c)try{var f=JSON.parse(c),h=f.availableLanguages["*"];f.locale,h||"en",f._translationsConfigFile}catch(e){}u=!0}}else{var d=navigator.userAgent;i=d.indexOf("Windows")>=0,o=d.indexOf("Macintosh")>=0,s=d.indexOf("Linux")>=0,a=!0,navigator.language}var m=i,p=a,g="object"==typeof self?self:"object"==typeof r?r:{}}).call(this,n(2),n(1))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t){var n,r,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function u(e){if(n===setTimeout)return setTimeout(e,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(e){n=o}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();var a,l=[],c=!1,f=-1;function h(){c&&a&&(c=!1,a.length?l=a.concat(l):f=-1,l.length&&d())}function d(){if(!c){var e=u(h);c=!0;for(var t=l.length;t;){for(a=l,l=[];++f1)for(var n=1;n=0&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),t))},n(5),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,n(1))},function(e,t,n){(function(e,t){!function(e,n){"use strict";if(!e.setImmediate){var r,i,o,s,u,a=1,l={},c=!1,f=e.document,h=Object.getPrototypeOf&&Object.getPrototypeOf(e);h=h&&h.setTimeout?h:e,"[object process]"==={}.toString.call(e.process)?r=function(e){t.nextTick((function(){m(e)}))}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=n,t}}()?e.MessageChannel?((o=new MessageChannel).port1.onmessage=function(e){m(e.data)},r=function(e){o.port2.postMessage(e)}):f&&"onreadystatechange"in f.createElement("script")?(i=f.documentElement,r=function(e){var t=f.createElement("script");t.onreadystatechange=function(){m(e),t.onreadystatechange=null,i.removeChild(t),t=null},i.appendChild(t)}):r=function(e){setTimeout(m,0,e)}:(s="setImmediate$"+Math.random()+"$",u=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(s)&&m(+t.data.slice(s.length))},e.addEventListener?e.addEventListener("message",u,!1):e.attachEvent("onmessage",u),r=function(t){e.postMessage(s+t,"*")}),h.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;nr?e[a]=o[u++]:u>i?e[a]=o[s++]:t(o[u],o[s])<0?e[a]=o[u++]:e[a]=o[s++]}(t,n,r,s,i,o)}(e,t,0,e.length-1,[]),e}var _=function(){function e(e,t,n,r){this.originalStart=e,this.originalLength=t,this.modifiedStart=n,this.modifiedLength=r}return e.prototype.getOriginalEnd=function(){return this.originalStart+this.originalLength},e.prototype.getModifiedEnd=function(){return this.modifiedStart+this.modifiedLength},e}();function v(e){return{getLength:function(){return e.length},getElementAtIndex:function(t){return e.charCodeAt(t)}}}function y(e,t,n){return new E(v(e),v(t)).ComputeDiff(n)}var C,b=function(){function e(){}return e.Assert=function(e,t){if(!e)throw new Error(t)},e}(),L=function(){function e(){}return e.Copy=function(e,t,n,r,i){for(var o=0;o0||this.m_modifiedCount>0)&&this.m_changes.push(new _(this.m_originalStart,this.m_originalCount,this.m_modifiedStart,this.m_modifiedCount)),this.m_originalCount=0,this.m_modifiedCount=0,this.m_originalStart=Number.MAX_VALUE,this.m_modifiedStart=Number.MAX_VALUE},e.prototype.AddOriginalElement=function(e,t){this.m_originalStart=Math.min(this.m_originalStart,e),this.m_modifiedStart=Math.min(this.m_modifiedStart,t),this.m_originalCount++},e.prototype.AddModifiedElement=function(e,t){this.m_originalStart=Math.min(this.m_originalStart,e),this.m_modifiedStart=Math.min(this.m_modifiedStart,t),this.m_modifiedCount++},e.prototype.getChanges=function(){return(this.m_originalCount>0||this.m_modifiedCount>0)&&this.MarkNextChange(),this.m_changes},e.prototype.getReverseChanges=function(){return(this.m_originalCount>0||this.m_modifiedCount>0)&&this.MarkNextChange(),this.m_changes.reverse(),this.m_changes},e}(),E=function(){function e(e,t,n){void 0===n&&(n=null),this.OriginalSequence=e,this.ModifiedSequence=t,this.ContinueProcessingPredicate=n,this.m_forwardHistory=[],this.m_reverseHistory=[]}return e.prototype.ElementsAreEqual=function(e,t){return this.OriginalSequence.getElementAtIndex(e)===this.ModifiedSequence.getElementAtIndex(t)},e.prototype.OriginalElementsAreEqual=function(e,t){return this.OriginalSequence.getElementAtIndex(e)===this.OriginalSequence.getElementAtIndex(t)},e.prototype.ModifiedElementsAreEqual=function(e,t){return this.ModifiedSequence.getElementAtIndex(e)===this.ModifiedSequence.getElementAtIndex(t)},e.prototype.ComputeDiff=function(e){return this._ComputeDiff(0,this.OriginalSequence.getLength()-1,0,this.ModifiedSequence.getLength()-1,e)},e.prototype._ComputeDiff=function(e,t,n,r,i){var o=this.ComputeDiffRecursive(e,t,n,r,[!1]);return i?this.PrettifyChanges(o):o},e.prototype.ComputeDiffRecursive=function(e,t,n,r,i){for(i[0]=!1;e<=t&&n<=r&&this.ElementsAreEqual(e,n);)e++,n++;for(;t>=e&&r>=n&&this.ElementsAreEqual(t,r);)t--,r--;if(e>t||n>r){var o=void 0;return n<=r?(b.Assert(e===t+1,"originalStart should only be one more than originalEnd"),o=[new _(e,0,n,r-n+1)]):e<=t?(b.Assert(n===r+1,"modifiedStart should only be one more than modifiedEnd"),o=[new _(e,t-e+1,n,0)]):(b.Assert(e===t+1,"originalStart should only be one more than originalEnd"),b.Assert(n===r+1,"modifiedStart should only be one more than modifiedEnd"),o=[]),o}var s=[0],u=[0],a=this.ComputeRecursionPoint(e,t,n,r,s,u,i),l=s[0],c=u[0];if(null!==a)return a;if(!i[0]){var f=this.ComputeDiffRecursive(e,l,n,c,i),h=[];return h=i[0]?[new _(l+1,t-(l+1)+1,c+1,r-(c+1)+1)]:this.ComputeDiffRecursive(l+1,t,c+1,r,i),this.ConcatenateChanges(f,h)}return[new _(e,t-e+1,n,r-n+1)]},e.prototype.WALKTRACE=function(e,t,n,r,i,o,s,u,a,l,c,f,h,d,m,p,g,v){var y,C,b=null,L=new N,E=t,S=n,w=h[0]-p[0]-r,A=Number.MIN_VALUE,M=this.m_forwardHistory.length-1;do{(C=w+e)===E||C=0&&(e=(a=this.m_forwardHistory[M])[0],E=1,S=a.length-1)}while(--M>=-1);if(y=L.getReverseChanges(),v[0]){var T=h[0]+1,P=p[0]+1;if(null!==y&&y.length>0){var O=y[y.length-1];T=Math.max(T,O.getOriginalEnd()),P=Math.max(P,O.getModifiedEnd())}b=[new _(T,f-T+1,P,m-P+1)]}else{L=new N,E=o,S=s,w=h[0]-p[0]-u,A=Number.MAX_VALUE,M=g?this.m_reverseHistory.length-1:this.m_reverseHistory.length-2;do{(C=w+i)===E||C=l[C+1]?(d=(c=l[C+1]-1)-w-u,c>A&&L.MarkNextChange(),A=c+1,L.AddOriginalElement(c+1,d+1),w=C+1-i):(d=(c=l[C-1])-w-u,c>A&&L.MarkNextChange(),A=c,L.AddModifiedElement(c+1,d+1),w=C-1-i),M>=0&&(i=(l=this.m_reverseHistory[M])[0],E=1,S=l.length-1)}while(--M>=-1);b=L.getChanges()}return this.ConcatenateChanges(y,b)},e.prototype.ComputeRecursionPoint=function(e,t,n,r,i,o,s){var u,a=0,l=0,c=0,f=0,h=0,d=0;e--,n--,i[0]=0,o[0]=0,this.m_forwardHistory=[],this.m_reverseHistory=[];var m,p,g=t-e+(r-n),v=g+1,y=new Array(v),C=new Array(v),b=r-n,N=t-e,E=e-n,S=t-r,w=(N-b)%2==0;for(y[b]=e,C[N]=t,s[0]=!1,u=1;u<=g/2+1;u++){var A=0,M=0;for(c=this.ClipDiagonalBound(b-u,u,b,v),f=this.ClipDiagonalBound(b+u,u,b,v),m=c;m<=f;m+=2){for(l=(a=m===c||mA+M&&(A=a,M=l),!w&&Math.abs(m-N)<=u-1&&a>=C[m])return i[0]=a,o[0]=l,p<=C[m]&&u<=1448?this.WALKTRACE(b,c,f,E,N,h,d,S,y,C,a,t,i,l,r,o,w,s):null}var T=(A-e+(M-n)-u)/2;if(null!==this.ContinueProcessingPredicate&&!this.ContinueProcessingPredicate(A,this.OriginalSequence,T))return s[0]=!0,i[0]=A,o[0]=M,T>0&&u<=1448?this.WALKTRACE(b,c,f,E,N,h,d,S,y,C,a,t,i,l,r,o,w,s):(e++,n++,[new _(e,t-e+1,n,r-n+1)]);for(h=this.ClipDiagonalBound(N-u,u,N,v),d=this.ClipDiagonalBound(N+u,u,N,v),m=h;m<=d;m+=2){for(l=(a=m===h||m=C[m+1]?C[m+1]-1:C[m-1])-(m-N)-S,p=a;a>e&&l>n&&this.ElementsAreEqual(a,l);)a--,l--;if(C[m]=a,w&&Math.abs(m-b)<=u&&a<=y[m])return i[0]=a,o[0]=l,p>=y[m]&&u<=1448?this.WALKTRACE(b,c,f,E,N,h,d,S,y,C,a,t,i,l,r,o,w,s):null}if(u<=1447){var P=new Array(f-c+2);P[0]=b-c+1,L.Copy(y,c,P,1,f-c+1),this.m_forwardHistory.push(P),(P=new Array(d-h+2))[0]=N-h+1,L.Copy(C,h,P,1,d-h+1),this.m_reverseHistory.push(P)}}return this.WALKTRACE(b,c,f,E,N,h,d,S,y,C,a,t,i,l,r,o,w,s)},e.prototype.PrettifyChanges=function(e){for(var t=0;t0,s=n.modifiedLength>0;n.originalStart+n.originalLength=0;t--){n=e[t],r=0,i=0;if(t>0){var a=e[t-1];a.originalLength>0&&(r=a.originalStart+a.originalLength),a.modifiedLength>0&&(i=a.modifiedStart+a.modifiedLength)}o=n.originalLength>0,s=n.modifiedLength>0;for(var l=0,c=this._boundaryScore(n.originalStart,n.originalLength,n.modifiedStart,n.modifiedLength),f=1;;f++){var h=n.originalStart-f,d=n.modifiedStart-f;if(hc&&(c=m,l=f)}n.originalStart-=l,n.modifiedStart-=l}return e},e.prototype._OriginalIsBoundary=function(e){if(e<=0||e>=this.OriginalSequence.getLength()-1)return!0;var t=this.OriginalSequence.getElementAtIndex(e);return"string"==typeof t&&/^\s*$/.test(t)},e.prototype._OriginalRegionIsBoundary=function(e,t){if(this._OriginalIsBoundary(e)||this._OriginalIsBoundary(e-1))return!0;if(t>0){var n=e+t;if(this._OriginalIsBoundary(n-1)||this._OriginalIsBoundary(n))return!0}return!1},e.prototype._ModifiedIsBoundary=function(e){if(e<=0||e>=this.ModifiedSequence.getLength()-1)return!0;var t=this.ModifiedSequence.getElementAtIndex(e);return"string"==typeof t&&/^\s*$/.test(t)},e.prototype._ModifiedRegionIsBoundary=function(e,t){if(this._ModifiedIsBoundary(e)||this._ModifiedIsBoundary(e-1))return!0;if(t>0){var n=e+t;if(this._ModifiedIsBoundary(n-1)||this._ModifiedIsBoundary(n))return!0}return!1},e.prototype._boundaryScore=function(e,t,n,r){return(this._OriginalRegionIsBoundary(e,t)?1:0)+(this._ModifiedRegionIsBoundary(n,r)?1:0)},e.prototype.ConcatenateChanges=function(e,t){var n=[];if(0===e.length||0===t.length)return t.length>0?t:e;if(this.ChangesOverlap(e[e.length-1],t[0],n)){var r=new Array(e.length+t.length-1);return L.Copy(e,0,r,0,e.length-1),r[e.length-1]=n[0],L.Copy(t,1,r,e.length,t.length-1),r}r=new Array(e.length+t.length);return L.Copy(e,0,r,0,e.length),L.Copy(t,0,r,e.length,t.length),r},e.prototype.ChangesOverlap=function(e,t,n){if(b.Assert(e.originalStart<=t.originalStart,"Left change is not less than or equal to right change"),b.Assert(e.modifiedStart<=t.modifiedStart,"Left change is not less than or equal to right change"),e.originalStart+e.originalLength>=t.originalStart||e.modifiedStart+e.modifiedLength>=t.modifiedStart){var r=e.originalStart,i=e.originalLength,o=e.modifiedStart,s=e.modifiedLength;return e.originalStart+e.originalLength>=t.originalStart&&(i=t.originalStart+t.originalLength-e.originalStart),e.modifiedStart+e.modifiedLength>=t.modifiedStart&&(s=t.modifiedStart+t.modifiedLength-e.modifiedStart),n[0]=new _(r,i,o,s),!0}return n[0]=null,!1},e.prototype.ClipDiagonalBound=function(e,t,n,r){if(e>=0&&e=n?w:{done:!1,value:e[t++]}}}},e.from=function(t){return t?Array.isArray(t)?e.fromArray(t):t:e.empty()},e.map=function(e,t){return{next:function(){var n=e.next();return n.done?w:{done:!1,value:t(n.value)}}}},e.filter=function(e,t){return{next:function(){for(;;){var n=e.next();if(n.done)return w;if(t(n.value))return{done:!1,value:n.value}}}}},e.forEach=n,e.collect=function(e){var t=[];return n(e,(function(e){return t.push(e)})),t}}(C||(C={}));(function(e){function t(t,n,r,i){return void 0===n&&(n=0),void 0===r&&(r=t.length),void 0===i&&(i=n-1),e.call(this,t,n,r,i)||this}S(t,e),t.prototype.current=function(){return e.prototype.current.call(this)},t.prototype.previous=function(){return this.index=Math.max(this.index-1,this.start-1),this.current()},t.prototype.first=function(){return this.index=this.start,this.current()},t.prototype.last=function(){return this.index=this.end-1,this.current()},t.prototype.parent=function(){return null}})(function(){function e(e,t,n,r){void 0===t&&(t=0),void 0===n&&(n=e.length),void 0===r&&(r=t-1),this.items=e,this.start=t,this.end=n,this.index=r}return e.prototype.next=function(){return this.index=Math.min(this.index+1,this.end),this.current()},e.prototype.current=function(){return this.index===this.start-1||this.index===this.end?null:this.items[this.index]},e}()),function(){function e(e,t){this.iterator=e,this.fn=t}e.prototype.next=function(){return this.fn(this.iterator.next())}}();var A,M=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),T=/^\w[\w\d+.-]*$/,P=/^\//,O=/^\/\//;var x="",I="/",R=/^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,k=function(){function e(e,t,n,r,i,o){void 0===o&&(o=!1),"object"==typeof e?(this.scheme=e.scheme||x,this.authority=e.authority||x,this.path=e.path||x,this.query=e.query||x,this.fragment=e.fragment||x):(this.scheme=e||x,this.authority=t||x,this.path=function(e,t){switch(e){case"https":case"http":case"file":t?t[0]!==I&&(t=I+t):t=I}return t}(this.scheme,n||x),this.query=r||x,this.fragment=i||x,function(e,t){if(!e.scheme)throw new Error('[UriError]: Scheme is missing: {scheme: "", authority: "'+e.authority+'", path: "'+e.path+'", query: "'+e.query+'", fragment: "'+e.fragment+'"}');if(e.scheme&&!T.test(e.scheme))throw new Error("[UriError]: Scheme contains illegal characters.");if(e.path)if(e.authority){if(!P.test(e.path))throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character')}else if(O.test(e.path))throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")')}(this))}return e.isUri=function(t){return t instanceof e||!!t&&("string"==typeof t.authority&&"string"==typeof t.fragment&&"string"==typeof t.path&&"string"==typeof t.query&&"string"==typeof t.scheme&&"function"==typeof t.fsPath&&"function"==typeof t.with&&"function"==typeof t.toString)},Object.defineProperty(e.prototype,"fsPath",{get:function(){return q(this)},enumerable:!0,configurable:!0}),e.prototype.with=function(e){if(!e)return this;var t=e.scheme,n=e.authority,r=e.path,i=e.query,o=e.fragment;return void 0===t?t=this.scheme:null===t&&(t=x),void 0===n?n=this.authority:null===n&&(n=x),void 0===r?r=this.path:null===r&&(r=x),void 0===i?i=this.query:null===i&&(i=x),void 0===o?o=this.fragment:null===o&&(o=x),t===this.scheme&&n===this.authority&&r===this.path&&i===this.query&&o===this.fragment?this:new U(t,n,r,i,o)},e.parse=function(e,t){void 0===t&&(t=!1);var n=R.exec(e);return n?new U(n[2]||x,decodeURIComponent(n[4]||x),decodeURIComponent(n[5]||x),decodeURIComponent(n[7]||x),decodeURIComponent(n[9]||x),t):new U(x,x,x,x,x)},e.file=function(e){var t=x;if(c.c&&(e=e.replace(/\\/g,I)),e[0]===I&&e[1]===I){var n=e.indexOf(I,2);-1===n?(t=e.substring(2),e=I):(t=e.substring(2,n),e=e.substring(n)||I)}return new U("file",t,e,x,x)},e.from=function(e){return new U(e.scheme,e.authority,e.path,e.query,e.fragment)},e.prototype.toString=function(e){return void 0===e&&(e=!1),V(this,e)},e.prototype.toJSON=function(){return this},e.revive=function(t){if(t){if(t instanceof e)return t;var n=new U(t);return n._fsPath=t.fsPath,n._formatted=t.external,n}return t},e}(),U=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._formatted=null,t._fsPath=null,t}return M(t,e),Object.defineProperty(t.prototype,"fsPath",{get:function(){return this._fsPath||(this._fsPath=q(this)),this._fsPath},enumerable:!0,configurable:!0}),t.prototype.toString=function(e){return void 0===e&&(e=!1),e?V(this,!0):(this._formatted||(this._formatted=V(this,!1)),this._formatted)},t.prototype.toJSON=function(){var e={$mid:1};return this._fsPath&&(e.fsPath=this._fsPath),this._formatted&&(e.external=this._formatted),this.path&&(e.path=this.path),this.scheme&&(e.scheme=this.scheme),this.authority&&(e.authority=this.authority),this.query&&(e.query=this.query),this.fragment&&(e.fragment=this.fragment),e},t}(k),F=((A={})[58]="%3A",A[47]="%2F",A[63]="%3F",A[35]="%23",A[91]="%5B",A[93]="%5D",A[64]="%40",A[33]="%21",A[36]="%24",A[38]="%26",A[39]="%27",A[40]="%28",A[41]="%29",A[42]="%2A",A[43]="%2B",A[44]="%2C",A[59]="%3B",A[61]="%3D",A[32]="%20",A);function D(e,t){for(var n=void 0,r=-1,i=0;i=97&&o<=122||o>=65&&o<=90||o>=48&&o<=57||45===o||46===o||95===o||126===o||t&&47===o)-1!==r&&(n+=encodeURIComponent(e.substring(r,i)),r=-1),void 0!==n&&(n+=e.charAt(i));else{void 0===n&&(n=e.substr(0,i));var s=F[o];void 0!==s?(-1!==r&&(n+=encodeURIComponent(e.substring(r,i)),r=-1),n+=s):-1===r&&(r=i)}}return-1!==r&&(n+=encodeURIComponent(e.substring(r))),void 0!==n?n:e}function K(e){for(var t=void 0,n=0;n1&&"file"===e.scheme?"//"+e.authority+e.path:47===e.path.charCodeAt(0)&&(e.path.charCodeAt(1)>=65&&e.path.charCodeAt(1)<=90||e.path.charCodeAt(1)>=97&&e.path.charCodeAt(1)<=122)&&58===e.path.charCodeAt(2)?e.path[1].toLowerCase()+e.path.substr(2):e.path,c.c&&(t=t.replace(/\//g,"\\")),t}function V(e,t){var n=t?K:D,r="",i=e.scheme,o=e.authority,s=e.path,u=e.query,a=e.fragment;if(i&&(r+=i,r+=":"),(o||"file"===i)&&(r+=I,r+=I),o){var l=o.indexOf("@");if(-1!==l){var c=o.substr(0,l);o=o.substr(l+1),-1===(l=c.indexOf(":"))?r+=n(c,!1):(r+=n(c.substr(0,l),!1),r+=":",r+=n(c.substr(l+1),!1)),r+="@"}-1===(l=(o=o.toLowerCase()).indexOf(":"))?r+=n(o,!1):(r+=n(o.substr(0,l),!1),r+=o.substr(l))}if(s){if(s.length>=3&&47===s.charCodeAt(0)&&58===s.charCodeAt(2))(f=s.charCodeAt(1))>=65&&f<=90&&(s="/"+String.fromCharCode(f+32)+":"+s.substr(3));else if(s.length>=2&&58===s.charCodeAt(1)){var f;(f=s.charCodeAt(0))>=65&&f<=90&&(s=String.fromCharCode(f+32)+":"+s.substr(2))}r+=n(s,!0)}return u&&(r+="?",r+=n(u,!1)),a&&(r+="#",r+=t?a:D(a,!1)),r}var B=function(){function e(e,t){this.lineNumber=e,this.column=t}return e.prototype.with=function(t,n){return void 0===t&&(t=this.lineNumber),void 0===n&&(n=this.column),t===this.lineNumber&&n===this.column?this:new e(t,n)},e.prototype.delta=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=0),this.with(this.lineNumber+e,this.column+t)},e.prototype.equals=function(t){return e.equals(this,t)},e.equals=function(e,t){return!e&&!t||!!e&&!!t&&e.lineNumber===t.lineNumber&&e.column===t.column},e.prototype.isBefore=function(t){return e.isBefore(this,t)},e.isBefore=function(e,t){return e.lineNumbern||e===n&&t>r?(this.startLineNumber=n,this.startColumn=r,this.endLineNumber=e,this.endColumn=t):(this.startLineNumber=e,this.startColumn=t,this.endLineNumber=n,this.endColumn=r)}return e.prototype.isEmpty=function(){return e.isEmpty(this)},e.isEmpty=function(e){return e.startLineNumber===e.endLineNumber&&e.startColumn===e.endColumn},e.prototype.containsPosition=function(t){return e.containsPosition(this,t)},e.containsPosition=function(e,t){return!(t.lineNumbere.endLineNumber)&&(!(t.lineNumber===e.startLineNumber&&t.columne.endColumn))},e.prototype.containsRange=function(t){return e.containsRange(this,t)},e.containsRange=function(e,t){return!(t.startLineNumbere.endLineNumber||t.endLineNumber>e.endLineNumber)&&(!(t.startLineNumber===e.startLineNumber&&t.startColumne.endColumn)))},e.prototype.plusRange=function(t){return e.plusRange(this,t)},e.plusRange=function(t,n){var r,i,o,s;return n.startLineNumbert.endLineNumber?(o=n.endLineNumber,s=n.endColumn):n.endLineNumber===t.endLineNumber?(o=n.endLineNumber,s=Math.max(n.endColumn,t.endColumn)):(o=t.endLineNumber,s=t.endColumn),new e(r,i,o,s)},e.prototype.intersectRanges=function(t){return e.intersectRanges(this,t)},e.intersectRanges=function(t,n){var r=t.startLineNumber,i=t.startColumn,o=t.endLineNumber,s=t.endColumn,u=n.startLineNumber,a=n.startColumn,l=n.endLineNumber,c=n.endColumn;return rl?(o=l,s=c):o===l&&(s=Math.min(s,c)),r>o?null:r===o&&i>s?null:new e(r,i,o,s)},e.prototype.equalsRange=function(t){return e.equalsRange(this,t)},e.equalsRange=function(e,t){return!!e&&!!t&&e.startLineNumber===t.startLineNumber&&e.startColumn===t.startColumn&&e.endLineNumber===t.endLineNumber&&e.endColumn===t.endColumn},e.prototype.getEndPosition=function(){return new B(this.endLineNumber,this.endColumn)},e.prototype.getStartPosition=function(){return new B(this.startLineNumber,this.startColumn)},e.prototype.toString=function(){return"["+this.startLineNumber+","+this.startColumn+" -> "+this.endLineNumber+","+this.endColumn+"]"},e.prototype.setEndPosition=function(t,n){return new e(this.startLineNumber,this.startColumn,t,n)},e.prototype.setStartPosition=function(t,n){return new e(t,n,this.endLineNumber,this.endColumn)},e.prototype.collapseToStart=function(){return e.collapseToStart(this)},e.collapseToStart=function(t){return new e(t.startLineNumber,t.startColumn,t.startLineNumber,t.startColumn)},e.fromPositions=function(t,n){return void 0===n&&(n=t),new e(t.lineNumber,t.column,n.lineNumber,n.column)},e.lift=function(t){return t?new e(t.startLineNumber,t.startColumn,t.endLineNumber,t.endColumn):null},e.isIRange=function(e){return e&&"number"==typeof e.startLineNumber&&"number"==typeof e.startColumn&&"number"==typeof e.endLineNumber&&"number"==typeof e.endColumn},e.areIntersectingOrTouching=function(e,t){return!(e.endLineNumbere.startLineNumber},e}();String.fromCharCode(65279);function Y(e,t,n,r){return new E(e,t,n).ComputeDiff(r)}var W=function(){function e(t){for(var n=[],r=[],i=0,o=t.length;i=0;n--){var r=e.charCodeAt(n);if(32!==r&&9!==r)return n}return-1}(e);return-1===n?t:n+2},e.prototype.getCharSequence=function(e,t,n){for(var r=[],i=[],o=[],s=0,u=t;u<=n;u++)for(var a=this._lines[u],l=e?this._startColumns[u]:1,c=e?this._endColumns[u]:a.length+1,f=l;f1&&m>1;){if(f.charCodeAt(d-2)!==h.charCodeAt(m-2))break;d--,m--}(d>1||m>1)&&this._pushTrimWhitespaceCharChange(i,o+1,1,d,s+1,1,m);for(var p=W._getLastNonBlankColumn(f,1),g=W._getLastNonBlankColumn(h,1),_=f.length+1,v=h.length+1;p<_&&g255?255:0|e}function J(e){return e<0?0:e>4294967295?4294967295:0|e}var Z=function(e,t){this.index=e,this.remainder=t},ee=function(){function e(e){this.values=e,this.prefixSum=new Uint32Array(e.length),this.prefixSumValidIndex=new Int32Array(1),this.prefixSumValidIndex[0]=-1}return e.prototype.getCount=function(){return this.values.length},e.prototype.insertValues=function(e,t){e=J(e);var n=this.values,r=this.prefixSum,i=t.length;return 0!==i&&(this.values=new Uint32Array(n.length+i),this.values.set(n.subarray(0,e),0),this.values.set(n.subarray(e),e+i),this.values.set(t,e),e-1=0&&this.prefixSum.set(r.subarray(0,this.prefixSumValidIndex[0]+1)),!0)},e.prototype.changeValue=function(e,t){return e=J(e),t=J(t),this.values[e]!==t&&(this.values[e]=t,e-1=n.length)return!1;var i=n.length-e;return t>=i&&(t=i),0!==t&&(this.values=new Uint32Array(n.length-t),this.values.set(n.subarray(0,e),0),this.values.set(n.subarray(e+t),e),this.prefixSum=new Uint32Array(this.values.length),e-1=0&&this.prefixSum.set(r.subarray(0,this.prefixSumValidIndex[0]+1)),!0)},e.prototype.getTotalValue=function(){return 0===this.values.length?0:this._getAccumulatedValue(this.values.length-1)},e.prototype.getAccumulatedValue=function(e){return e<0?0:(e=J(e),this._getAccumulatedValue(e))},e.prototype._getAccumulatedValue=function(e){if(e<=this.prefixSumValidIndex[0])return this.prefixSum[e];var t=this.prefixSumValidIndex[0]+1;0===t&&(this.prefixSum[0]=this.values[0],t++),e>=this.values.length&&(e=this.values.length-1);for(var n=t;n<=e;n++)this.prefixSum[n]=this.prefixSum[n-1]+this.values[n];return this.prefixSumValidIndex[0]=Math.max(this.prefixSumValidIndex[0],e),this.prefixSum[e]},e.prototype.getIndexOf=function(e){e=Math.floor(e),this.getTotalValue();for(var t=0,n=this.values.length-1,r=0,i=0,o=0;t<=n;)if(r=t+(n-t)/2|0,e<(o=(i=this.prefixSum[r])-this.values[r]))n=r-1;else{if(!(e>=i))break;t=r+1}return new Z(r,e-o)},e}(),te=(function(){function e(e){this._cacheAccumulatedValueStart=0,this._cache=null,this._actual=new ee(e),this._bustCache()}e.prototype._bustCache=function(){this._cacheAccumulatedValueStart=0,this._cache=null},e.prototype.insertValues=function(e,t){this._actual.insertValues(e,t)&&this._bustCache()},e.prototype.changeValue=function(e,t){this._actual.changeValue(e,t)&&this._bustCache()},e.prototype.removeValues=function(e,t){this._actual.removeValues(e,t)&&this._bustCache()},e.prototype.getTotalValue=function(){return this._actual.getTotalValue()},e.prototype.getAccumulatedValue=function(e){return this._actual.getAccumulatedValue(e)},e.prototype.getIndexOf=function(e){if(e=Math.floor(e),null!==this._cache){var t=e-this._cacheAccumulatedValueStart;if(t>=0&&t/?".length;n++){var r="`~!@#$%^&*()-=+[{]}\\|;:'\",.<>/?"[n];e.indexOf(r)>=0||(t+="\\"+r)}return t+="\\s]+)",new RegExp(t,"g")}();var re=function(){function e(t){var n=$(t);this._defaultValue=n,this._asciiMap=e._createAsciiMap(n),this._map=new Map}return e._createAsciiMap=function(e){for(var t=new Uint8Array(256),n=0;n<256;n++)t[n]=e;return t},e.prototype.set=function(e,t){var n=$(t);e>=0&&e<256?this._asciiMap[e]=n:this._map.set(e,n)},e.prototype.get=function(e){return e>=0&&e<256?this._asciiMap[e]:this._map.get(e)||this._defaultValue},e}(),ie=(function(){function e(){this._actual=new re(0)}e.prototype.add=function(e){this._actual.set(e,1)},e.prototype.has=function(e){return 1===this._actual.get(e)}}(),function(){function e(e){for(var t=0,n=0,r=0,i=e.length;rt&&(t=l),s>n&&(n=s),(c=o[2])>n&&(n=c)}t++,n++;var u=new X(n,t,0);for(r=0,i=e.length;r=this._maxCharCode?0:this._states.get(e,t)},e}()),oe=null;var se=null;var ue=function(){function e(){}return e._createLink=function(e,t,n,r,i){var o=i-1;do{var s=t.charCodeAt(o);if(2!==e.get(s))break;o--}while(o>r);if(r>0){var u=t.charCodeAt(r-1),a=t.charCodeAt(o);(40===u&&41===a||91===u&&93===a||123===u&&125===a)&&o--}return{range:{startLineNumber:n,startColumn:r+1,endLineNumber:n,endColumn:o+2},url:t.substring(r,o+1)}},e.computeLinks=function(t,n){void 0===n&&(null===oe&&(oe=new ie([[1,104,2],[1,72,2],[1,102,6],[1,70,6],[2,116,3],[2,84,3],[3,116,4],[3,84,4],[4,112,5],[4,80,5],[5,115,9],[5,83,9],[5,58,10],[6,105,7],[6,73,7],[7,108,8],[7,76,8],[8,101,9],[8,69,9],[9,58,10],[10,47,11],[11,47,12]])),n=oe);for(var r=function(){if(null===se){se=new re(0);for(var e=0;e<" \t<>'\"、。。、,.:;?!@#$%&*‘“〈《「『【〔([{「」}])〕】』」》〉”’`~…".length;e++)se.set(" \t<>'\"、。。、,.:;?!@#$%&*‘“〈《「『【〔([{「」}])〕】』」》〉”’`~…".charCodeAt(e),1);for(e=0;e<".,;".length;e++)se.set(".,;".charCodeAt(e),2)}return se}(),i=[],o=1,s=t.getLineCount();o<=s;o++){for(var u=t.getLineContent(o),a=u.length,l=0,c=0,f=0,h=1,d=!1,m=!1,p=!1;l=0?((r+=n?1:-1)<0?r=e.length-1:r%=e.length,e[r]):null},e.INSTANCE=new e,e}();n(3);var le,ce=function(){function e(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}return e.Undefined=new e(void 0),e}(),fe=function(){function e(){this._first=ce.Undefined,this._last=ce.Undefined,this._size=0}return Object.defineProperty(e.prototype,"size",{get:function(){return this._size},enumerable:!0,configurable:!0}),e.prototype.isEmpty=function(){return this._first===ce.Undefined},e.prototype.clear=function(){this._first=ce.Undefined,this._last=ce.Undefined,this._size=0},e.prototype.unshift=function(e){return this._insert(e,!1)},e.prototype.push=function(e){return this._insert(e,!0)},e.prototype._insert=function(e,t){var n=this,r=new ce(e);if(this._first===ce.Undefined)this._first=r,this._last=r;else if(t){var i=this._last;this._last=r,r.prev=i,i.next=r}else{var o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;var s=!1;return function(){s||(s=!0,n._remove(r))}},e.prototype.shift=function(){if(this._first!==ce.Undefined){var e=this._first.element;return this._remove(this._first),e}},e.prototype._remove=function(e){if(e.prev!==ce.Undefined&&e.next!==ce.Undefined){var t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===ce.Undefined&&e.next===ce.Undefined?(this._first=ce.Undefined,this._last=ce.Undefined):e.next===ce.Undefined?(this._last=this._last.prev,this._last.next=ce.Undefined):e.prev===ce.Undefined&&(this._first=this._first.next,this._first.prev=ce.Undefined);this._size-=1},e.prototype.iterator=function(){var e,t=this._first;return{next:function(){return t===ce.Undefined?w:(e?e.value=t.element:e={done:!1,value:t.element},t=t.next,e)}}},e.prototype.toArray=function(){for(var e=[],t=this._first;t!==ce.Undefined;t=t.next)e.push(t.element);return e},e}(),he=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();!function(e){var t={dispose:function(){}};function n(e){return function(t,n,r){void 0===n&&(n=null);var i,o=!1;return i=e((function(e){if(!o)return i?i.dispose():o=!0,t.call(n,e)}),null,r),o&&i.dispose(),i}}function r(e,t){return u((function(n,r,i){return void 0===r&&(r=null),e((function(e){return n.call(r,t(e))}),null,i)}))}function i(e,t){return u((function(n,r,i){return void 0===r&&(r=null),e((function(e){t(e),n.call(r,e)}),null,i)}))}function o(e,t){return u((function(n,r,i){return void 0===r&&(r=null),e((function(e){return t(e)&&n.call(r,e)}),null,i)}))}function s(e,t,n){var i=n;return r(e,(function(e){return i=t(i,e)}))}function u(e){var t,n=new pe({onFirstListenerAdd:function(){t=e(n.fire,n)},onLastListenerRemove:function(){t.dispose()}});return n.event}function l(e){var t,n=!0;return o(e,(function(e){var r=n||e!==t;return n=!1,t=e,r}))}e.None=function(){return t},e.once=n,e.map=r,e.forEach=i,e.filter=o,e.signal=function(e){return e},e.any=function(){for(var e=[],t=0;t1)&&l.fire(e),a=0}),n)}))},onLastListenerRemove:function(){o.dispose()}});return l.event},e.stopwatch=function(e){var t=(new Date).getTime();return r(n(e),(function(e){return(new Date).getTime()-t}))},e.latch=l,e.buffer=function(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=[]);var r=n.slice(),i=e((function(e){r?r.push(e):s.fire(e)})),o=function(){r&&r.forEach((function(e){return s.fire(e)})),r=null},s=new pe({onFirstListenerAdd:function(){i||(i=e((function(e){return s.fire(e)})))},onFirstListenerDidAdd:function(){r&&(t?setTimeout(o):o())},onLastListenerRemove:function(){i&&i.dispose(),i=null}});return s.event};var c=function(){function e(e){this.event=e}return e.prototype.map=function(t){return new e(r(this.event,t))},e.prototype.forEach=function(t){return new e(i(this.event,t))},e.prototype.filter=function(t){return new e(o(this.event,t))},e.prototype.reduce=function(t,n){return new e(s(this.event,t,n))},e.prototype.latch=function(){return new e(l(this.event))},e.prototype.on=function(e,t,n){return this.event(e,t,n)},e.prototype.once=function(e,t,r){return n(this.event)(e,t,r)},e}();e.chain=function(e){return new c(e)},e.fromNodeEventEmitter=function(e,t,n){void 0===n&&(n=function(e){return e});var r=function(){for(var e=[],t=0;t0;){var r=this._deliveryQueue.shift(),o=r[0],s=r[1];try{"function"==typeof o?o.call(void 0,s):o[0].call(o[1],s)}catch(n){i(n)}}}},e.prototype.dispose=function(){this._listeners&&this._listeners.clear(),this._deliveryQueue&&this._deliveryQueue.clear(),this._leakageMon&&this._leakageMon.dispose(),this._disposed=!0},e._noop=function(){},e}(),ge=(function(e){function t(t){var n=e.call(this,t)||this;return n._isPaused=0,n._eventQueue=new fe,n._mergeFn=t&&t.merge,n}he(t,e),t.prototype.pause=function(){this._isPaused++},t.prototype.resume=function(){if(0!==this._isPaused&&0==--this._isPaused)if(this._mergeFn){var t=this._eventQueue.toArray();this._eventQueue.clear(),e.prototype.fire.call(this,this._mergeFn(t))}else for(;!this._isPaused&&0!==this._eventQueue.size;)e.prototype.fire.call(this,this._eventQueue.shift())},t.prototype.fire=function(t){this._listeners&&(0!==this._isPaused?this._eventQueue.push(t):e.prototype.fire.call(this,t))}}(pe),function(){function e(){var e=this;this.hasListeners=!1,this.events=[],this.emitter=new pe({onFirstListenerAdd:function(){return e.onFirstListenerAdd()},onLastListenerRemove:function(){return e.onLastListenerRemove()}})}Object.defineProperty(e.prototype,"event",{get:function(){return this.emitter.event},enumerable:!0,configurable:!0}),e.prototype.add=function(e){var t=this,n={event:e,listener:null};this.events.push(n),this.hasListeners&&this.hook(n);return function(e){return{dispose:function(){e()}}}(function(e){var t,n=this,r=!1;return function(){return r?t:(r=!0,t=e.apply(n,arguments))}}((function(){t.hasListeners&&t.unhook(n);var e=t.events.indexOf(n);t.events.splice(e,1)})))},e.prototype.onFirstListenerAdd=function(){var e=this;this.hasListeners=!0,this.events.forEach((function(t){return e.hook(t)}))},e.prototype.onLastListenerRemove=function(){var e=this;this.hasListeners=!1,this.events.forEach((function(t){return e.unhook(t)}))},e.prototype.hook=function(e){var t=this;e.listener=e.event((function(e){return t.emitter.fire(e)}))},e.prototype.unhook=function(e){e.listener&&e.listener.dispose(),e.listener=null},e.prototype.dispose=function(){this.emitter.dispose()}}(),function(){function e(){this.buffers=[]}e.prototype.wrapEvent=function(e){var t=this;return function(n,r,i){return e((function(e){var i=t.buffers[t.buffers.length-1];i?i.push((function(){return n.call(r,e)})):n.call(r,e)}),void 0,i)}},e.prototype.bufferEvents=function(e){var t=[];this.buffers.push(t);var n=e();return this.buffers.pop(),t.forEach((function(e){return e()})),n}}(),function(){function e(){var e=this;this.listening=!1,this.inputEvent=le.None,this.inputEventListener=l.None,this.emitter=new pe({onFirstListenerDidAdd:function(){e.listening=!0,e.inputEventListener=e.inputEvent(e.emitter.fire,e.emitter)},onLastListenerRemove:function(){e.listening=!1,e.inputEventListener.dispose()}}),this.event=this.emitter.event}Object.defineProperty(e.prototype,"input",{set:function(e){this.inputEvent=e,this.listening&&(this.inputEventListener.dispose(),this.inputEventListener=e(this.emitter.fire,this.emitter))},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){this.inputEventListener.dispose(),this.emitter.dispose()}}(),Object.freeze((function(e,t){var n=setTimeout(e.bind(t),0);return{dispose:function(){clearTimeout(n)}}})));(me=de||(de={})).isCancellationToken=function(e){return e===me.None||e===me.Cancelled||e instanceof ve||!(!e||"object"!=typeof e)&&"boolean"==typeof e.isCancellationRequested&&"function"==typeof e.onCancellationRequested},me.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:le.None}),me.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:ge});var _e,ve=function(){function e(){this._isCancelled=!1,this._emitter=null}return e.prototype.cancel=function(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))},Object.defineProperty(e.prototype,"isCancellationRequested",{get:function(){return this._isCancelled},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onCancellationRequested",{get:function(){return this._isCancelled?ge:(this._emitter||(this._emitter=new pe),this._emitter.event)},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){this._emitter&&(this._emitter.dispose(),this._emitter=null)},e}(),ye=function(){function e(e){this._token=void 0,this._parentListener=void 0,this._parentListener=e&&e.onCancellationRequested(this.cancel,this)}return Object.defineProperty(e.prototype,"token",{get:function(){return this._token||(this._token=new ve),this._token},enumerable:!0,configurable:!0}),e.prototype.cancel=function(){this._token?this._token instanceof ve&&this._token.cancel():this._token=de.Cancelled},e.prototype.dispose=function(){this._parentListener&&this._parentListener.dispose(),this._token?this._token instanceof ve&&this._token.dispose():this._token=de.None},e}(),Ce=function(){function e(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}return e.prototype.define=function(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e},e.prototype.keyCodeToStr=function(e){return this._keyCodeToStr[e]},e.prototype.strToKeyCode=function(e){return this._strToKeyCode[e.toLowerCase()]||0},e}(),be=new Ce,Le=new Ce,Ne=new Ce;!function(){function e(e,t,n,r){void 0===n&&(n=t),void 0===r&&(r=n),be.define(e,t),Le.define(e,n),Ne.define(e,r)}e(0,"unknown"),e(1,"Backspace"),e(2,"Tab"),e(3,"Enter"),e(4,"Shift"),e(5,"Ctrl"),e(6,"Alt"),e(7,"PauseBreak"),e(8,"CapsLock"),e(9,"Escape"),e(10,"Space"),e(11,"PageUp"),e(12,"PageDown"),e(13,"End"),e(14,"Home"),e(15,"LeftArrow","Left"),e(16,"UpArrow","Up"),e(17,"RightArrow","Right"),e(18,"DownArrow","Down"),e(19,"Insert"),e(20,"Delete"),e(21,"0"),e(22,"1"),e(23,"2"),e(24,"3"),e(25,"4"),e(26,"5"),e(27,"6"),e(28,"7"),e(29,"8"),e(30,"9"),e(31,"A"),e(32,"B"),e(33,"C"),e(34,"D"),e(35,"E"),e(36,"F"),e(37,"G"),e(38,"H"),e(39,"I"),e(40,"J"),e(41,"K"),e(42,"L"),e(43,"M"),e(44,"N"),e(45,"O"),e(46,"P"),e(47,"Q"),e(48,"R"),e(49,"S"),e(50,"T"),e(51,"U"),e(52,"V"),e(53,"W"),e(54,"X"),e(55,"Y"),e(56,"Z"),e(57,"Meta"),e(58,"ContextMenu"),e(59,"F1"),e(60,"F2"),e(61,"F3"),e(62,"F4"),e(63,"F5"),e(64,"F6"),e(65,"F7"),e(66,"F8"),e(67,"F9"),e(68,"F10"),e(69,"F11"),e(70,"F12"),e(71,"F13"),e(72,"F14"),e(73,"F15"),e(74,"F16"),e(75,"F17"),e(76,"F18"),e(77,"F19"),e(78,"NumLock"),e(79,"ScrollLock"),e(80,";",";","OEM_1"),e(81,"=","=","OEM_PLUS"),e(82,",",",","OEM_COMMA"),e(83,"-","-","OEM_MINUS"),e(84,".",".","OEM_PERIOD"),e(85,"/","/","OEM_2"),e(86,"`","`","OEM_3"),e(110,"ABNT_C1"),e(111,"ABNT_C2"),e(87,"[","[","OEM_4"),e(88,"\\","\\","OEM_5"),e(89,"]","]","OEM_6"),e(90,"'","'","OEM_7"),e(91,"OEM_8"),e(92,"OEM_102"),e(93,"NumPad0"),e(94,"NumPad1"),e(95,"NumPad2"),e(96,"NumPad3"),e(97,"NumPad4"),e(98,"NumPad5"),e(99,"NumPad6"),e(100,"NumPad7"),e(101,"NumPad8"),e(102,"NumPad9"),e(103,"NumPad_Multiply"),e(104,"NumPad_Add"),e(105,"NumPad_Separator"),e(106,"NumPad_Subtract"),e(107,"NumPad_Decimal"),e(108,"NumPad_Divide")}(),function(e){e.toString=function(e){return be.keyCodeToStr(e)},e.fromString=function(e){return be.strToKeyCode(e)},e.toUserSettingsUS=function(e){return Le.keyCodeToStr(e)},e.toUserSettingsGeneral=function(e){return Ne.keyCodeToStr(e)},e.fromUserSettings=function(e){return Le.strToKeyCode(e)||Ne.strToKeyCode(e)}}(_e||(_e={}));!function(){function e(e,t,n,r,i){this.ctrlKey=e,this.shiftKey=t,this.altKey=n,this.metaKey=r,this.keyCode=i}e.prototype.equals=function(e){return this.ctrlKey===e.ctrlKey&&this.shiftKey===e.shiftKey&&this.altKey===e.altKey&&this.metaKey===e.metaKey&&this.keyCode===e.keyCode},e.prototype.isModifierKey=function(){return 0===this.keyCode||5===this.keyCode||57===this.keyCode||6===this.keyCode||4===this.keyCode},e.prototype.toChord=function(){return new $e([this])},e.prototype.isDuplicateModifierCase=function(){return this.ctrlKey&&5===this.keyCode||this.shiftKey&&4===this.keyCode||this.altKey&&6===this.keyCode||this.metaKey&&57===this.keyCode}}();var Ee,Se,we,Ae,Me,Te,Pe,Oe,xe,Ie,Re,ke,Ue,Fe,De,Ke,qe,Ve,Be,je,Ye,We,He,Ge,Qe,ze,Xe,$e=function(){function e(e){if(0===e.length)throw(t="parts")?new Error("Illegal argument: "+t):new Error("Illegal argument");var t;this.parts=e}return e.prototype.equals=function(e){if(null===e)return!1;if(this.parts.length!==e.parts.length)return!1;for(var t=0;t "+this.positionLineNumber+","+this.positionColumn+"]"},t.prototype.equalsSelection=function(e){return t.selectionsEqual(this,e)},t.selectionsEqual=function(e,t){return e.selectionStartLineNumber===t.selectionStartLineNumber&&e.selectionStartColumn===t.selectionStartColumn&&e.positionLineNumber===t.positionLineNumber&&e.positionColumn===t.positionColumn},t.prototype.getDirection=function(){return this.selectionStartLineNumber===this.startLineNumber&&this.selectionStartColumn===this.startColumn?0:1},t.prototype.setEndPosition=function(e,n){return 0===this.getDirection()?new t(this.startLineNumber,this.startColumn,e,n):new t(e,n,this.startLineNumber,this.startColumn)},t.prototype.getPosition=function(){return new B(this.positionLineNumber,this.positionColumn)},t.prototype.setStartPosition=function(e,n){return 0===this.getDirection()?new t(e,n,this.endLineNumber,this.endColumn):new t(this.endLineNumber,this.endColumn,e,n)},t.fromPositions=function(e,n){return void 0===n&&(n=e),new t(e.lineNumber,e.column,n.lineNumber,n.column)},t.liftSelection=function(e){return new t(e.selectionStartLineNumber,e.selectionStartColumn,e.positionLineNumber,e.positionColumn)},t.selectionsArrEqual=function(e,t){if(e&&!t||!e&&t)return!1;if(!e&&!t)return!0;if(e.length!==t.length)return!1;for(var n=0,r=e.length;n>>0)>>>0}(e,t)},e.CtrlCmd=2048,e.Shift=1024,e.Alt=512,e.WinCtrl=256,e}();var nt=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),rt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return nt(t,e),Object.defineProperty(t.prototype,"uri",{get:function(){return this._uri},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"version",{get:function(){return this._versionId},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"eol",{get:function(){return this._eol},enumerable:!0,configurable:!0}),t.prototype.getValue=function(){return this.getText()},t.prototype.getLinesContent=function(){return this._lines.slice(0)},t.prototype.getLineCount=function(){return this._lines.length},t.prototype.getLineContent=function(e){return this._lines[e-1]},t.prototype.getWordAtPosition=function(e,t){var n=function(e,t,n,r){t.lastIndex=0;var i=t.exec(n);if(!i)return null;var o=i[0].indexOf(" ")>=0?function(e,t,n,r){var i,o=e-1-r;for(t.lastIndex=0;i=t.exec(n);){var s=i.index||0;if(s>o)return null;if(t.lastIndex>=o)return{word:i[0],startColumn:r+1+s,endColumn:r+1+t.lastIndex}}return null}(e,t,n,r):function(e,t,n,r){var i,o=e-1-r,s=n.lastIndexOf(" ",o-1)+1;for(t.lastIndex=s;i=t.exec(n);){var u=i.index||0;if(u<=o&&t.lastIndex>=o)return{word:i[0],startColumn:r+1+u,endColumn:r+1+t.lastIndex}}return null}(e,t,n,r);return t.lastIndex=0,o}(e.column,function(e){var t=ne;if(e&&e instanceof RegExp)if(e.global)t=e;else{var n="g";e.ignoreCase&&(n+="i"),e.multiline&&(n+="m"),e.unicode&&(n+="u"),t=new RegExp(e.source,n)}return t.lastIndex=0,t}(t),this._lines[e.lineNumber-1],0);return n?new j(e.lineNumber,n.startColumn,e.lineNumber,n.endColumn):null},t.prototype.getWordUntilPosition=function(e,t){var n=this.getWordAtPosition(e,t);return n?{word:this._lines[e.lineNumber-1].substring(n.startColumn-1,e.column-1),startColumn:n.startColumn,endColumn:e.column}:{word:"",startColumn:e.column,endColumn:e.column}},t.prototype.createWordIterator=function(e){var t,n,r=this,i=0,o=0,s=[],u=function(){if(o=r._lines.length?w:(n=r._lines[i],s=r._wordenize(n,e),o=0,i+=1,u())};return{next:u}},t.prototype.getLineWords=function(e,t){for(var n=this._lines[e-1],r=[],i=0,o=this._wordenize(n,t);ithis._lines.length)t=this._lines.length,n=this._lines[t-1].length+1,r=!0;else{var i=this._lines[t-1].length+1;n<1?(n=1,r=!0):n>i&&(n=i,r=!0)}return r?{lineNumber:t,column:n}:e},t}(te),it=function(e){function t(t){var n=e.call(this,t)||this;return n._models=Object.create(null),n}return nt(t,e),t.prototype.dispose=function(){this._models=Object.create(null)},t.prototype._getModel=function(e){return this._models[e]},t.prototype._getModels=function(){var e=this,t=[];return Object.keys(this._models).forEach((function(n){return t.push(e._models[n])})),t},t.prototype.acceptNewModel=function(e){this._models[e.url]=new rt(k.parse(e.url),e.lines,e.EOL,e.versionId)},t.prototype.acceptModelChanged=function(e,t){this._models[e]&&this._models[e].onEvents(t)},t.prototype.acceptRemovedModel=function(e){this._models[e]&&delete this._models[e]},t}(function(){function e(e){this._foreignModuleFactory=e,this._foreignModule=null}return e.prototype.computeDiff=function(e,t,n){var r=this._getModel(e),i=this._getModel(t);if(!r||!i)return Promise.resolve(null);var o=r.getLinesContent(),s=i.getLinesContent(),u=new z(o,s,{shouldComputeCharChanges:!0,shouldPostProcessCharChanges:!0,shouldIgnoreTrimWhitespace:n,shouldMakePrettyDiff:!0}).computeDiff(),a=!(u.length>0)&&this._modelsAreIdentical(r,i);return Promise.resolve({identical:a,changes:u})},e.prototype._modelsAreIdentical=function(e,t){var n=e.getLineCount();if(n!==t.getLineCount())return!1;for(var r=1;r<=n;r++){if(e.getLineContent(r)!==t.getLineContent(r))return!1}return!0},e.prototype.computeMoreMinimalEdits=function(t,n){var r=this._getModel(t);if(!r)return Promise.resolve(n);for(var i=[],o=void 0,s=0,u=n=g(n,(function(e,t){return e.range&&t.range?j.compareRangesUsingStarts(e.range,t.range):(e.range?0:1)-(t.range?0:1)}));se._diffLimit)i.push({range:l,text:c});else for(var d=y(h,c,!1),m=r.offsetAt(j.lift(l).getStartPosition()),p=0,_=d;p<_.length;p++){var v=_[p],C=r.positionAt(m+v.originalStart),b=r.positionAt(m+v.originalStart+v.originalLength),L={text:c.substr(v.modifiedStart,v.modifiedLength),range:{startLineNumber:C.lineNumber,startColumn:C.column,endLineNumber:b.lineNumber,endColumn:b.column}};r.getValueInRange(L.range)!==L.text&&i.push(L)}}}return"number"==typeof o&&i.push({eol:o,text:"",range:{startLineNumber:0,startColumn:0,endLineNumber:0,endColumn:0}}),Promise.resolve(i)},e.prototype.computeLinks=function(e){var t=this._getModel(e);return t?Promise.resolve(function(e){return e&&"function"==typeof e.getLineCount&&"function"==typeof e.getLineContent?ue.computeLinks(e):[]}(t)):Promise.resolve(null)},e.prototype.textualSuggest=function(t,n,r,i){var o=this._getModel(t);if(!o)return Promise.resolve(null);var s=Object.create(null),u=[],a=new RegExp(r,i),l=o.getWordUntilPosition(n,a),c=o.getWordAtPosition(n,a);c&&(s[o.getValueInRange(c)]=!0);for(var f=o.createWordIterator(a),h=f.next();!h.done&&u.length<=e._suggestionsLimit;h=f.next()){var d=h.value;s[d]||(s[d]=!0,isNaN(Number(d))&&u.push({kind:18,label:d,insertText:d,range:{startLineNumber:n.lineNumber,startColumn:l.startColumn,endLineNumber:n.lineNumber,endColumn:l.endColumn}}))}return Promise.resolve({suggestions:u})},e.prototype.computeWordRanges=function(e,t,n,r){var i=this._getModel(e);if(!i)return Promise.resolve(Object.create(null));for(var o=new RegExp(n,r),s=Object.create(null),u=t.startLineNumber;u{let e,t,n,r,i,o={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},s=function(t){throw{at:e,text:t,message:t}},u=function(t){return t&&t!==n&&s("Expected '"+t+"' instead of '"+n+"'"),n=r.charAt(e),e+=1,n},a=function(t,i){let o=e,u=r.indexOf(t,o);var a;return u<0&&s(i||"Expected '"+t+"'"),a=u+t.length,n=r.charAt(a),e=a+1,r.substring(o,u)},l=function(){var e,t="";for("-"===n&&(t="-",u("-"));n>="0"&&"9">=n;)t+=n,u();if("."===n)for(t+=".";u()&&n>="0"&&"9">=n;)t+=n;if("e"===n||"E"===n)for(t+=n,u(),("-"===n||"+"===n)&&(t+=n,u());n>="0"&&"9">=n;)t+=n,u();return e=+t,isNaN(e)?void s("Bad number"):e},c=function(){let t,i,l,c="";if('"'===n){if(f='""',r.substr(e,f.length)===f)return u('"'),u('"'),a('"""','failed to find closing \'"""\'');for(;u();){if('"'===n)return u(),c;if("\\"===n)if(u(),"u"===n){for(l=0,i=0;4>i&&(t=parseInt(u(),16),isFinite(t));i+=1)l=16*l+t;c+=String.fromCharCode(l)}else{if("string"!=typeof o[n])break;c+=o[n]}else c+=n}}var f;s("Bad string")},f=function(){for(;n&&" ">=n;)u()};return i=function(){switch(f(),n){case"{":return function(){var r,o,a,l={};if("{"===n){if(u("{"),f(),"}"===n)return u("}"),l;for(;n;){let s=e;if(r=c(),f(),u(":"),Object.hasOwnProperty.call(l,r)&&(o='Duplicate key "'+r+'"',a=s,t.push({type:ut.warning,at:a,text:o})),l[r]=i(),f(),"}"===n)return u("}"),l;u(","),f()}}s("Bad object")}();case"[":return function(){var e=[];if("["===n){if(u("["),f(),"]"===n)return u("]"),e;for(;n;){if(e.push(i()),f(),"]"===n)return u("]"),e;u(","),f()}}s("Bad array")}();case'"':return c();case"-":return l();default:return n>="0"&&"9">=n?l():function(){switch(n){case"t":return u("t"),u("r"),u("u"),u("e"),!0;case"f":return u("f"),u("a"),u("l"),u("s"),u("e"),!1;case"n":return u("n"),u("u"),u("l"),u("l"),null}s("Unexpected '"+n+"'")}()}},function(o){t=[];let u=!1;r=o,e=0,n=" ",f();try{i()}catch(e){u=!0,t.push({type:ut.error,at:e.at-1,text:e.message})}return!u&&n&&s("Syntax error"),{annotations:t}}};class lt{constructor(e){this.ctx=e}async parse(){this.parser||(this.parser=at());const[e]=this.ctx.getMirrorModels();return this.parser(e.getValue())}}self.onmessage=()=>{st((e,t)=>new lt(e))}}]); \ No newline at end of file diff --git a/packages/kbn-ui-shared-deps/monaco/xjson/dist/bundle.editor.worker.js b/packages/kbn-ui-shared-deps/monaco/xjson/dist/bundle.editor.worker.js deleted file mode 100644 index 48106b652e700e..00000000000000 --- a/packages/kbn-ui-shared-deps/monaco/xjson/dist/bundle.editor.worker.js +++ /dev/null @@ -1 +0,0 @@ -/*! /* eslint-disable * / */!function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=6)}([function(e,t,n){"use strict";(function(e,r){n.d(t,"c",(function(){return m})),n.d(t,"b",(function(){return p})),n.d(t,"a",(function(){return g}));var i=!1,o=!1,s=!1,u=!1,a=!1,l=void 0!==e&&void 0!==e.versions&&void 0!==e.versions.electron&&"renderer"===e.type;if("object"!=typeof navigator||l){if("object"==typeof e){i="win32"===e.platform,o="darwin"===e.platform,s="linux"===e.platform,"en","en";var c=e.env.VSCODE_NLS_CONFIG;if(c)try{var f=JSON.parse(c),h=f.availableLanguages["*"];f.locale,h||"en",f._translationsConfigFile}catch(e){}u=!0}}else{var d=navigator.userAgent;i=d.indexOf("Windows")>=0,o=d.indexOf("Macintosh")>=0,s=d.indexOf("Linux")>=0,a=!0,navigator.language}var m=i,p=a,g="object"==typeof self?self:"object"==typeof r?r:{}}).call(this,n(2),n(1))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t){var n,r,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function u(e){if(n===setTimeout)return setTimeout(e,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(e){n=o}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();var a,l=[],c=!1,f=-1;function h(){c&&a&&(c=!1,a.length?l=a.concat(l):f=-1,l.length&&d())}function d(){if(!c){var e=u(h);c=!0;for(var t=l.length;t;){for(a=l,l=[];++f1)for(var n=1;n=0&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),t))},n(5),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,n(1))},function(e,t,n){(function(e,t){!function(e,n){"use strict";if(!e.setImmediate){var r,i,o,s,u,a=1,l={},c=!1,f=e.document,h=Object.getPrototypeOf&&Object.getPrototypeOf(e);h=h&&h.setTimeout?h:e,"[object process]"==={}.toString.call(e.process)?r=function(e){t.nextTick((function(){m(e)}))}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=n,t}}()?e.MessageChannel?((o=new MessageChannel).port1.onmessage=function(e){m(e.data)},r=function(e){o.port2.postMessage(e)}):f&&"onreadystatechange"in f.createElement("script")?(i=f.documentElement,r=function(e){var t=f.createElement("script");t.onreadystatechange=function(){m(e),t.onreadystatechange=null,i.removeChild(t),t=null},i.appendChild(t)}):r=function(e){setTimeout(m,0,e)}:(s="setImmediate$"+Math.random()+"$",u=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(s)&&m(+t.data.slice(s.length))},e.addEventListener?e.addEventListener("message",u,!1):e.attachEvent("onmessage",u),r=function(t){e.postMessage(s+t,"*")}),h.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;nr?e[a]=o[u++]:u>i?e[a]=o[s++]:t(o[u],o[s])<0?e[a]=o[u++]:e[a]=o[s++]}(t,n,r,s,i,o)}(e,t,0,e.length-1,[]),e}var v=function(){function e(e,t,n,r){this.originalStart=e,this.originalLength=t,this.modifiedStart=n,this.modifiedLength=r}return e.prototype.getOriginalEnd=function(){return this.originalStart+this.originalLength},e.prototype.getModifiedEnd=function(){return this.modifiedStart+this.modifiedLength},e}();function y(e){return{getLength:function(){return e.length},getElementAtIndex:function(t){return e.charCodeAt(t)}}}function C(e,t,n){return new S(y(e),y(t)).ComputeDiff(n)}var b,L=function(){function e(){}return e.Assert=function(e,t){if(!e)throw new Error(t)},e}(),N=function(){function e(){}return e.Copy=function(e,t,n,r,i){for(var o=0;o0||this.m_modifiedCount>0)&&this.m_changes.push(new v(this.m_originalStart,this.m_originalCount,this.m_modifiedStart,this.m_modifiedCount)),this.m_originalCount=0,this.m_modifiedCount=0,this.m_originalStart=Number.MAX_VALUE,this.m_modifiedStart=Number.MAX_VALUE},e.prototype.AddOriginalElement=function(e,t){this.m_originalStart=Math.min(this.m_originalStart,e),this.m_modifiedStart=Math.min(this.m_modifiedStart,t),this.m_originalCount++},e.prototype.AddModifiedElement=function(e,t){this.m_originalStart=Math.min(this.m_originalStart,e),this.m_modifiedStart=Math.min(this.m_modifiedStart,t),this.m_modifiedCount++},e.prototype.getChanges=function(){return(this.m_originalCount>0||this.m_modifiedCount>0)&&this.MarkNextChange(),this.m_changes},e.prototype.getReverseChanges=function(){return(this.m_originalCount>0||this.m_modifiedCount>0)&&this.MarkNextChange(),this.m_changes.reverse(),this.m_changes},e}(),S=function(){function e(e,t,n){void 0===n&&(n=null),this.OriginalSequence=e,this.ModifiedSequence=t,this.ContinueProcessingPredicate=n,this.m_forwardHistory=[],this.m_reverseHistory=[]}return e.prototype.ElementsAreEqual=function(e,t){return this.OriginalSequence.getElementAtIndex(e)===this.ModifiedSequence.getElementAtIndex(t)},e.prototype.OriginalElementsAreEqual=function(e,t){return this.OriginalSequence.getElementAtIndex(e)===this.OriginalSequence.getElementAtIndex(t)},e.prototype.ModifiedElementsAreEqual=function(e,t){return this.ModifiedSequence.getElementAtIndex(e)===this.ModifiedSequence.getElementAtIndex(t)},e.prototype.ComputeDiff=function(e){return this._ComputeDiff(0,this.OriginalSequence.getLength()-1,0,this.ModifiedSequence.getLength()-1,e)},e.prototype._ComputeDiff=function(e,t,n,r,i){var o=this.ComputeDiffRecursive(e,t,n,r,[!1]);return i?this.PrettifyChanges(o):o},e.prototype.ComputeDiffRecursive=function(e,t,n,r,i){for(i[0]=!1;e<=t&&n<=r&&this.ElementsAreEqual(e,n);)e++,n++;for(;t>=e&&r>=n&&this.ElementsAreEqual(t,r);)t--,r--;if(e>t||n>r){var o=void 0;return n<=r?(L.Assert(e===t+1,"originalStart should only be one more than originalEnd"),o=[new v(e,0,n,r-n+1)]):e<=t?(L.Assert(n===r+1,"modifiedStart should only be one more than modifiedEnd"),o=[new v(e,t-e+1,n,0)]):(L.Assert(e===t+1,"originalStart should only be one more than originalEnd"),L.Assert(n===r+1,"modifiedStart should only be one more than modifiedEnd"),o=[]),o}var s=[0],u=[0],a=this.ComputeRecursionPoint(e,t,n,r,s,u,i),l=s[0],c=u[0];if(null!==a)return a;if(!i[0]){var f=this.ComputeDiffRecursive(e,l,n,c,i),h=[];return h=i[0]?[new v(l+1,t-(l+1)+1,c+1,r-(c+1)+1)]:this.ComputeDiffRecursive(l+1,t,c+1,r,i),this.ConcatenateChanges(f,h)}return[new v(e,t-e+1,n,r-n+1)]},e.prototype.WALKTRACE=function(e,t,n,r,i,o,s,u,a,l,c,f,h,d,m,p,g,_){var y,C,b=null,L=new E,N=t,S=n,w=h[0]-p[0]-r,A=Number.MIN_VALUE,T=this.m_forwardHistory.length-1;do{(C=w+e)===N||C=0&&(e=(a=this.m_forwardHistory[T])[0],N=1,S=a.length-1)}while(--T>=-1);if(y=L.getReverseChanges(),_[0]){var M=h[0]+1,P=p[0]+1;if(null!==y&&y.length>0){var O=y[y.length-1];M=Math.max(M,O.getOriginalEnd()),P=Math.max(P,O.getModifiedEnd())}b=[new v(M,f-M+1,P,m-P+1)]}else{L=new E,N=o,S=s,w=h[0]-p[0]-u,A=Number.MAX_VALUE,T=g?this.m_reverseHistory.length-1:this.m_reverseHistory.length-2;do{(C=w+i)===N||C=l[C+1]?(d=(c=l[C+1]-1)-w-u,c>A&&L.MarkNextChange(),A=c+1,L.AddOriginalElement(c+1,d+1),w=C+1-i):(d=(c=l[C-1])-w-u,c>A&&L.MarkNextChange(),A=c,L.AddModifiedElement(c+1,d+1),w=C-1-i),T>=0&&(i=(l=this.m_reverseHistory[T])[0],N=1,S=l.length-1)}while(--T>=-1);b=L.getChanges()}return this.ConcatenateChanges(y,b)},e.prototype.ComputeRecursionPoint=function(e,t,n,r,i,o,s){var u,a=0,l=0,c=0,f=0,h=0,d=0;e--,n--,i[0]=0,o[0]=0,this.m_forwardHistory=[],this.m_reverseHistory=[];var m,p,g=t-e+(r-n),_=g+1,y=new Array(_),C=new Array(_),b=r-n,L=t-e,E=e-n,S=t-r,w=(L-b)%2==0;for(y[b]=e,C[L]=t,s[0]=!1,u=1;u<=g/2+1;u++){var A=0,T=0;for(c=this.ClipDiagonalBound(b-u,u,b,_),f=this.ClipDiagonalBound(b+u,u,b,_),m=c;m<=f;m+=2){for(l=(a=m===c||mA+T&&(A=a,T=l),!w&&Math.abs(m-L)<=u-1&&a>=C[m])return i[0]=a,o[0]=l,p<=C[m]&&u<=1448?this.WALKTRACE(b,c,f,E,L,h,d,S,y,C,a,t,i,l,r,o,w,s):null}var M=(A-e+(T-n)-u)/2;if(null!==this.ContinueProcessingPredicate&&!this.ContinueProcessingPredicate(A,this.OriginalSequence,M))return s[0]=!0,i[0]=A,o[0]=T,M>0&&u<=1448?this.WALKTRACE(b,c,f,E,L,h,d,S,y,C,a,t,i,l,r,o,w,s):(e++,n++,[new v(e,t-e+1,n,r-n+1)]);for(h=this.ClipDiagonalBound(L-u,u,L,_),d=this.ClipDiagonalBound(L+u,u,L,_),m=h;m<=d;m+=2){for(l=(a=m===h||m=C[m+1]?C[m+1]-1:C[m-1])-(m-L)-S,p=a;a>e&&l>n&&this.ElementsAreEqual(a,l);)a--,l--;if(C[m]=a,w&&Math.abs(m-b)<=u&&a<=y[m])return i[0]=a,o[0]=l,p>=y[m]&&u<=1448?this.WALKTRACE(b,c,f,E,L,h,d,S,y,C,a,t,i,l,r,o,w,s):null}if(u<=1447){var P=new Array(f-c+2);P[0]=b-c+1,N.Copy(y,c,P,1,f-c+1),this.m_forwardHistory.push(P),(P=new Array(d-h+2))[0]=L-h+1,N.Copy(C,h,P,1,d-h+1),this.m_reverseHistory.push(P)}}return this.WALKTRACE(b,c,f,E,L,h,d,S,y,C,a,t,i,l,r,o,w,s)},e.prototype.PrettifyChanges=function(e){for(var t=0;t0,s=n.modifiedLength>0;n.originalStart+n.originalLength=0;t--){n=e[t],r=0,i=0;if(t>0){var a=e[t-1];a.originalLength>0&&(r=a.originalStart+a.originalLength),a.modifiedLength>0&&(i=a.modifiedStart+a.modifiedLength)}o=n.originalLength>0,s=n.modifiedLength>0;for(var l=0,c=this._boundaryScore(n.originalStart,n.originalLength,n.modifiedStart,n.modifiedLength),f=1;;f++){var h=n.originalStart-f,d=n.modifiedStart-f;if(hc&&(c=m,l=f)}n.originalStart-=l,n.modifiedStart-=l}return e},e.prototype._OriginalIsBoundary=function(e){if(e<=0||e>=this.OriginalSequence.getLength()-1)return!0;var t=this.OriginalSequence.getElementAtIndex(e);return"string"==typeof t&&/^\s*$/.test(t)},e.prototype._OriginalRegionIsBoundary=function(e,t){if(this._OriginalIsBoundary(e)||this._OriginalIsBoundary(e-1))return!0;if(t>0){var n=e+t;if(this._OriginalIsBoundary(n-1)||this._OriginalIsBoundary(n))return!0}return!1},e.prototype._ModifiedIsBoundary=function(e){if(e<=0||e>=this.ModifiedSequence.getLength()-1)return!0;var t=this.ModifiedSequence.getElementAtIndex(e);return"string"==typeof t&&/^\s*$/.test(t)},e.prototype._ModifiedRegionIsBoundary=function(e,t){if(this._ModifiedIsBoundary(e)||this._ModifiedIsBoundary(e-1))return!0;if(t>0){var n=e+t;if(this._ModifiedIsBoundary(n-1)||this._ModifiedIsBoundary(n))return!0}return!1},e.prototype._boundaryScore=function(e,t,n,r){return(this._OriginalRegionIsBoundary(e,t)?1:0)+(this._ModifiedRegionIsBoundary(n,r)?1:0)},e.prototype.ConcatenateChanges=function(e,t){var n=[];if(0===e.length||0===t.length)return t.length>0?t:e;if(this.ChangesOverlap(e[e.length-1],t[0],n)){var r=new Array(e.length+t.length-1);return N.Copy(e,0,r,0,e.length-1),r[e.length-1]=n[0],N.Copy(t,1,r,e.length,t.length-1),r}r=new Array(e.length+t.length);return N.Copy(e,0,r,0,e.length),N.Copy(t,0,r,e.length,t.length),r},e.prototype.ChangesOverlap=function(e,t,n){if(L.Assert(e.originalStart<=t.originalStart,"Left change is not less than or equal to right change"),L.Assert(e.modifiedStart<=t.modifiedStart,"Left change is not less than or equal to right change"),e.originalStart+e.originalLength>=t.originalStart||e.modifiedStart+e.modifiedLength>=t.modifiedStart){var r=e.originalStart,i=e.originalLength,o=e.modifiedStart,s=e.modifiedLength;return e.originalStart+e.originalLength>=t.originalStart&&(i=t.originalStart+t.originalLength-e.originalStart),e.modifiedStart+e.modifiedLength>=t.modifiedStart&&(s=t.modifiedStart+t.modifiedLength-e.modifiedStart),n[0]=new v(r,i,o,s),!0}return n[0]=null,!1},e.prototype.ClipDiagonalBound=function(e,t,n,r){if(e>=0&&e=n?A:{done:!1,value:e[t++]}}}},e.from=function(t){return t?Array.isArray(t)?e.fromArray(t):t:e.empty()},e.map=function(e,t){return{next:function(){var n=e.next();return n.done?A:{done:!1,value:t(n.value)}}}},e.filter=function(e,t){return{next:function(){for(;;){var n=e.next();if(n.done)return A;if(t(n.value))return{done:!1,value:n.value}}}}},e.forEach=n,e.collect=function(e){var t=[];return n(e,(function(e){return t.push(e)})),t}}(b||(b={}));(function(e){function t(t,n,r,i){return void 0===n&&(n=0),void 0===r&&(r=t.length),void 0===i&&(i=n-1),e.call(this,t,n,r,i)||this}w(t,e),t.prototype.current=function(){return e.prototype.current.call(this)},t.prototype.previous=function(){return this.index=Math.max(this.index-1,this.start-1),this.current()},t.prototype.first=function(){return this.index=this.start,this.current()},t.prototype.last=function(){return this.index=this.end-1,this.current()},t.prototype.parent=function(){return null}})(function(){function e(e,t,n,r){void 0===t&&(t=0),void 0===n&&(n=e.length),void 0===r&&(r=t-1),this.items=e,this.start=t,this.end=n,this.index=r}return e.prototype.next=function(){return this.index=Math.min(this.index+1,this.end),this.current()},e.prototype.current=function(){return this.index===this.start-1||this.index===this.end?null:this.items[this.index]},e}()),function(){function e(e,t){this.iterator=e,this.fn=t}e.prototype.next=function(){return this.fn(this.iterator.next())}}();var T,M=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),P=/^\w[\w\d+.-]*$/,O=/^\//,x=/^\/\//;var I="",R="/",k=/^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,U=function(){function e(e,t,n,r,i,o){void 0===o&&(o=!1),"object"==typeof e?(this.scheme=e.scheme||I,this.authority=e.authority||I,this.path=e.path||I,this.query=e.query||I,this.fragment=e.fragment||I):(this.scheme=e||I,this.authority=t||I,this.path=function(e,t){switch(e){case"https":case"http":case"file":t?t[0]!==R&&(t=R+t):t=R}return t}(this.scheme,n||I),this.query=r||I,this.fragment=i||I,function(e,t){if(!e.scheme)throw new Error('[UriError]: Scheme is missing: {scheme: "", authority: "'+e.authority+'", path: "'+e.path+'", query: "'+e.query+'", fragment: "'+e.fragment+'"}');if(e.scheme&&!P.test(e.scheme))throw new Error("[UriError]: Scheme contains illegal characters.");if(e.path)if(e.authority){if(!O.test(e.path))throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character')}else if(x.test(e.path))throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")')}(this))}return e.isUri=function(t){return t instanceof e||!!t&&("string"==typeof t.authority&&"string"==typeof t.fragment&&"string"==typeof t.path&&"string"==typeof t.query&&"string"==typeof t.scheme&&"function"==typeof t.fsPath&&"function"==typeof t.with&&"function"==typeof t.toString)},Object.defineProperty(e.prototype,"fsPath",{get:function(){return V(this)},enumerable:!0,configurable:!0}),e.prototype.with=function(e){if(!e)return this;var t=e.scheme,n=e.authority,r=e.path,i=e.query,o=e.fragment;return void 0===t?t=this.scheme:null===t&&(t=I),void 0===n?n=this.authority:null===n&&(n=I),void 0===r?r=this.path:null===r&&(r=I),void 0===i?i=this.query:null===i&&(i=I),void 0===o?o=this.fragment:null===o&&(o=I),t===this.scheme&&n===this.authority&&r===this.path&&i===this.query&&o===this.fragment?this:new F(t,n,r,i,o)},e.parse=function(e,t){void 0===t&&(t=!1);var n=k.exec(e);return n?new F(n[2]||I,decodeURIComponent(n[4]||I),decodeURIComponent(n[5]||I),decodeURIComponent(n[7]||I),decodeURIComponent(n[9]||I),t):new F(I,I,I,I,I)},e.file=function(e){var t=I;if(f.c&&(e=e.replace(/\\/g,R)),e[0]===R&&e[1]===R){var n=e.indexOf(R,2);-1===n?(t=e.substring(2),e=R):(t=e.substring(2,n),e=e.substring(n)||R)}return new F("file",t,e,I,I)},e.from=function(e){return new F(e.scheme,e.authority,e.path,e.query,e.fragment)},e.prototype.toString=function(e){return void 0===e&&(e=!1),B(this,e)},e.prototype.toJSON=function(){return this},e.revive=function(t){if(t){if(t instanceof e)return t;var n=new F(t);return n._fsPath=t.fsPath,n._formatted=t.external,n}return t},e}(),F=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._formatted=null,t._fsPath=null,t}return M(t,e),Object.defineProperty(t.prototype,"fsPath",{get:function(){return this._fsPath||(this._fsPath=V(this)),this._fsPath},enumerable:!0,configurable:!0}),t.prototype.toString=function(e){return void 0===e&&(e=!1),e?B(this,!0):(this._formatted||(this._formatted=B(this,!1)),this._formatted)},t.prototype.toJSON=function(){var e={$mid:1};return this._fsPath&&(e.fsPath=this._fsPath),this._formatted&&(e.external=this._formatted),this.path&&(e.path=this.path),this.scheme&&(e.scheme=this.scheme),this.authority&&(e.authority=this.authority),this.query&&(e.query=this.query),this.fragment&&(e.fragment=this.fragment),e},t}(U),D=((T={})[58]="%3A",T[47]="%2F",T[63]="%3F",T[35]="%23",T[91]="%5B",T[93]="%5D",T[64]="%40",T[33]="%21",T[36]="%24",T[38]="%26",T[39]="%27",T[40]="%28",T[41]="%29",T[42]="%2A",T[43]="%2B",T[44]="%2C",T[59]="%3B",T[61]="%3D",T[32]="%20",T);function K(e,t){for(var n=void 0,r=-1,i=0;i=97&&o<=122||o>=65&&o<=90||o>=48&&o<=57||45===o||46===o||95===o||126===o||t&&47===o)-1!==r&&(n+=encodeURIComponent(e.substring(r,i)),r=-1),void 0!==n&&(n+=e.charAt(i));else{void 0===n&&(n=e.substr(0,i));var s=D[o];void 0!==s?(-1!==r&&(n+=encodeURIComponent(e.substring(r,i)),r=-1),n+=s):-1===r&&(r=i)}}return-1!==r&&(n+=encodeURIComponent(e.substring(r))),void 0!==n?n:e}function q(e){for(var t=void 0,n=0;n1&&"file"===e.scheme?"//"+e.authority+e.path:47===e.path.charCodeAt(0)&&(e.path.charCodeAt(1)>=65&&e.path.charCodeAt(1)<=90||e.path.charCodeAt(1)>=97&&e.path.charCodeAt(1)<=122)&&58===e.path.charCodeAt(2)?e.path[1].toLowerCase()+e.path.substr(2):e.path,f.c&&(t=t.replace(/\//g,"\\")),t}function B(e,t){var n=t?q:K,r="",i=e.scheme,o=e.authority,s=e.path,u=e.query,a=e.fragment;if(i&&(r+=i,r+=":"),(o||"file"===i)&&(r+=R,r+=R),o){var l=o.indexOf("@");if(-1!==l){var c=o.substr(0,l);o=o.substr(l+1),-1===(l=c.indexOf(":"))?r+=n(c,!1):(r+=n(c.substr(0,l),!1),r+=":",r+=n(c.substr(l+1),!1)),r+="@"}-1===(l=(o=o.toLowerCase()).indexOf(":"))?r+=n(o,!1):(r+=n(o.substr(0,l),!1),r+=o.substr(l))}if(s){if(s.length>=3&&47===s.charCodeAt(0)&&58===s.charCodeAt(2))(f=s.charCodeAt(1))>=65&&f<=90&&(s="/"+String.fromCharCode(f+32)+":"+s.substr(3));else if(s.length>=2&&58===s.charCodeAt(1)){var f;(f=s.charCodeAt(0))>=65&&f<=90&&(s=String.fromCharCode(f+32)+":"+s.substr(2))}r+=n(s,!0)}return u&&(r+="?",r+=n(u,!1)),a&&(r+="#",r+=t?a:K(a,!1)),r}var j=function(){function e(e,t){this.lineNumber=e,this.column=t}return e.prototype.with=function(t,n){return void 0===t&&(t=this.lineNumber),void 0===n&&(n=this.column),t===this.lineNumber&&n===this.column?this:new e(t,n)},e.prototype.delta=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=0),this.with(this.lineNumber+e,this.column+t)},e.prototype.equals=function(t){return e.equals(this,t)},e.equals=function(e,t){return!e&&!t||!!e&&!!t&&e.lineNumber===t.lineNumber&&e.column===t.column},e.prototype.isBefore=function(t){return e.isBefore(this,t)},e.isBefore=function(e,t){return e.lineNumbern||e===n&&t>r?(this.startLineNumber=n,this.startColumn=r,this.endLineNumber=e,this.endColumn=t):(this.startLineNumber=e,this.startColumn=t,this.endLineNumber=n,this.endColumn=r)}return e.prototype.isEmpty=function(){return e.isEmpty(this)},e.isEmpty=function(e){return e.startLineNumber===e.endLineNumber&&e.startColumn===e.endColumn},e.prototype.containsPosition=function(t){return e.containsPosition(this,t)},e.containsPosition=function(e,t){return!(t.lineNumbere.endLineNumber)&&(!(t.lineNumber===e.startLineNumber&&t.columne.endColumn))},e.prototype.containsRange=function(t){return e.containsRange(this,t)},e.containsRange=function(e,t){return!(t.startLineNumbere.endLineNumber||t.endLineNumber>e.endLineNumber)&&(!(t.startLineNumber===e.startLineNumber&&t.startColumne.endColumn)))},e.prototype.plusRange=function(t){return e.plusRange(this,t)},e.plusRange=function(t,n){var r,i,o,s;return n.startLineNumbert.endLineNumber?(o=n.endLineNumber,s=n.endColumn):n.endLineNumber===t.endLineNumber?(o=n.endLineNumber,s=Math.max(n.endColumn,t.endColumn)):(o=t.endLineNumber,s=t.endColumn),new e(r,i,o,s)},e.prototype.intersectRanges=function(t){return e.intersectRanges(this,t)},e.intersectRanges=function(t,n){var r=t.startLineNumber,i=t.startColumn,o=t.endLineNumber,s=t.endColumn,u=n.startLineNumber,a=n.startColumn,l=n.endLineNumber,c=n.endColumn;return rl?(o=l,s=c):o===l&&(s=Math.min(s,c)),r>o?null:r===o&&i>s?null:new e(r,i,o,s)},e.prototype.equalsRange=function(t){return e.equalsRange(this,t)},e.equalsRange=function(e,t){return!!e&&!!t&&e.startLineNumber===t.startLineNumber&&e.startColumn===t.startColumn&&e.endLineNumber===t.endLineNumber&&e.endColumn===t.endColumn},e.prototype.getEndPosition=function(){return new j(this.endLineNumber,this.endColumn)},e.prototype.getStartPosition=function(){return new j(this.startLineNumber,this.startColumn)},e.prototype.toString=function(){return"["+this.startLineNumber+","+this.startColumn+" -> "+this.endLineNumber+","+this.endColumn+"]"},e.prototype.setEndPosition=function(t,n){return new e(this.startLineNumber,this.startColumn,t,n)},e.prototype.setStartPosition=function(t,n){return new e(t,n,this.endLineNumber,this.endColumn)},e.prototype.collapseToStart=function(){return e.collapseToStart(this)},e.collapseToStart=function(t){return new e(t.startLineNumber,t.startColumn,t.startLineNumber,t.startColumn)},e.fromPositions=function(t,n){return void 0===n&&(n=t),new e(t.lineNumber,t.column,n.lineNumber,n.column)},e.lift=function(t){return t?new e(t.startLineNumber,t.startColumn,t.endLineNumber,t.endColumn):null},e.isIRange=function(e){return e&&"number"==typeof e.startLineNumber&&"number"==typeof e.startColumn&&"number"==typeof e.endLineNumber&&"number"==typeof e.endColumn},e.areIntersectingOrTouching=function(e,t){return!(e.endLineNumbere.startLineNumber},e}();String.fromCharCode(65279);function W(e,t,n,r){return new S(e,t,n).ComputeDiff(r)}var H=function(){function e(t){for(var n=[],r=[],i=0,o=t.length;i=0;n--){var r=e.charCodeAt(n);if(32!==r&&9!==r)return n}return-1}(e);return-1===n?t:n+2},e.prototype.getCharSequence=function(e,t,n){for(var r=[],i=[],o=[],s=0,u=t;u<=n;u++)for(var a=this._lines[u],l=e?this._startColumns[u]:1,c=e?this._endColumns[u]:a.length+1,f=l;f1&&m>1;){if(f.charCodeAt(d-2)!==h.charCodeAt(m-2))break;d--,m--}(d>1||m>1)&&this._pushTrimWhitespaceCharChange(i,o+1,1,d,s+1,1,m);for(var p=H._getLastNonBlankColumn(f,1),g=H._getLastNonBlankColumn(h,1),_=f.length+1,v=h.length+1;p<_&&g255?255:0|e}function Z(e){return e<0?0:e>4294967295?4294967295:0|e}var ee=function(e,t){this.index=e,this.remainder=t},te=function(){function e(e){this.values=e,this.prefixSum=new Uint32Array(e.length),this.prefixSumValidIndex=new Int32Array(1),this.prefixSumValidIndex[0]=-1}return e.prototype.getCount=function(){return this.values.length},e.prototype.insertValues=function(e,t){e=Z(e);var n=this.values,r=this.prefixSum,i=t.length;return 0!==i&&(this.values=new Uint32Array(n.length+i),this.values.set(n.subarray(0,e),0),this.values.set(n.subarray(e),e+i),this.values.set(t,e),e-1=0&&this.prefixSum.set(r.subarray(0,this.prefixSumValidIndex[0]+1)),!0)},e.prototype.changeValue=function(e,t){return e=Z(e),t=Z(t),this.values[e]!==t&&(this.values[e]=t,e-1=n.length)return!1;var i=n.length-e;return t>=i&&(t=i),0!==t&&(this.values=new Uint32Array(n.length-t),this.values.set(n.subarray(0,e),0),this.values.set(n.subarray(e+t),e),this.prefixSum=new Uint32Array(this.values.length),e-1=0&&this.prefixSum.set(r.subarray(0,this.prefixSumValidIndex[0]+1)),!0)},e.prototype.getTotalValue=function(){return 0===this.values.length?0:this._getAccumulatedValue(this.values.length-1)},e.prototype.getAccumulatedValue=function(e){return e<0?0:(e=Z(e),this._getAccumulatedValue(e))},e.prototype._getAccumulatedValue=function(e){if(e<=this.prefixSumValidIndex[0])return this.prefixSum[e];var t=this.prefixSumValidIndex[0]+1;0===t&&(this.prefixSum[0]=this.values[0],t++),e>=this.values.length&&(e=this.values.length-1);for(var n=t;n<=e;n++)this.prefixSum[n]=this.prefixSum[n-1]+this.values[n];return this.prefixSumValidIndex[0]=Math.max(this.prefixSumValidIndex[0],e),this.prefixSum[e]},e.prototype.getIndexOf=function(e){e=Math.floor(e),this.getTotalValue();for(var t=0,n=this.values.length-1,r=0,i=0,o=0;t<=n;)if(r=t+(n-t)/2|0,e<(o=(i=this.prefixSum[r])-this.values[r]))n=r-1;else{if(!(e>=i))break;t=r+1}return new ee(r,e-o)},e}(),ne=(function(){function e(e){this._cacheAccumulatedValueStart=0,this._cache=null,this._actual=new te(e),this._bustCache()}e.prototype._bustCache=function(){this._cacheAccumulatedValueStart=0,this._cache=null},e.prototype.insertValues=function(e,t){this._actual.insertValues(e,t)&&this._bustCache()},e.prototype.changeValue=function(e,t){this._actual.changeValue(e,t)&&this._bustCache()},e.prototype.removeValues=function(e,t){this._actual.removeValues(e,t)&&this._bustCache()},e.prototype.getTotalValue=function(){return this._actual.getTotalValue()},e.prototype.getAccumulatedValue=function(e){return this._actual.getAccumulatedValue(e)},e.prototype.getIndexOf=function(e){if(e=Math.floor(e),null!==this._cache){var t=e-this._cacheAccumulatedValueStart;if(t>=0&&t/?".length;n++){var r="`~!@#$%^&*()-=+[{]}\\|;:'\",.<>/?"[n];e.indexOf(r)>=0||(t+="\\"+r)}return t+="\\s]+)",new RegExp(t,"g")}();var ie=function(){function e(t){var n=J(t);this._defaultValue=n,this._asciiMap=e._createAsciiMap(n),this._map=new Map}return e._createAsciiMap=function(e){for(var t=new Uint8Array(256),n=0;n<256;n++)t[n]=e;return t},e.prototype.set=function(e,t){var n=J(t);e>=0&&e<256?this._asciiMap[e]=n:this._map.set(e,n)},e.prototype.get=function(e){return e>=0&&e<256?this._asciiMap[e]:this._map.get(e)||this._defaultValue},e}(),oe=(function(){function e(){this._actual=new ie(0)}e.prototype.add=function(e){this._actual.set(e,1)},e.prototype.has=function(e){return 1===this._actual.get(e)}}(),function(){function e(e){for(var t=0,n=0,r=0,i=e.length;rt&&(t=l),s>n&&(n=s),(c=o[2])>n&&(n=c)}t++,n++;var u=new $(n,t,0);for(r=0,i=e.length;r=this._maxCharCode?0:this._states.get(e,t)},e}()),se=null;var ue=null;var ae=function(){function e(){}return e._createLink=function(e,t,n,r,i){var o=i-1;do{var s=t.charCodeAt(o);if(2!==e.get(s))break;o--}while(o>r);if(r>0){var u=t.charCodeAt(r-1),a=t.charCodeAt(o);(40===u&&41===a||91===u&&93===a||123===u&&125===a)&&o--}return{range:{startLineNumber:n,startColumn:r+1,endLineNumber:n,endColumn:o+2},url:t.substring(r,o+1)}},e.computeLinks=function(t,n){void 0===n&&(null===se&&(se=new oe([[1,104,2],[1,72,2],[1,102,6],[1,70,6],[2,116,3],[2,84,3],[3,116,4],[3,84,4],[4,112,5],[4,80,5],[5,115,9],[5,83,9],[5,58,10],[6,105,7],[6,73,7],[7,108,8],[7,76,8],[8,101,9],[8,69,9],[9,58,10],[10,47,11],[11,47,12]])),n=se);for(var r=function(){if(null===ue){ue=new ie(0);for(var e=0;e<" \t<>'\"、。。、,.:;?!@#$%&*‘“〈《「『【〔([{「」}])〕】』」》〉”’`~…".length;e++)ue.set(" \t<>'\"、。。、,.:;?!@#$%&*‘“〈《「『【〔([{「」}])〕】』」》〉”’`~…".charCodeAt(e),1);for(e=0;e<".,;".length;e++)ue.set(".,;".charCodeAt(e),2)}return ue}(),i=[],o=1,s=t.getLineCount();o<=s;o++){for(var u=t.getLineContent(o),a=u.length,l=0,c=0,f=0,h=1,d=!1,m=!1,p=!1;l=0?((r+=n?1:-1)<0?r=e.length-1:r%=e.length,e[r]):null},e.INSTANCE=new e,e}();n(3);var ce,fe=function(){function e(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}return e.Undefined=new e(void 0),e}(),he=function(){function e(){this._first=fe.Undefined,this._last=fe.Undefined,this._size=0}return Object.defineProperty(e.prototype,"size",{get:function(){return this._size},enumerable:!0,configurable:!0}),e.prototype.isEmpty=function(){return this._first===fe.Undefined},e.prototype.clear=function(){this._first=fe.Undefined,this._last=fe.Undefined,this._size=0},e.prototype.unshift=function(e){return this._insert(e,!1)},e.prototype.push=function(e){return this._insert(e,!0)},e.prototype._insert=function(e,t){var n=this,r=new fe(e);if(this._first===fe.Undefined)this._first=r,this._last=r;else if(t){var i=this._last;this._last=r,r.prev=i,i.next=r}else{var o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;var s=!1;return function(){s||(s=!0,n._remove(r))}},e.prototype.shift=function(){if(this._first!==fe.Undefined){var e=this._first.element;return this._remove(this._first),e}},e.prototype._remove=function(e){if(e.prev!==fe.Undefined&&e.next!==fe.Undefined){var t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===fe.Undefined&&e.next===fe.Undefined?(this._first=fe.Undefined,this._last=fe.Undefined):e.next===fe.Undefined?(this._last=this._last.prev,this._last.next=fe.Undefined):e.prev===fe.Undefined&&(this._first=this._first.next,this._first.prev=fe.Undefined);this._size-=1},e.prototype.iterator=function(){var e,t=this._first;return{next:function(){return t===fe.Undefined?A:(e?e.value=t.element:e={done:!1,value:t.element},t=t.next,e)}}},e.prototype.toArray=function(){for(var e=[],t=this._first;t!==fe.Undefined;t=t.next)e.push(t.element);return e},e}(),de=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();!function(e){var t={dispose:function(){}};function n(e){return function(t,n,r){void 0===n&&(n=null);var i,o=!1;return i=e((function(e){if(!o)return i?i.dispose():o=!0,t.call(n,e)}),null,r),o&&i.dispose(),i}}function r(e,t){return u((function(n,r,i){return void 0===r&&(r=null),e((function(e){return n.call(r,t(e))}),null,i)}))}function i(e,t){return u((function(n,r,i){return void 0===r&&(r=null),e((function(e){t(e),n.call(r,e)}),null,i)}))}function o(e,t){return u((function(n,r,i){return void 0===r&&(r=null),e((function(e){return t(e)&&n.call(r,e)}),null,i)}))}function s(e,t,n){var i=n;return r(e,(function(e){return i=t(i,e)}))}function u(e){var t,n=new ge({onFirstListenerAdd:function(){t=e(n.fire,n)},onLastListenerRemove:function(){t.dispose()}});return n.event}function a(e){var t,n=!0;return o(e,(function(e){var r=n||e!==t;return n=!1,t=e,r}))}e.None=function(){return t},e.once=n,e.map=r,e.forEach=i,e.filter=o,e.signal=function(e){return e},e.any=function(){for(var e=[],t=0;t1)&&l.fire(e),a=0}),n)}))},onLastListenerRemove:function(){o.dispose()}});return l.event},e.stopwatch=function(e){var t=(new Date).getTime();return r(n(e),(function(e){return(new Date).getTime()-t}))},e.latch=a,e.buffer=function(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=[]);var r=n.slice(),i=e((function(e){r?r.push(e):s.fire(e)})),o=function(){r&&r.forEach((function(e){return s.fire(e)})),r=null},s=new ge({onFirstListenerAdd:function(){i||(i=e((function(e){return s.fire(e)})))},onFirstListenerDidAdd:function(){r&&(t?setTimeout(o):o())},onLastListenerRemove:function(){i&&i.dispose(),i=null}});return s.event};var c=function(){function e(e){this.event=e}return e.prototype.map=function(t){return new e(r(this.event,t))},e.prototype.forEach=function(t){return new e(i(this.event,t))},e.prototype.filter=function(t){return new e(o(this.event,t))},e.prototype.reduce=function(t,n){return new e(s(this.event,t,n))},e.prototype.latch=function(){return new e(a(this.event))},e.prototype.on=function(e,t,n){return this.event(e,t,n)},e.prototype.once=function(e,t,r){return n(this.event)(e,t,r)},e}();e.chain=function(e){return new c(e)},e.fromNodeEventEmitter=function(e,t,n){void 0===n&&(n=function(e){return e});var r=function(){for(var e=[],t=0;t0;){var r=this._deliveryQueue.shift(),i=r[0],s=r[1];try{"function"==typeof i?i.call(void 0,s):i[0].call(i[1],s)}catch(n){o(n)}}}},e.prototype.dispose=function(){this._listeners&&this._listeners.clear(),this._deliveryQueue&&this._deliveryQueue.clear(),this._leakageMon&&this._leakageMon.dispose(),this._disposed=!0},e._noop=function(){},e}(),_e=(function(e){function t(t){var n=e.call(this,t)||this;return n._isPaused=0,n._eventQueue=new he,n._mergeFn=t&&t.merge,n}de(t,e),t.prototype.pause=function(){this._isPaused++},t.prototype.resume=function(){if(0!==this._isPaused&&0==--this._isPaused)if(this._mergeFn){var t=this._eventQueue.toArray();this._eventQueue.clear(),e.prototype.fire.call(this,this._mergeFn(t))}else for(;!this._isPaused&&0!==this._eventQueue.size;)e.prototype.fire.call(this,this._eventQueue.shift())},t.prototype.fire=function(t){this._listeners&&(0!==this._isPaused?this._eventQueue.push(t):e.prototype.fire.call(this,t))}}(ge),function(){function e(){var e=this;this.hasListeners=!1,this.events=[],this.emitter=new ge({onFirstListenerAdd:function(){return e.onFirstListenerAdd()},onLastListenerRemove:function(){return e.onLastListenerRemove()}})}Object.defineProperty(e.prototype,"event",{get:function(){return this.emitter.event},enumerable:!0,configurable:!0}),e.prototype.add=function(e){var t=this,n={event:e,listener:null};this.events.push(n),this.hasListeners&&this.hook(n);return function(e){return{dispose:function(){e()}}}(function(e){var t,n=this,r=!1;return function(){return r?t:(r=!0,t=e.apply(n,arguments))}}((function(){t.hasListeners&&t.unhook(n);var e=t.events.indexOf(n);t.events.splice(e,1)})))},e.prototype.onFirstListenerAdd=function(){var e=this;this.hasListeners=!0,this.events.forEach((function(t){return e.hook(t)}))},e.prototype.onLastListenerRemove=function(){var e=this;this.hasListeners=!1,this.events.forEach((function(t){return e.unhook(t)}))},e.prototype.hook=function(e){var t=this;e.listener=e.event((function(e){return t.emitter.fire(e)}))},e.prototype.unhook=function(e){e.listener&&e.listener.dispose(),e.listener=null},e.prototype.dispose=function(){this.emitter.dispose()}}(),function(){function e(){this.buffers=[]}e.prototype.wrapEvent=function(e){var t=this;return function(n,r,i){return e((function(e){var i=t.buffers[t.buffers.length-1];i?i.push((function(){return n.call(r,e)})):n.call(r,e)}),void 0,i)}},e.prototype.bufferEvents=function(e){var t=[];this.buffers.push(t);var n=e();return this.buffers.pop(),t.forEach((function(e){return e()})),n}}(),function(){function e(){var e=this;this.listening=!1,this.inputEvent=ce.None,this.inputEventListener=c.None,this.emitter=new ge({onFirstListenerDidAdd:function(){e.listening=!0,e.inputEventListener=e.inputEvent(e.emitter.fire,e.emitter)},onLastListenerRemove:function(){e.listening=!1,e.inputEventListener.dispose()}}),this.event=this.emitter.event}Object.defineProperty(e.prototype,"input",{set:function(e){this.inputEvent=e,this.listening&&(this.inputEventListener.dispose(),this.inputEventListener=e(this.emitter.fire,this.emitter))},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){this.inputEventListener.dispose(),this.emitter.dispose()}}(),Object.freeze((function(e,t){var n=setTimeout(e.bind(t),0);return{dispose:function(){clearTimeout(n)}}})));(pe=me||(me={})).isCancellationToken=function(e){return e===pe.None||e===pe.Cancelled||e instanceof ye||!(!e||"object"!=typeof e)&&"boolean"==typeof e.isCancellationRequested&&"function"==typeof e.onCancellationRequested},pe.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:ce.None}),pe.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:_e});var ve,ye=function(){function e(){this._isCancelled=!1,this._emitter=null}return e.prototype.cancel=function(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))},Object.defineProperty(e.prototype,"isCancellationRequested",{get:function(){return this._isCancelled},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onCancellationRequested",{get:function(){return this._isCancelled?_e:(this._emitter||(this._emitter=new ge),this._emitter.event)},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){this._emitter&&(this._emitter.dispose(),this._emitter=null)},e}(),Ce=function(){function e(e){this._token=void 0,this._parentListener=void 0,this._parentListener=e&&e.onCancellationRequested(this.cancel,this)}return Object.defineProperty(e.prototype,"token",{get:function(){return this._token||(this._token=new ye),this._token},enumerable:!0,configurable:!0}),e.prototype.cancel=function(){this._token?this._token instanceof ye&&this._token.cancel():this._token=me.Cancelled},e.prototype.dispose=function(){this._parentListener&&this._parentListener.dispose(),this._token?this._token instanceof ye&&this._token.dispose():this._token=me.None},e}(),be=function(){function e(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}return e.prototype.define=function(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e},e.prototype.keyCodeToStr=function(e){return this._keyCodeToStr[e]},e.prototype.strToKeyCode=function(e){return this._strToKeyCode[e.toLowerCase()]||0},e}(),Le=new be,Ne=new be,Ee=new be;!function(){function e(e,t,n,r){void 0===n&&(n=t),void 0===r&&(r=n),Le.define(e,t),Ne.define(e,n),Ee.define(e,r)}e(0,"unknown"),e(1,"Backspace"),e(2,"Tab"),e(3,"Enter"),e(4,"Shift"),e(5,"Ctrl"),e(6,"Alt"),e(7,"PauseBreak"),e(8,"CapsLock"),e(9,"Escape"),e(10,"Space"),e(11,"PageUp"),e(12,"PageDown"),e(13,"End"),e(14,"Home"),e(15,"LeftArrow","Left"),e(16,"UpArrow","Up"),e(17,"RightArrow","Right"),e(18,"DownArrow","Down"),e(19,"Insert"),e(20,"Delete"),e(21,"0"),e(22,"1"),e(23,"2"),e(24,"3"),e(25,"4"),e(26,"5"),e(27,"6"),e(28,"7"),e(29,"8"),e(30,"9"),e(31,"A"),e(32,"B"),e(33,"C"),e(34,"D"),e(35,"E"),e(36,"F"),e(37,"G"),e(38,"H"),e(39,"I"),e(40,"J"),e(41,"K"),e(42,"L"),e(43,"M"),e(44,"N"),e(45,"O"),e(46,"P"),e(47,"Q"),e(48,"R"),e(49,"S"),e(50,"T"),e(51,"U"),e(52,"V"),e(53,"W"),e(54,"X"),e(55,"Y"),e(56,"Z"),e(57,"Meta"),e(58,"ContextMenu"),e(59,"F1"),e(60,"F2"),e(61,"F3"),e(62,"F4"),e(63,"F5"),e(64,"F6"),e(65,"F7"),e(66,"F8"),e(67,"F9"),e(68,"F10"),e(69,"F11"),e(70,"F12"),e(71,"F13"),e(72,"F14"),e(73,"F15"),e(74,"F16"),e(75,"F17"),e(76,"F18"),e(77,"F19"),e(78,"NumLock"),e(79,"ScrollLock"),e(80,";",";","OEM_1"),e(81,"=","=","OEM_PLUS"),e(82,",",",","OEM_COMMA"),e(83,"-","-","OEM_MINUS"),e(84,".",".","OEM_PERIOD"),e(85,"/","/","OEM_2"),e(86,"`","`","OEM_3"),e(110,"ABNT_C1"),e(111,"ABNT_C2"),e(87,"[","[","OEM_4"),e(88,"\\","\\","OEM_5"),e(89,"]","]","OEM_6"),e(90,"'","'","OEM_7"),e(91,"OEM_8"),e(92,"OEM_102"),e(93,"NumPad0"),e(94,"NumPad1"),e(95,"NumPad2"),e(96,"NumPad3"),e(97,"NumPad4"),e(98,"NumPad5"),e(99,"NumPad6"),e(100,"NumPad7"),e(101,"NumPad8"),e(102,"NumPad9"),e(103,"NumPad_Multiply"),e(104,"NumPad_Add"),e(105,"NumPad_Separator"),e(106,"NumPad_Subtract"),e(107,"NumPad_Decimal"),e(108,"NumPad_Divide")}(),function(e){e.toString=function(e){return Le.keyCodeToStr(e)},e.fromString=function(e){return Le.strToKeyCode(e)},e.toUserSettingsUS=function(e){return Ne.keyCodeToStr(e)},e.toUserSettingsGeneral=function(e){return Ee.keyCodeToStr(e)},e.fromUserSettings=function(e){return Ne.strToKeyCode(e)||Ee.strToKeyCode(e)}}(ve||(ve={}));!function(){function e(e,t,n,r,i){this.ctrlKey=e,this.shiftKey=t,this.altKey=n,this.metaKey=r,this.keyCode=i}e.prototype.equals=function(e){return this.ctrlKey===e.ctrlKey&&this.shiftKey===e.shiftKey&&this.altKey===e.altKey&&this.metaKey===e.metaKey&&this.keyCode===e.keyCode},e.prototype.isModifierKey=function(){return 0===this.keyCode||5===this.keyCode||57===this.keyCode||6===this.keyCode||4===this.keyCode},e.prototype.toChord=function(){return new Je([this])},e.prototype.isDuplicateModifierCase=function(){return this.ctrlKey&&5===this.keyCode||this.shiftKey&&4===this.keyCode||this.altKey&&6===this.keyCode||this.metaKey&&57===this.keyCode}}();var Se,we,Ae,Te,Me,Pe,Oe,xe,Ie,Re,ke,Ue,Fe,De,Ke,qe,Ve,Be,je,Ye,We,He,Ge,Qe,ze,Xe,$e,Je=function(){function e(e){if(0===e.length)throw(t="parts")?new Error("Illegal argument: "+t):new Error("Illegal argument");var t;this.parts=e}return e.prototype.equals=function(e){if(null===e)return!1;if(this.parts.length!==e.parts.length)return!1;for(var t=0;t "+this.positionLineNumber+","+this.positionColumn+"]"},t.prototype.equalsSelection=function(e){return t.selectionsEqual(this,e)},t.selectionsEqual=function(e,t){return e.selectionStartLineNumber===t.selectionStartLineNumber&&e.selectionStartColumn===t.selectionStartColumn&&e.positionLineNumber===t.positionLineNumber&&e.positionColumn===t.positionColumn},t.prototype.getDirection=function(){return this.selectionStartLineNumber===this.startLineNumber&&this.selectionStartColumn===this.startColumn?0:1},t.prototype.setEndPosition=function(e,n){return 0===this.getDirection()?new t(this.startLineNumber,this.startColumn,e,n):new t(e,n,this.startLineNumber,this.startColumn)},t.prototype.getPosition=function(){return new j(this.positionLineNumber,this.positionColumn)},t.prototype.setStartPosition=function(e,n){return 0===this.getDirection()?new t(e,n,this.endLineNumber,this.endColumn):new t(this.endLineNumber,this.endColumn,e,n)},t.fromPositions=function(e,n){return void 0===n&&(n=e),new t(e.lineNumber,e.column,n.lineNumber,n.column)},t.liftSelection=function(e){return new t(e.selectionStartLineNumber,e.selectionStartColumn,e.positionLineNumber,e.positionColumn)},t.selectionsArrEqual=function(e,t){if(e&&!t||!e&&t)return!1;if(!e&&!t)return!0;if(e.length!==t.length)return!1;for(var n=0,r=e.length;n>>0)>>>0}(e,t)},e.CtrlCmd=2048,e.Shift=1024,e.Alt=512,e.WinCtrl=256,e}();var rt=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),it=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return rt(t,e),Object.defineProperty(t.prototype,"uri",{get:function(){return this._uri},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"version",{get:function(){return this._versionId},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"eol",{get:function(){return this._eol},enumerable:!0,configurable:!0}),t.prototype.getValue=function(){return this.getText()},t.prototype.getLinesContent=function(){return this._lines.slice(0)},t.prototype.getLineCount=function(){return this._lines.length},t.prototype.getLineContent=function(e){return this._lines[e-1]},t.prototype.getWordAtPosition=function(e,t){var n=function(e,t,n,r){t.lastIndex=0;var i=t.exec(n);if(!i)return null;var o=i[0].indexOf(" ")>=0?function(e,t,n,r){var i,o=e-1-r;for(t.lastIndex=0;i=t.exec(n);){var s=i.index||0;if(s>o)return null;if(t.lastIndex>=o)return{word:i[0],startColumn:r+1+s,endColumn:r+1+t.lastIndex}}return null}(e,t,n,r):function(e,t,n,r){var i,o=e-1-r,s=n.lastIndexOf(" ",o-1)+1;for(t.lastIndex=s;i=t.exec(n);){var u=i.index||0;if(u<=o&&t.lastIndex>=o)return{word:i[0],startColumn:r+1+u,endColumn:r+1+t.lastIndex}}return null}(e,t,n,r);return t.lastIndex=0,o}(e.column,function(e){var t=re;if(e&&e instanceof RegExp)if(e.global)t=e;else{var n="g";e.ignoreCase&&(n+="i"),e.multiline&&(n+="m"),e.unicode&&(n+="u"),t=new RegExp(e.source,n)}return t.lastIndex=0,t}(t),this._lines[e.lineNumber-1],0);return n?new Y(e.lineNumber,n.startColumn,e.lineNumber,n.endColumn):null},t.prototype.getWordUntilPosition=function(e,t){var n=this.getWordAtPosition(e,t);return n?{word:this._lines[e.lineNumber-1].substring(n.startColumn-1,e.column-1),startColumn:n.startColumn,endColumn:e.column}:{word:"",startColumn:e.column,endColumn:e.column}},t.prototype.createWordIterator=function(e){var t,n,r=this,i=0,o=0,s=[],u=function(){if(o=r._lines.length?A:(n=r._lines[i],s=r._wordenize(n,e),o=0,i+=1,u())};return{next:u}},t.prototype.getLineWords=function(e,t){for(var n=this._lines[e-1],r=[],i=0,o=this._wordenize(n,t);ithis._lines.length)t=this._lines.length,n=this._lines[t-1].length+1,r=!0;else{var i=this._lines[t-1].length+1;n<1?(n=1,r=!0):n>i&&(n=i,r=!0)}return r?{lineNumber:t,column:n}:e},t}(ne),ot=function(e){function t(t){var n=e.call(this,t)||this;return n._models=Object.create(null),n}return rt(t,e),t.prototype.dispose=function(){this._models=Object.create(null)},t.prototype._getModel=function(e){return this._models[e]},t.prototype._getModels=function(){var e=this,t=[];return Object.keys(this._models).forEach((function(n){return t.push(e._models[n])})),t},t.prototype.acceptNewModel=function(e){this._models[e.url]=new it(U.parse(e.url),e.lines,e.EOL,e.versionId)},t.prototype.acceptModelChanged=function(e,t){this._models[e]&&this._models[e].onEvents(t)},t.prototype.acceptRemovedModel=function(e){this._models[e]&&delete this._models[e]},t}(function(){function e(e){this._foreignModuleFactory=e,this._foreignModule=null}return e.prototype.computeDiff=function(e,t,n){var r=this._getModel(e),i=this._getModel(t);if(!r||!i)return Promise.resolve(null);var o=r.getLinesContent(),s=i.getLinesContent(),u=new X(o,s,{shouldComputeCharChanges:!0,shouldPostProcessCharChanges:!0,shouldIgnoreTrimWhitespace:n,shouldMakePrettyDiff:!0}).computeDiff(),a=!(u.length>0)&&this._modelsAreIdentical(r,i);return Promise.resolve({identical:a,changes:u})},e.prototype._modelsAreIdentical=function(e,t){var n=e.getLineCount();if(n!==t.getLineCount())return!1;for(var r=1;r<=n;r++){if(e.getLineContent(r)!==t.getLineContent(r))return!1}return!0},e.prototype.computeMoreMinimalEdits=function(t,n){var r=this._getModel(t);if(!r)return Promise.resolve(n);for(var i=[],o=void 0,s=0,u=n=_(n,(function(e,t){return e.range&&t.range?Y.compareRangesUsingStarts(e.range,t.range):(e.range?0:1)-(t.range?0:1)}));se._diffLimit)i.push({range:l,text:c});else for(var d=C(h,c,!1),m=r.offsetAt(Y.lift(l).getStartPosition()),p=0,g=d;p{let e,t,n,r,i,o={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},s=function(t){throw{at:e,text:t,message:t}},u=function(t){return t&&t!==n&&s("Expected '"+t+"' instead of '"+n+"'"),n=r.charAt(e),e+=1,n},a=function(t,i){let o=e,u=r.indexOf(t,o);var a;return u<0&&s(i||"Expected '"+t+"'"),a=u+t.length,n=r.charAt(a),e=a+1,r.substring(o,u)},l=function(){var e,t="";for("-"===n&&(t="-",u("-"));n>="0"&&"9">=n;)t+=n,u();if("."===n)for(t+=".";u()&&n>="0"&&"9">=n;)t+=n;if("e"===n||"E"===n)for(t+=n,u(),("-"===n||"+"===n)&&(t+=n,u());n>="0"&&"9">=n;)t+=n,u();return e=+t,isNaN(e)?void s("Bad number"):e},c=function(){let t,i,l,c="";if('"'===n){if(f='""',r.substr(e,f.length)===f)return u('"'),u('"'),a('"""','failed to find closing \'"""\'');for(;u();){if('"'===n)return u(),c;if("\\"===n)if(u(),"u"===n){for(l=0,i=0;4>i&&(t=parseInt(u(),16),isFinite(t));i+=1)l=16*l+t;c+=String.fromCharCode(l)}else{if("string"!=typeof o[n])break;c+=o[n]}else c+=n}}var f;s("Bad string")},f=function(){for(;n&&" ">=n;)u()};return i=function(){switch(f(),n){case"{":return function(){var r,o,a,l={};if("{"===n){if(u("{"),f(),"}"===n)return u("}"),l;for(;n;){let s=e;if(r=c(),f(),u(":"),Object.hasOwnProperty.call(l,r)&&(o='Duplicate key "'+r+'"',a=s,t.push({type:at.warning,at:a,text:o})),l[r]=i(),f(),"}"===n)return u("}"),l;u(","),f()}}s("Bad object")}();case"[":return function(){var e=[];if("["===n){if(u("["),f(),"]"===n)return u("]"),e;for(;n;){if(e.push(i()),f(),"]"===n)return u("]"),e;u(","),f()}}s("Bad array")}();case'"':return c();case"-":return l();default:return n>="0"&&"9">=n?l():function(){switch(n){case"t":return u("t"),u("r"),u("u"),u("e"),!0;case"f":return u("f"),u("a"),u("l"),u("s"),u("e"),!1;case"n":return u("n"),u("u"),u("l"),u("l"),null}s("Unexpected '"+n+"'")}()}},function(o){t=[];let u=!1;r=o,e=0,n=" ",f();try{i()}catch(e){u=!0,t.push({type:at.error,at:e.at-1,text:e.message})}return!u&&n&&s("Syntax error"),{annotations:t}}};class ct{constructor(e){this.ctx=e}async parse(){this.parser||(this.parser=r.createParser());const[e]=this.ctx.getMirrorModels();return this.parser(e.getValue())}}self.onmessage=()=>{ut((e,t)=>new ct(e))}}]); \ No newline at end of file diff --git a/packages/kbn-ui-shared-deps/package.json b/packages/kbn-ui-shared-deps/package.json index d34fe3624ab266..177acfb1c9aba7 100644 --- a/packages/kbn-ui-shared-deps/package.json +++ b/packages/kbn-ui-shared-deps/package.json @@ -12,6 +12,7 @@ "@elastic/charts": "19.2.0", "@elastic/eui": "23.3.1", "@kbn/i18n": "1.0.0", + "@kbn/monaco": "1.0.0", "abortcontroller-polyfill": "^1.4.0", "angular": "^1.7.9", "compression-webpack-plugin": "^3.1.0", @@ -21,7 +22,6 @@ "jquery": "^3.5.0", "moment": "^2.24.0", "moment-timezone": "^0.5.27", - "monaco-editor": "~0.17.0", "react": "^16.12.0", "react-dom": "^16.12.0", "react-intl": "^2.8.0", diff --git a/packages/kbn-ui-shared-deps/webpack.config.js b/packages/kbn-ui-shared-deps/webpack.config.js index 9abd00a5b401f1..158a972a70f9a6 100644 --- a/packages/kbn-ui-shared-deps/webpack.config.js +++ b/packages/kbn-ui-shared-deps/webpack.config.js @@ -79,7 +79,7 @@ exports.getWebpackConfig = ({ dev = false } = {}) => ({ use: [MiniCssExtractPlugin.loader, 'css-loader'], }, { - include: [require.resolve('./monaco/index.ts')], + include: [require.resolve('./monaco.ts')], use: [ { loader: 'babel-loader', From a2e2550e25b5313c7c5388a492ead23a0635dddc Mon Sep 17 00:00:00 2001 From: spalger Date: Fri, 29 May 2020 11:13:47 -0700 Subject: [PATCH 10/26] always access monaco through `@kbn/monaco` --- packages/eslint-config-kibana/.eslintrc.js | 9 +++++++++ packages/kbn-monaco/index.ts | 7 ++++++- packages/kbn-monaco/monaco.ts | 4 ++-- .../kbn-monaco/xjson/lexer_rules/index.ts | 1 + .../kbn-monaco/xjson/worker/xjson.worker.ts | 2 ++ .../kbn-monaco/xjson/worker/xjson_worker.ts | 1 + packages/kbn-ui-shared-deps/entry.js | 4 ++-- packages/kbn-ui-shared-deps/index.js | 4 ++-- packages/kbn-ui-shared-deps/monaco.ts | 20 ------------------- .../monaco/use_xjson_mode.ts | 2 +- .../code_editor/code_editor.examples.tsx | 2 +- .../public/code_editor/code_editor.test.tsx | 4 +++- .../public/code_editor/code_editor.tsx | 2 +- .../public/code_editor/editor_theme.ts | 2 +- .../components/timelion_expression_input.tsx | 2 +- .../timelion_expression_input_helpers.ts | 2 +- .../expression_input.examples.tsx | 2 +- .../expression_input/expression_input.tsx | 2 +- .../canvas/public/lib/monaco_language_def.ts | 2 +- .../components/output_pane/parameters_tab.tsx | 2 +- .../public/lib/monaco_painless_lang.ts | 2 +- .../public/services/language_service.ts | 2 +- 22 files changed, 40 insertions(+), 40 deletions(-) delete mode 100644 packages/kbn-ui-shared-deps/monaco.ts diff --git a/packages/eslint-config-kibana/.eslintrc.js b/packages/eslint-config-kibana/.eslintrc.js index 624ee4679a3b91..594dbbc60ba53a 100644 --- a/packages/eslint-config-kibana/.eslintrc.js +++ b/packages/eslint-config-kibana/.eslintrc.js @@ -52,6 +52,15 @@ module.exports = { from: 'react-router', to: 'react-router-dom', }, + { + from: '@kbn/ui-shared-deps/monaco', + to: '@kbn/monaco', + }, + { + from: 'monaco-editor', + to: false, + disallowedMessage: `Don't import monaco directly, use or add exports to @kbn/monaco` + }, ], ], }, diff --git a/packages/kbn-monaco/index.ts b/packages/kbn-monaco/index.ts index ad74ca76c0dd0f..6f322b9a872ce6 100644 --- a/packages/kbn-monaco/index.ts +++ b/packages/kbn-monaco/index.ts @@ -17,4 +17,9 @@ * under the License. */ -export * from './monaco'; +export { monaco } from './monaco'; +export { XJsonLang } from './xjson'; + +/* eslint-disable-next-line @kbn/eslint/module_migration */ +import BarePluginApi from 'monaco-editor/esm/vs/editor/editor.api'; +export { BarePluginApi }; diff --git a/packages/kbn-monaco/monaco.ts b/packages/kbn-monaco/monaco.ts index c29282865131ef..a40b2212ef0e23 100644 --- a/packages/kbn-monaco/monaco.ts +++ b/packages/kbn-monaco/monaco.ts @@ -17,6 +17,8 @@ * under the License. */ +/* eslint-disable @kbn/eslint/module_migration */ + import * as monaco from 'monaco-editor/esm/vs/editor/editor.api'; import 'monaco-editor/esm/vs/base/common/worker/simpleWorker'; @@ -31,6 +33,4 @@ import 'monaco-editor/esm/vs/editor/contrib/suggest/suggestController.js'; // Ne import 'monaco-editor/esm/vs/editor/contrib/hover/hover.js'; // Needed for hover import 'monaco-editor/esm/vs/editor/contrib/parameterHints/parameterHints.js'; // Needed for signature -export { XJsonLang } from './xjson'; - export { monaco }; diff --git a/packages/kbn-monaco/xjson/lexer_rules/index.ts b/packages/kbn-monaco/xjson/lexer_rules/index.ts index 7063fb0aa8f8b8..515de09510a617 100644 --- a/packages/kbn-monaco/xjson/lexer_rules/index.ts +++ b/packages/kbn-monaco/xjson/lexer_rules/index.ts @@ -17,6 +17,7 @@ * under the License. */ +/* eslint-disable-next-line @kbn/eslint/module_migration */ import * as monaco from 'monaco-editor/esm/vs/editor/editor.api'; import * as xJson from './xjson'; import * as esql from './esql'; diff --git a/packages/kbn-monaco/xjson/worker/xjson.worker.ts b/packages/kbn-monaco/xjson/worker/xjson.worker.ts index 5e6482fcbda65b..9eac0d914211c9 100644 --- a/packages/kbn-monaco/xjson/worker/xjson.worker.ts +++ b/packages/kbn-monaco/xjson/worker/xjson.worker.ts @@ -19,8 +19,10 @@ // Please note: this module is intended to be run inside of a webworker. +/* eslint-disable @kbn/eslint/module_migration */ // @ts-ignore import * as worker from 'monaco-editor/esm/vs/editor/editor.worker'; +/* eslint-enable @kbn/eslint/module_migration */ import { XJsonWorker } from './xjson_worker'; self.onmessage = () => { diff --git a/packages/kbn-monaco/xjson/worker/xjson_worker.ts b/packages/kbn-monaco/xjson/worker/xjson_worker.ts index 5bc0f9fb91ab93..501adcacb69902 100644 --- a/packages/kbn-monaco/xjson/worker/xjson_worker.ts +++ b/packages/kbn-monaco/xjson/worker/xjson_worker.ts @@ -17,6 +17,7 @@ * under the License. */ +/* eslint-disable-next-line @kbn/eslint/module_migration */ import * as monaco from 'monaco-editor/esm/vs/editor/editor.api'; import { createParser } from '../grammar'; diff --git a/packages/kbn-ui-shared-deps/entry.js b/packages/kbn-ui-shared-deps/entry.js index 26efd174f4e39a..90ed5136a33440 100644 --- a/packages/kbn-ui-shared-deps/entry.js +++ b/packages/kbn-ui-shared-deps/entry.js @@ -30,8 +30,8 @@ export const KbnI18nReact = require('@kbn/i18n/react'); export const Angular = require('angular'); export const Moment = require('moment'); export const MomentTimezone = require('moment-timezone/moment-timezone'); -export const Monaco = require('./monaco.ts'); -export const MonacoBare = require('monaco-editor/esm/vs/editor/editor.api'); +export const KbnMonaco = require('@kbn/monaco'); +export const MonacoBarePluginApi = require('@kbn/monaco').BarePluginApi; export const React = require('react'); export const ReactDom = require('react-dom'); export const ReactDomServer = require('react-dom/server'); diff --git a/packages/kbn-ui-shared-deps/index.js b/packages/kbn-ui-shared-deps/index.js index 9aec3ab3599242..2dec639a23787b 100644 --- a/packages/kbn-ui-shared-deps/index.js +++ b/packages/kbn-ui-shared-deps/index.js @@ -42,9 +42,9 @@ exports.externals = { 'react-intl': '__kbnSharedDeps__.ReactIntl', 'react-router': '__kbnSharedDeps__.ReactRouter', 'react-router-dom': '__kbnSharedDeps__.ReactRouterDom', - '@kbn/ui-shared-deps/monaco': '__kbnSharedDeps__.Monaco', + '@kbn/monaco': '__kbnSharedDeps__.KbnMonaco', // this is how plugins/consumers from npm load monaco - 'monaco-editor/esm/vs/editor/editor.api': '__kbnSharedDeps__.MonacoBare', + 'monaco-editor/esm/vs/editor/editor.api': '__kbnSharedDeps__.MonacoBarePluginApi', /** * big deps which are locked to a single version diff --git a/packages/kbn-ui-shared-deps/monaco.ts b/packages/kbn-ui-shared-deps/monaco.ts deleted file mode 100644 index dc57a07055e050..00000000000000 --- a/packages/kbn-ui-shared-deps/monaco.ts +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -export { monaco, XJsonLang } from '@kbn/monaco/monaco'; diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/use_xjson_mode.ts b/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/use_xjson_mode.ts index 8e71e50fa72043..b783045492f056 100644 --- a/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/use_xjson_mode.ts +++ b/src/plugins/es_ui_shared/__packages_do_not_import__/monaco/use_xjson_mode.ts @@ -17,7 +17,7 @@ * under the License. */ -import { XJsonLang } from '@kbn/ui-shared-deps/monaco'; +import { XJsonLang } from '@kbn/monaco'; import { useXJsonMode as useBaseXJsonMode } from '../xjson'; interface ReturnValue extends ReturnType { diff --git a/src/plugins/kibana_react/public/code_editor/code_editor.examples.tsx b/src/plugins/kibana_react/public/code_editor/code_editor.examples.tsx index b6d5f2c5460f6c..892c97e0ffae08 100644 --- a/src/plugins/kibana_react/public/code_editor/code_editor.examples.tsx +++ b/src/plugins/kibana_react/public/code_editor/code_editor.examples.tsx @@ -20,7 +20,7 @@ import { action } from '@storybook/addon-actions'; import { storiesOf } from '@storybook/react'; import React from 'react'; -import { monaco as monacoEditor } from '@kbn/ui-shared-deps/monaco'; +import { monaco as monacoEditor } from '@kbn/monaco'; import { CodeEditor } from './code_editor'; // A sample language definition with a few example tokens diff --git a/src/plugins/kibana_react/public/code_editor/code_editor.test.tsx b/src/plugins/kibana_react/public/code_editor/code_editor.test.tsx index bcb46fac368561..2f0670226cf469 100644 --- a/src/plugins/kibana_react/public/code_editor/code_editor.test.tsx +++ b/src/plugins/kibana_react/public/code_editor/code_editor.test.tsx @@ -19,9 +19,11 @@ import React from 'react'; import { CodeEditor } from './code_editor'; -import { monaco } from '@kbn/ui-shared-deps/monaco'; +import { monaco } from '@kbn/monaco'; import { shallow } from 'enzyme'; +// disabled because this is a test, but also it seems we shouldn't need this? +/* eslint-disable-next-line @kbn/eslint/module_migration */ import 'monaco-editor/esm/vs/basic-languages/html/html.contribution.js'; // A sample language definition with a few example tokens diff --git a/src/plugins/kibana_react/public/code_editor/code_editor.tsx b/src/plugins/kibana_react/public/code_editor/code_editor.tsx index e8b118b804347e..f049085ccff61d 100644 --- a/src/plugins/kibana_react/public/code_editor/code_editor.tsx +++ b/src/plugins/kibana_react/public/code_editor/code_editor.tsx @@ -21,7 +21,7 @@ import React from 'react'; import ReactResizeDetector from 'react-resize-detector'; import MonacoEditor from 'react-monaco-editor'; -import { monaco } from '@kbn/ui-shared-deps/monaco'; +import { monaco } from '@kbn/monaco'; import { LIGHT_THEME, DARK_THEME } from './editor_theme'; diff --git a/src/plugins/kibana_react/public/code_editor/editor_theme.ts b/src/plugins/kibana_react/public/code_editor/editor_theme.ts index 586b4a568c348a..91d66ce8cbf81a 100644 --- a/src/plugins/kibana_react/public/code_editor/editor_theme.ts +++ b/src/plugins/kibana_react/public/code_editor/editor_theme.ts @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { monaco } from '@kbn/ui-shared-deps/monaco'; +import { monaco } from '@kbn/monaco'; import darkTheme from '@elastic/eui/dist/eui_theme_dark.json'; import lightTheme from '@elastic/eui/dist/eui_theme_light.json'; diff --git a/src/plugins/vis_type_timelion/public/components/timelion_expression_input.tsx b/src/plugins/vis_type_timelion/public/components/timelion_expression_input.tsx index 8c76b41df0cedb..8258b92b096c1b 100644 --- a/src/plugins/vis_type_timelion/public/components/timelion_expression_input.tsx +++ b/src/plugins/vis_type_timelion/public/components/timelion_expression_input.tsx @@ -20,7 +20,7 @@ import React, { useEffect, useCallback, useRef, useMemo } from 'react'; import { EuiFormLabel } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; -import { monaco } from '@kbn/ui-shared-deps/monaco'; +import { monaco } from '@kbn/monaco'; import { CodeEditor, useKibana } from '../../../kibana_react/public'; import { suggest, getSuggestion } from './timelion_expression_input_helpers'; diff --git a/src/plugins/vis_type_timelion/public/components/timelion_expression_input_helpers.ts b/src/plugins/vis_type_timelion/public/components/timelion_expression_input_helpers.ts index f7b3433105b76b..8db057cdb3cc55 100644 --- a/src/plugins/vis_type_timelion/public/components/timelion_expression_input_helpers.ts +++ b/src/plugins/vis_type_timelion/public/components/timelion_expression_input_helpers.ts @@ -19,7 +19,7 @@ import { get, startsWith } from 'lodash'; import { i18n } from '@kbn/i18n'; -import { monaco } from '@kbn/ui-shared-deps/monaco'; +import { monaco } from '@kbn/monaco'; import { Parser } from 'pegjs'; diff --git a/x-pack/plugins/canvas/public/components/expression_input/__examples__/expression_input.examples.tsx b/x-pack/plugins/canvas/public/components/expression_input/__examples__/expression_input.examples.tsx index 51caf1db196bc7..d010f4a554b871 100644 --- a/x-pack/plugins/canvas/public/components/expression_input/__examples__/expression_input.examples.tsx +++ b/x-pack/plugins/canvas/public/components/expression_input/__examples__/expression_input.examples.tsx @@ -7,7 +7,7 @@ import { action } from '@storybook/addon-actions'; import { storiesOf } from '@storybook/react'; import React from 'react'; -import { monaco } from '@kbn/ui-shared-deps/monaco'; +import { monaco } from '@kbn/monaco'; import { ExpressionInput } from '../expression_input'; import { language, LANGUAGE_ID } from '../../../lib/monaco_language_def'; diff --git a/x-pack/plugins/canvas/public/components/expression_input/expression_input.tsx b/x-pack/plugins/canvas/public/components/expression_input/expression_input.tsx index 99e12b14104be1..5ada495208fba1 100644 --- a/x-pack/plugins/canvas/public/components/expression_input/expression_input.tsx +++ b/x-pack/plugins/canvas/public/components/expression_input/expression_input.tsx @@ -8,7 +8,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { EuiFormRow } from '@elastic/eui'; import { debounce } from 'lodash'; -import { monaco } from '@kbn/ui-shared-deps/monaco'; +import { monaco } from '@kbn/monaco'; import { ExpressionFunction } from '../../../types'; import { CodeEditor } from '../../../../../../src/plugins/kibana_react/public'; import { diff --git a/x-pack/plugins/canvas/public/lib/monaco_language_def.ts b/x-pack/plugins/canvas/public/lib/monaco_language_def.ts index 7bd9ea7b6ef9a0..5b88658ddcd632 100644 --- a/x-pack/plugins/canvas/public/lib/monaco_language_def.ts +++ b/x-pack/plugins/canvas/public/lib/monaco_language_def.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { monaco } from '@kbn/ui-shared-deps/monaco'; +import { monaco } from '@kbn/monaco'; import { ExpressionFunction } from '../../types'; export const LANGUAGE_ID = 'canvas-expression'; diff --git a/x-pack/plugins/painless_lab/public/application/components/output_pane/parameters_tab.tsx b/x-pack/plugins/painless_lab/public/application/components/output_pane/parameters_tab.tsx index 5a417933e80224..b707fd493bcdd0 100644 --- a/x-pack/plugins/painless_lab/public/application/components/output_pane/parameters_tab.tsx +++ b/x-pack/plugins/painless_lab/public/application/components/output_pane/parameters_tab.tsx @@ -14,7 +14,7 @@ import { EuiText, } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; -import { monaco } from '@kbn/ui-shared-deps/monaco'; +import { monaco } from '@kbn/monaco'; import { i18n } from '@kbn/i18n'; import { CodeEditor } from '../../../../../../../src/plugins/kibana_react/public'; diff --git a/x-pack/plugins/painless_lab/public/lib/monaco_painless_lang.ts b/x-pack/plugins/painless_lab/public/lib/monaco_painless_lang.ts index 602697064a7686..4278c77b4c7917 100644 --- a/x-pack/plugins/painless_lab/public/lib/monaco_painless_lang.ts +++ b/x-pack/plugins/painless_lab/public/lib/monaco_painless_lang.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import * as monaco from 'monaco-editor'; +import { monaco } from '@kbn/monaco'; /** * Extends the default type for a Monarch language so we can use diff --git a/x-pack/plugins/painless_lab/public/services/language_service.ts b/x-pack/plugins/painless_lab/public/services/language_service.ts index e6d56a3e16910c..8df40899692228 100644 --- a/x-pack/plugins/painless_lab/public/services/language_service.ts +++ b/x-pack/plugins/painless_lab/public/services/language_service.ts @@ -7,7 +7,7 @@ // It is important that we use this specific monaco instance so that // editor settings are registered against the instance our React component // uses. -import { monaco } from '@kbn/ui-shared-deps/monaco'; +import { monaco } from '@kbn/monaco'; // @ts-ignore import workerSrc from 'raw-loader!monaco-editor/min/vs/base/worker/workerMain.js'; From e81c5d23f247805ae0d18142c736b4ea60f28646 Mon Sep 17 00:00:00 2001 From: spalger Date: Fri, 29 May 2020 11:22:20 -0700 Subject: [PATCH 11/26] use path.resolve to create path --- packages/kbn-monaco/scripts/build.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/kbn-monaco/scripts/build.js b/packages/kbn-monaco/scripts/build.js index 39599afc47f0d0..922a71ebde84b6 100644 --- a/packages/kbn-monaco/scripts/build.js +++ b/packages/kbn-monaco/scripts/build.js @@ -25,6 +25,7 @@ const { ToolingLog, withProcRunner, pickLevelFromFlags } = require('@kbn/dev-uti const TARGET_BUILD_DIR = path.resolve(__dirname, '../target'); const ROOT_DIR = path.resolve(__dirname, '../'); +const WEBPACK_CONFIG_PATH = path.resolve(ROOT_DIR, 'webpack.config.js'); const flags = getopts(process.argv, { boolean: ['dev'], @@ -48,7 +49,7 @@ withProcRunner(log, async (proc) => { await proc.run('webpack ', { cmd: 'webpack', - args: ['--config', `${ROOT_DIR}/webpack.config.js`, flags.dev ? '--env.dev' : '--env.prod'], + args: ['--config', WEBPACK_CONFIG_PATH, flags.dev ? '--env.dev' : '--env.prod'], wait: true, env, cwd, From a81c8921e6f17293258f7677c8576ac0d560da95 Mon Sep 17 00:00:00 2001 From: spalger Date: Fri, 29 May 2020 11:22:43 -0700 Subject: [PATCH 12/26] add basic readme --- packages/kbn-monaco/README.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 packages/kbn-monaco/README.md diff --git a/packages/kbn-monaco/README.md b/packages/kbn-monaco/README.md new file mode 100644 index 00000000000000..c5d7dd7dbfed52 --- /dev/null +++ b/packages/kbn-monaco/README.md @@ -0,0 +1,5 @@ +# @kbn/monaco + +A customized version of monaco that is automatically configured the way we want it to be when imported as `@kbn/monaco`. Additionally, imports to this package are automatically shared with all plugins using `@kbn/ui-shared-deps`. + +Includes custom xjson language support. The `es_ui_shared` plugin has an example of how to use it, in the future we will likely expose helpers from this package to make using it everywhere a little more seamless. \ No newline at end of file From 9ad8888bd95ca0b83bd228e87885cc698ad2de28 Mon Sep 17 00:00:00 2001 From: spalger Date: Fri, 29 May 2020 11:28:15 -0700 Subject: [PATCH 13/26] remove console.log call --- .../painless_lab/public/application/components/editor.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/x-pack/plugins/painless_lab/public/application/components/editor.tsx b/x-pack/plugins/painless_lab/public/application/components/editor.tsx index b2f4081a094df4..62158956b1a7b4 100644 --- a/x-pack/plugins/painless_lab/public/application/components/editor.tsx +++ b/x-pack/plugins/painless_lab/public/application/components/editor.tsx @@ -25,7 +25,6 @@ export function Editor({ code, onChange }: Props) { }} value={xJson} onChange={(value) => { - console.log(convertToJson(value)); setXJson(value); onChange(value); }} From b9a2b5169da8645c8ed33bc96a51c56e73fa19b9 Mon Sep 17 00:00:00 2001 From: spalger Date: Fri, 29 May 2020 12:06:46 -0700 Subject: [PATCH 14/26] remove typescript support from ui-shared-deps webpack config --- packages/kbn-monaco/scripts/build.js | 2 +- packages/kbn-ui-shared-deps/webpack.config.js | 22 ------------------- 2 files changed, 1 insertion(+), 23 deletions(-) diff --git a/packages/kbn-monaco/scripts/build.js b/packages/kbn-monaco/scripts/build.js index 922a71ebde84b6..9e291efc42880e 100644 --- a/packages/kbn-monaco/scripts/build.js +++ b/packages/kbn-monaco/scripts/build.js @@ -55,7 +55,7 @@ withProcRunner(log, async (proc) => { cwd, }); - await proc.run('tsc ', { + await proc.run('tsc ', { cmd: 'tsc', args: ['--emitDeclarationOnly'], wait: true, diff --git a/packages/kbn-ui-shared-deps/webpack.config.js b/packages/kbn-ui-shared-deps/webpack.config.js index 158a972a70f9a6..523927bd64a20d 100644 --- a/packages/kbn-ui-shared-deps/webpack.config.js +++ b/packages/kbn-ui-shared-deps/webpack.config.js @@ -78,28 +78,6 @@ exports.getWebpackConfig = ({ dev = false } = {}) => ({ test: /\.css$/, use: [MiniCssExtractPlugin.loader, 'css-loader'], }, - { - include: [require.resolve('./monaco.ts')], - use: [ - { - loader: 'babel-loader', - options: { - presets: [require.resolve('@kbn/babel-preset/webpack_preset')], - }, - }, - ], - }, - { - test: /\.ts$/, - use: [ - { - loader: 'babel-loader', - options: { - presets: [require.resolve('@kbn/babel-preset/webpack_preset')], - }, - }, - ], - }, ], }, From d0b16687435d1266672f454ffe8468ac011c0d3c Mon Sep 17 00:00:00 2001 From: spalger Date: Fri, 29 May 2020 15:36:32 -0700 Subject: [PATCH 15/26] use `@kbn/babel-preset` --- packages/kbn-monaco/package.json | 1 + packages/kbn-monaco/webpack.config.js | 15 +++++++-------- .../kbn-monaco/xjson/webpack.worker.config.js | 5 +++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/packages/kbn-monaco/package.json b/packages/kbn-monaco/package.json index e239eb9f24e855..73ca71a702aa8f 100644 --- a/packages/kbn-monaco/package.json +++ b/packages/kbn-monaco/package.json @@ -9,6 +9,7 @@ "monaco-editor": "~0.17.0" }, "devDependencies": { + "@kbn/babel-preset": "1.0.0", "@kbn/dev-utils": "1.0.0", "getopts": "^2.2.4", "babel-loader": "^8.0.6", diff --git a/packages/kbn-monaco/webpack.config.js b/packages/kbn-monaco/webpack.config.js index 6301456ba26ef0..de4ec98ebeb83d 100644 --- a/packages/kbn-monaco/webpack.config.js +++ b/packages/kbn-monaco/webpack.config.js @@ -37,16 +37,15 @@ module.exports = (env) => { module: { rules: [ { - test: /\.ts$/, + test: /\.(js|ts)$/, exclude: /node_modules/, - use: [ - { - loader: 'babel-loader', - options: { - presets: ['@babel/typescript'], - }, + use: { + loader: 'babel-loader', + options: { + babelrc: false, + presets: [require.resolve('@kbn/babel-preset/webpack_preset')], }, - ], + }, }, { test: /\.css$/, diff --git a/packages/kbn-monaco/xjson/webpack.worker.config.js b/packages/kbn-monaco/xjson/webpack.worker.config.js index 2c89c78fe83653..9ff6bad8c0d62d 100644 --- a/packages/kbn-monaco/xjson/webpack.worker.config.js +++ b/packages/kbn-monaco/xjson/webpack.worker.config.js @@ -33,12 +33,13 @@ const createConfig = (lang) => ({ module: { rules: [ { - test: /\.ts$/, + test: /\.(js|ts)$/, exclude: /node_modules/, use: { loader: 'babel-loader', options: { - presets: ['@babel/typescript'], + babelrc: false, + presets: [require.resolve('@kbn/babel-preset/webpack_preset')], }, }, }, From 683888174732ff4c8ee2f2e0c1de6c9e2bbb4838 Mon Sep 17 00:00:00 2001 From: spalger Date: Fri, 29 May 2020 15:37:02 -0700 Subject: [PATCH 16/26] include the monaco styles in the kbn-ui-shared-deps --- packages/kbn-ui-shared-deps/entry.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/kbn-ui-shared-deps/entry.js b/packages/kbn-ui-shared-deps/entry.js index 90ed5136a33440..dfa978d0cad3ec 100644 --- a/packages/kbn-ui-shared-deps/entry.js +++ b/packages/kbn-ui-shared-deps/entry.js @@ -19,6 +19,9 @@ require('./polyfills'); +// styles +require('@kbn/monaco/target/index.css'); + // must load before angular export const Jquery = require('jquery'); window.$ = window.jQuery = Jquery; From fdf76ec694fb5b2ddb66a68e2fa525b454bc7627 Mon Sep 17 00:00:00 2001 From: spalger Date: Fri, 29 May 2020 16:08:11 -0700 Subject: [PATCH 17/26] sort package.json --- packages/kbn-monaco/package.json | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/kbn-monaco/package.json b/packages/kbn-monaco/package.json index 73ca71a702aa8f..7f25e85fe9d274 100644 --- a/packages/kbn-monaco/package.json +++ b/packages/kbn-monaco/package.json @@ -1,29 +1,29 @@ { "name": "@kbn/monaco", "version": "1.0.0", - "license": "MIT", "private": true, - "types": "./target/types/index.d.ts", + "license": "MIT", "main": "./target/index.js", + "types": "./target/types/index.d.ts", + "scripts": { + "build": "node ./scripts/build.js", + "kbn:bootstrap": "yarn build --dev" + }, "dependencies": { "monaco-editor": "~0.17.0" }, "devDependencies": { "@kbn/babel-preset": "1.0.0", "@kbn/dev-utils": "1.0.0", - "getopts": "^2.2.4", "babel-loader": "^8.0.6", - "webpack": "^4.41.5", - "webpack-cli": "^3.3.10", - "supports-color": "^7.0.0", - "del": "^5.1.0", - "raw-loader": "3.1.0", "css-loader": "^3.4.2", + "del": "^5.1.0", + "getopts": "^2.2.4", "mini-css-extract-plugin": "0.8.0", - "typescript": "3.7.2" - }, - "scripts": { - "build": "node ./scripts/build.js", - "kbn:bootstrap": "yarn build --dev" + "raw-loader": "3.1.0", + "supports-color": "^7.0.0", + "typescript": "3.7.2", + "webpack": "^4.41.5", + "webpack-cli": "^3.3.10" } } From 5f83a0e797372a22553d72a94fa6aa7a5ea0a5fb Mon Sep 17 00:00:00 2001 From: spalger Date: Fri, 29 May 2020 16:10:57 -0700 Subject: [PATCH 18/26] build worker at bootstrap rather than commiting to repo --- .eslintignore | 1 - packages/kbn-monaco/scripts/build.js | 11 +++- packages/kbn-monaco/webpack.worker.config.js | 51 +++++++++++++++++++ .../xjson/dist/bundle.editor.worker.js | 1 - packages/kbn-monaco/xjson/language.ts | 2 +- .../kbn-monaco/xjson/worker/xjson.worker.ts | 3 +- 6 files changed, 63 insertions(+), 6 deletions(-) create mode 100644 packages/kbn-monaco/webpack.worker.config.js delete mode 100644 packages/kbn-monaco/xjson/dist/bundle.editor.worker.js diff --git a/.eslintignore b/.eslintignore index 4da2749807a724..fbdd70703f3c40 100644 --- a/.eslintignore +++ b/.eslintignore @@ -48,5 +48,4 @@ target /packages/kbn-ui-framework/dist /packages/kbn-ui-framework/doc_site/build /packages/kbn-ui-framework/generator-kui/*/templates/ -/packages/kbn-monaco/xjson/dist diff --git a/packages/kbn-monaco/scripts/build.js b/packages/kbn-monaco/scripts/build.js index 9e291efc42880e..ab9467973c1d87 100644 --- a/packages/kbn-monaco/scripts/build.js +++ b/packages/kbn-monaco/scripts/build.js @@ -26,6 +26,7 @@ const { ToolingLog, withProcRunner, pickLevelFromFlags } = require('@kbn/dev-uti const TARGET_BUILD_DIR = path.resolve(__dirname, '../target'); const ROOT_DIR = path.resolve(__dirname, '../'); const WEBPACK_CONFIG_PATH = path.resolve(ROOT_DIR, 'webpack.config.js'); +const WORKER_WEBPACK_CONFIG_PATH = path.resolve(ROOT_DIR, 'webpack.worker.config.js'); const flags = getopts(process.argv, { boolean: ['dev'], @@ -47,7 +48,15 @@ withProcRunner(log, async (proc) => { env.FORCE_COLOR = 'true'; } - await proc.run('webpack ', { + await proc.run('worker wp', { + cmd: 'webpack', + args: ['--config', WORKER_WEBPACK_CONFIG_PATH, flags.dev ? '--env.dev' : '--env.prod'], + wait: true, + env, + cwd, + }); + + await proc.run('base wp ', { cmd: 'webpack', args: ['--config', WEBPACK_CONFIG_PATH, flags.dev ? '--env.dev' : '--env.prod'], wait: true, diff --git a/packages/kbn-monaco/webpack.worker.config.js b/packages/kbn-monaco/webpack.worker.config.js new file mode 100644 index 00000000000000..0c28e7bd191acd --- /dev/null +++ b/packages/kbn-monaco/webpack.worker.config.js @@ -0,0 +1,51 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +const path = require('path'); + +const createLangWorkerConfig = (lang) => ({ + mode: 'production', + entry: path.resolve(__dirname, lang, 'worker', `${lang}.worker.ts`), + output: { + path: path.resolve(__dirname, 'target'), + filename: `${lang}.worker.js`, + }, + resolve: { + modules: ['node_modules'], + extensions: ['.js', '.ts', '.tsx'], + }, + stats: 'errors-only', + module: { + rules: [ + { + test: /\.(js|ts)$/, + exclude: /node_modules/, + use: { + loader: 'babel-loader', + options: { + babelrc: false, + presets: [require.resolve('@kbn/babel-preset/webpack_preset')], + }, + }, + }, + ], + }, +}); + +module.exports = [createLangWorkerConfig('xjson')]; diff --git a/packages/kbn-monaco/xjson/dist/bundle.editor.worker.js b/packages/kbn-monaco/xjson/dist/bundle.editor.worker.js deleted file mode 100644 index 44487983574ccb..00000000000000 --- a/packages/kbn-monaco/xjson/dist/bundle.editor.worker.js +++ /dev/null @@ -1 +0,0 @@ -!function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=6)}([function(e,t,n){"use strict";(function(e,r){n.d(t,"c",(function(){return m})),n.d(t,"b",(function(){return p})),n.d(t,"a",(function(){return g}));var i=!1,o=!1,s=!1,u=!1,a=!1,l=void 0!==e&&void 0!==e.versions&&void 0!==e.versions.electron&&"renderer"===e.type;if("object"!=typeof navigator||l){if("object"==typeof e){i="win32"===e.platform,o="darwin"===e.platform,s="linux"===e.platform,"en","en";var c=e.env.VSCODE_NLS_CONFIG;if(c)try{var f=JSON.parse(c),h=f.availableLanguages["*"];f.locale,h||"en",f._translationsConfigFile}catch(e){}u=!0}}else{var d=navigator.userAgent;i=d.indexOf("Windows")>=0,o=d.indexOf("Macintosh")>=0,s=d.indexOf("Linux")>=0,a=!0,navigator.language}var m=i,p=a,g="object"==typeof self?self:"object"==typeof r?r:{}}).call(this,n(2),n(1))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t){var n,r,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function u(e){if(n===setTimeout)return setTimeout(e,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(e){n=o}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();var a,l=[],c=!1,f=-1;function h(){c&&a&&(c=!1,a.length?l=a.concat(l):f=-1,l.length&&d())}function d(){if(!c){var e=u(h);c=!0;for(var t=l.length;t;){for(a=l,l=[];++f1)for(var n=1;n=0&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),t))},n(5),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,n(1))},function(e,t,n){(function(e,t){!function(e,n){"use strict";if(!e.setImmediate){var r,i,o,s,u,a=1,l={},c=!1,f=e.document,h=Object.getPrototypeOf&&Object.getPrototypeOf(e);h=h&&h.setTimeout?h:e,"[object process]"==={}.toString.call(e.process)?r=function(e){t.nextTick((function(){m(e)}))}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=n,t}}()?e.MessageChannel?((o=new MessageChannel).port1.onmessage=function(e){m(e.data)},r=function(e){o.port2.postMessage(e)}):f&&"onreadystatechange"in f.createElement("script")?(i=f.documentElement,r=function(e){var t=f.createElement("script");t.onreadystatechange=function(){m(e),t.onreadystatechange=null,i.removeChild(t),t=null},i.appendChild(t)}):r=function(e){setTimeout(m,0,e)}:(s="setImmediate$"+Math.random()+"$",u=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(s)&&m(+t.data.slice(s.length))},e.addEventListener?e.addEventListener("message",u,!1):e.attachEvent("onmessage",u),r=function(t){e.postMessage(s+t,"*")}),h.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;nr?e[a]=o[u++]:u>i?e[a]=o[s++]:t(o[u],o[s])<0?e[a]=o[u++]:e[a]=o[s++]}(t,n,r,s,i,o)}(e,t,0,e.length-1,[]),e}var _=function(){function e(e,t,n,r){this.originalStart=e,this.originalLength=t,this.modifiedStart=n,this.modifiedLength=r}return e.prototype.getOriginalEnd=function(){return this.originalStart+this.originalLength},e.prototype.getModifiedEnd=function(){return this.modifiedStart+this.modifiedLength},e}();function v(e){return{getLength:function(){return e.length},getElementAtIndex:function(t){return e.charCodeAt(t)}}}function y(e,t,n){return new E(v(e),v(t)).ComputeDiff(n)}var C,b=function(){function e(){}return e.Assert=function(e,t){if(!e)throw new Error(t)},e}(),L=function(){function e(){}return e.Copy=function(e,t,n,r,i){for(var o=0;o0||this.m_modifiedCount>0)&&this.m_changes.push(new _(this.m_originalStart,this.m_originalCount,this.m_modifiedStart,this.m_modifiedCount)),this.m_originalCount=0,this.m_modifiedCount=0,this.m_originalStart=Number.MAX_VALUE,this.m_modifiedStart=Number.MAX_VALUE},e.prototype.AddOriginalElement=function(e,t){this.m_originalStart=Math.min(this.m_originalStart,e),this.m_modifiedStart=Math.min(this.m_modifiedStart,t),this.m_originalCount++},e.prototype.AddModifiedElement=function(e,t){this.m_originalStart=Math.min(this.m_originalStart,e),this.m_modifiedStart=Math.min(this.m_modifiedStart,t),this.m_modifiedCount++},e.prototype.getChanges=function(){return(this.m_originalCount>0||this.m_modifiedCount>0)&&this.MarkNextChange(),this.m_changes},e.prototype.getReverseChanges=function(){return(this.m_originalCount>0||this.m_modifiedCount>0)&&this.MarkNextChange(),this.m_changes.reverse(),this.m_changes},e}(),E=function(){function e(e,t,n){void 0===n&&(n=null),this.OriginalSequence=e,this.ModifiedSequence=t,this.ContinueProcessingPredicate=n,this.m_forwardHistory=[],this.m_reverseHistory=[]}return e.prototype.ElementsAreEqual=function(e,t){return this.OriginalSequence.getElementAtIndex(e)===this.ModifiedSequence.getElementAtIndex(t)},e.prototype.OriginalElementsAreEqual=function(e,t){return this.OriginalSequence.getElementAtIndex(e)===this.OriginalSequence.getElementAtIndex(t)},e.prototype.ModifiedElementsAreEqual=function(e,t){return this.ModifiedSequence.getElementAtIndex(e)===this.ModifiedSequence.getElementAtIndex(t)},e.prototype.ComputeDiff=function(e){return this._ComputeDiff(0,this.OriginalSequence.getLength()-1,0,this.ModifiedSequence.getLength()-1,e)},e.prototype._ComputeDiff=function(e,t,n,r,i){var o=this.ComputeDiffRecursive(e,t,n,r,[!1]);return i?this.PrettifyChanges(o):o},e.prototype.ComputeDiffRecursive=function(e,t,n,r,i){for(i[0]=!1;e<=t&&n<=r&&this.ElementsAreEqual(e,n);)e++,n++;for(;t>=e&&r>=n&&this.ElementsAreEqual(t,r);)t--,r--;if(e>t||n>r){var o=void 0;return n<=r?(b.Assert(e===t+1,"originalStart should only be one more than originalEnd"),o=[new _(e,0,n,r-n+1)]):e<=t?(b.Assert(n===r+1,"modifiedStart should only be one more than modifiedEnd"),o=[new _(e,t-e+1,n,0)]):(b.Assert(e===t+1,"originalStart should only be one more than originalEnd"),b.Assert(n===r+1,"modifiedStart should only be one more than modifiedEnd"),o=[]),o}var s=[0],u=[0],a=this.ComputeRecursionPoint(e,t,n,r,s,u,i),l=s[0],c=u[0];if(null!==a)return a;if(!i[0]){var f=this.ComputeDiffRecursive(e,l,n,c,i),h=[];return h=i[0]?[new _(l+1,t-(l+1)+1,c+1,r-(c+1)+1)]:this.ComputeDiffRecursive(l+1,t,c+1,r,i),this.ConcatenateChanges(f,h)}return[new _(e,t-e+1,n,r-n+1)]},e.prototype.WALKTRACE=function(e,t,n,r,i,o,s,u,a,l,c,f,h,d,m,p,g,v){var y,C,b=null,L=new N,E=t,S=n,w=h[0]-p[0]-r,A=Number.MIN_VALUE,M=this.m_forwardHistory.length-1;do{(C=w+e)===E||C=0&&(e=(a=this.m_forwardHistory[M])[0],E=1,S=a.length-1)}while(--M>=-1);if(y=L.getReverseChanges(),v[0]){var T=h[0]+1,P=p[0]+1;if(null!==y&&y.length>0){var O=y[y.length-1];T=Math.max(T,O.getOriginalEnd()),P=Math.max(P,O.getModifiedEnd())}b=[new _(T,f-T+1,P,m-P+1)]}else{L=new N,E=o,S=s,w=h[0]-p[0]-u,A=Number.MAX_VALUE,M=g?this.m_reverseHistory.length-1:this.m_reverseHistory.length-2;do{(C=w+i)===E||C=l[C+1]?(d=(c=l[C+1]-1)-w-u,c>A&&L.MarkNextChange(),A=c+1,L.AddOriginalElement(c+1,d+1),w=C+1-i):(d=(c=l[C-1])-w-u,c>A&&L.MarkNextChange(),A=c,L.AddModifiedElement(c+1,d+1),w=C-1-i),M>=0&&(i=(l=this.m_reverseHistory[M])[0],E=1,S=l.length-1)}while(--M>=-1);b=L.getChanges()}return this.ConcatenateChanges(y,b)},e.prototype.ComputeRecursionPoint=function(e,t,n,r,i,o,s){var u,a=0,l=0,c=0,f=0,h=0,d=0;e--,n--,i[0]=0,o[0]=0,this.m_forwardHistory=[],this.m_reverseHistory=[];var m,p,g=t-e+(r-n),v=g+1,y=new Array(v),C=new Array(v),b=r-n,N=t-e,E=e-n,S=t-r,w=(N-b)%2==0;for(y[b]=e,C[N]=t,s[0]=!1,u=1;u<=g/2+1;u++){var A=0,M=0;for(c=this.ClipDiagonalBound(b-u,u,b,v),f=this.ClipDiagonalBound(b+u,u,b,v),m=c;m<=f;m+=2){for(l=(a=m===c||mA+M&&(A=a,M=l),!w&&Math.abs(m-N)<=u-1&&a>=C[m])return i[0]=a,o[0]=l,p<=C[m]&&u<=1448?this.WALKTRACE(b,c,f,E,N,h,d,S,y,C,a,t,i,l,r,o,w,s):null}var T=(A-e+(M-n)-u)/2;if(null!==this.ContinueProcessingPredicate&&!this.ContinueProcessingPredicate(A,this.OriginalSequence,T))return s[0]=!0,i[0]=A,o[0]=M,T>0&&u<=1448?this.WALKTRACE(b,c,f,E,N,h,d,S,y,C,a,t,i,l,r,o,w,s):(e++,n++,[new _(e,t-e+1,n,r-n+1)]);for(h=this.ClipDiagonalBound(N-u,u,N,v),d=this.ClipDiagonalBound(N+u,u,N,v),m=h;m<=d;m+=2){for(l=(a=m===h||m=C[m+1]?C[m+1]-1:C[m-1])-(m-N)-S,p=a;a>e&&l>n&&this.ElementsAreEqual(a,l);)a--,l--;if(C[m]=a,w&&Math.abs(m-b)<=u&&a<=y[m])return i[0]=a,o[0]=l,p>=y[m]&&u<=1448?this.WALKTRACE(b,c,f,E,N,h,d,S,y,C,a,t,i,l,r,o,w,s):null}if(u<=1447){var P=new Array(f-c+2);P[0]=b-c+1,L.Copy(y,c,P,1,f-c+1),this.m_forwardHistory.push(P),(P=new Array(d-h+2))[0]=N-h+1,L.Copy(C,h,P,1,d-h+1),this.m_reverseHistory.push(P)}}return this.WALKTRACE(b,c,f,E,N,h,d,S,y,C,a,t,i,l,r,o,w,s)},e.prototype.PrettifyChanges=function(e){for(var t=0;t0,s=n.modifiedLength>0;n.originalStart+n.originalLength=0;t--){n=e[t],r=0,i=0;if(t>0){var a=e[t-1];a.originalLength>0&&(r=a.originalStart+a.originalLength),a.modifiedLength>0&&(i=a.modifiedStart+a.modifiedLength)}o=n.originalLength>0,s=n.modifiedLength>0;for(var l=0,c=this._boundaryScore(n.originalStart,n.originalLength,n.modifiedStart,n.modifiedLength),f=1;;f++){var h=n.originalStart-f,d=n.modifiedStart-f;if(hc&&(c=m,l=f)}n.originalStart-=l,n.modifiedStart-=l}return e},e.prototype._OriginalIsBoundary=function(e){if(e<=0||e>=this.OriginalSequence.getLength()-1)return!0;var t=this.OriginalSequence.getElementAtIndex(e);return"string"==typeof t&&/^\s*$/.test(t)},e.prototype._OriginalRegionIsBoundary=function(e,t){if(this._OriginalIsBoundary(e)||this._OriginalIsBoundary(e-1))return!0;if(t>0){var n=e+t;if(this._OriginalIsBoundary(n-1)||this._OriginalIsBoundary(n))return!0}return!1},e.prototype._ModifiedIsBoundary=function(e){if(e<=0||e>=this.ModifiedSequence.getLength()-1)return!0;var t=this.ModifiedSequence.getElementAtIndex(e);return"string"==typeof t&&/^\s*$/.test(t)},e.prototype._ModifiedRegionIsBoundary=function(e,t){if(this._ModifiedIsBoundary(e)||this._ModifiedIsBoundary(e-1))return!0;if(t>0){var n=e+t;if(this._ModifiedIsBoundary(n-1)||this._ModifiedIsBoundary(n))return!0}return!1},e.prototype._boundaryScore=function(e,t,n,r){return(this._OriginalRegionIsBoundary(e,t)?1:0)+(this._ModifiedRegionIsBoundary(n,r)?1:0)},e.prototype.ConcatenateChanges=function(e,t){var n=[];if(0===e.length||0===t.length)return t.length>0?t:e;if(this.ChangesOverlap(e[e.length-1],t[0],n)){var r=new Array(e.length+t.length-1);return L.Copy(e,0,r,0,e.length-1),r[e.length-1]=n[0],L.Copy(t,1,r,e.length,t.length-1),r}r=new Array(e.length+t.length);return L.Copy(e,0,r,0,e.length),L.Copy(t,0,r,e.length,t.length),r},e.prototype.ChangesOverlap=function(e,t,n){if(b.Assert(e.originalStart<=t.originalStart,"Left change is not less than or equal to right change"),b.Assert(e.modifiedStart<=t.modifiedStart,"Left change is not less than or equal to right change"),e.originalStart+e.originalLength>=t.originalStart||e.modifiedStart+e.modifiedLength>=t.modifiedStart){var r=e.originalStart,i=e.originalLength,o=e.modifiedStart,s=e.modifiedLength;return e.originalStart+e.originalLength>=t.originalStart&&(i=t.originalStart+t.originalLength-e.originalStart),e.modifiedStart+e.modifiedLength>=t.modifiedStart&&(s=t.modifiedStart+t.modifiedLength-e.modifiedStart),n[0]=new _(r,i,o,s),!0}return n[0]=null,!1},e.prototype.ClipDiagonalBound=function(e,t,n,r){if(e>=0&&e=n?w:{done:!1,value:e[t++]}}}},e.from=function(t){return t?Array.isArray(t)?e.fromArray(t):t:e.empty()},e.map=function(e,t){return{next:function(){var n=e.next();return n.done?w:{done:!1,value:t(n.value)}}}},e.filter=function(e,t){return{next:function(){for(;;){var n=e.next();if(n.done)return w;if(t(n.value))return{done:!1,value:n.value}}}}},e.forEach=n,e.collect=function(e){var t=[];return n(e,(function(e){return t.push(e)})),t}}(C||(C={}));(function(e){function t(t,n,r,i){return void 0===n&&(n=0),void 0===r&&(r=t.length),void 0===i&&(i=n-1),e.call(this,t,n,r,i)||this}S(t,e),t.prototype.current=function(){return e.prototype.current.call(this)},t.prototype.previous=function(){return this.index=Math.max(this.index-1,this.start-1),this.current()},t.prototype.first=function(){return this.index=this.start,this.current()},t.prototype.last=function(){return this.index=this.end-1,this.current()},t.prototype.parent=function(){return null}})(function(){function e(e,t,n,r){void 0===t&&(t=0),void 0===n&&(n=e.length),void 0===r&&(r=t-1),this.items=e,this.start=t,this.end=n,this.index=r}return e.prototype.next=function(){return this.index=Math.min(this.index+1,this.end),this.current()},e.prototype.current=function(){return this.index===this.start-1||this.index===this.end?null:this.items[this.index]},e}()),function(){function e(e,t){this.iterator=e,this.fn=t}e.prototype.next=function(){return this.fn(this.iterator.next())}}();var A,M=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),T=/^\w[\w\d+.-]*$/,P=/^\//,O=/^\/\//;var x="",I="/",R=/^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,k=function(){function e(e,t,n,r,i,o){void 0===o&&(o=!1),"object"==typeof e?(this.scheme=e.scheme||x,this.authority=e.authority||x,this.path=e.path||x,this.query=e.query||x,this.fragment=e.fragment||x):(this.scheme=e||x,this.authority=t||x,this.path=function(e,t){switch(e){case"https":case"http":case"file":t?t[0]!==I&&(t=I+t):t=I}return t}(this.scheme,n||x),this.query=r||x,this.fragment=i||x,function(e,t){if(!e.scheme)throw new Error('[UriError]: Scheme is missing: {scheme: "", authority: "'+e.authority+'", path: "'+e.path+'", query: "'+e.query+'", fragment: "'+e.fragment+'"}');if(e.scheme&&!T.test(e.scheme))throw new Error("[UriError]: Scheme contains illegal characters.");if(e.path)if(e.authority){if(!P.test(e.path))throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character')}else if(O.test(e.path))throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")')}(this))}return e.isUri=function(t){return t instanceof e||!!t&&("string"==typeof t.authority&&"string"==typeof t.fragment&&"string"==typeof t.path&&"string"==typeof t.query&&"string"==typeof t.scheme&&"function"==typeof t.fsPath&&"function"==typeof t.with&&"function"==typeof t.toString)},Object.defineProperty(e.prototype,"fsPath",{get:function(){return q(this)},enumerable:!0,configurable:!0}),e.prototype.with=function(e){if(!e)return this;var t=e.scheme,n=e.authority,r=e.path,i=e.query,o=e.fragment;return void 0===t?t=this.scheme:null===t&&(t=x),void 0===n?n=this.authority:null===n&&(n=x),void 0===r?r=this.path:null===r&&(r=x),void 0===i?i=this.query:null===i&&(i=x),void 0===o?o=this.fragment:null===o&&(o=x),t===this.scheme&&n===this.authority&&r===this.path&&i===this.query&&o===this.fragment?this:new U(t,n,r,i,o)},e.parse=function(e,t){void 0===t&&(t=!1);var n=R.exec(e);return n?new U(n[2]||x,decodeURIComponent(n[4]||x),decodeURIComponent(n[5]||x),decodeURIComponent(n[7]||x),decodeURIComponent(n[9]||x),t):new U(x,x,x,x,x)},e.file=function(e){var t=x;if(c.c&&(e=e.replace(/\\/g,I)),e[0]===I&&e[1]===I){var n=e.indexOf(I,2);-1===n?(t=e.substring(2),e=I):(t=e.substring(2,n),e=e.substring(n)||I)}return new U("file",t,e,x,x)},e.from=function(e){return new U(e.scheme,e.authority,e.path,e.query,e.fragment)},e.prototype.toString=function(e){return void 0===e&&(e=!1),V(this,e)},e.prototype.toJSON=function(){return this},e.revive=function(t){if(t){if(t instanceof e)return t;var n=new U(t);return n._fsPath=t.fsPath,n._formatted=t.external,n}return t},e}(),U=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._formatted=null,t._fsPath=null,t}return M(t,e),Object.defineProperty(t.prototype,"fsPath",{get:function(){return this._fsPath||(this._fsPath=q(this)),this._fsPath},enumerable:!0,configurable:!0}),t.prototype.toString=function(e){return void 0===e&&(e=!1),e?V(this,!0):(this._formatted||(this._formatted=V(this,!1)),this._formatted)},t.prototype.toJSON=function(){var e={$mid:1};return this._fsPath&&(e.fsPath=this._fsPath),this._formatted&&(e.external=this._formatted),this.path&&(e.path=this.path),this.scheme&&(e.scheme=this.scheme),this.authority&&(e.authority=this.authority),this.query&&(e.query=this.query),this.fragment&&(e.fragment=this.fragment),e},t}(k),F=((A={})[58]="%3A",A[47]="%2F",A[63]="%3F",A[35]="%23",A[91]="%5B",A[93]="%5D",A[64]="%40",A[33]="%21",A[36]="%24",A[38]="%26",A[39]="%27",A[40]="%28",A[41]="%29",A[42]="%2A",A[43]="%2B",A[44]="%2C",A[59]="%3B",A[61]="%3D",A[32]="%20",A);function D(e,t){for(var n=void 0,r=-1,i=0;i=97&&o<=122||o>=65&&o<=90||o>=48&&o<=57||45===o||46===o||95===o||126===o||t&&47===o)-1!==r&&(n+=encodeURIComponent(e.substring(r,i)),r=-1),void 0!==n&&(n+=e.charAt(i));else{void 0===n&&(n=e.substr(0,i));var s=F[o];void 0!==s?(-1!==r&&(n+=encodeURIComponent(e.substring(r,i)),r=-1),n+=s):-1===r&&(r=i)}}return-1!==r&&(n+=encodeURIComponent(e.substring(r))),void 0!==n?n:e}function K(e){for(var t=void 0,n=0;n1&&"file"===e.scheme?"//"+e.authority+e.path:47===e.path.charCodeAt(0)&&(e.path.charCodeAt(1)>=65&&e.path.charCodeAt(1)<=90||e.path.charCodeAt(1)>=97&&e.path.charCodeAt(1)<=122)&&58===e.path.charCodeAt(2)?e.path[1].toLowerCase()+e.path.substr(2):e.path,c.c&&(t=t.replace(/\//g,"\\")),t}function V(e,t){var n=t?K:D,r="",i=e.scheme,o=e.authority,s=e.path,u=e.query,a=e.fragment;if(i&&(r+=i,r+=":"),(o||"file"===i)&&(r+=I,r+=I),o){var l=o.indexOf("@");if(-1!==l){var c=o.substr(0,l);o=o.substr(l+1),-1===(l=c.indexOf(":"))?r+=n(c,!1):(r+=n(c.substr(0,l),!1),r+=":",r+=n(c.substr(l+1),!1)),r+="@"}-1===(l=(o=o.toLowerCase()).indexOf(":"))?r+=n(o,!1):(r+=n(o.substr(0,l),!1),r+=o.substr(l))}if(s){if(s.length>=3&&47===s.charCodeAt(0)&&58===s.charCodeAt(2))(f=s.charCodeAt(1))>=65&&f<=90&&(s="/"+String.fromCharCode(f+32)+":"+s.substr(3));else if(s.length>=2&&58===s.charCodeAt(1)){var f;(f=s.charCodeAt(0))>=65&&f<=90&&(s=String.fromCharCode(f+32)+":"+s.substr(2))}r+=n(s,!0)}return u&&(r+="?",r+=n(u,!1)),a&&(r+="#",r+=t?a:D(a,!1)),r}var B=function(){function e(e,t){this.lineNumber=e,this.column=t}return e.prototype.with=function(t,n){return void 0===t&&(t=this.lineNumber),void 0===n&&(n=this.column),t===this.lineNumber&&n===this.column?this:new e(t,n)},e.prototype.delta=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=0),this.with(this.lineNumber+e,this.column+t)},e.prototype.equals=function(t){return e.equals(this,t)},e.equals=function(e,t){return!e&&!t||!!e&&!!t&&e.lineNumber===t.lineNumber&&e.column===t.column},e.prototype.isBefore=function(t){return e.isBefore(this,t)},e.isBefore=function(e,t){return e.lineNumbern||e===n&&t>r?(this.startLineNumber=n,this.startColumn=r,this.endLineNumber=e,this.endColumn=t):(this.startLineNumber=e,this.startColumn=t,this.endLineNumber=n,this.endColumn=r)}return e.prototype.isEmpty=function(){return e.isEmpty(this)},e.isEmpty=function(e){return e.startLineNumber===e.endLineNumber&&e.startColumn===e.endColumn},e.prototype.containsPosition=function(t){return e.containsPosition(this,t)},e.containsPosition=function(e,t){return!(t.lineNumbere.endLineNumber)&&(!(t.lineNumber===e.startLineNumber&&t.columne.endColumn))},e.prototype.containsRange=function(t){return e.containsRange(this,t)},e.containsRange=function(e,t){return!(t.startLineNumbere.endLineNumber||t.endLineNumber>e.endLineNumber)&&(!(t.startLineNumber===e.startLineNumber&&t.startColumne.endColumn)))},e.prototype.plusRange=function(t){return e.plusRange(this,t)},e.plusRange=function(t,n){var r,i,o,s;return n.startLineNumbert.endLineNumber?(o=n.endLineNumber,s=n.endColumn):n.endLineNumber===t.endLineNumber?(o=n.endLineNumber,s=Math.max(n.endColumn,t.endColumn)):(o=t.endLineNumber,s=t.endColumn),new e(r,i,o,s)},e.prototype.intersectRanges=function(t){return e.intersectRanges(this,t)},e.intersectRanges=function(t,n){var r=t.startLineNumber,i=t.startColumn,o=t.endLineNumber,s=t.endColumn,u=n.startLineNumber,a=n.startColumn,l=n.endLineNumber,c=n.endColumn;return rl?(o=l,s=c):o===l&&(s=Math.min(s,c)),r>o?null:r===o&&i>s?null:new e(r,i,o,s)},e.prototype.equalsRange=function(t){return e.equalsRange(this,t)},e.equalsRange=function(e,t){return!!e&&!!t&&e.startLineNumber===t.startLineNumber&&e.startColumn===t.startColumn&&e.endLineNumber===t.endLineNumber&&e.endColumn===t.endColumn},e.prototype.getEndPosition=function(){return new B(this.endLineNumber,this.endColumn)},e.prototype.getStartPosition=function(){return new B(this.startLineNumber,this.startColumn)},e.prototype.toString=function(){return"["+this.startLineNumber+","+this.startColumn+" -> "+this.endLineNumber+","+this.endColumn+"]"},e.prototype.setEndPosition=function(t,n){return new e(this.startLineNumber,this.startColumn,t,n)},e.prototype.setStartPosition=function(t,n){return new e(t,n,this.endLineNumber,this.endColumn)},e.prototype.collapseToStart=function(){return e.collapseToStart(this)},e.collapseToStart=function(t){return new e(t.startLineNumber,t.startColumn,t.startLineNumber,t.startColumn)},e.fromPositions=function(t,n){return void 0===n&&(n=t),new e(t.lineNumber,t.column,n.lineNumber,n.column)},e.lift=function(t){return t?new e(t.startLineNumber,t.startColumn,t.endLineNumber,t.endColumn):null},e.isIRange=function(e){return e&&"number"==typeof e.startLineNumber&&"number"==typeof e.startColumn&&"number"==typeof e.endLineNumber&&"number"==typeof e.endColumn},e.areIntersectingOrTouching=function(e,t){return!(e.endLineNumbere.startLineNumber},e}();String.fromCharCode(65279);function Y(e,t,n,r){return new E(e,t,n).ComputeDiff(r)}var W=function(){function e(t){for(var n=[],r=[],i=0,o=t.length;i=0;n--){var r=e.charCodeAt(n);if(32!==r&&9!==r)return n}return-1}(e);return-1===n?t:n+2},e.prototype.getCharSequence=function(e,t,n){for(var r=[],i=[],o=[],s=0,u=t;u<=n;u++)for(var a=this._lines[u],l=e?this._startColumns[u]:1,c=e?this._endColumns[u]:a.length+1,f=l;f1&&m>1;){if(f.charCodeAt(d-2)!==h.charCodeAt(m-2))break;d--,m--}(d>1||m>1)&&this._pushTrimWhitespaceCharChange(i,o+1,1,d,s+1,1,m);for(var p=W._getLastNonBlankColumn(f,1),g=W._getLastNonBlankColumn(h,1),_=f.length+1,v=h.length+1;p<_&&g255?255:0|e}function J(e){return e<0?0:e>4294967295?4294967295:0|e}var Z=function(e,t){this.index=e,this.remainder=t},ee=function(){function e(e){this.values=e,this.prefixSum=new Uint32Array(e.length),this.prefixSumValidIndex=new Int32Array(1),this.prefixSumValidIndex[0]=-1}return e.prototype.getCount=function(){return this.values.length},e.prototype.insertValues=function(e,t){e=J(e);var n=this.values,r=this.prefixSum,i=t.length;return 0!==i&&(this.values=new Uint32Array(n.length+i),this.values.set(n.subarray(0,e),0),this.values.set(n.subarray(e),e+i),this.values.set(t,e),e-1=0&&this.prefixSum.set(r.subarray(0,this.prefixSumValidIndex[0]+1)),!0)},e.prototype.changeValue=function(e,t){return e=J(e),t=J(t),this.values[e]!==t&&(this.values[e]=t,e-1=n.length)return!1;var i=n.length-e;return t>=i&&(t=i),0!==t&&(this.values=new Uint32Array(n.length-t),this.values.set(n.subarray(0,e),0),this.values.set(n.subarray(e+t),e),this.prefixSum=new Uint32Array(this.values.length),e-1=0&&this.prefixSum.set(r.subarray(0,this.prefixSumValidIndex[0]+1)),!0)},e.prototype.getTotalValue=function(){return 0===this.values.length?0:this._getAccumulatedValue(this.values.length-1)},e.prototype.getAccumulatedValue=function(e){return e<0?0:(e=J(e),this._getAccumulatedValue(e))},e.prototype._getAccumulatedValue=function(e){if(e<=this.prefixSumValidIndex[0])return this.prefixSum[e];var t=this.prefixSumValidIndex[0]+1;0===t&&(this.prefixSum[0]=this.values[0],t++),e>=this.values.length&&(e=this.values.length-1);for(var n=t;n<=e;n++)this.prefixSum[n]=this.prefixSum[n-1]+this.values[n];return this.prefixSumValidIndex[0]=Math.max(this.prefixSumValidIndex[0],e),this.prefixSum[e]},e.prototype.getIndexOf=function(e){e=Math.floor(e),this.getTotalValue();for(var t=0,n=this.values.length-1,r=0,i=0,o=0;t<=n;)if(r=t+(n-t)/2|0,e<(o=(i=this.prefixSum[r])-this.values[r]))n=r-1;else{if(!(e>=i))break;t=r+1}return new Z(r,e-o)},e}(),te=(function(){function e(e){this._cacheAccumulatedValueStart=0,this._cache=null,this._actual=new ee(e),this._bustCache()}e.prototype._bustCache=function(){this._cacheAccumulatedValueStart=0,this._cache=null},e.prototype.insertValues=function(e,t){this._actual.insertValues(e,t)&&this._bustCache()},e.prototype.changeValue=function(e,t){this._actual.changeValue(e,t)&&this._bustCache()},e.prototype.removeValues=function(e,t){this._actual.removeValues(e,t)&&this._bustCache()},e.prototype.getTotalValue=function(){return this._actual.getTotalValue()},e.prototype.getAccumulatedValue=function(e){return this._actual.getAccumulatedValue(e)},e.prototype.getIndexOf=function(e){if(e=Math.floor(e),null!==this._cache){var t=e-this._cacheAccumulatedValueStart;if(t>=0&&t/?".length;n++){var r="`~!@#$%^&*()-=+[{]}\\|;:'\",.<>/?"[n];e.indexOf(r)>=0||(t+="\\"+r)}return t+="\\s]+)",new RegExp(t,"g")}();var re=function(){function e(t){var n=$(t);this._defaultValue=n,this._asciiMap=e._createAsciiMap(n),this._map=new Map}return e._createAsciiMap=function(e){for(var t=new Uint8Array(256),n=0;n<256;n++)t[n]=e;return t},e.prototype.set=function(e,t){var n=$(t);e>=0&&e<256?this._asciiMap[e]=n:this._map.set(e,n)},e.prototype.get=function(e){return e>=0&&e<256?this._asciiMap[e]:this._map.get(e)||this._defaultValue},e}(),ie=(function(){function e(){this._actual=new re(0)}e.prototype.add=function(e){this._actual.set(e,1)},e.prototype.has=function(e){return 1===this._actual.get(e)}}(),function(){function e(e){for(var t=0,n=0,r=0,i=e.length;rt&&(t=l),s>n&&(n=s),(c=o[2])>n&&(n=c)}t++,n++;var u=new X(n,t,0);for(r=0,i=e.length;r=this._maxCharCode?0:this._states.get(e,t)},e}()),oe=null;var se=null;var ue=function(){function e(){}return e._createLink=function(e,t,n,r,i){var o=i-1;do{var s=t.charCodeAt(o);if(2!==e.get(s))break;o--}while(o>r);if(r>0){var u=t.charCodeAt(r-1),a=t.charCodeAt(o);(40===u&&41===a||91===u&&93===a||123===u&&125===a)&&o--}return{range:{startLineNumber:n,startColumn:r+1,endLineNumber:n,endColumn:o+2},url:t.substring(r,o+1)}},e.computeLinks=function(t,n){void 0===n&&(null===oe&&(oe=new ie([[1,104,2],[1,72,2],[1,102,6],[1,70,6],[2,116,3],[2,84,3],[3,116,4],[3,84,4],[4,112,5],[4,80,5],[5,115,9],[5,83,9],[5,58,10],[6,105,7],[6,73,7],[7,108,8],[7,76,8],[8,101,9],[8,69,9],[9,58,10],[10,47,11],[11,47,12]])),n=oe);for(var r=function(){if(null===se){se=new re(0);for(var e=0;e<" \t<>'\"、。。、,.:;?!@#$%&*‘“〈《「『【〔([{「」}])〕】』」》〉”’`~…".length;e++)se.set(" \t<>'\"、。。、,.:;?!@#$%&*‘“〈《「『【〔([{「」}])〕】』」》〉”’`~…".charCodeAt(e),1);for(e=0;e<".,;".length;e++)se.set(".,;".charCodeAt(e),2)}return se}(),i=[],o=1,s=t.getLineCount();o<=s;o++){for(var u=t.getLineContent(o),a=u.length,l=0,c=0,f=0,h=1,d=!1,m=!1,p=!1;l=0?((r+=n?1:-1)<0?r=e.length-1:r%=e.length,e[r]):null},e.INSTANCE=new e,e}();n(3);var le,ce=function(){function e(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}return e.Undefined=new e(void 0),e}(),fe=function(){function e(){this._first=ce.Undefined,this._last=ce.Undefined,this._size=0}return Object.defineProperty(e.prototype,"size",{get:function(){return this._size},enumerable:!0,configurable:!0}),e.prototype.isEmpty=function(){return this._first===ce.Undefined},e.prototype.clear=function(){this._first=ce.Undefined,this._last=ce.Undefined,this._size=0},e.prototype.unshift=function(e){return this._insert(e,!1)},e.prototype.push=function(e){return this._insert(e,!0)},e.prototype._insert=function(e,t){var n=this,r=new ce(e);if(this._first===ce.Undefined)this._first=r,this._last=r;else if(t){var i=this._last;this._last=r,r.prev=i,i.next=r}else{var o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;var s=!1;return function(){s||(s=!0,n._remove(r))}},e.prototype.shift=function(){if(this._first!==ce.Undefined){var e=this._first.element;return this._remove(this._first),e}},e.prototype._remove=function(e){if(e.prev!==ce.Undefined&&e.next!==ce.Undefined){var t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===ce.Undefined&&e.next===ce.Undefined?(this._first=ce.Undefined,this._last=ce.Undefined):e.next===ce.Undefined?(this._last=this._last.prev,this._last.next=ce.Undefined):e.prev===ce.Undefined&&(this._first=this._first.next,this._first.prev=ce.Undefined);this._size-=1},e.prototype.iterator=function(){var e,t=this._first;return{next:function(){return t===ce.Undefined?w:(e?e.value=t.element:e={done:!1,value:t.element},t=t.next,e)}}},e.prototype.toArray=function(){for(var e=[],t=this._first;t!==ce.Undefined;t=t.next)e.push(t.element);return e},e}(),he=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();!function(e){var t={dispose:function(){}};function n(e){return function(t,n,r){void 0===n&&(n=null);var i,o=!1;return i=e((function(e){if(!o)return i?i.dispose():o=!0,t.call(n,e)}),null,r),o&&i.dispose(),i}}function r(e,t){return u((function(n,r,i){return void 0===r&&(r=null),e((function(e){return n.call(r,t(e))}),null,i)}))}function i(e,t){return u((function(n,r,i){return void 0===r&&(r=null),e((function(e){t(e),n.call(r,e)}),null,i)}))}function o(e,t){return u((function(n,r,i){return void 0===r&&(r=null),e((function(e){return t(e)&&n.call(r,e)}),null,i)}))}function s(e,t,n){var i=n;return r(e,(function(e){return i=t(i,e)}))}function u(e){var t,n=new pe({onFirstListenerAdd:function(){t=e(n.fire,n)},onLastListenerRemove:function(){t.dispose()}});return n.event}function l(e){var t,n=!0;return o(e,(function(e){var r=n||e!==t;return n=!1,t=e,r}))}e.None=function(){return t},e.once=n,e.map=r,e.forEach=i,e.filter=o,e.signal=function(e){return e},e.any=function(){for(var e=[],t=0;t1)&&l.fire(e),a=0}),n)}))},onLastListenerRemove:function(){o.dispose()}});return l.event},e.stopwatch=function(e){var t=(new Date).getTime();return r(n(e),(function(e){return(new Date).getTime()-t}))},e.latch=l,e.buffer=function(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=[]);var r=n.slice(),i=e((function(e){r?r.push(e):s.fire(e)})),o=function(){r&&r.forEach((function(e){return s.fire(e)})),r=null},s=new pe({onFirstListenerAdd:function(){i||(i=e((function(e){return s.fire(e)})))},onFirstListenerDidAdd:function(){r&&(t?setTimeout(o):o())},onLastListenerRemove:function(){i&&i.dispose(),i=null}});return s.event};var c=function(){function e(e){this.event=e}return e.prototype.map=function(t){return new e(r(this.event,t))},e.prototype.forEach=function(t){return new e(i(this.event,t))},e.prototype.filter=function(t){return new e(o(this.event,t))},e.prototype.reduce=function(t,n){return new e(s(this.event,t,n))},e.prototype.latch=function(){return new e(l(this.event))},e.prototype.on=function(e,t,n){return this.event(e,t,n)},e.prototype.once=function(e,t,r){return n(this.event)(e,t,r)},e}();e.chain=function(e){return new c(e)},e.fromNodeEventEmitter=function(e,t,n){void 0===n&&(n=function(e){return e});var r=function(){for(var e=[],t=0;t0;){var r=this._deliveryQueue.shift(),o=r[0],s=r[1];try{"function"==typeof o?o.call(void 0,s):o[0].call(o[1],s)}catch(n){i(n)}}}},e.prototype.dispose=function(){this._listeners&&this._listeners.clear(),this._deliveryQueue&&this._deliveryQueue.clear(),this._leakageMon&&this._leakageMon.dispose(),this._disposed=!0},e._noop=function(){},e}(),ge=(function(e){function t(t){var n=e.call(this,t)||this;return n._isPaused=0,n._eventQueue=new fe,n._mergeFn=t&&t.merge,n}he(t,e),t.prototype.pause=function(){this._isPaused++},t.prototype.resume=function(){if(0!==this._isPaused&&0==--this._isPaused)if(this._mergeFn){var t=this._eventQueue.toArray();this._eventQueue.clear(),e.prototype.fire.call(this,this._mergeFn(t))}else for(;!this._isPaused&&0!==this._eventQueue.size;)e.prototype.fire.call(this,this._eventQueue.shift())},t.prototype.fire=function(t){this._listeners&&(0!==this._isPaused?this._eventQueue.push(t):e.prototype.fire.call(this,t))}}(pe),function(){function e(){var e=this;this.hasListeners=!1,this.events=[],this.emitter=new pe({onFirstListenerAdd:function(){return e.onFirstListenerAdd()},onLastListenerRemove:function(){return e.onLastListenerRemove()}})}Object.defineProperty(e.prototype,"event",{get:function(){return this.emitter.event},enumerable:!0,configurable:!0}),e.prototype.add=function(e){var t=this,n={event:e,listener:null};this.events.push(n),this.hasListeners&&this.hook(n);return function(e){return{dispose:function(){e()}}}(function(e){var t,n=this,r=!1;return function(){return r?t:(r=!0,t=e.apply(n,arguments))}}((function(){t.hasListeners&&t.unhook(n);var e=t.events.indexOf(n);t.events.splice(e,1)})))},e.prototype.onFirstListenerAdd=function(){var e=this;this.hasListeners=!0,this.events.forEach((function(t){return e.hook(t)}))},e.prototype.onLastListenerRemove=function(){var e=this;this.hasListeners=!1,this.events.forEach((function(t){return e.unhook(t)}))},e.prototype.hook=function(e){var t=this;e.listener=e.event((function(e){return t.emitter.fire(e)}))},e.prototype.unhook=function(e){e.listener&&e.listener.dispose(),e.listener=null},e.prototype.dispose=function(){this.emitter.dispose()}}(),function(){function e(){this.buffers=[]}e.prototype.wrapEvent=function(e){var t=this;return function(n,r,i){return e((function(e){var i=t.buffers[t.buffers.length-1];i?i.push((function(){return n.call(r,e)})):n.call(r,e)}),void 0,i)}},e.prototype.bufferEvents=function(e){var t=[];this.buffers.push(t);var n=e();return this.buffers.pop(),t.forEach((function(e){return e()})),n}}(),function(){function e(){var e=this;this.listening=!1,this.inputEvent=le.None,this.inputEventListener=l.None,this.emitter=new pe({onFirstListenerDidAdd:function(){e.listening=!0,e.inputEventListener=e.inputEvent(e.emitter.fire,e.emitter)},onLastListenerRemove:function(){e.listening=!1,e.inputEventListener.dispose()}}),this.event=this.emitter.event}Object.defineProperty(e.prototype,"input",{set:function(e){this.inputEvent=e,this.listening&&(this.inputEventListener.dispose(),this.inputEventListener=e(this.emitter.fire,this.emitter))},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){this.inputEventListener.dispose(),this.emitter.dispose()}}(),Object.freeze((function(e,t){var n=setTimeout(e.bind(t),0);return{dispose:function(){clearTimeout(n)}}})));(me=de||(de={})).isCancellationToken=function(e){return e===me.None||e===me.Cancelled||e instanceof ve||!(!e||"object"!=typeof e)&&"boolean"==typeof e.isCancellationRequested&&"function"==typeof e.onCancellationRequested},me.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:le.None}),me.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:ge});var _e,ve=function(){function e(){this._isCancelled=!1,this._emitter=null}return e.prototype.cancel=function(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))},Object.defineProperty(e.prototype,"isCancellationRequested",{get:function(){return this._isCancelled},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onCancellationRequested",{get:function(){return this._isCancelled?ge:(this._emitter||(this._emitter=new pe),this._emitter.event)},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){this._emitter&&(this._emitter.dispose(),this._emitter=null)},e}(),ye=function(){function e(e){this._token=void 0,this._parentListener=void 0,this._parentListener=e&&e.onCancellationRequested(this.cancel,this)}return Object.defineProperty(e.prototype,"token",{get:function(){return this._token||(this._token=new ve),this._token},enumerable:!0,configurable:!0}),e.prototype.cancel=function(){this._token?this._token instanceof ve&&this._token.cancel():this._token=de.Cancelled},e.prototype.dispose=function(){this._parentListener&&this._parentListener.dispose(),this._token?this._token instanceof ve&&this._token.dispose():this._token=de.None},e}(),Ce=function(){function e(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}return e.prototype.define=function(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e},e.prototype.keyCodeToStr=function(e){return this._keyCodeToStr[e]},e.prototype.strToKeyCode=function(e){return this._strToKeyCode[e.toLowerCase()]||0},e}(),be=new Ce,Le=new Ce,Ne=new Ce;!function(){function e(e,t,n,r){void 0===n&&(n=t),void 0===r&&(r=n),be.define(e,t),Le.define(e,n),Ne.define(e,r)}e(0,"unknown"),e(1,"Backspace"),e(2,"Tab"),e(3,"Enter"),e(4,"Shift"),e(5,"Ctrl"),e(6,"Alt"),e(7,"PauseBreak"),e(8,"CapsLock"),e(9,"Escape"),e(10,"Space"),e(11,"PageUp"),e(12,"PageDown"),e(13,"End"),e(14,"Home"),e(15,"LeftArrow","Left"),e(16,"UpArrow","Up"),e(17,"RightArrow","Right"),e(18,"DownArrow","Down"),e(19,"Insert"),e(20,"Delete"),e(21,"0"),e(22,"1"),e(23,"2"),e(24,"3"),e(25,"4"),e(26,"5"),e(27,"6"),e(28,"7"),e(29,"8"),e(30,"9"),e(31,"A"),e(32,"B"),e(33,"C"),e(34,"D"),e(35,"E"),e(36,"F"),e(37,"G"),e(38,"H"),e(39,"I"),e(40,"J"),e(41,"K"),e(42,"L"),e(43,"M"),e(44,"N"),e(45,"O"),e(46,"P"),e(47,"Q"),e(48,"R"),e(49,"S"),e(50,"T"),e(51,"U"),e(52,"V"),e(53,"W"),e(54,"X"),e(55,"Y"),e(56,"Z"),e(57,"Meta"),e(58,"ContextMenu"),e(59,"F1"),e(60,"F2"),e(61,"F3"),e(62,"F4"),e(63,"F5"),e(64,"F6"),e(65,"F7"),e(66,"F8"),e(67,"F9"),e(68,"F10"),e(69,"F11"),e(70,"F12"),e(71,"F13"),e(72,"F14"),e(73,"F15"),e(74,"F16"),e(75,"F17"),e(76,"F18"),e(77,"F19"),e(78,"NumLock"),e(79,"ScrollLock"),e(80,";",";","OEM_1"),e(81,"=","=","OEM_PLUS"),e(82,",",",","OEM_COMMA"),e(83,"-","-","OEM_MINUS"),e(84,".",".","OEM_PERIOD"),e(85,"/","/","OEM_2"),e(86,"`","`","OEM_3"),e(110,"ABNT_C1"),e(111,"ABNT_C2"),e(87,"[","[","OEM_4"),e(88,"\\","\\","OEM_5"),e(89,"]","]","OEM_6"),e(90,"'","'","OEM_7"),e(91,"OEM_8"),e(92,"OEM_102"),e(93,"NumPad0"),e(94,"NumPad1"),e(95,"NumPad2"),e(96,"NumPad3"),e(97,"NumPad4"),e(98,"NumPad5"),e(99,"NumPad6"),e(100,"NumPad7"),e(101,"NumPad8"),e(102,"NumPad9"),e(103,"NumPad_Multiply"),e(104,"NumPad_Add"),e(105,"NumPad_Separator"),e(106,"NumPad_Subtract"),e(107,"NumPad_Decimal"),e(108,"NumPad_Divide")}(),function(e){e.toString=function(e){return be.keyCodeToStr(e)},e.fromString=function(e){return be.strToKeyCode(e)},e.toUserSettingsUS=function(e){return Le.keyCodeToStr(e)},e.toUserSettingsGeneral=function(e){return Ne.keyCodeToStr(e)},e.fromUserSettings=function(e){return Le.strToKeyCode(e)||Ne.strToKeyCode(e)}}(_e||(_e={}));!function(){function e(e,t,n,r,i){this.ctrlKey=e,this.shiftKey=t,this.altKey=n,this.metaKey=r,this.keyCode=i}e.prototype.equals=function(e){return this.ctrlKey===e.ctrlKey&&this.shiftKey===e.shiftKey&&this.altKey===e.altKey&&this.metaKey===e.metaKey&&this.keyCode===e.keyCode},e.prototype.isModifierKey=function(){return 0===this.keyCode||5===this.keyCode||57===this.keyCode||6===this.keyCode||4===this.keyCode},e.prototype.toChord=function(){return new $e([this])},e.prototype.isDuplicateModifierCase=function(){return this.ctrlKey&&5===this.keyCode||this.shiftKey&&4===this.keyCode||this.altKey&&6===this.keyCode||this.metaKey&&57===this.keyCode}}();var Ee,Se,we,Ae,Me,Te,Pe,Oe,xe,Ie,Re,ke,Ue,Fe,De,Ke,qe,Ve,Be,je,Ye,We,He,Ge,Qe,ze,Xe,$e=function(){function e(e){if(0===e.length)throw(t="parts")?new Error("Illegal argument: "+t):new Error("Illegal argument");var t;this.parts=e}return e.prototype.equals=function(e){if(null===e)return!1;if(this.parts.length!==e.parts.length)return!1;for(var t=0;t "+this.positionLineNumber+","+this.positionColumn+"]"},t.prototype.equalsSelection=function(e){return t.selectionsEqual(this,e)},t.selectionsEqual=function(e,t){return e.selectionStartLineNumber===t.selectionStartLineNumber&&e.selectionStartColumn===t.selectionStartColumn&&e.positionLineNumber===t.positionLineNumber&&e.positionColumn===t.positionColumn},t.prototype.getDirection=function(){return this.selectionStartLineNumber===this.startLineNumber&&this.selectionStartColumn===this.startColumn?0:1},t.prototype.setEndPosition=function(e,n){return 0===this.getDirection()?new t(this.startLineNumber,this.startColumn,e,n):new t(e,n,this.startLineNumber,this.startColumn)},t.prototype.getPosition=function(){return new B(this.positionLineNumber,this.positionColumn)},t.prototype.setStartPosition=function(e,n){return 0===this.getDirection()?new t(e,n,this.endLineNumber,this.endColumn):new t(this.endLineNumber,this.endColumn,e,n)},t.fromPositions=function(e,n){return void 0===n&&(n=e),new t(e.lineNumber,e.column,n.lineNumber,n.column)},t.liftSelection=function(e){return new t(e.selectionStartLineNumber,e.selectionStartColumn,e.positionLineNumber,e.positionColumn)},t.selectionsArrEqual=function(e,t){if(e&&!t||!e&&t)return!1;if(!e&&!t)return!0;if(e.length!==t.length)return!1;for(var n=0,r=e.length;n>>0)>>>0}(e,t)},e.CtrlCmd=2048,e.Shift=1024,e.Alt=512,e.WinCtrl=256,e}();var nt=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),rt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return nt(t,e),Object.defineProperty(t.prototype,"uri",{get:function(){return this._uri},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"version",{get:function(){return this._versionId},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"eol",{get:function(){return this._eol},enumerable:!0,configurable:!0}),t.prototype.getValue=function(){return this.getText()},t.prototype.getLinesContent=function(){return this._lines.slice(0)},t.prototype.getLineCount=function(){return this._lines.length},t.prototype.getLineContent=function(e){return this._lines[e-1]},t.prototype.getWordAtPosition=function(e,t){var n=function(e,t,n,r){t.lastIndex=0;var i=t.exec(n);if(!i)return null;var o=i[0].indexOf(" ")>=0?function(e,t,n,r){var i,o=e-1-r;for(t.lastIndex=0;i=t.exec(n);){var s=i.index||0;if(s>o)return null;if(t.lastIndex>=o)return{word:i[0],startColumn:r+1+s,endColumn:r+1+t.lastIndex}}return null}(e,t,n,r):function(e,t,n,r){var i,o=e-1-r,s=n.lastIndexOf(" ",o-1)+1;for(t.lastIndex=s;i=t.exec(n);){var u=i.index||0;if(u<=o&&t.lastIndex>=o)return{word:i[0],startColumn:r+1+u,endColumn:r+1+t.lastIndex}}return null}(e,t,n,r);return t.lastIndex=0,o}(e.column,function(e){var t=ne;if(e&&e instanceof RegExp)if(e.global)t=e;else{var n="g";e.ignoreCase&&(n+="i"),e.multiline&&(n+="m"),e.unicode&&(n+="u"),t=new RegExp(e.source,n)}return t.lastIndex=0,t}(t),this._lines[e.lineNumber-1],0);return n?new j(e.lineNumber,n.startColumn,e.lineNumber,n.endColumn):null},t.prototype.getWordUntilPosition=function(e,t){var n=this.getWordAtPosition(e,t);return n?{word:this._lines[e.lineNumber-1].substring(n.startColumn-1,e.column-1),startColumn:n.startColumn,endColumn:e.column}:{word:"",startColumn:e.column,endColumn:e.column}},t.prototype.createWordIterator=function(e){var t,n,r=this,i=0,o=0,s=[],u=function(){if(o=r._lines.length?w:(n=r._lines[i],s=r._wordenize(n,e),o=0,i+=1,u())};return{next:u}},t.prototype.getLineWords=function(e,t){for(var n=this._lines[e-1],r=[],i=0,o=this._wordenize(n,t);ithis._lines.length)t=this._lines.length,n=this._lines[t-1].length+1,r=!0;else{var i=this._lines[t-1].length+1;n<1?(n=1,r=!0):n>i&&(n=i,r=!0)}return r?{lineNumber:t,column:n}:e},t}(te),it=function(e){function t(t){var n=e.call(this,t)||this;return n._models=Object.create(null),n}return nt(t,e),t.prototype.dispose=function(){this._models=Object.create(null)},t.prototype._getModel=function(e){return this._models[e]},t.prototype._getModels=function(){var e=this,t=[];return Object.keys(this._models).forEach((function(n){return t.push(e._models[n])})),t},t.prototype.acceptNewModel=function(e){this._models[e.url]=new rt(k.parse(e.url),e.lines,e.EOL,e.versionId)},t.prototype.acceptModelChanged=function(e,t){this._models[e]&&this._models[e].onEvents(t)},t.prototype.acceptRemovedModel=function(e){this._models[e]&&delete this._models[e]},t}(function(){function e(e){this._foreignModuleFactory=e,this._foreignModule=null}return e.prototype.computeDiff=function(e,t,n){var r=this._getModel(e),i=this._getModel(t);if(!r||!i)return Promise.resolve(null);var o=r.getLinesContent(),s=i.getLinesContent(),u=new z(o,s,{shouldComputeCharChanges:!0,shouldPostProcessCharChanges:!0,shouldIgnoreTrimWhitespace:n,shouldMakePrettyDiff:!0}).computeDiff(),a=!(u.length>0)&&this._modelsAreIdentical(r,i);return Promise.resolve({identical:a,changes:u})},e.prototype._modelsAreIdentical=function(e,t){var n=e.getLineCount();if(n!==t.getLineCount())return!1;for(var r=1;r<=n;r++){if(e.getLineContent(r)!==t.getLineContent(r))return!1}return!0},e.prototype.computeMoreMinimalEdits=function(t,n){var r=this._getModel(t);if(!r)return Promise.resolve(n);for(var i=[],o=void 0,s=0,u=n=g(n,(function(e,t){return e.range&&t.range?j.compareRangesUsingStarts(e.range,t.range):(e.range?0:1)-(t.range?0:1)}));se._diffLimit)i.push({range:l,text:c});else for(var d=y(h,c,!1),m=r.offsetAt(j.lift(l).getStartPosition()),p=0,_=d;p<_.length;p++){var v=_[p],C=r.positionAt(m+v.originalStart),b=r.positionAt(m+v.originalStart+v.originalLength),L={text:c.substr(v.modifiedStart,v.modifiedLength),range:{startLineNumber:C.lineNumber,startColumn:C.column,endLineNumber:b.lineNumber,endColumn:b.column}};r.getValueInRange(L.range)!==L.text&&i.push(L)}}}return"number"==typeof o&&i.push({eol:o,text:"",range:{startLineNumber:0,startColumn:0,endLineNumber:0,endColumn:0}}),Promise.resolve(i)},e.prototype.computeLinks=function(e){var t=this._getModel(e);return t?Promise.resolve(function(e){return e&&"function"==typeof e.getLineCount&&"function"==typeof e.getLineContent?ue.computeLinks(e):[]}(t)):Promise.resolve(null)},e.prototype.textualSuggest=function(t,n,r,i){var o=this._getModel(t);if(!o)return Promise.resolve(null);var s=Object.create(null),u=[],a=new RegExp(r,i),l=o.getWordUntilPosition(n,a),c=o.getWordAtPosition(n,a);c&&(s[o.getValueInRange(c)]=!0);for(var f=o.createWordIterator(a),h=f.next();!h.done&&u.length<=e._suggestionsLimit;h=f.next()){var d=h.value;s[d]||(s[d]=!0,isNaN(Number(d))&&u.push({kind:18,label:d,insertText:d,range:{startLineNumber:n.lineNumber,startColumn:l.startColumn,endLineNumber:n.lineNumber,endColumn:l.endColumn}}))}return Promise.resolve({suggestions:u})},e.prototype.computeWordRanges=function(e,t,n,r){var i=this._getModel(e);if(!i)return Promise.resolve(Object.create(null));for(var o=new RegExp(n,r),s=Object.create(null),u=t.startLineNumber;u{let e,t,n,r,i,o={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},s=function(t){throw{at:e,text:t,message:t}},u=function(t){return t&&t!==n&&s("Expected '"+t+"' instead of '"+n+"'"),n=r.charAt(e),e+=1,n},a=function(t,i){let o=e,u=r.indexOf(t,o);var a;return u<0&&s(i||"Expected '"+t+"'"),a=u+t.length,n=r.charAt(a),e=a+1,r.substring(o,u)},l=function(){var e,t="";for("-"===n&&(t="-",u("-"));n>="0"&&"9">=n;)t+=n,u();if("."===n)for(t+=".";u()&&n>="0"&&"9">=n;)t+=n;if("e"===n||"E"===n)for(t+=n,u(),("-"===n||"+"===n)&&(t+=n,u());n>="0"&&"9">=n;)t+=n,u();return e=+t,isNaN(e)?void s("Bad number"):e},c=function(){let t,i,l,c="";if('"'===n){if(f='""',r.substr(e,f.length)===f)return u('"'),u('"'),a('"""','failed to find closing \'"""\'');for(;u();){if('"'===n)return u(),c;if("\\"===n)if(u(),"u"===n){for(l=0,i=0;4>i&&(t=parseInt(u(),16),isFinite(t));i+=1)l=16*l+t;c+=String.fromCharCode(l)}else{if("string"!=typeof o[n])break;c+=o[n]}else c+=n}}var f;s("Bad string")},f=function(){for(;n&&" ">=n;)u()};return i=function(){switch(f(),n){case"{":return function(){var r,o,a,l={};if("{"===n){if(u("{"),f(),"}"===n)return u("}"),l;for(;n;){let s=e;if(r=c(),f(),u(":"),Object.hasOwnProperty.call(l,r)&&(o='Duplicate key "'+r+'"',a=s,t.push({type:ut.warning,at:a,text:o})),l[r]=i(),f(),"}"===n)return u("}"),l;u(","),f()}}s("Bad object")}();case"[":return function(){var e=[];if("["===n){if(u("["),f(),"]"===n)return u("]"),e;for(;n;){if(e.push(i()),f(),"]"===n)return u("]"),e;u(","),f()}}s("Bad array")}();case'"':return c();case"-":return l();default:return n>="0"&&"9">=n?l():function(){switch(n){case"t":return u("t"),u("r"),u("u"),u("e"),!0;case"f":return u("f"),u("a"),u("l"),u("s"),u("e"),!1;case"n":return u("n"),u("u"),u("l"),u("l"),null}s("Unexpected '"+n+"'")}()}},function(o){t=[];let u=!1;r=o,e=0,n=" ",f();try{i()}catch(e){u=!0,t.push({type:ut.error,at:e.at-1,text:e.message})}return!u&&n&&s("Syntax error"),{annotations:t}}};class lt{constructor(e){this.ctx=e}async parse(){this.parser||(this.parser=at());const[e]=this.ctx.getMirrorModels();return this.parser(e.getValue())}}self.onmessage=()=>{st((e,t)=>new lt(e))}}]); \ No newline at end of file diff --git a/packages/kbn-monaco/xjson/language.ts b/packages/kbn-monaco/xjson/language.ts index 79a2ed7c0241d9..aed010eddc1e08 100644 --- a/packages/kbn-monaco/xjson/language.ts +++ b/packages/kbn-monaco/xjson/language.ts @@ -24,7 +24,7 @@ import { WorkerProxyService } from './worker_proxy_service'; import { registerLexerRules } from './lexer_rules'; import { ID } from './constants'; // @ts-ignore -import workerSrc from '!!raw-loader!./dist/bundle.editor.worker.js'; +import workerSrc from '!!raw-loader!../target/xjson.worker.js'; const wps = new WorkerProxyService(); diff --git a/packages/kbn-monaco/xjson/worker/xjson.worker.ts b/packages/kbn-monaco/xjson/worker/xjson.worker.ts index 9eac0d914211c9..eb5e9ca81eb617 100644 --- a/packages/kbn-monaco/xjson/worker/xjson.worker.ts +++ b/packages/kbn-monaco/xjson/worker/xjson.worker.ts @@ -18,11 +18,10 @@ */ // Please note: this module is intended to be run inside of a webworker. - /* eslint-disable @kbn/eslint/module_migration */ + // @ts-ignore import * as worker from 'monaco-editor/esm/vs/editor/editor.worker'; -/* eslint-enable @kbn/eslint/module_migration */ import { XJsonWorker } from './xjson_worker'; self.onmessage = () => { From 73c33b258d481edc072b091f71bee116191a0234 Mon Sep 17 00:00:00 2001 From: spalger Date: Fri, 29 May 2020 16:48:12 -0700 Subject: [PATCH 19/26] only build worker, don't pre-bundle monaco --- packages/kbn-monaco/package.json | 4 - packages/kbn-monaco/scripts/build.js | 79 ++++++++----------- packages/kbn-monaco/{ => src}/index.ts | 2 +- packages/kbn-monaco/{ => src}/monaco.ts | 0 packages/kbn-monaco/{ => src}/xjson/README.md | 0 .../kbn-monaco/{ => src}/xjson/constants.ts | 0 .../kbn-monaco/{ => src}/xjson/grammar.ts | 0 packages/kbn-monaco/{ => src}/xjson/index.ts | 0 .../kbn-monaco/{ => src}/xjson/language.ts | 2 +- .../{ => src}/xjson/lexer_rules/esql.ts | 0 .../{ => src}/xjson/lexer_rules/index.ts | 0 .../{ => src}/xjson/lexer_rules/painless.ts | 0 .../{ => src}/xjson/lexer_rules/shared.ts | 0 .../{ => src}/xjson/lexer_rules/xjson.ts | 0 .../{ => src}/xjson/worker/index.ts | 0 .../{ => src}/xjson/worker/xjson.worker.ts | 0 .../{ => src}/xjson/worker/xjson_worker.ts | 0 .../{ => src}/xjson/worker_proxy_service.ts | 0 packages/kbn-monaco/tsconfig.json | 14 +++- packages/kbn-monaco/webpack.config.js | 67 +++++++--------- packages/kbn-monaco/webpack.worker.config.js | 51 ------------ .../kbn-monaco/xjson/webpack.worker.config.js | 50 ------------ packages/kbn-ui-shared-deps/entry.js | 3 - 23 files changed, 72 insertions(+), 200 deletions(-) rename packages/kbn-monaco/{ => src}/index.ts (92%) rename packages/kbn-monaco/{ => src}/monaco.ts (100%) rename packages/kbn-monaco/{ => src}/xjson/README.md (100%) rename packages/kbn-monaco/{ => src}/xjson/constants.ts (100%) rename packages/kbn-monaco/{ => src}/xjson/grammar.ts (100%) rename packages/kbn-monaco/{ => src}/xjson/index.ts (100%) rename packages/kbn-monaco/{ => src}/xjson/language.ts (97%) rename packages/kbn-monaco/{ => src}/xjson/lexer_rules/esql.ts (100%) rename packages/kbn-monaco/{ => src}/xjson/lexer_rules/index.ts (100%) rename packages/kbn-monaco/{ => src}/xjson/lexer_rules/painless.ts (100%) rename packages/kbn-monaco/{ => src}/xjson/lexer_rules/shared.ts (100%) rename packages/kbn-monaco/{ => src}/xjson/lexer_rules/xjson.ts (100%) rename packages/kbn-monaco/{ => src}/xjson/worker/index.ts (100%) rename packages/kbn-monaco/{ => src}/xjson/worker/xjson.worker.ts (100%) rename packages/kbn-monaco/{ => src}/xjson/worker/xjson_worker.ts (100%) rename packages/kbn-monaco/{ => src}/xjson/worker_proxy_service.ts (100%) delete mode 100644 packages/kbn-monaco/webpack.worker.config.js delete mode 100644 packages/kbn-monaco/xjson/webpack.worker.config.js diff --git a/packages/kbn-monaco/package.json b/packages/kbn-monaco/package.json index 7f25e85fe9d274..94f30666c861be 100644 --- a/packages/kbn-monaco/package.json +++ b/packages/kbn-monaco/package.json @@ -2,9 +2,7 @@ "name": "@kbn/monaco", "version": "1.0.0", "private": true, - "license": "MIT", "main": "./target/index.js", - "types": "./target/types/index.d.ts", "scripts": { "build": "node ./scripts/build.js", "kbn:bootstrap": "yarn build --dev" @@ -18,8 +16,6 @@ "babel-loader": "^8.0.6", "css-loader": "^3.4.2", "del": "^5.1.0", - "getopts": "^2.2.4", - "mini-css-extract-plugin": "0.8.0", "raw-loader": "3.1.0", "supports-color": "^7.0.0", "typescript": "3.7.2", diff --git a/packages/kbn-monaco/scripts/build.js b/packages/kbn-monaco/scripts/build.js index ab9467973c1d87..c5540e3c956c8f 100644 --- a/packages/kbn-monaco/scripts/build.js +++ b/packages/kbn-monaco/scripts/build.js @@ -19,61 +19,46 @@ const path = require('path'); const del = require('del'); -const getopts = require('getopts'); const supportsColor = require('supports-color'); -const { ToolingLog, withProcRunner, pickLevelFromFlags } = require('@kbn/dev-utils'); +const { run } = require('@kbn/dev-utils'); const TARGET_BUILD_DIR = path.resolve(__dirname, '../target'); const ROOT_DIR = path.resolve(__dirname, '../'); const WEBPACK_CONFIG_PATH = path.resolve(ROOT_DIR, 'webpack.config.js'); -const WORKER_WEBPACK_CONFIG_PATH = path.resolve(ROOT_DIR, 'webpack.worker.config.js'); -const flags = getopts(process.argv, { - boolean: ['dev'], -}); +run( + async ({ procRunner, log, flags }) => { + log.info('Deleting old output'); -const log = new ToolingLog({ - level: pickLevelFromFlags(flags), - writeTo: process.stdout, -}); + await del(TARGET_BUILD_DIR); -withProcRunner(log, async (proc) => { - log.info('Deleting old output'); + const cwd = ROOT_DIR; + const env = { ...process.env }; + if (supportsColor.stdout) { + env.FORCE_COLOR = 'true'; + } - await del(TARGET_BUILD_DIR); + await procRunner.run('worker', { + cmd: 'webpack', + args: ['--config', WEBPACK_CONFIG_PATH, flags.dev ? '--env.dev' : '--env.prod'], + wait: true, + env, + cwd, + }); - const cwd = ROOT_DIR; - const env = { ...process.env }; - if (supportsColor.stdout) { - env.FORCE_COLOR = 'true'; - } - - await proc.run('worker wp', { - cmd: 'webpack', - args: ['--config', WORKER_WEBPACK_CONFIG_PATH, flags.dev ? '--env.dev' : '--env.prod'], - wait: true, - env, - cwd, - }); - - await proc.run('base wp ', { - cmd: 'webpack', - args: ['--config', WEBPACK_CONFIG_PATH, flags.dev ? '--env.dev' : '--env.prod'], - wait: true, - env, - cwd, - }); + await procRunner.run('tsc ', { + cmd: 'tsc', + args: [], + wait: true, + env, + cwd, + }); - await proc.run('tsc ', { - cmd: 'tsc', - args: ['--emitDeclarationOnly'], - wait: true, - env, - cwd, - }); - - log.success('Complete'); -}).catch((error) => { - log.error(error); - process.exit(1); -}); + log.success('Complete'); + }, + { + flags: { + boolean: ['dev'], + }, + } +); diff --git a/packages/kbn-monaco/index.ts b/packages/kbn-monaco/src/index.ts similarity index 92% rename from packages/kbn-monaco/index.ts rename to packages/kbn-monaco/src/index.ts index 6f322b9a872ce6..9213a1bfe13270 100644 --- a/packages/kbn-monaco/index.ts +++ b/packages/kbn-monaco/src/index.ts @@ -21,5 +21,5 @@ export { monaco } from './monaco'; export { XJsonLang } from './xjson'; /* eslint-disable-next-line @kbn/eslint/module_migration */ -import BarePluginApi from 'monaco-editor/esm/vs/editor/editor.api'; +import * as BarePluginApi from 'monaco-editor/esm/vs/editor/editor.api'; export { BarePluginApi }; diff --git a/packages/kbn-monaco/monaco.ts b/packages/kbn-monaco/src/monaco.ts similarity index 100% rename from packages/kbn-monaco/monaco.ts rename to packages/kbn-monaco/src/monaco.ts diff --git a/packages/kbn-monaco/xjson/README.md b/packages/kbn-monaco/src/xjson/README.md similarity index 100% rename from packages/kbn-monaco/xjson/README.md rename to packages/kbn-monaco/src/xjson/README.md diff --git a/packages/kbn-monaco/xjson/constants.ts b/packages/kbn-monaco/src/xjson/constants.ts similarity index 100% rename from packages/kbn-monaco/xjson/constants.ts rename to packages/kbn-monaco/src/xjson/constants.ts diff --git a/packages/kbn-monaco/xjson/grammar.ts b/packages/kbn-monaco/src/xjson/grammar.ts similarity index 100% rename from packages/kbn-monaco/xjson/grammar.ts rename to packages/kbn-monaco/src/xjson/grammar.ts diff --git a/packages/kbn-monaco/xjson/index.ts b/packages/kbn-monaco/src/xjson/index.ts similarity index 100% rename from packages/kbn-monaco/xjson/index.ts rename to packages/kbn-monaco/src/xjson/index.ts diff --git a/packages/kbn-monaco/xjson/language.ts b/packages/kbn-monaco/src/xjson/language.ts similarity index 97% rename from packages/kbn-monaco/xjson/language.ts rename to packages/kbn-monaco/src/xjson/language.ts index aed010eddc1e08..c5be909c0e2883 100644 --- a/packages/kbn-monaco/xjson/language.ts +++ b/packages/kbn-monaco/src/xjson/language.ts @@ -24,7 +24,7 @@ import { WorkerProxyService } from './worker_proxy_service'; import { registerLexerRules } from './lexer_rules'; import { ID } from './constants'; // @ts-ignore -import workerSrc from '!!raw-loader!../target/xjson.worker.js'; +import workerSrc from '!!raw-loader!../../target/public/xjson.worker.js'; const wps = new WorkerProxyService(); diff --git a/packages/kbn-monaco/xjson/lexer_rules/esql.ts b/packages/kbn-monaco/src/xjson/lexer_rules/esql.ts similarity index 100% rename from packages/kbn-monaco/xjson/lexer_rules/esql.ts rename to packages/kbn-monaco/src/xjson/lexer_rules/esql.ts diff --git a/packages/kbn-monaco/xjson/lexer_rules/index.ts b/packages/kbn-monaco/src/xjson/lexer_rules/index.ts similarity index 100% rename from packages/kbn-monaco/xjson/lexer_rules/index.ts rename to packages/kbn-monaco/src/xjson/lexer_rules/index.ts diff --git a/packages/kbn-monaco/xjson/lexer_rules/painless.ts b/packages/kbn-monaco/src/xjson/lexer_rules/painless.ts similarity index 100% rename from packages/kbn-monaco/xjson/lexer_rules/painless.ts rename to packages/kbn-monaco/src/xjson/lexer_rules/painless.ts diff --git a/packages/kbn-monaco/xjson/lexer_rules/shared.ts b/packages/kbn-monaco/src/xjson/lexer_rules/shared.ts similarity index 100% rename from packages/kbn-monaco/xjson/lexer_rules/shared.ts rename to packages/kbn-monaco/src/xjson/lexer_rules/shared.ts diff --git a/packages/kbn-monaco/xjson/lexer_rules/xjson.ts b/packages/kbn-monaco/src/xjson/lexer_rules/xjson.ts similarity index 100% rename from packages/kbn-monaco/xjson/lexer_rules/xjson.ts rename to packages/kbn-monaco/src/xjson/lexer_rules/xjson.ts diff --git a/packages/kbn-monaco/xjson/worker/index.ts b/packages/kbn-monaco/src/xjson/worker/index.ts similarity index 100% rename from packages/kbn-monaco/xjson/worker/index.ts rename to packages/kbn-monaco/src/xjson/worker/index.ts diff --git a/packages/kbn-monaco/xjson/worker/xjson.worker.ts b/packages/kbn-monaco/src/xjson/worker/xjson.worker.ts similarity index 100% rename from packages/kbn-monaco/xjson/worker/xjson.worker.ts rename to packages/kbn-monaco/src/xjson/worker/xjson.worker.ts diff --git a/packages/kbn-monaco/xjson/worker/xjson_worker.ts b/packages/kbn-monaco/src/xjson/worker/xjson_worker.ts similarity index 100% rename from packages/kbn-monaco/xjson/worker/xjson_worker.ts rename to packages/kbn-monaco/src/xjson/worker/xjson_worker.ts diff --git a/packages/kbn-monaco/xjson/worker_proxy_service.ts b/packages/kbn-monaco/src/xjson/worker_proxy_service.ts similarity index 100% rename from packages/kbn-monaco/xjson/worker_proxy_service.ts rename to packages/kbn-monaco/src/xjson/worker_proxy_service.ts diff --git a/packages/kbn-monaco/tsconfig.json b/packages/kbn-monaco/tsconfig.json index 32c7ca98c1bc86..95acfd32b24dd3 100644 --- a/packages/kbn-monaco/tsconfig.json +++ b/packages/kbn-monaco/tsconfig.json @@ -1,9 +1,15 @@ { "extends": "../../tsconfig.json", - "include": ["xjson/**/*.ts", "index.ts", "monaco.ts"], "compilerOptions": { + "outDir": "./target", "declaration": true, - "declarationDir": "./target/types", - "types": ["jest", "node"] - } + "sourceMap": true, + "types": [ + "jest", + "node" + ] + }, + "include": [ + "src/**/*" + ] } diff --git a/packages/kbn-monaco/webpack.config.js b/packages/kbn-monaco/webpack.config.js index de4ec98ebeb83d..4eab34652cea6f 100644 --- a/packages/kbn-monaco/webpack.config.js +++ b/packages/kbn-monaco/webpack.config.js @@ -16,47 +16,36 @@ * specific language governing permissions and limitations * under the License. */ + const path = require('path'); -const MiniCssExtractPlugin = require('mini-css-extract-plugin'); -module.exports = (env) => { - return { - mode: env.prod ? 'production' : 'development', - devtool: env.prod ? false : '#cheap-source-map', - entry: './index.ts', - output: { - filename: 'index.js', - path: path.resolve(__dirname, 'target'), - libraryTarget: 'commonjs', - }, - resolve: { - modules: ['node_modules'], - extensions: ['.js', '.ts'], - }, - stats: 'errors-only', - module: { - rules: [ - { - test: /\.(js|ts)$/, - exclude: /node_modules/, - use: { - loader: 'babel-loader', - options: { - babelrc: false, - presets: [require.resolve('@kbn/babel-preset/webpack_preset')], - }, +const createLangWorkerConfig = (lang) => ({ + mode: 'production', + entry: path.resolve(__dirname, 'src', lang, 'worker', `${lang}.worker.ts`), + output: { + path: path.resolve(__dirname, 'target/public'), + filename: `${lang}.worker.js`, + }, + resolve: { + modules: ['node_modules'], + extensions: ['.js', '.ts', '.tsx'], + }, + stats: 'errors-only', + module: { + rules: [ + { + test: /\.(js|ts)$/, + exclude: /node_modules/, + use: { + loader: 'babel-loader', + options: { + babelrc: false, + presets: [require.resolve('@kbn/babel-preset/webpack_preset')], }, }, - { - test: /\.css$/, - use: [MiniCssExtractPlugin.loader, 'css-loader'], - }, - ], - }, - plugins: [ - new MiniCssExtractPlugin({ - filename: 'index.css', - }), + }, ], - }; -}; + }, +}); + +module.exports = [createLangWorkerConfig('xjson')]; diff --git a/packages/kbn-monaco/webpack.worker.config.js b/packages/kbn-monaco/webpack.worker.config.js deleted file mode 100644 index 0c28e7bd191acd..00000000000000 --- a/packages/kbn-monaco/webpack.worker.config.js +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -const path = require('path'); - -const createLangWorkerConfig = (lang) => ({ - mode: 'production', - entry: path.resolve(__dirname, lang, 'worker', `${lang}.worker.ts`), - output: { - path: path.resolve(__dirname, 'target'), - filename: `${lang}.worker.js`, - }, - resolve: { - modules: ['node_modules'], - extensions: ['.js', '.ts', '.tsx'], - }, - stats: 'errors-only', - module: { - rules: [ - { - test: /\.(js|ts)$/, - exclude: /node_modules/, - use: { - loader: 'babel-loader', - options: { - babelrc: false, - presets: [require.resolve('@kbn/babel-preset/webpack_preset')], - }, - }, - }, - ], - }, -}); - -module.exports = [createLangWorkerConfig('xjson')]; diff --git a/packages/kbn-monaco/xjson/webpack.worker.config.js b/packages/kbn-monaco/xjson/webpack.worker.config.js deleted file mode 100644 index 9ff6bad8c0d62d..00000000000000 --- a/packages/kbn-monaco/xjson/webpack.worker.config.js +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -const path = require('path'); - -const createConfig = (lang) => ({ - mode: 'production', - entry: path.resolve(__dirname, `./worker/${lang}.worker.ts`), - output: { - path: path.resolve(__dirname, 'dist'), - filename: 'bundle.editor.worker.js', - }, - resolve: { - modules: ['node_modules'], - extensions: ['.js', '.ts', '.tsx'], - }, - module: { - rules: [ - { - test: /\.(js|ts)$/, - exclude: /node_modules/, - use: { - loader: 'babel-loader', - options: { - babelrc: false, - presets: [require.resolve('@kbn/babel-preset/webpack_preset')], - }, - }, - }, - ], - }, -}); - -module.exports = createConfig('xjson'); diff --git a/packages/kbn-ui-shared-deps/entry.js b/packages/kbn-ui-shared-deps/entry.js index dfa978d0cad3ec..90ed5136a33440 100644 --- a/packages/kbn-ui-shared-deps/entry.js +++ b/packages/kbn-ui-shared-deps/entry.js @@ -19,9 +19,6 @@ require('./polyfills'); -// styles -require('@kbn/monaco/target/index.css'); - // must load before angular export const Jquery = require('jquery'); window.$ = window.jQuery = Jquery; From 979c8c69ab4434b40b0c4442a42834b112ed4084 Mon Sep 17 00:00:00 2001 From: spalger Date: Fri, 29 May 2020 17:12:20 -0700 Subject: [PATCH 20/26] fix type check errors --- .../public/application/components/editor.tsx | 2 +- .../painless_lab/public/services/language_service.ts | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/x-pack/plugins/painless_lab/public/application/components/editor.tsx b/x-pack/plugins/painless_lab/public/application/components/editor.tsx index 62158956b1a7b4..a6699ba45fa959 100644 --- a/x-pack/plugins/painless_lab/public/application/components/editor.tsx +++ b/x-pack/plugins/painless_lab/public/application/components/editor.tsx @@ -13,7 +13,7 @@ interface Props { } export function Editor({ code, onChange }: Props) { - const { XJsonLang, xJson, convertToJson, setXJson } = Monaco.useXJsonMode(code); + const { XJsonLang, xJson, setXJson } = Monaco.useXJsonMode(code); return ( Date: Fri, 29 May 2020 17:25:28 -0700 Subject: [PATCH 21/26] remove section from readme about committed dist --- packages/kbn-monaco/src/xjson/README.md | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/packages/kbn-monaco/src/xjson/README.md b/packages/kbn-monaco/src/xjson/README.md index a419db122bc6c0..8652d0bd776d20 100644 --- a/packages/kbn-monaco/src/xjson/README.md +++ b/packages/kbn-monaco/src/xjson/README.md @@ -10,18 +10,6 @@ Note: All source code. The worker proxy and worker instantiation code used in both the main thread and the worker thread. -### ./dist - -The transpiled, production-ready version of the worker code that will be loaded by Monaco client side. -Currently this is not served by Kibana but raw-loaded as a string and served with the source code via -the "raw-loader". - -See the related ./webpack.xjson-worker.config.js file that is runnable with Kibana's webpack with: - -```sh -yarn webpack --config ./xjson/webpack.worker.config.js -``` - ### ./lexer_rules Contains the Monarch-specific language tokenization rules for XJSON. Each set of rules registers itself against monaco. From df9a4ad61298f024925ed19cb1dc18770ce45ead Mon Sep 17 00:00:00 2001 From: spalger Date: Fri, 29 May 2020 18:26:08 -0700 Subject: [PATCH 22/26] keep editor.worker.js postfix --- packages/kbn-monaco/webpack.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/kbn-monaco/webpack.config.js b/packages/kbn-monaco/webpack.config.js index 4eab34652cea6f..1a7d8c031670c4 100644 --- a/packages/kbn-monaco/webpack.config.js +++ b/packages/kbn-monaco/webpack.config.js @@ -24,7 +24,7 @@ const createLangWorkerConfig = (lang) => ({ entry: path.resolve(__dirname, 'src', lang, 'worker', `${lang}.worker.ts`), output: { path: path.resolve(__dirname, 'target/public'), - filename: `${lang}.worker.js`, + filename: `${lang}.editor.worker.js`, }, resolve: { modules: ['node_modules'], From 7b135b5c791855db983939b667395dd54e010823 Mon Sep 17 00:00:00 2001 From: spalger Date: Fri, 29 May 2020 19:23:09 -0700 Subject: [PATCH 23/26] forgot to save update to import --- packages/kbn-monaco/src/xjson/language.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/kbn-monaco/src/xjson/language.ts b/packages/kbn-monaco/src/xjson/language.ts index c5be909c0e2883..fe505818d3c9ab 100644 --- a/packages/kbn-monaco/src/xjson/language.ts +++ b/packages/kbn-monaco/src/xjson/language.ts @@ -24,7 +24,7 @@ import { WorkerProxyService } from './worker_proxy_service'; import { registerLexerRules } from './lexer_rules'; import { ID } from './constants'; // @ts-ignore -import workerSrc from '!!raw-loader!../../target/public/xjson.worker.js'; +import workerSrc from '!!raw-loader!../../target/public/xjson.editor.worker.js'; const wps = new WorkerProxyService(); From c18af02663ad9c877b16cbdeb0ad350ebcba07f0 Mon Sep 17 00:00:00 2001 From: spalger Date: Fri, 29 May 2020 22:13:13 -0700 Subject: [PATCH 24/26] license package as apache-2.0 --- packages/kbn-monaco/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/kbn-monaco/package.json b/packages/kbn-monaco/package.json index 94f30666c861be..0a149f418ac24d 100644 --- a/packages/kbn-monaco/package.json +++ b/packages/kbn-monaco/package.json @@ -3,6 +3,7 @@ "version": "1.0.0", "private": true, "main": "./target/index.js", + "license": "Apache-2.0", "scripts": { "build": "node ./scripts/build.js", "kbn:bootstrap": "yarn build --dev" From ad9f4d221f192eda0370d49d612801fcbc98478d Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Tue, 2 Jun 2020 10:47:59 +0200 Subject: [PATCH 25/26] Added regenerator runtime for worker bundle --- packages/kbn-monaco/package.json | 1 + packages/kbn-monaco/src/xjson/worker/xjson.worker.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/kbn-monaco/package.json b/packages/kbn-monaco/package.json index 0a149f418ac24d..170c014e6e3265 100644 --- a/packages/kbn-monaco/package.json +++ b/packages/kbn-monaco/package.json @@ -9,6 +9,7 @@ "kbn:bootstrap": "yarn build --dev" }, "dependencies": { + "regenerator-runtime": "^0.13.3", "monaco-editor": "~0.17.0" }, "devDependencies": { diff --git a/packages/kbn-monaco/src/xjson/worker/xjson.worker.ts b/packages/kbn-monaco/src/xjson/worker/xjson.worker.ts index eb5e9ca81eb617..608e6446f4a22d 100644 --- a/packages/kbn-monaco/src/xjson/worker/xjson.worker.ts +++ b/packages/kbn-monaco/src/xjson/worker/xjson.worker.ts @@ -20,6 +20,7 @@ // Please note: this module is intended to be run inside of a webworker. /* eslint-disable @kbn/eslint/module_migration */ +import 'regenerator-runtime/runtime'; // @ts-ignore import * as worker from 'monaco-editor/esm/vs/editor/editor.worker'; import { XJsonWorker } from './xjson_worker'; From dcbf9c38d0e43c9a360e3e84efa11a6c287d3854 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Thu, 4 Jun 2020 11:57:20 +0200 Subject: [PATCH 26/26] revert changes to painless lab --- .../public/application/components/editor.tsx | 14 ++----- .../public/services/language_service.ts | 41 ++++++++++--------- 2 files changed, 24 insertions(+), 31 deletions(-) diff --git a/x-pack/plugins/painless_lab/public/application/components/editor.tsx b/x-pack/plugins/painless_lab/public/application/components/editor.tsx index a6699ba45fa959..b8891ce6524f55 100644 --- a/x-pack/plugins/painless_lab/public/application/components/editor.tsx +++ b/x-pack/plugins/painless_lab/public/application/components/editor.tsx @@ -4,7 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ import React from 'react'; -import { Monaco } from '../../../../../../src/plugins/es_ui_shared/public'; import { CodeEditor } from '../../../../../../src/plugins/kibana_react/public'; interface Props { @@ -13,21 +12,14 @@ interface Props { } export function Editor({ code, onChange }: Props) { - const { XJsonLang, xJson, setXJson } = Monaco.useXJsonMode(code); return ( { - XJsonLang.registerGrammarChecker(editor); - }} - value={xJson} - onChange={(value) => { - setXJson(value); - onChange(value); - }} + value={code} + onChange={onChange} options={{ fontSize: 12, minimap: { diff --git a/x-pack/plugins/painless_lab/public/services/language_service.ts b/x-pack/plugins/painless_lab/public/services/language_service.ts index 5f1f875e2347f3..68ac3ca290ad85 100644 --- a/x-pack/plugins/painless_lab/public/services/language_service.ts +++ b/x-pack/plugins/painless_lab/public/services/language_service.ts @@ -7,38 +7,39 @@ // It is important that we use this specific monaco instance so that // editor settings are registered against the instance our React component // uses. -// import { monaco } from '@kbn/monaco'; +import { monaco } from '@kbn/monaco'; // @ts-ignore -// import workerSrc from 'raw-loader!monaco-editor/min/vs/base/worker/workerMain.js'; +import workerSrc from 'raw-loader!monaco-editor/min/vs/base/worker/workerMain.js'; -// import { monacoPainlessLang } from '../lib'; +import { monacoPainlessLang } from '../lib'; -// const LANGUAGE_ID = 'painless'; +const LANGUAGE_ID = 'painless'; // Safely check whether these globals are present -// const CAN_CREATE_WORKER = typeof Blob === 'function' && typeof Worker === 'function'; +const CAN_CREATE_WORKER = typeof Blob === 'function' && typeof Worker === 'function'; export class LanguageService { - // private originalMonacoEnvironment: any; + private originalMonacoEnvironment: any; public setup() { - // monaco.languages.register({ id: LANGUAGE_ID }); - // monaco.languages.setMonarchTokensProvider(LANGUAGE_ID, monacoPainlessLang); - // if (CAN_CREATE_WORKER) { - // this.originalMonacoEnvironment = (window as any).MonacoEnvironment; - // (window as any).MonacoEnvironment = { - // getWorker: () => { - // const blob = new Blob([workerSrc], { type: 'application/javascript' }); - // return new Worker(window.URL.createObjectURL(blob)); - // }, - // }; - // } + monaco.languages.register({ id: LANGUAGE_ID }); + monaco.languages.setMonarchTokensProvider(LANGUAGE_ID, monacoPainlessLang); + + if (CAN_CREATE_WORKER) { + this.originalMonacoEnvironment = (window as any).MonacoEnvironment; + (window as any).MonacoEnvironment = { + getWorker: () => { + const blob = new Blob([workerSrc], { type: 'application/javascript' }); + return new Worker(window.URL.createObjectURL(blob)); + }, + }; + } } public stop() { - // if (CAN_CREATE_WORKER) { - // (window as any).MonacoEnvironment = this.originalMonacoEnvironment; - // } + if (CAN_CREATE_WORKER) { + (window as any).MonacoEnvironment = this.originalMonacoEnvironment; + } } }