Skip to content

Commit

Permalink
feat: allow pixi v7
Browse files Browse the repository at this point in the history
  • Loading branch information
Prozi committed Nov 14, 2024
1 parent 6def207 commit 0f233ef
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 43 deletions.
4 changes: 2 additions & 2 deletions dist/scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ class Scene extends scene_ssr_1.SceneSSR {
if (showFPS) {
this.showFPS(typeof showFPS === 'string' ? showFPS : undefined);
}
// pixi v6
if (!('Assets' in PIXI)) {
// pixi v6 or v7
if (!PIXI.VERSION.startsWith('8.')) {
this.resize();
(0, rxjs_1.fromEvent)(document, 'fullscreenchange', { passive: true })
.pipe((0, takeUntil_1.takeUntil)(this.destroy$))
Expand Down
2 changes: 1 addition & 1 deletion dist/sprite.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/sprite.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const lifecycle_1 = require('./lifecycle');
const Subject_1 = require('rxjs/internal/Subject');
class Sprite extends PIXI.Sprite {
constructor(gameObject, texture) {
super('Assets' in PIXI ? { texture } : texture);
super(!PIXI.VERSION.startsWith('8.') ? texture : { texture });
/**
* When Lifecycle Object is updated, it emits this subject.
* Along with updating his children, which in turn behave the same.
Expand Down
8 changes: 4 additions & 4 deletions docs/classes/Sprite.html
Original file line number Diff line number Diff line change
Expand Up @@ -7854,8 +7854,8 @@ <h4 class="tsd-returns-title">
<li>
Defined in
<a
href="https://github.com/Prozi/oneforall/blob/main/src/sprite.ts#L46"
>src/sprite.ts:46</a
href="https://github.com/Prozi/oneforall/blob/main/src/sprite.ts#L48"
>src/sprite.ts:48</a
>
</li>
</ul>
Expand Down Expand Up @@ -11617,8 +11617,8 @@ <h4 class="tsd-returns-title">
<li>
Defined in
<a
href="https://github.com/Prozi/oneforall/blob/main/src/sprite.ts#L40"
>src/sprite.ts:40</a
href="https://github.com/Prozi/oneforall/blob/main/src/sprite.ts#L42"
>src/sprite.ts:42</a
>
</li>
</ul>
Expand Down
4 changes: 2 additions & 2 deletions docs/demo/demo.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -96209,8 +96209,8 @@ Deprecated since v${version}`
if (showFPS) {
this.showFPS(typeof showFPS === 'string' ? showFPS : undefined);
}
// pixi v6
if (!('Assets' in PIXI)) {
// pixi v6 or v7
if (!PIXI.VERSION.startsWith('8.')) {
this.resize();
(0, rxjs_1.fromEvent)(document, 'fullscreenchange', {
passive: true
Expand Down
22 changes: 7 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@pietal.dev/engine",
"description": "PIXI v8 and v6 compatible: inspired by Unity, reactive Game Framework: GameObject, StateMachine, CircleBody, PolygonBody, Physics, Sprite, Container, Animator, TextureAtlas, Resources loading",
"version": "9.22.0",
"description": "PIXI v8, v7, v6 compatible: inspired by Unity, reactive Game Framework: GameObject, StateMachine, CircleBody, PolygonBody, Physics, Sprite, Container, Animator, TextureAtlas, Resources loading",
"version": "9.23.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
Expand All @@ -24,7 +24,10 @@
"lint": "eslint 'src/**/*.ts' --fix",
"format": "prettier . --write",
"test": "jest --silent --verbose --forceExit",
"test:build": "node ./test-build.js",
"test-v6": "yarn add pixi.js@^6 pixi.js-legacy@^6 -D && node test-build",
"test-v7": "yarn add pixi.js@^7 pixi.js-legacy@^7 -D && node test-build",
"test-v8": "yarn add pixi.js@^8 pixi.js-legacy@^7 -D && node test-build",
"test-build": "yarn test-v6 && yarn test-v7 && yarn test-v8",
"precommit": "yarn lint && yarn build && yarn test && yarn format",
"amend": "yarn precommit && git commit -a --am --no-edit"
},
Expand All @@ -51,17 +54,6 @@
"@babel/plugin-transform-class-properties": "^7.25.9",
"@babel/plugin-transform-modules-commonjs": "^7.25.9",
"@babel/preset-typescript": "^7.26.0",
"@pixi/core": "^7",
"@pixi/display": "^7",
"@pixi/extract": "^7",
"@pixi/graphics": "^7",
"@pixi/mesh": "^7",
"@pixi/mesh-extras": "^7",
"@pixi/particle-container": "^7",
"@pixi/prepare": "^7",
"@pixi/sprite": "^7",
"@pixi/sprite-tiling": "^7",
"@pixi/text": "^7",
"@types/jest": "^29.5.14",
"@types/offscreencanvas": "^2019.7.3",
"babel-jest": "^29.7.0",
Expand All @@ -82,7 +74,7 @@
"webpack-dev-server": "^5.1.0"
},
"peerDependencies": {
"pixi.js": "^6 || ^8"
"pixi.js": "^6 || ^7 || ^8"
},
"keywords": [
"unity",
Expand Down
2 changes: 1 addition & 1 deletion src/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class Resources {

loader.add(url);
loader.onError.add(reject);
loader.load((_: PIXIv6Loader, resources) => {
loader.load((_: PIXIv6Loader, resources: Record<string, any>) => {
const response = resources[url];

resolve(response.texture || response.data);
Expand Down
4 changes: 2 additions & 2 deletions src/scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ export class Scene<TBody extends Body = Body> extends SceneSSR<TBody> {
this.showFPS(typeof showFPS === 'string' ? showFPS : undefined);
}

// pixi v6
if (!('Assets' in PIXI)) {
// pixi v6 or v7
if (!PIXI.VERSION.startsWith('8.')) {
this.resize();

fromEvent(document, 'fullscreenchange', { passive: true })
Expand Down
4 changes: 3 additions & 1 deletion src/sprite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ export class Sprite extends PIXI.Sprite implements LifecycleProps {
label = 'Sprite';

constructor(gameObject: GameObject, texture: PIXI.Texture) {
super(('Assets' in PIXI ? { texture } : texture) as any);
super(
!PIXI.VERSION.startsWith('8.') ? (texture as any) : ({ texture } as any)
);

gameObject.addChild(this);
}
Expand Down
3 changes: 0 additions & 3 deletions test-build.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
require('pixi-shim');
require('pixi.js-legacy');

const { GameObject, Component } = require('./dist/index.js');

const gameObject = new GameObject();
Expand Down
22 changes: 11 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@
resolved "https://registry.yarnpkg.com/@pixi/constants/-/constants-7.4.2.tgz#e1b12316e1c637f3ebe80b599a707de4bdc4ab9b"
integrity sha512-N9vn6Wpz5WIQg7ugUg2+SdqD2u2+NM0QthE8YzLJ4tLH2Iz+/TrnPKUJzeyIqbg3sxJG5ZpGGPiacqIBpy1KyA==

"@pixi/core@7.4.2", "@pixi/core@^7":
"@pixi/core@7.4.2":
version "7.4.2"
resolved "https://registry.yarnpkg.com/@pixi/core/-/core-7.4.2.tgz#521de6fe99d48ffffef7e79d4dfde5c5055e8a13"
integrity sha512-UbMtgSEnyCOFPzbE6ThB9qopXxbZ5GCof2ArB4FXOC5Xi/83MOIIYg5kf5M8689C5HJMhg2SrJu3xLKppF+CMg==
Expand All @@ -896,7 +896,7 @@
"@pixi/ticker" "7.4.2"
"@pixi/utils" "7.4.2"

"@pixi/display@7.4.2", "@pixi/display@^7":
"@pixi/display@7.4.2":
version "7.4.2"
resolved "https://registry.yarnpkg.com/@pixi/display/-/display-7.4.2.tgz#f0b7db822fba80cd2e8c28f6f489244360a578ba"
integrity sha512-DaD0J7gIlNlzO0Fdlby/0OH+tB5LtCY6rgFeCBKVDnzmn8wKW3zYZRenWBSFJ0Psx6vLqXYkSIM/rcokaKviIw==
Expand All @@ -911,7 +911,7 @@
resolved "https://registry.yarnpkg.com/@pixi/extensions/-/extensions-7.4.2.tgz#4e939e3670ca66fdcd2590e8ab90a6a04a176dec"
integrity sha512-Hmx2+O0yZ8XIvgomHM9GZEGcy9S9Dd8flmtOK5Aa3fXs/8v7xD08+ANQpN9ZqWU2Xs+C6UBlpqlt2BWALvKKKA==

"@pixi/extract@7.4.2", "@pixi/extract@^7":
"@pixi/extract@7.4.2":
version "7.4.2"
resolved "https://registry.yarnpkg.com/@pixi/extract/-/extract-7.4.2.tgz#0e52446202bc8521ca9821a276e919020b0688f4"
integrity sha512-JOX27TRWjVEjauGBbF8PU7/g6LYXnivehdgqS5QlVDv1CNHTOrz/j3MdKcVWOhyZPbH5c9sh7lxyRxvd9AIuTQ==
Expand Down Expand Up @@ -946,7 +946,7 @@
resolved "https://registry.yarnpkg.com/@pixi/filter-noise/-/filter-noise-7.4.2.tgz#99aebe14d0f52aaa8509e2531f1a4e658a702da9"
integrity sha512-Vy9ViBFhZEGh6xKkd3kFWErolZTwv1Y5Qb1bV7qPIYbvBECYsqzlR4uCrrjBV6KKm0PufpG/+NKC5vICZaqKzg==

"@pixi/graphics@7.4.2", "@pixi/graphics@^7":
"@pixi/graphics@7.4.2":
version "7.4.2"
resolved "https://registry.yarnpkg.com/@pixi/graphics/-/graphics-7.4.2.tgz#b4fcc39f6a0af4c74d66b3d45b6728c33467bc78"
integrity sha512-jH4/Tum2RqWzHGzvlwEr7HIVduoLO57Ze705N2zQPkUD57TInn5911aGUeoua7f/wK8cTLGzgB9BzSo2kTdcHw==
Expand All @@ -956,12 +956,12 @@
resolved "https://registry.yarnpkg.com/@pixi/math/-/math-7.4.2.tgz#473b400c89ac8fcdf6e09259ab097ce35cd8ac68"
integrity sha512-7jHmCQoYk6e0rfSKjdNFOPl0wCcdgoraxgteXJTTHv3r0bMNx2pHD9FJ0VvocEUG7XHfj55O3+u7yItOAx0JaQ==

"@pixi/mesh-extras@7.4.2", "@pixi/mesh-extras@^7":
"@pixi/mesh-extras@7.4.2":
version "7.4.2"
resolved "https://registry.yarnpkg.com/@pixi/mesh-extras/-/mesh-extras-7.4.2.tgz#92eb4f41fd08907f6118dbfcb4b65fc5642d14d3"
integrity sha512-vNR/7wjxjs7sv9fGoKkHyU91ZAD+7EnMHBS5F3CVISlOIFxLi96NNZCB81oUIdky/90pHw40johd/4izR5zTyw==

"@pixi/mesh@7.4.2", "@pixi/mesh@^7":
"@pixi/mesh@7.4.2":
version "7.4.2"
resolved "https://registry.yarnpkg.com/@pixi/mesh/-/mesh-7.4.2.tgz#f2095eb8ec792a102c76f18838f75d860bd42dff"
integrity sha512-mEkKyQvvMrYXC3pahvH5WBIKtrtB63WixRr91ANFI7zXD+ESG6Ap6XtxMCJmXDQPwBDNk7SWVMiCflYuchG7kA==
Expand All @@ -981,12 +981,12 @@
resolved "https://registry.yarnpkg.com/@pixi/mixin-get-global-position/-/mixin-get-global-position-7.4.2.tgz#9dcc9f49fa8001103ceadb1061efe03a71761952"
integrity sha512-LcsahbVdX4DFS2IcGfNp4KaXuu7SjAwUp/flZSGIfstyKOKb5FWFgihtqcc9ZT4coyri3gs2JbILZub/zPZj1w==

"@pixi/particle-container@7.4.2", "@pixi/particle-container@^7":
"@pixi/particle-container@7.4.2":
version "7.4.2"
resolved "https://registry.yarnpkg.com/@pixi/particle-container/-/particle-container-7.4.2.tgz#f829caaa724be10b7e0a04fca89a68f64e80012a"
integrity sha512-B78Qq86kt0lEa5WtB2YFIm3+PjhKfw9La9R++GBSgABl+g13s2UaZ6BIPxvY3JxWMdxPm4iPrQPFX1QWRN68mw==

"@pixi/prepare@7.4.2", "@pixi/prepare@^7":
"@pixi/prepare@7.4.2":
version "7.4.2"
resolved "https://registry.yarnpkg.com/@pixi/prepare/-/prepare-7.4.2.tgz#36fa8f5a044e6c4f46e7d2df1bef82dce7d40455"
integrity sha512-PugyMzReCHXUzc3so9PPJj2OdHwibpUNWyqG4mWY2UUkb6c8NAGK1AnAPiscOvLilJcv/XQSFoNhX+N1jrvJEg==
Expand All @@ -1010,12 +1010,12 @@
resolved "https://registry.yarnpkg.com/@pixi/sprite-animated/-/sprite-animated-7.4.2.tgz#c28a3b2a8ee986517657ad5a1406fdddd610f56b"
integrity sha512-QPT6yxCUGOBN+98H3pyIZ1ZO6Y7BN1o0Q2IMZEsD1rNfZJrTYS3Q8VlCG5t2YlFlcB8j5iBo24bZb6FUxLOmsQ==

"@pixi/sprite-tiling@7.4.2", "@pixi/sprite-tiling@^7":
"@pixi/sprite-tiling@7.4.2":
version "7.4.2"
resolved "https://registry.yarnpkg.com/@pixi/sprite-tiling/-/sprite-tiling-7.4.2.tgz#ba6e3c596cb6dadb21795153058a900dcb1cfd2b"
integrity sha512-Z8PP6ewy3nuDYL+NeEdltHAhuucVgia33uzAitvH3OqqRSx6a6YRBFbNLUM9Sx+fBO2Lk3PpV1g6QZX+NE5LOg==

"@pixi/sprite@7.4.2", "@pixi/sprite@^7":
"@pixi/sprite@7.4.2":
version "7.4.2"
resolved "https://registry.yarnpkg.com/@pixi/sprite/-/sprite-7.4.2.tgz#beed8c2fd2e00a02e340eaba9844b180bf1f1b24"
integrity sha512-Ccf/OVQsB+HQV0Fyf5lwD+jk1jeU7uSIqEjbxenNNssmEdB7S5qlkTBV2EJTHT83+T6Z9OMOHsreJZerydpjeg==
Expand All @@ -1035,7 +1035,7 @@
resolved "https://registry.yarnpkg.com/@pixi/text-html/-/text-html-7.4.2.tgz#843e153d1f8c09fdf18c2527baa9f778061e94d3"
integrity sha512-duOu8oDYeDNuyPozj2DAsQ5VZBbRiwIXy78Gn7H2pCiEAefw/Uv5jJYwdgneKME0e1tOxz1eOUGKPcI6IJnZjw==

"@pixi/text@7.4.2", "@pixi/text@^7":
"@pixi/text@7.4.2":
version "7.4.2"
resolved "https://registry.yarnpkg.com/@pixi/text/-/text-7.4.2.tgz#ee9f54083ecbf5b07d4410ede0cd005a312d2e71"
integrity sha512-rZZWpJNsIQ8WoCWrcVg8Gi6L/PDakB941clo6dO3XjoII2ucoOUcnpe5HIkudxi2xPvS/8Bfq990gFEx50TP5A==
Expand Down

0 comments on commit 0f233ef

Please sign in to comment.