Skip to content

Commit

Permalink
Update rollup-plugin-ts, rearrange source so that .d.ts output works.
Browse files Browse the repository at this point in the history
andrewstart committed Apr 3, 2020
1 parent 204f107 commit 4fe3cbe
Showing 17 changed files with 472 additions and 278 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ https://pixijs.io/pixi-animate/
Using the legacy bundle file `dist/pixi-animate-legacy.js` (requires `PIXI` namespace to be set up) will restore the removed functionality so that assets published for the previous version of PixiAnimate will work correctly.

Changes that the legacy build doesn't account for:
* `load()` no longer has so many variants allowed. Instead, the first argument is always the scene that you want to load, followed by either a callback or an options object. If using the legacy shim, pass in the constructor for the main scene MovieClip, as you did in v1.
* `load()` no longer has so many variants allowed. Instead, the first argument is always the scene that you want to load, followed by either a callback or an options object. If using the legacy build, pass in the constructor for the main scene MovieClip, as you did in v1.
* `createInstance` now defaults to false, instead of true, when calling `load()`.

### Asset changes
641 changes: 415 additions & 226 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@
"rollup-plugin-jscc": "^1.0.0",
"rollup-plugin-node-resolve": "^4.0.1",
"rollup-plugin-sourcemaps": "^0.4.2",
"rollup-plugin-ts": "^1.2.14",
"rollup-plugin-ts": "^1.2.23",
"semver": "^5.3.0",
"terser": "^3.16.1",
"tslib": "^1.9.3",
@@ -55,8 +55,8 @@
"prebuild": "npm run lint",
"build": "tsc && rollup -c && npm run build:min && npm run build:dts",
"build:min": "npm run build:min:bundle && npm run build:min:legacy",
"build:min:bundle":"terser dist/pixi-animate.js -c -m -o dist/pixi-animate.min.js --source-map \"content='dist/pixi-animate.js.map',includeSources=true,filename='dist/pixi-animate.min.js.map',url='pixi-animate.min.js.map'\" --comments \"/pixi-animate.js - /\"",
"build:min:legacy":"terser dist/pixi-animate-legacy.js -c -m -o dist/pixi-animate-legacy.min.js --source-map \"content='dist/pixi-animate-legacy.js.map',includeSources=true,filename='dist/pixi-animate-legacy.min.js.map',url='pixi-animate-legacy.min.js.map'\" --comments \"/pixi-animate-legacy.js - /\"",
"build:min:bundle": "terser dist/pixi-animate.js -c -m -o dist/pixi-animate.min.js --source-map \"content='dist/pixi-animate.js.map',includeSources=true,filename='dist/pixi-animate.min.js.map',url='pixi-animate.min.js.map'\" --comments \"/pixi-animate.js - /\"",
"build:min:legacy": "terser dist/pixi-animate-legacy.js -c -m -o dist/pixi-animate-legacy.min.js --source-map \"content='dist/pixi-animate-legacy.js.map',includeSources=true,filename='dist/pixi-animate-legacy.min.js.map',url='pixi-animate-legacy.min.js.map'\" --comments \"/pixi-animate-legacy.js - /\"",
"build:dts": "node scripts/buildAmbientTypes.js",
"test": "floss --path tests/index.js",
"coverage": "nyc npm test",
18 changes: 13 additions & 5 deletions src/AnimateAsset.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
import * as Animate from './';
import { MovieClip, AnimateContainer, AnimateGraphics, AnimateText, AnimateSprite, DrawCommands } from './animate';
import { Texture, Spritesheet } from 'pixi.js';

interface PixiAnimate {
Movieclip: typeof MovieClip;
Container: typeof AnimateContainer;
Graphics: typeof AnimateGraphics;
Text: typeof AnimateText;
Sprite: typeof AnimateSprite;
}

/**
* The format of the output javascript file when publishing a scene.
*/
export interface AnimateAsset {
/**
* Constructor for the root MovieClip. Is null before setup() is run.
*/
stage: new () => Animate.MovieClip;
stage: new () => MovieClip;
/**
* Background color of the scene, as defined when the asset is published.
*/
@@ -37,13 +45,13 @@ export interface AnimateAsset {
* Dictionary of display object constructors used within this scene. This is an empty object
* before setup() is run, but can be overwritten with a shared library dictionary (before setup() is run).
*/
lib: { [id: string]: (new () => (Animate.MovieClip|Animate.Container))};
lib: { [id: string]: (new () => (MovieClip|AnimateContainer))};
/**
* Dictionary of loaded shape instructions for this scene. This is intially an empty object that
* can be filled by animate.load(), or by a custom loading system. It must be filled before
* any items are instantiated.
*/
shapes: { [id: string]: Animate.DrawCommands[] };
shapes: { [id: string]: DrawCommands[] };
/**
* Dictionary of loaded individual images for this scene.This is intially an empty object that
* will be filled by animate.load(). It will be used by the animate.load() method for
@@ -65,5 +73,5 @@ export interface AnimateAsset {
* Creates classes for each Container and MovieClip within the scene, filling data.lib and
* setting data.stage.
*/
setup: (animate: typeof Animate) => void;
setup: (animate: PixiAnimate) => void;
}
2 changes: 1 addition & 1 deletion src/mixins/Container.ts → src/animate/Container.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Container, filters, Graphics, Sprite } from 'pixi.js';
import { utils_ns as utils } from '../animate/utils';
import { utils } from './utils';
// Color Matrix filter
let ColorMatrixFilter: typeof filters.ColorMatrixFilter;

