@eva/plugin-renderer-mask 2.1.0-beta.2 → 2.1.0-beta.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eva/plugin-renderer-mask",
3
- "version": "2.1.0-beta.2",
3
+ "version": "2.1.0-beta.3",
4
4
  "description": "@eva/plugin-renderer-mask",
5
5
  "main": "index.js",
6
6
  "module": "dist/plugin-renderer-mask.esm.js",
@@ -19,9 +19,9 @@
19
19
  "homepage": "https://eva.js.org",
20
20
  "dependencies": {
21
21
  "@eva/inspector-decorator": "^2.0.0-beta.0",
22
- "@eva/plugin-renderer": "2.1.0-beta.2",
23
- "@eva/renderer-adapter": "2.1.0-beta.2",
24
- "@eva/eva.js": "2.1.0-beta.2",
22
+ "@eva/plugin-renderer": "2.1.0-beta.3",
23
+ "@eva/renderer-adapter": "2.1.0-beta.3",
24
+ "@eva/eva.js": "2.1.0-beta.3",
25
25
  "pixi.js": "^8.17.0"
26
26
  }
27
27
  }
@@ -1,454 +0,0 @@
1
- function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
- globalThis.EVA = globalThis.EVA || {};
3
- globalThis.EVA.plugin = globalThis.EVA.plugin || {};
4
- globalThis.EVA.plugin.renderer = globalThis.EVA.plugin.renderer || {};
5
- var _EVA_IIFE_mask = function (exports, eva_js, pluginRenderer, rendererAdapter) {
6
- 'use strict';
7
- function __rest$1(s, e) {
8
- var t = {};
9
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
10
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
11
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
12
- }
13
- return t;
14
- }
15
- function __decorate(decorators, target, key, desc) {
16
- var c = arguments.length,
17
- r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
18
- d;
19
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
20
- return c > 3 && r && Object.defineProperty(target, key, r), r;
21
- }
22
- function __metadata(metadataKey, metadataValue) {
23
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
24
- }
25
- function __awaiter(thisArg, _arguments, P, generator) {
26
- function adopt(value) {
27
- return value instanceof P ? value : new P(function (resolve) {
28
- resolve(value);
29
- });
30
- }
31
- return new (P || (P = Promise))(function (resolve, reject) {
32
- function fulfilled(value) {
33
- try {
34
- step(generator.next(value));
35
- } catch (e) {
36
- reject(e);
37
- }
38
- }
39
- function rejected(value) {
40
- try {
41
- step(generator["throw"](value));
42
- } catch (e) {
43
- reject(e);
44
- }
45
- }
46
- function step(result) {
47
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
48
- }
49
- step((generator = generator.apply(thisArg, _arguments || [])).next());
50
- });
51
- }
52
- function __rest(s, e) {
53
- var t = {};
54
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
55
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
56
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
57
- }
58
- return t;
59
- }
60
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
61
- var e = new Error(message);
62
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
63
- };
64
- class SymbolKeysNotSupportedError extends Error {
65
- constructor() {
66
- super('Symbol keys are not supported yet!');
67
- Object.setPrototypeOf(this, new.target.prototype);
68
- }
69
- }
70
- const IDE_PROPERTY_METADATA = 'IDE_PROPERTY_METADATA';
71
- function transformBasicType(type) {
72
- if (type === String) {
73
- return 'string';
74
- }
75
- if (type === Number) {
76
- return 'number';
77
- }
78
- if (type === Boolean) {
79
- return 'boolean';
80
- }
81
- return 'unknown';
82
- }
83
- function defineLegacyIDEProp(target, propertyKey, patch) {
84
- const constructor = target.constructor;
85
- const current = constructor.IDEProps || {};
86
- current[propertyKey] = _extends(_extends({
87
- key: propertyKey
88
- }, current[propertyKey]), patch);
89
- constructor.IDEProps = current;
90
- }
91
- function defineTypes(target, key, options, returnTypeFunction) {
92
- let type = Reflect.getMetadata('design:type', target, key);
93
- let isArray = type === Array;
94
- const str = transformBasicType(type);
95
- if (str !== 'unknown') {
96
- type = str;
97
- }
98
- if (returnTypeFunction) {
99
- const returnType = returnTypeFunction();
100
- if (Array.isArray(returnType)) {
101
- isArray = true;
102
- type = returnType[0];
103
- } else {
104
- type = returnType;
105
- }
106
- }
107
- const properties = Reflect.getMetadata(IDE_PROPERTY_METADATA, target.constructor) || {};
108
- const current = properties[key] || {};
109
- const property = _extends(_extends(_extends({}, current), {
110
- type,
111
- isArray: isArray
112
- }), options);
113
- properties[key] = property;
114
- Reflect.defineMetadata(IDE_PROPERTY_METADATA, properties, target.constructor);
115
- const legacyProperty = __rest(property, ["isArray"]);
116
- defineLegacyIDEProp(target, key, legacyProperty);
117
- }
118
- function type(type) {
119
- return Field({
120
- type
121
- });
122
- }
123
- function getTypeDecoratorParams(returnTypeFuncOrOptions, maybeOptions) {
124
- if (typeof returnTypeFuncOrOptions === 'function') {
125
- return {
126
- returnTypeFunc: returnTypeFuncOrOptions,
127
- options: maybeOptions || {}
128
- };
129
- }
130
- return {
131
- options: returnTypeFuncOrOptions || {}
132
- };
133
- }
134
- function Field(returnTypeFunction, maybeOptions) {
135
- return (target, propertyKey) => {
136
- if (typeof propertyKey === 'symbol') {
137
- throw new SymbolKeysNotSupportedError();
138
- }
139
- const {
140
- options,
141
- returnTypeFunc
142
- } = getTypeDecoratorParams(returnTypeFunction, maybeOptions);
143
- defineTypes(target, propertyKey, options, returnTypeFunc);
144
- };
145
- }
146
- var ExecuteMode;
147
- (function (ExecuteMode) {
148
- ExecuteMode[ExecuteMode["Edit"] = 2] = "Edit";
149
- ExecuteMode[ExecuteMode["Game"] = 4] = "Game";
150
- ExecuteMode[ExecuteMode["All"] = 6] = "All";
151
- })(ExecuteMode || (ExecuteMode = {}));
152
- exports.MASK_TYPE = void 0;
153
- (function (MASK_TYPE) {
154
- MASK_TYPE["Circle"] = "Circle";
155
- MASK_TYPE["Ellipse"] = "Ellipse";
156
- MASK_TYPE["Rect"] = "Rect";
157
- MASK_TYPE["RoundedRect"] = "RoundedRect";
158
- MASK_TYPE["Polygon"] = "Polygon";
159
- MASK_TYPE["Img"] = "Img";
160
- MASK_TYPE["Sprite"] = "Sprite";
161
- })(exports.MASK_TYPE || (exports.MASK_TYPE = {}));
162
- class Mask$2 extends eva_js.Component {
163
- constructor(params) {
164
- super(params);
165
- this.type = exports.MASK_TYPE.Rect;
166
- this.style = {};
167
- this.x = 0;
168
- this.y = 0;
169
- this.resource = '';
170
- this.spriteName = '';
171
- this.enabled = true;
172
- this.init(params);
173
- }
174
- init(obj) {
175
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
176
- if (!obj) return;
177
- const {
178
- style
179
- } = obj,
180
- rest = __rest$1(obj, ["style"]);
181
- _extends(this, rest);
182
- this.style = _extends(_extends(_extends({}, this.style), style), {
183
- x: (_d = (_b = (_a = obj.x) !== null && _a !== void 0 ? _a : style === null || style === void 0 ? void 0 : style.x) !== null && _b !== void 0 ? _b : (_c = this.style) === null || _c === void 0 ? void 0 : _c.x) !== null && _d !== void 0 ? _d : this.x,
184
- y: (_h = (_f = (_e = obj.y) !== null && _e !== void 0 ? _e : style === null || style === void 0 ? void 0 : style.y) !== null && _f !== void 0 ? _f : (_g = this.style) === null || _g === void 0 ? void 0 : _g.y) !== null && _h !== void 0 ? _h : this.y,
185
- radius: (_k = (_j = obj.radius) !== null && _j !== void 0 ? _j : style === null || style === void 0 ? void 0 : style.radius) !== null && _k !== void 0 ? _k : (_l = this.style) === null || _l === void 0 ? void 0 : _l.radius,
186
- width: (_o = (_m = obj.width) !== null && _m !== void 0 ? _m : style === null || style === void 0 ? void 0 : style.width) !== null && _o !== void 0 ? _o : (_p = this.style) === null || _p === void 0 ? void 0 : _p.width,
187
- height: (_r = (_q = obj.height) !== null && _q !== void 0 ? _q : style === null || style === void 0 ? void 0 : style.height) !== null && _r !== void 0 ? _r : (_s = this.style) === null || _s === void 0 ? void 0 : _s.height,
188
- paths: (_u = (_t = obj.paths) !== null && _t !== void 0 ? _t : style === null || style === void 0 ? void 0 : style.paths) !== null && _u !== void 0 ? _u : (_v = this.style) === null || _v === void 0 ? void 0 : _v.paths
189
- });
190
- this.x = (_w = this.style.x) !== null && _w !== void 0 ? _w : 0;
191
- this.y = (_x = this.style.y) !== null && _x !== void 0 ? _x : 0;
192
- this.radius = this.style.radius;
193
- this.width = this.style.width;
194
- this.height = this.style.height;
195
- this.paths = this.style.paths;
196
- }
197
- destroy() {
198
- return this;
199
- }
200
- }
201
- Mask$2.componentName = 'Mask';
202
- __decorate([type('number'), __metadata("design:type", Number)], Mask$2.prototype, "x", void 0);
203
- __decorate([type('number'), __metadata("design:type", Number)], Mask$2.prototype, "y", void 0);
204
- __decorate([type('number'), __metadata("design:type", Number)], Mask$2.prototype, "radius", void 0);
205
- __decorate([type('number'), __metadata("design:type", Number)], Mask$2.prototype, "width", void 0);
206
- __decorate([type('number'), __metadata("design:type", Number)], Mask$2.prototype, "height", void 0);
207
- __decorate([type('string'), __metadata("design:type", String)], Mask$2.prototype, "resource", void 0);
208
- __decorate([type('string'), __metadata("design:type", String)], Mask$2.prototype, "spriteName", void 0);
209
- __decorate([type('boolean'), __metadata("design:type", Boolean)], Mask$2.prototype, "enabled", void 0);
210
- const resourceKeySplit = '_s|r|c_';
211
- const propertyForGraphics = {
212
- Circle: ['x', 'y', 'radius'],
213
- Ellipse: ['x', 'y', 'width', 'height'],
214
- Rect: ['x', 'y', 'width', 'height'],
215
- RoundedRect: ['x', 'y', 'width', 'height', 'radius'],
216
- Polygon: ['paths']
217
- };
218
- const functionForGraphics = {
219
- Circle: 'circle',
220
- Ellipse: 'ellipse',
221
- Rect: 'rect',
222
- RoundedRect: 'roundRect',
223
- Polygon: 'poly'
224
- };
225
- const maskTypeAliases = {
226
- circle: exports.MASK_TYPE.Circle,
227
- ellipse: exports.MASK_TYPE.Ellipse,
228
- rect: exports.MASK_TYPE.Rect,
229
- roundedrect: exports.MASK_TYPE.RoundedRect,
230
- roundedRect: exports.MASK_TYPE.RoundedRect,
231
- polygon: exports.MASK_TYPE.Polygon,
232
- img: exports.MASK_TYPE.Img,
233
- image: exports.MASK_TYPE.Img,
234
- sprite: exports.MASK_TYPE.Sprite
235
- };
236
- function normalizeMaskType(type) {
237
- if (!type) return undefined;
238
- if (Object.values(exports.MASK_TYPE).includes(type)) return type;
239
- return maskTypeAliases[String(type)] || maskTypeAliases[String(type).toLowerCase()];
240
- }
241
- let Mask = class Mask extends pluginRenderer.Renderer {
242
- constructor() {
243
- super(...arguments);
244
- this.name = 'MaskSystem';
245
- this.changedCache = {};
246
- this.maskSpriteCache = {};
247
- }
248
- init() {
249
- this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
250
- this.renderSystem.rendererManager.register(this);
251
- }
252
- rendererUpdate() {
253
- this.changedCache = {};
254
- }
255
- componentChanged(changed) {
256
- if (changed.component.name !== 'Mask') return;
257
- switch (changed.type) {
258
- case eva_js.OBSERVER_TYPE.ADD:
259
- this.add(changed);
260
- break;
261
- case eva_js.OBSERVER_TYPE.REMOVE:
262
- this.remove(changed);
263
- break;
264
- case eva_js.OBSERVER_TYPE.CHANGE:
265
- this.change(changed);
266
- break;
267
- }
268
- }
269
- add(changed) {
270
- const component = changed.component;
271
- if (component.enabled === false) return;
272
- const maskType = normalizeMaskType(component.type);
273
- if (!maskType) {
274
- throw new Error('no have Mask type: ' + component.type);
275
- }
276
- if (!component.style) {
277
- throw new Error('no have Mask style: ' + component.type);
278
- }
279
- let mask;
280
- switch (maskType) {
281
- case exports.MASK_TYPE.Circle:
282
- mask = this.createGraphics(component);
283
- break;
284
- case exports.MASK_TYPE.Ellipse:
285
- mask = this.createGraphics(component);
286
- break;
287
- case exports.MASK_TYPE.Rect:
288
- mask = this.createGraphics(component);
289
- break;
290
- case exports.MASK_TYPE.RoundedRect:
291
- mask = this.createGraphics(component);
292
- break;
293
- case exports.MASK_TYPE.Polygon:
294
- mask = this.createGraphics(component);
295
- break;
296
- case exports.MASK_TYPE.Img:
297
- mask = this.createSprite(component);
298
- break;
299
- case exports.MASK_TYPE.Sprite:
300
- mask = this.createSprite(component);
301
- break;
302
- }
303
- if (!mask) {
304
- throw new Error('no have mask instance, check your mask params: ' + component.type);
305
- }
306
- const container = this.containerManager.getContainer(changed.gameObject.id);
307
- container.mask = mask;
308
- container.addChild(mask);
309
- }
310
- remove(changed) {
311
- const container = this.containerManager.getContainer(changed.gameObject.id);
312
- if (!(container === null || container === void 0 ? void 0 : container.mask)) return;
313
- container.removeChild(container.mask);
314
- container.mask.destroy({
315
- children: true
316
- });
317
- container.mask = null;
318
- delete this.maskSpriteCache[changed.gameObject.id];
319
- }
320
- change(changed) {
321
- if (this.changedCache[changed.gameObject.id]) return;
322
- const component = changed.component;
323
- if (changed.prop.prop[0] === 'enabled') {
324
- this.changedCache[changed.gameObject.id] = true;
325
- if (component.enabled === false) {
326
- this.remove(changed);
327
- } else {
328
- this.add(changed);
329
- }
330
- return;
331
- }
332
- if (changed.prop.prop[0] === 'type') {
333
- this.changedCache[changed.gameObject.id] = true;
334
- const maskType = normalizeMaskType(component.type);
335
- const lastType = normalizeMaskType(component._lastType);
336
- if ([exports.MASK_TYPE.Sprite, exports.MASK_TYPE.Img].indexOf(maskType) > -1 || lastType !== maskType) {
337
- this.remove(changed);
338
- this.add(changed);
339
- component._lastType = component.type;
340
- } else {
341
- this.redrawGraphics(changed);
342
- }
343
- } else if (['style', 'x', 'y', 'radius', 'width', 'height', 'paths'].indexOf(changed.prop.prop[0]) > -1) {
344
- this.syncComponentStyle(component);
345
- const maskType = normalizeMaskType(component.type);
346
- if ([exports.MASK_TYPE.Sprite, exports.MASK_TYPE.Img].indexOf(maskType) > -1) {
347
- this.changeSpriteStyle(component);
348
- } else {
349
- this.redrawGraphics(changed);
350
- }
351
- } else if (changed.prop.prop[0] === 'resource') {
352
- this.changedCache[changed.gameObject.id] = true;
353
- this.changeSprite(component);
354
- } else if (changed.prop.prop[0] === 'spriteName') {
355
- this.changedCache[changed.gameObject.id] = true;
356
- this.changeSprite(component);
357
- }
358
- }
359
- createGraphics(component) {
360
- const graphics = new rendererAdapter.Graphics();
361
- this.draw(graphics, component);
362
- return graphics;
363
- }
364
- redrawGraphics(changed) {
365
- const container = this.containerManager.getContainer(changed.gameObject.id);
366
- const graphics = container.mask;
367
- graphics.clear();
368
- this.draw(graphics, changed.component);
369
- }
370
- draw(graphics, component) {
371
- const maskType = normalizeMaskType(component.type);
372
- const style = this.syncComponentStyle(component);
373
- const params = [];
374
- for (const key of propertyForGraphics[maskType]) {
375
- params.push(style[key]);
376
- }
377
- graphics[functionForGraphics[maskType]](...params);
378
- graphics.fill(0x000000);
379
- }
380
- createSprite(component) {
381
- const sprite = new rendererAdapter.Sprite(null);
382
- this.maskSpriteCache[component.gameObject.id] = sprite;
383
- this.setSprite(component, sprite);
384
- return sprite.sprite;
385
- }
386
- changeSpriteStyle(component) {
387
- const sprite = this.maskSpriteCache[component.gameObject.id];
388
- sprite.sprite.width = component.style.width;
389
- sprite.sprite.height = component.style.height;
390
- sprite.sprite.position.x = component.style.x;
391
- sprite.sprite.position.y = component.style.y;
392
- }
393
- changeSprite(component) {
394
- const sprite = this.maskSpriteCache[component.gameObject.id];
395
- this.setSprite(component, sprite);
396
- }
397
- setSprite(component, sprite) {
398
- var _a, _b;
399
- return __awaiter(this, void 0, void 0, function* () {
400
- const maskType = normalizeMaskType(component.type);
401
- let res;
402
- try {
403
- const asyncId = this.increaseAsyncId(component.gameObject.id);
404
- res = yield eva_js.resource.getResource(component.resource);
405
- if (!this.validateAsyncId(component.gameObject.id, asyncId)) return;
406
- } catch (e) {
407
- throw new Error('mask resource load error');
408
- }
409
- if (maskType === exports.MASK_TYPE.Sprite) {
410
- const img = component.resource + resourceKeySplit + component.spriteName;
411
- const texture = (_a = res === null || res === void 0 ? void 0 : res.instance) === null || _a === void 0 ? void 0 : _a[img];
412
- if (texture) {
413
- sprite.image = texture;
414
- }
415
- } else {
416
- if ((_b = res === null || res === void 0 ? void 0 : res.data) === null || _b === void 0 ? void 0 : _b.image) {
417
- sprite.image = res.data.image;
418
- }
419
- }
420
- sprite.sprite.width = component.style.width;
421
- sprite.sprite.height = component.style.height;
422
- sprite.sprite.position.x = component.style.x;
423
- sprite.sprite.position.y = component.style.y;
424
- });
425
- }
426
- syncComponentStyle(component) {
427
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
428
- component.style = _extends(_extends({}, component.style), {
429
- x: (_c = (_a = component.x) !== null && _a !== void 0 ? _a : (_b = component.style) === null || _b === void 0 ? void 0 : _b.x) !== null && _c !== void 0 ? _c : 0,
430
- y: (_f = (_d = component.y) !== null && _d !== void 0 ? _d : (_e = component.style) === null || _e === void 0 ? void 0 : _e.y) !== null && _f !== void 0 ? _f : 0,
431
- radius: (_g = component.radius) !== null && _g !== void 0 ? _g : (_h = component.style) === null || _h === void 0 ? void 0 : _h.radius,
432
- width: (_j = component.width) !== null && _j !== void 0 ? _j : (_k = component.style) === null || _k === void 0 ? void 0 : _k.width,
433
- height: (_l = component.height) !== null && _l !== void 0 ? _l : (_m = component.style) === null || _m === void 0 ? void 0 : _m.height,
434
- paths: (_o = component.paths) !== null && _o !== void 0 ? _o : (_p = component.style) === null || _p === void 0 ? void 0 : _p.paths
435
- });
436
- return component.style;
437
- }
438
- };
439
- Mask.systemName = 'MaskSystem';
440
- Mask = __decorate([eva_js.decorators.componentObserver({
441
- Mask: ['type', {
442
- prop: ['style'],
443
- deep: true
444
- }, 'x', 'y', 'radius', 'width', 'height', 'paths', 'resource', 'spriteName', 'enabled']
445
- })], Mask);
446
- var Mask$1 = Mask;
447
- exports.Mask = Mask$2;
448
- exports.MaskSystem = Mask$1;
449
- Object.defineProperty(exports, '__esModule', {
450
- value: true
451
- });
452
- return exports;
453
- }({}, EVA, EVA.plugin.renderer, EVA.rendererAdapter);
454
- globalThis.EVA.plugin.renderer.mask = globalThis.EVA.plugin.renderer.mask || _EVA_IIFE_mask;
@@ -1 +0,0 @@
1
- function _extends(){return _extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var r in i)({}).hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e},_extends.apply(null,arguments)}globalThis.EVA=globalThis.EVA||{},globalThis.EVA.plugin=globalThis.EVA.plugin||{},globalThis.EVA.plugin.renderer=globalThis.EVA.plugin.renderer||{};var _EVA_IIFE_mask=function(e,t,i,r){"use strict";function n(e,t,i,r){var n,s=arguments.length,o=s<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,r);else for(var l=e.length-1;l>=0;l--)(n=e[l])&&(o=(s<3?n(o):s>3?n(t,i,o):n(t,i))||o);return s>3&&o&&Object.defineProperty(t,i,o),o}function s(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function o(e,t,i,r){return new(i||(i=Promise))(function(n,s){function o(e){try{a(r.next(e))}catch(e){s(e)}}function l(e){try{a(r.throw(e))}catch(e){s(e)}}function a(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(o,l)}a((r=r.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class l extends Error{constructor(){super("Symbol keys are not supported yet!"),Object.setPrototypeOf(this,new.target.prototype)}}const a="IDE_PROPERTY_METADATA";function d(e,t,i,r){let n=Reflect.getMetadata("design:type",e,t),s=n===Array;const o=function(e){return e===String?"string":e===Number?"number":e===Boolean?"boolean":"unknown"}(n);if("unknown"!==o&&(n=o),r){const e=r();Array.isArray(e)?(s=!0,n=e[0]):n=e}const l=Reflect.getMetadata(a,e.constructor)||{},d=_extends(_extends(_extends({},l[t]||{}),{type:n,isArray:s}),i);l[t]=d,Reflect.defineMetadata(a,l,e.constructor);!function(e,t,i){const r=e.constructor,n=r.IDEProps||{};n[t]=_extends(_extends({key:t},n[t]),i),r.IDEProps=n}(e,t,function(e,t){var i={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(i[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(e);n<r.length;n++)t.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(e,r[n])&&(i[r[n]]=e[r[n]])}return i}(d,["isArray"]))}function c(e){return t={type:e},(e,r)=>{if("symbol"==typeof r)throw new l;const{options:n,returnTypeFunc:s}=function(e,t){return"function"==typeof e?{returnTypeFunc:e,options:t||{}}:{options:e||{}}}(t,i);d(e,r,n,s)};var t,i}var p,h;!function(e){e[e.Edit=2]="Edit",e[e.Game=4]="Game",e[e.All=6]="All"}(p||(p={})),e.MASK_TYPE=void 0,(h=e.MASK_TYPE||(e.MASK_TYPE={})).Circle="Circle",h.Ellipse="Ellipse",h.Rect="Rect",h.RoundedRect="RoundedRect",h.Polygon="Polygon",h.Img="Img",h.Sprite="Sprite";class u extends t.Component{constructor(t){super(t),this.type=e.MASK_TYPE.Rect,this.style={},this.x=0,this.y=0,this.resource="",this.spriteName="",this.enabled=!0,this.init(t)}init(e){var t,i,r,n,s,o,l,a,d,c,p,h,u,y,g,v,m,f,E,S,b,_;if(!e)return;const{style:w}=e;_extends(this,function(e,t){var i={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(i[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(e);n<r.length;n++)t.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(e,r[n])&&(i[r[n]]=e[r[n]])}return i}(e,["style"])),this.style=_extends(_extends(_extends({},this.style),w),{x:null!==(n=null!==(i=null!==(t=e.x)&&void 0!==t?t:null==w?void 0:w.x)&&void 0!==i?i:null===(r=this.style)||void 0===r?void 0:r.x)&&void 0!==n?n:this.x,y:null!==(a=null!==(o=null!==(s=e.y)&&void 0!==s?s:null==w?void 0:w.y)&&void 0!==o?o:null===(l=this.style)||void 0===l?void 0:l.y)&&void 0!==a?a:this.y,radius:null!==(c=null!==(d=e.radius)&&void 0!==d?d:null==w?void 0:w.radius)&&void 0!==c?c:null===(p=this.style)||void 0===p?void 0:p.radius,width:null!==(u=null!==(h=e.width)&&void 0!==h?h:null==w?void 0:w.width)&&void 0!==u?u:null===(y=this.style)||void 0===y?void 0:y.width,height:null!==(v=null!==(g=e.height)&&void 0!==g?g:null==w?void 0:w.height)&&void 0!==v?v:null===(m=this.style)||void 0===m?void 0:m.height,paths:null!==(E=null!==(f=e.paths)&&void 0!==f?f:null==w?void 0:w.paths)&&void 0!==E?E:null===(S=this.style)||void 0===S?void 0:S.paths}),this.x=null!==(b=this.style.x)&&void 0!==b?b:0,this.y=null!==(_=this.style.y)&&void 0!==_?_:0,this.radius=this.style.radius,this.width=this.style.width,this.height=this.style.height,this.paths=this.style.paths}destroy(){return this}}u.componentName="Mask",n([c("number"),s("design:type",Number)],u.prototype,"x",void 0),n([c("number"),s("design:type",Number)],u.prototype,"y",void 0),n([c("number"),s("design:type",Number)],u.prototype,"radius",void 0),n([c("number"),s("design:type",Number)],u.prototype,"width",void 0),n([c("number"),s("design:type",Number)],u.prototype,"height",void 0),n([c("string"),s("design:type",String)],u.prototype,"resource",void 0),n([c("string"),s("design:type",String)],u.prototype,"spriteName",void 0),n([c("boolean"),s("design:type",Boolean)],u.prototype,"enabled",void 0);const y={Circle:["x","y","radius"],Ellipse:["x","y","width","height"],Rect:["x","y","width","height"],RoundedRect:["x","y","width","height","radius"],Polygon:["paths"]},g={Circle:"circle",Ellipse:"ellipse",Rect:"rect",RoundedRect:"roundRect",Polygon:"poly"},v={circle:e.MASK_TYPE.Circle,ellipse:e.MASK_TYPE.Ellipse,rect:e.MASK_TYPE.Rect,roundedrect:e.MASK_TYPE.RoundedRect,roundedRect:e.MASK_TYPE.RoundedRect,polygon:e.MASK_TYPE.Polygon,img:e.MASK_TYPE.Img,image:e.MASK_TYPE.Img,sprite:e.MASK_TYPE.Sprite};function m(t){if(t)return Object.values(e.MASK_TYPE).includes(t)?t:v[String(t)]||v[String(t).toLowerCase()]}let f=class extends i.Renderer{constructor(){super(...arguments),this.name="MaskSystem",this.changedCache={},this.maskSpriteCache={}}init(){this.renderSystem=this.game.getSystem(i.RendererSystem),this.renderSystem.rendererManager.register(this)}rendererUpdate(){this.changedCache={}}componentChanged(e){if("Mask"===e.component.name)switch(e.type){case t.OBSERVER_TYPE.ADD:this.add(e);break;case t.OBSERVER_TYPE.REMOVE:this.remove(e);break;case t.OBSERVER_TYPE.CHANGE:this.change(e)}}add(t){const i=t.component;if(!1===i.enabled)return;const r=m(i.type);if(!r)throw new Error("no have Mask type: "+i.type);if(!i.style)throw new Error("no have Mask style: "+i.type);let n;switch(r){case e.MASK_TYPE.Circle:case e.MASK_TYPE.Ellipse:case e.MASK_TYPE.Rect:case e.MASK_TYPE.RoundedRect:case e.MASK_TYPE.Polygon:n=this.createGraphics(i);break;case e.MASK_TYPE.Img:case e.MASK_TYPE.Sprite:n=this.createSprite(i)}if(!n)throw new Error("no have mask instance, check your mask params: "+i.type);const s=this.containerManager.getContainer(t.gameObject.id);s.mask=n,s.addChild(n)}remove(e){const t=this.containerManager.getContainer(e.gameObject.id);(null==t?void 0:t.mask)&&(t.removeChild(t.mask),t.mask.destroy({children:!0}),t.mask=null,delete this.maskSpriteCache[e.gameObject.id])}change(t){if(this.changedCache[t.gameObject.id])return;const i=t.component;if("enabled"===t.prop.prop[0])return this.changedCache[t.gameObject.id]=!0,void(!1===i.enabled?this.remove(t):this.add(t));if("type"===t.prop.prop[0]){this.changedCache[t.gameObject.id]=!0;const r=m(i.type),n=m(i._lastType);[e.MASK_TYPE.Sprite,e.MASK_TYPE.Img].indexOf(r)>-1||n!==r?(this.remove(t),this.add(t),i._lastType=i.type):this.redrawGraphics(t)}else if(["style","x","y","radius","width","height","paths"].indexOf(t.prop.prop[0])>-1){this.syncComponentStyle(i);const r=m(i.type);[e.MASK_TYPE.Sprite,e.MASK_TYPE.Img].indexOf(r)>-1?this.changeSpriteStyle(i):this.redrawGraphics(t)}else("resource"===t.prop.prop[0]||"spriteName"===t.prop.prop[0])&&(this.changedCache[t.gameObject.id]=!0,this.changeSprite(i))}createGraphics(e){const t=new r.Graphics;return this.draw(t,e),t}redrawGraphics(e){const t=this.containerManager.getContainer(e.gameObject.id).mask;t.clear(),this.draw(t,e.component)}draw(e,t){const i=m(t.type),r=this.syncComponentStyle(t),n=[];for(const e of y[i])n.push(r[e]);e[g[i]](...n),e.fill(0)}createSprite(e){const t=new r.Sprite(null);return this.maskSpriteCache[e.gameObject.id]=t,this.setSprite(e,t),t.sprite}changeSpriteStyle(e){const t=this.maskSpriteCache[e.gameObject.id];t.sprite.width=e.style.width,t.sprite.height=e.style.height,t.sprite.position.x=e.style.x,t.sprite.position.y=e.style.y}changeSprite(e){const t=this.maskSpriteCache[e.gameObject.id];this.setSprite(e,t)}setSprite(i,r){var n,s;return o(this,void 0,void 0,function*(){const o=m(i.type);let l;try{const e=this.increaseAsyncId(i.gameObject.id);if(l=yield t.resource.getResource(i.resource),!this.validateAsyncId(i.gameObject.id,e))return}catch(e){throw new Error("mask resource load error")}if(o===e.MASK_TYPE.Sprite){const e=i.resource+"_s|r|c_"+i.spriteName,t=null===(n=null==l?void 0:l.instance)||void 0===n?void 0:n[e];t&&(r.image=t)}else(null===(s=null==l?void 0:l.data)||void 0===s?void 0:s.image)&&(r.image=l.data.image);r.sprite.width=i.style.width,r.sprite.height=i.style.height,r.sprite.position.x=i.style.x,r.sprite.position.y=i.style.y})}syncComponentStyle(e){var t,i,r,n,s,o,l,a,d,c,p,h,u,y;return e.style=_extends(_extends({},e.style),{x:null!==(r=null!==(t=e.x)&&void 0!==t?t:null===(i=e.style)||void 0===i?void 0:i.x)&&void 0!==r?r:0,y:null!==(o=null!==(n=e.y)&&void 0!==n?n:null===(s=e.style)||void 0===s?void 0:s.y)&&void 0!==o?o:0,radius:null!==(l=e.radius)&&void 0!==l?l:null===(a=e.style)||void 0===a?void 0:a.radius,width:null!==(d=e.width)&&void 0!==d?d:null===(c=e.style)||void 0===c?void 0:c.width,height:null!==(p=e.height)&&void 0!==p?p:null===(h=e.style)||void 0===h?void 0:h.height,paths:null!==(u=e.paths)&&void 0!==u?u:null===(y=e.style)||void 0===y?void 0:y.paths}),e.style}};f.systemName="MaskSystem",f=n([t.decorators.componentObserver({Mask:["type",{prop:["style"],deep:!0},"x","y","radius","width","height","paths","resource","spriteName","enabled"]})],f);var E=f;return e.Mask=u,e.MaskSystem=E,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.plugin.renderer,EVA.rendererAdapter);globalThis.EVA.plugin.renderer.mask=globalThis.EVA.plugin.renderer.mask||_EVA_IIFE_mask;