@versa_ai/vmml-editor 1.0.51 → 1.0.53

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.51 build D:\code\work\vmml-player\packages\editor
2
+ > @versa_ai/vmml-editor@1.0.53 build D:\code\work\vmml-player\packages\editor
3
3
  > tsup
4
4
 
5
5
  CLI Building entry: src/index.tsx
@@ -17,7 +17,6 @@ Recommendation: math.div($px, 750) or calc($px / 750)
17
17
  More info and automated migrator: https://sass-lang.com/d/slash-div [plugin sass-plugin]
18
18
 
19
19
  src/assets/css/colorSelector.scss:4:9:
20
- DTS Build start
21
20
   4 │ $px / 750
22
21
  ╵ ^
23
22
 
@@ -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 121.84 KB
128
- CJS dist\index.js.map 233.86 KB
129
- CJS ⚡️ Build success in 997ms
130
- ESM dist\index.mjs 119.97 KB
131
- ESM dist\index.mjs.map 233.56 KB
132
- ESM ⚡️ Build success in 998ms
133
- DTS ⚡️ Build success in 2081ms
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
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
@@ -681,6 +681,7 @@ var VmmlConverter = class {
681
681
  } else {
682
682
  editorTrack.clips.push(tClipData);
683
683
  }
684
+ this.updateVmml(this.vmml);
684
685
  }
