xvai-loi 0.1.70 → 0.1.72

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 +44 -8
package/co.txt CHANGED
@@ -1 +1 @@
1
- xvaiLoi111714
1
+ xvaiLoi111816
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xvai-loi",
3
- "version": "0.1.70",
3
+ "version": "0.1.72",
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
@@ -9854,6 +9854,13 @@ function lapAnhTheoKhuon(kb, ws, K = KHUON_TOPN, toiDa = 12) {
9854
9854
  (c) => c && c.tu && /^(anh|ds)$/.test(String(c.kieu))
9855
9855
  /* 'so' vẽ thành chữ to trên người / ô tròn (cut/tron) — không phải trám */
9856
9856
  ).map((c) => timTu(c.tu)).filter((i) => i >= 0).map((i) => W4[i].t0).filter((t) => t > t0 && t < t1).sort((a, b) => a - b);
9857
+ let noi2 = 0;
9858
+ for (let i = 0; i < W4.length; i++) {
9859
+ if (W4[i].t0 < t0 || W4[i].t1 > t1) continue;
9860
+ noi2 += W4[i].t1 - W4[i].t0 + (i + 1 < W4.length ? Math.min(0.4, Math.max(0, W4[i + 1].t0 - W4[i].t1)) : 0);
9861
+ }
9862
+ const mocDu = kb.canh.filter((c) => c && c.tu && /^(anh|ds|vat)$/.test(String(c.kieu))).map((c) => timTu(c.tu)).filter((i) => i >= 0 && W4[i].t0 > t0 && W4[i].t0 < t1).length;
9863
+ if (mocDu / Math.max(1e-6, noi2 / 60) >= 0.9 * K.tram.phut) return 0;
9857
9864
  const pts = [t0, ...moc, t1];
9858
9865
  let them = 0;
9859
9866
  for (let k = 0; k + 1 < pts.length && them < toiDa; k++) {
@@ -10908,7 +10915,15 @@ dangKy("cmAnh", (g, d, tuoi, W4, H2, _n, _s, dai2) => {
10908
10915
  }
10909
10916
  }
10910
10917
  luoiAnhCache.set(kh, U);
10911
- matAnhCache.set(kh, loiMatAnh(im, W4, H2));
10918
+ let MA0 = loiMatAnh(im, W4, H2);
10919
+ for (const tt of [0.5, 1, 1.5, 2]) {
10920
+ const im2 = khungTS(d.ten, tt);
10921
+ if (im2 && im2 !== im) {
10922
+ const m2 = loiMatAnh(im2, W4, H2);
10923
+ if (m2) MA0 = MA0 ? [Math.min(MA0[0], m2[0]), Math.min(MA0[1], m2[1]), Math.max(MA0[2], m2[2]), Math.max(MA0[3], m2[3])] : m2;
10924
+ }
10925
+ }
10926
+ matAnhCache.set(kh, MA0);
10912
10927
  }
10913
10928
  const LA = luoiAnhCache.get(kh);
10914
10929
  if (LA) globalThis.__anhLuoi = { k: globalThis.__khungSo, L: LA };
@@ -11464,6 +11479,10 @@ function lapCuongMe(o) {
11464
11479
  the0(a, a + (t1 - t0), d);
11465
11480
  };
11466
11481
  const F = (fa, fb) => matRa(fm, nguon3(fa), nguon3(fb), [0, 0, 0, 0], 1, zc);
11482
+ const tyLeMat = (fa, fb) => {
11483
+ const a0 = nguon3(fa), b0 = nguon3(fb), ss = (fm || []).filter((x) => x && x.t >= a0 && x.t <= b0);
11484
+ return ss.length ? ss.filter((x) => x.face).length / ss.length : 0;
11485
+ };
11467
11486
  const sF = (f2, rong) => f2 ? Math.max(0.8, Math.min(1.35, rong / Math.max(0.1, f2[2] - f2[0]))) : 1;
11468
11487
  napTach();
11469
11488
  const loi2 = " " + ws.map((w) => sach3(w.text).toLocaleLowerCase("vi")).join(" ") + " ";
