@versa_ai/vmml-editor 1.0.6 → 1.0.8

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.6 build D:\code\work\vmml-player\packages\editor
2
+ > @versa_ai/vmml-editor@1.0.8 build D:\code\work\vmml-player\packages\editor
3
3
  > tsup
4
4
 
5
5
  CLI Building entry: src/index.tsx
@@ -204,12 +204,12 @@ More info and automated migrator: https://sass-lang.com/d/slash-div [35
204
204
 
205
205
 
206
206
 
207
- ESM dist\index.mjs 102.35 KB
208
- ESM dist\index.mjs.map 197.47 KB
209
- ESM ⚡️ Build success in 788ms
210
- CJS dist\index.js 103.89 KB
211
- CJS dist\index.js.map 197.75 KB
212
- CJS ⚡️ Build success in 788ms
213
- DTS ⚡️ Build success in 2270ms
207
+ CJS dist\index.js 103.79 KB
208
+ CJS dist\index.js.map 197.83 KB
209
+ CJS ⚡️ Build success in 816ms
210
+ ESM dist\index.mjs 102.26 KB
211
+ ESM dist\index.mjs.map 197.55 KB
212
+ ESM ⚡️ Build success in 817ms
213
+ DTS ⚡️ Build success in 1972ms
214
214
  DTS dist\index.d.ts 158.00 B
215
215
  DTS dist\index.d.mts 158.00 B
