From cb2125b641758056ff81e33160eea552262cafd1 Mon Sep 17 00:00:00 2001 From: Mariusz Jurowicz Date: Thu, 7 Jun 2018 14:27:24 +0200 Subject: [PATCH] #7322 use typings in Lab lib --- js/lab/package-lock.json | 51 ++++++++++++++++++++++ js/lab/package.json | 1 + js/notebook/package.json | 2 + js/notebook/src/index.d.ts | 19 +++++++++ js/notebook/src/tsconfig.json | 2 +- js/notebook/src/types/GridView.d.ts | 4 +- js/notebook/src/types/Plot.d.ts | 10 +++++ js/notebook/src/types/assets.d.ts | 3 +- js/notebook/src/types/index.d.ts | 3 ++ js/notebook/webpack.config.js | 12 +++++- js/notebook/yarn.lock | 65 +++++++++++++++++++++++++++++ 11 files changed, 167 insertions(+), 5 deletions(-) create mode 100644 js/notebook/src/index.d.ts create mode 100644 js/notebook/src/types/Plot.d.ts diff --git a/js/lab/package-lock.json b/js/lab/package-lock.json index ebdccb0e44..4d1ad2ab07 100644 --- a/js/lab/package-lock.json +++ b/js/lab/package-lock.json @@ -340,6 +340,57 @@ "integrity": "sha1-YyktOBwBLFqw0Blug87YKbfgSkI=", "dev": true }, + "@phosphor/datagrid": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/@phosphor/datagrid/-/datagrid-0.1.6.tgz", + "integrity": "sha512-JDeM5Y9+S1pvB4u75eYtOeCr6Ra2vLNh4UGNg3aYwtqK8OYNNVBiPhPKK8Fw3zR+vjS3GDy8DYX6A5jRY1uW2g==", + "dev": true, + "requires": { + "@phosphor/algorithm": "1.1.2", + "@phosphor/coreutils": "1.3.0", + "@phosphor/disposable": "1.1.2", + "@phosphor/domutils": "1.1.2", + "@phosphor/dragdrop": "1.3.0", + "@phosphor/messaging": "1.2.2", + "@phosphor/signaling": "1.2.2", + "@phosphor/widgets": "1.6.0" + }, + "dependencies": { + "@phosphor/commands": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@phosphor/commands/-/commands-1.5.0.tgz", + "integrity": "sha512-j8+hIlQZT3imFYVAPO3JxbCUbogOT65uUvUk9AsQXJahm7m8+3a7U4yACshjynJwMM6cxX1AEEo7PUgFwhL97g==", + "dev": true, + "requires": { + "@phosphor/algorithm": "1.1.2", + "@phosphor/coreutils": "1.3.0", + "@phosphor/disposable": "1.1.2", + "@phosphor/domutils": "1.1.2", + "@phosphor/keyboard": "1.1.2", + "@phosphor/signaling": "1.2.2" + } + }, + "@phosphor/widgets": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@phosphor/widgets/-/widgets-1.6.0.tgz", + "integrity": "sha512-HqVckVF8rJ15ss0Zf/q0AJ69ZKNFOO26qtNKAdGZ9SmmkSMf73X6pB0R3Fj5+Y4Sjl8ezIIKG6mXj+DxOofnwA==", + "dev": true, + "requires": { + "@phosphor/algorithm": "1.1.2", + "@phosphor/commands": "1.5.0", + "@phosphor/coreutils": "1.3.0", + "@phosphor/disposable": "1.1.2", + "@phosphor/domutils": "1.1.2", + "@phosphor/dragdrop": "1.3.0", + "@phosphor/keyboard": "1.1.2", + "@phosphor/messaging": "1.2.2", + "@phosphor/properties": "1.1.2", + "@phosphor/signaling": "1.2.2", + "@phosphor/virtualdom": "1.1.2" + } + } + } + }, "@phosphor/disposable": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@phosphor/disposable/-/disposable-1.1.2.tgz", diff --git a/js/lab/package.json b/js/lab/package.json index 4a55cc7ccb..33165d64ee 100644 --- a/js/lab/package.json +++ b/js/lab/package.json @@ -33,6 +33,7 @@ "@jupyterlab/rendermime": "^0.15.2", "@jupyterlab/rendermime-interfaces": "^1.0.4", "@jupyterlab/services": "^1.1.2", + "@phosphor/datagrid": "^0.1.6", "@types/node": "^8.0.56", "rimraf": "^2.6.2", "typescript": "~2.6.2" diff --git a/js/notebook/package.json b/js/notebook/package.json index be9ab1a997..ef226975d2 100644 --- a/js/notebook/package.json +++ b/js/notebook/package.json @@ -39,8 +39,10 @@ "@types/chai": "^4.1.1", "@types/jquery": "^3.3.0", "@types/mocha": "^2.2.46", + "@types/node": "^10.3.1", "base64-inline-loader": "^1.1.1", "chai": "^4.1.2", + "copy-webpack-plugin": "^4.5.1", "css-loader": "^0.28.4", "file-loader": "^0.10.0", "fork-ts-checker-webpack-plugin": "^0.2.8", diff --git a/js/notebook/src/index.d.ts b/js/notebook/src/index.d.ts new file mode 100644 index 0000000000..d62c2e75ff --- /dev/null +++ b/js/notebook/src/index.d.ts @@ -0,0 +1,19 @@ +/* + * Copyright 2018 TWO SIGMA OPEN SOURCE, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// + +export * from './types/index.d'; diff --git a/js/notebook/src/tsconfig.json b/js/notebook/src/tsconfig.json index e93a34b505..de0e5acf6b 100644 --- a/js/notebook/src/tsconfig.json +++ b/js/notebook/src/tsconfig.json @@ -9,7 +9,7 @@ "moduleResolution": "Node", "noEmit": true, "lib": ["dom", "es5", "es2015"], - "types": [], + "types": ["node"], "paths": { "jquery": ["jquery/dist/jquery.js"] } diff --git a/js/notebook/src/types/GridView.d.ts b/js/notebook/src/types/GridView.d.ts index 39a8a65aac..325c164e9f 100644 --- a/js/notebook/src/types/GridView.d.ts +++ b/js/notebook/src/types/GridView.d.ts @@ -1,13 +1,13 @@ import widgets from './widgets'; import './gridView/grid-view.scss'; -export declare class GridViewModel extends widgets.VBoxModel { +export declare class GridModel extends widgets.VBoxModel { defaults(): any; } export declare class GridView extends widgets.VBoxView { render(): void; } declare const _default: { - GridViewModel: typeof GridViewModel; + GridViewModel: typeof GridModel; GridView: typeof GridView; }; export default _default; diff --git a/js/notebook/src/types/Plot.d.ts b/js/notebook/src/types/Plot.d.ts new file mode 100644 index 0000000000..5749ee98ec --- /dev/null +++ b/js/notebook/src/types/Plot.d.ts @@ -0,0 +1,10 @@ +import widgets from './widgets'; +export declare class PlotModel extends widgets.DOMWidgetModel { + defaults(): any; +} +export declare class PlotView extends widgets.DOMWidgetView {} +declare const _default: { + PlotModel: typeof PlotModel; + PlotView: typeof PlotView; +}; +export default _default; diff --git a/js/notebook/src/types/assets.d.ts b/js/notebook/src/types/assets.d.ts index dfe1ad987f..0b74e012c9 100644 --- a/js/notebook/src/types/assets.d.ts +++ b/js/notebook/src/types/assets.d.ts @@ -14,9 +14,10 @@ * limitations under the License. */ +/// + declare var __webpack_public_path__: string; declare var BEAKERX_MODULE_VERSION: string; -declare var require: Function; declare var Jupyter: any; declare var beakerx: any; diff --git a/js/notebook/src/types/index.d.ts b/js/notebook/src/types/index.d.ts index e4082c2008..fcf1efe591 100644 --- a/js/notebook/src/types/index.d.ts +++ b/js/notebook/src/types/index.d.ts @@ -30,3 +30,6 @@ export * from './TabView'; export * from './GridView'; export * from './CyclingDisplayBox'; export * from './EasyForm'; +export * from './Plot'; + +export declare const version: string; diff --git a/js/notebook/webpack.config.js b/js/notebook/webpack.config.js index cdb11516f5..55d9852336 100644 --- a/js/notebook/webpack.config.js +++ b/js/notebook/webpack.config.js @@ -20,6 +20,7 @@ var path = require('path'); var ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); var TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin'); var tsConfigPath = path.resolve(__dirname, './src/tsconfig.json'); +var CopyWebpackPlugin = require('copy-webpack-plugin'); // Custom webpack loaders are generally the same for all webpack bundles, hence // stored in a separate local variable. @@ -182,7 +183,16 @@ module.exports = [ '@jupyter-widgets/jupyterlab-manager', '@jupyterlab' ]), - plugins: plugins + plugins: plugins.concat([ + new CopyWebpackPlugin([{ + from: path.resolve(__dirname, './src/types'), + to: path.resolve(__dirname, '../lab/lib/types') + }, + { + from: path.resolve(__dirname, './src/index.d.ts'), + to: path.resolve(__dirname, '../lab/lib/index.d.ts') + }]) + ]) }, { // tree - notebook diff --git a/js/notebook/yarn.lock b/js/notebook/yarn.lock index c0ef17c607..39449ccab6 100644 --- a/js/notebook/yarn.lock +++ b/js/notebook/yarn.lock @@ -249,6 +249,10 @@ version "2.2.48" resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-2.2.48.tgz#3523b126a0b049482e1c3c11877460f76622ffab" +"@types/node@^10.3.1": + version "10.3.1" + resolved "https://registry.yarnpkg.com/@types/node/-/node-10.3.1.tgz#51092fbacaed768a122a293814474fbf6e5e8b6d" + "@types/strip-bom@^3.0.0": version "3.0.0" resolved "https://registry.yarnpkg.com/@types/strip-bom/-/strip-bom-3.0.0.tgz#14a8ec3956c2e81edb7520790aecf21c290aebd2" @@ -426,6 +430,16 @@ array-find-index@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1" +array-union@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/array-union/-/array-union-1.0.2.tgz#9a34410e4f4e3da23dea375be5be70f24778ec39" + dependencies: + array-uniq "^1.0.1" + +array-uniq@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/array-uniq/-/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6" + array-unique@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53" @@ -1186,6 +1200,19 @@ copy-descriptor@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d" +copy-webpack-plugin@^4.5.1: + version "4.5.1" + resolved "https://registry.yarnpkg.com/copy-webpack-plugin/-/copy-webpack-plugin-4.5.1.tgz#fc4f68f4add837cc5e13d111b20715793225d29c" + dependencies: + cacache "^10.0.4" + find-cache-dir "^1.0.0" + globby "^7.1.1" + is-glob "^4.0.0" + loader-utils "^1.1.0" + minimatch "^3.0.4" + p-limit "^1.0.0" + serialize-javascript "^1.4.0" + core-js@^2.4.0: version "2.5.3" resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.3.tgz#8acc38345824f16d8365b7c9b4259168e8ed603e" @@ -1712,6 +1739,13 @@ diffie-hellman@^5.0.0: miller-rabin "^4.0.0" randombytes "^2.0.0" +dir-glob@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-2.0.0.tgz#0b205d2b6aef98238ca286598a8204d29d0a0034" + dependencies: + arrify "^1.0.1" + path-type "^3.0.0" + domain-browser@^1.1.1: version "1.2.0" resolved "https://registry.yarnpkg.com/domain-browser/-/domain-browser-1.2.0.tgz#3d31f50191a6749dd1375a7f522e823d42e54eda" @@ -2304,6 +2338,17 @@ globals@^9.18.0: version "9.18.0" resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" +globby@^7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/globby/-/globby-7.1.1.tgz#fb2ccff9401f8600945dfada97440cca972b8680" + dependencies: + array-union "^1.0.1" + dir-glob "^2.0.0" + glob "^7.1.2" + ignore "^3.3.5" + pify "^3.0.0" + slash "^1.0.0" + globule@^1.0.0: version "1.2.0" resolved "https://registry.yarnpkg.com/globule/-/globule-1.2.0.tgz#1dc49c6822dd9e8a2fa00ba2a295006e8664bd09" @@ -2583,6 +2628,10 @@ ignore-styles@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/ignore-styles/-/ignore-styles-5.0.1.tgz#b49ef2274bdafcd8a4880a966bfe38d1a0bf4671" +ignore@^3.3.5: + version "3.3.8" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.8.tgz#3f8e9c35d38708a3a7e0e9abb6c73e7ee7707b2b" + imurmurhash@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" @@ -3805,6 +3854,12 @@ p-finally@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" +p-limit@^1.0.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.3.0.tgz#b86bd5f0c25690911c7590fcbfc2010d54b3ccb8" + dependencies: + p-try "^1.0.0" + p-limit@^1.1.0: version "1.2.0" resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.2.0.tgz#0e92b6bedcb59f022c13d0f1949dc82d15909f1c" @@ -3930,6 +3985,12 @@ path-type@^2.0.0: dependencies: pify "^2.0.0" +path-type@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/path-type/-/path-type-3.0.0.tgz#cef31dc8e0a1a3bb0d105c0cd97cf3bf47f4e36f" + dependencies: + pify "^3.0.0" + pathval@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.0.tgz#b942e6d4bde653005ef6b71361def8727d0645e0" @@ -4816,6 +4877,10 @@ sinon@^4.2.0: supports-color "^5.1.0" type-detect "^4.0.5" +slash@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55" + slide@^1.1.5: version "1.1.6" resolved "https://registry.yarnpkg.com/slide/-/slide-1.1.6.tgz#56eb027d65b4d2dce6cb2e2d32c4d4afc9e1d707"