geckosio / phaser-on-nodejs

Allows you to run Phaser 3 game (including Phaser's physics engines) on Node.js
MIT License
103 stars 11 forks source link

localStorage is not available for opaque origins #18

Open ilackarms opened 1 year ago

ilackarms commented 1 year ago

Describe the bug Cannot run a project which imports phaser-on-nodejs in dev mode.

When refreshing the page, i get the error SecurityError: localStorage is not available for opaque origins

Seems this is supposedly caused by jest and JSDOM, but none of the fixes suggested in the issues i've found have worked

yandeu commented 1 year ago

What's the project. Is it open source? I suggest using arcade-physics instead.

ilackarms commented 1 year ago

was not able to et arcade-physics working with scene.physics.overlapRect

yandeu commented 1 year ago

Support for overlap has been added 4 days ago. See https://github.com/yandeu/arcade-physics/blob/main/test/overlap.test.js

ilackarms commented 1 year ago

interesting. i still need the ability to read in tilemaps for collisions and object layers. is that possible with arcade-physics?

zewa666 commented 1 year ago

not sure if thats fully related to this but I had a bunch of similar issues. Try changing this line from the dist https://github.com/geckosio/phaser-on-nodejs/blob/master/src/index.ts#L10 to read have an URL:

-const dom = new JSDOM(`<!DOCTYPE html><body></body>`);
+const dom = new JSDOM(`<!DOCTYPE html><body></body>`, {
+  url: 'http://localhost/'
+});
yandeu commented 1 year ago

interesting. i still need the ability to read in tilemaps for collisions and object layers. is that possible with arcade-physics?

Not yet, but I plan to implement it.