Socket
Socket
Sign inDemoInstall

@jupyter/ydoc

Package Overview
Dependencies
Maintainers
0
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jupyter/ydoc - npm Package Compare versions

Comparing version 2.0.1 to 3.0.0-a0

3

lib/api.d.ts

@@ -15,2 +15,3 @@ /**

import type { ISignal } from '@lumino/signaling';
import * as Y from 'yjs';
/**

@@ -626,3 +627,3 @@ * Changes on Sequence-like data are expressed as Quill-inspired deltas.

*/
outputsChange?: Delta<nbformat.IOutput[]>;
outputsChange?: Delta<Y.Map<any>>;
/**

@@ -629,0 +630,0 @@ * Cell execution count change

@@ -276,2 +276,3 @@ import type * as nbformat from '@jupyterlab/nbformat';

set outputs(v: Array<nbformat.IOutput>);
get youtputs(): Y.Array<any>;
/**

@@ -281,2 +282,3 @@ * Execution, display, or stream outputs.

getOutputs(): Array<nbformat.IOutput>;
createOutputs(outputs: Array<nbformat.IOutput>): Array<Y.Map<any>>;
/**

@@ -287,2 +289,10 @@ * Replace all outputs.

/**
* Remove text from a stream output.
*/
removeStreamOutput(index: number, start: number): void;
/**
* Append text to a stream output.
*/
appendStreamOutput(index: number, text: string): void;
/**
* Replace content from `start' to `end` with `outputs`.

@@ -289,0 +299,0 @@ *

@@ -623,2 +623,5 @@ /* -----------------------------------------------------------------------------

}
get youtputs() {
return this._youtputs;
}
/**

@@ -628,4 +631,32 @@ * Execution, display, or stream outputs.

getOutputs() {
return JSONExt.deepCopy(this._youtputs.toArray());
return JSONExt.deepCopy(this._youtputs.toJSON());
}
createOutputs(outputs) {
const newOutputs = [];
for (const output of outputs) {
let _newOutput;
const newOutput = new Y.Map();
if (output.output_type === 'stream') {
// Set the text field as a Y.Text
const { text, ...outputWithoutText } = output;
_newOutput = outputWithoutText;
const newText = new Y.Text();
let length = 0;
// text is a list of strings
for (const str of text) {
newText.insert(length, str);
length += str.length;
}
_newOutput['text'] = newText;
}
else {
_newOutput = output;
}
for (const [key, value] of Object.entries(_newOutput)) {
newOutput.set(key, value);
}
newOutputs.push(newOutput);
}
return newOutputs;
}
/**

@@ -637,6 +668,28 @@ * Replace all outputs.

this._youtputs.delete(0, this._youtputs.length);
this._youtputs.insert(0, outputs);
const newOutputs = this.createOutputs(outputs);
this._youtputs.insert(0, newOutputs);
}, false);
}
/**
* Remove text from a stream output.
*/
removeStreamOutput(index, start) {
this.transact(() => {
const output = this._youtputs.get(index);
const prevText = output.get('text');
const length = prevText.length - start;
prevText.delete(start, length);
}, false);
}
/**
* Append text to a stream output.
*/
appendStreamOutput(index, text) {
this.transact(() => {
const output = this._youtputs.get(index);
const prevText = output.get('text');
prevText.insert(prevText.length, text);
}, false);
}
/**
* Replace content from `start' to `end` with `outputs`.

@@ -654,3 +707,4 @@ *

this._youtputs.delete(start, fin);
this._youtputs.insert(start, outputs);
const newOutputs = this.createOutputs(outputs);
this._youtputs.insert(start, newOutputs);
}, false);

@@ -657,0 +711,0 @@ }

@@ -35,3 +35,3 @@ /* -----------------------------------------------------------------------------

*/
this.version = '1.0.0';
this.version = '2.0.0';
/**

@@ -38,0 +38,0 @@ * YJS map for the notebook metadata

{
"name": "@jupyter/ydoc",
"version": "2.0.1",
"version": "3.0.0-a0",
"type": "module",

@@ -5,0 +5,0 @@ "description": "Jupyter document structures for collaborative editing using YJS",

Sorry, the diff of this file is not supported yet

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