pixifact 0.1.3 → 0.1.5

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 (185) hide show
  1. package/README.md +3 -3
  2. package/dist/builtin-scenes/CenterContainer.d.ts +13 -0
  3. package/dist/builtin-scenes/CenterContainer.js +71 -0
  4. package/dist/builtin-scenes/CenterContainer.scene +3 -0
  5. package/dist/builtin-scenes/CenterContainer.ts +77 -0
  6. package/dist/builtin-scenes/Control.d.ts +44 -0
  7. package/dist/builtin-scenes/Control.js +206 -0
  8. package/dist/builtin-scenes/Control.scene +3 -0
  9. package/dist/builtin-scenes/Control.ts +233 -0
  10. package/dist/builtin-scenes/FlexItem.d.ts +45 -0
  11. package/dist/builtin-scenes/FlexItem.js +164 -0
  12. package/dist/builtin-scenes/FlexItem.scene +3 -0
  13. package/dist/builtin-scenes/FlexItem.ts +180 -0
  14. package/dist/builtin-scenes/FlexLayout.d.ts +29 -0
  15. package/dist/builtin-scenes/FlexLayout.js +358 -0
  16. package/dist/builtin-scenes/FlexLayout.scene +3 -0
  17. package/dist/builtin-scenes/FlexLayout.ts +409 -0
  18. package/dist/builtin-scenes/HBoxContainer.d.ts +15 -0
  19. package/dist/builtin-scenes/HBoxContainer.js +70 -0
  20. package/dist/builtin-scenes/HBoxContainer.scene +3 -0
  21. package/dist/builtin-scenes/HBoxContainer.ts +75 -0
  22. package/dist/builtin-scenes/MarginContainer.d.ts +23 -0
  23. package/dist/builtin-scenes/MarginContainer.js +131 -0
  24. package/dist/builtin-scenes/MarginContainer.scene +3 -0
  25. package/dist/builtin-scenes/MarginContainer.ts +139 -0
  26. package/dist/builtin-scenes/VBoxContainer.d.ts +15 -0
  27. package/dist/builtin-scenes/VBoxContainer.js +70 -0
  28. package/dist/builtin-scenes/VBoxContainer.scene +3 -0
  29. package/dist/builtin-scenes/VBoxContainer.ts +75 -0
  30. package/dist/builtin-scenes/controlLayout.d.ts +57 -0
  31. package/dist/builtin-scenes/controlLayout.js +202 -0
  32. package/dist/builtin-scenes/controlLayout.ts +270 -0
  33. package/dist/compiler/builtinScenes.d.ts +14 -0
  34. package/dist/compiler/builtinScenes.js +62 -0
  35. package/dist/compiler/compileScenes.js +126 -19
  36. package/dist/compiler/decorators.js +3 -0
  37. package/dist/compiler/index.d.ts +1 -0
  38. package/dist/compiler/index.js +1 -0
  39. package/dist/compiler/sceneAssetPair.js +19 -0
  40. package/dist/compiler/sceneRuntime.d.ts +5 -4
  41. package/dist/compiler/scriptInterfaceExtractor.d.ts +5 -0
  42. package/dist/compiler/scriptInterfaceExtractor.js +214 -8
  43. package/dist/compiler/spec.d.ts +2 -0
  44. package/dist/compiler/templateParser.js +4 -3
  45. package/dist/compiler/templateSerializer.js +2 -1
  46. package/dist/compiler/typescriptCompiler.js +87 -13
  47. package/dist/compiler-node/builtinSceneAssets.d.ts +8 -0
  48. package/dist/compiler-node/builtinSceneAssets.js +57 -0
  49. package/dist/compiler-node/index.d.ts +1 -0
  50. package/dist/compiler-node/index.js +1 -0
  51. package/dist/errors.d.ts +1 -0
  52. package/dist/errors.js +24 -0
  53. package/dist/index.d.ts +2 -5
  54. package/dist/index.js +2 -5
  55. package/dist/{authoring/ProjectConfig.d.ts → project/index.d.ts} +7 -0
  56. package/dist/{authoring/ProjectConfig.js → project/index.js} +22 -0
  57. package/dist/runtime/Group.d.ts +18 -0
  58. package/dist/runtime/Group.js +45 -0
  59. package/dist/runtime/index.d.ts +1 -9
  60. package/dist/runtime/index.js +1 -9
  61. package/package.json +4 -26
  62. package/dist/authoring/ActionRegistry.d.ts +0 -10
  63. package/dist/authoring/ActionRegistry.js +0 -26
  64. package/dist/authoring/ComponentPalette.d.ts +0 -16
  65. package/dist/authoring/ComponentPalette.js +0 -50
  66. package/dist/authoring/DesignToken.d.ts +0 -16
  67. package/dist/authoring/DesignToken.js +0 -33
  68. package/dist/authoring/DiffModel.d.ts +0 -10
  69. package/dist/authoring/DiffModel.js +0 -104
  70. package/dist/authoring/InspectorModel.d.ts +0 -27
  71. package/dist/authoring/InspectorModel.js +0 -139
  72. package/dist/authoring/LogicGraph.d.ts +0 -66
  73. package/dist/authoring/LogicGraph.js +0 -184
  74. package/dist/authoring/OverrideJournal.d.ts +0 -18
  75. package/dist/authoring/OverrideJournal.js +0 -23
  76. package/dist/authoring/PreferenceMemory.d.ts +0 -21
  77. package/dist/authoring/PreferenceMemory.js +0 -39
  78. package/dist/authoring/RuntimePreview.d.ts +0 -11
  79. package/dist/authoring/RuntimePreview.js +0 -25
  80. package/dist/authoring/SceneDocument.d.ts +0 -74
  81. package/dist/authoring/SceneDocument.js +0 -332
  82. package/dist/authoring/SceneProjectState.d.ts +0 -20
  83. package/dist/authoring/SceneProjectState.js +0 -8
  84. package/dist/authoring/SceneSelection.d.ts +0 -11
  85. package/dist/authoring/SceneSelection.js +0 -1
  86. package/dist/authoring/index.d.ts +0 -13
  87. package/dist/authoring/index.js +0 -13
  88. package/dist/commands/Command.d.ts +0 -63
  89. package/dist/commands/Command.js +0 -1
  90. package/dist/commands/CommandStack.d.ts +0 -14
  91. package/dist/commands/CommandStack.js +0 -45
  92. package/dist/commands/applyCommand.d.ts +0 -23
  93. package/dist/commands/applyCommand.js +0 -316
  94. package/dist/commands/index.d.ts +0 -4
  95. package/dist/commands/index.js +0 -4
  96. package/dist/commands/utils.d.ts +0 -17
  97. package/dist/commands/utils.js +0 -77
  98. package/dist/commands/validateCommand.d.ts +0 -12
  99. package/dist/commands/validateCommand.js +0 -285
  100. package/dist/nodes/Input.d.ts +0 -91
  101. package/dist/nodes/Input.js +0 -352
  102. package/dist/nodes/Textarea.d.ts +0 -10
  103. package/dist/nodes/Textarea.js +0 -38
  104. package/dist/nodes/components/Button.d.ts +0 -8
  105. package/dist/nodes/components/Button.js +0 -45
  106. package/dist/nodes/components/InputField.d.ts +0 -12
  107. package/dist/nodes/components/InputField.js +0 -53
  108. package/dist/nodes/components/ProgressBar.d.ts +0 -14
  109. package/dist/nodes/components/ProgressBar.js +0 -66
  110. package/dist/nodes/components/ScrollRect.d.ts +0 -23
  111. package/dist/nodes/components/ScrollRect.js +0 -108
  112. package/dist/nodes/components/Selectable.d.ts +0 -32
  113. package/dist/nodes/components/Selectable.js +0 -153
  114. package/dist/nodes/components/index.d.ts +0 -5
  115. package/dist/nodes/components/index.js +0 -5
  116. package/dist/nodes/graphics/Graphic.d.ts +0 -14
  117. package/dist/nodes/graphics/Graphic.js +0 -47
  118. package/dist/nodes/graphics/ImageGraphic.d.ts +0 -9
  119. package/dist/nodes/graphics/ImageGraphic.js +0 -42
  120. package/dist/nodes/graphics/RoundedRectGraphic.d.ts +0 -13
  121. package/dist/nodes/graphics/RoundedRectGraphic.js +0 -65
  122. package/dist/nodes/graphics/TextGraphic.d.ts +0 -13
  123. package/dist/nodes/graphics/TextGraphic.js +0 -70
  124. package/dist/nodes/graphics/index.d.ts +0 -4
  125. package/dist/nodes/graphics/index.js +0 -4
  126. package/dist/nodes/index.d.ts +0 -3
  127. package/dist/nodes/index.js +0 -3
  128. package/dist/runtime/Application.d.ts +0 -15
  129. package/dist/runtime/Application.js +0 -67
  130. package/dist/runtime/GameObject.d.ts +0 -100
  131. package/dist/runtime/GameObject.js +0 -297
  132. package/dist/runtime/GameObjectEvent.d.ts +0 -52
  133. package/dist/runtime/GameObjectEvent.js +0 -38
  134. package/dist/runtime/Transform.d.ts +0 -32
  135. package/dist/runtime/Transform.js +0 -157
  136. package/dist/runtime/component/Component.d.ts +0 -13
  137. package/dist/runtime/component/Component.js +0 -13
  138. package/dist/runtime/component/ComponentRegistry.d.ts +0 -49
  139. package/dist/runtime/component/ComponentRegistry.js +0 -25
  140. package/dist/runtime/component/Flex.d.ts +0 -6
  141. package/dist/runtime/component/Flex.js +0 -15
  142. package/dist/runtime/component/FlexGroup.d.ts +0 -26
  143. package/dist/runtime/component/FlexGroup.js +0 -136
  144. package/dist/runtime/component/GridLayout.d.ts +0 -47
  145. package/dist/runtime/component/GridLayout.js +0 -129
  146. package/dist/runtime/component/Layout.d.ts +0 -104
  147. package/dist/runtime/component/Layout.js +0 -248
  148. package/dist/runtime/component/decorators.d.ts +0 -4
  149. package/dist/runtime/component/decorators.js +0 -52
  150. package/dist/runtime/component/index.d.ts +0 -7
  151. package/dist/runtime/component/index.js +0 -7
  152. package/dist/runtime/graphics/index.d.ts +0 -11
  153. package/dist/runtime/graphics/index.js +0 -29
  154. package/dist/runtime/group/index.d.ts +0 -39
  155. package/dist/runtime/group/index.js +0 -102
  156. package/dist/runtime/image/Image.d.ts +0 -19
  157. package/dist/runtime/image/Image.js +0 -60
  158. package/dist/runtime/image/NineSliceImage.d.ts +0 -23
  159. package/dist/runtime/image/NineSliceImage.js +0 -64
  160. package/dist/runtime/image/index.d.ts +0 -2
  161. package/dist/runtime/image/index.js +0 -2
  162. package/dist/runtime/label/Label.d.ts +0 -11
  163. package/dist/runtime/label/Label.js +0 -26
  164. package/dist/runtime/label/LabelStyle.d.ts +0 -3
  165. package/dist/runtime/label/LabelStyle.js +0 -3
  166. package/dist/runtime/label/index.d.ts +0 -2
  167. package/dist/runtime/label/index.js +0 -2
  168. package/dist/runtime/utils/index.d.ts +0 -1
  169. package/dist/runtime/utils/index.js +0 -1
  170. package/dist/runtime/utils/onlyOnceQueueMicrotask.d.ts +0 -1
  171. package/dist/runtime/utils/onlyOnceQueueMicrotask.js +0 -12
  172. package/dist/runtime/utils/setProps.d.ts +0 -10
  173. package/dist/runtime/utils/setProps.js +0 -17
  174. package/dist/scene/dsl.d.ts +0 -25
  175. package/dist/scene/dsl.js +0 -112
  176. package/dist/scene/index.d.ts +0 -5
  177. package/dist/scene/index.js +0 -5
  178. package/dist/scene/instantiate.d.ts +0 -8
  179. package/dist/scene/instantiate.js +0 -208
  180. package/dist/scene/nodesDsl.d.ts +0 -42
  181. package/dist/scene/nodesDsl.js +0 -169
  182. package/dist/scene/spec.d.ts +0 -100
  183. package/dist/scene/spec.js +0 -1
  184. package/dist/scene/templates.d.ts +0 -21
  185. package/dist/scene/templates.js +0 -239
