@versa_ai/vmml-editor 1.0.32 → 1.0.34

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.32 build D:\code\work\vmml-player\packages\editor
2
+ > @versa_ai/vmml-editor@1.0.34 build D:\code\work\vmml-player\packages\editor
3
3
  > tsup
4
4
 
5
5
  CLI Building entry: src/index.tsx
@@ -9,6 +9,7 @@
9
9
  CLI Target: node16
10
10
  CJS Build start
11
11
  ESM Build start
12
+ DTS Build start
12
13
 
13
14
   WARN  ▲ [WARNING] Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.
14
15
 
@@ -123,13 +124,12 @@ More info and automated migrator: https://sass-lang.com/d/slash-div [35
123
124
 
124
125
 
125
126
 
126
- CJS dist\index.js 115.87 KB
127
- CJS dist\index.js.map 221.07 KB
128
- CJS ⚡️ Build success in 906ms
129
- ESM dist\index.mjs 114.26 KB
130
- ESM dist\index.mjs.map 220.78 KB
131
- ESM ⚡️ Build success in 906ms
132
- DTS Build start
133
- DTS ⚡️ Build success in 1918ms
127
+ ESM dist\index.mjs 114.84 KB
128
+ ESM dist\index.mjs.map 222.06 KB
129
+ ESM ⚡️ Build success in 3042ms
130
+ CJS dist\index.js 116.45 KB
131
+ CJS dist\index.js.map 222.35 KB
132
+ CJS ⚡️ Build success in 3042ms
133
+ DTS ⚡️ Build success in 1673ms
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
@@ -1055,6 +1055,7 @@ var EditorCanvas = react.forwardRef(
1055
1055
  if (fc) {
1056
1056
  const ns = Math.floor((f ?? frame) / 30 * 1e6);
1057
1057
  const objects = fc.getObjects();
1058
+ console.log(objects, "checkObjectInPoint>>>objects>>>>>>>>>>>", ns, f, frame);
1058
1059
  objects.forEach((item) => {
1059
1060
  var _a, _b, _c;
1060
1061
  if (((_a = item == null ? void 0 : item.clipData) == null ? void 0 : _a.type) === "\u6587\u5B57") {
@@ -1441,6 +1442,25 @@ var EditorCanvas = react.forwardRef(
1441
1442
  return null;
1442
1443
  }
1443
1444
  };
1445
+ const setTextAlign = (p, stroke, direction) => {
1446
+ if (direction === "center") {
1447
+ p.style.justifyContent = "center";
1448
+ stroke.style.left = "50%";
1449
+ stroke.style.top = "50%";
1450
+ stroke.style.transform = "translate(-50%, -50%)";
1451
+ }
1452
+ if (direction === "left") {
1453
+ stroke.style.left = "0";
1454
+ stroke.style.top = "0";
1455
+ stroke.style.transform = "none";
1456
+ }
1457
+ if (direction === "right") {
1458
+ p.style.justifyContent = "flex-end";
1459
+ stroke.style.right = "0";
1460
+ stroke.style.top = "50%";
1461
+ stroke.style.transform = "translateY(-50%)";
1462
+ }
1463
+ };
1444
1464
  const createTextImg = async ({ textContent, bgColor, textColor, stColor, strokeW, fontAssetUrl = null, textBasicInfo, letterSpacing }) => {
1445
1465
  const fontBase64 = await loadFont(fontAssetUrl);
1446
1466
  const container = document.createElement("div");
@@ -1462,7 +1482,6 @@ var EditorCanvas = react.forwardRef(
1462
1482
  p.style.padding = "0";
1463
1483
  if (letterSpacing) p.style.letterSpacing = `${letterSpacing}px`;
1464
1484
  p.style.zIndex = "2";
1465
- if (textWarapCenter) p.style.justifyContent = "center";
1466
1485
  const fill = document.createElement("span");
1467
1486
  fill.textContent = line || " ";
1468
1487
  fill.style.color = textColor;
@@ -1474,15 +1493,9 @@ var EditorCanvas = react.forwardRef(
1474
1493
  stroke.style.color = "transparent";
1475
1494
  stroke.style.webkitTextStrokeWidth = `${strokeW}px`;
1476
1495
  stroke.style.webkitTextStrokeColor = stColor;
1477
- if (textWarapCenter) {
1478
- stroke.style.left = "50%";
1479
- stroke.style.top = "50%";
1480
- stroke.style.transform = "translate(-50%, -50%)";
1481
- } else {
1482
- stroke.style.left = "0";
1483
- stroke.style.top = "0";
1484
- }
1485
- stroke.style.zIndex = "-1";
1496
+ let dr = textBasicInfo.textAlign || "left";
1497
+ if (textWarapCenter) dr = "center";
1498
+ setTextAlign(p, stroke, dr);
1486
1499
  p.appendChild(fill);
1487
1500
  p.appendChild(stroke);
1488
1501
  container.appendChild(p);
@@ -2762,24 +2775,24 @@ var EditorFn = ({
2762
2775
  }
2763
2776
  }, [dragState]);
2764
2777
  const updateEditor = (v, checkFrame) => {
2765
- var _a2, _b, _c, _d;
2778
+ var _a2, _b, _c, _d, _e;
2766
2779
  const { current: playerCurrent } = vmmlPlayerRef;
2767
2780
  const { current: canvasCurrent } = canvasRef;
2768
2781
  if (!playerCurrent) return;
2769
- const isSame = JSON.stringify(v) === JSON.stringify(vmmlState);
2770
- console.log(v, vmmlState, isSame, "\u5224\u65ADvmml\u662F\u5426\u76F8\u540C");
2771
2782
  needPlay.current = false;
2772
2783
  once.current = false;
2773
2784
  const convertedVmml = vmmlUtils.convertVmmlTextScaleByForbidden(v);
2785
+ const isSame = JSON.stringify(convertedVmml) === JSON.stringify(vmmlState);
2786
+ const currentFrame = checkFrame ?? (((_a2 = player == null ? void 0 : player.getCurrentFrame) == null ? void 0 : _a2.call(player)) ?? frame ?? pauseFrame);
2787
+ setFrame(currentFrame);
2788
+ playerCurrent.setVmml(convertedVmml, currentFrame);
2774
2789
  if (!isSame) {
2775
- (_b = (_a2 = canvasCurrent == null ? void 0 : canvasCurrent.getCanvasCtx()) == null ? void 0 : _a2.clear) == null ? void 0 : _b.call(_a2);
2790
+ (_c = (_b = canvasCurrent == null ? void 0 : canvasCurrent.getCanvasCtx()) == null ? void 0 : _b.clear) == null ? void 0 : _c.call(_b);
2776
2791
  setVmmlState(convertedVmml);
2777
- setDurationInFrames(vmmlUtils.getFrames(((_c = v == null ? void 0 : v.template) == null ? void 0 : _c.duration) || 1, fps));
2778
- setRefreshEdit(Date.now());
2792
+ setDurationInFrames(vmmlUtils.getFrames(((_d = convertedVmml == null ? void 0 : convertedVmml.template) == null ? void 0 : _d.duration) || 1, fps));
2793
+ } else {
2794
+ (_e = canvasCurrent == null ? void 0 : canvasCurrent.checkObjectInPoint) == null ? void 0 : _e.call(canvasCurrent, currentFrame);
2779
2795
  }
2780
- const currentFrame = checkFrame ?? pauseFrame;
2781
- playerCurrent.setVmml(convertedVmml, currentFrame);
2782
- (_d = canvasCurrent == null ? void 0 : canvasCurrent.checkObjectInPoint) == null ? void 0 : _d.call(canvasCurrent, currentFrame);
2783
2796
  };
2784
2797
  const getCurrentFrame = () => {
2785
2798
  if (!player) return 0;
@@ -2788,6 +2801,7 @@ var EditorFn = ({
2788
2801
  const editorSeekTo = (frame2) => {
2789
2802
  var _a2;
2790
2803
  (_a2 = player == null ? void 0 : player.seekTo) == null ? void 0 : _a2.call(player, frame2 ?? 0);
2804
+ setFrame(frame2 ?? 0);
2791
2805
  const { current: canvasCurrent } = canvasRef;
2792
2806
  if (canvasCurrent) {
2793
2807
  canvasCurrent.checkObjectInPoint(frame2);