@safe-engine/cocos 2.6.5 → 2.6.7
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.
- package/README.md +124 -2
- package/dist/core/NodeComp.d.ts +4 -1
- package/dist/core/NodeComp.d.ts.map +1 -1
- package/dist/core/NodeComp.js +12 -1
- package/dist/dragonbones/db-cocos/SimpleMeshNode.d.ts +1 -1
- package/dist/dragonbones/db-cocos/SimpleMeshNode.d.ts.map +1 -1
- package/dist/gui/GUIComponent.d.ts +1 -0
- package/dist/gui/GUIComponent.d.ts.map +1 -1
- package/dist/gui/GUISystem.js +2 -2
- package/dist/gui/SliderComp.d.ts +16 -0
- package/dist/gui/SliderComp.d.ts.map +1 -0
- package/dist/gui/SliderComp.js +32 -0
- package/dist/render/RenderTextureComp.d.ts +10 -0
- package/dist/render/RenderTextureComp.d.ts.map +1 -0
- package/dist/render/RenderTextureComp.js +13 -0
- package/dist/richtext/RichTextComp.d.ts +1 -0
- package/dist/richtext/RichTextComp.d.ts.map +1 -1
- package/dist/richtext/RichTextSystem.js +4 -4
- package/package.json +3 -3
- package/dist/dragonbones/PixiDragonBonesSprite.d.ts +0 -19
- package/dist/dragonbones/PixiDragonBonesSprite.d.ts.map +0 -1
- package/dist/dragonbones/PixiDragonBonesSprite.js +0 -75
- package/dist/gworld/components/AnimationComponent.d.ts +0 -65
- package/dist/gworld/components/AnimationComponent.d.ts.map +0 -1
- package/dist/gworld/components/AnimationComponent.js +0 -141
- package/dist/gworld/components/CollideComponent.d.ts +0 -64
- package/dist/gworld/components/CollideComponent.d.ts.map +0 -1
- package/dist/gworld/components/CollideComponent.js +0 -269
- package/dist/gworld/components/EnhancedComponent.d.ts +0 -22
- package/dist/gworld/components/EnhancedComponent.d.ts.map +0 -1
- package/dist/gworld/components/EnhancedComponent.js +0 -51
- package/dist/gworld/components/GUIComponent.d.ts +0 -67
- package/dist/gworld/components/GUIComponent.d.ts.map +0 -1
- package/dist/gworld/components/GUIComponent.js +0 -166
- package/dist/gworld/components/NoRenderComponent.d.ts +0 -38
- package/dist/gworld/components/NoRenderComponent.d.ts.map +0 -1
- package/dist/gworld/components/NoRenderComponent.js +0 -81
- package/dist/gworld/components/NodeComp.d.ts +0 -152
- package/dist/gworld/components/NodeComp.d.ts.map +0 -1
- package/dist/gworld/components/NodeComp.js +0 -405
- package/dist/gworld/components/RenderComponent.d.ts +0 -58
- package/dist/gworld/components/RenderComponent.d.ts.map +0 -1
- package/dist/gworld/components/RenderComponent.js +0 -166
- package/dist/gworld/core/NodePool.d.ts +0 -9
- package/dist/gworld/core/NodePool.d.ts.map +0 -1
- package/dist/gworld/core/NodePool.js +0 -30
- package/dist/gworld/core/Scene.d.ts +0 -5
- package/dist/gworld/core/Scene.d.ts.map +0 -1
- package/dist/gworld/core/Scene.js +0 -38
- package/dist/gworld/core/decorator.d.ts +0 -9
- package/dist/gworld/core/decorator.d.ts.map +0 -1
- package/dist/gworld/core/decorator.js +0 -43
- package/dist/gworld/index.d.ts +0 -8
- package/dist/gworld/index.d.ts.map +0 -1
- package/dist/gworld/index.js +0 -43
- package/dist/gworld/systems/AnimationSystem.d.ts +0 -6
- package/dist/gworld/systems/AnimationSystem.d.ts.map +0 -1
- package/dist/gworld/systems/AnimationSystem.js +0 -30
- package/dist/gworld/systems/CollideSystem.d.ts +0 -20
- package/dist/gworld/systems/CollideSystem.d.ts.map +0 -1
- package/dist/gworld/systems/CollideSystem.js +0 -171
- package/dist/gworld/systems/GUISystem.d.ts +0 -15
- package/dist/gworld/systems/GUISystem.d.ts.map +0 -1
- package/dist/gworld/systems/GUISystem.js +0 -123
- package/dist/gworld/systems/NoRenderSystem.d.ts +0 -16
- package/dist/gworld/systems/NoRenderSystem.d.ts.map +0 -1
- package/dist/gworld/systems/NoRenderSystem.js +0 -85
- package/dist/gworld/systems/RenderSystem.d.ts +0 -22
- package/dist/gworld/systems/RenderSystem.d.ts.map +0 -1
- package/dist/gworld/systems/RenderSystem.js +0 -104
- package/dist/helper/NodePool.d.ts +0 -9
- package/dist/helper/NodePool.d.ts.map +0 -1
- package/dist/helper/NodePool.js +0 -29
- package/dist/helper/html-text-parser.d.ts +0 -30
- package/dist/helper/html-text-parser.d.ts.map +0 -1
- package/dist/helper/html-text-parser.js +0 -354
- package/dist/safex.d.ts +0 -10
- package/dist/safex.d.ts.map +0 -1
- package/dist/safex.js +0 -25
- package/dist/spine/CCSkeleton.d.ts +0 -2
- package/dist/spine/CCSkeleton.d.ts.map +0 -1
- package/dist/spine/CCSkeleton.js +0 -344
- package/dist/spine/CCSkeletonAnimation.d.ts +0 -16
- package/dist/spine/CCSkeletonAnimation.d.ts.map +0 -1
- package/dist/spine/CCSkeletonAnimation.js +0 -317
- package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts +0 -2
- package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts.map +0 -1
- package/dist/spine/CCSkeletonCanvasRenderCmd.js +0 -225
- package/dist/spine/CCSkeletonTexture.d.ts +0 -2
- package/dist/spine/CCSkeletonTexture.d.ts.map +0 -1
- package/dist/spine/CCSkeletonTexture.js +0 -62
- package/dist/spine/CCSkeletonWebGLRenderCmd.d.ts +0 -2
- package/dist/spine/CCSkeletonWebGLRenderCmd.d.ts.map +0 -1
- package/dist/spine/CCSkeletonWebGLRenderCmd.js +0 -281
- package/dist/spine/PixiSpineSprite.d.ts +0 -19
- package/dist/spine/PixiSpineSprite.d.ts.map +0 -1
- package/dist/spine/PixiSpineSprite.js +0 -72
package/README.md
CHANGED
|
@@ -1,3 +1,125 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Safex = JSX + cocos2x html5 Game Engine
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Introduction
|
|
4
|
+
|
|
5
|
+
Safex is an game engine written in TypeScript, combining the power of JSX syntax with the renowned cocos2x html5 rendering library. This project aims to help mobile game developers build games quickly, easily, and intuitively.
|
|
6
|
+
|
|
7
|
+
## Key Features
|
|
8
|
+
|
|
9
|
+
- **JSX Syntax:** Write UI and game logic in a React-like style for better code organization and readability.
|
|
10
|
+
- **Powered by Cocos2x html5:** Utilize for high-performance 2D rendering.
|
|
11
|
+
- **Component-based Architecture:** Easily manage game elements such as scenes, sprites, events, actions and animations.
|
|
12
|
+
- **Asset Loading Support:** Quickly load images, sounds, and sprite sheets.
|
|
13
|
+
- All components must be extends from `ComponentX` or call `registerSystem(${className})`
|
|
14
|
+
- `node` property represent node, and can pass properties to assign
|
|
15
|
+
- Example `<SpriteRender node={{ xy: [5, 9] }} />`
|
|
16
|
+
- `$ref` bind component with current class property as string
|
|
17
|
+
- `$push` push component to list
|
|
18
|
+
- `$refNode` and `$pushNode` for `NodeComp` component from any component.
|
|
19
|
+
- `Array(2).map(_, i)` iteration repeat component 2 times
|
|
20
|
+
- `Loading.listItems.map(item, i = 1)` iteration in class static readonly property
|
|
21
|
+
|
|
22
|
+
## Benefits
|
|
23
|
+
|
|
24
|
+
- **Rapid Development:** JSX makes writing code clean and intuitive.
|
|
25
|
+
- **Extensibility:** Easily add new features and functionalities.
|
|
26
|
+
- **Web Developer Friendly:** If you're familiar with React, you'll quickly get up to speed with Safex.
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
npm install @safe-engine/cocos
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Basic Example
|
|
35
|
+
|
|
36
|
+
```tsx GameScene.tsx
|
|
37
|
+
import { SceneComponent, LabelComp, ButtonComp, SpriteRender, instantiate, Touch } from '@safe-engine/cocos'
|
|
38
|
+
import ColliderSprite from './ColliderSprite'
|
|
39
|
+
import { sf_sprite } from '../assets'
|
|
40
|
+
|
|
41
|
+
export class GameScene extends SceneComponent {
|
|
42
|
+
sprite: SpriteRender
|
|
43
|
+
label: LabelComp
|
|
44
|
+
|
|
45
|
+
onPress(target: ButtonComp) {
|
|
46
|
+
this.sprite.spriteFrame = 'other.sprite.png'
|
|
47
|
+
this.label.string = target.node.name
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
onTouchMove(event: Touch) {
|
|
51
|
+
const {x,y} = event.getLocation()
|
|
52
|
+
const sprite = instantiate(ColliderSprite)
|
|
53
|
+
sprite.node.posX = x
|
|
54
|
+
sprite.node.posY = y
|
|
55
|
+
this.node.addChild(sprite)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
render() {
|
|
59
|
+
return (
|
|
60
|
+
<SceneComponent>
|
|
61
|
+
<TouchEventRegister
|
|
62
|
+
onTouchMove={this.onTouchMove}
|
|
63
|
+
/>
|
|
64
|
+
<LabelComp $ref={this.label} node={{ xy: [106, 240] }} string="Hello safex" font={defaultFont} />
|
|
65
|
+
<ButtonComp $ref={this.sprite} node={{ xy: [500, 600], name: 'sf_sprite' }} spriteFrame={sf_sprite} onPress={this.onPress} >
|
|
66
|
+
</ButtonComp>
|
|
67
|
+
</SceneComponent>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Collider Events
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
import { ComponentX, SpriteRender } from '@safe-engine/cocos'
|
|
77
|
+
import { BoxCollider } from '@safe-engine/cocos/dist/collider'
|
|
78
|
+
import { sf_crash } from '../assets'
|
|
79
|
+
|
|
80
|
+
export class ColliderSprite extends ComponentX {
|
|
81
|
+
onCollisionEnter(other: Collider) {
|
|
82
|
+
console.log(other.props.tag)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
render() {
|
|
86
|
+
return (
|
|
87
|
+
<SpriteRender node={{ xy: [640, 360] }} spriteFrame={sf_crash}>
|
|
88
|
+
<BoxCollider height={100} width={100} onCollisionEnter={this.onCollisionEnter} tag={3} />
|
|
89
|
+
</SpriteRender>
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Physics Events
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
import { ComponentX, SpriteRender } from '@safe-engine/cocos'
|
|
99
|
+
import { DynamicBody, PhysicsBoxCollider, RigidBody } from '@safe-engine/cocos/dist/box2d-wasm'
|
|
100
|
+
import { sf_crash } from '../assets'
|
|
101
|
+
|
|
102
|
+
export class PhysicsCollider extends ComponentX {
|
|
103
|
+
onBeginContact(other: RigidBody) {
|
|
104
|
+
console.log('onBeginContact', other)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
render() {
|
|
108
|
+
return (
|
|
109
|
+
<SpriteRender node={{ xy: [640, 360] }} spriteFrame={sf_crash}>
|
|
110
|
+
<RigidBody type={DynamicBody} onBeginContact={this.onBeginContact} tag={2} isSensor ></RigidBody>
|
|
111
|
+
<PhysicsBoxCollider height={100} width={100}></PhysicsBoxCollider>
|
|
112
|
+
</SpriteRender>
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Contributing
|
|
119
|
+
|
|
120
|
+
We welcome all contributions! If you have ideas or want to improve the engine, feel free to create an issue or submit a pull request on GitHub.
|
|
121
|
+
|
|
122
|
+
## Contact
|
|
123
|
+
- [Discord](https://discord.com/channels/1344214207268388979/1344214208044208140)
|
|
124
|
+
|
|
125
|
+
Let's build a powerful and convenient game engine together! 🚀
|
package/dist/core/NodeComp.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ export declare class NodeComp<C extends cc.Node = cc.Node> {
|
|
|
8
8
|
instance: C;
|
|
9
9
|
parent: NodeComp;
|
|
10
10
|
children: NodeComp[];
|
|
11
|
-
name: string;
|
|
12
11
|
private _active;
|
|
13
12
|
constructor(instance: C, entity: Entity);
|
|
14
13
|
get uuid(): number;
|
|
@@ -57,6 +56,10 @@ export declare class NodeComp<C extends cc.Node = cc.Node> {
|
|
|
57
56
|
set h(val: number);
|
|
58
57
|
get zIndex(): number;
|
|
59
58
|
set zIndex(val: number);
|
|
59
|
+
get name(): string;
|
|
60
|
+
set name(val: string);
|
|
61
|
+
get tag(): number;
|
|
62
|
+
set tag(val: number);
|
|
60
63
|
get childrenCount(): number;
|
|
61
64
|
destroy(): void;
|
|
62
65
|
addComponent<T extends ComponentType>(instance: T & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeComp.d.ts","sourceRoot":"","sources":["../../src/core/NodeComp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAGhD,OAAO,EAAE,aAAa,EAAiB,MAAM,aAAa,CAAA;AAC1D,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAEtE,MAAM,MAAM,iBAAiB,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,IAAI,CAAA;AAC5D,qBAAa,QAAQ,CAAC,CAAC,SAAS,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI;IAC/C,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,CAAC,CAAA;IACX,MAAM,EAAE,QAAQ,CAAA;IAChB,QAAQ,EAAE,QAAQ,EAAE,CAAK;IACzB,
|
|
1
|
+
{"version":3,"file":"NodeComp.d.ts","sourceRoot":"","sources":["../../src/core/NodeComp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAGhD,OAAO,EAAE,aAAa,EAAiB,MAAM,aAAa,CAAA;AAC1D,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAEtE,MAAM,MAAM,iBAAiB,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,IAAI,CAAA;AA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EAAE,CAAC,KAAK;;;;;;;;;;;;;;;;;;;IAIpC,qBAAqB,CAAC,KAAK,EAAE,IAAI;;;;;;;;;;;;;;;;;;;IAIjC,mBAAmB,CAAC,KAAK,EAAE,IAAI;;;;;;;;;;;;;;;;;;;IAI/B,cAAc;IAQd,IAAI,WAAW,IAIO,IAAI,CAFzB;IAED,IAAI,WAAW,CAAC,IAAI,EAAE,IAAI,EAWzB;IAED,SAAS,CAAC,GAAG,EAAE,EAAE,CAAC,cAAc;IAIhC,cAAc;IAId,0BAA0B;IAK1B,2BAA2B;IAK3B,gBAAgB,CAAC,OAAO,CAAC,EAAE,OAAO;IAkBlC,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM;IAOvD,iBAAiB,CAAC,OAAO,CAAC,EAAE,OAAO;IAMnC,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC;IAM1B,OAAO,CAAC,CAAC,SAAS,OAAO,GAAG,KAAK,GAAG,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IASjE,IAAI,KAAK,kBAMR;IAED,UAAU,CAAC,GAAG,EAAE,MAAM;IAOtB,gBAAgB,CAAC,SAAS,EAAE,iBAAiB,CAAC,MAAM,EAAE,QAAQ,CAAC;CAOhE"}
|
package/dist/core/NodeComp.js
CHANGED
|
@@ -6,7 +6,6 @@ export class NodeComp {
|
|
|
6
6
|
instance;
|
|
7
7
|
parent;
|
|
8
8
|
children = [];
|
|
9
|
-
name;
|
|
10
9
|
_active = true;
|
|
11
10
|
constructor(instance, entity) {
|
|
12
11
|
this.entity = entity;
|
|
@@ -137,6 +136,18 @@ export class NodeComp {
|
|
|
137
136
|
set zIndex(val) {
|
|
138
137
|
this.instance.zIndex = val;
|
|
139
138
|
}
|
|
139
|
+
get name() {
|
|
140
|
+
return this.instance.getName();
|
|
141
|
+
}
|
|
142
|
+
set name(val) {
|
|
143
|
+
this.instance.setName(val);
|
|
144
|
+
}
|
|
145
|
+
get tag() {
|
|
146
|
+
return this.instance.getTag();
|
|
147
|
+
}
|
|
148
|
+
set tag(val) {
|
|
149
|
+
this.instance.setTag(val);
|
|
150
|
+
}
|
|
140
151
|
get childrenCount() {
|
|
141
152
|
return this.children.length;
|
|
142
153
|
}
|
|
@@ -19,7 +19,7 @@ export declare class SimpleMeshNode extends cc.Sprite {
|
|
|
19
19
|
setIndices(inds: Uint16Array): void;
|
|
20
20
|
setTexture(tex: cc.Texture2D): void;
|
|
21
21
|
setSpriteFrame(renderTexture: any): void;
|
|
22
|
-
visit(ctx?:
|
|
22
|
+
visit(ctx?: cc.Node): void;
|
|
23
23
|
_drawMesh(): void;
|
|
24
24
|
_ensureGL(): void;
|
|
25
25
|
_computeModelMatrixFromNode(): Float32Array;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SimpleMeshNode.d.ts","sourceRoot":"","sources":["../../../src/dragonbones/db-cocos/SimpleMeshNode.ts"],"names":[],"mappings":"AAOA,qBAAa,cAAe,SAAQ,EAAE,CAAC,MAAM;IAE3C,QAAQ,EAAE,GAAG,CAAO;IACpB,SAAS,EAAE,YAAY,GAAG,IAAI,CAAO;IACrC,IAAI,EAAE,YAAY,GAAG,IAAI,CAAO;IAChC,QAAQ,EAAE,WAAW,GAAG,IAAI,CAAO;IAGnC,GAAG,EAAE,qBAAqB,GAAG,IAAI,CAAO;IACxC,QAAQ,EAAE,YAAY,GAAG,IAAI,CAAO;IACpC,IAAI,EAAE,WAAW,GAAG,IAAI,CAAO;IAC/B,KAAK,EAAE,WAAW,GAAG,IAAI,CAAO;IAChC,IAAI,EAAE,WAAW,GAAG,IAAI,CAAO;IAC/B,YAAY,UAAO;IACnB,MAAM,SAAM;IAGZ,aAAa,EAAE,EAAE,CAAC,QAAQ,CAAO;IACjC,SAAS,UAAO;gBAEJ,OAAO,CAAC,EAAE,EAAE,CAAC,SAAS,EAAE,Q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IAAI;IAMtC,MAAM,CAAC,GAAG,EAAE,YAAY,GAAG,IAAI;IAK/B,UAAU,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI;IAKnC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,GAAG,IAAI;IAGnC,cAAc,CAAC,aAAa,KAAA;IAK5B,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,IAAI,GAAG,IAAI;IAU1B,SAAS,IAAI,IAAI;IAQjB,SAAS,IAAI,IAAI;IAuEjB,2BAA2B,IAAI,YAAY;IA0D3C,cAAc,IAAI,IAAI;IAkGtB,uBAAuB,IAAI,IAAI;IAuB/B,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAKzB,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;;;;;IAU5G,MAAM,IAAI,IAAI;CAcf"}
|
|
@@ -36,6 +36,7 @@ interface LabelCompProps {
|
|
|
36
36
|
size?: number;
|
|
37
37
|
outline?: [ColorSource, number];
|
|
38
38
|
shadow?: [ColorSource, number, Size];
|
|
39
|
+
isAdaptWithSize?: boolean;
|
|
39
40
|
}
|
|
40
41
|
export declare class LabelComp extends ComponentX<LabelCompProps & BaseComponentProps<LabelComp>, ccui.Text> {
|
|
41
42
|
get string(): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GUIComponent.d.ts","sourceRoot":"","sources":["../../src/gui/GUIComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,IAAI,CAAA;AACpD,OAAO,EAAE,UAAU,EAAU,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE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,SAAQ,UAAU,CAAC,cAAc,GAAG,kBAAkB,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC;IACvG,IAAI,MAAM,WAET;CACF;AACD,UAAU,eAAe;IACvB,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AACD,qBAAa,UAAW,SAAQ,UAAU,CAAC,eAAe,GAAG,kBAAkB,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC;CAAG;AAExG,UAAU,mBAAmB;IAC3B,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AACD,qBAAa,cAAe,SAAQ,UAAU,CAAC,mBAAmB,GAAG,kBAAkB,CAAC,cAAc,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC;IAC/G,KAAK;IAIL,QAAQ;CAWT"}
|
package/dist/gui/GUISystem.js
CHANGED
|
@@ -54,7 +54,7 @@ export class GUISystem {
|
|
|
54
54
|
bar.node = entity.assign(new NodeComp(pTimer, entity));
|
|
55
55
|
};
|
|
56
56
|
onAddLabelComp = ({ entity, component: label }) => {
|
|
57
|
-
const { string = '', font = GUISystem.defaultFont, size = 64, outline, shadow } = label.props;
|
|
57
|
+
const { string = '', font = GUISystem.defaultFont, size = 64, outline, shadow, isAdaptWithSize } = label.props;
|
|
58
58
|
const fontName = cc.path.basename(font, '.ttf');
|
|
59
59
|
const node = new ccui.Text(string, fontName, size);
|
|
60
60
|
node.setTextVerticalAlignment(cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM);
|
|
@@ -66,7 +66,7 @@ export class GUISystem {
|
|
|
66
66
|
const [color, blur, offset] = shadow;
|
|
67
67
|
node.enableShadow(color, offset, blur);
|
|
68
68
|
}
|
|
69
|
-
node.ignoreContentAdaptWithSize(
|
|
69
|
+
node.ignoreContentAdaptWithSize(!isAdaptWithSize);
|
|
70
70
|
label.node = entity.assign(new NodeComp(node, entity));
|
|
71
71
|
};
|
|
72
72
|
onAddScrollViewComp = ({ entity, component: scrollView }) => {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseComponentProps, ComponentX } from '..';
|
|
2
|
+
interface SliderCompProps extends BaseComponentProps<SliderComp> {
|
|
3
|
+
barBackground: string;
|
|
4
|
+
normalBall: string;
|
|
5
|
+
pressedBall?: string;
|
|
6
|
+
disabledBall?: string;
|
|
7
|
+
percent?: number;
|
|
8
|
+
onChange: (percent: number) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare class SliderComp extends ComponentX<SliderCompProps, ccui.Slider> {
|
|
11
|
+
set percent(val: number);
|
|
12
|
+
get percent(): number;
|
|
13
|
+
render(): this;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=SliderComp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SliderComp.d.ts","sourceRoot":"","sources":["../../src/gui/SliderComp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAuC,MAAM,IAAI,CAAA;AAExF,UAAU,eAAgB,SAAQ,kBAAkB,CAAC,UAAU,CAAC;IAC9D,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;CACpC;AAED,qBAAa,UAAW,SAAQ,UAAU,CAAC,eAAe,EAAE,IAAI,CAAC,MAAM,CAAC;IACtE,IAAI,OAAO,CAAC,GAAG,EAAE,MAAM,EAEtB;IACD,IAAI,OAAO,IAAI,MAAM,CAEpB;IACD,MAAM;CAqBP"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ComponentX, GameWorld, NodeComp, registerSystem } from '..';
|
|
2
|
+
export class SliderComp extends ComponentX {
|
|
3
|
+
set percent(val) {
|
|
4
|
+
this.node.instance.setPercent(val);
|
|
5
|
+
}
|
|
6
|
+
get percent() {
|
|
7
|
+
return this.node.instance.getPercent();
|
|
8
|
+
}
|
|
9
|
+
render() {
|
|
10
|
+
const { barBackground, normalBall, pressedBall, disabledBall, percent } = this.props;
|
|
11
|
+
const frame = cc.spriteFrameCache.getSpriteFrame(normalBall);
|
|
12
|
+
const textureType = !frame ? ccui.Widget.LOCAL_TEXTURE : ccui.Widget.PLIST_TEXTURE;
|
|
13
|
+
const slider = new ccui.Slider(barBackground, normalBall, textureType);
|
|
14
|
+
slider.loadSlidBallTexturePressed(pressedBall || normalBall, textureType);
|
|
15
|
+
slider.loadSlidBallTextureDisabled(disabledBall || normalBall, textureType);
|
|
16
|
+
if (percent !== undefined)
|
|
17
|
+
slider.setPercent(percent);
|
|
18
|
+
slider.addEventListener((sender, type) => {
|
|
19
|
+
// console.log('SliderComp onChange', type, sender)
|
|
20
|
+
if (type === ccui.Slider.EVENT_PERCENT_CHANGED) {
|
|
21
|
+
const percent = sender.getPercent();
|
|
22
|
+
this.props.onChange(percent);
|
|
23
|
+
}
|
|
24
|
+
}, this);
|
|
25
|
+
const world = GameWorld.Instance;
|
|
26
|
+
const entity = world.entities.create();
|
|
27
|
+
this.node = entity.assign(new NodeComp(slider, entity));
|
|
28
|
+
const comp = entity.assign(this);
|
|
29
|
+
return comp;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
registerSystem(SliderComp);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseComponentProps, ComponentX } from '..';
|
|
2
|
+
interface RenderTextureCompProps extends BaseComponentProps<RenderTextureComp> {
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
}
|
|
6
|
+
export declare class RenderTextureComp extends ComponentX<RenderTextureCompProps, cc.RenderTexture> {
|
|
7
|
+
render(): this;
|
|
8
|
+
}
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=RenderTextureComp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RenderTextureComp.d.ts","sourceRoot":"","sources":["../../src/render/RenderTextureComp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAuC,MAAM,IAAI,CAAA;AAExF,UAAU,sBAAuB,SAAQ,kBAAkB,CAAC,iBAAiB,CAAC;IAC5E,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf;AAED,qBAAa,iBAAkB,SAAQ,UAAU,CAAC,sBAAsB,EAAE,EAAE,CAAC,aAAa,CAAC;IACzF,MAAM;CAUP"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ComponentX, GameWorld, NodeComp, registerSystem } from '..';
|
|
2
|
+
export class RenderTextureComp extends ComponentX {
|
|
3
|
+
render() {
|
|
4
|
+
const { width, height } = this.props;
|
|
5
|
+
const rt = new cc.RenderTexture(width, height);
|
|
6
|
+
const world = GameWorld.Instance;
|
|
7
|
+
const entity = world.entities.create();
|
|
8
|
+
this.node = entity.assign(new NodeComp(rt, entity));
|
|
9
|
+
const comp = entity.assign(this);
|
|
10
|
+
return comp;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
registerSystem(RenderTextureComp);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichTextComp.d.ts","sourceRoot":"","sources":["../../src/richtext/RichTextComp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAa,MAAM,IAAI,CAAA;AAClD,OAAO,EAAE,UAAU,EAAU,MAAM,mBAAmB,CAAA;AAKtD,UAAU,iBAAiB;IACzB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"RichTextComp.d.ts","sourceRoot":"","sources":["../../src/richtext/RichTextComp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAa,MAAM,IAAI,CAAA;AAClD,OAAO,EAAE,UAAU,EAAU,MAAM,mBAAmB,CAAA;AAKtD,UAAU,iBAAiB;IACzB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B;AAED,qBAAa,YAAa,SAAQ,UAAU,CAAC,iBAAiB,GAAG,kBAAkB,CAAC,YAAY,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;IAC/G,IAAI,MAAM,IAIM,MAAM,CAFrB;IAED,IAAI,MAAM,CAAC,GAAG,EAAE,MAAM,EAyBrB;CACF"}
|
|
@@ -6,11 +6,11 @@ export class RichTextSystem {
|
|
|
6
6
|
event_manager.subscribe(EventTypes.ComponentAdded, RichTextComp, this.onAddRichTextComp);
|
|
7
7
|
}
|
|
8
8
|
onAddRichTextComp = ({ entity, component: rich }) => {
|
|
9
|
-
const { string = '' } = rich.props;
|
|
9
|
+
const { string = '', isAdaptWithSize } = rich.props;
|
|
10
10
|
const node = new ccui.RichText();
|
|
11
|
-
node.width = 500
|
|
12
|
-
node.height = 300
|
|
13
|
-
node.ignoreContentAdaptWithSize(
|
|
11
|
+
// node.width = 500
|
|
12
|
+
// node.height = 300
|
|
13
|
+
node.ignoreContentAdaptWithSize(!isAdaptWithSize);
|
|
14
14
|
rich.node = entity.assign(new NodeComp(node, entity));
|
|
15
15
|
rich.string = string;
|
|
16
16
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@safe-engine/cocos",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.7",
|
|
4
4
|
"description": "safe-engine with cocos renderer support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@cocos/dragonbones-js": "^1.0.2",
|
|
25
|
-
"@esotericsoftware/spine-core": "^4.2.
|
|
25
|
+
"@esotericsoftware/spine-core": "^4.2.104",
|
|
26
26
|
"box2d-wasm": "^7.0.0",
|
|
27
|
-
"cocos-html5-ts": "^2.1.
|
|
27
|
+
"cocos-html5-ts": "^2.1.11",
|
|
28
28
|
"entityx-ts": "^2.3.1"
|
|
29
29
|
},
|
|
30
30
|
"author": "",
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { PixiArmatureDisplay } from 'dragonbones-pixijs';
|
|
2
|
-
import { Application } from 'pixi.js';
|
|
3
|
-
export declare function loadDragonBonesAssets({ skeleton, atlas, texture }: {
|
|
4
|
-
skeleton: any;
|
|
5
|
-
atlas: any;
|
|
6
|
-
texture: any;
|
|
7
|
-
}): Promise<any>;
|
|
8
|
-
export declare class PixiDragonBonesSprite extends cc.Sprite {
|
|
9
|
-
_canvas: any;
|
|
10
|
-
_pixiApp: Application;
|
|
11
|
-
_texture: cc.Texture2D;
|
|
12
|
-
_config: any;
|
|
13
|
-
_armatureDisplay: PixiArmatureDisplay;
|
|
14
|
-
constructor(config: any);
|
|
15
|
-
_setupArmature(): void;
|
|
16
|
-
updateTexture(): void;
|
|
17
|
-
onExit(): void;
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=PixiDragonBonesSprite.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PixiDragonBonesSprite.d.ts","sourceRoot":"","sources":["../../src/dragonbones/PixiDragonBonesSprite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAe,MAAM,oBAAoB,CAAA;AACrE,OAAO,EAAE,WAAW,EAAU,MAAM,SAAS,CAAA;AAE7C,wBAAgB,qBAAqB,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE;;;;CAAA,gBAGjE;AAED,qBAAa,qBAAsB,SAAQ,EAAE,CAAC,MAAM;IAClD,OAAO,EAAE,GAAG,CAAA;IACZ,QAAQ,EAAE,WAAW,CAAA;IACrB,QAAQ,EAAE,EAAE,CAAC,SAAS,CAAA;IACtB,OAAO,MAAA;IACP,gBAAgB,EAAE,mBAAmB,CAAA;gBACzB,MAAM,KAAA;IA+BlB,cAAc;IAuBd,aAAa;IASb,MAAM;CAQP"}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { PixiFactory } from 'dragonbones-pixijs';
|
|
2
|
-
import { Application, Assets } from 'pixi.js';
|
|
3
|
-
export function loadDragonBonesAssets({ skeleton, atlas, texture }) {
|
|
4
|
-
// console.log('loadDragonBonesAssets', skeleton, atlas, texture)
|
|
5
|
-
return Assets.load([skeleton, atlas, texture]);
|
|
6
|
-
}
|
|
7
|
-
export class PixiDragonBonesSprite extends cc.Sprite {
|
|
8
|
-
_canvas;
|
|
9
|
-
_pixiApp;
|
|
10
|
-
_texture;
|
|
11
|
-
_config;
|
|
12
|
-
_armatureDisplay;
|
|
13
|
-
constructor(config) {
|
|
14
|
-
super();
|
|
15
|
-
super.ctor(); // always call this for compatibility with cocos2dx JS Javascript class system
|
|
16
|
-
this._canvas = document.createElement('canvas');
|
|
17
|
-
this._canvas.width = config.width || 1024;
|
|
18
|
-
this._canvas.height = config.height || 1024;
|
|
19
|
-
this._pixiApp = new Application();
|
|
20
|
-
this._pixiApp.init({
|
|
21
|
-
view: this._canvas,
|
|
22
|
-
width: this._canvas.width,
|
|
23
|
-
height: this._canvas.height,
|
|
24
|
-
backgroundAlpha: 0, // nền trong suốt
|
|
25
|
-
// transparent: true, // bắt buộc để alpha hoạt động
|
|
26
|
-
clearBeforeRender: true, // xoá trước khi vẽ frame mới
|
|
27
|
-
preserveDrawingBuffer: true, // giúp lấy ảnh từ canvas
|
|
28
|
-
antialias: true,
|
|
29
|
-
});
|
|
30
|
-
this._texture = new cc.Texture2D();
|
|
31
|
-
this._texture.initWithElement(this._canvas);
|
|
32
|
-
this._texture.handleLoadedTexture();
|
|
33
|
-
this.initWithTexture(this._texture);
|
|
34
|
-
this._config = config;
|
|
35
|
-
this._armatureDisplay = null;
|
|
36
|
-
this._setupArmature();
|
|
37
|
-
// this.schedule(this.updateTexture, 1 / 30);
|
|
38
|
-
}
|
|
39
|
-
_setupArmature() {
|
|
40
|
-
const { skeleton, atlas, texture, playTimes, animationName, scale = 1 } = this._config;
|
|
41
|
-
const factory = PixiFactory.factory;
|
|
42
|
-
const atlasAsset = Assets.get(atlas);
|
|
43
|
-
const dragonData = factory.parseDragonBonesData(Assets.get(skeleton), atlasAsset.name);
|
|
44
|
-
factory.parseTextureAtlasData(Assets.get(atlas), Assets.get(texture), atlasAsset.name);
|
|
45
|
-
const { armatureNames } = dragonData;
|
|
46
|
-
const armatureName = armatureNames[0];
|
|
47
|
-
const display = factory.buildArmatureDisplay(armatureName, atlasAsset.name);
|
|
48
|
-
if (!display) {
|
|
49
|
-
console.error('Cannot build armature:', armatureName);
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
display.animation.play(animationName, playTimes);
|
|
53
|
-
display.x = this._canvas.width / 2;
|
|
54
|
-
display.y = this._canvas.height / 2;
|
|
55
|
-
display.scale.set(scale);
|
|
56
|
-
this._pixiApp.stage.addChild(display);
|
|
57
|
-
this._armatureDisplay = display;
|
|
58
|
-
}
|
|
59
|
-
updateTexture() {
|
|
60
|
-
if (this._armatureDisplay && this._pixiApp.renderer && this._pixiApp.stage) {
|
|
61
|
-
this._pixiApp.renderer.render(this._pixiApp.stage);
|
|
62
|
-
this._texture.initWithElement(this._canvas);
|
|
63
|
-
this._texture.handleLoadedTexture();
|
|
64
|
-
this.setTexture(this._texture);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
onExit() {
|
|
68
|
-
// this.unschedule(this.updateTexture);
|
|
69
|
-
this._pixiApp.destroy(true, { children: true });
|
|
70
|
-
this._canvas.remove();
|
|
71
|
-
this._armatureDisplay.destroy();
|
|
72
|
-
this._armatureDisplay = null;
|
|
73
|
-
super.onExit();
|
|
74
|
-
}
|
|
75
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { EnhancedComponent } from './EnhancedComponent';
|
|
2
|
-
export declare namespace AnimationClip {
|
|
3
|
-
interface IEvent {
|
|
4
|
-
frame: number;
|
|
5
|
-
func: string;
|
|
6
|
-
params: string[];
|
|
7
|
-
isCalled: boolean;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
export declare enum WrapMode {
|
|
11
|
-
Default = 0,
|
|
12
|
-
Normal = 1,
|
|
13
|
-
Loop = 2,
|
|
14
|
-
PingPong = 22,
|
|
15
|
-
Reverse = 36,
|
|
16
|
-
LoopReverse = 38,
|
|
17
|
-
PingPongReverse = 54
|
|
18
|
-
}
|
|
19
|
-
interface AnimProp {
|
|
20
|
-
frame: number;
|
|
21
|
-
value: number;
|
|
22
|
-
}
|
|
23
|
-
interface SpriteFrameProp {
|
|
24
|
-
frame: number;
|
|
25
|
-
value: string;
|
|
26
|
-
}
|
|
27
|
-
interface CurveData {
|
|
28
|
-
comps: {
|
|
29
|
-
spriteFrame: SpriteFrameProp[];
|
|
30
|
-
nextFrame: number;
|
|
31
|
-
};
|
|
32
|
-
props: {
|
|
33
|
-
[key: string]: AnimProp[];
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
export declare class AnimationClip {
|
|
37
|
-
static WrapMode: typeof WrapMode;
|
|
38
|
-
sample: number;
|
|
39
|
-
speed: number;
|
|
40
|
-
wrapMode: WrapMode;
|
|
41
|
-
events: AnimationClip.IEvent[];
|
|
42
|
-
duration: number;
|
|
43
|
-
name: string;
|
|
44
|
-
curveData: CurveData;
|
|
45
|
-
}
|
|
46
|
-
export declare class AnimationComp extends EnhancedComponent {
|
|
47
|
-
defaultClip: AnimationClip;
|
|
48
|
-
clips: AnimationClip[];
|
|
49
|
-
playOnLoad: boolean;
|
|
50
|
-
private isPaused;
|
|
51
|
-
private elapsed;
|
|
52
|
-
private currentClip;
|
|
53
|
-
constructor(defaultClip: AnimationClip, clips: AnimationClip[], playOnLoad: boolean);
|
|
54
|
-
start(): void;
|
|
55
|
-
update(dt: Float): void;
|
|
56
|
-
getAnimationState(name: string): {
|
|
57
|
-
isPlaying: boolean;
|
|
58
|
-
};
|
|
59
|
-
play(name?: string): void;
|
|
60
|
-
pause(): void;
|
|
61
|
-
resume(): void;
|
|
62
|
-
stop(name?: string): void;
|
|
63
|
-
}
|
|
64
|
-
export {};
|
|
65
|
-
//# sourceMappingURL=AnimationComponent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AnimationComponent.d.ts","sourceRoot":"","sources":["../../../src/gworld/components/AnimationComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAGvD,MAAM,CAAC,OAAO,WAAW,aAAa,CAAC;IACrC,UAAiB,MAAM;QACrB,KAAK,EAAE,MAAM,CAAA;QACb,IAAI,EAAE,MAAM,CAAA;QACZ,MAAM,EAAE,MAAM,EAAE,CAAA;QAChB,QAAQ,EAAE,OAAO,CAAA;KAClB;CACF;AAED,oBAAY,QAAQ;IAClB,OAAO,IAAI;IACX,MAAM,IAAI;IACV,IAAI,IAAI;IACR,QAAQ,KAAK;IACb,OAAO,KAAK;IACZ,WAAW,KAAK;IAChB,eAAe,KAAK;CACrB;AAED,UAAU,QAAQ;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd;AAED,UAAU,eAAe;IACvB,KAAK,EAAE,MAAM,CAAA;IACb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