@meta2d/core 1.0.25 → 1.0.26
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 +2 -2
- package/src/canvas/canvas.js +106 -98
- package/src/canvas/canvas.js.map +1 -1
- package/src/core.js +35 -8
- package/src/core.js.map +1 -1
- package/src/diagrams/iframe.js +27 -4
- package/src/diagrams/iframe.js.map +1 -1
- package/src/event/event.d.ts +3 -1
- package/src/event/event.js +2 -0
- package/src/event/event.js.map +1 -1
- package/src/options.d.ts +6 -0
- package/src/options.js +1 -0
- package/src/options.js.map +1 -1
- package/src/pen/model.d.ts +1 -0
- package/src/pen/model.js.map +1 -1
- package/src/pen/text.js +17 -1
- package/src/pen/text.js.map +1 -1
- package/src/title/title.js +9 -9
- package/src/title/title.js.map +1 -1
- package/src/utils/clone.d.ts +1 -1
- package/src/utils/clone.js +14 -4
- package/src/utils/clone.js.map +1 -1
- package/src/utils/url.d.ts +3 -0
- package/src/utils/url.js +7 -0
- package/src/utils/url.js.map +1 -0
package/src/core.js
CHANGED
|
@@ -96,6 +96,7 @@ import pkg from '../package.json';
|
|
|
96
96
|
import { lockedError } from './utils/error';
|
|
97
97
|
import { Scroll } from './scroll';
|
|
98
98
|
import { getter } from './utils/object';
|
|
99
|
+
import { queryURLParams } from './utils/url';
|
|
99
100
|
var Meta2d = /** @class */ (function () {
|
|
100
101
|
function Meta2d(parent, opts) {
|
|
101
102
|
var _this = this;
|
|
@@ -569,6 +570,31 @@ var Meta2d = /** @class */ (function () {
|
|
|
569
570
|
}
|
|
570
571
|
}
|
|
571
572
|
};
|
|
573
|
+
this.events[EventAction.PostMessage] = function (pen, e) {
|
|
574
|
+
if (typeof e.value !== 'string') {
|
|
575
|
+
console.warn('[meta2d] Emit value must be a string');
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
578
|
+
var _pen = e.params ? _this.findOne(e.params) : pen;
|
|
579
|
+
if (_pen.name !== 'iframe' || !_pen.iframe) {
|
|
580
|
+
console.warn('不是嵌入页面');
|
|
581
|
+
return;
|
|
582
|
+
}
|
|
583
|
+
var params = queryURLParams(_pen.iframe.split('?')[1]);
|
|
584
|
+
_pen.calculative.singleton.div.children[0].contentWindow.postMessage(JSON.stringify({
|
|
585
|
+
name: e.value,
|
|
586
|
+
id: params.id,
|
|
587
|
+
}), '*');
|
|
588
|
+
return;
|
|
589
|
+
};
|
|
590
|
+
this.events[EventAction.PostMessageToParent] = function (pen, e) {
|
|
591
|
+
if (typeof e.value !== 'string') {
|
|
592
|
+
console.warn('[meta2d] Emit value must be a string');
|
|
593
|
+
return;
|
|
594
|
+
}
|
|
595
|
+
window.parent.postMessage(JSON.stringify(e.value), '*');
|
|
596
|
+
return;
|
|
597
|
+
};
|
|
572
598
|
};
|
|
573
599
|
Meta2d.prototype.navigatorTo = function (id) {
|
|
574
600
|
if (!id) {
|
|
@@ -1205,9 +1231,10 @@ var Meta2d = /** @class */ (function () {
|
|
|
1205
1231
|
var _this = this;
|
|
1206
1232
|
this.stopAnimate(idOrTagOrPens);
|
|
1207
1233
|
var pens;
|
|
1234
|
+
// 没有参数 则播放有自动播放属性的动画
|
|
1208
1235
|
if (!idOrTagOrPens) {
|
|
1209
1236
|
pens = this.store.data.pens.filter(function (pen) {
|
|
1210
|
-
return (pen.type || pen.frames) && pen.autoPlay;
|
|
1237
|
+
return ((pen.type || pen.frames) && pen.autoPlay) || (pen.animations && pen.autoPlay);
|
|
1211
1238
|
});
|
|
1212
1239
|
}
|
|
1213
1240
|
else if (typeof idOrTagOrPens === 'string') {
|
|
@@ -1217,6 +1244,7 @@ var Meta2d = /** @class */ (function () {
|
|
|
1217
1244
|
pens = idOrTagOrPens;
|
|
1218
1245
|
}
|
|
1219
1246
|
pens.forEach(function (pen) {
|
|
1247
|
+
var _a;
|
|
1220
1248
|
if (pen.calculative.pause) {
|
|
1221
1249
|
var d = Date.now() - pen.calculative.pause;
|
|
1222
1250
|
pen.calculative.pause = undefined;
|
|
@@ -1224,8 +1252,8 @@ var Meta2d = /** @class */ (function () {
|
|
|
1224
1252
|
pen.calculative.frameEnd += d;
|
|
1225
1253
|
}
|
|
1226
1254
|
else {
|
|
1255
|
+
var index = -1;
|
|
1227
1256
|
if (params !== undefined && pen.animations) {
|
|
1228
|
-
var index = -1;
|
|
1229
1257
|
if (typeof params === 'string') {
|
|
1230
1258
|
index = pen.animations.findIndex(function (animation) { return animation.name === params; });
|
|
1231
1259
|
if (index === -1) {
|
|
@@ -1240,6 +1268,11 @@ var Meta2d = /** @class */ (function () {
|
|
|
1240
1268
|
return;
|
|
1241
1269
|
}
|
|
1242
1270
|
}
|
|
1271
|
+
}
|
|
1272
|
+
else if (params === undefined) {
|
|
1273
|
+
index = ((_a = pen.animations) === null || _a === void 0 ? void 0 : _a.findIndex(function (i) { return i.autoPlay; })) || -1;
|
|
1274
|
+
}
|
|
1275
|
+
if (index !== -1) {
|
|
1243
1276
|
var animate = deepClone(pen.animations[index]);
|
|
1244
1277
|
delete animate.name;
|
|
1245
1278
|
animate.currentAnimation = index;
|
|
@@ -1972,12 +2005,6 @@ var Meta2d = /** @class */ (function () {
|
|
|
1972
2005
|
};
|
|
1973
2006
|
//获取动态参数
|
|
1974
2007
|
Meta2d.prototype.getDynamicParam = function (key) {
|
|
1975
|
-
function queryURLParams() {
|
|
1976
|
-
var url = window.location.href.split('?')[1];
|
|
1977
|
-
var urlSearchParams = new URLSearchParams(url);
|
|
1978
|
-
var params = Object.fromEntries(urlSearchParams.entries());
|
|
1979
|
-
return params;
|
|
1980
|
-
}
|
|
1981
2008
|
function getCookie(name) {
|
|
1982
2009
|
var arr;
|
|
1983
2010
|
var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)');
|