Coder Social home page Coder Social logo

hathora / builder Goto Github PK

View Code? Open in Web Editor NEW
547.0 547.0 35.0 4.84 MB

Multiplayer game framework

Home Page: https://docs.hathora.dev/#/builder/

License: MIT License

Handlebars 84.68% JavaScript 2.11% TypeScript 12.36% Shell 0.42% CSS 0.32% HTML 0.12%
framework game gamedev multiplayer networking realtime websocket

builder's Introduction

hathora logo

npm version node compatibility build status discord chat


Hathora Builder - multiplayer game framework

Overview

The Hathora Builder is a framework for building multiplayer games and other realtime applications.

Documentation

Visit https://docs.hathora.dev/#/builder/

Quick start

First, make sure you have node v16.12.0+ installed.

Then install the hathora cli from the npm registry:

npm install -g hathora

Clone an example hathora game:

git clone https://github.com/hathora/ship-battle.git

Inside the ship-battle directory, start the Hathora dev server:

hathora dev

Finally, visit http://localhost:3001 to see the game in action (add multiple users by opening the same url in different tabs):

Instructions: Arrow keys to move, space bar to fire.

image

For a deeper introduction, take a look at the tutorial.

Examples

Here are some other example apps built with hathora:

Community

Discord: https://discord.com/invite/hathora

Contributing

To contribute to Hathora, first clone the repo:

https://github.com/hathora/hathora

Make sure you have ts-node installed globally:

npm install -g ts-node

You can now invoke your local hathora cli as follows:

ts-node /path/to/hathora/cli.ts dev

builder's People

Contributors

arranf avatar dependabot[bot] avatar dieseldeesh avatar dsiddharth avatar francislavoie avatar greenheart avatar gwprice115 avatar hpx7 avatar ianssenne avatar jchu231 avatar joeynenni avatar kasbah avatar knigam avatar lint-action avatar mihirpandya avatar penguisnt avatar philihp avatar saricden avatar shooksie avatar tarunipaleru avatar udgeetham avatar varunm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

builder's Issues

deprecation of npm i global

npm WARN config global --global, --local are deprecated. Use --location=global instead.

might want to adjust it at some time...

Consider exposing subscriptions

Hathora knows which userIds are subscribed to a given stateId. We should explore if and how the client/server should have access to this information

Creating the 200.html for surge.sh deploy

Since you have docs on how to deploy to surge.sh you should probably mention creating the 200.html, or create it automatically somehow. It's something I stumbled on and would have had no idea what's happening had I not been talking to you @hpx7.

Need to specify a minimum node version

My global node version was 14.15.0, running hathora dev crashed with this error:

up to date in 0.109s
(node:15544) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
TypeError [ERR_INVALID_RETURN_PROPERTY_VALUE]: Expected string to be returned for the "format" from the "loader getFormat" function but got type object.
    at Loader.getFormat (internal/modules/esm/loader.js:110:13)
    at async Loader.getModuleJob (internal/modules/esm/loader.js:230:20)
    at async Loader.import (internal/modules/esm/loader.js:164:17)
    at async Object.loadESM (internal/process/esm_loader.js:68:5) {
  code: 'ERR_INVALID_RETURN_PROPERTY_VALUE'
}

After some googling, I came across a stack overflow that talked about upgrading node version.

So when I switched to node 16.13.0, it worked just fine.

Specifying a .nodenv and .nvmrc file in the tutorial repos would fix the short-term issue. (You can symlink one to the other to keep them in sync)

I didn't dig in to what feature is necessary for the build to pass, to track down the minimum node version, but just documenting it as an issue here.

Introduce scenarios

For the debug app, it would be nice to be able to be able to define scenarios and have certain actions executed step by step. For example, there could be a scenario to login (creates a user). Then another scenario to join a game. These scenarios can be chained to bootstrap the debug app with many users in a game with certain configurations. This could also be useful for writing tests.

Typescript errors in api/base.ts and .hathora/patch.ts

I've been working on a simple game and when I import HathoraClient from .hathora/client (as is done in the ship example) the web client compilation errors with typescript errors coming from api/base.ts and .hathora/patch.ts.

If required I can share more of my code, but since this errors in the automatically generated api code I'm unsure if that's needed.

Extra info:

$ hathora --version
0.9.12
$ node -v
v16.12.0

image

Make Impl methods `async`?

Would be nice if all the methods were declared as async / returning Promise<> so I can await in them if needed. As far as I can see they are currently called in async functions in wrapper.ts.hbs

What do you think? It will be a breaking change but fairly straight-forward to do.

`hathora build` fails with import errors

Steps to reproduce:

npm install --global [email protected]
git clone https://github.com/hathora/among-us-tutorial
cd among-us-tutorial
hathora dev
# Ctrl-C
hathora build
Error: Build failed with 5 errors:
server/.hathora/protocol.ts:2:31: ERROR: Could not resolve "bin-serde"
server/.hathora/store.ts:3:23: ERROR: Could not resolve "chance"
server/.hathora/store.ts:4:31: ERROR: Could not resolve "bin-serde"
server/.hathora/store.ts:5:7: ERROR: Could not resolve "dotenv/config"
server/.hathora/wrapper.ts:1:21: ERROR: Could not resolve "on-change"
Project root: /tmp/among-us-tutorial
✘ [ERROR] Could not resolve "chance"

    server/.hathora/store.ts:3:23:
      3 │ import { Chance } from "chance";
        ╵                        ~~~~~~~~

  You can mark the path "chance" as external to exclude it from the bundle, which will remove this
  error.

