@safe-engine/pixi 8.4.7 → 8.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/README.md +17 -25
  2. package/dist/app.d.ts.map +1 -1
  3. package/dist/app.js +0 -23
  4. package/dist/box2d-wasm/ContactListener.d.ts +1 -1
  5. package/dist/box2d-wasm/ContactListener.d.ts.map +1 -1
  6. package/dist/box2d-wasm/ContactListener.js +50 -18
  7. package/dist/box2d-wasm/PhysicsComponent.d.ts +27 -30
  8. package/dist/box2d-wasm/PhysicsComponent.d.ts.map +1 -1
  9. package/dist/box2d-wasm/PhysicsComponent.js +44 -11
  10. package/dist/box2d-wasm/PhysicsSprite.d.ts +3 -0
  11. package/dist/box2d-wasm/PhysicsSprite.d.ts.map +1 -1
  12. package/dist/box2d-wasm/PhysicsSprite.js +24 -3
  13. package/dist/box2d-wasm/PhysicsSystem.d.ts +5 -3
  14. package/dist/box2d-wasm/PhysicsSystem.d.ts.map +1 -1
  15. package/dist/box2d-wasm/PhysicsSystem.js +135 -45
  16. package/dist/collider/CollideComponent.d.ts +27 -10
  17. package/dist/collider/CollideComponent.d.ts.map +1 -1
  18. package/dist/collider/CollideComponent.js +10 -12
  19. package/dist/collider/helper/Intersection.d.ts +6 -6
  20. package/dist/collider/helper/Intersection.d.ts.map +1 -1
  21. package/dist/collider/helper/Intersection.js +4 -4
  22. package/dist/collider/index.d.ts +1 -0
  23. package/dist/collider/index.d.ts.map +1 -1
  24. package/dist/collider/index.js +1 -0
  25. package/dist/components/NodeComp.d.ts +62 -36
  26. package/dist/components/NodeComp.d.ts.map +1 -1
  27. package/dist/components/NodeComp.js +18 -99
  28. package/dist/core/Color.d.ts.map +1 -1
  29. package/dist/dragonbones/DragonBonesComponent.d.ts +3 -2
  30. package/dist/dragonbones/DragonBonesComponent.d.ts.map +1 -1
  31. package/dist/dragonbones/DragonBonesComponent.js +1 -1
  32. package/dist/dragonbones/DragonBonesSystem.js +2 -2
  33. package/dist/gui/GUISystem.d.ts.map +1 -1
  34. package/dist/gui/GUISystem.js +5 -6
  35. package/dist/helper/utils.d.ts +0 -6
  36. package/dist/helper/utils.d.ts.map +1 -1
  37. package/dist/helper/utils.js +0 -12
  38. package/dist/index.d.ts +0 -5
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +0 -5
  41. package/dist/norender/NoRenderComponent.d.ts +5 -1
  42. package/dist/norender/NoRenderComponent.d.ts.map +1 -1
  43. package/dist/norender/NoRenderSystem.d.ts.map +1 -1
  44. package/dist/norender/NoRenderSystem.js +8 -9
  45. package/dist/render/RenderComponent.d.ts +6 -17
  46. package/dist/render/RenderComponent.d.ts.map +1 -1
  47. package/dist/render/RenderComponent.js +26 -18
  48. package/dist/spine/lib/require-shim.d.ts.map +1 -1
  49. package/dist/spine/lib/require-shim.js +1 -1
  50. package/package.json +6 -7
  51. package/.github/workflows/npm-publish.yml +0 -35
  52. package/src/app.ts +0 -91
  53. package/src/base/EnhancedComponent.ts +0 -38
  54. package/src/base/gworld.ts +0 -20
  55. package/src/base/index.ts +0 -14
  56. package/src/base/utils.ts +0 -23
  57. package/src/box2d-wasm/ContactListener.ts +0 -66
  58. package/src/box2d-wasm/PhysicsComponent.ts +0 -83
  59. package/src/box2d-wasm/PhysicsSprite.ts +0 -42
  60. package/src/box2d-wasm/PhysicsSystem.ts +0 -142
  61. package/src/box2d-wasm/debugDraw.ts +0 -249
  62. package/src/box2d-wasm/index.ts +0 -19
  63. package/src/collider/CollideComponent.ts +0 -257
  64. package/src/collider/CollideSystem.ts +0 -166
  65. package/src/collider/helper/Intersection.ts +0 -139
  66. package/src/collider/helper/utils.ts +0 -37
  67. package/src/collider/index.ts +0 -16
  68. package/src/components/BaseComponent.ts +0 -17
  69. package/src/components/NodeComp.ts +0 -442
  70. package/src/components/Scene.ts +0 -17
  71. package/src/core/Color.ts +0 -7
  72. package/src/core/LoadingBar.ts +0 -63
  73. package/src/core/NodePool.ts +0 -28
  74. package/src/core/Size.ts +0 -21
  75. package/src/core/Vec2.ts +0 -108
  76. package/src/core/director.ts +0 -11
  77. package/src/core/index.ts +0 -7
  78. package/src/core/loader.ts +0 -14
  79. package/src/core/math.ts +0 -22
  80. package/src/dragonbones/DragonBonesComponent.ts +0 -32
  81. package/src/dragonbones/DragonBonesSystem.ts +0 -35
  82. package/src/dragonbones/index.ts +0 -11
  83. package/src/gui/GUIComponent.ts +0 -155
  84. package/src/gui/GUISystem.ts +0 -125
  85. package/src/helper/utils.ts +0 -50
  86. package/src/index.ts +0 -21
  87. package/src/norender/NoRenderComponent.ts +0 -60
  88. package/src/norender/NoRenderSystem.ts +0 -67
  89. package/src/norender/Touch.ts +0 -37
  90. package/src/planck/PhysicsComponent.ts +0 -83
  91. package/src/planck/PhysicsSprite.ts +0 -43
  92. package/src/planck/PhysicsSystem.ts +0 -201
  93. package/src/planck/index.ts +0 -3
  94. package/src/render/RenderComponent.ts +0 -132
  95. package/src/render/RenderSystem.ts +0 -64
  96. package/src/richtext/RichTextComp.ts +0 -50
  97. package/src/richtext/RichTextSystem.ts +0 -26
  98. package/src/richtext/html-text-parser.ts +0 -87
  99. package/src/richtext/index.ts +0 -8
  100. package/src/spine/SpineComponent.ts +0 -18
  101. package/src/spine/SpineSystem.ts +0 -30
  102. package/src/spine/index.ts +0 -11
  103. package/src/spine/lib/BatchableSpineSlot.ts +0 -138
  104. package/src/spine/lib/Spine.ts +0 -894
  105. package/src/spine/lib/SpineDebugRenderer.ts +0 -615
  106. package/src/spine/lib/SpinePipe.ts +0 -203
  107. package/src/spine/lib/SpineTexture.ts +0 -143
  108. package/src/spine/lib/assets/atlasLoader.ts +0 -158
  109. package/src/spine/lib/assets/skeletonLoader.ts +0 -81
  110. package/src/spine/lib/darktint/DarkTintBatchGeometry.ts +0 -92
  111. package/src/spine/lib/darktint/DarkTintBatcher.ts +0 -186
  112. package/src/spine/lib/darktint/DarkTintShader.ts +0 -74
  113. package/src/spine/lib/darktint/darkTintBit.ts +0 -77
  114. package/src/spine/lib/index.ts +0 -43
  115. package/src/spine/lib/require-shim.ts +0 -43
  116. package/tsconfig.json +0 -18
  117. /package/{src/@types → @types}/index.d.ts +0 -0
