From bf0b5a5f2fda54eaf4c1a4f66b97ba26dcb4901d Mon Sep 17 00:00:00 2001 From: cha0s Date: Fri, 22 Nov 2019 02:19:44 -0600 Subject: [PATCH] refactor: PIXI shims --- packages/graphics/shim/pixi/constants.js | 40 +++++++++++++++++++ packages/graphics/shim/pixi/core.js | 13 ++++++ packages/graphics/shim/pixi/display.js | 1 + packages/graphics/shim/pixi/graphics.js | 0 packages/graphics/shim/pixi/pixi.avopack.js | 20 ++++++++++ packages/graphics/shim/pixi/settings/index.js | 4 ++ .../graphics/shim/pixi/settings/settings.js | 6 +++ packages/graphics/shim/pixi/text.js | 0 8 files changed, 84 insertions(+) create mode 100644 packages/graphics/shim/pixi/constants.js create mode 100644 packages/graphics/shim/pixi/core.js create mode 100644 packages/graphics/shim/pixi/display.js create mode 100644 packages/graphics/shim/pixi/graphics.js create mode 100644 packages/graphics/shim/pixi/pixi.avopack.js create mode 100644 packages/graphics/shim/pixi/settings/index.js create mode 100644 packages/graphics/shim/pixi/settings/settings.js create mode 100644 packages/graphics/shim/pixi/text.js diff --git a/packages/graphics/shim/pixi/constants.js b/packages/graphics/shim/pixi/constants.js new file mode 100644 index 0000000..aff4fab --- /dev/null +++ b/packages/graphics/shim/pixi/constants.js @@ -0,0 +1,40 @@ +export const BLEND_MODES = { + NORMAL: 0, + ADD: 1, + MULTIPLY: 2, + SCREEN: 3, + OVERLAY: 4, + DARKEN: 5, + LIGHTEN: 6, + COLOR_DODGE: 7, + COLOR_BURN: 8, + HARD_LIGHT: 9, + SOFT_LIGHT: 10, + DIFFERENCE: 11, + EXCLUSION: 12, + HUE: 13, + SATURATION: 14, + COLOR: 15, + LUMINOSITY: 16, + NORMAL_NPM: 17, + ADD_NPM: 18, + SCREEN_NPM: 19, + NONE: 20, + + SRC_OVER: 0, + SRC_IN: 21, + SRC_OUT: 22, + SRC_ATOP: 23, + DST_OVER: 24, + DST_IN: 25, + DST_OUT: 26, + DST_ATOP: 27, + ERASE: 26, + SUBTRACT: 28, + XOR: 29, +}; + +export const SCALE_MODES = { + NEAREST: 0, + LINEAR: 1, +}; diff --git a/packages/graphics/shim/pixi/core.js b/packages/graphics/shim/pixi/core.js new file mode 100644 index 0000000..c4b4ac7 --- /dev/null +++ b/packages/graphics/shim/pixi/core.js @@ -0,0 +1,13 @@ +export class BaseRenderer {} +export class BaseTexture {} +export class BatchRenderer {} +export class Filter {} +export class Renderer { + + static registerPlugin() {} + +} +export class RenderTexture {} +export class Texture {} + +export const defaultFilterVertex = ''; diff --git a/packages/graphics/shim/pixi/display.js b/packages/graphics/shim/pixi/display.js new file mode 100644 index 0000000..11e8a24 --- /dev/null +++ b/packages/graphics/shim/pixi/display.js @@ -0,0 +1 @@ +export class Container {} diff --git a/packages/graphics/shim/pixi/graphics.js b/packages/graphics/shim/pixi/graphics.js new file mode 100644 index 0000000..e69de29 diff --git a/packages/graphics/shim/pixi/pixi.avopack.js b/packages/graphics/shim/pixi/pixi.avopack.js new file mode 100644 index 0000000..fce15bf --- /dev/null +++ b/packages/graphics/shim/pixi/pixi.avopack.js @@ -0,0 +1,20 @@ +const path = require('path'); + +module.exports = ({options, side}) => { + if ('server' === side) { + const pixiPackages = [ + 'constants', + 'core', + 'display', + 'graphics', + 'settings', + 'text', + ]; + pixiPackages.forEach((pixiPackage) => { + options.resolve.alias[`@pixi/${pixiPackage}`] = path.join( + __dirname, + pixiPackage, + ); + }); + } +}; diff --git a/packages/graphics/shim/pixi/settings/index.js b/packages/graphics/shim/pixi/settings/index.js new file mode 100644 index 0000000..272a366 --- /dev/null +++ b/packages/graphics/shim/pixi/settings/index.js @@ -0,0 +1,4 @@ +import {settings} from './settings'; +export {settings}; + +export const isMobile = settings.isMobile; diff --git a/packages/graphics/shim/pixi/settings/settings.js b/packages/graphics/shim/pixi/settings/settings.js new file mode 100644 index 0000000..9ad92d6 --- /dev/null +++ b/packages/graphics/shim/pixi/settings/settings.js @@ -0,0 +1,6 @@ +export const settings = { + isMobile: { + android: {}, + apple: {}, + }, +}; \ No newline at end of file diff --git a/packages/graphics/shim/pixi/text.js b/packages/graphics/shim/pixi/text.js new file mode 100644 index 0000000..e69de29