Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jupyter-js-notebook

Package Overview
Dependencies
Maintainers
2
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jupyter-js-notebook - npm Package Compare versions

Comparing version 0.6.0 to 0.7.0

12

lib/notebook/model.d.ts

@@ -6,2 +6,3 @@ import { INotebookSession } from 'jupyter-js-services';

import { ICellModel, ICodeCellModel, CodeCellModel, IMarkdownCellModel } from '../cells';
import { NotebookMetadata } from './nbformat';
/**

@@ -109,2 +110,6 @@ * The interactivity modes for a notebook.

runSelectedCell(): void;
/**
* The metadata associated with the notebook.
*/
metadata: NotebookMetadata;
}

@@ -152,2 +157,9 @@ /**

/**
* Get the metadata for the notebook.
*/
/**
* Set the metadata for the notebook.
*/
metadata: NotebookMetadata;
/**
* Get the selected cell index.

@@ -154,0 +166,0 @@ */

27

lib/notebook/model.js

@@ -105,2 +105,18 @@ var phosphor_observablelist_1 = require('phosphor-observablelist');

});
Object.defineProperty(NotebookModel.prototype, "metadata", {
/**
* Get the metadata for the notebook.
*/
get: function () {
return NotebookModelPrivate.metadataProperty.get(this);
},
/**
* Set the metadata for the notebook.
*/
set: function (value) {
NotebookModelPrivate.metadataProperty.set(this, value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(NotebookModel.prototype, "selectedCellIndex", {

@@ -276,4 +292,4 @@ /**

/**
* A property descriptor which holds the session of the notebook.
*/
* A property descriptor which holds the session of the notebook.
*/
NotebookModelPrivate.sessionProperty = new phosphor_properties_1.Property({

@@ -284,2 +300,9 @@ name: 'session',

/**
* A property descriptor which holds the metadata of the notebook.
*/
NotebookModelPrivate.metadataProperty = new phosphor_properties_1.Property({
name: 'metadata',
notify: NotebookModelPrivate.stateChangedSignal,
});
/**
* A property descriptor for the selected cell index.

@@ -286,0 +309,0 @@ */

34

lib/notebook/nbformat.d.ts

@@ -72,17 +72,18 @@ import { MimeBundle } from '../output-area';

export declare function isCodeCell(d: BaseCell): d is CodeCell;
export interface Notebook {
metadata: {
kernelspec: {
name: string;
display_name: string;
};
language_info: {
name: string;
codemirror_mode?: string | {};
file_extension?: string;
mimetype?: string;
pygments_lexer?: string;
};
orig_nbformat?: number;
export interface NotebookMetadata {
kernelspec: {
name: string;
display_name: string;
};
language_info: {
name: string;
codemirror_mode?: string | {};
file_extension?: string;
mimetype?: string;
pygments_lexer?: string;
};
orig_nbformat?: number;
}
export interface NotebookContent {
metadata: NotebookMetadata;
nbformat_minor: number;

@@ -92,6 +93,1 @@ nbformat: number;

}
export interface NBData {
content: Notebook;
name: string;
path: string;
}
// Notebook format interfaces
// https://nbformat.readthedocs.org/en/latest/format_description.html
// https://github.com/jupyter/nbformat/blob/master/nbformat/v4/nbformat.v4.schema.json
/**

@@ -4,0 +5,0 @@ * The major version of the notebook format.

@@ -1,9 +0,9 @@

import { IContentsModel, IKernelMessage, IContentsManager } from 'jupyter-js-services';
import { IKernelMessage } from 'jupyter-js-services';
import { NotebookModel, INotebookModel } from './model';
import { DisplayDataModel, ExecuteResultModel, ExecuteErrorModel, StreamModel, OutputModel } from '../output-area';
import { NBData, Cell, Output } from './nbformat';
import { NotebookContent, Output } from './nbformat';
/**
* Build a complete notebook model from the notebook data.
*/
export declare function populateNotebookModel(nb: INotebookModel, data: NBData): void;
export declare function populateNotebookModel(nb: INotebookModel, data: NotebookContent): void;
/**

@@ -18,8 +18,4 @@ * Build an output model from output message data.

/**
* Save the current notebook state to disk.
* Get the current notebook content.
*/
export declare function saveNotebook(nb: NotebookModel, contents: IContentsManager): Promise<IContentsModel>;
/**
* Get the cell data for a given notebook.
*/
export declare function getNotebookData(nb: NotebookModel): Cell[];
export declare function getNotebookContent(nb: NotebookModel): NotebookContent;

@@ -15,3 +15,3 @@ // Copyright (c) Jupyter Development Team.

// iterate through the cell data, creating cell models
data.content.cells.forEach(function (c) {
data.cells.forEach(function (c) {
var input = new input_area_1.InputAreaModel();

@@ -41,2 +41,3 @@ input.textEditor = new editor_1.EditorModel({ lineNumbers: false });

}
nb.metadata = data.metadata;
}

@@ -101,28 +102,17 @@ exports.populateNotebookModel = populateNotebookModel;

/**
* Save the current notebook state to disk.
* Get the current notebook content.
*/
function saveNotebook(nb, contents) {
if (!nb.session) {
Promise.reject('No notebook session');
}
var cells = getNotebookData(nb);
return nb.session.kernel.kernelInfo().then(function (info) {
var name = nb.session.kernel.name;
// TODO: Get the display name.
var metadata = { kernelspec: { name: name, display_name: name },
language_info: info.language_info
};
var notebook = { cells: cells, metadata: metadata, nbformat: nbformat_1.MAJOR_VERSION,
nbformat_minor: nbformat_1.MINOR_VERSION };
return contents.save(nb.session.notebookPath, {
type: 'notebook',
content: notebook
});
});
function getNotebookContent(nb) {
return {
cells: getNotebookCells(nb),
metadata: nb.metadata,
nbformat: nbformat_1.MAJOR_VERSION,
nbformat_minor: nbformat_1.MINOR_VERSION
};
}
exports.saveNotebook = saveNotebook;
exports.getNotebookContent = getNotebookContent;
/**
* Get the cell data for a given notebook.
*/
function getNotebookData(nb) {
function getNotebookCells(nb) {
var cells = [];

@@ -157,3 +147,2 @@ for (var i = 0; i < nb.cells.length; i++) {

}
exports.getNotebookData = getNotebookData;
/**

@@ -160,0 +149,0 @@ * Get the output data for a given cell.

{
"name": "jupyter-js-notebook",
"version": "0.6.0",
"version": "0.7.0",
"description": "Notebook widget for Jupyter",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc