cortico-world-extra-actions 0.3.18 → 0.3.20

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortico-world-extra-actions",
3
- "version": "0.3.18",
3
+ "version": "0.3.20",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "勾选动作库里的动作,写进形象包的「额外动作拓展」文件夹,让桌宠照着做。自带入门形象包与示例动作;完整 105 段可一键下载安装(不用解压、不用选文件夹)。",
package/src/online.js CHANGED
@@ -19,6 +19,9 @@ export const DEFAULT_REMOTE = '';
19
19
  const MAX_LIBRARY_BYTES = 800 * 1024 * 1024; // 完整库上限
20
20
  const MAX_ACTION_BYTES = 32 * 1024 * 1024; // 单个动作上限
21
21
  /** 没配 remoteBase 时的兜底:GitHub Release 上的完整库(国内可能慢,但不至于完全没有)。 */
22
+ /** 单段动作的兜底地址:GitHub Release 上的扁平资产 `<id>.zip`(Gitee 建好后用 remoteActionBase 覆盖)。 */
23
+ export const FALLBACK_ACTION_BASE = 'https://github.com/MOYU-AI-Lab/cortico-world-extra-actions/releases/download/per-action';
24
+
22
25
  export const FALLBACK_LIBRARY = 'https://github.com/MOYU-AI-Lab/cortico-world-extra-actions/releases/download/library/shenshen-action-library.zip';
23
26
  /** 只收这些条目:动作库的两种格式(帧序列 / 单文件动画)。 */
24
27
  const WANT = /(^|\/)actions\/[a-z][a-z0-9-]*\/[a-z0-9][a-z0-9-]*\/(action\.json|anim\.webp|preview\.webp|f_\d{4}\.webp)$/;
@@ -114,3 +117,5 @@ export async function installAction({ url, libraryDir, category, id, log }) {
114
117
  /** 由 remoteBase 拼出两个地址。 */
115
118
  export const libraryUrl = (base) => `${String(base).replace(/\/+$/, '')}/library.zip`;
116
119
  export const actionUrl = (base, category, id) => `${String(base).replace(/\/+$/, '')}/actions/${category}/${id}.zip`;
120
+ /** 扁平布局(GitHub Release 的资产做不到子目录):<base>/<id>.zip */
121
+ export const flatActionUrl = (base, id) => `${String(base).replace(/\/+$/, '')}/${id}.zip`;
package/src/world.js CHANGED
@@ -14,7 +14,7 @@ import { fileURLToPath } from 'node:url';
14
14
  import { EXTRA_DIR, clear, inspect, isInside, packLooksSupported, prunePack, readExtra, removeOne, save } from './writer.js';
15
15
  import { addModules, rebuildIndex, scanLibrary } from './importer.js';
16
16
  import { ensureStarter, installStarterLibrary, libraryHealth, restorePack, safePackName } from './starter.js';
17
- import { FALLBACK_LIBRARY, actionUrl, installAction, installLibrary, libraryUrl } from './online.js';
17
+ import { FALLBACK_ACTION_BASE, FALLBACK_LIBRARY, actionUrl, flatActionUrl, installAction, installLibrary, libraryUrl } from './online.js';
18
18
  import { petFigures, petState } from './pet.js';
19
19
 
20
20
  const ID = 'extra-actions';
@@ -506,17 +506,29 @@ export class ExtraActionsWorld {
506
506
 
507
507
  /** 下载源:设置里的 remoteBase(Gitee 等),没配就退回 GitHub 直链。 */
508
508
  remoteBase() {
509
- const fromCfg = this.ctx.cfg && typeof this.ctx.cfg === 'object' ? this.ctx.cfg.remoteBase : '';
510
- return typeof fromCfg === 'string' && fromCfg.trim() ? fromCfg.trim().replace(/\/+$/, '') : '';
509
+ const c = this.ctx.cfg && typeof this.ctx.cfg === 'object' ? this.ctx.cfg : {};
510
+ const pick = (v) => (typeof v === 'string' && v.trim() ? v.trim().replace(/\/+$/, '') : '');
511
+ return pick(c.remoteBase) || '';
512
+ }
513
+
514
+ /** 单段动作的地址前缀(GitHub Release 的资产是扁平的,没有 actions/<分类>/ 这层)。 */
515
+ remoteActionBase() {
516
+ const c = this.ctx.cfg && typeof this.ctx.cfg === 'object' ? this.ctx.cfg : {};
517
+ const pick = (v) => (typeof v === 'string' && v.trim() ? v.trim().replace(/\/+$/, '') : '');
518
+ return pick(c.remoteActionBase) || FALLBACK_ACTION_BASE;
511
519
  }
512
520
 
513
521
  /** 面板需要知道:完整库从哪下、能不能单个下。 */
514
522
  downloadInfo() {
515
523
  const base = this.remoteBase();
524
+ const actionBase = this.remoteActionBase();
516
525
  return {
517
526
  base,
527
+ actionBase,
518
528
  libraryUrl: base ? libraryUrl(base) : FALLBACK_LIBRARY,
519
- perAction: !!base,
529
+ // 完整库有 GitHub 兜底;单段必须有专门的前缀
530
+ perAction: !!(actionBase || base),
531
+ flat: !!actionBase,
520
532
  };
521
533
  }
522
534
 
@@ -542,8 +554,9 @@ export class ExtraActionsWorld {
542
554
  if (!info.perAction) throw new Error('还没配置单动作下载源(remoteBase)');
543
555
  const lib = this.libraryDir();
544
556
  if (!lib) throw new Error('动作库还没设置好');
557
+ const url = info.flat ? flatActionUrl(info.actionBase, id) : actionUrl(info.base, category, id);
545
558
  const r = await installAction({
546
- url: actionUrl(info.base, category, id),
559
+ url,
547
560
  libraryDir: lib,
548
561
  category,
549
562
  id,
@@ -0,0 +1 @@
1
+ {"id":"cheer-hop","category":"core","word":"cheer-hop","zh":"cheer-hop","say":"cheer-hop","clip":"actions/core/cheer-hop","frames":1,"fps":24,"seconds":1,"anim":true}
@@ -0,0 +1 @@
1
+ {"id":"eat-dumplings","category":"eat","word":"eat-dumplings","zh":"eat-dumplings","say":"eat-dumplings","clip":"actions/eat/eat-dumplings","frames":1,"fps":24,"seconds":1,"anim":true}