├── .gitignore ├── .travis.yml ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── example ├── example.ipynb ├── index.css ├── index.html ├── index.js ├── jupyter.png ├── main.py ├── package.json └── webpack.conf.js ├── jupyter-plugins-demo.gif ├── jupyter_plugins.png ├── package.json ├── scripts ├── copyfiles.js ├── travis_after_success.sh ├── travis_install.sh └── travis_script.sh ├── src ├── about │ └── plugin.ts ├── clipboard │ └── plugin.ts ├── console │ └── plugin.ts ├── default-theme │ ├── about.css │ ├── commandpalette.css │ ├── help.css │ └── index.css ├── docregistry │ └── plugin.ts ├── editorhandler │ └── plugin.ts ├── filebrowser │ └── plugin.ts ├── help │ ├── iframe.ts │ └── plugin.ts ├── imagehandler │ └── plugin.ts ├── index.ts ├── landing │ ├── images │ │ ├── jupyterlab.svg │ │ ├── notebook.svg │ │ ├── terminal.svg │ │ └── texteditor.svg │ ├── index.css │ └── plugin.ts ├── main │ └── plugin.ts ├── notebook │ └── plugin.ts ├── rendermime │ └── plugin.ts ├── services │ ├── plugin.ts │ └── test.ts ├── shortcuts │ └── plugin.ts ├── terminal │ └── plugin.ts ├── tsconfig.json ├── typings.d.ts └── widgets │ └── index.ts ├── test ├── karma-cov.conf.js ├── karma.conf.js ├── src │ ├── index.ts │ ├── tsconfig.json │ └── typings.d.ts ├── webpack-cov.conf.js └── webpack.conf.js └── typings ├── backbone ├── backbone-global.d.ts └── backbone.d.ts ├── codemirror └── codemirror.d.ts ├── es6-promise └── es6-promise.d.ts ├── expect.js └── expect.js.d.ts ├── jquery └── jquery.d.ts ├── jupyter-js-widgets └── jupyter-js-widgets.d.ts ├── mocha └── mocha.d.ts ├── moment └── moment.d.ts ├── requirejs └── requirejs.d.ts └── underscore └── underscore.d.ts /.gitignore: -------------------------------------------------------------------------------- 1 | *.suo 2 | *.user 3 | .DS_Store 4 | node_modules 5 | npm-debug.log 6 | test/build 7 | test/coverage 8 | lib/ 9 | example/build 10 | example/untitled* 11 | example/Untitled* 12 | example/*.png 13 | example/*.gif 14 | docs 15 | 16 | .ipynb_checkpoints 17 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - '0.12' 4 | sudo: false 5 | env: 6 | matrix: 7 | - GROUP= 8 | global: 9 | - GH_REF: github.com/jupyter/jupyter-js-plugins.git 10 | - secure: UwfNcdwPGuWRY6A0kjeEC0Py7OEuSOO14aSypr779D1jabGkXLVPtmXQzy3kRQuMRVse/OVC88wNzYDnTEikwrWHOguANlYyTjJCmeG+YVWjpDN6OzAWYJ/RCacPyY7+mkQKizzKBfgJy39AXMRTp17kYePVo4yTfvkQpaZfFVQqVhL1v6Qz4rI3IG5DlCJFn6le9uhv5tJan+a2iQQBNHNAyrFoTujGz/PVDmuQ/EUF/RuC3OYGOBfkZgsiOeB9eFHSa5sweFnn+57a1Y0YOJM7TqpOwDzWrEbNnev08I5YTH2RJ1hMhLXOUmHAI8vW42IxMWo6B/b6n0/0x2lCbQTNKl6So4esu+G2di5VsSMvyXkVH7ahJRmR/iHAhb7vBR0eJ90vKp2xcVRsWFEKy/MNXECAPnqqPLsCFb8My3ecxDpNiSnTrB54at5OoR5cD7q5ZGDQ7wU+tePVWXZHiiL9j+OcqyjrvcMEp1sbRGriOwhzkJsFW4/SJ1yrcmX/PnMiZBTbxuxjYMaO5+pr49mKCs220keukN0MxiK/1WHQMiNxY7bePA6JPk1SMWyan64D9O6KmoelaIYO6vOWV8ndpQfBez2D1db4VCArJBJqHC1BRWS6/akkFMbsV6YXBi94rsfNAEx2m0d6X++cioqnuw2t3PvK2Bxnxc6TMrU= 11 | install: 12 | - bash ./scripts/travis_install.sh 13 | script: 14 | - bash ./scripts/travis_script.sh 15 | after_success: 16 | - bash ./scripts/travis_after_success.sh 17 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | We follow the [IPython Contributing Guide](https://github.com/ipython/ipython/blob/master/CONTRIBUTING.md). 4 | 5 | All source code is written in [TypeScript](http://www.typescriptlang.org/Handbook). See the [Style Guide](https://github.com/phosphorjs/phosphor/wiki/Style-Guide). 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Project Jupyter 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of jupyter-js-filebrowser nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Jupyter JS Plugins 2 | ================== 3 | 4 | Plugins for JupyterLab. The default set of [phosphide](https://github.com/phosphorjs/phosphide) 5 | plugins used to create [JupyterLab](https://github.com/jupyter/notebook/tree/master/notebook/lab). 6 | 7 | [API Docs](http://jupyter.github.io/jupyter-js-plugins/) 8 | 9 | JupyterLab Demo 10 | 11 | Package Install 12 | --------------- 13 | 14 | **Prerequisites** 15 | - [node](http://nodejs.org/) 16 | - [python](https://www.continuum.io/downloads) 17 | 18 | ```bash 19 | npm install --save jupyter-js-plugins 20 | conda install notebook # notebook 4.2+ required 21 | ``` 22 | 23 | 24 | Source Build 25 | ------------ 26 | 27 | **Prerequisites** 28 | - [git](http://git-scm.com/) 29 | - [node 0.12+](http://nodejs.org/) 30 | - [python](https://www.continuum.io/downloads) 31 | 32 | ```bash 33 | git clone https://github.com/jupyter/jupyter-js-plugins.git 34 | cd jupyter-js-plugins 35 | npm install 36 | npm run build 37 | conda install notebook # notebook 4.2+ required 38 | ``` 39 | 40 | **Rebuild** 41 | ```bash 42 | npm run clean 43 | npm run build 44 | ``` 45 | 46 | 47 | Run Tests 48 | --------- 49 | 50 | Follow the source build instructions first. 51 | 52 | ```bash 53 | npm test 54 | ``` 55 | 56 | 57 | Build Example 58 | ------------- 59 | 60 | Follow the source build instructions first. 61 | Requires a Python install with the Jupyter notebook. 62 | 63 | ```bash 64 | npm run build:example 65 | ``` 66 | 67 | Change to `example` directory and run `python main.py`. 68 | 69 | 70 | Build Docs 71 | ---------- 72 | 73 | Follow the source build instructions first. 74 | 75 | ```bash 76 | npm run docs 77 | ``` 78 | 79 | Navigate to `docs/index.html`. 80 | 81 | 82 | Supported Runtimes 83 | ------------------ 84 | 85 | The runtime versions which are currently *known to work* are listed below. 86 | Earlier versions may also work, but come with no guarantees. 87 | 88 | - IE 11+ 89 | - Firefox 32+ 90 | - Chrome 38+ 91 | 92 | Note: "requirejs" must be included in a global context (usually as a 93 | ` 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /example/index.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 'use strict'; 4 | 5 | var phosphide = require('phosphide/lib/core/application'); 6 | 7 | // ES6 Promise polyfill 8 | require('es6-promise').polyfill(); 9 | 10 | require('jupyter-js-plugins/lib/default-theme/index.css'); 11 | 12 | var app = new phosphide.Application({ 13 | extensions: [ 14 | require('phosphide/lib/extensions/commandpalette').commandPaletteExtension, 15 | require('jupyter-js-plugins/lib/terminal/plugin').terminalExtension, 16 | require('jupyter-js-plugins/lib/editorhandler/plugin').editorHandlerExtension, 17 | require('jupyter-js-plugins/lib/filebrowser/plugin').fileBrowserExtension, 18 | require('jupyter-js-plugins/lib/imagehandler/plugin').imageHandlerExtension, 19 | require('jupyter-js-plugins/lib/help/plugin').helpHandlerExtension, 20 | require('jupyter-js-plugins/lib/notebook/plugin').notebookHandlerExtension, 21 | require('jupyter-js-plugins/lib/shortcuts/plugin').shortcutsExtension, 22 | require('jupyter-js-plugins/lib/about/plugin').aboutExtension, 23 | require('jupyter-js-plugins/lib/landing/plugin').landingExtension, 24 | require('jupyter-js-plugins/lib/console/plugin').consoleExtension, 25 | require('jupyter-js-plugins/lib/main/plugin').mainExtension, 26 | require('jupyter-js-plugins/lib/widgets/index').widgetManagerExtension, 27 | ], 28 | providers: [ 29 | require('jupyter-js-plugins/lib/clipboard/plugin').clipboardProvider, 30 | require('jupyter-js-plugins/lib/docregistry/plugin').docRegistryProvider, 31 | require('jupyter-js-plugins/lib/services/plugin').servicesProvider, 32 | require('jupyter-js-plugins/lib/rendermime/plugin').renderMimeProvider, 33 | require('jupyter-js-plugins/lib/notebook/plugin').activeNotebookProvider 34 | ] 35 | }); 36 | 37 | window.onload = function() { 38 | app.run(); 39 | } 40 | -------------------------------------------------------------------------------- /example/jupyter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter/jupyter-js-plugins/e08e191c25c6a71d8dd88591a5260417e3a03a21/example/jupyter.png -------------------------------------------------------------------------------- /example/main.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) Jupyter Development Team. 3 | Distributed under the terms of the Modified BSD License. 4 | """ 5 | import re 6 | import subprocess 7 | import sys 8 | import threading 9 | 10 | import tornado.web 11 | 12 | # Install the pyzmq ioloop. This has to be done before anything else from 13 | # tornado is imported. 14 | from zmq.eventloop import ioloop 15 | ioloop.install() 16 | 17 | PORT = 8765 18 | 19 | 20 | class MainPageHandler(tornado.web.RequestHandler): 21 | 22 | def initialize(self, base_url, ws_url): 23 | self.base_url = base_url 24 | self.ws_url = ws_url 25 | 26 | def get(self): 27 | return self.render("index.html", static=self.static_url, 28 | base_url=self.base_url, ws_url=self.ws_url) 29 | 30 | 31 | def main(argv): 32 | 33 | url = "http://localhost:%s" % PORT 34 | 35 | nb_command = [sys.executable, '-m', 'notebook', '--no-browser', '--debug', 36 | '--NotebookApp.allow_origin="%s"' % url] 37 | nb_server = subprocess.Popen(nb_command, stderr=subprocess.STDOUT, 38 | stdout=subprocess.PIPE) 39 | 40 | # wait for notebook server to start up 41 | while 1: 42 | line = nb_server.stdout.readline().decode('utf-8').strip() 43 | if not line: 44 | continue 45 | print(line) 46 | if 'Jupyter Notebook is running at:' in line: 47 | base_url = re.search('(http.*?)$', line).groups()[0] 48 | ws_url = base_url.replace('http', 'ws') 49 | break 50 | 51 | while 1: 52 | line = nb_server.stdout.readline().decode('utf-8').strip() 53 | if not line: 54 | continue 55 | print(line) 56 | if 'Control-C' in line: 57 | break 58 | 59 | def print_thread(): 60 | while 1: 61 | line = nb_server.stdout.readline().decode('utf-8').strip() 62 | if not line: 63 | continue 64 | print(line) 65 | 66 | thread = threading.Thread(target=print_thread) 67 | thread.setDaemon(True) 68 | thread.start() 69 | 70 | handlers = [ 71 | (r"/", MainPageHandler, {'base_url': base_url, 'ws_url': ws_url}), 72 | (r'/(.*)', tornado.web.StaticFileHandler, {'path': '.'}), 73 | ] 74 | 75 | app = tornado.web.Application(handlers, static_path='build', 76 | template_path='.', 77 | compiled_template_cache=False) 78 | 79 | app.listen(PORT, 'localhost') 80 | 81 | if sys.platform.startswith('win'): 82 | # add no-op to wake every 5s 83 | # to handle signals that may be ignored by the inner loop 84 | pc = ioloop.PeriodicCallback(lambda: None, 5000) 85 | pc.start() 86 | 87 | loop = ioloop.IOLoop.current() 88 | print('Browse to http://localhost:%s' % PORT) 89 | try: 90 | loop.start() 91 | except KeyboardInterrupt: 92 | print(" Shutting down on SIGINT") 93 | finally: 94 | nb_server.kill() 95 | loop.close() 96 | 97 | if __name__ == '__main__': 98 | main(sys.argv) 99 | -------------------------------------------------------------------------------- /example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "name": "jupyter-js-plugins-example", 4 | "dependencies": { 5 | "es6-promise": "^3.1.2", 6 | "jupyter-js-plugins": "file:..", 7 | "jupyter-js-services": "^0.10.4", 8 | "phosphide": "^0.9.4" 9 | }, 10 | "scripts": { 11 | "build": "webpack --config webpack.conf.js", 12 | "clean": "rimraf build && rimraf node_modules", 13 | "postinstall": "npm dedupe", 14 | "update": "rimraf node_modules/jupyter-js-plugins && npm install", 15 | "watch": "watch 'npm run update && npm run build' ../src --wait 10" 16 | }, 17 | "devDependencies": { 18 | "rimraf": "^2.5.2", 19 | "watch": "^0.18.0", 20 | "webpack": "^1.13.1" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /example/webpack.conf.js: -------------------------------------------------------------------------------- 1 | 2 | module.exports = { 3 | entry: './index.js', 4 | output: { 5 | path: __dirname + "/build", 6 | filename: "bundle.js", 7 | publicPath: "./build/" 8 | }, 9 | node: { 10 | fs: "empty" 11 | }, 12 | debug: true, 13 | devtool: 'source-map', 14 | bail: true, 15 | module: { 16 | loaders: [ 17 | { test: /\.css$/, loader: 'style-loader!css-loader' }, 18 | { test: /\.json$/, loader: 'json-loader' }, 19 | { test: /\.html$/, loader: 'file' }, 20 | // Handle image 21 | { test: /\.(jpg|png|gif|svg)$/, loader: "file" }, 22 | ] 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /jupyter-plugins-demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter/jupyter-js-plugins/e08e191c25c6a71d8dd88591a5260417e3a03a21/jupyter-plugins-demo.gif -------------------------------------------------------------------------------- /jupyter_plugins.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter/jupyter-js-plugins/e08e191c25c6a71d8dd88591a5260417e3a03a21/jupyter_plugins.png -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jupyter-js-plugins", 3 | "version": "0.13.0", 4 | "description": "Plugins for JupyterLab", 5 | "main": "lib/index.js", 6 | "typings": "lib/index.d.ts", 7 | "dependencies": { 8 | "backbone": "^1.2.0", 9 | "codemirror": "^5.12.0", 10 | "file-loader": "^0.8.5", 11 | "jquery": "^2.2.0", 12 | "jquery-ui": "^1.10.5", 13 | "jupyter-js-notebook": "^0.21.2", 14 | "jupyter-js-services": "^0.10.4", 15 | "jupyter-js-ui": "^0.14.0", 16 | "jupyter-js-utils": "^0.4.0", 17 | "phosphide": "^0.9.4", 18 | "phosphor-codemirror": "^0.0.1", 19 | "phosphor-di": "^0.9.0", 20 | "phosphor-disposable": "^1.0.5", 21 | "phosphor-keymap": "^0.8.0", 22 | "phosphor-menus": "^1.0.0-rc.1", 23 | "phosphor-panel": "^1.0.0-rc.1", 24 | "phosphor-properties": "^2.0.0", 25 | "phosphor-signaling": "^1.2.0", 26 | "phosphor-tabs": "^1.0.0-rc.2", 27 | "phosphor-widget": "^1.0.0-rc.1" 28 | }, 29 | "devDependencies": { 30 | "css-loader": "^0.23.1", 31 | "expect.js": "^0.3.1", 32 | "file-loader": "^0.8.5", 33 | "fs-extra": "^0.26.4", 34 | "istanbul-instrumenter-loader": "^0.1.3", 35 | "json-loader": "^0.5.4", 36 | "karma": "^0.13.19", 37 | "karma-chrome-launcher": "^0.2.2", 38 | "karma-coverage": "^0.5.3", 39 | "karma-firefox-launcher": "^0.1.7", 40 | "karma-ie-launcher": "^0.2.0", 41 | "karma-mocha": "^0.2.1", 42 | "karma-mocha-reporter": "^1.1.5", 43 | "mocha": "^2.3.4", 44 | "rimraf": "^2.5.0", 45 | "style-loader": "^0.13.0", 46 | "typedoc": "https://github.com/SierraSoftworks/typedoc.git#cb5aea2b218b4f773451e2818a48629ee9c5066e", 47 | "typescript": "^1.8.0", 48 | "url-loader": "^0.5.7", 49 | "watch": "^0.17.1", 50 | "webpack": "^1.12.11" 51 | }, 52 | "scripts": { 53 | "clean": "rimraf docs && rimraf lib && rimraf test/build", 54 | "clean:example": "rimraf example/build", 55 | "build:example": "cd example && npm run update && npm run build", 56 | "build:src": "tsc --project src && node scripts/copyfiles.js", 57 | "build:test": "tsc --project test/src && webpack --config test/webpack.conf.js", 58 | "build": "npm run build:src", 59 | "docs": "typedoc --mode file --module commonjs --excludeNotExported --target es5 --moduleResolution node --out docs/ src", 60 | "postinstall": "npm dedupe", 61 | "prepublish": "npm run build", 62 | "test:chrome": "karma start --browsers=Chrome test/karma.conf.js", 63 | "test:coverage": "npm run build:test && webpack --config test/webpack-cov.conf.js && karma start test/karma-cov.conf.js", 64 | "test:firefox": "karma start --browsers=Firefox test/karma.conf.js", 65 | "test:ie": "karma start --browsers=IE test/karma.conf.js", 66 | "test:debug": "karma start --browsers=Chrome --singleRun=false --debug=true test/karma.conf.js", 67 | "test": "npm run build:test && npm run test:firefox", 68 | "watch": "watch 'npm run build' src --wait 10", 69 | "watch:test": "watch 'npm run build && npm test' src src/test --wait 10" 70 | }, 71 | "repository": { 72 | "type": "git", 73 | "url": "https://github.com/jupyter/jupyter-js-plugins" 74 | }, 75 | "keywords": [ 76 | "jupyter", 77 | "jupyterlab", 78 | "plugins", 79 | "lab" 80 | ], 81 | "files": [ 82 | "lib/*.css", 83 | "lib/*.d.ts", 84 | "lib/*.js", 85 | "lib/**/*.css", 86 | "lib/**/*.d.ts", 87 | "lib/**/*.js", 88 | "lib/**/*.svg" 89 | ], 90 | "author": "Project Jupyter", 91 | "license": "BSD-3-Clause", 92 | "bugs": { 93 | "url": "https://github.com/jupyter/jupyter-js-plugins/issues" 94 | }, 95 | "homepage": "https://github.com/jupyter/jupyter-js-plugins" 96 | } 97 | -------------------------------------------------------------------------------- /scripts/copyfiles.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs-extra'); 2 | fs.copySync('src/', 'lib/', { filter: /\.css$/ }); 3 | fs.copySync('src/', 'lib/', { filter: /\.svg$/ }); 4 | -------------------------------------------------------------------------------- /scripts/travis_after_success.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [[ $TRAVIS_PULL_REQUEST == false && $TRAVIS_BRANCH == "master" ]] 3 | then 4 | echo "-- pushing docs --" 5 | 6 | ( cd docs 7 | git init 8 | git config user.email "travis@travis-ci.com" 9 | git config user.name "Travis Bot" 10 | 11 | git add . 12 | git commit -m "Deploy to GitHub Pages" 13 | git push --force --quiet "https://${GHTOKEN}@${GH_REF}" master:gh-pages > /dev/null 2>&1 14 | ) && echo "-- pushed docs --" 15 | else 16 | echo "-- will only push docs from master --" 17 | fi 18 | -------------------------------------------------------------------------------- /scripts/travis_install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | npm install 3 | wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh; 4 | bash miniconda.sh -b -p $HOME/miniconda 5 | export PATH="$HOME/miniconda/bin:$PATH" 6 | hash -r 7 | conda config --set always_yes yes --set changeps1 no 8 | conda update -q conda 9 | conda info -a 10 | conda install jupyter 11 | 12 | # create jupyter base dir (needed for config retreival) 13 | mkdir ~/.jupyter 14 | -------------------------------------------------------------------------------- /scripts/travis_script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | export DISPLAY=:99.0 4 | sh -e /etc/init.d/xvfb start || true 5 | 6 | npm run clean 7 | npm run build 8 | npm test 9 | npm run test:coverage 10 | export PATH="$HOME/miniconda/bin:$PATH" 11 | npm run build:example 12 | npm run docs 13 | cp jupyter-plugins-demo.gif docs 14 | -------------------------------------------------------------------------------- /src/about/plugin.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 'use strict'; 4 | 5 | import { 6 | Application 7 | } from 'phosphide/lib/core/application'; 8 | 9 | import { 10 | Widget 11 | } from 'phosphor-widget'; 12 | 13 | 14 | /** 15 | * The about page extension. 16 | */ 17 | export 18 | const aboutExtension = { 19 | id: 'jupyter.extensions.about', 20 | activate: activateAbout 21 | }; 22 | 23 | 24 | function activateAbout(app: Application): void { 25 | let widget = new Widget(); 26 | let commandId = 'about-jupyterlab:show'; 27 | widget.id = 'about-jupyterlab'; 28 | widget.title.text = 'About'; 29 | widget.title.closable = true; 30 | widget.node.innerHTML = ` 31 |

