Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let model = (this._model = options.model);
let config = options.config || {};
let fullConfig = (this._config = {
...CodeMirrorEditor.defaultConfig,
...config
});
let editor = (this._editor = Private.createEditor(host, fullConfig));
let doc = editor.getDoc();
// Handle initial values for text, mimetype, and selections.
doc.setValue(model.value.text);
this.clearHistory();
this._onMimeTypeChanged();
this._onCursorActivity();
this._poll = new Poll({
factory: async () => {
this._checkSync();
},
frequency: { interval: 3000, backoff: false },
standby: () => {
// If changed, only stand by when hidden, otherwise always stand by.
return this._lastChange ? 'when-hidden' : true;
}
});
// Connect to changes.
model.value.changed.connect(this._onValueChanged, this);
model.mimeTypeChanged.connect(this._onMimeTypeChanged, this);
model.selections.changed.connect(this._onSelectionsChanged, this);
CodeMirror.on(editor, 'keydown', (editor: CodeMirror.Editor, event) => {
constructor(options: KernelSpecManager.IOptions = {}) {
super(options);
// Initialize internal data.
this._ready = Promise.all([this.requestSpecs()])
.then(_ => undefined)
.catch(_ => undefined)
.then(() => {
if (this.isDisposed) {
return;
}
this._isReady = true;
});
this._pollSpecs = new Poll({
auto: false,
factory: () => this.requestSpecs(),
frequency: {
interval: 61 * 1000,
backoff: true,
max: 300 * 1000
},
name: `@jupyterlab/services:KernelSpecManager#specs`,
standby: options.standby ?? 'when-hidden'
});
void this.ready.then(() => {
void this._pollSpecs.start();
});
}
// When a kernel gets strted, restarted or stopped, update the kernel id
options.labShell.currentChanged.connect((_, change) => {
const { oldValue, newValue } = change;
if (oldValue) {
var context = (oldValue as NotebookPanel).sessionContext
context.connectionStatusChanged.disconnect(this.onConnectionStatusChange, this)
}
if (newValue) {
var context = (newValue as NotebookPanel).sessionContext
context.connectionStatusChanged.connect(this.onConnectionStatusChange, this)
}
})
}
)
this._poll = new Poll({
factory: () => Private.factory(this, options.notebookTracker),
frequency: {
interval: options.refreshRate,
backoff: true
},
name: 'statusbar-extension:databrickslabs-jupyterlab#status'
});
this._poll.ticked.connect(poll => {
const { payload, phase } = poll.state;
if (phase === 'resolved') {
this._updateStatusValues(payload);
return;
}
if (phase === 'rejected') {
(msg as Widget.ChildMessage).child.removeClass(ACTIVITY_CLASS);
this._tracker.remove((msg as Widget.ChildMessage).child);
break;
default:
break;
}
return true;
};
private _activeChanged = new Signal(this);
private _cachedLayout: DockLayout.ILayoutConfig | null = null;
private _currentChanged = new Signal(this);
private _dockPanel: DockPanel;
private _isRestored = false;
private _layoutModified = new Signal(this);
private _layoutDebouncer = new Debouncer(() => {
this._layoutModified.emit(undefined);
}, 0);
private _leftHandler: Private.SideBarHandler;
private _restored = new PromiseDelegate();
private _rightHandler: Private.SideBarHandler;
private _tracker = new FocusTracker();
private _headerPanel: Panel;
private _topHandler: Private.PanelHandler;
private _bottomPanel: Panel;
private _mainOptionsCache = new Map();
private _sideOptionsCache = new Map();
}
namespace Private {
/**
* An object which holds a widget and its sort rank.
constructor(options: Model.IOptions) {
super();
this._poll = new Poll({
factory: () => Private.factory(),
frequency: {
interval: options.refreshRate,
backoff: true
},
name: '@jupyterlab/statusbar:MemoryUsage#metrics'
});
this._poll.ticked.connect(poll => {
const { payload, phase } = poll.state;
if (phase === 'resolved') {
this._updateMetricsValues(payload);
return;
}
if (phase === 'rejected') {
const oldMetricsAvailable = this._metricsAvailable;
this._metricsAvailable = false;