xvai-loi 0.1.62 → 0.1.64

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.
Files changed (3) hide show
  1. package/co.txt +1 -1
  2. package/package.json +1 -1
  3. package/xvai-loi.js +19 -8
package/co.txt CHANGED
@@ -1 +1 @@
1
- xvaiLoi111245
1
+ xvaiLoi111325
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xvai-loi",
3
- "version": "0.1.62",
3
+ "version": "0.1.64",
4
4
  "description": "Loi dung video (Edit Video Tu Dong) nap vao tool Google Flow qua o cam engine/oCam.ts",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
package/xvai-loi.js CHANGED
@@ -10765,11 +10765,17 @@ dangKy("cmAnh", (g, d, tuoi, W4, H2, _n, _s, dai2) => {
10765
10765
  wK2 = 0.76 * W4;
10766
10766
  yK = (c.y - hK * c.k / 2 + 0.575 * 112 / 1920 * c.k) * H2;
10767
10767
  } else {
10768
+ let rT = 64;
10769
+ for (let r = 0; r < 64 && rT === 64; r++) {
10770
+ let m = 0;
10771
+ for (let cc = 4; cc < 32; cc++) m += LA[r * 36 + cc];
10772
+ if (m >= 3) rT = r;
10773
+ }
10768
10774
  const ph = (y0) => {
10769
10775
  let n = 0, t = 0;
10770
10776
  for (let r = Math.floor(y0 * 64); r < Math.min(64, Math.ceil((y0 + hK) * 64)); r++) for (let cc = 4; cc < 32; cc++) {
10771
10777
  t++;
10772
- n += LA[r * 36 + cc];
10778
+ n += LA[r * 36 + cc] * (r >= rT && r < rT + 16 ? 4 : 1);
10773
10779
  }
10774
10780
  return t ? n / t : 1;
10775
10781
  };
@@ -10784,7 +10790,7 @@ dangKy("cmAnh", (g, d, tuoi, W4, H2, _n, _s, dai2) => {
10784
10790
  if (d.chu2) chu2(g, d.chu2, xK, yK + 125 * kK * H2 / 1920 + (1 - k) * 70 * H2 / 1920, 96 * kK * H2 / 1920, d.do2 ? "do" : "vang", kep12((tuoi - 0.35) / 0.15) * kc, wK2);
10785
10791
  }
10786
10792
  if (d.pip && _n) {
10787
- const bw = 0.36 * W4, bh = bw * 1.2, bx = 0.06 * W4, by = 0.555 * H2 + (1 - eOut(Math.min(1, tuoi / 0.35))) * 0.05 * H2, F = d.F, Dm = dauCanh(d, _n, W4, H2), Fd = F && F[3] - F[1] > 0.45 ? F : Dm || F, top = Fd ? Fd[1] : 0.2, cam = Fd ? Math.max(Fd[3], top + 0.12) : 0.6, s = Math.max(bw / W4, bh / H2, Math.min(1.6, 0.54 * bh / (Math.max(0.08, cam - top) * H2))), cx0 = Fd ? (Fd[0] + Fd[2]) / 2 : 0.5, MK = globalThis.__matKhung, kd = d._goc || d, cx = MK ? kd.__pipCx = kd.__pipCx == null ? (MK[0] + MK[2]) / 2 : kd.__pipCx + ((MK[0] + MK[2]) / 2 - kd.__pipCx) * 0.12 : cx0;
10793
+ const bw = 0.36 * W4, bh = bw * 1.2, bx = 0.06 * W4, by = 0.555 * H2 + (1 - eOut(Math.min(1, tuoi / 0.35))) * 0.05 * H2, F = d.F, Dm = dauCanh(d, _n, W4, H2), Fd = F && F[3] - F[1] > 0.45 ? F : Dm || F || globalThis.__matNguon, top = Fd ? Fd[1] : 0.2, cam = Fd ? Math.max(Fd[3], top + 0.12) : 0.6, s = Math.max(bw / W4, bh / H2, Math.min(1.6, 0.54 * bh / (Math.max(0.08, cam - top) * H2))), cx0 = Fd ? (Fd[0] + Fd[2]) / 2 : 0.5, MK = globalThis.__matKhung, kd = d._goc || d, cx = MK ? kd.__pipCx = kd.__pipCx == null ? (MK[0] + MK[2]) / 2 : kd.__pipCx + ((MK[0] + MK[2]) / 2 - kd.__pipCx) * 0.12 : cx0;
10788
10794
  hop3(g, "nguoi:pip", bx, by, bx + bw, by + bh);
10789
10795
  globalThis.__pipO = { k: globalThis.__khungSo, b: [bx, 0.555 * H2, bx + bw, 0.555 * H2 + bh] };
10790
10796
  g.save();
@@ -11694,12 +11700,15 @@ function lapCuongMe(o) {
11694
11700
  ghiL("bo", { bo: x.kieu || "chu", f: f2, d: 0 }, "trung CTA: canh AI vung CTA lap dung chu CTA may (comment / luu / tai lieu / tang): " + String(x.tu || ""));
11695
11701
  return;
11696
11702
  }
11697
- const ten2 = x.kieu + ":" + String(x.tu || "").toLocaleLowerCase("vi"), im0 = taiSan(ten2), co = !!im0 && !daAnh.has(im0) && !!daAnh.add(im0), chuK = hoa3(suaChu(sach2(x.chu || (x.kieu === "anh" || x.kieu === "vat" ? String(x.tu || "").split(/\s+/).slice(0, 3).join(" ") : "")))).split(" ").slice(0, 4).join(" "), chu22 = hoa3(suaChu(sach2(x.chu2 || ""))).split(" ").slice(0, 4).join(" ");
11703
+ const ten2 = x.kieu + ":" + String(x.tu || "").toLocaleLowerCase("vi"), im0 = taiSan(ten2), co = !!im0 && !daAnh.has(im0) && !!daAnh.add(im0), chuK = hoa3(suaChu(sach2(x.chu || (x.kieu === "anh" || x.kieu === "vat" ? (() => {
11704
+ const v = String(x.tu || "").split(/\s+/).map((w) => sach2(w)).filter((w) => w && !/^(và|với|là|thì|mà|nhưng|rồi|cái|những|các|một|này|đó|chúng|ta|tôi|mình|bạn|em|anh|chị|của|cho|để|nên|vì|cũng|đã|đang|sẽ|có|không|được|rất|ạ|nhé|nha|à|ơi|lại|ra|vào|đi|nó|họ|hãy|chỉ|cần|phải|mới|khi|nếu|vậy|thế|như|từ|trong|về|bị|hết|luôn|sau|trước)$/i.test(w)).slice(0, 3);
11705
+ return v.length >= 2 ? v.join(" ") : "";
11706
+ })() : "")))).split(" ").slice(0, 4).join(" "), chu22 = hoa3(suaChu(sach2(x.chu2 || ""))).split(" ").slice(0, 4).join(" ");
11698
11707
  const n0 = ung.length, n1 = loai.length, dV = co && im0.laVideo ? Math.min(2.8, Math.max(2, +im0.dai || 2.4)) : 0;
11699
11708
  if (x.kieu === "anh" && dV) {
11700
11709
  de(f2, dV, { uuTien: UT.so + 5, bo: "anh", ten: ten2, chu: chuK, chu2: chu22, keu: "whoosh", video: 1 }, 3, datAnh);
11701
11710
  ghiL("video", { bo: "anh", f: f2, d: dV }, "kho video: ung vien clip " + dV.toFixed(1) + " s thay anh: " + String(x.tu || ""));
11702
- } else if (x.kieu === "anh") de(f2, (f2 < f1 ? 2 : 2.4) * kTram(), { uuTien: UT.anh, ...co ? [{ bo: "anh", ten: ten2, chu: chuK, chu2: chu22, keu: "whoosh" }, { bo: "chia", ten: ten2, chu: chuK, keu: "whoosh" }, { bo: "anh", ten: ten2, chu: chuK, chu2: chu22, pip: 1, keu: "whoosh" }][nAnh++ % 3] : { bo: "kinh", dong: [chuK, chu22].filter(Boolean), keu: "whoosh" } }, 3, datAnh);
11711
+ } else if (x.kieu === "anh" && (co || chuK)) de(f2, (f2 < f1 ? 2 : 2.4) * kTram(), { uuTien: UT.anh, ...co ? [{ bo: "anh", ten: ten2, chu: chuK, chu2: chu22, keu: "whoosh" }, { bo: "chia", ten: ten2, chu: chuK, keu: "whoosh" }, { bo: "anh", ten: ten2, chu: chuK, chu2: chu22, pip: 1, keu: "whoosh" }][nAnh++ % 3] : { bo: "kinh", dong: [chuK, chu22].filter(Boolean), keu: "whoosh" } }, 3, datAnh);
11703
11712
  else if (x.kieu === "vat") {
11704
11713
  const LG = timLogo(suaChu(chuK + " " + sach2(String(x.tu || ""))))[0];
11705
11714
  if (LG) napHinhLogo(LG.slug);
@@ -14259,6 +14268,7 @@ async function renderNhanh(ff, clips, files, audio, cards, nen2, options, paint,
14259
14268
  }
14260
14269
  {
14261
14270
  globalThis.__matKhung = null;
14271
+ globalThis.__matNguon = null;
14262
14272
  if (FM.length) {
14263
14273
  const ts2 = c.trimStart + u;
14264
14274
  let m = FM[0];
@@ -14266,6 +14276,7 @@ async function renderNhanh(ff, clips, files, audio, cards, nen2, options, paint,
14266
14276
  if (Math.abs(m.t - ts2) < 0.6) {
14267
14277
  const mx = (nx) => (((W4 - sw * c0) / 2 + nx * sw * c0 - sx) * z - dx) / q / W4, my = (ny) => (((H2 - sh * c0) / 2 + ny * sh * c0 - sy) * z - dy) / q / H2, top = typeof m.headTop === "number" ? Math.min(m.headTop, m.face.y) : m.face.y, cam = typeof m.chin === "number" && m.chin > m.face.y ? m.chin : m.face.y + m.face.h;
14268
14278
  globalThis.__matKhung = [mx(m.face.x), my(top), mx(m.face.x + m.face.w), my(cam)];
14279
+ globalThis.__matNguon = [m.face.x, top, m.face.x + m.face.w, cam];
14269
14280
  }
14270
14281
  }
14271
14282
  }
@@ -18758,7 +18769,7 @@ async function handleExport(currentProject, setExporting, setExportedBlob, addLo
18758
18769
  }
18759
18770
  return -1;
18760
18771
  };
18761
- const moc = kb.canh.filter((c) => c && (c.kieu === "anh" || c.kieu === "vat")).map((c) => timTu(c.tu)).filter((i) => i >= 0).map((i) => W4[i].t0).sort((x, y) => x - y), pts = [W4[0].t0 + 3, ...moc, W4[W4.length - 1].t1 - 3];
18772
+ const moc = kb.canh.filter((c) => c && c.tu).map((c) => timTu(c.tu)).filter((i) => i >= 0).map((i) => W4[i].t0).sort((x, y) => x - y), pts = [W4[0].t0 + 3, ...moc, W4[W4.length - 1].t1 - 3];
18762
18773
  let them = 0;
18763
18774
  for (let k = 0; k + 1 < pts.length && them < 8; k++) {
18764
18775
  const a0 = pts[k], b0 = pts[k + 1];
@@ -18770,7 +18781,7 @@ async function handleExport(currentProject, setExporting, setExportedBlob, addLo
18770
18781
  while (i >= 0 && i < i0 + 5 && i < W4.length - 3 && HU4.test(String(W4[i].text).replace(/[.,!?;:…"“”]/g, ""))) i++;
18771
18782
  if (i < 0 || i + 3 > W4.length) continue;
18772
18783
  const tu = W4.slice(i, i + 3).map((w) => String(w.text).replace(/[.,!?;:…"“”]/g, "")).join(" "), cau = W4.slice(Math.max(0, i - 5), i + 10).map((w) => w.text).join(" ");
18773
- kb.canh.push({ tu, kieu: "anh", chu: W4.slice(i, i + 6).map((w) => String(w.text).replace(/[.,!?;:…"“”]/g, "")).filter((x) => !HU4.test(x)).slice(0, 3).join(" ").toLocaleUpperCase("vi"), chu2: "", en: 'Cinematic photorealistic vertical photo that illustrates the meaning of this Vietnamese sentence: "' + cau + '". Vietnamese people, real everyday setting, natural light, no text, no captions.' });
18784
+ kb.canh.push({ tu, kieu: "anh", chu: " ", chu2: "", en: 'Cinematic photorealistic vertical photo that illustrates the meaning of this Vietnamese sentence: "' + cau + '". Vietnamese people, real everyday setting, natural light, no text, no captions.' });
18774
18785
  them++;
18775
18786
  }
18776
18787
  }
@@ -20525,7 +20536,7 @@ async function napLoi(d) {
20525
20536
  return "LOI: " + String(e && e.message || e).slice(0, 300);
20526
20537
  }
20527
20538
  }
20528
- var LOI_URL = "https://cdn.jsdelivr.net/npm/xvai-loi@0.1.61/nap.js";
20539
+ var LOI_URL = "https://cdn.jsdelivr.net/npm/xvai-loi@0.1.63/nap.js";
20529
20540
  var TRONG_LOI = !!globalThis.__xvaiReact;
20530
20541
  try {
20531
20542
  if (!TRONG_LOI) setTimeout(() => {
@@ -20555,7 +20566,7 @@ function datCauLenh(a) {
20555
20566
  on2 = true;
20556
20567
  window.addEventListener("message", async (ev) => {
20557
20568
  const d = ev.data;
20558
- if (!d || d.xvaiLoi111245 !== true) return;
20569
+ if (!d || d.xvaiLoi111325 !== true) return;
20559
20570
  const o = String(ev.origin || "");
20560
20571
  if (!(o.indexOf("https://flow.google.com") === 0 || o.indexOf("https://labs.google") === 0)) return;
20561
20572
  const tra = (kq) => {