@jupyterlab/coreutils
Advanced tools
Comparing version 0.6.0 to 0.7.0
@@ -12,2 +12,5 @@ export * from './activitymonitor'; | ||
export * from './path'; | ||
export * from './settingregistry'; | ||
export * from './statedb'; | ||
export * from './text'; | ||
export * from './time'; | ||
@@ -14,0 +17,0 @@ export * from './undoablelist'; |
@@ -18,2 +18,5 @@ "use strict"; | ||
__export(require("./path")); | ||
__export(require("./settingregistry")); | ||
__export(require("./statedb")); | ||
__export(require("./text")); | ||
__export(require("./time")); | ||
@@ -20,0 +23,0 @@ __export(require("./undoablelist")); |
@@ -0,1 +1,4 @@ | ||
/** | ||
* A generic interface for change emitter payloads. | ||
*/ | ||
export interface IChangedArgs<T> { | ||
@@ -15,1 +18,36 @@ /** | ||
} | ||
/** | ||
* The description of a general purpose datastore. | ||
*/ | ||
export interface IDatastore<T, U> { | ||
/** | ||
* Retrieve a saved bundle from the datastore. | ||
* | ||
* @param id - The identifier used to retrieve a data bundle. | ||
* | ||
* @returns A promise that bears a data payload if available. | ||
* | ||
* #### Notes | ||
* The promise returned by this method may be rejected if an error occurs in | ||
* retrieving the data. Non-existence of an `id` will succeed with `null`. | ||
*/ | ||
fetch(id: string): Promise<T | null>; | ||
/** | ||
* Remove a value from the datastore. | ||
* | ||
* @param id - The identifier for the data being removed. | ||
* | ||
* @returns A promise that is rejected if remove fails and succeeds otherwise. | ||
*/ | ||
remove(id: string): Promise<void>; | ||
/** | ||
* Save a value in the datastore. | ||
* | ||
* @param id - The identifier for the data being saved. | ||
* | ||
* @param value - The data being saved. | ||
* | ||
* @returns A promise that is rejected if saving fails and succeeds otherwise. | ||
*/ | ||
save(id: string, value: U): Promise<T | void>; | ||
} |
@@ -6,3 +6,3 @@ /** | ||
export declare namespace MarkdownCodeBlocks { | ||
const markdownMarkers: string[]; | ||
const CODE_BLOCK_MARKER = "```"; | ||
class MarkdownCodeBlock { | ||
@@ -9,0 +9,0 @@ startLine: number; |
@@ -11,3 +11,3 @@ "use strict"; | ||
(function (MarkdownCodeBlocks) { | ||
MarkdownCodeBlocks.markdownMarkers = ["```", "~~~~", "`"]; | ||
MarkdownCodeBlocks.CODE_BLOCK_MARKER = "```"; | ||
var markdownExtensions = [ | ||
@@ -57,57 +57,43 @@ '.markdown', | ||
var lines = text.split("\n"); | ||
var codeSnippets = []; | ||
var currentCode = null; | ||
var codeBlocks = []; | ||
var currentBlock = null; | ||
for (var lineIndex = 0; lineIndex < lines.length; lineIndex++) { | ||
var line = lines[lineIndex]; | ||
var marker = findNextMarker(line); | ||
var lineContainsMarker = marker != ''; | ||
var constructingSnippet = currentCode != null; | ||
//skip this line if it is not part of any code snippet and doesn't contain a marker | ||
if (!lineContainsMarker && !constructingSnippet) { | ||
var lineContainsMarker = line.indexOf(MarkdownCodeBlocks.CODE_BLOCK_MARKER) === 0; | ||
var constructingBlock = currentBlock != null; | ||
// Skip this line if it is not part of any code block and doesn't contain a marker. | ||
if (!lineContainsMarker && !constructingBlock) { | ||
continue; | ||
} | ||
//check if we are already constructing a code snippet | ||
if (!constructingSnippet) { | ||
//start constructing | ||
currentCode = new MarkdownCodeBlock(lineIndex); | ||
//check whether this is a single line code snippet | ||
var firstIndex = line.indexOf(marker); | ||
var lastIndex = line.lastIndexOf(marker); | ||
// Check if we are already constructing a code block. | ||
if (!constructingBlock) { | ||
// Start constructing a new code block. | ||
currentBlock = new MarkdownCodeBlock(lineIndex); | ||
// Check whether this is a single line code block of the form ```a = 10```. | ||
var firstIndex = line.indexOf(MarkdownCodeBlocks.CODE_BLOCK_MARKER); | ||
var lastIndex = line.lastIndexOf(MarkdownCodeBlocks.CODE_BLOCK_MARKER); | ||
var isSingleLine = firstIndex != lastIndex; | ||
if (isSingleLine) { | ||
currentCode.code = line.substring(firstIndex + marker.length, lastIndex); | ||
currentCode.endLine = lineIndex; | ||
codeSnippets.push(currentCode); | ||
currentCode = null; | ||
currentBlock.code = line.substring(firstIndex + MarkdownCodeBlocks.CODE_BLOCK_MARKER.length, lastIndex); | ||
currentBlock.endLine = lineIndex; | ||
codeBlocks.push(currentBlock); | ||
currentBlock = null; | ||
} | ||
else { | ||
currentCode.code = line.substring(firstIndex + marker.length); | ||
} | ||
} | ||
else { | ||
//already constructing | ||
if (lineContainsMarker) { | ||
currentCode.code += "\n" + line.substring(0, line.indexOf(marker)); | ||
currentCode.endLine = lineIndex; | ||
codeSnippets.push(currentCode); | ||
currentCode = null; | ||
// End of block, finish it up. | ||
currentBlock.endLine = lineIndex - 1; | ||
codeBlocks.push(currentBlock); | ||
currentBlock = null; | ||
} | ||
else { | ||
currentCode.code += "\n" + line; | ||
// Append the current line. | ||
currentBlock.code += line + "\n"; | ||
} | ||
} | ||
} | ||
return codeSnippets; | ||
return codeBlocks; | ||
} | ||
MarkdownCodeBlocks.findMarkdownCodeBlocks = findMarkdownCodeBlocks; | ||
function findNextMarker(text) { | ||
for (var _i = 0, markdownMarkers_1 = MarkdownCodeBlocks.markdownMarkers; _i < markdownMarkers_1.length; _i++) { | ||
var marker = markdownMarkers_1[_i]; | ||
var index = text.indexOf(marker); | ||
if (index > -1) { | ||
return marker; | ||
} | ||
} | ||
return ''; | ||
} | ||
})(MarkdownCodeBlocks = exports.MarkdownCodeBlocks || (exports.MarkdownCodeBlocks = {})); |
@@ -227,3 +227,3 @@ import { JSONObject } from '@phosphor/coreutils'; | ||
*/ | ||
type OutputType = 'execute_result' | 'display_data' | 'stream' | 'error'; | ||
type OutputType = 'execute_result' | 'display_data' | 'stream' | 'error' | 'update_display_data'; | ||
/** | ||
@@ -277,2 +277,19 @@ * The base output type. | ||
/** | ||
* Data displayed as an update to existing display data. | ||
*/ | ||
interface IDisplayUpdate extends IBaseOutput { | ||
/** | ||
* Type of cell output. | ||
*/ | ||
output_type: 'update_display_data'; | ||
/** | ||
* A mime-type keyed dictionary of data. | ||
*/ | ||
data: IMimeBundle; | ||
/** | ||
* Cell output metadata. | ||
*/ | ||
metadata: OutputMetadata; | ||
} | ||
/** | ||
* Stream output from a code cell. | ||
@@ -333,2 +350,6 @@ */ | ||
/** | ||
* Test whether an output is from updated display data. | ||
*/ | ||
function isDisplayUpdate(output: IOutput): output is IDisplayUpdate; | ||
/** | ||
* Test whether an output is from a stream. | ||
@@ -335,0 +356,0 @@ */ |
@@ -100,2 +100,9 @@ "use strict"; | ||
/** | ||
* Test whether an output is from updated display data. | ||
*/ | ||
function isDisplayUpdate(output) { | ||
return output.output_type === 'update_display_data'; | ||
} | ||
nbformat.isDisplayUpdate = isDisplayUpdate; | ||
/** | ||
* Test whether an output is from a stream. | ||
@@ -102,0 +109,0 @@ */ |
@@ -46,6 +46,4 @@ "use strict"; | ||
function dirname(path) { | ||
if (path === '') { | ||
return ''; | ||
} | ||
return removeSlash(posix.dirname(path)); | ||
var dir = removeSlash(posix.dirname(path)); | ||
return dir === '.' ? '' : dir; | ||
} | ||
@@ -52,0 +50,0 @@ PathExt.dirname = dirname; |
@@ -90,3 +90,3 @@ "use strict"; | ||
switch (parse(url).hostname) { | ||
case 'localhost': | ||
case location.hostname: | ||
case '': | ||
@@ -93,0 +93,0 @@ return true; |
{ | ||
"name": "@jupyterlab/coreutils", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"description": "JupyterLab - Core Utilities", | ||
@@ -15,7 +15,7 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@phosphor/algorithm": "^1.1.0", | ||
"@phosphor/coreutils": "^1.1.0", | ||
"@phosphor/disposable": "^1.1.0", | ||
"@phosphor/messaging": "^1.2.0", | ||
"@phosphor/signaling": "^1.2.0", | ||
"@phosphor/algorithm": "^1.1.1", | ||
"@phosphor/coreutils": "^1.1.1", | ||
"@phosphor/disposable": "^1.1.1", | ||
"@phosphor/messaging": "^1.2.1", | ||
"@phosphor/signaling": "^1.2.1", | ||
"minimist": "^1.2.0", | ||
@@ -22,0 +22,0 @@ "moment": "^2.17.1", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
164593
39
5470
Updated@phosphor/algorithm@^1.1.1
Updated@phosphor/coreutils@^1.1.1
Updated@phosphor/disposable@^1.1.1
Updated@phosphor/messaging@^1.2.1
Updated@phosphor/signaling@^1.2.1