5 changes: 0 additions & 5 deletions src/mixins/index.ts → src/animate/DisplayObject.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
export * from './Container';
export * from './Sprite';
export * from './Graphics';
export * from './Text';

import { AnimateContainer } from './Container';
import { AnimateSprite } from './Sprite';
import { AnimateGraphics } from './Graphics';
2 changes: 1 addition & 1 deletion src/mixins/Graphics.ts → src/animate/Graphics.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Graphics, filters, Sprite } from 'pixi.js';
import { utils_ns as utils } from '../animate/utils';
import { utils } from './utils';
// Color Matrix filter
let ColorMatrixFilter: typeof filters.ColorMatrixFilter;

5 changes: 3 additions & 2 deletions src/animate/MovieClip.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Timeline } from './Timeline';
import { TweenProps, EaseMethod } from './Tween';
import { utils_ns as utils } from './utils';
import { utils } from './utils';
import { sound } from './sound';
import { AnimateContainer, AnimateDisplayObject } from '../mixins';
import { AnimateContainer } from './Container';
import { AnimateDisplayObject } from './DisplayObject';
import { Ticker, settings, Graphics, Sprite /* , IDestroyOptions */ } from 'pixi.js';
const SharedTicker = Ticker.shared;

2 changes: 1 addition & 1 deletion src/mixins/Sprite.ts → src/animate/Sprite.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Sprite, filters, Graphics } from 'pixi.js';
import { utils_ns as utils } from '../animate/utils';
import { utils } from './utils';
// Color Matrix filter
let ColorMatrixFilter: typeof filters.ColorMatrixFilter;

2 changes: 1 addition & 1 deletion src/mixins/Text.ts → src/animate/Text.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Text, filters, Graphics, Sprite } from 'pixi.js';
import { utils_ns as utils } from '../animate/utils';
import { utils } from './utils';
// Color Matrix filter
let ColorMatrixFilter: typeof filters.ColorMatrixFilter;

2 changes: 1 addition & 1 deletion src/animate/Timeline.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Tween, TweenProps, EaseMethod } from './Tween';
import { AnimateDisplayObject } from '../mixins';
import { AnimateDisplayObject } from './DisplayObject';

/**
* The Timeline class represents a series of tweens, tied to keyframes.
2 changes: 1 addition & 1 deletion src/animate/Tween.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AnimateDisplayObject } from '../mixins';
import { AnimateDisplayObject } from './DisplayObject';
import { Graphics, Sprite } from 'pixi.js';

export type EaseMethod = (input: number) => number;
26 changes: 14 additions & 12 deletions src/animate/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
export { load } from './load';
export { sound } from './sound';
// eslint-disable-next-line @typescript-eslint/camelcase
export { utils_ns as utils } from './utils';
export { MovieClip } from './MovieClip';
export { Scene } from './Scene';
export { Timeline } from './Timeline';
export { Tween } from './Tween';
export { Animator } from './Animator';
export { AnimatorTimeline } from './AnimatorTimeline';

export const VERSION = '__VERSION__';
export * from './load';
export * from './sound';
export * from './utils';
export * from './MovieClip';
export * from './Scene';
export * from './Timeline';
export * from './Tween';
export * from './Animator';
export * from './AnimatorTimeline';
export * from './Container';
export * from './Sprite';
export * from './Graphics';
export * from './Text';
export * from './DisplayObject';
4 changes: 2 additions & 2 deletions src/animate/load.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Loader, LoaderResource, Container } from 'pixi.js';
import { AnimateAsset } from '../AnimateAsset';
import { MovieClip } from './MovieClip';
import { DrawCommands } from '../mixins';
import { utils_ns as utils } from './utils';
import { DrawCommands } from './Graphics';
import { utils } from './utils';

type Complete = (instance: MovieClip|null, loader: Loader) => void;
export interface LoadOptions {
6 changes: 3 additions & 3 deletions src/animate/utils.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { DrawCommands } from '../mixins';
import { DrawCommands } from './Graphics';
import { TweenProps } from './Tween';
import { MovieClip } from './MovieClip';
import { DisplayObject, Renderer, Prepare } from 'pixi.js';

// If the movieclip plugin is installed
let _prepare: Prepare = null;

/* eslint-disable @typescript-eslint/camelcase, @typescript-eslint/no-namespace, no-inner-declarations */
/* eslint-disable @typescript-eslint/no-namespace, no-inner-declarations */
// awkwardly named instead of the final export of 'utils' to avoid problems in .d.ts build tools.
export namespace utils_ns {
export namespace utils {

/**
* Convert the Hexidecimal string (e.g., "#fff") to uint
15 changes: 12 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
// Because AnimateAsset wants to import the entire library for typing purposes, they are separated
// at this level to try to reduce odd references
export * from './main';
export { load, sound, utils, MovieClip, Scene, Timeline, Tween, Animator, AnimatorTimeline, DrawCommands } from './animate';

export {
AnimateContainer as Container,
AnimateSprite as Sprite,
AnimateGraphics as Graphics,
AnimateText as Text,
AnimateDisplayObject as DisplayObject,
} from './animate';

export const VERSION = '__VERSION__';

export * from './AnimateAsset';
10 changes: 0 additions & 10 deletions src/main.ts

This file was deleted.

0 comments on commit 4fe3cbe

Please sign in to comment.