package/dist/index.js CHANGED
@@ -297,7 +297,7 @@ var SeekBar = ({ player, vmmlRef, frame, durationInFrames, intoEdit, setDragStat
297
297
  if (e.button !== 0) {
298
298
  return;
299
299
  }
300
- const { left, width } = (_a = containerRef.current) == null ? undefined : _a.getBoundingClientRect();
300
+ const { left, width } = (_a = containerRef.current) == null ? void 0 : _a.getBoundingClientRect();
301
301
  const _frame = getFrameFromX(
302
302
  e.clientX - left,
303
303
  durationInFrames,
@@ -317,7 +317,7 @@ var SeekBar = ({ player, vmmlRef, frame, durationInFrames, intoEdit, setDragStat
317
317
  if (!dragging.dragging) {
318
318
  return;
319
319
  }
320
- const { left, width } = (_a = containerRef.current) == null ? undefined : _a.getBoundingClientRect();
320
+ const { left, width } = (_a = containerRef.current) == null ? void 0 : _a.getBoundingClientRect();
321
321
  const _frame = getFrameFromX(
322
322
  e.clientX - left,
323
323
  durationInFrames,
@@ -396,7 +396,6 @@ var HistoryClass = class {
396
396
  editorInstance;
397
397
  actionTypeList;
398
398
  constructor(canvas) {
399
- console.log("history init");
400
399
  this.canvas = canvas;
401
400
  this.historyUndo = [];
402
401
  this.historyRedo = [];
@@ -655,7 +654,7 @@ var VmmlConverter = class {
655
654
  existClip = originClip;
656
655
  } else {
657
656
  const editorTrack = this.tracks.find((track) => track.editorType === type);
658
- existClip = ((editorTrack == null ? undefined : editorTrack.clips) || []).find((clip) => clip.id === id);
657
+ existClip = ((editorTrack == null ? void 0 : editorTrack.clips) || []).find((clip) => clip.id === id);
659
658
  }
660
659
  if (existClip) {
661
660
  !originClip && (existClip.fObj = fObj);
@@ -794,11 +793,11 @@ var VmmlConverter = class {
794
793
  };
795
794
  var VmmlConverter_default = VmmlConverter;
796
795
  function drawImg(ctx, left, top, img, wSize, hSize, angle) {
797
- if (angle === undefined) return;
796
+ if (angle === void 0) return;
798
797
  ctx.save();
799
798
  ctx.translate(left, top);
800
799
  ctx.rotate(fabric.fabric.util.degreesToRadians(angle));
801
- ctx.drawImage(img, -28 / 2, -28 / 2, wSize, hSize);
800
+ ctx.drawImage(img, -wSize / 2, -hSize / 2, wSize, hSize);
802
801
  ctx.restore();
803
802
  }
804
803
  function usePeekControl(canvas) {
@@ -839,7 +838,7 @@ function usePeekControl(canvas) {
839
838
  const renderMuteIcon = (ctx, left, top, styleOverride, fabricObject) => {
840
839
  if (!fabricObject.clipData) return false;
841
840
  if (fabricObject.clipData.type === "\u8868\u60C5\u5305") {
842
- if (fabricObject.clipData.isMute === null || fabricObject.clipData.isMute === undefined) return false;
841
+ if (fabricObject.clipData.isMute === null || fabricObject.clipData.isMute === void 0) return false;
843
842
  if (fabricObject.clipData.isMute) {
844
843
  drawImg(ctx, left, top, muteImg, 28, 28, fabricObject.angle);
845
844
  } else {
@@ -982,10 +981,10 @@ var EditorCanvas = react.forwardRef(
982
981
  const objects = fc.getObjects();
983
982
  objects.forEach((item) => {
984
983
  var _a, _b, _c;
985
- if (((_a = item == null ? undefined : item.clipData) == null ? undefined : _a.type) === "\u6587\u5B57") {
984
+ if (((_a = item == null ? void 0 : item.clipData) == null ? void 0 : _a.type) === "\u6587\u5B57") {
986
985
  item.set("visible", ns >= item.clipData.inPoint && ns < item.clipData.inPoint + (item.clipData.duration || vmml.template.duration));
987
986
  } else {
988
- item.set("visible", ns >= item.clipData.inPoint && ns < item.clipData.inPoint + ((_c = (_b = item.clipData) == null ? undefined : _b.fileUrl) == null ? undefined : _c.duration));
987
+ 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));
989
988
  }
990
989
  });
991
990
  fc.discardActiveObject();
@@ -1119,7 +1118,7 @@ var EditorCanvas = react.forwardRef(
1119
1118
  if (canvas) {
1120
1119
  const imgs = canvas.getObjects().filter((item) => {
1121
1120
  var _a;
1122
- return ((_a = item == null ? undefined : item.clipData) == null ? undefined : _a.type) === "\u8868\u60C5\u5305";
1121
+ return ((_a = item == null ? void 0 : item.clipData) == null ? void 0 : _a.type) === "\u8868\u60C5\u5305";
1123
1122
  });
1124
1123
  const target = imgs.find((item) => item.clipData.id === id);
1125
1124
  if (target) {
@@ -1129,7 +1128,7 @@ var EditorCanvas = react.forwardRef(
1129
1128
  });
1130
1129
  }
1131
1130
  } else {
1132
- waitFcTasks.current.push(updateImage.bind(undefined, id, base64));
1131
+ waitFcTasks.current.push(updateImage.bind(void 0, id, base64));
1133
1132
  }
1134
1133
  };
1135
1134
  const createImageFromClip = (clip, fc2) => {
@@ -1176,7 +1175,7 @@ var EditorCanvas = react.forwardRef(
1176
1175
  });
1177
1176
  });
1178
1177
  } else {
1179
- waitFcTasks.current.push(createImageFromClip.bind(undefined, clip));
1178
+ waitFcTasks.current.push(createImageFromClip.bind(void 0, clip));
1180
1179
  }
1181
1180
  };
1182
1181
  const handleRedo = () => {
@@ -1256,7 +1255,7 @@ var EditorCanvas = react.forwardRef(
1256
1255
  canvas.add(imgData).renderAll();
1257
1256
  });
1258
1257
  } else {
1259
- waitFcTasks.current.push(createTextFromClip.bind(undefined, clip));
1258
+ waitFcTasks.current.push(createTextFromClip.bind(void 0, clip));
1260
1259
  }
1261
1260
  };
1262
1261
  const embedFontInSVG = async (svgString, url) => {
@@ -1295,7 +1294,7 @@ var EditorCanvas = react.forwardRef(
1295
1294
  container.style.padding = "6.5px 7px 6.5px 7px";
1296
1295
  container.style.borderRadius = "5px";
1297
1296
  document.body.appendChild(container);
1298
- const { width, height } = container == null ? undefined : container.getBoundingClientRect();
1297
+ const { width, height } = container == null ? void 0 : container.getBoundingClientRect();
1299
1298
  const dataurl = await domToImage.toSvg(container);
1300
1299
  document.body.removeChild(container);
1301
1300
  const base64Image = await embedFontInSVG(dataurl, fontAssetUrl);
@@ -1718,14 +1717,14 @@ var stopMove = () => {
1718
1717
  const currentTouchPositionY = e.touches[0].clientY;
1719
1718
  const deltaX = currentTouchPositionX - lastTouchPositionX;
1720
1719
  const deltaY = currentTouchPositionY - lastTouchPositionY;
1721
- if (["text-header", "overlay", "text_bg_change"].includes((_a = e.target) == null ? undefined : _a.className)) {
1720
+ if (["text-header", "overlay", "text_bg_change"].includes((_a = e.target) == null ? void 0 : _a.className)) {
1722
1721
  e.preventDefault();
1723
1722
  }
1724
1723
  if (element) {
1725
1724
  const willOverflow = element.scrollHeight > element.clientHeight;
1726
1725
  if (willOverflow) {
1727
1726
  return;
1728
- } else if (((_b = e.target) == null ? undefined : _b.className.split(" ").includes("color-item")) || ((_c = e.target) == null ? undefined : _c.className) === "text_color_change") {
1727
+ } else if (((_b = e.target) == null ? void 0 : _b.className.split(" ").includes("color-item")) || ((_c = e.target) == null ? void 0 : _c.className) === "text_color_change") {
1729
1728
  if (deltaX < 0 || deltaX > 0) {
1730
1729
  return;
1731
1730
  } else {
@@ -1904,7 +1903,7 @@ var ColorSelector_default = ColorSelector;
1904
1903
  var formatText = (text, maxLengthBase = 40) => {
1905
1904
  var _a;
1906
1905
  const newlineRegex = /(\r\n|\r|\n)/g;
1907
- const matches = ((_a = text.match(newlineRegex)) == null ? undefined : _a.length) || 0;
1906
+ const matches = ((_a = text.match(newlineRegex)) == null ? void 0 : _a.length) || 0;
1908
1907
  const maxLength = maxLengthBase + matches;
1909
1908
  let trimmedText = text.substring(0, maxLength);
1910
1909
  if (text.length - matches === maxLengthBase) {
@@ -2230,7 +2229,7 @@ var EditorFn = ({
2230
2229
  const [isPlaying, setIsPlaying] = react.useState(false);
2231
2230
  const [showCanvas, setShowCanvas] = react.useState(false);
2232
2231
  const [filterIds, setFilterIds] = react.useState([]);
2233
- const [durationInFrames, setDurationInFrames] = react.useState(vmmlUtils.getFrames(((_a = vmml == null ? undefined : vmml.template) == null ? undefined : _a.duration) || 1, fps));
2232
+ const [durationInFrames, setDurationInFrames] = react.useState(vmmlUtils.getFrames(((_a = vmml == null ? void 0 : vmml.template) == null ? void 0 : _a.duration) || 1, fps));
2234
2233
  const [previewState, setPreviewState] = react.useState(true);
2235
2234
  const [menuState, setMenuState] = react.useState("");
2236
2235
  const [canvasSize, setCanvasSize] = react.useState({ width: 0, height: 0, top: 0 });
@@ -2506,8 +2505,8 @@ var EditorFn = ({
2506
2505
  if (player) {
2507
2506
  const parent = player.getContainerNode();
2508
2507
  if (!canvasSize.width) {
2509
- const playerElement = parent == null ? undefined : parent.children[0];
2510
- const { width, height } = (playerElement == null ? undefined : playerElement.getBoundingClientRect()) || {};
2508
+ const playerElement = parent == null ? void 0 : parent.children[0];
2509
+ const { width, height } = (playerElement == null ? void 0 : playerElement.getBoundingClientRect()) || {};
2511
2510
  setCanvasSize({ width, height, top: playerElement.offsetTop });
2512
2511
  }
2513
2512
  player.addEventListener("play", onPlay);