Files
factorio-clusterio/plugins/subspace_storage/index.ts
T
Hornwitser 5dcaca4d0b Migrate to ECMAScript Modules
Migrate the usage of CommonJS specific code and imports to ESM.  Roughly
summarised this:
- Changes all require() calls to import statement or expressions.
- Changes usage of module.exports to export statements.
- Replaces require.resolve with import.meta.resolve.
- Replaces conditional imports with conditional subpath imports.
- Replaces module === require.main with import.meta.main.
- Adds the full filename with extention to all relative imports.
- Changes all usage of __dirname and __filename to their import.meta
  equivalents.
- Sets "type": "module" in package.json files.
- Removes usage of "use strict".
- Adds .ts an an alias of .js for the webpack build.

Due to differences in how require and import resolves files the plugin
entrypoints will have to include the filename and extension after this
migration in order to work.
2026-09-11 22:43:57 +02:00

66 lines
1.8 KiB
TypeScript

import * as lib from "@clusterio/lib";
import * as messages from "./messages.js";
declare module "@clusterio/lib" {
export interface ControllerConfigFields {
"subspace_storage.division_method": "simple" | "dole" | "neural_dole";
"subspace_storage.log_item_transfers": boolean;
}
export interface InstanceConfigFields {
"subspace_storage.log_item_transfers": boolean;
}
}
lib.definePermission({
name: "subspace_storage.storage.view",
title: "View Subspace Storage",
description: "View the items and fluids stored in the shared subspace.",
grantByDefault: true,
});
export const plugin: lib.PluginDeclaration = {
name: "subspace_storage",
title: "Subspace Storage",
description: "Provides shared storage across instances for the Subspace Storage mod",
instanceEntrypoint: "dist/node/instance.js",
instanceConfigFields: {
"subspace_storage.log_item_transfers": {
title: "Log Item Transfers",
description: "Spam host console with item transfers done.",
type: "boolean",
initialValue: false,
},
},
controllerEntrypoint: "dist/node/controller.js",
controllerConfigFields: {
"subspace_storage.division_method": {
title: "Division Method",
description: "Method for dividing resource requests between instances.",
type: "string",
enum: ["simple", "dole", "neural_dole"],
initialValue: "simple",
},
"subspace_storage.log_item_transfers": {
title: "Log Item Transfers",
description: "Spam controller console with item transfers done.",
type: "boolean",
initialValue: false,
},
},
features: [
"ScriptCommands",
],
messages: [
messages.PlaceEvent,
messages.RemoveRequest,
messages.GetStorageRequest,
messages.UpdateStorageEvent,
messages.SetStorageSubscriptionRequest,
],
webEntrypoint: "./web",
routes: ["/storage"],
};