685
686
  /**
686
687
  * 转换 VideoClip
@@ -748,29 +749,6 @@ var VmmlConverter = class {
748
749
  }
749
750
  }
750
751
  }
751
- updateTextClip(fObj, duration) {
752
- const posParam = this.setPosParam(fObj);
753
- const {
754
- clipData: { id }
755
- } = fObj;
756
- const [existClip] = this.findClip(id);
757
- if (existClip) {
758
- const { clipData: { text, textColor, bgColor } } = fObj;
759
- const scale = this.fontSize / 22;
760
- existClip.duration = duration;
761
- existClip.textClip = {
762
- ...existClip.textClip,
763
- posParam,
764
- backgroundColor: this.toARGB(bgColor),
765
- textContent: text,
766
- textColor: this.toARGB(textColor),
767
- dimension: {
768
- width: Math.floor(fObj.width * scale),
769
- height: Math.floor(fObj.height * scale)
770
- }
771
- };
772
- }
773
- }
774
752
  /**
775
753
  * 删除 Clip
776
754
  * @param id - 实例 id
@@ -1041,7 +1019,7 @@ function usePeekControl(canvas, hideConfig) {
1041
1019
  return canvas;
1042
1020
  }
1043
1021
  var EditorCanvas = react.forwardRef(
1044
- ({ previewState, showCanvas, canvasSize, enterPreview, intoTextEdit, frame, vmml, dragState, initFcObjs, editClips = [], onVideoChange, isBatchModify, hideConfig, textWarapCenter }, ref) => {
1022
+ ({ previewState, showCanvas, canvasSize, enterPreview, intoTextEdit, frame, vmml, dragState, initFcObjs, editClips = [], onVideoChange, isBatchModify, hideConfig, textWarapCenter, updateVmml }, ref) => {
1045
1023
  const [fc, setFc] = react.useState(null);
1046
1024
  const [history, setHistory] = react.useState(null);
1047
1025
  const [canvasReady, setCanvasReady] = react.useState(false);
@@ -1076,6 +1054,7 @@ var EditorCanvas = react.forwardRef(
1076
1054
  item.on("modified", () => {
1077
1055
  const fObj = convertToJSON(item);
1078
1056
  vmmlConverterRef.current.updateClip(fObj);
1057
+ updateVmml(vmmlConverterRef.current.vmml);
1079
1058
  });
1080
1059
  item.set("visible", ns >= item.clipData.inPoint);
1081
1060
  canvas.add(item);
@@ -1305,6 +1284,7 @@ var EditorCanvas = react.forwardRef(
1305
1284
  const fObj = convertToJSON(img);
1306
1285
  fObj.src = "";
1307
1286
  vmmlConverterRef.current.updateClip(fObj);
1287
+ updateVmml(vmmlConverterRef.current.vmml);
1308
1288
  });
1309
1289
  resolve(img);
1310
1290
  });
@@ -1317,7 +1297,7 @@ var EditorCanvas = react.forwardRef(
1317
1297
  history.undo();
1318
1298
  };
1319
1299
  const onBatchModify = (fObj, canvas) => {
1320
- var _a;
1300
+ var _a, _b;
1321
1301
  if (!canvas) return;
1322
1302
  const textObjects = canvas.getObjects().filter((item) => {
1323
1303
  var _a2;
@@ -1337,9 +1317,10 @@ var EditorCanvas = react.forwardRef(
1337
1317
  vmmlConverterRef.current.updateClip(updatedFObj);
1338
1318
  });
1339
1319
  canvas.renderAll();
1320
+ updateVmml((_a = vmmlConverterRef.current) == null ? void 0 : _a.vmml);
1340
1321
  const event = new CustomEvent("editor-vmml-batch-change", {
1341
1322
  detail: {
1342
- vmml: ((_a = vmmlConverterRef.current) == null ? void 0 : _a.vmml) ?? null
1323
+ vmml: ((_b = vmmlConverterRef.current) == null ? void 0 : _b.vmml) ?? null
1343
1324
  }
1344
1325
  });
1345
1326
  window.dispatchEvent(event);
@@ -1484,6 +1465,7 @@ var EditorCanvas = react.forwardRef(
1484
1465
  options.transform.target.isSelected = 0;
1485
1466
  });
1486
1467
  group.on("modified", () => {
1468
+ var _a;
1487
1469
  const fObj = convertToJSON(group);
1488
1470
  if (fObj.clipData.isAiError) {
1489
1471
  fObj.clipData.textColor = "rgba(0, 0, 0, 0)";
@@ -1492,6 +1474,7 @@ var EditorCanvas = react.forwardRef(
1492
1474
  onBatchModify(fObj, canvas);
1493
1475
  } else {
1494
1476
  vmmlConverterRef.current.updateClip(fObj);
1477
+ updateVmml((_a = vmmlConverterRef.current) == null ? void 0 : _a.vmml);
1495
1478
  }
1496
1479
  });
1497
1480
  resolve(group);
@@ -1565,8 +1548,10 @@ var EditorCanvas = react.forwardRef(
1565
1548
  options.transform.target.isSelected = 0;
1566
1549
  });
1567
1550
  group.on("modified", () => {
1551
+ var _a;
1568
1552
  const fObj = convertToJSON(group);
1569
1553
  vmmlConverterRef.current.updateClip(fObj);
1554
+ updateVmml((_a = vmmlConverterRef.current) == null ? void 0 : _a.vmml);
1570
1555
  });
1571
1556
  canvas.centerObject(group);
1572
1557
  canvas.add(group);
@@ -1579,7 +1564,7 @@ var EditorCanvas = react.forwardRef(
1579
1564
  });
1580
1565
  };
1581
1566
  const updateText = async ({ id, textContent, bgColor, textColor, strokeColor, letterSpacing, strokeWidth, textBasicInfo, fontAssetUrl, posParam = null, alignType }) => {
1582
- var _a;
1567
+ var _a, _b;
1583
1568
  const { width, height } = vmml.template.dimension;
1584
1569
  const fontSize = vmmlUtils.getFontSize(width, height);
1585
1570
  const target = fc.getObjects().find((item) => {
@@ -1645,6 +1630,7 @@ var EditorCanvas = react.forwardRef(
1645
1630
  target.setCoords();
1646
1631
  fc == null ? void 0 : fc.requestRenderAll();
1647
1632
  vmmlConverterRef.current.updateClip(convertToJSON(target));
1633
+ updateVmml((_b = vmmlConverterRef.current) == null ? void 0 : _b.vmml);
1648
1634
  }
1649
1635
  };
1650
1636
  const changeObjectVisible = (id, visible = true) => {
@@ -2604,14 +2590,11 @@ var EditorFn = ({
2604
2590
  }
2605
2591
  };
2606
2592
  const onControlsClick = () => {
2593
+ const { current } = vmmlPlayerRef;
2594
+ current.unmute();
2595
+ current.play();
2607
2596
  setPreviewState(true);
2608
- if (previewState) {
2609
- const { current } = vmmlPlayerRef;
2610
- current.unmute();
2611
- current.play();
2612
- } else {
2613
- setMenuState("");
2614
- }
2597
+ setMenuState("");
2615
2598
  };
2616
2599
  const onClickMenu = (type) => {
2617
2600
  if (type === "text" && checkTextNum()) return;
@@ -2794,11 +2777,10 @@ var EditorFn = ({
2794
2777
  }
2795
2778
  }, [menuState]);
2796
2779
  react.useEffect(() => {
2797
- if (previewState && !vmmlFlag.current) {
2798
- vmmlFlag.current = true;
2780
+ if (!vmmlFlag.current) {
2799
2781
  setVmml();
2800
2782
  }
2801
- }, [previewState]);
2783
+ }, []);
2802
2784
  react.useEffect(() => {
2803
2785
  if (canvasSize.width && canvasSize.height && vmmlState) {
2804
2786
  if (!vmmlConverterRef.current) {
@@ -2982,6 +2964,14 @@ var EditorFn = ({
2982
2964
  }
2983
2965
  return {};
2984
2966
  }, [loading]);
2967
+ const updateVmml = (vmml) => {
2968
+ var _a2, _b;
2969
+ const { current } = vmmlPlayerRef;
2970
+ if (!current) return;
2971
+ const playing = ((_b = (_a2 = current == null ? void 0 : current.playerRef) == null ? void 0 : _a2.isPlaying) == null ? void 0 : _b.call(_a2)) ?? false;
2972
+ if (!playing) needPlay.current = false;
2973
+ current.setVmml(vmml, frame, false);
2974
+ };
2985
2975
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2986
2976
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "editor", style: { height }, children: [
2987
2977
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "editor-vessel", onClick: () => {
@@ -3021,7 +3011,8 @@ var EditorFn = ({
3021
3011
  onVideoChange,
3022
3012
  isBatchModify,
3023
3013
  hideConfig,
3024
- textWarapCenter
3014
+ textWarapCenter,
3015
+ updateVmml
3025
3016
  }
3026
3017
  ),
3027
3018
  /* @__PURE__ */ jsxRuntime.jsx(Loading_default, { show: loading })