✘ [ERROR] Could not resolve "bin-serde"

    server/.hathora/store.ts:4:31:
      4 │ import { Writer, Reader } from "bin-serde";
        ╵                                ~~~~~~~~~~~

  You can mark the path "bin-serde" as external to exclude it from the bundle, which will remove
  this error.

✘ [ERROR] Could not resolve "dotenv/config"

    server/.hathora/store.ts:5:7:
      5 │ import "dotenv/config";
        ╵        ~~~~~~~~~~~~~~~

  You can mark the path "dotenv/config" as external to exclude it from the bundle, which will remove
  this error.

✘ [ERROR] Could not resolve "bin-serde"

    server/.hathora/protocol.ts:2:31:
      2 │ import { Reader, Writer } from "bin-serde";
        ╵                                ~~~~~~~~~~~

  You can mark the path "bin-serde" as external to exclude it from the bundle, which will remove
  this error.

✘ [ERROR] Could not resolve "on-change"

    server/.hathora/wrapper.ts:1:21:
      1 │ import onChange from "on-change";
        ╵                      ~~~~~~~~~~~

  You can mark the path "on-change" as external to exclude it from the bundle, which will remove
  this error.

vite v2.8.4 building for production...
vite v2.8.4 building for production...
[!] Error: unfinished hook action(s) on exit:
(vite:load-fallback) load "/tmp/among-us-tutorial/client/prototype-ui/index.html"
(vite:load-fallback) load "/tmp/among-us-tutorial/client/web/index.html"

/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/esbuild/lib/main.js:1602
  let error = new Error(`${text}${summary}`);
              ^

Error: Build failed with 5 errors:
server/.hathora/protocol.ts:2:31: ERROR: Could not resolve "bin-serde"
server/.hathora/store.ts:3:23: ERROR: Could not resolve "chance"
server/.hathora/store.ts:4:31: ERROR: Could not resolve "bin-serde"
server/.hathora/store.ts:5:7: ERROR: Could not resolve "dotenv/config"
server/.hathora/wrapper.ts:1:21: ERROR: Could not resolve "on-change"
    at failureErrorWithLog (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/esbuild/lib/main.js:1602:15)
    at /home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/esbuild/lib/main.js:1248:28
    at runOnEndCallbacks (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/esbuild/lib/main.js:1161:65)
    at buildResponseToResult (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/esbuild/lib/main.js:1246:7)
    at /home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/esbuild/lib/main.js:1355:14
    at /home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/esbuild/lib/main.js:665:9
    at handleIncomingPacket (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/esbuild/lib/main.js:762:9)
    at Socket.readFromStdout (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/esbuild/lib/main.js:632:7)
    at Socket.emit (node:events:390:28)
    at addChunk (node:internal/streams/readable:315:12) {
  errors: [
    {
      detail: undefined,
      location: {
        column: 31,
        file: 'server/.hathora/protocol.ts',
        length: 11,
        line: 2,
        lineText: 'import { Reader, Writer } from "bin-serde";',
        namespace: '',
        suggestion: ''
      },
      notes: [
        {
          location: null,
          text: 'You can mark the path "bin-serde" as external to exclude it from the bundle, which will remove this error.'
        }
      ],
      pluginName: '',
      text: 'Could not resolve "bin-serde"'
    },
    {
      detail: undefined,
      location: {
        column: 23,
        file: 'server/.hathora/store.ts',
        length: 8,
        line: 3,
        lineText: 'import { Chance } from "chance";',
        namespace: '',
        suggestion: ''
      },
      notes: [
        {
          location: null,
          text: 'You can mark the path "chance" as external to exclude it from the bundle, which will remove this error.'
        }
      ],
      pluginName: '',
      text: 'Could not resolve "chance"'
    },
    {
      detail: undefined,
      location: {
        column: 31,
        file: 'server/.hathora/store.ts',
        length: 11,
        line: 4,
        lineText: 'import { Writer, Reader } from "bin-serde";',
        namespace: '',
        suggestion: ''
      },
      notes: [
        {
          location: null,
          text: 'You can mark the path "bin-serde" as external to exclude it from the bundle, which will remove this error.'
        }
      ],
      pluginName: '',
      text: 'Could not resolve "bin-serde"'
    },
    {
      detail: undefined,
      location: {
        column: 7,
        file: 'server/.hathora/store.ts',
        length: 15,
        line: 5,
        lineText: 'import "dotenv/config";',
        namespace: '',
        suggestion: ''
      },
      notes: [
        {
          location: null,
          text: 'You can mark the path "dotenv/config" as external to exclude it from the bundle, which will remove this error.'
        }
      ],
      pluginName: '',
      text: 'Could not resolve "dotenv/config"'
    },
    {
      detail: undefined,
      location: {
        column: 21,
        file: 'server/.hathora/wrapper.ts',
        length: 11,
        line: 1,
        lineText: 'import onChange from "on-change";',
        namespace: '',
        suggestion: ''
      },
      notes: [
        {
          location: null,
          text: 'You can mark the path "on-change" as external to exclude it from the bundle, which will remove this error.'
        }
      ],
      pluginName: '',
      text: 'Could not resolve "on-change"'
    }
  ],
  warnings: []
}

Lobby service

1 aspect is to have rooms be public or private
and.... if public
can we get a method to list of all public rooms ?

How do you safely change the HathoraConfig types?

