mirror of
https://github.com/Heretek-Games/drop-emulation.git
synced 2026-11-07 10:05:59 -10:00
feat(init): scaffold drop-emulation (plugin API v2)
This commit is contained in:
commit
a5aac5d1d6
11 files changed
+228
No files matched your search
@@ -0,0 +1,3 @@
|
||||
node_modules/
|
||||
dist/
|
||||
*.log
|
||||
@@ -0,0 +1,14 @@
|
||||
# AGENTS.md — drop-emulation
|
||||
|
||||
Emulator and ROM linking plugin for Drop (#10, #189).
|
||||
|
||||
## Commands
|
||||
|
||||
```sh
|
||||
pnpm install
|
||||
pnpm build
|
||||
pnpm test
|
||||
```
|
||||
|
||||
Built on `@droposs/plugin-sdk` (plugin API v2); the dependency resolves the
|
||||
sibling checkout at `../drop-plugin-sdk/packages/plugin-sdk`.
|
||||
@@ -0,0 +1,9 @@
|
||||
# Drop Emulation
|
||||
|
||||
Emulator and ROM linking plugin for Drop (#10, #189).
|
||||
|
||||
## Build
|
||||
|
||||
```sh
|
||||
pnpm install && pnpm build && pnpm test
|
||||
```
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"id": "drop-emulation",
|
||||
"name": "Emulation & ROM Linking",
|
||||
"version": "0.1.0",
|
||||
"description": "Links ROM titles to emulators and rewrites launch arguments",
|
||||
"author": "Heretek Games",
|
||||
"apiVersion": 2,
|
||||
"trust": "trusted",
|
||||
"storageVersion": 1,
|
||||
"capabilities": [
|
||||
"ui:slot",
|
||||
"game:launch-hook",
|
||||
"system:command",
|
||||
"game:fs",
|
||||
"client:storage"
|
||||
],
|
||||
"targets": [
|
||||
"client"
|
||||
],
|
||||
"entry": "dist/src/index.js"
|
||||
}
|
||||
Generated
+87
@@ -0,0 +1,87 @@
|
||||
{
|
||||
"name": "drop-emulation",
|
||||
"version": "0.1.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "drop-emulation",
|
||||
"version": "0.1.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@droposs/plugin-sdk": "file:../drop-plugin-sdk/packages/plugin-sdk"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@droposs/plugin-cli": "file:../drop-plugin-sdk/packages/plugin-cli",
|
||||
"@types/node": "^22.0.0",
|
||||
"typescript": "^5.7.0"
|
||||
}
|
||||
},
|
||||
"../drop-plugin-sdk/packages/plugin-cli": {
|
||||
"name": "@droposs/plugin-cli",
|
||||
"version": "0.3.0",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@droposs/plugin-sdk": "workspace:*",
|
||||
"ajv": "^8.20.0",
|
||||
"esbuild": "^0.28.2"
|
||||
},
|
||||
"bin": {
|
||||
"drop-plugin": "bin/drop-plugin.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.0.0",
|
||||
"typescript": "^5.7.0"
|
||||
}
|
||||
},
|
||||
"../drop-plugin-sdk/packages/plugin-sdk": {
|
||||
"name": "@droposs/plugin-sdk",
|
||||
"version": "0.3.0",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.0.0",
|
||||
"typescript": "^5.7.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@droposs/plugin-cli": {
|
||||
"resolved": "../drop-plugin-sdk/packages/plugin-cli",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@droposs/plugin-sdk": {
|
||||
"resolved": "../drop-plugin-sdk/packages/plugin-sdk",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "22.20.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.2.tgz",
|
||||
"integrity": "sha512-xlvWf4Vs9n1PEVYwP1n4vvG07M6y8WgvJ2t0vbrWTmijsIHp1cS+uJ2kMIRdY3nHZK0nCYKrPeD171+SzF4/zw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"undici-types": "~6.21.0"
|
||||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.9.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
|
||||
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.17"
|
||||
}
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "6.21.0",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
|
||||
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "drop-emulation",
|
||||
"version": "0.1.0",
|
||||
"description": "Emulator and ROM linking plugin for Drop",
|
||||
"type": "module",
|
||||
"main": "dist/src/index.js",
|
||||
"scripts": {
|
||||
"build": "rm -rf dist && tsc",
|
||||
"test": "node --test dist/test/*.js",
|
||||
"sign": "drop-plugin sign ."
|
||||
},
|
||||
"dependencies": {
|
||||
"@droposs/plugin-sdk": "file:../drop-plugin-sdk/packages/plugin-sdk"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@droposs/plugin-cli": "file:../drop-plugin-sdk/packages/plugin-cli",
|
||||
"typescript": "^5.7.0",
|
||||
"@types/node": "^22.0.0"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import type {
|
||||
ClientPlugin,
|
||||
ClientPluginContext,
|
||||
LaunchContext,
|
||||
} from "@droposs/plugin-sdk";
|
||||
|
||||
export interface EmulatorBinding {
|
||||
coreId: string;
|
||||
romPath: string;
|
||||
}
|
||||
|
||||
/** Expands the ROM placeholder in an emulator launch command. */
|
||||
export function expandRomArgs(command: string, binding: EmulatorBinding): string {
|
||||
return command.replaceAll("{rom_path}", binding.romPath).replaceAll("{core}", binding.coreId);
|
||||
}
|
||||
|
||||
export default class EmulationPlugin implements ClientPlugin {
|
||||
metadata = {
|
||||
id: "drop-emulation",
|
||||
name: "Emulation & ROM Linking",
|
||||
version: "0.1.0",
|
||||
};
|
||||
|
||||
async init(ctx: ClientPluginContext): Promise<void> {
|
||||
ctx.registerLaunchHook({
|
||||
stage: "pre-launch:prepare",
|
||||
execute: async (context: LaunchContext) => {
|
||||
const binding = await ctx.storage.get<EmulatorBinding>(`binding:${context.gameId}`);
|
||||
if (!binding) return;
|
||||
ctx.logger.debug(
|
||||
`ROM binding active for ${context.gameTitle}: ${expandRomArgs("{rom_path}", binding)}`,
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
ctx.registerSlot("game-detail:panels", { template: "EmulatorPanel" });
|
||||
ctx.logger.info("Emulation plugin initialized");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { MockClientPluginContext } from "@droposs/plugin-sdk";
|
||||
import Plugin, { expandRomArgs } from "../src/index.js";
|
||||
|
||||
test("drop-emulation registers a launch hook and panel", async () => {
|
||||
const ctx = new MockClientPluginContext("drop-emulation", ["ui:slot", "game:launch-hook", "system:command", "game:fs", "client:storage"]);
|
||||
await new Plugin().init(ctx);
|
||||
assert.equal(ctx.launchHooks.length, 1);
|
||||
});
|
||||
|
||||
test("expandRomArgs substitutes placeholders", () => {
|
||||
const command = "retroarch -L {core} {rom_path}";
|
||||
const expanded = expandRomArgs(command, { coreId: "snes9x", romPath: "/roms/game.sfc" });
|
||||
assert.equal(expanded, "retroarch -L snes9x /roms/game.sfc");
|
||||
});
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"declaration": true,
|
||||
"outDir": "./dist",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"include": [
|
||||
"src/**/*",
|
||||
"test/**/*"
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user