Skip to content

Commit

Permalink
Add test workspaces and examples to monorepo design (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
lugehorsam committed Mar 6, 2023
1 parent 50e8869 commit 5382b9d
Show file tree
Hide file tree
Showing 13 changed files with 27,107 additions and 782 deletions.
27,830 changes: 27,073 additions & 757 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion package.json
Expand Up @@ -28,7 +28,12 @@
"private": true,
"workspaces": [
"packages/nakama-js",
"packages/nakama-js-test",
"packages/satori-js",
"packages/satori-js-test",
"packages/nakama-js-create-react-app-example",
"packages/nakama-js-iife-example",
"packages/nakama-js-protobuf",
"packages/satori-js"
"packages/nakama-js-webpack-example"
]
}
2 changes: 1 addition & 1 deletion packages/nakama-js-test/client-group.test.ts
Expand Up @@ -309,7 +309,7 @@ describe('Group Tests', () => {
expect(result.user_groups![0].group!.edge_count).toBe(2);
});

it('should create closed, request to join, promote, then list user groups and see count affected', async () => {
it('should create closed group, request to join, promote, then list user groups and see count affected', async () => {
const page : Page = await createPage();

const customid1 = generateid();
Expand Down
7 changes: 4 additions & 3 deletions packages/nakama-js-test/package.json
Expand Up @@ -5,9 +5,10 @@
"private": true,
"license": "Apache-2.0",
"dependencies": {
"@heroiclabs/nakama-js": "2.6.0",
"@heroiclabs/nakama-js-protobuf": "1.3.0",
"merge": "^2.1.1"
"@heroiclabs/nakama-js": "file:../nakama-js",
"@heroiclabs/nakama-js-protobuf": "file:../nakama-js-protobuf",
"merge": "^2.1.1",
"base64url": "3.0.1"
},
"devDependencies": {
"@types/expect-puppeteer": "^4.4.5",
Expand Down
2 changes: 1 addition & 1 deletion packages/nakama-js-webpack-example/package.json
Expand Up @@ -5,7 +5,7 @@
"private": true,
"license": "Apache-2.0",
"dependencies": {
"@heroiclabs/nakama-js": "2.5.0",
"@heroiclabs/nakama-js": "file:../nakama-js",
"ts-loader": "^8.0.14",
"webpack": "^5.12.2",
"webpack-cli": "^4.3.1"
Expand Down
7 changes: 4 additions & 3 deletions packages/nakama-js/README.md
Expand Up @@ -162,11 +162,12 @@ Ensure you are using Node v18>.

The codebase is multi-package monorepo written in TypeScript and can be built with [esbuild](https://github.com/evanw/esbuild). All dependencies are managed with NPM.

To build from source, install dependencies and build the `nakama-js` and `nakama-js-protobuf` subrepositories:
To build from source, first install all workspace dependencies from the repository root with `npm install`.

Then to build a specific workspace, pass the `--workspace` flag to your build command, for example:

```shell
npm install --workspace=@heroiclabs/nakama-js --include-workspace-root && npm run build --workspace=@heroiclabs/nakama-js
npm install --workspace=@heroiclabs/nakama-js-protobuf --include-workspace-root && npm run build --workspace=@heroiclabs/nakama-js-protobuf
npm run build --workspace=@heroiclabs/nakama-js
```

### Run Tests
Expand Down
6 changes: 3 additions & 3 deletions packages/nakama-js/dist/nakama-js.cjs.js
Expand Up @@ -3194,7 +3194,7 @@ var _DefaultSocket = class {
reject(evt);
this.adapter.close();
};
window.setTimeout(() => {
setTimeout(() => {
reject("The socket timed out when trying to connect.");
}, connectTimeoutMs);
});
Expand Down Expand Up @@ -3328,7 +3328,7 @@ var _DefaultSocket = class {
}
const cid = this.generatecid();
this.cIds[cid] = { resolve, reject };
window.setTimeout(() => {
setTimeout(() => {
reject("The socket timed out while waiting for a response.");
}, sendTimeout);
untypedMessage.cid = cid;
Expand Down Expand Up @@ -3548,7 +3548,7 @@ var _DefaultSocket = class {
}
return;
}
window.setTimeout(() => this.pingPong(), this._heartbeatTimeoutMs);
setTimeout(() => this.pingPong(), this._heartbeatTimeoutMs);
});
}
};
Expand Down
6 changes: 3 additions & 3 deletions packages/nakama-js/dist/nakama-js.esm.mjs
Expand Up @@ -3168,7 +3168,7 @@ var _DefaultSocket = class {
reject(evt);
this.adapter.close();
};
window.setTimeout(() => {
setTimeout(() => {
reject("The socket timed out when trying to connect.");
}, connectTimeoutMs);
});
Expand Down Expand Up @@ -3302,7 +3302,7 @@ var _DefaultSocket = class {
}
const cid = this.generatecid();
this.cIds[cid] = { resolve, reject };
window.setTimeout(() => {
setTimeout(() => {
reject("The socket timed out while waiting for a response.");
}, sendTimeout);
untypedMessage.cid = cid;
Expand Down Expand Up @@ -3522,7 +3522,7 @@ var _DefaultSocket = class {
}
return;
}
window.setTimeout(() => this.pingPong(), this._heartbeatTimeoutMs);
setTimeout(() => this.pingPong(), this._heartbeatTimeoutMs);
});
}
};
Expand Down
6 changes: 3 additions & 3 deletions packages/nakama-js/dist/nakama-js.iife.js
Expand Up @@ -3194,7 +3194,7 @@ var nakamajs = (() => {
reject(evt);
this.adapter.close();
};
window.setTimeout(() => {
setTimeout(() => {
reject("The socket timed out when trying to connect.");
}, connectTimeoutMs);
});
Expand Down Expand Up @@ -3328,7 +3328,7 @@ var nakamajs = (() => {
}
const cid = this.generatecid();
this.cIds[cid] = { resolve, reject };
window.setTimeout(() => {
setTimeout(() => {
reject("The socket timed out while waiting for a response.");
}, sendTimeout);
untypedMessage.cid = cid;
Expand Down Expand Up @@ -3548,7 +3548,7 @@ var nakamajs = (() => {
}
return;
}
window.setTimeout(() => this.pingPong(), this._heartbeatTimeoutMs);
setTimeout(() => this.pingPong(), this._heartbeatTimeoutMs);
});
}
};
Expand Down
6 changes: 3 additions & 3 deletions packages/nakama-js/dist/nakama-js.umd.js
Expand Up @@ -3924,7 +3924,7 @@
reject(evt);
_this.adapter.close();
};
window.setTimeout(function () {
setTimeout(function () {
// if promise has resolved by now, the reject() is a no-op
reject("The socket timed out when trying to connect.");
}, connectTimeoutMs);
Expand Down Expand Up @@ -4066,7 +4066,7 @@
}
var cid = _this.generatecid();
_this.cIds[cid] = { resolve: resolve, reject: reject };
window.setTimeout(function () {
setTimeout(function () {
reject("The socket timed out while waiting for a response.");
}, sendTimeout);
/** Add id for promise executor. */
Expand Down Expand Up @@ -4396,7 +4396,7 @@
case 4:
// reuse the timeout as the interval for now.
// we can separate them out into separate values if needed later.
window.setTimeout(function () { return _this.pingPong(); }, this._heartbeatTimeoutMs);
setTimeout(function () { return _this.pingPong(); }, this._heartbeatTimeoutMs);
return [2 /*return*/];
}
});
Expand Down
6 changes: 3 additions & 3 deletions packages/nakama-js/socket.ts
Expand Up @@ -838,7 +838,7 @@ export class DefaultSocket implements Socket {
}