I'm new to the hathora project and didn't see any documentation talking about the upgrade process for your HathoraConfig types. Did I miss it?

I'm wondering about questions like:

  • What if my client is running an older version of the types than the server I'm connecting to?
  • What if I deploy a new server, it breaks, and I need to roll it back but some clients already have downloaded the new version of the types?
  • How do I make sure that the clients and the servers are able to talk to each other?

The coordinator process described in the architecture docs indicates that clients should be able to seamlessly transition between backends.

  • How do we make sure that all of the backends are running the same version of the software?
  • What if a client gets migrated from a backend from one version to a backend of a different version?

There's a similar issue with the transaction log of all method calls being used for persistence.

  • What if the types of method calls changes?
  • How do I make sure that all of my old message calls can be read and handled by the new version of my software?

type generation goes into infinite loop with recursive types

  UserState:
    prevState: UserState?

hathora generate doesn't like this

± hathora g
Generate error: RangeError: Maximum call stack size exceeded
    at /Users/philihp/.nodenv/versions/16.19.1/lib/node_modules/hathora/lib/generate.js:36:37
    at Array.every (<anonymous>)
    at getArgsInfo (/Users/philihp/.nodenv/versions/16.19.1/lib/node_modules/hathora/lib/generate.js:36:18)
    at getArgsInfo (/Users/philihp/.nodenv/versions/16.19.1/lib/node_modules/hathora/lib/generate.js:77:30)
    at /Users/philihp/.nodenv/versions/16.19.1/lib/node_modules/hathora/lib/generate.js:56:116
    at Array.map (<anonymous>)
    at getArgsInfo (/Users/philihp/.nodenv/versions/16.19.1/lib/node_modules/hathora/lib/generate.js:56:65)
    at getArgsInfo (/Users/philihp/.nodenv/versions/16.19.1/lib/node_modules/hathora/lib/generate.js:77:30)
    at getArgsInfo (/Users/philihp/.nodenv/versions/16.19.1/lib/node_modules/hathora/lib/generate.js:73:24)
    at /Users/philihp/.nodenv/versions/16.19.1/lib/node_modules/hathora/lib/generate.js:56:116

RFC: Merge hathora.yml and server/impl.ts

From a private email:

The current hathora.yml DSL is more geared towards the client rather than the server. It defines the data types that the client consumes and the server produces. It also defines the rpc methods.

There are some advantages of having the DSL be decoupled from the server implementation. The first is that you can model your internal server data however you want. This lets you do things like use libraries for the internal state (see chess for example), which is something that would be harder to do if you had to define the internal state in a DSL. The other advantage is privacy — see uno or poker for example where the server knows about everyone’s hands and the deck, but the client only knows about their hand.

I wanted to provide a proof-of-concept for a pure-typescript DSL that allows you to implement all of the features required of hathora.yml: usable for code generation, allows clients to be agnostic about the implementation details of the server (e.g. closed source server), usable with libraries (because it's TypeScript), privacy (via the getUserState function).

My proof-of-concept lives in this gist. I implemented the Rock-Paper-Scissors example to demonstrate. The net result is that I output a JSON blob that matches the loaded HathoraConfig, and there's also a method which returns a compatible Impl class. Some notes points about the proof of concept:

  • We leverage Zod to provide introspectable types. We don't actually validate any objects, although the option is available.
  • Due to the structure of declaring methods next to the Zod schema for their arguments, we can actually infer the types of all method arguments (don't have to type them).
  • Line counts are almost identical if you don't count import lines. If you do, then the proposal is shorter by that amount.
  • The proposal requires use of Zod schemas, which increases the learning curve for those who don't already know it. On the other hand, it does not require YML, which has its own set of pitfalls. Considering that the proposal provides IDE autocompletion for Zod schemas and for the Engine methods, I suspect this nets out as a win.

Would there be interest in adopting something like this as the preferred way of specifying the client interface in Hathora?

Coordinator source code not available?

Per the architecture, any application using Hathora is connected to a Hathora-hosted coordinator at coordinator.hathora.dev, which terminates SSL and performs several other vital parts of the system operation. Is the source code for coordinators available? Can it be self-hosted?

Generated onTick method does not compile by default

When using tick: true, the generated onTick method gives the following errors when compiling:

.rtag/store.ts(72,70): error TS2554: Expected 2 arguments, but got 3.
.rtag/store.ts(73,20): error TS2339: Property 'type' does not exist on
type 'void'.
.rtag/store.ts(170,44): error TS2554: Expected 2 arguments, but got 3.

Example rtag.yml

types:
  PlayerInfo:
    name: string
    score: number
methods:
  createGame:
  joinGame:
  answerQuestion:
    answer: string
auth:
  anonymous:
    separator: "-"
tick: true

userState: PlayerInfo
initialize: createGame
error: string
❯ rtag
Project root: /Users/anuj.patel/Code/rtag/quaestio
❯ rtag install
Project root: /Users/anuj.patel/Code/rtag/quaestio
Installing dependencies in /Users/anuj.patel/Code/rtag/quaestio/client

added 1 package, and audited 2 packages in 955ms

found 0 vulnerabilities
Installing dependencies in /Users/anuj.patel/Code/rtag/quaestio/client/
.rtag

added 14 packages, and audited 15 packages in 2s

1 package is looking for funding
  run `npm fund` for details

1 moderate severity vulnerability

To address all issues, run:
  npm audit fix --force

Run `npm audit` for details.
Installing dependencies in /Users/anuj.patel/Code/rtag/quaestio/server

added 10 packages, and audited 11 packages in 1s

found 0 vulnerabilities
Installing dependencies in /Users/anuj.patel/Code/rtag/quaestio/server/
.rtag
npm WARN deprecated [email protected]: "Please update to latest v2.3 or v2
.2"

added 207 packages, and audited 208 packages in 8s

11 packages are looking for funding
  run `npm fund` for details

1 moderate severity vulnerability

To address all issues, run:
  npm audit fix --force

Run `npm audit` for details.
Time: 0h:00m:15s
❯ rtag start
Project root: /Users/anuj.patel/Code/rtag/quaestio
(node:57097) ExperimentalWarning: --experimental-loader is an experimen
tal feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)

/Users/anuj.patel/Code/rtag/quaestio/server/node_modules/ts-node/src/in
dex.ts:513
    return new TSError(diagnosticText, diagnosticCodes)
           ^
TSError: ⨯ Unable to compile TypeScript:
.rtag/store.ts(72,70): error TS2554: Expected 2 arguments, but got 3.
.rtag/store.ts(73,20): error TS2339: Property 'type' does not exist on
type 'void'.
.rtag/store.ts(170,44): error TS2554: Expected 2 arguments, but got 3.

    at createTSError (/Users/anuj.patel/Code/rtag/quaestio/server/node_
modules/ts-node/src/index.ts:513:12)
    at reportTSError (/Users/anuj.patel/Code/rtag/quaestio/server/node_
modules/ts-node/src/index.ts:517:19)
    at getOutput (/Users/anuj.patel/Code/rtag/quaestio/server/node_modu
les/ts-node/src/index.ts:752:36)
    at Object.compile (/Users/anuj.patel/Code/rtag/quaestio/server/node
_modules/ts-node/src/index.ts:968:32)
    at /Users/anuj.patel/Code/rtag/quaestio/server/node_modules/ts-node
/src/esm.ts:99:38
    at Generator.next (<anonymous>)
    at /Users/anuj.patel/Code/rtag/quaestio/server/node_modules/ts-node
/dist/esm.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/anuj.patel/Code/rtag/quaestio/server/node_modu
les/ts-node/dist/esm.js:4:12)
    at transformSource (/Users/anuj.patel/Code/rtag/quaestio/server/nod
e_modules/ts-node/dist/esm.js:72:16)

