diff --git a/js/amd-public-path.js b/js/amd-public-path.js new file mode 100644 index 00000000..e03476a0 --- /dev/null +++ b/js/amd-public-path.js @@ -0,0 +1,8 @@ +// In an AMD module, we set the public path using the magic requirejs 'module' dependency +// See https://github.com/requirejs/requirejs/wiki/Differences-between-the-simplified-CommonJS-wrapper-and-standard-AMD-define#module +// Since 'module' is a requirejs magic module, we must include 'module' in the webpack externals configuration. +var module = require('module'); +var url = new URL(module.uri, document.location); +// Using lastIndexOf('/')+1 gives us the empty string if there is no '/', so pathname becomes '/' +url.pathname = url.pathname.slice(0,url.pathname.lastIndexOf('/')+1); +__webpack_public_path__ = `${url.origin}${url.pathname}`; diff --git a/js/package.json b/js/package.json index 91917399..310b703f 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "jupyter-threejs", - "version": "2.4.0", + "version": "2.4.1", "description": "jupyter - threejs bridge", "keywords": [ "jupyterlab", diff --git a/js/src/_base/Renderable.js b/js/src/_base/Renderable.js index 38e67d02..680d101e 100644 --- a/js/src/_base/Renderable.js +++ b/js/src/_base/Renderable.js @@ -197,8 +197,8 @@ class RenderableView extends widgets.DOMWidgetView { } } - processPhosphorMessage(msg) { - widgets.DOMWidgetView.prototype.processPhosphorMessage.call(this, msg); + _processLuminoMessage(msg, _super) { + _super.call(this, msg); switch (msg.type) { case 'after-attach': this.el.addEventListener('contextmenu', this, true); @@ -209,6 +209,14 @@ class RenderableView extends widgets.DOMWidgetView { } } + processPhosphorMessage(msg) { + this._processLuminoMessage(msg, widgets.DOMWidgetView.prototype.processPhosphorMessage); + } + + processLuminoMessage(msg) { + this._processLuminoMessage(msg, widgets.DOMWidgetView.prototype.processLuminoMessage); + } + handleEvent(event) { switch (event.type) { case 'contextmenu': diff --git a/js/src/extension.js b/js/src/extension.js index ffcc2e3b..4ddf6199 100644 --- a/js/src/extension.js +++ b/js/src/extension.js @@ -1,12 +1,4 @@ // Entry point for the notebook bundle containing custom model definitions. -// -// Setup notebook base URL -// -// Some static assets may be required by the custom widget javascript. The base -// url for the notebook is not known at build time and is therefore computed -// dynamically. -__webpack_public_path__ = document.querySelector('body').getAttribute('data-base-url') + 'nbextensions/jupyter-threejs/'; - // Configure requirejs if (window.requirejs) { diff --git a/js/webpack.config.js b/js/webpack.config.js index b81b6deb..650b16b6 100644 --- a/js/webpack.config.js +++ b/js/webpack.config.js @@ -1,6 +1,6 @@ const path = require('path'); -const externals = ['@jupyter-widgets/base', 'three']; +const externals = ['@jupyter-widgets/base', 'three', 'module']; module.exports = [ { @@ -17,11 +17,12 @@ module.exports = [ }, { // jupyter-threejs bundle for the notebook - entry: './src/index.js', + entry: ['./amd-public-path.js', './src/index.js'], output: { filename: 'index.js', path: path.resolve(__dirname, '..', 'pythreejs', 'static'), - libraryTarget: 'amd' + libraryTarget: 'amd', + publicPath: '', // Set in amd-public-path.js }, devtool: 'source-map', externals: externals, @@ -32,14 +33,15 @@ module.exports = [ }, { // embeddable jupyter-threejs bundle (e.g. for docs) - entry: './src/index.js', + entry: ['./amd-public-path.js', './src/index.js'], output: { filename: 'index.js', path: path.resolve(__dirname, 'dist'), library: 'jupyter-threejs', - libraryTarget: 'amd' + libraryTarget: 'amd', + publicPath: '', // Set in amd-public-path.js }, - externals: ['@jupyter-widgets/base'], + externals: ['@jupyter-widgets/base', 'module'], resolve: { extensions: [ '.autogen.js', '.js' ] }, diff --git a/pythreejs/_version.py b/pythreejs/_version.py index 5373fc84..64636cdf 100644 --- a/pythreejs/_version.py +++ b/pythreejs/_version.py @@ -1,4 +1,4 @@ -version_info = (2, 4, 1, 'final') +version_info = (2, 4, 3, 'dev') _specifier_ = {'alpha': 'a', 'beta': 'b', 'candidate': 'rc', 'final': '', 'dev': 'dev'} @@ -20,4 +20,4 @@ # the widget models, or if the serialized format changes. # # The major version needs to match that of the JS package. -EXTENSION_SPEC_VERSION = '^2.1.0' +EXTENSION_SPEC_VERSION = '^2.4.1' diff --git a/setupbase.py b/setupbase.py index 13c926b1..44a02aa2 100644 --- a/setupbase.py +++ b/setupbase.py @@ -659,7 +659,7 @@ def _translate_glob(pat): translated_parts.append(_translate_glob_part(part)) os_sep_class = '[%s]' % re.escape(SEPARATORS) res = _join_translated(translated_parts, os_sep_class) - return '{res}\\Z(?ms)'.format(res=res) + return '(?ms){res}\\Z'.format(res=res) def _join_translated(translated_parts, os_sep_class):