window.setTimeout(() => {
setTimeout(() => {
// if promise has resolved by now, the reject() is a no-op
reject("The socket timed out when trying to connect.");
}, connectTimeoutMs);
Expand Down Expand Up @@ -1007,7 +1007,7 @@ export class DefaultSocket implements Socket {

const cid = this.generatecid();
this.cIds[cid] = {resolve, reject};
window.setTimeout(() => {
setTimeout(() => {
reject("The socket timed out while waiting for a response.")
}, sendTimeout);

Expand Down Expand Up @@ -1238,6 +1238,6 @@ export class DefaultSocket implements Socket {

// reuse the timeout as the interval for now.
// we can separate them out into separate values if needed later.
window.setTimeout(() => this.pingPong(), this._heartbeatTimeoutMs);
setTimeout(() => this.pingPong(), this._heartbeatTimeoutMs);
}
};
3 changes: 2 additions & 1 deletion packages/satori-js-test/package.json
Expand Up @@ -5,7 +5,8 @@
"private": true,
"license": "Apache-2.0",
"dependencies": {
"@heroiclabs/satori-js": "2.5.2"
"@heroiclabs/satori-js": "file:../satori-js",
"base64url": "3.0.1"
},
"scripts": {
"test": "npx typescript --project tsconfig.test.json && jest --runInBand"
Expand Down
1 change: 1 addition & 0 deletions tsconfig.base.json
Expand Up @@ -25,6 +25,7 @@
"strictNullChecks": true,
"strictFunctionTypes": true,
"alwaysStrict": true,
"skipLibCheck": true
},
"exclude": [
"node_modules"
Expand Down

0 comments on commit 5382b9d

Please sign in to comment.