@versa_ai/vmml-editor 1.0.39 → 1.0.41

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.39 build D:\code\work\vmml-player\packages\editor
2
+ > @versa_ai/vmml-editor@1.0.41 build D:\code\work\vmml-player\packages\editor
3
3
  > tsup
4
4
 
5
5
  CLI Building entry: src/index.tsx
@@ -9,7 +9,6 @@
9
9
  CLI Target: node16
10
10
  CJS Build start
11
11
  ESM Build start
12
- DTS Build start
13
12
 
14
13
   WARN  ▲ [WARNING] Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.
15
14
 
@@ -67,6 +66,7 @@ More info and automated migrator: https://sass-lang.com/d/slash-div [35
67
66
 
68
67
 
69
68
 
69
+ DTS Build start
70
70
 
71
71
   WARN  ▲ [WARNING] Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.
72
72
 
@@ -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 122.27 KB
128
- CJS dist\index.js.map 233.66 KB
129
- CJS ⚡️ Build success in 839ms
130
- ESM dist\index.mjs 120.58 KB
131
- ESM dist\index.mjs.map 233.36 KB
132
- ESM ⚡️ Build success in 839ms
133
- DTS ⚡️ Build success in 2050ms
127
+ CJS dist\index.js 122.59 KB
128
+ CJS dist\index.js.map 234.64 KB
129
+ CJS ⚡️ Build success in 868ms
130
+ ESM dist\index.mjs 120.90 KB
131
+ ESM dist\index.mjs.map 234.34 KB
132
+ ESM ⚡️ Build success in 868ms
133
+ DTS ⚡️ Build success in 1828ms
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
@@ -617,6 +617,20 @@ var VmmlConverter = class {
617
617
  rotationY: _rotationY
618
618
  };
619
619
  }
620
+ findClip(id) {
621
+ const tracks = this.vmml.template.tracks || [];
622
+ const isString = typeof id === "string";
623
+ const ids = isString ? [id] : id;
624
+ const list = [];
625
+ tracks.forEach((track) => {
626
+ track.clips.forEach((clip) => {
627
+ if (ids == null ? void 0 : ids.includes(clip.id)) {
628
+ list.push(clip);
629
+ }
630
+ });
631
+ });
632
+ return list;
633
+ }
620
634
  /**
621
635
  * 转换 TextClip
622
636
  * @param fObj - 画布fObj
@@ -709,19 +723,12 @@ var VmmlConverter = class {
709
723
  * @param fObj - 画布fObj
710
724
  */
711
725
  updateClip(fObj) {
712
- console.log("updateClip fObj", fObj);
726
+ console.log("updateClip fObj", fObj, this.tracks);
713
727
  const posParam = this.setPosParam(fObj);
714
728
  const {
715
- // clipData: { id, type, lineSpacing },
716
729
  clipData: { id, type, lineSpacing, originClip }
717
730
  } = fObj;
718
- let existClip = null;
719
- if (originClip) {
720
- existClip = originClip;
721
- } else {
722
- const editorTrack = this.tracks.find((track) => track.editorType === type);
723
- existClip = ((editorTrack == null ? void 0 : editorTrack.clips) || []).find((clip) => clip.id === id);
724
- }
731
+ const [existClip] = this.findClip(id);
725
732
  if (existClip) {
726
733
  !originClip && (existClip.fObj = fObj);
727
734
  if (type === "\u8868\u60C5\u5305") {
@@ -742,7 +749,6 @@ var VmmlConverter = class {
742
749
  };
743
750
  }
744
751
  }
745
- console.log("updateClip \u6700\u7EC8vmml", this.vmml);
746
752
  }
747
753
  /**
748
754
  * 删除 Clip
@@ -751,7 +757,13 @@ var VmmlConverter = class {
751
757
  */
752
758
  deleteClip({ id, type, originClip }) {
753
759
  if (originClip) {
754
- originClip.duration = 0;
760
+ for (const track of this.tracks) {
761
+ const clip = (track.clips || []).find((c) => c.id === originClip.id);
762
+ if (clip) {
763
+ clip.duration = 0;
764
+ break;
765
+ }
766
+ }
755
767
  } else {
756
768
  const editorTrack = this.tracks.find((track) => track.editorType === type);
757
769
  const index = editorTrack.clips.findIndex((item) => item.id === id);
@@ -769,7 +781,9 @@ var VmmlConverter = class {
769
781
  }
770
782
  }
771
783
  }
772
- console.log("deleteClip \u6700\u7EC8Vmml", this.vmml);
784
+ }
785
+ changeVmml(newVmml) {
786
+ this.vmml = newVmml;
773
787
  }
774
788
  //切换静音 视频/音频
775
789
  changeMute({ id, isMute }) {
@@ -1056,13 +1070,12 @@ var EditorCanvas = react.forwardRef(
1056
1070
  if (fc) {
1057
1071
  const ns = Math.floor((f ?? frame) / 30 * 1e6);
1058
1072
  const objects = fc.getObjects();
1059
- console.log(objects, "fc>>>>>>>>>>>>>>>>", frame);
1060
1073
  objects.forEach((item) => {
1061
1074
  var _a, _b, _c;
1062
1075
  if (((_a = item == null ? void 0 : item.clipData) == null ? void 0 : _a.type) === "\u6587\u5B57") {
1063
- item.set("visible", ns >= item.clipData.inPoint && ns < item.clipData.inPoint + (item.clipData.duration || vmml.template.duration));
1076
+ item.set("visible", item.clipData.duration > 0 && ns >= item.clipData.inPoint && ns < item.clipData.inPoint + (item.clipData.duration || vmml.template.duration));
1064
1077
  } else {
1065
- item.set("visible", ns >= item.clipData.inPoint && ns < item.clipData.inPoint + ((_c = (_b = item.clipData) == null ? void 0 : _b.fileUrl) == null ? void 0 : _c.duration));
1078
+ item.set("visible", item.clipData.duration > 0 && ns >= item.clipData.inPoint && ns < item.clipData.inPoint + ((_c = (_b = item.clipData) == null ? void 0 : _b.fileUrl) == null ? void 0 : _c.duration));
1066
1079
  }
1067
1080
  });
1068
1081
  fc.discardActiveObject();
@@ -1338,7 +1351,7 @@ var EditorCanvas = react.forwardRef(
1338
1351
  await document.fonts.ready;
1339
1352
  }
1340
1353
  }
1341
- const lines = textContent.split("\n");
1354
+ const lines = textContent.split("\n").filter((item) => item);
1342
1355
  const lineHeight = 22 + strokeW;
1343
1356
  const textHeight = lines.length * lineHeight;
1344
1357
  const groupWidth = Math.max(...lines.map((l) => {
@@ -1762,8 +1775,12 @@ var EditorCanvas = react.forwardRef(
1762
1775
  }
1763
1776
  }, [fc, dragState]);
1764
1777
  react.useEffect(() => {
1765
- if (canvasSize.width && canvasSize.height && !vmmlConverterRef.current) {
1766
- vmmlConverterRef.current = new VmmlConverter_default({ vmml, canvasSize });
1778
+ if (canvasSize.width && canvasSize.height) {
1779
+ if (vmmlConverterRef.current) {
1780
+ vmmlConverterRef.current.changeVmml(vmml);
1781
+ } else {
1782
+ vmmlConverterRef.current = new VmmlConverter_default({ vmml, canvasSize });
1783
+ }
1767
1784
  }
1768
1785
  }, [canvasSize, vmml]);
1769
1786
  react.useEffect(() => {