@versa_ai/vmml-editor 1.0.53 → 1.0.55

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @versa_ai/vmml-editor@1.0.53 build D:\code\work\vmml-player\packages\editor
2
+ > @versa_ai/vmml-editor@1.0.55 build D:\code\work\vmml-player\packages\editor
3
3
  > tsup
4
4
 
5
5
  CLI Building entry: src/index.tsx
@@ -124,12 +124,12 @@ More info and automated migrator: https://sass-lang.com/d/slash-div [35
124
124
 
125
125
 
126
126
 
127
- CJS dist\index.js 121.96 KB
128
- CJS dist\index.js.map 234.13 KB
129
- CJS ⚡️ Build success in 848ms
130
- ESM dist\index.mjs 120.09 KB
131
- ESM dist\index.mjs.map 233.83 KB
132
- ESM ⚡️ Build success in 852ms
133
- DTS ⚡️ Build success in 1567ms
127
+ CJS dist\index.js 122.48 KB
128
+ CJS dist\index.js.map 235.03 KB
129
+ CJS ⚡️ Build success in 756ms
130
+ ESM dist\index.mjs 120.61 KB
131
+ ESM dist\index.mjs.map 234.73 KB
132
+ ESM ⚡️ Build success in 757ms
133
+ DTS ⚡️ Build success in 1764ms
134
134
  DTS dist\index.d.ts 158.00 B
135
135
  DTS dist\index.d.mts 158.00 B
