xvai-loi 0.1.35 → 0.1.37

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 +64 -7
package/co.txt CHANGED
@@ -1 +1 @@
1
- xvaiLoi100001
1
+ xvaiLoi100036
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xvai-loi",
3
- "version": "0.1.35",
3
+ "version": "0.1.37",
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
@@ -11524,13 +11524,18 @@ function lapCuongMe(o) {
11524
11524
  nS++;
11525
11525
  }
11526
11526
  }
11527
+ if (Array.isArray(sua.them)) for (const t of sua.them) {
11528
+ if (!t || typeof t.f !== "number" || !(t.d > 0.3)) continue;
11529
+ sp.push({ id: idC({ f: +t.f, bo: ["depth", "anh", "cut", "tron"].includes(t.bo) ? t.bo : "depth" }), f: +t.f, d: +t.d, bo: ["depth", "anh", "cut", "tron"].includes(t.bo) ? t.bo : "depth", giant: String(t.giant || ""), chu: String(t.chu || ""), chu2: String(t.chu2 || ""), ten: String(t.ten || ""), st: String(t.st || ""), khoa: 1, dSua: 1, moi: 1, keu: 1 });
11530
+ nS++;
11531
+ }
11527
11532
  const sp2 = sp.filter((s) => !s.xoa);
11528
11533
  sp.length = 0;
11529
11534
  sp.push(...sp2);
11530
11535
  sp.sort((p, q) => p.f - q.f);
11531
11536
  for (let i = 0; i + 1 < sp.length; i++) {
11532
11537
  const s = sp[i];
11533
- if (s.dSua && s.f + s.d > sp[i + 1].f + 0.05) s.d = Math.max(0.4, +(sp[i + 1].f - s.f).toFixed(2));
11538
+ if ((s.dSua || sp[i + 1].moi) && s.f + s.d > sp[i + 1].f + 0.05) s.d = Math.max(0.4, +(sp[i + 1].f - s.f).toFixed(2));
11534
11539
  }
11535
11540
  G2.__lichSuaDaAp = nS;
11536
11541
  ghiL("bo", { bo: "sua-tay" }, "sua tay: " + nS + " truong");
@@ -16003,6 +16008,17 @@ function qcBaoCao(project, seconds) {
16003
16008
  return "Phim " + dur.toFixed(1) + " s \xB7 xu\u1EA5t " + Math.round(seconds) + " s \xB7 " + subs.length + " trang ch\u1EEF (t\u1ED1i \u0111a " + maxWords + " t\u1EEB) \xB7 " + pills.length + " th\u1EBB nh\u1EA5n \xB7 " + ills.length + " \u1EA3nh (" + (dur ? Math.round(illSec / dur * 100) : 0) + " % th\u1EDDi l\u01B0\u1EE3ng) \xB7 ch\u1EEF n\xE9 m\u1EB7t " + placed + "/" + (subs.length + pills.length) + " \xB7 hook 3 s: " + (hook ? "c\xF3" : "kh\xF4ng") + " \xB7 ch\u1ED1ng rung " + (fx.stabilize ?? 1) + " \xB7 l\xE0m \u0111\u1EB9p " + (fx.beauty ?? 2) + " \xB7 s\u1EA1ch ti\u1EBFng " + (fx.voice ?? 1) + " \xB7 r\u0103ng " + (fx.teeth ?? 1 ? "b\u1EADt" : "t\u1EAFt") + " \xB7 r\xFAt l\u1EB7ng " + rut.toFixed(1) + " s" + mau7;
16004
16009
  }
16005
16010
 
