notebook 7.1.1__py3-none-any.whl → 7.1.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of notebook might be problematic. Click here for more details.
- notebook/_version.py +1 -1
- notebook/static/1198.bundle.js +1 -1
- notebook/static/131.bundle.js +1 -1
- notebook/static/1337.bundle.js +1 -1
- notebook/static/134.bundle.js +1 -1
- notebook/static/1408.bundle.js +1 -1
- notebook/static/1496.bundle.js +1 -1
- notebook/static/1647.bundle.js +1 -1
- notebook/static/1650.bundle.js +1 -1
- notebook/static/1664.bundle.js +17 -17
- notebook/static/1682.bundle.js +1 -1
- notebook/static/1684.bundle.js +1 -1
- notebook/static/1809.bundle.js +1 -1
- notebook/static/1827.bundle.js +1 -1
- notebook/static/1833.bundle.js +1 -1
- notebook/static/1835.bundle.js +1 -1
- notebook/static/1950.bundle.js +1 -1
- notebook/static/1958.bundle.js +1 -1
- notebook/static/2007.bundle.js +1 -1
- notebook/static/2067.bundle.js +1 -1
- notebook/static/2088.bundle.js +1 -1
- notebook/static/2089.bundle.js +1 -1
- notebook/static/2122.bundle.js +1 -1
- notebook/static/2167.bundle.js +1 -1
- notebook/static/2184.bundle.js +1 -1
- notebook/static/2311.bundle.js +1 -1
- notebook/static/2401.bundle.js +1 -1
- notebook/static/2479.bundle.js +1 -1
- notebook/static/2489.bundle.js +1 -1
- notebook/static/2512.bundle.js +1 -1
- notebook/static/2577.bundle.js +1 -1
- notebook/static/2607.bundle.js +1 -1
- notebook/static/2615.bundle.js +1 -1
- notebook/static/2682.bundle.js +1 -1
- notebook/static/2866.bundle.js +1 -1
- notebook/static/2924.bundle.js +1 -1
- notebook/static/2944.bundle.js +1 -1
- notebook/static/3129.bundle.js +1 -1
- notebook/static/3146.bundle.js +1 -1
- notebook/static/3187.bundle.js +1 -1
- notebook/static/3213.bundle.js +1 -1
- notebook/static/3301.bundle.js +1 -1
- notebook/static/3340.bundle.js +1 -1
- notebook/static/3360.bundle.js +1 -1
- notebook/static/3466.bundle.js +1 -1
- notebook/static/3512.bundle.js +1 -1
- notebook/static/3654.bundle.js +1 -1
- notebook/static/3676.bundle.js +1 -1
- notebook/static/3680.bundle.js +1 -1
- notebook/static/3768.bundle.js +1 -1
- notebook/static/377.bundle.js +1 -1
- notebook/static/3863.bundle.js +1 -1
- notebook/static/3881.bundle.js +1 -1
- notebook/static/4042.bundle.js +1 -1
- notebook/static/4212.bundle.js +1 -1
- notebook/static/4382.bundle.js +1 -1
- notebook/static/4558.bundle.js +1 -1
- notebook/static/4645.bundle.js +1 -1
- notebook/static/4811.bundle.js +1 -1
- notebook/static/4837.bundle.js +1 -0
- notebook/static/5088.bundle.js +1 -1
- notebook/static/5099.bundle.js +1 -1
- notebook/static/5135.bundle.js +1 -1
- notebook/static/514.bundle.js +1 -1
- notebook/static/5263.bundle.js +1 -0
- notebook/static/5313.bundle.js +1 -1
- notebook/static/5325.bundle.js +1 -1
- notebook/static/5346.bundle.js +1 -1
- notebook/static/5426.bundle.js +1 -1
- notebook/static/5573.bundle.js +1 -1
- notebook/static/5601.bundle.js +1 -1
- notebook/static/5649.bundle.js +3 -3
- notebook/static/5733.bundle.js +1 -1
- notebook/static/5912.bundle.js +1 -1
- notebook/static/5921.bundle.js +1 -1
- notebook/static/6017.bundle.js +1 -1
- notebook/static/6139.bundle.js +1 -1
- notebook/static/62.bundle.js +1 -1
- notebook/static/6256.bundle.js +1 -1
- notebook/static/6345.bundle.js +1 -1
- notebook/static/6604.bundle.js +1 -1
- notebook/static/6621.bundle.js +1 -1
- notebook/static/6627.bundle.js +1 -1
- notebook/static/6815.bundle.js +1 -1
- notebook/static/6893.bundle.js +1 -1
- notebook/static/690.bundle.js +1 -1
- notebook/static/6962.bundle.js +1 -1
- notebook/static/6999.bundle.js +1 -1
- notebook/static/7226.bundle.js +1 -1
- notebook/static/7252.bundle.js +1 -1
- notebook/static/7302.bundle.js +1 -1
- notebook/static/7386.bundle.js +1 -1
- notebook/static/7391.bundle.js +1 -1
- notebook/static/7394.bundle.js +1 -1
- notebook/static/7603.bundle.js +1 -1
- notebook/static/7639.bundle.js +1 -1
- notebook/static/7684.bundle.js +1 -1
- notebook/static/7812.bundle.js +1 -1
- notebook/static/7819.bundle.js +1 -1
- notebook/static/7900.bundle.js +1 -1
- notebook/static/7906.bundle.js +1 -1
- notebook/static/7995.bundle.js +1 -1
- notebook/static/853.bundle.js +1 -0
- notebook/static/8579.bundle.js +1 -1
- notebook/static/8633.bundle.js +1 -1
- notebook/static/8771.bundle.js +1 -1
- notebook/static/8781.bundle.js +1 -1
- notebook/static/8875.bundle.js +1 -1
- notebook/static/8907.bundle.js +1 -1
- notebook/static/8928.bundle.js +1 -1
- notebook/static/8929.bundle.js +1 -1
- notebook/static/893.bundle.js +1 -1
- notebook/static/901.bundle.js +1 -1
- notebook/static/9068.bundle.js +1 -1
- notebook/static/911.bundle.js +1 -1
- notebook/static/9151.bundle.js +1 -1
- notebook/static/9161.bundle.js +1 -1
- notebook/static/9268.bundle.js +1 -1
- notebook/static/9335.bundle.js +1 -1
- notebook/static/9341.bundle.js +1 -1
- notebook/static/9380.bundle.js +1 -1
- notebook/static/9605.bundle.js +1 -1
- notebook/static/9638.bundle.js +1 -1
- notebook/static/9680.bundle.js +1 -1
- notebook/static/9685.bundle.js +1 -1
- notebook/static/9752.bundle.js +1 -1
- notebook/static/9821.bundle.js +1 -1
- notebook/static/9852.bundle.js +1 -1
- notebook/static/bundle.js +1 -1
- notebook/static/third-party-licenses.json +99 -99
- {notebook-7.1.1.data → notebook-7.1.3.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/application-extension/package.json.orig +14 -14
- {notebook-7.1.1.data → notebook-7.1.3.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/documentsearch-extension/package.json.orig +4 -4
- {notebook-7.1.1.data → notebook-7.1.3.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/help-extension/package.json.orig +6 -6
- {notebook-7.1.1.data → notebook-7.1.3.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/notebook-extension/package.json.orig +9 -9
- {notebook-7.1.1.data → notebook-7.1.3.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/tree-extension/package.json.orig +15 -15
- {notebook-7.1.1.data → notebook-7.1.3.data}/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/package.json +11 -11
- {notebook-7.1.1.data → notebook-7.1.3.data}/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/schemas/@jupyter-notebook/lab-extension/package.json.orig +10 -10
- notebook-7.1.3.data/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/419.e980232a56ae53a39be0.js +1 -0
- notebook-7.1.3.data/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/568.1a379d1d7dc566a197da.js +1 -0
- notebook-7.1.1.data/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/928.32f48ad22cd5f6a8da04.js → notebook-7.1.3.data/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/928.a1f037cc55c9ffb2e994.js +1 -1
- notebook-7.1.1.data/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/93.d3d4e56f2f961c2c2a13.js → notebook-7.1.3.data/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/93.eae3497dd223d842d198.js +1 -1
- notebook-7.1.1.data/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/remoteEntry.330dffb5180b5b71100a.js → notebook-7.1.3.data/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/remoteEntry.a1a4e0e795dca61023d3.js +1 -1
- {notebook-7.1.1.data → notebook-7.1.3.data}/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/third-party-licenses.json +2 -2
- {notebook-7.1.1.dist-info → notebook-7.1.3.dist-info}/METADATA +2 -2
- {notebook-7.1.1.dist-info → notebook-7.1.3.dist-info}/RECORD +167 -167
- {notebook-7.1.1.dist-info → notebook-7.1.3.dist-info}/WHEEL +1 -1
- notebook/static/4131.bundle.js +0 -1
- notebook/static/6853.bundle.js +0 -1
- notebook/static/771.bundle.js +0 -1
- notebook-7.1.1.data/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/355.1213f16419258c4671ec.js +0 -1
- notebook-7.1.1.data/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/568.c74a681c6a303d4da718.js +0 -1
- {notebook-7.1.1.data → notebook-7.1.3.data}/data/etc/jupyter/jupyter_server_config.d/notebook.json +0 -0
- {notebook-7.1.1.data → notebook-7.1.3.data}/data/share/applications/jupyter-notebook.desktop +0 -0
- {notebook-7.1.1.data → notebook-7.1.3.data}/data/share/icons/hicolor/scalable/apps/notebook.svg +0 -0
- {notebook-7.1.1.data → notebook-7.1.3.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/application-extension/menus.json +0 -0
- {notebook-7.1.1.data → notebook-7.1.3.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/application-extension/pages.json +0 -0
- {notebook-7.1.1.data → notebook-7.1.3.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/application-extension/shell.json +0 -0
- {notebook-7.1.1.data → notebook-7.1.3.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/application-extension/title.json +0 -0
- {notebook-7.1.1.data → notebook-7.1.3.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/application-extension/top.json +0 -0
- {notebook-7.1.1.data → notebook-7.1.3.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/application-extension/zen.json +0 -0
- {notebook-7.1.1.data → notebook-7.1.3.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/help-extension/open.json +0 -0
- {notebook-7.1.1.data → notebook-7.1.3.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/notebook-extension/checkpoints.json +0 -0
- {notebook-7.1.1.data → notebook-7.1.3.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/notebook-extension/edit-notebook-metadata.json +0 -0
- {notebook-7.1.1.data → notebook-7.1.3.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/notebook-extension/kernel-logo.json +0 -0
- {notebook-7.1.1.data → notebook-7.1.3.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/notebook-extension/scroll-output.json +0 -0
- {notebook-7.1.1.data → notebook-7.1.3.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/tree-extension/file-actions.json +0 -0
- {notebook-7.1.1.data → notebook-7.1.3.data}/data/share/jupyter/lab/schemas/@jupyter-notebook/tree-extension/widget.json +0 -0
- {notebook-7.1.1.data → notebook-7.1.3.data}/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/schemas/@jupyter-notebook/lab-extension/interface-switcher.json +0 -0
- {notebook-7.1.1.data → notebook-7.1.3.data}/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/schemas/@jupyter-notebook/lab-extension/launch-tree.json +0 -0
- {notebook-7.1.1.data → notebook-7.1.3.data}/data/share/jupyter/labextensions/@jupyter-notebook/lab-extension/static/style.js +0 -0
- {notebook-7.1.1.dist-info → notebook-7.1.3.dist-info}/entry_points.txt +0 -0
- {notebook-7.1.1.dist-info → notebook-7.1.3.dist-info}/licenses/LICENSE +0 -0
notebook/static/7226.bundle.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_JUPYTERLAB_CORE_OUTPUT=self.webpackChunk_JUPYTERLAB_CORE_OUTPUT||[]).push([[7226],{47226:(t,e,s)=>{s.r(e),s.d(e,{OutputArea:()=>x,OutputAreaModel:()=>d,OutputPrompt:()=>w,SimplifiedOutputArea:()=>v,Stdin:()=>O});var i,n=s(43593),r=s(50892),a=s(56761),o=s(33625),h=s(20998),u=s(81997);class d{constructor(t={}){if(this.clearNext=!1,this._lastStream="",this._trusted=!1,this._isDisposed=!1,this._stateChanged=new u.Signal(this),this._changed=new u.Signal(this),this._trusted=!!t.trusted,this.contentFactory=t.contentFactory||d.defaultContentFactory,this.list=new r.ObservableList,t.values)for(const e of t.values){const t=this._add(e)-1;this.list.get(t).changed.connect(this._onGenericChange,this)}this.list.changed.connect(this._onListChanged,this)}get stateChanged(){return this._stateChanged}get changed(){return this._changed}get length(){return this.list?this.list.length:0}get trusted(){return this._trusted}set trusted(t){if(t===this._trusted)return;const e=this._trusted=t;for(let t=0;t<this.list.length;t++){const s=this.list.get(t),i=s.toJSON(),n=this._createItem({value:i,trusted:e});this.list.set(t,n),s.dispose()}}get isDisposed(){return this._isDisposed}dispose(){this.isDisposed||(this._isDisposed=!0,this.list.dispose(),u.Signal.clearData(this))}get(t){return this.list.get(t)}set(t,e){e=h.JSONExt.deepCopy(e),i.normalize(e);const s=this._createItem({value:e,trusted:this._trusted});this.list.set(t,s)}add(t){return this.clearNext&&(this.clear(),this.clearNext=!1),this._add(t)}clear(t=!1){if(this._lastStream="",t)this.clearNext=!0;else{for(const t of this.list)t.dispose();this.list.clear()}}fromJSON(t){this.clear();for(const e of t)this._add(e)}toJSON(){return Array.from((0,o.map)(this.list,(t=>t.toJSON())))}_add(t){const e=this._trusted;if(t=h.JSONExt.deepCopy(t),i.normalize(t),n.isStream(t)&&this._lastStream&&t.name===this._lastName&&this.shouldCombine({value:t,lastModel:this.list.get(this.length-1)})){this._lastStream+=t.text,this._lastStream=i.removeOverwrittenChars(this._lastStream),t.text=this._lastStream;const s=this._createItem({value:t,trusted:e}),n=this.length-1,r=this.list.get(n);return this.list.set(n,s),r.dispose(),this.length}n.isStream(t)&&(t.text=i.removeOverwrittenChars(t.text));const s=this._createItem({value:t,trusted:e});return n.isStream(t)?(this._lastStream=t.text,this._lastName=t.name):this._lastStream="",this.list.push(s)}shouldCombine(t){return!0}_createItem(t){return this.contentFactory.createOutputModel(t)}_onListChanged(t,e){switch(e.type){case"add":e.newValues.forEach((t=>{t.changed.connect(this._onGenericChange,this)}));break;case"remove":e.oldValues.forEach((t=>{t.changed.disconnect(this._onGenericChange,this)}));break;case"set":e.newValues.forEach((t=>{t.changed.connect(this._onGenericChange,this)})),e.oldValues.forEach((t=>{t.changed.disconnect(this._onGenericChange,this)}))}this._changed.emit(e)}_onGenericChange(t){let e,s=null;for(e=0;e<this.list.length&&(s=this.list.get(e),s!==t);e++);null!=s&&(this._stateChanged.emit(e),this._changed.emit({type:"set",newIndex:e,oldIndex:e,oldValues:[s],newValues:[s]}))}}!function(t){class e{createOutputModel(t){return new a.OutputModel(t)}}t.ContentFactory=e,t.defaultContentFactory=new e}(d||(d={})),function(t){t.normalize=function(t){n.isStream(t)&&Array.isArray(t.text)&&(t.text=t.text.join("\n"))},t.removeOverwrittenChars=function(t){return function(t){for(t=t.replace(/\r+\n/gm,"\n");t.search(/\r[^$]/g)>-1;){const e=t.match(/^(.*)\r+/m)[1];let s=t.match(/\r+(.*)$/m)[1];s+=e.slice(s.length,e.length),t=t.replace(/\r+.*$/m,"\r").replace(/^.*\r/m,s)}return t}(function(t){let e=t;do{e=(t=e).replace(/[^\n]\x08/gm,"")}while(e.length<t.length);return t}(t))}}(i||(i={}));var l=s(57797),c=s(5390),p=s(11523),m=s(14421),_=s(31516);const g="jp-OutputArea-child",y="jp-OutputArea-output",f="jp-OutputArea-prompt";class x extends _.Widget{constructor(t){var e,s,i,n;super(),this.outputLengthChanged=new u.Signal(this),this._onIOPub=t=>{const e=this.model,s=t.header.msg_type;let i;const n=(t.content.transient||{}).display_id;let r;switch(s){case"execute_result":case"display_data":case"stream":case"error":i={...t.content,output_type:s},e.add(i);break;case"clear_output":{const s=t.content.wait;e.clear(s);break}case"update_display_data":if(i={...t.content,output_type:"display_data"},r=this._displayIdMap.get(n),r)for(const t of r)e.set(t,i)}n&&"display_data"===s&&(r=this._displayIdMap.get(n)||[],r.push(e.length-1),this._displayIdMap.set(n,r))},this._onExecuteReply=t=>{const e=this.model,s=t.content;if("ok"!==s.status)return;const i=s&&s.payload;if(!i||!i.length)return;const n=i.filter((t=>"page"===t.source));if(!n.length)return;const r={output_type:"display_data",data:JSON.parse(JSON.stringify(n[0])).data,metadata:{}};e.add(r)},this._displayIdMap=new Map,this._minHeightTimeout=null,this._inputRequested=new u.Signal(this),this._toggleScrolling=new u.Signal(this),this._initialize=new u.Signal(this),this._outputTracker=new l.WidgetTracker({namespace:h.UUID.uuid4()}),this._inputHistoryScope="global",super.layout=new _.PanelLayout,this.addClass("jp-OutputArea"),this.contentFactory=null!==(e=t.contentFactory)&&void 0!==e?e:x.defaultContentFactory,this.rendermime=t.rendermime,this._maxNumberOutputs=null!==(s=t.maxNumberOutputs)&&void 0!==s?s:1/0,this._translator=null!==(i=t.translator)&&void 0!==i?i:p.nullTranslator,this._inputHistoryScope=null!==(n=t.inputHistoryScope)&&void 0!==n?n:"global";const r=this.model=t.model;for(let t=0;t<Math.min(r.length,this._maxNumberOutputs+1);t++){const e=r.get(t);this._insertOutput(t,e)}r.changed.connect(this.onModelChanged,this),r.stateChanged.connect(this.onStateChanged,this),t.promptOverlay&&this._addPromptOverlay()}get layout(){return super.layout}get widgets(){return this.layout.widgets}get future(){return this._future}set future(t){if(this.model.isDisposed)throw Error("Model is disposed");this._future!==t&&(this._future&&this._future.dispose(),this._future=t,this.model.clear(),this.widgets.length&&(this._clear(),this.outputLengthChanged.emit(Math.min(this.model.length,this._maxNumberOutputs))),t.onIOPub=this._onIOPub,t.onReply=this._onExecuteReply,t.onStdin=e=>{c.KernelMessage.isInputRequestMsg(e)&&this.onInputRequest(e,t)})}get inputRequested(){return this._inputRequested}get maxNumberOutputs(){return this._maxNumberOutputs}set maxNumberOutputs(t){if(t<=0)return void console.warn("OutputArea.maxNumberOutputs must be strictly positive.");const e=this._maxNumberOutputs;this._maxNumberOutputs=t,e<t&&this._showTrimmedOutputs(e)}dispose(){this._future&&(this._future.dispose(),this._future=null),this._displayIdMap.clear(),this._outputTracker.dispose(),super.dispose()}onModelChanged(t,e){switch(e.type){case"add":this._insertOutput(e.newIndex,e.newValues[0]);break;case"remove":if(this.widgets.length)if(0===this.model.length)this._clear();else{const t=e.oldIndex;for(let s=0;s<e.oldValues.length&&t<this.widgets.length;++s){const e=this.widgets[t];e.parent=null,e.dispose()}this._moveDisplayIdIndices(t,e.oldValues.length),this._preventHeightChangeJitter()}break;case"set":this._setOutput(e.newIndex,e.newValues[0])}this.outputLengthChanged.emit(Math.min(this.model.length,this._maxNumberOutputs))}get toggleScrolling(){return this._toggleScrolling}get initialize(){return this._initialize}_addPromptOverlay(){const t=document.createElement("div");t.className="jp-OutputArea-promptOverlay",t.addEventListener("click",(()=>{this._toggleScrolling.emit()})),this.node.appendChild(t),requestAnimationFrame((()=>{this._initialize.emit()}))}_moveDisplayIdIndices(t,e){this._displayIdMap.forEach((s=>{const i=t+e;for(let n=s.length-1;n>=0;--n){const r=s[n];r>=t&&r<i?s.splice(n,1):r>=i&&(s[n]-=e)}}))}onStateChanged(t,e){const s=Math.min(this.model.length,this._maxNumberOutputs);if(e){if(e>=this._maxNumberOutputs)return;this._setOutput(e,this.model.get(e))}else for(let t=0;t<s;t++)this._setOutput(t,this.model.get(t));this.outputLengthChanged.emit(s)}_clear(){if(!this.widgets.length)return;const t=this.widgets.length;for(let e=0;e<t;e++){const t=this.widgets[0];t.parent=null,t.dispose()}this._displayIdMap.clear(),this._preventHeightChangeJitter()}_preventHeightChangeJitter(){const t=this.node.getBoundingClientRect();this.node.style.minHeight=`${t.height}px`,this._minHeightTimeout&&window.clearTimeout(this._minHeightTimeout),this._minHeightTimeout=window.setTimeout((()=>{this.isDisposed||(this.node.style.minHeight="")}),50)}onInputRequest(t,e){const s=this.contentFactory,i=t.content.prompt,n=t.content.password,r=new _.Panel;r.addClass(g),r.addClass("jp-OutputArea-stdin-item");const a=s.createOutputPrompt();a.addClass(f),r.addWidget(a);const o=s.createStdin({parent_header:t.header,prompt:i,password:n,future:e,translator:this._translator,inputHistoryScope:this._inputHistoryScope});o.addClass(y),r.addWidget(o),this.model.length>=this.maxNumberOutputs&&(this.maxNumberOutputs=this.model.length),this._inputRequested.emit(o);const h=o.node.getElementsByTagName("input")[0];o.value.then((t=>{this.model.length>=this.maxNumberOutputs&&(this.maxNumberOutputs=this.model.length+1),r.addClass("jp-OutputArea-stdin-hiding"),this.model.add({output_type:"stream",name:"stdin",text:t+"\n"}),h.focus(),window.setTimeout((()=>{const t=document.activeElement;r.dispose(),t&&t instanceof HTMLElement&&t.focus()}),500)})),this.layout.addWidget(r)}_setOutput(t,e){if(t>=this._maxNumberOutputs)return;const s=this.layout.widgets[t],i=s.widgets?s.widgets.filter((t=>"renderModel"in t)).pop():s,n=this.rendermime.preferredMimeType(e.data,e.trusted?"any":"ensure");C.currentPreferredMimetype.get(i)===n&&x.isIsolated(n,e.metadata)===i instanceof C.IsolatedRenderer?i.renderModel(e):(this.layout.widgets[t].dispose(),this._insertOutput(t,e))}_insertOutput(t,e){if(t>this._maxNumberOutputs)return;const s=this.layout;if(t===this._maxNumberOutputs){const e=new C.TrimmedOutputs(this._maxNumberOutputs,(()=>{const t=this._maxNumberOutputs;this._maxNumberOutputs=1/0,this._showTrimmedOutputs(t)}));s.insertWidget(t,this._wrappedOutput(e))}else{let i=this.createOutputItem(e);i?i.toggleClass("jp-OutputArea-executeResult",null!==e.executionCount):i=new _.Widget,this._outputTracker.has(i)||this._outputTracker.add(i),s.insertWidget(t,i)}}get outputTracker(){return this._outputTracker}_showTrimmedOutputs(t){this.widgets[t].dispose();for(let e=t;e<this.model.length;e++)this._insertOutput(e,this.model.get(e));this.outputLengthChanged.emit(Math.min(this.model.length,this._maxNumberOutputs))}createOutputItem(t){const e=this.createRenderedMimetype(t);return e?this._wrappedOutput(e,t.executionCount):null}createRenderedMimetype(t){const e=this.rendermime.preferredMimeType(t.data,t.trusted?"any":"ensure");if(!e)return null;let s=this.rendermime.createRenderer(e);return!0===x.isIsolated(e,t.metadata)&&(s=new C.IsolatedRenderer(s)),C.currentPreferredMimetype.set(s,e),s.renderModel(t).catch((t=>{const e=document.createElement("pre"),i=this._translator.load("jupyterlab");e.textContent=i.__("Javascript Error: %1",t.message),s.node.appendChild(e),s.node.className="lm-Widget jp-RenderedText",s.node.setAttribute("data-mime-type","application/vnd.jupyter.stderr")})),s}_wrappedOutput(t,e=null){const s=new C.OutputPanel;s.addClass(g);const i=this.contentFactory.createOutputPrompt();return i.executionCount=e,i.addClass(f),s.addWidget(i),t.addClass(y),s.addWidget(t),s}}class v extends x{onInputRequest(t,e){}createOutputItem(t){const e=this.createRenderedMimetype(t);if(!e)return null;const s=new C.OutputPanel;return s.addClass(g),e.addClass(y),s.addWidget(e),s}}!function(t){t.execute=async function(t,e,s,i){var n;let r=!0;i&&Array.isArray(i.tags)&&-1!==i.tags.indexOf("raises-exception")&&(r=!1);const a={code:t,stop_on_error:r},o=null===(n=s.session)||void 0===n?void 0:n.kernel;if(!o)throw new Error("Session has no kernel.");const h=o.requestExecute(a,!1,i);return e.future=h,h.done},t.isIsolated=function(t,e){const s=e[t];return s&&void 0!==s.isolated?!!s.isolated:!!e.isolated};class e{createOutputPrompt(){return new w}createStdin(t){return new O(t)}}t.ContentFactory=e,t.defaultContentFactory=new e}(x||(x={}));class w extends _.Widget{constructor(){super(),this._executionCount=null,this.addClass("jp-OutputPrompt")}get executionCount(){return this._executionCount}set executionCount(t){this._executionCount=t,this.node.textContent=null===t?"":`[${t}]:`}}class O extends _.Widget{static _historyIx(t,e){const s=O._history.get(t);if(!s)return;const i=s.length;return e<=0?i+e:void 0}static _historyAt(t,e){const s=O._history.get(t);if(!s)return;const i=s.length,n=O._historyIx(t,e);return void 0!==n&&n<i?s[n]:void 0}static _historyPush(t,e){const s=O._history.get(t);s.push(e),s.length>1e3&&s.shift()}static _historySearch(t,e,s,i=!0){const n=O._history.get(t),r=n.length,a=O._historyIx(t,s),o=t=>-1!==t.search(e);if(void 0!==a)if(i){if(0===a)return;const t=n.slice(0,a).findLastIndex(o);if(-1!==t)return t-r}else{if(a>=r-1)return;const t=n.slice(a+1).findIndex(o);if(-1!==t)return t-r+a+1}}constructor(t){var e;super({node:C.createInputWidgetNode(t.prompt,t.password)}),this._promise=new h.PromiseDelegate,this._resolved=!1,this.addClass("jp-Stdin"),this._future=t.future,this._historyIndex=0,this._historyKey="session"===t.inputHistoryScope?t.parent_header.session:"",this._historyPat="",this._parentHeader=t.parent_header,this._password=t.password,this._trans=(null!==(e=t.translator)&&void 0!==e?e:p.nullTranslator).load("jupyterlab"),this._value=t.prompt+" ",this._input=this.node.getElementsByTagName("input")[0],this._input.placeholder=this._trans.__("↑↓ for history. Search history with c-↑/c-↓"),O._history.has(this._historyKey)||O._history.set(this._historyKey,[])}get value(){return this._promise.promise.then((()=>this._value))}handleEvent(t){if(this._resolved)return void t.preventDefault();const e=this._input;if("keydown"===t.type)if("Enter"===t.key)this.resetSearch(),this._future.sendInputReply({status:"ok",value:e.value},this._parentHeader),this._password?this._value+="········":(this._value+=e.value,O._historyPush(this._historyKey,e.value)),this._resolved=!0,this._promise.resolve(void 0);else if("Escape"===t.key)this.resetSearch(),e.blur();else if(!t.ctrlKey||"ArrowUp"!==t.key&&"ArrowDown"!==t.key){if("ArrowUp"===t.key){this.resetSearch();const s=O._historyAt(this._historyKey,this._historyIndex-1);s&&(0===this._historyIndex&&(this._valueCache=e.value),this._setInputValue(s),--this._historyIndex,t.preventDefault())}else if("ArrowDown"===t.key)if(this.resetSearch(),0===this._historyIndex);else if(-1===this._historyIndex)this._setInputValue(this._valueCache),++this._historyIndex;else{const t=O._historyAt(this._historyKey,this._historyIndex+1);t&&(this._setInputValue(t),++this._historyIndex)}}else{""===this._historyPat&&(this._historyPat=e.value);const s="ArrowUp"===t.key,i=O._historySearch(this._historyKey,this._historyPat,this._historyIndex,s);if(void 0!==i){const s=O._historyAt(this._historyKey,i);void 0!==s&&(0===this._historyIndex&&(this._valueCache=e.value),this._setInputValue(s),this._historyIndex=i,t.preventDefault())}}}resetSearch(){this._historyPat=""}onAfterAttach(t){this._input.addEventListener("keydown",this),this._input.focus()}onBeforeDetach(t){this._input.removeEventListener("keydown",this)}_setInputValue(t){this._input.value=t,this._input.setSelectionRange(t.length,t.length)}}var C;O._history=new Map,function(t){t.createInputWidgetNode=function(t,e){const s=document.createElement("div"),i=document.createElement("pre");i.className="jp-Stdin-prompt",i.textContent=t;const n=document.createElement("input");return n.className="jp-Stdin-input",e&&(n.type="password"),s.appendChild(i),i.appendChild(n),s};class e extends _.Widget{constructor(t){super({node:document.createElement("iframe")}),this.addClass("jp-mod-isolated"),this._wrapped=t;const e=this.node;e.frameBorder="0",e.scrolling="auto",e.addEventListener("load",(()=>{e.contentDocument.open(),e.contentDocument.write(this._wrapped.node.innerHTML),e.contentDocument.close();const t=e.contentDocument.body;e.style.height=`${t.scrollHeight}px`,e.heightChangeObserver=new ResizeObserver((()=>{e.style.height=`${t.scrollHeight}px`})),e.heightChangeObserver.observe(t)}))}renderModel(t){return this._wrapped.renderModel(t)}}t.IsolatedRenderer=e,t.currentPreferredMimetype=new m.AttachedProperty({name:"preferredMimetype",create:t=>""});class s extends _.Panel{constructor(t){super(t)}_onContext(t){this.node.focus()}onAfterAttach(t){super.onAfterAttach(t),this.node.addEventListener("contextmenu",this._onContext.bind(this))}onBeforeDetach(t){super.onAfterDetach(t),this.node.removeEventListener("contextmenu",this._onContext.bind(this))}}t.OutputPanel=s;class i extends _.Widget{constructor(t,e){const s=document.createElement("div"),i=`The first ${t} are displayed`;s.insertAdjacentHTML("afterbegin",`<a title=${i}>\n <pre>Show more outputs</pre>\n </a>`),super({node:s}),this._onClick=e,this.addClass("jp-TrimmedOutputs"),this.addClass("jp-RenderedHTMLCommon")}handleEvent(t){"click"===t.type&&this._onClick(t)}onAfterAttach(t){super.onAfterAttach(t),this.node.addEventListener("click",this)}onBeforeDetach(t){super.onBeforeDetach(t),this.node.removeEventListener("click",this)}}t.TrimmedOutputs=i}(C||(C={}))}}]);
|
|
1
|
+
"use strict";(self.webpackChunk_JUPYTERLAB_CORE_OUTPUT=self.webpackChunk_JUPYTERLAB_CORE_OUTPUT||[]).push([[7226],{47226:(t,e,s)=>{s.r(e),s.d(e,{OutputArea:()=>x,OutputAreaModel:()=>d,OutputPrompt:()=>w,SimplifiedOutputArea:()=>v,Stdin:()=>O});var i,n=s(85923),r=s(11351),a=s(70856),o=s(33625),h=s(20998),u=s(81997);class d{constructor(t={}){if(this.clearNext=!1,this._lastStream="",this._trusted=!1,this._isDisposed=!1,this._stateChanged=new u.Signal(this),this._changed=new u.Signal(this),this._trusted=!!t.trusted,this.contentFactory=t.contentFactory||d.defaultContentFactory,this.list=new r.ObservableList,t.values)for(const e of t.values){const t=this._add(e)-1;this.list.get(t).changed.connect(this._onGenericChange,this)}this.list.changed.connect(this._onListChanged,this)}get stateChanged(){return this._stateChanged}get changed(){return this._changed}get length(){return this.list?this.list.length:0}get trusted(){return this._trusted}set trusted(t){if(t===this._trusted)return;const e=this._trusted=t;for(let t=0;t<this.list.length;t++){const s=this.list.get(t),i=s.toJSON(),n=this._createItem({value:i,trusted:e});this.list.set(t,n),s.dispose()}}get isDisposed(){return this._isDisposed}dispose(){this.isDisposed||(this._isDisposed=!0,this.list.dispose(),u.Signal.clearData(this))}get(t){return this.list.get(t)}set(t,e){e=h.JSONExt.deepCopy(e),i.normalize(e);const s=this._createItem({value:e,trusted:this._trusted});this.list.set(t,s)}add(t){return this.clearNext&&(this.clear(),this.clearNext=!1),this._add(t)}clear(t=!1){if(this._lastStream="",t)this.clearNext=!0;else{for(const t of this.list)t.dispose();this.list.clear()}}fromJSON(t){this.clear();for(const e of t)this._add(e)}toJSON(){return Array.from((0,o.map)(this.list,(t=>t.toJSON())))}_add(t){const e=this._trusted;if(t=h.JSONExt.deepCopy(t),i.normalize(t),n.isStream(t)&&this._lastStream&&t.name===this._lastName&&this.shouldCombine({value:t,lastModel:this.list.get(this.length-1)})){this._lastStream+=t.text,this._lastStream=i.removeOverwrittenChars(this._lastStream),t.text=this._lastStream;const s=this._createItem({value:t,trusted:e}),n=this.length-1,r=this.list.get(n);return this.list.set(n,s),r.dispose(),this.length}n.isStream(t)&&(t.text=i.removeOverwrittenChars(t.text));const s=this._createItem({value:t,trusted:e});return n.isStream(t)?(this._lastStream=t.text,this._lastName=t.name):this._lastStream="",this.list.push(s)}shouldCombine(t){return!0}_createItem(t){return this.contentFactory.createOutputModel(t)}_onListChanged(t,e){switch(e.type){case"add":e.newValues.forEach((t=>{t.changed.connect(this._onGenericChange,this)}));break;case"remove":e.oldValues.forEach((t=>{t.changed.disconnect(this._onGenericChange,this)}));break;case"set":e.newValues.forEach((t=>{t.changed.connect(this._onGenericChange,this)})),e.oldValues.forEach((t=>{t.changed.disconnect(this._onGenericChange,this)}))}this._changed.emit(e)}_onGenericChange(t){let e,s=null;for(e=0;e<this.list.length&&(s=this.list.get(e),s!==t);e++);null!=s&&(this._stateChanged.emit(e),this._changed.emit({type:"set",newIndex:e,oldIndex:e,oldValues:[s],newValues:[s]}))}}!function(t){class e{createOutputModel(t){return new a.OutputModel(t)}}t.ContentFactory=e,t.defaultContentFactory=new e}(d||(d={})),function(t){t.normalize=function(t){n.isStream(t)&&Array.isArray(t.text)&&(t.text=t.text.join("\n"))},t.removeOverwrittenChars=function(t){return function(t){for(t=t.replace(/\r+\n/gm,"\n");t.search(/\r[^$]/g)>-1;){const e=t.match(/^(.*)\r+/m)[1];let s=t.match(/\r+(.*)$/m)[1];s+=e.slice(s.length,e.length),t=t.replace(/\r+.*$/m,"\r").replace(/^.*\r/m,s)}return t}(function(t){let e=t;do{e=(t=e).replace(/[^\n]\x08/gm,"")}while(e.length<t.length);return t}(t))}}(i||(i={}));var l=s(12982),c=s(16954),p=s(71677),m=s(14421),_=s(31516);const g="jp-OutputArea-child",y="jp-OutputArea-output",f="jp-OutputArea-prompt";class x extends _.Widget{constructor(t){var e,s,i,n;super(),this.outputLengthChanged=new u.Signal(this),this._onIOPub=t=>{const e=this.model,s=t.header.msg_type;let i;const n=(t.content.transient||{}).display_id;let r;switch(s){case"execute_result":case"display_data":case"stream":case"error":i={...t.content,output_type:s},e.add(i);break;case"clear_output":{const s=t.content.wait;e.clear(s);break}case"update_display_data":if(i={...t.content,output_type:"display_data"},r=this._displayIdMap.get(n),r)for(const t of r)e.set(t,i)}n&&"display_data"===s&&(r=this._displayIdMap.get(n)||[],r.push(e.length-1),this._displayIdMap.set(n,r))},this._onExecuteReply=t=>{const e=this.model,s=t.content;if("ok"!==s.status)return;const i=s&&s.payload;if(!i||!i.length)return;const n=i.filter((t=>"page"===t.source));if(!n.length)return;const r={output_type:"display_data",data:JSON.parse(JSON.stringify(n[0])).data,metadata:{}};e.add(r)},this._displayIdMap=new Map,this._minHeightTimeout=null,this._inputRequested=new u.Signal(this),this._toggleScrolling=new u.Signal(this),this._initialize=new u.Signal(this),this._outputTracker=new l.WidgetTracker({namespace:h.UUID.uuid4()}),this._inputHistoryScope="global",super.layout=new _.PanelLayout,this.addClass("jp-OutputArea"),this.contentFactory=null!==(e=t.contentFactory)&&void 0!==e?e:x.defaultContentFactory,this.rendermime=t.rendermime,this._maxNumberOutputs=null!==(s=t.maxNumberOutputs)&&void 0!==s?s:1/0,this._translator=null!==(i=t.translator)&&void 0!==i?i:p.nullTranslator,this._inputHistoryScope=null!==(n=t.inputHistoryScope)&&void 0!==n?n:"global";const r=this.model=t.model;for(let t=0;t<Math.min(r.length,this._maxNumberOutputs+1);t++){const e=r.get(t);this._insertOutput(t,e)}r.changed.connect(this.onModelChanged,this),r.stateChanged.connect(this.onStateChanged,this),t.promptOverlay&&this._addPromptOverlay()}get layout(){return super.layout}get widgets(){return this.layout.widgets}get future(){return this._future}set future(t){if(this.model.isDisposed)throw Error("Model is disposed");this._future!==t&&(this._future&&this._future.dispose(),this._future=t,this.model.clear(),this.widgets.length&&(this._clear(),this.outputLengthChanged.emit(Math.min(this.model.length,this._maxNumberOutputs))),t.onIOPub=this._onIOPub,t.onReply=this._onExecuteReply,t.onStdin=e=>{c.KernelMessage.isInputRequestMsg(e)&&this.onInputRequest(e,t)})}get inputRequested(){return this._inputRequested}get maxNumberOutputs(){return this._maxNumberOutputs}set maxNumberOutputs(t){if(t<=0)return void console.warn("OutputArea.maxNumberOutputs must be strictly positive.");const e=this._maxNumberOutputs;this._maxNumberOutputs=t,e<t&&this._showTrimmedOutputs(e)}dispose(){this._future&&(this._future.dispose(),this._future=null),this._displayIdMap.clear(),this._outputTracker.dispose(),super.dispose()}onModelChanged(t,e){switch(e.type){case"add":this._insertOutput(e.newIndex,e.newValues[0]);break;case"remove":if(this.widgets.length)if(0===this.model.length)this._clear();else{const t=e.oldIndex;for(let s=0;s<e.oldValues.length&&t<this.widgets.length;++s){const e=this.widgets[t];e.parent=null,e.dispose()}this._moveDisplayIdIndices(t,e.oldValues.length),this._preventHeightChangeJitter()}break;case"set":this._setOutput(e.newIndex,e.newValues[0])}this.outputLengthChanged.emit(Math.min(this.model.length,this._maxNumberOutputs))}get toggleScrolling(){return this._toggleScrolling}get initialize(){return this._initialize}_addPromptOverlay(){const t=document.createElement("div");t.className="jp-OutputArea-promptOverlay",t.addEventListener("click",(()=>{this._toggleScrolling.emit()})),this.node.appendChild(t),requestAnimationFrame((()=>{this._initialize.emit()}))}_moveDisplayIdIndices(t,e){this._displayIdMap.forEach((s=>{const i=t+e;for(let n=s.length-1;n>=0;--n){const r=s[n];r>=t&&r<i?s.splice(n,1):r>=i&&(s[n]-=e)}}))}onStateChanged(t,e){const s=Math.min(this.model.length,this._maxNumberOutputs);if(e){if(e>=this._maxNumberOutputs)return;this._setOutput(e,this.model.get(e))}else for(let t=0;t<s;t++)this._setOutput(t,this.model.get(t));this.outputLengthChanged.emit(s)}_clear(){if(!this.widgets.length)return;const t=this.widgets.length;for(let e=0;e<t;e++){const t=this.widgets[0];t.parent=null,t.dispose()}this._displayIdMap.clear(),this._preventHeightChangeJitter()}_preventHeightChangeJitter(){const t=this.node.getBoundingClientRect();this.node.style.minHeight=`${t.height}px`,this._minHeightTimeout&&window.clearTimeout(this._minHeightTimeout),this._minHeightTimeout=window.setTimeout((()=>{this.isDisposed||(this.node.style.minHeight="")}),50)}onInputRequest(t,e){const s=this.contentFactory,i=t.content.prompt,n=t.content.password,r=new _.Panel;r.addClass(g),r.addClass("jp-OutputArea-stdin-item");const a=s.createOutputPrompt();a.addClass(f),r.addWidget(a);const o=s.createStdin({parent_header:t.header,prompt:i,password:n,future:e,translator:this._translator,inputHistoryScope:this._inputHistoryScope});o.addClass(y),r.addWidget(o),this.model.length>=this.maxNumberOutputs&&(this.maxNumberOutputs=this.model.length),this._inputRequested.emit(o);const h=o.node.getElementsByTagName("input")[0];o.value.then((t=>{this.model.length>=this.maxNumberOutputs&&(this.maxNumberOutputs=this.model.length+1),r.addClass("jp-OutputArea-stdin-hiding"),this.model.add({output_type:"stream",name:"stdin",text:t+"\n"}),h.focus(),window.setTimeout((()=>{const t=document.activeElement;r.dispose(),t&&t instanceof HTMLElement&&t.focus()}),500)})),this.layout.addWidget(r)}_setOutput(t,e){if(t>=this._maxNumberOutputs)return;const s=this.layout.widgets[t],i=s.widgets?s.widgets.filter((t=>"renderModel"in t)).pop():s,n=this.rendermime.preferredMimeType(e.data,e.trusted?"any":"ensure");C.currentPreferredMimetype.get(i)===n&&x.isIsolated(n,e.metadata)===i instanceof C.IsolatedRenderer?i.renderModel(e):(this.layout.widgets[t].dispose(),this._insertOutput(t,e))}_insertOutput(t,e){if(t>this._maxNumberOutputs)return;const s=this.layout;if(t===this._maxNumberOutputs){const e=new C.TrimmedOutputs(this._maxNumberOutputs,(()=>{const t=this._maxNumberOutputs;this._maxNumberOutputs=1/0,this._showTrimmedOutputs(t)}));s.insertWidget(t,this._wrappedOutput(e))}else{let i=this.createOutputItem(e);i?i.toggleClass("jp-OutputArea-executeResult",null!==e.executionCount):i=new _.Widget,this._outputTracker.has(i)||this._outputTracker.add(i),s.insertWidget(t,i)}}get outputTracker(){return this._outputTracker}_showTrimmedOutputs(t){this.widgets[t].dispose();for(let e=t;e<this.model.length;e++)this._insertOutput(e,this.model.get(e));this.outputLengthChanged.emit(Math.min(this.model.length,this._maxNumberOutputs))}createOutputItem(t){const e=this.createRenderedMimetype(t);return e?this._wrappedOutput(e,t.executionCount):null}createRenderedMimetype(t){const e=this.rendermime.preferredMimeType(t.data,t.trusted?"any":"ensure");if(!e)return null;let s=this.rendermime.createRenderer(e);return!0===x.isIsolated(e,t.metadata)&&(s=new C.IsolatedRenderer(s)),C.currentPreferredMimetype.set(s,e),s.renderModel(t).catch((t=>{const e=document.createElement("pre"),i=this._translator.load("jupyterlab");e.textContent=i.__("Javascript Error: %1",t.message),s.node.appendChild(e),s.node.className="lm-Widget jp-RenderedText",s.node.setAttribute("data-mime-type","application/vnd.jupyter.stderr")})),s}_wrappedOutput(t,e=null){const s=new C.OutputPanel;s.addClass(g);const i=this.contentFactory.createOutputPrompt();return i.executionCount=e,i.addClass(f),s.addWidget(i),t.addClass(y),s.addWidget(t),s}}class v extends x{onInputRequest(t,e){}createOutputItem(t){const e=this.createRenderedMimetype(t);if(!e)return null;const s=new C.OutputPanel;return s.addClass(g),e.addClass(y),s.addWidget(e),s}}!function(t){t.execute=async function(t,e,s,i){var n;let r=!0;i&&Array.isArray(i.tags)&&-1!==i.tags.indexOf("raises-exception")&&(r=!1);const a={code:t,stop_on_error:r},o=null===(n=s.session)||void 0===n?void 0:n.kernel;if(!o)throw new Error("Session has no kernel.");const h=o.requestExecute(a,!1,i);return e.future=h,h.done},t.isIsolated=function(t,e){const s=e[t];return s&&void 0!==s.isolated?!!s.isolated:!!e.isolated};class e{createOutputPrompt(){return new w}createStdin(t){return new O(t)}}t.ContentFactory=e,t.defaultContentFactory=new e}(x||(x={}));class w extends _.Widget{constructor(){super(),this._executionCount=null,this.addClass("jp-OutputPrompt")}get executionCount(){return this._executionCount}set executionCount(t){this._executionCount=t,this.node.textContent=null===t?"":`[${t}]:`}}class O extends _.Widget{static _historyIx(t,e){const s=O._history.get(t);if(!s)return;const i=s.length;return e<=0?i+e:void 0}static _historyAt(t,e){const s=O._history.get(t);if(!s)return;const i=s.length,n=O._historyIx(t,e);return void 0!==n&&n<i?s[n]:void 0}static _historyPush(t,e){const s=O._history.get(t);s.push(e),s.length>1e3&&s.shift()}static _historySearch(t,e,s,i=!0){const n=O._history.get(t),r=n.length,a=O._historyIx(t,s),o=t=>-1!==t.search(e);if(void 0!==a)if(i){if(0===a)return;const t=n.slice(0,a).findLastIndex(o);if(-1!==t)return t-r}else{if(a>=r-1)return;const t=n.slice(a+1).findIndex(o);if(-1!==t)return t-r+a+1}}constructor(t){var e;super({node:C.createInputWidgetNode(t.prompt,t.password)}),this._promise=new h.PromiseDelegate,this._resolved=!1,this.addClass("jp-Stdin"),this._future=t.future,this._historyIndex=0,this._historyKey="session"===t.inputHistoryScope?t.parent_header.session:"",this._historyPat="",this._parentHeader=t.parent_header,this._password=t.password,this._trans=(null!==(e=t.translator)&&void 0!==e?e:p.nullTranslator).load("jupyterlab"),this._value=t.prompt+" ",this._input=this.node.getElementsByTagName("input")[0],this._input.placeholder=this._trans.__("↑↓ for history. Search history with c-↑/c-↓"),O._history.has(this._historyKey)||O._history.set(this._historyKey,[])}get value(){return this._promise.promise.then((()=>this._value))}handleEvent(t){if(this._resolved)return void t.preventDefault();const e=this._input;if("keydown"===t.type)if("Enter"===t.key)this.resetSearch(),this._future.sendInputReply({status:"ok",value:e.value},this._parentHeader),this._password?this._value+="········":(this._value+=e.value,O._historyPush(this._historyKey,e.value)),this._resolved=!0,this._promise.resolve(void 0);else if("Escape"===t.key)this.resetSearch(),e.blur();else if(!t.ctrlKey||"ArrowUp"!==t.key&&"ArrowDown"!==t.key){if("ArrowUp"===t.key){this.resetSearch();const s=O._historyAt(this._historyKey,this._historyIndex-1);s&&(0===this._historyIndex&&(this._valueCache=e.value),this._setInputValue(s),--this._historyIndex,t.preventDefault())}else if("ArrowDown"===t.key)if(this.resetSearch(),0===this._historyIndex);else if(-1===this._historyIndex)this._setInputValue(this._valueCache),++this._historyIndex;else{const t=O._historyAt(this._historyKey,this._historyIndex+1);t&&(this._setInputValue(t),++this._historyIndex)}}else{""===this._historyPat&&(this._historyPat=e.value);const s="ArrowUp"===t.key,i=O._historySearch(this._historyKey,this._historyPat,this._historyIndex,s);if(void 0!==i){const s=O._historyAt(this._historyKey,i);void 0!==s&&(0===this._historyIndex&&(this._valueCache=e.value),this._setInputValue(s),this._historyIndex=i,t.preventDefault())}}}resetSearch(){this._historyPat=""}onAfterAttach(t){this._input.addEventListener("keydown",this),this._input.focus()}onBeforeDetach(t){this._input.removeEventListener("keydown",this)}_setInputValue(t){this._input.value=t,this._input.setSelectionRange(t.length,t.length)}}var C;O._history=new Map,function(t){t.createInputWidgetNode=function(t,e){const s=document.createElement("div"),i=document.createElement("pre");i.className="jp-Stdin-prompt",i.textContent=t;const n=document.createElement("input");return n.className="jp-Stdin-input",e&&(n.type="password"),s.appendChild(i),i.appendChild(n),s};class e extends _.Widget{constructor(t){super({node:document.createElement("iframe")}),this.addClass("jp-mod-isolated"),this._wrapped=t;const e=this.node;e.frameBorder="0",e.scrolling="auto",e.addEventListener("load",(()=>{e.contentDocument.open(),e.contentDocument.write(this._wrapped.node.innerHTML),e.contentDocument.close();const t=e.contentDocument.body;e.style.height=`${t.scrollHeight}px`,e.heightChangeObserver=new ResizeObserver((()=>{e.style.height=`${t.scrollHeight}px`})),e.heightChangeObserver.observe(t)}))}renderModel(t){return this._wrapped.renderModel(t)}}t.IsolatedRenderer=e,t.currentPreferredMimetype=new m.AttachedProperty({name:"preferredMimetype",create:t=>""});class s extends _.Panel{constructor(t){super(t)}_onContext(t){this.node.focus()}onAfterAttach(t){super.onAfterAttach(t),this.node.addEventListener("contextmenu",this._onContext.bind(this))}onBeforeDetach(t){super.onAfterDetach(t),this.node.removeEventListener("contextmenu",this._onContext.bind(this))}}t.OutputPanel=s;class i extends _.Widget{constructor(t,e){const s=document.createElement("div"),i=`The first ${t} are displayed`;s.insertAdjacentHTML("afterbegin",`<a title=${i}>\n <pre>Show more outputs</pre>\n </a>`),super({node:s}),this._onClick=e,this.addClass("jp-TrimmedOutputs"),this.addClass("jp-RenderedHTMLCommon")}handleEvent(t){"click"===t.type&&this._onClick(t)}onAfterAttach(t){super.onAfterAttach(t),this.node.addEventListener("click",this)}onBeforeDetach(t){super.onBeforeDetach(t),this.node.removeEventListener("click",this)}}t.TrimmedOutputs=i}(C||(C={}))}}]);
|
notebook/static/7252.bundle.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_JUPYTERLAB_CORE_OUTPUT=self.webpackChunk_JUPYTERLAB_CORE_OUTPUT||[]).push([[7252,9685],{79685:(e,t,r)=>{r.r(t),r.d(t,{default:()=>k});var n,a=r(
|
|
1
|
+
"use strict";(self.webpackChunk_JUPYTERLAB_CORE_OUTPUT=self.webpackChunk_JUPYTERLAB_CORE_OUTPUT||[]).push([[7252,9685],{79685:(e,t,r)=>{r.r(t),r.d(t,{default:()=>k});var n,a=r(3053),o=r(12982),d=r(38639),i=r(73847),c=r(70856),s=r(36768),w=r(87749),m=r(71677);!function(e){e.markdownPreview="markdownviewer:open",e.markdownEditor="markdownviewer:edit"}(n||(n={}));const p="Markdown Preview",l={activate:function(e,t,r,a,s,w,m){const k=r.load("jupyterlab"),{commands:u,docRegistry:g}=e;t.addFactory(c.markdownRendererFactory);const f=new o.WidgetTracker({namespace:"markdownviewer-widget"});let h={...i.MarkdownViewer.defaultConfig};function y(e){Object.keys(h).forEach((t=>{var r;e.setOption(t,null!==(r=h[t])&&void 0!==r?r:null)}))}if(s){const e=e=>{h=e.composite,f.forEach((e=>{y(e.content)}))};s.load(l.id).then((t=>{t.changed.connect((()=>{e(t)})),e(t)})).catch((e=>{console.error(e.message)}))}const v=new i.MarkdownViewerFactory({rendermime:t,name:p,label:k.__("Markdown Preview"),primaryFileType:g.getFileType("markdown"),fileTypes:["markdown"],defaultRendered:["markdown"]});return v.widgetCreated.connect(((e,t)=>{t.context.pathChanged.connect((()=>{f.save(t)})),y(t.content),f.add(t)})),g.addWidgetFactory(v),a&&a.restore(f,{command:"docmanager:open",args:e=>({path:e.context.path,factory:p}),name:e=>e.context.path}),u.addCommand(n.markdownPreview,{label:k.__("Markdown Preview"),execute:e=>{const t=e.path;if("string"==typeof t)return u.execute("docmanager:open",{path:t,factory:p,options:e.options})}}),u.addCommand(n.markdownEditor,{execute:()=>{const e=f.currentWidget;if(!e)return;const t=e.context.path;return u.execute("docmanager:open",{path:t,factory:"Editor",options:{mode:"split-right"}})},isVisible:()=>{const e=f.currentWidget;return e&&".md"===d.PathExt.extname(e.context.path)||!1},label:k.__("Show Markdown Editor")}),w&&w.add(new i.MarkdownViewerTableOfContentsFactory(f,t.markdownParser,null!=m?m:t.sanitizer)),f},id:"@jupyterlab/markdownviewer-extension:plugin",description:"Adds markdown file viewer and provides its tracker.",provides:i.IMarkdownViewerTracker,requires:[c.IRenderMimeRegistry,m.ITranslator],optional:[a.ILayoutRestorer,s.ISettingRegistry,w.ITableOfContentsRegistry,o.ISanitizer],autoStart:!0},k=l}}]);
|
notebook/static/7302.bundle.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_JUPYTERLAB_CORE_OUTPUT=self.webpackChunk_JUPYTERLAB_CORE_OUTPUT||[]).push([[7302,3768],{83768:(e,t,o)=>{o.r(t),o.d(t,{default:()=>F});var n=o(
|
|
1
|
+
"use strict";(self.webpackChunk_JUPYTERLAB_CORE_OUTPUT=self.webpackChunk_JUPYTERLAB_CORE_OUTPUT||[]).push([[7302,3768],{83768:(e,t,o)=>{o.r(t),o.d(t,{default:()=>F});var n=o(12982),r=o(38639),i=o(97713),a=o(36768),s=o(13589),l=o(68671),d=o(71677),c=o(68239),g=o(81997),u=o(31516),w=o(45321),h=o(78156),b=o.n(h);class p{constructor(e){this._onSelectionChanged=()=>{var e,t,o,n,r,i;const a=Array.from(this._browser.selectedItems()),s=a.length>0,l=a.some((e=>"directory"===e.type));null===(e=this._widgets.get("placeholder"))||void 0===e||e.setHidden(s),null===(t=this._widgets.get("delete"))||void 0===t||t.setHidden(!s),null===(o=this._widgets.get("duplicate"))||void 0===o||o.setHidden(!s||l),null===(n=this._widgets.get("download"))||void 0===n||n.setHidden(!s||l),null===(r=this._widgets.get("open"))||void 0===r||r.setHidden(!s||l),null===(i=this._widgets.get("rename"))||void 0===i||i.setHidden(1!==a.length)},this._widgets=new Map,this._browser=e.browser;const{commands:t,selectionChanged:o,translator:r}=e,i=r.load("notebook"),a=n.ReactWidget.create(b().createElement("div",{key:"placeholder"},i.__("Select items to perform actions on them.")));a.id="fileAction-placeholder",this._widgets.set("placeholder",a),["open","download","rename","duplicate","delete"].forEach((e=>{const o=n.ReactWidget.create(b().createElement(n.CommandToolbarButtonComponent,{key:e,commands:t,id:`filebrowser:${e}`,args:{toolbar:!0},icon:void 0}));o.id=`fileAction-${e}`,o.addClass("jp-ToolbarButton"),o.addClass("jp-FileAction"),this._widgets.set(e,o)})),o.connect(this._onSelectionChanged,this),this._onSelectionChanged()}get widgets(){return this._widgets.values()}}const m="FileBrowser";var f;!function(e){e.activate="filebrowser:activate"}(f||(f={}));const _={id:"@jupyter-notebook/tree-extension:new",description:"Plugin to add extra commands to the file browser to create new notebooks, files, consoles and terminals.",requires:[d.ITranslator],optional:[n.IToolbarWidgetRegistry],autoStart:!0,activate:(e,t,o)=>{var n;const{commands:r,serviceManager:i}=e,a=t.load("notebook"),s={overflowMenuOptions:{isVisible:!1}},l=new u.MenuBar(s),d=new u.Menu({commands:r});d.title.label=a.__("New"),d.title.icon=c.caretDownIcon,l.addMenu(d);const g=()=>{var e,t;const o=null===(t=null===(e=i.kernelspecs)||void 0===e?void 0:e.specs)||void 0===t?void 0:t.kernelspecs;for(const e in o)d.addItem({args:{kernelName:e,isLauncher:!0},command:"notebook:create-new"});["terminal:create-new","console:create","filebrowser:create-new-file","filebrowser:create-new-directory"].forEach((e=>{d.addItem({command:e})}))};null===(n=i.kernelspecs)||void 0===n||n.specsChanged.connect((()=>{d.clearItems(),g()})),g(),o&&o.addFactory(m,"new-dropdown",(e=>{const t=new u.MenuBar(s);return t.addMenu(d),t.addClass("jp-DropdownMenu"),t}))}},v={id:"@jupyter-notebook/tree-extension:file-actions",description:"A plugin to add file browser actions to the file browser toolbar.",autoStart:!0,requires:[i.IDefaultFileBrowser,n.IToolbarWidgetRegistry,d.ITranslator],activate:(e,t,o,n)=>{const r=new g.Signal(t);["_selectItem","_handleMultiSelect","handleFileSelect"].forEach((e=>{const o=t.listing[e];t.listing[e]=(...e)=>{o.call(t.listing,...e),r.emit(void 0)}}));const{commands:i}=e,a=new p({commands:i,browser:t,selectionChanged:r,translator:n});for(const e of a.widgets)o.addFactory(m,e.id,(()=>e))}},y={id:"@jupyter-notebook/tree-extension:load-plugins",description:"Plugin to load the default plugins that are loaded on all the Notebook pages (tree, edit, view, etc.) so they are visible in the settings editor.",autoStart:!0,requires:[a.ISettingRegistry],activate(e,t){const{isDisabled:o}=r.PageConfig.Extension,n=t.connector,i=r.PageConfig.getOption("allPlugins");if(!i)return;const a=JSON.parse(i),s=new Set;Object.keys(a).forEach((e=>{const t=a[e];Object.keys(t).forEach((e=>{const o=t[e];"boolean"==typeof o&&o?s.add(e):Array.isArray(o)&&o.forEach((e=>{s.add(e)}))}))})),e.restored.then((async()=>{(await n.list("all")).ids.forEach((async e=>{const[n]=e.split(":");if((s.has(n)||s.has(e))&&!o(e)&&!(e in t.plugins))try{await t.load(e)}catch(t){console.warn(`Settings failed to load for (${e})`,t)}}))}))}},k={id:"@jupyter-notebook/tree-extension:open-file-browser",description:"A plugin to add file browser commands for the tree view.",requires:[w.INotebookTree,i.IDefaultFileBrowser],autoStart:!0,activate:(e,t,o)=>{const{commands:n}=e;n.addCommand(f.activate,{execute:()=>{t.currentWidget=o}})}},S={id:"@jupyter-notebook/tree-extension:widget",description:"A plugin to add the file browser widget to an INotebookShell.",requires:[i.IDefaultFileBrowser,d.ITranslator,a.ISettingRegistry,n.IToolbarWidgetRegistry,i.IFileBrowserFactory],optional:[s.IRunningSessionManagers,l.ISettingEditorTracker,l.IJSONSettingEditorTracker],autoStart:!0,provides:w.INotebookTree,activate:(e,t,o,r,a,l,d,g,u)=>{const h=new w.NotebookTreeWidget,b=o.load("notebook");if(t.title.label=b.__("Files"),t.node.setAttribute("role","region"),t.node.setAttribute("aria-label",b.__("File Browser Section")),t.title.icon=c.folderIcon,h.addWidget(t),h.tabBar.addTab(t.title),h.tabsMovable=!1,a.addFactory(m,"uploader",(e=>new i.Uploader({model:e.model,translator:o,label:b.__("Upload")}))),a.addFactory(m,"fileNameSearcher",(e=>{const t=(0,c.FilenameSearcher)({updateFilter:(t,o)=>{e.model.setFilter((e=>t(e.name.toLowerCase())))},useFuzzyFilter:!0,placeholder:b.__("Filter files by name"),forceRefresh:!0});return t.addClass("jp-FileBrowser-filterBox"),t})),(0,n.setToolbar)(t,(0,n.createToolbarFactory)(a,r,m,S.id,o)),d){const e=new s.RunningSessions(d,o);e.id="jp-running-sessions-tree",e.title.label=b.__("Running"),e.title.icon=c.runningIcon,h.addWidget(e),h.tabBar.addTab(e.title)}const p=r.load("@jupyterlab/filebrowser-extension:browser");Promise.all([p,e.restored]).then((([e])=>{["showFileCheckboxes","showFileSizeColumn","sortNotebooksFirst","showFullPath"].forEach((t=>{void 0===e.user[t]&&e.set(t,!0)}))})).catch((e=>{console.error(e.message)})),e.shell.add(h,"main",{rank:100}),[g,u].forEach((e=>{e&&e.widgetAdded.connect(((e,t)=>{h.addWidget(t),h.tabBar.addTab(t.title),h.currentWidget=t}))}));const{tracker:f}=l,_=()=>{f._pool.current=t};return f.widgetAdded.connect(((e,t)=>_())),_(),h}},F=[_,v,y,k,S]}}]);
|
notebook/static/7386.bundle.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_JUPYTERLAB_CORE_OUTPUT=self.webpackChunk_JUPYTERLAB_CORE_OUTPUT||[]).push([[7386,4811],{37386:(e,t,o)=>{o.r(t),o.d(t,{CellBarExtension:()=>u,CellToolbarTracker:()=>c});var l=o(
|
|
1
|
+
"use strict";(self.webpackChunk_JUPYTERLAB_CORE_OUTPUT=self.webpackChunk_JUPYTERLAB_CORE_OUTPUT||[]).push([[7386,4811],{37386:(e,t,o)=>{o.r(t),o.d(t,{CellBarExtension:()=>u,CellToolbarTracker:()=>c});var l=o(12982),n=o(11351),a=o(68239),i=o(33625),s=o(81997);const r=["text/plain","application/vnd.jupyter.stdout","application/vnd.jupyter.stderr"],d="jp-toolbar-overlap";class c{constructor(e,t,o){if(this._isDisposed=!1,this._toolbar=null,this._toolbarItems=null,this._toolbarFactory=null,this._panel=e,this._previousActiveCell=this._panel.content.activeCell,this._toolbarItems=null!=t?t:null,this._toolbarFactory=null!=o?o:null,null===this._toolbarItems&&null===this._toolbarFactory)throw Error("You must provide the toolbarFactory or the toolbar items.");!this._toolbarFactory&&this._toolbarItems&&(this._onToolbarChanged(),this._toolbarItems.changed.connect(this._onToolbarChanged,this)),e.revealed.then((()=>{requestAnimationFrame((()=>{const t=e.content;this._onActiveCellChanged(t),t.activeCellChanged.connect(this._onActiveCellChanged,this),t.renderingLayoutChanged.connect(this._onActiveCellChanged,this),t.disposed.connect((()=>{t.activeCellChanged.disconnect(this._onActiveCellChanged)}))}))}))}_onMetadataChanged(e,t){"jupyter"===t.key&&("object"!=typeof t.newValue||!0!==t.newValue.source_hidden||"add"!==t.type&&"change"!==t.type?"object"==typeof t.oldValue&&!0===t.oldValue.source_hidden&&this._addToolbar(e):this._removeToolbar(e))}_onActiveCellChanged(e){this._previousActiveCell&&!this._previousActiveCell.isDisposed&&(this._removeToolbar(this._previousActiveCell.model),this._previousActiveCell.model.metadataChanged.disconnect(this._onMetadataChanged));const t=e.activeCell;this._previousActiveCell=t,null===t||t.inputHidden||(t.model.metadataChanged.connect(this._onMetadataChanged,this),this._addToolbar(t.model))}get isDisposed(){return this._isDisposed}dispose(){var e,t;this.isDisposed||(this._isDisposed=!0,null===(e=this._toolbarItems)||void 0===e||e.changed.disconnect(this._onToolbarChanged,this),null===(t=this._toolbar)||void 0===t||t.dispose(),this._panel=null,s.Signal.clearData(this))}_addToolbar(e){const t=this._getCell(e);if(t&&!t.isDisposed){const e=this._toolbar=new a.Toolbar;e.addClass("jp-cell-menu"),e.addClass("jp-cell-toolbar");const o=[t.ready];if(this._toolbarFactory)(0,l.setToolbar)(t,this._toolbarFactory,e),e.layout.widgets.forEach((e=>{e.update()}));else for(const{name:t,widget:l}of this._toolbarItems)e.addItem(t,l),l instanceof a.ReactWidget&&void 0!==l.renderPromise&&(l.update(),o.push(l.renderPromise));Promise.all(o).then((()=>{var o;t.isDisposed||(null===(o=this._panel)||void 0===o?void 0:o.content.activeCell)!==t?e.dispose():(t.layout.insertWidget(0,e),t.displayChanged.connect(this._resizeEventCallback,this),t.model.contentChanged.connect(this._changedEventCallback,this),this._updateCellForToolbarOverlap(t))})).catch((e=>{console.error("Error rendering buttons of the cell toolbar: ",e)}))}}_getCell(e){var t;return null===(t=this._panel)||void 0===t?void 0:t.content.widgets.find((t=>t.model===e))}_removeToolbar(e){var t,o;const l=this._getCell(e);l&&!l.isDisposed&&l.displayChanged.disconnect(this._resizeEventCallback,this),e.contentChanged.disconnect(this._changedEventCallback,this),(null===(t=this._toolbar)||void 0===t?void 0:t.parent)===l&&!1===(null===(o=this._toolbar)||void 0===o?void 0:o.isDisposed)&&this._toolbar.dispose()}_onToolbarChanged(){var e;const t=null===(e=this._panel)||void 0===e?void 0:e.content.activeCell;t&&(this._removeToolbar(t.model),this._addToolbar(t.model))}_changedEventCallback(){var e;const t=null===(e=this._panel)||void 0===e?void 0:e.content.activeCell;null!=t&&this._updateCellForToolbarOverlap(t)}_resizeEventCallback(){var e;const t=null===(e=this._panel)||void 0===e?void 0:e.content.activeCell;null!=t&&this._updateCellForToolbarOverlap(t)}_updateCellForToolbarOverlap(e){requestAnimationFrame((()=>{const t=e.node;t.classList.remove(d),this._cellToolbarOverlapsContents(e)&&t.classList.add(d)}))}_cellToolbarOverlapsContents(e){var t,o,l,n;const a=e.model.type,i=null===(t=e.editorWidget)||void 0===t?void 0:t.node.getBoundingClientRect(),s=null!==(o=null==i?void 0:i.left)&&void 0!==o?o:0,r=null!==(l=null==i?void 0:i.right)&&void 0!==l?l:0,d=this._cellToolbarLeft(e);return null!==d&&((s+r)/2>d||("markdown"===a&&e.rendered?this._markdownOverlapsToolbar(e):"default"===(null===(n=this._panel)||void 0===n?void 0:n.content.renderingLayout)?this._codeOverlapsToolbar(e):this._outputOverlapsToolbar(e)))}_markdownOverlapsToolbar(e){const t=e.inputArea;if(!t)return!1;const o=t.renderedInput.node.firstElementChild;if(null===o)return!1;const l=o.style.maxWidth;o.style.maxWidth="max-content";const n=o.getBoundingClientRect().right;o.style.maxWidth=l;const a=this._cellToolbarLeft(e);return null!==a&&n>a}_outputOverlapsToolbar(e){const t=e.outputArea.node;if(t){const o=t.querySelectorAll("[data-mime-type]"),l=this._cellToolbarRect(e);if(l){const{left:e,bottom:t}=l;return(0,i.some)(o,(o=>{const l=o.firstElementChild;if(l){const n=new Range;r.includes(o.getAttribute("data-mime-type")||"")?n.selectNodeContents(l):n.selectNode(l);const{right:a,top:i}=n.getBoundingClientRect();return a>e&&i<t}return!1}))}}return!1}_codeOverlapsToolbar(e){const t=e.editorWidget,o=e.editor;if(!t||!o)return!1;if(o.lineCount<1)return!1;const l=t.node.getElementsByClassName("cm-line");if(l.length<1)return!1;let n=l[0].getBoundingClientRect().left;const a=document.createRange();a.selectNodeContents(l[0]),n+=a.getBoundingClientRect().width;const i=this._cellToolbarLeft(e);return null!==i&&n>i}_cellToolbarRect(e){var t;return(null===(t=this._toolbar)||void 0===t?void 0:t.parent)!==e?null:this._toolbar.node.getBoundingClientRect()}_cellToolbarLeft(e){var t;return(null===(t=this._cellToolbarRect(e))||void 0===t?void 0:t.left)||null}}const h=[{command:"notebook:duplicate-below",name:"duplicate-cell"},{command:"notebook:move-cell-up",name:"move-cell-up"},{command:"notebook:move-cell-down",name:"move-cell-down"},{command:"notebook:insert-cell-above",name:"insert-cell-above"},{command:"notebook:insert-cell-below",name:"insert-cell-below"},{command:"notebook:delete-cell",name:"delete-cell"}];class u{constructor(e,t){this._commands=e,this._toolbarFactory=null!=t?t:this.defaultToolbarFactory}get defaultToolbarFactory(){const e=(0,l.createDefaultFactory)(this._commands);return t=>new n.ObservableList({values:h.map((o=>({name:o.name,widget:e(u.FACTORY_NAME,t,o)})))})}createNew(e){return new c(e,void 0,this._toolbarFactory)}}u.FACTORY_NAME="Cell"}}]);
|
notebook/static/7391.bundle.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_JUPYTERLAB_CORE_OUTPUT=self.webpackChunk_JUPYTERLAB_CORE_OUTPUT||[]).push([[7391],{77391:(e,t,i)=>{i.r(t),i.d(t,{COMPLETER_ACTIVE_CLASS:()=>D,COMPLETER_ENABLED_CLASS:()=>E,CodeEditor:()=>o,CodeEditorWrapper:()=>L,CodeViewerWidget:()=>j,IEditorMimeTypeService:()=>s,IEditorServices:()=>S,IPositionModel:()=>N,JSONEditor:()=>m,LineCol:()=>f});var s,o,n=i(23781),r=i(50892),a=i(81997);!function(e){e.defaultMimeType="text/plain"}(s||(s={})),function(e){e.Model=class{constructor(e={}){var t,i;this.standaloneModel=!1,this._isDisposed=!1,this._selections=new r.ObservableMap,this._mimeType=s.defaultMimeType,this._mimeTypeChanged=new a.Signal(this),this.standaloneModel=void 0===e.sharedModel,this.sharedModel=null!==(t=e.sharedModel)&&void 0!==t?t:new n.YFile,this._mimeType=null!==(i=e.mimeType)&&void 0!==i?i:s.defaultMimeType}get mimeTypeChanged(){return this._mimeTypeChanged}get selections(){return this._selections}get mimeType(){return this._mimeType}set mimeType(e){const t=this.mimeType;t!==e&&(this._mimeType=e,this._mimeTypeChanged.emit({name:"mimeType",oldValue:t,newValue:e}))}get isDisposed(){return this._isDisposed}dispose(){this._isDisposed||(this._isDisposed=!0,this._selections.dispose(),this.standaloneModel&&this.sharedModel.dispose(),a.Signal.clearData(this))}}}(o||(o={}));var d=i(11523),h=i(52018),l=i(20998),c=i(31516);const u="jp-mod-error";class m extends c.Widget{constructor(e){super(),this._dataDirty=!1,this._inputDirty=!1,this._source=null,this._originalValue=l.JSONExt.emptyObject,this._changeGuard=!1,this.translator=e.translator||d.nullTranslator,this._trans=this.translator.load("jupyterlab"),this.addClass("jp-JSONEditor"),this.headerNode=document.createElement("div"),this.headerNode.className="jp-JSONEditor-header",this.revertButtonNode=h.undoIcon.element({tag:"span",title:this._trans.__("Revert changes to data")}),this.commitButtonNode=h.checkIcon.element({tag:"span",title:this._trans.__("Commit changes to data"),marginLeft:"8px"}),this.editorHostNode=document.createElement("div"),this.editorHostNode.className="jp-JSONEditor-host",this.headerNode.appendChild(this.revertButtonNode),this.headerNode.appendChild(this.commitButtonNode),this.node.appendChild(this.headerNode),this.node.appendChild(this.editorHostNode);const t=new o.Model({mimeType:"application/json"});t.sharedModel.changed.connect(this._onModelChanged,this),this.model=t,this.editor=e.editorFactory({host:this.editorHostNode,model:t,config:{readOnly:!0}})}get source(){return this._source}set source(e){this._source!==e&&(this._source&&this._source.changed.disconnect(this._onSourceChanged,this),this._source=e,this.editor.setOption("readOnly",null===e),e&&e.changed.connect(this._onSourceChanged,this),this._setValue())}get isDirty(){return this._dataDirty||this._inputDirty}dispose(){var e;this.isDisposed||(null===(e=this.source)||void 0===e||e.dispose(),this.model.dispose(),this.editor.dispose(),super.dispose())}handleEvent(e){switch(e.type){case"blur":this._evtBlur(e);break;case"click":this._evtClick(e)}}onAfterAttach(e){const t=this.editorHostNode;t.addEventListener("blur",this,!0),t.addEventListener("click",this,!0),this.revertButtonNode.hidden=!0,this.commitButtonNode.hidden=!0,this.headerNode.addEventListener("click",this)}onBeforeDetach(e){const t=this.editorHostNode;t.removeEventListener("blur",this,!0),t.removeEventListener("click",this,!0),this.headerNode.removeEventListener("click",this)}_onSourceChanged(e,t){this._changeGuard||(this._inputDirty||this.editor.hasFocus()?this._dataDirty=!0:this._setValue())}_onModelChanged(e,t){if(t.sourceChange){let e=!0;try{const e=JSON.parse(this.editor.model.sharedModel.getSource());this.removeClass(u),this._inputDirty=!this._changeGuard&&!l.JSONExt.deepEqual(e,this._originalValue)}catch(t){this.addClass(u),this._inputDirty=!0,e=!1}this.revertButtonNode.hidden=!this._inputDirty,this.commitButtonNode.hidden=!e||!this._inputDirty}}_evtBlur(e){!this._inputDirty&&this._dataDirty&&this._setValue()}_evtClick(e){const t=e.target;this.revertButtonNode.contains(t)?this._setValue():this.commitButtonNode.contains(t)?this.commitButtonNode.hidden||this.hasClass(u)||(this._changeGuard=!0,this._mergeContent(),this._changeGuard=!1,this._setValue()):this.editorHostNode.contains(t)&&this.editor.focus()}_mergeContent(){const e=this.editor.model,t=this._originalValue,i=JSON.parse(e.sharedModel.getSource()),s=this.source;if(s){for(const e in i)l.JSONExt.deepEqual(i[e],t[e]||null)||s.set(e,i[e]);for(const e in t)e in i||s.delete(e)}}_setValue(){this._dataDirty=!1,this._inputDirty=!1,this.revertButtonNode.hidden=!0,this.commitButtonNode.hidden=!0,this.removeClass(u);const e=this.editor.model,t=this._source?this._source.toJSON():{};if(this._changeGuard=!0,void 0===t)e.sharedModel.setSource(this._trans.__("No data!")),this._originalValue=l.JSONExt.emptyObject;else{const i=JSON.stringify(t,null,4);e.sharedModel.setSource(i),this._originalValue=t,i.length>1&&"{"===i[0]&&this.editor.setCursorPosition({line:0,column:1})}this._changeGuard=!1,this.commitButtonNode.hidden=!0,this.revertButtonNode.hidden=!0}}var p=i(22629),_=i(78156),g=i.n(_),v=i(57797);class C extends g().Component{constructor(e){super(e),this._handleChange=e=>{this.setState({value:e.currentTarget.value})},this._handleSubmit=e=>{e.preventDefault();const t=parseInt(this._textInput.value,10);return!isNaN(t)&&isFinite(t)&&1<=t&&t<=this.props.maxLine&&this.props.handleSubmit(t),!1},this._handleFocus=()=>{this.setState({hasFocus:!0})},this._handleBlur=()=>{this.setState({hasFocus:!1})},this._textInput=null,this.translator=e.translator||d.nullTranslator,this._trans=this.translator.load("jupyterlab"),this.state={value:"",hasFocus:!1,textInputId:v.DOMUtils.createDomID()+"-line-number-input"}}componentDidMount(){this._textInput.focus()}render(){return g().createElement("div",{className:"jp-lineFormSearch"},g().createElement("form",{name:"lineColumnForm",onSubmit:this._handleSubmit,noValidate:!0},g().createElement("div",{className:(0,h.classes)("jp-lineFormWrapper","lm-lineForm-wrapper",this.state.hasFocus?"jp-lineFormWrapperFocusWithin":void 0)},g().createElement("input",{type:"text",id:this.state.textInputId,className:"jp-lineFormInput",onChange:this._handleChange,onFocus:this._handleFocus,onBlur:this._handleBlur,value:this.state.value,ref:e=>{this._textInput=e}}),g().createElement("div",{className:"jp-baseLineForm jp-lineFormButtonContainer"},g().createElement(h.lineFormIcon.react,{className:"jp-baseLineForm jp-lineFormButtonIcon",elementPosition:"center"}),g().createElement("input",{type:"submit",className:"jp-baseLineForm jp-lineFormButton",value:""}))),g().createElement("label",{className:"jp-lineFormCaption",htmlFor:this.state.textInputId},this._trans.__("Go to line number between 1 and %1",this.props.maxLine))))}}function y(e){const t=(e.translator||d.nullTranslator).load("jupyterlab");return g().createElement(p.TextItem,{onClick:e.handleClick,source:t.__("Ln %1, Col %2",e.line,e.column),title:t.__("Go to line number…"),tabIndex:0,onKeyDown:t=>{"Enter"!==t.key&&"Spacebar"!==t.key&&" "!==t.key||(t.preventDefault(),t.stopPropagation(),e.handleClick())}})}class f extends h.VDomRenderer{constructor(e){super(new f.Model),this._popup=null,this.addClass("jp-mod-highlighted"),this.translator=e||d.nullTranslator}render(){return null===this.model?null:g().createElement(y,{line:this.model.line,column:this.model.column,translator:this.translator,handleClick:()=>this._handleClick()})}_handleClick(){this._popup&&this._popup.dispose();const e=h.ReactWidget.create(g().createElement(C,{handleSubmit:e=>this._handleSubmit(e),currentLine:this.model.line,maxLine:this.model.editor.lineCount,translator:this.translator}));this._popup=(0,p.showPopup)({body:e,anchor:this,align:"right"})}_handleSubmit(e){this.model.editor.setCursorPosition({line:e-1,column:0}),this._popup.dispose(),this.model.editor.focus()}}!function(e){class t extends h.VDomModel{constructor(){super(...arguments),this._onSelectionChanged=()=>{const e=this._getAllState(),t=this.editor.getCursorPosition();this._line=t.line+1,this._column=t.column+1,this._triggerChange(e,this._getAllState())},this._line=1,this._column=1,this._editor=null}get editor(){return this._editor}set editor(e){var t;const i=this._editor;(null===(t=null==i?void 0:i.model)||void 0===t?void 0:t.selections)&&i.model.selections.changed.disconnect(this._onSelectionChanged);const s=this._getAllState();if(this._editor=e,this._editor){this._editor.model.selections.changed.connect(this._onSelectionChanged);const e=this._editor.getCursorPosition();this._column=e.column+1,this._line=e.line+1}else this._column=1,this._line=1;this._triggerChange(s,this._getAllState())}get line(){return this._line}get column(){return this._column}_getAllState(){return[this._line,this._column]}_triggerChange(e,t){e[0]===t[0]&&e[1]===t[1]||this.stateChanged.emit(void 0)}}e.Model=t}(f||(f={}));const E="jp-mod-completer-enabled",D="jp-mod-completer-active",S=new l.Token("@jupyterlab/codeeditor:IEditorServices","A service for the text editor provider\n for the application. Use this to create new text editors and host them in your\n UI elements."),N=new l.Token("@jupyterlab/codeeditor:IPositionModel","A service to handle an code editor cursor position."),T="jp-mod-has-primary-selection",O="jp-mod-in-leading-whitespace",b="jp-mod-dropTarget",x=/^\s+$/;class L extends c.Widget{constructor(e){super();const{factory:t,model:i,editorOptions:s}=e;(this.editor=t({host:this.node,model:i,...s})).model.selections.changed.connect(this._onSelectionsChanged,this)}get model(){return this.editor.model}dispose(){this.isDisposed||(this.editor.dispose(),super.dispose())}handleEvent(e){switch(e.type){case"lm-dragenter":this._evtDragEnter(e);break;case"lm-dragleave":this._evtDragLeave(e);break;case"lm-dragover":this._evtDragOver(e);break;case"lm-drop":this._evtDrop(e)}}onActivateRequest(e){this.editor.focus()}onAfterAttach(e){super.onAfterAttach(e);const t=this.node;t.addEventListener("lm-dragenter",this),t.addEventListener("lm-dragleave",this),t.addEventListener("lm-dragover",this),t.addEventListener("lm-drop",this)}onBeforeDetach(e){const t=this.node;t.removeEventListener("lm-dragenter",this),t.removeEventListener("lm-dragleave",this),t.removeEventListener("lm-dragover",this),t.removeEventListener("lm-drop",this)}_onSelectionsChanged(){const{start:e,end:t}=this.editor.getSelection();e.column!==t.column||e.line!==t.line?(this.addClass(T),this.removeClass(O)):(this.removeClass(T),this.editor.getLine(t.line).slice(0,t.column).match(x)?this.addClass(O):this.removeClass(O))}_evtDragEnter(e){!0!==this.editor.getOption("readOnly")&&void 0!==M.findTextData(e.mimeData)&&(e.preventDefault(),e.stopPropagation(),this.addClass("jp-mod-dropTarget"))}_evtDragLeave(e){this.removeClass(b),!0!==this.editor.getOption("readOnly")&&void 0!==M.findTextData(e.mimeData)&&(e.preventDefault(),e.stopPropagation())}_evtDragOver(e){this.removeClass(b),!0!==this.editor.getOption("readOnly")&&void 0!==M.findTextData(e.mimeData)&&(e.preventDefault(),e.stopPropagation(),e.dropAction="copy",this.addClass(b))}_evtDrop(e){if(!0===this.editor.getOption("readOnly"))return;const t=M.findTextData(e.mimeData);if(void 0===t)return;const i={top:e.y,bottom:e.y,left:e.x,right:e.x,x:e.x,y:e.y,width:0,height:0},s=this.editor.getPositionForCoordinate(i);if(null===s)return;if(this.removeClass(b),e.preventDefault(),e.stopPropagation(),"none"===e.proposedAction)return void(e.dropAction="none");const o=this.editor.getOffsetAt(s);this.model.sharedModel.updateSource(o,o,t)}}var M;!function(e){e.findTextData=function(e){const t=e.types().find((e=>0===e.indexOf("text")));if(void 0!==t)return e.getData(t)}}(M||(M={}));class j extends c.Widget{constructor(e){var t;super(),this.model=e.model;const i=new L({factory:e.factory,model:this.model,editorOptions:{...e.editorOptions,config:{...null===(t=e.editorOptions)||void 0===t?void 0:t.config,readOnly:!0}}});this.editor=i.editor,(this.layout=new c.StackedLayout).addWidget(i)}static createCodeViewer(e){const{content:t,mimeType:i,...s}=e,n=new o.Model({mimeType:i});n.sharedModel.setSource(t);const r=new j({...s,model:n});return r.disposed.connect((()=>{n.dispose()})),r}get content(){return this.model.sharedModel.getSource()}get mimeType(){return this.model.mimeType}}}}]);
|
|
1
|
+
"use strict";(self.webpackChunk_JUPYTERLAB_CORE_OUTPUT=self.webpackChunk_JUPYTERLAB_CORE_OUTPUT||[]).push([[7391],{77391:(e,t,i)=>{i.r(t),i.d(t,{COMPLETER_ACTIVE_CLASS:()=>D,COMPLETER_ENABLED_CLASS:()=>E,CodeEditor:()=>o,CodeEditorWrapper:()=>L,CodeViewerWidget:()=>j,IEditorMimeTypeService:()=>s,IEditorServices:()=>S,IPositionModel:()=>N,JSONEditor:()=>m,LineCol:()=>f});var s,o,n=i(23781),r=i(11351),a=i(81997);!function(e){e.defaultMimeType="text/plain"}(s||(s={})),function(e){e.Model=class{constructor(e={}){var t,i;this.standaloneModel=!1,this._isDisposed=!1,this._selections=new r.ObservableMap,this._mimeType=s.defaultMimeType,this._mimeTypeChanged=new a.Signal(this),this.standaloneModel=void 0===e.sharedModel,this.sharedModel=null!==(t=e.sharedModel)&&void 0!==t?t:new n.YFile,this._mimeType=null!==(i=e.mimeType)&&void 0!==i?i:s.defaultMimeType}get mimeTypeChanged(){return this._mimeTypeChanged}get selections(){return this._selections}get mimeType(){return this._mimeType}set mimeType(e){const t=this.mimeType;t!==e&&(this._mimeType=e,this._mimeTypeChanged.emit({name:"mimeType",oldValue:t,newValue:e}))}get isDisposed(){return this._isDisposed}dispose(){this._isDisposed||(this._isDisposed=!0,this._selections.dispose(),this.standaloneModel&&this.sharedModel.dispose(),a.Signal.clearData(this))}}}(o||(o={}));var d=i(71677),h=i(68239),l=i(20998),c=i(31516);const u="jp-mod-error";class m extends c.Widget{constructor(e){super(),this._dataDirty=!1,this._inputDirty=!1,this._source=null,this._originalValue=l.JSONExt.emptyObject,this._changeGuard=!1,this.translator=e.translator||d.nullTranslator,this._trans=this.translator.load("jupyterlab"),this.addClass("jp-JSONEditor"),this.headerNode=document.createElement("div"),this.headerNode.className="jp-JSONEditor-header",this.revertButtonNode=h.undoIcon.element({tag:"span",title:this._trans.__("Revert changes to data")}),this.commitButtonNode=h.checkIcon.element({tag:"span",title:this._trans.__("Commit changes to data"),marginLeft:"8px"}),this.editorHostNode=document.createElement("div"),this.editorHostNode.className="jp-JSONEditor-host",this.headerNode.appendChild(this.revertButtonNode),this.headerNode.appendChild(this.commitButtonNode),this.node.appendChild(this.headerNode),this.node.appendChild(this.editorHostNode);const t=new o.Model({mimeType:"application/json"});t.sharedModel.changed.connect(this._onModelChanged,this),this.model=t,this.editor=e.editorFactory({host:this.editorHostNode,model:t,config:{readOnly:!0}})}get source(){return this._source}set source(e){this._source!==e&&(this._source&&this._source.changed.disconnect(this._onSourceChanged,this),this._source=e,this.editor.setOption("readOnly",null===e),e&&e.changed.connect(this._onSourceChanged,this),this._setValue())}get isDirty(){return this._dataDirty||this._inputDirty}dispose(){var e;this.isDisposed||(null===(e=this.source)||void 0===e||e.dispose(),this.model.dispose(),this.editor.dispose(),super.dispose())}handleEvent(e){switch(e.type){case"blur":this._evtBlur(e);break;case"click":this._evtClick(e)}}onAfterAttach(e){const t=this.editorHostNode;t.addEventListener("blur",this,!0),t.addEventListener("click",this,!0),this.revertButtonNode.hidden=!0,this.commitButtonNode.hidden=!0,this.headerNode.addEventListener("click",this)}onBeforeDetach(e){const t=this.editorHostNode;t.removeEventListener("blur",this,!0),t.removeEventListener("click",this,!0),this.headerNode.removeEventListener("click",this)}_onSourceChanged(e,t){this._changeGuard||(this._inputDirty||this.editor.hasFocus()?this._dataDirty=!0:this._setValue())}_onModelChanged(e,t){if(t.sourceChange){let e=!0;try{const e=JSON.parse(this.editor.model.sharedModel.getSource());this.removeClass(u),this._inputDirty=!this._changeGuard&&!l.JSONExt.deepEqual(e,this._originalValue)}catch(t){this.addClass(u),this._inputDirty=!0,e=!1}this.revertButtonNode.hidden=!this._inputDirty,this.commitButtonNode.hidden=!e||!this._inputDirty}}_evtBlur(e){!this._inputDirty&&this._dataDirty&&this._setValue()}_evtClick(e){const t=e.target;this.revertButtonNode.contains(t)?this._setValue():this.commitButtonNode.contains(t)?this.commitButtonNode.hidden||this.hasClass(u)||(this._changeGuard=!0,this._mergeContent(),this._changeGuard=!1,this._setValue()):this.editorHostNode.contains(t)&&this.editor.focus()}_mergeContent(){const e=this.editor.model,t=this._originalValue,i=JSON.parse(e.sharedModel.getSource()),s=this.source;if(s){for(const e in i)l.JSONExt.deepEqual(i[e],t[e]||null)||s.set(e,i[e]);for(const e in t)e in i||s.delete(e)}}_setValue(){this._dataDirty=!1,this._inputDirty=!1,this.revertButtonNode.hidden=!0,this.commitButtonNode.hidden=!0,this.removeClass(u);const e=this.editor.model,t=this._source?this._source.toJSON():{};if(this._changeGuard=!0,void 0===t)e.sharedModel.setSource(this._trans.__("No data!")),this._originalValue=l.JSONExt.emptyObject;else{const i=JSON.stringify(t,null,4);e.sharedModel.setSource(i),this._originalValue=t,i.length>1&&"{"===i[0]&&this.editor.setCursorPosition({line:0,column:1})}this._changeGuard=!1,this.commitButtonNode.hidden=!0,this.revertButtonNode.hidden=!0}}var p=i(34276),_=i(78156),g=i.n(_),v=i(12982);class C extends g().Component{constructor(e){super(e),this._handleChange=e=>{this.setState({value:e.currentTarget.value})},this._handleSubmit=e=>{e.preventDefault();const t=parseInt(this._textInput.value,10);return!isNaN(t)&&isFinite(t)&&1<=t&&t<=this.props.maxLine&&this.props.handleSubmit(t),!1},this._handleFocus=()=>{this.setState({hasFocus:!0})},this._handleBlur=()=>{this.setState({hasFocus:!1})},this._textInput=null,this.translator=e.translator||d.nullTranslator,this._trans=this.translator.load("jupyterlab"),this.state={value:"",hasFocus:!1,textInputId:v.DOMUtils.createDomID()+"-line-number-input"}}componentDidMount(){this._textInput.focus()}render(){return g().createElement("div",{className:"jp-lineFormSearch"},g().createElement("form",{name:"lineColumnForm",onSubmit:this._handleSubmit,noValidate:!0},g().createElement("div",{className:(0,h.classes)("jp-lineFormWrapper","lm-lineForm-wrapper",this.state.hasFocus?"jp-lineFormWrapperFocusWithin":void 0)},g().createElement("input",{type:"text",id:this.state.textInputId,className:"jp-lineFormInput",onChange:this._handleChange,onFocus:this._handleFocus,onBlur:this._handleBlur,value:this.state.value,ref:e=>{this._textInput=e}}),g().createElement("div",{className:"jp-baseLineForm jp-lineFormButtonContainer"},g().createElement(h.lineFormIcon.react,{className:"jp-baseLineForm jp-lineFormButtonIcon",elementPosition:"center"}),g().createElement("input",{type:"submit",className:"jp-baseLineForm jp-lineFormButton",value:""}))),g().createElement("label",{className:"jp-lineFormCaption",htmlFor:this.state.textInputId},this._trans.__("Go to line number between 1 and %1",this.props.maxLine))))}}function y(e){const t=(e.translator||d.nullTranslator).load("jupyterlab");return g().createElement(p.TextItem,{onClick:e.handleClick,source:t.__("Ln %1, Col %2",e.line,e.column),title:t.__("Go to line number…"),tabIndex:0,onKeyDown:t=>{"Enter"!==t.key&&"Spacebar"!==t.key&&" "!==t.key||(t.preventDefault(),t.stopPropagation(),e.handleClick())}})}class f extends h.VDomRenderer{constructor(e){super(new f.Model),this._popup=null,this.addClass("jp-mod-highlighted"),this.translator=e||d.nullTranslator}render(){return null===this.model?null:g().createElement(y,{line:this.model.line,column:this.model.column,translator:this.translator,handleClick:()=>this._handleClick()})}_handleClick(){this._popup&&this._popup.dispose();const e=h.ReactWidget.create(g().createElement(C,{handleSubmit:e=>this._handleSubmit(e),currentLine:this.model.line,maxLine:this.model.editor.lineCount,translator:this.translator}));this._popup=(0,p.showPopup)({body:e,anchor:this,align:"right"})}_handleSubmit(e){this.model.editor.setCursorPosition({line:e-1,column:0}),this._popup.dispose(),this.model.editor.focus()}}!function(e){class t extends h.VDomModel{constructor(){super(...arguments),this._onSelectionChanged=()=>{const e=this._getAllState(),t=this.editor.getCursorPosition();this._line=t.line+1,this._column=t.column+1,this._triggerChange(e,this._getAllState())},this._line=1,this._column=1,this._editor=null}get editor(){return this._editor}set editor(e){var t;const i=this._editor;(null===(t=null==i?void 0:i.model)||void 0===t?void 0:t.selections)&&i.model.selections.changed.disconnect(this._onSelectionChanged);const s=this._getAllState();if(this._editor=e,this._editor){this._editor.model.selections.changed.connect(this._onSelectionChanged);const e=this._editor.getCursorPosition();this._column=e.column+1,this._line=e.line+1}else this._column=1,this._line=1;this._triggerChange(s,this._getAllState())}get line(){return this._line}get column(){return this._column}_getAllState(){return[this._line,this._column]}_triggerChange(e,t){e[0]===t[0]&&e[1]===t[1]||this.stateChanged.emit(void 0)}}e.Model=t}(f||(f={}));const E="jp-mod-completer-enabled",D="jp-mod-completer-active",S=new l.Token("@jupyterlab/codeeditor:IEditorServices","A service for the text editor provider\n for the application. Use this to create new text editors and host them in your\n UI elements."),N=new l.Token("@jupyterlab/codeeditor:IPositionModel","A service to handle an code editor cursor position."),T="jp-mod-has-primary-selection",O="jp-mod-in-leading-whitespace",b="jp-mod-dropTarget",x=/^\s+$/;class L extends c.Widget{constructor(e){super();const{factory:t,model:i,editorOptions:s}=e;(this.editor=t({host:this.node,model:i,...s})).model.selections.changed.connect(this._onSelectionsChanged,this)}get model(){return this.editor.model}dispose(){this.isDisposed||(this.editor.dispose(),super.dispose())}handleEvent(e){switch(e.type){case"lm-dragenter":this._evtDragEnter(e);break;case"lm-dragleave":this._evtDragLeave(e);break;case"lm-dragover":this._evtDragOver(e);break;case"lm-drop":this._evtDrop(e)}}onActivateRequest(e){this.editor.focus()}onAfterAttach(e){super.onAfterAttach(e);const t=this.node;t.addEventListener("lm-dragenter",this),t.addEventListener("lm-dragleave",this),t.addEventListener("lm-dragover",this),t.addEventListener("lm-drop",this)}onBeforeDetach(e){const t=this.node;t.removeEventListener("lm-dragenter",this),t.removeEventListener("lm-dragleave",this),t.removeEventListener("lm-dragover",this),t.removeEventListener("lm-drop",this)}_onSelectionsChanged(){const{start:e,end:t}=this.editor.getSelection();e.column!==t.column||e.line!==t.line?(this.addClass(T),this.removeClass(O)):(this.removeClass(T),this.editor.getLine(t.line).slice(0,t.column).match(x)?this.addClass(O):this.removeClass(O))}_evtDragEnter(e){!0!==this.editor.getOption("readOnly")&&void 0!==M.findTextData(e.mimeData)&&(e.preventDefault(),e.stopPropagation(),this.addClass("jp-mod-dropTarget"))}_evtDragLeave(e){this.removeClass(b),!0!==this.editor.getOption("readOnly")&&void 0!==M.findTextData(e.mimeData)&&(e.preventDefault(),e.stopPropagation())}_evtDragOver(e){this.removeClass(b),!0!==this.editor.getOption("readOnly")&&void 0!==M.findTextData(e.mimeData)&&(e.preventDefault(),e.stopPropagation(),e.dropAction="copy",this.addClass(b))}_evtDrop(e){if(!0===this.editor.getOption("readOnly"))return;const t=M.findTextData(e.mimeData);if(void 0===t)return;const i={top:e.y,bottom:e.y,left:e.x,right:e.x,x:e.x,y:e.y,width:0,height:0},s=this.editor.getPositionForCoordinate(i);if(null===s)return;if(this.removeClass(b),e.preventDefault(),e.stopPropagation(),"none"===e.proposedAction)return void(e.dropAction="none");const o=this.editor.getOffsetAt(s);this.model.sharedModel.updateSource(o,o,t)}}var M;!function(e){e.findTextData=function(e){const t=e.types().find((e=>0===e.indexOf("text")));if(void 0!==t)return e.getData(t)}}(M||(M={}));class j extends c.Widget{constructor(e){var t;super(),this.model=e.model;const i=new L({factory:e.factory,model:this.model,editorOptions:{...e.editorOptions,config:{...null===(t=e.editorOptions)||void 0===t?void 0:t.config,readOnly:!0}}});this.editor=i.editor,(this.layout=new c.StackedLayout).addWidget(i)}static createCodeViewer(e){const{content:t,mimeType:i,...s}=e,n=new o.Model({mimeType:i});n.sharedModel.setSource(t);const r=new j({...s,model:n});return r.disposed.connect((()=>{n.dispose()})),r}get content(){return this.model.sharedModel.getSource()}get mimeType(){return this.model.mimeType}}}}]);
|
notebook/static/7394.bundle.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_JUPYTERLAB_CORE_OUTPUT=self.webpackChunk_JUPYTERLAB_CORE_OUTPUT||[]).push([[7394],{97394:(t,e,s)=>{s.r(e),s.d(e,{default:()=>L});var r,o,a=s(6312),i=s(11523),n=s(52018),c=s(32895),l=s(20998),h=s(2549),u=s(18395),p=s(31516),d=s(78156),m=s.n(d),S=s(33625),y=s(58114);class g{constructor(){this.commandName="",this.label="",this.keys={},this.source="",this.selector="",this.category="",this.id="",this.numberOfShortcuts=0,this.hasConflict=!1}get(t){return"label"===t?this.label:"selector"===t?this.selector:"category"===t?this.category:"source"===t?this.source:""}}class f extends g{constructor(){super(),this.takenBy=new C}}class C{constructor(t){t?(this.takenBy=t,this.takenByKey="",this.takenByLabel=t.category+": "+t.label,this.id=t.commandName+"_"+t.selector):(this.takenBy=new g,this.takenByKey="",this.takenByLabel="",this.id="")}}class k extends d.Component{constructor(t){super(t),this.handleUpdate=()=>{let t=this.state.keys;t.push(this.state.currentChain),this.setState({keys:t}),this.props.handleUpdate(this.props.shortcut,this.state.keys)},this.handleOverwrite=async()=>{this.props.deleteShortcut(this.state.takenByObject.takenBy,this.state.takenByObject.takenByKey).then(this.handleUpdate())},this.handleReplace=async()=>{let t=this.state.keys;t.push(this.state.currentChain),this.props.toggleInput(),await this.props.deleteShortcut(this.props.shortcut,this.props.shortcutId),this.props.handleUpdate(this.props.shortcut,t)},this.parseChaining=(t,e,s,r,o)=>{let a=y.EN_US.keyForKeydownEvent(t.nativeEvent);const i=["Shift","Control","Alt","Meta","Ctrl","Accel"];if("Backspace"===t.key)s="",r=[],o="",this.setState({value:"",userInput:s,keys:r,currentChain:o});else if("CapsLock"!==t.key){const e=s.substr(s.lastIndexOf(" ")+1,s.length).trim();-1===i.lastIndexOf(e)&&""!=e?(s+=",",r.push(o),o="",t.ctrlKey&&"Control"!=t.key&&(s=(s+" Ctrl").trim(),o=(o+" Ctrl").trim()),t.metaKey&&"Meta"!=t.key&&(s=(s+" Accel").trim(),o=(o+" Accel").trim()),t.altKey&&"Alt"!=t.key&&(s=(s+" Alt").trim(),o=(o+" Alt").trim()),t.shiftKey&&"Shift"!=t.key&&(s=(s+" Shift").trim(),o=(o+" Shift").trim()),-1===i.lastIndexOf(t.key)?(s=(s+" "+a).trim(),o=(o+" "+a).trim()):"Meta"===t.key?(s=(s+" Accel").trim(),o=(o+" Accel").trim()):"Control"===t.key?(s=(s+" Ctrl").trim(),o=(o+" Ctrl").trim()):"Shift"===t.key?(s=(s+" Shift").trim(),o=(o+" Shift").trim()):"Alt"===t.key?(s=(s+" Alt").trim(),o=(o+" Alt").trim()):(s=(s+" "+t.key).trim(),o=(o+" "+t.key).trim())):"Control"===t.key?(s=(s+" Ctrl").trim(),o=(o+" Ctrl").trim()):"Meta"===t.key?(s=(s+" Accel").trim(),o=(o+" Accel").trim()):"Shift"===t.key?(s=(s+" Shift").trim(),o=(o+" Shift").trim()):"Alt"===t.key?(s=(s+" Alt").trim(),o=(o+" Alt").trim()):(s=(s+" "+a).trim(),o=(o+" "+a).trim())}return this.setState({keys:r,currentChain:o}),[s,r,o]},this.checkNonFunctional=t=>{const e=["Ctrl","Alt","Accel","Shift"],s=this.state.currentChain.split(" "),r=s[s.length-1];return this.setState({isFunctional:!(-1!==e.indexOf(r))}),-1!==e.indexOf(r)},this.checkShortcutAvailability=(t,e,s)=>{let r=-1===Object.keys(this.props.keyBindingsUsed).indexOf(e.join(" ")+s+"_"+this.props.shortcut.selector)||""===t,o=new C;if(r){for(let t of e)if(-1!==Object.keys(this.props.keyBindingsUsed).indexOf(t+"_"+this.props.shortcut.selector)&&""!==t){r=!1,o=this.props.keyBindingsUsed[t+"_"+this.props.shortcut.selector];break}r&&-1!==Object.keys(this.props.keyBindingsUsed).indexOf(s+"_"+this.props.shortcut.selector)&&""!==s&&(r=!1,o=this.props.keyBindingsUsed[s+"_"+this.props.shortcut.selector])}else o=this.props.keyBindingsUsed[e.join(" ")+s+"_"+this.props.shortcut.selector];return r||o.takenBy.id===this.props.shortcut.id&&"replace"===this.props.newOrReplace&&(r=!0,o=new C),this.setState({isAvailable:r}),o},this.handleInput=t=>{t.preventDefault(),this.setState({selected:!1});const e=this.parseChaining(t,this.state.value,this.state.userInput,this.state.keys,this.state.currentChain),s=e[0],r=e[1],o=e[2],a=this.props.toSymbols(s);let i=this.checkShortcutAvailability(s,r,o);this.checkConflict(i,r),this.setState({value:a,userInput:s,takenByObject:i,keys:r,currentChain:o},(()=>this.checkNonFunctional(this.state.userInput)))},this.handleBlur=t=>{(null===t.relatedTarget||"no-blur"!==t.relatedTarget.id&&"overwrite"!==t.relatedTarget.id)&&(this.props.toggleInput(),this.setState({value:"",userInput:""}),this.props.clearConflicts())},this.state={value:this.props.placeholder,userInput:"",isAvailable:!0,isFunctional:"replace"===this.props.newOrReplace,takenByObject:new C,keys:new Array,currentChain:"",selected:!0}}checkConflict(t,e){""!==t.id&&t.takenBy.id!==this.props.shortcut.id?this.props.sortConflict(this.props.shortcut,t,t.takenByLabel,""):this.props.clearConflicts()}render(){const t=this.props.translator.load("jupyterlab");let e="jp-Shortcuts-Input";return this.state.isAvailable||(e+=" jp-mod-unavailable-Input"),d.createElement("div",{className:this.props.displayInput?"new"===this.props.newOrReplace?"jp-Shortcuts-InputBox jp-Shortcuts-InputBoxNew":"jp-Shortcuts-InputBox":"jp-mod-hidden",onBlur:t=>this.handleBlur(t)},d.createElement("div",{tabIndex:0,id:"no-blur",className:e,onKeyDown:this.handleInput,ref:t=>t&&t.focus()},d.createElement("p",{className:this.state.selected&&"replace"===this.props.newOrReplace?"jp-Shortcuts-InputText jp-mod-selected-InputText":""===this.state.value?"jp-Shortcuts-InputText jp-mod-waiting-InputText":"jp-Shortcuts-InputText"},""===this.state.value?t.__("press keys"):this.state.value)),d.createElement("button",{className:this.state.isFunctional?this.state.isAvailable?"jp-Shortcuts-Submit":"jp-Shortcuts-Submit jp-mod-conflict-Submit":"jp-Shortcuts-Submit jp-mod-defunc-Submit",id:"no-blur",disabled:!this.state.isAvailable||!this.state.isFunctional,onClick:()=>{"new"===this.props.newOrReplace?(this.handleUpdate(),this.setState({value:"",keys:[],currentChain:""}),this.props.toggleInput()):this.state.selected?(this.props.toggleInput(),this.setState({value:"",userInput:""}),this.props.clearConflicts()):this.handleReplace()}},this.state.isAvailable?d.createElement(n.checkIcon.react,null):d.createElement(n.errorIcon.react,null)),!this.state.isAvailable&&d.createElement("button",{hidden:!0,id:"overwrite",onClick:()=>{this.handleOverwrite(),this.props.clearConflicts(),this.props.toggleInput()}},t.__("Overwrite")))}}!function(t){t[t.Left=0]="Left",t[t.Right=1]="Right"}(r||(r={}));class b extends d.Component{constructor(t){var e;super(t),this.toggleInputNew=()=>{this.setState({displayNewInput:!this.state.displayNewInput})},this.toggleInputReplaceLeft=()=>{this.setState({displayReplaceInputLeft:!this.state.displayReplaceInputLeft})},this.toggleInputReplaceRight=()=>{this.setState({displayReplaceInputRight:!this.state.displayReplaceInputRight})},this.addCommandIfNeeded=(t,e)=>{const s=this.props.shortcut.commandName+"_"+this.props.shortcut.selector;this.props.external.hasCommand(t.commandId+s)||this.props.external.addCommand(t.commandId+s,{label:t.label,caption:t.caption,execute:e})},this.handleRightClick=t=>{this.addCommandIfNeeded(this._commands.shortcutEdit,(()=>this.toggleInputReplaceLeft())),this.addCommandIfNeeded(this._commands.shortcutEditLeft,(()=>this.toggleInputReplaceLeft())),this.addCommandIfNeeded(this._commands.shortcutEditRight,(()=>this.toggleInputReplaceRight())),this.addCommandIfNeeded(this._commands.shortcutAddNew,(()=>this.toggleInputNew())),this.addCommandIfNeeded(this._commands.shortcutAddAnother,(()=>this.toggleInputNew())),this.addCommandIfNeeded(this._commands.shortcutReset,(()=>this.props.resetShortcut(this.props.shortcut)));const e=this.props.shortcut.commandName+"_"+this.props.shortcut.selector;this.setState({numShortcuts:Object.keys(this.props.shortcut.keys).filter((t=>""!==this.props.shortcut.keys[t][0])).length},(()=>{let s=[];s=2==this.state.numShortcuts?s.concat([this._commands.shortcutEditLeft.commandId+e,this._commands.shortcutEditRight.commandId+e]):1==this.state.numShortcuts?s.concat([this._commands.shortcutEdit.commandId+e,this._commands.shortcutAddAnother.commandId+e]):s.concat([this._commands.shortcutAddNew.commandId+e]),"Custom"===this.props.shortcut.source&&(s=s.concat([this._commands.shortcutReset.commandId+e])),this.props.contextMenu(t,s)}))},this.toSymbols=t=>t.split(" ").reduce(((t,e)=>"Ctrl"===e?(t+" ⌃").trim():"Alt"===e?(t+" ⌥").trim():"Shift"===e?(t+" ⇧").trim():"Accel"===e&&u.Platform.IS_MAC?(t+" ⌘").trim():"Accel"===e?(t+" ⌃").trim():(t+" "+e).trim()),""),this._commands={shortcutEditLeft:{commandId:"shortcutui:EditLeft",label:(e=t.external.translator.load("jupyterlab")).__("Edit First"),caption:e.__("Edit existing shortcut")},shortcutEditRight:{commandId:"shortcutui:EditRight",label:e.__("Edit Second"),caption:e.__("Edit existing shortcut")},shortcutEdit:{commandId:"shortcutui:Edit",label:e.__("Edit"),caption:e.__("Edit existing shortcut")},shortcutAddNew:{commandId:"shortcutui:AddNew",label:e.__("Add"),caption:e.__("Add new shortcut")},shortcutAddAnother:{commandId:"shortcutui:AddAnother",label:e.__("Add"),caption:e.__("Add another shortcut")},shortcutReset:{commandId:"shortcutui:Reset",label:e.__("Reset"),caption:e.__("Reset shortcut back to default")}},this.state={displayNewInput:!1,displayReplaceInputLeft:!1,displayReplaceInputRight:!1,numShortcuts:Object.keys(this.props.shortcut.keys).filter((t=>""!==this.props.shortcut.keys[t][0])).length}}getErrorRow(){const t=this.props.external.translator.load("jupyterlab");return d.createElement("div",{className:"jp-Shortcuts-Row"},d.createElement("div",{className:"jp-Shortcuts-ConflictContainer"},d.createElement("div",{className:"jp-Shortcuts-ErrorMessage"},t.__("Shortcut already in use by %1. Overwrite it?",this.props.shortcut.takenBy.takenByLabel)),d.createElement("div",{className:"jp-Shortcuts-ErrorButton"},d.createElement("button",null,t.__("Cancel")),d.createElement("button",{id:"no-blur",onClick:()=>{var t;null===(t=document.getElementById("overwrite"))||void 0===t||t.click()}},t.__("Overwrite")))))}getCategoryCell(){return d.createElement("div",{className:"jp-Shortcuts-Cell"},this.props.shortcut.category)}getLabelCell(){return d.createElement("div",{className:"jp-Shortcuts-Cell"},d.createElement("div",{className:"jp-label"},this.props.shortcut.label))}getResetShortCutLink(){const t=this.props.external.translator.load("jupyterlab");return d.createElement("a",{className:"jp-Shortcuts-Reset",onClick:()=>this.props.resetShortcut(this.props.shortcut)},t.__("Reset"))}getSourceCell(){return d.createElement("div",{className:"jp-Shortcuts-Cell"},d.createElement("div",{className:"jp-Shortcuts-SourceCell"},this.props.shortcut.source),"Custom"===this.props.shortcut.source&&this.getResetShortCutLink())}getOptionalSelectorCell(){return this.props.showSelectors?d.createElement("div",{className:"jp-Shortcuts-Cell"},d.createElement("div",{className:"jp-selector"},this.props.shortcut.selector)):null}getClassNameForShortCuts(t){const e=["jp-Shortcuts-ShortcutCell"];switch(t.length){case 1:e.push("jp-Shortcuts-SingleCell");break;case 0:e.push("jp-Shortcuts-EmptyCell")}return e.join(" ")}getToggleInputReplaceMethod(t){switch(t){case r.Left:return this.toggleInputReplaceLeft;case r.Right:return this.toggleInputReplaceRight}}getDisplayReplaceInput(t){switch(t){case r.Left:return this.state.displayReplaceInputLeft;case r.Right:return this.state.displayReplaceInputRight}}getOrDiplayIfNeeded(t){const e=this.props.external.translator.load("jupyterlab");return d.createElement("div",{className:2==t.length||this.state.displayNewInput?"jp-Shortcuts-OrTwo":"jp-Shortcuts-Or",id:2==t.length?"secondor":this.state.displayReplaceInputLeft?"noor":"or"},e.__("or"))}getShortCutAsInput(t,e){return d.createElement(k,{handleUpdate:this.props.handleUpdate,deleteShortcut:this.props.deleteShortcut,toggleInput:this.getToggleInputReplaceMethod(e),shortcut:this.props.shortcut,shortcutId:t,toSymbols:this.toSymbols,keyBindingsUsed:this.props.keyBindingsUsed,sortConflict:this.props.sortConflict,clearConflicts:this.props.clearConflicts,displayInput:this.getDisplayReplaceInput(e),newOrReplace:"replace",placeholder:this.toSymbols(this.props.shortcut.keys[t].join(", ")),translator:this.props.external.translator})}getShortCutForDisplayOnly(t){return this.props.shortcut.keys[t].map(((e,s)=>d.createElement("div",{className:"jp-Shortcuts-ShortcutKeysContainer",key:s},d.createElement("div",{className:"jp-Shortcuts-ShortcutKeys"},this.toSymbols(e)),s+1<this.props.shortcut.keys[t].length?d.createElement("div",{className:"jp-Shortcuts-Comma"},","):null)))}isLocationBeingEdited(t){return t===r.Left&&this.state.displayReplaceInputLeft||t===r.Right&&this.state.displayReplaceInputRight}getLocationFromIndex(t){return 0===t?r.Left:r.Right}getDivForKey(t,e,s){const o=this.getLocationFromIndex(t);return d.createElement("div",{className:"jp-Shortcuts-ShortcutContainer",key:this.props.shortcut.id+"_"+t,onClick:this.getToggleInputReplaceMethod(o)},this.isLocationBeingEdited(o)?this.getShortCutAsInput(e,o):this.getShortCutForDisplayOnly(e),o===r.Left&&this.getOrDiplayIfNeeded(s))}getAddLink(){const t=this.props.external.translator.load("jupyterlab");return d.createElement("a",{className:this.state.displayNewInput?"":"jp-Shortcuts-Plus",onClick:()=>{this.toggleInputNew(),this.props.clearConflicts()},id:"add-link"},t.__("Add"))}getInputBoxWhenToggled(){return this.state.displayNewInput?d.createElement(k,{handleUpdate:this.props.handleUpdate,deleteShortcut:this.props.deleteShortcut,toggleInput:this.toggleInputNew,shortcut:this.props.shortcut,shortcutId:"",toSymbols:this.toSymbols,keyBindingsUsed:this.props.keyBindingsUsed,sortConflict:this.props.sortConflict,clearConflicts:this.props.clearConflicts,displayInput:this.state.displayNewInput,newOrReplace:"new",placeholder:"",translator:this.props.external.translator}):d.createElement("div",null)}getShortCutsCell(t){return d.createElement("div",{className:"jp-Shortcuts-Cell"},d.createElement("div",{className:this.getClassNameForShortCuts(t)},t.map(((e,s)=>this.getDivForKey(s,e,t))),1===t.length&&!this.state.displayNewInput&&!this.state.displayReplaceInputLeft&&this.getAddLink(),0===t.length&&!this.state.displayNewInput&&this.getAddLink(),this.getInputBoxWhenToggled()))}render(){const t=Object.keys(this.props.shortcut.keys).filter((t=>""!==this.props.shortcut.keys[t][0]));return"error_row"===this.props.shortcut.id?this.getErrorRow():d.createElement("div",{className:"jp-Shortcuts-Row",onContextMenu:t=>{t.persist(),this.handleRightClick(t)}},this.getCategoryCell(),this.getLabelCell(),this.getShortCutsCell(t),this.getSourceCell(),this.getOptionalSelectorCell())}}class I extends d.Component{render(){return d.createElement("div",{className:"jp-Shortcuts-ShortcutListContainer",style:{height:this.props.height-115+"px"},id:"shortcutListContainer"},d.createElement("div",{className:"jp-Shortcuts-ShortcutList"},this.props.shortcuts.map((t=>d.createElement(b,{key:t.commandName+"_"+t.selector,resetShortcut:this.props.resetShortcut,shortcut:t,handleUpdate:this.props.handleUpdate,deleteShortcut:this.props.deleteShortcut,showSelectors:this.props.showSelectors,keyBindingsUsed:this.props.keyBindingsUsed,sortConflict:this.props.sortConflict,clearConflicts:this.props.clearConflicts,contextMenu:this.props.contextMenu,external:this.props.external})))))}}class E extends d.Component{render(){return d.createElement("div",{className:this.props.title.toLowerCase()===this.props.active?"jp-Shortcuts-Header jp-Shortcuts-CurrentHeader":"jp-Shortcuts-Header",onClick:()=>this.props.updateSort(this.props.title.toLowerCase())},this.props.title,d.createElement(n.caretDownEmptyThinIcon.react,{className:"jp-Shortcuts-SortButton jp-ShortcutTitleItem-sortButton"}))}}function _(t){return d.createElement("div",{className:"jp-Shortcuts-Symbols"},d.createElement("table",null,d.createElement("tbody",null,d.createElement("tr",null,d.createElement("td",null,d.createElement("kbd",null,"Cmd")),d.createElement("td",null,"⌘"),d.createElement("td",null,d.createElement("kbd",null,"Ctrl")),d.createElement("td",null,"⌃")),d.createElement("tr",null,d.createElement("td",null,d.createElement("kbd",null,"Alt")),d.createElement("td",null,"⌥"),d.createElement("td",null,d.createElement("kbd",null,"Shift")),d.createElement("td",null,"⇧")))))}function w(t){const e=t.translator.load("jupyterlab");return d.createElement("div",{className:"jp-Shortcuts-AdvancedOptions"},d.createElement("a",{className:"jp-Shortcuts-AdvancedOptionsLink",onClick:()=>t.toggleSelectors()},t.showSelectors?e.__("Hide Selectors"):e.__("Show Selectors")),d.createElement("a",{className:"jp-Shortcuts-AdvancedOptionsLink",onClick:()=>t.resetShortcuts()},e.__("Reset All")))}!function(t){t.showSelectors="shortcutui:showSelectors",t.resetAll="shortcutui:resetAll"}(o||(o={}));class v extends d.Component{constructor(t){super(t),this.addMenuCommands(),this.menu=this.props.external.createMenu(),this.menu.addItem({command:o.showSelectors}),this.menu.addItem({command:o.resetAll})}addMenuCommands(){const t=this.props.external.translator.load("jupyterlab");this.props.external.hasCommand(o.showSelectors)||this.props.external.addCommand(o.showSelectors,{label:t.__("Toggle Selectors"),caption:t.__("Toggle command selectors"),execute:()=>{this.props.toggleSelectors()}}),this.props.external.hasCommand(o.resetAll)||this.props.external.addCommand(o.resetAll,{label:t.__("Reset All"),caption:t.__("Reset all shortcuts"),execute:()=>{this.props.resetShortcuts()}})}getShortCutTitleItem(t){return d.createElement("div",{className:"jp-Shortcuts-Cell"},d.createElement(E,{title:t,updateSort:this.props.updateSort,active:this.props.currentSort}))}render(){const t=this.props.external.translator.load("jupyterlab");return d.createElement("div",{className:"jp-Shortcuts-Top"},d.createElement("div",{className:"jp-Shortcuts-TopNav"},d.createElement(_,null),d.createElement(n.InputGroup,{className:"jp-Shortcuts-Search","aria-label":t.__("Search shortcuts"),type:"text",onChange:t=>this.props.updateSearchQuery(t),placeholder:t.__("Search…"),rightIcon:"ui-components:search"}),d.createElement(w,{toggleSelectors:this.props.toggleSelectors,showSelectors:this.props.showSelectors,resetShortcuts:this.props.resetShortcuts,menu:this.menu,translator:this.props.external.translator})),d.createElement("div",{className:"jp-Shortcuts-HeaderRowContainer"},d.createElement("div",{className:"jp-Shortcuts-HeaderRow"},this.getShortCutTitleItem(t.__("Category")),this.getShortCutTitleItem(t.__("Command")),d.createElement("div",{className:"jp-Shortcuts-Cell"},d.createElement("div",{className:"title-div"},t.__("Shortcut"))),this.getShortCutTitleItem(t.__("Source")),this.props.showSelectors&&this.getShortCutTitleItem(t.__("Selectors")))))}}function j(t,e){const s=t.category.toLowerCase(),r=`${s} ${t.label.toLowerCase()}`;let o=1/0,a=null;const i=/\b\w/g;for(;;){const t=i.exec(r);if(!t)break;const s=S.StringExt.matchSumOfDeltas(r,e,t.index);if(!s)break;s&&s.score<=o&&(o=s.score,a=s.indices)}if(!a||o===1/0)return null;const n=s.length+1,c=S.ArrayExt.lowerBound(a,n,((t,e)=>t-e)),l=a.slice(0,c),h=a.slice(c);for(let t=0,e=h.length;t<e;++t)h[t]-=n;return 0===l.length?{matchType:0,categoryIndices:null,labelIndices:h,score:o,item:t}:0===h.length?{matchType:1,categoryIndices:l,labelIndices:null,score:o,item:t}:{matchType:2,categoryIndices:l,labelIndices:h,score:o,item:t}}class x extends d.Component{constructor(t){super(t),this.updateSearchQuery=t=>{this.setState({searchQuery:t.target.value},(()=>this.setState({filteredShortcutList:this._searchFilterShortcuts(this.state.shortcutList)},(()=>{this.sortShortcuts()}))))},this.resetShortcuts=async()=>{const t=await this.props.external.getAllShortCutSettings();for(const e of Object.keys(t.user))await this.props.external.removeShortCut(e);await this._refreshShortcutList()},this.handleUpdate=async(t,e)=>{const s=await this.props.external.getAllShortCutSettings(),r=s.user.shortcuts,o=[];let a=!1;for(let s of r)s.command===t.commandName&&s.selector===t.selector?(o.push({command:s.command,selector:s.selector,keys:e}),a=!0):o.push(s);a||o.push({command:t.commandName,selector:t.selector,keys:e}),await s.set("shortcuts",o),await this._refreshShortcutList()},this.deleteShortcut=async(t,e)=>{await this.handleUpdate(t,[""]),await this._refreshShortcutList()},this.resetShortcut=async t=>{const e=await this.props.external.getAllShortCutSettings(),s=e.user.shortcuts,r=[];for(let e of s)e.command===t.commandName&&e.selector===t.selector||r.push(e);await e.set("shortcuts",r),await this._refreshShortcutList()},this.toggleSelectors=()=>{this.setState({showSelectors:!this.state.showSelectors})},this.updateSort=t=>{t!==this.state.currentSort&&this.setState({currentSort:t},this.sortShortcuts)},this.sortConflict=(t,e)=>{const s=this.state.filteredShortcutList;if(0===s.filter((t=>"error_row"===t.id)).length){const r=new f;r.takenBy=e,r.id="error_row",s.splice(s.indexOf(t)+1,0,r),r.hasConflict=!0,this.setState({filteredShortcutList:s})}},this.clearConflicts=()=>{const t=this.state.filteredShortcutList.filter((t=>"error_row"!==t.id));t.forEach((t=>{t.hasConflict=!1})),this.setState({filteredShortcutList:t})},this.contextMenu=(t,e)=>{t.persist(),this.setState({contextMenu:this.props.external.createMenu()},(()=>{t.preventDefault();for(let t of e)this.state.contextMenu.addItem({command:t});this.state.contextMenu.open(t.clientX,t.clientY)}))},this.state={shortcutList:{},filteredShortcutList:new Array,shortcutsFetched:!1,searchQuery:"",showSelectors:!1,currentSort:"category",keyBindingsUsed:{},contextMenu:this.props.external.createMenu()}}componentDidMount(){this._refreshShortcutList()}async _refreshShortcutList(){const t=await this.props.external.getAllShortCutSettings(),e=function(t,e){const s=e.composite.shortcuts;let r={};return s.forEach((e=>{let s=e.command+"_"+e.selector;if(-1!==Object.keys(r).indexOf(s)){let t=r[s].numberOfShortcuts;r[s].keys[t]=e.keys,r[s].numberOfShortcuts++}else{let o=new g;o.commandName=e.command;let a=t.getLabel(e.command);const i=e.command.split(":");a||(a=i.length>1?i[1]:"(Command label missing)"),o.label=a,o.category=i[0],o.keys[0]=e.keys,o.selector=e.selector,o.source="Default",o.id=s,o.numberOfShortcuts=1,r[s]=o}})),e.user.shortcuts.forEach((t=>{const e=t.command+"_"+t.selector;r[e]&&(r[e].source="Custom")})),r}(this.props.external,t);this.setState({shortcutList:e,filteredShortcutList:this._searchFilterShortcuts(e),shortcutsFetched:!0},(()=>{let t=function(t){let e={};return Object.keys(t).forEach((s=>{Object.keys(t[s].keys).forEach((r=>{const o=new C(t[s]);o.takenByKey=r,e[t[s].keys[r].join(" ")+"_"+t[s].selector]=o}))})),e}(e);this.setState({keyBindingsUsed:t}),this.sortShortcuts()}))}_searchFilterShortcuts(t){return function(t,e){e=e.replace(/\s+/g,"").toLowerCase();let s=[],r=Object.keys(t);for(let o=0,a=r.length;o<a;++o){let a=t[r[o]];if(!e){s.push({matchType:3,categoryIndices:null,labelIndices:null,score:0,item:a});continue}let i=j(a,e);i&&s.push(i)}return s}(t,this.state.searchQuery).map((t=>t.item))}sortShortcuts(){const t=this.state.filteredShortcutList;let e=this.state.currentSort;"command"===e&&(e="label"),""!==e&&t.sort(((t,s)=>{const r=t.get(e),o=s.get(e);return r<o?-1:r>o?1:t.label<s.label?-1:t.label>s.label?1:0})),this.setState({filteredShortcutList:t})}render(){return this.state.shortcutsFetched?d.createElement("div",{className:"jp-Shortcuts-ShortcutUI",id:"jp-shortcutui"},d.createElement(v,{updateSearchQuery:this.updateSearchQuery,resetShortcuts:this.resetShortcuts,toggleSelectors:this.toggleSelectors,showSelectors:this.state.showSelectors,updateSort:this.updateSort,currentSort:this.state.currentSort,width:this.props.width,external:this.props.external}),d.createElement(I,{shortcuts:this.state.filteredShortcutList,resetShortcut:this.resetShortcut,handleUpdate:this.handleUpdate,deleteShortcut:this.deleteShortcut,showSelectors:this.state.showSelectors,keyBindingsUsed:this.state.keyBindingsUsed,sortConflict:this.sortConflict,clearConflicts:this.clearConflicts,height:this.props.height,contextMenu:this.contextMenu,external:this.props.external})):null}}const N="@jupyterlab/shortcuts-extension:shortcuts";function R(t,e,s){const{commands:r}=e;return{translator:s,getAllShortCutSettings:()=>t.load(N,!0),removeShortCut:e=>t.remove(N,e),createMenu:()=>new p.Menu({commands:r}),hasCommand:t=>r.hasCommand(t),addCommand:(t,e)=>r.addCommand(t,e),getLabel:t=>r.label(t)}}const A={id:N,description:"Adds the keyboard shortcuts editor.",requires:[a.ISettingRegistry],optional:[i.ITranslator,n.IFormRendererRegistry],activate:async(t,e,s,r)=>{const o=null!=s?s:i.nullTranslator,n=o.load("jupyterlab"),{commands:h}=t;let p,d,S={};if(r){const s={fieldRenderer:s=>(t=>m().createElement(x,{external:t.external,height:1e3,width:1e3}))({external:R(e,t,o),...s})};r.addRenderer(`${A.id}.shortcuts`,s)}function y(s){const r=t.commands.listCommands().join("\n");d||(d=l.JSONExt.deepCopy(s.properties.shortcuts.default)),S={},s.properties.shortcuts.default=Object.keys(e.plugins).map((t=>{const s=e.plugins[t].schema["jupyter.lab.shortcuts"]||[];return S[t]=s,s})).concat([d]).reduce(((t,e)=>u.Platform.IS_MAC?t.concat(e):t.concat(e.filter((t=>!t.keys.some((t=>{const{cmd:e}=c.CommandRegistry.parseKeystroke(t);return e})))))),[]).sort(((t,e)=>t.command.localeCompare(e.command))),s.properties.shortcuts.description=n.__('Note: To disable a system default shortcut,\ncopy it to User Preferences and add the\n"disabled" key, for example:\n{\n "command": "application:activate-next-tab",\n "keys": [\n "Ctrl Shift ]"\n ],\n "selector": "body",\n "disabled": true\n}\n\nList of commands followed by keyboard shortcuts:\n%1\n\nList of keyboard shortcuts:',r)}e.pluginChanged.connect((async(t,s)=>{if(s!==A.id){const t=S[s],r=e.plugins[s].schema["jupyter.lab.shortcuts"]||[];void 0!==t&&l.JSONExt.deepEqual(t,r)||(p=null,e.plugins[A.id].schema.properties.shortcuts.default=d,await e.load(A.id,!0))}})),e.transform(A.id,{compose:t=>{var e,s,r,o;p||(p=l.JSONExt.deepCopy(t.schema),y(p));const i=null!==(r=null===(s=null===(e=p.properties)||void 0===e?void 0:e.shortcuts)||void 0===s?void 0:s.default)&&void 0!==r?r:[],n={shortcuts:null!==(o=t.data.user.shortcuts)&&void 0!==o?o:[]},c={shortcuts:a.SettingRegistry.reconcileShortcuts(i,n.shortcuts)};return t.data={composite:c,user:n},t},fetch:t=>(p||(p=l.JSONExt.deepCopy(t.schema),y(p)),{data:t.data,id:t.id,raw:t.raw,schema:p,version:t.version})});try{p=null;const t=await e.load(A.id);O.loadShortcuts(h,t.composite),t.changed.connect((()=>{O.loadShortcuts(h,t.composite)}))}catch(t){console.error(`Loading ${A.id} failed.`,t)}},autoStart:!0},L=A;var O;!function(t){let e;t.loadShortcuts=function(t,s){var r;const o=null!==(r=null==s?void 0:s.shortcuts)&&void 0!==r?r:[];e&&e.dispose(),e=o.reduce(((e,s)=>{const r=function(t){if(!t||"object"!=typeof t)return;const{isArray:e}=Array;return"command"in t&&"keys"in t&&"selector"in t&&e(t.keys)?t:void 0}(s);return r&&e.add(t.addKeyBinding(r)),e}),new h.DisposableSet)}}(O||(O={}))}}]);
|
|
1
|
+
"use strict";(self.webpackChunk_JUPYTERLAB_CORE_OUTPUT=self.webpackChunk_JUPYTERLAB_CORE_OUTPUT||[]).push([[7394],{97394:(t,e,s)=>{s.r(e),s.d(e,{default:()=>L});var r,o,a=s(36768),i=s(71677),n=s(68239),c=s(32895),l=s(20998),h=s(2549),u=s(18395),p=s(31516),d=s(78156),m=s.n(d),S=s(33625),y=s(80554);class g{constructor(){this.commandName="",this.label="",this.keys={},this.source="",this.selector="",this.category="",this.id="",this.numberOfShortcuts=0,this.hasConflict=!1}get(t){return"label"===t?this.label:"selector"===t?this.selector:"category"===t?this.category:"source"===t?this.source:""}}class f extends g{constructor(){super(),this.takenBy=new C}}class C{constructor(t){t?(this.takenBy=t,this.takenByKey="",this.takenByLabel=t.category+": "+t.label,this.id=t.commandName+"_"+t.selector):(this.takenBy=new g,this.takenByKey="",this.takenByLabel="",this.id="")}}class k extends d.Component{constructor(t){super(t),this.handleUpdate=()=>{let t=this.state.keys;t.push(this.state.currentChain),this.setState({keys:t}),this.props.handleUpdate(this.props.shortcut,this.state.keys)},this.handleOverwrite=async()=>{this.props.deleteShortcut(this.state.takenByObject.takenBy,this.state.takenByObject.takenByKey).then(this.handleUpdate())},this.handleReplace=async()=>{let t=this.state.keys;t.push(this.state.currentChain),this.props.toggleInput(),await this.props.deleteShortcut(this.props.shortcut,this.props.shortcutId),this.props.handleUpdate(this.props.shortcut,t)},this.parseChaining=(t,e,s,r,o)=>{let a=y.EN_US.keyForKeydownEvent(t.nativeEvent);const i=["Shift","Control","Alt","Meta","Ctrl","Accel"];if("Backspace"===t.key)s="",r=[],o="",this.setState({value:"",userInput:s,keys:r,currentChain:o});else if("CapsLock"!==t.key){const e=s.substr(s.lastIndexOf(" ")+1,s.length).trim();-1===i.lastIndexOf(e)&&""!=e?(s+=",",r.push(o),o="",t.ctrlKey&&"Control"!=t.key&&(s=(s+" Ctrl").trim(),o=(o+" Ctrl").trim()),t.metaKey&&"Meta"!=t.key&&(s=(s+" Accel").trim(),o=(o+" Accel").trim()),t.altKey&&"Alt"!=t.key&&(s=(s+" Alt").trim(),o=(o+" Alt").trim()),t.shiftKey&&"Shift"!=t.key&&(s=(s+" Shift").trim(),o=(o+" Shift").trim()),-1===i.lastIndexOf(t.key)?(s=(s+" "+a).trim(),o=(o+" "+a).trim()):"Meta"===t.key?(s=(s+" Accel").trim(),o=(o+" Accel").trim()):"Control"===t.key?(s=(s+" Ctrl").trim(),o=(o+" Ctrl").trim()):"Shift"===t.key?(s=(s+" Shift").trim(),o=(o+" Shift").trim()):"Alt"===t.key?(s=(s+" Alt").trim(),o=(o+" Alt").trim()):(s=(s+" "+t.key).trim(),o=(o+" "+t.key).trim())):"Control"===t.key?(s=(s+" Ctrl").trim(),o=(o+" Ctrl").trim()):"Meta"===t.key?(s=(s+" Accel").trim(),o=(o+" Accel").trim()):"Shift"===t.key?(s=(s+" Shift").trim(),o=(o+" Shift").trim()):"Alt"===t.key?(s=(s+" Alt").trim(),o=(o+" Alt").trim()):(s=(s+" "+a).trim(),o=(o+" "+a).trim())}return this.setState({keys:r,currentChain:o}),[s,r,o]},this.checkNonFunctional=t=>{const e=["Ctrl","Alt","Accel","Shift"],s=this.state.currentChain.split(" "),r=s[s.length-1];return this.setState({isFunctional:!(-1!==e.indexOf(r))}),-1!==e.indexOf(r)},this.checkShortcutAvailability=(t,e,s)=>{let r=-1===Object.keys(this.props.keyBindingsUsed).indexOf(e.join(" ")+s+"_"+this.props.shortcut.selector)||""===t,o=new C;if(r){for(let t of e)if(-1!==Object.keys(this.props.keyBindingsUsed).indexOf(t+"_"+this.props.shortcut.selector)&&""!==t){r=!1,o=this.props.keyBindingsUsed[t+"_"+this.props.shortcut.selector];break}r&&-1!==Object.keys(this.props.keyBindingsUsed).indexOf(s+"_"+this.props.shortcut.selector)&&""!==s&&(r=!1,o=this.props.keyBindingsUsed[s+"_"+this.props.shortcut.selector])}else o=this.props.keyBindingsUsed[e.join(" ")+s+"_"+this.props.shortcut.selector];return r||o.takenBy.id===this.props.shortcut.id&&"replace"===this.props.newOrReplace&&(r=!0,o=new C),this.setState({isAvailable:r}),o},this.handleInput=t=>{t.preventDefault(),this.setState({selected:!1});const e=this.parseChaining(t,this.state.value,this.state.userInput,this.state.keys,this.state.currentChain),s=e[0],r=e[1],o=e[2],a=this.props.toSymbols(s);let i=this.checkShortcutAvailability(s,r,o);this.checkConflict(i,r),this.setState({value:a,userInput:s,takenByObject:i,keys:r,currentChain:o},(()=>this.checkNonFunctional(this.state.userInput)))},this.handleBlur=t=>{(null===t.relatedTarget||"no-blur"!==t.relatedTarget.id&&"overwrite"!==t.relatedTarget.id)&&(this.props.toggleInput(),this.setState({value:"",userInput:""}),this.props.clearConflicts())},this.state={value:this.props.placeholder,userInput:"",isAvailable:!0,isFunctional:"replace"===this.props.newOrReplace,takenByObject:new C,keys:new Array,currentChain:"",selected:!0}}checkConflict(t,e){""!==t.id&&t.takenBy.id!==this.props.shortcut.id?this.props.sortConflict(this.props.shortcut,t,t.takenByLabel,""):this.props.clearConflicts()}render(){const t=this.props.translator.load("jupyterlab");let e="jp-Shortcuts-Input";return this.state.isAvailable||(e+=" jp-mod-unavailable-Input"),d.createElement("div",{className:this.props.displayInput?"new"===this.props.newOrReplace?"jp-Shortcuts-InputBox jp-Shortcuts-InputBoxNew":"jp-Shortcuts-InputBox":"jp-mod-hidden",onBlur:t=>this.handleBlur(t)},d.createElement("div",{tabIndex:0,id:"no-blur",className:e,onKeyDown:this.handleInput,ref:t=>t&&t.focus()},d.createElement("p",{className:this.state.selected&&"replace"===this.props.newOrReplace?"jp-Shortcuts-InputText jp-mod-selected-InputText":""===this.state.value?"jp-Shortcuts-InputText jp-mod-waiting-InputText":"jp-Shortcuts-InputText"},""===this.state.value?t.__("press keys"):this.state.value)),d.createElement("button",{className:this.state.isFunctional?this.state.isAvailable?"jp-Shortcuts-Submit":"jp-Shortcuts-Submit jp-mod-conflict-Submit":"jp-Shortcuts-Submit jp-mod-defunc-Submit",id:"no-blur",disabled:!this.state.isAvailable||!this.state.isFunctional,onClick:()=>{"new"===this.props.newOrReplace?(this.handleUpdate(),this.setState({value:"",keys:[],currentChain:""}),this.props.toggleInput()):this.state.selected?(this.props.toggleInput(),this.setState({value:"",userInput:""}),this.props.clearConflicts()):this.handleReplace()}},this.state.isAvailable?d.createElement(n.checkIcon.react,null):d.createElement(n.errorIcon.react,null)),!this.state.isAvailable&&d.createElement("button",{hidden:!0,id:"overwrite",onClick:()=>{this.handleOverwrite(),this.props.clearConflicts(),this.props.toggleInput()}},t.__("Overwrite")))}}!function(t){t[t.Left=0]="Left",t[t.Right=1]="Right"}(r||(r={}));class b extends d.Component{constructor(t){var e;super(t),this.toggleInputNew=()=>{this.setState({displayNewInput:!this.state.displayNewInput})},this.toggleInputReplaceLeft=()=>{this.setState({displayReplaceInputLeft:!this.state.displayReplaceInputLeft})},this.toggleInputReplaceRight=()=>{this.setState({displayReplaceInputRight:!this.state.displayReplaceInputRight})},this.addCommandIfNeeded=(t,e)=>{const s=this.props.shortcut.commandName+"_"+this.props.shortcut.selector;this.props.external.hasCommand(t.commandId+s)||this.props.external.addCommand(t.commandId+s,{label:t.label,caption:t.caption,execute:e})},this.handleRightClick=t=>{this.addCommandIfNeeded(this._commands.shortcutEdit,(()=>this.toggleInputReplaceLeft())),this.addCommandIfNeeded(this._commands.shortcutEditLeft,(()=>this.toggleInputReplaceLeft())),this.addCommandIfNeeded(this._commands.shortcutEditRight,(()=>this.toggleInputReplaceRight())),this.addCommandIfNeeded(this._commands.shortcutAddNew,(()=>this.toggleInputNew())),this.addCommandIfNeeded(this._commands.shortcutAddAnother,(()=>this.toggleInputNew())),this.addCommandIfNeeded(this._commands.shortcutReset,(()=>this.props.resetShortcut(this.props.shortcut)));const e=this.props.shortcut.commandName+"_"+this.props.shortcut.selector;this.setState({numShortcuts:Object.keys(this.props.shortcut.keys).filter((t=>""!==this.props.shortcut.keys[t][0])).length},(()=>{let s=[];s=2==this.state.numShortcuts?s.concat([this._commands.shortcutEditLeft.commandId+e,this._commands.shortcutEditRight.commandId+e]):1==this.state.numShortcuts?s.concat([this._commands.shortcutEdit.commandId+e,this._commands.shortcutAddAnother.commandId+e]):s.concat([this._commands.shortcutAddNew.commandId+e]),"Custom"===this.props.shortcut.source&&(s=s.concat([this._commands.shortcutReset.commandId+e])),this.props.contextMenu(t,s)}))},this.toSymbols=t=>t.split(" ").reduce(((t,e)=>"Ctrl"===e?(t+" ⌃").trim():"Alt"===e?(t+" ⌥").trim():"Shift"===e?(t+" ⇧").trim():"Accel"===e&&u.Platform.IS_MAC?(t+" ⌘").trim():"Accel"===e?(t+" ⌃").trim():(t+" "+e).trim()),""),this._commands={shortcutEditLeft:{commandId:"shortcutui:EditLeft",label:(e=t.external.translator.load("jupyterlab")).__("Edit First"),caption:e.__("Edit existing shortcut")},shortcutEditRight:{commandId:"shortcutui:EditRight",label:e.__("Edit Second"),caption:e.__("Edit existing shortcut")},shortcutEdit:{commandId:"shortcutui:Edit",label:e.__("Edit"),caption:e.__("Edit existing shortcut")},shortcutAddNew:{commandId:"shortcutui:AddNew",label:e.__("Add"),caption:e.__("Add new shortcut")},shortcutAddAnother:{commandId:"shortcutui:AddAnother",label:e.__("Add"),caption:e.__("Add another shortcut")},shortcutReset:{commandId:"shortcutui:Reset",label:e.__("Reset"),caption:e.__("Reset shortcut back to default")}},this.state={displayNewInput:!1,displayReplaceInputLeft:!1,displayReplaceInputRight:!1,numShortcuts:Object.keys(this.props.shortcut.keys).filter((t=>""!==this.props.shortcut.keys[t][0])).length}}getErrorRow(){const t=this.props.external.translator.load("jupyterlab");return d.createElement("div",{className:"jp-Shortcuts-Row"},d.createElement("div",{className:"jp-Shortcuts-ConflictContainer"},d.createElement("div",{className:"jp-Shortcuts-ErrorMessage"},t.__("Shortcut already in use by %1. Overwrite it?",this.props.shortcut.takenBy.takenByLabel)),d.createElement("div",{className:"jp-Shortcuts-ErrorButton"},d.createElement("button",null,t.__("Cancel")),d.createElement("button",{id:"no-blur",onClick:()=>{var t;null===(t=document.getElementById("overwrite"))||void 0===t||t.click()}},t.__("Overwrite")))))}getCategoryCell(){return d.createElement("div",{className:"jp-Shortcuts-Cell"},this.props.shortcut.category)}getLabelCell(){return d.createElement("div",{className:"jp-Shortcuts-Cell"},d.createElement("div",{className:"jp-label"},this.props.shortcut.label))}getResetShortCutLink(){const t=this.props.external.translator.load("jupyterlab");return d.createElement("a",{className:"jp-Shortcuts-Reset",onClick:()=>this.props.resetShortcut(this.props.shortcut)},t.__("Reset"))}getSourceCell(){return d.createElement("div",{className:"jp-Shortcuts-Cell"},d.createElement("div",{className:"jp-Shortcuts-SourceCell"},this.props.shortcut.source),"Custom"===this.props.shortcut.source&&this.getResetShortCutLink())}getOptionalSelectorCell(){return this.props.showSelectors?d.createElement("div",{className:"jp-Shortcuts-Cell"},d.createElement("div",{className:"jp-selector"},this.props.shortcut.selector)):null}getClassNameForShortCuts(t){const e=["jp-Shortcuts-ShortcutCell"];switch(t.length){case 1:e.push("jp-Shortcuts-SingleCell");break;case 0:e.push("jp-Shortcuts-EmptyCell")}return e.join(" ")}getToggleInputReplaceMethod(t){switch(t){case r.Left:return this.toggleInputReplaceLeft;case r.Right:return this.toggleInputReplaceRight}}getDisplayReplaceInput(t){switch(t){case r.Left:return this.state.displayReplaceInputLeft;case r.Right:return this.state.displayReplaceInputRight}}getOrDiplayIfNeeded(t){const e=this.props.external.translator.load("jupyterlab");return d.createElement("div",{className:2==t.length||this.state.displayNewInput?"jp-Shortcuts-OrTwo":"jp-Shortcuts-Or",id:2==t.length?"secondor":this.state.displayReplaceInputLeft?"noor":"or"},e.__("or"))}getShortCutAsInput(t,e){return d.createElement(k,{handleUpdate:this.props.handleUpdate,deleteShortcut:this.props.deleteShortcut,toggleInput:this.getToggleInputReplaceMethod(e),shortcut:this.props.shortcut,shortcutId:t,toSymbols:this.toSymbols,keyBindingsUsed:this.props.keyBindingsUsed,sortConflict:this.props.sortConflict,clearConflicts:this.props.clearConflicts,displayInput:this.getDisplayReplaceInput(e),newOrReplace:"replace",placeholder:this.toSymbols(this.props.shortcut.keys[t].join(", ")),translator:this.props.external.translator})}getShortCutForDisplayOnly(t){return this.props.shortcut.keys[t].map(((e,s)=>d.createElement("div",{className:"jp-Shortcuts-ShortcutKeysContainer",key:s},d.createElement("div",{className:"jp-Shortcuts-ShortcutKeys"},this.toSymbols(e)),s+1<this.props.shortcut.keys[t].length?d.createElement("div",{className:"jp-Shortcuts-Comma"},","):null)))}isLocationBeingEdited(t){return t===r.Left&&this.state.displayReplaceInputLeft||t===r.Right&&this.state.displayReplaceInputRight}getLocationFromIndex(t){return 0===t?r.Left:r.Right}getDivForKey(t,e,s){const o=this.getLocationFromIndex(t);return d.createElement("div",{className:"jp-Shortcuts-ShortcutContainer",key:this.props.shortcut.id+"_"+t,onClick:this.getToggleInputReplaceMethod(o)},this.isLocationBeingEdited(o)?this.getShortCutAsInput(e,o):this.getShortCutForDisplayOnly(e),o===r.Left&&this.getOrDiplayIfNeeded(s))}getAddLink(){const t=this.props.external.translator.load("jupyterlab");return d.createElement("a",{className:this.state.displayNewInput?"":"jp-Shortcuts-Plus",onClick:()=>{this.toggleInputNew(),this.props.clearConflicts()},id:"add-link"},t.__("Add"))}getInputBoxWhenToggled(){return this.state.displayNewInput?d.createElement(k,{handleUpdate:this.props.handleUpdate,deleteShortcut:this.props.deleteShortcut,toggleInput:this.toggleInputNew,shortcut:this.props.shortcut,shortcutId:"",toSymbols:this.toSymbols,keyBindingsUsed:this.props.keyBindingsUsed,sortConflict:this.props.sortConflict,clearConflicts:this.props.clearConflicts,displayInput:this.state.displayNewInput,newOrReplace:"new",placeholder:"",translator:this.props.external.translator}):d.createElement("div",null)}getShortCutsCell(t){return d.createElement("div",{className:"jp-Shortcuts-Cell"},d.createElement("div",{className:this.getClassNameForShortCuts(t)},t.map(((e,s)=>this.getDivForKey(s,e,t))),1===t.length&&!this.state.displayNewInput&&!this.state.displayReplaceInputLeft&&this.getAddLink(),0===t.length&&!this.state.displayNewInput&&this.getAddLink(),this.getInputBoxWhenToggled()))}render(){const t=Object.keys(this.props.shortcut.keys).filter((t=>""!==this.props.shortcut.keys[t][0]));return"error_row"===this.props.shortcut.id?this.getErrorRow():d.createElement("div",{className:"jp-Shortcuts-Row",onContextMenu:t=>{t.persist(),this.handleRightClick(t)}},this.getCategoryCell(),this.getLabelCell(),this.getShortCutsCell(t),this.getSourceCell(),this.getOptionalSelectorCell())}}class I extends d.Component{render(){return d.createElement("div",{className:"jp-Shortcuts-ShortcutListContainer",style:{height:this.props.height-115+"px"},id:"shortcutListContainer"},d.createElement("div",{className:"jp-Shortcuts-ShortcutList"},this.props.shortcuts.map((t=>d.createElement(b,{key:t.commandName+"_"+t.selector,resetShortcut:this.props.resetShortcut,shortcut:t,handleUpdate:this.props.handleUpdate,deleteShortcut:this.props.deleteShortcut,showSelectors:this.props.showSelectors,keyBindingsUsed:this.props.keyBindingsUsed,sortConflict:this.props.sortConflict,clearConflicts:this.props.clearConflicts,contextMenu:this.props.contextMenu,external:this.props.external})))))}}class E extends d.Component{render(){return d.createElement("div",{className:this.props.title.toLowerCase()===this.props.active?"jp-Shortcuts-Header jp-Shortcuts-CurrentHeader":"jp-Shortcuts-Header",onClick:()=>this.props.updateSort(this.props.title.toLowerCase())},this.props.title,d.createElement(n.caretDownEmptyThinIcon.react,{className:"jp-Shortcuts-SortButton jp-ShortcutTitleItem-sortButton"}))}}function _(t){return d.createElement("div",{className:"jp-Shortcuts-Symbols"},d.createElement("table",null,d.createElement("tbody",null,d.createElement("tr",null,d.createElement("td",null,d.createElement("kbd",null,"Cmd")),d.createElement("td",null,"⌘"),d.createElement("td",null,d.createElement("kbd",null,"Ctrl")),d.createElement("td",null,"⌃")),d.createElement("tr",null,d.createElement("td",null,d.createElement("kbd",null,"Alt")),d.createElement("td",null,"⌥"),d.createElement("td",null,d.createElement("kbd",null,"Shift")),d.createElement("td",null,"⇧")))))}function w(t){const e=t.translator.load("jupyterlab");return d.createElement("div",{className:"jp-Shortcuts-AdvancedOptions"},d.createElement("a",{className:"jp-Shortcuts-AdvancedOptionsLink",onClick:()=>t.toggleSelectors()},t.showSelectors?e.__("Hide Selectors"):e.__("Show Selectors")),d.createElement("a",{className:"jp-Shortcuts-AdvancedOptionsLink",onClick:()=>t.resetShortcuts()},e.__("Reset All")))}!function(t){t.showSelectors="shortcutui:showSelectors",t.resetAll="shortcutui:resetAll"}(o||(o={}));class v extends d.Component{constructor(t){super(t),this.addMenuCommands(),this.menu=this.props.external.createMenu(),this.menu.addItem({command:o.showSelectors}),this.menu.addItem({command:o.resetAll})}addMenuCommands(){const t=this.props.external.translator.load("jupyterlab");this.props.external.hasCommand(o.showSelectors)||this.props.external.addCommand(o.showSelectors,{label:t.__("Toggle Selectors"),caption:t.__("Toggle command selectors"),execute:()=>{this.props.toggleSelectors()}}),this.props.external.hasCommand(o.resetAll)||this.props.external.addCommand(o.resetAll,{label:t.__("Reset All"),caption:t.__("Reset all shortcuts"),execute:()=>{this.props.resetShortcuts()}})}getShortCutTitleItem(t){return d.createElement("div",{className:"jp-Shortcuts-Cell"},d.createElement(E,{title:t,updateSort:this.props.updateSort,active:this.props.currentSort}))}render(){const t=this.props.external.translator.load("jupyterlab");return d.createElement("div",{className:"jp-Shortcuts-Top"},d.createElement("div",{className:"jp-Shortcuts-TopNav"},d.createElement(_,null),d.createElement(n.InputGroup,{className:"jp-Shortcuts-Search","aria-label":t.__("Search shortcuts"),type:"text",onChange:t=>this.props.updateSearchQuery(t),placeholder:t.__("Search…"),rightIcon:"ui-components:search"}),d.createElement(w,{toggleSelectors:this.props.toggleSelectors,showSelectors:this.props.showSelectors,resetShortcuts:this.props.resetShortcuts,menu:this.menu,translator:this.props.external.translator})),d.createElement("div",{className:"jp-Shortcuts-HeaderRowContainer"},d.createElement("div",{className:"jp-Shortcuts-HeaderRow"},this.getShortCutTitleItem(t.__("Category")),this.getShortCutTitleItem(t.__("Command")),d.createElement("div",{className:"jp-Shortcuts-Cell"},d.createElement("div",{className:"title-div"},t.__("Shortcut"))),this.getShortCutTitleItem(t.__("Source")),this.props.showSelectors&&this.getShortCutTitleItem(t.__("Selectors")))))}}function j(t,e){const s=t.category.toLowerCase(),r=`${s} ${t.label.toLowerCase()}`;let o=1/0,a=null;const i=/\b\w/g;for(;;){const t=i.exec(r);if(!t)break;const s=S.StringExt.matchSumOfDeltas(r,e,t.index);if(!s)break;s&&s.score<=o&&(o=s.score,a=s.indices)}if(!a||o===1/0)return null;const n=s.length+1,c=S.ArrayExt.lowerBound(a,n,((t,e)=>t-e)),l=a.slice(0,c),h=a.slice(c);for(let t=0,e=h.length;t<e;++t)h[t]-=n;return 0===l.length?{matchType:0,categoryIndices:null,labelIndices:h,score:o,item:t}:0===h.length?{matchType:1,categoryIndices:l,labelIndices:null,score:o,item:t}:{matchType:2,categoryIndices:l,labelIndices:h,score:o,item:t}}class x extends d.Component{constructor(t){super(t),this.updateSearchQuery=t=>{this.setState({searchQuery:t.target.value},(()=>this.setState({filteredShortcutList:this._searchFilterShortcuts(this.state.shortcutList)},(()=>{this.sortShortcuts()}))))},this.resetShortcuts=async()=>{const t=await this.props.external.getAllShortCutSettings();for(const e of Object.keys(t.user))await this.props.external.removeShortCut(e);await this._refreshShortcutList()},this.handleUpdate=async(t,e)=>{const s=await this.props.external.getAllShortCutSettings(),r=s.user.shortcuts,o=[];let a=!1;for(let s of r)s.command===t.commandName&&s.selector===t.selector?(o.push({command:s.command,selector:s.selector,keys:e}),a=!0):o.push(s);a||o.push({command:t.commandName,selector:t.selector,keys:e}),await s.set("shortcuts",o),await this._refreshShortcutList()},this.deleteShortcut=async(t,e)=>{await this.handleUpdate(t,[""]),await this._refreshShortcutList()},this.resetShortcut=async t=>{const e=await this.props.external.getAllShortCutSettings(),s=e.user.shortcuts,r=[];for(let e of s)e.command===t.commandName&&e.selector===t.selector||r.push(e);await e.set("shortcuts",r),await this._refreshShortcutList()},this.toggleSelectors=()=>{this.setState({showSelectors:!this.state.showSelectors})},this.updateSort=t=>{t!==this.state.currentSort&&this.setState({currentSort:t},this.sortShortcuts)},this.sortConflict=(t,e)=>{const s=this.state.filteredShortcutList;if(0===s.filter((t=>"error_row"===t.id)).length){const r=new f;r.takenBy=e,r.id="error_row",s.splice(s.indexOf(t)+1,0,r),r.hasConflict=!0,this.setState({filteredShortcutList:s})}},this.clearConflicts=()=>{const t=this.state.filteredShortcutList.filter((t=>"error_row"!==t.id));t.forEach((t=>{t.hasConflict=!1})),this.setState({filteredShortcutList:t})},this.contextMenu=(t,e)=>{t.persist(),this.setState({contextMenu:this.props.external.createMenu()},(()=>{t.preventDefault();for(let t of e)this.state.contextMenu.addItem({command:t});this.state.contextMenu.open(t.clientX,t.clientY)}))},this.state={shortcutList:{},filteredShortcutList:new Array,shortcutsFetched:!1,searchQuery:"",showSelectors:!1,currentSort:"category",keyBindingsUsed:{},contextMenu:this.props.external.createMenu()}}componentDidMount(){this._refreshShortcutList()}async _refreshShortcutList(){const t=await this.props.external.getAllShortCutSettings(),e=function(t,e){const s=e.composite.shortcuts;let r={};return s.forEach((e=>{let s=e.command+"_"+e.selector;if(-1!==Object.keys(r).indexOf(s)){let t=r[s].numberOfShortcuts;r[s].keys[t]=e.keys,r[s].numberOfShortcuts++}else{let o=new g;o.commandName=e.command;let a=t.getLabel(e.command);const i=e.command.split(":");a||(a=i.length>1?i[1]:"(Command label missing)"),o.label=a,o.category=i[0],o.keys[0]=e.keys,o.selector=e.selector,o.source="Default",o.id=s,o.numberOfShortcuts=1,r[s]=o}})),e.user.shortcuts.forEach((t=>{const e=t.command+"_"+t.selector;r[e]&&(r[e].source="Custom")})),r}(this.props.external,t);this.setState({shortcutList:e,filteredShortcutList:this._searchFilterShortcuts(e),shortcutsFetched:!0},(()=>{let t=function(t){let e={};return Object.keys(t).forEach((s=>{Object.keys(t[s].keys).forEach((r=>{const o=new C(t[s]);o.takenByKey=r,e[t[s].keys[r].join(" ")+"_"+t[s].selector]=o}))})),e}(e);this.setState({keyBindingsUsed:t}),this.sortShortcuts()}))}_searchFilterShortcuts(t){return function(t,e){e=e.replace(/\s+/g,"").toLowerCase();let s=[],r=Object.keys(t);for(let o=0,a=r.length;o<a;++o){let a=t[r[o]];if(!e){s.push({matchType:3,categoryIndices:null,labelIndices:null,score:0,item:a});continue}let i=j(a,e);i&&s.push(i)}return s}(t,this.state.searchQuery).map((t=>t.item))}sortShortcuts(){const t=this.state.filteredShortcutList;let e=this.state.currentSort;"command"===e&&(e="label"),""!==e&&t.sort(((t,s)=>{const r=t.get(e),o=s.get(e);return r<o?-1:r>o?1:t.label<s.label?-1:t.label>s.label?1:0})),this.setState({filteredShortcutList:t})}render(){return this.state.shortcutsFetched?d.createElement("div",{className:"jp-Shortcuts-ShortcutUI",id:"jp-shortcutui"},d.createElement(v,{updateSearchQuery:this.updateSearchQuery,resetShortcuts:this.resetShortcuts,toggleSelectors:this.toggleSelectors,showSelectors:this.state.showSelectors,updateSort:this.updateSort,currentSort:this.state.currentSort,width:this.props.width,external:this.props.external}),d.createElement(I,{shortcuts:this.state.filteredShortcutList,resetShortcut:this.resetShortcut,handleUpdate:this.handleUpdate,deleteShortcut:this.deleteShortcut,showSelectors:this.state.showSelectors,keyBindingsUsed:this.state.keyBindingsUsed,sortConflict:this.sortConflict,clearConflicts:this.clearConflicts,height:this.props.height,contextMenu:this.contextMenu,external:this.props.external})):null}}const N="@jupyterlab/shortcuts-extension:shortcuts";function R(t,e,s){const{commands:r}=e;return{translator:s,getAllShortCutSettings:()=>t.load(N,!0),removeShortCut:e=>t.remove(N,e),createMenu:()=>new p.Menu({commands:r}),hasCommand:t=>r.hasCommand(t),addCommand:(t,e)=>r.addCommand(t,e),getLabel:t=>r.label(t)}}const A={id:N,description:"Adds the keyboard shortcuts editor.",requires:[a.ISettingRegistry],optional:[i.ITranslator,n.IFormRendererRegistry],activate:async(t,e,s,r)=>{const o=null!=s?s:i.nullTranslator,n=o.load("jupyterlab"),{commands:h}=t;let p,d,S={};if(r){const s={fieldRenderer:s=>(t=>m().createElement(x,{external:t.external,height:1e3,width:1e3}))({external:R(e,t,o),...s})};r.addRenderer(`${A.id}.shortcuts`,s)}function y(s){const r=t.commands.listCommands().join("\n");d||(d=l.JSONExt.deepCopy(s.properties.shortcuts.default)),S={},s.properties.shortcuts.default=Object.keys(e.plugins).map((t=>{const s=e.plugins[t].schema["jupyter.lab.shortcuts"]||[];return S[t]=s,s})).concat([d]).reduce(((t,e)=>u.Platform.IS_MAC?t.concat(e):t.concat(e.filter((t=>!t.keys.some((t=>{const{cmd:e}=c.CommandRegistry.parseKeystroke(t);return e})))))),[]).sort(((t,e)=>t.command.localeCompare(e.command))),s.properties.shortcuts.description=n.__('Note: To disable a system default shortcut,\ncopy it to User Preferences and add the\n"disabled" key, for example:\n{\n "command": "application:activate-next-tab",\n "keys": [\n "Ctrl Shift ]"\n ],\n "selector": "body",\n "disabled": true\n}\n\nList of commands followed by keyboard shortcuts:\n%1\n\nList of keyboard shortcuts:',r)}e.pluginChanged.connect((async(t,s)=>{if(s!==A.id){const t=S[s],r=e.plugins[s].schema["jupyter.lab.shortcuts"]||[];void 0!==t&&l.JSONExt.deepEqual(t,r)||(p=null,e.plugins[A.id].schema.properties.shortcuts.default=d,await e.load(A.id,!0))}})),e.transform(A.id,{compose:t=>{var e,s,r,o;p||(p=l.JSONExt.deepCopy(t.schema),y(p));const i=null!==(r=null===(s=null===(e=p.properties)||void 0===e?void 0:e.shortcuts)||void 0===s?void 0:s.default)&&void 0!==r?r:[],n={shortcuts:null!==(o=t.data.user.shortcuts)&&void 0!==o?o:[]},c={shortcuts:a.SettingRegistry.reconcileShortcuts(i,n.shortcuts)};return t.data={composite:c,user:n},t},fetch:t=>(p||(p=l.JSONExt.deepCopy(t.schema),y(p)),{data:t.data,id:t.id,raw:t.raw,schema:p,version:t.version})});try{p=null;const t=await e.load(A.id);O.loadShortcuts(h,t.composite),t.changed.connect((()=>{O.loadShortcuts(h,t.composite)}))}catch(t){console.error(`Loading ${A.id} failed.`,t)}},autoStart:!0},L=A;var O;!function(t){let e;t.loadShortcuts=function(t,s){var r;const o=null!==(r=null==s?void 0:s.shortcuts)&&void 0!==r?r:[];e&&e.dispose(),e=o.reduce(((e,s)=>{const r=function(t){if(!t||"object"!=typeof t)return;const{isArray:e}=Array;return"command"in t&&"keys"in t&&"selector"in t&&e(t.keys)?t:void 0}(s);return r&&e.add(t.addKeyBinding(r)),e}),new h.DisposableSet)}}(O||(O={}))}}]);
|
notebook/static/7603.bundle.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_JUPYTERLAB_CORE_OUTPUT=self.webpackChunk_JUPYTERLAB_CORE_OUTPUT||[]).push([[7603],{97603:(e,t,n)=>{n.r(t),n.d(t,{Commands:()=>S,default:()=>R,tabSpaceStatus:()=>L});var o=n(49880),r=n(57797),a=n(2749),i=n(37682),d=n(65538),c=n(1879),l=n(11404),s=n(97655),u=n(69759),m=n(87098),g=n(94358),f=n(34127),p=n(6312),v=n(22629),h=n(547),C=n(11523),b=n(52018),y=n(33625),w=n(83861),_=n(35260),x=n(74787);const k="notebook:toggle-autoclosing-brackets",T="console:toggle-autoclosing-brackets";var I;!function(e){e.createNew="fileeditor:create-new",e.createNewMarkdown="fileeditor:create-new-markdown-file",e.changeFontSize="fileeditor:change-font-size",e.lineNumbers="fileeditor:toggle-line-numbers",e.currentLineNumbers="fileeditor:toggle-current-line-numbers",e.lineWrap="fileeditor:toggle-line-wrap",e.currentLineWrap="fileeditor:toggle-current-line-wrap",e.changeTabs="fileeditor:change-tabs",e.matchBrackets="fileeditor:toggle-match-brackets",e.currentMatchBrackets="fileeditor:toggle-current-match-brackets",e.autoClosingBrackets="fileeditor:toggle-autoclosing-brackets",e.autoClosingBracketsUniversal="fileeditor:toggle-autoclosing-brackets-universal",e.createConsole="fileeditor:create-console",e.replaceSelection="fileeditor:replace-selection",e.restartConsole="fileeditor:restart-console",e.runCode="fileeditor:run-code",e.runAllCode="fileeditor:run-all",e.markdownPreview="fileeditor:markdown-preview",e.undo="fileeditor:undo",e.redo="fileeditor:redo",e.cut="fileeditor:cut",e.copy="fileeditor:copy",e.paste="fileeditor:paste",e.selectAll="fileeditor:select-all",e.invokeCompleter="completer:invoke-file",e.selectCompleter="completer:select-file",e.openCodeViewer="code-viewer:open",e.changeTheme="fileeditor:change-theme",e.changeLanguage="fileeditor:change-language",e.find="fileeditor:find",e.goToLine="fileeditor:go-to-line"}(I||(I={}));const E="Editor";var S;!function(e){let t={},n=!0;function o(e){e.editor.setOptions({...t,scrollPastEnd:n})}function i(e){const t=e.getSelection(),{start:n,end:o}=t;return n.column!==o.column||n.line!==o.line}function d(e){const t=e.getSelection(),n=e.getOffsetAt(t.start),o=e.getOffsetAt(t.end);return e.model.sharedModel.getSource().substring(n,o)}async function c(e,t,n="txt"){const o=await e.execute("docmanager:new-untitled",{path:t,type:"file",ext:n});if(null!=o){const t=await e.execute("docmanager:open",{path:o.path,factory:E});return t.isUntitled=!0,t}}function l(e,t){e.add({command:I.createNew,category:t.__("Other"),rank:1})}function s(e,t){e.add({command:I.createNewMarkdown,category:t.__("Other"),rank:2})}function u(e,t){const n=t.__("Text Editor"),o=I.changeTabs;e.addItem({command:o,args:{size:4},category:n});for(const t of[1,2,4,8]){const r={size:t};e.addItem({command:o,args:r,category:n})}}function m(e,t){const n=t.__("Text Editor");e.addItem({command:I.createNew,args:{isPalette:!0},category:n})}function g(e,t){const n=t.__("Text Editor");e.addItem({command:I.createNewMarkdown,args:{isPalette:!0},category:n})}function f(e,t){const n=t.__("Text Editor"),o=I.changeFontSize;let r={delta:1};e.addItem({command:o,args:r,category:n}),r={delta:-1},e.addItem({command:o,args:r,category:n})}function p(e,t,n){const o=e=>n()&&e.context&&!!t.find((t=>{var n;return(null===(n=t.sessionContext.session)||void 0===n?void 0:n.path)===e.context.path}));e.runMenu.codeRunners.restart.add({id:I.restartConsole,isEnabled:o}),e.runMenu.codeRunners.run.add({id:I.runCode,isEnabled:o}),e.runMenu.codeRunners.runAll.add({id:I.runAllCode,isEnabled:o})}e.updateSettings=function(e,o){var r;t=null!==(r=e.get("editorConfig").composite)&&void 0!==r?r:{},n=e.get("scrollPasteEnd").composite,o.notifyCommandChanged(I.lineNumbers),o.notifyCommandChanged(I.currentLineNumbers),o.notifyCommandChanged(I.lineWrap),o.notifyCommandChanged(I.currentLineWrap),o.notifyCommandChanged(I.changeTabs),o.notifyCommandChanged(I.matchBrackets),o.notifyCommandChanged(I.currentMatchBrackets),o.notifyCommandChanged(I.autoClosingBrackets),o.notifyCommandChanged(I.changeLanguage)},e.updateTracker=function(e){e.forEach((e=>{o(e.content)}))},e.updateWidget=o,e.addCommands=function(e,n,o,l,s,u,m,g,f,p,v){e.addCommand(I.changeFontSize,{execute:e=>{var o;const r=Number(e.delta);if(Number.isNaN(r))return void console.error(`${I.changeFontSize}: delta arg must be a number`);const a=window.getComputedStyle(document.documentElement),i=parseInt(a.getPropertyValue("--jp-code-font-size"),10),d=(null!==(o=t.customStyles.fontSize)&&void 0!==o?o:g.baseConfiguration.customStyles.fontSize)||i;return t.fontSize=d+r,n.set(l,"editorConfig",t).catch((e=>{console.error(`Failed to set ${l}: ${e.message}`)}))},label:e=>{const t=Number(e.delta);return Number.isNaN(t)&&console.error(`${I.changeFontSize}: delta arg must be a number`),t>0?e.isMenu?o.__("Increase Text Editor Font Size"):o.__("Increase Font Size"):e.isMenu?o.__("Decrease Text Editor Font Size"):o.__("Decrease Font Size")}}),e.addCommand(I.lineNumbers,{execute:async()=>{var e;t.lineNumbers=!(null!==(e=t.lineNumbers)&&void 0!==e?e:g.baseConfiguration.lineNumbers);try{return await n.set(l,"editorConfig",t)}catch(e){console.error(`Failed to set ${l}: ${e.message}`)}},isEnabled:s,isToggled:()=>{var e;return null!==(e=t.lineNumbers)&&void 0!==e?e:g.baseConfiguration.lineNumbers},label:o.__("Show Line Numbers")}),e.addCommand(I.currentLineNumbers,{label:o.__("Show Line Numbers"),caption:o.__("Show the line numbers for the current file."),execute:()=>{const e=u.currentWidget;if(!e)return;const t=!e.content.editor.getOption("lineNumbers");e.content.editor.setOption("lineNumbers",t)},isEnabled:s,isToggled:()=>{var e;const t=u.currentWidget;return null!==(e=null==t?void 0:t.content.editor.getOption("lineNumbers"))&&void 0!==e&&e}}),e.addCommand(I.lineWrap,{execute:async e=>{var o;t.lineWrap=null!==(o=e.mode)&&void 0!==o&&o;try{return await n.set(l,"editorConfig",t)}catch(e){console.error(`Failed to set ${l}: ${e.message}`)}},isEnabled:s,isToggled:e=>{var n,o;return(null!==(n=e.mode)&&void 0!==n&&n)===(null!==(o=t.lineWrap)&&void 0!==o?o:g.baseConfiguration.lineWrap)},label:o.__("Word Wrap")}),e.addCommand(I.currentLineWrap,{label:o.__("Wrap Words"),caption:o.__("Wrap words for the current file."),execute:()=>{const e=u.currentWidget;if(!e)return;const t=e.content.editor.getOption("lineWrap");e.content.editor.setOption("lineWrap",!t)},isEnabled:s,isToggled:()=>{var e;const t=u.currentWidget;return null!==(e=null==t?void 0:t.content.editor.getOption("lineWrap"))&&void 0!==e&&e}}),e.addCommand(I.changeTabs,{label:e=>{var t;return e.size?o._p("v4","Spaces: %1",null!==(t=e.size)&&void 0!==t?t:""):o.__("Indent with Tab")},execute:async e=>{var o;t.indentUnit=void 0!==e.size?(null!==(o=e.size)&&void 0!==o?o:"4").toString():"Tab";try{return await n.set(l,"editorConfig",t)}catch(e){console.error(`Failed to set ${l}: ${e.message}`)}},isToggled:e=>{var n;const o=null!==(n=t.indentUnit)&&void 0!==n?n:g.baseConfiguration.indentUnit;return e.size?e.size===o:"Tab"==o}}),e.addCommand(I.matchBrackets,{execute:async()=>{var e;t.matchBrackets=!(null!==(e=t.matchBrackets)&&void 0!==e?e:g.baseConfiguration.matchBrackets);try{return await n.set(l,"editorConfig",t)}catch(e){console.error(`Failed to set ${l}: ${e.message}`)}},label:o.__("Match Brackets"),isEnabled:s,isToggled:()=>{var e;return null!==(e=t.matchBrackets)&&void 0!==e?e:g.baseConfiguration.matchBrackets}}),e.addCommand(I.currentMatchBrackets,{label:o.__("Match Brackets"),caption:o.__("Change match brackets for the current file."),execute:()=>{const e=u.currentWidget;if(!e)return;const t=!e.content.editor.getOption("matchBrackets");e.content.editor.setOption("matchBrackets",t)},isEnabled:s,isToggled:()=>{var e;const t=u.currentWidget;return null!==(e=null==t?void 0:t.content.editor.getOption("matchBrackets"))&&void 0!==e&&e}}),e.addCommand(I.autoClosingBrackets,{execute:async e=>{var o,r;t.autoClosingBrackets=!!(null!==(o=e.force)&&void 0!==o?o:!(null!==(r=t.autoClosingBrackets)&&void 0!==r?r:g.baseConfiguration.autoClosingBrackets));try{return await n.set(l,"editorConfig",t)}catch(e){console.error(`Failed to set ${l}: ${e.message}`)}},label:o.__("Auto Close Brackets in Text Editor"),isToggled:()=>{var e;return null!==(e=t.autoClosingBrackets)&&void 0!==e?e:g.baseConfiguration.autoClosingBrackets}}),e.addCommand(I.autoClosingBracketsUniversal,{execute:()=>{e.isToggled(I.autoClosingBrackets)||e.isToggled(k)||e.isToggled(T)?(e.execute(I.autoClosingBrackets,{force:!1}),e.execute(k,{force:!1}),e.execute(T,{force:!1})):(e.execute(I.autoClosingBrackets,{force:!0}),e.execute(k,{force:!0}),e.execute(T,{force:!0}))},label:o.__("Auto Close Brackets"),isToggled:()=>e.isToggled(I.autoClosingBrackets)||e.isToggled(k)||e.isToggled(T)}),e.addCommand(I.changeTheme,{label:e=>{var n,r,a,i;return null!==(i=null!==(a=null!==(r=null!==(n=e.displayName)&&void 0!==n?n:e.theme)&&void 0!==r?r:t.theme)&&void 0!==a?a:g.baseConfiguration.theme)&&void 0!==i?i:o.__("Editor Theme")},execute:async e=>{var o;t.theme=null!==(o=e.theme)&&void 0!==o?o:t.theme;try{return await n.set(l,"editorConfig",t)}catch(e){console.error(`Failed to set theme - ${e.message}`)}},isToggled:e=>{var n;return e.theme===(null!==(n=t.theme)&&void 0!==n?n:g.baseConfiguration.theme)}}),e.addCommand(I.find,{label:o.__("Find…"),execute:()=>{const e=u.currentWidget;e&&e.content.editor.execCommand(_.findNext)},isEnabled:s}),e.addCommand(I.goToLine,{label:o.__("Go to Line…"),execute:e=>{const t=u.currentWidget;if(!t)return;const n=t.content.editor,o=e.line,r=e.column;void 0!==o||void 0!==r?n.setCursorPosition({line:(null!=o?o:1)-1,column:(null!=r?r:1)-1}):n.execCommand(_.gotoLine)},isEnabled:s}),e.addCommand(I.changeLanguage,{label:e=>{var t,n;return null!==(n=null!==(t=e.displayName)&&void 0!==t?t:e.name)&&void 0!==n?n:o.__("Change editor language.")},execute:e=>{var t;const n=e.name,o=u.currentWidget;if(n&&o){const e=f.findByName(n);e&&(Array.isArray(e.mime)?o.content.model.mimeType=null!==(t=e.mime[0])&&void 0!==t?t:a.IEditorMimeTypeService.defaultMimeType:o.content.model.mimeType=e.mime)}},isEnabled:s,isToggled:e=>{const t=u.currentWidget;if(!t)return!1;const n=t.content.model.mimeType,o=f.findByMIME(n),r=o&&o.name;return e.name===r}}),e.addCommand(I.replaceSelection,{execute:e=>{var t,n;const o=e.text||"",r=u.currentWidget;r&&(null===(n=(t=r.content.editor).replaceSelection)||void 0===n||n.call(t,o))},isEnabled:s,label:o.__("Replace Selection in Editor")}),e.addCommand(I.createConsole,{execute:t=>{const n=u.currentWidget;if(n)return function(e,t){return async function(n,o){var r,a,i;const d=o||{},c=await e.execute("console:create",{activate:d.activate,name:null===(r=n.context.contentsModel)||void 0===r?void 0:r.name,path:n.context.path,preferredLanguage:n.context.model.defaultKernelLanguage||(null!==(i=null===(a=t.findByFileName(n.context.path))||void 0===a?void 0:a.name)&&void 0!==i?i:""),ref:n.id,insertMode:"split-bottom"});n.context.pathChanged.connect(((e,t)=>{var o;c.session.setPath(t),c.session.setName(null===(o=n.context.contentsModel)||void 0===o?void 0:o.name)}))}}(e,f)(n,t)},isEnabled:s,icon:b.consoleIcon,label:o.__("Create Console for Editor")}),e.addCommand(I.restartConsole,{execute:async()=>{var e;const t=null===(e=u.currentWidget)||void 0===e?void 0:e.content;if(!t||null===p)return;const n=p.find((e=>{var n;return(null===(n=e.sessionContext.session)||void 0===n?void 0:n.path)===t.context.path}));return n?v.restart(n.sessionContext):void 0},label:o.__("Restart Kernel"),isEnabled:()=>null!==p&&s()}),e.addCommand(I.runCode,{execute:()=>{var t;const n=null===(t=u.currentWidget)||void 0===t?void 0:t.content;if(!n)return;let o="";const r=n.editor,a=n.context.path,i=x.PathExt.extname(a),d=r.getSelection(),{start:c,end:l}=d;let s=c.column!==l.column||c.line!==l.line;if(s){const e=r.getOffsetAt(d.start),t=r.getOffsetAt(d.end);o=r.model.sharedModel.getSource().substring(e,t)}else if(x.MarkdownCodeBlocks.isMarkdown(i)){const e=r.model.sharedModel.getSource(),t=x.MarkdownCodeBlocks.findMarkdownCodeBlocks(e);for(const e of t)if(e.startLine<=c.line&&c.line<=e.endLine){o=e.code,s=!0;break}}if(!s){o=r.getLine(d.start.line);const e=r.getCursorPosition();if(e.line+1===r.lineCount){const e=r.model.sharedModel.getSource();r.model.sharedModel.setSource(e+"\n")}r.setCursorPosition({line:e.line+1,column:e.column})}return o?e.execute("console:inject",{activate:!1,code:o,path:a}):Promise.resolve(void 0)},isEnabled:s,label:o.__("Run Selected Code")}),e.addCommand(I.runAllCode,{execute:()=>{var t;const n=null===(t=u.currentWidget)||void 0===t?void 0:t.content;if(!n)return;let o="";const r=n.editor.model.sharedModel.getSource(),a=n.context.path,i=x.PathExt.extname(a);if(x.MarkdownCodeBlocks.isMarkdown(i)){const e=x.MarkdownCodeBlocks.findMarkdownCodeBlocks(r);for(const t of e)o+=t.code}else o=r;return o?e.execute("console:inject",{activate:!1,code:o,path:a}):Promise.resolve(void 0)},isEnabled:s,label:o.__("Run All Code")}),e.addCommand(I.markdownPreview,{execute:()=>{const t=u.currentWidget;if(!t)return;const n=t.context.path;return e.execute("markdownviewer:open",{path:n,options:{mode:"split-right"}})},isVisible:()=>{const e=u.currentWidget;return e&&".md"===x.PathExt.extname(e.context.path)||!1},icon:b.markdownIcon,label:o.__("Show Markdown Preview")}),e.addCommand(I.createNew,{label:e=>{var t,n;return e.isPalette?null!==(t=e.paletteLabel)&&void 0!==t?t:o.__("New Text File"):null!==(n=e.launcherLabel)&&void 0!==n?n:o.__("Text File")},caption:e=>{var t;return null!==(t=e.caption)&&void 0!==t?t:o.__("Create a new text file")},icon:e=>{var t;return e.isPalette?void 0:b.LabIcon.resolve({icon:null!==(t=e.iconName)&&void 0!==t?t:b.textEditorIcon})},execute:t=>{var n;const o=t.cwd||m.model.path;return c(e,o,null!==(n=t.fileExt)&&void 0!==n?n:"txt")}}),e.addCommand(I.createNewMarkdown,{label:e=>e.isPalette?o.__("New Markdown File"):o.__("Markdown File"),caption:o.__("Create a new markdown file"),icon:e=>e.isPalette?void 0:b.markdownIcon,execute:t=>{const n=t.cwd||m.model.path;return c(e,n,"md")}}),e.addCommand(I.undo,{execute:()=>{var e;const t=null===(e=u.currentWidget)||void 0===e?void 0:e.content;t&&t.editor.undo()},isEnabled:()=>{var e;if(!s())return!1;const t=null===(e=u.currentWidget)||void 0===e?void 0:e.content;return!!t&&t.editor.model.sharedModel.canUndo()},icon:b.undoIcon.bindprops({stylesheet:"menuItem"}),label:o.__("Undo")}),e.addCommand(I.redo,{execute:()=>{var e;const t=null===(e=u.currentWidget)||void 0===e?void 0:e.content;t&&t.editor.redo()},isEnabled:()=>{var e;if(!s())return!1;const t=null===(e=u.currentWidget)||void 0===e?void 0:e.content;return!!t&&t.editor.model.sharedModel.canRedo()},icon:b.redoIcon.bindprops({stylesheet:"menuItem"}),label:o.__("Redo")}),e.addCommand(I.cut,{execute:()=>{var e;const t=null===(e=u.currentWidget)||void 0===e?void 0:e.content;if(!t)return;const n=t.editor,o=d(n);r.Clipboard.copyToSystem(o),n.replaceSelection&&n.replaceSelection("")},isEnabled:()=>{var e;if(!s())return!1;const t=null===(e=u.currentWidget)||void 0===e?void 0:e.content;return!!t&&i(t.editor)},icon:b.cutIcon.bindprops({stylesheet:"menuItem"}),label:o.__("Cut")}),e.addCommand(I.copy,{execute:()=>{var e;const t=null===(e=u.currentWidget)||void 0===e?void 0:e.content;if(!t)return;const n=d(t.editor);r.Clipboard.copyToSystem(n)},isEnabled:()=>{var e;if(!s())return!1;const t=null===(e=u.currentWidget)||void 0===e?void 0:e.content;return!!t&&i(t.editor)},icon:b.copyIcon.bindprops({stylesheet:"menuItem"}),label:o.__("Copy")}),e.addCommand(I.paste,{execute:async()=>{var e;const t=null===(e=u.currentWidget)||void 0===e?void 0:e.content;if(!t)return;const n=t.editor,o=window.navigator.clipboard,r=await o.readText();r&&n.replaceSelection&&n.replaceSelection(r)},isEnabled:()=>{var e;return Boolean(s()&&(null===(e=u.currentWidget)||void 0===e?void 0:e.content))},icon:b.pasteIcon.bindprops({stylesheet:"menuItem"}),label:o.__("Paste")}),e.addCommand(I.selectAll,{execute:()=>{var e;const t=null===(e=u.currentWidget)||void 0===e?void 0:e.content;t&&t.editor.execCommand(w.selectAll)},isEnabled:()=>{var e;return Boolean(s()&&(null===(e=u.currentWidget)||void 0===e?void 0:e.content))},label:o.__("Select All")})},e.addCompleterCommands=function(e,t,n,o){const r=(null!=o?o:C.nullTranslator).load("jupyterlab");e.addCommand(I.invokeCompleter,{label:r.__("Display the completion helper."),execute:()=>{const e=t.currentWidget&&t.currentWidget.id;if(e)return n.invoke(e)}}),e.addCommand(I.selectCompleter,{label:r.__("Select the completion suggestion."),execute:()=>{const e=t.currentWidget&&t.currentWidget.id;if(e)return n.select(e)}}),e.addKeyBinding({command:I.selectCompleter,keys:["Enter"],selector:".jp-FileEditor .jp-mod-completer-active"})},e.addLauncherItems=function(e,t){l(e,t),s(e,t)},e.addCreateNewToLauncher=l,e.addCreateNewMarkdownToLauncher=s,e.addKernelLanguageLauncherItems=function(e,t,n){for(let o of n)e.add({command:I.createNew,category:t.__("Other"),rank:3,args:o})},e.addPaletteItems=function(e,t){u(e,t),m(e,t),g(e,t),f(e,t)},e.addChangeTabsCommandsToPalette=u,e.addCreateNewCommandToPalette=m,e.addCreateNewMarkdownCommandToPalette=g,e.addChangeFontSizeCommandsToPalette=f,e.addKernelLanguagePaletteItems=function(e,t,n){const o=t.__("Text Editor");for(let t of n)e.addItem({command:I.createNew,args:{...t,isPalette:!0},category:o})},e.addMenuItems=function(e,t,n,o){e.editMenu.undoers.redo.add({id:I.redo,isEnabled:o}),e.editMenu.undoers.undo.add({id:I.undo,isEnabled:o}),e.viewMenu.editorViewers.toggleLineNumbers.add({id:I.currentLineNumbers,isEnabled:o}),e.viewMenu.editorViewers.toggleMatchBrackets.add({id:I.currentMatchBrackets,isEnabled:o}),e.viewMenu.editorViewers.toggleWordWrap.add({id:I.currentLineWrap,isEnabled:o}),e.fileMenu.consoleCreators.add({id:I.createConsole,isEnabled:o}),n&&p(e,n,o)},e.addKernelLanguageMenuItems=function(e,t){for(let n of t)e.fileMenu.newMenu.addItem({command:I.createNew,args:n,rank:31})},e.addCodeRunnersToRunMenu=p,e.addOpenCodeViewerCommand=function(e,t,n,o){e.commands.addCommand(I.openCodeViewer,{label:o.__("Open Code Viewer"),execute:i=>(async i=>{var d;const c=t.factoryService.newDocumentEditor;let l=i.mimeType;!l&&i.extension&&(l=t.mimeTypeService.getMimeTypeByFilePath(`temp.${i.extension.replace(/\\.$/,"")}`));const s=a.CodeViewerWidget.createCodeViewer({factory:e=>c(e),content:i.content,mimeType:l});s.title.label=i.label||o.__("Code Viewer"),s.title.caption=s.title.label;const u=(0,y.find)(e.docRegistry.fileTypes(),(e=>!!l&&e.mimeTypes.includes(l)));s.title.icon=null!==(d=null==u?void 0:u.icon)&&void 0!==d?d:b.textEditorIcon,i.widgetId&&(s.id=i.widgetId);const m=new r.MainAreaWidget({content:s});return await n.add(m),e.shell.add(m,"main"),s})(i)})}}(S||(S={}));const M={id:"@jupyterlab/fileeditor-extension:editor-syntax-status",description:"Adds a file editor syntax status widget.",autoStart:!0,requires:[u.IEditorTracker,i.IEditorLanguageRegistry,o.ILabShell,C.ITranslator],optional:[v.IStatusBar],activate:(e,t,n,o,r,a)=>{if(!a)return;const i=new u.EditorSyntaxStatus({commands:e.commands,languages:n,translator:r});o.currentChanged.connect((()=>{const e=o.currentWidget;e&&t.has(e)&&i.model&&(i.model.editor=e.content.editor)})),a.registerStatusItem(M.id,{item:i,align:"left",rank:0,isActive:()=>!!o.currentWidget&&!!t.currentWidget&&o.currentWidget===t.currentWidget})}},W={activate:function(e,t,n,o,a,i,d,c,l,s,m,g,f,p,v,h,b){const y=W.id,w=null!=h?h:C.nullTranslator,_=null!=f?f:new r.SessionContextDialogs({translator:w}),x=w.load("jupyterlab");let k;v&&(k=(0,r.createToolbarFactory)(v,d,E,y,w));const T=new u.FileEditorFactory({editorServices:t,factoryOptions:{name:E,label:x.__("Editor"),fileTypes:["markdown","*"],defaultFor:["markdown","*"],toolbarFactory:k,translator:w}}),{commands:M,restored:L,shell:N}=e,P=new r.WidgetTracker({namespace:"editor"}),B=()=>null!==P.currentWidget&&P.currentWidget===N.currentWidget,F=new Map([["python",[{fileExt:"py",iconName:"ui-components:python",launcherLabel:x.__("Python File"),paletteLabel:x.__("New Python File"),caption:x.__("Create a new Python file")}]],["julia",[{fileExt:"jl",iconName:"ui-components:julia",launcherLabel:x.__("Julia File"),paletteLabel:x.__("New Julia File"),caption:x.__("Create a new Julia file")}]],["R",[{fileExt:"r",iconName:"ui-components:r-kernel",launcherLabel:x.__("R File"),paletteLabel:x.__("New R File"),caption:x.__("Create a new R file")}]]]);if(g&&g.restore(P,{command:"docmanager:open",args:e=>({path:e.context.path,factory:E}),name:e=>e.context.path}),Promise.all([d.load(y),L]).then((([e])=>{var t,n,r;if(m){const e=null===(t=m.viewMenu.items.find((e=>{var t;return"submenu"===e.type&&"jp-mainmenu-view-codemirror-language"===(null===(t=e.submenu)||void 0===t?void 0:t.id)})))||void 0===t?void 0:t.submenu;e&&o.getLanguages().sort(((e,t)=>{const n=e.name,o=t.name;return n.localeCompare(o)})).forEach((t=>{0!==t.name.toLowerCase().indexOf("brainf")&&e.addItem({command:I.changeLanguage,args:{...t}})}));const i=null===(n=m.settingsMenu.items.find((e=>{var t;return"submenu"===e.type&&"jp-mainmenu-settings-codemirror-theme"===(null===(t=e.submenu)||void 0===t?void 0:t.id)})))||void 0===n?void 0:n.submenu;if(i)for(const e of a.themes)i.addItem({command:I.changeTheme,args:{theme:e.name,displayName:null!==(r=e.displayName)&&void 0!==r?r:e.name}});m.editMenu.goToLiners.add({id:I.goToLine,isEnabled:e=>null!==P.currentWidget&&P.has(e)})}S.updateSettings(e,M),S.updateTracker(P),e.changed.connect((()=>{S.updateSettings(e,M),S.updateTracker(P)}))})).catch((e=>{console.error(e.message),S.updateTracker(P)})),b){const e=b.getRenderer("@jupyterlab/codemirror-extension:plugin.defaultConfig");e&&b.addRenderer("@jupyterlab/fileeditor-extension:plugin.editorConfig",e)}T.widgetCreated.connect(((e,t)=>{t.context.pathChanged.connect((()=>{P.save(t)})),P.add(t),S.updateWidget(t.content)})),e.docRegistry.addWidgetFactory(T),P.widgetAdded.connect(((e,t)=>{S.updateWidget(t.content)})),S.addCommands(e.commands,d,x,y,B,P,i,n,o,c,_);const R=new r.WidgetTracker({namespace:"codeviewer"});return g&&g.restore(R,{command:I.openCodeViewer,args:e=>({content:e.content.content,label:e.content.title.label,mimeType:e.content.mimeType,widgetId:e.content.id}),name:e=>e.content.id}),S.addOpenCodeViewerCommand(e,t,R,x),s&&S.addLauncherItems(s,x),l&&S.addPaletteItems(l,x),m&&S.addMenuItems(m,P,c,B),(async()=>{var t,n;const o=e.serviceManager.kernelspecs;await o.ready;let r=new Set;const a=null!==(n=null===(t=o.specs)||void 0===t?void 0:t.kernelspecs)&&void 0!==n?n:{};return Object.keys(a).forEach((e=>{const t=a[e];if(t){const e=F.get(t.language);null==e||e.forEach((e=>r.add(e)))}})),r})().then((e=>{s&&S.addKernelLanguageLauncherItems(s,x,e),l&&S.addKernelLanguagePaletteItems(l,x,e),m&&S.addKernelLanguageMenuItems(m,e)})).catch((e=>{console.error(e.message)})),p&&(p.add(new u.LaTeXTableOfContentsFactory(P)),p.add(new u.MarkdownTableOfContentsFactory(P)),p.add(new u.PythonTableOfContentsFactory(P))),P},id:"@jupyterlab/fileeditor-extension:plugin",description:"Provides the file editor widget tracker.",requires:[a.IEditorServices,i.IEditorExtensionRegistry,i.IEditorLanguageRegistry,i.IEditorThemeRegistry,s.IDefaultFileBrowser,p.ISettingRegistry],optional:[c.IConsoleTracker,r.ICommandPalette,m.ILauncher,f.IMainMenu,o.ILayoutRestorer,r.ISessionContextDialogs,h.ITableOfContentsRegistry,r.IToolbarWidgetRegistry,C.ITranslator,b.IFormRendererRegistry],provides:u.IEditorTracker,autoStart:!0},L={id:"@jupyterlab/fileeditor-extension:tab-space-status",description:"Adds a file editor indentation status widget.",autoStart:!0,requires:[u.IEditorTracker,i.IEditorExtensionRegistry,p.ISettingRegistry,C.ITranslator],optional:[v.IStatusBar],activate:(e,t,n,o,r,a)=>{const i=r.load("jupyterlab");if(!a)return;const d=new b.MenuSvg({commands:e.commands}),c="fileeditor:change-tabs",{shell:l}=e,s={name:i.__("Indent with Tab")};d.addItem({command:c,args:s});for(const e of["1","2","4","8"]){const t={size:e,name:i._p("v4","Spaces: %1",e)};d.addItem({command:c,args:t})}const m=new u.TabSpaceStatus({menu:d,translator:r}),g=e=>{var t,o,r;m.model.indentUnit=null!==(r=null!==(o=null===(t=e.get("editorConfig").composite)||void 0===t?void 0:t.indentUnit)&&void 0!==o?o:n.baseConfiguration.indentUnit)&&void 0!==r?r:null};Promise.all([o.load("@jupyterlab/fileeditor-extension:plugin"),e.restored]).then((([e])=>{g(e),e.changed.connect(g)})),a.registerStatusItem("@jupyterlab/fileeditor-extension:tab-space-status",{item:m,align:"right",rank:1,isActive:()=>!!l.currentWidget&&t.has(l.currentWidget)})}},N={id:"@jupyterlab/fileeditor-extension:cursor-position",description:"Adds a file editor cursor position status widget.",activate:(e,t,n)=>{n.addEditorProvider((e=>Promise.resolve(e&&t.has(e)?e.content.editor:null)))},requires:[u.IEditorTracker,a.IPositionModel],autoStart:!0},P={id:"@jupyterlab/fileeditor-extension:completer",description:"Adds the completer capability to the file editor.",requires:[u.IEditorTracker],optional:[d.ICompletionProviderManager,C.ITranslator,r.ISanitizer],activate:function(e,t,n,o,a){if(!n)return;S.addCompleterCommands(e.commands,t,n,o);const i=e.serviceManager.sessions,d=null!=a?a:new r.Sanitizer,c=new Map,l=async(e,t)=>{const o={editor:t.content.editor,widget:t};await n.updateCompleter(o);const r=(e,o)=>{const r=c.get(t.id),a=(0,y.find)(o,(e=>e.path===t.context.path));if(a){if(r&&r.id===a.id)return;r&&(c.delete(t.id),r.dispose());const e=i.connectTo({model:a}),o={editor:t.content.editor,widget:t,session:e,sanitizer:d};n.updateCompleter(o).catch(console.error),c.set(t.id,e)}else r&&(c.delete(t.id),r.dispose())};r(0,Array.from(i.running())),i.runningChanged.connect(r),t.disposed.connect((()=>{i.runningChanged.disconnect(r);const e=c.get(t.id);e&&(c.delete(t.id),e.dispose())}))};t.widgetAdded.connect(l),n.activeProvidersChanged.connect((()=>{t.forEach((e=>{l(0,e).catch(console.error)}))}))},autoStart:!0},B={id:"@jupyterlab/fileeditor-extension:search",description:"Adds search capability to the file editor.",requires:[l.ISearchProviderRegistry],autoStart:!0,activate:(e,t)=>{t.add("jp-fileeditorSearchProvider",u.FileEditorSearchProvider)}},F={id:"@jupyterlab/fileeditor-extension:language-server",description:"Adds Language Server capability to the file editor.",requires:[u.IEditorTracker,g.ILSPDocumentConnectionManager,g.ILSPFeatureManager,g.ILSPCodeExtractorsManager,g.IWidgetLSPAdapterTracker],activate:function(e,t,n,o,r,a){t.widgetAdded.connect((async(t,i)=>{const d=new u.FileEditorAdapter(i,{connectionManager:n,featureManager:o,foreignCodeExtractorsManager:r,docRegistry:e.docRegistry});a.add(d)}))},autoStart:!0},R=[W,N,P,F,B,M,L]}}]);
|
|
1
|
+
"use strict";(self.webpackChunk_JUPYTERLAB_CORE_OUTPUT=self.webpackChunk_JUPYTERLAB_CORE_OUTPUT||[]).push([[7603],{97603:(e,t,n)=>{n.r(t),n.d(t,{Commands:()=>S,default:()=>R,tabSpaceStatus:()=>L});var o=n(3053),r=n(12982),a=n(31536),i=n(52337),d=n(76867),c=n(46122),l=n(3486),s=n(97713),u=n(89421),m=n(389),g=n(12729),f=n(97104),p=n(36768),v=n(34276),h=n(87749),C=n(71677),b=n(68239),y=n(33625),w=n(83861),_=n(35260),x=n(38639);const k="notebook:toggle-autoclosing-brackets",T="console:toggle-autoclosing-brackets";var I;!function(e){e.createNew="fileeditor:create-new",e.createNewMarkdown="fileeditor:create-new-markdown-file",e.changeFontSize="fileeditor:change-font-size",e.lineNumbers="fileeditor:toggle-line-numbers",e.currentLineNumbers="fileeditor:toggle-current-line-numbers",e.lineWrap="fileeditor:toggle-line-wrap",e.currentLineWrap="fileeditor:toggle-current-line-wrap",e.changeTabs="fileeditor:change-tabs",e.matchBrackets="fileeditor:toggle-match-brackets",e.currentMatchBrackets="fileeditor:toggle-current-match-brackets",e.autoClosingBrackets="fileeditor:toggle-autoclosing-brackets",e.autoClosingBracketsUniversal="fileeditor:toggle-autoclosing-brackets-universal",e.createConsole="fileeditor:create-console",e.replaceSelection="fileeditor:replace-selection",e.restartConsole="fileeditor:restart-console",e.runCode="fileeditor:run-code",e.runAllCode="fileeditor:run-all",e.markdownPreview="fileeditor:markdown-preview",e.undo="fileeditor:undo",e.redo="fileeditor:redo",e.cut="fileeditor:cut",e.copy="fileeditor:copy",e.paste="fileeditor:paste",e.selectAll="fileeditor:select-all",e.invokeCompleter="completer:invoke-file",e.selectCompleter="completer:select-file",e.openCodeViewer="code-viewer:open",e.changeTheme="fileeditor:change-theme",e.changeLanguage="fileeditor:change-language",e.find="fileeditor:find",e.goToLine="fileeditor:go-to-line"}(I||(I={}));const E="Editor";var S;!function(e){let t={},n=!0;function o(e){e.editor.setOptions({...t,scrollPastEnd:n})}function i(e){const t=e.getSelection(),{start:n,end:o}=t;return n.column!==o.column||n.line!==o.line}function d(e){const t=e.getSelection(),n=e.getOffsetAt(t.start),o=e.getOffsetAt(t.end);return e.model.sharedModel.getSource().substring(n,o)}async function c(e,t,n="txt"){const o=await e.execute("docmanager:new-untitled",{path:t,type:"file",ext:n});if(null!=o){const t=await e.execute("docmanager:open",{path:o.path,factory:E});return t.isUntitled=!0,t}}function l(e,t){e.add({command:I.createNew,category:t.__("Other"),rank:1})}function s(e,t){e.add({command:I.createNewMarkdown,category:t.__("Other"),rank:2})}function u(e,t){const n=t.__("Text Editor"),o=I.changeTabs;e.addItem({command:o,args:{size:4},category:n});for(const t of[1,2,4,8]){const r={size:t};e.addItem({command:o,args:r,category:n})}}function m(e,t){const n=t.__("Text Editor");e.addItem({command:I.createNew,args:{isPalette:!0},category:n})}function g(e,t){const n=t.__("Text Editor");e.addItem({command:I.createNewMarkdown,args:{isPalette:!0},category:n})}function f(e,t){const n=t.__("Text Editor"),o=I.changeFontSize;let r={delta:1};e.addItem({command:o,args:r,category:n}),r={delta:-1},e.addItem({command:o,args:r,category:n})}function p(e,t,n){const o=e=>n()&&e.context&&!!t.find((t=>{var n;return(null===(n=t.sessionContext.session)||void 0===n?void 0:n.path)===e.context.path}));e.runMenu.codeRunners.restart.add({id:I.restartConsole,isEnabled:o}),e.runMenu.codeRunners.run.add({id:I.runCode,isEnabled:o}),e.runMenu.codeRunners.runAll.add({id:I.runAllCode,isEnabled:o})}e.updateSettings=function(e,o){var r;t=null!==(r=e.get("editorConfig").composite)&&void 0!==r?r:{},n=e.get("scrollPasteEnd").composite,o.notifyCommandChanged(I.lineNumbers),o.notifyCommandChanged(I.currentLineNumbers),o.notifyCommandChanged(I.lineWrap),o.notifyCommandChanged(I.currentLineWrap),o.notifyCommandChanged(I.changeTabs),o.notifyCommandChanged(I.matchBrackets),o.notifyCommandChanged(I.currentMatchBrackets),o.notifyCommandChanged(I.autoClosingBrackets),o.notifyCommandChanged(I.changeLanguage)},e.updateTracker=function(e){e.forEach((e=>{o(e.content)}))},e.updateWidget=o,e.addCommands=function(e,n,o,l,s,u,m,g,f,p,v){e.addCommand(I.changeFontSize,{execute:e=>{var o;const r=Number(e.delta);if(Number.isNaN(r))return void console.error(`${I.changeFontSize}: delta arg must be a number`);const a=window.getComputedStyle(document.documentElement),i=parseInt(a.getPropertyValue("--jp-code-font-size"),10),d=(null!==(o=t.customStyles.fontSize)&&void 0!==o?o:g.baseConfiguration.customStyles.fontSize)||i;return t.fontSize=d+r,n.set(l,"editorConfig",t).catch((e=>{console.error(`Failed to set ${l}: ${e.message}`)}))},label:e=>{const t=Number(e.delta);return Number.isNaN(t)&&console.error(`${I.changeFontSize}: delta arg must be a number`),t>0?e.isMenu?o.__("Increase Text Editor Font Size"):o.__("Increase Font Size"):e.isMenu?o.__("Decrease Text Editor Font Size"):o.__("Decrease Font Size")}}),e.addCommand(I.lineNumbers,{execute:async()=>{var e;t.lineNumbers=!(null!==(e=t.lineNumbers)&&void 0!==e?e:g.baseConfiguration.lineNumbers);try{return await n.set(l,"editorConfig",t)}catch(e){console.error(`Failed to set ${l}: ${e.message}`)}},isEnabled:s,isToggled:()=>{var e;return null!==(e=t.lineNumbers)&&void 0!==e?e:g.baseConfiguration.lineNumbers},label:o.__("Show Line Numbers")}),e.addCommand(I.currentLineNumbers,{label:o.__("Show Line Numbers"),caption:o.__("Show the line numbers for the current file."),execute:()=>{const e=u.currentWidget;if(!e)return;const t=!e.content.editor.getOption("lineNumbers");e.content.editor.setOption("lineNumbers",t)},isEnabled:s,isToggled:()=>{var e;const t=u.currentWidget;return null!==(e=null==t?void 0:t.content.editor.getOption("lineNumbers"))&&void 0!==e&&e}}),e.addCommand(I.lineWrap,{execute:async e=>{var o;t.lineWrap=null!==(o=e.mode)&&void 0!==o&&o;try{return await n.set(l,"editorConfig",t)}catch(e){console.error(`Failed to set ${l}: ${e.message}`)}},isEnabled:s,isToggled:e=>{var n,o;return(null!==(n=e.mode)&&void 0!==n&&n)===(null!==(o=t.lineWrap)&&void 0!==o?o:g.baseConfiguration.lineWrap)},label:o.__("Word Wrap")}),e.addCommand(I.currentLineWrap,{label:o.__("Wrap Words"),caption:o.__("Wrap words for the current file."),execute:()=>{const e=u.currentWidget;if(!e)return;const t=e.content.editor.getOption("lineWrap");e.content.editor.setOption("lineWrap",!t)},isEnabled:s,isToggled:()=>{var e;const t=u.currentWidget;return null!==(e=null==t?void 0:t.content.editor.getOption("lineWrap"))&&void 0!==e&&e}}),e.addCommand(I.changeTabs,{label:e=>{var t;return e.size?o._p("v4","Spaces: %1",null!==(t=e.size)&&void 0!==t?t:""):o.__("Indent with Tab")},execute:async e=>{var o;t.indentUnit=void 0!==e.size?(null!==(o=e.size)&&void 0!==o?o:"4").toString():"Tab";try{return await n.set(l,"editorConfig",t)}catch(e){console.error(`Failed to set ${l}: ${e.message}`)}},isToggled:e=>{var n;const o=null!==(n=t.indentUnit)&&void 0!==n?n:g.baseConfiguration.indentUnit;return e.size?e.size===o:"Tab"==o}}),e.addCommand(I.matchBrackets,{execute:async()=>{var e;t.matchBrackets=!(null!==(e=t.matchBrackets)&&void 0!==e?e:g.baseConfiguration.matchBrackets);try{return await n.set(l,"editorConfig",t)}catch(e){console.error(`Failed to set ${l}: ${e.message}`)}},label:o.__("Match Brackets"),isEnabled:s,isToggled:()=>{var e;return null!==(e=t.matchBrackets)&&void 0!==e?e:g.baseConfiguration.matchBrackets}}),e.addCommand(I.currentMatchBrackets,{label:o.__("Match Brackets"),caption:o.__("Change match brackets for the current file."),execute:()=>{const e=u.currentWidget;if(!e)return;const t=!e.content.editor.getOption("matchBrackets");e.content.editor.setOption("matchBrackets",t)},isEnabled:s,isToggled:()=>{var e;const t=u.currentWidget;return null!==(e=null==t?void 0:t.content.editor.getOption("matchBrackets"))&&void 0!==e&&e}}),e.addCommand(I.autoClosingBrackets,{execute:async e=>{var o,r;t.autoClosingBrackets=!!(null!==(o=e.force)&&void 0!==o?o:!(null!==(r=t.autoClosingBrackets)&&void 0!==r?r:g.baseConfiguration.autoClosingBrackets));try{return await n.set(l,"editorConfig",t)}catch(e){console.error(`Failed to set ${l}: ${e.message}`)}},label:o.__("Auto Close Brackets in Text Editor"),isToggled:()=>{var e;return null!==(e=t.autoClosingBrackets)&&void 0!==e?e:g.baseConfiguration.autoClosingBrackets}}),e.addCommand(I.autoClosingBracketsUniversal,{execute:()=>{e.isToggled(I.autoClosingBrackets)||e.isToggled(k)||e.isToggled(T)?(e.execute(I.autoClosingBrackets,{force:!1}),e.execute(k,{force:!1}),e.execute(T,{force:!1})):(e.execute(I.autoClosingBrackets,{force:!0}),e.execute(k,{force:!0}),e.execute(T,{force:!0}))},label:o.__("Auto Close Brackets"),isToggled:()=>e.isToggled(I.autoClosingBrackets)||e.isToggled(k)||e.isToggled(T)}),e.addCommand(I.changeTheme,{label:e=>{var n,r,a,i;return null!==(i=null!==(a=null!==(r=null!==(n=e.displayName)&&void 0!==n?n:e.theme)&&void 0!==r?r:t.theme)&&void 0!==a?a:g.baseConfiguration.theme)&&void 0!==i?i:o.__("Editor Theme")},execute:async e=>{var o;t.theme=null!==(o=e.theme)&&void 0!==o?o:t.theme;try{return await n.set(l,"editorConfig",t)}catch(e){console.error(`Failed to set theme - ${e.message}`)}},isToggled:e=>{var n;return e.theme===(null!==(n=t.theme)&&void 0!==n?n:g.baseConfiguration.theme)}}),e.addCommand(I.find,{label:o.__("Find…"),execute:()=>{const e=u.currentWidget;e&&e.content.editor.execCommand(_.findNext)},isEnabled:s}),e.addCommand(I.goToLine,{label:o.__("Go to Line…"),execute:e=>{const t=u.currentWidget;if(!t)return;const n=t.content.editor,o=e.line,r=e.column;void 0!==o||void 0!==r?n.setCursorPosition({line:(null!=o?o:1)-1,column:(null!=r?r:1)-1}):n.execCommand(_.gotoLine)},isEnabled:s}),e.addCommand(I.changeLanguage,{label:e=>{var t,n;return null!==(n=null!==(t=e.displayName)&&void 0!==t?t:e.name)&&void 0!==n?n:o.__("Change editor language.")},execute:e=>{var t;const n=e.name,o=u.currentWidget;if(n&&o){const e=f.findByName(n);e&&(Array.isArray(e.mime)?o.content.model.mimeType=null!==(t=e.mime[0])&&void 0!==t?t:a.IEditorMimeTypeService.defaultMimeType:o.content.model.mimeType=e.mime)}},isEnabled:s,isToggled:e=>{const t=u.currentWidget;if(!t)return!1;const n=t.content.model.mimeType,o=f.findByMIME(n),r=o&&o.name;return e.name===r}}),e.addCommand(I.replaceSelection,{execute:e=>{var t,n;const o=e.text||"",r=u.currentWidget;r&&(null===(n=(t=r.content.editor).replaceSelection)||void 0===n||n.call(t,o))},isEnabled:s,label:o.__("Replace Selection in Editor")}),e.addCommand(I.createConsole,{execute:t=>{const n=u.currentWidget;if(n)return function(e,t){return async function(n,o){var r,a,i;const d=o||{},c=await e.execute("console:create",{activate:d.activate,name:null===(r=n.context.contentsModel)||void 0===r?void 0:r.name,path:n.context.path,preferredLanguage:n.context.model.defaultKernelLanguage||(null!==(i=null===(a=t.findByFileName(n.context.path))||void 0===a?void 0:a.name)&&void 0!==i?i:""),ref:n.id,insertMode:"split-bottom"});n.context.pathChanged.connect(((e,t)=>{var o;c.session.setPath(t),c.session.setName(null===(o=n.context.contentsModel)||void 0===o?void 0:o.name)}))}}(e,f)(n,t)},isEnabled:s,icon:b.consoleIcon,label:o.__("Create Console for Editor")}),e.addCommand(I.restartConsole,{execute:async()=>{var e;const t=null===(e=u.currentWidget)||void 0===e?void 0:e.content;if(!t||null===p)return;const n=p.find((e=>{var n;return(null===(n=e.sessionContext.session)||void 0===n?void 0:n.path)===t.context.path}));return n?v.restart(n.sessionContext):void 0},label:o.__("Restart Kernel"),isEnabled:()=>null!==p&&s()}),e.addCommand(I.runCode,{execute:()=>{var t;const n=null===(t=u.currentWidget)||void 0===t?void 0:t.content;if(!n)return;let o="";const r=n.editor,a=n.context.path,i=x.PathExt.extname(a),d=r.getSelection(),{start:c,end:l}=d;let s=c.column!==l.column||c.line!==l.line;if(s){const e=r.getOffsetAt(d.start),t=r.getOffsetAt(d.end);o=r.model.sharedModel.getSource().substring(e,t)}else if(x.MarkdownCodeBlocks.isMarkdown(i)){const e=r.model.sharedModel.getSource(),t=x.MarkdownCodeBlocks.findMarkdownCodeBlocks(e);for(const e of t)if(e.startLine<=c.line&&c.line<=e.endLine){o=e.code,s=!0;break}}if(!s){o=r.getLine(d.start.line);const e=r.getCursorPosition();if(e.line+1===r.lineCount){const e=r.model.sharedModel.getSource();r.model.sharedModel.setSource(e+"\n")}r.setCursorPosition({line:e.line+1,column:e.column})}return o?e.execute("console:inject",{activate:!1,code:o,path:a}):Promise.resolve(void 0)},isEnabled:s,label:o.__("Run Selected Code")}),e.addCommand(I.runAllCode,{execute:()=>{var t;const n=null===(t=u.currentWidget)||void 0===t?void 0:t.content;if(!n)return;let o="";const r=n.editor.model.sharedModel.getSource(),a=n.context.path,i=x.PathExt.extname(a);if(x.MarkdownCodeBlocks.isMarkdown(i)){const e=x.MarkdownCodeBlocks.findMarkdownCodeBlocks(r);for(const t of e)o+=t.code}else o=r;return o?e.execute("console:inject",{activate:!1,code:o,path:a}):Promise.resolve(void 0)},isEnabled:s,label:o.__("Run All Code")}),e.addCommand(I.markdownPreview,{execute:()=>{const t=u.currentWidget;if(!t)return;const n=t.context.path;return e.execute("markdownviewer:open",{path:n,options:{mode:"split-right"}})},isVisible:()=>{const e=u.currentWidget;return e&&".md"===x.PathExt.extname(e.context.path)||!1},icon:b.markdownIcon,label:o.__("Show Markdown Preview")}),e.addCommand(I.createNew,{label:e=>{var t,n;return e.isPalette?null!==(t=e.paletteLabel)&&void 0!==t?t:o.__("New Text File"):null!==(n=e.launcherLabel)&&void 0!==n?n:o.__("Text File")},caption:e=>{var t;return null!==(t=e.caption)&&void 0!==t?t:o.__("Create a new text file")},icon:e=>{var t;return e.isPalette?void 0:b.LabIcon.resolve({icon:null!==(t=e.iconName)&&void 0!==t?t:b.textEditorIcon})},execute:t=>{var n;const o=t.cwd||m.model.path;return c(e,o,null!==(n=t.fileExt)&&void 0!==n?n:"txt")}}),e.addCommand(I.createNewMarkdown,{label:e=>e.isPalette?o.__("New Markdown File"):o.__("Markdown File"),caption:o.__("Create a new markdown file"),icon:e=>e.isPalette?void 0:b.markdownIcon,execute:t=>{const n=t.cwd||m.model.path;return c(e,n,"md")}}),e.addCommand(I.undo,{execute:()=>{var e;const t=null===(e=u.currentWidget)||void 0===e?void 0:e.content;t&&t.editor.undo()},isEnabled:()=>{var e;if(!s())return!1;const t=null===(e=u.currentWidget)||void 0===e?void 0:e.content;return!!t&&t.editor.model.sharedModel.canUndo()},icon:b.undoIcon.bindprops({stylesheet:"menuItem"}),label:o.__("Undo")}),e.addCommand(I.redo,{execute:()=>{var e;const t=null===(e=u.currentWidget)||void 0===e?void 0:e.content;t&&t.editor.redo()},isEnabled:()=>{var e;if(!s())return!1;const t=null===(e=u.currentWidget)||void 0===e?void 0:e.content;return!!t&&t.editor.model.sharedModel.canRedo()},icon:b.redoIcon.bindprops({stylesheet:"menuItem"}),label:o.__("Redo")}),e.addCommand(I.cut,{execute:()=>{var e;const t=null===(e=u.currentWidget)||void 0===e?void 0:e.content;if(!t)return;const n=t.editor,o=d(n);r.Clipboard.copyToSystem(o),n.replaceSelection&&n.replaceSelection("")},isEnabled:()=>{var e;if(!s())return!1;const t=null===(e=u.currentWidget)||void 0===e?void 0:e.content;return!!t&&i(t.editor)},icon:b.cutIcon.bindprops({stylesheet:"menuItem"}),label:o.__("Cut")}),e.addCommand(I.copy,{execute:()=>{var e;const t=null===(e=u.currentWidget)||void 0===e?void 0:e.content;if(!t)return;const n=d(t.editor);r.Clipboard.copyToSystem(n)},isEnabled:()=>{var e;if(!s())return!1;const t=null===(e=u.currentWidget)||void 0===e?void 0:e.content;return!!t&&i(t.editor)},icon:b.copyIcon.bindprops({stylesheet:"menuItem"}),label:o.__("Copy")}),e.addCommand(I.paste,{execute:async()=>{var e;const t=null===(e=u.currentWidget)||void 0===e?void 0:e.content;if(!t)return;const n=t.editor,o=window.navigator.clipboard,r=await o.readText();r&&n.replaceSelection&&n.replaceSelection(r)},isEnabled:()=>{var e;return Boolean(s()&&(null===(e=u.currentWidget)||void 0===e?void 0:e.content))},icon:b.pasteIcon.bindprops({stylesheet:"menuItem"}),label:o.__("Paste")}),e.addCommand(I.selectAll,{execute:()=>{var e;const t=null===(e=u.currentWidget)||void 0===e?void 0:e.content;t&&t.editor.execCommand(w.selectAll)},isEnabled:()=>{var e;return Boolean(s()&&(null===(e=u.currentWidget)||void 0===e?void 0:e.content))},label:o.__("Select All")})},e.addCompleterCommands=function(e,t,n,o){const r=(null!=o?o:C.nullTranslator).load("jupyterlab");e.addCommand(I.invokeCompleter,{label:r.__("Display the completion helper."),execute:()=>{const e=t.currentWidget&&t.currentWidget.id;if(e)return n.invoke(e)}}),e.addCommand(I.selectCompleter,{label:r.__("Select the completion suggestion."),execute:()=>{const e=t.currentWidget&&t.currentWidget.id;if(e)return n.select(e)}}),e.addKeyBinding({command:I.selectCompleter,keys:["Enter"],selector:".jp-FileEditor .jp-mod-completer-active"})},e.addLauncherItems=function(e,t){l(e,t),s(e,t)},e.addCreateNewToLauncher=l,e.addCreateNewMarkdownToLauncher=s,e.addKernelLanguageLauncherItems=function(e,t,n){for(let o of n)e.add({command:I.createNew,category:t.__("Other"),rank:3,args:o})},e.addPaletteItems=function(e,t){u(e,t),m(e,t),g(e,t),f(e,t)},e.addChangeTabsCommandsToPalette=u,e.addCreateNewCommandToPalette=m,e.addCreateNewMarkdownCommandToPalette=g,e.addChangeFontSizeCommandsToPalette=f,e.addKernelLanguagePaletteItems=function(e,t,n){const o=t.__("Text Editor");for(let t of n)e.addItem({command:I.createNew,args:{...t,isPalette:!0},category:o})},e.addMenuItems=function(e,t,n,o){e.editMenu.undoers.redo.add({id:I.redo,isEnabled:o}),e.editMenu.undoers.undo.add({id:I.undo,isEnabled:o}),e.viewMenu.editorViewers.toggleLineNumbers.add({id:I.currentLineNumbers,isEnabled:o}),e.viewMenu.editorViewers.toggleMatchBrackets.add({id:I.currentMatchBrackets,isEnabled:o}),e.viewMenu.editorViewers.toggleWordWrap.add({id:I.currentLineWrap,isEnabled:o}),e.fileMenu.consoleCreators.add({id:I.createConsole,isEnabled:o}),n&&p(e,n,o)},e.addKernelLanguageMenuItems=function(e,t){for(let n of t)e.fileMenu.newMenu.addItem({command:I.createNew,args:n,rank:31})},e.addCodeRunnersToRunMenu=p,e.addOpenCodeViewerCommand=function(e,t,n,o){e.commands.addCommand(I.openCodeViewer,{label:o.__("Open Code Viewer"),execute:i=>(async i=>{var d;const c=t.factoryService.newDocumentEditor;let l=i.mimeType;!l&&i.extension&&(l=t.mimeTypeService.getMimeTypeByFilePath(`temp.${i.extension.replace(/\\.$/,"")}`));const s=a.CodeViewerWidget.createCodeViewer({factory:e=>c(e),content:i.content,mimeType:l});s.title.label=i.label||o.__("Code Viewer"),s.title.caption=s.title.label;const u=(0,y.find)(e.docRegistry.fileTypes(),(e=>!!l&&e.mimeTypes.includes(l)));s.title.icon=null!==(d=null==u?void 0:u.icon)&&void 0!==d?d:b.textEditorIcon,i.widgetId&&(s.id=i.widgetId);const m=new r.MainAreaWidget({content:s});return await n.add(m),e.shell.add(m,"main"),s})(i)})}}(S||(S={}));const M={id:"@jupyterlab/fileeditor-extension:editor-syntax-status",description:"Adds a file editor syntax status widget.",autoStart:!0,requires:[u.IEditorTracker,i.IEditorLanguageRegistry,o.ILabShell,C.ITranslator],optional:[v.IStatusBar],activate:(e,t,n,o,r,a)=>{if(!a)return;const i=new u.EditorSyntaxStatus({commands:e.commands,languages:n,translator:r});o.currentChanged.connect((()=>{const e=o.currentWidget;e&&t.has(e)&&i.model&&(i.model.editor=e.content.editor)})),a.registerStatusItem(M.id,{item:i,align:"left",rank:0,isActive:()=>!!o.currentWidget&&!!t.currentWidget&&o.currentWidget===t.currentWidget})}},W={activate:function(e,t,n,o,a,i,d,c,l,s,m,g,f,p,v,h,b){const y=W.id,w=null!=h?h:C.nullTranslator,_=null!=f?f:new r.SessionContextDialogs({translator:w}),x=w.load("jupyterlab");let k;v&&(k=(0,r.createToolbarFactory)(v,d,E,y,w));const T=new u.FileEditorFactory({editorServices:t,factoryOptions:{name:E,label:x.__("Editor"),fileTypes:["markdown","*"],defaultFor:["markdown","*"],toolbarFactory:k,translator:w}}),{commands:M,restored:L,shell:N}=e,P=new r.WidgetTracker({namespace:"editor"}),B=()=>null!==P.currentWidget&&P.currentWidget===N.currentWidget,F=new Map([["python",[{fileExt:"py",iconName:"ui-components:python",launcherLabel:x.__("Python File"),paletteLabel:x.__("New Python File"),caption:x.__("Create a new Python file")}]],["julia",[{fileExt:"jl",iconName:"ui-components:julia",launcherLabel:x.__("Julia File"),paletteLabel:x.__("New Julia File"),caption:x.__("Create a new Julia file")}]],["R",[{fileExt:"r",iconName:"ui-components:r-kernel",launcherLabel:x.__("R File"),paletteLabel:x.__("New R File"),caption:x.__("Create a new R file")}]]]);if(g&&g.restore(P,{command:"docmanager:open",args:e=>({path:e.context.path,factory:E}),name:e=>e.context.path}),Promise.all([d.load(y),L]).then((([e])=>{var t,n,r;if(m){const e=null===(t=m.viewMenu.items.find((e=>{var t;return"submenu"===e.type&&"jp-mainmenu-view-codemirror-language"===(null===(t=e.submenu)||void 0===t?void 0:t.id)})))||void 0===t?void 0:t.submenu;e&&o.getLanguages().sort(((e,t)=>{const n=e.name,o=t.name;return n.localeCompare(o)})).forEach((t=>{0!==t.name.toLowerCase().indexOf("brainf")&&e.addItem({command:I.changeLanguage,args:{...t}})}));const i=null===(n=m.settingsMenu.items.find((e=>{var t;return"submenu"===e.type&&"jp-mainmenu-settings-codemirror-theme"===(null===(t=e.submenu)||void 0===t?void 0:t.id)})))||void 0===n?void 0:n.submenu;if(i)for(const e of a.themes)i.addItem({command:I.changeTheme,args:{theme:e.name,displayName:null!==(r=e.displayName)&&void 0!==r?r:e.name}});m.editMenu.goToLiners.add({id:I.goToLine,isEnabled:e=>null!==P.currentWidget&&P.has(e)})}S.updateSettings(e,M),S.updateTracker(P),e.changed.connect((()=>{S.updateSettings(e,M),S.updateTracker(P)}))})).catch((e=>{console.error(e.message),S.updateTracker(P)})),b){const e=b.getRenderer("@jupyterlab/codemirror-extension:plugin.defaultConfig");e&&b.addRenderer("@jupyterlab/fileeditor-extension:plugin.editorConfig",e)}T.widgetCreated.connect(((e,t)=>{t.context.pathChanged.connect((()=>{P.save(t)})),P.add(t),S.updateWidget(t.content)})),e.docRegistry.addWidgetFactory(T),P.widgetAdded.connect(((e,t)=>{S.updateWidget(t.content)})),S.addCommands(e.commands,d,x,y,B,P,i,n,o,c,_);const R=new r.WidgetTracker({namespace:"codeviewer"});return g&&g.restore(R,{command:I.openCodeViewer,args:e=>({content:e.content.content,label:e.content.title.label,mimeType:e.content.mimeType,widgetId:e.content.id}),name:e=>e.content.id}),S.addOpenCodeViewerCommand(e,t,R,x),s&&S.addLauncherItems(s,x),l&&S.addPaletteItems(l,x),m&&S.addMenuItems(m,P,c,B),(async()=>{var t,n;const o=e.serviceManager.kernelspecs;await o.ready;let r=new Set;const a=null!==(n=null===(t=o.specs)||void 0===t?void 0:t.kernelspecs)&&void 0!==n?n:{};return Object.keys(a).forEach((e=>{const t=a[e];if(t){const e=F.get(t.language);null==e||e.forEach((e=>r.add(e)))}})),r})().then((e=>{s&&S.addKernelLanguageLauncherItems(s,x,e),l&&S.addKernelLanguagePaletteItems(l,x,e),m&&S.addKernelLanguageMenuItems(m,e)})).catch((e=>{console.error(e.message)})),p&&(p.add(new u.LaTeXTableOfContentsFactory(P)),p.add(new u.MarkdownTableOfContentsFactory(P)),p.add(new u.PythonTableOfContentsFactory(P))),P},id:"@jupyterlab/fileeditor-extension:plugin",description:"Provides the file editor widget tracker.",requires:[a.IEditorServices,i.IEditorExtensionRegistry,i.IEditorLanguageRegistry,i.IEditorThemeRegistry,s.IDefaultFileBrowser,p.ISettingRegistry],optional:[c.IConsoleTracker,r.ICommandPalette,m.ILauncher,f.IMainMenu,o.ILayoutRestorer,r.ISessionContextDialogs,h.ITableOfContentsRegistry,r.IToolbarWidgetRegistry,C.ITranslator,b.IFormRendererRegistry],provides:u.IEditorTracker,autoStart:!0},L={id:"@jupyterlab/fileeditor-extension:tab-space-status",description:"Adds a file editor indentation status widget.",autoStart:!0,requires:[u.IEditorTracker,i.IEditorExtensionRegistry,p.ISettingRegistry,C.ITranslator],optional:[v.IStatusBar],activate:(e,t,n,o,r,a)=>{const i=r.load("jupyterlab");if(!a)return;const d=new b.MenuSvg({commands:e.commands}),c="fileeditor:change-tabs",{shell:l}=e,s={name:i.__("Indent with Tab")};d.addItem({command:c,args:s});for(const e of["1","2","4","8"]){const t={size:e,name:i._p("v4","Spaces: %1",e)};d.addItem({command:c,args:t})}const m=new u.TabSpaceStatus({menu:d,translator:r}),g=e=>{var t,o,r;m.model.indentUnit=null!==(r=null!==(o=null===(t=e.get("editorConfig").composite)||void 0===t?void 0:t.indentUnit)&&void 0!==o?o:n.baseConfiguration.indentUnit)&&void 0!==r?r:null};Promise.all([o.load("@jupyterlab/fileeditor-extension:plugin"),e.restored]).then((([e])=>{g(e),e.changed.connect(g)})),a.registerStatusItem("@jupyterlab/fileeditor-extension:tab-space-status",{item:m,align:"right",rank:1,isActive:()=>!!l.currentWidget&&t.has(l.currentWidget)})}},N={id:"@jupyterlab/fileeditor-extension:cursor-position",description:"Adds a file editor cursor position status widget.",activate:(e,t,n)=>{n.addEditorProvider((e=>Promise.resolve(e&&t.has(e)?e.content.editor:null)))},requires:[u.IEditorTracker,a.IPositionModel],autoStart:!0},P={id:"@jupyterlab/fileeditor-extension:completer",description:"Adds the completer capability to the file editor.",requires:[u.IEditorTracker],optional:[d.ICompletionProviderManager,C.ITranslator,r.ISanitizer],activate:function(e,t,n,o,a){if(!n)return;S.addCompleterCommands(e.commands,t,n,o);const i=e.serviceManager.sessions,d=null!=a?a:new r.Sanitizer,c=new Map,l=async(e,t)=>{const o={editor:t.content.editor,widget:t};await n.updateCompleter(o);const r=(e,o)=>{const r=c.get(t.id),a=(0,y.find)(o,(e=>e.path===t.context.path));if(a){if(r&&r.id===a.id)return;r&&(c.delete(t.id),r.dispose());const e=i.connectTo({model:a}),o={editor:t.content.editor,widget:t,session:e,sanitizer:d};n.updateCompleter(o).catch(console.error),c.set(t.id,e)}else r&&(c.delete(t.id),r.dispose())};r(0,Array.from(i.running())),i.runningChanged.connect(r),t.disposed.connect((()=>{i.runningChanged.disconnect(r);const e=c.get(t.id);e&&(c.delete(t.id),e.dispose())}))};t.widgetAdded.connect(l),n.activeProvidersChanged.connect((()=>{t.forEach((e=>{l(0,e).catch(console.error)}))}))},autoStart:!0},B={id:"@jupyterlab/fileeditor-extension:search",description:"Adds search capability to the file editor.",requires:[l.ISearchProviderRegistry],autoStart:!0,activate:(e,t)=>{t.add("jp-fileeditorSearchProvider",u.FileEditorSearchProvider)}},F={id:"@jupyterlab/fileeditor-extension:language-server",description:"Adds Language Server capability to the file editor.",requires:[u.IEditorTracker,g.ILSPDocumentConnectionManager,g.ILSPFeatureManager,g.ILSPCodeExtractorsManager,g.IWidgetLSPAdapterTracker],activate:function(e,t,n,o,r,a){t.widgetAdded.connect((async(t,i)=>{const d=new u.FileEditorAdapter(i,{connectionManager:n,featureManager:o,foreignCodeExtractorsManager:r,docRegistry:e.docRegistry});a.add(d)}))},autoStart:!0},R=[W,N,P,F,B,M,L]}}]);
|
notebook/static/7639.bundle.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_JUPYTERLAB_CORE_OUTPUT=self.webpackChunk_JUPYTERLAB_CORE_OUTPUT||[]).push([[7639,3680],{53680:(e,t,s)=>{s.r(t),s.d(t,{GroupItem:()=>r,IStatusBar:()=>f,Popup:()=>h,ProgressBar:()=>l,ProgressCircle:()=>m,StatusBar:()=>v,TextItem:()=>u,showPopup:()=>d});var i=s(78156),a=s.n(i);function r(e){const{spacing:t,children:s,className:a,...r}=e,n=i.Children.count(s);return i.createElement("div",{className:`jp-StatusBar-GroupItem ${a||""}`,...r},i.Children.map(s,((e,s)=>0===s?i.createElement("div",{style:{marginRight:`${t}px`}},e):s===n-1?i.createElement("div",{style:{marginLeft:`${t}px`}},e):i.createElement("div",{style:{margin:`0px ${t}px`}},e))))}var n=s(
|
|
1
|
+
"use strict";(self.webpackChunk_JUPYTERLAB_CORE_OUTPUT=self.webpackChunk_JUPYTERLAB_CORE_OUTPUT||[]).push([[7639,3680],{53680:(e,t,s)=>{s.r(t),s.d(t,{GroupItem:()=>r,IStatusBar:()=>f,Popup:()=>h,ProgressBar:()=>l,ProgressCircle:()=>m,StatusBar:()=>v,TextItem:()=>u,showPopup:()=>d});var i=s(78156),a=s.n(i);function r(e){const{spacing:t,children:s,className:a,...r}=e,n=i.Children.count(s);return i.createElement("div",{className:`jp-StatusBar-GroupItem ${a||""}`,...r},i.Children.map(s,((e,s)=>0===s?i.createElement("div",{style:{marginRight:`${t}px`}},e):s===n-1?i.createElement("div",{style:{marginLeft:`${t}px`}},e):i.createElement("div",{style:{margin:`0px ${t}px`}},e))))}var n=s(68239),o=s(31516);function d(e){const t=new h(e);return e.startHidden||t.launch(),t}class h extends o.Widget{constructor(e){super(),this._body=e.body,this._body.addClass("jp-StatusBar-HoverItem"),this._anchor=e.anchor,this._align=e.align,e.hasDynamicSize&&(this._observer=new ResizeObserver((()=>{this.update()}))),(this.layout=new o.PanelLayout).addWidget(e.body),this._body.node.addEventListener("resize",(()=>{this.update()}))}launch(){this._setGeometry(),o.Widget.attach(this,document.body),this.update(),this._anchor.addClass("jp-mod-clicked"),this._anchor.removeClass("jp-mod-highlight")}onUpdateRequest(e){this._setGeometry(),super.onUpdateRequest(e)}onAfterAttach(e){var t;document.addEventListener("click",this,!1),this.node.addEventListener("keydown",this,!1),window.addEventListener("resize",this,!1),null===(t=this._observer)||void 0===t||t.observe(this._body.node)}onBeforeDetach(e){var t;null===(t=this._observer)||void 0===t||t.disconnect(),document.removeEventListener("click",this,!1),this.node.removeEventListener("keydown",this,!1),window.removeEventListener("resize",this,!1)}onResize(){this.update()}dispose(){var e;null===(e=this._observer)||void 0===e||e.disconnect(),super.dispose(),this._anchor.removeClass("jp-mod-clicked"),this._anchor.addClass("jp-mod-highlight")}handleEvent(e){switch(e.type){case"keydown":this._evtKeydown(e);break;case"click":this._evtClick(e);break;case"resize":this.onResize()}}_evtClick(e){!e.target||this._body.node.contains(e.target)||this._anchor.node.contains(e.target)||this.dispose()}_evtKeydown(e){27===e.keyCode&&(e.stopPropagation(),e.preventDefault(),this.dispose())}_setGeometry(){let e=0;const t=this._anchor.node.getBoundingClientRect(),s=this._body.node.getBoundingClientRect();"right"===this._align&&(e=-(s.width-t.width));const i=window.getComputedStyle(this._body.node);n.HoverBox.setGeometry({anchor:t,host:document.body,maxHeight:500,minHeight:20,node:this._body.node,offset:{horizontal:e},privilege:"forceAbove",style:i})}}function l(e){const{width:t,percentage:s,...a}=e;return i.createElement("div",{className:"jp-Statusbar-ProgressBar-progress-bar",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":s},i.createElement(c,{percentage:s,...a,contentWidth:t}))}function c(e){return i.createElement("div",{style:{width:`${e.percentage}%`}},i.createElement("p",null,e.content))}function u(e){const{title:t,source:s,className:a,...r}=e;return i.createElement("span",{className:`jp-StatusBar-TextItem ${a}`,title:t,...r},s)}function m(e){return a().createElement("div",{className:"jp-Statusbar-ProgressCircle",role:"progressbar","aria-label":e.label||"Unlabelled progress circle","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":e.progress},a().createElement("svg",{viewBox:"0 0 250 250"},a().createElement("circle",{cx:"125",cy:"125",r:"104",stroke:"var(--jp-inverse-layout-color3)",strokeWidth:"20",fill:"none"}),a().createElement("path",{className:"jp-Statusbar-ProgressCirclePath",transform:"translate(125,125) scale(.9)",d:(e=>{const t=Math.max(3.6*e,.1),s=t*Math.PI/180,i=104*Math.sin(s),a=-104*Math.cos(s);return"M 0 0 v -104 A 104 104 1 "+(t<180?1:0)+" 0 "+i.toFixed(4)+" "+a.toFixed(4)+" z"})(e.progress),fill:"var(--jp-inverse-layout-color3)"})))}var p,g=s(33625),_=s(2549);class v extends o.Widget{constructor(){super(),this._isWindowNarrow=()=>window.innerWidth<=630,this._leftRankItems=[],this._rightRankItems=[],this._statusItems={},this._disposables=new _.DisposableSet,this.addClass("jp-StatusBar-Widget");const e=this.layout=new o.PanelLayout,t=this._leftSide=new o.Panel,s=this._middlePanel=new o.Panel,i=this._rightSide=new o.Panel;t.addClass("jp-StatusBar-Left"),s.addClass("jp-StatusBar-Middle"),i.addClass("jp-StatusBar-Right"),e.addWidget(t),e.addWidget(s),e.addWidget(i)}registerStatusItem(e,t){if(e in this._statusItems)throw new Error(`Status item ${e} already registered.`);const s={...p.statusItemDefaults,...t},{align:i,item:a,rank:r,priority:n}=s,o=()=>{this._refreshItem(e)};s.activeStateChanged&&s.activeStateChanged.connect(o);const d={id:e,rank:r,priority:n};if(s.item.addClass("jp-StatusBar-Item"),this._statusItems[e]=s,"left"===i){const e=this._findInsertIndex(this._leftRankItems,d);-1===e?(this._leftSide.addWidget(a),this._leftRankItems.push(d)):(g.ArrayExt.insert(this._leftRankItems,e,d),this._leftSide.insertWidget(e,a))}else if("right"===i){const e=this._findInsertIndex(this._rightRankItems,d);-1===e?(this._rightSide.addWidget(a),this._rightRankItems.push(d)):(g.ArrayExt.insert(this._rightRankItems,e,d),this._rightSide.insertWidget(e,a))}else this._middlePanel.addWidget(a);this._refreshItem(e);const h=new _.DisposableDelegate((()=>{delete this._statusItems[e],s.activeStateChanged&&s.activeStateChanged.disconnect(o),a.parent=null,a.dispose()}));return this._disposables.add(h),h}dispose(){this._leftRankItems.length=0,this._rightRankItems.length=0,this._disposables.dispose(),super.dispose()}onUpdateRequest(e){this._refreshAll(),super.onUpdateRequest(e)}_findInsertIndex(e,t){return g.ArrayExt.findFirstIndex(e,(e=>e.rank>t.rank))}_refreshItem(e){const t=this._statusItems[e];!t.isActive()||0===t.priority&&this._isWindowNarrow()?t.item.hide():(t.item.show(),t.item.update())}_refreshAll(){Object.keys(this._statusItems).forEach((e=>{this._refreshItem(e)}))}}!function(e){e.statusItemDefaults={align:"left",rank:0,priority:0,isActive:()=>!0,activeStateChanged:void 0}}(p||(p={}));const f=new(s(20998).Token)("@jupyterlab/statusbar:IStatusBar","A service for the status bar on the application. Use this if you want to add new status bar items.")}}]);
|
notebook/static/7684.bundle.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_JUPYTERLAB_CORE_OUTPUT=self.webpackChunk_JUPYTERLAB_CORE_OUTPUT||[]).push([[7684,6893],{56893:(t,e,o)=>{o.r(e),o.d(e,{CommandIDs:()=>n,default:()=>i});var n,a=o(
|
|
1
|
+
"use strict";(self.webpackChunk_JUPYTERLAB_CORE_OUTPUT=self.webpackChunk_JUPYTERLAB_CORE_OUTPUT||[]).push([[7684,6893],{56893:(t,e,o)=>{o.r(e),o.d(e,{CommandIDs:()=>n,default:()=>i});var n,a=o(3053),r=o(12982),s=o(38639),u=o(71677);!function(t){t.controlPanel="hub:control-panel",t.logout="hub:logout",t.restart="hub:restart"}(n||(n={}));const i=[{activate:function(t,e,o,a){const r=o.load("jupyterlab"),u=e.urls.hubHost||"",i=e.urls.hubPrefix||"",l=e.urls.hubUser||"",c=e.urls.hubServerName||"",d=e.urls.base;if(!i)return;console.debug("hub-extension: Found configuration ",{hubHost:u,hubPrefix:i});const b=s.URLExt.join(i,"spawn");let h;if(c){const t=s.URLExt.join(b,l,c);if(!t.startsWith(b))throw new Error("Can only be used for spawn requests");h=u+t}h=u+b;const{commands:_}=t;if(_.addCommand(n.restart,{label:r.__("Restart Server"),caption:r.__("Request that the Hub restart this server"),execute:()=>{window.open(h,"_blank")}}),_.addCommand(n.controlPanel,{label:r.__("Hub Control Panel"),caption:r.__("Open the Hub control panel in a new browser tab"),execute:()=>{window.open(u+s.URLExt.join(i,"home"),"_blank")}}),_.addCommand(n.logout,{label:r.__("Log Out"),caption:r.__("Log out of the Hub"),execute:()=>{window.location.href=u+s.URLExt.join(d,"logout")}}),a){const t=r.__("Hub");a.addItem({category:t,command:n.controlPanel}),a.addItem({category:t,command:n.logout})}},id:"@jupyterlab/hub-extension:plugin",description:"Registers commands related to the hub server",requires:[a.JupyterFrontEnd.IPaths,u.ITranslator],optional:[r.ICommandPalette],autoStart:!0},{activate:()=>{},id:"@jupyterlab/hub-extension:menu",description:"Adds hub related commands to the menu.",autoStart:!0},{id:"@jupyterlab/hub-extension:connectionlost",description:"Provides a service to be notified when the connection to the hub server is lost.",requires:[a.JupyterFrontEnd.IPaths,u.ITranslator],optional:[a.JupyterLab.IInfo],activate:(t,e,o,s)=>{const u=o.load("jupyterlab"),i=e.urls.hubPrefix||"",l=e.urls.base;if(!i)return a.ConnectionLost;let c=!1;return async(e,o)=>{if(c)return;c=!0,s&&(s.isConnected=!1);const a=await(0,r.showDialog)({title:u.__("Server unavailable or unreachable"),body:u.__("Your server at %1 is not running.\nWould you like to restart it?",l),buttons:[r.Dialog.okButton({label:u.__("Restart")}),r.Dialog.cancelButton({label:u.__("Dismiss")})]});s&&(s.isConnected=!0),c=!1,a.button.accept&&await t.commands.execute(n.restart)}},autoStart:!0,provides:a.IConnectionLost}]}}]);
|