@galacean/effects-specification 0.0.1 → 1.0.0

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/fallback.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  * Name: @galacean/effects-specification
3
3
  * Description: Galacean Effects JSON Specification
4
4
  * Author: Ant Group CO., Ltd.
5
- * Version: v0.0.1
5
+ * Version: v1.0.0
6
6
  */
7
7
 
8
8
  /*********************************************/
@@ -473,7 +473,7 @@ var ItemEndBehavior;
473
473
  (function (ItemEndBehavior) {
474
474
  ItemEndBehavior[ItemEndBehavior["destroy"] = END_BEHAVIOR_DESTROY] = "destroy";
475
475
  ItemEndBehavior[ItemEndBehavior["loop"] = END_BEHAVIOR_RESTART] = "loop";
476
- ItemEndBehavior[ItemEndBehavior["forward"] = END_BEHAVIOR_FREEZE] = "forward";
476
+ ItemEndBehavior[ItemEndBehavior["freeze"] = END_BEHAVIOR_FREEZE] = "freeze";
477
477
  })(ItemEndBehavior || (ItemEndBehavior = {}));
478
478
  var ParentItemEndBehavior;
479
479
  (function (ParentItemEndBehavior) {
@@ -719,7 +719,12 @@ function __read(o, n) {
719
719
  finally { if (e) throw e.error; }
720
720
  }
721
721
  return ar;
722
- }
722
+ }
723
+
724
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
725
+ var e = new Error(message);
726
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
727
+ };
723
728
 
724
729
  function arrAdd(arr, item) {
725
730
  if (!arr.includes(item)) {
@@ -1341,7 +1346,7 @@ function version21Migration(json) {
1341
1346
  composition.items.forEach(function (item) {
1342
1347
  if (item.type === ItemType.null) {
1343
1348
  if (item.endBehavior === ItemEndBehavior.destroy) {
1344
- item.endBehavior = ItemEndBehavior.forward;
1349
+ item.endBehavior = ItemEndBehavior.freeze;
1345
1350
  }
1346
1351
  }
1347
1352
  });
@@ -1349,6 +1354,24 @@ function version21Migration(json) {
1349
1354
  json.version = '2.1';
1350
1355
  return json;
1351
1356
  }
1357
+ /**
1358
+ * 2.2 以下版本数据适配(mars-player@2.5.0 及以上版本支持 2.2 以下数据的适配)
1359
+ */
1360
+ function version22Migration(json) {
1361
+ var _a;
1362
+ var singleVersion = (_a = json.version) === null || _a === void 0 ? void 0 : _a.split('.');
1363
+ if (!singleVersion || Number(singleVersion[0]) > 2 || (Number(singleVersion[0]) === 2 && Number(singleVersion[1]) >= 2)) {
1364
+ return json;
1365
+ }
1366
+ json.compositions.forEach(function (composition) {
1367
+ composition.items.forEach(function (item) {
1368
+ if (item.type === ItemType.mesh || item.type === ItemType.light) {
1369
+ item.endBehavior = item.endBehavior === 1 ? ItemEndBehavior.destroy : item.endBehavior;
1370
+ }
1371
+ });
1372
+ });
1373
+ return json;
1374
+ }
1352
1375
 
1353
1376
  var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
1354
1377
  var standardVersion = /^(\d+)\.(\d+)$/;
@@ -1358,6 +1381,8 @@ function getStandardJSON(json) {
1358
1381
  if (!json || typeof json !== 'object') {
1359
1382
  throw Error('expect a json object');
1360
1383
  }
1384
+ // 修正老版本数据中,meshItem以及lightItem结束行为错误问题
1385
+ version22Migration(json);
1361
1386
  if (v0.test(json.version)) {
1362
1387
  reverseParticle = ((_a = (/^(\d+)/).exec(json.version)) === null || _a === void 0 ? void 0 : _a[0]) === '0';
1363
1388
  return version21Migration(getStandardJSONFromV0(json));