16011
+ // flow-src/engine/lichV2.ts
16012
+ var idCanh = (f2, bo4) => Math.round(f2 * 10) + "-" + bo4;
16013
+ function tuSp(duAn, sp, sua, daiS) {
16014
+ const canh = (sp || []).map((s) => ({ id: s.id || idCanh(s.f, s.bo), f: +(+s.f).toFixed(2), d: +(+s.d).toFixed(2), bo: s.bo, giant: s.giant || "", chu: s.chu || "", chu2: s.chu2 || "", st: s.st || "", ten: s.ten || "", tieu: s.tieu || "", aiTao: s.khoa ? 0 : 1, khoa: s.khoa ? 1 : 0 }));
16015
+ for (const t of sua && Array.isArray(sua.them) ? sua.them : []) if (t && typeof t.f === "number") canh.push({ id: idCanh(t.f, t.bo || "depth"), f: +(+t.f).toFixed(2), d: +(+t.d).toFixed(2), bo: t.bo || "depth", giant: t.giant || "", chu: t.chu || "", ten: t.ten || "", aiTao: 0, khoa: 1, moi: 1 });
16016
+ canh.sort((a, b) => a.f - b.f);
16017
+ const ts2 = /* @__PURE__ */ new Map();
16018
+ for (const c of canh) if (c.ten) ts2.set(c.ten, { ten: c.ten, loai: "anh" });
16019
+ return { v: 2, duAn, luc: Date.now(), nguon: { daiS: +daiS.toFixed(2) }, quyetDinh: { canh }, taiSan: [...ts2.values()] };
16020
+ }
16021
+
16006
16022
  // flow-src/utils.ts
16007
16023
  var sanitizeFilename = (name) => {
16008
16024
  const str = name.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[đĐ]/g, "d").replace(/([^0-9a-z-\s])/g, "").replace(/(\s+)/g, "-").replace(/-+/g, "-").replace(/^-+|-+$/g, "");
