@jupyterlab/outputarea 0.17.3 → 0.18.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/widget.d.ts +2 -1
- package/lib/widget.js +3 -3
- package/lib/widget.js.map +1 -1
- package/package.json +7 -7
package/lib/widget.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { JSONObject } from '@phosphor/coreutils';
|
|
1
2
|
import { Message } from '@phosphor/messaging';
|
|
2
3
|
import { Signal } from '@phosphor/signaling';
|
|
3
4
|
import { Widget } from '@phosphor/widgets';
|
|
@@ -133,7 +134,7 @@ export declare namespace OutputArea {
|
|
|
133
134
|
/**
|
|
134
135
|
* Execute code on an output area.
|
|
135
136
|
*/
|
|
136
|
-
function execute(code: string, output: OutputArea, session: IClientSession): Promise<KernelMessage.IExecuteReplyMsg>;
|
|
137
|
+
function execute(code: string, output: OutputArea, session: IClientSession, metadata?: JSONObject): Promise<KernelMessage.IExecuteReplyMsg>;
|
|
137
138
|
/**
|
|
138
139
|
* An output area widget content factory.
|
|
139
140
|
*
|
package/lib/widget.js
CHANGED
|
@@ -415,7 +415,7 @@ exports.SimplifiedOutputArea = SimplifiedOutputArea;
|
|
|
415
415
|
/**
|
|
416
416
|
* Execute code on an output area.
|
|
417
417
|
*/
|
|
418
|
-
function execute(code, output, session) {
|
|
418
|
+
function execute(code, output, session, metadata) {
|
|
419
419
|
// Override the default for `stop_on_error`.
|
|
420
420
|
let content = {
|
|
421
421
|
code,
|
|
@@ -424,7 +424,7 @@ exports.SimplifiedOutputArea = SimplifiedOutputArea;
|
|
|
424
424
|
if (!session.kernel) {
|
|
425
425
|
return Promise.reject('Session has no kernel.');
|
|
426
426
|
}
|
|
427
|
-
let future = session.kernel.requestExecute(content, false);
|
|
427
|
+
let future = session.kernel.requestExecute(content, false, metadata);
|
|
428
428
|
output.future = future;
|
|
429
429
|
return future.done;
|
|
430
430
|
}
|
|
@@ -476,7 +476,7 @@ class OutputPrompt extends widgets_2.Widget {
|
|
|
476
476
|
this.node.textContent = '';
|
|
477
477
|
}
|
|
478
478
|
else {
|
|
479
|
-
this.node.textContent = `
|
|
479
|
+
this.node.textContent = `[${value}]:`;
|
|
480
480
|
}
|
|
481
481
|
}
|
|
482
482
|
}
|
package/lib/widget.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget.js","sourceRoot":"","sources":["../../../../outputarea/src/widget.ts"],"names":[],"mappings":";AAAA,0CAA0C;AAC1C,2DAA2D;;AAE3D,mDAI6B;AAI7B,mDAA6C;AAE7C,+CAAuD;AAEvD,+CAA2C;AAU3C,mDAA6D;AAI7D;;GAEG;AACH,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAE1C;;GAEG;AACH,MAAM,sBAAsB,GAAG,qBAAqB,CAAC;AAErD;;GAEG;AACH,MAAM,wBAAwB,GAAG,sBAAsB,CAAC;AAExD;;GAEG;AACH,MAAM,wBAAwB,GAAG,sBAAsB,CAAC;AAExD;;GAEG;AACH,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AAE9C;;GAEG;AACH,MAAM,aAAa,GAAG,6BAA6B,CAAC;AAEpD;;GAEG;AACH,MAAM,4BAA4B,GAAG,0BAA0B,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,GAAG,UAAU,CAAC;AAE/B;;GAEG;AACH,MAAM,kBAAkB,GAAG,iBAAiB,CAAC;AAE7C;;GAEG;AACH,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAE3C;;gFAEgF;AAEhF;;;;;;;;GAQG;AACH,gBAAwB,SAAQ,gBAAM;IACpC;;OAEG;IACH,YAAY,OAA4B;QACtC,KAAK,EAAE,CAAC;QAqCV;;;;;;WAMG;QACM,wBAAmB,GAAG,IAAI,kBAAM,CAAe,IAAI,CAAC,CAAC;QA0Q9D;;WAEG;QACK,aAAQ,GAAG,CAAC,GAAgC,EAAE,EAAE;YACtD,IAAI,KAAK,GAA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AC,WAAW,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;gBAChD,IAAI,GAAG,GAAI,IAAI,CAAC,IAA0B,CAAC,aAAa,CAAC;gBACzD,IAAI,GAAG,EAAE;oBACP,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;iBACvB;YACH,CAAC,CAAC,CAAC;QACL,CAAC;KAGF;IA1DY,wBAAgB,mBA0D5B,CAAA;AACH,CAAC,EApFS,OAAO,KAAP,OAAO,QAoFhB","sourcesContent":["// Copyright (c) Jupyter Development Team.\n// Distributed under the terms of the Modified BSD License.\n\nimport {\n JSONObject,\n PromiseDelegate,\n ReadonlyJSONObject\n} from '@phosphor/coreutils';\n\nimport { Message } from '@phosphor/messaging';\n\nimport { Signal } from '@phosphor/signaling';\n\nimport { Panel, PanelLayout } from '@phosphor/widgets';\n\nimport { Widget } from '@phosphor/widgets';\n\nimport { IClientSession } from '@jupyterlab/apputils';\n\nimport { nbformat } from '@jupyterlab/coreutils';\n\nimport { IOutputModel, RenderMimeRegistry } from '@jupyterlab/rendermime';\n\nimport { IRenderMime } from '@jupyterlab/rendermime-interfaces';\n\nimport { Kernel, KernelMessage } from '@jupyterlab/services';\n\nimport { IOutputAreaModel } from './model';\n\n/**\n * The class name added to an output area widget.\n */\nconst OUTPUT_AREA_CLASS = 'jp-OutputArea';\n\n/**\n * The class name added to the direction children of OutputArea\n */\nconst OUTPUT_AREA_ITEM_CLASS = 'jp-OutputArea-child';\n\n/**\n * The class name added to actual outputs\n */\nconst OUTPUT_AREA_OUTPUT_CLASS = 'jp-OutputArea-output';\n\n/**\n * The class name added to prompt children of OutputArea.\n */\nconst OUTPUT_AREA_PROMPT_CLASS = 'jp-OutputArea-prompt';\n\n/**\n * The class name added to OutputPrompt.\n */\nconst OUTPUT_PROMPT_CLASS = 'jp-OutputPrompt';\n\n/**\n * The class name added to an execution result.\n */\nconst EXECUTE_CLASS = 'jp-OutputArea-executeResult';\n\n/**\n * The class name added stdin items of OutputArea\n */\nconst OUTPUT_AREA_STDIN_ITEM_CLASS = 'jp-OutputArea-stdin-item';\n\n/**\n * The class name added to stdin widgets.\n */\nconst STDIN_CLASS = 'jp-Stdin';\n\n/**\n * The class name added to stdin data prompt nodes.\n */\nconst STDIN_PROMPT_CLASS = 'jp-Stdin-prompt';\n\n/**\n * The class name added to stdin data input nodes.\n */\nconst STDIN_INPUT_CLASS = 'jp-Stdin-input';\n\n/******************************************************************************\n * OutputArea\n ******************************************************************************/\n\n/**\n * An output area widget.\n *\n * #### Notes\n * The widget model must be set separately and can be changed\n * at any time. Consumers of the widget must account for a\n * `null` model, and may want to listen to the `modelChanged`\n * signal.\n */\nexport class OutputArea extends Widget {\n /**\n * Construct an output area widget.\n */\n constructor(options: OutputArea.IOptions) {\n super();\n let model = (this.model = options.model);\n this.addClass(OUTPUT_AREA_CLASS);\n this.rendermime = options.rendermime;\n this.contentFactory =\n options.contentFactory || OutputArea.defaultContentFactory;\n this.layout = new PanelLayout();\n for (let i = 0; i < model.length; i++) {\n let output = model.get(i);\n this._insertOutput(i, output);\n }\n model.changed.connect(this.onModelChanged, this);\n model.stateChanged.connect(this.onStateChanged, this);\n }\n\n /**\n * The model used by the widget.\n */\n readonly model: IOutputAreaModel;\n\n /**\n * The content factory used by the widget.\n */\n readonly contentFactory: OutputArea.IContentFactory;\n\n /**\n * The rendermime instance used by the widget.\n */\n readonly rendermime: RenderMimeRegistry;\n\n /**\n * A read-only sequence of the chidren widgets in the output area.\n */\n get widgets(): ReadonlyArray<Widget> {\n return (this.layout as PanelLayout).widgets;\n }\n\n /**\n * A public signal used to indicate the number of outputs has changed.\n *\n * #### Notes\n * This is useful for parents who want to apply styling based on the number\n * of outputs. Emits the current number of outputs.\n */\n readonly outputLengthChanged = new Signal<this, number>(this);\n\n /**\n * The kernel future associated with the output area.\n */\n get future(): Kernel.IFuture {\n return this._future;\n }\n\n set future(value: Kernel.IFuture) {\n // Bail if the model is disposed.\n if (this.model.isDisposed) {\n throw Error('Model is disposed');\n }\n if (this._future === value) {\n return;\n }\n if (this._future) {\n this._future.dispose();\n }\n this._future = value;\n\n this.model.clear();\n\n // Make sure there were no input widgets.\n if (this.widgets.length) {\n this._clear();\n this.outputLengthChanged.emit(this.model.length);\n }\n\n // Handle published messages.\n value.onIOPub = this._onIOPub;\n\n // Handle the execute reply.\n value.onReply = this._onExecuteReply;\n\n // Handle stdin.\n value.onStdin = msg => {\n if (KernelMessage.isInputRequestMsg(msg)) {\n this.onInputRequest(msg, value);\n }\n };\n }\n\n /**\n * Dispose of the resources used by the output area.\n */\n dispose(): void {\n if (this._future) {\n this._future.dispose();\n }\n this._future = null;\n this._displayIdMap.clear();\n super.dispose();\n }\n\n /**\n * Follow changes on the model state.\n */\n protected onModelChanged(\n sender: IOutputAreaModel,\n args: IOutputAreaModel.ChangedArgs\n ): void {\n switch (args.type) {\n case 'add':\n this._insertOutput(args.newIndex, args.newValues[0]);\n this.outputLengthChanged.emit(this.model.length);\n break;\n case 'remove':\n // Only clear is supported by the model.\n if (this.widgets.length) {\n this._clear();\n this.outputLengthChanged.emit(this.model.length);\n }\n break;\n case 'set':\n this._setOutput(args.newIndex, args.newValues[0]);\n this.outputLengthChanged.emit(this.model.length);\n break;\n default:\n break;\n }\n }\n\n /**\n * Follow changes on the output model state.\n */\n protected onStateChanged(sender: IOutputAreaModel): void {\n for (let i = 0; i < this.model.length; i++) {\n this._setOutput(i, this.model.get(i));\n }\n this.outputLengthChanged.emit(this.model.length);\n }\n\n /**\n * Clear the widget inputs and outputs.\n */\n private _clear(): void {\n // Bail if there is no work to do.\n if (!this.widgets.length) {\n return;\n }\n\n // Remove all of our widgets.\n let length = this.widgets.length;\n for (let i = 0; i < length; i++) {\n let widget = this.widgets[0];\n widget.parent = null;\n widget.dispose();\n }\n\n // Clear the display id map.\n this._displayIdMap.clear();\n\n // When an output area is cleared and then quickly replaced with new\n // content (as happens with @interact in widgets, for example), the\n // quickly changing height can make the page jitter.\n // We introduce a small delay in the minimum height\n // to prevent this jitter.\n let rect = this.node.getBoundingClientRect();\n this.node.style.minHeight = `${rect.height}px`;\n if (this._minHeightTimeout) {\n clearTimeout(this._minHeightTimeout);\n }\n this._minHeightTimeout = window.setTimeout(() => {\n if (this.isDisposed) {\n return;\n }\n this.node.style.minHeight = '';\n }, 50);\n }\n\n /**\n * Handle an input request from a kernel.\n */\n protected onInputRequest(\n msg: KernelMessage.IInputRequestMsg,\n future: Kernel.IFuture\n ): void {\n // Add an output widget to the end.\n let factory = this.contentFactory;\n let stdinPrompt = msg.content.prompt;\n let password = msg.content.password;\n\n let panel = new Panel();\n panel.addClass(OUTPUT_AREA_ITEM_CLASS);\n panel.addClass(OUTPUT_AREA_STDIN_ITEM_CLASS);\n\n let prompt = factory.createOutputPrompt();\n prompt.addClass(OUTPUT_AREA_PROMPT_CLASS);\n panel.addWidget(prompt);\n\n let input = factory.createStdin({ prompt: stdinPrompt, password, future });\n input.addClass(OUTPUT_AREA_OUTPUT_CLASS);\n panel.addWidget(input);\n\n let layout = this.layout as PanelLayout;\n layout.addWidget(panel);\n\n /**\n * Wait for the stdin to complete, add it to the model (so it persists)\n * and remove the stdin widget.\n */\n input.value.then(value => {\n // Use stdin as the stream so it does not get combined with stdout.\n this.model.add({\n output_type: 'stream',\n name: 'stdin',\n text: value + '\\n'\n });\n panel.dispose();\n });\n }\n\n /**\n * Update an output in the layout in place.\n */\n private _setOutput(index: number, model: IOutputModel): void {\n let layout = this.layout as PanelLayout;\n let panel = layout.widgets[index] as Panel;\n let renderer = (panel.widgets\n ? panel.widgets[1]\n : panel) as IRenderMime.IRenderer;\n if (renderer.renderModel) {\n renderer.renderModel(model);\n } else {\n layout.widgets[index].dispose();\n this._insertOutput(index, model);\n }\n }\n\n /**\n * Render and insert a single output into the layout.\n */\n private _insertOutput(index: number, model: IOutputModel): void {\n let output = this.createOutputItem(model);\n output.toggleClass(EXECUTE_CLASS, model.executionCount !== null);\n let layout = this.layout as PanelLayout;\n layout.insertWidget(index, output);\n }\n\n /**\n * Create an output item with a prompt and actual output\n */\n protected createOutputItem(model: IOutputModel): Widget {\n let panel = new Panel();\n panel.addClass(OUTPUT_AREA_ITEM_CLASS);\n\n let prompt = this.contentFactory.createOutputPrompt();\n prompt.executionCount = model.executionCount;\n prompt.addClass(OUTPUT_AREA_PROMPT_CLASS);\n panel.addWidget(prompt);\n\n let output = this.createRenderedMimetype(model);\n output.addClass(OUTPUT_AREA_OUTPUT_CLASS);\n panel.addWidget(output);\n\n return panel;\n }\n\n /**\n * Render a mimetype\n */\n protected createRenderedMimetype(model: IOutputModel): Widget {\n let widget: Widget;\n let mimeType = this.rendermime.preferredMimeType(\n model.data,\n model.trusted ? 'any' : 'ensure'\n );\n if (mimeType) {\n let metadata = model.metadata;\n let mimeMd = metadata[mimeType] as ReadonlyJSONObject;\n let isolated = false;\n // mime-specific higher priority\n if (mimeMd && mimeMd['isolated'] !== undefined) {\n isolated = mimeMd['isolated'] as boolean;\n } else {\n // fallback on global\n isolated = metadata['isolated'] as boolean;\n }\n\n let output = this.rendermime.createRenderer(mimeType);\n if (isolated === true) {\n output = new Private.IsolatedRenderer(output);\n }\n output.renderModel(model).catch(error => {\n // Manually append error message to output\n output.node.innerHTML = `<pre>Javascript Error: ${error.message}</pre>`;\n // Remove mime-type-specific CSS classes\n output.node.className = 'p-Widget jp-RenderedText';\n output.node.setAttribute(\n 'data-mime-type',\n 'application/vnd.jupyter.stderr'\n );\n });\n widget = output;\n } else {\n widget = new Widget();\n widget.node.innerHTML =\n `No ${model.trusted ? '' : '(safe) '}renderer could be ` +\n 'found for output. It has the following MIME types: ' +\n Object.keys(model.data).join(', ');\n }\n return widget;\n }\n\n /**\n * Handle an iopub message.\n */\n private _onIOPub = (msg: KernelMessage.IIOPubMessage) => {\n let model = this.model;\n let msgType = msg.header.msg_type;\n let output: nbformat.IOutput;\n let transient = (msg.content.transient || {}) as JSONObject;\n let displayId = transient['display_id'] as string;\n let targets: number[];\n\n switch (msgType) {\n case 'execute_result':\n case 'display_data':\n case 'stream':\n case 'error':\n output = msg.content as nbformat.IOutput;\n output.output_type = msgType as nbformat.OutputType;\n model.add(output);\n break;\n case 'clear_output':\n let wait = (msg as KernelMessage.IClearOutputMsg).content.wait;\n model.clear(wait);\n break;\n case 'update_display_data':\n output = msg.content as nbformat.IOutput;\n output.output_type = 'display_data';\n targets = this._displayIdMap.get(displayId);\n if (targets) {\n for (let index of targets) {\n model.set(index, output);\n }\n }\n break;\n default:\n break;\n }\n if (displayId && msgType === 'display_data') {\n targets = this._displayIdMap.get(displayId) || [];\n targets.push(model.length - 1);\n this._displayIdMap.set(displayId, targets);\n }\n };\n\n /**\n * Handle an execute reply message.\n */\n private _onExecuteReply = (msg: KernelMessage.IExecuteReplyMsg) => {\n // API responses that contain a pager are special cased and their type\n // is overridden from 'execute_reply' to 'display_data' in order to\n // render output.\n let model = this.model;\n let content = msg.content as KernelMessage.IExecuteOkReply;\n let payload = content && content.payload;\n if (!payload || !payload.length) {\n return;\n }\n let pages = payload.filter((i: any) => (i as any).source === 'page');\n if (!pages.length) {\n return;\n }\n let page = JSON.parse(JSON.stringify(pages[0]));\n let output: nbformat.IOutput = {\n output_type: 'display_data',\n data: (page as any).data as nbformat.IMimeBundle,\n metadata: {}\n };\n model.add(output);\n };\n\n private _minHeightTimeout: number = null;\n private _future: Kernel.IFuture = null;\n private _displayIdMap = new Map<string, number[]>();\n}\n\nexport class SimplifiedOutputArea extends OutputArea {\n /**\n * Handle an input request from a kernel by doing nothing.\n */\n protected onInputRequest(\n msg: KernelMessage.IInputRequestMsg,\n future: Kernel.IFuture\n ): void {\n return;\n }\n\n /**\n * Create an output item without a prompt, just the output widgets\n */\n protected createOutputItem(model: IOutputModel): Widget {\n let output = this.createRenderedMimetype(model);\n output.addClass(OUTPUT_AREA_OUTPUT_CLASS);\n return output;\n }\n}\n\n/**\n * A namespace for OutputArea statics.\n */\nexport namespace OutputArea {\n /**\n * The options to create an `OutputArea`.\n */\n export interface IOptions {\n /**\n * The model used by the widget.\n */\n model: IOutputAreaModel;\n\n /**\n * The content factory used by the widget to create children.\n */\n contentFactory?: IContentFactory;\n\n /**\n * The rendermime instance used by the widget.\n */\n rendermime: RenderMimeRegistry;\n }\n\n /**\n * Execute code on an output area.\n */\n export function execute(\n code: string,\n output: OutputArea,\n session: IClientSession\n ): Promise<KernelMessage.IExecuteReplyMsg> {\n // Override the default for `stop_on_error`.\n let content: KernelMessage.IExecuteRequest = {\n code,\n stop_on_error: true\n };\n\n if (!session.kernel) {\n return Promise.reject('Session has no kernel.');\n }\n let future = session.kernel.requestExecute(content, false);\n output.future = future;\n return future.done as Promise<KernelMessage.IExecuteReplyMsg>;\n }\n\n /**\n * An output area widget content factory.\n *\n * The content factory is used to create children in a way\n * that can be customized.\n */\n export interface IContentFactory {\n /**\n * Create an output prompt.\n */\n createOutputPrompt(): IOutputPrompt;\n\n /**\n * Create an stdin widget.\n */\n createStdin(options: Stdin.IOptions): IStdin;\n }\n\n /**\n * The default implementation of `IContentFactory`.\n */\n export class ContentFactory implements IContentFactory {\n /**\n * Create the output prompt for the widget.\n */\n createOutputPrompt(): IOutputPrompt {\n return new OutputPrompt();\n }\n\n /**\n * Create an stdin widget.\n */\n createStdin(options: Stdin.IOptions): IStdin {\n return new Stdin(options);\n }\n }\n\n /**\n * The default `ContentFactory` instance.\n */\n export const defaultContentFactory = new ContentFactory();\n}\n\n/******************************************************************************\n * OutputPrompt\n ******************************************************************************/\n\n/**\n * The interface for an output prompt.\n */\nexport interface IOutputPrompt extends Widget {\n /**\n * The execution count for the prompt.\n */\n executionCount: nbformat.ExecutionCount;\n}\n\n/**\n * The default output prompt implementation\n */\nexport class OutputPrompt extends Widget implements IOutputPrompt {\n /*\n * Create an output prompt widget.\n */\n constructor() {\n super();\n this.addClass(OUTPUT_PROMPT_CLASS);\n }\n\n /**\n * The execution count for the prompt.\n */\n get executionCount(): nbformat.ExecutionCount {\n return this._executionCount;\n }\n set executionCount(value: nbformat.ExecutionCount) {\n this._executionCount = value;\n if (value === null) {\n this.node.textContent = '';\n } else {\n this.node.textContent = `Out[${value}]:`;\n }\n }\n\n private _executionCount: nbformat.ExecutionCount = null;\n}\n\n/******************************************************************************\n * Stdin\n ******************************************************************************/\n\n/**\n * The stdin interface\n */\nexport interface IStdin extends Widget {\n /**\n * The stdin value.\n */\n readonly value: Promise<string>;\n}\n\n/**\n * The default stdin widget.\n */\nexport class Stdin extends Widget implements IStdin {\n /**\n * Construct a new input widget.\n */\n constructor(options: Stdin.IOptions) {\n super({\n node: Private.createInputWidgetNode(options.prompt, options.password)\n });\n this.addClass(STDIN_CLASS);\n this._input = this.node.getElementsByTagName('input')[0];\n this._input.focus();\n this._future = options.future;\n this._value = options.prompt + ' ';\n }\n\n /**\n * The value of the widget.\n */\n get value() {\n return this._promise.promise.then(() => this._value);\n }\n\n /**\n * Handle the DOM events for the widget.\n *\n * @param event - The DOM event sent to the widget.\n *\n * #### Notes\n * This method implements the DOM `EventListener` interface and is\n * called in response to events on the dock panel's node. It should\n * not be called directly by user code.\n */\n handleEvent(event: Event): void {\n let input = this._input;\n if (event.type === 'keydown') {\n if ((event as KeyboardEvent).keyCode === 13) {\n // Enter\n this._future.sendInputReply({\n value: input.value\n });\n if (input.type === 'password') {\n this._value += Array(input.value.length + 1).join('·');\n } else {\n this._value += input.value;\n }\n this._promise.resolve(void 0);\n }\n }\n }\n\n /**\n * Handle `after-attach` messages sent to the widget.\n */\n protected onAfterAttach(msg: Message): void {\n this._input.addEventListener('keydown', this);\n this.update();\n }\n\n /**\n * Handle `update-request` messages sent to the widget.\n */\n protected onUpdateRequest(msg: Message): void {\n this._input.focus();\n }\n\n /**\n * Handle `before-detach` messages sent to the widget.\n */\n protected onBeforeDetach(msg: Message): void {\n this._input.removeEventListener('keydown', this);\n }\n\n private _future: Kernel.IFuture = null;\n private _input: HTMLInputElement = null;\n private _value: string;\n private _promise = new PromiseDelegate<void>();\n}\n\nexport namespace Stdin {\n /**\n * The options to create a stdin widget.\n */\n export interface IOptions {\n /**\n * The prompt text.\n */\n prompt: string;\n\n /**\n * Whether the input is a password.\n */\n password: boolean;\n\n /**\n * The kernel future associated with the request.\n */\n future: Kernel.IFuture;\n }\n}\n\n/******************************************************************************\n * Private namespace\n ******************************************************************************/\n\n/**\n * A namespace for private data.\n */\nnamespace Private {\n /**\n * Create the node for an InputWidget.\n */\n export function createInputWidgetNode(\n prompt: string,\n password: boolean\n ): HTMLElement {\n let node = document.createElement('div');\n let promptNode = document.createElement('pre');\n promptNode.className = STDIN_PROMPT_CLASS;\n promptNode.textContent = prompt;\n let input = document.createElement('input');\n input.className = STDIN_INPUT_CLASS;\n if (password) {\n input.type = 'password';\n }\n node.appendChild(promptNode);\n promptNode.appendChild(input);\n return node;\n }\n\n /**\n * A renderer for IFrame data.\n */\n export class IsolatedRenderer extends Widget\n implements IRenderMime.IRenderer {\n /**\n * Create an isolated renderer.\n */\n constructor(wrapped: IRenderMime.IRenderer) {\n super({ node: document.createElement('iframe') });\n this.addClass('jp-mod-isolated');\n\n this._wrapped = wrapped;\n\n // Once the iframe is loaded, the subarea is dynamically inserted\n let iframe = this.node as HTMLIFrameElement;\n\n iframe.frameBorder = '0';\n iframe.scrolling = 'auto';\n\n iframe.addEventListener('load', () => {\n // Workaround needed by Firefox, to properly render svg inside\n // iframes, see https://stackoverflow.com/questions/10177190/\n // svg-dynamically-added-to-iframe-does-not-render-correctly\n iframe.contentDocument.open();\n\n // Insert the subarea into the iframe\n // We must directly write the html. At this point, subarea doesn't\n // contain any user content.\n iframe.contentDocument.write(this._wrapped.node.innerHTML);\n\n iframe.contentDocument.close();\n\n let body = iframe.contentDocument.body;\n\n // Adjust the iframe height automatically\n iframe.style.height = body.scrollHeight + 'px';\n });\n }\n\n /**\n * Render a mime model.\n *\n * @param model - The mime model to render.\n *\n * @returns A promise which resolves when rendering is complete.\n *\n * #### Notes\n * This method may be called multiple times during the lifetime\n * of the widget to update it if and when new data is available.\n */\n renderModel(model: IRenderMime.IMimeModel): Promise<void> {\n return this._wrapped.renderModel(model).then(() => {\n let win = (this.node as HTMLIFrameElement).contentWindow;\n if (win) {\n win.location.reload();\n }\n });\n }\n\n private _wrapped: IRenderMime.IRenderer;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"widget.js","sourceRoot":"","sources":["../../../../outputarea/src/widget.ts"],"names":[],"mappings":";AAAA,0CAA0C;AAC1C,2DAA2D;;AAE3D,mDAI6B;AAI7B,mDAA6C;AAE7C,+CAAuD;AAEvD,+CAA2C;AAU3C,mDAA6D;AAI7D;;GAEG;AACH,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAE1C;;GAEG;AACH,MAAM,sBAAsB,GAAG,qBAAqB,CAAC;AAErD;;GAEG;AACH,MAAM,wBAAwB,GAAG,sBAAsB,CAAC;AAExD;;GAEG;AACH,MAAM,wBAAwB,GAAG,sBAAsB,CAAC;AAExD;;GAEG;AACH,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AAE9C;;GAEG;AACH,MAAM,aAAa,GAAG,6BAA6B,CAAC;AAEpD;;GAEG;AACH,MAAM,4BAA4B,GAAG,0BAA0B,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,GAAG,UAAU,CAAC;AAE/B;;GAEG;AACH,MAAM,kBAAkB,GAAG,iBAAiB,CAAC;AAE7C;;GAEG;AACH,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAE3C;;gFAEgF;AAEhF;;;;;;;;GAQG;AACH,gBAAwB,SAAQ,gBAAM;IACpC;;OAEG;IACH,YAAY,OAA4B;QACtC,KAAK,EAAE,CAAC;QAqCV;;;;;;WAMG;QACM,wBAAmB,GAAG,IAAI,kBAAM,CAAe,IAAI,CAAC,CAAC;QA0Q9D;;WAEG;QACK,aAAQ,GAAG,CAAC,GAAgC,EAAE,EAAE;YACtD,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;YACvB,IAAI,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC;YAClC,IAAI,MA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AI,IAAI,CAAC,IAA0B,CAAC,aAAa,CAAC;gBACzD,IAAI,GAAG,EAAE;oBACP,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;iBACvB;YACH,CAAC,CAAC,CAAC;QACL,CAAC;KAGF;IA1DY,wBAAgB,mBA0D5B,CAAA;AACH,CAAC,EApFS,OAAO,KAAP,OAAO,QAoFhB","sourcesContent":["// Copyright (c) Jupyter Development Team.\n// Distributed under the terms of the Modified BSD License.\n\nimport {\n JSONObject,\n PromiseDelegate,\n ReadonlyJSONObject\n} from '@phosphor/coreutils';\n\nimport { Message } from '@phosphor/messaging';\n\nimport { Signal } from '@phosphor/signaling';\n\nimport { Panel, PanelLayout } from '@phosphor/widgets';\n\nimport { Widget } from '@phosphor/widgets';\n\nimport { IClientSession } from '@jupyterlab/apputils';\n\nimport { nbformat } from '@jupyterlab/coreutils';\n\nimport { IOutputModel, RenderMimeRegistry } from '@jupyterlab/rendermime';\n\nimport { IRenderMime } from '@jupyterlab/rendermime-interfaces';\n\nimport { Kernel, KernelMessage } from '@jupyterlab/services';\n\nimport { IOutputAreaModel } from './model';\n\n/**\n * The class name added to an output area widget.\n */\nconst OUTPUT_AREA_CLASS = 'jp-OutputArea';\n\n/**\n * The class name added to the direction children of OutputArea\n */\nconst OUTPUT_AREA_ITEM_CLASS = 'jp-OutputArea-child';\n\n/**\n * The class name added to actual outputs\n */\nconst OUTPUT_AREA_OUTPUT_CLASS = 'jp-OutputArea-output';\n\n/**\n * The class name added to prompt children of OutputArea.\n */\nconst OUTPUT_AREA_PROMPT_CLASS = 'jp-OutputArea-prompt';\n\n/**\n * The class name added to OutputPrompt.\n */\nconst OUTPUT_PROMPT_CLASS = 'jp-OutputPrompt';\n\n/**\n * The class name added to an execution result.\n */\nconst EXECUTE_CLASS = 'jp-OutputArea-executeResult';\n\n/**\n * The class name added stdin items of OutputArea\n */\nconst OUTPUT_AREA_STDIN_ITEM_CLASS = 'jp-OutputArea-stdin-item';\n\n/**\n * The class name added to stdin widgets.\n */\nconst STDIN_CLASS = 'jp-Stdin';\n\n/**\n * The class name added to stdin data prompt nodes.\n */\nconst STDIN_PROMPT_CLASS = 'jp-Stdin-prompt';\n\n/**\n * The class name added to stdin data input nodes.\n */\nconst STDIN_INPUT_CLASS = 'jp-Stdin-input';\n\n/******************************************************************************\n * OutputArea\n ******************************************************************************/\n\n/**\n * An output area widget.\n *\n * #### Notes\n * The widget model must be set separately and can be changed\n * at any time. Consumers of the widget must account for a\n * `null` model, and may want to listen to the `modelChanged`\n * signal.\n */\nexport class OutputArea extends Widget {\n /**\n * Construct an output area widget.\n */\n constructor(options: OutputArea.IOptions) {\n super();\n let model = (this.model = options.model);\n this.addClass(OUTPUT_AREA_CLASS);\n this.rendermime = options.rendermime;\n this.contentFactory =\n options.contentFactory || OutputArea.defaultContentFactory;\n this.layout = new PanelLayout();\n for (let i = 0; i < model.length; i++) {\n let output = model.get(i);\n this._insertOutput(i, output);\n }\n model.changed.connect(this.onModelChanged, this);\n model.stateChanged.connect(this.onStateChanged, this);\n }\n\n /**\n * The model used by the widget.\n */\n readonly model: IOutputAreaModel;\n\n /**\n * The content factory used by the widget.\n */\n readonly contentFactory: OutputArea.IContentFactory;\n\n /**\n * The rendermime instance used by the widget.\n */\n readonly rendermime: RenderMimeRegistry;\n\n /**\n * A read-only sequence of the chidren widgets in the output area.\n */\n get widgets(): ReadonlyArray<Widget> {\n return (this.layout as PanelLayout).widgets;\n }\n\n /**\n * A public signal used to indicate the number of outputs has changed.\n *\n * #### Notes\n * This is useful for parents who want to apply styling based on the number\n * of outputs. Emits the current number of outputs.\n */\n readonly outputLengthChanged = new Signal<this, number>(this);\n\n /**\n * The kernel future associated with the output area.\n */\n get future(): Kernel.IFuture {\n return this._future;\n }\n\n set future(value: Kernel.IFuture) {\n // Bail if the model is disposed.\n if (this.model.isDisposed) {\n throw Error('Model is disposed');\n }\n if (this._future === value) {\n return;\n }\n if (this._future) {\n this._future.dispose();\n }\n this._future = value;\n\n this.model.clear();\n\n // Make sure there were no input widgets.\n if (this.widgets.length) {\n this._clear();\n this.outputLengthChanged.emit(this.model.length);\n }\n\n // Handle published messages.\n value.onIOPub = this._onIOPub;\n\n // Handle the execute reply.\n value.onReply = this._onExecuteReply;\n\n // Handle stdin.\n value.onStdin = msg => {\n if (KernelMessage.isInputRequestMsg(msg)) {\n this.onInputRequest(msg, value);\n }\n };\n }\n\n /**\n * Dispose of the resources used by the output area.\n */\n dispose(): void {\n if (this._future) {\n this._future.dispose();\n }\n this._future = null;\n this._displayIdMap.clear();\n super.dispose();\n }\n\n /**\n * Follow changes on the model state.\n */\n protected onModelChanged(\n sender: IOutputAreaModel,\n args: IOutputAreaModel.ChangedArgs\n ): void {\n switch (args.type) {\n case 'add':\n this._insertOutput(args.newIndex, args.newValues[0]);\n this.outputLengthChanged.emit(this.model.length);\n break;\n case 'remove':\n // Only clear is supported by the model.\n if (this.widgets.length) {\n this._clear();\n this.outputLengthChanged.emit(this.model.length);\n }\n break;\n case 'set':\n this._setOutput(args.newIndex, args.newValues[0]);\n this.outputLengthChanged.emit(this.model.length);\n break;\n default:\n break;\n }\n }\n\n /**\n * Follow changes on the output model state.\n */\n protected onStateChanged(sender: IOutputAreaModel): void {\n for (let i = 0; i < this.model.length; i++) {\n this._setOutput(i, this.model.get(i));\n }\n this.outputLengthChanged.emit(this.model.length);\n }\n\n /**\n * Clear the widget inputs and outputs.\n */\n private _clear(): void {\n // Bail if there is no work to do.\n if (!this.widgets.length) {\n return;\n }\n\n // Remove all of our widgets.\n let length = this.widgets.length;\n for (let i = 0; i < length; i++) {\n let widget = this.widgets[0];\n widget.parent = null;\n widget.dispose();\n }\n\n // Clear the display id map.\n this._displayIdMap.clear();\n\n // When an output area is cleared and then quickly replaced with new\n // content (as happens with @interact in widgets, for example), the\n // quickly changing height can make the page jitter.\n // We introduce a small delay in the minimum height\n // to prevent this jitter.\n let rect = this.node.getBoundingClientRect();\n this.node.style.minHeight = `${rect.height}px`;\n if (this._minHeightTimeout) {\n clearTimeout(this._minHeightTimeout);\n }\n this._minHeightTimeout = window.setTimeout(() => {\n if (this.isDisposed) {\n return;\n }\n this.node.style.minHeight = '';\n }, 50);\n }\n\n /**\n * Handle an input request from a kernel.\n */\n protected onInputRequest(\n msg: KernelMessage.IInputRequestMsg,\n future: Kernel.IFuture\n ): void {\n // Add an output widget to the end.\n let factory = this.contentFactory;\n let stdinPrompt = msg.content.prompt;\n let password = msg.content.password;\n\n let panel = new Panel();\n panel.addClass(OUTPUT_AREA_ITEM_CLASS);\n panel.addClass(OUTPUT_AREA_STDIN_ITEM_CLASS);\n\n let prompt = factory.createOutputPrompt();\n prompt.addClass(OUTPUT_AREA_PROMPT_CLASS);\n panel.addWidget(prompt);\n\n let input = factory.createStdin({ prompt: stdinPrompt, password, future });\n input.addClass(OUTPUT_AREA_OUTPUT_CLASS);\n panel.addWidget(input);\n\n let layout = this.layout as PanelLayout;\n layout.addWidget(panel);\n\n /**\n * Wait for the stdin to complete, add it to the model (so it persists)\n * and remove the stdin widget.\n */\n input.value.then(value => {\n // Use stdin as the stream so it does not get combined with stdout.\n this.model.add({\n output_type: 'stream',\n name: 'stdin',\n text: value + '\\n'\n });\n panel.dispose();\n });\n }\n\n /**\n * Update an output in the layout in place.\n */\n private _setOutput(index: number, model: IOutputModel): void {\n let layout = this.layout as PanelLayout;\n let panel = layout.widgets[index] as Panel;\n let renderer = (panel.widgets\n ? panel.widgets[1]\n : panel) as IRenderMime.IRenderer;\n if (renderer.renderModel) {\n renderer.renderModel(model);\n } else {\n layout.widgets[index].dispose();\n this._insertOutput(index, model);\n }\n }\n\n /**\n * Render and insert a single output into the layout.\n */\n private _insertOutput(index: number, model: IOutputModel): void {\n let output = this.createOutputItem(model);\n output.toggleClass(EXECUTE_CLASS, model.executionCount !== null);\n let layout = this.layout as PanelLayout;\n layout.insertWidget(index, output);\n }\n\n /**\n * Create an output item with a prompt and actual output\n */\n protected createOutputItem(model: IOutputModel): Widget {\n let panel = new Panel();\n panel.addClass(OUTPUT_AREA_ITEM_CLASS);\n\n let prompt = this.contentFactory.createOutputPrompt();\n prompt.executionCount = model.executionCount;\n prompt.addClass(OUTPUT_AREA_PROMPT_CLASS);\n panel.addWidget(prompt);\n\n let output = this.createRenderedMimetype(model);\n output.addClass(OUTPUT_AREA_OUTPUT_CLASS);\n panel.addWidget(output);\n\n return panel;\n }\n\n /**\n * Render a mimetype\n */\n protected createRenderedMimetype(model: IOutputModel): Widget {\n let widget: Widget;\n let mimeType = this.rendermime.preferredMimeType(\n model.data,\n model.trusted ? 'any' : 'ensure'\n );\n if (mimeType) {\n let metadata = model.metadata;\n let mimeMd = metadata[mimeType] as ReadonlyJSONObject;\n let isolated = false;\n // mime-specific higher priority\n if (mimeMd && mimeMd['isolated'] !== undefined) {\n isolated = mimeMd['isolated'] as boolean;\n } else {\n // fallback on global\n isolated = metadata['isolated'] as boolean;\n }\n\n let output = this.rendermime.createRenderer(mimeType);\n if (isolated === true) {\n output = new Private.IsolatedRenderer(output);\n }\n output.renderModel(model).catch(error => {\n // Manually append error message to output\n output.node.innerHTML = `<pre>Javascript Error: ${error.message}</pre>`;\n // Remove mime-type-specific CSS classes\n output.node.className = 'p-Widget jp-RenderedText';\n output.node.setAttribute(\n 'data-mime-type',\n 'application/vnd.jupyter.stderr'\n );\n });\n widget = output;\n } else {\n widget = new Widget();\n widget.node.innerHTML =\n `No ${model.trusted ? '' : '(safe) '}renderer could be ` +\n 'found for output. It has the following MIME types: ' +\n Object.keys(model.data).join(', ');\n }\n return widget;\n }\n\n /**\n * Handle an iopub message.\n */\n private _onIOPub = (msg: KernelMessage.IIOPubMessage) => {\n let model = this.model;\n let msgType = msg.header.msg_type;\n let output: nbformat.IOutput;\n let transient = (msg.content.transient || {}) as JSONObject;\n let displayId = transient['display_id'] as string;\n let targets: number[];\n\n switch (msgType) {\n case 'execute_result':\n case 'display_data':\n case 'stream':\n case 'error':\n output = msg.content as nbformat.IOutput;\n output.output_type = msgType as nbformat.OutputType;\n model.add(output);\n break;\n case 'clear_output':\n let wait = (msg as KernelMessage.IClearOutputMsg).content.wait;\n model.clear(wait);\n break;\n case 'update_display_data':\n output = msg.content as nbformat.IOutput;\n output.output_type = 'display_data';\n targets = this._displayIdMap.get(displayId);\n if (targets) {\n for (let index of targets) {\n model.set(index, output);\n }\n }\n break;\n default:\n break;\n }\n if (displayId && msgType === 'display_data') {\n targets = this._displayIdMap.get(displayId) || [];\n targets.push(model.length - 1);\n this._displayIdMap.set(displayId, targets);\n }\n };\n\n /**\n * Handle an execute reply message.\n */\n private _onExecuteReply = (msg: KernelMessage.IExecuteReplyMsg) => {\n // API responses that contain a pager are special cased and their type\n // is overridden from 'execute_reply' to 'display_data' in order to\n // render output.\n let model = this.model;\n let content = msg.content as KernelMessage.IExecuteOkReply;\n let payload = content && content.payload;\n if (!payload || !payload.length) {\n return;\n }\n let pages = payload.filter((i: any) => (i as any).source === 'page');\n if (!pages.length) {\n return;\n }\n let page = JSON.parse(JSON.stringify(pages[0]));\n let output: nbformat.IOutput = {\n output_type: 'display_data',\n data: (page as any).data as nbformat.IMimeBundle,\n metadata: {}\n };\n model.add(output);\n };\n\n private _minHeightTimeout: number = null;\n private _future: Kernel.IFuture = null;\n private _displayIdMap = new Map<string, number[]>();\n}\n\nexport class SimplifiedOutputArea extends OutputArea {\n /**\n * Handle an input request from a kernel by doing nothing.\n */\n protected onInputRequest(\n msg: KernelMessage.IInputRequestMsg,\n future: Kernel.IFuture\n ): void {\n return;\n }\n\n /**\n * Create an output item without a prompt, just the output widgets\n */\n protected createOutputItem(model: IOutputModel): Widget {\n let output = this.createRenderedMimetype(model);\n output.addClass(OUTPUT_AREA_OUTPUT_CLASS);\n return output;\n }\n}\n\n/**\n * A namespace for OutputArea statics.\n */\nexport namespace OutputArea {\n /**\n * The options to create an `OutputArea`.\n */\n export interface IOptions {\n /**\n * The model used by the widget.\n */\n model: IOutputAreaModel;\n\n /**\n * The content factory used by the widget to create children.\n */\n contentFactory?: IContentFactory;\n\n /**\n * The rendermime instance used by the widget.\n */\n rendermime: RenderMimeRegistry;\n }\n\n /**\n * Execute code on an output area.\n */\n export function execute(\n code: string,\n output: OutputArea,\n session: IClientSession,\n metadata?: JSONObject\n ): Promise<KernelMessage.IExecuteReplyMsg> {\n // Override the default for `stop_on_error`.\n let content: KernelMessage.IExecuteRequest = {\n code,\n stop_on_error: true\n };\n\n if (!session.kernel) {\n return Promise.reject('Session has no kernel.');\n }\n let future = session.kernel.requestExecute(content, false, metadata);\n output.future = future;\n return future.done as Promise<KernelMessage.IExecuteReplyMsg>;\n }\n\n /**\n * An output area widget content factory.\n *\n * The content factory is used to create children in a way\n * that can be customized.\n */\n export interface IContentFactory {\n /**\n * Create an output prompt.\n */\n createOutputPrompt(): IOutputPrompt;\n\n /**\n * Create an stdin widget.\n */\n createStdin(options: Stdin.IOptions): IStdin;\n }\n\n /**\n * The default implementation of `IContentFactory`.\n */\n export class ContentFactory implements IContentFactory {\n /**\n * Create the output prompt for the widget.\n */\n createOutputPrompt(): IOutputPrompt {\n return new OutputPrompt();\n }\n\n /**\n * Create an stdin widget.\n */\n createStdin(options: Stdin.IOptions): IStdin {\n return new Stdin(options);\n }\n }\n\n /**\n * The default `ContentFactory` instance.\n */\n export const defaultContentFactory = new ContentFactory();\n}\n\n/******************************************************************************\n * OutputPrompt\n ******************************************************************************/\n\n/**\n * The interface for an output prompt.\n */\nexport interface IOutputPrompt extends Widget {\n /**\n * The execution count for the prompt.\n */\n executionCount: nbformat.ExecutionCount;\n}\n\n/**\n * The default output prompt implementation\n */\nexport class OutputPrompt extends Widget implements IOutputPrompt {\n /*\n * Create an output prompt widget.\n */\n constructor() {\n super();\n this.addClass(OUTPUT_PROMPT_CLASS);\n }\n\n /**\n * The execution count for the prompt.\n */\n get executionCount(): nbformat.ExecutionCount {\n return this._executionCount;\n }\n set executionCount(value: nbformat.ExecutionCount) {\n this._executionCount = value;\n if (value === null) {\n this.node.textContent = '';\n } else {\n this.node.textContent = `[${value}]:`;\n }\n }\n\n private _executionCount: nbformat.ExecutionCount = null;\n}\n\n/******************************************************************************\n * Stdin\n ******************************************************************************/\n\n/**\n * The stdin interface\n */\nexport interface IStdin extends Widget {\n /**\n * The stdin value.\n */\n readonly value: Promise<string>;\n}\n\n/**\n * The default stdin widget.\n */\nexport class Stdin extends Widget implements IStdin {\n /**\n * Construct a new input widget.\n */\n constructor(options: Stdin.IOptions) {\n super({\n node: Private.createInputWidgetNode(options.prompt, options.password)\n });\n this.addClass(STDIN_CLASS);\n this._input = this.node.getElementsByTagName('input')[0];\n this._input.focus();\n this._future = options.future;\n this._value = options.prompt + ' ';\n }\n\n /**\n * The value of the widget.\n */\n get value() {\n return this._promise.promise.then(() => this._value);\n }\n\n /**\n * Handle the DOM events for the widget.\n *\n * @param event - The DOM event sent to the widget.\n *\n * #### Notes\n * This method implements the DOM `EventListener` interface and is\n * called in response to events on the dock panel's node. It should\n * not be called directly by user code.\n */\n handleEvent(event: Event): void {\n let input = this._input;\n if (event.type === 'keydown') {\n if ((event as KeyboardEvent).keyCode === 13) {\n // Enter\n this._future.sendInputReply({\n value: input.value\n });\n if (input.type === 'password') {\n this._value += Array(input.value.length + 1).join('·');\n } else {\n this._value += input.value;\n }\n this._promise.resolve(void 0);\n }\n }\n }\n\n /**\n * Handle `after-attach` messages sent to the widget.\n */\n protected onAfterAttach(msg: Message): void {\n this._input.addEventListener('keydown', this);\n this.update();\n }\n\n /**\n * Handle `update-request` messages sent to the widget.\n */\n protected onUpdateRequest(msg: Message): void {\n this._input.focus();\n }\n\n /**\n * Handle `before-detach` messages sent to the widget.\n */\n protected onBeforeDetach(msg: Message): void {\n this._input.removeEventListener('keydown', this);\n }\n\n private _future: Kernel.IFuture = null;\n private _input: HTMLInputElement = null;\n private _value: string;\n private _promise = new PromiseDelegate<void>();\n}\n\nexport namespace Stdin {\n /**\n * The options to create a stdin widget.\n */\n export interface IOptions {\n /**\n * The prompt text.\n */\n prompt: string;\n\n /**\n * Whether the input is a password.\n */\n password: boolean;\n\n /**\n * The kernel future associated with the request.\n */\n future: Kernel.IFuture;\n }\n}\n\n/******************************************************************************\n * Private namespace\n ******************************************************************************/\n\n/**\n * A namespace for private data.\n */\nnamespace Private {\n /**\n * Create the node for an InputWidget.\n */\n export function createInputWidgetNode(\n prompt: string,\n password: boolean\n ): HTMLElement {\n let node = document.createElement('div');\n let promptNode = document.createElement('pre');\n promptNode.className = STDIN_PROMPT_CLASS;\n promptNode.textContent = prompt;\n let input = document.createElement('input');\n input.className = STDIN_INPUT_CLASS;\n if (password) {\n input.type = 'password';\n }\n node.appendChild(promptNode);\n promptNode.appendChild(input);\n return node;\n }\n\n /**\n * A renderer for IFrame data.\n */\n export class IsolatedRenderer extends Widget\n implements IRenderMime.IRenderer {\n /**\n * Create an isolated renderer.\n */\n constructor(wrapped: IRenderMime.IRenderer) {\n super({ node: document.createElement('iframe') });\n this.addClass('jp-mod-isolated');\n\n this._wrapped = wrapped;\n\n // Once the iframe is loaded, the subarea is dynamically inserted\n let iframe = this.node as HTMLIFrameElement;\n\n iframe.frameBorder = '0';\n iframe.scrolling = 'auto';\n\n iframe.addEventListener('load', () => {\n // Workaround needed by Firefox, to properly render svg inside\n // iframes, see https://stackoverflow.com/questions/10177190/\n // svg-dynamically-added-to-iframe-does-not-render-correctly\n iframe.contentDocument.open();\n\n // Insert the subarea into the iframe\n // We must directly write the html. At this point, subarea doesn't\n // contain any user content.\n iframe.contentDocument.write(this._wrapped.node.innerHTML);\n\n iframe.contentDocument.close();\n\n let body = iframe.contentDocument.body;\n\n // Adjust the iframe height automatically\n iframe.style.height = body.scrollHeight + 'px';\n });\n }\n\n /**\n * Render a mime model.\n *\n * @param model - The mime model to render.\n *\n * @returns A promise which resolves when rendering is complete.\n *\n * #### Notes\n * This method may be called multiple times during the lifetime\n * of the widget to update it if and when new data is available.\n */\n renderModel(model: IRenderMime.IMimeModel): Promise<void> {\n return this._wrapped.renderModel(model).then(() => {\n let win = (this.node as HTMLIFrameElement).contentWindow;\n if (win) {\n win.location.reload();\n }\n });\n }\n\n private _wrapped: IRenderMime.IRenderer;\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jupyterlab/outputarea",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.4",
|
|
4
4
|
"description": "JupyterLab - Notebook Output Area",
|
|
5
5
|
"homepage": "https://github.com/jupyterlab/jupyterlab",
|
|
6
6
|
"bugs": {
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
"watch": "tsc -w --listEmittedFiles"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@jupyterlab/apputils": "^0.
|
|
34
|
-
"@jupyterlab/coreutils": "^2.
|
|
35
|
-
"@jupyterlab/observables": "^2.0.
|
|
36
|
-
"@jupyterlab/rendermime": "^0.
|
|
37
|
-
"@jupyterlab/rendermime-interfaces": "^1.1.
|
|
38
|
-
"@jupyterlab/services": "^3.
|
|
33
|
+
"@jupyterlab/apputils": "^0.18.4",
|
|
34
|
+
"@jupyterlab/coreutils": "^2.1.4",
|
|
35
|
+
"@jupyterlab/observables": "^2.0.7",
|
|
36
|
+
"@jupyterlab/rendermime": "^0.18.4",
|
|
37
|
+
"@jupyterlab/rendermime-interfaces": "^1.1.7",
|
|
38
|
+
"@jupyterlab/services": "^3.1.4",
|
|
39
39
|
"@phosphor/algorithm": "^1.1.2",
|
|
40
40
|
"@phosphor/coreutils": "^1.3.0",
|
|
41
41
|
"@phosphor/disposable": "^1.1.2",
|