Welcome to the JupyterLab alpha preview

32 | 33 |

This demo gives an alpha-level preview of the JupyterLab environment. Here is a brief description of some of the things you'll find in this demo.

34 | 35 |

File Browser

36 | 37 |

Clicking the "Files" tab, located on the left, will toggle the file browser. Navigate into directories by double-clicking, and use the breadcrumbs at the top to navigate out. Create a new file/directory by clicking the plus icon at the top. Click the middle icon to upload files,and click the last icon to reload the file listing. Drag and drop files to move them to subdirectories. Click on a selected file to rename it. Sort the list by clicking on a column header. Open a file by double-clicking it or dragging it into the main area. Opening an image displays the image. Opening a code file opens a code editor. Opening a notebook opens a very preliminary proof-of-concept non-executable view of the notebook.

38 | 39 |

Command Palette

40 | 41 |

Clicking the "Commands" tab, located on the left, will toggle the command palette. Execute a command by clicking, or navigating with your arrow keys and pressing Enter. Filter commands by typing in the text box at the top of the palette. The palette is organized into categories, and you can filter on a single category by clicking on the category header or by typing the header surrounded by colons in the search input (e.g., :file:).

42 | 43 |

You can try these things out from the command palette:

44 | 45 | 51 | 52 |

Main area

53 | 54 |

The main area is divided into panels of tabs. Drag a tab around the area to split the main area in different ways. Drag a tab to the center of a panel to move a tab without splitting the panel (in this case, the whole panel will highlight, instead of just a portion). Resize panels by dragging their borders (be aware that panels and sidebars also have a minimum width). A file that contains changes to be saved has a star for a close icon.

55 | 56 |

Notebook

57 | 58 |

Opening a notebook will open a minimally featured notebook. Code execution, Markdown rendering, and basic cell toolbar actions are supported. Future versions will add more features from the existing Jupyter notebook.

