microboard-temp 0.4.89 → 0.4.91
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/cjs/browser.js +26 -1
- package/dist/cjs/index.js +26 -1
- package/dist/cjs/node.js +26 -1
- package/dist/esm/browser.js +26 -1
- package/dist/esm/index.js +26 -1
- package/dist/esm/node.js +26 -1
- package/dist/types/Items/Examples/CardGame/Deck/Deck.d.ts +3 -0
- package/package.json +1 -1
package/dist/cjs/browser.js
CHANGED
|
@@ -47928,6 +47928,8 @@ var defaultDeckData = {
|
|
|
47928
47928
|
class Deck extends BaseItem {
|
|
47929
47929
|
subject = new Subject;
|
|
47930
47930
|
shouldUseCustomRender = false;
|
|
47931
|
+
cachedCanvas = null;
|
|
47932
|
+
isCacheDirty = true;
|
|
47931
47933
|
constructor(board, id = "") {
|
|
47932
47934
|
super(board, id, defaultDeckData, true);
|
|
47933
47935
|
this.index.getUnderPoint = () => [];
|
|
@@ -48025,6 +48027,9 @@ class Deck extends BaseItem {
|
|
|
48025
48027
|
}
|
|
48026
48028
|
apply(op) {
|
|
48027
48029
|
super.apply(op);
|
|
48030
|
+
if (op.class === "Deck") {
|
|
48031
|
+
this.isCacheDirty = true;
|
|
48032
|
+
}
|
|
48028
48033
|
this.subject.publish(this);
|
|
48029
48034
|
}
|
|
48030
48035
|
updateMbr() {
|
|
@@ -48046,7 +48051,27 @@ class Deck extends BaseItem {
|
|
|
48046
48051
|
if (this.transformationRenderBlock) {
|
|
48047
48052
|
return;
|
|
48048
48053
|
}
|
|
48049
|
-
|
|
48054
|
+
const ctx = context.ctx;
|
|
48055
|
+
if (this.isCacheDirty || !this.cachedCanvas) {
|
|
48056
|
+
this.updateCache(context);
|
|
48057
|
+
this.isCacheDirty = false;
|
|
48058
|
+
}
|
|
48059
|
+
if (this.cachedCanvas && this.cachedCanvas.width && this.cachedCanvas.height) {
|
|
48060
|
+
ctx.save();
|
|
48061
|
+
ctx.drawImage(this.cachedCanvas, this.left, this.top);
|
|
48062
|
+
ctx.restore();
|
|
48063
|
+
}
|
|
48064
|
+
}
|
|
48065
|
+
updateCache(context) {
|
|
48066
|
+
const tempCanvas = document.createElement("canvas");
|
|
48067
|
+
tempCanvas.width = this.getWidth();
|
|
48068
|
+
tempCanvas.height = this.getHeight();
|
|
48069
|
+
const tempCtx = tempCanvas.getContext("2d");
|
|
48070
|
+
if (!tempCtx)
|
|
48071
|
+
return;
|
|
48072
|
+
const tempContext = { ...context, ctx: tempCtx };
|
|
48073
|
+
this.index?.render(tempContext);
|
|
48074
|
+
this.cachedCanvas = tempCanvas;
|
|
48050
48075
|
}
|
|
48051
48076
|
}
|
|
48052
48077
|
registerItem({
|
package/dist/cjs/index.js
CHANGED
|
@@ -47928,6 +47928,8 @@ var defaultDeckData = {
|
|
|
47928
47928
|
class Deck extends BaseItem {
|
|
47929
47929
|
subject = new Subject;
|
|
47930
47930
|
shouldUseCustomRender = false;
|
|
47931
|
+
cachedCanvas = null;
|
|
47932
|
+
isCacheDirty = true;
|
|
47931
47933
|
constructor(board, id = "") {
|
|
47932
47934
|
super(board, id, defaultDeckData, true);
|
|
47933
47935
|
this.index.getUnderPoint = () => [];
|
|
@@ -48025,6 +48027,9 @@ class Deck extends BaseItem {
|
|
|
48025
48027
|
}
|
|
48026
48028
|
apply(op) {
|
|
48027
48029
|
super.apply(op);
|
|
48030
|
+
if (op.class === "Deck") {
|
|
48031
|
+
this.isCacheDirty = true;
|
|
48032
|
+
}
|
|
48028
48033
|
this.subject.publish(this);
|
|
48029
48034
|
}
|
|
48030
48035
|
updateMbr() {
|
|
@@ -48046,7 +48051,27 @@ class Deck extends BaseItem {
|
|
|
48046
48051
|
if (this.transformationRenderBlock) {
|
|
48047
48052
|
return;
|
|
48048
48053
|
}
|
|
48049
|
-
|
|
48054
|
+
const ctx = context.ctx;
|
|
48055
|
+
if (this.isCacheDirty || !this.cachedCanvas) {
|
|
48056
|
+
this.updateCache(context);
|
|
48057
|
+
this.isCacheDirty = false;
|
|
48058
|
+
}
|
|
48059
|
+
if (this.cachedCanvas && this.cachedCanvas.width && this.cachedCanvas.height) {
|
|
48060
|
+
ctx.save();
|
|
48061
|
+
ctx.drawImage(this.cachedCanvas, this.left, this.top);
|
|
48062
|
+
ctx.restore();
|
|
48063
|
+
}
|
|
48064
|
+
}
|
|
48065
|
+
updateCache(context) {
|
|
48066
|
+
const tempCanvas = document.createElement("canvas");
|
|
48067
|
+
tempCanvas.width = this.getWidth();
|
|
48068
|
+
tempCanvas.height = this.getHeight();
|
|
48069
|
+
const tempCtx = tempCanvas.getContext("2d");
|
|
48070
|
+
if (!tempCtx)
|
|
48071
|
+
return;
|
|
48072
|
+
const tempContext = { ...context, ctx: tempCtx };
|
|
48073
|
+
this.index?.render(tempContext);
|
|
48074
|
+
this.cachedCanvas = tempCanvas;
|
|
48050
48075
|
}
|
|
48051
48076
|
}
|
|
48052
48077
|
registerItem({
|
package/dist/cjs/node.js
CHANGED
|
@@ -50401,6 +50401,8 @@ var defaultDeckData = {
|
|
|
50401
50401
|
class Deck extends BaseItem {
|
|
50402
50402
|
subject = new Subject;
|
|
50403
50403
|
shouldUseCustomRender = false;
|
|
50404
|
+
cachedCanvas = null;
|
|
50405
|
+
isCacheDirty = true;
|
|
50404
50406
|
constructor(board, id = "") {
|
|
50405
50407
|
super(board, id, defaultDeckData, true);
|
|
50406
50408
|
this.index.getUnderPoint = () => [];
|
|
@@ -50498,6 +50500,9 @@ class Deck extends BaseItem {
|
|
|
50498
50500
|
}
|
|
50499
50501
|
apply(op) {
|
|
50500
50502
|
super.apply(op);
|
|
50503
|
+
if (op.class === "Deck") {
|
|
50504
|
+
this.isCacheDirty = true;
|
|
50505
|
+
}
|
|
50501
50506
|
this.subject.publish(this);
|
|
50502
50507
|
}
|
|
50503
50508
|
updateMbr() {
|
|
@@ -50519,7 +50524,27 @@ class Deck extends BaseItem {
|
|
|
50519
50524
|
if (this.transformationRenderBlock) {
|
|
50520
50525
|
return;
|
|
50521
50526
|
}
|
|
50522
|
-
|
|
50527
|
+
const ctx = context.ctx;
|
|
50528
|
+
if (this.isCacheDirty || !this.cachedCanvas) {
|
|
50529
|
+
this.updateCache(context);
|
|
50530
|
+
this.isCacheDirty = false;
|
|
50531
|
+
}
|
|
50532
|
+
if (this.cachedCanvas && this.cachedCanvas.width && this.cachedCanvas.height) {
|
|
50533
|
+
ctx.save();
|
|
50534
|
+
ctx.drawImage(this.cachedCanvas, this.left, this.top);
|
|
50535
|
+
ctx.restore();
|
|
50536
|
+
}
|
|
50537
|
+
}
|
|
50538
|
+
updateCache(context) {
|
|
50539
|
+
const tempCanvas = document.createElement("canvas");
|
|
50540
|
+
tempCanvas.width = this.getWidth();
|
|
50541
|
+
tempCanvas.height = this.getHeight();
|
|
50542
|
+
const tempCtx = tempCanvas.getContext("2d");
|
|
50543
|
+
if (!tempCtx)
|
|
50544
|
+
return;
|
|
50545
|
+
const tempContext = { ...context, ctx: tempCtx };
|
|
50546
|
+
this.index?.render(tempContext);
|
|
50547
|
+
this.cachedCanvas = tempCanvas;
|
|
50523
50548
|
}
|
|
50524
50549
|
}
|
|
50525
50550
|
registerItem({
|
package/dist/esm/browser.js
CHANGED
|
@@ -47777,6 +47777,8 @@ var defaultDeckData = {
|
|
|
47777
47777
|
class Deck extends BaseItem {
|
|
47778
47778
|
subject = new Subject;
|
|
47779
47779
|
shouldUseCustomRender = false;
|
|
47780
|
+
cachedCanvas = null;
|
|
47781
|
+
isCacheDirty = true;
|
|
47780
47782
|
constructor(board, id = "") {
|
|
47781
47783
|
super(board, id, defaultDeckData, true);
|
|
47782
47784
|
this.index.getUnderPoint = () => [];
|
|
@@ -47874,6 +47876,9 @@ class Deck extends BaseItem {
|
|
|
47874
47876
|
}
|
|
47875
47877
|
apply(op) {
|
|
47876
47878
|
super.apply(op);
|
|
47879
|
+
if (op.class === "Deck") {
|
|
47880
|
+
this.isCacheDirty = true;
|
|
47881
|
+
}
|
|
47877
47882
|
this.subject.publish(this);
|
|
47878
47883
|
}
|
|
47879
47884
|
updateMbr() {
|
|
@@ -47895,7 +47900,27 @@ class Deck extends BaseItem {
|
|
|
47895
47900
|
if (this.transformationRenderBlock) {
|
|
47896
47901
|
return;
|
|
47897
47902
|
}
|
|
47898
|
-
|
|
47903
|
+
const ctx = context.ctx;
|
|
47904
|
+
if (this.isCacheDirty || !this.cachedCanvas) {
|
|
47905
|
+
this.updateCache(context);
|
|
47906
|
+
this.isCacheDirty = false;
|
|
47907
|
+
}
|
|
47908
|
+
if (this.cachedCanvas && this.cachedCanvas.width && this.cachedCanvas.height) {
|
|
47909
|
+
ctx.save();
|
|
47910
|
+
ctx.drawImage(this.cachedCanvas, this.left, this.top);
|
|
47911
|
+
ctx.restore();
|
|
47912
|
+
}
|
|
47913
|
+
}
|
|
47914
|
+
updateCache(context) {
|
|
47915
|
+
const tempCanvas = document.createElement("canvas");
|
|
47916
|
+
tempCanvas.width = this.getWidth();
|
|
47917
|
+
tempCanvas.height = this.getHeight();
|
|
47918
|
+
const tempCtx = tempCanvas.getContext("2d");
|
|
47919
|
+
if (!tempCtx)
|
|
47920
|
+
return;
|
|
47921
|
+
const tempContext = { ...context, ctx: tempCtx };
|
|
47922
|
+
this.index?.render(tempContext);
|
|
47923
|
+
this.cachedCanvas = tempCanvas;
|
|
47899
47924
|
}
|
|
47900
47925
|
}
|
|
47901
47926
|
registerItem({
|
package/dist/esm/index.js
CHANGED
|
@@ -47770,6 +47770,8 @@ var defaultDeckData = {
|
|
|
47770
47770
|
class Deck extends BaseItem {
|
|
47771
47771
|
subject = new Subject;
|
|
47772
47772
|
shouldUseCustomRender = false;
|
|
47773
|
+
cachedCanvas = null;
|
|
47774
|
+
isCacheDirty = true;
|
|
47773
47775
|
constructor(board, id = "") {
|
|
47774
47776
|
super(board, id, defaultDeckData, true);
|
|
47775
47777
|
this.index.getUnderPoint = () => [];
|
|
@@ -47867,6 +47869,9 @@ class Deck extends BaseItem {
|
|
|
47867
47869
|
}
|
|
47868
47870
|
apply(op) {
|
|
47869
47871
|
super.apply(op);
|
|
47872
|
+
if (op.class === "Deck") {
|
|
47873
|
+
this.isCacheDirty = true;
|
|
47874
|
+
}
|
|
47870
47875
|
this.subject.publish(this);
|
|
47871
47876
|
}
|
|
47872
47877
|
updateMbr() {
|
|
@@ -47888,7 +47893,27 @@ class Deck extends BaseItem {
|
|
|
47888
47893
|
if (this.transformationRenderBlock) {
|
|
47889
47894
|
return;
|
|
47890
47895
|
}
|
|
47891
|
-
|
|
47896
|
+
const ctx = context.ctx;
|
|
47897
|
+
if (this.isCacheDirty || !this.cachedCanvas) {
|
|
47898
|
+
this.updateCache(context);
|
|
47899
|
+
this.isCacheDirty = false;
|
|
47900
|
+
}
|
|
47901
|
+
if (this.cachedCanvas && this.cachedCanvas.width && this.cachedCanvas.height) {
|
|
47902
|
+
ctx.save();
|
|
47903
|
+
ctx.drawImage(this.cachedCanvas, this.left, this.top);
|
|
47904
|
+
ctx.restore();
|
|
47905
|
+
}
|
|
47906
|
+
}
|
|
47907
|
+
updateCache(context) {
|
|
47908
|
+
const tempCanvas = document.createElement("canvas");
|
|
47909
|
+
tempCanvas.width = this.getWidth();
|
|
47910
|
+
tempCanvas.height = this.getHeight();
|
|
47911
|
+
const tempCtx = tempCanvas.getContext("2d");
|
|
47912
|
+
if (!tempCtx)
|
|
47913
|
+
return;
|
|
47914
|
+
const tempContext = { ...context, ctx: tempCtx };
|
|
47915
|
+
this.index?.render(tempContext);
|
|
47916
|
+
this.cachedCanvas = tempCanvas;
|
|
47892
47917
|
}
|
|
47893
47918
|
}
|
|
47894
47919
|
registerItem({
|
package/dist/esm/node.js
CHANGED
|
@@ -50238,6 +50238,8 @@ var defaultDeckData = {
|
|
|
50238
50238
|
class Deck extends BaseItem {
|
|
50239
50239
|
subject = new Subject;
|
|
50240
50240
|
shouldUseCustomRender = false;
|
|
50241
|
+
cachedCanvas = null;
|
|
50242
|
+
isCacheDirty = true;
|
|
50241
50243
|
constructor(board, id = "") {
|
|
50242
50244
|
super(board, id, defaultDeckData, true);
|
|
50243
50245
|
this.index.getUnderPoint = () => [];
|
|
@@ -50335,6 +50337,9 @@ class Deck extends BaseItem {
|
|
|
50335
50337
|
}
|
|
50336
50338
|
apply(op) {
|
|
50337
50339
|
super.apply(op);
|
|
50340
|
+
if (op.class === "Deck") {
|
|
50341
|
+
this.isCacheDirty = true;
|
|
50342
|
+
}
|
|
50338
50343
|
this.subject.publish(this);
|
|
50339
50344
|
}
|
|
50340
50345
|
updateMbr() {
|
|
@@ -50356,7 +50361,27 @@ class Deck extends BaseItem {
|
|
|
50356
50361
|
if (this.transformationRenderBlock) {
|
|
50357
50362
|
return;
|
|
50358
50363
|
}
|
|
50359
|
-
|
|
50364
|
+
const ctx = context.ctx;
|
|
50365
|
+
if (this.isCacheDirty || !this.cachedCanvas) {
|
|
50366
|
+
this.updateCache(context);
|
|
50367
|
+
this.isCacheDirty = false;
|
|
50368
|
+
}
|
|
50369
|
+
if (this.cachedCanvas && this.cachedCanvas.width && this.cachedCanvas.height) {
|
|
50370
|
+
ctx.save();
|
|
50371
|
+
ctx.drawImage(this.cachedCanvas, this.left, this.top);
|
|
50372
|
+
ctx.restore();
|
|
50373
|
+
}
|
|
50374
|
+
}
|
|
50375
|
+
updateCache(context) {
|
|
50376
|
+
const tempCanvas = document.createElement("canvas");
|
|
50377
|
+
tempCanvas.width = this.getWidth();
|
|
50378
|
+
tempCanvas.height = this.getHeight();
|
|
50379
|
+
const tempCtx = tempCanvas.getContext("2d");
|
|
50380
|
+
if (!tempCtx)
|
|
50381
|
+
return;
|
|
50382
|
+
const tempContext = { ...context, ctx: tempCtx };
|
|
50383
|
+
this.index?.render(tempContext);
|
|
50384
|
+
this.cachedCanvas = tempCanvas;
|
|
50360
50385
|
}
|
|
50361
50386
|
}
|
|
50362
50387
|
registerItem({
|
|
@@ -8,6 +8,8 @@ export declare const defaultDeckData: BaseItemData;
|
|
|
8
8
|
export declare class Deck extends BaseItem {
|
|
9
9
|
readonly subject: Subject<Deck>;
|
|
10
10
|
shouldUseCustomRender: boolean;
|
|
11
|
+
private cachedCanvas;
|
|
12
|
+
private isCacheDirty;
|
|
11
13
|
constructor(board: Board, id?: string);
|
|
12
14
|
applyAddChildren(childIds: string[]): void;
|
|
13
15
|
applyRemoveChildren(childIds: string[]): void;
|
|
@@ -20,4 +22,5 @@ export declare class Deck extends BaseItem {
|
|
|
20
22
|
updateMbr(): void;
|
|
21
23
|
deserialize(data: SerializedItemData): this;
|
|
22
24
|
render(context: DrawingContext): void;
|
|
25
|
+
private updateCache;
|
|
23
26
|
}
|