Skip to content

Commit

Permalink
fix the extension registration (#7679)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariusz Jurowicz authored and LeeTZ committed Jul 12, 2018
1 parent 343f503 commit c04239e
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 40 deletions.
45 changes: 45 additions & 0 deletions js/notebook/src/extension.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright 2017 TWO SIGMA OPEN SOURCE, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// This file contains the javascript that is run when the notebook is loaded.
// It contains some requirejs configuration and the `load_ipython_extension`
// which is required for any notebook extension.

// Configure requirejs
if (window.require) {
window.require.config({
map: {
"*": {
"beakerx": "nbextensions/beakerx/index",
"jupyter-js-widgets": "nbextensions/jupyter-js-widgets/extension",
"@jupyter-widgets/base": "nbextensions/jupyter-js-widgets/extension",
"@jupyter-widgets/controls": "nbextensions/jupyter-js-widgets/extension"
}
}
});
}

__webpack_public_path__ = document.querySelector('body').getAttribute('data-base-url') + 'nbextensions/beakerx/';

var extension = require('./extension/index').default;

define([], function () {
"use strict";

return {
load_ipython_extension: extension.load_ipython_extension
};
});
61 changes: 22 additions & 39 deletions js/notebook/src/extension.ts → js/notebook/src/extension/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,48 +18,31 @@
// It contains some requirejs configuration and the `load_ipython_extension`
// which is required for any notebook extension.

/// <reference path='./types/index.d.ts'/>

"use strict";

// Configure requirejs
if (window.require) {
window.require.config({
map: {
"*": {
"beakerx": "nbextensions/beakerx/index",
"jupyter-js-widgets": "nbextensions/jupyter-js-widgets/extension",
"@jupyter-widgets/base": "nbextensions/jupyter-js-widgets/extension",
"@jupyter-widgets/controls": "nbextensions/jupyter-js-widgets/extension"
}
}
});
}

__webpack_public_path__ = `${document.querySelector('body').getAttribute('data-base-url')}nbextensions/beakerx/`;

import {registerFeature} from './extension/UIOptionsHelper';
import {enableInitializationCellsFeature} from './extension/initializationCells';
import {GroovyMode} from './extension/groovyModeExtension';
import {Autotranslation} from './extension/autotranslation';
import {BeakerXKernel} from './extension/kernel';
import {displayHTML as htmlOutput} from './htmlOutput/htmlOutput';
import bkCoreManager from './shared/bkCoreManager';

import './shared/style/beakerx.scss';
import './plot/bko-combinedplot.css';
import './plot/bko-plot.css';
import './extension/dataBrowser/dataBrowser.css';
import './extension/tableOfContents/toc.css';
/// <reference path='../types/index.d.ts'/>

import {extendHighlightModes, extendWithLineComment} from "./codeEditor";
import {registerFeature} from './UIOptionsHelper';
import {enableInitializationCellsFeature} from './initializationCells';
import {Autotranslation} from './autotranslation';
import {BeakerXKernel} from './kernel';
import {displayHTML} from '../htmlOutput/htmlOutput';
import {GroovyMode} from "./groovyModeExtension";
import bkCoreManager from '../shared/bkCoreManager';

import '../shared/style/beakerx.scss';
import '../plot/bko-combinedplot.css';
import '../plot/bko-plot.css';
import './dataBrowser/dataBrowser.css';
import './tableOfContents/toc.css';

const configmod = require('services/config');
const comm = require('services/kernels/comm');
const utils = require('base/js/utils');
const Jupyter = require('base/js/namespace');
const events = require('base/js/events');
const plotApi = require('./plot/plotApi');
const plotApi = require('../plot/plotApi');
const big = require('big.js');
const tocUtils = require('./extension/tableOfContents/index');
const tocUtils = require('./tableOfContents/index');

window['Big'] = big;

Expand Down Expand Up @@ -90,7 +73,7 @@ function extendWindowObject() {
const bkObject = bkApp.getBeakerObject();
const beakerxInstance = {
...plotApiList,
...htmlOutput,
displayHTML,
prefs: bkObject.beakerObj.prefs
};

Expand Down Expand Up @@ -119,11 +102,11 @@ function setupNotebook() {
GroovyMode.extendWithLineComment(Jupyter, CodeMirror);
}

function load_ipython_extension() {
export const load_ipython_extension = () => {
extendWindowObject();
setupNotebook();
}
};

export default {
load_ipython_extension
};
}
2 changes: 1 addition & 1 deletion js/notebook/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ module.exports = [
// "load_ipython_extension" function which is required for any notebook
// extension.
//
entry: './src/extension.ts',
entry: './src/extension.js',
output: {
filename: 'extension.js',
path: path.resolve(__dirname, '../../beakerx/beakerx/static'),
Expand Down

0 comments on commit c04239e

Please sign in to comment.