@@ -1,64 +0,0 @@
1
- import { EventManager, EventTypes, System } from 'entityx-ts'
2
- import { Container, Graphics, Sprite } from 'pixi.js'
3
-
4
- import { NodeComp } from '..'
5
- import { GraphicsRender, MaskRender, NodeRender, SpriteRender } from './RenderComponent'
6
-
7
- export enum SpriteTypes {
8
- SIMPLE,
9
- SLICED,
10
- TILED,
11
- FILLED,
12
- MESH,
13
- ANIMATION,
14
- }
15
-
16
- export class RenderSystem implements System {
17
- configure(event_manager: EventManager) {
18
- event_manager.subscribe(EventTypes.ComponentAdded, NodeRender, ({ entity }) => {
19
- const nodeRenderComp = entity.getComponent(NodeRender)
20
- const node = new Container()
21
- nodeRenderComp.node = entity.assign(new NodeComp(node, entity))
22
- })
23
- event_manager.subscribe(EventTypes.ComponentAdded, SpriteRender, ({ entity, component }) => {
24
- const { spriteFrame } = component.props
25
- // const texture = GameWorld.Instance.assetManager.get<Texture>(spriteFrame)
26
- // console.log('SpriteRender ComponentAdded', component, texture)
27
- const node = Sprite.from(spriteFrame)
28
- // if (type === SpriteTypes.FILLED) {
29
- // // console.log('fillType', fillType)
30
- // const loadingBar = new LoadingBar(fillType, node)
31
- // if (fillRange) loadingBar.progress = fillRange
32
- // if (fillCenter) loadingBar.fillCenter = fillCenter
33
- // component.loadingBar = loadingBar
34
- // // node.setMidpoint(fillCenter)
35
- // }
36
- // node.texture.rotate = 8
37
- component.node = entity.assign(new NodeComp(node, entity))
38
- // component.node.anchorX = 0.5
39
- // component.node.anchorY = 0.5
40
- })
41
- event_manager.subscribe(EventTypes.ComponentAdded, MaskRender, ({ component }) => {
42
- console.log('MaskRender', component)
43
- // const { type, segments, inverted } = maskComp
44
- // const node = new cc.ClippingNode()
45
- // node.setInverted(inverted)
46
- // maskComp.node = ett.assign(new NodeComp(node, ett))
47
- })
48
- event_manager.subscribe(EventTypes.ComponentAdded, GraphicsRender, ({ entity, component }) => {
49
- // const { lineWidth, strokeColor, fillColor } = component.props
50
- // console.log('GraphicsRender', component);
51
- const node = new Graphics()
52
- component.node = entity.assign(new NodeComp(node, entity))
53
- })
54
- event_manager.subscribe(EventTypes.ComponentRemoved, NodeComp, ({ component }) => {
55
- if (component) {
56
- component.instance.removeFromParent()
57
- }
58
- })
59
- }
60
-
61
- // update() {
62
- // throw new Error('Method not implemented.');
63
- // }
64
- }
@@ -1,50 +0,0 @@
1
- import TaggedText from 'pixi-tagged-text-plus'
2
- import { BaseComponentProps } from '..'
3
- import { ComponentX } from '../components/BaseComponent'
4
- import {
5
- generateStringFromStyledElements,
6
- generateStylesFromStyledElements,
7
- parseFontString,
8
- transformToStyledElements,
9
- } from './html-text-parser'
10
-
11
- interface RichTextCompProps extends BaseComponentProps<RichTextComp> {
12
- font?: string
13
- string?: string
14
- size?: number
15
- }
16
-
17
- export class RichTextComp extends ComponentX<RichTextCompProps, TaggedText> {
18
- get string() {
19
- return this.props.string
20
- }
21
-
22
- set string(val: string) {
23
- this.props.string = val
24
- if (!this.node) return
25
- const jObj = parseFontString(val)
26
- const styledOutput = transformToStyledElements(jObj)
27
- const newText = generateStringFromStyledElements(styledOutput)
28
- const styles = generateStylesFromStyledElements(styledOutput)
29
- // console.log(styledOutput)
30
- const wrapped = `<root>${newText}</root>`
31
- this.node.instance.setText(wrapped)
32
- this.node.instance.setTagStyles(styles)
33
- }
34
- get size() {
35
- return this.props.size
36
- }
37
- set size(size: number) {
38
- this.props.size = size
39
- if (!this.node) return
40
- this.node.instance.setStyleForTag('root', { fontSize: size, color: '#fff' })
41
- }
42
- get font() {
43
- return this.props.font
44
- }
45
- set font(font: string) {
46
- this.props.font = font
47
- if (!this.node) return
48
- this.node.instance.setStyleForTag('root', { color: '#fff', fontFamily: font })
49
- }
50
- }
@@ -1,26 +0,0 @@
1
- import { EntityManager, EventManager, EventReceiveCallback, EventTypes, System } from 'entityx-ts'
2
-
3
- import TaggedText from 'pixi-tagged-text-plus'
4
- import { NodeComp } from '..'
5
- import { RichTextComp } from './RichTextComp'
6
-
7
- export class RichTextSystem implements System {
8
- configure(event_manager: EventManager) {
9
- event_manager.subscribe(EventTypes.ComponentAdded, RichTextComp, this.onAddRichTextComp)
10
- }
11
-
12
- private onAddRichTextComp: EventReceiveCallback<RichTextComp> = ({ entity, component }) => {
13
- const { string = '', font = '', size = 64 } = component.props
14
- const node = new TaggedText(string);
15
- // node.defaultStyle = { }
16
- component.node = entity.assign(new NodeComp(node, entity))
17
- component.string = (string)
18
- if (font) component.font = (font)
19
- if (size) component.size = (size)
20
- }
21
-
22
- update(entities: EntityManager, events: EventManager, dt: number)
23
- update() {
24
- // throw new Error('Method not implemented.');
25
- }
26
- }
@@ -1,87 +0,0 @@
1
- interface FontTag {
2
- color?: string;
3
- size?: number;
4
- text: string;
5
- }
6
-
7
- type ParsedResult = FontTag[];
8
-
9
- type StyledElement = {
10
- tag?: string;
11
- style?: { color?: string; size?: number };
12
- text: string;
13
- };
14
-
15
- export function parseFontString(input: string): ParsedResult {
16
- const regex = /<font\s+color=['"](#?[0-9a-fA-F]{6})['"](?:\s+size=(\d+))?>(.*?)<\/font>/gi;
17
- const results: ParsedResult = [];
18
- let lastIndex = 0;
19
-
20
- let match: RegExpExecArray | null;
21
- while ((match = regex.exec(input)) !== null) {
22
- // Add plain text before the match if it exists
23
- if (match.index > lastIndex) {
24
- const plainText = input.slice(lastIndex, match.index)
25
- if (plainText) {
26
- results.push({ text: plainText });
27
- }
28
- }
29
-
30
- const color = match[1];
31
- const size = match[2] ? parseInt(match[2], 10) : undefined;
32
- const text = match[3];
33
-
34
- results.push({ color, size, text });
35
-
36
- lastIndex = regex.lastIndex;
37
- }
38
-
39
- // Add remaining plain text after the last match
40
- if (lastIndex < input.length) {
41
- const plainText = input.slice(lastIndex);
42
- if (plainText) {
43
- results.push({ text: plainText });
44
- }
45
- }
46
-
47
- return results;
48
- }
49
-
50
- export function transformToStyledElements(parsed: ParsedResult): StyledElement[] {
51
- return parsed.map((item, index) => {
52
- if (item.color || item.size) {
53
- return {
54
- tag: `b${index + 1}`,
55
- style: { color: item.color, size: item.size },
56
- text: item.text,
57
- };
58
- }
59
- return {
60
- text: item.text,
61
- };
62
- });
63
- }
64
-
65
- export function generateStringFromStyledElements(elements: StyledElement[]): string {
66
- return elements
67
- .map((element) => {
68
- if (!element.tag) {
69
- return element.text;
70
- }
71
- return `<${element.tag}>${element.text}</${element.tag}>`;
72
- })
73
- .join('');
74
- }
75
-
76
- export function generateStylesFromStyledElements(elements: StyledElement[]) {
77
- const styles = {};
78
- elements
79
- .forEach((element) => {
80
- const { tag, style } = element
81
- if (!tag) {
82
- return;
83
- }
84
- styles[element.tag] = style
85
- })
86
- return styles
87
- }
@@ -1,8 +0,0 @@
1
- import { GameWorld } from '..'
2
- import { RichTextSystem } from './RichTextSystem'
3
- export * from './RichTextComp'
4
-
5
- export function setupRichText() {
6
- GameWorld.Instance.systems.add(RichTextSystem)
7
- GameWorld.Instance.systems.configureOnce(RichTextSystem)
8
- }
@@ -1,18 +0,0 @@
1
- import { BaseComponentProps } from '..'
2
- import { ComponentX } from '../components/BaseComponent'
3
- import { Spine } from './lib'
4
-
5
- interface SpineData {
6
- atlas: string
7
- skeleton: string
8
- texture?: string
9
- }
10
-
11
- interface SpineSkeletonProps extends BaseComponentProps<SpineSkeleton> {
12
- data: SpineData
13
- skin?: string
14
- animation?: string
15
- timeScale?: number
16
- loop?: boolean
17
- }
18
- export class SpineSkeleton extends ComponentX<SpineSkeletonProps, Spine> {}
@@ -1,30 +0,0 @@
1
- import { EventManager, EventTypes, System } from 'entityx-ts'
2
- import { Spine } from './lib'
3
-
4
- import { NodeComp } from '../components/NodeComp'
5
- import { SpineSkeleton } from './SpineComponent'
6
-
7
- export class SpineSystem implements System {
8
- configure(event_manager: EventManager) {
9
- event_manager.subscribe(EventTypes.ComponentAdded, SpineSkeleton, ({ entity, component }) => {
10
- // console.log('SpineSkeleton', component)
11
- // const spine = entity.getComponent(SpineSkeleton)
12
- const { data, skin, animation, loop, timeScale } = component.props
13
- const node = Spine.from(data)
14
- // node.skeleton.scaleY = -1
15
- if (skin) {
16
- node.skeleton.setSkinByName(skin)
17
- }
18
- if (animation) {
19
- node.state.setAnimation(0, animation, loop)
20
- }
21
- if (timeScale) {
22
- node.state.timeScale = timeScale
23
- }
24
- component.node = entity.assign(new NodeComp(node, entity))
25
- })
26
- }
27
- // update() {
28
- // throw new Error('Method not implemented.');
29
- // }
30
- }
@@ -1,11 +0,0 @@
1
- import { GameWorld } from '..'
2
- import { SpineSystem } from './SpineSystem'
3
-
4
- export * from './SpineComponent'
5
- export * from './SpineSystem'
6
-
7
- export function setupSpine() {
8
- GameWorld.Instance.systems.add(SpineSystem)
9
- // GameWorld.Instance.listUpdate.push(SpineSystem)
10
- GameWorld.Instance.systems.configureOnce(SpineSystem)
11
- }
@@ -1,138 +0,0 @@
1
- /** ****************************************************************************
2
- * Spine Runtimes License Agreement
3
- * Last updated July 28, 2023. Replaces all prior versions.
4
- *
5
- * Copyright (c) 2013-2023, Esoteric Software LLC
6
- *
7
- * Integration of the Spine Runtimes into software or otherwise creating
8
- * derivative works of the Spine Runtimes is permitted under the terms and
9
- * conditions of Section 2 of the Spine Editor License Agreement:
10
- * http://esotericsoftware.com/spine-editor-license
11
- *
12
- * Otherwise, it is permitted to integrate the Spine Runtimes into software or
13
- * otherwise create derivative works of the Spine Runtimes (collectively,
14
- * "Products"), provided that each user of the Products must obtain their own
15
- * Spine Editor license and redistribution of the Products in any form must
16
- * include this license and copyright notice.
17
- *
18
- * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
19
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
- * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
22
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
24
- * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
25
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
27
- * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
- *****************************************************************************/
29
-
30
- import { AttachmentCacheData, Spine } from './Spine.js';
31
-
32
- import type { Batch, Batcher, BLEND_MODES, DefaultBatchableMeshElement, Matrix, Texture, Topology } from 'pixi.js';
33
-
34
- export class BatchableSpineSlot implements DefaultBatchableMeshElement {
35
- indexOffset = 0;
36
- attributeOffset = 0;
37
-
38
- indexSize!: number;
39
- attributeSize!: number;
40
-
41
- batcherName = 'darkTint';
42
-
43
- topology: Topology = 'triangle-list';
44
-
45
- readonly packAsQuad = false;
46
-
47
- renderable!: Spine;
48
-
49
- positions!: Float32Array;
50
- indices!: number[] | Uint16Array;
51
- uvs!: Float32Array;
52
-
53
- roundPixels!: 0 | 1;
54
- data!: AttachmentCacheData;
55
- blendMode!: BLEND_MODES;
56
-
57
- darkTint!: number;
58
-
59
- texture!: Texture;
60
-
61
- transform!: Matrix;
62
-
63
- // used internally by batcher specific. Stored for efficient updating.
64
- _textureId!: number;
65
- _attributeStart!: number;
66
- _indexStart!: number;
67
- _batcher!: Batcher;
68
- _batch!: Batch;
69
-
70
-
71
- get color () {
72
- const slotColor = this.data.color;
73
-
74
- const parentColor: number = this.renderable.groupColor;
75
- const parentAlpha: number = this.renderable.groupAlpha;
76
- let abgr: number;
77
-
78
- const mixedA = (slotColor.a * parentAlpha) * 255;
79
-
80
- if (parentColor !== 0xFFFFFF) {
81
- const parentB = (parentColor >> 16) & 0xFF;
82
- const parentG = (parentColor >> 8) & 0xFF;
83
- const parentR = parentColor & 0xFF;
84
-
85
- const mixedR = (slotColor.r * parentR);
86
- const mixedG = (slotColor.g * parentG);
87
- const mixedB = (slotColor.b * parentB);
88
-
89
- abgr = ((mixedA) << 24) | (mixedB << 16) | (mixedG << 8) | mixedR;
90
- }
91
- else {
92
- abgr = ((mixedA) << 24) | ((slotColor.b * 255) << 16) | ((slotColor.g * 255) << 8) | (slotColor.r * 255);
93
- }
94
-
95
- return abgr;
96
- }
97
-
98
- get darkColor () {
99
- const darkColor = this.data.darkColor;
100
- return ((darkColor.b * 255) << 16) | ((darkColor.g * 255) << 8) | (darkColor.r * 255);
101
- }
102
-
103
- get groupTransform () { return this.renderable.groupTransform; }
104
-
105
- setData (
106
- renderable: Spine,
107
- data: AttachmentCacheData,
108
- blendMode: BLEND_MODES,
109
- roundPixels: 0 | 1) {
110
- this.renderable = renderable;
111
- this.transform = renderable.groupTransform;
112
- this.data = data;
113
-
114
- if (data.clipped) {
115
- const clippedData = data.clippedData;
116
-
117
- this.indexSize = clippedData!.indicesCount;
118
- this.attributeSize = clippedData!.vertexCount;
119
- this.positions = clippedData!.vertices;
120
- this.indices = clippedData!.indices;
121
- this.uvs = clippedData!.uvs;
122
- }
123
- else {
124
- this.indexSize = data.indices.length;
125
- this.attributeSize = data.vertices.length / 2;
126
- this.positions = data.vertices;
127
- this.indices = data.indices;
128
- this.uvs = data.uvs;
129
- }
130
-
131
- this.texture = data.texture;
132
- this.roundPixels = roundPixels;
133
-
134
- this.blendMode = blendMode;
135
-
136
- this.batcherName = data.darkTint ? 'darkTint' : 'default';
137
- }
138
- }