@biunow/agent-biuart 0.1.1 → 0.1.3

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/bin/server.mjs CHANGED
@@ -118,12 +118,12 @@ async function renderThumb(cfg, engineRoot, item, kind) {
118
118
  if (kind === 'style' && item.era) {
119
119
  await render({
120
120
  engineRoot, out: tmpDir, solo: item.era, film: item.film || '',
121
- stills: '1.2', width: 480, height: 270,
121
+ stills: '1.2', stillWidth: 640,
122
122
  });
123
123
  } else {
124
124
  const example = path.join(engineRoot, 'examples', `${item.id}.json`);
125
125
  if (!fs.existsSync(example)) throw new Error(`缺少示例 spec:examples/${item.id}.json`);
126
- await render({ engineRoot, out: tmpDir, specPath: example, stills: '0.8' });
126
+ await render({ engineRoot, out: tmpDir, specPath: example, stills: '0.8', stillWidth: 640 });
127
127
  }
128
128
  const png = fs.readdirSync(tmpDir).find((name) => name.endsWith('.png'));
129
129
  if (!png) throw new Error('引擎没有产出静帧');
@@ -472,8 +472,25 @@ export async function render(options) {
472
472
  const dir = path.resolve(out);
473
473
  fs.mkdirSync(dir, { recursive: true });
474
474
  const times = String(stills).split(',').map(Number).filter(Number.isFinite);
475
+ // stillWidth:先在原尺寸渲完整构图,再等比缩到指定宽度(引擎场景按 1920 坐标写死,直接小画布渲会被裁成左上角)
476
+ const stillWidth = Number(options.stillWidth || 0);
475
477
  for (const time of times) {
476
- const base64 = await grab(time);
478
+ let base64 = await grab(time);
479
+ if (stillWidth > 0) {
480
+ base64 = await page.evaluate(({ b64, w }) => new Promise((resolve, reject) => {
481
+ const img = new Image();
482
+ img.onload = () => {
483
+ const k = Math.min(1, w / img.width);
484
+ const c2 = document.createElement('canvas');
485
+ c2.width = Math.round(img.width * k);
486
+ c2.height = Math.round(img.height * k);
487
+ c2.getContext('2d').drawImage(img, 0, 0, c2.width, c2.height);
488
+ resolve(c2.toDataURL('image/png').split(',')[1]);
489
+ };
490
+ img.onerror = () => reject(new Error('静帧缩放失败'));
491
+ img.src = `data:image/png;base64,${b64}`;
492
+ }), { b64: base64, w: stillWidth });
493
+ }
477
494
  fs.writeFileSync(path.join(dir, `t${time.toFixed(2).padStart(6, '0')}.png`), Buffer.from(base64, 'base64'));
478
495
  }
479
496
  return { out: dir, mode: 'stills', frames: times.length, stills: times, errors, engineRoot };
package/manifest.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "schemaVersion": 1,
3
3
  "id": "biuart",
4
4
  "name": "BiuArt",
5
- "version": "0.1.1",
5
+ "version": "0.1.3",
6
6
  "publisher": "Biunow",
7
7
  "description": "BiuArt 艺术动画:锁定一种画风,用代码画出会动的画面,一镜一镜渲成片。",
8
8
  "entry": {
@@ -45,8 +45,8 @@
45
45
  "requiresEntitlement": "export"
46
46
  },
47
47
  "integrity": {
48
- "sha256": "5ee503b1ad7e88970c96d450b4edd761b84706421c5d09948c3ac971f888c17f",
49
- "signature": "FVdVE6A4jQsji9xub+qwU1+verf60xU+HJEEAm/PjXGrKD0uPi1UiSrkGGp4O1hN+jSJanWrSjgvPzjPbHbNCQ==",
48
+ "sha256": "abffc8170429a312a02a0275b661336f2c30e652d83e553140eba0e395d501bb",
49
+ "signature": "mf5AuMQ3vXjnbUpfdpt0Lqi/BxYGeCllJo6W6W2xFuGG0ASAAOEtXwHnpeZkKML+Q6jUacjyyABaR5+ewsbUDA==",
50
50
  "signedBy": "publisher-key"
51
51
  }
52
52
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@biunow/agent-biuart",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "BiuArt",
5
5
  "license": "UNLICENSED",
6
6
  "publishConfig": {
package/studio/app.js CHANGED
@@ -79,14 +79,14 @@
79
79
  state.style = item?.id || state.style;
80
80
  if (!item) return;
81
81
  $('style-group').textContent = item.group || '—';
82
- const parts = [item.summary || '', item.previewable ? '可试渲染 2 秒。' : '参数化片段,由代码按 spec 渲染。'];
82
+ const parts = [item.summary || '', item.previewable ? '可试渲染 2 秒。' : '这一种直接出片,不做试渲染。'];
83
83
  $('style-summary').textContent = parts.filter(Boolean).join(' ');
84
84
  const canPreview = !!item.previewable && state.meta.enginePresent;
85
85
  $('preview').disabled = !canPreview;
86
- $('preview').title = canPreview ? '渲一段示例看画风' : (item.previewable ? '引擎未安装' : '这个语法没有内置示例场景');
86
+ $('preview').title = canPreview ? '渲一段示例看画风' : (item.previewable ? '画风样本准备中' : '这一种没有试渲染');
87
87
  $('preview-status').textContent = item.previewable
88
- ? (state.meta.enginePresent ? '示例场景可用。' : '引擎未安装。')
89
- : '解说语法走 spec,不提供内置预览。';
88
+ ? (state.meta.enginePresent ? '示例场景可用。' : '样本准备中。')
89
+ : '';
90
90
  }
91
91
 
92
92
  /* ---------- 小选择器:时长 / 画幅 ---------- */
@@ -216,6 +216,7 @@
216
216
  host.prepend(el);
217
217
  }
218
218
  const mp4 = job.outputMp4 && /\.mp4$/i.test(job.outputMp4);
219
+ el.className = `job${mp4 ? ' playable' : ''}`;
219
220
  el.innerHTML = `
220
221
  <div class="job-top">
221
222
  <div class="job-title">${escapeHtml(job.title || job.styleName || '任务')}</div>
@@ -223,13 +224,45 @@
223
224
  </div>
224
225
  <div class="job-msg">${escapeHtml(job.message || '')}</div>
225
226
  <div class="job-bar"><span style="width:${Math.max(0, Math.min(100, Number(job.progress) || 0))}%"></span></div>
226
- ${mp4 ? `<video class="job-video" controls playsinline preload="metadata" src="/api/file?path=${encodeURIComponent(job.outputMp4)}"></video>` : ''}
227
- <div class="job-actions">
228
- ${job.projectPath ? `<span class="job-msg">${escapeHtml(job.projectPath)}</span>` : ''}
229
- ${job.error ? `<span class="job-msg">${escapeHtml(job.error)}</span>` : ''}
230
- </div>
227
+ ${mp4 ? '<div class="job-play">▷ 点击播放成片</div>' : ''}
228
+ ${job.error ? `<div class="job-msg">${escapeHtml(job.error)}</div>` : ''}
231
229
  `;
230
+ el.onclick = mp4 ? () => openFilm(job) : null;
231
+ }
232
+ }
233
+
234
+ /* ---------- 成片弹窗 ---------- */
235
+ function openFilm(job) {
236
+ let back = document.querySelector('.film-modal');
237
+ if (!back) {
238
+ back = document.createElement('div');
239
+ back.className = 'film-modal';
240
+ back.innerHTML = `
241
+ <div class="film-modal-card" role="dialog" aria-modal="true">
242
+ <div class="film-modal-bar">
243
+ <strong></strong>
244
+ <button type="button" class="film-modal-x" aria-label="关闭">×</button>
245
+ </div>
246
+ <video controls playsinline></video>
247
+ </div>`;
248
+ document.body.appendChild(back);
249
+ const close = () => {
250
+ const video = back.querySelector('video');
251
+ video.pause();
252
+ video.removeAttribute('src');
253
+ video.load();
254
+ back.hidden = true;
255
+ };
256
+ back.querySelector('.film-modal-x').addEventListener('click', close);
257
+ back.addEventListener('click', (e) => { if (e.target === back) close(); });
258
+ document.addEventListener('keydown', (e) => { if (e.key === 'Escape') close(); });
232
259
  }
260
+ back.querySelector('strong').textContent = job.title || job.styleName || '成片';
261
+ const src = `/api/jobs/${encodeURIComponent(job.id)}/film`;
262
+ const video = back.querySelector('video');
263
+ video.src = src;
264
+ back.hidden = false;
265
+ video.play().catch(() => {});
233
266
  }
