feat: quick and dirty item use and scripting

This commit is contained in:
cha0s 2024-06-22 07:47:19 -05:00
parent 9e5efdf413
commit 630740e71e
11 changed files with 370 additions and 73 deletions

View File

@ -0,0 +1,3 @@
export default {
health: {type: 'uint32'},
};

View File

@ -0,0 +1,34 @@
import Schema from '@/ecs/schema.js';
export default function(Component) {
return class Inventory extends Component {
instanceFromSchema() {
const Instance = super.instanceFromSchema();
Instance.prototype.item = function (slot) {
const {slots} = this;
for (const {slotIndex, source} of this.slots) {
if (slot === slotIndex) {
return source;
}
}
};
return Instance;
}
static schema = new Schema({
type: 'object',
properties: {
slots: {
type: 'array',
subtype: {
type: 'object',
properties: {
quantity: {type: 'uint16'},
slotIndex: {type: 'uint16'},
source: {type: 'string'},
},
},
},
},
});
}
}

View File

@ -0,0 +1,44 @@
import Schema from '@/ecs/schema.js';
export default function(Component) {
return class Ticking extends Component {
instanceFromSchema() {
const Instance = super.instanceFromSchema();
Instance.prototype.$$finished = [];
Instance.prototype.$$tickingPromises = [];
Instance.prototype.addTickingPromise = function(tickingPromise) {
this.$$tickingPromises.push(tickingPromise);
tickingPromise.then(() => {
this.$$finished.push(tickingPromise);
});
}
Instance.prototype.tick = function(elapsed) {
for (const tickingPromise of this.$$finished) {
this.$$tickingPromises.splice(
this.$$tickingPromises.indexOf(tickingPromise),
1,
);
}
this.$$finished = [];
for (const tickingPromise of this.$$tickingPromises) {
tickingPromise.tick(elapsed);
}
for (const tickingPromise of this.$$finished) {
this.$$tickingPromises.splice(
this.$$tickingPromises.indexOf(tickingPromise),
1,
);
}
this.$$finished = [];
}
return Instance;
}
static schema = new Schema({
type: 'object',
properties: {
isTicking: {defaultValue: 1, type: 'uint8'},
},
});
};
}

View File

@ -0,0 +1,19 @@
import {System} from '@/ecs/index.js';
export default class RunTickingPromises extends System {
static queries() {
return {
default: ['Ticking'],
};
}
tick(elapsed) {
for (const [Ticking] of this.select('default')) {
if (Ticking.isTicking) {
Ticking.tick(elapsed);
}
}
}
}

View File

