1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-12-13 18:21:51 +00:00

Improve mod developing so mods are directly ready to be deployed, load mods from local file server

This commit is contained in:
tobspr 2022-01-14 11:08:16 +01:00
parent f3b8d329fc
commit 6fa2515d85
6 changed files with 19 additions and 4 deletions

View File

@ -146,7 +146,7 @@ gulp.task("main.webserver", () => {
*/
function serve({ version = "web" }) {
browserSync.init({
server: buildFolder,
server: [buildFolder, path.join(baseDir, "src", "js")],
port: 3005,
ghostMode: {
clicks: false,

View File

@ -71,6 +71,7 @@ module.exports = ({ watch = false, standalone = false, chineseVersion = false, w
type: "javascript/auto",
},
{ test: /\.(png|jpe?g|svg)$/, loader: "ignore-loader" },
{ test: /\.nobuild/, loader: "ignore-loader" },
{
test: /\.md$/,
use: [

View File

@ -177,6 +177,7 @@ module.exports = ({
type: "javascript/auto",
},
{ test: /\.(png|jpe?g|svg)$/, loader: "ignore-loader" },
{ test: /\.nobuild/, loader: "ignore-loader" },
{
test: /\.js$/,
enforce: "pre",

View File

@ -1,5 +1,6 @@
/* typehints:start */
import { ModLoader } from "./modloader";
import { Component } from "../game/component";
import { MetaBuilding } from "../game/meta_building";
/* typehints:end */
@ -16,7 +17,7 @@ import { Loader } from "../core/loader";
import { LANGUAGES } from "../languages";
import { matchDataRecursive, T } from "../translations";
import { gBuildingVariants, registerBuildingVariant } from "../game/building_codes";
import { gMetaBuildingRegistry } from "../core/global_registries";
import { gComponentRegistry, gMetaBuildingRegistry } from "../core/global_registries";
import { MODS_ADDITIONAL_SHAPE_MAP_WEIGHTS } from "../game/map_chunk";
const LOG = createLogger("mod-interface");
@ -106,6 +107,14 @@ export class ModInterface {
}
}
/**
*
* @param {typeof Component} component
*/
registerComponent(component) {
gComponentRegistry.register(component);
}
/**
*
* @param {object} param0

View File

@ -41,8 +41,12 @@ export class ModLoader {
if (G_IS_STANDALONE) {
mods = await getIPCRenderer().invoke("get-mods");
} else if (G_IS_DEV && globalConfig.debug.loadDevMod) {
// @ts-expect-error
mods = [require("!!raw-loader!./dev_mod")];
const mod = await (
await fetch("http://localhost:3005/mods/demo_mod.nobuild/index.js", {
method: "GET",
})
).text();
mods.push(mod);
}
mods.forEach(modCode => {