@@ -17370,7 +17386,18 @@ async function handleExport(currentProject, setExporting, setExportedBlob, addLo
17370
17386
  async function handleExportProject(currentProject, showToast) {
17371
17387
  if (!currentProject) return;
17372
17388
  try {
17373
- const data = JSON.stringify(currentProject, null, 2);
17389
+ const G = globalThis;
17390
+ let lichV2 = void 0;
17391
+ try {
17392
+ if (Array.isArray(G.__lichSp) && G.__lichSp.length) {
17393
+ const tl = currentProject.timeline || [];
17394
+ const dai2 = tl.reduce((a, c) => a + Math.max(0, (+c.trimEnd || 0) - (+c.trimStart || 0)), 0);
17395
+ lichV2 = tuSp(currentProject.name || currentProject.id, G.__lichSp, G.__lichSua, dai2);
17396
+ G.__lichV2 = lichV2;
17397
+ }
17398
+ } catch (e) {
17399
+ }
17400
+ const data = JSON.stringify(lichV2 ? { ...currentProject, lichV2 } : currentProject, null, 2);
17374
17401
  const base64 = btoa(unescape(encodeURIComponent(data)));
17375
17402
  const filename = `project-${currentProject.id.slice(0, 8)}.json`;
17376
17403
  await Flow.download({ base64, mimeType: "application/json", filename });
@@ -18962,7 +18989,7 @@ async function napLoi(d) {
18962
18989
  return "LOI: " + String(e && e.message || e).slice(0, 300);
18963
18990
  }
18964
18991
  }
18965
- var LOI_URL = "https://cdn.jsdelivr.net/npm/xvai-loi@0.1.34/nap.js";
18992
+ var LOI_URL = "https://cdn.jsdelivr.net/npm/xvai-loi@0.1.36/nap.js";
18966
18993
  var TRONG_LOI = !!globalThis.__xvaiReact;
18967
18994
  try {
18968
18995
  if (!TRONG_LOI) setTimeout(() => {
@@ -18992,7 +19019,7 @@ function datCauLenh(a) {
18992
19019
  on2 = true;
18993
19020
  window.addEventListener("message", async (ev) => {
18994
19021
  const d = ev.data;
18995
- if (!d || d.xvaiLoi100001 !== true) return;
19022
+ if (!d || d.xvaiLoi100036 !== true) return;
18996
19023
  const o = String(ev.origin || "");
18997
19024
  if (!(o.indexOf("https://flow.google.com") === 0 || o.indexOf("https://labs.google") === 0)) return;
18998
19025
  const tra = (kq) => {
@@ -19121,10 +19148,38 @@ var SuaLich = ({ ten, onDong }) => {
19121
19148
  setSua(n);
19122
19149
  G.__lichSua = n;
19123
19150
  };
19151
+ const [ls, setLs] = useState([]);
19152
+ const [them, setThem] = useState({ f: 0, d: 2, bo: "depth", giant: "", ten: "" });
19153
+ useEffect(() => {
19154
+ (async () => {
19155
+ const d = await docDem("lichSuaLS:" + ten);
19156
+ if (d && Array.isArray(d.ds)) setLs(d.ds);
19157
+ })();
19158
+ }, [ten]);
19124
19159
  const luu = async () => {
19125
19160
  G.__lichSua = sua;
19126
19161
  await ghiDem("lichSua:" + ten, { sua });
19127
- setBao("\u0110\xE3 l\u01B0u " + Object.keys(sua).length + " c\u1EA3nh s\u1EEDa tay \xB7 b\u1EA5m V\u1EBD l\u1EA1i \u0111\u1EC3 \xE1p");
19162
+ const t = Date.now();
19163
+ await ghiDem("lichSua:" + ten + ":" + t, { sua });
19164
+ const ds3 = [t, ...ls].slice(0, 10);
19165
+ setLs(ds3);
19166
+ await ghiDem("lichSuaLS:" + ten, { ds: ds3 });
19167
+ setBao("\u0110\xE3 l\u01B0u " + Object.keys(sua).length + " c\u1EA3nh s\u1EEDa tay (b\u1EA3n " + new Date(t).toTimeString().slice(0, 5) + ") \xB7 b\u1EA5m V\u1EBD l\u1EA1i \u0111\u1EC3 \xE1p");
19168
+ };
19169
+ const napBan = async (t) => {
19170
+ const d = await docDem("lichSua:" + ten + ":" + t);
19171
+ if (d && d.sua) {
19172
+ setSua(d.sua);
19173
+ G.__lichSua = d.sua;
19174
+ setBao("\u0110\xE3 n\u1EA1p b\u1EA3n " + new Date(t).toTimeString().slice(0, 5) + " \xB7 b\u1EA5m V\u1EBD l\u1EA1i \u0111\u1EC3 \xE1p");
19175
+ }
19176
+ };
19177
+ const themCanh = () => {
19178
+ if (!(them.d > 0.3)) return;
19179
+ const n = { ...sua, them: [...sua.them || [], { ...them, f: +them.f, d: +them.d }] };
19180
+ setSua(n);
19181
+ G.__lichSua = n;
19182
+ setBao("\u0110\xE3 th\xEAm c\u1EA3nh " + them.bo + " \u1EDF " + (+them.f).toFixed(1) + " s \xB7 L\u01B0u r\u1ED3i V\u1EBD l\u1EA1i");
19128
19183
  };
19129
19184
  const veLai = async () => {
19130
19185
  await luu();
@@ -19144,7 +19199,9 @@ var SuaLich = ({ ten, onDong }) => {
19144
19199
  if (!ds2.length) return /* @__PURE__ */ shim_react_default.createElement("div", { className: "rounded-xl border border-[#2C4A73] p-4 text-[12px]" }, 'Ch\u01B0a c\xF3 l\u1ECBch d\u1EF1ng \u2014 b\u1EA5m "L\xE0m pro" m\u1ED9t l\u1EA7n r\u1ED3i quay l\u1EA1i \u0111\xE2y. ', /* @__PURE__ */ shim_react_default.createElement("button", { className: nut3, onClick: onDong }, "\u0110\xF3ng"));
19145
19200
  return /* @__PURE__ */ shim_react_default.createElement("div", { className: "rounded-xl border border-[#F6D178]/60 p-3 text-[12px] bg-[#0E2240]" }, /* @__PURE__ */ shim_react_default.createElement("div", { className: "flex items-center gap-2 mb-2" }, /* @__PURE__ */ shim_react_default.createElement("span", { className: "font-black text-[#F6D178]" }, "S\u1EECA L\u1ECACH D\u1EF0NG \xB7 ", ds2.length, " c\u1EA3nh"), /* @__PURE__ */ shim_react_default.createElement("span", { className: "text-[#A2B2C9] flex-1" }, bao), /* @__PURE__ */ shim_react_default.createElement("button", { className: nut3, onClick: luu }, "L\u01B0u"), /* @__PURE__ */ shim_react_default.createElement("button", { className: nut3 + " bg-[#F6D178] text-[#122238]", onClick: veLai }, "V\u1EBD l\u1EA1i"), /* @__PURE__ */ shim_react_default.createElement("button", { className: nut3, onClick: xoaHet }, "B\u1ECF s\u1EEDa"), /* @__PURE__ */ shim_react_default.createElement("button", { className: nut3, onClick: () => {
19146
19201
  setDs(G.__lichSp || []);
19147
- } }, "N\u1EA1p l\u1EA1i"), /* @__PURE__ */ shim_react_default.createElement("button", { className: nut3, onClick: onDong }, "\u0110\xF3ng")), /* @__PURE__ */ shim_react_default.createElement("div", { className: "max-h-[60vh] overflow-auto" }, /* @__PURE__ */ shim_react_default.createElement("table", { className: "w-full text-[11px]" }, /* @__PURE__ */ shim_react_default.createElement("thead", null, /* @__PURE__ */ shim_react_default.createElement("tr", { className: "text-[#A2B2C9]" }, /* @__PURE__ */ shim_react_default.createElement("th", { className: "text-left" }, "#"), /* @__PURE__ */ shim_react_default.createElement("th", { className: "text-left" }, "gi\xE2y"), /* @__PURE__ */ shim_react_default.createElement("th", { className: "text-left" }, "b\u1ED1 c\u1EE5c"), /* @__PURE__ */ shim_react_default.createElement("th", { className: "text-left" }, "\u0111\u1EA7u/d\xE0i (s)"), /* @__PURE__ */ shim_react_default.createElement("th", { className: "text-left" }, "ch\u1EEF nh\u1EA5n"), /* @__PURE__ */ shim_react_default.createElement("th", { className: "text-left" }, "ch\u1EEF ph\u1EE5"), /* @__PURE__ */ shim_react_default.createElement("th", { className: "text-left" }, "icon"), /* @__PURE__ */ shim_react_default.createElement("th", { className: "text-left" }, "\u1EA3nh (t\xEAn kho)"), /* @__PURE__ */ shim_react_default.createElement("th", null, "xo\xE1"))), /* @__PURE__ */ shim_react_default.createElement("tbody", null, ds2.map((s) => {
19202
+ } }, "N\u1EA1p l\u1EA1i"), /* @__PURE__ */ shim_react_default.createElement("button", { className: nut3, onClick: onDong }, "\u0110\xF3ng"), ls.length ? /* @__PURE__ */ shim_react_default.createElement("select", { className: "bg-[#0B1A2D] border border-[#2C4A73] rounded px-1 text-[11px]", value: "", onChange: (ev) => {
19203
+ if (ev.target.value) napBan(+ev.target.value);
19204
+ } }, /* @__PURE__ */ shim_react_default.createElement("option", { value: "" }, "b\u1EA3n c\u0169\u2026"), ls.map((t) => /* @__PURE__ */ shim_react_default.createElement("option", { key: t, value: t }, new Date(t).toLocaleString("vi")))) : null), /* @__PURE__ */ shim_react_default.createElement("div", { className: "flex items-center gap-1 mb-2 text-[11px] flex-wrap" }, /* @__PURE__ */ shim_react_default.createElement("span", { className: "text-[#A2B2C9]" }, "Th\xEAm c\u1EA3nh:"), /* @__PURE__ */ shim_react_default.createElement("input", { className: "w-12 bg-[#0B1A2D] border border-[#2C4A73] rounded px-1", type: "number", step: "0.1", value: them.f, onChange: (ev) => setThem({ ...them, f: ev.target.value }), title: "gi\xE2y \u0111\u1EA7u" }), /* @__PURE__ */ shim_react_default.createElement("input", { className: "w-12 bg-[#0B1A2D] border border-[#2C4A73] rounded px-1", type: "number", step: "0.1", value: them.d, onChange: (ev) => setThem({ ...them, d: ev.target.value }), title: "d\xE0i (s)" }), /* @__PURE__ */ shim_react_default.createElement("select", { className: "bg-[#0B1A2D] border border-[#2C4A73] rounded px-1", value: them.bo, onChange: (ev) => setThem({ ...them, bo: ev.target.value }) }, /* @__PURE__ */ shim_react_default.createElement("option", { value: "depth" }, "ch\u1EEF nh\u1EA5n"), /* @__PURE__ */ shim_react_default.createElement("option", { value: "anh" }, "\u1EA3nh to\xE0n khung"), /* @__PURE__ */ shim_react_default.createElement("option", { value: "cut" }, "c\u1EAFt ch\u1EEF"), /* @__PURE__ */ shim_react_default.createElement("option", { value: "tron" }, "\xF4 tr\xF2n")), /* @__PURE__ */ shim_react_default.createElement("input", { className: "w-28 bg-[#0B1A2D] border border-[#2C4A73] rounded px-1", placeholder: "ch\u1EEF nh\u1EA5n", value: them.giant, onChange: (ev) => setThem({ ...them, giant: ev.target.value }) }), /* @__PURE__ */ shim_react_default.createElement("input", { className: "w-24 bg-[#0B1A2D] border border-[#2C4A73] rounded px-1", placeholder: "\u1EA3nh: trang:\u2026", value: them.ten, onChange: (ev) => setThem({ ...them, ten: ev.target.value }) }), /* @__PURE__ */ shim_react_default.createElement("button", { className: nut3, onClick: themCanh }, "+ Th\xEAm"), (sua.them || []).length ? /* @__PURE__ */ shim_react_default.createElement("span", { className: "text-[#F6D178]" }, (sua.them || []).length, " c\u1EA3nh th\xEAm") : null), /* @__PURE__ */ shim_react_default.createElement("div", { className: "max-h-[60vh] overflow-auto" }, /* @__PURE__ */ shim_react_default.createElement("table", { className: "w-full text-[11px]" }, /* @__PURE__ */ shim_react_default.createElement("thead", null, /* @__PURE__ */ shim_react_default.createElement("tr", { className: "text-[#A2B2C9]" }, /* @__PURE__ */ shim_react_default.createElement("th", { className: "text-left" }, "#"), /* @__PURE__ */ shim_react_default.createElement("th", { className: "text-left" }, "gi\xE2y"), /* @__PURE__ */ shim_react_default.createElement("th", { className: "text-left" }, "b\u1ED1 c\u1EE5c"), /* @__PURE__ */ shim_react_default.createElement("th", { className: "text-left" }, "\u0111\u1EA7u/d\xE0i (s)"), /* @__PURE__ */ shim_react_default.createElement("th", { className: "text-left" }, "ch\u1EEF nh\u1EA5n"), /* @__PURE__ */ shim_react_default.createElement("th", { className: "text-left" }, "ch\u1EEF ph\u1EE5"), /* @__PURE__ */ shim_react_default.createElement("th", { className: "text-left" }, "icon"), /* @__PURE__ */ shim_react_default.createElement("th", { className: "text-left" }, "\u1EA3nh (t\xEAn kho)"), /* @__PURE__ */ shim_react_default.createElement("th", null, "xo\xE1"))), /* @__PURE__ */ shim_react_default.createElement("tbody", null, ds2.map((s) => {
19148
19205
  const e = sua[s.id] || sua[s.i] || {};
19149
19206
  const v = (k) => (typeof e[k] === "string" ? e[k] : s[k]) || "";
19150
19207
  return /* @__PURE__ */ shim_react_default.createElement("tr", { key: s.id || s.i, className: e.xoa ? "opacity-40" : s.khoa ? "bg-[#1E3A5F]/40" : "" }, /* @__PURE__ */ shim_react_default.createElement("td", null, s.i), /* @__PURE__ */ shim_react_default.createElement("td", null, s.f.toFixed(1), "\u2013", (s.f + s.d).toFixed(1)), /* @__PURE__ */ shim_react_default.createElement("td", null, s.bo), /* @__PURE__ */ shim_react_default.createElement("td", { className: "whitespace-nowrap" }, /* @__PURE__ */ shim_react_default.createElement("input", { className: "w-12 bg-[#0B1A2D] border border-[#2C4A73] rounded px-1", value: typeof e.f === "number" ? e.f : s.f, onChange: (ev) => dat(s.id || String(s.i), "f", +ev.target.value), type: "number", step: "0.1" }), " ", /* @__PURE__ */ shim_react_default.createElement("input", { className: "w-12 bg-[#0B1A2D] border border-[#2C4A73] rounded px-1", value: typeof e.d === "number" ? e.d : s.d, onChange: (ev) => dat(s.id || String(s.i), "d", +ev.target.value), type: "number", step: "0.1", min: "0.4" })), /* @__PURE__ */ shim_react_default.createElement("td", null, /* @__PURE__ */ shim_react_default.createElement("input", { className: "w-full bg-[#0B1A2D] border border-[#2C4A73] rounded px-1", value: v("giant"), onChange: (ev) => dat(s.id || String(s.i), "giant", ev.target.value) })), /* @__PURE__ */ shim_react_default.createElement("td", null, /* @__PURE__ */ shim_react_default.createElement("input", { className: "w-full bg-[#0B1A2D] border border-[#2C4A73] rounded px-1", value: v("chu2") || v("chu"), onChange: (ev) => dat(s.id || String(s.i), s.chu2 || !s.chu ? "chu2" : "chu", ev.target.value) })), /* @__PURE__ */ shim_react_default.createElement("td", null, /* @__PURE__ */ shim_react_default.createElement("input", { className: "w-20 bg-[#0B1A2D] border border-[#2C4A73] rounded px-1", value: v("st"), onChange: (ev) => dat(s.id || String(s.i), "st", ev.target.value), placeholder: "tich/luu\u2026" })), /* @__PURE__ */ shim_react_default.createElement("td", null, /* @__PURE__ */ shim_react_default.createElement("input", { className: "w-24 bg-[#0B1A2D] border border-[#2C4A73] rounded px-1", value: v("ten"), onChange: (ev) => dat(s.id || String(s.i), "ten", ev.target.value), placeholder: "trang:\u2026 / anh:\u2026" })), /* @__PURE__ */ shim_react_default.createElement("td", { className: "text-center" }, /* @__PURE__ */ shim_react_default.createElement("input", { type: "checkbox", checked: !!e.xoa, onChange: (ev) => dat(s.id || String(s.i), "xoa", ev.target.checked ? 1 : 0) })));
@@ -19152,7 +19209,7 @@ var SuaLich = ({ ten, onDong }) => {
19152
19209
  };
19153
19210
 
19154
19211
  // loi/vo-flow.tsx
19155
- var PHIEN_BAN = "loi-0910M";
19212
+ var PHIEN_BAN = "loi-1010A";
19156
19213
  var TRONG = () => migrateProject({ id: crypto.randomUUID(), name: "D\u1EF1 \xE1n m\u1EDBi", scenes: [], timeline: [], images: [null, null, null] });
19157
19214
  var nut4 = "px-3 py-1.5 rounded-lg border border-[#2C4A73] text-[11px] font-bold text-[#A2B2C9] hover:text-[#F6D178] hover:border-[#F6D178]/60";
19158
19215
  var Vo = () => {