59 | `; 60 | 61 | app.commands.add([{ 62 | id: commandId, 63 | handler: () => { 64 | if (!widget.isAttached) app.shell.addToMainArea(widget); 65 | app.shell.activateMain(widget.id); 66 | } 67 | }]); 68 | 69 | app.palette.add([{ 70 | command: commandId, 71 | text: 'About JupyterLab', 72 | category: 'Help' 73 | }]); 74 | } 75 | -------------------------------------------------------------------------------- /src/clipboard/plugin.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 'use strict'; 4 | 5 | import { 6 | MimeData as IClipboard 7 | } from 'phosphor-dragdrop'; 8 | 9 | 10 | /** 11 | * The clipboard provider. 12 | */ 13 | export 14 | const clipboardProvider = { 15 | id: 'jupyter.services.clipboard', 16 | provides: IClipboard, 17 | resolve: () => { 18 | return new IClipboard(); 19 | } 20 | }; 21 | -------------------------------------------------------------------------------- /src/console/plugin.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 'use strict'; 4 | 5 | import { 6 | ConsolePanel 7 | } from 'jupyter-js-notebook/lib/console'; 8 | 9 | import { 10 | RenderMime 11 | } from 'jupyter-js-ui/lib/rendermime'; 12 | 13 | import { 14 | selectKernel 15 | } from 'jupyter-js-ui/lib/docmanager'; 16 | 17 | import { 18 | Application 19 | } from 'phosphide/lib/core/application'; 20 | 21 | import { 22 | TabPanel 23 | } from 'phosphor-tabs'; 24 | 25 | import { 26 | Widget 27 | } from 'phosphor-widget'; 28 | 29 | import { 30 | JupyterServices 31 | } from '../services/plugin'; 32 | 33 | 34 | /** 35 | * The console extension. 36 | */ 37 | export 38 | const consoleExtension = { 39 | id: 'jupyter.extensions.console', 40 | requires: [JupyterServices, RenderMime], 41 | activate: activateConsole 42 | }; 43 | 44 | 45 | /** 46 | * Activate the console extension. 47 | */ 48 | function activateConsole(app: Application, services: JupyterServices, rendermime: RenderMime): Promise { 49 | 50 | let manager = services.notebookSessionManager; 51 | 52 | // Add the ability to create new consoles for each kernel. 53 | let specs = services.kernelspecs; 54 | let displayNameMap: { [key: string]: string } = Object.create(null); 55 | for (let kernelName in specs.kernelspecs) { 56 | let displayName = specs.kernelspecs[kernelName].spec.display_name; 57 | displayNameMap[displayName] = kernelName; 58 | } 59 | let displayNames = Object.keys(displayNameMap).sort((a, b) => { 60 | return a.localeCompare(b); 61 | }); 62 | let count = 0; 63 | for (let displayName of displayNames) { 64 | let id = `console:create-${displayNameMap[displayName]}`; 65 | app.commands.add([{ 66 | id, 67 | handler: () => { 68 | manager.startNew({ 69 | notebookPath: `Console-${count++}`, 70 | kernelName: `${displayNameMap[displayName]}` 71 | }).then(session => { 72 | let console = new ConsolePanel(session, rendermime.clone()); 73 | console.id = `console-${count}`; 74 | console.title.text = `Console-${count}`; 75 | console.title.closable = true; 76 | app.shell.addToMainArea(console); 77 | Private.activeWidget = console; 78 | // TODO: Move this logic to the shell. 79 | let stack = console.parent; 80 | if (!stack) { 81 | return; 82 | } 83 | let tabs = stack.parent; 84 | if (tabs instanceof TabPanel) { 85 | tabs.currentWidget = console; 86 | } 87 | console.content.prompt.focus(); 88 | console.disposed.connect(() => { 89 | let index = Private.widgets.indexOf(console); 90 | Private.widgets.splice(index, 1); 91 | if (Private.activeWidget === console) { 92 | Private.activeWidget = null; 93 | } 94 | }); 95 | }); 96 | } 97 | }]); 98 | app.palette.add([{ 99 | command: id, 100 | category: 'Console', 101 | text: `New ${displayName}` 102 | }]); 103 | } 104 | 105 | // Temporary console focus follower. 106 | document.body.addEventListener('focus', event => { 107 | for (let widget of Private.widgets) { 108 | let target = event.target as HTMLElement; 109 | if (widget.isAttached && widget.isVisible) { 110 | if (widget.node.contains(target)) { 111 | Private.activeWidget = widget; 112 | return; 113 | } 114 | } 115 | } 116 | }, true); 117 | 118 | app.commands.add([ 119 | { 120 | id: 'console:clear', 121 | handler: () => { 122 | if (Private.activeWidget) { 123 | Private.activeWidget.content.clear(); 124 | } 125 | } 126 | }, 127 | { 128 | id: 'console:execute', 129 | handler: () => { 130 | if (Private.activeWidget) { 131 | Private.activeWidget.content.execute(); 132 | } 133 | } 134 | }, 135 | { 136 | id: 'console:interrupt-kernel', 137 | handler: () => { 138 | if (Private.activeWidget) { 139 | let kernel = Private.activeWidget.content.session.kernel; 140 | if (kernel) { 141 | kernel.interrupt(); 142 | } 143 | } 144 | } 145 | }, 146 | { 147 | id: 'console:switch-kernel', 148 | handler: () => { 149 | if (Private.activeWidget) { 150 | let widget = Private.activeWidget.content; 151 | let session = widget.session; 152 | let lang = ''; 153 | if (session.kernel) { 154 | lang = specs.kernelspecs[session.kernel.name].spec.language; 155 | } 156 | manager.listRunning().then(sessions => { 157 | let options = { 158 | name: widget.parent.title.text, 159 | specs, 160 | sessions, 161 | preferredLanguage: lang, 162 | kernel: session.kernel, 163 | host: widget.parent.node 164 | }; 165 | return selectKernel(options); 166 | }).then(kernelId => { 167 | if (kernelId) { 168 | session.changeKernel(kernelId); 169 | } else { 170 | session.kernel.shutdown(); 171 | } 172 | }); 173 | } 174 | } 175 | } 176 | 177 | ]); 178 | app.palette.add([ 179 | { 180 | command: 'console:clear', 181 | category: 'Console', 182 | text: 'Clear Cells' 183 | }, 184 | { 185 | command: 'console:execute', 186 | category: 'Console', 187 | text: 'Execute Cell' 188 | }, 189 | { 190 | command: 'console:interrupt-kernel', 191 | category: 'Console', 192 | text: 'Interrupt Kernel' 193 | }, 194 | { 195 | command: 'console:switch-kernel', 196 | category: 'Console', 197 | text: 'Switch Kernel' 198 | }]); 199 | 200 | return Promise.resolve(void 0); 201 | } 202 | 203 | 204 | /** 205 | * A namespace for private data. 206 | */ 207 | namespace Private { 208 | export 209 | var widgets: ConsolePanel[] = []; 210 | 211 | export 212 | var activeWidget: ConsolePanel = null; 213 | } 214 | -------------------------------------------------------------------------------- /src/default-theme/about.css: -------------------------------------------------------------------------------- 1 | #about-jupyterlab { 2 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; 3 | padding: 2em; 4 | } 5 | -------------------------------------------------------------------------------- /src/default-theme/commandpalette.css: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------- 2 | | Copyright (c) Jupyter Development Team. 3 | | Distributed under the terms of the Modified BSD License. 4 | |----------------------------------------------------------------------------*/ 5 | .p-CommandPalette { 6 | min-width: 300px; 7 | padding: 8px; 8 | padding-bottom: 0px; 9 | color: #757575; 10 | background: #FAFAFA; 11 | font-family: "Helvetica Neue", Helvetica; 12 | } 13 | 14 | 15 | .p-CommandPalette-search { 16 | margin-bottom: 4px; 17 | } 18 | 19 | 20 | .p-CommandPalette-inputWrapper { 21 | padding: 4px 6px; 22 | background: white; 23 | border: 1px solid #E0E0E0; 24 | border-radius: 4px; 25 | } 26 | 27 | 28 | .p-CommandPalette-input { 29 | width: 100%; 30 | outline: none; 31 | border: none; 32 | } 33 | 34 | 35 | .p-CommandPalette-header { 36 | margin: 4px 0px; 37 | padding: 4px 0px; 38 | font-size: 11px; 39 | font-weight: 500; 40 | text-transform: capitalize; 41 | border-bottom: 1px solid #E0E0E0; 42 | } 43 | 44 | 45 | .p-CommandPalette-command { 46 | padding: 4px; 47 | font-size: 13px; 48 | font-weight: 500; 49 | } 50 | 51 | 52 | .p-CommandPalette-commandCaption { 53 | font-size: 10px; 54 | font-weight: 400; 55 | color: #9E9E9E; 56 | } 57 | 58 | 59 | .p-CommandPalette-header:hover:not(.p-mod-active), 60 | .p-CommandPalette-command:hover:not(.p-mod-active) { 61 | background: #EEEEEE; 62 | border-radius: 2px; 63 | } 64 | 65 | 66 | .p-CommandPalette-header.p-mod-active, 67 | .p-CommandPalette-command.p-mod-active { 68 | color: white; 69 | background: #F27624; 70 | border-radius: 2px; 71 | } 72 | 73 | 74 | .p-CommandPalette-command.p-mod-active .p-CommandPalette-commandCaption { 75 | color: inherit; 76 | } 77 | 78 | 79 | .p-CommandPalette mark { 80 | color: #424242; 81 | font-weight: bold; 82 | background: inherit; 83 | } 84 | -------------------------------------------------------------------------------- /src/default-theme/help.css: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------- 2 | | Copyright (c) Jupyter Development Team. 3 | | Distributed under the terms of the Modified BSD License. 4 | |----------------------------------------------------------------------------*/ 5 | .jp-Help { 6 | min-width: 480px; 7 | background: white; 8 | } 9 | 10 | 11 | .jp-Help > iframe { 12 | border: none; 13 | } 14 | 15 | 16 | /* 17 | When drag events occur, `p-mod-override-cursor` is added to the body. 18 | Because iframes steal all cursor events, the following two rules are necessary 19 | to suppress pointer events while resize drags are occuring. There may be a 20 | better solution to this problem. 21 | */ 22 | body.p-mod-override-cursor .jp-Help { 23 | position: relative; 24 | } 25 | 26 | body.p-mod-override-cursor .jp-Help:before { 27 | content: ''; 28 | position: absolute; 29 | top: 0; 30 | left: 0; 31 | right: 0; 32 | bottom: 0; 33 | background: transparent; 34 | } 35 | -------------------------------------------------------------------------------- /src/default-theme/index.css: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------- 2 | | Copyright (c) Jupyter Development Team. 3 | | Distributed under the terms of the Modified BSD License. 4 | |----------------------------------------------------------------------------*/ 5 | @import url('~jupyter-js-notebook/lib/index.css'); 6 | @import url('~jupyter-js-notebook/lib/theme.css'); 7 | @import url('~jupyter-js-ui/lib/index.css'); 8 | @import url('~jupyter-js-ui/lib/theme.css'); 9 | @import './commandpalette.css'; 10 | @import './help.css'; 11 | @import './about.css'; 12 | @import '../landing/index.css'; 13 | 14 | 15 | body { 16 | margin: 0; 17 | padding: 0; 18 | background: #E0E0E0; 19 | overflow: hidden; 20 | } 21 | 22 | 23 | .p-ApplicationShell.p-Widget { 24 | position: absolute; 25 | top: 0; 26 | left: 0; 27 | right: 0; 28 | bottom: 0; 29 | font-size: 13px; 30 | } 31 | 32 | 33 | .jp-Document { 34 | min-width: 120px; 35 | min-height: 120px; 36 | outline: none; 37 | } 38 | 39 | 40 | .jp-NotebookContainer-widget { 41 | flex: 0 0 auto; 42 | } 43 | 44 | 45 | .jp-Notebook { 46 | flex: 1 1 auto; 47 | } 48 | 49 | 50 | 51 | .jp-FileBrowser { 52 | min-width: 300px; 53 | } 54 | 55 | 56 | .p-SideBar { 57 | min-width: 36px; 58 | max-width: 36px; 59 | font-size: 13px; 60 | font-family: Helvetica, Arial; 61 | color: #757575; 62 | background: #EEEEEE; 63 | } 64 | 65 | 66 | .p-SideBar.p-Widget { 67 | overflow: visible; 68 | } 69 | 70 | 71 | .p-SideBar.p-mod-left { 72 | border-right: 1px solid #BDBDBD; 73 | } 74 | 75 | 76 | .p-SideBar.p-mod-right { 77 | border-left: 1px solid #BDBDBD; 78 | } 79 | 80 | 81 | .p-SideBar-content { 82 | height: 35px; 83 | transform-origin: 0 0 0; 84 | } 85 | 86 | 87 | .p-SideBar.p-mod-left > .p-SideBar-content { 88 | flex-direction: row-reverse; 89 | transform: rotate(-90deg) translateX(-100%); 90 | } 91 | 92 | 93 | .p-SideBar.p-mod-right > .p-SideBar-content { 94 | flex-direction: row; 95 | transform: rotate(90deg) translateY(-100%); 96 | } 97 | 98 | 99 | .p-SideBar-button { 100 | padding: 0 18px; 101 | line-height: 35px; 102 | } 103 | 104 | 105 | .p-SideBar-button:hover:not(.p-mod-current) { 106 | background: #FAFAFA; 107 | } 108 | 109 | 110 | .p-SideBar-button.p-mod-current { 111 | color: #F27624; 112 | background: #FAFAFA; 113 | } 114 | 115 | 116 | .p-SideBar.p-mod-left .p-SideBar-button { 117 | border-left: 1px solid #BDBDBD; 118 | } 119 | 120 | 121 | .p-SideBar.p-mod-right .p-SideBar-button { 122 | border-right: 1px solid #BDBDBD; 123 | } 124 | 125 | 126 | #p-main-dock-panel { 127 | padding: 8px; 128 | } 129 | 130 | 131 | .p-DockTabPanel { 132 | border: 1px solid #BDBDBD; 133 | border-top: none; 134 | } 135 | 136 | 137 | .p-DockTabPanel > .p-StackedPanel { 138 | background: white; 139 | } 140 | 141 | 142 | .p-DockPanel-overlay { 143 | background: rgba(242, 118, 36, 0.1); 144 | border: 1px dashed #F27624; 145 | } 146 | 147 | 148 | .p-DockPanel-overlay.p-mod-root-top, 149 | .p-DockPanel-overlay.p-mod-root-left, 150 | .p-DockPanel-overlay.p-mod-root-right, 151 | .p-DockPanel-overlay.p-mod-root-bottom, 152 | .p-DockPanel-overlay.p-mod-root-center { 153 | border-width: 2px; 154 | } 155 | 156 | 157 | .p-TabBar { 158 | min-height: 28px; 159 | max-height: 28px; 160 | color: #757575; 161 | background: #F5F5F5; 162 | font: 12px Helvetica, Arial, sans-serif; 163 | } 164 | 165 | 166 | /* increase specificity to override default */ 167 | .p-TabBar > .p-TabBar-header { 168 | flex: 0 0 1px; 169 | background: #BDBDBD; 170 | } 171 | 172 | 173 | .p-TabBar-content { 174 | min-width: 0; 175 | max-height: 22px; 176 | } 177 | 178 | 179 | /* increase specificity to override default */ 180 | .p-TabBar > .p-TabBar-footer { 181 | flex: 0 0 3px; 182 | background: #FAFAFA; 183 | border-top: 1px solid #BDBDBD; 184 | border-bottom: 1px solid #E0E0E0; 185 | } 186 | 187 | 188 | .p-TabBar-tab { 189 | flex-basis: 144px; 190 | min-height: 23px; 191 | max-height: 23px; 192 | min-width: 35px; 193 | margin-left: -1px; 194 | padding: 0px 10px; 195 | background: #EEEEEE; 196 | border: 1px solid #BDBDBD; 197 | border-bottom: none; 198 | transform: translateY(-1px); 199 | } 200 | 201 | 202 | .p-TabBar-tab:last-child { 203 | margin-right: -1px; 204 | } 205 | 206 | 207 | .p-TabBar-tab.p-mod-current { 208 | min-height: 24px; 209 | max-height: 24px; 210 | background: #FAFAFA; 211 | border-top: 1px solid #F27624; 212 | } 213 | 214 | 215 | .p-TabBar-tab:hover:not(.p-mod-current) { 216 | background: #FAFAFA; 217 | } 218 | 219 | 220 | .p-TabBar-tabIcon, 221 | .p-TabBar-tabText, 222 | .p-TabBar-tabCloseIcon { 223 | line-height: 22px; 224 | } 225 | 226 | 227 | .p-TabBar-tab.p-mod-closable > .p-TabBar-tabCloseIcon { 228 | margin-left: 4px; 229 | } 230 | 231 | 232 | .p-TabBar-tab.p-mod-closable > .p-TabBar-tabCloseIcon:before { 233 | font-family: FontAwesome; 234 | content: '\f00d'; /* close */ 235 | } 236 | 237 | 238 | .p-TabBar-tab.p-mod-closable.jp-mod-dirty > .p-TabBar-tabCloseIcon:before { 239 | font-family: FontAwesome; 240 | content: '\f069'; /* asterisk */ 241 | } 242 | 243 | 244 | .p-TabBar-tab.p-mod-drag-image { 245 | min-height: 24px; 246 | min-width: 124px; 247 | color: #757575; 248 | background: white; 249 | border: 1px solid #BDBDBD; 250 | border-top: 1px solid #F27624; 251 | font: 12px Helvetica, Arial, sans-serif; 252 | box-shadow: 1px 1px 2px rgba(0, 0, 1, 0.1); 253 | transform: translateX(-40%) translateY(-58%); 254 | } 255 | 256 | 257 | #p-main-split-panel > .p-SplitPanel-handle { 258 | background: #BDBDBD; 259 | } 260 | 261 | 262 | .p-MenuBar { 263 | padding-left: 5px; 264 | background: #FAFAFA; 265 | color: rgba(0, 0, 0, 0.87); 266 | border-bottom: 1px solid #DDDDDD; 267 | font: 13px Helvetica, Arial, sans-serif; 268 | } 269 | 270 | 271 | .p-MenuBar-menu { 272 | transform: translateY(-1px); 273 | } 274 | 275 | 276 | .p-MenuBar-item { 277 | padding: 4px 8px; 278 | border-left: 1px solid transparent; 279 | border-right: 1px solid transparent; 280 | } 281 | 282 | 283 | .p-MenuBar-item.p-mod-active { 284 | background: #E5E5E5; 285 | } 286 | 287 | 288 | .p-MenuBar-item.p-mod-disabled { 289 | color: rgba(0, 0, 0, 0.26); 290 | } 291 | 292 | 293 | .p-MenuBar-item.p-type-separator { 294 | margin: 2px; 295 | padding: 0; 296 | border: none; 297 | border-left: 1px solid #DDDDDD; 298 | } 299 | 300 | 301 | .p-MenuBar.p-mod-active .p-MenuBar-item.p-mod-active { 302 | z-index: 10001; 303 | background: white; 304 | border-left: 1px solid #C0C0C0; 305 | border-right: 1px solid #C0C0C0; 306 | box-shadow: 0px 0px 6px rgba(0, 0, 0, 0.2); 307 | } 308 | 309 | 310 | .p-Menu { 311 | z-index: 10000; 312 | padding: 3px 0px; 313 | background: white; 314 | color: rgba(0, 0, 0, 0.87); 315 | border: 1px solid #C0C0C0; 316 | font: 12px Helvetica, Arial, sans-serif; 317 | box-shadow: 0px 1px 6px rgba(0, 0, 0, 0.2); 318 | } 319 | 320 | 321 | .p-Menu-item.p-mod-active { 322 | background: #E5E5E5; 323 | } 324 | 325 | 326 | .p-Menu-item.p-mod-disabled { 327 | color: rgba(0, 0, 0, 0.26); 328 | } 329 | 330 | 331 | .p-Menu-itemIcon { 332 | width: 21px; 333 | padding: 4px 2px; 334 | } 335 | 336 | 337 | .p-Menu-itemText { 338 | padding: 4px 35px 4px 2px; 339 | } 340 | 341 | 342 | .p-Menu-itemShortcut { 343 | padding: 4px 0px; 344 | } 345 | 346 | 347 | .p-Menu-itemSubmenuIcon { 348 | width: 16px; 349 | padding: 4px 0px; 350 | } 351 | 352 | 353 | .p-Menu-item.p-type-separator > span { 354 | padding: 0; 355 | height: 9px; 356 | } 357 | 358 | 359 | .p-Menu-item.p-type-separator > span::after { 360 | content: ''; 361 | display: block; 362 | position: relative; 363 | top: 4px; 364 | border-top: 1px solid #DDDDDD; 365 | } 366 | 367 | 368 | .p-Menu-itemIcon::before, 369 | .p-Menu-itemSubmenuIcon::before { 370 | font-family: FontAwesome; 371 | } 372 | 373 | 374 | .p-Menu-item.p-type-check.p-mod-checked > .p-Menu-itemIcon::before { 375 | content: '\f00c'; 376 | } 377 | 378 | 379 | .p-Menu-item.p-type-submenu > .p-Menu-itemSubmenuIcon::before { 380 | content: '\f0da'; 381 | } 382 | -------------------------------------------------------------------------------- /src/docregistry/plugin.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 'use strict'; 4 | 5 | import { 6 | DocumentRegistry, TextModelFactory, Base64ModelFactory 7 | } from 'jupyter-js-ui/lib/docmanager'; 8 | 9 | 10 | /** 11 | * The default document registry provider. 12 | */ 13 | export 14 | const docRegistryProvider = { 15 | id: 'jupyter.services.document-registry', 16 | provides: DocumentRegistry, 17 | resolve: () => { 18 | let registry = new DocumentRegistry(); 19 | registry.registerModelFactory(new TextModelFactory()); 20 | registry.registerModelFactory(new Base64ModelFactory()); 21 | return registry; 22 | } 23 | }; 24 | -------------------------------------------------------------------------------- /src/editorhandler/plugin.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 'use strict'; 4 | 5 | import { 6 | DocumentRegistry, EditorWidgetFactory 7 | } from 'jupyter-js-ui/lib/docmanager'; 8 | 9 | import { 10 | Application 11 | } from 'phosphide/lib/core/application'; 12 | 13 | 14 | /** 15 | * The editor handler extension. 16 | */ 17 | export 18 | const editorHandlerExtension = { 19 | id: 'jupyter.extensions.editorHandler', 20 | requires: [DocumentRegistry], 21 | activate: (app: Application, registry: DocumentRegistry) => { 22 | registry.registerWidgetFactory(new EditorWidgetFactory(), 23 | { 24 | fileExtensions: ['.*'], 25 | displayName: 'Editor', 26 | modelName: 'text', 27 | defaultFor: ['.*'], 28 | preferKernel: false, 29 | canStartKernel: false 30 | }); 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /src/filebrowser/plugin.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 'use strict'; 4 | 5 | import { 6 | FileBrowserWidget, FileBrowserModel 7 | } from 'jupyter-js-ui/lib/filebrowser'; 8 | 9 | import { 10 | DocumentManager, DocumentRegistry, DocumentWidget 11 | } from 'jupyter-js-ui/lib/docmanager'; 12 | 13 | import { 14 | Application 15 | } from 'phosphide/lib/core/application'; 16 | 17 | import { 18 | Menu, MenuItem 19 | } from 'phosphor-menus'; 20 | 21 | import { 22 | TabPanel 23 | } from 'phosphor-tabs'; 24 | 25 | import { 26 | JupyterServices 27 | } from '../services/plugin'; 28 | 29 | 30 | /** 31 | * The default file browser extension. 32 | */ 33 | export 34 | const fileBrowserExtension = { 35 | id: 'jupyter.extensions.fileBrowser', 36 | requires: [JupyterServices, DocumentRegistry], 37 | activate: activateFileBrowser 38 | }; 39 | 40 | 41 | /** 42 | * Activate the file browser. 43 | */ 44 | function activateFileBrowser(app: Application, provider: JupyterServices, registry: DocumentRegistry): Promise { 45 | let contents = provider.contentsManager; 46 | let sessions = provider.notebookSessionManager; 47 | let widgets: DocumentWidget[] = []; 48 | let activeWidget: DocumentWidget; 49 | let id = 0; 50 | 51 | let opener = { 52 | open: (widget: DocumentWidget) => { 53 | if (!widget.id) { 54 | widget.id = `document-manager-${++id}`; 55 | } 56 | if (!widget.isAttached) { 57 | app.shell.addToMainArea(widget); 58 | } 59 | // TODO: Move this logic to the shell. 60 | let stack = widget.parent; 61 | if (!stack) { 62 | return; 63 | } 64 | let tabs = stack.parent; 65 | if (tabs instanceof TabPanel) { 66 | tabs.currentWidget = widget; 67 | } 68 | activeWidget = widget; 69 | widget.disposed.connect((w: DocumentWidget) => { 70 | let index = widgets.indexOf(w); 71 | widgets.splice(index, 1); 72 | }); 73 | } 74 | }; 75 | 76 | // TODO: Move focus tracking to the shell. 77 | document.addEventListener('focus', event => { 78 | for (let i = 0; i < widgets.length; i++) { 79 | let widget = widgets[i]; 80 | if (widget.node.contains(event.target as HTMLElement)) { 81 | activeWidget = widget; 82 | break; 83 | } 84 | } 85 | }); 86 | 87 | let docManager = new DocumentManager( 88 | registry, contents, sessions, provider.kernelspecs, opener 89 | ); 90 | let model = new FileBrowserModel(contents, sessions, provider.kernelspecs); 91 | let widget = new FileBrowserWidget(model, docManager, opener); 92 | let menu = createMenu(widget); 93 | 94 | // Add a context menu to the dir listing. 95 | let node = widget.node.getElementsByClassName('jp-DirListing-content')[0]; 96 | node.addEventListener('contextmenu', (event: MouseEvent) => { 97 | event.preventDefault(); 98 | let x = event.clientX; 99 | let y = event.clientY; 100 | menu.popup(x, y); 101 | }); 102 | 103 | // Add the command for a new items. 104 | let newTextFileId = 'file-operations:new-text-file'; 105 | 106 | app.commands.add([ 107 | { 108 | id: newTextFileId, 109 | handler: () => widget.createNew('file') 110 | } 111 | ]); 112 | 113 | let newNotebookId = 'file-operations:new-notebook'; 114 | 115 | app.commands.add([ 116 | { 117 | id: newNotebookId, 118 | handler: () => widget.createNew('notebook') 119 | }]); 120 | 121 | 122 | // Add the command for saving a document. 123 | let saveDocumentId = 'file-operations:save'; 124 | 125 | app.commands.add([ 126 | { 127 | id: saveDocumentId, 128 | handler: () => { 129 | if (!activeWidget) { 130 | return; 131 | } 132 | activeWidget.context.save(); 133 | } 134 | } 135 | ]); 136 | app.palette.add([ 137 | { 138 | command: saveDocumentId, 139 | category: 'File Operations', 140 | text: 'Save Document', 141 | caption: 'Save the current document' 142 | } 143 | ]); 144 | 145 | // Add the command for reverting a document. 146 | let revertDocumentId = 'file-operations:revert'; 147 | 148 | app.commands.add([ 149 | { 150 | id: revertDocumentId, 151 | handler: () => { 152 | if (!activeWidget) { 153 | return; 154 | } 155 | activeWidget.context.revert(); 156 | } 157 | } 158 | ]); 159 | app.palette.add([ 160 | { 161 | command: revertDocumentId, 162 | category: 'File Operations', 163 | text: 'Revert Document', 164 | caption: 'Revert the current document' 165 | } 166 | ]); 167 | 168 | // Add the command for closing a document. 169 | let closeDocumentId = 'file-operations:close'; 170 | 171 | app.commands.add([ 172 | { 173 | id: closeDocumentId, 174 | handler: () => { 175 | if (activeWidget) { 176 | activeWidget.close(); 177 | } 178 | } 179 | } 180 | ]); 181 | app.palette.add([ 182 | { 183 | command: closeDocumentId, 184 | category: 'File Operations', 185 | text: 'Close Document', 186 | caption: 'Close the current document' 187 | } 188 | ]); 189 | 190 | // Add the command for closing all documents. 191 | let closeAllId = 'file-operations:close-all'; 192 | 193 | app.commands.add([ 194 | { 195 | id: closeAllId, 196 | handler: () => { 197 | docManager.closeAll(); 198 | } 199 | } 200 | ]); 201 | app.palette.add([ 202 | { 203 | command: closeAllId, 204 | category: 'File Operations', 205 | text: 'Close All', 206 | caption: 'Close all open documents' 207 | } 208 | ]); 209 | 210 | app.palette.add([ 211 | { 212 | command: newTextFileId, 213 | category: 'File Operations', 214 | text: 'New Text File', 215 | caption: 'Create a new text file' 216 | }, 217 | { 218 | command: newNotebookId, 219 | category: 'File Operations', 220 | text: 'New Notebook', 221 | caption: 'Create a new notebook' 222 | } 223 | ]); 224 | 225 | app.commands.add([ 226 | { 227 | id: 'file-browser:activate', 228 | handler: showBrowser 229 | }, 230 | { 231 | id: 'file-browser:hide', 232 | handler: hideBrowser 233 | }, 234 | { 235 | id: 'file-browser:toggle', 236 | handler: toggleBrowser 237 | } 238 | ]); 239 | 240 | widget.title.text = 'Files'; 241 | widget.id = 'file-browser'; 242 | app.shell.addToLeftArea(widget, { rank: 40 }); 243 | showBrowser(); 244 | return Promise.resolve(void 0); 245 | 246 | function showBrowser(): void { 247 | app.shell.activateLeft(widget.id); 248 | } 249 | 250 | function hideBrowser(): void { 251 | if (!widget.isHidden) { 252 | app.shell.collapseLeft(); 253 | } 254 | } 255 | 256 | function toggleBrowser(): void { 257 | if (widget.isHidden) { 258 | showBrowser(); 259 | } else { 260 | hideBrowser(); 261 | } 262 | } 263 | } 264 | 265 | 266 | /** 267 | * Create a context menu for the file browser listing. 268 | */ 269 | function createMenu(fbWidget: FileBrowserWidget): Menu { 270 | return new Menu([ 271 | new MenuItem({ 272 | text: '&Open', 273 | icon: 'fa fa-folder-open-o', 274 | shortcut: 'Ctrl+O', 275 | handler: () => { fbWidget.open(); } 276 | }), 277 | new MenuItem({ 278 | text: '&Rename', 279 | icon: 'fa fa-edit', 280 | shortcut: 'Ctrl+R', 281 | handler: () => { fbWidget.rename(); } 282 | }), 283 | new MenuItem({ 284 | text: '&Delete', 285 | icon: 'fa fa-remove', 286 | shortcut: 'Ctrl+D', 287 | handler: () => { fbWidget.delete(); } 288 | }), 289 | new MenuItem({ 290 | text: 'Duplicate', 291 | icon: 'fa fa-copy', 292 | handler: () => { fbWidget.duplicate(); } 293 | }), 294 | new MenuItem({ 295 | text: 'Cut', 296 | icon: 'fa fa-cut', 297 | shortcut: 'Ctrl+X', 298 | handler: () => { fbWidget.cut(); } 299 | }), 300 | new MenuItem({ 301 | text: '&Copy', 302 | icon: 'fa fa-copy', 303 | shortcut: 'Ctrl+C', 304 | handler: () => { fbWidget.copy(); } 305 | }), 306 | new MenuItem({ 307 | text: '&Paste', 308 | icon: 'fa fa-paste', 309 | shortcut: 'Ctrl+V', 310 | handler: () => { fbWidget.paste(); } 311 | }), 312 | new MenuItem({ 313 | text: 'Download', 314 | icon: 'fa fa-download', 315 | handler: () => { fbWidget.download(); } 316 | }), 317 | new MenuItem({ 318 | text: 'Shutdown Kernel', 319 | icon: 'fa fa-stop-circle-o', 320 | handler: () => { fbWidget.shutdownKernels(); } 321 | }) 322 | ]); 323 | } 324 | -------------------------------------------------------------------------------- /src/help/iframe.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 'use strict'; 4 | 5 | import { 6 | Widget 7 | } from 'phosphor-widget'; 8 | 9 | 10 | /** 11 | * The class name added to an IFrame widget. 12 | */ 13 | const IFRAME_CLASS = 'jp-IFrame'; 14 | 15 | 16 | /** 17 | * A phosphor widget which wraps an IFrame. 18 | */ 19 | export 20 | class IFrame extends Widget { 21 | /** 22 | * Create the main content node of an iframe widget. 23 | */ 24 | static createNode(): HTMLElement { 25 | let node = document.createElement('div'); 26 | let iframe = document.createElement('iframe'); 27 | iframe.style.height = '100%'; 28 | iframe.style.width = '100%'; 29 | node.appendChild(iframe); 30 | return node; 31 | } 32 | 33 | /** 34 | * Create a new iframe widget. 35 | */ 36 | constructor() { 37 | super(); 38 | this.addClass(IFRAME_CLASS); 39 | } 40 | 41 | /** 42 | * Load a URL into the iframe. 43 | * 44 | * @param url - The URL to load into the iframe widget. 45 | */ 46 | loadURL(url: string): void { 47 | this.node.querySelector('iframe').setAttribute('src', url); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/help/plugin.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 'use strict'; 4 | 5 | import { 6 | Application 7 | } from 'phosphide/lib/core/application'; 8 | 9 | import { 10 | IFrame 11 | } from './iframe'; 12 | 13 | 14 | /** 15 | * The class name added to the help widget. 16 | */ 17 | const HELP_CLASS = 'jp-Help'; 18 | 19 | 20 | /** 21 | * A list of commands to add to the help widget. 22 | */ 23 | const COMMANDS = [ 24 | { 25 | text: 'Scipy Lecture Notes', 26 | id: 'help-doc:scipy-lecture-notes', 27 | url: 'http://www.scipy-lectures.org/' 28 | }, 29 | { 30 | text: 'Numpy Reference', 31 | id: 'help-doc:numpy-reference', 32 | url: 'http://docs.scipy.org/doc/numpy/reference/' 33 | }, 34 | { 35 | text: 'Scipy Reference', 36 | id: 'help-doc:scipy-reference', 37 | url: 'http://docs.scipy.org/doc/scipy/reference/' 38 | }, 39 | { 40 | text: 'Notebook Tutorial', 41 | id: 'help-doc:notebook-tutorial', 42 | url: 'http://nbviewer.jupyter.org/github/jupyter/notebook/' + 43 | 'blob/master/docs/source/examples/Notebook/Notebook Basics.ipynb' 44 | } 45 | ]; 46 | 47 | 48 | /** 49 | * The help handler extension. 50 | */ 51 | export 52 | const helpHandlerExtension = { 53 | id: 'jupyter.extensions.helpHandler', 54 | activate: activateHelpHandler 55 | }; 56 | 57 | 58 | /** 59 | * Activate the help handler extension. 60 | * 61 | * @param app - The phosphide application object. 62 | * 63 | * returns A promise that resolves when the extension is activated. 64 | */ 65 | function activateHelpHandler(app: Application): Promise { 66 | let widget = new IFrame(); 67 | widget.addClass(HELP_CLASS); 68 | widget.title.text = 'Help'; 69 | widget.id = 'help-doc'; 70 | 71 | let helpCommandItems = COMMANDS.map(command => { 72 | return { 73 | id: command.id, 74 | handler: () => { 75 | attachHelp(); 76 | showHelp(); 77 | widget.loadURL(command.url); 78 | } 79 | }; 80 | }); 81 | 82 | app.commands.add(helpCommandItems); 83 | 84 | app.commands.add([ 85 | { 86 | id: 'help-doc:activate', 87 | handler: showHelp 88 | }, 89 | { 90 | id: 'help-doc:hide', 91 | handler: hideHelp 92 | }, 93 | { 94 | id: 'help-doc:toggle', 95 | handler: toggleHelp 96 | } 97 | ]); 98 | 99 | let helpPaletteItems = COMMANDS.map(command => { 100 | return { 101 | command: command.id, 102 | text: command.text, 103 | caption: `Open ${command.text}`, 104 | category: 'Help' 105 | }; 106 | }); 107 | 108 | app.palette.add(helpPaletteItems); 109 | 110 | return Promise.resolve(void 0); 111 | 112 | function attachHelp(): void { 113 | if (!widget.isAttached) app.shell.addToRightArea(widget); 114 | } 115 | 116 | function showHelp(): void { 117 | app.shell.activateRight(widget.id); 118 | } 119 | 120 | function hideHelp(): void { 121 | if (!widget.isHidden) app.shell.collapseRight(); 122 | } 123 | 124 | function toggleHelp(): void { 125 | if (widget.isHidden) { 126 | showHelp(); 127 | } else { 128 | hideHelp(); 129 | } 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /src/imagehandler/plugin.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 'use strict'; 4 | 5 | import { 6 | DocumentRegistry, ImageWidgetFactory 7 | } from 'jupyter-js-ui/lib/docmanager'; 8 | 9 | import { 10 | Application 11 | } from 'phosphide/lib/core/application'; 12 | 13 | 14 | /** 15 | * The list of file extensions for images. 16 | */ 17 | const EXTENSIONS = ['.png', '.gif', '.jpeg', '.jpg', '.svg', '.bmp', '.ico', 18 | '.xbm', '.tiff', '.tif']; 19 | 20 | 21 | /** 22 | * The image file handler extension. 23 | */ 24 | export 25 | const imageHandlerExtension = { 26 | id: 'jupyter.extensions.imageHandler', 27 | requires: [DocumentRegistry], 28 | activate: (app: Application, registry: DocumentRegistry) => { 29 | registry.registerWidgetFactory(new ImageWidgetFactory(), 30 | { 31 | fileExtensions: EXTENSIONS, 32 | displayName: 'Image', 33 | modelName: 'base64', 34 | defaultFor: EXTENSIONS, 35 | preferKernel: false, 36 | canStartKernel: false 37 | }); 38 | } 39 | }; 40 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 'use strict'; 4 | 5 | -------------------------------------------------------------------------------- /src/landing/images/jupyterlab.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Group 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/landing/images/notebook.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Group 13 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /src/landing/images/terminal.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Group 8 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/landing/images/texteditor.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Group 2 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/landing/index.css: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------- 2 | | Copyright (c) Jupyter Development Team. 3 | | Distributed under the terms of the Modified BSD License. 4 | |----------------------------------------------------------------------------*/ 5 | .jp-Landing { 6 | background: rgba(0,0,0,0.25); 7 | color: #757575; 8 | position: absolute; 9 | z-index: 10000; 10 | display: flex; 11 | flex-direction: column; 12 | align-items: center; 13 | justify-content: center; 14 | top: 0px; 15 | left: 0px; 16 | margin: 0; 17 | padding: 0; 18 | width: 100%; 19 | height: 100%; 20 | } 21 | 22 | 23 | .jp-Landing-dialog { 24 | padding-bottom: 20px; 25 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; 26 | font-size: 16px; 27 | color: #757575; 28 | background: #FAFAFA; 29 | margin-left: auto; 30 | margin-right: auto; 31 | text-align: center; 32 | display: flex; 33 | align-items: center; 34 | justify-content: center; 35 | flex-direction: column; 36 | border: 1px solid #BDBDBD; 37 | border-radius: 2px; 38 | box-shadow: 0px 2px 2px 0px rgba(0,0,0,0.5); 39 | } 40 | 41 | 42 | .jp-Landing-logo { 43 | flex: 0 0 40px; 44 | margin-left: auto; 45 | margin-right: auto; 46 | width: 100%; 47 | background: white; 48 | background-image: url(images/jupyterlab.svg); 49 | background-size: 193px 40px; 50 | background-repeat: no-repeat; 51 | background-position: center top; 52 | padding-bottom: 20px; 53 | border-bottom: 1px solid #BDBDBD; 54 | } 55 | 56 | 57 | .jp-Landing-title { 58 | padding-top: 20px; 59 | background: white; 60 | width: 100%; 61 | } 62 | 63 | 64 | .jp-Landing-header { 65 | 66 | padding-top: 20px; 67 | padding-bottom: 8px; 68 | } 69 | 70 | 71 | .jp-Landing-body { 72 | display: flex; 73 | flex-direction: row; 74 | padding-left: 20px; 75 | padding-right: 20px; 76 | } 77 | 78 | 79 | .jp-Landing-column { 80 | padding-left: 20px; 81 | padding-right: 20px; 82 | display: flex; 83 | flex-direction: column; 84 | } 85 | 86 | 87 | .jp-Landing-image { 88 | flex: 0 0 auto; 89 | min-height: 72px; 90 | max-height: 72px; 91 | min-width: 56px; 92 | max-width: 56px; 93 | background-size: 56px 72px; 94 | background-repeat: no-repeat; 95 | 96 | } 97 | 98 | 99 | .jp-Landing-image:hover { 100 | cursor: pointer; 101 | } 102 | 103 | 104 | .jp-Landing-text { 105 | flex: 0 0 auto; 106 | font-size: 12px; 107 | padding-top: 8px; 108 | } 109 | 110 | 111 | .jp-Landing-imageNotebook { 112 | background-image: url(images/notebook.svg); 113 | } 114 | 115 | 116 | .jp-Landing-imageTerminal { 117 | background-image: url(images/terminal.svg); 118 | } 119 | 120 | 121 | .jp-Landing-imageTextEditor { 122 | background-image: url(images/texteditor.svg); 123 | } 124 | -------------------------------------------------------------------------------- /src/landing/plugin.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 'use strict'; 4 | 5 | import { 6 | Application 7 | } from 'phosphide/lib/core/application'; 8 | 9 | import { 10 | Widget 11 | } from 'phosphor-widget'; 12 | 13 | 14 | /** 15 | * The landing page extension. 16 | */ 17 | export 18 | const landingExtension = { 19 | id: 'jupyter.extensions.landing', 20 | activate: activateLanding 21 | }; 22 | 23 | 24 | function activateLanding(app: Application): void { 25 | let widget = new Widget(); 26 | widget.id = 'landing-jupyterlab'; 27 | widget.title.text = 'JupyterLab'; 28 | widget.title.closable = true; 29 | widget.addClass('jp-Landing'); 30 | 31 | let dialog = document.createElement('div'); 32 | dialog.className = 'jp-Landing-dialog'; 33 | widget.node.appendChild(dialog); 34 | 35 | let title = document.createElement('span'); 36 | title.textContent = 'Welcome to'; 37 | title.className = 'jp-Landing-title'; 38 | dialog.appendChild(title); 39 | 40 | let logo = document.createElement('span'); 41 | logo.className = 'jp-Landing-logo'; 42 | dialog.appendChild(logo); 43 | 44 | let header = document.createElement('span'); 45 | header.textContent = 'Start a new activity:'; 46 | header.className = 'jp-Landing-header'; 47 | dialog.appendChild(header); 48 | 49 | let body = document.createElement('div'); 50 | body.className = 'jp-Landing-body'; 51 | dialog.appendChild(body); 52 | 53 | for (let name of ['Notebook', 'Terminal', 'Text Editor']) { 54 | let column = document.createElement('div'); 55 | body.appendChild(column); 56 | column.className = 'jp-Landing-column'; 57 | 58 | let img = document.createElement('span'); 59 | let imgName = name.replace(' ', ''); 60 | img.className = `jp-Landing-image${imgName} jp-Landing-image`; 61 | 62 | column.appendChild(img); 63 | 64 | let text = document.createElement('span'); 65 | text.textContent = name; 66 | text.className = 'jp-Landing-text'; 67 | column.appendChild(text); 68 | } 69 | 70 | let img = body.getElementsByClassName('jp-Landing-imageNotebook')[0]; 71 | img.addEventListener('click', () => { 72 | app.commands.execute('file-operations:new-notebook'); 73 | }); 74 | 75 | img = body.getElementsByClassName('jp-Landing-imageTextEditor')[0]; 76 | img.addEventListener('click', () => { 77 | app.commands.execute('file-operations:new-text-file'); 78 | }); 79 | 80 | img = body.getElementsByClassName('jp-Landing-imageTerminal')[0]; 81 | img.addEventListener('click', () => { 82 | app.commands.execute('terminal:create-new'); 83 | }); 84 | 85 | app.commands.add([{ 86 | id: 'jupyterlab-launcher:show', 87 | handler: () => { 88 | if (!widget.isAttached) { 89 | app.shell.addToMainArea(widget); 90 | } 91 | app.shell.activateMain(widget.id); 92 | } 93 | }]); 94 | 95 | app.palette.add([{ 96 | command: 'jupyterlab-launcher:show', 97 | text: 'JupyterLab Launcher', 98 | category: 'Help' 99 | }]); 100 | 101 | app.shell.addToMainArea(widget); 102 | } 103 | -------------------------------------------------------------------------------- /src/main/plugin.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 'use strict'; 4 | 5 | import { 6 | Application 7 | } from 'phosphide/lib/core/application'; 8 | 9 | 10 | /** 11 | * The main extension. 12 | */ 13 | export 14 | const mainExtension = { 15 | id: 'jupyter.extensions.main', 16 | activate: (app: Application) => { 17 | window.onbeforeunload = event => { 18 | let msg = 'Are you sure you want to exit JupyterLab?'; 19 | msg += '\nAny unsaved changes will be lost.'; 20 | return msg; 21 | }; 22 | } 23 | }; 24 | -------------------------------------------------------------------------------- /src/notebook/plugin.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 'use strict'; 4 | 5 | import { 6 | NotebookPanel, NotebookModelFactory, INotebookModel, 7 | NotebookWidgetFactory, NotebookActions 8 | } from 'jupyter-js-notebook'; 9 | 10 | import { 11 | IKernelId 12 | } from 'jupyter-js-services'; 13 | 14 | import { 15 | IDocumentContext, DocumentRegistry, selectKernelForContext 16 | } from 'jupyter-js-ui/lib/docmanager'; 17 | 18 | import { 19 | RenderMime 20 | } from 'jupyter-js-ui/lib/rendermime'; 21 | 22 | import { 23 | Application 24 | } from 'phosphide/lib/core/application'; 25 | 26 | import { 27 | MimeData as IClipboard 28 | } from 'phosphor-dragdrop'; 29 | 30 | import { 31 | ISignal, Signal 32 | } from 'phosphor-signaling'; 33 | 34 | import { 35 | Widget 36 | } from 'phosphor-widget'; 37 | 38 | import { 39 | JupyterServices 40 | } from '../services/plugin'; 41 | 42 | 43 | /** 44 | * The map of command ids used by the notebook. 45 | */ 46 | const cmdIds = { 47 | interrupt: 'notebook:interrupt-kernel', 48 | restart: 'notebook:restart-kernel', 49 | restartClear: 'notebook:restart-clear', 50 | restartRunAll: 'notebook:restart-runAll', 51 | switchKernel: 'notebook:switch-kernel', 52 | clearAllOutputs: 'notebook:clear-outputs', 53 | run: 'notebook-cells:run', 54 | runAndAdvance: 'notebook-cells:runAndAdvance', 55 | runAndInsert: 'notebook-cells:runAndInsert', 56 | runAll: 'notebook:run-all', 57 | toCode: 'notebook-cells:to-code', 58 | toMarkdown: 'notebook-cells:to-markdown', 59 | toRaw: 'notebook-cells:to-raw', 60 | cut: 'notebook-cells:cut', 61 | copy: 'notebook-cells:copy', 62 | paste: 'notebook-cells:paste', 63 | clearOutputs: 'notebook-cells:clear-output', 64 | deleteCell: 'notebook-cells:delete', 65 | insertAbove: 'notebook-cells:insert-above', 66 | insertBelow: 'notebook-cells:insert-below', 67 | selectAbove: 'notebook-cells:select-above', 68 | selectBelow: 'notebook-cells:select-below', 69 | extendAbove: 'notebook-cells:extend-above', 70 | extendBelow: 'notebook-cells:extend-below', 71 | editMode: 'notebook:editMode', 72 | merge: 'notebook-cells:merge', 73 | split: 'notebook-cells:split', 74 | commandMode: 'notebook:commandMode', 75 | newNotebook: 'notebook:create-new', 76 | toggleLines: 'notebook-cells:toggle-lineNumbers', 77 | toggleAllLines: 'notebook-cells:toggle-allLineNumbers', 78 | undo: 'notebook-cells:undo', 79 | redo: 'notebook-cells:redo' 80 | }; 81 | 82 | 83 | /** 84 | * The notebook file handler provider. 85 | */ 86 | export 87 | const notebookHandlerExtension = { 88 | id: 'jupyter.extensions.notebookHandler', 89 | requires: [DocumentRegistry, JupyterServices, RenderMime, IClipboard], 90 | activate: activateNotebookHandler 91 | }; 92 | 93 | 94 | /** 95 | * An interface exposing the current active notebook. 96 | */ 97 | export 98 | class ActiveNotebook { 99 | /** 100 | * Construct a new active notebook tracker. 101 | */ 102 | constructor() { 103 | // Temporary notebook focus follower. 104 | document.body.addEventListener('focus', event => { 105 | for (let widget of this._widgets) { 106 | let target = event.target as HTMLElement; 107 | if (widget.isAttached && widget.isVisible) { 108 | if (widget.node.contains(target)) { 109 | this.activeNotebook = widget; 110 | return; 111 | } 112 | } 113 | } 114 | }, true); 115 | } 116 | 117 | /** 118 | * A signal emitted when the active notebook changes. 119 | */ 120 | get activeNotebookChanged(): ISignal { 121 | return Private.activeNotebookChangedSignal.bind(this); 122 | } 123 | 124 | /** 125 | * The current active notebook. 126 | */ 127 | get activeNotebook(): NotebookPanel { 128 | return this._activeWidget; 129 | } 130 | set activeNotebook(widget: NotebookPanel) { 131 | if (this._activeWidget === widget) { 132 | return; 133 | } 134 | if (this._widgets.indexOf(widget) !== -1) { 135 | this._activeWidget = widget; 136 | this.activeNotebookChanged.emit(widget); 137 | return; 138 | } 139 | if (widget === null) { 140 | return; 141 | } 142 | this._widgets.push(widget); 143 | widget.disposed.connect(() => { 144 | let index = this._widgets.indexOf(widget); 145 | this._widgets.splice(index, 1); 146 | if (this._activeWidget === widget) { 147 | this.activeNotebook = null; 148 | } 149 | }); 150 | } 151 | 152 | private _activeWidget: NotebookPanel = null; 153 | private _widgets: NotebookPanel[] = []; 154 | } 155 | 156 | 157 | /** 158 | * A service tracking the active notebook widget. 159 | */ 160 | export 161 | const activeNotebookProvider = { 162 | id: 'jupyter.services.activeNotebook', 163 | provides: ActiveNotebook, 164 | resolve: () => { 165 | return Private.notebookTracker; 166 | } 167 | }; 168 | 169 | 170 | /** 171 | * A version of the notebook widget factory that uses the notebook tracker. 172 | */ 173 | class TrackingNotebookWidgetFactory extends NotebookWidgetFactory { 174 | /** 175 | * Create a new widget. 176 | */ 177 | createNew(model: INotebookModel, context: IDocumentContext, kernel?: IKernelId): NotebookPanel { 178 | let widget = super.createNew(model, context, kernel); 179 | Private.notebookTracker.activeNotebook = widget; 180 | return widget; 181 | } 182 | } 183 | 184 | 185 | /** 186 | * Activate the notebook handler extension. 187 | */ 188 | function activateNotebookHandler(app: Application, registry: DocumentRegistry, services: JupyterServices, rendermime: RenderMime, clipboard: IClipboard): Promise { 189 | 190 | let widgetFactory = new TrackingNotebookWidgetFactory(rendermime, clipboard); 191 | registry.registerModelFactory(new NotebookModelFactory()); 192 | registry.registerWidgetFactory(widgetFactory, 193 | { 194 | fileExtensions: ['.ipynb'], 195 | displayName: 'Notebook', 196 | modelName: 'notebook', 197 | defaultFor: ['.ipynb'], 198 | preferKernel: true, 199 | canStartKernel: true 200 | }); 201 | 202 | 203 | // Add the ability to launch notebooks for each kernel type. 204 | let displayNameMap: { [key: string]: string } = Object.create(null); 205 | let specs = services.kernelspecs; 206 | for (let kernelName in specs.kernelspecs) { 207 | let displayName = specs.kernelspecs[kernelName].spec.display_name; 208 | displayNameMap[displayName] = kernelName; 209 | } 210 | let displayNames = Object.keys(displayNameMap).sort((a, b) => { 211 | return a.localeCompare(b); 212 | }); 213 | for (let displayName of displayNames) { 214 | registry.registerCreator({ 215 | name: `${displayName} Notebook`, 216 | extension: '.ipynb', 217 | type: 'notebook', 218 | kernelName: displayNameMap[displayName] 219 | }); 220 | } 221 | 222 | let tracker = Private.notebookTracker; 223 | app.commands.add([ 224 | { 225 | id: cmdIds['runAndAdvance'], 226 | handler: () => { 227 | if (tracker.activeNotebook) { 228 | let nbWidget = tracker.activeNotebook; 229 | NotebookActions.runAndAdvance(nbWidget.content, nbWidget.context.kernel); 230 | } 231 | } 232 | }, 233 | { 234 | id: cmdIds['run'], 235 | handler: () => { 236 | if (tracker.activeNotebook) { 237 | let nbWidget = tracker.activeNotebook; 238 | NotebookActions.run(nbWidget.content, nbWidget.context.kernel); 239 | } 240 | } 241 | }, 242 | { 243 | id: cmdIds['runAndInsert'], 244 | handler: () => { 245 | if (tracker.activeNotebook) { 246 | let nbWidget = tracker.activeNotebook; 247 | NotebookActions.runAndInsert(nbWidget.content, nbWidget.context.kernel); 248 | } 249 | } 250 | }, 251 | { 252 | id: cmdIds['runAll'], 253 | handler: () => { 254 | if (tracker.activeNotebook) { 255 | let nbWidget = tracker.activeNotebook; 256 | NotebookActions.runAll(nbWidget.content, nbWidget.context.kernel); 257 | } 258 | } 259 | }, 260 | { 261 | id: cmdIds['restart'], 262 | handler: () => { 263 | if (tracker.activeNotebook) { 264 | let nbWidget = tracker.activeNotebook; 265 | nbWidget.restart(); 266 | } 267 | } 268 | }, 269 | { 270 | id: cmdIds['restartClear'], 271 | handler: () => { 272 | if (tracker.activeNotebook) { 273 | let nbWidget = tracker.activeNotebook; 274 | nbWidget.restart().then(result => { 275 | if (result) { 276 | NotebookActions.clearAllOutputs(nbWidget.content); 277 | } 278 | }); 279 | } 280 | } 281 | }, 282 | { 283 | id: cmdIds['restartRunAll'], 284 | handler: () => { 285 | if (tracker.activeNotebook) { 286 | let nbWidget = tracker.activeNotebook; 287 | nbWidget.restart().then(result => { 288 | NotebookActions.runAll(nbWidget.content, nbWidget.context.kernel); 289 | }); 290 | } 291 | } 292 | }, 293 | { 294 | id: cmdIds['clearAllOutputs'], 295 | handler: () => { 296 | if (tracker.activeNotebook) { 297 | let nbWidget = tracker.activeNotebook; 298 | NotebookActions.clearAllOutputs(nbWidget.content); 299 | } 300 | } 301 | }, 302 | { 303 | id: cmdIds['clearOutputs'], 304 | handler: () => { 305 | if (tracker.activeNotebook) { 306 | let nbWidget = tracker.activeNotebook; 307 | NotebookActions.clearOutputs(nbWidget.content); 308 | } 309 | } 310 | }, 311 | { 312 | id: cmdIds['interrupt'], 313 | handler: () => { 314 | if (tracker.activeNotebook) { 315 | let kernel = tracker.activeNotebook.context.kernel; 316 | if (kernel) { 317 | kernel.interrupt(); 318 | } 319 | } 320 | } 321 | }, 322 | { 323 | id: cmdIds['toCode'], 324 | handler: () => { 325 | if (tracker.activeNotebook) { 326 | let nbWidget = tracker.activeNotebook; 327 | NotebookActions.changeCellType(nbWidget.content, 'code'); 328 | } 329 | } 330 | }, 331 | { 332 | id: cmdIds['toMarkdown'], 333 | handler: () => { 334 | if (tracker.activeNotebook) { 335 | let nbWidget = tracker.activeNotebook; 336 | NotebookActions.changeCellType(nbWidget.content, 'markdown'); 337 | } 338 | } 339 | }, 340 | { 341 | id: cmdIds['toRaw'], 342 | handler: () => { 343 | if (tracker.activeNotebook) { 344 | let nbWidget = tracker.activeNotebook; 345 | NotebookActions.changeCellType(nbWidget.content, 'raw'); 346 | } 347 | } 348 | }, 349 | { 350 | id: cmdIds['cut'], 351 | handler: () => { 352 | if (tracker.activeNotebook) { 353 | let nbWidget = tracker.activeNotebook; 354 | NotebookActions.cut(nbWidget.content, nbWidget.clipboard); 355 | } 356 | } 357 | }, 358 | { 359 | id: cmdIds['copy'], 360 | handler: () => { 361 | if (tracker.activeNotebook) { 362 | let nbWidget = tracker.activeNotebook; 363 | NotebookActions.copy(nbWidget.content, nbWidget.clipboard); 364 | } 365 | } 366 | }, 367 | { 368 | id: cmdIds['paste'], 369 | handler: () => { 370 | if (tracker.activeNotebook) { 371 | let nbWidget = tracker.activeNotebook; 372 | NotebookActions.paste(nbWidget.content, nbWidget.clipboard); 373 | } 374 | } 375 | }, 376 | { 377 | id: cmdIds['deleteCell'], 378 | handler: () => { 379 | if (tracker.activeNotebook) { 380 | let nbWidget = tracker.activeNotebook; 381 | NotebookActions.deleteCells(nbWidget.content); 382 | } 383 | } 384 | }, 385 | { 386 | id: cmdIds['split'], 387 | handler: () => { 388 | if (tracker.activeNotebook) { 389 | let nbWidget = tracker.activeNotebook; 390 | NotebookActions.splitCell(nbWidget.content); 391 | } 392 | } 393 | }, 394 | { 395 | id: cmdIds['merge'], 396 | handler: () => { 397 | if (tracker.activeNotebook) { 398 | let nbWidget = tracker.activeNotebook; 399 | NotebookActions.mergeCells(nbWidget.content); 400 | } 401 | } 402 | }, 403 | { 404 | id: cmdIds['insertAbove'], 405 | handler: () => { 406 | if (tracker.activeNotebook) { 407 | let nbWidget = tracker.activeNotebook; 408 | NotebookActions.insertAbove(nbWidget.content); 409 | } 410 | } 411 | }, 412 | { 413 | id: cmdIds['insertBelow'], 414 | handler: () => { 415 | if (tracker.activeNotebook) { 416 | let nbWidget = tracker.activeNotebook; 417 | NotebookActions.insertBelow(nbWidget.content); 418 | } 419 | } 420 | }, 421 | { 422 | id: cmdIds['selectAbove'], 423 | handler: () => { 424 | if (tracker.activeNotebook) { 425 | let nbWidget = tracker.activeNotebook; 426 | NotebookActions.selectAbove(nbWidget.content); 427 | } 428 | } 429 | }, 430 | { 431 | id: cmdIds['selectBelow'], 432 | handler: () => { 433 | if (tracker.activeNotebook) { 434 | let nbWidget = tracker.activeNotebook; 435 | NotebookActions.selectBelow(nbWidget.content); 436 | } 437 | } 438 | }, 439 | { 440 | id: cmdIds['extendAbove'], 441 | handler: () => { 442 | if (tracker.activeNotebook) { 443 | let nbWidget = tracker.activeNotebook; 444 | NotebookActions.extendSelectionAbove(nbWidget.content); 445 | } 446 | } 447 | }, 448 | { 449 | id: cmdIds['extendBelow'], 450 | handler: () => { 451 | if (tracker.activeNotebook) { 452 | let nbWidget = tracker.activeNotebook; 453 | NotebookActions.extendSelectionBelow(nbWidget.content); 454 | } 455 | } 456 | }, 457 | { 458 | id: cmdIds['toggleLines'], 459 | handler: () => { 460 | if (tracker.activeNotebook) { 461 | let nbWidget = tracker.activeNotebook; 462 | NotebookActions.toggleLineNumbers(nbWidget.content); 463 | } 464 | } 465 | }, 466 | { 467 | id: cmdIds['toggleAllLines'], 468 | handler: () => { 469 | if (tracker.activeNotebook) { 470 | let nbWidget = tracker.activeNotebook; 471 | NotebookActions.toggleAllLineNumbers(nbWidget.content); 472 | } 473 | } 474 | }, 475 | { 476 | id: cmdIds['commandMode'], 477 | handler: () => { 478 | if (tracker.activeNotebook) { 479 | tracker.activeNotebook.content.mode = 'command'; 480 | } 481 | } 482 | }, 483 | { 484 | id: cmdIds['editMode'], 485 | handler: () => { 486 | if (tracker.activeNotebook) { 487 | tracker.activeNotebook.content.mode = 'edit'; 488 | } 489 | } 490 | }, 491 | { 492 | id: cmdIds['undo'], 493 | handler: () => { 494 | if (tracker.activeNotebook) { 495 | NotebookActions.undo(tracker.activeNotebook.content); 496 | } 497 | } 498 | }, 499 | { 500 | id: cmdIds['redo'], 501 | handler: () => { 502 | if (tracker.activeNotebook) { 503 | NotebookActions.redo(tracker.activeNotebook.content); 504 | } 505 | } 506 | }, 507 | { 508 | id: cmdIds['switchKernel'], 509 | handler: () => { 510 | if (tracker.activeNotebook) { 511 | selectKernelForContext(tracker.activeNotebook.context, tracker.activeNotebook.node); 512 | } 513 | } 514 | } 515 | ]); 516 | app.palette.add([ 517 | { 518 | command: cmdIds['run'], 519 | category: 'Notebook Cell Operations', 520 | text: 'Run Cell(s)' 521 | }, 522 | { 523 | command: cmdIds['runAndAdvance'], 524 | category: 'Notebook Cell Operations', 525 | text: 'Run Cell(s) and Advance' 526 | }, 527 | { 528 | command: cmdIds['runAndInsert'], 529 | category: 'Notebook Cell Operations', 530 | text: 'Run Cell(s) and Insert' 531 | }, 532 | { 533 | command: cmdIds['interrupt'], 534 | category: 'Notebook Operations', 535 | text: 'Interrupt Kernel' 536 | }, 537 | { 538 | command: cmdIds['restart'], 539 | category: 'Notebook Operations', 540 | text: 'Restart Kernel' 541 | }, 542 | { 543 | command: cmdIds['restartClear'], 544 | category: 'Notebook Operations', 545 | text: 'Restart Kernel & Clear Outputs' 546 | }, 547 | { 548 | command: cmdIds['restartRunAll'], 549 | category: 'Notebook Operations', 550 | text: 'Restart Kernel & Run All' 551 | }, 552 | { 553 | command: cmdIds['runAll'], 554 | category: 'Notebook Operations', 555 | text: 'Run All Cells' 556 | }, 557 | { 558 | command: cmdIds['clearAllOutputs'], 559 | category: 'Notebook Operations', 560 | text: 'Clear All Outputs' 561 | }, 562 | { 563 | command: cmdIds['clearOutputs'], 564 | category: 'Notebook Cell Operations', 565 | text: 'Clear Output(s)' 566 | }, 567 | { 568 | command: cmdIds['toCode'], 569 | category: 'Notebook Cell Operations', 570 | text: 'Convert to Code' 571 | }, 572 | { 573 | command: cmdIds['toMarkdown'], 574 | category: 'Notebook Cell Operations', 575 | text: 'Convert to Markdown' 576 | }, 577 | { 578 | command: cmdIds['toRaw'], 579 | category: 'Notebook Cell Operations', 580 | text: 'Convert to Raw' 581 | }, 582 | { 583 | command: cmdIds['cut'], 584 | category: 'Notebook Cell Operations', 585 | text: 'Cut Cell(s)' 586 | }, 587 | { 588 | command: cmdIds['copy'], 589 | category: 'Notebook Cell Operations', 590 | text: 'Copy Cell(s)' 591 | }, 592 | { 593 | command: cmdIds['paste'], 594 | category: 'Notebook Cell Operations', 595 | text: 'Paste Cell(s)' 596 | }, 597 | { 598 | command: cmdIds['deleteCell'], 599 | category: 'Notebook Cell Operations', 600 | text: 'Delete Cell(s)' 601 | }, 602 | { 603 | command: cmdIds['split'], 604 | category: 'Notebook Cell Operations', 605 | text: 'Split Cell' 606 | }, 607 | { 608 | command: cmdIds['merge'], 609 | category: 'Notebook Cell Operations', 610 | text: 'Merge Selected Cell(s)' 611 | }, 612 | { 613 | command: cmdIds['insertAbove'], 614 | category: 'Notebook Cell Operations', 615 | text: 'Insert Cell Above' 616 | }, 617 | { 618 | command: cmdIds['insertBelow'], 619 | category: 'Notebook Cell Operations', 620 | text: 'Insert Cell Below' 621 | }, 622 | { 623 | command: cmdIds['selectAbove'], 624 | category: 'Notebook Cell Operations', 625 | text: 'Select Cell Above' 626 | }, 627 | { 628 | command: cmdIds['selectBelow'], 629 | category: 'Notebook Cell Operations', 630 | text: 'Select Cell Below' 631 | }, 632 | { 633 | command: cmdIds['extendAbove'], 634 | category: 'Notebook Cell Operations', 635 | text: 'Extend Selection Above' 636 | }, 637 | { 638 | command: cmdIds['extendBelow'], 639 | category: 'Notebook Cell Operations', 640 | text: 'Extend Selection Below' 641 | }, 642 | { 643 | command: cmdIds['toggleLines'], 644 | category: 'Notebook Cell Operations', 645 | text: 'Toggle Line Numbers' 646 | }, 647 | { 648 | command: cmdIds['toggleAllLines'], 649 | category: 'Notebook Operations', 650 | text: 'Toggle All Line Numbers' 651 | }, 652 | { 653 | command: cmdIds['editMode'], 654 | category: 'Notebook Operations', 655 | text: 'To Edit Mode' 656 | }, 657 | { 658 | command: cmdIds['commandMode'], 659 | category: 'Notebook Operations', 660 | text: 'To Command Mode' 661 | }, 662 | { 663 | command: cmdIds['switchKernel'], 664 | category: 'Notebook Operations', 665 | text: 'Switch Kernel' 666 | }, 667 | { 668 | command: cmdIds['undo'], 669 | category: 'Notebook Cell Operations', 670 | text: 'Undo Cell Operation' 671 | }, 672 | { 673 | command: cmdIds['redo'], 674 | category: 'Notebook Cell Operations', 675 | text: 'Redo Cell Operation' 676 | } 677 | ]); 678 | 679 | return Promise.resolve(void 0); 680 | } 681 | 682 | 683 | /** 684 | * A namespace for notebook plugin private data. 685 | */ 686 | namespace Private { 687 | /** 688 | * A signal emitted when the active notebook changes. 689 | */ 690 | export 691 | const activeNotebookChangedSignal = new Signal(); 692 | 693 | /** 694 | * A singleton notebook tracker instance. 695 | */ 696 | export 697 | const notebookTracker = new ActiveNotebook(); 698 | } 699 | -------------------------------------------------------------------------------- /src/rendermime/plugin.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 'use strict'; 4 | 5 | import { 6 | RenderMime, MimeMap, IRenderer 7 | } from 'jupyter-js-ui/lib/rendermime'; 8 | 9 | import { 10 | HTMLRenderer, LatexRenderer, ImageRenderer, TextRenderer, 11 | JavascriptRenderer, SVGRenderer, MarkdownRenderer 12 | } from 'jupyter-js-ui/lib/renderers'; 13 | 14 | import { 15 | Widget 16 | } from 'phosphor-widget'; 17 | 18 | 19 | /** 20 | * The default rendermime provider. 21 | */ 22 | export 23 | const renderMimeProvider = { 24 | id: 'jupyter.services.rendermime', 25 | provides: RenderMime, 26 | resolve: () => { 27 | const transformers = [ 28 | new JavascriptRenderer(), 29 | new MarkdownRenderer(), 30 | new HTMLRenderer(), 31 | new ImageRenderer(), 32 | new SVGRenderer(), 33 | new LatexRenderer(), 34 | new TextRenderer() 35 | ]; 36 | let renderers: MimeMap> = {}; 37 | let order: string[] = []; 38 | for (let t of transformers) { 39 | for (let m of t.mimetypes) { 40 | renderers[m] = t; 41 | order.push(m); 42 | } 43 | } 44 | return new RenderMime(renderers, order); 45 | } 46 | }; 47 | -------------------------------------------------------------------------------- /src/services/plugin.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 'use strict'; 4 | 5 | import { 6 | getBaseUrl, getConfigOption 7 | } from 'jupyter-js-utils'; 8 | 9 | import { 10 | IKernelManager, INotebookSessionManager, IContentsManager, 11 | ContentsManager, KernelManager, NotebookSessionManager, 12 | getKernelSpecs, IKernelSpecIds, IAjaxSettings 13 | } from 'jupyter-js-services'; 14 | 15 | 16 | /** 17 | * An implementation of a services provider. 18 | */ 19 | export 20 | class JupyterServices { 21 | 22 | /** 23 | * Construct a new services provider. 24 | */ 25 | constructor(baseUrl: string, ajaxSettings: IAjaxSettings, specs: IKernelSpecIds) { 26 | let options = { baseUrl, ajaxSettings }; 27 | this._kernelspecs = specs; 28 | this._kernelManager = new KernelManager(options); 29 | this._sessionManager = new NotebookSessionManager(options); 30 | this._contentsManager = new ContentsManager(baseUrl, ajaxSettings); 31 | } 32 | 33 | /** 34 | * Get kernel specs. 35 | */ 36 | get kernelspecs(): IKernelSpecIds { 37 | return this._kernelspecs; 38 | } 39 | 40 | /** 41 | * Get kernel manager instance. 42 | * 43 | * #### Notes 44 | * This is a read-only property. 45 | */ 46 | get kernelManager(): IKernelManager { 47 | return this._kernelManager; 48 | } 49 | 50 | /** 51 | * Get the session manager instance. 52 | * 53 | * #### Notes 54 | * This is a read-only property. 55 | */ 56 | get notebookSessionManager(): INotebookSessionManager { 57 | return this._sessionManager; 58 | } 59 | 60 | /** 61 | * Get the contents manager instance. 62 | * 63 | * #### Notes 64 | * This is a read-only property. 65 | */ 66 | get contentsManager(): IContentsManager { 67 | return this._contentsManager; 68 | } 69 | 70 | private _kernelManager: IKernelManager = null; 71 | private _sessionManager: INotebookSessionManager = null; 72 | private _contentsManager: IContentsManager = null; 73 | private _kernelspecs: IKernelSpecIds = null; 74 | } 75 | 76 | 77 | /** 78 | * The default services provider. 79 | */ 80 | export 81 | const servicesProvider = { 82 | id: 'jupyter.services.services', 83 | provides: JupyterServices, 84 | resolve: () => { 85 | let baseUrl = getBaseUrl(); 86 | let ajaxSettings = getConfigOption('ajaxSettings'); 87 | let options = { baseUrl, ajaxSettings }; 88 | return getKernelSpecs(options).then(specs => { 89 | return new JupyterServices(baseUrl, ajaxSettings, specs); 90 | }); 91 | } 92 | }; 93 | -------------------------------------------------------------------------------- /src/services/test.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jupyter/jupyter-js-plugins/e08e191c25c6a71d8dd88591a5260417e3a03a21/src/services/test.ts -------------------------------------------------------------------------------- /src/shortcuts/plugin.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 'use strict'; 4 | 5 | import { 6 | Application 7 | } from 'phosphide/lib/core/application'; 8 | 9 | 10 | /** 11 | * The list of default application shortcuts. 12 | * 13 | * #### Notes 14 | * When setting shortcut selectors, there are two concepts to consider: 15 | * specificity and matchability. These two interact in sometimes 16 | * counterintuitive ways. Keyboard events are triggered from an element and 17 | * they propagate up the DOM until they reach the `documentElement` (``). 18 | * 19 | * When a registered shortcut sequence is fired, the shortcut manager checks 20 | * the node that fired the event and each of its ancestors until a node matches 21 | * one or more registered selectors. The *first* matching selector in the 22 | * chain of ancestors will invoke the shortcut handler and the traversal will 23 | * end at that point. If a node matches more than one selector, the handler for 24 | * whichever selector is more *specific* fires. 25 | * @see https://www.w3.org/TR/css3-selectors/#specificity 26 | * 27 | * The practical consequence of this is that a very broadly matching selector, 28 | * e.g. `'*'` or `'div'` may match and therefore invoke a handler *before* a 29 | * more specific selector. The most common pitfall is to use the universal 30 | * (`'*'`) selector. For almost any use case where a global keyboard shortcut is 31 | * required, using the `'body'` selector is more appropriate. 32 | */ 33 | const SHORTCUTS = [ 34 | { 35 | command: 'command-palette:toggle', 36 | selector: 'body', 37 | sequence: ['Accel Shift P'] 38 | }, 39 | { 40 | command: 'command-palette:hide', 41 | selector: 'body[data-left-area="command-palette"]', 42 | sequence: ['Escape'] 43 | }, 44 | { 45 | command: 'file-browser:toggle', 46 | selector: 'body', 47 | sequence: ['Accel Shift F'] 48 | }, 49 | { 50 | command: 'file-browser:hide', 51 | selector: 'body[data-left-area="file-browser"]', 52 | sequence: ['Escape'] 53 | }, 54 | { 55 | command: 'file-operations:new-text-file', 56 | selector: 'body', 57 | sequence: ['Ctrl O'] 58 | }, 59 | { 60 | command: 'file-operations:new-notebook', 61 | selector: 'body', 62 | sequence: ['Ctrl Shift N'] 63 | }, 64 | { 65 | command: 'file-operations:save', 66 | selector: '.jp-DocumentWidget', 67 | sequence: ['Accel S'] 68 | }, 69 | { 70 | command: 'file-operations:close', 71 | selector: '.jp-DocumentWidget', 72 | sequence: ['Ctrl Q'] 73 | }, 74 | { 75 | command: 'file-operations:close-all', 76 | selector: '.jp-DocumentWidget', 77 | sequence: ['Ctrl Shift Q'] 78 | }, 79 | { 80 | command: 'help-doc:toggle', 81 | selector: 'body', 82 | sequence: ['Accel Shift H'] 83 | }, 84 | { 85 | command: 'help-doc:hide', 86 | selector: 'body[data-right-area="help-doc"]', 87 | sequence: ['Escape'] 88 | }, 89 | { 90 | command: 'notebook-cells:runAndAdvance', 91 | selector: '.jp-Notebook', 92 | sequence: ['Shift Enter'] 93 | }, 94 | { 95 | command: 'notebook-cells:runAndInsert', 96 | selector: '.jp-Notebook', 97 | sequence: ['Alt Enter'] 98 | }, 99 | { 100 | command: 'notebook-cells:run', 101 | selector: '.jp-Notebook', 102 | sequence: ['Ctrl Enter'] 103 | }, 104 | { 105 | command: 'notebook:interrupt-kernel', 106 | selector: '.jp-Notebook.jp-mod-commandMode', 107 | sequence: ['I', 'I'] 108 | }, 109 | { 110 | command: 'notebook:restart-kernel', 111 | selector: '.jp-Notebook.jp-mod-commandMode', 112 | sequence: ['0', '0'] 113 | }, 114 | { 115 | command: 'notebook-cells:to-code', 116 | selector: '.jp-Notebook.jp-mod-commandMode', 117 | sequence: ['E'] 118 | }, 119 | { 120 | command: 'notebook-cells:to-markdown', 121 | selector: '.jp-Notebook.jp-mod-commandMode', 122 | sequence: ['M'] 123 | }, 124 | { 125 | command: 'notebook-cells:to-raw', 126 | selector: '.jp-Notebook.jp-mod-commandMode', 127 | sequence: ['R'] 128 | }, 129 | { 130 | command: 'notebook-cells:delete', 131 | selector: '.jp-Notebook.jp-mod-commandMode', 132 | sequence: ['D', 'D'], 133 | }, 134 | { 135 | command: 'notebook-cells:split', 136 | selector: '.jp-Notebook.jp-mod-editMode', 137 | sequence: ['Ctrl Shift -'], 138 | }, 139 | { 140 | command: 'notebook-cells:merge', 141 | selector: '.jp-Notebook.jp-mod-commandMode', 142 | sequence: ['Shift M'], 143 | }, 144 | { 145 | command: 'notebook-cells:select-above', 146 | selector: '.jp-Notebook.jp-mod-commandMode', 147 | sequence: ['ArrowUp'], 148 | }, 149 | { 150 | command: 'notebook-cells:select-below', 151 | selector: '.jp-Notebook.jp-mod-commandMode', 152 | sequence: ['ArrowDown'], 153 | }, 154 | { 155 | command: 'notebook-cells:extend-above', 156 | selector: '.jp-Notebook.jp-mod-commandMode', 157 | sequence: ['Shift ArrowUp'], 158 | }, 159 | { 160 | command: 'notebook-cells:extend-below', 161 | selector: '.jp-Notebook.jp-mod-commandMode', 162 | sequence: ['Shift ArrowDown'], 163 | }, 164 | { 165 | command: 'notebook-cells:undo', 166 | selector: '.jp-Notebook.jp-mod-commandMode', 167 | sequence: ['Z'], 168 | }, 169 | { 170 | command: 'notebook-cells:redo', 171 | selector: '.jp-Notebook.jp-mod-commandMode', 172 | sequence: ['Y'], 173 | }, 174 | { 175 | command: 'notebook-cells:cut', 176 | selector: '.jp-Notebook.jp-mod-commandMode', 177 | sequence: ['X'] 178 | }, 179 | { 180 | command: 'notebook-cells:copy', 181 | selector: '.jp-Notebook.jp-mod-commandMode', 182 | sequence: ['C'] 183 | }, 184 | { 185 | command: 'notebook-cells:paste', 186 | selector: '.jp-Notebook.jp-mod-commandMode', 187 | sequence: ['V'] 188 | }, 189 | { 190 | command: 'notebook-cells:insert-above', 191 | selector: '.jp-Notebook.jp-mod-commandMode', 192 | sequence: ['A'] 193 | }, 194 | { 195 | command: 'notebook-cells:insert-below', 196 | selector: '.jp-Notebook.jp-mod-commandMode', 197 | sequence: ['B'] 198 | }, 199 | { 200 | command: 'notebook-cells:select-previous', 201 | selector: '.jp-Notebook.jp-mod-commandMode', 202 | sequence: ['ArrowUp'] 203 | }, 204 | { 205 | command: 'notebook-cells:select-next', 206 | selector: '.jp-Notebook.jp-mod-commandMode', 207 | sequence: ['ArrowDown'] 208 | }, 209 | { 210 | command: 'notebook-cells:toggle-lineNumbers', 211 | selector: '.jp-Notebook.jp-mod-commandMode', 212 | sequence: ['L'] 213 | }, 214 | { 215 | command: 'notebook-cells:editMode', 216 | selector: '.jp-Notebook.jp-mod-commandMode', 217 | sequence: ['Enter'] 218 | }, 219 | { 220 | command: 'notebook-cells:commandMode', 221 | selector: '.jp-Notebook.jp-mod-editMode', 222 | sequence: ['Escape'] 223 | }, 224 | { 225 | command: 'console:execute', 226 | selector: '.jp-Console .jp-CellEditor', 227 | sequence: ['Shift Enter'] 228 | }, 229 | ]; 230 | 231 | 232 | /** 233 | * The default shortcuts extension. 234 | */ 235 | export 236 | const shortcutsExtension = { 237 | id: 'jupyter.extensions.shortcuts', 238 | activate: (app: Application): Promise => { 239 | app.shortcuts.add(SHORTCUTS); 240 | return Promise.resolve(void 0); 241 | } 242 | }; 243 | -------------------------------------------------------------------------------- /src/terminal/plugin.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 'use strict'; 4 | 5 | import { 6 | TerminalWidget 7 | } from 'jupyter-js-ui/lib/terminal'; 8 | 9 | import { 10 | Application 11 | } from 'phosphide/lib/core/application'; 12 | 13 | import { 14 | TabPanel 15 | } from 'phosphor-tabs'; 16 | 17 | 18 | /** 19 | * The default terminal extension. 20 | */ 21 | export 22 | const terminalExtension = { 23 | id: 'jupyter.extensions.terminal', 24 | activate: activateTerminal 25 | }; 26 | 27 | 28 | function activateTerminal(app: Application): Promise { 29 | 30 | let newTerminalId = 'terminal:create-new'; 31 | 32 | app.commands.add([{ 33 | id: newTerminalId, 34 | handler: () => { 35 | let term = new TerminalWidget(); 36 | term.color = 'black'; 37 | term.background = 'white'; 38 | term.title.closable = true; 39 | app.shell.addToMainArea(term); 40 | let stack = term.parent; 41 | if (!stack) { 42 | return; 43 | } 44 | let tabs = stack.parent; 45 | if (tabs instanceof TabPanel) { 46 | tabs.currentWidget = term; 47 | } 48 | } 49 | }]); 50 | app.palette.add([ 51 | { 52 | command: newTerminalId, 53 | category: 'Terminal', 54 | text: 'New Terminal', 55 | caption: 'Start a new terminal session' 56 | } 57 | ]); 58 | 59 | return Promise.resolve(void 0); 60 | } 61 | -------------------------------------------------------------------------------- /src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "declaration": true, 4 | "noImplicitAny": true, 5 | "noEmitOnError": true, 6 | "module": "commonjs", 7 | "moduleResolution": "node", 8 | "target": "ES5", 9 | "outDir": "../lib" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/typings.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | /// 4 | /// 5 | -------------------------------------------------------------------------------- /src/widgets/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 4 | import { 5 | IWidgetExtension, IDocumentContext, IDocumentModel, DocumentRegistry 6 | } from 'jupyter-js-ui/lib/docmanager'; 7 | 8 | import { 9 | IDisposable, DisposableDelegate 10 | } from 'phosphor-disposable'; 11 | 12 | import { 13 | Widget 14 | } from 'phosphor-widget'; 15 | 16 | import { 17 | NotebookPanel 18 | } from 'jupyter-js-notebook/lib/notebook/panel'; 19 | 20 | import { 21 | Application 22 | } from 'phosphide/lib/core/application'; 23 | 24 | import { 25 | WidgetManager, WidgetRenderer 26 | } from 'jupyter-js-ui/lib/widgets'; 27 | 28 | import { 29 | IKernel 30 | } from 'jupyter-js-services'; 31 | 32 | const WIDGET_MIMETYPE = 'application/vnd.jupyter.widget'; 33 | 34 | 35 | /** 36 | * The widget manager provider. 37 | */ 38 | export 39 | const widgetManagerExtension = { 40 | id: 'jupyter.extensions.widgetManager', 41 | requires: [DocumentRegistry], 42 | activate: activateWidgetExtension 43 | }; 44 | 45 | export 46 | class IPyWidgetExtension implements IWidgetExtension{ 47 | /** 48 | * Create a new extension object. 49 | */ 50 | createNew(nb: NotebookPanel, model: IDocumentModel, 51 | context: IDocumentContext): IDisposable { 52 | let wManager = new WidgetManager(context); 53 | let wRenderer = new WidgetRenderer(wManager); 54 | 55 | nb.content.rendermime.addRenderer(WIDGET_MIMETYPE, wRenderer, 0) 56 | return new DisposableDelegate(() => { 57 | nb.content.rendermime.removeRenderer(WIDGET_MIMETYPE); 58 | wRenderer.dispose(); 59 | wManager.dispose(); 60 | }) 61 | } 62 | } 63 | 64 | /** 65 | * Activate the widget extension. 66 | */ 67 | function activateWidgetExtension(app: Application, registry: DocumentRegistry) { 68 | registry.registerExtension('Notebook', new IPyWidgetExtension()); 69 | } 70 | -------------------------------------------------------------------------------- /test/karma-cov.conf.js: -------------------------------------------------------------------------------- 1 | var path = require('path'); 2 | 3 | module.exports = function (config) { 4 | config.set({ 5 | basePath: '..', 6 | browsers: ['Firefox'], 7 | frameworks: ['mocha'], 8 | reporters: ['mocha', 'coverage'], 9 | files: ['test/build/coverage.js'], 10 | coverageReporter: { 11 | reporters : [ 12 | { 'type': 'text' }, 13 | { 'type': 'lcov', dir: 'test/coverage' }, 14 | { 'type': 'html', dir: 'test/coverage' } 15 | ] 16 | }, 17 | port: 9876, 18 | colors: true, 19 | singleRun: true, 20 | logLevel: config.LOG_INFO 21 | }); 22 | }; 23 | -------------------------------------------------------------------------------- /test/karma.conf.js: -------------------------------------------------------------------------------- 1 | module.exports = function (config) { 2 | config.set({ 3 | basePath: '..', 4 | frameworks: ['mocha'], 5 | reporters: ['mocha'], 6 | files: ['test/build/bundle.js'], 7 | port: 9876, 8 | colors: true, 9 | singleRun: true, 10 | logLevel: config.LOG_INFO 11 | }); 12 | }; 13 | -------------------------------------------------------------------------------- /test/src/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 'use strict'; 4 | 5 | import expect = require('expect.js'); 6 | 7 | 8 | describe('jupyter.filebrowser', () => { 9 | 10 | describe('FileBrowserWidget', () => { 11 | 12 | it('should always pass', () => { 13 | 14 | }); 15 | 16 | }); 17 | 18 | }); 19 | -------------------------------------------------------------------------------- /test/src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "noImplicitAny": true, 4 | "noEmitOnError": true, 5 | "module": "commonjs", 6 | "moduleResolution": "node", 7 | "target": "ES5", 8 | "outDir": "../build" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/src/typings.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | -------------------------------------------------------------------------------- /test/webpack-cov.conf.js: -------------------------------------------------------------------------------- 1 | var path = require('path'); 2 | 3 | module.exports = { 4 | entry: './test/build/index.js', 5 | output: { 6 | path: __dirname + "/build", 7 | filename: "coverage.js", 8 | publicPath: "./build/" 9 | }, 10 | bail: true, 11 | module: { 12 | loaders: [ 13 | { test: /\.css$/, loader: 'style-loader!css-loader' }, 14 | ], 15 | preLoaders: [ 16 | // instrument only testing sources with Istanbul 17 | { 18 | test: /\.js$/, 19 | include: path.resolve('lib/'), 20 | loader: 'istanbul-instrumenter' 21 | } 22 | ] 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test/webpack.conf.js: -------------------------------------------------------------------------------- 1 | var path = require('path'); 2 | 3 | module.exports = { 4 | entry: './test/build/index.js', 5 | output: { 6 | path: __dirname + "/build", 7 | filename: "bundle.js", 8 | publicPath: "./build/" 9 | }, 10 | bail: true, 11 | module: { 12 | loaders: [ 13 | { test: /\.css$/, loader: 'style-loader!css-loader' }, 14 | ], 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /typings/backbone/backbone-global.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for Backbone 1.0.0 2 | // Project: http://backbonejs.org/ 3 | // Definitions by: Boris Yankov , Natan Vivo 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | 6 | /// 7 | 8 | declare module Backbone { 9 | 10 | interface AddOptions extends Silenceable { 11 | at?: number; 12 | } 13 | 14 | interface HistoryOptions extends Silenceable { 15 | pushState?: boolean; 16 | root?: string; 17 | } 18 | 19 | interface NavigateOptions { 20 | trigger?: boolean; 21 | replace?: boolean; 22 | } 23 | 24 | interface RouterOptions { 25 | routes: any; 26 | } 27 | 28 | interface Silenceable { 29 | silent?: boolean; 30 | } 31 | 32 | interface Validable { 33 | validate?: boolean; 34 | } 35 | 36 | interface Waitable { 37 | wait?: boolean; 38 | } 39 | 40 | interface Parseable { 41 | parse?: any; 42 | } 43 | 44 | interface PersistenceOptions { 45 | url?: string; 46 | data?: any; 47 | beforeSend?: (jqxhr: JQueryXHR) => void; 48 | success?: (modelOrCollection?: any, response?: any, options?: any) => void; 49 | error?: (modelOrCollection?: any, jqxhr?: JQueryXHR, options?: any) => void; 50 | } 51 | 52 | interface ModelSetOptions extends Silenceable, Validable { 53 | } 54 | 55 | interface ModelFetchOptions extends PersistenceOptions, ModelSetOptions, Parseable { 56 | } 57 | 58 | interface ModelSaveOptions extends Silenceable, Waitable, Validable, Parseable, PersistenceOptions { 59 | patch?: boolean; 60 | } 61 | 62 | interface ModelDestroyOptions extends Waitable, PersistenceOptions { 63 | } 64 | 65 | interface CollectionFetchOptions extends PersistenceOptions, Parseable { 66 | reset?: boolean; 67 | } 68 | 69 | interface ObjectHash { 70 | [key: string]: any; 71 | } 72 | 73 | interface RoutesHash { 74 | [routePattern: string]: string | {(...urlParts: string[]): void}; 75 | } 76 | 77 | interface EventsHash { 78 | [selector: string]: string | {(eventObject: JQueryEventObject): void}; 79 | } 80 | 81 | class Events { 82 | on(eventName: string, callback?: Function, context?: any): any; 83 | on(eventMap: EventsHash): any; 84 | off(eventName?: string, callback?: Function, context?: any): any; 85 | trigger(eventName: string, ...args: any[]): any; 86 | bind(eventName: string, callback: Function, context?: any): any; 87 | unbind(eventName?: string, callback?: Function, context?: any): any; 88 | 89 | once(events: string, callback: Function, context?: any): any; 90 | listenTo(object: any, events: string, callback: Function): any; 91 | listenToOnce(object: any, events: string, callback: Function): any; 92 | stopListening(object?: any, events?: string, callback?: Function): any; 93 | } 94 | 95 | class ModelBase extends Events { 96 | url: any; 97 | parse(response: any, options?: any): any; 98 | toJSON(options?: any): any; 99 | sync(...arg: any[]): JQueryXHR; 100 | } 101 | 102 | class Model extends ModelBase { 103 | 104 | /** 105 | * Do not use, prefer TypeScript's extend functionality. 106 | **/ 107 | private static extend(properties: any, classProperties?: any): any; 108 | 109 | attributes: any; 110 | changed: any[]; 111 | cid: string; 112 | collection: Collection; 113 | 114 | /** 115 | * Default attributes for the model. It can be an object hash or a method returning an object hash. 116 | * For assigning an object hash, do it like this: this.defaults = { attribute: value, ... }; 117 | * That works only if you set it in the constructor or the initialize method. 118 | **/ 119 | defaults(): ObjectHash; 120 | id: any; 121 | idAttribute: string; 122 | validationError: any; 123 | urlRoot: any; 124 | 125 | constructor(attributes?: any, options?: any); 126 | initialize(attributes?: any, options?: any): void; 127 | 128 | fetch(options?: ModelFetchOptions): JQueryXHR; 129 | 130 | /** 131 | * For strongly-typed access to attributes, use the `get` method only privately in public getter properties. 132 | * @example 133 | * get name(): string { 134 | * return super.get("name"); 135 | * } 136 | **/ 137 | /*private*/ get(attributeName: string): any; 138 | 139 | /** 140 | * For strongly-typed assignment of attributes, use the `set` method only privately in public setter properties. 141 | * @example 142 | * set name(value: string) { 143 | * super.set("name", value); 144 | * } 145 | **/ 146 | /*private*/ set(attributeName: string, value: any, options?: ModelSetOptions): Model; 147 | set(obj: any, options?: ModelSetOptions): Model; 148 | 149 | change(): any; 150 | changedAttributes(attributes?: any): any[]; 151 | clear(options?: Silenceable): any; 152 | clone(): Model; 153 | destroy(options?: ModelDestroyOptions): any; 154 | escape(attribute: string): string; 155 | has(attribute: string): boolean; 156 | hasChanged(attribute?: string): boolean; 157 | isNew(): boolean; 158 | isValid(options?:any): boolean; 159 | previous(attribute: string): any; 160 | previousAttributes(): any[]; 161 | save(attributes?: any, options?: ModelSaveOptions): any; 162 | unset(attribute: string, options?: Silenceable): Model; 163 | validate(attributes: any, options?: any): any; 164 | 165 | private _validate(attributes: any, options: any): boolean; 166 | 167 | // mixins from underscore 168 | 169 | keys(): string[]; 170 | values(): any[]; 171 | pairs(): any[]; 172 | invert(): any; 173 | pick(keys: string[]): any; 174 | pick(...keys: string[]): any; 175 | omit(keys: string[]): any; 176 | omit(...keys: string[]): any; 177 | } 178 | 179 | class Collection extends ModelBase { 180 | 181 | /** 182 | * Do not use, prefer TypeScript's extend functionality. 183 | **/ 184 | private static extend(properties: any, classProperties?: any): any; 185 | 186 | model: new (...args:any[]) => TModel; 187 | models: TModel[]; 188 | length: number; 189 | 190 | constructor(models?: TModel[] | Object[], options?: any); 191 | initialize(models?: TModel[] | Object[], options?: any): void; 192 | 193 | fetch(options?: CollectionFetchOptions): JQueryXHR; 194 | 195 | comparator(element: TModel): number; 196 | comparator(compare: TModel, to?: TModel): number; 197 | 198 | add(model: {}|TModel, options?: AddOptions): TModel; 199 | add(models: ({}|TModel)[], options?: AddOptions): TModel[]; 200 | at(index: number): TModel; 201 | /** 202 | * Get a model from a collection, specified by an id, a cid, or by passing in a model. 203 | **/ 204 | get(id: number|string|Model): TModel; 205 | create(attributes: any, options?: ModelSaveOptions): TModel; 206 | pluck(attribute: string): any[]; 207 | push(model: TModel, options?: AddOptions): TModel; 208 | pop(options?: Silenceable): TModel; 209 | remove(model: TModel, options?: Silenceable): TModel; 210 | remove(models: TModel[], options?: Silenceable): TModel[]; 211 | reset(models?: TModel[], options?: Silenceable): TModel[]; 212 | set(models?: TModel[], options?: Silenceable): TModel[]; 213 | shift(options?: Silenceable): TModel; 214 | sort(options?: Silenceable): Collection; 215 | unshift(model: TModel, options?: AddOptions): TModel; 216 | where(properties: any): TModel[]; 217 | findWhere(properties: any): TModel; 218 | 219 | private _prepareModel(attributes?: any, options?: any): any; 220 | private _removeReference(model: TModel): void; 221 | private _onModelEvent(event: string, model: TModel, collection: Collection, options: any): void; 222 | 223 | // mixins from underscore 224 | 225 | all(iterator: (element: TModel, index: number) => boolean, context?: any): boolean; 226 | any(iterator: (element: TModel, index: number) => boolean, context?: any): boolean; 227 | collect(iterator: (element: TModel, index: number, context?: any) => any[], context?: any): any[]; 228 | chain(): any; 229 | contains(value: any): boolean; 230 | countBy(iterator: (element: TModel, index: number) => any): _.Dictionary; 231 | countBy(attribute: string): _.Dictionary; 232 | detect(iterator: (item: any) => boolean, context?: any): any; // ??? 233 | drop(): TModel; 234 | drop(n: number): TModel[]; 235 | each(iterator: (element: TModel, index: number, list?: any) => void, context?: any): any; 236 | every(iterator: (element: TModel, index: number) => boolean, context?: any): boolean; 237 | filter(iterator: (element: TModel, index: number) => boolean, context?: any): TModel[]; 238 | find(iterator: (element: TModel, index: number) => boolean, context?: any): TModel; 239 | first(): TModel; 240 | first(n: number): TModel[]; 241 | foldl(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any; 242 | forEach(iterator: (element: TModel, index: number, list?: any) => void, context?: any): any; 243 | groupBy(iterator: (element: TModel, index: number) => string, context?: any): _.Dictionary; 244 | groupBy(attribute: string, context?: any): _.Dictionary; 245 | include(value: any): boolean; 246 | indexOf(element: TModel, isSorted?: boolean): number; 247 | initial(): TModel; 248 | initial(n: number): TModel[]; 249 | inject(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any; 250 | isEmpty(object: any): boolean; 251 | invoke(methodName: string, args?: any[]): any; 252 | last(): TModel; 253 | last(n: number): TModel[]; 254 | lastIndexOf(element: TModel, fromIndex?: number): number; 255 | map(iterator: (element: TModel, index: number, context?: any) => any, context?: any): any[]; 256 | max(iterator?: (element: TModel, index: number) => any, context?: any): TModel; 257 | min(iterator?: (element: TModel, index: number) => any, context?: any): TModel; 258 | reduce(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any; 259 | select(iterator: any, context?: any): any[]; 260 | size(): number; 261 | shuffle(): any[]; 262 | slice(min: number, max?: number): TModel[]; 263 | some(iterator: (element: TModel, index: number) => boolean, context?: any): boolean; 264 | sortBy(iterator: (element: TModel, index: number) => number, context?: any): TModel[]; 265 | sortBy(attribute: string, context?: any): TModel[]; 266 | sortedIndex(element: TModel, iterator?: (element: TModel, index: number) => number): number; 267 | reduceRight(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any[]; 268 | reject(iterator: (element: TModel, index: number) => boolean, context?: any): TModel[]; 269 | rest(): TModel; 270 | rest(n: number): TModel[]; 271 | tail(): TModel; 272 | tail(n: number): TModel[]; 273 | toArray(): any[]; 274 | without(...values: any[]): TModel[]; 275 | } 276 | 277 | class Router extends Events { 278 | 279 | /** 280 | * Do not use, prefer TypeScript's extend functionality. 281 | **/ 282 | private static extend(properties: any, classProperties?: any): any; 283 | 284 | /** 285 | * Routes hash or a method returning the routes hash that maps URLs with parameters to methods on your Router. 286 | * For assigning routes as object hash, do it like this: this.routes = { "route": callback, ... }; 287 | * That works only if you set it in the constructor or the initialize method. 288 | **/ 289 | routes: RoutesHash | any; 290 | 291 | constructor(options?: RouterOptions); 292 | initialize(options?: RouterOptions): void; 293 | route(route: string|RegExp, name: string, callback?: Function): Router; 294 | navigate(fragment: string, options?: NavigateOptions): Router; 295 | navigate(fragment: string, trigger?: boolean): Router; 296 | 297 | private _bindRoutes(): void; 298 | private _routeToRegExp(route: string): RegExp; 299 | private _extractParameters(route: RegExp, fragment: string): string[]; 300 | } 301 | 302 | var history: History; 303 | 304 | class History extends Events { 305 | 306 | handlers: any[]; 307 | interval: number; 308 | 309 | start(options?: HistoryOptions): boolean; 310 | 311 | getHash(window?: Window): string; 312 | getFragment(fragment?: string, forcePushState?: boolean): string; 313 | stop(): void; 314 | route(route: string, callback: Function): number; 315 | checkUrl(e?: any): void; 316 | loadUrl(fragmentOverride: string): boolean; 317 | navigate(fragment: string, options?: any): boolean; 318 | static started: boolean; 319 | options: any; 320 | 321 | private _updateHash(location: Location, fragment: string, replace: boolean): void; 322 | } 323 | 324 | interface ViewOptions { 325 | model?: TModel; 326 | // TODO: quickfix, this can't be fixed easy. The collection does not need to have the same model as the parent view. 327 | collection?: Backbone.Collection; //was: Collection; 328 | el?: any; 329 | id?: string; 330 | className?: string; 331 | tagName?: string; 332 | attributes?: {[id: string]: any}; 333 | } 334 | 335 | class View extends Events { 336 | 337 | /** 338 | * Do not use, prefer TypeScript's extend functionality. 339 | **/ 340 | private static extend(properties: any, classProperties?: any): any; 341 | 342 | constructor(options?: ViewOptions); 343 | initialize(options?: ViewOptions): void; 344 | 345 | /** 346 | * Events hash or a method returning the events hash that maps events/selectors to methods on your View. 347 | * For assigning events as object hash, do it like this: this.events = { "event:selector": callback, ... }; 348 | * That works only if you set it in the constructor or the initialize method. 349 | **/ 350 | events(): EventsHash; 351 | 352 | $(selector: string): JQuery; 353 | model: TModel; 354 | collection: Collection; 355 | //template: (json, options?) => string; 356 | setElement(element: HTMLElement|JQuery, delegate?: boolean): View; 357 | id: string; 358 | cid: string; 359 | className: string; 360 | tagName: string; 361 | 362 | el: any; 363 | $el: JQuery; 364 | setElement(element: any): View; 365 | attributes: any; 366 | $(selector: any): JQuery; 367 | render(): View; 368 | remove(): View; 369 | make(tagName: any, attributes?: any, content?: any): any; 370 | delegateEvents(events?: EventsHash): any; 371 | delegate(eventName: string, selector: string, listener: Function): View; 372 | undelegateEvents(): any; 373 | undelegate(eventName: string, selector?: string, listener?: Function): View; 374 | 375 | _ensureElement(): void; 376 | } 377 | 378 | // SYNC 379 | function sync(method: string, model: Model, options?: JQueryAjaxSettings): any; 380 | function ajax(options?: JQueryAjaxSettings): JQueryXHR; 381 | var emulateHTTP: boolean; 382 | var emulateJSON: boolean; 383 | 384 | // Utility 385 | function noConflict(): typeof Backbone; 386 | var $: JQueryStatic; 387 | } 388 | 389 | declare module "backbone" { 390 | export = Backbone; 391 | } 392 | -------------------------------------------------------------------------------- /typings/backbone/backbone.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for Backbone 1.0.0 2 | // Project: http://backbonejs.org/ 3 | // Definitions by: Boris Yankov , Natan Vivo 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | 6 | /// 7 | /// 8 | -------------------------------------------------------------------------------- /typings/es6-promise/es6-promise.d.ts: -------------------------------------------------------------------------------- 1 | // ES6 Promises 2 | // From https://github.com/Microsoft/TypeScript/blob/911d07a81b9348dd576985f263955c8e0968277e/lib/lib.core.es6.d.ts 3 | 4 | /*! ***************************************************************************** 5 | Copyright (c) Microsoft Corporation. All rights reserved. 6 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 7 | this file except in compliance with the License. You may obtain a copy of the 8 | License at http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 11 | KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 12 | WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 13 | MERCHANTABLITY OR NON-INFRINGEMENT. 14 | 15 | See the Apache Version 2.0 License for specific language governing permissions 16 | and limitations under the License. 17 | ***************************************************************************** */ 18 | 19 | interface Symbol { 20 | /** Returns a string representation of an object. */ 21 | toString(): string; 22 | 23 | /** Returns the primitive value of the specified object. */ 24 | valueOf(): Object; 25 | 26 | //[Symbol.toStringTag]: "Symbol"; 27 | } 28 | 29 | interface SymbolConstructor { 30 | /** 31 | * A reference to the prototype. 32 | */ 33 | prototype: Symbol; 34 | 35 | /** 36 | * Returns a new unique Symbol value. 37 | * @param description Description of the new Symbol object. 38 | */ 39 | (description?: string|number): symbol; 40 | 41 | /** 42 | * Returns a Symbol object from the global symbol registry matching the given key if found. 43 | * Otherwise, returns a new symbol with this key. 44 | * @param key key to search for. 45 | */ 46 | for(key: string): symbol; 47 | 48 | /** 49 | * Returns a key from the global symbol registry matching the given Symbol if found. 50 | * Otherwise, returns a undefined. 51 | * @param sym Symbol to find the key for. 52 | */ 53 | keyFor(sym: symbol): string; 54 | 55 | // Well-known Symbols 56 | 57 | /** 58 | * A method that determines if a constructor object recognizes an object as one of the 59 | * constructor’s instances. Called by the semantics of the instanceof operator. 60 | */ 61 | hasInstance: symbol; 62 | 63 | /** 64 | * A Boolean value that if true indicates that an object should flatten to its array elements 65 | * by Array.prototype.concat. 66 | */ 67 | isConcatSpreadable: symbol; 68 | 69 | /** 70 | * A method that returns the default iterator for an object. Called by the semantics of the 71 | * for-of statement. 72 | */ 73 | iterator: symbol; 74 | 75 | /** 76 | * A regular expression method that matches the regular expression against a string. Called 77 | * by the String.prototype.match method. 78 | */ 79 | match: symbol; 80 | 81 | /** 82 | * A regular expression method that replaces matched substrings of a string. Called by the 83 | * String.prototype.replace method. 84 | */ 85 | replace: symbol; 86 | 87 | /** 88 | * A regular expression method that returns the index within a string that matches the 89 | * regular expression. Called by the String.prototype.search method. 90 | */ 91 | search: symbol; 92 | 93 | /** 94 | * A function valued property that is the constructor function that is used to create 95 | * derived objects. 96 | */ 97 | species: symbol; 98 | 99 | /** 100 | * A regular expression method that splits a string at the indices that match the regular 101 | * expression. Called by the String.prototype.split method. 102 | */ 103 | split: symbol; 104 | 105 | /** 106 | * A method that converts an object to a corresponding primitive value. 107 | * Called by the ToPrimitive abstract operation. 108 | */ 109 | toPrimitive: symbol; 110 | 111 | /** 112 | * A String value that is used in the creation of the default string description of an object. 113 | * Called by the built-in method Object.prototype.toString. 114 | */ 115 | toStringTag: symbol; 116 | 117 | /** 118 | * An Object whose own property names are property names that are excluded from the 'with' 119 | * environment bindings of the associated objects. 120 | */ 121 | unscopables: symbol; 122 | } 123 | declare var Symbol: SymbolConstructor; 124 | 125 | interface IteratorResult { 126 | done: boolean; 127 | value?: T; 128 | } 129 | 130 | interface Iterator { 131 | next(value?: any): IteratorResult; 132 | return?(value?: any): IteratorResult; 133 | throw?(e?: any): IteratorResult; 134 | } 135 | 136 | interface Iterable { 137 | [Symbol.iterator](): Iterator; 138 | } 139 | 140 | 141 | /** 142 | * Represents the completion of an asynchronous operation 143 | */ 144 | interface Promise { 145 | /** 146 | * Attaches callbacks for the resolution and/or rejection of the Promise. 147 | * @param onfulfilled The callback to execute when the Promise is resolved. 148 | * @param onrejected The callback to execute when the Promise is rejected. 149 | * @returns A Promise for the completion of which ever callback is executed. 150 | */ 151 | then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; 152 | then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): Promise; 153 | 154 | /** 155 | * Attaches a callback for only the rejection of the Promise. 156 | * @param onrejected The callback to execute when the Promise is rejected. 157 | * @returns A Promise for the completion of the callback. 158 | */ 159 | catch(onrejected?: (reason: any) => T | PromiseLike): Promise; 160 | catch(onrejected?: (reason: any) => void): Promise; 161 | 162 | //[Symbol.toStringTag]: "Promise"; 163 | } 164 | 165 | interface PromiseConstructor { 166 | /** 167 | * A reference to the prototype. 168 | */ 169 | prototype: Promise; 170 | 171 | /** 172 | * Creates a new Promise. 173 | * @param executor A callback used to initialize the promise. This callback is passed two arguments: 174 | * a resolve callback used resolve the promise with a value or the result of another promise, 175 | * and a reject callback used to reject the promise with a provided reason or error. 176 | */ 177 | new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void): Promise; 178 | 179 | /** 180 | * Creates a Promise that is resolved with an array of results when all of the provided Promises 181 | * resolve, or rejected when any Promise is rejected. 182 | * @param values An array of Promises. 183 | * @returns A new Promise. 184 | */ 185 | all(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; 186 | all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; 187 | all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike ]): Promise<[T1, T2, T3, T4]>; 188 | all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; 189 | all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; 190 | all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; 191 | all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; 192 | all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; 193 | all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; 194 | all(values: Iterable>): Promise; 195 | 196 | /** 197 | * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved 198 | * or rejected. 199 | * @param values An array of Promises. 200 | * @returns A new Promise. 201 | */ 202 | race(values: Iterable>): Promise; 203 | 204 | /** 205 | * Creates a new rejected promise for the provided reason. 206 | * @param reason The reason the promise was rejected. 207 | * @returns A new rejected Promise. 208 | */ 209 | reject(reason: any): Promise; 210 | 211 | /** 212 | * Creates a new rejected promise for the provided reason. 213 | * @param reason The reason the promise was rejected. 214 | * @returns A new rejected Promise. 215 | */ 216 | reject(reason: any): Promise; 217 | 218 | /** 219 | * Creates a new resolved promise for the provided value. 220 | * @param value A promise. 221 | * @returns A promise whose internal state matches the provided promise. 222 | */ 223 | resolve(value: T | PromiseLike): Promise; 224 | 225 | /** 226 | * Creates a new resolved promise . 227 | * @returns A resolved promise. 228 | */ 229 | resolve(): Promise; 230 | 231 | [Symbol.species]: Function; 232 | } 233 | 234 | declare var Promise: PromiseConstructor; 235 | 236 | 237 | // *just* for jupyter-js-services, which uses a different name. 238 | declare type Thenable = PromiseLike; -------------------------------------------------------------------------------- /typings/expect.js/expect.js.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for expect.js 0.3.1 2 | // Project: https://github.com/Automattic/expect.js 3 | // Definitions by: Teppei Sato 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | 6 | declare function expect(target?: any): Expect.Root; 7 | 8 | declare module Expect { 9 | interface Assertion { 10 | /** 11 | * Check if the value is truthy 12 | */ 13 | ok(): void; 14 | 15 | /** 16 | * Creates an anonymous function which calls fn with arguments. 17 | */ 18 | withArgs(...args: any[]): Root; 19 | 20 | /** 21 | * Assert that the function throws. 22 | * 23 | * @param fn callback to match error string against 24 | */ 25 | throwError(fn?: (exception: any) => void): void; 26 | 27 | /** 28 | * Assert that the function throws. 29 | * 30 | * @param fn callback to match error string against 31 | */ 32 | throwException(fn?: (exception: any) => void): void; 33 | 34 | /** 35 | * Assert that the function throws. 36 | * 37 | * @param regexp regexp to match error string against 38 | */ 39 | throwError(regexp: RegExp): void; 40 | 41 | /** 42 | * Assert that the function throws. 43 | * 44 | * @param fn callback to match error string against 45 | */ 46 | throwException(regexp: RegExp): void; 47 | 48 | /** 49 | * Checks if the array is empty. 50 | */ 51 | empty(): Assertion; 52 | 53 | /** 54 | * Checks if the obj exactly equals another. 55 | */ 56 | equal(obj: any): Assertion; 57 | 58 | /** 59 | * Checks if the obj sortof equals another. 60 | */ 61 | eql(obj: any): Assertion; 62 | 63 | /** 64 | * Assert within start to finish (inclusive). 65 | * 66 | * @param start 67 | * @param finish 68 | */ 69 | within(start: number, finish: number): Assertion; 70 | 71 | /** 72 | * Assert typeof. 73 | */ 74 | a(type: string): Assertion; 75 | 76 | /** 77 | * Assert instanceof. 78 | */ 79 | a(type: Function): Assertion; 80 | 81 | /** 82 | * Assert typeof / instanceof. 83 | */ 84 | an: An; 85 | 86 | /** 87 | * Assert numeric value above n. 88 | */ 89 | greaterThan(n: number): Assertion; 90 | 91 | /** 92 | * Assert numeric value above n. 93 | */ 94 | above(n: number): Assertion; 95 | 96 | /** 97 | * Assert numeric value below n. 98 | */ 99 | lessThan(n: number): Assertion; 100 | 101 | /** 102 | * Assert numeric value below n. 103 | */ 104 | below(n: number): Assertion; 105 | 106 | /** 107 | * Assert string value matches regexp. 108 | * 109 | * @param regexp 110 | */ 111 | match(regexp: RegExp): Assertion; 112 | 113 | /** 114 | * Assert property "length" exists and has value of n. 115 | * 116 | * @param n 117 | */ 118 | length(n: number): Assertion; 119 | 120 | /** 121 | * Assert property name exists, with optional val. 122 | * 123 | * @param name 124 | * @param val 125 | */ 126 | property(name: string, val?: any): Assertion; 127 | 128 | /** 129 | * Assert that string contains str. 130 | */ 131 | contain(str: string): Assertion; 132 | string(str: string): Assertion; 133 | 134 | /** 135 | * Assert that the array contains obj. 136 | */ 137 | contain(obj: any): Assertion; 138 | string(obj: any): Assertion; 139 | 140 | /** 141 | * Assert exact keys or inclusion of keys by using the `.own` modifier. 142 | */ 143 | key(keys: string[]): Assertion; 144 | /** 145 | * Assert exact keys or inclusion of keys by using the `.own` modifier. 146 | */ 147 | key(...keys: string[]): Assertion; 148 | /** 149 | * Assert exact keys or inclusion of keys by using the `.own` modifier. 150 | */ 151 | keys(keys: string[]): Assertion; 152 | /** 153 | * Assert exact keys or inclusion of keys by using the `.own` modifier. 154 | */ 155 | keys(...keys: string[]): Assertion; 156 | 157 | /** 158 | * Assert a failure. 159 | */ 160 | fail(message?: string): Assertion; 161 | } 162 | 163 | interface Root extends Assertion { 164 | not: Not; 165 | to: To; 166 | only: Only; 167 | have: Have; 168 | be: Be; 169 | } 170 | 171 | interface Be extends Assertion { 172 | /** 173 | * Checks if the obj exactly equals another. 174 | */ 175 | (obj: any): Assertion; 176 | 177 | an: An; 178 | } 179 | 180 | interface An extends Assertion { 181 | /** 182 | * Assert typeof. 183 | */ 184 | (type: string): Assertion; 185 | 186 | /** 187 | * Assert instanceof. 188 | */ 189 | (type: Function): Assertion; 190 | } 191 | 192 | interface Not extends Expect.NotBase { 193 | to: Expect.ToBase; 194 | } 195 | 196 | interface NotBase extends Assertion { 197 | be: Be; 198 | have: Have; 199 | include: Assertion; 200 | only: Only; 201 | } 202 | 203 | interface To extends Expect.ToBase { 204 | not: Expect.NotBase; 205 | } 206 | 207 | interface ToBase extends Assertion { 208 | be: Be; 209 | have: Have; 210 | include: Assertion; 211 | only: Only; 212 | } 213 | 214 | interface Only extends Assertion { 215 | have: Have; 216 | } 217 | 218 | interface Have extends Assertion { 219 | own: Assertion; 220 | } 221 | } 222 | 223 | declare module "expect.js" { 224 | 225 | export = expect; 226 | 227 | } 228 | -------------------------------------------------------------------------------- /typings/jupyter-js-widgets/jupyter-js-widgets.d.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Jupyter Development Team. 2 | // Distributed under the terms of the Modified BSD License. 3 | 4 | /// 5 | 6 | 7 | declare module "jupyter-js-widgets" { 8 | import * as services from 'jupyter-js-services'; 9 | 10 | export class ManagerBase { 11 | display_view(msg: services.IKernelMessage, view: Backbone.View, options: any): T; 12 | handle_comm_open(comm: shims.services.Comm, msg: services.IKernelIOPubCommOpenMessage): Promise; 13 | display_model(msg: services.IKernelMessage, model: Backbone.Model, options: any): Promise; 14 | get_model(id: string): Promise; 15 | validateVersion(): Promise; 16 | comm_target_name: string; 17 | } 18 | 19 | export namespace shims { 20 | export namespace services { 21 | export class Comm { 22 | constructor(comm: any); 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /typings/mocha/mocha.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for mocha 2.2.5 2 | // Project: http://mochajs.org/ 3 | // Definitions by: Kazi Manzur Rashid , otiai10 , jt000 , Vadim Macagon 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | 6 | interface MochaSetupOptions { 7 | //milliseconds to wait before considering a test slow 8 | slow?: number; 9 | 10 | // timeout in milliseconds 11 | timeout?: number; 12 | 13 | // ui name "bdd", "tdd", "exports" etc 14 | ui?: string; 15 | 16 | //array of accepted globals 17 | globals?: any[]; 18 | 19 | // reporter instance (function or string), defaults to `mocha.reporters.Spec` 20 | reporter?: any; 21 | 22 | // bail on the first test failure 23 | bail?: boolean; 24 | 25 | // ignore global leaks 26 | ignoreLeaks?: boolean; 27 | 28 | // grep string or regexp to filter tests with 29 | grep?: any; 30 | } 31 | 32 | interface MochaDone { 33 | (error?: Error): void; 34 | } 35 | 36 | declare var mocha: Mocha; 37 | declare var describe: Mocha.IContextDefinition; 38 | declare var xdescribe: Mocha.IContextDefinition; 39 | // alias for `describe` 40 | declare var context: Mocha.IContextDefinition; 41 | // alias for `describe` 42 | declare var suite: Mocha.IContextDefinition; 43 | declare var it: Mocha.ITestDefinition; 44 | declare var xit: Mocha.ITestDefinition; 45 | // alias for `it` 46 | declare var test: Mocha.ITestDefinition; 47 | 48 | declare function before(action: () => void): void; 49 | 50 | declare function before(action: (done: MochaDone) => void): void; 51 | 52 | declare function setup(action: () => void): void; 53 | 54 | declare function setup(action: (done: MochaDone) => void): void; 55 | 56 | declare function after(action: () => void): void; 57 | 58 | declare function after(action: (done: MochaDone) => void): void; 59 | 60 | declare function teardown(action: () => void): void; 61 | 62 | declare function teardown(action: (done: MochaDone) => void): void; 63 | 64 | declare function beforeEach(action: () => void): void; 65 | 66 | declare function beforeEach(action: (done: MochaDone) => void): void; 67 | 68 | declare function suiteSetup(action: () => void): void; 69 | 70 | declare function suiteSetup(action: (done: MochaDone) => void): void; 71 | 72 | declare function afterEach(action: () => void): void; 73 | 74 | declare function afterEach(action: (done: MochaDone) => void): void; 75 | 76 | declare function suiteTeardown(action: () => void): void; 77 | 78 | declare function suiteTeardown(action: (done: MochaDone) => void): void; 79 | 80 | declare class Mocha { 81 | constructor(options?: { 82 | grep?: RegExp; 83 | ui?: string; 84 | reporter?: string; 85 | timeout?: number; 86 | bail?: boolean; 87 | }); 88 | 89 | /** Setup mocha with the given options. */ 90 | setup(options: MochaSetupOptions): Mocha; 91 | bail(value?: boolean): Mocha; 92 | addFile(file: string): Mocha; 93 | /** Sets reporter by name, defaults to "spec". */ 94 | reporter(name: string): Mocha; 95 | /** Sets reporter constructor, defaults to mocha.reporters.Spec. */ 96 | reporter(reporter: (runner: Mocha.IRunner, options: any) => any): Mocha; 97 | ui(value: string): Mocha; 98 | grep(value: string): Mocha; 99 | grep(value: RegExp): Mocha; 100 | invert(): Mocha; 101 | ignoreLeaks(value: boolean): Mocha; 102 | checkLeaks(): Mocha; 103 | /** 104 | * Function to allow assertion libraries to throw errors directly into mocha. 105 | * This is useful when running tests in a browser because window.onerror will 106 | * only receive the 'message' attribute of the Error. 107 | */ 108 | throwError(error: Error): void; 109 | /** Enables growl support. */ 110 | growl(): Mocha; 111 | globals(value: string): Mocha; 112 | globals(values: string[]): Mocha; 113 | useColors(value: boolean): Mocha; 114 | useInlineDiffs(value: boolean): Mocha; 115 | timeout(value: number): Mocha; 116 | slow(value: number): Mocha; 117 | enableTimeouts(value: boolean): Mocha; 118 | asyncOnly(value: boolean): Mocha; 119 | noHighlighting(value: boolean): Mocha; 120 | /** Runs tests and invokes `onComplete()` when finished. */ 121 | run(onComplete?: (failures: number) => void): Mocha.IRunner; 122 | } 123 | 124 | // merge the Mocha class declaration with a module 125 | declare module Mocha { 126 | /** Partial interface for Mocha's `Runnable` class. */ 127 | interface IRunnable { 128 | title: string; 129 | fn: Function; 130 | async: boolean; 131 | sync: boolean; 132 | timedOut: boolean; 133 | } 134 | 135 | /** Partial interface for Mocha's `Suite` class. */ 136 | interface ISuite { 137 | parent: ISuite; 138 | title: string; 139 | 140 | fullTitle(): string; 141 | } 142 | 143 | /** Partial interface for Mocha's `Test` class. */ 144 | interface ITest extends IRunnable { 145 | parent: ISuite; 146 | pending: boolean; 147 | 148 | fullTitle(): string; 149 | } 150 | 151 | /** Partial interface for Mocha's `Runner` class. */ 152 | interface IRunner {} 153 | 154 | interface IContextDefinition { 155 | (description: string, spec: () => void): ISuite; 156 | only(description: string, spec: () => void): ISuite; 157 | skip(description: string, spec: () => void): void; 158 | timeout(ms: number): void; 159 | } 160 | 161 | interface ITestDefinition { 162 | (expectation: string, assertion?: () => void): ITest; 163 | (expectation: string, assertion?: (done: MochaDone) => void): ITest; 164 | only(expectation: string, assertion?: () => void): ITest; 165 | only(expectation: string, assertion?: (done: MochaDone) => void): ITest; 166 | skip(expectation: string, assertion?: () => void): void; 167 | skip(expectation: string, assertion?: (done: MochaDone) => void): void; 168 | timeout(ms: number): void; 169 | } 170 | 171 | export module reporters { 172 | export class Base { 173 | stats: { 174 | suites: number; 175 | tests: number; 176 | passes: number; 177 | pending: number; 178 | failures: number; 179 | }; 180 | 181 | constructor(runner: IRunner); 182 | } 183 | 184 | export class Doc extends Base {} 185 | export class Dot extends Base {} 186 | export class HTML extends Base {} 187 | export class HTMLCov extends Base {} 188 | export class JSON extends Base {} 189 | export class JSONCov extends Base {} 190 | export class JSONStream extends Base {} 191 | export class Landing extends Base {} 192 | export class List extends Base {} 193 | export class Markdown extends Base {} 194 | export class Min extends Base {} 195 | export class Nyan extends Base {} 196 | export class Progress extends Base { 197 | /** 198 | * @param options.open String used to indicate the start of the progress bar. 199 | * @param options.complete String used to indicate a complete test on the progress bar. 200 | * @param options.incomplete String used to indicate an incomplete test on the progress bar. 201 | * @param options.close String used to indicate the end of the progress bar. 202 | */ 203 | constructor(runner: IRunner, options?: { 204 | open?: string; 205 | complete?: string; 206 | incomplete?: string; 207 | close?: string; 208 | }); 209 | } 210 | export class Spec extends Base {} 211 | export class TAP extends Base {} 212 | export class XUnit extends Base { 213 | constructor(runner: IRunner, options?: any); 214 | } 215 | } 216 | } 217 | 218 | declare module "mocha" { 219 | export = Mocha; 220 | } 221 | -------------------------------------------------------------------------------- /typings/moment/moment.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for Moment.js 2.8.0 2 | // Project: https://github.com/timrwood/moment 3 | // Definitions by: Michael Lakerveld , Aaron King , Hiroki Horiuchi , Dick van den Brink , Adi Dahiya , Matt Brooks 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | 6 | declare module moment { 7 | 8 | interface MomentInput { 9 | /** Year */ 10 | years?: number; 11 | /** Year */ 12 | year?: number; 13 | /** Year */ 14 | y?: number; 15 | 16 | /** Month */ 17 | months?: number; 18 | /** Month */ 19 | month?: number; 20 | /** Month */ 21 | M?: number; 22 | 23 | /** Week */ 24 | weeks?: number; 25 | /** Week */ 26 | week?: number; 27 | /** Week */ 28 | w?: number; 29 | 30 | /** Day/Date */ 31 | days?: number; 32 | /** Day/Date */ 33 | day?: number; 34 | /** Day/Date */ 35 | date?: number; 36 | /** Day/Date */ 37 | d?: number; 38 | 39 | /** Hour */ 40 | hours?: number; 41 | /** Hour */ 42 | hour?: number; 43 | /** Hour */ 44 | h?: number; 45 | 46 | /** Minute */ 47 | minutes?: number; 48 | /** Minute */ 49 | minute?: number; 50 | /** Minute */ 51 | m?: number; 52 | 53 | /** Second */ 54 | seconds?: number; 55 | /** Second */ 56 | second?: number; 57 | /** Second */ 58 | s?: number; 59 | 60 | /** Millisecond */ 61 | milliseconds?: number; 62 | /** Millisecond */ 63 | millisecond?: number; 64 | /** Millisecond */ 65 | ms?: number; 66 | } 67 | 68 | interface Duration { 69 | humanize(withSuffix?: boolean): string; 70 | 71 | as(units: string): number; 72 | 73 | milliseconds(): number; 74 | asMilliseconds(): number; 75 | 76 | seconds(): number; 77 | asSeconds(): number; 78 | 79 | minutes(): number; 80 | asMinutes(): number; 81 | 82 | hours(): number; 83 | asHours(): number; 84 | 85 | days(): number; 86 | asDays(): number; 87 | 88 | months(): number; 89 | asMonths(): number; 90 | 91 | years(): number; 92 | asYears(): number; 93 | 94 | add(n: number, p: string): Duration; 95 | add(n: number): Duration; 96 | add(d: Duration): Duration; 97 | 98 | subtract(n: number, p: string): Duration; 99 | subtract(n: number): Duration; 100 | subtract(d: Duration): Duration; 101 | 102 | toISOString(): string; 103 | toJSON(): string; 104 | } 105 | 106 | interface Moment { 107 | format(format: string): string; 108 | format(): string; 109 | 110 | fromNow(withoutSuffix?: boolean): string; 111 | 112 | startOf(unitOfTime: string): Moment; 113 | endOf(unitOfTime: string): Moment; 114 | 115 | /** 116 | * Mutates the original moment by adding time. (deprecated in 2.8.0) 117 | * 118 | * @param unitOfTime the unit of time you want to add (eg "years" / "hours" etc) 119 | * @param amount the amount you want to add 120 | */ 121 | add(unitOfTime: string, amount: number): Moment; 122 | /** 123 | * Mutates the original moment by adding time. 124 | * 125 | * @param amount the amount you want to add 126 | * @param unitOfTime the unit of time you want to add (eg "years" / "hours" etc) 127 | */ 128 | add(amount: number, unitOfTime: string): Moment; 129 | /** 130 | * Mutates the original moment by adding time. Note that the order of arguments can be flipped. 131 | * 132 | * @param amount the amount you want to add 133 | * @param unitOfTime the unit of time you want to add (eg "years" / "hours" etc) 134 | */ 135 | add(amount: string, unitOfTime: string): Moment; 136 | /** 137 | * Mutates the original moment by adding time. 138 | * 139 | * @param objectLiteral an object literal that describes multiple time units {days:7,months:1} 140 | */ 141 | add(objectLiteral: MomentInput): Moment; 142 | /** 143 | * Mutates the original moment by adding time. 144 | * 145 | * @param duration a length of time 146 | */ 147 | add(duration: Duration): Moment; 148 | 149 | /** 150 | * Mutates the original moment by subtracting time. (deprecated in 2.8.0) 151 | * 152 | * @param unitOfTime the unit of time you want to subtract (eg "years" / "hours" etc) 153 | * @param amount the amount you want to subtract 154 | */ 155 | subtract(unitOfTime: string, amount: number): Moment; 156 | /** 157 | * Mutates the original moment by subtracting time. 158 | * 159 | * @param unitOfTime the unit of time you want to subtract (eg "years" / "hours" etc) 160 | * @param amount the amount you want to subtract 161 | */ 162 | subtract(amount: number, unitOfTime: string): Moment; 163 | /** 164 | * Mutates the original moment by subtracting time. Note that the order of arguments can be flipped. 165 | * 166 | * @param amount the amount you want to add 167 | * @param unitOfTime the unit of time you want to subtract (eg "years" / "hours" etc) 168 | */ 169 | subtract(amount: string, unitOfTime: string): Moment; 170 | /** 171 | * Mutates the original moment by subtracting time. 172 | * 173 | * @param objectLiteral an object literal that describes multiple time units {days:7,months:1} 174 | */ 175 | subtract(objectLiteral: MomentInput): Moment; 176 | /** 177 | * Mutates the original moment by subtracting time. 178 | * 179 | * @param duration a length of time 180 | */ 181 | subtract(duration: Duration): Moment; 182 | 183 | calendar(): string; 184 | calendar(start: Moment): string; 185 | calendar(start: Moment, formats: MomentCalendar): string; 186 | 187 | clone(): Moment; 188 | 189 | /** 190 | * @return Unix timestamp, or milliseconds since the epoch. 191 | */ 192 | valueOf(): number; 193 | 194 | local(): Moment; // current date/time in local mode 195 | 196 | utc(): Moment; // current date/time in UTC mode 197 | 198 | isValid(): boolean; 199 | invalidAt(): number; 200 | 201 | year(y: number): Moment; 202 | year(): number; 203 | quarter(): number; 204 | quarter(q: number): Moment; 205 | month(M: number): Moment; 206 | month(M: string): Moment; 207 | month(): number; 208 | day(d: number): Moment; 209 | day(d: string): Moment; 210 | day(): number; 211 | date(d: number): Moment; 212 | date(): number; 213 | hour(h: number): Moment; 214 | hour(): number; 215 | hours(h: number): Moment; 216 | hours(): number; 217 | minute(m: number): Moment; 218 | minute(): number; 219 | minutes(m: number): Moment; 220 | minutes(): number; 221 | second(s: number): Moment; 222 | second(): number; 223 | seconds(s: number): Moment; 224 | seconds(): number; 225 | millisecond(ms: number): Moment; 226 | millisecond(): number; 227 | milliseconds(ms: number): Moment; 228 | milliseconds(): number; 229 | weekday(): number; 230 | weekday(d: number): Moment; 231 | isoWeekday(): number; 232 | isoWeekday(d: number): Moment; 233 | weekYear(): number; 234 | weekYear(d: number): Moment; 235 | isoWeekYear(): number; 236 | isoWeekYear(d: number): Moment; 237 | week(): number; 238 | week(d: number): Moment; 239 | weeks(): number; 240 | weeks(d: number): Moment; 241 | isoWeek(): number; 242 | isoWeek(d: number): Moment; 243 | isoWeeks(): number; 244 | isoWeeks(d: number): Moment; 245 | weeksInYear(): number; 246 | isoWeeksInYear(): number; 247 | dayOfYear(): number; 248 | dayOfYear(d: number): Moment; 249 | 250 | from(f: Moment|string|number|Date|number[], suffix?: boolean): string; 251 | to(f: Moment|string|number|Date|number[], suffix?: boolean): string; 252 | toNow(withoutPrefix?: boolean): string; 253 | 254 | diff(b: Moment): number; 255 | diff(b: Moment, unitOfTime: string): number; 256 | diff(b: Moment, unitOfTime: string, round: boolean): number; 257 | 258 | toArray(): number[]; 259 | toDate(): Date; 260 | toISOString(): string; 261 | toJSON(): string; 262 | unix(): number; 263 | 264 | isLeapYear(): boolean; 265 | zone(): number; 266 | zone(b: number): Moment; 267 | zone(b: string): Moment; 268 | utcOffset(): number; 269 | utcOffset(b: number): Moment; 270 | utcOffset(b: string): Moment; 271 | daysInMonth(): number; 272 | isDST(): boolean; 273 | 274 | isBefore(): boolean; 275 | isBefore(b: Moment|string|number|Date|number[], granularity?: string): boolean; 276 | 277 | isAfter(): boolean; 278 | isAfter(b: Moment|string|number|Date|number[], granularity?: string): boolean; 279 | 280 | isSame(b: Moment|string|number|Date|number[], granularity?: string): boolean; 281 | isBetween(a: Moment|string|number|Date|number[], b: Moment|string|number|Date|number[], granularity?: string): boolean; 282 | 283 | // Deprecated as of 2.8.0. 284 | lang(language: string): Moment; 285 | lang(reset: boolean): Moment; 286 | lang(): MomentLanguage; 287 | 288 | locale(language: string): Moment; 289 | locale(reset: boolean): Moment; 290 | locale(): string; 291 | 292 | localeData(language: string): Moment; 293 | localeData(reset: boolean): Moment; 294 | localeData(): MomentLanguage; 295 | 296 | // Deprecated as of 2.7.0. 297 | max(date: Moment|string|number|Date|any[]): Moment; 298 | max(date: string, format: string): Moment; 299 | 300 | // Deprecated as of 2.7.0. 301 | min(date: Moment|string|number|Date|any[]): Moment; 302 | min(date: string, format: string): Moment; 303 | 304 | get(unit: string): number; 305 | set(unit: string, value: number): Moment; 306 | set(objectLiteral: MomentInput): Moment; 307 | } 308 | 309 | type formatFunction = () => string; 310 | 311 | interface MomentCalendar { 312 | lastDay?: string | formatFunction; 313 | sameDay?: string | formatFunction; 314 | nextDay?: string | formatFunction; 315 | lastWeek?: string | formatFunction; 316 | nextWeek?: string | formatFunction; 317 | sameElse?: string | formatFunction; 318 | } 319 | 320 | interface BaseMomentLanguage { 321 | months ?: any; 322 | monthsShort ?: any; 323 | weekdays ?: any; 324 | weekdaysShort ?: any; 325 | weekdaysMin ?: any; 326 | relativeTime ?: MomentRelativeTime; 327 | meridiem ?: (hour: number, minute: number, isLowercase: boolean) => string; 328 | calendar ?: MomentCalendar; 329 | ordinal ?: (num: number) => string; 330 | } 331 | 332 | interface MomentLanguage extends BaseMomentLanguage { 333 | longDateFormat?: MomentLongDateFormat; 334 | } 335 | 336 | interface MomentLanguageData extends BaseMomentLanguage { 337 | /** 338 | * @param formatType should be L, LL, LLL, LLLL. 339 | */ 340 | longDateFormat(formatType: string): string; 341 | } 342 | 343 | interface MomentLongDateFormat { 344 | L: string; 345 | LL: string; 346 | LLL: string; 347 | LLLL: string; 348 | LT: string; 349 | LTS: string; 350 | l?: string; 351 | ll?: string; 352 | lll?: string; 353 | llll?: string; 354 | lt?: string; 355 | lts?: string; 356 | } 357 | 358 | interface MomentRelativeTime { 359 | future: any; 360 | past: any; 361 | s: any; 362 | m: any; 363 | mm: any; 364 | h: any; 365 | hh: any; 366 | d: any; 367 | dd: any; 368 | M: any; 369 | MM: any; 370 | y: any; 371 | yy: any; 372 | } 373 | 374 | interface MomentStatic { 375 | version: string; 376 | fn: Moment; 377 | 378 | (): Moment; 379 | (date: number): Moment; 380 | (date: number[]): Moment; 381 | (date: string, format?: string, strict?: boolean): Moment; 382 | (date: string, format?: string, language?: string, strict?: boolean): Moment; 383 | (date: string, formats: string[], strict?: boolean): Moment; 384 | (date: string, formats: string[], language?: string, strict?: boolean): Moment; 385 | (date: string, specialFormat: () => void, strict?: boolean): Moment; 386 | (date: string, specialFormat: () => void, language?: string, strict?: boolean): Moment; 387 | (date: string, formatsIncludingSpecial: any[], strict?: boolean): Moment; 388 | (date: string, formatsIncludingSpecial: any[], language?: string, strict?: boolean): Moment; 389 | (date: Date): Moment; 390 | (date: Moment): Moment; 391 | (date: Object): Moment; 392 | 393 | utc(): Moment; 394 | utc(date: number): Moment; 395 | utc(date: number[]): Moment; 396 | utc(date: string, format?: string, strict?: boolean): Moment; 397 | utc(date: string, format?: string, language?: string, strict?: boolean): Moment; 398 | utc(date: string, formats: string[], strict?: boolean): Moment; 399 | utc(date: string, formats: string[], language?: string, strict?: boolean): Moment; 400 | utc(date: Date): Moment; 401 | utc(date: Moment): Moment; 402 | utc(date: Object): Moment; 403 | 404 | unix(timestamp: number): Moment; 405 | 406 | invalid(parsingFlags?: Object): Moment; 407 | isMoment(): boolean; 408 | isMoment(m: any): boolean; 409 | isDate(m: any): boolean; 410 | isDuration(): boolean; 411 | isDuration(d: any): boolean; 412 | 413 | // Deprecated in 2.8.0. 414 | lang(language?: string): string; 415 | lang(language?: string, definition?: MomentLanguage): string; 416 | 417 | locale(language?: string): string; 418 | locale(language?: string[]): string; 419 | locale(language?: string, definition?: MomentLanguage): string; 420 | 421 | localeData(language?: string): MomentLanguageData; 422 | 423 | longDateFormat: any; 424 | relativeTime: any; 425 | meridiem: (hour: number, minute: number, isLowercase: boolean) => string; 426 | calendar: any; 427 | ordinal: (num: number) => string; 428 | 429 | duration(milliseconds: Number): Duration; 430 | duration(num: Number, unitOfTime: string): Duration; 431 | duration(input: MomentInput): Duration; 432 | duration(object: any): Duration; 433 | duration(): Duration; 434 | 435 | parseZone(date: string): Moment; 436 | 437 | months(): string[]; 438 | months(index: number): string; 439 | months(format: string): string[]; 440 | months(format: string, index: number): string; 441 | monthsShort(): string[]; 442 | monthsShort(index: number): string; 443 | monthsShort(format: string): string[]; 444 | monthsShort(format: string, index: number): string; 445 | 446 | weekdays(): string[]; 447 | weekdays(index: number): string; 448 | weekdays(format: string): string[]; 449 | weekdays(format: string, index: number): string; 450 | weekdaysShort(): string[]; 451 | weekdaysShort(index: number): string; 452 | weekdaysShort(format: string): string[]; 453 | weekdaysShort(format: string, index: number): string; 454 | weekdaysMin(): string[]; 455 | weekdaysMin(index: number): string; 456 | weekdaysMin(format: string): string[]; 457 | weekdaysMin(format: string, index: number): string; 458 | 459 | min(...moments: Moment[]): Moment; 460 | max(...moments: Moment[]): Moment; 461 | 462 | normalizeUnits(unit: string): string; 463 | relativeTimeThreshold(threshold: string): number|boolean; 464 | relativeTimeThreshold(threshold: string, limit:number): boolean; 465 | 466 | /** 467 | * Constant used to enable explicit ISO_8601 format parsing. 468 | */ 469 | ISO_8601(): void; 470 | 471 | defaultFormat: string; 472 | } 473 | 474 | } 475 | 476 | declare module 'moment' { 477 | var moment: moment.MomentStatic; 478 | export = moment; 479 | } 480 | -------------------------------------------------------------------------------- /typings/requirejs/requirejs.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for RequireJS 2.1.20 2 | // Project: http://requirejs.org/ 3 | // Definitions by: Josh Baldwin 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | 6 | /* 7 | require-2.1.8.d.ts may be freely distributed under the MIT license. 8 | 9 | Copyright (c) 2013 Josh Baldwin https://github.com/jbaldwin/require.d.ts 10 | 11 | Permission is hereby granted, free of charge, to any person 12 | obtaining a copy of this software and associated documentation 13 | files (the "Software"), to deal in the Software without 14 | restriction, including without limitation the rights to use, 15 | copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | copies of the Software, and to permit persons to whom the 17 | Software is furnished to do so, subject to the following conditions: 18 | 19 | The above copyright notice and this permission notice shall be 20 | included in all copies or substantial portions of the Software. 21 | 22 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 23 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 24 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 25 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 26 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 27 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 29 | OTHER DEALINGS IN THE SOFTWARE. 30 | */ 31 | 32 | declare module 'module' { 33 | var mod: { 34 | config: () => any; 35 | id: string; 36 | uri: string; 37 | } 38 | export = mod; 39 | } 40 | 41 | interface RequireError extends Error { 42 | 43 | /** 44 | * The error ID that maps to an ID on a web page. 45 | **/ 46 | requireType: string; 47 | 48 | /** 49 | * Required modules. 50 | **/ 51 | requireModules: string[]; 52 | 53 | /** 54 | * The original error, if there is one (might be null). 55 | **/ 56 | originalError: Error; 57 | } 58 | 59 | interface RequireShim { 60 | 61 | /** 62 | * List of dependencies. 63 | **/ 64 | deps?: string[]; 65 | 66 | /** 67 | * Name the module will be exported as. 68 | **/ 69 | exports?: string; 70 | 71 | /** 72 | * Initialize function with all dependcies passed in, 73 | * if the function returns a value then that value is used 74 | * as the module export value instead of the object 75 | * found via the 'exports' string. 76 | * @param dependencies 77 | * @return 78 | **/ 79 | init?: (...dependencies: any[]) => any; 80 | } 81 | 82 | interface RequireConfig { 83 | 84 | // The root path to use for all module lookups. 85 | baseUrl?: string; 86 | 87 | // Path mappings for module names not found directly under 88 | // baseUrl. 89 | paths?: { [key: string]: any; }; 90 | 91 | 92 | // Dictionary of Shim's. 93 | // does not cover case of key->string[] 94 | shim?: { [key: string]: RequireShim; }; 95 | 96 | /** 97 | * For the given module prefix, instead of loading the 98 | * module with the given ID, substitude a different 99 | * module ID. 100 | * 101 | * @example 102 | * requirejs.config({ 103 | * map: { 104 | * 'some/newmodule': { 105 | * 'foo': 'foo1.2' 106 | * }, 107 | * 'some/oldmodule': { 108 | * 'foo': 'foo1.0' 109 | * } 110 | * } 111 | * }); 112 | **/ 113 | map?: { 114 | [id: string]: { 115 | [id: string]: string; 116 | }; 117 | }; 118 | 119 | /** 120 | * Allows pointing multiple module IDs to a module ID that contains a bundle of modules. 121 | * 122 | * @example 123 | * requirejs.config({ 124 | * bundles: { 125 | * 'primary': ['main', 'util', 'text', 'text!template.html'], 126 | * 'secondary': ['text!secondary.html'] 127 | * } 128 | * }); 129 | **/ 130 | bundles?: { [key: string]: string[]; }; 131 | 132 | /** 133 | * AMD configurations, use module.config() to access in 134 | * define() functions 135 | **/ 136 | config?: { [id: string]: {}; }; 137 | 138 | /** 139 | * Configures loading modules from CommonJS packages. 140 | **/ 141 | packages?: {}; 142 | 143 | /** 144 | * The number of seconds to wait before giving up on loading 145 | * a script. The default is 7 seconds. 146 | **/ 147 | waitSeconds?: number; 148 | 149 | /** 150 | * A name to give to a loading context. This allows require.js 151 | * to load multiple versions of modules in a page, as long as 152 | * each top-level require call specifies a unique context string. 153 | **/ 154 | context?: string; 155 | 156 | /** 157 | * An array of dependencies to load. 158 | **/ 159 | deps?: string[]; 160 | 161 | /** 162 | * A function to pass to require that should be require after 163 | * deps have been loaded. 164 | * @param modules 165 | **/ 166 | callback?: (...modules: any[]) => void; 167 | 168 | /** 169 | * If set to true, an error will be thrown if a script loads 170 | * that does not call define() or have shim exports string 171 | * value that can be checked. 172 | **/ 173 | enforceDefine?: boolean; 174 | 175 | /** 176 | * If set to true, document.createElementNS() will be used 177 | * to create script elements. 178 | **/ 179 | xhtml?: boolean; 180 | 181 | /** 182 | * Extra query string arguments appended to URLs that RequireJS 183 | * uses to fetch resources. Most useful to cache bust when 184 | * the browser or server is not configured correctly. 185 | * 186 | * @example 187 | * urlArgs: "bust= + (new Date()).getTime() 188 | **/ 189 | urlArgs?: string; 190 | 191 | /** 192 | * Specify the value for the type="" attribute used for script 193 | * tags inserted into the document by RequireJS. Default is 194 | * "text/javascript". To use Firefox's JavasScript 1.8 195 | * features, use "text/javascript;version=1.8". 196 | **/ 197 | scriptType?: string; 198 | 199 | /** 200 | * If set to true, skips the data-main attribute scanning done 201 | * to start module loading. Useful if RequireJS is embedded in 202 | * a utility library that may interact with other RequireJS 203 | * library on the page, and the embedded version should not do 204 | * data-main loading. 205 | **/ 206 | skipDataMain?: boolean; 207 | 208 | /** 209 | * Allow extending requirejs to support Subresource Integrity 210 | * (SRI). 211 | **/ 212 | onNodeCreated?: (node: HTMLScriptElement, config: RequireConfig, moduleName: string, url: string) => void; 213 | } 214 | 215 | // todo: not sure what to do with this guy 216 | interface RequireModule { 217 | 218 | /** 219 | * 220 | **/ 221 | config(): {}; 222 | 223 | } 224 | 225 | /** 226 | * 227 | **/ 228 | interface RequireMap { 229 | 230 | /** 231 | * 232 | **/ 233 | prefix: string; 234 | 235 | /** 236 | * 237 | **/ 238 | name: string; 239 | 240 | /** 241 | * 242 | **/ 243 | parentMap: RequireMap; 244 | 245 | /** 246 | * 247 | **/ 248 | url: string; 249 | 250 | /** 251 | * 252 | **/ 253 | originalName: string; 254 | 255 | /** 256 | * 257 | **/ 258 | fullName: string; 259 | } 260 | 261 | interface Require { 262 | 263 | /** 264 | * Configure require.js 265 | **/ 266 | config(config: RequireConfig): Require; 267 | 268 | /** 269 | * CommonJS require call 270 | * @param module Module to load 271 | * @return The loaded module 272 | */ 273 | (module: string): any; 274 | 275 | /** 276 | * Start the main app logic. 277 | * Callback is optional. 278 | * Can alternatively use deps and callback. 279 | * @param modules Required modules to load. 280 | **/ 281 | (modules: string[]): void; 282 | 283 | /** 284 | * @see Require() 285 | * @param ready Called when required modules are ready. 286 | **/ 287 | (modules: string[], ready: Function): void; 288 | 289 | /** 290 | * @see http://requirejs.org/docs/api.html#errbacks 291 | * @param ready Called when required modules are ready. 292 | **/ 293 | (modules: string[], ready: Function, errback: Function): void; 294 | 295 | /** 296 | * Generate URLs from require module 297 | * @param module Module to URL 298 | * @return URL string 299 | **/ 300 | toUrl(module: string): string; 301 | 302 | /** 303 | * Returns true if the module has already been loaded and defined. 304 | * @param module Module to check 305 | **/ 306 | defined(module: string): boolean; 307 | 308 | /** 309 | * Returns true if the module has already been requested or is in the process of loading and should be available at some point. 310 | * @param module Module to check 311 | **/ 312 | specified(module: string): boolean; 313 | 314 | /** 315 | * On Error override 316 | * @param err 317 | **/ 318 | onError(err: RequireError, errback?: (err: RequireError) => void): void; 319 | 320 | /** 321 | * Undefine a module 322 | * @param module Module to undefine. 323 | **/ 324 | undef(module: string): void; 325 | 326 | /** 327 | * Semi-private function, overload in special instance of undef() 328 | **/ 329 | onResourceLoad(context: Object, map: RequireMap, depArray: RequireMap[]): void; 330 | } 331 | 332 | interface RequireDefine { 333 | 334 | /** 335 | * Define Simple Name/Value Pairs 336 | * @param config Dictionary of Named/Value pairs for the config. 337 | **/ 338 | (config: { [key: string]: any; }): void; 339 | 340 | /** 341 | * Define function. 342 | * @param func: The function module. 343 | **/ 344 | (func: () => any): void; 345 | 346 | /** 347 | * Define function with dependencies. 348 | * @param deps List of dependencies module IDs. 349 | * @param ready Callback function when the dependencies are loaded. 350 | * callback param deps module dependencies 351 | * callback return module definition 352 | **/ 353 | (deps: string[], ready: Function): void; 354 | 355 | /** 356 | * Define module with simplified CommonJS wrapper. 357 | * @param ready 358 | * callback require requirejs instance 359 | * callback exports exports object 360 | * callback module module 361 | * callback return module definition 362 | **/ 363 | (ready: (require: Require, exports: { [key: string]: any; }, module: RequireModule) => any): void; 364 | 365 | /** 366 | * Define a module with a name and dependencies. 367 | * @param name The name of the module. 368 | * @param deps List of dependencies module IDs. 369 | * @param ready Callback function when the dependencies are loaded. 370 | * callback deps module dependencies 371 | * callback return module definition 372 | **/ 373 | (name: string, deps: string[], ready: Function): void; 374 | 375 | /** 376 | * Define a module with a name. 377 | * @param name The name of the module. 378 | * @param ready Callback function when the dependencies are loaded. 379 | * callback return module definition 380 | **/ 381 | (name: string, ready: Function): void; 382 | 383 | /** 384 | * Used to allow a clear indicator that a global define function (as needed for script src browser loading) conforms 385 | * to the AMD API, any global define function SHOULD have a property called "amd" whose value is an object. 386 | * This helps avoid conflict with any other existing JavaScript code that could have defined a define() function 387 | * that does not conform to the AMD API. 388 | * define.amd.jQuery is specific to jQuery and indicates that the loader is able to account for multiple version 389 | * of jQuery being loaded simultaneously. 390 | */ 391 | amd: Object; 392 | } 393 | 394 | // Ambient declarations for 'require' and 'define' 395 | declare var requirejs: Require; 396 | declare var require: Require; 397 | declare var define: RequireDefine; 398 | --------------------------------------------------------------------------------