Skip to content

Commit

Permalink
Don't define/require under nbextension prefix (#382)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpsievert authored Feb 9, 2022
1 parent 7241fa3 commit 5acd121
Show file tree
Hide file tree
Showing 13 changed files with 1,792 additions and 334 deletions.
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,19 @@
"@types/webpack-env": "*"
},
"devDependencies": {
"filemanager-webpack-plugin": "^6.1.7",
"prettier": "^2.5.1",
"typescript": "^4.5.5",
"ts-loader": "^9.2.6",
"webpack": "^5.68.0",
"webpack-cli": "^4.9.2"
},
"private": true
"files": [
"dist",
"src",
"package.json",
"tsconfig.json",
"webpack.config.js",
"yarn.lock"
]
}
20 changes: 20 additions & 0 deletions src/extension.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// 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.
//
// 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-vega';


// Configure requirejs
if (window.require) {
window.require.config({
map: {
"*": {
"jupyter-vega": "nbextensions/jupyter-vega/index",
}
}
});
}
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,5 @@ export function render(
})
.catch((error) => showError(el, error));
}

export * from "./widget";
32 changes: 32 additions & 0 deletions src/vega.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const spec = {spec};
const opt = {opt};
const type = "{type}";
const id = "{id}";

const output_area = this;

require(["jupyter-vega"], function(vega) {{
const target = document.createElement("div");
target.id = id;
target.className = "vega-embed";

const style = document.createElement("style");
style.textContent = [
".vega-embed .error p {{",
" color: firebrick;",
" font-size: 14px;",
"}}",
].join("\\n");

// element is a jQuery wrapped DOM element inside the output area
// see http://ipython.readthedocs.io/en/stable/api/generated/\
// IPython.display.html#IPython.display.Javascript.__init__
element[0].appendChild(target);
element[0].appendChild(style);

vega.render("#" + id, spec, type, opt, output_area);
}}, function (err) {{
if (err.requireType !== "scripterror") {{
throw(err);
}}
}});
20 changes: 20 additions & 0 deletions vega/static/extension.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// 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.
//
// 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-vega';


// Configure requirejs
if (window.require) {
window.require.config({
map: {
"*": {
"jupyter-vega": "nbextensions/jupyter-vega/index",
}
}
});
}
2 changes: 1 addition & 1 deletion vega/static/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion vega/static/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion vega/static/vega.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const id = "{id}";

const output_area = this;

require(["nbextensions/jupyter-vega/index"], function(vega) {{
require(["jupyter-vega"], function(vega) {{
const target = document.createElement("div");
target.id = id;
target.className = "vega-embed";
Expand Down
2 changes: 1 addition & 1 deletion vega/static/widget.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vega/static/widget.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5acd121

Please sign in to comment.