Skip to content
This repository has been archived by the owner on Jun 28, 2021. It is now read-only.

Commit

Permalink
feat: Add support for commonjs/es module (#92)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Releasing as a breaking change to make sure this doesn't break for any other existing users without any notice. This commit introduces an import for pixi.js to make it work properly in a commonjs/es modules world
  • Loading branch information
mimshwright authored Feb 28, 2020
1 parent 7418d70 commit d1e108c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<link rel="stylesheet" href="style.css" />
<link href="https://fonts.googleapis.com/css?family=Inconsolata" rel="stylesheet">

<script src="https://cdnjs.cloudflare.com/ajax/libs/pixi.js/4.5.6/pixi.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pixi.js/5.2.0/pixi.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/highlight.min.js"></script>
<script src="../dist/pixi-multistyle-text.umd.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
Expand Down
18 changes: 9 additions & 9 deletions src/pixi-multistyle-text.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// <reference types="pixi.js" />
import * as PIXI from "pixi.js";

"use strict";

Expand Down Expand Up @@ -34,14 +34,14 @@ interface TextStyle {
wordWrapWidth?: number;
}

export interface ExtendedTextStyle extends TextStyle {
export interface TextStyleExtended extends TextStyle {
valign?: "top" | "middle" | "bottom" | "baseline" | number;
debug?: boolean;
tagStyle?: "xml" | "bbcode";
}

export interface TextStyleSet {
[key: string]: ExtendedTextStyle;
[key: string]: TextStyleExtended;
}

interface FontProperties {
Expand All @@ -52,7 +52,7 @@ interface FontProperties {

interface TextData {
text: string;
style: ExtendedTextStyle;
style: TextStyleExtended;
width: number;
height: number;
fontProperties: FontProperties;
Expand All @@ -61,7 +61,7 @@ interface TextData {

interface TextDrawingData {
text: string;
style: ExtendedTextStyle;
style: TextStyleExtended;
x: number;
y: number;
width: number;
Expand Down Expand Up @@ -143,7 +143,7 @@ interface TextWithPrivateMembers extends PIXI.Text {
}

export default class MultiStyleText extends PIXI.Text {
private static DEFAULT_TAG_STYLE: ExtendedTextStyle = {
private static DEFAULT_TAG_STYLE: TextStyleExtended = {
align: "left",
breakWords: false,
// debug intentionally not included
Expand Down Expand Up @@ -241,7 +241,7 @@ export default class MultiStyleText extends PIXI.Text {
this.withPrivateMembers().dirty = true;
}

public setTagStyle(tag: string, style: ExtendedTextStyle): void {
public setTagStyle(tag: string, style: TextStyleExtended): void {
if (tag in this.textStyles) {
this.assign(this.textStyles[tag], style);
} else {
Expand Down Expand Up @@ -386,11 +386,11 @@ export default class MultiStyleText extends PIXI.Text {
return outputTextData;
}

private getFontString(style: ExtendedTextStyle): string {
private getFontString(style: TextStyleExtended): string {
return new PIXI.TextStyle(style).toFontString();
}

private createTextData(text: string, style: ExtendedTextStyle, tag: TagData): TextData {
private createTextData(text: string, style: TextStyleExtended, tag: TagData): TextData {
return {
text,
style,
Expand Down

0 comments on commit d1e108c

Please sign in to comment.