@meta2d/core 1.0.19 → 1.0.20
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/package.json +1 -1
- package/src/canvas/canvas.js +14 -2
- package/src/canvas/canvas.js.map +1 -1
- package/src/core.d.ts +1 -0
- package/src/core.js +71 -38
- package/src/core.js.map +1 -1
- package/src/diagrams/gif.js +4 -2
- package/src/diagrams/gif.js.map +1 -1
- package/src/options.d.ts +1 -0
- package/src/options.js.map +1 -1
- package/src/pen/render.js +8 -8
- package/src/pen/render.js.map +1 -1
- package/src/store/store.d.ts +2 -0
- package/src/store/store.js +1 -0
- package/src/store/store.js.map +1 -1
package/src/core.d.ts
CHANGED
package/src/core.js
CHANGED
|
@@ -774,58 +774,76 @@ var Meta2d = /** @class */ (function () {
|
|
|
774
774
|
var _this = this;
|
|
775
775
|
if (render === void 0) { render = true; }
|
|
776
776
|
this.clear(false);
|
|
777
|
-
|
|
777
|
+
var index = this.store.meta2dDatas.findIndex(function (item) { return item._id === data._id; });
|
|
778
|
+
if (this.store.options.cacheLength && data._id && index !== -1) {
|
|
779
|
+
this.store.data = this.store.meta2dDatas[index];
|
|
778
780
|
this.setBackgroundImage(data.bkImage);
|
|
779
|
-
|
|
780
|
-
this.store.data.pens
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
781
|
+
this.store.pens = {};
|
|
782
|
+
this.store.data.pens.forEach(function (pen) {
|
|
783
|
+
pen.calculative.canvas = _this.canvas;
|
|
784
|
+
_this.store.pens[pen.id] = pen;
|
|
785
|
+
globalStore.path2dDraws[pen.name] &&
|
|
786
|
+
_this.store.path2dMap.set(pen, globalStore.path2dDraws[pen.name](pen));
|
|
787
|
+
pen.type &&
|
|
788
|
+
_this.store.path2dMap.set(pen, globalStore.path2dDraws[pen.name](pen));
|
|
789
|
+
_this.canvas.loadImage(pen);
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
else {
|
|
793
|
+
if (data) {
|
|
794
|
+
this.setBackgroundImage(data.bkImage);
|
|
795
|
+
Object.assign(this.store.data, data);
|
|
796
|
+
this.store.data.pens = [];
|
|
794
797
|
try {
|
|
795
|
-
|
|
798
|
+
// 第一遍赋初值
|
|
799
|
+
for (var _f = __values(data.pens), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
800
|
+
var pen = _g.value;
|
|
801
|
+
if (!pen.id) {
|
|
802
|
+
pen.id = s8();
|
|
803
|
+
}
|
|
804
|
+
!pen.calculative && (pen.calculative = { canvas: this.canvas });
|
|
805
|
+
this.store.pens[pen.id] = pen;
|
|
806
|
+
}
|
|
796
807
|
}
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
808
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
809
|
+
finally {
|
|
810
|
+
try {
|
|
811
|
+
if (_g && !_g.done && (_a = _f.return)) _a.call(_f);
|
|
812
|
+
}
|
|
813
|
+
finally { if (e_1) throw e_1.error; }
|
|
803
814
|
}
|
|
804
|
-
}
|
|
805
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
806
|
-
finally {
|
|
807
815
|
try {
|
|
808
|
-
|
|
816
|
+
for (var _h = __values(data.pens), _j = _h.next(); !_j.done; _j = _h.next()) {
|
|
817
|
+
var pen = _j.value;
|
|
818
|
+
this.canvas.makePen(pen);
|
|
819
|
+
}
|
|
809
820
|
}
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
821
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
822
|
+
finally {
|
|
823
|
+
try {
|
|
824
|
+
if (_j && !_j.done && (_b = _h.return)) _b.call(_h);
|
|
825
|
+
}
|
|
826
|
+
finally { if (e_2) throw e_2.error; }
|
|
816
827
|
}
|
|
817
|
-
}
|
|
818
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
819
|
-
finally {
|
|
820
828
|
try {
|
|
821
|
-
|
|
829
|
+
for (var _k = __values(data.pens), _l = _k.next(); !_l.done; _l = _k.next()) {
|
|
830
|
+
var pen = _l.value;
|
|
831
|
+
this.canvas.updateLines(pen);
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
835
|
+
finally {
|
|
836
|
+
try {
|
|
837
|
+
if (_l && !_l.done && (_c = _k.return)) _c.call(_k);
|
|
838
|
+
}
|
|
839
|
+
finally { if (e_3) throw e_3.error; }
|
|
822
840
|
}
|
|
823
|
-
finally { if (e_3) throw e_3.error; }
|
|
824
841
|
}
|
|
825
842
|
}
|
|
826
843
|
if (!render) {
|
|
827
844
|
this.canvas.opening = true;
|
|
828
845
|
}
|
|
846
|
+
this.cacheMeta2dData(data);
|
|
829
847
|
this.initBindDatas();
|
|
830
848
|
this.initBinds();
|
|
831
849
|
this.render();
|
|
@@ -856,6 +874,21 @@ var Meta2d = /** @class */ (function () {
|
|
|
856
874
|
this.canvas.scroll.init();
|
|
857
875
|
}
|
|
858
876
|
};
|
|
877
|
+
Meta2d.prototype.cacheMeta2dData = function (data) {
|
|
878
|
+
if (data._id && this.store.options.cacheLength) {
|
|
879
|
+
var index = this.store.meta2dDatas.findIndex(function (item) { return item._id === data._id; });
|
|
880
|
+
if (index === -1) {
|
|
881
|
+
this.store.meta2dDatas.push(deepClone(this.store.data, true));
|
|
882
|
+
if (this.store.meta2dDatas.length > this.store.options.cacheLength) {
|
|
883
|
+
this.store.meta2dDatas.shift();
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
else {
|
|
887
|
+
var meta2dData = this.store.meta2dDatas.splice(index, 1)[0];
|
|
888
|
+
this.store.meta2dDatas.push(meta2dData);
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
};
|
|
859
892
|
Meta2d.prototype.initBindDatas = function () {
|
|
860
893
|
var _this = this;
|
|
861
894
|
this.store.bindDatas = {};
|