hytopia 0.1.13 → 0.1.15

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -29,29 +29,24 @@ With these resources, you can quickly build and share immersive, voxel-style mul
29
29
 
30
30
  ## Quickstart
31
31
 
32
- 1. Install a compatible JavaScript runtime. We recommend [Bun (recommended)](https://bun.sh/), but [Node.js](https://nodejs.org/) and [Deno](https://deno.com/) are also supported. All examples will be given using Bun.
32
+ 1. Install a compatible JavaScript runtime. We recommend you use [Bun](https://bun.sh/), but [Node.js](https://nodejs.org/) and [Deno](https://deno.com/) can work with additional configuration. All examples will be given using Bun.
33
33
 
34
- 2. If you're starting a new project, initialize it.
34
+ 2. Create a new project directory somewhere on your machine and navigate into it.
35
35
  ```bash
36
- bun init
36
+ mkdir my-project-directory && cd my-project-directory
37
37
  ```
38
38
 
39
- 3. Install the SDK in a new or existing project.
40
- ```bash
41
- bun add hytopia
42
- ```
43
-
44
- 4. Initialize boilerplate. Copies assets and an index.ts game script into your project.
39
+ 3. Initialize a hytopia project. Sets up package.json and all dependencies, copies assets and an index.ts game script into your project.
45
40
  ```bash
46
41
  bunx hytopia init
47
42
  ```
48
43
 
49
- 5. Start the server, use --watch for hot reloads as you make changes.
44
+ 3. Start the server, use --watch for hot reloads as you make changes.
50
45
  ```bash
51
46
  bun --watch index.ts
52
47
  ```
53
48
 
54
- 6. Visit https://play.hytopia.com - when prompted, enter `localhost:8080` - this is the hostname of the local server you started in the previous step.
49
+ 4. Visit https://play.hytopia.com - when prompted, enter `localhost:8080` - this is the hostname of the local server you started in the previous step.
55
50
 
56
51
  Once you're up and running, here's some other resources to go further:
57
52
  - [Game Examples](./examples)
package/bin/scripts.js CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ const { execSync } = require('child_process');
3
4
  const fs = require('fs');
4
5
  const path = require('path');
5
- const mkcert = require('mkcert');
6
6
 
7
7
  (async () => {
8
8
  const command = process.argv[2];
@@ -10,35 +10,23 @@ const mkcert = require('mkcert');
10
10
  /**
11
11
  * Init command
12
12
  *
13
- * Initializes a new HYTOPIA project.
13
+ * Initializes a new HYTOPIA project. Accepting an optional
14
+ * project name as an argument.
15
+ *
16
+ * @example
17
+ * `bunx hytopia init my-project-name`
14
18
  */
15
19
  if (command === 'init') {
16
20
  const srcDir = path.join(__dirname, '..', 'boilerplate');
17
21
  const destDir = process.cwd();
18
-
22
+
23
+ // Initialize project
24
+ execSync('bun init --yes');
25
+ execSync('bun add hytopia');
26
+
19
27
  // Copy boilerplate
20
28
  console.log(`🖨️ Copying boilerplate to ${destDir}`);
21
29
  fs.cpSync(srcDir, destDir, { recursive: true });
22
-
23
- // Generate SSL cert and allow mkcert to auto handle CA/Cert setup
24
- console.log(`🔒 Generating SSL cert for local development`);
25
- const validity = 3650; // 10 years
26
- const ca = await mkcert.createCA({
27
- organization: 'HYTOPIA',
28
- countryCode: 'US',
29
- state: 'Washington',
30
- locality: 'Seattle',
31
- validity,
32
- });
33
-
34
- const cert = await mkcert.createCert({
35
- ca: { key: ca.key, cert: ca.cert },
36
- domains: ['localhost', '127.0.0.1'],
37
- validity,
38
- });
39
-
40
- fs.writeFileSync(path.join(destDir, 'assets', 'certs', 'localhost.crt'), cert.cert);
41
- fs.writeFileSync(path.join(destDir, 'assets', 'certs', 'localhost.key'), cert.key);
42
30
 
43
31
  // Done, lfg!
44
32
  console.log('🚀 Hytopia project initialized successfully!');
@@ -1,6 +1,11 @@
1
- For local development, mkcert generated certs will be stored here.
2
- We do this to allow https://localhost & wss://localhost support.
3
- Without this, play.hytopia.com requires a bunch of funky browser
4
- flag workarounds in order to connect to our local server.
5
- This is only used for local development and will be ignored
6
- when your game is deployed to HYTOPIA servers.
1
+ For local development self-signed certs are stored here.
2
+ The server when GameServer.instance.webServer.enableLocalSSL();
3
+ is used, will look for assets/certs/localhost.key and
4
+ assets/certs/localhost.cert and use those for SSL.
5
+
6
+ We use these self-signed certs to allow https://localhost
7
+ & wss://localhost support. Without this, play.hytopia.com
8
+ requires a bunch of funky browser flag workarounds in
9
+ order to connect to your local server. This is only used
10
+ for local development and will be ignored when your game
11
+ is deployed to HYTOPIA servers.
@@ -0,0 +1,20 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIDRjCCAi6gAwIBAgIFOTEzNTIwDQYJKoZIhvcNAQELBQAwWDEQMA4GA1UEAxMH
3
+ SFlUT1BJQTELMAkGA1UEBhMCVVMxEzARBgNVBAgTCldhc2hpbmd0b24xEDAOBgNV
4
+ BAcTB1NlYXR0bGUxEDAOBgNVBAoTB0hZVE9QSUEwHhcNMjQxMTEzMjIyMjEwWhcN
5
+ MzQxMTExMjIyMjEwWjAUMRIwEAYDVQQDEwlsb2NhbGhvc3QwggEiMA0GCSqGSIb3
6
+ DQEBAQUAA4IBDwAwggEKAoIBAQCo2i9L13+4KxvR9dxBeE3Xrj5WtoGFBwbUZkeV
7
+ 3B8n+ehJ2LWD13sGvCuHvSDovbSOxLxqbESQzWBRVrmfJMR1qe+o7kd/SMaLHosC
8
+ 2BWASn1oV9rGLktvd2Xs6xRf75cejzrr/OrNoTpICp3j1Z0Kd+73TuYyVFPfCbqH
9
+ N6mwS+yCmG2/w3sXwbOGymNuYpaPoD8XVcIhO7GPZsCVqqSKP2xsGF+oP5+Isma+
10
+ y3usNUnFnVW5ckk6SWWdxP9kuOW2xXoFFwj43STaE4OvXbTPCG7jowUpDH1aMvFA
11
+ ceXUfuaE7H8QfZqoUNu8jCb8LiqTL+uL5kHbl2kQ7sQCN9gjAgMBAAGjWzBZMAwG
12
+ A1UdEwEB/wQCMAAwDgYDVR0PAQH/BAQDAgWgMB0GA1UdJQQWMBQGCCsGAQUFBwMB
13
+ BggrBgEFBQcDAjAaBgNVHREEEzARgglsb2NhbGhvc3SHBH8AAAEwDQYJKoZIhvcN
14
+ AQELBQADggEBAHSINJsVuu11kmzx7/2yEiDSIQVzdzk/+hnx0iQt6rDy9ZNVdI8w
15
+ JOUYaPjxDFfZ5gaPqrlb0n248lBMdGrp6xmhbgXL8e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Ktu
13
+ liBmYxkCgYEA4VDPtFAGnChCTGLVwo7MKmH6/KU5Qj2fuufGNw8jcW3H0Ea52OFC
14
+ qOGA9pRJVXCap7Wa7XCJXENLYWpSfB7H7GnhFLwHw7jAVB52DLDCdUnRv5fP3o8K
15
+ xEseMJQaJm95eFVfTETcnjDixWtIzNbXULQbGjF3AY74aFjc1fhc/yUCgYEAv9jj
16
+ Zrc+UzR0oi00Ip8O5C5Uvu2W35M+j2XoV/xPkX+Hcr12U40Gnc/rnzVp2lGTwNZS
17
+ ImQcjLEd31qLOy90F9lcaKvOfgcx0JvGEp5SdzQQaS3RJqn0xWLh1O4NMsiVbLNi
18
+ Zi5qFv7pW/DO174xSa7cMVE8qp8YHAOZdpcqm6cCgYB9FL2ZnetteTQE78E3NsrE
19
+ pIwPATIeQdOQkOaK3k6Qw57vUrQNYE//LODJAl0Ln21buQd+1MCMhZctRzbvTK8z
20
+ 4TtgpVmyH7g1eouSU/Y/4nEcaYyuQr55ZjImSbGSsMPAN7SlxHytHPpnGj3Z6VKy
21
+ rKl3CwrDxLjGRL6j0jLeOQKBgBiu3xMoIGy0Iw16o2qQ7GmPTHgEOZUqbLImem5X
22
+ mCUwM00f80lsq51CUx540NW2CTyWVpr2JnYzk5RZIfDLejRXUvxknny4kEA2ypU6
23
+ qYGMwU/HBVHkLAn5XvT2a9xM0mzZ558d+ahbw8qAgRxg7BZ+2PW/bf7F2WRBUk1f
24
+ xauhAoGBALEspoxQozwohGQnP7EMF0/0JoKNpdNv0b0qCVvNiMo0+N297lI2mFQp
25
+ 6xYlW/1l9afLokklF/J2IsyBrTCZoY7SaEk/lMMrQSyra+y0z71ogZ8A4ny9fxsj
26
+ 0dDYJZGllL+3E/MQfd7k+KnOM/+A+cPoAnci76+L3vdkUb2P8SJk
27
+ -----END RSA PRIVATE KEY-----
@@ -733,6 +733,17 @@ Description
733
733
  The default rigid body options when EntityOptions.rigidBodyOptions is not provided.
734
734
 
735
735
 
736
+ </td></tr>
737
+ <tr><td>
738
+
739
+ [PORT](./server.hytopia.port.md)
740
+
741
+
742
+ </td><td>
743
+
744
+ The port the server will listen on. You can override this in your .env by setting PORT.
745
+
746
+
736
747
  </td></tr>
737
748
  <tr><td>
738
749
 
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [server](./server.md) &gt; [HYTOPIA](./server.hytopia.md) &gt; [PORT](./server.hytopia.port.md)
4
+
5
+ ## HYTOPIA.PORT variable
6
+
7
+ The port the server will listen on. You can override this in your .env by setting PORT.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ PORT: string | number
13
+ ```
package/docs/server.md CHANGED
@@ -742,6 +742,17 @@ Description
742
742
  The default rigid body options when EntityOptions.rigidBodyOptions is not provided.
743
743
 
744
744
 
745
+ </td></tr>
746
+ <tr><td>
747
+
748
+ [PORT](./server.port.md)
749
+
750
+
751
+ </td><td>
752
+
753
+ The port the server will listen on. You can override this in your .env by setting PORT.
754
+
755
+
745
756
  </td></tr>
746
757
  <tr><td>
747
758
 
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [server](./server.md) &gt; [PORT](./server.port.md)
4
+
5
+ ## PORT variable
6
+
7
+ The port the server will listen on. You can override this in your .env by setting PORT.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ PORT: string | number
13
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hytopia",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "The HYTOPIA SDK makes it easy for developers to create multiplayer games on the HYTOPIA platform using JavaScript or TypeScript.",
5
5
  "main": "server.js",
6
6
  "bin": {
@@ -46,8 +46,5 @@
46
46
  "bugs": {
47
47
  "url": "https://github.com/hytopiagg/sdk/issues"
48
48
  },
49
- "homepage": "https://github.com/hytopiagg/sdk#readme",
50
- "dependencies": {
51
- "mkcert": "^3.2.0"
52
- }
49
+ "homepage": "https://github.com/hytopiagg/sdk#readme"
53
50
  }
package/server.api.json CHANGED
@@ -23998,6 +23998,29 @@
23998
23998
  "endIndex": 2
23999
23999
  }
24000
24000
  },
24001
+ {
24002
+ "kind": "Variable",
24003
+ "canonicalReference": "server!HYTOPIA.PORT:var",
24004
+ "docComment": "/**\n * The port the server will listen on. You can override this in your .env by setting PORT.\n */\n",
24005
+ "excerptTokens": [
24006
+ {
24007
+ "kind": "Content",
24008
+ "text": "PORT: "
24009
+ },
24010
+ {
24011
+ "kind": "Content",
24012
+ "text": "string | number"
24013
+ }
24014
+ ],
24015
+ "fileUrlPath": "src/networking/WebServer.ts",
24016
+ "isReadonly": true,
24017
+ "releaseTag": "Public",
24018
+ "name": "PORT",
24019
+ "variableTypeTokenRange": {
24020
+ "startIndex": 1,
24021
+ "endIndex": 2
24022
+ }
24023
+ },
24001
24024
  {
24002
24025
  "kind": "TypeAlias",
24003
24026
  "canonicalReference": "server!HYTOPIA.RawCollisionGroups:type",
@@ -30799,6 +30822,29 @@
30799
30822
  "endIndex": 2
30800
30823
  }
30801
30824
  },
30825
+ {
30826
+ "kind": "Variable",
30827
+ "canonicalReference": "server!PORT:var",
30828
+ "docComment": "/**\n * The port the server will listen on. You can override this in your .env by setting PORT.\n */\n",
30829
+ "excerptTokens": [
30830
+ {
30831
+ "kind": "Content",
30832
+ "text": "PORT: "
30833
+ },
30834
+ {
30835
+ "kind": "Content",
30836
+ "text": "string | number"
30837
+ }
30838
+ ],
30839
+ "fileUrlPath": "src/networking/WebServer.ts",
30840
+ "isReadonly": true,
30841
+ "releaseTag": "Public",
30842
+ "name": "PORT",
30843
+ "variableTypeTokenRange": {
30844
+ "startIndex": 1,
30845
+ "endIndex": 2
30846
+ }
30847
+ },
30802
30848
  {
30803
30849
  "kind": "TypeAlias",
30804
30850
  "canonicalReference": "server!RawCollisionGroups:type",
package/server.d.ts CHANGED
@@ -1618,6 +1618,7 @@ declare namespace HYTOPIA {
1618
1618
  RigidBodyOptions,
1619
1619
  Simulation,
1620
1620
  WebServer,
1621
+ PORT,
1621
1622
  World,
1622
1623
  WorldMap,
1623
1624
  WorldOptions,
@@ -1800,6 +1801,9 @@ export declare type PlayerOrientationState = {
1800
1801
  yaw: number;
1801
1802
  };
1802
1803
 
1804
+ /** The port the server will listen on. You can override this in your .env by setting PORT. */
1805
+ export declare const PORT: string | number;
1806
+
1803
1807
  /** A raw set of collision groups represented as a 32-bit number. @public */
1804
1808
  export declare type RawCollisionGroups = RAPIER.InteractionGroups;
1805
1809