@celljs/ta-moves 0.0.0-stage → 4.30.0

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.
package/README.en.md ADDED
@@ -0,0 +1,11 @@
1
+ # @celljs/ta-moves
2
+
3
+ Adds clips you made or filmed to the moves of the person of video calls; they play with her own. Design: `docs/design/ta-call.md` 16.
4
+
5
+ - **Where**: Settings → "Moves in video calls" (in the Ta group, beside "Lifelike mouth in video calls"). The package can be turned off in Extensions.
6
+ - **The clip**: a video of 1 to 12 s, made 24 frames a second, 720 × 1178, H.264 without sound; best when it begins and ends with her seated on the sofa as in her own clips. When an end is far from that (the root mean square of the grey over 8%), half a second of it is blended into her seated picture, and the settings say so. Use only clips you filmed or may use.
7
+ - **Kinds**: as she says it (once), after she says it (once, she may stand up: it is framed by how the picture moves, the camera drawing back), or a loop while she listens, thinks or speaks. Loops are kept in `~/.ta/agent/call-moves/loops/`, those played once in `once/`, the list in `moves.json`; never in Ta's files.
8
+ - **Bringing it**: a move played once has the words that bring it, and she does it as she says one; Ta is told the moves and their words in the scene of the call. "In place of" makes it take the place of her own move of that name (wave, heart…).
9
+ - **Falling back**: a clip that cannot be read or decoded gives way to her own move in that call; its row in the settings says why, with Try again.
10
+ - **Mouth**: with "Lifelike mouth" (`@celljs/ta-lips`) set up, it asks this package for the clips (the host method `clips`), finds her face in them and prepares them, and draws her mouth on them as on her own.
11
+ - **Host methods** (`callPackageHost` / `ta call @celljs/ta-moves <method>`): `list`, `begin` / `put` / `finish` (the clip in pieces, then made), `clip` (its bytes, base64), `clips` (paths for the mouth), `remove`, `failed`, `retry`. Needs ffmpeg and ffprobe on the computer.
package/README.md CHANGED
@@ -1,3 +1,11 @@
1
- # Temporary Holding Version
1
+ # @celljs/ta-moves
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 把你自己生成或拍摄的片段加进视频通话形象的动作库,通话时和她自带的动作一起出现。设计见 `docs/design/ta-call.md` 16。
4
+
5
+ - **从哪里进**:设置 → “视频通话的动作”(和“视频通话口型更真”同在 Ta 分组)。可在扩展里关掉这个包。
6
+ - **片段要求**:1–12 秒的视频,会统一成每秒 24 帧、720 × 1178、H.264、无声;开头和结尾最好是她坐在沙发上、和自带片段一样的样子。首尾帧和坐姿差得多(灰度均方差超过 8%)时,首尾各补 0.5 秒交叉淡化回坐姿,并在设置里说明。请只用自己拍摄或有权使用的片段。
7
+ - **类型**:说那句话时(一次)、说完以后(一次,可以站起来;会按画面变化算出取景,镜头跟着后拉)、听 / 想 / 说时的循环。循环段放在 `~/.ta/agent/call-moves/loops/`,一次性段在 `once/`,清单 `moves.json`;不进 Ta 的文件。
8
+ - **叫出来**:一次性动作填“触发的话”,她说到其中一句时做;Ta 从通话场景里知道有哪些动作和对应的话。选“替换自带的”时,同名的自带动作(挥手、比心……)换成你的。
9
+ - **回落**:片段读不到或解码失败时,这次通话用她自带的动作代替,设置里那一行写明原因,可“再试一次”。
10
+ - **口型**:装了“视频通话口型更真”(`@celljs/ta-lips`)时,它向本包要片段清单(宿主方法 `clips`),为它们找脸、预算,和自带片段一样画嘴。
11
+ - **宿主方法**(`callPackageHost` / `ta call @celljs/ta-moves <method>`):`list`、`begin` / `put` / `finish`(分块上传并处理)、`clip`(片段字节,base64)、`clips`(给口型用的路径)、`remove`、`failed`、`retry`。需要本机有 ffmpeg 和 ffprobe。
package/host/index.mjs ADDED
@@ -0,0 +1,452 @@
1
+ // web-src/host.ts
2
+ import { spawn } from "node:child_process";
3
+ import { randomBytes } from "node:crypto";
4
+ import { appendFileSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
5
+ import { delimiter, join } from "node:path";
6
+
7
+ // web-src/moves-protocol.ts
8
+ var NAME = "@celljs/ta-moves";
9
+ var WIDTH = 720;
10
+ var HEIGHT = 1178;
11
+ var FPS = 24;
12
+ var MIN_S = 1;
13
+ var MAX_S = 12;
14
+ var MAX_BYTES = 60 * 1024 * 1024;
15
+ var CHUNK_BYTES = 512 * 1024;
16
+ var SEAT_LIMIT = 8;
17
+ var BLEND_S = 0.5;
18
+ var SAMPLE_W = 64;
19
+ var SAMPLE_H = 105;
20
+ var SAMPLE_FPS = 6;
21
+ var MOVE_KINDS = ["say", "after", "listening", "thinking", "speaking"];
22
+ var MoveErrors;
23
+ ((MoveErrors) => {
24
+ const PREFIX = "ta-moves:";
25
+ function error(code, detail = "") {
26
+ return new Error(`${PREFIX}${code}:${detail}`);
27
+ }
28
+ MoveErrors.error = error;
29
+ function of(error2) {
30
+ const message = String(error2?.message ?? error2);
31
+ const at = message.indexOf(PREFIX);
32
+ if (at < 0) {
33
+ return { code: "unknown", detail: message };
34
+ }
35
+ const [code, ...rest] = message.slice(at + PREFIX.length).split(":");
36
+ return { code, detail: rest.join(":") };
37
+ }
38
+ MoveErrors.of = of;
39
+ })(MoveErrors ||= {});
40
+
41
+ // web-src/clip-check.ts
42
+ var SEATED_TOP = 0.115;
43
+ var MOVED = 28;
44
+ var ROW_PIXELS = 2;
45
+ var ENVELOPE = 3;
46
+ var ClipCheck;
47
+ ((ClipCheck) => {
48
+ function distance(a, b) {
49
+ const n = Math.min(a.length, b.length);
50
+ if (!n) {
51
+ return 100;
52
+ }
53
+ let sum = 0;
54
+ for (let i = 0;i < n; i++) {
55
+ const d = a[i] - b[i];
56
+ sum += d * d;
57
+ }
58
+ return Math.round(Math.sqrt(sum / n) / 255 * 1000) / 10;
59
+ }
60
+ ClipCheck.distance = distance;
61
+ function split(bytes, width = SAMPLE_W, height = SAMPLE_H) {
62
+ const size = width * height;
63
+ const frames = [];
64
+ for (let at = 0;at + size <= bytes.length; at += size) {
65
+ frames.push(bytes.subarray(at, at + size));
66
+ }
67
+ return frames;
68
+ }
69
+ ClipCheck.split = split;
70
+ function bodies(frames, clipW, clipH, width = SAMPLE_W, height = SAMPLE_H) {
71
+ const first = frames[0];
72
+ const seated = SEATED_TOP * height;
73
+ const raw = frames.map((frame) => {
74
+ let top = height;
75
+ for (let y = 0;y < height && top === height; y++) {
76
+ let row = 0;
77
+ for (let x = 0;x < width; x++) {
78
+ if (Math.abs(frame[y * width + x] - first[y * width + x]) > MOVED) {
79
+ row++;
80
+ }
81
+ }
82
+ if (row >= ROW_PIXELS) {
83
+ top = y;
84
+ }
85
+ }
86
+ return [0, Math.min(seated, top), width, height];
87
+ });
88
+ const sx = clipW / width;
89
+ const sy = clipH / height;
90
+ return raw.map((_, i) => {
91
+ const near = raw.slice(Math.max(0, i - ENVELOPE), i + ENVELOPE + 1);
92
+ const box = [
93
+ Math.min(...near.map((b) => b[0])),
94
+ Math.min(...near.map((b) => b[1])),
95
+ Math.max(...near.map((b) => b[2])),
96
+ Math.max(...near.map((b) => b[3]))
97
+ ];
98
+ return [Math.round(box[0] * sx), Math.round(box[1] * sy), Math.round(box[2] * sx), Math.round(box[3] * sy)];
99
+ });
100
+ }
101
+ ClipCheck.bodies = bodies;
102
+ function words(text) {
103
+ return [
104
+ ...new Set(text.split(/[,,、;;\n]/).map((word) => word.trim().slice(0, 24)).filter(Boolean))
105
+ ].slice(0, 8);
106
+ }
107
+ ClipCheck.words = words;
108
+ })(ClipCheck ||= {});
109
+
110
+ // web-src/host.ts
111
+ var BUILT_IN = {
112
+ wave: "say",
113
+ laugh: "say",
114
+ heart: "say",
115
+ clap: "say",
116
+ shy: "say",
117
+ happy: "say",
118
+ surprised: "say",
119
+ sorry: "say",
120
+ dance: "after",
121
+ stretch: "after"
122
+ };
123
+ function fileOf(name, kind) {
124
+ return `${kind === "say" || kind === "after" ? "once" : "loops"}/${name}.mp4`;
125
+ }
126
+
127
+ class MovesHost {
128
+ dir;
129
+ faces;
130
+ ffmpeg;
131
+ ffprobe;
132
+ now;
133
+ uploads = new Map;
134
+ constructor(dir, faces, ffmpeg = MovesHost.find("ffmpeg"), ffprobe = MovesHost.find("ffprobe"), now = Date.now) {
135
+ this.dir = dir;
136
+ this.faces = faces;
137
+ this.ffmpeg = ffmpeg;
138
+ this.ffprobe = ffprobe;
139
+ this.now = now;
140
+ }
141
+ sweep() {
142
+ for (const [id, upload] of this.uploads) {
143
+ if (this.now() - upload.at > MovesHost.UPLOAD_IDLE_MS) {
144
+ this.drop(id);
145
+ }
146
+ }
147
+ if (!this.uploads.size) {
148
+ rmSync(join(this.dir, "incoming"), { recursive: true, force: true });
149
+ }
150
+ }
151
+ static UPLOAD_IDLE_MS = 30 * 60 * 1000;
152
+ list() {
153
+ return this.read();
154
+ }
155
+ begin(draft) {
156
+ const title = String(draft?.title ?? "").trim().slice(0, 24);
157
+ const replace = typeof draft?.replace === "string" && typeof BUILT_IN[draft.replace] === "string" ? draft.replace : undefined;
158
+ const kind = replace ? BUILT_IN[replace] : MOVE_KINDS.includes(draft?.kind) ? draft.kind : "say";
159
+ const words = ClipCheck.words((draft?.words ?? []).join(`
160
+ `));
161
+ if (!title) {
162
+ throw MoveErrors.error("no-title");
163
+ }
164
+ if ((kind === "say" || kind === "after") && !words.length && !replace) {
165
+ throw MoveErrors.error("no-words");
166
+ }
167
+ if (!(Number(draft?.size) > 0) || draft.size > MAX_BYTES) {
168
+ throw MoveErrors.error("too-big", MAX_BYTES / 1024 / 1024);
169
+ }
170
+ if (!this.ffmpeg || !this.ffprobe) {
171
+ throw MoveErrors.error("no-ffmpeg");
172
+ }
173
+ this.sweep();
174
+ const id = randomBytes(8).toString("hex");
175
+ const incoming = join(this.dir, "incoming");
176
+ mkdirSync(incoming, { recursive: true });
177
+ const file = join(incoming, id);
178
+ writeFileSync(file, "");
179
+ this.uploads.set(id, { draft: { title, kind, words, replace, size: draft.size }, file, received: 0, at: this.now() });
180
+ return { id };
181
+ }
182
+ put(id, data) {
183
+ const upload = this.upload(id);
184
+ const bytes = Buffer.from(String(data), "base64");
185
+ upload.received += bytes.length;
186
+ upload.at = this.now();
187
+ if (upload.received > MAX_BYTES) {
188
+ this.drop(id);
189
+ throw MoveErrors.error("too-big", MAX_BYTES / 1024 / 1024);
190
+ }
191
+ appendFileSync(upload.file, bytes);
192
+ return { received: upload.received };
193
+ }
194
+ async finish(id) {
195
+ const upload = this.upload(id);
196
+ try {
197
+ return await this.make(upload.file, upload.draft);
198
+ } finally {
199
+ this.drop(id);
200
+ }
201
+ }
202
+ clip(name) {
203
+ const move = this.read().find((one) => one.name === name);
204
+ if (!move) {
205
+ throw new Error(`No move ${name}`);
206
+ }
207
+ return { data: readFileSync(join(this.dir, move.file)).toString("base64") };
208
+ }
209
+ clips() {
210
+ return this.read().filter((move) => !move.problem).map((move) => ({ clip: `own:${move.name}`, path: join(this.dir, move.file) }));
211
+ }
212
+ remove(name) {
213
+ const moves = this.read();
214
+ const move = moves.find((one) => one.name === name);
215
+ if (move) {
216
+ rmSync(join(this.dir, move.file), { force: true });
217
+ }
218
+ return this.write(moves.filter((one) => one.name !== name));
219
+ }
220
+ failed(name, reason) {
221
+ return this.write(this.read().map((move) => move.name === name ? { ...move, problem: String(reason).slice(0, 200) } : move));
222
+ }
223
+ retry(name) {
224
+ return this.write(this.read().map((move) => move.name === name ? { ...move, problem: undefined } : move));
225
+ }
226
+ async make(input, draft) {
227
+ const seconds = await this.duration(input);
228
+ if (seconds < MIN_S) {
229
+ throw MoveErrors.error("too-short", seconds.toFixed(1));
230
+ }
231
+ if (seconds > MAX_S) {
232
+ throw MoveErrors.error("too-long", seconds.toFixed(1));
233
+ }
234
+ const work = `${input}.mp4`;
235
+ const fit = `scale=${WIDTH}:${HEIGHT}:force_original_aspect_ratio=increase,crop=${WIDTH}:${HEIGHT},fps=${FPS},format=yuv420p,setsar=1`;
236
+ await this.encode(["-i", input, "-an", "-vf", fit], work);
237
+ const seated = this.faces && existsSync(join(this.faces, "poster.jpg")) ? join(this.faces, "poster.jpg") : undefined;
238
+ const seat = seated ? ClipCheck.split(await this.run(this.ffmpeg, ["-v", "error", "-i", seated, "-vf", `${fit},${MovesHost.SAMPLE}`, "-f", "rawvideo", "pipe:1"]))[0] : undefined;
239
+ let samples = await this.samples(work);
240
+ const far = (frame) => seat && frame ? ClipCheck.distance(frame, seat) : 0;
241
+ const was = { first: far(samples[0]), last: far(samples[samples.length - 1]) };
242
+ const blended = !!seated && (was.first > SEAT_LIMIT || was.last > SEAT_LIMIT);
243
+ if (seated && blended) {
244
+ await this.blend(work, seated, fit, was.first > SEAT_LIMIT, was.last > SEAT_LIMIT);
245
+ samples = await this.samples(work);
246
+ }
247
+ const name = draft.replace ?? `m${Date.now().toString(36)}`;
248
+ const file = fileOf(name, draft.kind);
249
+ mkdirSync(join(this.dir, file, ".."), { recursive: true });
250
+ const moves = this.read();
251
+ const old = moves.find((one) => one.name === name);
252
+ if (old) {
253
+ rmSync(join(this.dir, old.file), { force: true });
254
+ }
255
+ renameSync(work, join(this.dir, file));
256
+ const move = {
257
+ name,
258
+ title: draft.title,
259
+ kind: draft.kind,
260
+ words: draft.words,
261
+ frames: await this.frames(join(this.dir, file)),
262
+ file,
263
+ seat: was,
264
+ blended,
265
+ ...draft.kind === "after" ? { framing: { rest: [0, 0, WIDTH, HEIGHT], body: ClipCheck.bodies(samples, WIDTH, HEIGHT), fps: SAMPLE_FPS } } : {},
266
+ added: Date.now()
267
+ };
268
+ this.write([move, ...moves.filter((one) => one.name !== name)]);
269
+ return move;
270
+ }
271
+ static SAMPLE = `scale=${SAMPLE_W}:${SAMPLE_H},format=gray`;
272
+ async samples(file) {
273
+ const bytes = await this.run(this.ffmpeg, ["-v", "error", "-i", file, "-vf", `fps=${SAMPLE_FPS},${MovesHost.SAMPLE}`, "-f", "rawvideo", "pipe:1"]);
274
+ const last = await this.run(this.ffmpeg, [
275
+ "-v",
276
+ "error",
277
+ "-sseof",
278
+ "-0.05",
279
+ "-i",
280
+ file,
281
+ "-vf",
282
+ MovesHost.SAMPLE,
283
+ "-frames:v",
284
+ "1",
285
+ "-f",
286
+ "rawvideo",
287
+ "pipe:1"
288
+ ]).catch(() => new Uint8Array);
289
+ return [...ClipCheck.split(bytes), ...ClipCheck.split(last)];
290
+ }
291
+ async blend(work, seated, fit, first, last) {
292
+ const length = await this.frames(work) / FPS;
293
+ const parts = [`[0:v]settb=AVTB[c0]`, `[1:v]${fit},settb=AVTB[p1]`, `[2:v]${fit},settb=AVTB[p2]`];
294
+ let at = "c0";
295
+ if (first) {
296
+ parts.push(`[p1][${at}]xfade=transition=fade:duration=${BLEND_S}:offset=0[c1]`);
297
+ at = "c1";
298
+ }
299
+ if (last) {
300
+ parts.push(`[${at}][p2]xfade=transition=fade:duration=${BLEND_S}:offset=${(length - BLEND_S).toFixed(3)}[c2]`);
301
+ at = "c2";
302
+ }
303
+ const still = ["-loop", "1", "-t", String(BLEND_S), "-i", seated];
304
+ const out = `${work}.blend.mp4`;
305
+ await this.encode(["-i", work, ...still, ...still, "-filter_complex", parts.join(";"), "-map", `[${at}]`], out);
306
+ renameSync(out, work);
307
+ }
308
+ async encode(args, out) {
309
+ await this.run(this.ffmpeg, [
310
+ "-v",
311
+ "error",
312
+ "-y",
313
+ ...args,
314
+ "-c:v",
315
+ "libx264",
316
+ "-preset",
317
+ "veryfast",
318
+ "-crf",
319
+ "22",
320
+ "-movflags",
321
+ "+faststart",
322
+ out
323
+ ]).catch((error) => {
324
+ rmSync(out, { force: true });
325
+ throw MoveErrors.error("not-video", String(error.message).split(`
326
+ `)[0]);
327
+ });
328
+ }
329
+ async duration(file) {
330
+ const text = await this.run(this.ffprobe, [
331
+ "-v",
332
+ "error",
333
+ "-select_streams",
334
+ "v:0",
335
+ "-show_entries",
336
+ "stream=codec_type:format=duration",
337
+ "-of",
338
+ "json",
339
+ file
340
+ ]).catch(() => {
341
+ throw MoveErrors.error("not-video");
342
+ });
343
+ const probed = JSON.parse(Buffer.from(text).toString("utf8"));
344
+ const seconds = Number(probed.format?.duration);
345
+ if (!probed.streams?.length || !Number.isFinite(seconds)) {
346
+ throw MoveErrors.error("not-video");
347
+ }
348
+ return seconds;
349
+ }
350
+ async frames(file) {
351
+ const text = await this.run(this.ffprobe, [
352
+ "-v",
353
+ "error",
354
+ "-select_streams",
355
+ "v:0",
356
+ "-count_packets",
357
+ "-show_entries",
358
+ "stream=nb_read_packets",
359
+ "-of",
360
+ "csv=p=0",
361
+ file
362
+ ]);
363
+ return Number(Buffer.from(text).toString("utf8").trim()) || 0;
364
+ }
365
+ run(command, args) {
366
+ return new Promise((resolve, reject) => {
367
+ if (!command) {
368
+ reject(MoveErrors.error("no-ffmpeg"));
369
+ return;
370
+ }
371
+ const child = spawn(command, args, { stdio: ["ignore", "pipe", "pipe"] });
372
+ const out = [];
373
+ let error = "";
374
+ child.stdout.on("data", (chunk) => out.push(chunk));
375
+ child.stderr.on("data", (chunk) => {
376
+ error = (error + chunk.toString()).slice(-2000);
377
+ });
378
+ child.on("error", reject);
379
+ child.on("exit", (code) => code === 0 ? resolve(new Uint8Array(Buffer.concat(out))) : reject(new Error(error.trim() || `${command} failed (${code})`)));
380
+ });
381
+ }
382
+ upload(id) {
383
+ const upload = this.uploads.get(String(id));
384
+ if (!upload) {
385
+ throw new Error(`No clip coming as ${id}`);
386
+ }
387
+ return upload;
388
+ }
389
+ drop(id) {
390
+ const upload = this.uploads.get(id);
391
+ this.uploads.delete(id);
392
+ if (upload) {
393
+ rmSync(upload.file, { force: true });
394
+ rmSync(`${upload.file}.mp4`, { force: true });
395
+ }
396
+ }
397
+ read() {
398
+ try {
399
+ const file = JSON.parse(readFileSync(join(this.dir, "moves.json"), "utf8"));
400
+ return Array.isArray(file.moves) ? file.moves : [];
401
+ } catch {
402
+ return [];
403
+ }
404
+ }
405
+ write(moves) {
406
+ mkdirSync(this.dir, { recursive: true });
407
+ const file = join(this.dir, "moves.json");
408
+ writeFileSync(`${file}.tmp`, JSON.stringify({ version: 1, moves }, null, 1));
409
+ renameSync(`${file}.tmp`, file);
410
+ return moves;
411
+ }
412
+ static find(name, path = process.env.PATH ?? "") {
413
+ const exe = process.platform === "win32" ? `${name}.exe` : name;
414
+ const dirs = [...path.split(delimiter), "/opt/homebrew/bin", "/usr/local/bin", "/usr/bin"];
415
+ return dirs.map((dir) => join(dir, exe)).find(isFile);
416
+ }
417
+ static faces(root) {
418
+ if (!root) {
419
+ return;
420
+ }
421
+ const built = join(root, "..", "..", "..", "public", "faces");
422
+ return existsSync(join(built, "poster.jpg")) ? built : join(root, "..", "ta-web", "public", "faces");
423
+ }
424
+ }
425
+ function isFile(file) {
426
+ try {
427
+ return statSync(file).isFile();
428
+ } catch {
429
+ return false;
430
+ }
431
+ }
432
+ async function activate(host) {
433
+ const root = (await host.listPackages()).find((pkg) => pkg.name === NAME)?.root;
434
+ const moves = new MovesHost(join(host.agentDir, "call-moves"), MovesHost.faces(root));
435
+ moves.sweep();
436
+ return {
437
+ list: () => moves.list(),
438
+ begin: (draft) => moves.begin(draft),
439
+ put: (id, data) => moves.put(id, data),
440
+ finish: (id) => moves.finish(id),
441
+ clip: (name) => moves.clip(String(name)),
442
+ clips: () => moves.clips(),
443
+ remove: (name) => moves.remove(String(name)),
444
+ failed: (name, reason) => moves.failed(String(name), String(reason)),
445
+ retry: (name) => moves.retry(String(name))
446
+ };
447
+ }
448
+ export {
449
+ activate as default,
450
+ MovesHost,
451
+ BUILT_IN
452
+ };
package/package.json CHANGED
@@ -1,6 +1,64 @@
1
1
  {
2
2
  "name": "@celljs/ta-moves",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "4.30.0",
4
+ "description": "A pi package for Ta: the user's own clips of the person of video calls, checked, made like Ta's own and played with her moves",
5
+ "keywords": [
6
+ "pi-package"
7
+ ],
8
+ "homepage": "https://github.com/cellbang/ta",
9
+ "bugs": {
10
+ "url": "https://github.com/cellbang/ta/issues"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/cellbang/cell.git"
15
+ },
16
+ "license": "MIT",
17
+ "files": [
18
+ "web",
19
+ "host",
20
+ "!**/*.map"
21
+ ],
22
+ "scripts": {
23
+ "build": "tsc -b && bun build web-src/index.tsx --format esm --target browser --outfile web/index.js && bun build web-src/host.ts --format esm --target node --outfile host/index.mjs",
24
+ "clean": "rm -rf lib web host *.tsbuildinfo",
25
+ "test": "bun test ./lib",
26
+ "watch": "tsc -b -w --preserveWatchOutput"
27
+ },
28
+ "devDependencies": {
29
+ "@celljs/ta-protocol": "4.30.0",
30
+ "@celljs/ta-web": "4.30.0",
31
+ "@types/react": "^19.3.0"
32
+ },
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
36
+ "pi": {
37
+ "title": {
38
+ "en": "My moves",
39
+ "zh-CN": "我的动作",
40
+ "zh-TW": "我的動作",
41
+ "ja-JP": "自分の動き"
42
+ },
43
+ "summary": {
44
+ "en": "Add clips you made or filmed of the person of video calls: they play with her own moves, as smoothly, yours first.",
45
+ "zh-CN": "把你自己生成或拍的片段加进视频通话形象的动作里:和她自带的动作一样衔接,同名同类时用你的。",
46
+ "zh-TW": "把你自己生成或拍的片段加進視訊通話形象的動作裡:和她內建的動作一樣銜接,同名同類時用你的。",
47
+ "ja-JP": "自分で作った・撮ったクリップをビデオ通話の人物の動きに追加します。内蔵の動きと同じようになめらかにつながり、同じ名前・種類ならあなたのものが優先です。"
48
+ },
49
+ "icon": "Sparkles",
50
+ "web": [
51
+ "./web/index.js"
52
+ ],
53
+ "host": "./host/index.mjs",
54
+ "permissions": {
55
+ "host": {
56
+ "list": "models.use",
57
+ "clip": "models.use",
58
+ "clips": "models.use",
59
+ "failed": "models.use",
60
+ "*": "settings.manage"
61
+ }
62
+ }
63
+ }
64
+ }
package/web/index.js ADDED
@@ -0,0 +1,556 @@
1
+ // ../ta-protocol/esm/common/language.js
2
+ var TaLanguageUtil;
3
+ (function(TaLanguageUtil2) {
4
+ TaLanguageUtil2.ALL = ["zh-CN", "zh-TW", "en-US", "ja-JP"];
5
+ TaLanguageUtil2.NAMES = { "zh-CN": "简体中文", "zh-TW": "繁體中文", "en-US": "English", "ja-JP": "日本語" };
6
+ function of(tag) {
7
+ const said = (tag !== null && tag !== undefined ? tag : "").toLowerCase().replace(/_/g, "-");
8
+ if (/^zh(\b|-)/.test(said)) {
9
+ return /-hant\b/.test(said) || !/-hans\b/.test(said) && /-(tw|hk|mo)\b/.test(said) ? "zh-TW" : "zh-CN";
10
+ }
11
+ return /^ja(\b|-)/.test(said) ? "ja-JP" : "en-US";
12
+ }
13
+ TaLanguageUtil2.of = of;
14
+ function server(env = typeof process === "undefined" ? {} : process.env) {
15
+ return of(env.TA_LANGUAGE || env.LC_ALL || env.LC_MESSAGES || env.LANG);
16
+ }
17
+ TaLanguageUtil2.server = server;
18
+ function pick(language, words) {
19
+ return words[of(language)];
20
+ }
21
+ TaLanguageUtil2.pick = pick;
22
+ function say(words) {
23
+ return words[server()];
24
+ }
25
+ TaLanguageUtil2.say = say;
26
+ function chinese(language) {
27
+ return of(language).startsWith("zh");
28
+ }
29
+ TaLanguageUtil2.chinese = chinese;
30
+ function cjk(language) {
31
+ return of(language) !== "en-US";
32
+ }
33
+ TaLanguageUtil2.cjk = cjk;
34
+ function list(language, items) {
35
+ return items.join(cjk(language) ? "、" : ", ");
36
+ }
37
+ TaLanguageUtil2.list = list;
38
+ })(TaLanguageUtil || (TaLanguageUtil = {}));
39
+
40
+ // web-src/i18n.ts
41
+ var EN = {
42
+ title: "Moves in video calls",
43
+ section: "Moves",
44
+ hint: "Clips you made or filmed of her, played in video calls with her own moves, yours first.",
45
+ rules: "1 to 12 s, made 24 frames a second and 720 × 1178. Best when it begins and ends with her seated on the sofa as in her own clips; otherwise each end is blended into that half a second.",
46
+ rights: "Use only clips you filmed or may use: no ready-made characters of others under copyright.",
47
+ add: "Add a move",
48
+ file: "Clip",
49
+ pick: "Choose a video",
50
+ name: "Name",
51
+ namePlaceholder: "Spin around",
52
+ kind: "When",
53
+ kinds: {
54
+ say: "As she says it",
55
+ after: "After she says it (she may stand up)",
56
+ listening: "While she listens (a loop)",
57
+ thinking: "While she thinks (a loop)",
58
+ speaking: "While she speaks (a loop)"
59
+ },
60
+ replace: "In place of",
61
+ replaceNone: "None: a new move",
62
+ builtIn: {
63
+ wave: "Wave",
64
+ laugh: "Laugh",
65
+ heart: "Heart",
66
+ clap: "Clap",
67
+ shy: "Shy",
68
+ happy: "Glad",
69
+ surprised: "Surprised",
70
+ sorry: "Sorry",
71
+ dance: "Dance",
72
+ stretch: "Stretch"
73
+ },
74
+ words: "Words that bring it",
75
+ wordsPlaceholder: "spin around, turn around",
76
+ wordsHint: "Separate with commas. She does it as she says one of them; Ta is told them.",
77
+ adding: "Checking and making it… {percent}%",
78
+ added: "Added {name}.",
79
+ blended: "Its ends were far from her seated ({first}% / {last}%), so each was blended into it for half a second.",
80
+ ok: "Plays",
81
+ remove: "Remove",
82
+ retry: "Try again",
83
+ problem: "Her own move plays in its place: {reason}",
84
+ none: "No moves of yours yet.",
85
+ errors: {
86
+ "no-ffmpeg": "Needs ffmpeg on this computer (brew install ffmpeg).",
87
+ "not-video": "Not a video Ta can read.",
88
+ "too-short": "Too short ({detail} s): at least 1 s.",
89
+ "too-long": "Too long ({detail} s): at most 12 s.",
90
+ "too-big": "Too large: at most {detail} MB.",
91
+ "no-words": "Give the words that bring it.",
92
+ "no-title": "Give it a name.",
93
+ unknown: "{detail}"
94
+ }
95
+ };
96
+ var ZH = {
97
+ title: "视频通话的动作",
98
+ section: "动作",
99
+ hint: "你自己生成或拍的她的片段,视频通话时和她自带的动作一起出现,同名同类时用你的。",
100
+ rules: "1–12 秒,会统一成每秒 24 帧、720 × 1178。开头和结尾最好是她坐在沙发上、和自带片段一样的样子;不一样时首尾各补半秒过渡回坐姿。",
101
+ rights: "请只用你自己拍摄或有权使用的片段,不要用受版权保护的现成角色内容。",
102
+ add: "添加动作",
103
+ file: "片段",
104
+ pick: "选择视频",
105
+ name: "名字",
106
+ namePlaceholder: "转个圈",
107
+ kind: "什么时候",
108
+ kinds: { say: "说那句话时", after: "说完以后(可以站起来)", listening: "听你说话时(循环)", thinking: "思考时(循环)", speaking: "说话时(循环)" },
109
+ replace: "替换自带的",
110
+ replaceNone: "不替换,新动作",
111
+ builtIn: {
112
+ wave: "挥手",
113
+ laugh: "大笑",
114
+ heart: "比心",
115
+ clap: "鼓掌",
116
+ shy: "害羞",
117
+ happy: "开心",
118
+ surprised: "惊讶",
119
+ sorry: "抱歉",
120
+ dance: "跳舞",
121
+ stretch: "伸懒腰"
122
+ },
123
+ words: "触发的话",
124
+ wordsPlaceholder: "转个圈,转一圈",
125
+ wordsHint: "用逗号分开。她说到其中一句就做;Ta 也会知道这些话。",
126
+ adding: "正在检查和转换… {percent}%",
127
+ added: "已添加「{name}」。",
128
+ blended: "首尾和坐姿差得较多({first}% / {last}%),已各补半秒过渡回坐姿。",
129
+ ok: "可用",
130
+ remove: "删除",
131
+ retry: "再试一次",
132
+ problem: "用她自带的动作代替:{reason}",
133
+ none: "还没有你自己的动作。",
134
+ errors: {
135
+ "no-ffmpeg": "这台电脑需要装 ffmpeg(brew install ffmpeg)。",
136
+ "not-video": "不是 Ta 能读的视频。",
137
+ "too-short": "太短({detail} 秒),至少 1 秒。",
138
+ "too-long": "太长({detail} 秒),最多 12 秒。",
139
+ "too-big": "文件太大,最多 {detail} MB。",
140
+ "no-words": "请填写触发的话。",
141
+ "no-title": "请起个名字。",
142
+ unknown: "{detail}"
143
+ }
144
+ };
145
+ var ZH_TW = {
146
+ ...ZH,
147
+ title: "視訊通話的動作",
148
+ section: "動作",
149
+ hint: "你自己生成或拍的她的片段,視訊通話時和她內建的動作一起出現,同名同類時用你的。",
150
+ rules: "1–12 秒,會統一成每秒 24 格、720 × 1178。開頭和結尾最好是她坐在沙發上、和內建片段一樣的樣子;不一樣時首尾各補半秒過渡回坐姿。",
151
+ rights: "請只用你自己拍攝或有權使用的片段,不要用受版權保護的現成角色內容。",
152
+ add: "新增動作",
153
+ pick: "選擇影片",
154
+ name: "名字",
155
+ namePlaceholder: "轉個圈",
156
+ kind: "什麼時候",
157
+ kinds: { say: "說那句話時", after: "說完以後(可以站起來)", listening: "聽你說話時(循環)", thinking: "思考時(循環)", speaking: "說話時(循環)" },
158
+ replace: "取代內建的",
159
+ replaceNone: "不取代,新動作",
160
+ builtIn: {
161
+ wave: "揮手",
162
+ laugh: "大笑",
163
+ heart: "比心",
164
+ clap: "鼓掌",
165
+ shy: "害羞",
166
+ happy: "開心",
167
+ surprised: "驚訝",
168
+ sorry: "抱歉",
169
+ dance: "跳舞",
170
+ stretch: "伸懶腰"
171
+ },
172
+ words: "觸發的話",
173
+ wordsPlaceholder: "轉個圈,轉一圈",
174
+ wordsHint: "用逗號分開。她說到其中一句就做;Ta 也會知道這些話。",
175
+ adding: "正在檢查和轉換… {percent}%",
176
+ added: "已新增「{name}」。",
177
+ blended: "首尾和坐姿差得較多({first}% / {last}%),已各補半秒過渡回坐姿。",
178
+ ok: "可用",
179
+ remove: "刪除",
180
+ retry: "再試一次",
181
+ problem: "用她內建的動作代替:{reason}",
182
+ none: "還沒有你自己的動作。",
183
+ errors: {
184
+ "no-ffmpeg": "這台電腦需要安裝 ffmpeg(brew install ffmpeg)。",
185
+ "not-video": "不是 Ta 能讀的影片。",
186
+ "too-short": "太短({detail} 秒),至少 1 秒。",
187
+ "too-long": "太長({detail} 秒),最多 12 秒。",
188
+ "too-big": "檔案太大,最多 {detail} MB。",
189
+ "no-words": "請填寫觸發的話。",
190
+ "no-title": "請取個名字。",
191
+ unknown: "{detail}"
192
+ }
193
+ };
194
+ var JA = {
195
+ ...EN,
196
+ title: "ビデオ通話の動き",
197
+ section: "動き",
198
+ hint: "あなたが作った・撮った彼女のクリップを、ビデオ通話で彼女自身の動きと一緒に使います。同じ名前・種類ならあなたのものが優先です。",
199
+ rules: "1〜12 秒。毎秒 24 コマ、720 × 1178 に揃えます。最初と最後は内蔵クリップと同じくソファに座った姿が最適です。違う場合は両端を 0.5 秒かけて座った姿につなぎます。",
200
+ rights: "自分で撮影したか使用権のあるクリップだけを使ってください。著作権のある既成キャラクターは使わないでください。",
201
+ add: "動きを追加",
202
+ file: "クリップ",
203
+ pick: "動画を選ぶ",
204
+ name: "名前",
205
+ namePlaceholder: "くるっと回る",
206
+ kind: "いつ",
207
+ kinds: {
208
+ say: "その言葉を言うとき",
209
+ after: "言ったあと(立ち上がれます)",
210
+ listening: "聞いているとき(ループ)",
211
+ thinking: "考えているとき(ループ)",
212
+ speaking: "話しているとき(ループ)"
213
+ },
214
+ replace: "置き換える内蔵の動き",
215
+ replaceNone: "なし(新しい動き)",
216
+ builtIn: {
217
+ wave: "手を振る",
218
+ laugh: "笑う",
219
+ heart: "ハート",
220
+ clap: "拍手",
221
+ shy: "照れる",
222
+ happy: "喜ぶ",
223
+ surprised: "驚く",
224
+ sorry: "謝る",
225
+ dance: "踊る",
226
+ stretch: "伸び"
227
+ },
228
+ words: "きっかけの言葉",
229
+ wordsPlaceholder: "回って, くるっと",
230
+ wordsHint: "カンマで区切ります。どれかを言うと動きます。Ta にも伝わります。",
231
+ adding: "確認して変換中… {percent}%",
232
+ added: "「{name}」を追加しました。",
233
+ blended: "最初と最後が座った姿から離れていた({first}% / {last}%)ので、両端を 0.5 秒かけて座った姿につなぎました。",
234
+ ok: "使えます",
235
+ remove: "削除",
236
+ retry: "もう一度",
237
+ problem: "代わりに内蔵の動きを使います:{reason}",
238
+ none: "まだあなたの動きはありません。",
239
+ errors: {
240
+ "no-ffmpeg": "このコンピューターに ffmpeg が必要です(brew install ffmpeg)。",
241
+ "not-video": "Ta が読める動画ではありません。",
242
+ "too-short": "短すぎます({detail} 秒)。1 秒以上にしてください。",
243
+ "too-long": "長すぎます({detail} 秒)。12 秒までです。",
244
+ "too-big": "ファイルが大きすぎます。{detail} MB までです。",
245
+ "no-words": "きっかけの言葉を入れてください。",
246
+ "no-title": "名前を付けてください。",
247
+ unknown: "{detail}"
248
+ }
249
+ };
250
+ var WORDS = { "zh-CN": ZH, "zh-TW": ZH_TW, "en-US": EN, "ja-JP": JA };
251
+ var MovesWords;
252
+ ((MovesWords) => {
253
+ function of(language) {
254
+ return TaLanguageUtil.pick(language, WORDS);
255
+ }
256
+ MovesWords.of = of;
257
+ function fill(text, values) {
258
+ return text.replace(/\{(\w+)\}/g, (_, key) => String(values[key] ?? ""));
259
+ }
260
+ MovesWords.fill = fill;
261
+ })(MovesWords ||= {});
262
+
263
+ // web-src/moves-protocol.ts
264
+ var MAX_BYTES = 60 * 1024 * 1024;
265
+ var CHUNK_BYTES = 512 * 1024;
266
+ var MOVE_KINDS = ["say", "after", "listening", "thinking", "speaking"];
267
+ var MoveErrors;
268
+ ((MoveErrors) => {
269
+ const PREFIX = "ta-moves:";
270
+ function error(code, detail = "") {
271
+ return new Error(`${PREFIX}${code}:${detail}`);
272
+ }
273
+ MoveErrors.error = error;
274
+ function of(error2) {
275
+ const message = String(error2?.message ?? error2);
276
+ const at = message.indexOf(PREFIX);
277
+ if (at < 0) {
278
+ return { code: "unknown", detail: message };
279
+ }
280
+ const [code, ...rest] = message.slice(at + PREFIX.length).split(":");
281
+ return { code, detail: rest.join(":") };
282
+ }
283
+ MoveErrors.of = of;
284
+ })(MoveErrors ||= {});
285
+
286
+ // web-src/react.ts
287
+ var React;
288
+ function bind(react) {
289
+ React = react;
290
+ }
291
+
292
+ // web-src/style.ts
293
+ var STYLE = `
294
+ .tmv-panel { display: flex; flex-direction: column; gap: 12px; width: 100%; }
295
+ .tmv-note { margin: 0; color: var(--ta-secondary); font-size: calc(13px * var(--ta-font-scale)); line-height: 1.5; }
296
+ .tmv-bad { color: var(--ta-danger, #d93025); }
297
+ .tmv-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; border-radius: 12px; background: var(--ta-raised); }
298
+ .tmv-move { display: flex; align-items: center; gap: 8px; padding: 10px 12px; }
299
+ .tmv-move + .tmv-move { box-shadow: inset 0 1px 0 var(--ta-border-muted); }
300
+ .tmv-move-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
301
+ .tmv-move-title { font-weight: 500; }
302
+ .tmv-form { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 12px; background: var(--ta-raised); }
303
+ .tmv-head { font-weight: 600; }
304
+ .tmv-field { display: grid; grid-template-columns: 96px 1fr; align-items: center; gap: 8px; font-size: calc(14px * var(--ta-font-scale)); }
305
+ .tmv-field input:not([type='file']), .tmv-field select { height: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--ta-border); background: var(--ta-main); color: var(--ta-text); font: inherit; min-width: 0; }
306
+ .tmv-actions { display: flex; justify-content: flex-end; }
307
+ .tmv-button { height: 32px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--ta-border); background: transparent; color: var(--ta-text); font: inherit; font-weight: 500; cursor: pointer; flex: none; }
308
+ .tmv-button:disabled { opacity: 0.5; cursor: default; }
309
+ .tmv-primary { background: var(--ta-accent); border-color: var(--ta-accent); color: #fff; }
310
+ [data-layout='compact'] .tmv-field { grid-template-columns: 1fr; gap: 4px; }
311
+ `;
312
+ function injectStyle() {
313
+ const element = document.createElement("style");
314
+ element.dataset.taPackage = "ta-moves";
315
+ element.textContent = STYLE;
316
+ document.head.appendChild(element);
317
+ return () => element.remove();
318
+ }
319
+
320
+ // web-src/index.tsx
321
+ var BUILT_IN = ["wave", "laugh", "heart", "clap", "shy", "happy", "surprised", "sorry", "dance", "stretch"];
322
+ var BUILT_IN_KIND = { dance: "after", stretch: "after" };
323
+ function activate(pi) {
324
+ bind(pi.React);
325
+ const removeStyle = injectStyle();
326
+ const clips = new OwnClips(pi);
327
+ pi.registerCallMoves?.({ moves: () => clips.moves(), failed: (name, reason) => clips.failed(name, reason) });
328
+ pi.registerSettings({
329
+ title: () => MovesWords.of(pi.ui.language).section,
330
+ icon: pi.ui.icons.Film ?? pi.ui.icons.Sparkles,
331
+ group: "voice",
332
+ order: 20,
333
+ rows: [
334
+ {
335
+ key: "moves",
336
+ label: "",
337
+ search: () => MovesWords.of(pi.ui.language).title,
338
+ stacked: true,
339
+ render: () => /* @__PURE__ */ React.createElement(MovesPanel, {
340
+ pi
341
+ })
342
+ }
343
+ ]
344
+ });
345
+ return () => {
346
+ clips.close();
347
+ removeStyle();
348
+ };
349
+ }
350
+
351
+ class OwnClips {
352
+ pi;
353
+ kept = new Map;
354
+ constructor(pi) {
355
+ this.pi = pi;
356
+ }
357
+ async moves() {
358
+ const list = await this.pi.callHost("list");
359
+ const moves = [];
360
+ for (const move of list.filter((one) => !one.problem)) {
361
+ try {
362
+ moves.push({
363
+ name: move.name,
364
+ title: move.title,
365
+ kind: move.kind,
366
+ words: move.words,
367
+ url: await this.url(move),
368
+ frames: move.frames,
369
+ framing: move.framing
370
+ });
371
+ } catch (error) {
372
+ this.failed(move.name, String(error?.message ?? error));
373
+ }
374
+ }
375
+ return moves;
376
+ }
377
+ failed(name, reason) {
378
+ this.pi.callHost("failed", name, reason).catch(() => {
379
+ return;
380
+ });
381
+ }
382
+ async url(move) {
383
+ const kept = this.kept.get(move.name);
384
+ if (kept?.added === move.added) {
385
+ return kept.url;
386
+ }
387
+ const { data } = await this.pi.callHost("clip", move.name);
388
+ const url = URL.createObjectURL(new Blob([OwnClips.bytes(data)], { type: "video/mp4" }));
389
+ if (kept) {
390
+ URL.revokeObjectURL(kept.url);
391
+ }
392
+ this.kept.set(move.name, { added: move.added, url });
393
+ return url;
394
+ }
395
+ close() {
396
+ for (const { url } of this.kept.values()) {
397
+ URL.revokeObjectURL(url);
398
+ }
399
+ this.kept.clear();
400
+ }
401
+ static bytes(base64) {
402
+ const text = atob(base64);
403
+ const bytes = new Uint8Array(text.length);
404
+ for (let i = 0;i < text.length; i++) {
405
+ bytes[i] = text.charCodeAt(i);
406
+ }
407
+ return bytes;
408
+ }
409
+ static base64(bytes) {
410
+ let text = "";
411
+ for (let at = 0;at < bytes.length; at += 32768) {
412
+ text += String.fromCharCode(...bytes.subarray(at, at + 32768));
413
+ }
414
+ return btoa(text);
415
+ }
416
+ static async upload(pi, file, draft, progress) {
417
+ const { id } = await pi.callHost("begin", { ...draft, size: file.size });
418
+ for (let at = 0;at < file.size; at += CHUNK_BYTES) {
419
+ const bytes = new Uint8Array(await file.slice(at, at + CHUNK_BYTES).arrayBuffer());
420
+ await pi.callHost("put", id, OwnClips.base64(bytes));
421
+ progress(0.8 * Math.min(file.size, at + CHUNK_BYTES) / file.size);
422
+ }
423
+ progress(0.9);
424
+ return pi.callHost("finish", id);
425
+ }
426
+ }
427
+ function MovesPanel({ pi }) {
428
+ const words = MovesWords.of(pi.ui.language);
429
+ const [moves, setMoves] = React.useState();
430
+ const [file, setFile] = React.useState();
431
+ const [title, setTitle] = React.useState("");
432
+ const [kind, setKind] = React.useState("say");
433
+ const [replace, setReplace] = React.useState("");
434
+ const [said, setSaid] = React.useState("");
435
+ const [note, setNote] = React.useState();
436
+ const [busy, run] = pi.ui.useBusy();
437
+ const input = React.useRef(null);
438
+ const load = React.useCallback(() => pi.callHost("list").then(setMoves, () => setMoves([])), [pi]);
439
+ React.useEffect(() => void load(), [load]);
440
+ const add = async () => {
441
+ if (!file) {
442
+ return;
443
+ }
444
+ try {
445
+ const move = await OwnClips.upload(pi, file, { title, kind: replace ? BUILT_IN_KIND[replace] ?? "say" : kind, words: said.split(/[,,、;;\n]/), ...replace ? { replace } : {} }, (part) => setNote({ text: MovesWords.fill(words.adding, { percent: Math.round(part * 100) }) }));
446
+ const blended = move.blended ? ` ${MovesWords.fill(words.blended, { first: move.seat.first, last: move.seat.last })}` : "";
447
+ setNote({ text: MovesWords.fill(words.added, { name: move.title }) + blended });
448
+ setFile(undefined);
449
+ setTitle("");
450
+ setSaid("");
451
+ setReplace("");
452
+ if (input.current) {
453
+ input.current.value = "";
454
+ }
455
+ await load();
456
+ } catch (error) {
457
+ const { code, detail } = MoveErrors.of(error);
458
+ setNote({ text: MovesWords.fill(words.errors[code] ?? words.errors.unknown, { detail }), bad: true });
459
+ }
460
+ };
461
+ const act = (method, name) => pi.callHost(method, name).then(setMoves);
462
+ const Loading = pi.ui.Loading;
463
+ return /* @__PURE__ */ React.createElement("div", {
464
+ className: "tmv-panel"
465
+ }, /* @__PURE__ */ React.createElement("p", {
466
+ className: "tmv-note"
467
+ }, words.hint), moves === undefined ? Loading && /* @__PURE__ */ React.createElement(Loading, {
468
+ compact: true
469
+ }) : moves.length ? /* @__PURE__ */ React.createElement("ul", {
470
+ className: "tmv-list"
471
+ }, moves.map((move) => /* @__PURE__ */ React.createElement("li", {
472
+ key: move.name,
473
+ className: "tmv-move"
474
+ }, /* @__PURE__ */ React.createElement("span", {
475
+ className: "tmv-move-text"
476
+ }, /* @__PURE__ */ React.createElement("span", {
477
+ className: "tmv-move-title"
478
+ }, move.title), /* @__PURE__ */ React.createElement("span", {
479
+ className: "tmv-note"
480
+ }, words.kinds[move.kind], move.words.length ? ` · ${move.words.join("、")}` : "", BUILT_IN.includes(move.name) ? ` · ${words.replace} ${words.builtIn[move.name] ?? move.name}` : ""), /* @__PURE__ */ React.createElement("span", {
481
+ className: `tmv-note${move.problem ? " tmv-bad" : ""}`
482
+ }, move.problem ? MovesWords.fill(words.problem, { reason: move.problem }) : words.ok, move.blended ? ` · ${MovesWords.fill(words.blended, { first: move.seat.first, last: move.seat.last })}` : "")), move.problem && /* @__PURE__ */ React.createElement("button", {
483
+ type: "button",
484
+ className: `tmv-button${busy ? " ta-busy" : ""}`,
485
+ disabled: busy,
486
+ onClick: () => void run(() => act("retry", move.name))
487
+ }, words.retry), /* @__PURE__ */ React.createElement("button", {
488
+ type: "button",
489
+ className: `tmv-button${busy ? " ta-busy" : ""}`,
490
+ disabled: busy,
491
+ onClick: () => void run(() => act("remove", move.name))
492
+ }, words.remove)))) : /* @__PURE__ */ React.createElement("p", {
493
+ className: "tmv-note"
494
+ }, words.none), /* @__PURE__ */ React.createElement("div", {
495
+ className: "tmv-form"
496
+ }, /* @__PURE__ */ React.createElement("div", {
497
+ className: "tmv-head"
498
+ }, words.add), /* @__PURE__ */ React.createElement("label", {
499
+ className: "tmv-field"
500
+ }, /* @__PURE__ */ React.createElement("span", null, words.file), /* @__PURE__ */ React.createElement("input", {
501
+ ref: input,
502
+ type: "file",
503
+ accept: "video/*",
504
+ onChange: (event) => setFile(event.currentTarget.files?.[0])
505
+ })), /* @__PURE__ */ React.createElement("label", {
506
+ className: "tmv-field"
507
+ }, /* @__PURE__ */ React.createElement("span", null, words.name), /* @__PURE__ */ React.createElement("input", {
508
+ value: title,
509
+ maxLength: 24,
510
+ placeholder: words.namePlaceholder,
511
+ onChange: (event) => setTitle(event.currentTarget.value)
512
+ })), /* @__PURE__ */ React.createElement("label", {
513
+ className: "tmv-field"
514
+ }, /* @__PURE__ */ React.createElement("span", null, words.replace), /* @__PURE__ */ React.createElement("select", {
515
+ value: replace,
516
+ onChange: (event) => setReplace(event.currentTarget.value)
517
+ }, /* @__PURE__ */ React.createElement("option", {
518
+ value: ""
519
+ }, words.replaceNone), BUILT_IN.map((name) => /* @__PURE__ */ React.createElement("option", {
520
+ key: name,
521
+ value: name
522
+ }, words.builtIn[name] ?? name)))), !replace && /* @__PURE__ */ React.createElement("label", {
523
+ className: "tmv-field"
524
+ }, /* @__PURE__ */ React.createElement("span", null, words.kind), /* @__PURE__ */ React.createElement("select", {
525
+ value: kind,
526
+ onChange: (event) => setKind(event.currentTarget.value)
527
+ }, MOVE_KINDS.map((one) => /* @__PURE__ */ React.createElement("option", {
528
+ key: one,
529
+ value: one
530
+ }, words.kinds[one])))), (replace || kind === "say" || kind === "after") && /* @__PURE__ */ React.createElement("label", {
531
+ className: "tmv-field"
532
+ }, /* @__PURE__ */ React.createElement("span", null, words.words), /* @__PURE__ */ React.createElement("input", {
533
+ value: said,
534
+ placeholder: words.wordsPlaceholder,
535
+ onChange: (event) => setSaid(event.currentTarget.value)
536
+ })), /* @__PURE__ */ React.createElement("p", {
537
+ className: "tmv-note"
538
+ }, words.wordsHint), /* @__PURE__ */ React.createElement("p", {
539
+ className: "tmv-note"
540
+ }, words.rules), /* @__PURE__ */ React.createElement("p", {
541
+ className: "tmv-note"
542
+ }, words.rights), note && /* @__PURE__ */ React.createElement("p", {
543
+ className: `tmv-note${note.bad ? " tmv-bad" : ""}`
544
+ }, note.text), /* @__PURE__ */ React.createElement("div", {
545
+ className: "tmv-actions"
546
+ }, /* @__PURE__ */ React.createElement("button", {
547
+ type: "button",
548
+ className: `tmv-button tmv-primary${busy ? " ta-busy" : ""}`,
549
+ disabled: busy || !file || !title.trim(),
550
+ onClick: () => void run(add)
551
+ }, words.add))));
552
+ }
553
+ export {
554
+ activate as default,
555
+ OwnClips
556
+ };