234
267
 
235
268
  function stateLabel(status) {
@@ -341,15 +374,14 @@
341
374
  updateCharHint();
342
375
  updateStoryboardHint();
343
376
  const chips = [];
344
- chips.push(`<span class="chip ${state.meta.enginePresent ? '' : 'bad'}">${state.meta.enginePresent ? '引擎已就绪' : '引擎未安装'}</span>`);
345
- if (!state.meta.canExport) chips.push('<span class="chip warn">未激活</span>');
377
+ chips.push(`<span class="chip ${state.meta.enginePresent ? '' : 'warn'}">${state.meta.enginePresent ? '画风已就绪' : '画风准备中'}</span>`);
378
+ if (!state.meta.canExport) chips.push('<span class="chip bad">未授权</span>');
379
+ chips.push(`<span class="chip">${state.meta.styles.length} 种画风</span>`);
346
380
  $('health-chips').innerHTML = chips.join('');
347
- $('engine-line').textContent = state.meta.enginePresent
348
- ? `Engine: ${state.meta.engineRoot}`
349
- : 'ENGINE_ROOT 未设置:把面板 settings.engineRoots["biuart"] 指向 huashu-art-motion/scripts/engine。';
350
381
  if (!state.meta.enginePresent) {
351
382
  $('preview').disabled = true;
352
383
  $('submit').disabled = true;
384
+ showError('BiuArt 暂时还没准备好,请稍后再试;一直不行请联系客服。');
353
385
  }
354
386
  await refreshJobs();
355
387
  setInterval(refreshJobs, 3000);
@@ -400,7 +400,7 @@ button:disabled { cursor: not-allowed; opacity: .5; }
400
400
  display: block; width: 100%; aspect-ratio: 16 / 9; border-radius: 7px;
401
401
  overflow: hidden; background: #ecece6;
402
402
  }