package/dist/index.js CHANGED
@@ -563,17 +563,19 @@ var VmmlConverter = class {
563
563
  heightScale;
564
564
  widthScale;
565
565
  fontSize;
566
+ updatePlayer;
566
567
  /**
567
568
  * VmmlConverter 构造函数
568
569
  * @param vmml - VMML 模板数据
569
570
  * @param canvasSize - 画布尺寸
570
571
  */
571
- constructor({ vmml, canvasSize }) {
572
+ constructor({ vmml, canvasSize, updatePlayer }) {
572
573
  const { width, height } = vmml.template.dimension;
573
574
  this.vmml = vmml;
574
575
  this.canvasSize = canvasSize;
575
576
  this.tracks = vmml.template.tracks;
576
577
  this.fontSize = vmmlUtils.getFontSize(width, height);
578
+ this.updatePlayer = updatePlayer;
577
579
  this.heightScale = height / canvasSize.height;
578
580
  this.widthScale = width / canvasSize.width;
579
581
  }
@@ -638,7 +640,9 @@ var VmmlConverter = class {
638
640
  * 转换 TextClip
639
641
  * @param fObj - 画布fObj
640
642
  */
641
- addTextClip(fObj) {
643
+ addTextClip(fObj, isUpdate) {
644
+ var _a;
645
+ isUpdate = isUpdate ?? true;
642
646
  const posParam = this.setPosParam(fObj);
643
647
  const { clipData: { id, inPoint, text, textColor, bgColor } } = fObj;
644
648
  const { template: { duration } } = this.vmml;
@@ -681,13 +685,15 @@ var VmmlConverter = class {
681
685
  } else {
682
686
  editorTrack.clips.push(tClipData);
683
687
  }
684
- this.updateVmml(this.vmml);
688
+ if (isUpdate) (_a = this == null ? void 0 : this.updatePlayer) == null ? void 0 : _a.call(this, this.vmml);
685
689
  }
686
690
  /**
687
691
  * 转换 VideoClip
688
692
  * @param fObj - 画布fObj
689
693
  */
690
- addVideoClip(fObj) {
694
+ addVideoClip(fObj, isUpdate) {
695
+ var _a;
696
+ isUpdate = isUpdate ?? true;
691
697
  const clips = [];
692
698
  const editorTrack = this.tracks.find((track) => track.editorType === "\u8868\u60C5\u5305");
693
699
  const clipData = this.loadClipData(fObj);
@@ -717,12 +723,15 @@ var VmmlConverter = class {
717
723
  }
718
724
  }
719
725
  }
726
+ if (isUpdate) (_a = this == null ? void 0 : this.updatePlayer) == null ? void 0 : _a.call(this, this.vmml);
720
727
  }
721
728
  /**
722
729
  * 更新 clip
723
730
  * @param fObj - 画布fObj
724
731
  */
725
- updateClip(fObj) {
732
+ updateClip(fObj, isUpdate) {
733
+ var _a;
734
+ isUpdate = isUpdate ?? true;
726
735
  const posParam = this.setPosParam(fObj);
727
736
  const {
728
737
  clipData: { id, type, lineSpacing, originClip }
@@ -748,13 +757,15 @@ var VmmlConverter = class {
748
757
  };
749
758
  }
750
759
  }
760
+ if (isUpdate) (_a = this == null ? void 0 : this.updatePlayer) == null ? void 0 : _a.call(this, this.vmml);
751
761
  }
752
762
  /**
753
763
  * 删除 Clip
754
764
  * @param id - 实例 id
755
765
  * @param type - 实例 类型
756
766
  */
757
- deleteClip({ id, type, originClip }) {
767
+ deleteClip({ id, type, originClip, isUpdate = true }) {
768
+ var _a;
758
769
  if (originClip) {
759
770
  const [existClip] = this.findClip(id);
760
771
  existClip.duration = 0;
@@ -775,13 +786,15 @@ var VmmlConverter = class {
775
786
  }
776
787
  }
777
788
  }
789
+ if (isUpdate) (_a = this == null ? void 0 : this.updatePlayer) == null ? void 0 : _a.call(this, this.vmml);
778
790
  }
779
791
  changeVmml(newVmml) {
780
792
  this.vmml = newVmml;
781
793
  this.tracks = this.vmml.template.tracks;
782
794
  }
783
795
  //切换静音 视频/音频
784
- changeMute({ id, isMute }) {
796
+ changeMute({ id, isMute, isUpdate = true }) {
797
+ var _a;
785
798
  const editorTrack = this.tracks.find((track) => track.editorType === "\u8868\u60C5\u5305");
786
799
  const index = editorTrack.clips.findIndex((item) => item.id === id);
787
800
  if (index !== -1) {
@@ -791,6 +804,7 @@ var VmmlConverter = class {
791
804
  editorTrack.clips[index + 1].audioClip.volume = volume;
792
805
  }
793
806
  }
807
+ if (isUpdate) (_a = this == null ? void 0 : this.updatePlayer) == null ? void 0 : _a.call(this, this.vmml);
794
808
  }
795
809
  //加载clip数据
796
810
  loadClipData(fObj) {
@@ -1054,7 +1068,6 @@ var EditorCanvas = react.forwardRef(
1054
1068
  item.on("modified", () => {
1055
1069
  const fObj = convertToJSON(item);
1056
1070
  vmmlConverterRef.current.updateClip(fObj);
1057
- updateVmml(vmmlConverterRef.current.vmml);
1058
1071
  });
1059
1072
  item.set("visible", ns >= item.clipData.inPoint);
1060
1073
  canvas.add(item);
@@ -1284,7 +1297,6 @@ var EditorCanvas = react.forwardRef(
1284
1297
  const fObj = convertToJSON(img);
1285
1298
  fObj.src = "";
1286
1299
  vmmlConverterRef.current.updateClip(fObj);
1287
- updateVmml(vmmlConverterRef.current.vmml);
1288
1300
  });
1289
1301
  resolve(img);
1290
1302
  });
@@ -1314,7 +1326,7 @@ var EditorCanvas = react.forwardRef(
1314
1326
  });
1315
1327
  textObj.setCoords();
1316
1328
  const updatedFObj = convertToJSON(textObj);
1317
- vmmlConverterRef.current.updateClip(updatedFObj);
1329
+ vmmlConverterRef.current.updateClip(updatedFObj, false);
1318
1330
  });
1319
1331
  canvas.renderAll();
1320
1332
  updateVmml((_a = vmmlConverterRef.current) == null ? void 0 : _a.vmml);
@@ -1465,7 +1477,6 @@ var EditorCanvas = react.forwardRef(
1465
1477
  options.transform.target.isSelected = 0;
1466
1478
  });
