@jupyterlab/services
Advanced tools
Comparing version 0.39.1 to 0.40.0
@@ -315,5 +315,3 @@ import { JSONObject } from '@phosphor/coreutils'; | ||
* #### Notes | ||
* It is expected that the path contains no relative paths, | ||
* use [[ContentsManager.getAbsolutePath]] to get an absolute | ||
* path if necessary. | ||
* It is expected that the path contains no relative paths. | ||
*/ | ||
@@ -470,42 +468,2 @@ getDownloadUrl(path: string): Promise<string>; | ||
} | ||
/** | ||
* Get the absolute POSIX path to a file on the server. | ||
* | ||
* @param relativePath - The relative POSIX path to the file. | ||
* | ||
* @param cwd - The optional POSIX current working directory. The default is | ||
* an empty string. | ||
* | ||
* #### Notes | ||
* Absolute path in this context is equivalent to a POSIX path without | ||
* the initial `'/'` because IPEP 27 paths denote `''` as the root. | ||
* If the resulting path is not contained within the server root, | ||
* returns `null`, since it cannot be served. | ||
*/ | ||
function getAbsolutePath(relativePath: string, cwd?: string): string; | ||
/** | ||
* Get the last portion of a path, similar to the Unix basename command. | ||
*/ | ||
function basename(path: string, ext?: string): string; | ||
/** | ||
* Get the directory name of a path, similar to the Unix dirname command. | ||
*/ | ||
function dirname(path: string): string; | ||
/** | ||
* Get the extension of the path. | ||
* | ||
* #### Notes | ||
* The extension is the string from the last occurance of the `.` | ||
* character to end of string in the last portion of the path. | ||
* If there is no `.` in the last portion of the path, or if the first | ||
* character of the basename of path [[basename]] is `.`, then an | ||
* empty string is returned. | ||
*/ | ||
function extname(path: string): string; | ||
/** | ||
* Normalize a file extension to be of the type `'.foo'`. | ||
* | ||
* Adds a leading dot if not present and converts to lower case. | ||
*/ | ||
function normalizeExtension(extension: string): string; | ||
} |
// Copyright (c) Jupyter Development Team. | ||
// Distributed under the terms of the Modified BSD License. | ||
"use strict"; | ||
var posix = require("path-posix"); | ||
var signaling_1 = require("@phosphor/signaling"); | ||
@@ -137,5 +136,3 @@ var utils = require("../utils"); | ||
* #### Notes | ||
* It is expected that the path contains no relative paths, | ||
* use [[ContentsManager.getAbsolutePath]] to get an absolute | ||
* path if necessary. | ||
* It is expected that the path contains no relative paths. | ||
*/ | ||
@@ -165,3 +162,3 @@ ContentsManager.prototype.getDownloadUrl = function (path) { | ||
if (options.ext) { | ||
options.ext = ContentsManager.normalizeExtension(options.ext); | ||
options.ext = Private.normalizeExtension(options.ext); | ||
} | ||
@@ -480,62 +477,7 @@ ajaxSettings.data = JSON.stringify(options); | ||
/** | ||
* A namespace for ContentsManager statics. | ||
* A namespace for module private data. | ||
*/ | ||
(function (ContentsManager) { | ||
var Private; | ||
(function (Private) { | ||
/** | ||
* Get the absolute POSIX path to a file on the server. | ||
* | ||
* @param relativePath - The relative POSIX path to the file. | ||
* | ||
* @param cwd - The optional POSIX current working directory. The default is | ||
* an empty string. | ||
* | ||
* #### Notes | ||
* Absolute path in this context is equivalent to a POSIX path without | ||
* the initial `'/'` because IPEP 27 paths denote `''` as the root. | ||
* If the resulting path is not contained within the server root, | ||
* returns `null`, since it cannot be served. | ||
*/ | ||
function getAbsolutePath(relativePath, cwd) { | ||
if (cwd === void 0) { cwd = ''; } | ||
// Bail if it looks like a url. | ||
var urlObj = utils.urlParse(relativePath); | ||
if (urlObj.protocol) { | ||
return relativePath; | ||
} | ||
var norm = posix.normalize(posix.join(cwd, relativePath)); | ||
if (norm.indexOf('../') === 0) { | ||
return null; | ||
} | ||
return posix.resolve('/', cwd, relativePath).slice(1); | ||
} | ||
ContentsManager.getAbsolutePath = getAbsolutePath; | ||
/** | ||
* Get the last portion of a path, similar to the Unix basename command. | ||
*/ | ||
function basename(path, ext) { | ||
return posix.basename(path, ext); | ||
} | ||
ContentsManager.basename = basename; | ||
/** | ||
* Get the directory name of a path, similar to the Unix dirname command. | ||
*/ | ||
function dirname(path) { | ||
return posix.dirname(path); | ||
} | ||
ContentsManager.dirname = dirname; | ||
/** | ||
* Get the extension of the path. | ||
* | ||
* #### Notes | ||
* The extension is the string from the last occurance of the `.` | ||
* character to end of string in the last portion of the path. | ||
* If there is no `.` in the last portion of the path, or if the first | ||
* character of the basename of path [[basename]] is `.`, then an | ||
* empty string is returned. | ||
*/ | ||
function extname(path) { | ||
return posix.extname(path); | ||
} | ||
ContentsManager.extname = extname; | ||
/** | ||
* Normalize a file extension to be of the type `'.foo'`. | ||
@@ -551,4 +493,3 @@ * | ||
} | ||
ContentsManager.normalizeExtension = normalizeExtension; | ||
})(ContentsManager = exports.ContentsManager || (exports.ContentsManager = {})); | ||
exports.ContentsManager = ContentsManager; | ||
Private.normalizeExtension = normalizeExtension; | ||
})(Private || (Private = {})); |
@@ -5,2 +5,3 @@ // Copyright (c) Jupyter Development Team. | ||
var algorithm_1 = require("@phosphor/algorithm"); | ||
var coreutils_1 = require("@phosphor/coreutils"); | ||
var disposable_1 = require("@phosphor/disposable"); | ||
@@ -656,3 +657,3 @@ var signaling_1 = require("@phosphor/signaling"); | ||
var parsed = utils.urlParse(partialUrl); | ||
var display = partialUrl.replace(parsed.auth, ''); | ||
console.log('Starting websocket', parsed.hostname); | ||
var url = utils.urlPathJoin(partialUrl, 'channels?session_id=' + encodeURIComponent(this._clientId)); | ||
@@ -663,4 +664,3 @@ // if token authentication is in use | ||
} | ||
console.log('Starting websocket', display); | ||
this._connectionPromise = new utils.PromiseDelegate(); | ||
this._connectionPromise = new coreutils_1.PromiseDelegate(); | ||
this._ws = new WebSocket(url); | ||
@@ -667,0 +667,0 @@ // Ensure incoming binary messages are not Blobs |
import { JSONObject } from '@phosphor/coreutils'; | ||
export { PromiseDelegate } from '@phosphor/coreutils'; | ||
/** | ||
@@ -27,3 +28,2 @@ * Copy the contents of one object to another, recursively. | ||
protocol?: string; | ||
auth?: string; | ||
hostname?: string; | ||
@@ -33,7 +33,4 @@ port?: string; | ||
pathname?: string; | ||
hash?: string; | ||
search?: string; | ||
query?: string | any; | ||
slashes?: boolean; | ||
hash?: string; | ||
path?: string; | ||
} | ||
@@ -43,28 +40,10 @@ /** | ||
* | ||
* @param urlString - The URL string to parse. | ||
* @param url - The URL string to parse. | ||
* | ||
* @param parseQueryString - If `true`, the query property will always be set | ||
* to an object returned by the `querystring` module's `parse()` method. | ||
* If `false`, the `query` property on the returned URL object will be an | ||
* unparsed, undecoded string. Defaults to `false`. | ||
* | ||
* @param slashedDenoteHost - If `true`, the first token after the literal | ||
* string `//` and preceeding the next `/` will be interpreted as the `host`. | ||
* For instance, given `//foo/bar`, the result would be | ||
* `{host: 'foo', pathname: '/bar'}` rather than `{pathname: '//foo/bar'}`. | ||
* Defaults to `false`. | ||
* | ||
* @returns A URL object. | ||
*/ | ||
export declare function urlParse(urlStr: string, parseQueryString?: boolean, slashesDenoteHost?: boolean): IUrl; | ||
export declare function urlParse(url: string): IUrl; | ||
/** | ||
* Resolve a url. | ||
* | ||
* Take a base URL, and a href URL, and resolve them as a browser would for | ||
* an anchor tag. | ||
* Join a sequence of url components with `'/'`. | ||
*/ | ||
export declare function urlResolve(from: string, to: string): string; | ||
/** | ||
* Join a sequence of url components and normalizes as in node `path.join`. | ||
*/ | ||
export declare function urlPathJoin(...parts: string[]): string; | ||
@@ -209,26 +188,2 @@ /** | ||
/** | ||
* A Promise that can be resolved or rejected by another object. | ||
*/ | ||
export declare class PromiseDelegate<T> { | ||
/** | ||
* Construct a new Promise delegate. | ||
*/ | ||
constructor(); | ||
/** | ||
* Get the underlying Promise. | ||
*/ | ||
readonly promise: Promise<T>; | ||
/** | ||
* Resolve the underlying Promise with an optional value or another Promise. | ||
*/ | ||
resolve(value?: T | Promise<T>): void; | ||
/** | ||
* Reject the underlying Promise with an optional reason. | ||
*/ | ||
reject(reason?: any): void; | ||
private _promise; | ||
private _resolve; | ||
private _reject; | ||
} | ||
/** | ||
* Get global configuration data for the Jupyter application. | ||
@@ -235,0 +190,0 @@ * |
109
lib/utils.js
@@ -5,4 +5,7 @@ // Copyright (c) Jupyter Development Team. | ||
var minimist = require("minimist"); | ||
var url = require("url"); | ||
var urljoin = require("url-join"); | ||
var path = require("path-posix"); | ||
var urlparse = require("url-parse"); | ||
// Export the Promise Delegate for now to preserve API. | ||
var coreutils_1 = require("@phosphor/coreutils"); | ||
exports.PromiseDelegate = coreutils_1.PromiseDelegate; | ||
/** | ||
@@ -49,34 +52,18 @@ * Copy the contents of one object to another, recursively. | ||
* | ||
* @param urlString - The URL string to parse. | ||
* @param url - The URL string to parse. | ||
* | ||
* @param parseQueryString - If `true`, the query property will always be set | ||
* to an object returned by the `querystring` module's `parse()` method. | ||
* If `false`, the `query` property on the returned URL object will be an | ||
* unparsed, undecoded string. Defaults to `false`. | ||
* | ||
* @param slashedDenoteHost - If `true`, the first token after the literal | ||
* string `//` and preceeding the next `/` will be interpreted as the `host`. | ||
* For instance, given `//foo/bar`, the result would be | ||
* `{host: 'foo', pathname: '/bar'}` rather than `{pathname: '//foo/bar'}`. | ||
* Defaults to `false`. | ||
* | ||
* @returns A URL object. | ||
*/ | ||
function urlParse(urlStr, parseQueryString, slashesDenoteHost) { | ||
return url.parse(urlStr, parseQueryString, slashesDenoteHost); | ||
function urlParse(url) { | ||
if (typeof document !== 'undefined') { | ||
var a = document.createElement('a'); | ||
a.href = url; | ||
return a; | ||
} | ||
return urlparse(url); | ||
} | ||
exports.urlParse = urlParse; | ||
/** | ||
* Resolve a url. | ||
* | ||
* Take a base URL, and a href URL, and resolve them as a browser would for | ||
* an anchor tag. | ||
* Join a sequence of url components with `'/'`. | ||
*/ | ||
function urlResolve(from, to) { | ||
return url.resolve(from, to); | ||
} | ||
exports.urlResolve = urlResolve; | ||
/** | ||
* Join a sequence of url components and normalizes as in node `path.join`. | ||
*/ | ||
function urlPathJoin() { | ||
@@ -87,3 +74,15 @@ var parts = []; | ||
} | ||
return urljoin.apply(void 0, parts); | ||
// Adapted from url-join. | ||
// Copyright (c) 2016 José F. Romaniello, MIT License. | ||
// https://github.com/jfromaniello/url-join/blob/v1.1.0/lib/url-join.js | ||
var str = [].slice.call(parts, 0).join('/'); | ||
// make sure protocol is followed by two slashes | ||
str = str.replace(/:\//g, '://'); | ||
// remove consecutive slashes | ||
str = str.replace(/([^:\s])\/+/g, '$1/'); | ||
// remove trailing slash before parameters or hash | ||
str = str.replace(/\/(\?|&|#[^!])/g, '$1'); | ||
// replace ? in parameters with & | ||
str = str.replace(/(\?.+)\?/g, '$1&'); | ||
return str; | ||
} | ||
@@ -99,6 +98,3 @@ exports.urlPathJoin = urlPathJoin; | ||
function urlEncodeParts(uri) { | ||
// Normalize and join, split, encode, then join. | ||
uri = urljoin(uri); | ||
var parts = uri.split('/').map(encodeURIComponent); | ||
return urljoin.apply(void 0, parts); | ||
return urlPathJoin.apply(void 0, uri.split('/').map(encodeURIComponent)); | ||
} | ||
@@ -252,45 +248,2 @@ exports.urlEncodeParts = urlEncodeParts; | ||
/** | ||
* A Promise that can be resolved or rejected by another object. | ||
*/ | ||
var PromiseDelegate = (function () { | ||
/** | ||
* Construct a new Promise delegate. | ||
*/ | ||
function PromiseDelegate() { | ||
var _this = this; | ||
this._promise = new Promise(function (resolve, reject) { | ||
_this._resolve = resolve; | ||
_this._reject = reject; | ||
}); | ||
} | ||
Object.defineProperty(PromiseDelegate.prototype, "promise", { | ||
/** | ||
* Get the underlying Promise. | ||
*/ | ||
get: function () { | ||
return this._promise; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
/** | ||
* Resolve the underlying Promise with an optional value or another Promise. | ||
*/ | ||
PromiseDelegate.prototype.resolve = function (value) { | ||
// Note: according to the Promise spec, and the `this` context for resolve | ||
// and reject are ignored | ||
this._resolve(value); | ||
}; | ||
/** | ||
* Reject the underlying Promise with an optional reason. | ||
*/ | ||
PromiseDelegate.prototype.reject = function (reason) { | ||
// Note: according to the Promise spec, the `this` context for resolve | ||
// and reject are ignored | ||
this._reject(reason); | ||
}; | ||
return PromiseDelegate; | ||
}()); | ||
exports.PromiseDelegate = PromiseDelegate; | ||
/** | ||
* Global config data for the Jupyter application. | ||
@@ -367,6 +320,6 @@ */ | ||
if (typeof location !== 'undefined') { | ||
baseUrl = urlPathJoin(location.origin, baseUrl); | ||
baseUrl = path.join(location.origin, baseUrl); | ||
} | ||
else { | ||
baseUrl = urlPathJoin('http://localhost:8888/', baseUrl); | ||
baseUrl = path.join('http://localhost:8888/', baseUrl); | ||
} | ||
@@ -393,3 +346,3 @@ } | ||
} | ||
if (!token || token == '') { | ||
if (!token || token === '') { | ||
return ajaxSettings; | ||
@@ -396,0 +349,0 @@ } |
{ | ||
"name": "@jupyterlab/services", | ||
"version": "0.39.1", | ||
"version": "0.40.0", | ||
"description": "Client APIs for the Jupyter services REST APIs", | ||
@@ -16,4 +16,3 @@ "main": "lib/index.js", | ||
"path-posix": "^1.0.0", | ||
"url": "^0.11.0", | ||
"url-join": "^1.1.0" | ||
"url-parse": "^1.1.8" | ||
}, | ||
@@ -23,3 +22,3 @@ "devDependencies": { | ||
"@types/mocha": "^2.2.39", | ||
"@types/ws": "0.0.38", | ||
"@types/ws": "0.0.39", | ||
"expect.js": "^0.3.1", | ||
@@ -30,3 +29,3 @@ "istanbul": "^0.3.18", | ||
"text-encoding": "^0.5.2", | ||
"typedoc": "^0.5.0", | ||
"typedoc": "^0.5.7", | ||
"typescript": "~2.1.6", | ||
@@ -33,0 +32,0 @@ "webpack": "^1.13.1", |
Sorry, the diff of this file is too big to display
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
9
761154
22288
+ Addedurl-parse@^1.1.8
+ Addedquerystringify@2.2.0(transitive)
+ Addedrequires-port@1.0.0(transitive)
+ Addedurl-parse@1.5.10(transitive)
- Removedurl@^0.11.0
- Removedurl-join@^1.1.0
- Removedcall-bind@1.0.7(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removedes-define-property@1.0.0(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-intrinsic@1.2.4(transitive)
- Removedgopd@1.0.1(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedhas-proto@1.0.3(transitive)
- Removedhas-symbols@1.0.3(transitive)
- Removedhasown@2.0.2(transitive)
- Removedobject-inspect@1.13.2(transitive)
- Removedpunycode@1.4.1(transitive)
- Removedqs@6.13.0(transitive)
- Removedset-function-length@1.2.2(transitive)
- Removedside-channel@1.0.6(transitive)
- Removedurl@0.11.4(transitive)
- Removedurl-join@1.1.0(transitive)