microboard-temp 0.4.100 → 0.4.102
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 -16
- package/dist/cjs/index.js +26 -16
- package/dist/cjs/node.js +26 -16
- package/dist/esm/browser.js +26 -16
- package/dist/esm/index.js +26 -16
- package/dist/esm/node.js +26 -16
- package/dist/types/Events/Command.d.ts +4 -4
- package/package.json +1 -1
package/dist/cjs/browser.js
CHANGED
|
@@ -19468,11 +19468,13 @@ class AudioCommand {
|
|
|
19468
19468
|
|
|
19469
19469
|
// src/Events/Command.ts
|
|
19470
19470
|
class BaseCommand {
|
|
19471
|
-
|
|
19471
|
+
board;
|
|
19472
|
+
itemIds;
|
|
19472
19473
|
operation;
|
|
19473
19474
|
reverse;
|
|
19474
|
-
constructor(
|
|
19475
|
-
this.
|
|
19475
|
+
constructor(board, itemIds, operation) {
|
|
19476
|
+
this.board = board;
|
|
19477
|
+
this.itemIds = itemIds;
|
|
19476
19478
|
this.operation = operation;
|
|
19477
19479
|
this.reverse = this.getReverse();
|
|
19478
19480
|
}
|
|
@@ -19481,49 +19483,57 @@ class BaseCommand {
|
|
|
19481
19483
|
return this;
|
|
19482
19484
|
}
|
|
19483
19485
|
apply() {
|
|
19484
|
-
for (const
|
|
19486
|
+
for (const itemId of this.itemIds) {
|
|
19487
|
+
const item = this.board.items.getById(itemId);
|
|
19488
|
+
if (!item) {
|
|
19489
|
+
continue;
|
|
19490
|
+
}
|
|
19485
19491
|
item.apply(this.operation);
|
|
19486
19492
|
}
|
|
19487
19493
|
}
|
|
19488
19494
|
revert() {
|
|
19489
|
-
for (const {
|
|
19495
|
+
for (const { itemId, operation } of this.reverse) {
|
|
19496
|
+
const item = this.board.items.getById(itemId);
|
|
19497
|
+
if (!item) {
|
|
19498
|
+
continue;
|
|
19499
|
+
}
|
|
19490
19500
|
item.apply(operation);
|
|
19491
19501
|
}
|
|
19492
19502
|
}
|
|
19493
19503
|
getReverse() {
|
|
19494
|
-
const items = this.items;
|
|
19495
19504
|
switch (this.operation.method) {
|
|
19496
19505
|
case "addChildren":
|
|
19497
|
-
return
|
|
19498
|
-
return {
|
|
19506
|
+
return this.itemIds.map((itemId) => {
|
|
19507
|
+
return { itemId, operation: {
|
|
19499
19508
|
...this.operation,
|
|
19500
19509
|
method: "removeChildren"
|
|
19501
19510
|
} };
|
|
19502
19511
|
});
|
|
19503
19512
|
case "removeChildren":
|
|
19504
|
-
return
|
|
19505
|
-
return {
|
|
19513
|
+
return this.itemIds.map((itemId) => {
|
|
19514
|
+
return { itemId, operation: {
|
|
19506
19515
|
...this.operation,
|
|
19507
19516
|
method: "addChildren"
|
|
19508
19517
|
} };
|
|
19509
19518
|
});
|
|
19510
19519
|
default:
|
|
19511
|
-
return
|
|
19520
|
+
return this.itemIds.map((itemId) => {
|
|
19512
19521
|
const op = this.operation;
|
|
19513
19522
|
let newData = {};
|
|
19514
19523
|
if (op.prevData) {
|
|
19515
19524
|
newData = { ...op.prevData };
|
|
19516
19525
|
} else {
|
|
19526
|
+
const item = this.board.items.getById(itemId);
|
|
19517
19527
|
Object.keys(op.newData).forEach((key) => {
|
|
19518
19528
|
if (item[key]) {
|
|
19519
19529
|
newData[key] = item[key];
|
|
19520
19530
|
}
|
|
19521
19531
|
});
|
|
19522
19532
|
}
|
|
19523
|
-
return {
|
|
19533
|
+
return { itemId, operation: {
|
|
19524
19534
|
...op,
|
|
19525
19535
|
newData
|
|
19526
|
-
};
|
|
19536
|
+
} };
|
|
19527
19537
|
});
|
|
19528
19538
|
}
|
|
19529
19539
|
}
|
|
@@ -21642,7 +21652,7 @@ class BaseItem extends Mbr {
|
|
|
21642
21652
|
}
|
|
21643
21653
|
emit(operation) {
|
|
21644
21654
|
if (this.board.events) {
|
|
21645
|
-
const command = new BaseCommand([this], operation);
|
|
21655
|
+
const command = new BaseCommand(this.board, [this.getId()], operation);
|
|
21646
21656
|
command.apply();
|
|
21647
21657
|
this.board.events.emit(operation, command);
|
|
21648
21658
|
} else {
|
|
@@ -47492,8 +47502,8 @@ function createItemValidator(defaultData2) {
|
|
|
47492
47502
|
};
|
|
47493
47503
|
}
|
|
47494
47504
|
function createItemCommandFactory(itemType) {
|
|
47495
|
-
return function itemCommandFactory(items, operation) {
|
|
47496
|
-
return new BaseCommand(items.filter((item) => item.itemType === itemType), operation);
|
|
47505
|
+
return function itemCommandFactory(items, operation, board) {
|
|
47506
|
+
return new BaseCommand(board, items.filter((item) => item.itemType === itemType).map((item) => item.getId()), operation);
|
|
47497
47507
|
};
|
|
47498
47508
|
}
|
|
47499
47509
|
// src/Items/Examples/Star/AddStar.ts
|
package/dist/cjs/index.js
CHANGED
|
@@ -19468,11 +19468,13 @@ class AudioCommand {
|
|
|
19468
19468
|
|
|
19469
19469
|
// src/Events/Command.ts
|
|
19470
19470
|
class BaseCommand {
|
|
19471
|
-
|
|
19471
|
+
board;
|
|
19472
|
+
itemIds;
|
|
19472
19473
|
operation;
|
|
19473
19474
|
reverse;
|
|
19474
|
-
constructor(
|
|
19475
|
-
this.
|
|
19475
|
+
constructor(board, itemIds, operation) {
|
|
19476
|
+
this.board = board;
|
|
19477
|
+
this.itemIds = itemIds;
|
|
19476
19478
|
this.operation = operation;
|
|
19477
19479
|
this.reverse = this.getReverse();
|
|
19478
19480
|
}
|
|
@@ -19481,49 +19483,57 @@ class BaseCommand {
|
|
|
19481
19483
|
return this;
|
|
19482
19484
|
}
|
|
19483
19485
|
apply() {
|
|
19484
|
-
for (const
|
|
19486
|
+
for (const itemId of this.itemIds) {
|
|
19487
|
+
const item = this.board.items.getById(itemId);
|
|
19488
|
+
if (!item) {
|
|
19489
|
+
continue;
|
|
19490
|
+
}
|
|
19485
19491
|
item.apply(this.operation);
|
|
19486
19492
|
}
|
|
19487
19493
|
}
|
|
19488
19494
|
revert() {
|
|
19489
|
-
for (const {
|
|
19495
|
+
for (const { itemId, operation } of this.reverse) {
|
|
19496
|
+
const item = this.board.items.getById(itemId);
|
|
19497
|
+
if (!item) {
|
|
19498
|
+
continue;
|
|
19499
|
+
}
|
|
19490
19500
|
item.apply(operation);
|
|
19491
19501
|
}
|
|
19492
19502
|
}
|
|
19493
19503
|
getReverse() {
|
|
19494
|
-
const items = this.items;
|
|
19495
19504
|
switch (this.operation.method) {
|
|
19496
19505
|
case "addChildren":
|
|
19497
|
-
return
|
|
19498
|
-
return {
|
|
19506
|
+
return this.itemIds.map((itemId) => {
|
|
19507
|
+
return { itemId, operation: {
|
|
19499
19508
|
...this.operation,
|
|
19500
19509
|
method: "removeChildren"
|
|
19501
19510
|
} };
|
|
19502
19511
|
});
|
|
19503
19512
|
case "removeChildren":
|
|
19504
|
-
return
|
|
19505
|
-
return {
|
|
19513
|
+
return this.itemIds.map((itemId) => {
|
|
19514
|
+
return { itemId, operation: {
|
|
19506
19515
|
...this.operation,
|
|
19507
19516
|
method: "addChildren"
|
|
19508
19517
|
} };
|
|
19509
19518
|
});
|
|
19510
19519
|
default:
|
|
19511
|
-
return
|
|
19520
|
+
return this.itemIds.map((itemId) => {
|
|
19512
19521
|
const op = this.operation;
|
|
19513
19522
|
let newData = {};
|
|
19514
19523
|
if (op.prevData) {
|
|
19515
19524
|
newData = { ...op.prevData };
|
|
19516
19525
|
} else {
|
|
19526
|
+
const item = this.board.items.getById(itemId);
|
|
19517
19527
|
Object.keys(op.newData).forEach((key) => {
|
|
19518
19528
|
if (item[key]) {
|
|
19519
19529
|
newData[key] = item[key];
|
|
19520
19530
|
}
|
|
19521
19531
|
});
|
|
19522
19532
|
}
|
|
19523
|
-
return {
|
|
19533
|
+
return { itemId, operation: {
|
|
19524
19534
|
...op,
|
|
19525
19535
|
newData
|
|
19526
|
-
};
|
|
19536
|
+
} };
|
|
19527
19537
|
});
|
|
19528
19538
|
}
|
|
19529
19539
|
}
|
|
@@ -21642,7 +21652,7 @@ class BaseItem extends Mbr {
|
|
|
21642
21652
|
}
|
|
21643
21653
|
emit(operation) {
|
|
21644
21654
|
if (this.board.events) {
|
|
21645
|
-
const command = new BaseCommand([this], operation);
|
|
21655
|
+
const command = new BaseCommand(this.board, [this.getId()], operation);
|
|
21646
21656
|
command.apply();
|
|
21647
21657
|
this.board.events.emit(operation, command);
|
|
21648
21658
|
} else {
|
|
@@ -47492,8 +47502,8 @@ function createItemValidator(defaultData2) {
|
|
|
47492
47502
|
};
|
|
47493
47503
|
}
|
|
47494
47504
|
function createItemCommandFactory(itemType) {
|
|
47495
|
-
return function itemCommandFactory(items, operation) {
|
|
47496
|
-
return new BaseCommand(items.filter((item) => item.itemType === itemType), operation);
|
|
47505
|
+
return function itemCommandFactory(items, operation, board) {
|
|
47506
|
+
return new BaseCommand(board, items.filter((item) => item.itemType === itemType).map((item) => item.getId()), operation);
|
|
47497
47507
|
};
|
|
47498
47508
|
}
|
|
47499
47509
|
// src/Items/Examples/Star/AddStar.ts
|
package/dist/cjs/node.js
CHANGED
|
@@ -22007,11 +22007,13 @@ class AudioCommand {
|
|
|
22007
22007
|
|
|
22008
22008
|
// src/Events/Command.ts
|
|
22009
22009
|
class BaseCommand {
|
|
22010
|
-
|
|
22010
|
+
board;
|
|
22011
|
+
itemIds;
|
|
22011
22012
|
operation;
|
|
22012
22013
|
reverse;
|
|
22013
|
-
constructor(
|
|
22014
|
-
this.
|
|
22014
|
+
constructor(board, itemIds, operation) {
|
|
22015
|
+
this.board = board;
|
|
22016
|
+
this.itemIds = itemIds;
|
|
22015
22017
|
this.operation = operation;
|
|
22016
22018
|
this.reverse = this.getReverse();
|
|
22017
22019
|
}
|
|
@@ -22020,49 +22022,57 @@ class BaseCommand {
|
|
|
22020
22022
|
return this;
|
|
22021
22023
|
}
|
|
22022
22024
|
apply() {
|
|
22023
|
-
for (const
|
|
22025
|
+
for (const itemId of this.itemIds) {
|
|
22026
|
+
const item = this.board.items.getById(itemId);
|
|
22027
|
+
if (!item) {
|
|
22028
|
+
continue;
|
|
22029
|
+
}
|
|
22024
22030
|
item.apply(this.operation);
|
|
22025
22031
|
}
|
|
22026
22032
|
}
|
|
22027
22033
|
revert() {
|
|
22028
|
-
for (const {
|
|
22034
|
+
for (const { itemId, operation } of this.reverse) {
|
|
22035
|
+
const item = this.board.items.getById(itemId);
|
|
22036
|
+
if (!item) {
|
|
22037
|
+
continue;
|
|
22038
|
+
}
|
|
22029
22039
|
item.apply(operation);
|
|
22030
22040
|
}
|
|
22031
22041
|
}
|
|
22032
22042
|
getReverse() {
|
|
22033
|
-
const items = this.items;
|
|
22034
22043
|
switch (this.operation.method) {
|
|
22035
22044
|
case "addChildren":
|
|
22036
|
-
return
|
|
22037
|
-
return {
|
|
22045
|
+
return this.itemIds.map((itemId) => {
|
|
22046
|
+
return { itemId, operation: {
|
|
22038
22047
|
...this.operation,
|
|
22039
22048
|
method: "removeChildren"
|
|
22040
22049
|
} };
|
|
22041
22050
|
});
|
|
22042
22051
|
case "removeChildren":
|
|
22043
|
-
return
|
|
22044
|
-
return {
|
|
22052
|
+
return this.itemIds.map((itemId) => {
|
|
22053
|
+
return { itemId, operation: {
|
|
22045
22054
|
...this.operation,
|
|
22046
22055
|
method: "addChildren"
|
|
22047
22056
|
} };
|
|
22048
22057
|
});
|
|
22049
22058
|
default:
|
|
22050
|
-
return
|
|
22059
|
+
return this.itemIds.map((itemId) => {
|
|
22051
22060
|
const op = this.operation;
|
|
22052
22061
|
let newData = {};
|
|
22053
22062
|
if (op.prevData) {
|
|
22054
22063
|
newData = { ...op.prevData };
|
|
22055
22064
|
} else {
|
|
22065
|
+
const item = this.board.items.getById(itemId);
|
|
22056
22066
|
Object.keys(op.newData).forEach((key) => {
|
|
22057
22067
|
if (item[key]) {
|
|
22058
22068
|
newData[key] = item[key];
|
|
22059
22069
|
}
|
|
22060
22070
|
});
|
|
22061
22071
|
}
|
|
22062
|
-
return {
|
|
22072
|
+
return { itemId, operation: {
|
|
22063
22073
|
...op,
|
|
22064
22074
|
newData
|
|
22065
|
-
};
|
|
22075
|
+
} };
|
|
22066
22076
|
});
|
|
22067
22077
|
}
|
|
22068
22078
|
}
|
|
@@ -24114,7 +24124,7 @@ class BaseItem extends Mbr {
|
|
|
24114
24124
|
}
|
|
24115
24125
|
emit(operation) {
|
|
24116
24126
|
if (this.board.events) {
|
|
24117
|
-
const command = new BaseCommand([this], operation);
|
|
24127
|
+
const command = new BaseCommand(this.board, [this.getId()], operation);
|
|
24118
24128
|
command.apply();
|
|
24119
24129
|
this.board.events.emit(operation, command);
|
|
24120
24130
|
} else {
|
|
@@ -49965,8 +49975,8 @@ function createItemValidator(defaultData2) {
|
|
|
49965
49975
|
};
|
|
49966
49976
|
}
|
|
49967
49977
|
function createItemCommandFactory(itemType) {
|
|
49968
|
-
return function itemCommandFactory(items, operation) {
|
|
49969
|
-
return new BaseCommand(items.filter((item) => item.itemType === itemType), operation);
|
|
49978
|
+
return function itemCommandFactory(items, operation, board) {
|
|
49979
|
+
return new BaseCommand(board, items.filter((item) => item.itemType === itemType).map((item) => item.getId()), operation);
|
|
49970
49980
|
};
|
|
49971
49981
|
}
|
|
49972
49982
|
// src/Items/Examples/Star/AddStar.ts
|
package/dist/esm/browser.js
CHANGED
|
@@ -19317,11 +19317,13 @@ class AudioCommand {
|
|
|
19317
19317
|
|
|
19318
19318
|
// src/Events/Command.ts
|
|
19319
19319
|
class BaseCommand {
|
|
19320
|
-
|
|
19320
|
+
board;
|
|
19321
|
+
itemIds;
|
|
19321
19322
|
operation;
|
|
19322
19323
|
reverse;
|
|
19323
|
-
constructor(
|
|
19324
|
-
this.
|
|
19324
|
+
constructor(board, itemIds, operation) {
|
|
19325
|
+
this.board = board;
|
|
19326
|
+
this.itemIds = itemIds;
|
|
19325
19327
|
this.operation = operation;
|
|
19326
19328
|
this.reverse = this.getReverse();
|
|
19327
19329
|
}
|
|
@@ -19330,49 +19332,57 @@ class BaseCommand {
|
|
|
19330
19332
|
return this;
|
|
19331
19333
|
}
|
|
19332
19334
|
apply() {
|
|
19333
|
-
for (const
|
|
19335
|
+
for (const itemId of this.itemIds) {
|
|
19336
|
+
const item = this.board.items.getById(itemId);
|
|
19337
|
+
if (!item) {
|
|
19338
|
+
continue;
|
|
19339
|
+
}
|
|
19334
19340
|
item.apply(this.operation);
|
|
19335
19341
|
}
|
|
19336
19342
|
}
|
|
19337
19343
|
revert() {
|
|
19338
|
-
for (const {
|
|
19344
|
+
for (const { itemId, operation } of this.reverse) {
|
|
19345
|
+
const item = this.board.items.getById(itemId);
|
|
19346
|
+
if (!item) {
|
|
19347
|
+
continue;
|
|
19348
|
+
}
|
|
19339
19349
|
item.apply(operation);
|
|
19340
19350
|
}
|
|
19341
19351
|
}
|
|
19342
19352
|
getReverse() {
|
|
19343
|
-
const items = this.items;
|
|
19344
19353
|
switch (this.operation.method) {
|
|
19345
19354
|
case "addChildren":
|
|
19346
|
-
return
|
|
19347
|
-
return {
|
|
19355
|
+
return this.itemIds.map((itemId) => {
|
|
19356
|
+
return { itemId, operation: {
|
|
19348
19357
|
...this.operation,
|
|
19349
19358
|
method: "removeChildren"
|
|
19350
19359
|
} };
|
|
19351
19360
|
});
|
|
19352
19361
|
case "removeChildren":
|
|
19353
|
-
return
|
|
19354
|
-
return {
|
|
19362
|
+
return this.itemIds.map((itemId) => {
|
|
19363
|
+
return { itemId, operation: {
|
|
19355
19364
|
...this.operation,
|
|
19356
19365
|
method: "addChildren"
|
|
19357
19366
|
} };
|
|
19358
19367
|
});
|
|
19359
19368
|
default:
|
|
19360
|
-
return
|
|
19369
|
+
return this.itemIds.map((itemId) => {
|
|
19361
19370
|
const op = this.operation;
|
|
19362
19371
|
let newData = {};
|
|
19363
19372
|
if (op.prevData) {
|
|
19364
19373
|
newData = { ...op.prevData };
|
|
19365
19374
|
} else {
|
|
19375
|
+
const item = this.board.items.getById(itemId);
|
|
19366
19376
|
Object.keys(op.newData).forEach((key) => {
|
|
19367
19377
|
if (item[key]) {
|
|
19368
19378
|
newData[key] = item[key];
|
|
19369
19379
|
}
|
|
19370
19380
|
});
|
|
19371
19381
|
}
|
|
19372
|
-
return {
|
|
19382
|
+
return { itemId, operation: {
|
|
19373
19383
|
...op,
|
|
19374
19384
|
newData
|
|
19375
|
-
};
|
|
19385
|
+
} };
|
|
19376
19386
|
});
|
|
19377
19387
|
}
|
|
19378
19388
|
}
|
|
@@ -21491,7 +21501,7 @@ class BaseItem extends Mbr {
|
|
|
21491
21501
|
}
|
|
21492
21502
|
emit(operation) {
|
|
21493
21503
|
if (this.board.events) {
|
|
21494
|
-
const command = new BaseCommand([this], operation);
|
|
21504
|
+
const command = new BaseCommand(this.board, [this.getId()], operation);
|
|
21495
21505
|
command.apply();
|
|
21496
21506
|
this.board.events.emit(operation, command);
|
|
21497
21507
|
} else {
|
|
@@ -47341,8 +47351,8 @@ function createItemValidator(defaultData2) {
|
|
|
47341
47351
|
};
|
|
47342
47352
|
}
|
|
47343
47353
|
function createItemCommandFactory(itemType) {
|
|
47344
|
-
return function itemCommandFactory(items, operation) {
|
|
47345
|
-
return new BaseCommand(items.filter((item) => item.itemType === itemType), operation);
|
|
47354
|
+
return function itemCommandFactory(items, operation, board) {
|
|
47355
|
+
return new BaseCommand(board, items.filter((item) => item.itemType === itemType).map((item) => item.getId()), operation);
|
|
47346
47356
|
};
|
|
47347
47357
|
}
|
|
47348
47358
|
// src/Items/Examples/Star/AddStar.ts
|
package/dist/esm/index.js
CHANGED
|
@@ -19310,11 +19310,13 @@ class AudioCommand {
|
|
|
19310
19310
|
|
|
19311
19311
|
// src/Events/Command.ts
|
|
19312
19312
|
class BaseCommand {
|
|
19313
|
-
|
|
19313
|
+
board;
|
|
19314
|
+
itemIds;
|
|
19314
19315
|
operation;
|
|
19315
19316
|
reverse;
|
|
19316
|
-
constructor(
|
|
19317
|
-
this.
|
|
19317
|
+
constructor(board, itemIds, operation) {
|
|
19318
|
+
this.board = board;
|
|
19319
|
+
this.itemIds = itemIds;
|
|
19318
19320
|
this.operation = operation;
|
|
19319
19321
|
this.reverse = this.getReverse();
|
|
19320
19322
|
}
|
|
@@ -19323,49 +19325,57 @@ class BaseCommand {
|
|
|
19323
19325
|
return this;
|
|
19324
19326
|
}
|
|
19325
19327
|
apply() {
|
|
19326
|
-
for (const
|
|
19328
|
+
for (const itemId of this.itemIds) {
|
|
19329
|
+
const item = this.board.items.getById(itemId);
|
|
19330
|
+
if (!item) {
|
|
19331
|
+
continue;
|
|
19332
|
+
}
|
|
19327
19333
|
item.apply(this.operation);
|
|
19328
19334
|
}
|
|
19329
19335
|
}
|
|
19330
19336
|
revert() {
|
|
19331
|
-
for (const {
|
|
19337
|
+
for (const { itemId, operation } of this.reverse) {
|
|
19338
|
+
const item = this.board.items.getById(itemId);
|
|
19339
|
+
if (!item) {
|
|
19340
|
+
continue;
|
|
19341
|
+
}
|
|
19332
19342
|
item.apply(operation);
|
|
19333
19343
|
}
|
|
19334
19344
|
}
|
|
19335
19345
|
getReverse() {
|
|
19336
|
-
const items = this.items;
|
|
19337
19346
|
switch (this.operation.method) {
|
|
19338
19347
|
case "addChildren":
|
|
19339
|
-
return
|
|
19340
|
-
return {
|
|
19348
|
+
return this.itemIds.map((itemId) => {
|
|
19349
|
+
return { itemId, operation: {
|
|
19341
19350
|
...this.operation,
|
|
19342
19351
|
method: "removeChildren"
|
|
19343
19352
|
} };
|
|
19344
19353
|
});
|
|
19345
19354
|
case "removeChildren":
|
|
19346
|
-
return
|
|
19347
|
-
return {
|
|
19355
|
+
return this.itemIds.map((itemId) => {
|
|
19356
|
+
return { itemId, operation: {
|
|
19348
19357
|
...this.operation,
|
|
19349
19358
|
method: "addChildren"
|
|
19350
19359
|
} };
|
|
19351
19360
|
});
|
|
19352
19361
|
default:
|
|
19353
|
-
return
|
|
19362
|
+
return this.itemIds.map((itemId) => {
|
|
19354
19363
|
const op = this.operation;
|
|
19355
19364
|
let newData = {};
|
|
19356
19365
|
if (op.prevData) {
|
|
19357
19366
|
newData = { ...op.prevData };
|
|
19358
19367
|
} else {
|
|
19368
|
+
const item = this.board.items.getById(itemId);
|
|
19359
19369
|
Object.keys(op.newData).forEach((key) => {
|
|
19360
19370
|
if (item[key]) {
|
|
19361
19371
|
newData[key] = item[key];
|
|
19362
19372
|
}
|
|
19363
19373
|
});
|
|
19364
19374
|
}
|
|
19365
|
-
return {
|
|
19375
|
+
return { itemId, operation: {
|
|
19366
19376
|
...op,
|
|
19367
19377
|
newData
|
|
19368
|
-
};
|
|
19378
|
+
} };
|
|
19369
19379
|
});
|
|
19370
19380
|
}
|
|
19371
19381
|
}
|
|
@@ -21484,7 +21494,7 @@ class BaseItem extends Mbr {
|
|
|
21484
21494
|
}
|
|
21485
21495
|
emit(operation) {
|
|
21486
21496
|
if (this.board.events) {
|
|
21487
|
-
const command = new BaseCommand([this], operation);
|
|
21497
|
+
const command = new BaseCommand(this.board, [this.getId()], operation);
|
|
21488
21498
|
command.apply();
|
|
21489
21499
|
this.board.events.emit(operation, command);
|
|
21490
21500
|
} else {
|
|
@@ -47334,8 +47344,8 @@ function createItemValidator(defaultData2) {
|
|
|
47334
47344
|
};
|
|
47335
47345
|
}
|
|
47336
47346
|
function createItemCommandFactory(itemType) {
|
|
47337
|
-
return function itemCommandFactory(items, operation) {
|
|
47338
|
-
return new BaseCommand(items.filter((item) => item.itemType === itemType), operation);
|
|
47347
|
+
return function itemCommandFactory(items, operation, board) {
|
|
47348
|
+
return new BaseCommand(board, items.filter((item) => item.itemType === itemType).map((item) => item.getId()), operation);
|
|
47339
47349
|
};
|
|
47340
47350
|
}
|
|
47341
47351
|
// src/Items/Examples/Star/AddStar.ts
|
package/dist/esm/node.js
CHANGED
|
@@ -21844,11 +21844,13 @@ class AudioCommand {
|
|
|
21844
21844
|
|
|
21845
21845
|
// src/Events/Command.ts
|
|
21846
21846
|
class BaseCommand {
|
|
21847
|
-
|
|
21847
|
+
board;
|
|
21848
|
+
itemIds;
|
|
21848
21849
|
operation;
|
|
21849
21850
|
reverse;
|
|
21850
|
-
constructor(
|
|
21851
|
-
this.
|
|
21851
|
+
constructor(board, itemIds, operation) {
|
|
21852
|
+
this.board = board;
|
|
21853
|
+
this.itemIds = itemIds;
|
|
21852
21854
|
this.operation = operation;
|
|
21853
21855
|
this.reverse = this.getReverse();
|
|
21854
21856
|
}
|
|
@@ -21857,49 +21859,57 @@ class BaseCommand {
|
|
|
21857
21859
|
return this;
|
|
21858
21860
|
}
|
|
21859
21861
|
apply() {
|
|
21860
|
-
for (const
|
|
21862
|
+
for (const itemId of this.itemIds) {
|
|
21863
|
+
const item = this.board.items.getById(itemId);
|
|
21864
|
+
if (!item) {
|
|
21865
|
+
continue;
|
|
21866
|
+
}
|
|
21861
21867
|
item.apply(this.operation);
|
|
21862
21868
|
}
|
|
21863
21869
|
}
|
|
21864
21870
|
revert() {
|
|
21865
|
-
for (const {
|
|
21871
|
+
for (const { itemId, operation } of this.reverse) {
|
|
21872
|
+
const item = this.board.items.getById(itemId);
|
|
21873
|
+
if (!item) {
|
|
21874
|
+
continue;
|
|
21875
|
+
}
|
|
21866
21876
|
item.apply(operation);
|
|
21867
21877
|
}
|
|
21868
21878
|
}
|
|
21869
21879
|
getReverse() {
|
|
21870
|
-
const items = this.items;
|
|
21871
21880
|
switch (this.operation.method) {
|
|
21872
21881
|
case "addChildren":
|
|
21873
|
-
return
|
|
21874
|
-
return {
|
|
21882
|
+
return this.itemIds.map((itemId) => {
|
|
21883
|
+
return { itemId, operation: {
|
|
21875
21884
|
...this.operation,
|
|
21876
21885
|
method: "removeChildren"
|
|
21877
21886
|
} };
|
|
21878
21887
|
});
|
|
21879
21888
|
case "removeChildren":
|
|
21880
|
-
return
|
|
21881
|
-
return {
|
|
21889
|
+
return this.itemIds.map((itemId) => {
|
|
21890
|
+
return { itemId, operation: {
|
|
21882
21891
|
...this.operation,
|
|
21883
21892
|
method: "addChildren"
|
|
21884
21893
|
} };
|
|
21885
21894
|
});
|
|
21886
21895
|
default:
|
|
21887
|
-
return
|
|
21896
|
+
return this.itemIds.map((itemId) => {
|
|
21888
21897
|
const op = this.operation;
|
|
21889
21898
|
let newData = {};
|
|
21890
21899
|
if (op.prevData) {
|
|
21891
21900
|
newData = { ...op.prevData };
|
|
21892
21901
|
} else {
|
|
21902
|
+
const item = this.board.items.getById(itemId);
|
|
21893
21903
|
Object.keys(op.newData).forEach((key) => {
|
|
21894
21904
|
if (item[key]) {
|
|
21895
21905
|
newData[key] = item[key];
|
|
21896
21906
|
}
|
|
21897
21907
|
});
|
|
21898
21908
|
}
|
|
21899
|
-
return {
|
|
21909
|
+
return { itemId, operation: {
|
|
21900
21910
|
...op,
|
|
21901
21911
|
newData
|
|
21902
|
-
};
|
|
21912
|
+
} };
|
|
21903
21913
|
});
|
|
21904
21914
|
}
|
|
21905
21915
|
}
|
|
@@ -23951,7 +23961,7 @@ class BaseItem extends Mbr {
|
|
|
23951
23961
|
}
|
|
23952
23962
|
emit(operation) {
|
|
23953
23963
|
if (this.board.events) {
|
|
23954
|
-
const command = new BaseCommand([this], operation);
|
|
23964
|
+
const command = new BaseCommand(this.board, [this.getId()], operation);
|
|
23955
23965
|
command.apply();
|
|
23956
23966
|
this.board.events.emit(operation, command);
|
|
23957
23967
|
} else {
|
|
@@ -49802,8 +49812,8 @@ function createItemValidator(defaultData2) {
|
|
|
49802
49812
|
};
|
|
49803
49813
|
}
|
|
49804
49814
|
function createItemCommandFactory(itemType) {
|
|
49805
|
-
return function itemCommandFactory(items, operation) {
|
|
49806
|
-
return new BaseCommand(items.filter((item) => item.itemType === itemType), operation);
|
|
49815
|
+
return function itemCommandFactory(items, operation, board) {
|
|
49816
|
+
return new BaseCommand(board, items.filter((item) => item.itemType === itemType).map((item) => item.getId()), operation);
|
|
49807
49817
|
};
|
|
49808
49818
|
}
|
|
49809
49819
|
// src/Items/Examples/Star/AddStar.ts
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { Board } from 'Board';
|
|
2
2
|
import { BaseOperation, ItemOperation, Operation } from './EventsOperations';
|
|
3
3
|
import { Item, TransformationOperation } from 'Items';
|
|
4
|
-
import { BaseItem } from "../Items/BaseItem";
|
|
5
4
|
export interface Command {
|
|
6
5
|
apply(): void;
|
|
7
6
|
revert(): void;
|
|
8
7
|
merge?: (op: any) => Command;
|
|
9
8
|
}
|
|
10
9
|
export declare class BaseCommand {
|
|
11
|
-
|
|
10
|
+
private board;
|
|
11
|
+
itemIds: string[];
|
|
12
12
|
operation: BaseOperation;
|
|
13
13
|
private reverse;
|
|
14
|
-
constructor(
|
|
14
|
+
constructor(board: Board, itemIds: string[], operation: BaseOperation);
|
|
15
15
|
merge(op: BaseOperation): this;
|
|
16
16
|
apply(): void;
|
|
17
17
|
revert(): void;
|
|
18
18
|
getReverse(): {
|
|
19
|
-
|
|
19
|
+
itemId: string;
|
|
20
20
|
operation: BaseOperation;
|
|
21
21
|
}[];
|
|
22
22
|
}
|