403
- .sm-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
403
+ .sm-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
404
404
  .sm-thumb-ph {
405
405
  display: flex; align-items: center; justify-content: center; width: 100%; height: 100%;
406
406
  font-size: 17px; font-weight: 600; color: var(--muted);
@@ -413,7 +413,7 @@ button:disabled { cursor: not-allowed; opacity: .5; }
413
413
  overflow: hidden; animation: sm-in .16s ease-out;
414
414
  }
415
415
  .sm-preview-img { width: 100%; aspect-ratio: 16 / 9; background: #ecece6; }
416
- .sm-preview-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
416
+ .sm-preview-img img { width: 100%; height: 100%; object-fit: contain; display: block; }
417
417
  .sm-preview-body { padding: 11px 14px 13px; }
418
418
  .sm-preview-title { display: flex; align-items: baseline; gap: 8px; }
419
419
  .sm-preview-title strong {
package/studio/index.html CHANGED
@@ -14,7 +14,6 @@
14
14
  <div class="eyebrow">BIUART · ART MOTION</div>
15
15
  <h1>把画风写成会动的代码</h1>
16
16
  <p class="hero-desc">选一种画风,写下要讲的事。BiuArt 先出镜头表,再逐帧渲成片;画面由代码绘制,不靠拼图转场。</p>
17
- <div class="sub" id="engine-line">正在检查引擎…</div>
18
17
  </div>
19
18
  <div class="hero-aside">
20
19
  <div class="hero-badge">
package/studio/styles.css CHANGED
@@ -59,6 +59,12 @@
59
59
  .job-bar { height: 4px; border-radius: 99px; background: #ededE7; margin-top: 8px; overflow: hidden; }
60
60
  .job-bar > span { display: block; height: 100%; background: var(--accent-deep); transition: width .3s ease; }
61
61
  .job-video { width: 100%; border-radius: 8px; margin-top: 8px; background: #111; }
62
+ .job.playable { cursor: pointer; }
63
+ .job.playable:hover { border-color: var(--accent-deep); background: #fbfdf2; }
64
+ .job-play {
65
+ margin-top: 8px; font-size: 11px; font-weight: 650; color: #4d5c16;
66
+ background: var(--accent-soft); border-radius: 99px; padding: 4px 10px; display: inline-block;
67
+ }
62
68
  .job-actions { display: flex; gap: 8px; margin-top: 7px; flex-wrap: wrap; }
63
69
  .job-actions a { font-size: 11px; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
64
70
  .empty { color: var(--muted-2); font-size: 12px; padding: 8px 0; }