xvai-loi 0.1.141 → 0.1.142

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 +42 -62
package/co.txt CHANGED
@@ -1 +1 @@
1
- xvaiLoi140209
1
+ xvaiLoi140229
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xvai-loi",
3
- "version": "0.1.141",
3
+ "version": "0.1.142",
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
@@ -5090,11 +5090,11 @@ function giaiBoCuc(ung, tong, nc = {}) {
5090
5090
  // flow-src/engine/moNhanh.ts
5091
5091
  var KHO = {};
5092
5092
  function moNhanh(g, W3, H2, ve, r, them = "") {
5093
- const k = 4, w = Math.ceil(W3 / k), h = Math.ceil(H2 / k), khoa2 = w + "x" + h;
5094
- let c = KHO[khoa2];
5093
+ const k = 4, w = Math.ceil(W3 / k), h = Math.ceil(H2 / k), khoa3 = w + "x" + h;
5094
+ let c = KHO[khoa3];
5095
5095
  if (!c) {
5096
5096
  const cv = new OffscreenCanvas(w, h);
5097
- c = KHO[khoa2] = { cv, g: cv.getContext("2d") };
5097
+ c = KHO[khoa3] = { cv, g: cv.getContext("2d") };
5098
5098
  }
5099
5099
  const x = c.g;
5100
5100
  x.setTransform(1, 0, 0, 1, 0, 0);
@@ -14085,12 +14085,12 @@ var bam = (s) => {
14085
14085
  };
14086
14086
  var DE = 'B\u1EA1n l\xE0 bi\xEAn t\u1EADp vi\xEAn ph\u1EE5 \u0111\u1EC1 video ng\u1EAFn ti\u1EBFng Vi\u1EC7t. D\u01B0\u1EDBi \u0111\xE2y l\xE0 l\u1EDDi n\xF3i, m\u1ED7i t\u1EEB c\xF3 s\u1ED1 th\u1EE9 t\u1EF1 \u0111\u1EE9ng tr\u01B0\u1EDBc d\u1EA5u hai ch\u1EA5m. Ch\u1ECDn t\u1EEB c\u1EA7n NH\u1EA4N tr\xEAn ph\u1EE5 \u0111\u1EC1. k = t\u1EEB kho\xE1 mang \xFD ch\xEDnh c\u1EE7a c\xE2u, X\u1EBEP t\u1EEB quan tr\u1ECDng nh\u1EA5t tr\u1EDF xu\u1ED1ng (t\u1EEB gh\xE9p nh\u01B0 kh\xF3 kh\u0103n, l\xF2ng ng\u01B0\u1EDDi th\xEC ch\u1ECDn c\u1EA3 hai ti\u1EBFng, \u0111\u1EE9ng li\u1EC1n nhau; kh\xF4ng ch\u1ECDn h\u01B0 t\u1EEB nh\u01B0 l\xE0, th\xEC, m\xE0, c\u1EE7a, c\xF3, nh\u1EEFng). d = danh t\u1EEB quan tr\u1ECDng. g = t\u1EEB g\u1EE3i h\xECnh ho\u1EB7c c\u1EA3m x\xFAc m\u1EA1nh. Ch\u1EC9 tr\u1EA3 v\u1EC1 \u0111\xFAng m\u1ED9t d\xF2ng JSON d\u1EA1ng {"k":[s\u1ED1],"d":[s\u1ED1],"g":[s\u1ED1]}, kh\xF4ng gi\u1EA3i th\xEDch. L\u1EDDi n\xF3i: ';
14087
14087
  async function nhanAI(ws, onStatus) {
14088
- const khoa2 = "xvaiNhan:2" + bam(ws.map((w) => w.text).join(" "));
14089
- if (kho4.has(khoa2)) return kho4.get(khoa2);
14088
+ const khoa3 = "xvaiNhan:2" + bam(ws.map((w) => w.text).join(" "));
14089
+ if (kho4.has(khoa3)) return kho4.get(khoa3);
14090
14090
  try {
14091
- const c = JSON.parse(localStorage.getItem(khoa2) || "null");
14091
+ const c = JSON.parse(localStorage.getItem(khoa3) || "null");
14092
14092
  if (c && Array.isArray(c.k)) {
14093
- kho4.set(khoa2, c);
14093
+ kho4.set(khoa3, c);
14094
14094
  return c;
14095
14095
  }
14096
14096
  } catch (e) {
@@ -14110,9 +14110,9 @@ async function nhanAI(ws, onStatus) {
14110
14110
  onStatus?.("AI ch\u1ECDn t\u1EEB nh\u1EA5n l\u1ED7i, xu\u1EA5t kh\xF4ng nh\u1EA5n: " + String(e?.message || e).slice(0, 60));
14111
14111
  return null;
14112
14112
  }
14113
- kho4.set(khoa2, ra2);
14113
+ kho4.set(khoa3, ra2);
14114
14114
  try {
14115
- localStorage.setItem(khoa2, JSON.stringify(ra2));
14115
+ localStorage.setItem(khoa3, JSON.stringify(ra2));
14116
14116
  } catch (e) {
14117
14117
  }
14118
14118
  return ra2;
@@ -15212,13 +15212,13 @@ async function chuanBiKho(kb, words, bao) {
15212
15212
  }
15213
15213
  }
15214
15214
  if (best < 0 || bd2 > Math.max(2, Math.round(0.25 * t.length))) continue;
15215
- const tu2 = W3.slice(best, best + 3).map((w) => String(w.text).replace(/[.,!?;:…"“”]/g, "")).join(" "), khoa2 = "anh:" + tu2.toLocaleLowerCase("vi");
15216
- const cu = taiSan(khoa2);
15215
+ const tu2 = W3.slice(best, best + 3).map((w) => String(w.text).replace(/[.,!?;:…"“”]/g, "")).join(" "), khoa3 = "anh:" + tu2.toLocaleLowerCase("vi");
15216
+ const cu = taiSan(khoa3);
15217
15217
  if (cu && cu.laVideo) continue;
15218
15218
  try {
15219
15219
  const im = await napVideo(a.blob, bao);
15220
15220
  im.khoId = a.id;
15221
- datTaiSan(khoa2, im);
15221
+ datTaiSan(khoa3, im);
15222
15222
  da.add(a.id);
15223
15223
  n++;
15224
15224
  them++;
@@ -15454,9 +15454,9 @@ async function kichBanDoan(ws) {
15454
15454
  let x = 5381;
15455
15455
  for (let i = 0; i < t.length; i++) x = (x * 33 ^ t.charCodeAt(i)) >>> 0;
15456
15456
  return x.toString(36).slice(0, 5);
15457
- })(), khoa2 = (cm ? "xvaiKbCm9" + hp + ":" : "xvaiKb3:") + h.toString(36);
15457
+ })(), khoa3 = (cm ? "xvaiKbCm9" + hp + ":" : "xvaiKb3:") + h.toString(36);
15458
15458
  try {
15459
- const c = localStorage.getItem("xvaiDemLanh") === "1" ? null : JSON.parse(localStorage.getItem(khoa2) || "null");
15459
+ const c = localStorage.getItem("xvaiDemLanh") === "1" ? null : JSON.parse(localStorage.getItem(khoa3) || "null");
15460
15460
  if (c && c.moc) {
15461
15461
  globalThis.__kbNguon = "dem";
15462
15462
  return c;
@@ -15464,8 +15464,8 @@ async function kichBanDoan(ws) {
15464
15464
  } catch (e) {
15465
15465
  }
15466
15466
  try {
15467
- const kDa = "kb:" + khoa2.split(":")[0] + ":da:" + maDuAn(), sg = (x) => String(x || "").replace(/[^\p{L}]/gu, "").slice(0, 40);
15468
- const b = await docDem("kb:" + khoa2) || await (async () => {
15467
+ const kDa = "kb:" + khoa3.split(":")[0] + ":da:" + maDuAn(), sg = (x) => String(x || "").replace(/[^\p{L}]/gu, "").slice(0, 40);
15468
+ const b = await docDem("kb:" + khoa3) || await (async () => {
15469
15469
  const c = await docDem(kDa);
15470
15470
  return c && c.van && sg(c.van.dau) === sg(van.dau) ? c : null;
15471
15471
  })();
@@ -15478,7 +15478,7 @@ async function kichBanDoan(ws) {
15478
15478
  if (cm) {
15479
15479
  const dau = van.dau;
15480
15480
  for (const k of Object.keys(localStorage)) {
15481
- if (k.indexOf(khoa2.split(":")[0] + ":") !== 0) continue;
15481
+ if (k.indexOf(khoa3.split(":")[0] + ":") !== 0) continue;
15482
15482
  try {
15483
15483
  const c = JSON.parse(localStorage.getItem(k) || "null"), v = c && c.van;
15484
15484
  if (c && c.moc && Array.isArray(c.canh) && c.canh.length > 10 && dau.indexOf(String(c.moc).toLocaleLowerCase("vi").slice(0, 18)) >= 0 && v && v.dau === van.dau && v.cuoi === van.cuoi && Math.abs((v.n || 0) - van.n) <= van.n * 0.1) {
@@ -15536,13 +15536,13 @@ async function kichBanDoan(ws) {
15536
15536
  }
15537
15537
  if (j && j.moc) {
15538
15538
  try {
15539
- localStorage.setItem(khoa2, JSON.stringify({ ...j, van }));
15539
+ localStorage.setItem(khoa3, JSON.stringify({ ...j, van }));
15540
15540
  } catch (e) {
15541
15541
  }
15542
15542
  try {
15543
15543
  const v2 = JSON.parse(JSON.stringify({ ...j, van }));
15544
- ghiDem("kb:" + khoa2, v2);
15545
- ghiDem("kb:" + khoa2.split(":")[0] + ":da:" + maDuAn(), v2);
15544
+ ghiDem("kb:" + khoa3, v2);
15545
+ ghiDem("kb:" + khoa3.split(":")[0] + ":da:" + maDuAn(), v2);
15546
15546
  } catch (e) {
15547
15547
  }
15548
15548
  return j;
@@ -16083,14 +16083,20 @@ function xepKho(p, mau2, kb, gia2) {
16083
16083
  }
16084
16084
  }
16085
16085
  var khoTile = (mau2, kb) => new Map(dsTaiSan(mau2.doan, kb).map((x) => [x[0], x[2]]));
16086
- function canhClip(p, mau2, kb) {
16086
+ var khoa = (c) => "anh:" + String(c.tu || "").toLocaleLowerCase("vi");
16087
+ function canhClip(p, mau2, kb, toiDa = 4) {
16087
16088
  if (!mau2?.doan || !kb) return null;
16088
- const tile = khoTile(mau2, kb);
16089
- const d = xepKho(p, mau2, kb, (k) => /^anh:/.test(k) ? clipGia : tile.has(k) ? anhGia(String(tile.get(k))) : null);
16090
- if (!d) return null;
16091
- const dung = new Set(d);
16092
- const ra2 = (kb.canh || []).filter((c) => c && c.kieu === "anh" && (c.en || c.de) && dung.has("anh:" + String(c.tu || "").toLocaleLowerCase("vi")));
16093
- G2.__xepThu = { ...G2.__xepThu || {}, clip: [d.length, ra2.length] };
16089
+ const tile = khoTile(mau2, kb), anhG = (k) => tile.has(k) ? anhGia(String(tile.get(k))) : null;
16090
+ const d0 = xepKho(p, mau2, kb, anhG);
16091
+ if (!d0) return null;
16092
+ const dung = new Set(d0);
16093
+ const ung = (kb.canh || []).filter((c) => c && c.kieu === "anh" && (c.en || c.de) && dung.has(khoa(c))), b = ung.length / Math.max(1, toiDa);
16094
+ const chon = ung.length <= toiDa ? ung : Array.from({ length: toiDa }, (_, i) => ung[Math.floor(i * b)]), ck = new Set(chon.map(khoa));
16095
+ const d1 = xepKho(p, mau2, kb, (k) => ck.has(k) ? clipGia : anhG(k));
16096
+ if (!d1) return null;
16097
+ const song = new Set(d1);
16098
+ const ra2 = chon.filter((c) => song.has(khoa(c)));
16099
+ G2.__xepThu = { ...G2.__xepThu || {}, clip: [ung.length, chon.length, ra2.length] };
16094
16100
  return ra2;
16095
16101
  }
16096
16102
  function anhCan(p, mau2, kb) {
@@ -16440,7 +16446,7 @@ async function handleExport(currentProject, setExporting, setExportedBlob, addLo
16440
16446
  const khoCu = await layKho(), nVid = khoCu.filter((m) => m.loai === "video" && cuaDuAn(m.ten)).length;
16441
16447
  const canVid = Math.max(3, Math.min(8, Math.ceil((window.__loiApp?.p?.timeline || []).reduce((s, t) => s + Math.max(0, (t.trimEnd || 0) - (t.trimStart || 0)), 0) / 18) || 4));
16442
16448
  if (nVid < canVid) {
16443
- const cc = canhClip(currentProject, mauPd, kb);
16449
+ const cc = canhClip(currentProject, mauPd, kb, canVid - nVid);
16444
16450
  const r = await taoTramOmni(cc || kb && kb.canh || [], { toiDa: canVid - nVid, giay: 4, tran: 40, daXep: !!cc, bao: (st) => setExporting({ percent: 1, step: "T\u1EA1o clip tr\xE1m Omni (c\xF3 credit) " + st }) });
16445
16451
  window.__omniXuat = r;
16446
16452
  }
@@ -18211,7 +18217,7 @@ function datCauLenh(a) {
18211
18217
  on2 = true;
18212
18218
  window.addEventListener("message", async (ev) => {
18213
18219
  const d = ev.data;
18214
- if (!d || d.xvaiLoi140209 !== true) return;
18220
+ if (!d || d.xvaiLoi140229 !== true) return;
18215
18221
  const o = String(ev.origin || "");
18216
18222
  if (!(o.indexOf("https://flow.google.com") === 0 || o.indexOf("https://labs.google") === 0)) return;
18217
18223
  const tra = (kq) => {
@@ -18234,24 +18240,6 @@ function datCauLenh(a) {
18234
18240
  const p = api.project;
18235
18241
  return tra({ id: p && p.id, ten: p && p.name, doan: p && p.timeline ? p.timeline.length : 0, fx: p && p.studioFx || null, sua: p && p.speechEdit && p.speechEdit.metrics || null, xuat: api.exporting || null, phim: api.blob ? api.blob.size : 0, pro: pro ? pro.trangThai() : null });
18236
18242
  }
18237
- if (d.lenh === "datFx") {
18238
- api.setProject((c) => c ? { ...c, studioFx: { ...c.studioFx || {}, ...d.fx || {} } } : c);
18239
- return tra("ok");
18240
- }
18241
- if (d.lenh === "tuyChon") return tra(pro ? pro.dat(d.tuyChon || {}) : "CHUA CO BANG HAU KY");
18242
- if (d.lenh === "tuDongPro") {
18243
- if (!pro) return tra("CHUA CO BANG HAU KY");
18244
- pro.tuDong();
18245
- return tra("ok");
18246
- }
18247
- if (d.lenh === "xuat") {
18248
- api.xuat();
18249
- return tra("ok");
18250
- }
18251
- if (d.lenh === "dongXuat") {
18252
- api.dongXuat();
18253
- return tra("ok");
18254
- }
18255
18243
  if (d.lenh === "taiPhim") {
18256
18244
  await api.tai();
18257
18245
  return tra("ok");
@@ -18269,14 +18257,6 @@ function datCauLenh(a) {
18269
18257
  const text2 = JSON.stringify(api.project), a2 = Number(d.tu) || 0, b = Math.min(text2.length, Number(d.den) || text2.length);
18270
18258
  return tra({ size: text2.length, tu: a2, den: b, text: text2.slice(a2, b) });
18271
18259
  }
18272
- if (d.lenh === "datXuatNhanh") {
18273
- window.__xuatNhanh = !!d.bat;
18274
- return tra("ok");
18275
- }
18276
- if (d.lenh === "datMauPhuDe") {
18277
- window.__mauPhuDe = d.mau ? String(d.mau) : "";
18278
- return tra("ok");
18279
- }
18280
18260
  if (d.lenh === "napLoi") return tra(await napLoi(d));
18281
18261
  if (d.lenh === "taoTramOmni") return tra(await taoTramOmni(d.canh || [], d));
18282
18262
  if (d.lenh === "cauApp") return tra(cauApp(d));
@@ -18293,10 +18273,10 @@ var sfx_kho_default = { "bong_001.ogg": "T2dnUwACAAAAAAAAAAABSQAAAAAAANTOBngBHgF
18293
18273
  // loi/tuyChonBen.ts
18294
18274
  var KHOA_TUY_CHON = ["xvaiNhipCham", "xvaiChuoiTram", "xvaiToanKhung", "xvaiNhacMuc", "xvaiNhac", "xvaiTramDai", "xvaiSfxCach", "xvaiMau", "xvaiAm", "xvaiKieuChu", "xvaiDem", "xvaiTuDien", "xvaiNguonTram", "xvaiTranAnh", "xvaiPhuDe"];
18295
18275
  var G4 = globalThis;
18296
- var khoa = () => Array.isArray(G4.__khoaTuyChon) ? G4.__khoaTuyChon : KHOA_TUY_CHON;
18276
+ var khoa2 = () => Array.isArray(G4.__khoaTuyChon) ? G4.__khoaTuyChon : KHOA_TUY_CHON;
18297
18277
  var anh = () => {
18298
18278
  const o = {};
18299
- for (const k of khoa()) {
18279
+ for (const k of khoa2()) {
18300
18280
  try {
18301
18281
  const v = localStorage.getItem(k);
18302
18282
  if (v != null) o[k] = v;
@@ -18318,7 +18298,7 @@ async function khoiPhucTuyChon() {
18318
18298
  let n = 0;
18319
18299
  try {
18320
18300
  const o = await hoiNgoai("lay", "tuyChon");
18321
- if (o && typeof o === "object") for (const k of khoa()) {
18301
+ if (o && typeof o === "object") for (const k of khoa2()) {
18322
18302
  if (typeof o[k] === "string" && localStorage.getItem(k) == null) {
18323
18303
  localStorage.setItem(k, o[k]);
18324
18304
  n++;
@@ -18332,11 +18312,11 @@ async function khoiPhucTuyChon() {
18332
18312
  const S = Storage.prototype, set = S.setItem, rm = S.removeItem;
18333
18313
  S.setItem = function(k, v) {
18334
18314
  set.call(this, k, v);
18335
- if (this === localStorage && khoa().indexOf(k) >= 0) (G4.__luuTuyChon || luu)();
18315
+ if (this === localStorage && khoa2().indexOf(k) >= 0) (G4.__luuTuyChon || luu)();
18336
18316
  };
18337
18317
  S.removeItem = function(k) {
18338
18318
  rm.call(this, k);
18339
- if (this === localStorage && khoa().indexOf(k) >= 0) (G4.__luuTuyChon || luu)();
18319
+ if (this === localStorage && khoa2().indexOf(k) >= 0) (G4.__luuTuyChon || luu)();
18340
18320
  };
18341
18321
  }
18342
18322
  return n;
@@ -18863,7 +18843,7 @@ var SuaLich = ({ ten, onDong }) => {
18863
18843
  const S = p && p.speechDraft && p.speechDraft.analysis && p.speechDraft.analysis.silences || [];
18864
18844
  return Array.isArray(w) ? canVung(w, S) : [];
18865
18845
  })();
18866
- const khoa2 = (r) => r.t0g !== void 0 ? r.t0g : r.t0;
18846
+ const khoa3 = (r) => r.t0g !== void 0 ? r.t0g : r.t0;
18867
18847
  const luuCat = (n) => {
18868
18848
  setCatTay(n);
18869
18849
  G6.__catTay = n;
@@ -18872,7 +18852,7 @@ var SuaLich = ({ ten, onDong }) => {
18872
18852
  } catch (e) {
18873
18853
  }
18874
18854
  };
18875
- const ids = (r) => Array.isArray(r.ids) ? r.ids : [khoa2(r)];
18855
+ const ids = (r) => Array.isArray(r.ids) ? r.ids : [khoa3(r)];
18876
18856
  const daCat = (w) => catTay.some((r) => ids(r).some((x) => Math.abs(x - w.t0g) < 0.01));
18877
18857
  const batCat = async (w) => {
18878
18858
  const chon = /* @__PURE__ */ new Set();