xvai-loi 0.1.77 → 0.1.78

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 +40 -19
package/co.txt CHANGED
@@ -1 +1 @@
1
- xvaiLoi112314
1
+ xvaiLoi112357
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xvai-loi",
3
- "version": "0.1.77",
3
+ "version": "0.1.78",
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
@@ -9822,10 +9822,8 @@ var KHUON_TOPN = {
9822
9822
  ten: "Top N chi\u1EC1u s\xE2u (Captions)",
9823
9823
  tram: { phut: 18.3, tyLe: 0.7, phan: [0.83, 0.81, 0.46], daiTV: 2.1, video: 0.33, nhanVat: ["Vietnamese people in a real everyday setting.", "Close-up of an object, hands or a place that shows the idea, no faces."] },
9824
9824
  // cảnh trám / phút, % thời lượng, 3 phần đầu/giữa/cuối, độ dài trung vị (s), tỉ lệ clip động; nhanVat: xen kẽ ảnh có người / cận vật-tay-nơi (đối thủ trộn web, stock, 3D — B06-1027: toàn ảnh người → 'không thấy mặt' 12 % < 15)
9825
- chu: { phut: [8, 18] },
9826
- icon: { phut: 11.5 },
9827
- cat: { moi10s: [4, 6], manhNguoi: 1.2 },
9828
- // manhNguoi: mẩu người nói kẹp giữa 2 cảnh ngắn hơn thì lấp (trước 0,6 — VD-236)
9825
+ chu: { phut: [8, 18], caoMin: 0.042 },
9826
+ // caoMin: nét chữ nhấn (kể cả dấu) / H — đối thủ trung vị 0,042 (đo tay 23 dòng); chữ bị ép ngang thấp hơn → 2 dòng icon: { phut: 11.5 }, cat: { moi10s: [4, 6], manhNguoi: 1.2, heChu: 0 }, // manhNguoi: mẩu người nói kẹp giữa 2 cảnh ngắn hơn thì lấp (trước 0,6 — VD-236); heChu: khe giữa 2 cảnh liền cùng có chữ (trước 0,06 → chớp 2 khung người nói = 2 cú cắt thừa; bàn thử 13 video 12/10 00:0x: 0,06 → 0 cắt TB 5,44 → 4,39/10 s, chồng chữ 0/13 — cảnh trước đã hết theo giờ PHIM nhờ bT)
9829
9827
  nguoi: { phongToiDa: 1.8, matToiDa: 0.55 },
9830
9828
  // matToiDa: hộp đầu (tóc→cằm) cao hơn 0,55 H thì KHÔNG dùng ô người / chia (không vừa ô) // MỌI ô người (PIP, thẻ, chia) phóng khung gốc tối đa 1,8× (độ nét) — trước: PIP 1,6, thẻ 1,3 (B05-1027: thẻ hiện cả người nhỏ)
9831
9829
  lietKe: { xenKe: 2 },
@@ -9992,6 +9990,27 @@ function kieuChu() {
9992
9990
  kcCache = k || {};
9993
9991
  return kcCache;
9994
9992
  }
9993
+ function haiDong4(g, txt, px, maxW, pxMin, pxMax) {
9994
+ const t = txt.normalize("NFC"), ws = t.split(/\s+/).filter(Boolean);
9995
+ if (t.indexOf(String.fromCharCode(10)) >= 0 || ws.length < 3) return [t, px, t.indexOf(String.fromCharCode(10)) >= 0];
9996
+ g.save();
9997
+ g.font = "900 " + px.toFixed(1) + "px " + FB;
9998
+ const w = g.measureText(t).width;
9999
+ if (px * Math.min(1, maxW / w) >= pxMin) {
10000
+ g.restore();
10001
+ return [t, px, false];
10002
+ }
10003
+ let tot = "", m = 1e9;
10004
+ for (let i = 1; i < ws.length; i++) {
10005
+ const a = ws.slice(0, i).join(" "), b = ws.slice(i).join(" "), x = Math.max(g.measureText(a).width, g.measureText(b).width);
10006
+ if (x < m) {
10007
+ m = x;
10008
+ tot = a + String.fromCharCode(10) + b;
10009
+ }
10010
+ }
10011
+ g.restore();
10012
+ return [tot, Math.min(pxMax, px * Math.min(1, maxW / m)), true];
10013
+ }
9995
10014
  function chu2(g, txt, x, y, px, kieu, a = 1, maxW = 0) {
9996
10015
  if (!txt || a <= 0) return;
9997
10016
  txt = String(txt).normalize("NFC");
@@ -10806,19 +10825,21 @@ dangKy("cmNen", (g, d, tuoi, W4, H2, nen2, _s, dai2) => {
10806
10825
  if (hv2 > 0) g.drawImage(vt, W4 / 2 - wv / 2, yv - hv2 / 2, wv, hv2);
10807
10826
  g.restore();
10808
10827
  }
10809
- if (d.tieu) chu2(g, d.tieu, W4 / 2, 0.135 * H2 + (1 - ka) * 70 * H2 / 1920, 122 * H2 / 1920, "brand", kep12(tuoi / 0.15), 0.76 * W4);
10828
+ const t2 = d.tieu ? haiDong4(g, String(d.tieu), 122 * H2 / 1920, 0.76 * W4, KHUON_TOPN.chu.caoMin / 0.92 * H2, 0.05 * H2) : null;
10829
+ if (t2) chu2(g, t2[0], W4 / 2, (t2[2] ? 0.118 : 0.135) * H2 + (1 - ka) * 70 * H2 / 1920, t2[1], "brand", kep12(tuoi / 0.15), 0.76 * W4);
10810
10830
  if (d.so) {
10811
10831
  g.save();
10812
10832
  g.globalAlpha = a * kep12((tuoi - 0.15) / 0.2);
10813
10833
  g.font = "900 " + (0.02 * H2).toFixed(1) + "px " + FB;
10814
10834
  const t = (d.nhom || "M\u1EE4C") + " " + d.so + "/" + d.N, tw = g.measureText(t).width + 0.05 * W4;
10815
- bo(g, W4 / 2 - tw / 2, 0.172 * H2, tw, 0.034 * H2, 0.017 * H2);
10835
+ const dy = t2 && t2[2] ? 0.01 * H2 : 0;
10836
+ bo(g, W4 / 2 - tw / 2, 0.172 * H2 + dy, tw, 0.034 * H2, 0.017 * H2);
10816
10837
  g.fillStyle = "rgba(20,20,26,0.85)";
10817
10838
  g.fill();
10818
10839
  g.fillStyle = VANG;
10819
10840
  g.textAlign = "center";
10820
10841
  g.textBaseline = "middle";
10821
- g.fillText(t, W4 / 2, 0.189 * H2);
10842
+ g.fillText(t, W4 / 2, 0.189 * H2 + dy);
10822
10843
  g.restore();
10823
10844
  }
10824
10845
  if (d.ui) theUI(g, d.ui, tuoi, W4, H2, 1);
@@ -11412,7 +11433,7 @@ function cum2(ws) {
11412
11433
  for (let i = w.length - 2; i >= 0; i--) if (!hu(w[i]) && !hu(w[i + 1])) return w[i] + " " + w[i + 1];
11413
11434
  return w.slice(-2).join(" ");
11414
11435
  }
11415
- var haiDong4 = (s, n = 10) => {
11436
+ var haiDong5 = (s, n = 10) => {
11416
11437
  const w = s.split(" ");
11417
11438
  if (s.length <= n || w.length < 2) return s;
11418
11439
  let best = 1, d = 99;
@@ -11781,7 +11802,7 @@ function lapCuongMe(o) {
11781
11802
  })(sach3(kb?.moc || layMoc(ws, kb)).split(" "))) || hoa3(cum2(cs[0] ? cs[0].chu : []));
11782
11803
  const Lm = Math.min(Math.max(2.4, docGiay(moc) + 0.4), Math.max(1.2, f1 - 0.3));
11783
11804
  bc = "B2 moc";
11784
- de(0, Lm, { uuTien: UT.moc, bo: "depth", giant: haiDong4(moc, 11), chu2: coBuoc ? N + " " + LOAI2 : "", yChu: 0.165, vao: 1e-3, z: 1.3, keu: "whoosh" });
11805
+ de(0, Lm, { uuTien: UT.moc, bo: "depth", giant: haiDong5(moc, 11), chu2: coBuoc ? N + " " + LOAI2 : "", yChu: 0.165, vao: 1e-3, z: 1.3, keu: "whoosh" });
11785
11806
  if (coBuoc && f1 - Lm > 3.4) de(Lm + 0.3, Math.min(3.2, f1 - Lm - 0.6), { uuTien: UT.moc, bo: "cut", tieu: N + " " + LOAI2, hang: muc.map((m) => m.ten).slice(0, 8), keu: "pop", st: "chuot", stX: 0.43, stY: 0.188, stR: 0.042, stTre: 1.2 });
11786
11807
  else if (N >= 2) ghiL("bo", { bo: "cut", f: Lm + 0.3, d: 3.2 }, "moc ngan (f1 - Lm <= 3,4 s) \u2192 bo hang N muc");
11787
11808
  const gonTen = (x) => {
@@ -11800,7 +11821,7 @@ function lapCuongMe(o) {
11800
11821
  const c = cs.filter((x) => x.f >= m.f + Lc + 2 && x.f + 2.4 <= m.b - 1).sort((p, q) => Math.abs(p.f - (m.f + L * 0.6)) - Math.abs(q.f - (m.f + L * 0.6)))[0];
11801
11822
  if (c) {
11802
11823
  const t = hoa3(cum2(c.chu));
11803
- de(c.f, Math.max(2.2, docGiay(t) + 0.6), { uuTien: UT.chu, bo: "depth", giant: haiDong4(t, 9), keu: "pop" });
11824
+ de(c.f, Math.max(2.2, docGiay(t) + 0.6), { uuTien: UT.chu, bo: "depth", giant: haiDong5(t, 9), keu: "pop" });
11804
11825
  }
11805
11826
  }
11806
11827
  });
@@ -11816,7 +11837,7 @@ function lapCuongMe(o) {
11816
11837
  if (iN >= 0 && ws[iN + 2] && /^[A-ZÀ-Ỹ]/.test(String(ws[iN + 2].text || "").trim())) {
11817
11838
  const nm = [];
11818
11839
  for (let k = iN + 2; k < W22.length && nm.length < 4 && !DUNG.test(W22[k].t) && !/^(nhớ|hãy|bấm)$/.test(W22[k].t); k++) nm.push(W22[k].t);
11819
- if (nm.length) de(W22[iN].f, 1.8, { uuTien: UT.cta, bo: "depth", giant: haiDong4(hoa3(suaChu(nm.join(" "))), 9), keu: "pop" }, 0.5);
11840
+ if (nm.length) de(W22[iN].f, 1.8, { uuTien: UT.cta, bo: "depth", giant: haiDong5(hoa3(suaChu(nm.join(" "))), 9), keu: "pop" }, 0.5);
11820
11841
  }
11821
11842
  if (iC >= 0) de(fC, 2.4, { uuTien: UT.cta, bo: "depth", giant: W22[iC].t === "comment" ? "COMMENT" : "B\xCCNH LU\u1EACN", yChu: 0.17, chu2: kw.length ? '"' + hoa3(kw.filter((w, i) => i === 0 || String(w).toLocaleLowerCase("vi") !== String(kw[i - 1]).toLocaleLowerCase("vi")).join(" ")) + '"' : "", keu: "pop" }, 1);
11822
11843
  if (iL >= 0) de(W22[iL].f, 2, { uuTien: UT.cta, bo: "cut", giant: "L\u01AFU VIDEO", st: "luu", keu: "pop" }, 1);
@@ -11906,7 +11927,7 @@ function lapCuongMe(o) {
11906
11927
  else if (x.kieu === "vat") {
11907
11928
  const LG = timLogo(suaChu(chuK + " " + sach3(String(x.tu || ""))))[0];
11908
11929
  if (LG) napHinhLogo(LG.slug);
11909
- de(f2, 2.3, { uuTien: UT.vat, bo: "cut", vat: co && !LG ? ten2 : "", logoTo: LG, giant: haiDong4(chuK, 11), chu2: co || LG ? "" : chu22, keu: "pop" }, 3);
11930
+ de(f2, 2.3, { uuTien: UT.vat, bo: "cut", vat: co && !LG ? ten2 : "", logoTo: LG, giant: haiDong5(chuK, 11), chu2: co || LG ? "" : chu22, keu: "pop" }, 3);
11910
11931
  } else if (x.kieu === "ds" && Array.isArray(x.dong) && x.dong.length >= 2) {
11911
11932
  const dg = x.dong.slice(0, 3).map((v) => hoa3(suaChu(sach3(String(v || "")))).split(" ").slice(0, 6).join(" ")).filter(Boolean);
11912
11933
  const qs = dg.map((v) => {
@@ -11916,7 +11937,7 @@ function lapCuongMe(o) {
11916
11937
  dg.splice(0, 9, ...dg2);
11917
11938
  de(f2, Math.max(2.4, Math.min(3.4, (moc2.filter((v) => v != null).pop() || 1) + 1.3)), { uuTien: UT.ds, bo: "kinh", dong: dg, moc: moc2, ten: co ? ten2 : "", keu: "whoosh" }, 3);
11918
11939
  } else if (x.kieu === "so") de(f2, 2.2, { uuTien: UT.so, bo: "cut", giant: chuK, cam: 1, chu2: chu22, keu: "pop" }, 3);
11919
- else if (chuK) de(f2, Math.max(2, docGiay(chuK) + 0.6), { uuTien: UT.chu, bo: "depth", giant: haiDong4(chuK, 9), keu: "pop" }, 3);
11940
+ else if (chuK) de(f2, Math.max(2, docGiay(chuK) + 0.6), { uuTien: UT.chu, bo: "depth", giant: haiDong5(chuK, 9), keu: "pop" }, 3);
11920
11941
  if (ung.length === n0 && x.kieu !== "anh") {
11921
11942
  boC.push([chuK || x.tu, +f2.toFixed(2), "khong-dat", x.kieu]);
11922
11943
  if (loai.length === n1) ghiL("bo", { bo: x.kieu || "chu", f: f2, d: 0 }, "khong goi dat(): ds < 2 dong hoac khong co chu: " + String(x.tu || ""));
@@ -11994,7 +12015,7 @@ function lapCuongMe(o) {
11994
12015
  if (k < 2) k = kc;
11995
12016
  if (k < 2) return;
11996
12017
  const t3 = hoa3(suaChu([k - 2, k - 1, k].map((q) => sach3(ws[q].text)).join(" "))), f32 = Math.max(a + 0.3, Math.min(W22[k - 2].f - 0.1, b - 1.9));
11997
- if (t3) dat(f32, Math.max(1.3, Math.min(2.1, b - f32 - 0.16)), { bo: "depth", giant: haiDong4(t3, 11), keu: "pop" }, 0.5);
12018
+ if (t3) dat(f32, Math.max(1.3, Math.min(2.1, b - f32 - 0.16)), { bo: "depth", giant: haiDong5(t3, 11), keu: "pop" }, 0.5);
11998
12019
  });
11999
12020
  }
12000
12021
  sp.sort((p, q) => p.f - q.f).forEach((s, k) => {
@@ -12035,7 +12056,7 @@ function lapCuongMe(o) {
12035
12056
  const p = sp[k - 1], q = sp[k], cl = (s) => !!(s.giant || s.tieu || s.dong || s.ui || s.doc || s.chu);
12036
12057
  if (p.bo === "kinh" && q.bo === "kinh" && q.f - p.f - p.d < 1) {
12037
12058
  ghiL("rut-dong", q, "2 the kinh lien < 1 s \u2192 khung tron, mat dong 2-3");
12038
- q.bo = "tron", q.giant = haiDong4(String((q.dong || [])[0] || ""), 11);
12059
+ q.bo = "tron", q.giant = haiDong5(String((q.dong || [])[0] || ""), 11);
12039
12060
  }
12040
12061
  if (cl(p) && cl(q) && q.f - p.f - p.d < 1 && q.f - p.f - 1 >= 1.2) {
12041
12062
  ghiL("rut", p, "2 canh chu lien < 1 s \u2192 ve mat + phu de >= 1 s", [p.f, q.f - 1]);
@@ -12443,7 +12464,7 @@ function lapCuongMe(o) {
12443
12464
  }
12444
12465
  if (dg.length >= 3) ghiL("rut-dong", s, "qua 3 the kinh \u2192 chu sau dau / nen toi, mat dong 3");
12445
12466
  s.bo = xen++ % 2 ? "cut" : "depth";
12446
- s.giant = haiDong4(String(dg[0] || ""), 9);
12467
+ s.giant = haiDong5(String(dg[0] || ""), 9);
12447
12468
  s.chu2 = dg[1] || "";
12448
12469
  if (s.bo === "cut") s.toiNen = 1;
12449
12470
  s.dong = void 0;
@@ -12508,7 +12529,7 @@ function lapCuongMe(o) {
12508
12529
  v.vat = v.ten;
12509
12530
  v.ten = "";
12510
12531
  v.vatChia = 0;
12511
- v.giant = haiDong4(String(v.chu || ""), 11);
12532
+ v.giant = haiDong5(String(v.chu || ""), 11);
12512
12533
  v.chu = "";
12513
12534
  v.st = v.st0;
12514
12535
  return true;
@@ -12967,7 +12988,7 @@ function lapCuongMe(o) {
12967
12988
  const cc = sp.filter((x) => x.bo !== "phong").sort((p, q) => p.f - q.f);
12968
12989
  for (let i = 0; i + 1 < cc.length; i++) {
12969
12990
  const x = cc[i], y = cc[i + 1];
12970
- const coChu = (z) => !!String(z.giant || z.chu || z.tieu || "").trim(), he = coChu(x) && coChu(y) ? 0.06 : 0;
12991
+ const coChu = (z) => !!String(z.giant || z.chu || z.tieu || "").trim(), he = coChu(x) && coChu(y) ? globalThis.__heChu ?? KHUON_TOPN.cat.heChu : 0;
12971
12992
  if (x.f + x.d > y.f - he && y.f > x.f + 0.3 && !x.khoa) {
12972
12993
  if (he) ghiL("doi", x, "N8: cat duoi " + (x.f + x.d - y.f + he).toFixed(2) + " s chong canh sau (2 chu cung hien)");
12973
12994
  x.d = +(y.f - x.f - he).toFixed(2);
@@ -20839,7 +20860,7 @@ function datCauLenh(a) {
20839
20860
  on2 = true;
20840
20861
  window.addEventListener("message", async (ev) => {
20841
20862
  const d = ev.data;
20842
- if (!d || d.xvaiLoi112314 !== true) return;
20863
+ if (!d || d.xvaiLoi112357 !== true) return;
20843
20864
  const o = String(ev.origin || "");
20844
20865
  if (!(o.indexOf("https://flow.google.com") === 0 || o.indexOf("https://labs.google") === 0)) return;
20845
20866
  const tra = (kq) => {