Files
factorio-scenario-ExpCluster/exp_roles/index.ts
bbassieandClaude Fable 5.1 7fd66c6ac7 Migrate to ES modules
Clusterio #984 converted its packages to ESM, so a CommonJS plugin can
no longer import @clusterio/lib and plugin entrypoints must name the
full file. Every package gets "type": "module", entrypoints and relative
imports carry the .js extension, and the webpack configs become .cjs as
webpack-cli loads them with require. tsconfig.node.json moves from
node16 to nodenext to match clusterio, which needs it for the JSON
import attributes in its sources.

The tap tests and the shared test helpers use import and
import.meta.dirname. The test scripts pass --type-strip-only so tap
leaves lib's .ts subpath imports to Node's own type stripping, as its
TypeScript loader compiled them without a default export. The lua
runner resolves fengari from the test file it is given, since a bare
import from the shared test directory does not reach the plugin's
devDependencies.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-12 01:10:02 +01:00

54 lines
1.4 KiB
TypeScript

import * as lib from "@clusterio/lib";
import * as messages from "./messages.js";
export * from "./messages.js";
export type { ControllerPlugin } from "./controller.js";
declare module "@clusterio/lib" {
export interface InstanceConfigFields {
"exp_roles.sync_mode": "disabled" | "enabled" | "bidirectional";
}
}
// The in game properties of a role are part of the role, so they are covered by
// the core role permissions rather than permissions of their own. Assignments
// are only ever sent between the controller and an instance, so they need none.
export const plugin: lib.PluginDeclaration = {
name: "exp_roles",
title: "ExpGaming - Roles",
description: "Clusterio plugin providing syncing of in game roles",
features: [
"SavePatching",
"ScriptCommands",
],
messages: [
messages.RoleUpdatedEvent,
messages.AssignmentUpdatedEvent,
messages.RoleListRequest,
messages.RoleMetaUpdateRequest,
messages.AssignmentListRequest,
messages.AssignmentUpdateRequest,
],
instanceEntrypoint: "./dist/node/instance.js",
instanceConfigFields: {
"exp_roles.sync_mode": {
description: "Synchronize in game roles with the controller",
type: "string",
enum: ["disabled", "enabled", "bidirectional"],
initialValue: "bidirectional",
},
},
controllerEntrypoint: "./dist/node/controller.js",
controllerConfigFields: {
},
webEntrypoint: "./web",
};