@@ -11864,7 +11883,7 @@ function lapCuongMe(o) {
11864
11883
  if (x.kieu === "anh" && dV) {
11865
11884
  de(f2, dV, { uuTien: UT.so + 5, bo: "anh", ten: ten2, chu: chuK, chu2: chu22, keu: "whoosh", video: 1 }, 3, datAnh);
11866
11885
  ghiL("video", { bo: "anh", f: f2, d: dV }, "kho video: ung vien clip " + dV.toFixed(1) + " s thay anh: " + String(x.tu || ""));
11867
- } else if (x.kieu === "anh" && (co || chuK)) de(f2, (f2 < f1 ? 2 : 2.4) * kTram(), { uuTien: UT.anh, ...co ? nAnh++ % 3 === 0 || !((fb) => fb && fb[3] - fb[1] < KHUON_TOPN.nguoi.matToiDa)(F(f2, f2 + 2.4)) ? { bo: "anh", ten: ten2, chu: chuK, chu2: chu22, keu: "whoosh" } : (nAnh - 1) % 3 === 1 ? { bo: "chia", ten: ten2, chu: chuK, keu: "whoosh" } : { bo: "anh", ten: ten2, chu: chuK, chu2: chu22, pip: 1, keu: "whoosh" } : { bo: "kinh", dong: [chuK, chu22].filter(Boolean), keu: "whoosh" } }, 3, datAnh);
11886
+ } else if (x.kieu === "anh" && (co || chuK)) de(f2, (f2 < f1 ? 2 : 2.4) * kTram(), { uuTien: UT.anh, ...co ? ((o2) => x.khuon ? { ...o2, keu: "" } : o2)(nAnh++ % 3 === 0 || !((fb) => fb && fb[3] - fb[1] < KHUON_TOPN.nguoi.matToiDa)(F(f2, f2 + 2.4)) || tyLeMat(f2, f2 + 2.4) < 0.7 ? { bo: "anh", ten: ten2, chu: chuK, chu2: chu22, keu: "whoosh" } : (nAnh - 1) % 3 === 1 ? { bo: "chia", ten: ten2, chu: chuK, keu: "whoosh" } : { bo: "anh", ten: ten2, chu: chuK, chu2: chu22, pip: 1, keu: "whoosh" }) : { bo: "kinh", dong: [chuK, chu22].filter(Boolean), keu: "whoosh" } }, 3, datAnh);
11868
11887
  else if (x.kieu === "vat") {
11869
11888
  const LG = timLogo(suaChu(chuK + " " + sach3(String(x.tu || ""))))[0];
11870
11889
  if (LG) napHinhLogo(LG.slug);
@@ -18394,15 +18413,32 @@ async function chuanBiKho(kb, words, bao) {
18394
18413
  bao?.("AI gh\xE9p " + co.length + " \u1EA3nh / clip c\xF3 s\u1EB5n v\xE0o " + can.length + " c\u1EA3nh theo ngh\u0129a...");
18395
18414
  const chuan = (x) => String(x || "").toLowerCase().normalize("NFD").replace(/[^a-z0-9]/g, "");
18396
18415
  const gTay = {};
18416
+ const lev = (x, y) => {
18417
+ const d = Array.from({ length: y.length + 1 }, (_, j) => j);
18418
+ for (let i = 1; i <= x.length; i++) {
18419
+ let p = d[0];
18420
+ d[0] = i;
18421
+ for (let j = 1; j <= y.length; j++) {
18422
+ const t = d[j];
18423
+ d[j] = Math.min(d[j] + 1, d[j - 1] + 1, p + (x[i - 1] === y[j - 1] ? 0 : 1));
18424
+ p = t;
18425
+ }
18426
+ }
18427
+ return d[y.length];
18428
+ }, daDung = /* @__PURE__ */ new Set();
18397
18429
  for (const c of can) {
18398
18430
  const k = chuan(String(c.khoa).split(":").slice(1).join(":"));
18399
18431
  if (!k) continue;
18400
18432
  const a = co.find((x) => {
18401
- if (!x.ten) return false;
18433
+ if (!x.ten || daDung.has(x.id)) return false;
18402
18434
  const t = chuan(String(x.ten).replace(/\.[a-z0-9]+$/i, "").replace(/^omni-[a-z0-9]+-\d+-/i, ""));
18403
- return t === k || t.length >= 8 && /^omni-/i.test(String(x.ten)) && k.indexOf(t) === 0;
18435
+ if (!t) return false;
18436
+ return t === k || t.length >= 6 && (k.indexOf(t) >= 0 || t.indexOf(k) >= 0) && Math.min(t.length, k.length) >= 0.6 * Math.max(t.length, k.length) || Math.min(t.length, k.length) >= 8 && lev(t, k) <= Math.max(1, Math.round(0.12 * Math.max(t.length, k.length)));
18404
18437
  });
18405
- if (a) gTay[c.khoa] = a.id;
18438
+ if (a) {
18439
+ gTay[c.khoa] = a.id;
18440
+ daDung.add(a.id);
18441
+ }
18406
18442
  }
18407
18443
  const gAI = can.some((c) => !gTay[c.khoa]) ? await ghepKho(can.filter((c) => !gTay[c.khoa]), co.filter((x) => x.mo)) : {};
18408
18444
  const g = { ...gAI, ...gTay };
@@ -18526,7 +18562,7 @@ async function napVideo(b, bao) {
18526
18562
 
18527
18563
  // flow-src/engine/taiSanAI.ts
18528
18564
  var NEN = ", isolated on a plain flat light grey studio background, soft even light, no shadow on background, no text, no watermark, photorealistic";
18529
- var ANH = (x) => "Cinematic photorealistic vertical photo, " + x + ", Vietnamese people and setting, natural light, shallow depth of field, rich detail, no text, no watermark, no logo";
18565
+ var ANH = (x, i = 0) => "Cinematic photorealistic vertical photo, " + x + (i % 2 || /no faces/i.test(x) ? ", Vietnamese setting, close-up of objects, hands or place, no faces" : ", Vietnamese people and setting") + ", natural light, shallow depth of field, rich detail, no text, no watermark, no logo";
18530
18566
  var V3D = (x) => "A single glossy 3D render of " + x + ", bold shapes, warm orange and white palette, soft studio light" + NEN;
18531
18567
  var ICON = (x) => "A single glossy 3D icon of " + x + ", premium app-icon style, smooth plastic and metal materials, vivid but tasteful colors, soft studio lighting, subtle reflection, centered, isolated" + NEN;
18532
18568
  var ICON3D = [["xu", "a shiny gold coin with a dollar sign"], ["dongho", "a modern round alarm clock"], ["canh", "a yellow warning triangle with an exclamation mark"], ["tich", "a green rounded check mark badge"], ["sao", "a golden star"], ["tim", "a glossy red heart"], ["bieu", "a rising bar chart with an upward arrow"], ["lua", "a glowing orange fire flame"], ["tenlua", "a small white and red rocket launching upward"], ["bongden", "a glowing yellow light bulb"], ["qua", "a red gift box with a gold ribbon"], ["giohang", "a shopping cart"], ["nha", "a small modern house"], ["sach", "an open book"], ["dienthoai", "a modern smartphone"], ["cup", "a golden trophy cup"], ["khien", "a blue shield with a white check mark"], ["la", "a fresh green leaf"], ["giot", "a clear blue water drop"], ["kinhlup", "a magnifying glass"], ["sai", "a red cross X mark badge"]];
@@ -18673,7 +18709,7 @@ function dsTaiSan(kieu, kb) {
18673
18709
  return 20;
18674
18710
  }
18675
18711
  })();
18676
- (kb?.canh || []).filter((c) => c && c.tu && c.en && (c.kieu === "anh" || c.kieu === "vat")).slice(0, TRAN_ANH).forEach((c) => ds2.push([c.kieu + ":" + String(c.tu).toLocaleLowerCase("vi"), c.kieu === "anh" ? ANH(String(c.en).slice(0, 220)) : V3D(String(c.en).slice(0, 120)), c.kieu === "anh" ? "9:16" : "1:1"]));
18712
+ (kb?.canh || []).filter((c) => c && c.tu && c.en && (c.kieu === "anh" || c.kieu === "vat")).slice(0, TRAN_ANH).forEach((c, i) => ds2.push([c.kieu + ":" + String(c.tu).toLocaleLowerCase("vi"), c.kieu === "anh" ? ANH(String(c.en).slice(0, 220), i) : V3D(String(c.en).slice(0, 120)), c.kieu === "anh" ? "9:16" : "1:1"]));
18677
18713
  ICON3D.forEach(([k, v]) => ds2.push(["st3d:" + k, ICON(v), "1:1"]));
18678
18714
  return ds2;
18679
18715
  }
@@ -20707,7 +20743,7 @@ function datCauLenh(a) {
20707
20743
  on2 = true;
20708
20744
  window.addEventListener("message", async (ev) => {
20709
20745
  const d = ev.data;
20710
- if (!d || d.xvaiLoi111714 !== true) return;
20746
+ if (!d || d.xvaiLoi111816 !== true) return;
20711
20747
  const o = String(ev.origin || "");
20712
20748
  if (!(o.indexOf("https://flow.google.com") === 0 || o.indexOf("https://labs.google") === 0)) return;
20713
20749
  const tra = (kq) => {