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 | KernelConnection.requestExecute | requestExecute(
content: KernelMessage.IExecuteRequestMsg['content'],
disposeOnDone = true,
metadata?: JSONObject,
): IShellFuture<KernelMessage.IExecuteRequestMsg, KernelMessage.IExecuteReplyMsg> {
const defaults: JSONObject = {
silent: false,
store_history: true,
user_expressions: ... | /**
* Send an `execute_request` message.
*
* #### Notes
* See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#execute).
*
* Future `onReply` is called with the `execute_reply` content when the
* shell reply is received and validated. The future will resolve whe... | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L835-L859 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelConnection.requestDebug | requestDebug(
content: KernelMessage.IDebugRequestMsg['content'],
disposeOnDone = true,
): IControlFuture<KernelMessage.IDebugRequestMsg, KernelMessage.IDebugReplyMsg> {
const msg = KernelMessage.createMessage({
msgType: 'debug_request',
channel: 'control',
username: this._username,
... | /**
* Send an experimental `debug_request` message.
*
* @hidden
*
* #### Notes
* Debug messages are experimental messages that are not in the official
* kernel message specification. As such, this function is *NOT* considered
* part of the public API, and may change without notice.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L871-L886 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelConnection.requestIsComplete | requestIsComplete(
content: KernelMessage.IIsCompleteRequestMsg['content'],
): Promise<KernelMessage.IIsCompleteReplyMsg> {
const msg = KernelMessage.createMessage({
msgType: 'is_complete_request',
channel: 'shell',
username: this._username,
session: this._clientId,
content,
... | /**
* Send an `is_complete_request` message.
*
* #### Notes
* See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#code-completeness).
*
* Fulfills with the `is_complete_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#L897-L911 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelConnection.requestCommInfo | requestCommInfo(
content: KernelMessage.ICommInfoRequestMsg['content'],
): Promise<KernelMessage.ICommInfoReplyMsg> {
const msg = KernelMessage.createMessage({
msgType: 'comm_info_request',
channel: 'shell',
username: this._username,
session: this._clientId,
content,
});
... | /**
* Send a `comm_info_request` message.
*
* #### Notes
* Fulfills with the `comm_info_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#L920-L934 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelConnection.sendInputReply | sendInputReply(
content: KernelMessage.IInputReplyMsg['content'],
parent_header: KernelMessage.IInputReplyMsg['parent_header'],
): void {
const msg = KernelMessage.createMessage({
msgType: 'input_reply',
channel: 'stdin',
username: this._username,
session: this._clientId,
con... | /**
* Send an `input_reply` message.
*
* #### Notes
* See [Messaging in Jupyter](https://jupyter-client.readthedocs.io/en/latest/messaging.html#messages-on-the-stdin-router-dealer-sockets).
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L942-L959 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelConnection.createComm | createComm(targetName: string, commId: string = v4()): IComm {
if (!this.handleComms) {
throw new Error('Comms are disabled on this kernel connection');
}
if (this._comms.has(commId)) {
throw new Error('Comm is already created');
}
const comm = new CommHandler(targetName, commId, this, ... | /**
* Create a new comm.
*
* #### Notes
* If a client-side comm already exists with the given commId, an error is thrown.
* If the kernel does not handle comms, an error is thrown.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L968-L981 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelConnection.hasComm | hasComm(commId: string): boolean {
return this._comms.has(commId);
} | /**
* Check if a comm exists.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L986-L988 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelConnection.registerCommTarget | registerCommTarget(
targetName: string,
callback: (
comm: IComm,
msg: KernelMessage.ICommOpenMsg,
) => void | PromiseLike<void>,
): void {
if (!this.handleComms) {
return;
}
this._targetRegistry[targetName] = callback;
} | /**
* Register a comm target handler.
*
* @param targetName - The name of the comm target.
*
* @param callback - The callback invoked for a comm open message.
*
* @returns A disposable used to unregister the comm target.
*
* #### Notes
* Only one comm target can be registered to a target n... | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L1008-L1020 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelConnection.removeCommTarget | removeCommTarget(
targetName: string,
callback: (
comm: IComm,
msg: KernelMessage.ICommOpenMsg,
) => void | PromiseLike<void>,
): void {
if (!this.handleComms) {
return;
}
if (!this.isDisposed && this._targetRegistry[targetName] === callback) {
delete this._targetRegis... | /**
* Remove a comm target handler.
*
* @param targetName - The name of the comm target to remove.
*
* @param callback - The callback to remove.
*
* #### Notes
* The comm target is only removed if the callback argument matches.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L1032-L1046 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelConnection.registerMessageHook | registerMessageHook(
msgId: string,
hook: (msg: KernelMessage.IIOPubMessage) => boolean | PromiseLike<boolean>,
): Disposable {
const future = this._futures?.get(msgId);
if (future) {
return future.registerMessageHook(hook);
}
return Disposable.NONE;
} | /**
* Register an IOPub message hook.
*
* @param msg_id - The parent_header message id the hook will intercept.
*
* @param hook - The callback invoked for the message.
*
* #### Notes
* The IOPub hook system allows you to preempt the handlers for IOPub
* messages that are responses to a given ... | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L1071-L1080 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelConnection.removeMessageHook | removeMessageHook(
msgId: string,
hook: (msg: KernelMessage.IIOPubMessage) => boolean | PromiseLike<boolean>,
): void {
const future = this._futures?.get(msgId);
if (future) {
future.removeMessageHook(hook);
}
} | /**
* Remove an IOPub message hook.
*
* @param msg_id - The parent_header message id the hook intercepted.
*
* @param hook - The callback invoked for the message.
*
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L1090-L1098 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelConnection.removeInputGuard | removeInputGuard() {
this.hasPendingInput = false;
} | /**
* Remove the input guard, if any.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L1103-L1105 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelConnection._handleDisplayId | protected async _handleDisplayId(
displayId: string,
msg: KernelMessage.IMessage,
): Promise<boolean> {
const msgId = (msg.parent_header as KernelMessage.IHeader).msg_id;
let parentIds = this._displayIdToParentIds.get(displayId);
if (parentIds) {
// We've seen it before, update existing outp... | /**
* Handle a message with a display id.
*
* @returns Whether the message was handled.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L1112-L1168 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelConnection._createSocket | protected _clearSocket = (): void => {
if (this._ws !== null) {
// Clear the websocket event handlers and the socket itself.
this._ws.onopen = this._noOp;
this._ws.onclose = this._noOp;
this._ws.onerror = this._noOp;
this._ws.onmessage = this._noOp;
this._ws.close();
this._... | /**
* Forcefully clear the socket state.
*
* #### Notes
* This will clear all socket state without calling any handlers and will
* not update the connection status. If you call this method, you are
* responsible for updating the connection status as needed and recreating
* the socket if you plan to... | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelConnection._updateStatus | protected _updateStatus(status: KernelMessage.Status): void {
if (this._status === status || this._status === 'dead') {
return;
}
this._status = status;
Private.logKernelStatus(this);
this.statusChangedEmitter.fire(status);
if (status === 'dead') {
this.dispose();
}
} | /**
* Handle status iopub messages from the kernel.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L1194-L1205 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelConnection._sendPending | protected _sendPending(): void {
// We check to make sure we are still connected each time. For
// example, if a websocket buffer overflows, it may close, so we should
// stop sending messages.
while (
this.connectionStatus === 'connected' &&
this._kernelSession !== RESTARTING_KERNEL_SESSION... | /**
* Send pending messages to the kernel.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L1210-L1225 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelConnection._clearKernelState | protected _clearKernelState(): void {
this._kernelSession = '';
this._pendingMessages = [];
this._futures.forEach((future) => {
future.dispose();
});
this._comms.forEach((comm) => {
comm.dispose();
});
this._msgChain = Promise.resolve();
this._futures = new Map<
string,... | /**
* Clear the internal state.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L1230-L1250 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelConnection._assertCurrentMessage | protected _assertCurrentMessage(msg: KernelMessage.IMessage) {
this._errorIfDisposed();
if (msg.header.session !== this._kernelSession) {
throw new Error(`Canceling handling of old message: ${msg.header.msg_type}`);
}
} | /**
* Check to make sure it is okay to proceed to handle a message.
*
* #### Notes
* Because we handle messages asynchronously, before a message is handled the
* kernel might be disposed or restarted (and have a different session id).
* This function throws an error in each of these cases. This is mea... | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L1262-L1268 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelConnection._handleCommOpen | protected async _handleCommOpen(msg: KernelMessage.ICommOpenMsg): Promise<void> {
this._assertCurrentMessage(msg);
const content = msg.content;
const comm = new CommHandler(content.target_name, content.comm_id, this, () => {
this._unregisterComm(content.comm_id);
});
this._comms.set(content.co... | /**
* Handle a `comm_open` kernel message.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L1273-L1295 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelConnection._handleCommClose | protected async _handleCommClose(msg: KernelMessage.ICommCloseMsg): Promise<void> {
this._assertCurrentMessage(msg);
const content = msg.content;
const comm = this._comms.get(content.comm_id);
if (!comm) {
console.error('Comm not found for comm id ' + content.comm_id);
return;
}
this... | /**
* Handle 'comm_close' kernel message.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L1300-L1315 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelConnection._handleCommMsg | protected async _handleCommMsg(msg: KernelMessage.ICommMsgMsg): Promise<void> {
this._assertCurrentMessage(msg);
const content = msg.content;
const comm = this._comms.get(content.comm_id);
if (!comm) {
return;
}
const onMsg = comm.onMsg;
if (onMsg) {
await onMsg(msg);
}
} | /**
* Handle a 'comm_msg' kernel message.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L1320-L1331 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelConnection._unregisterComm | protected _unregisterComm(commId: string) {
this._comms.delete(commId);
} | /**
* Unregister a comm instance.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L1336-L1338 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelConnection._updateConnectionStatus | protected _updateConnectionStatus(connectionStatus: ConnectionStatus): void {
if (this._connectionStatus === connectionStatus) {
return;
}
this._connectionStatus = connectionStatus;
// If we are not 'connecting', reset any reconnection attempts.
if (connectionStatus !== 'connecting') {
... | /**
* Handle connection status changes.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L1449-L1512 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelConnection._reconnect | protected _reconnect() {
this._errorIfDisposed();
// Clear any existing reconnection attempt
clearTimeout(this._reconnectTimeout);
// Update the connection status and schedule a possible reconnection.
if (this._reconnectAttempt < this._reconnectLimit) {
this._updateConnectionStatus('connecti... | /**
* Attempt a connection if we have not exhausted connection attempts.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L1605-L1637 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelConnection._errorIfDisposed | protected _errorIfDisposed() {
if (this.isDisposed) {
throw new Error('Kernel connection is disposed');
}
} | /**
* Utility function to throw an error if this instance is disposed.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/kernel-connection.ts#L1642-L1646 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroKernelManager.isReady | get isReady(): boolean {
return this._isReady;
} | /**
* Test whether the manager is ready.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/libro-kernel-manager.ts#L90-L92 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroKernelManager.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/kernel/libro-kernel-manager.ts#L97-L99 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroKernelManager.startNew | async startNew(
createOptions: IKernelOptions = {},
connectOptions: Omit<KernelConnectionOptions, 'model' | 'serverSettings'> = {},
): Promise<IKernelConnection> {
const model = await this.kernelRestAPI.startNew(createOptions);
return this.connectToKernel({
...connectOptions,
model,
})... | /**
* Start a new kernel.
*
* @param createOptions - The kernel creation options
*
* @param connectOptions - The kernel connection options
*
* @returns A promise that resolves with the kernel connection.
*
* #### Notes
* The manager `serverSettings` will be always be used.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/libro-kernel-manager.ts#L113-L122 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroKernelManager.runningChanged | get runningChanged(): ManaEvent<IKernelModel[]> {
return this.runningChangedEmitter.event;
} | /**
* A signal emitted when the running kernels change.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/libro-kernel-manager.ts#L127-L129 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroKernelManager.connectionFailure | get connectionFailure(): ManaEvent<Error> {
return this.connectionFailureEmmiter.event;
} | /**
* A signal emitted when there is a connection failure.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/libro-kernel-manager.ts#L134-L136 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroKernelManager.shutdown | async shutdown(id: string): Promise<void> {
await this.kernelRestAPI.shutdownKernel(id);
await this.refreshRunning();
} | /**
* Shut down a kernel by id.
*
* @param id - The id of the target kernel.
*
* @returns A promise that resolves when the operation is complete.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/libro-kernel-manager.ts#L145-L148 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroKernelManager.shutdownAll | async shutdownAll(): Promise<void> {
// Update the list of models to make sure our list is current.
await this.refreshRunning();
// Shut down all models.
await Promise.all(
[...this._models.keys()].map((id) => this.kernelRestAPI.shutdownKernel(id)),
);
// Update the list of models to cle... | /**
* Shut down all kernels.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/libro-kernel-manager.ts#L153-L164 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroKernelManager.isKernelAlive | async isKernelAlive(id: string): Promise<boolean> {
try {
const data = await this.kernelRestAPI.getKernelModel(id);
return !!data;
} catch {
return false;
}
} | // 通过kernel id判断kernel是否仍然存在 | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/libro-kernel-manager.ts#L174-L181 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroKernelManager.refreshRunning | async refreshRunning(): Promise<void> {
await getOrigin(this._pollModels).refresh();
await getOrigin(this._pollModels).tick;
} | /**
* Force a refresh of the running kernels.
*
* @returns A promise that resolves when the running list has been refreshed.
*
* #### Notes
* This is not typically meant to be called by the user, since the
* manager maintains its own internal state.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/libro-kernel-manager.ts#L220-L223 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroKernelManager.requestRunning | protected async requestRunning(): Promise<void> {
let models: KernelMeta[];
try {
models = await this.kernelRestAPI.listRunning();
} catch (err: any) {
// Handle network errors, as well as cases where we are on a
// JupyterHub and the server is not running. JupyterHub returns a
// 5... | /**
* Execute a request to the server to poll running kernels and update state.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/libro-kernel-manager.ts#L231-L273 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelError.constructor | constructor(content: KernelMessage.IExecuteReplyMsg['content']) {
const errorContent = content as KernelMessage.IReplyErrorContent;
const errorName = errorContent.ename;
const errorValue = errorContent.evalue;
super(`KernelReplyNotOK: ${errorName} ${errorValue}`);
this.errorName = errorName;
th... | /**
* Construct the kernel error.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/libro-kernel-protocol.ts#L73-L83 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelRestAPI.getKernelModel | async getKernelModel(
id: string,
serverSettings?: Partial<ISettings>,
): Promise<IKernelModel | undefined> {
const settings = { ...this.serverConnection.settings, ...serverSettings };
const url = URL.join(settings.baseUrl, KERNEL_SERVICE_URL, encodeURIComponent(id));
const response = await this.... | /**
* Get a full kernel model from the server by kernel id string.
*
* #### 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.
*
* The promise is f... | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/restapi.ts#L24-L41 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelRestAPI.startNew | async startNew(
options: IKernelOptions = {},
serverSettings?: Partial<ISettings>,
): Promise<IKernelModel> {
const settings = { ...this.serverConnection.settings, ...serverSettings };
const url = URL.join(settings.baseUrl, KERNEL_SERVICE_URL);
const init = {
method: 'POST',
body: JSON... | /**
* Start a new kernel.
*
* @param options - The options used to create the kernel.
*
* @returns A promise that resolves with a kernel connection object.
*
* #### Notes
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/n... | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/restapi.ts#L55-L73 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelRestAPI.listRunning | async listRunning(serverSettings?: Partial<ISettings>): Promise<KernelMeta[]> {
const settings = { ...this.serverConnection.settings, ...serverSettings };
const url = URL.join(settings.baseUrl, KERNEL_SERVICE_URL);
const response = await this.serverConnection.makeRequest(url, {}, settings);
if (response... | /**
* Fetch the running kernels.
*
* @param settings - The optional server settings.
*
* @returns A promise that resolves with the list of running kernels.
*
* #### Notes
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/n... | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/restapi.ts#L87-L98 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelRestAPI.shutdownKernel | async shutdownKernel(id: string, serverSettings?: Partial<ISettings>): Promise<void> {
const settings = { ...this.serverConnection.settings, ...serverSettings };
const url = URL.join(settings.baseUrl, KERNEL_SERVICE_URL, encodeURIComponent(id));
const init = { method: 'DELETE' };
const response = await ... | /**
* Shut down a kernel.
*
* @param id - The id of the running kernel.
*
* @param settings - The server settings for the request.
*
* @returns A promise that resolves when the kernel is shut down.
*
*
* #### Notes
* Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https:... | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/restapi.ts#L115-L127 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelRestAPI.restartKernel | async restartKernel(id: string, serverSettings?: Partial<ISettings>): Promise<void> {
const settings = { ...this.serverConnection.settings, ...serverSettings };
const url = URL.join(
settings.baseUrl,
KERNEL_SERVICE_URL,
encodeURIComponent(id),
'restart',
);
const init = { method... | /**
* Restart 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) and validates the response model.
*
* The promise is fulfilled on a valid response (and thus afte... | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/restapi.ts#L137-L154 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelRestAPI.interruptKernel | async interruptKernel(
id: string,
serverSettings?: Partial<ISettings>,
): Promise<void> {
const settings = { ...this.serverConnection.settings, ...serverSettings };
const url = URL.join(
settings.baseUrl,
KERNEL_SERVICE_URL,
encodeURIComponent(id),
'interrupt',
);
cons... | /**
* 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) and validates the response model.
*
* The promise is fulfilled on a valid response and rejected... | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/restapi.ts#L164-L181 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | deserializeBinary | function deserializeBinary(buf: ArrayBuffer): KernelMessage.IMessage {
const data = new DataView(buf);
// read the header: 1 + nbufs 32b integers
const nbufs = data.getUint32(0);
const offsets: number[] = [];
if (nbufs < 2) {
throw new Error('Invalid incoming Kernel Message');
}
for (let i = 1; i <= n... | /**
* Deserialize a binary message to a Kernel Message.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/serialize.ts#L196-L217 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | serializeBinary | function serializeBinary(msg: KernelMessage.IMessage): ArrayBuffer {
const offsets: number[] = [];
const buffers: ArrayBuffer[] = [];
const encoder = new TextEncoder();
let origBuffers: (ArrayBuffer | ArrayBufferView)[] = [];
if (msg.buffers !== undefined) {
origBuffers = msg.buffers;
delete msg.buffe... | /**
* Implement the binary serialization protocol.
*
* Serialize Kernel message to ArrayBuffer.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/serialize.ts#L224-L262 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | validateHeader | function validateHeader(
header: KernelMessage.IHeader,
): asserts header is KernelMessage.IHeader {
for (let i = 0; i < HEADER_FIELDS.length; i++) {
validateProperty(header, HEADER_FIELDS[i], 'string');
}
} | /**
* Validate the header of a kernel message.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/validate.ts#L38-L44 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | validateIOPubContent | function validateIOPubContent(
msg: KernelMessage.IIOPubMessage,
): asserts msg is KernelMessage.IIOPubMessage {
if (msg.channel === 'iopub') {
const fields = IOPUB_CONTENT_FIELDS[msg.header.msg_type];
// Check for unknown message type.
if (fields === undefined) {
return;
}
const names = O... | /**
* Validate content an kernel message on the iopub channel.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernel/validate.ts#L64-L83 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelSpecManager.constructor | constructor(@inject(ServerManager) serverManager: ServerManager) {
super();
this.serverManager = serverManager;
this._pollSpecs = new Poll({
auto: false,
factory: () => this.requestSpecs(),
frequency: {
interval: 61 * 1000,
backoff: true,
max: 300 * 1000,
},
... | /**
* Construct a new kernel spec manager.
*
* @param options - The default options for kernel.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernelspec/manager.ts#L29-L51 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelSpecManager.specsReady | get specsReady() {
return this.specsDeferred.promise;
} | // } | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernelspec/manager.ts#L72-L74 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelSpecManager.specs | get specs(): ISpecModels | null {
return this._specs;
} | /**
* Get the most recently fetched kernel specs.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernelspec/manager.ts#L79-L81 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelSpecManager.specsChanged | get specsChanged(): ManaEvent<ISpecModels> {
return this.specsChangedEmitter.event;
} | /**
* A signal emitted when the specs change.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernelspec/manager.ts#L86-L88 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelSpecManager.connectionFailure | override 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/kernelspec/manager.ts#L93-L95 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelSpecManager.dispose | override dispose(): void {
this._pollSpecs.dispose();
super.dispose();
} | /**
* Dispose of the resources used by the manager.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernelspec/manager.ts#L100-L103 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelSpecManager.refreshSpecs | async refreshSpecs(): Promise<void> {
await this._pollSpecs.refresh();
await this._pollSpecs.tick;
} | /**
* Force a refresh of the specs from the server.
*
* @returns A promise that resolves when the specs are fetched.
*
* #### Notes
* This is intended to be called only in response to a user action,
* since the manager maintains its internal state.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernelspec/manager.ts#L114-L117 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelSpecManager.requestSpecs | protected async requestSpecs(): Promise<void> {
const specs = await this.kernelSpecRestAPI.getSpecs(this.serverSettings);
if (specs) {
this.specsDeferred.resolve(specs);
}
if (this.isDisposed) {
return;
}
if (!this._specs || !deepEqual(specs, this._specs)) {
this._specs = spec... | /**
* Execute a request to the server to poll specs and update state.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernelspec/manager.ts#L122-L135 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | KernelSpecRestAPI.getSpecs | async getSpecs(serverSettings?: Partial<ISettings>): Promise<ISpecModels> {
const settings = { ...this.serverConnection.settings, ...serverSettings };
const url = settings.baseUrl + KERNELSPEC_SERVICE_URL;
// TODO: 当前URL.join 方法是坏的
// const url = URL.join(settings.baseUrl, KERNELSPEC_SERVICE_URL);
... | /**
* Fetch all of the kernel specs.
*
* @param settings - The optional server settings.
* @param useCache - Whether to use the cache. If false, always request.
*
* @returns A promise that resolves with the kernel specs.
*
* #### Notes
* Uses the [Jupyter Notebook API](http://petstore.swagger... | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/kernelspec/restapi.ts#L29-L42 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | JupyterResponseError.constructor | constructor(
response: Response,
message = `The response is invalid: ${response.status} ${response.statusText}`,
traceback = '',
) {
super(message);
this.response = response;
this.traceback = traceback;
} | /**
* Create a new response error.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/server/connection-error.ts#L17-L25 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | NetworkError.constructor | constructor(original: TypeError) {
super(original.message);
this.stack = original.stack;
} | /**
* Create a new network error.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/server/connection-error.ts#L35-L38 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | ServerConnection.makeRequest | makeRequest(
baseUrl: string,
init: RequestInit,
settings: ISettings = this.settings,
): Promise<Response> {
let url = baseUrl;
// Handle notebook server requests.
if (url.indexOf(settings.baseUrl) !== 0) {
throw new Error('Can only be used for notebook server requests');
}
// U... | /**
* Handle a request.
*
* @param url - The url for the request.
*
* @param init - The overrides for the request init.
*
* @param settings - The settings object for the request.
*
* #### Notes
* The `url` must start with `settings.baseUrl`. The `init` settings
* take precedence over `... | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/server/server-connection.ts#L85-L134 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | ServerConnection.getCookie | getCookie(name: string): string | undefined {
// From http://www.tornadoweb.org/en/stable/guide/security.html
const matches = document.cookie.match('\\b' + name + '=([^;]*)\\b');
return matches?.[1];
} | /**
* Get a cookie from the document.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/server/server-connection.ts#L139-L143 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroSessionManager.running | get running(): Map<string, SessionIModel> {
return this._models;
} | // sessionId -> kernelConnection | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/session/libro-session-manager.ts#L61-L63 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroSessionManager.requestRunning | protected async requestRunning(): Promise<void> {
let models: SessionMeta[];
try {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
models = await this.sessionRestAPI.listRunning(this.serverSettings);
} catch (err: any) {
// Handle network errors, as well as cases where we are... | /**
* Execute a request to the server to poll running kernels and update state.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/session/libro-session-manager.ts#L109-L166 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroSessionManager.connectionFailure | get connectionFailure(): Event<Error> {
return this._connectionFailure.event;
} | /**
* A signal emitted when there is a connection failure.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/session/libro-session-manager.ts#L173-L175 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroSessionManager.refreshRunning | async refreshRunning(): Promise<void> {
await getOrigin(this._pollModels).refresh();
await getOrigin(this._pollModels).tick;
} | /**
* Force a refresh of the running sessions.
*
* @returns A promise that with the list of running sessions.
*
* #### Notes
* This is not typically meant to be called by the user, since the
* manager maintains its own internal state.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/session/libro-session-manager.ts#L318-L321 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroSessionManager._patch | protected async _patch(
body: DeepPartial<SessionIModel>,
sessionId?: string,
): Promise<SessionIModel> {
// TODO: 复用session
const model = await this.sessionRestAPI.updateSession(
{ ...body, id: sessionId ?? '' },
this.serverSettings,
);
// this.update(model);
return model;
} | /**
* Send a PATCH to the server, updating the session path or the kernel.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/session/libro-session-manager.ts#L326-L337 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LibroSessionManager.changeKernel | async changeKernel(
fileInfo: IContentsModel,
options: Partial<IKernelModel>,
): Promise<IKernelConnection | null> {
let reuseSessionId = this.sessionIdMap.get(this.persistKey(fileInfo));
// shutdown 过后
if (!reuseSessionId) {
const newSession = await this.sessionRestAPI.startSession(
... | /**
* Change the kernel.
*
* @param options - The name or id of the new kernel.
*
* #### Notes
* This shuts down the existing kernel and creates a new kernel,
* keeping the existing session ID and session path.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/session/libro-session-manager.ts#L348-L405 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | SessionRestAPI.startSession | async startSession(
options: ISessionOptions,
serverSettings?: Partial<ISettings>,
): Promise<SessionIModel> {
const settings = { ...this.serverConnection.settings, ...serverSettings };
const url = URL.join(settings.baseUrl, SESSION_SERVICE_URL);
const init = {
method: 'POST',
body: JS... | /**
* Create a new session, or return an existing session if the session path
* already exists.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/session/restapi.ts#L58-L78 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | SessionRestAPI.listRunning | async listRunning(serverSettings?: Partial<ISettings>): Promise<SessionMeta[]> {
const settings = { ...this.serverConnection.settings, ...serverSettings };
const url = URL.join(settings.baseUrl, SESSION_SERVICE_URL);
const response = await this.serverConnection.makeRequest(url, {}, settings);
if (respon... | /**
* List the running sessions.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/session/restapi.ts#L83-L101 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | SessionRestAPI.updateSession | async updateSession(
model: Pick<SessionIModel, 'id'> & DeepPartial<Omit<SessionIModel, 'id'>>,
serverSettings?: Partial<ISettings>,
): Promise<SessionIModel> {
const settings = { ...this.serverConnection.settings, ...serverSettings };
const url = getSessionUrl(settings.baseUrl, model.id);
const i... | /**
* Send a PATCH to the server, updating the session path or the kernel.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-kernel/src/session/restapi.ts#L106-L125 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | CodeEditorViewerOpenHandler.canHandle | canHandle(uri: URI, options?: ViewOpenHandlerOptions) {
if (uri.scheme === 'file' && textFileTypes.includes(uri.path.ext.toLowerCase())) {
return 100;
}
return Priority.IDLE;
} | // TODO: 支持打开的文件扩展 | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lab/src/editor-viewer/code-editor-open-handler.ts#L21-L26 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | ImageViewerOpenHandler.canHandle | canHandle(uri: URI, _options?: ViewOpenHandlerOptions) {
if (uri.scheme === 'file') {
const ext = uri.path.ext;
if (imageExtToTypes.has(ext.toLowerCase())) {
return 100;
}
}
return Priority.IDLE;
} | // eslint-disable-next-line @typescript-eslint/no-unused-vars | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lab/src/image-viewer/open-handler.ts#L22-L30 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | isLocationLink | function isLocationLink(object: any): object is LocationLink {
return (
object !== undefined &&
'targetUri' in object &&
'targetRange' in object &&
'targetSelectionRange' in object
);
} | // Function to check if an object is a LocationLink | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-language-client/src/common/codeConverter.ts#L676-L683 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | equals | function equals(
one: NotebookCell,
other: NotebookCell,
compareMetaData = true,
): boolean {
if (
one.kind !== other.kind ||
one.document.uri.toString() !== other.document.uri.toString() ||
one.document.languageId !== other.document.languageId ||
!equalsExecution(one.execution... | /**
* We only sync kind, document, execution and metadata to the server. So we only need to compare those.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-language-client/src/common/notebook.ts#L291-L308 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | asTextDcouemnt | function asTextDcouemnt(value: ls.TextDocumentIdentifier): TextDocument {
return {
uri: URI.parse(value.uri),
} as TextDocument;
} | // new | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-language-client/src/common/protocolConverter.ts#L2554-L2558 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | WorkspaceEdit.renameFile | renameFile(
from: vscode.Uri,
to: vscode.Uri,
options?: { readonly overwrite?: boolean; readonly ignoreIfExists?: boolean },
metadata?: vscode.WorkspaceEditEntryMetadata,
): void {
this._edits.push({ _type: FileEditType.File, from, to, options, metadata });
} | // --- file | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-language-client/src/common/vscodeAdaptor/extHostTypes.ts#L809-L816 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | WorkspaceEdit.replaceNotebookMetadata | private replaceNotebookMetadata(
uri: URI,
value: Record<string, any>,
metadata?: vscode.WorkspaceEditEntryMetadata,
): void {
this._edits.push({
_type: FileEditType.Cell,
metadata,
uri,
edit: { editType: CellEditType.DocumentMetadata, metadata: value },
notebookMetadata:... | // --- notebook | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-language-client/src/common/vscodeAdaptor/extHostTypes.ts#L852-L864 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | WorkspaceEdit.replace | replace(
uri: URI,
range: Range,
newText: string,
metadata?: vscode.WorkspaceEditEntryMetadata,
): void {
this._edits.push({
_type: FileEditType.Text,
uri,
edit: new TextEdit(range, newText),
metadata,
});
} | // --- text | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-language-client/src/common/vscodeAdaptor/extHostTypes.ts#L903-L915 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | WorkspaceEdit.has | has(uri: URI): boolean {
return this._edits.some(
(edit) =>
edit._type === FileEditType.Text && edit.uri.toString() === uri.toString(),
);
} | // --- text (Maplike) | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-language-client/src/common/vscodeAdaptor/extHostTypes.ts#L936-L941 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | DocumentConnectionManager.connection | protected async connection(
language: string,
languageServerId: TLanguageServerId,
uris: IURIs,
onCreate: (connection: LSPConnection) => void,
capabilities: LspClientCapabilities,
): Promise<LSPConnection> {
let connection = this._connections.get(languageServerId);
if (!connection) {
... | /**
* Return (or create and initialize) the WebSocket associated with the language
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/connection-manager.ts#L82-L109 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | DocumentConnectionManager.initialized | get initialized(): Event<IDocumentConnectionData> {
return this._initialized.event;
} | /**
* Signal emitted when the manager is initialized.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/connection-manager.ts#L149-L151 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | DocumentConnectionManager.connected | get connected(): Event<IDocumentConnectionData> {
return this._connected.event;
} | /**
* Signal emitted when the manager is connected to the server
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/connection-manager.ts#L156-L158 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | DocumentConnectionManager.disconnected | get disconnected(): Event<IDocumentConnectionData> {
return this._disconnected.event;
} | /**
* Connection temporarily lost or could not be fully established; a re-connection will be attempted;
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/connection-manager.ts#L163-L165 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | DocumentConnectionManager.closed | get closed(): Event<IDocumentConnectionData> {
return this._closed.event;
} | /**
* Connection was closed permanently and no-reconnection will be attempted, e.g.:
* - there was a serious server error
* - user closed the connection,
* - re-connection attempts exceeded,
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/connection-manager.ts#L173-L175 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | DocumentConnectionManager.documentsChanged | get documentsChanged(): Event<Map<VirtualDocument.uri, VirtualDocument>> {
return this._documentsChanged.event;
} | /**
* Signal emitted when the document is changed.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/connection-manager.ts#L180-L182 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | DocumentConnectionManager.ready | get ready(): Promise<void> {
return this.languageServerManager.ready;
} | /**
* Promise resolved when the language server manager is ready.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/connection-manager.ts#L187-L189 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | DocumentConnectionManager.solveUris | solveUris(virtualDocument: VirtualDocument, language: string): IURIs | undefined {
const wsBase = PageConfig.getBaseUrl().replace(/^http/, 'ws');
const rootUri = PageConfig.getOption('rootUri');
const virtualDocumentsUri = PageConfig.getOption('virtualDocumentsUri');
const baseUri = virtualDocument.has... | /**
* Generate the URI of a virtual document from input
*
* @param virtualDocument - the virtual document
* @param language - language of the document
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/connection-manager.ts#L197-L232 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | DocumentConnectionManager.connectDocumentSignals | connectDocumentSignals(virtualDocument: VirtualDocument): void {
virtualDocument.foreignDocumentOpened(this.onForeignDocumentOpened, this);
virtualDocument.foreignDocumentClosed(this.onForeignDocumentClosed, this);
this.documents.set(virtualDocument.uri, virtualDocument);
this._documentsChanged.fire(th... | /**
* Helper to connect various virtual document signal with callbacks of
* this class.
*
* @param virtualDocument - virtual document to be connected.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/connection-manager.ts#L240-L246 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | DocumentConnectionManager.disconnectDocumentSignals | disconnectDocumentSignals(virtualDocument: VirtualDocument, emit = true): void {
this.documents.delete(virtualDocument.uri);
for (const foreign of virtualDocument.foreignDocuments.values()) {
this.disconnectDocumentSignals(foreign, false);
}
if (emit) {
this._documentsChanged.fire(this.docu... | /**
* Helper to disconnect various virtual document signal with callbacks of
* this class.
*
* @param virtualDocument - virtual document to be disconnected.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/connection-manager.ts#L254-L263 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | DocumentConnectionManager.onForeignDocumentOpened | onForeignDocumentOpened(context: Document.IForeignContext): void {
/** no-op */
} | // eslint-disable-next-line @typescript-eslint/no-unused-vars | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/connection-manager.ts#L269-L271 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | DocumentConnectionManager.onForeignDocumentClosed | onForeignDocumentClosed(context: Document.IForeignContext): void {
const { foreignDocument } = context;
this.unregisterDocument(foreignDocument.uri, false);
this.disconnectDocumentSignals(foreignDocument);
} | /**
* Handle foreign document closed event.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/connection-manager.ts#L276-L280 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | DocumentConnectionManager.registerAdapter | registerAdapter(path: string, adapter: WidgetLSPAdapter<NotebookView>): void {
this.adapters.set(path, adapter);
adapter.onDispose(() => {
if (adapter.virtualDocument) {
this.documents.delete(adapter.virtualDocument.uri);
}
this.adapters.delete(path);
});
} | /**
* Register a widget adapter with this manager
*
* @param path - path to the inner document of the adapter
* @param adapter - the adapter to be registered
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/connection-manager.ts#L288-L296 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | DocumentConnectionManager.updateConfiguration | updateConfiguration(allServerSettings: TLanguageServerConfigurations): void {
this.languageServerManager.setConfiguration(allServerSettings);
} | /**
* Handles the settings that do not require an existing connection
* with a language server (or can influence to which server the
* connection will be created, e.g. `rank`).
*
* This function should be called **before** initialization of servers.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/connection-manager.ts#L305-L307 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | DocumentConnectionManager.updateServerConfigurations | updateServerConfigurations(allServerSettings: TLanguageServerConfigurations): void {
let languageServerId: TServerKeys;
for (languageServerId in allServerSettings) {
if (!Object.prototype.hasOwnProperty.call(allServerSettings, languageServerId)) {
continue;
}
const rawSettings = allSe... | /**
* Handles the settings that the language servers accept using
* `onDidChangeConfiguration` messages, which should be passed under
* the "serverSettings" keyword in the setting registry.
* Other configuration options are handled by `updateConfiguration` instead.
*
* This function should be called *... | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/connection-manager.ts#L317-L334 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | DocumentConnectionManager.onNewConnection | onNewConnection = (connection: LSPConnection): void => {
const errorSignalSlot = (e: any): void => {
console.error(e);
const error: Error = e.length && e.length >= 1 ? e[0] : new Error();
if (error.message.indexOf('code = 1005') !== -1) {
console.error(`Connection failed for ${connection}`... | /**
* Fired the first time a connection is opened. These _should_ be the only
* invocation of `.on` (once remaining LSPFeature.connection_handlers are made
* singletons).
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/connection-manager.ts | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | DocumentConnectionManager.retryToConnect | async retryToConnect(
options: ISocketConnectionOptions,
reconnectDelay: number,
retrialsLeft = -1,
): Promise<void> {
const { virtualDocument } = options;
if (this._ignoredLanguages.has(virtualDocument.language)) {
return;
}
let interval = reconnectDelay * 1000;
let success = ... | /**
* Retry to connect to the server each `reconnectDelay` seconds
* and for `retrialsLeft` times.
* TODO: presently no longer referenced. A failing connection would close
* the socket, triggering the language server on the other end to exit.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/connection-manager.ts#L392-L423 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | DocumentConnectionManager.disconnect | disconnect(languageId: TLanguageServerId): void {
this.disconnectServer(languageId);
} | /**
* Disconnect the connection to the language server of the requested
* language.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/connection-manager.ts#L429-L431 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | DocumentConnectionManager.connect | async connect(
options: ISocketConnectionOptions,
firstTimeoutSeconds = 30,
secondTimeoutMinutes = 5,
): Promise<ILSPConnection | undefined> {
const connection = await this._connectSocket(options);
const { virtualDocument } = options;
if (!connection) {
return;
}
if (!connection.... | /**
* Create a new connection to the language server
* @return A promise of the LSP connection
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/connection-manager.ts#L437-L476 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | DocumentConnectionManager.unregisterDocument | unregisterDocument(uri: string, emit = true): void {
const connection = this.connections.get(uri);
if (connection) {
this.connections.delete(uri);
const allConnection = new Set(this.connections.values());
if (!allConnection.has(connection)) {
this.disconnect(connection.serverIdentifie... | /**
* Disconnect the signals of requested virtual document uri.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/connection-manager.ts#L481-L495 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | DocumentConnectionManager.updateLogging | updateLogging(
logAllCommunication: boolean,
setTrace: AskServersToSendTraceNotifications,
): void {
for (const connection of this.connections.values()) {
connection.logAllCommunication = logAllCommunication;
if (setTrace !== null) {
connection.clientNotifications['$/setTrace'].fire({ ... | /**
* Enable or disable the logging feature of the language servers
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/connection-manager.ts#L500-L510 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | DocumentConnectionManager._connectSocket | protected async _connectSocket(
options: ISocketConnectionOptions,
): Promise<LSPConnection | undefined> {
const { language, capabilities, virtualDocument } = options;
this.connectDocumentSignals(virtualDocument);
const uris = this.solveUris(virtualDocument, language);
const matchingServers = th... | /**
* Create the LSP connection for requested virtual document.
*
* @return Return the promise of the LSP connection.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/connection-manager.ts#L518-L552 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | DocumentConnectionManager._forEachDocumentOfConnection | protected _forEachDocumentOfConnection(
connection: ILSPConnection,
callback: (virtualDocument: VirtualDocument) => void,
) {
for (const [virtualDocumentUri, currentConnection] of this.connections.entries()) {
if (connection !== currentConnection) {
continue;
}
callback(this.docu... | /**
* Helper to apply callback on all documents of a connection.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-lsp/src/connection-manager.ts#L557-L567 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.