-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add interface to extension * Update readme and lite scripts * Update nx stuff * Remove caching * Add error dialog * Add additional command instructions to readme * Restructure host * Improve error messages * Implement suggestions
- Loading branch information
Showing
13 changed files
with
104 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ReadonlyPartialJSONObject } from '@lumino/coreutils'; | ||
|
||
/** | ||
* Represents a remote command bridge interface. | ||
* | ||
* This interface provides a standardized way to interact with a Jupyter environment contained in an iframe. | ||
*/ | ||
export interface ICommandBridgeRemote { | ||
/** | ||
* Executes a command with the given arguments. | ||
* | ||
* @param command - The name of the command to execute. | ||
* @param args - An object containing arguments for the command. | ||
*/ | ||
execute(command: string, args: ReadonlyPartialJSONObject): void; | ||
|
||
/** | ||
* Lists all available commands. | ||
* | ||
* @returns An array of strings representing the names of all available commands. | ||
*/ | ||
listCommands(): string[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,24 @@ | ||
// Copyright (c) TileDB, Inc. | ||
// Distributed under the terms of the Modified BSD License. | ||
import { Endpoint, Remote, windowEndpoint, wrap } from 'comlink'; | ||
|
||
import { windowEndpoint, wrap } from 'comlink'; | ||
import { ICommandBridgeRemote } from 'jupyter-iframe-commands'; | ||
/** | ||
* A bridge to expose actions on JupyterLab commands. | ||
*/ | ||
export class CommandBridge { | ||
constructor({ iframeId }: CommandBridge.IOptions) { | ||
this._iframe = document.getElementById(iframeId) as HTMLIFrameElement; | ||
|
||
if (!this._iframe) { | ||
console.error('iframe not found'); | ||
return; | ||
} | ||
|
||
this._childWindow = this._iframe.contentWindow; | ||
|
||
if (!this._childWindow) { | ||
console.error('child window not found'); | ||
return; | ||
} | ||
export function createBridge({ iframeId }: { iframeId: string }) { | ||
const iframe = document.getElementById(iframeId) as HTMLIFrameElement; | ||
|
||
this._endpoint = windowEndpoint(this._childWindow); | ||
this.commandBridge = wrap(this._endpoint); | ||
if (!iframe) { | ||
throw new Error( | ||
`Cannot create bridge: iframe with id "${iframeId}" not found` | ||
); | ||
} | ||
|
||
private _iframe: HTMLIFrameElement | null; | ||
private _childWindow: Window | undefined | null; | ||
private _endpoint: Endpoint | undefined; | ||
commandBridge: Remote<unknown> | undefined; | ||
} | ||
|
||
export namespace CommandBridge { | ||
export interface IOptions { | ||
iframeId: string; | ||
if (!iframe.contentWindow) { | ||
throw new Error( | ||
`Cannot create bridge: iframe with id "${iframeId}" has no content window` | ||
); | ||
} | ||
|
||
return wrap<ICommandBridgeRemote>(windowEndpoint(iframe.contentWindow)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters