diff --git a/.eslintrc.json b/.eslintrc.json index 314daa40d8..cb38697904 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,9 +1,89 @@ { - "extends": [ - "@pixi/eslint-config" - ], - "rules": { - "@typescript-eslint/no-parameter-properties": 1, - "@typescript-eslint/type-annotation-spacing": 1 - } + "extends": ["@pixi/eslint-config"], + "plugins": ["jsdoc"], + "parserOptions": { + "project": ["./tsconfig.eslint.json"] + }, + "ignorePatterns": ["**/*.index.d.ts"], + "settings": { + "jsdoc": { + "mode": "typescript", + "tagNamePreference": { + "method": "method", + "function": "function", + "extends": "extends", + "typeParam": "typeParam", + "api": "api" + } + } + }, + "rules": { + "@typescript-eslint/no-parameter-properties": 1, + "@typescript-eslint/type-annotation-spacing": 1, + "jsdoc/multiline-blocks": [ + 1, + { "noMultilineBlocks": true, "minimumLengthForMultiline": 115 } + ], + "jsdoc/check-access": 1, + "jsdoc/check-alignment": 1, + "jsdoc/check-param-names": 1, + "jsdoc/check-property-names": 1, + "jsdoc/check-tag-names": 1, + "jsdoc/check-types": 1, + "jsdoc/check-values": 1, + "jsdoc/empty-tags": 1, + "jsdoc/implements-on-classes": 1, + "jsdoc/newline-after-description": [1, "never"], + "jsdoc/no-multi-asterisks": [1, { "allowWhitespace": true }], + "jsdoc/no-undefined-types": [ + "warn", + { + "definedTypes": [ + "PIXI", + "WEBGL_draw_buffers", + "WEBGL_depth_texture", + "OES_texture_float", + "WEBGL_lose_context", + "OES_vertex_array_object", + "EXT_texture_filter_anisotropic" + ] + } + ], + "jsdoc/require-param": 1, + "jsdoc/require-param-description": 0, + "jsdoc/require-param-name": 1, + "jsdoc/require-param-type": [ + "warn", + { "contexts": ["TSMethodSignature"] } + ], + "jsdoc/require-property": 1, + "jsdoc/require-property-description": 1, + "jsdoc/require-property-name": 1, + "jsdoc/require-property-type": 1, + "jsdoc/require-returns-description": 1, + "jsdoc/tag-lines": 1, + "jsdoc/valid-types": 1 + }, + "overrides": [ + { + "files": ["*.tests.ts", "*.test.ts"], + "globals": { + "expect": false, + "assert": false, + "sinon": false + }, + "rules": { + "@typescript-eslint/no-unused-expressions": 0, + "@typescript-eslint/dot-notation": [ + 0, + { + "allowPrivateClassPropertyAccess": true, + "allowProtectedClassPropertyAccess": true, + "allowIndexSignaturePropertyAccess": true + } + ], + "dot-notation": 0 + } + } + ] } diff --git a/.eslintrc.tests.json b/.eslintrc.tests.json deleted file mode 100644 index f3aff55687..0000000000 --- a/.eslintrc.tests.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "extends": "./.eslintrc.json", - "globals": { - "expect": false, - "assert": false, - "sinon": false - }, - "rules": { - "func-names": 0, - "no-unused-expressions": 0, - "@typescript-eslint/no-var-requires": 0, - "@typescript-eslint/no-unused-expressions": 0, - "@typescript-eslint/no-use-before-define": 0, - "@typescript-eslint/no-unused-vars": 0, - "@typescript-eslint/no-empty-function": 0 - } -} diff --git a/.github/stale.yml b/.github/stale.yml index d3d2203e32..325fa49c3a 100644 --- a/.github/stale.yml +++ b/.github/stale.yml @@ -1,8 +1,8 @@ # Number of days of inactivity before an issue becomes stale -daysUntilStale: 90 +daysUntilStale: 180 # Number of days of inactivity before a stale issue is closed -daysUntilClose: 14 +daysUntilClose: 90 # Issues with these labels will never be considered stale #exemptLabels: diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 6361a741a0..fce815b46b 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -25,7 +25,7 @@ jobs: - name: Use Node.js uses: actions/setup-node@v2 with: - node-version: 12 + node-version: 14 registry-url: 'https://registry.npmjs.org' - name: Install npm run: npm install -g npm@>=7 diff --git a/.gitignore b/.gitignore index fd5f469803..bf1b2f2791 100644 --- a/.gitignore +++ b/.gitignore @@ -42,5 +42,8 @@ packages/**/index.d.ts .vscode pixi.code-workspace +# IntelliJ +*.iml + # webdoc api dist/docs/pixi.api.json diff --git a/README.md b/README.md index ac1788d2d4..43594929c5 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ PixiJS — The HTML5 Creation Engine ![pixi.js logo](https://pixijs.download/pixijs-banner-no-version.png) -[](https://join.slack.com/t/pixijs/shared_invite/zt-dcem1map-uVuVGC7pZ0trF8SrcA2p9g) +[![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/QrnxmQUPGV) [![npm version](https://badge.fury.io/js/pixi.js.svg)](https://badge.fury.io/js/pixi.js) [![Node.js CI](https://github.com/pixijs/pixi.js/workflows/Node.js%20CI/badge.svg)](https://github.com/pixi.js/pixi.js/actions?query=workflow%3A%22Node.js+CI%22) @@ -42,8 +42,7 @@ PixiJS has full [WebGL](https://en.wikipedia.org/wiki/WebGL) support and seamles ### Community ### - Forums: Check out the [forum](https://www.html5gamedevs.com/forum/15-pixijs/) and [Stackoverflow](http://stackoverflow.com/search?q=pixi.js), both friendly places to ask your PixiJS questions. - Inspiration: Check out the [gallery](https://www.pixijs.com/gallery) to see some of the amazing things people have created! -- Chat: You can join us on [Gitter](https://gitter.im/pixijs/pixi.js) To chat about PixiJS. We also now have a Slack channel. If you would like to join it please Send me an email (mat@goodboydigital.com) and I will invite you in. - +- Chat: You can join us on [Discord](https://discord.gg/QrnxmQUPGV) to chat about PixiJS. ### Setup ### diff --git a/bundles/pixi.js-legacy/package.json b/bundles/pixi.js-legacy/package.json index 78f208fcaf..2823c26150 100644 --- a/bundles/pixi.js-legacy/package.json +++ b/bundles/pixi.js-legacy/package.json @@ -1,6 +1,6 @@ { "name": "pixi.js-legacy", - "version": "6.3.0", + "version": "6.4.2", "description": "The HTML5 Creation Engine: Create beautiful digital content with the fastest, most flexible 2D WebGL renderer.", "author": "Mat Groves", "contributors": [ @@ -17,6 +17,19 @@ "bundleOutput": { "name": "PIXI" }, + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/pixi-legacy.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/pixi-legacy.js" + } + } + }, "homepage": "http://www.pixijs.com/", "bugs": "https://github.com/pixijs/pixi.js/issues", "license": "MIT", @@ -34,16 +47,16 @@ "url": "https://opencollective.com/pixijs" }, "dependencies": { - "@pixi/canvas-display": "6.3.0", - "@pixi/canvas-extract": "6.3.0", - "@pixi/canvas-graphics": "6.3.0", - "@pixi/canvas-mesh": "6.3.0", - "@pixi/canvas-particle-container": "6.3.0", - "@pixi/canvas-prepare": "6.3.0", - "@pixi/canvas-renderer": "6.3.0", - "@pixi/canvas-sprite": "6.3.0", - "@pixi/canvas-sprite-tiling": "6.3.0", - "@pixi/canvas-text": "6.3.0", - "pixi.js": "6.3.0" + "@pixi/canvas-display": "6.4.2", + "@pixi/canvas-extract": "6.4.2", + "@pixi/canvas-graphics": "6.4.2", + "@pixi/canvas-mesh": "6.4.2", + "@pixi/canvas-particle-container": "6.4.2", + "@pixi/canvas-prepare": "6.4.2", + "@pixi/canvas-renderer": "6.4.2", + "@pixi/canvas-sprite": "6.4.2", + "@pixi/canvas-sprite-tiling": "6.4.2", + "@pixi/canvas-text": "6.4.2", + "pixi.js": "6.4.2" } } diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 0c3a25c31a..8a242e9b2f 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -1,6 +1,6 @@ { "name": "pixi.js", - "version": "6.3.0", + "version": "6.4.2", "description": "PixiJS without the CanvasRenderer fallback, modern browsers only", "author": "Mat Groves", "contributors": [ @@ -17,6 +17,19 @@ "bundleOutput": { "name": "PIXI" }, + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/pixi.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/pixi.js" + } + } + }, "homepage": "http://www.pixijs.com/", "bugs": "https://github.com/pixijs/pixi.js/issues", "license": "MIT", @@ -37,40 +50,40 @@ "url": "https://opencollective.com/pixijs" }, "dependencies": { - "@pixi/accessibility": "6.3.0", - "@pixi/app": "6.3.0", - "@pixi/compressed-textures": "6.3.0", - "@pixi/constants": "6.3.0", - "@pixi/core": "6.3.0", - "@pixi/display": "6.3.0", - "@pixi/extract": "6.3.0", - "@pixi/filter-alpha": "6.3.0", - "@pixi/filter-blur": "6.3.0", - "@pixi/filter-color-matrix": "6.3.0", - "@pixi/filter-displacement": "6.3.0", - "@pixi/filter-fxaa": "6.3.0", - "@pixi/filter-noise": "6.3.0", - "@pixi/graphics": "6.3.0", - "@pixi/interaction": "6.3.0", - "@pixi/loaders": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/mesh": "6.3.0", - "@pixi/mesh-extras": "6.3.0", - "@pixi/mixin-cache-as-bitmap": "6.3.0", - "@pixi/mixin-get-child-by-name": "6.3.0", - "@pixi/mixin-get-global-position": "6.3.0", - "@pixi/particle-container": "6.3.0", - "@pixi/polyfill": "6.3.0", - "@pixi/prepare": "6.3.0", - "@pixi/runner": "6.3.0", - "@pixi/settings": "6.3.0", - "@pixi/sprite": "6.3.0", - "@pixi/sprite-animated": "6.3.0", - "@pixi/sprite-tiling": "6.3.0", - "@pixi/spritesheet": "6.3.0", - "@pixi/text": "6.3.0", - "@pixi/text-bitmap": "6.3.0", - "@pixi/ticker": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/accessibility": "6.4.2", + "@pixi/app": "6.4.2", + "@pixi/compressed-textures": "6.4.2", + "@pixi/constants": "6.4.2", + "@pixi/core": "6.4.2", + "@pixi/display": "6.4.2", + "@pixi/extract": "6.4.2", + "@pixi/filter-alpha": "6.4.2", + "@pixi/filter-blur": "6.4.2", + "@pixi/filter-color-matrix": "6.4.2", + "@pixi/filter-displacement": "6.4.2", + "@pixi/filter-fxaa": "6.4.2", + "@pixi/filter-noise": "6.4.2", + "@pixi/graphics": "6.4.2", + "@pixi/interaction": "6.4.2", + "@pixi/loaders": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/mesh": "6.4.2", + "@pixi/mesh-extras": "6.4.2", + "@pixi/mixin-cache-as-bitmap": "6.4.2", + "@pixi/mixin-get-child-by-name": "6.4.2", + "@pixi/mixin-get-global-position": "6.4.2", + "@pixi/particle-container": "6.4.2", + "@pixi/polyfill": "6.4.2", + "@pixi/prepare": "6.4.2", + "@pixi/runner": "6.4.2", + "@pixi/settings": "6.4.2", + "@pixi/sprite": "6.4.2", + "@pixi/sprite-animated": "6.4.2", + "@pixi/sprite-tiling": "6.4.2", + "@pixi/spritesheet": "6.4.2", + "@pixi/text": "6.4.2", + "@pixi/text-bitmap": "6.4.2", + "@pixi/ticker": "6.4.2", + "@pixi/utils": "6.4.2" } } diff --git a/bundles/pixi.js/src/index.ts b/bundles/pixi.js/src/index.ts index 924e2eb13e..2857ad544e 100644 --- a/bundles/pixi.js/src/index.ts +++ b/bundles/pixi.js/src/index.ts @@ -46,7 +46,6 @@ Application.registerPlugin(AppLoaderPlugin); /** * String of the current PIXI version. - * * @static * @constant * @memberof PIXI @@ -68,7 +67,6 @@ export const VERSION = '$_VERSION'; * PixiJS Filters repository. * * All filters must extend {@link PIXI.Filter}. - * * @example * // Create a new application * const app = new PIXI.Application(); diff --git a/lerna.json b/lerna.json index 94542e18c7..7ef090e493 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { "lerna": "4.0.0", "useWorkspaces": true, - "version": "6.3.0" + "version": "6.4.2" } diff --git a/package-lock.json b/package-lock.json index cec841b9dc..4cb5cf2cdb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,15 +8,13 @@ "workspaces": [ "bundles/*", "packages/*", - "packages/canvas/*", - "packages/filters/*", "tools/*" ], "devDependencies": { "@istanbuljs/nyc-config-typescript": "^1.0.1", - "@microsoft/api-extractor": "^7.9.11", - "@pixi-build-tools/api-extractor-lerna-monorepo": "^1.0.3", - "@pixi/eslint-config": "^2.0.1", + "@microsoft/api-extractor": "~7.20.1", + "@pixi-build-tools/api-extractor-lerna-monorepo": "~1.1.0", + "@pixi/eslint-config": "^4.0.1", "@pixi/webdoc-template": "^1.5.3", "@rollup/plugin-alias": "^3.1.1", "@rollup/plugin-buble": "^0.21.3", @@ -24,13 +22,17 @@ "@rollup/plugin-json": "^4.1.0", "@rollup/plugin-node-resolve": "^9.0.0", "@rollup/plugin-typescript": "^6.0.0", + "@types/chai": "^4.3.1", "@types/mocha": "^8.2.3", + "@types/sinon": "^10.0.11", + "@types/sinon-chai": "^3.2.8", "@webdoc/cli": "^1.5.5", "chai": "~4.3.6", "copyfiles": "^2.1.0", "cross-env": "^5.2.0", "electron": "^12.0.0", "eslint": "^7.2.0", + "eslint-plugin-jsdoc": "^39.2.9", "floss": "^5.0.0", "glob": "^7.1.3", "lerna": "^4.0.0", @@ -48,54 +50,54 @@ "sinon-chai": "^3.3.0", "ts-node": "^9.0.0", "tsconfig-paths": "^3.10.1", - "typescript": "^3.9.5", + "typescript": "~4.3.0", "workspaces-run": "^1.0.1" }, "engines": { - "node": ">=12", + "node": ">=14", "npm": ">=7", "yarn": "please-use-npm" } }, "bundles/pixi.js": { - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "dependencies": { - "@pixi/accessibility": "6.3.0", - "@pixi/app": "6.3.0", - "@pixi/compressed-textures": "6.3.0", - "@pixi/constants": "6.3.0", - "@pixi/core": "6.3.0", - "@pixi/display": "6.3.0", - "@pixi/extract": "6.3.0", - "@pixi/filter-alpha": "6.3.0", - "@pixi/filter-blur": "6.3.0", - "@pixi/filter-color-matrix": "6.3.0", - "@pixi/filter-displacement": "6.3.0", - "@pixi/filter-fxaa": "6.3.0", - "@pixi/filter-noise": "6.3.0", - "@pixi/graphics": "6.3.0", - "@pixi/interaction": "6.3.0", - "@pixi/loaders": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/mesh": "6.3.0", - "@pixi/mesh-extras": "6.3.0", - "@pixi/mixin-cache-as-bitmap": "6.3.0", - "@pixi/mixin-get-child-by-name": "6.3.0", - "@pixi/mixin-get-global-position": "6.3.0", - "@pixi/particle-container": "6.3.0", - "@pixi/polyfill": "6.3.0", - "@pixi/prepare": "6.3.0", - "@pixi/runner": "6.3.0", - "@pixi/settings": "6.3.0", - "@pixi/sprite": "6.3.0", - "@pixi/sprite-animated": "6.3.0", - "@pixi/sprite-tiling": "6.3.0", - "@pixi/spritesheet": "6.3.0", - "@pixi/text": "6.3.0", - "@pixi/text-bitmap": "6.3.0", - "@pixi/ticker": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/accessibility": "6.4.2", + "@pixi/app": "6.4.2", + "@pixi/compressed-textures": "6.4.2", + "@pixi/constants": "6.4.2", + "@pixi/core": "6.4.2", + "@pixi/display": "6.4.2", + "@pixi/extract": "6.4.2", + "@pixi/filter-alpha": "6.4.2", + "@pixi/filter-blur": "6.4.2", + "@pixi/filter-color-matrix": "6.4.2", + "@pixi/filter-displacement": "6.4.2", + "@pixi/filter-fxaa": "6.4.2", + "@pixi/filter-noise": "6.4.2", + "@pixi/graphics": "6.4.2", + "@pixi/interaction": "6.4.2", + "@pixi/loaders": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/mesh": "6.4.2", + "@pixi/mesh-extras": "6.4.2", + "@pixi/mixin-cache-as-bitmap": "6.4.2", + "@pixi/mixin-get-child-by-name": "6.4.2", + "@pixi/mixin-get-global-position": "6.4.2", + "@pixi/particle-container": "6.4.2", + "@pixi/polyfill": "6.4.2", + "@pixi/prepare": "6.4.2", + "@pixi/runner": "6.4.2", + "@pixi/settings": "6.4.2", + "@pixi/sprite": "6.4.2", + "@pixi/sprite-animated": "6.4.2", + "@pixi/sprite-tiling": "6.4.2", + "@pixi/spritesheet": "6.4.2", + "@pixi/text": "6.4.2", + "@pixi/text-bitmap": "6.4.2", + "@pixi/ticker": "6.4.2", + "@pixi/utils": "6.4.2" }, "funding": { "type": "opencollective", @@ -103,20 +105,20 @@ } }, "bundles/pixi.js-legacy": { - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "dependencies": { - "@pixi/canvas-display": "6.3.0", - "@pixi/canvas-extract": "6.3.0", - "@pixi/canvas-graphics": "6.3.0", - "@pixi/canvas-mesh": "6.3.0", - "@pixi/canvas-particle-container": "6.3.0", - "@pixi/canvas-prepare": "6.3.0", - "@pixi/canvas-renderer": "6.3.0", - "@pixi/canvas-sprite": "6.3.0", - "@pixi/canvas-sprite-tiling": "6.3.0", - "@pixi/canvas-text": "6.3.0", - "pixi.js": "6.3.0" + "@pixi/canvas-display": "6.4.2", + "@pixi/canvas-extract": "6.4.2", + "@pixi/canvas-graphics": "6.4.2", + "@pixi/canvas-mesh": "6.4.2", + "@pixi/canvas-particle-container": "6.4.2", + "@pixi/canvas-prepare": "6.4.2", + "@pixi/canvas-renderer": "6.4.2", + "@pixi/canvas-sprite": "6.4.2", + "@pixi/canvas-sprite-tiling": "6.4.2", + "@pixi/canvas-text": "6.4.2", + "pixi.js": "6.4.2" }, "funding": { "type": "opencollective", @@ -748,6 +750,20 @@ } } }, + "node_modules/@electron/get/node_modules/fs-extra": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", + "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + }, + "engines": { + "node": ">=6 <7 || >=8" + } + }, "node_modules/@electron/get/node_modules/ms": { "version": "2.1.2", "dev": true, @@ -761,6 +777,20 @@ "semver": "bin/semver.js" } }, + "node_modules/@es-joy/jsdoccomment": { + "version": "0.29.0", + "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.29.0.tgz", + "integrity": "sha512-4yKy5t+/joLihG+ei6CCU6sc08sjUdEdXCQ2U+9h9VP13EiqHQ4YMgDC18ys/AsLdJDBX3KRx/AWY6PR7hn52Q==", + "dev": true, + "dependencies": { + "comment-parser": "1.3.1", + "esquery": "^1.4.0", + "jsdoc-type-pratt-parser": "~3.0.1" + }, + "engines": { + "node": "^14 || ^16 || ^17 || ^18" + } + }, "node_modules/@gar/promisify": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@gar/promisify/-/promisify-1.1.2.tgz", @@ -4001,17 +4031,6 @@ "node": ">= 10.18.0" } }, - "node_modules/@lerna/validation-error": { - "version": "3.13.0", - "dev": true, - "license": "MIT", - "dependencies": { - "npmlog": "^4.1.2" - }, - "engines": { - "node": ">= 6.9.0" - } - }, "node_modules/@lerna/version": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/@lerna/version/-/version-4.0.0.tgz", @@ -4324,43 +4343,37 @@ } }, "node_modules/@microsoft/api-extractor": { - "version": "7.9.11", + "version": "7.20.1", + "resolved": "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.20.1.tgz", + "integrity": "sha512-T7cqcK+JpvHGOj7cD2ZCCWS7Xgru1uOqZwrV/FSUdyKVs5fopZcbBSuetwD/akst3O7Ypryg3UOLP54S/vnVmA==", "dev": true, - "license": "MIT", "dependencies": { - "@microsoft/api-extractor-model": "7.8.19", - "@microsoft/tsdoc": "0.12.19", - "@rushstack/node-core-library": "3.30.0", - "@rushstack/ts-command-line": "4.6.4", + "@microsoft/api-extractor-model": "7.16.0", + "@microsoft/tsdoc": "0.13.2", + "@microsoft/tsdoc-config": "~0.15.2", + "@rushstack/node-core-library": "3.45.1", + "@rushstack/rig-package": "0.3.8", + "@rushstack/ts-command-line": "4.10.7", "colors": "~1.2.1", "lodash": "~4.17.15", "resolve": "~1.17.0", "semver": "~7.3.0", "source-map": "~0.6.1", - "typescript": "~3.9.5" + "typescript": "~4.5.2" }, "bin": { "api-extractor": "bin/api-extractor" } }, "node_modules/@microsoft/api-extractor-model": { - "version": "7.8.19", - "dev": true, - "license": "MIT", - "dependencies": { - "@microsoft/tsdoc": "0.12.19", - "@rushstack/node-core-library": "3.30.0" - } - }, - "node_modules/@microsoft/api-extractor/node_modules/resolve": { - "version": "1.17.0", + "version": "7.16.0", + "resolved": "https://registry.npmjs.org/@microsoft/api-extractor-model/-/api-extractor-model-7.16.0.tgz", + "integrity": "sha512-0FOrbNIny8mzBrzQnSIkEjAXk0JMSnPmWYxt3ZDTPVg9S8xIPzB6lfgTg9+Mimu0RKCpGKBpd+v2WcR5vGzyUQ==", "dev": true, - "license": "MIT", "dependencies": { - "path-parse": "^1.0.6" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" + "@microsoft/tsdoc": "0.13.2", + "@microsoft/tsdoc-config": "~0.15.2", + "@rushstack/node-core-library": "3.45.1" } }, "node_modules/@microsoft/api-extractor/node_modules/semver": { @@ -4374,10 +4387,49 @@ "node": ">=10" } }, + "node_modules/@microsoft/api-extractor/node_modules/typescript": { + "version": "4.5.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz", + "integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, "node_modules/@microsoft/tsdoc": { - "version": "0.12.19", + "version": "0.13.2", + "resolved": "https://registry.npmjs.org/@microsoft/tsdoc/-/tsdoc-0.13.2.tgz", + "integrity": "sha512-WrHvO8PDL8wd8T2+zBGKrMwVL5IyzR3ryWUsl0PXgEV0QHup4mTLi0QcATefGI6Gx9Anu7vthPyyyLpY0EpiQg==", + "dev": true + }, + "node_modules/@microsoft/tsdoc-config": { + "version": "0.15.2", + "resolved": "https://registry.npmjs.org/@microsoft/tsdoc-config/-/tsdoc-config-0.15.2.tgz", + "integrity": "sha512-mK19b2wJHSdNf8znXSMYVShAHktVr/ib0Ck2FA3lsVBSEhSI/TfXT7DJQkAYgcztTuwazGcg58ZjYdk0hTCVrA==", "dev": true, - "license": "MIT" + "dependencies": { + "@microsoft/tsdoc": "0.13.2", + "ajv": "~6.12.6", + "jju": "~1.4.0", + "resolve": "~1.19.0" + } + }, + "node_modules/@microsoft/tsdoc-config/node_modules/resolve": { + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.19.0.tgz", + "integrity": "sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg==", + "dev": true, + "dependencies": { + "is-core-module": "^2.1.0", + "path-parse": "^1.0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } }, "node_modules/@mrmlnc/readdir-enhanced": { "version": "2.2.1", @@ -4898,194 +4950,18 @@ } }, "node_modules/@pixi-build-tools/api-extractor-lerna-monorepo": { - "version": "1.0.3", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@pixi-build-tools/api-extractor-lerna-monorepo/-/api-extractor-lerna-monorepo-1.1.0.tgz", + "integrity": "sha512-lBfrqrxXLoEjJcBe4umuXNezCvmciet9mA5V3gS/OvHUyimbwKhDAk4PHvxJDldmqd6vyJAZaka13gw011ji5w==", "dev": true, - "license": "MIT", "dependencies": { - "@lerna/project": "~3.21.0" + "@lerna/project": "^4.0.0" }, "bin": { "api-extractor-lerna-monorepo": "cli.js" }, "peerDependencies": { - "typescript": "^3.7.0" - } - }, - "node_modules/@pixi-build-tools/api-extractor-lerna-monorepo/node_modules/@lerna/package": { - "version": "3.16.0", - "dev": true, - "license": "MIT", - "dependencies": { - "load-json-file": "^5.3.0", - "npm-package-arg": "^6.1.0", - "write-pkg": "^3.1.0" - }, - "engines": { - "node": ">= 6.9.0" - } - }, - "node_modules/@pixi-build-tools/api-extractor-lerna-monorepo/node_modules/@lerna/project": { - "version": "3.21.0", - "dev": true, - "license": "MIT", - "dependencies": { - "@lerna/package": "3.16.0", - "@lerna/validation-error": "3.13.0", - "cosmiconfig": "^5.1.0", - "dedent": "^0.7.0", - "dot-prop": "^4.2.0", - "glob-parent": "^5.0.0", - "globby": "^9.2.0", - "load-json-file": "^5.3.0", - "npmlog": "^4.1.2", - "p-map": "^2.1.0", - "resolve-from": "^4.0.0", - "write-json-file": "^3.2.0" - }, - "engines": { - "node": ">= 6.9.0" - } - }, - "node_modules/@pixi-build-tools/api-extractor-lerna-monorepo/node_modules/dir-glob": { - "version": "2.2.2", - "dev": true, - "license": "MIT", - "dependencies": { - "path-type": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/@pixi-build-tools/api-extractor-lerna-monorepo/node_modules/glob-parent": { - "version": "5.1.2", - "dev": true, - "license": "ISC", - "dependencies": { - "is-glob": "^4.0.1" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/@pixi-build-tools/api-extractor-lerna-monorepo/node_modules/globby": { - "version": "9.2.0", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/glob": "^7.1.1", - "array-union": "^1.0.2", - "dir-glob": "^2.2.2", - "fast-glob": "^2.2.6", - "glob": "^7.1.3", - "ignore": "^4.0.3", - "pify": "^4.0.1", - "slash": "^2.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/@pixi-build-tools/api-extractor-lerna-monorepo/node_modules/ignore": { - "version": "4.0.6", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 4" - } - }, - "node_modules/@pixi-build-tools/api-extractor-lerna-monorepo/node_modules/is-glob": { - "version": "4.0.1", - "dev": true, - "license": "MIT", - "dependencies": { - "is-extglob": "^2.1.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/@pixi-build-tools/api-extractor-lerna-monorepo/node_modules/load-json-file": { - "version": "5.3.0", - "dev": true, - "license": "MIT", - "dependencies": { - "graceful-fs": "^4.1.15", - "parse-json": "^4.0.0", - "pify": "^4.0.1", - "strip-bom": "^3.0.0", - "type-fest": "^0.3.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/@pixi-build-tools/api-extractor-lerna-monorepo/node_modules/make-dir": { - "version": "2.1.0", - "dev": true, - "license": "MIT", - "dependencies": { - "pify": "^4.0.1", - "semver": "^5.6.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/@pixi-build-tools/api-extractor-lerna-monorepo/node_modules/p-map": { - "version": "2.1.0", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "node_modules/@pixi-build-tools/api-extractor-lerna-monorepo/node_modules/pify": { - "version": "4.0.1", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "node_modules/@pixi-build-tools/api-extractor-lerna-monorepo/node_modules/semver": { - "version": "5.7.1", - "dev": true, - "license": "ISC", - "bin": { - "semver": "bin/semver" - } - }, - "node_modules/@pixi-build-tools/api-extractor-lerna-monorepo/node_modules/slash": { - "version": "2.0.0", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "node_modules/@pixi-build-tools/api-extractor-lerna-monorepo/node_modules/type-fest": { - "version": "0.3.1", - "dev": true, - "license": "(MIT OR CC0-1.0)", - "engines": { - "node": ">=6" - } - }, - "node_modules/@pixi-build-tools/api-extractor-lerna-monorepo/node_modules/write-json-file": { - "version": "3.2.0", - "dev": true, - "license": "MIT", - "dependencies": { - "detect-indent": "^5.0.0", - "graceful-fs": "^4.1.15", - "make-dir": "^2.1.0", - "pify": "^4.0.1", - "sort-keys": "^2.0.0", - "write-file-atomic": "^2.4.2" - }, - "engines": { - "node": ">=6" + "typescript": "^4.0.0" } }, "node_modules/@pixi/accessibility": { @@ -5101,43 +4977,43 @@ "link": true }, "node_modules/@pixi/canvas-display": { - "resolved": "packages/canvas/canvas-display", + "resolved": "packages/canvas-display", "link": true }, "node_modules/@pixi/canvas-extract": { - "resolved": "packages/canvas/canvas-extract", + "resolved": "packages/canvas-extract", "link": true }, "node_modules/@pixi/canvas-graphics": { - "resolved": "packages/canvas/canvas-graphics", + "resolved": "packages/canvas-graphics", "link": true }, "node_modules/@pixi/canvas-mesh": { - "resolved": "packages/canvas/canvas-mesh", + "resolved": "packages/canvas-mesh", "link": true }, "node_modules/@pixi/canvas-particle-container": { - "resolved": "packages/canvas/canvas-particle-container", + "resolved": "packages/canvas-particle-container", "link": true }, "node_modules/@pixi/canvas-prepare": { - "resolved": "packages/canvas/canvas-prepare", + "resolved": "packages/canvas-prepare", "link": true }, "node_modules/@pixi/canvas-renderer": { - "resolved": "packages/canvas/canvas-renderer", + "resolved": "packages/canvas-renderer", "link": true }, "node_modules/@pixi/canvas-sprite": { - "resolved": "packages/canvas/canvas-sprite", + "resolved": "packages/canvas-sprite", "link": true }, "node_modules/@pixi/canvas-sprite-tiling": { - "resolved": "packages/canvas/canvas-sprite-tiling", + "resolved": "packages/canvas-sprite-tiling", "link": true }, "node_modules/@pixi/canvas-text": { - "resolved": "packages/canvas/canvas-text", + "resolved": "packages/canvas-text", "link": true }, "node_modules/@pixi/compressed-textures": { @@ -5157,12 +5033,13 @@ "link": true }, "node_modules/@pixi/eslint-config": { - "version": "2.0.1", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@pixi/eslint-config/-/eslint-config-4.0.1.tgz", + "integrity": "sha512-o75jXn96vBw37E/CCnwgfLOBVQAFf4Z7OyctLxcOmthQgr3iG4ILW2DbtZTh1+XuZ3eF2JqnLa9WjIgzZOAKMg==", "dev": true, - "license": "MIT", "dependencies": { - "@typescript-eslint/eslint-plugin": "^4.0.0", - "@typescript-eslint/parser": "^4.0.0" + "@typescript-eslint/eslint-plugin": "^5.0.0", + "@typescript-eslint/parser": "^5.0.0" }, "peerDependencies": { "eslint": ">=7.0.0", @@ -5178,27 +5055,27 @@ "link": true }, "node_modules/@pixi/filter-alpha": { - "resolved": "packages/filters/filter-alpha", + "resolved": "packages/filter-alpha", "link": true }, "node_modules/@pixi/filter-blur": { - "resolved": "packages/filters/filter-blur", + "resolved": "packages/filter-blur", "link": true }, "node_modules/@pixi/filter-color-matrix": { - "resolved": "packages/filters/filter-color-matrix", + "resolved": "packages/filter-color-matrix", "link": true }, "node_modules/@pixi/filter-displacement": { - "resolved": "packages/filters/filter-displacement", + "resolved": "packages/filter-displacement", "link": true }, "node_modules/@pixi/filter-fxaa": { - "resolved": "packages/filters/filter-fxaa", + "resolved": "packages/filter-fxaa", "link": true }, "node_modules/@pixi/filter-noise": { - "resolved": "packages/filters/filter-noise", + "resolved": "packages/filter-noise", "link": true }, "node_modules/@pixi/graphics": { @@ -5612,11 +5489,12 @@ "license": "MIT" }, "node_modules/@rushstack/node-core-library": { - "version": "3.30.0", + "version": "3.45.1", + "resolved": "https://registry.npmjs.org/@rushstack/node-core-library/-/node-core-library-3.45.1.tgz", + "integrity": "sha512-BwdssTNe007DNjDBxJgInHg8ePytIPyT0La7ZZSQZF9+rSkT42AygXPGvbGsyFfEntjr4X37zZSJI7yGzL16cQ==", "dev": true, - "license": "MIT", "dependencies": { - "@types/node": "10.17.13", + "@types/node": "12.20.24", "colors": "~1.2.1", "fs-extra": "~7.0.1", "import-lazy": "~4.0.0", @@ -5624,18 +5502,14 @@ "resolve": "~1.17.0", "semver": "~7.3.0", "timsort": "~0.3.0", - "z-schema": "~3.18.3" + "z-schema": "~5.0.2" } }, - "node_modules/@rushstack/node-core-library/node_modules/@types/node": { - "version": "10.17.13", - "dev": true, - "license": "MIT" - }, "node_modules/@rushstack/node-core-library/node_modules/fs-extra": { "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz", + "integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==", "dev": true, - "license": "MIT", "dependencies": { "graceful-fs": "^4.1.2", "jsonfile": "^4.0.0", @@ -5645,32 +5519,45 @@ "node": ">=6 <7 || >=8" } }, - "node_modules/@rushstack/node-core-library/node_modules/resolve": { - "version": "1.17.0", + "node_modules/@rushstack/node-core-library/node_modules/lru-cache": { + "version": "7.8.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.8.0.tgz", + "integrity": "sha512-AmXqneQZL3KZMIgBpaPTeI6pfwh+xQ2vutMsyqOu1TBdEXFZgpG/80wuJ531w2ZN7TI0/oc8CPxzh/DKQudZqg==", "dev": true, - "license": "MIT", - "dependencies": { - "path-parse": "^1.0.6" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" + "engines": { + "node": ">=12" } }, "node_modules/@rushstack/node-core-library/node_modules/semver": { - "version": "7.3.2", + "version": "7.3.6", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.6.tgz", + "integrity": "sha512-HZWqcgwLsjaX1HBD31msI/rXktuIhS+lWvdE4kN9z+8IVT4Itc7vqU2WvYsyD6/sjYCt4dEKH/m1M3dwI9CC5w==", "dev": true, - "license": "ISC", + "dependencies": { + "lru-cache": "^7.4.0" + }, "bin": { "semver": "bin/semver.js" }, "engines": { - "node": ">=10" + "node": "^10.0.0 || ^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, + "node_modules/@rushstack/rig-package": { + "version": "0.3.8", + "resolved": "https://registry.npmjs.org/@rushstack/rig-package/-/rig-package-0.3.8.tgz", + "integrity": "sha512-MDWg1xovea99PWloSiYMjFcCLsrdjFtYt6aOyHNs5ojn5mxrzR6U9F83hvbQjTWnKPMvZtr0vcek+4n+OQOp3Q==", + "dev": true, + "dependencies": { + "resolve": "~1.17.0", + "strip-json-comments": "~3.1.1" } }, "node_modules/@rushstack/ts-command-line": { - "version": "4.6.4", + "version": "4.10.7", + "resolved": "https://registry.npmjs.org/@rushstack/ts-command-line/-/ts-command-line-4.10.7.tgz", + "integrity": "sha512-CjS+DfNXUSO5Ab2wD1GBGtUTnB02OglRWGqfaTcac9Jn45V5MeUOsq/wA8wEeS5Y/3TZ2P1k+IWdVDiuOFP9Og==", "dev": true, - "license": "MIT", "dependencies": { "@types/argparse": "1.0.38", "argparse": "~1.0.9", @@ -5740,8 +5627,9 @@ }, "node_modules/@types/argparse": { "version": "1.0.38", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/@types/argparse/-/argparse-1.0.38.tgz", + "integrity": "sha512-ebDJ9b0e702Yr7pWgB0jzm+CX4Srzz8RcXtLJDJB+BSccqMa36uyH/zUsSYao5+BD1ytv3k3rPYCq4mAE1hsXA==", + "dev": true }, "node_modules/@types/buble": { "version": "0.19.2", @@ -5751,6 +5639,12 @@ "magic-string": "^0.25.0" } }, + "node_modules/@types/chai": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.1.tgz", + "integrity": "sha512-/zPMqDkzSZ8t3VtxOa4KPq7uzzW978M9Tvh+j7GHKuo6k6GTLxPJ4J5gE5cjfJ26pnXst0N5Hax8Sr0T2Mi9zQ==", + "dev": true + }, "node_modules/@types/color-name": { "version": "1.1.1", "dev": true, @@ -5775,9 +5669,10 @@ } }, "node_modules/@types/json-schema": { - "version": "7.0.6", - "dev": true, - "license": "MIT" + "version": "7.0.11", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", + "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", + "dev": true }, "node_modules/@types/minimatch": { "version": "3.0.3", @@ -5796,9 +5691,10 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "12.7.5", - "dev": true, - "license": "MIT" + "version": "12.20.24", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.24.tgz", + "integrity": "sha512-yxDeaQIAJlMav7fH5AQqPH1u8YIuhYJXYBzxaQ4PifsU0GDO38MSdmEDeRlIxrKbC6NbEaaEHDanWb+y30U8SQ==", + "dev": true }, "node_modules/@types/normalize-package-data": { "version": "2.4.0", @@ -5826,29 +5722,57 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/sinon": { + "version": "10.0.11", + "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-10.0.11.tgz", + "integrity": "sha512-dmZsHlBsKUtBpHriNjlK0ndlvEh8dcb9uV9Afsbt89QIyydpC7NcR+nWlAhASfy3GHnxTl4FX/aKE7XZUt/B4g==", + "dev": true, + "dependencies": { + "@types/sinonjs__fake-timers": "*" + } + }, + "node_modules/@types/sinon-chai": { + "version": "3.2.8", + "resolved": "https://registry.npmjs.org/@types/sinon-chai/-/sinon-chai-3.2.8.tgz", + "integrity": "sha512-d4ImIQbT/rKMG8+AXpmcan5T2/PNeSjrYhvkwet6z0p8kzYtfgA32xzOBlbU0yqJfq+/0Ml805iFoODO0LP5/g==", + "dev": true, + "dependencies": { + "@types/chai": "*", + "@types/sinon": "*" + } + }, + "node_modules/@types/sinonjs__fake-timers": { + "version": "8.1.2", + "resolved": "https://registry.npmjs.org/@types/sinonjs__fake-timers/-/sinonjs__fake-timers-8.1.2.tgz", + "integrity": "sha512-9GcLXF0/v3t80caGs5p2rRfkB+a8VBGLJZVih6CNFkx8IZ994wiKKLSRs9nuFwk1HevWs/1mnUmkApGrSGsShA==", + "dev": true + }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "4.12.0", + "version": "5.23.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.23.0.tgz", + "integrity": "sha512-hEcSmG4XodSLiAp1uxv/OQSGsDY6QN3TcRU32gANp+19wGE1QQZLRS8/GV58VRUoXhnkuJ3ZxNQ3T6Z6zM59DA==", "dev": true, - "license": "MIT", "dependencies": { - "@typescript-eslint/experimental-utils": "4.12.0", - "@typescript-eslint/scope-manager": "4.12.0", - "debug": "^4.1.1", + "@typescript-eslint/scope-manager": "5.23.0", + "@typescript-eslint/type-utils": "5.23.0", + "@typescript-eslint/utils": "5.23.0", + "debug": "^4.3.2", "functional-red-black-tree": "^1.0.1", - "regexpp": "^3.0.0", - "semver": "^7.3.2", - "tsutils": "^3.17.1" + "ignore": "^5.1.8", + "regexpp": "^3.2.0", + "semver": "^7.3.5", + "tsutils": "^3.21.0" }, "engines": { - "node": "^10.12.0 || >=12.0.0" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "@typescript-eslint/parser": "^4.0.0", - "eslint": "^5.0.0 || ^6.0.0 || ^7.0.0" + "@typescript-eslint/parser": "^5.0.0", + "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" }, "peerDependenciesMeta": { "typescript": { @@ -5857,9 +5781,10 @@ } }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/debug": { - "version": "4.3.1", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dev": true, - "license": "MIT", "dependencies": { "ms": "2.1.2" }, @@ -5874,8 +5799,9 @@ }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/lru-cache": { "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "dev": true, - "license": "ISC", "dependencies": { "yallist": "^4.0.0" }, @@ -5885,13 +5811,15 @@ }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/ms": { "version": "2.1.2", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/semver": { - "version": "7.3.4", + "version": "7.3.7", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", + "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", "dev": true, - "license": "ISC", "dependencies": { "lru-cache": "^6.0.0" }, @@ -5904,51 +5832,30 @@ }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/yallist": { "version": "4.0.0", - "dev": true, - "license": "ISC" - }, - "node_modules/@typescript-eslint/experimental-utils": { - "version": "4.12.0", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/json-schema": "^7.0.3", - "@typescript-eslint/scope-manager": "4.12.0", - "@typescript-eslint/types": "4.12.0", - "@typescript-eslint/typescript-estree": "4.12.0", - "eslint-scope": "^5.0.0", - "eslint-utils": "^2.0.0" - }, - "engines": { - "node": "^10.12.0 || >=12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "eslint": "*" - } + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true }, "node_modules/@typescript-eslint/parser": { - "version": "4.12.0", + "version": "5.23.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.23.0.tgz", + "integrity": "sha512-V06cYUkqcGqpFjb8ttVgzNF53tgbB/KoQT/iB++DOIExKmzI9vBJKjZKt/6FuV9c+zrDsvJKbJ2DOCYwX91cbw==", "dev": true, - "license": "BSD-2-Clause", "dependencies": { - "@typescript-eslint/scope-manager": "4.12.0", - "@typescript-eslint/types": "4.12.0", - "@typescript-eslint/typescript-estree": "4.12.0", - "debug": "^4.1.1" + "@typescript-eslint/scope-manager": "5.23.0", + "@typescript-eslint/types": "5.23.0", + "@typescript-eslint/typescript-estree": "5.23.0", + "debug": "^4.3.2" }, "engines": { - "node": "^10.12.0 || >=12.0.0" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "eslint": "^5.0.0 || ^6.0.0 || ^7.0.0" + "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" }, "peerDependenciesMeta": { "typescript": { @@ -5957,9 +5864,10 @@ } }, "node_modules/@typescript-eslint/parser/node_modules/debug": { - "version": "4.3.1", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dev": true, - "license": "MIT", "dependencies": { "ms": "2.1.2" }, @@ -5974,31 +5882,83 @@ }, "node_modules/@typescript-eslint/parser/node_modules/ms": { "version": "2.1.2", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true }, "node_modules/@typescript-eslint/scope-manager": { - "version": "4.12.0", + "version": "5.23.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.23.0.tgz", + "integrity": "sha512-EhjaFELQHCRb5wTwlGsNMvzK9b8Oco4aYNleeDlNuL6qXWDF47ch4EhVNPh8Rdhf9tmqbN4sWDk/8g+Z/J8JVw==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "5.23.0", + "@typescript-eslint/visitor-keys": "5.23.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/type-utils": { + "version": "5.23.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.23.0.tgz", + "integrity": "sha512-iuI05JsJl/SUnOTXA9f4oI+/4qS/Zcgk+s2ir+lRmXI+80D8GaGwoUqs4p+X+4AxDolPpEpVUdlEH4ADxFy4gw==", "dev": true, - "license": "MIT", "dependencies": { - "@typescript-eslint/types": "4.12.0", - "@typescript-eslint/visitor-keys": "4.12.0" + "@typescript-eslint/utils": "5.23.0", + "debug": "^4.3.2", + "tsutils": "^3.21.0" }, "engines": { - "node": "^8.10.0 || ^10.13.0 || >=11.10.1" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "*" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } } }, + "node_modules/@typescript-eslint/type-utils/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/type-utils/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, "node_modules/@typescript-eslint/types": { - "version": "4.12.0", + "version": "5.23.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.23.0.tgz", + "integrity": "sha512-NfBsV/h4dir/8mJwdZz7JFibaKC3E/QdeMEDJhiAE3/eMkoniZ7MjbEMCGXw6MZnZDMN3G9S0mH/6WUIj91dmw==", "dev": true, - "license": "MIT", "engines": { - "node": "^8.10.0 || ^10.13.0 || >=11.10.1" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "funding": { "type": "opencollective", @@ -6006,21 +5966,21 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "4.12.0", + "version": "5.23.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.23.0.tgz", + "integrity": "sha512-xE9e0lrHhI647SlGMl+m+3E3CKPF1wzvvOEWnuE3CCjjT7UiRnDGJxmAcVKJIlFgK6DY9RB98eLr1OPigPEOGg==", "dev": true, - "license": "BSD-2-Clause", "dependencies": { - "@typescript-eslint/types": "4.12.0", - "@typescript-eslint/visitor-keys": "4.12.0", - "debug": "^4.1.1", - "globby": "^11.0.1", - "is-glob": "^4.0.1", - "lodash": "^4.17.15", - "semver": "^7.3.2", - "tsutils": "^3.17.1" + "@typescript-eslint/types": "5.23.0", + "@typescript-eslint/visitor-keys": "5.23.0", + "debug": "^4.3.2", + "globby": "^11.0.4", + "is-glob": "^4.0.3", + "semver": "^7.3.5", + "tsutils": "^3.21.0" }, "engines": { - "node": "^10.12.0 || >=12.0.0" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "funding": { "type": "opencollective", @@ -6033,9 +5993,10 @@ } }, "node_modules/@typescript-eslint/typescript-estree/node_modules/debug": { - "version": "4.3.1", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dev": true, - "license": "MIT", "dependencies": { "ms": "2.1.2" }, @@ -6049,9 +6010,10 @@ } }, "node_modules/@typescript-eslint/typescript-estree/node_modules/is-glob": { - "version": "4.0.1", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", "dev": true, - "license": "MIT", "dependencies": { "is-extglob": "^2.1.1" }, @@ -6061,8 +6023,9 @@ }, "node_modules/@typescript-eslint/typescript-estree/node_modules/lru-cache": { "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "dev": true, - "license": "ISC", "dependencies": { "yallist": "^4.0.0" }, @@ -6072,13 +6035,15 @@ }, "node_modules/@typescript-eslint/typescript-estree/node_modules/ms": { "version": "2.1.2", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true }, "node_modules/@typescript-eslint/typescript-estree/node_modules/semver": { - "version": "7.3.4", + "version": "7.3.7", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", + "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", "dev": true, - "license": "ISC", "dependencies": { "lru-cache": "^6.0.0" }, @@ -6091,19 +6056,72 @@ }, "node_modules/@typescript-eslint/typescript-estree/node_modules/yallist": { "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, + "node_modules/@typescript-eslint/utils": { + "version": "5.23.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.23.0.tgz", + "integrity": "sha512-dbgaKN21drqpkbbedGMNPCtRPZo1IOUr5EI9Jrrh99r5UW5Q0dz46RKXeSBoPV+56R6dFKpbrdhgUNSJsDDRZA==", "dev": true, - "license": "ISC" + "dependencies": { + "@types/json-schema": "^7.0.9", + "@typescript-eslint/scope-manager": "5.23.0", + "@typescript-eslint/types": "5.23.0", + "@typescript-eslint/typescript-estree": "5.23.0", + "eslint-scope": "^5.1.1", + "eslint-utils": "^3.0.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + } }, - "node_modules/@typescript-eslint/visitor-keys": { - "version": "4.12.0", + "node_modules/@typescript-eslint/utils/node_modules/eslint-utils": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz", + "integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==", "dev": true, - "license": "MIT", "dependencies": { - "@typescript-eslint/types": "4.12.0", "eslint-visitor-keys": "^2.0.0" }, "engines": { - "node": "^8.10.0 || ^10.13.0 || >=11.10.1" + "node": "^10.0.0 || ^12.0.0 || >= 14.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/mysticatea" + }, + "peerDependencies": { + "eslint": ">=5" + } + }, + "node_modules/@typescript-eslint/utils/node_modules/eslint-visitor-keys": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", + "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "5.23.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.23.0.tgz", + "integrity": "sha512-Vd4mFNchU62sJB8pX19ZSPog05B0Y0CE2UxAZPT5k4iqhRYjPnqyY3woMxCd0++t9OTqkgjST+1ydLBi7e2Fvg==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "5.23.0", + "eslint-visitor-keys": "^3.0.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "funding": { "type": "opencollective", @@ -6111,11 +6129,12 @@ } }, "node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys": { - "version": "2.0.0", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", + "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", "dev": true, - "license": "Apache-2.0", "engines": { - "node": ">=10" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, "node_modules/@ungap/promise-all-settled": { @@ -7645,36 +7664,6 @@ "dev": true, "license": "MIT" }, - "node_modules/caller-callsite": { - "version": "2.0.0", - "dev": true, - "license": "MIT", - "dependencies": { - "callsites": "^2.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/caller-path": { - "version": "2.0.0", - "dev": true, - "license": "MIT", - "dependencies": { - "caller-callsite": "^2.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/callsites": { - "version": "2.0.0", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=4" - } - }, "node_modules/camelcase": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", @@ -8100,8 +8089,9 @@ }, "node_modules/colors": { "version": "1.2.5", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.2.5.tgz", + "integrity": "sha512-erNRLao/Y3Fv54qUa0LBB+//Uf3YwMUmdJinN20yMXm9zdKKqH9wt7R9IIVZ+K7ShzfpLV/Zg8+VyrBJYB4lpg==", "dev": true, - "license": "MIT", "engines": { "node": ">=0.1.90" } @@ -8134,6 +8124,15 @@ "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", "dev": true }, + "node_modules/comment-parser": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.3.1.tgz", + "integrity": "sha512-B52sN2VNghyq5ofvUsqZjmk6YkihBX5vMSChmSK9v4ShjKf3Vk5Xcmgpw4o+iIgtrnM/u5FiMpz9VKb8lpBveA==", + "dev": true, + "engines": { + "node": ">= 12.0.0" + } + }, "node_modules/common-path-prefix": { "version": "3.0.0", "dev": true, @@ -8779,21 +8778,6 @@ "dev": true, "license": "MIT" }, - "node_modules/cosmiconfig": { - "version": "5.1.0", - "dev": true, - "license": "MIT", - "dependencies": { - "import-fresh": "^2.0.0", - "is-directory": "^0.3.1", - "js-yaml": "^3.9.0", - "lodash.get": "^4.4.2", - "parse-json": "^4.0.0" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/cross-env": { "version": "5.2.0", "dev": true, @@ -9151,17 +9135,6 @@ "node": ">=6.0.0" } }, - "node_modules/dot-prop": { - "version": "4.2.0", - "dev": true, - "license": "MIT", - "dependencies": { - "is-obj": "^1.0.0" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/duplexer": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.2.tgz", @@ -9442,12 +9415,102 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/eslint-plugin-jsdoc": { + "version": "39.2.9", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-39.2.9.tgz", + "integrity": "sha512-gaPYJT94rWlWyQcisQyyEJHtLaaJqN4baFlLCEr/LcXVibS9wzQTL2dskqk327ggwqQopR+Xecu2Lng1IJ9Ypw==", + "dev": true, + "dependencies": { + "@es-joy/jsdoccomment": "~0.29.0", + "comment-parser": "1.3.1", + "debug": "^4.3.4", + "escape-string-regexp": "^4.0.0", + "esquery": "^1.4.0", + "semver": "^7.3.7", + "spdx-expression-parse": "^3.0.1" + }, + "engines": { + "node": "^14 || ^16 || ^17 || ^18" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + } + }, + "node_modules/eslint-plugin-jsdoc/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/eslint-plugin-jsdoc/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint-plugin-jsdoc/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/eslint-plugin-jsdoc/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node_modules/eslint-plugin-jsdoc/node_modules/semver": { + "version": "7.3.7", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", + "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/eslint-plugin-jsdoc/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, "node_modules/eslint-scope": { - "version": "5.1.0", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", + "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", "dev": true, - "license": "BSD-2-Clause", "dependencies": { - "esrecurse": "^4.1.0", + "esrecurse": "^4.3.0", "estraverse": "^4.1.1" }, "engines": { @@ -9740,9 +9803,10 @@ } }, "node_modules/esquery": { - "version": "1.3.1", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", + "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", "dev": true, - "license": "BSD-3-Clause", "dependencies": { "estraverse": "^5.1.0" }, @@ -9759,20 +9823,31 @@ } }, "node_modules/esrecurse": { - "version": "4.2.1", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", "dev": true, - "license": "BSD-2-Clause", "dependencies": { - "estraverse": "^4.1.0" + "estraverse": "^5.2.0" }, "engines": { "node": ">=4.0" } }, + "node_modules/esrecurse/node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "engines": { + "node": ">=4.0" + } + }, "node_modules/estraverse": { "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", "dev": true, - "license": "BSD-2-Clause", "engines": { "node": ">=4.0" } @@ -10645,19 +10720,6 @@ ], "license": "MIT" }, - "node_modules/fs-extra": { - "version": "8.1.0", - "dev": true, - "license": "MIT", - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - }, - "engines": { - "node": ">=6 <7 || >=8" - } - }, "node_modules/fs-minipass": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", @@ -11926,30 +11988,11 @@ "minimatch": "^3.0.4" } }, - "node_modules/import-fresh": { - "version": "2.0.0", - "dev": true, - "license": "MIT", - "dependencies": { - "caller-path": "^2.0.0", - "resolve-from": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/import-fresh/node_modules/resolve-from": { - "version": "3.0.0", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=4" - } - }, "node_modules/import-lazy": { "version": "4.0.0", + "resolved": "https://registry.npmjs.org/import-lazy/-/import-lazy-4.0.0.tgz", + "integrity": "sha512-rKtvo6a868b5Hu3heneU+L4yEQ4jYKLtjpnPeUdK7h0yzXGmyBTypknlkCvHFBqfX9YlorEiMM6Dnq/5atfHkw==", "dev": true, - "license": "MIT", "engines": { "node": ">=8" } @@ -12418,14 +12461,6 @@ "node": ">=0.10.0" } }, - "node_modules/is-directory": { - "version": "0.3.1", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/is-extendable": { "version": "0.1.1", "dev": true, @@ -12508,14 +12543,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-obj": { - "version": "1.0.1", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/is-plain-obj": { "version": "1.1.0", "dev": true, @@ -12975,8 +13002,9 @@ }, "node_modules/jju": { "version": "1.4.0", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/jju/-/jju-1.4.0.tgz", + "integrity": "sha1-o6vicYryQaKykE+EpiWXDzia4yo=", + "dev": true }, "node_modules/js-tokens": { "version": "4.0.0", @@ -13016,6 +13044,15 @@ "node": ">=6.0" } }, + "node_modules/jsdoc-type-pratt-parser": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-3.0.1.tgz", + "integrity": "sha512-vqMCdAFVIiFhVgBYE/X8naf3L/7qiJsaYWTfUJZZZ124dR3OUz9HrmaMUGpYIYAN4VSuodf6gIZY0e8ktPw9cg==", + "dev": true, + "engines": { + "node": ">=12.0.0" + } + }, "node_modules/jsesc": { "version": "0.5.0", "dev": true, @@ -13602,13 +13639,15 @@ }, "node_modules/lodash.get": { "version": "4.4.2", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", + "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=", + "dev": true }, "node_modules/lodash.isequal": { "version": "4.5.0", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", + "integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA=", + "dev": true }, "node_modules/lodash.ismatch": { "version": "4.4.0", @@ -13749,17 +13788,6 @@ "sourcemap-codec": "^1.4.4" } }, - "node_modules/make-dir": { - "version": "1.3.0", - "dev": true, - "license": "MIT", - "dependencies": { - "pify": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/make-error": { "version": "1.3.6", "dev": true, @@ -15252,17 +15280,6 @@ "integrity": "sha512-EPfafl6JL5/rU+ot6P3gRSCpPDW5VmIzX959Ob1+ySFUuuYHWHekXpwdUZcKP5C+DS4GEtdJluwBjnsNDl+fSA==", "dev": true }, - "node_modules/npm-package-arg": { - "version": "6.1.0", - "dev": true, - "license": "ISC", - "dependencies": { - "hosted-git-info": "^2.6.0", - "osenv": "^0.1.5", - "semver": "^5.5.0", - "validate-npm-package-name": "^3.0.0" - } - }, "node_modules/npm-packlist": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-2.2.2.tgz", @@ -16929,9 +16946,10 @@ } }, "node_modules/regexpp": { - "version": "3.1.0", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", + "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", "dev": true, - "license": "MIT", "engines": { "node": ">=8" }, @@ -17057,11 +17075,15 @@ "license": "ISC" }, "node_modules/resolve": { - "version": "1.10.0", + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", + "integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==", "dev": true, - "license": "MIT", "dependencies": { "path-parse": "^1.0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, "node_modules/resolve-cwd": { @@ -17898,9 +17920,10 @@ "license": "CC-BY-3.0" }, "node_modules/spdx-expression-parse": { - "version": "3.0.0", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz", + "integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==", "dev": true, - "license": "MIT", "dependencies": { "spdx-exceptions": "^2.1.0", "spdx-license-ids": "^3.0.0" @@ -18076,8 +18099,9 @@ }, "node_modules/string-argv": { "version": "0.3.1", + "resolved": "https://registry.npmjs.org/string-argv/-/string-argv-0.3.1.tgz", + "integrity": "sha512-a1uQGz7IyVy9YwhqjZIZu1c8JO8dNIe20xBmSS6qu9kv++k3JGzCVmprbNN5Kn+BgzD5E7YYwg1CcjuJMRNsvg==", "dev": true, - "license": "MIT", "engines": { "node": ">=0.6.19" } @@ -18527,8 +18551,9 @@ }, "node_modules/timsort": { "version": "0.3.0", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/timsort/-/timsort-0.3.0.tgz", + "integrity": "sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q=", + "dev": true }, "node_modules/tmp": { "version": "0.0.33", @@ -18676,9 +18701,10 @@ "license": "Apache-2.0" }, "node_modules/tsutils": { - "version": "3.18.0", + "version": "3.21.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", + "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==", "dev": true, - "license": "MIT", "dependencies": { "tslib": "^1.8.1" }, @@ -18758,9 +18784,10 @@ } }, "node_modules/typescript": { - "version": "3.9.5", + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.5.tgz", + "integrity": "sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==", "dev": true, - "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -19071,9 +19098,10 @@ } }, "node_modules/validator": { - "version": "8.2.0", + "version": "13.7.0", + "resolved": "https://registry.npmjs.org/validator/-/validator-13.7.0.tgz", + "integrity": "sha512-nYXQLCBkpJ8X6ltALua9dRrZDHVYxjJ1wgskNt1lH9fzGjs3tgojGSCBjmEPwkWS1y29+DrizMTW19Pr9uB2nw==", "dev": true, - "license": "MIT", "engines": { "node": ">= 0.10" } @@ -19644,34 +19672,6 @@ "signal-exit": "^3.0.2" } }, - "node_modules/write-json-file": { - "version": "2.3.0", - "dev": true, - "license": "MIT", - "dependencies": { - "detect-indent": "^5.0.0", - "graceful-fs": "^4.1.2", - "make-dir": "^1.0.0", - "pify": "^3.0.0", - "sort-keys": "^2.0.0", - "write-file-atomic": "^2.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/write-pkg": { - "version": "3.2.0", - "dev": true, - "license": "MIT", - "dependencies": { - "sort-keys": "^2.0.0", - "write-json-file": "^2.2.0" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/xtend": { "version": "4.0.1", "dev": true, @@ -19916,182 +19916,187 @@ } }, "node_modules/z-schema": { - "version": "3.18.4", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/z-schema/-/z-schema-5.0.2.tgz", + "integrity": "sha512-40TH47ukMHq5HrzkeVE40Ad7eIDKaRV2b+Qpi2prLc9X9eFJFzV7tMe5aH12e6avaSS/u5l653EQOv+J9PirPw==", "dev": true, - "license": "MIT", "dependencies": { - "lodash.get": "^4.0.0", - "lodash.isequal": "^4.0.0", - "validator": "^8.0.0" + "lodash.get": "^4.4.2", + "lodash.isequal": "^4.5.0", + "validator": "^13.7.0" }, "bin": { "z-schema": "bin/z-schema" }, + "engines": { + "node": ">=8.0.0" + }, "optionalDependencies": { "commander": "^2.7.1" } }, "packages/accessibility": { "name": "@pixi/accessibility", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/core": "6.3.0", - "@pixi/display": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/core": "6.4.2", + "@pixi/display": "6.4.2", + "@pixi/utils": "6.4.2" } }, "packages/app": { "name": "@pixi/app", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/core": "6.3.0", - "@pixi/display": "6.3.0" + "@pixi/core": "6.4.2", + "@pixi/display": "6.4.2" } }, "packages/basis": { "name": "@pixi/basis", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/compressed-textures": "6.3.0", - "@pixi/constants": "6.3.0", - "@pixi/core": "6.3.0", - "@pixi/loaders": "6.3.0", - "@pixi/runner": "6.3.0" + "@pixi/compressed-textures": "6.4.2", + "@pixi/constants": "6.4.2", + "@pixi/core": "6.4.2", + "@pixi/loaders": "6.4.2", + "@pixi/runner": "6.4.2" } }, - "packages/canvas/canvas-display": { + "packages/canvas-display": { "name": "@pixi/canvas-display", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/display": "6.3.0" + "@pixi/display": "6.4.2" } }, - "packages/canvas/canvas-extract": { + "packages/canvas-extract": { "name": "@pixi/canvas-extract", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/canvas-renderer": "6.3.0", - "@pixi/core": "6.3.0", - "@pixi/display": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/canvas-renderer": "6.4.2", + "@pixi/core": "6.4.2", + "@pixi/display": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/utils": "6.4.2" } }, - "packages/canvas/canvas-graphics": { + "packages/canvas-graphics": { "name": "@pixi/canvas-graphics", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/canvas-display": "6.3.0", - "@pixi/canvas-renderer": "6.3.0", - "@pixi/constants": "6.3.0", - "@pixi/core": "6.3.0", - "@pixi/graphics": "6.3.0", - "@pixi/math": "6.3.0" + "@pixi/canvas-display": "6.4.2", + "@pixi/canvas-renderer": "6.4.2", + "@pixi/constants": "6.4.2", + "@pixi/core": "6.4.2", + "@pixi/graphics": "6.4.2", + "@pixi/math": "6.4.2" } }, - "packages/canvas/canvas-mesh": { + "packages/canvas-mesh": { "name": "@pixi/canvas-mesh", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/canvas-display": "6.3.0", - "@pixi/canvas-renderer": "6.3.0", - "@pixi/constants": "6.3.0", - "@pixi/mesh": "6.3.0", - "@pixi/mesh-extras": "6.3.0", - "@pixi/settings": "6.3.0" + "@pixi/canvas-display": "6.4.2", + "@pixi/canvas-renderer": "6.4.2", + "@pixi/constants": "6.4.2", + "@pixi/mesh": "6.4.2", + "@pixi/mesh-extras": "6.4.2", + "@pixi/settings": "6.4.2" } }, - "packages/canvas/canvas-particle-container": { + "packages/canvas-particle-container": { "name": "@pixi/canvas-particle-container", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/particle-container": "6.3.0" + "@pixi/particle-container": "6.4.2" } }, - "packages/canvas/canvas-prepare": { + "packages/canvas-prepare": { "name": "@pixi/canvas-prepare", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/canvas-renderer": "6.3.0", - "@pixi/core": "6.3.0", - "@pixi/prepare": "6.3.0" + "@pixi/canvas-renderer": "6.4.2", + "@pixi/core": "6.4.2", + "@pixi/prepare": "6.4.2" } }, - "packages/canvas/canvas-renderer": { + "packages/canvas-renderer": { "name": "@pixi/canvas-renderer", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/constants": "6.3.0", - "@pixi/core": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/settings": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/constants": "6.4.2", + "@pixi/core": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/settings": "6.4.2", + "@pixi/utils": "6.4.2" } }, - "packages/canvas/canvas-sprite": { + "packages/canvas-sprite": { "name": "@pixi/canvas-sprite", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/canvas-display": "6.3.0", - "@pixi/canvas-renderer": "6.3.0", - "@pixi/constants": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/sprite": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/canvas-display": "6.4.2", + "@pixi/canvas-renderer": "6.4.2", + "@pixi/constants": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/sprite": "6.4.2", + "@pixi/utils": "6.4.2" } }, - "packages/canvas/canvas-sprite-tiling": { + "packages/canvas-sprite-tiling": { "name": "@pixi/canvas-sprite-tiling", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/canvas-renderer": "6.3.0", - "@pixi/canvas-sprite": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/sprite-tiling": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/canvas-renderer": "6.4.2", + "@pixi/canvas-sprite": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/sprite-tiling": "6.4.2", + "@pixi/utils": "6.4.2" } }, - "packages/canvas/canvas-text": { + "packages/canvas-text": { "name": "@pixi/canvas-text", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/canvas-sprite": "6.3.0", - "@pixi/sprite": "6.3.0", - "@pixi/text": "6.3.0" + "@pixi/canvas-sprite": "6.4.2", + "@pixi/sprite": "6.4.2", + "@pixi/text": "6.4.2" } }, "packages/compressed-textures": { "name": "@pixi/compressed-textures", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/constants": "6.3.0", - "@pixi/core": "6.3.0", - "@pixi/loaders": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/constants": "6.4.2", + "@pixi/core": "6.4.2", + "@pixi/loaders": "6.4.2", + "@pixi/settings": "6.4.2", + "@pixi/utils": "6.4.2" } }, "packages/constants": { "name": "@pixi/constants", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT" }, "packages/core": { "name": "@pixi/core", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "dependencies": { "@types/offscreencanvas": "^2019.6.4" @@ -20101,221 +20106,221 @@ "url": "https://opencollective.com/pixijs" }, "peerDependencies": { - "@pixi/constants": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/runner": "6.3.0", - "@pixi/settings": "6.3.0", - "@pixi/ticker": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/constants": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/runner": "6.4.2", + "@pixi/settings": "6.4.2", + "@pixi/ticker": "6.4.2", + "@pixi/utils": "6.4.2" } }, "packages/display": { "name": "@pixi/display", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/math": "6.3.0", - "@pixi/settings": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/math": "6.4.2", + "@pixi/settings": "6.4.2", + "@pixi/utils": "6.4.2" } }, "packages/events": { "name": "@pixi/events", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/display": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/display": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/utils": "6.4.2" } }, "packages/extract": { "name": "@pixi/extract", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/core": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/core": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/utils": "6.4.2" } }, - "packages/filters/filter-alpha": { + "packages/filter-alpha": { "name": "@pixi/filter-alpha", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/core": "6.3.0" + "@pixi/core": "6.4.2" } }, - "packages/filters/filter-blur": { + "packages/filter-blur": { "name": "@pixi/filter-blur", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/core": "6.3.0", - "@pixi/settings": "6.3.0" + "@pixi/core": "6.4.2", + "@pixi/settings": "6.4.2" } }, - "packages/filters/filter-color-matrix": { + "packages/filter-color-matrix": { "name": "@pixi/filter-color-matrix", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/core": "6.3.0" + "@pixi/core": "6.4.2" } }, - "packages/filters/filter-displacement": { + "packages/filter-displacement": { "name": "@pixi/filter-displacement", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/core": "6.3.0", - "@pixi/math": "6.3.0" + "@pixi/core": "6.4.2", + "@pixi/math": "6.4.2" } }, - "packages/filters/filter-fxaa": { + "packages/filter-fxaa": { "name": "@pixi/filter-fxaa", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/core": "6.3.0" + "@pixi/core": "6.4.2" } }, - "packages/filters/filter-noise": { + "packages/filter-noise": { "name": "@pixi/filter-noise", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/core": "6.3.0" + "@pixi/core": "6.4.2" } }, "packages/graphics": { "name": "@pixi/graphics", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/constants": "6.3.0", - "@pixi/core": "6.3.0", - "@pixi/display": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/sprite": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/constants": "6.4.2", + "@pixi/core": "6.4.2", + "@pixi/display": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/sprite": "6.4.2", + "@pixi/utils": "6.4.2" } }, "packages/graphics-extras": { "name": "@pixi/graphics-extras", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/graphics": "6.3.0", - "@pixi/math": "6.3.0" + "@pixi/graphics": "6.4.2", + "@pixi/math": "6.4.2" } }, "packages/interaction": { "name": "@pixi/interaction", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/core": "6.3.0", - "@pixi/display": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/ticker": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/core": "6.4.2", + "@pixi/display": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/ticker": "6.4.2", + "@pixi/utils": "6.4.2" } }, "packages/loaders": { "name": "@pixi/loaders", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/constants": "6.3.0", - "@pixi/core": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/constants": "6.4.2", + "@pixi/core": "6.4.2", + "@pixi/utils": "6.4.2" } }, "packages/math": { "name": "@pixi/math", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT" }, "packages/math-extras": { "name": "@pixi/math-extras", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/math": "6.3.0" + "@pixi/math": "6.4.2" } }, "packages/mesh": { "name": "@pixi/mesh", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/constants": "6.3.0", - "@pixi/core": "6.3.0", - "@pixi/display": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/settings": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/constants": "6.4.2", + "@pixi/core": "6.4.2", + "@pixi/display": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/settings": "6.4.2", + "@pixi/utils": "6.4.2" } }, "packages/mesh-extras": { "name": "@pixi/mesh-extras", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/constants": "6.3.0", - "@pixi/core": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/mesh": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/constants": "6.4.2", + "@pixi/core": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/mesh": "6.4.2", + "@pixi/utils": "6.4.2" } }, "packages/mixin-cache-as-bitmap": { "name": "@pixi/mixin-cache-as-bitmap", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/core": "6.3.0", - "@pixi/display": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/settings": "6.3.0", - "@pixi/sprite": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/core": "6.4.2", + "@pixi/display": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/settings": "6.4.2", + "@pixi/sprite": "6.4.2", + "@pixi/utils": "6.4.2" } }, "packages/mixin-get-child-by-name": { "name": "@pixi/mixin-get-child-by-name", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/display": "6.3.0" + "@pixi/display": "6.4.2" } }, "packages/mixin-get-global-position": { "name": "@pixi/mixin-get-global-position", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/display": "6.3.0", - "@pixi/math": "6.3.0" + "@pixi/display": "6.4.2", + "@pixi/math": "6.4.2" } }, "packages/particle-container": { "name": "@pixi/particle-container", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/constants": "6.3.0", - "@pixi/core": "6.3.0", - "@pixi/display": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/constants": "6.4.2", + "@pixi/core": "6.4.2", + "@pixi/display": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/utils": "6.4.2" } }, "packages/polyfill": { "name": "@pixi/polyfill", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "dependencies": { "object-assign": "^4.1.1", @@ -20328,25 +20333,25 @@ }, "packages/prepare": { "name": "@pixi/prepare", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/core": "6.3.0", - "@pixi/display": "6.3.0", - "@pixi/graphics": "6.3.0", - "@pixi/settings": "6.3.0", - "@pixi/text": "6.3.0", - "@pixi/ticker": "6.3.0" + "@pixi/core": "6.4.2", + "@pixi/display": "6.4.2", + "@pixi/graphics": "6.4.2", + "@pixi/settings": "6.4.2", + "@pixi/text": "6.4.2", + "@pixi/ticker": "6.4.2" } }, "packages/runner": { "name": "@pixi/runner", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT" }, "packages/settings": { "name": "@pixi/settings", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "dependencies": { "ismobilejs": "^1.1.0" @@ -20354,98 +20359,98 @@ }, "packages/sprite": { "name": "@pixi/sprite", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/constants": "6.3.0", - "@pixi/core": "6.3.0", - "@pixi/display": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/settings": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/constants": "6.4.2", + "@pixi/core": "6.4.2", + "@pixi/display": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/settings": "6.4.2", + "@pixi/utils": "6.4.2" } }, "packages/sprite-animated": { "name": "@pixi/sprite-animated", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/core": "6.3.0", - "@pixi/sprite": "6.3.0", - "@pixi/ticker": "6.3.0" + "@pixi/core": "6.4.2", + "@pixi/sprite": "6.4.2", + "@pixi/ticker": "6.4.2" } }, "packages/sprite-tiling": { "name": "@pixi/sprite-tiling", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/constants": "6.3.0", - "@pixi/core": "6.3.0", - "@pixi/display": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/sprite": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/constants": "6.4.2", + "@pixi/core": "6.4.2", + "@pixi/display": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/sprite": "6.4.2", + "@pixi/utils": "6.4.2" } }, "packages/spritesheet": { "name": "@pixi/spritesheet", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/core": "6.3.0", - "@pixi/loaders": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/core": "6.4.2", + "@pixi/loaders": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/utils": "6.4.2" } }, "packages/text": { "name": "@pixi/text", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/core": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/settings": "6.3.0", - "@pixi/sprite": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/core": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/settings": "6.4.2", + "@pixi/sprite": "6.4.2", + "@pixi/utils": "6.4.2" } }, "packages/text-bitmap": { "name": "@pixi/text-bitmap", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/constants": "6.3.0", - "@pixi/core": "6.3.0", - "@pixi/display": "6.3.0", - "@pixi/loaders": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/mesh": "6.3.0", - "@pixi/settings": "6.3.0", - "@pixi/text": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/constants": "6.4.2", + "@pixi/core": "6.4.2", + "@pixi/display": "6.4.2", + "@pixi/loaders": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/mesh": "6.4.2", + "@pixi/settings": "6.4.2", + "@pixi/text": "6.4.2", + "@pixi/utils": "6.4.2" } }, "packages/ticker": { "name": "@pixi/ticker", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/settings": "6.3.0" + "@pixi/settings": "6.4.2" } }, "packages/unsafe-eval": { "name": "@pixi/unsafe-eval", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "peerDependencies": { - "@pixi/core": "6.3.0" + "@pixi/core": "6.4.2" } }, "packages/utils": { "name": "@pixi/utils", - "version": "6.3.0", + "version": "6.4.2", "license": "MIT", "dependencies": { "@types/earcut": "^2.1.0", @@ -20457,29 +20462,29 @@ "css-color-names": "^1.0.1" }, "peerDependencies": { - "@pixi/constants": "6.3.0", - "@pixi/settings": "6.3.0" + "@pixi/constants": "6.4.2", + "@pixi/settings": "6.4.2" } }, "tools/integration-tests": { "name": "@internal/integration-tests", - "version": "6.3.0", + "version": "6.4.2", "devDependencies": { - "@pixi/canvas-display": "6.3.0", - "@pixi/canvas-graphics": "6.3.0", - "@pixi/canvas-mesh": "6.3.0", - "@pixi/canvas-renderer": "6.3.0", - "@pixi/canvas-sprite": "6.3.0", - "@pixi/canvas-text": "6.3.0", - "@pixi/core": "6.3.0", - "@pixi/display": "6.3.0", - "@pixi/graphics": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/mesh": "6.3.0", - "@pixi/mesh-extras": "6.3.0", - "@pixi/sprite": "6.3.0", - "@pixi/text": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/canvas-display": "6.4.2", + "@pixi/canvas-graphics": "6.4.2", + "@pixi/canvas-mesh": "6.4.2", + "@pixi/canvas-renderer": "6.4.2", + "@pixi/canvas-sprite": "6.4.2", + "@pixi/canvas-text": "6.4.2", + "@pixi/core": "6.4.2", + "@pixi/display": "6.4.2", + "@pixi/graphics": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/mesh": "6.4.2", + "@pixi/mesh-extras": "6.4.2", + "@pixi/sprite": "6.4.2", + "@pixi/text": "6.4.2", + "@pixi/utils": "6.4.2" } } }, @@ -20945,6 +20950,17 @@ "ms": "2.1.2" } }, + "fs-extra": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", + "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", + "dev": true, + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, "ms": { "version": "2.1.2", "dev": true @@ -20955,6 +20971,17 @@ } } }, + "@es-joy/jsdoccomment": { + "version": "0.29.0", + "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.29.0.tgz", + "integrity": "sha512-4yKy5t+/joLihG+ei6CCU6sc08sjUdEdXCQ2U+9h9VP13EiqHQ4YMgDC18ys/AsLdJDBX3KRx/AWY6PR7hn52Q==", + "dev": true, + "requires": { + "comment-parser": "1.3.1", + "esquery": "^1.4.0", + "jsdoc-type-pratt-parser": "~3.0.1" + } + }, "@gar/promisify": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@gar/promisify/-/promisify-1.1.2.tgz", @@ -20970,21 +20997,21 @@ "@internal/integration-tests": { "version": "file:tools/integration-tests", "requires": { - "@pixi/canvas-display": "6.3.0", - "@pixi/canvas-graphics": "6.3.0", - "@pixi/canvas-mesh": "6.3.0", - "@pixi/canvas-renderer": "6.3.0", - "@pixi/canvas-sprite": "6.3.0", - "@pixi/canvas-text": "6.3.0", - "@pixi/core": "6.3.0", - "@pixi/display": "6.3.0", - "@pixi/graphics": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/mesh": "6.3.0", - "@pixi/mesh-extras": "6.3.0", - "@pixi/sprite": "6.3.0", - "@pixi/text": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/canvas-display": "6.4.2", + "@pixi/canvas-graphics": "6.4.2", + "@pixi/canvas-mesh": "6.4.2", + "@pixi/canvas-renderer": "6.4.2", + "@pixi/canvas-sprite": "6.4.2", + "@pixi/canvas-text": "6.4.2", + "@pixi/core": "6.4.2", + "@pixi/display": "6.4.2", + "@pixi/graphics": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/mesh": "6.4.2", + "@pixi/mesh-extras": "6.4.2", + "@pixi/sprite": "6.4.2", + "@pixi/text": "6.4.2", + "@pixi/utils": "6.4.2" } }, "@istanbuljs/load-nyc-config": { @@ -23476,13 +23503,6 @@ "integrity": "sha512-WFsnlaE7SdOvjuyd05oKt8Leg3ENHICnvX3uYKKdByA+S3g+TCz38JsNs7OUZVt+ba63nC2nbXDlUnuT2Xbsfg==", "dev": true }, - "@lerna/validation-error": { - "version": "3.13.0", - "dev": true, - "requires": { - "npmlog": "^4.1.2" - } - }, "@lerna/version": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/@lerna/version/-/version-4.0.0.tgz", @@ -23720,46 +23740,78 @@ } }, "@microsoft/api-extractor": { - "version": "7.9.11", + "version": "7.20.1", + "resolved": "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.20.1.tgz", + "integrity": "sha512-T7cqcK+JpvHGOj7cD2ZCCWS7Xgru1uOqZwrV/FSUdyKVs5fopZcbBSuetwD/akst3O7Ypryg3UOLP54S/vnVmA==", "dev": true, "requires": { - "@microsoft/api-extractor-model": "7.8.19", - "@microsoft/tsdoc": "0.12.19", - "@rushstack/node-core-library": "3.30.0", - "@rushstack/ts-command-line": "4.6.4", + "@microsoft/api-extractor-model": "7.16.0", + "@microsoft/tsdoc": "0.13.2", + "@microsoft/tsdoc-config": "~0.15.2", + "@rushstack/node-core-library": "3.45.1", + "@rushstack/rig-package": "0.3.8", + "@rushstack/ts-command-line": "4.10.7", "colors": "~1.2.1", "lodash": "~4.17.15", "resolve": "~1.17.0", "semver": "~7.3.0", "source-map": "~0.6.1", - "typescript": "~3.9.5" + "typescript": "~4.5.2" }, "dependencies": { - "resolve": { - "version": "1.17.0", - "dev": true, - "requires": { - "path-parse": "^1.0.6" - } - }, "semver": { "version": "7.3.2", "dev": true + }, + "typescript": { + "version": "4.5.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz", + "integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==", + "dev": true } } }, "@microsoft/api-extractor-model": { - "version": "7.8.19", + "version": "7.16.0", + "resolved": "https://registry.npmjs.org/@microsoft/api-extractor-model/-/api-extractor-model-7.16.0.tgz", + "integrity": "sha512-0FOrbNIny8mzBrzQnSIkEjAXk0JMSnPmWYxt3ZDTPVg9S8xIPzB6lfgTg9+Mimu0RKCpGKBpd+v2WcR5vGzyUQ==", "dev": true, "requires": { - "@microsoft/tsdoc": "0.12.19", - "@rushstack/node-core-library": "3.30.0" + "@microsoft/tsdoc": "0.13.2", + "@microsoft/tsdoc-config": "~0.15.2", + "@rushstack/node-core-library": "3.45.1" } }, "@microsoft/tsdoc": { - "version": "0.12.19", + "version": "0.13.2", + "resolved": "https://registry.npmjs.org/@microsoft/tsdoc/-/tsdoc-0.13.2.tgz", + "integrity": "sha512-WrHvO8PDL8wd8T2+zBGKrMwVL5IyzR3ryWUsl0PXgEV0QHup4mTLi0QcATefGI6Gx9Anu7vthPyyyLpY0EpiQg==", "dev": true }, + "@microsoft/tsdoc-config": { + "version": "0.15.2", + "resolved": "https://registry.npmjs.org/@microsoft/tsdoc-config/-/tsdoc-config-0.15.2.tgz", + "integrity": "sha512-mK19b2wJHSdNf8znXSMYVShAHktVr/ib0Ck2FA3lsVBSEhSI/TfXT7DJQkAYgcztTuwazGcg58ZjYdk0hTCVrA==", + "dev": true, + "requires": { + "@microsoft/tsdoc": "0.13.2", + "ajv": "~6.12.6", + "jju": "~1.4.0", + "resolve": "~1.19.0" + }, + "dependencies": { + "resolve": { + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.19.0.tgz", + "integrity": "sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg==", + "dev": true, + "requires": { + "is-core-module": "^2.1.0", + "path-parse": "^1.0.6" + } + } + } + }, "@mrmlnc/readdir-enhanced": { "version": "2.2.1", "dev": true, @@ -24175,129 +24227,12 @@ } }, "@pixi-build-tools/api-extractor-lerna-monorepo": { - "version": "1.0.3", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@pixi-build-tools/api-extractor-lerna-monorepo/-/api-extractor-lerna-monorepo-1.1.0.tgz", + "integrity": "sha512-lBfrqrxXLoEjJcBe4umuXNezCvmciet9mA5V3gS/OvHUyimbwKhDAk4PHvxJDldmqd6vyJAZaka13gw011ji5w==", "dev": true, "requires": { - "@lerna/project": "~3.21.0" - }, - "dependencies": { - "@lerna/package": { - "version": "3.16.0", - "dev": true, - "requires": { - "load-json-file": "^5.3.0", - "npm-package-arg": "^6.1.0", - "write-pkg": "^3.1.0" - } - }, - "@lerna/project": { - "version": "3.21.0", - "dev": true, - "requires": { - "@lerna/package": "3.16.0", - "@lerna/validation-error": "3.13.0", - "cosmiconfig": "^5.1.0", - "dedent": "^0.7.0", - "dot-prop": "^4.2.0", - "glob-parent": "^5.0.0", - "globby": "^9.2.0", - "load-json-file": "^5.3.0", - "npmlog": "^4.1.2", - "p-map": "^2.1.0", - "resolve-from": "^4.0.0", - "write-json-file": "^3.2.0" - } - }, - "dir-glob": { - "version": "2.2.2", - "dev": true, - "requires": { - "path-type": "^3.0.0" - } - }, - "glob-parent": { - "version": "5.1.2", - "dev": true, - "requires": { - "is-glob": "^4.0.1" - } - }, - "globby": { - "version": "9.2.0", - "dev": true, - "requires": { - "@types/glob": "^7.1.1", - "array-union": "^1.0.2", - "dir-glob": "^2.2.2", - "fast-glob": "^2.2.6", - "glob": "^7.1.3", - "ignore": "^4.0.3", - "pify": "^4.0.1", - "slash": "^2.0.0" - } - }, - "ignore": { - "version": "4.0.6", - "dev": true - }, - "is-glob": { - "version": "4.0.1", - "dev": true, - "requires": { - "is-extglob": "^2.1.1" - } - }, - "load-json-file": { - "version": "5.3.0", - "dev": true, - "requires": { - "graceful-fs": "^4.1.15", - "parse-json": "^4.0.0", - "pify": "^4.0.1", - "strip-bom": "^3.0.0", - "type-fest": "^0.3.0" - } - }, - "make-dir": { - "version": "2.1.0", - "dev": true, - "requires": { - "pify": "^4.0.1", - "semver": "^5.6.0" - } - }, - "p-map": { - "version": "2.1.0", - "dev": true - }, - "pify": { - "version": "4.0.1", - "dev": true - }, - "semver": { - "version": "5.7.1", - "dev": true - }, - "slash": { - "version": "2.0.0", - "dev": true - }, - "type-fest": { - "version": "0.3.1", - "dev": true - }, - "write-json-file": { - "version": "3.2.0", - "dev": true, - "requires": { - "detect-indent": "^5.0.0", - "graceful-fs": "^4.1.15", - "make-dir": "^2.1.0", - "pify": "^4.0.1", - "sort-keys": "^2.0.0", - "write-file-atomic": "^2.4.2" - } - } + "@lerna/project": "^4.0.0" } }, "@pixi/accessibility": { @@ -24313,43 +24248,43 @@ "requires": {} }, "@pixi/canvas-display": { - "version": "file:packages/canvas/canvas-display", + "version": "file:packages/canvas-display", "requires": {} }, "@pixi/canvas-extract": { - "version": "file:packages/canvas/canvas-extract", + "version": "file:packages/canvas-extract", "requires": {} }, "@pixi/canvas-graphics": { - "version": "file:packages/canvas/canvas-graphics", + "version": "file:packages/canvas-graphics", "requires": {} }, "@pixi/canvas-mesh": { - "version": "file:packages/canvas/canvas-mesh", + "version": "file:packages/canvas-mesh", "requires": {} }, "@pixi/canvas-particle-container": { - "version": "file:packages/canvas/canvas-particle-container", + "version": "file:packages/canvas-particle-container", "requires": {} }, "@pixi/canvas-prepare": { - "version": "file:packages/canvas/canvas-prepare", + "version": "file:packages/canvas-prepare", "requires": {} }, "@pixi/canvas-renderer": { - "version": "file:packages/canvas/canvas-renderer", + "version": "file:packages/canvas-renderer", "requires": {} }, "@pixi/canvas-sprite": { - "version": "file:packages/canvas/canvas-sprite", + "version": "file:packages/canvas-sprite", "requires": {} }, "@pixi/canvas-sprite-tiling": { - "version": "file:packages/canvas/canvas-sprite-tiling", + "version": "file:packages/canvas-sprite-tiling", "requires": {} }, "@pixi/canvas-text": { - "version": "file:packages/canvas/canvas-text", + "version": "file:packages/canvas-text", "requires": {} }, "@pixi/compressed-textures": { @@ -24370,11 +24305,13 @@ "requires": {} }, "@pixi/eslint-config": { - "version": "2.0.1", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@pixi/eslint-config/-/eslint-config-4.0.1.tgz", + "integrity": "sha512-o75jXn96vBw37E/CCnwgfLOBVQAFf4Z7OyctLxcOmthQgr3iG4ILW2DbtZTh1+XuZ3eF2JqnLa9WjIgzZOAKMg==", "dev": true, "requires": { - "@typescript-eslint/eslint-plugin": "^4.0.0", - "@typescript-eslint/parser": "^4.0.0" + "@typescript-eslint/eslint-plugin": "^5.0.0", + "@typescript-eslint/parser": "^5.0.0" } }, "@pixi/events": { @@ -24386,27 +24323,27 @@ "requires": {} }, "@pixi/filter-alpha": { - "version": "file:packages/filters/filter-alpha", + "version": "file:packages/filter-alpha", "requires": {} }, "@pixi/filter-blur": { - "version": "file:packages/filters/filter-blur", + "version": "file:packages/filter-blur", "requires": {} }, "@pixi/filter-color-matrix": { - "version": "file:packages/filters/filter-color-matrix", + "version": "file:packages/filter-color-matrix", "requires": {} }, "@pixi/filter-displacement": { - "version": "file:packages/filters/filter-displacement", + "version": "file:packages/filter-displacement", "requires": {} }, "@pixi/filter-fxaa": { - "version": "file:packages/filters/filter-fxaa", + "version": "file:packages/filter-fxaa", "requires": {} }, "@pixi/filter-noise": { - "version": "file:packages/filters/filter-noise", + "version": "file:packages/filter-noise", "requires": {} }, "@pixi/graphics": { @@ -24736,10 +24673,12 @@ } }, "@rushstack/node-core-library": { - "version": "3.30.0", + "version": "3.45.1", + "resolved": "https://registry.npmjs.org/@rushstack/node-core-library/-/node-core-library-3.45.1.tgz", + "integrity": "sha512-BwdssTNe007DNjDBxJgInHg8ePytIPyT0La7ZZSQZF9+rSkT42AygXPGvbGsyFfEntjr4X37zZSJI7yGzL16cQ==", "dev": true, "requires": { - "@types/node": "10.17.13", + "@types/node": "12.20.24", "colors": "~1.2.1", "fs-extra": "~7.0.1", "import-lazy": "~4.0.0", @@ -24747,15 +24686,13 @@ "resolve": "~1.17.0", "semver": "~7.3.0", "timsort": "~0.3.0", - "z-schema": "~3.18.3" + "z-schema": "~5.0.2" }, "dependencies": { - "@types/node": { - "version": "10.17.13", - "dev": true - }, "fs-extra": { "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz", + "integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==", "dev": true, "requires": { "graceful-fs": "^4.1.2", @@ -24763,21 +24700,37 @@ "universalify": "^0.1.0" } }, - "resolve": { - "version": "1.17.0", + "lru-cache": { + "version": "7.8.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.8.0.tgz", + "integrity": "sha512-AmXqneQZL3KZMIgBpaPTeI6pfwh+xQ2vutMsyqOu1TBdEXFZgpG/80wuJ531w2ZN7TI0/oc8CPxzh/DKQudZqg==", + "dev": true + }, + "semver": { + "version": "7.3.6", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.6.tgz", + "integrity": "sha512-HZWqcgwLsjaX1HBD31msI/rXktuIhS+lWvdE4kN9z+8IVT4Itc7vqU2WvYsyD6/sjYCt4dEKH/m1M3dwI9CC5w==", "dev": true, "requires": { - "path-parse": "^1.0.6" + "lru-cache": "^7.4.0" } - }, - "semver": { - "version": "7.3.2", - "dev": true } } }, + "@rushstack/rig-package": { + "version": "0.3.8", + "resolved": "https://registry.npmjs.org/@rushstack/rig-package/-/rig-package-0.3.8.tgz", + "integrity": "sha512-MDWg1xovea99PWloSiYMjFcCLsrdjFtYt6aOyHNs5ojn5mxrzR6U9F83hvbQjTWnKPMvZtr0vcek+4n+OQOp3Q==", + "dev": true, + "requires": { + "resolve": "~1.17.0", + "strip-json-comments": "~3.1.1" + } + }, "@rushstack/ts-command-line": { - "version": "4.6.4", + "version": "4.10.7", + "resolved": "https://registry.npmjs.org/@rushstack/ts-command-line/-/ts-command-line-4.10.7.tgz", + "integrity": "sha512-CjS+DfNXUSO5Ab2wD1GBGtUTnB02OglRWGqfaTcac9Jn45V5MeUOsq/wA8wEeS5Y/3TZ2P1k+IWdVDiuOFP9Og==", "dev": true, "requires": { "@types/argparse": "1.0.38", @@ -24833,6 +24786,8 @@ }, "@types/argparse": { "version": "1.0.38", + "resolved": "https://registry.npmjs.org/@types/argparse/-/argparse-1.0.38.tgz", + "integrity": "sha512-ebDJ9b0e702Yr7pWgB0jzm+CX4Srzz8RcXtLJDJB+BSccqMa36uyH/zUsSYao5+BD1ytv3k3rPYCq4mAE1hsXA==", "dev": true }, "@types/buble": { @@ -24842,6 +24797,12 @@ "magic-string": "^0.25.0" } }, + "@types/chai": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.1.tgz", + "integrity": "sha512-/zPMqDkzSZ8t3VtxOa4KPq7uzzW978M9Tvh+j7GHKuo6k6GTLxPJ4J5gE5cjfJ26pnXst0N5Hax8Sr0T2Mi9zQ==", + "dev": true + }, "@types/color-name": { "version": "1.1.1", "dev": true @@ -24862,7 +24823,9 @@ } }, "@types/json-schema": { - "version": "7.0.6", + "version": "7.0.11", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", + "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", "dev": true }, "@types/minimatch": { @@ -24880,7 +24843,9 @@ "dev": true }, "@types/node": { - "version": "12.7.5", + "version": "12.20.24", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.24.tgz", + "integrity": "sha512-yxDeaQIAJlMav7fH5AQqPH1u8YIuhYJXYBzxaQ4PifsU0GDO38MSdmEDeRlIxrKbC6NbEaaEHDanWb+y30U8SQ==", "dev": true }, "@types/normalize-package-data": { @@ -24906,21 +24871,52 @@ "version": "6.0.3", "dev": true }, + "@types/sinon": { + "version": "10.0.11", + "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-10.0.11.tgz", + "integrity": "sha512-dmZsHlBsKUtBpHriNjlK0ndlvEh8dcb9uV9Afsbt89QIyydpC7NcR+nWlAhASfy3GHnxTl4FX/aKE7XZUt/B4g==", + "dev": true, + "requires": { + "@types/sinonjs__fake-timers": "*" + } + }, + "@types/sinon-chai": { + "version": "3.2.8", + "resolved": "https://registry.npmjs.org/@types/sinon-chai/-/sinon-chai-3.2.8.tgz", + "integrity": "sha512-d4ImIQbT/rKMG8+AXpmcan5T2/PNeSjrYhvkwet6z0p8kzYtfgA32xzOBlbU0yqJfq+/0Ml805iFoODO0LP5/g==", + "dev": true, + "requires": { + "@types/chai": "*", + "@types/sinon": "*" + } + }, + "@types/sinonjs__fake-timers": { + "version": "8.1.2", + "resolved": "https://registry.npmjs.org/@types/sinonjs__fake-timers/-/sinonjs__fake-timers-8.1.2.tgz", + "integrity": "sha512-9GcLXF0/v3t80caGs5p2rRfkB+a8VBGLJZVih6CNFkx8IZ994wiKKLSRs9nuFwk1HevWs/1mnUmkApGrSGsShA==", + "dev": true + }, "@typescript-eslint/eslint-plugin": { - "version": "4.12.0", + "version": "5.23.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.23.0.tgz", + "integrity": "sha512-hEcSmG4XodSLiAp1uxv/OQSGsDY6QN3TcRU32gANp+19wGE1QQZLRS8/GV58VRUoXhnkuJ3ZxNQ3T6Z6zM59DA==", "dev": true, "requires": { - "@typescript-eslint/experimental-utils": "4.12.0", - "@typescript-eslint/scope-manager": "4.12.0", - "debug": "^4.1.1", + "@typescript-eslint/scope-manager": "5.23.0", + "@typescript-eslint/type-utils": "5.23.0", + "@typescript-eslint/utils": "5.23.0", + "debug": "^4.3.2", "functional-red-black-tree": "^1.0.1", - "regexpp": "^3.0.0", - "semver": "^7.3.2", - "tsutils": "^3.17.1" + "ignore": "^5.1.8", + "regexpp": "^3.2.0", + "semver": "^7.3.5", + "tsutils": "^3.21.0" }, "dependencies": { "debug": { - "version": "4.3.1", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dev": true, "requires": { "ms": "2.1.2" @@ -24928,6 +24924,8 @@ }, "lru-cache": { "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "dev": true, "requires": { "yallist": "^4.0.0" @@ -24935,10 +24933,14 @@ }, "ms": { "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, "semver": { - "version": "7.3.4", + "version": "7.3.7", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", + "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", "dev": true, "requires": { "lru-cache": "^6.0.0" @@ -24946,34 +24948,28 @@ }, "yallist": { "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "dev": true } } }, - "@typescript-eslint/experimental-utils": { - "version": "4.12.0", - "dev": true, - "requires": { - "@types/json-schema": "^7.0.3", - "@typescript-eslint/scope-manager": "4.12.0", - "@typescript-eslint/types": "4.12.0", - "@typescript-eslint/typescript-estree": "4.12.0", - "eslint-scope": "^5.0.0", - "eslint-utils": "^2.0.0" - } - }, "@typescript-eslint/parser": { - "version": "4.12.0", + "version": "5.23.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.23.0.tgz", + "integrity": "sha512-V06cYUkqcGqpFjb8ttVgzNF53tgbB/KoQT/iB++DOIExKmzI9vBJKjZKt/6FuV9c+zrDsvJKbJ2DOCYwX91cbw==", "dev": true, "requires": { - "@typescript-eslint/scope-manager": "4.12.0", - "@typescript-eslint/types": "4.12.0", - "@typescript-eslint/typescript-estree": "4.12.0", - "debug": "^4.1.1" + "@typescript-eslint/scope-manager": "5.23.0", + "@typescript-eslint/types": "5.23.0", + "@typescript-eslint/typescript-estree": "5.23.0", + "debug": "^4.3.2" }, "dependencies": { "debug": { - "version": "4.3.1", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dev": true, "requires": { "ms": "2.1.2" @@ -24981,45 +24977,84 @@ }, "ms": { "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true } } }, "@typescript-eslint/scope-manager": { - "version": "4.12.0", + "version": "5.23.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.23.0.tgz", + "integrity": "sha512-EhjaFELQHCRb5wTwlGsNMvzK9b8Oco4aYNleeDlNuL6qXWDF47ch4EhVNPh8Rdhf9tmqbN4sWDk/8g+Z/J8JVw==", + "dev": true, + "requires": { + "@typescript-eslint/types": "5.23.0", + "@typescript-eslint/visitor-keys": "5.23.0" + } + }, + "@typescript-eslint/type-utils": { + "version": "5.23.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.23.0.tgz", + "integrity": "sha512-iuI05JsJl/SUnOTXA9f4oI+/4qS/Zcgk+s2ir+lRmXI+80D8GaGwoUqs4p+X+4AxDolPpEpVUdlEH4ADxFy4gw==", "dev": true, "requires": { - "@typescript-eslint/types": "4.12.0", - "@typescript-eslint/visitor-keys": "4.12.0" + "@typescript-eslint/utils": "5.23.0", + "debug": "^4.3.2", + "tsutils": "^3.21.0" + }, + "dependencies": { + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + } } }, "@typescript-eslint/types": { - "version": "4.12.0", + "version": "5.23.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.23.0.tgz", + "integrity": "sha512-NfBsV/h4dir/8mJwdZz7JFibaKC3E/QdeMEDJhiAE3/eMkoniZ7MjbEMCGXw6MZnZDMN3G9S0mH/6WUIj91dmw==", "dev": true }, "@typescript-eslint/typescript-estree": { - "version": "4.12.0", + "version": "5.23.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.23.0.tgz", + "integrity": "sha512-xE9e0lrHhI647SlGMl+m+3E3CKPF1wzvvOEWnuE3CCjjT7UiRnDGJxmAcVKJIlFgK6DY9RB98eLr1OPigPEOGg==", "dev": true, "requires": { - "@typescript-eslint/types": "4.12.0", - "@typescript-eslint/visitor-keys": "4.12.0", - "debug": "^4.1.1", - "globby": "^11.0.1", - "is-glob": "^4.0.1", - "lodash": "^4.17.15", - "semver": "^7.3.2", - "tsutils": "^3.17.1" + "@typescript-eslint/types": "5.23.0", + "@typescript-eslint/visitor-keys": "5.23.0", + "debug": "^4.3.2", + "globby": "^11.0.4", + "is-glob": "^4.0.3", + "semver": "^7.3.5", + "tsutils": "^3.21.0" }, "dependencies": { "debug": { - "version": "4.3.1", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dev": true, "requires": { "ms": "2.1.2" } }, "is-glob": { - "version": "4.0.1", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", "dev": true, "requires": { "is-extglob": "^2.1.1" @@ -25027,6 +25062,8 @@ }, "lru-cache": { "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "dev": true, "requires": { "yallist": "^4.0.0" @@ -25034,10 +25071,14 @@ }, "ms": { "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, "semver": { - "version": "7.3.4", + "version": "7.3.7", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", + "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", "dev": true, "requires": { "lru-cache": "^6.0.0" @@ -25045,20 +25086,57 @@ }, "yallist": { "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + } + } + }, + "@typescript-eslint/utils": { + "version": "5.23.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.23.0.tgz", + "integrity": "sha512-dbgaKN21drqpkbbedGMNPCtRPZo1IOUr5EI9Jrrh99r5UW5Q0dz46RKXeSBoPV+56R6dFKpbrdhgUNSJsDDRZA==", + "dev": true, + "requires": { + "@types/json-schema": "^7.0.9", + "@typescript-eslint/scope-manager": "5.23.0", + "@typescript-eslint/types": "5.23.0", + "@typescript-eslint/typescript-estree": "5.23.0", + "eslint-scope": "^5.1.1", + "eslint-utils": "^3.0.0" + }, + "dependencies": { + "eslint-utils": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz", + "integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==", + "dev": true, + "requires": { + "eslint-visitor-keys": "^2.0.0" + } + }, + "eslint-visitor-keys": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", + "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", "dev": true } } }, "@typescript-eslint/visitor-keys": { - "version": "4.12.0", + "version": "5.23.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.23.0.tgz", + "integrity": "sha512-Vd4mFNchU62sJB8pX19ZSPog05B0Y0CE2UxAZPT5k4iqhRYjPnqyY3woMxCd0++t9OTqkgjST+1ydLBi7e2Fvg==", "dev": true, "requires": { - "@typescript-eslint/types": "4.12.0", - "eslint-visitor-keys": "^2.0.0" + "@typescript-eslint/types": "5.23.0", + "eslint-visitor-keys": "^3.0.0" }, "dependencies": { "eslint-visitor-keys": { - "version": "2.0.0", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", + "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", "dev": true } } @@ -26169,24 +26247,6 @@ "version": "1.0.1", "dev": true }, - "caller-callsite": { - "version": "2.0.0", - "dev": true, - "requires": { - "callsites": "^2.0.0" - } - }, - "caller-path": { - "version": "2.0.0", - "dev": true, - "requires": { - "caller-callsite": "^2.0.0" - } - }, - "callsites": { - "version": "2.0.0", - "dev": true - }, "camelcase": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", @@ -26490,6 +26550,8 @@ }, "colors": { "version": "1.2.5", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.2.5.tgz", + "integrity": "sha512-erNRLao/Y3Fv54qUa0LBB+//Uf3YwMUmdJinN20yMXm9zdKKqH9wt7R9IIVZ+K7ShzfpLV/Zg8+VyrBJYB4lpg==", "dev": true }, "columnify": { @@ -26517,6 +26579,12 @@ "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", "dev": true }, + "comment-parser": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.3.1.tgz", + "integrity": "sha512-B52sN2VNghyq5ofvUsqZjmk6YkihBX5vMSChmSK9v4ShjKf3Vk5Xcmgpw4o+iIgtrnM/u5FiMpz9VKb8lpBveA==", + "dev": true + }, "common-path-prefix": { "version": "3.0.0", "dev": true @@ -26996,17 +27064,6 @@ "version": "1.0.2", "dev": true }, - "cosmiconfig": { - "version": "5.1.0", - "dev": true, - "requires": { - "import-fresh": "^2.0.0", - "is-directory": "^0.3.1", - "js-yaml": "^3.9.0", - "lodash.get": "^4.4.2", - "parse-json": "^4.0.0" - } - }, "cross-env": { "version": "5.2.0", "dev": true, @@ -27258,13 +27315,6 @@ "esutils": "^2.0.2" } }, - "dot-prop": { - "version": "4.2.0", - "dev": true, - "requires": { - "is-obj": "^1.0.0" - } - }, "duplexer": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.2.tgz", @@ -27616,11 +27666,75 @@ } } }, + "eslint-plugin-jsdoc": { + "version": "39.2.9", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-39.2.9.tgz", + "integrity": "sha512-gaPYJT94rWlWyQcisQyyEJHtLaaJqN4baFlLCEr/LcXVibS9wzQTL2dskqk327ggwqQopR+Xecu2Lng1IJ9Ypw==", + "dev": true, + "requires": { + "@es-joy/jsdoccomment": "~0.29.0", + "comment-parser": "1.3.1", + "debug": "^4.3.4", + "escape-string-regexp": "^4.0.0", + "esquery": "^1.4.0", + "semver": "^7.3.7", + "spdx-expression-parse": "^3.0.1" + }, + "dependencies": { + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true + }, + "lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "requires": { + "yallist": "^4.0.0" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "semver": { + "version": "7.3.7", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", + "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + }, + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + } + } + }, "eslint-scope": { - "version": "5.1.0", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", + "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", "dev": true, "requires": { - "esrecurse": "^4.1.0", + "esrecurse": "^4.3.0", "estraverse": "^4.1.1" } }, @@ -27661,7 +27775,9 @@ "dev": true }, "esquery": { - "version": "1.3.1", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", + "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", "dev": true, "requires": { "estraverse": "^5.1.0" @@ -27674,14 +27790,26 @@ } }, "esrecurse": { - "version": "4.2.1", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", "dev": true, "requires": { - "estraverse": "^4.1.0" + "estraverse": "^5.2.0" + }, + "dependencies": { + "estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true + } } }, "estraverse": { "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", "dev": true }, "estree-walker": { @@ -28274,15 +28402,6 @@ "version": "1.3.2", "dev": true }, - "fs-extra": { - "version": "8.1.0", - "dev": true, - "requires": { - "graceful-fs": "^4.2.0", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - } - }, "fs-minipass": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", @@ -29201,22 +29320,10 @@ "minimatch": "^3.0.4" } }, - "import-fresh": { - "version": "2.0.0", - "dev": true, - "requires": { - "caller-path": "^2.0.0", - "resolve-from": "^3.0.0" - }, - "dependencies": { - "resolve-from": { - "version": "3.0.0", - "dev": true - } - } - }, "import-lazy": { "version": "4.0.0", + "resolved": "https://registry.npmjs.org/import-lazy/-/import-lazy-4.0.0.tgz", + "integrity": "sha512-rKtvo6a868b5Hu3heneU+L4yEQ4jYKLtjpnPeUdK7h0yzXGmyBTypknlkCvHFBqfX9YlorEiMM6Dnq/5atfHkw==", "dev": true }, "import-local": { @@ -29554,10 +29661,6 @@ } } }, - "is-directory": { - "version": "0.3.1", - "dev": true - }, "is-extendable": { "version": "0.1.1", "dev": true @@ -29605,10 +29708,6 @@ "version": "1.0.5", "dev": true }, - "is-obj": { - "version": "1.0.1", - "dev": true - }, "is-plain-obj": { "version": "1.1.0", "dev": true @@ -29910,6 +30009,8 @@ }, "jju": { "version": "1.4.0", + "resolved": "https://registry.npmjs.org/jju/-/jju-1.4.0.tgz", + "integrity": "sha1-o6vicYryQaKykE+EpiWXDzia4yo=", "dev": true }, "js-tokens": { @@ -29941,6 +30042,12 @@ "skip-regex": "^1.0.2" } }, + "jsdoc-type-pratt-parser": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-3.0.1.tgz", + "integrity": "sha512-vqMCdAFVIiFhVgBYE/X8naf3L/7qiJsaYWTfUJZZZ124dR3OUz9HrmaMUGpYIYAN4VSuodf6gIZY0e8ktPw9cg==", + "dev": true + }, "jsesc": { "version": "0.5.0", "dev": true @@ -30395,10 +30502,14 @@ }, "lodash.get": { "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", + "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=", "dev": true }, "lodash.isequal": { "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", + "integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA=", "dev": true }, "lodash.ismatch": { @@ -30504,13 +30615,6 @@ "sourcemap-codec": "^1.4.4" } }, - "make-dir": { - "version": "1.3.0", - "dev": true, - "requires": { - "pify": "^3.0.0" - } - }, "make-error": { "version": "1.3.6", "dev": true @@ -31585,16 +31689,6 @@ "integrity": "sha512-EPfafl6JL5/rU+ot6P3gRSCpPDW5VmIzX959Ob1+ySFUuuYHWHekXpwdUZcKP5C+DS4GEtdJluwBjnsNDl+fSA==", "dev": true }, - "npm-package-arg": { - "version": "6.1.0", - "dev": true, - "requires": { - "hosted-git-info": "^2.6.0", - "osenv": "^0.1.5", - "semver": "^5.5.0", - "validate-npm-package-name": "^3.0.0" - } - }, "npm-packlist": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-2.2.2.tgz", @@ -32393,57 +32487,57 @@ "pixi.js": { "version": "file:bundles/pixi.js", "requires": { - "@pixi/accessibility": "6.3.0", - "@pixi/app": "6.3.0", - "@pixi/compressed-textures": "6.3.0", - "@pixi/constants": "6.3.0", - "@pixi/core": "6.3.0", - "@pixi/display": "6.3.0", - "@pixi/extract": "6.3.0", - "@pixi/filter-alpha": "6.3.0", - "@pixi/filter-blur": "6.3.0", - "@pixi/filter-color-matrix": "6.3.0", - "@pixi/filter-displacement": "6.3.0", - "@pixi/filter-fxaa": "6.3.0", - "@pixi/filter-noise": "6.3.0", - "@pixi/graphics": "6.3.0", - "@pixi/interaction": "6.3.0", - "@pixi/loaders": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/mesh": "6.3.0", - "@pixi/mesh-extras": "6.3.0", - "@pixi/mixin-cache-as-bitmap": "6.3.0", - "@pixi/mixin-get-child-by-name": "6.3.0", - "@pixi/mixin-get-global-position": "6.3.0", - "@pixi/particle-container": "6.3.0", - "@pixi/polyfill": "6.3.0", - "@pixi/prepare": "6.3.0", - "@pixi/runner": "6.3.0", - "@pixi/settings": "6.3.0", - "@pixi/sprite": "6.3.0", - "@pixi/sprite-animated": "6.3.0", - "@pixi/sprite-tiling": "6.3.0", - "@pixi/spritesheet": "6.3.0", - "@pixi/text": "6.3.0", - "@pixi/text-bitmap": "6.3.0", - "@pixi/ticker": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/accessibility": "6.4.2", + "@pixi/app": "6.4.2", + "@pixi/compressed-textures": "6.4.2", + "@pixi/constants": "6.4.2", + "@pixi/core": "6.4.2", + "@pixi/display": "6.4.2", + "@pixi/extract": "6.4.2", + "@pixi/filter-alpha": "6.4.2", + "@pixi/filter-blur": "6.4.2", + "@pixi/filter-color-matrix": "6.4.2", + "@pixi/filter-displacement": "6.4.2", + "@pixi/filter-fxaa": "6.4.2", + "@pixi/filter-noise": "6.4.2", + "@pixi/graphics": "6.4.2", + "@pixi/interaction": "6.4.2", + "@pixi/loaders": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/mesh": "6.4.2", + "@pixi/mesh-extras": "6.4.2", + "@pixi/mixin-cache-as-bitmap": "6.4.2", + "@pixi/mixin-get-child-by-name": "6.4.2", + "@pixi/mixin-get-global-position": "6.4.2", + "@pixi/particle-container": "6.4.2", + "@pixi/polyfill": "6.4.2", + "@pixi/prepare": "6.4.2", + "@pixi/runner": "6.4.2", + "@pixi/settings": "6.4.2", + "@pixi/sprite": "6.4.2", + "@pixi/sprite-animated": "6.4.2", + "@pixi/sprite-tiling": "6.4.2", + "@pixi/spritesheet": "6.4.2", + "@pixi/text": "6.4.2", + "@pixi/text-bitmap": "6.4.2", + "@pixi/ticker": "6.4.2", + "@pixi/utils": "6.4.2" } }, "pixi.js-legacy": { "version": "file:bundles/pixi.js-legacy", "requires": { - "@pixi/canvas-display": "6.3.0", - "@pixi/canvas-extract": "6.3.0", - "@pixi/canvas-graphics": "6.3.0", - "@pixi/canvas-mesh": "6.3.0", - "@pixi/canvas-particle-container": "6.3.0", - "@pixi/canvas-prepare": "6.3.0", - "@pixi/canvas-renderer": "6.3.0", - "@pixi/canvas-sprite": "6.3.0", - "@pixi/canvas-sprite-tiling": "6.3.0", - "@pixi/canvas-text": "6.3.0", - "pixi.js": "6.3.0" + "@pixi/canvas-display": "6.4.2", + "@pixi/canvas-extract": "6.4.2", + "@pixi/canvas-graphics": "6.4.2", + "@pixi/canvas-mesh": "6.4.2", + "@pixi/canvas-particle-container": "6.4.2", + "@pixi/canvas-prepare": "6.4.2", + "@pixi/canvas-renderer": "6.4.2", + "@pixi/canvas-sprite": "6.4.2", + "@pixi/canvas-sprite-tiling": "6.4.2", + "@pixi/canvas-text": "6.4.2", + "pixi.js": "6.4.2" } }, "pkg-dir": { @@ -32842,7 +32936,9 @@ } }, "regexpp": { - "version": "3.1.0", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", + "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", "dev": true }, "regjsgen": { @@ -32922,7 +33018,9 @@ "dev": true }, "resolve": { - "version": "1.10.0", + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", + "integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==", "dev": true, "requires": { "path-parse": "^1.0.6" @@ -33511,7 +33609,9 @@ "dev": true }, "spdx-expression-parse": { - "version": "3.0.0", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz", + "integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==", "dev": true, "requires": { "spdx-exceptions": "^2.1.0", @@ -33640,6 +33740,8 @@ }, "string-argv": { "version": "0.3.1", + "resolved": "https://registry.npmjs.org/string-argv/-/string-argv-0.3.1.tgz", + "integrity": "sha512-a1uQGz7IyVy9YwhqjZIZu1c8JO8dNIe20xBmSS6qu9kv++k3JGzCVmprbNN5Kn+BgzD5E7YYwg1CcjuJMRNsvg==", "dev": true }, "string-width": { @@ -33952,6 +34054,8 @@ }, "timsort": { "version": "0.3.0", + "resolved": "https://registry.npmjs.org/timsort/-/timsort-0.3.0.tgz", + "integrity": "sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q=", "dev": true }, "tmp": { @@ -34050,7 +34154,9 @@ "dev": true }, "tsutils": { - "version": "3.18.0", + "version": "3.21.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", + "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==", "dev": true, "requires": { "tslib": "^1.8.1" @@ -34105,7 +34211,9 @@ } }, "typescript": { - "version": "3.9.5", + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.5.tgz", + "integrity": "sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==", "dev": true }, "uc.micro": { @@ -34331,7 +34439,9 @@ } }, "validator": { - "version": "8.2.0", + "version": "13.7.0", + "resolved": "https://registry.npmjs.org/validator/-/validator-13.7.0.tgz", + "integrity": "sha512-nYXQLCBkpJ8X6ltALua9dRrZDHVYxjJ1wgskNt1lH9fzGjs3tgojGSCBjmEPwkWS1y29+DrizMTW19Pr9uB2nw==", "dev": true }, "verror": { @@ -34768,26 +34878,6 @@ "signal-exit": "^3.0.2" } }, - "write-json-file": { - "version": "2.3.0", - "dev": true, - "requires": { - "detect-indent": "^5.0.0", - "graceful-fs": "^4.1.2", - "make-dir": "^1.0.0", - "pify": "^3.0.0", - "sort-keys": "^2.0.0", - "write-file-atomic": "^2.0.0" - } - }, - "write-pkg": { - "version": "3.2.0", - "dev": true, - "requires": { - "sort-keys": "^2.0.0", - "write-json-file": "^2.2.0" - } - }, "xtend": { "version": "4.0.1", "dev": true @@ -34946,13 +35036,15 @@ "dev": true }, "z-schema": { - "version": "3.18.4", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/z-schema/-/z-schema-5.0.2.tgz", + "integrity": "sha512-40TH47ukMHq5HrzkeVE40Ad7eIDKaRV2b+Qpi2prLc9X9eFJFzV7tMe5aH12e6avaSS/u5l653EQOv+J9PirPw==", "dev": true, "requires": { "commander": "^2.7.1", - "lodash.get": "^4.0.0", - "lodash.isequal": "^4.0.0", - "validator": "^8.0.0" + "lodash.get": "^4.4.2", + "lodash.isequal": "^4.5.0", + "validator": "^13.7.0" } } } diff --git a/package.json b/package.json index 4359a6601a..88cf2aebac 100644 --- a/package.json +++ b/package.json @@ -4,38 +4,34 @@ "workspaces": [ "bundles/*", "packages/*", - "packages/canvas/*", - "packages/filters/*", "tools/*" ], "scripts": { "start": "run-s watch", - "clean:build": "rimraf \"{bundles,packages,packages/canvas,packages/filters,out}/*/dist\"", + "clean:build": "rimraf \"{bundles,packages,out}/*/dist\"", "clean:dist": "rimraf dist/*", "clean:modules": "lerna clean --yes", "clean": "run-s clean:*", "floss": "cross-env TS_NODE_PROJECT=tsconfig.tests.json floss -r ts-node/register/transpile-only -p test", - "test": "run-s lint:tests floss", + "test": "run-s floss", "unit-test": "npm run floss -- --", "unit-test:debug": "npm run floss -- --debug --", - "precoverage": "run-s lint:tests", + "precoverage": "run-s lint", "coverage": "nyc run-s floss && nyc report --reporter=html", "coverage:ci": "run-s coverage && nyc report --reporter=text-lcov > coverage.lcov", "docs": "mkdirp dist && webdoc -R README.md", - "lint:src": "eslint --ext .js --ext .ts test bundles packages scripts --ignore-path .gitignore --ignore-pattern \"**/*.tests.ts\" --max-warnings 0", - "lint:tests": "eslint -c .eslintrc.tests.json --ext .ts \"**/*.tests.ts\" --max-warnings 0", - "lint": "run-s lint:*", - "lintfix": "run-s \"lint:* -- --fix\"", + "lint": "eslint --ext .js --ext .ts test bundles packages scripts --ignore-path .gitignore --max-warnings 0", + "lintfix": "run-s \"lint -- --fix\"", "types": "tsc -noEmit", "build": "run-s clean:build build:dev", "build:prod": "cross-env NODE_ENV=production rollup -c", "build:dev": "rollup -c", "build:types": "rimraf out && tsc && api-extractor-lerna-monorepo && rimraf out && ts-node-script ./scripts/injectGlobalMixins.ts", "watch": "rollup -cw", - "dist": "run-s lint:src types build:prod build:types docs", + "dist": "run-s lint types build:prod build:types docs", "postdist": "copyfiles -f bundles/*/dist/browser/* dist && copyfiles -f \"packages/**/dist/browser/*\" dist/packages", "prerelease": "run-s clean:build test", - "postversion": "run-s lint:src types build:prod build:types", + "postversion": "run-s lint types build:prod build:types", "release": "lerna version --exact --force-publish", "version": "ts-node scripts/fixPeerVersions.ts && npx --yes npm@7.20.2 i --package-lock-only && git add package-lock.json", "prepublish-ci": "run-s build:types", @@ -46,7 +42,7 @@ "lintfix" ], "engines": { - "node": ">=12", + "node": ">=14", "yarn": "please-use-npm", "npm": ">=7" }, @@ -63,9 +59,9 @@ }, "devDependencies": { "@istanbuljs/nyc-config-typescript": "^1.0.1", - "@microsoft/api-extractor": "^7.9.11", - "@pixi-build-tools/api-extractor-lerna-monorepo": "^1.0.3", - "@pixi/eslint-config": "^2.0.1", + "@microsoft/api-extractor": "~7.20.1", + "@pixi-build-tools/api-extractor-lerna-monorepo": "~1.1.0", + "@pixi/eslint-config": "^4.0.1", "@pixi/webdoc-template": "^1.5.3", "@rollup/plugin-alias": "^3.1.1", "@rollup/plugin-buble": "^0.21.3", @@ -73,13 +69,17 @@ "@rollup/plugin-json": "^4.1.0", "@rollup/plugin-node-resolve": "^9.0.0", "@rollup/plugin-typescript": "^6.0.0", + "@types/chai": "^4.3.1", "@types/mocha": "^8.2.3", + "@types/sinon": "^10.0.11", + "@types/sinon-chai": "^3.2.8", "@webdoc/cli": "^1.5.5", "chai": "~4.3.6", "copyfiles": "^2.1.0", "cross-env": "^5.2.0", "electron": "^12.0.0", "eslint": "^7.2.0", + "eslint-plugin-jsdoc": "^39.2.9", "floss": "^5.0.0", "glob": "^7.1.3", "lerna": "^4.0.0", @@ -97,7 +97,7 @@ "sinon-chai": "^3.3.0", "ts-node": "^9.0.0", "tsconfig-paths": "^3.10.1", - "typescript": "^3.9.5", + "typescript": "~4.3.0", "workspaces-run": "^1.0.1" } } diff --git a/packages/accessibility/package.json b/packages/accessibility/package.json index c7dbcd0b42..83981d145e 100644 --- a/packages/accessibility/package.json +++ b/packages/accessibility/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/accessibility", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/accessibility.js", "module": "dist/esm/accessibility.js", "bundle": "dist/browser/accessibility.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/accessibility.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/accessibility.js" + } + } + }, "description": "Accessibility Plugin for visually impaired users", "author": "Mat Groves", "contributors": [ @@ -25,8 +38,8 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/core": "6.3.0", - "@pixi/display": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/core": "6.4.2", + "@pixi/display": "6.4.2", + "@pixi/utils": "6.4.2" } } diff --git a/packages/accessibility/src/AccessibilityManager.ts b/packages/accessibility/src/AccessibilityManager.ts index 7644a4f27c..68cf83b70a 100644 --- a/packages/accessibility/src/AccessibilityManager.ts +++ b/packages/accessibility/src/AccessibilityManager.ts @@ -30,7 +30,6 @@ const DIV_HOOK_ZINDEX = 2; * events as if the mouse was being used, minimizing the effort required to implement. * * An instance of this class is automatically created by default, and can be found at `renderer.plugins.accessibility` - * * @class * @memberof PIXI */ @@ -41,10 +40,9 @@ export class AccessibilityManager /** * The renderer this accessibility manager works for. - * * @type {PIXI.CanvasRenderer|PIXI.Renderer} */ - public renderer: AbstractRenderer|Renderer; + public renderer: AbstractRenderer | Renderer; /** Internal variable, see isActive getter. */ private _isActive = false; @@ -76,7 +74,7 @@ export class AccessibilityManager /** * @param {PIXI.CanvasRenderer|PIXI.Renderer} renderer - A reference to the current renderer */ - constructor(renderer: AbstractRenderer|Renderer) + constructor(renderer: AbstractRenderer | Renderer) { this._hookDiv = null; @@ -100,7 +98,6 @@ export class AccessibilityManager /** * pre-bind the functions - * * @type {Function} * @private */ @@ -108,7 +105,6 @@ export class AccessibilityManager /** * pre-bind the functions - * * @type {Function} * @private */ @@ -140,7 +136,6 @@ export class AccessibilityManager /** * Creates the touch hooks. - * * @private */ private createTouchHook(): void @@ -169,7 +164,6 @@ export class AccessibilityManager /** * Destroys the touch hooks. - * * @private */ private destroyTouchHook(): void @@ -185,7 +179,6 @@ export class AccessibilityManager /** * Activating will cause the Accessibility layer to be shown. * This is called when a user presses the tab key. - * * @private */ private activate(): void @@ -207,7 +200,6 @@ export class AccessibilityManager /** * Deactivating will cause the Accessibility layer to be hidden. * This is called when a user moves the mouse. - * * @private */ private deactivate(): void @@ -228,7 +220,6 @@ export class AccessibilityManager /** * This recursive function will run through the scene graph and add any new accessible objects to the DOM layer. - * * @private * @param {PIXI.Container} displayObject - The DisplayObject to check. */ @@ -262,7 +253,6 @@ export class AccessibilityManager /** * Before each render this function will ensure that all divs are mapped correctly to their DisplayObjects. - * * @private */ private update(): void @@ -375,8 +365,7 @@ export class AccessibilityManager /** * private function that will visually add the information to the * accessability div - * - * @param {HTMLElement} div + * @param {HTMLElement} div - */ public updateDebugHTML(div: IAccessibleHTMLElement): void { @@ -385,7 +374,6 @@ export class AccessibilityManager /** * Adjust the hit area based on the bounds of a display object - * * @param {PIXI.Rectangle} hitArea - Bounds of the child */ public capHitArea(hitArea: Rectangle): void @@ -417,7 +405,6 @@ export class AccessibilityManager /** * Adds a DisplayObject to the accessibility manager - * * @private * @param {PIXI.DisplayObject} displayObject - The child to make accessible. */ @@ -499,7 +486,6 @@ export class AccessibilityManager /** * Maps the div button press to pixi's InteractionManager (click) - * * @private * @param {MouseEvent} e - The click event. */ @@ -516,7 +502,6 @@ export class AccessibilityManager /** * Maps the div focus events to pixi's InteractionManager (mouseover) - * * @private * @param {FocusEvent} e - The focus event. */ @@ -536,7 +521,6 @@ export class AccessibilityManager /** * Maps the div focus events to pixi's InteractionManager (mouseout) - * * @private * @param {FocusEvent} e - The focusout event. */ @@ -556,7 +540,6 @@ export class AccessibilityManager /** * Is called when a key is pressed - * * @private * @param {KeyboardEvent} e - The keydown event. */ @@ -572,7 +555,6 @@ export class AccessibilityManager /** * Is called when the mouse moves across the renderer element - * * @private * @param {MouseEvent} e - The mouse event. */ @@ -586,10 +568,7 @@ export class AccessibilityManager this.deactivate(); } - /** - * Destroys the accessibility manager - * - */ + /** Destroys the accessibility manager */ public destroy(): void { this.destroyTouchHook(); diff --git a/packages/accessibility/src/accessibleTarget.ts b/packages/accessibility/src/accessibleTarget.ts index 8718ef0a5f..c5a50d9ca6 100644 --- a/packages/accessibility/src/accessibleTarget.ts +++ b/packages/accessibility/src/accessibleTarget.ts @@ -12,7 +12,8 @@ export type PointerEvents = 'auto' | 'all' | 'inherit'; -export interface IAccessibleTarget { +export interface IAccessibleTarget +{ accessible: boolean; accessibleTitle: string; accessibleHint: string; @@ -25,7 +26,8 @@ export interface IAccessibleTarget { renderId: number; } -export interface IAccessibleHTMLElement extends HTMLElement { +export interface IAccessibleHTMLElement extends HTMLElement +{ type?: string; displayObject?: DisplayObject; } @@ -33,11 +35,10 @@ export interface IAccessibleHTMLElement extends HTMLElement { /** * Default property values of accessible objects * used by {@link PIXI.AccessibilityManager}. - * * @private * @function accessibleTarget * @memberof PIXI - * @type {Object} + * @type {object} * @example * function MyObject() {} * @@ -50,7 +51,6 @@ export const accessibleTarget: IAccessibleTarget = { /** * Flag for if the object is accessible. If true AccessibilityManager will overlay a * shadow div with attributes set - * * @member {boolean} * @memberof PIXI.DisplayObject# */ @@ -59,7 +59,6 @@ export const accessibleTarget: IAccessibleTarget = { /** * Sets the title attribute of the shadow div * If accessibleTitle AND accessibleHint has not been this will default to 'displayObject [tabIndex]' - * * @member {?string} * @memberof PIXI.DisplayObject# */ @@ -67,7 +66,6 @@ export const accessibleTarget: IAccessibleTarget = { /** * Sets the aria-label attribute of the shadow div - * * @member {string} * @memberof PIXI.DisplayObject# */ @@ -98,7 +96,6 @@ export const accessibleTarget: IAccessibleTarget = { /** * Specify the type of div the accessible layer is. Screen readers treat the element differently * depending on this type. Defaults to button. - * * @member {string} * @memberof PIXI.DisplayObject# * @default 'button' @@ -108,7 +105,6 @@ export const accessibleTarget: IAccessibleTarget = { /** * Specify the pointer-events the accessible div will use * Defaults to auto. - * * @member {string} * @memberof PIXI.DisplayObject# * @default 'auto' @@ -118,7 +114,6 @@ export const accessibleTarget: IAccessibleTarget = { /** * Setting to false will prevent any children inside this container to * be accessible. Defaults to true. - * * @member {boolean} * @memberof PIXI.DisplayObject# * @default true diff --git a/packages/accessibility/test/AccessibilityManager.tests.ts b/packages/accessibility/test/AccessibilityManager.tests.ts index 15887c41d4..bce6e4fff0 100644 --- a/packages/accessibility/test/AccessibilityManager.tests.ts +++ b/packages/accessibility/test/AccessibilityManager.tests.ts @@ -5,22 +5,22 @@ import { Renderer } from '@pixi/core'; import { isMobile } from '@pixi/utils'; import { expect } from 'chai'; -describe('AccessibilityManager', function () +describe('AccessibilityManager', () => { - it('should exist', function () + it('should exist', () => { expect(AccessibilityManager).to.be.not.undefined; }); - it('should create new manager', function () + it('should create new manager', () => { - const manager = new AccessibilityManager(); + const manager = new AccessibilityManager(undefined); expect(manager).to.be.instanceof(AccessibilityManager); manager.destroy(); }); - it('should be plugin for renderer', function () + it('should be plugin for renderer', () => { CanvasRenderer.registerPlugin('accessibility', AccessibilityManager); @@ -30,13 +30,13 @@ describe('AccessibilityManager', function () renderer.destroy(); }); - it('should remove touch hook when destroyed', function () + it('should remove touch hook when destroyed', () => { const phone = isMobile.phone; isMobile.phone = true; - const manager = new AccessibilityManager(); - const hookDiv = manager._hookDiv; + const manager = new AccessibilityManager(undefined); + const hookDiv = manager['_hookDiv']; expect(hookDiv).to.be.instanceof(HTMLElement); expect(document.body.contains(hookDiv)).to.be.true; @@ -45,7 +45,7 @@ describe('AccessibilityManager', function () isMobile.phone = phone; }); - it('should activate when tab is pressed and deactivate when mouse moved', function () + it('should activate when tab is pressed and deactivate when mouse moved', () => { const renderer = new Renderer(); const manager = new AccessibilityManager(renderer); @@ -56,8 +56,9 @@ describe('AccessibilityManager', function () expect(manager.isActive).to.be.false; }); - it('should not crash when scene graph contains DisplayObjects without children', function () + it('should not crash when scene graph contains DisplayObjects without children', () => { + // @ts-expect-error - mock DisplayObject class CompleteDisplayObject extends DisplayObject { calculateBounds() { /* noop */ } diff --git a/packages/accessibility/test/accessibleTarget.tests.ts b/packages/accessibility/test/accessibleTarget.tests.ts index 6d1a340962..2199f4bb04 100644 --- a/packages/accessibility/test/accessibleTarget.tests.ts +++ b/packages/accessibility/test/accessibleTarget.tests.ts @@ -3,10 +3,11 @@ import { expect } from 'chai'; import '@pixi/accessibility'; -describe('accessibleTarget', function () +describe('accessibleTarget', () => { - it('should have target public properties', function () + it('should have target public properties', () => { + // @ts-expect-error --- const obj = new DisplayObject(); expect(obj.accessible).to.be.a('boolean'); diff --git a/packages/app/global.d.ts b/packages/app/global.d.ts index 7998a3c5b4..7be0741b72 100644 --- a/packages/app/global.d.ts +++ b/packages/app/global.d.ts @@ -1,15 +1,15 @@ declare namespace GlobalMixins { - // eslint-disable-next-line @typescript-eslint/no-empty-interface interface Application { - resizeTo: Window|HTMLElement; + resizeTo: Window | HTMLElement; resize(): void; + queueResize: () => void; + cancelResize: () => void; } - // eslint-disable-next-line @typescript-eslint/no-empty-interface interface IApplicationOptions { - resizeTo?: Window|HTMLElement; + resizeTo?: Window | HTMLElement; } } diff --git a/packages/app/package.json b/packages/app/package.json index 509ac0da9a..5b91a646c1 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/app", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/app.js", "module": "dist/esm/app.js", "bundle": "dist/browser/app.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/app.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/app.js" + } + } + }, "description": "Convenience class to create a new PixiJS application", "author": "Mat Groves", "contributors": [ @@ -25,7 +38,7 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/core": "6.3.0", - "@pixi/display": "6.3.0" + "@pixi/core": "6.4.2", + "@pixi/display": "6.4.2" } } diff --git a/packages/app/src/Application.ts b/packages/app/src/Application.ts index 5e333a30e4..22faa25851 100644 --- a/packages/app/src/Application.ts +++ b/packages/app/src/Application.ts @@ -10,16 +10,15 @@ import type { IDestroyOptions } from '@pixi/display'; * @memberof PIXI * @see {@link PIXI.Application.registerPlugin} */ -export interface IApplicationPlugin { +export interface IApplicationPlugin +{ /** * Called when Application is constructed, scoped to Application instance. * Passes in `options` as the only argument, which are Application constructor options. * @param {object} options - Application options. */ init(options: IApplicationOptions): void; - /** - * Called when destroying Application, scoped to Application instance. - */ + /** Called when destroying Application, scoped to Application instance. */ destroy(): void; } @@ -33,7 +32,6 @@ export interface Application extends GlobalMixins.Application {} * Convenience class to create a new PIXI application. * * This class automatically creates the renderer, ticker and root container. - * * @example * // Create the application * const app = new PIXI.Application(); @@ -43,7 +41,6 @@ export interface Application extends GlobalMixins.Application {} * * // ex, add display objects * app.stage.addChild(PIXI.Sprite.from('something.png')); - * * @class * @memberof PIXI */ @@ -62,7 +59,7 @@ export class Application * WebGL renderer if available, otherwise CanvasRenderer. * @member {PIXI.Renderer|PIXI.CanvasRenderer} */ - public renderer: Renderer|AbstractRenderer; + public renderer: Renderer | AbstractRenderer; /** * @param {object} [options] - The optional renderer parameters. @@ -123,9 +120,7 @@ export class Application Application._plugins.push(plugin); } - /** - * Render the current stage. - */ + /** Render the current stage. */ public render(): void { this.renderer.render(this.stage); @@ -153,7 +148,7 @@ export class Application /** * Destroy and don't use after this. - * @param {Boolean} [removeView=false] - Automatically remove canvas from DOM. + * @param {boolean} [removeView=false] - Automatically remove canvas from DOM. * @param {object|boolean} [stageOptions] - Options parameter. A boolean will act as if all options * have been set to that value * @param {boolean} [stageOptions.children=false] - if set to true, all the children will have their destroy @@ -163,7 +158,7 @@ export class Application * @param {boolean} [stageOptions.baseTexture=false] - Only used for child Sprites if stageOptions.children is set * to true. Should it destroy the base texture of the child sprite */ - public destroy(removeView?: boolean, stageOptions?: IDestroyOptions|boolean): void + public destroy(removeView?: boolean, stageOptions?: IDestroyOptions | boolean): void { // Destroy plugins in the opposite order // which they were constructed diff --git a/packages/app/src/ResizePlugin.ts b/packages/app/src/ResizePlugin.ts index 53ef096ebb..4e2f72d355 100644 --- a/packages/app/src/ResizePlugin.ts +++ b/packages/app/src/ResizePlugin.ts @@ -9,12 +9,12 @@ import type { IApplicationOptions } from './Application'; */ export class ResizePlugin { - public static resizeTo: Window|HTMLElement; + public static resizeTo: Window | HTMLElement; public static resize: () => void; - public static renderer: Renderer|CanvasRenderer; + public static renderer: Renderer | CanvasRenderer; public static queueResize: () => void; private static _resizeId: number; - private static _resizeTo: Window|HTMLElement; + private static _resizeTo: Window | HTMLElement; private static cancelResize: () => void; /** @@ -34,7 +34,7 @@ export class ResizePlugin * @memberof PIXI.Application# */ { - set(dom: Window|HTMLElement) + set(dom: Window | HTMLElement) { globalThis.removeEventListener('resize', this.queueResize); this._resizeTo = dom; @@ -53,7 +53,6 @@ export class ResizePlugin /** * Resize is throttled, so it's safe to call this multiple times per frame and it'll * only be called once. - * * @memberof PIXI.Application# * @method queueResize * @private @@ -73,7 +72,6 @@ export class ResizePlugin /** * Cancel the resize queue. - * * @memberof PIXI.Application# * @method cancelResize * @private @@ -91,7 +89,6 @@ export class ResizePlugin * Execute an immediate resize on the renderer, this is not * throttled and can be expensive to call many times in a row. * Will resize only if `resizeTo` property is set. - * * @memberof PIXI.Application# * @method resize */ @@ -134,7 +131,6 @@ export class ResizePlugin /** * Clean up the ticker, scoped to application - * * @static * @private */ diff --git a/packages/app/test/Application.tests.ts b/packages/app/test/Application.tests.ts index 28e1982bc3..54eae65792 100644 --- a/packages/app/test/Application.tests.ts +++ b/packages/app/test/Application.tests.ts @@ -1,18 +1,14 @@ import { Application } from '@pixi/app'; -import { autoDetectRenderer } from '@pixi/canvas-renderer'; -import { Container, DisplayObject } from '@pixi/display'; +import { Container } from '@pixi/display'; import { skipHello } from '@pixi/utils'; -import sinon from 'sinon'; import { expect } from 'chai'; +import sinon from 'sinon'; skipHello(); -// Use fallback if no webgl -Application.prototype.createRenderer = autoDetectRenderer; - -describe('Application', function () +describe('Application', () => { - it('should generate application', function () + it('should generate application', () => { expect(Application).to.be.a('function'); const app = new Application(); @@ -26,7 +22,7 @@ describe('Application', function () expect(app.renderer).to.be.null; }); - it('register a new plugin, then destroy it', function () + it('register a new plugin, then destroy it', () => { const plugin = { init: sinon.spy(), @@ -42,10 +38,10 @@ describe('Application', function () expect(plugin.init).to.be.calledOnce; expect(plugin.destroy).to.be.calledOnce; - Application._plugins.pop(); + Application['_plugins'].pop(); }); - it('should remove canvas when destroyed', function () + it('should remove canvas when destroyed', () => { const app = new Application(); const view = app.view; @@ -58,11 +54,11 @@ describe('Application', function () expect(document.body.contains(view)).to.be.false; }); - it('should not destroy children by default', function () + it('should not destroy children by default', () => { const app = new Application(); const stage = app.stage; - const child = new DisplayObject(); + const child = new Container(); stage.addChild(child); @@ -70,11 +66,11 @@ describe('Application', function () expect(child.transform).to.not.be.null; }); - it('should allow children destroy', function () + it('should allow children destroy', () => { const app = new Application(); const stage = app.stage; - const child = new DisplayObject(); + const child = new Container(); stage.addChild(child); @@ -82,41 +78,42 @@ describe('Application', function () expect(child.transform).to.be.null; }); - describe('resizeTo', function () + describe('resizeTo', () => { - before(function () + let div: HTMLDivElement; + + before(() => { - const div = document.createElement('div'); + div = document.createElement('div'); div.style.width = '100px'; div.style.height = '200px'; document.body.appendChild(div); - this.div = div; }); - after(function () + after(() => { - this.div.parentNode.removeChild(this.div); - this.div = null; + div.parentNode.removeChild(div); + div = null; }); - it('should assign resizeTo', function () + it('should assign resizeTo', () => { const app = new Application({ - resizeTo: this.div, + resizeTo: div, }); - expect(app.resizeTo).to.equal(this.div); + expect(app.resizeTo).to.equal(div); expect(app.view.width).to.equal(100); expect(app.view.height).to.equal(200); app.destroy(); }); - it('should force multiple immediate resizes', function () + it('should force multiple immediate resizes', () => { const spy = sinon.spy(); const app = new Application({ - resizeTo: this.div, + resizeTo: div, }); app.renderer.on('resize', spy); @@ -129,11 +126,11 @@ describe('Application', function () app.destroy(); }); - it('should throttle multiple resizes', function (done) + it('should throttle multiple resizes', (done) => { const spy = sinon.spy(); const app = new Application({ - resizeTo: this.div, + resizeTo: div, }); app.renderer.on('resize', spy); @@ -148,11 +145,11 @@ describe('Application', function () }, 50); }); - it('should cancel resize on destroy', function (done) + it('should cancel resize on destroy', (done) => { const spy = sinon.spy(); const app = new Application({ - resizeTo: this.div, + resizeTo: div, }); app.renderer.on('resize', spy); @@ -166,11 +163,11 @@ describe('Application', function () }); }); - it('should resize cancel resize queue', function (done) + it('should resize cancel resize queue', (done) => { const spy = sinon.spy(); const app = new Application({ - resizeTo: this.div, + resizeTo: div, }); app.renderer.on('resize', spy); @@ -185,11 +182,11 @@ describe('Application', function () }); }); - it('should resizeTo with resolution', function () + it('should resizeTo with resolution', () => { const app = new Application({ resolution: 2, - resizeTo: this.div, + resizeTo: div, }); expect(app.view.width).to.equal(200); @@ -197,18 +194,18 @@ describe('Application', function () app.destroy(); }); - it('should resizeTo with resolution and autoDensity', function () + it('should resizeTo with resolution and autoDensity', () => { const app = new Application({ resolution: 2, - resizeTo: this.div, + resizeTo: div, autoDensity: true, }); expect(app.view.width).to.equal(200); expect(app.view.height).to.equal(400); - expect(app.view.style.width).to.equal(this.div.style.width); - expect(app.view.style.height).to.equal(this.div.style.height); + expect(app.view.style.width).to.equal(div.style.width); + expect(app.view.style.height).to.equal(div.style.height); app.destroy(); }); }); diff --git a/packages/basis/package.json b/packages/basis/package.json index 76ddf536f6..dbf29a28d3 100644 --- a/packages/basis/package.json +++ b/packages/basis/package.json @@ -1,6 +1,6 @@ { "name": "@pixi/basis", - "version": "6.3.0", + "version": "6.4.2", "description": "Loader for the *.basis supercompressed texture file format. This package also ships with the transcoder!", "keywords": [ "basisu", @@ -14,6 +14,19 @@ "main": "dist/cjs/basis.js", "module": "dist/esm/basis.js", "bundle": "dist/browser/basis.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/basis.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/basis.js" + } + } + }, "publishConfig": { "access": "public" }, @@ -33,10 +46,10 @@ "url": "https://github.com/pixijs/pixi.js/issues" }, "peerDependencies": { - "@pixi/compressed-textures": "6.3.0", - "@pixi/constants": "6.3.0", - "@pixi/core": "6.3.0", - "@pixi/loaders": "6.3.0", - "@pixi/runner": "6.3.0" + "@pixi/compressed-textures": "6.4.2", + "@pixi/constants": "6.4.2", + "@pixi/core": "6.4.2", + "@pixi/loaders": "6.4.2", + "@pixi/runner": "6.4.2" } } diff --git a/packages/basis/src/Basis.ts b/packages/basis/src/Basis.ts index a673e1ad09..a85190222b 100644 --- a/packages/basis/src/Basis.ts +++ b/packages/basis/src/Basis.ts @@ -5,11 +5,11 @@ import { INTERNAL_FORMATS } from '@pixi/compressed-textures'; * The transcoding formats provided by basis_universal. * * NOTE: Not all of these formats are supported on WebGL! - * * @ignore */ -/* eslint-disable camelcase */ -export enum BASIS_FORMATS { +/* eslint-disable camelcase, @typescript-eslint/indent */ +export enum BASIS_FORMATS +{ cTFETC1 = 0, cTFETC2 = 1, cTFBC1 = 2, @@ -27,11 +27,10 @@ export enum BASIS_FORMATS { cTFBGR565 = 15, cTFRGBA4444 = 16, } -/* eslint-enable camelcase */ +/* eslint-enable camelcase, @typescript-eslint/indent */ /** * Maps {@link BASIS_FORMATS} to {@link PIXI.INTERNAL_FORMATS} - * * @ignore */ export const BASIS_FORMAT_TO_INTERNAL_FORMAT: { [id: number]: INTERNAL_FORMATS } = { @@ -41,7 +40,7 @@ export const BASIS_FORMAT_TO_INTERNAL_FORMAT: { [id: number]: INTERNAL_FORMATS } [BASIS_FORMATS.cTFPVRTC1_4_RGB]: INTERNAL_FORMATS.COMPRESSED_RGB_PVRTC_4BPPV1_IMG, [BASIS_FORMATS.cTFPVRTC1_4_RGBA]: INTERNAL_FORMATS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, [BASIS_FORMATS.cTFATC_RGB]: INTERNAL_FORMATS.COMPRESSED_RGB_ATC_WEBGL, - [BASIS_FORMATS.cTFASTC_4x4]: INTERNAL_FORMATS.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL + [BASIS_FORMATS.cTFASTC_4x4]: INTERNAL_FORMATS.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL, }; /** @@ -50,18 +49,16 @@ export const BASIS_FORMAT_TO_INTERNAL_FORMAT: { [id: number]: INTERNAL_FORMATS } * * NOTE: {@link BASIS_FORMATS.cTFBGR565} is not supported, while {@link BASIS_FORMATS.cTFRGBA4444} is not implemented by * [at]pixi/basis. - * * @ignore */ export const BASIS_FORMAT_TO_TYPE: { [id: number]: TYPES } = { [BASIS_FORMATS.cTFRGBA32]: TYPES.UNSIGNED_BYTE, [BASIS_FORMATS.cTFRGB565]: TYPES.UNSIGNED_SHORT_5_6_5, - [BASIS_FORMATS.cTFRGBA4444]: TYPES.UNSIGNED_SHORT_4_4_4_4 + [BASIS_FORMATS.cTFRGBA4444]: TYPES.UNSIGNED_SHORT_4_4_4_4, }; /** * Maps {@link PIXI.INTERNAL_FORMATS} to {@link BASIS_FORMATS} - * * @ignore */ export const INTERNAL_FORMAT_TO_BASIS_FORMAT: { [id: number]: number } @@ -76,18 +73,16 @@ export const INTERNAL_FORMAT_TO_BASIS_FORMAT: { [id: number]: number } /** * Enumerates the basis formats with alpha components - * * @ignore */ export const BASIS_FORMATS_ALPHA: { [id: number]: boolean } = { [BASIS_FORMATS.cTFBC3]: true, [BASIS_FORMATS.cTFPVRTC1_4_RGBA]: true, - [BASIS_FORMATS.cTFASTC_4x4]: true + [BASIS_FORMATS.cTFASTC_4x4]: true, }; /** * Binding to C++ {@code BasisFile} wrapper class. - * * @see https://github.com/BinomialLLC/basis_universal/blob/master/webgl/transcoder/basis_wrappers.cpp * @private */ @@ -117,7 +112,6 @@ export declare class BasisFile // Missing typings? - https://github.com/microsoft/TypeScript/issues/39655 /** * Compressed texture extensions relevant to the formats into which Basis can decompress into. - * * @ignore */ /* eslint-disable camelcase */ @@ -134,7 +128,6 @@ export type BasisTextureExtensions = { /** * API provided by basis_universal WebGL library. - * * @ignore */ export type BasisBinding = { @@ -144,7 +137,6 @@ export type BasisBinding = { /** * Binding to basis_universal WebGL library. - * * @see https://github.com/BinomialLLC/basis_universal/blob/master/webgl/transcoder/build/basis_transcoder.js * @ignore */ diff --git a/packages/basis/src/BasisLoader.ts b/packages/basis/src/BasisLoader.ts index 3ae3fb0b69..5f61f082c8 100644 --- a/packages/basis/src/BasisLoader.ts +++ b/packages/basis/src/BasisLoader.ts @@ -8,7 +8,7 @@ import { BASIS_FORMATS_ALPHA, BasisTextureExtensions, BasisBinding, - BASIS_FORMAT_TO_TYPE + BASIS_FORMAT_TO_TYPE, } from './Basis'; import { TranscoderWorker } from './TranscoderWorker'; import { LoaderResource } from '@pixi/loaders'; @@ -58,10 +58,9 @@ LoaderResource.setExtensionXhrType('basis', LoaderResource.XHR_RESPONSE_TYPE.BUF * ``` * * NOTE: This can only be used with web-workers. - * * @class * @memberof PIXI - * @implements PIXI.ILoaderPlugin + * @implements {PIXI.ILoaderPlugin} */ export class BasisLoader { @@ -74,7 +73,6 @@ export class BasisLoader /** * Transcodes the *.basis data when the data is loaded. If the transcoder is not bound yet, it * will hook transcoding to {@link BasisResource#onTranscoderInitialized}. - * * @see PIXI.Loader.loaderMiddleware * @param resource - loader resource that is checked to see if it is a basis file * @param next - callback Function to call when done @@ -104,7 +102,6 @@ export class BasisLoader /** * Runs transcoding and populates {@link imageArray}. It will run the transcoding in a web worker * if they are available. - * * @private */ private static async transcode(resource: LoaderResource, next: (...args: any[]) => void): Promise @@ -126,7 +123,7 @@ export class BasisLoader Object.assign(resource, BasisLoader.registerTextures( resource.url, resources, - resource.metadata + resource.metadata, )); } catch (err) @@ -149,7 +146,7 @@ export class BasisLoader private static registerTextures( url: string, resources: TranscodedResourcesArray, - metadata: IResourceMetadata + metadata: IResourceMetadata, ): BasisTexturesResult { const result: BasisTexturesResult = { @@ -175,7 +172,7 @@ export class BasisLoader : MIPMAP_MODES.OFF, alphaMode: ALPHA_MODES.NO_PREMULTIPLIED_ALPHA, type, - format + format, }, metadata))) )); @@ -202,7 +199,6 @@ export class BasisLoader /** * Finds a suitable worker for transcoding and sends a transcoding request - * * @private * @async */ @@ -236,7 +232,7 @@ export class BasisLoader const response = await worker.transcodeAsync( new Uint8Array(arrayBuffer), BasisLoader.defaultRGBAFormat.basisFormat, - BasisLoader.defaultRGBFormat.basisFormat + BasisLoader.defaultRGBFormat.basisFormat, ); const basisFormat = response.basisFormat; @@ -260,7 +256,7 @@ export class BasisLoader width: imageArray[i].width, height: imageArray[i].height, levelBuffers: imageArray[i].levelArray, - levels: imageArray[i].levelArray.length + levels: imageArray[i].levelArray.length, }); } } @@ -270,8 +266,8 @@ export class BasisLoader imageResources = imageArray.map((image) => new BufferResource( new Uint16Array(image.levelArray[0].levelBuffer.buffer), { width: image.width, - height: image.height - }) + height: image.height, + }), ) as TranscodedResourcesArray; } @@ -282,7 +278,6 @@ export class BasisLoader /** * Runs transcoding on the main thread. - * * @private */ private static transcodeSync(arrayBuffer: ArrayBuffer): TranscodedResourcesArray @@ -375,7 +370,7 @@ export class BasisLoader width: alignedWidth, height: alignedHeight, levelBuffers: imageLevels, - levels + levels, }); } else @@ -400,7 +395,6 @@ export class BasisLoader /** * Detects the available compressed texture formats on the device. - * * @param extensions - extensions provided by a WebGL context * @ignore */ @@ -427,7 +421,7 @@ export class BasisLoader pvrtc: gl.getExtension('WEBGL_compressed_texture_pvrtc') || gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc'), atc: gl.getExtension('WEBGL_compressed_texture_atc'), - astc: gl.getExtension('WEBGL_compressed_texture_astc') + astc: gl.getExtension('WEBGL_compressed_texture_astc'), }; } @@ -479,7 +473,7 @@ export class BasisLoader { BasisLoader[detectWithAlpha ? 'defaultRGBAFormat' : 'defaultRGBFormat'] = { textureFormat: TYPES.UNSIGNED_SHORT_5_6_5, - basisFormat: BASIS_FORMATS.cTFRGB565 + basisFormat: BASIS_FORMATS.cTFRGB565, }; BasisLoader.fallbackMode = true; @@ -504,7 +498,6 @@ export class BasisLoader * BasisLoader.bindTranscoder(basisLibrary); * }); * ``` - * * @param basisLibrary - the initialized transcoder library * @private */ @@ -515,7 +508,6 @@ export class BasisLoader /** * Loads the transcoder source code for use in {@link PIXI.BasisLoader.TranscoderWorker}. - * * @private * @param jsURL - URL to the javascript basis transcoder * @param wasmURL - URL to the wasm basis transcoder @@ -527,7 +519,6 @@ export class BasisLoader /** * Set the transcoder source code directly - * * @private * @param jsSource - source for the javascript basis transcoder * @param wasmSource - source for the wasm basis transcoder diff --git a/packages/basis/src/TranscoderWorker.ts b/packages/basis/src/TranscoderWorker.ts index 6cb48c5ee1..a0836c723c 100644 --- a/packages/basis/src/TranscoderWorker.ts +++ b/packages/basis/src/TranscoderWorker.ts @@ -7,7 +7,6 @@ import { ITranscodeResponse, TranscoderWorkerWrapper } from './TranscoderWorkerW * * To enable asynchronous transcoding, you need to provide the URL to the basis_universal transcoding * library. - * * @memberof PIXI.BasisLoader */ export class TranscoderWorker @@ -124,7 +123,6 @@ export class TranscoderWorker /** * Handles responses from the web-worker - * * @param e - a message event containing the transcoded response */ protected onMessage = (e: MessageEvent): void => @@ -162,7 +160,6 @@ export class TranscoderWorker /** * Loads the transcoder source code - * * @param jsURL - URL to the javascript basis transcoder * @param wasmURL - URL to the wasm basis transcoder * @returns A promise that resolves when both the js and wasm transcoders have been loaded. @@ -186,7 +183,6 @@ export class TranscoderWorker /** * Set the transcoder source code directly - * * @param jsSource - source for the javascript basis transcoder * @param wasmSource - source for the wasm basis transcoder */ diff --git a/packages/basis/src/TranscoderWorkerWrapper.ts b/packages/basis/src/TranscoderWorkerWrapper.ts index e53dce4cbc..0de27a9708 100644 --- a/packages/basis/src/TranscoderWorkerWrapper.ts +++ b/packages/basis/src/TranscoderWorkerWrapper.ts @@ -4,7 +4,8 @@ import type { BASIS, BASIS_FORMATS, BasisBinding } from './Basis'; * Initialization message sent by the main thread. * @ignore */ -export interface IInitializeTranscoderMessage { +export interface IInitializeTranscoderMessage +{ wasmSource: ArrayBuffer; type: 'init'; } @@ -23,7 +24,8 @@ export interface ITranscodeMessage } /** @ignore */ -export interface ITranscodedImage { +export interface ITranscodedImage +{ imageID: number; levelArray: Array<{ levelID: number, @@ -39,7 +41,8 @@ export interface ITranscodedImage { * Response format for {@link TranscoderWorker}. * @ignore */ -export interface ITranscodeResponse { +export interface ITranscodeResponse +{ type: 'init' | 'transcode'; requestID?: number; success: boolean; @@ -57,8 +60,10 @@ export interface ITranscodeResponse { }>; } -declare global { - interface Window { +declare global +{ + interface Window + { BASIS: BASIS; } } @@ -70,7 +75,6 @@ declare global { * The transcoder worker responds to two types of messages: "init" and "transcode". You must always send the first "init" * {@link IInitializeTranscoderMessage} message with the WebAssembly binary; if the transcoder is successfully initialized, * the web-worker will respond by sending another {@link ITranscodeResponse} message with `success: true`. - * * @ignore */ export function TranscoderWorkerWrapper(): void diff --git a/packages/canvas/canvas-display/LICENSE b/packages/canvas-display/LICENSE similarity index 100% rename from packages/canvas/canvas-display/LICENSE rename to packages/canvas-display/LICENSE diff --git a/packages/canvas/canvas-display/README.md b/packages/canvas-display/README.md similarity index 100% rename from packages/canvas/canvas-display/README.md rename to packages/canvas-display/README.md diff --git a/packages/canvas/canvas-display/global.d.ts b/packages/canvas-display/global.d.ts similarity index 60% rename from packages/canvas/canvas-display/global.d.ts rename to packages/canvas-display/global.d.ts index 5854bc9e9f..504a36c8d6 100644 --- a/packages/canvas/canvas-display/global.d.ts +++ b/packages/canvas-display/global.d.ts @@ -1,5 +1,7 @@ -declare namespace GlobalMixins { - interface Container { +declare namespace GlobalMixins +{ + interface Container + { _renderCanvas(renderer: import('@pixi/canvas-renderer').CanvasRenderer): void; } } diff --git a/packages/canvas/canvas-display/package.json b/packages/canvas-display/package.json similarity index 66% rename from packages/canvas/canvas-display/package.json rename to packages/canvas-display/package.json index 07f3f428ce..ccdfcda2c0 100644 --- a/packages/canvas/canvas-display/package.json +++ b/packages/canvas-display/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/canvas-display", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/canvas-display.js", "module": "dist/esm/canvas-display.js", "bundle": "dist/browser/canvas-display.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/canvas-display.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/canvas-display.js" + } + } + }, "bundleNoExports": true, "description": "Canvas mixin for the display package", "author": "Mat Groves", @@ -26,6 +39,6 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/display": "6.3.0" + "@pixi/display": "6.4.2" } } diff --git a/packages/canvas/canvas-display/src/Container.ts b/packages/canvas-display/src/Container.ts similarity index 95% rename from packages/canvas/canvas-display/src/Container.ts rename to packages/canvas-display/src/Container.ts index 361298855d..7c177d33e2 100644 --- a/packages/canvas/canvas-display/src/Container.ts +++ b/packages/canvas-display/src/Container.ts @@ -7,7 +7,7 @@ import type { MaskData } from '@pixi/core'; * @method _renderCanvas * @memberof PIXI.Container# * @protected - * @param {PIXI.CanvasRenderer} renderer - The renderer + * @param {PIXI.CanvasRenderer} _renderer - The renderer */ Container.prototype._renderCanvas = function _renderCanvas(_renderer: CanvasRenderer): void { diff --git a/packages/canvas/canvas-display/src/DisplayObject.ts b/packages/canvas-display/src/DisplayObject.ts similarity index 85% rename from packages/canvas/canvas-display/src/DisplayObject.ts rename to packages/canvas-display/src/DisplayObject.ts index e4d3f4f531..0e1fca35ff 100644 --- a/packages/canvas/canvas-display/src/DisplayObject.ts +++ b/packages/canvas-display/src/DisplayObject.ts @@ -5,7 +5,7 @@ import type { CanvasRenderer } from '@pixi/canvas-renderer'; * Renders the object using the Canvas renderer * @method renderCanvas * @memberof PIXI.Container# - * @param {PIXI.CanvasRenderer} renderer - The renderer + * @param {PIXI.CanvasRenderer} _renderer - The renderer */ DisplayObject.prototype.renderCanvas = function renderCanvas(_renderer: CanvasRenderer): void { diff --git a/packages/canvas/canvas-display/src/index.ts b/packages/canvas-display/src/index.ts similarity index 100% rename from packages/canvas/canvas-display/src/index.ts rename to packages/canvas-display/src/index.ts diff --git a/packages/canvas/canvas-display/test/.eslintrc.json b/packages/canvas-display/test/.eslintrc.json similarity index 100% rename from packages/canvas/canvas-display/test/.eslintrc.json rename to packages/canvas-display/test/.eslintrc.json diff --git a/packages/canvas/canvas-display/test/Container.tests.ts b/packages/canvas-display/test/Container.tests.ts similarity index 70% rename from packages/canvas/canvas-display/test/Container.tests.ts rename to packages/canvas-display/test/Container.tests.ts index 8f5d3f53f5..1a26c023cc 100644 --- a/packages/canvas/canvas-display/test/Container.tests.ts +++ b/packages/canvas-display/test/Container.tests.ts @@ -4,44 +4,44 @@ import { expect } from 'chai'; import '@pixi/canvas-display'; -describe('Container', function () +describe('Container', () => { - describe('render', function () + describe('render', () => { - it('should not render when object not visible', function () + it('should not render when object not visible', () => { const container = new Container(); const canvasSpy = sinon.spy(container._renderCanvas); container.visible = false; - container.renderCanvas(); + container.renderCanvas(undefined); expect(canvasSpy).to.not.have.been.called; }); - it('should not render when alpha is zero', function () + it('should not render when alpha is zero', () => { const container = new Container(); const canvasSpy = sinon.spy(container._renderCanvas); container.worldAlpha = 0; - container.renderCanvas(); + container.renderCanvas(undefined); expect(canvasSpy).to.not.have.been.called; }); - it('should not render when object not renderable', function () + it('should not render when object not renderable', () => { const container = new Container(); const canvasSpy = sinon.spy(container._renderCanvas); container.renderable = false; - container.renderCanvas(); + container.renderCanvas(undefined); expect(canvasSpy).to.not.have.been.called; }); - it('should render children', function () + it('should render children', () => { const container = new Container(); const child = new Container(); @@ -49,7 +49,7 @@ describe('Container', function () container.addChild(child); - container.renderCanvas(); + container.renderCanvas(undefined); expect(canvasSpy).to.have.been.called; }); }); diff --git a/packages/canvas/canvas-extract/LICENSE b/packages/canvas-extract/LICENSE similarity index 100% rename from packages/canvas/canvas-extract/LICENSE rename to packages/canvas-extract/LICENSE diff --git a/packages/canvas/canvas-extract/README.md b/packages/canvas-extract/README.md similarity index 100% rename from packages/canvas/canvas-extract/README.md rename to packages/canvas-extract/README.md diff --git a/packages/canvas/canvas-extract/package.json b/packages/canvas-extract/package.json similarity index 58% rename from packages/canvas/canvas-extract/package.json rename to packages/canvas-extract/package.json index 09ff9b473e..6893dcfda9 100644 --- a/packages/canvas/canvas-extract/package.json +++ b/packages/canvas-extract/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/canvas-extract", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/canvas-extract.js", "module": "dist/esm/canvas-extract.js", "bundle": "dist/browser/canvas-extract.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/canvas-extract.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/canvas-extract.js" + } + } + }, "description": "Canvas mixin for the extract package", "author": "Mat Groves", "contributors": [ @@ -25,10 +38,10 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/canvas-renderer": "6.3.0", - "@pixi/core": "6.3.0", - "@pixi/display": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/canvas-renderer": "6.4.2", + "@pixi/core": "6.4.2", + "@pixi/display": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/utils": "6.4.2" } } diff --git a/packages/canvas/canvas-extract/src/CanvasExtract.ts b/packages/canvas-extract/src/CanvasExtract.ts similarity index 88% rename from packages/canvas/canvas-extract/src/CanvasExtract.ts rename to packages/canvas-extract/src/CanvasExtract.ts index 1fb0d43ecb..36c4e6ad6f 100644 --- a/packages/canvas/canvas-extract/src/CanvasExtract.ts +++ b/packages/canvas-extract/src/CanvasExtract.ts @@ -11,7 +11,6 @@ const TEMP_RECT = new Rectangle(); * The extract manager provides functionality to export content from the renderers. * * An instance of this class is automatically created by default, and can be found at `renderer.plugins.extract` - * * @class * @memberof PIXI */ @@ -30,14 +29,13 @@ export class CanvasExtract /** * Will return a HTML Image of the target - * * @param target - A displayObject or renderTexture * to convert. If left empty will use the main renderer * @param format - Image format, e.g. "image/jpeg" or "image/webp". * @param quality - JPEG or Webp compression from 0 to 1. Default is 0.92. - * @return HTML Image of the target + * @returns HTML Image of the target */ - public image(target?: DisplayObject|RenderTexture, format?: string, quality?: number): HTMLImageElement + public image(target?: DisplayObject | RenderTexture, format?: string, quality?: number): HTMLImageElement { const image = new Image(); @@ -49,26 +47,24 @@ export class CanvasExtract /** * Will return a base64 encoded string of this target. It works by calling * `CanvasExtract.getCanvas` and then running toDataURL on that. - * * @param target - A displayObject or renderTexture * to convert. If left empty will use the main renderer * @param format - Image format, e.g. "image/jpeg" or "image/webp". * @param quality - JPEG or Webp compression from 0 to 1. Default is 0.92. - * @return A base64 encoded string of the texture. + * @returns A base64 encoded string of the texture. */ - public base64(target?: DisplayObject|RenderTexture, format?: string, quality?: number): string + public base64(target?: DisplayObject | RenderTexture, format?: string, quality?: number): string { return this.canvas(target).toDataURL(format, quality); } /** * Creates a Canvas element, renders this target to it and then returns it. - * * @param target - A displayObject or renderTexture * to convert. If left empty will use the main renderer - * @return A Canvas element with the texture rendered on. + * @returns A Canvas element with the texture rendered on. */ - public canvas(target?: DisplayObject|RenderTexture): HTMLCanvasElement + public canvas(target?: DisplayObject | RenderTexture): HTMLCanvasElement { const renderer = this.renderer; let context; @@ -118,12 +114,11 @@ export class CanvasExtract /** * Will return a one-dimensional array containing the pixel data of the entire texture in RGBA * order, with integer values between 0 and 255 (included). - * * @param target - A displayObject or renderTexture * to convert. If left empty will use the main renderer - * @return One-dimensional array containing the pixel data of the entire texture + * @returns One-dimensional array containing the pixel data of the entire texture */ - public pixels(target?: DisplayObject|RenderTexture): Uint8ClampedArray + public pixels(target?: DisplayObject | RenderTexture): Uint8ClampedArray { const renderer = this.renderer; let context; diff --git a/packages/canvas/canvas-extract/src/index.ts b/packages/canvas-extract/src/index.ts similarity index 100% rename from packages/canvas/canvas-extract/src/index.ts rename to packages/canvas-extract/src/index.ts diff --git a/packages/canvas/canvas-extract/test/CanvasExtract.tests.ts b/packages/canvas-extract/test/CanvasExtract.tests.ts similarity index 89% rename from packages/canvas/canvas-extract/test/CanvasExtract.tests.ts rename to packages/canvas-extract/test/CanvasExtract.tests.ts index b91b3b7658..149e009163 100644 --- a/packages/canvas/canvas-extract/test/CanvasExtract.tests.ts +++ b/packages/canvas-extract/test/CanvasExtract.tests.ts @@ -10,15 +10,15 @@ import '@pixi/canvas-display'; skipHello(); -describe('CanvasExtract', function () +describe('CanvasExtract', () => { - before(function () + before(() => { CanvasRenderer.registerPlugin('extract', CanvasExtract); CanvasRenderer.registerPlugin('sprite', CanvasSpriteRenderer); }); - it('should access extract on renderer', function () + it('should access extract on renderer', () => { const renderer = new CanvasRenderer(); @@ -27,7 +27,7 @@ describe('CanvasExtract', function () renderer.destroy(); }); - it('should extract an sprite', function () + it('should extract an sprite', () => { const renderer = new CanvasRenderer(); const sprite = new Sprite(Texture.WHITE); @@ -42,7 +42,7 @@ describe('CanvasExtract', function () sprite.destroy(); }); - it('should extract with no arguments', function () + it('should extract with no arguments', () => { const renderer = new CanvasRenderer(); const extract = renderer.plugins.extract as CanvasExtract; @@ -55,7 +55,7 @@ describe('CanvasExtract', function () renderer.destroy(); }); - it('should extract a render texture', function () + it('should extract a render texture', () => { const renderer = new CanvasRenderer(); const extract = renderer.plugins.extract as CanvasExtract; diff --git a/packages/canvas/canvas-graphics/LICENSE b/packages/canvas-graphics/LICENSE similarity index 100% rename from packages/canvas/canvas-graphics/LICENSE rename to packages/canvas-graphics/LICENSE diff --git a/packages/canvas/canvas-graphics/README.md b/packages/canvas-graphics/README.md similarity index 100% rename from packages/canvas/canvas-graphics/README.md rename to packages/canvas-graphics/README.md diff --git a/packages/canvas-graphics/global.d.ts b/packages/canvas-graphics/global.d.ts new file mode 100644 index 0000000000..7c04f35808 --- /dev/null +++ b/packages/canvas-graphics/global.d.ts @@ -0,0 +1,9 @@ +declare namespace GlobalMixins +{ + interface Graphics + { + _renderCanvas(renderer: import('@pixi/canvas-renderer').CanvasRenderer): void; + generateCanvasTexture(scaleMode?: import('@pixi/constants').SCALE_MODES, resolution?: number): Texture; + cachedGraphicsData: import('@pixi/graphics').GraphicsData[]; + } +} diff --git a/packages/canvas/canvas-graphics/package.json b/packages/canvas-graphics/package.json similarity index 56% rename from packages/canvas/canvas-graphics/package.json rename to packages/canvas-graphics/package.json index 900922f4cb..1046aad5fb 100644 --- a/packages/canvas/canvas-graphics/package.json +++ b/packages/canvas-graphics/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/canvas-graphics", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/canvas-graphics.js", "module": "dist/esm/canvas-graphics.js", "bundle": "dist/browser/canvas-graphics.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/canvas-graphics.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/canvas-graphics.js" + } + } + }, "description": "Canvas mixin for the graphics package", "author": "Mat Groves", "contributors": [ @@ -25,11 +38,11 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/canvas-display": "6.3.0", - "@pixi/canvas-renderer": "6.3.0", - "@pixi/constants": "6.3.0", - "@pixi/core": "6.3.0", - "@pixi/graphics": "6.3.0", - "@pixi/math": "6.3.0" + "@pixi/canvas-display": "6.4.2", + "@pixi/canvas-renderer": "6.4.2", + "@pixi/constants": "6.4.2", + "@pixi/core": "6.4.2", + "@pixi/graphics": "6.4.2", + "@pixi/math": "6.4.2" } } diff --git a/packages/canvas/canvas-graphics/src/CanvasGraphicsRenderer.ts b/packages/canvas-graphics/src/CanvasGraphicsRenderer.ts similarity index 98% rename from packages/canvas/canvas-graphics/src/CanvasGraphicsRenderer.ts rename to packages/canvas-graphics/src/CanvasGraphicsRenderer.ts index 25f6dfa58c..a3796f79f3 100644 --- a/packages/canvas/canvas-graphics/src/CanvasGraphicsRenderer.ts +++ b/packages/canvas-graphics/src/CanvasGraphicsRenderer.ts @@ -20,7 +20,6 @@ import { PolygonUtils } from './utils/PolygonUtils'; /** * Renderer dedicated to drawing and batching graphics objects. - * * @class * @protected * @memberof PIXI @@ -29,7 +28,7 @@ export class CanvasGraphicsRenderer { /** A reference to the current renderer */ public renderer: CanvasRenderer; - private _svgMatrix: DOMMatrix|boolean = null; + private _svgMatrix: DOMMatrix | boolean = null; private _tempMatrix: Matrix = new Matrix(); /** @@ -42,13 +41,12 @@ export class CanvasGraphicsRenderer /** * calculates fill/stroke style for canvas - * * @private * @param style - A graphics {@link PIXI.FILL_STYLE} where if `texture` is specified then a tinted CanvasPattern * will be used for the fill.stroke * @param tint - color to set the fill/stroke too. */ - private _calcCanvasStyle(style: FillStyle, tint: number): string|CanvasPattern + private _calcCanvasStyle(style: FillStyle, tint: number): string | CanvasPattern { let res; @@ -74,7 +72,6 @@ export class CanvasGraphicsRenderer /** * Renders a Graphics object to a canvas. - * * @param graphics - the actual graphics object to render */ public render(graphics: Graphics): void @@ -390,7 +387,6 @@ export class CanvasGraphicsRenderer /** * Paint stroke for polygon and holes - * * @private * @param shape - Shape to be drawn * @param lineStyle - Line style for the shape @@ -401,7 +397,7 @@ export class CanvasGraphicsRenderer * @param context - The canvas context */ private paintPolygonStroke( - shape: Polygon, lineStyle: LineStyle, contextStrokeStyle: string|CanvasPattern, + shape: Polygon, lineStyle: LineStyle, contextStrokeStyle: string | CanvasPattern, holes: GraphicsData[], holesDirection: boolean[], worldAlpha: number, context: CrossPlatformCanvasRenderingContext2D ): void @@ -463,7 +459,6 @@ export class CanvasGraphicsRenderer /** * Paint Ellipse - * * @private * @param shape - Shape to be drawn * @param fillStyle - Fill for the shape @@ -474,7 +469,7 @@ export class CanvasGraphicsRenderer */ private paintEllipse( shape: Ellipse, fillStyle: FillStyle, lineStyle: LineStyle, - contextFillStyle: string|CanvasPattern, worldAlpha: number, + contextFillStyle: string | CanvasPattern, worldAlpha: number, context: CrossPlatformCanvasRenderingContext2D): void { // ellipse code taken from: http://stackoverflow.com/questions/2172798/how-to-draw-an-oval-in-html5-canvas @@ -525,7 +520,6 @@ export class CanvasGraphicsRenderer /** * Paint Rounded Rectangle - * * @private * @param shape - Shape to be drawn * @param fillStyle - Fill for the shape @@ -536,7 +530,7 @@ export class CanvasGraphicsRenderer */ private paintRoundedRectangle( shape: RoundedRectangle, fillStyle: FillStyle, lineStyle: LineStyle, - contextFillStyle: string|CanvasPattern, worldAlpha: number, + contextFillStyle: string | CanvasPattern, worldAlpha: number, context: CrossPlatformCanvasRenderingContext2D ): void { diff --git a/packages/canvas/canvas-graphics/src/Graphics.ts b/packages/canvas-graphics/src/Graphics.ts similarity index 91% rename from packages/canvas/canvas-graphics/src/Graphics.ts rename to packages/canvas-graphics/src/Graphics.ts index 3282bda308..bf9406915c 100644 --- a/packages/canvas/canvas-graphics/src/Graphics.ts +++ b/packages/canvas-graphics/src/Graphics.ts @@ -14,11 +14,11 @@ const tempMatrix = new Matrix(); * or the **@pixi/canvas-graphics** package. * @method generateCanvasTexture * @memberof PIXI.Graphics# - * @param {PIXI.SCALE_MODES} scaleMode - The scale mode of the texture. + * @param {PIXI.SCALE_MODES} [scaleMode] - The scale mode of the texture. * @param {number} resolution - The resolution of the texture. - * @return {PIXI.Texture} The new texture. + * @returns {PIXI.Texture} The new texture. */ -Graphics.prototype.generateCanvasTexture = function generateCanvasTexture(scaleMode: SCALE_MODES, resolution = 1): Texture +Graphics.prototype.generateCanvasTexture = function generateCanvasTexture(scaleMode?: SCALE_MODES, resolution = 1): Texture { const bounds = this.getLocalBounds(); @@ -57,7 +57,6 @@ Graphics.prototype.cachedGraphicsData = []; /** * Renders the object using the Canvas renderer - * * @method _renderCanvas * @memberof PIXI.Graphics# * @private diff --git a/packages/canvas/canvas-graphics/src/index.ts b/packages/canvas-graphics/src/index.ts similarity index 100% rename from packages/canvas/canvas-graphics/src/index.ts rename to packages/canvas-graphics/src/index.ts diff --git a/packages/canvas/canvas-graphics/src/utils/PolygonUtils.ts b/packages/canvas-graphics/src/utils/PolygonUtils.ts similarity index 75% rename from packages/canvas/canvas-graphics/src/utils/PolygonUtils.ts rename to packages/canvas-graphics/src/utils/PolygonUtils.ts index ebf17bfc3c..ffaddc9df4 100644 --- a/packages/canvas/canvas-graphics/src/utils/PolygonUtils.ts +++ b/packages/canvas-graphics/src/utils/PolygonUtils.ts @@ -6,14 +6,13 @@ export class PolygonUtils { /** - * Calculate points of an offset polygon - * @see {@link http://csharphelper.com/blog/2016/01/enlarge-a-polygon-in-c/} - * - * @private - * @param {number[]} points - polygon coordinates - * @param {number} offset - * @return {number[]} - offset points - */ + * Calculate points of an offset polygon + * @see {@link http://csharphelper.com/blog/2016/01/enlarge-a-polygon-in-c/} + * @private + * @param {number[]} points - polygon coordinates + * @param {number} offset + * @returns {number[]} - offset points + */ static offsetPolygon(points: number[], offset: number): number[] { const offsetPoints: number[] = []; @@ -79,20 +78,19 @@ export class PolygonUtils } /** - * Determine the intersection point of two line segments - * @see {@link here http://paulbourke.net/geometry/pointlineplane/} - * - * @private - * @param {number} x1 - x-coordinate of start point at first line - * @param {number} y1 - y-coordinate of start point at first line - * @param {number} x2 - x-coordinate of end point at first line - * @param {number} y2 - y-coordinate of end point at first line - * @param {number} x3 - x-coordinate of start point at second line - * @param {number} y3 - y-coordinate of start point at second line - * @param {number} x4 - x-coordinate of end point at second line - * @param {number} y4 - y-coordinate of end point at second line - * @returns {[number, number] | null} - [x, y] coordinates of intersection - */ + * Determine the intersection point of two line segments + * @see {@link here http://paulbourke.net/geometry/pointlineplane/} + * @private + * @param {number} x1 - x-coordinate of start point at first line + * @param {number} y1 - y-coordinate of start point at first line + * @param {number} x2 - x-coordinate of end point at first line + * @param {number} y2 - y-coordinate of end point at first line + * @param {number} x3 - x-coordinate of start point at second line + * @param {number} y3 - y-coordinate of start point at second line + * @param {number} x4 - x-coordinate of end point at second line + * @param {number} y4 - y-coordinate of end point at second line + * @returns {[number, number] | null} - [x, y] coordinates of intersection + */ static findIntersection( x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number @@ -122,10 +120,9 @@ export class PolygonUtils /** * Determine polygon are clockwise or counterclockwise * @see {@link https://stackoverflow.com/questions/1165647} - * * @private * @param {number[]} polygon - polygon coordinates - * @return {boolean} + * @returns {boolean} - true if polygon is clockwise */ static isPolygonClockwise(polygon: number[]): boolean { diff --git a/packages/canvas/canvas-graphics/test/.eslintrc.json b/packages/canvas-graphics/test/.eslintrc.json similarity index 100% rename from packages/canvas/canvas-graphics/test/.eslintrc.json rename to packages/canvas-graphics/test/.eslintrc.json diff --git a/packages/canvas/canvas-graphics/test/CanvasGraphicsRenderer.tests.ts b/packages/canvas-graphics/test/CanvasGraphicsRenderer.tests.ts similarity index 86% rename from packages/canvas/canvas-graphics/test/CanvasGraphicsRenderer.tests.ts rename to packages/canvas-graphics/test/CanvasGraphicsRenderer.tests.ts index 077119f217..27f32a101d 100644 --- a/packages/canvas/canvas-graphics/test/CanvasGraphicsRenderer.tests.ts +++ b/packages/canvas-graphics/test/CanvasGraphicsRenderer.tests.ts @@ -4,9 +4,9 @@ import { CanvasRenderer } from '@pixi/canvas-renderer'; import { CanvasGraphicsRenderer } from '@pixi/canvas-graphics'; import { expect } from 'chai'; -describe('CanvasGraphicsRenderer', function () +describe('CanvasGraphicsRenderer', () => { - it('should not create pattern for White Texture', function () + it('should not create pattern for White Texture', () => { const renderer = new CanvasRenderer({ width: 1, height: 1 }); @@ -14,7 +14,7 @@ describe('CanvasGraphicsRenderer', function () const graphics = new Graphics(); - graphics.beginFill({ texture: Texture.WHITE }); + graphics.beginTextureFill({ texture: Texture.WHITE }); graphics.drawRect(0, 0, 1, 1); graphics.endFill(); @@ -29,7 +29,7 @@ describe('CanvasGraphicsRenderer', function () } }); - it('should create pattern for textures', function () + it('should create pattern for textures', () => { const renderer = new CanvasRenderer({ width: 1, height: 1 }); diff --git a/packages/canvas/canvas-graphics/test/PolygonUtils.tests.ts b/packages/canvas-graphics/test/PolygonUtils.tests.ts similarity index 95% rename from packages/canvas/canvas-graphics/test/PolygonUtils.tests.ts rename to packages/canvas-graphics/test/PolygonUtils.tests.ts index 46740c4288..3a6df72539 100644 --- a/packages/canvas/canvas-graphics/test/PolygonUtils.tests.ts +++ b/packages/canvas-graphics/test/PolygonUtils.tests.ts @@ -1,9 +1,9 @@ import { PolygonUtils } from '../src/utils/PolygonUtils'; import { expect } from 'chai'; -describe('PolygonUtils', function () +describe('PolygonUtils', () => { - it('isPolygonClockwise', function () + it('isPolygonClockwise', () => { const ccwTriangle1 = [0, 0, 1, 0, 0, 1]; const ccwTriangle2 = [1, 0, 0, 1, 0, 0]; diff --git a/packages/canvas/canvas-mesh/LICENSE b/packages/canvas-mesh/LICENSE similarity index 100% rename from packages/canvas/canvas-mesh/LICENSE rename to packages/canvas-mesh/LICENSE diff --git a/packages/canvas/canvas-mesh/README.md b/packages/canvas-mesh/README.md similarity index 100% rename from packages/canvas/canvas-mesh/README.md rename to packages/canvas-mesh/README.md diff --git a/packages/canvas/canvas-mesh/global.d.ts b/packages/canvas-mesh/global.d.ts similarity index 80% rename from packages/canvas/canvas-mesh/global.d.ts rename to packages/canvas-mesh/global.d.ts index 5974bc236e..5f84124f93 100644 --- a/packages/canvas/canvas-mesh/global.d.ts +++ b/packages/canvas-mesh/global.d.ts @@ -1,5 +1,7 @@ -declare namespace GlobalMixins { - interface Mesh { +declare namespace GlobalMixins +{ + interface Mesh + { _renderCanvas(renderer: import('@pixi/canvas-renderer').CanvasRenderer): void; _canvasPadding: number; canvasPadding: number; @@ -8,11 +10,13 @@ declare namespace GlobalMixins { _cachedTexture: import('@pixi/core').Texture; } - interface MeshMaterial { + interface MeshMaterial + { _renderCanvas(renderer: import('@pixi/canvas-renderer').CanvasRenderer, mesh: import('@pixi/mesh').Mesh): void; } - interface NineSlicePlane { + interface NineSlicePlane + { _cachedTint: number; _tintedCanvas: HTMLCanvasElement; _canvasUvs: number[]; diff --git a/packages/canvas/canvas-mesh/package.json b/packages/canvas-mesh/package.json similarity index 55% rename from packages/canvas/canvas-mesh/package.json rename to packages/canvas-mesh/package.json index 6611e3a4cd..b0ff29e4ff 100644 --- a/packages/canvas/canvas-mesh/package.json +++ b/packages/canvas-mesh/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/canvas-mesh", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/canvas-mesh.js", "module": "dist/esm/canvas-mesh.js", "bundle": "dist/browser/canvas-mesh.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/canvas-mesh.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/canvas-mesh.js" + } + } + }, "description": "Canvas mixin for the mesh package", "author": "Mat Groves", "contributors": [ @@ -25,11 +38,11 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/canvas-display": "6.3.0", - "@pixi/canvas-renderer": "6.3.0", - "@pixi/constants": "6.3.0", - "@pixi/mesh": "6.3.0", - "@pixi/mesh-extras": "6.3.0", - "@pixi/settings": "6.3.0" + "@pixi/canvas-display": "6.4.2", + "@pixi/canvas-renderer": "6.4.2", + "@pixi/constants": "6.4.2", + "@pixi/mesh": "6.4.2", + "@pixi/mesh-extras": "6.4.2", + "@pixi/settings": "6.4.2" } } diff --git a/packages/canvas/canvas-mesh/src/CanvasMeshRenderer.ts b/packages/canvas-mesh/src/CanvasMeshRenderer.ts similarity index 99% rename from packages/canvas/canvas-mesh/src/CanvasMeshRenderer.ts rename to packages/canvas-mesh/src/CanvasMeshRenderer.ts index b636f0c207..4a8b976a60 100644 --- a/packages/canvas/canvas-mesh/src/CanvasMeshRenderer.ts +++ b/packages/canvas-mesh/src/CanvasMeshRenderer.ts @@ -7,7 +7,6 @@ import type { Mesh } from '@pixi/mesh'; /** * Renderer dedicated to meshes. - * * @class * @protected * @memberof PIXI @@ -25,7 +24,6 @@ export class CanvasMeshRenderer /** * Renders the Mesh - * * @param mesh - the Mesh to render */ public render(mesh: Mesh): void @@ -49,7 +47,6 @@ export class CanvasMeshRenderer /** * Draws the object in Triangle Mesh mode - * * @private * @param mesh - the Mesh to render */ @@ -69,7 +66,6 @@ export class CanvasMeshRenderer /** * Draws the object in triangle mode using canvas - * * @private * @param mesh - the current mesh */ @@ -92,7 +88,6 @@ export class CanvasMeshRenderer /** * Draws one of the triangles that from the Mesh - * * @private * @param mesh - the current mesh * @param index0 - the index of the first vertex @@ -238,7 +233,6 @@ export class CanvasMeshRenderer /** * Renders a flat Mesh - * * @private * @param mesh - The Mesh to render */ diff --git a/packages/canvas/canvas-mesh/src/Mesh.ts b/packages/canvas-mesh/src/Mesh.ts similarity index 99% rename from packages/canvas/canvas-mesh/src/Mesh.ts rename to packages/canvas-mesh/src/Mesh.ts index 04309c1680..beb0ea571b 100644 --- a/packages/canvas/canvas-mesh/src/Mesh.ts +++ b/packages/canvas-mesh/src/Mesh.ts @@ -31,7 +31,6 @@ Mesh.prototype._cachedTexture = null; /** * Renders the object using the Canvas renderer - * * @private * @method _renderCanvas * @memberof PIXI.Mesh# @@ -65,7 +64,6 @@ Mesh.prototype._renderCanvas = function _renderCanvas(renderer: CanvasRenderer): /** * Internal variable for `canvasPadding`. - * * @private * @memberof PIXI.Mesh * @member {number} @@ -76,7 +74,6 @@ Mesh.prototype._canvasPadding = null; /** * Triangles in canvas mode are automatically antialiased, use this value to force triangles * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} - * * @see PIXI.settings.MESH_CANVAS_PADDING * @member {number} canvasPadding * @memberof PIXI.SimpleMesh# diff --git a/packages/canvas/canvas-mesh/src/MeshMaterial.ts b/packages/canvas-mesh/src/MeshMaterial.ts similarity index 99% rename from packages/canvas/canvas-mesh/src/MeshMaterial.ts rename to packages/canvas-mesh/src/MeshMaterial.ts index 73bca4b293..55d4436d98 100644 --- a/packages/canvas/canvas-mesh/src/MeshMaterial.ts +++ b/packages/canvas-mesh/src/MeshMaterial.ts @@ -5,7 +5,6 @@ import type { CanvasRenderer } from '@pixi/canvas-renderer'; /** * Renders the mesh using the Canvas renderer - * * @protected * @method render * @memberof PIXI.MeshMaterial# diff --git a/packages/canvas/canvas-mesh/src/NineSlicePlane.ts b/packages/canvas-mesh/src/NineSlicePlane.ts similarity index 99% rename from packages/canvas/canvas-mesh/src/NineSlicePlane.ts rename to packages/canvas-mesh/src/NineSlicePlane.ts index 7997c2b5cb..0c21f0f84a 100644 --- a/packages/canvas/canvas-mesh/src/NineSlicePlane.ts +++ b/packages/canvas-mesh/src/NineSlicePlane.ts @@ -29,7 +29,6 @@ NineSlicePlane.prototype._canvasUvs = null; /** * Renders the object using the Canvas renderer - * * @private * @method _renderCanvas * @memberof PIXI.NineSlicePlane# diff --git a/packages/canvas/canvas-mesh/src/SimpleMesh.ts b/packages/canvas-mesh/src/SimpleMesh.ts similarity index 99% rename from packages/canvas/canvas-mesh/src/SimpleMesh.ts rename to packages/canvas-mesh/src/SimpleMesh.ts index 85d6910571..d343fe6bda 100644 --- a/packages/canvas/canvas-mesh/src/SimpleMesh.ts +++ b/packages/canvas-mesh/src/SimpleMesh.ts @@ -4,7 +4,6 @@ import type { CanvasRenderer } from '@pixi/canvas-renderer'; /** * Renders the object using the Canvas renderer - * * @private * @method _renderCanvas * @memberof PIXI.Mesh# diff --git a/packages/canvas/canvas-mesh/src/SimpleRope.ts b/packages/canvas-mesh/src/SimpleRope.ts similarity index 99% rename from packages/canvas/canvas-mesh/src/SimpleRope.ts rename to packages/canvas-mesh/src/SimpleRope.ts index 428de43177..532e8157ad 100644 --- a/packages/canvas/canvas-mesh/src/SimpleRope.ts +++ b/packages/canvas-mesh/src/SimpleRope.ts @@ -5,7 +5,6 @@ import type { CanvasRenderer } from '@pixi/canvas-renderer'; /** * Renders the object using the Canvas renderer - * * @protected * @method _renderCanvas * @memberof PIXI.Mesh# diff --git a/packages/canvas/canvas-mesh/src/index.ts b/packages/canvas-mesh/src/index.ts similarity index 100% rename from packages/canvas/canvas-mesh/src/index.ts rename to packages/canvas-mesh/src/index.ts diff --git a/packages/canvas/canvas-mesh/src/settings.ts b/packages/canvas-mesh/src/settings.ts similarity index 98% rename from packages/canvas/canvas-mesh/src/settings.ts rename to packages/canvas-mesh/src/settings.ts index 39cd9f5205..114b10d367 100644 --- a/packages/canvas/canvas-mesh/src/settings.ts +++ b/packages/canvas-mesh/src/settings.ts @@ -2,7 +2,6 @@ import { settings } from '@pixi/settings'; /** * Default `canvasPadding` for canvas-based Mesh rendering. - * * @see PIXI.Mesh2d#canvasPadding * @static * @memberof PIXI.settings diff --git a/packages/canvas/canvas-mesh/test/.eslintrc.json b/packages/canvas-mesh/test/.eslintrc.json similarity index 100% rename from packages/canvas/canvas-mesh/test/.eslintrc.json rename to packages/canvas-mesh/test/.eslintrc.json diff --git a/packages/canvas/canvas-mesh/test/NineSlicePlane.tests.ts b/packages/canvas-mesh/test/NineSlicePlane.tests.ts similarity index 71% rename from packages/canvas/canvas-mesh/test/NineSlicePlane.tests.ts rename to packages/canvas-mesh/test/NineSlicePlane.tests.ts index 7c82a694b8..a0d97b4513 100644 --- a/packages/canvas/canvas-mesh/test/NineSlicePlane.tests.ts +++ b/packages/canvas-mesh/test/NineSlicePlane.tests.ts @@ -4,20 +4,22 @@ import { CanvasRenderer } from '@pixi/canvas-renderer'; import { NineSlicePlane } from '@pixi/mesh-extras'; import { expect } from 'chai'; -describe('NineSlicePlane', function () +describe('NineSlicePlane', () => { - before(function () + let renderer: CanvasRenderer; + + before(() => { - this.renderer = new CanvasRenderer(); + renderer = new CanvasRenderer(); }); - after(function () + after(() => { - this.renderer.destroy(); - this.renderer = null; + renderer.destroy(); + renderer = null; }); - it('should be renderable with renderTexture in canvas', function () + it('should be renderable with renderTexture in canvas', () => { const rt = RenderTexture.create({ width: 10, height: 10 }); const spr = new Sprite(Texture.WHITE); diff --git a/packages/canvas/canvas-particle-container/LICENSE b/packages/canvas-particle-container/LICENSE similarity index 100% rename from packages/canvas/canvas-particle-container/LICENSE rename to packages/canvas-particle-container/LICENSE diff --git a/packages/canvas/canvas-particle-container/README.md b/packages/canvas-particle-container/README.md similarity index 100% rename from packages/canvas/canvas-particle-container/README.md rename to packages/canvas-particle-container/README.md diff --git a/packages/canvas/canvas-particle-container/package.json b/packages/canvas-particle-container/package.json similarity index 66% rename from packages/canvas/canvas-particle-container/package.json rename to packages/canvas-particle-container/package.json index a90dd5e248..0e53f583fa 100644 --- a/packages/canvas/canvas-particle-container/package.json +++ b/packages/canvas-particle-container/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/canvas-particle-container", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/canvas-particle-container.js", "module": "dist/esm/canvas-particle-container.js", "bundle": "dist/browser/canvas-particle-container.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/canvas-particle-container.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/canvas-particle-container.js" + } + } + }, "bundleNoExports": true, "description": "Canvas mixin for the particles package", "author": "Mat Groves", @@ -26,6 +39,6 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/particle-container": "6.3.0" + "@pixi/particle-container": "6.4.2" } } diff --git a/packages/canvas/canvas-particle-container/src/ParticleContainer.ts b/packages/canvas-particle-container/src/ParticleContainer.ts similarity index 100% rename from packages/canvas/canvas-particle-container/src/ParticleContainer.ts rename to packages/canvas-particle-container/src/ParticleContainer.ts diff --git a/packages/canvas/canvas-particle-container/src/index.ts b/packages/canvas-particle-container/src/index.ts similarity index 100% rename from packages/canvas/canvas-particle-container/src/index.ts rename to packages/canvas-particle-container/src/index.ts diff --git a/packages/canvas/canvas-prepare/LICENSE b/packages/canvas-prepare/LICENSE similarity index 100% rename from packages/canvas/canvas-prepare/LICENSE rename to packages/canvas-prepare/LICENSE diff --git a/packages/canvas/canvas-prepare/README.md b/packages/canvas-prepare/README.md similarity index 100% rename from packages/canvas/canvas-prepare/README.md rename to packages/canvas-prepare/README.md diff --git a/packages/canvas/canvas-prepare/package.json b/packages/canvas-prepare/package.json similarity index 61% rename from packages/canvas/canvas-prepare/package.json rename to packages/canvas-prepare/package.json index e19b9a5307..d66c7e4093 100644 --- a/packages/canvas/canvas-prepare/package.json +++ b/packages/canvas-prepare/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/canvas-prepare", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/canvas-prepare.js", "module": "dist/esm/canvas-prepare.js", "bundle": "dist/browser/canvas-prepare.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/canvas-prepare.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/canvas-prepare.js" + } + } + }, "description": "Canvas mixin for the prepare package", "author": "Mat Groves", "contributors": [ @@ -25,8 +38,8 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/canvas-renderer": "6.3.0", - "@pixi/core": "6.3.0", - "@pixi/prepare": "6.3.0" + "@pixi/canvas-renderer": "6.4.2", + "@pixi/core": "6.4.2", + "@pixi/prepare": "6.4.2" } } diff --git a/packages/canvas/canvas-prepare/src/CanvasPrepare.ts b/packages/canvas-prepare/src/CanvasPrepare.ts similarity index 98% rename from packages/canvas/canvas-prepare/src/CanvasPrepare.ts rename to packages/canvas-prepare/src/CanvasPrepare.ts index 1e751c4477..80c9f39b65 100644 --- a/packages/canvas/canvas-prepare/src/CanvasPrepare.ts +++ b/packages/canvas-prepare/src/CanvasPrepare.ts @@ -9,11 +9,10 @@ const CANVAS_START_SIZE = 16; /** * Built-in hook to upload PIXI.Texture objects to the GPU. - * * @private * @param prepare - Instance of CanvasPrepare * @param item - Item to check - * @return If item was uploaded. + * @returns If item was uploaded. */ function uploadBaseTextures(prepare: AbstractRenderer | BasePrepare, item: IDisplayObjectExtended): boolean { @@ -50,7 +49,6 @@ function uploadBaseTextures(prepare: AbstractRenderer | BasePrepare, item: IDisp * textures to an offline canvas. This draw call will force the texture to be moved onto the GPU. * * An instance of this class is automatically created by default, and can be found at `renderer.plugins.prepare` - * * @class * @extends PIXI.BasePrepare * @memberof PIXI diff --git a/packages/canvas/canvas-prepare/src/index.ts b/packages/canvas-prepare/src/index.ts similarity index 100% rename from packages/canvas/canvas-prepare/src/index.ts rename to packages/canvas-prepare/src/index.ts diff --git a/packages/canvas/canvas-renderer/LICENSE b/packages/canvas-renderer/LICENSE similarity index 100% rename from packages/canvas/canvas-renderer/LICENSE rename to packages/canvas-renderer/LICENSE diff --git a/packages/canvas/canvas-renderer/README.md b/packages/canvas-renderer/README.md similarity index 100% rename from packages/canvas/canvas-renderer/README.md rename to packages/canvas-renderer/README.md diff --git a/packages/canvas/canvas-renderer/global.d.ts b/packages/canvas-renderer/global.d.ts similarity index 100% rename from packages/canvas/canvas-renderer/global.d.ts rename to packages/canvas-renderer/global.d.ts diff --git a/packages/canvas/canvas-renderer/package.json b/packages/canvas-renderer/package.json similarity index 58% rename from packages/canvas/canvas-renderer/package.json rename to packages/canvas-renderer/package.json index 2bbd1f1dcd..d0b17257eb 100644 --- a/packages/canvas/canvas-renderer/package.json +++ b/packages/canvas-renderer/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/canvas-renderer", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/canvas-renderer.js", "module": "dist/esm/canvas-renderer.js", "bundle": "dist/browser/canvas-renderer.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/canvas-renderer.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/canvas-renderer.js" + } + } + }, "description": "Rendering using the Canvas API", "author": "Mat Groves", "contributors": [ @@ -25,10 +38,10 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/constants": "6.3.0", - "@pixi/core": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/settings": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/constants": "6.4.2", + "@pixi/core": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/settings": "6.4.2", + "@pixi/utils": "6.4.2" } } diff --git a/packages/canvas/canvas-renderer/src/BaseTexture.ts b/packages/canvas-renderer/src/BaseTexture.ts similarity index 91% rename from packages/canvas/canvas-renderer/src/BaseTexture.ts rename to packages/canvas-renderer/src/BaseTexture.ts index c8e04c33f3..26b95c0282 100644 --- a/packages/canvas/canvas-renderer/src/BaseTexture.ts +++ b/packages/canvas-renderer/src/BaseTexture.ts @@ -5,7 +5,7 @@ import { BaseTexture, BaseRenderTexture, Texture } from '@pixi/core'; * for rendering with CanvasRenderer. Provided by **@pixi/canvas-renderer** package. * @method getDrawableSource * @memberof PIXI.BaseTexture# - * @return {PIXI.ICanvasImageSource} Source to render with CanvasRenderer + * @returns {PIXI.ICanvasImageSource} Source to render with CanvasRenderer */ BaseTexture.prototype.getDrawableSource = function getDrawableSource(): CanvasImageSource { @@ -16,7 +16,6 @@ BaseTexture.prototype.getDrawableSource = function getDrawableSource(): CanvasIm /** * A reference to the canvas render target (we only need one as this can be shared across renderers) - * * @protected * @member {PIXI.utils.CanvasRenderTarget} _canvasRenderTarget * @memberof PIXI.BaseRenderTexture# diff --git a/packages/canvas/canvas-renderer/src/CanvasRenderer.ts b/packages/canvas-renderer/src/CanvasRenderer.ts similarity index 98% rename from packages/canvas/canvas-renderer/src/CanvasRenderer.ts rename to packages/canvas-renderer/src/CanvasRenderer.ts index 7e85b46a40..e4b12d1cc9 100644 --- a/packages/canvas/canvas-renderer/src/CanvasRenderer.ts +++ b/packages/canvas-renderer/src/CanvasRenderer.ts @@ -16,7 +16,8 @@ import type { const tempMatrix = new Matrix(); -export interface ICanvasRendererPluginConstructor { +export interface ICanvasRendererPluginConstructor +{ new (renderer: CanvasRenderer, options?: any): IRendererPlugin; } @@ -54,7 +55,6 @@ export interface CrossPlatformCanvasRenderingContext2D extends CanvasRenderingCo * * This renderer should be used for browsers that do not support WebGL. * Don't forget to add the CanvasRenderer.view to your DOM or you will not see anything! - * * @class * @memberof PIXI * @extends PIXI.AbstractRenderer @@ -87,7 +87,7 @@ export class CanvasRenderer extends AbstractRenderer public readonly blendModes: string[] = mapCanvasBlendModesToPixi(); public renderingToScreen = false; - private _activeBlendMode: BLEND_MODES =null; + private _activeBlendMode: BLEND_MODES = null; /** Projection transform, passed in render() stored here */ private _projTransform: Matrix = null; @@ -152,9 +152,7 @@ export class CanvasRenderer extends AbstractRenderer this.resize(this.options.width, this.options.height); } - /** - * Adds a new system to the renderer. It does nothing in the CanvasRenderer. - */ + /** Adds a new system to the renderer. It does nothing in the CanvasRenderer. */ addSystem(): this { return this; @@ -162,7 +160,6 @@ export class CanvasRenderer extends AbstractRenderer /** * Renders the object to its WebGL view. - * * @param displayObject - The object to be rendered. * @param options - Object to use for render options. * @param {PIXI.RenderTexture} [options.renderTexture] - The render texture to render to. @@ -174,7 +171,6 @@ export class CanvasRenderer extends AbstractRenderer /** * Please use the `option` render arguments instead. - * * @deprecated Since 6.0.0 * @param displayObject - The object to be rendered. * @param renderTexture - The render texture to render to. @@ -372,7 +368,6 @@ export class CanvasRenderer extends AbstractRenderer /** * Clear the canvas of renderer. - * * @param {string} [clearColor] - Clear the canvas with this color, except the canvas is transparent. * @param {number} [alpha] - Alpha to apply to the background fill color. */ @@ -393,7 +388,6 @@ export class CanvasRenderer extends AbstractRenderer /** * Sets the blend mode of the renderer. - * * @param {number} blendMode - See {@link PIXI.BLEND_MODES} for valid values. * @param {boolean} [readyForOuterBlend=false] - Some blendModes are dangerous, they affect outer space of sprite. * Pass `true` only if you are ready to use them. @@ -422,7 +416,6 @@ export class CanvasRenderer extends AbstractRenderer /** * Removes everything from the renderer and optionally removes the Canvas DOM element. - * * @param {boolean} [removeView=false] - Removes the Canvas element from the DOM. */ public destroy(removeView?: boolean): void @@ -442,9 +435,7 @@ export class CanvasRenderer extends AbstractRenderer /** * Resizes the canvas view to the specified width and height. - * * @extends PIXI.AbstractRenderer#resize - * * @param desiredScreenWidth - the desired width of the screen * @param desiredScreenHeight - the desired height of the screen */ @@ -482,7 +473,6 @@ export class CanvasRenderer extends AbstractRenderer /** * Adds a plugin to the renderer. - * * @param pluginName - The name of the plugin. * @param ctor - The constructor function or class for the plugin. */ diff --git a/packages/canvas/canvas-renderer/src/Renderer.ts b/packages/canvas-renderer/src/Renderer.ts similarity index 97% rename from packages/canvas/canvas-renderer/src/Renderer.ts rename to packages/canvas-renderer/src/Renderer.ts index 0b08d2467e..f253f8713d 100644 --- a/packages/canvas/canvas-renderer/src/Renderer.ts +++ b/packages/canvas-renderer/src/Renderer.ts @@ -9,6 +9,7 @@ const parentCreate = Renderer.create; /** * Override the Renderer.create to fallback to use CanvasRenderer. * Also supports forceCanvas option with Application or autoDetectRenderer. + * @param options * @private */ Renderer.create = function create(options: IRendererOptionsAuto): AbstractRenderer diff --git a/packages/canvas/canvas-renderer/src/canvasUtils.ts b/packages/canvas-renderer/src/canvasUtils.ts similarity index 97% rename from packages/canvas/canvas-renderer/src/canvasUtils.ts rename to packages/canvas-renderer/src/canvasUtils.ts index e44857e386..1a2acd8547 100644 --- a/packages/canvas/canvas-renderer/src/canvasUtils.ts +++ b/packages/canvas-renderer/src/canvasUtils.ts @@ -8,7 +8,6 @@ import type { Texture } from '@pixi/core'; * * Tinting with the CanvasRenderer involves creating a new canvas to use as a texture, * so be aware of the performance implications. - * * @namespace PIXI.canvasUtils * @memberof PIXI */ @@ -17,11 +16,11 @@ export const canvasUtils = { /** * Basically this method just needs a sprite and a color and tints the sprite with the given color. - * * @memberof PIXI.canvasUtils * @param {PIXI.Sprite} sprite - the sprite to tint + * @param sprite.texture * @param {number} color - the color to use to tint the sprite with - * @return {HTMLCanvasElement} The tinted canvas + * @returns {HTMLCanvasElement} The tinted canvas */ getTintedCanvas: (sprite: { texture: Texture }, color: number): HTMLCanvasElement | HTMLImageElement => { @@ -74,11 +73,10 @@ export const canvasUtils = { /** * Basically this method just needs a sprite and a color and tints the sprite with the given color. - * * @memberof PIXI.canvasUtils * @param {PIXI.Texture} texture - the sprite to tint * @param {number} color - the color to use to tint the sprite with - * @return {HTMLCanvasElement} The tinted canvas + * @returns {HTMLCanvasElement} The tinted canvas */ getTintedPattern: (texture: Texture, color: number): CanvasPattern => { @@ -108,7 +106,6 @@ export const canvasUtils = { /** * Tint a texture using the 'multiply' operation. - * * @memberof PIXI.canvasUtils * @param {PIXI.Texture} texture - the texture to tint * @param {number} color - the color to use to tint the sprite with @@ -167,7 +164,6 @@ export const canvasUtils = { /** * Tint a texture using the 'overlay' operation. - * * @memberof PIXI.canvasUtils * @param {PIXI.Texture} texture - the texture to tint * @param {number} color - the color to use to tint the sprite with @@ -211,7 +207,6 @@ export const canvasUtils = { /** * Tint a texture pixel per pixel. - * * @memberof PIXI.canvasUtils * @param {PIXI.Texture} texture - the texture to tint * @param {number} color - the color to use to tint the sprite with @@ -267,10 +262,9 @@ export const canvasUtils = { /** * Rounds the specified color according to the canvasUtils.cacheStepsPerColorChannel. - * * @memberof PIXI.canvasUtils * @param {number} color - the color to round, should be a hex color - * @return {number} The rounded color. + * @returns {number} The rounded color. */ roundColor: (color: number): number => { @@ -287,7 +281,6 @@ export const canvasUtils = { /** * Number of steps which will be used as a cap when rounding colors. - * * @memberof PIXI.canvasUtils * @type {number} */ @@ -295,7 +288,6 @@ export const canvasUtils = { /** * Tint cache boolean flag. - * * @memberof PIXI.canvasUtils * @type {boolean} */ @@ -303,7 +295,6 @@ export const canvasUtils = { /** * Whether or not the Canvas BlendModes are supported, consequently the ability to tint using the multiply method. - * * @memberof PIXI.canvasUtils * @type {boolean} */ @@ -311,7 +302,6 @@ export const canvasUtils = { /** * The tinting method that will be used. - * * @memberof PIXI.canvasUtils * @type {Function} */ diff --git a/packages/canvas/canvas-renderer/src/index.ts b/packages/canvas-renderer/src/index.ts similarity index 100% rename from packages/canvas/canvas-renderer/src/index.ts rename to packages/canvas-renderer/src/index.ts diff --git a/packages/canvas/canvas-renderer/src/utils/CanvasMaskManager.ts b/packages/canvas-renderer/src/utils/CanvasMaskManager.ts similarity index 99% rename from packages/canvas/canvas-renderer/src/utils/CanvasMaskManager.ts rename to packages/canvas-renderer/src/utils/CanvasMaskManager.ts index 45d1c52812..737f33914d 100644 --- a/packages/canvas/canvas-renderer/src/utils/CanvasMaskManager.ts +++ b/packages/canvas-renderer/src/utils/CanvasMaskManager.ts @@ -9,7 +9,6 @@ import type { Container } from '@pixi/display'; * A set of functions used to handle masking. * * Sprite masking is not supported on the CanvasRenderer. - * * @class * @memberof PIXI */ @@ -27,7 +26,6 @@ export class CanvasMaskManager /** * This method adds it to the current stack of masks. - * * @param maskData - the maskData that will be pushed */ pushMask(maskData: MaskData | Graphics): void @@ -66,7 +64,6 @@ export class CanvasMaskManager /** * Renders all PIXI.Graphics shapes in a subtree. - * * @param container - container to scan. * @param out - where to put found shapes */ @@ -90,7 +87,6 @@ export class CanvasMaskManager /** * Renders a PIXI.Graphics shape. - * * @param graphics - The object to render. */ renderGraphicsShape(graphics: Graphics): void @@ -250,7 +246,6 @@ export class CanvasMaskManager /** * Restores the current drawing context to the state it was before the mask was applied. - * * @param renderer - The renderer context to use. */ popMask(renderer: CanvasRenderer): void diff --git a/packages/canvas/canvas-renderer/src/utils/canUseNewCanvasBlendModes.ts b/packages/canvas-renderer/src/utils/canUseNewCanvasBlendModes.ts similarity index 92% rename from packages/canvas/canvas-renderer/src/utils/canUseNewCanvasBlendModes.ts rename to packages/canvas-renderer/src/utils/canUseNewCanvasBlendModes.ts index 1086306c16..18e36818eb 100644 --- a/packages/canvas/canvas-renderer/src/utils/canUseNewCanvasBlendModes.ts +++ b/packages/canvas-renderer/src/utils/canUseNewCanvasBlendModes.ts @@ -1,9 +1,8 @@ /** * Creates a little colored canvas - * * @ignore * @param {string} color - The color to make the canvas - * @return {canvas} a small canvas element + * @returns {HTMLCanvasElement} a small canvas element */ function createColoredCanvas(color: string): HTMLCanvasElement { @@ -22,9 +21,8 @@ function createColoredCanvas(color: string): HTMLCanvasElement /** * Checks whether the Canvas BlendModes are supported by the current browser - * * @private - * @return {boolean} whether they are supported + * @returns {boolean} whether they are supported */ export function canUseNewCanvasBlendModes(): boolean { diff --git a/packages/canvas/canvas-renderer/src/utils/mapCanvasBlendModesToPixi.ts b/packages/canvas-renderer/src/utils/mapCanvasBlendModesToPixi.ts similarity index 98% rename from packages/canvas/canvas-renderer/src/utils/mapCanvasBlendModesToPixi.ts rename to packages/canvas-renderer/src/utils/mapCanvasBlendModesToPixi.ts index 7037b92b4a..696a5b850d 100644 --- a/packages/canvas/canvas-renderer/src/utils/mapCanvasBlendModesToPixi.ts +++ b/packages/canvas-renderer/src/utils/mapCanvasBlendModesToPixi.ts @@ -3,12 +3,11 @@ import { canUseNewCanvasBlendModes } from './canUseNewCanvasBlendModes'; /** * Maps blend combinations to Canvas. - * * @memberof PIXI * @function mapCanvasBlendModesToPixi * @private * @param {string[]} [array=[]] - The array to output into. - * @return {string[]} Mapped modes. + * @returns {string[]} Mapped modes. */ export function mapCanvasBlendModesToPixi(array: string[] = []): string[] { diff --git a/packages/canvas/canvas-renderer/test/.eslintrc.json b/packages/canvas-renderer/test/.eslintrc.json similarity index 100% rename from packages/canvas/canvas-renderer/test/.eslintrc.json rename to packages/canvas-renderer/test/.eslintrc.json diff --git a/packages/canvas/canvas-renderer/test/CanvasMaskManager.tests.ts b/packages/canvas-renderer/test/CanvasMaskManager.tests.ts similarity index 92% rename from packages/canvas/canvas-renderer/test/CanvasMaskManager.tests.ts rename to packages/canvas-renderer/test/CanvasMaskManager.tests.ts index c8c37d3f8a..4d19825c11 100644 --- a/packages/canvas/canvas-renderer/test/CanvasMaskManager.tests.ts +++ b/packages/canvas-renderer/test/CanvasMaskManager.tests.ts @@ -5,9 +5,9 @@ import { CanvasRenderer } from '@pixi/canvas-renderer'; import sinon from 'sinon'; import { expect } from 'chai'; -describe('CanvasMaskManager', function () +describe('CanvasMaskManager', () => { - it('should work on all graphics masks inside container', function () + it('should work on all graphics masks inside container', () => { const renderer = new CanvasRenderer({ width: 1, height: 1 }); const shapeSpy = sinon.spy(renderer.maskManager, 'renderGraphicsShape'); @@ -40,7 +40,7 @@ describe('CanvasMaskManager', function () expect(contextPath).to.calledThrice; }); - it('should set correct transform for graphics', function () + it('should set correct transform for graphics', () => { const renderer = new CanvasRenderer({ width: 1, height: 1 }); const transformSpy = sinon.spy(renderer.context, 'setTransform'); diff --git a/packages/canvas/canvas-renderer/test/CanvasRenderer.tests.ts b/packages/canvas-renderer/test/CanvasRenderer.tests.ts similarity index 88% rename from packages/canvas/canvas-renderer/test/CanvasRenderer.tests.ts rename to packages/canvas-renderer/test/CanvasRenderer.tests.ts index 9930067388..1b20942b45 100644 --- a/packages/canvas/canvas-renderer/test/CanvasRenderer.tests.ts +++ b/packages/canvas-renderer/test/CanvasRenderer.tests.ts @@ -3,9 +3,9 @@ import { Matrix } from '@pixi/math'; import { CanvasRenderer } from '@pixi/canvas-renderer'; import { expect } from 'chai'; -describe('CanvasRenderer', function () +describe('CanvasRenderer', () => { - it('should default context to rootContext', function () + it('should default context to rootContext', () => { const renderer = new CanvasRenderer({ width: 1, height: 1 }); @@ -19,7 +19,7 @@ describe('CanvasRenderer', function () } }); - it('should allow clear() to work despite no containers added to the renderer', function () + it('should allow clear() to work despite no containers added to the renderer', () => { const renderer = new CanvasRenderer({ width: 1, height: 1 }); @@ -33,7 +33,7 @@ describe('CanvasRenderer', function () } }); - it('should update transform in case of temp parent', function () + it('should update transform in case of temp parent', () => { // this test works only for CanvasRenderer, WebGLRenderer behaviour is different const renderer = new CanvasRenderer({ width: 1, height: 1 }); diff --git a/packages/canvas/canvas-sprite-tiling/LICENSE b/packages/canvas-sprite-tiling/LICENSE similarity index 100% rename from packages/canvas/canvas-sprite-tiling/LICENSE rename to packages/canvas-sprite-tiling/LICENSE diff --git a/packages/canvas/canvas-sprite-tiling/README.md b/packages/canvas-sprite-tiling/README.md similarity index 100% rename from packages/canvas/canvas-sprite-tiling/README.md rename to packages/canvas-sprite-tiling/README.md diff --git a/packages/canvas-sprite-tiling/global.d.ts b/packages/canvas-sprite-tiling/global.d.ts new file mode 100644 index 0000000000..011547f89f --- /dev/null +++ b/packages/canvas-sprite-tiling/global.d.ts @@ -0,0 +1,7 @@ +declare namespace GlobalMixins +{ + interface TilingSprite + { + _canvasPattern: CanvasPattern; + } +} diff --git a/packages/canvas/canvas-sprite-tiling/package.json b/packages/canvas-sprite-tiling/package.json similarity index 59% rename from packages/canvas/canvas-sprite-tiling/package.json rename to packages/canvas-sprite-tiling/package.json index d250e6a5e1..cc49a25504 100644 --- a/packages/canvas/canvas-sprite-tiling/package.json +++ b/packages/canvas-sprite-tiling/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/canvas-sprite-tiling", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/canvas-sprite-tiling.js", "module": "dist/esm/canvas-sprite-tiling.js", "bundle": "dist/browser/canvas-sprite-tiling.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/canvas-sprite-tiling.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/canvas-sprite-tiling.js" + } + } + }, "bundleNoExports": true, "description": "Canvas mixin for the sprite-tiling package", "author": "Mat Groves", @@ -26,10 +39,10 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/canvas-renderer": "6.3.0", - "@pixi/canvas-sprite": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/sprite-tiling": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/canvas-renderer": "6.4.2", + "@pixi/canvas-sprite": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/sprite-tiling": "6.4.2", + "@pixi/utils": "6.4.2" } } diff --git a/packages/canvas/canvas-sprite-tiling/src/TilingSprite.ts b/packages/canvas-sprite-tiling/src/TilingSprite.ts similarity index 99% rename from packages/canvas/canvas-sprite-tiling/src/TilingSprite.ts rename to packages/canvas-sprite-tiling/src/TilingSprite.ts index 4aca4c62a8..0002201326 100644 --- a/packages/canvas/canvas-sprite-tiling/src/TilingSprite.ts +++ b/packages/canvas-sprite-tiling/src/TilingSprite.ts @@ -11,7 +11,6 @@ const patternRect = [new Point(), new Point(), new Point(), new Point()]; /** * Renders the object using the Canvas renderer - * * @protected * @function _renderCanvas * @memberof PIXI.TilingSprite# diff --git a/packages/canvas/canvas-sprite-tiling/src/index.ts b/packages/canvas-sprite-tiling/src/index.ts similarity index 100% rename from packages/canvas/canvas-sprite-tiling/src/index.ts rename to packages/canvas-sprite-tiling/src/index.ts diff --git a/packages/canvas/canvas-sprite/LICENSE b/packages/canvas-sprite/LICENSE similarity index 100% rename from packages/canvas/canvas-sprite/LICENSE rename to packages/canvas-sprite/LICENSE diff --git a/packages/canvas/canvas-sprite/README.md b/packages/canvas-sprite/README.md similarity index 100% rename from packages/canvas/canvas-sprite/README.md rename to packages/canvas-sprite/README.md diff --git a/packages/canvas-sprite/global.d.ts b/packages/canvas-sprite/global.d.ts new file mode 100644 index 0000000000..77592778c6 --- /dev/null +++ b/packages/canvas-sprite/global.d.ts @@ -0,0 +1,8 @@ +declare namespace GlobalMixins +{ + interface Sprite + { + _tintedCanvas: HTMLCanvasElement | HTMLImageElement; + _renderCanvas(renderer: import('@pixi/canvas-renderer').CanvasRenderer): void; + } +} diff --git a/packages/canvas/canvas-sprite/package.json b/packages/canvas-sprite/package.json similarity index 56% rename from packages/canvas/canvas-sprite/package.json rename to packages/canvas-sprite/package.json index 6fb5036caa..1bcfbf0391 100644 --- a/packages/canvas/canvas-sprite/package.json +++ b/packages/canvas-sprite/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/canvas-sprite", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/canvas-sprite.js", "module": "dist/esm/canvas-sprite.js", "bundle": "dist/browser/canvas-sprite.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/canvas-sprite.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/canvas-sprite.js" + } + } + }, "description": "Canvas mixin for the sprite package", "author": "Mat Groves", "contributors": [ @@ -25,11 +38,11 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/canvas-display": "6.3.0", - "@pixi/canvas-renderer": "6.3.0", - "@pixi/constants": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/sprite": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/canvas-display": "6.4.2", + "@pixi/canvas-renderer": "6.4.2", + "@pixi/constants": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/sprite": "6.4.2", + "@pixi/utils": "6.4.2" } } diff --git a/packages/canvas/canvas-sprite/src/CanvasSpriteRenderer.ts b/packages/canvas-sprite/src/CanvasSpriteRenderer.ts similarity index 99% rename from packages/canvas/canvas-sprite/src/CanvasSpriteRenderer.ts rename to packages/canvas-sprite/src/CanvasSpriteRenderer.ts index 737867f854..d9be1dcd46 100644 --- a/packages/canvas/canvas-sprite/src/CanvasSpriteRenderer.ts +++ b/packages/canvas-sprite/src/CanvasSpriteRenderer.ts @@ -26,7 +26,6 @@ const canvasRenderWorldTransform = new Matrix(); /** * Renderer dedicated to drawing and batching sprites. - * * @class * @protected * @memberof PIXI @@ -44,7 +43,6 @@ export class CanvasSpriteRenderer /** * Renders the sprite object. - * * @param sprite - the sprite to render when using this spritebatch */ render(sprite: Sprite): void diff --git a/packages/canvas/canvas-sprite/src/Sprite.ts b/packages/canvas-sprite/src/Sprite.ts similarity index 70% rename from packages/canvas/canvas-sprite/src/Sprite.ts rename to packages/canvas-sprite/src/Sprite.ts index a57f0e0d3e..698fe198e9 100644 --- a/packages/canvas/canvas-sprite/src/Sprite.ts +++ b/packages/canvas-sprite/src/Sprite.ts @@ -10,13 +10,12 @@ import type { CanvasRenderer } from '@pixi/canvas-renderer'; Sprite.prototype._tintedCanvas = null; /** -* Renders the object using the Canvas renderer -* -* @private -* @method _renderCanvas -* @memberof PIXI.Sprite# -* @param {PIXI.CanvasRenderer} renderer - The renderer -*/ + * Renders the object using the Canvas renderer + * @private + * @method _renderCanvas + * @memberof PIXI.Sprite# + * @param {PIXI.CanvasRenderer} renderer - The renderer + */ Sprite.prototype._renderCanvas = function _renderCanvas(renderer: CanvasRenderer): void { renderer.plugins.sprite.render(this); diff --git a/packages/canvas/canvas-sprite/src/index.ts b/packages/canvas-sprite/src/index.ts similarity index 100% rename from packages/canvas/canvas-sprite/src/index.ts rename to packages/canvas-sprite/src/index.ts diff --git a/packages/canvas/canvas-sprite/test/.eslintrc.json b/packages/canvas-sprite/test/.eslintrc.json similarity index 100% rename from packages/canvas/canvas-sprite/test/.eslintrc.json rename to packages/canvas-sprite/test/.eslintrc.json diff --git a/packages/canvas/canvas-sprite/test/CanvasSpriteRenderer.tests.ts b/packages/canvas-sprite/test/CanvasSpriteRenderer.tests.ts similarity index 84% rename from packages/canvas/canvas-sprite/test/CanvasSpriteRenderer.tests.ts rename to packages/canvas-sprite/test/CanvasSpriteRenderer.tests.ts index 924dff8088..6b6b85b006 100644 --- a/packages/canvas/canvas-sprite/test/CanvasSpriteRenderer.tests.ts +++ b/packages/canvas-sprite/test/CanvasSpriteRenderer.tests.ts @@ -3,12 +3,12 @@ import { Sprite } from '@pixi/sprite'; import { CanvasRenderer } from '@pixi/canvas-renderer'; import { expect } from 'chai'; -describe('CanvasSpriteRenderer', function () +describe('CanvasSpriteRenderer', () => { - it('should still render a sprite after texture is destroyed', function () + it('should still render a sprite after texture is destroyed', () => { const renderer = new CanvasRenderer({ width: 1, height: 1 }); - const texture = new Texture(Texture.WHITE); + const texture = Texture.WHITE; const sprite = new Sprite(texture); renderer.render(sprite); diff --git a/packages/canvas/canvas-text/LICENSE b/packages/canvas-text/LICENSE similarity index 100% rename from packages/canvas/canvas-text/LICENSE rename to packages/canvas-text/LICENSE diff --git a/packages/canvas/canvas-text/README.md b/packages/canvas-text/README.md similarity index 100% rename from packages/canvas/canvas-text/README.md rename to packages/canvas-text/README.md diff --git a/packages/canvas/canvas-text/package.json b/packages/canvas-text/package.json similarity index 60% rename from packages/canvas/canvas-text/package.json rename to packages/canvas-text/package.json index 368008f81a..ab96689b2a 100644 --- a/packages/canvas/canvas-text/package.json +++ b/packages/canvas-text/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/canvas-text", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/canvas-text.js", "module": "dist/esm/canvas-text.js", "bundle": "dist/browser/canvas-text.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/canvas-text.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/canvas-text.js" + } + } + }, "bundleNoExports": true, "description": "Canvas mixin for the text package", "author": "Dave Moore", @@ -23,8 +36,8 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/canvas-sprite": "6.3.0", - "@pixi/sprite": "6.3.0", - "@pixi/text": "6.3.0" + "@pixi/canvas-sprite": "6.4.2", + "@pixi/sprite": "6.4.2", + "@pixi/text": "6.4.2" } } diff --git a/packages/canvas/canvas-text/src/Text.ts b/packages/canvas-text/src/Text.ts similarity index 99% rename from packages/canvas/canvas-text/src/Text.ts rename to packages/canvas-text/src/Text.ts index f4f730d426..c71bed8380 100644 --- a/packages/canvas/canvas-text/src/Text.ts +++ b/packages/canvas-text/src/Text.ts @@ -5,7 +5,6 @@ import type { CanvasRenderer } from '@pixi/canvas-renderer'; /** * Renders the object using the Canvas renderer - * * @method _renderCanvas * @memberof PIXI.Text# * @private diff --git a/packages/canvas/canvas-text/src/index.ts b/packages/canvas-text/src/index.ts similarity index 100% rename from packages/canvas/canvas-text/src/index.ts rename to packages/canvas-text/src/index.ts diff --git a/packages/canvas/canvas-graphics/global.d.ts b/packages/canvas/canvas-graphics/global.d.ts deleted file mode 100644 index 183cc55a3a..0000000000 --- a/packages/canvas/canvas-graphics/global.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -declare namespace GlobalMixins { - interface Graphics { - _renderCanvas(renderer: import('@pixi/canvas-renderer').CanvasRenderer): void; - generateCanvasTexture(scaleMode: import('@pixi/constants').SCALE_MODES, resolution?: number): Texture; - cachedGraphicsData: import('@pixi/graphics').GraphicsData[]; - } -} diff --git a/packages/canvas/canvas-sprite-tiling/global.d.ts b/packages/canvas/canvas-sprite-tiling/global.d.ts deleted file mode 100644 index e445fb0027..0000000000 --- a/packages/canvas/canvas-sprite-tiling/global.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -declare namespace GlobalMixins { - interface TilingSprite { - _canvasPattern: CanvasPattern; - } -} diff --git a/packages/canvas/canvas-sprite/global.d.ts b/packages/canvas/canvas-sprite/global.d.ts deleted file mode 100644 index 5f57e9e597..0000000000 --- a/packages/canvas/canvas-sprite/global.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -declare namespace GlobalMixins { - interface Sprite { - _tintedCanvas: HTMLCanvasElement|HTMLImageElement; - _renderCanvas(renderer: import('@pixi/canvas-renderer').CanvasRenderer): void; - } -} diff --git a/packages/compressed-textures/global.d.ts b/packages/compressed-textures/global.d.ts new file mode 100644 index 0000000000..156f0dc132 --- /dev/null +++ b/packages/compressed-textures/global.d.ts @@ -0,0 +1,8 @@ +declare namespace GlobalMixins +{ + // eslint-disable-next-line @typescript-eslint/no-empty-interface + interface BaseTexture + { + ktxKeyValueData: Map; + } +} diff --git a/packages/compressed-textures/package.json b/packages/compressed-textures/package.json index f1bf6a3fb9..0d09050903 100644 --- a/packages/compressed-textures/package.json +++ b/packages/compressed-textures/package.json @@ -1,6 +1,6 @@ { "name": "@pixi/compressed-textures", - "version": "6.3.0", + "version": "6.4.2", "description": "Loaders for compressed texture file formats", "keywords": [ "pixi.js", @@ -16,6 +16,19 @@ "main": "dist/cjs/compressed-textures.js", "module": "dist/esm/compressed-textures.js", "bundle": "dist/browser/compressed-textures.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/compressed-textures.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/compressed-textures.js" + } + } + }, "publishConfig": { "access": "public" }, @@ -35,9 +48,10 @@ "url": "https://github.com/pixijs/pixi.js/issues" }, "peerDependencies": { - "@pixi/constants": "6.3.0", - "@pixi/core": "6.3.0", - "@pixi/loaders": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/constants": "6.4.2", + "@pixi/core": "6.4.2", + "@pixi/loaders": "6.4.2", + "@pixi/settings": "6.4.2", + "@pixi/utils": "6.4.2" } } diff --git a/packages/compressed-textures/src/const.ts b/packages/compressed-textures/src/const.ts index abc8f655bb..e1573724aa 100644 --- a/packages/compressed-textures/src/const.ts +++ b/packages/compressed-textures/src/const.ts @@ -1,38 +1,39 @@ /** * WebGL internal formats, including compressed texture formats provided by extensions - * * @memberof PIXI * @static * @name INTERNAL_FORMATS * @enum {number} - * @property {number} COMPRESSED_RGB_S3TC_DXT1_EXT=0x83F0 - * @property {number} COMPRESSED_RGBA_S3TC_DXT1_EXT=0x83F1 - * @property {number} COMPRESSED_RGBA_S3TC_DXT3_EXT=0x83F2 - * @property {number} COMPRESSED_RGBA_S3TC_DXT5_EXT=0x83F3 - * @property {number} COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917 - * @property {number} COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918 - * @property {number} COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919 - * @property {number} COMPRESSED_SRGB_S3TC_DXT1_EXT=35916 - * @property {number} COMPRESSED_R11_EAC=0x9270 - * @property {number} COMPRESSED_SIGNED_R11_EAC=0x9271 - * @property {number} COMPRESSED_RG11_EAC=0x9272 - * @property {number} COMPRESSED_SIGNED_RG11_EAC=0x9273 - * @property {number} COMPRESSED_RGB8_ETC2=0x9274 - * @property {number} COMPRESSED_RGBA8_ETC2_EAC=0x9278 - * @property {number} COMPRESSED_SRGB8_ETC2=0x9275 - * @property {number} COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=0x9279 - * @property {number} COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=0x9276 - * @property {number} COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=0x9277 - * @property {number} COMPRESSED_RGB_PVRTC_4BPPV1_IMG=0x8C00 - * @property {number} COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=0x8C02 - * @property {number} COMPRESSED_RGB_PVRTC_2BPPV1_IMG=0x8C01 - * @property {number} COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=0x8C03 - * @property {number} COMPRESSED_RGB_ETC1_WEBGL=0x8D64 - * @property {number} COMPRESSED_RGB_ATC_WEBGL=0x8C92 - * @property {number} COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=0x8C92 - * @property {number} COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=0x87EE + * @property {number} [COMPRESSED_RGB_S3TC_DXT1_EXT=0x83F0] - + * @property {number} [COMPRESSED_RGBA_S3TC_DXT1_EXT=0x83F1] - + * @property {number} [COMPRESSED_RGBA_S3TC_DXT3_EXT=0x83F2] - + * @property {number} [COMPRESSED_RGBA_S3TC_DXT5_EXT=0x83F3] - + * @property {number} [COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917] - + * @property {number} [COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918] - + * @property {number} [COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919] - + * @property {number} [COMPRESSED_SRGB_S3TC_DXT1_EXT=35916] - + * @property {number} [COMPRESSED_R11_EAC=0x9270] - + * @property {number} [COMPRESSED_SIGNED_R11_EAC=0x9271] - + * @property {number} [COMPRESSED_RG11_EAC=0x9272] - + * @property {number} [COMPRESSED_SIGNED_RG11_EAC=0x9273] - + * @property {number} [COMPRESSED_RGB8_ETC2=0x9274] - + * @property {number} [COMPRESSED_RGBA8_ETC2_EAC=0x9278] - + * @property {number} [COMPRESSED_SRGB8_ETC2=0x9275] - + * @property {number} [COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=0x9279] - + * @property {number} [COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=0x9276] - + * @property {number} [COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=0x9277] - + * @property {number} [COMPRESSED_RGB_PVRTC_4BPPV1_IMG=0x8C00] - + * @property {number} [COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=0x8C02] - + * @property {number} [COMPRESSED_RGB_PVRTC_2BPPV1_IMG=0x8C01] - + * @property {number} [COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=0x8C03] - + * @property {number} [COMPRESSED_RGB_ETC1_WEBGL=0x8D64] - + * @property {number} [COMPRESSED_RGB_ATC_WEBGL=0x8C92] - + * @property {number} [COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=0x8C92] - + * @property {number} [COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=0x87EE] - */ -export enum INTERNAL_FORMATS { +export enum INTERNAL_FORMATS +// eslint-disable-next-line @typescript-eslint/indent +{ // WEBGL_compressed_texture_s3tc COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0, COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1, @@ -75,7 +76,6 @@ export enum INTERNAL_FORMATS { /** * Maps the compressed texture formats in {@link PIXI.INTERNAL_FORMATS} to the number of bytes taken by * each texel. - * * @memberof PIXI * @static * @ignore diff --git a/packages/compressed-textures/src/loaders/CompressedTextureLoader.ts b/packages/compressed-textures/src/loaders/CompressedTextureLoader.ts index eb8f1dd088..895675a2d1 100644 --- a/packages/compressed-textures/src/loaders/CompressedTextureLoader.ts +++ b/packages/compressed-textures/src/loaders/CompressedTextureLoader.ts @@ -6,7 +6,6 @@ import type { INTERNAL_FORMATS } from '../const'; /** * Schema for compressed-texture manifests - * * @ignore * @see PIXI.CompressedTextureLoader */ @@ -16,9 +15,7 @@ export type CompressedTextureManifest = { }; // Missing typings? - https://github.com/microsoft/TypeScript/issues/39655 -/** - * Compressed texture extensions - */ +/** Compressed texture extensions */ /* eslint-disable camelcase */ export type CompressedTextureExtensions = { s3tc?: WEBGL_compressed_texture_s3tc, @@ -34,18 +31,17 @@ export type CompressedTextureExtensionRef = keyof CompressedTextureExtensions; /** * Loader plugin for handling compressed textures for all platforms. - * * @class * @memberof PIXI - * @implements PIXI.ILoaderPlugin + * @implements {PIXI.ILoaderPlugin} */ export class CompressedTextureLoader { /** Map of available texture extensions. */ - static textureExtensions: Partial; + private static _textureExtensions: Partial; /** Map of available texture formats. */ - static textureFormats: { [P in keyof INTERNAL_FORMATS]?: number }; + private static _textureFormats: { [P in keyof INTERNAL_FORMATS]?: number }; /** * Called after a compressed-textures manifest is loaded. @@ -160,52 +156,66 @@ export class CompressedTextureLoader } } - /** - * Detects the available compressed texture extensions on the device. - * @ignore - */ - static add(): void + /** Map of available texture extensions. */ + public static get textureExtensions(): Partial { - // Auto-detect WebGL compressed-texture extensions - const canvas = document.createElement('canvas'); - const gl = canvas.getContext('webgl'); - - if (!gl) + if (!CompressedTextureLoader._textureExtensions) { - // #if _DEBUG - console.warn('WebGL not available for compressed textures. Silently failing.'); - // #endif + // Auto-detect WebGL compressed-texture extensions + const canvas = document.createElement('canvas'); + const gl = canvas.getContext('webgl'); + + if (!gl) + { + // #if _DEBUG + console.warn('WebGL not available for compressed textures. Silently failing.'); + // #endif + + return {}; + } + + const extensions = { + s3tc: gl.getExtension('WEBGL_compressed_texture_s3tc'), + s3tc_sRGB: gl.getExtension('WEBGL_compressed_texture_s3tc_srgb'), /* eslint-disable-line camelcase */ + etc: gl.getExtension('WEBGL_compressed_texture_etc'), + etc1: gl.getExtension('WEBGL_compressed_texture_etc1'), + pvrtc: gl.getExtension('WEBGL_compressed_texture_pvrtc') + || gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc'), + atc: gl.getExtension('WEBGL_compressed_texture_atc'), + astc: gl.getExtension('WEBGL_compressed_texture_astc') + }; - return; + CompressedTextureLoader._textureExtensions = extensions; } - const extensions = { - s3tc: gl.getExtension('WEBGL_compressed_texture_s3tc'), - s3tc_sRGB: gl.getExtension('WEBGL_compressed_texture_s3tc_srgb'), /* eslint-disable-line camelcase */ - etc: gl.getExtension('WEBGL_compressed_texture_etc'), - etc1: gl.getExtension('WEBGL_compressed_texture_etc1'), - pvrtc: gl.getExtension('WEBGL_compressed_texture_pvrtc') - || gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc'), - atc: gl.getExtension('WEBGL_compressed_texture_atc'), - astc: gl.getExtension('WEBGL_compressed_texture_astc') - }; - - CompressedTextureLoader.textureExtensions = extensions; - CompressedTextureLoader.textureFormats = {}; - - // Assign all available compressed-texture formats - for (const extensionName in extensions) + return CompressedTextureLoader._textureExtensions; + } + + /** Map of available texture formats. */ + public static get textureFormats(): { [P in keyof INTERNAL_FORMATS]?: number } + { + if (!CompressedTextureLoader._textureFormats) { - const extension = extensions[extensionName as CompressedTextureExtensionRef]; + const extensions = CompressedTextureLoader.textureExtensions; + + CompressedTextureLoader._textureFormats = {}; - if (!extension) + // Assign all available compressed-texture formats + for (const extensionName in extensions) { - continue; - } + const extension = extensions[extensionName as CompressedTextureExtensionRef]; - Object.assign( - CompressedTextureLoader.textureFormats, - Object.getPrototypeOf(extension)); + if (!extension) + { + continue; + } + + Object.assign( + CompressedTextureLoader._textureFormats, + Object.getPrototypeOf(extension)); + } } + + return CompressedTextureLoader._textureFormats; } } diff --git a/packages/compressed-textures/src/loaders/DDSLoader.ts b/packages/compressed-textures/src/loaders/DDSLoader.ts index 05686bb798..455df4849e 100644 --- a/packages/compressed-textures/src/loaders/DDSLoader.ts +++ b/packages/compressed-textures/src/loaders/DDSLoader.ts @@ -16,7 +16,6 @@ const DDS_MAGIC = 0x20534444; /** * DWORD offsets of the DDS file header fields (relative to file start). - * * @ignore */ const DDS_FIELDS = { @@ -30,7 +29,6 @@ const DDS_FIELDS = { /** * DWORD offsets of the DDS PIXEL_FORMAT fields. - * * @ignore */ const DDS_PF_FIELDS = { @@ -46,7 +44,6 @@ const DDS_PF_FIELDS = { /** * DWORD offsets of the DDS_HEADER_DX10 fields. - * * @ignore */ const DDS_DX10_FIELDS = { @@ -63,7 +60,8 @@ const DDS_DX10_FIELDS = { */ // This is way over-blown for us! Lend us a hand, and remove the ones that aren't used (but set the remaining // ones to their correct value) -enum DXGI_FORMAT { +enum DXGI_FORMAT + { DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_R32G32B32A32_TYPELESS, DXGI_FORMAT_R32G32B32A32_FLOAT, @@ -190,10 +188,10 @@ enum DXGI_FORMAT { /** * Possible values of the field {@link DDS_DX10_FIELDS.RESOURCE_DIMENSION} - * * @ignore */ -enum D3D10_RESOURCE_DIMENSION { +enum D3D10_RESOURCE_DIMENSION + { DDS_DIMENSION_TEXTURE1D = 2, DDS_DIMENSION_TEXTURE2D = 3, DDS_DIMENSION_TEXTURE3D = 6 @@ -219,7 +217,6 @@ const DDS_RESOURCE_MISC_TEXTURECUBE = 0x4; /** * Maps `FOURCC_*` formats to internal formats (see {@link PIXI.INTERNAL_FORMATS}). - * * @ignore */ const FOURCC_TO_FORMAT: { [id: number]: number } = { @@ -230,7 +227,6 @@ const FOURCC_TO_FORMAT: { [id: number]: number } = { /** * Maps {@link DXGI_FORMAT} to types/internal-formats (see {@link PIXI.TYPES}, {@link PIXI.INTERNAL_FORMATS}) - * * @ignore */ const DXGI_TO_FORMAT: { [id: number]: number } = { @@ -251,7 +247,7 @@ const DXGI_TO_FORMAT: { [id: number]: number } = { /** * @class * @memberof PIXI - * @implements PIXI.ILoaderPlugin + * @implements {PIXI.ILoaderPlugin} * @see https://docs.microsoft.com/en-us/windows/win32/direct3ddds/dx-graphics-dds-pguide */ export class DDSLoader diff --git a/packages/compressed-textures/src/loaders/KTXLoader.ts b/packages/compressed-textures/src/loaders/KTXLoader.ts index 63f4ad9ef6..6ee642cfc5 100644 --- a/packages/compressed-textures/src/loaders/KTXLoader.ts +++ b/packages/compressed-textures/src/loaders/KTXLoader.ts @@ -10,7 +10,6 @@ LoaderResource.setExtensionXhrType('ktx', LoaderResource.XHR_RESPONSE_TYPE.BUFFE /** * The 12-byte KTX file identifier - * * @see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/#2.1 * @ignore */ @@ -18,7 +17,6 @@ const FILE_IDENTIFIER = [0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0 /** * The value stored in the "endianness" field. - * * @see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/#2.2 * @ignore */ @@ -26,7 +24,6 @@ const ENDIANNESS = 0x04030201; /** * Byte offsets of the KTX file header fields - * * @ignore */ const KTX_FIELDS = { @@ -48,14 +45,12 @@ const KTX_FIELDS = { /** * Byte size of the file header fields in {@code KTX_FIELDS} - * * @ignore */ const FILE_HEADER_SIZE = 64; /** * Maps {@link PIXI.TYPES} to the bytes taken per component, excluding those ones that are bit-fields. - * * @ignore */ export const TYPES_TO_BYTES_PER_COMPONENT: { [id: number]: number } = { @@ -69,7 +64,6 @@ export const TYPES_TO_BYTES_PER_COMPONENT: { [id: number]: number } = { /** * Number of components in each {@link PIXI.FORMATS} - * * @ignore */ export const FORMATS_TO_COMPONENTS: { [id: number]: number } = { @@ -84,7 +78,6 @@ export const FORMATS_TO_COMPONENTS: { [id: number]: number } = { /** * Number of bytes per pixel in bit-field types in {@link PIXI.TYPES} - * * @ignore */ export const TYPES_TO_BYTES_PER_PIXEL: { [id: number]: number } = { @@ -99,26 +92,34 @@ export const TYPES_TO_BYTES_PER_PIXEL: { [id: number]: number } = { * This KTX loader does not currently support the following features: * * cube textures * * 3D textures - * * vendor-specific key/value data parsing * * endianness conversion for big-endian machines * * embedded *.basis files * * It does supports the following features: * * multiple textures per file * * mipmapping (only for compressed formats) - * + * * vendor-specific key/value data parsing (enable {@link PIXI.KTXLoader.loadKeyValueData}) * @class * @memberof PIXI - * @implements PIXI.ILoaderPlugin + * @implements {PIXI.ILoaderPlugin} */ export class KTXLoader { + /** + * If set to `true`, {@link PIXI.KTXLoader} will parse key-value data in KTX textures. This feature relies + * on the [Encoding Standard]{@link https://encoding.spec.whatwg.org}. + * + * The key-value data will be available on the base-textures as {@code PIXI.BaseTexture.ktxKeyValueData}. They + * will hold a reference to the texture data buffer, so make sure to delete key-value data once you are done + * using it. + */ + static loadKeyValueData = false; + /** * Called after a KTX file is loaded. * * This will parse the KTX file header and add a {@code BaseTexture} to the texture * cache. - * * @see PIXI.Loader.loaderMiddleware * @param resource - loader resource that is checked to see if it is a KTX file * @param next - callback Function to call when done @@ -130,15 +131,25 @@ export class KTXLoader try { const url = resource.name || resource.url; - const { compressed, uncompressed } = KTXLoader.parse(url, resource.data); + const { compressed, uncompressed, kvData } = KTXLoader.parse(url, resource.data); if (compressed) { - Object.assign(resource, registerCompressedTextures( + const result = registerCompressedTextures( url, compressed, resource.metadata, - )); + ); + + if (kvData && result.textures) + { + for (const textureId in result.textures) + { + result.textures[textureId].baseTexture.ktxKeyValueData = kvData; + } + } + + Object.assign(resource, result); } else if (uncompressed) { @@ -157,6 +168,8 @@ export class KTXLoader )); const cacheID = `${url}-${i + 1}`; + if (kvData) texture.baseTexture.ktxKeyValueData = kvData; + BaseTexture.addToCache(texture.baseTexture, cacheID); Texture.addToCache(texture, cacheID); @@ -188,6 +201,7 @@ export class KTXLoader private static parse(url: string, arrayBuffer: ArrayBuffer): { compressed?: CompressedTextureResource[] uncompressed?: { resource: BufferResource, type: TYPES, format: FORMATS }[] + kvData: Map | null } { const dataView = new DataView(arrayBuffer); @@ -268,6 +282,10 @@ export class KTXLoader throw new Error('Unable to resolve the pixel format stored in the *.ktx file!'); } + const kvData: Map | null = KTXLoader.loadKeyValueData + ? KTXLoader.parseKvData(dataView, bytesOfKeyValueData, littleEndian) + : null; + const imageByteSize = imagePixels * imagePixelByteSize; let mipByteSize = imageByteSize; let mipWidth = pixelWidth; @@ -362,7 +380,8 @@ export class KTXLoader type: glType, format: convertToInt ? KTXLoader.convertFormatToInteger(glFormat) : glFormat, }; - }) + }), + kvData }; } @@ -373,7 +392,8 @@ export class KTXLoader height: pixelHeight, levels: numberOfMipmapLevels, levelBuffers, - })) + })), + kvData }; } @@ -408,4 +428,59 @@ export class KTXLoader default: return format; } } + + private static parseKvData(dataView: DataView, bytesOfKeyValueData: number, littleEndian: boolean): Map + { + const kvData = new Map(); + let bytesIntoKeyValueData = 0; + + while (bytesIntoKeyValueData < bytesOfKeyValueData) + { + const keyAndValueByteSize = dataView.getUint32(FILE_HEADER_SIZE + bytesIntoKeyValueData, littleEndian); + const keyAndValueByteOffset = FILE_HEADER_SIZE + bytesIntoKeyValueData + 4; + const valuePadding = 3 - ((keyAndValueByteSize + 3) % 4); + + // Bounds check + if (keyAndValueByteSize === 0 || keyAndValueByteSize > bytesOfKeyValueData - bytesIntoKeyValueData) + { + console.error('KTXLoader: keyAndValueByteSize out of bounds'); + break; + } + + // Note: keyNulByte can't be 0 otherwise the key is an empty string. + let keyNulByte = 0; + + for (; keyNulByte < keyAndValueByteSize; keyNulByte++) + { + if (dataView.getUint8(keyAndValueByteOffset + keyNulByte) === 0x00) + { + break; + } + } + + if (keyNulByte === -1) + { + console.error('KTXLoader: Failed to find null byte terminating kvData key'); + break; + } + + const key = new TextDecoder().decode( + new Uint8Array(dataView.buffer, keyAndValueByteOffset, keyNulByte) + ); + const value = new DataView( + dataView.buffer, + keyAndValueByteOffset + keyNulByte + 1, + keyAndValueByteSize - keyNulByte - 1, + ); + + kvData.set(key, value); + + // 4 = the keyAndValueByteSize field itself + // keyAndValueByteSize = the bytes taken by the key and value + // valuePadding = extra padding to align with 4 bytes + bytesIntoKeyValueData += 4 + keyAndValueByteSize + valuePadding; + } + + return kvData; + } } diff --git a/packages/compressed-textures/src/loaders/registerCompressedTextures.ts b/packages/compressed-textures/src/loaders/registerCompressedTextures.ts index 6930b41e68..627f7c0ce5 100644 --- a/packages/compressed-textures/src/loaders/registerCompressedTextures.ts +++ b/packages/compressed-textures/src/loaders/registerCompressedTextures.ts @@ -14,14 +14,15 @@ type CompressedTexturesResult = Pick; * Creates base-textures and textures for each compressed-texture resource and adds them into the global * texture cache. The first texture has two IDs - `${url}`, `${url}-1`; while the rest have an ID of the * form `${url}-i`. - * * @param url - the original address of the resources * @param resources - the resources backing texture data * @ignore */ -export function registerCompressedTextures(url: string, +export function registerCompressedTextures( + url: string, resources: CompressedTextureResource[], - metadata: IResourceMetadata): CompressedTexturesResult + metadata: IResourceMetadata +): CompressedTexturesResult { const result: CompressedTexturesResult = { textures: {}, diff --git a/packages/compressed-textures/src/resources/BlobResource.ts b/packages/compressed-textures/src/resources/BlobResource.ts index e2d4f9b863..5bcc71747e 100644 --- a/packages/compressed-textures/src/resources/BlobResource.ts +++ b/packages/compressed-textures/src/resources/BlobResource.ts @@ -9,7 +9,6 @@ interface IBlobOptions /** * Resource that fetches texture data over the network and stores it in a buffer. - * * @class * @extends PIXI.Resource * @memberof PIXI @@ -21,9 +20,12 @@ export abstract class BlobResource extends BufferResource protected loaded: boolean; /** - * @param {string} url - the URL of the texture file - * @param {boolean}[autoLoad] - whether to fetch the data immediately; + * @param {string} source - the URL of the texture file + * @param {PIXI.IBlobOptions} options + * @param {boolean}[options.autoLoad] - whether to fetch the data immediately; * you can fetch it later via {@link BlobResource#load} + * @param {boolean}[options.width] - the width in pixels. + * @param {boolean}[options.height] - the height in pixels. */ constructor(source: string | Uint8Array | Uint32Array | Float32Array, options: IBlobOptions = { width: 1, height: 1, autoLoad: true }) @@ -74,9 +76,7 @@ export abstract class BlobResource extends BufferResource // TODO: Override this method } - /** - * Loads the blob - */ + /** Loads the blob */ async load(): Promise { const response = await fetch(this.origin); diff --git a/packages/compressed-textures/src/resources/CompressedTextureResource.ts b/packages/compressed-textures/src/resources/CompressedTextureResource.ts index cf024839ca..6e2e0a3919 100644 --- a/packages/compressed-textures/src/resources/CompressedTextureResource.ts +++ b/packages/compressed-textures/src/resources/CompressedTextureResource.ts @@ -37,10 +37,10 @@ export interface ICompressedTextureResourceOptions * For most developers, container file formats are a better abstraction instead of directly handling raw texture * data. PixiJS provides native support for the following texture file formats (via {@link PIXI.Loader}): * - * * **.dds** - the DirectDraw Surface file format stores DXTn (DXT-1,3,5) data. See {@link PIXI.DDSLoader} - * * **.ktx** - the Khronos Texture Container file format supports storing all the supported WebGL compression formats. + * **.dds** - the DirectDraw Surface file format stores DXTn (DXT-1,3,5) data. See {@link PIXI.DDSLoader} + * **.ktx** - the Khronos Texture Container file format supports storing all the supported WebGL compression formats. * See {@link PIXI.KTXLoader}. - * * **.basis** - the BASIS supercompressed file format stores texture data in an internal format that is transcoded + * **.basis** - the BASIS supercompressed file format stores texture data in an internal format that is transcoded * to the compression format supported on the device at _runtime_. It also supports transcoding into a uncompressed * format as a fallback; you must install the `@pixi/basis-loader`, `@pixi/basis-transcoder` packages separately to * use these files. See {@link PIXI.BasisLoader}. @@ -73,7 +73,6 @@ export interface ICompressedTextureResourceOptions * PIXI.BaseTexture.addToCache(baseTexture, "bunny.dxt5"); * PIXI.Texture.addToCache(texture, "bunny.dxt5"); * ``` - * * @memberof PIXI */ export class CompressedTextureResource extends BlobResource @@ -172,13 +171,12 @@ export class CompressedTextureResource extends BlobResource /** * Returns the key (to ContextSystem#extensions) for the WebGL extension supporting the compression format - * * @private * @param format - the compression format to get the extension for. */ private static _formatToExtension(format: INTERNAL_FORMATS): - 's3tc' | 's3tc_sRGB' | 'atc' | - 'astc' | 'etc' | 'etc1' | 'pvrtc' + 's3tc' | 's3tc_sRGB' | 'atc' | + 'astc' | 'etc' | 'etc1' | 'pvrtc' { if (format >= 0x83F0 && format <= 0x83F3) { @@ -206,7 +204,6 @@ export class CompressedTextureResource extends BlobResource /** * Pre-creates buffer views for each mipmap level - * * @private * @param buffer - * @param format - compression formats diff --git a/packages/constants/package.json b/packages/constants/package.json index 2c851334ab..4cbb5aad27 100644 --- a/packages/constants/package.json +++ b/packages/constants/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/constants", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/constants.js", "module": "dist/esm/constants.js", "bundle": "dist/browser/constants.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/constants.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/constants.js" + } + } + }, "description": "Constants used across PixiJS", "author": "Mat Groves", "contributors": [ diff --git a/packages/constants/src/index.ts b/packages/constants/src/index.ts index 1c4ba80852..1561453e9c 100644 --- a/packages/constants/src/index.ts +++ b/packages/constants/src/index.ts @@ -1,6 +1,5 @@ /** * Different types of environments for WebGL. - * * @static * @memberof PIXI * @name ENV @@ -10,7 +9,9 @@ * @property {number} WEBGL - Version 1 of WebGL * @property {number} WEBGL2 - Version 2 of WebGL */ -export enum ENV { +export enum ENV +// eslint-disable-next-line @typescript-eslint/indent +{ WEBGL_LEGACY, WEBGL, WEBGL2, @@ -18,7 +19,6 @@ export enum ENV { /** * Constant to identify the Renderer Type. - * * @static * @memberof PIXI * @name RENDERER_TYPE @@ -27,7 +27,9 @@ export enum ENV { * @property {number} WEBGL - WebGL render type. * @property {number} CANVAS - Canvas render type. */ -export enum RENDERER_TYPE { +export enum RENDERER_TYPE +// eslint-disable-next-line @typescript-eslint/indent +{ UNKNOWN, WEBGL, CANVAS, @@ -35,7 +37,6 @@ export enum RENDERER_TYPE { /** * Bitwise OR of masks that indicate the buffers to be cleared. - * * @static * @memberof PIXI * @name BUFFER_BITS @@ -44,7 +45,9 @@ export enum RENDERER_TYPE { * @property {number} DEPTH - Indicates the depth buffer. * @property {number} STENCIL - Indicates the stencil buffer. */ -export enum BUFFER_BITS { +export enum BUFFER_BITS +// eslint-disable-next-line @typescript-eslint/indent +{ COLOR = 0x00004000, DEPTH = 0x00000100, STENCIL = 0x00000400 @@ -55,44 +58,45 @@ export enum BUFFER_BITS { * * IMPORTANT - The WebGL renderer only supports the NORMAL, ADD, MULTIPLY and SCREEN blend modes. * Anything else will silently act like NORMAL. - * * @memberof PIXI * @name BLEND_MODES * @enum {number} - * @property {number} NORMAL - * @property {number} ADD - * @property {number} MULTIPLY - * @property {number} SCREEN - * @property {number} OVERLAY - * @property {number} DARKEN - * @property {number} LIGHTEN - * @property {number} COLOR_DODGE - * @property {number} COLOR_BURN - * @property {number} HARD_LIGHT - * @property {number} SOFT_LIGHT - * @property {number} DIFFERENCE - * @property {number} EXCLUSION - * @property {number} HUE - * @property {number} SATURATION - * @property {number} COLOR - * @property {number} LUMINOSITY - * @property {number} NORMAL_NPM - * @property {number} ADD_NPM - * @property {number} SCREEN_NPM - * @property {number} NONE - * @property {number} SRC_IN - * @property {number} SRC_OUT - * @property {number} SRC_ATOP - * @property {number} DST_OVER - * @property {number} DST_IN - * @property {number} DST_OUT - * @property {number} DST_ATOP - * @property {number} SUBTRACT - * @property {number} SRC_OVER - * @property {number} ERASE - * @property {number} XOR + * @property {number} NORMAL - + * @property {number} ADD - + * @property {number} MULTIPLY - + * @property {number} SCREEN - + * @property {number} OVERLAY - + * @property {number} DARKEN - + * @property {number} LIGHTEN - + * @property {number} COLOR_DODGE - + * @property {number} COLOR_BURN - + * @property {number} HARD_LIGHT - + * @property {number} SOFT_LIGHT - + * @property {number} DIFFERENCE - + * @property {number} EXCLUSION - + * @property {number} HUE - + * @property {number} SATURATION - + * @property {number} COLOR - + * @property {number} LUMINOSITY - + * @property {number} NORMAL_NPM - + * @property {number} ADD_NPM - + * @property {number} SCREEN_NPM - + * @property {number} NONE - + * @property {number} SRC_IN - + * @property {number} SRC_OUT - + * @property {number} SRC_ATOP - + * @property {number} DST_OVER - + * @property {number} DST_IN - + * @property {number} DST_OUT - + * @property {number} DST_ATOP - + * @property {number} SUBTRACT - + * @property {number} SRC_OVER - + * @property {number} ERASE - + * @property {number} XOR - */ -export enum BLEND_MODES { +export enum BLEND_MODES +// eslint-disable-next-line @typescript-eslint/indent +{ NORMAL = 0, ADD = 1, MULTIPLY = 2, @@ -131,20 +135,21 @@ export enum BLEND_MODES { /** * Various webgl draw modes. These can be used to specify which GL drawMode to use * under certain situations and renderers. - * * @memberof PIXI * @static * @name DRAW_MODES * @enum {number} - * @property {number} POINTS - * @property {number} LINES - * @property {number} LINE_LOOP - * @property {number} LINE_STRIP - * @property {number} TRIANGLES - * @property {number} TRIANGLE_STRIP - * @property {number} TRIANGLE_FAN + * @property {number} POINTS - + * @property {number} LINES - + * @property {number} LINE_LOOP - + * @property {number} LINE_STRIP - + * @property {number} TRIANGLES - + * @property {number} TRIANGLE_STRIP - + * @property {number} TRIANGLE_FAN - */ -export enum DRAW_MODES { +export enum DRAW_MODES +// eslint-disable-next-line @typescript-eslint/indent +{ POINTS, LINES, LINE_LOOP, @@ -156,26 +161,27 @@ export enum DRAW_MODES { /** * Various GL texture/resources formats. - * * @memberof PIXI * @static * @name FORMATS * @enum {number} - * @property {number} RGBA=6408 - * @property {number} RGB=6407 - * @property {number} RG=33319 - * @property {number} RED=6403 - * @property {number} RGBA_INTEGER=36249 - * @property {number} RGB_INTEGER=36248 - * @property {number} RG_INTEGER=33320 - * @property {number} RED_INTEGER=36244 - * @property {number} ALPHA=6406 - * @property {number} LUMINANCE=6409 - * @property {number} LUMINANCE_ALPHA=6410 - * @property {number} DEPTH_COMPONENT=6402 - * @property {number} DEPTH_STENCIL=34041 + * @property {number} [RGBA=6408] - + * @property {number} [RGB=6407] - + * @property {number} [RG=33319] - + * @property {number} [RED=6403] - + * @property {number} [RGBA_INTEGER=36249] - + * @property {number} [RGB_INTEGER=36248] - + * @property {number} [RG_INTEGER=33320] - + * @property {number} [RED_INTEGER=36244] - + * @property {number} [ALPHA=6406] - + * @property {number} [LUMINANCE=6409] - + * @property {number} [LUMINANCE_ALPHA=6410] - + * @property {number} [DEPTH_COMPONENT=6402] - + * @property {number} [DEPTH_STENCIL=34041] - */ -export enum FORMATS { +export enum FORMATS +// eslint-disable-next-line @typescript-eslint/indent +{ RGBA = 6408, RGB = 6407, RG = 33319, @@ -193,22 +199,23 @@ export enum FORMATS { /** * Various GL target types. - * * @memberof PIXI * @static * @name TARGETS * @enum {number} - * @property {number} TEXTURE_2D=3553 - * @property {number} TEXTURE_CUBE_MAP=34067 - * @property {number} TEXTURE_2D_ARRAY=35866 - * @property {number} TEXTURE_CUBE_MAP_POSITIVE_X=34069 - * @property {number} TEXTURE_CUBE_MAP_NEGATIVE_X=34070 - * @property {number} TEXTURE_CUBE_MAP_POSITIVE_Y=34071 - * @property {number} TEXTURE_CUBE_MAP_NEGATIVE_Y=34072 - * @property {number} TEXTURE_CUBE_MAP_POSITIVE_Z=34073 - * @property {number} TEXTURE_CUBE_MAP_NEGATIVE_Z=34074 + * @property {number} [TEXTURE_2D=3553] - + * @property {number} [TEXTURE_CUBE_MAP=34067] - + * @property {number} [TEXTURE_2D_ARRAY=35866] - + * @property {number} [TEXTURE_CUBE_MAP_POSITIVE_X=34069] - + * @property {number} [TEXTURE_CUBE_MAP_NEGATIVE_X=34070] - + * @property {number} [TEXTURE_CUBE_MAP_POSITIVE_Y=34071] - + * @property {number} [TEXTURE_CUBE_MAP_NEGATIVE_Y=34072] - + * @property {number} [TEXTURE_CUBE_MAP_POSITIVE_Z=34073] - + * @property {number} [TEXTURE_CUBE_MAP_NEGATIVE_Z=34074] - */ -export enum TARGETS { +export enum TARGETS +// eslint-disable-next-line @typescript-eslint/indent +{ TEXTURE_2D = 3553, TEXTURE_CUBE_MAP = 34067, TEXTURE_2D_ARRAY = 35866, @@ -222,29 +229,30 @@ export enum TARGETS { /** * Various GL data format types. - * * @memberof PIXI * @static * @name TYPES * @enum {number} - * @property {number} UNSIGNED_BYTE=5121 - * @property {number} UNSIGNED_SHORT=5123 - * @property {number} UNSIGNED_SHORT_5_6_5=33635 - * @property {number} UNSIGNED_SHORT_4_4_4_4=32819 - * @property {number} UNSIGNED_SHORT_5_5_5_1=32820 - * @property {number} UNSIGNED_INT=5125 - * @property {number} UNSIGNED_INT_10F_11F_11F_REV=35899 - * @property {number} UNSIGNED_INT_2_10_10_10_REV=33640 - * @property {number} UNSIGNED_INT_24_8=34042 - * @property {number} UNSIGNED_INT_5_9_9_9_REV=35902 - * @property {number} BYTE=5120 - * @property {number} SHORT=5122 - * @property {number} INT=5124 - * @property {number} FLOAT=5126 - * @property {number} FLOAT_32_UNSIGNED_INT_24_8_REV=36269 - * @property {number} HALF_FLOAT=36193 + * @property {number} [UNSIGNED_BYTE=5121] - + * @property {number} [UNSIGNED_SHORT=5123] - + * @property {number} [UNSIGNED_SHORT_5_6_5=33635] - + * @property {number} [UNSIGNED_SHORT_4_4_4_4=32819] - + * @property {number} [UNSIGNED_SHORT_5_5_5_1=32820] - + * @property {number} [UNSIGNED_INT=5125] - + * @property {number} [UNSIGNED_INT_10F_11F_11F_REV=35899] - + * @property {number} [UNSIGNED_INT_2_10_10_10_REV=33640] - + * @property {number} [UNSIGNED_INT_24_8=34042] - + * @property {number} [UNSIGNED_INT_5_9_9_9_REV=35902] - + * @property {number} [BYTE=5120] - + * @property {number} [SHORT=5122] - + * @property {number} [INT=5124] - + * @property {number} [FLOAT=5126] - + * @property {number} [FLOAT_32_UNSIGNED_INT_24_8_REV=36269] - + * @property {number} [HALF_FLOAT=36193] - */ -export enum TYPES { +export enum TYPES +// eslint-disable-next-line @typescript-eslint/indent +{ UNSIGNED_BYTE = 5121, UNSIGNED_SHORT = 5123, UNSIGNED_SHORT_5_6_5 = 33635, @@ -266,16 +274,17 @@ export enum TYPES { /** * Various sampler types. Correspond to `sampler`, `isampler`, `usampler` GLSL types respectively. * WebGL1 works only with FLOAT. - * * @memberof PIXI * @static * @name SAMPLER_TYPES * @enum {number} - * @property {number} FLOAT=0 - * @property {number} INT=1 - * @property {number} UINT=2 + * @property {number} [FLOAT=0] - + * @property {number} [INT=1] - + * @property {number} [UINT=2] - */ -export enum SAMPLER_TYPES { +export enum SAMPLER_TYPES +// eslint-disable-next-line @typescript-eslint/indent +{ FLOAT = 0, INT = 1, UINT = 2, @@ -286,7 +295,6 @@ export enum SAMPLER_TYPES { * * The {@link PIXI.settings.SCALE_MODE} scale mode affects the default scaling mode of future operations. * It can be re-assigned to either LINEAR or NEAREST, depending upon suitability. - * * @memberof PIXI * @static * @name SCALE_MODES @@ -294,7 +302,9 @@ export enum SAMPLER_TYPES { * @property {number} LINEAR Smooth scaling * @property {number} NEAREST Pixelating scaling */ -export enum SCALE_MODES { +export enum SCALE_MODES +// eslint-disable-next-line @typescript-eslint/indent +{ NEAREST, LINEAR, } @@ -308,7 +318,6 @@ export enum SCALE_MODES { * only use REPEAT if the texture is po2. * * This property only affects WebGL. - * * @name WRAP_MODES * @memberof PIXI * @static @@ -317,7 +326,9 @@ export enum SCALE_MODES { * @property {number} REPEAT - The texture uvs tile and repeat * @property {number} MIRRORED_REPEAT - The texture uvs tile and repeat with mirroring */ -export enum WRAP_MODES { +export enum WRAP_MODES +// eslint-disable-next-line @typescript-eslint/indent +{ CLAMP = 33071, REPEAT = 10497, MIRRORED_REPEAT = 33648, @@ -332,7 +343,6 @@ export enum WRAP_MODES { * Due to platform restriction, `ON` option will work like `POW2` for webgl-1. * * This property only affects WebGL. - * * @name MIPMAP_MODES * @memberof PIXI * @static @@ -343,7 +353,9 @@ export enum WRAP_MODES { * @property {number} ON_MANUAL - Use mipmaps, but do not auto-generate them; this is used with a resource * that supports buffering each level-of-detail. */ -export enum MIPMAP_MODES { +export enum MIPMAP_MODES +// eslint-disable-next-line @typescript-eslint/indent +{ OFF, POW2, ON, @@ -352,7 +364,6 @@ export enum MIPMAP_MODES { /** * How to treat textures with premultiplied alpha - * * @name ALPHA_MODES * @memberof PIXI * @static @@ -367,7 +378,9 @@ export enum MIPMAP_MODES { * @property {number} UNPACK - Default option, alias for PREMULTIPLY_ON_UPLOAD. * @property {number} PMA - Alias for PREMULTIPLIED_ALPHA. */ -export enum ALPHA_MODES { +export enum ALPHA_MODES +// eslint-disable-next-line @typescript-eslint/indent +{ NPM = 0, UNPACK = 1, PMA = 2, @@ -382,7 +395,6 @@ export enum ALPHA_MODES { * * Filter textures need not be cleared if the filter does not use pixel blending. {@link CLEAR_MODES.BLIT} will detect * this and skip clearing as an optimization. - * * @name CLEAR_MODES * @memberof PIXI * @static @@ -394,7 +406,9 @@ export enum ALPHA_MODES { * @property {number} YES - Alias for CLEAR, same as `true` in earlier versions * @property {number} AUTO - Alias for BLIT */ -export enum CLEAR_MODES { +export enum CLEAR_MODES +// eslint-disable-next-line @typescript-eslint/indent +{ NO = 0, YES = 1, AUTO = 2, @@ -414,7 +428,6 @@ export enum CLEAR_MODES { * * Handy for mobile devices! * This property only affects WebGL. - * * @name GC_MODES * @enum {number} * @static @@ -422,24 +435,27 @@ export enum CLEAR_MODES { * @property {number} AUTO - Garbage collection will happen periodically automatically * @property {number} MANUAL - Garbage collection will need to be called manually */ -export enum GC_MODES { +export enum GC_MODES +// eslint-disable-next-line @typescript-eslint/indent +{ AUTO, MANUAL, } /** * Constants that specify float precision in shaders. - * * @name PRECISION * @memberof PIXI * @constant * @static * @enum {string} - * @property {string} LOW='lowp' - * @property {string} MEDIUM='mediump' - * @property {string} HIGH='highp' + * @property {string} [LOW='lowp'] - + * @property {string} [MEDIUM='mediump'] - + * @property {string} [HIGH='highp'] - */ -export enum PRECISION { +export enum PRECISION +// eslint-disable-next-line @typescript-eslint/indent +{ LOW = 'lowp', MEDIUM = 'mediump', HIGH = 'highp', @@ -448,7 +464,6 @@ export enum PRECISION { /** * Constants for mask implementations. * We use `type` suffix because it leads to very different behaviours - * * @name MASK_TYPES * @memberof PIXI * @static @@ -458,7 +473,9 @@ export enum PRECISION { * @property {number} STENCIL - Stencil mask, 1-bit, medium, works only if renderer supports stencil * @property {number} SPRITE - Mask that uses SpriteMaskFilter, uses temporary RenderTexture */ -export enum MASK_TYPES { +export enum MASK_TYPES +// eslint-disable-next-line @typescript-eslint/indent +{ NONE = 0, SCISSOR = 1, STENCIL = 2, @@ -467,9 +484,7 @@ export enum MASK_TYPES { /** * Constants for multi-sampling antialiasing. - * * @see PIXI.Framebuffer#multisample - * * @name MSAA_QUALITY * @memberof PIXI * @static @@ -479,7 +494,9 @@ export enum MASK_TYPES { * @property {number} MEDIUM - Try 4 samples * @property {number} HIGH - Try 8 samples */ -export enum MSAA_QUALITY { +export enum MSAA_QUALITY +// eslint-disable-next-line @typescript-eslint/indent +{ NONE = 0, LOW = 2, MEDIUM = 4, @@ -488,9 +505,7 @@ export enum MSAA_QUALITY { /** * Constants for various buffer types in Pixi - * * @see PIXI.BUFFER_TYPE - * * @name BUFFER_TYPE * @memberof PIXI * @static @@ -499,7 +514,9 @@ export enum MSAA_QUALITY { * @property {number} ARRAY_BUFFER - buffer type for using attribute data * @property {number} UNIFORM_BUFFER - the buffer type is for uniform buffer objects */ -export enum BUFFER_TYPE { +export enum BUFFER_TYPE +// eslint-disable-next-line @typescript-eslint/indent +{ ELEMENT_ARRAY_BUFFER = 34963, ARRAY_BUFFER = 34962, // NOT YET SUPPORTED diff --git a/packages/constants/test/constants.tests.ts b/packages/constants/test/constants.tests.ts index fed5fa6ca5..259e37f366 100644 --- a/packages/constants/test/constants.tests.ts +++ b/packages/constants/test/constants.tests.ts @@ -1,69 +1,69 @@ import * as lib from '@pixi/constants'; import { expect } from 'chai'; -describe('Constants', function () +describe('Constants', () => { - it('should have ENV', function () + it('should have ENV', () => { expect(lib.ENV).to.be.an('object'); }); - it('should have RENDERER_TYPE', function () + it('should have RENDERER_TYPE', () => { expect(lib.RENDERER_TYPE).to.be.an('object'); }); - it('should have BLEND_MODES', function () + it('should have BLEND_MODES', () => { expect(lib.RENDERER_TYPE).to.be.an('object'); }); - it('should have DRAW_MODES', function () + it('should have DRAW_MODES', () => { expect(lib.DRAW_MODES).to.be.an('object'); }); - it('should have FORMATS', function () + it('should have FORMATS', () => { expect(lib.FORMATS).to.be.an('object'); }); - it('should have TARGETS', function () + it('should have TARGETS', () => { expect(lib.TARGETS).to.be.an('object'); }); - it('should have TYPES', function () + it('should have TYPES', () => { expect(lib.TYPES).to.be.an('object'); }); - it('should have SCALE_MODES', function () + it('should have SCALE_MODES', () => { expect(lib.SCALE_MODES).to.be.an('object'); }); - it('should have WRAP_MODES', function () + it('should have WRAP_MODES', () => { expect(lib.WRAP_MODES).to.be.an('object'); }); - it('should have MIPMAP_MODES', function () + it('should have MIPMAP_MODES', () => { expect(lib.MIPMAP_MODES).to.be.an('object'); }); - it('should have ALPHA_MODES', function () + it('should have ALPHA_MODES', () => { expect(lib.ALPHA_MODES).to.be.an('object'); }); - it('should have GC_MODES', function () + it('should have GC_MODES', () => { expect(lib.GC_MODES).to.be.an('object'); }); - it('should have PRECISION', function () + it('should have PRECISION', () => { expect(lib.PRECISION).to.be.an('object'); }); diff --git a/packages/core/package.json b/packages/core/package.json index f987b5dc88..e2395231a2 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/core", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/core.js", "module": "dist/esm/core.js", "bundle": "dist/browser/core.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/core.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/core.js" + } + } + }, "description": "Core PixiJS", "author": "Mat Groves", "contributors": [ @@ -32,11 +45,11 @@ "@types/offscreencanvas": "^2019.6.4" }, "peerDependencies": { - "@pixi/constants": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/runner": "6.3.0", - "@pixi/settings": "6.3.0", - "@pixi/ticker": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/constants": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/runner": "6.4.2", + "@pixi/settings": "6.4.2", + "@pixi/ticker": "6.4.2", + "@pixi/utils": "6.4.2" } } diff --git a/packages/core/src/AbstractRenderer.ts b/packages/core/src/AbstractRenderer.ts index 7334f61c6c..5f30f2243e 100644 --- a/packages/core/src/AbstractRenderer.ts +++ b/packages/core/src/AbstractRenderer.ts @@ -38,14 +38,16 @@ export interface IRendererPlugins [key: string]: any; } -export interface IRendererRenderOptions { +export interface IRendererRenderOptions +{ renderTexture?: RenderTexture; clear?: boolean; transform?: Matrix; skipUpdateTransform?: boolean; } -export interface IGenerateTextureOptions { +export interface IGenerateTextureOptions +{ scaleMode?: SCALE_MODES; resolution?: number; region?: Rectangle; @@ -55,7 +57,6 @@ export interface IGenerateTextureOptions { /** * The AbstractRenderer is the base for a PixiJS Renderer. It is extended by the {@link PIXI.CanvasRenderer} * and {@link PIXI.Renderer} which can be used for rendering a PixiJS scene. - * * @abstract * @class * @extends PIXI.utils.EventEmitter @@ -80,7 +81,7 @@ export abstract class AbstractRenderer extends EventEmitter _lastObjectRendered: IRenderableObject; /** - * @param system - The name of the system this renderer is for. + * @param type - The renderer type. * @param [options] - The optional renderer parameters. * @param {number} [options.width=800] - The width of the screen. * @param {number} [options.height=600] - The height of the screen. @@ -109,15 +110,13 @@ export abstract class AbstractRenderer extends EventEmitter /** * The supplied constructor options. - * - * @member {Object} - * @readOnly + * @member {object} + * @readonly */ this.options = options; /** * The type of the renderer. - * * @member {number} * @default PIXI.RENDERER_TYPE.UNKNOWN * @see PIXI.RENDERER_TYPE @@ -128,21 +127,18 @@ export abstract class AbstractRenderer extends EventEmitter * Measurements of the screen. (0, 0, screenWidth, screenHeight). * * Its safe to use as filterArea or hitArea for the whole stage. - * * @member {PIXI.Rectangle} */ this.screen = new Rectangle(0, 0, options.width, options.height); /** * The canvas element that everything is drawn to. - * * @member {HTMLCanvasElement} */ this.view = options.view || document.createElement('canvas'); /** * The resolution / device pixel ratio of the renderer. - * * @member {number} * @default PIXI.settings.RESOLUTION */ @@ -151,14 +147,12 @@ export abstract class AbstractRenderer extends EventEmitter /** * Pass-thru setting for the canvas' context `alpha` property. This is typically * not something you need to fiddle with. If you want transparency, use `backgroundAlpha`. - * * @member {boolean} */ this.useContextAlpha = options.useContextAlpha; /** * Whether CSS dimensions of canvas view should be resized to screen dimensions automatically. - * * @member {boolean} */ this.autoDensity = !!options.autoDensity; @@ -166,7 +160,6 @@ export abstract class AbstractRenderer extends EventEmitter /** * The value of the preserveDrawingBuffer flag affects whether or not the contents of * the stencil buffer is retained after rendering. - * * @member {boolean} */ this.preserveDrawingBuffer = options.preserveDrawingBuffer; @@ -177,7 +170,6 @@ export abstract class AbstractRenderer extends EventEmitter * frame to set the canvas background color. If the scene is transparent PixiJS will use clearRect * to clear the canvas every frame. Disable this by setting this to false. For example, if * your game has a canvas filling background image you often don't need this set. - * * @member {boolean} * @default */ @@ -185,7 +177,6 @@ export abstract class AbstractRenderer extends EventEmitter /** * The background color as a number. - * * @member {number} * @protected */ @@ -193,7 +184,6 @@ export abstract class AbstractRenderer extends EventEmitter /** * The background color as an [R, G, B, A] array. - * * @member {number[]} * @protected */ @@ -201,7 +191,6 @@ export abstract class AbstractRenderer extends EventEmitter /** * The background color as a string. - * * @member {string} * @protected */ @@ -222,7 +211,6 @@ export abstract class AbstractRenderer extends EventEmitter /** * The last root object that the renderer tried to render. - * * @member {PIXI.DisplayObject} * @protected */ @@ -238,7 +226,6 @@ export abstract class AbstractRenderer extends EventEmitter /** * Initialize the plugins. - * * @protected * @param {object} staticMap - The dictionary of statically saved plugins. */ @@ -252,7 +239,6 @@ export abstract class AbstractRenderer extends EventEmitter /** * Same as view.width, actual number of pixels in the canvas by horizontal. - * * @member {number} * @readonly * @default 800 @@ -264,7 +250,6 @@ export abstract class AbstractRenderer extends EventEmitter /** * Same as view.height, actual number of pixels in the canvas by vertical. - * * @member {number} * @readonly * @default 600 @@ -278,7 +263,6 @@ export abstract class AbstractRenderer extends EventEmitter * Resizes the screen and canvas as close as possible to the specified width and height. * Canvas dimensions are multiplied by resolution and rounded to the nearest integers. * The new canvas dimensions divided by the resolution become the new screen dimensions. - * * @param desiredScreenWidth - The desired width of the screen. * @param desiredScreenHeight - The desired height of the screen. */ @@ -301,7 +285,6 @@ export abstract class AbstractRenderer extends EventEmitter /** * Fired after view has been resized. - * * @event PIXI.Renderer#resize * @param {number} screenWidth - The new width of the screen. * @param {number} screenHeight - The new height of the screen. @@ -320,13 +303,12 @@ export abstract class AbstractRenderer extends EventEmitter * @param {PIXI.Rectangle} options.region - The region of the displayObject, that shall be rendered, * if no region is specified, defaults to the local bounds of the displayObject. * @param {PIXI.MSAA_QUALITY} options.multisample - The number of samples of the frame buffer. - * @return A texture of the graphics object. + * @returns A texture of the graphics object. */ generateTexture(displayObject: IRenderableObject, options?: IGenerateTextureOptions): RenderTexture; /** * Please use the options argument instead. - * * @method PIXI.AbstractRenderer#generateTexture * @deprecated Since 6.1.0 * @param displayObject - The displayObject the object will be generated from. @@ -334,7 +316,7 @@ export abstract class AbstractRenderer extends EventEmitter * @param resolution - The resolution / device pixel ratio of the texture being generated. * @param region - The region of the displayObject, that shall be rendered, * if no region is specified, defaults to the local bounds of the displayObject. - * @return A texture of the graphics object. + * @returns A texture of the graphics object. */ generateTexture( displayObject: IRenderableObject, @@ -389,10 +371,9 @@ export abstract class AbstractRenderer extends EventEmitter /** * Adds a new system to the renderer. - * * @param ClassRef - Class reference * @param name - Property name for system - * @return Return instance of renderer + * @returns Return instance of renderer */ abstract addSystem(ClassRef: ISystemConstructor, name: string): this; @@ -400,7 +381,6 @@ export abstract class AbstractRenderer extends EventEmitter /** * Removes everything from the renderer and optionally removes the Canvas DOM element. - * * @param [removeView=false] - Removes the Canvas element from the DOM. */ destroy(removeView?: boolean): void @@ -433,7 +413,6 @@ export abstract class AbstractRenderer extends EventEmitter /** * The background color to fill if not transparent - * * @member {number} */ get backgroundColor(): number @@ -450,7 +429,6 @@ export abstract class AbstractRenderer extends EventEmitter /** * The background color alpha. Setting this to 0 will make the canvas transparent. - * * @member {number} */ get backgroundAlpha(): number diff --git a/packages/core/src/IRenderableObject.ts b/packages/core/src/IRenderableObject.ts index 1247c5e8c4..1516077ef6 100644 --- a/packages/core/src/IRenderableObject.ts +++ b/packages/core/src/IRenderableObject.ts @@ -6,7 +6,8 @@ import type { Renderer } from './Renderer'; * The minimum APIs needed to implement a renderable object. * @memberof PIXI */ -interface IRenderableObject { +interface IRenderableObject +{ /** Object must have a parent container */ parent: IRenderableContainer; /** Before method for transform updates */ @@ -23,7 +24,8 @@ interface IRenderableObject { * Interface for Container to interface with Renderer. * @memberof PIXI */ -interface IRenderableContainer extends IRenderableObject { +interface IRenderableContainer extends IRenderableObject +{ /** Get Local bounds for container */ getLocalBounds(rect?: Rectangle, skipChildrenUpdate?: boolean): Rectangle; } diff --git a/packages/core/src/IRenderingContext.ts b/packages/core/src/IRenderingContext.ts index de2b9f2924..da81f3584d 100644 --- a/packages/core/src/IRenderingContext.ts +++ b/packages/core/src/IRenderingContext.ts @@ -1,7 +1,4 @@ -/** - * Mixed WebGL1/WebGL2 Rendering Context. - * Either its WebGL2, either its WebGL1 with PixiJS polyfills on it - */ +/** Mixed WebGL1/WebGL2 Rendering Context. Either its WebGL2, either its WebGL1 with PixiJS polyfills on it */ // eslint-disable-next-line @typescript-eslint/no-empty-interface export interface IRenderingContext extends WebGL2RenderingContext { diff --git a/packages/core/src/ISystem.ts b/packages/core/src/ISystem.ts index 9c4a147c9d..2fafe5dcc1 100644 --- a/packages/core/src/ISystem.ts +++ b/packages/core/src/ISystem.ts @@ -7,15 +7,12 @@ import { deprecation } from '@pixi/utils'; */ export interface ISystem { - /** - * Generic destroy methods to be overridden by the subclass - */ + /** Generic destroy methods to be overridden by the subclass */ destroy(): void; } /** * Types for system and pipe classes. - * * @ignore */ export interface ISystemConstructor diff --git a/packages/core/src/Renderer.ts b/packages/core/src/Renderer.ts index 19ba626c73..66e505861f 100644 --- a/packages/core/src/Renderer.ts +++ b/packages/core/src/Renderer.ts @@ -28,11 +28,13 @@ import type { ISystemConstructor } from './ISystem'; import type { IRenderingContext } from './IRenderingContext'; import type { IRenderableObject } from './IRenderableObject'; -export interface IRendererPluginConstructor { +export interface IRendererPluginConstructor +{ new (renderer: Renderer, options?: any): IRendererPlugin; } -export interface IRendererPlugin { +export interface IRendererPlugin +{ destroy(): void; } @@ -66,14 +68,12 @@ export interface IRendererPlugin { * | {@link PIXI.TextureGCSystem} | This will automatically remove textures from the GPU if they are not used. | * * The breadth of the API surface provided by the renderer is contained within these systems. - * * @memberof PIXI */ export class Renderer extends AbstractRenderer { /** * WebGL context, set by {@link PIXI.ContextSystem this.context}. - * * @readonly * @member {WebGLRenderingContext} */ @@ -87,7 +87,6 @@ export class Renderer extends AbstractRenderer /** * Flag if we are rendering to the screen vs renderTexture - * * @readonly * @default true */ @@ -212,7 +211,7 @@ export class Renderer extends AbstractRenderer * Create renderer if WebGL is available. Overrideable * by the **@pixi/canvas-renderer** package to allow fallback. * throws error if WebGL is not available. - * + * @param options * @private */ static create(options?: IRendererOptions): AbstractRenderer @@ -250,7 +249,7 @@ export class Renderer extends AbstractRenderer * for devices with dual graphics card. * @param {object} [options.context] - If WebGL context already exists, all parameters must be taken from it. */ - constructor(options? : IRendererOptions) + constructor(options?: IRendererOptions) { super(RENDERER_TYPE.WEBGL, options); @@ -370,13 +369,12 @@ export class Renderer extends AbstractRenderer /** * Add a new system to the renderer. - * * @param ClassRef - Class reference * @param name - Property name for system, if not specified * will use a static `name` property on the class itself. This * name will be assigned as s property on the Renderer so make * sure it doesn't collide with properties on Renderer. - * @return Return instance of renderer + * @returns Return instance of renderer */ addSystem(ClassRef: ISystemConstructor, name: string): this { @@ -396,19 +394,16 @@ export class Renderer extends AbstractRenderer /** * Fired after rendering finishes. - * * @event PIXI.Renderer#postrender */ /** * Fired before rendering starts. - * * @event PIXI.Renderer#prerender */ /** * Fired when the WebGL context is set. - * * @event PIXI.Renderer#context * @param {WebGLRenderingContext} gl - WebGL context. */ @@ -418,7 +413,6 @@ export class Renderer extends AbstractRenderer /** * Renders the object to its WebGL view. - * * @param displayObject - The object to be rendered. * @param {object} [options] - Object to use for render options. * @param {PIXI.RenderTexture} [options.renderTexture] - The render texture to render to. @@ -430,7 +424,6 @@ export class Renderer extends AbstractRenderer /** * Please use the `option` render arguments instead. - * * @deprecated Since 6.0.0 * @param displayObject * @param renderTexture @@ -548,7 +541,6 @@ export class Renderer extends AbstractRenderer /** * Resizes the WebGL view to the specified width and height. - * * @param desiredScreenWidth - The desired width of the screen. * @param desiredScreenHeight - The desired height of the screen. */ @@ -561,8 +553,7 @@ export class Renderer extends AbstractRenderer /** * Resets the WebGL state so you can render things however you fancy! - * - * @return Returns itself. + * @returns Returns itself. */ reset(): this { @@ -580,7 +571,6 @@ export class Renderer extends AbstractRenderer /** * Removes everything from the renderer (event listeners, spritebatch, etc...) - * * @param [removeView=false] - Removes the Canvas element from the DOM. * See: https://github.com/pixijs/pixi.js/issues/2233 */ @@ -619,7 +609,6 @@ export class Renderer extends AbstractRenderer * Collection of installed plugins. These are included by default in PIXI, but can be excluded * by creating a custom build. Consult the README for more information about creating custom * builds and excluding plugins. - * * @readonly * @property {PIXI.AccessibilityManager} accessibility Support tabbing interactive elements. * @property {PIXI.Extract} extract Extract image data from renderer. @@ -633,7 +622,6 @@ export class Renderer extends AbstractRenderer /** * Adds a plugin to the renderer. - * * @param pluginName - The name of the plugin. * @param ctor - The constructor function or class for the plugin. */ diff --git a/packages/core/src/autoDetectRenderer.ts b/packages/core/src/autoDetectRenderer.ts index c89b685a9c..f8e32388e7 100644 --- a/packages/core/src/autoDetectRenderer.ts +++ b/packages/core/src/autoDetectRenderer.ts @@ -9,7 +9,6 @@ export interface IRendererOptionsAuto extends IRendererOptions * This helper function will automatically detect which renderer you should be using. * WebGL is the preferred renderer as it is a lot faster. If WebGL is not supported by * the browser then this function will return a canvas renderer - * * @memberof PIXI * @function autoDetectRenderer * @param {object} [options] - The optional renderer parameters @@ -35,7 +34,7 @@ export interface IRendererOptionsAuto extends IRendererOptions * it is ignored. * @param {string} [options.powerPreference] - Parameter passed to webgl context, set to "high-performance" * for devices with dual graphics card **webgl only** - * @return {PIXI.Renderer|PIXI.CanvasRenderer} Returns WebGL renderer if available, otherwise CanvasRenderer + * @returns {PIXI.Renderer|PIXI.CanvasRenderer} Returns WebGL renderer if available, otherwise CanvasRenderer */ export function autoDetectRenderer(options?: IRendererOptionsAuto): AbstractRenderer { diff --git a/packages/core/src/batch/AbstractBatchRenderer.ts b/packages/core/src/batch/AbstractBatchRenderer.ts index 4038158bae..dbb9cf3fc9 100644 --- a/packages/core/src/batch/AbstractBatchRenderer.ts +++ b/packages/core/src/batch/AbstractBatchRenderer.ts @@ -20,10 +20,10 @@ import type { BLEND_MODES } from '@pixi/constants'; /** * Interface for elements like Sprite, Mesh etc. for batching. - * * @memberof PIXI */ -export interface IBatchableElement { +export interface IBatchableElement +{ _texture: Texture; vertexData: Float32Array; indices: Uint16Array | Uint32Array | Array; @@ -40,7 +40,6 @@ export interface IBatchableElement { * with texture-based geometries and renders them in * batches. It uploads multiple textures to the GPU to * reduce to the number of draw calls. - * * @memberof PIXI */ export class AbstractBatchRenderer extends ObjectRenderer @@ -51,7 +50,6 @@ export class AbstractBatchRenderer extends ObjectRenderer /** * The number of bufferable objects before a flush * occurs automatically. - * * @default settings.SPRITE_BATCH_SIZE * 4 */ public size: number; @@ -60,7 +58,6 @@ export class AbstractBatchRenderer extends ObjectRenderer * Maximum number of textures that can be uploaded to * the GPU under the current context. It is initialized * properly in `this.contextChange`. - * * @see PIXI.AbstractBatchRenderer#contextChange * @readonly */ @@ -82,7 +79,6 @@ export class AbstractBatchRenderer extends ObjectRenderer /** * The class that represents the geometry of objects * that are going to be batched with this. - * * @member {object} * @default PIXI.BatchGeometry */ @@ -98,7 +94,6 @@ export class AbstractBatchRenderer extends ObjectRenderer * | aTextureCoords | 2 | * | aColor | 1 | * | aTextureId | 1 | - * * @readonly */ protected vertexSize: number; @@ -111,14 +106,12 @@ export class AbstractBatchRenderer extends ObjectRenderer /** * Buffer of objects that are yet to be rendered. - * * @member {PIXI.DisplayObject[]} */ protected _bufferedElements: Array; /** * Data for texture batch builder, helps to save a bit of CPU on a pass. - * * @member {PIXI.BaseTexture[]} */ protected _bufferedTextures: Array; @@ -154,7 +147,6 @@ export class AbstractBatchRenderer extends ObjectRenderer * * The first buffer has a size of 8; each subsequent * buffer has double capacity of its previous. - * * @member {PIXI.ViewableBuffer[]} * @see PIXI.AbstractBatchRenderer#getAttributeBuffer */ @@ -168,7 +160,6 @@ export class AbstractBatchRenderer extends ObjectRenderer * * The first buffer has a size of 12; each subsequent * buffer has double capacity of its previous. - * * @member {Uint16Array[]} * @see PIXI.AbstractBatchRenderer#getIndexBuffer */ @@ -188,7 +179,6 @@ export class AbstractBatchRenderer extends ObjectRenderer * These are never re-allocated again, unless a * context change occurs; however, the pool may * be expanded if required. - * * @member {PIXI.Geometry[]} * @see PIXI.AbstractBatchRenderer.contextChange */ @@ -204,7 +194,6 @@ export class AbstractBatchRenderer extends ObjectRenderer /** * This will hook onto the renderer's `contextChange` * and `prerender` signals. - * * @param {PIXI.Renderer} renderer - The renderer this works for. */ constructor(renderer: Renderer) @@ -305,11 +294,7 @@ export class AbstractBatchRenderer extends ObjectRenderer } } - /** - * Handles the `prerender` signal. - * - * It ensures that flushes start from the first geometry object again. - */ + /** Handles the `prerender` signal. It ensures that flushes start from the first geometry object again. */ onPrerender(): void { this._flushId = 0; @@ -317,7 +302,6 @@ export class AbstractBatchRenderer extends ObjectRenderer /** * Buffers the "batchable" object. It need not be rendered immediately. - * * @param {PIXI.DisplayObject} element - the element to render when * using this renderer */ @@ -398,7 +382,12 @@ export class AbstractBatchRenderer extends ObjectRenderer BaseTexture._globalBatch = TICK; } - /** Populating drawcalls for rendering */ + /** + * Populating drawcalls for rendering + * @param texArray + * @param start + * @param finish + */ buildDrawCalls(texArray: BatchTextureArray, start: number, finish: number): void { const { @@ -454,7 +443,10 @@ export class AbstractBatchRenderer extends ObjectRenderer this._iIndex = iIndex; } - /** Bind textures for current rendering */ + /** + * Bind textures for current rendering + * @param texArray + */ bindAndClearTexArray(texArray: BatchTextureArray): void { const textureSystem = this.renderer.texture; @@ -602,9 +594,8 @@ export class AbstractBatchRenderer extends ObjectRenderer /** * Fetches an attribute buffer from `this._aBuffers` that can hold atleast `size` floats. - * * @param size - minimum capacity required - * @return - buffer than can hold atleast `size` floats + * @returns - buffer than can hold atleast `size` floats */ getAttributeBuffer(size: number): ViewableBuffer { @@ -631,9 +622,8 @@ export class AbstractBatchRenderer extends ObjectRenderer /** * Fetches an index buffer from `this._iBuffers` that can * have at least `size` capacity. - * * @param size - minimum required capacity - * @return - buffer that can fit `size` indices. + * @returns - buffer that can fit `size` indices. */ getIndexBuffer(size: number): Uint16Array { @@ -664,7 +654,6 @@ export class AbstractBatchRenderer extends ObjectRenderer * It uses these properties: `vertexData` `uvs`, `textureId` and * `indicies`. It also uses the "tint" of the base-texture, if * present. - * * @param {PIXI.DisplayObject} element - element being rendered * @param attributeBuffer - attribute buffer. * @param indexBuffer - index buffer @@ -714,7 +703,6 @@ export class AbstractBatchRenderer extends ObjectRenderer * * These are never re-allocated again. * Shared between all batch renderers because it can be only one "flush" working at the moment. - * * @member {PIXI.BatchDrawCall[]} */ static _drawCallPool: Array = []; @@ -725,7 +713,6 @@ export class AbstractBatchRenderer extends ObjectRenderer * * These are never re-allocated again. * Shared between all batch renderers because it can be only one "flush" working at the moment. - * * @member {PIXI.BatchTextureArray[]} */ static _textureArrayPool: Array = []; diff --git a/packages/core/src/batch/BatchDrawCall.ts b/packages/core/src/batch/BatchDrawCall.ts index 6902086490..f3fade5b1a 100644 --- a/packages/core/src/batch/BatchDrawCall.ts +++ b/packages/core/src/batch/BatchDrawCall.ts @@ -6,7 +6,6 @@ import type { BatchTextureArray } from './BatchTextureArray'; /** * Used by the batcher to draw batches. * Each one of these contains all information required to draw a bound geometry. - * * @memberof PIXI */ export class BatchDrawCall diff --git a/packages/core/src/batch/BatchGeometry.ts b/packages/core/src/batch/BatchGeometry.ts index 9d48cba1c7..98419bd4b1 100644 --- a/packages/core/src/batch/BatchGeometry.ts +++ b/packages/core/src/batch/BatchGeometry.ts @@ -4,21 +4,18 @@ import { Buffer } from '../geometry/Buffer'; /** * Geometry used to batch standard PIXI content (e.g. Mesh, Sprite, Graphics objects). - * * @memberof PIXI */ export class BatchGeometry extends Geometry { /** * Buffer used for position, color, texture IDs - * * @protected */ _buffer: Buffer; /** * Index buffer data - * * @protected */ _indexBuffer: Buffer; diff --git a/packages/core/src/batch/BatchPluginFactory.ts b/packages/core/src/batch/BatchPluginFactory.ts index 2a2f645e6f..158c45c2bf 100644 --- a/packages/core/src/batch/BatchPluginFactory.ts +++ b/packages/core/src/batch/BatchPluginFactory.ts @@ -38,13 +38,12 @@ export class BatchPluginFactory * PIXI.Renderer.registerPlugin('invert', InvertBatchRenderer); * const sprite = new PIXI.Sprite(); * sprite.pluginName = 'invert'; - * * @param {object} [options] * @param {string} [options.vertex=PIXI.BatchPluginFactory.defaultVertexSrc] - Vertex shader source * @param {string} [options.fragment=PIXI.BatchPluginFactory.defaultFragmentTemplate] - Fragment shader template * @param {number} [options.vertexSize=6] - Vertex size * @param {object} [options.geometryClass=PIXI.BatchGeometry] - * @return {*} New batch renderer plugin + * @returns {*} New batch renderer plugin */ static create(options?: IBatchFactoryOptions): typeof AbstractBatchRenderer { @@ -70,7 +69,6 @@ export class BatchPluginFactory /** * The default vertex shader source - * * @readonly */ static get defaultVertexSrc(): string @@ -80,7 +78,6 @@ export class BatchPluginFactory /** * The default fragment shader source - * * @readonly */ static get defaultFragmentTemplate(): string diff --git a/packages/core/src/batch/BatchShaderGenerator.ts b/packages/core/src/batch/BatchShaderGenerator.ts index 3dcaeced17..43d477ec10 100644 --- a/packages/core/src/batch/BatchShaderGenerator.ts +++ b/packages/core/src/batch/BatchShaderGenerator.ts @@ -5,7 +5,6 @@ import { Matrix } from '@pixi/math'; /** * Helper that generates batching multi-texture shader. Use it with your new BatchRenderer - * * @memberof PIXI */ export class BatchShaderGenerator diff --git a/packages/core/src/batch/BatchSystem.ts b/packages/core/src/batch/BatchSystem.ts index cd76d0e064..cfc89f94c7 100644 --- a/packages/core/src/batch/BatchSystem.ts +++ b/packages/core/src/batch/BatchSystem.ts @@ -7,7 +7,6 @@ import type { BatchTextureArray } from './BatchTextureArray'; /** * System plugin to the renderer to manage batching. - * * @memberof PIXI */ export class BatchSystem implements ISystem @@ -31,7 +30,6 @@ export class BatchSystem implements ISystem /** * Changes the current renderer to the one given in parameter - * * @param objectRenderer - The object renderer to use. */ setObjectRenderer(objectRenderer: ObjectRenderer): void @@ -56,9 +54,7 @@ export class BatchSystem implements ISystem this.setObjectRenderer(this.emptyRenderer); } - /** - * Reset the system to an empty renderer - */ + /** Reset the system to an empty renderer */ reset(): void { this.setObjectRenderer(this.emptyRenderer); @@ -67,7 +63,6 @@ export class BatchSystem implements ISystem /** * Handy function for batch renderers: copies bound textures in first maxTextures locations to array * sets actual _batchLocation for them - * * @param arr - arr copy destination * @param maxTextures - number of copied elements */ @@ -89,7 +84,6 @@ export class BatchSystem implements ISystem * Assigns batch locations to textures in array based on boundTextures state. * All textures in texArray should have `_batchEnabled = _batchId`, * and their count should be less than `maxTextures`. - * * @param texArray - textures to bound * @param boundTextures - current state of bound textures * @param batchId - marker for _batchEnabled param of textures in texArray diff --git a/packages/core/src/batch/BatchTextureArray.ts b/packages/core/src/batch/BatchTextureArray.ts index adaf65a237..29d51dd40c 100644 --- a/packages/core/src/batch/BatchTextureArray.ts +++ b/packages/core/src/batch/BatchTextureArray.ts @@ -3,7 +3,6 @@ import type { BaseTexture } from '@pixi/core'; /** * Used by the batcher to build texture batches. * Holds list of textures and their respective locations. - * * @memberof PIXI */ export class BatchTextureArray diff --git a/packages/core/src/batch/ObjectRenderer.ts b/packages/core/src/batch/ObjectRenderer.ts index 02d9c78657..7712420eb2 100644 --- a/packages/core/src/batch/ObjectRenderer.ts +++ b/packages/core/src/batch/ObjectRenderer.ts @@ -4,7 +4,6 @@ import type { Renderer } from '../Renderer'; /** * Base for a common object renderer that can be used as a * system renderer plugin. - * * @memberof PIXI */ export class ObjectRenderer implements ISystem @@ -20,19 +19,13 @@ export class ObjectRenderer implements ISystem this.renderer = renderer; } - /** - * Stub method that should be used to empty the current - * batch by rendering objects now. - */ + /** Stub method that should be used to empty the current batch by rendering objects now. */ flush(): void { // flush! } - /** - * Generic destruction method that frees all resources. This - * should be called by subclasses. - */ + /** Generic destruction method that frees all resources. This should be called by subclasses. */ destroy(): void { this.renderer = null; @@ -49,10 +42,7 @@ export class ObjectRenderer implements ISystem // set the shader.. } - /** - * Stops the renderer. It should free up any state and - * become dormant. - */ + /** Stops the renderer. It should free up any state and become dormant. */ stop(): void { this.flush(); @@ -61,8 +51,7 @@ export class ObjectRenderer implements ISystem /** * Keeps the object to render. It doesn't have to be * rendered immediately. - * - * @param {PIXI.DisplayObject} object - The object to render. + * @param {PIXI.DisplayObject} _object - The object to render. */ render(_object: any): void // eslint-disable-line @typescript-eslint/explicit-module-boundary-types { diff --git a/packages/core/src/context/ContextSystem.ts b/packages/core/src/context/ContextSystem.ts index 365371a5b4..e157924a62 100644 --- a/packages/core/src/context/ContextSystem.ts +++ b/packages/core/src/context/ContextSystem.ts @@ -8,27 +8,25 @@ import type { WebGLExtensions } from './WebGLExtensions'; let CONTEXT_UID_COUNTER = 0; -export interface ISupportDict { +export interface ISupportDict +{ uint32Indices: boolean; } /** * System plugin to the renderer to manage the context. - * * @memberof PIXI */ export class ContextSystem implements ISystem { /** * Either 1 or 2 to reflect the WebGL version being used. - * * @readonly */ public webGLVersion: number; /** * Features supported by current context. - * * @type {object} * @readonly * @property {boolean} uint32Indices - Support for 32-bit indices buffer. @@ -40,7 +38,6 @@ export class ContextSystem implements ISystem /** * Extensions available. - * * @type {object} * @readonly * @property {WEBGL_draw_buffers} drawBuffers - WebGL v1 extension @@ -76,7 +73,6 @@ export class ContextSystem implements ISystem /** * `true` if the context is lost - * * @readonly */ get isLost(): boolean @@ -86,7 +82,6 @@ export class ContextSystem implements ISystem /** * Handles the context change event. - * * @param {WebGLRenderingContext} gl - New WebGL context. */ protected contextChange(gl: IRenderingContext): void @@ -104,7 +99,6 @@ export class ContextSystem implements ISystem /** * Initializes the context. - * * @protected * @param {WebGLRenderingContext} gl - WebGL context */ @@ -119,7 +113,6 @@ export class ContextSystem implements ISystem /** * Initialize from context options - * * @protected * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/getContext * @param {object} options - context attributes @@ -133,12 +126,11 @@ export class ContextSystem implements ISystem /** * Helper class to create a WebGL Context - * * @param canvas - the canvas element that we will get the context from * @param options - An options object that gets passed in to the canvas element containing the * context attributes * @see https://developer.mozilla.org/en/docs/Web/API/HTMLCanvasElement/getContext - * @return {WebGLRenderingContext} the WebGL context + * @returns {WebGLRenderingContext} the WebGL context */ createContext(canvas: HTMLCanvasElement, options: WebGLContextAttributes): IRenderingContext { @@ -222,7 +214,6 @@ export class ContextSystem implements ISystem /** * Handles a lost webgl context - * * @param {WebGLContextEvent} event - The context lost event. */ protected handleContextLost(event: WebGLContextEvent): void @@ -265,7 +256,6 @@ export class ContextSystem implements ISystem /** * Validate context. - * * @param {WebGLRenderingContext} gl - Render context. */ protected validateContext(gl: IRenderingContext): void @@ -280,7 +270,7 @@ export class ContextSystem implements ISystem } // this is going to be fairly simple for now.. but at least we have room to grow! - if (!attributes.stencil) + if (attributes && !attributes.stencil) { /* eslint-disable max-len, no-console */ console.warn('Provided WebGL context does not have a stencil buffer, masks may not render correctly'); diff --git a/packages/core/src/context/WebGLExtensions.ts b/packages/core/src/context/WebGLExtensions.ts index eeb8b82eb8..aae4036faa 100644 --- a/packages/core/src/context/WebGLExtensions.ts +++ b/packages/core/src/context/WebGLExtensions.ts @@ -30,7 +30,8 @@ export interface WEBGL_compressed_texture_atc COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: number; } -export interface WebGLExtensions { +export interface WebGLExtensions +{ drawBuffers?: WEBGL_draw_buffers; depthTexture?: OES_texture_float; loseContext?: WEBGL_lose_context; diff --git a/packages/core/src/filters/Filter.ts b/packages/core/src/filters/Filter.ts index a4fd6045f4..ca84f6978e 100644 --- a/packages/core/src/filters/Filter.ts +++ b/packages/core/src/filters/Filter.ts @@ -179,7 +179,6 @@ import type { Dict } from '@pixi/utils'; * * Since PixiJS only had a handful of built-in filters, additional filters can be downloaded * {@link https://github.com/pixijs/pixi-filters here} from the PixiJS Filters repository. - * * @memberof PIXI */ export class Filter extends Shader @@ -200,14 +199,12 @@ export class Filter extends Shader /** * If enabled, PixiJS will fit the filter area into boundaries for better performance. * Switch it off if it does not work for specific shader. - * * @default true */ public autoFit: boolean; /** * Legacy filters use position and uvs from attributes (set by filter system) - * * @readonly */ public legacy: boolean; @@ -239,12 +236,11 @@ export class Filter extends Shader /** * Applies the filter - * * @param {PIXI.FilterSystem} filterManager - The renderer to retrieve the filter from * @param {PIXI.RenderTexture} input - The input render target. * @param {PIXI.RenderTexture} output - The target to output to. * @param {PIXI.CLEAR_MODES} [clearMode] - Should the output be cleared before rendering to it. - * @param {object} [currentState] - It's current state of filter. + * @param {object} [_currentState] - It's current state of filter. * There are some useful properties in the currentState : * target, filters, sourceFrame, destinationFrame, renderTarget, resolution */ @@ -260,7 +256,6 @@ export class Filter extends Shader /** * Sets the blend mode of the filter. - * * @default PIXI.BLEND_MODES.NORMAL */ get blendMode(): BLEND_MODES @@ -289,7 +284,6 @@ export class Filter extends Shader /** * The default vertex shader source - * * @constant */ static get defaultVertexSrc(): string @@ -299,7 +293,6 @@ export class Filter extends Shader /** * The default fragment shader source - * * @constant */ static get defaultFragmentSrc(): string diff --git a/packages/core/src/filters/FilterState.ts b/packages/core/src/filters/FilterState.ts index ef601e0e84..278a2de6b9 100644 --- a/packages/core/src/filters/FilterState.ts +++ b/packages/core/src/filters/FilterState.ts @@ -7,7 +7,6 @@ import type { RenderTexture } from '../renderTexture/RenderTexture'; /** * System plugin to the renderer to manage filter states. - * * @ignore */ export class FilterState diff --git a/packages/core/src/filters/FilterSystem.ts b/packages/core/src/filters/FilterSystem.ts index b46564b5a8..6319486a05 100644 --- a/packages/core/src/filters/FilterSystem.ts +++ b/packages/core/src/filters/FilterSystem.ts @@ -33,20 +33,19 @@ const tempMatrix = new Matrix(); * * {@link PIXI.Container#renderAdvanced} is an example of how to use the filter system. It is a 3 step process: * - * * **push**: Use {@link PIXI.FilterSystem#push} to push the set of filters to be applied on a filter-target. - * * **render**: Render the contents to be filtered using the renderer. The filter-system will only capture the contents + * **push**: Use {@link PIXI.FilterSystem#push} to push the set of filters to be applied on a filter-target. + * **render**: Render the contents to be filtered using the renderer. The filter-system will only capture the contents * inside the bounds of the filter-target. NOTE: Using {@link PIXI.Renderer#render} is * illegal during an existing render cycle, and it may reset the filter system. - * * **pop**: Use {@link PIXI.FilterSystem#pop} to pop & execute the filters you initially pushed. It will apply them + * **pop**: Use {@link PIXI.FilterSystem#pop} to pop & execute the filters you initially pushed. It will apply them * serially and output to the bounds of the filter-target. - * * @memberof PIXI */ export class FilterSystem implements ISystem { /** * List of filters for the FilterSystem - * @member {Object[]} + * @member {object[]} */ public readonly defaultFilterStack: Array; @@ -80,14 +79,13 @@ export class FilterSystem implements ISystem /** * This uniform group is attached to filter uniforms when used. - * - * @property {PIXI.Rectangle} outputFrame - * @property {Float32Array} inputSize - * @property {Float32Array} inputPixel - * @property {Float32Array} inputClamp - * @property {Number} resolution - * @property {Float32Array} filterArea - * @property {Float32Array} filterClamp + * @property {PIXI.Rectangle} outputFrame - + * @property {Float32Array} inputSize - + * @property {Float32Array} inputPixel - + * @property {Float32Array} inputClamp - + * @property {number} resolution - + * @property {Float32Array} filterArea - + * @property {Float32Array} filterClamp - */ protected globalUniforms: UniformGroup; @@ -132,7 +130,6 @@ export class FilterSystem implements ISystem /** * Pushes a set of filters to be applied later to the system. This will redirect further rendering into an * input render-texture for the rest of the filtering pipeline. - * * @param {PIXI.DisplayObject} target - The target of the filter to render. * @param filters - The filters to apply. */ @@ -188,20 +185,31 @@ export class FilterSystem implements ISystem state.sourceFrame.pad(padding); + const sourceFrameProjected = this.tempRect.copyFrom(renderTextureSystem.sourceFrame); + + // Project source frame into world space (if projection is applied) + if (renderer.projection.transform) + { + this.transformAABB( + tempMatrix.copyFrom(renderer.projection.transform).invert(), + sourceFrameProjected + ); + } + if (autoFit) { - const sourceFrameProjected = this.tempRect.copyFrom(renderTextureSystem.sourceFrame); + state.sourceFrame.fit(sourceFrameProjected); - // Project source frame into world space (if projection is applied) - if (renderer.projection.transform) + if (state.sourceFrame.width <= 0 || state.sourceFrame.height <= 0) { - this.transformAABB( - tempMatrix.copyFrom(renderer.projection.transform).invert(), - sourceFrameProjected - ); + state.sourceFrame.width = 0; + state.sourceFrame.height = 0; } - - state.sourceFrame.fit(sourceFrameProjected); + } + else if (!state.sourceFrame.intersects(sourceFrameProjected)) + { + state.sourceFrame.width = 0; + state.sourceFrame.height = 0; } // Round sourceFrame in screen space based on render-texture. @@ -348,7 +356,6 @@ export class FilterSystem implements ISystem /** * Binds a renderTexture with corresponding `filterFrame`, clears it if mode corresponds. - * * @param filterTexture - renderTexture to bind, should belong to filter pool or filter stack * @param clearMode - clearMode, by default its CLEAR/YES. See {@link PIXI.CLEAR_MODES} */ @@ -413,7 +420,6 @@ export class FilterSystem implements ISystem * Draws a filter using the default rendering process. * * This should be called only by {@link Filter#apply}. - * * @param filter - The filter to draw. * @param input - The input render target. * @param output - The target to output to. @@ -457,10 +463,9 @@ export class FilterSystem implements ISystem * Multiply _input normalized coordinates_ to this matrix to get _sprite texture normalized coordinates_. * * Use `outputMatrix * vTextureCoord` in the shader. - * * @param outputMatrix - The matrix to output to. * @param {PIXI.Sprite} sprite - The sprite to map to. - * @return The mapped matrix. + * @returns The mapped matrix. */ calculateSpriteMatrix(outputMatrix: Matrix, sprite: ISpriteMaskTarget): Matrix { @@ -489,12 +494,11 @@ export class FilterSystem implements ISystem /** * Gets a Power-of-Two render texture or fullScreen texture - * * @param minWidth - The minimum width of the render texture in real pixels. * @param minHeight - The minimum height of the render texture in real pixels. * @param resolution - The resolution of the render texture. * @param multisample - Number of samples of the render texture. - * @return - The new render texture. + * @returns - The new render texture. */ protected getOptimalFilterTexture(minWidth: number, minHeight: number, resolution = 1, multisample: MSAA_QUALITY = MSAA_QUALITY.NONE): RenderTexture @@ -505,7 +509,6 @@ export class FilterSystem implements ISystem /** * Gets extra render texture to use inside current filter * To be compliant with older filters, you can use params in any order - * * @param input - renderTexture from which size and resolution will be copied * @param resolution - override resolution of the renderTexture * @param multisample - number of samples of the renderTexture @@ -532,7 +535,6 @@ export class FilterSystem implements ISystem /** * Frees a render texture back into the pool. - * * @param renderTexture - The renderTarget to free */ returnFilterTexture(renderTexture: RenderTexture): void diff --git a/packages/core/src/filters/spriteMask/SpriteMaskFilter.ts b/packages/core/src/filters/spriteMask/SpriteMaskFilter.ts index f6496fb026..78e815bb2f 100644 --- a/packages/core/src/filters/spriteMask/SpriteMaskFilter.ts +++ b/packages/core/src/filters/spriteMask/SpriteMaskFilter.ts @@ -27,7 +27,6 @@ export interface ISpriteMaskFilter extends Filter * This handles a Sprite acting as a mask, as opposed to a Graphic. * * WebGL only. - * * @memberof PIXI */ export class SpriteMaskFilter extends Filter @@ -71,7 +70,6 @@ export class SpriteMaskFilter extends Filter /** * Sprite mask - * * @type {PIXI.DisplayObject} */ get maskSprite(): IMaskTarget @@ -91,7 +89,6 @@ export class SpriteMaskFilter extends Filter /** * Applies the filter - * * @param filterManager - The renderer to retrieve the filter from * @param input - The input render target. * @param output - The target to output to. diff --git a/packages/core/src/framebuffer/Framebuffer.ts b/packages/core/src/framebuffer/Framebuffer.ts index 7e5f7206c3..29c5f7f761 100644 --- a/packages/core/src/framebuffer/Framebuffer.ts +++ b/packages/core/src/framebuffer/Framebuffer.ts @@ -10,7 +10,6 @@ import type { GLFramebuffer } from './GLFramebuffer'; * one internally to render into itself. You can attach a depth or stencil buffer to a framebuffer. * * On WebGL 2 machines, shaders can output to multiple textures simultaneously with GLSL 300 ES. - * * @memberof PIXI */ export class Framebuffer @@ -34,7 +33,6 @@ export class Framebuffer * renderer.render(myContainer, {renderTexture}); * renderer.framebuffer.blit(); // copies data from MSAA framebuffer to texture * ``` - * * @default PIXI.MSAA_QUALITY.NONE */ public multisample: MSAA_QUALITY; @@ -76,7 +74,6 @@ export class Framebuffer /** * Reference to the colorTexture. - * * @readonly */ get colorTexture(): BaseTexture @@ -86,7 +83,6 @@ export class Framebuffer /** * Add texture to the colorTexture array. - * * @param index - Index of the array to add the texture to * @param texture - Texture to add to the array */ @@ -109,7 +105,6 @@ export class Framebuffer /** * Add a depth texture to the frame buffer. - * * @param texture - Texture to add. */ addDepthTexture(texture?: BaseTexture): this @@ -155,7 +150,6 @@ export class Framebuffer /** * Resize the frame buffer - * * @param width - Width of the frame buffer to resize to * @param height - Height of the frame buffer to resize to */ diff --git a/packages/core/src/framebuffer/FramebufferSystem.ts b/packages/core/src/framebuffer/FramebufferSystem.ts index f550c2461f..236455ba3b 100644 --- a/packages/core/src/framebuffer/FramebufferSystem.ts +++ b/packages/core/src/framebuffer/FramebufferSystem.ts @@ -12,7 +12,6 @@ const tempRectangle = new Rectangle(); /** * System plugin to the renderer to manage framebuffers. - * * @memberof PIXI */ export class FramebufferSystem implements ISystem @@ -98,7 +97,6 @@ export class FramebufferSystem implements ISystem /** * Bind a framebuffer. - * * @param framebuffer * @param frame - frame, default is framebuffer size * @param mipLevel - optional mip level to set on the framebuffer - defaults to 0 @@ -200,7 +198,6 @@ export class FramebufferSystem implements ISystem /** * Set the WebGLRenderingContext's viewport. - * * @param x - X position of viewport * @param y - Y position of viewport * @param width - Width of viewport @@ -228,7 +225,6 @@ export class FramebufferSystem implements ISystem /** * Get the size of the current width and height. Returns object with `width` and `height` values. - * * @readonly */ get size(): { x: number; y: number; width: number; height: number } @@ -244,7 +240,6 @@ export class FramebufferSystem implements ISystem /** * Clear the color of the context - * * @param r - Red value from 0 to 1 * @param g - Green value from 0 to 1 * @param b - Blue value from 0 to 1 @@ -263,7 +258,6 @@ export class FramebufferSystem implements ISystem /** * Initialize framebuffer for this context - * * @protected * @param framebuffer * @returns - created GLFramebuffer @@ -284,7 +278,7 @@ export class FramebufferSystem implements ISystem /** * Resize the framebuffer - * + * @param framebuffer * @protected */ resizeFramebuffer(framebuffer: Framebuffer): void @@ -340,7 +334,8 @@ export class FramebufferSystem implements ISystem /** * Update the framebuffer - * + * @param framebuffer + * @param mipLevel * @protected */ updateFramebuffer(framebuffer: Framebuffer, mipLevel: number): void @@ -450,7 +445,10 @@ export class FramebufferSystem implements ISystem } } - /** Returns true if the frame buffer can be multisampled. */ + /** + * Returns true if the frame buffer can be multisampled. + * @param framebuffer + */ protected canMultisampleFramebuffer(framebuffer: Framebuffer): boolean { return this.renderer.context.webGLVersion !== 1 @@ -459,7 +457,6 @@ export class FramebufferSystem implements ISystem /** * Detects number of samples that is not more than a param but as close to it as possible - * * @param samples - number of samples * @returns - recommended number of samples */ @@ -496,7 +493,6 @@ export class FramebufferSystem implements ISystem * after that target framebuffer is bound * * Fails with WebGL warning if blits multisample framebuffer to different size - * * @param framebuffer - by default it blits "into itself", from renderBuffer to texture. * @param sourcePixels - source rectangle in pixels * @param destPixels - dest rectangle in pixels, assumed to be the same as sourcePixels @@ -582,7 +578,6 @@ export class FramebufferSystem implements ISystem /** * Disposes framebuffer. - * * @param framebuffer - framebuffer that has to be disposed of * @param contextLost - If context was lost, we suppress all delete function calls */ @@ -630,7 +625,6 @@ export class FramebufferSystem implements ISystem /** * Disposes all framebuffers, but not textures bound to them. - * * @param [contextLost=false] - If context was lost, we suppress all delete function calls */ disposeAll(contextLost?: boolean): void @@ -650,7 +644,6 @@ export class FramebufferSystem implements ISystem * Used by MaskSystem, when its time to use stencil mask for Graphics element. * * Its an alternative for public lazy `framebuffer.enableStencil`, in case we need stencil without rebind. - * * @private */ forceStencil(): void @@ -691,11 +684,7 @@ export class FramebufferSystem implements ISystem gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, stencil); } - /** - * Resets framebuffer stored state, binds screen framebuffer. - * - * Should be called before renderTexture reset(). - */ + /** Resets framebuffer stored state, binds screen framebuffer. Should be called before renderTexture reset(). */ reset(): void { this.current = this.unknownFramebuffer; diff --git a/packages/core/src/framebuffer/GLFramebuffer.ts b/packages/core/src/framebuffer/GLFramebuffer.ts index 64d3dea085..bd3e282cec 100644 --- a/packages/core/src/framebuffer/GLFramebuffer.ts +++ b/packages/core/src/framebuffer/GLFramebuffer.ts @@ -4,7 +4,6 @@ import type { Framebuffer } from './Framebuffer'; /** * Internal framebuffer for WebGL context. - * * @memberof PIXI */ export class GLFramebuffer diff --git a/packages/core/src/geometry/Attribute.ts b/packages/core/src/geometry/Attribute.ts index 2541094117..310245ccc9 100644 --- a/packages/core/src/geometry/Attribute.ts +++ b/packages/core/src/geometry/Attribute.ts @@ -7,7 +7,6 @@ import { TYPES } from '@pixi/constants'; * * This does not contain the actual data, but instead has a buffer id that maps to a {@link PIXI.Buffer} * This can include anything from positions, uvs, normals, colors etc. - * * @memberof PIXI */ export class Attribute @@ -48,7 +47,6 @@ export class Attribute /** * Helper function that creates an Attribute based on the information provided - * * @param buffer - the id of the buffer that this attribute will look for * @param [size=0] - the size of the attribute. If you have 2 floats per vertex (eg position x and y) this would be 2 * @param [normalized=false] - should the data be normalized. diff --git a/packages/core/src/geometry/Buffer.ts b/packages/core/src/geometry/Buffer.ts index 890ca47794..564560feb8 100644 --- a/packages/core/src/geometry/Buffer.ts +++ b/packages/core/src/geometry/Buffer.ts @@ -1,6 +1,5 @@ import { BUFFER_TYPE } from '@pixi/constants'; import { Runner } from '@pixi/runner'; - import type { GLBuffer } from './GLBuffer'; let UID = 0; @@ -21,8 +20,7 @@ export interface IArrayBuffer extends ArrayBuffer * to support expressions like `geometry.buffers[0].data[0] = position.x`. * * Gives access to indexing and `length` field - * - * @popelyshev: If data is actually ArrayBuffer and throws Exception on indexing - its user problem :) + * * @popelyshev: If data is actually ArrayBuffer and throws Exception on indexing - its user problem :) */ export interface ITypedArray extends IArrayBuffer { @@ -33,15 +31,13 @@ export interface ITypedArray extends IArrayBuffer /** * A wrapper for data so that it can be used and uploaded by WebGL - * * @memberof PIXI */ export class Buffer { /** * The data in the buffer, as a typed array - * - * @type {ArrayBuffer| SharedArrayBuffer | ArrayBufferView} + * @type {PIXI.IArrayBuffer} */ public data: ITypedArray; @@ -55,19 +51,18 @@ export class Buffer public static: boolean; public id: number; - disposeRunner: Runner; + disposeRunner: Runner; /** * A map of renderer IDs to webgl buffer - * * @private - * @type {object} + * @type {Object} */ _glBuffers: {[key: number]: GLBuffer}; _updateID: number; /** - * @param {ArrayBuffer| SharedArrayBuffer|ArrayBufferView} data - the data to store in the buffer. + * @param {PIXI.IArrayBuffer} data - the data to store in the buffer. * @param _static - `true` for static buffer * @param index - `true` for index buffer */ @@ -88,7 +83,7 @@ export class Buffer // TODO could explore flagging only a partial upload? /** * Flags this buffer as requiring an upload to the GPU. - * @param {ArrayBuffer|SharedArrayBuffer|ArrayBufferView|number[]} [data] - the data to update in the buffer. + * @param {PIXI.IArrayBuffer|number[]} [data] - the data to update in the buffer. */ update(data?: IArrayBuffer | Array): void { @@ -134,9 +129,8 @@ export class Buffer /** * Helper function that creates a buffer based on an array or TypedArray - * * @param {ArrayBufferView | number[]} data - the TypedArray that the buffer will store. If this is a regular Array it will be converted to a Float32Array. - * @return - A new Buffer based on the data provided. + * @returns - A new Buffer based on the data provided. */ static from(data: IArrayBuffer | number[]): Buffer { diff --git a/packages/core/src/geometry/BufferSystem.ts b/packages/core/src/geometry/BufferSystem.ts index ab10ef1e0d..50feea8400 100644 --- a/packages/core/src/geometry/BufferSystem.ts +++ b/packages/core/src/geometry/BufferSystem.ts @@ -19,8 +19,6 @@ import type { ISystem } from '../ISystem'; * This system will handle the binding of buffers to the GPU as well as uploading * them. With this system, you never need to work directly with GPU buffers, but instead work with * the PIXI.Buffer class. - * - * * @class * @memberof PIXI */ @@ -55,9 +53,7 @@ export class BufferSystem implements ISystem this.renderer = null; } - /** - * Sets up the renderer context and necessary buffers. - */ + /** Sets up the renderer context and necessary buffers. */ protected contextChange(): void { this.disposeAll(true); @@ -70,7 +66,6 @@ export class BufferSystem implements ISystem /** * This binds specified buffer. On first run, it will create the webGL buffers for the context too - * * @param buffer - the buffer to bind to the renderer */ bind(buffer: Buffer): void @@ -86,7 +81,6 @@ export class BufferSystem implements ISystem * Binds an uniform buffer to at the given index. * * A cache is used so a buffer will not be bound again if already bound. - * * @param buffer - the buffer to bind * @param index - the base index to bind it to. */ @@ -107,7 +101,6 @@ export class BufferSystem implements ISystem /** * Binds a buffer whilst also binding its range. * This will make the buffer start from the offset supplied rather than 0 when it is read. - * * @param buffer - the buffer to bind * @param index - the base index to bind at, defaults to 0 * @param offset - the offset to bind at (this is blocks of 256). 0 = 0, 1 = 256, 2 = 512 etc @@ -125,7 +118,6 @@ export class BufferSystem implements ISystem /** * Will ensure the data in the buffer is uploaded to the GPU. - * * @param {PIXI.Buffer} buffer - the buffer to update */ update(buffer: Buffer): void @@ -205,6 +197,7 @@ export class BufferSystem implements ISystem /** * creates and attaches a GLBuffer object tied to the current context. + * @param buffer * @protected */ protected createGLBuffer(buffer: Buffer): GLBuffer diff --git a/packages/core/src/geometry/Geometry.ts b/packages/core/src/geometry/Geometry.ts index dbc3e1478c..1ea201fa1b 100644 --- a/packages/core/src/geometry/Geometry.ts +++ b/packages/core/src/geometry/Geometry.ts @@ -37,7 +37,6 @@ const map: Dict = { * geometry.addAttribute('uvs', [0,0,1,0,1,1,0,1],2) * geometry.addIndex([0,1,2,1,3,2]) * ``` - * * @memberof PIXI */ export class Geometry @@ -52,14 +51,12 @@ export class Geometry /** * Number of instances in this geometry, pass it to `GeometrySystem.draw()`. - * * @default 1 */ public instanceCount: number; /** * A map of renderer IDs to webgl VAOs - * * @type {object} */ glVertexArrayObjects: {[key: number]: {[key: string]: WebGLVertexArrayObject}}; @@ -95,7 +92,6 @@ export class Geometry * * Adds an attribute to the geometry * Note: `stride` and `start` should be `undefined` if you dont know them, not 0! - * * @param id - the name of the attribute (matching up to a shader) * @param {PIXI.Buffer|number[]} buffer - the buffer that holds the data of the attribute . You can also provide an Array and a buffer will be created from it. * @param size - the size of the attribute. If you have 2 floats per vertex (eg position x and y) this would be 2 @@ -104,9 +100,9 @@ export class Geometry * @param [stride=0] - How far apart, in bytes, the start of each value is. (used for interleaving data) * @param [start=0] - How far into the array to start reading values (used for interleaving data) * @param instance - Instancing flag - * @return - Returns self, useful for chaining. + * @returns - Returns self, useful for chaining. */ - addAttribute(id: string, buffer: Buffer|Float32Array|Uint32Array|Array, size = 0, normalized = false, + addAttribute(id: string, buffer: Buffer | Float32Array | Uint32Array | Array, size = 0, normalized = false, type?: TYPES, stride?: number, start?: number, instance = false): this { if (!buffer) @@ -156,9 +152,8 @@ export class Geometry /** * Returns the requested attribute. - * * @param id - The name of the attribute required - * @return - The attribute requested. + * @returns - The attribute requested. */ getAttribute(id: string): Attribute { @@ -167,9 +162,8 @@ export class Geometry /** * Returns the requested buffer. - * * @param id - The name of the buffer required. - * @return - The buffer requested. + * @returns - The buffer requested. */ getBuffer(id: string): Buffer { @@ -177,13 +171,12 @@ export class Geometry } /** - * - * Adds an index buffer to the geometry - * The index buffer contains integers, three for each triangle in the geometry, which reference the various attribute buffers (position, colour, UV coordinates, other UV coordinates, normal, …). There is only ONE index buffer. - * - * @param {PIXI.Buffer|number[]} [buffer] - The buffer that holds the data of the index buffer. You can also provide an Array and a buffer will be created from it. - * @return - Returns self, useful for chaining. - */ + * + * Adds an index buffer to the geometry + * The index buffer contains integers, three for each triangle in the geometry, which reference the various attribute buffers (position, colour, UV coordinates, other UV coordinates, normal, …). There is only ONE index buffer. + * @param {PIXI.Buffer|number[]} [buffer] - The buffer that holds the data of the index buffer. You can also provide an Array and a buffer will be created from it. + * @returns - Returns self, useful for chaining. + */ addIndex(buffer?: Buffer | IArrayBuffer | number[]): Geometry { if (!(buffer instanceof Buffer)) @@ -211,8 +204,7 @@ export class Geometry /** * Returns the index buffer - * - * @return - The index buffer. + * @returns - The index buffer. */ getIndex(): Buffer { @@ -222,8 +214,7 @@ export class Geometry /** * This function modifies the structure so that all current attributes become interleaved into a single buffer * This can be useful if your model remains static as it offers a little performance boost - * - * @return - Returns self, useful for chaining. + * @returns - Returns self, useful for chaining. */ interleave(): Geometry { @@ -301,7 +292,6 @@ export class Geometry /** * Returns a clone of the geometry. - * * @returns - A new clone of this geometry. */ clone(): Geometry @@ -341,9 +331,8 @@ export class Geometry * Merges an array of geometries into a new single one. * * Geometry attribute styles must match for this operation to work. - * * @param geometries - array of geometries to merge - * @return - Shiny new geometry! + * @returns - Shiny new geometry! */ static merge(geometries: Array): Geometry { diff --git a/packages/core/src/geometry/GeometrySystem.ts b/packages/core/src/geometry/GeometrySystem.ts index cbcc41a993..5409e8d633 100644 --- a/packages/core/src/geometry/GeometrySystem.ts +++ b/packages/core/src/geometry/GeometrySystem.ts @@ -15,28 +15,24 @@ const byteSizeMap: {[key: number]: number} = { 5126: 4, 5123: 2, 5121: 1 }; /** * System plugin to the renderer to manage geometry. - * * @memberof PIXI */ export class GeometrySystem implements ISystem { /** * `true` if we has `*_vertex_array_object` extension. - * * @readonly */ public hasVao: boolean; /** * `true` if has `ANGLE_instanced_arrays` extension. - * * @readonly */ public hasInstance: boolean; /** * `true` if support `gl.UNSIGNED_INT` in `gl.drawElements` or `gl.drawElementsInstanced`. - * * @readonly */ public canUseUInt32ElementIndex: boolean; @@ -138,7 +134,6 @@ export class GeometrySystem implements ISystem /** * Binds geometry so that is can be drawn. Creating a Vao if required - * * @param geometry - Instance of geometry to bind. * @param shader - Instance of shader to use vao for. */ @@ -210,7 +205,6 @@ export class GeometrySystem implements ISystem /** * Check compatibility between a geometry and a program - * * @param geometry - Geometry instance. * @param program - Program instance. */ @@ -231,10 +225,9 @@ export class GeometrySystem implements ISystem /** * Takes a geometry and program and generates a unique signature for them. - * * @param geometry - To get signature from. * @param program - To test geometry against. - * @return - Unique signature of the geometry and program + * @returns - Unique signature of the geometry and program */ protected getSignature(geometry: Geometry, program: Program): string { @@ -258,7 +251,6 @@ export class GeometrySystem implements ISystem * Creates or gets Vao with the same structure as the geometry and stores it on the geometry. * If vao is created, it is bound automatically. We use a shader to infer what and how to set up the * attribute locations. - * * @param geometry - Instance of geometry to to generate Vao for. * @param shader - Instance of the shader. * @param incRefCount - Increment refCount of all geometry buffers. @@ -375,7 +367,6 @@ export class GeometrySystem implements ISystem /** * Disposes geometry. - * * @param geometry - Geometry with buffers. Only VAO will be disposed * @param [contextLost=false] - If context was lost, we suppress deleteVertexArray */ @@ -444,7 +435,6 @@ export class GeometrySystem implements ISystem /** * Dispose all WebGL resources of all managed geometries. - * * @param [contextLost=false] - If context was lost, we suppress `gl.delete` calls */ disposeAll(contextLost?: boolean): void @@ -459,7 +449,6 @@ export class GeometrySystem implements ISystem /** * Activate vertex array object. - * * @param geometry - Geometry instance. * @param program - Shader program instance. */ @@ -526,7 +515,6 @@ export class GeometrySystem implements ISystem /** * Draws the currently bound geometry. - * * @param type - The type primitive to render. * @param size - The number of elements to be rendered. If not specified, all vertices after the * starting vertex will be drawn. diff --git a/packages/core/src/geometry/ViewableBuffer.ts b/packages/core/src/geometry/ViewableBuffer.ts index 7f212666db..8912f4fcb6 100644 --- a/packages/core/src/geometry/ViewableBuffer.ts +++ b/packages/core/src/geometry/ViewableBuffer.ts @@ -2,7 +2,6 @@ import type { ITypedArray } from './Buffer'; /** * Flexible wrapper around `ArrayBuffer` that also provides typed array views on demand. - * * @memberof PIXI */ export class ViewableBuffer @@ -110,10 +109,9 @@ export class ViewableBuffer /** * Returns the view of the given type. - * * @param type - One of `int8`, `uint8`, `int16`, * `uint16`, `int32`, `uint32`, and `float32`. - * @return - typed array of given type + * @returns - typed array of given type */ view(type: string): ITypedArray { diff --git a/packages/core/src/mask/AbstractMaskSystem.ts b/packages/core/src/mask/AbstractMaskSystem.ts index 0aedd39d01..e729507ea8 100644 --- a/packages/core/src/mask/AbstractMaskSystem.ts +++ b/packages/core/src/mask/AbstractMaskSystem.ts @@ -4,7 +4,6 @@ import type { Renderer } from '../Renderer'; /** * System plugin to the renderer to manage specific types of masking operations. - * * @memberof PIXI */ export class AbstractMaskSystem implements ISystem @@ -41,7 +40,6 @@ export class AbstractMaskSystem implements ISystem /** * Changes the mask stack that is used by this System. - * * @param {PIXI.MaskData[]} maskStack - The mask stack */ setMaskStack(maskStack: Array): void diff --git a/packages/core/src/mask/MaskData.ts b/packages/core/src/mask/MaskData.ts index 5d5c5c4388..ef5350c466 100644 --- a/packages/core/src/mask/MaskData.ts +++ b/packages/core/src/mask/MaskData.ts @@ -19,7 +19,6 @@ export interface IMaskTarget extends IFilterTarget * Component for masked elements. * * Holds mask mode and temporary data about current mask. - * * @memberof PIXI */ export class MaskData @@ -80,16 +79,10 @@ export class MaskData */ _scissorCounter: number; - /** - * Scissor operation above the mask in stack. - * Null if _scissorCounter is zero, rectangle instance if positive. - */ + /** Scissor operation above the mask in stack. Null if _scissorCounter is zero, rectangle instance if positive. */ _scissorRect: Rectangle; - /** - * pre-computed scissor rect - * does become _scissorRect when mask is actually pushed - */ + /** pre-computed scissor rect does become _scissorRect when mask is actually pushed */ _scissorRectLocal: Rectangle; /** @@ -101,7 +94,6 @@ export class MaskData /** * Create MaskData - * * @param {PIXI.DisplayObject} [maskObject=null] - object that describes the mask */ constructor(maskObject: IMaskTarget = null) @@ -167,7 +159,10 @@ export class MaskData this._scissorRectLocal = null; } - /** Copies counters from maskData above, called from pushMask(). */ + /** + * Copies counters from maskData above, called from pushMask(). + * @param maskAbove + */ copyCountersOrReset(maskAbove?: MaskData): void { if (maskAbove) diff --git a/packages/core/src/mask/MaskSystem.ts b/packages/core/src/mask/MaskSystem.ts index dc175200c2..7eb262c68b 100644 --- a/packages/core/src/mask/MaskSystem.ts +++ b/packages/core/src/mask/MaskSystem.ts @@ -10,12 +10,12 @@ import type { Renderer } from '../Renderer'; * System plugin to the renderer to manage masks. * * There are three built-in types of masking: - * * **Scissor Masking**: Scissor masking discards pixels that are outside of a rectangle called the scissor box. It is + * **Scissor Masking**: Scissor masking discards pixels that are outside of a rectangle called the scissor box. It is * the most performant as the scissor test is inexpensive. However, it can only be used when the mask is rectangular. - * * **Stencil Masking**: Stencil masking discards pixels that don't overlap with the pixels rendered into the stencil + * **Stencil Masking**: Stencil masking discards pixels that don't overlap with the pixels rendered into the stencil * buffer. It is the next fastest option as it does not require rendering into a separate framebuffer. However, it does * cause the mask to be rendered **twice** for each masking operation; hence, minimize the rendering cost of your masks. - * * **Sprite Mask Filtering**: Sprite mask filtering discards pixels based on the red channel of the sprite-mask's + * **Sprite Mask Filtering**: Sprite mask filtering discards pixels based on the red channel of the sprite-mask's * texture. (Generally, the masking texture is grayscale). Using advanced techniques, you might be able to embed this * type of masking in a custom shader - and hence, bypassing the masking system fully for performance wins. * @@ -27,14 +27,12 @@ import type { Renderer } from '../Renderer'; * In the scene graph, masks can be applied recursively, i.e. a mask can be applied during a masking operation. The mask * stack stores the currently applied masks in order. Each {@link PIXI.BaseRenderTexture} holds its own mask stack, i.e. * when you switch render-textures, the old masks only applied when you switch back to rendering to the old render-target. - * * @memberof PIXI */ export class MaskSystem implements ISystem { /** * Flag to enable scissor masking. - * * @default true */ public enableScissor: boolean; @@ -71,7 +69,6 @@ export class MaskSystem implements ISystem /** * Changes the mask stack that is used by this System. - * * @param maskStack - The mask stack */ setMaskStack(maskStack: Array): void @@ -85,11 +82,10 @@ export class MaskSystem implements ISystem * Enables the mask and appends it to the current mask stack. * * NOTE: The batch renderer should be flushed beforehand to prevent pending renders from being masked. - * * @param {PIXI.DisplayObject} target - Display Object to push the mask to - * @param {PIXI.MaskData|PIXI.Sprite|PIXI.Graphics|PIXI.DisplayObject} maskData - The masking data. + * @param {PIXI.MaskData|PIXI.Sprite|PIXI.Graphics|PIXI.DisplayObject} maskDataOrTarget - The masking data. */ - push(target: IMaskTarget, maskDataOrTarget: MaskData|IMaskTarget): void + push(target: IMaskTarget, maskDataOrTarget: MaskData | IMaskTarget): void { let maskData = maskDataOrTarget as MaskData; @@ -147,8 +143,7 @@ export class MaskSystem implements ISystem * Removes the last mask from the mask stack and doesn't return it. * * NOTE: The batch renderer should be flushed beforehand to render the masked contents before the mask is removed. - * - * @param {PIXI.DisplayObject} target - Display Object to pop the mask from + * @param {PIXI.IMaskTarget} target - Display Object to pop the mask from */ pop(target: IMaskTarget): void { @@ -197,7 +192,10 @@ export class MaskSystem implements ISystem } } - /** Sets type of MaskData based on its maskObject. */ + /** + * Sets type of MaskData based on its maskObject. + * @param maskData + */ detect(maskData: MaskData): void { const maskObject = maskData.maskObject; @@ -218,7 +216,6 @@ export class MaskSystem implements ISystem /** * Applies the Mask and adds it to the current filter stack. - * * @param maskData - Sprite to be used as the mask. */ pushSpriteMask(maskData: MaskData): void @@ -274,7 +271,6 @@ export class MaskSystem implements ISystem /** * Removes the last filter from the filter stack and doesn't return it. - * * @param maskData - Sprite to be used as the mask. */ popSpriteMask(maskData: MaskData): void diff --git a/packages/core/src/mask/ScissorSystem.ts b/packages/core/src/mask/ScissorSystem.ts index dbe3d45d50..0582c76870 100644 --- a/packages/core/src/mask/ScissorSystem.ts +++ b/packages/core/src/mask/ScissorSystem.ts @@ -12,7 +12,6 @@ const tempMatrix = new Matrix(); * Scissor masking discards pixels outside of a rectangle called the scissor box. The scissor box is in the framebuffer * viewport's space; however, the mask's rectangle is projected from world-space to viewport space automatically * by this system. - * * @memberof PIXI */ export class ScissorSystem extends AbstractMaskSystem @@ -57,7 +56,7 @@ export class ScissorSystem extends AbstractMaskSystem maskObject.renderable = true; - const rect = maskObject.getBounds(); + const rect = maskObject.getBounds(true); this.roundFrameToPixels(rect, renderTextureSystem.current ? renderTextureSystem.current.resolution : renderer.resolution, @@ -91,7 +90,7 @@ export class ScissorSystem extends AbstractMaskSystem /** * Test, whether the object can be scissor mask with current renderer projection. * Calls "calcScissorRect()" if its true. - * @param maskData mask data + * @param maskData - mask data * @returns whether Whether the object can be scissor mask */ public testScissor(maskData: MaskData): boolean @@ -153,7 +152,6 @@ export class ScissorSystem extends AbstractMaskSystem /** * Applies the Mask and adds it to the current stencil stack. - * * @author alvin * @param maskData - The mask data. */ diff --git a/packages/core/src/mask/StencilSystem.ts b/packages/core/src/mask/StencilSystem.ts index dcf8fddfee..e5537e804a 100644 --- a/packages/core/src/mask/StencilSystem.ts +++ b/packages/core/src/mask/StencilSystem.ts @@ -5,7 +5,6 @@ import type { IMaskTarget, MaskData } from './MaskData'; /** * System plugin to the renderer to manage stencils (used for masks). - * * @memberof PIXI */ export class StencilSystem extends AbstractMaskSystem @@ -34,7 +33,6 @@ export class StencilSystem extends AbstractMaskSystem /** * Applies the Mask and adds it to the current stencil stack. - * * @param maskData - The mask data */ push(maskData: MaskData): void @@ -69,7 +67,6 @@ export class StencilSystem extends AbstractMaskSystem /** * Pops stencil mask. MaskData is already removed from stack - * * @param {PIXI.DisplayObject} maskObject - object of popped mask data */ pop(maskObject: IMaskTarget): void diff --git a/packages/core/src/projection/ProjectionSystem.ts b/packages/core/src/projection/ProjectionSystem.ts index eea9e1cb83..fa7ead0c80 100644 --- a/packages/core/src/projection/ProjectionSystem.ts +++ b/packages/core/src/projection/ProjectionSystem.ts @@ -9,7 +9,6 @@ import type { Renderer } from '../Renderer'; * * The `projectionMatrix` is a global uniform provided to all shaders. It is used to transform points in world space to * normalized device coordinates. - * * @memberof PIXI */ export class ProjectionSystem implements ISystem @@ -28,7 +27,6 @@ export class ProjectionSystem implements ISystem * The destination frame's dimensions (width,height) should be equal to the source frame. This is because, * otherwise, the contents will be scaled to fill the destination frame. Similarly, the destination frame's (x,y) * coordinates are (0,0) unless you know what you're doing. - * * @readonly */ public destinationFrame: Rectangle; @@ -37,7 +35,6 @@ export class ProjectionSystem implements ISystem * The source frame used to calculate the current projection matrix. * * The source frame is the rectangle in world space containing the contents to be rendered. - * * @readonly */ public sourceFrame: Rectangle; @@ -47,7 +44,6 @@ export class ProjectionSystem implements ISystem * * This is not used internally. It is not advised to use this feature specifically unless you know what * you're doing. The `update` method will default to this frame if you do not pass the destination frame. - * * @readonly */ public defaultFrame: Rectangle; @@ -60,7 +56,6 @@ export class ProjectionSystem implements ISystem * * The renderer's `globalUniforms` keeps a reference to this, and so it is available for all shaders to use as a * uniform. - * * @readonly */ public projectionMatrix: Matrix; @@ -70,7 +65,6 @@ export class ProjectionSystem implements ISystem * * This can be used to transform points in world-space one last time before they are outputted by the shader. You can * use to rotate the whole scene, for example. Remember to clear it once you've rendered everything. - * * @member {PIXI.Matrix} */ public transform: Matrix; @@ -97,7 +91,6 @@ export class ProjectionSystem implements ISystem * * NOTE-2: {@link RenderTextureSystem#bind} updates the projection-matrix when you bind a render-texture. It is expected * that you dirty the current bindings when calling this manually. - * * @param destinationFrame - The rectangle in the render-target to render the contents into. If rendering to the canvas, * the origin is on the top-left; if rendering to a render-texture, the origin is on the bottom-left. * @param sourceFrame - The rectangle in world space that contains the contents being rendered. @@ -134,10 +127,9 @@ export class ProjectionSystem implements ISystem /** * Calculates the `projectionMatrix` to map points inside `sourceFrame` to inside `destinationFrame`. - * - * @param destinationFrame - The destination frame in the render-target. + * @param _destinationFrame - The destination frame in the render-target. * @param sourceFrame - The source frame in world space. - * @param resolution - The render-target's resolution, i.e. ratio of CSS to physical pixels. + * @param _resolution - The render-target's resolution, i.e. ratio of CSS to physical pixels. * @param root - Whether rendering into the screen. Otherwise, if rendering to a framebuffer, the projection * is y-flipped. */ @@ -157,8 +149,7 @@ export class ProjectionSystem implements ISystem /** * Sets the transform of the active render target to the given matrix. - * - * @param matrix - The transformation matrix + * @param _matrix - The transformation matrix */ setTransform(_matrix: Matrix): void { diff --git a/packages/core/src/renderTexture/BaseRenderTexture.ts b/packages/core/src/renderTexture/BaseRenderTexture.ts index bc221ce3fb..9d48b8e41b 100644 --- a/packages/core/src/renderTexture/BaseRenderTexture.ts +++ b/packages/core/src/renderTexture/BaseRenderTexture.ts @@ -42,7 +42,6 @@ export interface BaseRenderTexture extends GlobalMixins.BaseRenderTexture, BaseT * * renderer.render(sprite, {renderTexture}); // Renders to center of RenderTexture * ``` - * * @memberof PIXI */ export class BaseRenderTexture extends BaseTexture @@ -104,7 +103,6 @@ export class BaseRenderTexture extends BaseTexture /** * Resizes the BaseRenderTexture. - * * @param desiredWidth - The desired width to resize to. * @param desiredHeight - The desired height to resize to. */ @@ -118,7 +116,6 @@ export class BaseRenderTexture extends BaseTexture * Frees the texture and framebuffer from WebGL memory without destroying this texture object. * This means you can still use the texture later which will upload it to GPU * memory again. - * * @fires PIXI.BaseTexture#dispose */ dispose(): void diff --git a/packages/core/src/renderTexture/RenderTexture.ts b/packages/core/src/renderTexture/RenderTexture.ts index ce0c2d618e..26ae74bf1f 100644 --- a/packages/core/src/renderTexture/RenderTexture.ts +++ b/packages/core/src/renderTexture/RenderTexture.ts @@ -43,7 +43,6 @@ import { deprecation } from '@pixi/utils'; * * renderer.render(sprite, {renderTexture}); // Renders to center of RenderTexture * ``` - * * @memberof PIXI */ export class RenderTexture extends Texture @@ -54,17 +53,15 @@ export class RenderTexture extends Texture * Stores `sourceFrame` when this texture is inside current filter stack. * * You can read it inside filters. - * * @readonly */ - public filterFrame: Rectangle|null; + public filterFrame: Rectangle | null; /** * The key for pooled texture of FilterSystem. - * * @see PIXI.RenderTexturePool */ - public filterPoolKey: string|number|null; + public filterPoolKey: string | number | null; /** * @param baseRenderTexture - The base texture object that this texture uses. @@ -84,7 +81,6 @@ export class RenderTexture extends Texture /** * Shortcut to `this.baseTexture.framebuffer`, saves baseTexture cast. - * * @readonly */ get framebuffer(): Framebuffer @@ -94,7 +90,6 @@ export class RenderTexture extends Texture /** * Shortcut to `this.framebuffer.multisample`. - * * @default PIXI.MSAA_QUALITY.NONE */ get multisample(): MSAA_QUALITY @@ -109,7 +104,6 @@ export class RenderTexture extends Texture /** * Resizes the RenderTexture. - * * @param desiredWidth - The desired width to resize to. * @param desiredHeight - The desired height to resize to. * @param resizeBaseTexture - Should the baseTexture.width and height values be resized as well? @@ -136,7 +130,6 @@ export class RenderTexture extends Texture /** * Changes the resolution of baseTexture, but does not change framebuffer size. - * * @param resolution - The new resolution to apply to RenderTexture */ setResolution(resolution: number): void @@ -154,7 +147,6 @@ export class RenderTexture extends Texture /** * Use the object-based construction instead. - * * @deprecated since 6.0.0 * @param {number} [width] * @param {number} [height] @@ -165,7 +157,6 @@ export class RenderTexture extends Texture /** * A short hand way of creating a render texture. - * * @param options - Options * @param {number} [options.width=100] - The width of the render texture * @param {number} [options.height=100] - The height of the render texture @@ -174,7 +165,7 @@ export class RenderTexture extends Texture * @param {number} [options.resolution=PIXI.settings.RESOLUTION] - The resolution / device pixel ratio of the texture * being generated * @param {PIXI.MSAA_QUALITY} [options.multisample=PIXI.MSAA_QUALITY.NONE] - The number of samples of the frame buffer - * @return The new render texture + * @returns The new render texture */ static create(options?: IBaseTextureOptions): RenderTexture; static create(options?: IBaseTextureOptions | number, ...rest: any[]): RenderTexture diff --git a/packages/core/src/renderTexture/RenderTexturePool.ts b/packages/core/src/renderTexture/RenderTexturePool.ts index 08c45f24f7..e24a31771e 100644 --- a/packages/core/src/renderTexture/RenderTexturePool.ts +++ b/packages/core/src/renderTexture/RenderTexturePool.ts @@ -13,7 +13,6 @@ import type { ISize } from '@pixi/math'; * * If you use custom RenderTexturePool for your filters, you can use methods * `getFilterTexture` and `returnFilterTexture` same as in - * * @memberof PIXI */ export class RenderTexturePool @@ -24,11 +23,10 @@ export class RenderTexturePool * Allow renderTextures of the same size as screen, not just pow2 * * Automatically sets to true after `setScreenSize` - * * @default false */ public enableFullScreen: boolean; - texturePool: {[x in string|number]: RenderTexture[]}; + texturePool: {[x in string | number]: RenderTexture[]}; private _pixelsWidth: number; private _pixelsHeight: number; @@ -48,7 +46,6 @@ export class RenderTexturePool /** * Creates texture with params that were specified in pool constructor. - * * @param realWidth - Width of texture in pixels. * @param realHeight - Height of texture in pixels. * @param multisample - Number of samples of the framebuffer. @@ -67,12 +64,11 @@ export class RenderTexturePool /** * Gets a Power-of-Two render texture or fullScreen texture - * * @param minWidth - The minimum width of the render texture. * @param minHeight - The minimum height of the render texture. * @param resolution - The resolution of the render texture. * @param multisample - Number of samples of the render texture. - * @return The new render texture. + * @returns The new render texture. */ getOptimalTexture(minWidth: number, minHeight: number, resolution = 1, multisample = MSAA_QUALITY.NONE): RenderTexture { @@ -119,12 +115,10 @@ export class RenderTexturePool * Gets extra texture of the same size as input renderTexture * * `getFilterTexture(input, 0.5)` or `getFilterTexture(0.5, input)` - * * @param input - renderTexture from which size and resolution will be copied * @param resolution - override resolution of the renderTexture * It overrides, it does not multiply * @param multisample - number of samples of the renderTexture - * @returns */ getFilterTexture(input: RenderTexture, resolution?: number, multisample?: MSAA_QUALITY): RenderTexture { @@ -138,7 +132,6 @@ export class RenderTexturePool /** * Place a render texture back into the pool. - * * @param renderTexture - The renderTexture to free */ returnTexture(renderTexture: RenderTexture): void @@ -151,7 +144,6 @@ export class RenderTexturePool /** * Alias for returnTexture, to be compliant with FilterSystem interface. - * * @param renderTexture - The renderTexture to free */ returnFilterTexture(renderTexture: RenderTexture): void @@ -161,7 +153,6 @@ export class RenderTexturePool /** * Clears the pool. - * * @param destroyTextures - Destroy all stored textures. */ clear(destroyTextures?: boolean): void @@ -191,7 +182,6 @@ export class RenderTexturePool * sets new screen size, sets `enableFullScreen` to true * * Size is measured in pixels, `renderer.view` can be passed here, not `renderer.screen` - * * @param size - Initial size of screen. */ setScreenSize(size: ISize): void @@ -230,7 +220,6 @@ export class RenderTexturePool /** * Key that is used to store fullscreen renderTextures in a pool - * * @constant */ static SCREEN_KEY = -1; diff --git a/packages/core/src/renderTexture/RenderTextureSystem.ts b/packages/core/src/renderTexture/RenderTextureSystem.ts index 6c63f4d693..cc04f2387f 100644 --- a/packages/core/src/renderTexture/RenderTextureSystem.ts +++ b/packages/core/src/renderTexture/RenderTextureSystem.ts @@ -30,7 +30,6 @@ const tempRect2 = new Rectangle(); * | sourceFrame | The rectangle inside of which display-objects are being rendered | **World Space**: The origin on the top-left | * | destinationFrame | The rectangle in the render-target (canvas or texture) into which contents should be rendered | If rendering to the canvas, this is in screen space and the origin is on the top-left. If rendering to a render-texture, this is in its base-texture's space with the origin on the bottom-left. | * | viewportFrame | The framebuffer viewport corresponding to the destination-frame | **Window Coordinates**: The origin is always on the bottom-left. | - * * @memberof PIXI */ export class RenderTextureSystem implements ISystem @@ -42,14 +41,12 @@ export class RenderTextureSystem implements ISystem /** * List of masks for the {@link PIXI.StencilSystem}. - * * @readonly */ public defaultMaskStack: Array; /** * Render texture currently bound. {@code null} if rendering to the canvas. - * * @readonly */ public current: RenderTexture | null; @@ -94,7 +91,6 @@ export class RenderTextureSystem implements ISystem /** * Bind the current render texture. - * * @param renderTexture - RenderTexture to bind, by default its `null` - the screen. * @param sourceFrame - Part of world that is mapped to the renderTexture. * @param destinationFrame - Part of renderTexture, by default it has the same size as sourceFrame. @@ -188,7 +184,6 @@ export class RenderTextureSystem implements ISystem /** * Erases the render texture and fills the drawing area with a colour. - * * @param clearColor - The color as rgba, default to use the renderer backgroundColor * @param [mask=BUFFER_BITS.COLOR | BUFFER_BITS.DEPTH] - Bitwise OR of masks * that indicate the buffers to be cleared, by default COLOR and DEPTH buffers. diff --git a/packages/core/src/settings.ts b/packages/core/src/settings.ts index 844699a48b..e6f56d27a2 100644 --- a/packages/core/src/settings.ts +++ b/packages/core/src/settings.ts @@ -11,7 +11,6 @@ import { isMobile } from '@pixi/utils'; * * Due to {@link https://bugs.chromium.org/p/chromium/issues/detail?id=934823|bug in chromium} * we disable webgl2 by default for all non-apple mobile devices. - * * @static * @name PREFER_ENV * @memberof PIXI.settings @@ -29,7 +28,6 @@ settings.PREFER_ENV = isMobile.any ? ENV.WEBGL : ENV.WEBGL2; * Otherwise, these `from` calls throw an exception. Using this property * can be useful if you want to enforce preloading all assets with * {@link PIXI.Loader Loader}. - * * @static * @name STRICT_TEXTURE_CACHE * @memberof PIXI.settings diff --git a/packages/core/src/shader/GLProgram.ts b/packages/core/src/shader/GLProgram.ts index 4f2496e9d1..7d65e803ff 100644 --- a/packages/core/src/shader/GLProgram.ts +++ b/packages/core/src/shader/GLProgram.ts @@ -11,7 +11,6 @@ export class IGLUniformData /** * Helper class to create a WebGL Program - * * @memberof PIXI */ export class GLProgram @@ -46,7 +45,6 @@ export class GLProgram /** * Makes a new Pixi program. - * * @param program - webgl program * @param uniformData - uniforms */ diff --git a/packages/core/src/shader/Program.ts b/packages/core/src/shader/Program.ts index bd87c241da..4e36dd8c27 100644 --- a/packages/core/src/shader/Program.ts +++ b/packages/core/src/shader/Program.ts @@ -32,7 +32,6 @@ export interface IUniformData /** * Helper class to create a shader program. - * * @memberof PIXI */ export class Program @@ -99,7 +98,6 @@ export class Program /** * The default vertex shader source. - * * @constant */ static get defaultVertexSrc(): string @@ -109,7 +107,6 @@ export class Program /** * The default fragment shader source. - * * @constant */ static get defaultFragmentSrc(): string @@ -121,7 +118,6 @@ export class Program * A short hand function to create a program based of a vertex and fragment shader. * * This method will also check to see if there is a cached program. - * * @param vertexSrc - The source of the vertex shader. * @param fragmentSrc - The source of the fragment shader. * @param name - Name for shader diff --git a/packages/core/src/shader/Shader.ts b/packages/core/src/shader/Shader.ts index e693e52c04..67b500a3fd 100644 --- a/packages/core/src/shader/Shader.ts +++ b/packages/core/src/shader/Shader.ts @@ -5,7 +5,6 @@ import type { Dict } from '@pixi/utils'; /** * A helper class for shaders. - * * @memberof PIXI */ export class Shader @@ -80,7 +79,6 @@ export class Shader /** * Shader uniform values, shortcut for `uniformGroup.uniforms`. - * * @readonly */ get uniforms(): Dict @@ -90,7 +88,6 @@ export class Shader /** * A short hand function to create a shader based of a vertex and fragment shader. - * * @param vertexSrc - The source of the vertex shader. * @param fragmentSrc - The source of the fragment shader. * @param uniforms - Custom uniforms to use to augment the built-in ones. diff --git a/packages/core/src/shader/ShaderSystem.ts b/packages/core/src/shader/ShaderSystem.ts index 1b9bdc92be..94da759978 100644 --- a/packages/core/src/shader/ShaderSystem.ts +++ b/packages/core/src/shader/ShaderSystem.ts @@ -19,14 +19,12 @@ const defaultSyncData = { textureCount: 0, uboCount: 0 }; /** * System plugin to the renderer to manage shaders. - * * @memberof PIXI */ export class ShaderSystem implements ISystem { /** * The current WebGL rendering context. - * * @member {WebGLRenderingContext} */ protected gl: IRenderingContext; @@ -63,7 +61,6 @@ export class ShaderSystem implements ISystem /** * Overrideable function by `@pixi/unsafe-eval` to silence * throwing an error if platform doesn't support unsafe-evals. - * * @private */ systemCheck(): void @@ -83,7 +80,6 @@ export class ShaderSystem implements ISystem /** * Changes the current shader to the one given in parameter. - * * @param shader - the new shader * @param dontSync - false if the shader should automatically sync its uniforms. * @returns the glProgram that belongs to the shader. @@ -117,7 +113,6 @@ export class ShaderSystem implements ISystem /** * Uploads the uniforms values to the currently bound shader. - * * @param uniforms - the uniforms values that be applied to the current shader */ setUniforms(uniforms: Dict): void @@ -131,7 +126,6 @@ export class ShaderSystem implements ISystem /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ /** * Syncs uniforms on the group - * * @param group - the uniform group to sync * @param syncData - this is data that is passed to the sync function and any nested sync functions */ @@ -149,6 +143,9 @@ export class ShaderSystem implements ISystem /** * Overrideable by the @pixi/unsafe-eval package to use static syncUniforms instead. + * @param group + * @param glProgram + * @param syncData */ syncUniforms(group: UniformGroup, glProgram: GLProgram, syncData: any): void { @@ -173,7 +170,6 @@ export class ShaderSystem implements ISystem /** * Syncs uniform buffers - * * @param group - the uniform buffer group to sync * @param name - the name of the uniform buffer */ @@ -206,7 +202,6 @@ export class ShaderSystem implements ISystem * Will create a function that uploads a uniform buffer using the STD140 standard. * The upload function will then be cached for future calls * If a group is manually managed, then a simple upload function is generated - * * @param group - the uniform buffer group to sync * @param glProgram - the gl program to attach the uniform bindings to * @param name - the name of the uniform buffer (must exist on the shader) @@ -249,9 +244,10 @@ export class ShaderSystem implements ISystem /** * Takes a uniform group and data and generates a unique signature for them. - * * @param group - The uniform group to get signature of + * @param group.uniforms * @param uniformData - Uniform information generated by the shader + * @param preFix * @returns Unique signature of the uniform group */ private getSignature(group: {uniforms: Dict}, uniformData: Dict, preFix: string): string @@ -277,8 +273,7 @@ export class ShaderSystem implements ISystem * Returns the underlying GLShade rof the currently bound shader. * * This can be handy for when you to have a little more control over the setting of your uniforms. - * - * @return The glProgram for the currently bound Shader for this context + * @returns The glProgram for the currently bound Shader for this context */ getGlProgram(): GLProgram { @@ -292,9 +287,8 @@ export class ShaderSystem implements ISystem /** * Generates a glProgram version of the Shader provided. - * * @param shader - The shader that the glProgram will be based on. - * @return A shiny new glProgram! + * @returns A shiny new glProgram! */ generateProgram(shader: Shader): GLProgram { diff --git a/packages/core/src/shader/UniformGroup.ts b/packages/core/src/shader/UniformGroup.ts index 7b5aadac7d..3f212224ec 100644 --- a/packages/core/src/shader/UniformGroup.ts +++ b/packages/core/src/shader/UniformGroup.ts @@ -45,28 +45,24 @@ let UID = 0; * }) * * ``` - * * @memberof PIXI */ export class UniformGroup> { /** * Uniform values - * * @member {object} */ public readonly uniforms: LAYOUT; /** * Its a group and not a single uniforms. - * * @default true */ public readonly group: boolean; /** * unique id - * * @protected */ public id: number; @@ -74,7 +70,6 @@ export class UniformGroup> /** * Dirty version - * * @protected */ dirtyId: number; @@ -153,7 +148,6 @@ export class UniformGroup> /** * A short hand function for creating a static UBO UniformGroup. - * * @param uniforms - the ubo item * @param _static - should this be updated each time it is used? defaults to true here! */ diff --git a/packages/core/src/shader/utils/compileShader.ts b/packages/core/src/shader/utils/compileShader.ts index d4fdf18e10..7821e1ec26 100644 --- a/packages/core/src/shader/utils/compileShader.ts +++ b/packages/core/src/shader/utils/compileShader.ts @@ -1,9 +1,9 @@ /** * @private * @param {WebGLRenderingContext} gl - The current WebGL context {WebGLProgram} - * @param {Number} type - the type, can be either VERTEX_SHADER or FRAGMENT_SHADER + * @param {number} type - the type, can be either VERTEX_SHADER or FRAGMENT_SHADER * @param {string} src - The vertex shader source as an array of strings. - * @return {WebGLShader} the shader + * @returns {WebGLShader} the shader */ export function compileShader(gl: WebGLRenderingContextBase, type: number, src: string): WebGLShader { diff --git a/packages/core/src/shader/utils/defaultValue.ts b/packages/core/src/shader/utils/defaultValue.ts index 748e8c0afd..74824226e2 100644 --- a/packages/core/src/shader/utils/defaultValue.ts +++ b/packages/core/src/shader/utils/defaultValue.ts @@ -17,7 +17,10 @@ function booleanArray(size: number): Array * @param {number} size * @private */ -export function defaultValue(type: string, size: number): number|Float32Array|Int32Array|Uint32Array|boolean|boolean[] +export function defaultValue( + type: string, + size: number +): number | Float32Array | Int32Array | Uint32Array | boolean | boolean[] { switch (type) { diff --git a/packages/core/src/shader/utils/generateProgram.ts b/packages/core/src/shader/utils/generateProgram.ts index 5653e574bb..4d85b64ebf 100644 --- a/packages/core/src/shader/utils/generateProgram.ts +++ b/packages/core/src/shader/utils/generateProgram.ts @@ -10,7 +10,6 @@ import { logProgramError } from './logProgramError'; /** * generates a WebGL Program object from a high level Pixi Program. - * * @param gl - a rendering context on which to generate the program * @param program - the high level Pixi Program. */ diff --git a/packages/core/src/shader/utils/generateUniformBufferSync.ts b/packages/core/src/shader/utils/generateUniformBufferSync.ts index 43116e978e..60aea75302 100644 --- a/packages/core/src/shader/utils/generateUniformBufferSync.ts +++ b/packages/core/src/shader/utils/generateUniformBufferSync.ts @@ -92,7 +92,8 @@ const GLSL_TO_STD40_SIZE: Dict = { mat4: 16 * 4, }; -interface UBOElement { +interface UBOElement +{ data: IUniformData offset: number, dataLen: number, @@ -100,11 +101,9 @@ interface UBOElement { } /** - * @ignore - * * logic originally from here: https://github.com/sketchpunk/FunWithWebGL2/blob/master/lesson_022/Shaders.js * rewrote it, but this was a great starting point to get a solid understanding of whats going on :) - * + * @ignore * @param uniformData */ export function createUBOElements(uniformData: IUniformData[]): {uboElements: UBOElement[], size: number} diff --git a/packages/core/src/shader/utils/getAttributeData.ts b/packages/core/src/shader/utils/getAttributeData.ts index de046eb6cc..b9dbcb5ece 100644 --- a/packages/core/src/shader/utils/getAttributeData.ts +++ b/packages/core/src/shader/utils/getAttributeData.ts @@ -5,10 +5,8 @@ import { mapType } from './mapType'; /** * returns the attribute data from the program * @private - * * @param {WebGLProgram} [program] - the WebGL program * @param {WebGLRenderingContext} [gl] - the WebGL context - * * @returns {object} the attribute data for this program */ export function getAttributeData(program: WebGLProgram, gl: WebGLRenderingContextBase): {[key: string]: IAttributeData} diff --git a/packages/core/src/shader/utils/getTestContext.ts b/packages/core/src/shader/utils/getTestContext.ts index c39f6ae0ab..72cea796a9 100644 --- a/packages/core/src/shader/utils/getTestContext.ts +++ b/packages/core/src/shader/utils/getTestContext.ts @@ -6,7 +6,6 @@ let context: WebGLRenderingContext | WebGL2RenderingContext = unknownContext as /** * returns a little WebGL context to use for program inspection. - * * @static * @private * @returns {WebGLRenderingContext} a gl context to test with diff --git a/packages/core/src/shader/utils/getUniformData.ts b/packages/core/src/shader/utils/getUniformData.ts index 1d254c9000..89b0d9471e 100644 --- a/packages/core/src/shader/utils/getUniformData.ts +++ b/packages/core/src/shader/utils/getUniformData.ts @@ -5,10 +5,8 @@ import { mapType } from './mapType'; /** * returns the uniform data from the program * @private - * * @param program - the webgl program * @param gl - the WebGL context - * * @returns {object} the uniform data for this program */ export function getUniformData(program: WebGLProgram, gl: WebGLRenderingContextBase): {[key: string]: IUniformData} diff --git a/packages/core/src/shader/utils/logProgramError.ts b/packages/core/src/shader/utils/logProgramError.ts index 8ae819bfd4..5e649446bf 100644 --- a/packages/core/src/shader/utils/logProgramError.ts +++ b/packages/core/src/shader/utils/logProgramError.ts @@ -1,7 +1,6 @@ /** * will log a shader error highlighting the lines with the error * also will add numbers along the side. - * * @param gl - the WebGLContext * @param shader - the shader to log errors for */ @@ -54,7 +53,6 @@ function logPrettyShaderError(gl: WebGLRenderingContext, shader: WebGLShader): v /** * * logs out any program errors - * * @param gl - The current WebGL context * @param program - the WebGL program to display errors for * @param vertexShader - the fragment WebGL shader program diff --git a/packages/core/src/shader/utils/mapSize.ts b/packages/core/src/shader/utils/mapSize.ts index 9d32e96263..1b37e3d829 100644 --- a/packages/core/src/shader/utils/mapSize.ts +++ b/packages/core/src/shader/utils/mapSize.ts @@ -32,8 +32,7 @@ const GLSL_TO_SIZE: Dict = { * @private * @method mapSize * @memberof PIXI.glCore.shader - * @param {String} type - * @return {Number} + * @param {string} type */ export function mapSize(type: string): number { diff --git a/packages/core/src/shader/utils/setPrecision.ts b/packages/core/src/shader/utils/setPrecision.ts index 292169a31f..78aa37920d 100644 --- a/packages/core/src/shader/utils/setPrecision.ts +++ b/packages/core/src/shader/utils/setPrecision.ts @@ -3,13 +3,11 @@ import { PRECISION } from '@pixi/constants'; /** * Sets the float precision on the shader, ensuring the device supports the request precision. * If the precision is already present, it just ensures that the device is able to handle it. - * * @private * @param {string} src - The shader source * @param {PIXI.PRECISION} requestedPrecision - The request float precision of the shader. * @param {PIXI.PRECISION} maxSupportedPrecision - The maximum precision the shader supports. - * - * @return {string} modified shader source + * @returns {string} modified shader source */ export function setPrecision(src: string, requestedPrecision: PRECISION, maxSupportedPrecision: PRECISION): string { diff --git a/packages/core/src/shader/utils/unsafeEvalSupported.ts b/packages/core/src/shader/utils/unsafeEvalSupported.ts index 408fc31852..c579977855 100644 --- a/packages/core/src/shader/utils/unsafeEvalSupported.ts +++ b/packages/core/src/shader/utils/unsafeEvalSupported.ts @@ -4,9 +4,8 @@ let unsafeEval: boolean; /** * Not all platforms allow to generate function code (e.g., `new Function`). * this provides the platform-level detection. - * * @private - * @returns {boolean} + * @returns {boolean} `true` if `new Function` is supported. */ export function unsafeEvalSupported(): boolean { diff --git a/packages/core/src/state/State.ts b/packages/core/src/state/State.ts index 83a3f2cebe..908deccafd 100644 --- a/packages/core/src/state/State.ts +++ b/packages/core/src/state/State.ts @@ -14,7 +14,6 @@ const DEPTH_MASK = 5; * * Each mesh rendered may require WebGL to be in a different state. * For example you may want different blend mode or to enable polygon offsets - * * @memberof PIXI */ export class State @@ -37,7 +36,6 @@ export class State /** * Activates blending of the computed fragment color values. - * * @default true */ get blend(): boolean @@ -55,7 +53,6 @@ export class State /** * Activates adding an offset to depth values of polygon's fragments - * * @default false */ get offsets(): boolean @@ -73,7 +70,6 @@ export class State /** * Activates culling of polygons. - * * @default false */ get culling(): boolean @@ -91,7 +87,6 @@ export class State /** * Activates depth comparisons and updates to the depth buffer. - * * @default false */ get depthTest(): boolean @@ -109,7 +104,6 @@ export class State /** * Enables or disables writing to the depth buffer. - * * @default true */ get depthMask(): boolean @@ -127,7 +121,6 @@ export class State /** * Specifies whether or not front or back-facing polygons can be culled. - * * @default false */ get clockwiseFrontFace(): boolean @@ -146,7 +139,6 @@ export class State /** * The blend mode to be applied when this state is set. Apply a value of `PIXI.BLEND_MODES.NORMAL` to reset the blend mode. * Setting this mode to anything other than NO_BLEND will automatically switch blending on. - * * @default PIXI.BLEND_MODES.NORMAL */ get blendMode(): BLEND_MODES @@ -162,7 +154,6 @@ export class State /** * The polygon offset. Setting this property to anything other than 0 will automatically enable polygon offset fill. - * * @default 0 */ get polygonOffset(): number diff --git a/packages/core/src/state/StateSystem.ts b/packages/core/src/state/StateSystem.ts index 7e3b7ee257..f7cd3654eb 100644 --- a/packages/core/src/state/StateSystem.ts +++ b/packages/core/src/state/StateSystem.ts @@ -14,7 +14,6 @@ const DEPTH_MASK = 5; /** * System plugin to the renderer to manage WebGL state machines. - * * @memberof PIXI */ export class StateSystem implements ISystem @@ -52,13 +51,13 @@ export class StateSystem implements ISystem /** * Collection of calls - * @member {function[]} + * @member {Function[]} */ protected readonly map: Array<(value: boolean) => void>; /** * Collection of check calls - * @member {function[]} + * @member {Function[]} */ protected readonly checks: Array<(system: this, state: State) => void>; @@ -106,7 +105,6 @@ export class StateSystem implements ISystem /** * Sets the current state - * * @param {*} state - The state to set. */ set(state: State): void @@ -146,7 +144,6 @@ export class StateSystem implements ISystem /** * Sets the state, when previous state is unknown. - * * @param {*} state - The state to set */ forceState(state: State): void @@ -166,7 +163,6 @@ export class StateSystem implements ISystem /** * Sets whether to enable or disable blending. - * * @param value - Turn on or off WebGl blending. */ setBlend(value: boolean): void @@ -178,7 +174,6 @@ export class StateSystem implements ISystem /** * Sets whether to enable or disable polygon offset fill. - * * @param value - Turn on or off webgl polygon offset testing. */ setOffset(value: boolean): void @@ -190,7 +185,6 @@ export class StateSystem implements ISystem /** * Sets whether to enable or disable depth test. - * * @param value - Turn on or off webgl depth testing. */ setDepthTest(value: boolean): void @@ -200,7 +194,6 @@ export class StateSystem implements ISystem /** * Sets whether to enable or disable depth mask. - * * @param value - Turn on or off webgl depth mask. */ setDepthMask(value: boolean): void @@ -210,7 +203,6 @@ export class StateSystem implements ISystem /** * Sets whether to enable or disable cull face. - * * @param {boolean} value - Turn on or off webgl cull face. */ setCullFace(value: boolean): void @@ -220,7 +212,6 @@ export class StateSystem implements ISystem /** * Sets the gl front face. - * * @param {boolean} value - true is clockwise and false is counter-clockwise */ setFrontFace(value: boolean): void @@ -230,7 +221,6 @@ export class StateSystem implements ISystem /** * Sets the blend mode. - * * @param {number} value - The blend mode to set to. */ setBlendMode(value: number): void @@ -267,7 +257,6 @@ export class StateSystem implements ISystem /** * Sets the polygon offset. - * * @param {number} value - the polygon offset * @param {number} scale - the polygon offset scale */ @@ -295,7 +284,6 @@ export class StateSystem implements ISystem * For example, if blend is enabled then we should check the blend modes each time the state is changed * or if polygon fill is activated then we need to check if the polygon offset changes. * The idea is that we only check what we have too. - * * @param func - the checking function to add or remove * @param value - should the check function be added or removed. */ @@ -315,8 +303,7 @@ export class StateSystem implements ISystem /** * A private little wrapper function that we call to check the blend mode. - * - * @param System - the System to perform the state check on + * @param system - the System to perform the state check on * @param state - the state that the blendMode will pulled from */ private static checkBlendMode(system: StateSystem, state: State): void @@ -326,8 +313,7 @@ export class StateSystem implements ISystem /** * A private little wrapper function that we call to check the polygon offset. - * - * @param System - the System to perform the state check on + * @param system - the System to perform the state check on * @param state - the state that the blendMode will pulled from */ private static checkPolygonOffset(system: StateSystem, state: State): void diff --git a/packages/core/src/state/utils/mapWebGLBlendModesToPixi.ts b/packages/core/src/state/utils/mapWebGLBlendModesToPixi.ts index 6ff02679ec..17daa5d2ab 100644 --- a/packages/core/src/state/utils/mapWebGLBlendModesToPixi.ts +++ b/packages/core/src/state/utils/mapWebGLBlendModesToPixi.ts @@ -2,13 +2,12 @@ import { BLEND_MODES } from '@pixi/constants'; /** * Maps gl blend combinations to WebGL. - * * @memberof PIXI * @function mapWebGLBlendModesToPixi * @private * @param {WebGLRenderingContext} gl - The rendering context. * @param {number[][]} [array=[]] - The array to output into. - * @return {number[][]} Mapped modes. + * @returns {number[][]} Mapped modes. */ export function mapWebGLBlendModesToPixi(gl: WebGLRenderingContextBase, array: number[][] = []): number[][] { diff --git a/packages/core/src/textures/BaseTexture.ts b/packages/core/src/textures/BaseTexture.ts index e1e2ecf7d6..2045f3eb4d 100644 --- a/packages/core/src/textures/BaseTexture.ts +++ b/packages/core/src/textures/BaseTexture.ts @@ -15,9 +15,10 @@ const defaultBufferOptions = { alphaMode: ALPHA_MODES.NPM, }; -export type ImageSource = HTMLImageElement|HTMLCanvasElement|HTMLVideoElement|ImageBitmap; +export type ImageSource = HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap; -export interface IBaseTextureOptions { +export interface IBaseTextureOptions +{ alphaMode?: ALPHA_MODES; mipmap?: MIPMAP_MODES; anisotropicLevel?: number; @@ -40,7 +41,6 @@ export interface BaseTexture extends GlobalMixins.BaseTexture, EventEmitter {} * A Texture stores the information that represents an image. * All textures have a base texture, which contains information about the source. * Therefore you can have many textures all using a single BaseTexture - * * @memberof PIXI * @typeParam R - The BaseTexture's Resource type. * @typeParam RO - The options for constructing resource. @@ -49,21 +49,18 @@ export class BaseTexture { /** * The width of the base texture set when the image has loaded - * * @readonly */ public width: number; /** * The height of the base texture set when the image has loaded - * * @readonly */ public height: number; /** * The resolution / device pixel ratio of the texture - * * @readonly * @default PIXI.settings.RESOLUTION */ @@ -71,7 +68,6 @@ export class BaseTexture /** * How to treat premultiplied alpha, see {@link PIXI.ALPHA_MODES}. - * * @member {PIXI.ALPHA_MODES} * @default PIXI.ALPHA_MODES.UNPACK */ @@ -79,7 +75,6 @@ export class BaseTexture /** * Anisotropic filtering level of texture - * * @member {number} * @default PIXI.settings.ANISOTROPIC_LEVEL */ @@ -87,35 +82,30 @@ export class BaseTexture /** * The pixel format of the texture - * * @default PIXI.FORMATS.RGBA */ public format?: FORMATS; /** * The type of resource data - * * @default PIXI.TYPES.UNSIGNED_BYTE */ public type?: TYPES; /** * The target type - * * @default PIXI.TARGETS.TEXTURE_2D */ public target?: TARGETS; /** * Global unique identifier for this BaseTexture - * * @protected */ public readonly uid: number; /** * Used by automatic texture Garbage Collection, stores last GC tick when it was bound - * * @protected */ touched: number; @@ -123,7 +113,6 @@ export class BaseTexture /** * Whether or not the texture is a power of two, try to use power of two textures as much * as you can - * * @readonly * @default false */ @@ -131,7 +120,6 @@ export class BaseTexture /** * The map of render context textures where this is bound - * * @private */ _glTextures: { [key: number]: GLTexture }; @@ -139,21 +127,18 @@ export class BaseTexture /** * Used by TextureSystem to only update texture to the GPU when needed. * Please call `update()` to increment it. - * * @readonly */ dirtyId: number; /** * Used by TextureSystem to only update texture style when needed. - * * @protected */ dirtyStyleId: number; /** * Currently default cache ID. - * * @member {string} */ public cacheId: string; @@ -168,7 +153,6 @@ export class BaseTexture /** * The collection of alternative cache ids, since some BaseTextures * can have more than one ID, short name and longer full URL - * * @member {Array} * @readonly */ @@ -176,7 +160,6 @@ export class BaseTexture /** * Flag if BaseTexture has been destroyed. - * * @member {boolean} * @readonly */ @@ -186,7 +169,6 @@ export class BaseTexture * The resource used by this BaseTexture, there can only * be one resource per BaseTexture, but textures can share * resources. - * * @member {PIXI.Resource} * @readonly */ @@ -194,21 +176,18 @@ export class BaseTexture /** * Number of the texture batch, used by multi-texture renderers - * * @member {number} */ _batchEnabled: number; /** * Location inside texture batch, used by multi-texture renderers - * * @member {number} */ _batchLocation: number; /** * Whether its a part of another texture, handled by ArrayResource or CubeResource - * * @member {PIXI.BaseTexture} */ parentTextureArray: BaseTexture; @@ -284,7 +263,6 @@ export class BaseTexture /** * Fired when a not-immediately-available source finishes loading. - * * @protected * @event PIXI.BaseTexture#loaded * @param {PIXI.BaseTexture} baseTexture - Resource loaded. @@ -292,7 +270,6 @@ export class BaseTexture /** * Fired when a not-immediately-available source fails to load. - * * @protected * @event PIXI.BaseTexture#error * @param {PIXI.BaseTexture} baseTexture - Resource errored. @@ -301,7 +278,6 @@ export class BaseTexture /** * Fired when BaseTexture is updated. - * * @protected * @event PIXI.BaseTexture#loaded * @param {PIXI.BaseTexture} baseTexture - Resource loaded. @@ -309,7 +285,6 @@ export class BaseTexture /** * Fired when BaseTexture is updated. - * * @protected * @event PIXI.BaseTexture#update * @param {PIXI.BaseTexture} baseTexture - Instance of texture being updated. @@ -317,7 +292,6 @@ export class BaseTexture /** * Fired when BaseTexture is destroyed. - * * @protected * @event PIXI.BaseTexture#dispose * @param {PIXI.BaseTexture} baseTexture - Instance of texture being destroyed. @@ -329,7 +303,6 @@ export class BaseTexture /** * Pixel width of the source of this texture - * * @readonly */ get realWidth(): number @@ -339,7 +312,6 @@ export class BaseTexture /** * Pixel height of the source of this texture - * * @readonly */ get realHeight(): number @@ -349,7 +321,6 @@ export class BaseTexture /** * Mipmap mode of the texture, affects downscaled images - * * @default PIXI.settings.MIPMAP_TEXTURES */ get mipmap(): MIPMAP_MODES @@ -367,7 +338,6 @@ export class BaseTexture /** * The scale mode to apply when scaling this texture - * * @default PIXI.settings.SCALE_MODE */ get scaleMode(): SCALE_MODES @@ -385,7 +355,6 @@ export class BaseTexture /** * How the texture wraps - * * @default PIXI.settings.WRAP_MODE */ get wrapMode(): WRAP_MODES @@ -403,7 +372,6 @@ export class BaseTexture /** * Changes style options of BaseTexture - * * @param scaleMode - Pixi scalemode * @param mipmap - enable mipmaps * @returns - this @@ -434,7 +402,6 @@ export class BaseTexture /** * Changes w/h/resolution. Texture becomes valid if width and height are greater than zero. - * * @param desiredWidth - Desired visual width * @param desiredHeight - Desired visual height * @param resolution - Optionally set resolution @@ -449,7 +416,6 @@ export class BaseTexture /** * Sets real size of baseTexture, preserves current resolution. - * * @param realWidth - Full rendered width * @param realHeight - Full rendered height * @param resolution - Optionally set resolution @@ -468,7 +434,6 @@ export class BaseTexture /** * Refresh check for isPowerOfTwo texture based on size - * * @private */ protected _refreshPOT(): void @@ -478,7 +443,6 @@ export class BaseTexture /** * Changes resolution - * * @param resolution - res * @returns - this */ @@ -507,7 +471,6 @@ export class BaseTexture /** * Sets the resource if it wasn't set. Throws error if resource already present - * * @param resource - that is managing this BaseTexture * @returns - this */ @@ -552,7 +515,6 @@ export class BaseTexture /** * Handle errors with resources. - * * @private * @param event - Error event emitted. */ @@ -601,7 +563,6 @@ export class BaseTexture * Frees the texture from WebGL memory without destroying this texture object. * This means you can still use the texture later which will upload it to GPU * memory again. - * * @fires PIXI.BaseTexture#dispose */ dispose(): void @@ -620,16 +581,15 @@ export class BaseTexture * The source can be - image url, image element, canvas element. If the * source is an image url or an image element and not in the base texture * cache, it will be created and loaded. - * * @static - * @param {string|HTMLImageElement|HTMLCanvasElement|SVGElement|HTMLVideoElement} source - The + * @param {string|string[]|HTMLImageElement|HTMLCanvasElement|SVGElement|HTMLVideoElement} source - The * source to create base texture from. * @param options - See {@link PIXI.BaseTexture}'s constructor for options. * @param {string} [options.pixiIdPrefix=pixiid] - If a source has no id, this is the prefix of the generated id * @param {boolean} [strict] - Enforce strict-mode, see {@link PIXI.settings.STRICT_TEXTURE_CACHE}. * @returns {PIXI.BaseTexture} The new base texture. */ - static from(source: ImageSource|string, + static from(source: ImageSource | string | string[], options?: IBaseTextureOptions, strict = settings.STRICT_TEXTURE_CACHE): BaseTexture { const isFrame = typeof source === 'string'; @@ -672,15 +632,14 @@ export class BaseTexture /** * Create a new BaseTexture with a BufferResource from a Float32Array. * RGBA values are floats from 0 to 1. - * * @param {Float32Array|Uint8Array} buffer - The optional array to use, if no data * is provided, a new Float32Array is created. * @param width - Width of the resource * @param height - Height of the resource * @param options - See {@link PIXI.BaseTexture}'s constructor for options. - * @return - The resulting new BaseTexture + * @returns - The resulting new BaseTexture */ - static fromBuffer(buffer: Float32Array|Uint8Array, + static fromBuffer(buffer: Float32Array | Uint8Array, width: number, height: number, options?: IBaseTextureOptions): BaseTexture { buffer = buffer || new Float32Array(width * height * 4); @@ -693,8 +652,6 @@ export class BaseTexture /** * Adds a BaseTexture to the global BaseTextureCache. This cache is shared across the whole PIXI object. - * - * * @param {PIXI.BaseTexture} baseTexture - The BaseTexture to add to the cache. * @param {string} id - The id that the BaseTexture will be stored against. */ @@ -719,11 +676,10 @@ export class BaseTexture /** * Remove a BaseTexture from the global BaseTextureCache. - * * @param {string|PIXI.BaseTexture} baseTexture - id of a BaseTexture to be removed, or a BaseTexture instance itself. - * @return {PIXI.BaseTexture|null} The BaseTexture that was removed. + * @returns {PIXI.BaseTexture|null} The BaseTexture that was removed. */ - static removeFromCache(baseTexture: string | BaseTexture): BaseTexture|null + static removeFromCache(baseTexture: string | BaseTexture): BaseTexture | null { if (typeof baseTexture === 'string') { diff --git a/packages/core/src/textures/GLTexture.ts b/packages/core/src/textures/GLTexture.ts index 28545a94ed..2770c957c6 100644 --- a/packages/core/src/textures/GLTexture.ts +++ b/packages/core/src/textures/GLTexture.ts @@ -2,7 +2,6 @@ import { FORMATS, TYPES } from '@pixi/constants'; /** * Internal texture for WebGL context. - * * @memberof PIXI */ export class GLTexture diff --git a/packages/core/src/textures/Texture.ts b/packages/core/src/textures/Texture.ts index 126b6df7cb..7242df1dce 100644 --- a/packages/core/src/textures/Texture.ts +++ b/packages/core/src/textures/Texture.ts @@ -14,10 +14,22 @@ import type { TextureMatrix } from './TextureMatrix'; const DEFAULT_UVS = new TextureUvs(); -export type TextureSource = string|BaseTexture|ImageSource; +export type TextureSource = string | BaseTexture | ImageSource; export interface Texture extends GlobalMixins.Texture, EventEmitter {} +/** + * Used to remove listeners from WHITE and EMPTY Textures + * @ignore + */ +function removeAllHandlers(tex: any): void +{ + tex.destroy = function _emptyDestroy(): void { /* empty */ }; + tex.on = function _emptyOn(): void { /* empty */ }; + tex.once = function _emptyOnce(): void { /* empty */ }; + tex.emit = function _emptyEmit(): void { /* empty */ }; +} + /** * A texture stores the information that represents an image or part of an image. * @@ -43,7 +55,6 @@ export interface Texture extends GlobalMixins.Texture, EventEmitter {} * //sprite1._textureID should not be undefined if the texture has finished processing the SVG file * ``` * You can use a ticker or rAF to ensure your sprites load the finished textures after processing. See issue #3068. - * * @memberof PIXI * @typeParam R - The BaseTexture's Resource type. */ @@ -85,22 +96,17 @@ export class Texture extends EventEmitter /** * Anchor point that is used as default if sprite is created with this texture. * Changing the `defaultAnchor` at a later point of time will not update Sprite's anchor point. - * * @default {0,0} */ public defaultAnchor: Point; - /** - * Default TextureMatrix instance for this texture. - * By default, that object is not created because its heavy. - */ + /** Default TextureMatrix instance for this texture. By default, that object is not created because its heavy. */ public uvMatrix: TextureMatrix; protected _rotate: number; /** * Update ID is observed by sprites and TextureMatrix instances. * Call updateUvs() to increment it. - * * @protected */ _updateID: number; @@ -113,7 +119,6 @@ export class Texture extends EventEmitter /** * The WebGL UV data cache. Can be used as quad UV. - * * @protected */ _uvs: TextureUvs; @@ -217,7 +222,6 @@ export class Texture extends EventEmitter /** * Called when the base texture is updated - * * @protected * @param baseTexture - The base texture. */ @@ -247,7 +251,6 @@ export class Texture extends EventEmitter /** * Destroys this texture - * * @param [destroyBase=false] - Whether to destroy the base texture as well */ destroy(destroyBase?: boolean): void @@ -287,8 +290,7 @@ export class Texture extends EventEmitter /** * Creates a new texture object that acts the same as this one. - * - * @return - The new texture + * @returns - The new texture */ clone(): Texture { @@ -329,15 +331,15 @@ export class Texture extends EventEmitter /** * Helper function that creates a new Texture based on the source you provide. * The source can be - frame id, image url, video url, canvas element, video element, base texture - * * @param {string|HTMLImageElement|HTMLCanvasElement|HTMLVideoElement|PIXI.BaseTexture} source - - * Source to create texture from + * Source or array of sources to create texture from * @param options - See {@link PIXI.BaseTexture}'s constructor for options. * @param {string} [options.pixiIdPrefix=pixiid] - If a source has no id, this is the prefix of the generated id * @param {boolean} [strict] - Enforce strict-mode, see {@link PIXI.settings.STRICT_TEXTURE_CACHE}. - * @return {PIXI.Texture} The newly created texture + * @returns {PIXI.Texture} The newly created texture */ - static from(source: TextureSource, options: IBaseTextureOptions = {}, + static from(source: TextureSource | TextureSource[], + options: IBaseTextureOptions = {}, strict = settings.STRICT_TEXTURE_CACHE): Texture { const isFrame = typeof source === 'string'; @@ -407,13 +409,12 @@ export class Texture extends EventEmitter * Useful for loading textures via URLs. Use instead of `Texture.from` because * it does a better job of handling failed URLs more effectively. This also ignores * `PIXI.settings.STRICT_TEXTURE_CACHE`. Works for Videos, SVGs, Images. - * - * @param url - The remote URL to load. + * @param url - The remote URL or array of URLs to load. * @param options - Optional options to include - * @return - A Promise that resolves to a Texture. + * @returns - A Promise that resolves to a Texture. */ static fromURL( - url: string, options?: IBaseTextureOptions): Promise> + url: string | string[], options?: IBaseTextureOptions): Promise> { const resourceOptions = Object.assign({ autoLoad: false }, options?.resourceOptions); const texture = Texture.from(url, Object.assign({ resourceOptions }, options), false); @@ -432,15 +433,14 @@ export class Texture extends EventEmitter /** * Create a new Texture with a BufferResource from a Float32Array. * RGBA values are floats from 0 to 1. - * * @param {Float32Array|Uint8Array} buffer - The optional array to use, if no data * is provided, a new Float32Array is created. * @param width - Width of the resource * @param height - Height of the resource * @param options - See {@link PIXI.BaseTexture}'s constructor for options. - * @return - The resulting new BaseTexture + * @returns - The resulting new BaseTexture */ - static fromBuffer(buffer: Float32Array|Uint8Array, + static fromBuffer(buffer: Float32Array | Uint8Array, width: number, height: number, options?: IBaseTextureOptions): Texture { return new Texture(BaseTexture.fromBuffer(buffer, width, height, options)); @@ -448,14 +448,14 @@ export class Texture extends EventEmitter /** * Create a texture from a source and add to the cache. - * * @param {HTMLImageElement|HTMLCanvasElement|string} source - The input source. * @param imageUrl - File name of texture, for cache and resolving resolution. * @param name - Human readable name for the texture cache. If no name is * specified, only `imageUrl` will be used as the cache ID. - * @return - Output texture + * @param options + * @returns - Output texture */ - static fromLoader(source: HTMLImageElement|HTMLCanvasElement|string, + static fromLoader(source: HTMLImageElement | HTMLCanvasElement | string, imageUrl: string, name?: string, options?: IBaseTextureOptions): Promise> { const baseTexture = new BaseTexture(source, Object.assign({ @@ -504,7 +504,6 @@ export class Texture extends EventEmitter /** * Adds a Texture to the global TextureCache. This cache is shared across the whole PIXI object. - * * @param texture - The Texture to add to the cache. * @param id - The id that the Texture will be stored against. */ @@ -529,11 +528,10 @@ export class Texture extends EventEmitter /** * Remove a Texture from the global TextureCache. - * * @param texture - id of a Texture to be removed, or a Texture instance itself - * @return - The Texture that was removed + * @returns - The Texture that was removed */ - static removeFromCache(texture: string|Texture): Texture|null + static removeFromCache(texture: string | Texture): Texture | null { if (typeof texture === 'string') { @@ -574,7 +572,6 @@ export class Texture extends EventEmitter /** * Returns resolution of baseTexture - * * @readonly */ get resolution(): number @@ -663,53 +660,41 @@ export class Texture extends EventEmitter return this.baseTexture; } - static readonly EMPTY: Texture; - static readonly WHITE: Texture; -} + private static _EMPTY: Texture; + private static _WHITE: Texture; -function createWhiteTexture(): Texture -{ - const canvas = document.createElement('canvas'); + /** An empty texture, used often to not have to create multiple empty textures. Can not be destroyed. */ + public static get EMPTY(): Texture + { + if (!Texture._EMPTY) + { + Texture._EMPTY = new Texture(new BaseTexture()); + removeAllHandlers(Texture._EMPTY); + removeAllHandlers(Texture._EMPTY.baseTexture); + } - canvas.width = 16; - canvas.height = 16; + return Texture._EMPTY; + } - const context = canvas.getContext('2d'); + /** A white texture of 16x16 size, used for graphics and other things Can not be destroyed. */ + public static get WHITE(): Texture + { + if (!Texture._WHITE) + { + const canvas = document.createElement('canvas'); + const context = canvas.getContext('2d'); - context.fillStyle = 'white'; - context.fillRect(0, 0, 16, 16); + canvas.width = 16; + canvas.height = 16; + context.fillStyle = 'white'; + context.fillRect(0, 0, 16, 16); - return new Texture(new BaseTexture(new CanvasResource(canvas))); -} + Texture._WHITE = new Texture(new BaseTexture(new CanvasResource(canvas))); + removeAllHandlers(Texture._WHITE); + removeAllHandlers(Texture._WHITE.baseTexture); + } -function removeAllHandlers(tex: any): void -{ - tex.destroy = function _emptyDestroy(): void { /* empty */ }; - tex.on = function _emptyOn(): void { /* empty */ }; - tex.once = function _emptyOnce(): void { /* empty */ }; - tex.emit = function _emptyEmit(): void { /* empty */ }; + return Texture._WHITE; + } } -/** - * An empty texture, used often to not have to create multiple empty textures. - * Can not be destroyed. - * - * @static - * @constant - * @member {PIXI.Texture} - */ -(Texture as any).EMPTY = new Texture(new BaseTexture()); -removeAllHandlers(Texture.EMPTY); -removeAllHandlers(Texture.EMPTY.baseTexture); - -/** - * A white texture of 16x16 size, used for graphics and other things - * Can not be destroyed. - * - * @static - * @constant - * @member {PIXI.Texture} - */ -(Texture as any).WHITE = createWhiteTexture(); -removeAllHandlers(Texture.WHITE); -removeAllHandlers(Texture.WHITE.baseTexture); diff --git a/packages/core/src/textures/TextureGCSystem.ts b/packages/core/src/textures/TextureGCSystem.ts index fe17f8800e..26a5880de9 100644 --- a/packages/core/src/textures/TextureGCSystem.ts +++ b/packages/core/src/textures/TextureGCSystem.ts @@ -6,7 +6,8 @@ import type { Renderer } from '../Renderer'; import type { Texture } from './Texture'; import type { RenderTexture } from '../renderTexture/RenderTexture'; -export interface IUnloadableTexture { +export interface IUnloadableTexture +{ _texture: Texture | RenderTexture; children: IUnloadableTexture[]; } @@ -14,42 +15,36 @@ export interface IUnloadableTexture { /** * System plugin to the renderer to manage texture garbage collection on the GPU, * ensuring that it does not get clogged up with textures that are no longer being used. - * * @memberof PIXI */ export class TextureGCSystem implements ISystem { /** * Count - * * @readonly */ public count: number; /** * Check count - * * @readonly */ public checkCount: number; /** * Maximum idle time, in seconds - * * @see PIXI.settings.GC_MAX_IDLE */ public maxIdle: number; /** * Maximum number of item to check - * * @see PIXI.settings.GC_MAX_CHECK_COUNT */ public checkCountMax: number; /** * Current garbage collection mode - * * @see PIXI.settings.GC_MODE */ public mode: GC_MODES; @@ -136,7 +131,6 @@ export class TextureGCSystem implements ISystem /** * Removes all the textures within the specified displayObject and its children from the GPU - * * @param {PIXI.DisplayObject} displayObject - the displayObject to remove the textures from. */ unload(displayObject: IUnloadableTexture): void diff --git a/packages/core/src/textures/TextureMatrix.ts b/packages/core/src/textures/TextureMatrix.ts index 4c0c3fb80f..013628309a 100644 --- a/packages/core/src/textures/TextureMatrix.ts +++ b/packages/core/src/textures/TextureMatrix.ts @@ -14,7 +14,6 @@ const tempMat = new Matrix(); * * Takes track of Texture changes through `_lastTextureID` private field. * Use `update()` method call to track it from outside. - * * @see PIXI.Texture * @see PIXI.Mesh * @see PIXI.TilingSprite @@ -24,7 +23,6 @@ export class TextureMatrix { /** * Matrix operation that converts texture region coords to texture coords - * * @readonly */ public mapCoord: Matrix; @@ -33,7 +31,6 @@ export class TextureMatrix * Changes frame clamping * Works with TilingSprite and Mesh * Change to 1.5 if you texture has repeated right and bottom lines, that leads to smoother borders - * * @default 0 */ public clampOffset: number; @@ -42,7 +39,6 @@ export class TextureMatrix * Changes frame clamping * Works with TilingSprite and Mesh * Change to -0.5 to add a pixel to the edge, recommended for transparent trimmed textures in atlas - * * @default 0.5 */ public clampMargin: number; @@ -53,22 +49,17 @@ export class TextureMatrix */ readonly uClampFrame: Float32Array; - /** - * Normalized clamp offset. - * Calculated based on clampOffset. - */ + /** Normalized clamp offset. Calculated based on clampOffset. */ readonly uClampOffset: Float32Array; /** * Tracks Texture frame changes. - * * @protected */ _textureID: number; /** * Tracks Texture frame changes. - * * @protected */ _updateID: number; @@ -76,7 +67,6 @@ export class TextureMatrix /** * If texture size is the same as baseTexture. - * * @default false * @readonly */ @@ -115,7 +105,6 @@ export class TextureMatrix /** * Multiplies uvs array to transform - * * @param uvs - mesh uvs * @param [out=uvs] - output * @returns - output @@ -143,7 +132,6 @@ export class TextureMatrix /** * Updates matrices if texture was changed. - * * @param [forceUpdate=false] - if true, matrices will be updated any case * @returns - Whether or not it was updated */ diff --git a/packages/core/src/textures/TextureSystem.ts b/packages/core/src/textures/TextureSystem.ts index 2a2a8b7cd1..d23e6a1f0a 100644 --- a/packages/core/src/textures/TextureSystem.ts +++ b/packages/core/src/textures/TextureSystem.ts @@ -11,21 +11,18 @@ import type { Renderer } from '../Renderer'; /** * System plugin to the renderer to manage textures. - * * @memberof PIXI */ export class TextureSystem implements ISystem { /** * Bound textures. - * * @readonly */ public boundTextures: BaseTexture[]; /** * List of managed textures. - * * @readonly */ public managedTextures: Array; @@ -39,21 +36,18 @@ export class TextureSystem implements ISystem /** * BaseTexture value that shows that we don't know what is bound. - * * @readonly */ protected unknownTexture: BaseTexture; /** * Did someone temper with textures state? We'll overwrite them when we need to unbind something. - * * @private */ protected _unknownBoundTextures: boolean; /** * Current location. - * * @readonly */ currentLocation: number; @@ -129,11 +123,10 @@ export class TextureSystem implements ISystem * Bind a texture to a specific location * * If you want to unbind something, please use `unbind(texture)` instead of `bind(null, textureLocation)` - * - * @param texture_ - Texture to bind + * @param texture - Texture to bind * @param [location=0] - Location to bind at */ - bind(texture: Texture|BaseTexture, location = 0): void + bind(texture: Texture | BaseTexture, location = 0): void { const { gl } = this; @@ -183,11 +176,7 @@ export class TextureSystem implements ISystem } } - /** - * Resets texture location and bound textures - * - * Actual `bind(null, i)` calls will be performed at next `unbind()` call - */ + /** Resets texture location and bound textures Actual `bind(null, i)` calls will be performed at next `unbind()` call */ reset(): void { this._unknownBoundTextures = true; @@ -202,7 +191,6 @@ export class TextureSystem implements ISystem /** * Unbind a texture. - * * @param texture - Texture to bind */ unbind(texture?: BaseTexture): void @@ -242,7 +230,6 @@ export class TextureSystem implements ISystem /** * Ensures that current boundTextures all have FLOAT sampler type, * see {@link PIXI.SAMPLER_TYPES} for explanation. - * * @param maxTextures - number of locations to check */ ensureSamplerType(maxTextures: number): void @@ -272,7 +259,6 @@ export class TextureSystem implements ISystem /** * Initialize a texture - * * @private * @param texture - Texture to initialize */ @@ -309,7 +295,6 @@ export class TextureSystem implements ISystem /** * Update a texture - * * @private * @param {PIXI.BaseTexture} texture - Texture to initialize */ @@ -369,12 +354,11 @@ export class TextureSystem implements ISystem /** * Deletes the texture from WebGL - * * @private - * @param texture_ - the texture to destroy + * @param texture - the texture to destroy * @param [skipRemove=false] - Whether to skip removing the texture from the TextureManager. */ - destroyTexture(texture: BaseTexture|Texture, skipRemove?: boolean): void + destroyTexture(texture: BaseTexture | Texture, skipRemove?: boolean): void { const { gl } = this; @@ -403,7 +387,6 @@ export class TextureSystem implements ISystem /** * Update texture style such as mipmap flag - * * @private * @param {PIXI.BaseTexture} texture - Texture to update */ @@ -448,7 +431,6 @@ export class TextureSystem implements ISystem /** * Set style for texture - * * @private * @param texture - Texture to update * @param glTexture diff --git a/packages/core/src/textures/TextureUvs.ts b/packages/core/src/textures/TextureUvs.ts index 4f90e1e6f0..6e796c6f8e 100644 --- a/packages/core/src/textures/TextureUvs.ts +++ b/packages/core/src/textures/TextureUvs.ts @@ -13,7 +13,6 @@ import type { Rectangle, ISize } from '@pixi/math'; * | Top-Right | `(x1,y1)` | * | Bottom-Right | `(x2,y2)` | * | Bottom-Left | `(x3,y3)` | - * * @protected * @memberof PIXI */ @@ -60,7 +59,6 @@ export class TextureUvs /** * Sets the texture Uvs based on the given frame information. - * * @protected * @param frame - The frame of the texture * @param baseFrame - The base frame of the texture diff --git a/packages/core/src/textures/resources/AbstractMultiResource.ts b/packages/core/src/textures/resources/AbstractMultiResource.ts index 85f9ea5792..d44b856c5e 100644 --- a/packages/core/src/textures/resources/AbstractMultiResource.ts +++ b/packages/core/src/textures/resources/AbstractMultiResource.ts @@ -7,7 +7,6 @@ import { autoDetectResource, IAutoDetectOptions } from './autoDetectResource'; * Resource that can manage several resource (items) inside. * All resources need to have the same pixel size. * Parent class for CubeResource and ArrayResource - * * @memberof PIXI */ export abstract class AbstractMultiResource extends Resource @@ -17,21 +16,18 @@ export abstract class AbstractMultiResource extends Resource /** * Collection of partial baseTextures that correspond to resources. - * * @readonly */ items: Array; /** * Dirty IDs for each part. - * * @readonly */ itemDirtyIds: Array; /** * Promise when loading. - * * @default null */ private _load: Promise; @@ -72,7 +68,6 @@ export abstract class AbstractMultiResource extends Resource /** * Used from ArrayResource and CubeResource constructors. - * * @param resources - Can be resources, image elements, canvas, etc. , * length should be same as constructor length * @param options - Detect options for resources @@ -114,19 +109,17 @@ export abstract class AbstractMultiResource extends Resource /** * Set a baseTexture by ID - * * @param baseTexture * @param index - Zero-based index of resource to set - * @return - Instance for chaining + * @returns - Instance for chaining */ abstract addBaseTextureAt(baseTexture: BaseTexture, index: number): this; /** * Set a resource by ID - * * @param resource * @param index - Zero-based index of resource to set - * @return - Instance for chaining + * @returns - Instance for chaining */ addResourceAt(resource: Resource, index: number): this { @@ -146,7 +139,10 @@ export abstract class AbstractMultiResource extends Resource return this; } - /** Set the parent base texture. */ + /** + * Set the parent base texture. + * @param baseTexture + */ bind(baseTexture: BaseTexture): void { if (this.baseTexture !== null) @@ -162,7 +158,10 @@ export abstract class AbstractMultiResource extends Resource } } - /** Unset the parent base texture. */ + /** + * Unset the parent base texture. + * @param baseTexture + */ unbind(baseTexture: BaseTexture): void { super.unbind(baseTexture); @@ -176,8 +175,7 @@ export abstract class AbstractMultiResource extends Resource /** * Load all the resources simultaneously - * - * @return - When load is resolved + * @returns - When load is resolved */ load(): Promise { diff --git a/packages/core/src/textures/resources/ArrayResource.ts b/packages/core/src/textures/resources/ArrayResource.ts index 260321dd5e..1b9d17d09a 100644 --- a/packages/core/src/textures/resources/ArrayResource.ts +++ b/packages/core/src/textures/resources/ArrayResource.ts @@ -9,7 +9,6 @@ import type { ISize } from '@pixi/math'; /** * A resource that contains a number of sources. - * * @memberof PIXI */ export class ArrayResource extends AbstractMultiResource @@ -21,7 +20,7 @@ export class ArrayResource extends AbstractMultiResource * @param {number} [options.width] - Width of the resource * @param {number} [options.height] - Height of the resource */ - constructor(source: number|Array, options?: ISize) + constructor(source: number | Array, options?: ISize) { const { width, height } = options || {}; @@ -49,10 +48,9 @@ export class ArrayResource extends AbstractMultiResource /** * Set a baseTexture by ID, * ArrayResource just takes resource from it, nothing more - * * @param baseTexture * @param index - Zero-based index of resource to set - * @return - Instance for chaining + * @returns - Instance for chaining */ addBaseTextureAt(baseTexture: BaseTexture, index: number): this { @@ -68,7 +66,10 @@ export class ArrayResource extends AbstractMultiResource return this; } - /** Add binding */ + /** + * Add binding + * @param baseTexture + */ bind(baseTexture: BaseTexture): void { super.bind(baseTexture); @@ -78,7 +79,6 @@ export class ArrayResource extends AbstractMultiResource /** * Upload the resources to the GPU. - * * @param renderer * @param texture * @param glTexture diff --git a/packages/core/src/textures/resources/BaseImageResource.ts b/packages/core/src/textures/resources/BaseImageResource.ts index 85cabac3d8..a58d52cf2d 100644 --- a/packages/core/src/textures/resources/BaseImageResource.ts +++ b/packages/core/src/textures/resources/BaseImageResource.ts @@ -8,14 +8,12 @@ import type { GLTexture } from '../GLTexture'; /** * Base for all the image/canvas resources. - * * @memberof PIXI */ export class BaseImageResource extends Resource { /** * The source element. - * * @member {HTMLImageElement|HTMLCanvasElement|HTMLVideoElement|SVGElement} * @readonly */ @@ -24,7 +22,6 @@ export class BaseImageResource extends Resource /** * If set to `true`, will force `texImage2D` over `texSubImage2D` for uploading. * Certain types of media (e.g. video) using `texImage2D` is more performant. - * * @default false * @private */ @@ -47,12 +44,11 @@ export class BaseImageResource extends Resource /** * Set cross origin based detecting the url and the crossorigin - * * @param element - Element to apply crossOrigin * @param url - URL to check * @param crossorigin - Cross origin value to use */ - static crossOrigin(element: HTMLImageElement|HTMLVideoElement, url: string, crossorigin?: boolean|string): void + static crossOrigin(element: HTMLImageElement | HTMLVideoElement, url: string, crossorigin?: boolean | string): void { if (crossorigin === undefined && url.indexOf('data:') !== 0) { @@ -66,7 +62,6 @@ export class BaseImageResource extends Resource /** * Upload the texture to the GPU. - * * @param renderer - Upload to the renderer * @param baseTexture - Reference to parent texture * @param glTexture diff --git a/packages/core/src/textures/resources/BufferResource.ts b/packages/core/src/textures/resources/BufferResource.ts index 402adeeb2b..691f66a9c3 100644 --- a/packages/core/src/textures/resources/BufferResource.ts +++ b/packages/core/src/textures/resources/BufferResource.ts @@ -11,16 +11,12 @@ import type { GLTexture } from '../GLTexture'; /** * Buffer resource with data of typed array. - * * @memberof PIXI */ export class BufferResource extends Resource { - /** - * Source array - * Cannot be {@code ClampedUint8Array} because it cant be uploaded to WebGL - */ - data: Float32Array|Uint8Array|Uint16Array|Int32Array|Uint32Array; + /** Source array Cannot be {@code ClampedUint8Array} because it cant be uploaded to WebGL */ + data: Float32Array | Uint8Array | Uint16Array | Int32Array | Uint32Array; /** * @param source - Source buffer @@ -28,7 +24,7 @@ export class BufferResource extends Resource * @param {number} options.width - Width of the texture * @param {number} options.height - Height of the texture */ - constructor(source: Float32Array|Uint8Array|Uint16Array|Int32Array|Uint32Array, options: ISize) + constructor(source: Float32Array | Uint8Array | Uint16Array | Int32Array | Uint32Array, options: ISize) { const { width, height } = options || {}; @@ -44,7 +40,6 @@ export class BufferResource extends Resource /** * Upload the texture to the GPU. - * * @param renderer - Upload to the renderer * @param baseTexture - Reference to parent texture * @param glTexture - glTexture @@ -102,11 +97,10 @@ export class BufferResource extends Resource /** * Used to auto-detect the type of resource. - * * @param {*} source - The source object - * @return {boolean} `true` if + * @returns {boolean} `true` if */ - static test(source: unknown): source is Float32Array|Uint8Array|Uint32Array + static test(source: unknown): source is Float32Array | Uint8Array | Uint32Array { return source instanceof Float32Array || source instanceof Uint8Array diff --git a/packages/core/src/textures/resources/CanvasResource.ts b/packages/core/src/textures/resources/CanvasResource.ts index 85ec31a6f9..f9826772b3 100644 --- a/packages/core/src/textures/resources/CanvasResource.ts +++ b/packages/core/src/textures/resources/CanvasResource.ts @@ -6,7 +6,6 @@ import { BaseImageResource } from './BaseImageResource'; /** * Resource type for HTMLCanvasElement. - * * @memberof PIXI */ export class CanvasResource extends BaseImageResource @@ -22,11 +21,10 @@ export class CanvasResource extends BaseImageResource /** * Used to auto-detect the type of resource. - * * @param {*} source - The source object - * @return {boolean} `true` if source is HTMLCanvasElement or OffscreenCanvas + * @returns {boolean} `true` if source is HTMLCanvasElement or OffscreenCanvas */ - static test(source: unknown): source is OffscreenCanvas|HTMLCanvasElement + static test(source: unknown): source is OffscreenCanvas | HTMLCanvasElement { const { OffscreenCanvas } = globalThis; diff --git a/packages/core/src/textures/resources/CubeResource.ts b/packages/core/src/textures/resources/CubeResource.ts index 19d1c56d5f..55a5d86347 100644 --- a/packages/core/src/textures/resources/CubeResource.ts +++ b/packages/core/src/textures/resources/CubeResource.ts @@ -8,9 +8,7 @@ import type { BaseTexture } from '../BaseTexture'; import type { Renderer } from '../../Renderer'; import type { GLTexture } from '../GLTexture'; -/** - * Constructor options for CubeResource - */ +/** Constructor options for CubeResource */ export interface ICubeResourceOptions extends ISize { /** Whether to auto-load resources */ @@ -22,7 +20,6 @@ export interface ICubeResourceOptions extends ISize /** * Resource for a CubeTexture which contains six resources. - * * @memberof PIXI */ export class CubeResource extends AbstractMultiResource @@ -31,7 +28,6 @@ export class CubeResource extends AbstractMultiResource /** * In case BaseTextures are supplied, whether to use same resource or bind baseTexture itself. - * * @protected */ linkBaseTexture: boolean; @@ -46,7 +42,7 @@ export class CubeResource extends AbstractMultiResource * @param {number} [options.linkBaseTexture=true] - In case BaseTextures are supplied, * whether to copy them or use */ - constructor(source?: ArrayFixed, options?: ICubeResourceOptions) + constructor(source?: ArrayFixed, options?: ICubeResourceOptions) { const { width, height, autoLoad, linkBaseTexture } = options || {}; @@ -77,7 +73,6 @@ export class CubeResource extends AbstractMultiResource /** * Add binding. - * * @param baseTexture - parent base texture */ bind(baseTexture: BaseTexture): void @@ -134,7 +129,9 @@ export class CubeResource extends AbstractMultiResource /** * Upload the resource - * + * @param renderer + * @param _baseTexture + * @param glTexture * @returns {boolean} true is success */ upload(renderer: Renderer, _baseTexture: BaseTexture, glTexture: GLTexture): boolean @@ -177,11 +174,10 @@ export class CubeResource extends AbstractMultiResource /** * Used to auto-detect the type of resource. - * * @param {*} source - The source object - * @return {boolean} `true` if source is an array of 6 elements + * @returns {boolean} `true` if source is an array of 6 elements */ - static test(source: unknown): source is ArrayFixed + static test(source: unknown): source is ArrayFixed { return Array.isArray(source) && source.length === CubeResource.SIDES; } diff --git a/packages/core/src/textures/resources/DepthResource.ts b/packages/core/src/textures/resources/DepthResource.ts index 8b01c5381c..68080be37b 100644 --- a/packages/core/src/textures/resources/DepthResource.ts +++ b/packages/core/src/textures/resources/DepthResource.ts @@ -7,18 +7,16 @@ import type { GLTexture } from '../GLTexture'; /** * Resource type for DepthTexture. - * * @memberof PIXI */ export class DepthResource extends BufferResource { /** * Upload the texture to the GPU. - * * @param renderer - Upload to the renderer * @param baseTexture - Reference to parent texture * @param glTexture - glTexture - * @return - true is success + * @returns - true is success */ upload(renderer: Renderer, baseTexture: BaseTexture, glTexture: GLTexture): boolean { diff --git a/packages/core/src/textures/resources/ImageBitmapResource.ts b/packages/core/src/textures/resources/ImageBitmapResource.ts index 28840e70b2..8043a2b1a4 100644 --- a/packages/core/src/textures/resources/ImageBitmapResource.ts +++ b/packages/core/src/textures/resources/ImageBitmapResource.ts @@ -2,7 +2,6 @@ import { BaseImageResource } from './BaseImageResource'; /** * Resource type for ImageBitmap. - * * @memberof PIXI */ export class ImageBitmapResource extends BaseImageResource @@ -18,9 +17,8 @@ export class ImageBitmapResource extends BaseImageResource /** * Used to auto-detect the type of resource. - * * @param {*} source - The source object - * @return {boolean} `true` if source is an ImageBitmap + * @returns {boolean} `true` if source is an ImageBitmap */ static test(source: unknown): source is ImageBitmap { diff --git a/packages/core/src/textures/resources/ImageResource.ts b/packages/core/src/textures/resources/ImageResource.ts index 8357a66cd1..b968436889 100644 --- a/packages/core/src/textures/resources/ImageResource.ts +++ b/packages/core/src/textures/resources/ImageResource.ts @@ -15,7 +15,7 @@ export interface IImageResourceOptions createBitmap?: boolean; /** Load image using cross origin. */ - crossorigin?: boolean|string; + crossorigin?: boolean | string; /** Premultiply image alpha in bitmap. */ alphaMode?: ALPHA_MODES; @@ -23,7 +23,6 @@ export interface IImageResourceOptions /** * Resource type for HTMLImageElement. - * * @memberof PIXI */ export class ImageResource extends BaseImageResource @@ -33,14 +32,12 @@ export class ImageResource extends BaseImageResource /** * If the image should be disposed after upload - * * @default false */ preserveBitmap: boolean; /** * If capable, convert the image using createImageBitmap API. - * * @default PIXI.settings.CREATE_IMAGE_BITMAP */ createBitmap: boolean; @@ -49,21 +46,18 @@ export class ImageResource extends BaseImageResource * Controls texture alphaMode field * Copies from options * Default is `null`, copies option from baseTexture - * * @readonly */ alphaMode: ALPHA_MODES; /** * The ImageBitmap element created for a {@code HTMLImageElement}. - * * @default null */ bitmap: ImageBitmap; /** * Promise when loading. - * * @default null */ private _load: Promise; @@ -80,7 +74,7 @@ export class ImageResource extends BaseImageResource * @param {boolean} [options.crossorigin=true] - Load image using cross origin * @param {PIXI.ALPHA_MODES} [options.alphaMode=PIXI.ALPHA_MODES.UNPACK] - Premultiply image alpha in bitmap */ - constructor(source: HTMLImageElement|string, options?: IImageResourceOptions) + constructor(source: HTMLImageElement | string, options?: IImageResourceOptions) { options = options || {}; @@ -126,7 +120,6 @@ export class ImageResource extends BaseImageResource /** * Returns a promise when image will be loaded and processed. - * * @param createBitmap - whether process image into bitmap */ load(createBitmap?: boolean): Promise @@ -191,8 +184,7 @@ export class ImageResource extends BaseImageResource /** * Called when we need to convert image into BitmapImage. * Can be called multiple times, real promise is cached inside. - * - * @return - Cached promise to fill that bitmap + * @returns - Cached promise to fill that bitmap */ process(): Promise { @@ -238,7 +230,6 @@ export class ImageResource extends BaseImageResource /** * Upload the image resource to GPU. - * * @param renderer - Renderer to upload to * @param baseTexture - BaseTexture for this resource * @param glTexture - GLTexture to use @@ -321,11 +312,10 @@ export class ImageResource extends BaseImageResource /** * Used to auto-detect the type of resource. - * * @param {*} source - The source object - * @return {boolean} `true` if source is string or HTMLImageElement + * @returns {boolean} `true` if source is string or HTMLImageElement */ - static test(source: unknown): source is string|HTMLImageElement + static test(source: unknown): source is string | HTMLImageElement { return typeof source === 'string' || source instanceof HTMLImageElement; } diff --git a/packages/core/src/textures/resources/Resource.ts b/packages/core/src/textures/resources/Resource.ts index 51b422f78c..9342b0391a 100644 --- a/packages/core/src/textures/resources/Resource.ts +++ b/packages/core/src/textures/resources/Resource.ts @@ -8,14 +8,12 @@ import type { GLTexture } from '../GLTexture'; * Base resource class for textures that manages validation and uploading, depending on its type. * * Uploading of a base texture to the GPU is required. - * * @memberof PIXI */ export abstract class Resource { /** * If resource has been destroyed. - * * @readonly * @default false */ @@ -38,7 +36,6 @@ export abstract class Resource /** * Mini-runner for handling resize events * accepts 2 parameters: width, height - * * @member {Runner} * @private */ @@ -46,7 +43,6 @@ export abstract class Resource /** * Mini-runner for handling update events - * * @member {Runner} * @private */ @@ -55,7 +51,6 @@ export abstract class Resource /** * Handle internal errors, such as loading errors * accepts 1 param: error - * * @member {Runner} * @private */ @@ -80,7 +75,6 @@ export abstract class Resource /** * Bind to a parent BaseTexture - * * @param baseTexture - Parent texture */ bind(baseTexture: BaseTexture): void @@ -99,7 +93,6 @@ export abstract class Resource /** * Unbind to a parent BaseTexture - * * @param baseTexture - Parent texture */ unbind(baseTexture: BaseTexture): void @@ -111,7 +104,6 @@ export abstract class Resource /** * Trigger a resize event - * * @param width - X dimension * @param height - Y dimension */ @@ -127,7 +119,6 @@ export abstract class Resource /** * Has been validated - * * @readonly */ get valid(): boolean @@ -147,9 +138,8 @@ export abstract class Resource /** * This can be overridden to start preloading a resource * or do any other prepare step. - * * @protected - * @return Handle the validate event + * @returns Handle the validate event */ load(): Promise { @@ -158,7 +148,6 @@ export abstract class Resource /** * The width of the resource. - * * @readonly */ get width(): number @@ -168,7 +157,6 @@ export abstract class Resource /** * The height of the resource. - * * @readonly */ get height(): number @@ -178,7 +166,6 @@ export abstract class Resource /** * Uploads the texture or returns false if it cant for some reason. Override this. - * * @param renderer - yeah, renderer! * @param baseTexture - the texture * @param glTexture - texture instance for this webgl context @@ -188,10 +175,9 @@ export abstract class Resource /** * Set the style, optional to override - * - * @param renderer - yeah, renderer! - * @param baseTexture - the texture - * @param glTexture - texture instance for this webgl context + * @param _renderer - yeah, renderer! + * @param _baseTexture - the texture + * @param _glTexture - texture instance for this webgl context * @returns - `true` is success */ style(_renderer: Renderer, _baseTexture: BaseTexture, _glTexture: GLTexture): boolean @@ -227,9 +213,8 @@ export abstract class Resource /** * Abstract, used to auto-detect resource type. - * - * @param {*} source - The source object - * @param {string} extension - The extension of source, if set + * @param {*} _source - The source object + * @param {string} _extension - The extension of source, if set */ static test(_source: unknown, _extension?: string): boolean { diff --git a/packages/core/src/textures/resources/SVGResource.ts b/packages/core/src/textures/resources/SVGResource.ts index 7432530b57..464f631d6a 100644 --- a/packages/core/src/textures/resources/SVGResource.ts +++ b/packages/core/src/textures/resources/SVGResource.ts @@ -10,11 +10,10 @@ export interface ISVGResourceOptions width?: number; height?: number; autoLoad?: boolean; - crossorigin?: boolean|string; + crossorigin?: boolean | string; } /** * Resource type for SVG elements and graphics. - * * @memberof PIXI */ export class SVGResource extends BaseImageResource @@ -38,7 +37,7 @@ export class SVGResource extends BaseImageResource private _load: Promise; /** Cross origin value to use */ - private _crossorigin?: boolean|string; + private _crossorigin?: boolean | string; /** * @param sourceBase64 - Base64 encoded SVG element or URL for SVG file. @@ -168,9 +167,8 @@ export class SVGResource extends BaseImageResource /** * Get size from an svg string using a regular expression. - * * @param svgString - a serialized svg element - * @return - image extension + * @returns - image extension */ static getSize(svgString?: string): ISize { @@ -196,10 +194,9 @@ export class SVGResource extends BaseImageResource /** * Used to auto-detect the type of resource. - * * @param {*} source - The source object * @param {string} extension - The extension of source, if set - * @return {boolean} - If the source is a SVG source or data file + * @returns {boolean} - If the source is a SVG source or data file */ static test(source: unknown, extension?: string): boolean { @@ -213,7 +210,6 @@ export class SVGResource extends BaseImageResource /** * Regular expression for SVG XML document. - * * @example <?xml version="1.0" encoding="utf-8" ?><!-- image/svg --><svg * @readonly */ @@ -221,7 +217,6 @@ export class SVGResource extends BaseImageResource /** * Regular expression for SVG size. - * * @example <svg width="100" height="100"></svg> * @readonly */ diff --git a/packages/core/src/textures/resources/VideoResource.ts b/packages/core/src/textures/resources/VideoResource.ts index 705e2dd7fe..96763b1cd3 100644 --- a/packages/core/src/textures/resources/VideoResource.ts +++ b/packages/core/src/textures/resources/VideoResource.ts @@ -8,7 +8,7 @@ export interface IVideoResourceOptions autoLoad?: boolean; autoPlay?: boolean; updateFPS?: number; - crossorigin?: boolean|string; + crossorigin?: boolean | string; } export interface IVideoResourceOptionsElement @@ -19,7 +19,6 @@ export interface IVideoResourceOptionsElement /** * Resource type for {@code HTMLVideoElement}. - * * @memberof PIXI */ export class VideoResource extends BaseImageResource @@ -29,14 +28,12 @@ export class VideoResource extends BaseImageResource /** * `true` to use PIXI.Ticker.shared to auto update the base texture. - * * @default true */ protected _autoUpdate: boolean; /** * `true` if the instance is currently connected to PIXI.Ticker.shared to auto update the base texture. - * * @default false */ protected _isConnectedToTicker: boolean; @@ -46,14 +43,12 @@ export class VideoResource extends BaseImageResource /** * When set to true will automatically play videos used by this texture once * they are loaded. If false, it will not modify the playing state. - * * @default true */ protected autoPlay: boolean; /** * Promise when loading. - * * @default null */ private _load: Promise; @@ -70,7 +65,9 @@ export class VideoResource extends BaseImageResource * Leave at 0 to update at every render. * @param {boolean} [options.crossorigin=true] - Load image using cross origin */ - constructor(source?: HTMLVideoElement|Array|string, options?: IVideoResourceOptions) + constructor( + source?: HTMLVideoElement | Array | string, options?: IVideoResourceOptions + ) { options = options || {}; @@ -142,8 +139,7 @@ export class VideoResource extends BaseImageResource /** * Trigger updating of the texture. - * - * @param deltaTime - time delta since last tick + * @param _deltaTime - time delta since last tick */ update(_deltaTime = 0): void { @@ -163,8 +159,7 @@ export class VideoResource extends BaseImageResource /** * Start preloading the video resource. - * - * @return {Promise} Handle the validate event + * @returns {Promise} Handle the validate event */ load(): Promise { @@ -212,7 +207,10 @@ export class VideoResource extends BaseImageResource return this._load; } - /** Handle video error events. */ + /** + * Handle video error events. + * @param event + */ private _onError(event: ErrorEvent): void { (this.source as HTMLVideoElement).removeEventListener('error', this._onError, true); @@ -221,8 +219,7 @@ export class VideoResource extends BaseImageResource /** * Returns true if the underlying source is playing. - * - * @return - True if playing. + * @returns - True if playing. */ private _isSourcePlaying(): boolean { @@ -233,8 +230,7 @@ export class VideoResource extends BaseImageResource /** * Returns true if the underlying source is ready for playing. - * - * @return - True if ready. + * @returns - True if ready. */ private _isSourceReady(): boolean { @@ -363,10 +359,9 @@ export class VideoResource extends BaseImageResource /** * Used to auto-detect the type of resource. - * * @param {*} source - The source object * @param {string} extension - The extension of source, if set - * @return {boolean} `true` if video source + * @returns {boolean} `true` if video source */ static test(source: unknown, extension?: string): source is HTMLVideoElement { @@ -376,14 +371,12 @@ export class VideoResource extends BaseImageResource /** * List of common video file extensions supported by VideoResource. - * * @readonly */ static TYPES: Array = ['mp4', 'm4v', 'webm', 'ogg', 'ogv', 'h264', 'avi', 'mov']; /** * Map of video MIME types that can't be directly derived from file extensions. - * * @readonly */ static MIME_TYPES: Dict = { diff --git a/packages/core/src/textures/resources/autoDetectResource.ts b/packages/core/src/textures/resources/autoDetectResource.ts index dbf90a3bc3..580aba4b76 100644 --- a/packages/core/src/textures/resources/autoDetectResource.ts +++ b/packages/core/src/textures/resources/autoDetectResource.ts @@ -15,15 +15,14 @@ export type IResourcePluginOptions = { [key: string]: any }; * All allowable options for autoDetectResource */ export type IAutoDetectOptions = ISize - | ICubeResourceOptions - | IImageResourceOptions - | ISVGResourceOptions - | IVideoResourceOptions - | IResourcePluginOptions; +| ICubeResourceOptions +| IImageResourceOptions +| ISVGResourceOptions +| IVideoResourceOptions +| IResourcePluginOptions; /** * Shape of supported resource plugins - * * @memberof PIXI */ export interface IResourcePlugin @@ -52,7 +51,6 @@ export interface IResourcePlugin * } * // Install the new resource type * PIXI.INSTALLED.push(CustomResource); - * * @memberof PIXI * @type {Array} * @static @@ -88,7 +86,7 @@ export const INSTALLED: Array> = []; * @param {boolean} [options.autoPlay=true] - Video option to start playing video immediately * @param {number} [options.updateFPS=0] - Video option to update how many times a second the * texture should be updated from the video. Leave at 0 to update at every render - * @return {PIXI.Resource} The created resource. + * @returns {PIXI.Resource} The created resource. */ export function autoDetectResource(source: unknown, options?: RO): R { diff --git a/packages/core/src/textures/utils/mapTypeAndFormatToInternalFormat.ts b/packages/core/src/textures/utils/mapTypeAndFormatToInternalFormat.ts index dde0c3f738..74577faf21 100644 --- a/packages/core/src/textures/utils/mapTypeAndFormatToInternalFormat.ts +++ b/packages/core/src/textures/utils/mapTypeAndFormatToInternalFormat.ts @@ -2,15 +2,14 @@ import { FORMATS, TYPES } from '@pixi/constants'; /** * Returns a lookup table that maps each type-format pair to a compatible internal format. - * * @memberof PIXI * @function mapTypeAndFormatToInternalFormat * @private * @param {WebGLRenderingContext} gl - The rendering context. - * @return {{ [type: number]: { [format: number]: number } }} Lookup table. + * @returns Lookup table. */ export function mapTypeAndFormatToInternalFormat(gl: WebGLRenderingContextBase): - { [type: number]: { [format: number]: number } } +{ [type: number]: { [format: number]: number } } { let table; diff --git a/packages/core/src/utils/Quad.ts b/packages/core/src/utils/Quad.ts index 1aa1de3843..e5f692931e 100644 --- a/packages/core/src/utils/Quad.ts +++ b/packages/core/src/utils/Quad.ts @@ -2,7 +2,6 @@ import { Geometry } from '../geometry/Geometry'; /** * Helper class to create a quad - * * @memberof PIXI */ export class Quad extends Geometry diff --git a/packages/core/src/utils/QuadUv.ts b/packages/core/src/utils/QuadUv.ts index eb4ef0a745..f55bcd5870 100644 --- a/packages/core/src/utils/QuadUv.ts +++ b/packages/core/src/utils/QuadUv.ts @@ -5,7 +5,6 @@ import type { Rectangle } from '@pixi/math'; /** * Helper class to create a quad with uvs like in v4 - * * @memberof PIXI */ export class QuadUv extends Geometry @@ -47,10 +46,9 @@ export class QuadUv extends Geometry /** * Maps two Rectangle to the quad. - * * @param targetTextureFrame - The first rectangle * @param destinationFrame - The second rectangle - * @return - Returns itself. + * @returns - Returns itself. */ map(targetTextureFrame: Rectangle, destinationFrame: Rectangle): this { @@ -91,7 +89,6 @@ export class QuadUv extends Geometry /** * Legacy upload method, just marks buffers dirty. - * * @returns - Returns itself. */ invalidate(): this diff --git a/packages/core/test/ArrayResource.tests.ts b/packages/core/test/ArrayResource.tests.ts index 9c8826ef65..bf5719a31b 100644 --- a/packages/core/test/ArrayResource.tests.ts +++ b/packages/core/test/ArrayResource.tests.ts @@ -1,17 +1,20 @@ -import { ArrayResource, ImageResource } from '@pixi/core'; +import { ArrayResource, BaseTexture, ImageResource } from '@pixi/core'; import { join } from 'path'; import sinon from 'sinon'; import { expect } from 'chai'; -describe('ArrayResource', function () +describe('ArrayResource', () => { - before(function () + let basePath: string; + let imageUrl: string; + + before(() => { - this.basePath = join(__dirname, 'resources'); - this.imageUrl = join(this.basePath, 'slug.png'); + basePath = join(__dirname, 'resources'); + imageUrl = join(basePath, 'slug.png'); }); - it('should create new resource by length', function () + it('should create new resource by length', () => { const resource = new ArrayResource(5, { width: 100, height: 100 }); @@ -19,40 +22,40 @@ describe('ArrayResource', function () expect(resource.destroyed).to.be.true; }); - it('should error on out of bound', function () + it('should error on out of bound', () => { const resource = new ArrayResource(5, { width: 100, height: 100 }); - const image = new ImageResource(this.imageUrl); + const image = new ImageResource(imageUrl); expect(() => resource.addResourceAt(image, 10)).to.throw(Error, /out of bounds/); resource.destroy(); }); - it('should load array of URL resources', function () + it('should load array of URL resources', () => { const images = [ - this.imageUrl, - this.imageUrl, - this.imageUrl, - this.imageUrl, + imageUrl, + imageUrl, + imageUrl, + imageUrl, ]; const resource = new ArrayResource(images, { width: 100, height: 100, - autoLoad: false, }); const baseTexture = { setRealSize: sinon.stub(), update: sinon.stub(), - }; + } as unknown as BaseTexture; resource.bind(baseTexture); return resource.load().then((res) => { expect(res).to.equal(resource); + // @ts-expect-error - issue with sinon typings expect(baseTexture.setRealSize.calledOnce).to.be.true; for (let i = 0; i < images.length; i++) { diff --git a/packages/core/test/BaseTexture.tests.ts b/packages/core/test/BaseTexture.tests.ts index bafee3bf39..a107a2c990 100644 --- a/packages/core/test/BaseTexture.tests.ts +++ b/packages/core/test/BaseTexture.tests.ts @@ -18,12 +18,12 @@ function cleanCache() delete TextureCache[NAME2]; } -describe('BaseTexture', function () +describe('BaseTexture', () => { /* - describe('updateImageType', function () + describe('updateImageType', () => { - it('should allow no extension', function () + it('should allow no extension', () => { cleanCache(); @@ -36,15 +36,19 @@ describe('BaseTexture', function () }); }); */ + interface PixiCanvas extends HTMLCanvasElement + { + _pixiId: string; + } - it('should handle invalid image URL for textures', function (done) + it('should handle invalid image URL for textures', (done) => { cleanCache(); const invalidFile = 'missing-image.png'; const baseTexture = BaseTexture.from(invalidFile); - baseTexture.once('error', function (baseTexture, event) + baseTexture.once('error', (baseTexture, event) => { expect(baseTexture.resource).to.be.instanceof(ImageResource); expect(baseTexture.resource.url).contains(invalidFile); @@ -54,14 +58,14 @@ describe('BaseTexture', function () }); }); - it('should handle invalid svg URL for textures', function (done) + it('should handle invalid svg URL for textures', (done) => { cleanCache(); const invalidFile = 'missing-image.svg'; const baseTexture = BaseTexture.from(invalidFile); - baseTexture.once('error', function (baseTexture, event) + baseTexture.once('error', (baseTexture, event) => { expect(baseTexture.resource).to.be.instanceof(SVGResource); expect(baseTexture.resource.svg).contains(invalidFile); @@ -71,14 +75,14 @@ describe('BaseTexture', function () }); }); - it('should handle invalid video URL for textures', function (done) + it('should handle invalid video URL for textures', (done) => { cleanCache(); const invalidFile = 'missing-image.mp4'; const baseTexture = BaseTexture.from(invalidFile); - baseTexture.once('error', function (baseTexture, event) + baseTexture.once('error', (baseTexture, event) => { expect(baseTexture.resource).to.be.instanceof(VideoResource); expect(baseTexture.resource.source.firstChild.src).contains(invalidFile); @@ -88,11 +92,11 @@ describe('BaseTexture', function () }); }); - it('should use pixiIdPrefix correctly', function () + it('should use pixiIdPrefix correctly', () => { cleanCache(); - const canvas = document.createElement('canvas'); + const canvas = document.createElement('canvas') as PixiCanvas; const baseTexture = BaseTexture.from(canvas, { pixiIdPrefix: 'unittest' }); const _pixiId = canvas._pixiId; @@ -101,11 +105,11 @@ describe('BaseTexture', function () expect(BaseTextureCache[_pixiId]).to.equal(baseTexture); }); - it('should remove Canvas BaseTexture from cache on destroy', function () + it('should remove Canvas BaseTexture from cache on destroy', () => { cleanCache(); - const canvas = document.createElement('canvas'); + const canvas = document.createElement('canvas') as PixiCanvas; const baseTexture = BaseTexture.from(canvas); const _pixiId = canvas._pixiId; @@ -116,7 +120,7 @@ describe('BaseTexture', function () expect(BaseTextureCache[_pixiId]).to.equal(undefined); }); - it('should remove Image BaseTexture from cache on destroy', function (done) + it('should remove Image BaseTexture from cache on destroy', (done) => { cleanCache(); @@ -139,7 +143,7 @@ describe('BaseTexture', function () }); }); - it('should remove BaseTexture from entire cache using removeFromCache (by BaseTexture instance)', function () + it('should remove BaseTexture from entire cache using removeFromCache (by BaseTexture instance)', () => { cleanCache(); @@ -158,7 +162,7 @@ describe('BaseTexture', function () expect(BaseTextureCache[NAME2]).to.equal(undefined); }); - it('should remove BaseTexture from single cache entry using removeFromCache (by id)', function () + it('should remove BaseTexture from single cache entry using removeFromCache (by id)', () => { cleanCache(); @@ -177,7 +181,7 @@ describe('BaseTexture', function () expect(BaseTextureCache[NAME2]).to.equal(baseTexture); }); - it('should not throw an error destroying a destroyed BaseTexture', function () + it('should not throw an error destroying a destroyed BaseTexture', () => { const baseTexture = new BaseTexture(); @@ -185,7 +189,7 @@ describe('BaseTexture', function () baseTexture.destroy(); }); - it('should update width and height', function () + it('should update width and height', () => { const canvas = document.createElement('canvas'); @@ -200,7 +204,7 @@ describe('BaseTexture', function () baseTexture.destroy(); }); - it('should set source.crossOrigin to anonymous if explicitly set', function () + it('should set source.crossOrigin to anonymous if explicitly set', () => { cleanCache(); @@ -209,14 +213,15 @@ describe('BaseTexture', function () }); const baseTexture = new BaseTexture(imageResource); + const source = (baseTexture.resource as ImageResource).source as HTMLImageElement; - expect(baseTexture.resource.source.crossOrigin).to.equal('anonymous'); + expect(source.crossOrigin).to.equal('anonymous'); baseTexture.destroy(); imageResource.destroy(); }); - it('should not destroy externally created resources', function () + it('should not destroy externally created resources', () => { cleanCache(); @@ -233,7 +238,7 @@ describe('BaseTexture', function () expect(imageResource.destroyed).to.be.true; }); - it('should destroy internally created resources', function () + it('should destroy internally created resources', () => { cleanCache(); @@ -246,7 +251,7 @@ describe('BaseTexture', function () expect(baseTexture.destroyed).to.be.true; }); - it('should show correct width/height after setResolution', function () + it('should show correct width/height after setResolution', () => { const texture = RenderTexture.create({ width: 15, height: 15 }); @@ -255,7 +260,7 @@ describe('BaseTexture', function () expect(texture.baseTexture.realHeight).to.equal(15); }); - it('should throw and error in strict from mode', function () + it('should throw and error in strict from mode', () => { const id = 'baz'; diff --git a/packages/core/test/BatchRenderer.tests.ts b/packages/core/test/BatchRenderer.tests.ts index 30b125c04c..163f8f3401 100644 --- a/packages/core/test/BatchRenderer.tests.ts +++ b/packages/core/test/BatchRenderer.tests.ts @@ -1,4 +1,4 @@ -import { Renderer, BatchRenderer, CanvasResource, Texture, BaseTexture } from '@pixi/core'; +import { Renderer, BatchRenderer, CanvasResource, Texture, BaseTexture, IBatchableElement } from '@pixi/core'; import { skipHello } from '@pixi/utils'; import { BLEND_MODES } from '@pixi/constants'; import sinon from 'sinon'; @@ -6,9 +6,9 @@ import { expect } from 'chai'; skipHello(); -describe('BatchRenderer', function () +describe('BatchRenderer', () => { - function createTexture(w, h) + function createTexture(w: number, h: number) { const canvas = document.createElement('canvas'); const context = canvas.getContext('2d'); @@ -35,13 +35,13 @@ describe('BatchRenderer', function () const tint2 = 0xffff00; const tint3 = 0x00ffff; - it('should pass the batching test', function () + it('should pass the batching test', () => { const renderer = new Renderer({ width: 1, height: 1 }); const batchRenderer = new BatchRenderer(renderer); - const drawCalls = []; + const drawCalls = [] as number[]; - renderer.gl.drawElements = (type, size, indexType, start) => + renderer.gl.drawElements = (_type, size, _indexType, start) => { drawCalls.push(start, size); }; @@ -58,8 +58,8 @@ describe('BatchRenderer', function () _tintRGB: tint2, worldAlpha: 1.0, _texture: new Texture(tex1), blendMode: 0 }, { uvs, vertexData, indices, _tintRGB: tint3, worldAlpha: 1.0, _texture: new Texture(tex2), blendMode: 0 }, { uvs, vertexData, indices, _tintRGB: tint1, worldAlpha: 0.5, _texture: new Texture(tex4), blendMode: 0 }, - ]; - const nullArray = [null, null, null, null, null, null, null, null]; + ] as unknown as IBatchableElement[]; + const nullArray = [null, null, null, null, null, null, null, null] as null[]; try { @@ -68,13 +68,13 @@ describe('BatchRenderer', function () batchRenderer.MAX_TEXTURES = 2; batchRenderer.start(); elements.forEach((element) => batchRenderer.render(element)); - expect(batchRenderer._bufferedElements.length).to.equal(8); - expect(batchRenderer._bufferedTextures.length).to.equal(8); + expect(batchRenderer['_bufferedElements'].length).to.equal(8); + expect(batchRenderer['_bufferedTextures'].length).to.equal(8); batchRenderer.flush(); - expect(batchRenderer._bufferedElements).to.eql(nullArray); - expect(batchRenderer._bufferedTextures).to.eql(nullArray); + expect(batchRenderer['_bufferedElements']).to.eql(nullArray); + expect(batchRenderer['_bufferedTextures']).to.eql(nullArray); - const attrCount = batchRenderer._aIndex; + const attrCount = batchRenderer['_aIndex']; // first number is start * 2, second is size expect(drawCalls).to.eql([0, 18, 36, 6, 48, 11, 70, 12]); @@ -120,11 +120,11 @@ describe('BatchRenderer', function () 0, 1, 2, 0, 2, 3, 4, 5, 6, 4, 6, 7, 8, 9, 10, 8, 10, 11, 12, 13, 14, 12, 14, 15, 16, 17, 18, 16, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 25, 27, 28, 29, 30, 31, 29, 31, 32, ]; - const resultAttr = []; - const resultInd = []; + const resultAttr: number[] = []; + const resultInd: number[] = []; - batchRenderer._attributeBuffer.uint32View.slice(0, 198).forEach((x) => { resultAttr.push(x); }); - batchRenderer._indexBuffer.slice(0, 47).forEach((x) => { resultInd.push(x); }); + batchRenderer['_attributeBuffer'].uint32View.slice(0, 198).forEach((x) => { resultAttr.push(x); }); + batchRenderer['_indexBuffer'].slice(0, 47).forEach((x) => { resultInd.push(x); }); expect(resultAttr).to.eql(attr); expect(resultInd).to.eql(ind); @@ -136,7 +136,7 @@ describe('BatchRenderer', function () } }); - it('should ask StateSystem to call gl.disable(gl.BLEND) if sprite has BLEND_MODES.NONE', function () + it('should ask StateSystem to call gl.disable(gl.BLEND) if sprite has BLEND_MODES.NONE', () => { const renderer = new Renderer({ width: 1, height: 1 }); const batchRenderer = new BatchRenderer(renderer); @@ -147,7 +147,7 @@ describe('BatchRenderer', function () blendMode: BLEND_MODES.NONE }, { uvs, vertexData, indices, _tintRGB: tint1, worldAlpha: 0.5, _texture: new Texture(tex1), blendMode: BLEND_MODES.NORMAL }, - ]; + ] as unknown as IBatchableElement[]; try { diff --git a/packages/core/test/CanvasResource.tests.ts b/packages/core/test/CanvasResource.tests.ts index ef64620c17..cb75a67919 100644 --- a/packages/core/test/CanvasResource.tests.ts +++ b/packages/core/test/CanvasResource.tests.ts @@ -2,9 +2,9 @@ import { CanvasResource, BaseTexture } from '@pixi/core'; import sinon from 'sinon'; import { expect } from 'chai'; -describe('CanvasResource', function () +describe('CanvasResource', () => { - it('should create new dimension-less resource', function () + it('should create new dimension-less resource', () => { const canvas = document.createElement('canvas'); @@ -17,7 +17,7 @@ describe('CanvasResource', function () resource.destroy(); }); - it('should create new valid resource', function () + it('should create new valid resource', () => { const canvas = document.createElement('canvas'); @@ -33,27 +33,27 @@ describe('CanvasResource', function () resource.destroy(); }); - it('should fire resize event on bind', function () + it('should fire resize event on bind', () => { const canvas = document.createElement('canvas'); const resource = new CanvasResource(canvas); const baseTexture = { setRealSize: sinon.stub() }; - resource.bind(baseTexture); + resource.bind(baseTexture as unknown as BaseTexture); expect(baseTexture.setRealSize.calledOnce).to.be.true; - resource.unbind(baseTexture); + resource.unbind(baseTexture as unknown as BaseTexture); resource.destroy(); }); - it('should fire manual update event', function () + it('should fire manual update event', () => { const canvas = document.createElement('canvas'); const resource = new CanvasResource(canvas); const baseTexture = { update: sinon.stub() }; - resource.bind(baseTexture); + resource.bind(baseTexture as unknown as BaseTexture); expect(baseTexture.update.called).to.be.false; @@ -61,11 +61,11 @@ describe('CanvasResource', function () expect(baseTexture.update.calledOnce).to.be.true; - resource.unbind(baseTexture); + resource.unbind(baseTexture as unknown as BaseTexture); resource.destroy(); }); - it('should change BaseTexture size on update', function () + it('should change BaseTexture size on update', () => { const canvas = document.createElement('canvas'); diff --git a/packages/core/test/CubeResource.tests.ts b/packages/core/test/CubeResource.tests.ts index 842622c9e6..a0a7bd0c18 100644 --- a/packages/core/test/CubeResource.tests.ts +++ b/packages/core/test/CubeResource.tests.ts @@ -2,24 +2,27 @@ import { CubeResource, BaseTexture } from '@pixi/core'; import path from 'path'; import { expect } from 'chai'; -describe('CubeResource', function () +describe('CubeResource', () => { - before(function () + let baseTexUrl: string; + + before(() => { - this.baseTexUrl = path.resolve(__dirname, 'resources', 'slug.png'); + baseTexUrl = path.resolve(__dirname, 'resources', 'slug.png'); }); - it('should create invalid length resource', function () + it('should create invalid length resource', () => { expect(() => { + // @ts-expect-error - using an invalid length // eslint-disable-next-line no-new new CubeResource([null, null, null, null, null, null, null, null]); }).to.throw(Error, /invalid length/i); }); - it('should be created through BaseTexture.from()', function () + it('should be created through BaseTexture.from()', () => { - const path1 = this.baseTexUrl; + const path1 = baseTexUrl; const baseTex = BaseTexture.from([path1, path1, path1, path1, path1, path1]); expect(baseTex.resource).to.be.instanceof(CubeResource); diff --git a/packages/core/test/FilterSystem.tests.ts b/packages/core/test/FilterSystem.tests.ts index f065f97627..9d6b1c4650 100644 --- a/packages/core/test/FilterSystem.tests.ts +++ b/packages/core/test/FilterSystem.tests.ts @@ -1,12 +1,12 @@ -import { CLEAR_MODES, BLEND_MODES } from '@pixi/constants'; -import { Rectangle, Matrix } from '@pixi/math'; -import { Renderer, Filter } from '@pixi/core'; -import sinon from 'sinon'; +import { CLEAR_MODES } from '@pixi/constants'; +import { Filter, IFilterTarget, Renderer } from '@pixi/core'; +import { Matrix, Rectangle } from '@pixi/math'; import { expect } from 'chai'; +import sinon from 'sinon'; -describe('FilterSystem', function () +describe('FilterSystem', () => { - function onePixelObject(worldTransform, size = 1) + function onePixelObject(worldTransform?: Matrix, size = 1) { const mat = worldTransform || Matrix.IDENTITY; @@ -15,27 +15,29 @@ describe('FilterSystem', function () worldTransform: mat, getBounds() { return new Rectangle(mat.tx, mat.ty, size, size); }, render() { /* nothing*/ }, - }; + } as unknown as IFilterTarget; } - before(function () + let renderer: Renderer; + + before(() => { - this.renderer = new Renderer(); + renderer = new Renderer(); }); - after(function () + after(() => { - this.renderer.destroy(); - this.renderer = null; + renderer.destroy(); + renderer = null; }); - it('should support clearMode', function () + it('should support clearMode', () => { const innerFilter = new Filter(); const filter = new Filter(); - const clearSpy = sinon.spy(this.renderer.framebuffer, 'clear'); + const clearSpy = sinon.spy(renderer.framebuffer, 'clear'); const obj = onePixelObject(); - const filterSystem = this.renderer.filter; + const filterSystem = renderer.filter; innerFilter.state.blend = false; @@ -52,7 +54,7 @@ describe('FilterSystem', function () let prevCalls = 0; - function render(clearMode, forceClear) + function render(clearMode: CLEAR_MODES, forceClear: boolean) { clearModeValue = clearMode; filterSystem.forceClear = forceClear; @@ -81,15 +83,14 @@ describe('FilterSystem', function () expect(filterSystem.texturePool.texturePool[65537].length).to.equal(2); }); - function rectToString(rect) + function rectToString(rect: Rectangle) { return `(${rect.x}, ${rect.y}, ${rect.width}, ${rect.height})`; } - it('should account autoFit for global projection transform and rounding', function () + it('should account autoFit for global projection transform and rounding', () => { const obj = onePixelObject(new Matrix().translate(20, 10), 10); - const { renderer } = this; const src = new Rectangle(9, 10, 100, 100); const dst = new Rectangle(0, 0, 50, 50); const trans = new Matrix().translate(-14, -5); @@ -125,13 +126,12 @@ describe('FilterSystem', function () renderer.projection.transform = null; }); - it('should round the source frame in screen space even when rotated by 90°', function () + it('should round the source frame in screen space even when rotated by 90°', () => { const obj = { getBounds() { return new Rectangle(0.1, 0.1, 100, 100); }, render() { /* Mock */ }, - }; - const { renderer } = this; + } as unknown as IFilterTarget; const src = new Rectangle(0, 0, 101, 101); const dst = new Rectangle(0, 0, 50, 50); const transform = new Matrix() @@ -147,7 +147,6 @@ describe('FilterSystem', function () renderer.filter.push(obj, filters); const newSrc = renderer.projection.sourceFrame; - const newDst = renderer.projection.destinationFrame; // Coords are shifted by 2x (0.1, 0.1) expect(newSrc.x).to.be.closeTo(-0.9, 1e-5); diff --git a/packages/core/test/FramebufferSystem.tests.ts b/packages/core/test/FramebufferSystem.tests.ts index 0d2cc8e967..8ecb1bbc12 100644 --- a/packages/core/test/FramebufferSystem.tests.ts +++ b/packages/core/test/FramebufferSystem.tests.ts @@ -3,76 +3,78 @@ import { MSAA_QUALITY } from '@pixi/constants'; import { Rectangle } from '@pixi/math'; import { expect } from 'chai'; -describe('FramebufferSystem', function () +describe('FramebufferSystem', () => { - before(function () + let renderer: Renderer; + + before(() => { - this.renderer = new Renderer(); + renderer = new Renderer(); }); - after(function () + after(() => { - this.renderer.destroy(); - this.renderer = null; + renderer.destroy(); + renderer = null; }); - it('should choose correct AA samples based on samples array', function () + it('should choose correct AA samples based on samples array', () => { - const { framebuffer } = this.renderer; + const { framebuffer } = renderer; // chrome, general - framebuffer.msaaSamples = [8, 4, 1]; - expect(framebuffer.detectSamples(1)).to.equal(0); - expect(framebuffer.detectSamples(4)).to.equal(4); - expect(framebuffer.detectSamples(8)).to.equal(8); + framebuffer['msaaSamples'] = [8, 4, 1]; + expect(framebuffer['detectSamples'](1)).to.equal(0); + expect(framebuffer['detectSamples'](4)).to.equal(4); + expect(framebuffer['detectSamples'](8)).to.equal(8); // some mobile devices - framebuffer.msaaSamples = [4, 1]; - expect(framebuffer.detectSamples(8)).to.equal(4); + framebuffer['msaaSamples'] = [4, 1]; + expect(framebuffer['detectSamples'](8)).to.equal(4); // firefox on mac - framebuffer.msaaSamples = [8, 4]; - expect(framebuffer.detectSamples(1)).to.equal(0); + framebuffer['msaaSamples'] = [8, 4]; + expect(framebuffer['detectSamples'](1)).to.equal(0); // no MSAA - framebuffer.msaaSamples = null; - expect(framebuffer.detectSamples(8)).to.equal(0); + framebuffer['msaaSamples'] = null; + expect(framebuffer['detectSamples'](8)).to.equal(0); }); - it('should render to mip levels', function () + it('should render to mip levels', () => { - const { gl, CONTEXT_UID } = this.renderer; + const { gl, CONTEXT_UID } = renderer; const framebuffer = new Framebuffer(4, 4); - this.renderer.framebuffer.bind(framebuffer, null, 1); + renderer.framebuffer.bind(framebuffer, null, 1); expect(framebuffer.glFramebuffers[CONTEXT_UID].mipLevel).to.equal(1); expect(Array.from(gl.getParameter(gl.VIEWPORT))).to.deep.equal([0, 0, 2, 2]); - this.renderer.framebuffer.bind(framebuffer, null, 0); + renderer.framebuffer.bind(framebuffer, null, 0); expect(framebuffer.glFramebuffers[CONTEXT_UID].mipLevel).to.equal(0); expect(Array.from(gl.getParameter(gl.VIEWPORT))).to.deep.equal([0, 0, 4, 4]); }); - it('should render to with correct frame', function () + it('should render to with correct frame', () => { - const { gl, CONTEXT_UID } = this.renderer; + const { gl } = renderer; const framebuffer = new Framebuffer(4, 4); const frame = new Rectangle(2, 2, 2, 2); - this.renderer.framebuffer.bind(framebuffer, frame, 0); + renderer.framebuffer.bind(framebuffer, frame, 0); expect(Array.from(gl.getParameter(gl.VIEWPORT))).to.deep.equal([2, 2, 2, 2]); }); - it('should create an incomplete framebuffer if it has no attachments', function () + it('should create an incomplete framebuffer if it has no attachments', () => { - this.renderer.framebuffer.contextChange(); + renderer.framebuffer['contextChange'](); - const { gl, CONTEXT_UID } = this.renderer; + const { gl } = renderer; const framebuffer = new Framebuffer(4, 4); @@ -80,16 +82,16 @@ describe('FramebufferSystem', function () framebuffer.stencil = false; framebuffer.multisample = MSAA_QUALITY.NONE; - this.renderer.framebuffer.bind(framebuffer); + renderer.framebuffer.bind(framebuffer); expect(gl.checkFramebufferStatus(gl.FRAMEBUFFER)).to.equal(gl.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT); }); - it('should create a complete framebuffer with a color texture attachment', function () + it('should create a complete framebuffer with a color texture attachment', () => { - this.renderer.framebuffer.contextChange(); + renderer.framebuffer['contextChange'](); - const { gl, CONTEXT_UID } = this.renderer; + const { gl, CONTEXT_UID } = renderer; const framebuffer = new Framebuffer(4, 4); @@ -98,7 +100,7 @@ describe('FramebufferSystem', function () framebuffer.multisample = MSAA_QUALITY.NONE; framebuffer.addColorTexture(0); - this.renderer.framebuffer.bind(framebuffer); + renderer.framebuffer.bind(framebuffer); const fbo = framebuffer.glFramebuffers[CONTEXT_UID]; @@ -108,18 +110,19 @@ describe('FramebufferSystem', function () expect(fbo.stencil).to.be.null; }); + // eslint-disable-next-line func-names it('should create a complete framebuffer with depth/stencil attachment', function () { - this.renderer.framebuffer.contextChange(); + renderer.framebuffer['contextChange'](); - if (this.renderer.context.webGLVersion === 1 - || this.renderer.framebuffer.msaaSamples === null - || this.renderer.framebuffer.msaaSamples.every((x) => x <= 1)) + if (renderer.context.webGLVersion === 1 + || renderer.framebuffer['msaaSamples'] === null + || renderer.framebuffer['msaaSamples'].every((x) => x <= 1)) { this.skip(); } - const { gl, CONTEXT_UID } = this.renderer; + const { gl, CONTEXT_UID } = renderer; const framebuffer = new Framebuffer(4, 4); @@ -127,7 +130,7 @@ describe('FramebufferSystem', function () framebuffer.stencil = true; framebuffer.multisample = MSAA_QUALITY.NONE; - this.renderer.framebuffer.bind(framebuffer); + renderer.framebuffer.bind(framebuffer); const fbo = framebuffer.glFramebuffers[CONTEXT_UID]; @@ -141,17 +144,18 @@ describe('FramebufferSystem', function () expect(gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_SAMPLES)).to.equal(fbo.multisample); }); + // eslint-disable-next-line func-names it('should create a complete multisampled framebuffer', function () { - this.renderer.framebuffer.contextChange(); + renderer.framebuffer['contextChange'](); - if (this.renderer.context.webGLVersion === 1 - || this.renderer.framebuffer.msaaSamples === null - || this.renderer.framebuffer.msaaSamples.every((x) => x <= 1)) + if (renderer.context.webGLVersion === 1 + || renderer.framebuffer['msaaSamples'] === null + || renderer.framebuffer['msaaSamples'].every((x) => x <= 1)) { this.skip(); } - const { gl, CONTEXT_UID } = this.renderer; + const { gl, CONTEXT_UID } = renderer; const framebuffer = new Framebuffer(4, 4); @@ -159,7 +163,7 @@ describe('FramebufferSystem', function () framebuffer.stencil = false; framebuffer.multisample = MSAA_QUALITY.HIGH; - this.renderer.framebuffer.bind(framebuffer); + renderer.framebuffer.bind(framebuffer); const fbo = framebuffer.glFramebuffers[CONTEXT_UID]; @@ -173,18 +177,19 @@ describe('FramebufferSystem', function () expect(gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_SAMPLES)).to.equal(fbo.multisample); }); + // eslint-disable-next-line func-names it('should create a complete multisampled framebuffer with depth/stencil attachment', function () { - this.renderer.framebuffer.contextChange(); + renderer.framebuffer['contextChange'](); - if (this.renderer.context.webGLVersion === 1 - || this.renderer.framebuffer.msaaSamples === null - || this.renderer.framebuffer.msaaSamples.every((x) => x <= 1)) + if (renderer.context.webGLVersion === 1 + || renderer.framebuffer['msaaSamples'] === null + || renderer.framebuffer['msaaSamples'].every((x) => x <= 1)) { this.skip(); } - const { gl, CONTEXT_UID } = this.renderer; + const { gl, CONTEXT_UID } = renderer; const framebuffer = new Framebuffer(4, 4); @@ -192,7 +197,7 @@ describe('FramebufferSystem', function () framebuffer.stencil = true; framebuffer.multisample = MSAA_QUALITY.HIGH; - this.renderer.framebuffer.bind(framebuffer); + renderer.framebuffer.bind(framebuffer); const fbo = framebuffer.glFramebuffers[CONTEXT_UID]; @@ -211,11 +216,11 @@ describe('FramebufferSystem', function () }); it('should not create an incomplete framebuffer if it has multiple color attachments and multisampling is requested', - function () + () => { - this.renderer.framebuffer.contextChange(); + renderer.framebuffer['contextChange'](); - const { gl, CONTEXT_UID } = this.renderer; + const { gl, CONTEXT_UID } = renderer; const framebuffer = new Framebuffer(4, 4); @@ -225,7 +230,7 @@ describe('FramebufferSystem', function () framebuffer.addColorTexture(0); framebuffer.addColorTexture(1); - this.renderer.framebuffer.bind(framebuffer); + renderer.framebuffer.bind(framebuffer); const fbo = framebuffer.glFramebuffers[CONTEXT_UID]; @@ -235,16 +240,17 @@ describe('FramebufferSystem', function () }); it('should not create an incomplete framebuffer if it has depth texture and multisampling is requested', + // eslint-disable-next-line func-names function () { - this.renderer.framebuffer.contextChange(); + renderer.framebuffer['contextChange'](); - if (!this.renderer.framebuffer.writeDepthTexture) + if (!renderer.framebuffer.writeDepthTexture) { this.skip(); } - const { gl, CONTEXT_UID } = this.renderer; + const { gl, CONTEXT_UID } = renderer; const framebuffer = new Framebuffer(4, 4); @@ -253,7 +259,7 @@ describe('FramebufferSystem', function () framebuffer.multisample = MSAA_QUALITY.HIGH; framebuffer.addDepthTexture(); - this.renderer.framebuffer.bind(framebuffer); + renderer.framebuffer.bind(framebuffer); const fbo = framebuffer.glFramebuffers[CONTEXT_UID]; @@ -262,11 +268,11 @@ describe('FramebufferSystem', function () expect(fbo.stencil).to.be.null; }); - it('should succeed to resize framebuffer', function () + it('should succeed to resize framebuffer', () => { - this.renderer.framebuffer.contextChange(); + renderer.framebuffer['contextChange'](); - const { gl, CONTEXT_UID } = this.renderer; + const { gl, CONTEXT_UID } = renderer; const framebuffer = new Framebuffer(4, 8); @@ -274,7 +280,7 @@ describe('FramebufferSystem', function () framebuffer.stencil = true; framebuffer.multisample = MSAA_QUALITY.NONE; - this.renderer.framebuffer.bind(framebuffer); + renderer.framebuffer.bind(framebuffer); const fbo = framebuffer.glFramebuffers[CONTEXT_UID]; @@ -291,7 +297,7 @@ describe('FramebufferSystem', function () framebuffer.resize(16, 32); - this.renderer.framebuffer.bind(framebuffer); + renderer.framebuffer.bind(framebuffer); expect(gl.checkFramebufferStatus(gl.FRAMEBUFFER)).to.equal(gl.FRAMEBUFFER_COMPLETE); expect(fbo.multisample).to.equal(0); @@ -305,18 +311,19 @@ describe('FramebufferSystem', function () expect(gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_HEIGHT)).to.equal(32); }); + // eslint-disable-next-line func-names it('should succeed to resize multisampled framebuffer', function () { - this.renderer.framebuffer.contextChange(); + renderer.framebuffer['contextChange'](); - if (this.renderer.context.webGLVersion === 1 - || this.renderer.framebuffer.msaaSamples === null - || this.renderer.framebuffer.msaaSamples.every((x) => x <= 1)) + if (renderer.context.webGLVersion === 1 + || renderer.framebuffer['msaaSamples'] === null + || renderer.framebuffer['msaaSamples'].every((x) => x <= 1)) { this.skip(); } - const { gl, CONTEXT_UID } = this.renderer; + const { gl, CONTEXT_UID } = renderer; const framebuffer = new Framebuffer(4, 8); @@ -324,7 +331,7 @@ describe('FramebufferSystem', function () framebuffer.stencil = true; framebuffer.multisample = MSAA_QUALITY.HIGH; - this.renderer.framebuffer.bind(framebuffer); + renderer.framebuffer.bind(framebuffer); const fbo = framebuffer.glFramebuffers[CONTEXT_UID]; @@ -347,7 +354,7 @@ describe('FramebufferSystem', function () framebuffer.resize(16, 32); - this.renderer.framebuffer.bind(framebuffer); + renderer.framebuffer.bind(framebuffer); expect(gl.checkFramebufferStatus(gl.FRAMEBUFFER)).to.equal(gl.FRAMEBUFFER_COMPLETE); expect(fbo.multisample).to.be.greaterThan(1); diff --git a/packages/core/test/Geometry.tests.ts b/packages/core/test/Geometry.tests.ts index 317755e36c..01c9841080 100644 --- a/packages/core/test/Geometry.tests.ts +++ b/packages/core/test/Geometry.tests.ts @@ -30,15 +30,15 @@ void main() { gl_FragColor = texture2D(uSampler, vUvs); }`; -describe('Geometry', function () +describe('Geometry', () => { - it('should dispose shared index buffer after all geometries were disposed/destroyed', function () + it('should dispose shared index buffer after all geometries were disposed/destroyed', () => { const renderer = new Renderer({ width: 1, height: 1 }); try { - const indices = new Buffer([0, 1, 2, 0, 2, 3], true, true); + const indices = new Buffer(new Float32Array([0, 1, 2, 0, 2, 3]), true, true); const geometry1 = new Geometry(); const geometry2 = new Geometry(); const prog = new Program(vert, frag); @@ -66,13 +66,13 @@ describe('Geometry', function () } }); - it('should dispose buffer if geometry is used by two shaders', function () + it('should dispose buffer if geometry is used by two shaders', () => { const renderer = new Renderer({ width: 1, height: 1 }); try { - const indices = new Buffer([0, 1, 2, 0, 2, 3], true, true); + const indices = new Buffer(new Float32Array([0, 1, 2, 0, 2, 3]), true, true); const geometry = new Geometry(); const prog = new Program(vert, frag); const prog2 = new Program(vert2, frag); @@ -104,7 +104,7 @@ describe('Geometry', function () } }); - it('should correctly merge the index buffers of geometries with different length', function () + it('should correctly merge the index buffers of geometries with different length', () => { const geom0 = new Geometry() .addAttribute('aVertexPosition', [0, 0, 1, 1, 2, 2], 2) @@ -115,16 +115,16 @@ describe('Geometry', function () const geom = Geometry.merge([geom0, geom1]); - expect([...geom.getIndex().data]).to.have.members([0, 1, 2, 3, 4, 5, 6]); + expect([...(geom.getIndex().data) as unknown as number[]]).to.have.members([0, 1, 2, 3, 4, 5, 6]); }); - it('should create one VAO for shaders with the same attributes and same location specifiers', function () + it('should create one VAO for shaders with the same attributes and same location specifiers', () => { const renderer = new Renderer({ width: 1, height: 1 }); try { - const indices = new Buffer([0, 1, 2], true, true); + const indices = new Buffer(new Float32Array([0, 1, 2]), true, true); const prog1 = new Program(`\ #version 300 es @@ -175,11 +175,11 @@ describe('Geometry', function () renderer.geometry.bind(geometry, shader1); - const vao1 = renderer.geometry._activeVao; + const vao1 = renderer.geometry['_activeVao']; renderer.geometry.bind(geometry, shader2); - const vao2 = renderer.geometry._activeVao; + const vao2 = renderer.geometry['_activeVao']; expect(vao1).to.equal(vao2); @@ -191,13 +191,13 @@ describe('Geometry', function () } }); - it('should create different VAOs for shaders with the same attributes but different location specifiers', function () + it('should create different VAOs for shaders with the same attributes but different location specifiers', () => { const renderer = new Renderer({ width: 1, height: 1 }); try { - const indices = new Buffer([0, 1, 2], true, true); + const indices = new Buffer(new Float32Array([0, 1, 2]), true, true); const prog1 = new Program(`\ #version 300 es @@ -248,11 +248,11 @@ describe('Geometry', function () renderer.geometry.bind(geometry, shader1); - const vao1 = renderer.geometry._activeVao; + const vao1 = renderer.geometry['_activeVao']; renderer.geometry.bind(geometry, shader2); - const vao2 = renderer.geometry._activeVao; + const vao2 = renderer.geometry['_activeVao']; expect(vao1).to.not.equal(vao2); @@ -264,15 +264,16 @@ describe('Geometry', function () } }); - it('should create compatible VAOs if GeometrySystem.checkCompatibility is disabled', function () + it('should create compatible VAOs if GeometrySystem.checkCompatibility is disabled', () => { const renderer = new Renderer({ width: 1, height: 1 }); - renderer.geometry.checkCompatibility = function () {}; + // eslint-disable-next-line @typescript-eslint/no-empty-function + renderer.geometry['checkCompatibility'] = () => {}; try { - const indices = new Buffer([0, 1, 2], true, true); + const indices = new Buffer(new Float32Array([0, 1, 2]), true, true); const prog1 = new Program(`\ #version 100 @@ -317,11 +318,11 @@ describe('Geometry', function () renderer.geometry.bind(geometry, shader1); - const vao1 = renderer.geometry._activeVao; + const vao1 = renderer.geometry['_activeVao']; renderer.geometry.bind(geometry, shader2); - const vao2 = renderer.geometry._activeVao; + const vao2 = renderer.geometry['_activeVao']; expect(vao1).to.not.equal(vao2); diff --git a/packages/core/test/ImageBitmapResource.tests.ts b/packages/core/test/ImageBitmapResource.tests.ts index c90fd1b83e..49d6de20f3 100644 --- a/packages/core/test/ImageBitmapResource.tests.ts +++ b/packages/core/test/ImageBitmapResource.tests.ts @@ -1,10 +1,10 @@ -import { ImageBitmapResource } from '@pixi/core'; +import { BaseTexture, ImageBitmapResource } from '@pixi/core'; import sinon from 'sinon'; import { expect } from 'chai'; -describe('ImageBitmapResource', function () +describe('ImageBitmapResource', () => { - it('should create new dimension-less resource', async function () + it('should create new dimension-less resource', async () => { const canvas = document.createElement('canvas'); @@ -18,7 +18,7 @@ describe('ImageBitmapResource', function () resource.destroy(); }); - it('should create new valid resource', async function () + it('should create new valid resource', async () => { const canvas = document.createElement('canvas'); @@ -35,29 +35,29 @@ describe('ImageBitmapResource', function () resource.destroy(); }); - it('should fire resize event on bind', async function () + it('should fire resize event on bind', async () => { const canvas = document.createElement('canvas'); const bitmap = await createImageBitmap(canvas); const resource = new ImageBitmapResource(bitmap); const baseTexture = { setRealSize: sinon.stub() }; - resource.bind(baseTexture); + resource.bind(baseTexture as unknown as BaseTexture); expect(baseTexture.setRealSize.calledOnce).to.be.true; - resource.unbind(baseTexture); + resource.unbind(baseTexture as unknown as BaseTexture); resource.destroy(); }); - it('should fire manual update event', async function () + it('should fire manual update event', async () => { const canvas = document.createElement('canvas'); const bitmap = await createImageBitmap(canvas); const resource = new ImageBitmapResource(bitmap); const baseTexture = { update: sinon.stub() }; - resource.bind(baseTexture); + resource.bind(baseTexture as unknown as BaseTexture); expect(baseTexture.update.called).to.be.false; @@ -65,7 +65,7 @@ describe('ImageBitmapResource', function () expect(baseTexture.update.calledOnce).to.be.true; - resource.unbind(baseTexture); + resource.unbind(baseTexture as unknown as BaseTexture); resource.destroy(); }); }); diff --git a/packages/core/test/ImageResource.tests.ts b/packages/core/test/ImageResource.tests.ts index 97173e6453..64ccb071c4 100644 --- a/packages/core/test/ImageResource.tests.ts +++ b/packages/core/test/ImageResource.tests.ts @@ -3,14 +3,16 @@ import { settings } from '@pixi/settings'; import path from 'path'; import { expect } from 'chai'; -describe('ImageResource', function () +describe('ImageResource', () => { - before(function () + let slugUrl: string; + + before(() => { - this.slugUrl = path.resolve(__dirname, 'resources', 'slug.png'); + slugUrl = path.resolve(__dirname, 'resources', 'slug.png'); }); - it('should create new dimension-less resource', function () + it('should create new dimension-less resource', () => { const image = new Image(); @@ -24,7 +26,7 @@ describe('ImageResource', function () resource.destroy(); }); - it('should destroy resource multiple times', function () + it('should destroy resource multiple times', () => { const resource = new ImageResource(new Image()); @@ -32,11 +34,11 @@ describe('ImageResource', function () resource.destroy(); }); - it('should create new valid resource from HTMLImageElement', function () + it('should create new valid resource from HTMLImageElement', () => { const image = new Image(); - image.src = this.slugUrl; + image.src = slugUrl; const resource = new ImageResource(image); @@ -48,11 +50,11 @@ describe('ImageResource', function () resource.destroy(); }); - it('should handle the loaded event with createBitmapImage', function () + it('should handle the loaded event with createBitmapImage', () => { const image = new Image(); - image.src = this.slugUrl; + image.src = slugUrl; const resource = new ImageResource(image, { autoLoad: false, @@ -69,11 +71,11 @@ describe('ImageResource', function () }); }); - it('should handle the loaded event with no createBitmapImage', function () + it('should handle the loaded event with no createBitmapImage', () => { const image = new Image(); - image.src = this.slugUrl; + image.src = slugUrl; const resource = new ImageResource(image, { autoLoad: false, @@ -90,7 +92,7 @@ describe('ImageResource', function () }); }); - it('should handle error when resource is broken', function () + it('should handle error when resource is broken', () => { const image = new Image(); @@ -107,13 +109,13 @@ describe('ImageResource', function () }); }); - it('should handle the loaded event with createBitmapImage using global setting', function () + it('should handle the loaded event with createBitmapImage using global setting', () => { const old = settings.CREATE_IMAGE_BITMAP; const image = new Image(); settings.CREATE_IMAGE_BITMAP = true; - image.src = this.slugUrl; + image.src = slugUrl; const resource = new ImageResource(image, { autoLoad: false }); @@ -129,13 +131,13 @@ describe('ImageResource', function () }); }); - it('should handle the loaded event with no createBitmapImage using global setting', function () + it('should handle the loaded event with no createBitmapImage using global setting', () => { const old = settings.CREATE_IMAGE_BITMAP; const image = new Image(); settings.CREATE_IMAGE_BITMAP = false; - image.src = this.slugUrl; + image.src = slugUrl; const resource = new ImageResource(image, { autoLoad: false }); @@ -151,35 +153,37 @@ describe('ImageResource', function () }); }); - describe('alphaMode behaviour', function () + describe('alphaMode behaviour', () => { - before(function () + let renderer: Renderer; + + before(() => { - this.renderer = new Renderer(); + renderer = new Renderer(); }); - after(function () + after(() => { - this.renderer.destroy(); - this.renderer = null; + renderer.destroy(); + renderer = null; }); - it('should override BaseTexture alphaMode if specified', function () + it('should override BaseTexture alphaMode if specified', () => { const image = new Image(); const resource = new ImageResource(image, { autoLoad: false, alphaMode: 2 }); const baseTexture = new BaseTexture(resource); - image.src = this.slugUrl; + image.src = slugUrl; return resource.load(false).then(() => { - this.renderer.texture.bind(baseTexture); + renderer.texture.bind(baseTexture); expect(baseTexture.alphaMode).to.equal(2); }); }); - it('should not override BaseTexture alphaMode if not specified', function () + it('should not override BaseTexture alphaMode if not specified', () => { const image = new Image(); const resource = new ImageResource(image, { autoLoad: false }); @@ -188,11 +192,11 @@ describe('ImageResource', function () baseTexture.alphaMode = 2; expect(resource.alphaMode).to.be.null; - image.src = this.slugUrl; + image.src = slugUrl; return resource.load(false).then(() => { - this.renderer.texture.bind(baseTexture); + renderer.texture.bind(baseTexture); expect(baseTexture.alphaMode).to.equal(2); }); }); diff --git a/packages/core/test/MaskSystem.tests.ts b/packages/core/test/MaskSystem.tests.ts index 70c9eea7cd..cc3f109bd9 100644 --- a/packages/core/test/MaskSystem.tests.ts +++ b/packages/core/test/MaskSystem.tests.ts @@ -1,25 +1,35 @@ -import { MASK_TYPES, MSAA_QUALITY } from '@pixi/constants'; -import { Rectangle, Matrix } from '@pixi/math'; -import { Renderer, MaskData, RenderTexture, Filter, Texture, BaseTexture, CanvasResource, - SpriteMaskFilter } from '@pixi/core'; +import { MASK_TYPES } from '@pixi/constants'; +import { + BaseTexture, + CanvasResource, + Filter, + IFilterTarget, + IMaskTarget, + MaskData, + Renderer, + RenderTexture, + SpriteMaskFilter, + Texture +} from '@pixi/core'; import { Graphics } from '@pixi/graphics'; +import { Matrix, Rectangle } from '@pixi/math'; import { Sprite } from '@pixi/sprite'; -import sinon from 'sinon'; import { expect } from 'chai'; +import sinon from 'sinon'; -describe('MaskSystem', function () +describe('MaskSystem', () => { - function onePixelMask(worldTransform) + function onePixelMask(worldTransform: Matrix | Record): IMaskTarget { return { isFastRect() { return true; }, worldTransform: worldTransform || Matrix.IDENTITY, getBounds() { return new Rectangle(0, 0, 1, 1); }, render() { /* nothing*/ }, - }; + } as unknown as IMaskTarget; } - function createColorTexture(color) + function createColorTexture(color: CanvasRenderingContext2D['fillStyle']) { const canvas = document.createElement('canvas'); @@ -34,14 +44,19 @@ describe('MaskSystem', function () return new Texture(new BaseTexture(new CanvasResource(canvas))); } - before(function () + let renderer: Renderer; + let textureRed: Texture; + let textureGreen: Texture; + let spriteMaskFilterGreen: SpriteMaskFilter; + + before(() => { - this.renderer = new Renderer(); - this.renderer.mask.enableScissor = true; - this.textureRed = createColorTexture('#ff0000'); - this.textureGreen = createColorTexture('#00ff00'); + renderer = new Renderer(); + renderer.mask.enableScissor = true; + textureRed = createColorTexture('#ff0000'); + textureGreen = createColorTexture('#00ff00'); // Like SpriteMaskFilter, but with green instead of red channel - this.spriteMaskFilterGreen = new SpriteMaskFilter(undefined, `\ + spriteMaskFilterGreen = new SpriteMaskFilter(undefined, `\ varying vec2 vMaskCoord; varying vec2 vTextureCoord; @@ -69,116 +84,116 @@ describe('MaskSystem', function () }`); }); - after(function () + after(() => { - this.renderer.destroy(); - this.renderer = null; - this.textureRed.destroy(true); - this.textureRed = null; - this.textureGreen.destroy(true); - this.textureGreen = null; - this.spriteMaskFilterGreen.destroy(); - this.spriteMaskFilterGreen = null; + renderer.destroy(); + renderer = null; + textureRed.destroy(true); + textureRed = null; + textureGreen.destroy(true); + textureGreen = null; + spriteMaskFilterGreen.destroy(); + spriteMaskFilterGreen = null; }); - it('should have scissor-masks enabled', function () + it('should have scissor-masks enabled', () => { - expect(this.renderer.mask.enableScissor).to.equal(true); + expect(renderer.mask.enableScissor).to.equal(true); }); - it('should use scissor masks with axis aligned squares', function () + it('should use scissor masks with axis aligned squares', () => { - const context = {}; + const context = {} as IMaskTarget; const maskObject = onePixelMask({ a: 1, b: 0, c: 0, d: 1 }); const maskObject2 = onePixelMask({ a: 0, b: 1, c: 1, d: 0 }); - this.renderer.mask.push(context, maskObject); + renderer.mask.push(context, maskObject); - expect(this.renderer.scissor.getStackLength()).to.equal(1); + expect(renderer.scissor.getStackLength()).to.equal(1); - this.renderer.mask.push(context, maskObject2); + renderer.mask.push(context, maskObject2); - expect(this.renderer.scissor.getStackLength()).to.equal(2); + expect(renderer.scissor.getStackLength()).to.equal(2); - this.renderer.mask.pop(context, maskObject2); + renderer.mask.pop(context); - expect(this.renderer.scissor.getStackLength()).to.equal(1); + expect(renderer.scissor.getStackLength()).to.equal(1); - this.renderer.mask.pop(context, maskObject); + renderer.mask.pop(context); - expect(this.renderer.scissor.getStackLength()).to.equal(0); + expect(renderer.scissor.getStackLength()).to.equal(0); }); - it('should return maskData to pool if it does not belong in the object', function () + it('should return maskData to pool if it does not belong in the object', () => { - const context = {}; + const context: IMaskTarget = {} as IMaskTarget; const maskObject = onePixelMask({ a: 1, b: 0, c: 0, d: 1 }); - this.renderer.mask.maskDataPool.length = 0; - this.renderer.mask.push(context, maskObject); - this.renderer.mask.pop(context, maskObject); + renderer.mask['maskDataPool'].length = 0; + renderer.mask.push(context, maskObject); + renderer.mask.pop(context); - const maskData = this.renderer.mask.maskDataPool[0]; + const maskData = renderer.mask['maskDataPool'][0]; expect(maskData).to.exist; expect(maskData._scissorCounter).to.equal(1); }); - it('should not put maskData to pool if it belongs to object', function () + it('should not put maskData to pool if it belongs to object', () => { - const context = {}; + const context: IMaskTarget = {} as IMaskTarget; const maskData = new MaskData(onePixelMask({ a: 1, b: 0, c: 0, d: 1 })); - this.renderer.mask.maskDataPool.length = 0; + renderer.mask['maskDataPool'].length = 0; for (let i = 0; i < 2; i++) { // repeat two times just to be sure - this.renderer.mask.push(context, maskData); - this.renderer.mask.pop(context, maskData); + renderer.mask.push(context, maskData); + renderer.mask.pop(context); expect(maskData._scissorCounter).to.equal(1); - expect(this.renderer.mask.maskDataPool.length).to.equal(0); + expect(renderer.mask['maskDataPool'].length).to.equal(0); } }); - it('should not use scissor masks with non axis aligned squares', function () + it('should not use scissor masks with non axis aligned squares', () => { - const context = {}; + const context: IMaskTarget = {} as IMaskTarget; const maskObject = onePixelMask({ a: 0.1, b: 2, c: 2, d: -0.1 }); - this.renderer.mask.push(context, maskObject); + renderer.mask.push(context, maskObject); - expect(this.renderer.scissor.getStackLength()).to.equal(0); + expect(renderer.scissor.getStackLength()).to.equal(0); - this.renderer.mask.pop(context, maskObject); + renderer.mask.pop(context); }); - it('should apply scissor with transform on canvas or renderTexture', function () + it('should apply scissor with transform on canvas or renderTexture', () => { - const context = {}; + const context: IMaskTarget = {} as IMaskTarget; const maskObject = { isFastRect() { return true; }, worldTransform: Matrix.IDENTITY, getBounds() { return new Rectangle(2, 3, 6, 5); }, render() { /* nothing*/ }, - }; + } as unknown as IMaskTarget; - this.renderer.resolution = 2; - this.renderer.resize(30, 30); + renderer.resolution = 2; + renderer.resize(30, 30); const rt = RenderTexture.create({ width: 20, height: 20, resolution: 3 }); - const scissor = sinon.spy(this.renderer.gl, 'scissor'); + const scissor = sinon.spy(renderer.gl, 'scissor'); - this.renderer.projection.transform = new Matrix(1, 0, 0, 1, 0.5, 1); - this.renderer.mask.push(context, maskObject); - this.renderer.mask.pop(context, maskObject); + renderer.projection.transform = new Matrix(1, 0, 0, 1, 0.5, 1); + renderer.mask.push(context, maskObject); + renderer.mask.pop(context); // now , lets try it for renderTexture - this.renderer.renderTexture.bind(rt); + renderer.renderTexture.bind(rt); - this.renderer.mask.push(context, maskObject); - this.renderer.mask.pop(context, maskObject); + renderer.mask.push(context, maskObject); + renderer.mask.pop(context); expect(scissor.calledTwice).to.be.true; // result Y is 2 because after transform y=8 h=10 and renderer H=60 is inverted , 8-18 becomes 52-42, e.g. Y=2 @@ -187,43 +202,45 @@ describe('MaskSystem', function () expect(scissor.args[1]).to.eql([Math.round(7.5), Math.round(12), Math.round(18), Math.round(15)]); rt.destroy(true); - this.renderer.projection.transform = null; - this.renderer.resolution = 1; + renderer.projection.transform = null; + renderer.resolution = 1; }); + // eslint-disable-next-line func-names it('should correctly calculate alpha mask area if filter is present', function () { // fixes slow runs on CI #6604 this.timeout(5000); // the bug was fixed in #5444 - this.renderer.resize(10, 10); + renderer.resize(10, 10); - const filteredObject = { + const filteredObject: IFilterTarget = { getBounds() { return new Rectangle(0, 0, 10, 10); }, render() { /* nothing*/ }, - }; + } as unknown as IFilterTarget; const maskBounds = new Rectangle(2, 3, 6, 5); const maskObject = { isSprite: true, _texture: Texture.WHITE, + // @ts-expect-error - mocking IMaskTarget get texture() { return this._texture; }, anchor: { x: 0, y: 0 }, isFastRect() { return true; }, worldTransform: Matrix.IDENTITY, getBounds() { return maskBounds.clone(); }, - }; + } as unknown as IMaskTarget; const filters = [new Filter()]; - const maskSystem = this.renderer.mask; + const maskSystem = renderer.mask; for (let i = 0; i < 6; i++) { - this.renderer.filter.push(filteredObject, filters); - maskSystem.push(filteredObject, maskObject); - expect(maskSystem.maskStack.length).to.equal(1); - expect(maskSystem.maskStack[0].type).to.equal(MASK_TYPES.SPRITE); - expect(this.renderer.renderTexture.current).to.exist; + renderer.filter.push(filteredObject, filters); + maskSystem.push(filteredObject as IMaskTarget, maskObject); + expect(maskSystem['maskStack'].length).to.equal(1); + expect(maskSystem['maskStack'][0].type).to.equal(MASK_TYPES.SPRITE); + expect(renderer.renderTexture.current).to.exist; - const filterArea = this.renderer.renderTexture.current.filterFrame; + const filterArea = renderer.renderTexture.current.filterFrame; const expected = maskBounds.clone().ceil(); expected.fit(filteredObject.getBounds()); @@ -233,30 +250,30 @@ describe('MaskSystem', function () expect(filterArea.width).to.equal(expected.width); expect(filterArea.height).to.equal(expected.height); - maskSystem.pop(filteredObject); - this.renderer.filter.pop(); - expect(maskSystem.maskStack.length).to.equal(0); - expect(this.renderer.renderTexture.current).to.be.null; + maskSystem.pop(filteredObject as IMaskTarget); + renderer.filter.pop(); + expect(maskSystem['maskStack'].length).to.equal(0); + expect(renderer.renderTexture.current).to.be.null; maskBounds.x += 1.0; maskBounds.y += 0.5; } }); - it('should render correctly without a custom sprite mask filter and a red texture sprite mask', function () + it('should render correctly without a custom sprite mask filter and a red texture sprite mask', () => { const graphics = new Graphics().beginFill(0xffffff, 1.0).drawRect(0, 0, 1, 1).endFill(); - graphics.mask = new MaskData(new Sprite(this.textureRed)); + graphics.mask = new MaskData(new Sprite(textureRed)); - const renderTexture = this.renderer.generateTexture(graphics); + const renderTexture = renderer.generateTexture(graphics); graphics.destroy(true); - this.renderer.renderTexture.bind(renderTexture); + renderer.renderTexture.bind(renderTexture); const pixel = new Uint8Array(4); - const gl = this.renderer.gl; + const gl = renderer.gl; gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, pixel); @@ -270,20 +287,20 @@ describe('MaskSystem', function () expect(a).to.equal(0xff); }); - it('should render correctly without a custom sprite mask filter and a green texture sprite mask', function () + it('should render correctly without a custom sprite mask filter and a green texture sprite mask', () => { const graphics = new Graphics().beginFill(0xffffff, 1.0).drawRect(0, 0, 1, 1).endFill(); - graphics.mask = new MaskData(new Sprite(this.textureGreen)); + graphics.mask = new MaskData(new Sprite(textureGreen)); - const renderTexture = this.renderer.generateTexture(graphics); + const renderTexture = renderer.generateTexture(graphics); graphics.destroy(true); - this.renderer.renderTexture.bind(renderTexture); + renderer.renderTexture.bind(renderTexture); const pixel = new Uint8Array(4); - const gl = this.renderer.gl; + const gl = renderer.gl; gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, pixel); @@ -297,21 +314,21 @@ describe('MaskSystem', function () expect(a).to.equal(0x00); }); - it('should render correctly with acustom sprite mask filter and a red texture sprite mask', function () + it('should render correctly with acustom sprite mask filter and a red texture sprite mask', () => { const graphics = new Graphics().beginFill(0xffffff, 1.0).drawRect(0, 0, 1, 1).endFill(); - graphics.mask = new MaskData(new Sprite(this.textureRed)); - graphics.mask.filter = this.spriteMaskFilterGreen; + graphics.mask = new MaskData(new Sprite(textureRed)); + graphics.mask.filter = spriteMaskFilterGreen; - const renderTexture = this.renderer.generateTexture(graphics); + const renderTexture = renderer.generateTexture(graphics); graphics.destroy(true); - this.renderer.renderTexture.bind(renderTexture); + renderer.renderTexture.bind(renderTexture); const pixel = new Uint8Array(4); - const gl = this.renderer.gl; + const gl = renderer.gl; gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, pixel); @@ -325,21 +342,21 @@ describe('MaskSystem', function () expect(a).to.equal(0x00); }); - it('should render correctly with a custom sprite mask filter and a green texture sprite mask', function () + it('should render correctly with a custom sprite mask filter and a green texture sprite mask', () => { const graphics = new Graphics().beginFill(0xffffff, 1.0).drawRect(0, 0, 1, 1).endFill(); - graphics.mask = new MaskData(new Sprite(this.textureGreen)); - graphics.mask.filter = this.spriteMaskFilterGreen; + graphics.mask = new MaskData(new Sprite(textureGreen)); + graphics.mask.filter = spriteMaskFilterGreen; - const renderTexture = this.renderer.generateTexture(graphics); + const renderTexture = renderer.generateTexture(graphics); graphics.destroy(true); - this.renderer.renderTexture.bind(renderTexture); + renderer.renderTexture.bind(renderTexture); const pixel = new Uint8Array(4); - const gl = this.renderer.gl; + const gl = renderer.gl; gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, pixel); @@ -353,23 +370,23 @@ describe('MaskSystem', function () expect(a).to.equal(0xff); }); - it('should restore sprite of current sprite mask filter after pop', function () + it('should restore sprite of current sprite mask filter after pop', () => { const renderTexture = RenderTexture.create({ width: 1, height: 1 }); - this.renderer.renderTexture.bind(renderTexture); + renderer.renderTexture.bind(renderTexture); const graphics1 = new Graphics(); const graphics2 = new Graphics(); - const sprite1 = new Sprite(this.textureRed); - const sprite2 = new Sprite(this.textureGreen); + const sprite1 = new Sprite(textureRed); + const sprite2 = new Sprite(textureGreen); const maskData1 = new MaskData(sprite1); const maskData2 = new MaskData(sprite2); - maskData1.filter = this.spriteMaskFilterGreen; - maskData2.filter = this.spriteMaskFilterGreen; + maskData1.filter = spriteMaskFilterGreen; + maskData2.filter = spriteMaskFilterGreen; expect(maskData1.filter.maskSprite).to.be.null; expect(maskData2.filter.maskSprite).to.be.null; @@ -377,19 +394,19 @@ describe('MaskSystem', function () graphics1.mask = maskData1; graphics2.mask = maskData2; - this.renderer.mask.push(graphics1, maskData1); + renderer.mask.push(graphics1, maskData1); expect(maskData1.filter.maskSprite).to.equal(sprite1); - this.renderer.mask.push(graphics2, maskData2); + renderer.mask.push(graphics2, maskData2); expect(maskData2.filter.maskSprite).to.equal(sprite2); - this.renderer.mask.pop(graphics2); + renderer.mask.pop(graphics2); expect(maskData1.filter.maskSprite).to.equal(sprite1); - this.renderer.mask.pop(graphics1); + renderer.mask.pop(graphics1); expect(maskData1.filter.maskSprite).to.be.null; expect(maskData2.filter.maskSprite).to.be.null; diff --git a/packages/core/test/ProjectionSystem.tests.ts b/packages/core/test/ProjectionSystem.tests.ts index a89c266469..f2ce4407b1 100644 --- a/packages/core/test/ProjectionSystem.tests.ts +++ b/packages/core/test/ProjectionSystem.tests.ts @@ -2,32 +2,34 @@ import { Renderer } from '@pixi/core'; import { Point, Rectangle } from '@pixi/math'; import { expect } from 'chai'; -describe('ProjectionSystem', function () +describe('ProjectionSystem', () => { - before(function () + let renderer: Renderer; + + before(() => { - this.renderer = new Renderer(); + renderer = new Renderer(); }); - after(function () + after(() => { - this.renderer = null; + renderer = null; }); - it('should calculate a projection-matrix that transforms a source-frame to the clipping rectangle', function () + it('should calculate a projection-matrix that transforms a source-frame to the clipping rectangle', () => { const sourceFrame = new Rectangle(16, 16, 1024, 1024); - this.renderer.projection.update(null, sourceFrame, 2, true); + renderer.projection.update(null, sourceFrame, 2, true); const sourceOrigin = new Point(16, 16); - const clipOrigin = this.renderer.projection.projectionMatrix.apply(sourceOrigin); + const clipOrigin = renderer.projection.projectionMatrix.apply(sourceOrigin); expect(clipOrigin.x).to.equal(-1); expect(clipOrigin.y).to.equal(1); const sourceCorner = new Point(1040, 1040); - const clipCorner = this.renderer.projection.projectionMatrix.apply(sourceCorner); + const clipCorner = renderer.projection.projectionMatrix.apply(sourceCorner); expect(clipCorner.x).to.equal(1); expect(clipCorner.y).to.equal(-1); diff --git a/packages/core/test/RenderTexture.tests.ts b/packages/core/test/RenderTexture.tests.ts index 8a17af513c..02a02d78b7 100644 --- a/packages/core/test/RenderTexture.tests.ts +++ b/packages/core/test/RenderTexture.tests.ts @@ -5,21 +5,23 @@ import { MSAA_QUALITY } from '@pixi/constants'; import { AlphaFilter } from '@pixi/filter-alpha'; import { expect } from 'chai'; -describe('RenderTexture', function () +describe('RenderTexture', () => { - before(function () + let renderer: Renderer; + + before(() => { Renderer.registerPlugin('batch', BatchRenderer); - this.renderer = new Renderer(); + renderer = new Renderer(); }); - after(function () + after(() => { - this.renderer.destroy(); - this.renderer = null; + renderer.destroy(); + renderer = null; }); - it('should destroy the depth texture too', function () + it('should destroy the depth texture too', () => { const renderer = autoDetectRenderer() as Renderer; @@ -38,9 +40,9 @@ describe('RenderTexture', function () expect(depthTexture._glTextures[renderer.CONTEXT_UID]).to.equal(undefined); }); - it('should render correctly with empty mask', function () + it('should render correctly with empty mask', () => { - const { gl } = this.renderer; + const { gl } = renderer; const renderTexture = RenderTexture.create({ width: 1, height: 1 }); @@ -59,9 +61,9 @@ describe('RenderTexture', function () container.addChild(graphics); container.mask = container.addChild(new Graphics()); - this.renderer.render(container, { renderTexture, clear: true }); + renderer.render(container, { renderTexture, clear: true }); - this.renderer.renderTexture.bind(renderTexture); + renderer.renderTexture.bind(renderTexture); const pixel = new Uint8Array([0x80, 0x80, 0x80, 0x80]); @@ -73,9 +75,9 @@ describe('RenderTexture', function () expect(pixel[3]).to.equal(51); }); - it('should render correctly with empty mask and multisampling', function () + it('should render correctly with empty mask and multisampling', () => { - const { gl } = this.renderer; + const { gl } = renderer; const renderTexture = RenderTexture.create({ width: 1, height: 1 }); @@ -94,14 +96,14 @@ describe('RenderTexture', function () container.addChild(graphics); container.mask = container.addChild(new Graphics()); - this.renderer.render(container, { renderTexture, clear: true }); - this.renderer.framebuffer.blit(); + renderer.render(container, { renderTexture, clear: true }); + renderer.framebuffer.blit(); const textureFramebuffer = new Framebuffer(framebuffer.width, framebuffer.height); textureFramebuffer.addColorTexture(0, framebuffer.colorTextures[0]); - this.renderer.framebuffer.bind(textureFramebuffer); + renderer.framebuffer.bind(textureFramebuffer); const pixel = new Uint8Array([0x80, 0x80, 0x80, 0x80]); @@ -113,9 +115,9 @@ describe('RenderTexture', function () expect(pixel[3]).to.equal(51); }); - it('should render correctly with mask', function () + it('should render correctly with mask', () => { - const { gl } = this.renderer; + const { gl } = renderer; const renderTexture = RenderTexture.create({ width: 2, height: 2 }); @@ -139,9 +141,9 @@ describe('RenderTexture', function () .endFill() ); - this.renderer.render(container, { renderTexture, clear: true }); + renderer.render(container, { renderTexture, clear: true }); - this.renderer.renderTexture.bind(renderTexture); + renderer.renderTexture.bind(renderTexture); const pixel = new Uint8Array([0x80, 0x80, 0x80, 0x80]); @@ -162,9 +164,9 @@ describe('RenderTexture', function () expect(pixel[3]).to.equal(51); }); - it('should render correctly with stencil mask and filter', function () + it('should render correctly with stencil mask and filter', () => { - const { gl } = this.renderer; + const { gl } = renderer; const renderTexture = RenderTexture.create({ width: 1, height: 1 }); @@ -186,13 +188,13 @@ describe('RenderTexture', function () container.mask = container.addChild( new Graphics() .beginFill(0xffffff) - .drawCircle(0, 0, 4, 4) + .drawCircle(0, 0, 4) .endFill() ); - this.renderer.render(container, { renderTexture, clear: true }); + renderer.render(container, { renderTexture, clear: true }); - this.renderer.renderTexture.bind(renderTexture); + renderer.renderTexture.bind(renderTexture); const pixel = new Uint8Array([0x80, 0x80, 0x80, 0x80]); @@ -204,9 +206,9 @@ describe('RenderTexture', function () expect(pixel[3]).to.equal(0xff); }); - it('should render correctly with mask and multisampling', function () + it('should render correctly with mask and multisampling', () => { - const { gl } = this.renderer; + const { gl } = renderer; const renderTexture = RenderTexture.create({ width: 2, height: 2 }); @@ -230,14 +232,14 @@ describe('RenderTexture', function () .endFill() ); - this.renderer.render(container, { renderTexture, clear: true }); - this.renderer.framebuffer.blit(); + renderer.render(container, { renderTexture, clear: true }); + renderer.framebuffer.blit(); const textureFramebuffer = new Framebuffer(framebuffer.width, framebuffer.height); textureFramebuffer.addColorTexture(0, framebuffer.colorTextures[0]); - this.renderer.framebuffer.bind(textureFramebuffer); + renderer.framebuffer.bind(textureFramebuffer); const pixel = new Uint8Array([0x80, 0x80, 0x80, 0x80]); @@ -258,9 +260,9 @@ describe('RenderTexture', function () expect(pixel[3]).to.equal(51); }); - it('should resize framebuffer', function () + it('should resize framebuffer', () => { - const { gl } = this.renderer; + const { gl } = renderer; const renderTexture = RenderTexture.create({ width: 1, height: 1 }); @@ -274,13 +276,13 @@ describe('RenderTexture', function () graphics.beginFill(0xffffff).drawRect(0, 0, 2, 2).endFill(); - this.renderer.render(graphics, { renderTexture, clear: true }); + renderer.render(graphics, { renderTexture, clear: true }); renderTexture.resize(2, 2); - this.renderer.render(graphics, { renderTexture, clear: true }); + renderer.render(graphics, { renderTexture, clear: true }); - this.renderer.renderTexture.bind(renderTexture); + renderer.renderTexture.bind(renderTexture); const pixel = new Uint8Array([0x80, 0x80, 0x80, 0x80]); @@ -292,9 +294,9 @@ describe('RenderTexture', function () expect(pixel[3]).to.equal(0xff); }); - it('should resize multisampled framebuffer', function () + it('should resize multisampled framebuffer', () => { - const { gl } = this.renderer; + const { gl } = renderer; const renderTexture = RenderTexture.create({ width: 1, height: 1 }); @@ -308,19 +310,19 @@ describe('RenderTexture', function () graphics.beginFill(0xffffff).drawRect(0, 0, 2, 2).endFill(); - this.renderer.render(graphics, { renderTexture, clear: true }); - this.renderer.framebuffer.blit(); + renderer.render(graphics, { renderTexture, clear: true }); + renderer.framebuffer.blit(); renderTexture.resize(2, 2); - this.renderer.render(graphics, { renderTexture, clear: true }); - this.renderer.framebuffer.blit(); + renderer.render(graphics, { renderTexture, clear: true }); + renderer.framebuffer.blit(); const textureFramebuffer = new Framebuffer(framebuffer.width, framebuffer.height); textureFramebuffer.addColorTexture(0, framebuffer.colorTextures[0]); - this.renderer.framebuffer.bind(textureFramebuffer); + renderer.framebuffer.bind(textureFramebuffer); const pixel = new Uint8Array([0x80, 0x80, 0x80, 0x80]); diff --git a/packages/core/test/RenderTexturePool.tests.ts b/packages/core/test/RenderTexturePool.tests.ts index 9e787540ef..0d3ef4264b 100644 --- a/packages/core/test/RenderTexturePool.tests.ts +++ b/packages/core/test/RenderTexturePool.tests.ts @@ -1,9 +1,9 @@ import { RenderTexturePool } from '@pixi/core'; import { expect } from 'chai'; -describe('RenderTexturePool', function () +describe('RenderTexturePool', () => { - it('should destroy screen-sized textures on resize', function () + it('should destroy screen-sized textures on resize', () => { const renderTexturePool = new RenderTexturePool(); @@ -30,7 +30,7 @@ describe('RenderTexturePool', function () renderTexturePool.clear(true); }); - it('should create screen-sized texture with noninteger resolution', function () + it('should create screen-sized texture with noninteger resolution', () => { const resolution = 1.1; const viewWidth = 1419; diff --git a/packages/core/test/RenderTextureSystem.tests.ts b/packages/core/test/RenderTextureSystem.tests.ts index 0271784b18..07e9d749f7 100644 --- a/packages/core/test/RenderTextureSystem.tests.ts +++ b/packages/core/test/RenderTextureSystem.tests.ts @@ -2,42 +2,44 @@ import { Renderer } from '@pixi/core'; import { Rectangle } from '@pixi/math'; import { expect } from 'chai'; -describe('RenderTextureSystem', function () +describe('RenderTextureSystem', () => { - before(function () + let renderer: Renderer; + + before(() => { - this.renderer = new Renderer({ resolution: 4, width: 1024, height: 1024 }); + renderer = new Renderer({ resolution: 4, width: 1024, height: 1024 }); }); - after(function () + after(() => { - this.renderer = null; + renderer = null; }); - it('the default viewport should have a width/height equal to that of the renderer', function () + it('the default viewport should have a width/height equal to that of the renderer', () => { - this.renderer.renderTexture.bind(); + renderer.renderTexture.bind(); - const viewport = this.renderer.framebuffer.viewport; + const viewport = renderer.framebuffer.viewport; expect(viewport.x).to.equal(0); expect(viewport.y).to.equal(0); - expect(viewport.width).to.equal(this.renderer.width); - expect(viewport.height).to.equal(this.renderer.height); + expect(viewport.width).to.equal(renderer.width); + expect(viewport.height).to.equal(renderer.height); - const destinationFrame = this.renderer.renderTexture.destinationFrame; + const destinationFrame = renderer.renderTexture.destinationFrame; expect(destinationFrame.x).to.equal(0); expect(destinationFrame.y).to.equal(0); - expect(destinationFrame.width).to.equal(this.renderer.width / this.renderer.resolution); - expect(destinationFrame.height).to.equal(this.renderer.height / this.renderer.resolution); + expect(destinationFrame.width).to.equal(renderer.width / renderer.resolution); + expect(destinationFrame.height).to.equal(renderer.height / renderer.resolution); }); - it('rebinding with the same source & destination frame should change nothing', function () + it('rebinding with the same source & destination frame should change nothing', () => { const sourceFrame = new Rectangle(16, 16, 512, 512); const destinationFrame = new Rectangle(24, 24, 64, 64); - const renderTextureSystem = this.renderer.renderTexture; + const renderTextureSystem = renderer.renderTexture; renderTextureSystem.bind(null, sourceFrame, destinationFrame); renderTextureSystem.bind(null, renderTextureSystem.sourceFrame, renderTextureSystem.destinationFrame); diff --git a/packages/core/test/Renderer.tests.ts b/packages/core/test/Renderer.tests.ts index f3385b80b5..643bb857cc 100644 --- a/packages/core/test/Renderer.tests.ts +++ b/packages/core/test/Renderer.tests.ts @@ -1,4 +1,4 @@ -import { Renderer, Framebuffer } from '@pixi/core'; +import { Renderer, Framebuffer, ObjectRenderer } from '@pixi/core'; import { Graphics } from '@pixi/graphics'; import { settings } from '@pixi/settings'; import { ENV, MSAA_QUALITY } from '@pixi/constants'; @@ -8,9 +8,9 @@ import { expect } from 'chai'; skipHello(); -describe('Renderer', function () +describe('Renderer', () => { - it('setting option legacy should disable VAOs and SPRITE_MAX_TEXTURES', function () + it('setting option legacy should disable VAOs and SPRITE_MAX_TEXTURES', () => { settings.PREFER_ENV = ENV.WEBGL_LEGACY; const renderer = new Renderer({ width: 1, height: 1 }); @@ -27,7 +27,7 @@ describe('Renderer', function () settings.PREFER_ENV = ENV.WEBGL2; }); - it('should allow clear() to work despite no containers added to the renderer', function () + it('should allow clear() to work despite no containers added to the renderer', () => { const renderer = new Renderer({ width: 1, height: 1 }); @@ -41,7 +41,7 @@ describe('Renderer', function () } }); - it('should emit resize event', function () + it('should emit resize event', () => { const renderer = new Renderer({ width: 1, height: 1 }); const spy = sinon.spy(); @@ -56,59 +56,63 @@ describe('Renderer', function () renderer.destroy(); }); - describe('.setObjectRenderer()', function () + describe('.setObjectRenderer()', () => { - before(function () + let renderer: Renderer; + let curRenderer: ObjectRenderer; + let objRenderer: ObjectRenderer; + + before(() => { - this.renderer = new Renderer(); + renderer = new Renderer(); }); - beforeEach(function () + beforeEach(() => { - this.curRenderer = { + curRenderer = { start: sinon.spy(), stop: sinon.spy(), - }; - this.objRenderer = { + } as unknown as ObjectRenderer; + objRenderer = { start: sinon.spy(), stop: sinon.spy(), - }; - this.renderer.batch.currentRenderer = this.curRenderer; + } as unknown as ObjectRenderer; + renderer.batch.currentRenderer = curRenderer; }); - after(function () + after(() => { - this.renderer.destroy(); - this.renderer = null; - this.curRenderer = null; - this.objRenderer = null; + renderer.destroy(); + renderer = null; + curRenderer = null; + objRenderer = null; }); - it('should set objectRenderer as new current renderer', function () + it('should set objectRenderer as new current renderer', () => { - this.renderer.batch.setObjectRenderer(this.objRenderer); - expect(this.curRenderer.stop).to.be.calledOnce; - expect(this.renderer.batch.currentRenderer).to.be.equal(this.objRenderer); - expect(this.objRenderer.start).to.be.calledOnce; + renderer.batch.setObjectRenderer(objRenderer); + expect(curRenderer.stop).to.be.calledOnce; + expect(renderer.batch.currentRenderer).to.be.equal(objRenderer); + expect(objRenderer.start).to.be.calledOnce; }); - it('should do nothing if objectRenderer is already used as current', function () + it('should do nothing if objectRenderer is already used as current', () => { - this.renderer.batch.setObjectRenderer(this.curRenderer); - expect(this.renderer.batch.currentRenderer).to.be.equal(this.curRenderer); - expect(this.curRenderer.stop).to.not.be.called; - expect(this.curRenderer.start).to.not.be.called; + renderer.batch.setObjectRenderer(curRenderer); + expect(renderer.batch.currentRenderer).to.be.equal(curRenderer); + expect(curRenderer.stop).to.not.be.called; + expect(curRenderer.start).to.not.be.called; }); - it('should generate a multisampled texture', function () + it('should generate a multisampled texture', () => { - const { gl } = this.renderer; + const { gl } = renderer; const graphics = new Graphics(); graphics.beginFill(0xffffff).drawRect(0, 0, 1, 1).endFill(); - const renderTexture = this.renderer.generateTexture(graphics, { multisample: MSAA_QUALITY.HIGH }); + const renderTexture = renderer.generateTexture(graphics, { multisample: MSAA_QUALITY.HIGH }); const framebuffer = renderTexture.framebuffer; @@ -116,7 +120,7 @@ describe('Renderer', function () textureFramebuffer.addColorTexture(0, framebuffer.colorTextures[0]); - this.renderer.framebuffer.bind(textureFramebuffer); + renderer.framebuffer.bind(textureFramebuffer); const pixel = new Uint8Array([0x80, 0x80, 0x80, 0x80]); diff --git a/packages/core/test/SVGResource.tests.ts b/packages/core/test/SVGResource.tests.ts index e64deda431..c889975115 100644 --- a/packages/core/test/SVGResource.tests.ts +++ b/packages/core/test/SVGResource.tests.ts @@ -3,23 +3,25 @@ import fs from 'fs'; import path from 'path'; import { expect } from 'chai'; -describe('SVGResource', function () +describe('SVGResource', () => { - before(function () + let resources: string; + + before(() => { - this.resources = path.join(__dirname, 'resources'); + resources = path.join(__dirname, 'resources'); }); - describe('constructor', function () + describe('constructor', () => { - it('should create new resource from data-uri', function (done) + it('should create new resource from data-uri', (done) => { - const url = path.join(this.resources, 'svg-base64.txt'); + const url = path.join(resources, 'svg-base64.txt'); const buffer = fs.readFileSync(url, 'utf8'); const resource = new SVGResource(buffer, { autoLoad: false }); expect(resource.valid).to.equal(false); - resource.load().then(function () + resource.load().then(() => { expect(resource.valid).to.equal(true); expect(resource.width).to.equal(100); @@ -29,14 +31,14 @@ describe('SVGResource', function () }); }); - it('should create new resource from data-uri with charset=utf8', function (done) + it('should create new resource from data-uri with charset=utf8', (done) => { - const url = path.join(this.resources, 'svg-base64-utf8.txt'); + const url = path.join(resources, 'svg-base64-utf8.txt'); const buffer = fs.readFileSync(url, 'utf8'); const resource = new SVGResource(buffer, { autoLoad: false }); expect(resource.valid).to.equal(false); - resource.load().then(function () + resource.load().then(() => { expect(resource.valid).to.equal(true); expect(resource.width).to.equal(100); @@ -46,15 +48,15 @@ describe('SVGResource', function () }); }); - it('should create resource from SVG URL', function (done) + it('should create resource from SVG URL', (done) => { const resource = new SVGResource( - path.join(this.resources, 'heart.svg'), + path.join(resources, 'heart.svg'), { autoLoad: false } ); expect(resource.valid).to.equal(false); - resource.load().then(function () + resource.load().then(() => { expect(resource.valid).to.equal(true); expect(resource.width).to.equal(100); @@ -64,17 +66,17 @@ describe('SVGResource', function () }); }); - it('should create resource from SVG URL with {scale: 2.123}', function (done) + it('should create resource from SVG URL with {scale: 2.123}', (done) => { const resource = new SVGResource( - path.join(this.resources, 'heart.svg'), + path.join(resources, 'heart.svg'), { autoLoad: false, scale: 2.123, } ); - resource.load().then(function () + resource.load().then(() => { expect(resource.width).to.equal(212); expect(resource.height).to.equal(212); @@ -83,17 +85,17 @@ describe('SVGResource', function () }); }); - it('should create resource from SVG URL with {width: 10}', function (done) + it('should create resource from SVG URL with {width: 10}', (done) => { const resource = new SVGResource( - path.join(this.resources, 'heart.svg'), + path.join(resources, 'heart.svg'), { autoLoad: false, width: 10, } ); - resource.load().then(function () + resource.load().then(() => { expect(resource.width).to.equal(10); expect(resource.height).to.equal(10); @@ -102,10 +104,10 @@ describe('SVGResource', function () }); }); - it('should create resource from SVG URL with {width: 10, height: 10}', function (done) + it('should create resource from SVG URL with {width: 10, height: 10}', (done) => { const resource = new SVGResource( - path.join(this.resources, 'heart.svg'), + path.join(resources, 'heart.svg'), { autoLoad: false, width: 10, @@ -113,7 +115,7 @@ describe('SVGResource', function () } ); - resource.load().then(function () + resource.load().then(() => { expect(resource.width).to.equal(10); expect(resource.height).to.equal(10); @@ -122,14 +124,14 @@ describe('SVGResource', function () }); }); - it('should create resource from inline SVG', function (done) + it('should create resource from inline SVG', (done) => { - const url = path.join(this.resources, 'heart.svg'); + const url = path.join(resources, 'heart.svg'); const buffer = fs.readFileSync(url, 'utf8'); const resource = new SVGResource(buffer, { autoLoad: false }); expect(resource.valid).to.equal(false); - resource.load().then(function () + resource.load().then(() => { expect(resource.valid).to.equal(true); expect(resource.width).to.equal(100); @@ -139,15 +141,15 @@ describe('SVGResource', function () }); }); - it('should create resource from SVG with XML Prolog', function (done) + it('should create resource from SVG with XML Prolog', (done) => { - const url = path.join(this.resources, 'circle-with-prolog.svg'); + const url = path.join(resources, 'circle-with-prolog.svg'); const buffer = fs.readFileSync(url, 'utf8'); const resource = new SVGResource(buffer, { autoLoad: false }); expect(buffer.startsWith(' { expect(resource.valid).to.equal(true); expect(resource.width).to.equal(48); @@ -158,15 +160,15 @@ describe('SVGResource', function () }); }); - describe('getSize', function () + describe('getSize', () => { - it('should exist', function () + it('should exist', () => { expect(SVGResource.getSize) .to.be.a('function'); }); - it('should return a size object with width and height from an SVG string', function () + it('should return a size object with width and height from an SVG string', () => { const svgSize = SVGResource.getSize(''); @@ -178,9 +180,9 @@ describe('SVGResource', function () .to.equal(32); }); - it('should return a size object from an SVG string with inverted quotes', function () + it('should return a size object from an SVG string with inverted quotes', () => { - const svgSize = SVGResource.getSize(""); // eslint-disable-line quotes + const svgSize = SVGResource.getSize(''); // eslint-disable-line quotes expect(svgSize) .to.be.an('object'); @@ -190,7 +192,7 @@ describe('SVGResource', function () .to.equal(32); }); - it('should work with px values', function () + it('should work with px values', () => { const svgSize = SVGResource.getSize(''); @@ -202,7 +204,7 @@ describe('SVGResource', function () .to.equal(32); }); - it('should return an empty object when width and/or height is missing', function () + it('should return an empty object when width and/or height is missing', () => { const svgSize = SVGResource.getSize(''); @@ -211,16 +213,16 @@ describe('SVGResource', function () }); }); - describe('test', function () + describe('test', () => { - it('should pass simple SVG document', function () + it('should pass simple SVG document', () => { const didPass = SVGResource.test(``, 'xml'); expect(didPass).to.equal(true); }); - it('should pass SVG document with prolog', function () + it('should pass SVG document with prolog', () => { const didPass = SVGResource.test(` @@ -231,7 +233,7 @@ describe('SVGResource', function () expect(didPass).to.equal(true); }); - it('should pass SVG document with only prolog, no comments', function () + it('should pass SVG document with only prolog, no comments', () => { const didPass = SVGResource.test( `Hello world`, @@ -240,7 +242,7 @@ describe('SVGResource', function () expect(didPass).to.equal(true); }); - it('should not pass HTML fragment', function () + it('should not pass HTML fragment', () => { const didPass = SVGResource.test( `This is a mistake`, diff --git a/packages/core/test/Shader.tests.ts b/packages/core/test/Shader.tests.ts index 8e64c4d3bd..40d8aea235 100644 --- a/packages/core/test/Shader.tests.ts +++ b/packages/core/test/Shader.tests.ts @@ -3,7 +3,7 @@ import { skipHello } from '@pixi/utils'; skipHello(); -describe('Shader', function () +describe('Shader', () => { const vertexSrc = ` attribute vec2 aVertexPosition; @@ -14,20 +14,23 @@ void main() { }`; - before(function () + let renderer: Renderer; + let geometry: Geometry; + + before(() => { - this.renderer = new Renderer(); - this.geometry = new Geometry() + renderer = new Renderer(); + geometry = new Geometry() .addAttribute('aVertexPosition', [-100, -100, 100, -100, 100, 100], 2); }); - after(function () + after(() => { - this.renderer.destroy(); - this.renderer = null; + renderer.destroy(); + renderer = null; }); - it('should be able to set uniform value', function () + it('should be able to set uniform value', () => { const fragmentSrc = ` uniform float uTestFloat; @@ -42,11 +45,11 @@ void main() { shader.uniforms.uTestFloat = 0.88; - this.renderer.shader.bind(shader); - this.renderer.geometry.bind(this.geometry); + renderer.shader.bind(shader); + renderer.geometry.bind(geometry); }); - it('should be able to set uniform arrays', function () + it('should be able to set uniform arrays', () => { const fragmentSrc = ` uniform float uTestFloat[3]; @@ -61,11 +64,11 @@ void main() { shader.uniforms.uTestFloat = [1, 2, 3]; - this.renderer.shader.bind(shader); - this.renderer.geometry.bind(this.geometry); + renderer.shader.bind(shader); + renderer.geometry.bind(geometry); }); - it('should be able to set uniform structs', function () + it('should be able to set uniform structs', () => { const fragmentSrc = ` struct Test { @@ -84,11 +87,11 @@ void main() { shader.uniforms['uTest.testFloat'] = 1; - this.renderer.shader.bind(shader); - this.renderer.geometry.bind(this.geometry); + renderer.shader.bind(shader); + renderer.geometry.bind(geometry); }); - it('should be able to set uniform struct arrays', function () + it('should be able to set uniform struct arrays', () => { const fragmentSrc = ` struct Test { @@ -119,7 +122,7 @@ void main() { shader.uniforms['uTest[2].testFloat'] = 3.3; shader.uniforms['uTest[2].testVec3'] = [1, 2, 3]; - this.renderer.shader.bind(shader); - this.renderer.geometry.bind(this.geometry); + renderer.shader.bind(shader); + renderer.geometry.bind(geometry); }); }); diff --git a/packages/core/test/ShaderSystem.tests.ts b/packages/core/test/ShaderSystem.tests.ts index 396a4d26f2..3861a2fab2 100644 --- a/packages/core/test/ShaderSystem.tests.ts +++ b/packages/core/test/ShaderSystem.tests.ts @@ -4,7 +4,7 @@ import { expect } from 'chai'; skipHello(); -describe('ShaderSystem', function () +describe('ShaderSystem', () => { const vertexSrc = ` attribute vec2 aVertexPosition; @@ -34,7 +34,7 @@ void main() { }`; - function createTexture(w, h) + function createTexture(w: number, h: number) { const canvas = document.createElement('canvas'); const context = canvas.getContext('2d'); @@ -47,20 +47,21 @@ void main() { return new BaseTexture(new CanvasResource(canvas)); } - before(function () + let renderer: Renderer; + + before(() => { - this.renderer = new Renderer(); + renderer = new Renderer(); }); - after(function () + after(() => { - this.renderer.destroy(); - this.renderer = null; + renderer.destroy(); + renderer = null; }); - it('should set textures in different groups to different locations', function () + it('should set textures in different groups to different locations', () => { - const renderer = this.renderer; const texture1 = createTexture(10, 10); const texture2 = createTexture(20, 20); diff --git a/packages/core/test/Texture.tests.ts b/packages/core/test/Texture.tests.ts index e376c048f4..07426a3730 100644 --- a/packages/core/test/Texture.tests.ts +++ b/packages/core/test/Texture.tests.ts @@ -1,8 +1,9 @@ import { BaseTextureCache, TextureCache } from '@pixi/utils'; import { Rectangle, Point } from '@pixi/math'; -import { BaseTexture, Texture } from '@pixi/core'; +import { BaseTexture, ImageResource, Texture } from '@pixi/core'; import { settings } from '@pixi/settings'; import { expect } from 'chai'; +import path from 'path'; const URL = 'foo.png'; const NAME = 'foo'; @@ -19,9 +20,14 @@ function cleanCache() delete TextureCache[NAME2]; } -describe('Texture', function () +interface PixiCanvas extends HTMLCanvasElement { - it('should register Texture from Loader', function (done) + _pixiId: string; +} + +describe('Texture', () => +{ + it('should register Texture from Loader', (done) => { cleanCache(); @@ -32,7 +38,7 @@ describe('Texture', function () Texture.fromLoader(image, URL, NAME).then((texture) => { - expect(texture.baseTexture.resource.url).to.equal('foo.png'); + expect((texture.baseTexture.resource as ImageResource).url).to.equal('foo.png'); expect(TextureCache[NAME]).to.equal(texture); expect(BaseTextureCache[NAME]).to.equal(texture.baseTexture); expect(TextureCache[URL]).to.equal(texture); @@ -42,7 +48,7 @@ describe('Texture', function () }); }); - it('should remove Texture from cache on destroy', function () + it('should remove Texture from cache on destroy', () => { cleanCache(); @@ -60,14 +66,14 @@ describe('Texture', function () expect(TextureCache[NAME2]).to.equal(undefined); }); - it('should use pixiIdPrefix correctly', function () + it('should use pixiIdPrefix correctly', () => { cleanCache(); const canvas = document.createElement('canvas'); const texture = Texture.from(canvas, { pixiIdPrefix: 'unittest' }); - const baseTexture = texture.baseTexture; - const _pixiId = baseTexture.resource.source._pixiId; + const baseTexture = texture.baseTexture as BaseTexture; + const _pixiId = (baseTexture.resource.source as PixiCanvas)._pixiId; expect(_pixiId.indexOf('unittest_')).to.equal(0); expect(baseTexture.textureCacheIds.indexOf(_pixiId)).to.equal(0); @@ -77,7 +83,7 @@ describe('Texture', function () }); it('should be added to the texture cache correctly, ' - + 'and should remove only itself, not effecting the base texture and its cache', function () + + 'and should remove only itself, not effecting the base texture and its cache', () => { cleanCache(); @@ -96,7 +102,7 @@ describe('Texture', function () expect(TextureCache[NAME]).to.equal(undefined); }); - it('should remove Texture from entire cache using removeFromCache (by Texture instance)', function () + it('should remove Texture from entire cache using removeFromCache (by Texture instance)', () => { cleanCache(); @@ -115,7 +121,7 @@ describe('Texture', function () expect(TextureCache[NAME2]).to.equal(undefined); }); - it('should remove Texture from single cache entry using removeFromCache (by id)', function () + it('should remove Texture from single cache entry using removeFromCache (by id)', () => { cleanCache(); @@ -134,7 +140,7 @@ describe('Texture', function () expect(TextureCache[NAME2]).to.equal(texture); }); - it('should not remove Texture from cache if Texture instance has been replaced', function () + it('should not remove Texture from cache if Texture instance has been replaced', () => { cleanCache(); @@ -153,7 +159,7 @@ describe('Texture', function () expect(TextureCache[NAME]).to.equal(texture2); }); - it('destroying a destroyed texture should not throw an error', function () + it('destroying a destroyed texture should not throw an error', () => { const texture = new Texture(new BaseTexture()); @@ -161,7 +167,7 @@ describe('Texture', function () texture.destroy(true); }); - it('should not throw if base texture loaded after destroy', function () + it('should not throw if base texture loaded after destroy', () => { const base = new BaseTexture(); const texture = new Texture(base); @@ -170,13 +176,13 @@ describe('Texture', function () base.emit('loaded', base); }); - it('should clone a minimal texture', function () + it('should clone a minimal texture', () => { const baseTexture = new BaseTexture(); const frame = new Rectangle(0, 0, 10, 10); const texture = new Texture(baseTexture, frame); const clone = texture.clone(); - const toJSON = ({ x, y, width, height }) => ({ x, y, width, height }); + const toJSON = ({ x, y, width, height }: any) => ({ x, y, width, height }); expect(clone.baseTexture).to.equal(baseTexture); expect(clone.frame).to.not.equal(texture.frame); @@ -191,7 +197,7 @@ describe('Texture', function () texture.destroy(true); }); - it('should clone a texture', function () + it('should clone a texture', () => { const baseTexture = new BaseTexture(); const frame = new Rectangle(); @@ -201,7 +207,7 @@ describe('Texture', function () const anchor = new Point(1, 0.5); const texture = new Texture(baseTexture, frame, orig, trim, rotate, anchor); const clone = texture.clone(); - const toJSON = ({ x, y, width, height }) => ({ x, y, width, height }); + const toJSON = ({ x, y, width, height }: any) => ({ x, y, width, height }); expect(clone.baseTexture).to.equal(baseTexture); expect(clone.defaultAnchor).to.not.equal(texture.defaultAnchor); @@ -221,7 +227,7 @@ describe('Texture', function () texture.destroy(true); }); - it('should update frame if its backed by canvas that was resized', function () + it('should update frame if its backed by canvas that was resized', () => { const canvas = document.createElement('canvas'); @@ -255,7 +261,7 @@ describe('Texture', function () texture.destroy(true); }); - it('should update frame on baseTexture update only if user set it in constructor or in setter', function () + it('should update frame on baseTexture update only if user set it in constructor or in setter', () => { let baseTexture = new BaseTexture(); @@ -285,26 +291,7 @@ describe('Texture', function () texture.destroy(true); }); - it('should handle loading an invalid URL', function () - { - expect(() => Texture.fromURL('invalid/image.png')).throws; - }); - - it('should handle loading an cached URL', async function () - { - const url = 'noop.png'; - - TextureCache[url] = Texture.WHITE; - - expect(Texture.WHITE.valid).to.be.true; - - const texture = await Texture.fromURL(url); - - expect(texture).equals(Texture.WHITE); - delete TextureCache[url]; - }); - - it('should throw and error in strict from mode', function () + it('should throw and error in strict from mode', () => { const id = 'baz'; @@ -321,11 +308,69 @@ describe('Texture', function () const baseTexture = new BaseTexture(null, { width: 100, height: 100 }); const texture1 = Texture.from(baseTexture); - expect(baseTexture.cacheId).to.not.equal(null); + expect(baseTexture.cacheId).to.not.be.null; expect(BaseTextureCache[baseTexture.cacheId]).to.equal(baseTexture); expect(texture1.baseTexture).to.equal(baseTexture); expect(Texture.from(baseTexture)).to.equal(texture1); }); + + it('should accept an array of strings to create a cubemap', () => + { + const resources = path.join(process.cwd(), 'packages/core/test/resources/'); + + const texture = Texture.from([ + path.join(resources, 'cube-face.jpg'), + path.join(resources, 'cube-face.jpg'), + path.join(resources, 'cube-face.jpg'), + path.join(resources, 'cube-face.jpg'), + path.join(resources, 'cube-face.jpg'), + path.join(resources, 'cube-face.jpg')]); + + expect(texture).to.not.be.null + .and.to.not.be.undefined; + + expect(texture).to.be.an.instanceof(Texture); + }); + }); + + describe('Texture.fromURL', () => + { + it('should handle loading an invalid URL', () => + { + expect(() => Texture.fromURL('invalid/image.png')).throws; + }); + + it('should handle loading an cached URL', async () => + { + const url = 'noop.png'; + + TextureCache[url] = Texture.WHITE; + + expect(Texture.WHITE.valid).to.be.true; + + const texture = await Texture.fromURL(url); + + expect(texture).equals(Texture.WHITE); + delete TextureCache[url]; + }); + + it('should accept an array of strings to create a cubemap', async () => + { + const resources = path.join(__dirname, 'resources'); + + const texture = await Texture.fromURL([ + path.join(resources, 'cube-face.jpg'), + path.join(resources, 'cube-face.jpg'), + path.join(resources, 'cube-face.jpg'), + path.join(resources, 'cube-face.jpg'), + path.join(resources, 'cube-face.jpg'), + path.join(resources, 'cube-face.jpg')]); + + expect(texture).to.not.be.null + .and.to.not.be.undefined; + + expect(texture).to.be.an.instanceof(Texture); + }); }); }); diff --git a/packages/core/test/TextureSystem.tests.ts b/packages/core/test/TextureSystem.tests.ts index 181cc05f9c..84e029c098 100644 --- a/packages/core/test/TextureSystem.tests.ts +++ b/packages/core/test/TextureSystem.tests.ts @@ -2,9 +2,11 @@ import { WRAP_MODES, TYPES, FORMATS, SAMPLER_TYPES } from '@pixi/constants'; import { Renderer, Texture, BaseTexture } from '@pixi/core'; import { expect } from 'chai'; -describe('TextureSystem', function () +describe('TextureSystem', () => { - function createTempTexture(options) + let renderer: Renderer; + + function createTempTexture(options?: Parameters[1]) { const canvas = document.createElement('canvas'); @@ -14,84 +16,85 @@ describe('TextureSystem', function () return BaseTexture.from(canvas, options); } - beforeEach(function () + beforeEach(() => { - this.renderer = new Renderer(); - this.renderer.mask.enableScissor = true; + renderer = new Renderer(); + renderer.mask.enableScissor = true; }); - afterEach(function () + afterEach(() => { - this.renderer.destroy(); - this.renderer = null; + renderer.destroy(); + renderer = null; }); - it('should allow glTexture wrapMode=REPEAT for non-pow2 in webgl2', function () + it('should allow glTexture wrapMode=REPEAT for non-pow2 in webgl2', () => { const baseTex = createTempTexture(); baseTex.wrapMode = WRAP_MODES.REPEAT; - this.renderer.texture.webGLVersion = 2; - this.renderer.texture.bind(baseTex); + renderer.texture['webGLVersion'] = 2; + renderer.texture.bind(baseTex); - const glTex = baseTex._glTextures[this.renderer.CONTEXT_UID]; + const glTex = baseTex._glTextures[renderer.CONTEXT_UID]; expect(glTex).to.exist; expect(glTex.wrapMode).to.equal(WRAP_MODES.REPEAT); }); - it('should not allow glTexture wrapMode=REPEAT for non-pow2 in webgl1', function () + it('should not allow glTexture wrapMode=REPEAT for non-pow2 in webgl1', () => { const baseTex = createTempTexture(); baseTex.wrapMode = WRAP_MODES.REPEAT; - this.renderer.texture.webGLVersion = 1; - this.renderer.texture.bind(baseTex); + renderer.texture['webGLVersion'] = 1; + renderer.texture.bind(baseTex); - const glTex = baseTex._glTextures[this.renderer.CONTEXT_UID]; + const glTex = baseTex._glTextures[renderer.CONTEXT_UID]; expect(glTex).to.exist; expect(glTex.wrapMode).to.equal(WRAP_MODES.CLAMP); }); - it('should set internalFormat correctly for RGBA float textures', function () + it('should set internalFormat correctly for RGBA float textures', () => { const baseTex = createTempTexture({ type: TYPES.FLOAT, format: FORMATS.RGBA }); - this.renderer.texture.bind(baseTex); + renderer.texture.bind(baseTex); - const glTex = baseTex._glTextures[this.renderer.CONTEXT_UID]; + const glTex = baseTex._glTextures[renderer.CONTEXT_UID]; expect(glTex).to.not.be.null; - expect(glTex.internalFormat).to.equal(this.renderer.gl.RGBA32F); + expect(glTex.internalFormat).to.equal(renderer.gl.RGBA32F); }); - it('should set internalFormat correctly for red-channel float textures', function () + it('should set internalFormat correctly for red-channel float textures', () => { const baseTex = createTempTexture({ type: TYPES.FLOAT, format: FORMATS.RED }); - this.renderer.texture.bind(baseTex); + renderer.texture.bind(baseTex); - const glTex = baseTex._glTextures[this.renderer.CONTEXT_UID]; + const glTex = baseTex._glTextures[renderer.CONTEXT_UID]; expect(glTex).to.not.be.null; - expect(glTex.internalFormat).to.equal(this.renderer.gl.R32F); + expect(glTex.internalFormat).to.equal(renderer.gl.R32F); }); - it('should set internalFormat correctly for RGB FLOAT textures', function () + it('should set internalFormat correctly for RGB FLOAT textures', () => { const baseTex = createTempTexture({ type: TYPES.FLOAT, format: FORMATS.RGB }); - this.renderer.texture.bind(baseTex); + renderer.texture.bind(baseTex); - const glTex = baseTex._glTextures[this.renderer.CONTEXT_UID]; + const glTex = baseTex._glTextures[renderer.CONTEXT_UID]; expect(glTex).to.not.be.null; - expect(glTex.internalFormat).to.equal(this.renderer.gl.RGB32F); + expect(glTex.internalFormat).to.equal(renderer.gl.RGB32F); }); function createIntegerTexture() { + // @ts-expect-error --- const baseTexture = BaseTexture.fromBuffer(new Uint32Array([0, 0, 0, 0]), 1, 1); const oldUpload = baseTexture.resource.upload.bind(baseTexture); @@ -100,7 +103,7 @@ describe('TextureSystem', function () glTexture.samplerType = SAMPLER_TYPES.INT; if (renderer.context.webGLVersion === 2) { - glTexture.internalFormat = renderer.context.gl.RGBA32I; + glTexture.internalFormat = renderer.context['gl'].RGBA32I; } return oldUpload(renderer, baseTexture, glTexture); @@ -109,9 +112,9 @@ describe('TextureSystem', function () return baseTexture; } - it('should unbind textures with non-float samplerType for batching', function () + it('should unbind textures with non-float samplerType for batching', () => { - const textureSystem = this.renderer.texture; + const textureSystem = renderer.texture; const { boundTextures } = textureSystem; const sampleTex = createIntegerTexture(); const sampleTex2 = createIntegerTexture(); @@ -119,16 +122,16 @@ describe('TextureSystem', function () textureSystem.bind(Texture.WHITE.baseTexture, 0); textureSystem.bind(sampleTex, 1); textureSystem.bind(sampleTex2, 2); - expect(textureSystem.hasIntegerTextures).to.be.true; + expect(textureSystem['hasIntegerTextures']).to.be.true; textureSystem.ensureSamplerType(2); expect(boundTextures[0]).to.equal(Texture.WHITE.baseTexture); expect(boundTextures[1]).to.be.null; expect(boundTextures[2]).to.equal(sampleTex2); }); - it('should bind empty texture if texture is invalid', function () + it('should bind empty texture if texture is invalid', () => { - const textureSystem = this.renderer.texture; + const textureSystem = renderer.texture; expect(Texture.WHITE.baseTexture.valid).to.be.true; diff --git a/packages/core/test/UniformBuffer.tests.ts b/packages/core/test/UniformBuffer.tests.ts index 755a0ef475..9786d1a923 100644 --- a/packages/core/test/UniformBuffer.tests.ts +++ b/packages/core/test/UniformBuffer.tests.ts @@ -7,6 +7,7 @@ import { UniformGroup, generateProgram, getTestContext, + IRenderingContext, } from '@pixi/core'; import { expect } from 'chai'; import { skipHello } from '@pixi/utils'; @@ -36,9 +37,9 @@ const stubRenderer = { gl: {} }; -describe('UniformBuffer', function () +describe('UniformBuffer', () => { - it('should generate the correct correctly ordered UBO data', function () + it('should generate the correct correctly ordered UBO data', () => { const uniformData = { uAlpha: { @@ -105,7 +106,7 @@ describe('UniformBuffer', function () expect(usedUniformData3).to.deep.equal(expectedResult); }); - it('should generate correct UBO elements', function () + it('should generate correct UBO elements', () => { const uniformData = [ { name: 'uFloat', index: 1, type: 'float', size: 1, isArray: false, value: 0 }, @@ -178,7 +179,7 @@ describe('UniformBuffer', function () uRect: new Rectangle(0, 0, 33, 33), }); - const gl = getTestContext(); + const gl = getTestContext() as IRenderingContext; generateProgram(gl, shader.program); @@ -209,7 +210,7 @@ describe('UniformBuffer', function () it('should write arrays types to buffer correctly', () => { - const gl = getTestContext(); + const gl = getTestContext() as IRenderingContext; [ { @@ -547,7 +548,7 @@ describe('UniformBuffer', function () ]) }, - ].forEach((toTest, i) => + ].forEach((toTest) => { const fragmentSrc = ` #version 300 es diff --git a/packages/core/test/VideoResource.tests.ts b/packages/core/test/VideoResource.tests.ts index b98e5d3909..8b545c4fc5 100644 --- a/packages/core/test/VideoResource.tests.ts +++ b/packages/core/test/VideoResource.tests.ts @@ -2,16 +2,18 @@ import { VideoResource } from '@pixi/core'; import path from 'path'; import { expect } from 'chai'; -describe('VideoResource', function () +describe('VideoResource', () => { - before(function () + let videoUrl: string; + + before(() => { - this.videoUrl = path.resolve(__dirname, 'resources', 'small.mp4'); + videoUrl = path.resolve(__dirname, 'resources', 'small.mp4'); }); - it('should create new resource', function () + it('should create new resource', () => { - const resource = new VideoResource(this.videoUrl, { autoLoad: false }); + const resource = new VideoResource(videoUrl, { autoLoad: false }); expect(resource.width).to.equal(0); expect(resource.height).to.equal(0); @@ -21,9 +23,9 @@ describe('VideoResource', function () resource.destroy(); }); - it('should load new resource', function () + it('should load new resource', () => { - const resource = new VideoResource(this.videoUrl, { + const resource = new VideoResource(videoUrl, { autoLoad: false, autoPlay: false, }); @@ -38,33 +40,35 @@ describe('VideoResource', function () }); }); - it('should find correct video extension from Url', function () + it('should find correct video extension from Url', () => { const resource = new VideoResource('https://example.org/video.webm', { autoLoad: false, autoPlay: false, }); + // @ts-expect-error --- expect(resource.source.firstChild.type).to.be.equals('video/webm'); resource.destroy(); }); - it('should get video extension without being thrown by query string', function () + it('should get video extension without being thrown by query string', () => { const resource = new VideoResource('/test.mp4?123...', { autoLoad: false, autoPlay: false, }); + // @ts-expect-error --- expect(resource.source.firstChild.type).to.be.equals('video/mp4'); resource.destroy(); }); - it('should respect the updateFPS settings property and getter / setter', function () + it('should respect the updateFPS settings property and getter / setter', () => { - const resource = new VideoResource(this.videoUrl, { + const resource = new VideoResource(videoUrl, { autoLoad: false, autoPlay: false, updateFPS: 30, diff --git a/packages/core/test/autoDetectResource.tests.ts b/packages/core/test/autoDetectResource.tests.ts index 0534b5e857..30a799be4e 100644 --- a/packages/core/test/autoDetectResource.tests.ts +++ b/packages/core/test/autoDetectResource.tests.ts @@ -6,20 +6,20 @@ import { autoDetectResource, VideoResource, SVGResource } from '@pixi/core'; -describe('autoDetectResource', function () +describe('autoDetectResource', () => { - it('should have api', function () + it('should have api', () => { expect(autoDetectResource).to.be.a('function'); }); - it('should have installed resources', function () + it('should have installed resources', () => { expect(INSTALLED).to.be.an('array'); expect(INSTALLED.length).to.equal(8); }); - it('should auto-detect canvas element', function () + it('should auto-detect canvas element', () => { const canvas = document.createElement('canvas'); @@ -33,7 +33,7 @@ describe('autoDetectResource', function () expect(resource.height).to.equal(100); }); - it('should auto-detect video element', function () + it('should auto-detect video element', () => { const video = document.createElement('video'); const resource = autoDetectResource(video); @@ -41,7 +41,7 @@ describe('autoDetectResource', function () expect(resource).is.instanceOf(VideoResource); }); - it('should auto-detect image element', function () + it('should auto-detect image element', () => { const img = new Image(); const resource = autoDetectResource(img); @@ -49,7 +49,7 @@ describe('autoDetectResource', function () expect(resource).is.instanceOf(ImageResource); }); - it('should auto-detect image string', function () + it('should auto-detect image string', () => { const img = 'foo.png'; const resource = autoDetectResource(img); @@ -57,7 +57,7 @@ describe('autoDetectResource', function () expect(resource).is.instanceOf(ImageResource); }); - it('should auto-detect svg string', function () + it('should auto-detect svg string', () => { const svg = 'foo.svg'; const resource = autoDetectResource(svg); @@ -65,7 +65,7 @@ describe('autoDetectResource', function () expect(resource).is.instanceOf(SVGResource); }); - it('should auto-detect video Url', function () + it('should auto-detect video Url', () => { const video = 'foo.mp4'; const resource = autoDetectResource(video); @@ -73,14 +73,14 @@ describe('autoDetectResource', function () expect(resource).is.instanceOf(VideoResource); }); - it('should pass null', function () + it('should pass null', () => { const resource = autoDetectResource(null); expect(resource).to.equal(null); }); - it('should throw for unknown types', function () + it('should throw for unknown types', () => { expect(() => autoDetectResource({})).throws; expect(() => autoDetectResource(document.createElement('input'))).throws; diff --git a/packages/core/test/resources/cube-face.jpg b/packages/core/test/resources/cube-face.jpg new file mode 100644 index 0000000000..bfccd62b3f Binary files /dev/null and b/packages/core/test/resources/cube-face.jpg differ diff --git a/packages/display/package.json b/packages/display/package.json index 51c1640ac2..9f1023f255 100644 --- a/packages/display/package.json +++ b/packages/display/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/display", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/display.js", "module": "dist/esm/display.js", "bundle": "dist/browser/display.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/display.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/display.js" + } + } + }, "description": "Core display functionality", "author": "Mat Groves", "contributors": [ @@ -25,8 +38,8 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/math": "6.3.0", - "@pixi/settings": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/math": "6.4.2", + "@pixi/settings": "6.4.2", + "@pixi/utils": "6.4.2" } } diff --git a/packages/display/src/Bounds.ts b/packages/display/src/Bounds.ts index fff7c9da14..4cc0688aa9 100644 --- a/packages/display/src/Bounds.ts +++ b/packages/display/src/Bounds.ts @@ -7,7 +7,6 @@ import type { IPointData, Transform, Matrix } from '@pixi/math'; * * This could be called an Axis-Aligned Bounding Box. * It is not an actual shape. It is a mutable thing; no 'EMPTY' or those kind of problems. - * * @memberof PIXI */ export class Bounds @@ -45,8 +44,7 @@ export class Bounds /** * Checks if bounds are empty. - * - * @return - True if empty. + * @returns - True if empty. */ isEmpty(): boolean { @@ -65,7 +63,6 @@ export class Bounds /** * Can return Rectangle.EMPTY constant, either construct new rectangle, either use your rectangle * It is not guaranteed that it will return tempRect - * * @param rect - Temporary object will be used if AABB is not empty * @returns - A rectangle of the bounds */ @@ -88,7 +85,6 @@ export class Bounds /** * This function should be inlined when its possible. - * * @param point - The point to add. */ addPoint(point: IPointData): void @@ -99,7 +95,11 @@ export class Bounds this.maxY = Math.max(this.maxY, point.y); } - /** Adds a point, after transformed. This should be inlined when its possible. */ + /** + * Adds a point, after transformed. This should be inlined when its possible. + * @param matrix + * @param point + */ addPointMatrix(matrix: Matrix, point: IPointData): void { const { a, b, c, d, tx, ty } = matrix; @@ -115,7 +115,6 @@ export class Bounds /** * Adds a quad, not transformed - * * @param vertices - The verts to add. */ addQuad(vertices: Float32Array): void @@ -162,7 +161,6 @@ export class Bounds /** * Adds sprite frame, transformed. - * * @param transform - transform to apply * @param x0 - left X of frame * @param y0 - top Y of frame @@ -176,7 +174,6 @@ export class Bounds /** * Adds sprite frame, multiplied by matrix - * * @param matrix - matrix to apply * @param x0 - left X of frame * @param y0 - top Y of frame @@ -234,7 +231,6 @@ export class Bounds /** * Adds screen vertices from array - * * @param vertexData - calculated vertices * @param beginOffset - begin offset * @param endOffset - end offset, excluded @@ -265,7 +261,6 @@ export class Bounds /** * Add an array of mesh vertices - * * @param transform - mesh transform * @param vertices - mesh coordinates in array * @param beginOffset - begin offset @@ -278,7 +273,6 @@ export class Bounds /** * Add an array of mesh vertices. - * * @param matrix - mesh matrix * @param vertices - mesh coordinates in array * @param beginOffset - begin offset @@ -322,7 +316,6 @@ export class Bounds /** * Adds other {@link Bounds}. - * * @param bounds - The Bounds to be added */ addBounds(bounds: Bounds): void @@ -340,7 +333,6 @@ export class Bounds /** * Adds other Bounds, masked with Bounds. - * * @param bounds - The Bounds to be added. * @param mask - TODO */ @@ -367,7 +359,6 @@ export class Bounds /** * Adds other Bounds, multiplied by matrix. Bounds shouldn't be empty. - * * @param bounds - other bounds * @param matrix - multiplicator */ @@ -378,7 +369,6 @@ export class Bounds /** * Adds other Bounds, masked with Rectangle. - * * @param bounds - TODO * @param area - TODO */ @@ -406,7 +396,6 @@ export class Bounds /** * Pads bounds object, making it grow in all directions. * If paddingY is omitted, both paddingX and paddingY will be set to paddingX. - * * @param paddingX - The horizontal padding amount. * @param paddingY - The vertical padding amount. */ @@ -423,7 +412,6 @@ export class Bounds /** * Adds padded frame. (x0, y0) should be strictly less than (x1, y1) - * * @param x0 - left X of frame * @param y0 - top Y of frame * @param x1 - right X of frame diff --git a/packages/display/src/Container.ts b/packages/display/src/Container.ts index e56b19b95b..a742121197 100644 --- a/packages/display/src/Container.ts +++ b/packages/display/src/Container.ts @@ -51,14 +51,12 @@ export interface Container extends GlobalMixins.Container, DisplayObject {} * .drawCircle(sprite.width / 2, sprite.height / 2, Math.min(sprite.width, sprite.height) / 2) * .endFill(); * ``` - * * @memberof PIXI */ export class Container extends DisplayObject { /** * The array of children of this container. - * * @readonly */ public readonly children: DisplayObject[]; @@ -73,7 +71,6 @@ export class Container extends DisplayObject * * Also be aware of that this may not work nicely with the addChildAt() function, * as the zIndex sorting may cause the child to automatically sorted to another position. - * * @see PIXI.settings.SORTABLE_CHILDREN */ public sortableChildren: boolean; @@ -100,7 +97,6 @@ export class Container extends DisplayObject /** * Fired when a DisplayObject is added to this Container. - * * @event PIXI.Container#childAdded * @param {PIXI.DisplayObject} child - The child added to the Container. * @param {PIXI.Container} container - The container that added the child. @@ -109,7 +105,6 @@ export class Container extends DisplayObject /** * Fired when a DisplayObject is removed from this Container. - * * @event PIXI.DisplayObject#removedFrom * @param {PIXI.DisplayObject} child - The child removed from the Container. * @param {PIXI.Container} container - The container that removed removed the child. @@ -117,7 +112,10 @@ export class Container extends DisplayObject */ } - /** Overridable method that can be used by Container subclasses whenever the children array is modified. */ + /** + * Overridable method that can be used by Container subclasses whenever the children array is modified. + * @param _length + */ protected onChildrenChange(_length?: number): void { /* empty */ @@ -127,9 +125,8 @@ export class Container extends DisplayObject * Adds one or more children to the container. * * Multiple items can be added like so: `myContainer.addChild(thingOne, thingTwo, thingThree)` - * * @param {...PIXI.DisplayObject} children - The DisplayObject(s) to add to the container - * @return {PIXI.DisplayObject} - The first child that was added. + * @returns {PIXI.DisplayObject} - The first child that was added. */ addChild(...children: T): T[0] { @@ -175,10 +172,9 @@ export class Container extends DisplayObject /** * Adds a child to the container at a specified index. If the index is out of bounds an error will be thrown - * * @param {PIXI.DisplayObject} child - The child to add * @param {number} index - The index to place the child in - * @return {PIXI.DisplayObject} The child that was added. + * @returns {PIXI.DisplayObject} The child that was added. */ addChildAt(child: T, index: number): T { @@ -213,7 +209,6 @@ export class Container extends DisplayObject /** * Swaps the position of 2 Display Objects within this container. - * * @param child - First display object to swap * @param child2 - Second display object to swap */ @@ -234,9 +229,8 @@ export class Container extends DisplayObject /** * Returns the index position of a child DisplayObject instance - * * @param child - The DisplayObject instance to identify - * @return - The index position of the child display object to identify + * @returns - The index position of the child display object to identify */ getChildIndex(child: DisplayObject): number { @@ -252,7 +246,6 @@ export class Container extends DisplayObject /** * Changes the position of an existing child in the display object container - * * @param child - The child DisplayObject instance for which you want to change the index number * @param index - The resulting index number for the child display object */ @@ -273,9 +266,8 @@ export class Container extends DisplayObject /** * Returns the child at the specified index - * * @param index - The index to get the child at - * @return - The child at the given index, if any. + * @returns - The child at the given index, if any. */ getChildAt(index: number): DisplayObject { @@ -289,9 +281,8 @@ export class Container extends DisplayObject /** * Removes one or more children from the container. - * * @param {...PIXI.DisplayObject} children - The DisplayObject(s) to remove - * @return {PIXI.DisplayObject} The first child that was removed. + * @returns {PIXI.DisplayObject} The first child that was removed. */ removeChild(...children: T): T[0] { @@ -330,9 +321,8 @@ export class Container extends DisplayObject /** * Removes a child from the specified index position. - * * @param index - The index to get the child from - * @return The child that was removed. + * @returns The child that was removed. */ removeChildAt(index: number): DisplayObject { @@ -356,7 +346,6 @@ export class Container extends DisplayObject /** * Removes all children from this container that are within the begin and end indexes. - * * @param beginIndex - The beginning position. * @param endIndex - The ending position. Default value is size of the container. * @returns - List of removed children @@ -501,11 +490,10 @@ export class Container extends DisplayObject * * Calling `getLocalBounds` may invalidate the `_bounds` of the whole subtree below. If using it inside a render() * call, it is advised to call `getBounds()` immediately after to recalculate the world bounds of the subtree. - * * @param rect - Optional rectangle to store the result of the bounds calculation. * @param skipChildrenUpdate - Setting to `true` will stop re-calculation of children transforms, * it was default behaviour of pixi 4.0-5.2 and caused many problems to users. - * @return - The rectangular bounding area. + * @returns - The rectangular bounding area. */ public getLocalBounds(rect?: Rectangle, skipChildrenUpdate = false): Rectangle { @@ -530,7 +518,6 @@ export class Container extends DisplayObject /** * Recalculates the content bounds of this object. This should be overriden to * calculate the bounds of this specific object (not including children). - * * @protected */ protected _calculateBounds(): void @@ -540,7 +527,6 @@ export class Container extends DisplayObject /** * Renders this object and its children with culling. - * * @protected * @param {PIXI.Renderer} renderer - The renderer */ @@ -625,7 +611,6 @@ export class Container extends DisplayObject * The [renderAdvanced]{@link PIXI.Container#renderAdvanced} method is internally used when when masking or * filtering is applied on a container. This does, however, break batching and can affect performance when * masking and filtering is applied extensively throughout the scene graph. - * * @param renderer - The renderer */ render(renderer: Renderer): void @@ -658,7 +643,6 @@ export class Container extends DisplayObject /** * Render the object using the WebGL renderer and advanced features. - * * @param renderer - The renderer */ protected renderAdvanced(renderer: Renderer): void @@ -736,8 +720,7 @@ export class Container extends DisplayObject /** * To be overridden by the subclasses. - * - * @param renderer - The renderer + * @param _renderer - The renderer */ protected _render(_renderer: Renderer): void // eslint-disable-line no-unused-vars { @@ -747,7 +730,6 @@ export class Container extends DisplayObject /** * Removes all internal references and listeners as well as removes children from the display list. * Do not use a Container after calling `destroy`. - * * @param options - Options parameter. A boolean will act as if all options * have been set to that value * @param {boolean} [options.children=false] - if set to true, all the children will have their destroy @@ -757,7 +739,7 @@ export class Container extends DisplayObject * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true * Should it destroy the base texture of the child sprite */ - destroy(options?: IDestroyOptions|boolean): void + destroy(options?: IDestroyOptions | boolean): void { super.destroy(); @@ -824,7 +806,6 @@ export class Container extends DisplayObject /** * Container default updateTransform, does update children of container. * Will crash if there's no parent element. - * * @memberof PIXI.Container# * @method containerUpdateTransform */ diff --git a/packages/display/src/DisplayObject.ts b/packages/display/src/DisplayObject.ts index d9a8269069..d0f425d556 100644 --- a/packages/display/src/DisplayObject.ts +++ b/packages/display/src/DisplayObject.ts @@ -7,7 +7,8 @@ import type { Filter, MaskData, Renderer } from '@pixi/core'; import type { IPointData, ObservablePoint } from '@pixi/math'; import type { Dict } from '@pixi/utils'; -export interface IDestroyOptions { +export interface IDestroyOptions +{ children?: boolean; texture?: boolean; baseTexture?: boolean; @@ -198,7 +199,6 @@ export interface DisplayObject extends Omit void; /** * Mixes all enumerable properties and methods from a source object to DisplayObject. - * * @param source - The source of properties and methods to mix in. */ static mixin(source: Dict): void @@ -395,7 +388,6 @@ export abstract class DisplayObject extends EventEmitter /** * Fired when this DisplayObject is added to a Container. - * * @instance * @event added * @param {PIXI.Container} container - The container added to. @@ -403,15 +395,14 @@ export abstract class DisplayObject extends EventEmitter /** * Fired when this DisplayObject is removed from a Container. - * * @instance * @event removed * @param {PIXI.Container} container - The container removed from. */ /** - * Fired when this DisplayObject is destroyed. - * + * Fired when this DisplayObject is destroyed. This event is emitted once + * destroy is finished. * @instance * @event destroyed */ @@ -429,15 +420,11 @@ export abstract class DisplayObject extends EventEmitter /** * Renders the object using the WebGL renderer. - * * @param renderer - The renderer. */ abstract render(renderer: Renderer): void; - /** - * Recursively updates transform of all objects from the root to this one - * internal function for toLocal() - */ + /** Recursively updates transform of all objects from the root to this one internal function for toLocal() */ protected _recursivePostUpdateTransform(): void { if (this.parent) @@ -451,11 +438,7 @@ export abstract class DisplayObject extends EventEmitter } } - /** - * Updates the object transform for rendering. - * - * TODO - Optimization pass! - */ + /** Updates the object transform for rendering. TODO - Optimization pass! */ updateTransform(): void { this._boundsID++; @@ -476,8 +459,8 @@ export abstract class DisplayObject extends EventEmitter * calling `getBounds` on each object in a subtree will cause the total cost to increase quadratically as * its height increases. * - * * The transforms of all objects in a container's **subtree** and of all **ancestors** are updated. - * * The world bounds of all display objects in a container's **subtree** will also be recalculated. + * The transforms of all objects in a container's **subtree** and of all **ancestors** are updated. + * The world bounds of all display objects in a container's **subtree** will also be recalculated. * * The `_bounds` object stores the last calculation of the bounds. You can use to entirely skip bounds * calculation if needed. @@ -493,12 +476,11 @@ export abstract class DisplayObject extends EventEmitter * `getBounds` should be called with `skipUpdate` equal to `true` in a render() call. This is because the transforms * are guaranteed to be update-to-date. In fact, recalculating inside a render() call may cause corruption in certain * cases. - * * @param skipUpdate - Setting to `true` will stop the transforms of the scene graph from * being updated. This means the calculation returned MAY be out of date BUT will give you a * nice performance boost. * @param rect - Optional rectangle to store the result of the bounds calculation. - * @return - The minimum axis-aligned rectangle in world space that fits around this object. + * @returns - The minimum axis-aligned rectangle in world space that fits around this object. */ getBounds(skipUpdate?: boolean, rect?: Rectangle): Rectangle { @@ -538,9 +520,8 @@ export abstract class DisplayObject extends EventEmitter /** * Retrieves the local bounds of the displayObject as a rectangle object. - * * @param rect - Optional rectangle to store the result of the bounds calculation. - * @return - The rectangular bounding area. + * @returns - The rectangular bounding area. */ getLocalBounds(rect?: Rectangle): Rectangle { @@ -583,12 +564,11 @@ export abstract class DisplayObject extends EventEmitter /** * Calculates the global position of the display object. - * * @param position - The world origin to calculate from. * @param point - A Point object in which to store the value, optional * (otherwise will create a new Point). * @param skipUpdate - Should we skip the update transform. - * @return - A point object representing the position of this object. + * @returns - A point object representing the position of this object. */ toGlobal

(position: IPointData, point?: P, skipUpdate = false): P { @@ -617,13 +597,12 @@ export abstract class DisplayObject extends EventEmitter /** * Calculates the local position of the display object relative to another point. - * * @param position - The world origin to calculate from. * @param from - The DisplayObject to calculate the global position from. * @param point - A Point object in which to store the value, optional * (otherwise will create a new Point). * @param skipUpdate - Should we skip the update transform - * @return - A point object representing the position of this object + * @returns - A point object representing the position of this object */ toLocal

(position: IPointData, from?: DisplayObject, point?: P, skipUpdate?: boolean): P { @@ -657,9 +636,8 @@ export abstract class DisplayObject extends EventEmitter /** * Set the parent Container of this DisplayObject. - * * @param container - The Container to add this DisplayObject to. - * @return - The Container that this DisplayObject was added to. + * @returns - The Container that this DisplayObject was added to. */ setParent(container: Container): Container { @@ -675,7 +653,6 @@ export abstract class DisplayObject extends EventEmitter /** * Convenience function to set the position, scale, skew and pivot at once. - * * @param x - The X position * @param y - The Y position * @param scaleX - The X scale value @@ -685,7 +662,7 @@ export abstract class DisplayObject extends EventEmitter * @param skewY - The Y skew value * @param pivotX - The X pivot value * @param pivotY - The Y pivot value - * @return - The DisplayObject instance + * @returns - The DisplayObject instance */ setTransform(x = 0, y = 0, scaleX = 1, scaleY = 1, rotation = 0, skewX = 0, skewY = 0, pivotX = 0, pivotY = 0): this { @@ -707,15 +684,15 @@ export abstract class DisplayObject extends EventEmitter * remove the display object from its parent Container as well as remove * all current event listeners and internal references. Do not use a DisplayObject * after calling `destroy()`. + * @param _options */ - destroy(_options?: IDestroyOptions|boolean): void + destroy(_options?: IDestroyOptions | boolean): void { if (this.parent) { this.parent.removeChild(this); } - this.emit('destroyed'); - this.removeAllListeners(); + this._destroyed = true; this.transform = null; this.parent = null; @@ -730,7 +707,8 @@ export abstract class DisplayObject extends EventEmitter this.interactive = false; this.interactiveChildren = false; - this._destroyed = true; + this.emit('destroyed'); + this.removeAllListeners(); } /** @@ -756,7 +734,6 @@ export abstract class DisplayObject extends EventEmitter * elem.updateTransform(); * elem.disableTempParent(cacheParent); * ``` - * * @returns - current parent */ enableTempParent(): Container @@ -770,7 +747,6 @@ export abstract class DisplayObject extends EventEmitter /** * Pair method for `enableTempParent` - * * @param cacheParent - Actual parent of element */ disableTempParent(cacheParent: Container): void @@ -808,7 +784,6 @@ export abstract class DisplayObject extends EventEmitter /** * Current transform of the object based on world (parent) factors. - * * @readonly */ get worldTransform(): Matrix @@ -818,7 +793,6 @@ export abstract class DisplayObject extends EventEmitter /** * Current transform of the object based on local factors: position, scale, other stuff. - * * @readonly */ get localTransform(): Matrix @@ -828,15 +802,14 @@ export abstract class DisplayObject extends EventEmitter /** * The coordinate of the object relative to the local coordinates of the parent. - * - * @since PixiJS 4 + * @since 4.0.0 */ get position(): ObservablePoint { return this.transform.position; } - set position(value: ObservablePoint) + set position(value: IPointData) { this.transform.position.copyFrom(value); } @@ -845,15 +818,14 @@ export abstract class DisplayObject extends EventEmitter * The scale factors of this object along the local coordinate axes. * * The default scale is (1, 1). - * - * @since PixiJS 4 + * @since 4.0.0 */ get scale(): ObservablePoint { return this.transform.scale; } - set scale(value: ObservablePoint) + set scale(value: IPointData) { this.transform.scale.copyFrom(value); } @@ -863,30 +835,28 @@ export abstract class DisplayObject extends EventEmitter * is the projection of `pivot` in the parent's local space. * * By default, the pivot is the origin (0, 0). - * - * @since PixiJS 4 + * @since 4.0.0 */ get pivot(): ObservablePoint { return this.transform.pivot; } - set pivot(value: ObservablePoint) + set pivot(value: IPointData) { this.transform.pivot.copyFrom(value); } /** * The skew factor for the object in radians. - * - * @since PixiJS 4 + * @since 4.0.0 */ get skew(): ObservablePoint { return this.transform.skew; } - set skew(value: ObservablePoint) + set skew(value: IPointData) { this.transform.skew.copyFrom(value); } @@ -925,7 +895,6 @@ export abstract class DisplayObject extends EventEmitter * If a container has the sortableChildren property set to true, children will be automatically * sorted by zIndex value; a higher value will mean it will be moved towards the end of the array, * and thus rendered on top of other display objects within the same container. - * * @see PIXI.Container#sortableChildren */ get zIndex(): number @@ -944,7 +913,6 @@ export abstract class DisplayObject extends EventEmitter /** * Indicates if the object is globally visible. - * * @readonly */ get worldVisible(): boolean @@ -968,10 +936,11 @@ export abstract class DisplayObject extends EventEmitter * Sets a mask for the displayObject. A mask is an object that limits the visibility of an * object to the shape of the mask applied to it. In PixiJS a regular mask must be a * {@link PIXI.Graphics} or a {@link PIXI.Sprite} object. This allows for much faster masking in canvas as it - * utilities shape clipping. To remove a mask, set this property to `null`. + * utilities shape clipping. Furthermore, a mask of an object must be in the subtree of its parent. + * Otherwise, `getLocalBounds` may calculate incorrect bounds, which makes the container's width and height wrong. + * To remove a mask, set this property to `null`. * * For sprite mask both alpha and red channel are used. Black mask is the same as transparent mask. - * * @example * const graphics = new PIXI.Graphics(); * graphics.beginFill(0xFF3300); @@ -980,15 +949,14 @@ export abstract class DisplayObject extends EventEmitter * * const sprite = new PIXI.Sprite(texture); * sprite.mask = graphics; - * * @todo At the moment, PIXI.CanvasRenderer doesn't support PIXI.Sprite as mask. */ - get mask(): Container|MaskData|null + get mask(): Container | MaskData | null { return this._mask; } - set mask(value: Container|MaskData|null) + set mask(value: Container | MaskData | null) { if (this._mask === value) { @@ -1039,7 +1007,6 @@ export class TemporaryDisplayObject extends DisplayObject /** * DisplayObject default updateTransform, does not update children of container. * Will crash if there's no parent element. - * * @memberof PIXI.DisplayObject# * @method displayObjectUpdateTransform */ diff --git a/packages/display/src/settings.ts b/packages/display/src/settings.ts index 5de2e34327..1368a2dc1e 100644 --- a/packages/display/src/settings.ts +++ b/packages/display/src/settings.ts @@ -11,7 +11,6 @@ import { settings } from '@pixi/settings'; * * Also be aware of that this may not work nicely with the addChildAt() function, * as the zIndex sorting may cause the child to automatically sorted to another position. - * * @static * @constant * @name SORTABLE_CHILDREN diff --git a/packages/display/test/Container.tests.ts b/packages/display/test/Container.tests.ts index 73dc10426d..28fcd11d53 100644 --- a/packages/display/test/Container.tests.ts +++ b/packages/display/test/Container.tests.ts @@ -6,47 +6,50 @@ import { Rectangle } from '@pixi/math'; import sinon from 'sinon'; import { expect } from 'chai'; -function testAddChild(fn) +function testAddChild(fn: any) { - return function () + return () => { - fn(function (container, obj) + fn((container: Container, obj: Container) => { container.addChild(obj); }); - fn(function (container, obj) + fn((container: Container, obj: Container) => { + // TODO: is this used? + // @ts-expect-error - legacy test container.addChildAt(obj); }); }; } -function testRemoveChild(fn) +function testRemoveChild(fn: any) { - return function () + return () => { - fn(function (container, obj) + fn((container: Container, obj: Container) => { container.removeChild(obj); }); - fn(function (container, obj) + fn((container: Container, obj: Container) => { container.removeChildAt(container.children.indexOf(obj)); }); - fn(function (container, obj) + fn((container: Container, obj: Container) => { container.removeChildren(container.children.indexOf(obj), container.children.indexOf(obj) + 1); }); }; } -describe('Container', function () +describe('Container', () => { - describe('parent', function () + describe('parent', () => { - it('should be present when adding children to Container', function () + it('should be present when adding children to Container', () => { const container = new Container(); + // @ts-expect-error - instantiating DisplayObject const child = new DisplayObject(); expect(container.children.length).to.be.equals(0); @@ -56,24 +59,25 @@ describe('Container', function () }); }); - describe('events', function () + describe('events', () => { - it('should trigger "added", "removed", "childAdded", and "childRemoved" events on itself and children', function () + it('should trigger "added", "removed", "childAdded", and "childRemoved" events on itself and children', () => { const container = new Container(); + // @ts-expect-error - instantiating DisplayObject const child = new DisplayObject(); let triggeredAdded = false; let triggeredRemoved = false; let triggeredChildAdded = false; let triggeredChildRemoved = false; - child.on('added', (to) => + child.on('added', (to: Container) => { triggeredAdded = true; expect(container.children.length).to.be.equals(1); expect(child.parent).to.be.equals(to); }); - child.on('removed', (from) => + child.on('removed', (from: Container) => { triggeredRemoved = true; expect(container.children.length).to.be.equals(0); @@ -108,22 +112,24 @@ describe('Container', function () }); }); - describe('addChild', function () + describe('addChild', () => { - it('should remove from current parent', function () + it('should remove from current parent', () => { const parent = new Container(); const container = new Container(); + // @ts-expect-error - instantiating DisplayObject const child = new DisplayObject(); assertRemovedFromParent(parent, container, child, () => { container.addChild(child); }); }); - it('should call onChildrenChange', function () + it('should call onChildrenChange', () => { const container = new Container(); + // @ts-expect-error - instantiating DisplayObject const child = new DisplayObject(); - const spy = sinon.spy(container, 'onChildrenChange'); + const spy = sinon.spy(container, 'onChildrenChange' as keyof Container); container.addChild(child); @@ -131,42 +137,45 @@ describe('Container', function () expect(spy).to.have.been.calledWith(0); }); - it('should flag child transform and container bounds for recalculation', testAddChild(function (mockAddChild) - { - const container = new Container(); - const child = new Container(); + it('should flag child transform and container bounds for recalculation', testAddChild( + (mockAddChild: (container: Container, child: Container) => void) => + { + const container = new Container(); + const child = new Container(); - container.getBounds(); - child.getBounds(); + container.getBounds(); + child.getBounds(); - const boundsID = container._boundsID; - const childParentID = child.transform._parentID; + const boundsID = container['_boundsID']; + const childParentID = child.transform._parentID; - mockAddChild(container, child); + mockAddChild(container, child); - expect(boundsID).to.not.be.equals(container._boundsID); - expect(childParentID).to.not.be.equals(child.transform._parentID); - })); + expect(boundsID).to.not.be.equals(container['_boundsID']); + expect(childParentID).to.not.be.equals(child.transform._parentID); + })); }); - describe('removeChildAt', function () + describe('removeChildAt', () => { - it('should remove from current parent', function () + it('should remove from current parent', () => { const parent = new Container(); + // @ts-expect-error - instantiating DisplayObject const child = new DisplayObject(); assertRemovedFromParent(parent, null, child, () => { parent.removeChildAt(0); }); }); - it('should call onChildrenChange', function () + it('should call onChildrenChange', () => { const container = new Container(); + // @ts-expect-error - instantiating DisplayObject const child = new DisplayObject(); container.addChild(child); - const spy = sinon.spy(container, 'onChildrenChange'); + const spy = sinon.spy(container, 'onChildrenChange' as keyof Container); container.removeChildAt(0); expect(spy).to.have.been.called; @@ -174,13 +183,15 @@ describe('Container', function () }); }); - describe('addChildAt', function () + describe('addChildAt', () => { - it('should allow placements at start', function () + it('should allow placements at start', () => { const container = new Container(); + // @ts-expect-error - instantiating DisplayObject const child = new DisplayObject(); + // @ts-expect-error - instantiating DisplayObject container.addChild(new DisplayObject()); container.addChildAt(child, 0); @@ -188,11 +199,13 @@ describe('Container', function () expect(container.children[0]).to.be.equals(child); }); - it('should allow placements at end', function () + it('should allow placements at end', () => { const container = new Container(); + // @ts-expect-error - instantiating DisplayObject const child = new DisplayObject(); + // @ts-expect-error - instantiating DisplayObject container.addChild(new DisplayObject()); container.addChildAt(child, 1); @@ -200,34 +213,39 @@ describe('Container', function () expect(container.children[1]).to.be.equals(child); }); - it('should throw on out-of-bounds', function () + it('should throw on out-of-bounds', () => { const container = new Container(); + // @ts-expect-error - instantiating DisplayObject const child = new DisplayObject(); + // @ts-expect-error - instantiating DisplayObject container.addChild(new DisplayObject()); expect(() => container.addChildAt(child, -1)).to.throw('The index -1 supplied is out of bounds 1'); expect(() => container.addChildAt(child, 2)).to.throw('The index 2 supplied is out of bounds 1'); }); - it('should remove from current parent', function () + it('should remove from current parent', () => { const parent = new Container(); const container = new Container(); + // @ts-expect-error - instantiating DisplayObject const child = new DisplayObject(); assertRemovedFromParent(parent, container, child, () => { container.addChildAt(child, 0); }); }); - it('should call onChildrenChange', function () + it('should call onChildrenChange', () => { const container = new Container(); + // @ts-expect-error - instantiating DisplayObject const child = new DisplayObject(); + // @ts-expect-error - instantiating DisplayObject container.addChild(new DisplayObject()); - const spy = sinon.spy(container, 'onChildrenChange'); + const spy = sinon.spy(container, 'onChildrenChange' as keyof Container); container.addChildAt(child, 0); @@ -236,24 +254,28 @@ describe('Container', function () }); }); - describe('removeChild', function () + describe('removeChild', () => { - it('should ignore non-children', function () + it('should ignore non-children', () => { const container = new Container(); + // @ts-expect-error - instantiating DisplayObject const child = new DisplayObject(); container.addChild(child); + // @ts-expect-error - instantiating DisplayObject container.removeChild(new DisplayObject()); expect(container.children.length).to.be.equals(1); }); - it('should remove all children supplied', function () + it('should remove all children supplied', () => { const container = new Container(); + // @ts-expect-error - instantiating DisplayObject const child1 = new DisplayObject(); + // @ts-expect-error - instantiating DisplayObject const child2 = new DisplayObject(); container.addChild(child1, child2); @@ -265,14 +287,15 @@ describe('Container', function () expect(container.children.length).to.be.equals(0); }); - it('should call onChildrenChange', function () + it('should call onChildrenChange', () => { const container = new Container(); + // @ts-expect-error - instantiating DisplayObject const child = new DisplayObject(); container.addChild(child); - const spy = sinon.spy(container, 'onChildrenChange'); + const spy = sinon.spy(container, 'onChildrenChange' as keyof Container); container.removeChild(child); @@ -280,39 +303,43 @@ describe('Container', function () expect(spy).to.have.been.calledWith(0); }); - it('should flag transform for recalculation', testRemoveChild(function (mockRemoveChild) - { - const container = new Container(); - const child = new Container(); + it('should flag transform for recalculation', testRemoveChild( + (mockRemoveChild: (c: Container, b: Container) => void) => + { + const container = new Container(); + const child = new Container(); - container.addChild(child); - container.getBounds(); + container.addChild(child); + container.getBounds(); - const childParentID = child.transform._parentID; - const boundsID = container._boundsID; + const childParentID = child.transform._parentID; + const boundsID = container['_boundsID']; - mockRemoveChild(container, child); + mockRemoveChild(container, child); - expect(childParentID).to.not.be.equals(child.transform._parentID); - expect(boundsID).to.not.be.equals(container._boundsID); - })); + expect(childParentID).to.not.be.equals(child.transform._parentID); + expect(boundsID).to.not.be.equals(container['_boundsID']); + })); }); - describe('getChildIndex', function () + describe('getChildIndex', () => { - it('should return the correct index', function () + it('should return the correct index', () => { const container = new Container(); + // @ts-expect-error - instantiating DisplayObject const child = new DisplayObject(); + // @ts-expect-error - instantiating DisplayObject container.addChild(new DisplayObject(), child, new DisplayObject()); expect(container.getChildIndex(child)).to.be.equals(1); }); - it('should throw when child does not exist', function () + it('should throw when child does not exist', () => { const container = new Container(); + // @ts-expect-error - instantiating DisplayObject const child = new DisplayObject(); expect(() => container.getChildIndex(child)) @@ -320,9 +347,9 @@ describe('Container', function () }); }); - describe('getChildAt', function () + describe('getChildAt', () => { - it('should throw when out-of-bounds', function () + it('should throw when out-of-bounds', () => { const container = new Container(); @@ -331,11 +358,12 @@ describe('Container', function () }); }); - describe('setChildIndex', function () + describe('setChildIndex', () => { - it('should throw on out-of-bounds', function () + it('should throw on out-of-bounds', () => { const container = new Container(); + // @ts-expect-error - instantiating DisplayObject const child = new DisplayObject(); container.addChild(child); @@ -344,22 +372,26 @@ describe('Container', function () expect(() => container.setChildIndex(child, 1)).to.throw('The index 1 supplied is out of bounds 1'); }); - it('should throw when child does not belong', function () + it('should throw when child does not belong', () => { const container = new Container(); + // @ts-expect-error - instantiating DisplayObject const child = new DisplayObject(); + // @ts-expect-error - instantiating DisplayObject container.addChild(new DisplayObject()); expect(() => container.setChildIndex(child, 0)) .to.throw('The supplied DisplayObject must be a child of the caller'); }); - it('should set index', function () + it('should set index', () => { const container = new Container(); + // @ts-expect-error - instantiating DisplayObject const child = new DisplayObject(); + // @ts-expect-error - instantiating DisplayObject container.addChild(child, new DisplayObject(), new DisplayObject()); expect(container.children.indexOf(child)).to.be.equals(0); @@ -373,14 +405,16 @@ describe('Container', function () expect(container.children.indexOf(child)).to.be.equals(0); }); - it('should call onChildrenChange', function () + it('should call onChildrenChange', () => { const container = new Container(); + // @ts-expect-error - instantiating DisplayObject const child = new DisplayObject(); + // @ts-expect-error - instantiating DisplayObject container.addChild(child, new DisplayObject()); - const spy = sinon.spy(container, 'onChildrenChange'); + const spy = sinon.spy(container, 'onChildrenChange' as keyof Container); container.setChildIndex(child, 1); @@ -389,17 +423,19 @@ describe('Container', function () }); }); - describe('swapChildren', function () + describe('swapChildren', () => { - it('should call onChildrenChange', function () + it('should call onChildrenChange', () => { const container = new Container(); + // @ts-expect-error - instantiating DisplayObject const child1 = new DisplayObject(); + // @ts-expect-error - instantiating DisplayObject const child2 = new DisplayObject(); container.addChild(child1, child2); - const spy = sinon.spy(container, 'onChildrenChange'); + const spy = sinon.spy(container, 'onChildrenChange' as keyof Container); container.swapChildren(child1, child2); expect(spy).to.have.been.called; @@ -411,37 +447,44 @@ describe('Container', function () expect(spy).to.have.been.calledWith(0); }); - it('should not call onChildrenChange if supplied children are equal', function () + it('should not call onChildrenChange if supplied children are equal', () => { const container = new Container(); + // @ts-expect-error - instantiating DisplayObject const child = new DisplayObject(); + // @ts-expect-error - instantiating DisplayObject container.addChild(child, new DisplayObject()); - const spy = sinon.spy(container, 'onChildrenChange'); + const spy = sinon.spy(container, 'onChildrenChange' as keyof Container); container.swapChildren(child, child); expect(spy).to.not.have.been.called; }); - it('should throw if children do not belong', function () + it('should throw if children do not belong', () => { const container = new Container(); const child = new Container(); + // @ts-expect-error - instantiating DisplayObject container.addChild(child, new DisplayObject()); + // @ts-expect-error - instantiating DisplayObject expect(() => container.swapChildren(child, new DisplayObject())) .to.throw('The supplied DisplayObject must be a child of the caller'); + // @ts-expect-error - instantiating DisplayObject expect(() => container.swapChildren(new DisplayObject(), child)) .to.throw('The supplied DisplayObject must be a child of the caller'); }); - it('should result in swapped child positions', function () + it('should result in swapped child positions', () => { const container = new Container(); + // @ts-expect-error - instantiating DisplayObject const child1 = new DisplayObject(); + // @ts-expect-error - instantiating DisplayObject const child2 = new DisplayObject(); container.addChild(child1, child2); @@ -456,9 +499,9 @@ describe('Container', function () }); }); - describe('updateTransform', function () + describe('updateTransform', () => { - it('should call sortChildren if sortDirty and sortableChildren are true', function () + it('should call sortChildren if sortDirty and sortableChildren are true', () => { const parent = new Container(); const container = new Container(); @@ -476,7 +519,7 @@ describe('Container', function () expect(canvasSpy).to.have.been.called; }); - it('should not call sortChildren if sortDirty is false', function () + it('should not call sortChildren if sortDirty is false', () => { const parent = new Container(); const container = new Container(); @@ -494,7 +537,7 @@ describe('Container', function () expect(canvasSpy).to.not.have.been.called; }); - it('should not call sortChildren if sortableChildren is false', function () + it('should not call sortChildren if sortableChildren is false', () => { const parent = new Container(); const container = new Container(); @@ -513,61 +556,62 @@ describe('Container', function () }); }); - describe('render', function () + describe('render', () => { - it('should not render when object not visible', function () + it('should not render when object not visible', () => { const container = new Container(); - const webGLSpy = sinon.spy(container._render); + const webGLSpy = sinon.spy(container['_render']); container.visible = false; - container.render(); + container.render(undefined); expect(webGLSpy).to.not.have.been.called; }); - it('should not render when alpha is zero', function () + it('should not render when alpha is zero', () => { const container = new Container(); - const webGLSpy = sinon.spy(container._render); + const webGLSpy = sinon.spy(container['_render']); container.worldAlpha = 0; - container.render(); + container.render(undefined); expect(webGLSpy).to.not.have.been.called; }); - it('should not render when object not renderable', function () + it('should not render when object not renderable', () => { const container = new Container(); - const webGLSpy = sinon.spy(container._render); + const webGLSpy = sinon.spy(container['_render']); container.renderable = false; - container.render(); + container.render(undefined); expect(webGLSpy).to.not.have.been.called; }); - it('should render children', function () + it('should render children', () => { const container = new Container(); const child = new Container(); - const webGLSpy = sinon.spy(child, '_render'); + const webGLSpy = sinon.spy(child, '_render' as keyof Container); container.addChild(child); - container.render(); + container.render(undefined); expect(webGLSpy).to.have.been.called; }); }); - describe('removeChildren', function () + describe('removeChildren', () => { - it('should remove all children when no arguments supplied', function () + it('should remove all children when no arguments supplied', () => { const container = new Container(); let removed = []; + // @ts-expect-error - instantiating DisplayObject container.addChild(new DisplayObject(), new DisplayObject(), new DisplayObject()); expect(container.children.length).to.be.equals(3); @@ -578,7 +622,7 @@ describe('Container', function () expect(removed.length).to.be.equals(3); }); - it('should return empty array if no children', function () + it('should return empty array if no children', () => { const container = new Container(); const removed = container.removeChildren(); @@ -586,21 +630,23 @@ describe('Container', function () expect(removed.length).to.be.equals(0); }); - it('should handle a range greater than length', function () + it('should handle a range greater than length', () => { const container = new Container(); let removed = []; + // @ts-expect-error - instantiating DisplayObject container.addChild(new DisplayObject()); removed = container.removeChildren(0, 2); expect(removed.length).to.be.equals(1); }); - it('should throw outside acceptable range', function () + it('should throw outside acceptable range', () => { const container = new Container(); + // @ts-expect-error - instantiating DisplayObject container.addChild(new DisplayObject()); expect(() => container.removeChildren(2)) @@ -612,11 +658,12 @@ describe('Container', function () }); }); - describe('destroy', function () + describe('destroy', () => { - it('should not destroy children by default', function () + it('should not destroy children by default', () => { const container = new Container(); + // @ts-expect-error - instantiating DisplayObject const child = new DisplayObject(); container.addChild(child); @@ -626,9 +673,10 @@ describe('Container', function () expect(child.transform).to.not.be.null; }); - it('should allow children destroy', function () + it('should allow children destroy', () => { let container = new Container(); + // @ts-expect-error - instantiating DisplayObject let child = new DisplayObject(); container.addChild(child); @@ -639,6 +687,7 @@ describe('Container', function () expect(child.transform).to.be.null; container = new Container(); + // @ts-expect-error - instantiating DisplayObject child = new DisplayObject(); container.addChild(child); @@ -650,9 +699,9 @@ describe('Container', function () }); }); - describe('getLocalBounds', function () + describe('getLocalBounds', () => { - it('should recalculate children transform by default', function () + it('should recalculate children transform by default', () => { const root = new Container(); const container = new Container(); @@ -671,14 +720,15 @@ describe('Container', function () expect(child.transform.worldTransform.ty).to.equal(40); }); - it('should recalculate bounds if children position was changed', function () + it('should recalculate bounds if children position was changed', () => { const root = new Container(); const container = new Container(); const child = new Container(); let bounds = null; - child._calculateBounds = function () + // eslint-disable-next-line func-names + child['_calculateBounds'] = function () { this._bounds.addFrame(this.transform, 0, 0, 1, 1); }; @@ -699,9 +749,9 @@ describe('Container', function () }); }); - describe('width', function () + describe('width', () => { - it('should reset scale', function () + it('should reset scale', () => { const container = new Container(); @@ -713,9 +763,9 @@ describe('Container', function () }); }); - describe('height', function () + describe('height', () => { - it('should reset scale', function () + it('should reset scale', () => { const container = new Container(); @@ -727,11 +777,12 @@ describe('Container', function () }); }); - describe('sortDirty', function () + describe('sortDirty', () => { - it('should set sortDirty flag to true when adding a new child', function () + it('should set sortDirty flag to true when adding a new child', () => { const parent = new Container(); + // @ts-expect-error - instantiating DisplayObject const child = new DisplayObject(); expect(parent.sortDirty).to.be.false; @@ -741,9 +792,10 @@ describe('Container', function () expect(parent.sortDirty).to.be.true; }); - it('should set sortDirty flag to true when changing a child zIndex', function () + it('should set sortDirty flag to true when changing a child zIndex', () => { const parent = new Container(); + // @ts-expect-error - instantiating DisplayObject const child = new DisplayObject(); parent.addChild(child); @@ -756,9 +808,9 @@ describe('Container', function () }); }); - describe('sortChildren', function () + describe('sortChildren', () => { - it('should reset sortDirty flag', function () + it('should reset sortDirty flag', () => { const container = new Container(); @@ -769,10 +821,12 @@ describe('Container', function () expect(container.sortDirty).to.be.false; }); - it('should call sort when at least one child has a zIndex', function () + it('should call sort when at least one child has a zIndex', () => { const container = new Container(); + // @ts-expect-error - instantiating DisplayObject const child1 = new DisplayObject(); + // @ts-expect-error - instantiating DisplayObject const child2 = new DisplayObject(); const spy = sinon.spy(container.children, 'sort'); @@ -784,10 +838,12 @@ describe('Container', function () expect(spy).to.have.been.called; }); - it('should not call sort when children have no zIndex', function () + it('should not call sort when children have no zIndex', () => { const container = new Container(); + // @ts-expect-error - instantiating DisplayObject const child1 = new DisplayObject(); + // @ts-expect-error - instantiating DisplayObject const child2 = new DisplayObject(); const spy = sinon.spy(container.children, 'sort'); @@ -798,12 +854,16 @@ describe('Container', function () expect(spy).to.not.have.been.called; }); - it('should sort children by zIndex value', function () + it('should sort children by zIndex value', () => { const container = new Container(); + // @ts-expect-error - instantiating DisplayObject const child1 = new DisplayObject(); + // @ts-expect-error - instantiating DisplayObject const child2 = new DisplayObject(); + // @ts-expect-error - instantiating DisplayObject const child3 = new DisplayObject(); + // @ts-expect-error - instantiating DisplayObject const child4 = new DisplayObject(); child1.zIndex = 20; @@ -825,12 +885,16 @@ describe('Container', function () expect(container.children.indexOf(child4)).to.be.equals(0); }); - it('should sort children by current array order if zIndex values match', function () + it('should sort children by current array order if zIndex values match', () => { const container = new Container(); + // @ts-expect-error - instantiating DisplayObject const child1 = new DisplayObject(); + // @ts-expect-error - instantiating DisplayObject const child2 = new DisplayObject(); + // @ts-expect-error - instantiating DisplayObject const child3 = new DisplayObject(); + // @ts-expect-error - instantiating DisplayObject const child4 = new DisplayObject(); child1.zIndex = 20; @@ -858,12 +922,16 @@ describe('Container', function () expect(container.children.indexOf(child4)).to.be.equals(1); }); - it('should sort children in the same way despite being called multiple times', function () + it('should sort children in the same way despite being called multiple times', () => { const container = new Container(); + // @ts-expect-error - instantiating DisplayObject const child1 = new DisplayObject(); + // @ts-expect-error - instantiating DisplayObject const child2 = new DisplayObject(); + // @ts-expect-error - instantiating DisplayObject const child3 = new DisplayObject(); + // @ts-expect-error - instantiating DisplayObject const child4 = new DisplayObject(); child1.zIndex = 10; @@ -905,12 +973,16 @@ describe('Container', function () expect(container.children.indexOf(child4)).to.be.equals(0); }); - it('should sort new children added correctly', function () + it('should sort new children added correctly', () => { const container = new Container(); + // @ts-expect-error - instantiating DisplayObject const child1 = new DisplayObject(); + // @ts-expect-error - instantiating DisplayObject const child2 = new DisplayObject(); + // @ts-expect-error - instantiating DisplayObject const child3 = new DisplayObject(); + // @ts-expect-error - instantiating DisplayObject const child4 = new DisplayObject(); child1.zIndex = 20; @@ -944,12 +1016,16 @@ describe('Container', function () expect(container.children.indexOf(child4)).to.be.equals(0); }); - it('should sort children after a removal correctly', function () + it('should sort children after a removal correctly', () => { const container = new Container(); + // @ts-expect-error - instantiating DisplayObject const child1 = new DisplayObject(); + // @ts-expect-error - instantiating DisplayObject const child2 = new DisplayObject(); + // @ts-expect-error - instantiating DisplayObject const child3 = new DisplayObject(); + // @ts-expect-error - instantiating DisplayObject const child4 = new DisplayObject(); child1.zIndex = 20; @@ -984,7 +1060,7 @@ describe('Container', function () }); }); - function assertRemovedFromParent(parent, container, child, functionToAssert) + function assertRemovedFromParent(parent: Container, container: Container, child: Container, functionToAssert: () => void) { parent.addChild(child); @@ -997,29 +1073,31 @@ describe('Container', function () expect(child.parent).to.be.equals(container); } - describe('culling', function () + describe('culling', () => { - before(function () + let renderer: Renderer; + let filterPush: sinon.SinonSpy; + + before(() => { - this.renderer = new Renderer({ width: 100, height: 100 }); - this.filterPush = sinon.spy(this.renderer.filter, 'push'); + renderer = new Renderer({ width: 100, height: 100 }); + filterPush = sinon.spy(renderer.filter, 'push'); }); - after(function () + after(() => { - this.renderer.destroy(); - this.renderer = null; - this.filterPush = null; + renderer.destroy(); + renderer = null; + filterPush = null; }); - afterEach(function () + afterEach(() => { - this.filterPush.resetHistory(); + filterPush.resetHistory(); }); - it('noncullable container should always be rendered even if bounds do not intersect the frame', function () + it('noncullable container should always be rendered even if bounds do not intersect the frame', () => { - const renderer = this.renderer; const container = new Container(); const graphics = container.addChild(new Graphics().beginFill().drawRect(0, 0, 10, 10).endFill()); @@ -1027,8 +1105,8 @@ describe('Container', function () graphics.x = -1000; graphics.y = -1000; - const _renderContainer = sinon.spy(container, '_render'); - const _renderGraphics = sinon.spy(graphics, '_render'); + const _renderContainer = sinon.spy(container, '_render' as keyof Container); + const _renderGraphics = sinon.spy(graphics, '_render' as keyof Graphics); renderer.render(container); @@ -1036,9 +1114,8 @@ describe('Container', function () expect(_renderGraphics).to.have.been.called; }); - it('cullable container should not be rendered if bounds do not intersect the frame', function () + it('cullable container should not be rendered if bounds do not intersect the frame', () => { - const renderer = this.renderer; const container = new Container(); const graphics = container.addChild(new Graphics().beginFill().drawRect(0, 0, 10, 10).endFill()); @@ -1046,8 +1123,8 @@ describe('Container', function () graphics.x = 0; graphics.y = -10; - const _renderContainer = sinon.spy(container, '_render'); - const _renderGraphics = sinon.spy(graphics, '_render'); + const _renderContainer = sinon.spy(container, '_render' as keyof Container); + const _renderGraphics = sinon.spy(graphics, '_render' as keyof Graphics); renderer.render(container); @@ -1055,9 +1132,8 @@ describe('Container', function () expect(_renderGraphics).to.not.have.been.called; }); - it('cullable container should be rendered if bounds intersects the frame', function () + it('cullable container should be rendered if bounds intersects the frame', () => { - const renderer = this.renderer; const container = new Container(); const graphics = container.addChild(new Graphics().beginFill().drawRect(0, 0, 10, 10).endFill()); @@ -1065,8 +1141,8 @@ describe('Container', function () graphics.x = 0; graphics.y = -9; - const _renderContainer = sinon.spy(container, '_render'); - const _renderGraphics = sinon.spy(graphics, '_render'); + const _renderContainer = sinon.spy(container, '_render' as keyof Container); + const _renderGraphics = sinon.spy(graphics, '_render' as keyof Graphics); renderer.render(container); @@ -1076,9 +1152,8 @@ describe('Container', function () it('cullable container that contains a child with a padded filter (autoFit=true) ' + 'such that the child in out of frame but the filter padding intersects the frame ' - + 'should render the filter padding but not the container or child', function () + + 'should render the filter padding but not the container or child', () => { - const renderer = this.renderer; const container = new Container(); const graphics = container.addChild(new Graphics().beginFill().drawRect(0, 0, 10, 10).endFill()); const filter = new AlphaFilter(); @@ -1091,21 +1166,20 @@ describe('Container', function () graphics.x = 0; graphics.y = -15; - const _renderContainer = sinon.spy(container, '_render'); - const _renderGraphics = sinon.spy(graphics, '_render'); + const _renderContainer = sinon.spy(container, '_render' as keyof Container); + const _renderGraphics = sinon.spy(graphics, '_render' as keyof Graphics); renderer.render(container); expect(_renderContainer).to.not.have.been.called; expect(_renderGraphics).to.not.have.been.called; - expect(this.filterPush).to.have.been.called; + expect(filterPush).to.have.been.called; }); it('cullable container that contains a child with a padded filter (autoFit=false) ' + 'such that the child in out of frame but the filter padding intersects the frame ' - + 'should render the filtered child but not the container', function () + + 'should render the filtered child but not the container', () => { - const renderer = this.renderer; const container = new Container(); const graphics = container.addChild(new Graphics().beginFill().drawRect(0, 0, 10, 10).endFill()); const filter = new AlphaFilter(); @@ -1118,20 +1192,19 @@ describe('Container', function () graphics.x = 0; graphics.y = -15; - const _renderContainer = sinon.spy(container, '_render'); - const _renderGraphics = sinon.spy(graphics, '_render'); + const _renderContainer = sinon.spy(container, '_render' as keyof Container); + const _renderGraphics = sinon.spy(graphics, '_render' as keyof Graphics); renderer.render(container); expect(_renderContainer).to.not.have.been.called; expect(_renderGraphics).to.have.been.called; - expect(this.filterPush).to.have.been.called; + expect(filterPush).to.have.been.called; }); it('cullable container with a filter (autoFit=true) should not render the container or children ' - + 'if the bounds as well as the filter padding do no intersect the frame', function () + + 'if the bounds as well as the filter padding do no intersect the frame', () => { - const renderer = this.renderer; const container = new Container(); const graphics = container.addChild(new Graphics().beginFill().drawRect(0, 0, 10, 10).endFill()); const filter = new AlphaFilter(); @@ -1144,19 +1217,18 @@ describe('Container', function () graphics.x = 0; graphics.y = -15; - const _renderContainer = sinon.spy(container, '_render'); + const _renderContainer = sinon.spy(container, '_render' as keyof Container); const renderGraphics = sinon.spy(graphics, 'render'); renderer.render(container); expect(_renderContainer).to.not.have.been.called; expect(renderGraphics).to.not.have.been.called; - expect(this.filterPush).to.have.been.called; + expect(filterPush).to.have.been.called; }); - it('cullable container with cullArea should be rendered if the bounds intersect the frame', function () + it('cullable container with cullArea should be rendered if the bounds intersect the frame', () => { - const renderer = this.renderer; const container = new Container(); const graphics = container.addChild(new Graphics().beginFill().drawRect(0, 0, 10, 10).endFill()); @@ -1165,16 +1237,15 @@ describe('Container', function () container.x = container.y = 107.07; container.rotation = Math.PI / 4; - const _renderGraphics = sinon.spy(graphics, '_render'); + const _renderGraphics = sinon.spy(graphics, '_render' as keyof Graphics); renderer.render(container); expect(_renderGraphics).to.have.been.called; }); - it('cullable container with cullArea should not be rendered if the bounds do not intersect the frame', function () + it('cullable container with cullArea should not be rendered if the bounds do not intersect the frame', () => { - const renderer = this.renderer; const container = new Container(); const graphics = container.addChild(new Graphics().beginFill().drawRect(0, 0, 10, 10).endFill()); diff --git a/packages/display/test/DisplayObject.tests.ts b/packages/display/test/DisplayObject.tests.ts index a4df3c6c1a..2bc22c19b8 100755 --- a/packages/display/test/DisplayObject.tests.ts +++ b/packages/display/test/DisplayObject.tests.ts @@ -3,12 +3,13 @@ import { RAD_TO_DEG, DEG_TO_RAD } from '@pixi/math'; import sinon from 'sinon'; import { expect } from 'chai'; -describe('DisplayObject', function () +describe('DisplayObject', () => { - describe('constructor', function () + describe('constructor', () => { - it('should initialise properties', function () + it('should initialise properties', () => { + // @ts-expect-error - instantiating DisplayOBject const object = new DisplayObject(); expect(object.alpha).to.equal(1); @@ -18,10 +19,11 @@ describe('DisplayObject', function () }); }); - describe('setParent', function () + describe('setParent', () => { - it('should add itself to a Container', function () + it('should add itself to a Container', () => { + // @ts-expect-error - instantiating DisplayOBject const child = new DisplayObject(); const container = new Container(); @@ -31,8 +33,9 @@ describe('DisplayObject', function () expect(child.parent).to.equal(container); }); - it('should throw if not Container', function () + it('should throw if not Container', () => { + // @ts-expect-error - instantiating DisplayOBject const child = new DisplayObject(); const notAContainer = {}; @@ -41,10 +44,11 @@ describe('DisplayObject', function () }); }); - describe('setTransform', function () + describe('setTransform', () => { - it('should set correct properties', function () + it('should set correct properties', () => { + // @ts-expect-error - instantiating DisplayOBject const object = new DisplayObject(); object.setTransform(1, 2, 3, 4, 5, 6, 7, 8, 9); @@ -60,8 +64,9 @@ describe('DisplayObject', function () expect(object.pivot.y).to.be.equal(9); }); - it('should convert zero scale to one', function () + it('should convert zero scale to one', () => { + // @ts-expect-error - instantiating DisplayOBject const object = new DisplayObject(); object.setTransform(1, 1, 0, 0, 1, 1, 1, 1, 1); @@ -71,12 +76,13 @@ describe('DisplayObject', function () }); }); - describe('worldVisible', function () + describe('worldVisible', () => { - it('should traverse parents', function () + it('should traverse parents', () => { const grandParent = new Container(); const parent = new Container(); + // @ts-expect-error - instantiating DisplayOBject const child = new DisplayObject(); grandParent.addChild(parent); @@ -90,10 +96,11 @@ describe('DisplayObject', function () }); }); - describe('rotation', function () + describe('rotation', () => { - it('rotation and angle are different units of the same transformation', function () + it('rotation and angle are different units of the same transformation', () => { + // @ts-expect-error - instantiating DisplayOBject const object = new DisplayObject(); expect(object.rotation).to.be.equal(0); @@ -111,10 +118,11 @@ describe('DisplayObject', function () }); }); - describe('enableTempParent', function () + describe('enableTempParent', () => { - it('should allow to recalc children transform', function () + it('should allow to recalc children transform', () => { + // @ts-expect-error - instantiating DisplayOBject const child = new DisplayObject(); const container = new Container(); @@ -146,12 +154,14 @@ describe('DisplayObject', function () }); }); - describe('mask', function () + describe('mask', () => { it('should set isMask and renderable properties correctly even if the same mask is used by multiple objects', - function () + () => { + // @ts-expect-error - instantiating DisplayOBject const mask1 = new DisplayObject(); + // @ts-expect-error - instantiating DisplayOBject const mask2 = new DisplayObject(); const container1 = new Container(); const container2 = new Container(); @@ -223,11 +233,12 @@ describe('DisplayObject', function () ); }); - describe('remove', function () + describe('remove', () => { - it('should trigger removed listeners', function () + it('should trigger removed listeners', () => { const listener = sinon.spy(); + // @ts-expect-error - instantiating DisplayOBject const child = new DisplayObject(); const container = new Container(); @@ -245,11 +256,12 @@ describe('DisplayObject', function () }); }); - describe('destroy', function () + describe('destroy', () => { - it('should trigger destroyed listeners', function () + it('should trigger destroyed listeners', () => { const listener = sinon.spy(); + // @ts-expect-error - instantiating DisplayOBject const child = new DisplayObject(); const container = new Container(); @@ -265,5 +277,30 @@ describe('DisplayObject', function () expect(listener.calledOnce).to.be.true; }); + + it('should trigger destroyed listeners once destruction is complete', () => + { + let listenerCallCount = 0; + // @ts-expect-error - instantiating DisplayOBject + const child = new DisplayObject(); + const container = new Container(); + + child.on('destroyed', () => + { + listenerCallCount++; + expect(child.destroyed).to.be.true; + expect(child.parent).to.be.null; + }); + + container.addChild(child); + container.removeChild(child); + + expect(listenerCallCount).to.equal(0); + + container.addChild(child); + child.destroy(); + + expect(listenerCallCount).to.equal(1); + }); }); }); diff --git a/packages/display/test/toGlobal.tests.ts b/packages/display/test/toGlobal.tests.ts index ca2b71a40e..59e57f8802 100644 --- a/packages/display/test/toGlobal.tests.ts +++ b/packages/display/test/toGlobal.tests.ts @@ -2,9 +2,9 @@ import { Container } from '@pixi/display'; import { Point } from '@pixi/math'; import { expect } from 'chai'; -describe('toGlobal', function () +describe('toGlobal', () => { - it('should return correct global cordinates of a point from within a displayObject', function () + it('should return correct global cordinates of a point from within a displayObject', () => { const parent = new Container(); diff --git a/packages/display/test/toLocal.tests.ts b/packages/display/test/toLocal.tests.ts index 91cffc27bb..0808000a56 100644 --- a/packages/display/test/toLocal.tests.ts +++ b/packages/display/test/toLocal.tests.ts @@ -2,9 +2,9 @@ import { Container } from '@pixi/display'; import { Point } from '@pixi/math'; import { expect } from 'chai'; -describe('toLocal', function () +describe('toLocal', () => { - it('should return correct local cordinates of a displayObject', function () + it('should return correct local cordinates of a displayObject', () => { const parent = new Container(); @@ -31,7 +31,7 @@ describe('toLocal', function () expect(localPoint.y).to.equal(40); }); - it('should map the correct local cordinates of a displayObject to another', function () + it('should map the correct local cordinates of a displayObject to another', () => { const parent = new Container(); diff --git a/packages/events/package.json b/packages/events/package.json index 1a8ec89491..c4a2038159 100644 --- a/packages/events/package.json +++ b/packages/events/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/events", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/events.js", "module": "dist/esm/events.js", "bundle": "dist/browser/events.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/events.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/events.js" + } + } + }, "description": "UI events for scene graphs", "keywords": [ "interaction", @@ -32,8 +45,8 @@ "url": "https://github.com/pixijs/pixi.js/issues" }, "peerDependencies": { - "@pixi/display": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/display": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/utils": "6.4.2" } } diff --git a/packages/events/src/EventBoundary.ts b/packages/events/src/EventBoundary.ts index d9b0466dfa..d7a482518f 100644 --- a/packages/events/src/EventBoundary.ts +++ b/packages/events/src/EventBoundary.ts @@ -30,11 +30,10 @@ const tempLocalMapping = new Point(); * }; * overTargets: FederatedEventTarget[]; * ``` - * * @typedef {object} TrackingData * @property {Record.} pressTargetsByButton - The pressed display objects' * propagation paths by each button of the pointer. - * @property {Record.} clicksByButton - Holds clicking data for each button of the pointer. + * @property {Record.} clicksByButton - Holds clicking data for each button of the pointer. * @property {PIXI.DisplayObject[]} overTargets - The DisplayObject propagation path over which the pointer is hovering. * @memberof PIXI */ @@ -54,12 +53,11 @@ type TrackingData = { /** * Internal storage of event listeners in EventEmitter. - * * @ignore */ type EmitterListeners = Record - | { fn(...args: any[]): any, context: any } +| Array<{ fn(...args: any[]): any, context: any }> +| { fn(...args: any[]): any, context: any } >; /** @@ -116,7 +114,6 @@ type EmitterListeners = Record = { @@ -176,7 +169,6 @@ export class EventBoundary /** * The event pool maps event constructors to an free pool of instances of those specific events. - * * @see PIXI.EventBoundary#allocateEvent * @see PIXI.EventBoundary#freeEvent */ @@ -219,7 +211,6 @@ export class EventBoundary * * To modify the semantics of existing events, the built-in mapping methods of EventBoundary should be overridden * instead. - * * @param type - The type of upstream event to map. * @param fn - The mapping method. The context of this function must be bound manually, if desired. */ @@ -237,7 +228,11 @@ export class EventBoundary this.mappingTable[type].sort((a, b) => a.priority - b.priority); } - /** Dispatches the given event */ + /** + * Dispatches the given event + * @param e + * @param type + */ public dispatchEvent(e: FederatedEvent, type?: string): void { e.propagationStopped = false; @@ -247,7 +242,10 @@ export class EventBoundary this.dispatch.emit(type || e.type, e); } - /** Maps the given upstream event through the event boundary and propagates it downstream. */ + /** + * Maps the given upstream event through the event boundary and propagates it downstream. + * @param e + */ public mapEvent(e: FederatedEvent): void { if (!this.rootTarget) @@ -274,6 +272,8 @@ export class EventBoundary * Finds the DisplayObject that is the target of a event at the given coordinates. * * The passed (x,y) coordinates are in the world space above this event boundary. + * @param x + * @param y */ public hitTest( x: number, @@ -294,8 +294,8 @@ export class EventBoundary /** * Propagate the passed event from from {@link EventBoundary.rootTarget this.rootTarget} to its * target {@code e.target}. - * * @param e - The event to propagate. + * @param type */ public propagate(e: FederatedEvent, type?: string): void { @@ -344,9 +344,9 @@ export class EventBoundary * Emits the event {@link e} to all display objects. The event is propagated in the bubbling phase always. * * This is used in the `pointermove` legacy mode. - * * @param e - The emitted event. * @param type - The listeners to notify. + * @param target */ public all(e: FederatedEvent, type?: string, target: FederatedEventTarget = this.rootTarget): void { @@ -369,7 +369,6 @@ export class EventBoundary /** * Finds the propagation path from {@link PIXI.EventBoundary.rootTarget rootTarget} to the passed * {@code target}. The last element in the path is {@code target}. - * * @param target */ public propagationPath(target: FederatedEventTarget): FederatedEventTarget[] @@ -395,7 +394,6 @@ export class EventBoundary /** * Recursive implementation for {@link EventBoundary.hitTest hitTest}. - * * @param currentTarget - The DisplayObject that is to be hit tested. * @param interactive - Flags whether `currentTarget` or one of its parents are interactive. * @param location - The location that is being tested for overlap. @@ -404,7 +402,7 @@ export class EventBoundary * @param pruneFn - Callback that determiness whether the target and all of its children * cannot pass the hit test. It is used as a preliminary optimization to prune entire subtrees * of the scene graph. - * @return An array holding the hit testing target and all its ancestors in order. The first element + * @returns An array holding the hit testing target and all its ancestors in order. The first element * is the target itself and the last is {@link EventBoundary.rootTarget rootTarget}. This is the opposite * order w.r.t. the propagation path. If no hit testing target is found, null is returned. */ @@ -482,7 +480,6 @@ export class EventBoundary * * {@link EventBoundary}'s implementation uses the {@link PIXI.DisplayObject.hitArea hitArea} * and {@link PIXI.DisplayObject._mask} for pruning. - * * @param displayObject * @param location */ @@ -513,10 +510,9 @@ export class EventBoundary /** * Checks whether the display object passes hit testing for the given location. - * * @param displayObject * @param location - * @return - Whether `displayObject` passes hit testing for `location`. + * @returns - Whether `displayObject` passes hit testing for `location`. */ protected hitTestFn(displayObject: DisplayObject, location: Point): boolean { @@ -538,8 +534,8 @@ export class EventBoundary /** * Notify all the listeners to the event's `currentTarget`. - * * @param e - The event passed to the target. + * @param type */ protected notifyTarget(e: FederatedEvent, type?: string): void { @@ -558,7 +554,6 @@ export class EventBoundary * Maps the upstream `pointerdown` events to a downstream `pointerdown` event. * * `touchstart`, `rightdown`, `mousedown` events are also dispatched for specific pointer types. - * * @param from */ protected mapPointerDown(from: FederatedEvent): void @@ -597,7 +592,6 @@ export class EventBoundary * * The tracking data for the specific pointer has an updated `overTarget`. `mouseout`, `mouseover`, * `mousemove`, and `touchmove` events are fired as well for specific pointer types. - * * @param from - The upstream `pointermove` event. */ protected mapPointerMove(from: FederatedEvent): void @@ -718,7 +712,6 @@ export class EventBoundary * Maps the upstream `pointerover` to downstream `pointerover` and `pointerenter` events, in that order. * * The tracking data for the specific pointer gets a new `overTarget`. - * * @param from - The upstream `pointerover` event. */ protected mapPointerOver(from: FederatedEvent): void @@ -763,7 +756,6 @@ export class EventBoundary * Maps the upstream `pointerout` to downstream `pointerout`, `pointerleave` events, in that order. * * The tracking data for the specific pointer is cleared of a `overTarget`. - * * @param from - The upstream `pointerout` event. */ protected mapPointerOut(from: FederatedEvent): void @@ -821,7 +813,6 @@ export class EventBoundary * ancestor of the `pointerdown` and `pointerup` targets, which is also the `click` event's target. `touchend`, * `rightup`, `mouseup`, `touchendoutside`, `rightupoutside`, `mouseupoutside`, and `tap` are fired as well for * specific pointer types. - * * @param from - The upstream `pointerup` event. */ protected mapPointerUp(from: FederatedEvent): void @@ -949,7 +940,6 @@ export class EventBoundary * * `touchendoutside`, `mouseupoutside`, and `rightupoutside` events are fired as well for specific pointer * types. The tracking data for the specific pointer is cleared of a `pressTarget`. - * * @param from - The upstream `pointerupoutside` event. */ protected mapPointerUpOutside(from: FederatedEvent): void @@ -995,7 +985,6 @@ export class EventBoundary /** * Maps the upstream `wheel` event to a downstream `wheel` event. - * * @param from - The upstream `wheel` event. */ protected mapWheel(from: FederatedEvent): void @@ -1018,9 +1007,8 @@ export class EventBoundary * * This is used to find the correct `pointerup` and `pointerout` target in the case that the original `pointerdown` * or `pointerover` target was unmounted from the scene graph. - * * @param propagationPath - The propagation path was valid in the past. - * @return - The most specific event-target still mounted at the same location in the scene graph. + * @returns - The most specific event-target still mounted at the same location in the scene graph. */ protected findMountedTarget(propagationPath: FederatedEventTarget[]): FederatedEventTarget { @@ -1052,7 +1040,6 @@ export class EventBoundary * Creates an event whose {@code originalEvent} is {@code from}, with an optional `type` and `target` override. * * The event is allocated using {@link PIXI.EventBoundary#allocateEvent this.allocateEvent}. - * * @param from - The {@code originalEvent} for the returned event. * @param [type=from.type] - The type of the returned event. * @param target - The target of the returned event. @@ -1085,7 +1072,6 @@ export class EventBoundary * Creates a wheel event whose {@code originalEvent} is {@code from}. * * The event is allocated using {@link PIXI.EventBoundary#allocateEvent this.allocateEvent}. - * * @param from - The upstream wheel event. */ protected createWheelEvent(from: FederatedWheelEvent): FederatedWheelEvent @@ -1107,7 +1093,6 @@ export class EventBoundary * Clones the event {@code from}, with an optional {@code type} override. * * The event is allocated using {@link PIXI.EventBoundary#allocateEvent this.allocateEvent}. - * * @param from - The event to clone. * @param [type=from.type] - The type of the returned event. */ @@ -1138,7 +1123,6 @@ export class EventBoundary * + deltaX * + deltaY * + deltaZ - * * @param from * @param to */ @@ -1163,7 +1147,6 @@ export class EventBoundary * + tangentialPressure * + tiltX * + tiltY - * * @param from * @param to */ @@ -1201,7 +1184,6 @@ export class EventBoundary * + y * + screen * + global - * * @param from * @param to */ @@ -1229,7 +1211,6 @@ export class EventBoundary * + srcElement * + timeStamp * + type - * * @param from - The event to copy data from. * @param to - The event to copy data into. */ @@ -1248,7 +1229,7 @@ export class EventBoundary /** * @param id - The pointer ID. - * @return The tracking data stored for the given pointer. If no data exists, a blank + * @returns The tracking data stored for the given pointer. If no data exists, a blank * state will be created. */ protected trackingData(id: number): TrackingData @@ -1270,7 +1251,6 @@ export class EventBoundary * * This allocation is constructor-agnostic, as long as it only takes one argument - this event * boundary. - * * @param constructor - The event's constructor. */ protected allocateEvent( @@ -1301,7 +1281,6 @@ export class EventBoundary * It is also advised that events not allocated from {@link PIXI.EventBoundary#allocateEvent this.allocateEvent} * not be freed. This is because of the possibility that the same event is freed twice, which can cause * it to be allocated twice & result in overwriting. - * * @param event - The event to be freed. * @throws Error if the event is managed by another event boundary. */ @@ -1322,7 +1301,6 @@ export class EventBoundary /** * Similar to {@link EventEmitter.emit}, except it stops if the `propagationImmediatelyStopped` flag * is set on the event. - * * @param e - The event to call each listener with. * @param type - The event key. */ @@ -1354,7 +1332,6 @@ export class EventBoundary * object. DisplayObject's `interactive` property must be set to `true` to fire event. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#mousedown * @param {PIXI.FederatedPointerEvent} event - The mousedown event. */ @@ -1363,7 +1340,6 @@ export class EventBoundary * Capture phase equivalent of {@code mousedown}. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#mousedowncapture * @param {PIXI.FederatedPointerEvent} event - The capture phase mousedown. */ @@ -1373,7 +1349,6 @@ export class EventBoundary * on the display object. DisplayObject's `interactive` property must be set to `true` to fire event. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#rightdown * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1382,7 +1357,6 @@ export class EventBoundary * Capture phase equivalent of {@code rightdown}. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#rightdowncapture * @param {PIXI.FederatedPointerEvent} event - The rightdowncapture event. */ @@ -1392,7 +1366,6 @@ export class EventBoundary * object. DisplayObject's `interactive` property must be set to `true` to fire event. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#mouseup * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1401,7 +1374,6 @@ export class EventBoundary * Capture phase equivalent of {@code mouseup}. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#mouseupcature * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1411,7 +1383,6 @@ export class EventBoundary * over the display object. DisplayObject's `interactive` property must be set to `true` to fire event. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#rightup * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1420,7 +1391,6 @@ export class EventBoundary * Capture phase equivalent of {@code rightup}. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#rightupcapture * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1437,7 +1407,6 @@ export class EventBoundary * window of each other upto the current click. For example, it will be {@code 2} for a double click. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#click * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1446,7 +1415,6 @@ export class EventBoundary * Capture phase equivalent of {@code click}. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#clickcapture * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1458,7 +1426,6 @@ export class EventBoundary * This event follows the semantics of {@code click}. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#rightclick * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1467,7 +1434,6 @@ export class EventBoundary * Capture phase equivalent of {@code rightclick}. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#rightclickcapture * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1483,7 +1449,6 @@ export class EventBoundary * and {@code pointerup} events, i.e. the target of the {@code click} event. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#mouseupoutside * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1492,7 +1457,6 @@ export class EventBoundary * Capture phase equivalent of {@code mouseupoutside}. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#mouseupoutsidecapture * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1504,7 +1468,6 @@ export class EventBoundary * DisplayObject's `interactive` property must be set to `true` to fire event. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#rightupoutside * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1513,7 +1476,6 @@ export class EventBoundary * Capture phase equivalent of {@code rightupoutside}. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#rightupoutsidecapture * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1523,7 +1485,6 @@ export class EventBoundary * DisplayObject's `interactive` property must be set to `true` to fire event. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#mousemove * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1532,7 +1493,6 @@ export class EventBoundary * Capture phase equivalent of {@code mousemove}. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#mousemovecature * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1542,7 +1502,6 @@ export class EventBoundary * DisplayObject's `interactive` property must be set to `true` to fire event. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#mouseover * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1551,7 +1510,6 @@ export class EventBoundary * Capture phase equivalent of {@code mouseover}. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#mouseovercapture * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1560,7 +1518,6 @@ export class EventBoundary * Fired when the mouse pointer is moved over a DisplayObject and its descendant's hit testing boundaries. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#mouseenter * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1569,7 +1526,6 @@ export class EventBoundary * Capture phase equivalent of {@code mouseenter} * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#mouseentercapture * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1582,7 +1538,6 @@ export class EventBoundary * a {@code mouseover} event. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#mouseout * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1591,7 +1546,6 @@ export class EventBoundary * Capture phase equivalent of {@code mouseout}. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#mouseoutcapture * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1600,7 +1554,6 @@ export class EventBoundary * Fired when the mouse pointer exits a DisplayObject and its descendants. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#mouseleave * @param {PIXI.FederatedPointerEvent} event */ @@ -1609,7 +1562,6 @@ export class EventBoundary * Capture phase equivalent of {@code mouseleave}. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#mouseleavecapture * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1619,7 +1571,6 @@ export class EventBoundary * DisplayObject's `interactive` property must be set to `true` to fire event. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#pointerdown * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1628,7 +1579,6 @@ export class EventBoundary * Capture phase equivalent of {@code pointerdown}. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#pointerdowncapture * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1638,7 +1588,6 @@ export class EventBoundary * DisplayObject's `interactive` property must be set to `true` to fire event. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#pointerup * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1647,7 +1596,6 @@ export class EventBoundary * Capture phase equivalent of {@code pointerup}. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#pointerupcapture * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1657,7 +1605,6 @@ export class EventBoundary * DisplayObject's `interactive` property must be set to `true` to fire event. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#pointercancel * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1666,7 +1613,6 @@ export class EventBoundary * Capture phase equivalent of {@code pointercancel}. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#pointercancelcapture * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1676,7 +1622,6 @@ export class EventBoundary * DisplayObject's `interactive` property must be set to `true` to fire event. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#pointertap * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1685,7 +1630,6 @@ export class EventBoundary * Capture phase equivalent of {@code pointertap}. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#pointertapcapture * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1700,7 +1644,6 @@ export class EventBoundary * and {@code pointerup} events, i.e. the target of the {@code click} event. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#pointerupoutside * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1709,7 +1652,6 @@ export class EventBoundary * Capture phase equivalent of {@code pointerupoutside}. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#pointerupoutsidecapture * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1719,7 +1661,6 @@ export class EventBoundary * DisplayObject's `interactive` property must be set to `true` to fire event. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#pointermove * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1728,7 +1669,6 @@ export class EventBoundary * Capture phase equivalent of {@code pointermove}. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#pointermovecapture * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1738,7 +1678,6 @@ export class EventBoundary * DisplayObject's `interactive` property must be set to `true` to fire event. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#pointerover * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1747,7 +1686,6 @@ export class EventBoundary * Capture phase equivalent of {@code pointerover}. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#pointerovercapture * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1756,7 +1694,6 @@ export class EventBoundary * Fired when the pointer is moved over a DisplayObject and its descendant's hit testing boundaries. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#pointerenter * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1765,7 +1702,6 @@ export class EventBoundary * Capture phase equivalent of {@code pointerenter} * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#pointerentercapture * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1775,7 +1711,6 @@ export class EventBoundary * DisplayObject's `interactive` property must be set to `true` to fire event. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#pointerout * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1784,7 +1719,6 @@ export class EventBoundary * Capture phase equivalent of {@code pointerout}. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#pointeroutcapture * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1795,7 +1729,6 @@ export class EventBoundary * This event notifies only the target and does not bubble. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#pointerleave * @param {PIXI.FederatedPointerEvent} event - The `pointerleave` event. */ @@ -1804,7 +1737,6 @@ export class EventBoundary * Capture phase equivalent of {@code pointerleave}. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#pointerleavecapture * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1814,7 +1746,6 @@ export class EventBoundary * DisplayObject's `interactive` property must be set to `true` to fire event. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#touchstart * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1823,7 +1754,6 @@ export class EventBoundary * Capture phase equivalent of {@code touchstart}. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#touchstartcapture * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1833,7 +1763,6 @@ export class EventBoundary * DisplayObject's `interactive` property must be set to `true` to fire event. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#touchend * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1842,7 +1771,6 @@ export class EventBoundary * Capture phase equivalent of {@code touchend}. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#touchendcapture * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1852,7 +1780,6 @@ export class EventBoundary * DisplayObject's `interactive` property must be set to `true` to fire event. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#touchcancel * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1861,7 +1788,6 @@ export class EventBoundary * Capture phase equivalent of {@code touchcancel}. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#touchcancelcapture * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1871,7 +1797,6 @@ export class EventBoundary * DisplayObject's `interactive` property must be set to `true` to fire event. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#tap * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1880,7 +1805,6 @@ export class EventBoundary * Capture phase equivalent of {@code tap}. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#tapcapture * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1891,7 +1815,6 @@ export class EventBoundary * DisplayObject's `interactive` property must be set to `true` to fire event. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#touchendoutside * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1900,7 +1823,6 @@ export class EventBoundary * Capture phase equivalent of {@code touchendoutside}. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#touchendoutsidecapture * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1910,7 +1832,6 @@ export class EventBoundary * DisplayObject's `interactive` property must be set to `true` to fire event. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#touchmove * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1919,7 +1840,6 @@ export class EventBoundary * Capture phase equivalent of {@code touchmove}. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#touchmovecapture * @param {PIXI.FederatedPointerEvent} event - Event */ @@ -1928,7 +1848,6 @@ export class EventBoundary * Fired when a the user scrolls with the mouse cursor over a DisplayObject. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#wheel * @type {PIXI.FederatedWheelEvent} */ @@ -1937,7 +1856,6 @@ export class EventBoundary * Capture phase equivalent of {@code wheel}. * * These events are propagating from the {@link PIXI.EventSystem EventSystem} in @pixi/events. - * * @event PIXI.DisplayObject#wheelcapture * @type {PIXI.FederatedWheelEvent} */ diff --git a/packages/events/src/EventSystem.ts b/packages/events/src/EventSystem.ts index 3b3db9aadf..a553bbc187 100644 --- a/packages/events/src/EventSystem.ts +++ b/packages/events/src/EventSystem.ts @@ -26,7 +26,6 @@ interface Renderer /** * The system for handling UI events. - * * @memberof PIXI */ export class EventSystem @@ -43,16 +42,10 @@ export class EventSystem */ public readonly rootBoundary: EventBoundary; - /** - * Does the device support touch events - * https://www.w3.org/TR/touch-events/ - */ + /** Does the device support touch events https://www.w3.org/TR/touch-events/ */ public readonly supportsTouchEvents = 'ontouchstart' in globalThis; - /** - * Does the device support pointer events - * https://www.w3.org/Submission/pointer-events/ - */ + /** Does the device support pointer events https://www.w3.org/Submission/pointer-events/ */ public readonly supportsPointerEvents = !!globalThis.PointerEvent; /** @@ -60,7 +53,6 @@ export class EventSystem * Does not apply to pointer events for backwards compatibility * preventDefault on pointer events stops mouse events from firing * Thus, for every pointer event, there will always be either a mouse of touch event alongside it. - * * @default true */ public autoPreventDefault: boolean; @@ -70,8 +62,7 @@ export class EventSystem * values, objects are handled as dictionaries of CSS values for {@code domElement}, * and functions are called instead of changing the CSS. * Default CSS cursor values are provided for 'default' and 'pointer' modes. - * - * @member {Object. void) | CSSStyleDeclaration>} + * @member {Object void) | CSSStyleDeclaration>} */ public cursorStyles: Record void) | CSSStyleDeclaration>; @@ -81,14 +72,10 @@ export class EventSystem */ public domElement: HTMLElement; - /** - * The resolution used to convert between the DOM client space into world space. - */ + /** The resolution used to convert between the DOM client space into world space. */ public resolution = 1; - /** - * The renderer managing this {@link EventSystem}. - */ + /** The renderer managing this {@link EventSystem}. */ public renderer: Renderer; private currentCursor: string; @@ -131,9 +118,7 @@ export class EventSystem this.resolution = this.renderer.resolution; } - /** - * Destroys all event listeners and detaches the renderer. - */ + /** Destroys all event listeners and detaches the renderer. */ destroy(): void { this.setTargetElement(null); @@ -142,7 +127,6 @@ export class EventSystem /** * Sets the current cursor mode, handling any callbacks or CSS style changes. - * * @param mode - cursor mode, a key from the cursorStyles dictionary */ public setCursor(mode: string): void @@ -200,7 +184,6 @@ export class EventSystem /** * Event handler for pointer down events on {@link PIXI.EventSystem#domElement this.domElement}. - * * @param nativeEvent - The native mouse/pointer/touch event. */ private onPointerDown(nativeEvent: MouseEvent | PointerEvent | TouchEvent): void @@ -243,7 +226,6 @@ export class EventSystem /** * Event handler for pointer move events on on {@link PIXI.EventSystem#domElement this.domElement}. - * * @param nativeEvent - The native mouse/pointer/touch events. */ private onPointerMove(nativeEvent: MouseEvent | PointerEvent | TouchEvent): void @@ -267,7 +249,6 @@ export class EventSystem /** * Event handler for pointer up events on {@link PIXI.EventSystem#domElement this.domElement}. - * * @param nativeEvent - The native mouse/pointer/touch event. */ private onPointerUp(nativeEvent: MouseEvent | PointerEvent | TouchEvent): void @@ -294,7 +275,6 @@ export class EventSystem /** * Event handler for pointer over & out events on {@link PIXI.EventSystem#domElement this.domElement}. - * * @param nativeEvent - The native mouse/pointer/touch event. */ private onPointerOverOut(nativeEvent: MouseEvent | PointerEvent | TouchEvent): void @@ -318,7 +298,6 @@ export class EventSystem /** * Passive handler for `wheel` events on {@link EventSystem.domElement this.domElement}. - * * @param nativeEvent - The native wheel event. */ protected onWheel(nativeEvent: WheelEvent): void @@ -333,7 +312,6 @@ export class EventSystem * Sets the {@link PIXI.EventSystem#domElement domElement} and binds event listeners. * * To deregister the current DOM element without setting a new one, pass {@code null}. - * * @param element - The new DOM element. */ public setTargetElement(element: HTMLElement): void @@ -343,9 +321,7 @@ export class EventSystem this.addEvents(); } - /** - * Register event listeners on {@link PIXI.Renderer#domElement this.domElement}. - */ + /** Register event listeners on {@link PIXI.Renderer#domElement this.domElement}. */ private addEvents(): void { if (this.eventsAdded || !this.domElement) @@ -355,7 +331,7 @@ export class EventSystem const style = this.domElement.style as CrossCSSStyleDeclaration; - if (globalThis.navigator.msPointerEnabled) + if ((globalThis.navigator as any).msPointerEnabled) { style.msContentZooming = 'none'; style.msTouchAction = 'none'; @@ -409,9 +385,7 @@ export class EventSystem this.eventsAdded = true; } - /** - * Unregister event listeners on {@link PIXI.EventSystem#domElement this.domElement}. - */ + /** Unregister event listeners on {@link PIXI.EventSystem#domElement this.domElement}. */ private removeEvents(): void { if (!this.eventsAdded || !this.domElement) @@ -421,7 +395,7 @@ export class EventSystem const style = this.domElement.style as CrossCSSStyleDeclaration; - if (globalThis.navigator.msPointerEnabled) + if ((globalThis.navigator as any).msPointerEnabled) { style.msContentZooming = ''; style.msTouchAction = ''; @@ -467,7 +441,6 @@ export class EventSystem * Maps x and y coords from a DOM object and maps them correctly to the PixiJS view. The * resulting value is stored in the point. This takes into account the fact that the DOM * element could be scaled and positioned anywhere on the screen. - * * @param {PIXI.IPointData} point - the point that the result will be stored in * @param {number} x - the x coord of the position to map * @param {number} y - the y coord of the position to map @@ -501,12 +474,11 @@ export class EventSystem /** * Ensures that the original event object contains all data that a regular pointer event would have - * * @param event - The original event data from a touch or mouse event - * @return An array containing a single normalized pointer event, in the case of a pointer + * @returns An array containing a single normalized pointer event, in the case of a pointer * or mouse event, or a multiple normalized pointer events if there are multiple changed touches */ - private normalizeToPointerData(event: TouchEvent|MouseEvent|PointerEvent): PointerEvent[] + private normalizeToPointerData(event: TouchEvent | MouseEvent | PointerEvent): PointerEvent[] { const normalizedEvents = []; @@ -580,9 +552,8 @@ export class EventSystem * * The returned {@link PIXI.FederatedWheelEvent} is a shared instance. It will not persist across * multiple native wheel events. - * * @param nativeEvent - The native wheel event that occurred on the canvas. - * @return A federated wheel event. + * @returns A federated wheel event. */ protected normalizeWheelEvent(nativeEvent: WheelEvent): FederatedWheelEvent { @@ -607,7 +578,6 @@ export class EventSystem /** * Normalizes the {@code nativeEvent} into a federateed {@code FederatedPointerEvent}. - * * @param event * @param nativeEvent */ @@ -651,7 +621,6 @@ export class EventSystem /** * Transfers base & mouse event data from the {@code nativeEvent} to the federated event. - * * @param event * @param nativeEvent */ diff --git a/packages/events/src/FederatedEvent.ts b/packages/events/src/FederatedEvent.ts index b01782de1a..253853a56f 100644 --- a/packages/events/src/FederatedEvent.ts +++ b/packages/events/src/FederatedEvent.ts @@ -5,7 +5,6 @@ import type { FederatedEventTarget } from './FederatedEventTarget'; /** * An DOM-compatible synthetic event implementation that is "forwarded" on behalf of an original * FederatedEvent or native {@link https://dom.spec.whatwg.org/#event Event}. - * * @memberof PIXI * @typeParam N - The type of native event held. */ @@ -26,7 +25,6 @@ export class FederatedEvent implements UIEvent /** * Flag added for compatibility with DOM {@code Event}. It is not used in the Federated Events * API. - * * @see https://dom.spec.whatwg.org/#dom-event-composed */ public readonly composed = false; @@ -39,7 +37,6 @@ export class FederatedEvent implements UIEvent /** * The propagation phase. - * * @default {@link FederatedEvent.NONE} */ public eventPhase = FederatedEvent.prototype.NONE; @@ -92,10 +89,7 @@ export class FederatedEvent implements UIEvent */ public which: number; - /** - * The coordinates of the evnet relative to the nearest DOM layer. This is a non-standard - * property. - */ + /** The coordinates of the evnet relative to the nearest DOM layer. This is a non-standard property. */ public layer: Point = new Point(); /** @readonly */ @@ -104,9 +98,7 @@ export class FederatedEvent implements UIEvent /** @readonly */ get layerY(): number { return this.layer.y; } - /** - * The coordinates of the event relative to the DOM document. This is a non-standard property. - */ + /** The coordinates of the event relative to the DOM document. This is a non-standard property. */ public page: Point = new Point(); /** @readonly */ @@ -126,7 +118,6 @@ export class FederatedEvent implements UIEvent /** * Fallback for the deprecated {@link PIXI.InteractionEvent.data}. - * * @deprecated */ get data(): this @@ -134,9 +125,7 @@ export class FederatedEvent implements UIEvent return this; } - /** - * The propagation path for this event. Alias for {@link EventBoundary.propagationPath}. - */ + /** The propagation path for this event. Alias for {@link EventBoundary.propagationPath}. */ composedPath(): FederatedEventTarget[] { // Find the propagation path if it isn't cached or if the target has changed since since @@ -150,17 +139,17 @@ export class FederatedEvent implements UIEvent } /** - * Unimplemented method included for implementing the DOM interface {@code Event}. It will throw - * an {@code Error}. + * Unimplemented method included for implementing the DOM interface {@code Event}. It will throw an {@code Error}. + * @param _type + * @param _bubbles + * @param _cancelable */ initEvent(_type: string, _bubbles?: boolean, _cancelable?: boolean): void { throw new Error('initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.'); } - /** - * Prevent default behavior of PixiJS and the user agent. - */ + /** Prevent default behavior of PixiJS and the user agent. */ preventDefault(): void { if (this.nativeEvent instanceof Event && this.nativeEvent.cancelable) diff --git a/packages/events/src/FederatedEventTarget.ts b/packages/events/src/FederatedEventTarget.ts index 718f5e856d..ebaf8e8bbe 100644 --- a/packages/events/src/FederatedEventTarget.ts +++ b/packages/events/src/FederatedEventTarget.ts @@ -4,53 +4,54 @@ import { FederatedEvent } from './FederatedEvent'; import type { EventEmitter } from '@pixi/utils'; export type Cursor = 'auto' - | 'default' - | 'none' - | 'context-menu' - | 'help' - | 'pointer' - | 'progress' - | 'wait' - | 'cell' - | 'crosshair' - | 'text' - | 'vertical-text' - | 'alias' - | 'copy' - | 'move' - | 'no-drop' - | 'not-allowed' - | 'e-resize' - | 'n-resize' - | 'ne-resize' - | 'nw-resize' - | 's-resize' - | 'se-resize' - | 'sw-resize' - | 'w-resize' - | 'ns-resize' - | 'ew-resize' - | 'nesw-resize' - | 'col-resize' - | 'nwse-resize' - | 'row-resize' - | 'all-scroll' - | 'zoom-in' - | 'zoom-out' - | 'grab' - | 'grabbing'; +| 'default' +| 'none' +| 'context-menu' +| 'help' +| 'pointer' +| 'progress' +| 'wait' +| 'cell' +| 'crosshair' +| 'text' +| 'vertical-text' +| 'alias' +| 'copy' +| 'move' +| 'no-drop' +| 'not-allowed' +| 'e-resize' +| 'n-resize' +| 'ne-resize' +| 'nw-resize' +| 's-resize' +| 'se-resize' +| 'sw-resize' +| 'w-resize' +| 'ns-resize' +| 'ew-resize' +| 'nesw-resize' +| 'col-resize' +| 'nwse-resize' +| 'row-resize' +| 'all-scroll' +| 'zoom-in' +| 'zoom-out' +| 'grab' +| 'grabbing'; // @ignore - This is documented elsewhere. -export interface IHitArea { +export interface IHitArea +{ contains(x: number, y: number): boolean; } /** * Describes the shape for a {@link FederatedEvent}'s' `eventTarget`. - * * @memberof PIXI */ -export interface FederatedEventTarget extends EventEmitter, EventTarget { +export interface FederatedEventTarget extends EventEmitter, EventTarget +{ /** The cursor preferred when the mouse pointer is hovering over. */ cursor: Cursor | string; @@ -63,10 +64,7 @@ export interface FederatedEventTarget extends EventEmitter, EventTarget { /** Whether this event target should fire UI events. */ interactive: boolean; - /** - * Whether this event target has any children that need UI events. This can be used optimize - * event propagation. - */ + /** Whether this event target has any children that need UI events. This can be used optimize event propagation. */ interactiveChildren: boolean; /** The hit-area specifies the area for which pointer events should be captured by this event target. */ @@ -74,13 +72,12 @@ export interface FederatedEventTarget extends EventEmitter, EventTarget { } export const FederatedDisplayObject: Omit< - FederatedEventTarget, - 'parent' | 'children' | keyof EventEmitter | 'cursor' +FederatedEventTarget, +'parent' | 'children' | keyof EventEmitter | 'cursor' > = { /** * Enable interaction events for the DisplayObject. Touch, pointer and mouse * events will not be emitted unless `interactive` is set to `true`. - * * @example * const sprite = new PIXI.Sprite(texture); * sprite.interactive = true; @@ -94,7 +91,6 @@ export const FederatedDisplayObject: Omit< /** * Determines if the children to the displayObject can be clicked/touched * Setting this to false allows PixiJS to bypass a recursive `hitTest` function - * * @memberof PIXI.Container# */ interactiveChildren: true, @@ -102,7 +98,6 @@ export const FederatedDisplayObject: Omit< /** * Interaction shape. Children will be hit first, then this shape will be checked. * Setting this will cause this shape to be checked in hit tests rather than the displayObject's bounds. - * * @example * const sprite = new PIXI.Sprite(texture); * sprite.interactive = true; @@ -194,7 +189,7 @@ export const FederatedDisplayObject: Omit< * **IMPORTANT:** _Only_ available if using the `@pixi/events` package. * @memberof PIXI.DisplayObject * @param e - The event to dispatch. - * @return Whether the {@link PIXI.FederatedEvent.preventDefault preventDefault}() method was not invoked. + * @returns Whether the {@link PIXI.FederatedEvent.preventDefault preventDefault}() method was not invoked. * @example * // Reuse a click event! * button.dispatchEvent(clickEvent); diff --git a/packages/events/src/FederatedMouseEvent.ts b/packages/events/src/FederatedMouseEvent.ts index 928521f741..ee5c616d95 100644 --- a/packages/events/src/FederatedMouseEvent.ts +++ b/packages/events/src/FederatedMouseEvent.ts @@ -3,11 +3,10 @@ import { Point } from '@pixi/math'; /** * A {@link PIXI.FederatedEvent} for mouse events. - * * @memberof PIXI */ export class FederatedMouseEvent extends FederatedEvent< - MouseEvent | PointerEvent | TouchEvent +MouseEvent | PointerEvent | TouchEvent > implements MouseEvent { /** Whether the "alt" key was pressed when this mouse event occurred. */ @@ -31,9 +30,7 @@ export class FederatedMouseEvent extends FederatedEvent< /** Whether the "shift" key was pressed when this mouse event occurred. */ shiftKey: boolean; - /** - * The coordinates of the mouse event relative to the canvas. - */ + /** The coordinates of the mouse event relative to the canvas. */ public client: Point = new Point(); /** @readonly */ @@ -44,26 +41,20 @@ export class FederatedMouseEvent extends FederatedEvent< /** * Alias for {@link FederatedMouseEvent.clientX this.clientX}. - * * @readonly */ get x(): number { return this.clientX; } /** * Alias for {@link FederatedMouseEvent.clientY this.clientY}. - * * @readonly */ get y(): number { return this.clientY; } - /** - * This is the number of clicks that occurs in 200ms/click of each other. - */ + /** This is the number of clicks that occurs in 200ms/click of each other. */ public detail: number; - /** - * The movement in this pointer relative to the last `mousemove` event. - */ + /** The movement in this pointer relative to the last `mousemove` event. */ public movement: Point = new Point(); /** @readonly */ @@ -84,9 +75,7 @@ export class FederatedMouseEvent extends FederatedEvent< /** @readonly */ get offsetY(): number { return this.offset.y; } - /** - * The pointer coordinates in world space. - */ + /** The pointer coordinates in world space. */ public global: Point = new Point(); /** @readonly */ @@ -103,21 +92,18 @@ export class FederatedMouseEvent extends FederatedEvent< /** * The pointer coordinates in the renderer's screen. Alias for {@code screen.x}. - * * @readonly */ get screenX(): number { return this.screen.x; } /** * The pointer coordinates in the renderer's screen. Alias for {@code screen.y}. - * * @readonly */ get screenY(): number { return this.screen.y; } /** * Whether the modifier key was pressed when this event natively occurred. - * * @param key - The modifier key. */ getModifierState(key: string): boolean @@ -127,7 +113,21 @@ export class FederatedMouseEvent extends FederatedEvent< /** * Not supported. - * + * @param _typeArg + * @param _canBubbleArg + * @param _cancelableArg + * @param _viewArg + * @param _detailArg + * @param _screenXArg + * @param _screenYArg + * @param _clientXArg + * @param _clientYArg + * @param _ctrlKeyArg + * @param _altKeyArg + * @param _shiftKeyArg + * @param _metaKeyArg + * @param _buttonArg + * @param _relatedTargetArg * @deprecated */ // eslint-disable-next-line max-params diff --git a/packages/events/src/FederatedPointerEvent.ts b/packages/events/src/FederatedPointerEvent.ts index 5f26235008..030baae204 100644 --- a/packages/events/src/FederatedPointerEvent.ts +++ b/packages/events/src/FederatedPointerEvent.ts @@ -2,14 +2,12 @@ import { FederatedMouseEvent } from './FederatedMouseEvent'; /** * A {@link PIXI.FederatedEvent} for pointer events. - * * @memberof PIXI */ export class FederatedPointerEvent extends FederatedMouseEvent implements PointerEvent { /** * The unique identifier of the pointer. - * * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pointerId} */ public pointerId: number; @@ -17,7 +15,6 @@ export class FederatedPointerEvent extends FederatedMouseEvent implements Pointe /** * The width of the pointer's contact along the x-axis, measured in CSS pixels. * radiusX of TouchEvents will be represented by this value. - * * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/width */ public width = 0; @@ -25,21 +22,18 @@ export class FederatedPointerEvent extends FederatedMouseEvent implements Pointe /** * The height of the pointer's contact along the y-axis, measured in CSS pixels. * radiusY of TouchEvents will be represented by this value. - * * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/height */ public height = 0; /** * Indicates whether or not the pointer device that created the event is the primary pointer. - * * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/isPrimary */ public isPrimary = false; /** * The type of pointer that triggered the event. - * * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pointerType */ public pointerType: string; @@ -48,42 +42,35 @@ export class FederatedPointerEvent extends FederatedMouseEvent implements Pointe * Pressure applied by the pointing device during the event. *s * A Touch's force property will be represented by this value. - * * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pressure */ public pressure: number; /** * Barrel pressure on a stylus pointer. - * * @see https://w3c.github.io/pointerevents/#pointerevent-interface */ public tangentialPressure: number; /** * The angle, in degrees, between the pointer device and the screen. - * * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/tiltX */ public tiltX: number; /** * The angle, in degrees, between the pointer device and the screen. - * * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/tiltY */ public tiltY: number; /** * Twist of a stylus pointer. - * * @see https://w3c.github.io/pointerevents/#pointerevent-interface */ public twist: number; - /** - * This is the number of clicks that occurs in 200ms/click of each other. - */ + /** This is the number of clicks that occurs in 200ms/click of each other. */ public detail: number; // Only included for completeness for now diff --git a/packages/events/src/FederatedWheelEvent.ts b/packages/events/src/FederatedWheelEvent.ts index 89b5e6d5f5..02965487d0 100644 --- a/packages/events/src/FederatedWheelEvent.ts +++ b/packages/events/src/FederatedWheelEvent.ts @@ -2,7 +2,6 @@ import { FederatedMouseEvent } from './FederatedMouseEvent'; /** * A {@link PIXI.FederatedEvent} for wheel events. - * * @memberof PIXI */ export class FederatedWheelEvent extends FederatedMouseEvent implements WheelEvent diff --git a/packages/events/test/EventBoundary.tests.ts b/packages/events/test/EventBoundary.tests.ts index 6e5c521e77..53fd1d7986 100644 --- a/packages/events/test/EventBoundary.tests.ts +++ b/packages/events/test/EventBoundary.tests.ts @@ -4,9 +4,9 @@ import { Graphics } from '@pixi/graphics'; import sinon from 'sinon'; import { expect } from 'chai'; -describe('EventBoundary', function () +describe('EventBoundary', () => { - it('should fire capture, bubble events on the correct target', function () + it('should fire capture, bubble events on the correct target', () => { const stage = new Container(); const boundary = new EventBoundary(stage); @@ -50,7 +50,7 @@ describe('EventBoundary', function () expect(stageSpy).to.have.been.calledOnce; }); - it('should set hit-test target to most specific ancestor if hit object is not interactive', function () + it('should set hit-test target to most specific ancestor if hit object is not interactive', () => { const stage = new Container(); const boundary = new EventBoundary(stage); @@ -65,13 +65,14 @@ describe('EventBoundary', function () expect(hitTestTarget).to.equal(container); }); - it('should fire pointerupoutside only on relevant & still mounted targets', function () + it('should fire pointerupoutside only on relevant & still mounted targets', () => { const stage = new Container(); const boundary = new EventBoundary(stage); const container = stage.addChild(new Container()); const pressed = container.addChild(new Graphics().beginFill(0).drawRect(0, 0, 100, 100)); - const outside = stage.addChild(new Graphics().beginFill(0).drawRect(100, 0, 100, 100)); + + stage.addChild(new Graphics().beginFill(0).drawRect(100, 0, 100, 100)); const eventSpy = sinon.spy(); const containerSpy = sinon.spy(); @@ -101,7 +102,7 @@ describe('EventBoundary', function () off.global.set(150, 50); boundary.mapEvent(on); - expect(boundary.trackingData(1).pressTargetsByButton[1][2]).to.equal(pressed); + expect(boundary['trackingData'](1).pressTargetsByButton[1][2]).to.equal(pressed); pressed.destroy(); boundary.mapEvent(off); @@ -118,7 +119,7 @@ describe('EventBoundary', function () expect(stageSpy).to.have.been.calledOnce; }); - it('should fire pointerout on the most specific mounted ancestor of pointerover target', function () + it('should fire pointerout on the most specific mounted ancestor of pointerover target', () => { const stage = new Container(); const boundary = new EventBoundary(stage); @@ -133,13 +134,13 @@ describe('EventBoundary', function () const toOverSpy = sinon.spy(); over.addEventListener('pointerover', orgOverSpy); - container.addEventListener('pointerover', function (e) + container.addEventListener('pointerover', (e) => { expect(e.target).to.equal(over); orgContainerOverSpy(); }); over.addEventListener('pointerout', outSpy); - container.addEventListener('pointerout', function (e) + container.addEventListener('pointerout', (e) => { expect(e.target).to.equal(container); containerOutSpy(); diff --git a/packages/events/test/EventSystem.tests.ts b/packages/events/test/EventSystem.tests.ts index 18b71bf715..3bdb2631a4 100644 --- a/packages/events/test/EventSystem.tests.ts +++ b/packages/events/test/EventSystem.tests.ts @@ -5,27 +5,33 @@ import { Graphics } from '@pixi/graphics'; import sinon from 'sinon'; import { expect } from 'chai'; -function createRenderer(view, supportsPointerEvents) +function createRenderer(view?: HTMLCanvasElement, supportsPointerEvents?: boolean) { + // TODO: event emitter types do not appear in tests + interface EERenderer extends Renderer + { + events: any + } + const renderer = Renderer.create({ width: 100, height: 100, view, - }); + }) as EERenderer; - if (!renderer.events) + if (!renderer['events']) { renderer.addSystem(EventSystem, 'events'); } if (supportsPointerEvents === false) { - renderer.events.removeEvents(); - renderer.events.supportsPointerEvents = false; - renderer.events.setTargetElement(renderer.view); + renderer['events'].removeEvents(); + renderer['events'].supportsPointerEvents = false; + renderer['events'].setTargetElement(renderer.view); } - renderer.events.supportsTouchEvents = true; + renderer['events'].supportsTouchEvents = true; return renderer; } @@ -44,7 +50,7 @@ function createScene() return [stage, graphics]; } -describe('EventSystem', function () +describe('EventSystem', () => { // Share WebGL context for performance const view = document.createElement('canvas'); @@ -83,7 +89,12 @@ describe('EventSystem', function () { type: 'touchstart' }, { type: 'touchendoutside', native: 'touchend' }, ] - ]; + ] as Array<{ + type: string; + clientX?: number; + clientY?: number; + native?: string; + }>; // Maps native event types to their listeners on EventSystem. const handlers = { @@ -108,7 +119,7 @@ describe('EventSystem', function () const isMouseEvent = events[0].type.startsWith('mouse'); const isTouchEvent = events[0].type.startsWith('touch'); - it(`should fire ${events[events.length - 1].type}`, function () + it(`should fire ${events[events.length - 1].type}`, () => { const renderer = createRenderer(view, isMouseEvent); const stage = new Container(); @@ -127,7 +138,7 @@ describe('EventSystem', function () clientY = clientY || 25; const eventSpy = sinon.spy(); - const handler = handlers[native || type]; + const handler = handlers[(native || type) as keyof typeof handlers]; graphics.on(type, function testEvent(e) { @@ -149,7 +160,6 @@ describe('EventSystem', function () new Touch({ identifier: 0, target: renderer.view, - isPrimary: true, clientX, clientY, }), @@ -161,14 +171,14 @@ describe('EventSystem', function () event = new MouseEvent(native || type, { clientX, clientY }); } - renderer.events[handler](event); + renderer['events'][handler](event); expect(eventSpy).to.have.been.calledOnce; }); }); }); - it('should manage the CSS cursor', function () + it('should manage the CSS cursor', () => { const renderer = createRenderer(); const [stage, graphics] = createScene(); @@ -176,7 +186,7 @@ describe('EventSystem', function () renderer.render(stage); graphics.cursor = 'copy'; - renderer.events.onPointerMove( + renderer['events'].onPointerMove( new PointerEvent('pointermove', { clientX: 40, clientY: 40, @@ -189,7 +199,7 @@ describe('EventSystem', function () const eventSpy = sinon.spy(); graphics.on('mousemove', eventSpy); - renderer.events.onPointerMove( + renderer['events'].onPointerMove( new PointerEvent('pointermove', { clientX: 60, clientY: 60, @@ -201,7 +211,7 @@ describe('EventSystem', function () expect(renderer.view.style.cursor).to.equal('inherit'); }); - it('should dispatch synthetic over/out events on pointermove', function () + it('should dispatch synthetic over/out events on pointermove', () => { const renderer = createRenderer(); const [stage, graphics] = createScene(); @@ -220,19 +230,19 @@ describe('EventSystem', function () let callCount = 0; - graphics.on('pointerover', function () + graphics.on('pointerover', () => { expect(callCount).to.equal(0); primaryOverSpy(); ++callCount; }); - graphics.on('pointermove', function () + graphics.on('pointermove', () => { expect(callCount).to.equal(1); primaryMoveSpy(); ++callCount; }); - graphics.on('pointerout', function () + graphics.on('pointerout', () => { expect(callCount).to.equal(2); primaryOutSpy(); @@ -243,27 +253,27 @@ describe('EventSystem', function () const secondaryOutSpy = sinon.spy(); const secondaryMoveSpy = sinon.spy(); - second.on('pointerover', function () + second.on('pointerover', () => { expect(callCount).to.equal(3); secondaryOverSpy(); ++callCount; }); second.on('pointerout', secondaryOutSpy); - second.on('pointermove', function () + second.on('pointermove', () => { expect(callCount).to.equal(4); secondaryMoveSpy(); ++callCount; }); - renderer.events.onPointerMove( + renderer['events'].onPointerMove( new PointerEvent('pointermove', { clientX: 25, clientY: 25 }) ); expect(primaryOverSpy).to.have.been.calledOnce; expect(primaryMoveSpy).to.have.been.calledOnce; - renderer.events.onPointerMove( + renderer['events'].onPointerMove( new PointerEvent('pointermove', { clientX: 125, clientY: 25 }) ); expect(primaryOutSpy).to.have.been.calledOnce; @@ -272,7 +282,7 @@ describe('EventSystem', function () expect(secondaryOutSpy).to.not.have.been.calledOnce; }); - it('should dispatch click events', function () + it('should dispatch click events', () => { const renderer = createRenderer(); const [stage, graphics] = createScene(); @@ -280,13 +290,13 @@ describe('EventSystem', function () renderer.render(stage); - graphics.addEventListener('pointertap', function (e) + graphics.addEventListener('pointertap', (e) => { expect(e.type).to.equal('click'); eventSpy(); }); - renderer.events.onPointerDown( + renderer['events'].onPointerDown( new PointerEvent('pointerdown', { clientX: 25, clientY: 25 }) ); const e = new PointerEvent('pointerup', { clientX: 30, clientY: 20 }); @@ -296,12 +306,12 @@ describe('EventSystem', function () writable: false, value: renderer.view }); - renderer.events.onPointerUp(e); + renderer['events'].onPointerUp(e); expect(eventSpy).to.have.been.calledOnce; }); - it('should set the detail of click events to the click count', function (done) + it('should set the detail of click events to the click count', (done) => { const renderer = createRenderer(); const [stage, graphics] = createScene(); @@ -310,16 +320,16 @@ describe('EventSystem', function () renderer.render(stage); - graphics.addEventListener('pointertap', function (e) + graphics.addEventListener('pointertap', (e) => { ++clickCount; - expect(e.detail).to.equal(clickCount); + expect((e as PointerEvent).detail).to.equal(clickCount); eventSpy(); }); for (let i = 0; i < 3; i++) { - renderer.events.onPointerDown( + renderer['events'].onPointerDown( new PointerEvent('pointerdown', { clientX: 25, clientY: 25 }) ); const e = new PointerEvent('pointerup', { clientX: 30, clientY: 20 }); @@ -329,7 +339,7 @@ describe('EventSystem', function () writable: false, value: renderer.view }); - renderer.events.onPointerUp(e); + renderer['events'].onPointerUp(e); } expect(eventSpy).to.have.been.calledThrice; @@ -338,15 +348,15 @@ describe('EventSystem', function () const newSpy = sinon.spy(); - graphics.addEventListener('pointertap', function (e) + graphics.addEventListener('pointertap', (e) => { - expect(e.detail).to.equal(1); + expect((e as PointerEvent).detail).to.equal(1); newSpy(); }); - setTimeout(function () + setTimeout(() => { - renderer.events.onPointerDown( + renderer['events'].onPointerDown( new PointerEvent('pointerdown', { clientX: 25, clientY: 25 }) ); const e = new PointerEvent('pointerup', { clientX: 30, clientY: 20 }); @@ -356,7 +366,7 @@ describe('EventSystem', function () writable: false, value: renderer.view }); - renderer.events.onPointerUp(e); + renderer['events'].onPointerUp(e); expect(newSpy).to.have.been.calledOnce; done(); diff --git a/packages/extract/package.json b/packages/extract/package.json index cfc5fce6d4..f35833b6bc 100644 --- a/packages/extract/package.json +++ b/packages/extract/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/extract", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/extract.js", "module": "dist/esm/extract.js", "bundle": "dist/browser/extract.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/extract.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/extract.js" + } + } + }, "description": "Extract raw graphics data from renderer", "author": "Mat Groves", "contributors": [ @@ -25,8 +38,8 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/core": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/core": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/utils": "6.4.2" } } diff --git a/packages/extract/src/Extract.ts b/packages/extract/src/Extract.ts index 7335bd4277..6c247d4a12 100644 --- a/packages/extract/src/Extract.ts +++ b/packages/extract/src/Extract.ts @@ -3,18 +3,32 @@ import { Rectangle } from '@pixi/math'; import { RenderTexture } from '@pixi/core'; import type { Renderer, IRendererPlugin } from '@pixi/core'; -import type { DisplayObject } from '@pixi/display'; +import { DisplayObject } from '@pixi/display'; const TEMP_RECT = new Rectangle(); const BYTES_PER_PIXEL = 4; +/** + * this interface is used to extract only a single pixel of Render Texture or Display Object + * if you use this Interface all fields is required + * @example + * test: PixelExtractOptions = { x: 15, y: 20, resolution: 4, width: 10, height: 10 } + */ +export interface PixelExtractOptions +{ + x: number, + y: number, + height: number, + resolution: number, + width: number +} + /** * This class provides renderer-specific plugins for exporting content from a renderer. * For instance, these plugins can be used for saving an Image, Canvas element or for exporting the raw image data (pixels). * * Do not instantiate these plugins directly. It is available from the `renderer.plugins` property. * See {@link PIXI.CanvasRenderer#plugins} or {@link PIXI.Renderer#plugins}. - * * @example * // Create a new app (will auto-add extract plugin to renderer) * const app = new PIXI.Application(); @@ -27,9 +41,9 @@ const BYTES_PER_PIXEL = 4; * // Render the graphics as an HTMLImageElement * const image = app.renderer.plugins.extract.image(graphics); * document.body.appendChild(image); - * * @memberof PIXI */ + export class Extract implements IRendererPlugin { private renderer: Renderer; @@ -44,14 +58,13 @@ export class Extract implements IRendererPlugin /** * Will return a HTML Image of the target - * * @param target - A displayObject or renderTexture * to convert. If left empty will use the main renderer * @param format - Image format, e.g. "image/jpeg" or "image/webp". * @param quality - JPEG or Webp compression from 0 to 1. Default is 0.92. - * @return - HTML Image of the target + * @returns - HTML Image of the target */ - public image(target: DisplayObject|RenderTexture, format?: string, quality?: number): HTMLImageElement + public image(target: DisplayObject | RenderTexture, format?: string, quality?: number): HTMLImageElement { const image = new Image(); @@ -63,26 +76,24 @@ export class Extract implements IRendererPlugin /** * Will return a base64 encoded string of this target. It works by calling * `Extract.getCanvas` and then running toDataURL on that. - * * @param target - A displayObject or renderTexture * to convert. If left empty will use the main renderer * @param format - Image format, e.g. "image/jpeg" or "image/webp". * @param quality - JPEG or Webp compression from 0 to 1. Default is 0.92. - * @return - A base64 encoded string of the texture. + * @returns - A base64 encoded string of the texture. */ - public base64(target: DisplayObject|RenderTexture, format?: string, quality?: number): string + public base64(target: DisplayObject | RenderTexture, format?: string, quality?: number): string { return this.canvas(target).toDataURL(format, quality); } /** * Creates a Canvas element, renders this target to it and then returns it. - * * @param target - A displayObject or renderTexture * to convert. If left empty will use the main renderer - * @return - A Canvas element with the texture rendered on. + * @returns - A Canvas element with the texture rendered on. */ - public canvas(target: DisplayObject|RenderTexture): HTMLCanvasElement + public canvas(target: DisplayObject | RenderTexture): HTMLCanvasElement { const renderer = this.renderer; let resolution; @@ -177,12 +188,12 @@ export class Extract implements IRendererPlugin /** * Will return a one-dimensional array containing the pixel data of the entire texture in RGBA * order, with integer values between 0 and 255 (included). - * * @param target - A displayObject or renderTexture * to convert. If left empty will use the main renderer - * @return - One-dimensional array containing the pixel data of the entire texture + * @param options + * @returns - One-dimensional array containing the pixel data of the entire texture */ - public pixels(target?: DisplayObject|RenderTexture): Uint8Array + public pixels(target?: DisplayObject | RenderTexture, options?: PixelExtractOptions): Uint8Array { const renderer = this.renderer; let resolution; @@ -196,7 +207,7 @@ export class Extract implements IRendererPlugin { renderTexture = target; } - else + else if (target instanceof DisplayObject) { renderTexture = this.renderer.generateTexture(target); generated = true; @@ -205,11 +216,31 @@ export class Extract implements IRendererPlugin if (renderTexture) { - resolution = renderTexture.baseTexture.resolution; - frame = renderTexture.frame; + if (options) + { + resolution = options.resolution; + frame = renderTexture.frame; - // bind the buffer - renderer.renderTexture.bind(renderTexture); + // bind the buffer + renderer.renderTexture.bind(renderTexture); + } + else + { + resolution = renderTexture.baseTexture.resolution; + frame = renderTexture.frame; + + // bind the buffer + renderer.renderTexture.bind(renderTexture); + } + } + else if (options) + { + resolution = options.resolution; + + frame = TEMP_RECT; + frame.width = options.width; + frame.height = options.height; + renderer.renderTexture.bind(null); } else { @@ -258,7 +289,6 @@ export class Extract implements IRendererPlugin /** * Takes premultiplied pixel data and produces regular pixel data - * * @private * @param pixels - array of pixel data * @param out - output array diff --git a/packages/extract/test/Extract.tests.ts b/packages/extract/test/Extract.tests.ts index ab970b2a29..49a4035ff4 100644 --- a/packages/extract/test/Extract.tests.ts +++ b/packages/extract/test/Extract.tests.ts @@ -2,19 +2,19 @@ import { Sprite } from '@pixi/sprite'; import { expect } from 'chai'; import { skipHello } from '@pixi/utils'; import { Texture, RenderTexture, BatchRenderer, Renderer } from '@pixi/core'; -import { Extract } from '@pixi/extract'; +import { Extract, PixelExtractOptions } from '@pixi/extract'; skipHello(); -describe('Extract', function () +describe('Extract', () => { - before(function () + before(() => { Renderer.registerPlugin('extract', Extract); Renderer.registerPlugin('batch', BatchRenderer); }); - it('should access extract on renderer', function () + it('should access extract on renderer', () => { const renderer = new Renderer(); @@ -23,7 +23,7 @@ describe('Extract', function () renderer.destroy(); }); - it('should extract an sprite', function () + it('should extract an sprite', () => { const renderer = new Renderer(); const sprite = new Sprite(Texture.WHITE); @@ -38,31 +38,32 @@ describe('Extract', function () sprite.destroy(); }); - it('should extract with no arguments', function () + it('should extract with no arguments', () => { const renderer = new Renderer(); const extract = renderer.plugins.extract as Extract; - expect(extract.canvas()).to.be.an.instanceof(HTMLCanvasElement); - expect(extract.base64()).to.be.a('string'); + expect(extract.canvas(undefined)).to.be.an.instanceof(HTMLCanvasElement); + expect(extract.base64(undefined)).to.be.a('string'); expect(extract.pixels()).to.be.instanceOf(Uint8Array); - expect(extract.image()).to.be.instanceOf(HTMLImageElement); + expect(extract.image(undefined)).to.be.instanceOf(HTMLImageElement); renderer.destroy(); }); - it('should extract a render texture', function () + it('should extract a render texture', () => { const renderer = new Renderer(); const extract = renderer.plugins.extract as Extract; const renderTexture = RenderTexture.create({ width: 10, height: 10 }); const sprite = new Sprite(Texture.WHITE); + const test: PixelExtractOptions = { x: 1, y: 2, resolution: 5, width: 10, height: 10 }; renderer.render(sprite, { renderTexture }); expect(extract.canvas(renderTexture)).to.be.an.instanceof(HTMLCanvasElement); expect(extract.base64(renderTexture)).to.be.a('string'); - expect(extract.pixels(renderTexture)).to.be.instanceOf(Uint8Array); + expect(extract.pixels(renderTexture, test)).to.be.instanceOf(Uint8Array); expect(extract.image(renderTexture)).to.be.instanceOf(HTMLImageElement); renderer.destroy(); diff --git a/packages/filters/filter-alpha/LICENSE b/packages/filter-alpha/LICENSE similarity index 100% rename from packages/filters/filter-alpha/LICENSE rename to packages/filter-alpha/LICENSE diff --git a/packages/filters/filter-alpha/README.md b/packages/filter-alpha/README.md similarity index 100% rename from packages/filters/filter-alpha/README.md rename to packages/filter-alpha/README.md diff --git a/packages/filters/filter-alpha/package.json b/packages/filter-alpha/package.json similarity index 69% rename from packages/filters/filter-alpha/package.json rename to packages/filter-alpha/package.json index af84f6a4bc..ecef8d1ed0 100644 --- a/packages/filters/filter-alpha/package.json +++ b/packages/filter-alpha/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/filter-alpha", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/filter-alpha.js", "module": "dist/esm/filter-alpha.js", "bundle": "dist/browser/filter-alpha.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/filter-alpha.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/filter-alpha.js" + } + } + }, "namespace": "PIXI.filters", "description": "Filter that applies alpha evenly across the entire display object and any opaque elements it contains", "author": "Mat Groves", @@ -26,6 +39,6 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/core": "6.3.0" + "@pixi/core": "6.4.2" } } diff --git a/packages/filters/filter-alpha/src/AlphaFilter.ts b/packages/filter-alpha/src/AlphaFilter.ts similarity index 99% rename from packages/filters/filter-alpha/src/AlphaFilter.ts rename to packages/filter-alpha/src/AlphaFilter.ts index b02e3485cf..a8d124d396 100644 --- a/packages/filters/filter-alpha/src/AlphaFilter.ts +++ b/packages/filter-alpha/src/AlphaFilter.ts @@ -13,7 +13,6 @@ import fragment from './alpha.frag'; * 1. Assign a blendMode to this filter, blend all elements inside display object with background. * * 2. To use clipping in display coordinates, assign a filterArea to the same container that has this filter. - * * @memberof PIXI.filters */ export class AlphaFilter extends Filter @@ -30,7 +29,6 @@ export class AlphaFilter extends Filter /** * Coefficient for alpha multiplication - * * @default 1 */ get alpha(): number diff --git a/packages/filters/filter-alpha/src/alpha.frag b/packages/filter-alpha/src/alpha.frag similarity index 100% rename from packages/filters/filter-alpha/src/alpha.frag rename to packages/filter-alpha/src/alpha.frag diff --git a/packages/filters/filter-alpha/src/index.ts b/packages/filter-alpha/src/index.ts similarity index 100% rename from packages/filters/filter-alpha/src/index.ts rename to packages/filter-alpha/src/index.ts diff --git a/packages/filters/filter-alpha/test/AlphaFilter.tests.ts b/packages/filter-alpha/test/AlphaFilter.tests.ts similarity index 76% rename from packages/filters/filter-alpha/test/AlphaFilter.tests.ts rename to packages/filter-alpha/test/AlphaFilter.tests.ts index 87cddbbdcc..54f850c9c9 100644 --- a/packages/filters/filter-alpha/test/AlphaFilter.tests.ts +++ b/packages/filter-alpha/test/AlphaFilter.tests.ts @@ -1,9 +1,9 @@ import { AlphaFilter } from '@pixi/filter-alpha'; import { expect } from 'chai'; -describe('AlphaFilter', function () +describe('AlphaFilter', () => { - it('should construct filter', function () + it('should construct filter', () => { const filter = new AlphaFilter(); @@ -13,7 +13,7 @@ describe('AlphaFilter', function () filter.destroy(); }); - it('should allow alpha to be set', function () + it('should allow alpha to be set', () => { const filter = new AlphaFilter(); diff --git a/packages/filters/filter-blur/LICENSE b/packages/filter-blur/LICENSE similarity index 100% rename from packages/filters/filter-blur/LICENSE rename to packages/filter-blur/LICENSE diff --git a/packages/filters/filter-blur/README.md b/packages/filter-blur/README.md similarity index 100% rename from packages/filters/filter-blur/README.md rename to packages/filter-blur/README.md diff --git a/packages/filters/filter-blur/package.json b/packages/filter-blur/package.json similarity index 65% rename from packages/filters/filter-blur/package.json rename to packages/filter-blur/package.json index 9a5bb6d4d2..97603ca825 100644 --- a/packages/filters/filter-blur/package.json +++ b/packages/filter-blur/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/filter-blur", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/filter-blur.js", "module": "dist/esm/filter-blur.js", "bundle": "dist/browser/filter-blur.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/filter-blur.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/filter-blur.js" + } + } + }, "namespace": "PIXI.filters", "description": "Filter that blurs the display object", "author": "Mat Groves", @@ -26,7 +39,7 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/core": "6.3.0", - "@pixi/settings": "6.3.0" + "@pixi/core": "6.4.2", + "@pixi/settings": "6.4.2" } } diff --git a/packages/filters/filter-blur/src/BlurFilter.ts b/packages/filter-blur/src/BlurFilter.ts similarity index 98% rename from packages/filters/filter-blur/src/BlurFilter.ts rename to packages/filter-blur/src/BlurFilter.ts index 889f303144..096ea02d74 100644 --- a/packages/filters/filter-blur/src/BlurFilter.ts +++ b/packages/filter-blur/src/BlurFilter.ts @@ -10,7 +10,6 @@ import type { BLEND_MODES } from '@pixi/constants'; * The BlurFilter applies a Gaussian blur to an object. * * The strength of the blur can be set for the x-axis and y-axis separately. - * * @memberof PIXI.filters */ export class BlurFilter extends Filter @@ -42,7 +41,6 @@ export class BlurFilter extends Filter /** * Applies the filter. - * * @param filterManager - The manager. * @param input - The input target. * @param output - The output target. @@ -86,7 +84,6 @@ export class BlurFilter extends Filter /** * Sets the strength of both the blurX and blurY properties simultaneously - * * @default 2 */ get blur(): number @@ -102,7 +99,6 @@ export class BlurFilter extends Filter /** * Sets the number of passes for blur. More passes means higher quality bluring. - * * @default 1 */ get quality(): number @@ -117,7 +113,6 @@ export class BlurFilter extends Filter /** * Sets the strength of the blurX property - * * @default 2 */ get blurX(): number @@ -133,7 +128,6 @@ export class BlurFilter extends Filter /** * Sets the strength of the blurY property - * * @default 2 */ get blurY(): number @@ -149,7 +143,6 @@ export class BlurFilter extends Filter /** * Sets the blendmode of the filter - * * @default PIXI.BLEND_MODES.NORMAL */ get blendMode(): BLEND_MODES @@ -164,7 +157,6 @@ export class BlurFilter extends Filter /** * If set to true the edge of the target will be clamped - * * @default false */ get repeatEdgePixels(): boolean diff --git a/packages/filters/filter-blur/src/BlurFilterPass.ts b/packages/filter-blur/src/BlurFilterPass.ts similarity index 99% rename from packages/filters/filter-blur/src/BlurFilterPass.ts rename to packages/filter-blur/src/BlurFilterPass.ts index 2cb7982414..87806f2948 100644 --- a/packages/filters/filter-blur/src/BlurFilterPass.ts +++ b/packages/filter-blur/src/BlurFilterPass.ts @@ -8,7 +8,6 @@ import type { FilterSystem, RenderTexture } from '@pixi/core'; /** * The BlurFilterPass applies a horizontal or vertical Gaussian blur to an object. - * * @memberof PIXI.filters */ export class BlurFilterPass extends Filter @@ -51,7 +50,6 @@ export class BlurFilterPass extends Filter /** * Applies the filter. - * * @param filterManager - The manager. * @param input - The input target. * @param output - The output target. @@ -125,7 +123,6 @@ export class BlurFilterPass extends Filter } /** * Sets the strength of both the blur. - * * @default 16 */ get blur(): number @@ -142,7 +139,6 @@ export class BlurFilterPass extends Filter /** * Sets the quality of the blur by modifying the number of passes. More passes means higher * quality bluring but the lower the performance. - * * @default 4 */ get quality(): number diff --git a/packages/filters/filter-blur/src/generateBlurFragSource.ts b/packages/filter-blur/src/generateBlurFragSource.ts similarity index 98% rename from packages/filters/filter-blur/src/generateBlurFragSource.ts rename to packages/filter-blur/src/generateBlurFragSource.ts index 090ad96e12..376d2c3956 100644 --- a/packages/filters/filter-blur/src/generateBlurFragSource.ts +++ b/packages/filter-blur/src/generateBlurFragSource.ts @@ -1,4 +1,5 @@ -interface IGAUSSIAN_VALUES { +interface IGAUSSIAN_VALUES +{ [x: number]: number[]; } const GAUSSIAN_VALUES: IGAUSSIAN_VALUES = { diff --git a/packages/filters/filter-blur/src/generateBlurVertSource.ts b/packages/filter-blur/src/generateBlurVertSource.ts similarity index 100% rename from packages/filters/filter-blur/src/generateBlurVertSource.ts rename to packages/filter-blur/src/generateBlurVertSource.ts diff --git a/packages/filters/filter-blur/src/getMaxBlurKernelSize.ts b/packages/filter-blur/src/getMaxBlurKernelSize.ts similarity index 100% rename from packages/filters/filter-blur/src/getMaxBlurKernelSize.ts rename to packages/filter-blur/src/getMaxBlurKernelSize.ts diff --git a/packages/filters/filter-blur/src/index.ts b/packages/filter-blur/src/index.ts similarity index 100% rename from packages/filters/filter-blur/src/index.ts rename to packages/filter-blur/src/index.ts diff --git a/packages/filters/filter-blur/test/BlurFilter.tests.ts b/packages/filter-blur/test/BlurFilter.tests.ts similarity index 84% rename from packages/filters/filter-blur/test/BlurFilter.tests.ts rename to packages/filter-blur/test/BlurFilter.tests.ts index 41485517b7..241a1ace8d 100644 --- a/packages/filters/filter-blur/test/BlurFilter.tests.ts +++ b/packages/filter-blur/test/BlurFilter.tests.ts @@ -1,9 +1,9 @@ import { BlurFilter } from '@pixi/filter-blur'; import { expect } from 'chai'; -describe('BlurFilter', function () +describe('BlurFilter', () => { - it('should construct filter', function () + it('should construct filter', () => { const filter = new BlurFilter(); @@ -16,7 +16,7 @@ describe('BlurFilter', function () filter.destroy(); }); - it('should support repeatEdgePixels', function () + it('should support repeatEdgePixels', () => { const filter = new BlurFilter(); diff --git a/packages/filters/filter-color-matrix/LICENSE b/packages/filter-color-matrix/LICENSE similarity index 100% rename from packages/filters/filter-color-matrix/LICENSE rename to packages/filter-color-matrix/LICENSE diff --git a/packages/filters/filter-color-matrix/README.md b/packages/filter-color-matrix/README.md similarity index 100% rename from packages/filters/filter-color-matrix/README.md rename to packages/filter-color-matrix/README.md diff --git a/packages/filters/filter-color-matrix/package.json b/packages/filter-color-matrix/package.json similarity index 68% rename from packages/filters/filter-color-matrix/package.json rename to packages/filter-color-matrix/package.json index bcfac4bdfe..62a2a1b58b 100644 --- a/packages/filters/filter-color-matrix/package.json +++ b/packages/filter-color-matrix/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/filter-color-matrix", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/filter-color-matrix.js", "module": "dist/esm/filter-color-matrix.js", "bundle": "dist/browser/filter-color-matrix.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/filter-color-matrix.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/filter-color-matrix.js" + } + } + }, "namespace": "PIXI.filters", "description": "Filter that lets you change RGBA via a 5x4 matrix transformation", "author": "Mat Groves", @@ -26,6 +39,6 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/core": "6.3.0" + "@pixi/core": "6.4.2" } } diff --git a/packages/filters/filter-color-matrix/src/ColorMatrixFilter.ts b/packages/filter-color-matrix/src/ColorMatrixFilter.ts similarity index 98% rename from packages/filters/filter-color-matrix/src/ColorMatrixFilter.ts rename to packages/filter-color-matrix/src/ColorMatrixFilter.ts index bd563d1f23..4c4038c257 100644 --- a/packages/filters/filter-color-matrix/src/ColorMatrixFilter.ts +++ b/packages/filter-color-matrix/src/ColorMatrixFilter.ts @@ -39,7 +39,6 @@ export class ColorMatrixFilter extends Filter /** * Transforms current matrix and set the new one - * * @param {number[]} matrix - 5x4 matrix * @param multiply - if true, current matrix and matrix are multiplied. If false, * just set the current matrix with @param matrix @@ -60,7 +59,6 @@ export class ColorMatrixFilter extends Filter /** * Multiplies two mat5's - * * @private * @param out - 5x4 matrix the receiving matrix * @param a - 5x4 matrix the first operand @@ -102,9 +100,8 @@ export class ColorMatrixFilter extends Filter /** * Create a Float32 Array and normalize the offset component to 0-1 - * * @param {number[]} matrix - 5x4 matrix - * @return {number[]} 5x4 matrix with all values between 0-1 + * @returns {number[]} 5x4 matrix with all values between 0-1 */ private _colorMatrix(matrix: ColorMatrix): ColorMatrix { @@ -121,7 +118,6 @@ export class ColorMatrixFilter extends Filter /** * Adjusts brightness - * * @param b - value of the brigthness (0-1, where 0 is black) * @param multiply - if true, current matrix and matrix are multiplied. If false, * just set the current matrix with @param matrix @@ -142,7 +138,6 @@ export class ColorMatrixFilter extends Filter * Sets each channel on the diagonal of the color matrix. * This can be used to achieve a tinting effect on Containers similar to the tint field of some * display objects like Sprite, Text, Graphics, and Mesh. - * * @param color - Color of the tint. This is a hex value. * @param multiply - if true, current matrix and matrix are multiplied. If false, * just set the current matrix with @param matrix @@ -165,7 +160,6 @@ export class ColorMatrixFilter extends Filter /** * Set the matrices in grey scales - * * @param scale - value of the grey (0-1, where 0 is black) * @param multiply - if true, current matrix and matrix are multiplied. If false, * just set the current matrix with @param matrix @@ -184,7 +178,6 @@ export class ColorMatrixFilter extends Filter /** * Set the black and white matrice. - * * @param multiply - if true, current matrix and matrix are multiplied. If false, * just set the current matrix with @param matrix */ @@ -202,7 +195,6 @@ export class ColorMatrixFilter extends Filter /** * Set the hue property of the color - * * @param rotation - in degrees * @param multiply - if true, current matrix and matrix are multiplied. If false, * just set the current matrix with @param matrix @@ -257,7 +249,6 @@ export class ColorMatrixFilter extends Filter * Set the contrast matrix, increase the separation between dark and bright * Increase contrast : shadows darker and highlights brighter * Decrease contrast : bring the shadows up and the highlights down - * * @param amount - value of the contrast (0-1) * @param multiply - if true, current matrix and matrix are multiplied. If false, * just set the current matrix with @param matrix @@ -280,7 +271,6 @@ export class ColorMatrixFilter extends Filter /** * Set the saturation matrix, increase the separation between colors * Increase saturation : increase contrast, brightness, and sharpness - * * @param amount - The saturation amount (0-1) * @param multiply - if true, current matrix and matrix are multiplied. If false, * just set the current matrix with @param matrix @@ -300,11 +290,7 @@ export class ColorMatrixFilter extends Filter this._loadMatrix(matrix, multiply); } - /** - * Desaturate image (remove color) - * - * Call the saturate function - */ + /** Desaturate image (remove color) Call the saturate function */ public desaturate(): void // eslint-disable-line no-unused-vars { this.saturate(-1); @@ -312,7 +298,6 @@ export class ColorMatrixFilter extends Filter /** * Negative image (inverse of classic rgb matrix) - * * @param multiply - if true, current matrix and matrix are multiplied. If false, * just set the current matrix with @param matrix */ @@ -330,7 +315,6 @@ export class ColorMatrixFilter extends Filter /** * Sepia image - * * @param multiply - if true, current matrix and matrix are multiplied. If false, * just set the current matrix with @param matrix */ @@ -348,7 +332,6 @@ export class ColorMatrixFilter extends Filter /** * Color motion picture process invented in 1916 (thanks Dominic Szablewski) - * * @param multiply - if true, current matrix and matrix are multiplied. If false, * just set the current matrix with @param matrix */ @@ -366,7 +349,6 @@ export class ColorMatrixFilter extends Filter /** * Polaroid filter - * * @param multiply - if true, current matrix and matrix are multiplied. If false, * just set the current matrix with @param matrix */ @@ -384,7 +366,6 @@ export class ColorMatrixFilter extends Filter /** * Filter who transforms : Red -> Blue and Blue -> Red - * * @param multiply - if true, current matrix and matrix are multiplied. If false, * just set the current matrix with @param matrix */ @@ -402,7 +383,6 @@ export class ColorMatrixFilter extends Filter /** * Color reversal film introduced by Eastman Kodak in 1935. (thanks Dominic Szablewski) - * * @param multiply - if true, current matrix and matrix are multiplied. If false, * just set the current matrix with @param matrix */ @@ -420,7 +400,6 @@ export class ColorMatrixFilter extends Filter /** * Brown delicious browni filter (thanks Dominic Szablewski) - * * @param multiply - if true, current matrix and matrix are multiplied. If false, * just set the current matrix with @param matrix */ @@ -438,7 +417,6 @@ export class ColorMatrixFilter extends Filter /** * Vintage filter (thanks Dominic Szablewski) - * * @param multiply - if true, current matrix and matrix are multiplied. If false, * just set the current matrix with @param matrix */ @@ -456,7 +434,6 @@ export class ColorMatrixFilter extends Filter /** * We don't know exactly what it does, kind of gradient map, but funny to play with! - * * @param desaturation - Tone values. * @param toned - Tone values. * @param lightColor - Tone values, example: `0xFFE580` @@ -491,7 +468,6 @@ export class ColorMatrixFilter extends Filter /** * Night effect - * * @param intensity - The intensity of the night effect. * @param multiply - if true, current matrix and matrix are multiplied. If false, * just set the current matrix with @param matrix @@ -514,7 +490,6 @@ export class ColorMatrixFilter extends Filter * Predator effect * * Erase the current matrix by setting a new indepent one - * * @param amount - how much the predator feels his future victim * @param multiply - if true, current matrix and matrix are multiplied. If false, * just set the current matrix with @param matrix @@ -551,7 +526,6 @@ export class ColorMatrixFilter extends Filter * LSD effect * * Multiply the current matrix - * * @param multiply - if true, current matrix and matrix are multiplied. If false, * just set the current matrix with @param matrix */ @@ -582,7 +556,6 @@ export class ColorMatrixFilter extends Filter /** * The matrix of the color matrix filter - * * @member {number[]} * @default [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0] */ @@ -602,7 +575,6 @@ export class ColorMatrixFilter extends Filter * When the value is 0, the original color is used without modification. * When the value is 1, the result color is used. * When in the range (0, 1) the color is interpolated between the original and result by this amount. - * * @default 1 */ get alpha(): number diff --git a/packages/filters/filter-color-matrix/src/colorMatrix.frag b/packages/filter-color-matrix/src/colorMatrix.frag similarity index 100% rename from packages/filters/filter-color-matrix/src/colorMatrix.frag rename to packages/filter-color-matrix/src/colorMatrix.frag diff --git a/packages/filters/filter-color-matrix/src/index.ts b/packages/filter-color-matrix/src/index.ts similarity index 100% rename from packages/filters/filter-color-matrix/src/index.ts rename to packages/filter-color-matrix/src/index.ts diff --git a/packages/filters/filter-color-matrix/test/ColorMatrixFilter.tests.ts b/packages/filter-color-matrix/test/ColorMatrixFilter.tests.ts similarity index 90% rename from packages/filters/filter-color-matrix/test/ColorMatrixFilter.tests.ts rename to packages/filter-color-matrix/test/ColorMatrixFilter.tests.ts index e6e2249c63..1e23350073 100644 --- a/packages/filters/filter-color-matrix/test/ColorMatrixFilter.tests.ts +++ b/packages/filter-color-matrix/test/ColorMatrixFilter.tests.ts @@ -1,9 +1,9 @@ import { ColorMatrixFilter } from '@pixi/filter-color-matrix'; import { expect } from 'chai'; -describe('ColorMatrixFilter', function () +describe('ColorMatrixFilter', () => { - it('should construct filter', function () + it('should construct filter', () => { const filter = new ColorMatrixFilter(); @@ -20,7 +20,7 @@ describe('ColorMatrixFilter', function () filter.destroy(); }); - it('should run all operations without multiply', function () + it('should run all operations without multiply', () => { const filter = new ColorMatrixFilter(); @@ -49,7 +49,7 @@ describe('ColorMatrixFilter', function () filter.destroy(); }); - it('should run all operations with multiply', function () + it('should run all operations with multiply', () => { const filter = new ColorMatrixFilter(); diff --git a/packages/filters/filter-displacement/LICENSE b/packages/filter-displacement/LICENSE similarity index 100% rename from packages/filters/filter-displacement/LICENSE rename to packages/filter-displacement/LICENSE diff --git a/packages/filters/filter-displacement/README.md b/packages/filter-displacement/README.md similarity index 100% rename from packages/filters/filter-displacement/README.md rename to packages/filter-displacement/README.md diff --git a/packages/filters/filter-displacement/package.json b/packages/filter-displacement/package.json similarity index 66% rename from packages/filters/filter-displacement/package.json rename to packages/filter-displacement/package.json index 480d027e73..9f23828f58 100644 --- a/packages/filters/filter-displacement/package.json +++ b/packages/filter-displacement/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/filter-displacement", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/filter-displacement.js", "module": "dist/esm/filter-displacement.js", "bundle": "dist/browser/filter-displacement.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/filter-displacement.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/filter-displacement.js" + } + } + }, "namespace": "PIXI.filters", "description": "Filter that allows offsetting of pixel values to create warping effects", "author": "Mat Groves", @@ -26,7 +39,7 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/core": "6.3.0", - "@pixi/math": "6.3.0" + "@pixi/core": "6.4.2", + "@pixi/math": "6.4.2" } } diff --git a/packages/filters/filter-displacement/src/DisplacementFilter.ts b/packages/filter-displacement/src/DisplacementFilter.ts similarity index 99% rename from packages/filters/filter-displacement/src/DisplacementFilter.ts rename to packages/filter-displacement/src/DisplacementFilter.ts index ca50329024..545bd7859e 100644 --- a/packages/filters/filter-displacement/src/DisplacementFilter.ts +++ b/packages/filter-displacement/src/DisplacementFilter.ts @@ -19,7 +19,6 @@ import type { FilterSystem, RenderTexture, Texture, ISpriteMaskTarget } from '@p * Instead, it's starting at the output and asking "which pixel from the original goes here". * For example, if a displacement map pixel has `red = 1` and the filter scale is `20`, * this filter will output the pixel approximately 20 pixels to the right of the original. - * * @memberof PIXI.filters */ export class DisplacementFilter extends Filter @@ -62,7 +61,6 @@ export class DisplacementFilter extends Filter /** * Applies the filter. - * * @param filterManager - The manager. * @param input - The input target. * @param output - The output target. diff --git a/packages/filters/filter-displacement/src/displacement.frag b/packages/filter-displacement/src/displacement.frag similarity index 100% rename from packages/filters/filter-displacement/src/displacement.frag rename to packages/filter-displacement/src/displacement.frag diff --git a/packages/filters/filter-displacement/src/displacement.vert b/packages/filter-displacement/src/displacement.vert similarity index 100% rename from packages/filters/filter-displacement/src/displacement.vert rename to packages/filter-displacement/src/displacement.vert diff --git a/packages/filters/filter-displacement/src/index.ts b/packages/filter-displacement/src/index.ts similarity index 100% rename from packages/filters/filter-displacement/src/index.ts rename to packages/filter-displacement/src/index.ts diff --git a/packages/filters/filter-fxaa/LICENSE b/packages/filter-fxaa/LICENSE similarity index 100% rename from packages/filters/filter-fxaa/LICENSE rename to packages/filter-fxaa/LICENSE diff --git a/packages/filters/filter-fxaa/README.md b/packages/filter-fxaa/README.md similarity index 100% rename from packages/filters/filter-fxaa/README.md rename to packages/filter-fxaa/README.md diff --git a/packages/filters/filter-fxaa/package.json b/packages/filter-fxaa/package.json similarity index 67% rename from packages/filters/filter-fxaa/package.json rename to packages/filter-fxaa/package.json index 282beb05b9..6849976247 100644 --- a/packages/filters/filter-fxaa/package.json +++ b/packages/filter-fxaa/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/filter-fxaa", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/filter-fxaa.js", "module": "dist/esm/filter-fxaa.js", "bundle": "dist/browser/filter-fxaa.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/filter-fxaa.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/filter-fxaa.js" + } + } + }, "namespace": "PIXI.filters", "description": "Filter for fast approximate anti-aliasing", "author": "Mat Groves", @@ -26,6 +39,6 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/core": "6.3.0" + "@pixi/core": "6.4.2" } } diff --git a/packages/filters/filter-fxaa/src/FXAAFilter.ts b/packages/filter-fxaa/src/FXAAFilter.ts similarity index 98% rename from packages/filters/filter-fxaa/src/FXAAFilter.ts rename to packages/filter-fxaa/src/FXAAFilter.ts index d1b8caf799..76831ffc70 100644 --- a/packages/filters/filter-fxaa/src/FXAAFilter.ts +++ b/packages/filter-fxaa/src/FXAAFilter.ts @@ -5,9 +5,7 @@ import fragment from './fxaa.frag'; /** * Basic FXAA (Fast Approximate Anti-Aliasing) implementation based on the code on geeks3d.com * with the modification that the texture2DLod stuff was removed since it is unsupported by WebGL. - * * @see https://github.com/mitsuhiko/webgl-meincraft - * * @memberof PIXI.filters */ export class FXAAFilter extends Filter diff --git a/packages/filters/filter-fxaa/src/fxaa.frag b/packages/filter-fxaa/src/fxaa.frag similarity index 100% rename from packages/filters/filter-fxaa/src/fxaa.frag rename to packages/filter-fxaa/src/fxaa.frag diff --git a/packages/filters/filter-fxaa/src/fxaa.vert b/packages/filter-fxaa/src/fxaa.vert similarity index 100% rename from packages/filters/filter-fxaa/src/fxaa.vert rename to packages/filter-fxaa/src/fxaa.vert diff --git a/packages/filters/filter-fxaa/src/index.ts b/packages/filter-fxaa/src/index.ts similarity index 100% rename from packages/filters/filter-fxaa/src/index.ts rename to packages/filter-fxaa/src/index.ts diff --git a/packages/filters/filter-noise/LICENSE b/packages/filter-noise/LICENSE similarity index 100% rename from packages/filters/filter-noise/LICENSE rename to packages/filter-noise/LICENSE diff --git a/packages/filters/filter-noise/README.md b/packages/filter-noise/README.md similarity index 100% rename from packages/filters/filter-noise/README.md rename to packages/filter-noise/README.md diff --git a/packages/filters/filter-noise/package.json b/packages/filter-noise/package.json similarity index 67% rename from packages/filters/filter-noise/package.json rename to packages/filter-noise/package.json index 10552cf7a5..eb2a69f04d 100644 --- a/packages/filters/filter-noise/package.json +++ b/packages/filter-noise/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/filter-noise", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/filter-noise.js", "module": "dist/esm/filter-noise.js", "bundle": "dist/browser/filter-noise.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/filter-noise.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/filter-noise.js" + } + } + }, "namespace": "PIXI.filters", "description": "Filter that applies noise to a display object", "author": "Mat Groves", @@ -26,6 +39,6 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/core": "6.3.0" + "@pixi/core": "6.4.2" } } diff --git a/packages/filters/filter-noise/src/NoiseFilter.ts b/packages/filter-noise/src/NoiseFilter.ts similarity index 99% rename from packages/filters/filter-noise/src/NoiseFilter.ts rename to packages/filter-noise/src/NoiseFilter.ts index 95000c5aa9..8c9fc59d34 100644 --- a/packages/filters/filter-noise/src/NoiseFilter.ts +++ b/packages/filter-noise/src/NoiseFilter.ts @@ -5,7 +5,6 @@ import fragment from './noise.frag'; * A Noise effect filter. * * original filter: https://github.com/evanw/glfx.js/blob/master/src/filters/adjust/noise.js - * * @memberof PIXI.filters * @author Vico @vicocotea */ @@ -28,7 +27,6 @@ export class NoiseFilter extends Filter /** * The amount of noise to apply, this value should be in the range (0, 1]. - * * @default 0.5 */ get noise(): number diff --git a/packages/filters/filter-noise/src/index.ts b/packages/filter-noise/src/index.ts similarity index 100% rename from packages/filters/filter-noise/src/index.ts rename to packages/filter-noise/src/index.ts diff --git a/packages/filters/filter-noise/src/noise.frag b/packages/filter-noise/src/noise.frag similarity index 100% rename from packages/filters/filter-noise/src/noise.frag rename to packages/filter-noise/src/noise.frag diff --git a/packages/graphics-extras/package.json b/packages/graphics-extras/package.json index a5d1c17a57..96aa9b0b99 100644 --- a/packages/graphics-extras/package.json +++ b/packages/graphics-extras/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/graphics-extras", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/graphics-extras.js", "module": "dist/esm/graphics-extras.js", "bundle": "dist/browser/graphics-extras.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/graphics-extras.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/graphics-extras.js" + } + } + }, "bundleNoExports": true, "description": "Additional Graphics functions for drawing special shapes.", "author": "Matt Karl ", @@ -23,7 +36,7 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/graphics": "6.3.0", - "@pixi/math": "6.3.0" + "@pixi/graphics": "6.4.2", + "@pixi/math": "6.4.2" } } diff --git a/packages/graphics-extras/src/drawChamferRect.ts b/packages/graphics-extras/src/drawChamferRect.ts index ed8cbef643..52db279d3c 100644 --- a/packages/graphics-extras/src/drawChamferRect.ts +++ b/packages/graphics-extras/src/drawChamferRect.ts @@ -4,14 +4,14 @@ import type { Graphics } from '@pixi/graphics'; * Draw Rectangle with chamfer corners. These are angled corners. * * _Note: Only available with **@pixi/graphics-extras**._ - * * @method PIXI.Graphics#drawChamferRect + * @param this * @param {number} x - Upper left corner of rect * @param {number} y - Upper right corner of rect * @param {number} width - Width of rect * @param {number} height - Height of rect * @param {number} chamfer - non-zero real number, size of corner cutout - * @return {PIXI.Graphics} Returns self. + * @returns {PIXI.Graphics} Returns self. */ export function drawChamferRect(this: Graphics, x: number, diff --git a/packages/graphics-extras/src/drawFilletRect.ts b/packages/graphics-extras/src/drawFilletRect.ts index e26647bd73..30012d4334 100644 --- a/packages/graphics-extras/src/drawFilletRect.ts +++ b/packages/graphics-extras/src/drawFilletRect.ts @@ -5,14 +5,14 @@ import type { Graphics } from '@pixi/graphics'; * however it support negative numbers as well for the corner radius. * * _Note: Only available with **@pixi/graphics-extras**._ - * * @method PIXI.Graphics#drawFilletRect + * @param this * @param {number} x - Upper left corner of rect * @param {number} y - Upper right corner of rect * @param {number} width - Width of rect * @param {number} height - Height of rect * @param {number} fillet - accept negative or positive values - * @return {PIXI.Graphics} Returns self. + * @returns {PIXI.Graphics} Returns self. */ export function drawFilletRect(this: Graphics, x: number, diff --git a/packages/graphics-extras/src/drawRegularPolygon.ts b/packages/graphics-extras/src/drawRegularPolygon.ts index 7767492b44..5fad58ea3e 100644 --- a/packages/graphics-extras/src/drawRegularPolygon.ts +++ b/packages/graphics-extras/src/drawRegularPolygon.ts @@ -4,14 +4,14 @@ import type { Graphics } from '@pixi/graphics'; * Draw a regular polygon where all sides are the same length. * * _Note: Only available with **@pixi/graphics-extras**._ - * * @method PIXI.Graphics#drawRegularPolygon + * @param this * @param {number} x - X position * @param {number} y - Y position * @param {number} radius - Polygon radius * @param {number} sides - Minimum value is 3 * @param {number} rotation - Starting rotation values in radians.. - * @return {PIXI.Graphics} + * @returns {PIXI.Graphics} This Graphics object. Good for chaining method calls */ export function drawRegularPolygon(this: Graphics, x: number, diff --git a/packages/graphics-extras/src/drawRoundedPolygon.ts b/packages/graphics-extras/src/drawRoundedPolygon.ts index 93a1bc4fe2..c06602a4ce 100644 --- a/packages/graphics-extras/src/drawRoundedPolygon.ts +++ b/packages/graphics-extras/src/drawRoundedPolygon.ts @@ -4,15 +4,15 @@ import type { Graphics } from '@pixi/graphics'; * Draw a regular polygon with rounded corners. * * _Note: Only available with **@pixi/graphics-extras**._ - * * @method PIXI.Graphics#drawRoundedPolygon + * @param this * @param {number} x - X position * @param {number} y - Y position * @param {number} radius - Polygon radius * @param {number} sides - Minimum value is 3 * @param {number} corner - Corner size in pixels. * @param {number} rotation - Starting rotation values in radians.. - * @return {PIXI.Graphics} + * @returns {PIXI.Graphics} This Graphics object. Good for chaining method calls */ export function drawRoundedPolygon(this: Graphics, x: number, diff --git a/packages/graphics-extras/src/drawStar.ts b/packages/graphics-extras/src/drawStar.ts index 403f30046d..20aadac5d2 100644 --- a/packages/graphics-extras/src/drawStar.ts +++ b/packages/graphics-extras/src/drawStar.ts @@ -3,7 +3,6 @@ import { Polygon, PI_2 } from '@pixi/math'; /** * Draw a star shape with an arbitrary number of points. - * * @ignore */ class Star extends Polygon @@ -44,15 +43,15 @@ class Star extends Polygon * Draw a star shape with an arbitrary number of points. * * _Note: Only available with **@pixi/graphics-extras**._ - * * @method PIXI.Graphics#drawStar + * @param this * @param x - Center X position of the star * @param y - Center Y position of the star * @param points - The number of points of the star, must be > 1 * @param radius - The outer radius of the star * @param innerRadius - The inner radius between points, default half `radius` * @param rotation - The rotation of the star in radians, where 0 is vertical - * @return - This Graphics object. Good for chaining method calls + * @returns - This Graphics object. Good for chaining method calls */ export function drawStar(this: Graphics, x: number, diff --git a/packages/graphics-extras/src/drawTorus.ts b/packages/graphics-extras/src/drawTorus.ts index eaa2d93b2e..cd298f2e68 100644 --- a/packages/graphics-extras/src/drawTorus.ts +++ b/packages/graphics-extras/src/drawTorus.ts @@ -4,15 +4,15 @@ import type { Graphics } from '@pixi/graphics'; * Draw a torus shape, like a donut. Can be used for something like a circle loader. * * _Note: Only available with **@pixi/graphics-extras**._ - * * @method PIXI.Graphics#drawTorus + * @param this * @param {number} x - X position * @param {number} y - Y position * @param {number} innerRadius - Inner circle radius * @param {number} outerRadius - Outer circle radius * @param {number} [startArc=0] - Where to begin sweep, in radians, 0.0 = to the right * @param {number} [endArc=Math.PI*2] - Where to end sweep, in radians - * @return {PIXI.Graphics} + * @returns {PIXI.Graphics} This Graphics object. Good for chaining method calls */ export function drawTorus(this: Graphics, x: number, diff --git a/packages/graphics-extras/src/index.ts b/packages/graphics-extras/src/index.ts index 795213c066..808613cf89 100644 --- a/packages/graphics-extras/src/index.ts +++ b/packages/graphics-extras/src/index.ts @@ -6,7 +6,8 @@ import { drawRegularPolygon } from './drawRegularPolygon'; import { drawRoundedPolygon } from './drawRoundedPolygon'; import { drawStar } from './drawStar'; -export interface IGraphicsExtras { +export interface IGraphicsExtras +{ drawTorus: typeof drawTorus; drawChamferRect: typeof drawChamferRect; drawFilletRect: typeof drawFilletRect; diff --git a/packages/graphics-extras/test/Graphics.tests.ts b/packages/graphics-extras/test/Graphics.tests.ts index 1c25189d6a..fac54e79e1 100644 --- a/packages/graphics-extras/test/Graphics.tests.ts +++ b/packages/graphics-extras/test/Graphics.tests.ts @@ -2,9 +2,9 @@ import { Graphics } from '@pixi/graphics'; import { expect } from 'chai'; import '@pixi/graphics-extras'; -describe('Graphics', function () +describe('Graphics', () => { - it('should have extras as mixins', function () + it('should have extras as mixins', () => { const g = new Graphics(); @@ -18,7 +18,7 @@ describe('Graphics', function () g.destroy(); }); - it('should call all commands with defaults', function () + it('should call all commands with defaults', () => { const g = new Graphics(); diff --git a/packages/graphics/package.json b/packages/graphics/package.json index 8d02d2c286..737e75ecf7 100644 --- a/packages/graphics/package.json +++ b/packages/graphics/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/graphics", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/graphics.js", "module": "dist/esm/graphics.js", "bundle": "dist/browser/graphics.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/graphics.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/graphics.js" + } + } + }, "description": "Draw primitive shapes such as lines, circles and rectangles to the display", "author": "Mat Groves", "contributors": [ @@ -25,11 +38,11 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/constants": "6.3.0", - "@pixi/core": "6.3.0", - "@pixi/display": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/sprite": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/constants": "6.4.2", + "@pixi/core": "6.4.2", + "@pixi/display": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/sprite": "6.4.2", + "@pixi/utils": "6.4.2" } } diff --git a/packages/graphics/src/Graphics.ts b/packages/graphics/src/Graphics.ts index 683ed2ffd5..8c4024afd7 100644 --- a/packages/graphics/src/Graphics.ts +++ b/packages/graphics/src/Graphics.ts @@ -23,10 +23,9 @@ import type { IShape, IPointData } from '@pixi/math'; import type { IDestroyOptions } from '@pixi/display'; import { LINE_JOIN, LINE_CAP } from './const'; -/** - * Batch element computed from Graphics geometry - */ -export interface IGraphicsBatchElement { +/** Batch element computed from Graphics geometry */ +export interface IGraphicsBatchElement +{ vertexData: Float32Array; blendMode: BLEND_MODES; indices: Uint16Array | Uint32Array; @@ -38,14 +37,16 @@ export interface IGraphicsBatchElement { _texture: Texture; } -export interface IFillStyleOptions { +export interface IFillStyleOptions +{ color?: number; alpha?: number; texture?: Texture; matrix?: Matrix; } -export interface ILineStyleOptions extends IFillStyleOptions { +export interface ILineStyleOptions extends IFillStyleOptions +{ width?: number; alignment?: number; native?: boolean; @@ -77,7 +78,6 @@ export interface Graphics extends GlobalMixins.Graphics, Container {} * an optimization, by passing it into a new Geometry object's constructor. Because of this * ability, it's important to call `destroy()` on Geometry objects once you are done with them, to * properly dereference each GraphicsGeometry and prevent memory leaks. - * * @memberof PIXI */ export class Graphics extends Container @@ -90,7 +90,6 @@ export class Graphics extends Container /** * Temporary point to use for containsPoint. - * * @private */ static _TEMP_POINT = new Point(); @@ -106,7 +105,6 @@ export class Graphics extends Container /** * Current path - * * @readonly */ public currentPath: Polygon = null; @@ -148,7 +146,6 @@ export class Graphics extends Container * Includes vertex positions, face indices, normals, colors, UVs, and * custom attributes within buffers, reducing the cost of passing all * this data to the GPU. Can be shared between multiple Mesh or Graphics objects. - * * @readonly */ public get geometry(): GraphicsGeometry @@ -172,7 +169,6 @@ export class Graphics extends Container * of the object in exchange for taking up texture memory. It is also useful if you need the graphics * object to be anti-aliased, because it will be rendered using canvas. This is not recommended if * you are constantly redrawing the graphics element. - * * @name cacheAsBitmap * @member {boolean} * @memberof PIXI.Graphics# @@ -189,8 +185,7 @@ export class Graphics extends Container /** * Creates a new Graphics object with the same values as this one. * Note that only the geometry of the object is cloned, not its transform (position,scale,etc) - * - * @return - A clone of the graphics object + * @returns - A clone of the graphics object */ public clone(): Graphics { @@ -205,7 +200,6 @@ export class Graphics extends Container * primitive in the GraphicsGeometry list is rendered sequentially, modes * such as `PIXI.BLEND_MODES.ADD` and `PIXI.BLEND_MODES.MULTIPLY` will * be applied per-primitive. - * * @default PIXI.BLEND_MODES.NORMAL */ public set blendMode(value: BLEND_MODES) @@ -221,7 +215,6 @@ export class Graphics extends Container /** * The tint applied to each graphic shape. This is a hex value. A value of * 0xFFFFFF will remove any tint effect. - * * @default 0xFFFFFF */ public get tint(): number @@ -236,7 +229,6 @@ export class Graphics extends Container /** * The current fill style. - * * @readonly */ public get fill(): FillStyle @@ -246,7 +238,6 @@ export class Graphics extends Container /** * The current line style. - * * @readonly */ public get line(): LineStyle @@ -257,21 +248,19 @@ export class Graphics extends Container /** * Specifies the line style used for subsequent calls to Graphics methods such as the lineTo() * method or the drawCircle() method. - * * @param [width=0] - width of the line to draw, will update the objects stored style * @param [color=0x0] - color of the line to draw, will update the objects stored style * @param [alpha=1] - alpha of the line to draw, will update the objects stored style * @param [alignment=0.5] - alignment of the line to draw, (0 = inner, 0.5 = middle, 1 = outer). * WebGL only. * @param [native=false] - If true the lines will be draw using LINES instead of TRIANGLE_STRIP - * @return - This Graphics object. Good for chaining method calls + * @returns - This Graphics object. Good for chaining method calls */ public lineStyle(width: number, color?: number, alpha?: number, alignment?: number, native?: boolean): this; /** * Specifies the line style used for subsequent calls to Graphics methods such as the lineTo() * method or the drawCircle() method. - * * @param options - Line style options * @param {number} [options.width=0] - width of the line to draw, will update the objects stored style * @param {number} [options.color=0x0] - color of the line to draw, will update the objects stored style @@ -282,7 +271,7 @@ export class Graphics extends Container * @param {PIXI.LINE_CAP}[options.cap=PIXI.LINE_CAP.BUTT] - line cap style * @param {PIXI.LINE_JOIN}[options.join=PIXI.LINE_JOIN.MITER] - line join style * @param {number}[options.miterLimit=10] - miter limit ratio - * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls + * @returns {PIXI.Graphics} This Graphics object. Good for chaining method calls */ public lineStyle(options?: ILineStyleOptions): this; @@ -300,8 +289,7 @@ export class Graphics extends Container /** * Like line style but support texture for line fill. - * - * @param options - Collection of options for setting line style. + * @param [options] - Collection of options for setting line style. * @param {number} [options.width=0] - width of the line to draw, will update the objects stored style * @param {PIXI.Texture} [options.texture=PIXI.Texture.WHITE] - Texture to use * @param {number} [options.color=0x0] - color of the line to draw, will update the objects stored style. @@ -314,9 +302,9 @@ export class Graphics extends Container * @param {PIXI.LINE_CAP}[options.cap=PIXI.LINE_CAP.BUTT] - line cap style * @param {PIXI.LINE_JOIN}[options.join=PIXI.LINE_JOIN.MITER] - line join style * @param {number}[options.miterLimit=10] - miter limit ratio - * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls + * @returns {PIXI.Graphics} This Graphics object. Good for chaining method calls */ - public lineTextureStyle(options: ILineStyleOptions): this + public lineTextureStyle(options?: ILineStyleOptions): this { // Apply defaults options = Object.assign({ @@ -359,7 +347,6 @@ export class Graphics extends Container /** * Start a polygon object internally. - * * @protected */ protected startPoly(): void @@ -386,7 +373,6 @@ export class Graphics extends Container /** * Finish the polygon object. - * * @protected */ finishPoly(): void @@ -407,10 +393,9 @@ export class Graphics extends Container /** * Moves the current drawing position to x, y. - * * @param x - the X coordinate to move to * @param y - the Y coordinate to move to - * @return - This Graphics object. Good for chaining method calls + * @returns - This Graphics object. Good for chaining method calls */ public moveTo(x: number, y: number): this { @@ -424,10 +409,9 @@ export class Graphics extends Container /** * Draws a line using the current line style from the current drawing position to (x, y); * The current drawing position is then set to (x, y). - * * @param x - the X coordinate to draw to * @param y - the Y coordinate to draw to - * @return - This Graphics object. Good for chaining method calls + * @returns - This Graphics object. Good for chaining method calls */ public lineTo(x: number, y: number): this { @@ -449,7 +433,11 @@ export class Graphics extends Container return this; } - /** Initialize the curve */ + /** + * Initialize the curve + * @param x + * @param y + */ protected _initCurve(x = 0, y = 0): void { if (this.currentPath) @@ -468,12 +456,11 @@ export class Graphics extends Container /** * Calculate the points for a quadratic bezier curve and then draws it. * Based on: https://stackoverflow.com/questions/785097/how-do-i-implement-a-bezier-curve-in-c - * * @param cpX - Control point x * @param cpY - Control point y * @param toX - Destination point x * @param toY - Destination point y - * @return - This Graphics object. Good for chaining method calls + * @returns - This Graphics object. Good for chaining method calls */ public quadraticCurveTo(cpX: number, cpY: number, toX: number, toY: number): this { @@ -493,14 +480,13 @@ export class Graphics extends Container /** * Calculate the points for a bezier curve and then draws it. - * * @param cpX - Control point x * @param cpY - Control point y * @param cpX2 - Second Control point x * @param cpY2 - Second Control point y * @param toX - Destination point x * @param toY - Destination point y - * @return This Graphics object. Good for chaining method calls + * @returns This Graphics object. Good for chaining method calls */ public bezierCurveTo(cpX: number, cpY: number, cpX2: number, cpY2: number, toX: number, toY: number): this { @@ -515,13 +501,12 @@ export class Graphics extends Container * The arcTo() method creates an arc/curve between two tangents on the canvas. * * "borrowed" from https://code.google.com/p/fxcanvas/ - thanks google! - * * @param x1 - The x-coordinate of the first tangent point of the arc * @param y1 - The y-coordinate of the first tangent point of the arc * @param x2 - The x-coordinate of the end of the arc * @param y2 - The y-coordinate of the end of the arc * @param radius - The radius of the arc - * @return - This Graphics object. Good for chaining method calls + * @returns - This Graphics object. Good for chaining method calls */ public arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): this { @@ -543,7 +528,6 @@ export class Graphics extends Container /** * The arc method creates an arc/curve (used to create circles, or parts of circles). - * * @param cx - The x-coordinate of the center of the circle * @param cy - The y-coordinate of the center of the circle * @param radius - The radius of the circle @@ -553,7 +537,7 @@ export class Graphics extends Container * @param anticlockwise - Specifies whether the drawing should be * counter-clockwise or clockwise. False is default, and indicates clockwise, while true * indicates counter-clockwise. - * @return - This Graphics object. Good for chaining method calls + * @returns - This Graphics object. Good for chaining method calls */ public arc(cx: number, cy: number, radius: number, startAngle: number, endAngle: number, anticlockwise = false): this { @@ -617,10 +601,9 @@ export class Graphics extends Container /** * Specifies a simple one-color fill that subsequent calls to other Graphics methods * (such as lineTo() or drawCircle()) use when drawing. - * * @param color - the color of the fill * @param alpha - the alpha of the fill - * @return - This Graphics object. Good for chaining method calls + * @returns - This Graphics object. Good for chaining method calls */ public beginFill(color = 0, alpha = 1): this { @@ -629,13 +612,12 @@ export class Graphics extends Container /** * Begin the texture fill - * * @param options - Object object. * @param {PIXI.Texture} [options.texture=PIXI.Texture.WHITE] - Texture to fill * @param {number} [options.color=0xffffff] - Background to fill behind texture * @param {number} [options.alpha=1] - Alpha of fill * @param {PIXI.Matrix} [options.matrix=null] - Transform matrix - * @return {PIXI.Graphics} This Graphics object. Good for chaining method calls + * @returns {PIXI.Graphics} This Graphics object. Good for chaining method calls */ beginTextureFill(options?: IFillStyleOptions): this { @@ -674,8 +656,7 @@ export class Graphics extends Container /** * Applies a fill to the lines and shapes that were added since the last call to the beginFill() method. - * - * @return - This Graphics object. Good for chaining method calls + * @returns - This Graphics object. Good for chaining method calls */ public endFill(): this { @@ -688,12 +669,11 @@ export class Graphics extends Container /** * Draws a rectangle shape. - * * @param x - The X coord of the top-left of the rectangle * @param y - The Y coord of the top-left of the rectangle * @param width - The width of the rectangle * @param height - The height of the rectangle - * @return - This Graphics object. Good for chaining method calls + * @returns - This Graphics object. Good for chaining method calls */ public drawRect(x: number, y: number, width: number, height: number): this { @@ -702,13 +682,12 @@ export class Graphics extends Container /** * Draw a rectangle shape with rounded/beveled corners. - * * @param x - The X coord of the top-left of the rectangle * @param y - The Y coord of the top-left of the rectangle * @param width - The width of the rectangle * @param height - The height of the rectangle * @param radius - Radius of the rectangle corners - * @return - This Graphics object. Good for chaining method calls + * @returns - This Graphics object. Good for chaining method calls */ public drawRoundedRect(x: number, y: number, width: number, height: number, radius: number): this { @@ -717,11 +696,10 @@ export class Graphics extends Container /** * Draws a circle. - * * @param x - The X coordinate of the center of the circle * @param y - The Y coordinate of the center of the circle * @param radius - The radius of the circle - * @return - This Graphics object. Good for chaining method calls + * @returns - This Graphics object. Good for chaining method calls */ public drawCircle(x: number, y: number, radius: number): this { @@ -730,26 +708,24 @@ export class Graphics extends Container /** * Draws an ellipse. - * * @param x - The X coordinate of the center of the ellipse * @param y - The Y coordinate of the center of the ellipse * @param width - The half width of the ellipse * @param height - The half height of the ellipse - * @return - This Graphics object. Good for chaining method calls + * @returns - This Graphics object. Good for chaining method calls */ public drawEllipse(x: number, y: number, width: number, height: number): this { return this.drawShape(new Ellipse(x, y, width, height)); } - public drawPolygon(...path: Array | Array): this - public drawPolygon(path: Array | Array | Polygon): this + public drawPolygon(...path: Array | Array): this; + public drawPolygon(path: Array | Array | Polygon): this; /** * Draws a polygon using the given path. - * * @param {number[]|PIXI.Point[]|PIXI.Polygon} path - The path data used to construct the polygon. - * @return - This Graphics object. Good for chaining method calls + * @returns - This Graphics object. Good for chaining method calls */ public drawPolygon(...path: any[]): this { @@ -785,9 +761,8 @@ export class Graphics extends Container /** * Draw any shape. - * * @param {PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.Rectangle|PIXI.RoundedRectangle} shape - Shape to draw - * @return - This Graphics object. Good for chaining method calls + * @returns - This Graphics object. Good for chaining method calls */ public drawShape(shape: IShape): this { @@ -810,8 +785,7 @@ export class Graphics extends Container /** * Clears the graphics that were drawn to this Graphics object, and resets fill and line style settings. - * - * @return - This Graphics object. Good for chaining method calls + * @returns - This Graphics object. Good for chaining method calls */ public clear(): this { @@ -830,7 +804,6 @@ export class Graphics extends Container /** * True if graphics consists of one rectangle, and thus, can be drawn like a Sprite and * masked with gl.scissor. - * * @returns - True if only 1 rect. */ public isFastRect(): boolean @@ -846,7 +819,6 @@ export class Graphics extends Container /** * Renders the object using the WebGL renderer - * * @param renderer - The renderer */ protected _render(renderer: Renderer): void @@ -925,7 +897,6 @@ export class Graphics extends Container /** * Renders the batches using the BathedRenderer plugin - * * @param renderer - The renderer */ protected _renderBatched(renderer: Renderer): void @@ -952,7 +923,6 @@ export class Graphics extends Container /** * Renders the graphics direct - * * @param renderer - The renderer */ protected _renderDirect(renderer: Renderer): void @@ -992,7 +962,11 @@ export class Graphics extends Container } } - /** Renders specific DrawCall */ + /** + * Renders specific DrawCall + * @param renderer + * @param drawCall + */ protected _renderDrawCallDirect(renderer: Renderer, drawCall: BatchDrawCall): void { const { texArray, type, size, start } = drawCall; @@ -1008,7 +982,6 @@ export class Graphics extends Container /** * Resolves shader for direct rendering - * * @param renderer - The renderer */ protected _resolveDirectShader(renderer: Renderer): Shader @@ -1024,7 +997,7 @@ export class Graphics extends Container // but may be more than one plugins for graphics if (!DEFAULT_SHADERS[pluginName]) { - const MAX_TEXTURES = renderer.plugins.batch.MAX_TEXTURES; + const { MAX_TEXTURES } = renderer.plugins[pluginName]; const sampleValues = new Int32Array(MAX_TEXTURES); for (let i = 0; i < MAX_TEXTURES; i++) @@ -1069,9 +1042,8 @@ export class Graphics extends Container /** * Tests if a point is inside this graphics object - * * @param point - the point to test - * @return - the result of the test + * @returns - the result of the test */ public containsPoint(point: IPointData): boolean { @@ -1109,10 +1081,7 @@ export class Graphics extends Container } } - /** - * If there's a transform update or a change to the shape of the - * geometry, recalculate the vertices. - */ + /** If there's a transform update or a change to the shape of the geometry, recalculate the vertices. */ protected calculateVertices(): void { const wtID = this.transform._worldID; @@ -1149,8 +1118,7 @@ export class Graphics extends Container /** * Closes the current path. - * - * @return - Returns itself. + * @returns - Returns itself. */ public closePath(): this { @@ -1170,9 +1138,8 @@ export class Graphics extends Container /** * Apply a matrix to the positional data. - * * @param matrix - Matrix to use for transform current shape. - * @return - Returns itself. + * @returns - Returns itself. */ public setMatrix(matrix: Matrix): this { @@ -1187,8 +1154,7 @@ export class Graphics extends Container * Also weirdness ensues if holes overlap! * Ellipses, Circles, Rectangles and Rounded Rectangles cannot be holes or host for holes in CanvasRenderer, * please use `moveTo` `lineTo`, `quadraticCurveTo` if you rely on pixi-legacy bundle. - * - * @return - Returns itself. + * @returns - Returns itself. */ public beginHole(): this { @@ -1200,8 +1166,7 @@ export class Graphics extends Container /** * End adding holes to the last draw shape. - * - * @return - Returns itself. + * @returns - Returns itself. */ public endHole(): this { @@ -1213,7 +1178,6 @@ export class Graphics extends Container /** * Destroys the Graphics object. - * * @param options - Options parameter. A boolean will act as if all * options have been set to that value * @param {boolean} [options.children=false] - if set to true, all the children will have @@ -1223,7 +1187,7 @@ export class Graphics extends Container * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true * Should it destroy the base texture of the child sprite */ - public destroy(options?: IDestroyOptions|boolean): void + public destroy(options?: IDestroyOptions | boolean): void { this._geometry.refCount--; if (this._geometry.refCount === 0) diff --git a/packages/graphics/src/GraphicsData.ts b/packages/graphics/src/GraphicsData.ts index 03d282c6cf..199172d7ac 100644 --- a/packages/graphics/src/GraphicsData.ts +++ b/packages/graphics/src/GraphicsData.ts @@ -4,14 +4,12 @@ import type { LineStyle } from './styles/LineStyle'; /** * A class to contain data useful for Graphics objects - * * @memberof PIXI */ export class GraphicsData { /** * The shape object to draw. - * * @member {PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.Rectangle|PIXI.RoundedRectangle} */ shape: IShape; @@ -52,8 +50,7 @@ export class GraphicsData /** * Creates a new GraphicsData object with the same values as this one. - * - * @return - Cloned GraphicsData object + * @returns - Cloned GraphicsData object */ public clone(): GraphicsData { diff --git a/packages/graphics/src/GraphicsGeometry.ts b/packages/graphics/src/GraphicsGeometry.ts index 853f737692..6a297d1ff8 100644 --- a/packages/graphics/src/GraphicsGeometry.ts +++ b/packages/graphics/src/GraphicsGeometry.ts @@ -40,7 +40,6 @@ const tmpBounds = new Bounds(); * * GraphicsGeometry is designed to not be continually updating the geometry since it's expensive * to re-tesselate using **earcut**. Consider using {@link PIXI.Mesh} for this use-case, it's much faster. - * * @memberof PIXI */ export class GraphicsGeometry extends BatchGeometry @@ -48,13 +47,11 @@ export class GraphicsGeometry extends BatchGeometry /** * The maximum number of points to consider an object "batchable", * able to be batched by the renderer's batch system. -\ */ +\ + */ public static BATCHABLE_SIZE = 100; - /** - * Minimal distance between points that are considered different. - * Affects line tesselation. - */ + /** Minimal distance between points that are considered different. Affects line tesselation. */ public closePointEps = 1e-4; /** Padding to add to the bounds. */ @@ -81,14 +78,12 @@ export class GraphicsGeometry extends BatchGeometry /** * The collection of drawn shapes. - * * @member {PIXI.GraphicsData[]} */ graphicsData: Array = []; /** * List of current draw calls drived from the batches. - * * @member {PIXI.BatchDrawCall[]} */ drawCalls: Array = []; @@ -99,7 +94,6 @@ export class GraphicsGeometry extends BatchGeometry /** * Intermediate abstract format sent to batch system. * Can be converted to drawCalls or to batchable objects. - * * @member {PIXI.graphicsUtils.BatchPart[]} */ batches: Array = []; @@ -130,7 +124,6 @@ export class GraphicsGeometry extends BatchGeometry /** * Get the current bounds of the graphic geometry. - * * @readonly */ public get bounds(): Bounds @@ -144,10 +137,7 @@ export class GraphicsGeometry extends BatchGeometry return this._bounds; } - /** - * Call if you changed graphicsData manually. - * Empties all batch buffers. - */ + /** Call if you changed graphicsData manually. Empties all batch buffers. */ protected invalidate(): void { this.boundsDirty = -1; @@ -182,8 +172,7 @@ export class GraphicsGeometry extends BatchGeometry /** * Clears the graphics that were drawn to this Graphics object, and resets fill and line style settings. - * - * @return - This GraphicsGeometry object. Good for chaining method calls + * @returns - This GraphicsGeometry object. Good for chaining method calls */ public clear(): GraphicsGeometry { @@ -199,12 +188,11 @@ export class GraphicsGeometry extends BatchGeometry /** * Draws the given shape to this Graphics object. Can be any of Circle, Rectangle, Ellipse, Line or Polygon. - * * @param {PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.Rectangle|PIXI.RoundedRectangle} shape - The shape object to draw. * @param fillStyle - Defines style of the fill. * @param lineStyle - Defines style of the lines. * @param matrix - Transform applied to the points of the shape. - * @return - Returns geometry for chaining. + * @returns - Returns geometry for chaining. */ public drawShape( shape: IShape, @@ -222,10 +210,9 @@ export class GraphicsGeometry extends BatchGeometry /** * Draws the given shape to this Graphics object. Can be any of Circle, Rectangle, Ellipse, Line or Polygon. - * * @param {PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.Rectangle|PIXI.RoundedRectangle} shape - The shape object to draw. * @param matrix - Transform applied to the points of the shape. - * @return - Returns geometry for chaining. + * @returns - Returns geometry for chaining. */ public drawHole(shape: IShape, matrix: Matrix = null): GraphicsGeometry { @@ -279,9 +266,8 @@ export class GraphicsGeometry extends BatchGeometry /** * Check to see if a point is contained within this geometry. - * * @param point - Point to check if it's contained. - * @return {Boolean} `true` if the point is contained within geometry. + * @returns {boolean} `true` if the point is contained within geometry. */ public containsPoint(point: IPointData): boolean { @@ -340,7 +326,6 @@ export class GraphicsGeometry extends BatchGeometry /** * Generates intermediate batch data. Either gets converted to drawCalls * or used to convert to batch objects directly by the Graphics object. - * * @param allow32Indices - Allow using 32-bit indices for preventing artifacts when more that 65535 vertices */ updateBatches(allow32Indices?: boolean): void @@ -482,7 +467,6 @@ export class GraphicsGeometry extends BatchGeometry /** * Affinity check - * * @param styleA * @param styleB */ @@ -730,7 +714,10 @@ export class GraphicsGeometry extends BatchGeometry this._indexBuffer.update(this.indicesUint16); } - /** Process fill part of Graphics. */ + /** + * Process fill part of Graphics. + * @param data + */ protected processFill(data: GraphicsData): void { if (data.holes.length) @@ -745,7 +732,10 @@ export class GraphicsGeometry extends BatchGeometry } } - /** Process line part of Graphics. */ + /** + * Process line part of Graphics. + * @param data + */ protected processLine(data: GraphicsData): void { buildLine(data, this); @@ -756,7 +746,10 @@ export class GraphicsGeometry extends BatchGeometry } } - /** Process the holes data. */ + /** + * Process the holes data. + * @param holes + */ protected processHoles(holes: Array): void { for (let i = 0; i < holes.length; i++) @@ -856,7 +849,6 @@ export class GraphicsGeometry extends BatchGeometry /** * Transform points using matrix. - * * @param points - Points to transform * @param matrix - Transform matrix */ @@ -874,7 +866,6 @@ export class GraphicsGeometry extends BatchGeometry /** * Add colors. - * * @param colors - List of colors to add to * @param color - Color to add * @param alpha - Alpha to use @@ -901,7 +892,13 @@ export class GraphicsGeometry extends BatchGeometry } } - /** Add texture id that the shader/fragment wants to use. */ + /** + * Add texture id that the shader/fragment wants to use. + * @param textureIds + * @param id + * @param size + * @param offset + */ protected addTextureIds( textureIds: Array, id: number, @@ -918,7 +915,6 @@ export class GraphicsGeometry extends BatchGeometry /** * Generates the UVs for a shape. - * * @param verts - Vertices * @param uvs - UVs * @param texture - Reference to Texture @@ -968,7 +964,6 @@ export class GraphicsGeometry extends BatchGeometry /** * Modify uvs array according to position of texture region * Does not work with rotated or trimmed textures - * * @param uvs - array * @param texture - region * @param start - starting index for uvs diff --git a/packages/graphics/src/const.ts b/packages/graphics/src/const.ts index 7d54aa9ac7..4387871c62 100644 --- a/packages/graphics/src/const.ts +++ b/packages/graphics/src/const.ts @@ -1,9 +1,7 @@ /** * Supported line joints in `PIXI.LineStyle` for graphics. - * * @see PIXI.Graphics#lineStyle * @see https://graphicdesign.stackexchange.com/questions/59018/what-is-a-bevel-join-of-two-lines-exactly-illustrator - * * @name LINE_JOIN * @memberof PIXI * @static @@ -12,7 +10,9 @@ * @property {string} BEVEL - 'bevel': add a square butt at each end of line segment and fill the triangle at turn * @property {string} ROUND - 'round': add an arc at the joint */ -export enum LINE_JOIN { +export enum LINE_JOIN +// eslint-disable-next-line @typescript-eslint/indent +{ MITER = 'miter', BEVEL = 'bevel', ROUND = 'round' @@ -20,9 +20,7 @@ export enum LINE_JOIN { /** * Support line caps in `PIXI.LineStyle` for graphics. - * * @see PIXI.Graphics#lineStyle - * * @name LINE_CAP * @memberof PIXI * @static @@ -31,13 +29,16 @@ export enum LINE_JOIN { * @property {string} ROUND - 'round': add semicircle at ends * @property {string} SQUARE - 'square': add square at end (like `BUTT` except more length at end) */ -export enum LINE_CAP { +export enum LINE_CAP +// eslint-disable-next-line @typescript-eslint/indent +{ BUTT = 'butt', ROUND = 'round', SQUARE = 'square' } -export interface IGraphicsCurvesSettings { +export interface IGraphicsCurvesSettings +{ adaptive: boolean; maxLength: number; minSegments: number; @@ -52,16 +53,15 @@ export interface IGraphicsCurvesSettings { * Graphics curves resolution settings. If `adaptive` flag is set to `true`, * the resolution is calculated based on the curve's length to ensure better visual quality. * Adaptive draw works with `bezierCurveTo` and `quadraticCurveTo`. - * * @static * @constant * @memberof PIXI * @name GRAPHICS_CURVES * @type {object} - * @property {boolean} adaptive=true - flag indicating if the resolution should be adaptive - * @property {number} maxLength=10 - maximal length of a single segment of the curve (if adaptive = false, ignored) - * @property {number} minSegments=8 - minimal number of segments in the curve (if adaptive = false, ignored) - * @property {number} maxSegments=2048 - maximal number of segments in the curve (if adaptive = false, ignored) + * @property {boolean} [adaptive=true] - flag indicating if the resolution should be adaptive + * @property {number} [maxLength=10] - maximal length of a single segment of the curve (if adaptive = false, ignored) + * @property {number} [minSegments=8] - minimal number of segments in the curve (if adaptive = false, ignored) + * @property {number} [maxSegments=2048] - maximal number of segments in the curve (if adaptive = false, ignored) */ export const GRAPHICS_CURVES: IGraphicsCurvesSettings = { adaptive: true, diff --git a/packages/graphics/src/styles/FillStyle.ts b/packages/graphics/src/styles/FillStyle.ts index 5db5da42ca..8e879ecd59 100644 --- a/packages/graphics/src/styles/FillStyle.ts +++ b/packages/graphics/src/styles/FillStyle.ts @@ -3,14 +3,12 @@ import type { Matrix } from '@pixi/math'; /** * Fill style object for Graphics. - * * @memberof PIXI */ export class FillStyle { /** * The hex color value used when coloring the Graphics object. - * * @default 0xFFFFFF */ public color = 0xFFFFFF; @@ -20,14 +18,12 @@ export class FillStyle /** * The texture to be used for the fill. - * * @default 0 */ public texture: Texture = Texture.WHITE; /** * The transform applied to the texture. - * * @default null */ public matrix: Matrix = null; diff --git a/packages/graphics/src/styles/LineStyle.ts b/packages/graphics/src/styles/LineStyle.ts index e0d1abd650..579bbd125d 100644 --- a/packages/graphics/src/styles/LineStyle.ts +++ b/packages/graphics/src/styles/LineStyle.ts @@ -3,7 +3,6 @@ import { LINE_JOIN, LINE_CAP } from '../const'; /** * Represents the line style for Graphics. - * * @memberof PIXI */ export class LineStyle extends FillStyle @@ -19,7 +18,6 @@ export class LineStyle extends FillStyle /** * Line cap style. - * * @member {PIXI.LINE_CAP} * @default PIXI.LINE_CAP.BUTT */ @@ -27,7 +25,6 @@ export class LineStyle extends FillStyle /** * Line join style. - * * @member {PIXI.LINE_JOIN} * @default PIXI.LINE_JOIN.MITER */ diff --git a/packages/graphics/src/utils/ArcUtils.ts b/packages/graphics/src/utils/ArcUtils.ts index 0aa46d393d..24e65ea0c7 100644 --- a/packages/graphics/src/utils/ArcUtils.ts +++ b/packages/graphics/src/utils/ArcUtils.ts @@ -1,7 +1,8 @@ import { GRAPHICS_CURVES } from '../const'; import { PI_2 } from '@pixi/math'; -interface IArcLikeShape { +interface IArcLikeShape +{ cx: number; cy: number; radius: number; @@ -12,7 +13,6 @@ interface IArcLikeShape { /** * Utilities for arc curves. - * * @private */ export class ArcUtils @@ -21,14 +21,14 @@ export class ArcUtils * The arcTo() method creates an arc/curve between two tangents on the canvas. * * "borrowed" from https://code.google.com/p/fxcanvas/ - thanks google! - * * @private * @param x1 - The x-coordinate of the beginning of the arc * @param y1 - The y-coordinate of the beginning of the arc * @param x2 - The x-coordinate of the end of the arc * @param y2 - The y-coordinate of the end of the arc * @param radius - The radius of the arc - * @return - If the arc length is valid, return center of circle, radius and other info otherwise `null`. + * @param points - + * @returns - If the arc length is valid, return center of circle, radius and other info otherwise `null`. */ static curveTo(x1: number, y1: number, x2: number, y2: number, radius: number, points: Array): IArcLikeShape { @@ -80,17 +80,16 @@ export class ArcUtils /* eslint-disable max-len */ /** * The arc method creates an arc/curve (used to create circles, or parts of circles). - * * @private - * @param startX - Start x location of arc - * @param startY - Start y location of arc + * @param _startX - Start x location of arc + * @param _startY - Start y location of arc * @param cx - The x-coordinate of the center of the circle * @param cy - The y-coordinate of the center of the circle * @param radius - The radius of the circle * @param startAngle - The starting angle, in radians (0 is at the 3 o'clock position * of the arc's circle) * @param endAngle - The ending angle, in radians - * @param anticlockwise - Specifies whether the drawing should be + * @param _anticlockwise - Specifies whether the drawing should be * counter-clockwise or clockwise. False is default, and indicates clockwise, while true * indicates counter-clockwise. * @param points - Collection of points to add to diff --git a/packages/graphics/src/utils/BatchPart.ts b/packages/graphics/src/utils/BatchPart.ts index 22753e5b14..fd51ba539e 100644 --- a/packages/graphics/src/utils/BatchPart.ts +++ b/packages/graphics/src/utils/BatchPart.ts @@ -3,7 +3,6 @@ import type { FillStyle } from '../styles/FillStyle'; /** * A structure to hold interim batch objects for Graphics. - * * @memberof PIXI.graphicsUtils */ export class BatchPart @@ -19,7 +18,12 @@ export class BatchPart this.reset(); } - /** Begin batch part. */ + /** + * Begin batch part. + * @param style + * @param startIndex + * @param attribStart + */ public begin(style: LineStyle | FillStyle, startIndex: number, attribStart: number): void { this.reset(); @@ -28,7 +32,11 @@ export class BatchPart this.attribStart = attribStart; } - /** End batch part. */ + /** + * End batch part. + * @param endIndex + * @param endAttrib + */ public end(endIndex: number, endAttrib: number): void { this.attribSize = endAttrib - this.attribStart; diff --git a/packages/graphics/src/utils/BezierUtils.ts b/packages/graphics/src/utils/BezierUtils.ts index 92bce58902..345c1606c9 100644 --- a/packages/graphics/src/utils/BezierUtils.ts +++ b/packages/graphics/src/utils/BezierUtils.ts @@ -2,7 +2,6 @@ import { GRAPHICS_CURVES } from '../const'; /** * Utilities for bezier curves - * * @private */ export class BezierUtils @@ -11,7 +10,6 @@ export class BezierUtils * Calculate length of bezier curve. * Analytical solution is impossible, since it involves an integral that does not integrate in general. * Therefore numerical solution is used. - * * @private * @param fromX - Starting point x * @param fromY - Starting point y @@ -21,7 +19,7 @@ export class BezierUtils * @param cpY2 - Second Control point y * @param toX - Destination point x * @param toY - Destination point y - * @return - Length of bezier curve + * @returns - Length of bezier curve */ static curveLength( fromX: number, fromY: number, @@ -70,7 +68,6 @@ export class BezierUtils * Calculate the points for a bezier curve and then draws it. * * Ignored from docs since it is not directly exposed. - * * @ignore * @param cpX - Control point x * @param cpY - Control point y diff --git a/packages/graphics/src/utils/IShapeBuildCommand.ts b/packages/graphics/src/utils/IShapeBuildCommand.ts index e3ffc23014..14573617f4 100644 --- a/packages/graphics/src/utils/IShapeBuildCommand.ts +++ b/packages/graphics/src/utils/IShapeBuildCommand.ts @@ -1,7 +1,8 @@ import type { GraphicsData } from '../GraphicsData'; import type { GraphicsGeometry } from '../GraphicsGeometry'; -export interface IShapeBuildCommand { +export interface IShapeBuildCommand +{ build(graphicsData: GraphicsData): void; triangulate(graphicsData: GraphicsData, target: GraphicsGeometry): void; } diff --git a/packages/graphics/src/utils/QuadraticUtils.ts b/packages/graphics/src/utils/QuadraticUtils.ts index a6a88ef3b5..e9c0552ddb 100644 --- a/packages/graphics/src/utils/QuadraticUtils.ts +++ b/packages/graphics/src/utils/QuadraticUtils.ts @@ -2,7 +2,6 @@ import { GRAPHICS_CURVES } from '../const'; /** * Utilities for quadratic curves. - * * @private */ export class QuadraticUtils @@ -11,7 +10,6 @@ export class QuadraticUtils * Calculate length of quadratic curve * @see {@link http://www.malczak.linuxpl.com/blog/quadratic-bezier-curve-length/} * for the detailed explanation of math behind this. - * * @private * @param fromX - x-coordinate of curve start point * @param fromY - y-coordinate of curve start point @@ -19,7 +17,7 @@ export class QuadraticUtils * @param cpY - y-coordinate of curve control point * @param toX - x-coordinate of curve end point * @param toY - y-coordinate of curve end point - * @return - Length of quadratic curve + * @returns - Length of quadratic curve */ static curveLength( fromX: number, fromY: number, @@ -53,7 +51,6 @@ export class QuadraticUtils /** * Calculate the points for a quadratic bezier curve and then draws it. * Based on: https://stackoverflow.com/questions/785097/how-do-i-implement-a-bezier-curve-in-c - * * @private * @param cpX - Control point x * @param cpY - Control point y diff --git a/packages/graphics/src/utils/buildCircle.ts b/packages/graphics/src/utils/buildCircle.ts index 863a297b76..4da1376ea4 100644 --- a/packages/graphics/src/utils/buildCircle.ts +++ b/packages/graphics/src/utils/buildCircle.ts @@ -8,7 +8,6 @@ import type { IShapeBuildCommand } from './IShapeBuildCommand'; * Builds a circle to draw * * Ignored from docs since it is not directly exposed. - * * @ignore * @private * @param {PIXI.WebGLGraphicsData} graphicsData - The graphics object to draw @@ -61,6 +60,13 @@ export const buildCircle: IShapeBuildCommand = { dy = halfHeight - ry; } + if (!(rx >= 0 && ry >= 0 && dx >= 0 && dy >= 0)) + { + points.length = 0; + + return; + } + // Choose a number of segments such that the maximum absolute deviation from the circle is approximately 0.029 const n = Math.ceil(2.3 * Math.sqrt(rx + ry)); const m = (n * 8) + (dx ? 4 : 0) + (dy ? 4 : 0); diff --git a/packages/graphics/src/utils/buildLine.ts b/packages/graphics/src/utils/buildLine.ts index e228562adf..14b69174f8 100644 --- a/packages/graphics/src/utils/buildLine.ts +++ b/packages/graphics/src/utils/buildLine.ts @@ -9,15 +9,17 @@ import { LINE_JOIN, LINE_CAP, GRAPHICS_CURVES } from '../const'; * Buffers vertices to draw a square cap. * * Ignored from docs since it is not directly exposed. - * * @ignore * @private * @param {number} x - X-coord of end point * @param {number} y - Y-coord of end point * @param {number} nx - X-coord of line normal pointing inside * @param {number} ny - Y-coord of line normal pointing inside + * @param {number} innerWeight - Weight of inner points + * @param {number} outerWeight - Weight of outer points + * @param {boolean} clockwise - Whether the cap is drawn clockwise * @param {Array} verts - vertex buffer - * @returns {} + * @returns {number} - no. of vertices pushed */ function square( x: number, @@ -67,7 +69,6 @@ function square( * Buffers vertices to draw an arc at the line joint or cap. * * Ignored from docs since it is not directly exposed. - * * @ignore * @private * @param {number} cx - X-coord of center @@ -172,7 +173,6 @@ function round( * Builds a line to draw using the polygon method. * * Ignored from docs since it is not directly exposed. - * * @ignore * @private * @param {PIXI.GraphicsData} graphicsData - The graphics object containing all the necessary properties @@ -427,11 +427,7 @@ function buildNonNativeLine(graphicsData: GraphicsData, graphicsGeometry: Graphi { verts.push(x1 - (perpx * innerWeight), y1 - (perpy * innerWeight)); // first segment's inner vertex verts.push(x1 + (perpx * outerWeight), y1 + (perpy * outerWeight)); // first segment's outer vertex - if (style.join === LINE_JOIN.BEVEL || pdist / widthSquared > miterLimitSquared) - { - // Nothing needed - } - else if (style.join === LINE_JOIN.ROUND) + if (style.join === LINE_JOIN.ROUND) { if (clockwise) /* arc is outside */ { @@ -452,7 +448,7 @@ function buildNonNativeLine(graphicsData: GraphicsData, graphicsGeometry: Graphi ) + 2; } } - else + else if (style.join === LINE_JOIN.MITER && pdist / widthSquared <= miterLimitSquared) { if (clockwise) { @@ -540,7 +536,6 @@ function buildNonNativeLine(graphicsData: GraphicsData, graphicsGeometry: Graphi * Builds a line to draw using the gl.drawArrays(gl.LINES) method * * Ignored from docs since it is not directly exposed. - * * @ignore * @private * @param {PIXI.GraphicsData} graphicsData - The graphics object containing all the necessary properties @@ -583,7 +578,6 @@ function buildNativeLine(graphicsData: GraphicsData, graphicsGeometry: GraphicsG * Builds a line to draw * * Ignored from docs since it is not directly exposed. - * * @ignore * @private * @param {PIXI.GraphicsData} graphicsData - The graphics object containing all the necessary properties diff --git a/packages/graphics/src/utils/buildPoly.ts b/packages/graphics/src/utils/buildPoly.ts index d6d4d62d40..3b749559ba 100644 --- a/packages/graphics/src/utils/buildPoly.ts +++ b/packages/graphics/src/utils/buildPoly.ts @@ -45,7 +45,6 @@ function fixOrientation(points: number[], hole = false) * Builds a polygon to draw * * Ignored from docs since it is not directly exposed. - * * @ignore * @private * @param {PIXI.WebGLGraphicsData} graphicsData - The graphics object containing all the necessary properties diff --git a/packages/graphics/src/utils/buildRectangle.ts b/packages/graphics/src/utils/buildRectangle.ts index 512f70507f..63a5a681c7 100644 --- a/packages/graphics/src/utils/buildRectangle.ts +++ b/packages/graphics/src/utils/buildRectangle.ts @@ -5,7 +5,6 @@ import type { Rectangle } from '@pixi/math'; * Builds a rectangle to draw * * Ignored from docs since it is not directly exposed. - * * @ignore * @private * @param {PIXI.WebGLGraphicsData} graphicsData - The graphics object containing all the necessary properties diff --git a/packages/graphics/src/utils/buildRoundedRectangle.ts b/packages/graphics/src/utils/buildRoundedRectangle.ts index 73ea13a39f..e624f6aa96 100644 --- a/packages/graphics/src/utils/buildRoundedRectangle.ts +++ b/packages/graphics/src/utils/buildRoundedRectangle.ts @@ -10,14 +10,12 @@ import { buildCircle } from './buildCircle'; * Calculate a single point for a quadratic bezier curve. * Utility function used by quadraticBezierCurve. * Ignored from docs since it is not directly exposed. - * * @ignore * @private * @param {number} n1 - first number * @param {number} n2 - second number * @param {number} perc - percentage - * @return {number} the result - * + * @returns {number} the result */ function getPt(n1: number, n2: number, perc: number): number { @@ -31,7 +29,6 @@ function getPt(n1: number, n2: number, perc: number): number * Based on: https://stackoverflow.com/questions/785097/how-do-i-implement-a-bezier-curve-in-c * * Ignored from docs since it is not directly exposed. - * * @ignore * @private * @param {number} fromX - Origin point x @@ -41,7 +38,7 @@ function getPt(n1: number, n2: number, perc: number): number * @param {number} toX - Destination point x * @param {number} toY - Destination point y * @param {number[]} [out=[]] - The output array to add points into. If not passed, a new array is created. - * @return {number[]} an array of points + * @returns {number[]} an array of points */ function quadraticBezierCurve( fromX: number, fromY: number, @@ -89,7 +86,6 @@ function quadraticBezierCurve( * Builds a rounded rectangle to draw * * Ignored from docs since it is not directly exposed. - * * @ignore * @private * @param {PIXI.WebGLGraphicsData} graphicsData - The graphics object containing all the necessary properties diff --git a/packages/graphics/src/utils/index.ts b/packages/graphics/src/utils/index.ts index 35e3b3dfab..c03a5060d4 100644 --- a/packages/graphics/src/utils/index.ts +++ b/packages/graphics/src/utils/index.ts @@ -1,6 +1,5 @@ /** * Generalized convenience utilities for Graphics. - * * @namespace graphicsUtils * @memberof PIXI */ @@ -31,9 +30,8 @@ import { IShapeBuildCommand } from './IShapeBuildCommand'; /** * Map of fill commands for each shape type. - * * @memberof PIXI.graphicsUtils - * @member {Object} FILL_COMMANDS + * @member {object} FILL_COMMANDS */ export const FILL_COMMANDS: Record = { [SHAPES.POLY]: buildPoly, @@ -45,7 +43,6 @@ export const FILL_COMMANDS: Record = { /** * Batch pool, stores unused batches for preventing allocations. - * * @memberof PIXI.graphicsUtils * @member {Array} BATCH_POOL */ @@ -53,7 +50,6 @@ export const BATCH_POOL: Array = []; /** * Draw call pool, stores unused draw calls for preventing allocations. - * * @memberof PIXI.graphicsUtils * @member {Array} DRAW_CALL_POOL */ diff --git a/packages/graphics/test/Graphics.tests.ts b/packages/graphics/test/Graphics.tests.ts index a3848a0b03..16713355da 100644 --- a/packages/graphics/test/Graphics.tests.ts +++ b/packages/graphics/test/Graphics.tests.ts @@ -1,5 +1,5 @@ import { Renderer, BatchRenderer, Texture } from '@pixi/core'; -import { Graphics, GRAPHICS_CURVES, FillStyle, LineStyle, graphicsUtils } from '@pixi/graphics'; +import { Graphics, GRAPHICS_CURVES, FillStyle, LineStyle, graphicsUtils, GraphicsGeometry } from '@pixi/graphics'; const { FILL_COMMANDS, buildLine } = graphicsUtils; import { BLEND_MODES } from '@pixi/constants'; @@ -12,11 +12,11 @@ Renderer.registerPlugin('batch', BatchRenderer); skipHello(); -describe('Graphics', function () +describe('Graphics', () => { - describe('constructor', function () + describe('constructor', () => { - it('should set defaults', function () + it('should set defaults', () => { const graphics = new Graphics(); @@ -29,9 +29,9 @@ describe('Graphics', function () }); }); - describe('lineStyle', function () + describe('lineStyle', () => { - it('should support a list of parameters', function () + it('should support a list of parameters', () => { const graphics = new Graphics(); @@ -46,7 +46,7 @@ describe('Graphics', function () graphics.destroy(); }); - it('should default color to black if texture not present and white if present', function () + it('should default color to black if texture not present and white if present', () => { const graphics = new Graphics(); @@ -57,7 +57,7 @@ describe('Graphics', function () graphics.destroy(); }); - it('should support object parameter', function () + it('should support object parameter', () => { const graphics = new Graphics(); @@ -89,13 +89,13 @@ describe('Graphics', function () }); }); - describe('lineTextureStyle', function () + describe('lineTextureStyle', () => { - it('should support object parameter', function () + it('should support object parameter', () => { const graphics = new Graphics(); const matrix = new Matrix(); - const texture = Texture.BLACK; + const texture = Texture.WHITE; graphics.lineTextureStyle({ width: 1, @@ -131,9 +131,9 @@ describe('Graphics', function () }); }); - describe('beginTextureFill', function () + describe('beginTextureFill', () => { - it('should pass texture to batches', function () + it('should pass texture to batches', () => { const graphics = new Graphics(); const canvas1 = document.createElement('canvas'); @@ -163,9 +163,9 @@ describe('Graphics', function () }); }); - describe('utils', function () + describe('utils', () => { - it('FILL_COMMADS should be filled', function () + it('FILL_COMMADS should be filled', () => { expect(FILL_COMMANDS).to.not.be.null; @@ -176,7 +176,7 @@ describe('Graphics', function () expect(FILL_COMMANDS[SHAPES.RREC]).to.not.be.null; }); - it('buildLine should execute without throws', function () + it('buildLine should execute without throws', () => { const graphics = new Graphics(); @@ -187,17 +187,17 @@ describe('Graphics', function () const data = geometry.graphicsData[0]; // native = false - expect(function () { buildLine(data, geometry); }).to.not.throw(); + expect(() => { buildLine(data, geometry); }).to.not.throw(); data.lineStyle.native = true; // native = true - expect(function () { buildLine(data, geometry); }).to.not.throw(); + expect(() => { buildLine(data, geometry); }).to.not.throw(); }); }); - describe('lineTo', function () + describe('lineTo', () => { - it('should return correct bounds - north', function () + it('should return correct bounds - north', () => { const graphics = new Graphics(); @@ -209,7 +209,7 @@ describe('Graphics', function () expect(graphics.height).to.be.closeTo(11, 0.0001); }); - it('should return correct bounds - south', function () + it('should return correct bounds - south', () => { const graphics = new Graphics(); @@ -221,7 +221,7 @@ describe('Graphics', function () expect(graphics.height).to.be.closeTo(11, 0.0001); }); - it('should return correct bounds - east', function () + it('should return correct bounds - east', () => { const graphics = new Graphics(); @@ -233,7 +233,7 @@ describe('Graphics', function () expect(graphics.width).to.be.closeTo(11, 0.0001); }); - it('should return correct bounds - west', function () + it('should return correct bounds - west', () => { const graphics = new Graphics(); @@ -245,7 +245,7 @@ describe('Graphics', function () expect(graphics.width).to.be.closeTo(11, 0.0001); }); - it('should return correct bounds when stacked with circle', function () + it('should return correct bounds when stacked with circle', () => { const graphics = new Graphics(); @@ -264,7 +264,7 @@ describe('Graphics', function () expect(graphics.height).to.be.equals(100); }); - it('should return correct bounds when square', function () + it('should return correct bounds when square', () => { const graphics = new Graphics(); @@ -279,7 +279,7 @@ describe('Graphics', function () expect(graphics.height).to.be.equals(70); }); - it('should ignore duplicate calls', function () + it('should ignore duplicate calls', () => { const graphics = new Graphics(); @@ -292,9 +292,9 @@ describe('Graphics', function () }); }); - describe('containsPoint', function () + describe('containsPoint', () => { - it('should return true when point inside a standard shape', function () + it('should return true when point inside a standard shape', () => { const point = new Point(1, 1); const graphics = new Graphics(); @@ -305,7 +305,7 @@ describe('Graphics', function () expect(graphics.containsPoint(point)).to.be.true; }); - it('should return false when point outside a standard shape', function () + it('should return false when point outside a standard shape', () => { const point = new Point(20, 20); const graphics = new Graphics(); @@ -316,7 +316,7 @@ describe('Graphics', function () expect(graphics.containsPoint(point)).to.be.false; }); - it('should return true when point inside just lines', function () + it('should return true when point inside just lines', () => { const point = new Point(1, 1); const graphics = new Graphics(); @@ -332,7 +332,7 @@ describe('Graphics', function () expect(graphics.containsPoint(point)).to.be.true; }); - it('should return false when point outside just lines', function () + it('should return false when point outside just lines', () => { const point = new Point(20, 20); const graphics = new Graphics(); @@ -347,7 +347,7 @@ describe('Graphics', function () expect(graphics.containsPoint(point)).to.be.false; }); - it('should return false when no fill', function () + it('should return false when no fill', () => { const point = new Point(1, 1); const graphics = new Graphics(); @@ -357,7 +357,7 @@ describe('Graphics', function () expect(graphics.containsPoint(point)).to.be.false; }); - it('should return false with hole', function () + it('should return false with hole', () => { const point1 = new Point(1, 1); const point2 = new Point(5, 5); @@ -379,7 +379,7 @@ describe('Graphics', function () expect(graphics.containsPoint(point2)).to.be.false; }); - it('should handle extra shapes in holes', function () + it('should handle extra shapes in holes', () => { const graphics = new Graphics(); @@ -413,7 +413,7 @@ describe('Graphics', function () expect(graphics.containsPoint(new Point(6, 6))).to.be.true; }); - it('should take a matrix into account', function () + it('should take a matrix into account', () => { const g = new Graphics(); const m = new Matrix(); @@ -435,9 +435,9 @@ describe('Graphics', function () }); }); - describe('chaining', function () + describe('chaining', () => { - it('should chain draw commands', function () + it('should chain draw commands', () => { // complex drawing #1: draw triangle, rounder rect and an arc (issue #3433) const graphics = new Graphics().beginFill(0xFF3300) @@ -449,7 +449,7 @@ describe('Graphics', function () .beginHole() .endHole() .quadraticCurveTo(1, 1, 1, 1) - .bezierCurveTo(1, 1, 1, 1) + .bezierCurveTo(1, 1, 1, 1, 1, 1) .arcTo(1, 1, 1, 1, 1) .arc(1, 1, 1, 1, 1, false) .drawRect(1, 1, 1, 1) @@ -463,104 +463,112 @@ describe('Graphics', function () }); }); - describe('drawPolygon', function () + describe('drawPolygon', () => { - before(function () + let numbers: number[]; + let points: Point[]; + let poly: Polygon; + + before(() => { - this.numbers = [0, 0, 10, 10, 20, 20]; - this.points = [new Point(0, 0), new Point(10, 10), new Point(20, 20)]; - this.poly = new Polygon(this.points); + numbers = [0, 0, 10, 10, 20, 20]; + points = [new Point(0, 0), new Point(10, 10), new Point(20, 20)]; + poly = new Polygon(points); }); - it('should support polygon argument', function () + it('should support polygon argument', () => { const graphics = new Graphics(); expect(graphics.currentPath).to.be.null; - graphics.drawPolygon(this.poly); + graphics.drawPolygon(poly); expect(graphics.geometry.graphicsData[0]).to.be.not.null; - const result = graphics.geometry.graphicsData[0].shape.points; + const result = (graphics.geometry.graphicsData[0].shape as Polygon).points; - expect(result).to.deep.equals(this.numbers); + expect(result).to.deep.equals(numbers); }); - it('should support array of numbers', function () + it('should support array of numbers', () => { const graphics = new Graphics(); expect(graphics.currentPath).to.be.null; - graphics.drawPolygon(this.numbers); + graphics.drawPolygon(numbers); expect(graphics.geometry.graphicsData[0]).to.be.not.null; - const result = graphics.geometry.graphicsData[0].shape.points; + const result = (graphics.geometry.graphicsData[0].shape as Polygon).points; - expect(result).to.deep.equals(this.numbers); + expect(result).to.deep.equals(numbers); }); - it('should support array of points', function () + it('should support array of points', () => { const graphics = new Graphics(); - graphics.drawPolygon(this.points); + graphics.drawPolygon(points); expect(graphics.geometry.graphicsData[0]).to.be.not.null; - const result = graphics.geometry.graphicsData[0].shape.points; + const result = (graphics.geometry.graphicsData[0].shape as Polygon).points; - expect(result).to.deep.equals(this.numbers); + expect(result).to.deep.equals(numbers); }); - it('should support flat arguments of numbers', function () + it('should support flat arguments of numbers', () => { const graphics = new Graphics(); expect(graphics.currentPath).to.be.null; - graphics.drawPolygon(...this.numbers); + graphics.drawPolygon(...numbers); expect(graphics.geometry.graphicsData[0]).to.be.not.null; - const result = graphics.geometry.graphicsData[0].shape.points; + const result = (graphics.geometry.graphicsData[0].shape as Polygon).points; - expect(result).to.deep.equals(this.numbers); + expect(result).to.deep.equals(numbers); }); - it('should support flat arguments of points', function () + it('should support flat arguments of points', () => { const graphics = new Graphics(); expect(graphics.currentPath).to.be.null; - graphics.drawPolygon(...this.points); + graphics.drawPolygon(...points); expect(graphics.geometry.graphicsData[0]).to.be.not.null; - const result = graphics.geometry.graphicsData[0].shape.points; + const result = (graphics.geometry.graphicsData[0].shape as Polygon).points; - expect(result).to.deep.equals(this.numbers); + expect(result).to.deep.equals(numbers); }); }); - describe('drawing same rectangle with drawPolygon and drawRect', function () + describe('drawing same rectangle with drawPolygon and drawRect', () => { - before(function () + let width: number; + let height: number; + let points: Point[]; + + before(() => { - this.width = 100; - this.height = 100; - this.points = [ + width = 100; + height = 100; + points = [ new Point(0, 0), - new Point(this.width, 0), - new Point(this.width, this.height), - new Point(0, this.height) + new Point(width, 0), + new Point(width, height), + new Point(0, height) ]; }); - it('should have the same bounds for any line alignment value', function () + it('should have the same bounds for any line alignment value', () => { const polyGraphics = new Graphics(); const rectGraphics = new Graphics(); @@ -575,12 +583,12 @@ describe('Graphics', function () polyGraphics.beginFill(0x0000ff); polyGraphics.lineStyle(lineWidth, 0xff0000, 1, lineAlignment); - polyGraphics.drawPolygon(this.points); + polyGraphics.drawPolygon(points); polyGraphics.endFill(); rectGraphics.beginFill(0x0000ff); rectGraphics.lineStyle(lineWidth, 0xff0000, 1, lineAlignment); - rectGraphics.drawRect(0, 0, this.width, this.height); + rectGraphics.drawRect(0, 0, width, height); rectGraphics.endFill(); const polyBounds = polyGraphics.getBounds(); @@ -594,9 +602,9 @@ describe('Graphics', function () }); }); - describe('arc', function () + describe('arc', () => { - it('should draw an arc', function () + it('should draw an arc', () => { const graphics = new Graphics(); @@ -607,7 +615,7 @@ describe('Graphics', function () expect(graphics.currentPath).to.be.not.null; }); - it('should not throw with other shapes', function () + it('should not throw with other shapes', () => { // complex drawing #1: draw triangle, rounder rect and an arc (issue #3433) const graphics = new Graphics(); @@ -634,7 +642,7 @@ describe('Graphics', function () expect(() => graphics.arc(300, 100, 20, 0, Math.PI)).to.not.throw(); }); - it('should do nothing when startAngle and endAngle are equal', function () + it('should do nothing when startAngle and endAngle are equal', () => { const graphics = new Graphics(); @@ -645,7 +653,7 @@ describe('Graphics', function () expect(graphics.currentPath).to.be.null; }); - it('should do nothing if sweep equals zero', function () + it('should do nothing if sweep equals zero', () => { const graphics = new Graphics(); @@ -657,44 +665,44 @@ describe('Graphics', function () }); }); - describe('_calculateBounds', function () + describe('_calculateBounds', () => { - it('should only call updateLocalBounds once when not empty', function () + it('should only call updateLocalBounds once when not empty', () => { const graphics = new Graphics(); graphics.drawRect(0, 0, 10, 10); - const spy = sinon.spy(graphics.geometry, 'calculateBounds'); + const spy = sinon.spy(graphics.geometry, 'calculateBounds' as keyof GraphicsGeometry); - graphics._calculateBounds(); + graphics['_calculateBounds'](); expect(spy).to.have.been.calledOnce; - graphics._calculateBounds(); + graphics['_calculateBounds'](); expect(spy).to.have.been.calledOnce; }); - it('should not call updateLocalBounds when empty', function () + it('should not call updateLocalBounds when empty', () => { const graphics = new Graphics(); - const spy = sinon.spy(graphics.geometry, 'calculateBounds'); + const spy = sinon.spy(graphics.geometry, 'calculateBounds' as keyof GraphicsGeometry); - graphics._calculateBounds(); + graphics['_calculateBounds'](); expect(spy).to.not.have.been.called; - graphics._calculateBounds(); + graphics['_calculateBounds'](); expect(spy).to.not.have.been.called; }); }); - describe('getBounds', function () + describe('getBounds', () => { - it('should use getBounds without stroke', function () + it('should use getBounds without stroke', () => { const graphics = new Graphics(); @@ -708,7 +716,7 @@ describe('Graphics', function () expect(height).to.equal(200); }); - it('should use getBounds with stroke', function () + it('should use getBounds with stroke', () => { const graphics = new Graphics(); @@ -725,7 +733,7 @@ describe('Graphics', function () expect(height).to.equal(204); }); - it('should be zero for empty Graphics', function () + it('should be zero for empty Graphics', () => { const graphics = new Graphics(); @@ -737,7 +745,7 @@ describe('Graphics', function () expect(height).to.equal(0); }); - it('should be zero after clear', function () + it('should be zero after clear', () => { const graphics = new Graphics(); @@ -755,7 +763,7 @@ describe('Graphics', function () expect(height).to.equal(0); }); - it('should be equal of childs bounds when empty', function () + it('should be equal of childs bounds when empty', () => { const graphics = new Graphics(); const child = new Graphics(); @@ -775,9 +783,9 @@ describe('Graphics', function () }); }); - describe('startPoly', function () + describe('startPoly', () => { - it('should fill two triangles', function () + it('should fill two triangles', () => { const graphics = new Graphics(); @@ -796,11 +804,11 @@ describe('Graphics', function () const data = graphics.geometry.graphicsData; expect(data.length).to.equals(2); - expect(data[0].shape.points).to.eql([50, 50, 250, 50, 100, 100, 50, 50]); - expect(data[1].shape.points).to.eql([250, 50, 450, 50, 300, 100, 250, 50]); + expect((data[0].shape as Polygon).points).to.eql([50, 50, 250, 50, 100, 100, 50, 50]); + expect((data[1].shape as Polygon).points).to.eql([250, 50, 450, 50, 300, 100, 250, 50]); }); - it('should honor lineStyle break', function () + it('should honor lineStyle break', () => { const graphics = new Graphics(); @@ -815,12 +823,12 @@ describe('Graphics', function () const data = graphics.geometry.graphicsData; expect(data.length).to.equals(2); - expect(data[0].shape.points).to.eql([50, 50, 250, 50]); - expect(data[1].shape.points).to.eql([250, 50, 100, 100, 50, 50]); + expect((data[0].shape as Polygon).points).to.eql([50, 50, 250, 50]); + expect((data[1].shape as Polygon).points).to.eql([250, 50, 100, 100, 50, 50]); }); }); - describe('should support adaptive curves', function () + describe('should support adaptive curves', () => { const defMode = GRAPHICS_CURVES.adaptive; const defMaxLen = GRAPHICS_CURVES.maxLength; @@ -834,7 +842,7 @@ describe('Graphics', function () graphics.quadraticCurveTo(600, 510, 590, 500); graphics.endFill(); - const pointsLen = graphics.geometry.graphicsData[0].shape.points.length / 2; + const pointsLen = (graphics.geometry.graphicsData[0].shape as Polygon).points.length / 2; const arcLen = Math.PI / 2 * Math.sqrt(200); const estimate = Math.ceil(arcLen / myMaxLen) + 1; @@ -844,9 +852,9 @@ describe('Graphics', function () GRAPHICS_CURVES.maxLength = defMaxLen; }); - describe('geometry', function () + describe('geometry', () => { - it('validateBatching should return false if any of textures is invalid', function () + it('validateBatching should return false if any of textures is invalid', () => { const graphics = new Graphics(); const invalidTex = Texture.EMPTY; @@ -859,10 +867,10 @@ describe('Graphics', function () const geometry = graphics.geometry; - expect(geometry.validateBatching()).to.be.false; + expect(geometry['validateBatching']()).to.be.false; }); - it('validateBatching should return true if all textures is valid', function () + it('validateBatching should return true if all textures is valid', () => { const graphics = new Graphics(); const validTex = Texture.WHITE; @@ -874,10 +882,10 @@ describe('Graphics', function () const geometry = graphics.geometry; - expect(geometry.validateBatching()).to.be.true; + expect(geometry['validateBatching']()).to.be.true; }); - it('should be batchable if graphicsData is empty', function () + it('should be batchable if graphicsData is empty', () => { const graphics = new Graphics(); const geometry = graphics.geometry; @@ -886,7 +894,7 @@ describe('Graphics', function () expect(geometry.batchable).to.be.true; }); - it('_compareStyles should return true for identical styles', function () + it('_compareStyles should return true for identical styles', () => { const graphics = new Graphics(); const geometry = graphics.geometry; @@ -899,7 +907,7 @@ describe('Graphics', function () const second = first.clone(); - expect(geometry._compareStyles(first, second)).to.be.true; + expect(geometry['_compareStyles'](first, second)).to.be.true; const firstLine = new LineStyle(); @@ -909,10 +917,10 @@ describe('Graphics', function () const secondLine = firstLine.clone(); - expect(geometry._compareStyles(firstLine, secondLine)).to.be.true; + expect(geometry['_compareStyles'](firstLine, secondLine)).to.be.true; }); - it('should be 1 batch for same styles', function () + it('should be 1 batch for same styles', () => { const graphics = new Graphics(); @@ -926,7 +934,7 @@ describe('Graphics', function () expect(geometry.batches).to.have.lengthOf(1); }); - it('should be 2 batches for 2 different styles', function () + it('should be 2 batches for 2 different styles', () => { const graphics = new Graphics(); @@ -947,7 +955,7 @@ describe('Graphics', function () expect(geometry.batches).to.have.lengthOf(2); }); - it('should be 1 batch if fill and line are the same', function () + it('should be 1 batch if fill and line are the same', () => { const graphics = new Graphics(); @@ -962,7 +970,7 @@ describe('Graphics', function () expect(geometry.batches).to.have.lengthOf(1); }); - it('should not use fill if triangulation does nothing', function () + it('should not use fill if triangulation does nothing', () => { const graphics = new Graphics(); diff --git a/packages/interaction/package.json b/packages/interaction/package.json index fe6e0dcc8e..eb5c607e7a 100644 --- a/packages/interaction/package.json +++ b/packages/interaction/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/interaction", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/interaction.js", "module": "dist/esm/interaction.js", "bundle": "dist/browser/interaction.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/interaction.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/interaction.js" + } + } + }, "description": "Plugin for handling mouse, touch and pointer events", "author": "Mat Groves", "contributors": [ @@ -25,10 +38,10 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/core": "6.3.0", - "@pixi/display": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/ticker": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/core": "6.4.2", + "@pixi/display": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/ticker": "6.4.2", + "@pixi/utils": "6.4.2" } } diff --git a/packages/interaction/src/InteractionData.ts b/packages/interaction/src/InteractionData.ts index eacbf95385..f8a20e0de5 100644 --- a/packages/interaction/src/InteractionData.ts +++ b/packages/interaction/src/InteractionData.ts @@ -6,7 +6,6 @@ export type InteractivePointerEvent = PointerEvent | TouchEvent | MouseEvent; /** * Holds all information related to an Interaction event - * * @memberof PIXI */ export class InteractionData @@ -19,7 +18,6 @@ export class InteractionData /** * When passed to an event handler, this will be the original DOM Event that was captured - * * @see https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent * @see https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent @@ -32,21 +30,18 @@ export class InteractionData /** * Indicates whether or not the pointer device that created the event is the primary pointer. - * * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/isPrimary */ public isPrimary: boolean; /** * Indicates which button was pressed on the mouse or pointer device to trigger the event. - * * @see https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button */ public button: number; /** * Indicates which buttons are pressed on the mouse or pointer device when the event is triggered. - * * @see https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons */ public buttons: number; @@ -54,7 +49,6 @@ export class InteractionData /** * The width of the pointer's contact along the x-axis, measured in CSS pixels. * radiusX of TouchEvents will be represented by this value. - * * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/width */ public width: number; @@ -62,28 +56,24 @@ export class InteractionData /** * The height of the pointer's contact along the y-axis, measured in CSS pixels. * radiusY of TouchEvents will be represented by this value. - * * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/height */ public height: number; /** * The angle, in degrees, between the pointer device and the screen. - * * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/tiltX */ public tiltX: number; /** * The angle, in degrees, between the pointer device and the screen. - * * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/tiltY */ public tiltY: number; /** * The type of pointer that triggered the event. - * * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pointerType */ public pointerType: string; @@ -91,28 +81,24 @@ export class InteractionData /** * Pressure applied by the pointing device during the event. A Touch's force property * will be represented by this value. - * * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pressure */ public pressure = 0; /** * From TouchEvents (not PointerEvents triggered by touches), the rotationAngle of the Touch. - * * @see https://developer.mozilla.org/en-US/docs/Web/API/Touch/rotationAngle */ public rotationAngle = 0; /** * Twist of a stylus pointer. - * * @see https://w3c.github.io/pointerevents/#pointerevent-interface */ public twist = 0; /** * Barrel pressure on a stylus pointer. - * * @see https://w3c.github.io/pointerevents/#pointerevent-interface */ public tangentialPressure = 0; @@ -139,7 +125,6 @@ export class InteractionData /** * The unique identifier of the pointer. It will be the same as `identifier`. - * * @readonly * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pointerId */ @@ -150,14 +135,13 @@ export class InteractionData /** * This will return the local coordinates of the specified displayObject for this InteractionData - * * @param displayObject - The DisplayObject that you would like the local * coords off * @param point - A Point object in which to store the value, optional (otherwise * will create a new point) * @param globalPos - A Point object containing your custom global coords, optional * (otherwise will use the current global coords) - * @return - A point containing the coordinates of the InteractionData position relative + * @returns - A point containing the coordinates of the InteractionData position relative * to the DisplayObject */ public getLocalPosition

(displayObject: DisplayObject, point?: P, globalPos?: IPointData): P @@ -167,7 +151,6 @@ export class InteractionData /** * Copies properties from normalized event data. - * * @param {Touch|MouseEvent|PointerEvent} event - The normalized event data */ public copyEvent(event: Touch | InteractivePointerEvent): void diff --git a/packages/interaction/src/InteractionEvent.ts b/packages/interaction/src/InteractionEvent.ts index 6b2df88ed1..6214cd62a5 100644 --- a/packages/interaction/src/InteractionEvent.ts +++ b/packages/interaction/src/InteractionEvent.ts @@ -5,7 +5,6 @@ export type InteractionCallback = (interactionEvent: InteractionEvent, displayOb /** * Event class that mimics native DOM events. - * * @memberof PIXI */ export class InteractionEvent @@ -20,7 +19,6 @@ export class InteractionEvent /** * At which object this event stops propagating. - * * @private */ public stopsPropagatingAt: DisplayObject; @@ -29,7 +27,6 @@ export class InteractionEvent * Whether we already reached the element we want to * stop propagating at. This is important for delayed events, * where we start over deeper in the tree again. - * * @private */ public stopPropagationHint: boolean; diff --git a/packages/interaction/src/InteractionManager.ts b/packages/interaction/src/InteractionManager.ts index 8cbaba67eb..11cba6d0e7 100644 --- a/packages/interaction/src/InteractionManager.ts +++ b/packages/interaction/src/InteractionManager.ts @@ -31,13 +31,15 @@ const hitTestEvent: TestInteractionEvent = { }, }; -export interface InteractionManagerOptions { +export interface InteractionManagerOptions +{ autoPreventDefault?: boolean; interactionFrequency?: number; useSystemTicker?: boolean; } -export interface DelayedEvent { +export interface DelayedEvent +{ displayObject: DisplayObject; eventString: string; eventData: InteractionEvent; @@ -57,55 +59,43 @@ interface CrossCSSStyleDeclaration extends CSSStyleDeclaration * This manager also supports multitouch. * * An instance of this class is automatically created by default, and can be found at `renderer.plugins.interaction` - * * @memberof PIXI */ export class InteractionManager extends EventEmitter { /** * Actively tracked InteractionData - * * @private - * @member {Object.} + * @member {Object} */ public readonly activeInteractionData: { [key: number]: InteractionData }; - /** - * Does the device support touch events - * https://www.w3.org/TR/touch-events/ - */ + /** Does the device support touch events https://www.w3.org/TR/touch-events/ */ public readonly supportsTouchEvents: boolean; - /** - * Does the device support pointer events - * https://www.w3.org/Submission/pointer-events/ - */ + /** Does the device support pointer events https://www.w3.org/Submission/pointer-events/ */ public readonly supportsPointerEvents: boolean; /** * Pool of unused InteractionData - * * @private */ public interactionDataPool: InteractionData[]; /** * Internal cached let. - * * @private */ public cursor: string; /** * Delayed pointer events. Used to guarantee correct ordering of over/out events. - * * @private */ public delayedEvents: DelayedEvent[]; /** * TreeSearch component that is used to hitTest stage tree. - * * @private */ public search: TreeSearch; @@ -118,14 +108,12 @@ export class InteractionManager extends EventEmitter * Does not apply to pointer events for backwards compatibility * preventDefault on pointer events stops mouse events from firing * Thus, for every pointer event, there will always be either a mouse of touch event alongside it. - * * @default true */ public autoPreventDefault: boolean; /** * Maximum frequency in milliseconds at which pointer over/out states will be checked by {@link tickerUpdate}. - * * @default 10 */ public interactionFrequency: number; @@ -143,7 +131,6 @@ export class InteractionManager extends EventEmitter * Setting to false can make things easier for things like dragging * It is currently set to false as this is how PixiJS used to work. This will be set to true in * future versions of pixi. - * * @default false */ public moveWhenInside: boolean; @@ -153,20 +140,15 @@ export class InteractionManager extends EventEmitter * values, objects are handled as dictionaries of CSS values for interactionDOMElement, * and functions are called instead of changing the CSS. * Default CSS cursor values are provided for 'default' and 'pointer' modes. - * - * @member {Object.} + * @member {Object} */ public cursorStyles: Dict void) | CSSStyleDeclaration>; - /** - * The mode of the cursor that is being used. - * The value of this is a key from the cursorStyles dictionary. - */ + /** The mode of the cursor that is being used. The value of this is a key from the cursorStyles dictionary. */ public currentCursorMode: string; /** * The current resolution / device pixel ratio. - * * @default 1 */ public resolution: number; @@ -192,8 +174,7 @@ export class InteractionManager extends EventEmitter /** * An options object specifies characteristics about the event listener. - * - * @member {Object.} + * @member {Object} */ private readonly _eventListenerOptions: { capture: true, passive: false }; @@ -269,7 +250,6 @@ export class InteractionManager extends EventEmitter /** * Fired when a pointer device button (usually a mouse left-button) is pressed on the display * object. - * * @event PIXI.InteractionManager#mousedown * @param {PIXI.InteractionEvent} event - Interaction event */ @@ -277,7 +257,6 @@ export class InteractionManager extends EventEmitter /** * Fired when a pointer device secondary button (usually a mouse right-button) is pressed * on the display object. - * * @event PIXI.InteractionManager#rightdown * @param {PIXI.InteractionEvent} event - Interaction event */ @@ -285,7 +264,6 @@ export class InteractionManager extends EventEmitter /** * Fired when a pointer device button (usually a mouse left-button) is released over the display * object. - * * @event PIXI.InteractionManager#mouseup * @param {PIXI.InteractionEvent} event - Interaction event */ @@ -293,7 +271,6 @@ export class InteractionManager extends EventEmitter /** * Fired when a pointer device secondary button (usually a mouse right-button) is released * over the display object. - * * @event PIXI.InteractionManager#rightup * @param {PIXI.InteractionEvent} event - Interaction event */ @@ -301,7 +278,6 @@ export class InteractionManager extends EventEmitter /** * Fired when a pointer device button (usually a mouse left-button) is pressed and released on * the display object. - * * @event PIXI.InteractionManager#click * @param {PIXI.InteractionEvent} event - Interaction event */ @@ -309,7 +285,6 @@ export class InteractionManager extends EventEmitter /** * Fired when a pointer device secondary button (usually a mouse right-button) is pressed * and released on the display object. - * * @event PIXI.InteractionManager#rightclick * @param {PIXI.InteractionEvent} event - Interaction event */ @@ -318,7 +293,6 @@ export class InteractionManager extends EventEmitter * Fired when a pointer device button (usually a mouse left-button) is released outside the * display object that initially registered a * [mousedown]{@link PIXI.InteractionManager#event:mousedown}. - * * @event PIXI.InteractionManager#mouseupoutside * @param {PIXI.InteractionEvent} event - Interaction event */ @@ -327,35 +301,30 @@ export class InteractionManager extends EventEmitter * Fired when a pointer device secondary button (usually a mouse right-button) is released * outside the display object that initially registered a * [rightdown]{@link PIXI.InteractionManager#event:rightdown}. - * * @event PIXI.InteractionManager#rightupoutside * @param {PIXI.InteractionEvent} event - Interaction event */ /** * Fired when a pointer device (usually a mouse) is moved while over the display object - * * @event PIXI.InteractionManager#mousemove * @param {PIXI.InteractionEvent} event - Interaction event */ /** * Fired when a pointer device (usually a mouse) is moved onto the display object - * * @event PIXI.InteractionManager#mouseover * @param {PIXI.InteractionEvent} event - Interaction event */ /** * Fired when a pointer device (usually a mouse) is moved off the display object - * * @event PIXI.InteractionManager#mouseout * @param {PIXI.InteractionEvent} event - Interaction event */ /** * Fired when a pointer device button is pressed on the display object. - * * @event PIXI.InteractionManager#pointerdown * @param {PIXI.InteractionEvent} event - Interaction event */ @@ -365,21 +334,18 @@ export class InteractionManager extends EventEmitter * Not always fired when some buttons are held down while others are released. In those cases, * use [mousedown]{@link PIXI.InteractionManager#event:mousedown} and * [mouseup]{@link PIXI.InteractionManager#event:mouseup} instead. - * * @event PIXI.InteractionManager#pointerup * @param {PIXI.InteractionEvent} event - Interaction event */ /** * Fired when the operating system cancels a pointer event - * * @event PIXI.InteractionManager#pointercancel * @param {PIXI.InteractionEvent} event - Interaction event */ /** * Fired when a pointer device button is pressed and released on the display object. - * * @event PIXI.InteractionManager#pointertap * @param {PIXI.InteractionEvent} event - Interaction event */ @@ -387,56 +353,48 @@ export class InteractionManager extends EventEmitter /** * Fired when a pointer device button is released outside the display object that initially * registered a [pointerdown]{@link PIXI.InteractionManager#event:pointerdown}. - * * @event PIXI.InteractionManager#pointerupoutside * @param {PIXI.InteractionEvent} event - Interaction event */ /** * Fired when a pointer device is moved while over the display object - * * @event PIXI.InteractionManager#pointermove * @param {PIXI.InteractionEvent} event - Interaction event */ /** * Fired when a pointer device is moved onto the display object - * * @event PIXI.InteractionManager#pointerover * @param {PIXI.InteractionEvent} event - Interaction event */ /** * Fired when a pointer device is moved off the display object - * * @event PIXI.InteractionManager#pointerout * @param {PIXI.InteractionEvent} event - Interaction event */ /** * Fired when a touch point is placed on the display object. - * * @event PIXI.InteractionManager#touchstart * @param {PIXI.InteractionEvent} event - Interaction event */ /** * Fired when a touch point is removed from the display object. - * * @event PIXI.InteractionManager#touchend * @param {PIXI.InteractionEvent} event - Interaction event */ /** * Fired when the operating system cancels a touch - * * @event PIXI.InteractionManager#touchcancel * @param {PIXI.InteractionEvent} event - Interaction event */ /** * Fired when a touch point is placed and removed from the display object. - * * @event PIXI.InteractionManager#tap * @param {PIXI.InteractionEvent} event - Interaction event */ @@ -444,14 +402,12 @@ export class InteractionManager extends EventEmitter /** * Fired when a touch point is removed outside of the display object that initially * registered a [touchstart]{@link PIXI.InteractionManager#event:touchstart}. - * * @event PIXI.InteractionManager#touchendoutside * @param {PIXI.InteractionEvent} event - Interaction event */ /** * Fired when a touch point is moved along the display object. - * * @event PIXI.InteractionManager#touchmove * @param {PIXI.InteractionEvent} event - Interaction event */ @@ -461,7 +417,6 @@ export class InteractionManager extends EventEmitter * object. DisplayObject's `interactive` property must be set to `true` to fire event. * * This comes from the @pixi/interaction package. - * * @event PIXI.DisplayObject#mousedown * @param {PIXI.InteractionEvent} event - Interaction event */ @@ -471,7 +426,6 @@ export class InteractionManager extends EventEmitter * on the display object. DisplayObject's `interactive` property must be set to `true` to fire event. * * This comes from the @pixi/interaction package. - * * @event PIXI.DisplayObject#rightdown * @param {PIXI.InteractionEvent} event - Interaction event */ @@ -481,7 +435,6 @@ export class InteractionManager extends EventEmitter * object. DisplayObject's `interactive` property must be set to `true` to fire event. * * This comes from the @pixi/interaction package. - * * @event PIXI.DisplayObject#mouseup * @param {PIXI.InteractionEvent} event - Interaction event */ @@ -491,7 +444,6 @@ export class InteractionManager extends EventEmitter * over the display object. DisplayObject's `interactive` property must be set to `true` to fire event. * * This comes from the @pixi/interaction package. - * * @event PIXI.DisplayObject#rightup * @param {PIXI.InteractionEvent} event - Interaction event */ @@ -501,7 +453,6 @@ export class InteractionManager extends EventEmitter * the display object. DisplayObject's `interactive` property must be set to `true` to fire event. * * This comes from the @pixi/interaction package. - * * @event PIXI.DisplayObject#click * @param {PIXI.InteractionEvent} event - Interaction event */ @@ -511,7 +462,6 @@ export class InteractionManager extends EventEmitter * and released on the display object. DisplayObject's `interactive` property must be set to `true` to fire event. * * This comes from the @pixi/interaction package. - * * @event PIXI.DisplayObject#rightclick * @param {PIXI.InteractionEvent} event - Interaction event */ @@ -523,7 +473,6 @@ export class InteractionManager extends EventEmitter * DisplayObject's `interactive` property must be set to `true` to fire event. * * This comes from the @pixi/interaction package. - * * @event PIXI.DisplayObject#mouseupoutside * @param {PIXI.InteractionEvent} event - Interaction event */ @@ -535,7 +484,6 @@ export class InteractionManager extends EventEmitter * DisplayObject's `interactive` property must be set to `true` to fire event. * * This comes from the @pixi/interaction package. - * * @event PIXI.DisplayObject#rightupoutside * @param {PIXI.InteractionEvent} event - Interaction event */ @@ -545,7 +493,6 @@ export class InteractionManager extends EventEmitter * DisplayObject's `interactive` property must be set to `true` to fire event. * * This comes from the @pixi/interaction package. - * * @event PIXI.DisplayObject#mousemove * @param {PIXI.InteractionEvent} event - Interaction event */ @@ -555,7 +502,6 @@ export class InteractionManager extends EventEmitter * DisplayObject's `interactive` property must be set to `true` to fire event. * * This comes from the @pixi/interaction package. - * * @event PIXI.DisplayObject#mouseover * @param {PIXI.InteractionEvent} event - Interaction event */ @@ -565,7 +511,6 @@ export class InteractionManager extends EventEmitter * DisplayObject's `interactive` property must be set to `true` to fire event. * * This comes from the @pixi/interaction package. - * * @event PIXI.DisplayObject#mouseout * @param {PIXI.InteractionEvent} event - Interaction event */ @@ -575,7 +520,6 @@ export class InteractionManager extends EventEmitter * DisplayObject's `interactive` property must be set to `true` to fire event. * * This comes from the @pixi/interaction package. - * * @event PIXI.DisplayObject#pointerdown * @param {PIXI.InteractionEvent} event - Interaction event */ @@ -585,7 +529,6 @@ export class InteractionManager extends EventEmitter * DisplayObject's `interactive` property must be set to `true` to fire event. * * This comes from the @pixi/interaction package. - * * @event PIXI.DisplayObject#pointerup * @param {PIXI.InteractionEvent} event - Interaction event */ @@ -595,7 +538,6 @@ export class InteractionManager extends EventEmitter * DisplayObject's `interactive` property must be set to `true` to fire event. * * This comes from the @pixi/interaction package. - * * @event PIXI.DisplayObject#pointercancel * @param {PIXI.InteractionEvent} event - Interaction event */ @@ -605,7 +547,6 @@ export class InteractionManager extends EventEmitter * DisplayObject's `interactive` property must be set to `true` to fire event. * * This comes from the @pixi/interaction package. - * * @event PIXI.DisplayObject#pointertap * @param {PIXI.InteractionEvent} event - Interaction event */ @@ -616,7 +557,6 @@ export class InteractionManager extends EventEmitter * DisplayObject's `interactive` property must be set to `true` to fire event. * * This comes from the @pixi/interaction package. - * * @event PIXI.DisplayObject#pointerupoutside * @param {PIXI.InteractionEvent} event - Interaction event */ @@ -626,7 +566,6 @@ export class InteractionManager extends EventEmitter * DisplayObject's `interactive` property must be set to `true` to fire event. * * This comes from the @pixi/interaction package. - * * @event PIXI.DisplayObject#pointermove * @param {PIXI.InteractionEvent} event - Interaction event */ @@ -636,7 +575,6 @@ export class InteractionManager extends EventEmitter * DisplayObject's `interactive` property must be set to `true` to fire event. * * This comes from the @pixi/interaction package. - * * @event PIXI.DisplayObject#pointerover * @param {PIXI.InteractionEvent} event - Interaction event */ @@ -646,7 +584,6 @@ export class InteractionManager extends EventEmitter * DisplayObject's `interactive` property must be set to `true` to fire event. * * This comes from the @pixi/interaction package. - * * @event PIXI.DisplayObject#pointerout * @param {PIXI.InteractionEvent} event - Interaction event */ @@ -656,7 +593,6 @@ export class InteractionManager extends EventEmitter * DisplayObject's `interactive` property must be set to `true` to fire event. * * This comes from the @pixi/interaction package. - * * @event PIXI.DisplayObject#touchstart * @param {PIXI.InteractionEvent} event - Interaction event */ @@ -666,7 +602,6 @@ export class InteractionManager extends EventEmitter * DisplayObject's `interactive` property must be set to `true` to fire event. * * This comes from the @pixi/interaction package. - * * @event PIXI.DisplayObject#touchend * @param {PIXI.InteractionEvent} event - Interaction event */ @@ -676,7 +611,6 @@ export class InteractionManager extends EventEmitter * DisplayObject's `interactive` property must be set to `true` to fire event. * * This comes from the @pixi/interaction package. - * * @event PIXI.DisplayObject#touchcancel * @param {PIXI.InteractionEvent} event - Interaction event */ @@ -686,7 +620,6 @@ export class InteractionManager extends EventEmitter * DisplayObject's `interactive` property must be set to `true` to fire event. * * This comes from the @pixi/interaction package. - * * @event PIXI.DisplayObject#tap * @param {PIXI.InteractionEvent} event - Interaction event */ @@ -697,7 +630,6 @@ export class InteractionManager extends EventEmitter * DisplayObject's `interactive` property must be set to `true` to fire event. * * This comes from the @pixi/interaction package. - * * @event PIXI.DisplayObject#touchendoutside * @param {PIXI.InteractionEvent} event - Interaction event */ @@ -707,7 +639,6 @@ export class InteractionManager extends EventEmitter * DisplayObject's `interactive` property must be set to `true` to fire event. * * This comes from the @pixi/interaction package. - * * @event PIXI.DisplayObject#touchmove * @param {PIXI.InteractionEvent} event - Interaction event */ @@ -719,7 +650,6 @@ export class InteractionManager extends EventEmitter /** * Should the InteractionManager automatically add {@link tickerUpdate} to {@link PIXI.Ticker.system}. - * * @default true */ get useSystemTicker(): boolean @@ -742,7 +672,6 @@ export class InteractionManager extends EventEmitter /** * Last rendered object or temp object. - * * @readonly * @protected */ @@ -753,11 +682,10 @@ export class InteractionManager extends EventEmitter /** * Hit tests a point against the display tree, returning the first interactive object that is hit. - * * @param globalPoint - A point to hit test with, in global space. * @param root - The root display object to start from. If omitted, defaults * to the last rendered root of the associated renderer. - * @return - The hit display object, if any. + * @returns - The hit display object, if any. */ public hitTest(globalPoint: Point, root?: DisplayObject): DisplayObject { @@ -781,7 +709,6 @@ export class InteractionManager extends EventEmitter * Sets the DOM element which will receive mouse/touch events. This is useful for when you have * other DOM elements on top of the renderers Canvas element. With this you'll be bale to delegate * another DOM element to receive those events. - * * @param element - the DOM element which will receive mouse and touch events. * @param resolution - The resolution / device pixel ratio of the new element (relative to the canvas). */ @@ -836,7 +763,7 @@ export class InteractionManager extends EventEmitter const style = this.interactionDOMElement.style as CrossCSSStyleDeclaration; - if (globalThis.navigator.msPointerEnabled) + if ((globalThis.navigator as any).msPointerEnabled) { style.msContentZooming = 'none'; style.msTouchAction = 'none'; @@ -895,7 +822,7 @@ export class InteractionManager extends EventEmitter const style = this.interactionDOMElement.style as CrossCSSStyleDeclaration; - if (globalThis.navigator.msPointerEnabled) + if ((globalThis.navigator as any).msPointerEnabled) { style.msContentZooming = ''; style.msTouchAction = ''; @@ -941,7 +868,6 @@ export class InteractionManager extends EventEmitter * milliseconds have passed since the last invocation. * * Invoked by a throttled ticker update from {@link PIXI.Ticker.system}. - * * @param deltaTime - time delta since the last call */ public tickerUpdate(deltaTime: number): void @@ -1009,7 +935,6 @@ export class InteractionManager extends EventEmitter /** * Sets the current cursor mode, handling any callbacks or CSS style changes. - * * @param mode - cursor mode, a key from the cursorStyles dictionary */ public setCursorMode(mode: string): void @@ -1067,7 +992,6 @@ export class InteractionManager extends EventEmitter /** * Dispatches an event on the display object that was interacted with. - * * @param displayObject - the display object in question * @param eventString - the name of the event (e.g, mousedown) * @param eventData - the event data object @@ -1093,7 +1017,6 @@ export class InteractionManager extends EventEmitter /** * Puts a event on a queue to be dispatched later. This is used to guarantee correct * ordering of over/out events. - * * @param displayObject - the display object in question * @param eventString - the name of the event (e.g, mousedown) * @param eventData - the event data object @@ -1107,7 +1030,6 @@ export class InteractionManager extends EventEmitter * Maps x and y coords from a DOM object and maps them correctly to the PixiJS view. The * resulting value is stored in the point. This takes into account the fact that the DOM * element could be scaled and positioned anywhere on the screen. - * * @param point - the point that the result will be stored in * @param x - the x coord of the position to map * @param y - the y coord of the position to map @@ -1143,7 +1065,6 @@ export class InteractionManager extends EventEmitter * This function is provides a neat way of crawling through the scene graph and running a * specified function on all interactive objects it finds. It will also take care of hit * testing the interactive objects and passes the hit across in the function. - * * @protected * @param interactionEvent - event containing the point that * is tested for collision @@ -1192,7 +1113,6 @@ export class InteractionManager extends EventEmitter /** * Is called when the pointer button is pressed down on the renderer element - * * @param originalEvent - The DOM event of a pointer button being pressed down */ private onPointerDown(originalEvent: InteractivePointerEvent): void @@ -1251,7 +1171,6 @@ export class InteractionManager extends EventEmitter /** * Processes the result of the pointer down check and dispatches the event if need be - * * @param interactionEvent - The interaction event wrapping the DOM event * @param displayObject - The display object that was tested * @param hit - the result of the hit test on the display object @@ -1293,7 +1212,6 @@ export class InteractionManager extends EventEmitter /** * Is called when the pointer button is released on the renderer element - * * @param originalEvent - The DOM event of a pointer button being released * @param cancelled - true if the pointer is cancelled * @param func - Function passed to {@link processInteractive} @@ -1339,7 +1257,6 @@ export class InteractionManager extends EventEmitter /** * Is called when the pointer button is cancelled - * * @param event - The DOM event of a pointer button being released */ private onPointerCancel(event: InteractivePointerEvent): void @@ -1352,7 +1269,6 @@ export class InteractionManager extends EventEmitter /** * Processes the result of the pointer cancel check and dispatches the event if need be - * * @param interactionEvent - The interaction event wrapping the DOM event * @param displayObject - The display object that was tested */ @@ -1376,7 +1292,6 @@ export class InteractionManager extends EventEmitter /** * Is called when the pointer button is released on the renderer element - * * @param event - The DOM event of a pointer button being released */ private onPointerUp(event: InteractivePointerEvent): void @@ -1389,7 +1304,6 @@ export class InteractionManager extends EventEmitter /** * Processes the result of the pointer up check and dispatches the event if need be - * * @param interactionEvent - The interaction event wrapping the DOM event * @param displayObject - The display object that was tested * @param hit - the result of the hit test on the display object @@ -1485,7 +1399,6 @@ export class InteractionManager extends EventEmitter /** * Is called when the pointer moves across the renderer element - * * @param originalEvent - The DOM event of a pointer moving */ private onPointerMove(originalEvent: InteractivePointerEvent): void @@ -1531,7 +1444,6 @@ export class InteractionManager extends EventEmitter /** * Processes the result of the pointer move check and dispatches the event if need be - * * @param interactionEvent - The interaction event wrapping the DOM event * @param displayObject - The display object that was tested * @param hit - the result of the hit test on the display object @@ -1559,7 +1471,6 @@ export class InteractionManager extends EventEmitter /** * Is called when the pointer is moved out of the renderer element - * * @private * @param {PointerEvent} originalEvent - The DOM event of a pointer being moved out */ @@ -1602,7 +1513,6 @@ export class InteractionManager extends EventEmitter /** * Processes the result of the pointer over/out check and dispatches the event if need be. - * * @param interactionEvent - The interaction event wrapping the DOM event * @param displayObject - The display object that was tested * @param hit - the result of the hit test on the display object @@ -1662,7 +1572,6 @@ export class InteractionManager extends EventEmitter /** * Is called when the pointer is moved into the renderer element. - * * @param originalEvent - The DOM event of a pointer button being moved into the renderer view. */ private onPointerOver(originalEvent: InteractivePointerEvent): void @@ -1692,9 +1601,8 @@ export class InteractionManager extends EventEmitter /** * Get InteractionData for a given pointerId. Store that data as well. - * * @param event - Normalized pointer event, output from normalizeToPointerData. - * @return - Interaction data for the given pointer identifier. + * @returns - Interaction data for the given pointer identifier. */ private getInteractionDataForPointerId(event: PointerEvent): InteractionData { @@ -1725,7 +1633,6 @@ export class InteractionManager extends EventEmitter /** * Return unused InteractionData to the pool, for a given pointerId - * * @param pointerId - Identifier from a pointer event */ private releaseInteractionDataForPointerId(pointerId: number): void @@ -1742,12 +1649,11 @@ export class InteractionManager extends EventEmitter /** * Configure an InteractionEvent to wrap a DOM PointerEvent and InteractionData - * * @param interactionEvent - The event to be configured * @param pointerEvent - The DOM event that will be paired with the InteractionEvent * @param interactionData - The InteractionData that will be paired * with the InteractionEvent - * @return - the interaction event that was passed in + * @returns - the interaction event that was passed in */ private configureInteractionEventForDOMEvent(interactionEvent: InteractionEvent, pointerEvent: PointerEvent, interactionData: InteractionData @@ -1772,9 +1678,8 @@ export class InteractionManager extends EventEmitter /** * Ensures that the original event object contains all data that a regular pointer event would have - * * @param {TouchEvent|MouseEvent|PointerEvent} event - The original event data from a touch or mouse event - * @return - An array containing a single normalized pointer event, in the case of a pointer + * @returns - An array containing a single normalized pointer event, in the case of a pointer * or mouse event, or a multiple normalized pointer events if there are multiple changed touches */ private normalizeToPointerData(event: InteractivePointerEvent): PointerEvent[] diff --git a/packages/interaction/src/InteractionTrackingData.ts b/packages/interaction/src/InteractionTrackingData.ts index 1f6c32ce49..c67b19765f 100644 --- a/packages/interaction/src/InteractionTrackingData.ts +++ b/packages/interaction/src/InteractionTrackingData.ts @@ -8,7 +8,6 @@ export interface InteractionTrackingFlags /** * DisplayObjects with the {@link PIXI.interactiveTarget} mixin use this class to track interactions - * * @class * @private * @memberof PIXI @@ -55,7 +54,6 @@ export class InteractionTrackingData /** * Unique pointer id of the event - * * @readonly * @private * @member {number} @@ -67,7 +65,6 @@ export class InteractionTrackingData /** * State of the tracking data, expressed as bit flags - * * @private * @member {number} */ @@ -83,7 +80,6 @@ export class InteractionTrackingData /** * Is the tracked event inactive (not over or down)? - * * @private * @member {number} */ @@ -94,7 +90,6 @@ export class InteractionTrackingData /** * Is the tracked event over the DisplayObject? - * * @private * @member {boolean} */ @@ -110,7 +105,6 @@ export class InteractionTrackingData /** * Did the right mouse button come down in the DisplayObject? - * * @private * @member {boolean} */ @@ -126,7 +120,6 @@ export class InteractionTrackingData /** * Did the left mouse button come down in the DisplayObject? - * * @private * @member {boolean} */ diff --git a/packages/interaction/src/TreeSearch.ts b/packages/interaction/src/TreeSearch.ts index f08817f185..1472dc2c3a 100644 --- a/packages/interaction/src/TreeSearch.ts +++ b/packages/interaction/src/TreeSearch.ts @@ -5,7 +5,6 @@ import type { Container, DisplayObject } from '@pixi/display'; /** * Strategy how to search through stage tree for interactive objects - * * @memberof PIXI */ export class TreeSearch @@ -19,7 +18,6 @@ export class TreeSearch /** * Recursive implementation for findHit - * * @private * @param interactionEvent - event containing the point that * is tested for collision @@ -29,7 +27,7 @@ export class TreeSearch * interactionEvent, displayObject and hit will be passed to the function * @param hitTest - this indicates if the objects inside should be hit test against the point * @param interactive - Whether the displayObject is interactive - * @return - Returns true if the displayObject hit the point + * @returns - Returns true if the displayObject hit the point */ public recursiveFindHit(interactionEvent: InteractionEvent, displayObject: DisplayObject, func?: InteractionCallback, hitTest?: boolean, interactive?: boolean @@ -180,7 +178,6 @@ export class TreeSearch * This function is provides a neat way of crawling through the scene graph and running a * specified function on all interactive objects it finds. It will also take care of hit * testing the interactive objects and passes the hit across in the function. - * * @private * @param interactionEvent - event containing the point that * is tested for collision @@ -189,7 +186,7 @@ export class TreeSearch * @param func - the function that will be called on each interactive object. The * interactionEvent, displayObject and hit will be passed to the function * @param hitTest - this indicates if the objects inside should be hit test against the point - * @return - Returns true if the displayObject hit the point + * @returns - Returns true if the displayObject hit the point */ public findHit(interactionEvent: InteractionEvent, displayObject: DisplayObject, func?: InteractionCallback, hitTest?: boolean diff --git a/packages/interaction/src/interactiveTarget.ts b/packages/interaction/src/interactiveTarget.ts index baa28049c5..2c17c4bbe4 100644 --- a/packages/interaction/src/interactiveTarget.ts +++ b/packages/interaction/src/interactiveTarget.ts @@ -1,47 +1,49 @@ import type { InteractionTrackingData } from './InteractionTrackingData'; type Cursor = 'auto' - | 'default' - | 'none' - | 'context-menu' - | 'help' - | 'pointer' - | 'progress' - | 'wait' - | 'cell' - | 'crosshair' - | 'text' - | 'vertical-text' - | 'alias' - | 'copy' - | 'move' - | 'no-drop' - | 'not-allowed' - | 'e-resize' - | 'n-resize' - | 'ne-resize' - | 'nw-resize' - | 's-resize' - | 'se-resize' - | 'sw-resize' - | 'w-resize' - | 'ns-resize' - | 'ew-resize' - | 'nesw-resize' - | 'col-resize' - | 'nwse-resize' - | 'row-resize' - | 'all-scroll' - | 'zoom-in' - | 'zoom-out' - | 'grab' - | 'grabbing'; +| 'default' +| 'none' +| 'context-menu' +| 'help' +| 'pointer' +| 'progress' +| 'wait' +| 'cell' +| 'crosshair' +| 'text' +| 'vertical-text' +| 'alias' +| 'copy' +| 'move' +| 'no-drop' +| 'not-allowed' +| 'e-resize' +| 'n-resize' +| 'ne-resize' +| 'nw-resize' +| 's-resize' +| 'se-resize' +| 'sw-resize' +| 'w-resize' +| 'ns-resize' +| 'ew-resize' +| 'nesw-resize' +| 'col-resize' +| 'nwse-resize' +| 'row-resize' +| 'all-scroll' +| 'zoom-in' +| 'zoom-out' +| 'grab' +| 'grabbing'; -export interface IHitArea { +export interface IHitArea +{ contains(x: number, y: number): boolean; } -export interface InteractiveTarget { +export interface InteractiveTarget +{ interactive: boolean; interactiveChildren: boolean; hitArea: IHitArea | null; @@ -59,29 +61,26 @@ export interface InteractiveTarget { * - {@link PIXI.Ellipse} * - {@link PIXI.Polygon} * - {@link PIXI.RoundedRectangle} - * * @interface IHitArea * @memberof PIXI */ /** * Checks whether the x and y coordinates given are contained within this area - * * @method * @name contains * @memberof PIXI.IHitArea# * @param {number} x - The X coordinate of the point to test * @param {number} y - The Y coordinate of the point to test - * @return {boolean} Whether the x/y coordinates are within this area + * @returns {boolean} Whether the x/y coordinates are within this area */ /** * Default property values of interactive objects * Used by {@link PIXI.InteractionManager} to automatically give all DisplayObjects these properties - * * @private * @name interactiveTarget - * @type {Object} + * @type {object} * @memberof PIXI * @example * function MyObject() {} @@ -99,7 +98,6 @@ export const interactiveTarget: InteractiveTarget = { /** * If enabled, the mouse cursor use the pointer behavior when hovered over the displayObject if it is interactive * Setting this changes the 'cursor' property to `'pointer'`. - * * @example * const sprite = new PIXI.Sprite(texture); * sprite.interactive = true; @@ -126,13 +124,11 @@ export const interactiveTarget: InteractiveTarget = { /** * This defines what cursor mode is used when the mouse cursor * is hovered over the displayObject. - * * @example * const sprite = new PIXI.Sprite(texture); * sprite.interactive = true; * sprite.cursor = 'wait'; * @see https://developer.mozilla.org/en/docs/Web/CSS/cursor - * * @member {string} * @memberof PIXI.DisplayObject# */ @@ -140,7 +136,6 @@ export const interactiveTarget: InteractiveTarget = { /** * Internal set of all active pointers, by identifier - * * @member {Map} * @memberof PIXI.DisplayObject# * @private @@ -154,7 +149,6 @@ export const interactiveTarget: InteractiveTarget = { /** * Map of all tracked pointers, by identifier. Use trackedPointers to access. - * * @private * @type {Map} */ diff --git a/packages/interaction/test/InteractionData.tests.ts b/packages/interaction/test/InteractionData.tests.ts index ac3d46e174..3f75ee6c37 100755 --- a/packages/interaction/test/InteractionData.tests.ts +++ b/packages/interaction/test/InteractionData.tests.ts @@ -5,14 +5,16 @@ import { expect } from 'chai'; import '@pixi/canvas-display'; -describe('InteractionData', function () +describe('InteractionData', () => { - describe('getLocalPosition', function () + describe('getLocalPosition', () => { - it('should populate second parameter with result', function () + it('should populate second parameter with result', () => { const data = new InteractionData(); + // @ts-expect-error - instantiating DisplayObject const stage = new DisplayObject(); + // @ts-expect-error - instantiating DisplayObject const displayObject = new DisplayObject(); const point = new Point(); diff --git a/packages/interaction/test/InteractionManager.tests.ts b/packages/interaction/test/InteractionManager.tests.ts index e3bbbb0dd0..dc64d75738 100644 --- a/packages/interaction/test/InteractionManager.tests.ts +++ b/packages/interaction/test/InteractionManager.tests.ts @@ -12,31 +12,35 @@ import sinon from 'sinon'; import { expect } from 'chai'; import '@pixi/canvas-display'; +import { Texture } from '@pixi/core'; CanvasRenderer.registerPlugin('interaction', InteractionManager); CanvasRenderer.registerPlugin('graphics', CanvasGraphicsRenderer); CanvasRenderer.registerPlugin('sprite', CanvasSpriteRenderer); -describe('InteractionManager', function () +describe('InteractionManager', () => { - afterEach(function () + let pointer: MockPointer; + + afterEach(() => { // if we made a MockPointer for the test, clean it up - if (this.pointer) + if (pointer) { - this.pointer.cleanUp(); - this.pointer = null; + pointer.cleanup(); + pointer = null; } }); - describe('event basics', function () + describe('event basics', () => { - it('should call mousedown handler', function () + it('should call mousedown handler', () => { const stage = new Container(); const graphics = new Graphics(); const eventSpy = sinon.spy(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); stage.addChild(graphics); graphics.beginFill(0xFFFFFF); @@ -49,12 +53,13 @@ describe('InteractionManager', function () expect(eventSpy).to.have.been.calledOnce; }); - it('should call mouseup handler', function () + it('should call mouseup handler', () => { const stage = new Container(); const graphics = new Graphics(); const eventSpy = sinon.spy(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); stage.addChild(graphics); graphics.beginFill(0xFFFFFF); @@ -67,12 +72,13 @@ describe('InteractionManager', function () expect(eventSpy).to.have.been.called; }); - it('should call mouseupoutside handler', function () + it('should call mouseupoutside handler', () => { const stage = new Container(); const graphics = new Graphics(); const eventSpy = sinon.spy(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); stage.addChild(graphics); graphics.beginFill(0xFFFFFF); @@ -86,12 +92,13 @@ describe('InteractionManager', function () expect(eventSpy).to.have.been.called; }); - it('should call mouseupoutside handler on mouseup on different elements', function () + it('should call mouseupoutside handler on mouseup on different elements', () => { const stage = new Container(); const graphics = new Graphics(); const eventSpy = sinon.spy(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); stage.addChild(graphics); graphics.beginFill(0xFFFFFF); @@ -105,12 +112,13 @@ describe('InteractionManager', function () expect(eventSpy).to.have.been.called; }); - it('should call mouseover handler', function () + it('should call mouseover handler', () => { const stage = new Container(); const graphics = new Graphics(); const eventSpy = sinon.spy(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); stage.addChild(graphics); graphics.beginFill(0xFFFFFF); @@ -123,12 +131,13 @@ describe('InteractionManager', function () expect(eventSpy).to.have.been.called; }); - it('should call mouseout handler', function () + it('should call mouseout handler', () => { const stage = new Container(); const graphics = new Graphics(); const eventSpy = sinon.spy(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); stage.addChild(graphics); graphics.beginFill(0xFFFFFF); @@ -142,7 +151,7 @@ describe('InteractionManager', function () expect(eventSpy).to.have.been.called; }); - it('should always call mouseout before mouseover', function () + it('should always call mouseout before mouseover', () => { const stage = new Container(); const graphicsA = new Graphics(); @@ -154,7 +163,7 @@ describe('InteractionManager', function () const mouseOverSpyB = sinon.spy(); const mouseOutSpyB = sinon.spy(); - const pointer = this.pointer = new MockPointer(stage); + pointer = new MockPointer(stage); stage.addChild(graphicsA); graphicsA.beginFill(0xFFFFFF); @@ -187,15 +196,15 @@ describe('InteractionManager', function () }); }); - describe('event propagation', function () + describe('event propagation', () => { - it('should stop event propagation', function () + it('should stop event propagation', () => { const stage = new Container(); const parent = new Container(); const graphics = new Graphics(); - const pointer = this.pointer = new MockPointer(stage); + pointer = new MockPointer(stage); const mouseDownChild = sinon.spy((evt) => evt.stopPropagation()); const mouseDownParent = sinon.spy(); @@ -218,13 +227,13 @@ describe('InteractionManager', function () expect(mouseDownParent).to.not.have.been.called; }); - it('should not stop events on the same object from happening', function () + it('should not stop events on the same object from happening', () => { const stage = new Container(); const parent = new Container(); const graphics = new Graphics(); - const pointer = this.pointer = new MockPointer(stage); + pointer = new MockPointer(stage); // Neither of these should stop the other from firing const mouseMoveChild = sinon.spy((evt) => evt.stopPropagation()); @@ -256,13 +265,13 @@ describe('InteractionManager', function () expect(mouseMoveParent).to.not.have.been.called; }); - it('should not stop events on children of an object from happening', function () + it('should not stop events on children of an object from happening', () => { const stage = new Container(); const parent = new Container(); const graphics = new Graphics(); - const pointer = this.pointer = new MockPointer(stage); + pointer = new MockPointer(stage); const mouseMoveChild = sinon.spy(); const mouseMoveParent = sinon.spy((evt) => evt.stopPropagation()); @@ -294,15 +303,16 @@ describe('InteractionManager', function () }); }); - describe('touch vs pointer', function () + describe('touch vs pointer', () => { - it('should call touchstart and pointerdown when touch event and pointer supported', function () + it('should call touchstart and pointerdown when touch event and pointer supported', () => { const stage = new Container(); const graphics = new Graphics(); const touchSpy = sinon.spy(function touchListen() { /* noop */ }); const pointerSpy = sinon.spy(function pointerListen() { /* noop */ }); - const pointer = this.pointer = new MockPointer(stage, null, null, true); + + pointer = new MockPointer(stage, null, null, true); stage.addChild(graphics); graphics.beginFill(0xFFFFFF); @@ -317,13 +327,14 @@ describe('InteractionManager', function () expect(pointerSpy).to.have.been.calledOnce; }); - it('should not call touchstart or pointerdown when pointer event and touch supported', function () + it('should not call touchstart or pointerdown when pointer event and touch supported', () => { const stage = new Container(); const graphics = new Graphics(); const touchSpy = sinon.spy(function touchListen() { /* noop */ }); const pointerSpy = sinon.spy(function pointerListen() { /* noop */ }); - const pointer = this.pointer = new MockPointer(stage, null, null, true); + + pointer = new MockPointer(stage, null, null, true); stage.addChild(graphics); graphics.beginFill(0xFFFFFF); @@ -338,13 +349,14 @@ describe('InteractionManager', function () expect(pointerSpy).to.not.have.been.called; }); - it('should call touchstart and pointerdown when touch event and pointer not supported', function () + it('should call touchstart and pointerdown when touch event and pointer not supported', () => { const stage = new Container(); const graphics = new Graphics(); const touchSpy = sinon.spy(function touchListen() { /* noop */ }); const pointerSpy = sinon.spy(function pointerListen() { /* noop */ }); - const pointer = this.pointer = new MockPointer(stage, null, null, false); + + pointer = new MockPointer(stage, null, null, false); stage.addChild(graphics); graphics.beginFill(0xFFFFFF); @@ -359,13 +371,14 @@ describe('InteractionManager', function () expect(pointerSpy).to.have.been.calledOnce; }); - it('should call touchstart and pointerdown when pointer event and touch not supported', function () + it('should call touchstart and pointerdown when pointer event and touch not supported', () => { const stage = new Container(); const graphics = new Graphics(); const touchSpy = sinon.spy(function touchListen() { /* noop */ }); const pointerSpy = sinon.spy(function pointerListen() { /* noop */ }); - const pointer = this.pointer = new MockPointer(stage, null, null, true); + + pointer = new MockPointer(stage, null, null, true); pointer.interaction.supportsTouchEvents = false; @@ -383,35 +396,40 @@ describe('InteractionManager', function () }); }); - describe('add/remove events and ticker', function () + describe('add/remove events and ticker', () => { - let stub; + let stub: sinon.SinonStub; - before(function () + before(() => { stub = sinon.stub(InteractionManager.prototype, 'setTargetElement'); }); - after(function () + after(() => { stub.restore(); }); - it('should add and remove pointer events to document', function () + it('should add and remove pointer events to document', () => { - const manager = new InteractionManager(sinon.stub()); + const manager = new InteractionManager(sinon.stub() as any); const addSpy = sinon.spy(window.document, 'addEventListener'); const removeSpy = sinon.spy(window.document, 'removeEventListener'); - manager.interactionDOMElement = { style: {}, addEventListener: sinon.stub(), removeEventListener: sinon.stub() }; - manager.supportsPointerEvents = true; + manager['interactionDOMElement'] = { + style: {}, + addEventListener: sinon.stub(), + removeEventListener: sinon.stub() + } as unknown as HTMLElement; + // @ts-expect-error - overriding readonly prop + manager['supportsPointerEvents'] = true; - manager.addEvents(); + manager['addEvents'](); expect(addSpy).to.have.been.calledOnce; expect(addSpy).to.have.been.calledWith('pointermove'); - manager.removeEvents(); + manager['removeEvents'](); expect(removeSpy).to.have.been.calledOnce; expect(removeSpy).to.have.been.calledWith('pointermove'); @@ -420,22 +438,27 @@ describe('InteractionManager', function () removeSpy.restore(); }); - it('should add and remove pointer events to window', function () + it('should add and remove pointer events to window', () => { - const manager = new InteractionManager(sinon.stub()); + const manager = new InteractionManager(sinon.stub() as any); const addSpy = sinon.spy(window, 'addEventListener'); const removeSpy = sinon.spy(window, 'removeEventListener'); - manager.interactionDOMElement = { style: {}, addEventListener: sinon.stub(), removeEventListener: sinon.stub() }; - manager.supportsPointerEvents = true; + manager['interactionDOMElement'] = { + style: {}, + addEventListener: sinon.stub(), + removeEventListener: sinon.stub() + } as unknown as HTMLElement; + // @ts-expect-error - overriding readonly prop + manager['supportsPointerEvents'] = true; - manager.addEvents(); + manager['addEvents'](); expect(addSpy).to.have.been.calledTwice; expect(addSpy).to.have.been.calledWith('pointercancel'); expect(addSpy).to.have.been.calledWith('pointerup'); - manager.removeEvents(); + manager['removeEvents'](); expect(removeSpy).to.have.been.calledTwice; expect(removeSpy).to.have.been.calledWith('pointercancel'); @@ -445,16 +468,22 @@ describe('InteractionManager', function () removeSpy.restore(); }); - it('should add and remove pointer events to element seven times when touch events are supported', function () + it('should add and remove pointer events to element seven times when touch events are supported', () => { - const manager = new InteractionManager(sinon.stub()); - const element = { style: {}, addEventListener: sinon.stub(), removeEventListener: sinon.stub() }; + const manager = new InteractionManager(sinon.stub() as any); + const element = { + style: {}, + addEventListener: sinon.stub(), + removeEventListener: sinon.stub() + } as unknown as HTMLElement; - manager.interactionDOMElement = element; - manager.supportsPointerEvents = true; - manager.supportsTouchEvents = true; + manager['interactionDOMElement'] = element; + // @ts-expect-error - overriding readonly prop + manager['supportsPointerEvents'] = true; + // @ts-expect-error - overriding readonly prop + manager['supportsTouchEvents'] = true; - manager.addEvents(); + manager['addEvents'](); expect(element.addEventListener).to.have.been.callCount(7); expect(element.addEventListener).to.have.been.calledWith('pointerdown'); @@ -466,7 +495,7 @@ describe('InteractionManager', function () expect(element.addEventListener).to.have.been.calledWith('touchend'); expect(element.addEventListener).to.have.been.calledWith('touchmove'); - manager.removeEvents(); + manager['removeEvents'](); expect(element.removeEventListener).to.have.been.callCount(7); expect(element.removeEventListener).to.have.been.calledWith('pointerdown'); @@ -479,23 +508,29 @@ describe('InteractionManager', function () expect(element.removeEventListener).to.have.been.calledWith('touchmove'); }); - it('should add and remove pointer events to element three times when touch events are not supported', function () + it('should add and remove pointer events to element three times when touch events are not supported', () => { - const manager = new InteractionManager(sinon.stub()); - const element = { style: {}, addEventListener: sinon.stub(), removeEventListener: sinon.stub() }; + const manager = new InteractionManager(sinon.stub() as any); + const element = { + style: {}, + addEventListener: sinon.stub(), + removeEventListener: sinon.stub() + } as unknown as HTMLElement; - manager.interactionDOMElement = element; - manager.supportsPointerEvents = true; - manager.supportsTouchEvents = false; + manager['interactionDOMElement'] = element; + // @ts-expect-error - overriding readonly prop + manager['supportsPointerEvents'] = true; + // @ts-expect-error - overriding readonly prop + manager['supportsTouchEvents'] = false; - manager.addEvents(); + manager['addEvents'](); expect(element.addEventListener).to.have.been.calledThrice; expect(element.addEventListener).to.have.been.calledWith('pointerdown'); expect(element.addEventListener).to.have.been.calledWith('pointerleave'); expect(element.addEventListener).to.have.been.calledWith('pointerover'); - manager.removeEvents(); + manager['removeEvents'](); expect(element.removeEventListener).to.have.been.calledThrice; expect(element.removeEventListener).to.have.been.calledWith('pointerdown'); @@ -503,21 +538,26 @@ describe('InteractionManager', function () expect(element.removeEventListener).to.have.been.calledWith('pointerover'); }); - it('should add and remove mouse events to document', function () + it('should add and remove mouse events to document', () => { - const manager = new InteractionManager(sinon.stub()); + const manager = new InteractionManager(sinon.stub() as any); const addSpy = sinon.spy(window.document, 'addEventListener'); const removeSpy = sinon.spy(window.document, 'removeEventListener'); - manager.interactionDOMElement = { style: {}, addEventListener: sinon.stub(), removeEventListener: sinon.stub() }; - manager.supportsPointerEvents = false; + manager['interactionDOMElement'] = { + style: {}, + addEventListener: sinon.stub(), + removeEventListener: sinon.stub() + } as unknown as HTMLElement; + // @ts-expect-error - overriding readonly prop + manager['supportsPointerEvents'] = false; - manager.addEvents(); + manager['addEvents'](); expect(addSpy).to.have.been.calledOnce; expect(addSpy).to.have.been.calledWith('mousemove'); - manager.removeEvents(); + manager['removeEvents'](); expect(removeSpy).to.have.been.calledOnce; expect(removeSpy).to.have.been.calledWith('mousemove'); @@ -526,21 +566,26 @@ describe('InteractionManager', function () removeSpy.restore(); }); - it('should add and remove mouse events to window', function () + it('should add and remove mouse events to window', () => { - const manager = new InteractionManager(sinon.stub()); + const manager = new InteractionManager(sinon.stub() as any); const addSpy = sinon.spy(window, 'addEventListener'); const removeSpy = sinon.spy(window, 'removeEventListener'); - manager.interactionDOMElement = { style: {}, addEventListener: sinon.stub(), removeEventListener: sinon.stub() }; - manager.supportsPointerEvents = false; + manager['interactionDOMElement'] = { + style: {}, + addEventListener: sinon.stub(), + removeEventListener: sinon.stub() + } as unknown as HTMLElement; + // @ts-expect-error - overriding readonly prop + manager['supportsPointerEvents'] = false; - manager.addEvents(); + manager['addEvents'](); expect(addSpy).to.have.been.calledOnce; expect(addSpy).to.have.been.calledWith('mouseup'); - manager.removeEvents(); + manager['removeEvents'](); expect(removeSpy).to.have.been.calledOnce; expect(removeSpy).to.have.been.calledWith('mouseup'); @@ -549,23 +594,29 @@ describe('InteractionManager', function () removeSpy.restore(); }); - it('should add and remove mouse events to element', function () + it('should add and remove mouse events to element', () => { - const manager = new InteractionManager(sinon.stub()); - const element = { style: {}, addEventListener: sinon.stub(), removeEventListener: sinon.stub() }; + const manager = new InteractionManager(sinon.stub() as any); + const element = { + style: {}, + addEventListener: sinon.stub(), + removeEventListener: sinon.stub() + } as unknown as HTMLElement; - manager.interactionDOMElement = element; - manager.supportsPointerEvents = false; - manager.supportsTouchEvents = false; + manager['interactionDOMElement'] = element; + // @ts-expect-error - overriding readonly prop + manager['supportsPointerEvents'] = false; + // @ts-expect-error - overriding readonly prop + manager['supportsTouchEvents'] = false; - manager.addEvents(); + manager['addEvents'](); expect(element.addEventListener).to.have.been.calledThrice; expect(element.addEventListener).to.have.been.calledWith('mousedown'); expect(element.addEventListener).to.have.been.calledWith('mouseout'); expect(element.addEventListener).to.have.been.calledWith('mouseover'); - manager.removeEvents(); + manager['removeEvents'](); expect(element.removeEventListener).to.have.been.calledThrice; expect(element.removeEventListener).to.have.been.calledWith('mousedown'); @@ -573,23 +624,29 @@ describe('InteractionManager', function () expect(element.removeEventListener).to.have.been.calledWith('mouseover'); }); - it('should add and remove touch events to element without pointer events', function () + it('should add and remove touch events to element without pointer events', () => { - const manager = new InteractionManager(sinon.stub()); - const element = { style: {}, addEventListener: sinon.stub(), removeEventListener: sinon.stub() }; + const manager = new InteractionManager(sinon.stub() as any); + const element = { + style: {}, + addEventListener: sinon.stub(), + removeEventListener: sinon.stub() + } as unknown as HTMLElement; - manager.interactionDOMElement = element; - manager.supportsPointerEvents = false; - manager.supportsTouchEvents = true; + manager['interactionDOMElement'] = element; + // @ts-expect-error - overriding readonly prop + manager['supportsPointerEvents'] = false; + // @ts-expect-error - overriding readonly prop + manager['supportsTouchEvents'] = true; - manager.addEvents(); + manager['addEvents'](); expect(element.addEventListener).to.have.been.calledWith('touchstart'); expect(element.addEventListener).to.have.been.calledWith('touchcancel'); expect(element.addEventListener).to.have.been.calledWith('touchend'); expect(element.addEventListener).to.have.been.calledWith('touchmove'); - manager.removeEvents(); + manager['removeEvents'](); expect(element.removeEventListener).to.have.been.calledWith('touchstart'); expect(element.removeEventListener).to.have.been.calledWith('touchcancel'); @@ -597,23 +654,29 @@ describe('InteractionManager', function () expect(element.removeEventListener).to.have.been.calledWith('touchmove'); }); - it('should add and remove touch events to element with pointer events', function () + it('should add and remove touch events to element with pointer events', () => { - const manager = new InteractionManager(sinon.stub()); - const element = { style: {}, addEventListener: sinon.stub(), removeEventListener: sinon.stub() }; + const manager = new InteractionManager(sinon.stub() as any); + const element = { + style: {}, + addEventListener: sinon.stub(), + removeEventListener: sinon.stub() + } as unknown as HTMLElement; - manager.interactionDOMElement = element; - manager.supportsPointerEvents = true; - manager.supportsTouchEvents = true; + manager['interactionDOMElement'] = element; + // @ts-expect-error - overriding readonly prop + manager['supportsPointerEvents'] = true; + // @ts-expect-error - overriding readonly prop + manager['supportsTouchEvents'] = true; - manager.addEvents(); + manager['addEvents'](); expect(element.addEventListener).to.have.been.calledWith('touchstart'); expect(element.addEventListener).to.have.been.calledWith('touchcancel'); expect(element.addEventListener).to.have.been.calledWith('touchend'); expect(element.addEventListener).to.have.been.calledWith('touchmove'); - manager.removeEvents(); + manager['removeEvents'](); expect(element.removeEventListener).to.have.been.calledWith('touchstart'); expect(element.removeEventListener).to.have.been.calledWith('touchcancel'); @@ -621,17 +684,16 @@ describe('InteractionManager', function () expect(element.removeEventListener).to.have.been.calledWith('touchmove'); }); - it('should add and remove Ticker.system listener', function () + it('should add and remove Ticker.system listener', () => { - const manager = new InteractionManager(sinon.stub()); + const manager = new InteractionManager(sinon.stub() as any); + const element = {} as unknown as HTMLElement; - const element = {}; - - manager.interactionDOMElement = element; + manager['interactionDOMElement'] = element; const listenerCount = Ticker.system.count; - manager.addTickerListener(); + manager['addTickerListener'](); expect(Ticker.system.count).to.equal(listenerCount + 1); @@ -643,7 +705,7 @@ describe('InteractionManager', function () expect(Ticker.system.count).to.equal(listenerCount + 1); - manager.removeTickerListener(); + manager['removeTickerListener'](); expect(Ticker.system.count).to.equal(listenerCount); @@ -651,20 +713,21 @@ describe('InteractionManager', function () expect(Ticker.system.count).to.equal(listenerCount); - manager.addTickerListener(); + manager['addTickerListener'](); expect(Ticker.system.count).to.equal(listenerCount); }); }); - describe('onClick', function () + describe('onClick', () => { - it('should call handler when inside', function () + it('should call handler when inside', () => { const stage = new Container(); const graphics = new Graphics(); const clickSpy = sinon.spy(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); stage.addChild(graphics); graphics.beginFill(0xFFFFFF); @@ -677,12 +740,13 @@ describe('InteractionManager', function () expect(clickSpy).to.have.been.calledOnce; }); - it('should not call handler when outside', function () + it('should not call handler when outside', () => { const stage = new Container(); const graphics = new Graphics(); const clickSpy = sinon.spy(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); stage.addChild(graphics); graphics.beginFill(0xFFFFFF); @@ -695,7 +759,7 @@ describe('InteractionManager', function () expect(clickSpy).to.not.have.been.called; }); - it('should not call handler when mousedown not received', function () + it('should not call handler when mousedown not received', () => { const stage = new Container(); const graphics = new Graphics(); @@ -719,14 +783,15 @@ describe('InteractionManager', function () }); }); - describe('onTap', function () + describe('onTap', () => { - it('should call handler when inside', function () + it('should call handler when inside', () => { const stage = new Container(); const graphics = new Graphics(); const clickSpy = sinon.spy(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); stage.addChild(graphics); graphics.beginFill(0xFFFFFF); @@ -739,12 +804,13 @@ describe('InteractionManager', function () expect(clickSpy).to.have.been.calledOnce; }); - it('should not call handler when outside', function () + it('should not call handler when outside', () => { const stage = new Container(); const graphics = new Graphics(); const clickSpy = sinon.spy(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); stage.addChild(graphics); graphics.beginFill(0xFFFFFF); @@ -757,7 +823,7 @@ describe('InteractionManager', function () expect(clickSpy).to.not.have.been.called; }); - it('should not call handler when moved to other sprite', function () + it('should not call handler when moved to other sprite', () => { const stage = new Container(); const graphics = new Graphics(); @@ -765,13 +831,13 @@ describe('InteractionManager', function () const clickSpy = sinon.spy(); const overSpy = sinon.spy(); const endSpy = sinon.spy(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); stage.addChild(graphics); graphics.beginFill(0xFFFFFF); graphics.drawRect(0, 0, 50, 50); graphics.interactive = true; - graphics.name = 'graphics1'; stage.addChild(graphics2); graphics2.beginFill(0xFFFFFF); @@ -780,7 +846,6 @@ describe('InteractionManager', function () graphics2.on('tap', clickSpy); graphics2.on('touchmove', overSpy); graphics2.on('touchend', endSpy); - graphics2.name = 'graphics2'; pointer.touchstart(25, 25, 3); pointer.touchmove(60, 60, 3); @@ -793,14 +858,15 @@ describe('InteractionManager', function () }); }); - describe('pointertap', function () + describe('pointertap', () => { - it('should call handler when inside', function () + it('should call handler when inside', () => { const stage = new Container(); const graphics = new Graphics(); const clickSpy = sinon.spy(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); stage.addChild(graphics); graphics.beginFill(0xFFFFFF); @@ -813,12 +879,13 @@ describe('InteractionManager', function () expect(clickSpy).to.have.been.calledOnce; }); - it('should not call handler when outside', function () + it('should not call handler when outside', () => { const stage = new Container(); const graphics = new Graphics(); const clickSpy = sinon.spy(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); stage.addChild(graphics); graphics.beginFill(0xFFFFFF); @@ -831,7 +898,7 @@ describe('InteractionManager', function () expect(clickSpy).to.not.have.been.called; }); - it('with mouse events, should not call handler when moved to other sprite', function () + it('with mouse events, should not call handler when moved to other sprite', () => { const stage = new Container(); const graphics = new Graphics(); @@ -839,13 +906,13 @@ describe('InteractionManager', function () const overSpy = sinon.spy(); const upSpy = sinon.spy(); const clickSpy = sinon.spy(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); stage.addChild(graphics); graphics.beginFill(0xFFFFFF); graphics.drawRect(0, 0, 50, 50); graphics.interactive = true; - graphics.name = 'graphics1'; stage.addChild(graphics2); graphics2.beginFill(0xFFFFFF); @@ -854,7 +921,6 @@ describe('InteractionManager', function () graphics2.on('pointertap', clickSpy); graphics2.on('pointerover', overSpy); graphics2.on('pointerup', upSpy); - graphics2.name = 'graphics2'; pointer.mousedown(25, 25); pointer.mousemove(60, 60); @@ -866,7 +932,7 @@ describe('InteractionManager', function () expect(clickSpy).to.not.have.been.called; }); - it('with pointer events, should not call handler when moved to other sprite', function () + it('with pointer events, should not call handler when moved to other sprite', () => { const stage = new Container(); const graphics = new Graphics(); @@ -874,13 +940,13 @@ describe('InteractionManager', function () const overSpy = sinon.spy(); const upSpy = sinon.spy(); const clickSpy = sinon.spy(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); stage.addChild(graphics); graphics.beginFill(0xFFFFFF); graphics.drawRect(0, 0, 50, 50); graphics.interactive = true; - graphics.name = 'graphics1'; stage.addChild(graphics2); graphics2.beginFill(0xFFFFFF); @@ -889,7 +955,6 @@ describe('InteractionManager', function () graphics2.on('pointertap', clickSpy); graphics2.on('pointerover', overSpy); graphics2.on('pointerup', upSpy); - graphics2.name = 'graphics2'; pointer.mousedown(25, 25, true); pointer.mousemove(60, 60, true); @@ -901,7 +966,7 @@ describe('InteractionManager', function () expect(clickSpy).to.not.have.been.called; }); - it('with touch events, should not call handler when moved to other sprite', function () + it('with touch events, should not call handler when moved to other sprite', () => { const stage = new Container(); const graphics = new Graphics(); @@ -909,13 +974,13 @@ describe('InteractionManager', function () const moveSpy = sinon.spy(); const upSpy = sinon.spy(); const clickSpy = sinon.spy(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); stage.addChild(graphics); graphics.beginFill(0xFFFFFF); graphics.drawRect(0, 0, 50, 50); graphics.interactive = true; - graphics.name = 'graphics1'; stage.addChild(graphics2); graphics2.beginFill(0xFFFFFF); @@ -924,7 +989,6 @@ describe('InteractionManager', function () graphics2.on('pointertap', clickSpy); graphics2.on('pointermove', moveSpy); graphics2.on('pointerup', upSpy); - graphics2.name = 'graphics2'; pointer.touchstart(25, 25, true); pointer.touchmove(60, 60, true); @@ -937,9 +1001,9 @@ describe('InteractionManager', function () }); }); - describe('overlapping children', function () + describe('overlapping children', () => { - function getScene(callbackEventName, splitParents) + function getScene(callbackEventName: string, splitParents?: boolean) { const behindChild = new Graphics(); const frontChild = new Graphics(); @@ -947,27 +1011,23 @@ describe('InteractionManager', function () const behindChildCallback = sinon.spy(function behindSpy() { /* no op*/ }); const frontChildCallback = sinon.spy(function frontSpy() { /* no op*/ }); const parentCallback = sinon.spy(function parentSpy() { /* no op*/ }); - let behindParent; - let frontParent; - let behindParentCallback; - let frontParentCallback; + let behindParent: Container; + let frontParent: Container; + let behindParentCallback: sinon.SinonSpy; + let frontParentCallback: sinon.SinonSpy; behindChild.beginFill(0xFF); behindChild.drawRect(0, 0, 50, 50); behindChild.on(callbackEventName, behindChildCallback); - behindChild.name = 'behind'; frontChild.beginFill(0x00FF); frontChild.drawRect(0, 0, 50, 50); frontChild.on(callbackEventName, frontChildCallback); - frontChild.name = 'front'; if (splitParents) { behindParent = new Container(); - behindParent.name = 'behindParent'; frontParent = new Container(); - frontParent.name = 'frontParent'; behindParentCallback = sinon.spy(function behindParentSpy() { /* no op*/ }); frontParentCallback = sinon.spy(function frontParentSpy() { /* no op*/ }); behindParent.on(callbackEventName, behindParentCallback); @@ -976,8 +1036,6 @@ describe('InteractionManager', function () parent.addChild(behindParent, frontParent); behindParent.addChild(behindChild); frontParent.addChild(frontChild); - - parent.name = 'parent'; } else { @@ -999,14 +1057,15 @@ describe('InteractionManager', function () }; } - describe('when parent is non-interactive', function () + describe('when parent is non-interactive', () => { - describe('when both children are interactive', function () + describe('when both children are interactive', () => { - it('should callback front child when clicking front child', function () + it('should callback front child when clicking front child', () => { const stage = new Container(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); const scene = getScene('click'); scene.behindChild.interactive = true; @@ -1021,10 +1080,11 @@ describe('InteractionManager', function () expect(scene.parentCallback).to.not.have.been.called; }); - it('should callback front child when clicking overlap', function () + it('should callback front child when clicking overlap', () => { const stage = new Container(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); const scene = getScene('click'); scene.behindChild.interactive = true; @@ -1039,10 +1099,11 @@ describe('InteractionManager', function () expect(scene.parentCallback).to.not.have.been.called; }); - it('should callback behind child when clicking behind child', function () + it('should callback behind child when clicking behind child', () => { const stage = new Container(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); const scene = getScene('click'); scene.behindChild.interactive = true; @@ -1057,10 +1118,11 @@ describe('InteractionManager', function () expect(scene.parentCallback).to.not.have.been.called; }); - it('should callback front child of different non-interactive parents when clicking overlap', function () + it('should callback front child of different non-interactive parents when clicking overlap', () => { const stage = new Container(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); const scene = getScene('click', true); scene.behindChild.interactive = true; @@ -1077,10 +1139,11 @@ describe('InteractionManager', function () expect(scene.frontParentCallback).to.not.have.been.called; }); - it('should callback front child of different interactive parents when clicking overlap', function () + it('should callback front child of different interactive parents when clicking overlap', () => { const stage = new Container(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); const scene = getScene('click', true); scene.behindChild.interactive = true; @@ -1100,12 +1163,13 @@ describe('InteractionManager', function () }); }); - describe('when front child is non-interactive', function () + describe('when front child is non-interactive', () => { - it('should not callback when clicking front child', function () + it('should not callback when clicking front child', () => { const stage = new Container(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); const scene = getScene('click'); scene.behindChild.interactive = true; @@ -1119,10 +1183,11 @@ describe('InteractionManager', function () expect(scene.parentCallback).to.not.have.been.called; }); - it('should callback behind child when clicking overlap', function () + it('should callback behind child when clicking overlap', () => { const stage = new Container(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); const scene = getScene('click'); scene.behindChild.interactive = true; @@ -1136,10 +1201,11 @@ describe('InteractionManager', function () expect(scene.parentCallback).to.not.have.been.called; }); - it('should callback behind child when clicking behind child', function () + it('should callback behind child when clicking behind child', () => { const stage = new Container(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); const scene = getScene('click'); scene.behindChild.interactive = true; @@ -1154,12 +1220,13 @@ describe('InteractionManager', function () }); }); - describe('when behind child is non-interactive', function () + describe('when behind child is non-interactive', () => { - it('should callback front child when clicking front child', function () + it('should callback front child when clicking front child', () => { const stage = new Container(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); const scene = getScene('click'); scene.behindChild.x = 25; @@ -1173,10 +1240,11 @@ describe('InteractionManager', function () expect(scene.parentCallback).to.not.have.been.called; }); - it('should callback front child when clicking overlap', function () + it('should callback front child when clicking overlap', () => { const stage = new Container(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); const scene = getScene('click'); scene.behindChild.x = 25; @@ -1190,10 +1258,11 @@ describe('InteractionManager', function () expect(scene.parentCallback).to.not.have.been.called; }); - it('should not callback when clicking behind child', function () + it('should not callback when clicking behind child', () => { const stage = new Container(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); const scene = getScene('click'); scene.behindChild.x = 25; @@ -1209,14 +1278,15 @@ describe('InteractionManager', function () }); }); - describe('when parent is interactive', function () + describe('when parent is interactive', () => { - describe('when both children are interactive', function () + describe('when both children are interactive', () => { - it('should callback parent and front child when clicking front child', function () + it('should callback parent and front child when clicking front child', () => { const stage = new Container(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); const scene = getScene('click'); scene.behindChild.interactive = true; @@ -1232,10 +1302,11 @@ describe('InteractionManager', function () expect(scene.parentCallback).to.have.been.calledOnce; }); - it('should callback parent and front child when clicking overlap', function () + it('should callback parent and front child when clicking overlap', () => { const stage = new Container(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); const scene = getScene('click'); scene.behindChild.interactive = true; @@ -1251,10 +1322,11 @@ describe('InteractionManager', function () expect(scene.parentCallback).to.have.been.calledOnce; }); - it('should callback parent and behind child when clicking behind child', function () + it('should callback parent and behind child when clicking behind child', () => { const stage = new Container(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); const scene = getScene('click'); scene.behindChild.interactive = true; @@ -1270,10 +1342,11 @@ describe('InteractionManager', function () expect(scene.parentCallback).to.have.been.calledOnce; }); - it('should callback front child of different non-interactive parents when clicking overlap', function () + it('should callback front child of different non-interactive parents when clicking overlap', () => { const stage = new Container(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); const scene = getScene('click', true); scene.behindChild.interactive = true; @@ -1291,10 +1364,11 @@ describe('InteractionManager', function () expect(scene.frontParentCallback).to.not.have.been.called; }); - it('should callback front child of different interactive parents when clicking overlap', function () + it('should callback front child of different interactive parents when clicking overlap', () => { const stage = new Container(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); const scene = getScene('click', true); scene.behindChild.interactive = true; @@ -1315,12 +1389,13 @@ describe('InteractionManager', function () }); }); - describe('when front child is non-interactive', function () + describe('when front child is non-interactive', () => { - it('should callback parent when clicking front child', function () + it('should callback parent when clicking front child', () => { const stage = new Container(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); const scene = getScene('click'); scene.behindChild.interactive = true; @@ -1335,10 +1410,11 @@ describe('InteractionManager', function () expect(scene.parentCallback).to.have.been.calledOnce; }); - it('should callback parent and behind child when clicking overlap', function () + it('should callback parent and behind child when clicking overlap', () => { const stage = new Container(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); const scene = getScene('click'); scene.behindChild.interactive = true; @@ -1353,10 +1429,11 @@ describe('InteractionManager', function () expect(scene.parentCallback).to.have.been.calledOnce; }); - it('should callback parent and behind child when clicking behind child', function () + it('should callback parent and behind child when clicking behind child', () => { const stage = new Container(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); const scene = getScene('click'); scene.behindChild.interactive = true; @@ -1372,12 +1449,13 @@ describe('InteractionManager', function () }); }); - describe('when behind child is non-interactive', function () + describe('when behind child is non-interactive', () => { - it('should callback parent and front child when clicking front child', function () + it('should callback parent and front child when clicking front child', () => { const stage = new Container(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); const scene = getScene('click'); scene.behindChild.x = 25; @@ -1392,10 +1470,11 @@ describe('InteractionManager', function () expect(scene.parentCallback).to.have.been.calledOnce; }); - it('should callback parent and front child when clicking overlap', function () + it('should callback parent and front child when clicking overlap', () => { const stage = new Container(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); const scene = getScene('click'); scene.behindChild.x = 25; @@ -1410,10 +1489,11 @@ describe('InteractionManager', function () expect(scene.parentCallback).to.have.been.calledOnce; }); - it('should callback parent when clicking behind child', function () + it('should callback parent when clicking behind child', () => { const stage = new Container(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); const scene = getScene('click'); scene.behindChild.x = 25; @@ -1430,7 +1510,7 @@ describe('InteractionManager', function () }); }); - it('Semi-complicated nesting with overlap, should not call behind callback', function () + it('Semi-complicated nesting with overlap, should not call behind callback', () => { const stage = new Container(); const frontParent = new Container(); @@ -1448,7 +1528,7 @@ describe('InteractionManager', function () frontChild.beginFill(0x00FF); frontChild.drawRect(0, 0, 50, 50); frontParent.on('click', frontCallback); - const pointer = this.pointer = new MockPointer(stage); + pointer = new MockPointer(stage); behindParent.x = 25; subParent.interactive = true; @@ -1467,9 +1547,9 @@ describe('InteractionManager', function () }); }); - describe('masks', function () + describe('masks', () => { - it('should trigger interaction callback when no mask present', function () + it('should trigger interaction callback when no mask present', () => { const stage = new Container(); const pointer = new MockPointer(stage); @@ -1491,7 +1571,7 @@ describe('InteractionManager', function () expect(spy).to.have.been.calledOnce; }); - it('should trigger interaction callback when mask uses beginFill', function () + it('should trigger interaction callback when mask uses beginFill', () => { const stage = new Container(); const pointer = new MockPointer(stage); @@ -1513,7 +1593,7 @@ describe('InteractionManager', function () expect(spy).to.have.been.calledOnce; }); - it('should trigger interaction callback on child when inside of parents mask', function () + it('should trigger interaction callback on child when inside of parents mask', () => { const stage = new Container(); const parent = new Container(); @@ -1537,7 +1617,7 @@ describe('InteractionManager', function () expect(spy).to.have.been.calledOnce; }); - it('should not trigger interaction callback on child when outside of parents mask', function () + it('should not trigger interaction callback on child when outside of parents mask', () => { const stage = new Container(); const parent = new Container(); @@ -1561,7 +1641,7 @@ describe('InteractionManager', function () expect(spy).to.have.not.been.calledOnce; }); - it('should not trigger interaction callback when mask doesn\'t use beginFill', function () + it('should not trigger interaction callback when mask doesn\'t use beginFill', () => { const stage = new Container(); const pointer = new MockPointer(stage); @@ -1582,7 +1662,7 @@ describe('InteractionManager', function () expect(spy).to.have.not.been.called; }); - it('should trigger interaction callback when mask doesn\'t use beginFill but hitArea is defined', function () + it('should trigger interaction callback when mask doesn\'t use beginFill but hitArea is defined', () => { const stage = new Container(); const pointer = new MockPointer(stage); @@ -1604,7 +1684,7 @@ describe('InteractionManager', function () expect(spy).to.have.been.calledOnce; }); - it('should trigger interaction callback when mask is a sprite', function () + it('should trigger interaction callback when mask is a sprite', () => { const stage = new Container(); const pointer = new MockPointer(stage); @@ -1618,7 +1698,7 @@ describe('InteractionManager', function () graphics.on('click', spy); stage.addChild(graphics); mask.drawRect(0, 0, 50, 50); - graphics.mask = new Sprite(mask.generateCanvasTexture()); + graphics.mask = new Sprite(mask.generateCanvasTexture() as Texture); pointer.click(10, 10); @@ -1626,9 +1706,9 @@ describe('InteractionManager', function () }); }); - describe('hitArea', function () + describe('hitArea', () => { - it('should trigger interaction callback when within hitArea', function () + it('should trigger interaction callback when within hitArea', () => { const stage = new Container(); const pointer = new MockPointer(stage); @@ -1647,7 +1727,7 @@ describe('InteractionManager', function () expect(spy).to.have.been.calledOnce; }); - it('should not trigger interaction callback when not within hitArea', function () + it('should not trigger interaction callback when not within hitArea', () => { const stage = new Container(); const pointer = new MockPointer(stage); @@ -1666,7 +1746,7 @@ describe('InteractionManager', function () expect(spy).to.have.not.been.calledOnce; }); - it('should trigger interaction callback on child when inside of parents hitArea', function () + it('should trigger interaction callback on child when inside of parents hitArea', () => { const stage = new Container(); const parent = new Container(); @@ -1687,7 +1767,7 @@ describe('InteractionManager', function () expect(spy).to.have.been.calledOnce; }); - it('should not trigger interaction callback on child when outside of parents hitArea', function () + it('should not trigger interaction callback on child when outside of parents hitArea', () => { const stage = new Container(); const parent = new Container(); @@ -1709,13 +1789,14 @@ describe('InteractionManager', function () }); }); - describe('cursor changes', function () + describe('cursor changes', () => { - it('cursor should be the cursor of interactive item', function () + it('cursor should be the cursor of interactive item', () => { const stage = new Container(); const graphics = new Graphics(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); stage.addChild(graphics); graphics.beginFill(0xFFFFFF); @@ -1729,11 +1810,12 @@ describe('InteractionManager', function () expect(pointer.renderer.view.style.cursor).to.equal('help'); }); - it('should return cursor to default on mouseout', function () + it('should return cursor to default on mouseout', () => { const stage = new Container(); const graphics = new Graphics(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); stage.addChild(graphics); graphics.beginFill(0xFFFFFF); @@ -1748,11 +1830,12 @@ describe('InteractionManager', function () expect(pointer.renderer.view.style.cursor).to.equal(pointer.interaction.cursorStyles.default); }); - it('should still be the over cursor after a click', function () + it('should still be the over cursor after a click', () => { const stage = new Container(); const graphics = new Graphics(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); stage.addChild(graphics); graphics.beginFill(0xFFFFFF); @@ -1767,11 +1850,12 @@ describe('InteractionManager', function () expect(pointer.renderer.view.style.cursor).to.equal('help'); }); - it('should return cursor to default when mouse leaves renderer', function () + it('should return cursor to default when mouse leaves renderer', () => { const stage = new Container(); const graphics = new Graphics(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); stage.addChild(graphics); graphics.beginFill(0xFFFFFF); @@ -1786,13 +1870,14 @@ describe('InteractionManager', function () expect(pointer.renderer.view.style.cursor).to.equal(pointer.interaction.cursorStyles.default); }); - it('cursor callback should be called', function () + it('cursor callback should be called', () => { const stage = new Container(); const graphics = new Graphics(); const overSpy = sinon.spy(); const defaultSpy = sinon.spy(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); stage.addChild(graphics); graphics.beginFill(0xFFFFFF); @@ -1809,12 +1894,13 @@ describe('InteractionManager', function () expect(defaultSpy).to.have.been.called; }); - it('cursor callback should only be called if the cursor actually changed', function () + it('cursor callback should only be called if the cursor actually changed', () => { const stage = new Container(); const graphics = new Graphics(); const defaultSpy = sinon.spy(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); stage.addChild(graphics); graphics.beginFill(0xFFFFFF); @@ -1829,11 +1915,12 @@ describe('InteractionManager', function () expect(defaultSpy).to.have.been.calledOnce; }); - it('cursor style object should be fully applied', function () + it('cursor style object should be fully applied', () => { const stage = new Container(); const graphics = new Graphics(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); stage.addChild(graphics); graphics.beginFill(0xFFFFFF); @@ -1851,11 +1938,12 @@ describe('InteractionManager', function () expect(pointer.renderer.view.style.display).to.equal('none'); }); - it('should not change cursor style if null cursor style provided', function () + it('should not change cursor style if null cursor style provided', () => { const stage = new Container(); const graphics = new Graphics(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); stage.addChild(graphics); graphics.beginFill(0xFFFFFF); @@ -1872,11 +1960,12 @@ describe('InteractionManager', function () expect(pointer.renderer.view.style.cursor).to.equal(''); }); - it('should use cursor property as css if no style entry', function () + it('should use cursor property as css if no style entry', () => { const stage = new Container(); const graphics = new Graphics(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); stage.addChild(graphics); graphics.beginFill(0xFFFFFF); @@ -1889,7 +1978,7 @@ describe('InteractionManager', function () }); }); - describe('recursive hitTesting', function () + describe('recursive hitTesting', () => { function getScene() { @@ -1917,12 +2006,13 @@ describe('InteractionManager', function () }; } - describe('when frontChild is interactive', function () + describe('when frontChild is interactive', () => { - it('should stop hitTesting after first hit', function () + it('should stop hitTesting after first hit', () => { const scene = getScene(); - const pointer = this.pointer = new MockPointer(scene.stage); + + pointer = new MockPointer(scene.stage); const frontHitTest = sinon.spy(scene.frontChild, 'containsPoint'); const middleHitTest = sinon.spy(scene.middleChild, 'containsPoint'); const behindHitTest = sinon.spy(scene.behindChild, 'containsPoint'); @@ -1939,12 +2029,13 @@ describe('InteractionManager', function () }); }); - describe('when frontChild is not interactive', function () + describe('when frontChild is not interactive', () => { - it('should stop hitTesting after first hit', function () + it('should stop hitTesting after first hit', () => { const scene = getScene(); - const pointer = this.pointer = new MockPointer(scene.stage); + + pointer = new MockPointer(scene.stage); const frontHitTest = sinon.spy(scene.frontChild, 'containsPoint'); const middleHitTest = sinon.spy(scene.middleChild, 'containsPoint'); const behindHitTest = sinon.spy(scene.behindChild, 'containsPoint'); @@ -1962,13 +2053,14 @@ describe('InteractionManager', function () }); }); - describe('pointer handling', function () + describe('pointer handling', () => { - it('pointer event from mouse should use single mouse data', function () + it('pointer event from mouse should use single mouse data', () => { const stage = new Container(); const graphics = new Graphics(); - const pointer = this.pointer = new MockPointer(stage, 100, 100, true); + + pointer = new MockPointer(stage, 100, 100, true); stage.addChild(graphics); graphics.beginFill(0xFFFFFF); @@ -1982,13 +2074,14 @@ describe('InteractionManager', function () }); }); - describe('data cleanup', function () + describe('data cleanup', () => { - it('touchleave after touchout should not orphan data', function () + it('touchleave after touchout should not orphan data', () => { const stage = new Container(); const graphics = new Graphics(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); stage.addChild(graphics); graphics.beginFill(0xFFFFFF); @@ -2004,13 +2097,14 @@ describe('InteractionManager', function () }); }); - describe('hitTest()', function () + describe('hitTest()', () => { - it('should return hit', function () + it('should return hit', () => { const stage = new Container(); const graphics = new Graphics(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); stage.addChild(graphics); graphics.beginFill(0xFFFFFF); @@ -2023,11 +2117,12 @@ describe('InteractionManager', function () expect(hit).to.equal(graphics); }); - it('should return null if not hit', function () + it('should return null if not hit', () => { const stage = new Container(); const graphics = new Graphics(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); stage.addChild(graphics); graphics.beginFill(0xFFFFFF); @@ -2040,12 +2135,13 @@ describe('InteractionManager', function () expect(hit).to.be.null; }); - it('should return top thing that was hit', function () + it('should return top thing that was hit', () => { const stage = new Container(); const graphics = new Graphics(); const behind = new Graphics(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); stage.addChild(behind); stage.addChild(graphics); @@ -2062,12 +2158,13 @@ describe('InteractionManager', function () expect(hit).to.equal(graphics); }); - it('should return hit when passing in root', function () + it('should return hit when passing in root', () => { const stage = new Container(); const graphics = new Graphics(); const behind = new Graphics(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); stage.addChild(behind); stage.addChild(graphics); @@ -2085,13 +2182,14 @@ describe('InteractionManager', function () }); }); - describe('InteractionData properties', function () + describe('InteractionData properties', () => { - it('isPrimary should be set for first touch only', function () + it('isPrimary should be set for first touch only', () => { const stage = new Container(); const graphics = new Graphics(); - const pointer = this.pointer = new MockPointer(stage); + + pointer = new MockPointer(stage); stage.addChild(graphics); graphics.beginFill(0xFFFFFF); @@ -2115,14 +2213,15 @@ describe('InteractionManager', function () }); }); - describe('mouse events from pens', function () + describe('mouse events from pens', () => { - it('should call mousedown handler', function () + it('should call mousedown handler', () => { const stage = new Container(); const graphics = new Graphics(); const eventSpy = sinon.spy(); - const pointer = this.pointer = new MockPointer(stage, null, null, true); + + pointer = new MockPointer(stage, null, null, true); stage.addChild(graphics); graphics.beginFill(0xFFFFFF); @@ -2135,12 +2234,13 @@ describe('InteractionManager', function () expect(eventSpy).to.have.been.calledOnce; }); - it('should call mousemove handler', function () + it('should call mousemove handler', () => { const stage = new Container(); const graphics = new Graphics(); const eventSpy = sinon.spy(); - const pointer = this.pointer = new MockPointer(stage, null, null, true); + + pointer = new MockPointer(stage, null, null, true); stage.addChild(graphics); graphics.beginFill(0xFFFFFF); @@ -2153,12 +2253,13 @@ describe('InteractionManager', function () expect(eventSpy).to.have.been.calledOnce; }); - it('should call mouseup handler', function () + it('should call mouseup handler', () => { const stage = new Container(); const graphics = new Graphics(); const eventSpy = sinon.spy(); - const pointer = this.pointer = new MockPointer(stage, null, null, true); + + pointer = new MockPointer(stage, null, null, true); stage.addChild(graphics); graphics.beginFill(0xFFFFFF); diff --git a/packages/interaction/test/MockPointer.ts b/packages/interaction/test/MockPointer.ts index 93959684a5..24a9c92112 100644 --- a/packages/interaction/test/MockPointer.ts +++ b/packages/interaction/test/MockPointer.ts @@ -1,33 +1,38 @@ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { CanvasRenderer } from '@pixi/canvas-renderer'; import { Ticker } from '@pixi/ticker'; -import { Rectangle } from '@pixi/math'; -import sinon from 'sinon'; +import { Point, Rectangle } from '@pixi/math'; +import { Container } from '@pixi/display'; const { system } = Ticker; /** * Use this to mock mouse/touch/pointer events - * * @class */ class MockPointer { + public createdPointerEvent: any; + public activeTouches: any[]; + public stage: Container; + public renderer: CanvasRenderer; + public interaction: any; /** * @param {PIXI.Container} stage - The root of the scene tree * @param {number} [width=100] - Width of the renderer * @param {number} [height=100] - Height of the renderer * @param {boolean} [ensurePointerEvents=false] - If we should make sure that PointerEvents are 'supported' */ - constructor(stage, width, height, ensurePointerEvents) + constructor(stage?: Container, width?: number, height?: number, ensurePointerEvents?: boolean) { // fake PointerEvent existing if (ensurePointerEvents && !window.PointerEvent) { - window.PointerEvent = class PointerEvent extends MouseEvent + (window as any).PointerEvent = class PointerEvent extends MouseEvent { + public pointerType: string; // eslint-disable-next-line - constructor(type, opts) + constructor(type: string, opts: any) { super(type, opts); this.pointerType = opts.pointerType; @@ -38,16 +43,18 @@ class MockPointer this.activeTouches = []; this.stage = stage; - this.renderer = new CanvasRenderer(width || 100, height || 100); + this.renderer = new CanvasRenderer({ + width: width || 100, + height: height || 100, + }); + // @ts-expect-error --- this.renderer.sayHello = () => { /* empty */ }; this.interaction = this.renderer.plugins.interaction; this.interaction.supportsTouchEvents = true; system.remove(this.interaction.update, this.interaction); } - /** - * Cleans up after tests - */ + /** Cleans up after tests */ cleanup() { if (this.createdPointerEvent) @@ -62,9 +69,9 @@ class MockPointer * @param {number} x - pointer x position * @param {number} y - pointer y position */ - setPosition(x, y) + setPosition(x: number, y: number) { - this.renderer.plugins.interaction.mapPositionToPoint = (point) => + this.renderer.plugins.interaction.mapPositionToPoint = (point: Point) => { point.x = x; point.y = y; @@ -81,17 +88,24 @@ class MockPointer /** * [createEvent description] - * @param {string} eventType `type` of event - * @param {number} x pointer x position - * @param {number} y pointer y position - * @param {number} [identifier] pointer id for touch events - * @param {boolean} [asPointer] If it should be a PointerEvent from a mouse or touch - * @param {boolean} [onCanvas=true] If the event should be on the canvas (as opposed to a different element) - * @return {Event} Generated MouseEvent, TouchEvent, or PointerEvent + * @param {string} eventType - `type` of event + * @param {number} x - pointer x position + * @param {number} y - pointer y position + * @param {number} [identifier] - pointer id for touch events + * @param {boolean} [asPointer] - If it should be a PointerEvent from a mouse or touch + * @param {boolean} [onCanvas=true] - If the event should be on the canvas (as opposed to a different element) + * @returns {Event} Generated MouseEvent, TouchEvent, or PointerEvent */ - createEvent(eventType, x, y, identifier, asPointer, onCanvas = true) + createEvent( + eventType: string, + x: number, + y: number, + identifier?: number | boolean, + asPointer?: boolean, + onCanvas = true + ): Event { - let event; + let event: PointerEvent | MouseEvent | TouchEvent; if (eventType.startsWith('mouse')) { @@ -101,7 +115,6 @@ class MockPointer pointerType: 'mouse', clientX: x, clientY: y, - preventDefault: sinon.stub(), }); } else @@ -109,7 +122,6 @@ class MockPointer event = new MouseEvent(eventType, { clientX: x, clientY: y, - preventDefault: sinon.stub(), }); } if (onCanvas) @@ -124,16 +136,15 @@ class MockPointer eventType = eventType.replace('touch', 'pointer').replace('start', 'down').replace('end', 'up'); event = new PointerEvent(eventType, { pointerType: 'touch', - pointerId: identifier || 0, + pointerId: identifier as number || 0, clientX: x, clientY: y, - preventDefault: sinon.stub(), }); Object.defineProperty(event, 'target', { value: this.renderer.view }); } else { - const touch = new Touch({ identifier: identifier || 0, target: this.renderer.view }); + const touch = new Touch({ identifier: identifier as number || 0, target: this.renderer.view }); if (eventType.endsWith('start')) { @@ -151,7 +162,6 @@ class MockPointer } } event = new TouchEvent(eventType, { - preventDefault: sinon.stub(), changedTouches: [touch], touches: this.activeTouches, }); @@ -163,10 +173,9 @@ class MockPointer { event = new PointerEvent(eventType, { pointerType: 'pen', - pointerId: identifier || 0, + pointerId: identifier as number || 0, clientX: x, clientY: y, - preventDefault: sinon.stub(), }); Object.defineProperty(event, 'target', { value: this.renderer.view }); } @@ -182,7 +191,7 @@ class MockPointer * @param {number} y - pointer y position * @param {boolean} [asPointer] - if it should be a PointerEvent from a mouse */ - mousemove(x, y, asPointer) + mousemove(x: number, y: number, asPointer?: boolean) { // mouseOverRenderer state should be correct, so mouse position to view rect const rect = new Rectangle(0, 0, this.renderer.width, this.renderer.height); @@ -206,7 +215,7 @@ class MockPointer * @param {number} y - pointer y position * @param {boolean} [asPointer] - if it should be a PointerEvent from a mouse */ - click(x, y, asPointer) + click(x: number, y: number, asPointer?: boolean) { this.mousedown(x, y, asPointer); this.mouseup(x, y, asPointer); @@ -217,7 +226,7 @@ class MockPointer * @param {number} y - pointer y position * @param {boolean} [asPointer] - if it should be a PointerEvent from a mouse */ - mousedown(x, y, asPointer) + mousedown(x: number, y: number, asPointer?: boolean) { this.interaction.onPointerDown(this.createEvent('mousedown', x, y, null, asPointer)); } @@ -228,7 +237,7 @@ class MockPointer * @param {boolean} [onCanvas=true] - if the event happened on the Canvas element or not * @param {boolean} [asPointer] - if it should be a PointerEvent from a mouse */ - mouseup(x, y, onCanvas = true, asPointer = false) + mouseup(x: number, y: number, onCanvas = true, asPointer = false) { this.interaction.onPointerUp(this.createEvent('mouseup', x, y, null, asPointer, onCanvas)); } @@ -239,7 +248,7 @@ class MockPointer * @param {number} [identifier] - pointer id * @param {boolean} [asPointer] - if it should be a PointerEvent from a touch */ - tap(x, y, identifier, asPointer) + tap(x: number, y: number, identifier?: undefined, asPointer?: undefined) { this.touchstart(x, y, identifier, asPointer); this.touchend(x, y, identifier, asPointer); @@ -251,7 +260,7 @@ class MockPointer * @param {number} [identifier] - pointer id * @param {boolean} [asPointer] - if it should be a PointerEvent from a touch */ - touchstart(x, y, identifier, asPointer) + touchstart(x: number, y: number, identifier?: number | boolean, asPointer?: boolean) { this.interaction.onPointerDown(this.createEvent('touchstart', x, y, identifier, asPointer)); } @@ -262,7 +271,7 @@ class MockPointer * @param {number} [identifier] - pointer id * @param {boolean} [asPointer] - if it should be a PointerEvent from a touch */ - touchmove(x, y, identifier, asPointer) + touchmove(x: number, y: number, identifier?: number | boolean, asPointer?: boolean) { this.interaction.onPointerMove(this.createEvent('touchmove', x, y, identifier, asPointer)); } @@ -273,7 +282,7 @@ class MockPointer * @param {number} [identifier] - pointer id * @param {boolean} [asPointer] - if it should be a PointerEvent from a touch */ - touchend(x, y, identifier, asPointer) + touchend(x: number, y: number, identifier?: number | boolean, asPointer?: boolean) { this.interaction.onPointerUp(this.createEvent('touchend', x, y, identifier, asPointer)); } @@ -284,7 +293,7 @@ class MockPointer * @param {number} [identifier] - pointer id * @param {boolean} [asPointer] - if it should be a PointerEvent from a touch */ - touchleave(x, y, identifier, asPointer) + touchleave(x: number, y: number, identifier?: number | boolean, asPointer?: boolean) { this.interaction.onPointerOut(this.createEvent('touchleave', x, y, identifier, asPointer)); } @@ -294,7 +303,7 @@ class MockPointer * @param {number} y - pointer y position * @param {number} [identifier] - pointer id */ - pendown(x, y, identifier) + pendown(x: number, y: number, identifier?: number) { this.interaction.onPointerDown(this.createEvent('pointerdown', x, y, identifier, true)); } @@ -304,7 +313,7 @@ class MockPointer * @param {number} y - pointer y position * @param {number} [identifier] - pointer id */ - penmove(x, y, identifier) + penmove(x: number, y: number, identifier?: number) { this.interaction.onPointerMove(this.createEvent('pointermove', x, y, identifier, true)); } @@ -314,7 +323,7 @@ class MockPointer * @param {number} y - pointer y position * @param {number} [identifier] - pointer id */ - penup(x, y, identifier) + penup(x: number, y: number, identifier?: number) { this.interaction.onPointerUp(this.createEvent('pointerup', x, y, identifier, true)); } diff --git a/packages/loaders/global.d.ts b/packages/loaders/global.d.ts index a72dfb0e4f..fdb725c333 100644 --- a/packages/loaders/global.d.ts +++ b/packages/loaders/global.d.ts @@ -3,9 +3,7 @@ declare namespace GlobalMixins // eslint-disable-next-line @typescript-eslint/no-empty-interface interface LoaderResource { - /** - * Texture reference for loading images and other textures. - */ + /** Texture reference for loading images and other textures. */ texture?: Texture; } // eslint-disable-next-line @typescript-eslint/no-empty-interface diff --git a/packages/loaders/package.json b/packages/loaders/package.json index 7df85ce9e7..f117ede212 100644 --- a/packages/loaders/package.json +++ b/packages/loaders/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/loaders", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/loaders.js", "module": "dist/esm/loaders.js", "bundle": "dist/browser/loaders.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/loaders.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/loaders.js" + } + } + }, "description": "Load assets and resources", "author": "Mat Groves", "contributors": [ @@ -25,8 +38,8 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/constants": "6.3.0", - "@pixi/core": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/constants": "6.4.2", + "@pixi/core": "6.4.2", + "@pixi/utils": "6.4.2" } } diff --git a/packages/loaders/src/AppLoaderPlugin.ts b/packages/loaders/src/AppLoaderPlugin.ts index 9353cbe58b..fb891c1c50 100644 --- a/packages/loaders/src/AppLoaderPlugin.ts +++ b/packages/loaders/src/AppLoaderPlugin.ts @@ -20,7 +20,7 @@ export class AppLoaderPlugin /** * Called on application constructor - * + * @param options * @private */ static init(options?: GlobalMixins.IApplicationOptions): void @@ -34,7 +34,6 @@ export class AppLoaderPlugin /** * Called when application destroyed - * * @private */ static destroy(): void diff --git a/packages/loaders/src/Loader.ts b/packages/loaders/src/Loader.ts index 1e80ed2d4b..bc49230d98 100644 --- a/packages/loaders/src/Loader.ts +++ b/packages/loaders/src/Loader.ts @@ -10,7 +10,8 @@ const rgxExtractUrlHash = /(#[\w-]+)?$/; export type ILoaderMiddleware = (resource: LoaderResource, next: (...args: any[]) => void) => void; -export interface ILoaderAdd { +export interface ILoaderAdd +{ (this: Loader, name: string, url: string, callback?: LoaderResource.OnCompleteSignal): Loader; (this: Loader, name: string, url: string, options?: IAddOptions, callback?: LoaderResource.OnCompleteSignal): Loader; (this: Loader, url: string, callback?: LoaderResource.OnCompleteSignal): Loader; @@ -21,24 +22,23 @@ export interface ILoaderAdd { /** * Options for a call to `.add()`. - * * @see Loader#add - * - * @property name - The name of the resource to load, if not passed the url is used. - * @property key - Alias for `name`. - * @property url - The url for this resource, relative to the baseUrl of this loader. - * @property crossOrigin - Is this request cross-origin? Default is to determine automatically. - * @property timeout=0 - A timeout in milliseconds for the load. If the load takes longer + * @property {string} name - The name of the resource to load, if not passed the url is used. + * @property {string} key - Alias for `name`. + * @property {string} url - The url for this resource, relative to the baseUrl of this loader. + * @property {string|boolean} crossOrigin - Is this request cross-origin? Default is to determine automatically. + * @property {number} [timeout=0] - A timeout in milliseconds for the load. If the load takes longer * than this time it is cancelled and the load is considered a failure. If this value is * set to `0` then there is no explicit timeout. - * @property loadType=LoaderResource.LOAD_TYPE.XHR - How should this resource be loaded? - * @property xhrType=LoaderResource.XHR_RESPONSE_TYPE.DEFAULT - How should the data being - * loaded be interpreted when using XHR? - * @property onComplete - Callback to add an an onComplete signal istener. - * @property callback - Alias for `onComplete`. - * @property metadata - Extra configuration for middleware and the Resource object. + * @property {LoaderResource.LOAD_TYPE} [loadType=LoaderResource.LOAD_TYPE.XHR] - How should this resource be loaded? + * @property {LoaderResource.XHR_RESPONSE_TYPE} [xhrType=LoaderResource.XHR_RESPONSE_TYPE.DEFAULT] - How should the data + * being loaded be interpreted when using XHR? + * @property {LoaderResource.OnCompleteSignal} onComplete - Callback to add an an onComplete signal istener. + * @property {LoaderResource.OnCompleteSignal} callback - Alias for `onComplete`. + * @property {IResourceMetadata} metadata - Extra configuration for middleware and the Resource object. */ -export interface IAddOptions { +export interface IAddOptions +{ name?: string; key?: string; url?: string; @@ -95,24 +95,17 @@ export interface IAddOptions { * loader.onLoad.add(() => {}); // called once per loaded file * loader.onComplete.add(() => {}); // called once when the queued resources all load. * ``` - * * @memberof PIXI */ class Loader { - /** - * The base url for all resources loaded by this loader. - */ + /** The base url for all resources loaded by this loader. */ baseUrl: string; - /** - * The progress percent of the loader going through the queue. - */ + /** The progress percent of the loader going through the queue. */ progress = 0; - /** - * Loading state of the loader, true if it is currently loading resources. - */ + /** Loading state of the loader, true if it is currently loading resources. */ loading = false; /** @@ -121,7 +114,6 @@ class Loader * This should be a valid query string *without* the question-mark (`?`). The loader will * also *not* escape values for you. Make sure to escape your parameters with * [`encodeURIComponent`](https://mdn.io/encodeURIComponent) before assigning this property. - * * @example * const loader = new Loader(); * @@ -137,62 +129,41 @@ class Loader */ defaultQueryString = ''; - /** - * The middleware to run before loading each resource. - */ + /** The middleware to run before loading each resource. */ private _beforeMiddleware: Array = []; - /** - * The middleware to run after loading each resource. - */ + /** The middleware to run after loading each resource. */ private _afterMiddleware: Array = []; - /** - * The tracks the resources we are currently completing parsing for. - */ + /** The tracks the resources we are currently completing parsing for. */ private _resourcesParsing: Array = []; /** * The `_loadResource` function bound with this object context. - * * @param r - The resource to load * @param d - The dequeue function */ private _boundLoadResource = (r: LoaderResource, d: () => void): void => this._loadResource(r, d); - /** - * The resources waiting to be loaded. - */ + /** The resources waiting to be loaded. */ private _queue: AsyncQueue; - /** - * All the resources for this loader keyed by name. - */ + /** All the resources for this loader keyed by name. */ resources: Dict = {}; - /** - * Dispatched once per loaded or errored resource. - */ + /** Dispatched once per loaded or errored resource. */ onProgress: Signal; - /** - * Dispatched once per errored resource. - */ + /** Dispatched once per errored resource. */ onError: Signal; - /** - * Dispatched once per loaded resource. - */ + /** Dispatched once per loaded resource. */ onLoad: Signal; - /** - * Dispatched when the loader begins to process the queue. - */ + /** Dispatched when the loader begins to process the queue. */ onStart: Signal; - /** - * Dispatched when the queued resources all load. - */ + /** Dispatched when the queued resources all load. */ onComplete: Signal; /** @@ -282,13 +253,12 @@ class Loader /** * Same as add, params have strict order - * * @private * @param name - The name of the resource to load. * @param url - The url for this resource, relative to the baseUrl of this loader. * @param options - The options for the load. * @param callback - Function to call when this specific resource completes loading. - * @return The loader itself. + * @returns The loader itself. */ protected _add(name: string, url: string, options: IAddOptions, callback?: LoaderResource.OnCompleteSignal): this { @@ -354,9 +324,8 @@ class Loader /** * Sets up a middleware function that will run *before* the * resource is loaded. - * * @param fn - The middleware function to register. - * @return The loader itself. + * @returns The loader itself. */ pre(fn: ILoaderMiddleware): this { @@ -368,9 +337,8 @@ class Loader /** * Sets up a middleware function that will run *after* the * resource is loaded. - * * @param fn - The middleware function to register. - * @return The loader itself. + * @returns The loader itself. */ use(fn: ILoaderMiddleware): this { @@ -381,8 +349,7 @@ class Loader /** * Resets the queue of the loader to prepare for a new load. - * - * @return The loader itself. + * @returns The loader itself. */ reset(): this { @@ -416,7 +383,7 @@ class Loader /** * Starts loading the queued resources. * @param cb - Optional callback that will be bound to the `complete` event. - * @return The loader itself. + * @returns The loader itself. */ load(cb?: Loader.OnCompleteSignal): this { @@ -460,7 +427,6 @@ class Loader /** * The number of resources to load concurrently. - * * @default 10 */ get concurrency(): number @@ -475,7 +441,7 @@ class Loader /** * Prepares a url for usage based on the configuration of this object * @param url - The url to prepare. - * @return The prepared url. + * @returns The prepared url. */ private _prepareUrl(url: string): string { @@ -524,7 +490,6 @@ class Loader /** * Loads a single resource. - * * @param resource - The resource to load. * @param dequeue - The function to call when we need to dequeue this item. */ @@ -560,9 +525,7 @@ class Loader ); } - /** - * Called once loading has started. - */ + /** Called once loading has started. */ private _onStart(): void { this.progress = 0; @@ -570,9 +533,7 @@ class Loader this.onStart.dispatch(this); } - /** - * Called once each resource has loaded. - */ + /** Called once each resource has loaded. */ private _onComplete(): void { this.progress = MAX_PROGRESS; @@ -635,9 +596,7 @@ class Loader */ private _protected: boolean; - /** - * Destroy the loader, removes references. - */ + /** Destroy the loader, removes references. */ public destroy(): void { if (!this._protected) @@ -646,9 +605,7 @@ class Loader } } - /** - * A premade instance of the loader that can be used to load resources. - */ + /** A premade instance of the loader that can be used to load resources. */ public static get shared(): Loader { let shared = Loader._shared; @@ -666,9 +623,8 @@ class Loader /** * Adds a Loader plugin for the global shared loader and all * new Loader instances created. - * * @param plugin - The plugin to add - * @return Reference to PIXI.Loader for chaining + * @returns Reference to PIXI.Loader for chaining */ public static registerPlugin(plugin: ILoaderPlugin): typeof Loader { @@ -766,30 +722,28 @@ export { Loader }; /** * Plugin to be installed for handling specific Loader resources. - * - * @property add - Function to call immediate after registering plugin. - * @property pre - Middleware function to run before load, the + * @property {Function} add - Function to call immediate after registering plugin. + * @property {Function} pre - Middleware function to run before load, the * arguments for this are `(resource, next)` - * @property use - Middleware function to run after load, the + * @property {Function} use - Middleware function to run after load, the * arguments for this are `(resource, next)` */ -export interface ILoaderPlugin { - /** - * Function to call immediate after registering plugin. - */ +export interface ILoaderPlugin +{ + /** Function to call immediate after registering plugin. */ add?(): void; /** * Middleware function to run before load - * @param resource - resource - * @param next - next middleware + * @param {LoaderResource} resource - resource + * @param {LoaderResource} next - next middleware */ pre?(resource: LoaderResource, next: (...args: any[]) => void): void; /** * Middleware function to run after load - * @param resource - resource - * @param next - next middleware + * @param {LoaderResource} resource - resource + * @param {LoaderResource} next - next middleware */ use?(resource: LoaderResource, next: (...args: any[]) => void): void; } diff --git a/packages/loaders/src/LoaderResource.ts b/packages/loaders/src/LoaderResource.ts index 42b050f71b..b1d64616c9 100644 --- a/packages/loaders/src/LoaderResource.ts +++ b/packages/loaders/src/LoaderResource.ts @@ -4,7 +4,7 @@ import { parseUri } from './base/parseUri'; import type { IBaseTextureOptions, Texture } from '@pixi/core'; // tests if CORS is supported in XHR, if not we need to use XDR -const useXdr = !!((globalThis as any).XDomainRequest && !('withCredentials' in (new XMLHttpRequest()))); +let useXdr: boolean; let tempAnchor: any = null; // some status constants @@ -20,7 +20,6 @@ function _noop(): void { /* empty */ } /** * Quick helper to set a value on one of the extension maps. Ensures there is no * dot at the start of the extension. - * * @ignore * @param map - The map to set on. * @param extname - The extension (or key) to set. @@ -43,10 +42,9 @@ function setExtMap(map: Dict, extname: string, val: number) /** * Quick helper to get string xhr type. - * * @ignore * @param xhr - The request to check. - * @return The type. + * @returns The type. */ function reqType(xhr: XMLHttpRequest) { @@ -57,14 +55,11 @@ function reqType(xhr: XMLHttpRequest) * Metadata for loader resource. It is very messy way to pass options for loader middlewares * * Can be extended in `GlobalMixins.IResourceMetadata` - * * @memberof PIXI */ export interface IResourceMetadata extends GlobalMixins.IResourceMetadata, IBaseTextureOptions { - /** - * The element to use for loading, instead of creating one. - */ + /** The element to use for loading, instead of creating one. */ loadElement?: HTMLImageElement | HTMLAudioElement | HTMLVideoElement; /** * Skips adding source(s) to the load element. This @@ -92,7 +87,6 @@ interface LoaderResource extends GlobalMixins.LoaderResource, GlobalMixins.ILoad * Manages the state and loading of a resource and all child resources. * * Can be extended in `GlobalMixins.LoaderResource`. - * * @memberof PIXI */ class LoaderResource @@ -103,57 +97,45 @@ class LoaderResource */ texture?: Texture; - /** - * used by parsing middleware - */ + /** used by parsing middleware */ blob?: Blob; /** * The name of this resource. - * * @readonly * @type {string} */ readonly name: string; /** * The url used to load this resource. - * * @readonly * @type {string} */ readonly url: string; /** * The extension used to load this resource. - * * @readonly * @type {string} */ readonly extension: string; - /** - * The data that was loaded by the resource. - */ + /** The data that was loaded by the resource. */ data: any; - /** - * Is this request cross-origin? If unset, determined automatically. - */ + /** Is this request cross-origin? If unset, determined automatically. */ crossOrigin: string | boolean; /** * A timeout in milliseconds for the load. If the load takes longer than this time * it is cancelled and the load is considered a failure. If this value is set to `0` * then there is no explicit timeout. - * * @type {number} */ timeout: number; /** * The method of loading to use for this resource. - * * @type {PIXI.LoaderResource.LOAD_TYPE} */ loadType: LoaderResource.LOAD_TYPE; /** * The type used to load the resource via XHR. If unset, determined automatically. - * * @member {string} */ xhrType: string; @@ -163,13 +145,11 @@ class LoaderResource * * Note that if you pass in a `loadElement`, the Resource class takes ownership of it. * Meaning it will modify it as it sees fit. - * * @type {PIXI.IResourceMetadata} */ metadata: IResourceMetadata; /** * The error that occurred while loading (if any). - * * @readonly * @member {Error} */ @@ -177,7 +157,6 @@ class LoaderResource /** * The XHR object that was used to load this resource. This is only set * when `loadType` is `LoaderResource.LOAD_TYPE.XHR`. - * * @readonly */ xhr: XMLHttpRequest; @@ -185,20 +164,17 @@ class LoaderResource private xdr: any; /** * The child resources this resource owns. - * * @type {PIXI.LoaderResource[]} */ readonly children: LoaderResource[]; /** * The resource type. - * * @readonly * @type {PIXI.LoaderResource.TYPE} */ type: LoaderResource.TYPE; /** * The progress chunk owned by this resource. - * * @readonly * @member {number} */ @@ -207,7 +183,6 @@ class LoaderResource * Dispatched when the resource beings to load. * * The callback looks like {@link LoaderResource.OnStartSignal}. - * * @type {PIXI.Signal} */ onStart: Signal; @@ -219,7 +194,6 @@ class LoaderResource * properly sets Content-Length headers, then this will be available. * * The callback looks like {@link LoaderResource.OnProgressSignal}. - * * @type {PIXI.Signal} */ onProgress: Signal; @@ -228,7 +202,6 @@ class LoaderResource * be in the `error` property. * * The callback looks like {@link LoaderResource.OnCompleteSignal}. - * * @type {PIXI.Signal} */ onComplete: Signal; @@ -236,14 +209,12 @@ class LoaderResource * Dispatched after this resource has had all the *after* middleware run on it. * * The callback looks like {@link LoaderResource.OnCompleteSignal}. - * * @type {PIXI.Signal} */ onAfterMiddleware: Signal; /** * The state flags of this resource. - * * @private * @member {number} */ @@ -252,56 +223,49 @@ class LoaderResource /** * The `dequeue` method that will be used a storage place for the async queue dequeue method * used privately by the loader. - * * @private - * @member {function} + * @member {Function} */ _dequeue: any = _noop; /** * Used a storage place for the on load binding used privately by the loader. - * * @private - * @member {function} + * @member {Function} */ _onLoadBinding: any = null; /** * The timer for element loads to check if they timeout. - * * @private */ private _elementTimer = 0; /** * The `complete` function bound to this resource's context. - * * @private - * @type {function} + * @type {Function} */ private _boundComplete: any = null; /** * The `_onError` function bound to this resource's context. - * * @private - * @type {function} + * @type {Function} */ private _boundOnError: any = null; /** * The `_onProgress` function bound to this resource's context. - * * @private - * @type {function} + * @type {Function} */ private _boundOnProgress: any = null; /** * The `_onTimeout` function bound to this resource's context. - * * @private - * @type {function} + * @type {Function} */ private _boundOnTimeout: any = null; @@ -312,7 +276,6 @@ class LoaderResource /** * Sets the load type to be used for a specific extension. - * * @static * @param {string} extname - The extension to set the type for, e.g. "png" or "fnt" * @param {PIXI.LoaderResource.LOAD_TYPE} loadType - The load type to set it to. @@ -323,7 +286,6 @@ class LoaderResource } /** * Sets the load type to be used for a specific extension. - * * @static * @param {string} extname - The extension to set the type for, e.g. "png" or "fnt" * @param {PIXI.LoaderResource.XHR_RESPONSE_TYPE} xhrType - The xhr type to set it to. @@ -449,27 +411,24 @@ class LoaderResource /** * When the resource starts to load. - * * @memberof PIXI.LoaderResource * @callback OnStartSignal - * @param {Resource} resource - The resource that the event happened on. + * @param {PIXI.Resource} resource - The resource that the event happened on. */ /** * When the resource reports loading progress. - * * @memberof PIXI.LoaderResource * @callback OnProgressSignal - * @param {Resource} resource - The resource that the event happened on. + * @param {PIXI.Resource} resource - The resource that the event happened on. * @param {number} percentage - The progress of the load in the range [0, 1]. */ /** * When the resource finishes loading. - * * @memberof PIXI.LoaderResource * @callback OnCompleteSignal - * @param {Resource} resource - The resource that the event happened on. + * @param {PIXI.Resource} resource - The resource that the event happened on. */ /** @@ -486,7 +445,6 @@ class LoaderResource /** * Stores whether or not this url is a data url. - * * @readonly * @member {boolean} */ @@ -498,7 +456,6 @@ class LoaderResource /** * Describes if this resource has finished loading. Is true when the resource has completely * loaded. - * * @readonly * @member {boolean} */ @@ -510,7 +467,6 @@ class LoaderResource /** * Describes if this resource is currently loading. Is true when the resource starts loading, * and is false again when complete. - * * @readonly * @member {boolean} */ @@ -519,10 +475,7 @@ class LoaderResource return this._hasFlag(LoaderResource.STATUS_FLAGS.LOADING); } - /** - * Marks the resource as complete. - * - */ + /** Marks the resource as complete. */ complete(): void { this._clearEvents(); @@ -531,7 +484,6 @@ class LoaderResource /** * Aborts the loading of this resource, with an optional message. - * * @param {string} message - The message to use for the error */ abort(message: string): void @@ -580,7 +532,6 @@ class LoaderResource /** * Kicks off loading of this resource. This method is asynchronous. - * * @param {PIXI.LoaderResource.OnCompleteSignal} [cb] - Optional callback to call once the resource is loaded. */ load(cb?: LoaderResource.OnCompleteSignal): void @@ -634,6 +585,10 @@ class LoaderResource case LoaderResource.LOAD_TYPE.XHR: /* falls through */ default: + if (typeof useXdr === 'undefined') + { + useXdr = !!((globalThis as any).XDomainRequest && !('withCredentials' in (new XMLHttpRequest()))); + } if (useXdr && this.crossOrigin) { this._loadXdr(); @@ -648,9 +603,8 @@ class LoaderResource /** * Checks if the flag is set. - * * @param flag - The flag to check. - * @return True if the flag is set. + * @returns True if the flag is set. */ private _hasFlag(flag: number): boolean { @@ -659,7 +613,6 @@ class LoaderResource /** * (Un)Sets the flag. - * * @param flag - The flag to (un)set. * @param value - Whether to set or (un)set the flag. */ @@ -668,9 +621,7 @@ class LoaderResource this._flags = value ? (this._flags | flag) : (this._flags & ~flag); } - /** - * Clears all the events from the underlying loading source. - */ + /** Clears all the events from the underlying loading source. */ private _clearEvents(): void { clearTimeout(this._elementTimer); @@ -703,9 +654,7 @@ class LoaderResource } } - /** - * Finalizes the load. - */ + /** Finalizes the load. */ private _finish(): void { if (this.isComplete) @@ -833,9 +782,7 @@ class LoaderResource } } - /** - * Loads this resources using an XMLHttpRequest. - */ + /** Loads this resources using an XMLHttpRequest. */ private _loadXhr(): void { // if unset, determine the value @@ -878,9 +825,7 @@ class LoaderResource xhr.send(); } - /** - * Loads this resources using an XDomainRequest. This is here because we need to support IE9 (gross). - */ + /** Loads this resources using an XDomainRequest. This is here because we need to support IE9 (gross). */ private _loadXdr(): void { // if unset, determine the value @@ -915,7 +860,7 @@ class LoaderResource * @param type - The element type (video or audio). * @param url - The source URL to load from. * @param [mime] - The mime type of the video - * @return The source element. + * @returns The source element. */ private _createSource(type: string, url: string, mime: string): HTMLSourceElement { @@ -934,7 +879,6 @@ class LoaderResource /** * Called if a load errors out. - * * @param event - The error event from the element that emits it. */ private _onError(event: Event): void @@ -954,17 +898,13 @@ class LoaderResource } } - /** - * Called if a timeout event fires for an element. - */ + /** Called if a timeout event fires for an element. */ private _onTimeout(): void { this.abort(`Load timed out.`); } - /** - * Called if an error event fires for xhr/xdr. - */ + /** Called if an error event fires for xhr/xdr. */ private _xhrOnError(): void { const xhr = this.xhr; @@ -972,9 +912,7 @@ class LoaderResource this.abort(`${reqType(xhr)} Request failed. Status: ${xhr.status}, text: "${xhr.statusText}"`); } - /** - * Called if an error event fires for xhr/xdr. - */ + /** Called if an error event fires for xhr/xdr. */ private _xhrOnTimeout(): void { const xhr = this.xhr; @@ -982,9 +920,7 @@ class LoaderResource this.abort(`${reqType(xhr)} Request timed out.`); } - /** - * Called if an abort event fires for xhr/xdr. - */ + /** Called if an abort event fires for xhr/xdr. */ private _xhrOnAbort(): void { const xhr = this.xhr; @@ -992,9 +928,7 @@ class LoaderResource this.abort(`${reqType(xhr)} Request was aborted by the user.`); } - /** - * Called when data successfully loads from an xhr/xdr request. - */ + /** Called when data successfully loads from an xhr/xdr request. */ private _xhrOnLoad(): void { const xhr = this.xhr; @@ -1096,7 +1030,7 @@ class LoaderResource * @private * @param url - The url to test. * @param [loc=globalThis.location] - The location object to test against. - * @return The crossOrigin value to use (or empty string for none). + * @returns The crossOrigin value to use (or empty string for none). */ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types _determineCrossOrigin(url: string, loc?: any): string @@ -1144,9 +1078,8 @@ class LoaderResource /** * Determines the responseType of an XHR request based on the extension of the * resource being loaded. - * * @private - * @return {PIXI.LoaderResource.XHR_RESPONSE_TYPE} The responseType to use. + * @returns {PIXI.LoaderResource.XHR_RESPONSE_TYPE} The responseType to use. */ private _determineXhrType(): LoaderResource.XHR_RESPONSE_TYPE { @@ -1156,9 +1089,8 @@ class LoaderResource /** * Determines the loadType of a resource based on the extension of the * resource being loaded. - * * @private - * @return {PIXI.LoaderResource.LOAD_TYPE} The loadType to use. + * @returns {PIXI.LoaderResource.LOAD_TYPE} The loadType to use. */ private _determineLoadType(): LoaderResource.LOAD_TYPE { @@ -1167,9 +1099,8 @@ class LoaderResource /** * Extracts the extension (sans '.') of the file being loaded by the resource. - * * @param [url] - url to parse, `this.url` by default. - * @return The extension. + * @returns The extension. */ private _getExtension(url = this.url): string { @@ -1200,10 +1131,9 @@ class LoaderResource /** * Determines the mime type of an XHR request based on the responseType of * resource being loaded. - * * @param type - The type to get a mime type for. * @private - * @return The mime type to use. + * @returns The mime type to use. */ _getMimeFromXhrType(type: LoaderResource.XHR_RESPONSE_TYPE): string { @@ -1231,86 +1161,87 @@ class LoaderResource } // eslint-disable-next-line @typescript-eslint/no-namespace -namespace LoaderResource { +namespace LoaderResource +{ /** * When the resource starts to load. - * * @memberof PIXI.LoaderResource * @callback OnStartSignal - * @param {Resource} resource - The resource that the event happened on. + * @param {PIXI.Resource} resource - The resource that the event happened on. */ export type OnStartSignal = (resource: LoaderResource) => void; /** * When the resource reports loading progress. - * * @memberof PIXI.LoaderResource * @callback OnProgressSignal - * @param {Resource} resource - The resource that the event happened on. + * @param {PIXI.Resource} resource - The resource that the event happened on. * @param {number} percentage - The progress of the load in the range [0, 1]. */ export type OnProgressSignal = (resource: LoaderResource, percentage: number) => void; /** * When the resource finishes loading. - * * @memberof PIXI.LoaderResource * @callback OnCompleteSignal - * @param {Resource} resource - The resource that the event happened on. + * @param {PIXI.Resource} resource - The resource that the event happened on. */ export type OnCompleteSignal = (resource: LoaderResource) => void; /** * The types of resources a resource could represent. - * * @static * @readonly * @enum {number} * @memberof PIXI.LoaderResource */ - export enum STATUS_FLAGS { + export enum STATUS_FLAGS + // eslint-disable-next-line @typescript-eslint/indent + { /** None */ - NONE= 0, + NONE = 0, /** Data URL */ - DATA_URL= (1 << 0), + DATA_URL = (1 << 0), /** Complete */ - COMPLETE= (1 << 1), + COMPLETE = (1 << 1), /** Loading */ - LOADING= (1 << 2), + LOADING = (1 << 2), } /** * The types of resources a resource could represent. - * * @static * @readonly * @enum {number} * @memberof PIXI.LoaderResource */ - export enum TYPE { + export enum TYPE + // eslint-disable-next-line @typescript-eslint/indent + { /** Unknown */ - UNKNOWN= 0, + UNKNOWN = 0, /** JSON */ - JSON= 1, + JSON = 1, /** XML */ - XML= 2, + XML = 2, /** Image */ - IMAGE= 3, + IMAGE = 3, /** Audio */ - AUDIO= 4, + AUDIO = 4, /** Video */ - VIDEO= 5, + VIDEO = 5, /** Plain text */ - TEXT= 6, + TEXT = 6, } /** * The types of loading a resource can use. - * * @static * @readonly * @enum {number} * @memberof PIXI.LoaderResource */ - export enum LOAD_TYPE { + export enum LOAD_TYPE + // eslint-disable-next-line @typescript-eslint/indent + { /** Uses XMLHttpRequest to load the resource. */ XHR = 1, /** Uses an `Image` object to load the resource. */ @@ -1323,13 +1254,14 @@ namespace LoaderResource { /** * The XHR ready states, used internally. - * * @static * @readonly * @enum {string} * @memberof PIXI.LoaderResource */ - export enum XHR_RESPONSE_TYPE { + export enum XHR_RESPONSE_TYPE + // eslint-disable-next-line @typescript-eslint/indent + { /** string */ DEFAULT = 'text', /** ArrayBuffer */ diff --git a/packages/loaders/src/TextureLoader.ts b/packages/loaders/src/TextureLoader.ts index 4c4f9b0901..ff5c621e89 100644 --- a/packages/loaders/src/TextureLoader.ts +++ b/packages/loaders/src/TextureLoader.ts @@ -3,14 +3,11 @@ import { LoaderResource } from './LoaderResource'; /** * Loader plugin for handling Texture resources. - * * @memberof PIXI */ export class TextureLoader { - /** - * Handle SVG elements a text, render with SVGResource. - */ + /** Handle SVG elements a text, render with SVGResource. */ public static add(): void { LoaderResource.setExtensionLoadType('svg', LoaderResource.LOAD_TYPE.XHR); @@ -21,7 +18,7 @@ export class TextureLoader * Called after a resource is loaded. * @see PIXI.Loader.loaderMiddleware * @param resource - * @param {function} next + * @param {Function} next */ public static use(resource: LoaderResource, next: (...args: any[]) => void): void { diff --git a/packages/loaders/src/base/AsyncQueue.ts b/packages/loaders/src/base/AsyncQueue.ts index 5a5c582abb..f691c4b3ce 100644 --- a/packages/loaders/src/base/AsyncQueue.ts +++ b/packages/loaders/src/base/AsyncQueue.ts @@ -9,8 +9,8 @@ function _noop(): void /** * Ensures a function is only called once. * @ignore - * @param {function} fn - The function to wrap. - * @return {function} The wrapping function. + * @param {Function} fn - The function to wrap. + * @returns {Function} The wrapping function. */ function onlyOnce(fn: () => void): () => void { @@ -29,7 +29,8 @@ function onlyOnce(fn: () => void): () => void } // eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface IQueue { +export interface IQueue +{ } @@ -43,6 +44,8 @@ export class AsyncQueueItem callback: (...args: any[]) => void; /** + * @param data + * @param callback * @private */ constructor(data: TaskData, callback: (...args: any[]) => void) @@ -76,6 +79,8 @@ export class AsyncQueue _tasks: Array> = []; /** + * @param worker + * @param concurrency * @private */ constructor(worker: (x: TaskData, next: () => void) => void, concurrency = 1) @@ -149,6 +154,7 @@ export class AsyncQueue }; /** + * @param task * @private */ _next(task: AsyncQueueItem): (...args: any) => void @@ -245,10 +251,9 @@ export class AsyncQueue /** * Iterates an array in series. - * * @param {Array.<*>} array - Array to iterate. - * @param {function} iterator - Function to call for each element. - * @param {function} callback - Function to call when done, or on error. + * @param {Function} iterator - Function to call for each element. + * @param {Function} callback - Function to call when done, or on error. * @param {boolean} [deferNext=false] - Break synchronous each loop by calling next with a setTimeout of 1. */ static eachSeries(array: Array, iterator: (x: any, next: (err?: any) => void) => void, @@ -287,10 +292,9 @@ export class AsyncQueue /** * Async queue implementation, - * - * @param {function} worker - The worker function to call for each task. + * @param {Function} worker - The worker function to call for each task. * @param {number} concurrency - How many workers to run in parrallel. - * @return {*} The async queue object. + * @returns {*} The async queue object. */ static queue(worker: (x: any, next: (...args: any) => void) => void, concurrency?: number): AsyncQueue { diff --git a/packages/loaders/src/base/Signal.ts b/packages/loaders/src/base/Signal.ts index 4078ee5830..eab49cd408 100644 --- a/packages/loaders/src/base/Signal.ts +++ b/packages/loaders/src/base/Signal.ts @@ -16,7 +16,7 @@ export class SignalBinding * SignalBinding constructor. * @constructs SignalBinding * @param {Function} fn - Event handler to be called. - * @param {Boolean} [once=false] - Should this listener be removed after dispatch + * @param {boolean} [once=false] - Should this listener be removed after dispatch * @param {object} [thisArg] - The context of the callback function. * @api private */ @@ -39,6 +39,8 @@ export class SignalBinding } /** + * @param self + * @param node * @private */ function _addSignalBinding(self: Signal, node: SignalBinding) @@ -83,9 +85,8 @@ export class Signal void> /** * Return an array of attached SignalBinding. - * - * @param {Boolean} [exists=false] - We only need to know if there are handlers. - * @returns {PIXI.SignalBinding[]|Boolean} Array of attached SignalBinding or Boolean if called with exists = true + * @param {boolean} [exists=false] - We only need to know if there are handlers. + * @returns {PIXI.SignalBinding[] | boolean} Array of attached SignalBinding or Boolean if called with exists = true * @api public */ handlers(exists = false): Array> | boolean @@ -107,9 +108,8 @@ export class Signal void> /** * Return true if node is a SignalBinding attached to this MiniSignal - * * @param {PIXI.SignalBinding} node - Node to check. - * @returns {Boolean} True if node is attache to mini-signal + * @returns {boolean} True if node is attache to mini-signal */ has(node: SignalBinding): boolean { @@ -123,8 +123,8 @@ export class Signal void> /** * Dispaches a signal to all registered listeners. - * - * @returns {Boolean} Indication if we've emitted an event. + * @param {...any} args + * @returns {boolean} Indication if we've emitted an event. */ dispatch(...args: any[]): boolean { @@ -144,7 +144,6 @@ export class Signal void> /** * Register a new listener. - * * @param {Function} fn - Callback function. * @param {object} [thisArg] - The context of the callback function. * @returns {PIXI.SignalBinding} The SignalBinding node that was added. @@ -161,7 +160,6 @@ export class Signal void> /** * Register a new listener that will be executed only once. - * * @param {Function} fn - Callback function. * @param {object} [thisArg] - The context of the callback function. * @returns {PIXI.SignalBinding} The SignalBinding node that was added. @@ -178,10 +176,9 @@ export class Signal void> /** * Remove binding object. - * * @param {PIXI.SignalBinding} node - The binding node that will be removed. * @returns {Signal} The instance on which this method was called. - * @api public */ + @api public */ detach(node: SignalBinding): this { if (!(node instanceof SignalBinding)) @@ -214,7 +211,6 @@ export class Signal void> /** * Detach all listeners. - * * @returns {Signal} The instance on which this method was called. */ detachAll(): this diff --git a/packages/loaders/src/base/encodeBinary.ts b/packages/loaders/src/base/encodeBinary.ts index 82d43c7f19..8270088fba 100644 --- a/packages/loaders/src/base/encodeBinary.ts +++ b/packages/loaders/src/base/encodeBinary.ts @@ -2,7 +2,6 @@ const _keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+ /** * Encodes binary into base64. - * * @function encodeBinary * @param {string} input - The input data to encode. * @returns {string} The encoded base64 string diff --git a/packages/loaders/src/middleware/caching.ts b/packages/loaders/src/middleware/caching.ts index 22046889d4..106f05426b 100644 --- a/packages/loaders/src/middleware/caching.ts +++ b/packages/loaders/src/middleware/caching.ts @@ -6,7 +6,6 @@ const cache: Dict = {}; /** * A simple in-memory cache for resource. - * * @ignore * @function caching * @example diff --git a/packages/loaders/src/middleware/parsing.ts b/packages/loaders/src/middleware/parsing.ts index 896282751d..79c4e09013 100644 --- a/packages/loaders/src/middleware/parsing.ts +++ b/packages/loaders/src/middleware/parsing.ts @@ -1,11 +1,8 @@ import { LoaderResource } from '../LoaderResource'; import { encodeBinary } from '../base/encodeBinary'; -const Url = self.URL || self.webkitURL; - /** * A middleware for transforming XHR loaded Blobs into more useful objects - * * @ignore * @function parsing * @example @@ -55,6 +52,7 @@ export function parsing(resource: LoaderResource, next: (...args: any) => void): // if content type says this is an image, then we should transform the blob into an Image object else if (resource.data.type.indexOf('image') === 0) { + const Url = globalThis.URL || globalThis.webkitURL; const src = Url.createObjectURL(resource.data); resource.blob = resource.data; diff --git a/packages/loaders/test/AppLoaderPlugin.tests.ts b/packages/loaders/test/AppLoaderPlugin.tests.ts index fb691a83bd..f8440af539 100644 --- a/packages/loaders/test/AppLoaderPlugin.tests.ts +++ b/packages/loaders/test/AppLoaderPlugin.tests.ts @@ -1,11 +1,11 @@ import { AppLoaderPlugin, Loader } from '@pixi/loaders'; import { expect } from 'chai'; -describe('AppLoaderPlugin', function () +describe('AppLoaderPlugin', () => { - it('should contain loader property', function () + it('should contain loader property', () => { - const obj = {}; + const obj = {} as any; AppLoaderPlugin.init.call(obj); @@ -17,9 +17,9 @@ describe('AppLoaderPlugin', function () expect(obj.loader).to.be.null; }); - it('should use sharedLoader option', function () + it('should use sharedLoader option', () => { - const obj = {}; + const obj = {} as any; AppLoaderPlugin.init.call(obj, { sharedLoader: true }); diff --git a/packages/loaders/test/AsyncQueue.tests.ts b/packages/loaders/test/AsyncQueue.tests.ts index eb14fdcfbe..1be0e50565 100644 --- a/packages/loaders/test/AsyncQueue.tests.ts +++ b/packages/loaders/test/AsyncQueue.tests.ts @@ -296,6 +296,7 @@ describe('async', () => expect(() => { + // @ts-expect-error - testing for error q.push({}, 1); }).to.throw(); done(); @@ -660,13 +661,13 @@ describe('async', () => ]); done(); }; - q.push(); + q.push(undefined); }); it('saturated', (done: () => void) => { let saturatedCalled = false; - const q = async.queue((task, cb) => + const q = async.queue((_task, cb) => { setTimeout(cb, 1); }, 2); @@ -855,7 +856,7 @@ describe('async', () => it('empty array', (done: () => void) => { - async.eachSeries([], (x: number, callback: () => void) => + async.eachSeries([], (_x: number, callback: () => void) => { expect(false).to.equal(true, 'iteratee should not be called'); callback(); @@ -875,7 +876,7 @@ describe('async', () => { const arr = [1, 2, 3, 4]; - async.eachSeries(arr, (x, callback) => + async.eachSeries(arr, (_x, callback) => { setTimeout(callback, 1); }, () => @@ -896,7 +897,7 @@ describe('async', () => async.eachSeries( [1], - (i, cb) => + (_i, cb) => { cb(null); }, @@ -916,7 +917,7 @@ describe('async', () => async.eachSeries( [1], - (i, cb) => + (_i, cb) => { cb(null); }, diff --git a/packages/loaders/test/Loader.tests.ts b/packages/loaders/test/Loader.tests.ts index ec09541c63..7cfcfa7f99 100644 --- a/packages/loaders/test/Loader.tests.ts +++ b/packages/loaders/test/Loader.tests.ts @@ -5,40 +5,44 @@ import { SCALE_MODES } from '@pixi/constants'; import { createServer } from './resources'; import { expect } from 'chai'; +import { Server } from 'http'; const createRandomName = () => `image${(Math.random() * 10000) | 0}`; -describe('Loader', function () +describe('Loader', () => { - before(function () + let server: Server; + let baseUrl: string; + + before(() => { - this.server = createServer(8125); - this.baseUrl = 'http://localhost:8125'; + server = createServer(8125); + baseUrl = 'http://localhost:8125'; }); - after(function () + after(() => { - this.server.close(); - this.server = null; - this.baseUrl = null; + server.close(); + server = null; + baseUrl = null; }); - it('should exist', function () + it('should exist', () => { expect(Loader).to.be.a('function'); }); - it('should have shared loader', function () + it('should have shared loader', () => { expect(Loader.shared).to.not.be.undefined; expect(Loader.shared).to.be.instanceof(Loader); }); - it('should basic load an image using the TextureLoader', function (done) + it('should basic load an image using the TextureLoader', (done) => { const loader = new Loader(); const name = createRandomName(); - const url = `${this.baseUrl}/bunny.png`; + const url = `${baseUrl}/bunny.png`; loader.add(name, url); loader.load((ldr, resources) => @@ -46,7 +50,7 @@ describe('Loader', function () expect(ldr).equals(loader); expect(name in resources).to.be.ok; - const { texture } = resources[name]; + const texture = resources[name].texture as Texture; expect(texture).instanceof(Texture); expect(texture.baseTexture.valid).to.be.true; @@ -63,11 +67,11 @@ describe('Loader', function () }); }); - it('should basic load an SVG using the TextureLoader', function (done) + it('should basic load an SVG using the TextureLoader', (done) => { const loader = new Loader(); const name = createRandomName(); - const url = `${this.baseUrl}/logo.svg`; + const url = `${baseUrl}/logo.svg`; loader.add(name, url); loader.load(() => @@ -86,7 +90,7 @@ describe('Loader', function () }); }); - it('should allow setting baseTexture properties through metadata', function (done) + it('should allow setting baseTexture properties through metadata', (done) => { const loader = new Loader(); const name = createRandomName(); @@ -97,7 +101,7 @@ describe('Loader', function () }, }; - loader.add(name, `${this.baseUrl}/bunny.png`, options).load(() => + loader.add(name, `${baseUrl}/bunny.png`, options).load(() => { const { texture } = loader.resources[name]; const { scaleMode, resolution } = texture.baseTexture; @@ -110,7 +114,7 @@ describe('Loader', function () }); }); - it('should allow setting SVG width/height through metadata', function (done) + it('should allow setting SVG width/height through metadata', (done) => { const loader = new Loader(); const name = createRandomName(); @@ -123,7 +127,7 @@ describe('Loader', function () }, }; - loader.add(name, `${this.baseUrl}/logo.svg`, options).load(() => + loader.add(name, `${baseUrl}/logo.svg`, options).load(() => { const { texture } = loader.resources[name]; const { width, height } = texture.baseTexture; @@ -136,7 +140,7 @@ describe('Loader', function () }); }); - it('should allow setting SVG scale through metadata', function (done) + it('should allow setting SVG scale through metadata', (done) => { const loader = new Loader(); const name = createRandomName(); @@ -148,7 +152,7 @@ describe('Loader', function () }, }; - loader.add(name, `${this.baseUrl}/logo.svg`, options).load(() => + loader.add(name, `${baseUrl}/logo.svg`, options).load(() => { const { texture } = loader.resources[name]; const { width, height } = texture.baseTexture; diff --git a/packages/loaders/test/LoaderBase.tests.ts b/packages/loaders/test/LoaderBase.tests.ts index 7b4be5db49..c0a6db88bb 100644 --- a/packages/loaders/test/LoaderBase.tests.ts +++ b/packages/loaders/test/LoaderBase.tests.ts @@ -6,20 +6,21 @@ import { fixtureData } from './fixtures/data'; import { spritesheetMiddleware } from './fixtures/spritesheet'; import { Dict } from '@pixi/utils/src'; import { createServer } from './resources'; +import { Server } from 'http'; describe('Loader', () => { - before(function () + let server: Server; + + before(() => { - this.server = createServer(8126); - this.baseUrl = 'http://localhost:8126'; + server = createServer(8126); }); - after(function () + after(() => { - this.server.close(); - this.server = null; - this.baseUrl = null; + server.close(); + server = null; }); let loader: Loader = null; @@ -27,8 +28,8 @@ describe('Loader', () => beforeEach(() => { loader = new Loader(fixtureData.baseUrl); - loader._beforeMiddleware = []; - loader._afterMiddleware = []; + loader['_beforeMiddleware'] = []; + loader['_afterMiddleware'] = []; }); it('should have correct properties', () => @@ -61,9 +62,9 @@ describe('Loader', () => { loader.add(name, fixtureData.url, options, callback); - expect(loader._queue.length()).to.equal(1); + expect(loader['_queue'].length()).to.equal(1); - const res = loader._queue._tasks[0].data; + const res = loader['_queue']._tasks[0].data; expect(res).to.be.an.instanceOf(LoaderResource); expect(res).to.have.property('name', name); @@ -81,9 +82,9 @@ describe('Loader', () => { loader.add(name, fixtureData.url, options); - expect(loader._queue.length()).to.equal(1); + expect(loader['_queue'].length()).to.equal(1); - const res = loader._queue._tasks[0].data; + const res = loader['_queue']._tasks[0].data; expect(res).to.be.an.instanceOf(LoaderResource); expect(res).to.have.property('name', name); @@ -97,9 +98,9 @@ describe('Loader', () => { loader.add(name, fixtureData.url, callback); - expect(loader._queue.length()).to.equal(1); + expect(loader['_queue'].length()).to.equal(1); - const res = loader._queue._tasks[0].data; + const res = loader['_queue']._tasks[0].data; expect(res).to.be.an.instanceOf(LoaderResource); expect(res).to.have.property('name', name); @@ -114,9 +115,9 @@ describe('Loader', () => { loader.add(name, fixtureData.url); - expect(loader._queue.length()).to.equal(1); + expect(loader['_queue'].length()).to.equal(1); - const res = loader._queue._tasks[0].data; + const res = loader['_queue']._tasks[0].data; expect(res).to.be.an.instanceOf(LoaderResource); expect(res).to.have.property('name', name); @@ -127,9 +128,9 @@ describe('Loader', () => { loader.add(fixtureData.url, options, callback); - expect(loader._queue.length()).to.equal(1); + expect(loader['_queue'].length()).to.equal(1); - const res = loader._queue._tasks[0].data; + const res = loader['_queue']._tasks[0].data; expect(res).to.be.an.instanceOf(LoaderResource); expect(res).to.have.property('name', fixtureData.url); @@ -147,9 +148,9 @@ describe('Loader', () => { loader.add(fixtureData.url, options); - expect(loader._queue.length()).to.equal(1); + expect(loader['_queue'].length()).to.equal(1); - const res = loader._queue._tasks[0].data; + const res = loader['_queue']._tasks[0].data; expect(res).to.be.an.instanceOf(LoaderResource); expect(res).to.have.property('name', fixtureData.url); @@ -163,9 +164,9 @@ describe('Loader', () => { loader.add(fixtureData.url, callback); - expect(loader._queue.length()).to.equal(1); + expect(loader['_queue'].length()).to.equal(1); - const res = loader._queue._tasks[0].data; + const res = loader['_queue']._tasks[0].data; expect(res).to.be.an.instanceOf(LoaderResource); expect(res).to.have.property('name', fixtureData.url); @@ -180,9 +181,9 @@ describe('Loader', () => { loader.add(fixtureData.url); - expect(loader._queue.length()).to.equal(1); + expect(loader['_queue'].length()).to.equal(1); - const res = loader._queue._tasks[0].data; + const res = loader['_queue']._tasks[0].data; expect(res).to.be.an.instanceOf(LoaderResource); expect(res).to.have.property('name', fixtureData.url); @@ -193,9 +194,9 @@ describe('Loader', () => { loader.add({ name, url: fixtureData.url }, callback); - expect(loader._queue.length()).to.equal(1); + expect(loader['_queue'].length()).to.equal(1); - const res = loader._queue._tasks[0].data; + const res = loader['_queue']._tasks[0].data; expect(res).to.be.an.instanceOf(LoaderResource); expect(res).to.have.property('name', name); @@ -210,9 +211,9 @@ describe('Loader', () => { loader.add({ name, url: fixtureData.url, onComplete: callback }); - expect(loader._queue.length()).to.equal(1); + expect(loader['_queue'].length()).to.equal(1); - const res = loader._queue._tasks[0].data; + const res = loader['_queue']._tasks[0].data; expect(res).to.be.an.instanceOf(LoaderResource); expect(res).to.have.property('name', name); @@ -227,9 +228,9 @@ describe('Loader', () => { loader.add({ url: fixtureData.url, onComplete: callback }); - expect(loader._queue.length()).to.equal(1); + expect(loader['_queue'].length()).to.equal(1); - const res = loader._queue._tasks[0].data; + const res = loader['_queue']._tasks[0].data; expect(res).to.be.an.instanceOf(LoaderResource); expect(res).to.have.property('name', fixtureData.url); @@ -264,7 +265,7 @@ describe('Loader', () => { loader.pre(() => { /* empty */ }); - expect(loader._beforeMiddleware).to.have.length(1); + expect(loader['_beforeMiddleware']).to.have.length(1); }); }); @@ -274,7 +275,7 @@ describe('Loader', () => { loader.use(() => { /* empty */ }); - expect(loader._afterMiddleware).to.have.length(1); + expect(loader['_afterMiddleware']).to.have.length(1); }); }); @@ -300,13 +301,13 @@ describe('Loader', () => it('should reset the queue/buffer of the loader', () => { - loader._queue.push('me'); - expect(loader._queue.length()).to.equal(1); - expect(loader._queue.started).to.equal(true); + loader['_queue'].push('me'); + expect(loader['_queue'].length()).to.equal(1); + expect(loader['_queue'].started).to.equal(true); loader.reset(); - expect(loader._queue.length()).to.equal(0); - expect(loader._queue.started).to.equal(false); + expect(loader['_queue'].length()).to.equal(0); + expect(loader['_queue'].started).to.equal(false); }); it('should reset the resources of the loader', () => @@ -482,10 +483,10 @@ describe('Loader', () => const u3 = '//myshare/image.png'; const u4 = '//myshare/image.png?v=1#me'; - expect(loader._prepareUrl(u1)).to.equal(u1); - expect(loader._prepareUrl(u2)).to.equal(u2); - expect(loader._prepareUrl(u3)).to.equal(u3); - expect(loader._prepareUrl(u4)).to.equal(u4); + expect(loader['_prepareUrl'](u1)).to.equal(u1); + expect(loader['_prepareUrl'](u2)).to.equal(u2); + expect(loader['_prepareUrl'](u3)).to.equal(u3); + expect(loader['_prepareUrl'](u4)).to.equal(u4); }); it('should add the baseUrl for relative urls (no trailing slash on baseUrl)', () => @@ -496,10 +497,10 @@ describe('Loader', () => const u3 = 'image.png?v=1'; const u4 = '/image.png?v=1#me'; - expect(loader._prepareUrl(u1)).to.equal(`${b}/${u1}`); - expect(loader._prepareUrl(u2)).to.equal(`${b}${u2}`); - expect(loader._prepareUrl(u3)).to.equal(`${b}/${u3}`); - expect(loader._prepareUrl(u4)).to.equal(`${b}${u4}`); + expect(loader['_prepareUrl'](u1)).to.equal(`${b}/${u1}`); + expect(loader['_prepareUrl'](u2)).to.equal(`${b}${u2}`); + expect(loader['_prepareUrl'](u3)).to.equal(`${b}/${u3}`); + expect(loader['_prepareUrl'](u4)).to.equal(`${b}${u4}`); }); it('should add the baseUrl for relative urls (yes trailing slash on baseUrl)', () => @@ -510,10 +511,10 @@ describe('Loader', () => const u3 = 'image.png?v=1'; const u4 = '/image.png?v=1#me'; - expect(loader._prepareUrl(u1)).to.equal(`${b}${u1}`); - expect(loader._prepareUrl(u2)).to.equal(`${b}${u2}`); - expect(loader._prepareUrl(u3)).to.equal(`${b}${u3}`); - expect(loader._prepareUrl(u4)).to.equal(`${b}${u4}`); + expect(loader['_prepareUrl'](u1)).to.equal(`${b}${u1}`); + expect(loader['_prepareUrl'](u2)).to.equal(`${b}${u2}`); + expect(loader['_prepareUrl'](u3)).to.equal(`${b}${u3}`); + expect(loader['_prepareUrl'](u4)).to.equal(`${b}${u4}`); }); it('should add the queryString when set', () => @@ -524,10 +525,10 @@ describe('Loader', () => loader.defaultQueryString = 'u=me&p=secret'; - expect(loader._prepareUrl(u1)) + expect(loader['_prepareUrl'](u1)) .to.equal(`${b}/${u1}?${loader.defaultQueryString}`); - expect(loader._prepareUrl(u2)) + expect(loader['_prepareUrl'](u2)) .to.equal(`${b}${u2}?${loader.defaultQueryString}`); }); @@ -539,10 +540,10 @@ describe('Loader', () => loader.defaultQueryString = 'u=me&p=secret'; - expect(loader._prepareUrl(u1)) + expect(loader['_prepareUrl'](u1)) .to.equal(`${b}/${u1}?${loader.defaultQueryString}`); - expect(loader._prepareUrl(u2)) + expect(loader['_prepareUrl'](u2)) .to.equal(`${b}${u2}?${loader.defaultQueryString}`); }); @@ -553,7 +554,7 @@ describe('Loader', () => loader.defaultQueryString = 'u=me&p=secret'; - expect(loader._prepareUrl(u1)) + expect(loader['_prepareUrl'](u1)) .to.equal(`${b}/${u1}&${loader.defaultQueryString}`); }); @@ -563,7 +564,7 @@ describe('Loader', () => loader.defaultQueryString = 'u=me&p=secret'; - expect(loader._prepareUrl('/image.png#me')) + expect(loader['_prepareUrl']('/image.png#me')) .to.equal(`${b}/image.png?${loader.defaultQueryString}#me`); }); @@ -573,7 +574,7 @@ describe('Loader', () => loader.defaultQueryString = 'u=me&p=secret'; - expect(loader._prepareUrl('/image.png?v=1#me')) + expect(loader['_prepareUrl']('/image.png?v=1#me')) .to.equal(`${b}/image.png?v=1&${loader.defaultQueryString}#me`); }); }); @@ -583,11 +584,11 @@ describe('Loader', () => it('should run the before middleware before loading the resource', (done: () => void) => { const spy = sinon.spy(); - const res = {}; + const res = {} as LoaderResource; loader.pre(spy); - loader._loadResource(res, null); + loader['_loadResource'](res, null); setTimeout(() => { @@ -605,7 +606,7 @@ describe('Loader', () => res.load = sinon.spy(); - loader._loadResource(res, null); + loader['_loadResource'](res, null); expect(res.load).to.have.been.calledOnce; }); @@ -622,7 +623,7 @@ describe('Loader', () => done(); }); - loader._onStart(); + loader['_onStart'](); }); }); @@ -638,7 +639,7 @@ describe('Loader', () => done(); }); - loader._onComplete(); + loader['_onComplete'](); }); }); @@ -653,7 +654,7 @@ describe('Loader', () => loader.onProgress.once(spy); - loader._onLoad(res); + loader['_onLoad'](res); expect(spy).to.have.been.calledOnce; }); @@ -669,7 +670,7 @@ describe('Loader', () => loader.onError.once(spy); - loader._onLoad(res); + loader['_onLoad'](res); expect(spy).to.have.been.calledOnce; }); @@ -683,7 +684,7 @@ describe('Loader', () => loader.onLoad.once(spy); - loader._onLoad(res); + loader['_onLoad'](res); expect(spy).to.have.been.calledOnce; }); @@ -697,7 +698,7 @@ describe('Loader', () => loader.use(spy); - loader._onLoad(res); + loader['_onLoad'](res); setTimeout(() => { diff --git a/packages/loaders/test/LoaderResource.test.ts b/packages/loaders/test/LoaderResource.test.ts index 5881402745..15f48bbd7b 100644 --- a/packages/loaders/test/LoaderResource.test.ts +++ b/packages/loaders/test/LoaderResource.test.ts @@ -1,13 +1,13 @@ /* eslint-disable @typescript-eslint/no-unused-expressions */ import sinon from 'sinon'; -import { LoaderResource } from '@pixi/loaders'; +import { IResourceMetadata, LoaderResource } from '@pixi/loaders'; import { expect } from 'chai'; import { fixtureData } from './fixtures/data'; describe('LoaderResource', () => { let request: any; - let res: LoaderResource; + let res: any; let xhr: any; let clock: any; const name = 'test-resource'; @@ -59,7 +59,7 @@ describe('LoaderResource', () => crossOrigin: true, loadType: LoaderResource.LOAD_TYPE.IMAGE, xhrType: LoaderResource.XHR_RESPONSE_TYPE.BLOB, - metadata: meta, + metadata: meta as IResourceMetadata, }); expect(res).to.have.property('name', name); @@ -139,7 +139,7 @@ describe('LoaderResource', () => res.xhr.abort = sinon.spy(); - res.abort(); + res.abort(undefined); expect(res.xhr.abort).to.have.been.calledOnce; }); @@ -153,7 +153,7 @@ describe('LoaderResource', () => expect(res.data.src).to.equal(fixtureData.url); - res.abort(); + res.abort(undefined); expect(res.data.src).to.equal(LoaderResource.EMPTY_GIF); }); @@ -165,7 +165,7 @@ describe('LoaderResource', () => expect(res.data.firstChild).to.exist; - res.abort(); + res.abort(undefined); expect(res.data.firstChild).to.not.exist; }); @@ -177,7 +177,7 @@ describe('LoaderResource', () => expect(res.data.firstChild).to.exist; - res.abort(); + res.abort(undefined); expect(res.data.firstChild).to.not.exist; }); @@ -475,7 +475,7 @@ describe('LoaderResource', () => xhr.responseText = 'I am loaded resource'; res.xhr = xhr; - res._xhrOnLoad(); + res['_xhrOnLoad'](); expect(res.isComplete).to.equal(true); }); @@ -485,7 +485,7 @@ describe('LoaderResource', () => xhr.responseType = LoaderResource.XHR_RESPONSE_TYPE.BUFFER; res.xhr = xhr; - res._xhrOnLoad(); + res['_xhrOnLoad'](); expect(res.isComplete).to.equal(true); }); @@ -568,35 +568,35 @@ describe('LoaderResource', () => it('should return the proper extension', () => { res.url = 'http://www.google.com/image.png'; - expect(res._getExtension()).to.equal('png'); + expect(res['_getExtension']()).to.equal('png'); res.url = 'http://domain.net/really/deep/path/that/goes/for/a/while/movie.wmv'; - expect(res._getExtension()).to.equal('wmv'); + expect(res['_getExtension']()).to.equal('wmv'); res.url = 'http://somewhere.io/path.with.dots/and_a-bunch_of.symbols/data.txt'; - expect(res._getExtension()).to.equal('txt'); + expect(res['_getExtension']()).to.equal('txt'); res.url = 'http://nowhere.me/image.jpg?query=true&string=false&name=real'; - expect(res._getExtension()).to.equal('jpg'); + expect(res['_getExtension']()).to.equal('jpg'); res.url = 'http://nowhere.me/image.jpeg?query=movie.wmv&file=data.json'; - expect(res._getExtension()).to.equal('jpeg'); + expect(res['_getExtension']()).to.equal('jpeg'); res.url = 'http://nowhere.me/image.jpeg?query=movie.wmv&file=data.json'; - expect(res._getExtension()).to.equal('jpeg'); + expect(res['_getExtension']()).to.equal('jpeg'); res.url = 'http://nowhere.me/image.jpeg?query=movie.wmv&file=data.json#/derp.mp3'; - expect(res._getExtension()).to.equal('jpeg'); + expect(res['_getExtension']()).to.equal('jpeg'); res.url = 'http://nowhere.me/image.jpeg?query=movie.wmv&file=data.json#/derp.mp3&?me=two'; - expect(res._getExtension()).to.equal('jpeg'); + expect(res['_getExtension']()).to.equal('jpeg'); res.url = 'http://nowhere.me/image.jpeg#nothing-to-see-here?query=movie.wmv&file=data.json#/derp.mp3&?me=two'; // eslint-disable-line max-len - expect(res._getExtension()).to.equal('jpeg'); + expect(res['_getExtension']()).to.equal('jpeg'); - res._setFlag(LoaderResource.STATUS_FLAGS.DATA_URL, true); + res['_setFlag'](LoaderResource.STATUS_FLAGS.DATA_URL, true); res.url = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAMSURBVBhXY2BgYAAAAAQAAVzN/2kAAAAASUVORK5CYII='; // eslint-disable-line max-len - expect(res._getExtension()).to.equal('png'); + expect(res['_getExtension']()).to.equal('png'); }); }); @@ -605,63 +605,63 @@ describe('LoaderResource', () => it('Should return the correct src url', () => { res.url = 'http://www.google.com/audio.mp3'; - expect(res._createSource('audio', res.url)).to.have.property('src', res.url); + expect(res['_createSource']('audio', res.url)).to.have.property('src', res.url); res.url = 'http://domain.net/really/deep/path/that/goes/for/a/while/movie.wmv'; - expect(res._createSource('video', res.url)).to.have.property('src', res.url); + expect(res['_createSource']('video', res.url)).to.have.property('src', res.url); res.url = 'http://somewhere.io/path.with.dots/and_a-bunch_of.symbols/audio.mp3'; - expect(res._createSource('audio', res.url)).to.have.property('src', res.url); + expect(res['_createSource']('audio', res.url)).to.have.property('src', res.url); res.url = 'http://nowhere.me/audio.mp3?query=true&string=false&name=real'; - expect(res._createSource('audio', res.url)).to.have.property('src', res.url); + expect(res['_createSource']('audio', res.url)).to.have.property('src', res.url); res.url = 'http://nowhere.me/audio.mp3?query=movie.wmv&file=data.json'; - expect(res._createSource('audio', res.url)).to.have.property('src', res.url); + expect(res['_createSource']('audio', res.url)).to.have.property('src', res.url); res.url = 'http://nowhere.me/audio.mp3?query=movie.wmv&file=data.json'; - expect(res._createSource('audio', res.url)).to.have.property('src', res.url); + expect(res['_createSource']('audio', res.url)).to.have.property('src', res.url); res.url = 'http://nowhere.me/audio.mp3?query=movie.wmv&file=data.json#/derp.mp3&?me=two'; - expect(res._createSource('audio', res.url)).to.have.property('src', res.url); + expect(res['_createSource']('audio', res.url)).to.have.property('src', res.url); res.url = 'http://nowhere.me/audio.mp3#nothing-to-see-here?query=movie.wmv&file=data.json#/derp.mp3&?me=two'; // eslint-disable-line max-len - expect(res._createSource('audio', res.url)).to.have.property('src', res.url); + expect(res['_createSource']('audio', res.url)).to.have.property('src', res.url); - res._setFlag(LoaderResource.STATUS_FLAGS.DATA_URL, true); + res['_setFlag'](LoaderResource.STATUS_FLAGS.DATA_URL, true); res.url = 'data:audio/wave;base64,UklGRjIAAABXQVZFZm10IBIAAAABAAEAQB8AAEAfAAABAAgAAABmYWN0BAAAAAAAAABkYXRhAAAAAA=='; // eslint-disable-line max-len - expect(res._createSource('audio', res.url)).to.have.property('src', res.url); + expect(res['_createSource']('audio', res.url)).to.have.property('src', res.url); }); it('Should correctly auto-detect the mime type', () => { res.url = 'http://www.google.com/audio.mp3'; - expect(res._createSource('audio', res.url)).to.have.property('type', 'audio/mp3'); + expect(res['_createSource']('audio', res.url)).to.have.property('type', 'audio/mp3'); res.url = 'http://domain.net/really/deep/path/that/goes/for/a/while/movie.wmv'; - expect(res._createSource('video', res.url)).to.have.property('type', 'video/wmv'); + expect(res['_createSource']('video', res.url)).to.have.property('type', 'video/wmv'); res.url = 'http://somewhere.io/path.with.dots/and_a-bunch_of.symbols/audio.mp3'; - expect(res._createSource('audio', res.url)).to.have.property('type', 'audio/mp3'); + expect(res['_createSource']('audio', res.url)).to.have.property('type', 'audio/mp3'); res.url = 'http://nowhere.me/audio.mp3?query=true&string=false&name=real'; - expect(res._createSource('audio', res.url)).to.have.property('type', 'audio/mp3'); + expect(res['_createSource']('audio', res.url)).to.have.property('type', 'audio/mp3'); res.url = 'http://nowhere.me/audio.mp3?query=movie.wmv&file=data.json'; - expect(res._createSource('audio', res.url)).to.have.property('type', 'audio/mp3'); + expect(res['_createSource']('audio', res.url)).to.have.property('type', 'audio/mp3'); res.url = 'http://nowhere.me/audio.mp3?query=movie.wmv&file=data.json'; - expect(res._createSource('audio', res.url)).to.have.property('type', 'audio/mp3'); + expect(res['_createSource']('audio', res.url)).to.have.property('type', 'audio/mp3'); res.url = 'http://nowhere.me/audio.mp3?query=movie.wmv&file=data.json#/derp.mp3&?me=two'; - expect(res._createSource('audio', res.url)).to.have.property('type', 'audio/mp3'); + expect(res['_createSource']('audio', res.url)).to.have.property('type', 'audio/mp3'); res.url = 'http://nowhere.me/audio.mp3#nothing-to-see-here?query=movie.wmv&file=data.json#/derp.mp3&?me=two'; // eslint-disable-line max-len - expect(res._createSource('audio', res.url)).to.have.property('type', 'audio/mp3'); + expect(res['_createSource']('audio', res.url)).to.have.property('type', 'audio/mp3'); - res._setFlag(LoaderResource.STATUS_FLAGS.DATA_URL, true); + res['_setFlag'](LoaderResource.STATUS_FLAGS.DATA_URL, true); res.url = 'data:audio/wave;base64,UklGRjIAAABXQVZFZm10IBIAAAABAAEAQB8AAEAfAAABAAgAAABmYWN0BAAAAAAAAABkYXRhAAAAAA=='; // eslint-disable-line max-len - expect(res._createSource('audio', res.url)).to.have.property('type', 'audio/wave'); + expect(res['_createSource']('audio', res.url)).to.have.property('type', 'audio/wave'); }); }); }); diff --git a/packages/loaders/test/TextureLoader.tests.ts b/packages/loaders/test/TextureLoader.tests.ts index 3a9dd53ff7..8176b7a6b5 100644 --- a/packages/loaders/test/TextureLoader.tests.ts +++ b/packages/loaders/test/TextureLoader.tests.ts @@ -4,18 +4,18 @@ import { BaseTextureCache, TextureCache } from '@pixi/utils'; import sinon from 'sinon'; import { expect } from 'chai'; -describe('TextureLoader', function () +describe('TextureLoader', () => { - it('should exist and return a function', function () + it('should exist and return a function', () => { expect(TextureLoader).to.not.be.undefined; expect(TextureLoader.use).to.be.a('function'); }); - it('should do nothing if the resource is not an image', function () + it('should do nothing if the resource is not an image', () => { const spy = sinon.spy(); - const res = {}; + const res = {} as LoaderResource; TextureLoader.use(res, spy); @@ -23,13 +23,13 @@ describe('TextureLoader', function () expect(res.texture).to.be.undefined; }); - it('should create a texture if resource is an image', function (done) + it('should create a texture if resource is an image', (done) => { const name = `${(Math.random() * 10000) | 0}`; const url = `http://localhost/doesnt_exist/${name}`; const data = new Image(); const type = LoaderResource.TYPE.IMAGE; - const res = { url, name, type, data, metadata: {} }; + const res = { url, name, type, data, metadata: {} } as LoaderResource; // Transparent image data.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJ' diff --git a/packages/loaders/test/resources/index.ts b/packages/loaders/test/resources/index.ts index f8cd47d39c..4159800ed5 100644 --- a/packages/loaders/test/resources/index.ts +++ b/packages/loaders/test/resources/index.ts @@ -14,14 +14,15 @@ const mimeTypes = { /** * Very HTTP server to requesting files. + * @param port */ -const createServer = (port) => +const createServer = (port: number) => { const server = http.createServer((request, response) => { const filePath = path.join(__dirname, request.url); const extname = path.extname(filePath); - const contentType = mimeTypes[extname] || 'text/html'; + const contentType = mimeTypes[extname as keyof typeof mimeTypes] || 'text/html'; fs.readFile(filePath, (error, content) => { diff --git a/packages/math-extras/global.d.ts b/packages/math-extras/global.d.ts index 8165d10230..3ecce994ae 100644 --- a/packages/math-extras/global.d.ts +++ b/packages/math-extras/global.d.ts @@ -12,21 +12,20 @@ declare namespace GlobalMixins interface Rectangle { - intersects(other: Rectangle): boolean; + containsRect(other: import('@pixi/math').Rectangle): boolean; - containsRect(other: Rectangle): boolean; + equals(other: import('@pixi/math').Rectangle): boolean; - equals(other: Rectangle): boolean; + intersection(other: import('@pixi/math').Rectangle): import('@pixi/math').Rectangle; + intersection(other: import('@pixi/math').Rectangle, outRect: T): T; - intersection(other: Rectangle): Rectangle; - intersection(other: Rectangle, outRect: T): T; - - union(other: Rectangle): Rectangle; - union(other: Rectangle, outRect: T): T; + union(other: import('@pixi/math').Rectangle): import('@pixi/math').Rectangle; + union(other: import('@pixi/math').Rectangle, outRect: T): T; } } -interface Vector2Math { +interface Vector2Math +{ add(other: import('@pixi/math').IPointData): import('@pixi/math').Point; add(other: import('@pixi/math').IPointData, outPoint: T): T; diff --git a/packages/math-extras/package.json b/packages/math-extras/package.json index 583f8c4a45..0ef97c2d97 100644 --- a/packages/math-extras/package.json +++ b/packages/math-extras/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/math-extras", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/math-extras.js", "module": "dist/esm/math-extras.js", "bundle": "dist/browser/math-extras.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/math-extras.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/math-extras.js" + } + } + }, "bundleNoExports": true, "description": "Useful methods for some math structures", "author": "Milton Candelero", @@ -27,6 +40,6 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/math": "6.3.0" + "@pixi/math": "6.4.2" } } diff --git a/packages/math-extras/src/index.ts b/packages/math-extras/src/index.ts index 8f086ee214..8405601c7d 100644 --- a/packages/math-extras/src/index.ts +++ b/packages/math-extras/src/index.ts @@ -8,7 +8,6 @@ import { IPointData, Point } from '@pixi/math'; * and see if it is less than `Math.EPSILON`. * * _Note: Only available with **@pixi/math-extras**._ - * * @param {number} a - First floating number to compare. * @param {number} b - Second floating number to compare. * @returns {boolean} Returns `true` if the difference between the values is less than `Math.EPSILON`; otherwise `false`. @@ -20,7 +19,6 @@ export function floatEqual(a: number, b: number): boolean; * A good epsilon would be the N% of the largest of the two values or `Math.EPSILON`. * * _Note: Only available with **@pixi/math-extras**._ - * * @memberof PIXI * @param {number} a - First floating number to compare. * @param {number} b - Second floating number to compare. @@ -113,7 +111,6 @@ function genericLineIntersection( * The intersection point may land outside the extents of the lines. * * _Note: Only available with **@pixi/math-extras**._ - * * @param aStart - First point of the first line. * @param aEnd - Second point of the first line. * @param bStart - First point of the second line. @@ -127,7 +124,6 @@ export function lineIntersection(aStart: IPointData, aEnd: IPointData, bStart: I * The intersection point may land outside the extents of the lines. * * _Note: Only available with **@pixi/math-extras**._ - * * @memberof PIXI * @param aStart - First point of the first line. * @param aEnd - Second point of the first line. @@ -151,7 +147,6 @@ export function lineIntersection * The intersection point must land inside the extents of the segments or return a `NaN` Point. * * _Note: Only available with **@pixi/math-extras**._ - * * @param aStart - Starting point of the first segment. * @param aEnd - Ending point of the first segment. * @param bStart - Starting point of the second segment. @@ -165,7 +160,6 @@ export function segmentIntersection(aStart: IPointData, aEnd: IPointData, bStart * The intersection point must land inside the extents of the segments or return a `NaN` Point. * * _Note: Only available with **@pixi/math-extras**._ - * * @memberof PIXI * @param aStart - Starting point of the first segment. * @param aEnd - Ending point of the first segment. diff --git a/packages/math-extras/src/pointExtras.ts b/packages/math-extras/src/pointExtras.ts index 1797b10c6b..6704e4063e 100644 --- a/packages/math-extras/src/pointExtras.ts +++ b/packages/math-extras/src/pointExtras.ts @@ -5,7 +5,6 @@ const mixins: any = { * Adds `other` to `this` point and outputs into `outPoint` or a new Point. * * _Note: Only available with **@pixi/math-extras**._ - * * @method add * @memberof PIXI.Point# * @param {IPointData} other - The point to add to `this`. @@ -17,7 +16,6 @@ const mixins: any = { * Adds `other` to `this` point and outputs into `outPoint` or a new Point. * * _Note: Only available with **@pixi/math-extras**._ - * * @method add * @memberof PIXI.ObservablePoint# * @param {IPointData} other - The point to add to `this`. @@ -41,7 +39,6 @@ const mixins: any = { * Subtracts `other` from `this` point and outputs into `outPoint` or a new Point. * * _Note: Only available with **@pixi/math-extras**._ - * * @method subtract * @memberof PIXI.Point# * @param {IPointData} other - The point to subtract to `this`. @@ -53,7 +50,6 @@ const mixins: any = { * Subtracts `other` from `this` point and outputs into `outPoint` or a new Point. * * _Note: Only available with **@pixi/math-extras**._ - * * @method subtract * @memberof PIXI.ObservablePoint# * @param {IPointData} other - The point to subtract to `this`. @@ -77,7 +73,6 @@ const mixins: any = { * Multiplies component-wise `other` and `this` points and outputs into `outPoint` or a new Point. * * _Note: Only available with **@pixi/math-extras**._ - * * @method multiply * @memberof PIXI.Point# * @param {IPointData} other - The point to multiply with `this`. @@ -89,7 +84,6 @@ const mixins: any = { * Multiplies component-wise `other` and `this` points and outputs into `outPoint` or a new Point. * * _Note: Only available with **@pixi/math-extras**._ - * * @method multiply * @memberof PIXI.ObservablePoint# * @param {IPointData} other - The point to multiply with `this`. @@ -113,7 +107,6 @@ const mixins: any = { * Multiplies each component of `this` point with the number `scalar` and outputs into `outPoint` or a new Point. * * _Note: Only available with **@pixi/math-extras**._ - * * @method multiplyScalar * @memberof PIXI.Point# * @param {number} scalar - The number to multiply both components of `this`. @@ -125,7 +118,6 @@ const mixins: any = { * Multiplies each component of `this` point with the number `scalar` and outputs into `outPoint` or a new Point. * * _Note: Only available with **@pixi/math-extras**._ - * * @method multiplyScalar * @memberof PIXI.ObservablePoint# * @param {number} scalar - The number to multiply both components of `this`. @@ -150,7 +142,6 @@ const mixins: any = { * The dot product is the sum of the products of the corresponding components of two vectors. * * _Note: Only available with **@pixi/math-extras**._ - * * @method dot * @memberof PIXI.Point# * @param {IPointData} other - The other point to calculate the dot product with `this`. @@ -161,7 +152,6 @@ const mixins: any = { * The dot product is the sum of the products of the corresponding components of two vectors. * * _Note: Only available with **@pixi/math-extras**._ - * * @method dot * @memberof PIXI.ObservablePoint# * @param {IPointData} other - The other point to calculate the dot product with `this`. @@ -182,7 +172,6 @@ const mixins: any = { * This function returns the z component of the cross product of the two points. * * _Note: Only available with **@pixi/math-extras**._ - * * @method cross * @memberof PIXI.Point# * @param {IPointData} other - The other point to calculate the cross product with `this`. @@ -198,7 +187,6 @@ const mixins: any = { * This function returns the z component of the cross product of the two points. * * _Note: Only available with **@pixi/math-extras**._ - * * @method cross * @memberof PIXI.ObservablePoint# * @param {IPointData} other - The other point to calculate the cross product with `this`. @@ -224,7 +212,6 @@ const mixins: any = { * A normalized vector is a vector of magnitude (length) 1 * * _Note: Only available with **@pixi/math-extras**._ - * * @method normalize * @memberof PIXI.Point# * @param {IPointData} [outPoint] - A Point-like object in which to store the value, @@ -237,7 +224,6 @@ const mixins: any = { * A normalized vector is a vector of magnitude (length) 1 * * _Note: Only available with **@pixi/math-extras**._ - * * @method normalize * @memberof PIXI.ObservablePoint# * @param {IPointData} [outPoint] - A Point-like object in which to store the value, @@ -264,7 +250,6 @@ const mixins: any = { * Defined as the square root of the sum of the squares of each component. * * _Note: Only available with **@pixi/math-extras**._ - * * @method magnitude * @memberof PIXI.Point# * @returns {number} The magnitude (length) of the vector. @@ -275,7 +260,6 @@ const mixins: any = { * Defined as the square root of the sum of the squares of each component. * * _Note: Only available with **@pixi/math-extras**._ - * * @method magnitude * @memberof PIXI.ObservablePoint# * @returns {number} The magnitude (length) of the vector. @@ -293,7 +277,6 @@ const mixins: any = { * Defined as the sum of the squares of each component. * * _Note: Only available with **@pixi/math-extras**._ - * * @method magnitudeSquared * @memberof PIXI.Point# * @returns {number} The magnitude squared (length squared) of the vector. @@ -306,7 +289,6 @@ const mixins: any = { * Defined as the sum of the squares of each component. * * _Note: Only available with **@pixi/math-extras**._ - * * @method magnitudeSquared * @memberof PIXI.ObservablePoint# * @returns {number} The magnitude squared (length squared) of the vector. @@ -324,7 +306,6 @@ const mixins: any = { * `this.project(onto)` is the shadow cast by `this` on the line defined by `onto` . * * _Note: Only available with **@pixi/math-extras**._ - * * @method project * @memberof PIXI.Point# * @param {IPointData} onto - A non zero vector describing a line on which to project `this`. @@ -340,7 +321,6 @@ const mixins: any = { * `this.project(onto)` is the shadow cast by `this` on the line defined by `onto` . * * _Note: Only available with **@pixi/math-extras**._ - * * @method project * @memberof PIXI.ObservablePoint# * @param {IPointData} onto - A non zero vector describing a line on which to project `this`. @@ -372,7 +352,6 @@ const mixins: any = { * `this.reflect(normal)` is the reflection of `this` on that mirror. * * _Note: Only available with **@pixi/math-extras**._ - * * @method reflect * @memberof PIXI.Point# * @param {IPointData} normal - The normal vector of your reflecting plane. @@ -389,7 +368,6 @@ const mixins: any = { * `this.reflect(normal)` is the reflection of `this` on that mirror. * * _Note: Only available with **@pixi/math-extras**._ - * * @method reflect * @memberof PIXI.ObservablePoint# * @param {IPointData} normal - The normal vector of your reflecting plane. diff --git a/packages/math-extras/src/rectangleExtras.ts b/packages/math-extras/src/rectangleExtras.ts index ff0f930503..ac6c6c9e1d 100644 --- a/packages/math-extras/src/rectangleExtras.ts +++ b/packages/math-extras/src/rectangleExtras.ts @@ -7,7 +7,6 @@ import { Rectangle } from '@pixi/math'; * not even other arealess rectangles. * * _Note: Only available with **@pixi/math-extras**._ - * * @method containsRect * @memberof PIXI.Rectangle# * @param {Rectangle} other - The Rectangle to fit inside `this`. @@ -27,7 +26,6 @@ Rectangle.prototype.containsRect = function containsRect(other: Rectangle): bool * Accepts `other` Rectangle and returns true if the given Rectangle is equal to `this` Rectangle. * * _Note: Only available with **@pixi/math-extras**._ - * * @method equals * @memberof PIXI.Rectangle# * @param {Rectangle} other - The Rectangle to compare with `this` @@ -51,7 +49,6 @@ Rectangle.prototype.equals = function equals(other: Rectangle): boolean * and will always return an empty rectangle with its properties set to zero. * * _Note: Only available with **@pixi/math-extras**._ - * * @method intersection * @memberof PIXI.Rectangle# * @param {Rectangle} other - The Rectangle to intersect with `this`. @@ -99,7 +96,6 @@ Rectangle.prototype.intersection = function intersection(ot * the horizontal and vertical space between the two rectangles. * * _Note: Only available with **@pixi/math-extras**._ - * * @method union * @memberof PIXI.Rectangle# * @param {Rectangle} other - The Rectangle to unite with `this`. diff --git a/packages/math-extras/test/Point.tests.ts b/packages/math-extras/test/Point.tests.ts index 1ea093e400..92bfed1eb8 100644 --- a/packages/math-extras/test/Point.tests.ts +++ b/packages/math-extras/test/Point.tests.ts @@ -2,11 +2,11 @@ import { ObservablePoint, Point } from '@pixi/math'; import { expect } from 'chai'; import '@pixi/math-extras'; -describe('Point', function () +describe('Point', () => { - describe('add', function () + describe('add', () => { - it('should add component-wise', function () + it('should add component-wise', () => { // Point const a = new Point(1, 2); @@ -25,7 +25,7 @@ describe('Point', function () expect(oc.y).to.equal(6); }); - it('should return the same reference given', function () + it('should return the same reference given', () => { // Point const a = new Point(1, 2); @@ -42,7 +42,7 @@ describe('Point', function () expect(oc).to.equal(oa); }); - it('can output into any IPointData given', function () + it('can output into any IPointData given', () => { // Point const a = new Point(1, 2); @@ -61,7 +61,7 @@ describe('Point', function () expect(oc.y).to.equal(6); }); - it('can take any IPointData as other input', function () + it('can take any IPointData as other input', () => { // Point const a = new Point(1, 2); @@ -79,9 +79,9 @@ describe('Point', function () }); }); - describe('subtract', function () + describe('subtract', () => { - it('should subtract component-wise', function () + it('should subtract component-wise', () => { // Point const a = new Point(1, 2); @@ -100,7 +100,7 @@ describe('Point', function () expect(oc.y).to.equal(-2); }); - it('should return the same reference given', function () + it('should return the same reference given', () => { // Point const a = new Point(1, 2); @@ -117,7 +117,7 @@ describe('Point', function () expect(oc).to.equal(oa); }); - it('can output into any IPointData given', function () + it('can output into any IPointData given', () => { // Point const a = new Point(1, 2); @@ -136,7 +136,7 @@ describe('Point', function () expect(oc.y).to.equal(-2); }); - it('can take any IPointData as other input', function () + it('can take any IPointData as other input', () => { // Point const a = new Point(1, 2); @@ -154,9 +154,9 @@ describe('Point', function () }); }); - describe('multiply', function () + describe('multiply', () => { - it('should multiply component-wise', function () + it('should multiply component-wise', () => { // Point const a = new Point(1, 2); @@ -175,7 +175,7 @@ describe('Point', function () expect(oc.y).to.equal(8); }); - it('should return the same reference given', function () + it('should return the same reference given', () => { // Point const a = new Point(1, 2); @@ -192,7 +192,7 @@ describe('Point', function () expect(oc).to.equal(oa); }); - it('can output into any IPointData given', function () + it('can output into any IPointData given', () => { // Point const a = new Point(1, 2); @@ -211,7 +211,7 @@ describe('Point', function () expect(oc.y).to.equal(8); }); - it('can take any IPointData as other input', function () + it('can take any IPointData as other input', () => { // Point const a = new Point(1, 2); @@ -229,9 +229,9 @@ describe('Point', function () }); }); - describe('multiplyScalar', function () + describe('multiplyScalar', () => { - it('should multiply both components by a scalar', function () + it('should multiply both components by a scalar', () => { // Point const a = new Point(1, 2); @@ -248,7 +248,7 @@ describe('Point', function () expect(oc.y).to.equal(6); }); - it('should return the same reference given', function () + it('should return the same reference given', () => { // Point const a = new Point(1, 2); @@ -263,7 +263,7 @@ describe('Point', function () expect(oc).to.equal(oa); }); - it('can output into any IPointData given', function () + it('can output into any IPointData given', () => { // Point const a = new Point(1, 2); @@ -281,9 +281,9 @@ describe('Point', function () }); }); - describe('dot', function () + describe('dot', () => { - it('should multiply component-wise and then add both components', function () + it('should multiply component-wise and then add both components', () => { // Point const a = new Point(1, 2); @@ -301,9 +301,9 @@ describe('Point', function () }); }); - describe('cross', function () + describe('cross', () => { - it('should return the magnitude of the result of a cross product', function () + it('should return the magnitude of the result of a cross product', () => { // Point const a = new Point(1, 2); @@ -321,9 +321,9 @@ describe('Point', function () }); }); - describe('normalize', function () + describe('normalize', () => { - it('magnitude should be 1', function () + it('magnitude should be 1', () => { // Point const a = new Point(3, 4); @@ -342,7 +342,7 @@ describe('Point', function () expect(omagnitude).to.be.closeTo(1, 0.001); }); - it('should return the same reference given', function () + it('should return the same reference given', () => { // Point const a = new Point(3, 4); @@ -357,7 +357,7 @@ describe('Point', function () expect(oc).to.equal(oa); }); - it('can output into any IPointData given', function () + it('can output into any IPointData given', () => { // Point const a = new Point(1, 2); @@ -377,9 +377,9 @@ describe('Point', function () }); }); - describe('magnitude', function () + describe('magnitude', () => { - it('should return the square root of the sum of the squares of each component', function () + it('should return the square root of the sum of the squares of each component', () => { const expectedMagnitude = Math.sqrt((3 * 3) + (4 * 4)); // Point @@ -395,7 +395,7 @@ describe('Point', function () expect(oc).to.be.closeTo(expectedMagnitude, 0.001); }); - it('should return the sum of the squares of each component', function () + it('should return the sum of the squares of each component', () => { const expectedMagnitudeSquared = (3 * 3) + (4 * 4); // Point @@ -412,9 +412,9 @@ describe('Point', function () }); }); - describe('project', function () + describe('project', () => { - it('should return the vector projection of a vector onto another nonzero vector', function () + it('should return the vector projection of a vector onto another nonzero vector', () => { // Point const a = new Point(1, 2); @@ -433,7 +433,7 @@ describe('Point', function () expect(oc.y).to.be.closeTo(44 / 25, 0.001); }); - it('should return the same reference given', function () + it('should return the same reference given', () => { // Point const a = new Point(1, 2); @@ -450,7 +450,7 @@ describe('Point', function () expect(oc).to.equal(oa); }); - it('can output into any IPointData given', function () + it('can output into any IPointData given', () => { // Point const a = new Point(1, 2); @@ -469,7 +469,7 @@ describe('Point', function () expect(oc.y).to.be.closeTo(44 / 25, 0.001); }); - it('can take any IPointData as other input', function () + it('can take any IPointData as other input', () => { // Point const a = new Point(1, 2); @@ -487,9 +487,9 @@ describe('Point', function () }); }); - describe('reflect', function () + describe('reflect', () => { - it('should return the specular reflect vector', function () + it('should return the specular reflect vector', () => { // Point const a = new Point(1, 2); @@ -508,7 +508,7 @@ describe('Point', function () expect(oc.y).to.equal(-86); }); - it('should return the same reference given', function () + it('should return the same reference given', () => { // Point const a = new Point(1, 2); @@ -525,7 +525,7 @@ describe('Point', function () expect(oc).to.equal(oa); }); - it('can output into any IPointData given', function () + it('can output into any IPointData given', () => { // Point const a = new Point(1, 2); @@ -544,7 +544,7 @@ describe('Point', function () expect(oc.y).to.equal(-86); }); - it('can take any IPointData as other input', function () + it('can take any IPointData as other input', () => { // Point const a = new Point(1, 2); diff --git a/packages/math-extras/test/Rectangle.tests.ts b/packages/math-extras/test/Rectangle.tests.ts index 76de6039c6..082ad5eecc 100644 --- a/packages/math-extras/test/Rectangle.tests.ts +++ b/packages/math-extras/test/Rectangle.tests.ts @@ -2,11 +2,11 @@ import { Rectangle } from '@pixi/math'; import { expect } from 'chai'; import '@pixi/math-extras'; -describe('Rectangle', function () +describe('Rectangle', () => { - describe('containsRect', function () + describe('containsRect', () => { - it('should return true if all four corners are inside or on the edge of the rectangle', function () + it('should return true if all four corners are inside or on the edge of the rectangle', () => { /* +-----------------+-----------------+ @@ -45,9 +45,9 @@ describe('Rectangle', function () }); }); - describe('equals', function () + describe('equals', () => { - it('should return true x, y, width and height match', function () + it('should return true x, y, width and height match', () => { const a = new Rectangle(0, 0, 100, 100); const b = new Rectangle(0, 0, 100, 100); @@ -67,10 +67,10 @@ describe('Rectangle', function () expect(c.equals(c.clone())).to.equal(true); }); }); - describe('intersection', function () + describe('intersection', () => { it('should return a rectangle with the intersection if the area is > 0, otherwise an empty rectangle', - function () + () => { /* +--------+ @@ -120,7 +120,7 @@ describe('Rectangle', function () expect(emptyIntersectsItself.height).to.equal(0); }); - it('should return the same reference given', function () + it('should return the same reference given', () => { const a = new Rectangle(0, 0, 100, 100); const b = new Rectangle(50, 50, 100, 100); @@ -130,10 +130,10 @@ describe('Rectangle', function () }); }); - describe('union', function () + describe('union', () => { it('should return a rectangle that includes both rectangles (similar to enlarge)', - function () + () => { const a = new Rectangle(0, 0, 100, 100); const b = new Rectangle(50, 50, 100, 100); @@ -145,7 +145,7 @@ describe('Rectangle', function () expect(c.height).to.equal(150); }); - it('should return the same reference given', function () + it('should return the same reference given', () => { const a = new Rectangle(0, 0, 100, 100); const b = new Rectangle(50, 50, 100, 100); @@ -155,7 +155,7 @@ describe('Rectangle', function () }); it('should return the same values as enalrge()', - function () + () => { const enlarged = new Rectangle(0, 0, 100, 100); const a = new Rectangle(0, 0, 100, 100); diff --git a/packages/math-extras/test/floatEqual.tests.ts b/packages/math-extras/test/floatEqual.tests.ts index 89c1d92f43..9726c29ce1 100644 --- a/packages/math-extras/test/floatEqual.tests.ts +++ b/packages/math-extras/test/floatEqual.tests.ts @@ -1,10 +1,10 @@ import { expect } from 'chai'; import { floatEqual } from '@pixi/math-extras'; -describe('floatEqual', function () +describe('floatEqual', () => { it('should return true if the difference between values is less than epsilon', - function () + () => { // 0.1 + 0.2 = 0.3 is the common floating point pitfall. expect(floatEqual(0.1 + 0.2, 0.3)).to.equal(true); diff --git a/packages/math-extras/test/lineIntersection.tests.ts b/packages/math-extras/test/lineIntersection.tests.ts index 4f90b40fd3..41061be073 100644 --- a/packages/math-extras/test/lineIntersection.tests.ts +++ b/packages/math-extras/test/lineIntersection.tests.ts @@ -2,10 +2,10 @@ import { Point } from '@pixi/math'; import { lineIntersection } from '@pixi/math-extras'; import { expect } from 'chai'; -describe('lineIntersection', function () +describe('lineIntersection', () => { it('should return the point where the lines intersect', - function () + () => { const aStart = new Point(1, 2); const aEnd = new Point(3, 4); @@ -19,7 +19,7 @@ describe('lineIntersection', function () }); it('should return NaN if the lines are parallel', - function () + () => { const aStart = new Point(1, 2); const aEnd = new Point(3, 4); @@ -31,7 +31,7 @@ describe('lineIntersection', function () expect(parallel.x).to.be.NaN; expect(parallel.y).to.be.NaN; }); - it('should return the same reference given', function () + it('should return the same reference given', () => { // Point const aStart = new Point(1, 2); @@ -44,7 +44,7 @@ describe('lineIntersection', function () expect(intersect).to.equal(outValue); }); - it('can output into any IPointData given', function () + it('can output into any IPointData given', () => { const aStart = new Point(1, 2); const aEnd = new Point(3, 4); @@ -58,7 +58,7 @@ describe('lineIntersection', function () expect(outValue.y).to.equal(7.25); }); - it('can take any IPointData as input', function () + it('can take any IPointData as input', () => { const aStart = { x: 1, y: 2 }; const aEnd = { x: 3, y: 4 }; diff --git a/packages/math-extras/test/segmentIntersection.tests.ts b/packages/math-extras/test/segmentIntersection.tests.ts index 2df1fdb6a9..a805748fc2 100644 --- a/packages/math-extras/test/segmentIntersection.tests.ts +++ b/packages/math-extras/test/segmentIntersection.tests.ts @@ -2,10 +2,10 @@ import { Point } from '@pixi/math'; import { expect } from 'chai'; import { segmentIntersection } from '@pixi/math-extras'; -describe('segmentIntersection', function () +describe('segmentIntersection', () => { it('should return the point where the segments intersect', - function () + () => { const aStart = new Point(1, 2); const aEnd = new Point(11, 12); @@ -19,7 +19,7 @@ describe('segmentIntersection', function () }); it('should return NaN if the segments are parallel', - function () + () => { const aStart = new Point(1, 2); const aEnd = new Point(11, 12); @@ -32,7 +32,7 @@ describe('segmentIntersection', function () expect(parallel.y).to.be.NaN; }); it('should return NaN if the segments dont intersect', - function () + () => { const aStart = new Point(1, 2); const aEnd = new Point(3, 4); @@ -44,7 +44,7 @@ describe('segmentIntersection', function () expect(parallel.x).to.be.NaN; expect(parallel.y).to.be.NaN; }); - it('should return the same reference given', function () + it('should return the same reference given', () => { // Point const aStart = new Point(1, 2); @@ -57,7 +57,7 @@ describe('segmentIntersection', function () expect(intersect).to.equal(outValue); }); - it('can output into any IPointData given', function () + it('can output into any IPointData given', () => { const aStart = new Point(1, 2); const aEnd = new Point(11, 12); @@ -71,7 +71,7 @@ describe('segmentIntersection', function () expect(outValue.y).to.equal(7.25); }); - it('can take any IPointData as input', function () + it('can take any IPointData as input', () => { const aStart = { x: 1, y: 2 }; const aEnd = { x: 11, y: 12 }; diff --git a/packages/math/package.json b/packages/math/package.json index bd4d4fe3a0..d15f79f8ab 100644 --- a/packages/math/package.json +++ b/packages/math/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/math", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/math.js", "module": "dist/esm/math.js", "bundle": "dist/browser/math.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/math.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/math.js" + } + } + }, "description": "Collection of math utilities", "author": "Mat Groves", "contributors": [ diff --git a/packages/math/src/IPoint.ts b/packages/math/src/IPoint.ts index 58900332c5..939ee623ed 100644 --- a/packages/math/src/IPoint.ts +++ b/packages/math/src/IPoint.ts @@ -17,7 +17,6 @@ export interface IPoint extends IPointData /** * Sets the point to a new x and y position. * If y is omitted, both x and y will be set to x. - * * @method set * @memberof PIXI.IPoint# * @param {number} [x=0] - position of the point on the x axis @@ -42,7 +41,6 @@ export interface IPoint extends IPointData /** * Returns true if the given point is equal to this point - * * @method equals * @memberof PIXI.IPoint# * @param {PIXI.IPointData} p - The point to check diff --git a/packages/math/src/Matrix.ts b/packages/math/src/Matrix.ts index 2301c8ddc4..0505720578 100644 --- a/packages/math/src/Matrix.ts +++ b/packages/math/src/Matrix.ts @@ -13,7 +13,6 @@ import type { IPointData } from './IPointData'; * | b | d | ty| * | 0 | 0 | 1 | * ``` - * * @memberof PIXI */ export class Matrix @@ -36,7 +35,7 @@ export class Matrix /** @default 0 */ public ty: number; - public array: Float32Array|null = null; + public array: Float32Array | null = null; /** * @param a - x scale @@ -65,7 +64,6 @@ export class Matrix * d = array[4] * tx = array[2] * ty = array[5] - * * @param array - The array that the matrix will be populated from. */ fromArray(array: number[]): void @@ -80,14 +78,13 @@ export class Matrix /** * Sets the matrix properties. - * * @param a - Matrix component * @param b - Matrix component * @param c - Matrix component * @param d - Matrix component * @param tx - Matrix component * @param ty - Matrix component - * @return This matrix. Good for chaining method calls. + * @returns This matrix. Good for chaining method calls. */ set(a: number, b: number, c: number, d: number, tx: number, ty: number): this { @@ -103,10 +100,9 @@ export class Matrix /** * Creates an array from the current Matrix object. - * * @param transpose - Whether we need to transpose the matrix or not * @param [out=new Float32Array(9)] - If provided the array will be assigned to out - * @return The newly created array which contains the matrix + * @returns The newly created array which contains the matrix */ toArray(transpose: boolean, out?: Float32Array): Float32Array { @@ -148,10 +144,9 @@ export class Matrix /** * Get a new position with the current transformation applied. * Can be used to go from a child's coordinate space to the world coordinate space. (e.g. rendering) - * * @param pos - The origin * @param {PIXI.Point} [newPos] - The point that the new position is assigned to (allowed to be same as input) - * @return {PIXI.Point} The new point, transformed through this matrix + * @returns {PIXI.Point} The new point, transformed through this matrix */ apply

(pos: IPointData, newPos?: P): P { @@ -169,10 +164,9 @@ export class Matrix /** * Get a new position with the inverse of the current transformation applied. * Can be used to go from the world coordinate space to a child's coordinate space. (e.g. input) - * * @param pos - The origin * @param {PIXI.Point} [newPos] - The point that the new position is assigned to (allowed to be same as input) - * @return {PIXI.Point} The new point, inverse-transformed through this matrix + * @returns {PIXI.Point} The new point, inverse-transformed through this matrix */ applyInverse

(pos: IPointData, newPos?: P): P { @@ -191,10 +185,9 @@ export class Matrix /** * Translates the matrix on the x and y. - * * @param x - How much to translate x by * @param y - How much to translate y by - * @return This matrix. Good for chaining method calls. + * @returns This matrix. Good for chaining method calls. */ translate(x: number, y: number): this { @@ -206,10 +199,9 @@ export class Matrix /** * Applies a scale transformation to the matrix. - * * @param x - The amount to scale horizontally * @param y - The amount to scale vertically - * @return This matrix. Good for chaining method calls. + * @returns This matrix. Good for chaining method calls. */ scale(x: number, y: number): this { @@ -225,9 +217,8 @@ export class Matrix /** * Applies a rotation transformation to the matrix. - * * @param angle - The angle in radians. - * @return This matrix. Good for chaining method calls. + * @returns This matrix. Good for chaining method calls. */ rotate(angle: number): this { @@ -250,9 +241,8 @@ export class Matrix /** * Appends the given Matrix to this Matrix. - * * @param matrix - The matrix to append. - * @return This matrix. Good for chaining method calls. + * @returns This matrix. Good for chaining method calls. */ append(matrix: Matrix): this { @@ -274,7 +264,6 @@ export class Matrix /** * Sets the matrix based on all the available properties - * * @param x - Position on the x axis * @param y - Position on the y axis * @param pivotX - Pivot on the x axis @@ -284,7 +273,7 @@ export class Matrix * @param rotation - Rotation in radians * @param skewX - Skew on the x axis * @param skewY - Skew on the y axis - * @return This matrix. Good for chaining method calls. + * @returns This matrix. Good for chaining method calls. */ setTransform(x: number, y: number, pivotX: number, pivotY: number, scaleX: number, scaleY: number, rotation: number, skewX: number, skewY: number): this @@ -302,9 +291,8 @@ export class Matrix /** * Prepends the given Matrix to this Matrix. - * * @param matrix - The matrix to prepend - * @return This matrix. Good for chaining method calls. + * @returns This matrix. Good for chaining method calls. */ prepend(matrix: Matrix): this { @@ -329,9 +317,8 @@ export class Matrix /** * Decomposes the matrix (x, y, scaleX, scaleY, and rotation) and sets the properties on to a transform. - * * @param transform - The transform to apply the properties to. - * @return The transform with the newly applied properties + * @returns The transform with the newly applied properties */ decompose(transform: Transform): Transform { @@ -372,8 +359,7 @@ export class Matrix /** * Inverts this matrix - * - * @return This matrix. Good for chaining method calls. + * @returns This matrix. Good for chaining method calls. */ invert(): this { @@ -396,8 +382,7 @@ export class Matrix /** * Resets this Matrix to an identity (default) matrix. - * - * @return This matrix. Good for chaining method calls. + * @returns This matrix. Good for chaining method calls. */ identity(): this { @@ -413,8 +398,7 @@ export class Matrix /** * Creates a new Matrix object with the same values as this one. - * - * @return A copy of this matrix. Good for chaining method calls. + * @returns A copy of this matrix. Good for chaining method calls. */ clone(): Matrix { @@ -432,9 +416,8 @@ export class Matrix /** * Changes the values of the given matrix to be the same as the ones in this matrix - * * @param matrix - The matrix to copy to. - * @return The matrix given in parameter with its values updated. + * @returns The matrix given in parameter with its values updated. */ copyTo(matrix: Matrix): Matrix { @@ -450,9 +433,8 @@ export class Matrix /** * Changes the values of the matrix to be the same as the ones in given matrix - * * @param {PIXI.Matrix} matrix - The matrix to copy from. - * @return {PIXI.Matrix} this + * @returns {PIXI.Matrix} this */ copyFrom(matrix: Matrix): this { @@ -475,7 +457,6 @@ export class Matrix /** * A default (identity) matrix - * * @readonly */ static get IDENTITY(): Matrix @@ -485,7 +466,6 @@ export class Matrix /** * A temp matrix - * * @readonly */ static get TEMP_MATRIX(): Matrix diff --git a/packages/math/src/ObservablePoint.ts b/packages/math/src/ObservablePoint.ts index e8c9bb7beb..1943eb5dfb 100644 --- a/packages/math/src/ObservablePoint.ts +++ b/packages/math/src/ObservablePoint.ts @@ -8,7 +8,6 @@ export interface ObservablePoint extends GlobalMixins.Point, IPoint {} * the position on the horizontal axis and `y` represents the position on the vertical axis. * * An `ObservablePoint` is a point that triggers a callback when the point's position is changed. - * * @memberof PIXI */ export class ObservablePoint implements IPoint @@ -24,12 +23,11 @@ export class ObservablePoint implements IPoint /** * Creates a new `ObservablePoint` - * * @param cb - callback function triggered when `x` and/or `y` are changed * @param scope - owner of callback * @param {number} [x=0] - position of the point on the x axis * @param {number} [y=0] - position of the point on the y axis - */ + */ constructor(cb: (this: T) => any, scope: T, x = 0, y = 0) { this._x = x; @@ -43,11 +41,10 @@ export class ObservablePoint implements IPoint * Creates a clone of this point. * The callback and scope params can be overridden otherwise they will default * to the clone object's values. - * * @override * @param cb - The callback function triggered when `x` and/or `y` are changed * @param scope - The owner of the callback - * @return a copy of this observable point + * @returns a copy of this observable point */ clone(cb = this.cb, scope = this.scope): ObservablePoint { @@ -57,7 +54,6 @@ export class ObservablePoint implements IPoint /** * Sets the point to a new `x` and `y` position. * If `y` is omitted, both `x` and `y` will be set to `x`. - * * @param {number} [x=0] - position of the point on the x axis * @param {number} [y=x] - position of the point on the y axis * @returns The observable point instance itself @@ -76,7 +72,6 @@ export class ObservablePoint implements IPoint /** * Copies x and y from the given point (`p`) - * * @param p - The point to copy from. Can be any of type that is or extends `IPointData` * @returns The observable point instance itself */ @@ -94,7 +89,6 @@ export class ObservablePoint implements IPoint /** * Copies this point's x and y into that of the given point (`p`) - * * @param p - The point to copy to. Can be any of type that is or extends `IPointData` * @returns The point (`p`) with values updated */ @@ -107,7 +101,6 @@ export class ObservablePoint implements IPoint /** * Accepts another point (`p`) and returns `true` if the given point is equal to this point - * * @param p - The point to check * @returns Returns `true` if both `x` and `y` are equal */ diff --git a/packages/math/src/Point.ts b/packages/math/src/Point.ts index c18ae01c66..d7c37a8dc8 100644 --- a/packages/math/src/Point.ts +++ b/packages/math/src/Point.ts @@ -6,10 +6,9 @@ export interface Point extends GlobalMixins.Point, IPoint {} /** * The Point object represents a location in a two-dimensional coordinate system, where `x` represents * the position on the horizontal axis and `y` represents the position on the vertical axis - * * @class * @memberof PIXI - * @implements IPoint + * @implements {IPoint} */ export class Point implements IPoint { @@ -18,7 +17,8 @@ export class Point implements IPoint /** Position of the point on the y axis */ public y = 0; - /** Creates a new `Point` + /** + * Creates a new `Point` * @param {number} [x=0] - position of the point on the x axis * @param {number} [y=0] - position of the point on the y axis */ @@ -28,7 +28,8 @@ export class Point implements IPoint this.y = y; } - /** Creates a clone of this point + /** + * Creates a clone of this point * @returns A clone of this point */ clone(): Point @@ -38,7 +39,6 @@ export class Point implements IPoint /** * Copies `x` and `y` from the given point into this point - * * @param p - The point to copy from * @returns The point instance itself */ @@ -51,7 +51,6 @@ export class Point implements IPoint /** * Copies this point's x and y into the given point (`p`). - * * @param p - The point to copy to. Can be any of type that is or extends `IPointData` * @returns The point (`p`) with values updated */ @@ -64,7 +63,6 @@ export class Point implements IPoint /** * Accepts another point (`p`) and returns `true` if the given point is equal to this point - * * @param p - The point to check * @returns Returns `true` if both `x` and `y` are equal */ @@ -76,7 +74,6 @@ export class Point implements IPoint /** * Sets the point to a new `x` and `y` position. * If `y` is omitted, both `x` and `y` will be set to `x`. - * * @param {number} [x=0] - position of the point on the `x` axis * @param {number} [y=x] - position of the point on the `y` axis * @returns The point instance itself diff --git a/packages/math/src/Transform.ts b/packages/math/src/Transform.ts index a64d9ea50d..5f0d2d84fe 100644 --- a/packages/math/src/Transform.ts +++ b/packages/math/src/Transform.ts @@ -6,7 +6,6 @@ export interface Transform extends GlobalMixins.Transform {} /** * Transform that takes care about its versions. - * * @memberof PIXI */ export class Transform @@ -32,10 +31,7 @@ export class Transform /** The skew amount, on the x and y axis. */ public skew: ObservablePoint; - /** - * The locally unique ID of the parent's world transform - * used to calculate the current world transformation matrix. - */ + /** The locally unique ID of the parent's world transform used to calculate the current world transformation matrix. */ public _parentID: number; /** The locally unique ID of the world transform. */ @@ -71,10 +67,7 @@ export class Transform /** The locally unique ID of the local transform. */ protected _localID: number; - /** - * The locally unique ID of the local transform - * used to calculate the current local transformation matrix. - */ + /** The locally unique ID of the local transform used to calculate the current local transformation matrix. */ protected _currentLocalID: number; constructor() @@ -151,7 +144,6 @@ export class Transform /** * Updates the local and the world transformation matrices. - * * @param parentTransform - The parent transform */ updateTransform(parentTransform: Transform): void @@ -196,7 +188,6 @@ export class Transform /** * Decomposes a matrix and sets the transforms properties based on it. - * * @param matrix - The matrix to decompose */ setFromMatrix(matrix: Matrix): void diff --git a/packages/math/src/const.ts b/packages/math/src/const.ts index 6fcfbf8450..46a9138e25 100644 --- a/packages/math/src/const.ts +++ b/packages/math/src/const.ts @@ -1,6 +1,5 @@ /** * Two Pi. - * * @static * @member {number} * @memberof PIXI @@ -9,7 +8,6 @@ export const PI_2 = Math.PI * 2; /** * Conversion factor for converting radians to degrees. - * * @static * @member {number} RAD_TO_DEG * @memberof PIXI @@ -18,7 +16,6 @@ export const RAD_TO_DEG = 180 / Math.PI; /** * Conversion factor for converting degrees to radians. - * * @static * @member {number} * @memberof PIXI @@ -27,7 +24,6 @@ export const DEG_TO_RAD = Math.PI / 180; /** * Constants that identify shapes, mainly to prevent `instanceof` calls. - * * @static * @memberof PIXI * @enum {number} @@ -37,7 +33,9 @@ export const DEG_TO_RAD = Math.PI / 180; * @property {number} ELIP Ellipse * @property {number} RREC Rounded Rectangle */ -export enum SHAPES { +export enum SHAPES +// eslint-disable-next-line @typescript-eslint/indent +{ POLY = 0, RECT = 1, CIRC = 2, diff --git a/packages/math/src/groupD8.ts b/packages/math/src/groupD8.ts index b691181329..392a750dfc 100644 --- a/packages/math/src/groupD8.ts +++ b/packages/math/src/groupD8.ts @@ -19,16 +19,14 @@ const vy = [1, 1, 0, -1, -1, -1, 0, 1, -1, -1, 0, 1, 1, 1, 0, -1]; /** * [Cayley Table]{@link https://en.wikipedia.org/wiki/Cayley_table} * for the composition of each rotation in the dihederal group D8. - * - * @type number[][] + * @type {number[][]} * @private */ const rotationCayley: number[][] = []; /** * Matrices for each `GD8Symmetry` rotation. - * - * @type Matrix[] + * @type {PIXI.Matrix[]} * @private */ const rotationMatrices: Matrix[] = []; @@ -101,7 +99,6 @@ type GD8Symmetry = number; * * **Origin:**
* This is the small part of gameofbombs.com portal system. It works. - * * @see PIXI.groupD8.E * @see PIXI.groupD8.SE * @see PIXI.groupD8.S @@ -119,7 +116,6 @@ export const groupD8 = { * | Rotation | Direction | * |----------|-----------| * | 0° | East | - * * @memberof PIXI.groupD8 * @constant {PIXI.GD8Symmetry} */ @@ -129,7 +125,6 @@ export const groupD8 = { * | Rotation | Direction | * |----------|-----------| * | 45°↻ | Southeast | - * * @memberof PIXI.groupD8 * @constant {PIXI.GD8Symmetry} */ @@ -139,7 +134,6 @@ export const groupD8 = { * | Rotation | Direction | * |----------|-----------| * | 90°↻ | South | - * * @memberof PIXI.groupD8 * @constant {PIXI.GD8Symmetry} */ @@ -149,7 +143,6 @@ export const groupD8 = { * | Rotation | Direction | * |----------|-----------| * | 135°↻ | Southwest | - * * @memberof PIXI.groupD8 * @constant {PIXI.GD8Symmetry} */ @@ -159,7 +152,6 @@ export const groupD8 = { * | Rotation | Direction | * |----------|-----------| * | 180° | West | - * * @memberof PIXI.groupD8 * @constant {PIXI.GD8Symmetry} */ @@ -169,7 +161,6 @@ export const groupD8 = { * | Rotation | Direction | * |-------------|--------------| * | -135°/225°↻ | Northwest | - * * @memberof PIXI.groupD8 * @constant {PIXI.GD8Symmetry} */ @@ -179,7 +170,6 @@ export const groupD8 = { * | Rotation | Direction | * |-------------|--------------| * | -90°/270°↻ | North | - * * @memberof PIXI.groupD8 * @constant {PIXI.GD8Symmetry} */ @@ -189,7 +179,6 @@ export const groupD8 = { * | Rotation | Direction | * |-------------|--------------| * | -45°/315°↻ | Northeast | - * * @memberof PIXI.groupD8 * @constant {PIXI.GD8Symmetry} */ @@ -197,7 +186,6 @@ export const groupD8 = { /** * Reflection about Y-axis. - * * @memberof PIXI.groupD8 * @constant {PIXI.GD8Symmetry} */ @@ -205,7 +193,6 @@ export const groupD8 = { /** * Reflection about the main diagonal. - * * @memberof PIXI.groupD8 * @constant {PIXI.GD8Symmetry} */ @@ -213,7 +200,6 @@ export const groupD8 = { /** * Reflection about X-axis. - * * @memberof PIXI.groupD8 * @constant {PIXI.GD8Symmetry} */ @@ -221,7 +207,6 @@ export const groupD8 = { /** * Reflection about reverse diagonal. - * * @memberof PIXI.groupD8 * @constant {PIXI.GD8Symmetry} */ @@ -230,7 +215,7 @@ export const groupD8 = { /** * @memberof PIXI.groupD8 * @param {PIXI.GD8Symmetry} ind - sprite rotation angle. - * @return {PIXI.GD8Symmetry} The X-component of the U-axis + * @returns {PIXI.GD8Symmetry} The X-component of the U-axis * after rotating the axes. */ uX: (ind: GD8Symmetry): GD8Symmetry => ux[ind], @@ -238,7 +223,7 @@ export const groupD8 = { /** * @memberof PIXI.groupD8 * @param {PIXI.GD8Symmetry} ind - sprite rotation angle. - * @return {PIXI.GD8Symmetry} The Y-component of the U-axis + * @returns {PIXI.GD8Symmetry} The Y-component of the U-axis * after rotating the axes. */ uY: (ind: GD8Symmetry): GD8Symmetry => uy[ind], @@ -246,7 +231,7 @@ export const groupD8 = { /** * @memberof PIXI.groupD8 * @param {PIXI.GD8Symmetry} ind - sprite rotation angle. - * @return {PIXI.GD8Symmetry} The X-component of the V-axis + * @returns {PIXI.GD8Symmetry} The X-component of the V-axis * after rotating the axes. */ vX: (ind: GD8Symmetry): GD8Symmetry => vx[ind], @@ -254,7 +239,7 @@ export const groupD8 = { /** * @memberof PIXI.groupD8 * @param {PIXI.GD8Symmetry} ind - sprite rotation angle. - * @return {PIXI.GD8Symmetry} The Y-component of the V-axis + * @returns {PIXI.GD8Symmetry} The Y-component of the V-axis * after rotating the axes. */ vY: (ind: GD8Symmetry): GD8Symmetry => vy[ind], @@ -264,7 +249,7 @@ export const groupD8 = { * @param {PIXI.GD8Symmetry} rotation - symmetry whose opposite * is needed. Only rotations have opposite symmetries while * reflections don't. - * @return {PIXI.GD8Symmetry} The opposite symmetry of `rotation` + * @returns {PIXI.GD8Symmetry} The opposite symmetry of `rotation` */ inv: (rotation: GD8Symmetry): GD8Symmetry => { @@ -298,7 +283,7 @@ export const groupD8 = { * is the row in the above cayley table. * @param {PIXI.GD8Symmetry} rotationFirst - First operation, which * is the column in the above cayley table. - * @return {PIXI.GD8Symmetry} Composed operation + * @returns {PIXI.GD8Symmetry} Composed operation */ add: (rotationSecond: GD8Symmetry, rotationFirst: GD8Symmetry): GD8Symmetry => ( rotationCayley[rotationSecond][rotationFirst] @@ -306,11 +291,10 @@ export const groupD8 = { /** * Reverse of `add`. - * * @memberof PIXI.groupD8 * @param {PIXI.GD8Symmetry} rotationSecond - Second operation * @param {PIXI.GD8Symmetry} rotationFirst - First operation - * @return {PIXI.GD8Symmetry} Result + * @returns {PIXI.GD8Symmetry} Result */ sub: (rotationSecond: GD8Symmetry, rotationFirst: GD8Symmetry): GD8Symmetry => ( rotationCayley[rotationSecond][groupD8.inv(rotationFirst)] @@ -319,7 +303,6 @@ export const groupD8 = { /** * Adds 180 degrees to rotation, which is a commutative * operation. - * * @memberof PIXI.groupD8 * @param {number} rotation - The number to rotate. * @returns {number} Rotated number @@ -329,7 +312,6 @@ export const groupD8 = { /** * Checks if the rotation angle is vertical, i.e. south * or north. It doesn't work for reflections. - * * @memberof PIXI.groupD8 * @param {PIXI.GD8Symmetry} rotation - The number to check. * @returns {boolean} Whether or not the direction is vertical @@ -339,11 +321,10 @@ export const groupD8 = { /** * Approximates the vector `V(dx,dy)` into one of the * eight directions provided by `groupD8`. - * * @memberof PIXI.groupD8 * @param {number} dx - X-component of the vector * @param {number} dy - Y-component of the vector - * @return {PIXI.GD8Symmetry} Approximation of the vector into + * @returns {PIXI.GD8Symmetry} Approximation of the vector into * one of the eight symmetries. */ byDirection: (dx: number, dy: number): GD8Symmetry => @@ -385,7 +366,6 @@ export const groupD8 = { /** * Helps sprite to compensate texture packer rotation. - * * @memberof PIXI.groupD8 * @param {PIXI.Matrix} matrix - sprite world matrix * @param {PIXI.GD8Symmetry} rotation - The rotation factor to use. diff --git a/packages/math/src/shapes/Circle.ts b/packages/math/src/shapes/Circle.ts index 352bf9bb37..e0fac48236 100644 --- a/packages/math/src/shapes/Circle.ts +++ b/packages/math/src/shapes/Circle.ts @@ -3,7 +3,6 @@ import { Rectangle } from './Rectangle'; /** * The Circle object is used to help draw graphics and can also be used to specify a hit area for displayObjects. - * * @memberof PIXI */ export class Circle @@ -19,7 +18,6 @@ export class Circle /** * The type of the object, mainly used to avoid `instanceof` checks - * * @default PIXI.SHAPES.CIRC * @see PIXI.SHAPES */ @@ -41,8 +39,7 @@ export class Circle /** * Creates a clone of this Circle instance - * - * @return A copy of the Circle + * @returns A copy of the Circle */ clone(): Circle { @@ -51,10 +48,9 @@ export class Circle /** * Checks whether the x and y coordinates given are contained within this circle - * * @param x - The X coordinate of the point to test * @param y - The Y coordinate of the point to test - * @return Whether the x/y coordinates are within this Circle + * @returns Whether the x/y coordinates are within this Circle */ contains(x: number, y: number): boolean { @@ -74,10 +70,9 @@ export class Circle } /** - * Returns the framing rectangle of the circle as a Rectangle object - * - * @return The framing rectangle - */ + * Returns the framing rectangle of the circle as a Rectangle object + * @returns The framing rectangle + */ getBounds(): Rectangle { return new Rectangle(this.x - this.radius, this.y - this.radius, this.radius * 2, this.radius * 2); diff --git a/packages/math/src/shapes/Ellipse.ts b/packages/math/src/shapes/Ellipse.ts index 06310f3cb8..2915700f30 100644 --- a/packages/math/src/shapes/Ellipse.ts +++ b/packages/math/src/shapes/Ellipse.ts @@ -3,7 +3,6 @@ import { SHAPES } from '../const'; /** * The Ellipse object is used to help draw graphics and can also be used to specify a hit area for displayObjects. - * * @memberof PIXI */ export class Ellipse @@ -22,7 +21,6 @@ export class Ellipse /** * The type of the object, mainly used to avoid `instanceof` checks - * * @default PIXI.SHAPES.ELIP * @see PIXI.SHAPES */ @@ -46,8 +44,7 @@ export class Ellipse /** * Creates a clone of this Ellipse instance - * - * @return {PIXI.Ellipse} A copy of the ellipse + * @returns {PIXI.Ellipse} A copy of the ellipse */ clone(): Ellipse { @@ -56,10 +53,9 @@ export class Ellipse /** * Checks whether the x and y coordinates given are contained within this ellipse - * * @param x - The X coordinate of the point to test * @param y - The Y coordinate of the point to test - * @return Whether the x/y coords are within this ellipse + * @returns Whether the x/y coords are within this ellipse */ contains(x: number, y: number): boolean { @@ -80,8 +76,7 @@ export class Ellipse /** * Returns the framing rectangle of the ellipse as a Rectangle object - * - * @return The framing rectangle + * @returns The framing rectangle */ getBounds(): Rectangle { diff --git a/packages/math/src/shapes/Polygon.ts b/packages/math/src/shapes/Polygon.ts index b36bdc01e6..dc83538480 100644 --- a/packages/math/src/shapes/Polygon.ts +++ b/packages/math/src/shapes/Polygon.ts @@ -3,7 +3,6 @@ import type { IPointData } from '../IPointData'; /** * A class to define a shape via user defined coordinates. - * * @memberof PIXI */ export class Polygon @@ -16,14 +15,13 @@ export class Polygon /** * The type of the object, mainly used to avoid `instanceof` checks - * * @default PIXI.SHAPES.POLY * @see PIXI.SHAPES */ public readonly type: SHAPES.POLY; - constructor(points: IPointData[]|number[]); - constructor(...points: IPointData[]|number[]); + constructor(points: IPointData[] | number[]); + constructor(...points: IPointData[] | number[]); /** * @param {PIXI.IPointData[]|number[]} points - This can be an array of Points @@ -34,7 +32,7 @@ export class Polygon */ constructor(...points: any[]) { - let flat: IPointData[]|number[] = Array.isArray(points[0]) ? points[0] : points; + let flat: IPointData[] | number[] = Array.isArray(points[0]) ? points[0] : points; // if this is an array of points, convert it to a flat array of numbers if (typeof flat[0] !== 'number') @@ -56,8 +54,7 @@ export class Polygon /** * Creates a clone of this polygon. - * - * @return - A copy of the polygon. + * @returns - A copy of the polygon. */ clone(): Polygon { @@ -71,10 +68,9 @@ export class Polygon /** * Checks whether the x and y coordinates passed to this function are contained within this polygon. - * * @param x - The X coordinate of the point to test. * @param y - The Y coordinate of the point to test. - * @return - Whether the x/y coordinates are within this polygon. + * @returns - Whether the x/y coordinates are within this polygon. */ contains(x: number, y: number): boolean { diff --git a/packages/math/src/shapes/Rectangle.ts b/packages/math/src/shapes/Rectangle.ts index bb570f9782..40126362d7 100644 --- a/packages/math/src/shapes/Rectangle.ts +++ b/packages/math/src/shapes/Rectangle.ts @@ -9,15 +9,15 @@ export interface Rectangle extends GlobalMixins.Rectangle {} /** * Size object, contains width and height - * * @memberof PIXI * @typedef {object} ISize + * @property {number} width - Width component + * @property {number} height - Height component */ /** * Rectangle object is an area defined by its position, as indicated by its top-left corner * point (x, y) and by its width and its height. - * * @memberof PIXI */ export class Rectangle @@ -46,7 +46,7 @@ export class Rectangle * @param width - The overall width of the rectangle * @param height - The overall height of the rectangle */ - constructor(x = 0, y = 0, width = 0, height = 0) + constructor(x: string | number = 0, y: string | number = 0, width: string | number = 0, height: string | number = 0) { this.x = Number(x); this.y = Number(y); @@ -87,8 +87,7 @@ export class Rectangle /** * Creates a clone of this Rectangle - * - * @return a copy of the rectangle + * @returns a copy of the rectangle */ clone(): Rectangle { @@ -97,9 +96,8 @@ export class Rectangle /** * Copies another rectangle to this one. - * * @param rectangle - The rectangle to copy from. - * @return Returns itself. + * @returns Returns itself. */ copyFrom(rectangle: Rectangle): Rectangle { @@ -113,9 +111,8 @@ export class Rectangle /** * Copies this rectangle to another one. - * * @param rectangle - The rectangle to copy to. - * @return Returns given parameter. + * @returns Returns given parameter. */ copyTo(rectangle: Rectangle): Rectangle { @@ -129,10 +126,9 @@ export class Rectangle /** * Checks whether the x and y coordinates given are contained within this Rectangle - * * @param x - The X coordinate of the point to test * @param y - The Y coordinate of the point to test - * @return Whether the x/y coordinates are within this Rectangle + * @returns Whether the x/y coordinates are within this Rectangle */ contains(x: number, y: number): boolean { @@ -157,7 +153,6 @@ export class Rectangle * Returns true only if the area of the intersection is >0, this means that Rectangles * sharing a side are not overlapping. Another side effect is that an arealess rectangle * (width or height equal to zero) can't intersect any other rectangle. - * * @param {Rectangle} other - The Rectangle to intersect with `this`. * @param {Matrix} transform - The transformation matrix of `other`. * @returns {boolean} A value of `true` if the transformed `other` Rectangle intersects with `this`; otherwise `false`. @@ -252,10 +247,9 @@ export class Rectangle /** * Pads the rectangle making it grow in all directions. * If paddingY is omitted, both paddingX and paddingY will be set to paddingX. - * * @param paddingX - The horizontal padding amount. * @param paddingY - The vertical padding amount. - * @return Returns itself. + * @returns Returns itself. */ pad(paddingX = 0, paddingY = paddingX): this { @@ -270,9 +264,8 @@ export class Rectangle /** * Fits this rectangle around the passed one. - * * @param rectangle - The rectangle to fit. - * @return Returns itself. + * @returns Returns itself. */ fit(rectangle: Rectangle): this { @@ -291,10 +284,9 @@ export class Rectangle /** * Enlarges rectangle that way its corners lie on grid - * * @param resolution - resolution * @param eps - precision - * @return Returns itself. + * @returns Returns itself. */ ceil(resolution = 1, eps = 0.001): this { @@ -312,9 +304,8 @@ export class Rectangle /** * Enlarges this rectangle to include the passed rectangle. - * * @param rectangle - The rectangle to include. - * @return Returns itself. + * @returns Returns itself. */ enlarge(rectangle: Rectangle): this { diff --git a/packages/math/src/shapes/RoundedRectangle.ts b/packages/math/src/shapes/RoundedRectangle.ts index a569b2a968..cbcf73f259 100644 --- a/packages/math/src/shapes/RoundedRectangle.ts +++ b/packages/math/src/shapes/RoundedRectangle.ts @@ -3,7 +3,6 @@ import { SHAPES } from '../const'; /** * The Rounded Rectangle object is an area that has nice rounded corners, as indicated by its * top-left corner point (x, y) and by its width and its height and its radius. - * * @memberof PIXI */ export class RoundedRectangle @@ -25,7 +24,6 @@ export class RoundedRectangle /** * The type of the object, mainly used to avoid `instanceof` checks - * * @default PIXI.SHAPES.RREC * @see PIXI.SHAPES */ @@ -50,8 +48,7 @@ export class RoundedRectangle /** * Creates a clone of this Rounded Rectangle. - * - * @return - A copy of the rounded rectangle. + * @returns - A copy of the rounded rectangle. */ clone(): RoundedRectangle { @@ -60,10 +57,9 @@ export class RoundedRectangle /** * Checks whether the x and y coordinates given are contained within this Rounded Rectangle - * * @param x - The X coordinate of the point to test. * @param y - The Y coordinate of the point to test. - * @return - Whether the x/y coordinates are within this Rounded Rectangle. + * @returns - Whether the x/y coordinates are within this Rounded Rectangle. */ contains(x: number, y: number): boolean { diff --git a/packages/math/test/Circle.tests.ts b/packages/math/test/Circle.tests.ts index c6f50c7bd8..1e9c7fbc53 100644 --- a/packages/math/test/Circle.tests.ts +++ b/packages/math/test/Circle.tests.ts @@ -1,9 +1,9 @@ import { Circle } from '@pixi/math'; import { expect } from 'chai'; -describe('Circle', function () +describe('Circle', () => { - it('should create a new circle', function () + it('should create a new circle', () => { const circ1 = new Circle(); @@ -18,7 +18,7 @@ describe('Circle', function () expect(circ2.radius).to.equal(5); }); - it('should clone a new circle', function () + it('should clone a new circle', () => { const circ1 = new Circle(10, 10, 5); @@ -34,7 +34,7 @@ describe('Circle', function () expect(circ1).to.not.equal(circ2); }); - it('should check if point is within circle', function () + it('should check if point is within circle', () => { const circ1 = new Circle(10, 10, 5); @@ -60,7 +60,7 @@ describe('Circle', function () expect(circ2.contains(10, 10)).to.be.false; }); - it('should return framing rectangle', function () + it('should return framing rectangle', () => { const circ1 = new Circle(10, 10, 5); const rect1 = circ1.getBounds(); diff --git a/packages/math/test/Ellipse.tests.ts b/packages/math/test/Ellipse.tests.ts index ff63e7b075..4439b2149f 100644 --- a/packages/math/test/Ellipse.tests.ts +++ b/packages/math/test/Ellipse.tests.ts @@ -1,9 +1,9 @@ import { Ellipse } from '@pixi/math'; import { expect } from 'chai'; -describe('Ellipse', function () +describe('Ellipse', () => { - it('should create a new ellipse', function () + it('should create a new ellipse', () => { const ellipse1 = new Ellipse(); @@ -20,7 +20,7 @@ describe('Ellipse', function () expect(ellipse2.height).to.equal(5); }); - it('should clone a new ellipse', function () + it('should clone a new ellipse', () => { const ellipse1 = new Ellipse(10, 10, 5, 5); @@ -37,7 +37,7 @@ describe('Ellipse', function () expect(ellipse2.height).to.equal(5); }); - it('should check if point is within ellipse', function () + it('should check if point is within ellipse', () => { const ellipse1 = new Ellipse(10, 10, 5, 5); @@ -63,7 +63,7 @@ describe('Ellipse', function () expect(ellipse2.contains(10, 10)).to.be.false; }); - it('should return framing rectangle', function () + it('should return framing rectangle', () => { const ellipse1 = new Ellipse(10, 10, 5, 5); const rect1 = ellipse1.getBounds(); diff --git a/packages/math/test/Matrix.tests.ts b/packages/math/test/Matrix.tests.ts index 56e3f944f5..8461664714 100644 --- a/packages/math/test/Matrix.tests.ts +++ b/packages/math/test/Matrix.tests.ts @@ -1,9 +1,9 @@ import { Matrix, Transform } from '@pixi/math'; import { expect } from 'chai'; -describe('Matrix', function () +describe('Matrix', () => { - it('should create a new matrix', function () + it('should create a new matrix', () => { const matrix = new Matrix(); @@ -46,7 +46,7 @@ describe('Matrix', function () expect(output[5]).to.equal(5); }); - it('should apply different transforms', function () + it('should apply different transforms', () => { const matrix = new Matrix(); @@ -82,7 +82,7 @@ describe('Matrix', function () expect(matrix.ty).to.equal(15); }); - it('should allow rotatation', function () + it('should allow rotatation', () => { const matrix = new Matrix(); @@ -94,7 +94,7 @@ describe('Matrix', function () expect(matrix.d).to.equal(-1); }); - it('should append matrix', function () + it('should append matrix', () => { const m1 = new Matrix(); const m2 = new Matrix(); @@ -108,7 +108,7 @@ describe('Matrix', function () expect(m1.ty).to.equal(m2.ty); }); - it('should prepend matrix', function () + it('should prepend matrix', () => { const m1 = new Matrix(); const m2 = new Matrix(); @@ -136,13 +136,13 @@ describe('Matrix', function () expect(m3.ty).to.equal(m4.ty); }); - it('should get IDENTITY and TEMP_MATRIX', function () + it('should get IDENTITY and TEMP_MATRIX', () => { expect(Matrix.IDENTITY instanceof Matrix).to.be.true; expect(Matrix.TEMP_MATRIX instanceof Matrix).to.be.true; }); - it('should reset matrix to default when identity() is called', function () + it('should reset matrix to default when identity() is called', () => { const matrix = new Matrix(); @@ -165,7 +165,7 @@ describe('Matrix', function () expect(matrix.ty).to.equal(0); }); - it('should have the same transform after decompose', function () + it('should have the same transform after decompose', () => { const matrix = new Matrix(); const transformInitial = new Transform(); @@ -182,7 +182,7 @@ describe('Matrix', function () transformInitial.skew.y = (Math.random() - 2) * Math.PI; matrix.setTransform( - transformInitial.x, transformInitial.y, + transformInitial.position.x, transformInitial.position.y, 0, 0, transformInitial.scale.x, transformInitial.scale.y, transformInitial.rotation, @@ -190,16 +190,19 @@ describe('Matrix', function () ); matrix.decompose(transformDecomposed); - expect(transformInitial.a).to.equal(transformDecomposed.a); - expect(transformInitial.b).to.equal(transformDecomposed.b); - expect(transformInitial.c).to.equal(transformDecomposed.c); - expect(transformInitial.d).to.equal(transformDecomposed.d); - expect(transformInitial.tx).to.equal(transformDecomposed.tx); - expect(transformInitial.ty).to.equal(transformDecomposed.ty); + transformInitial.updateLocalTransform(); + transformDecomposed.updateLocalTransform(); + + expect(transformInitial.localTransform.a).to.be.closeTo(transformDecomposed.localTransform.a, 0.0001); + expect(transformInitial.localTransform.b).to.be.closeTo(transformDecomposed.localTransform.b, 0.0001); + expect(transformInitial.localTransform.c).to.be.closeTo(transformDecomposed.localTransform.c, 0.0001); + expect(transformInitial.localTransform.d).to.be.closeTo(transformDecomposed.localTransform.d, 0.0001); + expect(transformInitial.localTransform.tx).to.be.closeTo(transformDecomposed.localTransform.tx, 0.0001); + expect(transformInitial.localTransform.ty).to.be.closeTo(transformDecomposed.localTransform.ty, 0.0001); } }); - it('should decompose corner case', function () + it('should decompose corner case', () => { const matrix = new Matrix(); const transform = new Transform(); @@ -218,9 +221,9 @@ describe('Matrix', function () expect(result.d).to.closeTo(matrix.d, 0.001); }); - describe('decompose', function () + describe('decompose', () => { - it('should be the inverse of updateLocalTransform even when pivot is set', function () + it('should be the inverse of updateLocalTransform even when pivot is set', () => { const matrix = new Matrix(0.01, 0.04, 0.04, 0.1, 2, 2); const transform = new Transform(); diff --git a/packages/math/test/ObservablePoint.tests.ts b/packages/math/test/ObservablePoint.tests.ts index 07342a9dc7..35bce2d27a 100644 --- a/packages/math/test/ObservablePoint.tests.ts +++ b/packages/math/test/ObservablePoint.tests.ts @@ -2,9 +2,9 @@ import { ObservablePoint } from '@pixi/math'; import sinon from 'sinon'; import { expect } from 'chai'; -describe('ObservablePoint', function () +describe('ObservablePoint', () => { - it('should create a new observable point', function () + it('should create a new observable point', () => { const cb = sinon.spy(); const pt = new ObservablePoint(cb, this); @@ -33,7 +33,7 @@ describe('ObservablePoint', function () expect(cb.callCount).to.equal(4); }); - it('should copy a new observable point', function () + it('should copy a new observable point', () => { function cb() { diff --git a/packages/math/test/Point.tests.ts b/packages/math/test/Point.tests.ts index 8470147fab..dbd47b76ec 100644 --- a/packages/math/test/Point.tests.ts +++ b/packages/math/test/Point.tests.ts @@ -1,9 +1,9 @@ import { Point } from '@pixi/math'; import { expect } from 'chai'; -describe('Point', function () +describe('Point', () => { - it('should create a new point', function () + it('should create a new point', () => { const pt = new Point(); @@ -11,7 +11,7 @@ describe('Point', function () expect(pt.y).to.equal(0); }); - it('should clone a new point', function () + it('should clone a new point', () => { const p1 = new Point(10, 20); @@ -26,7 +26,7 @@ describe('Point', function () expect(p1.equals(p2)).to.be.true; }); - it('should copy from one point to another', function () + it('should copy from one point to another', () => { const p1 = new Point(10, 20); const p2 = new Point(2, 5); @@ -37,7 +37,7 @@ describe('Point', function () expect(p1.y).to.equal(5); }); - it('should set a new value', function () + it('should set a new value', () => { const p1 = new Point(10, 20); diff --git a/packages/math/test/Polygon.tests.ts b/packages/math/test/Polygon.tests.ts index d3a5f0db22..7ff0ccde6e 100644 --- a/packages/math/test/Polygon.tests.ts +++ b/packages/math/test/Polygon.tests.ts @@ -1,18 +1,18 @@ import { Polygon, Point } from '@pixi/math'; import { expect } from 'chai'; -describe('Polygon', function () +describe('Polygon', () => { - describe('constructor', function () + describe('constructor', () => { - it('should accept a spread of values', function () + it('should accept a spread of values', () => { const polygon = new Polygon(0, 0, 10, 0, 0, 10); expect(polygon.points.length).to.be.equals(6); }); - it('should accept a spread of points', function () + it('should accept a spread of points', () => { const polygon = new Polygon( new Point(0, 0), @@ -23,14 +23,14 @@ describe('Polygon', function () expect(polygon.points.length).to.be.equals(6); }); - it('should accept an array of values', function () + it('should accept an array of values', () => { const polygon = new Polygon([0, 0, 10, 0, 0, 10]); expect(polygon.points.length).to.be.equals(6); }); - it('should accept an array of points', function () + it('should accept an array of points', () => { const polygon = new Polygon([ new Point(0, 0), @@ -42,9 +42,9 @@ describe('Polygon', function () }); }); - describe('clone', function () + describe('clone', () => { - it('should create a copy', function () + it('should create a copy', () => { const polygon1 = new Polygon(0, 0, 10, 0, 0, 10); @@ -68,9 +68,9 @@ describe('Polygon', function () }); }); - describe('contains', function () + describe('contains', () => { - it('should include points inside', function () + it('should include points inside', () => { const polygon = new Polygon(0, 0, 10, 0, 10, 10, 0, 10, 0, 0); @@ -80,7 +80,7 @@ describe('Polygon', function () expect(polygon.contains(9, 9)).to.be.true; }); - it('should exclude bounds', function () + it('should exclude bounds', () => { const polygon = new Polygon(0, 0, 10, 0, 10, 10, 0, 10, 0, 0); @@ -90,7 +90,7 @@ describe('Polygon', function () expect(polygon.contains(10, 10)).to.be.false; }); - it('should exclude points outside', function () + it('should exclude points outside', () => { const polygon = new Polygon(0, 0, 10, 0, 10, 10, 0, 10, 0, 0); diff --git a/packages/math/test/Rectangle.tests.ts b/packages/math/test/Rectangle.tests.ts index 0a51b09582..f2c3c1a820 100644 --- a/packages/math/test/Rectangle.tests.ts +++ b/packages/math/test/Rectangle.tests.ts @@ -1,9 +1,9 @@ import { Rectangle, Matrix } from '@pixi/math'; import { expect } from 'chai'; -describe('Rectangle', function () +describe('Rectangle', () => { - it('should create a new rectangle', function () + it('should create a new rectangle', () => { const rect = new Rectangle(5, 5, 1, 1); @@ -13,7 +13,7 @@ describe('Rectangle', function () expect(rect.bottom).to.equal(6); }); - it('should cast quantities to number types', function () + it('should cast quantities to number types', () => { const rect = new Rectangle('5', '5', '1', '1'); @@ -23,7 +23,7 @@ describe('Rectangle', function () expect(rect.bottom).to.equal(6); }); - it('should clone a new rectangle', function () + it('should clone a new rectangle', () => { const rect1 = new Rectangle(10, 10, 10, 10); @@ -41,7 +41,7 @@ describe('Rectangle', function () expect(rect1).to.not.equal(rect2); }); - it('should copy from one rectangle to another', function () + it('should copy from one rectangle to another', () => { const rect1 = new Rectangle(10, 10, 10, 10); const rect2 = new Rectangle(2, 2, 5, 5); @@ -54,7 +54,7 @@ describe('Rectangle', function () expect(rect1.height).to.equal(5); }); - it('should check if point is within rectangle', function () + it('should check if point is within rectangle', () => { const rect1 = new Rectangle(10, 10, 10, 10); @@ -78,7 +78,7 @@ describe('Rectangle', function () expect(rect2.contains(21, 21)).to.be.false; }); - it('should enlarge rectangle', function () + it('should enlarge rectangle', () => { const rect1 = new Rectangle(10, 10, 10, 10); const rect2 = new Rectangle(15, 15, 10, 10); @@ -101,7 +101,7 @@ describe('Rectangle', function () expect(rect4.bottom).to.equal(20); }); - it('should pad a rectangle', function () + it('should pad a rectangle', () => { // Pad with X & Y const rect = new Rectangle(10, 10, 10, 10); @@ -144,7 +144,7 @@ describe('Rectangle', function () expect(rect3.bottom).to.equal(30); }); - it('should fit a rectangle', function () + it('should fit a rectangle', () => { const rect1 = new Rectangle(0, 0, 10, 10); const rect2 = new Rectangle(-10, -10, 5, 5); @@ -187,7 +187,7 @@ describe('Rectangle', function () expect(rect7.bottom).to.equal(19); }); - it('should generate an empty rectangle', function () + it('should generate an empty rectangle', () => { const rect = Rectangle.EMPTY; @@ -197,7 +197,7 @@ describe('Rectangle', function () expect(rect.bottom).to.equal(0); }); - it('should return true if the area of the intersection > 0', function () + it('should return true if the area of the intersection > 0', () => { /* ! SHARING A SIDE IS NOT INTERSECTING ! diff --git a/packages/math/test/RoundedRectangle.tests.ts b/packages/math/test/RoundedRectangle.tests.ts index 9774714fb2..15056c3b37 100644 --- a/packages/math/test/RoundedRectangle.tests.ts +++ b/packages/math/test/RoundedRectangle.tests.ts @@ -1,9 +1,9 @@ import { RoundedRectangle } from '@pixi/math'; import { expect } from 'chai'; -describe('RoundedRectangle', function () +describe('RoundedRectangle', () => { - it('should create a new rounded rectangle', function () + it('should create a new rounded rectangle', () => { const rrect = new RoundedRectangle(5, 5, 1, 1); @@ -14,7 +14,7 @@ describe('RoundedRectangle', function () expect(rrect.radius).to.equal(20); }); - it('should clone a new rounded rectangle', function () + it('should clone a new rounded rectangle', () => { const rrect1 = new RoundedRectangle(0, 0, 100, 100, 40); @@ -34,7 +34,7 @@ describe('RoundedRectangle', function () expect(rrect1).to.not.equal(rrect2); }); - it('should check if point is within rounded rectangle', function () + it('should check if point is within rounded rectangle', () => { const rrect1 = new RoundedRectangle(0, 0, 200, 200, 50); diff --git a/packages/math/test/Transform.tests.ts b/packages/math/test/Transform.tests.ts index 47c18da5cc..84707e5af6 100644 --- a/packages/math/test/Transform.tests.ts +++ b/packages/math/test/Transform.tests.ts @@ -1,11 +1,11 @@ import { Transform } from '@pixi/math'; import { expect } from 'chai'; -describe('Transform', function () +describe('Transform', () => { - describe('setFromMatrix', function () + describe('setFromMatrix', () => { - it('should decompose negative scale into rotation', function () + it('should decompose negative scale into rotation', () => { const eps = 1e-3; @@ -33,7 +33,7 @@ describe('Transform', function () expect(otherTransform.rotation).to.be.closeTo(-5 * Math.PI / 6, eps); }); - it('should decompose mirror into skew', function () + it('should decompose mirror into skew', () => { const eps = 1e-3; @@ -61,7 +61,7 @@ describe('Transform', function () expect(otherTransform.rotation).to.equal(0); }); - it('should apply skew before scale, like in adobe animate and spine', function () + it('should apply skew before scale, like in adobe animate and spine', () => { // this example looks the same in CSS and in pixi, made with pixi-animate by @bigtimebuddy diff --git a/packages/mesh-extras/package.json b/packages/mesh-extras/package.json index e04a5de993..af0204e1f8 100644 --- a/packages/mesh-extras/package.json +++ b/packages/mesh-extras/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/mesh-extras", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/mesh-extras.js", "module": "dist/esm/mesh-extras.js", "bundle": "dist/browser/mesh-extras.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/mesh-extras.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/mesh-extras.js" + } + } + }, "description": "Custom Mesh display objects, like Rope and SimplePlane", "author": "Mat Groves", "contributors": [ @@ -25,10 +38,10 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/constants": "6.3.0", - "@pixi/core": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/mesh": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/constants": "6.4.2", + "@pixi/core": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/mesh": "6.4.2", + "@pixi/utils": "6.4.2" } } diff --git a/packages/mesh-extras/src/NineSlicePlane.ts b/packages/mesh-extras/src/NineSlicePlane.ts index b637e4c2dd..c0ed986238 100644 --- a/packages/mesh-extras/src/NineSlicePlane.ts +++ b/packages/mesh-extras/src/NineSlicePlane.ts @@ -26,14 +26,12 @@ export interface NineSlicePlane extends GlobalMixins.NineSlicePlane {} * +---+----------------------+---+ * D | 7 | 8 | 9 | * +---+----------------------+---+ - * When changing this objects width and/or height: * areas 1 3 7 and 9 will remain unscaled. * areas 2 and 8 will be stretched horizontally * areas 4 and 6 will be stretched vertically * area 5 will be stretched both horizontally and vertically * - * * @memberof PIXI */ export class NineSlicePlane extends SimplePlane @@ -43,28 +41,24 @@ export class NineSlicePlane extends SimplePlane /** * The width of the left column (a). - * * @private */ _leftWidth: number; /** * The width of the right column (b) - * * @private */ _rightWidth: number; /** * The height of the top row (c) - * * @private */ _topHeight: number; /** * The height of the bottom row (d) - * * @private */ _bottomHeight: number; @@ -146,8 +140,7 @@ export class NineSlicePlane extends SimplePlane /** * Returns the smaller of a set of vertical and horizontal scale of nine slice corners. - * - * @return Smaller number of vertical and horizontal scale. + * @returns Smaller number of vertical and horizontal scale. */ private _getMinScale(): number { diff --git a/packages/mesh-extras/src/SimpleMesh.ts b/packages/mesh-extras/src/SimpleMesh.ts index 29e8512f59..41cde93eb9 100644 --- a/packages/mesh-extras/src/SimpleMesh.ts +++ b/packages/mesh-extras/src/SimpleMesh.ts @@ -7,7 +7,6 @@ import type { DRAW_MODES } from '@pixi/constants'; /** * The Simple Mesh class mimics Mesh in PixiJS v4, providing easy-to-use constructor arguments. * For more robust customization, use {@link PIXI.Mesh}. - * * @memberof PIXI */ export class SimpleMesh extends Mesh diff --git a/packages/mesh-extras/src/SimplePlane.ts b/packages/mesh-extras/src/SimplePlane.ts index 0b9c52cdac..9dd32e43af 100644 --- a/packages/mesh-extras/src/SimplePlane.ts +++ b/packages/mesh-extras/src/SimplePlane.ts @@ -14,7 +14,6 @@ import type { IDestroyOptions } from '@pixi/display'; * }; * let SimplePlane = new PIXI.SimplePlane(PIXI.Texture.from("snake.png"), points); * ``` - * * @memberof PIXI */ export class SimplePlane extends Mesh @@ -29,7 +28,7 @@ export class SimplePlane extends Mesh * @param verticesX - The number of vertices in the x-axis * @param verticesY - The number of vertices in the y-axis */ - constructor(texture: Texture, verticesX: number, verticesY: number) + constructor(texture: Texture, verticesX?: number, verticesY?: number) { const planeGeometry = new PlaneGeometry(texture.width, texture.height, verticesX, verticesY); const meshMaterial = new MeshMaterial(Texture.WHITE); @@ -99,7 +98,7 @@ export class SimplePlane extends Mesh super._render(renderer); } - public destroy(options?: IDestroyOptions|boolean): void + public destroy(options?: IDestroyOptions | boolean): void { this.shader.texture.off('update', this.textureUpdated, this); super.destroy(options); diff --git a/packages/mesh-extras/src/SimpleRope.ts b/packages/mesh-extras/src/SimpleRope.ts index 0d94dbfdb0..a3e3506b10 100644 --- a/packages/mesh-extras/src/SimpleRope.ts +++ b/packages/mesh-extras/src/SimpleRope.ts @@ -14,7 +14,6 @@ import type { IPoint } from '@pixi/math'; * }; * let rope = new PIXI.SimpleRope(PIXI.Texture.from("snake.png"), points); * ``` - * * @memberof PIXI */ export class SimpleRope extends Mesh @@ -42,7 +41,6 @@ export class SimpleRope extends Mesh /** * re-calculate vertices by rope points each frame - * * @member {boolean} */ this.autoUpdate = true; diff --git a/packages/mesh-extras/src/geometry/RopeGeometry.ts b/packages/mesh-extras/src/geometry/RopeGeometry.ts index 72b10d83b3..2b7fbe43f4 100644 --- a/packages/mesh-extras/src/geometry/RopeGeometry.ts +++ b/packages/mesh-extras/src/geometry/RopeGeometry.ts @@ -10,7 +10,6 @@ import type { IPoint } from '@pixi/math'; * }; * const rope = new PIXI.RopeGeometry(100, points); * ``` - * * @memberof PIXI */ export class RopeGeometry extends MeshGeometry @@ -23,7 +22,6 @@ export class RopeGeometry extends MeshGeometry /** * The width (i.e., thickness) of the rope. - * * @readonly */ _width: number; @@ -54,8 +52,7 @@ export class RopeGeometry extends MeshGeometry /** * The width (i.e., thickness) of the rope. - * - * @readOnly + * @readonly */ get width(): number { @@ -150,9 +147,7 @@ export class RopeGeometry extends MeshGeometry this.updateVertices(); } - /** - * refreshes vertices of Rope mesh - */ + /** refreshes vertices of Rope mesh */ public updateVertices(): void { const points = this.points; diff --git a/packages/mesh-extras/test/NineSlicePlane.tests.ts b/packages/mesh-extras/test/NineSlicePlane.tests.ts index e6d1e8a526..cb11852984 100644 --- a/packages/mesh-extras/test/NineSlicePlane.tests.ts +++ b/packages/mesh-extras/test/NineSlicePlane.tests.ts @@ -5,9 +5,9 @@ import { expect } from 'chai'; skipHello(); -describe('NineSlicePlane', function () +describe('NineSlicePlane', () => { - it('should be able to create an instance', function () + it('should be able to create an instance', () => { const plane = new NineSlicePlane(Texture.WHITE); @@ -22,19 +22,19 @@ describe('NineSlicePlane', function () plane.destroy(); }); - it('shold return correct scaling for NineSlicePlane corners', function () + it('shold return correct scaling for NineSlicePlane corners', () => { const plane = new NineSlicePlane(Texture.EMPTY, 10, 10, 10, 10); plane.width = 100; plane.height = 100; - expect(plane._getMinScale()).to.equal(1); + expect(plane['_getMinScale']()).to.equal(1); plane.width = 10; plane.height = 100; - expect(plane._getMinScale()).to.equal(0.5); + expect(plane['_getMinScale']()).to.equal(0.5); plane.width = 100; plane.height = 10; - expect(plane._getMinScale()).to.equal(0.5); + expect(plane['_getMinScale']()).to.equal(0.5); plane.destroy(); }); diff --git a/packages/mesh-extras/test/SimpleMesh.tests.ts b/packages/mesh-extras/test/SimpleMesh.tests.ts index 509aeadbc5..2316ea4329 100644 --- a/packages/mesh-extras/test/SimpleMesh.tests.ts +++ b/packages/mesh-extras/test/SimpleMesh.tests.ts @@ -5,9 +5,9 @@ import { expect } from 'chai'; skipHello(); -describe('SimpleMesh', function () +describe('SimpleMesh', () => { - it('should create a simple mesh with defaults', function () + it('should create a simple mesh with defaults', () => { const mesh = new SimpleMesh(); @@ -17,7 +17,7 @@ describe('SimpleMesh', function () mesh.destroy(); }); - it('should render the rope', function () + it('should render the rope', () => { Renderer.registerPlugin('batch', BatchRenderer); diff --git a/packages/mesh-extras/test/SimplePlane.tests.ts b/packages/mesh-extras/test/SimplePlane.tests.ts index 926d680a00..f7384646b0 100644 --- a/packages/mesh-extras/test/SimplePlane.tests.ts +++ b/packages/mesh-extras/test/SimplePlane.tests.ts @@ -1,4 +1,4 @@ -import { SimplePlane } from '@pixi/mesh-extras'; +import { PlaneGeometry, SimplePlane } from '@pixi/mesh-extras'; import { skipHello } from '@pixi/utils'; import { Loader } from '@pixi/loaders'; import { Point } from '@pixi/math'; @@ -8,34 +8,34 @@ import { expect } from 'chai'; skipHello(); // TODO: fix with webglrenderer -describe('SimplePlane', function () +describe('SimplePlane', () => { - it('should create a plane from an external image', function (done) + it('should create a plane from an external image', (done) => { const loader = new Loader(); loader.add('testBitmap', `file://${__dirname}/resources/bitmap-1.png`) - .load(function (loader, resources) + .load((_loader, resources) => { const plane = new SimplePlane(resources.testBitmap.texture, 100, 100); - expect(plane.geometry.segWidth).to.equal(100); - expect(plane.geometry.segHeight).to.equal(100); + expect((plane.geometry as PlaneGeometry).segWidth).to.equal(100); + expect((plane.geometry as PlaneGeometry).segHeight).to.equal(100); done(); }); }); - it('should create a new empty textured SimplePlane', function () + it('should create a new empty textured SimplePlane', () => { const plane = new SimplePlane(Texture.EMPTY, 100, 100); - expect(plane.geometry.segWidth).to.equal(100); - expect(plane.geometry.segHeight).to.equal(100); + expect((plane.geometry as PlaneGeometry).segWidth).to.equal(100); + expect((plane.geometry as PlaneGeometry).segHeight).to.equal(100); }); - describe('containsPoint', function () + describe('containsPoint', () => { - it('should return true when point inside', function () + it('should return true when point inside', () => { const point = new Point(10, 10); const texture = RenderTexture.create({ width: 20, height: 30 }); @@ -44,7 +44,7 @@ describe('SimplePlane', function () expect(plane.containsPoint(point)).to.be.true; }); - it('should return false when point outside', function () + it('should return false when point outside', () => { const point = new Point(100, 100); const texture = RenderTexture.create({ width: 20, height: 30 }); @@ -54,7 +54,7 @@ describe('SimplePlane', function () }); }); - it('should render the plane', function () + it('should render the plane', () => { Renderer.registerPlugin('batch', BatchRenderer); diff --git a/packages/mesh-extras/test/SimpleRope.tests.ts b/packages/mesh-extras/test/SimpleRope.tests.ts index 6ffe55b2b8..e1c7f52f7a 100644 --- a/packages/mesh-extras/test/SimpleRope.tests.ts +++ b/packages/mesh-extras/test/SimpleRope.tests.ts @@ -7,14 +7,14 @@ import { expect } from 'chai'; skipHello(); -describe('SimpleRope', function () +describe('SimpleRope', () => { - it('should create a rope from an external image', function (done: () => void) + it('should create a rope from an external image', (done: () => void) => { const loader = new Loader(); loader.add('testBitmap', `file://${__dirname}/resources/bitmap-1.png`) - .load(function (loader, resources) + .load((loader, resources) => { const rope = new SimpleRope(resources.testBitmap.texture, [new Point(0, 0), new Point(0, 1)]); @@ -30,7 +30,7 @@ describe('SimpleRope', function () }); }); - it('should render the rope', function () + it('should render the rope', () => { Renderer.registerPlugin('batch', BatchRenderer); diff --git a/packages/mesh/package.json b/packages/mesh/package.json index c214d097c0..54170f1a37 100644 --- a/packages/mesh/package.json +++ b/packages/mesh/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/mesh", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/mesh.js", "module": "dist/esm/mesh.js", "bundle": "dist/browser/mesh.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/mesh.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/mesh.js" + } + } + }, "description": "Core Mesh functionality", "author": "Mat Groves", "contributors": [ @@ -25,11 +38,11 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/constants": "6.3.0", - "@pixi/core": "6.3.0", - "@pixi/display": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/settings": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/constants": "6.4.2", + "@pixi/core": "6.4.2", + "@pixi/display": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/settings": "6.4.2", + "@pixi/utils": "6.4.2" } } diff --git a/packages/mesh/src/Mesh.ts b/packages/mesh/src/Mesh.ts index a1002e703a..5d2ce7bf09 100644 --- a/packages/mesh/src/Mesh.ts +++ b/packages/mesh/src/Mesh.ts @@ -29,7 +29,6 @@ export interface Mesh extends GlobalMixins.Mesh {} * - State - This is the state of WebGL required to render the mesh. * * Through a combination of the above elements you can render anything you want, 2D or 3D! - * * @memberof PIXI */ export class Mesh extends Container @@ -37,7 +36,6 @@ export class Mesh extends Container /** * Represents the vertex and fragment shaders that processes the geometry and runs on the GPU. * Can be shared between multiple Mesh objects. - * * @type {PIXI.Shader|PIXI.MeshMaterial} */ public shader: T; @@ -53,14 +51,12 @@ export class Mesh extends Container /** * Typically the index of the IndexBuffer where to start drawing. - * * @default 0 */ public start: number; /** * How much of the geometry to draw, by default `0` renders everything. - * * @default 0 */ public size: number; @@ -70,10 +66,7 @@ export class Mesh extends Container /** This is the caching layer used by the batcher. */ private vertexData: Float32Array; - /** - * If geometry is changed used to decide to re-transform - * the vertexData. - */ + /** If geometry is changed used to decide to re-transform the vertexData. */ private vertexDirty: number; private _transformID: number; @@ -86,14 +79,12 @@ export class Mesh extends Container // Internal-only properties /** * These are used as easy access for batching. - * * @private */ uvs: Float32Array; /** * These are used as easy access for batching. - * * @private */ indices: Uint16Array; @@ -167,7 +158,6 @@ export class Mesh extends Container /** * To change mesh uv's, change its uvBuffer data and increment its _updateID. - * * @readonly */ get uvBuffer(): Buffer @@ -178,7 +168,6 @@ export class Mesh extends Container /** * To change mesh vertices, change its uvBuffer data and increment its _updateID. * Incrementing _updateID is optional because most of Mesh objects do it anyway. - * * @readonly */ get verticesBuffer(): Buffer @@ -200,7 +189,6 @@ export class Mesh extends Container /** * The blend mode to be applied to the Mesh. Apply a value of * `PIXI.BLEND_MODES.NORMAL` to reset the blend mode. - * * @default PIXI.BLEND_MODES.NORMAL; */ set blendMode(value: BLEND_MODES) @@ -218,7 +206,6 @@ export class Mesh extends Container * Advantages can include sharper image quality (like text) and faster rendering on canvas. * The main disadvantage is movement of objects may appear less smooth. * To set the global default, change {@link PIXI.settings.ROUND_PIXELS} - * * @default false */ set roundPixels(value: boolean) @@ -240,7 +227,6 @@ export class Mesh extends Container * `0xFFFFFF` will remove any tint effect. * * Null for non-MeshMaterial shaders - * * @default 0xFFFFFF */ get tint(): number @@ -253,11 +239,7 @@ export class Mesh extends Container (this.shader as unknown as MeshMaterial).tint = value; } - /** - * The texture that the Mesh uses. - * - * Null for non-MeshMaterial shaders - */ + /** The texture that the Mesh uses. Null for non-MeshMaterial shaders */ get texture(): Texture { return 'texture' in this.shader ? (this.shader as unknown as MeshMaterial).texture : null; @@ -270,7 +252,6 @@ export class Mesh extends Container /** * Standard renderer draw. - * * @param renderer - Instance to renderer. */ protected _render(renderer: Renderer): void @@ -297,7 +278,6 @@ export class Mesh extends Container /** * Standard non-batching way of rendering. - * * @param renderer - Instance to renderer. */ protected _renderDefault(renderer: Renderer): void @@ -328,7 +308,6 @@ export class Mesh extends Container /** * Rendering by using the Batch system. - * * @param renderer - Instance to renderer. */ protected _renderToBatch(renderer: Renderer): void @@ -440,9 +419,8 @@ export class Mesh extends Container /** * Tests if a point is inside this mesh. Works only for PIXI.DRAW_MODES.TRIANGLES. - * * @param point - The point to test. - * @return - The result of the test. + * @returns - The result of the test. */ public containsPoint(point: IPointData): boolean { @@ -482,7 +460,7 @@ export class Mesh extends Container return false; } - public destroy(options?: IDestroyOptions|boolean): void + public destroy(options?: IDestroyOptions | boolean): void { super.destroy(options); @@ -500,9 +478,6 @@ export class Mesh extends Container this.vertexData = null; } - /** - * The maximum number of vertices to consider batchable. Generally, the complexity - * of the geometry. - */ + /** The maximum number of vertices to consider batchable. Generally, the complexity of the geometry. */ public static BATCHABLE_SIZE = 100; } diff --git a/packages/mesh/src/MeshBatchUvs.ts b/packages/mesh/src/MeshBatchUvs.ts index 3fbc0fc53c..5c1b6ba08c 100644 --- a/packages/mesh/src/MeshBatchUvs.ts +++ b/packages/mesh/src/MeshBatchUvs.ts @@ -2,7 +2,6 @@ import type { TextureMatrix, Buffer } from '@pixi/core'; /** * Class controls cache for UV mapping from Texture normal space to BaseTexture normal space. - * * @memberof PIXI */ export class MeshBatchUvs @@ -39,7 +38,6 @@ export class MeshBatchUvs /** * Updates - * * @param forceUpdate - force the update */ public update(forceUpdate?: boolean): void diff --git a/packages/mesh/src/MeshGeometry.ts b/packages/mesh/src/MeshGeometry.ts index adf48f5be9..1e8618dca3 100644 --- a/packages/mesh/src/MeshGeometry.ts +++ b/packages/mesh/src/MeshGeometry.ts @@ -16,7 +16,6 @@ import type { IArrayBuffer } from '@pixi/core'; * geometry.addIndex([0,1,2,1,3,2]); * * ``` - * * @memberof PIXI */ export class MeshGeometry extends Geometry @@ -26,7 +25,6 @@ export class MeshGeometry extends Geometry * Dirty flag to limit update calls on Mesh. For example, * limiting updates on a single Mesh instance with a shared Geometry * within the render loop. - * * @private * @default -1 */ @@ -54,7 +52,6 @@ export class MeshGeometry extends Geometry /** * If the vertex position is updated. - * * @readonly * @private */ diff --git a/packages/mesh/src/MeshMaterial.ts b/packages/mesh/src/MeshMaterial.ts index fec1367d44..ff96ecb231 100644 --- a/packages/mesh/src/MeshMaterial.ts +++ b/packages/mesh/src/MeshMaterial.ts @@ -7,7 +7,8 @@ import vertex from './shader/mesh.vert'; import type { Texture } from '@pixi/core'; import type { Dict } from '@pixi/utils'; -export interface IMeshMaterialOptions { +export interface IMeshMaterialOptions +{ alpha?: number; tint?: number; pluginName?: string; @@ -20,28 +21,24 @@ export interface MeshMaterial extends GlobalMixins.MeshMaterial {} /** * Slightly opinionated default shader for PixiJS 2D objects. - * * @memberof PIXI */ export class MeshMaterial extends Shader { /** * TextureMatrix instance for this Mesh, used to track Texture changes. - * * @readonly */ public readonly uvMatrix: TextureMatrix; /** * `true` if shader can be batch with the renderer's batch system. - * * @default true */ public batchable: boolean; /** * Renderer plugin for batching. - * * @default 'batch' */ public pluginName: string; @@ -51,7 +48,6 @@ export class MeshMaterial extends Shader /** * Only do update if tint or alpha changes. - * * @private * @default false */ @@ -110,6 +106,11 @@ export class MeshMaterial extends Shader { if (this.uniforms.uSampler !== value) { + if (!this.uniforms.uSampler.baseTexture.alphaMode !== !value.baseTexture.alphaMode) + { + this._colorDirty = true; + } + this.uniforms.uSampler = value; this.uvMatrix.texture = value; } @@ -117,7 +118,6 @@ export class MeshMaterial extends Shader /** * This gets automatically set by the object using this. - * * @default 1 */ set alpha(value: number) @@ -134,7 +134,6 @@ export class MeshMaterial extends Shader /** * Multiply tint for the material. - * * @default 0xFFFFFF */ set tint(value: number) @@ -150,10 +149,7 @@ export class MeshMaterial extends Shader return this._tint; } - /** - * Gets called automatically by the Mesh. Intended to be overridden for custom - * {@link MeshMaterial} objects. - */ + /** Gets called automatically by the Mesh. Intended to be overridden for custom {@link MeshMaterial} objects. */ public update(): void { if (this._colorDirty) diff --git a/packages/mesh/test/Mesh.tests.ts b/packages/mesh/test/Mesh.tests.ts index 94623eea40..7014d24112 100644 --- a/packages/mesh/test/Mesh.tests.ts +++ b/packages/mesh/test/Mesh.tests.ts @@ -2,15 +2,16 @@ import { Mesh, MeshGeometry, MeshMaterial } from '@pixi/mesh'; import { skipHello } from '@pixi/utils'; import sinon from 'sinon'; import { expect } from 'chai'; +import { Texture } from '@pixi/core'; skipHello(); -describe('Mesh', function () +describe('Mesh', () => { - it('should dispose geometry correctly', function () + it('should dispose geometry correctly', () => { - const geometry1 = new MeshGeometry([0, 0]); - const geometry2 = new MeshGeometry([1, 1]); + const geometry1 = new MeshGeometry(new Float32Array([0, 0])); + const geometry2 = new MeshGeometry(new Float32Array([1, 1])); const dispose1 = sinon.spy(geometry1, 'dispose'); const dispose2 = sinon.spy(geometry2, 'dispose'); @@ -20,10 +21,10 @@ describe('Mesh', function () expect(dispose1.called).to.be.false; expect(dispose2.called).to.be.false; - const mesh = new Mesh(geometry1, new MeshMaterial()); + const mesh = new Mesh(geometry1, new MeshMaterial(Texture.EMPTY)); expect(mesh.geometry).to.equal(geometry1); - expect(mesh.vertexDirty).to.equal(-1); + expect(mesh['vertexDirty']).to.equal(-1); expect(geometry1.refCount).to.equal(1); expect(geometry2.refCount).to.equal(0); expect(dispose1.called).to.be.false; @@ -31,16 +32,16 @@ describe('Mesh', function () mesh.calculateVertices(); - expect(mesh.vertexDirty).to.equal(mesh.verticesBuffer._updateID); - expect(mesh.vertexData[0]).to.equal(0); - expect(mesh.vertexData[1]).to.equal(0); + expect(mesh['vertexDirty']).to.equal(mesh.verticesBuffer._updateID); + expect(mesh['vertexData'][0]).to.equal(0); + expect(mesh['vertexData'][1]).to.equal(0); mesh.geometry = geometry1; expect(mesh.geometry).to.equal(geometry1); - expect(mesh.vertexDirty).to.equal(mesh.verticesBuffer._updateID); - expect(mesh.vertexData[0]).to.equal(0); - expect(mesh.vertexData[1]).to.equal(0); + expect(mesh['vertexDirty']).to.equal(mesh.verticesBuffer._updateID); + expect(mesh['vertexData'][0]).to.equal(0); + expect(mesh['vertexData'][1]).to.equal(0); expect(geometry1.refCount).to.equal(1); expect(geometry2.refCount).to.equal(0); expect(dispose1.called).to.be.false; @@ -49,7 +50,7 @@ describe('Mesh', function () mesh.geometry = geometry2; expect(mesh.geometry).to.equal(geometry2); - expect(mesh.vertexDirty).to.equal(-1); + expect(mesh['vertexDirty']).to.equal(-1); expect(geometry1.refCount).to.equal(0); expect(geometry2.refCount).to.equal(1); expect(dispose1.called).to.be.true; @@ -57,14 +58,14 @@ describe('Mesh', function () mesh.calculateVertices(); - expect(mesh.vertexDirty).to.equal(mesh.verticesBuffer._updateID); - expect(mesh.vertexData[0]).to.equal(1); - expect(mesh.vertexData[1]).to.equal(1); + expect(mesh['vertexDirty']).to.equal(mesh.verticesBuffer._updateID); + expect(mesh['vertexData'][0]).to.equal(1); + expect(mesh['vertexData'][1]).to.equal(1); mesh.destroy(); expect(mesh.geometry).to.equal(null); - expect(mesh.vertexDirty).to.equal(-1); + expect(mesh['vertexDirty']).to.equal(-1); expect(geometry1.refCount).to.equal(0); expect(geometry2.refCount).to.equal(0); expect(dispose1.called).to.be.true; diff --git a/packages/mixin-cache-as-bitmap/global.d.ts b/packages/mixin-cache-as-bitmap/global.d.ts index 8fadc0b8a3..83f5cd3024 100644 --- a/packages/mixin-cache-as-bitmap/global.d.ts +++ b/packages/mixin-cache-as-bitmap/global.d.ts @@ -1,6 +1,7 @@ declare namespace GlobalMixins { - interface DisplayObject { + interface DisplayObject + { cacheAsBitmap: boolean; cacheAsBitmapResolution: number; cacheAsBitmapMultisample: import('@pixi/constants').MSAA_QUALITY; @@ -15,6 +16,6 @@ declare namespace GlobalMixins _renderCachedCanvas(renderer: import('@pixi/core').AbstractRenderer): void; _initCachedDisplayObjectCanvas(renderer: import('@pixi/core').AbstractRenderer): void; _destroyCachedDisplayObject(): void; - _cacheAsBitmapDestroy(options?: import('@pixi/display').IDestroyOptions|boolean): void; + _cacheAsBitmapDestroy(options?: import('@pixi/display').IDestroyOptions | boolean): void; } } diff --git a/packages/mixin-cache-as-bitmap/package.json b/packages/mixin-cache-as-bitmap/package.json index 58db611597..0a1051c217 100644 --- a/packages/mixin-cache-as-bitmap/package.json +++ b/packages/mixin-cache-as-bitmap/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/mixin-cache-as-bitmap", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/mixin-cache-as-bitmap.js", "module": "dist/esm/mixin-cache-as-bitmap.js", "bundle": "dist/browser/mixin-cache-as-bitmap.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/mixin-cache-as-bitmap.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/mixin-cache-as-bitmap.js" + } + } + }, "bundleNoExports": true, "description": "Mixin to allow caching container and its children to a bitmap texture", "author": "Mat Groves", @@ -26,11 +39,11 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/core": "6.3.0", - "@pixi/display": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/settings": "6.3.0", - "@pixi/sprite": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/core": "6.4.2", + "@pixi/display": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/settings": "6.4.2", + "@pixi/sprite": "6.4.2", + "@pixi/utils": "6.4.2" } } diff --git a/packages/mixin-cache-as-bitmap/src/index.ts b/packages/mixin-cache-as-bitmap/src/index.ts index 98c0a54946..6d0df080e2 100644 --- a/packages/mixin-cache-as-bitmap/src/index.ts +++ b/packages/mixin-cache-as-bitmap/src/index.ts @@ -8,7 +8,8 @@ import { MSAA_QUALITY } from '@pixi/constants'; // Don't import CanvasRender to remove dependency on this optional package // this type should satisify these requirements for cacheAsBitmap types -interface CanvasRenderer extends AbstractRenderer { +interface CanvasRenderer extends AbstractRenderer +{ context: CanvasRenderingContext2D; } @@ -35,8 +36,8 @@ export class CacheData public originalCalculateBounds: () => void; public originalGetLocalBounds: (rect?: Rectangle) => Rectangle; public originalUpdateTransform: () => void; - public originalDestroy: (options?: IDestroyOptions|boolean) => void; - public originalMask: Container|MaskData; + public originalDestroy: (options?: IDestroyOptions | boolean) => void; + public originalMask: Container | MaskData; public originalFilterArea: Rectangle; public originalContainsPoint: (point: IPointData) => boolean; public sprite: Sprite; @@ -65,7 +66,6 @@ Object.defineProperties(DisplayObject.prototype, { * but can be overriden for performance. Lower values will reduce memory usage at the expense * of render quality. A falsey value of `null` or `0` will default to the renderer's resolution. * If `cacheAsBitmap` is set to `true`, this will re-render with the new resolution. - * * @member {number} cacheAsBitmapResolution * @memberof PIXI.DisplayObject# * @default null @@ -97,7 +97,6 @@ Object.defineProperties(DisplayObject.prototype, { * The number of samples to use for cacheAsBitmap. If set to `null`, the renderer's * sample count is used. * If `cacheAsBitmap` is set to `true`, this will re-render with the new number of samples. - * * @member {number} cacheAsBitmapMultisample * @memberof PIXI.DisplayObject# * @default PIXI.MSAA_QUALITY.NONE @@ -133,7 +132,6 @@ Object.defineProperties(DisplayObject.prototype, { * * IMPORTANT GOTCHA - Make sure that all your textures are preloaded BEFORE setting this property to true * as it will take a snapshot of what is currently there. If the textures have not loaded then they will not appear. - * * @member {boolean} * @memberof PIXI.DisplayObject# */ @@ -209,7 +207,6 @@ Object.defineProperties(DisplayObject.prototype, { /** * Renders a cached version of the sprite with WebGL - * * @private * @method _renderCached * @memberof PIXI.DisplayObject# @@ -231,7 +228,6 @@ DisplayObject.prototype._renderCached = function _renderCached(renderer: Rendere /** * Prepares the WebGL renderer to cache the sprite - * * @private * @method _initCachedDisplayObject * @memberof PIXI.DisplayObject# @@ -349,7 +345,6 @@ DisplayObject.prototype._initCachedDisplayObject = function _initCachedDisplayOb /** * Renders a cached version of the sprite with canvas - * * @private * @method _renderCachedCanvas * @memberof PIXI.DisplayObject# @@ -371,7 +366,6 @@ DisplayObject.prototype._renderCachedCanvas = function _renderCachedCanvas(rende // TODO this can be the same as the WebGL version.. will need to do a little tweaking first though.. /** * Prepares the Canvas renderer to cache the sprite - * * @private * @method _initCachedDisplayObjectCanvas * @memberof PIXI.DisplayObject# @@ -465,7 +459,6 @@ DisplayObject.prototype._initCachedDisplayObjectCanvas = function _initCachedDis /** * Calculates the bounds of the cached sprite - * * @private * @method */ @@ -479,10 +472,9 @@ DisplayObject.prototype._calculateCachedBounds = function _calculateCachedBounds /** * Gets the bounds of the cached sprite. - * * @private * @method - * @return {Rectangle} The local bounds. + * @returns {Rectangle} The local bounds. */ DisplayObject.prototype._getCachedLocalBounds = function _getCachedLocalBounds(): Rectangle { @@ -491,7 +483,6 @@ DisplayObject.prototype._getCachedLocalBounds = function _getCachedLocalBounds() /** * Destroys the cached sprite. - * * @private * @method */ @@ -508,14 +499,13 @@ DisplayObject.prototype._destroyCachedDisplayObject = function _destroyCachedDis /** * Destroys the cached object. - * * @private * @method * @param {object|boolean} [options] - Options parameter. A boolean will act as if all options * have been set to that value. * Used when destroying containers, see the Container.destroy method. */ -DisplayObject.prototype._cacheAsBitmapDestroy = function _cacheAsBitmapDestroy(options?: IDestroyOptions|boolean): void +DisplayObject.prototype._cacheAsBitmapDestroy = function _cacheAsBitmapDestroy(options?: IDestroyOptions | boolean): void { this.cacheAsBitmap = false; this.destroy(options); diff --git a/packages/mixin-cache-as-bitmap/test/cacheAsBitmap.tests.ts b/packages/mixin-cache-as-bitmap/test/cacheAsBitmap.tests.ts index 1f059c7d07..561452fd70 100644 --- a/packages/mixin-cache-as-bitmap/test/cacheAsBitmap.tests.ts +++ b/packages/mixin-cache-as-bitmap/test/cacheAsBitmap.tests.ts @@ -5,10 +5,11 @@ import { expect } from 'chai'; import '@pixi/mixin-cache-as-bitmap'; -describe('DisplayObject#cacheAsBitmap', function () +describe('DisplayObject#cacheAsBitmap', () => { - it('should contain property', function () + it('should contain property', () => { + // @ts-expect-error - instantiating DisplayObject const obj = new DisplayObject(); expect(obj.cacheAsBitmap).to.be.not.undefined; @@ -16,14 +17,15 @@ describe('DisplayObject#cacheAsBitmap', function () expect(obj.cacheAsBitmap).to.be.false; }); - it('should enable cacheAsBitmap', function () + it('should enable cacheAsBitmap', () => { + // @ts-expect-error - instantiating DisplayObject const obj = new DisplayObject(); obj.cacheAsBitmap = true; }); - it('should respect filters', function () + it('should respect filters', () => { const par = new Container(); const obj = new Container(); @@ -35,7 +37,8 @@ describe('DisplayObject#cacheAsBitmap', function () obj.position.set(5, 15); obj.updateTransform(); obj.cacheAsBitmap = true; - obj._calculateBounds = function () + // eslint-disable-next-line func-names + obj['_calculateBounds'] = function () { this._bounds.clear(); this._bounds.addFrame(this.transform, 0, 0, 10, 11); @@ -71,14 +74,14 @@ describe('DisplayObject#cacheAsBitmap', function () } }); - it('should not throw error when filters is empty array', function () + it('should not throw error when filters is empty array', () => { const obj = new Container(); obj.filters = []; obj.cacheAsBitmap = true; - expect(function () + expect(() => { let renderer = null; @@ -95,7 +98,7 @@ describe('DisplayObject#cacheAsBitmap', function () }).to.not.throw(); }); - it('should respect projection', function () + it('should respect projection', () => { const par = new Container(); const obj = new Container(); @@ -107,7 +110,8 @@ describe('DisplayObject#cacheAsBitmap', function () obj.position.set(5, 15); obj.updateTransform(); obj.cacheAsBitmap = true; - obj._calculateBounds = function () + // eslint-disable-next-line func-names + obj['_calculateBounds'] = function () { this._bounds.clear(); this._bounds.addFrame(this.transform, 0, 0, 10, 11); diff --git a/packages/mixin-get-child-by-name/package.json b/packages/mixin-get-child-by-name/package.json index 5461855241..32fd6f5032 100644 --- a/packages/mixin-get-child-by-name/package.json +++ b/packages/mixin-get-child-by-name/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/mixin-get-child-by-name", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/mixin-get-child-by-name.js", "module": "dist/esm/mixin-get-child-by-name.js", "bundle": "dist/browser/mixin-get-child-by-name.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/mixin-get-child-by-name.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/mixin-get-child-by-name.js" + } + } + }, "bundleNoExports": true, "description": "Mixin function to find a child DisplayObject by name", "author": "Mat Groves", @@ -26,6 +39,6 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/display": "6.3.0" + "@pixi/display": "6.4.2" } } diff --git a/packages/mixin-get-child-by-name/src/index.ts b/packages/mixin-get-child-by-name/src/index.ts index fb0dbb789e..5003652e66 100644 --- a/packages/mixin-get-child-by-name/src/index.ts +++ b/packages/mixin-get-child-by-name/src/index.ts @@ -2,7 +2,6 @@ import { DisplayObject, Container } from '@pixi/display'; /** * The instance name of the object. - * * @memberof PIXI.DisplayObject# * @member {string} name */ @@ -12,12 +11,11 @@ DisplayObject.prototype.name = null; * Returns the display object in the container. * * Recursive searches are done in a preorder traversal. - * * @method getChildByName * @memberof PIXI.Container# * @param {string} name - Instance name. * @param {boolean}[deep=false] - Whether to search recursively - * @return {PIXI.DisplayObject} The child with the specified name. + * @returns {PIXI.DisplayObject} The child with the specified name. */ Container.prototype.getChildByName = function getChildByName(name: string, deep?: boolean): DisplayObject { diff --git a/packages/mixin-get-child-by-name/test/getChildByName.tests.ts b/packages/mixin-get-child-by-name/test/getChildByName.tests.ts index c97d2d098a..2d08438e7e 100644 --- a/packages/mixin-get-child-by-name/test/getChildByName.tests.ts +++ b/packages/mixin-get-child-by-name/test/getChildByName.tests.ts @@ -3,10 +3,11 @@ import { expect } from 'chai'; import '@pixi/mixin-get-child-by-name'; -describe('DisplayObject#name', function () +describe('DisplayObject#name', () => { - it('should contain property', function () + it('should contain property', () => { + // @ts-expect-error - instantiating DisplayObject const obj = new DisplayObject(); expect(obj.name).to.be.not.undefined; @@ -14,9 +15,9 @@ describe('DisplayObject#name', function () }); }); -describe('Container#getChildByName', function () +describe('Container#getChildByName', () => { - it('should exist', function () + it('should exist', () => { const parent = new Container(); @@ -24,8 +25,9 @@ describe('Container#getChildByName', function () expect(parent.getChildByName).to.be.a('function'); }); - it('should correctly find a child by its name', function () + it('should correctly find a child by its name', () => { + // @ts-expect-error - instantiating DisplayObject const obj = new DisplayObject(); const parent = new Container(); @@ -35,8 +37,9 @@ describe('Container#getChildByName', function () expect(parent.getChildByName('foo')).to.equal(obj); }); - it('should correctly find a indirect child by its name in deep search', function () + it('should correctly find a indirect child by its name in deep search', () => { + // @ts-expect-error - instantiating DisplayObject const obj = new DisplayObject(); const parent = new Container(); const grandParent = new Container(); @@ -48,21 +51,25 @@ describe('Container#getChildByName', function () expect(grandParent.getChildByName('foo', true)).to.equal(obj); }); - it('should return null if name does not exist', function () + it('should return null if name does not exist', () => { const root = new Container(); - const displayObject = root.addChild(new DisplayObject()); - const container = root.addChild(new Container()); + + // @ts-expect-error - instantiating DisplayObject + root.addChild(new DisplayObject()); + root.addChild(new Container()); expect(root.getChildByName('mock-name', true)).to.equal(null); }); - it('should return the match highest in the hierarchy', function () + it('should return the match highest in the hierarchy', () => { const stage = new Container(); const root = stage.addChild(new Container()); const parent = root.addChild(new Container()); + // @ts-expect-error - instantiating DisplayObject const uncle = root.addChild(new DisplayObject()); + // @ts-expect-error - instantiating DisplayObject const target = new DisplayObject(); parent.name = 'mock-parent'; diff --git a/packages/mixin-get-global-position/package.json b/packages/mixin-get-global-position/package.json index 6a6a9f0d98..7de7a4ad41 100644 --- a/packages/mixin-get-global-position/package.json +++ b/packages/mixin-get-global-position/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/mixin-get-global-position", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/mixin-get-global-position.js", "module": "dist/esm/mixin-get-global-position.js", "bundle": "dist/browser/mixin-get-global-position.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/mixin-get-global-position.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/mixin-get-global-position.js" + } + } + }, "bundleNoExports": true, "description": "Mixin to find the global position of a DisplayObject", "author": "Mat Groves", @@ -26,7 +39,7 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/display": "6.3.0", - "@pixi/math": "6.3.0" + "@pixi/display": "6.4.2", + "@pixi/math": "6.4.2" } } diff --git a/packages/mixin-get-global-position/src/index.ts b/packages/mixin-get-global-position/src/index.ts index 2eb46062c3..50a2e6d326 100644 --- a/packages/mixin-get-global-position/src/index.ts +++ b/packages/mixin-get-global-position/src/index.ts @@ -3,14 +3,13 @@ import { Point } from '@pixi/math'; /** * Returns the global position of the displayObject. Does not depend on object scale, rotation and pivot. - * * @method getGlobalPosition * @memberof PIXI.DisplayObject# * @param {PIXI.Point} [point=new PIXI.Point()] - The point to write the global value to. * @param {boolean} [skipUpdate=false] - Setting to true will stop the transforms of the scene graph from * being updated. This means the calculation returned MAY be out of date BUT will give you a * nice performance boost. - * @return {PIXI.Point} The updated point. + * @returns {PIXI.Point} The updated point. */ DisplayObject.prototype.getGlobalPosition = function getGlobalPosition(point: Point = new Point(), skipUpdate = false): Point { diff --git a/packages/mixin-get-global-position/test/getGlobalPosition.tests.ts b/packages/mixin-get-global-position/test/getGlobalPosition.tests.ts index 085495a178..3a999f4bca 100644 --- a/packages/mixin-get-global-position/test/getGlobalPosition.tests.ts +++ b/packages/mixin-get-global-position/test/getGlobalPosition.tests.ts @@ -3,17 +3,18 @@ import { expect } from 'chai'; import '@pixi/mixin-get-global-position'; -describe('DisplayObject#getGlobalPosition', function () +describe('DisplayObject#getGlobalPosition', () => { - it('should exist', function () + it('should exist', () => { + // @ts-expect-error - instantiating DisplayObject const obj = new DisplayObject(); expect(obj.getGlobalPosition).to.be.not.undefined; expect(obj.getGlobalPosition).to.be.a('function'); }); - it('should return correct global coordinates of a displayObject, without depending on its pivot', function () + it('should return correct global coordinates of a displayObject, without depending on its pivot', () => { const parent = new Container(); diff --git a/packages/particle-container/package.json b/packages/particle-container/package.json index 7f2c334de6..e4988d8bdd 100644 --- a/packages/particle-container/package.json +++ b/packages/particle-container/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/particle-container", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/particle-container.js", "module": "dist/esm/particle-container.js", "bundle": "dist/browser/particle-container.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/particle-container.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/particle-container.js" + } + } + }, "description": "Render many sprite particles as efficiently as possible", "author": "Mat Groves", "contributors": [ @@ -25,10 +38,10 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/constants": "6.3.0", - "@pixi/core": "6.3.0", - "@pixi/display": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/constants": "6.4.2", + "@pixi/core": "6.4.2", + "@pixi/display": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/utils": "6.4.2" } } diff --git a/packages/particle-container/src/ParticleBuffer.ts b/packages/particle-container/src/ParticleBuffer.ts index f40674932c..88842943f9 100644 --- a/packages/particle-container/src/ParticleBuffer.ts +++ b/packages/particle-container/src/ParticleBuffer.ts @@ -19,7 +19,6 @@ import type { IParticleRendererProperty } from './ParticleRenderer'; /** * The particle buffer manages the static and dynamic buffers for a particle container. - * * @private * @memberof PIXI */ @@ -182,7 +181,6 @@ export class ParticleBuffer /** * Uploads the dynamic properties. - * * @param children - The children to upload. * @param startIndex - The index to start at. * @param amount - The number to upload. @@ -203,7 +201,6 @@ export class ParticleBuffer /** * Uploads the static properties. - * * @param children - The children to upload. * @param startIndex - The index to start at. * @param amount - The number to upload. diff --git a/packages/particle-container/src/ParticleContainer.ts b/packages/particle-container/src/ParticleContainer.ts index 02054cf47b..646898bd7f 100644 --- a/packages/particle-container/src/ParticleContainer.ts +++ b/packages/particle-container/src/ParticleContainer.ts @@ -6,7 +6,8 @@ import type { BaseTexture, Renderer } from '@pixi/core'; import type { ParticleBuffer } from './ParticleBuffer'; import type { IDestroyOptions } from '@pixi/display'; -export interface IParticleProperties { +export interface IParticleProperties +{ vertices?: boolean; position?: boolean; rotation?: boolean; @@ -38,7 +39,6 @@ export interface IParticleProperties { * ``` * * And here you have a hundred sprites that will be rendered at the speed of light. - * * @memberof PIXI */ export class ParticleContainer extends Container @@ -46,14 +46,12 @@ export class ParticleContainer extends Container /** * The blend mode to be applied to the sprite. Apply a value of `PIXI.BLEND_MODES.NORMAL` * to reset the blend mode. - * * @default PIXI.BLEND_MODES.NORMAL */ public blendMode: BLEND_MODES; /** * If true, container allocates more batches in case there are more than `maxSize` particles. - * * @default false */ public autoResize: boolean; @@ -63,14 +61,12 @@ export class ParticleContainer extends Container * Advantages can include sharper image quality (like text) and faster rendering on canvas. * The main disadvantage is movement of objects may appear less smooth. * Default to true here as performance is usually the priority for particles. - * * @default true */ public roundPixels: boolean; /** * The texture used to render the children. - * * @readonly */ public baseTexture: BaseTexture; @@ -87,21 +83,18 @@ export class ParticleContainer extends Container /** * Set properties to be dynamic (true) / static (false). - * * @private */ _properties: boolean[]; /** * For every batch, stores _updateID corresponding to the last change in that batch. - * * @private */ _bufferUpdateIDs: number[]; /** * When child inserted, removed or changes position this number goes up. - * * @private */ _updateID: number; @@ -109,7 +102,6 @@ export class ParticleContainer extends Container /** * The tint applied to the container. * This is a hex value. A value of 0xFFFFFF will remove any tint effect. - * * @default 0xFFFFFF */ private _tint: number; @@ -164,7 +156,6 @@ export class ParticleContainer extends Container /** * Sets the private properties array to dynamic / static based on the passed properties object - * * @param properties - The properties to be uploaded */ public setProperties(properties: IParticleProperties): void @@ -191,7 +182,6 @@ export class ParticleContainer extends Container * The tint applied to the container. This is a hex value. * A value of 0xFFFFFF will remove any tint effect. * IMPORTANT: This is a WebGL only feature and will be ignored by the canvas renderer. - * * @default 0xFFFFFF */ get tint(): number @@ -207,7 +197,6 @@ export class ParticleContainer extends Container /** * Renders the container using the WebGL renderer. - * * @param renderer - The WebGL renderer. */ public render(renderer: Renderer): void @@ -232,7 +221,6 @@ export class ParticleContainer extends Container /** * Set the flag that static data should be updated to true - * * @param smallestChildIndex - The smallest child index. */ protected onChildrenChange(smallestChildIndex: number): void @@ -261,7 +249,6 @@ export class ParticleContainer extends Container /** * Destroys the container - * * @param options - Options parameter. A boolean will act as if all options * have been set to that value * @param {boolean} [options.children=false] - if set to true, all the children will have their @@ -271,7 +258,7 @@ export class ParticleContainer extends Container * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true * Should it destroy the base texture of the child sprite */ - public destroy(options?: IDestroyOptions|boolean): void + public destroy(options?: IDestroyOptions | boolean): void { super.destroy(options); diff --git a/packages/particle-container/src/ParticleRenderer.ts b/packages/particle-container/src/ParticleRenderer.ts index dae0ad425e..c8898f4bc2 100644 --- a/packages/particle-container/src/ParticleRenderer.ts +++ b/packages/particle-container/src/ParticleRenderer.ts @@ -10,7 +10,8 @@ import type { DisplayObject } from '@pixi/display'; import type { ParticleContainer } from './ParticleContainer'; import type { Renderer } from '@pixi/core'; -export interface IParticleRendererProperty { +export interface IParticleRendererProperty +{ attributeName: string; size: number; type?: TYPES; @@ -32,7 +33,6 @@ export interface IParticleRendererProperty { /** * Renderer for Particles that is designer for speed over feature set. - * * @memberof PIXI */ export class ParticleRenderer extends ObjectRenderer @@ -109,7 +109,6 @@ export class ParticleRenderer extends ObjectRenderer /** * Renders the particle container object. - * * @param container - The container to render using this ParticleRenderer. */ public render(container: ParticleContainer): void @@ -197,9 +196,8 @@ export class ParticleRenderer extends ObjectRenderer /** * Creates one particle buffer for each child in the container we want to render and updates internal properties. - * * @param container - The container to render using this ParticleRenderer - * @return - The buffers + * @returns - The buffers */ private generateBuffers(container: ParticleContainer): ParticleBuffer[] { @@ -218,9 +216,8 @@ export class ParticleRenderer extends ObjectRenderer /** * Creates one more particle buffer, because container has autoResize feature. - * * @param container - The container to render using this ParticleRenderer - * @return - The generated buffer + * @returns - The generated buffer */ private _generateOneMoreBuffer(container: ParticleContainer): ParticleBuffer { @@ -232,7 +229,6 @@ export class ParticleRenderer extends ObjectRenderer /** * Uploads the vertices. - * * @param children - the array of display objects to render * @param startIndex - the index to start from in the children array * @param amount - the amount of children that will have their vertices uploaded @@ -296,7 +292,6 @@ export class ParticleRenderer extends ObjectRenderer /** * Uploads the position. - * * @param children - the array of display objects to render * @param startIndex - the index to start from in the children array * @param amount - the amount of children that will have their positions uploaded @@ -331,7 +326,6 @@ export class ParticleRenderer extends ObjectRenderer /** * Uploads the rotation. - * * @param children - the array of display objects to render * @param startIndex - the index to start from in the children array * @param amount - the amount of children that will have their rotation uploaded @@ -359,7 +353,6 @@ export class ParticleRenderer extends ObjectRenderer /** * Uploads the UVs. - * * @param children - the array of display objects to render * @param startIndex - the index to start from in the children array * @param amount - the amount of children that will have their rotation uploaded @@ -414,7 +407,6 @@ export class ParticleRenderer extends ObjectRenderer /** * Uploads the tint. - * * @param children - the array of display objects to render * @param startIndex - the index to start from in the children array * @param amount - the amount of children that will have their rotation uploaded diff --git a/packages/particle-container/test/ParticleContainer.tests.ts b/packages/particle-container/test/ParticleContainer.tests.ts index c593891bc5..f0e9a16243 100644 --- a/packages/particle-container/test/ParticleContainer.tests.ts +++ b/packages/particle-container/test/ParticleContainer.tests.ts @@ -3,9 +3,9 @@ import { Sprite } from '@pixi/sprite'; import { Texture } from '@pixi/core'; import { expect } from 'chai'; -describe('ParticleContainer', function () +describe('ParticleContainer', () => { - it('should construct a container', function () + it('should construct a container', () => { const container = new ParticleContainer(); @@ -15,7 +15,7 @@ describe('ParticleContainer', function () container.destroy(); }); - it('should add a child', function () + it('should add a child', () => { const container = new ParticleContainer(); const child = new Sprite(Texture.WHITE); diff --git a/packages/particle-container/test/ParticleRenderer.tests.ts b/packages/particle-container/test/ParticleRenderer.tests.ts index a9f974a3fa..6425daed75 100644 --- a/packages/particle-container/test/ParticleRenderer.tests.ts +++ b/packages/particle-container/test/ParticleRenderer.tests.ts @@ -7,19 +7,19 @@ import path from 'path'; skipHello(); -describe('ParticleRenderer', function () +describe('ParticleRenderer', () => { - beforeEach(function () + beforeEach(() => { Renderer.registerPlugin('particle', ParticleRenderer); }); - afterEach(function () + afterEach(() => { delete Renderer.__plugins.particle; }); - it('should render a particle container with no children', function () + it('should render a particle container with no children', () => { const renderer = new Renderer(); const container = new ParticleContainer(); @@ -31,7 +31,7 @@ describe('ParticleRenderer', function () renderer.destroy(); }); - it('should render a particle container with children', function () + it('should render a particle container with children', () => { const renderer = new Renderer(); const container = new ParticleContainer(); @@ -43,7 +43,7 @@ describe('ParticleRenderer', function () renderer.destroy(); }); - it('should render a particle container with lazy texture loading', function (done: () => void) + it('should render a particle container with lazy texture loading', (done: () => void) => { const image = new Image(); @@ -67,7 +67,7 @@ describe('ParticleRenderer', function () }); }); - it('should support autoResize off', function () + it('should support autoResize off', () => { const renderer = new Renderer(); const container = new ParticleContainer(1); @@ -81,7 +81,7 @@ describe('ParticleRenderer', function () renderer.destroy(); }); - it('should support autoResize on', function () + it('should support autoResize on', () => { const renderer = new Renderer(); const container = new ParticleContainer(1); diff --git a/packages/polyfill/package.json b/packages/polyfill/package.json index 4b77aa4023..93c7b31e67 100644 --- a/packages/polyfill/package.json +++ b/packages/polyfill/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/polyfill", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/polyfill.js", "module": "dist/esm/polyfill.js", "bundle": "dist/browser/polyfill.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/polyfill.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/polyfill.js" + } + } + }, "standalone": true, "description": "Support for legacy browser JavaScript environments", "author": "Mat Groves", diff --git a/packages/prepare/package.json b/packages/prepare/package.json index dd47a9860e..f9611864c8 100644 --- a/packages/prepare/package.json +++ b/packages/prepare/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/prepare", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/prepare.js", "module": "dist/esm/prepare.js", "bundle": "dist/browser/prepare.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/prepare.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/prepare.js" + } + } + }, "description": "Plugin to allow uploading textures to the GPU", "author": "Mat Groves", "contributors": [ @@ -25,11 +38,11 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/core": "6.3.0", - "@pixi/display": "6.3.0", - "@pixi/graphics": "6.3.0", - "@pixi/settings": "6.3.0", - "@pixi/text": "6.3.0", - "@pixi/ticker": "6.3.0" + "@pixi/core": "6.4.2", + "@pixi/display": "6.4.2", + "@pixi/graphics": "6.4.2", + "@pixi/settings": "6.4.2", + "@pixi/text": "6.4.2", + "@pixi/ticker": "6.4.2" } } diff --git a/packages/prepare/src/BasePrepare.ts b/packages/prepare/src/BasePrepare.ts index bde8c89940..fefeeadc25 100644 --- a/packages/prepare/src/BasePrepare.ts +++ b/packages/prepare/src/BasePrepare.ts @@ -7,30 +7,33 @@ import { CountLimiter } from './CountLimiter'; import type { AbstractRenderer } from '@pixi/core'; -interface IArrowFunction { +interface IArrowFunction +{ (): void; } -interface IUploadHook { +interface IUploadHook +{ (helper: AbstractRenderer | BasePrepare, item: IDisplayObjectExtended): boolean; } -interface IFindHook { +interface IFindHook +{ (item: any, queue: Array): boolean; } -export interface IDisplayObjectExtended extends DisplayObject { +export interface IDisplayObjectExtended extends DisplayObject +{ _textures?: Array; _texture?: Texture; - style?: TextStyle|Partial; + style?: TextStyle | Partial; } /** * Built-in hook to find multiple textures from objects like AnimatedSprites. - * * @private * @param item - Display object to check * @param queue - Collection of items to upload - * @return If a PIXI.Texture object was found. + * @returns If a PIXI.Texture object was found. */ function findMultipleBaseTextures(item: IDisplayObjectExtended, queue: Array): boolean { @@ -59,11 +62,10 @@ function findMultipleBaseTextures(item: IDisplayObjectExtended, queue: Array): boolean { @@ -84,11 +86,10 @@ function findBaseTexture(item: Texture, queue: Array): boolean /** * Built-in hook to find textures from objects. - * * @private * @param item - Display object to check * @param queue - Collection of items to upload - * @return If a PIXI.Texture object was found. + * @returns If a PIXI.Texture object was found. */ function findTexture(item: IDisplayObjectExtended, queue: Array): boolean { @@ -109,11 +110,10 @@ function findTexture(item: IDisplayObjectExtended, queue: Array): boolean /** * Built-in hook to draw PIXI.Text to its texture. - * * @private - * @param helper - Not used by this upload handler + * @param _helper - Not used by this upload handler * @param item - Item to check - * @return If item was uploaded. + * @returns If item was uploaded. */ function drawText(_helper: AbstractRenderer | BasePrepare, item: IDisplayObjectExtended): boolean { @@ -130,11 +130,10 @@ function drawText(_helper: AbstractRenderer | BasePrepare, item: IDisplayObjectE /** * Built-in hook to calculate a text style for a PIXI.Text object. - * * @private - * @param helper - Not used by this upload handler + * @param _helper - Not used by this upload handler * @param item - Item to check - * @return If item was uploaded. + * @returns If item was uploaded. */ function calculateTextStyle(_helper: AbstractRenderer | BasePrepare, item: IDisplayObjectExtended): boolean { @@ -152,11 +151,10 @@ function calculateTextStyle(_helper: AbstractRenderer | BasePrepare, item: IDisp /** * Built-in hook to find Text objects. - * * @private * @param item - Display object to check * @param queue - Collection of items to upload - * @return if a PIXI.Text object was found. + * @returns if a PIXI.Text object was found. */ function findText(item: IDisplayObjectExtended, queue: Array): boolean { @@ -188,11 +186,10 @@ function findText(item: IDisplayObjectExtended, queue: Array): boolean /** * Built-in hook to find TextStyle objects. - * * @private * @param item - Display object to check * @param queue - Collection of items to upload - * @return If a PIXI.TextStyle object was found. + * @returns If a PIXI.TextStyle object was found. */ function findTextStyle(item: TextStyle, queue: Array): boolean { @@ -215,7 +212,6 @@ function findTextStyle(item: TextStyle, queue: Array): boolean * BasePrepare handles basic queuing functionality and is extended by * {@link PIXI.Prepare} and {@link PIXI.CanvasPrepare} * to provide preparation capabilities specific to their respective renderers. - * * @example * // Create a sprite * const sprite = PIXI.Sprite.from('something.png'); @@ -227,7 +223,6 @@ function findTextStyle(item: TextStyle, queue: Array): boolean * app.stage.addChild(sprite); * * }) - * * @abstract * @memberof PIXI */ @@ -318,7 +313,6 @@ export class BasePrepare /** * Upload all the textures and graphics to the GPU. - * * @param {Function|PIXI.DisplayObject|PIXI.Container|PIXI.BaseTexture|PIXI.Texture|PIXI.Graphics|PIXI.Text} item - * Either the container or display object to search for items to upload, the items to upload themselves, * or the callback function, if items have been added using `prepare.add`. @@ -361,7 +355,6 @@ export class BasePrepare /** * Handle tick update - * * @private */ tick(): void @@ -372,7 +365,6 @@ export class BasePrepare /** * Actually prepare items. This is handled outside of the tick because it will take a while * and we do NOT want to block the current animation frame from rendering. - * * @private */ prepareItems(): void @@ -426,10 +418,9 @@ export class BasePrepare /** * Adds hooks for finding items. - * * @param {Function} addHook - Function call that takes two parameters: `item:*, queue:Array` * function must return `true` if it was able to add item to the queue. - * @return Instance of plugin for chaining. + * @returns Instance of plugin for chaining. */ registerFindHook(addHook: IFindHook): this { @@ -443,10 +434,9 @@ export class BasePrepare /** * Adds hooks for uploading items. - * * @param {Function} uploadHook - Function call that takes two parameters: `prepare:CanvasPrepare, item:*` and * function must return `true` if it was able to handle upload of item. - * @return Instance of plugin for chaining. + * @returns Instance of plugin for chaining. */ registerUploadHook(uploadHook: IUploadHook): this { @@ -460,10 +450,9 @@ export class BasePrepare /** * Manually add an item to the uploading queue. - * * @param {PIXI.DisplayObject|PIXI.Container|PIXI.BaseTexture|PIXI.Texture|PIXI.Graphics|PIXI.Text|*} item - Object to * add to the queue - * @return Instance of plugin for chaining. + * @returns Instance of plugin for chaining. */ add(item: IDisplayObjectExtended | Container | BaseTexture | Texture): this { diff --git a/packages/prepare/src/CountLimiter.ts b/packages/prepare/src/CountLimiter.ts index 2dcb67c6f8..45dc267529 100644 --- a/packages/prepare/src/CountLimiter.ts +++ b/packages/prepare/src/CountLimiter.ts @@ -1,7 +1,6 @@ /** * CountLimiter limits the number of items handled by a {@link PIXI.BasePrepare} to a specified * number of items per frame. - * * @memberof PIXI */ export class CountLimiter @@ -9,8 +8,7 @@ export class CountLimiter /** The maximum number of items that can be prepared each frame. */ public maxItemsPerFrame: number; - /** - * The number of items that can be prepared in the current frame. */ + /** The number of items that can be prepared in the current frame. */ public itemsLeft: number; /** @@ -30,8 +28,7 @@ export class CountLimiter /** * Checks to see if another item can be uploaded. This should only be called once per item. - * - * @return If the item is allowed to be uploaded. + * @returns If the item is allowed to be uploaded. */ allowedToUpload(): boolean { diff --git a/packages/prepare/src/Prepare.ts b/packages/prepare/src/Prepare.ts index 7789ec2241..441a5d6fd7 100644 --- a/packages/prepare/src/Prepare.ts +++ b/packages/prepare/src/Prepare.ts @@ -6,11 +6,10 @@ import type { AbstractRenderer, Renderer } from '@pixi/core'; /** * Built-in hook to upload PIXI.Texture objects to the GPU. - * * @private * @param renderer - instance of the webgl renderer * @param item - Item to check - * @return If item was uploaded. + * @returns If item was uploaded. */ function uploadBaseTextures(renderer: AbstractRenderer | BasePrepare, item: IDisplayObjectExtended | BaseTexture): boolean { @@ -32,11 +31,10 @@ function uploadBaseTextures(renderer: AbstractRenderer | BasePrepare, item: IDis /** * Built-in hook to upload PIXI.Graphics to the GPU. - * * @private * @param renderer - instance of the webgl renderer * @param item - Item to check - * @return If item was uploaded. + * @returns If item was uploaded. */ function uploadGraphics(renderer: AbstractRenderer | BasePrepare, item: IDisplayObjectExtended): boolean { @@ -75,11 +73,10 @@ function uploadGraphics(renderer: AbstractRenderer | BasePrepare, item: IDisplay /** * Built-in hook to find graphics. - * * @private * @param item - Display object to check * @param queue - Collection of items to upload - * @return if a PIXI.Graphics object was found. + * @returns if a PIXI.Graphics object was found. */ function findGraphics(item: IDisplayObjectExtended, queue: Array): boolean { @@ -119,8 +116,6 @@ function findGraphics(item: IDisplayObjectExtended, queue: Array): boolean * app.renderer.plugins.prepare.upload(app.stage, () => { * app.start(); * }); - * - * * @memberof PIXI */ export class Prepare extends BasePrepare diff --git a/packages/prepare/src/TimeLimiter.ts b/packages/prepare/src/TimeLimiter.ts index 88f5c7543b..872192b942 100644 --- a/packages/prepare/src/TimeLimiter.ts +++ b/packages/prepare/src/TimeLimiter.ts @@ -1,7 +1,6 @@ /** * TimeLimiter limits the number of items handled by a {@link PIXI.BasePrepare} to a specified * number of milliseconds per frame. - * * @memberof PIXI */ export class TimeLimiter @@ -11,7 +10,6 @@ export class TimeLimiter /** * The start time of the current frame. - * * @readonly */ public frameStart: number; @@ -31,8 +29,7 @@ export class TimeLimiter /** * Checks to see if another item can be uploaded. This should only be called once per item. - * - * @return - If the item is allowed to be uploaded. + * @returns - If the item is allowed to be uploaded. */ allowedToUpload(): boolean { diff --git a/packages/prepare/src/settings.ts b/packages/prepare/src/settings.ts index 07a65437ac..3f5b9186e8 100644 --- a/packages/prepare/src/settings.ts +++ b/packages/prepare/src/settings.ts @@ -2,7 +2,6 @@ import { settings } from '@pixi/settings'; /** * Default number of uploads per frame using prepare plugin. - * * @static * @memberof PIXI.settings * @name UPLOADS_PER_FRAME diff --git a/packages/prepare/test/BasePrepare.tests.ts b/packages/prepare/test/BasePrepare.tests.ts index 1fb0534df2..7283038050 100644 --- a/packages/prepare/test/BasePrepare.tests.ts +++ b/packages/prepare/test/BasePrepare.tests.ts @@ -1,17 +1,19 @@ import { BasePrepare } from '@pixi/prepare'; import sinon from 'sinon'; import { expect } from 'chai'; +import { AbstractRenderer } from '@pixi/core'; +import { DisplayObject } from '@pixi/display'; -describe('BasePrepare', function () +describe('BasePrepare', () => { - it('should create a new, empty, BasePrepare', function () + it('should create a new, empty, BasePrepare', () => { - const renderer = {}; + const renderer = {} as AbstractRenderer; const prep = new BasePrepare(renderer); - expect(prep.renderer).to.equal(renderer); - expect(prep.uploadHookHelper).to.be.null; - expect(prep.queue).to.be.empty; + expect(prep['renderer']).to.equal(renderer); + expect(prep['uploadHookHelper']).to.be.null; + expect(prep['queue']).to.be.empty; expect(prep.addHooks).to.have.lengthOf(5); expect(prep.uploadHooks).to.have.lengthOf(2); expect(prep.completes).to.be.empty; @@ -19,11 +21,12 @@ describe('BasePrepare', function () prep.destroy(); }); - it('should add hooks', function () + it('should add hooks', () => { - function addHook() { /* empty */ } - function uploadHook() { /* empty */ } - const prep = new BasePrepare(); + function addHook() { return true; } + function uploadHook() { return true; } + const renderer = {} as AbstractRenderer; + const prep = new BasePrepare(renderer); prep.registerFindHook(addHook); prep.registerUploadHook(uploadHook); @@ -36,36 +39,37 @@ describe('BasePrepare', function () prep.destroy(); }); - it('should call hooks and complete', function () + it('should call hooks and complete', () => { - const prep = new BasePrepare(); - const uploadItem = {}; + const renderer = {} as AbstractRenderer; + const prep = new BasePrepare(renderer); + const uploadItem = {} as DisplayObject; const uploadHelper = {}; - prep.uploadHookHelper = uploadHelper; + prep['uploadHookHelper'] = uploadHelper; - const addHook = sinon.spy(function (item, queue) + const addHook = sinon.spy((item, queue) => { expect(item).to.equal(uploadItem); - expect(queue).to.equal(prep.queue); + expect(queue).to.equal(prep['queue']); queue.push(item); return true; }); - const uploadHook = sinon.spy(function (helper, item) + const uploadHook = sinon.spy((helper, item) => { expect(helper).to.equal(uploadHelper); expect(item).to.equal(uploadItem); return true; }); - const complete = sinon.spy(function () { /* empty */ }); + const complete = sinon.spy(() => { /* empty */ }); prep.registerFindHook(addHook); prep.registerUploadHook(uploadHook); prep.upload(uploadItem, complete); - expect(prep.queue).to.contain(uploadItem); + expect(prep['queue']).to.contain(uploadItem); prep.prepareItems(); @@ -76,49 +80,49 @@ describe('BasePrepare', function () prep.destroy(); }); - it('should call complete if no queue', function () + it('should call complete if no queue', () => { - const prep = new BasePrepare(); + const renderer = {} as AbstractRenderer; + const prep = new BasePrepare(renderer); function addHook() { return false; } - const complete = sinon.spy(function () { /* empty */ }); + const complete = sinon.spy(() => { /* empty */ }); prep.registerFindHook(addHook); - prep.upload({}, complete); + prep.upload({} as DisplayObject, complete); expect(complete.calledOnce).to.be.true; prep.destroy(); }); - it('should remove un-preparable items from queue', function () + it('should remove un-preparable items from queue', () => { - const prep = new BasePrepare(); + const renderer = {} as AbstractRenderer; + const prep = new BasePrepare(renderer); - const addHook = sinon.spy(function (item, queue) + const addHook = sinon.spy((item, queue) => { queue.push(item); return true; }); - const uploadHook = sinon.spy(function () - { - return false; - }); - const complete = sinon.spy(function () { /* empty */ }); + const uploadHook = sinon.spy(() => + false); + const complete = sinon.spy(() => { /* empty */ }); prep.registerFindHook(addHook); prep.registerUploadHook(uploadHook); - prep.upload({}, complete); + prep.upload({} as DisplayObject, complete); - expect(prep.queue).to.have.lengthOf(1); + expect(prep['queue']).to.have.lengthOf(1); prep.prepareItems(); - expect(prep.queue).to.be.empty; + expect(prep['queue']).to.be.empty; expect(addHook.calledOnce).to.be.true; expect(uploadHook.calledOnce).to.be.true; expect(complete.calledOnce).to.be.true; @@ -126,34 +130,33 @@ describe('BasePrepare', function () prep.destroy(); }); - it('should remove destroyed items from queue', function () + it('should remove destroyed items from queue', () => { - const prep = new BasePrepare(); + const renderer = {} as AbstractRenderer; + const prep = new BasePrepare(renderer); - const addHook = sinon.spy(function (item, queue) + const addHook = sinon.spy((item, queue) => { queue.push(item); return true; }); - const uploadHook = sinon.spy(function () - { - return false; - }); - const complete = sinon.spy(function () { /* empty */ }); + const uploadHook = sinon.spy(() => + false); + const complete = sinon.spy(() => { /* empty */ }); prep.registerFindHook(addHook); prep.registerUploadHook(uploadHook); - const item = {}; + const item = {} as DisplayObject; prep.upload(item, complete); - expect(prep.queue).to.have.lengthOf(1); + expect(prep['queue']).to.have.lengthOf(1); - item._destroyed = true; + item['_destroyed'] = true; prep.prepareItems(); - expect(prep.queue).to.be.empty; + expect(prep['queue']).to.be.empty; expect(addHook.calledOnce).to.be.true; expect(uploadHook.called).to.be.false; expect(complete.calledOnce).to.be.true; @@ -161,37 +164,35 @@ describe('BasePrepare', function () prep.destroy(); }); - it('should attach to the system ticker', function (done) + it('should attach to the system ticker', (done) => { - const prep = new BasePrepare(); + const renderer = {} as AbstractRenderer; + const prep = new BasePrepare(renderer); - const addHook = sinon.spy(function (item, queue) + const addHook = sinon.spy((item, queue) => { queue.push(item); return true; }); - const uploadHook = sinon.spy(function () - { - return true; - }); + const uploadHook = sinon.spy(() => true); - function complete() + const complete = sinon.spy(() => { - expect(prep.queue).to.be.empty; + expect(prep['queue']).to.be.empty; expect(addHook.calledOnce).to.be.true; expect(uploadHook.calledOnce).to.be.true; prep.destroy(); done(); - } + }); prep.registerFindHook(addHook); prep.registerUploadHook(uploadHook); - prep.upload({}, complete); + prep.upload({} as DisplayObject, complete); - expect(prep.queue).to.have.lengthOf(1); + expect(prep['queue']).to.have.lengthOf(1); expect(addHook.called).to.be.true; expect(uploadHook.called).to.be.false; expect(complete.called).to.not.be.ok; diff --git a/packages/prepare/test/CountLimiter.tests.ts b/packages/prepare/test/CountLimiter.tests.ts index 3d5a8c8949..3290ea1bf6 100644 --- a/packages/prepare/test/CountLimiter.tests.ts +++ b/packages/prepare/test/CountLimiter.tests.ts @@ -1,9 +1,9 @@ import { CountLimiter } from '@pixi/prepare'; import { expect } from 'chai'; -describe('CountLimiter', function () +describe('CountLimiter', () => { - it('should limit to specified number per beginFrame()', function () + it('should limit to specified number per beginFrame()', () => { const limit = new CountLimiter(3); diff --git a/packages/prepare/test/Prepare.tests.ts b/packages/prepare/test/Prepare.tests.ts index a89b05efaa..189847bfd7 100644 --- a/packages/prepare/test/Prepare.tests.ts +++ b/packages/prepare/test/Prepare.tests.ts @@ -4,9 +4,9 @@ import { Container } from '@pixi/display'; import { Graphics } from '@pixi/graphics'; import { expect } from 'chai'; -describe('Prepare', function () +describe('Prepare', () => { - it('should upload graphics vao and textures', function () + it('should upload graphics vao and textures', () => { const renderer = new Renderer({ width: 1, height: 1 }); const prepare = new Prepare(renderer); @@ -28,7 +28,7 @@ describe('Prepare', function () graphics.drawRect(0, 0, 10, 10); graphics.beginTextureFill({ texture }); graphics.drawRect(20, 20, 10, 10); - graphics.geometry.isBatchable = function () { return false; }; + graphics.geometry['isBatchable'] = () => false; container.addChild(graphics); prepare.add(container); diff --git a/packages/prepare/test/TimeLimiter.tests.ts b/packages/prepare/test/TimeLimiter.tests.ts index 467ff7f6bd..3300b58b44 100644 --- a/packages/prepare/test/TimeLimiter.tests.ts +++ b/packages/prepare/test/TimeLimiter.tests.ts @@ -1,8 +1,9 @@ import { TimeLimiter } from '@pixi/prepare'; import { expect } from 'chai'; -describe('TimeLimiter', function () +describe('TimeLimiter', () => { + // eslint-disable-next-line func-names it('should limit to stop after time from beginFrame()', function (done) { this.slow(500); @@ -15,7 +16,7 @@ describe('TimeLimiter', function () expect(limit.allowedToUpload()).to.be.true; } - setTimeout(function () + setTimeout(() => { expect(limit.allowedToUpload()).to.be.false; diff --git a/packages/runner/package.json b/packages/runner/package.json index 69a94e1e92..116738b657 100644 --- a/packages/runner/package.json +++ b/packages/runner/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/runner", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/runner.js", "module": "dist/esm/runner.js", "bundle": "dist/browser/runner.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/runner.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/runner.js" + } + } + }, "description": "A simple alternative to events and signals with an emphasis on performance.", "author": "Mat Groves", "contributors": [ diff --git a/packages/runner/src/Runner.ts b/packages/runner/src/Runner.ts index c90c99884c..c02319020a 100644 --- a/packages/runner/src/Runner.ts +++ b/packages/runner/src/Runner.ts @@ -40,7 +40,6 @@ * * myGame.update.emit(time); * ``` - * * @memberof PIXI */ export class Runner @@ -59,11 +58,12 @@ export class Runner this._aliasCount = 0; } + /* eslint-disable jsdoc/require-param, jsdoc/check-param-names */ /** * Dispatch/Broadcast Runner to all listeners added to the queue. - * * @param {...any} params - (optional) parameters to pass to each listener */ + /* eslint-enable jsdoc/require-param, jsdoc/check-param-names */ public emit(a0?: unknown, a1?: unknown, a2?: unknown, a3?: unknown, a4?: unknown, a5?: unknown, a6?: unknown, a7?: unknown): this { @@ -114,7 +114,6 @@ export class Runner * ``` * * The scope used will be the object itself. - * * @param {any} item - The object that will be listening. */ public add(item: unknown): this @@ -131,7 +130,6 @@ export class Runner /** * Remove a single listener from the dispatch queue. - * * @param {any} item - The listener that you would like to remove. */ public remove(item: unknown): this @@ -149,7 +147,6 @@ export class Runner /** * Check to see if the listener is already in the Runner - * * @param {any} item - The listener that you would like to check. */ public contains(item: unknown): boolean @@ -176,7 +173,6 @@ export class Runner /** * `true` if there are no this Runner contains no listeners - * * @readonly */ public get empty(): boolean @@ -186,7 +182,6 @@ export class Runner /** * The name of the runner. - * * @readonly */ public get name(): string diff --git a/packages/runner/test/Runner.tests.ts b/packages/runner/test/Runner.tests.ts index 7c4b88cb18..3aed18f28d 100644 --- a/packages/runner/test/Runner.tests.ts +++ b/packages/runner/test/Runner.tests.ts @@ -2,15 +2,15 @@ import { Runner } from '@pixi/runner'; import sinon from 'sinon'; import { expect } from 'chai'; -describe('Runner', function () +describe('Runner', () => { - it('should should exist', function () + it('should should exist', () => { expect(Runner).to.be.not.undefined; expect(typeof Runner).to.equal('function'); }); - it('should implement emit', function () + it('should implement emit', () => { const complete = new Runner('complete'); @@ -30,9 +30,10 @@ describe('Runner', function () expect(!complete.name).to.be.true; }); - it('should implement emit with arguments', function () + it('should implement emit with arguments', () => { const update = new Runner('update'); + // eslint-disable-next-line func-names const callback = sinon.spy(function (time, delta) { let len = 0; @@ -57,27 +58,28 @@ describe('Runner', function () expect(callback.calledOnce).to.be.true; }); - it('should throw an error with too many arguments', function () + it('should throw an error with too many arguments', () => { const complete = new Runner('complete'); complete.add({ - // eslint-disable-next-line no-unused-vars, no-empty-function - complete(a, b, c, d, e, f, g, h, i) {}, + // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function + complete(_a: any, _b: any, _c: any, _d: any, _e: any, _f: any, _g: any, _h: any, _i: any) {}, }); try { + // @ts-expect-error - testing to many arguments complete.emit(1, 2, 3, 4, 5, 6, 7, 8, 9); throw new Error('failed too many args'); } catch (e) { expect(!!e).to.be.true; - expect(e.message).to.equal('max arguments reached'); + expect((e as Error).message).to.equal('max arguments reached'); } }); - it('should implement multiple targets', function () + it('should implement multiple targets', () => { const complete = new Runner('complete'); const obj = { complete: sinon.spy() }; @@ -102,12 +104,12 @@ describe('Runner', function () expect(complete.empty).to.be.true; }); - it('should implement removeAll', function () + it('should implement removeAll', () => { const complete = new Runner('complete'); - // eslint-disable-next-line no-empty-function + // eslint-disable-next-line @typescript-eslint/no-empty-function const obj = { complete() {} }; - // eslint-disable-next-line no-empty-function + // eslint-disable-next-line @typescript-eslint/no-empty-function const obj2 = { complete() {} }; const obj3 = {}; @@ -122,17 +124,17 @@ describe('Runner', function () expect(complete.empty).to.be.true; }); - it('should not add items more than once', function () + it('should not add items more than once', () => { const complete = new Runner('complete'); - // eslint-disable-next-line no-empty-function + // eslint-disable-next-line @typescript-eslint/no-empty-function const obj = { complete() {} }; complete.add(obj).add(obj); expect(complete.items.length).to.equal(1); }); - it('should not not bug out is items are removed items whilst mid run', function () + it('should not not bug out is items are removed items whilst mid run', () => { const complete = new Runner('complete'); @@ -141,12 +143,15 @@ describe('Runner', function () for (let i = 0; i < 10; i++) { - // eslint-disable-next-line no-loop-func - const obj = { complete() - { - tick++; - complete.remove(obj); - } }; + const obj = { + id: 0, + // eslint-disable-next-line no-loop-func + complete() + { + tick++; + complete.remove(obj); + } + }; obj.id = i; objs.push(obj); @@ -154,7 +159,7 @@ describe('Runner', function () complete.add(obj); } - complete.run(); + complete.emit(); expect(complete.items.length).to.equal(0); expect(tick).to.equal(10); diff --git a/packages/settings/package.json b/packages/settings/package.json index 895bda2bf4..dd2cef4526 100644 --- a/packages/settings/package.json +++ b/packages/settings/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/settings", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/settings.js", "module": "dist/esm/settings.js", "bundle": "dist/browser/settings.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/settings.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/settings.js" + } + } + }, "description": "Collecting of user configurable settings used throughout PixiJS", "author": "Mat Groves", "contributors": [ diff --git a/packages/settings/src/settings.ts b/packages/settings/src/settings.ts index eb09d3702f..cd8228506e 100644 --- a/packages/settings/src/settings.ts +++ b/packages/settings/src/settings.ts @@ -4,7 +4,8 @@ import { canUploadSameBuffer } from './utils/canUploadSameBuffer'; import { GC_MODES, MIPMAP_MODES, MSAA_QUALITY, PRECISION, SCALE_MODES, WRAP_MODES } from '@pixi/constants'; import type { ENV } from '@pixi/constants'; -export interface IRenderOptions { +export interface IRenderOptions +{ view: HTMLCanvasElement; antialias: boolean; autoDensity: boolean; @@ -18,7 +19,8 @@ export interface IRenderOptions { legacy: boolean; } -export interface ISettings { +export interface ISettings +{ MIPMAP_TEXTURES: MIPMAP_MODES; ANISOTROPIC_LEVEL: number; RESOLUTION: number; @@ -64,7 +66,6 @@ export const settings: ISettings = { /** * If set to true WebGL will attempt make textures mimpaped by default. * Mipmapping will only succeed if the base texture uploaded has power of two dimensions. - * * @static * @name MIPMAP_TEXTURES * @memberof PIXI.settings @@ -76,7 +77,6 @@ export const settings: ISettings = { /** * Default anisotropic filtering level of textures. * Usually from 0 to 16 - * * @static * @name ANISOTROPIC_LEVEL * @memberof PIXI.settings @@ -87,7 +87,6 @@ export const settings: ISettings = { /** * Default resolution / device pixel ratio of the renderer. - * * @static * @name RESOLUTION * @memberof PIXI.settings @@ -98,7 +97,6 @@ export const settings: ISettings = { /** * Default filter resolution. - * * @static * @name FILTER_RESOLUTION * @memberof PIXI.settings @@ -109,7 +107,6 @@ export const settings: ISettings = { /** * Default filter samples. - * * @static * @name FILTER_MULTISAMPLE * @memberof PIXI.settings @@ -120,7 +117,6 @@ export const settings: ISettings = { /** * The maximum textures that this device supports. - * * @static * @name SPRITE_MAX_TEXTURES * @memberof PIXI.settings @@ -136,7 +132,6 @@ export const settings: ISettings = { * The default sprite batch size. * * The default aims to balance desktop and mobile devices. - * * @static * @name SPRITE_BATCH_SIZE * @memberof PIXI.settings @@ -148,22 +143,21 @@ export const settings: ISettings = { /** * The default render options if none are supplied to {@link PIXI.Renderer} * or {@link PIXI.CanvasRenderer}. - * * @static * @name RENDER_OPTIONS * @memberof PIXI.settings * @type {object} - * @property {HTMLCanvasElement} view=null - * @property {boolean} antialias=false - * @property {boolean} autoDensity=false - * @property {boolean} useContextAlpha=true - * @property {number} backgroundColor=0x000000 - * @property {number} backgroundAlpha=1 - * @property {boolean} clearBeforeRender=true - * @property {boolean} preserveDrawingBuffer=false - * @property {number} width=800 - * @property {number} height=600 - * @property {boolean} legacy=false + * @property {HTMLCanvasElement} [view=null] - + * @property {boolean} [antialias=false] - + * @property {boolean} [autoDensity=false] - + * @property {boolean} [useContextAlpha=true] - + * @property {number} [backgroundColor=0x000000] - + * @property {number} [backgroundAlpha=1] - + * @property {boolean} [clearBeforeRender=true] - + * @property {boolean} [preserveDrawingBuffer=false] - + * @property {number} [width=800] - + * @property {number} [height=600] - + * @property {boolean} [legacy=false] - */ RENDER_OPTIONS: { view: null, @@ -181,7 +175,6 @@ export const settings: ISettings = { /** * Default Garbage Collection mode. - * * @static * @name GC_MODE * @memberof PIXI.settings @@ -192,7 +185,6 @@ export const settings: ISettings = { /** * Default Garbage Collection max idle. - * * @static * @name GC_MAX_IDLE * @memberof PIXI.settings @@ -203,7 +195,6 @@ export const settings: ISettings = { /** * Default Garbage Collection maximum check count. - * * @static * @name GC_MAX_CHECK_COUNT * @memberof PIXI.settings @@ -214,7 +205,6 @@ export const settings: ISettings = { /** * Default wrap modes that are supported by pixi. - * * @static * @name WRAP_MODE * @memberof PIXI.settings @@ -225,7 +215,6 @@ export const settings: ISettings = { /** * Default scale mode for textures. - * * @static * @name SCALE_MODE * @memberof PIXI.settings @@ -236,7 +225,6 @@ export const settings: ISettings = { /** * Default specify float precision in vertex shader. - * * @static * @name PRECISION_VERTEX * @memberof PIXI.settings @@ -248,7 +236,6 @@ export const settings: ISettings = { /** * Default specify float precision in fragment shader. * iOS is best set at highp due to https://github.com/pixijs/pixi.js/issues/3742 - * * @static * @name PRECISION_FRAGMENT * @memberof PIXI.settings @@ -259,7 +246,6 @@ export const settings: ISettings = { /** * Can we upload the same buffer in a single frame? - * * @static * @name CAN_UPLOAD_SAME_BUFFER * @memberof PIXI.settings @@ -269,7 +255,6 @@ export const settings: ISettings = { /** * Enables bitmap creation before image load. This feature is experimental. - * * @static * @name CREATE_IMAGE_BITMAP * @memberof PIXI.settings @@ -282,7 +267,6 @@ export const settings: ISettings = { * If true PixiJS will Math.floor() x/y values when rendering, stopping pixel interpolation. * Advantages can include sharper image quality (like text) and faster rendering on canvas. * The main disadvantage is movement of objects may appear less smooth. - * * @static * @constant * @memberof PIXI.settings diff --git a/packages/settings/src/utils/canUploadSameBuffer.ts b/packages/settings/src/utils/canUploadSameBuffer.ts index c2706314a2..778c77c456 100644 --- a/packages/settings/src/utils/canUploadSameBuffer.ts +++ b/packages/settings/src/utils/canUploadSameBuffer.ts @@ -4,9 +4,8 @@ import { isMobile } from './isMobile'; * Uploading the same buffer multiple times in a single frame can cause performance issues. * Apparent on iOS so only check for that at the moment * This check may become more complex if this issue pops up elsewhere. - * * @private - * @returns {boolean} + * @returns {boolean} `true` if the same buffer may be uploaded more than once. */ export function canUploadSameBuffer(): boolean { diff --git a/packages/settings/src/utils/maxRecommendedTextures.ts b/packages/settings/src/utils/maxRecommendedTextures.ts index 0eb88fd526..e3482e31ff 100644 --- a/packages/settings/src/utils/maxRecommendedTextures.ts +++ b/packages/settings/src/utils/maxRecommendedTextures.ts @@ -8,10 +8,9 @@ import { isMobile } from './isMobile'; * * In v4, all mobile devices were limited to 4 texture units because for this. * In v5, we allow all texture units to be used on modern Apple or Android devices. - * * @private * @param {number} max - * @returns {number} + * @returns {number} The maximum recommended texture units to use. */ export function maxRecommendedTextures(max: number): number { diff --git a/packages/settings/test/settings.tests.ts b/packages/settings/test/settings.tests.ts index 82a22abf4f..a7326fca67 100644 --- a/packages/settings/test/settings.tests.ts +++ b/packages/settings/test/settings.tests.ts @@ -1,79 +1,79 @@ import { settings } from '@pixi/settings'; import { expect } from 'chai'; -describe('settings', function () +describe('settings', () => { - it('should have MIPMAP_TEXTURES', function () + it('should have MIPMAP_TEXTURES', () => { expect(settings.MIPMAP_TEXTURES).to.be.a('number'); }); - it('should have RESOLUTION', function () + it('should have RESOLUTION', () => { expect(settings.RESOLUTION).to.be.a('number'); }); - it('should have PREFER_ENV', function () + it('should have PREFER_ENV', () => { expect(settings.PREFER_ENV).to.be.a('number'); }); - it('should have FILTER_RESOLUTION', function () + it('should have FILTER_RESOLUTION', () => { expect(settings.FILTER_RESOLUTION).to.be.a('number'); }); - it('should have SPRITE_MAX_TEXTURES', function () + it('should have SPRITE_MAX_TEXTURES', () => { expect(settings.SPRITE_MAX_TEXTURES).to.be.a('number'); }); - it('should have SPRITE_BATCH_SIZE', function () + it('should have SPRITE_BATCH_SIZE', () => { expect(settings.SPRITE_BATCH_SIZE).to.be.a('number'); }); - it('should have RENDER_OPTIONS', function () + it('should have RENDER_OPTIONS', () => { expect(settings.RENDER_OPTIONS).to.be.an('object'); }); - it('should have GC_MODE', function () + it('should have GC_MODE', () => { expect(settings.GC_MODE).to.be.a('number'); }); - it('should have GC_MAX_IDLE', function () + it('should have GC_MAX_IDLE', () => { expect(settings.GC_MAX_IDLE).to.be.a('number'); }); - it('should have GC_MAX_CHECK_COUNT', function () + it('should have GC_MAX_CHECK_COUNT', () => { expect(settings.GC_MAX_CHECK_COUNT).to.be.a('number'); }); - it('should have WRAP_MODE', function () + it('should have WRAP_MODE', () => { expect(settings.WRAP_MODE).to.be.a('number'); }); - it('should have SCALE_MODE', function () + it('should have SCALE_MODE', () => { expect(settings.SCALE_MODE).to.be.a('number'); }); - it('should have PRECISION_VERTEX', function () + it('should have PRECISION_VERTEX', () => { expect(settings.PRECISION_VERTEX).to.be.a.string; }); - it('should have PRECISION_FRAGMENT', function () + it('should have PRECISION_FRAGMENT', () => { expect(settings.PRECISION_FRAGMENT).to.be.a.string; }); - it('should have CAN_UPLOAD_SAME_BUFFER', function () + it('should have CAN_UPLOAD_SAME_BUFFER', () => { expect(settings.CAN_UPLOAD_SAME_BUFFER).to.be.a('boolean'); }); diff --git a/packages/sprite-animated/package.json b/packages/sprite-animated/package.json index ee1049cea6..18bf65d9b1 100644 --- a/packages/sprite-animated/package.json +++ b/packages/sprite-animated/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/sprite-animated", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/sprite-animated.js", "module": "dist/esm/sprite-animated.js", "bundle": "dist/browser/sprite-animated.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/sprite-animated.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/sprite-animated.js" + } + } + }, "description": "Sprite Animations as depicted by playing a series of Textures", "author": "Mat Groves", "contributors": [ @@ -25,8 +38,8 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/core": "6.3.0", - "@pixi/sprite": "6.3.0", - "@pixi/ticker": "6.3.0" + "@pixi/core": "6.4.2", + "@pixi/sprite": "6.4.2", + "@pixi/ticker": "6.4.2" } } diff --git a/packages/sprite-animated/src/AnimatedSprite.ts b/packages/sprite-animated/src/AnimatedSprite.ts index 68170f380b..79f646852a 100644 --- a/packages/sprite-animated/src/AnimatedSprite.ts +++ b/packages/sprite-animated/src/AnimatedSprite.ts @@ -31,21 +31,18 @@ import type { IDestroyOptions } from '@pixi/display'; * ... * } * ``` - * * @memberof PIXI */ export class AnimatedSprite extends Sprite { /** * The speed that the AnimatedSprite will play at. Higher is faster, lower is slower. - * * @default 1 */ public animationSpeed: number; /** * Whether or not the animate sprite repeats after playing. - * * @default true */ public loop: boolean; @@ -58,14 +55,12 @@ export class AnimatedSprite extends Sprite * of the frame (e.g. left foot). * * Note: Enabling this will override any previously set `anchor` on each frame change. - * * @default false */ public updateAnchor: boolean; /** * User-assigned function to call when an AnimatedSprite finishes playing. - * * @example * animation.onComplete = function () { * // finished! @@ -75,7 +70,6 @@ export class AnimatedSprite extends Sprite /** * User-assigned function to call when an AnimatedSprite changes which texture is being rendered. - * * @example * animation.onFrameChange = function () { * // updated! @@ -86,7 +80,6 @@ export class AnimatedSprite extends Sprite /** * User-assigned function to call when `loop` is true, and an AnimatedSprite is played and * loops around to start again. - * * @example * animation.onLoop = function () { * // looped! @@ -100,14 +93,12 @@ export class AnimatedSprite extends Sprite /** * `true` uses PIXI.Ticker.shared to auto update animation time. - * * @default true */ private _autoUpdate: boolean; /** * `true` if the instance is currently connected to PIXI.Ticker.shared to auto update animation time. - * * @default false */ private _isConnectedToTicker: boolean; @@ -123,7 +114,7 @@ export class AnimatedSprite extends Sprite * objects that make up the animation. * @param {boolean} [autoUpdate=true] - Whether to use PIXI.Ticker.shared to auto update animation time. */ - constructor(textures: Texture[]|FrameObject[], autoUpdate = true) + constructor(textures: Texture[] | FrameObject[], autoUpdate = true) { super(textures[0] instanceof Texture ? textures[0] : textures[0].texture); @@ -181,7 +172,6 @@ export class AnimatedSprite extends Sprite /** * Stops the AnimatedSprite and goes to a specific frame. - * * @param frameNumber - Frame index to stop at. */ public gotoAndStop(frameNumber: number): void @@ -200,7 +190,6 @@ export class AnimatedSprite extends Sprite /** * Goes to a specific frame and begins playing the AnimatedSprite. - * * @param frameNumber - Frame index to start at. */ public gotoAndPlay(frameNumber: number): void @@ -219,7 +208,6 @@ export class AnimatedSprite extends Sprite /** * Updates the object transform for rendering. - * * @param deltaTime - Time since last tick. */ update(deltaTime: number): void @@ -328,7 +316,6 @@ export class AnimatedSprite extends Sprite /** * Stops the AnimatedSprite and destroys it. - * * @param {object|boolean} [options] - Options parameter. A boolean will act as if all options * have been set to that value. * @param {boolean} [options.children=false] - If set to true, all the children will have their destroy @@ -336,7 +323,7 @@ export class AnimatedSprite extends Sprite * @param {boolean} [options.texture=false] - Should it destroy the current texture of the sprite as well. * @param {boolean} [options.baseTexture=false] - Should it destroy the base texture of the sprite as well. */ - public destroy(options?: IDestroyOptions|boolean): void + public destroy(options?: IDestroyOptions | boolean): void { this.stop(); super.destroy(options); @@ -348,9 +335,8 @@ export class AnimatedSprite extends Sprite /** * A short hand way of creating an AnimatedSprite from an array of frame ids. - * * @param frames - The array of frames ids the AnimatedSprite will use as its texture frames. - * @return - The new animated sprite with the specified frames. + * @returns - The new animated sprite with the specified frames. */ public static fromFrames(frames: string[]): AnimatedSprite { @@ -366,9 +352,8 @@ export class AnimatedSprite extends Sprite /** * A short hand way of creating an AnimatedSprite from an array of image ids. - * * @param images - The array of image urls the AnimatedSprite will use as its texture frames. - * @return The new animate sprite with the specified images as frames. + * @returns The new animate sprite with the specified images as frames. */ public static fromImages(images: string[]): AnimatedSprite { @@ -385,7 +370,6 @@ export class AnimatedSprite extends Sprite /** * The total number of frames in the AnimatedSprite. This is the same as number of textures * assigned to the AnimatedSprite. - * * @readonly * @default 0 */ @@ -395,12 +379,12 @@ export class AnimatedSprite extends Sprite } /** The array of textures used for this AnimatedSprite. */ - get textures(): Texture[]|FrameObject[] + get textures(): Texture[] | FrameObject[] { return this._textures; } - set textures(value: Texture[]|FrameObject[]) + set textures(value: Texture[] | FrameObject[]) { if (value[0] instanceof Texture) { @@ -425,7 +409,6 @@ export class AnimatedSprite extends Sprite /** * The AnimatedSprites current frame index. - * * @readonly */ get currentFrame(): number @@ -442,7 +425,6 @@ export class AnimatedSprite extends Sprite /** * Indicates if the AnimatedSprite is currently playing. - * * @readonly */ get playing(): boolean @@ -477,7 +459,8 @@ export class AnimatedSprite extends Sprite } /** @memberof PIXI.AnimatedSprite */ -export interface FrameObject { +export interface FrameObject +{ /** The {@link PIXI.Texture} of the frame. */ texture: Texture; diff --git a/packages/sprite-animated/test/AnimatedSprite.tests.ts b/packages/sprite-animated/test/AnimatedSprite.tests.ts index 02ba960e7a..f2d73bdb66 100644 --- a/packages/sprite-animated/test/AnimatedSprite.tests.ts +++ b/packages/sprite-animated/test/AnimatedSprite.tests.ts @@ -2,329 +2,345 @@ import { AnimatedSprite } from '@pixi/sprite-animated'; import { Texture } from '@pixi/core'; import { expect } from 'chai'; -describe('AnimatedSprite', function () +describe('AnimatedSprite', () => { - describe('instance', function () + describe('instance', () => { - beforeEach(function () + let textures: Texture[]; + let sprite: AnimatedSprite; + + beforeEach(() => { - this.textures = [Texture.EMPTY]; + textures = [Texture.EMPTY]; }); - afterEach(function () + afterEach(() => { - expect(this.sprite.animationSpeed).to.be.equal(1); - expect(this.sprite.loop).to.be.true; - expect(this.sprite.onComplete).to.be.null; - expect(this.sprite.onFrameChange).to.be.null; - expect(this.sprite.onLoop).to.be.null; - expect(this.sprite.playing).to.be.false; + expect(sprite.animationSpeed).to.be.equal(1); + expect(sprite.loop).to.be.true; + expect(sprite.onComplete).to.be.null; + expect(sprite.onFrameChange).to.be.null; + expect(sprite.onLoop).to.be.null; + expect(sprite.playing).to.be.false; - this.sprite.destroy(); - this.sprite = null; + sprite.destroy(); + sprite = null; }); - it('should be correct with default options', function () + it('should be correct with default options', () => { - this.sprite = new AnimatedSprite(this.textures); - expect(this.sprite._autoUpdate).to.be.true; + sprite = new AnimatedSprite(textures); + expect(sprite['_autoUpdate']).to.be.true; }); - it('should be correct with autoUpdate=false', function () + it('should be correct with autoUpdate=false', () => { - this.sprite = new AnimatedSprite(this.textures, false); - expect(this.sprite._autoUpdate).to.be.false; + sprite = new AnimatedSprite(textures, false); + expect(sprite['_autoUpdate']).to.be.false; }); - it('should be correct with autoUpdate=true but then turned off via setter', function () + it('should be correct with autoUpdate=true but then turned off via setter', () => { - this.sprite = new AnimatedSprite(this.textures, true); - expect(this.sprite._autoUpdate).to.be.true; - this.sprite.autoUpdate = false; - expect(this.sprite._autoUpdate).to.be.false; + sprite = new AnimatedSprite(textures, true); + expect(sprite['_autoUpdate']).to.be.true; + sprite.autoUpdate = false; + expect(sprite['_autoUpdate']).to.be.false; }); }); - describe('.stop()', function () + describe('.stop()', () => { - before(function () + let sprite: AnimatedSprite; + + before(() => { - this.sprite = new AnimatedSprite([Texture.EMPTY], false); + sprite = new AnimatedSprite([Texture.EMPTY], false); }); - after(function () + after(() => { - this.sprite.destroy(); - this.sprite = null; + sprite.destroy(); + sprite = null; }); - afterEach(function () + afterEach(() => { - this.sprite.stop(); - expect(this.sprite.playing).to.be.false; + sprite.stop(); + expect(sprite.playing).to.be.false; }); - it('should stop playing if it is playing', function () + it('should stop playing if it is playing', () => { - this.sprite._playing = true; + sprite['_playing'] = true; }); - it('should do nothing if it is not playing', function () + it('should do nothing if it is not playing', () => { - this.sprite._playing = false; + sprite['_playing'] = false; }); }); - describe('.play()', function () + describe('.play()', () => { - before(function () + let sprite: AnimatedSprite; + + before(() => { - this.sprite = new AnimatedSprite([Texture.EMPTY], false); + sprite = new AnimatedSprite([Texture.EMPTY], false); }); - after(function () + after(() => { - this.sprite.destroy(); - this.sprite = null; + sprite.destroy(); + sprite = null; }); - afterEach(function () + afterEach(() => { - this.sprite.play(); - expect(this.sprite.playing).to.be.true; + sprite.play(); + expect(sprite.playing).to.be.true; }); - it('should start playing if it is not playing', function () + it('should start playing if it is not playing', () => { - this.sprite._playing = false; + sprite['_playing'] = false; }); - it('should do nothing if it is playing', function () + it('should do nothing if it is playing', () => { - this.sprite._playing = true; + sprite['_playing'] = true; }); }); - describe('.onComplete()', function () + describe('.onComplete()', () => { - before(function () + let sprite: AnimatedSprite; + + before(() => { - this.sprite = new AnimatedSprite([Texture.WHITE, Texture.WHITE, Texture.EMPTY]); - this.sprite.animationSpeed = 0.5; - this.sprite.loop = false; + sprite = new AnimatedSprite([Texture.WHITE, Texture.WHITE, Texture.EMPTY]); + sprite.animationSpeed = 0.5; + sprite.loop = false; }); - after(function () + after(() => { - this.sprite.destroy(); - this.sprite = null; + sprite.destroy(); + sprite = null; }); + // eslint-disable-next-line func-names it('should fire onComplete', function (done) { this.timeout(( - this.sprite.textures.length * 1000 / 60 / this.sprite.animationSpeed) - + (1000 / 60 / this.sprite.animationSpeed * 0.9) + sprite.textures.length * 1000 / 60 / sprite.animationSpeed) + + (1000 / 60 / sprite.animationSpeed * 0.9) ); - this.sprite.onComplete = () => + sprite.onComplete = () => { - this.sprite.onComplete = null; + sprite.onComplete = null; done(); }; - this.sprite.play(); - expect(this.sprite.playing).to.be.true; + sprite.play(); + expect(sprite.playing).to.be.true; }); - it('should the current texture be the last item in textures', function (done) + it('should the current texture be the last item in textures', (done) => { - this.sprite.play(); - this.sprite.onComplete = () => + sprite.play(); + sprite.onComplete = () => { - expect(this.sprite.texture === this.sprite.textures[this.sprite.currentFrame]).to.be.true; - this.sprite.onComplete = null; + expect(sprite.texture === sprite.textures[sprite.currentFrame]).to.be.true; + sprite.onComplete = null; done(); }; }); }); - describe('.gotoAndPlay()', function () + describe('.gotoAndPlay()', () => { - before(function () + let sprite: AnimatedSprite; + + before(() => { - this.sprite = new AnimatedSprite([Texture.EMPTY, Texture.EMPTY, Texture.EMPTY]); - this.sprite.animationSpeed = 0.5; - this.sprite.loop = false; + sprite = new AnimatedSprite([Texture.EMPTY, Texture.EMPTY, Texture.EMPTY]); + sprite.animationSpeed = 0.5; + sprite.loop = false; }); - after(function () + after(() => { - this.sprite.destroy(); - this.sprite = null; + sprite.destroy(); + sprite = null; }); - it('should fire frame after start frame during one play and fire onComplete', function (done) + it('should fire frame after start frame during one play and fire onComplete', (done) => { - const frameIds = []; + const frameIds = [] as number[]; - this.sprite.onComplete = () => + sprite.onComplete = () => { expect(frameIds).to.deep.equal([1, 2]); - expect(this.sprite.playing).to.be.false; - this.sprite.onComplete = null; - this.sprite.onFrameChange = null; + expect(sprite.playing).to.be.false; + sprite.onComplete = null; + sprite.onFrameChange = null; done(); }; - this.sprite.onFrameChange = (frame) => + sprite.onFrameChange = (frame) => { frameIds.push(frame); }; - this.sprite.gotoAndPlay(1); - expect(this.sprite.playing).to.be.true; + sprite.gotoAndPlay(1); + expect(sprite.playing).to.be.true; }); }); - describe('.gotoAndStop()', function () + describe('.gotoAndStop()', () => { - before(function () + let sprite: AnimatedSprite; + + before(() => { - this.sprite = new AnimatedSprite([Texture.EMPTY, Texture.EMPTY, Texture.EMPTY]); - this.sprite.animationSpeed = 0.5; - this.sprite.loop = false; + sprite = new AnimatedSprite([Texture.EMPTY, Texture.EMPTY, Texture.EMPTY]); + sprite.animationSpeed = 0.5; + sprite.loop = false; }); - after(function () + after(() => { - this.sprite.destroy(); - this.sprite = null; + sprite.destroy(); + sprite = null; }); - beforeEach(function () + beforeEach(() => { - this.sprite._playing = false; + sprite['_playing'] = false; }); - it('should fire onFrameChange on target frame', function (done) + it('should fire onFrameChange on target frame', (done) => { const targetFrame = 1; - this.sprite.onFrameChange = (frame) => + sprite.onFrameChange = (frame) => { expect(frame).to.equal(targetFrame); - expect(this.sprite.playing).to.be.false; - this.sprite.onComplete = null; - this.sprite.onFrameChange = null; + expect(sprite.playing).to.be.false; + sprite.onComplete = null; + sprite.onFrameChange = null; done(); }; - this.sprite.gotoAndStop(targetFrame); - expect(this.sprite.playing).to.be.false; + sprite.gotoAndStop(targetFrame); + expect(sprite.playing).to.be.false; }); - it('should not fire onFrameChange on target frame if current is already target', function () + it('should not fire onFrameChange on target frame if current is already target', () => { let fired = false; const targetFrame = 1; - this.sprite.gotoAndStop(targetFrame); + sprite.gotoAndStop(targetFrame); - this.sprite.onFrameChange = () => + sprite.onFrameChange = () => { fired = true; }; - this.sprite.gotoAndStop(targetFrame); - expect(this.sprite.playing).to.be.false; + sprite.gotoAndStop(targetFrame); + expect(sprite.playing).to.be.false; expect(fired).to.be.false; }); }); - describe('.onFrameChange()', function () + describe('.onFrameChange()', () => { - before(function () + let sprite: AnimatedSprite; + + before(() => { - this.sprite = new AnimatedSprite([Texture.EMPTY, Texture.WHITE, Texture.EMPTY]); - this.sprite.animationSpeed = 0.5; - this.sprite.loop = false; + sprite = new AnimatedSprite([Texture.EMPTY, Texture.WHITE, Texture.EMPTY]); + sprite.animationSpeed = 0.5; + sprite.loop = false; }); - after(function () + after(() => { - this.sprite.destroy(); - this.sprite = null; + sprite.destroy(); + sprite = null; }); - beforeEach(function () + beforeEach(() => { - this.sprite._playing = false; + sprite['_playing'] = false; }); - it('should fire every frame(except current) during one play', function (done) + it('should fire every frame(except current) during one play', (done) => { - const frameIds = []; + const frameIds = [] as number[]; - this.sprite.gotoAndStop(0); - this.sprite.onComplete = () => + sprite.gotoAndStop(0); + sprite.onComplete = () => { expect(frameIds).to.deep.equal([1, 2]); // from 0 to 2, triggers onFrameChange at 1,2. - expect(this.sprite.currentFrame).to.equal(2); - this.sprite.onComplete = null; - this.sprite.onFrameChange = null; + expect(sprite.currentFrame).to.equal(2); + sprite.onComplete = null; + sprite.onFrameChange = null; done(); }; - this.sprite.onFrameChange = (frame) => + sprite.onFrameChange = (frame) => { frameIds.push(frame); }; - this.sprite.play(); - expect(this.sprite.playing).to.be.true; + sprite.play(); + expect(sprite.playing).to.be.true; }); - it('should fire every frame(except current) during one play - reverse', function (done) + it('should fire every frame(except current) during one play - reverse', (done) => { - const frameIds = []; + const frameIds = [] as number[]; - this.sprite.gotoAndStop(2); - this.sprite.animationSpeed = -0.5; - this.sprite.onComplete = () => + sprite.gotoAndStop(2); + sprite.animationSpeed = -0.5; + sprite.onComplete = () => { expect(frameIds).to.deep.equal([1, 0]); // from 2 to 0, triggers onFrameChange at 1,0. - expect(this.sprite.currentFrame).to.equal(0); - this.sprite.onComplete = null; - this.sprite.onFrameChange = null; + expect(sprite.currentFrame).to.equal(0); + sprite.onComplete = null; + sprite.onFrameChange = null; done(); }; - this.sprite.onFrameChange = (frame) => + sprite.onFrameChange = (frame) => { frameIds.push(frame); }; - this.sprite.play(); - expect(this.sprite.playing).to.be.true; + sprite.play(); + expect(sprite.playing).to.be.true; }); - it('should fire every frame(except current) during one play - from not start/end', function (done) + it('should fire every frame(except current) during one play - from not start/end', (done) => { - const frameIds = []; + const frameIds = [] as number[]; - this.sprite.gotoAndStop(1); - this.sprite.animationSpeed = -0.5; - this.sprite.onComplete = () => + sprite.gotoAndStop(1); + sprite.animationSpeed = -0.5; + sprite.onComplete = () => { expect(frameIds).to.deep.equal([0]); // from 1 to 0, triggers onFrameChange at 0. - expect(this.sprite.currentFrame).to.equal(0); - this.sprite.onComplete = null; - this.sprite.onFrameChange = null; + expect(sprite.currentFrame).to.equal(0); + sprite.onComplete = null; + sprite.onFrameChange = null; done(); }; - this.sprite.onFrameChange = (frame) => + sprite.onFrameChange = (frame) => { frameIds.push(frame); }; - this.sprite.play(); - expect(this.sprite.playing).to.be.true; + sprite.play(); + expect(sprite.playing).to.be.true; }); }); - describe('.textures', function () + describe('.textures', () => { - it('should set the first frame when setting new textures', function (done) + it('should set the first frame when setting new textures', (done) => { const orig1 = Texture.EMPTY.clone(); const orig2 = Texture.EMPTY.clone(); diff --git a/packages/sprite-tiling/package.json b/packages/sprite-tiling/package.json index cf51452940..68e3d0f84f 100644 --- a/packages/sprite-tiling/package.json +++ b/packages/sprite-tiling/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/sprite-tiling", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/sprite-tiling.js", "module": "dist/esm/sprite-tiling.js", "bundle": "dist/browser/sprite-tiling.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/sprite-tiling.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/sprite-tiling.js" + } + } + }, "description": "Tiling Sprites for faster rendering a tiling image", "author": "Mat Groves", "contributors": [ @@ -25,11 +38,11 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/constants": "6.3.0", - "@pixi/core": "6.3.0", - "@pixi/display": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/sprite": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/constants": "6.4.2", + "@pixi/core": "6.4.2", + "@pixi/display": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/sprite": "6.4.2", + "@pixi/utils": "6.4.2" } } diff --git a/packages/sprite-tiling/src/TilingSprite.ts b/packages/sprite-tiling/src/TilingSprite.ts index e39fe09377..d2af957c47 100644 --- a/packages/sprite-tiling/src/TilingSprite.ts +++ b/packages/sprite-tiling/src/TilingSprite.ts @@ -12,7 +12,6 @@ export interface TilingSprite extends GlobalMixins.TilingSprite {} /** * A tiling sprite is a fast way of rendering a tiling image. - * * @memberof PIXI */ export class TilingSprite extends Sprite @@ -29,7 +28,6 @@ export class TilingSprite extends Sprite * * This will make the texture coordinates assigned to each vertex dependent on the value of the anchor. Without * this, the top-left corner always gets the (0, 0) texture coordinate. - * * @default false */ public uvRespectAnchor: boolean; @@ -56,7 +54,6 @@ export class TilingSprite extends Sprite /** * Plugin that is responsible for rendering this element. * Allows to customize the rendering process without overriding '_render' method. - * * @default 'tilingSprite' */ this.pluginName = 'tilingSprite'; @@ -66,7 +63,6 @@ export class TilingSprite extends Sprite /** * Changes frame clamping in corresponding textureTransform, shortcut * Change to -0.5 to add a pixel to the edge, recommended for transparent trimmed textures in atlas - * * @default 0.5 * @member {number} */ @@ -87,7 +83,7 @@ export class TilingSprite extends Sprite return this.tileTransform.scale; } - set tileScale(value: ObservablePoint) + set tileScale(value: IPointData) { this.tileTransform.scale.copyFrom(value as IPoint); } @@ -117,7 +113,6 @@ export class TilingSprite extends Sprite /** * Renders the object using the WebGL renderer - * * @param renderer - The renderer */ protected _render(renderer: Renderer): void @@ -150,9 +145,8 @@ export class TilingSprite extends Sprite /** * Gets the local bounds of the sprite object. - * * @param rect - Optional output rectangle. - * @return The bounds. + * @returns The bounds. */ public getLocalBounds(rect?: Rectangle): Rectangle { @@ -182,9 +176,8 @@ export class TilingSprite extends Sprite /** * Checks if a point is inside this tiling sprite. - * * @param point - The point to check. - * @return Whether or not the sprite contains the point. + * @returns Whether or not the sprite contains the point. */ public containsPoint(point: IPointData): boolean { @@ -209,7 +202,6 @@ export class TilingSprite extends Sprite /** * Destroys this sprite and optionally its texture and children - * * @param {object|boolean} [options] - Options parameter. A boolean will act as if all options * have been set to that value * @param {boolean} [options.children=false] - if set to true, all the children will have their destroy @@ -217,7 +209,7 @@ export class TilingSprite extends Sprite * @param {boolean} [options.texture=false] - Should it destroy the current texture of the sprite as well * @param {boolean} [options.baseTexture=false] - Should it destroy the base texture of the sprite as well */ - public destroy(options?: IDestroyOptions|boolean): void + public destroy(options?: IDestroyOptions | boolean): void { super.destroy(options); @@ -228,15 +220,14 @@ export class TilingSprite extends Sprite /** * Helper function that creates a new tiling sprite based on the source you provide. * The source can be - frame id, image url, video url, canvas element, video element, base texture - * * @static * @param {string|PIXI.Texture|HTMLCanvasElement|HTMLVideoElement} source - Source to create texture from - * @param {Object} options - See {@link PIXI.BaseTexture}'s constructor for options. + * @param {object} options - See {@link PIXI.BaseTexture}'s constructor for options. * @param {number} options.width - required width of the tiling sprite * @param {number} options.height - required height of the tiling sprite - * @return {PIXI.TilingSprite} The newly created texture + * @returns {PIXI.TilingSprite} The newly created texture */ - static from(source: TextureSource, options: ISize & IBaseTextureOptions): TilingSprite + static from(source: TextureSource | Texture, options: ISize & IBaseTextureOptions): TilingSprite { const texture = (source instanceof Texture) ? source diff --git a/packages/sprite-tiling/src/TilingSpriteRenderer.ts b/packages/sprite-tiling/src/TilingSpriteRenderer.ts index cb208936ab..481d3a9eb9 100644 --- a/packages/sprite-tiling/src/TilingSpriteRenderer.ts +++ b/packages/sprite-tiling/src/TilingSpriteRenderer.ts @@ -16,7 +16,6 @@ const tempMat = new Matrix(); /** * WebGL renderer plugin for tiling sprites - * * @class * @memberof PIXI * @extends PIXI.ObjectRenderer @@ -30,7 +29,6 @@ export class TilingSpriteRenderer extends ObjectRenderer /** * constructor for renderer - * * @param {PIXI.Renderer} renderer - The renderer this tiling awesomeness works for. */ constructor(renderer: Renderer) @@ -44,16 +42,13 @@ export class TilingSpriteRenderer extends ObjectRenderer /** * The WebGL state in which this renderer will work. - * * @member {PIXI.State} * @readonly */ this.state = State.for2d(); } - /** - * Creates shaders when context is initialized. - */ + /** Creates shaders when context is initialized. */ contextChange(): void { const renderer = this.renderer; diff --git a/packages/sprite-tiling/test/TilingSprite.tests.ts b/packages/sprite-tiling/test/TilingSprite.tests.ts index ccbd77e1e8..05a07499c1 100644 --- a/packages/sprite-tiling/test/TilingSprite.tests.ts +++ b/packages/sprite-tiling/test/TilingSprite.tests.ts @@ -1,4 +1,4 @@ -import { Container } from '@pixi/display'; +import { Bounds, Container } from '@pixi/display'; import { Texture, BaseTexture } from '@pixi/core'; import { Point, Rectangle } from '@pixi/math'; import { Sprite } from '@pixi/sprite'; @@ -6,11 +6,11 @@ import { TilingSprite } from '@pixi/sprite-tiling'; import sinon from 'sinon'; import { expect } from 'chai'; -describe('TilingSprite', function () +describe('TilingSprite', () => { - describe('getBounds()', function () + describe('getBounds()', () => { - it('must have correct value according to _width, _height and anchor', function () + it('must have correct value according to _width, _height and anchor', () => { const parent = new Container(); const texture = new Texture(new BaseTexture()); @@ -31,9 +31,9 @@ describe('TilingSprite', function () }); }); - describe('.from()', function () + describe('.from()', () => { - it('should build from texture', function () + it('should build from texture', () => { const sprite = TilingSprite.from(Texture.EMPTY, { width: 1, @@ -43,7 +43,7 @@ describe('TilingSprite', function () sprite.destroy(); }); - it('should build a texture from source', function () + it('should build a texture from source', () => { const canvas = document.createElement('canvas'); @@ -59,88 +59,96 @@ describe('TilingSprite', function () }); }); - describe('.getLocalBounds()', function () + describe('.getLocalBounds()', () => { - before(function () + let tileSprite: TilingSprite; + + before(() => { - this.tileSprite = new TilingSprite(Texture.EMPTY, 1, 2); - this.tileSprite.anchor.set(3, 4); + tileSprite = new TilingSprite(Texture.EMPTY, 1, 2); + tileSprite.anchor.set(3, 4); }); - beforeEach(function () + beforeEach(() => { sinon.stub(Sprite.prototype, 'getLocalBounds'); - this.tileSprite._bounds = { getRectangle: sinon.spy() }; + tileSprite['_bounds'] = { getRectangle: sinon.spy() } as unknown as Bounds; }); - afterEach(function () + afterEach(() => { + // @ts-expect-error --- Sprite.prototype.getLocalBounds.restore(); }); - after(function () + after(() => { - this.tileSprite.destroy(); - this.tileSprite = null; + tileSprite.destroy(); + tileSprite = null; }); - it('should call parent method if there are children', function () + it('should call parent method if there are children', () => { - this.tileSprite.children.length = 1; - this.tileSprite.getLocalBounds(); + tileSprite.children.length = 1; + tileSprite.getLocalBounds(); expect(Sprite.prototype.getLocalBounds).to.be.calledOnce; - expect(this.tileSprite._bounds.getRectangle).to.not.be.called; + expect(tileSprite['_bounds'].getRectangle).to.not.be.called; }); - it('should make quick calc if no children', function () + it('should make quick calc if no children', () => { - this.tileSprite.children.length = 0; - this.tileSprite.getLocalBounds('dummy'); + tileSprite.children.length = 0; + // @ts-expect-error --- + tileSprite.getLocalBounds('dummy'); - expect(this.tileSprite._bounds.getRectangle).to.be.calledOnce; - expect(this.tileSprite._bounds.getRectangle.args[0][0]).to.be.equal('dummy'); + expect(tileSprite['_bounds'].getRectangle).to.be.calledOnce; + // @ts-expect-error --- + expect(tileSprite['_bounds'].getRectangle.args[0][0]).to.be.equal('dummy'); expect(Sprite.prototype.getLocalBounds).to.not.be.called; - expect(this.tileSprite._bounds.minX).to.be.equal(-3); - expect(this.tileSprite._bounds.minY).to.be.equal(-8); - expect(this.tileSprite._bounds.maxX).to.be.equal(-2); - expect(this.tileSprite._bounds.maxY).to.be.equal(-6); + expect(tileSprite['_bounds'].minX).to.be.equal(-3); + expect(tileSprite['_bounds'].minY).to.be.equal(-8); + expect(tileSprite['_bounds'].maxX).to.be.equal(-2); + expect(tileSprite['_bounds'].maxY).to.be.equal(-6); }); - it('should assign default rect if rect is not specified', function () + it('should assign default rect if rect is not specified', () => { - this.tileSprite.children.length = 0; - this.tileSprite._localBoundsRect = 'localRect'; - this.tileSprite.getLocalBounds(); - - expect(this.tileSprite._bounds.getRectangle).to.be.calledOnce; - expect(this.tileSprite._bounds.getRectangle.args[0][0]).to.be.equal('localRect'); + tileSprite.children.length = 0; + // @ts-expect-error --- + tileSprite['_localBoundsRect'] = 'localRect'; + tileSprite.getLocalBounds(); + + expect(tileSprite['_bounds'].getRectangle).to.be.calledOnce; + // @ts-expect-error --- + expect(tileSprite['_bounds'].getRectangle.args[0][0]).to.be.equal('localRect'); expect(Sprite.prototype.getLocalBounds).to.not.be.called; - expect(this.tileSprite._bounds.minX).to.be.equal(-3); - expect(this.tileSprite._bounds.minY).to.be.equal(-8); - expect(this.tileSprite._bounds.maxX).to.be.equal(-2); - expect(this.tileSprite._bounds.maxY).to.be.equal(-6); + expect(tileSprite['_bounds'].minX).to.be.equal(-3); + expect(tileSprite['_bounds'].minY).to.be.equal(-8); + expect(tileSprite['_bounds'].maxX).to.be.equal(-2); + expect(tileSprite['_bounds'].maxY).to.be.equal(-6); }); - it('should create and assign rect if default rect is not', function () + it('should create and assign rect if default rect is not', () => { - this.tileSprite.children.length = 0; - this.tileSprite._localBoundsRect = null; - this.tileSprite.getLocalBounds(); + tileSprite.children.length = 0; + tileSprite['_localBoundsRect'] = null; + tileSprite.getLocalBounds(); - expect(this.tileSprite._bounds.getRectangle).to.be.calledOnce; - expect(this.tileSprite._bounds.getRectangle.args[0][0]).to.be.instanceof(Rectangle); + expect(tileSprite['_bounds'].getRectangle).to.be.calledOnce; + // @ts-expect-error --- + expect(tileSprite['_bounds'].getRectangle.args[0][0]).to.be.instanceof(Rectangle); expect(Sprite.prototype.getLocalBounds).to.not.be.called; - expect(this.tileSprite._bounds.minX).to.be.equal(-3); - expect(this.tileSprite._bounds.minY).to.be.equal(-8); - expect(this.tileSprite._bounds.maxX).to.be.equal(-2); - expect(this.tileSprite._bounds.maxY).to.be.equal(-6); + expect(tileSprite['_bounds'].minX).to.be.equal(-3); + expect(tileSprite['_bounds'].minY).to.be.equal(-8); + expect(tileSprite['_bounds'].maxX).to.be.equal(-2); + expect(tileSprite['_bounds'].maxY).to.be.equal(-6); }); }); - it('checks if tilingSprite contains a point', function () + it('checks if tilingSprite contains a point', () => { const texture = new Texture(new BaseTexture()); const tilingSprite = new TilingSprite(texture, 200, 300); @@ -151,7 +159,7 @@ describe('TilingSprite', function () expect(tilingSprite.containsPoint(new Point(300, 400))).to.equal(false); }); - it('gets and sets height and width correctly', function () + it('gets and sets height and width correctly', () => { const texture = new Texture(new BaseTexture()); const tilingSprite = new TilingSprite(texture, 200, 300); @@ -163,7 +171,7 @@ describe('TilingSprite', function () expect(tilingSprite.height).to.equal(600); }); - it('should create TilingSprite with nullable texture', function () + it('should create TilingSprite with nullable texture', () => { const tilingSprite = new TilingSprite(null, 1, 1); diff --git a/packages/sprite/package.json b/packages/sprite/package.json index c7d43ed6d8..ee9e922ee9 100644 --- a/packages/sprite/package.json +++ b/packages/sprite/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/sprite", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/sprite.js", "module": "dist/esm/sprite.js", "bundle": "dist/browser/sprite.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/sprite.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/sprite.js" + } + } + }, "description": "Base object for textured objects rendered to the screen", "author": "Mat Groves", "contributors": [ @@ -25,11 +38,11 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/constants": "6.3.0", - "@pixi/core": "6.3.0", - "@pixi/display": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/settings": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/constants": "6.4.2", + "@pixi/core": "6.4.2", + "@pixi/display": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/settings": "6.4.2", + "@pixi/utils": "6.4.2" } } diff --git a/packages/sprite/src/Sprite.ts b/packages/sprite/src/Sprite.ts index d514f1e54a..5239b8715b 100644 --- a/packages/sprite/src/Sprite.ts +++ b/packages/sprite/src/Sprite.ts @@ -12,13 +12,13 @@ import type { IPointData } from '@pixi/math'; const tempPoint = new Point(); const indices = new Uint16Array([0, 1, 2, 0, 2, 3]); -export type SpriteSource = TextureSource|Texture; +export type SpriteSource = TextureSource | Texture; export interface Sprite extends GlobalMixins.Sprite, Container {} /** * The Sprite object is the base for all textured objects that are rendered to the screen -* + * * A sprite can be created directly from an image like this: * * ```js @@ -37,14 +37,12 @@ export interface Sprite extends GlobalMixins.Sprite, Container {} * ... * } * ``` - * * @memberof PIXI */ export class Sprite extends Container { /** * The blend mode to be applied to the sprite. Apply a value of `PIXI.BLEND_MODES.NORMAL` to reset the blend mode. - * * @default PIXI.BLEND_MODES.NORMAL */ public blendMode: BLEND_MODES; @@ -53,28 +51,24 @@ export class Sprite extends Container /** * Plugin that is responsible for rendering this element. * Allows to customize the rendering process without overriding '_render' & '_renderCanvas' methods. - * * @default 'batch' */ public pluginName: string; /** * The width of the sprite (this is initially set by the texture). - * * @protected */ _width: number; /** * The height of the sprite (this is initially set by the texture) - * * @protected */ _height: number; /** * The texture that the sprite is using. - * * @private */ _texture: Texture; @@ -83,7 +77,6 @@ export class Sprite extends Container /** * Cached tint value so we can tell when the tint is changed. * Value is used for 2d CanvasRenderer. - * * @protected * @default 0xFFFFFF */ @@ -93,7 +86,6 @@ export class Sprite extends Container /** * This is used to store the uvs data of the sprite, assigned at the same time * as the vertexData in calculateVertices(). - * * @member {Float32Array} */ protected uvs: Float32Array; @@ -111,28 +103,24 @@ export class Sprite extends Container * constructing a `Sprite` does _not_ update its anchor. * * {@link https://docs.cocos2d-x.org/cocos2d-x/en/sprites/manipulation.html} - * * @default `this.texture.defaultAnchor` */ protected _anchor: ObservablePoint; /** * This is used to store the vertex data of the sprite (basically a quad). - * * @member {Float32Array} */ protected vertexData: Float32Array; /** * This is used to calculate the bounds of the object IF it is a trimmed sprite. - * * @member {Float32Array} */ private vertexTrimmedData: Float32Array; /** * Internal roundPixels field - * * @private */ private _roundPixels: boolean; @@ -141,7 +129,6 @@ export class Sprite extends Container /** * The tint applied to the sprite. This is a hex value. A value of 0xFFFFFF will remove any tint effect. - * * @default 0xFFFFFF */ private _tint: number; @@ -149,7 +136,6 @@ export class Sprite extends Container // Internal-only properties /** * The tint applied to the sprite. This is a RGB value. A value of 0xFFFFFF will remove any tint effect. - * * @private * @default 16777215 */ @@ -374,7 +360,6 @@ export class Sprite extends Container /** * * Renders the object using the WebGL renderer - * * @param renderer - The webgl renderer to use. */ protected _render(renderer: Renderer): void @@ -408,9 +393,8 @@ export class Sprite extends Container /** * Gets the local bounds of the sprite object. - * * @param rect - Optional output rectangle. - * @return The bounds. + * @returns The bounds. */ public getLocalBounds(rect?: Rectangle): Rectangle { @@ -445,9 +429,8 @@ export class Sprite extends Container /** * Tests if a point is inside this sprite - * * @param point - the point to test - * @return The result of the test + * @returns The result of the test */ public containsPoint(point: IPointData): boolean { @@ -473,7 +456,6 @@ export class Sprite extends Container /** * Destroys this sprite and optionally its texture and children. - * * @param options - Options parameter. A boolean will act as if all options * have been set to that value * @param [options.children=false] - if set to true, all the children will have their destroy @@ -481,7 +463,7 @@ export class Sprite extends Container * @param [options.texture=false] - Should it destroy the current texture of the sprite as well * @param [options.baseTexture=false] - Should it destroy the base texture of the sprite as well */ - public destroy(options?: IDestroyOptions|boolean): void + public destroy(options?: IDestroyOptions | boolean): void { super.destroy(options); @@ -506,10 +488,9 @@ export class Sprite extends Container /** * Helper function that creates a new sprite based on the source you provide. * The source can be - frame id, image url, video url, canvas element, video element, base texture - * * @param {string|PIXI.Texture|HTMLCanvasElement|HTMLVideoElement} source - Source to create texture from * @param {object} [options] - See {@link PIXI.BaseTexture}'s constructor for options. - * @return The newly created sprite + * @returns The newly created sprite */ static from(source: SpriteSource, options?: IBaseTextureOptions): Sprite { @@ -527,7 +508,6 @@ export class Sprite extends Container * The main disadvantage is movement of objects may appear less smooth. * * To set the global default, change {@link PIXI.settings.ROUND_PIXELS}. - * * @default false */ set roundPixels(value: boolean) @@ -583,7 +563,6 @@ export class Sprite extends Container * Setting the anchor to `(1,1)` would mean the sprite's origin point will be the bottom right corner. * * If you pass only single parameter, it will set both x and y to the same value as shown in the example below. - * * @example * const sprite = new PIXI.Sprite(texture); * sprite.anchor.set(0.5); // This will set the origin to center. (0.5) is same as (0.5, 0.5). @@ -602,7 +581,6 @@ export class Sprite extends Container * The tint applied to the sprite. This is a hex value. * * A value of 0xFFFFFF will remove any tint effect. - * * @default 0xFFFFFF */ get tint(): number diff --git a/packages/sprite/test/Sprite.tests.ts b/packages/sprite/test/Sprite.tests.ts index 1e89922457..3615faab9e 100755 --- a/packages/sprite/test/Sprite.tests.ts +++ b/packages/sprite/test/Sprite.tests.ts @@ -6,11 +6,11 @@ import { expect } from 'chai'; import path from 'path'; -describe('Sprite', function () +describe('Sprite', () => { - describe('width', function () + describe('width', () => { - it('should not be negative for negative scale.x', function () + it('should not be negative for negative scale.x', () => { const sprite = new Sprite(); @@ -20,7 +20,7 @@ describe('Sprite', function () expect(sprite.width).to.be.at.least(0); }); - it('should not change sign of scale.x', function () + it('should not change sign of scale.x', () => { const texture = new Texture(new BaseTexture()); const sprite = new Sprite(); @@ -38,9 +38,9 @@ describe('Sprite', function () }); }); - describe('height', function () + describe('height', () => { - it('should not be negative for negative scale.y', function () + it('should not be negative for negative scale.y', () => { const sprite = new Sprite(); @@ -50,7 +50,7 @@ describe('Sprite', function () expect(sprite.height).to.be.at.least(0); }); - it('should not change sign of scale.y', function () + it('should not change sign of scale.y', () => { const texture = new Texture(new BaseTexture()); const sprite = new Sprite(); @@ -68,9 +68,9 @@ describe('Sprite', function () }); }); - describe('getBounds', function () + describe('getBounds', () => { - it('must have correct value according to texture size, width, height and anchor', function () + it('must have correct value according to texture size, width, height and anchor', () => { const parent = new Container(); const texture = RenderTexture.create({ width: 20, height: 30 }); @@ -95,9 +95,9 @@ describe('Sprite', function () }); }); - describe('getLocalBounds', function () + describe('getLocalBounds', () => { - it('must have correct value according to texture size, width, height and anchor', function () + it('must have correct value according to texture size, width, height and anchor', () => { const texture = RenderTexture.create({ width: 20, height: 30 }); const sprite = new Sprite(texture); @@ -112,7 +112,7 @@ describe('Sprite', function () expect(bounds.height).to.equal(30); }); - it('should not corrupt bounds', function () + it('should not corrupt bounds', () => { const texture = RenderTexture.create({ width: 20, height: 30 }); const sprite = new Sprite(texture); @@ -143,33 +143,33 @@ describe('Sprite', function () }); }); - describe('containsPoint', function () + describe('containsPoint', () => { const texture = RenderTexture.create({ width: 20, height: 30 }); const sprite = new Sprite(texture); - it('should return true when point inside', function () + it('should return true when point inside', () => { const point = new Point(10, 10); expect(sprite.containsPoint(point)).to.be.true; }); - it('should return true when point on left edge', function () + it('should return true when point on left edge', () => { const point = new Point(0, 15); expect(sprite.containsPoint(point)).to.be.true; }); - it('should return true when point on top edge', function () + it('should return true when point on top edge', () => { const point = new Point(10, 0); expect(sprite.containsPoint(point)).to.be.true; }); - it('should return false when point outside', function () + it('should return false when point outside', () => { const point = new Point(100, 100); @@ -177,22 +177,27 @@ describe('Sprite', function () }); }); - describe('texture', function () + interface EETexture extends Texture { - it('should unsubscribe from old texture', function () + _eventsCount: number; // missing in ee3 typings + } + + describe('texture', () => + { + it('should unsubscribe from old texture', () => { - const texture = new Texture(new BaseTexture()); - const texture2 = new Texture(new BaseTexture()); + const texture = new Texture(new BaseTexture()) as EETexture; + const texture2 = new Texture(new BaseTexture()) as EETexture; const sprite = new Sprite(texture); - expect(texture._eventsCount).to.equal(1); - expect(texture2._eventsCount).to.equal(0); + expect(texture['_eventsCount']).to.equal(1); + expect(texture2['_eventsCount']).to.equal(0); sprite.texture = texture2; - expect(texture._eventsCount).to.equal(0); - expect(texture2._eventsCount).to.equal(1); + expect(texture['_eventsCount']).to.equal(0); + expect(texture2['_eventsCount']).to.equal(1); sprite.destroy(); texture.destroy(true); @@ -200,18 +205,18 @@ describe('Sprite', function () }); }); - describe('destroy', function () + describe('destroy', () => { - it('should destroy while BaseTexture is loading', function () + it('should destroy while BaseTexture is loading', () => { - const texture = Texture.from(path.resolve(__dirname, 'resources', 'building1.png')); + const texture = Texture.from(path.resolve(__dirname, 'resources', 'building1.png')) as EETexture; const sprite = new Sprite(texture); - expect(texture._eventsCount).to.equal(1); + expect(texture['_eventsCount']).to.equal(1); sprite.destroy(); - expect(texture._eventsCount).to.equal(0); + expect(texture['_eventsCount']).to.equal(0); texture.emit('update', texture); texture.destroy(true); diff --git a/packages/spritesheet/package.json b/packages/spritesheet/package.json index 2bb0bbc1c1..261d36f618 100644 --- a/packages/spritesheet/package.json +++ b/packages/spritesheet/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/spritesheet", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/spritesheet.js", "module": "dist/esm/spritesheet.js", "bundle": "dist/browser/spritesheet.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/spritesheet.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/spritesheet.js" + } + } + }, "description": "Spritesheets maintain a collection of Textures on a single image", "author": "Mat Groves", "contributors": [ @@ -25,9 +38,9 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/core": "6.3.0", - "@pixi/loaders": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/core": "6.4.2", + "@pixi/loaders": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/utils": "6.4.2" } } diff --git a/packages/spritesheet/src/Spritesheet.ts b/packages/spritesheet/src/Spritesheet.ts index 7b324f3763..7b341885fc 100644 --- a/packages/spritesheet/src/Spritesheet.ts +++ b/packages/spritesheet/src/Spritesheet.ts @@ -5,10 +5,9 @@ import type { Dict } from '@pixi/utils'; import type { ImageResource } from '@pixi/core'; import type { IPointData } from '@pixi/math'; -/** - * Represents the JSON data for a spritesheet atlas. - */ -export interface ISpritesheetFrameData { +/** Represents the JSON data for a spritesheet atlas. */ +export interface ISpritesheetFrameData +{ frame: { x: number; y: number; @@ -28,10 +27,9 @@ export interface ISpritesheetFrameData { anchor?: IPointData; } -/** - * Atlas format. - */ -export interface ISpritesheetData { +/** Atlas format. */ +export interface ISpritesheetData +{ frames: Dict; animations?: Dict; meta: { @@ -43,7 +41,7 @@ export interface ISpritesheetData { * Utility class for maintaining reference to a collection * of Textures on a single Spritesheet. * - * To access a sprite sheet from your code pass its JSON data file to Pixi's loader: + * To access a sprite sheet from your code you may pass its JSON data file to Pixi's loader: * * ```js * PIXI.Loader.shared.add("images/spritesheet.json").load(setup); @@ -53,13 +51,19 @@ export interface ISpritesheetData { * ... * } * ``` + * + * Alternately, you may circumvent the loader by instantiating the Spritesheet directly: + * ```js + * const sheet = new PIXI.Spritesheet(texture, spritesheetData); + * sheet.parse(() => console.log('Spritesheet ready to use!')); + * ``` + * * With the `sheet.textures` you can create Sprite objects,`sheet.animations` can be used to create an AnimatedSprite. * * Sprite sheets can be packed using tools like {@link https://codeandweb.com/texturepacker|TexturePacker}, * {@link https://renderhjs.net/shoebox/|Shoebox} or {@link https://github.com/krzysztof-o/spritesheet.js|Spritesheet.js}. * Default anchor points (see {@link PIXI.Texture#defaultAnchor}) and grouping of animation sprites are currently only * supported by TexturePacker. - * * @memberof PIXI */ export class Spritesheet @@ -90,7 +94,7 @@ export class Spritesheet /** * Reference to the original JSON data. - * @type {Object} + * @type {object} */ public data: ISpritesheetData; @@ -105,7 +109,7 @@ export class Spritesheet /** * Map of spritesheet frames. - * @type {Object} + * @type {object} */ private _frames: Dict; @@ -122,8 +126,8 @@ export class Spritesheet private _callback: (textures: Dict) => void; /** - * @param baseTexture - Reference to the source BaseTexture object. - * @param {Object} data - Spritesheet image data. + * @param texture - Reference to the source BaseTexture object. + * @param {object} data - Spritesheet image data. * @param resolutionFilename - The filename to consider when determining * the resolution of the spritesheet. If not provided, the imageUrl will * be used on the BaseTexture. @@ -148,10 +152,9 @@ export class Spritesheet /** * Generate the resolution from the filename or fallback * to the meta.scale field of the JSON data. - * * @param resolutionFilename - The filename to use for resolving * the default resolution. - * @return Resolution to use for spritesheet. + * @returns Resolution to use for spritesheet. */ private _updateResolution(resolutionFilename: string = null): number { @@ -179,7 +182,6 @@ export class Spritesheet /** * Parser spritesheet from loaded data. This is done asynchronously * to prevent creating too many Texture within a single process. - * * @param {Function} callback - Callback when complete returns * a map of the Textures for this spritesheet. */ @@ -202,7 +204,6 @@ export class Spritesheet /** * Process a batch of frames - * * @param initialFrameIndex - The index of frame to start. */ private _processFrames(initialFrameIndex: number): void @@ -325,7 +326,6 @@ export class Spritesheet /** * Destroy Spritesheet and don't use after this. - * * @param {boolean} [destroyBase=false] - Whether to destroy the base texture as well */ public destroy(destroyBase = false): void @@ -357,7 +357,7 @@ export class Spritesheet /** * Dictionary of textures from Spritesheet. - * @member {object} textures + * @member {Object} textures * @memberof PIXI.LoaderResource * @instance */ diff --git a/packages/spritesheet/src/SpritesheetLoader.ts b/packages/spritesheet/src/SpritesheetLoader.ts index 62587c45f8..2842a657ee 100644 --- a/packages/spritesheet/src/SpritesheetLoader.ts +++ b/packages/spritesheet/src/SpritesheetLoader.ts @@ -15,21 +15,18 @@ import type { Loader } from '@pixi/loaders'; * The Loader's image Resource name is automatically appended with `"_image"`. * If a Resource with this name is already loaded, the Loader will skip parsing the * Spritesheet. The code below will generate an internal Loader Resource called `"myatlas_image"`. - * * @example * loader.add('myatlas', 'path/to/myatlas.json'); * loader.load(() => { * loader.resources.myatlas; // atlas JSON resource * loader.resources.myatlas_image; // atlas Image resource * }); - * * @memberof PIXI */ export class SpritesheetLoader { /** * Called after a resource is loaded. - * * @see PIXI.Loader.loaderMiddleware * @param resource * @param next @@ -123,7 +120,6 @@ export class SpritesheetLoader /** * Get the spritesheets root path - * * @param resource - Resource to check path * @param baseUrl - Base root url */ diff --git a/packages/spritesheet/test/Spritesheet.tests.ts b/packages/spritesheet/test/Spritesheet.tests.ts index d19c84a1aa..02b501972d 100644 --- a/packages/spritesheet/test/Spritesheet.tests.ts +++ b/packages/spritesheet/test/Spritesheet.tests.ts @@ -1,16 +1,20 @@ -import { Spritesheet } from '@pixi/spritesheet'; -import { BaseTexture, Texture } from '@pixi/core'; +import { ISpritesheetData, ISpritesheetFrameData, Spritesheet } from '@pixi/spritesheet'; +import { BaseTexture, ImageResource, Texture } from '@pixi/core'; import path from 'path'; import { expect } from 'chai'; -describe('Spritesheet', function () +describe('Spritesheet', () => { - before(function () + let resources: string; + let validate: (spritesheet: Spritesheet, done: () => void) => void; + let parseFrame: (frameData: ISpritesheetFrameData, cb: (frame: Texture) => void) => void; + + before(() => { - this.resources = path.join(__dirname, 'resources'); - this.validate = function (spritesheet, done) + resources = path.join(__dirname, 'resources'); + validate = (spritesheet: Spritesheet, done) => { - spritesheet.parse(function (textures) + spritesheet.parse((textures) => { const id = 'goldmine_10_5.png'; const width = Math.floor(spritesheet.data.frames[id].frame.w); @@ -25,10 +29,10 @@ describe('Spritesheet', function () expect(textures[id].defaultAnchor.y).to.equal(0); expect(textures[id].textureCacheIds.indexOf(id)).to.equal(0); - expect(this.animations).to.have.property('star').that.is.an('array'); - expect(this.animations.star.length).to.equal(4); - expect(this.animations.star[0].defaultAnchor.x).to.equal(0.5); - expect(this.animations.star[0].defaultAnchor.y).to.equal(0.5); + expect(spritesheet.animations).to.have.property('star').that.is.an('array'); + expect(spritesheet.animations.star.length).to.equal(4); + expect(spritesheet.animations.star[0].defaultAnchor.x).to.equal(0.5); + expect(spritesheet.animations.star[0].defaultAnchor.y).to.equal(0.5); spritesheet.destroy(true); expect(spritesheet.textures).to.be.null; @@ -37,16 +41,17 @@ describe('Spritesheet', function () }); }; - this.parseFrame = function (frameData, callback) + parseFrame = (frameData, callback) => { const data = { frames: { frame: frameData }, meta: { scale: 1 }, - }; + } as unknown as ISpritesheetData; const baseTexture = BaseTexture.from( document.createElement('canvas') - ); + ) as BaseTexture; + // @ts-expect-error - hack baseTexture.imageUrl = 'test.png'; const sheet = new Spritesheet(baseTexture, data); @@ -64,19 +69,19 @@ describe('Spritesheet', function () }; }); - it('should exist on PIXI', function () + it('should exist on PIXI', () => { expect(Spritesheet).to.be.a('function'); expect(Spritesheet.BATCH_SIZE).to.be.a('number'); }); - it('should create an instance', function () + it('should create an instance', () => { const baseTexture = new BaseTexture(); const data = { frames: {}, meta: {}, - }; + } as unknown as ISpritesheetData; const spritesheet = new Spritesheet(baseTexture, data); @@ -87,27 +92,29 @@ describe('Spritesheet', function () spritesheet.destroy(true); }); - it('should create instance with scale resolution', function (done) + it('should create instance with scale resolution', (done) => { - const data = require(path.resolve(this.resources, 'building1.json')); // eslint-disable-line global-require + // eslint-disable-next-line @typescript-eslint/no-var-requires, global-require + const data = require(path.resolve(resources, 'building1.json')); const image = new Image(); - image.src = path.join(this.resources, data.meta.image); + image.src = path.join(resources, data.meta.image); image.onload = () => { - const baseTexture = new BaseTexture(image, null, 1); + const baseTexture = new BaseTexture(image, null); const spritesheet = new Spritesheet(baseTexture, data); expect(data).to.be.an('object'); expect(data.meta.image).to.equal('building1.png'); expect(spritesheet.resolution).to.equal(0.5); - this.validate(spritesheet, done); + validate(spritesheet, done); }; }); - it('should create instance with BaseTexture source scale', function (done) + it('should create instance with BaseTexture source scale', (done) => { - const data = require(path.resolve(this.resources, 'building1.json')); // eslint-disable-line global-require + // eslint-disable-next-line @typescript-eslint/no-var-requires, global-require + const data = require(path.resolve(resources, 'building1.json')); const baseTexture = BaseTexture.from(data.meta.image);// , undefined, undefined, 1.5); const spritesheet = new Spritesheet(baseTexture, data); @@ -115,16 +122,17 @@ describe('Spritesheet', function () expect(data.meta.image).to.equal('building1.png'); expect(spritesheet.resolution).to.equal(0.5); - this.validate(spritesheet, done); + validate(spritesheet, done); }); - it('should create instance with filename resolution', function (done) + it('should create instance with filename resolution', (done) => { - const uri = path.resolve(this.resources, 'building1@2x.json'); - const data = require(uri); // eslint-disable-line global-require + const uri = path.resolve(resources, 'building1@2x.json'); + // eslint-disable-next-line @typescript-eslint/no-var-requires, global-require + const data = require(uri); const image = new Image(); - image.src = path.join(this.resources, data.meta.image); + image.src = path.join(resources, data.meta.image); image.onload = () => { const baseTexture = new BaseTexture(image, { resolution: 1 }); @@ -134,11 +142,11 @@ describe('Spritesheet', function () expect(data.meta.image).to.equal('building1@2x.png'); expect(spritesheet.resolution).to.equal(2); - this.validate(spritesheet, done); + validate(spritesheet, done); }; }); - it('should parse full data untrimmed', function (done) + it('should parse full data untrimmed', (done) => { const data = { frame: { x: 0, y: 0, w: 14, h: 16 }, @@ -146,9 +154,9 @@ describe('Spritesheet', function () trimmed: false, spriteSourceSize: { x: 0, y: 0, w: 14, h: 16 }, sourceSize: { w: 14, h: 16 }, - }; + } as ISpritesheetFrameData; - this.parseFrame(data, (texture) => + parseFrame(data, (texture) => { expect(texture.width).to.equal(14); expect(texture.height).to.equal(16); @@ -156,7 +164,7 @@ describe('Spritesheet', function () }); }); - it('should parse texture from trimmed', function (done) + it('should parse texture from trimmed', (done) => { const data = { frame: { x: 0, y: 28, w: 14, h: 14 }, @@ -166,7 +174,7 @@ describe('Spritesheet', function () sourceSize: { w: 40, h: 20 }, }; - this.parseFrame(data, (texture) => + parseFrame(data, (texture) => { expect(texture.width).to.equal(40); expect(texture.height).to.equal(20); @@ -174,11 +182,11 @@ describe('Spritesheet', function () }); }); - it('should parse texture from minimal data', function (done) + it('should parse texture from minimal data', (done) => { const data = { frame: { x: 0, y: 0, w: 14, h: 14 } }; - this.parseFrame(data, (texture) => + parseFrame(data, (texture) => { expect(texture.width).to.equal(14); expect(texture.height).to.equal(14); @@ -186,7 +194,7 @@ describe('Spritesheet', function () }); }); - it('should parse texture without trimmed or sourceSize', function (done) + it('should parse texture without trimmed or sourceSize', (done) => { const data = { frame: { x: 0, y: 14, w: 14, h: 14 }, @@ -195,7 +203,7 @@ describe('Spritesheet', function () spriteSourceSize: { x: 0, y: 0, w: 20, h: 30 }, }; - this.parseFrame(data, (texture) => + parseFrame(data, (texture) => { expect(texture.width).to.equal(14); expect(texture.height).to.equal(14); @@ -203,7 +211,7 @@ describe('Spritesheet', function () }); }); - it('should parse as trimmed if spriteSourceSize is set', function (done) + it('should parse as trimmed if spriteSourceSize is set', (done) => { // shoebox format const data = { @@ -212,7 +220,7 @@ describe('Spritesheet', function () sourceSize: { w: 120, h: 100 }, }; - this.parseFrame(data, (texture) => + parseFrame(data, (texture) => { expect(texture.width).to.equal(120); expect(texture.height).to.equal(100); diff --git a/packages/spritesheet/test/SpritesheetLoader.tests.ts b/packages/spritesheet/test/SpritesheetLoader.tests.ts index 07d74751e1..1055c47be9 100644 --- a/packages/spritesheet/test/SpritesheetLoader.tests.ts +++ b/packages/spritesheet/test/SpritesheetLoader.tests.ts @@ -1,20 +1,20 @@ import path from 'path'; -import { Loader, LoaderResource } from '@pixi/loaders'; +import { IAddOptions, Loader, LoaderResource } from '@pixi/loaders'; import { Texture, BaseTexture } from '@pixi/core'; import { BaseTextureCache, TextureCache, url, clearTextureCache } from '@pixi/utils'; import { SpritesheetLoader, Spritesheet } from '@pixi/spritesheet'; import sinon from 'sinon'; import { expect } from 'chai'; -describe('SpritesheetLoader', function () +describe('SpritesheetLoader', () => { - it('should exist and return a function', function () + it('should exist and return a function', () => { expect(SpritesheetLoader).to.not.be.undefined; expect(SpritesheetLoader.use).to.be.a('function'); }); - it('should install middleware', function (done) + it('should install middleware', (done) => { Loader.registerPlugin(SpritesheetLoader); @@ -35,10 +35,10 @@ describe('SpritesheetLoader', function () }); }); - it('should do nothing if the resource is not JSON', function () + it('should do nothing if the resource is not JSON', () => { const spy = sinon.spy(); - const res = {}; + const res = {} as LoaderResource; SpritesheetLoader.use(res, spy); @@ -46,7 +46,7 @@ describe('SpritesheetLoader', function () expect(res.textures).to.be.undefined; }); - it('should do nothing if the resource is JSON, but improper format', function () + it('should do nothing if the resource is JSON, but improper format', () => { const spy = sinon.spy(); const res = createMockResource(LoaderResource.TYPE.JSON, {}); @@ -57,7 +57,7 @@ describe('SpritesheetLoader', function () expect(res.textures).to.be.undefined; }); - it('should load the image & create textures if json is properly formatted', function () + it('should load the image & create textures if json is properly formatted', () => { const spy = sinon.spy(); const res = createMockResource(LoaderResource.TYPE.JSON, getJsonSpritesheet()); @@ -98,7 +98,7 @@ describe('SpritesheetLoader', function () expect(res.spritesheet.animations.png123[0]).to.equal(res.textures['1.png']); }); - it('should not load binary images as an image loader type', function (done) + it('should not load binary images as an image loader type', (done) => { const loader = new Loader(); @@ -123,9 +123,9 @@ describe('SpritesheetLoader', function () }); }); - it('should dispatch an error failing to load spritesheet image', function (done) + it('should dispatch an error failing to load spritesheet image', (done) => { - const spy = sinon.spy((error, ldr, res) => + const spy = sinon.spy((error, _ldr, res) => { expect(res.name).to.equal('atlas_error_image'); expect(res.error).to.equal(error); @@ -144,14 +144,17 @@ describe('SpritesheetLoader', function () }); }); - it('should build the image url', function () + it('should build the image url', () => { - function getPath(url, image) + function getPath(url: string, image: string) { - return SpritesheetLoader.getResourcePath({ - url, - data: { meta: { image } }, - }); + return SpritesheetLoader.getResourcePath( + { + url, + data: { meta: { image } }, + } as LoaderResource, + '' + ); } let result = getPath('http://some.com/spritesheet.json', 'img.png'); @@ -185,7 +188,7 @@ describe('SpritesheetLoader', function () // TODO: Test that resolution processing works correctly. // TODO: Test that metadata is honored. - it('should not add itself via multipack', function (done) + it('should not add itself via multipack', (done) => { // clear the caches only to avoid cluttering the output clearTextureCache(); @@ -201,7 +204,7 @@ describe('SpritesheetLoader', function () }); }); - it('should create multipack resources when related_multi_packs field is an array of strings', function (done) + it('should create multipack resources when related_multi_packs field is an array of strings', (done) => { // clear the caches only to avoid cluttering the output clearTextureCache(); @@ -217,7 +220,7 @@ describe('SpritesheetLoader', function () }); }); - it('should not create multipack resources when related_multi_packs field is missing or the wrong type', function (done) + it('should not create multipack resources when related_multi_packs field is missing or the wrong type', (done) => { // clear the caches only to avoid cluttering the output clearTextureCache(); @@ -237,7 +240,7 @@ describe('SpritesheetLoader', function () }); }); - it('should build the multipack url', function () + it('should build the multipack url', () => { let result = url.resolve('http://some.com/spritesheet.json', 'spritesheet-1.json'); @@ -265,7 +268,7 @@ describe('SpritesheetLoader', function () expect(result).to.be.equals('/some/spritesheet-1.json'); }); - it('should use metadata to load all multipack resources', function (done) + it('should use metadata to load all multipack resources', (done) => { // clear the caches only to avoid cluttering the output clearTextureCache(); @@ -273,8 +276,8 @@ describe('SpritesheetLoader', function () const loader = new Loader(); const metadata = { key: 'value' }; - loader.add('building1-0', path.join(__dirname, 'resources', 'building1-0.json'), { metadata }); - loader.load((loader, resources) => + loader.add('building1-0', path.join(__dirname, 'resources', 'building1-0.json'), { metadata } as IAddOptions); + loader.load((_loader, resources) => { expect(resources['building1-0'].metadata).to.be.equals(metadata); expect(resources['building1-1'].metadata).to.be.equals(metadata); @@ -284,7 +287,7 @@ describe('SpritesheetLoader', function () }); }); -function createMockResource(type, data) +function createMockResource(type: LoaderResource.TYPE, data: any): LoaderResource { const name = `${Math.floor(Date.now() * Math.random())}`; @@ -294,7 +297,7 @@ function createMockResource(type, data) type, data, metadata: {}, - }; + } as LoaderResource; } function getJsonSpritesheet() diff --git a/packages/text-bitmap/global.d.ts b/packages/text-bitmap/global.d.ts index 08cee2b8c0..aa7375fc1c 100644 --- a/packages/text-bitmap/global.d.ts +++ b/packages/text-bitmap/global.d.ts @@ -1,6 +1,7 @@ declare namespace GlobalMixins { - interface IBitmapFontResource { + interface IBitmapFontResource + { bitmapFont: import('@pixi/text-bitmap').BitmapFont; } @@ -10,7 +11,8 @@ declare namespace GlobalMixins } - interface IBitmapFontResourceMetadata { + interface IBitmapFontResourceMetadata + { pageFile: string; } diff --git a/packages/text-bitmap/package.json b/packages/text-bitmap/package.json index 28b6a8ebe4..d5917b3f2c 100644 --- a/packages/text-bitmap/package.json +++ b/packages/text-bitmap/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/text-bitmap", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/text-bitmap.js", "module": "dist/esm/text-bitmap.js", "bundle": "dist/browser/text-bitmap.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/text-bitmap.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/text-bitmap.js" + } + } + }, "description": "Text via bitmap fonts", "author": "Mat Groves", "contributors": [ @@ -25,14 +38,14 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/constants": "6.3.0", - "@pixi/core": "6.3.0", - "@pixi/display": "6.3.0", - "@pixi/loaders": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/mesh": "6.3.0", - "@pixi/settings": "6.3.0", - "@pixi/text": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/constants": "6.4.2", + "@pixi/core": "6.4.2", + "@pixi/display": "6.4.2", + "@pixi/loaders": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/mesh": "6.4.2", + "@pixi/settings": "6.4.2", + "@pixi/text": "6.4.2", + "@pixi/utils": "6.4.2" } } diff --git a/packages/text-bitmap/src/BitmapFont.ts b/packages/text-bitmap/src/BitmapFont.ts index b6661a4d06..7310e6b930 100644 --- a/packages/text-bitmap/src/BitmapFont.ts +++ b/packages/text-bitmap/src/BitmapFont.ts @@ -57,14 +57,12 @@ export interface IBitmapFontOptions /** * BitmapFont represents a typeface available for use with the BitmapText class. Use the `install` * method for adding a font to be used. - * * @memberof PIXI */ export class BitmapFont { /** * This character set includes all the letters in the alphabet (both lower- and upper- case). - * * @type {string[][]} * @example * BitmapFont.from("ExampleFont", style, { chars: BitmapFont.ALPHA }) @@ -73,7 +71,6 @@ export class BitmapFont /** * This character set includes all decimal digits (from 0 to 9). - * * @type {string[][]} * @example * BitmapFont.from("ExampleFont", style, { chars: BitmapFont.NUMERIC }) @@ -82,14 +79,12 @@ export class BitmapFont /** * This character set is the union of `BitmapFont.ALPHA` and `BitmapFont.NUMERIC`. - * * @type {string[][]} */ public static readonly ALPHANUMERIC = [['a', 'z'], ['A', 'Z'], ['0', '9'], ' ']; /** * This character set consists of all the ASCII table. - * * @member {string[][]} * @see http://www.asciitable.com/ */ @@ -97,11 +92,10 @@ export class BitmapFont /** * Collection of default options when using `BitmapFont.from`. - * - * @property {number} resolution=1 - * @property {number} textureWidth=512 - * @property {number} textureHeight=512 - * @property {number} padding=4 + * @property {number} [resolution=1] - + * @property {number} [textureWidth=512] - + * @property {number} [textureHeight=512] - + * @property {number} [padding=4] - * @property {string|string[]|string[][]} chars = PIXI.BitmapFont.ALPHANUMERIC */ public static readonly defaultOptions: IBitmapFontOptions = { @@ -144,7 +138,7 @@ export class BitmapFont * @param ownsTextures - Setting to `true` will destroy page textures * when the font is uninstalled. */ - constructor(data: BitmapFontData, textures: Texture[]|Dict, ownsTextures?: boolean) + constructor(data: BitmapFontData, textures: Texture[] | Dict, ownsTextures?: boolean) { const [info] = data.info; const [common] = data.common; @@ -256,19 +250,18 @@ export class BitmapFont /** * Register a new bitmap font. - * * @param data - The * characters map that could be provided as xml or raw string. * @param textures - List of textures for each page. * @param ownsTextures - Set to `true` to destroy page textures * when the font is uninstalled. By default fonts created with * `BitmapFont.from` or from the `BitmapFontLoader` are `true`. - * @return {PIXI.BitmapFont} Result font object with font, size, lineHeight + * @returns {PIXI.BitmapFont} Result font object with font, size, lineHeight * and char fields. */ public static install( - data: string|XMLDocument|BitmapFontData, - textures: Texture|Texture[]|Dict, + data: string | XMLDocument | BitmapFontData, + textures: Texture | Texture[] | Dict, ownsTextures?: boolean ): BitmapFont { @@ -305,7 +298,6 @@ export class BitmapFont /** * Remove bitmap font by name. - * * @param name - Name of the font to uninstall. */ public static uninstall(name: string): void @@ -342,9 +334,8 @@ export class BitmapFont * - {@link PIXI.TextStyle#stroke|stroke} * - {@link PIXI.TextStyle#strokeThickness|strokeThickness} * - {@link PIXI.TextStyle#textBaseline|textBaseline} - * * @param name - The name of the custom font to use with BitmapText. - * @param style - Style options to render with BitmapFont. + * @param textStyle - Style options to render with BitmapFont. * @param options - Setup options for font or name of the font. * @param {string|string[]|string[][]} [options.chars=PIXI.BitmapFont.ALPHANUMERIC] - characters included * in the font set. You can also use ranges. For example, `[['a', 'z'], ['A', 'Z'], "!@#$%^&*()~{}[] "]`. @@ -353,7 +344,7 @@ export class BitmapFont * @param {number} [options.textureWidth=512] - Optional width of atlas, smaller values to reduce memory. * @param {number} [options.textureHeight=512] - Optional height of atlas, smaller values to reduce memory. * @param {number} [options.padding=4] - Padding between glyphs on texture atlas. - * @return Font generated by style options. + * @returns Font generated by style options. * @example * PIXI.BitmapFont.from("TitleFont", { * fontFamily: "Arial", diff --git a/packages/text-bitmap/src/BitmapFontData.ts b/packages/text-bitmap/src/BitmapFontData.ts index 49042209a8..cfc892e9d6 100644 --- a/packages/text-bitmap/src/BitmapFontData.ts +++ b/packages/text-bitmap/src/BitmapFontData.ts @@ -2,7 +2,6 @@ /** * Normalized parsed data from .fnt files. - * * @memberof PIXI */ export class BitmapFontData @@ -37,7 +36,8 @@ export class BitmapFontData } /** @memberof PIXI */ -export interface IBitmapFontDataInfo { +export interface IBitmapFontDataInfo +{ /** Font face */ face: string; @@ -46,13 +46,15 @@ export interface IBitmapFontDataInfo { } /** @memberof PIXI */ -export interface IBitmapFontDataCommon { +export interface IBitmapFontDataCommon +{ /** Line height, in pixels. */ lineHeight: number; } /** @memberof PIXI */ -export interface IBitmapFontDataPage { +export interface IBitmapFontDataPage +{ /** Unique id for bitmap texture */ id: number; @@ -61,7 +63,8 @@ export interface IBitmapFontDataPage { } /** @memberof PIXI */ -export interface IBitmapFontDataChar { +export interface IBitmapFontDataChar +{ /** Unique id of character */ id: number; @@ -91,7 +94,8 @@ export interface IBitmapFontDataChar { } /** @memberof PIXI */ -export interface IBitmapFontDataKerning { +export interface IBitmapFontDataKerning +{ /** First character of pair */ first: number; @@ -103,7 +107,8 @@ export interface IBitmapFontDataKerning { } /** @memberof PIXI */ -export interface IBitmapFontDataDistanceField { +export interface IBitmapFontDataDistanceField +{ /** Type of distance field */ fieldType: string; diff --git a/packages/text-bitmap/src/BitmapFontLoader.ts b/packages/text-bitmap/src/BitmapFontLoader.ts index 1f55dbe9ca..8b68c09514 100644 --- a/packages/text-bitmap/src/BitmapFontLoader.ts +++ b/packages/text-bitmap/src/BitmapFontLoader.ts @@ -9,14 +9,12 @@ import type { Texture } from '@pixi/core'; /** * {@link PIXI.Loader Loader} middleware for loading * bitmap-based fonts suitable for using with {@link PIXI.BitmapText}. - * * @memberof PIXI */ export class BitmapFontLoader { /** * Called when the plugin is installed. - * * @see PIXI.Loader.registerPlugin */ public static add(): void @@ -26,10 +24,10 @@ export class BitmapFontLoader /** * Called after a resource is loaded. - * * @see PIXI.Loader.loaderMiddleware + * @param this * @param {PIXI.LoaderResource} resource - * @param {function} next + * @param {Function} next */ static use(this: Loader, resource: LoaderResource, next: (...args: any[]) => void): void { @@ -108,7 +106,11 @@ export class BitmapFontLoader } } - /** Get folder path from a resource. */ + /** + * Get folder path from a resource. + * @param loader + * @param resource + */ private static getBaseUrl(loader: Loader, resource: LoaderResource): string { let resUrl = !resource.isDataUrl ? BitmapFontLoader.dirname(resource.url) : ''; @@ -144,7 +146,6 @@ export class BitmapFontLoader /** * Replacement for NodeJS's path.dirname - * * @param {string} url - Path to get directory for */ private static dirname(url: string): string diff --git a/packages/text-bitmap/src/BitmapText.ts b/packages/text-bitmap/src/BitmapText.ts index 61a1580e6b..36137be93f 100644 --- a/packages/text-bitmap/src/BitmapText.ts +++ b/packages/text-bitmap/src/BitmapText.ts @@ -14,7 +14,8 @@ import { Container } from '@pixi/display'; import type { IDestroyOptions } from '@pixi/display'; import { BLEND_MODES } from '@pixi/constants'; -interface PageMeshData { +interface PageMeshData +{ index: number; indexCount: number; vertexCount: number; @@ -25,7 +26,8 @@ interface PageMeshData { uvs?: Float32Array; indices?: Uint16Array; } -interface CharRenderData { +interface CharRenderData +{ texture: Texture; line: number; charCode: number; @@ -66,7 +68,6 @@ const charRenderDataPool: CharRenderData[] = []; * align: "right" * }); * ``` - * * @memberof PIXI */ export class BitmapText extends Container @@ -82,22 +83,28 @@ export class BitmapText extends Container public dirty: boolean; /** - * Private tracker for the width of the overall text. + * The resolution / device pixel ratio of the canvas. * + * This is set to automatically match the renderer resolution by default, but can be overridden by setting manually. + * @default PIXI.settings.RESOLUTION + */ + _resolution: number; + _autoResolution: boolean; + + /** + * Private tracker for the width of the overall text. * @private */ protected _textWidth: number; /** * Private tracker for the height of the overall text. - * * @private */ protected _textHeight: number; /** * Private tracker for the current text. - * * @private */ protected _text: string; @@ -106,7 +113,6 @@ export class BitmapText extends Container * The max width of this bitmap text in pixels. If the text provided is longer than the * value provided, line breaks will be automatically inserted in the last whitespace. * Disable by setting value to 0 - * * @private */ protected _maxWidth: number; @@ -114,21 +120,18 @@ export class BitmapText extends Container /** * The max line height. This is useful when trying to use the total height of the Text, * ie: when trying to vertically align. (Internally used) - * * @private */ protected _maxLineHeight: number; /** * Letter spacing. This is useful for setting the space between characters. - * * @private */ protected _letterSpacing: number; /** * Text anchor. - * * @readonly * @private */ @@ -136,21 +139,18 @@ export class BitmapText extends Container /** * Private tracker for the current font name. - * * @private */ protected _fontName: string; /** * Private tracker for the current font size. - * * @private */ protected _fontSize: number; /** * Private tracker for the current text align. - * * @type {string} * @private */ @@ -161,14 +161,12 @@ export class BitmapText extends Container /** * Private tracker for the current tint. - * * @private */ protected _tint = 0xFFFFFF; /** * If true PixiJS will Math.floor() x/y values when rendering. - * * @default PIXI.settings.ROUND_PIXELS */ protected _roundPixels: boolean; @@ -215,13 +213,12 @@ export class BitmapText extends Container this._anchor = new ObservablePoint((): void => { this.dirty = true; }, this, 0, 0); this._roundPixels = settings.ROUND_PIXELS; this.dirty = true; + this._resolution = settings.RESOLUTION; + this._autoResolution = true; this._textureCache = {}; } - /** - * Renders text and updates it when needed. This should only be called - * if the BitmapFont is regenerated. - */ + /** Renders text and updates it when needed. This should only be called if the BitmapFont is regenerated. */ public updateText(): void { const data = BitmapFont.available[this._fontName]; @@ -608,6 +605,12 @@ export class BitmapText extends Container _render(renderer: Renderer): void { + if (this._autoResolution && this._resolution !== renderer.resolution) + { + this._resolution = renderer.resolution; + this.dirty = true; + } + // Update the uniform const { distanceFieldRange, distanceFieldType, size } = BitmapFont.available[this._fontName]; @@ -624,7 +627,7 @@ export class BitmapText extends Container for (const mesh of this._activePagesMeshData) { - mesh.mesh.shader.uniforms.uFWidth = worldScale * distanceFieldRange * fontScale * renderer.resolution; + mesh.mesh.shader.uniforms.uFWidth = worldScale * distanceFieldRange * fontScale * this._resolution; } } @@ -633,8 +636,7 @@ export class BitmapText extends Container /** * Validates text before calling parent's getLocalBounds - * - * @return - The rectangular bounding area + * @returns - The rectangular bounding area */ public getLocalBounds(): Rectangle { @@ -645,7 +647,6 @@ export class BitmapText extends Container /** * Updates text when needed - * * @private */ protected validate(): void @@ -659,7 +660,6 @@ export class BitmapText extends Container /** * The tint of the BitmapText object. - * * @default 0xffffff */ public get tint(): number @@ -681,7 +681,6 @@ export class BitmapText extends Container /** * The alignment of the BitmapText object. - * * @member {string} * @default 'left' */ @@ -801,7 +800,6 @@ export class BitmapText extends Container /** * The max line height. This is useful when trying to use the total height of the Text, * i.e. when trying to vertically align. - * * @readonly */ public get maxLineHeight(): number @@ -814,7 +812,6 @@ export class BitmapText extends Container /** * The width of the overall text, different from fontSize, * which is defined in the style object. - * * @readonly */ public get textWidth(): number @@ -844,7 +841,6 @@ export class BitmapText extends Container * Advantages can include sharper image quality (like text) and faster rendering on canvas. * The main disadvantage is movement of objects may appear less smooth. * To set the global default, change {@link PIXI.settings.ROUND_PIXELS} - * * @default PIXI.settings.ROUND_PIXELS */ public get roundPixels(): boolean @@ -864,7 +860,6 @@ export class BitmapText extends Container /** * The height of the overall text, different from fontSize, * which is defined in the style object. - * * @readonly */ public get textHeight(): number @@ -874,6 +869,30 @@ export class BitmapText extends Container return this._textHeight; } + /** + * The resolution / device pixel ratio of the canvas. + * + * This is set to automatically match the renderer resolution by default, but can be overridden by setting manually. + * @default 1 + */ + get resolution(): number + { + return this._resolution; + } + + set resolution(value: number) + { + this._autoResolution = false; + + if (this._resolution === value) + { + return; + } + + this._resolution = value; + this.dirty = true; + } + destroy(options?: boolean | IDestroyOptions): void { const { _textureCache } = this; diff --git a/packages/text-bitmap/src/BitmapTextStyle.ts b/packages/text-bitmap/src/BitmapTextStyle.ts index c995d0de53..f0fa4a046d 100644 --- a/packages/text-bitmap/src/BitmapTextStyle.ts +++ b/packages/text-bitmap/src/BitmapTextStyle.ts @@ -1,6 +1,7 @@ import type { TextStyleAlign } from '@pixi/text'; -export interface IBitmapTextStyle { +export interface IBitmapTextStyle +{ fontName: string; fontSize: number; tint: number; @@ -9,7 +10,8 @@ export interface IBitmapTextStyle { maxWidth: number; } -export interface IBitmapTextFontDescriptor { +export interface IBitmapTextFontDescriptor +{ name: string; size: number; } diff --git a/packages/text-bitmap/src/formats/TextFormat.ts b/packages/text-bitmap/src/formats/TextFormat.ts index e93b253fa4..fe57f054b9 100644 --- a/packages/text-bitmap/src/formats/TextFormat.ts +++ b/packages/text-bitmap/src/formats/TextFormat.ts @@ -4,7 +4,8 @@ import { BitmapFontData } from '../BitmapFontData'; * Internal data format used to convert to BitmapFontData. * @private */ -interface IBitmapFontRawData { +interface IBitmapFontRawData +{ info: { face: string; size: string; @@ -44,16 +45,14 @@ interface IBitmapFontRawData { /** * BitmapFont format that's Text-based. - * * @private */ export class TextFormat { /** * Check if resource refers to txt font data. - * * @param data - * @return - True if resource could be treated as font data, false otherwise. + * @returns - True if resource could be treated as font data, false otherwise. */ static test(data: unknown): boolean { @@ -62,9 +61,8 @@ export class TextFormat /** * Convert text font data to a javascript object. - * * @param txt - Raw string data to be converted - * @return - Parsed font data + * @returns - Parsed font data */ static parse(txt: string): BitmapFontData { diff --git a/packages/text-bitmap/src/formats/XMLFormat.ts b/packages/text-bitmap/src/formats/XMLFormat.ts index 0d5930e4ab..adc33e4367 100644 --- a/packages/text-bitmap/src/formats/XMLFormat.ts +++ b/packages/text-bitmap/src/formats/XMLFormat.ts @@ -2,16 +2,14 @@ import { BitmapFontData } from '../BitmapFontData'; /** * BitmapFont format that's XML-based. - * * @private */ export class XMLFormat { /** * Check if resource refers to xml font data. - * * @param data - * @return - True if resource could be treated as font data, false otherwise. + * @returns - True if resource could be treated as font data, false otherwise. */ static test(data: unknown): boolean { @@ -22,9 +20,8 @@ export class XMLFormat /** * Convert the XML into BitmapFontData that we can use. - * * @param xml - * @return - Data to use for BitmapFont + * @returns - Data to use for BitmapFont */ static parse(xml: XMLDocument): BitmapFontData { diff --git a/packages/text-bitmap/src/formats/XMLStringFormat.ts b/packages/text-bitmap/src/formats/XMLStringFormat.ts index 5fb572120d..c5f217e6ab 100644 --- a/packages/text-bitmap/src/formats/XMLStringFormat.ts +++ b/packages/text-bitmap/src/formats/XMLStringFormat.ts @@ -3,16 +3,14 @@ import { XMLFormat } from './XMLFormat'; /** * BitmapFont format that's XML-based. - * * @private */ export class XMLStringFormat { /** * Check if resource refers to text xml font data. - * * @param data - * @return - True if resource could be treated as font data, false otherwise. + * @returns - True if resource could be treated as font data, false otherwise. */ static test(data: unknown): boolean { @@ -28,9 +26,8 @@ export class XMLStringFormat /** * Convert the text XML into BitmapFontData that we can use. - * * @param xmlTxt - * @return - Data to use for BitmapFont + * @returns - Data to use for BitmapFont */ static parse(xmlTxt: string): BitmapFontData { diff --git a/packages/text-bitmap/src/formats/index.ts b/packages/text-bitmap/src/formats/index.ts index af916c7e66..5514ce27ec 100644 --- a/packages/text-bitmap/src/formats/index.ts +++ b/packages/text-bitmap/src/formats/index.ts @@ -13,7 +13,7 @@ const formats = [ * Auto-detect BitmapFont parsing format based on data. * @private * @param {any} data - Data to detect format - * @return {any} Format or null + * @returns {any} Format or null */ export function autoDetectFormat(data: unknown): typeof formats[number] | null { diff --git a/packages/text-bitmap/src/utils/drawGlyph.ts b/packages/text-bitmap/src/utils/drawGlyph.ts index d1973509b7..43b0ac40d4 100644 --- a/packages/text-bitmap/src/utils/drawGlyph.ts +++ b/packages/text-bitmap/src/utils/drawGlyph.ts @@ -8,7 +8,6 @@ import type { TextMetrics, TextStyle } from '@pixi/text'; * Draws the glyph `metrics.text` on the given canvas. * * Ignored because not directly exposed. - * * @ignore * @param {HTMLCanvasElement} canvas * @param {CanvasRenderingContext2D} context diff --git a/packages/text-bitmap/src/utils/extractCharCode.ts b/packages/text-bitmap/src/utils/extractCharCode.ts index 69e289ab4a..03d43da943 100644 --- a/packages/text-bitmap/src/utils/extractCharCode.ts +++ b/packages/text-bitmap/src/utils/extractCharCode.ts @@ -1,5 +1,6 @@ /** * Ponyfill for IE because it doesn't support `codePointAt` + * @param str * @private */ export function extractCharCode(str: string): number diff --git a/packages/text-bitmap/src/utils/generateFillStyle.ts b/packages/text-bitmap/src/utils/generateFillStyle.ts index d33734833d..5e0f8e903f 100644 --- a/packages/text-bitmap/src/utils/generateFillStyle.ts +++ b/packages/text-bitmap/src/utils/generateFillStyle.ts @@ -4,11 +4,14 @@ import { TextStyle, TextMetrics, TEXT_GRADIENT } from '@pixi/text'; /** * Generates the fill style. Can automatically generate a gradient based on the fill style being an array - * * @private + * @param canvas + * @param context * @param {object} style - The style. + * @param resolution * @param {string[]} lines - The lines of text. - * @return {string|number|CanvasGradient} The fill style + * @param metrics + * @returns {string|number|CanvasGradient} The fill style */ export function generateFillStyle( canvas: HTMLCanvasElement, @@ -17,12 +20,12 @@ export function generateFillStyle( resolution: number, lines: string[], metrics: TextMetrics -): string|CanvasGradient|CanvasPattern +): string | CanvasGradient | CanvasPattern { // TODO: Can't have different types for getter and setter. The getter shouldn't have the number type as // the setter converts to string. See this thread for more details: // https://github.com/microsoft/TypeScript/issues/2521 - const fillStyle: string|string[]|CanvasGradient|CanvasPattern = style.fill as any; + const fillStyle: string | string[] | CanvasGradient | CanvasPattern = style.fill as any; if (!Array.isArray(fillStyle)) { @@ -35,7 +38,7 @@ export function generateFillStyle( // the gradient will be evenly spaced out according to how large the array is. // ['#FF0000', '#00FF00', '#0000FF'] would created stops at 0.25, 0.5 and 0.75 - let gradient: string[]|CanvasGradient; + let gradient: string[] | CanvasGradient; // a dropshadow will enlarge the canvas and result in the gradient being // generated with the incorrect dimensions diff --git a/packages/text-bitmap/src/utils/resolveCharacters.ts b/packages/text-bitmap/src/utils/resolveCharacters.ts index 6525d5945e..d5fe9dfb0d 100644 --- a/packages/text-bitmap/src/utils/resolveCharacters.ts +++ b/packages/text-bitmap/src/utils/resolveCharacters.ts @@ -4,10 +4,9 @@ import { splitTextToCharacters } from './splitTextToCharacters'; * Processes the passed character set data and returns a flattened array of all the characters. * * Ignored because not directly exposed. - * * @ignore * @param {string | string[] | string[][] } chars - * @returns {string[]} + * @returns {string[]} the flattened array of characters */ export function resolveCharacters(chars: string | (string | string[])[]): string[] { diff --git a/packages/text-bitmap/src/utils/splitTextToCharacters.ts b/packages/text-bitmap/src/utils/splitTextToCharacters.ts index 7156c4a940..78d13c7c29 100644 --- a/packages/text-bitmap/src/utils/splitTextToCharacters.ts +++ b/packages/text-bitmap/src/utils/splitTextToCharacters.ts @@ -1,5 +1,6 @@ /** * Ponyfill for IE because it doesn't support `Array.from` + * @param text * @private */ export function splitTextToCharacters(text: string): string[] diff --git a/packages/text-bitmap/test/BitmapFont.tests.ts b/packages/text-bitmap/test/BitmapFont.tests.ts index f482280b5c..459dba0886 100644 --- a/packages/text-bitmap/test/BitmapFont.tests.ts +++ b/packages/text-bitmap/test/BitmapFont.tests.ts @@ -1,11 +1,11 @@ import { BitmapFont } from '@pixi/text-bitmap'; import { expect } from 'chai'; -describe('BitmapFont', function () +describe('BitmapFont', () => { - describe('from', function () + describe('from', () => { - afterEach(function () + afterEach(() => { for (const name in BitmapFont.available) { @@ -13,11 +13,13 @@ describe('BitmapFont', function () } }); - it('should throw for missing name', function () + it('should throw for missing name', () => { + // @ts-expect-error - testing for error expect(() => BitmapFont.from()).to.throw; }); + // eslint-disable-next-line func-names it('should register the font if a name is provided', function () { this.timeout(8000); @@ -30,14 +32,14 @@ describe('BitmapFont', function () expect(BitmapFont.available.foo).to.equal(font); }); - it('should draw all characters in a provided range', function () + it('should draw all characters in a provided range', () => { const font = BitmapFont.from('foo', {}, { chars: [['a', 'z']] }); expect(Object.keys(font.chars).length).to.equal(26); }); - it('should draw emojis', function () + it('should draw emojis', () => { const emojis = ['🔥', '🌏', '😀']; const font = BitmapFont.from('foo', {}, { chars: [emojis.join('')] }); @@ -45,21 +47,23 @@ describe('BitmapFont', function () expect(Object.keys(font.chars).length).to.equal(emojis.length); for (const emoji of emojis) { - expect(font.chars).to.have.property(emoji.codePointAt(0)); + const char = String(emoji.codePointAt(0)); + + expect(font.chars).to.have.property(char); } }); - it('should throw an error when an invalid range is given', function () + it('should throw an error when an invalid range is given', () => { expect(() => BitmapFont.from('foo', {}, { chars: [['l', 'i', 'm']] })).to.throw; }); - it('should throw an error when an invalid start/end of range', function () + it('should throw an error when an invalid start/end of range', () => { expect(() => BitmapFont.from('foo', {}, { chars: [['z', 'a']] })).to.throw; }); - it('should render resolution with proportional size', function () + it('should render resolution with proportional size', () => { const fontRes1 = BitmapFont.from('foo', {}, { chars: 'a' }); const fontRes2 = BitmapFont.from('bar', {}, { chars: 'a', resolution: 2 }); @@ -71,7 +75,7 @@ describe('BitmapFont', function () expect(fontRes2.chars[id].texture.baseTexture.resolution).to.equal(2); }); - it('should override and replace font', function () + it('should override and replace font', () => { const id = 'a'.charCodeAt(0); @@ -83,7 +87,7 @@ describe('BitmapFont', function () expect(BitmapFont.available.foo.chars[id]).to.be.undefined; }); - it('should throw an error when no characters are passed', function () + it('should throw an error when no characters are passed', () => { expect(() => BitmapFont.from('foo', {}, { chars: [] })).to.throw; }); diff --git a/packages/text-bitmap/test/BitmapFontLoader.tests.ts b/packages/text-bitmap/test/BitmapFontLoader.tests.ts index 1506fed45a..7618c79b5d 100644 --- a/packages/text-bitmap/test/BitmapFontLoader.tests.ts +++ b/packages/text-bitmap/test/BitmapFontLoader.tests.ts @@ -1,16 +1,16 @@ import path from 'path'; import fs from 'fs'; -import { Loader } from '@pixi/loaders'; -import { BaseTextureCache, TextureCache, destroyTextureCache } from '@pixi/utils'; -import { Texture, BaseTexture } from '@pixi/core'; -import { Spritesheet } from '@pixi/spritesheet'; +import { Loader, LoaderResource } from '@pixi/loaders'; +import { BaseTextureCache, TextureCache } from '@pixi/utils'; +import { Texture, BaseTexture, ImageResource } from '@pixi/core'; +import { ISpritesheetData, Spritesheet } from '@pixi/spritesheet'; import { BitmapFont, BitmapFontLoader } from '@pixi/text-bitmap'; import sinon from 'sinon'; import { expect } from 'chai'; -describe('BitmapFontLoader', function () +describe('BitmapFontLoader', () => { - afterEach(function () + afterEach(() => { for (const font in BitmapFont.available) { @@ -26,42 +26,60 @@ describe('BitmapFontLoader', function () } }); - before(function (done) + let resources: string; + let fontXML: XMLDocument; + let fontTXT: string; + let fontScaledXML: XMLDocument; + let fontImage: HTMLImageElement; + let fontScaledImage: HTMLImageElement; + let fontText: string; + let fontRandomArgs: any; + let fontTXTImage: HTMLImageElement; + let atlasImage: HTMLImageElement; + let atlasScaledImage: HTMLImageElement; + let sdfXML: XMLDocument; + let msdfXML: XMLDocument; + let sdfImage: HTMLImageElement; + let msdfImage: HTMLImageElement; + let atlasJSON: ISpritesheetData; + let atlasScaledJSON: ISpritesheetData; + + before((done) => { - const resolveURL = (url) => path.resolve(this.resources, url); + const resolveURL = (url: string) => path.resolve(resources, url); BitmapFontLoader.add(); - this.resources = path.join(__dirname, 'resources'); - this.fontXML = null; - this.fontTXT = null; - this.fontScaledXML = null; - this.fontImage = null; - this.fontScaledImage = null; - this.atlasImage = null; - this.atlasScaledImage = null; - this.sdfXML = null; - this.msdfXML = null; - this.sdfImage = null; - this.msdfImage = null; - this.atlasJSON = require(resolveURL('atlas.json')); // eslint-disable-line global-require - this.atlasScaledJSON = require(resolveURL('atlas@0.5x.json')); // eslint-disable-line global-require - - const loadXML = (url) => new Promise((resolve) => + resources = path.join(__dirname, 'resources'); + fontXML = null; + fontTXT = null; + fontScaledXML = null; + fontImage = null; + fontScaledImage = null; + atlasImage = null; + atlasScaledImage = null; + sdfXML = null; + msdfXML = null; + sdfImage = null; + msdfImage = null; + atlasJSON = require(resolveURL('atlas.json')); // eslint-disable-line global-require + atlasScaledJSON = require(resolveURL('atlas@0.5x.json')); // eslint-disable-line global-require + + const loadXML = (url: string) => new Promise((resolve) => fs.readFile(resolveURL(url), 'utf8', (err, data) => { expect(err).to.be.null; resolve((new window.DOMParser()).parseFromString(data, 'text/xml')); })); - const loadTxt = (url) => new Promise((resolve) => + const loadTxt = (url: string) => new Promise((resolve) => fs.readFile(resolveURL(url), 'utf8', (err, data) => { expect(err).to.be.null; resolve(data); })); - const loadImage = (url) => new Promise((resolve) => + const loadImage = (url: string) => new Promise((resolve) => { const image = new Image(); @@ -69,7 +87,7 @@ describe('BitmapFontLoader', function () image.src = resolveURL(url); }); - Promise.all([ + Promise.all([ loadTxt('bmtxt-test.txt'), loadXML('font.fnt'), loadTxt('font-text.fnt'), @@ -85,49 +103,49 @@ describe('BitmapFontLoader', function () loadImage('sdf.png'), loadImage('msdf.png'), ]).then(([ - fontTXT, - fontXML, - fontText, - fontRandomArgs, - fontScaledXML, - sdfXML, - msdfXML, - fontTXTImage, - fontImage, - fontScaledImage, - atlasImage, - atlasScaledImage, - sdfImage, - msdfImage, + _fontTXT, + _fontXML, + _fontText, + _fontRandomArgs, + _fontScaledXML, + _sdfXML, + _msdfXML, + _fontTXTImage, + _fontImage, + _fontScaledImage, + _atlasImage, + _atlasScaledImage, + _sdfImage, + _msdfImage, ]) => { - this.fontTXT = fontTXT; - this.fontXML = fontXML; - this.fontText = fontText; - this.fontRandomArgs = fontRandomArgs; - this.fontScaledXML = fontScaledXML; - this.sdfXML = sdfXML; - this.msdfXML = msdfXML; - this.fontTXTImage = fontTXTImage; - this.fontImage = fontImage; - this.fontScaledImage = fontScaledImage; - this.atlasImage = atlasImage; - this.atlasScaledImage = atlasScaledImage; - this.sdfImage = sdfImage; - this.msdfImage = msdfImage; + fontTXT = _fontTXT; + fontXML = _fontXML; + fontText = _fontText; + fontRandomArgs = _fontRandomArgs; + fontScaledXML = _fontScaledXML; + sdfXML = _sdfXML; + msdfXML = _msdfXML; + fontTXTImage = _fontTXTImage; + fontImage = _fontImage; + fontScaledImage = _fontScaledImage; + atlasImage = _atlasImage; + atlasScaledImage = _atlasScaledImage; + sdfImage = _sdfImage; + msdfImage = _msdfImage; done(); }); }); - it('should exist and return a function', function () + it('should exist and return a function', () => { expect(BitmapFontLoader).to.not.be.undefined; expect(BitmapFontLoader.use).to.be.a('function'); }); - it('should process dirname correctly', function () + it('should process dirname correctly', () => { - const { dirname } = BitmapFontLoader; + const dirname = BitmapFontLoader['dirname']; expect(dirname('file.fnt')).to.equal('.'); expect(dirname('/file.fnt')).to.equal('/'); @@ -136,33 +154,36 @@ describe('BitmapFontLoader', function () expect(dirname('../file.fnt')).to.equal('..'); }); - it('should do nothing if the resource is not XML/TXT font data', function () + it('should do nothing if the resource is not XML/TXT font data', () => { const spy = sinon.spy(); - const res = {}; + const res = {} as LoaderResource; + // @ts-expect-error --- BitmapFontLoader.use(res, spy); expect(spy).to.have.been.calledOnce; expect(res.textures).to.be.undefined; }); - it('should do nothing if the resource is not properly formatted XML', function () + it('should do nothing if the resource is not properly formatted XML', () => { const spy = sinon.spy(); - const res = { data: document.createDocumentFragment() }; + const res = { data: document.createDocumentFragment() } as LoaderResource; + // @ts-expect-error --- BitmapFontLoader.use(res, spy); expect(spy).to.have.been.calledOnce; expect(res.textures).to.be.undefined; }); - it('should do nothing if the resource is not properly formatted TXT', function () + it('should do nothing if the resource is not properly formatted TXT', () => { const spy = sinon.spy(); - const res = { data: 'abcdefgh' }; + const res = { data: 'abcdefgh' } as LoaderResource; + // @ts-expect-error --- BitmapFontLoader.use(res, spy); expect(spy).to.have.been.calledOnce; @@ -173,157 +194,169 @@ describe('BitmapFontLoader', function () // TODO: Test the loading texture code path. // TODO: Test data-url code paths. - it('should properly register bitmap font', function (done) + it('should properly register bitmap font', (done) => { - const texture = Texture.from(this.fontImage); - const font = BitmapFont.install(this.fontXML, texture); + const texture = Texture.from(fontImage); + const font = BitmapFont.install(fontXML, texture); expect(font).to.be.an('object'); expect(BitmapFont.available.font).to.equal(font); expect(font).to.have.property('chars'); const charA = font.chars['A'.charCodeAt(0)]; + const charATexture = charA.texture as Texture; expect(charA).to.exist; - expect(charA.texture.baseTexture.resource.source).to.equal(this.fontImage); - expect(charA.texture.frame.x).to.equal(2); - expect(charA.texture.frame.y).to.equal(2); - expect(charA.texture.frame.width).to.equal(19); - expect(charA.texture.frame.height).to.equal(20); + expect(charATexture.baseTexture.resource.source).to.equal(fontImage); + expect(charATexture.frame.x).to.equal(2); + expect(charATexture.frame.y).to.equal(2); + expect(charATexture.frame.width).to.equal(19); + expect(charATexture.frame.height).to.equal(20); const charB = font.chars['B'.charCodeAt(0)]; + const charBTexture = charB.texture as Texture; expect(charB).to.exist; - expect(charB.texture.baseTexture.resource.source).to.equal(this.fontImage); - expect(charB.texture.frame.x).to.equal(2); - expect(charB.texture.frame.y).to.equal(24); - expect(charB.texture.frame.width).to.equal(15); - expect(charB.texture.frame.height).to.equal(20); + expect(charBTexture.baseTexture.resource.source).to.equal(fontImage); + expect(charBTexture.frame.x).to.equal(2); + expect(charBTexture.frame.y).to.equal(24); + expect(charBTexture.frame.width).to.equal(15); + expect(charBTexture.frame.height).to.equal(20); const charC = font.chars['C'.charCodeAt(0)]; + const charCTexture = charC.texture as Texture; expect(charC).to.exist; - expect(charC.texture.baseTexture.resource.source).to.equal(this.fontImage); - expect(charC.texture.frame.x).to.equal(23); - expect(charC.texture.frame.y).to.equal(2); - expect(charC.texture.frame.width).to.equal(18); - expect(charC.texture.frame.height).to.equal(20); + expect(charCTexture.baseTexture.resource.source).to.equal(fontImage); + expect(charCTexture.frame.x).to.equal(23); + expect(charCTexture.frame.y).to.equal(2); + expect(charCTexture.frame.width).to.equal(18); + expect(charCTexture.frame.height).to.equal(20); const charD = font.chars['D'.charCodeAt(0)]; + const charDTexture = charD.texture as Texture; expect(charD).to.exist; - expect(charD.texture.baseTexture.resource.source).to.equal(this.fontImage); - expect(charD.texture.frame.x).to.equal(19); - expect(charD.texture.frame.y).to.equal(24); - expect(charD.texture.frame.width).to.equal(17); - expect(charD.texture.frame.height).to.equal(20); + expect(charDTexture.baseTexture.resource.source).to.equal(fontImage); + expect(charDTexture.frame.x).to.equal(19); + expect(charDTexture.frame.y).to.equal(24); + expect(charDTexture.frame.width).to.equal(17); + expect(charDTexture.frame.height).to.equal(20); const charE = font.chars['E'.charCodeAt(0)]; expect(charE).to.be.undefined; done(); }); - it('should properly register bitmap font based on txt data', function (done) + it('should properly register bitmap font based on txt data', (done) => { - const texture = Texture.from(this.fontTXTImage); - const font = BitmapFont.install(this.fontTXT, texture); + const texture = Texture.from(fontTXTImage); + const font = BitmapFont.install(fontTXT, texture); expect(font).to.be.an('object'); expect(font).to.have.property('chars'); const charA = font.chars['A'.charCodeAt(0)]; + const charATexture = charA.texture as Texture; expect(charA).to.exist; - expect(charA.texture.baseTexture.resource.source).to.equal(this.fontTXTImage); - expect(charA.texture.frame.x).to.equal(1); - expect(charA.texture.frame.y).to.equal(179); - expect(charA.texture.frame.width).to.equal(38); - expect(charA.texture.frame.height).to.equal(28); + expect(charATexture.baseTexture.resource.source).to.equal(fontTXTImage); + expect(charATexture.frame.x).to.equal(1); + expect(charATexture.frame.y).to.equal(179); + expect(charATexture.frame.width).to.equal(38); + expect(charATexture.frame.height).to.equal(28); const charB = font.chars['B'.charCodeAt(0)]; + const charBTexture = charB.texture as Texture; expect(charB).to.exist; - expect(charB.texture.baseTexture.resource.source).to.equal(this.fontTXTImage); - expect(charB.texture.frame.x).to.equal(52); - expect(charB.texture.frame.y).to.equal(146); - expect(charB.texture.frame.width).to.equal(34); - expect(charB.texture.frame.height).to.equal(28); + expect(charBTexture.baseTexture.resource.source).to.equal(fontTXTImage); + expect(charBTexture.frame.x).to.equal(52); + expect(charBTexture.frame.y).to.equal(146); + expect(charBTexture.frame.width).to.equal(34); + expect(charBTexture.frame.height).to.equal(28); const charC = font.chars['C'.charCodeAt(0)]; + const charCTexture = charC.texture as Texture; expect(charC).to.exist; - expect(charC.texture.baseTexture.resource.source).to.equal(this.fontTXTImage); - expect(charC.texture.frame.x).to.equal(52); - expect(charC.texture.frame.y).to.equal(117); - expect(charC.texture.frame.width).to.equal(34); - expect(charC.texture.frame.height).to.equal(28); + expect(charCTexture.baseTexture.resource.source).to.equal(fontTXTImage); + expect(charCTexture.frame.x).to.equal(52); + expect(charCTexture.frame.y).to.equal(117); + expect(charCTexture.frame.width).to.equal(34); + expect(charCTexture.frame.height).to.equal(28); const charD = font.chars['D'.charCodeAt(0)]; + const charDTexture = charD.texture as Texture; expect(charD).to.exist; - expect(charD.texture.baseTexture.resource.source).to.equal(this.fontTXTImage); - expect(charD.texture.frame.x).to.equal(52); - expect(charD.texture.frame.y).to.equal(88); - expect(charD.texture.frame.width).to.equal(34); - expect(charD.texture.frame.height).to.equal(28); + expect(charDTexture.baseTexture.resource.source).to.equal(fontTXTImage); + expect(charDTexture.frame.x).to.equal(52); + expect(charDTexture.frame.y).to.equal(88); + expect(charDTexture.frame.width).to.equal(34); + expect(charDTexture.frame.height).to.equal(28); const charUndefined = font.chars['£'.charCodeAt(0)]; expect(charUndefined).to.be.undefined; done(); }); - it('should properly register SCALED bitmap font', function (done) + it('should properly register SCALED bitmap font', (done) => { - const baseTexture = new BaseTexture(this.fontScaledImage); + const baseTexture = new BaseTexture(fontScaledImage); baseTexture.setResolution(0.5); const texture = new Texture(baseTexture); - const font = BitmapFont.install(this.fontScaledXML, texture); + const font = BitmapFont.install(fontScaledXML, texture); expect(font).to.be.an('object'); expect(BitmapFont.available.font).to.equal(font); expect(font).to.have.property('chars'); const charA = font.chars['A'.charCodeAt(0)]; + const charATexture = charA.texture as Texture; expect(charA).to.exist; - expect(charA.texture.baseTexture.resource.source).to.equal(this.fontScaledImage); - expect(charA.texture.frame.x).to.equal(4); // 2 / 0.5 - expect(charA.texture.frame.y).to.equal(4); // 2 / 0.5 - expect(charA.texture.frame.width).to.equal(38); // 19 / 0.5 - expect(charA.texture.frame.height).to.equal(40); // 20 / 0.5 + expect(charATexture.baseTexture.resource.source).to.equal(fontScaledImage); + expect(charATexture.frame.x).to.equal(4); // 2 / 0.5 + expect(charATexture.frame.y).to.equal(4); // 2 / 0.5 + expect(charATexture.frame.width).to.equal(38); // 19 / 0.5 + expect(charATexture.frame.height).to.equal(40); // 20 / 0.5 const charB = font.chars['B'.charCodeAt(0)]; + const charBTexture = charB.texture as Texture; expect(charB).to.exist; - expect(charB.texture.baseTexture.resource.source).to.equal(this.fontScaledImage); - expect(charB.texture.frame.x).to.equal(4); // 2 / 0.5 - expect(charB.texture.frame.y).to.equal(48); // 24 / 0.5 - expect(charB.texture.frame.width).to.equal(30); // 15 / 0.5 - expect(charB.texture.frame.height).to.equal(40); // 20 / 0.5 + expect(charBTexture.baseTexture.resource.source).to.equal(fontScaledImage); + expect(charBTexture.frame.x).to.equal(4); // 2 / 0.5 + expect(charBTexture.frame.y).to.equal(48); // 24 / 0.5 + expect(charBTexture.frame.width).to.equal(30); // 15 / 0.5 + expect(charBTexture.frame.height).to.equal(40); // 20 / 0.5 const charC = font.chars['C'.charCodeAt(0)]; + const charCTexture = charC.texture as Texture; expect(charC).to.exist; - expect(charC.texture.baseTexture.resource.source).to.equal(this.fontScaledImage); - expect(charC.texture.frame.x).to.equal(46); // 23 / 0.5 - expect(charC.texture.frame.y).to.equal(4); // 2 / 0.5 - expect(charC.texture.frame.width).to.equal(36); // 18 / 0.5 - expect(charC.texture.frame.height).to.equal(40); // 20 / 0.5 + expect(charCTexture.baseTexture.resource.source).to.equal(fontScaledImage); + expect(charCTexture.frame.x).to.equal(46); // 23 / 0.5 + expect(charCTexture.frame.y).to.equal(4); // 2 / 0.5 + expect(charCTexture.frame.width).to.equal(36); // 18 / 0.5 + expect(charCTexture.frame.height).to.equal(40); // 20 / 0.5 const charD = font.chars['D'.charCodeAt(0)]; + const charDTexture = charD.texture as Texture; expect(charD).to.exist; - expect(charD.texture.baseTexture.resource.source).to.equal(this.fontScaledImage); - expect(charD.texture.frame.x).to.equal(38); // 19 / 0.5 - expect(charD.texture.frame.y).to.equal(48); // 24 / 0.5 - expect(charD.texture.frame.width).to.equal(34); // 17 / 0.5 - expect(charD.texture.frame.height).to.equal(40); // 20 / 0.5 + expect(charDTexture.baseTexture.resource.source).to.equal(fontScaledImage); + expect(charDTexture.frame.x).to.equal(38); // 19 / 0.5 + expect(charDTexture.frame.y).to.equal(48); // 24 / 0.5 + expect(charDTexture.frame.width).to.equal(34); // 17 / 0.5 + expect(charDTexture.frame.height).to.equal(40); // 20 / 0.5 const charE = font.chars['E'.charCodeAt(0)]; expect(charE).to.be.undefined; done(); }); - it('should properly register bitmap font NESTED into spritesheet', function (done) + it('should properly register bitmap font NESTED into spritesheet', (done) => { - const baseTexture = new BaseTexture(this.atlasImage); - const spritesheet = new Spritesheet(baseTexture, this.atlasJSON); + const baseTexture = new BaseTexture(atlasImage); + const spritesheet = new Spritesheet(baseTexture, atlasJSON); spritesheet.parse(() => { const fontTexture = Texture.from('resources/font.png'); - const font = BitmapFont.install(this.fontXML, fontTexture); + const font = BitmapFont.install(fontXML, fontTexture); const fontX = 158; // bare value from spritesheet frame const fontY = 2; // bare value from spritesheet frame @@ -331,37 +364,41 @@ describe('BitmapFontLoader', function () expect(BitmapFont.available.font).to.equal(font); expect(font).to.have.property('chars'); const charA = font.chars['A'.charCodeAt(0)]; + const charATexture = charA.texture as Texture; expect(charA).to.exist; - expect(charA.texture.baseTexture.resource.source).to.equal(this.atlasImage); - expect(charA.texture.frame.x).to.equal(fontX + 2); - expect(charA.texture.frame.y).to.equal(fontY + 2); - expect(charA.texture.frame.width).to.equal(19); - expect(charA.texture.frame.height).to.equal(20); + expect(charATexture.baseTexture.resource.source).to.equal(atlasImage); + expect(charATexture.frame.x).to.equal(fontX + 2); + expect(charATexture.frame.y).to.equal(fontY + 2); + expect(charATexture.frame.width).to.equal(19); + expect(charATexture.frame.height).to.equal(20); const charB = font.chars['B'.charCodeAt(0)]; + const charBTexture = charB.texture as Texture; expect(charB).to.exist; - expect(charB.texture.baseTexture.resource.source).to.equal(this.atlasImage); - expect(charB.texture.frame.x).to.equal(fontX + 2); - expect(charB.texture.frame.y).to.equal(fontY + 24); - expect(charB.texture.frame.width).to.equal(15); - expect(charB.texture.frame.height).to.equal(20); + expect(charBTexture.baseTexture.resource.source).to.equal(atlasImage); + expect(charBTexture.frame.x).to.equal(fontX + 2); + expect(charBTexture.frame.y).to.equal(fontY + 24); + expect(charBTexture.frame.width).to.equal(15); + expect(charBTexture.frame.height).to.equal(20); const charC = font.chars['C'.charCodeAt(0)]; + const charCTexture = charC.texture as Texture; expect(charC).to.exist; - expect(charC.texture.baseTexture.resource.source).to.equal(this.atlasImage); - expect(charC.texture.frame.x).to.equal(fontX + 23); - expect(charC.texture.frame.y).to.equal(fontY + 2); - expect(charC.texture.frame.width).to.equal(18); - expect(charC.texture.frame.height).to.equal(20); + expect(charCTexture.baseTexture.resource.source).to.equal(atlasImage); + expect(charCTexture.frame.x).to.equal(fontX + 23); + expect(charCTexture.frame.y).to.equal(fontY + 2); + expect(charCTexture.frame.width).to.equal(18); + expect(charCTexture.frame.height).to.equal(20); const charD = font.chars['D'.charCodeAt(0)]; + const charDTexture = charD.texture as Texture; expect(charD).to.exist; - expect(charD.texture.baseTexture.resource.source).to.equal(this.atlasImage); - expect(charD.texture.frame.x).to.equal(fontX + 19); - expect(charD.texture.frame.y).to.equal(fontY + 24); - expect(charD.texture.frame.width).to.equal(17); - expect(charD.texture.frame.height).to.equal(20); + expect(charDTexture.baseTexture.resource.source).to.equal(atlasImage); + expect(charDTexture.frame.x).to.equal(fontX + 19); + expect(charDTexture.frame.y).to.equal(fontY + 24); + expect(charDTexture.frame.width).to.equal(17); + expect(charDTexture.frame.height).to.equal(20); const charE = font.chars['E'.charCodeAt(0)]; expect(charE).to.be.undefined; @@ -369,17 +406,17 @@ describe('BitmapFontLoader', function () }); }); - it('should properly register bitmap font NESTED into SCALED spritesheet', function (done) + it('should properly register bitmap font NESTED into SCALED spritesheet', (done) => { - const baseTexture = new BaseTexture(this.atlasScaledImage); - const spritesheet = new Spritesheet(baseTexture, this.atlasScaledJSON); + const baseTexture = new BaseTexture(atlasScaledImage); + const spritesheet = new Spritesheet(baseTexture, atlasScaledJSON); spritesheet.resolution = 1; spritesheet.parse(() => { const fontTexture = Texture.from('resources/font.png'); - const font = BitmapFont.install(this.fontXML, fontTexture); + const font = BitmapFont.install(fontXML, fontTexture); const fontX = 158; // bare value from spritesheet frame const fontY = 2; // bare value from spritesheet frame @@ -387,37 +424,41 @@ describe('BitmapFontLoader', function () expect(BitmapFont.available.font).to.equal(font); expect(font).to.have.property('chars'); const charA = font.chars['A'.charCodeAt(0)]; + const charATexture = charA.texture as Texture; expect(charA).to.exist; - expect(charA.texture.baseTexture.resource.source).to.equal(this.atlasScaledImage); - expect(charA.texture.frame.x).to.equal(fontX + 2); - expect(charA.texture.frame.y).to.equal(fontY + 2); - expect(charA.texture.frame.width).to.equal(19); - expect(charA.texture.frame.height).to.equal(20); + expect(charATexture.baseTexture.resource.source).to.equal(atlasScaledImage); + expect(charATexture.frame.x).to.equal(fontX + 2); + expect(charATexture.frame.y).to.equal(fontY + 2); + expect(charATexture.frame.width).to.equal(19); + expect(charATexture.frame.height).to.equal(20); const charB = font.chars['B'.charCodeAt(0)]; + const charBTexture = charB.texture as Texture; expect(charB).to.exist; - expect(charB.texture.baseTexture.resource.source).to.equal(this.atlasScaledImage); - expect(charB.texture.frame.x).to.equal(fontX + 2); - expect(charB.texture.frame.y).to.equal(fontY + 24); - expect(charB.texture.frame.width).to.equal(15); - expect(charB.texture.frame.height).to.equal(20); + expect(charBTexture.baseTexture.resource.source).to.equal(atlasScaledImage); + expect(charBTexture.frame.x).to.equal(fontX + 2); + expect(charBTexture.frame.y).to.equal(fontY + 24); + expect(charBTexture.frame.width).to.equal(15); + expect(charBTexture.frame.height).to.equal(20); const charC = font.chars['C'.charCodeAt(0)]; + const charCTexture = charC.texture as Texture; expect(charC).to.exist; - expect(charC.texture.baseTexture.resource.source).to.equal(this.atlasScaledImage); - expect(charC.texture.frame.x).to.equal(fontX + 23); - expect(charC.texture.frame.y).to.equal(fontY + 2); - expect(charC.texture.frame.width).to.equal(18); - expect(charC.texture.frame.height).to.equal(20); + expect(charCTexture.baseTexture.resource.source).to.equal(atlasScaledImage); + expect(charCTexture.frame.x).to.equal(fontX + 23); + expect(charCTexture.frame.y).to.equal(fontY + 2); + expect(charCTexture.frame.width).to.equal(18); + expect(charCTexture.frame.height).to.equal(20); const charD = font.chars['D'.charCodeAt(0)]; + const charDTexture = charD.texture as Texture; expect(charD).to.exist; - expect(charD.texture.baseTexture.resource.source).to.equal(this.atlasScaledImage); - expect(charD.texture.frame.x).to.equal(fontX + 19); - expect(charD.texture.frame.y).to.equal(fontY + 24); - expect(charD.texture.frame.width).to.equal(17); - expect(charD.texture.frame.height).to.equal(20); + expect(charDTexture.baseTexture.resource.source).to.equal(atlasScaledImage); + expect(charDTexture.frame.x).to.equal(fontX + 19); + expect(charDTexture.frame.y).to.equal(fontY + 24); + expect(charDTexture.frame.width).to.equal(17); + expect(charDTexture.frame.height).to.equal(20); const charE = font.chars['E'.charCodeAt(0)]; expect(charE).to.be.undefined; @@ -425,12 +466,12 @@ describe('BitmapFontLoader', function () }); }); - it('should properly register bitmap font having more than one texture', function (done) + it('should properly register bitmap font having more than one texture', (done) => { const loader = new Loader(); loader.use(BitmapFontLoader.use); - loader.add(path.join(this.resources, 'split_font.fnt')); + loader.add(path.join(resources, 'split_font.fnt')); loader.load(() => { const font = BitmapFont.available.split_font; @@ -439,49 +480,53 @@ describe('BitmapFontLoader', function () expect(BitmapFont.available.split_font).to.equal(font); expect(font).to.have.property('chars'); const charA = font.chars['A'.charCodeAt(0)]; + const charATexture = charA.texture as Texture; expect(charA).to.exist; - let src = charA.texture.baseTexture.resource.url; + let src = charATexture.baseTexture.resource.url; src = src.substring(src.length - 17); expect(src).to.equal('split_font_ab.png'); - expect(charA.texture.frame.x).to.equal(2); - expect(charA.texture.frame.y).to.equal(2); - expect(charA.texture.frame.width).to.equal(19); - expect(charA.texture.frame.height).to.equal(20); + expect(charATexture.frame.x).to.equal(2); + expect(charATexture.frame.y).to.equal(2); + expect(charATexture.frame.width).to.equal(19); + expect(charATexture.frame.height).to.equal(20); const charB = font.chars['B'.charCodeAt(0)]; + const charBTexture = charB.texture as Texture; expect(charB).to.exist; - src = charB.texture.baseTexture.resource.url; + src = charBTexture.baseTexture.resource.url; src = src.substring(src.length - 17); expect(src).to.equal('split_font_ab.png'); - expect(charB.texture.frame.x).to.equal(2); - expect(charB.texture.frame.y).to.equal(24); - expect(charB.texture.frame.width).to.equal(15); - expect(charB.texture.frame.height).to.equal(20); + expect(charBTexture.frame.x).to.equal(2); + expect(charBTexture.frame.y).to.equal(24); + expect(charBTexture.frame.width).to.equal(15); + expect(charBTexture.frame.height).to.equal(20); const charC = font.chars['C'.charCodeAt(0)]; + const charCTexture = charC.texture as Texture; expect(charC).to.exist; - src = charC.texture.baseTexture.resource.url; + src = charCTexture.baseTexture.resource.url; src = src.substring(src.length - 17); expect(src).to.equal('split_font_cd.png'); - expect(charC.texture.frame.x).to.equal(2); - expect(charC.texture.frame.y).to.equal(2); - expect(charC.texture.frame.width).to.equal(18); - expect(charC.texture.frame.height).to.equal(20); + expect(charCTexture.frame.x).to.equal(2); + expect(charCTexture.frame.y).to.equal(2); + expect(charCTexture.frame.width).to.equal(18); + expect(charCTexture.frame.height).to.equal(20); const charD = font.chars['D'.charCodeAt(0)]; + const charDTexture = charD.texture as Texture; expect(charD).to.exist; - src = charD.texture.baseTexture.resource.url; + src = charDTexture.baseTexture.resource.url; src = src.substring(src.length - 17); expect(src).to.equal('split_font_cd.png'); - expect(charD.texture.frame.x).to.equal(2); - expect(charD.texture.frame.y).to.equal(24); - expect(charD.texture.frame.width).to.equal(17); - expect(charD.texture.frame.height).to.equal(20); + expect(charDTexture.frame.x).to.equal(2); + expect(charDTexture.frame.y).to.equal(24); + expect(charDTexture.frame.width).to.equal(17); + expect(charDTexture.frame.height).to.equal(20); const charE = font.chars['E'.charCodeAt(0)]; expect(charE).to.be.undefined; @@ -489,16 +534,16 @@ describe('BitmapFontLoader', function () }); }); - it('should split fonts if page IDs are in chronological order', function (done) + it('should split fonts if page IDs are in chronological order', (done) => { const loader = new Loader(); loader.use(BitmapFontLoader.use); - loader.add(path.join(this.resources, 'split_font2.fnt')); + loader.add(path.join(resources, 'split_font2.fnt')); loader.load(() => { - const page0 = path.join(this.resources, 'split_font_ab.png').replace(/\\/g, '/'); - const page1 = path.join(this.resources, 'split_font_cd.png').replace(/\\/g, '/'); + const page0 = path.join(resources, 'split_font_ab.png').replace(/\\/g, '/'); + const page1 = path.join(resources, 'split_font_cd.png').replace(/\\/g, '/'); expect(loader.resources[page0].metadata.pageFile).to.equal('split_font_ab.png'); expect(loader.resources[page1].metadata.pageFile).to.equal('split_font_cd.png'); @@ -506,21 +551,23 @@ describe('BitmapFontLoader', function () const font = BitmapFont.available.split_font2; const charA = font.chars['A'.charCodeAt(0)]; const charC = font.chars['C'.charCodeAt(0)]; + const charATexture = charA.texture as Texture; + const charCTexture = charC.texture as Texture; expect(charA.page).to.equal(0); expect(charC.page).to.equal(1); - expect(charA.texture.baseTexture.resource.url).to.equal(page0); - expect(charC.texture.baseTexture.resource.url).to.equal(page1); + expect(charATexture.baseTexture.resource.url).to.equal(page0); + expect(charCTexture.baseTexture.resource.url).to.equal(page1); done(); }); }); - it('should register bitmap font with side-loaded image', function (done) + it('should register bitmap font with side-loaded image', (done) => { const loader = new Loader(); - const imagePath = path.join(this.resources, 'font.png'); - const fontPath = path.join(this.resources, 'font.fnt'); + const imagePath = path.join(resources, 'font.png'); + const fontPath = path.join(resources, 'font.fnt'); loader.add('image', imagePath); loader.add('font', fontPath); @@ -534,10 +581,10 @@ describe('BitmapFontLoader', function () }); }); - it('should load and uninstall font cleanly, remove all textures', function (done) + it('should load and uninstall font cleanly, remove all textures', (done) => { const loader = new Loader(); - const fontPath = path.join(this.resources, 'font.fnt'); + const fontPath = path.join(resources, 'font.fnt'); const textureCount = Object.keys(TextureCache).length; expect(BitmapFont.available.font).to.be.undefined; @@ -555,13 +602,13 @@ describe('BitmapFontLoader', function () }); }); - it('should load and uninstall font cleanly, preserve textures', function () + it('should load and uninstall font cleanly, preserve textures', () => { const textureCount = Object.keys(TextureCache).length; - const texture = Texture.from(this.fontImage); - const fontText = BitmapFont.install(this.fontText, texture); + const texture = Texture.from(fontImage); + const font = BitmapFont.install(fontText, texture); - expect(BitmapFont.available.fontText).equals(fontText); + expect(BitmapFont.available.fontText).equals(font); BitmapFont.uninstall('fontText'); @@ -571,60 +618,64 @@ describe('BitmapFontLoader', function () texture.destroy(true); }); - it('should properly register bitmap font based on text format', function (done) + it('should properly register bitmap font based on text format', (done) => { - const texture = Texture.from(this.fontImage); - const font = BitmapFont.install(this.fontText, texture); + const texture = Texture.from(fontImage); + const font = BitmapFont.install(fontText, texture); expect(font).to.be.an('object'); expect(BitmapFont.available.fontText).to.equal(font); expect(font).to.have.property('chars'); const charA = font.chars['A'.charCodeAt(0)]; + const charATexture = charA.texture as Texture; expect(charA).to.exist; - expect(charA.texture.baseTexture.resource.source).to.equal(this.fontImage); - expect(charA.texture.frame.x).to.equal(2); - expect(charA.texture.frame.y).to.equal(2); - expect(charA.texture.frame.width).to.equal(19); - expect(charA.texture.frame.height).to.equal(20); + expect(charATexture.baseTexture.resource.source).to.equal(fontImage); + expect(charATexture.frame.x).to.equal(2); + expect(charATexture.frame.y).to.equal(2); + expect(charATexture.frame.width).to.equal(19); + expect(charATexture.frame.height).to.equal(20); const charB = font.chars['B'.charCodeAt(0)]; + const charBTexture = charB.texture as Texture; expect(charB).to.exist; - expect(charB.texture.baseTexture.resource.source).to.equal(this.fontImage); - expect(charB.texture.frame.x).to.equal(2); - expect(charB.texture.frame.y).to.equal(24); - expect(charB.texture.frame.width).to.equal(15); - expect(charB.texture.frame.height).to.equal(20); + expect(charBTexture.baseTexture.resource.source).to.equal(fontImage); + expect(charBTexture.frame.x).to.equal(2); + expect(charBTexture.frame.y).to.equal(24); + expect(charBTexture.frame.width).to.equal(15); + expect(charBTexture.frame.height).to.equal(20); const charC = font.chars['C'.charCodeAt(0)]; + const charCTexture = charC.texture as Texture; expect(charC).to.exist; - expect(charC.texture.baseTexture.resource.source).to.equal(this.fontImage); - expect(charC.texture.frame.x).to.equal(23); - expect(charC.texture.frame.y).to.equal(2); - expect(charC.texture.frame.width).to.equal(18); - expect(charC.texture.frame.height).to.equal(20); + expect(charCTexture.baseTexture.resource.source).to.equal(fontImage); + expect(charCTexture.frame.x).to.equal(23); + expect(charCTexture.frame.y).to.equal(2); + expect(charCTexture.frame.width).to.equal(18); + expect(charCTexture.frame.height).to.equal(20); const charD = font.chars['D'.charCodeAt(0)]; + const charDTexture = charD.texture as Texture; expect(charD).to.exist; - expect(charD.texture.baseTexture.resource.source).to.equal(this.fontImage); - expect(charD.texture.frame.x).to.equal(19); - expect(charD.texture.frame.y).to.equal(24); - expect(charD.texture.frame.width).to.equal(17); - expect(charD.texture.frame.height).to.equal(20); + expect(charDTexture.baseTexture.resource.source).to.equal(fontImage); + expect(charDTexture.frame.x).to.equal(19); + expect(charDTexture.frame.y).to.equal(24); + expect(charDTexture.frame.width).to.equal(17); + expect(charDTexture.frame.height).to.equal(20); const charE = font.chars['E'.charCodeAt(0)]; expect(charE).to.be.undefined; done(); }); - it('should set the texture to NPM on SDF fonts', function (done) + it('should set the texture to NPM on SDF fonts', (done) => { - const sdfTexture = Texture.from(this.sdfImage); - const msdfTexture = Texture.from(this.msdfImage); - const regularTexture = Texture.from(this.fontImage); - const sdfFont = BitmapFont.install(this.sdfXML, sdfTexture); - const msdfFont = BitmapFont.install(this.msdfXML, msdfTexture); - const regularFont = BitmapFont.install(this.fontText, regularTexture); + const sdfTexture = Texture.from(sdfImage); + const msdfTexture = Texture.from(msdfImage); + const regularTexture = Texture.from(fontImage); + const sdfFont = BitmapFont.install(sdfXML, sdfTexture); + const msdfFont = BitmapFont.install(msdfXML, msdfTexture); + const regularFont = BitmapFont.install(fontText, regularTexture); expect(sdfFont.chars['A'.charCodeAt(0)].texture.baseTexture.alphaMode).to.equal(0); expect(msdfFont.chars['A'.charCodeAt(0)].texture.baseTexture.alphaMode).to.equal(0); @@ -633,14 +684,14 @@ describe('BitmapFontLoader', function () done(); }); - it('should set the distanceFieldType correctly', function (done) + it('should set the distanceFieldType correctly', (done) => { - const sdfTexture = Texture.from(this.sdfImage); - const msdfTexture = Texture.from(this.msdfImage); - const regularTexture = Texture.from(this.fontImage); - const sdfFont = BitmapFont.install(this.sdfXML, sdfTexture); - const msdfFont = BitmapFont.install(this.msdfXML, msdfTexture); - const regularFont = BitmapFont.install(this.fontText, regularTexture); + const sdfTexture = Texture.from(sdfImage); + const msdfTexture = Texture.from(msdfImage); + const regularTexture = Texture.from(fontImage); + const sdfFont = BitmapFont.install(sdfXML, sdfTexture); + const msdfFont = BitmapFont.install(msdfXML, msdfTexture); + const regularFont = BitmapFont.install(fontText, regularTexture); expect(sdfFont.distanceFieldType).to.equal('sdf'); expect(msdfFont.distanceFieldType).to.equal('msdf'); @@ -649,22 +700,23 @@ describe('BitmapFontLoader', function () done(); }); - it('should properly register bitmap font with random placed arguments into info tag', function (done) + it('should properly register bitmap font with random placed arguments into info tag', (done) => { - const texture = Texture.from(this.fontImage); - const font = BitmapFont.install(this.fontRandomArgs, texture); + const texture = Texture.from(fontImage); + const font = BitmapFont.install(fontRandomArgs, texture); expect(font).to.be.an('object'); expect(BitmapFont.available.font).to.equal(font); expect(font).to.have.property('chars'); const charA = font.chars['A'.charCodeAt(0)]; + const charATexture = charA.texture as Texture; expect(charA).to.exist; - expect(charA.texture.baseTexture.resource.source).to.equal(this.fontImage); - expect(charA.texture.frame.x).to.equal(2); - expect(charA.texture.frame.y).to.equal(2); - expect(charA.texture.frame.width).to.equal(19); - expect(charA.texture.frame.height).to.equal(20); + expect(charATexture.baseTexture.resource.source).to.equal(fontImage); + expect(charATexture.frame.x).to.equal(2); + expect(charATexture.frame.y).to.equal(2); + expect(charATexture.frame.width).to.equal(19); + expect(charATexture.frame.height).to.equal(20); done(); }); diff --git a/packages/text-bitmap/test/BitmapText.tests.ts b/packages/text-bitmap/test/BitmapText.tests.ts index 14721dc640..6979ab27a2 100644 --- a/packages/text-bitmap/test/BitmapText.tests.ts +++ b/packages/text-bitmap/test/BitmapText.tests.ts @@ -1,27 +1,37 @@ import path from 'path'; import fs from 'fs'; import { BitmapText, BitmapFont } from '@pixi/text-bitmap'; -import { Texture } from '@pixi/core'; +import { settings } from '@pixi/settings'; +import { Texture, Renderer } from '@pixi/core'; import sinon from 'sinon'; import { expect } from 'chai'; +import { Container } from '@pixi/display'; -describe('BitmapText', function () +describe('BitmapText', () => { - before(function (done) + let resources: string; + let fontXML: XMLDocument; + let fontImage: HTMLImageElement; + let font: BitmapFont; + let font2: BitmapFont; + let font2XML: XMLDocument; + let texture: Texture; + + before((done) => { - this.fontXML = null; - this.fontImage = null; - this.font = null; + fontXML = null; + fontImage = null; + font = null; - const resolveURL = (url) => path.resolve(this.resources, url); - const loadXML = (url) => new Promise((resolve) => + const resolveURL = (url: string) => path.resolve(resources, url); + const loadXML = (url: string) => new Promise((resolve) => fs.readFile(resolveURL(url), 'utf8', (err, data) => { expect(err).to.be.null; resolve((new window.DOMParser()).parseFromString(data, 'text/xml')); })); - const loadImage = (url) => new Promise((resolve) => + const loadImage = (url: string) => new Promise((resolve) => { const image = new Image(); @@ -29,46 +39,46 @@ describe('BitmapText', function () image.src = resolveURL(url); }); - this.resources = path.join(__dirname, 'resources'); + resources = path.join(__dirname, 'resources'); Promise.all([ loadXML('font.fnt'), loadXML('font-no-page.fnt'), loadImage('font.png'), ]).then(([ - fontXML, - font2XML, - fontImage, + _fontXML, + _font2XML, + _fontImage, ]) => { - this.fontXML = fontXML; - this.font2XML = font2XML; - this.fontImage = fontImage; + fontXML = _fontXML; + font2XML = _font2XML; + fontImage = _fontImage; done(); }); }); - after(function () + after(() => { - BitmapFont.uninstall(this.font.font); - BitmapFont.uninstall(this.font2.font); - this.texture.destroy(true); - this.texture = null; - this.font = null; - this.font2 = null; + BitmapFont.uninstall(font.font); + BitmapFont.uninstall(font2.font); + texture.destroy(true); + texture = null; + font = null; + font2 = null; }); - it('should register fonts from preloaded images', function () + it('should register fonts from preloaded images', () => { - this.texture = Texture.from(this.fontImage); - this.font = BitmapFont.install(this.fontXML, this.texture); - this.font2 = BitmapFont.install(this.font2XML, this.texture); - expect(this.font).instanceof(BitmapFont); - expect(this.font2).instanceof(BitmapFont); - expect(BitmapFont.available[this.font.font]).to.equal(this.font); - expect(BitmapFont.available[this.font2.font]).to.equal(this.font2); + texture = Texture.from(fontImage); + font = BitmapFont.install(fontXML, texture); + font2 = BitmapFont.install(font2XML, texture); + expect(font).instanceof(BitmapFont); + expect(font2).instanceof(BitmapFont); + expect(BitmapFont.available[font.font]).to.equal(font); + expect(BitmapFont.available[font2.font]).to.equal(font2); }); - it('should have correct children when modified', function () + it('should have correct children when modified', () => { BitmapFont.from('testFont', { fill: '#333333', @@ -99,31 +109,31 @@ describe('BitmapText', function () expect(text.children.length).to.equal(1); }); - it('should render text even if there are unsupported characters', function () + it('should render text even if there are unsupported characters', () => { const text = new BitmapText('ABCDEFG', { - fontName: this.font.font, + fontName: font.font, }); text.updateText(); - expect(text._activePagesMeshData[0].total).to.equal(4); + expect(text['_activePagesMeshData'][0].total).to.equal(4); }); - it('should support font without page reference', function () + it('should support font without page reference', () => { const text = new BitmapText('A', { - fontName: this.font2.font, + fontName: font2.font, }); text.updateText(); - expect(text.children[0].width).to.equal(19); - expect(text.children[0].height).to.equal(20); + expect((text.children[0] as Container).width).to.equal(19); + expect((text.children[0] as Container).height).to.equal(20); }); - it('should break line on space', function () + it('should break line on space', () => { const bmpText = new BitmapText('', { - fontName: this.font.font, - size: 24, + fontName: font.font, + fontSize: 24, }); bmpText.updateText(); @@ -140,11 +150,11 @@ describe('BitmapText', function () expect(bmpText.textWidth).to.be.at.most(bmpText.maxWidth); }); - it('letterSpacing should add extra space between characters', function () + it('letterSpacing should add extra space between characters', () => { const text = 'ABCD zz DCBA'; const bmpText = new BitmapText(text, { - fontName: this.font.font, + fontName: font.font, }); bmpText.updateText(); @@ -169,20 +179,67 @@ describe('BitmapText', function () } } }); - it('should not crash if text is undefined', function () + it('should not crash if text is undefined', () => { let text = new BitmapText(undefined, { - fontName: this.font.font, + fontName: font.font, }); expect(() => text.updateText()).to.not.throw(); text = new BitmapText('not undefined', { - fontName: this.font.font, + fontName: font.font, }); text.text = undefined; expect(() => text.updateText()).to.not.throw(); }); + + it('should set the text resolution to match the resolution setting when constructed time', () => + { + const text = new BitmapText('foo', { + fontName: font.font, + }); + + expect(text.resolution).to.equal(settings.RESOLUTION); + }); + + it('should update the text resolution to match the renderer resolution when being rendered to screen', () => + { + const text = new BitmapText('foo', { + fontName: font.font, + }); + + expect(text.resolution).to.equal(settings.RESOLUTION); + + const renderer = new Renderer({ resolution: 2 }); + + expect(renderer.resolution).to.equal(2); + + renderer.render(text); + + expect(text.resolution).to.equal(renderer.resolution); + + renderer.destroy(); + }); + + it('should use any manually set text resolution over the renderer resolution', () => + { + const text = new BitmapText('foo', { + fontName: font.font, + }); + + text.resolution = 3; + + expect(text.resolution).to.equal(3); + + const renderer = new Renderer({ resolution: 2 }); + + renderer.render(text); + + expect(text.resolution).to.equal(3); + + renderer.destroy(); + }); }); diff --git a/packages/text/package.json b/packages/text/package.json index cb435885e1..e9c3fe71b2 100644 --- a/packages/text/package.json +++ b/packages/text/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/text", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/text.js", "module": "dist/esm/text.js", "bundle": "dist/browser/text.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/text.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/text.js" + } + } + }, "description": "Text via the Canvas API", "author": "Mat Groves", "contributors": [ @@ -25,10 +38,10 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/core": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/settings": "6.3.0", - "@pixi/sprite": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/core": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/settings": "6.4.2", + "@pixi/sprite": "6.4.2", + "@pixi/utils": "6.4.2" } } diff --git a/packages/text/src/Text.ts b/packages/text/src/Text.ts index dcc95daa95..f185264fa4 100644 --- a/packages/text/src/Text.ts +++ b/packages/text/src/Text.ts @@ -18,11 +18,12 @@ const defaultDestroyOptions: IDestroyOptions = { baseTexture: true, }; -interface ModernContext2D extends CanvasRenderingContext2D { - // for chrome less 94 - textLetterSpacing?: number; - // for chrome greater 94 - letterSpacing?: number; +interface ModernContext2D extends CanvasRenderingContext2D +{ + // for chrome less 94 + textLetterSpacing?: number; + // for chrome greater 94 + letterSpacing?: number; } /** @@ -45,7 +46,6 @@ interface ModernContext2D extends CanvasRenderingContext2D { * ```js * let text = new PIXI.Text('This is a PixiJS text',{fontFamily : 'Arial', fontSize: 24, fill : 0xff1010, align : 'center'}); * ``` - * * @memberof PIXI */ export class Text extends Sprite @@ -76,7 +76,6 @@ export class Text extends Sprite * The resolution / device pixel ratio of the canvas. * * This is set to automatically match the renderer resolution by default, but can be overridden by setting manually. - * * @default PIXI.settings.RESOLUTION */ _resolution: number; @@ -84,28 +83,24 @@ export class Text extends Sprite /** * Private tracker for the current text. - * * @private */ protected _text: string; /** * Private tracker for the current font. - * * @private */ protected _font: string; /** * Private tracker for the current style. - * * @private */ protected _style: TextStyle; /** * Private listener to track style changes. - * * @private */ protected _styleListener: () => void; @@ -123,7 +118,7 @@ export class Text extends Sprite * @param {object|PIXI.TextStyle} [style] - The style parameters * @param canvas - The canvas element for drawing text */ - constructor(text: string, style?: Partial|TextStyle, canvas?: HTMLCanvasElement) + constructor(text?: string | number, style?: Partial | TextStyle, canvas?: HTMLCanvasElement) { let ownCanvas = false; @@ -166,7 +161,6 @@ export class Text extends Sprite * By default this is used internally to ensure the texture is correct before rendering, * but it can be used called externally, for example from this class to 'pre-generate' the texture from a piece of text, * and then shared across multiple Sprites. - * * @param respectDirty - Whether to abort updating the text if the Text isn't dirty and the function is called. */ public updateText(respectDirty: boolean): void @@ -316,7 +310,6 @@ export class Text extends Sprite /** * Render the text with letter-spacing. - * * @param text - The text to draw * @param x - Horizontal position to draw the text * @param y - Vertical position to draw the text @@ -431,15 +424,11 @@ export class Text extends Sprite texture.updateUvs(); - // Recursively updates transform of all objects from the root to this one - this._recursivePostUpdateTransform(); - this.dirty = false; } /** * Renders the object using the WebGL renderer - * * @param renderer - The renderer */ protected _render(renderer: Renderer): void @@ -455,13 +444,33 @@ export class Text extends Sprite super._render(renderer); } + /** Updates the transform on all children of this container for rendering. */ + public updateTransform(): void + { + this.updateText(true); + + super.updateTransform(); + } + + public getBounds(skipUpdate?: boolean, rect?: Rectangle): Rectangle + { + this.updateText(true); + + if (this._textureID === -1) + { + // texture was updated: recalculate transforms + skipUpdate = false; + } + + return super.getBounds(skipUpdate, rect); + } + /** * Gets the local bounds of the text object. - * * @param rect - The output rectangle. - * @return The bounds. + * @returns The bounds. */ - public getLocalBounds(rect: Rectangle): Rectangle + public getLocalBounds(rect?: Rectangle): Rectangle { this.updateText(true); @@ -471,7 +480,6 @@ export class Text extends Sprite /** Calculates the bounds of the Text as a rectangle. The bounds calculation takes the worldTransform into account. */ protected _calculateBounds(): void { - this.updateText(true); this.calculateVertices(); // if we have already done this on THIS frame. this._bounds.addQuad(this.vertexData); @@ -479,17 +487,19 @@ export class Text extends Sprite /** * Generates the fill style. Can automatically generate a gradient based on the fill style being an array - * * @param style - The style. * @param lines - The lines of text. - * @return The fill style + * @param metrics + * @returns The fill style */ - private _generateFillStyle(style: TextStyle, lines: string[], metrics: TextMetrics): string|CanvasGradient|CanvasPattern + private _generateFillStyle( + style: TextStyle, lines: string[], metrics: TextMetrics + ): string | CanvasGradient | CanvasPattern { // TODO: Can't have different types for getter and setter. The getter shouldn't have the number type as // the setter converts to string. See this thread for more details: // https://github.com/microsoft/TypeScript/issues/2521 - const fillStyle: string|string[]|CanvasGradient|CanvasPattern = style.fill as any; + const fillStyle: string | string[] | CanvasGradient | CanvasPattern = style.fill as any; if (!Array.isArray(fillStyle)) { @@ -502,7 +512,7 @@ export class Text extends Sprite // the gradient will be evenly spaced out according to how large the array is. // ['#FF0000', '#00FF00', '#0000FF'] would created stops at 0.25, 0.5 and 0.75 - let gradient: string[]|CanvasGradient; + let gradient: string[] | CanvasGradient; // a dropshadow will enlarge the canvas and result in the gradient being // generated with the incorrect dimensions @@ -631,7 +641,6 @@ export class Text extends Sprite * * Note* Unlike a Sprite, a Text object will automatically destroy its baseTexture and texture as * the majority of the time the texture will not be shared with any other Sprites. - * * @param options - Options parameter. A boolean will act as if all options * have been set to that value * @param {boolean} [options.children=false] - if set to true, all the children will have their @@ -639,7 +648,7 @@ export class Text extends Sprite * @param {boolean} [options.texture=true] - Should it destroy the current texture of the sprite as well * @param {boolean} [options.baseTexture=true] - Should it destroy the base texture of the sprite as well */ - public destroy(options?: IDestroyOptions|boolean): void + public destroy(options?: IDestroyOptions | boolean): void { if (typeof options === 'boolean') { @@ -705,7 +714,7 @@ export class Text extends Sprite * * Set up an event listener to listen for changes on the style object and mark the text as dirty. */ - get style(): TextStyle|Partial + get style(): TextStyle | Partial { // TODO: Can't have different types for getter and setter. The getter shouldn't have the ITextStyle // since the setter creates the TextStyle. See this thread for more details: @@ -713,7 +722,7 @@ export class Text extends Sprite return this._style; } - set style(style: TextStyle|Partial) + set style(style: TextStyle | Partial) { style = style || {}; @@ -736,7 +745,7 @@ export class Text extends Sprite return this._text; } - set text(text: string) + set text(text: string | number) { text = String(text === null || text === undefined ? '' : text); @@ -752,7 +761,6 @@ export class Text extends Sprite * The resolution / device pixel ratio of the canvas. * * This is set to automatically match the renderer resolution by default, but can be overridden by setting manually. - * * @default 1 */ get resolution(): number diff --git a/packages/text/src/TextMetrics.ts b/packages/text/src/TextMetrics.ts index 078ce0af25..92133ab3aa 100644 --- a/packages/text/src/TextMetrics.ts +++ b/packages/text/src/TextMetrics.ts @@ -1,6 +1,7 @@ import { TextStyle, TextStyleWhiteSpace } from './TextStyle'; -interface IFontMetrics { +interface IFontMetrics +{ ascent: number; descent: number; fontSize: number; @@ -15,7 +16,6 @@ type CharacterWidthCache = { [key: string]: number }; * let style = new PIXI.TextStyle({fontFamily : 'Arial', fontSize: 24, fill : 0xff1010, align : 'center'}) * let textMetrics = PIXI.TextMetrics.measureText('Your text', style) * ``` - * * @memberof PIXI */ export class TextMetrics @@ -46,7 +46,6 @@ export class TextMetrics /** * The font properties object from TextMetrics.measureFont. - * * @type {PIXI.IFontMetrics} */ public fontProperties: IFontMetrics; @@ -56,9 +55,10 @@ export class TextMetrics public static BASELINE_MULTIPLIER: number; public static HEIGHT_MULTIPLIER: number; + private static __canvas: HTMLCanvasElement | OffscreenCanvas; + private static __context: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D; + // TODO: These should be protected but they're initialized outside of the class. - public static _canvas: HTMLCanvasElement|OffscreenCanvas; - public static _context: CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D; public static _fonts: { [font: string]: IFontMetrics }; public static _newlines: number[]; public static _breakingSpaces: number[]; @@ -90,12 +90,11 @@ export class TextMetrics /** * Measures the supplied string of text and returns a Rectangle. - * * @param text - The text to measure. * @param style - The text style to use for measuring * @param wordWrap - Override for if word-wrap should be applied to the text. * @param canvas - optional specification of the canvas to use for measuring. - * @return Measured width and height of the text. + * @returns Measured width and height of the text. */ public static measureText( text: string, @@ -164,11 +163,10 @@ export class TextMetrics /** * Applies newlines to a string to have it optimally fit into the horizontal * bounds set by the Text object's wordWrapWidth property. - * * @param text - String to apply word wrapping to * @param style - the style to use when wrapping * @param canvas - optional specification of the canvas to use for measuring. - * @return New string with new lines applied where required + * @returns New string with new lines applied where required */ private static wordWrap( text: string, @@ -363,10 +361,9 @@ export class TextMetrics /** * Convienience function for logging each line added during the wordWrap method. - * * @param line - The line of text to add * @param newLine - Add new line character to end - * @return A formatted line + * @returns A formatted line */ private static addLine(line: string, newLine = true): string { @@ -379,15 +376,14 @@ export class TextMetrics /** * Gets & sets the widths of calculated characters in a cache object - * * @param key - The key * @param letterSpacing - The letter spacing * @param cache - The cache * @param context - The canvas context - * @return The from cache. + * @returns The from cache. */ private static getFromCache(key: string, letterSpacing: number, cache: CharacterWidthCache, - context: CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D): number + context: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): number { let width = cache[key]; @@ -404,9 +400,8 @@ export class TextMetrics /** * Determines whether we should collapse breaking spaces. - * * @param whiteSpace - The TextStyle property whiteSpace - * @return Should collapse + * @returns Should collapse */ private static collapseSpaces(whiteSpace: TextStyleWhiteSpace): boolean { @@ -415,9 +410,8 @@ export class TextMetrics /** * Determines whether we should collapse newLine chars. - * * @param whiteSpace - The white space - * @return should collapse + * @returns should collapse */ private static collapseNewlines(whiteSpace: TextStyleWhiteSpace): boolean { @@ -426,9 +420,8 @@ export class TextMetrics /** * Trims breaking whitespaces from string. - * * @param text - The text - * @return Trimmed string + * @returns Trimmed string */ private static trimRight(text: string): string { @@ -454,9 +447,8 @@ export class TextMetrics /** * Determines if char is a newline. - * * @param char - The character - * @return True if newline, False otherwise. + * @returns True if newline, False otherwise. */ private static isNewline(char: string): boolean { @@ -474,10 +466,9 @@ export class TextMetrics * It allows one to determine whether char should be a breaking whitespace * For example certain characters in CJK langs or numbers. * It must return a boolean. - * - * @param char - The character - * @param [nextChar] - The next character - * @return True if whitespace, False otherwise. + * @param char - The character + * @param [_nextChar] - The next character + * @returns True if whitespace, False otherwise. */ static isBreakingSpace(char: string, _nextChar?: string): boolean { @@ -491,9 +482,8 @@ export class TextMetrics /** * Splits a string into words, breaking-spaces and newLine characters - * * @param text - The text - * @return A tokenized array + * @returns A tokenized array */ private static tokenize(text: string): string[] { @@ -540,10 +530,9 @@ export class TextMetrics * It allows one to customise which words should break * Examples are if the token is CJK or numbers. * It must return a boolean. - * - * @param token - The token + * @param _token - The token * @param breakWords - The style attr break words - * @return Whether to break word or not + * @returns Whether to break word or not */ static canBreakWords(_token: string, breakWords: boolean): boolean { @@ -557,13 +546,12 @@ export class TextMetrics * should be broken by newlines * For example certain characters in CJK langs or numbers. * It must return a boolean. - * - * @param char - The character - * @param nextChar - The next character - * @param token - The token/word the characters are from - * @param index - The index in the token of the char - * @param breakWords - The style attr break words - * @return whether to break word or not + * @param _char - The character + * @param _nextChar - The next character + * @param _token - The token/word the characters are from + * @param _index - The index in the token of the char + * @param _breakWords - The style attr break words + * @returns whether to break word or not */ static canBreakChars(_char: string, _nextChar: string, _token: string, _index: number, _breakWords: boolean): boolean @@ -577,13 +565,11 @@ export class TextMetrics * It is called when a token (usually a word) has to be split into separate pieces * in order to determine the point to break a word. * It must return an array of characters. - * * @example * // Correctly splits emojis, eg "🤪🤪" will result in two element array, each with one emoji. * TextMetrics.wordWrapSplit = (token) => [...token]; - * * @param token - The token to split - * @return The characters of the token + * @returns The characters of the token */ static wordWrapSplit(token: string): string[] { @@ -592,9 +578,8 @@ export class TextMetrics /** * Calculates the ascent, descent and fontSize of a given font-style - * * @param font - String representing the style of the font - * @return Font properties object + * @returns Font properties object */ public static measureFont(font: string): IFontMetrics { @@ -700,7 +685,6 @@ export class TextMetrics /** * Clear font metrics in metrics cache. - * * @param {string} [font] - font name. If font name not set then clear cache for all fonts. */ public static clearMetrics(font = ''): void @@ -714,65 +698,73 @@ export class TextMetrics TextMetrics._fonts = {}; } } -} -/** - * Internal return object for {@link PIXI.TextMetrics.measureFont `TextMetrics.measureFont`}. - * - * @typedef {object} FontMetrics - * @property {number} ascent - The ascent distance - * @property {number} descent - The descent distance - * @property {number} fontSize - Font size from ascent to descent - * @memberof PIXI.TextMetrics - * @private - */ - -const canvas = ((): HTMLCanvasElement|OffscreenCanvas => -{ - try + /** + * Cached canvas element for measuring text + * TODO: this should be private, but isn't because of backward compat, will fix later. + * @ignore + */ + public static get _canvas(): HTMLCanvasElement | OffscreenCanvas { - // OffscreenCanvas2D measureText can be up to 40% faster. - const c = new OffscreenCanvas(0, 0); - const context = c.getContext('2d'); - - if (context && context.measureText) + if (!TextMetrics.__canvas) { - return c; + let canvas: HTMLCanvasElement | OffscreenCanvas; + + try + { + // OffscreenCanvas2D measureText can be up to 40% faster. + const c = new OffscreenCanvas(0, 0); + const context = c.getContext('2d'); + + if (context && context.measureText) + { + TextMetrics.__canvas = c; + + return c; + } + + canvas = document.createElement('canvas'); + } + catch (ex) + { + canvas = document.createElement('canvas'); + } + canvas.width = canvas.height = 10; + TextMetrics.__canvas = canvas; } - return document.createElement('canvas'); + return TextMetrics.__canvas; } - catch (ex) - { - return document.createElement('canvas'); - } -})(); -canvas.width = canvas.height = 10; + /** + * TODO: this should be private, but isn't because of backward compat, will fix later. + * @ignore + */ + public static get _context(): CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D + { + if (!TextMetrics.__context) + { + TextMetrics.__context = TextMetrics._canvas.getContext('2d'); + } -/** - * Cached canvas element for measuring text - * - * @memberof PIXI.TextMetrics - * @type {HTMLCanvasElement} - * @private - */ -TextMetrics._canvas = canvas; + return TextMetrics.__context; + } +} /** - * Cache for context to use. - * + * Internal return object for {@link PIXI.TextMetrics.measureFont `TextMetrics.measureFont`}. + * @typedef {object} FontMetrics + * @property {number} ascent - The ascent distance + * @property {number} descent - The descent distance + * @property {number} fontSize - Font size from ascent to descent * @memberof PIXI.TextMetrics - * @type {CanvasRenderingContext2D} * @private */ -TextMetrics._context = canvas.getContext('2d'); /** * Cache of {@see PIXI.TextMetrics.FontMetrics} objects. - * * @memberof PIXI.TextMetrics - * @type {Object} + * @type {object} * @private */ TextMetrics._fonts = {}; @@ -780,7 +772,6 @@ TextMetrics._fonts = {}; /** * String used for calculate font metrics. * These characters are all tall to help calculate the height required for text. - * * @static * @memberof PIXI.TextMetrics * @name METRICS_STRING @@ -791,7 +782,6 @@ TextMetrics.METRICS_STRING = '|ÉqÅ'; /** * Baseline symbol for calculate font metrics. - * * @static * @memberof PIXI.TextMetrics * @name BASELINE_SYMBOL @@ -802,7 +792,6 @@ TextMetrics.BASELINE_SYMBOL = 'M'; /** * Baseline multiplier for calculate font metrics. - * * @static * @memberof PIXI.TextMetrics * @name BASELINE_MULTIPLIER @@ -813,7 +802,6 @@ TextMetrics.BASELINE_MULTIPLIER = 1.4; /** * Height multiplier for setting height of canvas to calculate font metrics. - * * @static * @memberof PIXI.TextMetrics * @name HEIGHT_MULTIPLIER @@ -824,7 +812,6 @@ TextMetrics.HEIGHT_MULTIPLIER = 2.0; /** * Cache of new line chars. - * * @memberof PIXI.TextMetrics * @type {number[]} * @private @@ -836,7 +823,6 @@ TextMetrics._newlines = [ /** * Cache of breaking spaces. - * * @memberof PIXI.TextMetrics * @type {number[]} * @private @@ -860,7 +846,6 @@ TextMetrics._breakingSpaces = [ /** * A number, or a string containing a number. - * * @memberof PIXI * @typedef {object} IFontMetrics * @property {number} ascent - Font ascent diff --git a/packages/text/src/const.ts b/packages/text/src/const.ts index 028a90055f..a842a43736 100644 --- a/packages/text/src/const.ts +++ b/packages/text/src/const.ts @@ -1,6 +1,5 @@ /** * Constants that define the type of gradient on text. - * * @static * @constant * @name TEXT_GRADIENT @@ -9,7 +8,9 @@ * @property {number} LINEAR_VERTICAL Vertical gradient * @property {number} LINEAR_HORIZONTAL Linear gradient */ -export enum TEXT_GRADIENT { +export enum TEXT_GRADIENT +// eslint-disable-next-line @typescript-eslint/indent +{ LINEAR_VERTICAL = 0, LINEAR_HORIZONTAL = 1 } diff --git a/packages/text/test/Text.tests.ts b/packages/text/test/Text.tests.ts index 3521df0663..cba5cdbf31 100644 --- a/packages/text/test/Text.tests.ts +++ b/packages/text/test/Text.tests.ts @@ -4,16 +4,17 @@ import { skipHello } from '@pixi/utils'; import { settings } from '@pixi/settings'; import { Renderer, BatchRenderer } from '@pixi/core'; import { expect } from 'chai'; +import { IDestroyOptions } from '@pixi/display'; skipHello(); Renderer.registerPlugin('batch', BatchRenderer); -describe('Text', function () +describe('Text', () => { - describe('properties', function () + describe('properties', () => { - it('should modify the height of the object when setting height', function () + it('should modify the height of the object when setting height', () => { const text = new Text('foo'); @@ -22,7 +23,7 @@ describe('Text', function () expect(text.height).to.equal(300); }); - it('should modify the width of the object when setting width', function () + it('should modify the width of the object when setting width', () => { const text = new Text('foo'); @@ -31,14 +32,14 @@ describe('Text', function () expect(text.width).to.equal(300); }); - it('should set the text resolution to match the resolution setting when constructed time', function () + it('should set the text resolution to match the resolution setting when constructed time', () => { const text = new Text('foo'); expect(text.resolution).to.equal(settings.RESOLUTION); }); - it('should update the text resolution to match the renderer resolution when being rendered to screen', function () + it('should update the text resolution to match the renderer resolution when being rendered to screen', () => { const text = new Text('foo'); @@ -55,7 +56,7 @@ describe('Text', function () renderer.destroy(); }); - it('should use any manually set text resolution over the renderer resolution', function () + it('should use any manually set text resolution over the renderer resolution', () => { const text = new Text('foo'); @@ -73,9 +74,9 @@ describe('Text', function () }); }); - describe('destroy', function () + describe('destroy', () => { - it('should now clear canvas size on imported canvas', function () + it('should now clear canvas size on imported canvas', () => { const canvas = document.createElement('canvas'); const text = new Text('blah', {}, canvas); @@ -87,7 +88,7 @@ describe('Text', function () expect(canvas.height).to.equal(height); }); - it('should clear size on owned canvas during destroy', function () + it('should clear size on owned canvas during destroy', () => { const text = new Text('blah', {}); const { canvas } = text; @@ -98,7 +99,7 @@ describe('Text', function () expect(canvas.height).to.equal(0); }); - it('should call through to Sprite.destroy', function () + it('should call through to Sprite.destroy', () => { const text = new Text('foo'); @@ -107,7 +108,7 @@ describe('Text', function () expect(text.anchor).to.equal(null); }); - it('should set context to null', function () + it('should set context to null', () => { const text = new Text('foo'); @@ -116,7 +117,7 @@ describe('Text', function () expect(text.style).to.equal(null); }); - it('should destroy children if children flag is set', function () + it('should destroy children if children flag is set', () => { const text = new Text('foo'); const child = new Sprite(); @@ -127,7 +128,7 @@ describe('Text', function () expect(child.transform).to.equal(null); }); - it('should accept options correctly', function () + it('should accept options correctly', () => { const text = new Text('foo'); const child = new Sprite(); @@ -138,13 +139,13 @@ describe('Text', function () expect(child.transform).to.equal(null); }); - it('should pass opts on to children if children flag is set', function () + it('should pass opts on to children if children flag is set', () => { const text = new Text('foo'); const child = new Sprite(); - let childDestroyOpts; + let childDestroyOpts: IDestroyOptions | boolean; - child.destroy = function (opts) + child.destroy = (opts) => { childDestroyOpts = opts; }; @@ -155,55 +156,55 @@ describe('Text', function () }); }); - describe('text', function () + describe('text', () => { - it('should convert numbers into strings', function () + it('should convert numbers into strings', () => { const text = new Text(2); expect(text.text).to.equal('2'); }); - it('should not change 0 to \'\'', function () + it('should not change 0 to \'\'', () => { const text = new Text(0); expect(text.text).to.equal('0'); }); - it('should prevent setting null', function () + it('should prevent setting null', () => { const text = new Text(null); expect(text.text).to.equal(''); }); - it('should prevent setting undefined', function () + it('should prevent setting undefined', () => { const text = new Text(); expect(text.text).to.equal(''); }); - it('should trim an empty string', function () + it('should trim an empty string', () => { const text = new Text('', { trim: true }); expect(text.text).to.equal(''); }); - it('should allow setting \'\' for v5', function () + it('should allow setting \'\' for v5', () => { const text = new Text(''); expect(text.text).to.equal(''); }); - it('should keep at least 1 pixel for canvas width and height', function () + it('should keep at least 1 pixel for canvas width and height', () => { const text = new Text(''); - text.updateText(); + text.updateText(undefined); expect(text.canvas.width).to.be.above(1); expect(text.canvas.height).to.be.above(1); diff --git a/packages/text/test/TextMetrics.tests.ts b/packages/text/test/TextMetrics.tests.ts index 25dbf9885f..8eb171ddf6 100644 --- a/packages/text/test/TextMetrics.tests.ts +++ b/packages/text/test/TextMetrics.tests.ts @@ -1,4 +1,4 @@ -import { TextMetrics, TextStyle } from '@pixi/text'; +import { ITextStyle, TextMetrics, TextStyle } from '@pixi/text'; import { expect } from 'chai'; /** @@ -44,7 +44,7 @@ const breakingSpaces = [ '\u3000', ]; -describe('TextMetrics', function () +describe('TextMetrics', () => { const defaultStyle = { breakWords: true, @@ -52,18 +52,18 @@ describe('TextMetrics', function () fontSize: 20, fontStyle: 'italic', fontVariant: 'normal', - fontWeight: 900, + fontWeight: '900', wordWrap: true, wordWrapWidth: 200, letterSpacing: 4, - }; + } as Partial; - describe('wordWrap without breakWords', function () + describe('wordWrap without breakWords', () => { - it('width should not be greater than wordWrapWidth with longText', function () + it('width should not be greater than wordWrapWidth with longText', () => { // On Windows 'exercitationem' renders to about 217px, bigger wrap width required for this test to be valid on every platform - const style = Object.assign({}, defaultStyle, { wordWrapWidth: 220, breakWords: false }); + const style = Object.assign({}, defaultStyle, { wordWrapWidth: 220, breakWords: false }) as Partial; const metrics = TextMetrics.measureText(longText, new TextStyle(style)); @@ -73,11 +73,11 @@ describe('TextMetrics', function () { expect(line).to.not.contain(' ', 'should not have multiple spaces in a row'); expect(line[0]).to.not.equal(' ', 'should not have space at the start'); - expect(line[line - 1]).to.not.equal(' ', 'should not have space at the end'); + expect(line[line.length - 1]).to.not.equal(' ', 'should not have space at the end'); }); }); - it('width should be greater than wordWrapWidth with breakingWordText', function () + it('width should be greater than wordWrapWidth with breakingWordText', () => { const style = Object.assign({}, defaultStyle, { breakWords: false }); @@ -88,11 +88,11 @@ describe('TextMetrics', function () metrics.lines.forEach((line) => { expect(line[0]).to.not.equal(' ', 'should not have space at the start'); - expect(line[line - 1]).to.not.equal(' ', 'should not have space at the end'); + expect(line[line.length - 1]).to.not.equal(' ', 'should not have space at the end'); }); }); - it('width should be within a character width from wordWrapWidth with fillText', function () + it('width should be within a character width from wordWrapWidth with fillText', () => { const charWidth = 4; // it should fill the line to at lease width -4 @@ -106,11 +106,11 @@ describe('TextMetrics', function () metrics.lines.forEach((line) => { expect(line[0]).to.not.equal(' ', 'should not have space at the start'); - expect(line[line - 1]).to.not.equal(' ', 'should not have space at the end'); + expect(line[line.length - 1]).to.not.equal(' ', 'should not have space at the end'); }); }); - it('width should be greater than wordWrapWidth and should format correct spaces', function () + it('width should be greater than wordWrapWidth and should format correct spaces', () => { const style = Object.assign({}, defaultStyle, { breakWords: false }); @@ -130,11 +130,11 @@ describe('TextMetrics', function () { expect(metrics.lines[1][0]).to.not.equal(' ', 'all lines except 1 & 5 should not have space at the start'); } - expect(line[line - 1]).to.not.equal(' ', 'no lines should have a space at the end'); + expect(line[line.length - 1]).to.not.equal(' ', 'no lines should have a space at the end'); }); }); - it('should be able to override wordWrap to false in measureText', function () + it('should be able to override wordWrap to false in measureText', () => { const metrics = TextMetrics.measureText(longText, new TextStyle(defaultStyle), false); @@ -142,9 +142,9 @@ describe('TextMetrics', function () }); }); - describe('wordWrap with breakWords', function () + describe('wordWrap with breakWords', () => { - it('width should not be greater than wordWrapWidth with longText', function () + it('width should not be greater than wordWrapWidth with longText', () => { const style = Object.assign({}, defaultStyle, { breakWords: true }); @@ -155,11 +155,11 @@ describe('TextMetrics', function () metrics.lines.forEach((line) => { expect(line[0]).to.not.equal(' ', 'should not have space at the start'); - expect(line[line - 1]).to.not.equal(' ', 'should not have space at the end'); + expect(line[line.length - 1]).to.not.equal(' ', 'should not have space at the end'); }); }); - it('width should not be greater than wordWrapWidth with breakingWordAtStartText', function () + it('width should not be greater than wordWrapWidth with breakingWordAtStartText', () => { const style = Object.assign({}, defaultStyle, { breakWords: true }); @@ -170,11 +170,11 @@ describe('TextMetrics', function () metrics.lines.forEach((line) => { expect(line[0]).to.not.equal(' ', 'should not have space at the start'); - expect(line[line - 1]).to.not.equal(' ', 'should not have space at the end'); + expect(line[line.length - 1]).to.not.equal(' ', 'should not have space at the end'); }); }); - it('width should be within a character width from wordWrapWidth with fillText', function () + it('width should be within a character width from wordWrapWidth with fillText', () => { const charWidth = 4; // it should fill the line to at lease width -4 @@ -188,11 +188,11 @@ describe('TextMetrics', function () metrics.lines.forEach((line) => { expect(line[0]).to.not.equal(' ', 'should not have space at the start'); - expect(line[line - 1]).to.not.equal(' ', 'should not have space at the end'); + expect(line[line.length - 1]).to.not.equal(' ', 'should not have space at the end'); }); }); - it('no words or characters should lost or changed', function () + it('no words or characters should lost or changed', () => { const style = Object.assign({}, defaultStyle, { breakWords: true }); @@ -203,7 +203,7 @@ describe('TextMetrics', function () expect(lines).to.equal(intergityText, 'should have the same chars as the original text'); }); - it('width should not be greater than wordWrapWidth and should format correct spaces', function () + it('width should not be greater than wordWrapWidth and should format correct spaces', () => { const style = Object.assign({}, defaultStyle, { breakWords: true }); @@ -223,16 +223,16 @@ describe('TextMetrics', function () { expect(metrics.lines[1][0]).to.not.equal(' ', 'all lines except 1 & 5 should not have space at the start'); } - expect(line[line - 1]).to.not.equal(' ', 'no lines should have a space at the end'); + expect(line[line.length - 1]).to.not.equal(' ', 'no lines should have a space at the end'); }); }); }); - describe('wordWrap misc', function () + describe('wordWrap misc', () => { const originalSplit = TextMetrics.wordWrapSplit; - afterEach(function () + afterEach(() => { TextMetrics.wordWrapSplit = originalSplit; }); @@ -249,16 +249,16 @@ describe('TextMetrics', function () return ['s', 'p', 'l', 'i', 't']; }; - const brokenText = TextMetrics.wordWrap('testword1234567890abcd!', new TextStyle(defaultStyle)); + const brokenText = TextMetrics['wordWrap']('testword1234567890abcd!', new TextStyle(defaultStyle)); expect(wasSplitCalled).to.equal(true); expect(brokenText).to.equal('split'); }); }); - describe('whiteSpace `normal` without breakWords', function () + describe('whiteSpace `normal` without breakWords', () => { - it('multiple spaces should be collapsed to 1 and but not newlines', function () + it('multiple spaces should be collapsed to 1 and but not newlines', () => { const style = Object.assign({}, defaultStyle, { breakWords: false, whiteSpace: 'normal' }); @@ -270,10 +270,11 @@ describe('TextMetrics', function () { expect(line).to.not.contain(' ', 'should not have multiple spaces in a row'); expect(line[0]).to.not.equal(' ', 'all lines should not have space at the start'); - expect(line[line - 1]).to.not.equal(' ', 'no lines should have a space at the end'); + expect(line[line.length - 1]).to.not.equal(' ', 'no lines should have a space at the end'); }); }); + // eslint-disable-next-line func-names it('text is wrapped in a platform-specific way', function () { if (process.platform === 'win32') @@ -295,9 +296,9 @@ describe('TextMetrics', function () }); }); - describe('whiteSpace `pre-line` without breakWords', function () + describe('whiteSpace `pre-line` without breakWords', () => { - it('multiple spaces should be collapsed to 1 but not newlines', function () + it('multiple spaces should be collapsed to 1 but not newlines', () => { const style = Object.assign({}, defaultStyle, { breakWords: false, whiteSpace: 'pre-line' }); @@ -314,14 +315,14 @@ describe('TextMetrics', function () metrics.lines.forEach((line) => { expect(line[0]).to.not.equal(' ', 'all lines should not have space at the start'); - expect(line[line - 1]).to.not.equal(' ', 'no lines should have a space at the end'); + expect(line[line.length - 1]).to.not.equal(' ', 'no lines should have a space at the end'); }); }); }); - describe('whiteSpace `normal` with breakWords', function () + describe('whiteSpace `normal` with breakWords', () => { - it('multiple spaces should be collapsed to 1 and but not newlines', function () + it('multiple spaces should be collapsed to 1 and but not newlines', () => { const style = Object.assign({}, defaultStyle, { breakWords: true, whiteSpace: 'normal' }); @@ -333,10 +334,11 @@ describe('TextMetrics', function () { expect(line).to.not.contain(' ', 'should not have multiple spaces in a row'); expect(line[0]).to.not.equal(' ', 'all lines should not have space at the start'); - expect(line[line - 1]).to.not.equal(' ', 'no lines should have a space at the end'); + expect(line[line.length - 1]).to.not.equal(' ', 'no lines should have a space at the end'); }); }); + // eslint-disable-next-line func-names it('text is wrapped in a platform-specific way', function () { if (process.platform === 'win32') @@ -358,9 +360,9 @@ describe('TextMetrics', function () }); }); - describe('whiteSpace `pre-line` with breakWords', function () + describe('whiteSpace `pre-line` with breakWords', () => { - it('multiple spaces should be collapsed to 1 but not newlines', function () + it('multiple spaces should be collapsed to 1 but not newlines', () => { const style = Object.assign({}, defaultStyle, { breakWords: true, whiteSpace: 'pre-line' }); @@ -377,83 +379,85 @@ describe('TextMetrics', function () metrics.lines.forEach((line) => { expect(line[0]).to.not.equal(' ', 'all lines should not have space at the start'); - expect(line[line - 1]).to.not.equal(' ', 'no lines should have a space at the end'); + expect(line[line.length - 1]).to.not.equal(' ', 'no lines should have a space at the end'); }); }); }); - describe('trimRight', function () + describe('trimRight', () => { - it('string with no whitespaces to trim', function () + it('string with no whitespaces to trim', () => { - const text = TextMetrics.trimRight('remove white spaces to the right'); + const text = TextMetrics['trimRight']('remove white spaces to the right'); expect(text).to.equal('remove white spaces to the right'); }); - it('string with whitespaces to trim', function () + it('string with whitespaces to trim', () => { - const text = TextMetrics.trimRight('remove white spaces to the right '); + const text = TextMetrics['trimRight']('remove white spaces to the right '); expect(text).to.equal('remove white spaces to the right'); }); - it('string with strange unicode whitespaces to trim', function () + it('string with strange unicode whitespaces to trim', () => { - const text = TextMetrics.trimRight('remove white spaces to the right\u0009\u0020\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2008\u2009\u200A\u205F\u3000'); + const text = TextMetrics['trimRight']('remove white spaces to the right\u0009\u0020\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2008\u2009\u200A\u205F\u3000'); expect(text).to.equal('remove white spaces to the right'); }); - it('empty string', function () + it('empty string', () => { - const text = TextMetrics.trimRight(''); + const text = TextMetrics['trimRight'](''); expect(text).to.equal(''); }); - it('non-string input', function () + it('non-string input', () => { - const text = TextMetrics.trimRight({}); + // @ts-expect-error - should return false on non-string input + const text = TextMetrics['trimRight']({}); expect(text).to.equal(''); }); }); - describe('isNewline', function () + describe('isNewline', () => { - it('line feed', function () + it('line feed', () => { - const bool = TextMetrics.isNewline('\n'); + const bool = TextMetrics['isNewline']('\n'); expect(bool).to.equal(true); }); - it('carriage return', function () + it('carriage return', () => { - const bool = TextMetrics.isNewline('\r'); + const bool = TextMetrics['isNewline']('\r'); expect(bool).to.equal(true); }); - it('newline char', function () + it('newline char', () => { - const bool = TextMetrics.isNewline('A'); + const bool = TextMetrics['isNewline']('A'); expect(bool).to.equal(false); }); - it('non string', function () + it('non string', () => { - const bool = TextMetrics.isNewline({}); + // @ts-expect-error - should return false on non-string input + const bool = TextMetrics['isNewline']({}); expect(bool).to.equal(false); }); }); - describe('isBreakingSpace', function () + describe('isBreakingSpace', () => { - it('legit breaking spaces', function () + it('legit breaking spaces', () => { breakingSpaces.forEach((char) => { @@ -463,7 +467,7 @@ describe('TextMetrics', function () }); }); - it('non breaking spaces', function () + it('non breaking spaces', () => { nonBreakingSpaces.forEach((char) => { @@ -473,28 +477,29 @@ describe('TextMetrics', function () }); }); - it('newline char', function () + it('newline char', () => { const bool = TextMetrics.isBreakingSpace('A'); expect(bool).to.equal(false); }); - it('non string', function () + it('non string', () => { + // @ts-expect-error - should return false on non-string input const bool = TextMetrics.isBreakingSpace({}); expect(bool).to.equal(false); }); - it('overridable breaking spaces', function () + it('overridable breaking spaces', () => { const reg = /[あいうえお]/; const original = TextMetrics.isBreakingSpace; // override breakingSpace - TextMetrics.isBreakingSpace = function (char, nextChar) + TextMetrics.isBreakingSpace = (char, nextChar) => { const isBreakingSpace = breakingSpaces.includes(char); @@ -518,11 +523,11 @@ describe('TextMetrics', function () }); }); - describe('tokenize', function () + describe('tokenize', () => { - it('full example', function () + it('full example', () => { - const arr = TextMetrics.tokenize(spaceNewLineText); + const arr = TextMetrics['tokenize'](spaceNewLineText); expect(arr).to.be.an('array'); expect(arr.length).to.equal(146); @@ -530,133 +535,138 @@ describe('TextMetrics', function () expect(arr).to.not.contain(null); }); - it('empty string', function () + it('empty string', () => { - const arr = TextMetrics.tokenize(''); + const arr = TextMetrics['tokenize'](''); expect(arr).to.be.an('array'); expect(arr.length).to.equal(0); }); - it('single char', function () + it('single char', () => { - const arr = TextMetrics.tokenize('A'); + const arr = TextMetrics['tokenize']('A'); expect(arr).to.be.an('array'); expect(arr.length).to.equal(1); }); - it('newline char', function () + it('newline char', () => { - const arr = TextMetrics.tokenize('\n'); + const arr = TextMetrics['tokenize']('\n'); expect(arr).to.be.an('array'); expect(arr.length).to.equal(1); }); - it('breakingSpaces', function () + it('breakingSpaces', () => { - const arr = TextMetrics.tokenize(breakingSpaces.join('')); + const arr = TextMetrics['tokenize'](breakingSpaces.join('')); expect(arr).to.be.an('array'); expect(arr.length).to.equal(breakingSpaces.length); }); - it('non string', function () + it('non string', () => { - const arr = TextMetrics.tokenize({}); + // @ts-expect-error - should return false on non-string input + const arr = TextMetrics['tokenize']({}); expect(arr).to.be.an('array'); expect(arr.length).to.equal(0); }); }); - describe('collapseSpaces', function () + describe('collapseSpaces', () => { - it('pre', function () + it('pre', () => { - const bool = TextMetrics.collapseSpaces('pre'); + const bool = TextMetrics['collapseSpaces']('pre'); expect(bool).to.equal(false); }); - it('normal', function () + it('normal', () => { - const bool = TextMetrics.collapseSpaces('normal'); + const bool = TextMetrics['collapseSpaces']('normal'); expect(bool).to.equal(true); }); - it('pre-line', function () + it('pre-line', () => { - const bool = TextMetrics.collapseSpaces('pre-line'); + const bool = TextMetrics['collapseSpaces']('pre-line'); expect(bool).to.equal(true); }); - it('non matching string', function () + it('non matching string', () => { - const bool = TextMetrics.collapseSpaces('bull'); + // @ts-expect-error - should return false on non matching string + const bool = TextMetrics['collapseSpaces']('bull'); expect(bool).to.equal(false); }); - it('non string', function () + it('non string', () => { - const bool = TextMetrics.collapseSpaces({}); + // @ts-expect-error - should return false on non-string input + const bool = TextMetrics['collapseSpaces']({}); expect(bool).to.equal(false); }); }); - describe('collapseNewlines', function () + describe('collapseNewlines', () => { - it('pre', function () + it('pre', () => { - const bool = TextMetrics.collapseNewlines('pre'); + const bool = TextMetrics['collapseNewlines']('pre'); expect(bool).to.equal(false); }); - it('normal', function () + it('normal', () => { - const bool = TextMetrics.collapseNewlines('normal'); + const bool = TextMetrics['collapseNewlines']('normal'); expect(bool).to.equal(true); }); - it('pre-line', function () + it('pre-line', () => { - const bool = TextMetrics.collapseNewlines('pre-line'); + const bool = TextMetrics['collapseNewlines']('pre-line'); expect(bool).to.equal(false); }); - it('non matching string', function () + it('non matching string', () => { - const bool = TextMetrics.collapseNewlines('bull'); + // @ts-expect-error - should return false on non matching string + const bool = TextMetrics['collapseNewlines']('bull'); expect(bool).to.equal(false); }); - it('non string', function () + it('non string', () => { - const bool = TextMetrics.collapseNewlines({}); + // @ts-expect-error - should return false on non-string input + const bool = TextMetrics['collapseNewlines']({}); expect(bool).to.equal(false); }); }); - describe('canBreakWords', function () + describe('canBreakWords', () => { - it('breakWords: true', function () + it('breakWords: true', () => { const bool = TextMetrics.canBreakWords('text', true); expect(bool).to.equal(true); }); - it('breakWords: false', function () + it('breakWords: false', () => { const bool = TextMetrics.canBreakWords('text', false); @@ -664,23 +674,24 @@ describe('TextMetrics', function () }); }); - describe('canBreakChars', function () + describe('canBreakChars', () => { - it('should always return true', function () + it('should always return true', () => { - const bool = TextMetrics.canBreakChars(); + // @ts-expect-error - function is meant to be overridden + const bool = TextMetrics['canBreakChars'](); expect(bool).to.equal(true); }); - it('should prevent breaking for all numbers', function () + it('should prevent breaking for all numbers', () => { const style = new TextStyle({ fontFamily: 'Arial', fontSize: 26, fontStyle: 'italic', fontVariant: 'normal', - fontWeight: 900, + fontWeight: '900', wordWrap: true, wordWrapWidth: 300, letterSpacing: 4, @@ -693,16 +704,12 @@ describe('TextMetrics', function () const str = '-------0000,1111,9999------'; const reg = /^\d+$/; - TextMetrics.canBreakWords = function () - { - return true; - }; + TextMetrics.canBreakWords = () => + true; // override breakChars - TextMetrics.canBreakChars = function (char, nextChar) - { - return !(char.match(reg) && nextChar.match(reg)); - }; + TextMetrics.canBreakChars = (char, nextChar) => + !(char.match(reg) && nextChar.match(reg)); const metrics = TextMetrics.measureText(str, style); diff --git a/packages/text/test/TextStyle.tests.ts b/packages/text/test/TextStyle.tests.ts index 975c0fc8a9..a88350a040 100644 --- a/packages/text/test/TextStyle.tests.ts +++ b/packages/text/test/TextStyle.tests.ts @@ -1,9 +1,9 @@ import { TextStyle } from '@pixi/text'; import { expect } from 'chai'; -describe('TextStyle', function () +describe('TextStyle', () => { - it('reset reverts style to default', function () + it('reset reverts style to default', () => { const textStyle = new TextStyle(); const defaultFontSize = textStyle.fontSize; @@ -15,7 +15,7 @@ describe('TextStyle', function () expect(textStyle.fontSize).to.equal(defaultFontSize); }); - it('should clone correctly', function () + it('should clone correctly', () => { const textStyle = new TextStyle({ fontSize: 1000 }); @@ -25,7 +25,7 @@ describe('TextStyle', function () expect(clonedTextStyle.fontSize).to.equal(textStyle.fontSize); }); - it('should assume pixel fonts', function () + it('should assume pixel fonts', () => { const style = new TextStyle({ fontSize: 72 }); const font = style.toFontString(); @@ -34,7 +34,7 @@ describe('TextStyle', function () expect(font).to.have.string(' 72px '); }); - it('should handle multiple fonts as array', function () + it('should handle multiple fonts as array', () => { const style = new TextStyle({ fontFamily: ['Georgia', 'Arial', 'sans-serif'], @@ -43,7 +43,7 @@ describe('TextStyle', function () expect(style.toFontString()).to.have.string('"Georgia","Arial",sans-serif'); }); - it('should handle multiple fonts as string', function () + it('should handle multiple fonts as string', () => { const style = new TextStyle({ fontFamily: 'Georgia, "Arial", sans-serif', @@ -52,7 +52,7 @@ describe('TextStyle', function () expect(style.toFontString()).to.have.string('"Georgia","Arial",sans-serif'); }); - it('should not shared array / object references between different instances', function () + it('should not shared array / object references between different instances', () => { const defaultStyle = new TextStyle(); const style = new TextStyle(); @@ -62,7 +62,7 @@ describe('TextStyle', function () expect(defaultStyle.fillGradientStops.length).to.not.equal(style.fillGradientStops.length); }); - it('should not quote generic font families when calling toFontString', function () + it('should not quote generic font families when calling toFontString', () => { // Should match the list in TextStyle const genericFontFamilies = [ diff --git a/packages/ticker/package.json b/packages/ticker/package.json index e901314f6c..c81734db1a 100644 --- a/packages/ticker/package.json +++ b/packages/ticker/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/ticker", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/ticker.js", "module": "dist/esm/ticker.js", "bundle": "dist/browser/ticker.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/ticker.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/ticker.js" + } + } + }, "description": "Tickers are control the timings within PixiJS", "author": "Mat Groves", "contributors": [ @@ -25,6 +38,6 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/settings": "6.3.0" + "@pixi/settings": "6.4.2" } } diff --git a/packages/ticker/src/Ticker.ts b/packages/ticker/src/Ticker.ts index 56ec93b7a8..84dc458eb5 100644 --- a/packages/ticker/src/Ticker.ts +++ b/packages/ticker/src/Ticker.ts @@ -9,7 +9,6 @@ export type TickerCallback = (this: T, dt: number) => any; * * This class is composed around listeners meant for execution on the next requested animation frame. * Animation frames are requested only when necessary, e.g. When the ticker is started and the emitter has listeners. - * * @class * @memberof PIXI */ @@ -96,10 +95,7 @@ export class Ticker private _minElapsedMS = 0; /** If enabled, deleting is disabled.*/ private _protected = false; - /** - * The last time keyframe was executed. - * Maintains a relatively fixed interval with the previous value. - */ + /** The last time keyframe was executed. Maintains a relatively fixed interval with the previous value. */ private _lastFrame = -1; /** * Internal tick method bound to ticker instance. @@ -108,7 +104,6 @@ export class Ticker * Also separating frame requests from update method * so listeners may be called at any time and with * any animation API, just invoke ticker.update(time). - * * @param time - Time since last tick. */ private _tick: (time: number) => any; @@ -140,7 +135,6 @@ export class Ticker * Conditionally requests a new animation frame. * If a frame has not already been requested, and if the internal * emitter has listeners, a new frame is requested. - * * @private */ private _requestIfNeeded(): void @@ -174,7 +168,6 @@ export class Ticker * conditions are met, a new frame is requested. If the ticker has not * been started, but autoStart is `true`, then the ticker starts now, * and continues with the previous conditions to request a new frame. - * * @private */ private _startIfPossible(): void @@ -192,7 +185,6 @@ export class Ticker /** * Register a handler for tick events. Calls continuously unless * it is removed or the ticker is stopped. - * * @param fn - The listener function to be added for updates * @param context - The listener context * @param {number} [priority=PIXI.UPDATE_PRIORITY.NORMAL] - The priority for emitting @@ -205,7 +197,6 @@ export class Ticker /** * Add a handler for the tick event which is only execute once. - * * @param fn - The listener function to be added for one update * @param context - The listener context * @param {number} [priority=PIXI.UPDATE_PRIORITY.NORMAL] - The priority for emitting @@ -220,7 +211,6 @@ export class Ticker * Internally adds the event handler so that it can be sorted by priority. * Priority allows certain handler (user, AnimatedSprite, Interaction) to be run * before the rendering. - * * @private * @param listener - Current listener being added. * @returns This instance of a ticker @@ -265,7 +255,6 @@ export class Ticker /** * Removes any handlers matching the function and context parameters. * If no handlers are left after removing, then it cancels the animation frame. - * * @param fn - The listener function to be removed * @param context - The listener context to be removed * @returns This instance of a ticker @@ -299,7 +288,6 @@ export class Ticker /** * The number of listeners on this ticker, calculated by walking through linked list - * * @readonly * @member {number} */ @@ -321,10 +309,7 @@ export class Ticker return count; } - /** - * Starts the ticker. If the ticker has listeners - * a new animation frame is requested at this point. - */ + /** Starts the ticker. If the ticker has listeners a new animation frame is requested at this point. */ start(): void { if (!this.started) @@ -334,10 +319,7 @@ export class Ticker } } - /** - * Stops the ticker. If the ticker has requested - * an animation frame it is canceled at this point. - */ + /** Stops the ticker. If the ticker has requested an animation frame it is canceled at this point. */ stop(): void { if (this.started) @@ -347,10 +329,7 @@ export class Ticker } } - /** - * Destroy the ticker and don't use after this. Calling - * this method removes all references to internal events. - */ + /** Destroy the ticker and don't use after this. Calling this method removes all references to internal events. */ destroy(): void { if (!this._protected) @@ -379,7 +358,6 @@ export class Ticker * This method will be called automatically by animation * frame callbacks if the ticker instance has been started * and listeners are added. - * * @param {number} [currentTime=performance.now()] - the current time of execution */ update(currentTime = performance.now()): void @@ -463,7 +441,6 @@ export class Ticker * **Note:** This does not factor in the value of * {@link PIXI.Ticker#speed}, which is specific * to scaling {@link PIXI.Ticker#deltaTime}. - * * @member {number} * @readonly */ @@ -479,7 +456,6 @@ export class Ticker * but does not effect the measured value of {@link PIXI.Ticker#FPS}. * When setting this property it is clamped to a value between * `0` and `PIXI.settings.TARGET_FPMS * 1000`. - * * @member {number} * @default 10 */ @@ -505,7 +481,6 @@ export class Ticker * This will effect the measured value of {@link PIXI.Ticker#FPS}. * If it is set to `0`, then there is no limit; PixiJS will render as many frames as it can. * Otherwise it will be at least `minFPS` - * * @member {number} * @default 0 */ @@ -542,7 +517,6 @@ export class Ticker * * The property {@link PIXI.Ticker#autoStart} is set to `true` for this instance. * Please follow the examples for usage, including how to opt-out of auto-starting the shared ticker. - * * @example * let ticker = PIXI.Ticker.shared; * // Set this to prevent starting this ticker when listeners are added. @@ -553,7 +527,6 @@ export class Ticker * ticker.stop(); * // Call this when you are ready for a running shared ticker. * ticker.start(); - * * @example * // You may use the shared ticker to render... * let renderer = PIXI.autoDetectRenderer(); @@ -562,7 +535,6 @@ export class Ticker * ticker.add(function (time) { * renderer.render(stage); * }); - * * @example * // Or you can just update it manually. * ticker.autoStart = false; @@ -573,7 +545,6 @@ export class Ticker * requestAnimationFrame(animate); * } * animate(performance.now()); - * * @member {PIXI.Ticker} * @static */ @@ -596,7 +567,6 @@ export class Ticker * unlike the `shared` ticker which drives visual animations and rendering which may want to be paused. * * The property {@link PIXI.Ticker#autoStart} is set to `true` for this instance. - * * @member {PIXI.Ticker} * @static */ diff --git a/packages/ticker/src/TickerListener.ts b/packages/ticker/src/TickerListener.ts index ec6f0f991b..9c931f7ae0 100644 --- a/packages/ticker/src/TickerListener.ts +++ b/packages/ticker/src/TickerListener.ts @@ -2,7 +2,6 @@ import { TickerCallback } from './Ticker'; /** * Internal class for handling the priority sorting of ticker handlers. - * * @private * @class * @memberof PIXI @@ -46,7 +45,7 @@ export class TickerListener * @private * @param fn - The listener function to be added for one update * @param context - The listener context - * @return `true` if the listener match the arguments + * @returns `true` if the listener match the arguments */ match(fn: TickerCallback, context: any = null): boolean { @@ -57,7 +56,7 @@ export class TickerListener * Emit by calling the current function. * @private * @param deltaTime - time since the last emit. - * @return Next ticker + * @returns Next ticker */ emit(deltaTime: number): TickerListener { @@ -111,7 +110,7 @@ export class TickerListener * @private * @param hard - `true` to remove the `next` reference, this * is considered a hard destroy. Soft destroy maintains the next reference. - * @return The listener to redirect while emitting or removing. + * @returns The listener to redirect while emitting or removing. */ destroy(hard = false): TickerListener { diff --git a/packages/ticker/src/TickerPlugin.ts b/packages/ticker/src/TickerPlugin.ts index bdf0a48f15..4756bb296e 100644 --- a/packages/ticker/src/TickerPlugin.ts +++ b/packages/ticker/src/TickerPlugin.ts @@ -3,12 +3,10 @@ import { Ticker } from './Ticker'; /** * Middleware for for Application Ticker. - * * @example * import {TickerPlugin} from '@pixi/ticker'; * import {Application} from '@pixi/app'; * Application.registerPlugin(TickerPlugin); - * * @class * @memberof PIXI */ @@ -21,7 +19,6 @@ export class TickerPlugin /** * Initialize the plugin with scope of application instance - * * @static * @private * @param {object} [options] - See application options @@ -57,7 +54,6 @@ export class TickerPlugin /** * Convenience method for stopping the render. - * * @method * @memberof PIXI.Application * @instance @@ -69,7 +65,6 @@ export class TickerPlugin /** * Convenience method for starting the render. - * * @method * @memberof PIXI.Application * @instance @@ -81,7 +76,6 @@ export class TickerPlugin /** * Internal reference to the ticker. - * * @type {PIXI.Ticker} * @name _ticker * @memberof PIXI.Application# @@ -91,7 +85,6 @@ export class TickerPlugin /** * Ticker for doing render updates. - * * @type {PIXI.Ticker} * @name ticker * @memberof PIXI.Application# @@ -108,7 +101,6 @@ export class TickerPlugin /** * Clean up the ticker, scoped to application. - * * @static * @private */ diff --git a/packages/ticker/src/const.ts b/packages/ticker/src/const.ts index be6b47c1e1..4c29a71045 100644 --- a/packages/ticker/src/const.ts +++ b/packages/ticker/src/const.ts @@ -2,19 +2,20 @@ * Represents the update priorities used by internal PIXI classes when registered with * the {@link PIXI.Ticker} object. Higher priority items are updated first and lower * priority items, such as render, should go later. - * * @static * @constant * @name UPDATE_PRIORITY * @memberof PIXI * @enum {number} - * @property {number} INTERACTION=50 Highest priority, used for {@link PIXI.InteractionManager} - * @property {number} HIGH=25 High priority updating, {@link PIXI.VideoBaseTexture} and {@link PIXI.AnimatedSprite} - * @property {number} NORMAL=0 Default priority for ticker events, see {@link PIXI.Ticker#add}. - * @property {number} LOW=-25 Low priority used for {@link PIXI.Application} rendering. - * @property {number} UTILITY=-50 Lowest priority used for {@link PIXI.BasePrepare} utility. + * @property {number} [INTERACTION=50] Highest priority, used for {@link PIXI.InteractionManager} + * @property {number} [HIGH=25] High priority updating, {@link PIXI.VideoBaseTexture} and {@link PIXI.AnimatedSprite} + * @property {number} [NORMAL=0] Default priority for ticker events, see {@link PIXI.Ticker#add}. + * @property {number} [LOW=-25] Low priority used for {@link PIXI.Application} rendering. + * @property {number} [UTILITY=-50] Lowest priority used for {@link PIXI.BasePrepare} utility. */ -export enum UPDATE_PRIORITY { +export enum UPDATE_PRIORITY +// eslint-disable-next-line @typescript-eslint/indent +{ INTERACTION = 50, HIGH = 25, NORMAL = 0, diff --git a/packages/ticker/src/settings.ts b/packages/ticker/src/settings.ts index 9a935a7126..0717bf2335 100644 --- a/packages/ticker/src/settings.ts +++ b/packages/ticker/src/settings.ts @@ -2,7 +2,6 @@ import { settings } from '@pixi/settings'; /** * Target frames per millisecond. - * * @static * @name TARGET_FPMS * @memberof PIXI.settings diff --git a/packages/ticker/test/Ticker.tests.ts b/packages/ticker/test/Ticker.tests.ts index 01ee5dea80..92ac5744db 100644 --- a/packages/ticker/test/Ticker.tests.ts +++ b/packages/ticker/test/Ticker.tests.ts @@ -4,20 +4,22 @@ import { expect } from 'chai'; const { shared, system } = Ticker; -describe('Ticker', function () +describe('Ticker', () => { - before(function () + let length: (ticker?: Ticker) => number; + + before(() => { - this.length = (ticker) => + length = (ticker?: Ticker) => { ticker = ticker || shared; - if (!ticker._head || !ticker._head.next) + if (!ticker['_head'] || !ticker['_head'].next) { return 0; } - let listener = ticker._head.next; + let listener = ticker['_head'].next; let i = 0; while (listener) @@ -30,14 +32,14 @@ describe('Ticker', function () }; }); - it('should be available', function () + it('should be available', () => { expect(Ticker).to.be.a('function'); expect(shared).to.be.an.instanceof(Ticker); expect(system).to.be.an.instanceof(Ticker); }); - it('should create a new ticker and destroy it', function () + it('should create a new ticker and destroy it', () => { const ticker = new Ticker(); @@ -45,54 +47,54 @@ describe('Ticker', function () const listener = sinon.spy(); - expect(this.length(ticker)).to.equal(0); + expect(length(ticker)).to.equal(0); ticker.add(listener); - expect(this.length(ticker)).to.equal(1); + expect(length(ticker)).to.equal(1); ticker.destroy(); - expect(ticker._head).to.be.null; + expect(ticker['_head']).to.be.null; expect(ticker.started).to.be.false; - expect(this.length(ticker)).to.equal(0); + expect(length(ticker)).to.equal(0); }); - it('should protect destroying shared ticker', function () + it('should protect destroying shared ticker', () => { const listener = sinon.spy(); shared.add(listener); // needed to autoStart shared.destroy(); - expect(shared._head).to.not.be.null; + expect(shared['_head']).to.not.be.null; expect(shared.started).to.be.true; }); - it('should protect destroying system ticker', function () + it('should protect destroying system ticker', () => { const listener = sinon.spy(); system.add(listener); // needed to autoStart system.destroy(); - expect(system._head).to.not.be.null; + expect(system['_head']).to.not.be.null; expect(system.started).to.be.true; }); - it('should add and remove listener', function () + it('should add and remove listener', () => { const listener = sinon.spy(); - const length = this.length(); + const len = length(); shared.add(listener); - expect(this.length()).to.equal(length + 1); + expect(length()).to.equal(len + 1); shared.remove(listener); - expect(this.length()).to.equal(length); + expect(length()).to.equal(len); }); - it('should update a listener', function () + it('should update a listener', () => { const listener = sinon.spy(); @@ -107,25 +109,25 @@ describe('Ticker', function () expect(listener.calledOnce).to.be.true; }); - it('should update a listener twice and remove once', function () + it('should update a listener twice and remove once', () => { const listener = sinon.spy(); - const length = this.length(); + const len = length(); shared.add(listener).add(listener); shared.update(); expect(listener.calledTwice).to.be.true; - expect(this.length()).to.equal(length + 2); + expect(length()).to.equal(len + 2); shared.remove(listener); shared.update(); expect(listener.calledTwice).to.be.true; - expect(this.length()).to.equal(length); + expect(length()).to.equal(len); }); - it('should count listeners correctly', function () + it('should count listeners correctly', () => { const ticker = new Ticker(); @@ -147,14 +149,14 @@ describe('Ticker', function () ticker.destroy(); - expect(ticker._head).to.be.null; + expect(ticker['_head']).to.be.null; expect(ticker.started).to.be.false; - expect(this.length(ticker)).to.equal(0); + expect(length(ticker)).to.equal(0); }); - it('should respect priority order', function () + it('should respect priority order', () => { - const length = this.length(); + const len = length(); const listener1 = sinon.spy(); const listener2 = sinon.spy(); const listener3 = sinon.spy(); @@ -167,7 +169,7 @@ describe('Ticker', function () shared.update(); - expect(this.length()).to.equal(length + 4); + expect(length()).to.equal(len + 4); sinon.assert.callOrder(listener4, listener3, listener2, listener1); @@ -176,12 +178,12 @@ describe('Ticker', function () .remove(listener3) .remove(listener4); - expect(this.length()).to.equal(length); + expect(length()).to.equal(len); }); - it('should auto-remove once listeners', function () + it('should auto-remove once listeners', () => { - const length = this.length(); + const len = length(); const listener = sinon.spy(); shared.addOnce(listener); @@ -189,12 +191,12 @@ describe('Ticker', function () shared.update(); expect(listener.calledOnce).to.be.true; - expect(this.length()).to.equal(length); + expect(length()).to.equal(len); }); - it('should call when adding same priority', function () + it('should call when adding same priority', () => { - const length = this.length(); + const len = length(); const listener1 = sinon.spy(); const listener2 = sinon.spy(); const listener3 = sinon.spy(); @@ -205,7 +207,7 @@ describe('Ticker', function () shared.update(); - expect(this.length()).to.equal(length + 3); + expect(length()).to.equal(len + 3); sinon.assert.callOrder(listener1, listener2, listener3); @@ -213,12 +215,12 @@ describe('Ticker', function () .remove(listener2) .remove(listener3); - expect(this.length()).to.equal(length); + expect(length()).to.equal(len); }); - it.skip('should remove once listener in a stack', function () + it.skip('should remove once listener in a stack', () => { - const length = this.length(); + const len = length(); const listener1 = sinon.spy(); const listener2 = sinon.spy(); const listener3 = sinon.spy(); @@ -229,7 +231,7 @@ describe('Ticker', function () shared.update(); - expect(this.length()).to.equal(length + 2); + expect(length()).to.equal(len + 2); shared.update(); @@ -239,12 +241,12 @@ describe('Ticker', function () shared.remove(listener1).remove(listener3); - expect(this.length()).to.equal(length); + expect(length()).to.equal(len); }); - it('should call inserted item with a lower priority', function () + it('should call inserted item with a lower priority', () => { - const length = this.length(); + const len = length(); const lowListener = sinon.spy(); const highListener = sinon.spy(); const mainListener = sinon.spy(() => @@ -257,7 +259,7 @@ describe('Ticker', function () shared.update(); - expect(this.length()).to.equal(length + 3); + expect(length()).to.equal(len + 3); expect(mainListener.calledOnce).to.be.true; expect(lowListener.calledOnce).to.be.true; @@ -267,12 +269,12 @@ describe('Ticker', function () .remove(highListener) .remove(lowListener); - expect(this.length()).to.equal(length); + expect(length()).to.equal(len); }); - it('should remove emit low-priority item during emit', function () + it('should remove emit low-priority item during emit', () => { - const length = this.length(); + const len = length(); const listener2 = sinon.spy(); const listener1 = sinon.spy(() => { @@ -283,7 +285,7 @@ describe('Ticker', function () shared.update(); - expect(this.length()).to.equal(length + 2); + expect(length()).to.equal(len + 2); expect(listener2.calledOnce).to.be.true; expect(listener1.calledOnce).to.be.true; @@ -291,12 +293,12 @@ describe('Ticker', function () shared.remove(listener1) .remove(listener2); - expect(this.length()).to.equal(length); + expect(length()).to.equal(len); }); - it('should remove itself on emit after adding new item', function () + it('should remove itself on emit after adding new item', () => { - const length = this.length(); + const len = length(); const listener2 = sinon.spy(); const listener1 = sinon.spy(() => { @@ -304,26 +306,26 @@ describe('Ticker', function () shared.remove(listener1); // listener is removed right away - expect(this.length()).to.equal(length + 1); + expect(length()).to.equal(len + 1); }); shared.add(listener1, null, UPDATE_PRIORITY.NORMAL); shared.update(); - expect(this.length()).to.equal(length + 1); + expect(length()).to.equal(len + 1); expect(listener2.calledOnce).to.be.true; expect(listener1.calledOnce).to.be.true; shared.remove(listener2); - expect(this.length()).to.equal(length); + expect(length()).to.equal(len); }); - it.skip('should remove itself before, still calling new item', function () + it.skip('should remove itself before, still calling new item', () => { - const length = this.length(); + const len = length(); const listener2 = sinon.spy(); const listener1 = sinon.spy(() => { @@ -331,14 +333,14 @@ describe('Ticker', function () shared.add(listener2, null, UPDATE_PRIORITY.LOW); // listener is removed right away - expect(this.length()).to.equal(length + 1); + expect(length()).to.equal(len + 1); }); shared.add(listener1, null, UPDATE_PRIORITY.NORMAL); shared.update(); - expect(this.length()).to.equal(length + 1); + expect(length()).to.equal(len + 1); expect(listener2.called).to.be.false; expect(listener1.calledOnce).to.be.true; @@ -350,12 +352,12 @@ describe('Ticker', function () shared.remove(listener2); - expect(this.length()).to.equal(length); + expect(length()).to.equal(len); }); - it.skip('should remove items before and after current priority', function () + it.skip('should remove items before and after current priority', () => { - const length = this.length(); + const len = length(); const listener2 = sinon.spy(); const listener3 = sinon.spy(); const listener4 = sinon.spy(); @@ -370,14 +372,14 @@ describe('Ticker', function () .remove(listener3); // listener is removed right away - expect(this.length()).to.equal(length + 2); + expect(length()).to.equal(len + 2); }); shared.add(listener1, null, UPDATE_PRIORITY.NORMAL); shared.update(); - expect(this.length()).to.equal(length + 2); + expect(length()).to.equal(len + 2); expect(listener2.calledOnce).to.be.true; expect(listener3.calledOnce).to.be.false; @@ -394,10 +396,10 @@ describe('Ticker', function () shared.remove(listener1) .remove(listener4); - expect(this.length()).to.equal(length); + expect(length()).to.equal(len); }); - it('should destroy on listener', function (done) + it('should destroy on listener', (done) => { const ticker = new Ticker(); const listener2 = sinon.spy(); @@ -417,7 +419,7 @@ describe('Ticker', function () ticker.start(); }); - it('should Ticker call destroyed listener "next" pointer after destroy', function (done) + it('should Ticker call destroyed listener "next" pointer after destroy', (done) => { const ticker = new Ticker(); diff --git a/packages/ticker/test/TickerPlugin.tests.ts b/packages/ticker/test/TickerPlugin.tests.ts index 47b6f47297..f8c0f97b01 100644 --- a/packages/ticker/test/TickerPlugin.tests.ts +++ b/packages/ticker/test/TickerPlugin.tests.ts @@ -1,92 +1,101 @@ -import { TickerPlugin, UPDATE_PRIORITY, Ticker } from '@pixi/ticker'; -import sinon from 'sinon'; +import { Ticker, TickerPlugin, UPDATE_PRIORITY } from '@pixi/ticker'; import { expect } from 'chai'; +import sinon from 'sinon'; -describe('TickerPlugin', function () +describe('TickerPlugin', () => { - it('should not start application before calling start method if options.autoStart is false', function (done) + interface App + { + _ticker?: Ticker; + ticker?: Ticker; + render?(): void; + start?(): void; + } + let app: App; + + it('should not start application before calling start method if options.autoStart is false', (done) => { - const app = {}; + const appp = {} as App; - TickerPlugin.init.call(app, { autoStart: false }); + TickerPlugin.init.call(appp, { autoStart: false }); - expect(app.ticker).to.be.instanceof(Ticker); - expect(app.ticker.started).to.be.false; + expect(appp.ticker).to.be.instanceof(Ticker); + expect(appp.ticker.started).to.be.false; - app.start(); + appp.start(); - app.ticker.addOnce(() => + appp.ticker.addOnce(() => { - TickerPlugin.destroy.call(app); + TickerPlugin.destroy.call(appp); done(); }); }); - describe('set ticker', function () + describe('set ticker', () => { - before(function () + before(() => { - this.app = { + app = { render() { // do nothing }, }; - TickerPlugin.init.call(this.app); + TickerPlugin.init.call(app); /* remove default listener to prevent uncaught exception */ - this.app._ticker.remove(this.app.render, this.app); + app._ticker.remove(app.render, app); }); - after(function () + after(() => { - TickerPlugin.destroy.call(this.app); + TickerPlugin.destroy.call(app); }); - it('should assign ticker object', function () + it('should assign ticker object', () => { const ticker = { add: sinon.spy() }; const _ticker = { remove: sinon.spy() }; - this.app._ticker = _ticker; - this.app.ticker = ticker; + app._ticker = _ticker as unknown as Ticker; + app.ticker = ticker as unknown as Ticker; expect(_ticker.remove).to.be.calledOnce; - expect(_ticker.remove.args[0][0]).to.be.equal(this.app.render); - expect(_ticker.remove.args[0][1]).to.be.equal(this.app); + expect(_ticker.remove.args[0][0]).to.be.equal(app.render); + expect(_ticker.remove.args[0][1]).to.be.equal(app); - expect(this.app._ticker).to.be.equal(ticker); + expect(app._ticker).to.be.equal(ticker); expect(ticker.add).to.be.calledOnce; - expect(ticker.add.args[0][0]).to.be.equal(this.app.render); - expect(ticker.add.args[0][1]).to.be.equal(this.app); + expect(ticker.add.args[0][0]).to.be.equal(app.render); + expect(ticker.add.args[0][1]).to.be.equal(app); expect(ticker.add.args[0][2]).to.be.equal(UPDATE_PRIORITY.LOW); }); - it('should assign ticker if no ticker', function () + it('should assign ticker if no ticker', () => { const ticker = { add: sinon.spy() }; - this.app._ticker = null; - this.app.ticker = ticker; + app._ticker = null; + app.ticker = ticker as unknown as Ticker; - expect(this.app._ticker).to.be.equal(ticker); + expect(app._ticker).to.be.equal(ticker); expect(ticker.add).to.be.calledOnce; - expect(ticker.add.args[0][0]).to.be.equal(this.app.render); - expect(ticker.add.args[0][1]).to.be.equal(this.app); + expect(ticker.add.args[0][0]).to.be.equal(app.render); + expect(ticker.add.args[0][1]).to.be.equal(app); expect(ticker.add.args[0][2]).to.be.equal(UPDATE_PRIORITY.LOW); }); - it('should assign null ticker', function () + it('should assign null ticker', () => { const _ticker = { remove: sinon.spy() }; - this.app._ticker = _ticker; - this.app.ticker = null; + app._ticker = _ticker as unknown as Ticker; + app.ticker = null; expect(_ticker.remove).to.be.calledOnce; - expect(_ticker.remove.args[0][0]).to.be.equal(this.app.render); - expect(_ticker.remove.args[0][1]).to.be.equal(this.app); + expect(_ticker.remove.args[0][0]).to.be.equal(app.render); + expect(_ticker.remove.args[0][1]).to.be.equal(app); - expect(this.app._ticker).to.be.null; + expect(app._ticker).to.be.null; }); }); }); diff --git a/packages/unsafe-eval/package.json b/packages/unsafe-eval/package.json index 1d66de1ade..a4ae468955 100644 --- a/packages/unsafe-eval/package.json +++ b/packages/unsafe-eval/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/unsafe-eval", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/unsafe-eval.js", "module": "dist/esm/unsafe-eval.js", "bundle": "dist/browser/unsafe-eval.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/unsafe-eval.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/unsafe-eval.js" + } + } + }, "bundleInput": "src/bundle.ts", "standalone": true, "description": "Adds support for environments that disallow support of new Function", @@ -24,6 +37,6 @@ "*.d.ts" ], "peerDependencies": { - "@pixi/core": "6.3.0" + "@pixi/core": "6.4.2" } } diff --git a/packages/unsafe-eval/src/install.ts b/packages/unsafe-eval/src/install.ts index a54495ea07..0a8f485b25 100644 --- a/packages/unsafe-eval/src/install.ts +++ b/packages/unsafe-eval/src/install.ts @@ -2,7 +2,8 @@ import { syncUniforms } from './syncUniforms'; import type { ShaderSystem, Program, UniformGroup } from '@pixi/core'; -interface PIXICore { +interface PIXICore +{ ShaderSystem: typeof ShaderSystem; } diff --git a/packages/utils/package.json b/packages/utils/package.json index f8cdc12d58..1ec1f08b1f 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,9 +1,22 @@ { "name": "@pixi/utils", - "version": "6.3.0", + "version": "6.4.2", "main": "dist/cjs/utils.js", "module": "dist/esm/utils.js", "bundle": "dist/browser/utils.js", + "types": "index.d.ts", + "exports": { + ".": { + "import": { + "types": "./index.d.ts", + "default": "./dist/esm/utils.js" + }, + "require": { + "types": "./index.d.ts", + "default": "./dist/cjs/utils.js" + } + } + }, "namespace": "PIXI.utils", "description": "Collection of utilities used by PixiJS", "author": "Mat Groves", @@ -32,8 +45,8 @@ "url": "^0.11.0" }, "peerDependencies": { - "@pixi/constants": "6.3.0", - "@pixi/settings": "6.3.0" + "@pixi/constants": "6.4.2", + "@pixi/settings": "6.4.2" }, "devDependencies": { "css-color-names": "^1.0.1" diff --git a/packages/utils/src/browser/hello.ts b/packages/utils/src/browser/hello.ts index 240d1dd61d..15d8ccf20c 100644 --- a/packages/utils/src/browser/hello.ts +++ b/packages/utils/src/browser/hello.ts @@ -3,7 +3,6 @@ const VERSION = '$_VERSION'; /** * Skips the hello message of renderers that are created after this is run. - * * @function skipHello * @memberof PIXI.utils */ @@ -16,7 +15,6 @@ export function skipHello(): void * Logs out the version and renderer information for this running instance of PIXI. * If you don't want to see this message you can run `PIXI.utils.skipHello()` before * creating your renderer. Keep in mind that doing that will forever make you a jerk face. - * * @static * @function sayHello * @memberof PIXI.utils diff --git a/packages/utils/src/browser/isWebGLSupported.ts b/packages/utils/src/browser/isWebGLSupported.ts index 18890a1ef3..45cd71cca0 100644 --- a/packages/utils/src/browser/isWebGLSupported.ts +++ b/packages/utils/src/browser/isWebGLSupported.ts @@ -1,13 +1,12 @@ import { settings } from '../settings'; -let supported: boolean|undefined; +let supported: boolean | undefined; /** * Helper for checking for WebGL support. - * * @memberof PIXI.utils * @function isWebGLSupported - * @return {boolean} Is WebGL supported. + * @returns {boolean} Is WebGL supported. */ export function isWebGLSupported(): boolean { diff --git a/packages/utils/src/color/hex.ts b/packages/utils/src/color/hex.ts index f05ff6f639..b96042f7f9 100644 --- a/packages/utils/src/color/hex.ts +++ b/packages/utils/src/color/hex.ts @@ -2,14 +2,13 @@ import { default as cssColorNames } from 'css-color-names'; /** * Converts a hexadecimal color number to an [R, G, B] array of normalized floats (numbers from 0.0 to 1.0). - * * @example * PIXI.utils.hex2rgb(0xffffff); // returns [1, 1, 1] * @memberof PIXI.utils * @function hex2rgb * @param {number} hex - The hexadecimal number to convert * @param {number[]} [out=[]] - If supplied, this array will be used rather than returning a new one - * @return {number[]} An array representing the [R, G, B] of the color where all values are floats. + * @returns {number[]} An array representing the [R, G, B] of the color where all values are floats. */ export function hex2rgb(hex: number, out: Array | Float32Array = []): Array | Float32Array { @@ -22,13 +21,12 @@ export function hex2rgb(hex: number, out: Array | Float32Array = []): Ar /** * Converts a hexadecimal color number to a string. - * * @example * PIXI.utils.hex2string(0xffffff); // returns "#ffffff" * @memberof PIXI.utils * @function hex2string * @param {number} hex - Number in hex (e.g., `0xffffff`) - * @return {string} The string color (e.g., `"#ffffff"`). + * @returns {string} The string color (e.g., `"#ffffff"`). */ export function hex2string(hex: number): string { @@ -46,13 +44,12 @@ export function hex2string(hex: number): string * hex strings starting with 0x: "0xffffff" * hex strings without prefix: "ffffff" * css colors: "black" - * * @example * PIXI.utils.string2hex("#ffffff"); // returns 0xffffff * @memberof PIXI.utils * @function string2hex * @param {string} string - The string color (e.g., `"#ffffff"`) - * @return {number} Number in hexadecimal. + * @returns {number} Number in hexadecimal. */ export function string2hex(string: string): number { @@ -71,13 +68,12 @@ export function string2hex(string: string): number /** * Converts a color as an [R, G, B] array of normalized floats to a hexadecimal number. - * * @example * PIXI.utils.rgb2hex([1, 1, 1]); // returns 0xffffff * @memberof PIXI.utils * @function rgb2hex * @param {number[]} rgb - Array of numbers where all values are normalized floats from 0.0 to 1.0. - * @return {number} Number in hexadecimal. + * @returns {number} Number in hexadecimal. */ export function rgb2hex(rgb: number[] | Float32Array): number { diff --git a/packages/utils/src/color/premultiply.ts b/packages/utils/src/color/premultiply.ts index 06cee17946..dc347ed2d5 100644 --- a/packages/utils/src/color/premultiply.ts +++ b/packages/utils/src/color/premultiply.ts @@ -2,11 +2,10 @@ import { BLEND_MODES } from '@pixi/constants'; /** * Corrects PixiJS blend, takes premultiplied alpha into account - * * @memberof PIXI.utils * @function mapPremultipliedBlendModes * @private - * @return {Array} Mapped modes. + * @returns {Array} Mapped modes. */ function mapPremultipliedBlendModes(): number[][] { @@ -38,14 +37,13 @@ function mapPremultipliedBlendModes(): number[][] /** * maps premultiply flag and blendMode to adjusted blendMode * @memberof PIXI.utils - * @const premultiplyBlendMode + * @constant premultiplyBlendMode * @type {Array} */ export const premultiplyBlendMode = mapPremultipliedBlendModes(); /** * changes blendMode according to texture format - * * @memberof PIXI.utils * @function correctBlendMode * @param {number} blendMode - supposed blend mode @@ -59,7 +57,6 @@ export function correctBlendMode(blendMode: number, premultiplied: boolean): num /** * combines rgb and alpha to out array - * * @memberof PIXI.utils * @function premultiplyRgba * @param {Float32Array|number[]} rgb - input rgb @@ -69,7 +66,7 @@ export function correctBlendMode(blendMode: number, premultiplied: boolean): num * @returns {Float32Array} vec4 rgba */ export function premultiplyRgba( - rgb: Float32Array|number[], + rgb: Float32Array | number[], alpha: number, out?: Float32Array, premultiply?: boolean @@ -95,7 +92,6 @@ export function premultiplyRgba( /** * premultiplies tint - * * @memberof PIXI.utils * @function premultiplyTint * @param {number} tint - integer RGB @@ -125,7 +121,6 @@ export function premultiplyTint(tint: number, alpha: number): number /** * converts integer tint and float alpha to vec4 form, premultiplies by default - * * @memberof PIXI.utils * @function premultiplyTintToRgba * @param {number} tint - input tint diff --git a/packages/utils/src/const.ts b/packages/utils/src/const.ts index 5895fe1af9..6e142ff28f 100644 --- a/packages/utils/src/const.ts +++ b/packages/utils/src/const.ts @@ -1,7 +1,6 @@ /** * Regexp for data URI. * Based on: {@link https://github.com/ragingwind/data-uri-regex} - * * @static * @constant {RegExp|string} DATA_URI * @memberof PIXI diff --git a/packages/utils/src/data/createIndicesForQuads.ts b/packages/utils/src/data/createIndicesForQuads.ts index 8a15ef52ee..a6e88ddbd6 100644 --- a/packages/utils/src/data/createIndicesForQuads.ts +++ b/packages/utils/src/data/createIndicesForQuads.ts @@ -1,13 +1,12 @@ /** * Generic Mask Stack data structure - * * @memberof PIXI.utils * @function createIndicesForQuads * @param {number} size - Number of quads * @param {Uint16Array|Uint32Array} [outBuffer] - Buffer for output, length has to be `6 * size` - * @return {Uint16Array|Uint32Array} - Resulting index buffer + * @returns {Uint16Array|Uint32Array} - Resulting index buffer */ -export function createIndicesForQuads(size: number, outBuffer: Uint16Array|Uint32Array = null): Uint16Array|Uint32Array +export function createIndicesForQuads(size: number, outBuffer: Uint16Array | Uint32Array = null): Uint16Array | Uint32Array { // the total number of indices in our array, there are 6 points per quad. const totalIndices = size * 6; diff --git a/packages/utils/src/data/getBufferType.ts b/packages/utils/src/data/getBufferType.ts index bc103ae6f5..094edf270c 100644 --- a/packages/utils/src/data/getBufferType.ts +++ b/packages/utils/src/data/getBufferType.ts @@ -1,6 +1,8 @@ import type { ITypedArray } from '@pixi/core'; -export function getBufferType(array: ITypedArray): 'Float32Array'|'Uint32Array'|'Int32Array'|'Uint16Array'|'Uint8Array'|null +export function getBufferType( + array: ITypedArray +): 'Float32Array' | 'Uint32Array' | 'Int32Array' | 'Uint16Array' | 'Uint8Array' | null { if (array.BYTES_PER_ELEMENT === 4) { diff --git a/packages/utils/src/data/interleaveTypedArrays.ts b/packages/utils/src/data/interleaveTypedArrays.ts index 54ae80d5d2..4e9c49d7ef 100644 --- a/packages/utils/src/data/interleaveTypedArrays.ts +++ b/packages/utils/src/data/interleaveTypedArrays.ts @@ -3,7 +3,7 @@ import { getBufferType } from './getBufferType'; /* eslint-disable object-shorthand */ const map = { Float32Array: Float32Array, Uint32Array: Uint32Array, Int32Array: Int32Array, Uint8Array: Uint8Array }; -type PackedArray = Float32Array|Uint32Array|Int32Array|Uint8Array; +type PackedArray = Float32Array | Uint32Array | Int32Array | Uint8Array; export function interleaveTypedArrays(arrays: PackedArray[], sizes: number[]): Float32Array { diff --git a/packages/utils/src/data/pow2.ts b/packages/utils/src/data/pow2.ts index 35ec211c4d..b7b44a6191 100644 --- a/packages/utils/src/data/pow2.ts +++ b/packages/utils/src/data/pow2.ts @@ -2,11 +2,10 @@ /** * Rounds to next power of two. - * * @function nextPow2 * @memberof PIXI.utils * @param {number} v - input value - * @return {number} + * @returns {number} - next rounded power of two */ export function nextPow2(v: number): number { @@ -23,11 +22,10 @@ export function nextPow2(v: number): number /** * Checks if a number is a power of two. - * * @function isPow2 * @memberof PIXI.utils * @param {number} v - input value - * @return {boolean} `true` if value is power of two + * @returns {boolean} `true` if value is power of two */ export function isPow2(v: number): boolean { @@ -36,11 +34,10 @@ export function isPow2(v: number): boolean /** * Computes ceil of log base 2 - * * @function log2 * @memberof PIXI.utils * @param {number} v - input value - * @return {number} logarithm base 2 + * @returns {number} logarithm base 2 */ export function log2(v: number): number { diff --git a/packages/utils/src/data/removeItems.ts b/packages/utils/src/data/removeItems.ts index 1f4ed6e0a5..6c739afa0f 100644 --- a/packages/utils/src/data/removeItems.ts +++ b/packages/utils/src/data/removeItems.ts @@ -1,6 +1,5 @@ /** * Remove items from a javascript array without generating garbage - * * @function removeItems * @memberof PIXI.utils * @param {Array} arr - Array to remove elements from diff --git a/packages/utils/src/data/sign.ts b/packages/utils/src/data/sign.ts index 4e41c0d4eb..06d763aae4 100644 --- a/packages/utils/src/data/sign.ts +++ b/packages/utils/src/data/sign.ts @@ -1,12 +1,11 @@ /** * Returns sign of number - * * @memberof PIXI.utils * @function sign * @param {number} n - the number to check the sign of * @returns {number} 0 if `n` is 0, -1 if `n` is negative, 1 if `n` is positive */ -export function sign(n: number): -1|0|1 +export function sign(n: number): -1 | 0 | 1 { if (n === 0) return 0; diff --git a/packages/utils/src/data/uid.ts b/packages/utils/src/data/uid.ts index 6d5b00a8e0..416eb4fbb6 100644 --- a/packages/utils/src/data/uid.ts +++ b/packages/utils/src/data/uid.ts @@ -2,10 +2,9 @@ let nextUid = 0; /** * Gets the next unique identifier - * * @memberof PIXI.utils * @function uid - * @return {number} The next unique identifier to use. + * @returns {number} The next unique identifier to use. */ export function uid(): number { diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index 5bde7ad712..1ef76824ef 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -19,29 +19,27 @@ /** * A simple JS library that detects mobile devices. - * * @see {@link https://github.com/kaimallea/isMobile} - * * @memberof PIXI.utils * @name isMobile - * @member {Object} + * @member {object} * @property {boolean} any - `true` if current platform is tablet or phone device * @property {boolean} tablet - `true` if current platform large-screen tablet device * @property {boolean} phone - `true` if current platform small-screen phone device - * @property {object} apple + * @property {object} apple - * @property {boolean} apple.device - `true` if any Apple device * @property {boolean} apple.tablet - `true` if any Apple iPad * @property {boolean} apple.phone - `true` if any Apple iPhone * @property {boolean} apple.ipod - `true` if any iPod - * @property {object} android + * @property {object} android - * @property {boolean} android.device - `true` if any Android device * @property {boolean} android.tablet - `true` if any Android tablet * @property {boolean} android.phone - `true` if any Android phone - * @property {object} amazon + * @property {object} amazon - * @property {boolean} amazon.device - `true` if any Silk device * @property {boolean} amazon.tablet - `true` if any Silk tablet * @property {boolean} amazon.phone - `true` if any Silk phone - * @property {object} windows + * @property {object} windows - * @property {boolean} windows.device - `true` if any Windows device * @property {boolean} windows.tablet - `true` if any Windows tablet * @property {boolean} windows.phone - `true` if any Windows phone @@ -52,9 +50,7 @@ import EventEmitter from 'eventemitter3'; /** * A high performance event emitter - * * @see {@link https://github.com/primus/eventemitter3} - * * @memberof PIXI.utils * @class EventEmitter */ @@ -62,23 +58,19 @@ export { EventEmitter }; /** * A polygon triangulation library - * * @see {@link https://github.com/mapbox/earcut} - * * @memberof PIXI.utils * @method earcut * @param {number[]} vertices - A flat array of vertex coordinates * @param {number[]} [holes] - An array of hole indices * @param {number} [dimensions=2] - The number of coordinates per vertex in the input array - * @return {number[]} Triangulated polygon + * @returns {number[]} Triangulated polygon */ export { default as earcut } from 'earcut'; /** * Node.js compatible URL utilities. - * * @see https://www.npmjs.com/package/url - * * @memberof PIXI.utils * @name url * @member {object} diff --git a/packages/utils/src/logging/deprecation.ts b/packages/utils/src/logging/deprecation.ts index 54a55e8cff..ed14f28334 100644 --- a/packages/utils/src/logging/deprecation.ts +++ b/packages/utils/src/logging/deprecation.ts @@ -7,7 +7,6 @@ const warnings: Dict = {}; * Helper for warning developers about deprecated features & settings. * A stack track for warnings is given; useful for tracking-down where * deprecated methods/properties/classes are being used within the code. - * * @memberof PIXI.utils * @function deprecation * @param {string} version - The version where the feature became deprecated diff --git a/packages/utils/src/media/CanvasRenderTarget.ts b/packages/utils/src/media/CanvasRenderTarget.ts index 13573b2728..972a898ccd 100644 --- a/packages/utils/src/media/CanvasRenderTarget.ts +++ b/packages/utils/src/media/CanvasRenderTarget.ts @@ -2,7 +2,6 @@ import { settings } from '@pixi/settings'; /** * Creates a Canvas element of the given size to be used as a target for rendering to. - * * @class * @memberof PIXI.utils */ @@ -38,7 +37,6 @@ export class CanvasRenderTarget /** * Clears the canvas that was created by the CanvasRenderTarget class. - * * @private */ clear(): void @@ -49,7 +47,6 @@ export class CanvasRenderTarget /** * Resizes the canvas to the specified width and height. - * * @param desiredWidth - the desired width of the canvas * @param desiredHeight - the desired height of the canvas */ @@ -68,7 +65,6 @@ export class CanvasRenderTarget /** * The width of the canvas buffer in pixels. - * * @member {number} */ get width(): number @@ -83,7 +79,6 @@ export class CanvasRenderTarget /** * The height of the canvas buffer in pixels. - * * @member {number} */ get height(): number diff --git a/packages/utils/src/media/caches.ts b/packages/utils/src/media/caches.ts index 85a764756c..21b7fe94ff 100644 --- a/packages/utils/src/media/caches.ts +++ b/packages/utils/src/media/caches.ts @@ -2,37 +2,33 @@ import type { Program, Texture, BaseTexture } from '@pixi/core'; /** * @todo Describe property usage - * * @static * @name ProgramCache * @memberof PIXI.utils - * @type {Object} + * @type {object} */ export const ProgramCache: {[key: string]: Program} = {}; /** * @todo Describe property usage - * * @static * @name TextureCache * @memberof PIXI.utils - * @type {Object} + * @type {object} */ export const TextureCache: {[key: string]: Texture} = Object.create(null); /** * @todo Describe property usage - * * @static * @name BaseTextureCache * @memberof PIXI.utils - * @type {Object} + * @type {object} */ export const BaseTextureCache: {[key: string]: BaseTexture} = Object.create(null); /** * Destroys all texture in the cache - * * @memberof PIXI.utils * @function destroyTextureCache */ @@ -52,7 +48,6 @@ export function destroyTextureCache(): void /** * Removes all textures from cache, but does not destroy them - * * @memberof PIXI.utils * @function clearTextureCache */ diff --git a/packages/utils/src/media/trimCanvas.ts b/packages/utils/src/media/trimCanvas.ts index 5c1ef32a43..630a42773d 100644 --- a/packages/utils/src/media/trimCanvas.ts +++ b/packages/utils/src/media/trimCanvas.ts @@ -1,4 +1,5 @@ -interface Inset { +interface Inset +{ top?: number; left?: number; right?: number; @@ -7,7 +8,6 @@ interface Inset { /** * Trim transparent borders from a canvas - * * @memberof PIXI.utils * @function trimCanvas * @param {HTMLCanvasElement} canvas - the canvas to trim diff --git a/packages/utils/src/network/decomposeDataUri.ts b/packages/utils/src/network/decomposeDataUri.ts index 3664242311..c1662f8a9d 100644 --- a/packages/utils/src/network/decomposeDataUri.ts +++ b/packages/utils/src/network/decomposeDataUri.ts @@ -1,6 +1,7 @@ import { DATA_URI } from '../const'; -export interface DecomposedDataUri { +export interface DecomposedDataUri +{ mediaType: string; subType: string; charset: string; @@ -45,11 +46,10 @@ export interface DecomposedDataUri { /** * Split a data URI into components. Returns undefined if * parameter `dataUri` is not a valid data URI. - * * @memberof PIXI.utils * @function decomposeDataUri * @param {string} dataUri - the data URI to check - * @return {PIXI.utils.DecomposedDataUri|undefined} The decomposed data uri or undefined + * @returns {PIXI.utils.DecomposedDataUri|undefined} The decomposed data uri or undefined */ export function decomposeDataUri(dataUri: string): DecomposedDataUri { diff --git a/packages/utils/src/network/determineCrossOrigin.ts b/packages/utils/src/network/determineCrossOrigin.ts index 0a73ffbfea..e4776e8c3f 100644 --- a/packages/utils/src/network/determineCrossOrigin.ts +++ b/packages/utils/src/network/determineCrossOrigin.ts @@ -1,17 +1,16 @@ import { url as _url } from '../url'; -let tempAnchor: HTMLAnchorElement|undefined; +let tempAnchor: HTMLAnchorElement | undefined; /** * Sets the `crossOrigin` property for this resource based on if the url * for this resource is cross-origin. If crossOrigin was manually set, this * function does nothing. * Nipped from the resource loader! - * * @ignore * @param {string} url - The url to test. * @param {object} [loc=window.location] - The location object to test against. - * @return {string} The crossOrigin value to use (or empty string for none). + * @returns {string} The crossOrigin value to use (or empty string for none). */ export function determineCrossOrigin(url: string, loc: Location = globalThis.location): string { diff --git a/packages/utils/src/network/getResolutionOfUrl.ts b/packages/utils/src/network/getResolutionOfUrl.ts index d30d830aaa..242e9d1f00 100644 --- a/packages/utils/src/network/getResolutionOfUrl.ts +++ b/packages/utils/src/network/getResolutionOfUrl.ts @@ -3,12 +3,11 @@ import { settings } from '../settings'; /** * get the resolution / device pixel ratio of an asset by looking for the prefix * used by spritesheets and image urls - * * @memberof PIXI.utils * @function getResolutionOfUrl * @param {string} url - the image path * @param {number} [defaultValue=1] - the defaultValue if no filename prefix is set. - * @return {number} resolution / device pixel ratio of an asset + * @returns {number} resolution / device pixel ratio of an asset */ export function getResolutionOfUrl(url: string, defaultValue?: number): number { diff --git a/packages/utils/src/settings.ts b/packages/utils/src/settings.ts index 07699ca5f7..a19bec5235 100644 --- a/packages/utils/src/settings.ts +++ b/packages/utils/src/settings.ts @@ -2,7 +2,6 @@ import { settings } from '@pixi/settings'; /** * The prefix that denotes a URL is for a retina asset. - * * @static * @name RETINA_PREFIX * @memberof PIXI.settings @@ -31,7 +30,6 @@ settings.RETINA_PREFIX = /@([0-9\.]+)x/; * renderer, and show an error message to the user if the function returns false, explaining that their device & browser * combination does not support high performance WebGL. * This is a much better strategy than trying to create a PixiJS renderer and finding it then fails. - * * @static * @name FAIL_IF_MAJOR_PERFORMANCE_CAVEAT * @memberof PIXI.settings diff --git a/packages/utils/src/url.ts b/packages/utils/src/url.ts index 57c0e9d48c..1763e98846 100644 --- a/packages/utils/src/url.ts +++ b/packages/utils/src/url.ts @@ -7,15 +7,18 @@ import { parse as _parse, format as _format, resolve as _resolve } from 'url'; -interface ParsedUrlQuery { +interface ParsedUrlQuery +{ [key: string]: string | string[]; } -interface ParsedUrlQueryInput { +interface ParsedUrlQueryInput +{ [key: string]: unknown; } -interface UrlObjectCommon { +interface UrlObjectCommon +{ auth?: string; hash?: string; host?: string; @@ -29,26 +32,31 @@ interface UrlObjectCommon { } // Input to `url.format` -interface UrlObject extends UrlObjectCommon { +interface UrlObject extends UrlObjectCommon +{ port?: string | number; query?: string | null | ParsedUrlQueryInput; } // Output of `url.parse` -interface Url extends UrlObjectCommon { +interface Url extends UrlObjectCommon +{ port?: string; query?: string | null | ParsedUrlQuery; } -interface UrlWithParsedQuery extends Url { +interface UrlWithParsedQuery extends Url +{ query: ParsedUrlQuery; } -interface UrlWithStringQuery extends Url { +interface UrlWithStringQuery extends Url +{ query: string | null; } -interface URLFormatOptions { +interface URLFormatOptions +{ auth?: boolean; fragment?: boolean; search?: boolean; diff --git a/packages/utils/test/CanvasRenderTarget.tests.ts b/packages/utils/test/CanvasRenderTarget.tests.ts index ab49167e8d..0e674d0a78 100644 --- a/packages/utils/test/CanvasRenderTarget.tests.ts +++ b/packages/utils/test/CanvasRenderTarget.tests.ts @@ -2,9 +2,9 @@ import { CanvasRenderTarget } from '@pixi/utils'; import { settings } from '@pixi/settings'; import { expect } from 'chai'; -describe('CanvasRenderTarget', function () +describe('CanvasRenderTarget', () => { - it('should create with default resolution', function () + it('should create with default resolution', () => { const renderTarget = new CanvasRenderTarget(200, 100); @@ -20,7 +20,7 @@ describe('CanvasRenderTarget', function () expect(renderTarget.canvas).to.be.null; }); - it('should create with custom resolution', function () + it('should create with custom resolution', () => { const renderTarget = new CanvasRenderTarget(200, 100, 2); @@ -34,7 +34,7 @@ describe('CanvasRenderTarget', function () renderTarget.destroy(); }); - it('should manually set width and height', function () + it('should manually set width and height', () => { const renderTarget = new CanvasRenderTarget(200, 100); @@ -47,7 +47,7 @@ describe('CanvasRenderTarget', function () renderTarget.destroy(); }); - it('should clear successfully', function () + it('should clear successfully', () => { const renderTarget = new CanvasRenderTarget(200, 100); diff --git a/packages/utils/test/TextureCache.tests.ts b/packages/utils/test/TextureCache.tests.ts index 0978b620c9..f077245117 100644 --- a/packages/utils/test/TextureCache.tests.ts +++ b/packages/utils/test/TextureCache.tests.ts @@ -2,22 +2,22 @@ import { Texture, BaseTexture } from '@pixi/core'; import { TextureCache, destroyTextureCache, clearTextureCache, BaseTextureCache } from '@pixi/utils'; import { expect } from 'chai'; -describe('TextureCache', function () +describe('TextureCache', () => { - beforeEach(function () + beforeEach(() => { destroyTextureCache(); clearTextureCache(); }); - it('should exist', function () + it('should exist', () => { expect(TextureCache).to.be.an('object'); }); - describe('destroyTextureCache', function () + describe('destroyTextureCache', () => { - it('should successfully destroy the texture cache', function () + it('should successfully destroy the texture cache', () => { const canvas = document.createElement('canvas'); const foo = new Texture(new BaseTexture(canvas)); @@ -45,9 +45,9 @@ describe('TextureCache', function () }); }); - describe('clearTextureCache', function () + describe('clearTextureCache', () => { - it('should successfully clear the texture cache', function () + it('should successfully clear the texture cache', () => { const canvas = document.createElement('canvas'); const foo = new Texture(new BaseTexture(canvas)); diff --git a/packages/utils/test/trimCanvas.tests.ts b/packages/utils/test/trimCanvas.tests.ts index 754192182c..0205ce5111 100644 --- a/packages/utils/test/trimCanvas.tests.ts +++ b/packages/utils/test/trimCanvas.tests.ts @@ -1,9 +1,9 @@ import { trimCanvas } from '@pixi/utils'; import { expect } from 'chai'; -describe('trimCanvas', function () +describe('trimCanvas', () => { - it('should trim the canvas', function () + it('should trim the canvas', () => { const canvas = document.createElement('canvas'); const context = canvas.getContext('2d'); diff --git a/packages/utils/test/utils.tests.ts b/packages/utils/test/utils.tests.ts index b0140cb33f..9baa283e24 100755 --- a/packages/utils/test/utils.tests.ts +++ b/packages/utils/test/utils.tests.ts @@ -1,26 +1,26 @@ import * as utils from '@pixi/utils'; import { expect } from 'chai'; -describe('utils', function () +describe('utils', () => { - describe('uid', function () + describe('uid', () => { - it('should exist', function () + it('should exist', () => { expect(utils.uid) .to.be.a('function'); }); - it('should return a number', function () + it('should return a number', () => { expect(utils.uid()) .to.be.a('number'); }); }); - describe('hex2rgb', function () + describe('hex2rgb', () => { - it('should exist', function () + it('should exist', () => { expect(utils.hex2rgb) .to.be.a('function'); @@ -29,9 +29,9 @@ describe('utils', function () // it('should properly convert number to rgb array'); }); - describe('hex2string', function () + describe('hex2string', () => { - it('should exist', function () + it('should exist', () => { expect(utils.hex2string) .to.be.a('function'); @@ -56,20 +56,20 @@ describe('utils', function () { it(`should properly convert number 0x${num.toString(16)} to hex color string #${result}`, () => { - expect(utils.hex2string(num)).to.equals(result); + expect(utils.hex2string(num as number)).to.equals(result); }); }); }); - describe('rgb2hex', function () + describe('rgb2hex', () => { - it('should exist', function () + it('should exist', () => { expect(utils.rgb2hex) .to.be.a('function'); }); - it('should calculate correctly', function () + it('should calculate correctly', () => { expect(utils.rgb2hex([0.3, 0.2, 0.1])).to.equals(0x4c3319); }); @@ -77,9 +77,9 @@ describe('utils', function () // it('should properly convert rgb array to hex color string'); }); - describe('getResolutionOfUrl', function () + describe('getResolutionOfUrl', () => { - it('should exist', function () + it('should exist', () => { expect(utils.getResolutionOfUrl) .to.be.a('function'); @@ -88,15 +88,15 @@ describe('utils', function () // it('should return the correct resolution based on a URL'); }); - describe('decomposeDataUri', function () + describe('decomposeDataUri', () => { - it('should exist', function () + it('should exist', () => { expect(utils.decomposeDataUri) .to.be.a('function'); }); - it('should decompose a data URI', function () + it('should decompose a data URI', () => { const dataUri = utils.decomposeDataUri('data:image/png;base64,94Z9RWUN77ZW'); @@ -114,7 +114,7 @@ describe('utils', function () .to.equal('94Z9RWUN77ZW'); }); - it('should decompose a data URI with charset', function () + it('should decompose a data URI with charset', () => { const dataUri = utils.decomposeDataUri('data:image/svg+xml;charset=utf8;base64,PGRpdiB4bWxucz0Pg=='); @@ -132,7 +132,7 @@ describe('utils', function () .to.equal('PGRpdiB4bWxucz0Pg=='); }); - it('should decompose a data URI with charset without encoding', function () + it('should decompose a data URI with charset without encoding', () => { const dataUri = utils.decomposeDataUri('data:image/svg+xml;charset=utf8,PGRpdiB4bWxucz0Pg=='); @@ -150,7 +150,7 @@ describe('utils', function () .to.equal('PGRpdiB4bWxucz0Pg=='); }); - it('should return undefined for anything else', function () + it('should return undefined for anything else', () => { const dataUri = utils.decomposeDataUri('foo'); @@ -159,33 +159,33 @@ describe('utils', function () }); }); - describe('sayHello', function () + describe('sayHello', () => { - it('should exist', function () + it('should exist', () => { expect(utils.sayHello) .to.be.a('function'); }); }); - describe('isWebGLSupported', function () + describe('isWebGLSupported', () => { - it('should exist', function () + it('should exist', () => { expect(utils.isWebGLSupported) .to.be.a('function'); }); }); - describe('sign', function () + describe('sign', () => { - it('should return 0 for 0', function () + it('should return 0 for 0', () => { expect(utils.sign(0)) .to.be.equal(0); }); - it('should return -1 for negative numbers', function () + it('should return -1 for negative numbers', () => { for (let i = 0; i < 10; i += 1) { @@ -194,7 +194,7 @@ describe('utils', function () } }); - it('should return 1 for positive numbers', function () + it('should return 1 for positive numbers', () => { for (let i = 0; i < 10; i += 1) { @@ -204,14 +204,14 @@ describe('utils', function () }); }); - describe('.removeItems', function () + describe('.removeItems', () => { - it('should exist', function () + it('should exist', () => { expect(utils.removeItems).to.be.a('function'); }); - it('should return if the start index is greater than or equal to the length of the array', function () + it('should return if the start index is greater than or equal to the length of the array', () => { const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; @@ -219,7 +219,7 @@ describe('utils', function () expect(arr.length).to.equal(10); }); - it('should return if the remove count is 0', function () + it('should return if the remove count is 0', () => { const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; @@ -227,7 +227,7 @@ describe('utils', function () expect(arr.length).to.equal(10); }); - it('should remove the number of elements specified from the array, starting from the start index', function () + it('should remove the number of elements specified from the array, starting from the start index', () => { const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; @@ -235,7 +235,7 @@ describe('utils', function () expect(arr).to.deep.equal([1, 2, 3, 8, 9, 10]); }); - it('should remove other elements if delete count is > than the number of elements after start index', function () + it('should remove other elements if delete count is > than the number of elements after start index', () => { const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; @@ -244,30 +244,30 @@ describe('utils', function () }); }); - describe('EventEmitter', function () + describe('EventEmitter', () => { - it('should exist', function () + it('should exist', () => { expect(utils.EventEmitter).to.be.a('function'); }); }); - describe('isMobile', function () + describe('isMobile', () => { - it('should exist', function () + it('should exist', () => { expect(utils.isMobile).to.be.an('object'); }); - it('should return a boolean for .any', function () + it('should return a boolean for .any', () => { expect(utils.isMobile.any).to.be.a('boolean'); }); }); - describe('earcut', function () + describe('earcut', () => { - it('should exist', function () + it('should exist', () => { expect(utils.earcut).to.be.a('function'); }); diff --git a/rollup.config.js b/rollup.config.js index 7b18779cd7..43797e47ea 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -19,7 +19,8 @@ const isProduction = process.env.NODE_ENV === 'production'; * Get the JSCC plugin for preprocessing code. * @param {boolean} debug Build is for debugging */ -function preprocessPlugin(debug) { +function preprocessPlugin(debug) +{ return jscc({ values: { _DEBUG: debug, @@ -33,7 +34,8 @@ function preprocessPlugin(debug) { * Convert a development file name to minified. * @param {string} name */ -function prodName(name) { +function prodName(name) +{ return name.replace(/\.(m)?js$/, '.min.$1js'); } @@ -47,7 +49,9 @@ async function main() }), commonjs(), json(), - typescript(), + typescript({ + tsconfig: path.resolve(__dirname, 'tsconfig.build.json'), + }), string({ include: [ '**/*.frag', @@ -119,7 +123,7 @@ async function main() dependencies, peerDependencies } = pkg.config; - let banner = [ + const banner = [ `/*!`, ` * ${pkg.name} - v${version}`, ` * Compiled ${compiled}`, @@ -133,7 +137,7 @@ async function main() const external = Object.keys(dependencies || []) .concat(Object.keys(peerDependencies || [])); const basePath = path.relative(__dirname, pkg.dir); - let input = path.join(basePath, 'src/index.ts'); + const input = path.join(basePath, 'src/index.ts'); const freeze = false; results.push({ @@ -158,7 +162,8 @@ async function main() plugins, }); - if (isProduction) { + if (isProduction) + { results.push({ input, output: [ diff --git a/scripts/fixPeerVersions.ts b/scripts/fixPeerVersions.ts index d87e5a14e1..896e9a81f6 100644 --- a/scripts/fixPeerVersions.ts +++ b/scripts/fixPeerVersions.ts @@ -3,9 +3,7 @@ import path from 'path'; import fs from 'fs'; import util from 'util'; -/** - * Simplified interface for a package.json - */ +/** Simplified interface for a package.json */ interface Package { name: string; diff --git a/scripts/injectGlobalMixins.ts b/scripts/injectGlobalMixins.ts index 3315b27fdd..baafa6c52c 100644 --- a/scripts/injectGlobalMixins.ts +++ b/scripts/injectGlobalMixins.ts @@ -2,9 +2,7 @@ import workspacesRun from 'workspaces-run'; import path from 'path'; import fs from 'fs'; -/** - * simplified interface for a package.json - */ +/** simplified interface for a package.json */ interface SimplePackageJson { location: string @@ -14,6 +12,8 @@ interface SimplePackageJson /** * Adds global reference to the start of a packages `index.d.ts` file + * @param basePath + * @param dataToWrite */ function writeToIndex(basePath: string, dataToWrite: string): void { @@ -26,6 +26,7 @@ function writeToIndex(basePath: string, dataToWrite: string): void /** * Collect the list of packages in the project + * @param result */ async function getPackages(result: SimplePackageJson[] = []): Promise { diff --git a/test/index.ts b/test/index.ts index 209a823c2f..737ceb4f6b 100644 --- a/test/index.ts +++ b/test/index.ts @@ -7,7 +7,8 @@ import type { FlossOptions } from 'floss'; import type { PackageResult } from './packages'; // Support for global otpions -declare global { +declare global +{ let options: FlossOptions; } @@ -17,7 +18,7 @@ import 'tsconfig-paths/register'; // We only need to do this one time chai.use(sinonChai); -const requireAsStrings = (module, filename) => +const requireAsStrings = (module: any, filename: string) => { module.exports = fs.readFileSync(filename, 'utf8'); }; diff --git a/test/packages.ts b/test/packages.ts index 94eda84403..1c5cb8555f 100644 --- a/test/packages.ts +++ b/test/packages.ts @@ -2,7 +2,8 @@ import path from 'path'; import fs from 'fs'; import workspacesRun from 'workspaces-run'; -interface PackageResult { +interface PackageResult +{ name: string; location: string; tests: string; diff --git a/tools/integration-tests/package.json b/tools/integration-tests/package.json index 33a108c761..e80f47ceba 100644 --- a/tools/integration-tests/package.json +++ b/tools/integration-tests/package.json @@ -1,23 +1,23 @@ { "name": "@internal/integration-tests", "private": true, - "version": "6.3.0", + "version": "6.4.2", "description": "Integration tests for PixiJS packages", "devDependencies": { - "@pixi/canvas-display": "6.3.0", - "@pixi/canvas-graphics": "6.3.0", - "@pixi/canvas-mesh": "6.3.0", - "@pixi/canvas-renderer": "6.3.0", - "@pixi/canvas-sprite": "6.3.0", - "@pixi/canvas-text": "6.3.0", - "@pixi/core": "6.3.0", - "@pixi/display": "6.3.0", - "@pixi/graphics": "6.3.0", - "@pixi/math": "6.3.0", - "@pixi/mesh": "6.3.0", - "@pixi/mesh-extras": "6.3.0", - "@pixi/sprite": "6.3.0", - "@pixi/text": "6.3.0", - "@pixi/utils": "6.3.0" + "@pixi/canvas-display": "6.4.2", + "@pixi/canvas-graphics": "6.4.2", + "@pixi/canvas-mesh": "6.4.2", + "@pixi/canvas-renderer": "6.4.2", + "@pixi/canvas-sprite": "6.4.2", + "@pixi/canvas-text": "6.4.2", + "@pixi/core": "6.4.2", + "@pixi/display": "6.4.2", + "@pixi/graphics": "6.4.2", + "@pixi/math": "6.4.2", + "@pixi/mesh": "6.4.2", + "@pixi/mesh-extras": "6.4.2", + "@pixi/sprite": "6.4.2", + "@pixi/text": "6.4.2", + "@pixi/utils": "6.4.2" } } diff --git a/tools/integration-tests/test/Bounds.tests.ts b/tools/integration-tests/test/Bounds.tests.ts index 0b4a84bac8..ca9dd7e6f1 100644 --- a/tools/integration-tests/test/Bounds.tests.ts +++ b/tools/integration-tests/test/Bounds.tests.ts @@ -7,9 +7,9 @@ import { Text } from '@pixi/text'; // import { SimplePlane } from '@pixi/mesh-extras'; import { expect } from 'chai'; -describe('getBounds', function () +describe('getBounds', () => { - it('should register correct width/height with a LOADED Sprite', function () + it('should register correct width/height with a LOADED Sprite', () => { const parent = new Container(); const texture = RenderTexture.create(10, 10); @@ -46,7 +46,7 @@ describe('getBounds', function () expect(bounds.height).to.equal(20); }); - it('should register correct width/height with Graphics', function () + it('should register correct width/height with Graphics', () => { const parent = new Container(); const graphics = new Graphics(); @@ -90,7 +90,7 @@ describe('getBounds', function () expect(bounds.height).to.equal(40); }); - it('should register correct width/height with an empty Container', function () + it('should register correct width/height with an empty Container', () => { const parent = new Container(); @@ -119,7 +119,7 @@ describe('getBounds', function () expect(bounds.height).to.equal(0); }); - it('should register correct width/height with a Container', function () + it('should register correct width/height with a Container', () => { const parent = new Container(); @@ -164,7 +164,7 @@ describe('getBounds', function () expect(bounds.height | 0).to.equal(97); }); - it('should register correct width/height with an item that has already had its parent Container transformed', function () + it('should register correct width/height with an item that has already had its parent Container transformed', () => { const parent = new Container(); @@ -194,7 +194,7 @@ describe('getBounds', function () }); /* - it('should register correct width/height with a Mesh', function () + it('should register correct width/height with a Mesh', ()=> { const parent = new Container(); @@ -226,7 +226,7 @@ describe('getBounds', function () }); */ - it('should register correct width/height with an a DisplayObject is visible false', function () + it('should register correct width/height with an a DisplayObject is visible false', () => { const parent = new Container(); @@ -273,7 +273,7 @@ describe('getBounds', function () expect(bounds.height).to.equal(10); }); - it('should register correct bounds of invisible Container', function () + it('should register correct bounds of invisible Container', () => { const parent = new Container(); @@ -297,7 +297,7 @@ describe('getBounds', function () expect(bounds.height).to.equal(10); }); - it('should register correct width/height with Container masked child', function () + it('should register correct width/height with Container masked child', () => { const parent = new Container(); @@ -334,7 +334,7 @@ describe('getBounds', function () expect(bounds.height).to.equal(7); }); - it('should register correct width/height with an a DisplayObject parent has moved', function () + it('should register correct width/height with an a DisplayObject parent has moved', () => { const parent = new Container(); @@ -359,7 +359,7 @@ describe('getBounds', function () expect(bounds.height).to.equal(20); }); - it('should register correct width/height with a Text Object', function () + it('should register correct width/height with a Text Object', () => { const parent = new Container(); @@ -387,7 +387,7 @@ describe('getBounds', function () expect(bounds.width).to.not.equal(bx); }); - it('should return a different rectangle if getting local bounds after global bounds ', function () + it('should return a different rectangle if getting local bounds after global bounds ', () => { const parent = new Container(); const texture = RenderTexture.create(10, 10); @@ -416,10 +416,13 @@ describe('getBounds', function () expect(localBounds.height).to.equal(10); }); - it('should ensure bounds respect the trim of a texture ', function () + it('should ensure bounds respect the trim of a texture ', () => { const parent = new Container(); - const baseTexture = new BaseRenderTexture(100, 100); + const baseTexture = new BaseRenderTexture({ + width: 100, + height: 100, + }); const orig = new Rectangle(0, 0, 100, 50); const frame = new Rectangle(2, 2, 50, 50); diff --git a/tools/integration-tests/test/Container.tests.ts b/tools/integration-tests/test/Container.tests.ts index c50fea3e6e..cd81b2dfd1 100644 --- a/tools/integration-tests/test/Container.tests.ts +++ b/tools/integration-tests/test/Container.tests.ts @@ -6,11 +6,11 @@ import { expect } from 'chai'; import '@pixi/canvas-display'; -describe('Container', function () +describe('Container', () => { - describe('addChild', function () + describe('addChild', () => { - it('should recalculate added child correctly', function () + it('should recalculate added child correctly', () => { const parent = new Container(); const container = new Container(); @@ -37,9 +37,9 @@ describe('Container', function () }); }); - describe('removeChild', function () + describe('removeChild', () => { - it('should recalculate removed child correctly', function () + it('should recalculate removed child correctly', () => { const parent = new Container(); const container = new Container(); @@ -61,9 +61,9 @@ describe('Container', function () }); }); - describe('width', function () + describe('width', () => { - it('should reflect scale', function () + it('should reflect scale', () => { const container = new Container(); const graphics = new Graphics(); @@ -75,7 +75,7 @@ describe('Container', function () expect(container.width).to.be.equals(20); }); - it('should adjust scale', function () + it('should adjust scale', () => { const container = new Container(); const graphics = new Graphics(); @@ -90,9 +90,9 @@ describe('Container', function () }); }); - describe('height', function () + describe('height', () => { - it('should reflect scale', function () + it('should reflect scale', () => { const container = new Container(); const graphics = new Graphics(); @@ -104,7 +104,7 @@ describe('Container', function () expect(container.height).to.be.equals(20); }); - it('should adjust scale', function () + it('should adjust scale', () => { const container = new Container(); const graphics = new Graphics(); @@ -119,13 +119,14 @@ describe('Container', function () }); }); - describe('calculateBounds', function () + describe('calculateBounds', () => { - function createSquareContainer(x1, y1, x2, y2) + function createSquareContainer(x1: number, y1: number, x2: number, y2: number) { const container = new Container(); - container._calculateBounds = function () + // eslint-disable-next-line func-names + container['_calculateBounds'] = function () { this._bounds.addFrame(Transform.IDENTITY, x1, y1, x2, y2); }; @@ -133,7 +134,7 @@ describe('Container', function () return container; } - it('should take into account mask bounds after mask is set', function () + it('should take into account mask bounds after mask is set', () => { const maskedObject = createSquareContainer(1, 15, 11, 31); const parentContainer = new Container(); diff --git a/tools/integration-tests/test/DisplayObject.tests.ts b/tools/integration-tests/test/DisplayObject.tests.ts index 415102b451..d2f115c351 100644 --- a/tools/integration-tests/test/DisplayObject.tests.ts +++ b/tools/integration-tests/test/DisplayObject.tests.ts @@ -4,13 +4,15 @@ import { expect } from 'chai'; import '@pixi/canvas-display'; -describe('DisplayObject', function () +describe('DisplayObject', () => { - describe('mask', function () + describe('mask', () => { - it('should change `renderable` field of maskedObject if we use MaskData', function () + it('should change `renderable` field of maskedObject if we use MaskData', () => { + // @ts-expect-error - Instantiating DisplayObject const maskedObject = new DisplayObject(); + // @ts-expect-error - Instantiating DisplayObject const maskObject = new DisplayObject(); maskedObject.mask = new MaskData(maskObject); diff --git a/tools/integration-tests/test/getLocalBounds.tests.ts b/tools/integration-tests/test/getLocalBounds.tests.ts index be71f7ea7a..9b17af2559 100644 --- a/tools/integration-tests/test/getLocalBounds.tests.ts +++ b/tools/integration-tests/test/getLocalBounds.tests.ts @@ -17,14 +17,14 @@ CanvasRenderer.registerPlugin('sprite', CanvasSpriteRenderer); CanvasRenderer.registerPlugin('graphics', CanvasGraphicsRenderer); CanvasRenderer.registerPlugin('mesh', CanvasMeshRenderer); -function withGL(fn) +function withGL(fn: () => void) { return !process.env.DISABLE_WEBGL ? fn : undefined; } -describe('getLocalBounds', function () +describe('getLocalBounds', () => { - it('should register correct local-bounds with a LOADED Sprite', function () + it('should register correct local-bounds with a LOADED Sprite', () => { const parent = new Container(); const texture = RenderTexture.create(10, 10); @@ -54,7 +54,7 @@ describe('getLocalBounds', function () expect(bounds.height).to.equal(10); }); - it('should register correct local-bounds with Graphics', function () + it('should register correct local-bounds with Graphics', () => { const parent = new Container(); @@ -72,7 +72,7 @@ describe('getLocalBounds', function () expect(bounds.height).to.equal(20); }); - it('should register correct local-bounds with Graphics after clear', function () + it('should register correct local-bounds with Graphics after clear', () => { const parent = new Container(); @@ -102,7 +102,7 @@ describe('getLocalBounds', function () expect(bounds.height).to.equal(10); }); - it('should register correct local-bounds with Graphics after generateCanvasTexture and clear', function () + it('should register correct local-bounds with Graphics after generateCanvasTexture and clear', () => { const parent = new Container(); @@ -134,7 +134,7 @@ describe('getLocalBounds', function () expect(bounds.height).to.equal(10); }); - it('should register correct local-bounds with an empty Container', function () + it('should register correct local-bounds with an empty Container', () => { const parent = new Container(); @@ -150,7 +150,7 @@ describe('getLocalBounds', function () expect(bounds.height).to.equal(0); }); - it('should register correct local-bounds with an item that has already had its parent Container transformed', function () + it('should register correct local-bounds with an item that has already had its parent Container transformed', () => { const parent = new Container(); @@ -172,7 +172,7 @@ describe('getLocalBounds', function () expect(bounds.height).to.equal(10); }); - it('should register correct local-bounds with a Mesh', withGL(function () + it('should register correct local-bounds with a Mesh', withGL(() => { const parent = new Container(); @@ -193,7 +193,7 @@ describe('getLocalBounds', function () expect(bounds.height).to.equal(10); })); - it('should register correct local-bounds with a cachAsBitmap item inside after a render', function () + it('should register correct local-bounds with a cachAsBitmap item inside after a render', () => { const parent = new Container(); @@ -206,8 +206,12 @@ describe('getLocalBounds', function () parent.addChild(graphic); - const renderer = new CanvasRenderer(100, 100); + const renderer = new CanvasRenderer({ + width: 100, + height: 100, + }); + // @ts-expect-error --- renderer.sayHello = () => { /* empty */ }; renderer.render(parent); @@ -219,7 +223,7 @@ describe('getLocalBounds', function () expect(bounds.height).to.equal(100); }); - it('should register correct local-bounds with a Text', function () + it('should register correct local-bounds with a Text', () => { const text = new Text('hello'); const bounds = text.getLocalBounds(); diff --git a/tsconfig.build.json b/tsconfig.build.json new file mode 100644 index 0000000000..d95c0ca931 --- /dev/null +++ b/tsconfig.build.json @@ -0,0 +1,41 @@ +{ + "compilerOptions": { + "target": "es5", + "allowJs": false, + "sourceMap": true, + "removeComments": false, + "strict": true, + "noImplicitAny": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "strictNullChecks": false, + "allowSyntheticDefaultImports": true, + "moduleResolution": "node", + "resolveJsonModule": true, + "baseUrl": "./", + "paths": { + "@pixi/*": [ + "packages/*/src" + ], + "pixi.js": [ + "bundles/pixi.js/src" + ], + "pixi.js-legacy": [ + "bundles/pixi.js-legacy/src" + ] + }, + "outDir": "./out", + "declaration": true + }, + "exclude": [ + "node_modules", + "**/dist/**", + "**/lib/**", + "**/scripts/**", + "**/test/**", + "**/types/**", + "bundles/**/*.d.ts", + "rollup.config.js" + ] +} diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json new file mode 100644 index 0000000000..1f2c04ea4e --- /dev/null +++ b/tsconfig.eslint.json @@ -0,0 +1,20 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "target": "es6", + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "module": "commonjs", + "baseUrl": "./", + "paths": { + "@pixi/*": [ + "packages/*/src" + ] + }, + }, + "exclude": [ + "node_modules", + "**/dist/**", + "**/lib/**" + ] +} diff --git a/tsconfig.json b/tsconfig.json index 971e031a25..a32c5a94e7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,12 +13,11 @@ "allowSyntheticDefaultImports": true, "moduleResolution": "node", "resolveJsonModule": true, + "downlevelIteration": true, "baseUrl": "./", "paths": { "@pixi/*": [ - "packages/*/src", - "packages/filters/*/src", - "packages/canvas/*/src" + "packages/*/src" ], "pixi.js": [ "bundles/pixi.js/src" @@ -34,11 +33,8 @@ "node_modules", "**/dist/**", "**/lib/**", - "**/test/**", - "**/scripts/**", - "**/types/**", "bundles/**/*.d.ts", - "rollup.config.js" + "**/out/**" ], "ts-node": { "files": true, diff --git a/tsconfig.tests.json b/tsconfig.tests.json index 70f2865d45..1b88153bdb 100644 --- a/tsconfig.tests.json +++ b/tsconfig.tests.json @@ -8,9 +8,7 @@ "baseUrl": "./", "paths": { "@pixi/*": [ - "packages/*/src", - "packages/filters/*/src", - "packages/canvas/*/src" + "packages/*/src" ] }, }, diff --git a/webdoc.conf.json b/webdoc.conf.json index bd8d999c9e..161ed4aeb5 100644 --- a/webdoc.conf.json +++ b/webdoc.conf.json @@ -5,9 +5,7 @@ "source": { "include": [ "packages/*/src/**/*.ts", - "bundles/pixi.js/src/*.ts", - "packages/filters/*/src/**/*.(ts)", - "packages/canvas/*/src/**/*.(ts)"], + "bundles/pixi.js/src/*.ts"], "excludePattern": "(node_modules|lib|test)" }, "plugins": [