Open shipurjan opened 7 months ago
The thing is the issue was already solved in this commit but it seems the change was never published with a new version on npm.
@davidfig Am I correct? Any chance you could publish a new version?
For now, I managed to by-pass importing the lib only when is rendered by the browser.
if (isPlatformBrowser(this.platformId)) { // <--- angular validation to check if the platform is browser
const { Viewport } = await import('pixi-viewport');
this.viewPort = new Viewport({
worldWidth: this.app.stage.width,
worldHeight: this.app.stage.height,
screenWidth: this.app.renderer.width,
screenHeight: this.app.renderer.height,
events: this.app.renderer.events,
});
}
Facing the same issue with window
object used wihtin pixi-viewport
. Not using Tauri but similar approach as yours.
The first thing I did was also this:
const { Viewport } = await import('pixi-viewport')
But then I'm now facing an error when trying to:
viewport.addChild(bunny)
It raises a runtime error:
TypeError: Cannot set properties of undefined (setting '_parentID')
Not completely sure if this is consecutive issue of another. Or they're two separate things.
Additionally, it raises an error in tsc:
Argument of type 'Sprite' is not assignable to parameter of type 'DisplayObject'
In other threads they say to re-install node_modules but this doesn't help: still wrong types.
Were you able to make it all work? Successfully draw a bunny or something?
@jerrygreen Yeah I made it work for 5.0.2 (I didn't upgrade to 5.1.0 yet) by using patch
command in pnpm:
https://github.com/shipurjan/bioparallel/blob/master/patches/pixi-viewport%405.0.2.patch
pnpm applies this patch every time I install packages and I haven't had problems ever since
The problem seems to be this: https://github.com/davidfig/pixi-viewport/issues/487
Hello, I'm using NextJS inside Tauri.
I set all components (and all pages in the router + layout) to client, however I still can't import
pixi-viewport
, because it referenceswindow
The lines causing this seem to be below, because if I change them to fixed values the error disappears
in
\node_modules\.pnpm\pixi-viewport@5.0.2\node_modules\pixi-viewport\dist\pixi_viewport.js
Here is the code I'm using:
Changing these lines to
seems to fix it.