[Documentation] Type Properties Cannot Start With a Number

If you have a type (as shown below) which has a property that begins with a numeric character (as a string or not!) encode and encodeDiff fail because they attempt to use dot notation obj.1 rather than square bracket notation obj['1'] for property access.

MyType:
 '1': string 

Check if player is still online

Hi, how shall I check if player is still online? Should I use onTick method to send heartbeat signal (for example with ctx.broadcastEvent) and wait for response and store it?
Thanks in advance :>

`hathora build` does not generate `dist` folder in custom react client

According to the build documentation hathora build should create a dist folder in all client subdirectories, but in my project with a custom react client it does not.

hathora build output:

hathora build
Installing dependencies in /Users/martijnwelker/web/wizard/api

up to date, audited 7 packages in 456ms

1 package is looking for funding
  run `npm fund` for details

found 0 vulnerabilities

Installing dependencies in /Users/martijnwelker/web/wizard/client/.DS_Store
npm or yarn not found.
Installing dependencies in /Users/martijnwelker/web/wizard/client/.hathora

up to date, audited 27 packages in 545ms

1 package is looking for funding
  run `npm fund` for details

found 0 vulnerabilities

Installing dependencies in /Users/martijnwelker/web/wizard/client/prototype-ui

up to date, audited 131 packages in 536ms

22 packages are looking for funding
  run `npm fund` for details

1 moderate severity vulnerability

To address all issues, run:
  npm audit fix --force

Run `npm audit` for details.

Installing dependencies in /Users/martijnwelker/web/wizard/client/web
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: [email protected]
npm WARN Found: [email protected]
npm WARN node_modules/react
npm WARN   react@"^18.2.0" from the root project
npm WARN   4 more (@testing-library/react, react-dom, react-router, react-router-dom)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer react@"^0.14.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" from [email protected]
npm WARN node_modules/react-router/node_modules/mini-create-react-context
npm WARN   mini-create-react-context@"^0.4.0" from [email protected]
npm WARN   node_modules/react-router
npm WARN
npm WARN Conflicting peer dependency: [email protected]
npm WARN node_modules/react
npm WARN   peer react@"^0.14.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" from [email protected]
npm WARN   node_modules/react-router/node_modules/mini-create-react-context
npm WARN     mini-create-react-context@"^0.4.0" from [email protected]
npm WARN     node_modules/react-router

up to date, audited 1440 packages in 1s

205 packages are looking for funding
  run `npm fund` for details

5 high severity vulnerabilities

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.

Installing dependencies in /Users/martijnwelker/web/wizard/server

up to date, audited 2 packages in 1s

found 0 vulnerabilities

Installing dependencies in /Users/martijnwelker/web/wizard/server/.hathora

up to date, audited 14 packages in 456ms

1 package is looking for funding
  run `npm fund` for details

found 0 vulnerabilities


> build
> vite build

vite v2.9.9 building for production...
✓ 697 modules transformed.
dist/index.html                  6.48 KiB
dist/assets/index.97f32ad3.css   30.53 KiB / gzip: 6.42 KiB
dist/assets/index.39cabb85.js    293.49 KiB / gzip: 86.09 KiB

