Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embedding not working from CDN #171

Closed
maartenbreddels opened this issue Mar 26, 2018 · 11 comments
Closed

Embedding not working from CDN #171

maartenbreddels opened this issue Mar 26, 2018 · 11 comments

Comments

@maartenbreddels
Copy link
Member

If I create a html page using a snippet generated from the the notebook using 'embed widget' menu item, that will not work:

embed-amd.js:198996 Uncaught (in promise) TypeError: Cannot read property 'BoxGeometryModel' of undefined
    at embed-amd.js:198996

The modules resolved to undefined :(

If I put jupyter-threejs.js used on readthedocs in the same directory, it does work, so I'm not sure what is wrong with the CDN version

@vidartf
Copy link
Member

vidartf commented Mar 28, 2018

What is the line that fails? Something like require(...)? If so, what is the ... arguments, and what is the source of the require function?

@maartenbreddels
Copy link
Member Author

https://github.com/jupyter-widgets/ipywidgets/blob/377594cb6f835d2c4ff3b7eb067f9868f7ff8f80/packages/html-manager/src/htmlmanager.ts#L77 module is undefined here. I tried debugging it, but have no idea how that is possible.

@maartenbreddels
Copy link
Member Author

(btw, it's the line below that gives the exception)

@vidartf
Copy link
Member

vidartf commented Mar 28, 2018

If you debug this line: https://github.com/jupyter-widgets/ipywidgets/blob/377594cb6f835d2c4ff3b7eb067f9868f7ff8f80/packages/html-manager/src/htmlmanager.ts#L73

What is the loader? Could you step into it until it does a require call?

@maartenbreddels
Copy link
Member Author

loader is requireLoader, and it does do a request, that all goes fine, request leads tot a 200 status code, really confusing.

@maartenbreddels
Copy link
Member Author

This is the html btw:

<html><head>


<!-- Load require.js. Delete this if your page already loads require.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" crossorigin="anonymous"></script>
<!--<script src="jupyter-three.js"></script>-->
<script src="embed-amd.js"></script>
<script type="application/vnd.jupyter.widget-state+json">
{
    "version_major": 2,
    "version_minor": 0,
    "state": {
        "ec9dc4ad96864404b1e52bd144988b9a": {
            "model_name": "BoxGeometryModel",
            "model_module": "jupyter-threejs",
            "model_module_version": "~1.0.0",
            "state": {
                "_model_module_version": "~1.0.0",
                "_view_module": null,
                "_view_module_version": "",
                "depth": 15,
                "depthSegments": 15,
                "height": 10,
                "heightSegments": 10,
                "width": 5,
                "widthSegments": 5
            }
        },
        "2e11356c28e54a91b54cb2f119e3a1cd": {
            "model_name": "LayoutModel",
            "model_module": "@jupyter-widgets/base",
            "model_module_version": "1.0.0",
            "state": {}
        },
        "18f9305f97db4bcc819b3a0abc7ba1ea": {
            "model_name": "WebGLShadowMapModel",
            "model_module": "jupyter-threejs",
            "model_module_version": "~1.0.0",
            "state": {
                "_model_module_version": "~1.0.0",
                "_view_module": null,
                "_view_module_version": ""
            }
        },
        "87adeb97400e48c5bc59a32afbef6faa": {
            "model_name": "PreviewModel",
            "model_module": "jupyter-threejs",
            "model_module_version": "~1.0.0",
            "state": {
                "_model_module_version": "~1.0.0",
                "_view_module_version": "~1.0.0",
                "child": "IPY_MODEL_ec9dc4ad96864404b1e52bd144988b9a",
                "layout": "IPY_MODEL_2e11356c28e54a91b54cb2f119e3a1cd",
                "shadowMap": "IPY_MODEL_18f9305f97db4bcc819b3a0abc7ba1ea"
            }
        }
    }
}
</script>
</head>
<body>

<script type="application/vnd.jupyter.widget-view+json">
{
    "version_major": 2,
    "version_minor": 0,
    "model_id": "87adeb97400e48c5bc59a32afbef6faa"
}
</script>

</body>
</html>

@vidartf
Copy link
Member

vidartf commented Mar 28, 2018

I think the problem is that requirejs is not built to take an URL as an argument. It works, but it's not how it is meant to be used, and it fails as pythreejs is exported as a named library (define(name, deps, factory)). I think ipywidgets should maybe do this when falling pack to CDN:

requirejs.config({
    paths: {
        moduleName: moduleNameToCDNUrl(moduleName, moduleVersion)
    }
});

@maartenbreddels
Copy link
Member Author

Any idea why that only happens to pythreejs?

@vidartf
Copy link
Member

vidartf commented Mar 28, 2018 via email

@vidartf
Copy link
Member

vidartf commented Jun 7, 2018

Having upstreamed the fix, which was accepted and released I will close this issue now.

@vidartf vidartf closed this as completed Jun 7, 2018
@maartenbreddels
Copy link
Member Author

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants