Flatten lib namespace

Move all functions and classes currently available through lib/name and
libName to be under a single flat namespace in lib.  This make
reorganising the lib namespace much simpler as the location of symbols
can move without breaking the consumers of lib.

The multi-entrypoint design was already problematic for the web plugin
system which couldn't effectively use it due to how webpack's shared
module system is awkward to set up with multiple entrypoints per package.
This commit is contained in:
Hornwitser committed 2023-07-28 16:03:29 +02:00
1 parent bb58670597
commit bfe119eaa3
143 files changed
+1798 -1918

No files matched your search

+6 -6
View File
@@ -2,14 +2,14 @@
const assert = require("assert").strict;
const mock = require("../mock");
const libPlugin = require("@clusterio/lib/plugin");
const lib = require("@clusterio/lib");
describe("lib/plugin", function() {
describe("class BaseInstancePlugin", function() {
let instancePlugin;
it("should be constructible", async function() {
instancePlugin = new libPlugin.BaseInstancePlugin({}, new mock.MockInstance(), {});
instancePlugin = new lib.BaseInstancePlugin({}, new mock.MockInstance(), {});
await instancePlugin.init();
});
it("should define defaults for hooks", async function() {
@@ -56,7 +56,7 @@ describe("lib/plugin", function() {
describe("class BaseControllerPlugin", function() {
let controllerPlugin;
it("should be constructible", async function() {
controllerPlugin = new libPlugin.BaseControllerPlugin({}, {}, {}, new mock.MockLogger());
controllerPlugin = new lib.BaseControllerPlugin({}, {}, {}, new mock.MockLogger());
await controllerPlugin.init();
});
it("should define defaults for hooks", async function() {
@@ -87,15 +87,15 @@ describe("lib/plugin", function() {
}],
]);
it("should invoke the hook on the plugin", async function() {
await libPlugin.invokeHook(plugins, "test");
await lib.invokeHook(plugins, "test");
assert(betaTestCalled, "Hook was not called");
});
it("should pass and return args", async function() {
let result = await libPlugin.invokeHook(plugins, "pass", 1234);
let result = await lib.invokeHook(plugins, "pass", 1234);
assert.deepEqual(result, [1234]);
});
it("should ignore errors", async function() {
await libPlugin.invokeHook(plugins, "error");
await lib.invokeHook(plugins, "error");
});
});
});