Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test workspaces and examples to monorepo design #149

Merged
merged 7 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"strictNullChecks": true,
"strictFunctionTypes": true,
"alwaysStrict": true,
"skipLibCheck": true
},
"exclude": [
"node_modules"
Expand Down