@@ -1,104 +0,0 @@
1
- import { Component } from "./Component.js";
2
- /**
3
- * 控制布局
4
- * 当添加了控制布局组件后,原本的position、size和scale可能会被自动管控手动设置将不会生效
5
- * ```ts
6
- * const node = GameObject.instantiate(Group, parent, {
7
- * width: 100,
8
- * height: 100,
9
- * anchorX: 0.5,
10
- * anchorY: 0.5,
11
- * });
12
- * node.addComponent(Layout, { centerX: 0, centerY: 0 });
13
- * ```
14
- */
15
- export declare class Layout extends Component {
16
- private preferredWidth;
17
- private preferredHeight;
18
- private _markResize;
19
- private _active;
20
- private _applyingLayout;
21
- private resizeLater;
22
- private handleAdded;
23
- private handleRemoved;
24
- private handleParentResize;
25
- private handleSelfResize;
26
- private _left?;
27
- /**
28
- * 相对左边的距离
29
- */
30
- get left(): number | undefined;
31
- set left(val: number | undefined);
32
- private _top?;
33
- /**
34
- * 相对顶部的距离
35
- */
36
- get top(): number | undefined;
37
- set top(val: number | undefined);
38
- private _right?;
39
- /**
40
- * 相对右边的距离
41
- */
42
- get right(): number | undefined;
43
- set right(val: number | undefined);
44
- private _bottom?;
45
- /**
46
- * 相对底部的距离
47
- */
48
- get bottom(): number | undefined;
49
- set bottom(val: number | undefined);
50
- private _centerX?;
51
- /**
52
- * 水平居中偏移。
53
- * left 和 right 将失效
54
- * 注意:如果要让节点真正实现水平居中,需要设置 `anchorX`
55
- * ```ts
56
- * const node = GameObject.instantiate(Group, parent, { anchorX: 0.5 });
57
- * node.addComponent(Layout, { centerX: 0 });
58
- * ```
59
- */
60
- get centerX(): number | undefined;
61
- set centerX(val: number | undefined);
62
- private _centerY?;
63
- /**
64
- * 垂直居中偏移。
65
- * top 和 bottom 将失效
66
- * 注意:如果要让节点真正实现垂直居中,需要设置 `anchorY`
67
- * ```ts
68
- * const node = GameObject.instantiate(Group, parent, { anchorY: 0.5 });
69
- * node.addComponent(Layout, { centerY: 0 });
70
- * ```
71
- */
72
- get centerY(): number | undefined;
73
- set centerY(val: number | undefined);
74
- private _minWidth;
75
- get minWidth(): number;
76
- set minWidth(val: number);
77
- private _minHeight;
78
- get minHeight(): number;
79
- set minHeight(val: number);
80
- awake(): void;
81
- private markResize;
82
- /**
83
- * 当挂载节点尺寸发生变化,且需要重新动态计算时调用
84
- * 将保存当前组件的位置和大小状态
85
- */
86
- saveNewSize(): void;
87
- private savePreferredSize;
88
- private clampWidth;
89
- private clampHeight;
90
- /**
91
- * 重新计算布局/矫正布局
92
- * ```ts
93
- * const node = new Transform();
94
- * const layout = node.addComponent(Layout);
95
- * node.anchor.set(0.5, 0.5);
96
- * layout.resize();
97
- * ```
98
- */
99
- /**
100
- * 矫正布局
101
- */
102
- resize(): void;
103
- onDestroy(): void;
104
- }
@@ -1,248 +0,0 @@
1
- import { GameObject } from "../GameObject.js";
2
- import { Component } from "./Component.js";
3
- import { onlyOnceQueueMicrotask } from "../utils/onlyOnceQueueMicrotask.js";
4
- /**
5
- * 控制布局
6
- * 当添加了控制布局组件后,原本的position、size和scale可能会被自动管控手动设置将不会生效
7
- * ```ts
8
- * const node = GameObject.instantiate(Group, parent, {
9
- * width: 100,
10
- * height: 100,
11
- * anchorX: 0.5,
12
- * anchorY: 0.5,
13
- * });
14
- * node.addComponent(Layout, { centerX: 0, centerY: 0 });
15
- * ```
16
- */
17
- export class Layout extends Component {
18
- preferredWidth = 0;
19
- preferredHeight = 0;
20
- _markResize = false;
21
- _active = false;
22
- _applyingLayout = false;
23
- resizeLater = onlyOnceQueueMicrotask(() => {
24
- if (!this._active || !this._markResize) {
25
- return;
26
- }
27
- this.resize();
28
- });
29
- handleAdded = () => {
30
- this.gameObject.parent?.emitter.on(GameObject.Event.RESIZE, this.handleParentResize, this);
31
- this.markResize();
32
- };
33
- handleRemoved = (parent) => {
34
- parent.emitter.off(GameObject.Event.RESIZE, this.handleParentResize, this);
35
- };
36
- handleParentResize = () => {
37
- this.markResize();
38
- };
39
- handleSelfResize = () => {
40
- if (!this._applyingLayout) {
41
- this.savePreferredSize();
42
- }
43
- this.markResize();
44
- };
45
- _left;
46
- /**
47
- * 相对左边的距离
48
- */
49
- get left() {
50
- return this._left;
51
- }
52
- set left(val) {
53
- this._left = val;
54
- this.markResize();
55
- }
56
- _top;
57
- /**
58
- * 相对顶部的距离
59
- */
60
- get top() {
61
- return this._top;
62
- }
63
- set top(val) {
64
- this._top = val;
65
- this.markResize();
66
- }
67
- _right;
68
- /**
69
- * 相对右边的距离
70
- */
71
- get right() {
72
- return this._right;
73
- }
74
- set right(val) {
75
- this._right = val;
76
- this.markResize();
77
- }
78
- _bottom;
79
- /**
80
- * 相对底部的距离
81
- */
82
- get bottom() {
83
- return this._bottom;
84
- }
85
- set bottom(val) {
86
- this._bottom = val;
87
- this.markResize();
88
- }
89
- _centerX;
90
- /**
91
- * 水平居中偏移。
92
- * left 和 right 将失效
93
- * 注意:如果要让节点真正实现水平居中,需要设置 `anchorX`
94
- * ```ts
95
- * const node = GameObject.instantiate(Group, parent, { anchorX: 0.5 });
96
- * node.addComponent(Layout, { centerX: 0 });
97
- * ```
98
- */
99
- get centerX() {
100
- return this._centerX;
101
- }
102
- set centerX(val) {
103
- this._centerX = val;
104
- this.markResize();
105
- }
106
- _centerY;
107
- /**
108
- * 垂直居中偏移。
109
- * top 和 bottom 将失效
110
- * 注意:如果要让节点真正实现垂直居中,需要设置 `anchorY`
111
- * ```ts
112
- * const node = GameObject.instantiate(Group, parent, { anchorY: 0.5 });
113
- * node.addComponent(Layout, { centerY: 0 });
114
- * ```
115
- */
116
- get centerY() {
117
- return this._centerY;
118
- }
119
- set centerY(val) {
120
- this._centerY = val;
121
- this.markResize();
122
- }
123
- _minWidth = 0;
124
- get minWidth() {
125
- return this._minWidth;
126
- }
127
- set minWidth(val) {
128
- this._minWidth = val;
129
- this.markResize();
130
- }
131
- _minHeight = 0;
132
- get minHeight() {
133
- return this._minHeight;
134
- }
135
- set minHeight(val) {
136
- this._minHeight = val;
137
- this.markResize();
138
- }
139
- awake() {
140
- this._active = true;
141
- this.savePreferredSize();
142
- // 当父元素尺寸发生变化时触发
143
- this.gameObject.parent?.emitter.on(GameObject.Event.RESIZE, this.handleParentResize, this);
144
- // 当自身发生变化时触发
145
- this.gameObject.emitter.on(GameObject.Event.RESIZE, this.handleSelfResize, this);
146
- // 当自身被添加时时添加监听
147
- this.gameObject.emitter.on(GameObject.Event.ADDED, this.handleAdded, this);
148
- // 当自身被移除时移除监听
149
- this.gameObject.emitter.on(GameObject.Event.REMOVED, this.handleRemoved, this);
150
- this.resize();
151
- }
152
- markResize() {
153
- this._markResize = true;
154
- if (this._active) {
155
- this.resizeLater();
156
- }
157
- }
158
- /**
159
- * 当挂载节点尺寸发生变化,且需要重新动态计算时调用
160
- * 将保存当前组件的位置和大小状态
161
- */
162
- saveNewSize() {
163
- this.savePreferredSize();
164
- this.resize();
165
- }
166
- savePreferredSize() {
167
- this.preferredWidth = this.gameObject.width;
168
- this.preferredHeight = this.gameObject.height;
169
- }
170
- clampWidth(width) {
171
- return Math.max(this.minWidth, width);
172
- }
173
- clampHeight(height) {
174
- return Math.max(this.minHeight, height);
175
- }
176
- /**
177
- * 重新计算布局/矫正布局
178
- * ```ts
179
- * const node = new Transform();
180
- * const layout = node.addComponent(Layout);
181
- * node.anchor.set(0.5, 0.5);
182
- * layout.resize();
183
- * ```
184
- */
185
- /**
186
- * 矫正布局
187
- */
188
- resize() {
189
- if (!this.gameObject.parent) {
190
- this._markResize = false;
191
- return;
192
- }
193
- const parent = this.gameObject.parent;
194
- let width = this.clampWidth(this.gameObject.width);
195
- let height = this.clampHeight(this.gameObject.height);
196
- let x = this.gameObject.x;
197
- let y = this.gameObject.y;
198
- if (this.centerX != undefined) {
199
- x = (parent.width - width) / 2 + this.centerX + this.gameObject.anchorX * width;
200
- }
201
- else if (this.left != undefined && this.right != undefined) {
202
- width = this.clampWidth(parent.width - this.left - this.right);
203
- x = this.left + this.gameObject.anchorX * width;
204
- }
205
- else if (this.left != undefined) {
206
- x = this.left + this.gameObject.anchorX * width;
207
- }
208
- else if (this.right != undefined) {
209
- width = this.clampWidth(this.preferredWidth);
210
- x = parent.width - this.right - width + this.gameObject.anchorX * width;
211
- }
212
- if (this.centerY != undefined) {
213
- y = (parent.height - height) / 2 + this.centerY + this.gameObject.anchorY * height;
214
- }
215
- else if (this.top != undefined && this.bottom != undefined) {
216
- height = this.clampHeight(parent.height - this.top - this.bottom);
217
- y = this.top + this.gameObject.anchorY * height;
218
- }
219
- else if (this.top != undefined) {
220
- y = this.top + this.gameObject.anchorY * height;
221
- }
222
- else if (this.bottom != undefined) {
223
- height = this.clampHeight(this.preferredHeight);
224
- y = parent.height - this.bottom - height + this.gameObject.anchorY * height;
225
- }
226
- this._applyingLayout = true;
227
- try {
228
- if (this.gameObject.width !== width) {
229
- this.gameObject.width = width;
230
- }
231
- if (this.gameObject.height !== height) {
232
- this.gameObject.height = height;
233
- }
234
- this.gameObject.transform.setPosition(x, y);
235
- }
236
- finally {
237
- this._applyingLayout = false;
238
- this._markResize = false;
239
- }
240
- }
241
- onDestroy() {
242
- this._active = false;
243
- this.gameObject.parent?.emitter.off(GameObject.Event.RESIZE, this.handleParentResize, this);
244
- this.gameObject.emitter.off(GameObject.Event.RESIZE, this.handleSelfResize, this);
245
- this.gameObject.emitter.off(GameObject.Event.ADDED, this.handleAdded, this);
246
- this.gameObject.emitter.off(GameObject.Event.REMOVED, this.handleRemoved, this);
247
- }
248
- }
@@ -1,4 +0,0 @@
1
- import type { ComponentMetaOptions, PropOptions, PropSchema } from "./ComponentRegistry.js";
2
- export declare function getDecoratedPropSchemas(ctor: Function): PropSchema[];
3
- export declare function ComponentMeta(options: ComponentMetaOptions): ClassDecorator;
4
- export declare function Prop(options: PropOptions): PropertyDecorator;
@@ -1,52 +0,0 @@
1
- import { ComponentRegistry } from "./ComponentRegistry.js";
2
- const propSchemas = new WeakMap();
3
- function getOwnPropSchemas(ctor) {
4
- let props = propSchemas.get(ctor);
5
- if (!props) {
6
- props = [];
7
- propSchemas.set(ctor, props);
8
- }
9
- return props;
10
- }
11
- export function getDecoratedPropSchemas(ctor) {
12
- const hierarchy = [];
13
- let proto = ctor.prototype;
14
- while (proto && proto.constructor && proto.constructor !== Object) {
15
- hierarchy.unshift(proto.constructor);
16
- proto = Object.getPrototypeOf(proto);
17
- }
18
- const propsByKey = new Map();
19
- for (const item of hierarchy) {
20
- for (const prop of propSchemas.get(item) ?? []) {
21
- propsByKey.set(prop.key, prop);
22
- }
23
- }
24
- return Array.from(propsByKey.values());
25
- }
26
- export function ComponentMeta(options) {
27
- return (target) => {
28
- ComponentRegistry.register({
29
- ...options,
30
- ctor: target,
31
- props: getDecoratedPropSchemas(target),
32
- });
33
- };
34
- }
35
- export function Prop(options) {
36
- return (target, propertyKey) => {
37
- const props = getOwnPropSchemas(target.constructor);
38
- const key = String(propertyKey);
39
- const index = props.findIndex((prop) => prop.key === key);
40
- const schema = {
41
- key,
42
- serialize: true,
43
- ...options,
44
- };
45
- if (index === -1) {
46
- props.push(schema);
47
- }
48
- else {
49
- props[index] = schema;
50
- }
51
- };
52
- }
@@ -1,7 +0,0 @@
1
- export * from './Component.js';
2
- export * from './ComponentRegistry.js';
3
- export * from './decorators.js';
4
- export * from './Layout.js';
5
- export * from './GridLayout.js';
6
- export * from './FlexGroup.js';
7
- export * from './Flex.js';
@@ -1,7 +0,0 @@
1
- export * from './Component.js';
2
- export * from './ComponentRegistry.js';
3
- export * from './decorators.js';
4
- export * from './Layout.js';
5
- export * from './GridLayout.js';
6
- export * from './FlexGroup.js';
7
- export * from './Flex.js';
@@ -1,11 +0,0 @@
1
- import { GameObject } from "../GameObject.js";
2
- import { FillInput, Graphics as PIXIGraphics, StrokeInput } from 'pixi.js';
3
- export declare class Graphics extends GameObject<PIXIGraphics> {
4
- display: PIXIGraphics;
5
- rect(x: number, y: number, width: number, height: number): this;
6
- roundRect(x: number, y: number, width: number, height: number, radius: number): this;
7
- circle(x: number, y: number, radius: number): this;
8
- stroke(style?: StrokeInput): this;
9
- fill(style?: FillInput): this;
10
- clear(): this;
11
- }
@@ -1,29 +0,0 @@
1
- import { GameObject } from "../GameObject.js";
2
- import { Graphics as PIXIGraphics } from 'pixi.js';
3
- export class Graphics extends GameObject {
4
- display = new PIXIGraphics();
5
- rect(x, y, width, height) {
6
- this.display.rect(x, y, width, height);
7
- return this;
8
- }
9
- roundRect(x, y, width, height, radius) {
10
- this.display.roundRect(x, y, width, height, radius);
11
- return this;
12
- }
13
- circle(x, y, radius) {
14
- this.display.circle(x, y, radius);
15
- return this;
16
- }
17
- stroke(style) {
18
- this.display.stroke(style);
19
- return this;
20
- }
21
- fill(style) {
22
- this.display.fill(style);
23
- return this;
24
- }
25
- clear() {
26
- this.display.clear();
27
- return this;
28
- }
29
- }
@@ -1,39 +0,0 @@
1
- import { Container } from "pixi.js";
2
- import { GameObject } from "../GameObject.js";
3
- export declare class Group extends GameObject<Container> {
4
- display: Container<import("pixi.js").ContainerChild>;
5
- protected _width: number;
6
- protected _height: number;
7
- children: GameObject[];
8
- get width(): number;
9
- set width(val: number);
10
- get height(): number;
11
- set height(val: number);
12
- resize(): void;
13
- getChildAt(index: number): GameObject<Container<import("pixi.js").ContainerChild>>;
14
- /**
15
- * 插入一个子节点
16
- * @param child - 待插入的节点
17
- */
18
- addChild(child: GameObject): GameObject<Container<import("pixi.js").ContainerChild>>;
19
- /**
20
- * 在指定位置插入节点
21
- * @param child - 待插入的节点
22
- * @param index - 要插入的位置
23
- */
24
- addChildAt(child: GameObject, index: number): GameObject<Container<import("pixi.js").ContainerChild>>;
25
- /**
26
- * 移除一个节点
27
- * @param child - 将要移除的节点
28
- */
29
- removeChild(child: GameObject): GameObject<Container<import("pixi.js").ContainerChild>> | undefined;
30
- /**
31
- * 移除一个指定位置的元素
32
- * @param index - 要移除节点的位置
33
- */
34
- removeChildAt(index: number): GameObject<Container<import("pixi.js").ContainerChild>>;
35
- /**
36
- * 移除所有子元素
37
- */
38
- removeChildren(): void;
39
- }
@@ -1,102 +0,0 @@
1
- import { Container } from "pixi.js";
2
- import { GameObject } from "../GameObject.js";
3
- export class Group extends GameObject {
4
- display = new Container();
5
- _width = 0;
6
- _height = 0;
7
- children = [];
8
- get width() {
9
- return this._width;
10
- }
11
- set width(val) {
12
- this._width = val;
13
- this.refreshPivot();
14
- this.emitter.emit(GameObject.Event.RESIZE);
15
- }
16
- get height() {
17
- return this._height;
18
- }
19
- set height(val) {
20
- this._height = val;
21
- this.refreshPivot();
22
- this.emitter.emit(GameObject.Event.RESIZE);
23
- }
24
- resize() {
25
- const bound = this.display.getBounds();
26
- this.width = bound.width;
27
- this.height = bound.height;
28
- }
29
- getChildAt(index) {
30
- if (index < 0 || index >= this.children.length) {
31
- throw new Error(`getChildAt: Index (${index}) does not exist.`);
32
- }
33
- return this.children[index];
34
- }
35
- /**
36
- * 插入一个子节点
37
- * @param child - 待插入的节点
38
- */
39
- addChild(child) {
40
- child.parent?.removeChild(child);
41
- this.children.push(child);
42
- child.parent = this;
43
- this.display.addChild(child.display);
44
- child.setApplication(this.app);
45
- this.emitter.emit(GameObject.Event.CHILD_ADDED, child);
46
- child.emitter.emit(GameObject.Event.ADDED, this);
47
- return child;
48
- }
49
- /**
50
- * 在指定位置插入节点
51
- * @param child - 待插入的节点
52
- * @param index - 要插入的位置
53
- */
54
- addChildAt(child, index) {
55
- if (index < 0 || index > this.children.length) {
56
- throw new Error(`addChildAt: Index (${index}) is out of bounds.`);
57
- }
58
- child.parent?.removeChild(child);
59
- this.children.splice(index, 0, child);
60
- child.parent = this;
61
- this.display.addChildAt(child.display, index);
62
- child.setApplication(this.app);
63
- this.emitter.emit(GameObject.Event.CHILD_ADDED, child);
64
- child.emitter.emit(GameObject.Event.ADDED, this);
65
- return child;
66
- }
67
- /**
68
- * 移除一个节点
69
- * @param child - 将要移除的节点
70
- */
71
- removeChild(child) {
72
- const index = this.children.indexOf(child);
73
- if (index === -1) {
74
- return;
75
- }
76
- return this.removeChildAt(index);
77
- }
78
- /**
79
- * 移除一个指定位置的元素
80
- * @param index - 要移除节点的位置
81
- */
82
- removeChildAt(index) {
83
- if (index < 0 || index >= this.children.length) {
84
- throw new Error(`removeChildAt: Index (${index}) does not exist.`);
85
- }
86
- const node = this.children.splice(index, 1)[0];
87
- node.parent = undefined;
88
- node.display.parent?.removeChild(node.display);
89
- node.setApplication(undefined);
90
- this.emitter.emit(GameObject.Event.CHILD_REMOVED, node);
91
- node.emitter.emit(GameObject.Event.REMOVED, this);
92
- return node;
93
- }
94
- /**
95
- * 移除所有子元素
96
- */
97
- removeChildren() {
98
- while (this.children.length > 0) {
99
- this.removeChildAt(0);
100
- }
101
- }
102
- }
@@ -1,19 +0,0 @@
1
- import { Sprite, Texture } from "pixi.js";
2
- import { GameObject } from "../GameObject.js";
3
- export declare class Image extends GameObject<Sprite> {
4
- display: Sprite;
5
- protected _width: number;
6
- protected _height: number;
7
- /**
8
- * 这两个参数主要用于解决从来没有执行过resize或没有宽高进行赋值的情况下,使用默认纹理的宽高进行配置
9
- */
10
- private _isSetWidth;
11
- private _isSetHeight;
12
- get width(): number;
13
- set width(val: number);
14
- get height(): number;
15
- set height(val: number);
16
- get texture(): Texture;
17
- set texture(tex: Texture);
18
- resize(): void;
19
- }
@@ -1,60 +0,0 @@
1
- import { Sprite } from "pixi.js";
2
- import { GameObject } from "../GameObject.js";
3
- export class Image extends GameObject {
4
- display = new Sprite();
5
- _width = 0;
6
- _height = 0;
7
- /**
8
- * 这两个参数主要用于解决从来没有执行过resize或没有宽高进行赋值的情况下,使用默认纹理的宽高进行配置
9
- */
10
- _isSetWidth = false;
11
- _isSetHeight = false;
12
- // get width() {
13
- // return this.display.texture.orig.width;
14
- // }
15
- get width() {
16
- return this._width;
17
- }
18
- set width(val) {
19
- this._width = val;
20
- this._isSetWidth = true;
21
- this.display.width = val;
22
- this.refreshPivot();
23
- this.emitter.emit(GameObject.Event.RESIZE);
24
- }
25
- // get height() {
26
- // return this.display.texture.orig.height;
27
- // }
28
- get height() {
29
- return this._height;
30
- }
31
- set height(val) {
32
- this._height = val;
33
- this._isSetHeight = true;
34
- this.display.height = val;
35
- this.refreshPivot();
36
- this.emitter.emit(GameObject.Event.RESIZE);
37
- }
38
- get texture() {
39
- return this.display.texture;
40
- }
41
- set texture(tex) {
42
- this.display.texture = tex;
43
- if (this._isSetWidth) {
44
- this.display.width = this.width;
45
- }
46
- else {
47
- this._width = this.display.width;
48
- }
49
- if (this._isSetHeight) {
50
- this.display.height = this.height;
51
- }
52
- else {
53
- this._height = this.display.height;
54
- }
55
- }
56
- resize() {
57
- this.width = this.display.texture.width;
58
- this.height = this.display.texture.height;
59
- }
60
- }