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.cjs
CHANGED
|
@@ -6250,9 +6250,12 @@ exports.Node = class Node extends CoreObject {
|
|
|
6250
6250
|
}
|
|
6251
6251
|
findOne(callbackfn) {
|
|
6252
6252
|
for (const child of this._children.default) {
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
|
|
6253
|
+
if (callbackfn(child)) {
|
|
6254
|
+
return child;
|
|
6255
|
+
}
|
|
6256
|
+
const res = child.findOne(callbackfn);
|
|
6257
|
+
if (res) {
|
|
6258
|
+
return res;
|
|
6256
6259
|
}
|
|
6257
6260
|
}
|
|
6258
6261
|
return void 0;
|
|
@@ -6260,9 +6263,8 @@ exports.Node = class Node extends CoreObject {
|
|
|
6260
6263
|
findAll(callbackfn) {
|
|
6261
6264
|
const items = [];
|
|
6262
6265
|
for (const child of this._children.default) {
|
|
6263
|
-
|
|
6264
|
-
|
|
6265
|
-
items.push(value);
|
|
6266
|
+
if (callbackfn(child)) {
|
|
6267
|
+
items.push(child);
|
|
6266
6268
|
}
|
|
6267
6269
|
items.push(...child.findAll(callbackfn));
|
|
6268
6270
|
}
|
|
@@ -6271,7 +6273,10 @@ exports.Node = class Node extends CoreObject {
|
|
|
6271
6273
|
findAncestor(callbackfn) {
|
|
6272
6274
|
const parent = this._parent;
|
|
6273
6275
|
if (parent) {
|
|
6274
|
-
|
|
6276
|
+
if (callbackfn(parent)) {
|
|
6277
|
+
return parent;
|
|
6278
|
+
}
|
|
6279
|
+
const value = parent.findAncestor(callbackfn);
|
|
6275
6280
|
if (value) {
|
|
6276
6281
|
return value;
|
|
6277
6282
|
}
|
|
@@ -10094,7 +10099,6 @@ class BaseElement2DText extends CoreObject {
|
|
|
10094
10099
|
this.parent = parent;
|
|
10095
10100
|
this.base = new modernText.Text();
|
|
10096
10101
|
this.base.setPropertyAccessor(this);
|
|
10097
|
-
this.update();
|
|
10098
10102
|
}
|
|
10099
10103
|
base;
|
|
10100
10104
|
_texture = new CanvasTexture();
|
|
@@ -10114,20 +10118,19 @@ class BaseElement2DText extends CoreObject {
|
|
|
10114
10118
|
case "measureDom":
|
|
10115
10119
|
case "fonts":
|
|
10116
10120
|
this.update();
|
|
10117
|
-
this.parent.requestRedraw();
|
|
10118
10121
|
break;
|
|
10119
10122
|
case "fill":
|
|
10120
10123
|
case "outline":
|
|
10121
10124
|
case "content":
|
|
10122
10125
|
this.update();
|
|
10123
10126
|
this._updateTextureMap();
|
|
10124
|
-
this.parent.requestRedraw();
|
|
10125
10127
|
break;
|
|
10126
10128
|
}
|
|
10127
10129
|
}
|
|
10128
10130
|
update() {
|
|
10129
10131
|
this.base.fonts = this.base.fonts ?? this.parent.tree?.fonts;
|
|
10130
10132
|
this.base.update();
|
|
10133
|
+
this.parent.requestRedraw();
|
|
10131
10134
|
}
|
|
10132
10135
|
_updateTextureMap() {
|
|
10133
10136
|
this._textureMap.clear();
|
|
@@ -10401,6 +10404,12 @@ exports.BaseElement2D = class BaseElement2D extends exports.Node2D {
|
|
|
10401
10404
|
this.style = new BaseElement2DStyle();
|
|
10402
10405
|
this.setProperties(properties).append(nodes);
|
|
10403
10406
|
}
|
|
10407
|
+
_treeEnter(tree) {
|
|
10408
|
+
super._treeEnter(tree);
|
|
10409
|
+
if (this._text.isValid()) {
|
|
10410
|
+
this._text.update();
|
|
10411
|
+
}
|
|
10412
|
+
}
|
|
10404
10413
|
setProperties(properties) {
|
|
10405
10414
|
if (properties) {
|
|
10406
10415
|
const {
|
|
@@ -10492,7 +10501,6 @@ exports.BaseElement2D = class BaseElement2D extends exports.Node2D {
|
|
|
10492
10501
|
if (textStyles.has(key) || layoutStyle.has(key)) {
|
|
10493
10502
|
if (this.text.isValid()) {
|
|
10494
10503
|
this.text.update();
|
|
10495
|
-
this.requestRedraw();
|
|
10496
10504
|
}
|
|
10497
10505
|
}
|
|
10498
10506
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -1757,7 +1757,7 @@ declare class Node extends CoreObject {
|
|
|
1757
1757
|
remove(): void;
|
|
1758
1758
|
findOne<T extends Node = Node>(callbackfn: (value: Node) => boolean): T | undefined;
|
|
1759
1759
|
findAll<T extends Node = Node>(callbackfn: (value: Node) => boolean): T[];
|
|
1760
|
-
findAncestor<T extends Node = Node>(callbackfn: (value: Node) =>
|
|
1760
|
+
findAncestor<T extends Node = Node>(callbackfn: (value: Node) => boolean): T | undefined;
|
|
1761
1761
|
/** override */
|
|
1762
1762
|
protected _ready(): void;
|
|
1763
1763
|
protected _treeEnter(tree: SceneTree): void;
|
|
@@ -2174,6 +2174,7 @@ declare class BaseElement2D extends Node2D implements Rectangulable {
|
|
|
2174
2174
|
get shadow(): BaseElement2DShadow;
|
|
2175
2175
|
set shadow(value: Shadow);
|
|
2176
2176
|
constructor(properties?: Partial<BaseElement2DProperties>, nodes?: Node[]);
|
|
2177
|
+
protected _treeEnter(tree: SceneTree): void;
|
|
2177
2178
|
setProperties(properties?: Record<string, any>): this;
|
|
2178
2179
|
protected _updateStyleProperty(key: string, value: any, oldValue: any): void;
|
|
2179
2180
|
protected _process(delta: number): void;
|
package/dist/index.d.mts
CHANGED
|
@@ -1757,7 +1757,7 @@ declare class Node extends CoreObject {
|
|
|
1757
1757
|
remove(): void;
|
|
1758
1758
|
findOne<T extends Node = Node>(callbackfn: (value: Node) => boolean): T | undefined;
|
|
1759
1759
|
findAll<T extends Node = Node>(callbackfn: (value: Node) => boolean): T[];
|
|
1760
|
-
findAncestor<T extends Node = Node>(callbackfn: (value: Node) =>
|
|
1760
|
+
findAncestor<T extends Node = Node>(callbackfn: (value: Node) => boolean): T | undefined;
|
|
1761
1761
|
/** override */
|
|
1762
1762
|
protected _ready(): void;
|
|
1763
1763
|
protected _treeEnter(tree: SceneTree): void;
|
|
@@ -2174,6 +2174,7 @@ declare class BaseElement2D extends Node2D implements Rectangulable {
|
|
|
2174
2174
|
get shadow(): BaseElement2DShadow;
|
|
2175
2175
|
set shadow(value: Shadow);
|
|
2176
2176
|
constructor(properties?: Partial<BaseElement2DProperties>, nodes?: Node[]);
|
|
2177
|
+
protected _treeEnter(tree: SceneTree): void;
|
|
2177
2178
|
setProperties(properties?: Record<string, any>): this;
|
|
2178
2179
|
protected _updateStyleProperty(key: string, value: any, oldValue: any): void;
|
|
2179
2180
|
protected _process(delta: number): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1757,7 +1757,7 @@ declare class Node extends CoreObject {
|
|
|
1757
1757
|
remove(): void;
|
|
1758
1758
|
findOne<T extends Node = Node>(callbackfn: (value: Node) => boolean): T | undefined;
|
|
1759
1759
|
findAll<T extends Node = Node>(callbackfn: (value: Node) => boolean): T[];
|
|
1760
|
-
findAncestor<T extends Node = Node>(callbackfn: (value: Node) =>
|
|
1760
|
+
findAncestor<T extends Node = Node>(callbackfn: (value: Node) => boolean): T | undefined;
|
|
1761
1761
|
/** override */
|
|
1762
1762
|
protected _ready(): void;
|
|
1763
1763
|
protected _treeEnter(tree: SceneTree): void;
|
|
@@ -2174,6 +2174,7 @@ declare class BaseElement2D extends Node2D implements Rectangulable {
|
|
|
2174
2174
|
get shadow(): BaseElement2DShadow;
|
|
2175
2175
|
set shadow(value: Shadow);
|
|
2176
2176
|
constructor(properties?: Partial<BaseElement2DProperties>, nodes?: Node[]);
|
|
2177
|
+
protected _treeEnter(tree: SceneTree): void;
|
|
2177
2178
|
setProperties(properties?: Record<string, any>): this;
|
|
2178
2179
|
protected _updateStyleProperty(key: string, value: any, oldValue: any): void;
|
|
2179
2180
|
protected _process(delta: number): void;
|