1467
1479
  group.on("modified", () => {
1468
- var _a;
1469
1480
  const fObj = convertToJSON(group);
1470
1481
  if (fObj.clipData.isAiError) {
1471
1482
  fObj.clipData.textColor = "rgba(0, 0, 0, 0)";
@@ -1474,7 +1485,6 @@ var EditorCanvas = react.forwardRef(
1474
1485
  onBatchModify(fObj, canvas);
1475
1486
  } else {
1476
1487
  vmmlConverterRef.current.updateClip(fObj);
1477
- updateVmml((_a = vmmlConverterRef.current) == null ? void 0 : _a.vmml);
1478
1488
  }
1479
1489
  });
1480
1490
  resolve(group);
@@ -1548,10 +1558,8 @@ var EditorCanvas = react.forwardRef(
1548
1558
  options.transform.target.isSelected = 0;
1549
1559
  });
1550
1560
  group.on("modified", () => {
1551
- var _a;
1552
1561
  const fObj = convertToJSON(group);
1553
1562
  vmmlConverterRef.current.updateClip(fObj);
1554
- updateVmml((_a = vmmlConverterRef.current) == null ? void 0 : _a.vmml);
1555
1563
  });
1556
1564
  canvas.centerObject(group);
1557
1565
  canvas.add(group);
@@ -1564,7 +1572,7 @@ var EditorCanvas = react.forwardRef(
1564
1572
  });
1565
1573
  };
1566
1574
  const updateText = async ({ id, textContent, bgColor, textColor, strokeColor, letterSpacing, strokeWidth, textBasicInfo, fontAssetUrl, posParam = null, alignType }) => {
1567
- var _a, _b;
1575
+ var _a;
1568
1576
  const { width, height } = vmml.template.dimension;
1569
1577
  const fontSize = vmmlUtils.getFontSize(width, height);
1570
1578
  const target = fc.getObjects().find((item) => {
@@ -1630,7 +1638,6 @@ var EditorCanvas = react.forwardRef(
1630
1638
  target.setCoords();
1631
1639
  fc == null ? void 0 : fc.requestRenderAll();
1632
1640
  vmmlConverterRef.current.updateClip(convertToJSON(target));
1633
- updateVmml((_b = vmmlConverterRef.current) == null ? void 0 : _b.vmml);
1634
1641
  }
1635
1642
  };
1636
1643
  const changeObjectVisible = (id, visible = true) => {
@@ -1685,7 +1692,7 @@ var EditorCanvas = react.forwardRef(
1685
1692
  if (vmmlConverterRef.current) {
1686
1693
  vmmlConverterRef.current.changeVmml(vmml);
1687
1694
  } else {
1688
- vmmlConverterRef.current = new VmmlConverter_default({ vmml, canvasSize });
1695
+ vmmlConverterRef.current = new VmmlConverter_default({ vmml, canvasSize, updatePlayer: updateVmml });
1689
1696
  }
1690
1697
  }
1691
1698
  }, [canvasSize, vmml]);
@@ -2665,6 +2672,7 @@ var EditorFn = ({
2665
2672
  if (current && !checkVideoNum()) {
2666
2673
  const fObj = await current.createImage(file, emojiId);
2667
2674
  vmmlConverterRef.current.addVideoClip(fObj);
2675
+ updateVmml(vmmlConverterRef.current.vmml);
2668
2676
  setMenuState("");
2669
2677
  setPreviewState(true);
2670
2678
  }
@@ -2784,7 +2792,7 @@ var EditorFn = ({
2784
2792
  react.useEffect(() => {
2785
2793
  if (canvasSize.width && canvasSize.height && vmmlState) {
2786
2794
  if (!vmmlConverterRef.current) {
2787
- vmmlConverterRef.current = new VmmlConverter_default({ vmml: vmmlState, canvasSize });
2795
+ vmmlConverterRef.current = new VmmlConverter_default({ vmml: vmmlState, canvasSize, updatePlayer: updateVmml });
2788
2796
  } else {
2789
2797
  vmmlConverterRef.current.vmml = vmmlState;
2790
2798
  }