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

'window is not defined' workaround #44

Closed
toniengelhardt opened this issue Jul 29, 2020 · 4 comments
Closed

'window is not defined' workaround #44

toniengelhardt opened this issue Jul 29, 2020 · 4 comments

Comments

@toniengelhardt
Copy link

I'm trying to get annotorious to work in Wix Corvid engine, but it seems that only importing the module already results in an attempt to access the window object, is there a workaround for that?

This is the code:

import { Annotorious } from '@recogito/annotorious';  

// The import above accesses window and throws an error since window is not available directly, or at least that's what I think...

// $w.onReady(function () {
//   const anno = new Annotorious({
//     image: $w("Image"),
//   });
// });

And this is the error:

console.js:35 There was an error in your script
e.<computed> @ console.js:35
console.js:35 ReferenceError: window is not defined
    at Object.1 (https://c4a8074e-f162-4306-9f5a-9efe29718b05.static.pub.wix-code.com/static/v2/822b9d6c-c00e-4f00-b471-78c10d1ecc8b/c4a8074e-f162-4306-9f5a-9efe29718b05/pages/f6i3c.js?empty-if-missing=true&inject-dollar-w=true:1:749)
    at o (https://c4a8074e-f162-4306-9f5a-9efe29718b05.static.pub.wix-code.com/static/v2/822b9d6c-c00e-4f00-b471-78c10d1ecc8b/c4a8074e-f162-4306-9f5a-9efe29718b05/pages/f6i3c.js?empty-if-missing=true&inject-dollar-w=true:1:543)
    at https://c4a8074e-f162-4306-9f5a-9efe29718b05.static.pub.wix-code.com/static/v2/822b9d6c-c00e-4f00-b471-78c10d1ecc8b/c4a8074e-f162-4306-9f5a-9efe29718b05/pages/f6i3c.js?empty-if-missing=true&inject-dollar-w=true:1:578
    at Object.2.@recogito/annotorious (https://c4a8074e-f162-4306-9f5a-9efe29718b05.static.pub.wix-code.com/static/v2/822b9d6c-c00e-4f00-b471-78c10d1ecc8b/c4a8074e-f162-4306-9f5a-9efe29718b05/pages/f6i3c.js?empty-if-missing=true&inject-dollar-w=true:9:112295)
    at o (https://c4a8074e-f162-4306-9f5a-9efe29718b05.static.pub.wix-code.com/static/v2/822b9d6c-c00e-4f00-b471-78c10d1ecc8b/c4a8074e-f162-4306-9f5a-9efe29718b05/pages/f6i3c.js?empty-if-missing=true&inject-dollar-w=true:1:543)
    at e (https://c4a8074e-f162-4306-9f5a-9efe29718b05.static.pub.wix-code.com/static/v2/822b9d6c-c00e-4f00-b471-78c10d1ecc8b/c4a8074e-f162-4306-9f5a-9efe29718b05/pages/f6i3c.js?empty-if-missing=true&inject-dollar-w=true:1:703)
    at https://c4a8074e-f162-4306-9f5a-9efe29718b05.static.pub.wix-code.com/static/v2/822b9d6c-c00e-4f00-b471-78c10d1ecc8b/c4a8074e-f162-4306-9f5a-9efe29718b05/pages/f6i3c.js?empty-if-missing=true&inject-dollar-w=true:1:720
    at eval (https://static.parastorage.com/services/wix-code-viewer-app/1.559.0/app.js:25:4615)
    at Array.map (<anonymous>)
    at runUserCode (https://static.parastorage.com/services/wix-code-viewer-app/1.559.0/app.js:25:4488)
    at eval (https://static.parastorage.com/services/wix-code-viewer-app/1.559.0/app.js:3:11776)
    at eval (https://static.parastorage.com/services/wix-code-viewer-app/1.559.0/app.js:3:11929)
    at Object.eval [as traceSync] (https://static.parastorage.com/services/wix-code-viewer-app/1.559.0/app.js:3:17158)
    at Object.createControllers (https://static.parastorage.com/services/wix-code-viewer-app/1.559.0/app.js:3:11582)
    at callAppCreateControllers (https://www.exposeprofi.de/_partials/wix-bolt/1.6443.0/node_modules/viewer-platform-worker/dist/bolt-worker.js:18:89840)
    at https://www.exposeprofi.de/_partials/wix-bolt/1.6443.0/node_modules/viewer-platform-worker/dist/bolt-worker.js:18:91528
    at async Promise.all (index 0)
@rsimon
Copy link
Member

rsimon commented Jul 30, 2020

Hi, I'm afraid I'm not familiar with Wix Corvid. This seems related:

https://www.wix.com/corvid/forum/community-discussion/window-js-object-access

It says that DOM access is not possible? (I'm not clear how this works. But if DOM access is somehow shielded, then Annotorious wouldn't be able to work. Everything is done via dynamically generated SVG.)

I'd suggest either digging for general instructions on using external JS libraries in Wix, or perhaps posting to Wix support forums? Chances of finding someone who's already experienced a similar issue will likely be a lot higher there. (Annotorious doesn't do anything special in this regard, so the same issue likely applies to other libraries, too.)

Sorry for not having a better answer right now. If you manage to get this working, it would be great if you could post the solution here.

@toniengelhardt
Copy link
Author

Thanks @rsimon, I'll follow up in case I find a solution.

@rsimon
Copy link
Member

rsimon commented Aug 24, 2020

Is there any news on this? Just linking in this (perhaps?) related issue:
#52

That issue relates to problems with server-side rendering - not sure if this is also what Wix Corvid does?

@rsimon
Copy link
Member

rsimon commented Mar 20, 2021

Closing this due to 6 months+ of inactivity.

@rsimon rsimon closed this as completed Mar 20, 2021
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