- 新增 4 编排层插件(session-score/hud-ui/scene-fsm/timer-scheduler),barrel 注册 12 件,各 impl/api.d.ts/manifest/PLUGIN.md/test,全 node 测绿;audio-music manifest 描述修红门 - skill littlejs-game-dev(code 层:12 插件 API/结构/写-vs-调/资产-mmx/工厂契约)+ sim-business-game-design(design 层:经营模拟范式 + 反"无趣"配方) - _template(游戏克隆起点,10/10)+ catch-fruit(sonnet 扮生成 agent 只凭 skill 产出,25/25,真浏览器可玩 + canvas 自适应修复) - docs/agent-specs SAA→A-model 改写评审版(Opus+Codex 双评审收口;D1=A 全压 A-model/D6=A 押 SAA,D6 已 mini-desktop 活验证 1/1) - staging-ops 加「ssh 绕代理直连内网 IP」配方 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
132 lines
6.7 KiB
JavaScript
132 lines
6.7 KiB
JavaScript
/**
|
||
* all-plugins.js — 全插件注册 barrel(集成段门①入口 + host-dev 冒烟复用)
|
||
* owner:T1b-α 集成段 | 消费方:scripts/build.mjs 全插件注册构建门 / host-dev 冒烟页 / SIZES 对照
|
||
*
|
||
* 【本文件定位】
|
||
* 把 core 协议 + 现有插件工厂在一个模块里汇总导出,并提供 `registerAllPlugins(registry, opts)`:
|
||
* 按依赖安全顺序把全部业务插件 register 进一个 PluginRegistry。
|
||
* - 集成段「全插件注册构建绿」门:以本文件为 esbuild 入口打包,验证「core + 九插件 + 注册编排」
|
||
* 在锁参 bundle 下零报错、可摇树、可生成 iife 产物。
|
||
* - host-dev 冒烟:host.js 复用 registerAllPlugins 一把挂全插件,逐件最小调用演示。
|
||
*
|
||
* 【为什么需要 barrel】
|
||
* core 的 PluginRegistry 只管「注册顺序即 init 顺序、依赖缺失即隔离」,不替你排拓扑(见 REPORT §3 取舍三)。
|
||
* 现有九件插件 dependencies 均为 [](无相互依赖,已逐件核对 manifest),故注册顺序无硬约束;
|
||
* 本 barrel 仍以「数学/能力基元在前、取证探针在后」的稳定顺序注册,便于 probe 的 pluginSet 快照稳定。
|
||
*
|
||
* 【边界】
|
||
* 本文件只做「能力编排 + 注册」,绝不内置任何玩法/美术/关卡/UI(模板哲学红线)。
|
||
* 插件实例的具体最小调用演示在 host.js 的 smoke 流程里,不在此处(此处只负责把能力凑齐并注册)。
|
||
*/
|
||
|
||
'use strict';
|
||
|
||
// ── core 协议(唯一权威实现源)──────────────────────────────────────────────
|
||
import {
|
||
PluginRegistry,
|
||
createHostDevContext,
|
||
SeededRandom,
|
||
HostDevTime,
|
||
HostDevInputBridge,
|
||
deriveSeed,
|
||
INPUT_EVENT_TYPE_LIST,
|
||
CORE_PROTOCOL_VERSION,
|
||
} from './core/plugin.js';
|
||
|
||
// ── 业务插件工厂(逐件按 manifest.exports.named 的工厂入口导入)──────────────
|
||
import { createCollisionPlugin } from './plugins/collision/impl.js';
|
||
import { createParticlesJuicePlugin } from './plugins/particles-juice/impl.js';
|
||
import { createPhysicsLitePlugin } from './plugins/physics-lite/impl.js';
|
||
import { createGamefeelPlugin } from './plugins/gamefeel/impl.js';
|
||
import { createPalettePostPlugin } from './plugins/palette-post/impl.js';
|
||
import { createAudioMusicPlugin } from './plugins/audio-music/impl.js';
|
||
import { createSaveProgressPlugin } from './plugins/save-progress/impl.js';
|
||
import { createRuntimeProbePlugin } from './plugins/runtime-probe/impl.js';
|
||
// ── 编排层 4 件(绘境AI 2026-06-21 新增:计分胜负 / HUD-UI / 场景状态机 / 受控调度)──
|
||
import { createSessionScorePlugin } from './plugins/session-score/impl.js';
|
||
import { createHudUiPlugin } from './plugins/hud-ui/impl.js';
|
||
import { createSceneFsmPlugin } from './plugins/scene-fsm/impl.js';
|
||
import { createTimerSchedulerPlugin } from './plugins/timer-scheduler/impl.js';
|
||
// _example 是「空插件样例」(五件全),不属业务能力面;barrel 不默认注册它,
|
||
// 但导出其工厂供 host 在需要「九件齐挂」演示时按需取用(SIZES 仍单独度量 _example,见 size.mjs)。
|
||
import { createExamplePlugin } from './plugins/_example/impl.js';
|
||
|
||
/**
|
||
* 插件工厂登记表(name → 工厂)。顺序 = 注册建议顺序(能力基元在前、编排层居中、取证探针 runtime-probe 在后)。
|
||
* runtime-probe 放最后,使其 init 时取 registry.list() 能看到已注册的其它插件(pluginSet 快照更完整)。
|
||
* @type {Array<{ key:string, make:(opts?:object)=>import('./core/api.d.ts').Plugin }>}
|
||
*/
|
||
const PLUGIN_FACTORIES = [
|
||
{ key: 'collision', make: createCollisionPlugin },
|
||
{ key: 'physics-lite', make: createPhysicsLitePlugin },
|
||
{ key: 'gamefeel', make: createGamefeelPlugin },
|
||
{ key: 'particles-juice', make: createParticlesJuicePlugin },
|
||
{ key: 'palette-post', make: createPalettePostPlugin },
|
||
{ key: 'save-progress', make: createSaveProgressPlugin },
|
||
{ key: 'audio-music', make: createAudioMusicPlugin },
|
||
// 编排层 4 件(计分/UI/状态机/调度;无依赖,置于探针前以纳入 pluginSet 快照)。
|
||
{ key: 'session-score', make: createSessionScorePlugin },
|
||
{ key: 'hud-ui', make: createHudUiPlugin },
|
||
{ key: 'scene-fsm', make: createSceneFsmPlugin },
|
||
{ key: 'timer-scheduler', make: createTimerSchedulerPlugin },
|
||
// runtime-probe 末位:见上注释(pluginSet 快照完整性)。
|
||
{ key: 'runtime-probe', make: createRuntimeProbePlugin },
|
||
];
|
||
|
||
/**
|
||
* 把全部业务插件实例化并 register 进给定注册器(不 initAll,由调用方决定时机)。
|
||
*
|
||
* @param {PluginRegistry} registry 目标注册器(调用方持有,便于先 useContext 再 initAll)。
|
||
* @param {Object} [opts] 各插件工厂选项(按 key 透传;缺省全用插件默认)。
|
||
* 形如 `{ 'particles-juice': { seed: 1 }, 'audio-music': { masterVolume: 0.8 } }`。
|
||
* @param {string[]} [opts.__skip] 跳过注册的插件 key 列表(host-dev 冒烟用:runtime-probe 需由 host
|
||
* 按「启动六锚点」canonical 顺序手动驱动其 t_input_bound 在 t_first_paint 之后打点,故不走本批量注册——
|
||
* 见 host.js。注意 `__skip` 是控制字段,不会被当作某插件的工厂选项透传)。
|
||
* @returns {{ registry: PluginRegistry, instances: Record<string, import('./core/api.d.ts').Plugin> }}
|
||
* 返回注册器与「name→实例」映射(host 冒烟据此对各插件做最小调用)。
|
||
*/
|
||
function registerAllPlugins(registry, opts) {
|
||
const o = opts || {};
|
||
const skip = Array.isArray(o.__skip) ? new Set(o.__skip) : new Set();
|
||
/** @type {Record<string, import('./core/api.d.ts').Plugin>} */
|
||
const instances = {};
|
||
for (const { key, make } of PLUGIN_FACTORIES) {
|
||
if (skip.has(key)) continue; // 跳过(host 自管该插件生命周期)
|
||
// 逐件实例化并注册;工厂选项按 key 透传。
|
||
const inst = make(o[key]);
|
||
registry.register(inst);
|
||
instances[key] = inst;
|
||
}
|
||
return { registry, instances };
|
||
}
|
||
|
||
// 统一再导出:core 公开面 + 九件工厂 + 编排器,供构建门入口 / host-dev / 单测复用。
|
||
export {
|
||
// core
|
||
PluginRegistry,
|
||
createHostDevContext,
|
||
SeededRandom,
|
||
HostDevTime,
|
||
HostDevInputBridge,
|
||
deriveSeed,
|
||
INPUT_EVENT_TYPE_LIST,
|
||
CORE_PROTOCOL_VERSION,
|
||
// 插件工厂
|
||
createCollisionPlugin,
|
||
createParticlesJuicePlugin,
|
||
createPhysicsLitePlugin,
|
||
createGamefeelPlugin,
|
||
createPalettePostPlugin,
|
||
createAudioMusicPlugin,
|
||
createSaveProgressPlugin,
|
||
createRuntimeProbePlugin,
|
||
createSessionScorePlugin,
|
||
createHudUiPlugin,
|
||
createSceneFsmPlugin,
|
||
createTimerSchedulerPlugin,
|
||
createExamplePlugin,
|
||
// 编排
|
||
registerAllPlugins,
|
||
PLUGIN_FACTORIES,
|
||
};
|