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.cjs
CHANGED
|
@@ -245,12 +245,23 @@ function defineProperty(constructor, name, declaration = {}) {
|
|
|
245
245
|
}
|
|
246
246
|
};
|
|
247
247
|
}
|
|
248
|
+
const getDefaultValue = () => typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
248
249
|
Object.defineProperty(constructor.prototype, name, {
|
|
249
250
|
get() {
|
|
250
|
-
|
|
251
|
+
let value = descriptor.get?.call(this);
|
|
252
|
+
if (value === void 0) {
|
|
253
|
+
value = getDefaultValue();
|
|
254
|
+
if (value !== void 0) {
|
|
255
|
+
descriptor.set?.call(this, value);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return value;
|
|
251
259
|
},
|
|
252
260
|
set(value) {
|
|
253
|
-
|
|
261
|
+
let oldValue = descriptor.get?.call(this);
|
|
262
|
+
if (oldValue === void 0) {
|
|
263
|
+
oldValue = getDefaultValue();
|
|
264
|
+
}
|
|
254
265
|
descriptor.set?.call(this, value);
|
|
255
266
|
this.requestUpdate?.(name, oldValue, declaration);
|
|
256
267
|
},
|
|
@@ -511,7 +522,7 @@ class CoreObject extends EventEmitter {
|
|
|
511
522
|
this._defaultProperties = {};
|
|
512
523
|
for (const [name, property] of this.getPropertyDeclarations()) {
|
|
513
524
|
if (!property.protected && !property.alias) {
|
|
514
|
-
this._defaultProperties[name] = property.default;
|
|
525
|
+
this._defaultProperties[name] = typeof property.default === "function" ? property.default() : property.default;
|
|
515
526
|
}
|
|
516
527
|
}
|
|
517
528
|
}
|
|
@@ -5171,7 +5182,7 @@ class GradientTexture extends Texture2D {
|
|
|
5171
5182
|
if (!ctx) {
|
|
5172
5183
|
throw new Error("Failed to parse linear gradient, get canvas context is null.");
|
|
5173
5184
|
}
|
|
5174
|
-
let { angle, stops } = linearGradient;
|
|
5185
|
+
let { angle = 0, stops } = linearGradient;
|
|
5175
5186
|
angle -= Math.PI / 2;
|
|
5176
5187
|
const halfWidth = width / 2;
|
|
5177
5188
|
const halfHeight = height / 2;
|
|
@@ -6057,7 +6068,7 @@ exports.Node = class Node extends CoreObject {
|
|
|
6057
6068
|
removeChild(child) {
|
|
6058
6069
|
const index = child.getIndex();
|
|
6059
6070
|
if (this.is(child.parent) && index > -1) {
|
|
6060
|
-
this._children.
|
|
6071
|
+
this._children.getInternal(child.internalMode).splice(index, 1);
|
|
6061
6072
|
child.setParent(void 0);
|
|
6062
6073
|
this.emit("removeChild", child, index);
|
|
6063
6074
|
}
|
|
@@ -6147,7 +6158,7 @@ __decorateClass$R([
|
|
|
6147
6158
|
property({ default: "default" })
|
|
6148
6159
|
], exports.Node.prototype, "internalMode", 2);
|
|
6149
6160
|
__decorateClass$R([
|
|
6150
|
-
property({ default: {} })
|
|
6161
|
+
property({ default: () => ({}) })
|
|
6151
6162
|
], exports.Node.prototype, "meta", 2);
|
|
6152
6163
|
exports.Node = __decorateClass$R([
|
|
6153
6164
|
customNode("Node")
|
|
@@ -6937,7 +6948,7 @@ void main(void) {
|
|
|
6937
6948
|
}`
|
|
6938
6949
|
}));
|
|
6939
6950
|
__decorateClass$L([
|
|
6940
|
-
property({ default: [] })
|
|
6951
|
+
property({ default: () => [] })
|
|
6941
6952
|
], exports.ColorOverlayEffect.prototype, "colors", 2);
|
|
6942
6953
|
__decorateClass$L([
|
|
6943
6954
|
property({ default: 0.5 })
|
|
@@ -7022,7 +7033,7 @@ void main(void) {
|
|
|
7022
7033
|
}`
|
|
7023
7034
|
}));
|
|
7024
7035
|
__decorateClass$K([
|
|
7025
|
-
property({ default: [] })
|
|
7036
|
+
property({ default: () => [] })
|
|
7026
7037
|
], exports.ColorRemoveEffect.prototype, "colors", 2);
|
|
7027
7038
|
__decorateClass$K([
|
|
7028
7039
|
property({ default: 0.5 })
|
|
@@ -8390,7 +8401,7 @@ __decorateClass$A([
|
|
|
8390
8401
|
property({ default: true })
|
|
8391
8402
|
], exports.GodrayEffect.prototype, "parallel", 2);
|
|
8392
8403
|
__decorateClass$A([
|
|
8393
|
-
property({ default: [0, 0] })
|
|
8404
|
+
property({ default: () => [0, 0] })
|
|
8394
8405
|
], exports.GodrayEffect.prototype, "center", 2);
|
|
8395
8406
|
__decorateClass$A([
|
|
8396
8407
|
property({ default: 1 })
|
|
@@ -9318,10 +9329,10 @@ __decorateClass$p([
|
|
|
9318
9329
|
property()
|
|
9319
9330
|
], BaseElement2DShape.prototype, "svg");
|
|
9320
9331
|
__decorateClass$p([
|
|
9321
|
-
property({ default: [0, 0, 1, 1] })
|
|
9332
|
+
property({ default: () => [0, 0, 1, 1] })
|
|
9322
9333
|
], BaseElement2DShape.prototype, "viewBox");
|
|
9323
9334
|
__decorateClass$p([
|
|
9324
|
-
property({ default: [] })
|
|
9335
|
+
property({ default: () => [] })
|
|
9325
9336
|
], BaseElement2DShape.prototype, "data");
|
|
9326
9337
|
|
|
9327
9338
|
class BaseElement2DStyle extends Resource {
|
|
@@ -11261,7 +11272,7 @@ __decorateClass$d([
|
|
|
11261
11272
|
property({ default: false })
|
|
11262
11273
|
], exports.Animation.prototype, "loop", 2);
|
|
11263
11274
|
__decorateClass$d([
|
|
11264
|
-
property({ default: [] })
|
|
11275
|
+
property({ default: () => [] })
|
|
11265
11276
|
], exports.Animation.prototype, "keyframes", 2);
|
|
11266
11277
|
__decorateClass$d([
|
|
11267
11278
|
property()
|
package/dist/index.d.cts
CHANGED
|
@@ -20,7 +20,7 @@ declare const customNodes: Map<string, any>;
|
|
|
20
20
|
declare function customNode<T = Record<string, any>>(tag: string, defaultProperties?: Partial<T>): ClassDecorator;
|
|
21
21
|
|
|
22
22
|
interface PropertyDeclaration {
|
|
23
|
-
readonly default?: any;
|
|
23
|
+
readonly default?: any | (() => any);
|
|
24
24
|
readonly protected?: boolean;
|
|
25
25
|
readonly alias?: string;
|
|
26
26
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -20,7 +20,7 @@ declare const customNodes: Map<string, any>;
|
|
|
20
20
|
declare function customNode<T = Record<string, any>>(tag: string, defaultProperties?: Partial<T>): ClassDecorator;
|
|
21
21
|
|
|
22
22
|
interface PropertyDeclaration {
|
|
23
|
-
readonly default?: any;
|
|
23
|
+
readonly default?: any | (() => any);
|
|
24
24
|
readonly protected?: boolean;
|
|
25
25
|
readonly alias?: string;
|
|
26
26
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ declare const customNodes: Map<string, any>;
|
|
|
20
20
|
declare function customNode<T = Record<string, any>>(tag: string, defaultProperties?: Partial<T>): ClassDecorator;
|
|
21
21
|
|
|
22
22
|
interface PropertyDeclaration {
|
|
23
|
-
readonly default?: any;
|
|
23
|
+
readonly default?: any | (() => any);
|
|
24
24
|
readonly protected?: boolean;
|
|
25
25
|
readonly alias?: string;
|
|
26
26
|
}
|