I've attempted to manually run npm run build in client/web/ but that errors with:

$ npm run build --verbose
npm verb cli /Users/martijnwelker/.nvm/versions/node/v16.16.0/bin/node /Users/martijnwelker/.nvm/versions/node/v16.16.0/bin/npm
npm info using [email protected]
npm info using [email protected]
npm timing npm:load:whichnode Completed in 1ms
npm timing config:load:defaults Completed in 0ms
npm timing config:load:file:/Users/martijnwelker/.nvm/versions/node/v16.16.0/lib/node_modules/npm/npmrc Completed in 1ms
npm timing config:load:builtin Completed in 1ms
npm timing config:load:cli Completed in 1ms
npm timing config:load:env Completed in 0ms
npm timing config:load:file:/Users/martijnwelker/web/wizard/client/web/.npmrc Completed in 0ms
npm timing config:load:project Completed in 4ms
npm timing config:load:file:/Users/martijnwelker/.npmrc Completed in 1ms
npm timing config:load:user Completed in 1ms
npm timing config:load:file:/Users/martijnwelker/.nvm/versions/node/v16.16.0/etc/npmrc Completed in 0ms
npm timing config:load:global Completed in 0ms
npm timing config:load:validate Completed in 0ms
npm timing config:load:credentials Completed in 0ms
npm timing config:load:setEnvs Completed in 1ms
npm timing config:load Completed in 8ms
npm timing npm:load:configload Completed in 8ms
npm timing npm:load:mkdirpcache Completed in 0ms
npm timing npm:load:mkdirplogs Completed in 0ms
npm verb title npm run build
npm verb argv "run" "build" "--loglevel" "verbose"
npm timing npm:load:setTitle Completed in 6ms
npm timing config:load:flatten Completed in 1ms
npm timing npm:load:display Completed in 3ms
npm verb logfile logs-max:10 dir:/Users/martijnwelker/.npm/_logs
npm verb logfile /Users/martijnwelker/.npm/_logs/2022-09-01T13_07_44_327Z-debug-0.log
npm timing npm:load:logFile Completed in 2ms
npm timing npm:load:timers Completed in 0ms
npm timing npm:load:configScope Completed in 0ms
npm timing npm:load Completed in 20ms

> [email protected] build
> node scripts/build.js

Creating an optimized production build...Completed in 20ms
Failed to compile.⠂) ⠴ : timing npm:load Completed in 20ms

Attempted import error: 'Writer' is not exported from 'bin-serde' (imported as '_Writer').


npm timing command:run Completed in 4792ms
npm verb exit 1
npm timing npm Completed in 4815ms
npm verb code 1

which comes from

import { Writer as _Writer, Reader as _Reader } from "bin-serde";

Extra info:

  • hathora --version: 0.9.16
  • node -v: v16.16.0
  • npm -v: 8.14.0

If required I can make my repo public 😄 Any help would be appreciated

Space bars in the path to my projects directory throws error

The error that is thrown is ERR_MODULE_NOT_FOUND which gets called in my global install of hathora at:
AppData\Roaming\nvm\v16.14.2\node_modules\hathora\node_modules\ts-node\dist-raw\node-esm-resolve-implementation.js:369

The problem was that I had spacebars in my filepath to my project folder, like this:
C:\Users\paccao\Documents\1 Code\Amongus demo\server.hathora\

It got fixed when changed the spacebars to a dash.

Declaring the Hathora version for the project

I was just trying out https://github.com/hpx7/tussie-mussie and hathora dev fails:

Project root: /tmp/tussie-mussie
Installing dependencies in /tmp/tussie-mussie/api

added 5 packages, and audited 6 packages in 2s

1 package is looking for funding
  run `npm fund` for details

found 0 vulnerabilities
Installing dependencies in /tmp/tussie-mussie/client/.hathora

added 14 packages, and audited 15 packages in 6s

1 package is looking for funding
  run `npm fund` for details

found 0 vulnerabilities
Installing dependencies in /tmp/tussie-mussie/client/prototype-ui
npm WARN deprecated @types/[email protected]: This is a stub types definition. history provides its own type definitions, so you do not need this installed.

added 122 packages, and audited 123 packages in 13s

20 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
Installing dependencies in /tmp/tussie-mussie/client/web

up to date, audited 35 packages in 525ms

found 0 vulnerabilities
Installing dependencies in /tmp/tussie-mussie/client/prototype-ui/plugins/Card

up to date, audited 14 packages in 501ms

found 0 vulnerabilities
Installing dependencies in /tmp/tussie-mussie/server

up to date, audited 2 packages in 468ms

found 0 vulnerabilities
Installing dependencies in /tmp/tussie-mussie/server/.hathora

added 10 packages, and audited 11 packages in 4s

1 package is looking for funding
  run `npm fund` for details

