@versa_ai/vmml-editor 1.0.16 → 1.0.18

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.16 build D:\code\work\vmml-player\packages\editor
2
+ > @versa_ai/vmml-editor@1.0.18 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
- ESM dist\index.mjs 111.04 KB
128
- ESM dist\index.mjs.map 213.31 KB
129
- ESM ⚡️ Build success in 1139ms
130
- CJS dist\index.js 112.66 KB
131
- CJS dist\index.js.map 213.61 KB
132
- CJS ⚡️ Build success in 1141ms
133
- DTS ⚡️ Build success in 2678ms
127
+ CJS dist\index.js 113.85 KB
128
+ CJS dist\index.js.map 215.74 KB
129
+ CJS ⚡️ Build success in 812ms
130
+ ESM dist\index.mjs 112.22 KB
131
+ ESM dist\index.mjs.map 215.45 KB
132
+ ESM ⚡️ Build success in 813ms
133
+ DTS ⚡️ Build success in 2001ms
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
@@ -577,8 +577,9 @@ var VmmlConverter = class {
577
577
  }
578
578
  //更新位置
579
579
  setPosParam(fObj) {
580
+ var _a, _b, _c, _d, _e, _f, _g, _h;
580
581
  const {
581
- clipData: { type },
582
+ clipData: { type, originClip },
582
583
  centerPoint,
583
584
  scaleX,
584
585
  scaleY,
@@ -586,24 +587,35 @@ var VmmlConverter = class {
586
587
  width,
587
588
  height
588
589
  } = fObj;
589
- let _scaleX, _scaleY, _centerX, _centerY;
590
+ let _scaleX, _scaleY, _centerX, _centerY, _scaleZ, _centerZ, _rotationX, _rotationY;
591
+ let key = "";
590
592
  if (type === "\u6587\u5B57") {
591
593
  _scaleX = 22 * scaleX * this.widthScale / this.fontSize;
592
594
  _scaleY = 22 * scaleY * this.heightScale / this.fontSize;
593
595
  _centerX = centerPoint.x / this.canvasSize.width;
594
596
  _centerY = centerPoint.y / this.canvasSize.height;
597
+ key = "textClip";
595
598
  } else if (type === "\u8868\u60C5\u5305") {
596
599
  _scaleX = width * scaleX * this.widthScale / width;
597
600
  _scaleY = height * scaleY * this.heightScale / height;
598
601
  _centerX = centerPoint.x / this.canvasSize.width;
599
602
  _centerY = centerPoint.y / this.canvasSize.height;
603
+ key = "videoClip";
600
604
  }
605
+ _scaleZ = ((_b = (_a = originClip == null ? void 0 : originClip[key]) == null ? void 0 : _a.posParam) == null ? void 0 : _b.scaleZ) ?? 1;
606
+ _centerZ = ((_d = (_c = originClip == null ? void 0 : originClip[key]) == null ? void 0 : _c.posParam) == null ? void 0 : _d.centerZ) ?? 0.5;
607
+ _rotationX = ((_f = (_e = originClip == null ? void 0 : originClip[key]) == null ? void 0 : _e.posParam) == null ? void 0 : _f.rotationX) ?? 0;
608
+ _rotationY = ((_h = (_g = originClip == null ? void 0 : originClip[key]) == null ? void 0 : _g.posParam) == null ? void 0 : _h.rotationY) ?? 0;
601
609
  return {
602
610
  scaleX: _scaleX,
603
611
  scaleY: _scaleY,
612
+ scaleZ: _scaleZ,
604
613
  centerX: _centerX,
605
614
  centerY: _centerY,
606
- rotationZ: angle
615
+ centerZ: _centerZ,
616
+ rotationZ: angle,
617
+ rotationX: _rotationX,
618
+ rotationY: _rotationY
607
619
  };
608
620
  }
609
621
  /**
@@ -1197,15 +1209,6 @@ var EditorCanvas = react.forwardRef(
1197
1209
  }
1198
1210
  };
1199
1211
  const createEditObjes = async (canvas, time) => {
1200
- const allObjects = canvas.getObjects();
1201
- const toRemove = [];
1202
- allObjects.forEach((obj) => {
1203
- var _a;
1204
- if ((_a = obj == null ? void 0 : obj.clipData) == null ? void 0 : _a.originClip) {
1205
- toRemove.push(obj);
1206
- }
1207
- });
1208
- toRemove.forEach((obj) => canvas.remove(obj));
1209
1212
  const promises = editClips.map((clip) => {
1210
1213
  if (clip.videoClip) {
1211
1214
  return createImageFromClip(clip);
@@ -1317,12 +1320,14 @@ var EditorCanvas = react.forwardRef(
1317
1320
  }
1318
1321
  const { width, height } = vmml.template.dimension;
1319
1322
  const fontSize = vmmlUtils.getFontSize(width, height);
1320
- const { textContent, backgroundColor, textColor, posParam, fontAssetUrl, alignType } = clip.textClip;
1323
+ const { textContent, backgroundColor, textColor, posParam, fontAssetUrl, alignType, strokeColor, strokeWidth } = clip.textClip;
1321
1324
  const scaleX = posParam.scaleX * fontSize / 22 / widthScaleRef.current;
1322
1325
  const scaleY = posParam.scaleY * fontSize / 22 / heightScaleRef.current;
1326
+ const strokeW = strokeWidth ? strokeWidth * 22 / fontSize : 0;
1323
1327
  const left = canvasSize.width * posParam.centerX;
1324
1328
  const top = canvasSize.height * posParam.centerY;
1325
1329
  const bgColor = backgroundColor ? vmmlUtils.argbToRgba(backgroundColor) : "transparent";
1330
+ const stColor = strokeColor ? vmmlUtils.argbToRgba(strokeColor) : "transparent";
1326
1331
  const isAiError = textContent === "\u8BF7\u8F93\u5165\u6587\u6848" && textColor === "#00000000";
1327
1332
  const textFill = vmmlUtils.argbToRgba(isAiError ? "#ffffffff" : textColor || "#ffffffff");
1328
1333
  const textBasicInfo = {
@@ -1331,7 +1336,7 @@ var EditorCanvas = react.forwardRef(
1331
1336
  colorName: "custom",
1332
1337
  textAlign: alignType === 1 ? "center" : alignType === 2 ? "right" : "left"
1333
1338
  };
1334
- const textImgData = await createTextImg({ textContent, bgColor, textColor: textFill, fontAssetUrl, textBasicInfo });
1339
+ const textImgData = await createTextImg({ textContent, bgColor, stColor, strokeW, textColor: textFill, fontAssetUrl, textBasicInfo });
1335
1340
  const fontJSON = localStorage.getItem("VMML_PLAYER_FONTSMAP");
1336
1341
  let fontMap = {};
1337
1342
  try {
@@ -1419,7 +1424,7 @@ var EditorCanvas = react.forwardRef(
1419
1424
  }
1420
1425
  return svgString;
1421
1426
  };
1422
- const createTextImg = async ({ textContent, bgColor, textColor, fontAssetUrl = null, textBasicInfo }) => {
1427
+ const createTextImg = async ({ textContent, bgColor, textColor, stColor, strokeW, fontAssetUrl = null, textBasicInfo }) => {
1423
1428
  const container = document.createElement("div");
1424
1429
  container.style.backgroundColor = bgColor;
1425
1430
  container.style.boxSizing = "content-box";
@@ -1435,6 +1440,9 @@ var EditorCanvas = react.forwardRef(
1435
1440
  p.style.fontFamily = fontFamily;
1436
1441
  p.style.whiteSpace = "nowrap";
1437
1442
  p.style.padding = "0";
1443
+ p.style.margin = "0";
1444
+ p.style.webkitTextStrokeWidth = `${strokeW ?? 0}px`;
1445
+ p.style.webkitTextStrokeColor = stColor;
1438
1446
  p.textContent = line || " ";
1439
1447
  container.appendChild(p);
1440
1448
  });
@@ -1581,6 +1589,9 @@ var EditorCanvas = react.forwardRef(
1581
1589
  }
1582
1590
  }
1583
1591
  }, [fc]);
1592
+ const getCanvasCtx = () => {
1593
+ return fc;
1594
+ };
1584
1595
  react.useImperativeHandle(ref, () => ({
1585
1596
  createImage,
1586
1597
  createText,
@@ -1594,8 +1605,9 @@ var EditorCanvas = react.forwardRef(
1594
1605
  checkObjectInPoint,
1595
1606
  createImageFromClip,
1596
1607
  createTextFromClip,
1597
- changeObjectVisible
1598
- }));
1608
+ changeObjectVisible,
1609
+ getCanvasCtx
1610
+ }), [fc]);
1599
1611
  const getActions = () => {
1600
1612
  if (history) {
1601
1613
  return history.getActionType();
@@ -2419,10 +2431,12 @@ var EditorFn = ({
2419
2431
  const onPlayerReady = () => {
2420
2432
  const { current } = vmmlPlayerRef;
2421
2433
  vmmlFlag.current = false;
2434
+ let show = false;
2422
2435
  if (current && current.playerRef) {
2423
2436
  setPlayer(current.playerRef);
2424
2437
  current.unmute();
2425
2438
  if (!once.current) {
2439
+ show = true;
2426
2440
  once.current = true;
2427
2441
  } else {
2428
2442
  if (needPlay.current) {
@@ -2432,7 +2446,7 @@ var EditorFn = ({
2432
2446
  }
2433
2447
  }
2434
2448
  }
2435
- setShowCanvas(false);
2449
+ setShowCanvas(show);
2436
2450
  setLoading(false);
2437
2451
  };
2438
2452
  const onClickMain = () => {
@@ -2573,9 +2587,11 @@ var EditorFn = ({
2573
2587
  setFrame(e.detail.frame);
2574
2588
  };
2575
2589
  const onPlay = () => {
2590
+ setShowCanvas(false);
2576
2591
  setIsPlaying(true);
2577
2592
  };
2578
2593
  const onPause = () => {
2594
+ setShowCanvas(true);
2579
2595
  setIsPlaying(false);
2580
2596
  };
2581
2597
  const onWaiting = () => {
@@ -2713,13 +2729,14 @@ var EditorFn = ({
2713
2729
  }
2714
2730
  }, [dragState]);
2715
2731
  const updateVmml = (v) => {
2716
- var _a2;
2732
+ var _a2, _b, _c;
2717
2733
  const { current: playerCurrent } = vmmlPlayerRef;
2718
2734
  const { current: canvasCurrent } = canvasRef;
2719
2735
  if (!playerCurrent) return;
2736
+ (_b = (_a2 = canvasCurrent == null ? void 0 : canvasCurrent.getCanvasCtx()) == null ? void 0 : _a2.clear) == null ? void 0 : _b.call(_a2);
2720
2737
  const convertedVmml = vmmlUtils.convertVmmlTextScaleByForbidden(v);
2721
2738
  setVmmlState(convertedVmml);
2722
- setDurationInFrames(vmmlUtils.getFrames(((_a2 = v == null ? void 0 : v.template) == null ? void 0 : _a2.duration) || 1, fps));
2739
+ setDurationInFrames(vmmlUtils.getFrames(((_c = v == null ? void 0 : v.template) == null ? void 0 : _c.duration) || 1, fps));
2723
2740
  playerCurrent.setVmml(convertedVmml, pauseFrame);
2724
2741
  setRefreshEdit(Date.now());
2725
2742
  if (canvasCurrent) {