modelstage 0.5.28 → 0.10.1
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/CHANGELOG.md +92 -0
- package/README.md +2 -63
- package/config/models/live2d.assetbundls.json +1 -1
- package/config/models/live2d.azurlane.json +1 -1
- package/config/models/live2d.azurlane_bundle.json +1 -1
- package/config/models/live2d.azurlane_bundle.jsonl +2 -0
- package/config/models/live2d.azurlane_spine.json +1 -1
- package/config/models/live2d.bd2.json +1 -1
- package/config/models/live2d.bd2.jsonl +2 -0
- package/config/models/live2d.bd2_mod.json +1 -0
- package/config/models/live2d.bluearchive.json +1 -1
- package/config/models/live2d.nikke.json +1 -1
- package/config/models/live2d.nikke.jsonl +2 -0
- package/config/models/live2d.nikke_2.json +1 -1
- package/config/models/live2d.npc.json +1 -1
- package/config/models/live2d.sample_haru.json +1 -0
- package/config/models/spine.assetbundls.json +1 -1
- package/config/models/spine.azurlane.json +1 -1
- package/config/models/spine.azurlane_bundle.json +1 -1
- package/config/models/spine.azurlane_bundle.jsonl +2 -0
- package/config/models/spine.azurlane_spine.json +1 -1
- package/config/models/spine.bd2.json +1 -1
- package/config/models/spine.bd2.jsonl +433 -0
- package/config/models/spine.bd2_mod.json +1 -0
- package/config/models/spine.bluearchive.json +1 -1
- package/config/models/spine.nikke.json +1 -1
- package/config/models/spine.nikke_2.json +1 -1
- package/config/models/spine.npc.json +1 -1
- package/config/models/spine.sample_haru.json +1 -0
- package/package.json +3 -2
- package/plugins/unity-live2d-bundle/index.js +43 -1
- package/plugins/unity-live2d-bundle/lib/bundle-probe.js +79 -0
- package/plugins/unity-live2d-bundle/plugin.json +2 -1
- package/plugins/unity-spine-bundle/index.js +38 -1
- package/plugins/unity-spine-bundle/lib/bundle-probe.js +323 -0
- package/plugins/unity-spine-bundle/plugin.json +3 -1
- package/src/server/analyze/index.mjs +470 -0
- package/src/server/assets/probe.mjs +1 -1
- package/src/server/core/config.mjs +2 -2
- package/src/server/core/log.mjs +1 -1
- package/src/server/data/catalog.mjs +41 -16
- package/src/server/data/display-name-cache.mjs +142 -0
- package/src/server/data/entry-states.mjs +21 -0
- package/src/server/data/live2d.mjs +139 -40
- package/src/server/data/manifest-cache.mjs +53 -10
- package/src/server/data/manifest-jsonl.mjs +264 -0
- package/src/server/data/manifest-stamp.mjs +52 -2
- package/src/server/data/scan-progress.mjs +305 -0
- package/src/server/data/scan-queue.mjs +99 -0
- package/src/server/data/spine.mjs +324 -106
- package/src/server/http/write.mjs +7 -6
- package/src/server/index.mjs +1 -1
- package/src/server/plugins/registry.mjs +3 -3
- package/src/server/routes/data.mjs +76 -17
- package/src/server/routes/display-name.mjs +157 -0
- package/src/server/serve.mjs +17 -4
- package/src/server/unpack/plugin-store.mjs +1 -1
- package/src/server/unpack/runtime/exec.mjs +37 -8
- package/src/server/unpack/worker-client.mjs +23 -8
- package/src/shared/scan-limits.mjs +23 -0
- package/src/web/app/anim-list.js +1 -1
- package/src/web/app/backgrounds.js +4 -8
- package/src/web/app/dir-picker.js +3 -5
- package/src/web/app/memory-budget.js +0 -1
- package/src/web/app/memory-guard.js +0 -1
- package/src/web/app/model-actions.js +18 -15
- package/src/web/app/root-manager.js +2 -4
- package/src/web/app/transport-actions.js +1 -1
- package/src/web/app/ui-state.js +1 -1
- package/src/web/components.css +90 -0
- package/src/web/debug/race-probe.js +36 -13
- package/src/web/engine/textures.js +1 -2
- package/src/web/infra/api.js +10 -19
- package/src/web/infra/document.js +3 -3
- package/src/web/infra/plugin-host-unpack.mjs +94 -12
- package/src/web/infra/plugin-host.js +3 -0
- package/src/web/infra/ready.js +177 -39
- package/src/web/live2d/bridge.js +1 -1
- package/src/web/live2d/runtime-adapter.js +2 -4
- package/src/web/panel/panel-settings.js +88 -3
- package/src/web/render/surface.js +49 -2
- package/src/web/roster/display-name.js +79 -0
- package/src/web/roster/events.js +198 -0
- package/src/web/roster/filter.js +4 -4
- package/src/web/roster/list.js +11 -5
- package/src/web/roster/load.js +440 -0
- package/src/web/roster/persist.js +46 -37
- package/src/web/roster/render.js +284 -0
- package/src/web/roster/reveal.js +4 -9
- package/src/web/roster/rows.js +35 -13
- package/src/web/roster/scan-stream.js +346 -0
- package/src/web/roster/snapshot.js +14 -8
- package/src/web/roster/store.js +340 -0
- package/src/web/roster/type-filter.js +5 -5
- package/src/web/roster/view.js +147 -634
- package/src/web/spine/canvas-runtime.js +4 -5
- package/src/web/spine/runtimes.js +1 -1
- package/tool/lib/bundle-probe-node.mjs +146 -32
|
@@ -1 +1 @@
|
|
|
1
|
-
{"rootId":"nikke_2","
|
|
1
|
+
{"rootId":"nikke_2","ts":1794127311813,"count":0,"generator":"793f6b2e","dirStamps":{"root":1793370056514,"dirs":{"PC預覽可用 - 新":1730713861813,"[Seireiko]":1793370082759}},"models":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"rootId":"npc","
|
|
1
|
+
{"rootId":"npc","ts":1794078060417,"count":0,"generator":"07d15bbe","dirStamps":{"root":null,"dirs":{}},"models":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"rootId":"sample_haru","ts":1794132142456,"count":0,"generator":"793f6b2e","dirStamps":{"root":1794131352857,"dirs":{"Haru.2048":1794131352603,"expressions":1794131352706,"motions":1794131352853,"sounds":1794131352877}},"models":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "modelstage",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "Spine / Live2D 模型查看器:三级名册、两套渲染面共享相机与面板、UnityFS 资源包解包",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"start": "node bin/modelstage.mjs",
|
|
14
14
|
"test": "node --test test/*.test.mjs",
|
|
15
15
|
"check:pack": "node tool/check-pack-boundary.mjs",
|
|
16
|
-
"prepublishOnly": "npm run check:pack
|
|
16
|
+
"prepublishOnly": "npm run check:pack"
|
|
17
17
|
},
|
|
18
18
|
"files": [
|
|
19
19
|
"bin/",
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"config/resources.example.json",
|
|
38
38
|
"config/diag-upload.example.json",
|
|
39
39
|
"README.md",
|
|
40
|
+
"CHANGELOG.md",
|
|
40
41
|
"LICENSE",
|
|
41
42
|
"!**/.tmp-*",
|
|
42
43
|
"!**/*.bak",
|
|
@@ -799,7 +799,7 @@ function createMemoryEstimator({ NS }) {
|
|
|
799
799
|
|
|
800
800
|
/** 浏览器侧:把本插件登记进宿主的资产提供者注册表(node 侧 host 为 null,整块跳过)。 */
|
|
801
801
|
function registerWithHost({ host, PLUGIN_ID, api }) {
|
|
802
|
-
const { canHandle, resolve, estimateMemory, explainReject } = api;
|
|
802
|
+
const { canHandle, resolve, estimateMemory, explainReject, analyze } = api;
|
|
803
803
|
|
|
804
804
|
// 契约 §一:plugin.json 的 provides=["asset-provider"] 让宿主把本插件登记进资产提供者注册表。
|
|
805
805
|
// 注册对象上 kind 是产出内容类型(live2d),与 fileKinds 的容器类型 bundle 正交;
|
|
@@ -814,6 +814,9 @@ function registerWithHost({ host, PLUGIN_ID, api }) {
|
|
|
814
814
|
resolve,
|
|
815
815
|
// 可选扩展:宿主在 not-handled 时用它拿到"为什么不认领"(浏览器侧与 node 侧同一份实现)
|
|
816
816
|
explainReject,
|
|
817
|
+
// 契约 §1.1 bundle-analyzer:只读分析容器字节流(不产模型、不写文件)。
|
|
818
|
+
// 核心按 plugin.json 的 provides 找提供者,不认插件名。
|
|
819
|
+
analyze,
|
|
817
820
|
// 契约 §2.2:让宿主与检查器都能发现"本插件能自己算内存代价"(估得准不准由本插件负责)
|
|
818
821
|
estimateMemory,
|
|
819
822
|
kind: 'live2d',
|
|
@@ -863,6 +866,43 @@ function install() {
|
|
|
863
866
|
const provider = createProvider({ NS, host, PLUGIN_ID, ulbLog, MIME_OCTET, MIME_JSON, MIME_PNG, loadProfile, container, coreMeta });
|
|
864
867
|
const mem = createMemoryEstimator({ NS });
|
|
865
868
|
|
|
869
|
+
// 契约 §1.1 bundle-analyzer:只读分析容器字节流。
|
|
870
|
+
// 实现直接复用 lib/bundle-probe.js(不重写解析),这里只做"事实 → 契约字段"的映射。
|
|
871
|
+
// verdict(model / asset-dependency)不在这里算:那是核心的判据(src/shared/bundle-shape.mjs),
|
|
872
|
+
// 插件只提供事实,判据只留一份。
|
|
873
|
+
function analyze(bytes) {
|
|
874
|
+
const bp = NS && NS.bundleProbe;
|
|
875
|
+
if (!bp || typeof bp.run !== 'function') {
|
|
876
|
+
return {
|
|
877
|
+
container: null,
|
|
878
|
+
objects: null,
|
|
879
|
+
textures: null,
|
|
880
|
+
warnings: ['插件内缺少 bundle-probe 实现(lib/bundle-probe.js 未加载)'],
|
|
881
|
+
};
|
|
882
|
+
}
|
|
883
|
+
const res = bp.run(bytes) || {};
|
|
884
|
+
return {
|
|
885
|
+
// 契约字段
|
|
886
|
+
container: res.container || null,
|
|
887
|
+
objects: typeof res.objects === 'number' ? res.objects : null,
|
|
888
|
+
textures: Array.isArray(res.textures) ? res.textures : null,
|
|
889
|
+
// 契约 §1.1 的 textAssets:名字 / 类型 / 骨架版本 / 字节数,由 lib/bundle-probe.js 从对象表取出
|
|
890
|
+
textAssets: Array.isArray(res.textAssets) ? res.textAssets : null,
|
|
891
|
+
warnings: Array.isArray(res.warnings) ? res.warnings : [],
|
|
892
|
+
// 透传既有字段:/api/bundle/probe 与页面预检此前就在用它们,
|
|
893
|
+
// 新增 analyze 不能把它们丢掉,否则行为会变。
|
|
894
|
+
ok: res.ok,
|
|
895
|
+
code: res.code,
|
|
896
|
+
error: res.error,
|
|
897
|
+
moc3: res.moc3 || null,
|
|
898
|
+
cubism2Moc: res.cubism2Moc || null,
|
|
899
|
+
physics3: res.physics3 || null,
|
|
900
|
+
motions: res.motions,
|
|
901
|
+
reject: res.reject || null,
|
|
902
|
+
nativeFiles: res.nativeFiles,
|
|
903
|
+
};
|
|
904
|
+
}
|
|
905
|
+
|
|
866
906
|
// 键顺序与原 return 字面量完全一致
|
|
867
907
|
const api = {
|
|
868
908
|
canHandle: provider.canHandle,
|
|
@@ -871,6 +911,8 @@ function install() {
|
|
|
871
911
|
explainReject: provider.explainReject,
|
|
872
912
|
estimateMemory: mem.estimateMemory,
|
|
873
913
|
peakFromDecompressed: mem.peakFromDecompressed,
|
|
914
|
+
// 契约 §1.1:只读分析能力(核心按 provides 找提供者)
|
|
915
|
+
analyze,
|
|
874
916
|
PLUGIN_ID,
|
|
875
917
|
};
|
|
876
918
|
registerWithHost({ host, PLUGIN_ID, api });
|
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
// 两端各自加载同一份文件即可。
|
|
11
11
|
//
|
|
12
12
|
// 挂载:globalThis.__ULB__.bundleProbe = { run, formatSupport }
|
|
13
|
+
//
|
|
14
|
+
// 同源副本:本文件在 unity-live2d-bundle 与 unity-spine-bundle 两个插件里各存一份,
|
|
15
|
+
// 内容逐字节相同(两个插件都声明 bundle-analyzer 角色,各自要能独立提供 analyze)。
|
|
16
|
+
// 改一处必须同步改另一处;test/bundle-probe-parity.test.mjs 比对两份 sha256。
|
|
13
17
|
// ============================================================================
|
|
14
18
|
|
|
15
19
|
'use strict';
|
|
@@ -146,6 +150,50 @@
|
|
|
146
150
|
}
|
|
147
151
|
}
|
|
148
152
|
|
|
153
|
+
/**
|
|
154
|
+
* 从对象表取 TextAsset:名字 / 类型 / 骨架版本 / 字节数。
|
|
155
|
+
*
|
|
156
|
+
* 为什么走 typetree 的 rawStrings 而不是 extract 的文本分支:
|
|
157
|
+
* m_Script 是二进制(.skel),按 UTF-8 字符串读再编码回去会毁字节
|
|
158
|
+
* (实测 651994 字节 → 641818 字符含 165995 个 U+FFFD,长度都对不上)。
|
|
159
|
+
*
|
|
160
|
+
* 骨架版本的正则与 src/server/assets/probe.mjs 的 detectSkelVersion 完全一致:
|
|
161
|
+
* 两处必须同口径,否则"分析说 4.1.11、扫描器说默认 4.0"会各说一套。
|
|
162
|
+
*
|
|
163
|
+
* @param {object} sf serialized.parse() 结果
|
|
164
|
+
* @returns {Array<{name: string, kind: string, spineVersion: string|null, size: number}>}
|
|
165
|
+
*/
|
|
166
|
+
function collectTextAssets(sf) {
|
|
167
|
+
const CLASS_ID_TEXT_ASSET = 49;
|
|
168
|
+
const out = [];
|
|
169
|
+
for (const obj of NS.serialized.byClass(sf, CLASS_ID_TEXT_ASSET)) {
|
|
170
|
+
let fields;
|
|
171
|
+
try {
|
|
172
|
+
fields = NS.typetree.readObject(sf, obj, { rawStrings: true });
|
|
173
|
+
} catch {
|
|
174
|
+
continue; // 单个对象读不出来不影响其它 TextAsset
|
|
175
|
+
}
|
|
176
|
+
const name = (fields.m_Name && typeof fields.m_Name.text === 'string')
|
|
177
|
+
? fields.m_Name.text : String(fields.m_Name || '');
|
|
178
|
+
const raw = fields.m_Script && fields.m_Script.bytes;
|
|
179
|
+
if (!raw || !raw.length) continue;
|
|
180
|
+
const lower = name.toLowerCase();
|
|
181
|
+
let kind = 'bytes';
|
|
182
|
+
if (lower.endsWith('.skel')) kind = 'skel';
|
|
183
|
+
else if (lower.endsWith('.atlas')) kind = 'atlas';
|
|
184
|
+
else if (lower.endsWith('.json')) kind = 'json';
|
|
185
|
+
let spineVersion = null;
|
|
186
|
+
if (kind === 'skel') {
|
|
187
|
+
// 只看前 512 字节:二进制骨架的版本串在文件头附近,整份读进来没有意义
|
|
188
|
+
const head = new TextDecoder('latin1').decode(raw.subarray(0, 512));
|
|
189
|
+
const m = head.match(/(2\.\d+|3\.[5-8]|4\.[0-3])\.\d+[\w-]*/);
|
|
190
|
+
if (m) spineVersion = m[0];
|
|
191
|
+
}
|
|
192
|
+
out.push({ name, kind, spineVersion, size: raw.length });
|
|
193
|
+
}
|
|
194
|
+
return out;
|
|
195
|
+
}
|
|
196
|
+
|
|
149
197
|
/**
|
|
150
198
|
* 预检一个资源包。
|
|
151
199
|
* @param {Uint8Array} bytes 资源包字节
|
|
@@ -226,12 +274,43 @@
|
|
|
226
274
|
nodes: parsed.nodes.length,
|
|
227
275
|
bytes: bytes.length,
|
|
228
276
|
},
|
|
277
|
+
// 节点列表(path + size):只读分析接口要逐条列出来回答"包里有什么"。
|
|
278
|
+
// 预检自己只用 nodes 的**个数**,多给一层列表不增加解析成本。
|
|
279
|
+
nodes: parsed.nodes.map((n) => ({ path: n.path, size: n.size })),
|
|
229
280
|
objects: (sf.objects || []).length,
|
|
230
281
|
moc3: got.moc3 ? { bytes: got.moc3.length } : null,
|
|
231
282
|
cubism2Moc: cubism2.count > 0 ? { count: cubism2.count, names: cubism2.names, version: cubism2.sample ? cubism2.sample.version : null } : null,
|
|
232
283
|
reject,
|
|
233
284
|
physics3: got.physics3 ? { bytes: got.physics3.length } : null,
|
|
234
285
|
nativeFiles: (got.nativeFiles || []).map((f) => f.name),
|
|
286
|
+
// TextAsset 明细(名字 / 类型 / 骨架版本 / 字节数):只读分析接口要用它回答
|
|
287
|
+
// "这个包里有哪些骨架、各是什么版本",而预检本身只要"有没有"就够 —— 多给一层不增加解析成本。
|
|
288
|
+
textAssets: collectTextAssets(sf),
|
|
289
|
+
/**
|
|
290
|
+
* 列表显示名(契约 §1.3)。
|
|
291
|
+
*
|
|
292
|
+
* 取值顺序(各条都是"容器里的入口文件名去后缀",不认识业务语义、不编名字):
|
|
293
|
+
* ① `.skel` —— Spine 的入口
|
|
294
|
+
* ② `.model3.json`(TextAsset 形式)—— Cubism 4 的入口
|
|
295
|
+
* ③ `.model3.json`(原生文件形式,见 nativeFiles)
|
|
296
|
+
* ④ `.moc3`(原生文件形式)
|
|
297
|
+
* 多骨架时取**对象表顺序第一个**(本步不拼多个);都没有 ⇒ null(不是空串)。
|
|
298
|
+
*/
|
|
299
|
+
displayName: (() => {
|
|
300
|
+
const assets = collectTextAssets(sf);
|
|
301
|
+
const skel = assets.find((t) => t && t.kind === 'skel');
|
|
302
|
+
if (skel && skel.name) return String(skel.name).replace(/\.skel$/i, '');
|
|
303
|
+
const model3Text = assets.find((t) => t && typeof t.name === 'string' && /\.model3\.json$/i.test(t.name));
|
|
304
|
+
if (model3Text) return String(model3Text.name).replace(/\.model3\.json$/i, '');
|
|
305
|
+
const natives = Array.isArray(got.nativeFiles)
|
|
306
|
+
? got.nativeFiles.map((f) => f && f.name).filter((n) => typeof n === 'string' && n)
|
|
307
|
+
: [];
|
|
308
|
+
const model3Native = natives.find((n) => /\.model3\.json$/i.test(n));
|
|
309
|
+
if (model3Native) return String(model3Native).replace(/\.model3\.json$/i, '');
|
|
310
|
+
const moc3Native = natives.find((n) => /\.moc3$/i.test(n));
|
|
311
|
+
if (moc3Native) return String(moc3Native).replace(/\.moc3$/i, '');
|
|
312
|
+
return null;
|
|
313
|
+
})(),
|
|
235
314
|
textures,
|
|
236
315
|
// 动作数 = AnimationClip 对象数(与装载时的 motion 数同源,但不跑转换)
|
|
237
316
|
motions: countByClass(sf, 'AnimationClip'),
|
|
@@ -498,6 +498,41 @@ function install() {
|
|
|
498
498
|
}
|
|
499
499
|
}
|
|
500
500
|
|
|
501
|
+
// 契约 §1.1 bundle-analyzer:只读分析容器字节流。
|
|
502
|
+
// 实现直接复用 lib/bundle-probe.js(与本插件同目录的那份,与 live2d 插件的逐字节相同),
|
|
503
|
+
// 这里只做"事实 → 契约字段"的映射。verdict 不在这里算:那是核心的判据(src/shared/bundle-shape.mjs)。
|
|
504
|
+
function analyze(bytes) {
|
|
505
|
+
const bp = NS && NS.bundleProbe;
|
|
506
|
+
if (!bp || typeof bp.run !== 'function') {
|
|
507
|
+
return {
|
|
508
|
+
container: null,
|
|
509
|
+
objects: null,
|
|
510
|
+
textures: null,
|
|
511
|
+
warnings: ['插件内缺少 bundle-probe 实现(lib/bundle-probe.js 未加载)'],
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
const res = bp.run(bytes) || {};
|
|
515
|
+
return {
|
|
516
|
+
// 契约字段
|
|
517
|
+
container: res.container || null,
|
|
518
|
+
objects: typeof res.objects === 'number' ? res.objects : null,
|
|
519
|
+
textures: Array.isArray(res.textures) ? res.textures : null,
|
|
520
|
+
// 契约 §1.1 的 textAssets:名字 / 类型 / 骨架版本 / 字节数,由 lib/bundle-probe.js 从对象表取出
|
|
521
|
+
textAssets: Array.isArray(res.textAssets) ? res.textAssets : null,
|
|
522
|
+
warnings: Array.isArray(res.warnings) ? res.warnings : [],
|
|
523
|
+
// 透传既有字段(与 live2d 插件同一套键,便于核心与诊断两端同口径)
|
|
524
|
+
ok: res.ok,
|
|
525
|
+
code: res.code,
|
|
526
|
+
error: res.error,
|
|
527
|
+
moc3: res.moc3 || null,
|
|
528
|
+
cubism2Moc: res.cubism2Moc || null,
|
|
529
|
+
physics3: res.physics3 || null,
|
|
530
|
+
motions: res.motions,
|
|
531
|
+
reject: res.reject || null,
|
|
532
|
+
nativeFiles: res.nativeFiles,
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
|
|
501
536
|
if (host) {
|
|
502
537
|
host.register({
|
|
503
538
|
id: PLUGIN_ID,
|
|
@@ -507,6 +542,8 @@ function install() {
|
|
|
507
542
|
resolve,
|
|
508
543
|
// 契约 §2.2:让宿主与检查器都能发现"本插件能自己算内存代价"
|
|
509
544
|
estimateMemory,
|
|
545
|
+
// 契约 §1.1 bundle-analyzer:只读分析容器字节流(不产模型、不写文件)
|
|
546
|
+
analyze,
|
|
510
547
|
// kind 的唯一权威来源是 plugin.json 的 produces.kind(契约 §3.2),这里带上只为调试可读。
|
|
511
548
|
kind: 'spine',
|
|
512
549
|
fileKinds: ['bundle'],
|
|
@@ -516,7 +553,7 @@ function install() {
|
|
|
516
553
|
// node 侧返回解析入口:服务端解包直接从返回值取 canHandle/resolve,不经过宿主注册。
|
|
517
554
|
// __test 只给单测用(纯函数、无副作用、宿主不读它):parseAtlasPages 是闭包内私有函数,
|
|
518
555
|
// 没有它就无法为"带 BOM 的 atlas 首行"补单测(这正是 NIKKE 根 34 份带 BOM 的 atlas 丢第一页贴图的根因)。
|
|
519
|
-
return { canHandle, resolve, estimateMemory, probeContainer, PLUGIN_ID, __test: { parseAtlasPages } };
|
|
556
|
+
return { canHandle, resolve, estimateMemory, probeContainer, analyze, PLUGIN_ID, __test: { parseAtlasPages } };
|
|
520
557
|
}
|
|
521
558
|
|
|
522
559
|
// 执行安装。为什么不用 `export { canHandle }`:那会把文件变成 ESM,
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// lib/bundle-probe.js —— 资源包「装载前预检」(只做便宜的事)
|
|
3
|
+
//
|
|
4
|
+
// 目的:不装载、不解码纹理像素,就能回答"这个资源包能不能装 / 装起来会缺什么"。
|
|
5
|
+
// 预检内容:容器头 → 对象表 → moc3/physics3 存在性 → 纹理格式是否可解码 → 动画片段数。
|
|
6
|
+
//
|
|
7
|
+
// 为什么放在 lib 而不是插件/服务端各写一份:
|
|
8
|
+
// 浏览器侧(插件的 probe)与 Node 侧(/api/bundle/probe)必须给出**同一口径**的结论,
|
|
9
|
+
// 否则"预检说能装、装载却失败"这类漂移会反复出现。这里只依赖 NS.* 里已有的库,
|
|
10
|
+
// 两端各自加载同一份文件即可。
|
|
11
|
+
//
|
|
12
|
+
// 挂载:globalThis.__ULB__.bundleProbe = { run, formatSupport }
|
|
13
|
+
//
|
|
14
|
+
// 同源副本:本文件在 unity-live2d-bundle 与 unity-spine-bundle 两个插件里各存一份,
|
|
15
|
+
// 内容逐字节相同(两个插件都声明 bundle-analyzer 角色,各自要能独立提供 analyze)。
|
|
16
|
+
// 改一处必须同步改另一处;test/bundle-probe-parity.test.mjs 比对两份 sha256。
|
|
17
|
+
// ============================================================================
|
|
18
|
+
|
|
19
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
{
|
|
22
|
+
const NS = (globalThis.__ULB__ = globalThis.__ULB__ || {});
|
|
23
|
+
|
|
24
|
+
// 已知但暂未实现的格式:预检要让调用方看到"ASTC"而不是"未知格式 50",
|
|
25
|
+
// 这样才能据此判断"是这个资源用了新压缩格式"而不是"文件坏了"。
|
|
26
|
+
const KNOWN_UNSUPPORTED = {
|
|
27
|
+
24: 'BC6H', 25: 'BC7',
|
|
28
|
+
30: 'PVRTC_RGB2', 31: 'PVRTC_RGBA2', 32: 'PVRTC_RGB4', 33: 'PVRTC_RGBA4',
|
|
29
|
+
50: 'ASTC_RGBA', 51: 'ASTC_RGBA_HDR', 52: 'ASTC_RGB', 53: 'ASTC_RGB_HDR',
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* 查某个 Unity TextureFormat 是否**可解码**。
|
|
34
|
+
*
|
|
35
|
+
* 判据只有一个:`texdecode.canDecode(fmt)`(内部只认 DECODERS 表)。
|
|
36
|
+
* 为什么不再用 `!!FORMATS[fmt]`:FORMATS 是格式字典(名称/尺寸/block),含 48 ETC2_RGBA1
|
|
37
|
+
* 这种"有条目但从未实现解码"的格式 ⇒ 预检会报"支持"、真正解包才抛 ULB_ERR_TEX_DECODE,
|
|
38
|
+
* 同一件事两套判据。改名/尺寸仍走 FORMATS,但"能不能解"不再由它决定。
|
|
39
|
+
*/
|
|
40
|
+
function formatSupport(fmt) {
|
|
41
|
+
const table = NS.texdecode && NS.texdecode.FORMATS ? NS.texdecode.FORMATS : null;
|
|
42
|
+
const entry = table ? table[fmt] : null;
|
|
43
|
+
const raw = NS.texdecode && NS.texdecode.formatName ? NS.texdecode.formatName(fmt) : `未知格式 ${fmt}`;
|
|
44
|
+
const name = entry ? raw : (KNOWN_UNSUPPORTED[fmt] || raw);
|
|
45
|
+
const canDecode = NS.texdecode && typeof NS.texdecode.canDecode === 'function'
|
|
46
|
+
? NS.texdecode.canDecode(fmt)
|
|
47
|
+
: false; // 缺 canDecode 时按"不可解码"处理:宁可早拒绝,也不要报"支持"却在解包时炸
|
|
48
|
+
return { supported: canDecode, formatName: name };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** 从序列化文件里按类名统计对象数(避免为了数动作而跑一遍动画转换) */
|
|
52
|
+
function countByClass(sf, className) {
|
|
53
|
+
try {
|
|
54
|
+
const stats = NS.serialized.typeStats(sf);
|
|
55
|
+
if (!stats) return null;
|
|
56
|
+
for (const k of Object.keys(stats)) {
|
|
57
|
+
if (k.toLowerCase() === String(className).toLowerCase()) return stats[k];
|
|
58
|
+
}
|
|
59
|
+
return 0;
|
|
60
|
+
} catch {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Cubism 2.1 运行时数据 .moc 的魔数:**小写三字节** 'm' 'o' 'c',紧随其后的第 4 字节是
|
|
66
|
+
// **文件版本号**(不是第四位魔数)。取证来源:Cubism 2 官方运行时 live2d.min.js 的
|
|
67
|
+
// loadModel() 里逐字节校验 `109 && 111 && 99`,随后把下一字节当 version 与 SDK 版本比较。
|
|
68
|
+
// ⇒ 判据**不能**写成 "moc\0"(第 4 字节是版本号,通常非 0)。
|
|
69
|
+
const CUBISM2_MOC_MAGIC = [0x6d, 0x6f, 0x63];
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* 在这个包里找 Cubism 2.1 的 .moc 运行时数据(**只判定存在性,不解析**)。
|
|
73
|
+
*
|
|
74
|
+
* 为什么要它:.moc 是 Cubism 2.1 的模型二进制,Cubism 3+ 的 SDK/运行时**完全不支持**它
|
|
75
|
+
* (官方帮助文档明说不支持 .moc/.mtn)。这类包既没有 moc3、也没有 .skel,两个 asset-provider
|
|
76
|
+
* 都不会认领 ⇒ 用户在界面上只看到一句"插件判定不处理该文件",无法判断是自己资源有问题、
|
|
77
|
+
* 还是格式超出支持范围。本函数就是为了让上层能说清"这是什么、为什么不行、你能做什么"。
|
|
78
|
+
*
|
|
79
|
+
* 判据(**宁缺勿错**,三条全满足才算命中):
|
|
80
|
+
* ① MonoBehaviour(class 114)的字节里出现 'moc' 魔数;
|
|
81
|
+
* ② 魔数前 4 字节(u32)是有意义的长度 L,且 `魔数起点 + L === 对象末尾`
|
|
82
|
+
* —— 与 findMoc3 同款自洽校验,把"随机字节里凑巧出现 moc"挡掉;
|
|
83
|
+
* ③ 魔数后第 4 字节是本文件的版本号,落在合理区间 1..16。
|
|
84
|
+
* 扩展名不参与判定(只用来在文案里报出文件名,供用户核对)。
|
|
85
|
+
*
|
|
86
|
+
* @param {object} sf SerializedFile(NS.serialized.parse 的结果)
|
|
87
|
+
* @returns {{count:number, names:string[], sample:{object:object, magicOffset:number, version:number, bytes:number}|null}}
|
|
88
|
+
*/
|
|
89
|
+
function findCubism2Moc(sf) {
|
|
90
|
+
const out = { count: 0, names: [], sample: null };
|
|
91
|
+
if (!sf || !NS.serialized || !NS.extract) return out;
|
|
92
|
+
let monos;
|
|
93
|
+
try {
|
|
94
|
+
monos = NS.serialized.byClass(sf, 114);
|
|
95
|
+
} catch {
|
|
96
|
+
return out; // 对象表读不出来就当没发现(宁可漏报,也不把别的包误判成 Cubism 2)
|
|
97
|
+
}
|
|
98
|
+
// 第一路(主判据):MonoBehaviour 内嵌字节里的魔数 + 前置长度自洽 + 版本合理
|
|
99
|
+
for (const obj of monos) {
|
|
100
|
+
const bytes = sf.bytes.subarray(obj.dataOffset, obj.dataOffset + obj.byteSize);
|
|
101
|
+
let from = 0;
|
|
102
|
+
for (;;) {
|
|
103
|
+
const at = NS.extract.indexOfMagic(bytes, CUBISM2_MOC_MAGIC, from);
|
|
104
|
+
if (at < 0) break;
|
|
105
|
+
from = at + 1;
|
|
106
|
+
// ② 前置长度自洽:魔数前 4 字节是小端长度,且「魔数起点 + L」恰好到对象末尾
|
|
107
|
+
// (与 findMoc3 同款;这一条把"随机字节里凑巧出现 moc"挡掉)
|
|
108
|
+
if (at < 4) continue;
|
|
109
|
+
const len = bytes[at - 4] | (bytes[at - 3] << 8) | (bytes[at - 2] << 16) | (bytes[at - 1] << 24);
|
|
110
|
+
if (!(len > 16) || at + len !== bytes.length) continue;
|
|
111
|
+
// ③ 版本号合理(Cubism 2.1 的 .moc 版本是个小整数,见魔数注释里的取证)
|
|
112
|
+
const end = at + 3;
|
|
113
|
+
if (end >= bytes.length) continue;
|
|
114
|
+
const version = bytes[end];
|
|
115
|
+
if (version < 1 || version > 16) continue;
|
|
116
|
+
out.count += 1;
|
|
117
|
+
const name = readObjectName(sf, obj);
|
|
118
|
+
if (name) out.names.push(name);
|
|
119
|
+
if (!out.sample) out.sample = { object: obj, magicOffset: at, version, bytes: len, by: 'magic' };
|
|
120
|
+
break; // 一个对象里只认第一处(同一个 .moc 不会被切成两段)
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// 第二路(兜底,只作辅助):TextAsset 的名字以 .moc 结尾。
|
|
124
|
+
// 为什么要这一路:真 .moc 在包里的形态**没有样本可验**(当前资源 0 个)。
|
|
125
|
+
// 若它是以 TextAsset/独立文件形式存在(而非仿真 moc3 的内嵌 TypelessData),
|
|
126
|
+
// 就不存在"前置 u32 长度",第一路会漏报。此时扩展名是唯一线索。
|
|
127
|
+
// 安全性:本函数只在 run() 里"已确认没有 moc3"之后才被调用,所以不会把 moc3 包误判成 Cubism 2。
|
|
128
|
+
if (out.count === 0) {
|
|
129
|
+
try {
|
|
130
|
+
for (const ta of NS.extract.findTextAssets(sf)) {
|
|
131
|
+
const nm = ta && ta.name ? String(ta.name) : '';
|
|
132
|
+
if (!/\.moc$/i.test(nm)) continue;
|
|
133
|
+
out.count += 1;
|
|
134
|
+
out.names.push(nm);
|
|
135
|
+
if (!out.sample) out.sample = { object: ta.object, magicOffset: -1, version: null, bytes: ta.bytes ? ta.bytes.length : null, by: 'name' };
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
} catch { /* 类型树读不出来就不兜底,不影响主判据 */ }
|
|
139
|
+
}
|
|
140
|
+
return out;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** 读对象名(读不出来返回空串;名字只用于文案,不参与判定) */
|
|
144
|
+
function readObjectName(sf, obj) {
|
|
145
|
+
try {
|
|
146
|
+
const fields = NS.typetree ? NS.typetree.readObject(sf, obj) : null;
|
|
147
|
+
return (fields && (fields.m_Name || fields.m_PathName)) || '';
|
|
148
|
+
} catch {
|
|
149
|
+
return '';
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* 从对象表取 TextAsset:名字 / 类型 / 骨架版本 / 字节数。
|
|
155
|
+
*
|
|
156
|
+
* 为什么走 typetree 的 rawStrings 而不是 extract 的文本分支:
|
|
157
|
+
* m_Script 是二进制(.skel),按 UTF-8 字符串读再编码回去会毁字节
|
|
158
|
+
* (实测 651994 字节 → 641818 字符含 165995 个 U+FFFD,长度都对不上)。
|
|
159
|
+
*
|
|
160
|
+
* 骨架版本的正则与 src/server/assets/probe.mjs 的 detectSkelVersion 完全一致:
|
|
161
|
+
* 两处必须同口径,否则"分析说 4.1.11、扫描器说默认 4.0"会各说一套。
|
|
162
|
+
*
|
|
163
|
+
* @param {object} sf serialized.parse() 结果
|
|
164
|
+
* @returns {Array<{name: string, kind: string, spineVersion: string|null, size: number}>}
|
|
165
|
+
*/
|
|
166
|
+
function collectTextAssets(sf) {
|
|
167
|
+
const CLASS_ID_TEXT_ASSET = 49;
|
|
168
|
+
const out = [];
|
|
169
|
+
for (const obj of NS.serialized.byClass(sf, CLASS_ID_TEXT_ASSET)) {
|
|
170
|
+
let fields;
|
|
171
|
+
try {
|
|
172
|
+
fields = NS.typetree.readObject(sf, obj, { rawStrings: true });
|
|
173
|
+
} catch {
|
|
174
|
+
continue; // 单个对象读不出来不影响其它 TextAsset
|
|
175
|
+
}
|
|
176
|
+
const name = (fields.m_Name && typeof fields.m_Name.text === 'string')
|
|
177
|
+
? fields.m_Name.text : String(fields.m_Name || '');
|
|
178
|
+
const raw = fields.m_Script && fields.m_Script.bytes;
|
|
179
|
+
if (!raw || !raw.length) continue;
|
|
180
|
+
const lower = name.toLowerCase();
|
|
181
|
+
let kind = 'bytes';
|
|
182
|
+
if (lower.endsWith('.skel')) kind = 'skel';
|
|
183
|
+
else if (lower.endsWith('.atlas')) kind = 'atlas';
|
|
184
|
+
else if (lower.endsWith('.json')) kind = 'json';
|
|
185
|
+
let spineVersion = null;
|
|
186
|
+
if (kind === 'skel') {
|
|
187
|
+
// 只看前 512 字节:二进制骨架的版本串在文件头附近,整份读进来没有意义
|
|
188
|
+
const head = new TextDecoder('latin1').decode(raw.subarray(0, 512));
|
|
189
|
+
const m = head.match(/(2\.\d+|3\.[5-8]|4\.[0-3])\.\d+[\w-]*/);
|
|
190
|
+
if (m) spineVersion = m[0];
|
|
191
|
+
}
|
|
192
|
+
out.push({ name, kind, spineVersion, size: raw.length });
|
|
193
|
+
}
|
|
194
|
+
return out;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* 预检一个资源包。
|
|
199
|
+
* @param {Uint8Array} bytes 资源包字节
|
|
200
|
+
* @returns {object} { ok, code?, error?, container?, objects?, moc3?, physics3?, textures?, motions? }
|
|
201
|
+
*/
|
|
202
|
+
function run(bytes) {
|
|
203
|
+
const E = NS.errors;
|
|
204
|
+
if (!bytes || !bytes.length) {
|
|
205
|
+
return { ok: false, code: E.CODES.NO_FILE, error: '资源包为空或不存在' };
|
|
206
|
+
}
|
|
207
|
+
// 容器头:只看签名,不合格直接定性(不必进解析)
|
|
208
|
+
let sig = '';
|
|
209
|
+
for (let i = 0; i < Math.min(7, bytes.length); i++) sig += String.fromCharCode(bytes[i]);
|
|
210
|
+
if (sig !== 'UnityFS') {
|
|
211
|
+
const shown = sig.replace(/[^\x20-\x7e]/g, '?');
|
|
212
|
+
return { ok: false, code: E.CODES.NOT_UNITYFS, error: `不是 UnityFS 资源包(signature="${shown}")` };
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
let parsed;
|
|
216
|
+
let sf;
|
|
217
|
+
let got;
|
|
218
|
+
try {
|
|
219
|
+
parsed = NS.unityfs.parse(bytes);
|
|
220
|
+
// 结构判据(不是名字前缀):CAB- + 32 位十六进制、无后缀。
|
|
221
|
+
// .resS / .resource 也以 CAB- 开头,但都不是 serialized file(后者是 FSB5 音频银行)。
|
|
222
|
+
const cab = parsed.nodes.find((n) => /^CAB-[0-9a-f]{32}$/i.test(n.path));
|
|
223
|
+
if (!cab) {
|
|
224
|
+
return { ok: false, code: E.CODES.NO_CAB, error: '资源包里没有 CAB-* 节点(不是资产包)' };
|
|
225
|
+
}
|
|
226
|
+
const resSNode = parsed.nodes.find((n) => /\.resS$/.test(n.path));
|
|
227
|
+
const cabBytes = NS.unityfs.nodeBytes(parsed, cab.path);
|
|
228
|
+
const resSBytes = resSNode ? NS.unityfs.nodeBytes(parsed, resSNode.path) : null;
|
|
229
|
+
sf = NS.serialized.parse(cabBytes);
|
|
230
|
+
got = NS.extract.extractAll({ cabBytes, resSBytes, sf });
|
|
231
|
+
} catch (e) {
|
|
232
|
+
return { ok: false, code: E.CODES.CONTAINER_PARSE, error: e.message };
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// 纹理:只判定格式是否可解码,**不解码像素**(解码是最贵的一步,预检故意跳过)
|
|
236
|
+
const textures = (got.textures || []).map((t) => {
|
|
237
|
+
const s = formatSupport(t.format);
|
|
238
|
+
return {
|
|
239
|
+
name: t.name,
|
|
240
|
+
width: t.width,
|
|
241
|
+
height: t.height,
|
|
242
|
+
format: t.format,
|
|
243
|
+
formatName: s.formatName,
|
|
244
|
+
supported: s.supported,
|
|
245
|
+
};
|
|
246
|
+
});
|
|
247
|
+
const unsupported = textures.filter((t) => !t.supported).map((t) => t.formatName);
|
|
248
|
+
|
|
249
|
+
// Cubism 2.1 的 .moc 存在性:**只有"没有 moc3"时才有意义**(有 moc3 的包一律按 moc3 走,
|
|
250
|
+
// 哪怕字节里凑巧有 'moc' 片段也不该被说成 Cubism 2 —— 这是判据可靠性的关键)
|
|
251
|
+
const moc3Hit = !!got.moc3;
|
|
252
|
+
const cubism2 = moc3Hit ? { count: 0, names: [], sample: null } : findCubism2Moc(sf);
|
|
253
|
+
// 结构化"为什么没人认领",交给上层(宿主/调试日志)原样透出给用户
|
|
254
|
+
let reject = null;
|
|
255
|
+
if (!moc3Hit && cubism2.count > 0) {
|
|
256
|
+
const ver = cubism2.sample ? cubism2.sample.version : null;
|
|
257
|
+
const fileHint = cubism2.names.length ? `(${cubism2.names.join('、')})` : '';
|
|
258
|
+
reject = {
|
|
259
|
+
code: 'LIVE2D_CUBISM2_MOC_UNSUPPORTED',
|
|
260
|
+
// 三句话缺一不可:这是什么 / 为什么不行 / 用户能做什么
|
|
261
|
+
message: `这是 Cubism 2.1 的 .moc 模型数据${fileHint}${ver ? `,版本 ${ver}` : ''}。`
|
|
262
|
+
+ 'Cubism 3 及以后的 SDK/运行时已不支持 .moc 与 .mtn 这两种旧格式,本页面的 Live2D 渲染只支持 .moc3。'
|
|
263
|
+
+ '若你手上有该模型的 .cmox 工程文件,可用官方 Cubism Editor 打开并转换为 .moc3 后再放进来;'
|
|
264
|
+
+ '如果是从游戏包里直接拆出的 .moc,则没有可用的转换途径(需要原作者提供工程文件)。',
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
return {
|
|
269
|
+
ok: true,
|
|
270
|
+
container: {
|
|
271
|
+
version: parsed.version,
|
|
272
|
+
engine: parsed.engineVersion,
|
|
273
|
+
player: parsed.playerVersion,
|
|
274
|
+
nodes: parsed.nodes.length,
|
|
275
|
+
bytes: bytes.length,
|
|
276
|
+
},
|
|
277
|
+
// 节点列表(path + size):只读分析接口要逐条列出来回答"包里有什么"。
|
|
278
|
+
// 预检自己只用 nodes 的**个数**,多给一层列表不增加解析成本。
|
|
279
|
+
nodes: parsed.nodes.map((n) => ({ path: n.path, size: n.size })),
|
|
280
|
+
objects: (sf.objects || []).length,
|
|
281
|
+
moc3: got.moc3 ? { bytes: got.moc3.length } : null,
|
|
282
|
+
cubism2Moc: cubism2.count > 0 ? { count: cubism2.count, names: cubism2.names, version: cubism2.sample ? cubism2.sample.version : null } : null,
|
|
283
|
+
reject,
|
|
284
|
+
physics3: got.physics3 ? { bytes: got.physics3.length } : null,
|
|
285
|
+
nativeFiles: (got.nativeFiles || []).map((f) => f.name),
|
|
286
|
+
// TextAsset 明细(名字 / 类型 / 骨架版本 / 字节数):只读分析接口要用它回答
|
|
287
|
+
// "这个包里有哪些骨架、各是什么版本",而预检本身只要"有没有"就够 —— 多给一层不增加解析成本。
|
|
288
|
+
textAssets: collectTextAssets(sf),
|
|
289
|
+
/**
|
|
290
|
+
* 列表显示名(契约 §1.3)。
|
|
291
|
+
*
|
|
292
|
+
* 取值顺序(各条都是"容器里的入口文件名去后缀",不认识业务语义、不编名字):
|
|
293
|
+
* ① `.skel` —— Spine 的入口
|
|
294
|
+
* ② `.model3.json`(TextAsset 形式)—— Cubism 4 的入口
|
|
295
|
+
* ③ `.model3.json`(原生文件形式,见 nativeFiles)
|
|
296
|
+
* ④ `.moc3`(原生文件形式)
|
|
297
|
+
* 多骨架时取**对象表顺序第一个**(本步不拼多个);都没有 ⇒ null(不是空串)。
|
|
298
|
+
*/
|
|
299
|
+
displayName: (() => {
|
|
300
|
+
const assets = collectTextAssets(sf);
|
|
301
|
+
const skel = assets.find((t) => t && t.kind === 'skel');
|
|
302
|
+
if (skel && skel.name) return String(skel.name).replace(/\.skel$/i, '');
|
|
303
|
+
const model3Text = assets.find((t) => t && typeof t.name === 'string' && /\.model3\.json$/i.test(t.name));
|
|
304
|
+
if (model3Text) return String(model3Text.name).replace(/\.model3\.json$/i, '');
|
|
305
|
+
const natives = Array.isArray(got.nativeFiles)
|
|
306
|
+
? got.nativeFiles.map((f) => f && f.name).filter((n) => typeof n === 'string' && n)
|
|
307
|
+
: [];
|
|
308
|
+
const model3Native = natives.find((n) => /\.model3\.json$/i.test(n));
|
|
309
|
+
if (model3Native) return String(model3Native).replace(/\.model3\.json$/i, '');
|
|
310
|
+
const moc3Native = natives.find((n) => /\.moc3$/i.test(n));
|
|
311
|
+
if (moc3Native) return String(moc3Native).replace(/\.moc3$/i, '');
|
|
312
|
+
return null;
|
|
313
|
+
})(),
|
|
314
|
+
textures,
|
|
315
|
+
// 动作数 = AnimationClip 对象数(与装载时的 motion 数同源,但不跑转换)
|
|
316
|
+
motions: countByClass(sf, 'AnimationClip'),
|
|
317
|
+
// 有纹理格式解不了时不算整体失败,只把结论带出来,交给调用方决定
|
|
318
|
+
warnings: unsupported.length ? [`有纹理格式暂不支持:${[...new Set(unsupported)].join('、')}`] : [],
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
NS.bundleProbe = { run, formatSupport, findCubism2Moc };
|
|
323
|
+
}
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
"id": "unity-spine-bundle",
|
|
3
3
|
"name": "Unity Spine 资源包",
|
|
4
4
|
"provides": [
|
|
5
|
-
"asset-provider"
|
|
5
|
+
"asset-provider",
|
|
6
|
+
"bundle-analyzer"
|
|
6
7
|
],
|
|
7
8
|
"label": "Spine包",
|
|
8
9
|
"accent": "#2b6cb0",
|
|
@@ -69,6 +70,7 @@
|
|
|
69
70
|
"lib/etc2.js",
|
|
70
71
|
"lib/dxt.js",
|
|
71
72
|
"lib/texdecode.js",
|
|
73
|
+
"lib/bundle-probe.js",
|
|
72
74
|
"lib/png.js",
|
|
73
75
|
"index.js"
|
|
74
76
|
]
|