found 0 vulnerabilities
(node:38265) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
Connected to coordinator at coordinator.hathora.dev
Starting frontend at /tmp/tussie-mussie/client/prototype-ui
✘ [ERROR] [plugin vite:dep-scan] Failed to resolve entry for package "/tmp/tussie-mussie/client/prototype-ui/plugins/Card". The package may have incorrect main/module/exports specified in its package.json: Failed to resolve entry for package "/tmp/tussie-mussie/client/prototype-ui/plugins/Card". The package may have incorrect main/module/exports specified in its package.json.

    ../../../../home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/vite/dist/node/chunks/dep-971d9e33.js:29521:10:
      29521 │     throw new Error(`Failed to resolve entry for package "${id}". ` +
            ╵           ^

    at packageEntryFailure (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/vite/dist/node/chunks/dep-971d9e33.js:29521:11)
    at resolvePackageEntry (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/vite/dist/node/chunks/dep-971d9e33.js:29517:9)
    at tryResolveFile (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/vite/dist/node/chunks/dep-971d9e33.js:29247:38)
    at tryFsResolve (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/vite/dist/node/chunks/dep-971d9e33.js:29229:16)
    at Context.resolveId (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/vite/dist/node/chunks/dep-971d9e33.js:29107:28)
    at Object.resolveId (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/vite/dist/node/chunks/dep-971d9e33.js:38255:55)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async resolve (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/vite/dist/node/chunks/dep-971d9e33.js:38458:26)
    at async /home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/vite/dist/node/chunks/dep-971d9e33.js:38644:34
    at async callback (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/esbuild/lib/main.js:920:28)

  This error came from the "onResolve" callback registered here:

    ../../../../home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/vite/dist/node/chunks/dep-971d9e33.js:38640:18:
      38640 │             build.onResolve({
            ╵                   ~~~~~~~~~

    at setup (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/vite/dist/node/chunks/dep-971d9e33.js:38640:19)
    at handlePlugins (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/esbuild/lib/main.js:842:23)
    at Object.buildOrServe (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/esbuild/lib/main.js:1136:7)
    at /home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/esbuild/lib/main.js:2064:17
    at new Promise (<anonymous>)
    at Object.build (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/esbuild/lib/main.js:2063:14)
    at Object.build (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/esbuild/lib/main.js:1913:51)
    at /home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/vite/dist/node/chunks/dep-971d9e33.js:38416:54
    at Array.map (<anonymous>)

  The plugin "vite:dep-scan" was triggered by this import

    ../../client/prototype-ui/State.tsx:7:23:
      7 │ import CardPlugin from "./plugins/Card";
        ╵                        ~~~~~~~~~~~~~~~~

/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/esbuild/lib/main.js:1602
  let error = new Error(`${text}${summary}`);
              ^

Error: Build failed with 1 error:
../../../../home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/vite/dist/node/chunks/dep-971d9e33.js:29521:10: ERROR: [plugin: vite:dep-scan] Failed to resolve entry for package "/tmp/tussie-mussie/client/prototype-ui/plugins/Card". The package may have incorrect main/module/exports specified in its package.json: Failed to resolve entry for package "/tmp/tussie-mussie/client/prototype-ui/plugins/Card". The package may have incorrect main/module/exports specified in its package.json.
    at failureErrorWithLog (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/esbuild/lib/main.js:1602:15)
    at /home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/esbuild/lib/main.js:1248:28
    at runOnEndCallbacks (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/esbuild/lib/main.js:1033:63)
    at buildResponseToResult (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/esbuild/lib/main.js:1246:7)
    at /home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/esbuild/lib/main.js:1355:14
    at /home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/esbuild/lib/main.js:665:9
    at handleIncomingPacket (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/esbuild/lib/main.js:762:9)
    at Socket.readFromStdout (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/esbuild/lib/main.js:632:7)
    at Socket.emit (node:events:390:28)
    at addChunk (node:internal/streams/readable:315:12) {
  errors: [
    {
      detail: Error: Failed to resolve entry for package "/tmp/tussie-mussie/client/prototype-ui/plugins/Card". The package may have incorrect main/module/exports specified in its package.json: Failed to resolve entry for package "/tmp/tussie-mussie/client/prototype-ui/plugins/Card". The package may have incorrect main/module/exports specified in its package.json.
          at packageEntryFailure (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/vite/dist/node/chunks/dep-971d9e33.js:29521:11)
          at resolvePackageEntry (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/vite/dist/node/chunks/dep-971d9e33.js:29517:9)
          at tryResolveFile (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/vite/dist/node/chunks/dep-971d9e33.js:29247:38)
          at tryFsResolve (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/vite/dist/node/chunks/dep-971d9e33.js:29229:16)
          at Context.resolveId (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/vite/dist/node/chunks/dep-971d9e33.js:29107:28)
          at Object.resolveId (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/vite/dist/node/chunks/dep-971d9e33.js:38255:55)
          at processTicksAndRejections (node:internal/process/task_queues:96:5)
          at async resolve (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/vite/dist/node/chunks/dep-971d9e33.js:38458:26)
          at async /home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/vite/dist/node/chunks/dep-971d9e33.js:38644:34
          at async callback (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/esbuild/lib/main.js:920:28),
      location: {
        column: 10,
        file: '../../../../home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/vite/dist/node/chunks/dep-971d9e33.js',
        length: 0,
        line: 29521,
        lineText: '    throw new Error(`Failed to resolve entry for package "${id}". ` +\n' +
          '    at packageEntryFailure (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/vite/dist/node/chunks/dep-971d9e33.js:29521:11)\n' +
          '    at resolvePackageEntry (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/vite/dist/node/chunks/dep-971d9e33.js:29517:9)\n' +
          '    at tryResolveFile (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/vite/dist/node/chunks/dep-971d9e33.js:29247:38)\n' +
          '    at tryFsResolve (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/vite/dist/node/chunks/dep-971d9e33.js:29229:16)\n' +
          '    at Context.resolveId (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/vite/dist/node/chunks/dep-971d9e33.js:29107:28)\n' +
          '    at Object.resolveId (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/vite/dist/node/chunks/dep-971d9e33.js:38255:55)\n' +
          '    at processTicksAndRejections (node:internal/process/task_queues:96:5)\n' +
          '    at async resolve (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/vite/dist/node/chunks/dep-971d9e33.js:38458:26)\n' +
          '    at async /home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/vite/dist/node/chunks/dep-971d9e33.js:38644:34\n' +
          '    at async callback (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/esbuild/lib/main.js:920:28)',
        namespace: 'file',
        suggestion: ''
      },
      notes: [
        {
          location: {
            column: 18,
            file: '../../../../home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/vite/dist/node/chunks/dep-971d9e33.js',
            length: 9,
            line: 38640,
            lineText: '            build.onResolve({\n' +
              '    at setup (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/vite/dist/node/chunks/dep-971d9e33.js:38640:19)\n' +
              '    at handlePlugins (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/esbuild/lib/main.js:842:23)\n' +
              '    at Object.buildOrServe (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/esbuild/lib/main.js:1136:7)\n' +
              '    at /home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/esbuild/lib/main.js:2064:17\n' +
              '    at new Promise (<anonymous>)\n' +
              '    at Object.build (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/esbuild/lib/main.js:2063:14)\n' +
              '    at Object.build (/home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/esbuild/lib/main.js:1913:51)\n' +
              '    at /home/kaspar/.nvm/versions/node/v16.13.2/lib/node_modules/hathora/node_modules/vite/dist/node/chunks/dep-971d9e33.js:38416:54\n' +
              '    at Array.map (<anonymous>)',
            namespace: 'file',
            suggestion: ''
          },
          text: 'This error came from the "onResolve" callback registered here:'
        },
        {
          location: {
            column: 23,
            file: '../../client/prototype-ui/State.tsx',
            length: 16,
            line: 7,
            lineText: 'import CardPlugin from "./plugins/Card";',
            namespace: '',
            suggestion: ''
          },
          text: 'The plugin "vite:dep-scan" was triggered by this import'
        }
      ],
      pluginName: 'vite:dep-scan',
      text: 'Failed to resolve entry for package "/tmp/tussie-mussie/client/prototype-ui/plugins/Card". The package may have incorrect main/module/exports specified in its package.json: Failed to resolve entry for package "/tmp/tussie-mussie/client/prototype-ui/plugins/Card". The package may have incorrect main/module/exports specified in its package.json.'
    }
  ],
  warnings: []
}

I'm guessing it was written for an older version of Hathora but there's no way to find out which.

One solution could be a top-level package.json and you always do npm run hathora (or maybe global hathora does that for you).

{
  "dependencies": {
    "hathora": "^0.5.19"
  },
  "scripts": {
    "hathora": "hathora"
  }
}

A less appealing but simpler solution would be to embed a version in hathora.yml and simply fail if hathora doesn't match.

Server has to be run from dist/server directory

Two issues related to this that I ran into:

  1. I was doing DATA_DIR=./data node dist/server/index.js and that wasn't picking up the .env (maybe just use a env.mjs or env.json file and import it in the index.mjs?)
  2. It never complained about a missing app secret

Typed events

Events should be defined in the yml and potentially have data associated with them

Then you can use it like this:

ctx.sendEvent(Event.Foo, {foo: "Bar"}, userId)

Uncaught RangeError: Offset is outside the bounds of the DataView

Hey, I'm seeing this error since adding a createdBy property to my state. If I remove that property it goes away. Any ideas what that's about?

Uncaught RangeError: Offset is outside the bounds of the DataView
    at DataView.getUint32 (<anonymous>)
    at Reader.readUInt32 (:3001/node_modules/.vite/bin-serde.js?v=c1087c99:271:31)
    at :3001/@fs/home/kaspar/projects/calm-go/code/api/types.ts:374:22
    at Array.map (<anonymous>)
    at decodeStateUpdate (:3001/@fs/home/kaspar/projects/calm-go/code/api/types.ts:373:50)
    at WebSocket.HathoraConnection.socket.onmessage (:3001/@fs/home/kaspar/projects/calm-go/code/client/.hathora/client.ts:63:63)

Can't build examples: "Unable to compile TypeScript"

I clones the project & installed npm. I also installed hathora using rpm.

Afterwards I navigate to the Pong (and Uno) directories and try to run hathora dev.

During the build an error occurs: Argument of type 'string' is not assignable to parameter of type 'Context'

The specific error I get when trying to build Uno & Pong is as follows:

/usr/local/lib/node_modules/hathora/node_modules/ts-node/src/index.ts:820
    return new TSError(diagnosticText, diagnosticCodes);
           ^
TSError: ⨯ Unable to compile TypeScript:
wrapper.ts(20,35): error TS2345: Argument of type 'string' is not assignable to parameter of type 'Context'.

    at createTSError (/usr/local/lib/node_modules/hathora/node_modules/ts-node/src/index.ts:820:12)
    at reportTSError (/usr/local/lib/node_modules/hathora/node_modules/ts-node/src/index.ts:824:19)
    at getOutput (/usr/local/lib/node_modules/hathora/node_modules/ts-node/src/index.ts:1014:36)
    at Object.compile (/usr/local/lib/node_modules/hathora/node_modules/ts-node/src/index.ts:1322:43)
    at transformSource (/usr/local/lib/node_modules/hathora/node_modules/ts-node/src/esm.ts:380:37)
    at load (/usr/local/lib/node_modules/hathora/node_modules/ts-node/src/esm.ts:280:51)
    at async ESMLoader.load (node:internal/modules/esm/loader:407:20)
    at async ESMLoader.moduleProvider (node:internal/modules/esm/loader:326:11) {
  diagnosticCodes: [ 2345 ]
}

tsconfig in `.hathora` is different from one in `server`

I have some type errors I'd like to work around with tsconfig settings on calm-go but I can't. It seems tsconfig is not being carried to the one in .hathora.

You should be able to reproduce by building running calm-go hathora-tsconfig branch and running npx hathora dev. You'll get a type error about implicitly 'any' type but I'm setting "noImplicitAny": false in tsconfig (but it doesn't get set in .hathora/tsconfig.json).

Listing games on the client

I'd like to list all the games on the home page. Ideally I'd also want to add a "private" property to the GameState/InternalState and filter those out of the list on the server. (Discussed on Discord.)

Why mutability ?

Coming from non-game environments (FP inspired Javascript notably, like well known flux architecture or even react at its core); I was heavily surprised the philosophy of State update has mutation at its core.

To challenge that, asking here a naive but important question :

Why not taking a non-mutative approach ?
ie

  onTick(prevState: InternalState, ctx: Context, timeDelta: number): InternalState {
    return {
      ...prevState,
      testValue: 1
    }
  }

instead of

  onTick(state: InternalState, ctx: Context, timeDelta: number): void {
    state.testValue = 1
  }

IMHO, this approach is broadly proven to be more easily testable and determinism-friendly

Support bigint

if I have a type foo: int in hathora.yml, I should be able to use foo: bigint in the server InternalState and it should work

`hathora init` throws an error

Was about to try making a project from scratch, and discovered that hathora init fails with this error:

<path>/node_modules/hathora/cli.js:28
        throw new Error("Doesn't appear to be inside a hathora project");
        ^

Error: Doesn't appear to be inside a hathora project
    at getProjectRoot (<path>/node_modules/hathora/cli.js:28:15)
    at getProjectRoot (<path>/node_modules/hathora/cli.js:30:12)
    at getProjectRoot (<path>/node_modules/hathora/cli.js:30:12)
    at getProjectRoot (<path>/node_modules/hathora/cli.js:30:12)
    at getProjectRoot (<path>/node_modules/hathora/cli.js:30:12)
    at getProjectRoot (<path>/node_modules/hathora/cli.js:30:12)
    at Object.<anonymous> (<path>/node_modules/hathora/cli.js:132:17)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)

Looks like the issue is that cli.ts (line 140) calls getProjectRoot at the top level of the file, but in the init scenario hathora.yml doesn't exist yet - and so it throws.

Additionally, running hathora --help throws the same error - which makes it hard to understand what is expected as a new user - since it's unclear what a 'hathora project' is yet.

Dependencies within monorepo are not loaded

Hathora is not loading installing dependencies from packages within the monorepo

Demo repo: https://github.com/philihp/hathora-et-labora/tree/69b1a8dfe3828544a1580d35ff0eef46c679057f

The package has a dependency declared at https://github.com/philihp/hathora-et-labora/blob/69b1a8dfe3828544a1580d35ff0eef46c679057f/game/package.json
and loaded at
https://github.com/philihp/hathora-et-labora/blob/69b1a8dfe3828544a1580d35ff0eef46c679057f/game/src/commands/start.ts

file:///Users/philihp/work/hathora-et-labora/game/src/commands/start.ts:34
  const shuffledColors = fastShuffle(playerOrderSeed, colors)
                         ^
TypeError: fastShuffle is not a function
    at start (file:///Users/philihp/work/hathora-et-labora/game/src/commands/start.ts:34:26)
    at handler (file:///Users/philihp/work/hathora-et-labora/game/src/reducer.ts:101:7)
    at n.run (file:///Users/philihp/work/hathora-et-labora/game/node_modules/ts-pattern/src/match.ts:162:12)
    at n.e.otherwise (file:///Users/philihp/work/hathora-et-labora/game/node_modules/ts-pattern/src/match.ts:131:7)
    at reducer (file:///Users/philihp/work/hathora-et-labora/game/src/reducer.ts:106:6)
    at Impl.start (file:///Users/philihp/work/hathora-et-labora/server/impl.ts:88:22)
    at ImplWrapper._getResult (file:///Users/philihp/work/hathora-et-labora/server/.hathora/wrapper.ts:50:21)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async ImplWrapper.getResult (file:///Users/philihp/work/hathora-et-labora/server/.hathora/wrapper.ts:29:17)
    at async Store.onMessage (file:///Users/philihp/work/hathora-et-labora/server/.hathora/store.ts:106:22)

Specifically for this case, I could dependency-inject a chance.js from impl, but the problem will still exist for other dependencies.

Could you advise what the correct way to include dependencies in a game is? Should game logic be kept as external dependencies?

Where to put custom_typings for server?

I'm trying to add some typings for an untyped module in the server. (@sabaki/deadstones, here's the branch where it's failing)

error TS7016: Could not find a declaration file for module '@sabaki/deadstones'.
  1. Tried adding server/custom_typings/@sabaki/deadstones.d.ts
  2. Tried copying the folder to server/.hathora/custom_typings
  3. Tried adding "typeRoots": ["./node_modules/@types", "./custom_typings"] to server/tsconfig.json
  4. Tried setting "strict": false in server/tsconfig.json (it doesn't actually even seem to propagate to server/.hathora/tsconfig.json?)

Nothing seems to be working. Still fairly new to Typescript so may be missing something.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.