modern-canvas 0.12.3 → 0.12.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.
- package/dist/index.cjs +19 -11
- package/dist/index.d.cts +2 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -2
- package/dist/index.mjs +19 -11
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -6244,9 +6244,12 @@ let Node = class extends CoreObject {
|
|
|
6244
6244
|
}
|
|
6245
6245
|
findOne(callbackfn) {
|
|
6246
6246
|
for (const child of this._children.default) {
|
|
6247
|
-
|
|
6248
|
-
|
|
6249
|
-
|
|
6247
|
+
if (callbackfn(child)) {
|
|
6248
|
+
return child;
|
|
6249
|
+
}
|
|
6250
|
+
const res = child.findOne(callbackfn);
|
|
6251
|
+
if (res) {
|
|
6252
|
+
return res;
|
|
6250
6253
|
}
|
|
6251
6254
|
}
|
|
6252
6255
|
return void 0;
|
|
@@ -6254,9 +6257,8 @@ let Node = class extends CoreObject {
|
|
|
6254
6257
|
findAll(callbackfn) {
|
|
6255
6258
|
const items = [];
|
|
6256
6259
|
for (const child of this._children.default) {
|
|
6257
|
-
|
|
6258
|
-
|
|
6259
|
-
items.push(value);
|
|
6260
|
+
if (callbackfn(child)) {
|
|
6261
|
+
items.push(child);
|
|
6260
6262
|
}
|
|
6261
6263
|
items.push(...child.findAll(callbackfn));
|
|
6262
6264
|
}
|
|
@@ -6265,7 +6267,10 @@ let Node = class extends CoreObject {
|
|
|
6265
6267
|
findAncestor(callbackfn) {
|
|
6266
6268
|
const parent = this._parent;
|
|
6267
6269
|
if (parent) {
|
|
6268
|
-
|
|
6270
|
+
if (callbackfn(parent)) {
|
|
6271
|
+
return parent;
|
|
6272
|
+
}
|
|
6273
|
+
const value = parent.findAncestor(callbackfn);
|
|
6269
6274
|
if (value) {
|
|
6270
6275
|
return value;
|
|
6271
6276
|
}
|
|
@@ -10088,7 +10093,6 @@ class BaseElement2DText extends CoreObject {
|
|
|
10088
10093
|
this.parent = parent;
|
|
10089
10094
|
this.base = new Text();
|
|
10090
10095
|
this.base.setPropertyAccessor(this);
|
|
10091
|
-
this.update();
|
|
10092
10096
|
}
|
|
10093
10097
|
base;
|
|
10094
10098
|
_texture = new CanvasTexture();
|
|
@@ -10108,20 +10112,19 @@ class BaseElement2DText extends CoreObject {
|
|
|
10108
10112
|
case "measureDom":
|
|
10109
10113
|
case "fonts":
|
|
10110
10114
|
this.update();
|
|
10111
|
-
this.parent.requestRedraw();
|
|
10112
10115
|
break;
|
|
10113
10116
|
case "fill":
|
|
10114
10117
|
case "outline":
|
|
10115
10118
|
case "content":
|
|
10116
10119
|
this.update();
|
|
10117
10120
|
this._updateTextureMap();
|
|
10118
|
-
this.parent.requestRedraw();
|
|
10119
10121
|
break;
|
|
10120
10122
|
}
|
|
10121
10123
|
}
|
|
10122
10124
|
update() {
|
|
10123
10125
|
this.base.fonts = this.base.fonts ?? this.parent.tree?.fonts;
|
|
10124
10126
|
this.base.update();
|
|
10127
|
+
this.parent.requestRedraw();
|
|
10125
10128
|
}
|
|
10126
10129
|
_updateTextureMap() {
|
|
10127
10130
|
this._textureMap.clear();
|
|
@@ -10395,6 +10398,12 @@ let BaseElement2D = class extends Node2D {
|
|
|
10395
10398
|
this.style = new BaseElement2DStyle();
|
|
10396
10399
|
this.setProperties(properties).append(nodes);
|
|
10397
10400
|
}
|
|
10401
|
+
_treeEnter(tree) {
|
|
10402
|
+
super._treeEnter(tree);
|
|
10403
|
+
if (this._text.isValid()) {
|
|
10404
|
+
this._text.update();
|
|
10405
|
+
}
|
|
10406
|
+
}
|
|
10398
10407
|
setProperties(properties) {
|
|
10399
10408
|
if (properties) {
|
|
10400
10409
|
const {
|
|
@@ -10486,7 +10495,6 @@ let BaseElement2D = class extends Node2D {
|
|
|
10486
10495
|
if (textStyles.has(key) || layoutStyle.has(key)) {
|
|
10487
10496
|
if (this.text.isValid()) {
|
|
10488
10497
|
this.text.update();
|
|
10489
|
-
this.requestRedraw();
|
|
10490
10498
|
}
|
|
10491
10499
|
}
|
|
10492
10500
|
}
|