@ -5,6 +5,7 @@ import Ecs from '@/ecs/ecs.js';
import Components from '@/ecs-components/index.js';
import Systems from '@/ecs-systems/index.js';
import {decode, encode} from '@/packets/index.js';
import Script from '@/util/script.js';
function join(...parts) {
return parts.join('/');
@ -92,6 +93,7 @@ export default class Engine {
'ControlDirection',
'SpriteDirection',
'RunAnimations',
'RunTickingPromises',
];
defaultSystems.forEach((defaultSystem) => {
const System = ecs.system(defaultSystem);
@ -109,6 +111,16 @@ export default class Engine {
Direction: {direction: 2},
Ecs: {path: join('homesteads', `${id}`)},
Momentum: {},
Inventory: {
slots: [
{
qty: 10,
slotIndex: 0,
source: '/assets/potion',
}
]
},
Health: {health: 100},
Position: {x: 368, y: 368},
VisibleAabb: {},
Speed: {speed: 100},
@ -119,6 +131,7 @@ export default class Engine {
source: '/assets/dude.json',
speed: 0.115,
},
Ticking: {},
Wielder: {
activeSlot: 0,
},
@ -203,8 +216,15 @@ export default class Engine {
for (const i in this.ecses) {
this.ecses[i].setClean();
}
for (const [{Controlled, Wielder}, payload] of this.incomingActions) {
for (const [
entity,
payload,
] of this.incomingActions) {
const {Ecs, Controlled, id, Inventory, Position, Ticking, Wielder} = entity;
switch (payload.type) {
case 'changeSlot': {
Wielder.activeSlot = payload.value - 1;
}
case 'moveUp':
case 'moveRight':
case 'moveDown':
@ -212,8 +232,17 @@ export default class Engine {
Controlled[payload.type] = payload.value;
break;
}
case 'changeSlot': {
Wielder.activeSlot = payload.value - 1;
case 'use': {
if (payload.value) {
const item = Inventory.item(Wielder.activeSlot);
this.server.readAsset(item + '/start.js')
.then((response) => response.text())
.then((code) => {
Ticking.addTickingPromise(
Script.tickingPromise(code, {console, wielder: entity}),
);
});
}
}
}
}

View File

@ -13,6 +13,9 @@ class WorkerServer extends Server {
static qualify(path) {
return ['UNIVERSE', path].join('/');
}
async readAsset(path) {
return fetch(path);
}
async readData(path) {
const data = await get(this.constructor.qualify(path));
if ('undefined' !== typeof data) {

148
app/util/script.js Normal file
View File

@ -0,0 +1,148 @@
import Sandbox from '@/swcx/sandbox.js';
import TickingPromise from '@/util/ticking-promise.js';
import {LRUCache} from 'lru-cache';
const Populated = Symbol.for('sandbox.populated');
export const cache = new LRUCache({
max: 128,
});
export default class Script {
static swcInitialized = false;
constructor(sandbox) {
this.sandbox = sandbox;
this.promise = null;
}
get context() {
return this.sandbox.context;
}
static createContext(locals = {}) {
if (locals[Populated]) {
return locals;
}
return {
[Populated]: true,
...locals,
};
}
// async evaluate(callback) {
// this.sandbox.reset();
// let {done, value} = this.sandbox.next();
// if (value instanceof Promise) {
// await value;
// }
// while (!done) {
// ({done, value} = this.sandbox.next());
// if (value instanceof Promise) {
// // eslint-disable-next-line no-await-in-loop
// await value;
// }
// }
// if (value instanceof Promise) {
// value.then(callback);
// }
// else {
// callback(value);
// }
// }
static async fromCode(code, context = {}) {
let ast;
if (cache.has(code)) {
ast = cache.get(code);
}
else {
cache.set(code, ast = await this.parse(code));
}
return new this(
new Sandbox(ast, this.createContext(context)),
);
}
static async parse(code) {
const {default: initSwc, parse} = await import('@swc/wasm-web');
if (!this.swcInitialized) {
await initSwc();
this.swcInitialized = true;
}
return parse(
code,
{
allowReturnOutsideFunction: true,
syntax: 'ecmascript',
},
);
}
reset() {
this.promise = null;
this.sandbox.compile();
}
tick(elapsed, resolve, reject) {
if (this.promise) {
if (this.promise instanceof TickingPromise) {
this.promise.tick(elapsed);
}
return;
}
while (true) {
this.sandbox.context.elapsed = elapsed;
const {done, value} = this.sandbox.step();
if (value) {
const {value: result} = value;
if (result instanceof Promise) {
this.promise = result;
result
.catch(reject)
.then(() => {
if (done) {
resolve();
}
})
.finally(() => {
this.promise = null;
});
break;
}
}
if (done) {
resolve();
break;
}
}
}
tickingPromise() {
return new TickingPromise(
() => {},
(elapsed, resolve, reject) => {
this.tick(elapsed, resolve, reject);
},
);
}
static tickingPromise(code, context = {}) {
let tickingPromise;
return new TickingPromise(
(resolve) => {
this.fromCode(code, context)
.then((script) => {
tickingPromise = script.tickingPromise();
resolve(tickingPromise);
})
},
(elapsed) => {
tickingPromise?.tick?.(elapsed);
},
);
}
};

144
package-lock.json generated
View File

@ -13,11 +13,13 @@
"@remix-run/express": "^2.9.2",
"@remix-run/node": "^2.9.2",
"@remix-run/react": "^2.9.2",
"@swc/core": "^1.6.0",
"@swc/core": "^1.6.5",
"@swc/wasm-web": "^1.6.5",
"compression": "^1.7.4",
"express": "^4.18.2",
"idb-keyval": "^6.2.1",
"isbot": "^4.1.0",
"lru-cache": "^10.2.2",
"morgan": "^1.10.0",
"pixi.js": "^7.4.2",
"react": "^18.2.0",
@ -212,6 +214,15 @@
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-compilation-targets/node_modules/lru-cache": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz",
"integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==",
"dev": true,
"dependencies": {
"yallist": "^3.0.2"
}
},
"node_modules/@babel/helper-compilation-targets/node_modules/semver": {
"version": "6.3.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
@ -4004,9 +4015,9 @@
}
},
"node_modules/@remix-run/dev/node_modules/ws": {
"version": "7.5.9",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz",
"integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==",
"version": "7.5.10",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz",
"integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==",
"dev": true,
"engines": {
"node": ">=8.3.0"
@ -6430,13 +6441,13 @@
}
},
"node_modules/@swc/core": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/@swc/core/-/core-1.6.0.tgz",
"integrity": "sha512-Wynbo79uIVBgmq3TPcTMdtXUkqk69IPSVuzo7/Jl1OhR4msC7cUaoRB1216ZanWttrAZ4/g6u17w9XZG4fzp1A==",
"version": "1.6.5",
"resolved": "https://registry.npmjs.org/@swc/core/-/core-1.6.5.tgz",
"integrity": "sha512-tyVvUK/HDOUUsK6/GmWvnqUtD9oDpPUA4f7f7JCOV8hXxtfjMtAZeBKf93yrB1XZet69TDR7EN0hFC6i4MF0Ig==",
"hasInstallScript": true,
"dependencies": {
"@swc/counter": "^0.1.3",
"@swc/types": "^0.1.8"
"@swc/types": "^0.1.9"
},
"engines": {
"node": ">=10"
@ -6446,16 +6457,16 @@
"url": "https://opencollective.com/swc"
},
"optionalDependencies": {
"@swc/core-darwin-arm64": "1.6.0",
"@swc/core-darwin-x64": "1.6.0",
"@swc/core-linux-arm-gnueabihf": "1.6.0",
"@swc/core-linux-arm64-gnu": "1.6.0",
"@swc/core-linux-arm64-musl": "1.6.0",
"@swc/core-linux-x64-gnu": "1.6.0",
"@swc/core-linux-x64-musl": "1.6.0",
"@swc/core-win32-arm64-msvc": "1.6.0",
"@swc/core-win32-ia32-msvc": "1.6.0",
"@swc/core-win32-x64-msvc": "1.6.0"
"@swc/core-darwin-arm64": "1.6.5",
"@swc/core-darwin-x64": "1.6.5",
"@swc/core-linux-arm-gnueabihf": "1.6.5",
"@swc/core-linux-arm64-gnu": "1.6.5",
"@swc/core-linux-arm64-musl": "1.6.5",
"@swc/core-linux-x64-gnu": "1.6.5",
"@swc/core-linux-x64-musl": "1.6.5",
"@swc/core-win32-arm64-msvc": "1.6.5",
"@swc/core-win32-ia32-msvc": "1.6.5",
"@swc/core-win32-x64-msvc": "1.6.5"
},
"peerDependencies": {
"@swc/helpers": "*"
@ -6467,9 +6478,9 @@
}
},
"node_modules/@swc/core-darwin-arm64": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.6.0.tgz",
"integrity": "sha512-W1Mwk0WRrJ5lAVkYRPxpxOmwu8p9ASXeOmiORhXvE7DYREyI30005xlqSOITU1pfSNKj7G9u3+9DjsOzPPPbBw==",
"version": "1.6.5",
"resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.6.5.tgz",
"integrity": "sha512-RGQhMdni2v1/ANQ/2K+F+QYdzaucekYBewZcX1ogqJ8G5sbPaBdYdDN1qQ4kHLCIkPtGP6qC7c71qPEqL2RidQ==",
"cpu": [
"arm64"
],
@ -6482,9 +6493,9 @@
}
},
"node_modules/@swc/core-darwin-x64": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.6.0.tgz",
"integrity": "sha512-EzxLnpPC1zgLb2Y0iVUG6b+/GUv43k6uJUIs52UzxOnBElYP/WeItI3RJ+LUMFzCpZMk/IxB10wofEoeQ1H/Xg==",
"version": "1.6.5",
"resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.6.5.tgz",
"integrity": "sha512-/pSN0/Jtcbbb9+ovS9rKxR3qertpFAM3OEJr/+Dh/8yy7jK5G5EFPIrfsw/7Q5987ERPIJIH6BspK2CBB2tgcg==",
"cpu": [
"x64"
],
@ -6497,9 +6508,9 @@
}
},
"node_modules/@swc/core-linux-arm-gnueabihf": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.6.0.tgz",
"integrity": "sha512-uP/STDjWZ5N6lc8mxJFsex4NXDaqhfzd8UOrI3LfdV97+4faE4/BC6bVqDNHFFzZi0PHuVBxD6md7IfPjugk6A==",
"version": "1.6.5",
"resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.6.5.tgz",
"integrity": "sha512-B0g/dROCE747RRegs/jPHuKJgwXLracDhnqQa80kFdgWEMjlcb7OMCgs5OX86yJGRS4qcYbiMGD0Pp7Kbqn3yw==",
"cpu": [
"arm"
],
@ -6512,9 +6523,9 @@
}
},
"node_modules/@swc/core-linux-arm64-gnu": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.6.0.tgz",
"integrity": "sha512-UgNz6anowcnYzJtZohzpii31FOgouBHJqluiq+p2geX/agbC+KfOKwVXdljn95+Qc4ygBuw/hjKjgF2msOLeVg==",
"version": "1.6.5",
"resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.6.5.tgz",
"integrity": "sha512-W8meapgXTq8AOtSvDG4yKR8ant2WWD++yOjgzAleB5VAC+oC+aa8YJROGxj8HepurU8kurqzcialwoMeq5SZZQ==",
"cpu": [
"arm64"
],
@ -6527,9 +6538,9 @@
}
},
"node_modules/@swc/core-linux-arm64-musl": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.6.0.tgz",
"integrity": "sha512-xPV6qrnj4nFwXQbIv70C1Kn5z5Th53sirIY76aEonr78qeC6+ywaBZR4uLFNHsljVjyuvVQfTTcl2qraGhu6oQ==",
"version": "1.6.5",
"resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.6.5.tgz",
"integrity": "sha512-jyCKqoX50Fg8rJUQqh4u5PqnE7nqYKXHjVH2WcYr114/MU21zlsI+YL6aOQU1XP8bJQ2gPQ1rnlnGJdEHiKS/w==",
"cpu": [
"arm64"
],
@ -6542,9 +6553,9 @@
}
},
"node_modules/@swc/core-linux-x64-gnu": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.6.0.tgz",
"integrity": "sha512-xTeWn4OT5uQ+DxT2cy94ngK8tF1U/5fMC49/V6FhCS2Wh+Xa/O+OWcOyKvYtk3b0eGYS4iNIRKgzog7fLSFtvQ==",
"version": "1.6.5",
"resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.6.5.tgz",
"integrity": "sha512-G6HmUn/RRIlXC0YYFfBz2qh6OZkHS/KUPkhoG4X9ADcgWXXjOFh6JrefwsYj8VBAJEnr5iewzjNfj+nztwHaeA==",
"cpu": [
"x64"
],
@ -6557,9 +6568,9 @@
}
},
"node_modules/@swc/core-linux-x64-musl": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.6.0.tgz",
"integrity": "sha512-3P01mYD5XbyaVLT0MGZmZE+ZdgmGSvuvIhSejRDBlEXqkFnH79nWds+KsE+91hzVU8XsgzX57Yzv4eO5dlIuPw==",
"version": "1.6.5",
"resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.6.5.tgz",
"integrity": "sha512-AQpBjBnelQDSbeTJA50AXdS6+CP66LsXIMNTwhPSgUfE7Bx1ggZV11Fsi4Q5SGcs6a8Qw1cuYKN57ZfZC5QOuA==",
"cpu": [
"x64"
],
@ -6572,9 +6583,9 @@
}
},
"node_modules/@swc/core-win32-arm64-msvc": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.6.0.tgz",
"integrity": "sha512-xFuook1efU0ctzMAEeol4eI7J6+k/c/pMJpp/NP/4JJDnhlHwAi2iyiZcID8YZS+ePHgXMLndGdIMHVv/wIPkQ==",
"version": "1.6.5",
"resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.6.5.tgz",
"integrity": "sha512-MZTWM8kUwS30pVrtbzSGEXtek46aXNb/mT9D6rsS7NvOuv2w+qZhjR1rzf4LNbbn5f8VnR4Nac1WIOYZmfC5ng==",
"cpu": [
"arm64"
],
@ -6587,9 +6598,9 @@
}
},
"node_modules/@swc/core-win32-ia32-msvc": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.6.0.tgz",
"integrity": "sha512-VCJa5vTywxzASqvf9OEUM5SZBcNrWbuIkSGM5T9guuBzyrh/tSqVHjzOWL9qpP69uPVj5G/I5bJObLiUKErhvQ==",
"version": "1.6.5",
"resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.6.5.tgz",
"integrity": "sha512-WZdu4gISAr3yOm1fVwKhhk6+MrP7kVX0KMP7+ZQFTN5zXQEiDSDunEJKVgjMVj3vlR+6mnAqa/L0V9Qa8+zKlQ==",
"cpu": [
"ia32"
],
@ -6602,9 +6613,9 @@
}
},
"node_modules/@swc/core-win32-x64-msvc": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.6.0.tgz",
"integrity": "sha512-L7i8WBSIJTQiMONJGHnznDydZmlJIqHjZ3VhBHeTTms8cEAuwkAVgzPwgr5cD9GhmcwdeBI9iYdOuKr1pUx19Q==",
"version": "1.6.5",
"resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.6.5.tgz",
"integrity": "sha512-ezXgucnMTzlFIxQZw7ls/5r2hseFaRoDL04cuXUOs97E8r+nJSmFsRQm/ygH5jBeXNo59nyZCalrjJAjwfgACA==",
"cpu": [
"x64"
],
@ -6622,13 +6633,18 @@
"integrity": "sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ=="
},
"node_modules/@swc/types": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/@swc/types/-/types-0.1.8.tgz",
"integrity": "sha512-RNFA3+7OJFNYY78x0FYwi1Ow+iF1eF5WvmfY1nXPOEH4R2p/D4Cr1vzje7dNAI2aLFqpv8Wyz4oKSWqIZArpQA==",
"version": "0.1.9",
"resolved": "https://registry.npmjs.org/@swc/types/-/types-0.1.9.tgz",
"integrity": "sha512-qKnCno++jzcJ4lM4NTfYifm1EFSCeIfKiAHAfkENZAV5Kl9PjJIyd2yeeVv6c/2CckuLyv2NmRC5pv6pm2WQBg==",
"dependencies": {
"@swc/counter": "^0.1.3"
}
},
"node_modules/@swc/wasm-web": {
"version": "1.6.5",
"resolved": "https://registry.npmjs.org/@swc/wasm-web/-/wasm-web-1.6.5.tgz",
"integrity": "sha512-gKNNR8m0mzeFjcGCmCTxUHsjkV/kwHhRHYxwqI117bhauctt/PCq9BqG/L/1ZlhDO0VRGyZfab64jXGUh70AVQ=="
},
"node_modules/@testing-library/dom": {
"version": "9.3.4",
"resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-9.3.4.tgz",
@ -12674,12 +12690,11 @@
}
},
"node_modules/lru-cache": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz",
"integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==",
"dev": true,
"dependencies": {
"yallist": "^3.0.2"
"version": "10.2.2",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.2.2.tgz",
"integrity": "sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ==",
"engines": {
"node": "14 || >=16.14"
}
},
"node_modules/lz-string": {
@ -14714,15 +14729,6 @@
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/path-scurry/node_modules/lru-cache": {
"version": "10.2.2",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.2.2.tgz",
"integrity": "sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ==",
"dev": true,
"engines": {
"node": "14 || >=16.14"
}
},
"node_modules/path-to-regexp": {
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
@ -19243,9 +19249,9 @@
}
},
"node_modules/ws": {
"version": "8.17.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.17.0.tgz",
"integrity": "sha512-uJq6108EgZMAl20KagGkzCKfMEjxmKvZHG7Tlq0Z6nOky7YF7aq4mOx6xK8TJ/i1LeK4Qus7INktacctDgY8Ow==",
"version": "8.17.1",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz",
"integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==",
"engines": {
"node": ">=10.0.0"
},

View File

@ -20,11 +20,13 @@
"@remix-run/express": "^2.9.2",
"@remix-run/node": "^2.9.2",
"@remix-run/react": "^2.9.2",
"@swc/core": "^1.6.0",
"@swc/core": "^1.6.5",
"@swc/wasm-web": "^1.6.5",
"compression": "^1.7.4",
"express": "^4.18.2",
"idb-keyval": "^6.2.1",
"isbot": "^4.1.0",
"lru-cache": "^10.2.2",
"morgan": "^1.10.0",
"pixi.js": "^7.4.2",
"react": "^18.2.0",

View File

@ -0,0 +1,3 @@
wielder.Health.health += 10
wielder.Inventory.slots[0].qty -= 1
console.log('hi', wielder.Health.health, wielder.Inventory.slots[0]);

View File

@ -56,6 +56,12 @@ app.use(compression());
// http://expressjs.com/en/advanced/best-practice-security.html#at-a-minimum-disable-x-powered-by-header
app.disable('x-powered-by');
// wasm
app.use(
'/node_modules/.vite/deps/wasm-web_bg.wasm',
express.static('node_modules/@swc/wasm-web/wasm-web_bg.wasm', { maxAge: '1h' })
);
// handle asset requests
if (viteDevServer) {
app.use(viteDevServer.middlewares);