repo_name
string
dataset
string
owner
string
lang
string
func_name
string
code
string
docstring
string
url
string
sha
string
libro
github_2023
weavefox
typescript
WidgetView.toJSON
toJSON(): string { return this.toModelKey(); }
/** * Serialize the model. See the deserialization function at the top of this file * and the kernel-side serializer/deserializer. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-jupyter/src/widget/widget-view.tsx#L222-L224
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
InstancesProgressWidget.handleCommMsg
override handleCommMsg(msg: KernelMessage.ICommMsgMsg): Promise<void> { const data = msg.content.data as any; const method = data.method; switch (method) { case 'update': if (data.state.prefix) { this.prefix = data.state.prefix; } if (data.state.suffix) { th...
/** * Handle incoming comm msg. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-jupyter/src/widget/instance-progress/view.tsx#L96-L154
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
BaseManager.onDisposed
get onDisposed(): ManaEvent<void> { return this.onDisposedEmitter.event; }
/** * A signal emitted when the delegate is disposed. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/basemanager.ts#L57-L59
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
BaseManager.connectionFailure
get connectionFailure(): ManaEvent<Error> { return this.connectionFailureEmitter.event; }
/** * A signal emitted when there is a connection failure. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/basemanager.ts#L64-L66
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
BaseManager.isDisposed
get isDisposed(): boolean { return this._isDisposed; }
/** * Test whether the delegate has been disposed. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/basemanager.ts#L71-L73
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
BaseManager.isReady
get isReady(): boolean { return this._isReady; }
/** * Test whether the manager is ready. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/basemanager.ts#L78-L80
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
BaseManager.ready
get ready(): Promise<void> { return this._ready; }
/** * A promise that fulfills when the manager is ready. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/basemanager.ts#L85-L87
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
BaseManager.isActive
get isActive(): boolean { return true; }
/** * Whether the manager is active. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/basemanager.ts#L92-L94
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
BaseManager.dispose
dispose(): void { if (this.isDisposed) { return; } this.onDisposedEmitter.fire(undefined); this.onDisposedEmitter.dispose(); }
/** * Dispose of the delegate and invoke the callback function. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/basemanager.ts#L99-L105
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
PageConfig.getBodyData
static getBodyData(key: string): string { if (typeof document === 'undefined' || !document.body) { return ''; } const val = document.body.dataset[key]; if (typeof val === 'undefined') { return ''; } return decodeURIComponent(val); }
/** * Get a url-encoded item from `body.data` and decode it * We should never have any encoded URLs anywhere else in code * until we are building an actual request. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/page-config.ts#L16-L25
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
PageConfig.setOption
static setOption(name: string, value: string): string { const last = PageConfig.getOption(name); configData![name] = value; return last; }
/** * Set global configuration data for the Jupyter application. * * @param name - The name of the configuration option. * @param value - The value to set the option to. * * @returns The last config value or an empty string if it doesn't exist. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/page-config.ts#L60-L65
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
PageConfig.getBaseUrl
static getBaseUrl(): string { return URL.normalize(PageConfig.getOption('baseUrl') || '/'); }
/** * Get the base url for a Jupyter application, or the base url of the page. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/page-config.ts#L70-L72
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
PageConfig.getWsUrl
static getWsUrl(baseUrl?: string): string { let wsUrl = PageConfig.getOption('wsUrl'); if (!wsUrl) { baseUrl = baseUrl ? URL.normalize(baseUrl) : PageConfig.getBaseUrl(); if (baseUrl.indexOf('http') !== 0) { return ''; } wsUrl = 'ws' + baseUrl.slice(4); } return URL.norma...
/** * Get the base websocket url for a Jupyter application, or an empty string. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/page-config.ts#L77-L87
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
PageConfig.getToken
static getToken(): string { return PageConfig.getOption('token') || PageConfig.getBodyData('jupyterApiToken'); }
/** * Get the authorization token for a Jupyter application. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/page-config.ts#L92-L94
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
PageConfig.getNotebookVersion
static getNotebookVersion(): [number, number, number] { const notebookVersion = PageConfig.getOption('notebookVersion'); if (notebookVersion === '') { return [0, 0, 0]; } return JSON.parse(notebookVersion); }
/** * Get the Notebook version info [major, minor, patch]. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/page-config.ts#L99-L105
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
Drive.constructor
constructor() { this.apiEndpoint = SERVICE_DRIVE_URL; }
/** * Construct a new contents manager object. * * @param options - The options used to initialize the object. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-drive.ts#L52-L54
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
Drive.fileChanged
get fileChanged(): ManaEvent<IContentsChangedArgs> { return this.fileChangedEmitter.event; }
/** * A signal emitted when a file operation takes place. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-drive.ts#L65-L67
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
Drive.isDisposed
get isDisposed(): boolean { return this._isDisposed; }
/** * Test whether the manager has been disposed. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-drive.ts#L77-L79
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
Drive.dispose
dispose(): void { if (this.isDisposed) { return; } this._isDisposed = true; this.fileChangedEmitter.dispose(); }
/** * Dispose of the resources held by the manager. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-drive.ts#L84-L90
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
Drive.get
async get( localPath: string, options?: IContentsFetchOptions, ): Promise<IContentsModel> { let url = this.getUrl(options?.baseUrl, localPath); const settings = this._getSettings(options?.baseUrl); if (options) { // The notebook type cannot take an format option. if (options.type === ...
/** * Get a file or directory. * * @param localPath: The path to the file. * * @param options: The options used to fetch the file. * * @returns A promise which resolves with the file content. * * Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com...
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-drive.ts#L103-L131
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
Drive.getDownloadUrl
getDownloadUrl( localPath: string, options?: IContentsRequestOptions, ): Promise<string> { const baseUrl = options?.baseUrl || this.serverConnection.settings.baseUrl; let url = URLUtil.join(baseUrl, FILES_URL, URLUtil.encodeParts(localPath)); const xsrfTokenMatch = document.cookie.match('\\b_xsrf=...
/** * Get an encoded download url given a file path. * * @param localPath - An absolute POSIX file path on the server. * * #### Notes * It is expected that the path contains no relative paths. * * The returned URL may include a query parameter. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-drive.ts#L143-L156
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
Drive.newUntitled
async newUntitled(options: IContentsCreateOptions = {}): Promise<IContentsModel> { let body = '{}'; const url = this.getUrl(options.baseUrl, options.path ?? ''); const settings = this._getSettings(options.baseUrl); if (options) { if (options.ext) { options.ext = normalizeExtension(options...
/** * Create a new untitled file or directory in the specified directory path. * * @param options: The options used to create the file. * * @returns A promise which resolves with the created file content when the * file is created. * * #### Notes * Uses the [Jupyter Notebook API](http://pe...
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-drive.ts#L169-L201
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
Drive.delete
async delete(localPath: string, options?: IContentsRequestOptions): Promise<void> { const url = this.getUrl(options?.baseUrl, localPath); const init = { method: 'DELETE' }; const settings = this._getSettings(options?.baseUrl); const response = await this.serverConnection.makeRequest(url, init, settings)...
/** * Delete a file. * * @param localPath - The path to the file. * * @returns A promise which resolves when the file is deleted. * * #### Notes * Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.y...
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-drive.ts#L213-L229
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
Drive.rename
async rename( oldLocalPath: string, newLocalPath: string, options?: IContentsRequestOptions, ): Promise<IContentsModel> { const url = this.getUrl(options?.baseUrl, oldLocalPath); const init = { method: 'PATCH', body: JSON.stringify({ path: newLocalPath }), }; const settings = t...
/** * Rename a file or directory. * * @param oldLocalPath - The original file path. * * @param newLocalPath - The new file path. * * @returns A promise which resolves with the new file contents model when * the file is renamed. * * #### Notes * Uses the [Jupyter Notebook API](http://p...
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-drive.ts#L244-L268
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
Drive.save
async save( localPath: string, options: Partial<IContentsModel> = {}, ): Promise<IContentsModel> { const url = this.getUrl(options.baseUrl, localPath); const settings = this._getSettings(options.baseUrl); if (options) { if (options.baseUrl) { delete options.baseUrl; } } ...
/** * Save a file. * * @param localPath - The desired file path. * * @param options - Optional overrides to the model. * * @returns A promise which resolves with the file content model when the * file is saved. * * #### Notes * Ensure that `model.content` is populated for the file. ...
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-drive.ts#L285-L316
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
Drive.copy
async copy( fromFile: string, toDir: string, options?: IContentsRequestOptions, ): Promise<IContentsModel> { const url = this.getUrl(options?.baseUrl, toDir); const init = { method: 'POST', body: JSON.stringify({ copy_from: fromFile }), }; const settings = this._getSettings(opt...
/** * Copy a file into a given directory. * * @param localPath - The original file path. * * @param toDir - The destination directory path. * * @returns A promise which resolves with the new contents model when the * file is copied. * * #### Notes * The server will select the name of t...
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-drive.ts#L333-L357
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
Drive.createCheckpoint
async createCheckpoint( localPath: string, options?: IContentsRequestOptions, ): Promise<IContentsCheckpointModel> { const url = this.getUrl(options?.baseUrl, localPath, 'checkpoints'); const init = { method: 'POST' }; const settings = this._getSettings(options?.baseUrl); const response = awai...
/** * Create a checkpoint for a file. * * @param localPath - The path of the file. * * @returns A promise which resolves with the new checkpoint model when the * checkpoint is created. * * #### Notes * Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercon...
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-drive.ts#L370-L385
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
Drive.listCheckpoints
async listCheckpoints( localPath: string, options?: IContentsRequestOptions, ): Promise<IContentsCheckpointModel[]> { const url = this.getUrl(options?.baseUrl, localPath, 'checkpoints'); const settings = this._getSettings(options?.baseUrl); const response = await this.serverConnection.makeRequest(...
/** * List available checkpoints for a file. * * @param localPath - The path of the file. * * @returns A promise which resolves with a list of checkpoint models for * the file. * * #### Notes * Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.co...
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-drive.ts#L398-L417
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
Drive.restoreCheckpoint
async restoreCheckpoint( localPath: string, checkpointID: string, options?: IContentsRequestOptions, ): Promise<void> { const url = this.getUrl(options?.baseUrl, localPath, 'checkpoints', checkpointID); const settings = this._getSettings(options?.baseUrl); const init = { method: 'POST' }; ...
/** * Restore a file to a known checkpoint state. * * @param localPath - The path of the file. * * @param checkpointID - The id of the checkpoint to restore. * * @returns A promise which resolves when the checkpoint is restored. * * #### Notes * Uses the [Jupyter Notebook API](http://petst...
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-drive.ts#L431-L444
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
Drive.deleteCheckpoint
async deleteCheckpoint( localPath: string, checkpointID: string, options?: IContentsRequestOptions, ): Promise<void> { const url = this.getUrl(options?.baseUrl, localPath, 'checkpoints', checkpointID); const init = { method: 'DELETE' }; const settings = this._getSettings(options?.baseUrl); ...
/** * Delete a checkpoint for a file. * * @param localPath - The path of the file. * * @param checkpointID - The id of the checkpoint to delete. * * @returns A promise which resolves when the checkpoint is deleted. * * #### Notes * Uses the [Jupyter Notebook API](http://petstore.swagger.io...
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-drive.ts#L458-L471
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
Drive.getUrl
protected getUrl(base?: string, ...args: string[]): string { let baseUrl = base; if (!baseUrl) { baseUrl = this.serverConnection.settings.baseUrl; } const parts = args.map((path) => URLUtil.encodeParts(path)); return URLUtil.join(baseUrl!, this.apiEndpoint, ...parts); }
/** * Get a REST url for a file given a path. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-drive.ts#L476-L483
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
ContentsManager.fileChanged
get fileChanged(): ManaEvent<IContentsChangedArgs> { // return this._fileChanged; return this.fileChangedEmitter.event; }
/** * A signal emitted when a file operation takes place. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-manager.ts#L43-L46
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
ContentsManager.isDisposed
get isDisposed(): boolean { return this._isDisposed; }
/** * Test whether the manager has been disposed. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-manager.ts#L51-L53
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
ContentsManager.dispose
dispose(): void { if (this.isDisposed) { return; } this._isDisposed = true; this.fileChangedEmitter.dispose(); }
/** * Dispose of the resources held by the manager. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-manager.ts#L58-L64
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
ContentsManager.addDrive
addDrive(drive: IContentsDrive): void { this.additionalDrives.set(drive.name, drive); drive.fileChanged((args) => this.onFileChanged(drive, args)); }
/** * Add an `IContentsDrive` to the manager. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-manager.ts#L69-L72
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
ContentsManager.localPath
localPath(path: string): string { const parts = path.split('/'); const firstParts = parts[0].split(':'); if (firstParts.length === 1 || !this.additionalDrives.has(firstParts[0])) { return PathExt.removeSlash(path); } return PathExt.join(firstParts.slice(1).join(':'), ...parts.slice(1)); }
/** * Given a path of the form `drive:local/portion/of/it.txt` * get the local part of it. * * @param path: the path. * * @returns The local part of the path. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-manager.ts#L92-L99
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
ContentsManager.normalize
normalize(path: string): string { const parts = path.split(':'); if (parts.length === 1) { return PathExt.normalize(path); } return `${parts[0]}:${PathExt.normalize(parts.slice(1).join(':'))}`; }
/** * Normalize a global path. Reduces '..' and '.' parts, and removes * leading slashes from the local part of the path, while retaining * the drive name if it exists. * * @param path: the path. * * @returns The normalized path. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-manager.ts#L110-L116
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
ContentsManager.resolvePath
resolvePath(root: string, path: string): string { const driveName = this.driveName(root); const localPath = this.localPath(root); const resolved = PathExt.resolve('/', localPath, path); return driveName ? `${driveName}:${resolved}` : resolved; }
/** * Resolve a global path, starting from the root path. Behaves like * posix-path.resolve, with 3 differences: * - will never prepend cwd * - if root has a drive name, the result is prefixed with "<drive>:" * - before adding drive name, leading slashes are removed * * @param path: the path. ...
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-manager.ts#L129-L134
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
ContentsManager.driveName
driveName(path: string): string { const parts = path.split('/'); const firstParts = parts[0].split(':'); if (firstParts.length === 1) { return ''; } if (this.additionalDrives.has(firstParts[0])) { return firstParts[0]; } return ''; }
/** * Given a path of the form `drive:local/portion/of/it.txt` * get the name of the drive. If the path is missing * a drive portion, returns an empty string. * * @param path: the path. * * @returns The drive name for the path, or the empty string. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-manager.ts#L145-L155
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
ContentsManager.get
get(path: string, options?: IContentsFetchOptions): Promise<IContentsModel> { const [drive, localPath] = this.driveForPath(path); return drive.get(localPath, options).then((contentsModel) => { const listing: IContentsModel[] = []; if (contentsModel.type === 'directory' && contentsModel.content) { ...
/** * Get a file or directory. * * @param path: The path to the file. * * @param options: The options used to fetch the file. * * @returns A promise which resolves with the file content. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-manager.ts#L166-L186
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
ContentsManager.getDownloadUrl
getDownloadUrl(path: string, options?: IContentsRequestOptions): Promise<string> { const [drive, localPath] = this.driveForPath(path); return drive.getDownloadUrl(localPath, options); }
/** * Get an encoded download url given a file path. * * @param path - An absolute POSIX file path on the server. * * #### Notes * It is expected that the path contains no relative paths. * * The returned URL may include a query parameter. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-manager.ts#L198-L201
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
ContentsManager.newUntitled
newUntitled(options: IContentsCreateOptions = {}): Promise<IContentsModel> { if (options.path) { const globalPath = this.normalize(options.path); const [drive, localPath] = this.driveForPath(globalPath); return drive .newUntitled({ ...options, path: localPath }) .then((contentsMode...
/** * Create a new untitled file or directory in the specified directory path. * * @param options: The options used to create the file. * * @returns A promise which resolves with the created file content when the * file is created. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-manager.ts#L211-L226
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
ContentsManager.delete
delete(path: string, options?: IContentsRequestOptions): Promise<void> { const [drive, localPath] = this.driveForPath(path); return drive.delete(localPath, options); }
/** * Delete a file. * * @param path - The path to the file. * * @returns A promise which resolves when the file is deleted. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-manager.ts#L235-L238
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
ContentsManager.rename
rename( path: string, newPath: string, options?: IContentsRequestOptions, ): Promise<IContentsModel> { const [drive1, path1] = this.driveForPath(path); const [drive2, path2] = this.driveForPath(newPath); if (drive1 !== drive2) { throw Error('ContentsManager: renaming files must occur wit...
/** * Rename a file or directory. * * @param path - The original file path. * * @param newPath - The new file path. * * @returns A promise which resolves with the new file contents model when * the file is renamed. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-manager.ts#L250-L266
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
ContentsManager.save
save(path: string, options: Partial<IContentsModel> = {}): Promise<IContentsModel> { const globalPath = this.normalize(path); const [drive, localPath] = this.driveForPath(path); return drive .save(localPath, { ...options, path: localPath }) .then((contentsModel) => { return { ...contents...
/** * Save a file. * * @param path - The desired file path. * * @param options - Optional overrides to the model. * * @returns A promise which resolves with the file content model when the * file is saved. * * #### Notes * Ensure that `model.content` is populated for the file. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-manager.ts#L281-L289
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
ContentsManager.copy
copy( fromFile: string, toDir: string, options?: IContentsRequestOptions, ): Promise<IContentsModel> { const [drive1, path1] = this.driveForPath(fromFile); const [drive2, path2] = this.driveForPath(toDir); if (drive1 === drive2) { return drive1.copy(path1, path2, options).then((contentsM...
/** * Copy a file into a given directory. * * @param path - The original file path. * * @param toDir - The destination directory path. * * @returns A promise which resolves with the new contents model when the * file is copied. * * #### Notes * The server will select the name of the co...
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-manager.ts#L304-L321
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
ContentsManager.createCheckpoint
createCheckpoint( path: string, options?: IContentsRequestOptions, ): Promise<IContentsCheckpointModel> { const [drive, localPath] = this.driveForPath(path); return drive.createCheckpoint(localPath, options); }
/** * Create a checkpoint for a file. * * @param path - The path of the file. * * @returns A promise which resolves with the new checkpoint model when the * checkpoint is created. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-manager.ts#L331-L337
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
ContentsManager.listCheckpoints
listCheckpoints( path: string, options?: IContentsRequestOptions, ): Promise<IContentsCheckpointModel[]> { const [drive, localPath] = this.driveForPath(path); return drive.listCheckpoints(localPath, options); }
/** * List available checkpoints for a file. * * @param path - The path of the file. * * @returns A promise which resolves with a list of checkpoint models for * the file. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-manager.ts#L347-L353
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
ContentsManager.restoreCheckpoint
restoreCheckpoint( path: string, checkpointID: string, options?: IContentsRequestOptions, ): Promise<void> { const [drive, localPath] = this.driveForPath(path); return drive.restoreCheckpoint(localPath, checkpointID, options); }
/** * Restore a file to a known checkpoint state. * * @param path - The path of the file. * * @param checkpointID - The id of the checkpoint to restore. * * @returns A promise which resolves when the checkpoint is restored. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-manager.ts#L364-L371
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
ContentsManager.deleteCheckpoint
deleteCheckpoint( path: string, checkpointID: string, options?: IContentsRequestOptions, ): Promise<void> { const [drive, localPath] = this.driveForPath(path); return drive.deleteCheckpoint(localPath, checkpointID, options); }
/** * Delete a checkpoint for a file. * * @param path - The path of the file. * * @param checkpointID - The id of the checkpoint to delete. * * @returns A promise which resolves when the checkpoint is deleted. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-manager.ts#L382-L389
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
ContentsManager.toGlobalPath
protected toGlobalPath(drive: IContentsDrive, localPath: string): string { if (drive === this.defaultDrive) { return PathExt.removeSlash(localPath); } else { return `${drive.name}:${PathExt.removeSlash(localPath)}`; } }
/** * Given a drive and a local path, construct a fully qualified * path. The inverse of `driveForPath`. * * @param drive: an `IContentsDrive`. * * @param localPath: the local path on the drive. * * @returns the fully qualified path. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-manager.ts#L401-L407
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
ContentsManager.driveForPath
protected driveForPath(path: string): [IContentsDrive, string] { const driveName = this.driveName(path); const localPath = this.localPath(path); if (driveName) { return [this.additionalDrives.get(driveName)!, localPath]; } else { return [this.defaultDrive, localPath]; } }
/** * Given a path, get the `IContentsDrive to which it refers, * where the path satisfies the pattern * `'driveName:path/to/file'`. If there is no `driveName` * prepended to the path, it returns the default drive. * * @param path: a path to a file. * * @returns A tuple containing an `IContentsD...
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-manager.ts#L420-L428
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
ContentsManager.onFileChanged
protected onFileChanged(sender: IContentsDrive, args: IContentsChangedArgs) { if (sender === this.defaultDrive) { this.fileChangedEmitter.fire(args); } else { let newValue: Partial<IContentsModel> | null = null; let oldValue: Partial<IContentsModel> | null = null; if (args.newValue?.path...
/** * Respond to fileChanged signals from the drives attached to * the manager. This prepends the drive name to the path if necessary, * and then forwards the signal. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/contents/contents-manager.ts#L435-L459
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
CommHandler.constructor
constructor( target: string, id: string, kernel: IKernelConnection, disposeCb: () => void, ) { this.disposeCb = disposeCb; this._id = id; this._target = target; this._kernel = kernel; }
/** * Construct a new comm channel. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/comm.ts#L28-L38
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
CommHandler.commId
get commId(): string { return this._id; }
/** * The unique id for the comm channel. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/comm.ts#L47-L49
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
CommHandler.targetName
get targetName(): string { return this._target; }
/** * The target name for the comm channel. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/comm.ts#L54-L56
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
CommHandler.onClose
get onClose(): (msg: KernelMessage.ICommCloseMsg) => void | PromiseLike<void> { return this._onClose; }
/** * Get the callback for a comm close event. * * #### Notes * This is called when the comm is closed from either the server or client. * * **See also:** [[ICommClose]], [[close]] */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/comm.ts#L66-L68
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
CommHandler.onClose
set onClose(cb: (msg: KernelMessage.ICommCloseMsg) => void | PromiseLike<void>) { this._onClose = cb; }
/** * Set the callback for a comm close event. * * #### Notes * This is called when the comm is closed from either the server or client. If * the function returns a promise, and the kernel was closed from the server, * kernel message processing will pause until the returned promise is * fulfilled. ...
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/comm.ts#L81-L83
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
CommHandler.onMsg
get onMsg(): (msg: KernelMessage.ICommMsgMsg) => void | PromiseLike<void> { return this._onMsg; }
/** * Get the callback for a comm message received event. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/comm.ts#L88-L90
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
CommHandler.onMsg
set onMsg(cb: (msg: KernelMessage.ICommMsgMsg) => void | PromiseLike<void>) { this._onMsg = cb; }
/** * Set the callback for a comm message received event. * * #### Notes * This is called when a comm message is received. If the function returns a * promise, kernel message processing will pause until it is fulfilled. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/comm.ts#L99-L101
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
CommHandler.open
open( data?: JSONObject, metadata?: JSONObject, buffers: (ArrayBuffer | ArrayBufferView)[] = [], ): IShellFuture { if (this.disposed || this._kernel.disposed) { throw new Error('Cannot open'); } const msg = KernelMessage.createMessage({ msgType: 'comm_open', channel: 'shell',...
/** * Open a comm with optional data and metadata. * * #### Notes * This sends a `comm_open` message to the server. * * **See also:** [[ICommOpen]] */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/comm.ts#L111-L133
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
CommHandler.send
send( data: JSONObject, metadata?: JSONObject, buffers: (ArrayBuffer | ArrayBufferView)[] = [], disposeOnDone = true, ): IShellFuture { if (this.disposed || this._kernel.disposed) { throw new Error('Cannot send'); } const msg = KernelMessage.createMessage({ msgType: 'comm_msg',...
/** * Send a `comm_msg` message to the kernel. * * #### Notes * This is a no-op if the comm has been closed. * * **See also:** [[ICommMsg]] */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/comm.ts#L143-L165
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
CommHandler.close
close( data?: JSONObject, metadata?: JSONObject, buffers: (ArrayBuffer | ArrayBufferView)[] = [], ): IShellFuture { if (this.disposed || this._kernel.disposed) { throw new Error('Cannot close'); } const msg = KernelMessage.createMessage({ msgType: 'comm_close', channel: 'shel...
/** * Close the comm. * * #### Notes * This will send a `comm_close` message to the kernel, and call the * `onClose` callback if set. * * This is a no-op if the comm is already closed. * * **See also:** [[ICommClose]], [[onClose]] */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/comm.ts#L178-L219
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
HookList.add
add(hook: (msg: T) => boolean | PromiseLike<boolean>): void { this.remove(hook); this._hooks.push(hook); }
/** * Register a hook. * * @param hook - The callback to register. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/future.ts#L42-L45
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
HookList.remove
remove(hook: (msg: T) => boolean | PromiseLike<boolean>): void { const index = this._hooks.indexOf(hook); if (index >= 0) { this._hooks[index] = null; this._scheduleCompact(); } }
/** * Remove a hook, if it exists in the hook list. * * @param hook - The callback to remove. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/future.ts#L52-L58
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
HookList.process
async process(msg: T): Promise<boolean> { // Wait until we can start a new process run. await this._processing; // Start the next process run. const processing = new Deferred<void>(); this._processing = processing.promise; let continueHandling: boolean; // Call the end hook ...
/** * Process a message through the hooks. * * @returns a promise resolving to false if any hook resolved as false, * otherwise true * * #### Notes * The most recently registered hook is run first. A hook can return a * boolean or a promise to a boolean, in which case processing ...
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/future.ts#L76-L116
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
HookList._scheduleCompact
protected _scheduleCompact(): void { if (!this._compactScheduled) { this._compactScheduled = true; // Schedule a compaction in between processing runs. We do the // scheduling in an animation frame to rate-limit our compactions. If we // need to compact more frequently, we can cha...
/** * Schedule a cleanup of the list, removing any hooks that have been nulled out. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/future.ts#L121-L137
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
HookList._compact
protected _compact(): void { let numNulls = 0; for (let i = 0, len = this._hooks.length; i < len; i++) { const hook = this._hooks[i]; if (this._hooks[i] === null) { numNulls++; } else { this._hooks[i - numNulls] = hook; } } this._hooks.length -...
/** * Compact the list, removing any nulls. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/future.ts#L142-L153
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
KernelConnection.constructor
constructor( @inject(KernelConnectionOptions) options: KernelConnectionOptions, @inject(ServerConnection) serverConnection: ServerConnection, ) { this.serverSettings = { ...serverConnection.settings, ...options.serverSettings }; this._name = options.model.name; this._id = options.model.id; th...
/** * Construct a kernel object. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L162-L175
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
KernelConnection.statusChanged
get statusChanged(): ManaEvent<KernelMessage.Status> { return this.statusChangedEmitter.event; }
/** * A signal emitted when the kernel status changes. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L205-L207
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
KernelConnection.connectionStatusChanged
get connectionStatusChanged(): ManaEvent<ConnectionStatus> { return this.connectionStatusChangedEmitter.event; }
/** * A signal emitted when the kernel status changes. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L212-L214
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
KernelConnection.iopubMessage
get iopubMessage(): ManaEvent<KernelMessage.IIOPubMessage> { return this.iopubMessageEmitter.event; }
/** * A signal emitted for iopub kernel messages. * * #### Notes * This signal is emitted after the iopub message is handled asynchronously. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L222-L224
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
KernelConnection.unhandledMessage
get unhandledMessage(): ManaEvent<KernelMessage.IMessage> { return this.unhandledMessageEmitter.event; }
/** * A signal emitted for unhandled kernel message. * * #### Notes * This signal is emitted for a message that was not handled. It is emitted * during the asynchronous message handling code. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L237-L239
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
KernelConnection.model
get model(): IKernelModel { return ( this._model || { id: this.id, name: this.name, reason: this._reason, } ); }
/** * The kernel model */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L244-L252
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
KernelConnection.anyMessage
get anyMessage(): ManaEvent<IAnyMessageArgs> { return this.anyMessageEmitter.event; }
/** * A signal emitted for any kernel message. * * #### Notes * This signal is emitted when a message is received, before it is handled * asynchronously. * * This message is emitted when a message is queued for sending (either in * the websocket buffer, or our own pending message buffer). The me...
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L267-L269
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
KernelConnection.pendingInput
get pendingInput(): ManaEvent<boolean> { return this.pendingInputEmitter.event; }
/** * A signal emitted when a kernel has pending inputs from the user. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L274-L276
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
KernelConnection.id
get id(): string { return this._id; }
/** * The id of the server-side kernel. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L281-L283
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
KernelConnection.name
get name(): string { return this._name; }
/** * The name of the server-side kernel. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L288-L290
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
KernelConnection.username
get username(): string { return this._username; }
/** * The client username. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L295-L297
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
KernelConnection.clientId
get clientId(): string { return this._clientId; }
/** * The client unique id. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L302-L304
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
KernelConnection.status
get status(): KernelMessage.Status { return this._status; }
/** * The current status of the kernel. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L309-L311
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
KernelConnection.connectionStatus
get connectionStatus(): ConnectionStatus { return this._connectionStatus; }
/** * The current connection status of the kernel connection. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L316-L318
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
KernelConnection.isDisposed
get isDisposed(): boolean { return this._isDisposed; }
/** * Test whether the kernel has been disposed. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L323-L325
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
KernelConnection.info
get info(): Promise<KernelMessage.IInfoReply> { return this._info.promise; }
/** * The cached kernel info. * * @returns A promise that resolves to the kernel info. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L332-L334
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
KernelConnection.spec
get spec(): Promise<ISpecModel | undefined> { if (this._specPromise) { return this._specPromise; } this._specPromise = this.kernelSpecRestAPI .getSpecs(this.serverSettings) .then((specs) => { return specs.kernelspecs[this._name]; }); return this._specPromise; }
/** * The kernel spec. * * @returns A promise that resolves to the kernel spec. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L341-L351
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
KernelConnection.clone
clone( options: Pick< KernelConnectionOptions, 'clientId' | 'username' | 'handleComms' > = {}, ): IKernelConnection { return this.libroKernelConnectionFactory({ model: this.model, username: this.username, // handleComms defaults to false since that is safer handleComms:...
/** * Clone the current kernel with a new clientId. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L356-L369
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
KernelConnection.dispose
dispose(): void { if (this.isDisposed) { return; } this.onDisposedEmitter.fire(); this._updateConnectionStatus('disconnected'); this._clearKernelState(); this._pendingMessages = []; this._clearSocket(); this.connectionStatusChangedEmitter.dispose(); this.statusChangedEmitter....
/** * Dispose of the resources held by the kernel. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L374-L394
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
KernelConnection.sendShellMessage
sendShellMessage<T extends KernelMessage.ShellMessageType>( msg: KernelMessage.IShellMessage<T>, expectReply = false, disposeOnDone = true, ): IShellFuture<KernelMessage.IShellMessage<T>> { return this._sendKernelShellControl( KernelShellFutureHandler as any, msg, expectReply, ...
/** * Send a shell message to the kernel. * * #### Notes * Send a message to the kernel's shell channel, yielding a future object * for accepting replies. * * If `expectReply` is given and `true`, the future is disposed when both a * shell reply and an idle status message are received. If `expec...
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L414-L425
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
KernelConnection.sendControlMessage
sendControlMessage<T extends KernelMessage.ControlMessageType>( msg: KernelMessage.IControlMessage<T>, expectReply = false, disposeOnDone = true, ): IControlFuture<KernelMessage.IControlMessage<T>> { return this._sendKernelShellControl( KernelControlFutureHandler as any, msg, expectR...
/** * Send a control message to the kernel. * * #### Notes * Send a message to the kernel's control channel, yielding a future object * for accepting replies. * * If `expectReply` is given and `true`, the future is disposed when both a * control reply and an idle status message are received. If ...
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L445-L456
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
KernelConnection._sendMessage
protected _sendMessage(msg: KernelMessage.IMessage, queue = true) { if (this.status === 'dead') { throw new Error('Kernel is dead'); } // If we have a kernel_info_request and we are starting or restarting, send the // kernel_info_request immediately if we can, and if not throw an error so // ...
/** * Send a message on the websocket. * * If queue is true, queue the message for later sending if we cannot send * now. Otherwise throw an error. * * #### Notes * As an exception to the queueing, if we are sending a kernel_info_request * message while we think the kernel is restarting, we send...
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L519-L559
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
KernelConnection.interrupt
async interrupt(): Promise<void> { this.hasPendingInput = false; if (this.status === 'dead') { throw new Error('Kernel is dead'); } return this.kernelRestAPI.interruptKernel(this.id, this.serverSettings); }
/** * Interrupt a kernel. * * #### Notes * Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/kernels). * * The promise is fulfilled on a valid response and rejected otherwise. * * It is assum...
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L574-L580
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
KernelConnection.restart
async restart(): Promise<void> { if (this.status === 'dead') { throw new Error('Kernel is dead'); } this._updateStatus('restarting'); this._clearKernelState(); this._kernelSession = RESTARTING_KERNEL_SESSION; await this.kernelRestAPI.restartKernel(this.id, this.serverSettings); // Reco...
/** * Request a kernel restart. * * #### Notes * Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/kernels) * and validates the response model. * * Any existing Future or Comm objects are cleare...
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L600-L612
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
KernelConnection.reconnect
reconnect(): Promise<void> { this._errorIfDisposed(); const result = new Deferred<void>(); let toDispose: Disposable | undefined = undefined; // Set up a listener for the connection status changing, which accepts or // rejects after the retries are done. const fulfill = (status: ConnectionStatu...
/** * Reconnect to a kernel. * * #### Notes * This may try multiple times to reconnect to a kernel, and will sever any * existing connection. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L621-L655
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
fulfill
const fulfill = (status: ConnectionStatus) => { if (status === 'connected') { result.resolve(); if (toDispose) { toDispose.dispose(); toDispose = undefined; } } else if (status === 'disconnected') { result.reject(new Error('Kernel connection disconnected')...
// Set up a listener for the connection status changing, which accepts or
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L628-L642
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
KernelConnection.shutdown
async shutdown(): Promise<void> { if (this.status !== 'dead') { await this.kernelRestAPI.shutdownKernel(this.id, this.serverSettings); } this.handleShutdown(); }
/** * Shutdown a kernel. * * #### Notes * Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/kernels). * * The promise is fulfilled on a valid response and rejected otherwise. * * On a valid r...
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L670-L675
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
KernelConnection.handleShutdown
handleShutdown(): void { this._updateStatus('dead'); this.dispose(); }
/** * Handles a kernel shutdown. * * #### Notes * This method should be called if we know from outside information that a * kernel is dead (for example, we cannot find the kernel model on the * server). */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L685-L688
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
KernelConnection.requestKernelInfo
async requestKernelInfo(): Promise<KernelMessage.IInfoReplyMsg | undefined> { const msg = KernelMessage.createMessage({ msgType: 'kernel_info_request', channel: 'shell', username: this._username, session: this._clientId, content: {}, }); let reply: KernelMessage.IInfoReplyMsg |...
/** * Send a `kernel_info_request` message. * * #### Notes * See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#kernel-info). * * Fulfills with the `kernel_info_response` content when the shell reply is * received and validated. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L699-L743
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
KernelConnection.requestComplete
requestComplete( content: KernelMessage.ICompleteRequestMsg['content'], ): Promise<KernelMessage.ICompleteReplyMsg> { const msg = KernelMessage.createMessage({ msgType: 'complete_request', channel: 'shell', username: this._username, session: this._clientId, content, }); r...
/** * Send a `complete_request` message. * * #### Notes * See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#completion). * * Fulfills with the `complete_reply` content when the shell reply is * received and validated. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L754-L768
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
KernelConnection.requestInspect
requestInspect( content: KernelMessage.IInspectRequestMsg['content'], ): Promise<KernelMessage.IInspectReplyMsg> { const msg = KernelMessage.createMessage({ msgType: 'inspect_request', channel: 'shell', username: this._username, session: this._clientId, content: content, }); ...
/** * Send an `inspect_request` message. * * #### Notes * See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#introspection). * * Fulfills with the `inspect_reply` content when the shell reply is * received and validated. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L779-L793
371f9fa4903254d60ed3142e335dbf3f6d8d03e4
libro
github_2023
weavefox
typescript
KernelConnection.requestHistory
requestHistory( content: KernelMessage.IHistoryRequestMsg['content'], ): Promise<KernelMessage.IHistoryReplyMsg> { const msg = KernelMessage.createMessage({ msgType: 'history_request', channel: 'shell', username: this._username, session: this._clientId, content, }); retur...
/** * Send a `history_request` message. * * #### Notes * See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#history). * * Fulfills with the `history_reply` content when the shell reply is * received and validated. */
https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L804-L818
371f9fa4903254d60ed3142e335dbf3f6d8d03e4