Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Problems with the npm package #7

Closed
AdrienLemaire opened this issue Dec 23, 2020 · 3 comments
Closed

Problems with the npm package #7

AdrienLemaire opened this issue Dec 23, 2020 · 3 comments

Comments

@AdrienLemaire
Copy link

getkey/gstatsjs has issues closed, which is why I'm creating the issue here.
@eXponenta @getkey when checking getkey's repo, I see

This branch is 4 commits ahead, 6 commits behind eXponenta:master.

Since getkey's PR has been merged, it'd be nice to have npm/gstats points to the official repo instead of the outdated fork.

Finally, I'm unable to get the fork working in my setup (react, pixi v5)

Getting errors from the editor:

[tsserver 2307] [E] Cannot find module 'gstats' or its corresponding type declarations.

Ignoring that, I get webpack errors when compiling:

ERROR in /path/to/project/src/components/DebugStatsView.tsx
./src/components/DebugStatsView.tsx
[tsl] ERROR in /path/to/project/src/components/DebugStatsView.tsx(7,9)
TS2461: Type 'StatsJSAdapter' is not an array type.

Ignoring that as well, I get browser console errors:

Stats can't found in window, pass instance of Stats.js as second param

Can we get a working example with es modules ?

@eXponenta
Copy link
Owner

Ok, i dont know what happened, i'd not published a NPM library for v5.
You can run PR from getkey repository :)
And i checking it.

@getkey
Copy link
Contributor

getkey commented Dec 23, 2020

import Stats from 'stats.js';
import { PIXIHooks, StatsJSAdapter } from 'gstats';

window.Stats = Stats; // gross, but needed by gstats

const pixiHooks = new PIXIHooks({
	renderer: renderer,
});
const stats = new Stats();
const statsAdapter = new StatsJSAdapter(pixiHooks, stats);
stats.showPanel(0); // 0: fps, 1: ms, 2: mb, 3+: custom
document.body.appendChild(stats.dom);

This is an example taken from my code. Relying on window is ugly but since I only use gstats in my dev builds I do not care too much.

Since getkey's PR has been merged

This one #2 hasn't been merged yet.

getkey/gstatsjs has issues closed, which is why I'm creating the issue here.

My bad, I don't know why I closed them, in any case I reopened them now. 😄

@AdrienLemaire
Copy link
Author

resolved my issues, closing. Thanks

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

No branches or pull requests

3 participants