modern-canvas 0.4.44 → 0.4.46
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/dist/index.cjs +23 -12
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -7
- package/dist/index.mjs +23 -12
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -239,12 +239,23 @@ function defineProperty(constructor, name, declaration = {}) {
|
|
|
239
239
|
}
|
|
240
240
|
};
|
|
241
241
|
}
|
|
242
|
+
const getDefaultValue = () => typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
242
243
|
Object.defineProperty(constructor.prototype, name, {
|
|
243
244
|
get() {
|
|
244
|
-
|
|
245
|
+
let value = descriptor.get?.call(this);
|
|
246
|
+
if (value === void 0) {
|
|
247
|
+
value = getDefaultValue();
|
|
248
|
+
if (value !== void 0) {
|
|
249
|
+
descriptor.set?.call(this, value);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return value;
|
|
245
253
|
},
|
|
246
254
|
set(value) {
|
|
247
|
-
|
|
255
|
+
let oldValue = descriptor.get?.call(this);
|
|
256
|
+
if (oldValue === void 0) {
|
|
257
|
+
oldValue = getDefaultValue();
|
|
258
|
+
}
|
|
248
259
|
descriptor.set?.call(this, value);
|
|
249
260
|
this.requestUpdate?.(name, oldValue, declaration);
|
|
250
261
|
},
|
|
@@ -505,7 +516,7 @@ class CoreObject extends EventEmitter {
|
|
|
505
516
|
this._defaultProperties = {};
|
|
506
517
|
for (const [name, property] of this.getPropertyDeclarations()) {
|
|
507
518
|
if (!property.protected && !property.alias) {
|
|
508
|
-
this._defaultProperties[name] = property.default;
|
|
519
|
+
this._defaultProperties[name] = typeof property.default === "function" ? property.default() : property.default;
|
|
509
520
|
}
|
|
510
521
|
}
|
|
511
522
|
}
|
|
@@ -5165,7 +5176,7 @@ class GradientTexture extends Texture2D {
|
|
|
5165
5176
|
if (!ctx) {
|
|
5166
5177
|
throw new Error("Failed to parse linear gradient, get canvas context is null.");
|
|
5167
5178
|
}
|
|
5168
|
-
let { angle, stops } = linearGradient;
|
|
5179
|
+
let { angle = 0, stops } = linearGradient;
|
|
5169
5180
|
angle -= Math.PI / 2;
|
|
5170
5181
|
const halfWidth = width / 2;
|
|
5171
5182
|
const halfHeight = height / 2;
|
|
@@ -6051,7 +6062,7 @@ let Node = class extends CoreObject {
|
|
|
6051
6062
|
removeChild(child) {
|
|
6052
6063
|
const index = child.getIndex();
|
|
6053
6064
|
if (this.is(child.parent) && index > -1) {
|
|
6054
|
-
this._children.
|
|
6065
|
+
this._children.getInternal(child.internalMode).splice(index, 1);
|
|
6055
6066
|
child.setParent(void 0);
|
|
6056
6067
|
this.emit("removeChild", child, index);
|
|
6057
6068
|
}
|
|
@@ -6141,7 +6152,7 @@ __decorateClass$R([
|
|
|
6141
6152
|
property({ default: "default" })
|
|
6142
6153
|
], Node.prototype, "internalMode", 2);
|
|
6143
6154
|
__decorateClass$R([
|
|
6144
|
-
property({ default: {} })
|
|
6155
|
+
property({ default: () => ({}) })
|
|
6145
6156
|
], Node.prototype, "meta", 2);
|
|
6146
6157
|
Node = __decorateClass$R([
|
|
6147
6158
|
customNode("Node")
|
|
@@ -6931,7 +6942,7 @@ void main(void) {
|
|
|
6931
6942
|
}`
|
|
6932
6943
|
}));
|
|
6933
6944
|
__decorateClass$L([
|
|
6934
|
-
property({ default: [] })
|
|
6945
|
+
property({ default: () => [] })
|
|
6935
6946
|
], ColorOverlayEffect.prototype, "colors", 2);
|
|
6936
6947
|
__decorateClass$L([
|
|
6937
6948
|
property({ default: 0.5 })
|
|
@@ -7016,7 +7027,7 @@ void main(void) {
|
|
|
7016
7027
|
}`
|
|
7017
7028
|
}));
|
|
7018
7029
|
__decorateClass$K([
|
|
7019
|
-
property({ default: [] })
|
|
7030
|
+
property({ default: () => [] })
|
|
7020
7031
|
], ColorRemoveEffect.prototype, "colors", 2);
|
|
7021
7032
|
__decorateClass$K([
|
|
7022
7033
|
property({ default: 0.5 })
|
|
@@ -8384,7 +8395,7 @@ __decorateClass$A([
|
|
|
8384
8395
|
property({ default: true })
|
|
8385
8396
|
], GodrayEffect.prototype, "parallel", 2);
|
|
8386
8397
|
__decorateClass$A([
|
|
8387
|
-
property({ default: [0, 0] })
|
|
8398
|
+
property({ default: () => [0, 0] })
|
|
8388
8399
|
], GodrayEffect.prototype, "center", 2);
|
|
8389
8400
|
__decorateClass$A([
|
|
8390
8401
|
property({ default: 1 })
|
|
@@ -9312,10 +9323,10 @@ __decorateClass$p([
|
|
|
9312
9323
|
property()
|
|
9313
9324
|
], BaseElement2DShape.prototype, "svg");
|
|
9314
9325
|
__decorateClass$p([
|
|
9315
|
-
property({ default: [0, 0, 1, 1] })
|
|
9326
|
+
property({ default: () => [0, 0, 1, 1] })
|
|
9316
9327
|
], BaseElement2DShape.prototype, "viewBox");
|
|
9317
9328
|
__decorateClass$p([
|
|
9318
|
-
property({ default: [] })
|
|
9329
|
+
property({ default: () => [] })
|
|
9319
9330
|
], BaseElement2DShape.prototype, "data");
|
|
9320
9331
|
|
|
9321
9332
|
class BaseElement2DStyle extends Resource {
|
|
@@ -11255,7 +11266,7 @@ __decorateClass$d([
|
|
|
11255
11266
|
property({ default: false })
|
|
11256
11267
|
], Animation.prototype, "loop", 2);
|
|
11257
11268
|
__decorateClass$d([
|
|
11258
|
-
property({ default: [] })
|
|
11269
|
+
property({ default: () => [] })
|
|
11259
11270
|
], Animation.prototype, "keyframes", 2);
|
|
11260
11271
|
__decorateClass$d([
|
|
11261
11272
|
property()
|