@biunow/agent-biuart 0.1.0 → 0.1.2

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.0",
5
+ "version": "0.1.2",
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": "0be499e80eb1cefb3d86c875c1e9d2bae6cfe2ae5ed60fed5201839f2aa68b74",
49
- "signature": "bDz5NmcG7CFseOoI+7zzWm6tEycR6A/cxL/DseJIZ2UMjJKsMCK72jKzIZuAWQ4H7na+8ER7Xd+d3WoKgZ7SAA==",
48
+ "sha256": "f6fca5f754b9d3c4fb1df85456d1b83232b58c3c14578a547816bfde8a1f88e1",
49
+ "signature": "mxu0dAVRKJFWK4dOJRH7rn5rkd3Phe/uX6xnGKl+08yQMLZY7m0U+b48JK7JISI2VhPDc31oRhUqLTdz2f50Bw==",
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.0",
3
+ "version": "0.1.2",
4
4
  "description": "BiuArt",
5
5
  "license": "UNLICENSED",
6
6
  "publishConfig": {
@@ -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 {